| [ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Summary view] [Print] [Text view]
1 "use strict"; 2 var wp; 3 (wp ||= {}).blockEditor = (() => { 4 var __create = Object.create; 5 var __defProp = Object.defineProperty; 6 var __getOwnPropDesc = Object.getOwnPropertyDescriptor; 7 var __getOwnPropNames = Object.getOwnPropertyNames; 8 var __getProtoOf = Object.getPrototypeOf; 9 var __hasOwnProp = Object.prototype.hasOwnProperty; 10 var __commonJS = (cb, mod) => function __require() { 11 return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; 12 }; 13 var __export = (target, all) => { 14 for (var name in all) 15 __defProp(target, name, { get: all[name], enumerable: true }); 16 }; 17 var __copyProps = (to2, from, except, desc) => { 18 if (from && typeof from === "object" || typeof from === "function") { 19 for (let key of __getOwnPropNames(from)) 20 if (!__hasOwnProp.call(to2, key) && key !== except) 21 __defProp(to2, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); 22 } 23 return to2; 24 }; 25 var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( 26 // If the importer is in node compatibility mode or this is not an ESM 27 // file that has been converted to a CommonJS file using a Babel- 28 // compatible transform (i.e. "__esModule" has not been set), then set 29 // "default" to the CommonJS "module.exports" for node compatibility. 30 isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, 31 mod 32 )); 33 var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); 34 35 // package-external:@wordpress/blocks 36 var require_blocks = __commonJS({ 37 "package-external:@wordpress/blocks"(exports, module) { 38 module.exports = window.wp.blocks; 39 } 40 }); 41 42 // package-external:@wordpress/element 43 var require_element = __commonJS({ 44 "package-external:@wordpress/element"(exports, module) { 45 module.exports = window.wp.element; 46 } 47 }); 48 49 // package-external:@wordpress/data 50 var require_data = __commonJS({ 51 "package-external:@wordpress/data"(exports, module) { 52 module.exports = window.wp.data; 53 } 54 }); 55 56 // package-external:@wordpress/compose 57 var require_compose = __commonJS({ 58 "package-external:@wordpress/compose"(exports, module) { 59 module.exports = window.wp.compose; 60 } 61 }); 62 63 // package-external:@wordpress/hooks 64 var require_hooks = __commonJS({ 65 "package-external:@wordpress/hooks"(exports, module) { 66 module.exports = window.wp.hooks; 67 } 68 }); 69 70 // package-external:@wordpress/components 71 var require_components = __commonJS({ 72 "package-external:@wordpress/components"(exports, module) { 73 module.exports = window.wp.components; 74 } 75 }); 76 77 // package-external:@wordpress/private-apis 78 var require_private_apis = __commonJS({ 79 "package-external:@wordpress/private-apis"(exports, module) { 80 module.exports = window.wp.privateApis; 81 } 82 }); 83 84 // package-external:@wordpress/deprecated 85 var require_deprecated = __commonJS({ 86 "package-external:@wordpress/deprecated"(exports, module) { 87 module.exports = window.wp.deprecated; 88 } 89 }); 90 91 // vendor-external:react/jsx-runtime 92 var require_jsx_runtime = __commonJS({ 93 "vendor-external:react/jsx-runtime"(exports, module) { 94 module.exports = window.ReactJSXRuntime; 95 } 96 }); 97 98 // package-external:@wordpress/url 99 var require_url = __commonJS({ 100 "package-external:@wordpress/url"(exports, module) { 101 module.exports = window.wp.url; 102 } 103 }); 104 105 // package-external:@wordpress/i18n 106 var require_i18n = __commonJS({ 107 "package-external:@wordpress/i18n"(exports, module) { 108 module.exports = window.wp.i18n; 109 } 110 }); 111 112 // node_modules/fast-deep-equal/es6/index.js 113 var require_es6 = __commonJS({ 114 "node_modules/fast-deep-equal/es6/index.js"(exports, module) { 115 "use strict"; 116 module.exports = function equal(a2, b2) { 117 if (a2 === b2) return true; 118 if (a2 && b2 && typeof a2 == "object" && typeof b2 == "object") { 119 if (a2.constructor !== b2.constructor) return false; 120 var length, i2, keys; 121 if (Array.isArray(a2)) { 122 length = a2.length; 123 if (length != b2.length) return false; 124 for (i2 = length; i2-- !== 0; ) 125 if (!equal(a2[i2], b2[i2])) return false; 126 return true; 127 } 128 if (a2 instanceof Map && b2 instanceof Map) { 129 if (a2.size !== b2.size) return false; 130 for (i2 of a2.entries()) 131 if (!b2.has(i2[0])) return false; 132 for (i2 of a2.entries()) 133 if (!equal(i2[1], b2.get(i2[0]))) return false; 134 return true; 135 } 136 if (a2 instanceof Set && b2 instanceof Set) { 137 if (a2.size !== b2.size) return false; 138 for (i2 of a2.entries()) 139 if (!b2.has(i2[0])) return false; 140 return true; 141 } 142 if (ArrayBuffer.isView(a2) && ArrayBuffer.isView(b2)) { 143 length = a2.length; 144 if (length != b2.length) return false; 145 for (i2 = length; i2-- !== 0; ) 146 if (a2[i2] !== b2[i2]) return false; 147 return true; 148 } 149 if (a2.constructor === RegExp) return a2.source === b2.source && a2.flags === b2.flags; 150 if (a2.valueOf !== Object.prototype.valueOf) return a2.valueOf() === b2.valueOf(); 151 if (a2.toString !== Object.prototype.toString) return a2.toString() === b2.toString(); 152 keys = Object.keys(a2); 153 length = keys.length; 154 if (length !== Object.keys(b2).length) return false; 155 for (i2 = length; i2-- !== 0; ) 156 if (!Object.prototype.hasOwnProperty.call(b2, keys[i2])) return false; 157 for (i2 = length; i2-- !== 0; ) { 158 var key = keys[i2]; 159 if (!equal(a2[key], b2[key])) return false; 160 } 161 return true; 162 } 163 return a2 !== a2 && b2 !== b2; 164 }; 165 } 166 }); 167 168 // package-external:@wordpress/primitives 169 var require_primitives = __commonJS({ 170 "package-external:@wordpress/primitives"(exports, module) { 171 module.exports = window.wp.primitives; 172 } 173 }); 174 175 // package-external:@wordpress/rich-text 176 var require_rich_text = __commonJS({ 177 "package-external:@wordpress/rich-text"(exports, module) { 178 module.exports = window.wp.richText; 179 } 180 }); 181 182 // package-external:@wordpress/block-serialization-default-parser 183 var require_block_serialization_default_parser = __commonJS({ 184 "package-external:@wordpress/block-serialization-default-parser"(exports, module) { 185 module.exports = window.wp.blockSerializationDefaultParser; 186 } 187 }); 188 189 // package-external:@wordpress/a11y 190 var require_a11y = __commonJS({ 191 "package-external:@wordpress/a11y"(exports, module) { 192 module.exports = window.wp.a11y; 193 } 194 }); 195 196 // package-external:@wordpress/notices 197 var require_notices = __commonJS({ 198 "package-external:@wordpress/notices"(exports, module) { 199 module.exports = window.wp.notices; 200 } 201 }); 202 203 // package-external:@wordpress/preferences 204 var require_preferences = __commonJS({ 205 "package-external:@wordpress/preferences"(exports, module) { 206 module.exports = window.wp.preferences; 207 } 208 }); 209 210 // node_modules/remove-accents/index.js 211 var require_remove_accents = __commonJS({ 212 "node_modules/remove-accents/index.js"(exports, module) { 213 var characterMap = { 214 "\xC0": "A", 215 "\xC1": "A", 216 "\xC2": "A", 217 "\xC3": "A", 218 "\xC4": "A", 219 "\xC5": "A", 220 "\u1EA4": "A", 221 "\u1EAE": "A", 222 "\u1EB2": "A", 223 "\u1EB4": "A", 224 "\u1EB6": "A", 225 "\xC6": "AE", 226 "\u1EA6": "A", 227 "\u1EB0": "A", 228 "\u0202": "A", 229 "\u1EA2": "A", 230 "\u1EA0": "A", 231 "\u1EA8": "A", 232 "\u1EAA": "A", 233 "\u1EAC": "A", 234 "\xC7": "C", 235 "\u1E08": "C", 236 "\xC8": "E", 237 "\xC9": "E", 238 "\xCA": "E", 239 "\xCB": "E", 240 "\u1EBE": "E", 241 "\u1E16": "E", 242 "\u1EC0": "E", 243 "\u1E14": "E", 244 "\u1E1C": "E", 245 "\u0206": "E", 246 "\u1EBA": "E", 247 "\u1EBC": "E", 248 "\u1EB8": "E", 249 "\u1EC2": "E", 250 "\u1EC4": "E", 251 "\u1EC6": "E", 252 "\xCC": "I", 253 "\xCD": "I", 254 "\xCE": "I", 255 "\xCF": "I", 256 "\u1E2E": "I", 257 "\u020A": "I", 258 "\u1EC8": "I", 259 "\u1ECA": "I", 260 "\xD0": "D", 261 "\xD1": "N", 262 "\xD2": "O", 263 "\xD3": "O", 264 "\xD4": "O", 265 "\xD5": "O", 266 "\xD6": "O", 267 "\xD8": "O", 268 "\u1ED0": "O", 269 "\u1E4C": "O", 270 "\u1E52": "O", 271 "\u020E": "O", 272 "\u1ECE": "O", 273 "\u1ECC": "O", 274 "\u1ED4": "O", 275 "\u1ED6": "O", 276 "\u1ED8": "O", 277 "\u1EDC": "O", 278 "\u1EDE": "O", 279 "\u1EE0": "O", 280 "\u1EDA": "O", 281 "\u1EE2": "O", 282 "\xD9": "U", 283 "\xDA": "U", 284 "\xDB": "U", 285 "\xDC": "U", 286 "\u1EE6": "U", 287 "\u1EE4": "U", 288 "\u1EEC": "U", 289 "\u1EEE": "U", 290 "\u1EF0": "U", 291 "\xDD": "Y", 292 "\xE0": "a", 293 "\xE1": "a", 294 "\xE2": "a", 295 "\xE3": "a", 296 "\xE4": "a", 297 "\xE5": "a", 298 "\u1EA5": "a", 299 "\u1EAF": "a", 300 "\u1EB3": "a", 301 "\u1EB5": "a", 302 "\u1EB7": "a", 303 "\xE6": "ae", 304 "\u1EA7": "a", 305 "\u1EB1": "a", 306 "\u0203": "a", 307 "\u1EA3": "a", 308 "\u1EA1": "a", 309 "\u1EA9": "a", 310 "\u1EAB": "a", 311 "\u1EAD": "a", 312 "\xE7": "c", 313 "\u1E09": "c", 314 "\xE8": "e", 315 "\xE9": "e", 316 "\xEA": "e", 317 "\xEB": "e", 318 "\u1EBF": "e", 319 "\u1E17": "e", 320 "\u1EC1": "e", 321 "\u1E15": "e", 322 "\u1E1D": "e", 323 "\u0207": "e", 324 "\u1EBB": "e", 325 "\u1EBD": "e", 326 "\u1EB9": "e", 327 "\u1EC3": "e", 328 "\u1EC5": "e", 329 "\u1EC7": "e", 330 "\xEC": "i", 331 "\xED": "i", 332 "\xEE": "i", 333 "\xEF": "i", 334 "\u1E2F": "i", 335 "\u020B": "i", 336 "\u1EC9": "i", 337 "\u1ECB": "i", 338 "\xF0": "d", 339 "\xF1": "n", 340 "\xF2": "o", 341 "\xF3": "o", 342 "\xF4": "o", 343 "\xF5": "o", 344 "\xF6": "o", 345 "\xF8": "o", 346 "\u1ED1": "o", 347 "\u1E4D": "o", 348 "\u1E53": "o", 349 "\u020F": "o", 350 "\u1ECF": "o", 351 "\u1ECD": "o", 352 "\u1ED5": "o", 353 "\u1ED7": "o", 354 "\u1ED9": "o", 355 "\u1EDD": "o", 356 "\u1EDF": "o", 357 "\u1EE1": "o", 358 "\u1EDB": "o", 359 "\u1EE3": "o", 360 "\xF9": "u", 361 "\xFA": "u", 362 "\xFB": "u", 363 "\xFC": "u", 364 "\u1EE7": "u", 365 "\u1EE5": "u", 366 "\u1EED": "u", 367 "\u1EEF": "u", 368 "\u1EF1": "u", 369 "\xFD": "y", 370 "\xFF": "y", 371 "\u0100": "A", 372 "\u0101": "a", 373 "\u0102": "A", 374 "\u0103": "a", 375 "\u0104": "A", 376 "\u0105": "a", 377 "\u0106": "C", 378 "\u0107": "c", 379 "\u0108": "C", 380 "\u0109": "c", 381 "\u010A": "C", 382 "\u010B": "c", 383 "\u010C": "C", 384 "\u010D": "c", 385 "C\u0306": "C", 386 "c\u0306": "c", 387 "\u010E": "D", 388 "\u010F": "d", 389 "\u0110": "D", 390 "\u0111": "d", 391 "\u0112": "E", 392 "\u0113": "e", 393 "\u0114": "E", 394 "\u0115": "e", 395 "\u0116": "E", 396 "\u0117": "e", 397 "\u0118": "E", 398 "\u0119": "e", 399 "\u011A": "E", 400 "\u011B": "e", 401 "\u011C": "G", 402 "\u01F4": "G", 403 "\u011D": "g", 404 "\u01F5": "g", 405 "\u011E": "G", 406 "\u011F": "g", 407 "\u0120": "G", 408 "\u0121": "g", 409 "\u0122": "G", 410 "\u0123": "g", 411 "\u0124": "H", 412 "\u0125": "h", 413 "\u0126": "H", 414 "\u0127": "h", 415 "\u1E2A": "H", 416 "\u1E2B": "h", 417 "\u0128": "I", 418 "\u0129": "i", 419 "\u012A": "I", 420 "\u012B": "i", 421 "\u012C": "I", 422 "\u012D": "i", 423 "\u012E": "I", 424 "\u012F": "i", 425 "\u0130": "I", 426 "\u0131": "i", 427 "\u0132": "IJ", 428 "\u0133": "ij", 429 "\u0134": "J", 430 "\u0135": "j", 431 "\u0136": "K", 432 "\u0137": "k", 433 "\u1E30": "K", 434 "\u1E31": "k", 435 "K\u0306": "K", 436 "k\u0306": "k", 437 "\u0139": "L", 438 "\u013A": "l", 439 "\u013B": "L", 440 "\u013C": "l", 441 "\u013D": "L", 442 "\u013E": "l", 443 "\u013F": "L", 444 "\u0140": "l", 445 "\u0141": "l", 446 "\u0142": "l", 447 "\u1E3E": "M", 448 "\u1E3F": "m", 449 "M\u0306": "M", 450 "m\u0306": "m", 451 "\u0143": "N", 452 "\u0144": "n", 453 "\u0145": "N", 454 "\u0146": "n", 455 "\u0147": "N", 456 "\u0148": "n", 457 "\u0149": "n", 458 "N\u0306": "N", 459 "n\u0306": "n", 460 "\u014C": "O", 461 "\u014D": "o", 462 "\u014E": "O", 463 "\u014F": "o", 464 "\u0150": "O", 465 "\u0151": "o", 466 "\u0152": "OE", 467 "\u0153": "oe", 468 "P\u0306": "P", 469 "p\u0306": "p", 470 "\u0154": "R", 471 "\u0155": "r", 472 "\u0156": "R", 473 "\u0157": "r", 474 "\u0158": "R", 475 "\u0159": "r", 476 "R\u0306": "R", 477 "r\u0306": "r", 478 "\u0212": "R", 479 "\u0213": "r", 480 "\u015A": "S", 481 "\u015B": "s", 482 "\u015C": "S", 483 "\u015D": "s", 484 "\u015E": "S", 485 "\u0218": "S", 486 "\u0219": "s", 487 "\u015F": "s", 488 "\u0160": "S", 489 "\u0161": "s", 490 "\u0162": "T", 491 "\u0163": "t", 492 "\u021B": "t", 493 "\u021A": "T", 494 "\u0164": "T", 495 "\u0165": "t", 496 "\u0166": "T", 497 "\u0167": "t", 498 "T\u0306": "T", 499 "t\u0306": "t", 500 "\u0168": "U", 501 "\u0169": "u", 502 "\u016A": "U", 503 "\u016B": "u", 504 "\u016C": "U", 505 "\u016D": "u", 506 "\u016E": "U", 507 "\u016F": "u", 508 "\u0170": "U", 509 "\u0171": "u", 510 "\u0172": "U", 511 "\u0173": "u", 512 "\u0216": "U", 513 "\u0217": "u", 514 "V\u0306": "V", 515 "v\u0306": "v", 516 "\u0174": "W", 517 "\u0175": "w", 518 "\u1E82": "W", 519 "\u1E83": "w", 520 "X\u0306": "X", 521 "x\u0306": "x", 522 "\u0176": "Y", 523 "\u0177": "y", 524 "\u0178": "Y", 525 "Y\u0306": "Y", 526 "y\u0306": "y", 527 "\u0179": "Z", 528 "\u017A": "z", 529 "\u017B": "Z", 530 "\u017C": "z", 531 "\u017D": "Z", 532 "\u017E": "z", 533 "\u017F": "s", 534 "\u0192": "f", 535 "\u01A0": "O", 536 "\u01A1": "o", 537 "\u01AF": "U", 538 "\u01B0": "u", 539 "\u01CD": "A", 540 "\u01CE": "a", 541 "\u01CF": "I", 542 "\u01D0": "i", 543 "\u01D1": "O", 544 "\u01D2": "o", 545 "\u01D3": "U", 546 "\u01D4": "u", 547 "\u01D5": "U", 548 "\u01D6": "u", 549 "\u01D7": "U", 550 "\u01D8": "u", 551 "\u01D9": "U", 552 "\u01DA": "u", 553 "\u01DB": "U", 554 "\u01DC": "u", 555 "\u1EE8": "U", 556 "\u1EE9": "u", 557 "\u1E78": "U", 558 "\u1E79": "u", 559 "\u01FA": "A", 560 "\u01FB": "a", 561 "\u01FC": "AE", 562 "\u01FD": "ae", 563 "\u01FE": "O", 564 "\u01FF": "o", 565 "\xDE": "TH", 566 "\xFE": "th", 567 "\u1E54": "P", 568 "\u1E55": "p", 569 "\u1E64": "S", 570 "\u1E65": "s", 571 "X\u0301": "X", 572 "x\u0301": "x", 573 "\u0403": "\u0413", 574 "\u0453": "\u0433", 575 "\u040C": "\u041A", 576 "\u045C": "\u043A", 577 "A\u030B": "A", 578 "a\u030B": "a", 579 "E\u030B": "E", 580 "e\u030B": "e", 581 "I\u030B": "I", 582 "i\u030B": "i", 583 "\u01F8": "N", 584 "\u01F9": "n", 585 "\u1ED2": "O", 586 "\u1ED3": "o", 587 "\u1E50": "O", 588 "\u1E51": "o", 589 "\u1EEA": "U", 590 "\u1EEB": "u", 591 "\u1E80": "W", 592 "\u1E81": "w", 593 "\u1EF2": "Y", 594 "\u1EF3": "y", 595 "\u0200": "A", 596 "\u0201": "a", 597 "\u0204": "E", 598 "\u0205": "e", 599 "\u0208": "I", 600 "\u0209": "i", 601 "\u020C": "O", 602 "\u020D": "o", 603 "\u0210": "R", 604 "\u0211": "r", 605 "\u0214": "U", 606 "\u0215": "u", 607 "B\u030C": "B", 608 "b\u030C": "b", 609 "\u010C\u0323": "C", 610 "\u010D\u0323": "c", 611 "\xCA\u030C": "E", 612 "\xEA\u030C": "e", 613 "F\u030C": "F", 614 "f\u030C": "f", 615 "\u01E6": "G", 616 "\u01E7": "g", 617 "\u021E": "H", 618 "\u021F": "h", 619 "J\u030C": "J", 620 "\u01F0": "j", 621 "\u01E8": "K", 622 "\u01E9": "k", 623 "M\u030C": "M", 624 "m\u030C": "m", 625 "P\u030C": "P", 626 "p\u030C": "p", 627 "Q\u030C": "Q", 628 "q\u030C": "q", 629 "\u0158\u0329": "R", 630 "\u0159\u0329": "r", 631 "\u1E66": "S", 632 "\u1E67": "s", 633 "V\u030C": "V", 634 "v\u030C": "v", 635 "W\u030C": "W", 636 "w\u030C": "w", 637 "X\u030C": "X", 638 "x\u030C": "x", 639 "Y\u030C": "Y", 640 "y\u030C": "y", 641 "A\u0327": "A", 642 "a\u0327": "a", 643 "B\u0327": "B", 644 "b\u0327": "b", 645 "\u1E10": "D", 646 "\u1E11": "d", 647 "\u0228": "E", 648 "\u0229": "e", 649 "\u0190\u0327": "E", 650 "\u025B\u0327": "e", 651 "\u1E28": "H", 652 "\u1E29": "h", 653 "I\u0327": "I", 654 "i\u0327": "i", 655 "\u0197\u0327": "I", 656 "\u0268\u0327": "i", 657 "M\u0327": "M", 658 "m\u0327": "m", 659 "O\u0327": "O", 660 "o\u0327": "o", 661 "Q\u0327": "Q", 662 "q\u0327": "q", 663 "U\u0327": "U", 664 "u\u0327": "u", 665 "X\u0327": "X", 666 "x\u0327": "x", 667 "Z\u0327": "Z", 668 "z\u0327": "z", 669 "\u0439": "\u0438", 670 "\u0419": "\u0418", 671 "\u0451": "\u0435", 672 "\u0401": "\u0415" 673 }; 674 var chars = Object.keys(characterMap).join("|"); 675 var allAccents = new RegExp(chars, "g"); 676 var firstAccent = new RegExp(chars, ""); 677 function matcher(match2) { 678 return characterMap[match2]; 679 } 680 var removeAccents2 = function(string) { 681 return string.replace(allAccents, matcher); 682 }; 683 var hasAccents = function(string) { 684 return !!string.match(firstAccent); 685 }; 686 module.exports = removeAccents2; 687 module.exports.has = hasAccents; 688 module.exports.remove = removeAccents2; 689 } 690 }); 691 692 // package-external:@wordpress/api-fetch 693 var require_api_fetch = __commonJS({ 694 "package-external:@wordpress/api-fetch"(exports, module) { 695 module.exports = window.wp.apiFetch; 696 } 697 }); 698 699 // package-external:@wordpress/html-entities 700 var require_html_entities = __commonJS({ 701 "package-external:@wordpress/html-entities"(exports, module) { 702 module.exports = window.wp.htmlEntities; 703 } 704 }); 705 706 // package-external:@wordpress/style-engine 707 var require_style_engine = __commonJS({ 708 "package-external:@wordpress/style-engine"(exports, module) { 709 module.exports = window.wp.styleEngine; 710 } 711 }); 712 713 // package-external:@wordpress/keycodes 714 var require_keycodes = __commonJS({ 715 "package-external:@wordpress/keycodes"(exports, module) { 716 module.exports = window.wp.keycodes; 717 } 718 }); 719 720 // package-external:@wordpress/dom 721 var require_dom = __commonJS({ 722 "package-external:@wordpress/dom"(exports, module) { 723 module.exports = window.wp.dom; 724 } 725 }); 726 727 // node_modules/diff/lib/diff/base.js 728 var require_base = __commonJS({ 729 "node_modules/diff/lib/diff/base.js"(exports) { 730 "use strict"; 731 Object.defineProperty(exports, "__esModule", { 732 value: true 733 }); 734 exports.default = Diff; 735 function Diff() { 736 } 737 Diff.prototype = { 738 /*istanbul ignore start*/ 739 /*istanbul ignore end*/ 740 diff: function diff(oldString, newString) { 741 var options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {}; 742 var callback = options.callback; 743 if (typeof options === "function") { 744 callback = options; 745 options = {}; 746 } 747 this.options = options; 748 var self = this; 749 function done(value) { 750 if (callback) { 751 setTimeout(function() { 752 callback(void 0, value); 753 }, 0); 754 return true; 755 } else { 756 return value; 757 } 758 } 759 oldString = this.castInput(oldString); 760 newString = this.castInput(newString); 761 oldString = this.removeEmpty(this.tokenize(oldString)); 762 newString = this.removeEmpty(this.tokenize(newString)); 763 var newLen = newString.length, oldLen = oldString.length; 764 var editLength = 1; 765 var maxEditLength = newLen + oldLen; 766 var bestPath = [{ 767 newPos: -1, 768 components: [] 769 }]; 770 var oldPos = this.extractCommon(bestPath[0], newString, oldString, 0); 771 if (bestPath[0].newPos + 1 >= newLen && oldPos + 1 >= oldLen) { 772 return done([{ 773 value: this.join(newString), 774 count: newString.length 775 }]); 776 } 777 function execEditLength() { 778 for (var diagonalPath = -1 * editLength; diagonalPath <= editLength; diagonalPath += 2) { 779 var basePath = ( 780 /*istanbul ignore start*/ 781 void 0 782 ); 783 var addPath = bestPath[diagonalPath - 1], removePath = bestPath[diagonalPath + 1], _oldPos = (removePath ? removePath.newPos : 0) - diagonalPath; 784 if (addPath) { 785 bestPath[diagonalPath - 1] = void 0; 786 } 787 var canAdd = addPath && addPath.newPos + 1 < newLen, canRemove = removePath && 0 <= _oldPos && _oldPos < oldLen; 788 if (!canAdd && !canRemove) { 789 bestPath[diagonalPath] = void 0; 790 continue; 791 } 792 if (!canAdd || canRemove && addPath.newPos < removePath.newPos) { 793 basePath = clonePath(removePath); 794 self.pushComponent(basePath.components, void 0, true); 795 } else { 796 basePath = addPath; 797 basePath.newPos++; 798 self.pushComponent(basePath.components, true, void 0); 799 } 800 _oldPos = self.extractCommon(basePath, newString, oldString, diagonalPath); 801 if (basePath.newPos + 1 >= newLen && _oldPos + 1 >= oldLen) { 802 return done(buildValues(self, basePath.components, newString, oldString, self.useLongestToken)); 803 } else { 804 bestPath[diagonalPath] = basePath; 805 } 806 } 807 editLength++; 808 } 809 if (callback) { 810 (function exec() { 811 setTimeout(function() { 812 if (editLength > maxEditLength) { 813 return callback(); 814 } 815 if (!execEditLength()) { 816 exec(); 817 } 818 }, 0); 819 })(); 820 } else { 821 while (editLength <= maxEditLength) { 822 var ret = execEditLength(); 823 if (ret) { 824 return ret; 825 } 826 } 827 } 828 }, 829 /*istanbul ignore start*/ 830 /*istanbul ignore end*/ 831 pushComponent: function pushComponent(components, added, removed) { 832 var last = components[components.length - 1]; 833 if (last && last.added === added && last.removed === removed) { 834 components[components.length - 1] = { 835 count: last.count + 1, 836 added, 837 removed 838 }; 839 } else { 840 components.push({ 841 count: 1, 842 added, 843 removed 844 }); 845 } 846 }, 847 /*istanbul ignore start*/ 848 /*istanbul ignore end*/ 849 extractCommon: function extractCommon(basePath, newString, oldString, diagonalPath) { 850 var newLen = newString.length, oldLen = oldString.length, newPos = basePath.newPos, oldPos = newPos - diagonalPath, commonCount = 0; 851 while (newPos + 1 < newLen && oldPos + 1 < oldLen && this.equals(newString[newPos + 1], oldString[oldPos + 1])) { 852 newPos++; 853 oldPos++; 854 commonCount++; 855 } 856 if (commonCount) { 857 basePath.components.push({ 858 count: commonCount 859 }); 860 } 861 basePath.newPos = newPos; 862 return oldPos; 863 }, 864 /*istanbul ignore start*/ 865 /*istanbul ignore end*/ 866 equals: function equals(left, right) { 867 if (this.options.comparator) { 868 return this.options.comparator(left, right); 869 } else { 870 return left === right || this.options.ignoreCase && left.toLowerCase() === right.toLowerCase(); 871 } 872 }, 873 /*istanbul ignore start*/ 874 /*istanbul ignore end*/ 875 removeEmpty: function removeEmpty(array) { 876 var ret = []; 877 for (var i2 = 0; i2 < array.length; i2++) { 878 if (array[i2]) { 879 ret.push(array[i2]); 880 } 881 } 882 return ret; 883 }, 884 /*istanbul ignore start*/ 885 /*istanbul ignore end*/ 886 castInput: function castInput(value) { 887 return value; 888 }, 889 /*istanbul ignore start*/ 890 /*istanbul ignore end*/ 891 tokenize: function tokenize2(value) { 892 return value.split(""); 893 }, 894 /*istanbul ignore start*/ 895 /*istanbul ignore end*/ 896 join: function join(chars) { 897 return chars.join(""); 898 } 899 }; 900 function buildValues(diff, components, newString, oldString, useLongestToken) { 901 var componentPos = 0, componentLen = components.length, newPos = 0, oldPos = 0; 902 for (; componentPos < componentLen; componentPos++) { 903 var component = components[componentPos]; 904 if (!component.removed) { 905 if (!component.added && useLongestToken) { 906 var value = newString.slice(newPos, newPos + component.count); 907 value = value.map(function(value2, i2) { 908 var oldValue = oldString[oldPos + i2]; 909 return oldValue.length > value2.length ? oldValue : value2; 910 }); 911 component.value = diff.join(value); 912 } else { 913 component.value = diff.join(newString.slice(newPos, newPos + component.count)); 914 } 915 newPos += component.count; 916 if (!component.added) { 917 oldPos += component.count; 918 } 919 } else { 920 component.value = diff.join(oldString.slice(oldPos, oldPos + component.count)); 921 oldPos += component.count; 922 if (componentPos && components[componentPos - 1].added) { 923 var tmp = components[componentPos - 1]; 924 components[componentPos - 1] = components[componentPos]; 925 components[componentPos] = tmp; 926 } 927 } 928 } 929 var lastComponent = components[componentLen - 1]; 930 if (componentLen > 1 && typeof lastComponent.value === "string" && (lastComponent.added || lastComponent.removed) && diff.equals("", lastComponent.value)) { 931 components[componentLen - 2].value += lastComponent.value; 932 components.pop(); 933 } 934 return components; 935 } 936 function clonePath(path) { 937 return { 938 newPos: path.newPos, 939 components: path.components.slice(0) 940 }; 941 } 942 } 943 }); 944 945 // node_modules/diff/lib/diff/character.js 946 var require_character = __commonJS({ 947 "node_modules/diff/lib/diff/character.js"(exports) { 948 "use strict"; 949 Object.defineProperty(exports, "__esModule", { 950 value: true 951 }); 952 exports.diffChars = diffChars2; 953 exports.characterDiff = void 0; 954 var _base = _interopRequireDefault(require_base()); 955 function _interopRequireDefault(obj) { 956 return obj && obj.__esModule ? obj : { default: obj }; 957 } 958 var characterDiff = new /*istanbul ignore start*/ 959 _base.default(); 960 exports.characterDiff = characterDiff; 961 function diffChars2(oldStr, newStr, options) { 962 return characterDiff.diff(oldStr, newStr, options); 963 } 964 } 965 }); 966 967 // vendor-external:react 968 var require_react = __commonJS({ 969 "vendor-external:react"(exports, module) { 970 module.exports = window.React; 971 } 972 }); 973 974 // node_modules/react-is/cjs/react-is.development.js 975 var require_react_is_development = __commonJS({ 976 "node_modules/react-is/cjs/react-is.development.js"(exports) { 977 "use strict"; 978 if (true) { 979 (function() { 980 "use strict"; 981 var hasSymbol = typeof Symbol === "function" && Symbol.for; 982 var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for("react.element") : 60103; 983 var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for("react.portal") : 60106; 984 var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for("react.fragment") : 60107; 985 var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for("react.strict_mode") : 60108; 986 var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for("react.profiler") : 60114; 987 var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for("react.provider") : 60109; 988 var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for("react.context") : 60110; 989 var REACT_ASYNC_MODE_TYPE = hasSymbol ? Symbol.for("react.async_mode") : 60111; 990 var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for("react.concurrent_mode") : 60111; 991 var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for("react.forward_ref") : 60112; 992 var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for("react.suspense") : 60113; 993 var REACT_SUSPENSE_LIST_TYPE = hasSymbol ? Symbol.for("react.suspense_list") : 60120; 994 var REACT_MEMO_TYPE = hasSymbol ? Symbol.for("react.memo") : 60115; 995 var REACT_LAZY_TYPE = hasSymbol ? Symbol.for("react.lazy") : 60116; 996 var REACT_BLOCK_TYPE = hasSymbol ? Symbol.for("react.block") : 60121; 997 var REACT_FUNDAMENTAL_TYPE = hasSymbol ? Symbol.for("react.fundamental") : 60117; 998 var REACT_RESPONDER_TYPE = hasSymbol ? Symbol.for("react.responder") : 60118; 999 var REACT_SCOPE_TYPE = hasSymbol ? Symbol.for("react.scope") : 60119; 1000 function isValidElementType(type) { 1001 return typeof type === "string" || typeof type === "function" || // Note: its typeof might be other than 'symbol' or 'number' if it's a polyfill. 1002 type === REACT_FRAGMENT_TYPE || type === REACT_CONCURRENT_MODE_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || typeof type === "object" && type !== null && (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_FUNDAMENTAL_TYPE || type.$$typeof === REACT_RESPONDER_TYPE || type.$$typeof === REACT_SCOPE_TYPE || type.$$typeof === REACT_BLOCK_TYPE); 1003 } 1004 function typeOf(object) { 1005 if (typeof object === "object" && object !== null) { 1006 var $$typeof = object.$$typeof; 1007 switch ($$typeof) { 1008 case REACT_ELEMENT_TYPE: 1009 var type = object.type; 1010 switch (type) { 1011 case REACT_ASYNC_MODE_TYPE: 1012 case REACT_CONCURRENT_MODE_TYPE: 1013 case REACT_FRAGMENT_TYPE: 1014 case REACT_PROFILER_TYPE: 1015 case REACT_STRICT_MODE_TYPE: 1016 case REACT_SUSPENSE_TYPE: 1017 return type; 1018 default: 1019 var $$typeofType = type && type.$$typeof; 1020 switch ($$typeofType) { 1021 case REACT_CONTEXT_TYPE: 1022 case REACT_FORWARD_REF_TYPE: 1023 case REACT_LAZY_TYPE: 1024 case REACT_MEMO_TYPE: 1025 case REACT_PROVIDER_TYPE: 1026 return $$typeofType; 1027 default: 1028 return $$typeof; 1029 } 1030 } 1031 case REACT_PORTAL_TYPE: 1032 return $$typeof; 1033 } 1034 } 1035 return void 0; 1036 } 1037 var AsyncMode = REACT_ASYNC_MODE_TYPE; 1038 var ConcurrentMode = REACT_CONCURRENT_MODE_TYPE; 1039 var ContextConsumer = REACT_CONTEXT_TYPE; 1040 var ContextProvider = REACT_PROVIDER_TYPE; 1041 var Element2 = REACT_ELEMENT_TYPE; 1042 var ForwardRef = REACT_FORWARD_REF_TYPE; 1043 var Fragment96 = REACT_FRAGMENT_TYPE; 1044 var Lazy = REACT_LAZY_TYPE; 1045 var Memo = REACT_MEMO_TYPE; 1046 var Portal = REACT_PORTAL_TYPE; 1047 var Profiler = REACT_PROFILER_TYPE; 1048 var StrictMode2 = REACT_STRICT_MODE_TYPE; 1049 var Suspense = REACT_SUSPENSE_TYPE; 1050 var hasWarnedAboutDeprecatedIsAsyncMode = false; 1051 function isAsyncMode(object) { 1052 { 1053 if (!hasWarnedAboutDeprecatedIsAsyncMode) { 1054 hasWarnedAboutDeprecatedIsAsyncMode = true; 1055 console["warn"]("The ReactIs.isAsyncMode() alias has been deprecated, and will be removed in React 17+. Update your code to use ReactIs.isConcurrentMode() instead. It has the exact same API."); 1056 } 1057 } 1058 return isConcurrentMode(object) || typeOf(object) === REACT_ASYNC_MODE_TYPE; 1059 } 1060 function isConcurrentMode(object) { 1061 return typeOf(object) === REACT_CONCURRENT_MODE_TYPE; 1062 } 1063 function isContextConsumer(object) { 1064 return typeOf(object) === REACT_CONTEXT_TYPE; 1065 } 1066 function isContextProvider(object) { 1067 return typeOf(object) === REACT_PROVIDER_TYPE; 1068 } 1069 function isElement(object) { 1070 return typeof object === "object" && object !== null && object.$$typeof === REACT_ELEMENT_TYPE; 1071 } 1072 function isForwardRef(object) { 1073 return typeOf(object) === REACT_FORWARD_REF_TYPE; 1074 } 1075 function isFragment(object) { 1076 return typeOf(object) === REACT_FRAGMENT_TYPE; 1077 } 1078 function isLazy(object) { 1079 return typeOf(object) === REACT_LAZY_TYPE; 1080 } 1081 function isMemo(object) { 1082 return typeOf(object) === REACT_MEMO_TYPE; 1083 } 1084 function isPortal(object) { 1085 return typeOf(object) === REACT_PORTAL_TYPE; 1086 } 1087 function isProfiler(object) { 1088 return typeOf(object) === REACT_PROFILER_TYPE; 1089 } 1090 function isStrictMode(object) { 1091 return typeOf(object) === REACT_STRICT_MODE_TYPE; 1092 } 1093 function isSuspense(object) { 1094 return typeOf(object) === REACT_SUSPENSE_TYPE; 1095 } 1096 exports.AsyncMode = AsyncMode; 1097 exports.ConcurrentMode = ConcurrentMode; 1098 exports.ContextConsumer = ContextConsumer; 1099 exports.ContextProvider = ContextProvider; 1100 exports.Element = Element2; 1101 exports.ForwardRef = ForwardRef; 1102 exports.Fragment = Fragment96; 1103 exports.Lazy = Lazy; 1104 exports.Memo = Memo; 1105 exports.Portal = Portal; 1106 exports.Profiler = Profiler; 1107 exports.StrictMode = StrictMode2; 1108 exports.Suspense = Suspense; 1109 exports.isAsyncMode = isAsyncMode; 1110 exports.isConcurrentMode = isConcurrentMode; 1111 exports.isContextConsumer = isContextConsumer; 1112 exports.isContextProvider = isContextProvider; 1113 exports.isElement = isElement; 1114 exports.isForwardRef = isForwardRef; 1115 exports.isFragment = isFragment; 1116 exports.isLazy = isLazy; 1117 exports.isMemo = isMemo; 1118 exports.isPortal = isPortal; 1119 exports.isProfiler = isProfiler; 1120 exports.isStrictMode = isStrictMode; 1121 exports.isSuspense = isSuspense; 1122 exports.isValidElementType = isValidElementType; 1123 exports.typeOf = typeOf; 1124 })(); 1125 } 1126 } 1127 }); 1128 1129 // node_modules/react-is/index.js 1130 var require_react_is = __commonJS({ 1131 "node_modules/react-is/index.js"(exports, module) { 1132 "use strict"; 1133 if (false) { 1134 module.exports = null; 1135 } else { 1136 module.exports = require_react_is_development(); 1137 } 1138 } 1139 }); 1140 1141 // node_modules/object-assign/index.js 1142 var require_object_assign = __commonJS({ 1143 "node_modules/object-assign/index.js"(exports, module) { 1144 "use strict"; 1145 var getOwnPropertySymbols = Object.getOwnPropertySymbols; 1146 var hasOwnProperty = Object.prototype.hasOwnProperty; 1147 var propIsEnumerable = Object.prototype.propertyIsEnumerable; 1148 function toObject(val) { 1149 if (val === null || val === void 0) { 1150 throw new TypeError("Object.assign cannot be called with null or undefined"); 1151 } 1152 return Object(val); 1153 } 1154 function shouldUseNative() { 1155 try { 1156 if (!Object.assign) { 1157 return false; 1158 } 1159 var test1 = new String("abc"); 1160 test1[5] = "de"; 1161 if (Object.getOwnPropertyNames(test1)[0] === "5") { 1162 return false; 1163 } 1164 var test2 = {}; 1165 for (var i2 = 0; i2 < 10; i2++) { 1166 test2["_" + String.fromCharCode(i2)] = i2; 1167 } 1168 var order2 = Object.getOwnPropertyNames(test2).map(function(n2) { 1169 return test2[n2]; 1170 }); 1171 if (order2.join("") !== "0123456789") { 1172 return false; 1173 } 1174 var test3 = {}; 1175 "abcdefghijklmnopqrst".split("").forEach(function(letter) { 1176 test3[letter] = letter; 1177 }); 1178 if (Object.keys(Object.assign({}, test3)).join("") !== "abcdefghijklmnopqrst") { 1179 return false; 1180 } 1181 return true; 1182 } catch (err) { 1183 return false; 1184 } 1185 } 1186 module.exports = shouldUseNative() ? Object.assign : function(target, source) { 1187 var from; 1188 var to2 = toObject(target); 1189 var symbols; 1190 for (var s2 = 1; s2 < arguments.length; s2++) { 1191 from = Object(arguments[s2]); 1192 for (var key in from) { 1193 if (hasOwnProperty.call(from, key)) { 1194 to2[key] = from[key]; 1195 } 1196 } 1197 if (getOwnPropertySymbols) { 1198 symbols = getOwnPropertySymbols(from); 1199 for (var i2 = 0; i2 < symbols.length; i2++) { 1200 if (propIsEnumerable.call(from, symbols[i2])) { 1201 to2[symbols[i2]] = from[symbols[i2]]; 1202 } 1203 } 1204 } 1205 } 1206 return to2; 1207 }; 1208 } 1209 }); 1210 1211 // node_modules/prop-types/lib/ReactPropTypesSecret.js 1212 var require_ReactPropTypesSecret = __commonJS({ 1213 "node_modules/prop-types/lib/ReactPropTypesSecret.js"(exports, module) { 1214 "use strict"; 1215 var ReactPropTypesSecret = "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"; 1216 module.exports = ReactPropTypesSecret; 1217 } 1218 }); 1219 1220 // node_modules/prop-types/lib/has.js 1221 var require_has = __commonJS({ 1222 "node_modules/prop-types/lib/has.js"(exports, module) { 1223 module.exports = Function.call.bind(Object.prototype.hasOwnProperty); 1224 } 1225 }); 1226 1227 // node_modules/prop-types/checkPropTypes.js 1228 var require_checkPropTypes = __commonJS({ 1229 "node_modules/prop-types/checkPropTypes.js"(exports, module) { 1230 "use strict"; 1231 var printWarning = function() { 1232 }; 1233 if (true) { 1234 ReactPropTypesSecret = require_ReactPropTypesSecret(); 1235 loggedTypeFailures = {}; 1236 has2 = require_has(); 1237 printWarning = function(text) { 1238 var message2 = "Warning: " + text; 1239 if (typeof console !== "undefined") { 1240 console.error(message2); 1241 } 1242 try { 1243 throw new Error(message2); 1244 } catch (x2) { 1245 } 1246 }; 1247 } 1248 var ReactPropTypesSecret; 1249 var loggedTypeFailures; 1250 var has2; 1251 function checkPropTypes(typeSpecs, values, location, componentName, getStack) { 1252 if (true) { 1253 for (var typeSpecName in typeSpecs) { 1254 if (has2(typeSpecs, typeSpecName)) { 1255 var error; 1256 try { 1257 if (typeof typeSpecs[typeSpecName] !== "function") { 1258 var err = Error( 1259 (componentName || "React class") + ": " + location + " type `" + typeSpecName + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof typeSpecs[typeSpecName] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`." 1260 ); 1261 err.name = "Invariant Violation"; 1262 throw err; 1263 } 1264 error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret); 1265 } catch (ex) { 1266 error = ex; 1267 } 1268 if (error && !(error instanceof Error)) { 1269 printWarning( 1270 (componentName || "React class") + ": type specification of " + location + " `" + typeSpecName + "` is invalid; the type checker function must return `null` or an `Error` but returned a " + typeof error + ". You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument)." 1271 ); 1272 } 1273 if (error instanceof Error && !(error.message in loggedTypeFailures)) { 1274 loggedTypeFailures[error.message] = true; 1275 var stack = getStack ? getStack() : ""; 1276 printWarning( 1277 "Failed " + location + " type: " + error.message + (stack != null ? stack : "") 1278 ); 1279 } 1280 } 1281 } 1282 } 1283 } 1284 checkPropTypes.resetWarningCache = function() { 1285 if (true) { 1286 loggedTypeFailures = {}; 1287 } 1288 }; 1289 module.exports = checkPropTypes; 1290 } 1291 }); 1292 1293 // node_modules/prop-types/factoryWithTypeCheckers.js 1294 var require_factoryWithTypeCheckers = __commonJS({ 1295 "node_modules/prop-types/factoryWithTypeCheckers.js"(exports, module) { 1296 "use strict"; 1297 var ReactIs = require_react_is(); 1298 var assign2 = require_object_assign(); 1299 var ReactPropTypesSecret = require_ReactPropTypesSecret(); 1300 var has2 = require_has(); 1301 var checkPropTypes = require_checkPropTypes(); 1302 var printWarning = function() { 1303 }; 1304 if (true) { 1305 printWarning = function(text) { 1306 var message2 = "Warning: " + text; 1307 if (typeof console !== "undefined") { 1308 console.error(message2); 1309 } 1310 try { 1311 throw new Error(message2); 1312 } catch (x2) { 1313 } 1314 }; 1315 } 1316 function emptyFunctionThatReturnsNull() { 1317 return null; 1318 } 1319 module.exports = function(isValidElement, throwOnDirectAccess) { 1320 var ITERATOR_SYMBOL = typeof Symbol === "function" && Symbol.iterator; 1321 var FAUX_ITERATOR_SYMBOL = "@@iterator"; 1322 function getIteratorFn(maybeIterable) { 1323 var iteratorFn = maybeIterable && (ITERATOR_SYMBOL && maybeIterable[ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]); 1324 if (typeof iteratorFn === "function") { 1325 return iteratorFn; 1326 } 1327 } 1328 var ANONYMOUS = "<<anonymous>>"; 1329 var ReactPropTypes = { 1330 array: createPrimitiveTypeChecker("array"), 1331 bigint: createPrimitiveTypeChecker("bigint"), 1332 bool: createPrimitiveTypeChecker("boolean"), 1333 func: createPrimitiveTypeChecker("function"), 1334 number: createPrimitiveTypeChecker("number"), 1335 object: createPrimitiveTypeChecker("object"), 1336 string: createPrimitiveTypeChecker("string"), 1337 symbol: createPrimitiveTypeChecker("symbol"), 1338 any: createAnyTypeChecker(), 1339 arrayOf: createArrayOfTypeChecker, 1340 element: createElementTypeChecker(), 1341 elementType: createElementTypeTypeChecker(), 1342 instanceOf: createInstanceTypeChecker, 1343 node: createNodeChecker(), 1344 objectOf: createObjectOfTypeChecker, 1345 oneOf: createEnumTypeChecker, 1346 oneOfType: createUnionTypeChecker, 1347 shape: createShapeTypeChecker, 1348 exact: createStrictShapeTypeChecker 1349 }; 1350 function is2(x2, y2) { 1351 if (x2 === y2) { 1352 return x2 !== 0 || 1 / x2 === 1 / y2; 1353 } else { 1354 return x2 !== x2 && y2 !== y2; 1355 } 1356 } 1357 function PropTypeError(message2, data) { 1358 this.message = message2; 1359 this.data = data && typeof data === "object" ? data : {}; 1360 this.stack = ""; 1361 } 1362 PropTypeError.prototype = Error.prototype; 1363 function createChainableTypeChecker(validate) { 1364 if (true) { 1365 var manualPropTypeCallCache = {}; 1366 var manualPropTypeWarningCount = 0; 1367 } 1368 function checkType(isRequired, props, propName, componentName, location, propFullName, secret) { 1369 componentName = componentName || ANONYMOUS; 1370 propFullName = propFullName || propName; 1371 if (secret !== ReactPropTypesSecret) { 1372 if (throwOnDirectAccess) { 1373 var err = new Error( 1374 "Calling PropTypes validators directly is not supported by the `prop-types` package. Use `PropTypes.checkPropTypes()` to call them. Read more at http://fb.me/use-check-prop-types" 1375 ); 1376 err.name = "Invariant Violation"; 1377 throw err; 1378 } else if (typeof console !== "undefined") { 1379 var cacheKey2 = componentName + ":" + propName; 1380 if (!manualPropTypeCallCache[cacheKey2] && // Avoid spamming the console because they are often not actionable except for lib authors 1381 manualPropTypeWarningCount < 3) { 1382 printWarning( 1383 "You are manually calling a React.PropTypes validation function for the `" + propFullName + "` prop on `" + componentName + "`. This is deprecated and will throw in the standalone `prop-types` package. You may be seeing this warning due to a third-party PropTypes library. See https://fb.me/react-warning-dont-call-proptypes for details." 1384 ); 1385 manualPropTypeCallCache[cacheKey2] = true; 1386 manualPropTypeWarningCount++; 1387 } 1388 } 1389 } 1390 if (props[propName] == null) { 1391 if (isRequired) { 1392 if (props[propName] === null) { 1393 return new PropTypeError("The " + location + " `" + propFullName + "` is marked as required " + ("in `" + componentName + "`, but its value is `null`.")); 1394 } 1395 return new PropTypeError("The " + location + " `" + propFullName + "` is marked as required in " + ("`" + componentName + "`, but its value is `undefined`.")); 1396 } 1397 return null; 1398 } else { 1399 return validate(props, propName, componentName, location, propFullName); 1400 } 1401 } 1402 var chainedCheckType = checkType.bind(null, false); 1403 chainedCheckType.isRequired = checkType.bind(null, true); 1404 return chainedCheckType; 1405 } 1406 function createPrimitiveTypeChecker(expectedType) { 1407 function validate(props, propName, componentName, location, propFullName, secret) { 1408 var propValue = props[propName]; 1409 var propType = getPropType(propValue); 1410 if (propType !== expectedType) { 1411 var preciseType = getPreciseType(propValue); 1412 return new PropTypeError( 1413 "Invalid " + location + " `" + propFullName + "` of type " + ("`" + preciseType + "` supplied to `" + componentName + "`, expected ") + ("`" + expectedType + "`."), 1414 { expectedType } 1415 ); 1416 } 1417 return null; 1418 } 1419 return createChainableTypeChecker(validate); 1420 } 1421 function createAnyTypeChecker() { 1422 return createChainableTypeChecker(emptyFunctionThatReturnsNull); 1423 } 1424 function createArrayOfTypeChecker(typeChecker) { 1425 function validate(props, propName, componentName, location, propFullName) { 1426 if (typeof typeChecker !== "function") { 1427 return new PropTypeError("Property `" + propFullName + "` of component `" + componentName + "` has invalid PropType notation inside arrayOf."); 1428 } 1429 var propValue = props[propName]; 1430 if (!Array.isArray(propValue)) { 1431 var propType = getPropType(propValue); 1432 return new PropTypeError("Invalid " + location + " `" + propFullName + "` of type " + ("`" + propType + "` supplied to `" + componentName + "`, expected an array.")); 1433 } 1434 for (var i2 = 0; i2 < propValue.length; i2++) { 1435 var error = typeChecker(propValue, i2, componentName, location, propFullName + "[" + i2 + "]", ReactPropTypesSecret); 1436 if (error instanceof Error) { 1437 return error; 1438 } 1439 } 1440 return null; 1441 } 1442 return createChainableTypeChecker(validate); 1443 } 1444 function createElementTypeChecker() { 1445 function validate(props, propName, componentName, location, propFullName) { 1446 var propValue = props[propName]; 1447 if (!isValidElement(propValue)) { 1448 var propType = getPropType(propValue); 1449 return new PropTypeError("Invalid " + location + " `" + propFullName + "` of type " + ("`" + propType + "` supplied to `" + componentName + "`, expected a single ReactElement.")); 1450 } 1451 return null; 1452 } 1453 return createChainableTypeChecker(validate); 1454 } 1455 function createElementTypeTypeChecker() { 1456 function validate(props, propName, componentName, location, propFullName) { 1457 var propValue = props[propName]; 1458 if (!ReactIs.isValidElementType(propValue)) { 1459 var propType = getPropType(propValue); 1460 return new PropTypeError("Invalid " + location + " `" + propFullName + "` of type " + ("`" + propType + "` supplied to `" + componentName + "`, expected a single ReactElement type.")); 1461 } 1462 return null; 1463 } 1464 return createChainableTypeChecker(validate); 1465 } 1466 function createInstanceTypeChecker(expectedClass) { 1467 function validate(props, propName, componentName, location, propFullName) { 1468 if (!(props[propName] instanceof expectedClass)) { 1469 var expectedClassName = expectedClass.name || ANONYMOUS; 1470 var actualClassName = getClassName(props[propName]); 1471 return new PropTypeError("Invalid " + location + " `" + propFullName + "` of type " + ("`" + actualClassName + "` supplied to `" + componentName + "`, expected ") + ("instance of `" + expectedClassName + "`.")); 1472 } 1473 return null; 1474 } 1475 return createChainableTypeChecker(validate); 1476 } 1477 function createEnumTypeChecker(expectedValues) { 1478 if (!Array.isArray(expectedValues)) { 1479 if (true) { 1480 if (arguments.length > 1) { 1481 printWarning( 1482 "Invalid arguments supplied to oneOf, expected an array, got " + arguments.length + " arguments. A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z])." 1483 ); 1484 } else { 1485 printWarning("Invalid argument supplied to oneOf, expected an array."); 1486 } 1487 } 1488 return emptyFunctionThatReturnsNull; 1489 } 1490 function validate(props, propName, componentName, location, propFullName) { 1491 var propValue = props[propName]; 1492 for (var i2 = 0; i2 < expectedValues.length; i2++) { 1493 if (is2(propValue, expectedValues[i2])) { 1494 return null; 1495 } 1496 } 1497 var valuesString = JSON.stringify(expectedValues, function replacer(key, value) { 1498 var type = getPreciseType(value); 1499 if (type === "symbol") { 1500 return String(value); 1501 } 1502 return value; 1503 }); 1504 return new PropTypeError("Invalid " + location + " `" + propFullName + "` of value `" + String(propValue) + "` " + ("supplied to `" + componentName + "`, expected one of " + valuesString + ".")); 1505 } 1506 return createChainableTypeChecker(validate); 1507 } 1508 function createObjectOfTypeChecker(typeChecker) { 1509 function validate(props, propName, componentName, location, propFullName) { 1510 if (typeof typeChecker !== "function") { 1511 return new PropTypeError("Property `" + propFullName + "` of component `" + componentName + "` has invalid PropType notation inside objectOf."); 1512 } 1513 var propValue = props[propName]; 1514 var propType = getPropType(propValue); 1515 if (propType !== "object") { 1516 return new PropTypeError("Invalid " + location + " `" + propFullName + "` of type " + ("`" + propType + "` supplied to `" + componentName + "`, expected an object.")); 1517 } 1518 for (var key in propValue) { 1519 if (has2(propValue, key)) { 1520 var error = typeChecker(propValue, key, componentName, location, propFullName + "." + key, ReactPropTypesSecret); 1521 if (error instanceof Error) { 1522 return error; 1523 } 1524 } 1525 } 1526 return null; 1527 } 1528 return createChainableTypeChecker(validate); 1529 } 1530 function createUnionTypeChecker(arrayOfTypeCheckers) { 1531 if (!Array.isArray(arrayOfTypeCheckers)) { 1532 true ? printWarning("Invalid argument supplied to oneOfType, expected an instance of array.") : void 0; 1533 return emptyFunctionThatReturnsNull; 1534 } 1535 for (var i2 = 0; i2 < arrayOfTypeCheckers.length; i2++) { 1536 var checker = arrayOfTypeCheckers[i2]; 1537 if (typeof checker !== "function") { 1538 printWarning( 1539 "Invalid argument supplied to oneOfType. Expected an array of check functions, but received " + getPostfixForTypeWarning(checker) + " at index " + i2 + "." 1540 ); 1541 return emptyFunctionThatReturnsNull; 1542 } 1543 } 1544 function validate(props, propName, componentName, location, propFullName) { 1545 var expectedTypes = []; 1546 for (var i3 = 0; i3 < arrayOfTypeCheckers.length; i3++) { 1547 var checker2 = arrayOfTypeCheckers[i3]; 1548 var checkerResult = checker2(props, propName, componentName, location, propFullName, ReactPropTypesSecret); 1549 if (checkerResult == null) { 1550 return null; 1551 } 1552 if (checkerResult.data && has2(checkerResult.data, "expectedType")) { 1553 expectedTypes.push(checkerResult.data.expectedType); 1554 } 1555 } 1556 var expectedTypesMessage = expectedTypes.length > 0 ? ", expected one of type [" + expectedTypes.join(", ") + "]" : ""; 1557 return new PropTypeError("Invalid " + location + " `" + propFullName + "` supplied to " + ("`" + componentName + "`" + expectedTypesMessage + ".")); 1558 } 1559 return createChainableTypeChecker(validate); 1560 } 1561 function createNodeChecker() { 1562 function validate(props, propName, componentName, location, propFullName) { 1563 if (!isNode(props[propName])) { 1564 return new PropTypeError("Invalid " + location + " `" + propFullName + "` supplied to " + ("`" + componentName + "`, expected a ReactNode.")); 1565 } 1566 return null; 1567 } 1568 return createChainableTypeChecker(validate); 1569 } 1570 function invalidValidatorError(componentName, location, propFullName, key, type) { 1571 return new PropTypeError( 1572 (componentName || "React class") + ": " + location + " type `" + propFullName + "." + key + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + type + "`." 1573 ); 1574 } 1575 function createShapeTypeChecker(shapeTypes) { 1576 function validate(props, propName, componentName, location, propFullName) { 1577 var propValue = props[propName]; 1578 var propType = getPropType(propValue); 1579 if (propType !== "object") { 1580 return new PropTypeError("Invalid " + location + " `" + propFullName + "` of type `" + propType + "` " + ("supplied to `" + componentName + "`, expected `object`.")); 1581 } 1582 for (var key in shapeTypes) { 1583 var checker = shapeTypes[key]; 1584 if (typeof checker !== "function") { 1585 return invalidValidatorError(componentName, location, propFullName, key, getPreciseType(checker)); 1586 } 1587 var error = checker(propValue, key, componentName, location, propFullName + "." + key, ReactPropTypesSecret); 1588 if (error) { 1589 return error; 1590 } 1591 } 1592 return null; 1593 } 1594 return createChainableTypeChecker(validate); 1595 } 1596 function createStrictShapeTypeChecker(shapeTypes) { 1597 function validate(props, propName, componentName, location, propFullName) { 1598 var propValue = props[propName]; 1599 var propType = getPropType(propValue); 1600 if (propType !== "object") { 1601 return new PropTypeError("Invalid " + location + " `" + propFullName + "` of type `" + propType + "` " + ("supplied to `" + componentName + "`, expected `object`.")); 1602 } 1603 var allKeys = assign2({}, props[propName], shapeTypes); 1604 for (var key in allKeys) { 1605 var checker = shapeTypes[key]; 1606 if (has2(shapeTypes, key) && typeof checker !== "function") { 1607 return invalidValidatorError(componentName, location, propFullName, key, getPreciseType(checker)); 1608 } 1609 if (!checker) { 1610 return new PropTypeError( 1611 "Invalid " + location + " `" + propFullName + "` key `" + key + "` supplied to `" + componentName + "`.\nBad object: " + JSON.stringify(props[propName], null, " ") + "\nValid keys: " + JSON.stringify(Object.keys(shapeTypes), null, " ") 1612 ); 1613 } 1614 var error = checker(propValue, key, componentName, location, propFullName + "." + key, ReactPropTypesSecret); 1615 if (error) { 1616 return error; 1617 } 1618 } 1619 return null; 1620 } 1621 return createChainableTypeChecker(validate); 1622 } 1623 function isNode(propValue) { 1624 switch (typeof propValue) { 1625 case "number": 1626 case "string": 1627 case "undefined": 1628 return true; 1629 case "boolean": 1630 return !propValue; 1631 case "object": 1632 if (Array.isArray(propValue)) { 1633 return propValue.every(isNode); 1634 } 1635 if (propValue === null || isValidElement(propValue)) { 1636 return true; 1637 } 1638 var iteratorFn = getIteratorFn(propValue); 1639 if (iteratorFn) { 1640 var iterator = iteratorFn.call(propValue); 1641 var step; 1642 if (iteratorFn !== propValue.entries) { 1643 while (!(step = iterator.next()).done) { 1644 if (!isNode(step.value)) { 1645 return false; 1646 } 1647 } 1648 } else { 1649 while (!(step = iterator.next()).done) { 1650 var entry = step.value; 1651 if (entry) { 1652 if (!isNode(entry[1])) { 1653 return false; 1654 } 1655 } 1656 } 1657 } 1658 } else { 1659 return false; 1660 } 1661 return true; 1662 default: 1663 return false; 1664 } 1665 } 1666 function isSymbol(propType, propValue) { 1667 if (propType === "symbol") { 1668 return true; 1669 } 1670 if (!propValue) { 1671 return false; 1672 } 1673 if (propValue["@@toStringTag"] === "Symbol") { 1674 return true; 1675 } 1676 if (typeof Symbol === "function" && propValue instanceof Symbol) { 1677 return true; 1678 } 1679 return false; 1680 } 1681 function getPropType(propValue) { 1682 var propType = typeof propValue; 1683 if (Array.isArray(propValue)) { 1684 return "array"; 1685 } 1686 if (propValue instanceof RegExp) { 1687 return "object"; 1688 } 1689 if (isSymbol(propType, propValue)) { 1690 return "symbol"; 1691 } 1692 return propType; 1693 } 1694 function getPreciseType(propValue) { 1695 if (typeof propValue === "undefined" || propValue === null) { 1696 return "" + propValue; 1697 } 1698 var propType = getPropType(propValue); 1699 if (propType === "object") { 1700 if (propValue instanceof Date) { 1701 return "date"; 1702 } else if (propValue instanceof RegExp) { 1703 return "regexp"; 1704 } 1705 } 1706 return propType; 1707 } 1708 function getPostfixForTypeWarning(value) { 1709 var type = getPreciseType(value); 1710 switch (type) { 1711 case "array": 1712 case "object": 1713 return "an " + type; 1714 case "boolean": 1715 case "date": 1716 case "regexp": 1717 return "a " + type; 1718 default: 1719 return type; 1720 } 1721 } 1722 function getClassName(propValue) { 1723 if (!propValue.constructor || !propValue.constructor.name) { 1724 return ANONYMOUS; 1725 } 1726 return propValue.constructor.name; 1727 } 1728 ReactPropTypes.checkPropTypes = checkPropTypes; 1729 ReactPropTypes.resetWarningCache = checkPropTypes.resetWarningCache; 1730 ReactPropTypes.PropTypes = ReactPropTypes; 1731 return ReactPropTypes; 1732 }; 1733 } 1734 }); 1735 1736 // node_modules/prop-types/index.js 1737 var require_prop_types = __commonJS({ 1738 "node_modules/prop-types/index.js"(exports, module) { 1739 if (true) { 1740 ReactIs = require_react_is(); 1741 throwOnDirectAccess = true; 1742 module.exports = require_factoryWithTypeCheckers()(ReactIs.isElement, throwOnDirectAccess); 1743 } else { 1744 module.exports = null(); 1745 } 1746 var ReactIs; 1747 var throwOnDirectAccess; 1748 } 1749 }); 1750 1751 // node_modules/autosize/dist/autosize.js 1752 var require_autosize = __commonJS({ 1753 "node_modules/autosize/dist/autosize.js"(exports, module) { 1754 (function(global, factory) { 1755 if (typeof define === "function" && define.amd) { 1756 define(["module", "exports"], factory); 1757 } else if (typeof exports !== "undefined") { 1758 factory(module, exports); 1759 } else { 1760 var mod = { 1761 exports: {} 1762 }; 1763 factory(mod, mod.exports); 1764 global.autosize = mod.exports; 1765 } 1766 })(exports, function(module2, exports2) { 1767 "use strict"; 1768 var map = typeof Map === "function" ? /* @__PURE__ */ new Map() : /* @__PURE__ */ (function() { 1769 var keys = []; 1770 var values = []; 1771 return { 1772 has: function has2(key) { 1773 return keys.indexOf(key) > -1; 1774 }, 1775 get: function get(key) { 1776 return values[keys.indexOf(key)]; 1777 }, 1778 set: function set(key, value) { 1779 if (keys.indexOf(key) === -1) { 1780 keys.push(key); 1781 values.push(value); 1782 } 1783 }, 1784 delete: function _delete(key) { 1785 var index = keys.indexOf(key); 1786 if (index > -1) { 1787 keys.splice(index, 1); 1788 values.splice(index, 1); 1789 } 1790 } 1791 }; 1792 })(); 1793 var createEvent = function createEvent2(name) { 1794 return new Event(name, { bubbles: true }); 1795 }; 1796 try { 1797 new Event("test"); 1798 } catch (e2) { 1799 createEvent = function createEvent2(name) { 1800 var evt = document.createEvent("Event"); 1801 evt.initEvent(name, true, false); 1802 return evt; 1803 }; 1804 } 1805 function assign2(ta) { 1806 if (!ta || !ta.nodeName || ta.nodeName !== "TEXTAREA" || map.has(ta)) return; 1807 var heightOffset = null; 1808 var clientWidth = null; 1809 var cachedHeight = null; 1810 function init() { 1811 var style = window.getComputedStyle(ta, null); 1812 if (style.resize === "vertical") { 1813 ta.style.resize = "none"; 1814 } else if (style.resize === "both") { 1815 ta.style.resize = "horizontal"; 1816 } 1817 if (style.boxSizing === "content-box") { 1818 heightOffset = -(parseFloat(style.paddingTop) + parseFloat(style.paddingBottom)); 1819 } else { 1820 heightOffset = parseFloat(style.borderTopWidth) + parseFloat(style.borderBottomWidth); 1821 } 1822 if (isNaN(heightOffset)) { 1823 heightOffset = 0; 1824 } 1825 update4(); 1826 } 1827 function changeOverflow(value) { 1828 { 1829 var width = ta.style.width; 1830 ta.style.width = "0px"; 1831 ta.offsetWidth; 1832 ta.style.width = width; 1833 } 1834 ta.style.overflowY = value; 1835 } 1836 function getParentOverflows(el) { 1837 var arr = []; 1838 while (el && el.parentNode && el.parentNode instanceof Element) { 1839 if (el.parentNode.scrollTop) { 1840 arr.push({ 1841 node: el.parentNode, 1842 scrollTop: el.parentNode.scrollTop 1843 }); 1844 } 1845 el = el.parentNode; 1846 } 1847 return arr; 1848 } 1849 function resize() { 1850 if (ta.scrollHeight === 0) { 1851 return; 1852 } 1853 var overflows = getParentOverflows(ta); 1854 var docTop = document.documentElement && document.documentElement.scrollTop; 1855 ta.style.height = ""; 1856 ta.style.height = ta.scrollHeight + heightOffset + "px"; 1857 clientWidth = ta.clientWidth; 1858 overflows.forEach(function(el) { 1859 el.node.scrollTop = el.scrollTop; 1860 }); 1861 if (docTop) { 1862 document.documentElement.scrollTop = docTop; 1863 } 1864 } 1865 function update4() { 1866 resize(); 1867 var styleHeight = Math.round(parseFloat(ta.style.height)); 1868 var computed = window.getComputedStyle(ta, null); 1869 var actualHeight = computed.boxSizing === "content-box" ? Math.round(parseFloat(computed.height)) : ta.offsetHeight; 1870 if (actualHeight < styleHeight) { 1871 if (computed.overflowY === "hidden") { 1872 changeOverflow("scroll"); 1873 resize(); 1874 actualHeight = computed.boxSizing === "content-box" ? Math.round(parseFloat(window.getComputedStyle(ta, null).height)) : ta.offsetHeight; 1875 } 1876 } else { 1877 if (computed.overflowY !== "hidden") { 1878 changeOverflow("hidden"); 1879 resize(); 1880 actualHeight = computed.boxSizing === "content-box" ? Math.round(parseFloat(window.getComputedStyle(ta, null).height)) : ta.offsetHeight; 1881 } 1882 } 1883 if (cachedHeight !== actualHeight) { 1884 cachedHeight = actualHeight; 1885 var evt = createEvent("autosize:resized"); 1886 try { 1887 ta.dispatchEvent(evt); 1888 } catch (err) { 1889 } 1890 } 1891 } 1892 var pageResize = function pageResize2() { 1893 if (ta.clientWidth !== clientWidth) { 1894 update4(); 1895 } 1896 }; 1897 var destroy2 = function(style) { 1898 window.removeEventListener("resize", pageResize, false); 1899 ta.removeEventListener("input", update4, false); 1900 ta.removeEventListener("keyup", update4, false); 1901 ta.removeEventListener("autosize:destroy", destroy2, false); 1902 ta.removeEventListener("autosize:update", update4, false); 1903 Object.keys(style).forEach(function(key) { 1904 ta.style[key] = style[key]; 1905 }); 1906 map.delete(ta); 1907 }.bind(ta, { 1908 height: ta.style.height, 1909 resize: ta.style.resize, 1910 overflowY: ta.style.overflowY, 1911 overflowX: ta.style.overflowX, 1912 wordWrap: ta.style.wordWrap 1913 }); 1914 ta.addEventListener("autosize:destroy", destroy2, false); 1915 if ("onpropertychange" in ta && "oninput" in ta) { 1916 ta.addEventListener("keyup", update4, false); 1917 } 1918 window.addEventListener("resize", pageResize, false); 1919 ta.addEventListener("input", update4, false); 1920 ta.addEventListener("autosize:update", update4, false); 1921 ta.style.overflowX = "hidden"; 1922 ta.style.wordWrap = "break-word"; 1923 map.set(ta, { 1924 destroy: destroy2, 1925 update: update4 1926 }); 1927 init(); 1928 } 1929 function destroy(ta) { 1930 var methods = map.get(ta); 1931 if (methods) { 1932 methods.destroy(); 1933 } 1934 } 1935 function update3(ta) { 1936 var methods = map.get(ta); 1937 if (methods) { 1938 methods.update(); 1939 } 1940 } 1941 var autosize = null; 1942 if (typeof window === "undefined" || typeof window.getComputedStyle !== "function") { 1943 autosize = function autosize2(el) { 1944 return el; 1945 }; 1946 autosize.destroy = function(el) { 1947 return el; 1948 }; 1949 autosize.update = function(el) { 1950 return el; 1951 }; 1952 } else { 1953 autosize = function autosize2(el, options) { 1954 if (el) { 1955 Array.prototype.forEach.call(el.length ? el : [el], function(x2) { 1956 return assign2(x2, options); 1957 }); 1958 } 1959 return el; 1960 }; 1961 autosize.destroy = function(el) { 1962 if (el) { 1963 Array.prototype.forEach.call(el.length ? el : [el], destroy); 1964 } 1965 return el; 1966 }; 1967 autosize.update = function(el) { 1968 if (el) { 1969 Array.prototype.forEach.call(el.length ? el : [el], update3); 1970 } 1971 return el; 1972 }; 1973 } 1974 exports2.default = autosize; 1975 module2.exports = exports2["default"]; 1976 }); 1977 } 1978 }); 1979 1980 // node_modules/computed-style/dist/computedStyle.commonjs.js 1981 var require_computedStyle_commonjs = __commonJS({ 1982 "node_modules/computed-style/dist/computedStyle.commonjs.js"(exports, module) { 1983 var computedStyle = function(el, prop, getComputedStyle) { 1984 getComputedStyle = window.getComputedStyle; 1985 return ( 1986 // If we have getComputedStyle 1987 (getComputedStyle ? ( 1988 // Query it 1989 // TODO: From CSS-Query notes, we might need (node, null) for FF 1990 getComputedStyle(el) 1991 ) : ( 1992 // Otherwise, we are in IE and use currentStyle 1993 el.currentStyle 1994 ))[ 1995 // Switch to camelCase for CSSOM 1996 // DEV: Grabbed from jQuery 1997 // https://github.com/jquery/jquery/blob/1.9-stable/src/css.js#L191-L194 1998 // https://github.com/jquery/jquery/blob/1.9-stable/src/core.js#L593-L597 1999 prop.replace(/-(\w)/gi, function(word, letter) { 2000 return letter.toUpperCase(); 2001 }) 2002 ] 2003 ); 2004 }; 2005 module.exports = computedStyle; 2006 } 2007 }); 2008 2009 // node_modules/line-height/lib/line-height.js 2010 var require_line_height = __commonJS({ 2011 "node_modules/line-height/lib/line-height.js"(exports, module) { 2012 var computedStyle = require_computedStyle_commonjs(); 2013 function lineHeight(node) { 2014 var lnHeightStr = computedStyle(node, "line-height"); 2015 var lnHeight = parseFloat(lnHeightStr, 10); 2016 if (lnHeightStr === lnHeight + "") { 2017 var _lnHeightStyle = node.style.lineHeight; 2018 node.style.lineHeight = lnHeightStr + "em"; 2019 lnHeightStr = computedStyle(node, "line-height"); 2020 lnHeight = parseFloat(lnHeightStr, 10); 2021 if (_lnHeightStyle) { 2022 node.style.lineHeight = _lnHeightStyle; 2023 } else { 2024 delete node.style.lineHeight; 2025 } 2026 } 2027 if (lnHeightStr.indexOf("pt") !== -1) { 2028 lnHeight *= 4; 2029 lnHeight /= 3; 2030 } else if (lnHeightStr.indexOf("mm") !== -1) { 2031 lnHeight *= 96; 2032 lnHeight /= 25.4; 2033 } else if (lnHeightStr.indexOf("cm") !== -1) { 2034 lnHeight *= 96; 2035 lnHeight /= 2.54; 2036 } else if (lnHeightStr.indexOf("in") !== -1) { 2037 lnHeight *= 96; 2038 } else if (lnHeightStr.indexOf("pc") !== -1) { 2039 lnHeight *= 16; 2040 } 2041 lnHeight = Math.round(lnHeight); 2042 if (lnHeightStr === "normal") { 2043 var nodeName = node.nodeName; 2044 var _node = document.createElement(nodeName); 2045 _node.innerHTML = " "; 2046 if (nodeName.toUpperCase() === "TEXTAREA") { 2047 _node.setAttribute("rows", "1"); 2048 } 2049 var fontSizeStr = computedStyle(node, "font-size"); 2050 _node.style.fontSize = fontSizeStr; 2051 _node.style.padding = "0px"; 2052 _node.style.border = "0px"; 2053 var body = document.body; 2054 body.appendChild(_node); 2055 var height = _node.offsetHeight; 2056 lnHeight = height; 2057 body.removeChild(_node); 2058 } 2059 return lnHeight; 2060 } 2061 module.exports = lineHeight; 2062 } 2063 }); 2064 2065 // node_modules/react-autosize-textarea/lib/TextareaAutosize.js 2066 var require_TextareaAutosize = __commonJS({ 2067 "node_modules/react-autosize-textarea/lib/TextareaAutosize.js"(exports) { 2068 "use strict"; 2069 var __extends2 = exports && exports.__extends || (function() { 2070 var extendStatics2 = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) { 2071 d2.__proto__ = b2; 2072 } || function(d2, b2) { 2073 for (var p2 in b2) if (b2.hasOwnProperty(p2)) d2[p2] = b2[p2]; 2074 }; 2075 return function(d2, b2) { 2076 extendStatics2(d2, b2); 2077 function __214() { 2078 this.constructor = d2; 2079 } 2080 d2.prototype = b2 === null ? Object.create(b2) : (__214.prototype = b2.prototype, new __214()); 2081 }; 2082 })(); 2083 var __assign2 = exports && exports.__assign || Object.assign || function(t3) { 2084 for (var s2, i2 = 1, n2 = arguments.length; i2 < n2; i2++) { 2085 s2 = arguments[i2]; 2086 for (var p2 in s2) if (Object.prototype.hasOwnProperty.call(s2, p2)) 2087 t3[p2] = s2[p2]; 2088 } 2089 return t3; 2090 }; 2091 var __rest = exports && exports.__rest || function(s2, e2) { 2092 var t3 = {}; 2093 for (var p2 in s2) if (Object.prototype.hasOwnProperty.call(s2, p2) && e2.indexOf(p2) < 0) 2094 t3[p2] = s2[p2]; 2095 if (s2 != null && typeof Object.getOwnPropertySymbols === "function") { 2096 for (var i2 = 0, p2 = Object.getOwnPropertySymbols(s2); i2 < p2.length; i2++) if (e2.indexOf(p2[i2]) < 0) 2097 t3[p2[i2]] = s2[p2[i2]]; 2098 } 2099 return t3; 2100 }; 2101 exports.__esModule = true; 2102 var React4 = require_react(); 2103 var PropTypes = require_prop_types(); 2104 var autosize = require_autosize(); 2105 var _getLineHeight = require_line_height(); 2106 var getLineHeight = _getLineHeight; 2107 var RESIZED = "autosize:resized"; 2108 var TextareaAutosizeClass = ( 2109 /** @class */ 2110 (function(_super) { 2111 __extends2(TextareaAutosizeClass2, _super); 2112 function TextareaAutosizeClass2() { 2113 var _this = _super !== null && _super.apply(this, arguments) || this; 2114 _this.state = { 2115 lineHeight: null 2116 }; 2117 _this.textarea = null; 2118 _this.onResize = function(e2) { 2119 if (_this.props.onResize) { 2120 _this.props.onResize(e2); 2121 } 2122 }; 2123 _this.updateLineHeight = function() { 2124 if (_this.textarea) { 2125 _this.setState({ 2126 lineHeight: getLineHeight(_this.textarea) 2127 }); 2128 } 2129 }; 2130 _this.onChange = function(e2) { 2131 var onChange = _this.props.onChange; 2132 _this.currentValue = e2.currentTarget.value; 2133 onChange && onChange(e2); 2134 }; 2135 return _this; 2136 } 2137 TextareaAutosizeClass2.prototype.componentDidMount = function() { 2138 var _this = this; 2139 var _a = this.props, maxRows = _a.maxRows, async = _a.async; 2140 if (typeof maxRows === "number") { 2141 this.updateLineHeight(); 2142 } 2143 if (typeof maxRows === "number" || async) { 2144 setTimeout(function() { 2145 return _this.textarea && autosize(_this.textarea); 2146 }); 2147 } else { 2148 this.textarea && autosize(this.textarea); 2149 } 2150 if (this.textarea) { 2151 this.textarea.addEventListener(RESIZED, this.onResize); 2152 } 2153 }; 2154 TextareaAutosizeClass2.prototype.componentWillUnmount = function() { 2155 if (this.textarea) { 2156 this.textarea.removeEventListener(RESIZED, this.onResize); 2157 autosize.destroy(this.textarea); 2158 } 2159 }; 2160 TextareaAutosizeClass2.prototype.render = function() { 2161 var _this = this; 2162 var _a = this, _b = _a.props, onResize = _b.onResize, maxRows = _b.maxRows, onChange = _b.onChange, style = _b.style, innerRef = _b.innerRef, children = _b.children, props = __rest(_b, ["onResize", "maxRows", "onChange", "style", "innerRef", "children"]), lineHeight = _a.state.lineHeight; 2163 var maxHeight = maxRows && lineHeight ? lineHeight * maxRows : null; 2164 return React4.createElement("textarea", __assign2({}, props, { onChange: this.onChange, style: maxHeight ? __assign2({}, style, { maxHeight }) : style, ref: function(element) { 2165 _this.textarea = element; 2166 if (typeof _this.props.innerRef === "function") { 2167 _this.props.innerRef(element); 2168 } else if (_this.props.innerRef) { 2169 _this.props.innerRef.current = element; 2170 } 2171 } }), children); 2172 }; 2173 TextareaAutosizeClass2.prototype.componentDidUpdate = function() { 2174 this.textarea && autosize.update(this.textarea); 2175 }; 2176 TextareaAutosizeClass2.defaultProps = { 2177 rows: 1, 2178 async: false 2179 }; 2180 TextareaAutosizeClass2.propTypes = { 2181 rows: PropTypes.number, 2182 maxRows: PropTypes.number, 2183 onResize: PropTypes.func, 2184 innerRef: PropTypes.any, 2185 async: PropTypes.bool 2186 }; 2187 return TextareaAutosizeClass2; 2188 })(React4.Component) 2189 ); 2190 exports.TextareaAutosize = React4.forwardRef(function(props, ref) { 2191 return React4.createElement(TextareaAutosizeClass, __assign2({}, props, { innerRef: ref })); 2192 }); 2193 } 2194 }); 2195 2196 // node_modules/react-autosize-textarea/lib/index.js 2197 var require_lib = __commonJS({ 2198 "node_modules/react-autosize-textarea/lib/index.js"(exports) { 2199 "use strict"; 2200 exports.__esModule = true; 2201 var TextareaAutosize_1 = require_TextareaAutosize(); 2202 exports["default"] = TextareaAutosize_1.TextareaAutosize; 2203 } 2204 }); 2205 2206 // package-external:@wordpress/warning 2207 var require_warning = __commonJS({ 2208 "package-external:@wordpress/warning"(exports, module) { 2209 module.exports = window.wp.warning; 2210 } 2211 }); 2212 2213 // vendor-external:react-dom 2214 var require_react_dom = __commonJS({ 2215 "vendor-external:react-dom"(exports, module) { 2216 module.exports = window.ReactDOM; 2217 } 2218 }); 2219 2220 // package-external:@wordpress/blob 2221 var require_blob = __commonJS({ 2222 "package-external:@wordpress/blob"(exports, module) { 2223 module.exports = window.wp.blob; 2224 } 2225 }); 2226 2227 // package-external:@wordpress/keyboard-shortcuts 2228 var require_keyboard_shortcuts = __commonJS({ 2229 "package-external:@wordpress/keyboard-shortcuts"(exports, module) { 2230 module.exports = window.wp.keyboardShortcuts; 2231 } 2232 }); 2233 2234 // (disabled):node_modules/postcss/node_modules/source-map-js/source-map.js 2235 var require_source_map = __commonJS({ 2236 "(disabled):node_modules/postcss/node_modules/source-map-js/source-map.js"() { 2237 } 2238 }); 2239 2240 // (disabled):path 2241 var require_path = __commonJS({ 2242 "(disabled):path"() { 2243 } 2244 }); 2245 2246 // (disabled):node_modules/url/url.js 2247 var require_url2 = __commonJS({ 2248 "(disabled):node_modules/url/url.js"() { 2249 } 2250 }); 2251 2252 // node_modules/nanoid/non-secure/index.cjs 2253 var require_non_secure = __commonJS({ 2254 "node_modules/nanoid/non-secure/index.cjs"(exports, module) { 2255 var urlAlphabet = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict"; 2256 var customAlphabet = (alphabet, defaultSize = 21) => { 2257 return (size = defaultSize) => { 2258 let id = ""; 2259 let i2 = size | 0; 2260 while (i2--) { 2261 id += alphabet[Math.random() * alphabet.length | 0]; 2262 } 2263 return id; 2264 }; 2265 }; 2266 var nanoid = (size = 21) => { 2267 let id = ""; 2268 let i2 = size | 0; 2269 while (i2--) { 2270 id += urlAlphabet[Math.random() * 64 | 0]; 2271 } 2272 return id; 2273 }; 2274 module.exports = { nanoid, customAlphabet }; 2275 } 2276 }); 2277 2278 // (disabled):node_modules/postcss/lib/terminal-highlight 2279 var require_terminal_highlight = __commonJS({ 2280 "(disabled):node_modules/postcss/lib/terminal-highlight"() { 2281 } 2282 }); 2283 2284 // node_modules/picocolors/picocolors.browser.js 2285 var require_picocolors_browser = __commonJS({ 2286 "node_modules/picocolors/picocolors.browser.js"(exports, module) { 2287 var x2 = String; 2288 var create6 = function() { 2289 return { isColorSupported: false, reset: x2, bold: x2, dim: x2, italic: x2, underline: x2, inverse: x2, hidden: x2, strikethrough: x2, black: x2, red: x2, green: x2, yellow: x2, blue: x2, magenta: x2, cyan: x2, white: x2, gray: x2, bgBlack: x2, bgRed: x2, bgGreen: x2, bgYellow: x2, bgBlue: x2, bgMagenta: x2, bgCyan: x2, bgWhite: x2, blackBright: x2, redBright: x2, greenBright: x2, yellowBright: x2, blueBright: x2, magentaBright: x2, cyanBright: x2, whiteBright: x2, bgBlackBright: x2, bgRedBright: x2, bgGreenBright: x2, bgYellowBright: x2, bgBlueBright: x2, bgMagentaBright: x2, bgCyanBright: x2, bgWhiteBright: x2 }; 2290 }; 2291 module.exports = create6(); 2292 module.exports.createColors = create6; 2293 } 2294 }); 2295 2296 // node_modules/postcss/lib/css-syntax-error.js 2297 var require_css_syntax_error = __commonJS({ 2298 "node_modules/postcss/lib/css-syntax-error.js"(exports, module) { 2299 "use strict"; 2300 var pico = require_picocolors_browser(); 2301 var terminalHighlight = require_terminal_highlight(); 2302 var CssSyntaxError2 = class _CssSyntaxError extends Error { 2303 constructor(message2, line, column, source, file, plugin) { 2304 super(message2); 2305 this.name = "CssSyntaxError"; 2306 this.reason = message2; 2307 if (file) { 2308 this.file = file; 2309 } 2310 if (source) { 2311 this.source = source; 2312 } 2313 if (plugin) { 2314 this.plugin = plugin; 2315 } 2316 if (typeof line !== "undefined" && typeof column !== "undefined") { 2317 if (typeof line === "number") { 2318 this.line = line; 2319 this.column = column; 2320 } else { 2321 this.line = line.line; 2322 this.column = line.column; 2323 this.endLine = column.line; 2324 this.endColumn = column.column; 2325 } 2326 } 2327 this.setMessage(); 2328 if (Error.captureStackTrace) { 2329 Error.captureStackTrace(this, _CssSyntaxError); 2330 } 2331 } 2332 setMessage() { 2333 this.message = this.plugin ? this.plugin + ": " : ""; 2334 this.message += this.file ? this.file : "<css input>"; 2335 if (typeof this.line !== "undefined") { 2336 this.message += ":" + this.line + ":" + this.column; 2337 } 2338 this.message += ": " + this.reason; 2339 } 2340 showSourceCode(color) { 2341 if (!this.source) return ""; 2342 let css = this.source; 2343 if (color == null) color = pico.isColorSupported; 2344 if (terminalHighlight) { 2345 if (color) css = terminalHighlight(css); 2346 } 2347 let lines = css.split(/\r?\n/); 2348 let start2 = Math.max(this.line - 3, 0); 2349 let end = Math.min(this.line + 2, lines.length); 2350 let maxWidth = String(end).length; 2351 let mark, aside; 2352 if (color) { 2353 let { bold, gray, red } = pico.createColors(true); 2354 mark = (text) => bold(red(text)); 2355 aside = (text) => gray(text); 2356 } else { 2357 mark = aside = (str) => str; 2358 } 2359 return lines.slice(start2, end).map((line, index) => { 2360 let number = start2 + 1 + index; 2361 let gutter = " " + (" " + number).slice(-maxWidth) + " | "; 2362 if (number === this.line) { 2363 let spacing = aside(gutter.replace(/\d/g, " ")) + line.slice(0, this.column - 1).replace(/[^\t]/g, " "); 2364 return mark(">") + aside(gutter) + line + "\n " + spacing + mark("^"); 2365 } 2366 return " " + aside(gutter) + line; 2367 }).join("\n"); 2368 } 2369 toString() { 2370 let code = this.showSourceCode(); 2371 if (code) { 2372 code = "\n\n" + code + "\n"; 2373 } 2374 return this.name + ": " + this.message + code; 2375 } 2376 }; 2377 module.exports = CssSyntaxError2; 2378 CssSyntaxError2.default = CssSyntaxError2; 2379 } 2380 }); 2381 2382 // (disabled):fs 2383 var require_fs = __commonJS({ 2384 "(disabled):fs"() { 2385 } 2386 }); 2387 2388 // node_modules/postcss/lib/previous-map.js 2389 var require_previous_map = __commonJS({ 2390 "node_modules/postcss/lib/previous-map.js"(exports, module) { 2391 "use strict"; 2392 var { SourceMapConsumer, SourceMapGenerator } = require_source_map(); 2393 var { existsSync, readFileSync } = require_fs(); 2394 var { dirname, join } = require_path(); 2395 function fromBase64(str) { 2396 if (Buffer) { 2397 return Buffer.from(str, "base64").toString(); 2398 } else { 2399 return window.atob(str); 2400 } 2401 } 2402 var PreviousMap = class { 2403 constructor(css, opts) { 2404 if (opts.map === false) return; 2405 this.loadAnnotation(css); 2406 this.inline = this.startWith(this.annotation, "data:"); 2407 let prev = opts.map ? opts.map.prev : void 0; 2408 let text = this.loadMap(opts.from, prev); 2409 if (!this.mapFile && opts.from) { 2410 this.mapFile = opts.from; 2411 } 2412 if (this.mapFile) this.root = dirname(this.mapFile); 2413 if (text) this.text = text; 2414 } 2415 consumer() { 2416 if (!this.consumerCache) { 2417 this.consumerCache = new SourceMapConsumer(this.text); 2418 } 2419 return this.consumerCache; 2420 } 2421 decodeInline(text) { 2422 let baseCharsetUri = /^data:application\/json;charset=utf-?8;base64,/; 2423 let baseUri = /^data:application\/json;base64,/; 2424 let charsetUri = /^data:application\/json;charset=utf-?8,/; 2425 let uri = /^data:application\/json,/; 2426 if (charsetUri.test(text) || uri.test(text)) { 2427 return decodeURIComponent(text.substr(RegExp.lastMatch.length)); 2428 } 2429 if (baseCharsetUri.test(text) || baseUri.test(text)) { 2430 return fromBase64(text.substr(RegExp.lastMatch.length)); 2431 } 2432 let encoding = text.match(/data:application\/json;([^,]+),/)[1]; 2433 throw new Error("Unsupported source map encoding " + encoding); 2434 } 2435 getAnnotationURL(sourceMapString) { 2436 return sourceMapString.replace(/^\/\*\s*# sourceMappingURL=/, "").trim(); 2437 } 2438 isMap(map) { 2439 if (typeof map !== "object") return false; 2440 return typeof map.mappings === "string" || typeof map._mappings === "string" || Array.isArray(map.sections); 2441 } 2442 loadAnnotation(css) { 2443 let comments = css.match(/\/\*\s*# sourceMappingURL=/gm); 2444 if (!comments) return; 2445 let start2 = css.lastIndexOf(comments.pop()); 2446 let end = css.indexOf("*/", start2); 2447 if (start2 > -1 && end > -1) { 2448 this.annotation = this.getAnnotationURL(css.substring(start2, end)); 2449 } 2450 } 2451 loadFile(path) { 2452 this.root = dirname(path); 2453 if (existsSync(path)) { 2454 this.mapFile = path; 2455 return readFileSync(path, "utf-8").toString().trim(); 2456 } 2457 } 2458 loadMap(file, prev) { 2459 if (prev === false) return false; 2460 if (prev) { 2461 if (typeof prev === "string") { 2462 return prev; 2463 } else if (typeof prev === "function") { 2464 let prevPath = prev(file); 2465 if (prevPath) { 2466 let map = this.loadFile(prevPath); 2467 if (!map) { 2468 throw new Error( 2469 "Unable to load previous source map: " + prevPath.toString() 2470 ); 2471 } 2472 return map; 2473 } 2474 } else if (prev instanceof SourceMapConsumer) { 2475 return SourceMapGenerator.fromSourceMap(prev).toString(); 2476 } else if (prev instanceof SourceMapGenerator) { 2477 return prev.toString(); 2478 } else if (this.isMap(prev)) { 2479 return JSON.stringify(prev); 2480 } else { 2481 throw new Error( 2482 "Unsupported previous source map format: " + prev.toString() 2483 ); 2484 } 2485 } else if (this.inline) { 2486 return this.decodeInline(this.annotation); 2487 } else if (this.annotation) { 2488 let map = this.annotation; 2489 if (file) map = join(dirname(file), map); 2490 return this.loadFile(map); 2491 } 2492 } 2493 startWith(string, start2) { 2494 if (!string) return false; 2495 return string.substr(0, start2.length) === start2; 2496 } 2497 withContent() { 2498 return !!(this.consumer().sourcesContent && this.consumer().sourcesContent.length > 0); 2499 } 2500 }; 2501 module.exports = PreviousMap; 2502 PreviousMap.default = PreviousMap; 2503 } 2504 }); 2505 2506 // node_modules/postcss/lib/input.js 2507 var require_input = __commonJS({ 2508 "node_modules/postcss/lib/input.js"(exports, module) { 2509 "use strict"; 2510 var { SourceMapConsumer, SourceMapGenerator } = require_source_map(); 2511 var { fileURLToPath, pathToFileURL } = require_url2(); 2512 var { isAbsolute, resolve } = require_path(); 2513 var { nanoid } = require_non_secure(); 2514 var terminalHighlight = require_terminal_highlight(); 2515 var CssSyntaxError2 = require_css_syntax_error(); 2516 var PreviousMap = require_previous_map(); 2517 var fromOffsetCache = Symbol("fromOffsetCache"); 2518 var sourceMapAvailable = Boolean(SourceMapConsumer && SourceMapGenerator); 2519 var pathAvailable = Boolean(resolve && isAbsolute); 2520 var Input = class { 2521 constructor(css, opts = {}) { 2522 if (css === null || typeof css === "undefined" || typeof css === "object" && !css.toString) { 2523 throw new Error(`PostCSS received $css} instead of CSS string`); 2524 } 2525 this.css = css.toString(); 2526 if (this.css[0] === "\uFEFF" || this.css[0] === "\uFFFE") { 2527 this.hasBOM = true; 2528 this.css = this.css.slice(1); 2529 } else { 2530 this.hasBOM = false; 2531 } 2532 if (opts.from) { 2533 if (!pathAvailable || /^\w+:\/\//.test(opts.from) || isAbsolute(opts.from)) { 2534 this.file = opts.from; 2535 } else { 2536 this.file = resolve(opts.from); 2537 } 2538 } 2539 if (pathAvailable && sourceMapAvailable) { 2540 let map = new PreviousMap(this.css, opts); 2541 if (map.text) { 2542 this.map = map; 2543 let file = map.consumer().file; 2544 if (!this.file && file) this.file = this.mapResolve(file); 2545 } 2546 } 2547 if (!this.file) { 2548 this.id = "<input css " + nanoid(6) + ">"; 2549 } 2550 if (this.map) this.map.file = this.from; 2551 } 2552 error(message2, line, column, opts = {}) { 2553 let result, endLine, endColumn; 2554 if (line && typeof line === "object") { 2555 let start2 = line; 2556 let end = column; 2557 if (typeof start2.offset === "number") { 2558 let pos = this.fromOffset(start2.offset); 2559 line = pos.line; 2560 column = pos.col; 2561 } else { 2562 line = start2.line; 2563 column = start2.column; 2564 } 2565 if (typeof end.offset === "number") { 2566 let pos = this.fromOffset(end.offset); 2567 endLine = pos.line; 2568 endColumn = pos.col; 2569 } else { 2570 endLine = end.line; 2571 endColumn = end.column; 2572 } 2573 } else if (!column) { 2574 let pos = this.fromOffset(line); 2575 line = pos.line; 2576 column = pos.col; 2577 } 2578 let origin = this.origin(line, column, endLine, endColumn); 2579 if (origin) { 2580 result = new CssSyntaxError2( 2581 message2, 2582 origin.endLine === void 0 ? origin.line : { column: origin.column, line: origin.line }, 2583 origin.endLine === void 0 ? origin.column : { column: origin.endColumn, line: origin.endLine }, 2584 origin.source, 2585 origin.file, 2586 opts.plugin 2587 ); 2588 } else { 2589 result = new CssSyntaxError2( 2590 message2, 2591 endLine === void 0 ? line : { column, line }, 2592 endLine === void 0 ? column : { column: endColumn, line: endLine }, 2593 this.css, 2594 this.file, 2595 opts.plugin 2596 ); 2597 } 2598 result.input = { column, endColumn, endLine, line, source: this.css }; 2599 if (this.file) { 2600 if (pathToFileURL) { 2601 result.input.url = pathToFileURL(this.file).toString(); 2602 } 2603 result.input.file = this.file; 2604 } 2605 return result; 2606 } 2607 fromOffset(offset) { 2608 let lastLine, lineToIndex; 2609 if (!this[fromOffsetCache]) { 2610 let lines = this.css.split("\n"); 2611 lineToIndex = new Array(lines.length); 2612 let prevIndex = 0; 2613 for (let i2 = 0, l2 = lines.length; i2 < l2; i2++) { 2614 lineToIndex[i2] = prevIndex; 2615 prevIndex += lines[i2].length + 1; 2616 } 2617 this[fromOffsetCache] = lineToIndex; 2618 } else { 2619 lineToIndex = this[fromOffsetCache]; 2620 } 2621 lastLine = lineToIndex[lineToIndex.length - 1]; 2622 let min = 0; 2623 if (offset >= lastLine) { 2624 min = lineToIndex.length - 1; 2625 } else { 2626 let max = lineToIndex.length - 2; 2627 let mid; 2628 while (min < max) { 2629 mid = min + (max - min >> 1); 2630 if (offset < lineToIndex[mid]) { 2631 max = mid - 1; 2632 } else if (offset >= lineToIndex[mid + 1]) { 2633 min = mid + 1; 2634 } else { 2635 min = mid; 2636 break; 2637 } 2638 } 2639 } 2640 return { 2641 col: offset - lineToIndex[min] + 1, 2642 line: min + 1 2643 }; 2644 } 2645 mapResolve(file) { 2646 if (/^\w+:\/\//.test(file)) { 2647 return file; 2648 } 2649 return resolve(this.map.consumer().sourceRoot || this.map.root || ".", file); 2650 } 2651 origin(line, column, endLine, endColumn) { 2652 if (!this.map) return false; 2653 let consumer = this.map.consumer(); 2654 let from = consumer.originalPositionFor({ column, line }); 2655 if (!from.source) return false; 2656 let to2; 2657 if (typeof endLine === "number") { 2658 to2 = consumer.originalPositionFor({ column: endColumn, line: endLine }); 2659 } 2660 let fromUrl; 2661 if (isAbsolute(from.source)) { 2662 fromUrl = pathToFileURL(from.source); 2663 } else { 2664 fromUrl = new URL( 2665 from.source, 2666 this.map.consumer().sourceRoot || pathToFileURL(this.map.mapFile) 2667 ); 2668 } 2669 let result = { 2670 column: from.column, 2671 endColumn: to2 && to2.column, 2672 endLine: to2 && to2.line, 2673 line: from.line, 2674 url: fromUrl.toString() 2675 }; 2676 if (fromUrl.protocol === "file:") { 2677 if (fileURLToPath) { 2678 result.file = fileURLToPath(fromUrl); 2679 } else { 2680 throw new Error(`file: protocol is not available in this PostCSS build`); 2681 } 2682 } 2683 let source = consumer.sourceContentFor(from.source); 2684 if (source) result.source = source; 2685 return result; 2686 } 2687 toJSON() { 2688 let json = {}; 2689 for (let name of ["hasBOM", "css", "file", "id"]) { 2690 if (this[name] != null) { 2691 json[name] = this[name]; 2692 } 2693 } 2694 if (this.map) { 2695 json.map = { ...this.map }; 2696 if (json.map.consumerCache) { 2697 json.map.consumerCache = void 0; 2698 } 2699 } 2700 return json; 2701 } 2702 get from() { 2703 return this.file || this.id; 2704 } 2705 }; 2706 module.exports = Input; 2707 Input.default = Input; 2708 if (terminalHighlight && terminalHighlight.registerInput) { 2709 terminalHighlight.registerInput(Input); 2710 } 2711 } 2712 }); 2713 2714 // node_modules/postcss/lib/map-generator.js 2715 var require_map_generator = __commonJS({ 2716 "node_modules/postcss/lib/map-generator.js"(exports, module) { 2717 "use strict"; 2718 var { SourceMapConsumer, SourceMapGenerator } = require_source_map(); 2719 var { dirname, relative, resolve, sep } = require_path(); 2720 var { pathToFileURL } = require_url2(); 2721 var Input = require_input(); 2722 var sourceMapAvailable = Boolean(SourceMapConsumer && SourceMapGenerator); 2723 var pathAvailable = Boolean(dirname && resolve && relative && sep); 2724 var MapGenerator = class { 2725 constructor(stringify2, root, opts, cssString) { 2726 this.stringify = stringify2; 2727 this.mapOpts = opts.map || {}; 2728 this.root = root; 2729 this.opts = opts; 2730 this.css = cssString; 2731 this.originalCSS = cssString; 2732 this.usesFileUrls = !this.mapOpts.from && this.mapOpts.absolute; 2733 this.memoizedFileURLs = /* @__PURE__ */ new Map(); 2734 this.memoizedPaths = /* @__PURE__ */ new Map(); 2735 this.memoizedURLs = /* @__PURE__ */ new Map(); 2736 } 2737 addAnnotation() { 2738 let content; 2739 if (this.isInline()) { 2740 content = "data:application/json;base64," + this.toBase64(this.map.toString()); 2741 } else if (typeof this.mapOpts.annotation === "string") { 2742 content = this.mapOpts.annotation; 2743 } else if (typeof this.mapOpts.annotation === "function") { 2744 content = this.mapOpts.annotation(this.opts.to, this.root); 2745 } else { 2746 content = this.outputFile() + ".map"; 2747 } 2748 let eol = "\n"; 2749 if (this.css.includes("\r\n")) eol = "\r\n"; 2750 this.css += eol + "/*# sourceMappingURL=" + content + " */"; 2751 } 2752 applyPrevMaps() { 2753 for (let prev of this.previous()) { 2754 let from = this.toUrl(this.path(prev.file)); 2755 let root = prev.root || dirname(prev.file); 2756 let map; 2757 if (this.mapOpts.sourcesContent === false) { 2758 map = new SourceMapConsumer(prev.text); 2759 if (map.sourcesContent) { 2760 map.sourcesContent = null; 2761 } 2762 } else { 2763 map = prev.consumer(); 2764 } 2765 this.map.applySourceMap(map, from, this.toUrl(this.path(root))); 2766 } 2767 } 2768 clearAnnotation() { 2769 if (this.mapOpts.annotation === false) return; 2770 if (this.root) { 2771 let node; 2772 for (let i2 = this.root.nodes.length - 1; i2 >= 0; i2--) { 2773 node = this.root.nodes[i2]; 2774 if (node.type !== "comment") continue; 2775 if (node.text.indexOf("# sourceMappingURL=") === 0) { 2776 this.root.removeChild(i2); 2777 } 2778 } 2779 } else if (this.css) { 2780 this.css = this.css.replace(/\n*?\/\*#[\S\s]*?\*\/$/gm, ""); 2781 } 2782 } 2783 generate() { 2784 this.clearAnnotation(); 2785 if (pathAvailable && sourceMapAvailable && this.isMap()) { 2786 return this.generateMap(); 2787 } else { 2788 let result = ""; 2789 this.stringify(this.root, (i2) => { 2790 result += i2; 2791 }); 2792 return [result]; 2793 } 2794 } 2795 generateMap() { 2796 if (this.root) { 2797 this.generateString(); 2798 } else if (this.previous().length === 1) { 2799 let prev = this.previous()[0].consumer(); 2800 prev.file = this.outputFile(); 2801 this.map = SourceMapGenerator.fromSourceMap(prev, { 2802 ignoreInvalidMapping: true 2803 }); 2804 } else { 2805 this.map = new SourceMapGenerator({ 2806 file: this.outputFile(), 2807 ignoreInvalidMapping: true 2808 }); 2809 this.map.addMapping({ 2810 generated: { column: 0, line: 1 }, 2811 original: { column: 0, line: 1 }, 2812 source: this.opts.from ? this.toUrl(this.path(this.opts.from)) : "<no source>" 2813 }); 2814 } 2815 if (this.isSourcesContent()) this.setSourcesContent(); 2816 if (this.root && this.previous().length > 0) this.applyPrevMaps(); 2817 if (this.isAnnotation()) this.addAnnotation(); 2818 if (this.isInline()) { 2819 return [this.css]; 2820 } else { 2821 return [this.css, this.map]; 2822 } 2823 } 2824 generateString() { 2825 this.css = ""; 2826 this.map = new SourceMapGenerator({ 2827 file: this.outputFile(), 2828 ignoreInvalidMapping: true 2829 }); 2830 let line = 1; 2831 let column = 1; 2832 let noSource = "<no source>"; 2833 let mapping = { 2834 generated: { column: 0, line: 0 }, 2835 original: { column: 0, line: 0 }, 2836 source: "" 2837 }; 2838 let lines, last; 2839 this.stringify(this.root, (str, node, type) => { 2840 this.css += str; 2841 if (node && type !== "end") { 2842 mapping.generated.line = line; 2843 mapping.generated.column = column - 1; 2844 if (node.source && node.source.start) { 2845 mapping.source = this.sourcePath(node); 2846 mapping.original.line = node.source.start.line; 2847 mapping.original.column = node.source.start.column - 1; 2848 this.map.addMapping(mapping); 2849 } else { 2850 mapping.source = noSource; 2851 mapping.original.line = 1; 2852 mapping.original.column = 0; 2853 this.map.addMapping(mapping); 2854 } 2855 } 2856 lines = str.match(/\n/g); 2857 if (lines) { 2858 line += lines.length; 2859 last = str.lastIndexOf("\n"); 2860 column = str.length - last; 2861 } else { 2862 column += str.length; 2863 } 2864 if (node && type !== "start") { 2865 let p2 = node.parent || { raws: {} }; 2866 let childless = node.type === "decl" || node.type === "atrule" && !node.nodes; 2867 if (!childless || node !== p2.last || p2.raws.semicolon) { 2868 if (node.source && node.source.end) { 2869 mapping.source = this.sourcePath(node); 2870 mapping.original.line = node.source.end.line; 2871 mapping.original.column = node.source.end.column - 1; 2872 mapping.generated.line = line; 2873 mapping.generated.column = column - 2; 2874 this.map.addMapping(mapping); 2875 } else { 2876 mapping.source = noSource; 2877 mapping.original.line = 1; 2878 mapping.original.column = 0; 2879 mapping.generated.line = line; 2880 mapping.generated.column = column - 1; 2881 this.map.addMapping(mapping); 2882 } 2883 } 2884 } 2885 }); 2886 } 2887 isAnnotation() { 2888 if (this.isInline()) { 2889 return true; 2890 } 2891 if (typeof this.mapOpts.annotation !== "undefined") { 2892 return this.mapOpts.annotation; 2893 } 2894 if (this.previous().length) { 2895 return this.previous().some((i2) => i2.annotation); 2896 } 2897 return true; 2898 } 2899 isInline() { 2900 if (typeof this.mapOpts.inline !== "undefined") { 2901 return this.mapOpts.inline; 2902 } 2903 let annotation = this.mapOpts.annotation; 2904 if (typeof annotation !== "undefined" && annotation !== true) { 2905 return false; 2906 } 2907 if (this.previous().length) { 2908 return this.previous().some((i2) => i2.inline); 2909 } 2910 return true; 2911 } 2912 isMap() { 2913 if (typeof this.opts.map !== "undefined") { 2914 return !!this.opts.map; 2915 } 2916 return this.previous().length > 0; 2917 } 2918 isSourcesContent() { 2919 if (typeof this.mapOpts.sourcesContent !== "undefined") { 2920 return this.mapOpts.sourcesContent; 2921 } 2922 if (this.previous().length) { 2923 return this.previous().some((i2) => i2.withContent()); 2924 } 2925 return true; 2926 } 2927 outputFile() { 2928 if (this.opts.to) { 2929 return this.path(this.opts.to); 2930 } else if (this.opts.from) { 2931 return this.path(this.opts.from); 2932 } else { 2933 return "to.css"; 2934 } 2935 } 2936 path(file) { 2937 if (this.mapOpts.absolute) return file; 2938 if (file.charCodeAt(0) === 60) return file; 2939 if (/^\w+:\/\//.test(file)) return file; 2940 let cached = this.memoizedPaths.get(file); 2941 if (cached) return cached; 2942 let from = this.opts.to ? dirname(this.opts.to) : "."; 2943 if (typeof this.mapOpts.annotation === "string") { 2944 from = dirname(resolve(from, this.mapOpts.annotation)); 2945 } 2946 let path = relative(from, file); 2947 this.memoizedPaths.set(file, path); 2948 return path; 2949 } 2950 previous() { 2951 if (!this.previousMaps) { 2952 this.previousMaps = []; 2953 if (this.root) { 2954 this.root.walk((node) => { 2955 if (node.source && node.source.input.map) { 2956 let map = node.source.input.map; 2957 if (!this.previousMaps.includes(map)) { 2958 this.previousMaps.push(map); 2959 } 2960 } 2961 }); 2962 } else { 2963 let input = new Input(this.originalCSS, this.opts); 2964 if (input.map) this.previousMaps.push(input.map); 2965 } 2966 } 2967 return this.previousMaps; 2968 } 2969 setSourcesContent() { 2970 let already = {}; 2971 if (this.root) { 2972 this.root.walk((node) => { 2973 if (node.source) { 2974 let from = node.source.input.from; 2975 if (from && !already[from]) { 2976 already[from] = true; 2977 let fromUrl = this.usesFileUrls ? this.toFileUrl(from) : this.toUrl(this.path(from)); 2978 this.map.setSourceContent(fromUrl, node.source.input.css); 2979 } 2980 } 2981 }); 2982 } else if (this.css) { 2983 let from = this.opts.from ? this.toUrl(this.path(this.opts.from)) : "<no source>"; 2984 this.map.setSourceContent(from, this.css); 2985 } 2986 } 2987 sourcePath(node) { 2988 if (this.mapOpts.from) { 2989 return this.toUrl(this.mapOpts.from); 2990 } else if (this.usesFileUrls) { 2991 return this.toFileUrl(node.source.input.from); 2992 } else { 2993 return this.toUrl(this.path(node.source.input.from)); 2994 } 2995 } 2996 toBase64(str) { 2997 if (Buffer) { 2998 return Buffer.from(str).toString("base64"); 2999 } else { 3000 return window.btoa(unescape(encodeURIComponent(str))); 3001 } 3002 } 3003 toFileUrl(path) { 3004 let cached = this.memoizedFileURLs.get(path); 3005 if (cached) return cached; 3006 if (pathToFileURL) { 3007 let fileURL = pathToFileURL(path).toString(); 3008 this.memoizedFileURLs.set(path, fileURL); 3009 return fileURL; 3010 } else { 3011 throw new Error( 3012 "`map.absolute` option is not available in this PostCSS build" 3013 ); 3014 } 3015 } 3016 toUrl(path) { 3017 let cached = this.memoizedURLs.get(path); 3018 if (cached) return cached; 3019 if (sep === "\\") { 3020 path = path.replace(/\\/g, "/"); 3021 } 3022 let url = encodeURI(path).replace(/[#?]/g, encodeURIComponent); 3023 this.memoizedURLs.set(path, url); 3024 return url; 3025 } 3026 }; 3027 module.exports = MapGenerator; 3028 } 3029 }); 3030 3031 // node_modules/postcss/lib/stringifier.js 3032 var require_stringifier = __commonJS({ 3033 "node_modules/postcss/lib/stringifier.js"(exports, module) { 3034 "use strict"; 3035 var DEFAULT_RAW = { 3036 after: "\n", 3037 beforeClose: "\n", 3038 beforeComment: "\n", 3039 beforeDecl: "\n", 3040 beforeOpen: " ", 3041 beforeRule: "\n", 3042 colon: ": ", 3043 commentLeft: " ", 3044 commentRight: " ", 3045 emptyBody: "", 3046 indent: " ", 3047 semicolon: false 3048 }; 3049 function capitalize(str) { 3050 return str[0].toUpperCase() + str.slice(1); 3051 } 3052 var Stringifier = class { 3053 constructor(builder) { 3054 this.builder = builder; 3055 } 3056 atrule(node, semicolon) { 3057 let name = "@" + node.name; 3058 let params = node.params ? this.rawValue(node, "params") : ""; 3059 if (typeof node.raws.afterName !== "undefined") { 3060 name += node.raws.afterName; 3061 } else if (params) { 3062 name += " "; 3063 } 3064 if (node.nodes) { 3065 this.block(node, name + params); 3066 } else { 3067 let end = (node.raws.between || "") + (semicolon ? ";" : ""); 3068 this.builder(name + params + end, node); 3069 } 3070 } 3071 beforeAfter(node, detect) { 3072 let value; 3073 if (node.type === "decl") { 3074 value = this.raw(node, null, "beforeDecl"); 3075 } else if (node.type === "comment") { 3076 value = this.raw(node, null, "beforeComment"); 3077 } else if (detect === "before") { 3078 value = this.raw(node, null, "beforeRule"); 3079 } else { 3080 value = this.raw(node, null, "beforeClose"); 3081 } 3082 let buf = node.parent; 3083 let depth = 0; 3084 while (buf && buf.type !== "root") { 3085 depth += 1; 3086 buf = buf.parent; 3087 } 3088 if (value.includes("\n")) { 3089 let indent = this.raw(node, null, "indent"); 3090 if (indent.length) { 3091 for (let step = 0; step < depth; step++) value += indent; 3092 } 3093 } 3094 return value; 3095 } 3096 block(node, start2) { 3097 let between = this.raw(node, "between", "beforeOpen"); 3098 this.builder(start2 + between + "{", node, "start"); 3099 let after; 3100 if (node.nodes && node.nodes.length) { 3101 this.body(node); 3102 after = this.raw(node, "after"); 3103 } else { 3104 after = this.raw(node, "after", "emptyBody"); 3105 } 3106 if (after) this.builder(after); 3107 this.builder("}", node, "end"); 3108 } 3109 body(node) { 3110 let last = node.nodes.length - 1; 3111 while (last > 0) { 3112 if (node.nodes[last].type !== "comment") break; 3113 last -= 1; 3114 } 3115 let semicolon = this.raw(node, "semicolon"); 3116 for (let i2 = 0; i2 < node.nodes.length; i2++) { 3117 let child = node.nodes[i2]; 3118 let before = this.raw(child, "before"); 3119 if (before) this.builder(before); 3120 this.stringify(child, last !== i2 || semicolon); 3121 } 3122 } 3123 comment(node) { 3124 let left = this.raw(node, "left", "commentLeft"); 3125 let right = this.raw(node, "right", "commentRight"); 3126 this.builder("/*" + left + node.text + right + "*/", node); 3127 } 3128 decl(node, semicolon) { 3129 let between = this.raw(node, "between", "colon"); 3130 let string = node.prop + between + this.rawValue(node, "value"); 3131 if (node.important) { 3132 string += node.raws.important || " !important"; 3133 } 3134 if (semicolon) string += ";"; 3135 this.builder(string, node); 3136 } 3137 document(node) { 3138 this.body(node); 3139 } 3140 raw(node, own, detect) { 3141 let value; 3142 if (!detect) detect = own; 3143 if (own) { 3144 value = node.raws[own]; 3145 if (typeof value !== "undefined") return value; 3146 } 3147 let parent = node.parent; 3148 if (detect === "before") { 3149 if (!parent || parent.type === "root" && parent.first === node) { 3150 return ""; 3151 } 3152 if (parent && parent.type === "document") { 3153 return ""; 3154 } 3155 } 3156 if (!parent) return DEFAULT_RAW[detect]; 3157 let root = node.root(); 3158 if (!root.rawCache) root.rawCache = {}; 3159 if (typeof root.rawCache[detect] !== "undefined") { 3160 return root.rawCache[detect]; 3161 } 3162 if (detect === "before" || detect === "after") { 3163 return this.beforeAfter(node, detect); 3164 } else { 3165 let method = "raw" + capitalize(detect); 3166 if (this[method]) { 3167 value = this[method](root, node); 3168 } else { 3169 root.walk((i2) => { 3170 value = i2.raws[own]; 3171 if (typeof value !== "undefined") return false; 3172 }); 3173 } 3174 } 3175 if (typeof value === "undefined") value = DEFAULT_RAW[detect]; 3176 root.rawCache[detect] = value; 3177 return value; 3178 } 3179 rawBeforeClose(root) { 3180 let value; 3181 root.walk((i2) => { 3182 if (i2.nodes && i2.nodes.length > 0) { 3183 if (typeof i2.raws.after !== "undefined") { 3184 value = i2.raws.after; 3185 if (value.includes("\n")) { 3186 value = value.replace(/[^\n]+$/, ""); 3187 } 3188 return false; 3189 } 3190 } 3191 }); 3192 if (value) value = value.replace(/\S/g, ""); 3193 return value; 3194 } 3195 rawBeforeComment(root, node) { 3196 let value; 3197 root.walkComments((i2) => { 3198 if (typeof i2.raws.before !== "undefined") { 3199 value = i2.raws.before; 3200 if (value.includes("\n")) { 3201 value = value.replace(/[^\n]+$/, ""); 3202 } 3203 return false; 3204 } 3205 }); 3206 if (typeof value === "undefined") { 3207 value = this.raw(node, null, "beforeDecl"); 3208 } else if (value) { 3209 value = value.replace(/\S/g, ""); 3210 } 3211 return value; 3212 } 3213 rawBeforeDecl(root, node) { 3214 let value; 3215 root.walkDecls((i2) => { 3216 if (typeof i2.raws.before !== "undefined") { 3217 value = i2.raws.before; 3218 if (value.includes("\n")) { 3219 value = value.replace(/[^\n]+$/, ""); 3220 } 3221 return false; 3222 } 3223 }); 3224 if (typeof value === "undefined") { 3225 value = this.raw(node, null, "beforeRule"); 3226 } else if (value) { 3227 value = value.replace(/\S/g, ""); 3228 } 3229 return value; 3230 } 3231 rawBeforeOpen(root) { 3232 let value; 3233 root.walk((i2) => { 3234 if (i2.type !== "decl") { 3235 value = i2.raws.between; 3236 if (typeof value !== "undefined") return false; 3237 } 3238 }); 3239 return value; 3240 } 3241 rawBeforeRule(root) { 3242 let value; 3243 root.walk((i2) => { 3244 if (i2.nodes && (i2.parent !== root || root.first !== i2)) { 3245 if (typeof i2.raws.before !== "undefined") { 3246 value = i2.raws.before; 3247 if (value.includes("\n")) { 3248 value = value.replace(/[^\n]+$/, ""); 3249 } 3250 return false; 3251 } 3252 } 3253 }); 3254 if (value) value = value.replace(/\S/g, ""); 3255 return value; 3256 } 3257 rawColon(root) { 3258 let value; 3259 root.walkDecls((i2) => { 3260 if (typeof i2.raws.between !== "undefined") { 3261 value = i2.raws.between.replace(/[^\s:]/g, ""); 3262 return false; 3263 } 3264 }); 3265 return value; 3266 } 3267 rawEmptyBody(root) { 3268 let value; 3269 root.walk((i2) => { 3270 if (i2.nodes && i2.nodes.length === 0) { 3271 value = i2.raws.after; 3272 if (typeof value !== "undefined") return false; 3273 } 3274 }); 3275 return value; 3276 } 3277 rawIndent(root) { 3278 if (root.raws.indent) return root.raws.indent; 3279 let value; 3280 root.walk((i2) => { 3281 let p2 = i2.parent; 3282 if (p2 && p2 !== root && p2.parent && p2.parent === root) { 3283 if (typeof i2.raws.before !== "undefined") { 3284 let parts = i2.raws.before.split("\n"); 3285 value = parts[parts.length - 1]; 3286 value = value.replace(/\S/g, ""); 3287 return false; 3288 } 3289 } 3290 }); 3291 return value; 3292 } 3293 rawSemicolon(root) { 3294 let value; 3295 root.walk((i2) => { 3296 if (i2.nodes && i2.nodes.length && i2.last.type === "decl") { 3297 value = i2.raws.semicolon; 3298 if (typeof value !== "undefined") return false; 3299 } 3300 }); 3301 return value; 3302 } 3303 rawValue(node, prop) { 3304 let value = node[prop]; 3305 let raw = node.raws[prop]; 3306 if (raw && raw.value === value) { 3307 return raw.raw; 3308 } 3309 return value; 3310 } 3311 root(node) { 3312 this.body(node); 3313 if (node.raws.after) this.builder(node.raws.after); 3314 } 3315 rule(node) { 3316 this.block(node, this.rawValue(node, "selector")); 3317 if (node.raws.ownSemicolon) { 3318 this.builder(node.raws.ownSemicolon, node, "end"); 3319 } 3320 } 3321 stringify(node, semicolon) { 3322 if (!this[node.type]) { 3323 throw new Error( 3324 "Unknown AST node type " + node.type + ". Maybe you need to change PostCSS stringifier." 3325 ); 3326 } 3327 this[node.type](node, semicolon); 3328 } 3329 }; 3330 module.exports = Stringifier; 3331 Stringifier.default = Stringifier; 3332 } 3333 }); 3334 3335 // node_modules/postcss/lib/stringify.js 3336 var require_stringify = __commonJS({ 3337 "node_modules/postcss/lib/stringify.js"(exports, module) { 3338 "use strict"; 3339 var Stringifier = require_stringifier(); 3340 function stringify2(node, builder) { 3341 let str = new Stringifier(builder); 3342 str.stringify(node); 3343 } 3344 module.exports = stringify2; 3345 stringify2.default = stringify2; 3346 } 3347 }); 3348 3349 // node_modules/postcss/lib/warn-once.js 3350 var require_warn_once = __commonJS({ 3351 "node_modules/postcss/lib/warn-once.js"(exports, module) { 3352 "use strict"; 3353 var printed = {}; 3354 module.exports = function warnOnce(message2) { 3355 if (printed[message2]) return; 3356 printed[message2] = true; 3357 if (typeof console !== "undefined" && console.warn) { 3358 console.warn(message2); 3359 } 3360 }; 3361 } 3362 }); 3363 3364 // node_modules/postcss/lib/symbols.js 3365 var require_symbols = __commonJS({ 3366 "node_modules/postcss/lib/symbols.js"(exports, module) { 3367 "use strict"; 3368 module.exports.isClean = Symbol("isClean"); 3369 module.exports.my = Symbol("my"); 3370 } 3371 }); 3372 3373 // node_modules/postcss/lib/node.js 3374 var require_node = __commonJS({ 3375 "node_modules/postcss/lib/node.js"(exports, module) { 3376 "use strict"; 3377 var { isClean, my } = require_symbols(); 3378 var CssSyntaxError2 = require_css_syntax_error(); 3379 var Stringifier = require_stringifier(); 3380 var stringify2 = require_stringify(); 3381 function cloneNode(obj, parent) { 3382 let cloned = new obj.constructor(); 3383 for (let i2 in obj) { 3384 if (!Object.prototype.hasOwnProperty.call(obj, i2)) { 3385 continue; 3386 } 3387 if (i2 === "proxyCache") continue; 3388 let value = obj[i2]; 3389 let type = typeof value; 3390 if (i2 === "parent" && type === "object") { 3391 if (parent) cloned[i2] = parent; 3392 } else if (i2 === "source") { 3393 cloned[i2] = value; 3394 } else if (Array.isArray(value)) { 3395 cloned[i2] = value.map((j2) => cloneNode(j2, cloned)); 3396 } else { 3397 if (type === "object" && value !== null) value = cloneNode(value); 3398 cloned[i2] = value; 3399 } 3400 } 3401 return cloned; 3402 } 3403 var Node = class { 3404 constructor(defaults2 = {}) { 3405 this.raws = {}; 3406 this[isClean] = false; 3407 this[my] = true; 3408 for (let name in defaults2) { 3409 if (name === "nodes") { 3410 this.nodes = []; 3411 for (let node of defaults2[name]) { 3412 if (typeof node.clone === "function") { 3413 this.append(node.clone()); 3414 } else { 3415 this.append(node); 3416 } 3417 } 3418 } else { 3419 this[name] = defaults2[name]; 3420 } 3421 } 3422 } 3423 addToError(error) { 3424 error.postcssNode = this; 3425 if (error.stack && this.source && /\n\s{4}at /.test(error.stack)) { 3426 let s2 = this.source; 3427 error.stack = error.stack.replace( 3428 /\n\s{4}at /, 3429 `$&$s2.input.from}:$s2.start.line}:$s2.start.column}$&` 3430 ); 3431 } 3432 return error; 3433 } 3434 after(add2) { 3435 this.parent.insertAfter(this, add2); 3436 return this; 3437 } 3438 assign(overrides = {}) { 3439 for (let name in overrides) { 3440 this[name] = overrides[name]; 3441 } 3442 return this; 3443 } 3444 before(add2) { 3445 this.parent.insertBefore(this, add2); 3446 return this; 3447 } 3448 cleanRaws(keepBetween) { 3449 delete this.raws.before; 3450 delete this.raws.after; 3451 if (!keepBetween) delete this.raws.between; 3452 } 3453 clone(overrides = {}) { 3454 let cloned = cloneNode(this); 3455 for (let name in overrides) { 3456 cloned[name] = overrides[name]; 3457 } 3458 return cloned; 3459 } 3460 cloneAfter(overrides = {}) { 3461 let cloned = this.clone(overrides); 3462 this.parent.insertAfter(this, cloned); 3463 return cloned; 3464 } 3465 cloneBefore(overrides = {}) { 3466 let cloned = this.clone(overrides); 3467 this.parent.insertBefore(this, cloned); 3468 return cloned; 3469 } 3470 error(message2, opts = {}) { 3471 if (this.source) { 3472 let { end, start: start2 } = this.rangeBy(opts); 3473 return this.source.input.error( 3474 message2, 3475 { column: start2.column, line: start2.line }, 3476 { column: end.column, line: end.line }, 3477 opts 3478 ); 3479 } 3480 return new CssSyntaxError2(message2); 3481 } 3482 getProxyProcessor() { 3483 return { 3484 get(node, prop) { 3485 if (prop === "proxyOf") { 3486 return node; 3487 } else if (prop === "root") { 3488 return () => node.root().toProxy(); 3489 } else { 3490 return node[prop]; 3491 } 3492 }, 3493 set(node, prop, value) { 3494 if (node[prop] === value) return true; 3495 node[prop] = value; 3496 if (prop === "prop" || prop === "value" || prop === "name" || prop === "params" || prop === "important" || /* c8 ignore next */ 3497 prop === "text") { 3498 node.markDirty(); 3499 } 3500 return true; 3501 } 3502 }; 3503 } 3504 markDirty() { 3505 if (this[isClean]) { 3506 this[isClean] = false; 3507 let next = this; 3508 while (next = next.parent) { 3509 next[isClean] = false; 3510 } 3511 } 3512 } 3513 next() { 3514 if (!this.parent) return void 0; 3515 let index = this.parent.index(this); 3516 return this.parent.nodes[index + 1]; 3517 } 3518 positionBy(opts, stringRepresentation) { 3519 let pos = this.source.start; 3520 if (opts.index) { 3521 pos = this.positionInside(opts.index, stringRepresentation); 3522 } else if (opts.word) { 3523 stringRepresentation = this.toString(); 3524 let index = stringRepresentation.indexOf(opts.word); 3525 if (index !== -1) pos = this.positionInside(index, stringRepresentation); 3526 } 3527 return pos; 3528 } 3529 positionInside(index, stringRepresentation) { 3530 let string = stringRepresentation || this.toString(); 3531 let column = this.source.start.column; 3532 let line = this.source.start.line; 3533 for (let i2 = 0; i2 < index; i2++) { 3534 if (string[i2] === "\n") { 3535 column = 1; 3536 line += 1; 3537 } else { 3538 column += 1; 3539 } 3540 } 3541 return { column, line }; 3542 } 3543 prev() { 3544 if (!this.parent) return void 0; 3545 let index = this.parent.index(this); 3546 return this.parent.nodes[index - 1]; 3547 } 3548 rangeBy(opts) { 3549 let start2 = { 3550 column: this.source.start.column, 3551 line: this.source.start.line 3552 }; 3553 let end = this.source.end ? { 3554 column: this.source.end.column + 1, 3555 line: this.source.end.line 3556 } : { 3557 column: start2.column + 1, 3558 line: start2.line 3559 }; 3560 if (opts.word) { 3561 let stringRepresentation = this.toString(); 3562 let index = stringRepresentation.indexOf(opts.word); 3563 if (index !== -1) { 3564 start2 = this.positionInside(index, stringRepresentation); 3565 end = this.positionInside(index + opts.word.length, stringRepresentation); 3566 } 3567 } else { 3568 if (opts.start) { 3569 start2 = { 3570 column: opts.start.column, 3571 line: opts.start.line 3572 }; 3573 } else if (opts.index) { 3574 start2 = this.positionInside(opts.index); 3575 } 3576 if (opts.end) { 3577 end = { 3578 column: opts.end.column, 3579 line: opts.end.line 3580 }; 3581 } else if (typeof opts.endIndex === "number") { 3582 end = this.positionInside(opts.endIndex); 3583 } else if (opts.index) { 3584 end = this.positionInside(opts.index + 1); 3585 } 3586 } 3587 if (end.line < start2.line || end.line === start2.line && end.column <= start2.column) { 3588 end = { column: start2.column + 1, line: start2.line }; 3589 } 3590 return { end, start: start2 }; 3591 } 3592 raw(prop, defaultType) { 3593 let str = new Stringifier(); 3594 return str.raw(this, prop, defaultType); 3595 } 3596 remove() { 3597 if (this.parent) { 3598 this.parent.removeChild(this); 3599 } 3600 this.parent = void 0; 3601 return this; 3602 } 3603 replaceWith(...nodes) { 3604 if (this.parent) { 3605 let bookmark = this; 3606 let foundSelf = false; 3607 for (let node of nodes) { 3608 if (node === this) { 3609 foundSelf = true; 3610 } else if (foundSelf) { 3611 this.parent.insertAfter(bookmark, node); 3612 bookmark = node; 3613 } else { 3614 this.parent.insertBefore(bookmark, node); 3615 } 3616 } 3617 if (!foundSelf) { 3618 this.remove(); 3619 } 3620 } 3621 return this; 3622 } 3623 root() { 3624 let result = this; 3625 while (result.parent && result.parent.type !== "document") { 3626 result = result.parent; 3627 } 3628 return result; 3629 } 3630 toJSON(_, inputs) { 3631 let fixed = {}; 3632 let emitInputs = inputs == null; 3633 inputs = inputs || /* @__PURE__ */ new Map(); 3634 let inputsNextIndex = 0; 3635 for (let name in this) { 3636 if (!Object.prototype.hasOwnProperty.call(this, name)) { 3637 continue; 3638 } 3639 if (name === "parent" || name === "proxyCache") continue; 3640 let value = this[name]; 3641 if (Array.isArray(value)) { 3642 fixed[name] = value.map((i2) => { 3643 if (typeof i2 === "object" && i2.toJSON) { 3644 return i2.toJSON(null, inputs); 3645 } else { 3646 return i2; 3647 } 3648 }); 3649 } else if (typeof value === "object" && value.toJSON) { 3650 fixed[name] = value.toJSON(null, inputs); 3651 } else if (name === "source") { 3652 let inputId = inputs.get(value.input); 3653 if (inputId == null) { 3654 inputId = inputsNextIndex; 3655 inputs.set(value.input, inputsNextIndex); 3656 inputsNextIndex++; 3657 } 3658 fixed[name] = { 3659 end: value.end, 3660 inputId, 3661 start: value.start 3662 }; 3663 } else { 3664 fixed[name] = value; 3665 } 3666 } 3667 if (emitInputs) { 3668 fixed.inputs = [...inputs.keys()].map((input) => input.toJSON()); 3669 } 3670 return fixed; 3671 } 3672 toProxy() { 3673 if (!this.proxyCache) { 3674 this.proxyCache = new Proxy(this, this.getProxyProcessor()); 3675 } 3676 return this.proxyCache; 3677 } 3678 toString(stringifier = stringify2) { 3679 if (stringifier.stringify) stringifier = stringifier.stringify; 3680 let result = ""; 3681 stringifier(this, (i2) => { 3682 result += i2; 3683 }); 3684 return result; 3685 } 3686 warn(result, text, opts) { 3687 let data = { node: this }; 3688 for (let i2 in opts) data[i2] = opts[i2]; 3689 return result.warn(text, data); 3690 } 3691 get proxyOf() { 3692 return this; 3693 } 3694 }; 3695 module.exports = Node; 3696 Node.default = Node; 3697 } 3698 }); 3699 3700 // node_modules/postcss/lib/declaration.js 3701 var require_declaration = __commonJS({ 3702 "node_modules/postcss/lib/declaration.js"(exports, module) { 3703 "use strict"; 3704 var Node = require_node(); 3705 var Declaration = class extends Node { 3706 constructor(defaults2) { 3707 if (defaults2 && typeof defaults2.value !== "undefined" && typeof defaults2.value !== "string") { 3708 defaults2 = { ...defaults2, value: String(defaults2.value) }; 3709 } 3710 super(defaults2); 3711 this.type = "decl"; 3712 } 3713 get variable() { 3714 return this.prop.startsWith("--") || this.prop[0] === "$"; 3715 } 3716 }; 3717 module.exports = Declaration; 3718 Declaration.default = Declaration; 3719 } 3720 }); 3721 3722 // node_modules/postcss/lib/comment.js 3723 var require_comment = __commonJS({ 3724 "node_modules/postcss/lib/comment.js"(exports, module) { 3725 "use strict"; 3726 var Node = require_node(); 3727 var Comment = class extends Node { 3728 constructor(defaults2) { 3729 super(defaults2); 3730 this.type = "comment"; 3731 } 3732 }; 3733 module.exports = Comment; 3734 Comment.default = Comment; 3735 } 3736 }); 3737 3738 // node_modules/postcss/lib/container.js 3739 var require_container = __commonJS({ 3740 "node_modules/postcss/lib/container.js"(exports, module) { 3741 "use strict"; 3742 var { isClean, my } = require_symbols(); 3743 var Declaration = require_declaration(); 3744 var Comment = require_comment(); 3745 var Node = require_node(); 3746 var parse4; 3747 var Rule; 3748 var AtRule; 3749 var Root2; 3750 function cleanSource(nodes) { 3751 return nodes.map((i2) => { 3752 if (i2.nodes) i2.nodes = cleanSource(i2.nodes); 3753 delete i2.source; 3754 return i2; 3755 }); 3756 } 3757 function markDirtyUp(node) { 3758 node[isClean] = false; 3759 if (node.proxyOf.nodes) { 3760 for (let i2 of node.proxyOf.nodes) { 3761 markDirtyUp(i2); 3762 } 3763 } 3764 } 3765 var Container = class _Container extends Node { 3766 append(...children) { 3767 for (let child of children) { 3768 let nodes = this.normalize(child, this.last); 3769 for (let node of nodes) this.proxyOf.nodes.push(node); 3770 } 3771 this.markDirty(); 3772 return this; 3773 } 3774 cleanRaws(keepBetween) { 3775 super.cleanRaws(keepBetween); 3776 if (this.nodes) { 3777 for (let node of this.nodes) node.cleanRaws(keepBetween); 3778 } 3779 } 3780 each(callback) { 3781 if (!this.proxyOf.nodes) return void 0; 3782 let iterator = this.getIterator(); 3783 let index, result; 3784 while (this.indexes[iterator] < this.proxyOf.nodes.length) { 3785 index = this.indexes[iterator]; 3786 result = callback(this.proxyOf.nodes[index], index); 3787 if (result === false) break; 3788 this.indexes[iterator] += 1; 3789 } 3790 delete this.indexes[iterator]; 3791 return result; 3792 } 3793 every(condition) { 3794 return this.nodes.every(condition); 3795 } 3796 getIterator() { 3797 if (!this.lastEach) this.lastEach = 0; 3798 if (!this.indexes) this.indexes = {}; 3799 this.lastEach += 1; 3800 let iterator = this.lastEach; 3801 this.indexes[iterator] = 0; 3802 return iterator; 3803 } 3804 getProxyProcessor() { 3805 return { 3806 get(node, prop) { 3807 if (prop === "proxyOf") { 3808 return node; 3809 } else if (!node[prop]) { 3810 return node[prop]; 3811 } else if (prop === "each" || typeof prop === "string" && prop.startsWith("walk")) { 3812 return (...args) => { 3813 return node[prop]( 3814 ...args.map((i2) => { 3815 if (typeof i2 === "function") { 3816 return (child, index) => i2(child.toProxy(), index); 3817 } else { 3818 return i2; 3819 } 3820 }) 3821 ); 3822 }; 3823 } else if (prop === "every" || prop === "some") { 3824 return (cb) => { 3825 return node[prop]( 3826 (child, ...other) => cb(child.toProxy(), ...other) 3827 ); 3828 }; 3829 } else if (prop === "root") { 3830 return () => node.root().toProxy(); 3831 } else if (prop === "nodes") { 3832 return node.nodes.map((i2) => i2.toProxy()); 3833 } else if (prop === "first" || prop === "last") { 3834 return node[prop].toProxy(); 3835 } else { 3836 return node[prop]; 3837 } 3838 }, 3839 set(node, prop, value) { 3840 if (node[prop] === value) return true; 3841 node[prop] = value; 3842 if (prop === "name" || prop === "params" || prop === "selector") { 3843 node.markDirty(); 3844 } 3845 return true; 3846 } 3847 }; 3848 } 3849 index(child) { 3850 if (typeof child === "number") return child; 3851 if (child.proxyOf) child = child.proxyOf; 3852 return this.proxyOf.nodes.indexOf(child); 3853 } 3854 insertAfter(exist, add2) { 3855 let existIndex = this.index(exist); 3856 let nodes = this.normalize(add2, this.proxyOf.nodes[existIndex]).reverse(); 3857 existIndex = this.index(exist); 3858 for (let node of nodes) this.proxyOf.nodes.splice(existIndex + 1, 0, node); 3859 let index; 3860 for (let id in this.indexes) { 3861 index = this.indexes[id]; 3862 if (existIndex < index) { 3863 this.indexes[id] = index + nodes.length; 3864 } 3865 } 3866 this.markDirty(); 3867 return this; 3868 } 3869 insertBefore(exist, add2) { 3870 let existIndex = this.index(exist); 3871 let type = existIndex === 0 ? "prepend" : false; 3872 let nodes = this.normalize(add2, this.proxyOf.nodes[existIndex], type).reverse(); 3873 existIndex = this.index(exist); 3874 for (let node of nodes) this.proxyOf.nodes.splice(existIndex, 0, node); 3875 let index; 3876 for (let id in this.indexes) { 3877 index = this.indexes[id]; 3878 if (existIndex <= index) { 3879 this.indexes[id] = index + nodes.length; 3880 } 3881 } 3882 this.markDirty(); 3883 return this; 3884 } 3885 normalize(nodes, sample) { 3886 if (typeof nodes === "string") { 3887 nodes = cleanSource(parse4(nodes).nodes); 3888 } else if (typeof nodes === "undefined") { 3889 nodes = []; 3890 } else if (Array.isArray(nodes)) { 3891 nodes = nodes.slice(0); 3892 for (let i2 of nodes) { 3893 if (i2.parent) i2.parent.removeChild(i2, "ignore"); 3894 } 3895 } else if (nodes.type === "root" && this.type !== "document") { 3896 nodes = nodes.nodes.slice(0); 3897 for (let i2 of nodes) { 3898 if (i2.parent) i2.parent.removeChild(i2, "ignore"); 3899 } 3900 } else if (nodes.type) { 3901 nodes = [nodes]; 3902 } else if (nodes.prop) { 3903 if (typeof nodes.value === "undefined") { 3904 throw new Error("Value field is missed in node creation"); 3905 } else if (typeof nodes.value !== "string") { 3906 nodes.value = String(nodes.value); 3907 } 3908 nodes = [new Declaration(nodes)]; 3909 } else if (nodes.selector) { 3910 nodes = [new Rule(nodes)]; 3911 } else if (nodes.name) { 3912 nodes = [new AtRule(nodes)]; 3913 } else if (nodes.text) { 3914 nodes = [new Comment(nodes)]; 3915 } else { 3916 throw new Error("Unknown node type in node creation"); 3917 } 3918 let processed = nodes.map((i2) => { 3919 if (!i2[my]) _Container.rebuild(i2); 3920 i2 = i2.proxyOf; 3921 if (i2.parent) i2.parent.removeChild(i2); 3922 if (i2[isClean]) markDirtyUp(i2); 3923 if (typeof i2.raws.before === "undefined") { 3924 if (sample && typeof sample.raws.before !== "undefined") { 3925 i2.raws.before = sample.raws.before.replace(/\S/g, ""); 3926 } 3927 } 3928 i2.parent = this.proxyOf; 3929 return i2; 3930 }); 3931 return processed; 3932 } 3933 prepend(...children) { 3934 children = children.reverse(); 3935 for (let child of children) { 3936 let nodes = this.normalize(child, this.first, "prepend").reverse(); 3937 for (let node of nodes) this.proxyOf.nodes.unshift(node); 3938 for (let id in this.indexes) { 3939 this.indexes[id] = this.indexes[id] + nodes.length; 3940 } 3941 } 3942 this.markDirty(); 3943 return this; 3944 } 3945 push(child) { 3946 child.parent = this; 3947 this.proxyOf.nodes.push(child); 3948 return this; 3949 } 3950 removeAll() { 3951 for (let node of this.proxyOf.nodes) node.parent = void 0; 3952 this.proxyOf.nodes = []; 3953 this.markDirty(); 3954 return this; 3955 } 3956 removeChild(child) { 3957 child = this.index(child); 3958 this.proxyOf.nodes[child].parent = void 0; 3959 this.proxyOf.nodes.splice(child, 1); 3960 let index; 3961 for (let id in this.indexes) { 3962 index = this.indexes[id]; 3963 if (index >= child) { 3964 this.indexes[id] = index - 1; 3965 } 3966 } 3967 this.markDirty(); 3968 return this; 3969 } 3970 replaceValues(pattern, opts, callback) { 3971 if (!callback) { 3972 callback = opts; 3973 opts = {}; 3974 } 3975 this.walkDecls((decl) => { 3976 if (opts.props && !opts.props.includes(decl.prop)) return; 3977 if (opts.fast && !decl.value.includes(opts.fast)) return; 3978 decl.value = decl.value.replace(pattern, callback); 3979 }); 3980 this.markDirty(); 3981 return this; 3982 } 3983 some(condition) { 3984 return this.nodes.some(condition); 3985 } 3986 walk(callback) { 3987 return this.each((child, i2) => { 3988 let result; 3989 try { 3990 result = callback(child, i2); 3991 } catch (e2) { 3992 throw child.addToError(e2); 3993 } 3994 if (result !== false && child.walk) { 3995 result = child.walk(callback); 3996 } 3997 return result; 3998 }); 3999 } 4000 walkAtRules(name, callback) { 4001 if (!callback) { 4002 callback = name; 4003 return this.walk((child, i2) => { 4004 if (child.type === "atrule") { 4005 return callback(child, i2); 4006 } 4007 }); 4008 } 4009 if (name instanceof RegExp) { 4010 return this.walk((child, i2) => { 4011 if (child.type === "atrule" && name.test(child.name)) { 4012 return callback(child, i2); 4013 } 4014 }); 4015 } 4016 return this.walk((child, i2) => { 4017 if (child.type === "atrule" && child.name === name) { 4018 return callback(child, i2); 4019 } 4020 }); 4021 } 4022 walkComments(callback) { 4023 return this.walk((child, i2) => { 4024 if (child.type === "comment") { 4025 return callback(child, i2); 4026 } 4027 }); 4028 } 4029 walkDecls(prop, callback) { 4030 if (!callback) { 4031 callback = prop; 4032 return this.walk((child, i2) => { 4033 if (child.type === "decl") { 4034 return callback(child, i2); 4035 } 4036 }); 4037 } 4038 if (prop instanceof RegExp) { 4039 return this.walk((child, i2) => { 4040 if (child.type === "decl" && prop.test(child.prop)) { 4041 return callback(child, i2); 4042 } 4043 }); 4044 } 4045 return this.walk((child, i2) => { 4046 if (child.type === "decl" && child.prop === prop) { 4047 return callback(child, i2); 4048 } 4049 }); 4050 } 4051 walkRules(selector3, callback) { 4052 if (!callback) { 4053 callback = selector3; 4054 return this.walk((child, i2) => { 4055 if (child.type === "rule") { 4056 return callback(child, i2); 4057 } 4058 }); 4059 } 4060 if (selector3 instanceof RegExp) { 4061 return this.walk((child, i2) => { 4062 if (child.type === "rule" && selector3.test(child.selector)) { 4063 return callback(child, i2); 4064 } 4065 }); 4066 } 4067 return this.walk((child, i2) => { 4068 if (child.type === "rule" && child.selector === selector3) { 4069 return callback(child, i2); 4070 } 4071 }); 4072 } 4073 get first() { 4074 if (!this.proxyOf.nodes) return void 0; 4075 return this.proxyOf.nodes[0]; 4076 } 4077 get last() { 4078 if (!this.proxyOf.nodes) return void 0; 4079 return this.proxyOf.nodes[this.proxyOf.nodes.length - 1]; 4080 } 4081 }; 4082 Container.registerParse = (dependant) => { 4083 parse4 = dependant; 4084 }; 4085 Container.registerRule = (dependant) => { 4086 Rule = dependant; 4087 }; 4088 Container.registerAtRule = (dependant) => { 4089 AtRule = dependant; 4090 }; 4091 Container.registerRoot = (dependant) => { 4092 Root2 = dependant; 4093 }; 4094 module.exports = Container; 4095 Container.default = Container; 4096 Container.rebuild = (node) => { 4097 if (node.type === "atrule") { 4098 Object.setPrototypeOf(node, AtRule.prototype); 4099 } else if (node.type === "rule") { 4100 Object.setPrototypeOf(node, Rule.prototype); 4101 } else if (node.type === "decl") { 4102 Object.setPrototypeOf(node, Declaration.prototype); 4103 } else if (node.type === "comment") { 4104 Object.setPrototypeOf(node, Comment.prototype); 4105 } else if (node.type === "root") { 4106 Object.setPrototypeOf(node, Root2.prototype); 4107 } 4108 node[my] = true; 4109 if (node.nodes) { 4110 node.nodes.forEach((child) => { 4111 Container.rebuild(child); 4112 }); 4113 } 4114 }; 4115 } 4116 }); 4117 4118 // node_modules/postcss/lib/tokenize.js 4119 var require_tokenize = __commonJS({ 4120 "node_modules/postcss/lib/tokenize.js"(exports, module) { 4121 "use strict"; 4122 var SINGLE_QUOTE = "'".charCodeAt(0); 4123 var DOUBLE_QUOTE = '"'.charCodeAt(0); 4124 var BACKSLASH = "\\".charCodeAt(0); 4125 var SLASH = "/".charCodeAt(0); 4126 var NEWLINE = "\n".charCodeAt(0); 4127 var SPACE3 = " ".charCodeAt(0); 4128 var FEED = "\f".charCodeAt(0); 4129 var TAB4 = " ".charCodeAt(0); 4130 var CR = "\r".charCodeAt(0); 4131 var OPEN_SQUARE = "[".charCodeAt(0); 4132 var CLOSE_SQUARE = "]".charCodeAt(0); 4133 var OPEN_PARENTHESES = "(".charCodeAt(0); 4134 var CLOSE_PARENTHESES = ")".charCodeAt(0); 4135 var OPEN_CURLY = "{".charCodeAt(0); 4136 var CLOSE_CURLY = "}".charCodeAt(0); 4137 var SEMICOLON = ";".charCodeAt(0); 4138 var ASTERISK = "*".charCodeAt(0); 4139 var COLON = ":".charCodeAt(0); 4140 var AT = "@".charCodeAt(0); 4141 var RE_AT_END = /[\t\n\f\r "#'()/;[\\\]{}]/g; 4142 var RE_WORD_END = /[\t\n\f\r !"#'():;@[\\\]{}]|\/(?=\*)/g; 4143 var RE_BAD_BRACKET = /.[\r\n"'(/\\]/; 4144 var RE_HEX_ESCAPE = /[\da-f]/i; 4145 module.exports = function tokenizer(input, options = {}) { 4146 let css = input.css.valueOf(); 4147 let ignore = options.ignoreErrors; 4148 let code, next, quote, content, escape; 4149 let escaped, escapePos, prev, n2, currentToken; 4150 let length = css.length; 4151 let pos = 0; 4152 let buffer = []; 4153 let returned = []; 4154 function position() { 4155 return pos; 4156 } 4157 function unclosed(what) { 4158 throw input.error("Unclosed " + what, pos); 4159 } 4160 function endOfFile() { 4161 return returned.length === 0 && pos >= length; 4162 } 4163 function nextToken(opts) { 4164 if (returned.length) return returned.pop(); 4165 if (pos >= length) return; 4166 let ignoreUnclosed = opts ? opts.ignoreUnclosed : false; 4167 code = css.charCodeAt(pos); 4168 switch (code) { 4169 case NEWLINE: 4170 case SPACE3: 4171 case TAB4: 4172 case CR: 4173 case FEED: { 4174 next = pos; 4175 do { 4176 next += 1; 4177 code = css.charCodeAt(next); 4178 } while (code === SPACE3 || code === NEWLINE || code === TAB4 || code === CR || code === FEED); 4179 currentToken = ["space", css.slice(pos, next)]; 4180 pos = next - 1; 4181 break; 4182 } 4183 case OPEN_SQUARE: 4184 case CLOSE_SQUARE: 4185 case OPEN_CURLY: 4186 case CLOSE_CURLY: 4187 case COLON: 4188 case SEMICOLON: 4189 case CLOSE_PARENTHESES: { 4190 let controlChar = String.fromCharCode(code); 4191 currentToken = [controlChar, controlChar, pos]; 4192 break; 4193 } 4194 case OPEN_PARENTHESES: { 4195 prev = buffer.length ? buffer.pop()[1] : ""; 4196 n2 = css.charCodeAt(pos + 1); 4197 if (prev === "url" && n2 !== SINGLE_QUOTE && n2 !== DOUBLE_QUOTE && n2 !== SPACE3 && n2 !== NEWLINE && n2 !== TAB4 && n2 !== FEED && n2 !== CR) { 4198 next = pos; 4199 do { 4200 escaped = false; 4201 next = css.indexOf(")", next + 1); 4202 if (next === -1) { 4203 if (ignore || ignoreUnclosed) { 4204 next = pos; 4205 break; 4206 } else { 4207 unclosed("bracket"); 4208 } 4209 } 4210 escapePos = next; 4211 while (css.charCodeAt(escapePos - 1) === BACKSLASH) { 4212 escapePos -= 1; 4213 escaped = !escaped; 4214 } 4215 } while (escaped); 4216 currentToken = ["brackets", css.slice(pos, next + 1), pos, next]; 4217 pos = next; 4218 } else { 4219 next = css.indexOf(")", pos + 1); 4220 content = css.slice(pos, next + 1); 4221 if (next === -1 || RE_BAD_BRACKET.test(content)) { 4222 currentToken = ["(", "(", pos]; 4223 } else { 4224 currentToken = ["brackets", content, pos, next]; 4225 pos = next; 4226 } 4227 } 4228 break; 4229 } 4230 case SINGLE_QUOTE: 4231 case DOUBLE_QUOTE: { 4232 quote = code === SINGLE_QUOTE ? "'" : '"'; 4233 next = pos; 4234 do { 4235 escaped = false; 4236 next = css.indexOf(quote, next + 1); 4237 if (next === -1) { 4238 if (ignore || ignoreUnclosed) { 4239 next = pos + 1; 4240 break; 4241 } else { 4242 unclosed("string"); 4243 } 4244 } 4245 escapePos = next; 4246 while (css.charCodeAt(escapePos - 1) === BACKSLASH) { 4247 escapePos -= 1; 4248 escaped = !escaped; 4249 } 4250 } while (escaped); 4251 currentToken = ["string", css.slice(pos, next + 1), pos, next]; 4252 pos = next; 4253 break; 4254 } 4255 case AT: { 4256 RE_AT_END.lastIndex = pos + 1; 4257 RE_AT_END.test(css); 4258 if (RE_AT_END.lastIndex === 0) { 4259 next = css.length - 1; 4260 } else { 4261 next = RE_AT_END.lastIndex - 2; 4262 } 4263 currentToken = ["at-word", css.slice(pos, next + 1), pos, next]; 4264 pos = next; 4265 break; 4266 } 4267 case BACKSLASH: { 4268 next = pos; 4269 escape = true; 4270 while (css.charCodeAt(next + 1) === BACKSLASH) { 4271 next += 1; 4272 escape = !escape; 4273 } 4274 code = css.charCodeAt(next + 1); 4275 if (escape && code !== SLASH && code !== SPACE3 && code !== NEWLINE && code !== TAB4 && code !== CR && code !== FEED) { 4276 next += 1; 4277 if (RE_HEX_ESCAPE.test(css.charAt(next))) { 4278 while (RE_HEX_ESCAPE.test(css.charAt(next + 1))) { 4279 next += 1; 4280 } 4281 if (css.charCodeAt(next + 1) === SPACE3) { 4282 next += 1; 4283 } 4284 } 4285 } 4286 currentToken = ["word", css.slice(pos, next + 1), pos, next]; 4287 pos = next; 4288 break; 4289 } 4290 default: { 4291 if (code === SLASH && css.charCodeAt(pos + 1) === ASTERISK) { 4292 next = css.indexOf("*/", pos + 2) + 1; 4293 if (next === 0) { 4294 if (ignore || ignoreUnclosed) { 4295 next = css.length; 4296 } else { 4297 unclosed("comment"); 4298 } 4299 } 4300 currentToken = ["comment", css.slice(pos, next + 1), pos, next]; 4301 pos = next; 4302 } else { 4303 RE_WORD_END.lastIndex = pos + 1; 4304 RE_WORD_END.test(css); 4305 if (RE_WORD_END.lastIndex === 0) { 4306 next = css.length - 1; 4307 } else { 4308 next = RE_WORD_END.lastIndex - 2; 4309 } 4310 currentToken = ["word", css.slice(pos, next + 1), pos, next]; 4311 buffer.push(currentToken); 4312 pos = next; 4313 } 4314 break; 4315 } 4316 } 4317 pos++; 4318 return currentToken; 4319 } 4320 function back(token) { 4321 returned.push(token); 4322 } 4323 return { 4324 back, 4325 endOfFile, 4326 nextToken, 4327 position 4328 }; 4329 }; 4330 } 4331 }); 4332 4333 // node_modules/postcss/lib/at-rule.js 4334 var require_at_rule = __commonJS({ 4335 "node_modules/postcss/lib/at-rule.js"(exports, module) { 4336 "use strict"; 4337 var Container = require_container(); 4338 var AtRule = class extends Container { 4339 constructor(defaults2) { 4340 super(defaults2); 4341 this.type = "atrule"; 4342 } 4343 append(...children) { 4344 if (!this.proxyOf.nodes) this.nodes = []; 4345 return super.append(...children); 4346 } 4347 prepend(...children) { 4348 if (!this.proxyOf.nodes) this.nodes = []; 4349 return super.prepend(...children); 4350 } 4351 }; 4352 module.exports = AtRule; 4353 AtRule.default = AtRule; 4354 Container.registerAtRule(AtRule); 4355 } 4356 }); 4357 4358 // node_modules/postcss/lib/root.js 4359 var require_root = __commonJS({ 4360 "node_modules/postcss/lib/root.js"(exports, module) { 4361 "use strict"; 4362 var Container = require_container(); 4363 var LazyResult; 4364 var Processor2; 4365 var Root2 = class extends Container { 4366 constructor(defaults2) { 4367 super(defaults2); 4368 this.type = "root"; 4369 if (!this.nodes) this.nodes = []; 4370 } 4371 normalize(child, sample, type) { 4372 let nodes = super.normalize(child); 4373 if (sample) { 4374 if (type === "prepend") { 4375 if (this.nodes.length > 1) { 4376 sample.raws.before = this.nodes[1].raws.before; 4377 } else { 4378 delete sample.raws.before; 4379 } 4380 } else if (this.first !== sample) { 4381 for (let node of nodes) { 4382 node.raws.before = sample.raws.before; 4383 } 4384 } 4385 } 4386 return nodes; 4387 } 4388 removeChild(child, ignore) { 4389 let index = this.index(child); 4390 if (!ignore && index === 0 && this.nodes.length > 1) { 4391 this.nodes[1].raws.before = this.nodes[index].raws.before; 4392 } 4393 return super.removeChild(child); 4394 } 4395 toResult(opts = {}) { 4396 let lazy = new LazyResult(new Processor2(), this, opts); 4397 return lazy.stringify(); 4398 } 4399 }; 4400 Root2.registerLazyResult = (dependant) => { 4401 LazyResult = dependant; 4402 }; 4403 Root2.registerProcessor = (dependant) => { 4404 Processor2 = dependant; 4405 }; 4406 module.exports = Root2; 4407 Root2.default = Root2; 4408 Container.registerRoot(Root2); 4409 } 4410 }); 4411 4412 // node_modules/postcss/lib/list.js 4413 var require_list = __commonJS({ 4414 "node_modules/postcss/lib/list.js"(exports, module) { 4415 "use strict"; 4416 var list = { 4417 comma(string) { 4418 return list.split(string, [","], true); 4419 }, 4420 space(string) { 4421 let spaces = [" ", "\n", " "]; 4422 return list.split(string, spaces); 4423 }, 4424 split(string, separators, last) { 4425 let array = []; 4426 let current = ""; 4427 let split2 = false; 4428 let func = 0; 4429 let inQuote = false; 4430 let prevQuote = ""; 4431 let escape = false; 4432 for (let letter of string) { 4433 if (escape) { 4434 escape = false; 4435 } else if (letter === "\\") { 4436 escape = true; 4437 } else if (inQuote) { 4438 if (letter === prevQuote) { 4439 inQuote = false; 4440 } 4441 } else if (letter === '"' || letter === "'") { 4442 inQuote = true; 4443 prevQuote = letter; 4444 } else if (letter === "(") { 4445 func += 1; 4446 } else if (letter === ")") { 4447 if (func > 0) func -= 1; 4448 } else if (func === 0) { 4449 if (separators.includes(letter)) split2 = true; 4450 } 4451 if (split2) { 4452 if (current !== "") array.push(current.trim()); 4453 current = ""; 4454 split2 = false; 4455 } else { 4456 current += letter; 4457 } 4458 } 4459 if (last || current !== "") array.push(current.trim()); 4460 return array; 4461 } 4462 }; 4463 module.exports = list; 4464 list.default = list; 4465 } 4466 }); 4467 4468 // node_modules/postcss/lib/rule.js 4469 var require_rule = __commonJS({ 4470 "node_modules/postcss/lib/rule.js"(exports, module) { 4471 "use strict"; 4472 var Container = require_container(); 4473 var list = require_list(); 4474 var Rule = class extends Container { 4475 constructor(defaults2) { 4476 super(defaults2); 4477 this.type = "rule"; 4478 if (!this.nodes) this.nodes = []; 4479 } 4480 get selectors() { 4481 return list.comma(this.selector); 4482 } 4483 set selectors(values) { 4484 let match2 = this.selector ? this.selector.match(/,\s*/) : null; 4485 let sep = match2 ? match2[0] : "," + this.raw("between", "beforeOpen"); 4486 this.selector = values.join(sep); 4487 } 4488 }; 4489 module.exports = Rule; 4490 Rule.default = Rule; 4491 Container.registerRule(Rule); 4492 } 4493 }); 4494 4495 // node_modules/postcss/lib/parser.js 4496 var require_parser = __commonJS({ 4497 "node_modules/postcss/lib/parser.js"(exports, module) { 4498 "use strict"; 4499 var Declaration = require_declaration(); 4500 var tokenizer = require_tokenize(); 4501 var Comment = require_comment(); 4502 var AtRule = require_at_rule(); 4503 var Root2 = require_root(); 4504 var Rule = require_rule(); 4505 var SAFE_COMMENT_NEIGHBOR = { 4506 empty: true, 4507 space: true 4508 }; 4509 function findLastWithPosition(tokens) { 4510 for (let i2 = tokens.length - 1; i2 >= 0; i2--) { 4511 let token = tokens[i2]; 4512 let pos = token[3] || token[2]; 4513 if (pos) return pos; 4514 } 4515 } 4516 var Parser = class { 4517 constructor(input) { 4518 this.input = input; 4519 this.root = new Root2(); 4520 this.current = this.root; 4521 this.spaces = ""; 4522 this.semicolon = false; 4523 this.createTokenizer(); 4524 this.root.source = { input, start: { column: 1, line: 1, offset: 0 } }; 4525 } 4526 atrule(token) { 4527 let node = new AtRule(); 4528 node.name = token[1].slice(1); 4529 if (node.name === "") { 4530 this.unnamedAtrule(node, token); 4531 } 4532 this.init(node, token[2]); 4533 let type; 4534 let prev; 4535 let shift; 4536 let last = false; 4537 let open = false; 4538 let params = []; 4539 let brackets = []; 4540 while (!this.tokenizer.endOfFile()) { 4541 token = this.tokenizer.nextToken(); 4542 type = token[0]; 4543 if (type === "(" || type === "[") { 4544 brackets.push(type === "(" ? ")" : "]"); 4545 } else if (type === "{" && brackets.length > 0) { 4546 brackets.push("}"); 4547 } else if (type === brackets[brackets.length - 1]) { 4548 brackets.pop(); 4549 } 4550 if (brackets.length === 0) { 4551 if (type === ";") { 4552 node.source.end = this.getPosition(token[2]); 4553 node.source.end.offset++; 4554 this.semicolon = true; 4555 break; 4556 } else if (type === "{") { 4557 open = true; 4558 break; 4559 } else if (type === "}") { 4560 if (params.length > 0) { 4561 shift = params.length - 1; 4562 prev = params[shift]; 4563 while (prev && prev[0] === "space") { 4564 prev = params[--shift]; 4565 } 4566 if (prev) { 4567 node.source.end = this.getPosition(prev[3] || prev[2]); 4568 node.source.end.offset++; 4569 } 4570 } 4571 this.end(token); 4572 break; 4573 } else { 4574 params.push(token); 4575 } 4576 } else { 4577 params.push(token); 4578 } 4579 if (this.tokenizer.endOfFile()) { 4580 last = true; 4581 break; 4582 } 4583 } 4584 node.raws.between = this.spacesAndCommentsFromEnd(params); 4585 if (params.length) { 4586 node.raws.afterName = this.spacesAndCommentsFromStart(params); 4587 this.raw(node, "params", params); 4588 if (last) { 4589 token = params[params.length - 1]; 4590 node.source.end = this.getPosition(token[3] || token[2]); 4591 node.source.end.offset++; 4592 this.spaces = node.raws.between; 4593 node.raws.between = ""; 4594 } 4595 } else { 4596 node.raws.afterName = ""; 4597 node.params = ""; 4598 } 4599 if (open) { 4600 node.nodes = []; 4601 this.current = node; 4602 } 4603 } 4604 checkMissedSemicolon(tokens) { 4605 let colon = this.colon(tokens); 4606 if (colon === false) return; 4607 let founded = 0; 4608 let token; 4609 for (let j2 = colon - 1; j2 >= 0; j2--) { 4610 token = tokens[j2]; 4611 if (token[0] !== "space") { 4612 founded += 1; 4613 if (founded === 2) break; 4614 } 4615 } 4616 throw this.input.error( 4617 "Missed semicolon", 4618 token[0] === "word" ? token[3] + 1 : token[2] 4619 ); 4620 } 4621 colon(tokens) { 4622 let brackets = 0; 4623 let token, type, prev; 4624 for (let [i2, element] of tokens.entries()) { 4625 token = element; 4626 type = token[0]; 4627 if (type === "(") { 4628 brackets += 1; 4629 } 4630 if (type === ")") { 4631 brackets -= 1; 4632 } 4633 if (brackets === 0 && type === ":") { 4634 if (!prev) { 4635 this.doubleColon(token); 4636 } else if (prev[0] === "word" && prev[1] === "progid") { 4637 continue; 4638 } else { 4639 return i2; 4640 } 4641 } 4642 prev = token; 4643 } 4644 return false; 4645 } 4646 comment(token) { 4647 let node = new Comment(); 4648 this.init(node, token[2]); 4649 node.source.end = this.getPosition(token[3] || token[2]); 4650 node.source.end.offset++; 4651 let text = token[1].slice(2, -2); 4652 if (/^\s*$/.test(text)) { 4653 node.text = ""; 4654 node.raws.left = text; 4655 node.raws.right = ""; 4656 } else { 4657 let match2 = text.match(/^(\s*)([^]*\S)(\s*)$/); 4658 node.text = match2[2]; 4659 node.raws.left = match2[1]; 4660 node.raws.right = match2[3]; 4661 } 4662 } 4663 createTokenizer() { 4664 this.tokenizer = tokenizer(this.input); 4665 } 4666 decl(tokens, customProperty) { 4667 let node = new Declaration(); 4668 this.init(node, tokens[0][2]); 4669 let last = tokens[tokens.length - 1]; 4670 if (last[0] === ";") { 4671 this.semicolon = true; 4672 tokens.pop(); 4673 } 4674 node.source.end = this.getPosition( 4675 last[3] || last[2] || findLastWithPosition(tokens) 4676 ); 4677 node.source.end.offset++; 4678 while (tokens[0][0] !== "word") { 4679 if (tokens.length === 1) this.unknownWord(tokens); 4680 node.raws.before += tokens.shift()[1]; 4681 } 4682 node.source.start = this.getPosition(tokens[0][2]); 4683 node.prop = ""; 4684 while (tokens.length) { 4685 let type = tokens[0][0]; 4686 if (type === ":" || type === "space" || type === "comment") { 4687 break; 4688 } 4689 node.prop += tokens.shift()[1]; 4690 } 4691 node.raws.between = ""; 4692 let token; 4693 while (tokens.length) { 4694 token = tokens.shift(); 4695 if (token[0] === ":") { 4696 node.raws.between += token[1]; 4697 break; 4698 } else { 4699 if (token[0] === "word" && /\w/.test(token[1])) { 4700 this.unknownWord([token]); 4701 } 4702 node.raws.between += token[1]; 4703 } 4704 } 4705 if (node.prop[0] === "_" || node.prop[0] === "*") { 4706 node.raws.before += node.prop[0]; 4707 node.prop = node.prop.slice(1); 4708 } 4709 let firstSpaces = []; 4710 let next; 4711 while (tokens.length) { 4712 next = tokens[0][0]; 4713 if (next !== "space" && next !== "comment") break; 4714 firstSpaces.push(tokens.shift()); 4715 } 4716 this.precheckMissedSemicolon(tokens); 4717 for (let i2 = tokens.length - 1; i2 >= 0; i2--) { 4718 token = tokens[i2]; 4719 if (token[1].toLowerCase() === "!important") { 4720 node.important = true; 4721 let string = this.stringFrom(tokens, i2); 4722 string = this.spacesFromEnd(tokens) + string; 4723 if (string !== " !important") node.raws.important = string; 4724 break; 4725 } else if (token[1].toLowerCase() === "important") { 4726 let cache = tokens.slice(0); 4727 let str = ""; 4728 for (let j2 = i2; j2 > 0; j2--) { 4729 let type = cache[j2][0]; 4730 if (str.trim().indexOf("!") === 0 && type !== "space") { 4731 break; 4732 } 4733 str = cache.pop()[1] + str; 4734 } 4735 if (str.trim().indexOf("!") === 0) { 4736 node.important = true; 4737 node.raws.important = str; 4738 tokens = cache; 4739 } 4740 } 4741 if (token[0] !== "space" && token[0] !== "comment") { 4742 break; 4743 } 4744 } 4745 let hasWord = tokens.some((i2) => i2[0] !== "space" && i2[0] !== "comment"); 4746 if (hasWord) { 4747 node.raws.between += firstSpaces.map((i2) => i2[1]).join(""); 4748 firstSpaces = []; 4749 } 4750 this.raw(node, "value", firstSpaces.concat(tokens), customProperty); 4751 if (node.value.includes(":") && !customProperty) { 4752 this.checkMissedSemicolon(tokens); 4753 } 4754 } 4755 doubleColon(token) { 4756 throw this.input.error( 4757 "Double colon", 4758 { offset: token[2] }, 4759 { offset: token[2] + token[1].length } 4760 ); 4761 } 4762 emptyRule(token) { 4763 let node = new Rule(); 4764 this.init(node, token[2]); 4765 node.selector = ""; 4766 node.raws.between = ""; 4767 this.current = node; 4768 } 4769 end(token) { 4770 if (this.current.nodes && this.current.nodes.length) { 4771 this.current.raws.semicolon = this.semicolon; 4772 } 4773 this.semicolon = false; 4774 this.current.raws.after = (this.current.raws.after || "") + this.spaces; 4775 this.spaces = ""; 4776 if (this.current.parent) { 4777 this.current.source.end = this.getPosition(token[2]); 4778 this.current.source.end.offset++; 4779 this.current = this.current.parent; 4780 } else { 4781 this.unexpectedClose(token); 4782 } 4783 } 4784 endFile() { 4785 if (this.current.parent) this.unclosedBlock(); 4786 if (this.current.nodes && this.current.nodes.length) { 4787 this.current.raws.semicolon = this.semicolon; 4788 } 4789 this.current.raws.after = (this.current.raws.after || "") + this.spaces; 4790 this.root.source.end = this.getPosition(this.tokenizer.position()); 4791 } 4792 freeSemicolon(token) { 4793 this.spaces += token[1]; 4794 if (this.current.nodes) { 4795 let prev = this.current.nodes[this.current.nodes.length - 1]; 4796 if (prev && prev.type === "rule" && !prev.raws.ownSemicolon) { 4797 prev.raws.ownSemicolon = this.spaces; 4798 this.spaces = ""; 4799 } 4800 } 4801 } 4802 // Helpers 4803 getPosition(offset) { 4804 let pos = this.input.fromOffset(offset); 4805 return { 4806 column: pos.col, 4807 line: pos.line, 4808 offset 4809 }; 4810 } 4811 init(node, offset) { 4812 this.current.push(node); 4813 node.source = { 4814 input: this.input, 4815 start: this.getPosition(offset) 4816 }; 4817 node.raws.before = this.spaces; 4818 this.spaces = ""; 4819 if (node.type !== "comment") this.semicolon = false; 4820 } 4821 other(start2) { 4822 let end = false; 4823 let type = null; 4824 let colon = false; 4825 let bracket = null; 4826 let brackets = []; 4827 let customProperty = start2[1].startsWith("--"); 4828 let tokens = []; 4829 let token = start2; 4830 while (token) { 4831 type = token[0]; 4832 tokens.push(token); 4833 if (type === "(" || type === "[") { 4834 if (!bracket) bracket = token; 4835 brackets.push(type === "(" ? ")" : "]"); 4836 } else if (customProperty && colon && type === "{") { 4837 if (!bracket) bracket = token; 4838 brackets.push("}"); 4839 } else if (brackets.length === 0) { 4840 if (type === ";") { 4841 if (colon) { 4842 this.decl(tokens, customProperty); 4843 return; 4844 } else { 4845 break; 4846 } 4847 } else if (type === "{") { 4848 this.rule(tokens); 4849 return; 4850 } else if (type === "}") { 4851 this.tokenizer.back(tokens.pop()); 4852 end = true; 4853 break; 4854 } else if (type === ":") { 4855 colon = true; 4856 } 4857 } else if (type === brackets[brackets.length - 1]) { 4858 brackets.pop(); 4859 if (brackets.length === 0) bracket = null; 4860 } 4861 token = this.tokenizer.nextToken(); 4862 } 4863 if (this.tokenizer.endOfFile()) end = true; 4864 if (brackets.length > 0) this.unclosedBracket(bracket); 4865 if (end && colon) { 4866 if (!customProperty) { 4867 while (tokens.length) { 4868 token = tokens[tokens.length - 1][0]; 4869 if (token !== "space" && token !== "comment") break; 4870 this.tokenizer.back(tokens.pop()); 4871 } 4872 } 4873 this.decl(tokens, customProperty); 4874 } else { 4875 this.unknownWord(tokens); 4876 } 4877 } 4878 parse() { 4879 let token; 4880 while (!this.tokenizer.endOfFile()) { 4881 token = this.tokenizer.nextToken(); 4882 switch (token[0]) { 4883 case "space": 4884 this.spaces += token[1]; 4885 break; 4886 case ";": 4887 this.freeSemicolon(token); 4888 break; 4889 case "}": 4890 this.end(token); 4891 break; 4892 case "comment": 4893 this.comment(token); 4894 break; 4895 case "at-word": 4896 this.atrule(token); 4897 break; 4898 case "{": 4899 this.emptyRule(token); 4900 break; 4901 default: 4902 this.other(token); 4903 break; 4904 } 4905 } 4906 this.endFile(); 4907 } 4908 precheckMissedSemicolon() { 4909 } 4910 raw(node, prop, tokens, customProperty) { 4911 let token, type; 4912 let length = tokens.length; 4913 let value = ""; 4914 let clean = true; 4915 let next, prev; 4916 for (let i2 = 0; i2 < length; i2 += 1) { 4917 token = tokens[i2]; 4918 type = token[0]; 4919 if (type === "space" && i2 === length - 1 && !customProperty) { 4920 clean = false; 4921 } else if (type === "comment") { 4922 prev = tokens[i2 - 1] ? tokens[i2 - 1][0] : "empty"; 4923 next = tokens[i2 + 1] ? tokens[i2 + 1][0] : "empty"; 4924 if (!SAFE_COMMENT_NEIGHBOR[prev] && !SAFE_COMMENT_NEIGHBOR[next]) { 4925 if (value.slice(-1) === ",") { 4926 clean = false; 4927 } else { 4928 value += token[1]; 4929 } 4930 } else { 4931 clean = false; 4932 } 4933 } else { 4934 value += token[1]; 4935 } 4936 } 4937 if (!clean) { 4938 let raw = tokens.reduce((all, i2) => all + i2[1], ""); 4939 node.raws[prop] = { raw, value }; 4940 } 4941 node[prop] = value; 4942 } 4943 rule(tokens) { 4944 tokens.pop(); 4945 let node = new Rule(); 4946 this.init(node, tokens[0][2]); 4947 node.raws.between = this.spacesAndCommentsFromEnd(tokens); 4948 this.raw(node, "selector", tokens); 4949 this.current = node; 4950 } 4951 spacesAndCommentsFromEnd(tokens) { 4952 let lastTokenType; 4953 let spaces = ""; 4954 while (tokens.length) { 4955 lastTokenType = tokens[tokens.length - 1][0]; 4956 if (lastTokenType !== "space" && lastTokenType !== "comment") break; 4957 spaces = tokens.pop()[1] + spaces; 4958 } 4959 return spaces; 4960 } 4961 // Errors 4962 spacesAndCommentsFromStart(tokens) { 4963 let next; 4964 let spaces = ""; 4965 while (tokens.length) { 4966 next = tokens[0][0]; 4967 if (next !== "space" && next !== "comment") break; 4968 spaces += tokens.shift()[1]; 4969 } 4970 return spaces; 4971 } 4972 spacesFromEnd(tokens) { 4973 let lastTokenType; 4974 let spaces = ""; 4975 while (tokens.length) { 4976 lastTokenType = tokens[tokens.length - 1][0]; 4977 if (lastTokenType !== "space") break; 4978 spaces = tokens.pop()[1] + spaces; 4979 } 4980 return spaces; 4981 } 4982 stringFrom(tokens, from) { 4983 let result = ""; 4984 for (let i2 = from; i2 < tokens.length; i2++) { 4985 result += tokens[i2][1]; 4986 } 4987 tokens.splice(from, tokens.length - from); 4988 return result; 4989 } 4990 unclosedBlock() { 4991 let pos = this.current.source.start; 4992 throw this.input.error("Unclosed block", pos.line, pos.column); 4993 } 4994 unclosedBracket(bracket) { 4995 throw this.input.error( 4996 "Unclosed bracket", 4997 { offset: bracket[2] }, 4998 { offset: bracket[2] + 1 } 4999 ); 5000 } 5001 unexpectedClose(token) { 5002 throw this.input.error( 5003 "Unexpected }", 5004 { offset: token[2] }, 5005 { offset: token[2] + 1 } 5006 ); 5007 } 5008 unknownWord(tokens) { 5009 throw this.input.error( 5010 "Unknown word", 5011 { offset: tokens[0][2] }, 5012 { offset: tokens[0][2] + tokens[0][1].length } 5013 ); 5014 } 5015 unnamedAtrule(node, token) { 5016 throw this.input.error( 5017 "At-rule without name", 5018 { offset: token[2] }, 5019 { offset: token[2] + token[1].length } 5020 ); 5021 } 5022 }; 5023 module.exports = Parser; 5024 } 5025 }); 5026 5027 // node_modules/postcss/lib/parse.js 5028 var require_parse = __commonJS({ 5029 "node_modules/postcss/lib/parse.js"(exports, module) { 5030 "use strict"; 5031 var Container = require_container(); 5032 var Parser = require_parser(); 5033 var Input = require_input(); 5034 function parse4(css, opts) { 5035 let input = new Input(css, opts); 5036 let parser = new Parser(input); 5037 try { 5038 parser.parse(); 5039 } catch (e2) { 5040 if (true) { 5041 if (e2.name === "CssSyntaxError" && opts && opts.from) { 5042 if (/\.scss$/i.test(opts.from)) { 5043 e2.message += "\nYou tried to parse SCSS with the standard CSS parser; try again with the postcss-scss parser"; 5044 } else if (/\.sass/i.test(opts.from)) { 5045 e2.message += "\nYou tried to parse Sass with the standard CSS parser; try again with the postcss-sass parser"; 5046 } else if (/\.less$/i.test(opts.from)) { 5047 e2.message += "\nYou tried to parse Less with the standard CSS parser; try again with the postcss-less parser"; 5048 } 5049 } 5050 } 5051 throw e2; 5052 } 5053 return parser.root; 5054 } 5055 module.exports = parse4; 5056 parse4.default = parse4; 5057 Container.registerParse(parse4); 5058 } 5059 }); 5060 5061 // node_modules/postcss/lib/warning.js 5062 var require_warning2 = __commonJS({ 5063 "node_modules/postcss/lib/warning.js"(exports, module) { 5064 "use strict"; 5065 var Warning2 = class { 5066 constructor(text, opts = {}) { 5067 this.type = "warning"; 5068 this.text = text; 5069 if (opts.node && opts.node.source) { 5070 let range2 = opts.node.rangeBy(opts); 5071 this.line = range2.start.line; 5072 this.column = range2.start.column; 5073 this.endLine = range2.end.line; 5074 this.endColumn = range2.end.column; 5075 } 5076 for (let opt in opts) this[opt] = opts[opt]; 5077 } 5078 toString() { 5079 if (this.node) { 5080 return this.node.error(this.text, { 5081 index: this.index, 5082 plugin: this.plugin, 5083 word: this.word 5084 }).message; 5085 } 5086 if (this.plugin) { 5087 return this.plugin + ": " + this.text; 5088 } 5089 return this.text; 5090 } 5091 }; 5092 module.exports = Warning2; 5093 Warning2.default = Warning2; 5094 } 5095 }); 5096 5097 // node_modules/postcss/lib/result.js 5098 var require_result = __commonJS({ 5099 "node_modules/postcss/lib/result.js"(exports, module) { 5100 "use strict"; 5101 var Warning2 = require_warning2(); 5102 var Result = class { 5103 constructor(processor, root, opts) { 5104 this.processor = processor; 5105 this.messages = []; 5106 this.root = root; 5107 this.opts = opts; 5108 this.css = void 0; 5109 this.map = void 0; 5110 } 5111 toString() { 5112 return this.css; 5113 } 5114 warn(text, opts = {}) { 5115 if (!opts.plugin) { 5116 if (this.lastPlugin && this.lastPlugin.postcssPlugin) { 5117 opts.plugin = this.lastPlugin.postcssPlugin; 5118 } 5119 } 5120 let warning6 = new Warning2(text, opts); 5121 this.messages.push(warning6); 5122 return warning6; 5123 } 5124 warnings() { 5125 return this.messages.filter((i2) => i2.type === "warning"); 5126 } 5127 get content() { 5128 return this.css; 5129 } 5130 }; 5131 module.exports = Result; 5132 Result.default = Result; 5133 } 5134 }); 5135 5136 // node_modules/postcss/lib/no-work-result.js 5137 var require_no_work_result = __commonJS({ 5138 "node_modules/postcss/lib/no-work-result.js"(exports, module) { 5139 "use strict"; 5140 var MapGenerator = require_map_generator(); 5141 var stringify2 = require_stringify(); 5142 var warnOnce = require_warn_once(); 5143 var parse4 = require_parse(); 5144 var Result = require_result(); 5145 var NoWorkResult = class { 5146 constructor(processor, css, opts) { 5147 css = css.toString(); 5148 this.stringified = false; 5149 this._processor = processor; 5150 this._css = css; 5151 this._opts = opts; 5152 this._map = void 0; 5153 let root; 5154 let str = stringify2; 5155 this.result = new Result(this._processor, root, this._opts); 5156 this.result.css = css; 5157 let self = this; 5158 Object.defineProperty(this.result, "root", { 5159 get() { 5160 return self.root; 5161 } 5162 }); 5163 let map = new MapGenerator(str, root, this._opts, css); 5164 if (map.isMap()) { 5165 let [generatedCSS, generatedMap] = map.generate(); 5166 if (generatedCSS) { 5167 this.result.css = generatedCSS; 5168 } 5169 if (generatedMap) { 5170 this.result.map = generatedMap; 5171 } 5172 } else { 5173 map.clearAnnotation(); 5174 this.result.css = map.css; 5175 } 5176 } 5177 async() { 5178 if (this.error) return Promise.reject(this.error); 5179 return Promise.resolve(this.result); 5180 } 5181 catch(onRejected) { 5182 return this.async().catch(onRejected); 5183 } 5184 finally(onFinally) { 5185 return this.async().then(onFinally, onFinally); 5186 } 5187 sync() { 5188 if (this.error) throw this.error; 5189 return this.result; 5190 } 5191 then(onFulfilled, onRejected) { 5192 if (true) { 5193 if (!("from" in this._opts)) { 5194 warnOnce( 5195 "Without `from` option PostCSS could generate wrong source map and will not find Browserslist config. Set it to CSS file path or to `undefined` to prevent this warning." 5196 ); 5197 } 5198 } 5199 return this.async().then(onFulfilled, onRejected); 5200 } 5201 toString() { 5202 return this._css; 5203 } 5204 warnings() { 5205 return []; 5206 } 5207 get content() { 5208 return this.result.css; 5209 } 5210 get css() { 5211 return this.result.css; 5212 } 5213 get map() { 5214 return this.result.map; 5215 } 5216 get messages() { 5217 return []; 5218 } 5219 get opts() { 5220 return this.result.opts; 5221 } 5222 get processor() { 5223 return this.result.processor; 5224 } 5225 get root() { 5226 if (this._root) { 5227 return this._root; 5228 } 5229 let root; 5230 let parser = parse4; 5231 try { 5232 root = parser(this._css, this._opts); 5233 } catch (error) { 5234 this.error = error; 5235 } 5236 if (this.error) { 5237 throw this.error; 5238 } else { 5239 this._root = root; 5240 return root; 5241 } 5242 } 5243 get [Symbol.toStringTag]() { 5244 return "NoWorkResult"; 5245 } 5246 }; 5247 module.exports = NoWorkResult; 5248 NoWorkResult.default = NoWorkResult; 5249 } 5250 }); 5251 5252 // node_modules/postcss/lib/document.js 5253 var require_document = __commonJS({ 5254 "node_modules/postcss/lib/document.js"(exports, module) { 5255 "use strict"; 5256 var Container = require_container(); 5257 var LazyResult; 5258 var Processor2; 5259 var Document = class extends Container { 5260 constructor(defaults2) { 5261 super({ type: "document", ...defaults2 }); 5262 if (!this.nodes) { 5263 this.nodes = []; 5264 } 5265 } 5266 toResult(opts = {}) { 5267 let lazy = new LazyResult(new Processor2(), this, opts); 5268 return lazy.stringify(); 5269 } 5270 }; 5271 Document.registerLazyResult = (dependant) => { 5272 LazyResult = dependant; 5273 }; 5274 Document.registerProcessor = (dependant) => { 5275 Processor2 = dependant; 5276 }; 5277 module.exports = Document; 5278 Document.default = Document; 5279 } 5280 }); 5281 5282 // node_modules/postcss/lib/lazy-result.js 5283 var require_lazy_result = __commonJS({ 5284 "node_modules/postcss/lib/lazy-result.js"(exports, module) { 5285 "use strict"; 5286 var { isClean, my } = require_symbols(); 5287 var MapGenerator = require_map_generator(); 5288 var stringify2 = require_stringify(); 5289 var Container = require_container(); 5290 var Document = require_document(); 5291 var warnOnce = require_warn_once(); 5292 var Result = require_result(); 5293 var parse4 = require_parse(); 5294 var Root2 = require_root(); 5295 var TYPE_TO_CLASS_NAME = { 5296 atrule: "AtRule", 5297 comment: "Comment", 5298 decl: "Declaration", 5299 document: "Document", 5300 root: "Root", 5301 rule: "Rule" 5302 }; 5303 var PLUGIN_PROPS = { 5304 AtRule: true, 5305 AtRuleExit: true, 5306 Comment: true, 5307 CommentExit: true, 5308 Declaration: true, 5309 DeclarationExit: true, 5310 Document: true, 5311 DocumentExit: true, 5312 Once: true, 5313 OnceExit: true, 5314 postcssPlugin: true, 5315 prepare: true, 5316 Root: true, 5317 RootExit: true, 5318 Rule: true, 5319 RuleExit: true 5320 }; 5321 var NOT_VISITORS = { 5322 Once: true, 5323 postcssPlugin: true, 5324 prepare: true 5325 }; 5326 var CHILDREN = 0; 5327 function isPromise(obj) { 5328 return typeof obj === "object" && typeof obj.then === "function"; 5329 } 5330 function getEvents(node) { 5331 let key = false; 5332 let type = TYPE_TO_CLASS_NAME[node.type]; 5333 if (node.type === "decl") { 5334 key = node.prop.toLowerCase(); 5335 } else if (node.type === "atrule") { 5336 key = node.name.toLowerCase(); 5337 } 5338 if (key && node.append) { 5339 return [ 5340 type, 5341 type + "-" + key, 5342 CHILDREN, 5343 type + "Exit", 5344 type + "Exit-" + key 5345 ]; 5346 } else if (key) { 5347 return [type, type + "-" + key, type + "Exit", type + "Exit-" + key]; 5348 } else if (node.append) { 5349 return [type, CHILDREN, type + "Exit"]; 5350 } else { 5351 return [type, type + "Exit"]; 5352 } 5353 } 5354 function toStack(node) { 5355 let events; 5356 if (node.type === "document") { 5357 events = ["Document", CHILDREN, "DocumentExit"]; 5358 } else if (node.type === "root") { 5359 events = ["Root", CHILDREN, "RootExit"]; 5360 } else { 5361 events = getEvents(node); 5362 } 5363 return { 5364 eventIndex: 0, 5365 events, 5366 iterator: 0, 5367 node, 5368 visitorIndex: 0, 5369 visitors: [] 5370 }; 5371 } 5372 function cleanMarks(node) { 5373 node[isClean] = false; 5374 if (node.nodes) node.nodes.forEach((i2) => cleanMarks(i2)); 5375 return node; 5376 } 5377 var postcss = {}; 5378 var LazyResult = class _LazyResult { 5379 constructor(processor, css, opts) { 5380 this.stringified = false; 5381 this.processed = false; 5382 let root; 5383 if (typeof css === "object" && css !== null && (css.type === "root" || css.type === "document")) { 5384 root = cleanMarks(css); 5385 } else if (css instanceof _LazyResult || css instanceof Result) { 5386 root = cleanMarks(css.root); 5387 if (css.map) { 5388 if (typeof opts.map === "undefined") opts.map = {}; 5389 if (!opts.map.inline) opts.map.inline = false; 5390 opts.map.prev = css.map; 5391 } 5392 } else { 5393 let parser = parse4; 5394 if (opts.syntax) parser = opts.syntax.parse; 5395 if (opts.parser) parser = opts.parser; 5396 if (parser.parse) parser = parser.parse; 5397 try { 5398 root = parser(css, opts); 5399 } catch (error) { 5400 this.processed = true; 5401 this.error = error; 5402 } 5403 if (root && !root[my]) { 5404 Container.rebuild(root); 5405 } 5406 } 5407 this.result = new Result(processor, root, opts); 5408 this.helpers = { ...postcss, postcss, result: this.result }; 5409 this.plugins = this.processor.plugins.map((plugin) => { 5410 if (typeof plugin === "object" && plugin.prepare) { 5411 return { ...plugin, ...plugin.prepare(this.result) }; 5412 } else { 5413 return plugin; 5414 } 5415 }); 5416 } 5417 async() { 5418 if (this.error) return Promise.reject(this.error); 5419 if (this.processed) return Promise.resolve(this.result); 5420 if (!this.processing) { 5421 this.processing = this.runAsync(); 5422 } 5423 return this.processing; 5424 } 5425 catch(onRejected) { 5426 return this.async().catch(onRejected); 5427 } 5428 finally(onFinally) { 5429 return this.async().then(onFinally, onFinally); 5430 } 5431 getAsyncError() { 5432 throw new Error("Use process(css).then(cb) to work with async plugins"); 5433 } 5434 handleError(error, node) { 5435 let plugin = this.result.lastPlugin; 5436 try { 5437 if (node) node.addToError(error); 5438 this.error = error; 5439 if (error.name === "CssSyntaxError" && !error.plugin) { 5440 error.plugin = plugin.postcssPlugin; 5441 error.setMessage(); 5442 } else if (plugin.postcssVersion) { 5443 if (true) { 5444 let pluginName = plugin.postcssPlugin; 5445 let pluginVer = plugin.postcssVersion; 5446 let runtimeVer = this.result.processor.version; 5447 let a2 = pluginVer.split("."); 5448 let b2 = runtimeVer.split("."); 5449 if (a2[0] !== b2[0] || parseInt(a2[1]) > parseInt(b2[1])) { 5450 console.error( 5451 "Unknown error from PostCSS plugin. Your current PostCSS version is " + runtimeVer + ", but " + pluginName + " uses " + pluginVer + ". Perhaps this is the source of the error below." 5452 ); 5453 } 5454 } 5455 } 5456 } catch (err) { 5457 if (console && console.error) console.error(err); 5458 } 5459 return error; 5460 } 5461 prepareVisitors() { 5462 this.listeners = {}; 5463 let add2 = (plugin, type, cb) => { 5464 if (!this.listeners[type]) this.listeners[type] = []; 5465 this.listeners[type].push([plugin, cb]); 5466 }; 5467 for (let plugin of this.plugins) { 5468 if (typeof plugin === "object") { 5469 for (let event in plugin) { 5470 if (!PLUGIN_PROPS[event] && /^[A-Z]/.test(event)) { 5471 throw new Error( 5472 `Unknown event $event} in $plugin.postcssPlugin}. Try to update PostCSS ($this.processor.version} now).` 5473 ); 5474 } 5475 if (!NOT_VISITORS[event]) { 5476 if (typeof plugin[event] === "object") { 5477 for (let filter in plugin[event]) { 5478 if (filter === "*") { 5479 add2(plugin, event, plugin[event][filter]); 5480 } else { 5481 add2( 5482 plugin, 5483 event + "-" + filter.toLowerCase(), 5484 plugin[event][filter] 5485 ); 5486 } 5487 } 5488 } else if (typeof plugin[event] === "function") { 5489 add2(plugin, event, plugin[event]); 5490 } 5491 } 5492 } 5493 } 5494 } 5495 this.hasListener = Object.keys(this.listeners).length > 0; 5496 } 5497 async runAsync() { 5498 this.plugin = 0; 5499 for (let i2 = 0; i2 < this.plugins.length; i2++) { 5500 let plugin = this.plugins[i2]; 5501 let promise = this.runOnRoot(plugin); 5502 if (isPromise(promise)) { 5503 try { 5504 await promise; 5505 } catch (error) { 5506 throw this.handleError(error); 5507 } 5508 } 5509 } 5510 this.prepareVisitors(); 5511 if (this.hasListener) { 5512 let root = this.result.root; 5513 while (!root[isClean]) { 5514 root[isClean] = true; 5515 let stack = [toStack(root)]; 5516 while (stack.length > 0) { 5517 let promise = this.visitTick(stack); 5518 if (isPromise(promise)) { 5519 try { 5520 await promise; 5521 } catch (e2) { 5522 let node = stack[stack.length - 1].node; 5523 throw this.handleError(e2, node); 5524 } 5525 } 5526 } 5527 } 5528 if (this.listeners.OnceExit) { 5529 for (let [plugin, visitor] of this.listeners.OnceExit) { 5530 this.result.lastPlugin = plugin; 5531 try { 5532 if (root.type === "document") { 5533 let roots = root.nodes.map( 5534 (subRoot) => visitor(subRoot, this.helpers) 5535 ); 5536 await Promise.all(roots); 5537 } else { 5538 await visitor(root, this.helpers); 5539 } 5540 } catch (e2) { 5541 throw this.handleError(e2); 5542 } 5543 } 5544 } 5545 } 5546 this.processed = true; 5547 return this.stringify(); 5548 } 5549 runOnRoot(plugin) { 5550 this.result.lastPlugin = plugin; 5551 try { 5552 if (typeof plugin === "object" && plugin.Once) { 5553 if (this.result.root.type === "document") { 5554 let roots = this.result.root.nodes.map( 5555 (root) => plugin.Once(root, this.helpers) 5556 ); 5557 if (isPromise(roots[0])) { 5558 return Promise.all(roots); 5559 } 5560 return roots; 5561 } 5562 return plugin.Once(this.result.root, this.helpers); 5563 } else if (typeof plugin === "function") { 5564 return plugin(this.result.root, this.result); 5565 } 5566 } catch (error) { 5567 throw this.handleError(error); 5568 } 5569 } 5570 stringify() { 5571 if (this.error) throw this.error; 5572 if (this.stringified) return this.result; 5573 this.stringified = true; 5574 this.sync(); 5575 let opts = this.result.opts; 5576 let str = stringify2; 5577 if (opts.syntax) str = opts.syntax.stringify; 5578 if (opts.stringifier) str = opts.stringifier; 5579 if (str.stringify) str = str.stringify; 5580 let map = new MapGenerator(str, this.result.root, this.result.opts); 5581 let data = map.generate(); 5582 this.result.css = data[0]; 5583 this.result.map = data[1]; 5584 return this.result; 5585 } 5586 sync() { 5587 if (this.error) throw this.error; 5588 if (this.processed) return this.result; 5589 this.processed = true; 5590 if (this.processing) { 5591 throw this.getAsyncError(); 5592 } 5593 for (let plugin of this.plugins) { 5594 let promise = this.runOnRoot(plugin); 5595 if (isPromise(promise)) { 5596 throw this.getAsyncError(); 5597 } 5598 } 5599 this.prepareVisitors(); 5600 if (this.hasListener) { 5601 let root = this.result.root; 5602 while (!root[isClean]) { 5603 root[isClean] = true; 5604 this.walkSync(root); 5605 } 5606 if (this.listeners.OnceExit) { 5607 if (root.type === "document") { 5608 for (let subRoot of root.nodes) { 5609 this.visitSync(this.listeners.OnceExit, subRoot); 5610 } 5611 } else { 5612 this.visitSync(this.listeners.OnceExit, root); 5613 } 5614 } 5615 } 5616 return this.result; 5617 } 5618 then(onFulfilled, onRejected) { 5619 if (true) { 5620 if (!("from" in this.opts)) { 5621 warnOnce( 5622 "Without `from` option PostCSS could generate wrong source map and will not find Browserslist config. Set it to CSS file path or to `undefined` to prevent this warning." 5623 ); 5624 } 5625 } 5626 return this.async().then(onFulfilled, onRejected); 5627 } 5628 toString() { 5629 return this.css; 5630 } 5631 visitSync(visitors, node) { 5632 for (let [plugin, visitor] of visitors) { 5633 this.result.lastPlugin = plugin; 5634 let promise; 5635 try { 5636 promise = visitor(node, this.helpers); 5637 } catch (e2) { 5638 throw this.handleError(e2, node.proxyOf); 5639 } 5640 if (node.type !== "root" && node.type !== "document" && !node.parent) { 5641 return true; 5642 } 5643 if (isPromise(promise)) { 5644 throw this.getAsyncError(); 5645 } 5646 } 5647 } 5648 visitTick(stack) { 5649 let visit = stack[stack.length - 1]; 5650 let { node, visitors } = visit; 5651 if (node.type !== "root" && node.type !== "document" && !node.parent) { 5652 stack.pop(); 5653 return; 5654 } 5655 if (visitors.length > 0 && visit.visitorIndex < visitors.length) { 5656 let [plugin, visitor] = visitors[visit.visitorIndex]; 5657 visit.visitorIndex += 1; 5658 if (visit.visitorIndex === visitors.length) { 5659 visit.visitors = []; 5660 visit.visitorIndex = 0; 5661 } 5662 this.result.lastPlugin = plugin; 5663 try { 5664 return visitor(node.toProxy(), this.helpers); 5665 } catch (e2) { 5666 throw this.handleError(e2, node); 5667 } 5668 } 5669 if (visit.iterator !== 0) { 5670 let iterator = visit.iterator; 5671 let child; 5672 while (child = node.nodes[node.indexes[iterator]]) { 5673 node.indexes[iterator] += 1; 5674 if (!child[isClean]) { 5675 child[isClean] = true; 5676 stack.push(toStack(child)); 5677 return; 5678 } 5679 } 5680 visit.iterator = 0; 5681 delete node.indexes[iterator]; 5682 } 5683 let events = visit.events; 5684 while (visit.eventIndex < events.length) { 5685 let event = events[visit.eventIndex]; 5686 visit.eventIndex += 1; 5687 if (event === CHILDREN) { 5688 if (node.nodes && node.nodes.length) { 5689 node[isClean] = true; 5690 visit.iterator = node.getIterator(); 5691 } 5692 return; 5693 } else if (this.listeners[event]) { 5694 visit.visitors = this.listeners[event]; 5695 return; 5696 } 5697 } 5698 stack.pop(); 5699 } 5700 walkSync(node) { 5701 node[isClean] = true; 5702 let events = getEvents(node); 5703 for (let event of events) { 5704 if (event === CHILDREN) { 5705 if (node.nodes) { 5706 node.each((child) => { 5707 if (!child[isClean]) this.walkSync(child); 5708 }); 5709 } 5710 } else { 5711 let visitors = this.listeners[event]; 5712 if (visitors) { 5713 if (this.visitSync(visitors, node.toProxy())) return; 5714 } 5715 } 5716 } 5717 } 5718 warnings() { 5719 return this.sync().warnings(); 5720 } 5721 get content() { 5722 return this.stringify().content; 5723 } 5724 get css() { 5725 return this.stringify().css; 5726 } 5727 get map() { 5728 return this.stringify().map; 5729 } 5730 get messages() { 5731 return this.sync().messages; 5732 } 5733 get opts() { 5734 return this.result.opts; 5735 } 5736 get processor() { 5737 return this.result.processor; 5738 } 5739 get root() { 5740 return this.sync().root; 5741 } 5742 get [Symbol.toStringTag]() { 5743 return "LazyResult"; 5744 } 5745 }; 5746 LazyResult.registerPostcss = (dependant) => { 5747 postcss = dependant; 5748 }; 5749 module.exports = LazyResult; 5750 LazyResult.default = LazyResult; 5751 Root2.registerLazyResult(LazyResult); 5752 Document.registerLazyResult(LazyResult); 5753 } 5754 }); 5755 5756 // node_modules/postcss/lib/processor.js 5757 var require_processor = __commonJS({ 5758 "node_modules/postcss/lib/processor.js"(exports, module) { 5759 "use strict"; 5760 var NoWorkResult = require_no_work_result(); 5761 var LazyResult = require_lazy_result(); 5762 var Document = require_document(); 5763 var Root2 = require_root(); 5764 var Processor2 = class { 5765 constructor(plugins = []) { 5766 this.version = "8.4.38"; 5767 this.plugins = this.normalize(plugins); 5768 } 5769 normalize(plugins) { 5770 let normalized = []; 5771 for (let i2 of plugins) { 5772 if (i2.postcss === true) { 5773 i2 = i2(); 5774 } else if (i2.postcss) { 5775 i2 = i2.postcss; 5776 } 5777 if (typeof i2 === "object" && Array.isArray(i2.plugins)) { 5778 normalized = normalized.concat(i2.plugins); 5779 } else if (typeof i2 === "object" && i2.postcssPlugin) { 5780 normalized.push(i2); 5781 } else if (typeof i2 === "function") { 5782 normalized.push(i2); 5783 } else if (typeof i2 === "object" && (i2.parse || i2.stringify)) { 5784 if (true) { 5785 throw new Error( 5786 "PostCSS syntaxes cannot be used as plugins. Instead, please use one of the syntax/parser/stringifier options as outlined in your PostCSS runner documentation." 5787 ); 5788 } 5789 } else { 5790 throw new Error(i2 + " is not a PostCSS plugin"); 5791 } 5792 } 5793 return normalized; 5794 } 5795 process(css, opts = {}) { 5796 if (!this.plugins.length && !opts.parser && !opts.stringifier && !opts.syntax) { 5797 return new NoWorkResult(this, css, opts); 5798 } else { 5799 return new LazyResult(this, css, opts); 5800 } 5801 } 5802 use(plugin) { 5803 this.plugins = this.plugins.concat(this.normalize([plugin])); 5804 return this; 5805 } 5806 }; 5807 module.exports = Processor2; 5808 Processor2.default = Processor2; 5809 Root2.registerProcessor(Processor2); 5810 Document.registerProcessor(Processor2); 5811 } 5812 }); 5813 5814 // node_modules/postcss-prefix-selector/index.js 5815 var require_postcss_prefix_selector = __commonJS({ 5816 "node_modules/postcss-prefix-selector/index.js"(exports, module) { 5817 module.exports = function postcssPrefixSelector(options) { 5818 const prefix2 = options.prefix; 5819 const prefixWithSpace = /\s+$/.test(prefix2) ? prefix2 : `$prefix2} `; 5820 const ignoreFiles = options.ignoreFiles ? [].concat(options.ignoreFiles) : []; 5821 const includeFiles = options.includeFiles ? [].concat(options.includeFiles) : []; 5822 return function(root) { 5823 if (ignoreFiles.length && root.source.input.file && isFileInArray(root.source.input.file, ignoreFiles)) { 5824 return; 5825 } 5826 if (includeFiles.length && root.source.input.file && !isFileInArray(root.source.input.file, includeFiles)) { 5827 return; 5828 } 5829 root.walkRules((rule) => { 5830 const keyframeRules = [ 5831 "keyframes", 5832 "-webkit-keyframes", 5833 "-moz-keyframes", 5834 "-o-keyframes", 5835 "-ms-keyframes" 5836 ]; 5837 if (rule.parent && keyframeRules.includes(rule.parent.name)) { 5838 return; 5839 } 5840 rule.selectors = rule.selectors.map((selector3) => { 5841 if (options.exclude && excludeSelector(selector3, options.exclude)) { 5842 return selector3; 5843 } 5844 if (options.transform) { 5845 return options.transform( 5846 prefix2, 5847 selector3, 5848 prefixWithSpace + selector3, 5849 root.source.input.file, 5850 rule 5851 ); 5852 } 5853 return prefixWithSpace + selector3; 5854 }); 5855 }); 5856 }; 5857 }; 5858 function isFileInArray(file, arr) { 5859 return arr.some((ruleOrString) => { 5860 if (ruleOrString instanceof RegExp) { 5861 return ruleOrString.test(file); 5862 } 5863 return file.includes(ruleOrString); 5864 }); 5865 } 5866 function excludeSelector(selector3, excludeArr) { 5867 return excludeArr.some((excludeRule) => { 5868 if (excludeRule instanceof RegExp) { 5869 return excludeRule.test(selector3); 5870 } 5871 return selector3 === excludeRule; 5872 }); 5873 } 5874 } 5875 }); 5876 5877 // packages/block-editor/node_modules/postcss-value-parser/lib/parse.js 5878 var require_parse2 = __commonJS({ 5879 "packages/block-editor/node_modules/postcss-value-parser/lib/parse.js"(exports, module) { 5880 var openParentheses = "(".charCodeAt(0); 5881 var closeParentheses = ")".charCodeAt(0); 5882 var singleQuote = "'".charCodeAt(0); 5883 var doubleQuote = '"'.charCodeAt(0); 5884 var backslash = "\\".charCodeAt(0); 5885 var slash = "/".charCodeAt(0); 5886 var comma = ",".charCodeAt(0); 5887 var colon = ":".charCodeAt(0); 5888 var star = "*".charCodeAt(0); 5889 var uLower = "u".charCodeAt(0); 5890 var uUpper = "U".charCodeAt(0); 5891 var plus = "+".charCodeAt(0); 5892 var isUnicodeRange = /^[a-f0-9?-]+$/i; 5893 module.exports = function(input) { 5894 var tokens = []; 5895 var value = input; 5896 var next, quote, prev, token, escape, escapePos, whitespacePos, parenthesesOpenPos; 5897 var pos = 0; 5898 var code = value.charCodeAt(pos); 5899 var max = value.length; 5900 var stack = [{ nodes: tokens }]; 5901 var balanced = 0; 5902 var parent; 5903 var name = ""; 5904 var before = ""; 5905 var after = ""; 5906 while (pos < max) { 5907 if (code <= 32) { 5908 next = pos; 5909 do { 5910 next += 1; 5911 code = value.charCodeAt(next); 5912 } while (code <= 32); 5913 token = value.slice(pos, next); 5914 prev = tokens[tokens.length - 1]; 5915 if (code === closeParentheses && balanced) { 5916 after = token; 5917 } else if (prev && prev.type === "div") { 5918 prev.after = token; 5919 prev.sourceEndIndex += token.length; 5920 } else if (code === comma || code === colon || code === slash && value.charCodeAt(next + 1) !== star && (!parent || parent && parent.type === "function" && parent.value !== "calc")) { 5921 before = token; 5922 } else { 5923 tokens.push({ 5924 type: "space", 5925 sourceIndex: pos, 5926 sourceEndIndex: next, 5927 value: token 5928 }); 5929 } 5930 pos = next; 5931 } else if (code === singleQuote || code === doubleQuote) { 5932 next = pos; 5933 quote = code === singleQuote ? "'" : '"'; 5934 token = { 5935 type: "string", 5936 sourceIndex: pos, 5937 quote 5938 }; 5939 do { 5940 escape = false; 5941 next = value.indexOf(quote, next + 1); 5942 if (~next) { 5943 escapePos = next; 5944 while (value.charCodeAt(escapePos - 1) === backslash) { 5945 escapePos -= 1; 5946 escape = !escape; 5947 } 5948 } else { 5949 value += quote; 5950 next = value.length - 1; 5951 token.unclosed = true; 5952 } 5953 } while (escape); 5954 token.value = value.slice(pos + 1, next); 5955 token.sourceEndIndex = token.unclosed ? next : next + 1; 5956 tokens.push(token); 5957 pos = next + 1; 5958 code = value.charCodeAt(pos); 5959 } else if (code === slash && value.charCodeAt(pos + 1) === star) { 5960 next = value.indexOf("*/", pos); 5961 token = { 5962 type: "comment", 5963 sourceIndex: pos, 5964 sourceEndIndex: next + 2 5965 }; 5966 if (next === -1) { 5967 token.unclosed = true; 5968 next = value.length; 5969 token.sourceEndIndex = next; 5970 } 5971 token.value = value.slice(pos + 2, next); 5972 tokens.push(token); 5973 pos = next + 2; 5974 code = value.charCodeAt(pos); 5975 } else if ((code === slash || code === star) && parent && parent.type === "function" && parent.value === "calc") { 5976 token = value[pos]; 5977 tokens.push({ 5978 type: "word", 5979 sourceIndex: pos - before.length, 5980 sourceEndIndex: pos + token.length, 5981 value: token 5982 }); 5983 pos += 1; 5984 code = value.charCodeAt(pos); 5985 } else if (code === slash || code === comma || code === colon) { 5986 token = value[pos]; 5987 tokens.push({ 5988 type: "div", 5989 sourceIndex: pos - before.length, 5990 sourceEndIndex: pos + token.length, 5991 value: token, 5992 before, 5993 after: "" 5994 }); 5995 before = ""; 5996 pos += 1; 5997 code = value.charCodeAt(pos); 5998 } else if (openParentheses === code) { 5999 next = pos; 6000 do { 6001 next += 1; 6002 code = value.charCodeAt(next); 6003 } while (code <= 32); 6004 parenthesesOpenPos = pos; 6005 token = { 6006 type: "function", 6007 sourceIndex: pos - name.length, 6008 value: name, 6009 before: value.slice(parenthesesOpenPos + 1, next) 6010 }; 6011 pos = next; 6012 if (name === "url" && code !== singleQuote && code !== doubleQuote) { 6013 next -= 1; 6014 do { 6015 escape = false; 6016 next = value.indexOf(")", next + 1); 6017 if (~next) { 6018 escapePos = next; 6019 while (value.charCodeAt(escapePos - 1) === backslash) { 6020 escapePos -= 1; 6021 escape = !escape; 6022 } 6023 } else { 6024 value += ")"; 6025 next = value.length - 1; 6026 token.unclosed = true; 6027 } 6028 } while (escape); 6029 whitespacePos = next; 6030 do { 6031 whitespacePos -= 1; 6032 code = value.charCodeAt(whitespacePos); 6033 } while (code <= 32); 6034 if (parenthesesOpenPos < whitespacePos) { 6035 if (pos !== whitespacePos + 1) { 6036 token.nodes = [ 6037 { 6038 type: "word", 6039 sourceIndex: pos, 6040 sourceEndIndex: whitespacePos + 1, 6041 value: value.slice(pos, whitespacePos + 1) 6042 } 6043 ]; 6044 } else { 6045 token.nodes = []; 6046 } 6047 if (token.unclosed && whitespacePos + 1 !== next) { 6048 token.after = ""; 6049 token.nodes.push({ 6050 type: "space", 6051 sourceIndex: whitespacePos + 1, 6052 sourceEndIndex: next, 6053 value: value.slice(whitespacePos + 1, next) 6054 }); 6055 } else { 6056 token.after = value.slice(whitespacePos + 1, next); 6057 token.sourceEndIndex = next; 6058 } 6059 } else { 6060 token.after = ""; 6061 token.nodes = []; 6062 } 6063 pos = next + 1; 6064 token.sourceEndIndex = token.unclosed ? next : pos; 6065 code = value.charCodeAt(pos); 6066 tokens.push(token); 6067 } else { 6068 balanced += 1; 6069 token.after = ""; 6070 token.sourceEndIndex = pos + 1; 6071 tokens.push(token); 6072 stack.push(token); 6073 tokens = token.nodes = []; 6074 parent = token; 6075 } 6076 name = ""; 6077 } else if (closeParentheses === code && balanced) { 6078 pos += 1; 6079 code = value.charCodeAt(pos); 6080 parent.after = after; 6081 parent.sourceEndIndex += after.length; 6082 after = ""; 6083 balanced -= 1; 6084 stack[stack.length - 1].sourceEndIndex = pos; 6085 stack.pop(); 6086 parent = stack[balanced]; 6087 tokens = parent.nodes; 6088 } else { 6089 next = pos; 6090 do { 6091 if (code === backslash) { 6092 next += 1; 6093 } 6094 next += 1; 6095 code = value.charCodeAt(next); 6096 } while (next < max && !(code <= 32 || code === singleQuote || code === doubleQuote || code === comma || code === colon || code === slash || code === openParentheses || code === star && parent && parent.type === "function" && parent.value === "calc" || code === slash && parent.type === "function" && parent.value === "calc" || code === closeParentheses && balanced)); 6097 token = value.slice(pos, next); 6098 if (openParentheses === code) { 6099 name = token; 6100 } else if ((uLower === token.charCodeAt(0) || uUpper === token.charCodeAt(0)) && plus === token.charCodeAt(1) && isUnicodeRange.test(token.slice(2))) { 6101 tokens.push({ 6102 type: "unicode-range", 6103 sourceIndex: pos, 6104 sourceEndIndex: next, 6105 value: token 6106 }); 6107 } else { 6108 tokens.push({ 6109 type: "word", 6110 sourceIndex: pos, 6111 sourceEndIndex: next, 6112 value: token 6113 }); 6114 } 6115 pos = next; 6116 } 6117 } 6118 for (pos = stack.length - 1; pos; pos -= 1) { 6119 stack[pos].unclosed = true; 6120 stack[pos].sourceEndIndex = value.length; 6121 } 6122 return stack[0].nodes; 6123 }; 6124 } 6125 }); 6126 6127 // packages/block-editor/node_modules/postcss-value-parser/lib/walk.js 6128 var require_walk = __commonJS({ 6129 "packages/block-editor/node_modules/postcss-value-parser/lib/walk.js"(exports, module) { 6130 module.exports = function walk(nodes, cb, bubble) { 6131 var i2, max, node, result; 6132 for (i2 = 0, max = nodes.length; i2 < max; i2 += 1) { 6133 node = nodes[i2]; 6134 if (!bubble) { 6135 result = cb(node, i2, nodes); 6136 } 6137 if (result !== false && node.type === "function" && Array.isArray(node.nodes)) { 6138 walk(node.nodes, cb, bubble); 6139 } 6140 if (bubble) { 6141 cb(node, i2, nodes); 6142 } 6143 } 6144 }; 6145 } 6146 }); 6147 6148 // packages/block-editor/node_modules/postcss-value-parser/lib/stringify.js 6149 var require_stringify2 = __commonJS({ 6150 "packages/block-editor/node_modules/postcss-value-parser/lib/stringify.js"(exports, module) { 6151 function stringifyNode(node, custom) { 6152 var type = node.type; 6153 var value = node.value; 6154 var buf; 6155 var customResult; 6156 if (custom && (customResult = custom(node)) !== void 0) { 6157 return customResult; 6158 } else if (type === "word" || type === "space") { 6159 return value; 6160 } else if (type === "string") { 6161 buf = node.quote || ""; 6162 return buf + value + (node.unclosed ? "" : buf); 6163 } else if (type === "comment") { 6164 return "/*" + value + (node.unclosed ? "" : "*/"); 6165 } else if (type === "div") { 6166 return (node.before || "") + value + (node.after || ""); 6167 } else if (Array.isArray(node.nodes)) { 6168 buf = stringify2(node.nodes, custom); 6169 if (type !== "function") { 6170 return buf; 6171 } 6172 return value + "(" + (node.before || "") + buf + (node.after || "") + (node.unclosed ? "" : ")"); 6173 } 6174 return value; 6175 } 6176 function stringify2(nodes, custom) { 6177 var result, i2; 6178 if (Array.isArray(nodes)) { 6179 result = ""; 6180 for (i2 = nodes.length - 1; ~i2; i2 -= 1) { 6181 result = stringifyNode(nodes[i2], custom) + result; 6182 } 6183 return result; 6184 } 6185 return stringifyNode(nodes, custom); 6186 } 6187 module.exports = stringify2; 6188 } 6189 }); 6190 6191 // packages/block-editor/node_modules/postcss-value-parser/lib/unit.js 6192 var require_unit = __commonJS({ 6193 "packages/block-editor/node_modules/postcss-value-parser/lib/unit.js"(exports, module) { 6194 var minus = "-".charCodeAt(0); 6195 var plus = "+".charCodeAt(0); 6196 var dot = ".".charCodeAt(0); 6197 var exp = "e".charCodeAt(0); 6198 var EXP = "E".charCodeAt(0); 6199 function likeNumber(value) { 6200 var code = value.charCodeAt(0); 6201 var nextCode; 6202 if (code === plus || code === minus) { 6203 nextCode = value.charCodeAt(1); 6204 if (nextCode >= 48 && nextCode <= 57) { 6205 return true; 6206 } 6207 var nextNextCode = value.charCodeAt(2); 6208 if (nextCode === dot && nextNextCode >= 48 && nextNextCode <= 57) { 6209 return true; 6210 } 6211 return false; 6212 } 6213 if (code === dot) { 6214 nextCode = value.charCodeAt(1); 6215 if (nextCode >= 48 && nextCode <= 57) { 6216 return true; 6217 } 6218 return false; 6219 } 6220 if (code >= 48 && code <= 57) { 6221 return true; 6222 } 6223 return false; 6224 } 6225 module.exports = function(value) { 6226 var pos = 0; 6227 var length = value.length; 6228 var code; 6229 var nextCode; 6230 var nextNextCode; 6231 if (length === 0 || !likeNumber(value)) { 6232 return false; 6233 } 6234 code = value.charCodeAt(pos); 6235 if (code === plus || code === minus) { 6236 pos++; 6237 } 6238 while (pos < length) { 6239 code = value.charCodeAt(pos); 6240 if (code < 48 || code > 57) { 6241 break; 6242 } 6243 pos += 1; 6244 } 6245 code = value.charCodeAt(pos); 6246 nextCode = value.charCodeAt(pos + 1); 6247 if (code === dot && nextCode >= 48 && nextCode <= 57) { 6248 pos += 2; 6249 while (pos < length) { 6250 code = value.charCodeAt(pos); 6251 if (code < 48 || code > 57) { 6252 break; 6253 } 6254 pos += 1; 6255 } 6256 } 6257 code = value.charCodeAt(pos); 6258 nextCode = value.charCodeAt(pos + 1); 6259 nextNextCode = value.charCodeAt(pos + 2); 6260 if ((code === exp || code === EXP) && (nextCode >= 48 && nextCode <= 57 || (nextCode === plus || nextCode === minus) && nextNextCode >= 48 && nextNextCode <= 57)) { 6261 pos += nextCode === plus || nextCode === minus ? 3 : 2; 6262 while (pos < length) { 6263 code = value.charCodeAt(pos); 6264 if (code < 48 || code > 57) { 6265 break; 6266 } 6267 pos += 1; 6268 } 6269 } 6270 return { 6271 number: value.slice(0, pos), 6272 unit: value.slice(pos) 6273 }; 6274 }; 6275 } 6276 }); 6277 6278 // packages/block-editor/node_modules/postcss-value-parser/lib/index.js 6279 var require_lib2 = __commonJS({ 6280 "packages/block-editor/node_modules/postcss-value-parser/lib/index.js"(exports, module) { 6281 var parse4 = require_parse2(); 6282 var walk = require_walk(); 6283 var stringify2 = require_stringify2(); 6284 function ValueParser(value) { 6285 if (this instanceof ValueParser) { 6286 this.nodes = parse4(value); 6287 return this; 6288 } 6289 return new ValueParser(value); 6290 } 6291 ValueParser.prototype.toString = function() { 6292 return Array.isArray(this.nodes) ? stringify2(this.nodes) : ""; 6293 }; 6294 ValueParser.prototype.walk = function(cb, bubble) { 6295 walk(this.nodes, cb, bubble); 6296 return this; 6297 }; 6298 ValueParser.unit = require_unit(); 6299 ValueParser.walk = walk; 6300 ValueParser.stringify = stringify2; 6301 module.exports = ValueParser; 6302 } 6303 }); 6304 6305 // packages/block-editor/node_modules/postcss-urlrebase/index.js 6306 var require_postcss_urlrebase = __commonJS({ 6307 "packages/block-editor/node_modules/postcss-urlrebase/index.js"(exports, module) { 6308 var CSSValueParser = require_lib2(); 6309 module.exports = (opts) => { 6310 const DEFAULTS = { 6311 skipHostRelativeUrls: true 6312 }; 6313 const config2 = Object.assign(DEFAULTS, opts); 6314 return { 6315 postcssPlugin: "rebaseUrl", 6316 Declaration(decl) { 6317 const parsedValue = CSSValueParser(decl.value); 6318 let valueChanged = false; 6319 parsedValue.walk((node) => { 6320 if (node.type !== "function" || node.value !== "url") { 6321 return; 6322 } 6323 const urlVal = node.nodes[0].value; 6324 const basedUrl = new URL(urlVal, opts.rootUrl); 6325 if (basedUrl.pathname === urlVal && config2.skipHostRelativeUrls) { 6326 return false; 6327 } 6328 node.nodes[0].value = basedUrl.toString(); 6329 valueChanged = true; 6330 return false; 6331 }); 6332 if (valueChanged) { 6333 decl.value = CSSValueParser.stringify(parsedValue); 6334 } 6335 } 6336 }; 6337 }; 6338 module.exports.postcss = true; 6339 } 6340 }); 6341 6342 // package-external:@wordpress/priority-queue 6343 var require_priority_queue = __commonJS({ 6344 "package-external:@wordpress/priority-queue"(exports, module) { 6345 module.exports = window.wp.priorityQueue; 6346 } 6347 }); 6348 6349 // package-external:@wordpress/is-shallow-equal 6350 var require_is_shallow_equal = __commonJS({ 6351 "package-external:@wordpress/is-shallow-equal"(exports, module) { 6352 module.exports = window.wp.isShallowEqual; 6353 } 6354 }); 6355 6356 // package-external:@wordpress/token-list 6357 var require_token_list = __commonJS({ 6358 "package-external:@wordpress/token-list"(exports, module) { 6359 module.exports = window.wp.tokenList; 6360 } 6361 }); 6362 6363 // node_modules/deepmerge/dist/cjs.js 6364 var require_cjs = __commonJS({ 6365 "node_modules/deepmerge/dist/cjs.js"(exports, module) { 6366 "use strict"; 6367 var isMergeableObject = function isMergeableObject2(value) { 6368 return isNonNullObject(value) && !isSpecial(value); 6369 }; 6370 function isNonNullObject(value) { 6371 return !!value && typeof value === "object"; 6372 } 6373 function isSpecial(value) { 6374 var stringValue = Object.prototype.toString.call(value); 6375 return stringValue === "[object RegExp]" || stringValue === "[object Date]" || isReactElement(value); 6376 } 6377 var canUseSymbol = typeof Symbol === "function" && Symbol.for; 6378 var REACT_ELEMENT_TYPE = canUseSymbol ? Symbol.for("react.element") : 60103; 6379 function isReactElement(value) { 6380 return value.$$typeof === REACT_ELEMENT_TYPE; 6381 } 6382 function emptyTarget(val) { 6383 return Array.isArray(val) ? [] : {}; 6384 } 6385 function cloneUnlessOtherwiseSpecified(value, options) { 6386 return options.clone !== false && options.isMergeableObject(value) ? deepmerge(emptyTarget(value), value, options) : value; 6387 } 6388 function defaultArrayMerge(target, source, options) { 6389 return target.concat(source).map(function(element) { 6390 return cloneUnlessOtherwiseSpecified(element, options); 6391 }); 6392 } 6393 function getMergeFunction(key, options) { 6394 if (!options.customMerge) { 6395 return deepmerge; 6396 } 6397 var customMerge = options.customMerge(key); 6398 return typeof customMerge === "function" ? customMerge : deepmerge; 6399 } 6400 function getEnumerableOwnPropertySymbols(target) { 6401 return Object.getOwnPropertySymbols ? Object.getOwnPropertySymbols(target).filter(function(symbol) { 6402 return Object.propertyIsEnumerable.call(target, symbol); 6403 }) : []; 6404 } 6405 function getKeys(target) { 6406 return Object.keys(target).concat(getEnumerableOwnPropertySymbols(target)); 6407 } 6408 function propertyIsOnObject(object, property) { 6409 try { 6410 return property in object; 6411 } catch (_) { 6412 return false; 6413 } 6414 } 6415 function propertyIsUnsafe(target, key) { 6416 return propertyIsOnObject(target, key) && !(Object.hasOwnProperty.call(target, key) && Object.propertyIsEnumerable.call(target, key)); 6417 } 6418 function mergeObject(target, source, options) { 6419 var destination = {}; 6420 if (options.isMergeableObject(target)) { 6421 getKeys(target).forEach(function(key) { 6422 destination[key] = cloneUnlessOtherwiseSpecified(target[key], options); 6423 }); 6424 } 6425 getKeys(source).forEach(function(key) { 6426 if (propertyIsUnsafe(target, key)) { 6427 return; 6428 } 6429 if (propertyIsOnObject(target, key) && options.isMergeableObject(source[key])) { 6430 destination[key] = getMergeFunction(key, options)(target[key], source[key], options); 6431 } else { 6432 destination[key] = cloneUnlessOtherwiseSpecified(source[key], options); 6433 } 6434 }); 6435 return destination; 6436 } 6437 function deepmerge(target, source, options) { 6438 options = options || {}; 6439 options.arrayMerge = options.arrayMerge || defaultArrayMerge; 6440 options.isMergeableObject = options.isMergeableObject || isMergeableObject; 6441 options.cloneUnlessOtherwiseSpecified = cloneUnlessOtherwiseSpecified; 6442 var sourceIsArray = Array.isArray(source); 6443 var targetIsArray = Array.isArray(target); 6444 var sourceAndTargetTypesMatch = sourceIsArray === targetIsArray; 6445 if (!sourceAndTargetTypesMatch) { 6446 return cloneUnlessOtherwiseSpecified(source, options); 6447 } else if (sourceIsArray) { 6448 return options.arrayMerge(target, source, options); 6449 } else { 6450 return mergeObject(target, source, options); 6451 } 6452 } 6453 deepmerge.all = function deepmergeAll(array, options) { 6454 if (!Array.isArray(array)) { 6455 throw new Error("first argument should be an array"); 6456 } 6457 return array.reduce(function(prev, next) { 6458 return deepmerge(prev, next, options); 6459 }, {}); 6460 }; 6461 var deepmerge_1 = deepmerge; 6462 module.exports = deepmerge_1; 6463 } 6464 }); 6465 6466 // package-external:@wordpress/commands 6467 var require_commands = __commonJS({ 6468 "package-external:@wordpress/commands"(exports, module) { 6469 module.exports = window.wp.commands; 6470 } 6471 }); 6472 6473 // package-external:@wordpress/date 6474 var require_date = __commonJS({ 6475 "package-external:@wordpress/date"(exports, module) { 6476 module.exports = window.wp.date; 6477 } 6478 }); 6479 6480 // node_modules/normalize-wheel/src/UserAgent_DEPRECATED.js 6481 var require_UserAgent_DEPRECATED = __commonJS({ 6482 "node_modules/normalize-wheel/src/UserAgent_DEPRECATED.js"(exports, module) { 6483 var _populated = false; 6484 var _ie; 6485 var _firefox; 6486 var _opera; 6487 var _webkit; 6488 var _chrome; 6489 var _ie_real_version; 6490 var _osx; 6491 var _windows; 6492 var _linux; 6493 var _android; 6494 var _win64; 6495 var _iphone; 6496 var _ipad; 6497 var _native; 6498 var _mobile; 6499 function _populate() { 6500 if (_populated) { 6501 return; 6502 } 6503 _populated = true; 6504 var uas = navigator.userAgent; 6505 var agent = /(?:MSIE.(\d+\.\d+))|(?:(?:Firefox|GranParadiso|Iceweasel).(\d+\.\d+))|(?:Opera(?:.+Version.|.)(\d+\.\d+))|(?:AppleWebKit.(\d+(?:\.\d+)?))|(?:Trident\/\d+\.\d+.*rv:(\d+\.\d+))/.exec(uas); 6506 var os = /(Mac OS X)|(Windows)|(Linux)/.exec(uas); 6507 _iphone = /\b(iPhone|iP[ao]d)/.exec(uas); 6508 _ipad = /\b(iP[ao]d)/.exec(uas); 6509 _android = /Android/i.exec(uas); 6510 _native = /FBAN\/\w+;/i.exec(uas); 6511 _mobile = /Mobile/i.exec(uas); 6512 _win64 = !!/Win64/.exec(uas); 6513 if (agent) { 6514 _ie = agent[1] ? parseFloat(agent[1]) : agent[5] ? parseFloat(agent[5]) : NaN; 6515 if (_ie && document && document.documentMode) { 6516 _ie = document.documentMode; 6517 } 6518 var trident = /(?:Trident\/(\d+.\d+))/.exec(uas); 6519 _ie_real_version = trident ? parseFloat(trident[1]) + 4 : _ie; 6520 _firefox = agent[2] ? parseFloat(agent[2]) : NaN; 6521 _opera = agent[3] ? parseFloat(agent[3]) : NaN; 6522 _webkit = agent[4] ? parseFloat(agent[4]) : NaN; 6523 if (_webkit) { 6524 agent = /(?:Chrome\/(\d+\.\d+))/.exec(uas); 6525 _chrome = agent && agent[1] ? parseFloat(agent[1]) : NaN; 6526 } else { 6527 _chrome = NaN; 6528 } 6529 } else { 6530 _ie = _firefox = _opera = _chrome = _webkit = NaN; 6531 } 6532 if (os) { 6533 if (os[1]) { 6534 var ver = /(?:Mac OS X (\d+(?:[._]\d+)?))/.exec(uas); 6535 _osx = ver ? parseFloat(ver[1].replace("_", ".")) : true; 6536 } else { 6537 _osx = false; 6538 } 6539 _windows = !!os[2]; 6540 _linux = !!os[3]; 6541 } else { 6542 _osx = _windows = _linux = false; 6543 } 6544 } 6545 var UserAgent_DEPRECATED = { 6546 /** 6547 * Check if the UA is Internet Explorer. 6548 * 6549 * 6550 * @return float|NaN Version number (if match) or NaN. 6551 */ 6552 ie: function() { 6553 return _populate() || _ie; 6554 }, 6555 /** 6556 * Check if we're in Internet Explorer compatibility mode. 6557 * 6558 * @return bool true if in compatibility mode, false if 6559 * not compatibility mode or not ie 6560 */ 6561 ieCompatibilityMode: function() { 6562 return _populate() || _ie_real_version > _ie; 6563 }, 6564 /** 6565 * Whether the browser is 64-bit IE. Really, this is kind of weak sauce; we 6566 * only need this because Skype can't handle 64-bit IE yet. We need to remove 6567 * this when we don't need it -- tracked by #601957. 6568 */ 6569 ie64: function() { 6570 return UserAgent_DEPRECATED.ie() && _win64; 6571 }, 6572 /** 6573 * Check if the UA is Firefox. 6574 * 6575 * 6576 * @return float|NaN Version number (if match) or NaN. 6577 */ 6578 firefox: function() { 6579 return _populate() || _firefox; 6580 }, 6581 /** 6582 * Check if the UA is Opera. 6583 * 6584 * 6585 * @return float|NaN Version number (if match) or NaN. 6586 */ 6587 opera: function() { 6588 return _populate() || _opera; 6589 }, 6590 /** 6591 * Check if the UA is WebKit. 6592 * 6593 * 6594 * @return float|NaN Version number (if match) or NaN. 6595 */ 6596 webkit: function() { 6597 return _populate() || _webkit; 6598 }, 6599 /** 6600 * For Push 6601 * WILL BE REMOVED VERY SOON. Use UserAgent_DEPRECATED.webkit 6602 */ 6603 safari: function() { 6604 return UserAgent_DEPRECATED.webkit(); 6605 }, 6606 /** 6607 * Check if the UA is a Chrome browser. 6608 * 6609 * 6610 * @return float|NaN Version number (if match) or NaN. 6611 */ 6612 chrome: function() { 6613 return _populate() || _chrome; 6614 }, 6615 /** 6616 * Check if the user is running Windows. 6617 * 6618 * @return bool `true' if the user's OS is Windows. 6619 */ 6620 windows: function() { 6621 return _populate() || _windows; 6622 }, 6623 /** 6624 * Check if the user is running Mac OS X. 6625 * 6626 * @return float|bool Returns a float if a version number is detected, 6627 * otherwise true/false. 6628 */ 6629 osx: function() { 6630 return _populate() || _osx; 6631 }, 6632 /** 6633 * Check if the user is running Linux. 6634 * 6635 * @return bool `true' if the user's OS is some flavor of Linux. 6636 */ 6637 linux: function() { 6638 return _populate() || _linux; 6639 }, 6640 /** 6641 * Check if the user is running on an iPhone or iPod platform. 6642 * 6643 * @return bool `true' if the user is running some flavor of the 6644 * iPhone OS. 6645 */ 6646 iphone: function() { 6647 return _populate() || _iphone; 6648 }, 6649 mobile: function() { 6650 return _populate() || (_iphone || _ipad || _android || _mobile); 6651 }, 6652 nativeApp: function() { 6653 return _populate() || _native; 6654 }, 6655 android: function() { 6656 return _populate() || _android; 6657 }, 6658 ipad: function() { 6659 return _populate() || _ipad; 6660 } 6661 }; 6662 module.exports = UserAgent_DEPRECATED; 6663 } 6664 }); 6665 6666 // node_modules/normalize-wheel/src/ExecutionEnvironment.js 6667 var require_ExecutionEnvironment = __commonJS({ 6668 "node_modules/normalize-wheel/src/ExecutionEnvironment.js"(exports, module) { 6669 "use strict"; 6670 var canUseDOM = !!(typeof window !== "undefined" && window.document && window.document.createElement); 6671 var ExecutionEnvironment = { 6672 canUseDOM, 6673 canUseWorkers: typeof Worker !== "undefined", 6674 canUseEventListeners: canUseDOM && !!(window.addEventListener || window.attachEvent), 6675 canUseViewport: canUseDOM && !!window.screen, 6676 isInWorker: !canUseDOM 6677 // For now, this is true - might change in the future. 6678 }; 6679 module.exports = ExecutionEnvironment; 6680 } 6681 }); 6682 6683 // node_modules/normalize-wheel/src/isEventSupported.js 6684 var require_isEventSupported = __commonJS({ 6685 "node_modules/normalize-wheel/src/isEventSupported.js"(exports, module) { 6686 "use strict"; 6687 var ExecutionEnvironment = require_ExecutionEnvironment(); 6688 var useHasFeature; 6689 if (ExecutionEnvironment.canUseDOM) { 6690 useHasFeature = document.implementation && document.implementation.hasFeature && // always returns true in newer browsers as per the standard. 6691 // @see http://dom.spec.whatwg.org/#dom-domimplementation-hasfeature 6692 document.implementation.hasFeature("", "") !== true; 6693 } 6694 function isEventSupported(eventNameSuffix, capture) { 6695 if (!ExecutionEnvironment.canUseDOM || capture && !("addEventListener" in document)) { 6696 return false; 6697 } 6698 var eventName = "on" + eventNameSuffix; 6699 var isSupported = eventName in document; 6700 if (!isSupported) { 6701 var element = document.createElement("div"); 6702 element.setAttribute(eventName, "return;"); 6703 isSupported = typeof element[eventName] === "function"; 6704 } 6705 if (!isSupported && useHasFeature && eventNameSuffix === "wheel") { 6706 isSupported = document.implementation.hasFeature("Events.wheel", "3.0"); 6707 } 6708 return isSupported; 6709 } 6710 module.exports = isEventSupported; 6711 } 6712 }); 6713 6714 // node_modules/normalize-wheel/src/normalizeWheel.js 6715 var require_normalizeWheel = __commonJS({ 6716 "node_modules/normalize-wheel/src/normalizeWheel.js"(exports, module) { 6717 "use strict"; 6718 var UserAgent_DEPRECATED = require_UserAgent_DEPRECATED(); 6719 var isEventSupported = require_isEventSupported(); 6720 var PIXEL_STEP = 10; 6721 var LINE_HEIGHT = 40; 6722 var PAGE_HEIGHT = 800; 6723 function normalizeWheel2(event) { 6724 var sX = 0, sY = 0, pX = 0, pY = 0; 6725 if ("detail" in event) { 6726 sY = event.detail; 6727 } 6728 if ("wheelDelta" in event) { 6729 sY = -event.wheelDelta / 120; 6730 } 6731 if ("wheelDeltaY" in event) { 6732 sY = -event.wheelDeltaY / 120; 6733 } 6734 if ("wheelDeltaX" in event) { 6735 sX = -event.wheelDeltaX / 120; 6736 } 6737 if ("axis" in event && event.axis === event.HORIZONTAL_AXIS) { 6738 sX = sY; 6739 sY = 0; 6740 } 6741 pX = sX * PIXEL_STEP; 6742 pY = sY * PIXEL_STEP; 6743 if ("deltaY" in event) { 6744 pY = event.deltaY; 6745 } 6746 if ("deltaX" in event) { 6747 pX = event.deltaX; 6748 } 6749 if ((pX || pY) && event.deltaMode) { 6750 if (event.deltaMode == 1) { 6751 pX *= LINE_HEIGHT; 6752 pY *= LINE_HEIGHT; 6753 } else { 6754 pX *= PAGE_HEIGHT; 6755 pY *= PAGE_HEIGHT; 6756 } 6757 } 6758 if (pX && !sX) { 6759 sX = pX < 1 ? -1 : 1; 6760 } 6761 if (pY && !sY) { 6762 sY = pY < 1 ? -1 : 1; 6763 } 6764 return { 6765 spinX: sX, 6766 spinY: sY, 6767 pixelX: pX, 6768 pixelY: pY 6769 }; 6770 } 6771 normalizeWheel2.getEventType = function() { 6772 return UserAgent_DEPRECATED.firefox() ? "DOMMouseScroll" : isEventSupported("wheel") ? "wheel" : "mousewheel"; 6773 }; 6774 module.exports = normalizeWheel2; 6775 } 6776 }); 6777 6778 // node_modules/normalize-wheel/index.js 6779 var require_normalize_wheel = __commonJS({ 6780 "node_modules/normalize-wheel/index.js"(exports, module) { 6781 module.exports = require_normalizeWheel(); 6782 } 6783 }); 6784 6785 // node_modules/fast-deep-equal/index.js 6786 var require_fast_deep_equal = __commonJS({ 6787 "node_modules/fast-deep-equal/index.js"(exports, module) { 6788 "use strict"; 6789 module.exports = function equal(a2, b2) { 6790 if (a2 === b2) return true; 6791 if (a2 && b2 && typeof a2 == "object" && typeof b2 == "object") { 6792 if (a2.constructor !== b2.constructor) return false; 6793 var length, i2, keys; 6794 if (Array.isArray(a2)) { 6795 length = a2.length; 6796 if (length != b2.length) return false; 6797 for (i2 = length; i2-- !== 0; ) 6798 if (!equal(a2[i2], b2[i2])) return false; 6799 return true; 6800 } 6801 if (a2.constructor === RegExp) return a2.source === b2.source && a2.flags === b2.flags; 6802 if (a2.valueOf !== Object.prototype.valueOf) return a2.valueOf() === b2.valueOf(); 6803 if (a2.toString !== Object.prototype.toString) return a2.toString() === b2.toString(); 6804 keys = Object.keys(a2); 6805 length = keys.length; 6806 if (length !== Object.keys(b2).length) return false; 6807 for (i2 = length; i2-- !== 0; ) 6808 if (!Object.prototype.hasOwnProperty.call(b2, keys[i2])) return false; 6809 for (i2 = length; i2-- !== 0; ) { 6810 var key = keys[i2]; 6811 if (!equal(a2[key], b2[key])) return false; 6812 } 6813 return true; 6814 } 6815 return a2 !== a2 && b2 !== b2; 6816 }; 6817 } 6818 }); 6819 6820 // packages/block-editor/build-module/index.js 6821 var index_exports = {}; 6822 __export(index_exports, { 6823 AlignmentControl: () => AlignmentControl, 6824 AlignmentToolbar: () => AlignmentToolbar, 6825 Autocomplete: () => autocomplete_default, 6826 BlockAlignmentControl: () => BlockAlignmentControl, 6827 BlockAlignmentToolbar: () => BlockAlignmentToolbar, 6828 BlockBindingsAttributeControl: () => BlockBindingsAttributeControl, 6829 BlockBindingsSourceFieldsList: () => BlockBindingsSourceFieldsList, 6830 BlockBreadcrumb: () => block_breadcrumb_default, 6831 BlockCanvas: () => block_canvas_default, 6832 BlockColorsStyleSelector: () => color_style_selector_default, 6833 BlockContextProvider: () => BlockContextProvider, 6834 BlockControls: () => block_controls_default, 6835 BlockEdit: () => BlockEdit, 6836 BlockEditorKeyboardShortcuts: () => keyboard_shortcuts_default, 6837 BlockEditorProvider: () => provider_default2, 6838 BlockFormatControls: () => BlockFormatControls, 6839 BlockIcon: () => block_icon_default, 6840 BlockInspector: () => block_inspector_default, 6841 BlockList: () => BlockList, 6842 BlockMover: () => block_mover_default, 6843 BlockNavigationDropdown: () => dropdown_default, 6844 BlockPopover: () => block_popover_default, 6845 BlockPreview: () => block_preview_default, 6846 BlockSelectionClearer: () => BlockSelectionClearer, 6847 BlockSettingsMenu: () => block_settings_menu_default, 6848 BlockSettingsMenuControls: () => block_settings_menu_controls_default, 6849 BlockStyles: () => block_styles_default, 6850 BlockTitle: () => BlockTitle, 6851 BlockToolbar: () => BlockToolbar, 6852 BlockTools: () => BlockTools, 6853 BlockVerticalAlignmentControl: () => BlockVerticalAlignmentControl, 6854 BlockVerticalAlignmentToolbar: () => BlockVerticalAlignmentToolbar, 6855 ButtonBlockAppender: () => button_block_appender_default, 6856 ButtonBlockerAppender: () => ButtonBlockerAppender, 6857 ColorPalette: () => color_palette_default, 6858 ColorPaletteControl: () => ColorPaletteControl, 6859 ContrastChecker: () => contrast_checker_default, 6860 CopyHandler: () => CopyHandler, 6861 DefaultBlockAppender: () => DefaultBlockAppender, 6862 DimensionControl: () => DimensionControl, 6863 FontSizePicker: () => font_size_picker_default, 6864 HeadingLevelDropdown: () => HeadingLevelDropdown, 6865 HeightControl: () => HeightControl, 6866 InnerBlocks: () => inner_blocks_default, 6867 Inserter: () => inserter_default, 6868 InspectorAdvancedControls: () => InspectorAdvancedControls, 6869 InspectorControls: () => inspector_controls_default, 6870 JustifyContentControl: () => JustifyContentControl, 6871 JustifyToolbar: () => JustifyToolbar, 6872 LineHeightControl: () => line_height_control_default, 6873 LinkControl: () => link_control_default, 6874 MediaPlaceholder: () => media_placeholder_default, 6875 MediaReplaceFlow: () => media_replace_flow_default, 6876 MediaUpload: () => media_upload_default, 6877 MediaUploadCheck: () => check_default2, 6878 MultiSelectScrollIntoView: () => MultiSelectScrollIntoView, 6879 NavigableToolbar: () => NavigableToolbar, 6880 ObserveTyping: () => observe_typing_default, 6881 PanelColorSettings: () => panel_color_settings_default, 6882 PlainText: () => plain_text_default, 6883 RecursionProvider: () => RecursionProvider, 6884 RichText: () => rich_text_default, 6885 RichTextShortcut: () => RichTextShortcut, 6886 RichTextToolbarButton: () => RichTextToolbarButton, 6887 SETTINGS_DEFAULTS: () => SETTINGS_DEFAULTS, 6888 SkipToSelectedBlock: () => SkipToSelectedBlock, 6889 ToolSelector: () => tool_selector_default, 6890 Typewriter: () => typewriter_default, 6891 URLInput: () => url_input_default, 6892 URLInputButton: () => button_default, 6893 URLPopover: () => url_popover_default, 6894 Warning: () => warning_default, 6895 WritingFlow: () => writing_flow_default, 6896 __experimentalBlockAlignmentMatrixControl: () => block_alignment_matrix_control_default, 6897 __experimentalBlockFullHeightAligmentControl: () => block_full_height_alignment_control_default, 6898 __experimentalBlockPatternSetup: () => block_pattern_setup_default, 6899 __experimentalBlockPatternsList: () => block_patterns_list_default, 6900 __experimentalBlockVariationPicker: () => block_variation_picker_default, 6901 __experimentalBlockVariationTransforms: () => block_variation_transforms_default, 6902 __experimentalBorderRadiusControl: () => BorderRadiusControl, 6903 __experimentalColorGradientControl: () => control_default, 6904 __experimentalColorGradientSettingsDropdown: () => ColorGradientSettingsDropdown, 6905 __experimentalDateFormatPicker: () => DateFormatPicker, 6906 __experimentalDuotoneControl: () => duotone_control_default, 6907 __experimentalFontAppearanceControl: () => FontAppearanceControl, 6908 __experimentalFontFamilyControl: () => FontFamilyControl, 6909 __experimentalGetBorderClassesAndStyles: () => getBorderClassesAndStyles, 6910 __experimentalGetColorClassesAndStyles: () => getColorClassesAndStyles, 6911 __experimentalGetElementClassName: () => __experimentalGetElementClassName, 6912 __experimentalGetGapCSSValue: () => getGapCSSValue, 6913 __experimentalGetGradientClass: () => __experimentalGetGradientClass, 6914 __experimentalGetGradientObjectByGradientValue: () => __experimentalGetGradientObjectByGradientValue, 6915 __experimentalGetShadowClassesAndStyles: () => getShadowClassesAndStyles, 6916 __experimentalGetSpacingClassesAndStyles: () => getSpacingClassesAndStyles, 6917 __experimentalImageEditor: () => ImageEditor, 6918 __experimentalImageSizeControl: () => ImageSizeControl, 6919 __experimentalImageURLInputUI: () => ImageURLInputUI, 6920 __experimentalInspectorPopoverHeader: () => InspectorPopoverHeader, 6921 __experimentalLetterSpacingControl: () => LetterSpacingControl, 6922 __experimentalLibrary: () => library_default, 6923 __experimentalLinkControl: () => DeprecatedExperimentalLinkControl, 6924 __experimentalLinkControlSearchInput: () => __experimentalLinkControlSearchInput, 6925 __experimentalLinkControlSearchItem: () => __experimentalLinkControlSearchItem, 6926 __experimentalLinkControlSearchResults: () => __experimentalLinkControlSearchResults, 6927 __experimentalListView: () => list_view_default2, 6928 __experimentalPanelColorGradientSettings: () => panel_color_gradient_settings_default, 6929 __experimentalPreviewOptions: () => PreviewOptions, 6930 __experimentalPublishDateTimePicker: () => publish_date_time_picker_default, 6931 __experimentalRecursionProvider: () => DeprecatedExperimentalRecursionProvider, 6932 __experimentalResponsiveBlockControl: () => responsive_block_control_default, 6933 __experimentalSpacingSizesControl: () => SpacingSizesControl, 6934 __experimentalTextDecorationControl: () => TextDecorationControl, 6935 __experimentalTextTransformControl: () => TextTransformControl, 6936 __experimentalUnitControl: () => UnitControl6, 6937 __experimentalUseBlockOverlayActive: () => useBlockOverlayActive, 6938 __experimentalUseBlockPreview: () => useBlockPreview, 6939 __experimentalUseBorderProps: () => useBorderProps, 6940 __experimentalUseColorProps: () => useColorProps, 6941 __experimentalUseCustomSides: () => useCustomSides, 6942 __experimentalUseGradient: () => __experimentalUseGradient, 6943 __experimentalUseHasRecursion: () => DeprecatedExperimentalUseHasRecursion, 6944 __experimentalUseMultipleOriginColorsAndGradients: () => useMultipleOriginColorsAndGradients, 6945 __experimentalUseResizeCanvas: () => useResizeCanvas, 6946 __experimentalWritingModeControl: () => WritingModeControl, 6947 __unstableBlockSettingsMenuFirstItem: () => block_settings_menu_first_item_default, 6948 __unstableBlockToolbarLastItem: () => block_toolbar_last_item_default, 6949 __unstableEditorStyles: () => editor_styles_default, 6950 __unstableIframe: () => iframe_default, 6951 __unstableInserterMenuExtension: () => inserter_menu_extension_default, 6952 __unstableRichTextInputEvent: () => __unstableRichTextInputEvent, 6953 __unstableUseBlockSelectionClearer: () => useBlockSelectionClearer, 6954 __unstableUseClipboardHandler: () => __unstableUseClipboardHandler, 6955 __unstableUseMouseMoveTypingReset: () => useMouseMoveTypingReset, 6956 __unstableUseTypewriter: () => useTypewriter, 6957 __unstableUseTypingObserver: () => useTypingObserver, 6958 createCustomColorsHOC: () => createCustomColorsHOC, 6959 getColorClassName: () => getColorClassName, 6960 getColorObjectByAttributeValues: () => getColorObjectByAttributeValues, 6961 getColorObjectByColorValue: () => getColorObjectByColorValue, 6962 getComputedFluidTypographyValue: () => getComputedFluidTypographyValue, 6963 getCustomValueFromPreset: () => getCustomValueFromPreset, 6964 getFontSize: () => getFontSize, 6965 getFontSizeClass: () => getFontSizeClass, 6966 getFontSizeObjectByValue: () => getFontSizeObjectByValue, 6967 getGradientSlugByValue: () => getGradientSlugByValue, 6968 getGradientValueBySlug: () => getGradientValueBySlug, 6969 getPxFromCssUnit: () => get_px_from_css_unit_default, 6970 getSpacingPresetCssVar: () => getSpacingPresetCssVar, 6971 getTypographyClassesAndStyles: () => getTypographyClassesAndStyles, 6972 isValueSpacingPreset: () => isValueSpacingPreset, 6973 privateApis: () => privateApis12, 6974 store: () => store, 6975 storeConfig: () => storeConfig, 6976 transformStyles: () => transform_styles_default, 6977 useBlockBindingsUtils: () => useBlockBindingsUtils, 6978 useBlockCommands: () => useBlockCommands, 6979 useBlockDisplayInformation: () => useBlockDisplayInformation, 6980 useBlockEditContext: () => useBlockEditContext, 6981 useBlockEditingMode: () => useBlockEditingMode, 6982 useBlockProps: () => useBlockProps, 6983 useCachedTruthy: () => useCachedTruthy, 6984 useHasRecursion: () => useHasRecursion, 6985 useInnerBlocksProps: () => useInnerBlocksProps, 6986 useSetting: () => useSetting, 6987 useSettings: () => useSettings, 6988 useStyleOverride: () => useStyleOverride, 6989 withColorContext: () => with_color_context_default, 6990 withColors: () => withColors, 6991 withFontSizes: () => with_font_sizes_default 6992 }); 6993 6994 // packages/block-editor/build-module/hooks/utils.js 6995 var import_blocks94 = __toESM(require_blocks()); 6996 var import_element247 = __toESM(require_element()); 6997 var import_data176 = __toESM(require_data()); 6998 var import_compose94 = __toESM(require_compose()); 6999 var import_hooks13 = __toESM(require_hooks()); 7000 7001 // packages/block-editor/build-module/components/block-edit/context.js 7002 var import_element = __toESM(require_element()); 7003 var mayDisplayControlsKey = Symbol("mayDisplayControls"); 7004 var mayDisplayParentControlsKey = Symbol("mayDisplayParentControls"); 7005 var blockEditingModeKey = Symbol("blockEditingMode"); 7006 var blockBindingsKey = Symbol("blockBindings"); 7007 var isPreviewModeKey = Symbol("isPreviewMode"); 7008 var DEFAULT_BLOCK_EDIT_CONTEXT = { 7009 name: "", 7010 isSelected: false 7011 }; 7012 var Context = (0, import_element.createContext)(DEFAULT_BLOCK_EDIT_CONTEXT); 7013 Context.displayName = "BlockEditContext"; 7014 var { Provider } = Context; 7015 function useBlockEditContext() { 7016 return (0, import_element.useContext)(Context); 7017 } 7018 7019 // node_modules/colord/index.mjs 7020 var r = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }; 7021 var t = function(r3) { 7022 return "string" == typeof r3 ? r3.length > 0 : "number" == typeof r3; 7023 }; 7024 var n = function(r3, t3, n2) { 7025 return void 0 === t3 && (t3 = 0), void 0 === n2 && (n2 = Math.pow(10, t3)), Math.round(n2 * r3) / n2 + 0; 7026 }; 7027 var e = function(r3, t3, n2) { 7028 return void 0 === t3 && (t3 = 0), void 0 === n2 && (n2 = 1), r3 > n2 ? n2 : r3 > t3 ? r3 : t3; 7029 }; 7030 var u = function(r3) { 7031 return (r3 = isFinite(r3) ? r3 % 360 : 0) > 0 ? r3 : r3 + 360; 7032 }; 7033 var a = function(r3) { 7034 return { r: e(r3.r, 0, 255), g: e(r3.g, 0, 255), b: e(r3.b, 0, 255), a: e(r3.a) }; 7035 }; 7036 var o = function(r3) { 7037 return { r: n(r3.r), g: n(r3.g), b: n(r3.b), a: n(r3.a, 3) }; 7038 }; 7039 var i = /^#([0-9a-f]{3,8})$/i; 7040 var s = function(r3) { 7041 var t3 = r3.toString(16); 7042 return t3.length < 2 ? "0" + t3 : t3; 7043 }; 7044 var h = function(r3) { 7045 var t3 = r3.r, n2 = r3.g, e2 = r3.b, u2 = r3.a, a2 = Math.max(t3, n2, e2), o3 = a2 - Math.min(t3, n2, e2), i2 = o3 ? a2 === t3 ? (n2 - e2) / o3 : a2 === n2 ? 2 + (e2 - t3) / o3 : 4 + (t3 - n2) / o3 : 0; 7046 return { h: 60 * (i2 < 0 ? i2 + 6 : i2), s: a2 ? o3 / a2 * 100 : 0, v: a2 / 255 * 100, a: u2 }; 7047 }; 7048 var b = function(r3) { 7049 var t3 = r3.h, n2 = r3.s, e2 = r3.v, u2 = r3.a; 7050 t3 = t3 / 360 * 6, n2 /= 100, e2 /= 100; 7051 var a2 = Math.floor(t3), o3 = e2 * (1 - n2), i2 = e2 * (1 - (t3 - a2) * n2), s2 = e2 * (1 - (1 - t3 + a2) * n2), h2 = a2 % 6; 7052 return { r: 255 * [e2, i2, o3, o3, s2, e2][h2], g: 255 * [s2, e2, e2, i2, o3, o3][h2], b: 255 * [o3, o3, s2, e2, e2, i2][h2], a: u2 }; 7053 }; 7054 var g = function(r3) { 7055 return { h: u(r3.h), s: e(r3.s, 0, 100), l: e(r3.l, 0, 100), a: e(r3.a) }; 7056 }; 7057 var d = function(r3) { 7058 return { h: n(r3.h), s: n(r3.s), l: n(r3.l), a: n(r3.a, 3) }; 7059 }; 7060 var f = function(r3) { 7061 return b((n2 = (t3 = r3).s, { h: t3.h, s: (n2 *= ((e2 = t3.l) < 50 ? e2 : 100 - e2) / 100) > 0 ? 2 * n2 / (e2 + n2) * 100 : 0, v: e2 + n2, a: t3.a })); 7062 var t3, n2, e2; 7063 }; 7064 var c = function(r3) { 7065 return { h: (t3 = h(r3)).h, s: (u2 = (200 - (n2 = t3.s)) * (e2 = t3.v) / 100) > 0 && u2 < 200 ? n2 * e2 / 100 / (u2 <= 100 ? u2 : 200 - u2) * 100 : 0, l: u2 / 2, a: t3.a }; 7066 var t3, n2, e2, u2; 7067 }; 7068 var l = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i; 7069 var p = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i; 7070 var v = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i; 7071 var m = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i; 7072 var y = { string: [[function(r3) { 7073 var t3 = i.exec(r3); 7074 return t3 ? (r3 = t3[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; 7075 }, "hex"], [function(r3) { 7076 var t3 = v.exec(r3) || m.exec(r3); 7077 return t3 ? t3[2] !== t3[4] || t3[4] !== t3[6] ? null : a({ r: Number(t3[1]) / (t3[2] ? 100 / 255 : 1), g: Number(t3[3]) / (t3[4] ? 100 / 255 : 1), b: Number(t3[5]) / (t3[6] ? 100 / 255 : 1), a: void 0 === t3[7] ? 1 : Number(t3[7]) / (t3[8] ? 100 : 1) }) : null; 7078 }, "rgb"], [function(t3) { 7079 var n2 = l.exec(t3) || p.exec(t3); 7080 if (!n2) return null; 7081 var e2, u2, a2 = g({ h: (e2 = n2[1], u2 = n2[2], void 0 === u2 && (u2 = "deg"), Number(e2) * (r[u2] || 1)), s: Number(n2[3]), l: Number(n2[4]), a: void 0 === n2[5] ? 1 : Number(n2[5]) / (n2[6] ? 100 : 1) }); 7082 return f(a2); 7083 }, "hsl"]], object: [[function(r3) { 7084 var n2 = r3.r, e2 = r3.g, u2 = r3.b, o3 = r3.a, i2 = void 0 === o3 ? 1 : o3; 7085 return t(n2) && t(e2) && t(u2) ? a({ r: Number(n2), g: Number(e2), b: Number(u2), a: Number(i2) }) : null; 7086 }, "rgb"], [function(r3) { 7087 var n2 = r3.h, e2 = r3.s, u2 = r3.l, a2 = r3.a, o3 = void 0 === a2 ? 1 : a2; 7088 if (!t(n2) || !t(e2) || !t(u2)) return null; 7089 var i2 = g({ h: Number(n2), s: Number(e2), l: Number(u2), a: Number(o3) }); 7090 return f(i2); 7091 }, "hsl"], [function(r3) { 7092 var n2 = r3.h, a2 = r3.s, o3 = r3.v, i2 = r3.a, s2 = void 0 === i2 ? 1 : i2; 7093 if (!t(n2) || !t(a2) || !t(o3)) return null; 7094 var h2 = (function(r4) { 7095 return { h: u(r4.h), s: e(r4.s, 0, 100), v: e(r4.v, 0, 100), a: e(r4.a) }; 7096 })({ h: Number(n2), s: Number(a2), v: Number(o3), a: Number(s2) }); 7097 return b(h2); 7098 }, "hsv"]] }; 7099 var N = function(r3, t3) { 7100 for (var n2 = 0; n2 < t3.length; n2++) { 7101 var e2 = t3[n2][0](r3); 7102 if (e2) return [e2, t3[n2][1]]; 7103 } 7104 return [null, void 0]; 7105 }; 7106 var x = function(r3) { 7107 return "string" == typeof r3 ? N(r3.trim(), y.string) : "object" == typeof r3 && null !== r3 ? N(r3, y.object) : [null, void 0]; 7108 }; 7109 var M = function(r3, t3) { 7110 var n2 = c(r3); 7111 return { h: n2.h, s: e(n2.s + 100 * t3, 0, 100), l: n2.l, a: n2.a }; 7112 }; 7113 var H = function(r3) { 7114 return (299 * r3.r + 587 * r3.g + 114 * r3.b) / 1e3 / 255; 7115 }; 7116 var $ = function(r3, t3) { 7117 var n2 = c(r3); 7118 return { h: n2.h, s: n2.s, l: e(n2.l + 100 * t3, 0, 100), a: n2.a }; 7119 }; 7120 var j = (function() { 7121 function r3(r4) { 7122 this.parsed = x(r4)[0], this.rgba = this.parsed || { r: 0, g: 0, b: 0, a: 1 }; 7123 } 7124 return r3.prototype.isValid = function() { 7125 return null !== this.parsed; 7126 }, r3.prototype.brightness = function() { 7127 return n(H(this.rgba), 2); 7128 }, r3.prototype.isDark = function() { 7129 return H(this.rgba) < 0.5; 7130 }, r3.prototype.isLight = function() { 7131 return H(this.rgba) >= 0.5; 7132 }, r3.prototype.toHex = function() { 7133 return r4 = o(this.rgba), t3 = r4.r, e2 = r4.g, u2 = r4.b, i2 = (a2 = r4.a) < 1 ? s(n(255 * a2)) : "", "#" + s(t3) + s(e2) + s(u2) + i2; 7134 var r4, t3, e2, u2, a2, i2; 7135 }, r3.prototype.toRgb = function() { 7136 return o(this.rgba); 7137 }, r3.prototype.toRgbString = function() { 7138 return r4 = o(this.rgba), t3 = r4.r, n2 = r4.g, e2 = r4.b, (u2 = r4.a) < 1 ? "rgba(" + t3 + ", " + n2 + ", " + e2 + ", " + u2 + ")" : "rgb(" + t3 + ", " + n2 + ", " + e2 + ")"; 7139 var r4, t3, n2, e2, u2; 7140 }, r3.prototype.toHsl = function() { 7141 return d(c(this.rgba)); 7142 }, r3.prototype.toHslString = function() { 7143 return r4 = d(c(this.rgba)), t3 = r4.h, n2 = r4.s, e2 = r4.l, (u2 = r4.a) < 1 ? "hsla(" + t3 + ", " + n2 + "%, " + e2 + "%, " + u2 + ")" : "hsl(" + t3 + ", " + n2 + "%, " + e2 + "%)"; 7144 var r4, t3, n2, e2, u2; 7145 }, r3.prototype.toHsv = function() { 7146 return r4 = h(this.rgba), { h: n(r4.h), s: n(r4.s), v: n(r4.v), a: n(r4.a, 3) }; 7147 var r4; 7148 }, r3.prototype.invert = function() { 7149 return w({ r: 255 - (r4 = this.rgba).r, g: 255 - r4.g, b: 255 - r4.b, a: r4.a }); 7150 var r4; 7151 }, r3.prototype.saturate = function(r4) { 7152 return void 0 === r4 && (r4 = 0.1), w(M(this.rgba, r4)); 7153 }, r3.prototype.desaturate = function(r4) { 7154 return void 0 === r4 && (r4 = 0.1), w(M(this.rgba, -r4)); 7155 }, r3.prototype.grayscale = function() { 7156 return w(M(this.rgba, -1)); 7157 }, r3.prototype.lighten = function(r4) { 7158 return void 0 === r4 && (r4 = 0.1), w($(this.rgba, r4)); 7159 }, r3.prototype.darken = function(r4) { 7160 return void 0 === r4 && (r4 = 0.1), w($(this.rgba, -r4)); 7161 }, r3.prototype.rotate = function(r4) { 7162 return void 0 === r4 && (r4 = 15), this.hue(this.hue() + r4); 7163 }, r3.prototype.alpha = function(r4) { 7164 return "number" == typeof r4 ? w({ r: (t3 = this.rgba).r, g: t3.g, b: t3.b, a: r4 }) : n(this.rgba.a, 3); 7165 var t3; 7166 }, r3.prototype.hue = function(r4) { 7167 var t3 = c(this.rgba); 7168 return "number" == typeof r4 ? w({ h: r4, s: t3.s, l: t3.l, a: t3.a }) : n(t3.h); 7169 }, r3.prototype.isEqual = function(r4) { 7170 return this.toHex() === w(r4).toHex(); 7171 }, r3; 7172 })(); 7173 var w = function(r3) { 7174 return r3 instanceof j ? r3 : new j(r3); 7175 }; 7176 var S = []; 7177 var k = function(r3) { 7178 r3.forEach(function(r4) { 7179 S.indexOf(r4) < 0 && (r4(j, y), S.push(r4)); 7180 }); 7181 }; 7182 7183 // node_modules/colord/plugins/names.mjs 7184 function names_default(e2, f2) { 7185 var a2 = { white: "#ffffff", bisque: "#ffe4c4", blue: "#0000ff", cadetblue: "#5f9ea0", chartreuse: "#7fff00", chocolate: "#d2691e", coral: "#ff7f50", antiquewhite: "#faebd7", aqua: "#00ffff", azure: "#f0ffff", whitesmoke: "#f5f5f5", papayawhip: "#ffefd5", plum: "#dda0dd", blanchedalmond: "#ffebcd", black: "#000000", gold: "#ffd700", goldenrod: "#daa520", gainsboro: "#dcdcdc", cornsilk: "#fff8dc", cornflowerblue: "#6495ed", burlywood: "#deb887", aquamarine: "#7fffd4", beige: "#f5f5dc", crimson: "#dc143c", cyan: "#00ffff", darkblue: "#00008b", darkcyan: "#008b8b", darkgoldenrod: "#b8860b", darkkhaki: "#bdb76b", darkgray: "#a9a9a9", darkgreen: "#006400", darkgrey: "#a9a9a9", peachpuff: "#ffdab9", darkmagenta: "#8b008b", darkred: "#8b0000", darkorchid: "#9932cc", darkorange: "#ff8c00", darkslateblue: "#483d8b", gray: "#808080", darkslategray: "#2f4f4f", darkslategrey: "#2f4f4f", deeppink: "#ff1493", deepskyblue: "#00bfff", wheat: "#f5deb3", firebrick: "#b22222", floralwhite: "#fffaf0", ghostwhite: "#f8f8ff", darkviolet: "#9400d3", magenta: "#ff00ff", green: "#008000", dodgerblue: "#1e90ff", grey: "#808080", honeydew: "#f0fff0", hotpink: "#ff69b4", blueviolet: "#8a2be2", forestgreen: "#228b22", lawngreen: "#7cfc00", indianred: "#cd5c5c", indigo: "#4b0082", fuchsia: "#ff00ff", brown: "#a52a2a", maroon: "#800000", mediumblue: "#0000cd", lightcoral: "#f08080", darkturquoise: "#00ced1", lightcyan: "#e0ffff", ivory: "#fffff0", lightyellow: "#ffffe0", lightsalmon: "#ffa07a", lightseagreen: "#20b2aa", linen: "#faf0e6", mediumaquamarine: "#66cdaa", lemonchiffon: "#fffacd", lime: "#00ff00", khaki: "#f0e68c", mediumseagreen: "#3cb371", limegreen: "#32cd32", mediumspringgreen: "#00fa9a", lightskyblue: "#87cefa", lightblue: "#add8e6", midnightblue: "#191970", lightpink: "#ffb6c1", mistyrose: "#ffe4e1", moccasin: "#ffe4b5", mintcream: "#f5fffa", lightslategray: "#778899", lightslategrey: "#778899", navajowhite: "#ffdead", navy: "#000080", mediumvioletred: "#c71585", powderblue: "#b0e0e6", palegoldenrod: "#eee8aa", oldlace: "#fdf5e6", paleturquoise: "#afeeee", mediumturquoise: "#48d1cc", mediumorchid: "#ba55d3", rebeccapurple: "#663399", lightsteelblue: "#b0c4de", mediumslateblue: "#7b68ee", thistle: "#d8bfd8", tan: "#d2b48c", orchid: "#da70d6", mediumpurple: "#9370db", purple: "#800080", pink: "#ffc0cb", skyblue: "#87ceeb", springgreen: "#00ff7f", palegreen: "#98fb98", red: "#ff0000", yellow: "#ffff00", slateblue: "#6a5acd", lavenderblush: "#fff0f5", peru: "#cd853f", palevioletred: "#db7093", violet: "#ee82ee", teal: "#008080", slategray: "#708090", slategrey: "#708090", aliceblue: "#f0f8ff", darkseagreen: "#8fbc8f", darkolivegreen: "#556b2f", greenyellow: "#adff2f", seagreen: "#2e8b57", seashell: "#fff5ee", tomato: "#ff6347", silver: "#c0c0c0", sienna: "#a0522d", lavender: "#e6e6fa", lightgreen: "#90ee90", orange: "#ffa500", orangered: "#ff4500", steelblue: "#4682b4", royalblue: "#4169e1", turquoise: "#40e0d0", yellowgreen: "#9acd32", salmon: "#fa8072", saddlebrown: "#8b4513", sandybrown: "#f4a460", rosybrown: "#bc8f8f", darksalmon: "#e9967a", lightgoldenrodyellow: "#fafad2", snow: "#fffafa", lightgrey: "#d3d3d3", lightgray: "#d3d3d3", dimgray: "#696969", dimgrey: "#696969", olivedrab: "#6b8e23", olive: "#808000" }, r3 = {}; 7186 for (var d2 in a2) r3[a2[d2]] = d2; 7187 var l2 = {}; 7188 e2.prototype.toName = function(f3) { 7189 if (!(this.rgba.a || this.rgba.r || this.rgba.g || this.rgba.b)) return "transparent"; 7190 var d3, i2, n2 = r3[this.toHex()]; 7191 if (n2) return n2; 7192 if (null == f3 ? void 0 : f3.closest) { 7193 var o3 = this.toRgb(), t3 = 1 / 0, b2 = "black"; 7194 if (!l2.length) for (var c6 in a2) l2[c6] = new e2(a2[c6]).toRgb(); 7195 for (var g2 in a2) { 7196 var u2 = (d3 = o3, i2 = l2[g2], Math.pow(d3.r - i2.r, 2) + Math.pow(d3.g - i2.g, 2) + Math.pow(d3.b - i2.b, 2)); 7197 u2 < t3 && (t3 = u2, b2 = g2); 7198 } 7199 return b2; 7200 } 7201 }; 7202 f2.string.push([function(f3) { 7203 var r4 = f3.toLowerCase(), d3 = "transparent" === r4 ? "#0000" : a2[r4]; 7204 return d3 ? new e2(d3).toRgb() : null; 7205 }, "name"]); 7206 } 7207 7208 // node_modules/colord/plugins/a11y.mjs 7209 var o2 = function(o3) { 7210 var t3 = o3 / 255; 7211 return t3 < 0.04045 ? t3 / 12.92 : Math.pow((t3 + 0.055) / 1.055, 2.4); 7212 }; 7213 var t2 = function(t3) { 7214 return 0.2126 * o2(t3.r) + 0.7152 * o2(t3.g) + 0.0722 * o2(t3.b); 7215 }; 7216 function a11y_default(o3) { 7217 o3.prototype.luminance = function() { 7218 return o4 = t2(this.rgba), void 0 === (r3 = 2) && (r3 = 0), void 0 === n2 && (n2 = Math.pow(10, r3)), Math.round(n2 * o4) / n2 + 0; 7219 var o4, r3, n2; 7220 }, o3.prototype.contrast = function(r3) { 7221 void 0 === r3 && (r3 = "#FFF"); 7222 var n2, a2, i2, e2, v2, u2, d2, c6 = r3 instanceof o3 ? r3 : new o3(r3); 7223 return e2 = this.rgba, v2 = c6.toRgb(), u2 = t2(e2), d2 = t2(v2), n2 = u2 > d2 ? (u2 + 0.05) / (d2 + 0.05) : (d2 + 0.05) / (u2 + 0.05), void 0 === (a2 = 2) && (a2 = 0), void 0 === i2 && (i2 = Math.pow(10, a2)), Math.floor(i2 * n2) / i2 + 0; 7224 }, o3.prototype.isReadable = function(o4, t3) { 7225 return void 0 === o4 && (o4 = "#FFF"), void 0 === t3 && (t3 = {}), this.contrast(o4) >= (e2 = void 0 === (i2 = (r3 = t3).size) ? "normal" : i2, "AAA" === (a2 = void 0 === (n2 = r3.level) ? "AA" : n2) && "normal" === e2 ? 7 : "AA" === a2 && "large" === e2 ? 3 : 4.5); 7226 var r3, n2, a2, i2, e2; 7227 }; 7228 } 7229 7230 // packages/block-editor/build-module/components/colors/utils.js 7231 var import_components = __toESM(require_components()); 7232 7233 // packages/block-editor/build-module/lock-unlock.js 7234 var import_private_apis = __toESM(require_private_apis()); 7235 var { lock, unlock } = (0, import_private_apis.__dangerousOptInToUnstableAPIsOnlyForCoreModules)( 7236 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.", 7237 "@wordpress/block-editor" 7238 ); 7239 7240 // packages/block-editor/build-module/components/colors/utils.js 7241 k([names_default, a11y_default]); 7242 var { kebabCase } = unlock(import_components.privateApis); 7243 var getColorObjectByAttributeValues = (colors2, definedColor, customColor) => { 7244 if (definedColor) { 7245 const colorObj = colors2?.find( 7246 (color) => color.slug === definedColor 7247 ); 7248 if (colorObj) { 7249 return colorObj; 7250 } 7251 } 7252 return { 7253 color: customColor 7254 }; 7255 }; 7256 var getColorObjectByColorValue = (colors2, colorValue) => { 7257 return colors2?.find((color) => color.color === colorValue); 7258 }; 7259 function getColorClassName(colorContextName, colorSlug) { 7260 if (!colorContextName || !colorSlug) { 7261 return void 0; 7262 } 7263 return `has-$kebabCase(colorSlug)}-$colorContextName}`; 7264 } 7265 function getMostReadableColor(colors2, colorValue) { 7266 const colordColor = w(colorValue); 7267 const getColorContrast = ({ color }) => colordColor.contrast(color); 7268 const maxContrast = Math.max(...colors2.map(getColorContrast)); 7269 return colors2.find((color) => getColorContrast(color) === maxContrast).color; 7270 } 7271 7272 // packages/block-editor/build-module/components/colors/with-colors.js 7273 var import_element9 = __toESM(require_element()); 7274 var import_compose2 = __toESM(require_compose()); 7275 var import_components5 = __toESM(require_components()); 7276 7277 // packages/block-editor/build-module/components/use-settings/index.js 7278 var import_data7 = __toESM(require_data()); 7279 var import_deprecated5 = __toESM(require_deprecated()); 7280 7281 // packages/block-editor/build-module/components/block-edit/index.js 7282 var import_element8 = __toESM(require_element()); 7283 var import_blocks9 = __toESM(require_blocks()); 7284 7285 // node_modules/clsx/dist/clsx.mjs 7286 function r2(e2) { 7287 var t3, f2, n2 = ""; 7288 if ("string" == typeof e2 || "number" == typeof e2) n2 += e2; 7289 else if ("object" == typeof e2) if (Array.isArray(e2)) { 7290 var o3 = e2.length; 7291 for (t3 = 0; t3 < o3; t3++) e2[t3] && (f2 = r2(e2[t3])) && (n2 && (n2 += " "), n2 += f2); 7292 } else for (f2 in e2) e2[f2] && (n2 && (n2 += " "), n2 += f2); 7293 return n2; 7294 } 7295 function clsx() { 7296 for (var e2, t3, f2 = 0, n2 = "", o3 = arguments.length; f2 < o3; f2++) (e2 = arguments[f2]) && (t3 = r2(e2)) && (n2 && (n2 += " "), n2 += t3); 7297 return n2; 7298 } 7299 var clsx_default = clsx; 7300 7301 // packages/block-editor/build-module/components/block-edit/edit.js 7302 var import_blocks = __toESM(require_blocks()); 7303 var import_components2 = __toESM(require_components()); 7304 var import_data = __toESM(require_data()); 7305 var import_element4 = __toESM(require_element()); 7306 7307 // packages/block-editor/build-module/components/block-context/index.js 7308 var import_element2 = __toESM(require_element()); 7309 var import_jsx_runtime = __toESM(require_jsx_runtime()); 7310 var Context2 = (0, import_element2.createContext)({}); 7311 Context2.displayName = "BlockContext"; 7312 function BlockContextProvider({ value, children }) { 7313 const context = (0, import_element2.useContext)(Context2); 7314 const nextValue = (0, import_element2.useMemo)( 7315 () => ({ ...context, ...value }), 7316 [context, value] 7317 ); 7318 return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Context2.Provider, { value: nextValue, children }); 7319 } 7320 var block_context_default = Context2; 7321 7322 // packages/block-editor/build-module/components/link-control/is-url-like.js 7323 var import_url = __toESM(require_url()); 7324 function isURLLike(val) { 7325 const hasSpaces = val.includes(" "); 7326 if (hasSpaces) { 7327 return false; 7328 } 7329 const protocol = (0, import_url.getProtocol)(val); 7330 const protocolIsValid = (0, import_url.isValidProtocol)(protocol); 7331 const mayBeTLD = hasPossibleTLD(val); 7332 const isWWW = val?.startsWith("www."); 7333 const isInternal = val?.startsWith("#") && (0, import_url.isValidFragment)(val); 7334 return protocolIsValid || isWWW || isInternal || mayBeTLD; 7335 } 7336 function hasPossibleTLD(url, maxLength = 6) { 7337 const cleanedURL = url.split(/[?#]/)[0]; 7338 const regex = new RegExp( 7339 `(?<=\\S)\\.(?:[a-zA-Z_]{2,$maxLength}})(?:\\/|$)` 7340 ); 7341 return regex.test(cleanedURL); 7342 } 7343 7344 // packages/block-editor/build-module/utils/block-bindings.js 7345 var DEFAULT_ATTRIBUTE = "__default"; 7346 var PATTERN_OVERRIDES_SOURCE = "core/pattern-overrides"; 7347 function hasPatternOverridesDefaultBinding(bindings) { 7348 return bindings?.[DEFAULT_ATTRIBUTE]?.source === PATTERN_OVERRIDES_SOURCE; 7349 } 7350 function replacePatternOverridesDefaultBinding(bindings, supportedAttributes) { 7351 if (hasPatternOverridesDefaultBinding(bindings)) { 7352 const bindingsWithDefaults = {}; 7353 for (const attributeName of supportedAttributes) { 7354 const bindingSource = bindings[attributeName] ? bindings[attributeName] : { source: PATTERN_OVERRIDES_SOURCE }; 7355 bindingsWithDefaults[attributeName] = bindingSource; 7356 } 7357 return bindingsWithDefaults; 7358 } 7359 return bindings; 7360 } 7361 7362 // packages/block-editor/build-module/components/block-list/private-block-context.js 7363 var import_element3 = __toESM(require_element()); 7364 var PrivateBlockContext = (0, import_element3.createContext)({}); 7365 PrivateBlockContext.displayName = "PrivateBlockContext"; 7366 7367 // packages/block-editor/build-module/components/block-edit/edit.js 7368 var import_jsx_runtime2 = __toESM(require_jsx_runtime()); 7369 var DEFAULT_BLOCK_CONTEXT = {}; 7370 var Edit = (props) => { 7371 const { name } = props; 7372 const blockType = (0, import_blocks.getBlockType)(name); 7373 if (!blockType) { 7374 return null; 7375 } 7376 const Component7 = blockType.edit || blockType.save; 7377 return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Component7, { ...props }); 7378 }; 7379 var EditWithFilters = (0, import_components2.withFilters)("editor.BlockEdit")(Edit); 7380 var EditWithGeneratedProps = (props) => { 7381 const { name, clientId, attributes, setAttributes } = props; 7382 const registry = (0, import_data.useRegistry)(); 7383 const blockType = (0, import_blocks.getBlockType)(name); 7384 const blockContext = (0, import_element4.useContext)(block_context_default); 7385 const registeredSources = (0, import_data.useSelect)( 7386 (select3) => unlock(select3(import_blocks.store)).getAllBlockBindingsSources(), 7387 [] 7388 ); 7389 const { bindableAttributes } = (0, import_element4.useContext)(PrivateBlockContext); 7390 const { blockBindings, context, hasPatternOverrides } = (0, import_element4.useMemo)(() => { 7391 const computedContext = blockType?.usesContext ? Object.fromEntries( 7392 Object.entries(blockContext).filter( 7393 ([key]) => blockType.usesContext.includes(key) 7394 ) 7395 ) : DEFAULT_BLOCK_CONTEXT; 7396 if (attributes?.metadata?.bindings) { 7397 Object.values(attributes?.metadata?.bindings || {}).forEach( 7398 (binding) => { 7399 registeredSources[binding?.source]?.usesContext?.forEach( 7400 (key) => { 7401 computedContext[key] = blockContext[key]; 7402 } 7403 ); 7404 } 7405 ); 7406 } 7407 return { 7408 blockBindings: replacePatternOverridesDefaultBinding( 7409 attributes?.metadata?.bindings, 7410 bindableAttributes 7411 ), 7412 context: computedContext, 7413 hasPatternOverrides: hasPatternOverridesDefaultBinding( 7414 attributes?.metadata?.bindings 7415 ) 7416 }; 7417 }, [ 7418 blockType?.usesContext, 7419 blockContext, 7420 attributes?.metadata?.bindings, 7421 bindableAttributes, 7422 registeredSources 7423 ]); 7424 const computedAttributes = (0, import_data.useSelect)( 7425 (select3) => { 7426 if (!blockBindings) { 7427 return attributes; 7428 } 7429 const attributesFromSources = {}; 7430 const blockBindingsBySource = /* @__PURE__ */ new Map(); 7431 for (const [attributeName, binding] of Object.entries( 7432 blockBindings 7433 )) { 7434 const { source: sourceName, args: sourceArgs } = binding; 7435 const source = registeredSources[sourceName]; 7436 if (!source || !bindableAttributes?.includes(attributeName)) { 7437 continue; 7438 } 7439 blockBindingsBySource.set(source, { 7440 ...blockBindingsBySource.get(source), 7441 [attributeName]: { 7442 args: sourceArgs 7443 } 7444 }); 7445 } 7446 if (blockBindingsBySource.size) { 7447 for (const [source, bindings] of blockBindingsBySource) { 7448 let values = {}; 7449 if (!source.getValues) { 7450 Object.keys(bindings).forEach((attr) => { 7451 values[attr] = source.label; 7452 }); 7453 } else { 7454 values = source.getValues({ 7455 select: select3, 7456 context, 7457 clientId, 7458 bindings 7459 }); 7460 } 7461 for (const [attributeName, value] of Object.entries( 7462 values 7463 )) { 7464 if (attributeName === "url" && (!value || !isURLLike(value))) { 7465 attributesFromSources[attributeName] = null; 7466 } else { 7467 attributesFromSources[attributeName] = value; 7468 } 7469 } 7470 } 7471 } 7472 return { 7473 ...attributes, 7474 ...attributesFromSources 7475 }; 7476 }, 7477 [ 7478 attributes, 7479 bindableAttributes, 7480 blockBindings, 7481 clientId, 7482 context, 7483 registeredSources 7484 ] 7485 ); 7486 const setBoundAttributes = (0, import_element4.useCallback)( 7487 (nextAttributes) => { 7488 if (!blockBindings) { 7489 setAttributes(nextAttributes); 7490 return; 7491 } 7492 registry.batch(() => { 7493 const keptAttributes = { ...nextAttributes }; 7494 const blockBindingsBySource = /* @__PURE__ */ new Map(); 7495 for (const [attributeName, newValue] of Object.entries( 7496 keptAttributes 7497 )) { 7498 if (!blockBindings[attributeName] || !bindableAttributes?.includes(attributeName)) { 7499 continue; 7500 } 7501 const binding = blockBindings[attributeName]; 7502 const source = registeredSources[binding?.source]; 7503 if (!source?.setValues) { 7504 continue; 7505 } 7506 blockBindingsBySource.set(source, { 7507 ...blockBindingsBySource.get(source), 7508 [attributeName]: { 7509 args: binding.args, 7510 newValue 7511 } 7512 }); 7513 delete keptAttributes[attributeName]; 7514 } 7515 if (blockBindingsBySource.size) { 7516 for (const [ 7517 source, 7518 bindings 7519 ] of blockBindingsBySource) { 7520 source.setValues({ 7521 select: registry.select, 7522 dispatch: registry.dispatch, 7523 context, 7524 clientId, 7525 bindings 7526 }); 7527 } 7528 } 7529 const hasParentPattern = !!context["pattern/overrides"]; 7530 if ( 7531 // Don't update non-connected attributes if the block is using pattern overrides 7532 // and the editing is happening while overriding the pattern (not editing the original). 7533 !(hasPatternOverrides && hasParentPattern) && Object.keys(keptAttributes).length 7534 ) { 7535 if (hasPatternOverrides) { 7536 delete keptAttributes.href; 7537 } 7538 setAttributes(keptAttributes); 7539 } 7540 }); 7541 }, 7542 [ 7543 bindableAttributes, 7544 blockBindings, 7545 clientId, 7546 context, 7547 hasPatternOverrides, 7548 setAttributes, 7549 registeredSources, 7550 registry 7551 ] 7552 ); 7553 if (!blockType) { 7554 return null; 7555 } 7556 if (blockType.apiVersion > 1) { 7557 return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)( 7558 EditWithFilters, 7559 { 7560 ...props, 7561 attributes: computedAttributes, 7562 context, 7563 setAttributes: setBoundAttributes 7564 } 7565 ); 7566 } 7567 const generatedClassName = (0, import_blocks.hasBlockSupport)(blockType, "className", true) ? (0, import_blocks.getBlockDefaultClassName)(name) : null; 7568 const className = clsx_default( 7569 generatedClassName, 7570 attributes?.className, 7571 props.className 7572 ); 7573 return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)( 7574 EditWithFilters, 7575 { 7576 ...props, 7577 attributes: computedAttributes, 7578 className, 7579 context, 7580 setAttributes: setBoundAttributes 7581 } 7582 ); 7583 }; 7584 var edit_default = EditWithGeneratedProps; 7585 7586 // packages/block-editor/build-module/components/block-edit/multiple-usage-warning.js 7587 var import_blocks8 = __toESM(require_blocks()); 7588 var import_components4 = __toESM(require_components()); 7589 var import_data6 = __toESM(require_data()); 7590 var import_i18n6 = __toESM(require_i18n()); 7591 7592 // packages/block-editor/build-module/store/index.js 7593 var import_data5 = __toESM(require_data()); 7594 7595 // packages/block-editor/build-module/store/reducer.js 7596 var import_es6 = __toESM(require_es6()); 7597 var import_compose = __toESM(require_compose()); 7598 var import_data2 = __toESM(require_data()); 7599 var import_deprecated = __toESM(require_deprecated()); 7600 var import_blocks2 = __toESM(require_blocks()); 7601 7602 // packages/block-editor/build-module/store/defaults.js 7603 var import_i18n = __toESM(require_i18n()); 7604 var PREFERENCES_DEFAULTS = { 7605 insertUsage: {} 7606 }; 7607 var SETTINGS_DEFAULTS = { 7608 alignWide: false, 7609 supportsLayout: true, 7610 // colors setting is not used anymore now defaults are passed from theme.json on the server and core has its own defaults. 7611 // The setting is only kept for backward compatibility purposes. 7612 colors: [ 7613 { 7614 name: (0, import_i18n.__)("Black"), 7615 slug: "black", 7616 color: "#000000" 7617 }, 7618 { 7619 name: (0, import_i18n.__)("Cyan bluish gray"), 7620 slug: "cyan-bluish-gray", 7621 color: "#abb8c3" 7622 }, 7623 { 7624 name: (0, import_i18n.__)("White"), 7625 slug: "white", 7626 color: "#ffffff" 7627 }, 7628 { 7629 name: (0, import_i18n.__)("Pale pink"), 7630 slug: "pale-pink", 7631 color: "#f78da7" 7632 }, 7633 { name: (0, import_i18n.__)("Vivid red"), slug: "vivid-red", color: "#cf2e2e" }, 7634 { 7635 name: (0, import_i18n.__)("Luminous vivid orange"), 7636 slug: "luminous-vivid-orange", 7637 color: "#ff6900" 7638 }, 7639 { 7640 name: (0, import_i18n.__)("Luminous vivid amber"), 7641 slug: "luminous-vivid-amber", 7642 color: "#fcb900" 7643 }, 7644 { 7645 name: (0, import_i18n.__)("Light green cyan"), 7646 slug: "light-green-cyan", 7647 color: "#7bdcb5" 7648 }, 7649 { 7650 name: (0, import_i18n.__)("Vivid green cyan"), 7651 slug: "vivid-green-cyan", 7652 color: "#00d084" 7653 }, 7654 { 7655 name: (0, import_i18n.__)("Pale cyan blue"), 7656 slug: "pale-cyan-blue", 7657 color: "#8ed1fc" 7658 }, 7659 { 7660 name: (0, import_i18n.__)("Vivid cyan blue"), 7661 slug: "vivid-cyan-blue", 7662 color: "#0693e3" 7663 }, 7664 { 7665 name: (0, import_i18n.__)("Vivid purple"), 7666 slug: "vivid-purple", 7667 color: "#9b51e0" 7668 } 7669 ], 7670 // fontSizes setting is not used anymore now defaults are passed from theme.json on the server and core has its own defaults. 7671 // The setting is only kept for backward compatibility purposes. 7672 fontSizes: [ 7673 { 7674 name: (0, import_i18n._x)("Small", "font size name"), 7675 size: 13, 7676 slug: "small" 7677 }, 7678 { 7679 name: (0, import_i18n._x)("Normal", "font size name"), 7680 size: 16, 7681 slug: "normal" 7682 }, 7683 { 7684 name: (0, import_i18n._x)("Medium", "font size name"), 7685 size: 20, 7686 slug: "medium" 7687 }, 7688 { 7689 name: (0, import_i18n._x)("Large", "font size name"), 7690 size: 36, 7691 slug: "large" 7692 }, 7693 { 7694 name: (0, import_i18n._x)("Huge", "font size name"), 7695 size: 42, 7696 slug: "huge" 7697 } 7698 ], 7699 // Image default size slug. 7700 imageDefaultSize: "large", 7701 imageSizes: [ 7702 { slug: "thumbnail", name: (0, import_i18n.__)("Thumbnail") }, 7703 { slug: "medium", name: (0, import_i18n.__)("Medium") }, 7704 { slug: "large", name: (0, import_i18n.__)("Large") }, 7705 { slug: "full", name: (0, import_i18n.__)("Full Size") } 7706 ], 7707 // Allow plugin to disable Image Editor if need be. 7708 imageEditing: true, 7709 // This is current max width of the block inner area 7710 // It's used to constraint image resizing and this value could be overridden later by themes 7711 maxWidth: 580, 7712 // Allowed block types for the editor, defaulting to true (all supported). 7713 allowedBlockTypes: true, 7714 // Maximum upload size in bytes allowed for the site. 7715 maxUploadFileSize: 0, 7716 // List of allowed mime types and file extensions. 7717 allowedMimeTypes: null, 7718 // Allows to disable block locking interface. 7719 canLockBlocks: true, 7720 // Allows to disable Openverse media category in the inserter. 7721 enableOpenverseMediaCategory: true, 7722 clearBlockSelection: true, 7723 __experimentalCanUserUseUnfilteredHTML: false, 7724 __experimentalBlockDirectory: false, 7725 __mobileEnablePageTemplates: false, 7726 __experimentalBlockPatterns: [], 7727 __experimentalBlockPatternCategories: [], 7728 isPreviewMode: false, 7729 // These settings will be completely revamped in the future. 7730 // The goal is to evolve this into an API which will instruct 7731 // the block inspector to animate transitions between what it 7732 // displays based on the relationship between the selected block 7733 // and its parent, and only enable it if the parent is controlling 7734 // its children blocks. 7735 blockInspectorAnimation: { 7736 animationParent: "core/navigation", 7737 "core/navigation": { enterDirection: "leftToRight" }, 7738 "core/navigation-submenu": { enterDirection: "rightToLeft" }, 7739 "core/navigation-link": { enterDirection: "rightToLeft" }, 7740 "core/search": { enterDirection: "rightToLeft" }, 7741 "core/social-links": { enterDirection: "rightToLeft" }, 7742 "core/page-list": { enterDirection: "rightToLeft" }, 7743 "core/spacer": { enterDirection: "rightToLeft" }, 7744 "core/home-link": { enterDirection: "rightToLeft" }, 7745 "core/site-title": { enterDirection: "rightToLeft" }, 7746 "core/site-logo": { enterDirection: "rightToLeft" } 7747 }, 7748 generateAnchors: false, 7749 // gradients setting is not used anymore now defaults are passed from theme.json on the server and core has its own defaults. 7750 // The setting is only kept for backward compatibility purposes. 7751 gradients: [ 7752 { 7753 name: (0, import_i18n.__)("Vivid cyan blue to vivid purple"), 7754 gradient: "linear-gradient(135deg,rgba(6,147,227,1) 0%,rgb(155,81,224) 100%)", 7755 slug: "vivid-cyan-blue-to-vivid-purple" 7756 }, 7757 { 7758 name: (0, import_i18n.__)("Light green cyan to vivid green cyan"), 7759 gradient: "linear-gradient(135deg,rgb(122,220,180) 0%,rgb(0,208,130) 100%)", 7760 slug: "light-green-cyan-to-vivid-green-cyan" 7761 }, 7762 { 7763 name: (0, import_i18n.__)("Luminous vivid amber to luminous vivid orange"), 7764 gradient: "linear-gradient(135deg,rgba(252,185,0,1) 0%,rgba(255,105,0,1) 100%)", 7765 slug: "luminous-vivid-amber-to-luminous-vivid-orange" 7766 }, 7767 { 7768 name: (0, import_i18n.__)("Luminous vivid orange to vivid red"), 7769 gradient: "linear-gradient(135deg,rgba(255,105,0,1) 0%,rgb(207,46,46) 100%)", 7770 slug: "luminous-vivid-orange-to-vivid-red" 7771 }, 7772 { 7773 name: (0, import_i18n.__)("Very light gray to cyan bluish gray"), 7774 gradient: "linear-gradient(135deg,rgb(238,238,238) 0%,rgb(169,184,195) 100%)", 7775 slug: "very-light-gray-to-cyan-bluish-gray" 7776 }, 7777 { 7778 name: (0, import_i18n.__)("Cool to warm spectrum"), 7779 gradient: "linear-gradient(135deg,rgb(74,234,220) 0%,rgb(151,120,209) 20%,rgb(207,42,186) 40%,rgb(238,44,130) 60%,rgb(251,105,98) 80%,rgb(254,248,76) 100%)", 7780 slug: "cool-to-warm-spectrum" 7781 }, 7782 { 7783 name: (0, import_i18n.__)("Blush light purple"), 7784 gradient: "linear-gradient(135deg,rgb(255,206,236) 0%,rgb(152,150,240) 100%)", 7785 slug: "blush-light-purple" 7786 }, 7787 { 7788 name: (0, import_i18n.__)("Blush bordeaux"), 7789 gradient: "linear-gradient(135deg,rgb(254,205,165) 0%,rgb(254,45,45) 50%,rgb(107,0,62) 100%)", 7790 slug: "blush-bordeaux" 7791 }, 7792 { 7793 name: (0, import_i18n.__)("Luminous dusk"), 7794 gradient: "linear-gradient(135deg,rgb(255,203,112) 0%,rgb(199,81,192) 50%,rgb(65,88,208) 100%)", 7795 slug: "luminous-dusk" 7796 }, 7797 { 7798 name: (0, import_i18n.__)("Pale ocean"), 7799 gradient: "linear-gradient(135deg,rgb(255,245,203) 0%,rgb(182,227,212) 50%,rgb(51,167,181) 100%)", 7800 slug: "pale-ocean" 7801 }, 7802 { 7803 name: (0, import_i18n.__)("Electric grass"), 7804 gradient: "linear-gradient(135deg,rgb(202,248,128) 0%,rgb(113,206,126) 100%)", 7805 slug: "electric-grass" 7806 }, 7807 { 7808 name: (0, import_i18n.__)("Midnight"), 7809 gradient: "linear-gradient(135deg,rgb(2,3,129) 0%,rgb(40,116,252) 100%)", 7810 slug: "midnight" 7811 } 7812 ], 7813 __unstableResolvedAssets: { styles: [], scripts: [] } 7814 }; 7815 7816 // packages/block-editor/build-module/store/array.js 7817 function insertAt(array, elements, index) { 7818 return [ 7819 ...array.slice(0, index), 7820 ...Array.isArray(elements) ? elements : [elements], 7821 ...array.slice(index) 7822 ]; 7823 } 7824 function moveTo(array, from, to2, count = 1) { 7825 const withoutMovedElements = [...array]; 7826 withoutMovedElements.splice(from, count); 7827 return insertAt( 7828 withoutMovedElements, 7829 array.slice(from, from + count), 7830 to2 7831 ); 7832 } 7833 7834 // packages/block-editor/build-module/store/private-keys.js 7835 var globalStylesDataKey = Symbol("globalStylesDataKey"); 7836 var globalStylesLinksDataKey = Symbol("globalStylesLinks"); 7837 var selectBlockPatternsKey = Symbol("selectBlockPatternsKey"); 7838 var reusableBlocksSelectKey = Symbol("reusableBlocksSelect"); 7839 var sectionRootClientIdKey = Symbol("sectionRootClientIdKey"); 7840 var mediaEditKey = Symbol("mediaEditKey"); 7841 var getMediaSelectKey = Symbol("getMediaSelect"); 7842 var essentialFormatKey = Symbol("essentialFormat"); 7843 var isIsolatedEditorKey = Symbol("isIsolatedEditor"); 7844 7845 // packages/block-editor/build-module/store/reducer.js 7846 var { isContentBlock } = unlock(import_blocks2.privateApis); 7847 var identity = (x2) => x2; 7848 function mapBlockOrder(blocks2, rootClientId = "") { 7849 const result = /* @__PURE__ */ new Map(); 7850 const current = []; 7851 result.set(rootClientId, current); 7852 blocks2.forEach((block) => { 7853 const { clientId, innerBlocks } = block; 7854 current.push(clientId); 7855 mapBlockOrder(innerBlocks, clientId).forEach( 7856 (order, subClientId) => { 7857 result.set(subClientId, order); 7858 } 7859 ); 7860 }); 7861 return result; 7862 } 7863 function mapBlockParents(blocks2, rootClientId = "") { 7864 const result = []; 7865 const stack = [[rootClientId, blocks2]]; 7866 while (stack.length) { 7867 const [parent, currentBlocks] = stack.shift(); 7868 currentBlocks.forEach(({ innerBlocks, ...block }) => { 7869 result.push([block.clientId, parent]); 7870 if (innerBlocks?.length) { 7871 stack.push([block.clientId, innerBlocks]); 7872 } 7873 }); 7874 } 7875 return result; 7876 } 7877 function flattenBlocks(blocks2, transform = identity) { 7878 const result = []; 7879 const stack = [...blocks2]; 7880 while (stack.length) { 7881 const { innerBlocks, ...block } = stack.shift(); 7882 stack.push(...innerBlocks); 7883 result.push([block.clientId, transform(block)]); 7884 } 7885 return result; 7886 } 7887 function getFlattenedClientIds(blocks2) { 7888 const result = {}; 7889 const stack = [...blocks2]; 7890 while (stack.length) { 7891 const { innerBlocks, ...block } = stack.shift(); 7892 stack.push(...innerBlocks); 7893 result[block.clientId] = true; 7894 } 7895 return result; 7896 } 7897 function getFlattenedBlocksWithoutAttributes(blocks2) { 7898 return flattenBlocks(blocks2, (block) => { 7899 const { attributes, ...restBlock } = block; 7900 return restBlock; 7901 }); 7902 } 7903 function getFlattenedBlockAttributes(blocks2) { 7904 return flattenBlocks(blocks2, (block) => block.attributes); 7905 } 7906 function hasSameKeys(a2, b2) { 7907 return (0, import_es6.default)(Object.keys(a2), Object.keys(b2)); 7908 } 7909 function isUpdatingSameBlockAttribute(action, lastAction) { 7910 return action.type === "UPDATE_BLOCK_ATTRIBUTES" && lastAction !== void 0 && lastAction.type === "UPDATE_BLOCK_ATTRIBUTES" && (0, import_es6.default)(action.clientIds, lastAction.clientIds) && hasSameKeys(action.attributes, lastAction.attributes); 7911 } 7912 function updateBlockTreeForBlocks(state, blocks2) { 7913 const treeToUpdate = state.tree; 7914 const stack = [...blocks2]; 7915 const flattenedBlocks = [...blocks2]; 7916 while (stack.length) { 7917 const block = stack.shift(); 7918 stack.push(...block.innerBlocks); 7919 flattenedBlocks.push(...block.innerBlocks); 7920 } 7921 for (const block of flattenedBlocks) { 7922 treeToUpdate.set(block.clientId, {}); 7923 } 7924 for (const block of flattenedBlocks) { 7925 treeToUpdate.set( 7926 block.clientId, 7927 Object.assign(treeToUpdate.get(block.clientId), { 7928 ...state.byClientId.get(block.clientId), 7929 attributes: state.attributes.get(block.clientId), 7930 innerBlocks: block.innerBlocks.map( 7931 (subBlock) => treeToUpdate.get(subBlock.clientId) 7932 ) 7933 }) 7934 ); 7935 } 7936 } 7937 function updateParentInnerBlocksInTree(state, updatedClientIds, updateChildrenOfUpdatedClientIds = false) { 7938 const treeToUpdate = state.tree; 7939 const uncontrolledParents = /* @__PURE__ */ new Set([]); 7940 const controlledParents = /* @__PURE__ */ new Set(); 7941 for (const clientId of updatedClientIds) { 7942 let current = updateChildrenOfUpdatedClientIds ? clientId : state.parents.get(clientId); 7943 do { 7944 if (state.controlledInnerBlocks[current]) { 7945 controlledParents.add(current); 7946 break; 7947 } else { 7948 uncontrolledParents.add(current); 7949 current = state.parents.get(current); 7950 } 7951 } while (current !== void 0); 7952 } 7953 for (const clientId of uncontrolledParents) { 7954 treeToUpdate.set(clientId, { ...treeToUpdate.get(clientId) }); 7955 } 7956 for (const clientId of uncontrolledParents) { 7957 treeToUpdate.get(clientId).innerBlocks = (state.order.get(clientId) || []).map((subClientId) => treeToUpdate.get(subClientId)); 7958 } 7959 for (const clientId of controlledParents) { 7960 treeToUpdate.set("controlled||" + clientId, { 7961 innerBlocks: (state.order.get(clientId) || []).map( 7962 (subClientId) => treeToUpdate.get(subClientId) 7963 ) 7964 }); 7965 } 7966 } 7967 var withBlockTree = (reducer4) => (state = {}, action) => { 7968 const newState = reducer4(state, action); 7969 if (newState === state) { 7970 return state; 7971 } 7972 newState.tree = state.tree ? state.tree : /* @__PURE__ */ new Map(); 7973 switch (action.type) { 7974 case "RECEIVE_BLOCKS": 7975 case "INSERT_BLOCKS": { 7976 newState.tree = new Map(newState.tree); 7977 updateBlockTreeForBlocks(newState, action.blocks); 7978 updateParentInnerBlocksInTree( 7979 newState, 7980 action.rootClientId ? [action.rootClientId] : [""], 7981 true 7982 ); 7983 break; 7984 } 7985 case "UPDATE_BLOCK": 7986 newState.tree = new Map(newState.tree); 7987 newState.tree.set(action.clientId, { 7988 ...newState.tree.get(action.clientId), 7989 ...newState.byClientId.get(action.clientId), 7990 attributes: newState.attributes.get(action.clientId) 7991 }); 7992 updateParentInnerBlocksInTree( 7993 newState, 7994 [action.clientId], 7995 false 7996 ); 7997 break; 7998 case "SYNC_DERIVED_BLOCK_ATTRIBUTES": 7999 case "UPDATE_BLOCK_ATTRIBUTES": { 8000 newState.tree = new Map(newState.tree); 8001 action.clientIds.forEach((clientId) => { 8002 newState.tree.set(clientId, { 8003 ...newState.tree.get(clientId), 8004 attributes: newState.attributes.get(clientId) 8005 }); 8006 }); 8007 updateParentInnerBlocksInTree( 8008 newState, 8009 action.clientIds, 8010 false 8011 ); 8012 break; 8013 } 8014 case "REPLACE_BLOCKS_AUGMENTED_WITH_CHILDREN": { 8015 const inserterClientIds = getFlattenedClientIds( 8016 action.blocks 8017 ); 8018 newState.tree = new Map(newState.tree); 8019 action.replacedClientIds.forEach((clientId) => { 8020 newState.tree.delete(clientId); 8021 if (!inserterClientIds[clientId]) { 8022 newState.tree.delete("controlled||" + clientId); 8023 } 8024 }); 8025 updateBlockTreeForBlocks(newState, action.blocks); 8026 updateParentInnerBlocksInTree( 8027 newState, 8028 action.blocks.map((b2) => b2.clientId), 8029 false 8030 ); 8031 const parentsOfRemovedBlocks2 = []; 8032 for (const clientId of action.clientIds) { 8033 const parentId = state.parents.get(clientId); 8034 if (parentId !== void 0 && (parentId === "" || newState.byClientId.get(parentId))) { 8035 parentsOfRemovedBlocks2.push(parentId); 8036 } 8037 } 8038 updateParentInnerBlocksInTree( 8039 newState, 8040 parentsOfRemovedBlocks2, 8041 true 8042 ); 8043 break; 8044 } 8045 case "REMOVE_BLOCKS_AUGMENTED_WITH_CHILDREN": 8046 const parentsOfRemovedBlocks = []; 8047 for (const clientId of action.clientIds) { 8048 const parentId = state.parents.get(clientId); 8049 if (parentId !== void 0 && (parentId === "" || newState.byClientId.get(parentId))) { 8050 parentsOfRemovedBlocks.push(parentId); 8051 } 8052 } 8053 newState.tree = new Map(newState.tree); 8054 action.removedClientIds.forEach((clientId) => { 8055 newState.tree.delete(clientId); 8056 newState.tree.delete("controlled||" + clientId); 8057 }); 8058 updateParentInnerBlocksInTree( 8059 newState, 8060 parentsOfRemovedBlocks, 8061 true 8062 ); 8063 break; 8064 case "MOVE_BLOCKS_TO_POSITION": { 8065 const updatedBlockUids = []; 8066 if (action.fromRootClientId) { 8067 updatedBlockUids.push(action.fromRootClientId); 8068 } else { 8069 updatedBlockUids.push(""); 8070 } 8071 if (action.toRootClientId) { 8072 updatedBlockUids.push(action.toRootClientId); 8073 } 8074 newState.tree = new Map(newState.tree); 8075 updateParentInnerBlocksInTree( 8076 newState, 8077 updatedBlockUids, 8078 true 8079 ); 8080 break; 8081 } 8082 case "MOVE_BLOCKS_UP": 8083 case "MOVE_BLOCKS_DOWN": { 8084 const updatedBlockUids = [ 8085 action.rootClientId ? action.rootClientId : "" 8086 ]; 8087 newState.tree = new Map(newState.tree); 8088 updateParentInnerBlocksInTree( 8089 newState, 8090 updatedBlockUids, 8091 true 8092 ); 8093 break; 8094 } 8095 case "SAVE_REUSABLE_BLOCK_SUCCESS": { 8096 const updatedBlockUids = []; 8097 newState.attributes.forEach((attributes, clientId) => { 8098 if (newState.byClientId.get(clientId).name === "core/block" && attributes.ref === action.updatedId) { 8099 updatedBlockUids.push(clientId); 8100 } 8101 }); 8102 newState.tree = new Map(newState.tree); 8103 updatedBlockUids.forEach((clientId) => { 8104 newState.tree.set(clientId, { 8105 ...newState.byClientId.get(clientId), 8106 attributes: newState.attributes.get(clientId), 8107 innerBlocks: newState.tree.get(clientId).innerBlocks 8108 }); 8109 }); 8110 updateParentInnerBlocksInTree( 8111 newState, 8112 updatedBlockUids, 8113 false 8114 ); 8115 } 8116 } 8117 return newState; 8118 }; 8119 function withPersistentBlockChange(reducer4) { 8120 let lastAction; 8121 let markNextChangeAsNotPersistent = false; 8122 let explicitPersistent; 8123 return (state, action) => { 8124 let nextState = reducer4(state, action); 8125 let nextIsPersistentChange; 8126 if (action.type === "SET_EXPLICIT_PERSISTENT") { 8127 explicitPersistent = action.isPersistentChange; 8128 nextIsPersistentChange = state.isPersistentChange ?? true; 8129 } 8130 if (explicitPersistent !== void 0) { 8131 nextIsPersistentChange = explicitPersistent; 8132 return nextIsPersistentChange === nextState.isPersistentChange ? nextState : { 8133 ...nextState, 8134 isPersistentChange: nextIsPersistentChange 8135 }; 8136 } 8137 const isExplicitPersistentChange = action.type === "MARK_LAST_CHANGE_AS_PERSISTENT" || markNextChangeAsNotPersistent; 8138 if (state === nextState && !isExplicitPersistentChange) { 8139 markNextChangeAsNotPersistent = action.type === "MARK_NEXT_CHANGE_AS_NOT_PERSISTENT"; 8140 nextIsPersistentChange = state?.isPersistentChange ?? true; 8141 if (state.isPersistentChange === nextIsPersistentChange) { 8142 return state; 8143 } 8144 return { 8145 ...nextState, 8146 isPersistentChange: nextIsPersistentChange 8147 }; 8148 } 8149 nextState = { 8150 ...nextState, 8151 isPersistentChange: isExplicitPersistentChange ? !markNextChangeAsNotPersistent : !isUpdatingSameBlockAttribute(action, lastAction) 8152 }; 8153 lastAction = action; 8154 markNextChangeAsNotPersistent = action.type === "MARK_NEXT_CHANGE_AS_NOT_PERSISTENT"; 8155 return nextState; 8156 }; 8157 } 8158 function withIgnoredBlockChange(reducer4) { 8159 const IGNORED_ACTION_TYPES = /* @__PURE__ */ new Set(["RECEIVE_BLOCKS"]); 8160 return (state, action) => { 8161 const nextState = reducer4(state, action); 8162 if (nextState !== state) { 8163 nextState.isIgnoredChange = IGNORED_ACTION_TYPES.has(action.type); 8164 } 8165 return nextState; 8166 }; 8167 } 8168 var withInnerBlocksRemoveCascade = (reducer4) => (state, action) => { 8169 const getAllChildren = (clientIds) => { 8170 let result = clientIds; 8171 for (let i2 = 0; i2 < result.length; i2++) { 8172 if (!state.order.get(result[i2]) || action.keepControlledInnerBlocks && action.keepControlledInnerBlocks[result[i2]]) { 8173 continue; 8174 } 8175 if (result === clientIds) { 8176 result = [...result]; 8177 } 8178 result.push(...state.order.get(result[i2])); 8179 } 8180 return result; 8181 }; 8182 if (state) { 8183 switch (action.type) { 8184 case "REMOVE_BLOCKS": 8185 action = { 8186 ...action, 8187 type: "REMOVE_BLOCKS_AUGMENTED_WITH_CHILDREN", 8188 removedClientIds: getAllChildren(action.clientIds) 8189 }; 8190 break; 8191 case "REPLACE_BLOCKS": 8192 action = { 8193 ...action, 8194 type: "REPLACE_BLOCKS_AUGMENTED_WITH_CHILDREN", 8195 replacedClientIds: getAllChildren(action.clientIds) 8196 }; 8197 break; 8198 } 8199 } 8200 return reducer4(state, action); 8201 }; 8202 var withBlockReset = (reducer4) => (state, action) => { 8203 if (action.type === "RESET_BLOCKS") { 8204 const newState = { 8205 ...state, 8206 byClientId: new Map( 8207 getFlattenedBlocksWithoutAttributes(action.blocks) 8208 ), 8209 attributes: new Map(getFlattenedBlockAttributes(action.blocks)), 8210 order: mapBlockOrder(action.blocks), 8211 parents: new Map(mapBlockParents(action.blocks)), 8212 controlledInnerBlocks: {} 8213 }; 8214 newState.tree = new Map(state?.tree); 8215 updateBlockTreeForBlocks(newState, action.blocks); 8216 newState.tree.set("", { 8217 innerBlocks: action.blocks.map( 8218 (subBlock) => newState.tree.get(subBlock.clientId) 8219 ) 8220 }); 8221 return newState; 8222 } 8223 return reducer4(state, action); 8224 }; 8225 var withReplaceInnerBlocks = (reducer4) => (state, action) => { 8226 if (action.type !== "REPLACE_INNER_BLOCKS") { 8227 return reducer4(state, action); 8228 } 8229 const nestedControllers = {}; 8230 if (Object.keys(state.controlledInnerBlocks).length) { 8231 const stack = [...action.blocks]; 8232 while (stack.length) { 8233 const { innerBlocks, ...block } = stack.shift(); 8234 stack.push(...innerBlocks); 8235 if (!!state.controlledInnerBlocks[block.clientId]) { 8236 nestedControllers[block.clientId] = true; 8237 } 8238 } 8239 } 8240 let stateAfterBlocksRemoval = state; 8241 if (state.order.get(action.rootClientId)) { 8242 stateAfterBlocksRemoval = reducer4(stateAfterBlocksRemoval, { 8243 type: "REMOVE_BLOCKS", 8244 keepControlledInnerBlocks: nestedControllers, 8245 clientIds: state.order.get(action.rootClientId) 8246 }); 8247 } 8248 let stateAfterInsert = stateAfterBlocksRemoval; 8249 if (action.blocks.length) { 8250 stateAfterInsert = reducer4(stateAfterInsert, { 8251 ...action, 8252 type: "INSERT_BLOCKS", 8253 index: 0 8254 }); 8255 const stateAfterInsertOrder = new Map(stateAfterInsert.order); 8256 Object.keys(nestedControllers).forEach((key) => { 8257 if (state.order.get(key)) { 8258 stateAfterInsertOrder.set(key, state.order.get(key)); 8259 } 8260 }); 8261 stateAfterInsert.order = stateAfterInsertOrder; 8262 stateAfterInsert.tree = new Map(stateAfterInsert.tree); 8263 Object.keys(nestedControllers).forEach((_key) => { 8264 const key = `controlled||$_key}`; 8265 if (state.tree.has(key)) { 8266 stateAfterInsert.tree.set(key, state.tree.get(key)); 8267 } 8268 }); 8269 } 8270 return stateAfterInsert; 8271 }; 8272 var withSaveReusableBlock = (reducer4) => (state, action) => { 8273 if (state && action.type === "SAVE_REUSABLE_BLOCK_SUCCESS") { 8274 const { id, updatedId } = action; 8275 if (id === updatedId) { 8276 return state; 8277 } 8278 state = { ...state }; 8279 state.attributes = new Map(state.attributes); 8280 state.attributes.forEach((attributes, clientId) => { 8281 const { name } = state.byClientId.get(clientId); 8282 if (name === "core/block" && attributes.ref === id) { 8283 state.attributes.set(clientId, { 8284 ...attributes, 8285 ref: updatedId 8286 }); 8287 } 8288 }); 8289 } 8290 return reducer4(state, action); 8291 }; 8292 var withResetControlledBlocks = (reducer4) => (state, action) => { 8293 if (action.type === "SET_HAS_CONTROLLED_INNER_BLOCKS") { 8294 const tempState = reducer4(state, { 8295 type: "REPLACE_INNER_BLOCKS", 8296 rootClientId: action.clientId, 8297 blocks: [] 8298 }); 8299 return reducer4(tempState, action); 8300 } 8301 return reducer4(state, action); 8302 }; 8303 var blocks = (0, import_compose.pipe)( 8304 import_data2.combineReducers, 8305 withSaveReusableBlock, 8306 // Needs to be before withBlockCache. 8307 withBlockTree, 8308 // Needs to be before withInnerBlocksRemoveCascade. 8309 withInnerBlocksRemoveCascade, 8310 withReplaceInnerBlocks, 8311 // Needs to be after withInnerBlocksRemoveCascade. 8312 withBlockReset, 8313 withPersistentBlockChange, 8314 withIgnoredBlockChange, 8315 withResetControlledBlocks 8316 )({ 8317 // The state is using a Map instead of a plain object for performance reasons. 8318 // You can run the "./test/performance.js" unit test to check the impact 8319 // code changes can have on this reducer. 8320 byClientId(state = /* @__PURE__ */ new Map(), action) { 8321 switch (action.type) { 8322 case "RECEIVE_BLOCKS": 8323 case "INSERT_BLOCKS": { 8324 const newState = new Map(state); 8325 getFlattenedBlocksWithoutAttributes(action.blocks).forEach( 8326 ([key, value]) => { 8327 newState.set(key, value); 8328 } 8329 ); 8330 return newState; 8331 } 8332 case "UPDATE_BLOCK": { 8333 if (!state.has(action.clientId)) { 8334 return state; 8335 } 8336 const { attributes, ...changes } = action.updates; 8337 if (Object.values(changes).length === 0) { 8338 return state; 8339 } 8340 const newState = new Map(state); 8341 newState.set(action.clientId, { 8342 ...state.get(action.clientId), 8343 ...changes 8344 }); 8345 return newState; 8346 } 8347 case "REPLACE_BLOCKS_AUGMENTED_WITH_CHILDREN": { 8348 if (!action.blocks) { 8349 return state; 8350 } 8351 const newState = new Map(state); 8352 action.replacedClientIds.forEach((clientId) => { 8353 newState.delete(clientId); 8354 }); 8355 getFlattenedBlocksWithoutAttributes(action.blocks).forEach( 8356 ([key, value]) => { 8357 newState.set(key, value); 8358 } 8359 ); 8360 return newState; 8361 } 8362 case "REMOVE_BLOCKS_AUGMENTED_WITH_CHILDREN": { 8363 const newState = new Map(state); 8364 action.removedClientIds.forEach((clientId) => { 8365 newState.delete(clientId); 8366 }); 8367 return newState; 8368 } 8369 } 8370 return state; 8371 }, 8372 // The state is using a Map instead of a plain object for performance reasons. 8373 // You can run the "./test/performance.js" unit test to check the impact 8374 // code changes can have on this reducer. 8375 attributes(state = /* @__PURE__ */ new Map(), action) { 8376 switch (action.type) { 8377 case "RECEIVE_BLOCKS": 8378 case "INSERT_BLOCKS": { 8379 const newState = new Map(state); 8380 getFlattenedBlockAttributes(action.blocks).forEach( 8381 ([key, value]) => { 8382 newState.set(key, value); 8383 } 8384 ); 8385 return newState; 8386 } 8387 case "UPDATE_BLOCK": { 8388 if (!state.get(action.clientId) || !action.updates.attributes) { 8389 return state; 8390 } 8391 const newState = new Map(state); 8392 newState.set(action.clientId, { 8393 ...state.get(action.clientId), 8394 ...action.updates.attributes 8395 }); 8396 return newState; 8397 } 8398 case "SYNC_DERIVED_BLOCK_ATTRIBUTES": 8399 case "UPDATE_BLOCK_ATTRIBUTES": { 8400 if (action.clientIds.every((id) => !state.get(id))) { 8401 return state; 8402 } 8403 let hasChange = false; 8404 const newState = new Map(state); 8405 for (const clientId of action.clientIds) { 8406 const updatedAttributeEntries = Object.entries( 8407 !!action.options?.uniqueByBlock ? action.attributes[clientId] : action.attributes ?? {} 8408 ); 8409 if (updatedAttributeEntries.length === 0) { 8410 continue; 8411 } 8412 let hasUpdatedAttributes = false; 8413 const existingAttributes = state.get(clientId); 8414 const newAttributes = {}; 8415 updatedAttributeEntries.forEach(([key, value]) => { 8416 if (existingAttributes[key] !== value) { 8417 hasUpdatedAttributes = true; 8418 newAttributes[key] = value; 8419 } 8420 }); 8421 hasChange = hasChange || hasUpdatedAttributes; 8422 if (hasUpdatedAttributes) { 8423 newState.set(clientId, { 8424 ...existingAttributes, 8425 ...newAttributes 8426 }); 8427 } 8428 } 8429 return hasChange ? newState : state; 8430 } 8431 case "REPLACE_BLOCKS_AUGMENTED_WITH_CHILDREN": { 8432 if (!action.blocks) { 8433 return state; 8434 } 8435 const newState = new Map(state); 8436 action.replacedClientIds.forEach((clientId) => { 8437 newState.delete(clientId); 8438 }); 8439 getFlattenedBlockAttributes(action.blocks).forEach( 8440 ([key, value]) => { 8441 newState.set(key, value); 8442 } 8443 ); 8444 return newState; 8445 } 8446 case "REMOVE_BLOCKS_AUGMENTED_WITH_CHILDREN": { 8447 const newState = new Map(state); 8448 action.removedClientIds.forEach((clientId) => { 8449 newState.delete(clientId); 8450 }); 8451 return newState; 8452 } 8453 } 8454 return state; 8455 }, 8456 // The state is using a Map instead of a plain object for performance reasons. 8457 // You can run the "./test/performance.js" unit test to check the impact 8458 // code changes can have on this reducer. 8459 order(state = /* @__PURE__ */ new Map(), action) { 8460 switch (action.type) { 8461 case "RECEIVE_BLOCKS": { 8462 const blockOrder = mapBlockOrder(action.blocks); 8463 const newState = new Map(state); 8464 blockOrder.forEach((order, clientId) => { 8465 if (clientId !== "") { 8466 newState.set(clientId, order); 8467 } 8468 }); 8469 newState.set( 8470 "", 8471 (state.get("") ?? []).concat(blockOrder[""]) 8472 ); 8473 return newState; 8474 } 8475 case "INSERT_BLOCKS": { 8476 const { rootClientId = "" } = action; 8477 const subState = state.get(rootClientId) || []; 8478 const mappedBlocks = mapBlockOrder( 8479 action.blocks, 8480 rootClientId 8481 ); 8482 const { index = subState.length } = action; 8483 const newState = new Map(state); 8484 mappedBlocks.forEach((order, clientId) => { 8485 newState.set(clientId, order); 8486 }); 8487 newState.set( 8488 rootClientId, 8489 insertAt( 8490 subState, 8491 mappedBlocks.get(rootClientId), 8492 index 8493 ) 8494 ); 8495 return newState; 8496 } 8497 case "MOVE_BLOCKS_TO_POSITION": { 8498 const { 8499 fromRootClientId = "", 8500 toRootClientId = "", 8501 clientIds 8502 } = action; 8503 const { index = state.get(toRootClientId).length } = action; 8504 if (fromRootClientId === toRootClientId) { 8505 const subState = state.get(toRootClientId); 8506 const fromIndex = subState.indexOf(clientIds[0]); 8507 const newState2 = new Map(state); 8508 newState2.set( 8509 toRootClientId, 8510 moveTo( 8511 state.get(toRootClientId), 8512 fromIndex, 8513 index, 8514 clientIds.length 8515 ) 8516 ); 8517 return newState2; 8518 } 8519 const newState = new Map(state); 8520 newState.set( 8521 fromRootClientId, 8522 state.get(fromRootClientId)?.filter((id) => !clientIds.includes(id)) ?? [] 8523 ); 8524 newState.set( 8525 toRootClientId, 8526 insertAt(state.get(toRootClientId), clientIds, index) 8527 ); 8528 return newState; 8529 } 8530 case "MOVE_BLOCKS_UP": { 8531 const { clientIds, rootClientId = "" } = action; 8532 const firstClientId = clientIds[0]; 8533 const subState = state.get(rootClientId); 8534 if (!subState.length || firstClientId === subState[0]) { 8535 return state; 8536 } 8537 const firstIndex = subState.indexOf(firstClientId); 8538 const newState = new Map(state); 8539 newState.set( 8540 rootClientId, 8541 moveTo( 8542 subState, 8543 firstIndex, 8544 firstIndex - 1, 8545 clientIds.length 8546 ) 8547 ); 8548 return newState; 8549 } 8550 case "MOVE_BLOCKS_DOWN": { 8551 const { clientIds, rootClientId = "" } = action; 8552 const firstClientId = clientIds[0]; 8553 const lastClientId = clientIds[clientIds.length - 1]; 8554 const subState = state.get(rootClientId); 8555 if (!subState.length || lastClientId === subState[subState.length - 1]) { 8556 return state; 8557 } 8558 const firstIndex = subState.indexOf(firstClientId); 8559 const newState = new Map(state); 8560 newState.set( 8561 rootClientId, 8562 moveTo( 8563 subState, 8564 firstIndex, 8565 firstIndex + 1, 8566 clientIds.length 8567 ) 8568 ); 8569 return newState; 8570 } 8571 case "REPLACE_BLOCKS_AUGMENTED_WITH_CHILDREN": { 8572 const { clientIds } = action; 8573 if (!action.blocks) { 8574 return state; 8575 } 8576 const mappedBlocks = mapBlockOrder(action.blocks); 8577 const newState = new Map(state); 8578 action.replacedClientIds.forEach((clientId) => { 8579 newState.delete(clientId); 8580 }); 8581 mappedBlocks.forEach((order, clientId) => { 8582 if (clientId !== "") { 8583 newState.set(clientId, order); 8584 } 8585 }); 8586 newState.forEach((order, clientId) => { 8587 const newSubOrder = Object.values(order).reduce( 8588 (result, subClientId) => { 8589 if (subClientId === clientIds[0]) { 8590 return [...result, ...mappedBlocks.get("")]; 8591 } 8592 if (clientIds.indexOf(subClientId) === -1) { 8593 result.push(subClientId); 8594 } 8595 return result; 8596 }, 8597 [] 8598 ); 8599 newState.set(clientId, newSubOrder); 8600 }); 8601 return newState; 8602 } 8603 case "REMOVE_BLOCKS_AUGMENTED_WITH_CHILDREN": { 8604 const newState = new Map(state); 8605 action.removedClientIds.forEach((clientId) => { 8606 newState.delete(clientId); 8607 }); 8608 newState.forEach((order, clientId) => { 8609 const newSubOrder = order?.filter( 8610 (id) => !action.removedClientIds.includes(id) 8611 ) ?? []; 8612 if (newSubOrder.length !== order.length) { 8613 newState.set(clientId, newSubOrder); 8614 } 8615 }); 8616 return newState; 8617 } 8618 } 8619 return state; 8620 }, 8621 // While technically redundant data as the inverse of `order`, it serves as 8622 // an optimization for the selectors which derive the ancestry of a block. 8623 parents(state = /* @__PURE__ */ new Map(), action) { 8624 switch (action.type) { 8625 case "RECEIVE_BLOCKS": { 8626 const newState = new Map(state); 8627 mapBlockParents(action.blocks).forEach( 8628 ([key, value]) => { 8629 newState.set(key, value); 8630 } 8631 ); 8632 return newState; 8633 } 8634 case "INSERT_BLOCKS": { 8635 const newState = new Map(state); 8636 mapBlockParents( 8637 action.blocks, 8638 action.rootClientId || "" 8639 ).forEach(([key, value]) => { 8640 newState.set(key, value); 8641 }); 8642 return newState; 8643 } 8644 case "MOVE_BLOCKS_TO_POSITION": { 8645 const newState = new Map(state); 8646 action.clientIds.forEach((id) => { 8647 newState.set(id, action.toRootClientId || ""); 8648 }); 8649 return newState; 8650 } 8651 case "REPLACE_BLOCKS_AUGMENTED_WITH_CHILDREN": { 8652 const newState = new Map(state); 8653 action.replacedClientIds.forEach((clientId) => { 8654 newState.delete(clientId); 8655 }); 8656 mapBlockParents( 8657 action.blocks, 8658 state.get(action.clientIds[0]) 8659 ).forEach(([key, value]) => { 8660 newState.set(key, value); 8661 }); 8662 return newState; 8663 } 8664 case "REMOVE_BLOCKS_AUGMENTED_WITH_CHILDREN": { 8665 const newState = new Map(state); 8666 action.removedClientIds.forEach((clientId) => { 8667 newState.delete(clientId); 8668 }); 8669 return newState; 8670 } 8671 } 8672 return state; 8673 }, 8674 controlledInnerBlocks(state = {}, { type, clientId, hasControlledInnerBlocks }) { 8675 if (type === "SET_HAS_CONTROLLED_INNER_BLOCKS") { 8676 return { 8677 ...state, 8678 [clientId]: hasControlledInnerBlocks 8679 }; 8680 } 8681 return state; 8682 } 8683 }); 8684 function isBlockInterfaceHidden(state = false, action) { 8685 switch (action.type) { 8686 case "HIDE_BLOCK_INTERFACE": 8687 return true; 8688 case "SHOW_BLOCK_INTERFACE": 8689 return false; 8690 } 8691 return state; 8692 } 8693 function isTyping(state = false, action) { 8694 switch (action.type) { 8695 case "START_TYPING": 8696 return true; 8697 case "STOP_TYPING": 8698 return false; 8699 } 8700 return state; 8701 } 8702 function isDragging(state = false, action) { 8703 switch (action.type) { 8704 case "START_DRAGGING": 8705 return true; 8706 case "STOP_DRAGGING": 8707 return false; 8708 } 8709 return state; 8710 } 8711 function draggedBlocks(state = [], action) { 8712 switch (action.type) { 8713 case "START_DRAGGING_BLOCKS": 8714 return action.clientIds; 8715 case "STOP_DRAGGING_BLOCKS": 8716 return []; 8717 } 8718 return state; 8719 } 8720 function blockVisibility(state = {}, action) { 8721 if (action.type === "SET_BLOCK_VISIBILITY") { 8722 return { 8723 ...state, 8724 ...action.updates 8725 }; 8726 } 8727 return state; 8728 } 8729 function selectionHelper(state = {}, action) { 8730 switch (action.type) { 8731 case "CLEAR_SELECTED_BLOCK": { 8732 if (state.clientId) { 8733 return {}; 8734 } 8735 return state; 8736 } 8737 case "SELECT_BLOCK": 8738 if (action.clientId === state.clientId) { 8739 return state; 8740 } 8741 return { clientId: action.clientId }; 8742 case "REPLACE_INNER_BLOCKS": 8743 case "INSERT_BLOCKS": { 8744 if (!action.updateSelection || !action.blocks.length) { 8745 return state; 8746 } 8747 return { clientId: action.blocks[0].clientId }; 8748 } 8749 case "REMOVE_BLOCKS": 8750 if (!action.clientIds || !action.clientIds.length || action.clientIds.indexOf(state.clientId) === -1) { 8751 return state; 8752 } 8753 return {}; 8754 case "REPLACE_BLOCKS": { 8755 if (action.clientIds.indexOf(state.clientId) === -1) { 8756 return state; 8757 } 8758 const blockToSelect = action.blocks[action.indexToSelect] || action.blocks[action.blocks.length - 1]; 8759 if (!blockToSelect) { 8760 return {}; 8761 } 8762 if (blockToSelect.clientId === state.clientId) { 8763 return state; 8764 } 8765 return { clientId: blockToSelect.clientId }; 8766 } 8767 } 8768 return state; 8769 } 8770 function selection(state = {}, action) { 8771 switch (action.type) { 8772 case "SELECTION_CHANGE": 8773 if (action.clientId) { 8774 return { 8775 selectionStart: { 8776 clientId: action.clientId, 8777 attributeKey: action.attributeKey, 8778 offset: action.startOffset 8779 }, 8780 selectionEnd: { 8781 clientId: action.clientId, 8782 attributeKey: action.attributeKey, 8783 offset: action.endOffset 8784 } 8785 }; 8786 } 8787 return { 8788 selectionStart: action.start || state.selectionStart, 8789 selectionEnd: action.end || state.selectionEnd 8790 }; 8791 case "RESET_SELECTION": 8792 const { selectionStart: selectionStart2, selectionEnd: selectionEnd2 } = action; 8793 return { 8794 selectionStart: selectionStart2, 8795 selectionEnd: selectionEnd2 8796 }; 8797 case "MULTI_SELECT": 8798 const { start: start2, end } = action; 8799 if (start2 === state.selectionStart?.clientId && end === state.selectionEnd?.clientId) { 8800 return state; 8801 } 8802 return { 8803 selectionStart: { clientId: start2 }, 8804 selectionEnd: { clientId: end } 8805 }; 8806 case "RESET_BLOCKS": 8807 const startClientId = state?.selectionStart?.clientId; 8808 const endClientId = state?.selectionEnd?.clientId; 8809 if (!startClientId && !endClientId) { 8810 return state; 8811 } 8812 if (!action.blocks.some( 8813 (block) => block.clientId === startClientId 8814 )) { 8815 return { 8816 selectionStart: {}, 8817 selectionEnd: {} 8818 }; 8819 } 8820 if (!action.blocks.some( 8821 (block) => block.clientId === endClientId 8822 )) { 8823 return { 8824 ...state, 8825 selectionEnd: state.selectionStart 8826 }; 8827 } 8828 } 8829 const selectionStart = selectionHelper(state.selectionStart, action); 8830 const selectionEnd = selectionHelper(state.selectionEnd, action); 8831 if (selectionStart === state.selectionStart && selectionEnd === state.selectionEnd) { 8832 return state; 8833 } 8834 return { 8835 selectionStart, 8836 selectionEnd 8837 }; 8838 } 8839 function isMultiSelecting(state = false, action) { 8840 switch (action.type) { 8841 case "START_MULTI_SELECT": 8842 return true; 8843 case "STOP_MULTI_SELECT": 8844 return false; 8845 } 8846 return state; 8847 } 8848 function isSelectionEnabled(state = true, action) { 8849 switch (action.type) { 8850 case "TOGGLE_SELECTION": 8851 return action.isSelectionEnabled; 8852 } 8853 return state; 8854 } 8855 function removalPromptData(state = false, action) { 8856 switch (action.type) { 8857 case "DISPLAY_BLOCK_REMOVAL_PROMPT": 8858 const { clientIds, selectPrevious, message: message2 } = action; 8859 return { 8860 clientIds, 8861 selectPrevious, 8862 message: message2 8863 }; 8864 case "CLEAR_BLOCK_REMOVAL_PROMPT": 8865 return false; 8866 } 8867 return state; 8868 } 8869 function blockRemovalRules(state = false, action) { 8870 switch (action.type) { 8871 case "SET_BLOCK_REMOVAL_RULES": 8872 return action.rules; 8873 } 8874 return state; 8875 } 8876 function initialPosition(state = null, action) { 8877 if (action.type === "REPLACE_BLOCKS" && action.initialPosition !== void 0) { 8878 return action.initialPosition; 8879 } else if ([ 8880 "MULTI_SELECT", 8881 "SELECT_BLOCK", 8882 "RESET_SELECTION", 8883 "INSERT_BLOCKS", 8884 "REPLACE_INNER_BLOCKS" 8885 ].includes(action.type)) { 8886 return action.initialPosition; 8887 } 8888 return state; 8889 } 8890 function blocksMode(state = {}, action) { 8891 if (action.type === "TOGGLE_BLOCK_MODE") { 8892 const { clientId } = action; 8893 return { 8894 ...state, 8895 [clientId]: state[clientId] && state[clientId] === "html" ? "visual" : "html" 8896 }; 8897 } 8898 return state; 8899 } 8900 function insertionCue(state = null, action) { 8901 switch (action.type) { 8902 case "SHOW_INSERTION_POINT": { 8903 const { 8904 rootClientId, 8905 index, 8906 __unstableWithInserter, 8907 operation, 8908 nearestSide 8909 } = action; 8910 const nextState = { 8911 rootClientId, 8912 index, 8913 __unstableWithInserter, 8914 operation, 8915 nearestSide 8916 }; 8917 return (0, import_es6.default)(state, nextState) ? state : nextState; 8918 } 8919 case "HIDE_INSERTION_POINT": 8920 return null; 8921 } 8922 return state; 8923 } 8924 function template(state = { isValid: true }, action) { 8925 switch (action.type) { 8926 case "SET_TEMPLATE_VALIDITY": 8927 return { 8928 ...state, 8929 isValid: action.isValid 8930 }; 8931 } 8932 return state; 8933 } 8934 function settings(state = SETTINGS_DEFAULTS, action) { 8935 switch (action.type) { 8936 case "UPDATE_SETTINGS": { 8937 const updatedSettings = action.reset ? { 8938 ...SETTINGS_DEFAULTS, 8939 ...action.settings 8940 } : { 8941 ...state, 8942 ...action.settings 8943 }; 8944 Object.defineProperty(updatedSettings, "__unstableIsPreviewMode", { 8945 get() { 8946 (0, import_deprecated.default)("__unstableIsPreviewMode", { 8947 since: "6.8", 8948 alternative: "isPreviewMode" 8949 }); 8950 return this.isPreviewMode; 8951 } 8952 }); 8953 return updatedSettings; 8954 } 8955 } 8956 return state; 8957 } 8958 function preferences(state = PREFERENCES_DEFAULTS, action) { 8959 switch (action.type) { 8960 case "INSERT_BLOCKS": 8961 case "REPLACE_BLOCKS": { 8962 const nextInsertUsage = action.blocks.reduce( 8963 (prevUsage, block) => { 8964 const { attributes, name: blockName } = block; 8965 let id = blockName; 8966 const match2 = (0, import_data2.select)(import_blocks2.store).getActiveBlockVariation( 8967 blockName, 8968 attributes 8969 ); 8970 if (match2?.name) { 8971 id += "/" + match2.name; 8972 } 8973 if (blockName === "core/block") { 8974 id += "/" + attributes.ref; 8975 } 8976 return { 8977 ...prevUsage, 8978 [id]: { 8979 time: action.time, 8980 count: prevUsage[id] ? prevUsage[id].count + 1 : 1 8981 } 8982 }; 8983 }, 8984 state.insertUsage 8985 ); 8986 return { 8987 ...state, 8988 insertUsage: nextInsertUsage 8989 }; 8990 } 8991 } 8992 return state; 8993 } 8994 var blockListSettings = (state = {}, action) => { 8995 switch (action.type) { 8996 // Even if the replaced blocks have the same client ID, our logic 8997 // should correct the state. 8998 case "REPLACE_BLOCKS": 8999 case "REMOVE_BLOCKS": { 9000 return Object.fromEntries( 9001 Object.entries(state).filter( 9002 ([id]) => !action.clientIds.includes(id) 9003 ) 9004 ); 9005 } 9006 case "UPDATE_BLOCK_LIST_SETTINGS": { 9007 const updates = typeof action.clientId === "string" ? { [action.clientId]: action.settings } : action.clientId; 9008 for (const clientId in updates) { 9009 if (!updates[clientId]) { 9010 if (!state[clientId]) { 9011 delete updates[clientId]; 9012 } 9013 } else if ((0, import_es6.default)(state[clientId], updates[clientId])) { 9014 delete updates[clientId]; 9015 } 9016 } 9017 if (Object.keys(updates).length === 0) { 9018 return state; 9019 } 9020 const merged = { ...state, ...updates }; 9021 for (const clientId in updates) { 9022 if (!updates[clientId]) { 9023 delete merged[clientId]; 9024 } 9025 } 9026 return merged; 9027 } 9028 } 9029 return state; 9030 }; 9031 function lastBlockAttributesChange(state = null, action) { 9032 switch (action.type) { 9033 case "UPDATE_BLOCK": 9034 if (!action.updates.attributes) { 9035 break; 9036 } 9037 return { [action.clientId]: action.updates.attributes }; 9038 case "UPDATE_BLOCK_ATTRIBUTES": 9039 return action.clientIds.reduce( 9040 (accumulator, id) => ({ 9041 ...accumulator, 9042 [id]: !!action.options?.uniqueByBlock ? action.attributes[id] : action.attributes 9043 }), 9044 {} 9045 ); 9046 } 9047 return state; 9048 } 9049 function highlightedBlock(state, action) { 9050 switch (action.type) { 9051 case "TOGGLE_BLOCK_HIGHLIGHT": 9052 const { clientId, isHighlighted } = action; 9053 if (isHighlighted) { 9054 return clientId; 9055 } else if (state === clientId) { 9056 return null; 9057 } 9058 return state; 9059 case "SELECT_BLOCK": 9060 if (action.clientId !== state) { 9061 return null; 9062 } 9063 } 9064 return state; 9065 } 9066 function hasBlockSpotlight(state, action) { 9067 switch (action.type) { 9068 case "TOGGLE_BLOCK_SPOTLIGHT": 9069 const { clientId, hasBlockSpotlight: _hasBlockSpotlight } = action; 9070 if (_hasBlockSpotlight) { 9071 return clientId; 9072 } else if (state === clientId) { 9073 return null; 9074 } 9075 return state; 9076 case "SELECT_BLOCK": 9077 if (action.clientId !== state) { 9078 return null; 9079 } 9080 return state; 9081 case "SELECTION_CHANGE": 9082 if (action.start?.clientId !== state || action.end?.clientId !== state) { 9083 return null; 9084 } 9085 return state; 9086 case "CLEAR_SELECTED_BLOCK": 9087 return null; 9088 } 9089 return state; 9090 } 9091 function expandedBlock(state = null, action) { 9092 switch (action.type) { 9093 case "SET_BLOCK_EXPANDED_IN_LIST_VIEW": 9094 return action.clientId; 9095 case "SELECT_BLOCK": 9096 if (action.clientId !== state) { 9097 return null; 9098 } 9099 } 9100 return state; 9101 } 9102 function lastBlockInserted(state = {}, action) { 9103 switch (action.type) { 9104 case "INSERT_BLOCKS": 9105 case "REPLACE_BLOCKS": 9106 if (!action.blocks.length) { 9107 return state; 9108 } 9109 const clientIds = action.blocks.map((block) => { 9110 return block.clientId; 9111 }); 9112 const source = action.meta?.source; 9113 return { clientIds, source }; 9114 case "RESET_BLOCKS": 9115 return {}; 9116 } 9117 return state; 9118 } 9119 function editedContentOnlySection(state, action) { 9120 if (action.type === "EDIT_CONTENT_ONLY_SECTION") { 9121 return action.clientId; 9122 } 9123 return state; 9124 } 9125 function blockEditingModes(state = /* @__PURE__ */ new Map(), action) { 9126 switch (action.type) { 9127 case "SET_BLOCK_EDITING_MODE": 9128 if (state.get(action.clientId) === action.mode) { 9129 return state; 9130 } 9131 return new Map(state).set(action.clientId, action.mode); 9132 case "UNSET_BLOCK_EDITING_MODE": { 9133 if (!state.has(action.clientId)) { 9134 return state; 9135 } 9136 const newState = new Map(state); 9137 newState.delete(action.clientId); 9138 return newState; 9139 } 9140 case "RESET_BLOCKS": { 9141 return state.has("") ? (/* @__PURE__ */ new Map()).set("", state.get("")) : state; 9142 } 9143 } 9144 return state; 9145 } 9146 function openedBlockSettingsMenu(state = null, action) { 9147 if ("SET_OPENED_BLOCK_SETTINGS_MENU" === action.type) { 9148 return action?.clientId ?? null; 9149 } 9150 return state; 9151 } 9152 function styleOverrides(state = /* @__PURE__ */ new Map(), action) { 9153 switch (action.type) { 9154 case "SET_STYLE_OVERRIDE": 9155 return new Map(state).set(action.id, action.style); 9156 case "DELETE_STYLE_OVERRIDE": { 9157 const newState = new Map(state); 9158 newState.delete(action.id); 9159 return newState; 9160 } 9161 } 9162 return state; 9163 } 9164 function registeredInserterMediaCategories(state = [], action) { 9165 switch (action.type) { 9166 case "REGISTER_INSERTER_MEDIA_CATEGORY": 9167 return [...state, action.category]; 9168 } 9169 return state; 9170 } 9171 function lastFocus(state = false, action) { 9172 switch (action.type) { 9173 case "LAST_FOCUS": 9174 return action.lastFocus; 9175 } 9176 return state; 9177 } 9178 function zoomLevel(state = 100, action) { 9179 switch (action.type) { 9180 case "SET_ZOOM_LEVEL": 9181 return action.zoom; 9182 case "RESET_ZOOM_LEVEL": 9183 return 100; 9184 } 9185 return state; 9186 } 9187 function insertionPoint(state = null, action) { 9188 switch (action.type) { 9189 case "SET_INSERTION_POINT": 9190 return action.value; 9191 case "SELECT_BLOCK": 9192 return null; 9193 } 9194 return state; 9195 } 9196 var combinedReducers = (0, import_data2.combineReducers)({ 9197 blocks, 9198 isDragging, 9199 isTyping, 9200 isBlockInterfaceHidden, 9201 draggedBlocks, 9202 selection, 9203 isMultiSelecting, 9204 isSelectionEnabled, 9205 initialPosition, 9206 blocksMode, 9207 blockListSettings, 9208 insertionPoint, 9209 insertionCue, 9210 template, 9211 settings, 9212 preferences, 9213 lastBlockAttributesChange, 9214 lastFocus, 9215 expandedBlock, 9216 highlightedBlock, 9217 lastBlockInserted, 9218 editedContentOnlySection, 9219 blockVisibility, 9220 blockEditingModes, 9221 styleOverrides, 9222 removalPromptData, 9223 blockRemovalRules, 9224 openedBlockSettingsMenu, 9225 registeredInserterMediaCategories, 9226 zoomLevel, 9227 hasBlockSpotlight 9228 }); 9229 function getBlockTreeBlock(state, clientId) { 9230 if (clientId === "") { 9231 const rootBlock = state.blocks.tree.get(clientId); 9232 if (!rootBlock) { 9233 return; 9234 } 9235 return { 9236 clientId: "", 9237 ...rootBlock 9238 }; 9239 } 9240 if (!state.blocks.controlledInnerBlocks[clientId]) { 9241 return state.blocks.tree.get(clientId); 9242 } 9243 const controlledTree = state.blocks.tree.get(`controlled||$clientId}`); 9244 const regularTree = state.blocks.tree.get(clientId); 9245 return { 9246 ...regularTree, 9247 innerBlocks: controlledTree?.innerBlocks 9248 }; 9249 } 9250 function traverseBlockTree(state, clientId, callback) { 9251 const tree = getBlockTreeBlock(state, clientId); 9252 if (!tree) { 9253 return; 9254 } 9255 callback(tree); 9256 if (!tree?.innerBlocks?.length) { 9257 return; 9258 } 9259 for (const innerBlock of tree?.innerBlocks) { 9260 traverseBlockTree(state, innerBlock.clientId, callback); 9261 } 9262 } 9263 function findParentInClientIdsList(state, clientId, clientIds) { 9264 if (!clientIds.length) { 9265 return; 9266 } 9267 let parent = state.blocks.parents.get(clientId); 9268 while (parent !== void 0) { 9269 if (clientIds.includes(parent)) { 9270 return parent; 9271 } 9272 parent = state.blocks.parents.get(parent); 9273 } 9274 } 9275 function hasBindings(block) { 9276 return block?.attributes?.metadata?.bindings && Object.keys(block?.attributes?.metadata?.bindings).length; 9277 } 9278 function getDerivedBlockEditingModesForTree(state, treeClientId = "") { 9279 const isZoomedOut = state?.zoomLevel < 100 || state?.zoomLevel === "auto-scaled"; 9280 const derivedBlockEditingModes = /* @__PURE__ */ new Map(); 9281 const sectionRootClientId = state.settings?.[sectionRootClientIdKey]; 9282 const sectionClientIds = state.blocks.order.get(sectionRootClientId); 9283 const hasDisabledBlocks = Array.from(state.blockEditingModes).some( 9284 ([, mode2]) => mode2 === "disabled" 9285 ); 9286 const templatePartClientIds = []; 9287 const syncedPatternClientIds = []; 9288 Object.keys(state.blocks.controlledInnerBlocks).forEach((clientId) => { 9289 const block = state.blocks.byClientId?.get(clientId); 9290 if (block?.name === "core/template-part") { 9291 templatePartClientIds.push(clientId); 9292 } 9293 if (block?.name === "core/block") { 9294 syncedPatternClientIds.push(clientId); 9295 } 9296 }); 9297 const contentOnlyTemplateLockedClientIds = Object.keys( 9298 state.blockListSettings 9299 ).filter( 9300 (clientId) => state.blockListSettings[clientId]?.templateLock === "contentOnly" 9301 ); 9302 const isIsolatedEditor = state.settings?.[isIsolatedEditorKey]; 9303 const unsyncedPatternClientIds = !!window?.__experimentalContentOnlyPatternInsertion && !isIsolatedEditor ? Array.from(state.blocks.attributes.keys()).filter( 9304 (clientId) => state.blocks.attributes.get(clientId)?.metadata?.patternName 9305 ) : []; 9306 const contentOnlyParents = [ 9307 ...contentOnlyTemplateLockedClientIds, 9308 ...unsyncedPatternClientIds, 9309 ...window?.__experimentalContentOnlyPatternInsertion && !isIsolatedEditor ? templatePartClientIds : [] 9310 ]; 9311 traverseBlockTree(state, treeClientId, (block) => { 9312 const { clientId, name: blockName } = block; 9313 if (state.editedContentOnlySection) { 9314 if (state.editedContentOnlySection === clientId) { 9315 derivedBlockEditingModes.set(clientId, "default"); 9316 return; 9317 } 9318 const parentTempEditedClientId = findParentInClientIdsList( 9319 state, 9320 clientId, 9321 [state.editedContentOnlySection] 9322 ); 9323 if (parentTempEditedClientId) { 9324 derivedBlockEditingModes.set(clientId, "default"); 9325 return; 9326 } 9327 if (window?.__experimentalContentOnlyPatternInsertion) { 9328 derivedBlockEditingModes.set(clientId, "disabled"); 9329 return; 9330 } 9331 } 9332 if (state.blockEditingModes.has(clientId)) { 9333 return; 9334 } 9335 if (hasDisabledBlocks) { 9336 let ancestorBlockEditingMode; 9337 let parent = state.blocks.parents.get(clientId); 9338 while (parent !== void 0) { 9339 if (state.blockEditingModes.has(parent)) { 9340 ancestorBlockEditingMode = state.blockEditingModes.get(parent); 9341 } 9342 if (ancestorBlockEditingMode) { 9343 break; 9344 } 9345 parent = state.blocks.parents.get(parent); 9346 } 9347 if (ancestorBlockEditingMode === "disabled") { 9348 derivedBlockEditingModes.set(clientId, "disabled"); 9349 return; 9350 } 9351 } 9352 if (isZoomedOut) { 9353 if (clientId === sectionRootClientId) { 9354 derivedBlockEditingModes.set(clientId, "contentOnly"); 9355 return; 9356 } 9357 if (!sectionClientIds?.length) { 9358 derivedBlockEditingModes.set(clientId, "disabled"); 9359 return; 9360 } 9361 if (sectionClientIds.includes(clientId)) { 9362 derivedBlockEditingModes.set(clientId, "contentOnly"); 9363 return; 9364 } 9365 derivedBlockEditingModes.set(clientId, "disabled"); 9366 return; 9367 } 9368 if (syncedPatternClientIds.length) { 9369 if (syncedPatternClientIds.includes(clientId)) { 9370 if (findParentInClientIdsList( 9371 state, 9372 clientId, 9373 syncedPatternClientIds 9374 )) { 9375 derivedBlockEditingModes.set(clientId, "disabled"); 9376 return; 9377 } 9378 return; 9379 } 9380 const parentPatternClientId = findParentInClientIdsList( 9381 state, 9382 clientId, 9383 syncedPatternClientIds 9384 ); 9385 if (parentPatternClientId) { 9386 if (findParentInClientIdsList( 9387 state, 9388 parentPatternClientId, 9389 syncedPatternClientIds 9390 )) { 9391 derivedBlockEditingModes.set(clientId, "disabled"); 9392 return; 9393 } 9394 if (hasBindings(block)) { 9395 derivedBlockEditingModes.set(clientId, "contentOnly"); 9396 return; 9397 } 9398 derivedBlockEditingModes.set(clientId, "disabled"); 9399 } 9400 } 9401 if (contentOnlyParents.length) { 9402 const hasContentOnlyParent = !!findParentInClientIdsList( 9403 state, 9404 clientId, 9405 contentOnlyParents 9406 ); 9407 if (hasContentOnlyParent) { 9408 if (isContentBlock(blockName)) { 9409 derivedBlockEditingModes.set(clientId, "contentOnly"); 9410 } else { 9411 derivedBlockEditingModes.set(clientId, "disabled"); 9412 } 9413 } 9414 } 9415 }); 9416 return derivedBlockEditingModes; 9417 } 9418 function getDerivedBlockEditingModesUpdates({ 9419 prevState, 9420 nextState, 9421 addedBlocks, 9422 removedClientIds 9423 }) { 9424 const prevDerivedBlockEditingModes = prevState.derivedBlockEditingModes; 9425 let nextDerivedBlockEditingModes; 9426 removedClientIds?.forEach((clientId) => { 9427 traverseBlockTree(prevState, clientId, (block) => { 9428 if (prevDerivedBlockEditingModes.has(block.clientId)) { 9429 if (!nextDerivedBlockEditingModes) { 9430 nextDerivedBlockEditingModes = new Map( 9431 prevDerivedBlockEditingModes 9432 ); 9433 } 9434 nextDerivedBlockEditingModes.delete(block.clientId); 9435 } 9436 }); 9437 }); 9438 addedBlocks?.forEach((addedBlock) => { 9439 const updates = getDerivedBlockEditingModesForTree( 9440 nextState, 9441 addedBlock.clientId 9442 ); 9443 if (updates.size) { 9444 if (!nextDerivedBlockEditingModes) { 9445 nextDerivedBlockEditingModes = new Map([ 9446 ...prevDerivedBlockEditingModes?.size ? prevDerivedBlockEditingModes : [], 9447 ...updates 9448 ]); 9449 } else { 9450 nextDerivedBlockEditingModes = new Map([ 9451 ...nextDerivedBlockEditingModes?.size ? nextDerivedBlockEditingModes : [], 9452 ...updates 9453 ]); 9454 } 9455 } 9456 }); 9457 return nextDerivedBlockEditingModes; 9458 } 9459 function withDerivedBlockEditingModes(reducer4) { 9460 return (state, action) => { 9461 const nextState = reducer4(state, action); 9462 if (action.type !== "SET_EDITOR_MODE" && nextState === state) { 9463 return state; 9464 } 9465 switch (action.type) { 9466 case "REMOVE_BLOCKS": { 9467 const nextDerivedBlockEditingModes = getDerivedBlockEditingModesUpdates({ 9468 prevState: state, 9469 nextState, 9470 removedClientIds: action.clientIds 9471 }); 9472 if (nextDerivedBlockEditingModes) { 9473 return { 9474 ...nextState, 9475 derivedBlockEditingModes: nextDerivedBlockEditingModes ?? state.derivedBlockEditingModes 9476 }; 9477 } 9478 break; 9479 } 9480 case "RECEIVE_BLOCKS": 9481 case "INSERT_BLOCKS": { 9482 const nextDerivedBlockEditingModes = getDerivedBlockEditingModesUpdates({ 9483 prevState: state, 9484 nextState, 9485 addedBlocks: action.blocks 9486 }); 9487 if (nextDerivedBlockEditingModes) { 9488 return { 9489 ...nextState, 9490 derivedBlockEditingModes: nextDerivedBlockEditingModes ?? state.derivedBlockEditingModes 9491 }; 9492 } 9493 break; 9494 } 9495 case "UPDATE_BLOCK_ATTRIBUTES": { 9496 const addedBlocks = []; 9497 const removedClientIds = []; 9498 for (const clientId of action?.clientIds) { 9499 const attributes = action.options?.uniqueByBlock ? action.attributes[clientId] : action.attributes; 9500 if (!attributes) { 9501 break; 9502 } 9503 if ( 9504 // patternName is switching from falsy to truthy, indicating 9505 // this block is becoming an unsynced pattern. 9506 attributes.metadata?.patternName && !state.blocks.attributes.get(clientId)?.metadata?.patternName 9507 ) { 9508 addedBlocks.push( 9509 nextState.blocks.tree.get(clientId) 9510 ); 9511 } else if ( 9512 // patternName is switching from truthy to falsy, this block is becoming 9513 // a regular block but was an unsynced pattern. 9514 // Check that `metadata` is part of the included attributes, as 9515 // `updateBlockAttributes` merges attributes, if it isn't present 9516 // the previous `metadata` would be retained. 9517 attributes.metadata && !attributes.metadata?.patternName && state.blocks.attributes.get(clientId)?.metadata?.patternName 9518 ) { 9519 removedClientIds.push(clientId); 9520 } 9521 } 9522 if (!addedBlocks?.length && !removedClientIds?.length) { 9523 break; 9524 } 9525 const nextDerivedBlockEditingModes = getDerivedBlockEditingModesUpdates({ 9526 prevState: state, 9527 nextState, 9528 addedBlocks, 9529 removedClientIds 9530 }); 9531 if (nextDerivedBlockEditingModes) { 9532 return { 9533 ...nextState, 9534 derivedBlockEditingModes: nextDerivedBlockEditingModes ?? state.derivedBlockEditingModes 9535 }; 9536 } 9537 break; 9538 } 9539 case "UPDATE_BLOCK_LIST_SETTINGS": { 9540 const addedBlocks = []; 9541 const removedClientIds = []; 9542 const updates = typeof action.clientId === "string" ? { [action.clientId]: action.settings } : action.clientId; 9543 for (const clientId in updates) { 9544 const isNewContentOnlyBlock = state.blockListSettings[clientId]?.templateLock !== "contentOnly" && nextState.blockListSettings[clientId]?.templateLock === "contentOnly"; 9545 const wasContentOnlyBlock = state.blockListSettings[clientId]?.templateLock === "contentOnly" && nextState.blockListSettings[clientId]?.templateLock !== "contentOnly"; 9546 if (isNewContentOnlyBlock) { 9547 addedBlocks.push( 9548 nextState.blocks.tree.get(clientId) 9549 ); 9550 } else if (wasContentOnlyBlock) { 9551 removedClientIds.push(clientId); 9552 } 9553 } 9554 if (!addedBlocks.length && !removedClientIds.length) { 9555 break; 9556 } 9557 const nextDerivedBlockEditingModes = getDerivedBlockEditingModesUpdates({ 9558 prevState: state, 9559 nextState, 9560 addedBlocks, 9561 removedClientIds 9562 }); 9563 if (nextDerivedBlockEditingModes) { 9564 return { 9565 ...nextState, 9566 derivedBlockEditingModes: nextDerivedBlockEditingModes ?? state.derivedBlockEditingModes 9567 }; 9568 } 9569 break; 9570 } 9571 case "SET_BLOCK_EDITING_MODE": 9572 case "UNSET_BLOCK_EDITING_MODE": 9573 case "SET_HAS_CONTROLLED_INNER_BLOCKS": { 9574 const updatedBlock = getBlockTreeBlock( 9575 nextState, 9576 action.clientId 9577 ); 9578 if (!updatedBlock) { 9579 break; 9580 } 9581 const nextDerivedBlockEditingModes = getDerivedBlockEditingModesUpdates({ 9582 prevState: state, 9583 nextState, 9584 removedClientIds: [action.clientId], 9585 addedBlocks: [updatedBlock] 9586 }); 9587 if (nextDerivedBlockEditingModes) { 9588 return { 9589 ...nextState, 9590 derivedBlockEditingModes: nextDerivedBlockEditingModes ?? state.derivedBlockEditingModes 9591 }; 9592 } 9593 break; 9594 } 9595 case "REPLACE_BLOCKS": { 9596 const nextDerivedBlockEditingModes = getDerivedBlockEditingModesUpdates({ 9597 prevState: state, 9598 nextState, 9599 addedBlocks: action.blocks, 9600 removedClientIds: action.clientIds 9601 }); 9602 if (nextDerivedBlockEditingModes) { 9603 return { 9604 ...nextState, 9605 derivedBlockEditingModes: nextDerivedBlockEditingModes ?? state.derivedBlockEditingModes 9606 }; 9607 } 9608 break; 9609 } 9610 case "REPLACE_INNER_BLOCKS": { 9611 const removedClientIds = state.blocks.order.get( 9612 action.rootClientId 9613 ); 9614 const nextDerivedBlockEditingModes = getDerivedBlockEditingModesUpdates({ 9615 prevState: state, 9616 nextState, 9617 addedBlocks: action.blocks, 9618 removedClientIds 9619 }); 9620 if (nextDerivedBlockEditingModes) { 9621 return { 9622 ...nextState, 9623 derivedBlockEditingModes: nextDerivedBlockEditingModes ?? state.derivedBlockEditingModes 9624 }; 9625 } 9626 break; 9627 } 9628 case "MOVE_BLOCKS_TO_POSITION": { 9629 const addedBlocks = action.clientIds.map((clientId) => { 9630 return nextState.blocks.byClientId.get(clientId); 9631 }); 9632 const nextDerivedBlockEditingModes = getDerivedBlockEditingModesUpdates({ 9633 prevState: state, 9634 nextState, 9635 addedBlocks, 9636 removedClientIds: action.clientIds 9637 }); 9638 if (nextDerivedBlockEditingModes) { 9639 return { 9640 ...nextState, 9641 derivedBlockEditingModes: nextDerivedBlockEditingModes ?? state.derivedBlockEditingModes 9642 }; 9643 } 9644 break; 9645 } 9646 case "UPDATE_SETTINGS": { 9647 if (state?.settings?.[sectionRootClientIdKey] !== nextState?.settings?.[sectionRootClientIdKey]) { 9648 return { 9649 ...nextState, 9650 derivedBlockEditingModes: getDerivedBlockEditingModesForTree(nextState) 9651 }; 9652 } 9653 break; 9654 } 9655 case "RESET_BLOCKS": 9656 case "EDIT_CONTENT_ONLY_SECTION": 9657 case "SET_EDITOR_MODE": 9658 case "RESET_ZOOM_LEVEL": 9659 case "SET_ZOOM_LEVEL": { 9660 return { 9661 ...nextState, 9662 derivedBlockEditingModes: getDerivedBlockEditingModesForTree(nextState) 9663 }; 9664 } 9665 } 9666 nextState.derivedBlockEditingModes = state?.derivedBlockEditingModes ?? /* @__PURE__ */ new Map(); 9667 return nextState; 9668 }; 9669 } 9670 function withAutomaticChangeReset(reducer4) { 9671 return (state, action) => { 9672 const nextState = reducer4(state, action); 9673 if (!state) { 9674 return nextState; 9675 } 9676 nextState.automaticChangeStatus = state.automaticChangeStatus; 9677 if (action.type === "MARK_AUTOMATIC_CHANGE") { 9678 return { 9679 ...nextState, 9680 automaticChangeStatus: "pending" 9681 }; 9682 } 9683 if (action.type === "MARK_AUTOMATIC_CHANGE_FINAL" && state.automaticChangeStatus === "pending") { 9684 return { 9685 ...nextState, 9686 automaticChangeStatus: "final" 9687 }; 9688 } 9689 if (nextState.blocks === state.blocks && nextState.selection === state.selection) { 9690 return nextState; 9691 } 9692 if (nextState.automaticChangeStatus !== "final" && nextState.selection !== state.selection) { 9693 return nextState; 9694 } 9695 return { 9696 ...nextState, 9697 automaticChangeStatus: void 0 9698 }; 9699 }; 9700 } 9701 var reducer_default = (0, import_compose.pipe)( 9702 withDerivedBlockEditingModes, 9703 withAutomaticChangeReset 9704 )(combinedReducers); 9705 9706 // packages/block-editor/build-module/store/selectors.js 9707 var selectors_exports = {}; 9708 __export(selectors_exports, { 9709 __experimentalGetActiveBlockIdByBlockNames: () => __experimentalGetActiveBlockIdByBlockNames, 9710 __experimentalGetAllowedBlocks: () => __experimentalGetAllowedBlocks, 9711 __experimentalGetAllowedPatterns: () => __experimentalGetAllowedPatterns, 9712 __experimentalGetBlockListSettingsForBlocks: () => __experimentalGetBlockListSettingsForBlocks, 9713 __experimentalGetDirectInsertBlock: () => __experimentalGetDirectInsertBlock, 9714 __experimentalGetGlobalBlocksByName: () => __experimentalGetGlobalBlocksByName, 9715 __experimentalGetLastBlockAttributeChanges: () => __experimentalGetLastBlockAttributeChanges, 9716 __experimentalGetParsedPattern: () => __experimentalGetParsedPattern, 9717 __experimentalGetPatternTransformItems: () => __experimentalGetPatternTransformItems, 9718 __experimentalGetPatternsByBlockTypes: () => __experimentalGetPatternsByBlockTypes, 9719 __experimentalGetReusableBlockTitle: () => __experimentalGetReusableBlockTitle, 9720 __unstableGetBlockWithoutInnerBlocks: () => __unstableGetBlockWithoutInnerBlocks, 9721 __unstableGetClientIdWithClientIdsTree: () => __unstableGetClientIdWithClientIdsTree, 9722 __unstableGetClientIdsTree: () => __unstableGetClientIdsTree, 9723 __unstableGetContentLockingParent: () => __unstableGetContentLockingParent, 9724 __unstableGetSelectedBlocksWithPartialSelection: () => __unstableGetSelectedBlocksWithPartialSelection, 9725 __unstableGetTemporarilyEditingAsBlocks: () => __unstableGetTemporarilyEditingAsBlocks, 9726 __unstableGetVisibleBlocks: () => __unstableGetVisibleBlocks, 9727 __unstableHasActiveBlockOverlayActive: () => __unstableHasActiveBlockOverlayActive, 9728 __unstableIsFullySelected: () => __unstableIsFullySelected, 9729 __unstableIsLastBlockChangeIgnored: () => __unstableIsLastBlockChangeIgnored, 9730 __unstableIsSelectionCollapsed: () => __unstableIsSelectionCollapsed, 9731 __unstableIsSelectionMergeable: () => __unstableIsSelectionMergeable, 9732 __unstableIsWithinBlockOverlay: () => __unstableIsWithinBlockOverlay, 9733 __unstableSelectionHasUnmergeableBlock: () => __unstableSelectionHasUnmergeableBlock, 9734 areInnerBlocksControlled: () => areInnerBlocksControlled, 9735 canEditBlock: () => canEditBlock, 9736 canInsertBlockType: () => canInsertBlockType, 9737 canInsertBlocks: () => canInsertBlocks, 9738 canLockBlockType: () => canLockBlockType, 9739 canMoveBlock: () => canMoveBlock, 9740 canMoveBlocks: () => canMoveBlocks, 9741 canRemoveBlock: () => canRemoveBlock, 9742 canRemoveBlocks: () => canRemoveBlocks, 9743 didAutomaticChange: () => didAutomaticChange, 9744 getAdjacentBlockClientId: () => getAdjacentBlockClientId, 9745 getAllowedBlocks: () => getAllowedBlocks, 9746 getBlock: () => getBlock, 9747 getBlockAttributes: () => getBlockAttributes, 9748 getBlockCount: () => getBlockCount, 9749 getBlockEditingMode: () => getBlockEditingMode, 9750 getBlockHierarchyRootClientId: () => getBlockHierarchyRootClientId, 9751 getBlockIndex: () => getBlockIndex, 9752 getBlockInsertionPoint: () => getBlockInsertionPoint, 9753 getBlockListSettings: () => getBlockListSettings, 9754 getBlockMode: () => getBlockMode, 9755 getBlockName: () => getBlockName, 9756 getBlockNamesByClientId: () => getBlockNamesByClientId, 9757 getBlockOrder: () => getBlockOrder, 9758 getBlockParents: () => getBlockParents, 9759 getBlockParentsByBlockName: () => getBlockParentsByBlockName, 9760 getBlockRootClientId: () => getBlockRootClientId, 9761 getBlockSelectionEnd: () => getBlockSelectionEnd, 9762 getBlockSelectionStart: () => getBlockSelectionStart, 9763 getBlockTransformItems: () => getBlockTransformItems, 9764 getBlocks: () => getBlocks, 9765 getBlocksByClientId: () => getBlocksByClientId, 9766 getBlocksByName: () => getBlocksByName, 9767 getClientIdsOfDescendants: () => getClientIdsOfDescendants, 9768 getClientIdsWithDescendants: () => getClientIdsWithDescendants, 9769 getDirectInsertBlock: () => getDirectInsertBlock, 9770 getDraggedBlockClientIds: () => getDraggedBlockClientIds, 9771 getFirstMultiSelectedBlockClientId: () => getFirstMultiSelectedBlockClientId, 9772 getGlobalBlockCount: () => getGlobalBlockCount, 9773 getHoveredBlockClientId: () => getHoveredBlockClientId, 9774 getInserterItems: () => getInserterItems, 9775 getLastMultiSelectedBlockClientId: () => getLastMultiSelectedBlockClientId, 9776 getLowestCommonAncestorWithSelectedBlock: () => getLowestCommonAncestorWithSelectedBlock, 9777 getMultiSelectedBlockClientIds: () => getMultiSelectedBlockClientIds, 9778 getMultiSelectedBlocks: () => getMultiSelectedBlocks, 9779 getMultiSelectedBlocksEndClientId: () => getMultiSelectedBlocksEndClientId, 9780 getMultiSelectedBlocksStartClientId: () => getMultiSelectedBlocksStartClientId, 9781 getNextBlockClientId: () => getNextBlockClientId, 9782 getPatternsByBlockTypes: () => getPatternsByBlockTypes, 9783 getPreviousBlockClientId: () => getPreviousBlockClientId, 9784 getSelectedBlock: () => getSelectedBlock, 9785 getSelectedBlockClientId: () => getSelectedBlockClientId, 9786 getSelectedBlockClientIds: () => getSelectedBlockClientIds, 9787 getSelectedBlockCount: () => getSelectedBlockCount, 9788 getSelectedBlocksInitialCaretPosition: () => getSelectedBlocksInitialCaretPosition, 9789 getSelectionEnd: () => getSelectionEnd, 9790 getSelectionStart: () => getSelectionStart, 9791 getSettings: () => getSettings, 9792 getTemplate: () => getTemplate, 9793 getTemplateLock: () => getTemplateLock, 9794 hasBlockMovingClientId: () => hasBlockMovingClientId, 9795 hasDraggedInnerBlock: () => hasDraggedInnerBlock, 9796 hasInserterItems: () => hasInserterItems, 9797 hasMultiSelection: () => hasMultiSelection, 9798 hasSelectedBlock: () => hasSelectedBlock, 9799 hasSelectedInnerBlock: () => hasSelectedInnerBlock, 9800 isAncestorBeingDragged: () => isAncestorBeingDragged, 9801 isAncestorMultiSelected: () => isAncestorMultiSelected, 9802 isBlockBeingDragged: () => isBlockBeingDragged, 9803 isBlockHighlighted: () => isBlockHighlighted, 9804 isBlockInsertionPointVisible: () => isBlockInsertionPointVisible, 9805 isBlockMultiSelected: () => isBlockMultiSelected, 9806 isBlockSelected: () => isBlockSelected, 9807 isBlockValid: () => isBlockValid, 9808 isBlockVisible: () => isBlockVisible, 9809 isBlockWithinSelection: () => isBlockWithinSelection, 9810 isCaretWithinFormattedText: () => isCaretWithinFormattedText, 9811 isDraggingBlocks: () => isDraggingBlocks, 9812 isFirstMultiSelectedBlock: () => isFirstMultiSelectedBlock, 9813 isGroupable: () => isGroupable, 9814 isLastBlockChangePersistent: () => isLastBlockChangePersistent, 9815 isMultiSelecting: () => isMultiSelecting2, 9816 isSelectionEnabled: () => isSelectionEnabled2, 9817 isTyping: () => isTyping2, 9818 isUngroupable: () => isUngroupable, 9819 isValidTemplate: () => isValidTemplate, 9820 wasBlockJustInserted: () => wasBlockJustInserted 9821 }); 9822 var import_blocks6 = __toESM(require_blocks()); 9823 var import_element6 = __toESM(require_element()); 9824 var import_hooks2 = __toESM(require_hooks()); 9825 9826 // packages/icons/build-module/icon/index.js 9827 var import_element5 = __toESM(require_element()); 9828 var icon_default = (0, import_element5.forwardRef)( 9829 ({ icon, size = 24, ...props }, ref) => { 9830 return (0, import_element5.cloneElement)(icon, { 9831 width: size, 9832 height: size, 9833 ...props, 9834 ref 9835 }); 9836 } 9837 ); 9838 9839 // packages/icons/build-module/library/align-center.js 9840 var import_primitives = __toESM(require_primitives()); 9841 var import_jsx_runtime3 = __toESM(require_jsx_runtime()); 9842 var align_center_default = /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_primitives.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_primitives.Path, { d: "M7.5 5.5h9V4h-9v1.5Zm-3.5 7h16V11H4v1.5Zm3.5 7h9V18h-9v1.5Z" }) }); 9843 9844 // packages/icons/build-module/library/align-justify.js 9845 var import_primitives2 = __toESM(require_primitives()); 9846 var import_jsx_runtime4 = __toESM(require_jsx_runtime()); 9847 var align_justify_default = /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_primitives2.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_primitives2.Path, { d: "M4 12.8h16v-1.5H4v1.5zm0 7h12.4v-1.5H4v1.5zM4 4.3v1.5h16V4.3H4z" }) }); 9848 9849 // packages/icons/build-module/library/align-left.js 9850 var import_primitives3 = __toESM(require_primitives()); 9851 var import_jsx_runtime5 = __toESM(require_jsx_runtime()); 9852 var align_left_default = /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_primitives3.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_primitives3.Path, { d: "M13 5.5H4V4h9v1.5Zm7 7H4V11h16v1.5Zm-7 7H4V18h9v1.5Z" }) }); 9853 9854 // packages/icons/build-module/library/align-none.js 9855 var import_primitives4 = __toESM(require_primitives()); 9856 var import_jsx_runtime6 = __toESM(require_jsx_runtime()); 9857 var align_none_default = /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_primitives4.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_primitives4.Path, { d: "M19 5.5H5V4h14v1.5ZM19 20H5v-1.5h14V20ZM5 9h14v6H5V9Z" }) }); 9858 9859 // packages/icons/build-module/library/align-right.js 9860 var import_primitives5 = __toESM(require_primitives()); 9861 var import_jsx_runtime7 = __toESM(require_jsx_runtime()); 9862 var align_right_default = /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_primitives5.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_primitives5.Path, { d: "M11.111 5.5H20V4h-8.889v1.5ZM4 12.5h16V11H4v1.5Zm7.111 7H20V18h-8.889v1.5Z" }) }); 9863 9864 // packages/icons/build-module/library/arrow-down.js 9865 var import_primitives6 = __toESM(require_primitives()); 9866 var import_jsx_runtime8 = __toESM(require_jsx_runtime()); 9867 var arrow_down_default = /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_primitives6.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_primitives6.Path, { d: "m16.5 13.5-3.7 3.7V4h-1.5v13.2l-3.8-3.7-1 1 5.5 5.6 5.5-5.6z" }) }); 9868 9869 // packages/icons/build-module/library/arrow-left.js 9870 var import_primitives7 = __toESM(require_primitives()); 9871 var import_jsx_runtime9 = __toESM(require_jsx_runtime()); 9872 var arrow_left_default = /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_primitives7.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_primitives7.Path, { d: "M20 11.2H6.8l3.7-3.7-1-1L3.9 12l5.6 5.5 1-1-3.7-3.7H20z" }) }); 9873 9874 // packages/icons/build-module/library/arrow-right.js 9875 var import_primitives8 = __toESM(require_primitives()); 9876 var import_jsx_runtime10 = __toESM(require_jsx_runtime()); 9877 var arrow_right_default = /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_primitives8.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_primitives8.Path, { d: "m14.5 6.5-1 1 3.7 3.7H4v1.6h13.2l-3.7 3.7 1 1 5.6-5.5z" }) }); 9878 9879 // packages/icons/build-module/library/aspect-ratio.js 9880 var import_primitives9 = __toESM(require_primitives()); 9881 var import_jsx_runtime11 = __toESM(require_jsx_runtime()); 9882 var aspect_ratio_default = /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_primitives9.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_primitives9.Path, { d: "M18.5 5.5h-13c-1.1 0-2 .9-2 2v9c0 1.1.9 2 2 2h13c1.1 0 2-.9 2-2v-9c0-1.1-.9-2-2-2zm.5 11c0 .3-.2.5-.5.5h-13c-.3 0-.5-.2-.5-.5v-9c0-.3.2-.5.5-.5h13c.3 0 .5.2.5.5v9zM6.5 12H8v-2h2V8.5H6.5V12zm9.5 2h-2v1.5h3.5V12H16v2z" }) }); 9883 9884 // packages/icons/build-module/library/audio.js 9885 var import_primitives10 = __toESM(require_primitives()); 9886 var import_jsx_runtime12 = __toESM(require_jsx_runtime()); 9887 var audio_default = /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_primitives10.SVG, { viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_primitives10.Path, { d: "M17.7 4.3c-1.2 0-2.8 0-3.8 1-.6.6-.9 1.5-.9 2.6V14c-.6-.6-1.5-1-2.5-1C8.6 13 7 14.6 7 16.5S8.6 20 10.5 20c1.5 0 2.8-1 3.3-2.3.5-.8.7-1.8.7-2.5V7.9c0-.7.2-1.2.5-1.6.6-.6 1.8-.6 2.8-.6h.3V4.3h-.4z" }) }); 9888 9889 // packages/icons/build-module/library/block-default.js 9890 var import_primitives11 = __toESM(require_primitives()); 9891 var import_jsx_runtime13 = __toESM(require_jsx_runtime()); 9892 var block_default_default = /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_primitives11.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_primitives11.Path, { d: "M19 8h-1V6h-5v2h-2V6H6v2H5c-1.1 0-2 .9-2 2v8c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2v-8c0-1.1-.9-2-2-2zm.5 10c0 .3-.2.5-.5.5H5c-.3 0-.5-.2-.5-.5v-8c0-.3.2-.5.5-.5h14c.3 0 .5.2.5.5v8z" }) }); 9893 9894 // packages/icons/build-module/library/category.js 9895 var import_primitives12 = __toESM(require_primitives()); 9896 var import_jsx_runtime14 = __toESM(require_jsx_runtime()); 9897 var category_default = /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_primitives12.SVG, { viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)( 9898 import_primitives12.Path, 9899 { 9900 d: "M6 5.5h3a.5.5 0 01.5.5v3a.5.5 0 01-.5.5H6a.5.5 0 01-.5-.5V6a.5.5 0 01.5-.5zM4 6a2 2 0 012-2h3a2 2 0 012 2v3a2 2 0 01-2 2H6a2 2 0 01-2-2V6zm11-.5h3a.5.5 0 01.5.5v3a.5.5 0 01-.5.5h-3a.5.5 0 01-.5-.5V6a.5.5 0 01.5-.5zM13 6a2 2 0 012-2h3a2 2 0 012 2v3a2 2 0 01-2 2h-3a2 2 0 01-2-2V6zm5 8.5h-3a.5.5 0 00-.5.5v3a.5.5 0 00.5.5h3a.5.5 0 00.5-.5v-3a.5.5 0 00-.5-.5zM15 13a2 2 0 00-2 2v3a2 2 0 002 2h3a2 2 0 002-2v-3a2 2 0 00-2-2h-3zm-9 1.5h3a.5.5 0 01.5.5v3a.5.5 0 01-.5.5H6a.5.5 0 01-.5-.5v-3a.5.5 0 01.5-.5zM4 15a2 2 0 012-2h3a2 2 0 012 2v3a2 2 0 01-2 2H6a2 2 0 01-2-2v-3z", 9901 fillRule: "evenodd", 9902 clipRule: "evenodd" 9903 } 9904 ) }); 9905 9906 // packages/icons/build-module/library/check.js 9907 var import_primitives13 = __toESM(require_primitives()); 9908 var import_jsx_runtime15 = __toESM(require_jsx_runtime()); 9909 var check_default = /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_primitives13.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_primitives13.Path, { d: "M16.5 7.5 10 13.9l-2.5-2.4-1 1 3.5 3.6 7.5-7.6z" }) }); 9910 9911 // packages/icons/build-module/library/chevron-down.js 9912 var import_primitives14 = __toESM(require_primitives()); 9913 var import_jsx_runtime16 = __toESM(require_jsx_runtime()); 9914 var chevron_down_default = /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_primitives14.SVG, { viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_primitives14.Path, { d: "M17.5 11.6L12 16l-5.5-4.4.9-1.2L12 14l4.5-3.6 1 1.2z" }) }); 9915 9916 // packages/icons/build-module/library/chevron-left-small.js 9917 var import_primitives15 = __toESM(require_primitives()); 9918 var import_jsx_runtime17 = __toESM(require_jsx_runtime()); 9919 var chevron_left_small_default = /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_primitives15.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_primitives15.Path, { d: "m13.1 16-3.4-4 3.4-4 1.1 1-2.6 3 2.6 3-1.1 1z" }) }); 9920 9921 // packages/icons/build-module/library/chevron-left.js 9922 var import_primitives16 = __toESM(require_primitives()); 9923 var import_jsx_runtime18 = __toESM(require_jsx_runtime()); 9924 var chevron_left_default = /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_primitives16.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_primitives16.Path, { d: "M14.6 7l-1.2-1L8 12l5.4 6 1.2-1-4.6-5z" }) }); 9925 9926 // packages/icons/build-module/library/chevron-right-small.js 9927 var import_primitives17 = __toESM(require_primitives()); 9928 var import_jsx_runtime19 = __toESM(require_jsx_runtime()); 9929 var chevron_right_small_default = /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_primitives17.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_primitives17.Path, { d: "M10.8622 8.04053L14.2805 12.0286L10.8622 16.0167L9.72327 15.0405L12.3049 12.0286L9.72327 9.01672L10.8622 8.04053Z" }) }); 9930 9931 // packages/icons/build-module/library/chevron-right.js 9932 var import_primitives18 = __toESM(require_primitives()); 9933 var import_jsx_runtime20 = __toESM(require_jsx_runtime()); 9934 var chevron_right_default = /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_primitives18.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_primitives18.Path, { d: "M10.6 6L9.4 7l4.6 5-4.6 5 1.2 1 5.4-6z" }) }); 9935 9936 // packages/icons/build-module/library/chevron-up.js 9937 var import_primitives19 = __toESM(require_primitives()); 9938 var import_jsx_runtime21 = __toESM(require_jsx_runtime()); 9939 var chevron_up_default = /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_primitives19.SVG, { viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_primitives19.Path, { d: "M6.5 12.4L12 8l5.5 4.4-.9 1.2L12 10l-4.5 3.6-1-1.2z" }) }); 9940 9941 // packages/icons/build-module/library/close-small.js 9942 var import_primitives20 = __toESM(require_primitives()); 9943 var import_jsx_runtime22 = __toESM(require_jsx_runtime()); 9944 var close_small_default = /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_primitives20.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_primitives20.Path, { d: "M12 13.06l3.712 3.713 1.061-1.06L13.061 12l3.712-3.712-1.06-1.06L12 10.938 8.288 7.227l-1.061 1.06L10.939 12l-3.712 3.712 1.06 1.061L12 13.061z" }) }); 9945 9946 // packages/icons/build-module/library/cog.js 9947 var import_primitives21 = __toESM(require_primitives()); 9948 var import_jsx_runtime23 = __toESM(require_jsx_runtime()); 9949 var cog_default = /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_primitives21.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)( 9950 import_primitives21.Path, 9951 { 9952 fillRule: "evenodd", 9953 d: "M10.289 4.836A1 1 0 0111.275 4h1.306a1 1 0 01.987.836l.244 1.466c.787.26 1.503.679 2.108 1.218l1.393-.522a1 1 0 011.216.437l.653 1.13a1 1 0 01-.23 1.273l-1.148.944a6.025 6.025 0 010 2.435l1.149.946a1 1 0 01.23 1.272l-.653 1.13a1 1 0 01-1.216.437l-1.394-.522c-.605.54-1.32.958-2.108 1.218l-.244 1.466a1 1 0 01-.987.836h-1.306a1 1 0 01-.986-.836l-.244-1.466a5.995 5.995 0 01-2.108-1.218l-1.394.522a1 1 0 01-1.217-.436l-.653-1.131a1 1 0 01.23-1.272l1.149-.946a6.026 6.026 0 010-2.435l-1.148-.944a1 1 0 01-.23-1.272l.653-1.131a1 1 0 011.217-.437l1.393.522a5.994 5.994 0 012.108-1.218l.244-1.466zM14.929 12a3 3 0 11-6 0 3 3 0 016 0z", 9954 clipRule: "evenodd" 9955 } 9956 ) }); 9957 9958 // packages/icons/build-module/library/copy-small.js 9959 var import_primitives22 = __toESM(require_primitives()); 9960 var import_jsx_runtime24 = __toESM(require_jsx_runtime()); 9961 var copy_small_default = /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_primitives22.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)( 9962 import_primitives22.Path, 9963 { 9964 fillRule: "evenodd", 9965 clipRule: "evenodd", 9966 d: "M5.625 5.5h9.75c.069 0 .125.056.125.125v9.75a.125.125 0 0 1-.125.125h-9.75a.125.125 0 0 1-.125-.125v-9.75c0-.069.056-.125.125-.125ZM4 5.625C4 4.728 4.728 4 5.625 4h9.75C16.273 4 17 4.728 17 5.625v9.75c0 .898-.727 1.625-1.625 1.625h-9.75A1.625 1.625 0 0 1 4 15.375v-9.75Zm14.5 11.656v-9H20v9C20 18.8 18.77 20 17.251 20H6.25v-1.5h11.001c.69 0 1.249-.528 1.249-1.219Z" 9967 } 9968 ) }); 9969 9970 // packages/icons/build-module/library/copy.js 9971 var import_primitives23 = __toESM(require_primitives()); 9972 var import_jsx_runtime25 = __toESM(require_jsx_runtime()); 9973 var copy_default = /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_primitives23.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)( 9974 import_primitives23.Path, 9975 { 9976 fillRule: "evenodd", 9977 clipRule: "evenodd", 9978 d: "M5 4.5h11a.5.5 0 0 1 .5.5v11a.5.5 0 0 1-.5.5H5a.5.5 0 0 1-.5-.5V5a.5.5 0 0 1 .5-.5ZM3 5a2 2 0 0 1 2-2h11a2 2 0 0 1 2 2v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5Zm17 3v10.75c0 .69-.56 1.25-1.25 1.25H6v1.5h12.75a2.75 2.75 0 0 0 2.75-2.75V8H20Z" 9979 } 9980 ) }); 9981 9982 // packages/icons/build-module/library/corner-all.js 9983 var import_primitives24 = __toESM(require_primitives()); 9984 var import_jsx_runtime26 = __toESM(require_jsx_runtime()); 9985 var corner_all_default = /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_primitives24.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)( 9986 import_primitives24.Path, 9987 { 9988 fillRule: "evenodd", 9989 clipRule: "evenodd", 9990 d: "M5.75 6A.25.25 0 0 1 6 5.75h3v-1.5H6A1.75 1.75 0 0 0 4.25 6v3h1.5V6ZM18 18.25h-3v1.5h3A1.75 1.75 0 0 0 19.75 18v-3h-1.5v3a.25.25 0 0 1-.25.25ZM18.25 9V6a.25.25 0 0 0-.25-.25h-3v-1.5h3c.966 0 1.75.784 1.75 1.75v3h-1.5Zm-12.5 9v-3h-1.5v3c0 .966.784 1.75 1.75 1.75h3v-1.5H6a.25.25 0 0 1-.25-.25Z" 9991 } 9992 ) }); 9993 9994 // packages/icons/build-module/library/corner-bottom-left.js 9995 var import_primitives25 = __toESM(require_primitives()); 9996 var import_jsx_runtime27 = __toESM(require_jsx_runtime()); 9997 var corner_bottom_left_default = /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(import_primitives25.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: [ 9998 /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_primitives25.G, { opacity: ".25", children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_primitives25.Path, { d: "M5.75 6A.25.25 0 0 1 6 5.75h3v-1.5H6A1.75 1.75 0 0 0 4.25 6v3h1.5V6ZM18 18.25h-3v1.5h3A1.75 1.75 0 0 0 19.75 18v-3h-1.5v3a.25.25 0 0 1-.25.25ZM18.25 9V6a.25.25 0 0 0-.25-.25h-3v-1.5h3c.966 0 1.75.784 1.75 1.75v3h-1.5ZM5.75 18v-3h-1.5v3c0 .966.784 1.75 1.75 1.75h3v-1.5H6a.25.25 0 0 1-.25-.25Z" }) }), 9999 /* @__PURE__ */ (0, import_jsx_runtime27.jsx)( 10000 import_primitives25.Path, 10001 { 10002 fillRule: "evenodd", 10003 clipRule: "evenodd", 10004 d: "M5.75 15v3c0 .138.112.25.25.25h3v1.5H6A1.75 1.75 0 0 1 4.25 18v-3h1.5Z" 10005 } 10006 ) 10007 ] }); 10008 10009 // packages/icons/build-module/library/corner-bottom-right.js 10010 var import_primitives26 = __toESM(require_primitives()); 10011 var import_jsx_runtime28 = __toESM(require_jsx_runtime()); 10012 var corner_bottom_right_default = /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(import_primitives26.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: [ 10013 /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_primitives26.G, { opacity: ".25", children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_primitives26.Path, { d: "M5.75 6A.25.25 0 0 1 6 5.75h3v-1.5H6A1.75 1.75 0 0 0 4.25 6v3h1.5V6ZM18 18.25h-3v1.5h3A1.75 1.75 0 0 0 19.75 18v-3h-1.5v3a.25.25 0 0 1-.25.25ZM18.25 9V6a.25.25 0 0 0-.25-.25h-3v-1.5h3c.966 0 1.75.784 1.75 1.75v3h-1.5ZM5.75 18v-3h-1.5v3c0 .966.784 1.75 1.75 1.75h3v-1.5H6a.25.25 0 0 1-.25-.25Z" }) }), 10014 /* @__PURE__ */ (0, import_jsx_runtime28.jsx)( 10015 import_primitives26.Path, 10016 { 10017 fillRule: "evenodd", 10018 clipRule: "evenodd", 10019 d: "M15 18.25h3a.25.25 0 0 0 .25-.25v-3h1.5v3A1.75 1.75 0 0 1 18 19.75h-3v-1.5Z" 10020 } 10021 ) 10022 ] }); 10023 10024 // packages/icons/build-module/library/corner-top-left.js 10025 var import_primitives27 = __toESM(require_primitives()); 10026 var import_jsx_runtime29 = __toESM(require_jsx_runtime()); 10027 var corner_top_left_default = /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(import_primitives27.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: [ 10028 /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_primitives27.G, { opacity: ".25", children: /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(import_primitives27.Path, { d: "M5.75 6A.25.25 0 0 1 6 5.75h3v-1.5H6A1.75 1.75 0 0 0 4.25 6v3h1.5V6ZM18 18.25h-3v1.5h3A1.75 1.75 0 0 0 19.75 18v-3h-1.5v3a.25.25 0 0 1-.25.25ZM18.25 9V6a.25.25 0 0 0-.25-.25h-3v-1.5h3c.966 0 1.75.784 1.75 1.75v3h-1.5ZM5.75 18v-3h-1.5v3c0 .966.784 1.75 1.75 1.75h3v-1.5H6a.25.25 0 0 1-.25-.25Z" }) }), 10029 /* @__PURE__ */ (0, import_jsx_runtime29.jsx)( 10030 import_primitives27.Path, 10031 { 10032 fillRule: "evenodd", 10033 clipRule: "evenodd", 10034 d: "M6 5.75a.25.25 0 0 0-.25.25v3h-1.5V6c0-.966.784-1.75 1.75-1.75h3v1.5H6Z" 10035 } 10036 ) 10037 ] }); 10038 10039 // packages/icons/build-module/library/corner-top-right.js 10040 var import_primitives28 = __toESM(require_primitives()); 10041 var import_jsx_runtime30 = __toESM(require_jsx_runtime()); 10042 var corner_top_right_default = /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(import_primitives28.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: [ 10043 /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_primitives28.G, { opacity: ".25", children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(import_primitives28.Path, { d: "M5.75 6A.25.25 0 0 1 6 5.75h3v-1.5H6A1.75 1.75 0 0 0 4.25 6v3h1.5V6ZM18 18.25h-3v1.5h3A1.75 1.75 0 0 0 19.75 18v-3h-1.5v3a.25.25 0 0 1-.25.25ZM18.25 9V6a.25.25 0 0 0-.25-.25h-3v-1.5h3c.966 0 1.75.784 1.75 1.75v3h-1.5ZM5.75 18v-3h-1.5v3c0 .966.784 1.75 1.75 1.75h3v-1.5H6a.25.25 0 0 1-.25-.25Z" }) }), 10044 /* @__PURE__ */ (0, import_jsx_runtime30.jsx)( 10045 import_primitives28.Path, 10046 { 10047 fillRule: "evenodd", 10048 clipRule: "evenodd", 10049 d: "M18.25 9V6a.25.25 0 0 0-.25-.25h-3v-1.5h3c.966 0 1.75.784 1.75 1.75v3h-1.5Z" 10050 } 10051 ) 10052 ] }); 10053 10054 // packages/icons/build-module/library/drag-handle.js 10055 var import_primitives29 = __toESM(require_primitives()); 10056 var import_jsx_runtime31 = __toESM(require_jsx_runtime()); 10057 var drag_handle_default = /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_primitives29.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_primitives29.Path, { d: "M8 7h2V5H8v2zm0 6h2v-2H8v2zm0 6h2v-2H8v2zm6-14v2h2V5h-2zm0 8h2v-2h-2v2zm0 6h2v-2h-2v2z" }) }); 10058 10059 // packages/icons/build-module/library/envelope.js 10060 var import_primitives30 = __toESM(require_primitives()); 10061 var import_jsx_runtime32 = __toESM(require_jsx_runtime()); 10062 var envelope_default = /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_primitives30.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)( 10063 import_primitives30.Path, 10064 { 10065 fillRule: "evenodd", 10066 clipRule: "evenodd", 10067 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" 10068 } 10069 ) }); 10070 10071 // packages/icons/build-module/library/error.js 10072 var import_primitives31 = __toESM(require_primitives()); 10073 var import_jsx_runtime33 = __toESM(require_jsx_runtime()); 10074 var error_default = /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_primitives31.SVG, { viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)( 10075 import_primitives31.Path, 10076 { 10077 fillRule: "evenodd", 10078 clipRule: "evenodd", 10079 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" 10080 } 10081 ) }); 10082 10083 // packages/icons/build-module/library/external.js 10084 var import_primitives32 = __toESM(require_primitives()); 10085 var import_jsx_runtime34 = __toESM(require_jsx_runtime()); 10086 var external_default = /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_primitives32.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_primitives32.Path, { d: "M19.5 4.5h-7V6h4.44l-5.97 5.97 1.06 1.06L18 7.06v4.44h1.5v-7Zm-13 1a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2v-3H17v3a.5.5 0 0 1-.5.5h-10a.5.5 0 0 1-.5-.5v-10a.5.5 0 0 1 .5-.5h3V5.5h-3Z" }) }); 10087 10088 // packages/icons/build-module/library/file.js 10089 var import_primitives33 = __toESM(require_primitives()); 10090 var import_jsx_runtime35 = __toESM(require_jsx_runtime()); 10091 var file_default = /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(import_primitives33.SVG, { viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)( 10092 import_primitives33.Path, 10093 { 10094 fillRule: "evenodd", 10095 clipRule: "evenodd", 10096 d: "M12.848 8a1 1 0 0 1-.914-.594l-.723-1.63a.5.5 0 0 0-.447-.276H5a.5.5 0 0 0-.5.5v11.5a.5.5 0 0 0 .5.5h14a.5.5 0 0 0 .5-.5v-9A.5.5 0 0 0 19 8h-6.152Zm.612-1.5a.5.5 0 0 1-.462-.31l-.445-1.084A2 2 0 0 0 10.763 4H5a2 2 0 0 0-2 2v11.5a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-9a2 2 0 0 0-2-2h-5.54Z" 10097 } 10098 ) }); 10099 10100 // packages/icons/build-module/library/filter.js 10101 var import_primitives34 = __toESM(require_primitives()); 10102 var import_jsx_runtime36 = __toESM(require_jsx_runtime()); 10103 var filter_default = /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_primitives34.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_primitives34.Path, { d: "M12 4 4 19h16L12 4zm0 3.2 5.5 10.3H12V7.2z" }) }); 10104 10105 // packages/icons/build-module/library/format-capitalize.js 10106 var import_primitives35 = __toESM(require_primitives()); 10107 var import_jsx_runtime37 = __toESM(require_jsx_runtime()); 10108 var format_capitalize_default = /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_primitives35.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_primitives35.Path, { d: "M7.1 6.8L3.1 18h1.6l1.1-3h4.3l1.1 3h1.6l-4-11.2H7.1zm-.8 6.8L8 8.9l1.7 4.7H6.3zm14.5-1.5c-.3-.6-.7-1.1-1.2-1.5-.6-.4-1.2-.6-1.9-.6-.5 0-.9.1-1.4.3-.4.2-.8.5-1.1.8V6h-1.4v12h1.3l.2-1c.2.4.6.6 1 .8.4.2.9.3 1.4.3.7 0 1.2-.2 1.8-.5.5-.4 1-.9 1.3-1.5.3-.6.5-1.3.5-2.1-.1-.6-.2-1.3-.5-1.9zm-1.7 4c-.4.5-.9.8-1.6.8s-1.2-.2-1.7-.7c-.4-.5-.7-1.2-.7-2.1 0-.9.2-1.6.7-2.1.4-.5 1-.7 1.7-.7s1.2.3 1.6.8c.4.5.6 1.2.6 2 .1.8-.2 1.4-.6 2z" }) }); 10109 10110 // packages/icons/build-module/library/format-lowercase.js 10111 var import_primitives36 = __toESM(require_primitives()); 10112 var import_jsx_runtime38 = __toESM(require_jsx_runtime()); 10113 var format_lowercase_default = /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_primitives36.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_primitives36.Path, { d: "M11 16.8c-.1-.1-.2-.3-.3-.5v-2.6c0-.9-.1-1.7-.3-2.2-.2-.5-.5-.9-.9-1.2-.4-.2-.9-.3-1.6-.3-.5 0-1 .1-1.5.2s-.9.3-1.2.6l.2 1.2c.4-.3.7-.4 1.1-.5.3-.1.7-.2 1-.2.6 0 1 .1 1.3.4.3.2.4.7.4 1.4-1.2 0-2.3.2-3.3.7s-1.4 1.1-1.4 2.1c0 .7.2 1.2.7 1.6.4.4 1 .6 1.8.6.9 0 1.7-.4 2.4-1.2.1.3.2.5.4.7.1.2.3.3.6.4.3.1.6.1 1.1.1h.1l.2-1.2h-.1c-.4.1-.6 0-.7-.1zM9.2 16c-.2.3-.5.6-.9.8-.3.1-.7.2-1.1.2-.4 0-.7-.1-.9-.3-.2-.2-.3-.5-.3-.9 0-.6.2-1 .7-1.3.5-.3 1.3-.4 2.5-.5v2zm10.6-3.9c-.3-.6-.7-1.1-1.2-1.5-.6-.4-1.2-.6-1.9-.6-.5 0-.9.1-1.4.3-.4.2-.8.5-1.1.8V6h-1.4v12h1.3l.2-1c.2.4.6.6 1 .8.4.2.9.3 1.4.3.7 0 1.2-.2 1.8-.5.5-.4 1-.9 1.3-1.5.3-.6.5-1.3.5-2.1-.1-.6-.2-1.3-.5-1.9zm-1.7 4c-.4.5-.9.8-1.6.8s-1.2-.2-1.7-.7c-.4-.5-.7-1.2-.7-2.1 0-.9.2-1.6.7-2.1.4-.5 1-.7 1.7-.7s1.2.3 1.6.8c.4.5.6 1.2.6 2s-.2 1.4-.6 2z" }) }); 10114 10115 // packages/icons/build-module/library/format-strikethrough.js 10116 var import_primitives37 = __toESM(require_primitives()); 10117 var import_jsx_runtime39 = __toESM(require_jsx_runtime()); 10118 var format_strikethrough_default = /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_primitives37.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_primitives37.Path, { d: "M9.1 9v-.5c0-.6.2-1.1.7-1.4.5-.3 1.2-.5 2-.5.7 0 1.4.1 2.1.3.7.2 1.4.5 2.1.9l.2-1.9c-.6-.3-1.2-.5-1.9-.7-.8-.1-1.6-.2-2.4-.2-1.5 0-2.7.3-3.6 1-.8.7-1.2 1.5-1.2 2.6V9h2zM20 12H4v1h8.3c.3.1.6.2.8.3.5.2.9.5 1.1.8.3.3.4.7.4 1.2 0 .7-.2 1.1-.8 1.5-.5.3-1.2.5-2.1.5-.8 0-1.6-.1-2.4-.3-.8-.2-1.5-.5-2.2-.8L7 18.1c.5.2 1.2.4 2 .6.8.2 1.6.3 2.4.3 1.7 0 3-.3 3.9-1 .9-.7 1.3-1.6 1.3-2.8 0-.9-.2-1.7-.7-2.2H20v-1z" }) }); 10119 10120 // packages/icons/build-module/library/format-underline.js 10121 var import_primitives38 = __toESM(require_primitives()); 10122 var import_jsx_runtime40 = __toESM(require_jsx_runtime()); 10123 var format_underline_default = /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(import_primitives38.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(import_primitives38.Path, { d: "M7 18v1h10v-1H7zm5-2c1.5 0 2.6-.4 3.4-1.2.8-.8 1.1-2 1.1-3.5V5H15v5.8c0 1.2-.2 2.1-.6 2.8-.4.7-1.2 1-2.4 1s-2-.3-2.4-1c-.4-.7-.6-1.6-.6-2.8V5H7.5v6.2c0 1.5.4 2.7 1.1 3.5.8.9 1.9 1.3 3.4 1.3z" }) }); 10124 10125 // packages/icons/build-module/library/format-uppercase.js 10126 var import_primitives39 = __toESM(require_primitives()); 10127 var import_jsx_runtime41 = __toESM(require_jsx_runtime()); 10128 var format_uppercase_default = /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(import_primitives39.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(import_primitives39.Path, { d: "M6.1 6.8L2.1 18h1.6l1.1-3h4.3l1.1 3h1.6l-4-11.2H6.1zm-.8 6.8L7 8.9l1.7 4.7H5.3zm15.1-.7c-.4-.5-.9-.8-1.6-1 .4-.2.7-.5.8-.9.2-.4.3-.9.3-1.4 0-.9-.3-1.6-.8-2-.6-.5-1.3-.7-2.4-.7h-3.5V18h4.2c1.1 0 2-.3 2.6-.8.6-.6 1-1.4 1-2.4-.1-.8-.3-1.4-.6-1.9zm-5.7-4.7h1.8c.6 0 1.1.1 1.4.4.3.2.5.7.5 1.3 0 .6-.2 1.1-.5 1.3-.3.2-.8.4-1.4.4h-1.8V8.2zm4 8c-.4.3-.9.5-1.5.5h-2.6v-3.8h2.6c1.4 0 2 .6 2 1.9.1.6-.1 1-.5 1.4z" }) }); 10129 10130 // packages/icons/build-module/library/fullscreen.js 10131 var import_primitives40 = __toESM(require_primitives()); 10132 var import_jsx_runtime42 = __toESM(require_jsx_runtime()); 10133 var fullscreen_default = /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_primitives40.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_primitives40.Path, { d: "M6 4a2 2 0 0 0-2 2v3h1.5V6a.5.5 0 0 1 .5-.5h3V4H6Zm3 14.5H6a.5.5 0 0 1-.5-.5v-3H4v3a2 2 0 0 0 2 2h3v-1.5Zm6 1.5v-1.5h3a.5.5 0 0 0 .5-.5v-3H20v3a2 2 0 0 1-2 2h-3Zm3-16a2 2 0 0 1 2 2v3h-1.5V6a.5.5 0 0 0-.5-.5h-3V4h3Z" }) }); 10134 10135 // packages/icons/build-module/library/globe.js 10136 var import_primitives41 = __toESM(require_primitives()); 10137 var import_jsx_runtime43 = __toESM(require_jsx_runtime()); 10138 var globe_default = /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_primitives41.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_primitives41.Path, { d: "M12 4c-4.4 0-8 3.6-8 8s3.6 8 8 8 8-3.6 8-8-3.6-8-8-8Zm6.5 8c0 .6 0 1.2-.2 1.8h-2.7c0-.6.2-1.1.2-1.8s0-1.2-.2-1.8h2.7c.2.6.2 1.1.2 1.8Zm-.9-3.2h-2.4c-.3-.9-.7-1.8-1.1-2.4-.1-.2-.2-.4-.3-.5 1.6.5 3 1.6 3.8 3ZM12.8 17c-.3.5-.6 1-.8 1.3-.2-.3-.5-.8-.8-1.3-.3-.5-.6-1.1-.8-1.7h3.3c-.2.6-.5 1.2-.8 1.7Zm-2.9-3.2c-.1-.6-.2-1.1-.2-1.8s0-1.2.2-1.8H14c.1.6.2 1.1.2 1.8s0 1.2-.2 1.8H9.9ZM11.2 7c.3-.5.6-1 .8-1.3.2.3.5.8.8 1.3.3.5.6 1.1.8 1.7h-3.3c.2-.6.5-1.2.8-1.7Zm-1-1.2c-.1.2-.2.3-.3.5-.4.7-.8 1.5-1.1 2.4H6.4c.8-1.4 2.2-2.5 3.8-3Zm-1.8 8H5.7c-.2-.6-.2-1.1-.2-1.8s0-1.2.2-1.8h2.7c0 .6-.2 1.1-.2 1.8s0 1.2.2 1.8Zm-2 1.4h2.4c.3.9.7 1.8 1.1 2.4.1.2.2.4.3.5-1.6-.5-3-1.6-3.8-3Zm7.4 3c.1-.2.2-.3.3-.5.4-.7.8-1.5 1.1-2.4h2.4c-.8 1.4-2.2 2.5-3.8 3Z" }) }); 10139 10140 // packages/icons/build-module/library/grid.js 10141 var import_primitives42 = __toESM(require_primitives()); 10142 var import_jsx_runtime44 = __toESM(require_jsx_runtime()); 10143 var grid_default = /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(import_primitives42.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)( 10144 import_primitives42.Path, 10145 { 10146 d: "m3 5c0-1.10457.89543-2 2-2h13.5c1.1046 0 2 .89543 2 2v13.5c0 1.1046-.8954 2-2 2h-13.5c-1.10457 0-2-.8954-2-2zm2-.5h6v6.5h-6.5v-6c0-.27614.22386-.5.5-.5zm-.5 8v6c0 .2761.22386.5.5.5h6v-6.5zm8 0v6.5h6c.2761 0 .5-.2239.5-.5v-6zm0-8v6.5h6.5v-6c0-.27614-.2239-.5-.5-.5z", 10147 fillRule: "evenodd", 10148 clipRule: "evenodd" 10149 } 10150 ) }); 10151 10152 // packages/icons/build-module/library/group.js 10153 var import_primitives43 = __toESM(require_primitives()); 10154 var import_jsx_runtime45 = __toESM(require_jsx_runtime()); 10155 var group_default = /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(import_primitives43.SVG, { viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(import_primitives43.Path, { d: "M18 4h-7c-1.1 0-2 .9-2 2v3H6c-1.1 0-2 .9-2 2v7c0 1.1.9 2 2 2h7c1.1 0 2-.9 2-2v-3h3c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm-4.5 14c0 .3-.2.5-.5.5H6c-.3 0-.5-.2-.5-.5v-7c0-.3.2-.5.5-.5h3V13c0 1.1.9 2 2 2h2.5v3zm0-4.5H11c-.3 0-.5-.2-.5-.5v-2.5H13c.3 0 .5.2.5.5v2.5zm5-.5c0 .3-.2.5-.5.5h-3V11c0-1.1-.9-2-2-2h-2.5V6c0-.3.2-.5.5-.5h7c.3 0 .5.2.5.5v7z" }) }); 10156 10157 // packages/icons/build-module/library/heading-level-1.js 10158 var import_primitives44 = __toESM(require_primitives()); 10159 var import_jsx_runtime46 = __toESM(require_jsx_runtime()); 10160 var heading_level_1_default = /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(import_primitives44.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(import_primitives44.Path, { d: "M17.6 7c-.6.9-1.5 1.7-2.6 2v1h2v7h2V7h-1.4zM11 11H7V7H5v10h2v-4h4v4h2V7h-2v4z" }) }); 10161 10162 // packages/icons/build-module/library/heading-level-2.js 10163 var import_primitives45 = __toESM(require_primitives()); 10164 var import_jsx_runtime47 = __toESM(require_jsx_runtime()); 10165 var heading_level_2_default = /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(import_primitives45.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(import_primitives45.Path, { d: "M9 11.1H5v-4H3v10h2v-4h4v4h2v-10H9v4zm8 4c.5-.4.6-.6 1.1-1.1.4-.4.8-.8 1.2-1.3.3-.4.6-.8.9-1.3.2-.4.3-.8.3-1.3 0-.4-.1-.9-.3-1.3-.2-.4-.4-.7-.8-1-.3-.3-.7-.5-1.2-.6-.5-.2-1-.2-1.5-.2-.4 0-.7 0-1.1.1-.3.1-.7.2-1 .3-.3.1-.6.3-.9.5-.3.2-.6.4-.8.7l1.2 1.2c.3-.3.6-.5 1-.7.4-.2.7-.3 1.2-.3s.9.1 1.3.4c.3.3.5.7.5 1.1 0 .4-.1.8-.4 1.1-.3.5-.6.9-1 1.2-.4.4-1 .9-1.6 1.4-.6.5-1.4 1.1-2.2 1.6v1.5h8v-2H17z" }) }); 10166 10167 // packages/icons/build-module/library/heading-level-3.js 10168 var import_primitives46 = __toESM(require_primitives()); 10169 var import_jsx_runtime48 = __toESM(require_jsx_runtime()); 10170 var heading_level_3_default = /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(import_primitives46.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(import_primitives46.Path, { d: "M9 11H5V7H3v10h2v-4h4v4h2V7H9v4zm11.3 1.7c-.4-.4-1-.7-1.6-.8v-.1c.6-.2 1.1-.5 1.5-.9.3-.4.5-.8.5-1.3 0-.4-.1-.8-.3-1.1-.2-.3-.5-.6-.8-.8-.4-.2-.8-.4-1.2-.5-.6-.1-1.1-.2-1.6-.2-.6 0-1.3.1-1.8.3s-1.1.5-1.6.9l1.2 1.4c.4-.2.7-.4 1.1-.6.3-.2.7-.3 1.1-.3.4 0 .8.1 1.1.3.3.2.4.5.4.8 0 .4-.2.7-.6.9-.7.3-1.5.5-2.2.4v1.6c.5 0 1 0 1.5.1.3.1.7.2 1 .3.2.1.4.2.5.4s.1.4.1.6c0 .3-.2.7-.5.8-.4.2-.9.3-1.4.3s-1-.1-1.4-.3c-.4-.2-.8-.4-1.2-.7L13 15.6c.5.4 1 .8 1.6 1 .7.3 1.5.4 2.3.4.6 0 1.1-.1 1.6-.2.4-.1.9-.2 1.3-.5.4-.2.7-.5.9-.9.2-.4.3-.8.3-1.2 0-.6-.3-1.1-.7-1.5z" }) }); 10171 10172 // packages/icons/build-module/library/heading-level-4.js 10173 var import_primitives47 = __toESM(require_primitives()); 10174 var import_jsx_runtime49 = __toESM(require_jsx_runtime()); 10175 var heading_level_4_default = /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(import_primitives47.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(import_primitives47.Path, { d: "M20 13V7h-3l-4 6v2h5v2h2v-2h1v-2h-1zm-2 0h-2.8L18 9v4zm-9-2H5V7H3v10h2v-4h4v4h2V7H9v4z" }) }); 10176 10177 // packages/icons/build-module/library/heading-level-5.js 10178 var import_primitives48 = __toESM(require_primitives()); 10179 var import_jsx_runtime50 = __toESM(require_jsx_runtime()); 10180 var heading_level_5_default = /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(import_primitives48.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(import_primitives48.Path, { d: "M9 11H5V7H3v10h2v-4h4v4h2V7H9v4zm11.7 1.2c-.2-.3-.5-.7-.8-.9-.3-.3-.7-.5-1.1-.6-.5-.1-.9-.2-1.4-.2-.2 0-.5.1-.7.1-.2.1-.5.1-.7.2l.1-1.9h4.3V7H14l-.3 5 1 .6.5-.2.4-.1c.1-.1.3-.1.4-.1h.5c.5 0 1 .1 1.4.4.4.2.6.7.6 1.1 0 .4-.2.8-.6 1.1-.4.3-.9.4-1.4.4-.4 0-.9-.1-1.3-.3-.4-.2-.7-.4-1.1-.7 0 0-1.1 1.4-1 1.5.5.4 1 .8 1.6 1 .7.3 1.5.4 2.3.4.5 0 1-.1 1.5-.3s.9-.4 1.3-.7c.4-.3.7-.7.9-1.1s.3-.9.3-1.4-.1-1-.3-1.4z" }) }); 10181 10182 // packages/icons/build-module/library/heading-level-6.js 10183 var import_primitives49 = __toESM(require_primitives()); 10184 var import_jsx_runtime51 = __toESM(require_jsx_runtime()); 10185 var heading_level_6_default = /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(import_primitives49.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(import_primitives49.Path, { d: "M20.7 12.4c-.2-.3-.4-.6-.7-.9s-.6-.5-1-.6c-.4-.2-.8-.2-1.2-.2-.5 0-.9.1-1.3.3s-.8.5-1.2.8c0-.5 0-.9.2-1.4l.6-.9c.2-.2.5-.4.8-.5.6-.2 1.3-.2 1.9 0 .3.1.6.3.8.5 0 0 1.3-1.3 1.3-1.4-.4-.3-.9-.6-1.4-.8-.6-.2-1.3-.3-2-.3-.6 0-1.1.1-1.7.4-.5.2-1 .5-1.4.9-.4.4-.8 1-1 1.6-.3.7-.4 1.5-.4 2.3s.1 1.5.3 2.1c.2.6.6 1.1 1 1.5.4.4.9.7 1.4.9 1 .3 2 .3 3 0 .4-.1.8-.3 1.2-.6.3-.3.6-.6.8-1 .2-.5.3-.9.3-1.4s-.1-.9-.3-1.3zm-2 2.1c-.1.2-.3.4-.4.5-.1.1-.3.2-.5.2-.2.1-.4.1-.6.1-.2.1-.5 0-.7-.1-.2 0-.3-.2-.5-.3-.1-.2-.3-.4-.4-.6-.2-.3-.3-.7-.3-1 .3-.3.6-.5 1-.7.3-.1.7-.2 1-.2.4 0 .8.1 1.1.3.3.3.4.7.4 1.1 0 .2 0 .5-.1.7zM9 11H5V7H3v10h2v-4h4v4h2V7H9v4z" }) }); 10186 10187 // packages/icons/build-module/library/home.js 10188 var import_primitives50 = __toESM(require_primitives()); 10189 var import_jsx_runtime52 = __toESM(require_jsx_runtime()); 10190 var home_default = /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(import_primitives50.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(import_primitives50.Path, { d: "M12 4L4 7.9V20h16V7.9L12 4zm6.5 14.5H14V13h-4v5.5H5.5V8.8L12 5.7l6.5 3.1v9.7z" }) }); 10191 10192 // packages/icons/build-module/library/image.js 10193 var import_primitives51 = __toESM(require_primitives()); 10194 var import_jsx_runtime53 = __toESM(require_jsx_runtime()); 10195 var image_default = /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(import_primitives51.SVG, { viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(import_primitives51.Path, { d: "M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zM5 4.5h14c.3 0 .5.2.5.5v8.4l-3-2.9c-.3-.3-.8-.3-1 0L11.9 14 9 12c-.3-.2-.6-.2-.8 0l-3.6 2.6V5c-.1-.3.1-.5.4-.5zm14 15H5c-.3 0-.5-.2-.5-.5v-2.4l4.1-3 3 1.9c.3.2.7.2.9-.1L16 12l3.5 3.4V19c0 .3-.2.5-.5.5z" }) }); 10196 10197 // packages/icons/build-module/library/info.js 10198 var import_primitives52 = __toESM(require_primitives()); 10199 var import_jsx_runtime54 = __toESM(require_jsx_runtime()); 10200 var info_default = /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(import_primitives52.SVG, { viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)( 10201 import_primitives52.Path, 10202 { 10203 fillRule: "evenodd", 10204 clipRule: "evenodd", 10205 d: "M5.5 12a6.5 6.5 0 1 0 13 0 6.5 6.5 0 0 0-13 0ZM12 4a8 8 0 1 0 0 16 8 8 0 0 0 0-16Zm.75 4v1.5h-1.5V8h1.5Zm0 8v-5h-1.5v5h1.5Z" 10206 } 10207 ) }); 10208 10209 // packages/icons/build-module/library/justify-bottom.js 10210 var import_primitives53 = __toESM(require_primitives()); 10211 var import_jsx_runtime55 = __toESM(require_jsx_runtime()); 10212 var justify_bottom_default = /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(import_primitives53.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(import_primitives53.Path, { d: "M15 4H9v11h6V4zM4 18.5V20h16v-1.5H4z" }) }); 10213 10214 // packages/icons/build-module/library/justify-center-vertical.js 10215 var import_primitives54 = __toESM(require_primitives()); 10216 var import_jsx_runtime56 = __toESM(require_jsx_runtime()); 10217 var justify_center_vertical_default = /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(import_primitives54.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(import_primitives54.Path, { d: "M20 11h-5V4H9v7H4v1.5h5V20h6v-7.5h5z" }) }); 10218 10219 // packages/icons/build-module/library/justify-center.js 10220 var import_primitives55 = __toESM(require_primitives()); 10221 var import_jsx_runtime57 = __toESM(require_jsx_runtime()); 10222 var justify_center_default = /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(import_primitives55.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(import_primitives55.Path, { d: "M12.5 15v5H11v-5H4V9h7V4h1.5v5h7v6h-7Z" }) }); 10223 10224 // packages/icons/build-module/library/justify-left.js 10225 var import_primitives56 = __toESM(require_primitives()); 10226 var import_jsx_runtime58 = __toESM(require_jsx_runtime()); 10227 var justify_left_default = /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(import_primitives56.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(import_primitives56.Path, { d: "M9 9v6h11V9H9zM4 20h1.5V4H4v16z" }) }); 10228 10229 // packages/icons/build-module/library/justify-right.js 10230 var import_primitives57 = __toESM(require_primitives()); 10231 var import_jsx_runtime59 = __toESM(require_jsx_runtime()); 10232 var justify_right_default = /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(import_primitives57.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime59.jsx)(import_primitives57.Path, { d: "M4 15h11V9H4v6zM18.5 4v16H20V4h-1.5z" }) }); 10233 10234 // packages/icons/build-module/library/justify-space-between-vertical.js 10235 var import_primitives58 = __toESM(require_primitives()); 10236 var import_jsx_runtime60 = __toESM(require_jsx_runtime()); 10237 var justify_space_between_vertical_default = /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(import_primitives58.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(import_primitives58.Path, { d: "M7 4H17V8L7 8V4ZM7 16L17 16V20L7 20V16ZM20 11.25H4V12.75H20V11.25Z" }) }); 10238 10239 // packages/icons/build-module/library/justify-space-between.js 10240 var import_primitives59 = __toESM(require_primitives()); 10241 var import_jsx_runtime61 = __toESM(require_jsx_runtime()); 10242 var justify_space_between_default = /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(import_primitives59.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(import_primitives59.Path, { d: "M9 15h6V9H9v6zm-5 5h1.5V4H4v16zM18.5 4v16H20V4h-1.5z" }) }); 10243 10244 // packages/icons/build-module/library/justify-stretch-vertical.js 10245 var import_primitives60 = __toESM(require_primitives()); 10246 var import_jsx_runtime62 = __toESM(require_jsx_runtime()); 10247 var justify_stretch_vertical_default = /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(import_primitives60.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime62.jsx)(import_primitives60.Path, { d: "M4 4L20 4L20 5.5L4 5.5L4 4ZM10 7L14 7L14 17L10 17L10 7ZM20 18.5L4 18.5L4 20L20 20L20 18.5Z" }) }); 10248 10249 // packages/icons/build-module/library/justify-stretch.js 10250 var import_primitives61 = __toESM(require_primitives()); 10251 var import_jsx_runtime63 = __toESM(require_jsx_runtime()); 10252 var justify_stretch_default = /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(import_primitives61.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(import_primitives61.Path, { d: "M4 4H5.5V20H4V4ZM7 10L17 10V14L7 14V10ZM20 4H18.5V20H20V4Z" }) }); 10253 10254 // packages/icons/build-module/library/justify-top.js 10255 var import_primitives62 = __toESM(require_primitives()); 10256 var import_jsx_runtime64 = __toESM(require_jsx_runtime()); 10257 var justify_top_default = /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(import_primitives62.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime64.jsx)(import_primitives62.Path, { d: "M9 20h6V9H9v11zM4 4v1.5h16V4H4z" }) }); 10258 10259 // packages/icons/build-module/library/keyboard-return.js 10260 var import_primitives63 = __toESM(require_primitives()); 10261 var import_jsx_runtime65 = __toESM(require_jsx_runtime()); 10262 var keyboard_return_default = /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(import_primitives63.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(import_primitives63.Path, { d: "m6.734 16.106 2.176-2.38-1.093-1.028-3.846 4.158 3.846 4.158 1.093-1.028-2.176-2.38h2.811c1.125 0 2.25.03 3.374 0 1.428-.001 3.362-.25 4.963-1.277 1.66-1.065 2.868-2.906 2.868-5.859 0-2.479-1.327-4.896-3.65-5.93-1.82-.813-3.044-.8-4.806-.788l-.567.002v1.5c.184 0 .368 0 .553-.002 1.82-.007 2.704-.014 4.21.657 1.854.827 2.76 2.657 2.76 4.561 0 2.472-.973 3.824-2.178 4.596-1.258.807-2.864 1.04-4.163 1.04h-.02c-1.115.03-2.229 0-3.344 0H6.734Z" }) }); 10263 10264 // packages/icons/build-module/library/layout.js 10265 var import_primitives64 = __toESM(require_primitives()); 10266 var import_jsx_runtime66 = __toESM(require_jsx_runtime()); 10267 var layout_default = /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(import_primitives64.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(import_primitives64.Path, { d: "M18 5.5H6a.5.5 0 00-.5.5v3h13V6a.5.5 0 00-.5-.5zm.5 5H10v8h8a.5.5 0 00.5-.5v-7.5zm-10 0h-3V18a.5.5 0 00.5.5h2.5v-8zM6 4h12a2 2 0 012 2v12a2 2 0 01-2 2H6a2 2 0 01-2-2V6a2 2 0 012-2z" }) }); 10268 10269 // packages/icons/build-module/library/link-off.js 10270 var import_primitives65 = __toESM(require_primitives()); 10271 var import_jsx_runtime67 = __toESM(require_jsx_runtime()); 10272 var link_off_default = /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(import_primitives65.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(import_primitives65.Path, { d: "M17.031 4.703 15.576 4l-1.56 3H14v.03l-2.324 4.47H9.5V13h1.396l-1.502 2.889h-.95a3.694 3.694 0 0 1 0-7.389H10V7H8.444a5.194 5.194 0 1 0 0 10.389h.17L7.5 19.53l1.416.719L15.049 8.5h.507a3.694 3.694 0 0 1 0 7.39H14v1.5h1.556a5.194 5.194 0 0 0 .273-10.383l1.202-2.304Z" }) }); 10273 10274 // packages/icons/build-module/library/link.js 10275 var import_primitives66 = __toESM(require_primitives()); 10276 var import_jsx_runtime68 = __toESM(require_jsx_runtime()); 10277 var link_default = /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(import_primitives66.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime68.jsx)(import_primitives66.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" }) }); 10278 10279 // packages/icons/build-module/library/list-view.js 10280 var import_primitives67 = __toESM(require_primitives()); 10281 var import_jsx_runtime69 = __toESM(require_jsx_runtime()); 10282 var list_view_default = /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(import_primitives67.SVG, { viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(import_primitives67.Path, { d: "M3 6h11v1.5H3V6Zm3.5 5.5h11V13h-11v-1.5ZM21 17H10v1.5h11V17Z" }) }); 10283 10284 // packages/icons/build-module/library/lock-outline.js 10285 var import_primitives68 = __toESM(require_primitives()); 10286 var import_jsx_runtime70 = __toESM(require_jsx_runtime()); 10287 var lock_outline_default = /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(import_primitives68.SVG, { viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(import_primitives68.Path, { d: "M17 10h-1.2V7c0-2.1-1.7-3.8-3.8-3.8-2.1 0-3.8 1.7-3.8 3.8v3H7c-.6 0-1 .4-1 1v8c0 .6.4 1 1 1h10c.6 0 1-.4 1-1v-8c0-.6-.4-1-1-1zM9.8 7c0-1.2 1-2.2 2.2-2.2 1.2 0 2.2 1 2.2 2.2v3H9.8V7zm6.7 11.5h-9v-7h9v7z" }) }); 10288 10289 // packages/icons/build-module/library/lock-small.js 10290 var import_primitives69 = __toESM(require_primitives()); 10291 var import_jsx_runtime71 = __toESM(require_jsx_runtime()); 10292 var lock_small_default = /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(import_primitives69.SVG, { viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ (0, import_jsx_runtime71.jsx)( 10293 import_primitives69.Path, 10294 { 10295 fillRule: "evenodd", 10296 clipRule: "evenodd", 10297 d: "M15 11h-.2V9c0-1.5-1.2-2.8-2.8-2.8S9.2 7.5 9.2 9v2H9c-.6 0-1 .4-1 1v4c0 .6.4 1 1 1h6c.6 0 1-.4 1-1v-4c0-.6-.4-1-1-1zm-1.8 0h-2.5V9c0-.7.6-1.2 1.2-1.2s1.2.6 1.2 1.2v2z" 10298 } 10299 ) }); 10300 10301 // packages/icons/build-module/library/lock.js 10302 var import_primitives70 = __toESM(require_primitives()); 10303 var import_jsx_runtime72 = __toESM(require_jsx_runtime()); 10304 var lock_default = /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(import_primitives70.SVG, { viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(import_primitives70.Path, { d: "M17 10h-1.2V7c0-2.1-1.7-3.8-3.8-3.8-2.1 0-3.8 1.7-3.8 3.8v3H7c-.6 0-1 .4-1 1v8c0 .6.4 1 1 1h10c.6 0 1-.4 1-1v-8c0-.6-.4-1-1-1zm-2.8 0H9.8V7c0-1.2 1-2.2 2.2-2.2s2.2 1 2.2 2.2v3z" }) }); 10305 10306 // packages/icons/build-module/library/media.js 10307 var import_primitives71 = __toESM(require_primitives()); 10308 var import_jsx_runtime73 = __toESM(require_jsx_runtime()); 10309 var media_default = /* @__PURE__ */ (0, import_jsx_runtime73.jsxs)(import_primitives71.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: [ 10310 /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(import_primitives71.Path, { d: "m7 6.5 4 2.5-4 2.5z" }), 10311 /* @__PURE__ */ (0, import_jsx_runtime73.jsx)( 10312 import_primitives71.Path, 10313 { 10314 fillRule: "evenodd", 10315 clipRule: "evenodd", 10316 d: "m5 3c-1.10457 0-2 .89543-2 2v14c0 1.1046.89543 2 2 2h14c1.1046 0 2-.8954 2-2v-14c0-1.10457-.8954-2-2-2zm14 1.5h-14c-.27614 0-.5.22386-.5.5v10.7072l3.62953-2.6465c.25108-.1831.58905-.1924.84981-.0234l2.92666 1.8969 3.5712-3.4719c.2911-.2831.7545-.2831 1.0456 0l2.9772 2.8945v-9.3568c0-.27614-.2239-.5-.5-.5zm-14.5 14.5v-1.4364l4.09643-2.987 2.99567 1.9417c.2936.1903.6798.1523.9307-.0917l3.4772-3.3806 3.4772 3.3806.0228-.0234v2.5968c0 .2761-.2239.5-.5.5h-14c-.27614 0-.5-.2239-.5-.5z" 10317 } 10318 ) 10319 ] }); 10320 10321 // packages/icons/build-module/library/mobile.js 10322 var import_primitives72 = __toESM(require_primitives()); 10323 var import_jsx_runtime74 = __toESM(require_jsx_runtime()); 10324 var mobile_default = /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(import_primitives72.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime74.jsx)(import_primitives72.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" }) }); 10325 10326 // packages/icons/build-module/library/more-vertical.js 10327 var import_primitives73 = __toESM(require_primitives()); 10328 var import_jsx_runtime75 = __toESM(require_jsx_runtime()); 10329 var more_vertical_default = /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(import_primitives73.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(import_primitives73.Path, { d: "M13 19h-2v-2h2v2zm0-6h-2v-2h2v2zm0-6h-2V5h2v2z" }) }); 10330 10331 // packages/icons/build-module/library/page.js 10332 var import_primitives74 = __toESM(require_primitives()); 10333 var import_jsx_runtime76 = __toESM(require_jsx_runtime()); 10334 var page_default = /* @__PURE__ */ (0, import_jsx_runtime76.jsxs)(import_primitives74.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: [ 10335 /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(import_primitives74.Path, { d: "M15.5 7.5h-7V9h7V7.5Zm-7 3.5h7v1.5h-7V11Zm7 3.5h-7V16h7v-1.5Z" }), 10336 /* @__PURE__ */ (0, import_jsx_runtime76.jsx)(import_primitives74.Path, { d: "M17 4H7a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2ZM7 5.5h10a.5.5 0 0 1 .5.5v12a.5.5 0 0 1-.5.5H7a.5.5 0 0 1-.5-.5V6a.5.5 0 0 1 .5-.5Z" }) 10337 ] }); 10338 10339 // packages/icons/build-module/library/paragraph.js 10340 var import_primitives75 = __toESM(require_primitives()); 10341 var import_jsx_runtime77 = __toESM(require_jsx_runtime()); 10342 var paragraph_default = /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(import_primitives75.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime77.jsx)(import_primitives75.Path, { d: "m9.99609 14v-.2251l.00391.0001v6.225h1.5v-14.5h2.5v14.5h1.5v-14.5h3v-1.5h-8.50391c-2.76142 0-5 2.23858-5 5 0 2.7614 2.23858 5 5 5z" }) }); 10343 10344 // packages/icons/build-module/library/pencil.js 10345 var import_primitives76 = __toESM(require_primitives()); 10346 var import_jsx_runtime78 = __toESM(require_jsx_runtime()); 10347 var pencil_default = /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(import_primitives76.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(import_primitives76.Path, { d: "m19 7-3-3-8.5 8.5-1 4 4-1L19 7Zm-7 11.5H5V20h7v-1.5Z" }) }); 10348 10349 // packages/icons/build-module/library/pin-small.js 10350 var import_primitives77 = __toESM(require_primitives()); 10351 var import_jsx_runtime79 = __toESM(require_jsx_runtime()); 10352 var pin_small_default = /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(import_primitives77.SVG, { viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(import_primitives77.Path, { d: "M10.97 10.159a3.382 3.382 0 0 0-2.857.955l1.724 1.723-2.836 2.913L7 17h1.25l2.913-2.837 1.723 1.723a3.38 3.38 0 0 0 .606-.825c.33-.63.446-1.343.35-2.032L17 10.695 13.305 7l-2.334 3.159Z" }) }); 10353 10354 // packages/icons/build-module/library/plus.js 10355 var import_primitives78 = __toESM(require_primitives()); 10356 var import_jsx_runtime80 = __toESM(require_jsx_runtime()); 10357 var plus_default = /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(import_primitives78.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(import_primitives78.Path, { d: "M11 12.5V17.5H12.5V12.5H17.5V11H12.5V6H11V11H6V12.5H11Z" }) }); 10358 10359 // packages/icons/build-module/library/position-center.js 10360 var import_primitives79 = __toESM(require_primitives()); 10361 var import_jsx_runtime81 = __toESM(require_jsx_runtime()); 10362 var position_center_default = /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(import_primitives79.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(import_primitives79.Path, { d: "M19 5.5H5V4h14v1.5ZM19 20H5v-1.5h14V20ZM7 9h10v6H7V9Z" }) }); 10363 10364 // packages/icons/build-module/library/position-left.js 10365 var import_primitives80 = __toESM(require_primitives()); 10366 var import_jsx_runtime82 = __toESM(require_jsx_runtime()); 10367 var position_left_default = /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(import_primitives80.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(import_primitives80.Path, { d: "M5 5.5h8V4H5v1.5ZM5 20h8v-1.5H5V20ZM19 9H5v6h14V9Z" }) }); 10368 10369 // packages/icons/build-module/library/position-right.js 10370 var import_primitives81 = __toESM(require_primitives()); 10371 var import_jsx_runtime83 = __toESM(require_jsx_runtime()); 10372 var position_right_default = /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(import_primitives81.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(import_primitives81.Path, { d: "M19 5.5h-8V4h8v1.5ZM19 20h-8v-1.5h8V20ZM5 9h14v6H5V9Z" }) }); 10373 10374 // packages/icons/build-module/library/post-featured-image.js 10375 var import_primitives82 = __toESM(require_primitives()); 10376 var import_jsx_runtime84 = __toESM(require_jsx_runtime()); 10377 var post_featured_image_default = /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(import_primitives82.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(import_primitives82.Path, { d: "M19 3H5c-.6 0-1 .4-1 1v7c0 .5.4 1 1 1h14c.5 0 1-.4 1-1V4c0-.6-.4-1-1-1zM5.5 10.5v-.4l1.8-1.3 1.3.8c.3.2.7.2.9-.1L11 8.1l2.4 2.4H5.5zm13 0h-2.9l-4-4c-.3-.3-.8-.3-1.1 0L8.9 8l-1.2-.8c-.3-.2-.6-.2-.9 0l-1.3 1V4.5h13v6zM4 20h9v-1.5H4V20zm0-4h16v-1.5H4V16z" }) }); 10378 10379 // packages/icons/build-module/library/post-list.js 10380 var import_primitives83 = __toESM(require_primitives()); 10381 var import_jsx_runtime85 = __toESM(require_jsx_runtime()); 10382 var post_list_default = /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(import_primitives83.SVG, { viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(import_primitives83.Path, { d: "M18 5.5H6a.5.5 0 0 0-.5.5v12a.5.5 0 0 0 .5.5h12a.5.5 0 0 0 .5-.5V6a.5.5 0 0 0-.5-.5ZM6 4h12a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2Zm1 5h1.5v1.5H7V9Zm1.5 4.5H7V15h1.5v-1.5ZM10 9h7v1.5h-7V9Zm7 4.5h-7V15h7v-1.5Z" }) }); 10383 10384 // packages/icons/build-module/library/post.js 10385 var import_primitives84 = __toESM(require_primitives()); 10386 var import_jsx_runtime86 = __toESM(require_jsx_runtime()); 10387 var post_default = /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(import_primitives84.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(import_primitives84.Path, { d: "m7.3 9.7 1.4 1.4c.2-.2.3-.3.4-.5 0 0 0-.1.1-.1.3-.5.4-1.1.3-1.6L12 7 9 4 7.2 6.5c-.6-.1-1.1 0-1.6.3 0 0-.1 0-.1.1-.3.1-.4.2-.6.4l1.4 1.4L4 11v1h1l2.3-2.3zM4 20h9v-1.5H4V20zm0-5.5V16h16v-1.5H4z" }) }); 10388 10389 // packages/icons/build-module/library/reset.js 10390 var import_primitives85 = __toESM(require_primitives()); 10391 var import_jsx_runtime87 = __toESM(require_jsx_runtime()); 10392 var reset_default = /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(import_primitives85.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(import_primitives85.Path, { d: "M7 11.5h10V13H7z" }) }); 10393 10394 // packages/icons/build-module/library/rotate-right.js 10395 var import_primitives86 = __toESM(require_primitives()); 10396 var import_jsx_runtime88 = __toESM(require_jsx_runtime()); 10397 var rotate_right_default = /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(import_primitives86.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(import_primitives86.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" }) }); 10398 10399 // packages/icons/build-module/library/row.js 10400 var import_primitives87 = __toESM(require_primitives()); 10401 var import_jsx_runtime89 = __toESM(require_jsx_runtime()); 10402 var row_default = /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(import_primitives87.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(import_primitives87.Path, { d: "M4 6.5h5a2 2 0 0 1 2 2v7a2 2 0 0 1-2 2H4V16h5a.5.5 0 0 0 .5-.5v-7A.5.5 0 0 0 9 8H4V6.5Zm16 0h-5a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h5V16h-5a.5.5 0 0 1-.5-.5v-7A.5.5 0 0 1 15 8h5V6.5Z" }) }); 10403 10404 // packages/icons/build-module/library/search.js 10405 var import_primitives88 = __toESM(require_primitives()); 10406 var import_jsx_runtime90 = __toESM(require_jsx_runtime()); 10407 var search_default = /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(import_primitives88.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime90.jsx)(import_primitives88.Path, { d: "M13 5c-3.3 0-6 2.7-6 6 0 1.4.5 2.7 1.3 3.7l-3.8 3.8 1.1 1.1 3.8-3.8c1 .8 2.3 1.3 3.7 1.3 3.3 0 6-2.7 6-6S16.3 5 13 5zm0 10.5c-2.5 0-4.5-2-4.5-4.5s2-4.5 4.5-4.5 4.5 2 4.5 4.5-2 4.5-4.5 4.5z" }) }); 10408 10409 // packages/icons/build-module/library/seen.js 10410 var import_primitives89 = __toESM(require_primitives()); 10411 var import_jsx_runtime91 = __toESM(require_jsx_runtime()); 10412 var seen_default = /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(import_primitives89.SVG, { viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(import_primitives89.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" }) }); 10413 10414 // packages/icons/build-module/library/settings.js 10415 var import_primitives90 = __toESM(require_primitives()); 10416 var import_jsx_runtime92 = __toESM(require_jsx_runtime()); 10417 var settings_default = /* @__PURE__ */ (0, import_jsx_runtime92.jsxs)(import_primitives90.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: [ 10418 /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(import_primitives90.Path, { d: "m19 7.5h-7.628c-.3089-.87389-1.1423-1.5-2.122-1.5-.97966 0-1.81309.62611-2.12197 1.5h-2.12803v1.5h2.12803c.30888.87389 1.14231 1.5 2.12197 1.5.9797 0 1.8131-.62611 2.122-1.5h7.628z" }), 10419 /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(import_primitives90.Path, { d: "m19 15h-2.128c-.3089-.8739-1.1423-1.5-2.122-1.5s-1.8131.6261-2.122 1.5h-7.628v1.5h7.628c.3089.8739 1.1423 1.5 2.122 1.5s1.8131-.6261 2.122-1.5h2.128z" }) 10420 ] }); 10421 10422 // packages/icons/build-module/library/shadow.js 10423 var import_primitives91 = __toESM(require_primitives()); 10424 var import_jsx_runtime93 = __toESM(require_jsx_runtime()); 10425 var shadow_default = /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(import_primitives91.SVG, { viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(import_primitives91.Path, { d: "M12 8c-2.2 0-4 1.8-4 4s1.8 4 4 4 4-1.8 4-4-1.8-4-4-4zm0 6.5c-1.4 0-2.5-1.1-2.5-2.5s1.1-2.5 2.5-2.5 2.5 1.1 2.5 2.5-1.1 2.5-2.5 2.5zM12.8 3h-1.5v3h1.5V3zm-1.6 18h1.5v-3h-1.5v3zm6.8-9.8v1.5h3v-1.5h-3zm-12 0H3v1.5h3v-1.5zm9.7 5.6 2.1 2.1 1.1-1.1-2.1-2.1-1.1 1.1zM8.3 7.2 6.2 5.1 5.1 6.2l2.1 2.1 1.1-1.1zM5.1 17.8l1.1 1.1 2.1-2.1-1.1-1.1-2.1 2.1zM18.9 6.2l-1.1-1.1-2.1 2.1 1.1 1.1 2.1-2.1z" }) }); 10426 10427 // packages/icons/build-module/library/sides-all.js 10428 var import_primitives92 = __toESM(require_primitives()); 10429 var import_jsx_runtime94 = __toESM(require_jsx_runtime()); 10430 var sides_all_default = /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(import_primitives92.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(import_primitives92.Path, { d: "m7.5 6h9v-1.5h-9zm0 13.5h9v-1.5h-9zm-3-3h1.5v-9h-1.5zm13.5-9v9h1.5v-9z" }) }); 10431 10432 // packages/icons/build-module/library/sides-bottom.js 10433 var import_primitives93 = __toESM(require_primitives()); 10434 var import_jsx_runtime95 = __toESM(require_jsx_runtime()); 10435 var sides_bottom_default = /* @__PURE__ */ (0, import_jsx_runtime95.jsxs)(import_primitives93.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: [ 10436 /* @__PURE__ */ (0, import_jsx_runtime95.jsx)( 10437 import_primitives93.Path, 10438 { 10439 d: "m7.5 6h9v-1.5h-9zm0 13.5h9v-1.5h-9zm-3-3h1.5v-9h-1.5zm13.5-9v9h1.5v-9z", 10440 style: { opacity: 0.25 } 10441 } 10442 ), 10443 /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(import_primitives93.Path, { d: "m16.5 19.5h-9v-1.5h9z" }) 10444 ] }); 10445 10446 // packages/icons/build-module/library/sides-horizontal.js 10447 var import_primitives94 = __toESM(require_primitives()); 10448 var import_jsx_runtime96 = __toESM(require_jsx_runtime()); 10449 var sides_horizontal_default = /* @__PURE__ */ (0, import_jsx_runtime96.jsxs)(import_primitives94.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: [ 10450 /* @__PURE__ */ (0, import_jsx_runtime96.jsx)( 10451 import_primitives94.Path, 10452 { 10453 d: "m7.5 6h9v-1.5h-9zm0 13.5h9v-1.5h-9zm-3-3h1.5v-9h-1.5zm13.5-9v9h1.5v-9z", 10454 style: { opacity: 0.25 } 10455 } 10456 ), 10457 /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(import_primitives94.Path, { d: "m4.5 7.5v9h1.5v-9z" }), 10458 /* @__PURE__ */ (0, import_jsx_runtime96.jsx)(import_primitives94.Path, { d: "m18 7.5v9h1.5v-9z" }) 10459 ] }); 10460 10461 // packages/icons/build-module/library/sides-left.js 10462 var import_primitives95 = __toESM(require_primitives()); 10463 var import_jsx_runtime97 = __toESM(require_jsx_runtime()); 10464 var sides_left_default = /* @__PURE__ */ (0, import_jsx_runtime97.jsxs)(import_primitives95.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: [ 10465 /* @__PURE__ */ (0, import_jsx_runtime97.jsx)( 10466 import_primitives95.Path, 10467 { 10468 d: "m7.5 6h9v-1.5h-9zm0 13.5h9v-1.5h-9zm-3-3h1.5v-9h-1.5zm13.5-9v9h1.5v-9z", 10469 style: { opacity: 0.25 } 10470 } 10471 ), 10472 /* @__PURE__ */ (0, import_jsx_runtime97.jsx)(import_primitives95.Path, { d: "m4.5 16.5v-9h1.5v9z" }) 10473 ] }); 10474 10475 // packages/icons/build-module/library/sides-right.js 10476 var import_primitives96 = __toESM(require_primitives()); 10477 var import_jsx_runtime98 = __toESM(require_jsx_runtime()); 10478 var sides_right_default = /* @__PURE__ */ (0, import_jsx_runtime98.jsxs)(import_primitives96.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: [ 10479 /* @__PURE__ */ (0, import_jsx_runtime98.jsx)( 10480 import_primitives96.Path, 10481 { 10482 d: "m7.5 6h9v-1.5h-9zm0 13.5h9v-1.5h-9zm-3-3h1.5v-9h-1.5zm13.5-9v9h1.5v-9z", 10483 style: { opacity: 0.25 } 10484 } 10485 ), 10486 /* @__PURE__ */ (0, import_jsx_runtime98.jsx)(import_primitives96.Path, { d: "m18 16.5v-9h1.5v9z" }) 10487 ] }); 10488 10489 // packages/icons/build-module/library/sides-top.js 10490 var import_primitives97 = __toESM(require_primitives()); 10491 var import_jsx_runtime99 = __toESM(require_jsx_runtime()); 10492 var sides_top_default = /* @__PURE__ */ (0, import_jsx_runtime99.jsxs)(import_primitives97.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: [ 10493 /* @__PURE__ */ (0, import_jsx_runtime99.jsx)( 10494 import_primitives97.Path, 10495 { 10496 d: "m7.5 6h9v-1.5h-9zm0 13.5h9v-1.5h-9zm-3-3h1.5v-9h-1.5zm13.5-9v9h1.5v-9z", 10497 style: { opacity: 0.25 } 10498 } 10499 ), 10500 /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(import_primitives97.Path, { d: "m16.5 6h-9v-1.5h9z" }) 10501 ] }); 10502 10503 // packages/icons/build-module/library/sides-vertical.js 10504 var import_primitives98 = __toESM(require_primitives()); 10505 var import_jsx_runtime100 = __toESM(require_jsx_runtime()); 10506 var sides_vertical_default = /* @__PURE__ */ (0, import_jsx_runtime100.jsxs)(import_primitives98.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: [ 10507 /* @__PURE__ */ (0, import_jsx_runtime100.jsx)( 10508 import_primitives98.Path, 10509 { 10510 d: "m7.5 6h9v-1.5h-9zm0 13.5h9v-1.5h-9zm-3-3h1.5v-9h-1.5zm13.5-9v9h1.5v-9z", 10511 style: { opacity: 0.25 } 10512 } 10513 ), 10514 /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(import_primitives98.Path, { d: "m7.5 6h9v-1.5h-9z" }), 10515 /* @__PURE__ */ (0, import_jsx_runtime100.jsx)(import_primitives98.Path, { d: "m7.5 19.5h9v-1.5h-9z" }) 10516 ] }); 10517 10518 // packages/icons/build-module/library/stack.js 10519 var import_primitives99 = __toESM(require_primitives()); 10520 var import_jsx_runtime101 = __toESM(require_jsx_runtime()); 10521 var stack_default = /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(import_primitives99.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(import_primitives99.Path, { d: "M17.5 4v5a2 2 0 0 1-2 2h-7a2 2 0 0 1-2-2V4H8v5a.5.5 0 0 0 .5.5h7A.5.5 0 0 0 16 9V4h1.5Zm0 16v-5a2 2 0 0 0-2-2h-7a2 2 0 0 0-2 2v5H8v-5a.5.5 0 0 1 .5-.5h7a.5.5 0 0 1 .5.5v5h1.5Z" }) }); 10522 10523 // packages/icons/build-module/library/stretch-full-width.js 10524 var import_primitives100 = __toESM(require_primitives()); 10525 var import_jsx_runtime102 = __toESM(require_jsx_runtime()); 10526 var stretch_full_width_default = /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(import_primitives100.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime102.jsx)(import_primitives100.Path, { d: "M5 4h14v11H5V4Zm11 16H8v-1.5h8V20Z" }) }); 10527 10528 // packages/icons/build-module/library/stretch-wide.js 10529 var import_primitives101 = __toESM(require_primitives()); 10530 var import_jsx_runtime103 = __toESM(require_jsx_runtime()); 10531 var stretch_wide_default = /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(import_primitives101.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime103.jsx)(import_primitives101.Path, { d: "M16 5.5H8V4h8v1.5ZM16 20H8v-1.5h8V20ZM5 9h14v6H5V9Z" }) }); 10532 10533 // packages/icons/build-module/library/styles.js 10534 var import_primitives102 = __toESM(require_primitives()); 10535 var import_jsx_runtime104 = __toESM(require_jsx_runtime()); 10536 var styles_default = /* @__PURE__ */ (0, import_jsx_runtime104.jsx)(import_primitives102.SVG, { viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ (0, import_jsx_runtime104.jsx)( 10537 import_primitives102.Path, 10538 { 10539 fillRule: "evenodd", 10540 clipRule: "evenodd", 10541 d: "M20 12a8 8 0 1 1-16 0 8 8 0 0 1 16 0Zm-1.5 0a6.5 6.5 0 0 1-6.5 6.5v-13a6.5 6.5 0 0 1 6.5 6.5Z" 10542 } 10543 ) }); 10544 10545 // packages/icons/build-module/library/symbol.js 10546 var import_primitives103 = __toESM(require_primitives()); 10547 var import_jsx_runtime105 = __toESM(require_jsx_runtime()); 10548 var symbol_default = /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(import_primitives103.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime105.jsx)(import_primitives103.Path, { d: "M21.3 10.8l-5.6-5.6c-.7-.7-1.8-.7-2.5 0l-5.6 5.6c-.7.7-.7 1.8 0 2.5l5.6 5.6c.3.3.8.5 1.2.5s.9-.2 1.2-.5l5.6-5.6c.8-.7.8-1.9.1-2.5zm-1 1.4l-5.6 5.6c-.1.1-.3.1-.4 0l-5.6-5.6c-.1-.1-.1-.3 0-.4l5.6-5.6s.1-.1.2-.1.1 0 .2.1l5.6 5.6c.1.1.1.3 0 .4zm-16.6-.4L10 5.5l-1-1-6.3 6.3c-.7.7-.7 1.8 0 2.5L9 19.5l1.1-1.1-6.3-6.3c-.2 0-.2-.2-.1-.3z" }) }); 10549 10550 // packages/icons/build-module/library/tag.js 10551 var import_primitives104 = __toESM(require_primitives()); 10552 var import_jsx_runtime106 = __toESM(require_jsx_runtime()); 10553 var tag_default = /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(import_primitives104.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime106.jsx)(import_primitives104.Path, { d: "M4.75 4a.75.75 0 0 0-.75.75v7.826c0 .2.08.39.22.53l6.72 6.716a2.313 2.313 0 0 0 3.276-.001l5.61-5.611-.531-.53.532.528a2.315 2.315 0 0 0 0-3.264L13.104 4.22a.75.75 0 0 0-.53-.22H4.75ZM19 12.576a.815.815 0 0 1-.236.574l-5.61 5.611a.814.814 0 0 1-1.153 0L5.5 12.264V5.5h6.763l6.5 6.502a.816.816 0 0 1 .237.574ZM8.75 9.75a1 1 0 1 0 0-2 1 1 0 0 0 0 2Z" }) }); 10554 10555 // packages/icons/build-module/library/text-horizontal.js 10556 var import_primitives105 = __toESM(require_primitives()); 10557 var import_jsx_runtime107 = __toESM(require_jsx_runtime()); 10558 var text_horizontal_default = /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(import_primitives105.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime107.jsx)(import_primitives105.Path, { d: "M8.2 14.4h3.9L13 17h1.7L11 6.5H9.3L5.6 17h1.7l.9-2.6zm2-5.5 1.4 4H8.8l1.4-4zm7.4 7.5-1.3.8.8 1.4H5.5V20h14.3l-2.2-3.6z" }) }); 10559 10560 // packages/icons/build-module/library/text-vertical.js 10561 var import_primitives106 = __toESM(require_primitives()); 10562 var import_jsx_runtime108 = __toESM(require_jsx_runtime()); 10563 var text_vertical_default = /* @__PURE__ */ (0, import_jsx_runtime108.jsx)(import_primitives106.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime108.jsx)(import_primitives106.Path, { d: "M7 5.6v1.7l2.6.9v3.9L7 13v1.7L17.5 11V9.3L7 5.6zm4.2 6V8.8l4 1.4-4 1.4zm-5.7 5.6V5.5H4v14.3l3.6-2.2-.8-1.3-1.3.9z" }) }); 10564 10565 // packages/icons/build-module/library/trash.js 10566 var import_primitives107 = __toESM(require_primitives()); 10567 var import_jsx_runtime109 = __toESM(require_jsx_runtime()); 10568 var trash_default = /* @__PURE__ */ (0, import_jsx_runtime109.jsx)(import_primitives107.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime109.jsx)( 10569 import_primitives107.Path, 10570 { 10571 fillRule: "evenodd", 10572 clipRule: "evenodd", 10573 d: "M12 5.5A2.25 2.25 0 0 0 9.878 7h4.244A2.251 2.251 0 0 0 12 5.5ZM12 4a3.751 3.751 0 0 0-3.675 3H5v1.5h1.27l.818 8.997a2.75 2.75 0 0 0 2.739 2.501h4.347a2.75 2.75 0 0 0 2.738-2.5L17.73 8.5H19V7h-3.325A3.751 3.751 0 0 0 12 4Zm4.224 4.5H7.776l.806 8.861a1.25 1.25 0 0 0 1.245 1.137h4.347a1.25 1.25 0 0 0 1.245-1.137l.805-8.861Z" 10574 } 10575 ) }); 10576 10577 // packages/icons/build-module/library/ungroup.js 10578 var import_primitives108 = __toESM(require_primitives()); 10579 var import_jsx_runtime110 = __toESM(require_jsx_runtime()); 10580 var ungroup_default = /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(import_primitives108.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime110.jsx)(import_primitives108.Path, { d: "M18 4h-7c-1.1 0-2 .9-2 2v7c0 1.1.9 2 2 2h7c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm.5 9c0 .3-.2.5-.5.5h-7c-.3 0-.5-.2-.5-.5V6c0-.3.2-.5.5-.5h7c.3 0 .5.2.5.5v7zm-5 5c0 .3-.2.5-.5.5H6c-.3 0-.5-.2-.5-.5v-7c0-.3.2-.5.5-.5h1V9H6c-1.1 0-2 .9-2 2v7c0 1.1.9 2 2 2h7c1.1 0 2-.9 2-2v-1h-1.5v1z" }) }); 10581 10582 // packages/icons/build-module/library/unlock.js 10583 var import_primitives109 = __toESM(require_primitives()); 10584 var import_jsx_runtime111 = __toESM(require_jsx_runtime()); 10585 var unlock_default = /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(import_primitives109.SVG, { viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ (0, import_jsx_runtime111.jsx)(import_primitives109.Path, { d: "M17 10h-1.2V7c0-2.1-1.7-3.8-3.8-3.8-2.1 0-3.8 1.7-3.8 3.8h1.5c0-1.2 1-2.2 2.2-2.2s2.2 1 2.2 2.2v3H7c-.6 0-1 .4-1 1v8c0 .6.4 1 1 1h10c.6 0 1-.4 1-1v-8c0-.6-.4-1-1-1z" }) }); 10586 10587 // packages/icons/build-module/library/unseen.js 10588 var import_primitives110 = __toESM(require_primitives()); 10589 var import_jsx_runtime112 = __toESM(require_jsx_runtime()); 10590 var unseen_default = /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(import_primitives110.SVG, { viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ (0, import_jsx_runtime112.jsx)(import_primitives110.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" }) }); 10591 10592 // packages/icons/build-module/library/upload.js 10593 var import_primitives111 = __toESM(require_primitives()); 10594 var import_jsx_runtime113 = __toESM(require_jsx_runtime()); 10595 var upload_default = /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(import_primitives111.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime113.jsx)(import_primitives111.Path, { d: "M18.5 15v3.5H13V6.7l4.5 4.1 1-1.1-6.2-5.8-5.8 5.8 1 1.1 4-4v11.7h-6V15H4v5h16v-5z" }) }); 10596 10597 // packages/icons/build-module/library/verse.js 10598 var import_primitives112 = __toESM(require_primitives()); 10599 var import_jsx_runtime114 = __toESM(require_jsx_runtime()); 10600 var verse_default = /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(import_primitives112.SVG, { viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ (0, import_jsx_runtime114.jsx)(import_primitives112.Path, { d: "M17.8 2l-.9.3c-.1 0-3.6 1-5.2 2.1C10 5.5 9.3 6.5 8.9 7.1c-.6.9-1.7 4.7-1.7 6.3l-.9 2.3c-.2.4 0 .8.4 1 .1 0 .2.1.3.1.3 0 .6-.2.7-.5l.6-1.5c.3 0 .7-.1 1.2-.2.7-.1 1.4-.3 2.2-.5.8-.2 1.6-.5 2.4-.8.7-.3 1.4-.7 1.9-1.2s.8-1.2 1-1.9c.2-.7.3-1.6.4-2.4.1-.8.1-1.7.2-2.5 0-.8.1-1.5.2-2.1V2zm-1.9 5.6c-.1.8-.2 1.5-.3 2.1-.2.6-.4 1-.6 1.3-.3.3-.8.6-1.4.9-.7.3-1.4.5-2.2.8-.6.2-1.3.3-1.8.4L15 7.5c.3-.3.6-.7 1-1.1 0 .4 0 .8-.1 1.2zM6 20h8v-1.5H6V20z" }) }); 10601 10602 // packages/icons/build-module/library/video.js 10603 var import_primitives113 = __toESM(require_primitives()); 10604 var import_jsx_runtime115 = __toESM(require_jsx_runtime()); 10605 var video_default = /* @__PURE__ */ (0, import_jsx_runtime115.jsx)(import_primitives113.SVG, { viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ (0, import_jsx_runtime115.jsx)(import_primitives113.Path, { d: "M18.7 3H5.3C4 3 3 4 3 5.3v13.4C3 20 4 21 5.3 21h13.4c1.3 0 2.3-1 2.3-2.3V5.3C21 4 20 3 18.7 3zm.8 15.7c0 .4-.4.8-.8.8H5.3c-.4 0-.8-.4-.8-.8V5.3c0-.4.4-.8.8-.8h13.4c.4 0 .8.4.8.8v13.4zM10 15l5-3-5-3v6z" }) }); 10606 10607 // packages/block-editor/build-module/store/selectors.js 10608 var import_rich_text = __toESM(require_rich_text()); 10609 var import_deprecated2 = __toESM(require_deprecated()); 10610 var import_data4 = __toESM(require_data()); 10611 10612 // packages/block-editor/build-module/store/utils.js 10613 var import_blocks5 = __toESM(require_blocks()); 10614 var import_block_serialization_default_parser = __toESM(require_block_serialization_default_parser()); 10615 10616 // packages/block-editor/build-module/store/constants.js 10617 var STORE_NAME = "core/block-editor"; 10618 10619 // packages/block-editor/build-module/store/private-selectors.js 10620 var private_selectors_exports = {}; 10621 __export(private_selectors_exports, { 10622 getAllPatterns: () => getAllPatterns, 10623 getBlockRemovalRules: () => getBlockRemovalRules, 10624 getBlockSettings: () => getBlockSettings, 10625 getBlockStyles: () => getBlockStyles, 10626 getBlockWithoutAttributes: () => getBlockWithoutAttributes, 10627 getClosestAllowedInsertionPoint: () => getClosestAllowedInsertionPoint, 10628 getClosestAllowedInsertionPointForPattern: () => getClosestAllowedInsertionPointForPattern, 10629 getContentLockingParent: () => getContentLockingParent, 10630 getEditedContentOnlySection: () => getEditedContentOnlySection, 10631 getEnabledBlockParents: () => getEnabledBlockParents, 10632 getEnabledClientIdsTree: () => getEnabledClientIdsTree, 10633 getExpandedBlock: () => getExpandedBlock, 10634 getInserterMediaCategories: () => getInserterMediaCategories, 10635 getInsertionPoint: () => getInsertionPoint, 10636 getLastFocus: () => getLastFocus, 10637 getLastInsertedBlocksClientIds: () => getLastInsertedBlocksClientIds, 10638 getOpenedBlockSettingsMenu: () => getOpenedBlockSettingsMenu, 10639 getParentSectionBlock: () => getParentSectionBlock, 10640 getPatternBySlug: () => getPatternBySlug, 10641 getRegisteredInserterMediaCategories: () => getRegisteredInserterMediaCategories, 10642 getRemovalPromptData: () => getRemovalPromptData, 10643 getReusableBlocks: () => getReusableBlocks, 10644 getSectionRootClientId: () => getSectionRootClientId, 10645 getStyleOverrides: () => getStyleOverrides, 10646 getZoomLevel: () => getZoomLevel, 10647 hasAllowedPatterns: () => hasAllowedPatterns, 10648 hasBlockSpotlight: () => hasBlockSpotlight2, 10649 isBlockHidden: () => isBlockHidden, 10650 isBlockInterfaceHidden: () => isBlockInterfaceHidden2, 10651 isBlockSubtreeDisabled: () => isBlockSubtreeDisabled, 10652 isContainerInsertableToInContentOnlyMode: () => isContainerInsertableToInContentOnlyMode, 10653 isDragging: () => isDragging2, 10654 isEditLockedBlock: () => isEditLockedBlock, 10655 isLockedBlock: () => isLockedBlock, 10656 isMoveLockedBlock: () => isMoveLockedBlock, 10657 isRemoveLockedBlock: () => isRemoveLockedBlock, 10658 isSectionBlock: () => isSectionBlock, 10659 isWithinEditedContentOnlySection: () => isWithinEditedContentOnlySection, 10660 isZoomOut: () => isZoomOut 10661 }); 10662 var import_data3 = __toESM(require_data()); 10663 var import_blocks4 = __toESM(require_blocks()); 10664 10665 // packages/block-editor/build-module/store/get-block-settings.js 10666 var import_blocks3 = __toESM(require_blocks()); 10667 var import_hooks = __toESM(require_hooks()); 10668 10669 // packages/block-editor/build-module/utils/object.js 10670 function setImmutably(object, path, value) { 10671 path = Array.isArray(path) ? [...path] : [path]; 10672 object = Array.isArray(object) ? [...object] : { ...object }; 10673 const leaf = path.pop(); 10674 let prev = object; 10675 for (const key of path) { 10676 const lvl = prev[key]; 10677 prev = prev[key] = Array.isArray(lvl) ? [...lvl] : { ...lvl }; 10678 } 10679 prev[leaf] = value; 10680 return object; 10681 } 10682 var getValueFromObjectPath = (object, path, defaultValue) => { 10683 const arrayPath = Array.isArray(path) ? path : path.split("."); 10684 let value = object; 10685 arrayPath.forEach((fieldName) => { 10686 value = value?.[fieldName]; 10687 }); 10688 return value ?? defaultValue; 10689 }; 10690 10691 // packages/block-editor/build-module/store/get-block-settings.js 10692 var blockedPaths = [ 10693 "color", 10694 "border", 10695 "dimensions", 10696 "typography", 10697 "spacing" 10698 ]; 10699 var deprecatedFlags = { 10700 "color.palette": (settings2) => settings2.colors, 10701 "color.gradients": (settings2) => settings2.gradients, 10702 "color.custom": (settings2) => settings2.disableCustomColors === void 0 ? void 0 : !settings2.disableCustomColors, 10703 "color.customGradient": (settings2) => settings2.disableCustomGradients === void 0 ? void 0 : !settings2.disableCustomGradients, 10704 "typography.fontSizes": (settings2) => settings2.fontSizes, 10705 "typography.customFontSize": (settings2) => settings2.disableCustomFontSizes === void 0 ? void 0 : !settings2.disableCustomFontSizes, 10706 "typography.lineHeight": (settings2) => settings2.enableCustomLineHeight, 10707 "spacing.units": (settings2) => { 10708 if (settings2.enableCustomUnits === void 0) { 10709 return; 10710 } 10711 if (settings2.enableCustomUnits === true) { 10712 return ["px", "em", "rem", "vh", "vw", "%"]; 10713 } 10714 return settings2.enableCustomUnits; 10715 }, 10716 "spacing.padding": (settings2) => settings2.enableCustomSpacing 10717 }; 10718 var prefixedFlags = { 10719 /* 10720 * These were only available in the plugin 10721 * and can be removed when the minimum WordPress version 10722 * for the plugin is 5.9. 10723 */ 10724 "border.customColor": "border.color", 10725 "border.customStyle": "border.style", 10726 "border.customWidth": "border.width", 10727 "typography.customFontStyle": "typography.fontStyle", 10728 "typography.customFontWeight": "typography.fontWeight", 10729 "typography.customLetterSpacing": "typography.letterSpacing", 10730 "typography.customTextDecorations": "typography.textDecoration", 10731 "typography.customTextTransforms": "typography.textTransform", 10732 /* 10733 * These were part of WordPress 5.8 and we need to keep them. 10734 */ 10735 "border.customRadius": "border.radius", 10736 "spacing.customMargin": "spacing.margin", 10737 "spacing.customPadding": "spacing.padding", 10738 "typography.customLineHeight": "typography.lineHeight" 10739 }; 10740 var removeCustomPrefixes = (path) => { 10741 return prefixedFlags[path] || path; 10742 }; 10743 function getBlockSettings(state, clientId, ...paths) { 10744 const blockName = getBlockName(state, clientId); 10745 const candidates = []; 10746 if (clientId) { 10747 let id = clientId; 10748 do { 10749 const name = getBlockName(state, id); 10750 if ((0, import_blocks3.hasBlockSupport)(name, "__experimentalSettings", false)) { 10751 candidates.push(id); 10752 } 10753 } while (id = state.blocks.parents.get(id)); 10754 } 10755 return paths.map((path) => { 10756 if (blockedPaths.includes(path)) { 10757 console.warn( 10758 "Top level useSetting paths are disabled. Please use a subpath to query the information needed." 10759 ); 10760 return void 0; 10761 } 10762 let result = (0, import_hooks.applyFilters)( 10763 "blockEditor.useSetting.before", 10764 void 0, 10765 path, 10766 clientId, 10767 blockName 10768 ); 10769 if (void 0 !== result) { 10770 return result; 10771 } 10772 const normalizedPath = removeCustomPrefixes(path); 10773 for (const candidateClientId of candidates) { 10774 const candidateAtts = getBlockAttributes( 10775 state, 10776 candidateClientId 10777 ); 10778 result = getValueFromObjectPath( 10779 candidateAtts.settings?.blocks?.[blockName], 10780 normalizedPath 10781 ) ?? getValueFromObjectPath( 10782 candidateAtts.settings, 10783 normalizedPath 10784 ); 10785 if (result !== void 0) { 10786 break; 10787 } 10788 } 10789 const settings2 = getSettings(state); 10790 if (result === void 0 && blockName) { 10791 result = getValueFromObjectPath( 10792 settings2.__experimentalFeatures?.blocks?.[blockName], 10793 normalizedPath 10794 ); 10795 } 10796 if (result === void 0) { 10797 result = getValueFromObjectPath( 10798 settings2.__experimentalFeatures, 10799 normalizedPath 10800 ); 10801 } 10802 if (result !== void 0) { 10803 if (import_blocks3.__EXPERIMENTAL_PATHS_WITH_OVERRIDE[normalizedPath]) { 10804 return result.custom ?? result.theme ?? result.default; 10805 } 10806 return result; 10807 } 10808 const deprecatedSettingsValue = deprecatedFlags[normalizedPath]?.(settings2); 10809 if (deprecatedSettingsValue !== void 0) { 10810 return deprecatedSettingsValue; 10811 } 10812 return normalizedPath === "typography.dropCap" ? true : void 0; 10813 }); 10814 } 10815 10816 // packages/block-editor/build-module/store/private-selectors.js 10817 var { isContentBlock: isContentBlock2 } = unlock(import_blocks4.privateApis); 10818 function isBlockInterfaceHidden2(state) { 10819 return state.isBlockInterfaceHidden; 10820 } 10821 function getLastInsertedBlocksClientIds(state) { 10822 return state?.lastBlockInserted?.clientIds; 10823 } 10824 function getBlockWithoutAttributes(state, clientId) { 10825 return state.blocks.byClientId.get(clientId); 10826 } 10827 var isBlockSubtreeDisabled = (state, clientId) => { 10828 const isChildSubtreeDisabled = (childClientId) => { 10829 return getBlockEditingMode(state, childClientId) === "disabled" && getBlockOrder(state, childClientId).every( 10830 isChildSubtreeDisabled 10831 ); 10832 }; 10833 return getBlockOrder(state, clientId).every(isChildSubtreeDisabled); 10834 }; 10835 function isContainerInsertableToInContentOnlyMode(state, blockName, rootClientId) { 10836 const isBlockContentBlock = isContentBlock2(blockName); 10837 const rootBlockName = getBlockName(state, rootClientId); 10838 const isContainerContentBlock = isContentBlock2(rootBlockName); 10839 const isRootBlockMain = getSectionRootClientId(state) === rootClientId; 10840 return isRootBlockMain || isContainerContentBlock && isBlockContentBlock; 10841 } 10842 function getEnabledClientIdsTreeUnmemoized(state, rootClientId) { 10843 const blockOrder = getBlockOrder(state, rootClientId); 10844 const result = []; 10845 for (const clientId of blockOrder) { 10846 const innerBlocks = getEnabledClientIdsTreeUnmemoized( 10847 state, 10848 clientId 10849 ); 10850 if (getBlockEditingMode(state, clientId) !== "disabled") { 10851 result.push({ clientId, innerBlocks }); 10852 } else { 10853 result.push(...innerBlocks); 10854 } 10855 } 10856 return result; 10857 } 10858 var getEnabledClientIdsTree = (0, import_data3.createRegistrySelector)( 10859 () => (0, import_data3.createSelector)(getEnabledClientIdsTreeUnmemoized, (state) => [ 10860 state.blocks.order, 10861 state.derivedBlockEditingModes, 10862 state.blockEditingModes 10863 ]) 10864 ); 10865 var getEnabledBlockParents = (0, import_data3.createSelector)( 10866 (state, clientId, ascending = false) => { 10867 return getBlockParents(state, clientId, ascending).filter( 10868 (parent) => getBlockEditingMode(state, parent) !== "disabled" 10869 ); 10870 }, 10871 (state) => [ 10872 state.blocks.parents, 10873 state.blockEditingModes, 10874 state.settings.templateLock, 10875 state.blockListSettings 10876 ] 10877 ); 10878 function getRemovalPromptData(state) { 10879 return state.removalPromptData; 10880 } 10881 function getBlockRemovalRules(state) { 10882 return state.blockRemovalRules; 10883 } 10884 function getOpenedBlockSettingsMenu(state) { 10885 return state.openedBlockSettingsMenu; 10886 } 10887 var getStyleOverrides = (0, import_data3.createSelector)( 10888 (state) => { 10889 const clientIds = getClientIdsWithDescendants(state); 10890 const clientIdMap = clientIds.reduce((acc, clientId, index) => { 10891 acc[clientId] = index; 10892 return acc; 10893 }, {}); 10894 return [...state.styleOverrides].sort((overrideA, overrideB) => { 10895 const [, { clientId: clientIdA }] = overrideA; 10896 const [, { clientId: clientIdB }] = overrideB; 10897 const aIndex = clientIdMap[clientIdA] ?? -1; 10898 const bIndex = clientIdMap[clientIdB] ?? -1; 10899 return aIndex - bIndex; 10900 }); 10901 }, 10902 (state) => [state.blocks.order, state.styleOverrides] 10903 ); 10904 function getRegisteredInserterMediaCategories(state) { 10905 return state.registeredInserterMediaCategories; 10906 } 10907 var getInserterMediaCategories = (0, import_data3.createSelector)( 10908 (state) => { 10909 const { 10910 settings: { 10911 inserterMediaCategories, 10912 allowedMimeTypes, 10913 enableOpenverseMediaCategory 10914 }, 10915 registeredInserterMediaCategories: registeredInserterMediaCategories2 10916 } = state; 10917 if (!inserterMediaCategories && !registeredInserterMediaCategories2.length || !allowedMimeTypes) { 10918 return; 10919 } 10920 const coreInserterMediaCategoriesNames = inserterMediaCategories?.map(({ name }) => name) || []; 10921 const mergedCategories = [ 10922 ...inserterMediaCategories || [], 10923 ...(registeredInserterMediaCategories2 || []).filter( 10924 ({ name }) => !coreInserterMediaCategoriesNames.includes(name) 10925 ) 10926 ]; 10927 return mergedCategories.filter((category) => { 10928 if (!enableOpenverseMediaCategory && category.name === "openverse") { 10929 return false; 10930 } 10931 return Object.values(allowedMimeTypes).some( 10932 (mimeType) => mimeType.startsWith(`$category.mediaType}/`) 10933 ); 10934 }); 10935 }, 10936 (state) => [ 10937 state.settings.inserterMediaCategories, 10938 state.settings.allowedMimeTypes, 10939 state.settings.enableOpenverseMediaCategory, 10940 state.registeredInserterMediaCategories 10941 ] 10942 ); 10943 var hasAllowedPatterns = (0, import_data3.createRegistrySelector)( 10944 (select3) => (0, import_data3.createSelector)( 10945 (state, rootClientId = null) => { 10946 const { getAllPatterns: getAllPatterns2 } = unlock(select3(STORE_NAME)); 10947 const patterns = getAllPatterns2(); 10948 const { allowedBlockTypes } = getSettings(state); 10949 return patterns.some((pattern) => { 10950 const { inserter = true } = pattern; 10951 if (!inserter) { 10952 return false; 10953 } 10954 const grammar = getGrammar(pattern); 10955 return checkAllowListRecursive(grammar, allowedBlockTypes) && grammar.every( 10956 ({ name: blockName }) => canInsertBlockType(state, blockName, rootClientId) 10957 ); 10958 }); 10959 }, 10960 (state, rootClientId) => [ 10961 ...getAllPatternsDependants(select3)(state), 10962 ...getInsertBlockTypeDependants(select3)(state, rootClientId) 10963 ] 10964 ) 10965 ); 10966 var getPatternBySlug = (0, import_data3.createRegistrySelector)( 10967 (select3) => (0, import_data3.createSelector)( 10968 (state, patternName) => { 10969 if (patternName?.startsWith("core/block/")) { 10970 const _id = parseInt( 10971 patternName.slice("core/block/".length), 10972 10 10973 ); 10974 const block = unlock(select3(STORE_NAME)).getReusableBlocks().find(({ id }) => id === _id); 10975 if (!block) { 10976 return null; 10977 } 10978 return mapUserPattern( 10979 block, 10980 state.settings.__experimentalUserPatternCategories 10981 ); 10982 } 10983 return [ 10984 // This setting is left for back compat. 10985 ...state.settings.__experimentalBlockPatterns ?? [], 10986 ...state.settings[selectBlockPatternsKey]?.(select3) ?? [] 10987 ].find(({ name }) => name === patternName); 10988 }, 10989 (state, patternName) => patternName?.startsWith("core/block/") ? [ 10990 unlock(select3(STORE_NAME)).getReusableBlocks(), 10991 state.settings.__experimentalReusableBlocks 10992 ] : [ 10993 state.settings.__experimentalBlockPatterns, 10994 state.settings[selectBlockPatternsKey]?.(select3) 10995 ] 10996 ) 10997 ); 10998 var getAllPatterns = (0, import_data3.createRegistrySelector)( 10999 (select3) => (0, import_data3.createSelector)((state) => { 11000 return [ 11001 ...unlock(select3(STORE_NAME)).getReusableBlocks().map( 11002 (userPattern) => mapUserPattern( 11003 userPattern, 11004 state.settings.__experimentalUserPatternCategories 11005 ) 11006 ), 11007 // This setting is left for back compat. 11008 ...state.settings.__experimentalBlockPatterns ?? [], 11009 ...state.settings[selectBlockPatternsKey]?.(select3) ?? [] 11010 ].filter( 11011 (x2, index, arr) => index === arr.findIndex((y2) => x2.name === y2.name) 11012 ); 11013 }, getAllPatternsDependants(select3)) 11014 ); 11015 var EMPTY_ARRAY = []; 11016 var getReusableBlocks = (0, import_data3.createRegistrySelector)( 11017 (select3) => (state) => { 11018 const reusableBlocksSelect = state.settings[reusableBlocksSelectKey]; 11019 return (reusableBlocksSelect ? reusableBlocksSelect(select3) : state.settings.__experimentalReusableBlocks) ?? EMPTY_ARRAY; 11020 } 11021 ); 11022 function getLastFocus(state) { 11023 return state.lastFocus; 11024 } 11025 function isDragging2(state) { 11026 return state.isDragging; 11027 } 11028 function getExpandedBlock(state) { 11029 return state.expandedBlock; 11030 } 11031 var getContentLockingParent = (state, clientId) => { 11032 let current = clientId; 11033 let result; 11034 while (!result && (current = state.blocks.parents.get(current))) { 11035 if (getTemplateLock(state, current) === "contentOnly") { 11036 result = current; 11037 } 11038 } 11039 return result; 11040 }; 11041 var getParentSectionBlock = (state, clientId) => { 11042 let current = clientId; 11043 let result; 11044 while (current = state.blocks.parents.get(current)) { 11045 if (isSectionBlock(state, current)) { 11046 result = current; 11047 } 11048 } 11049 return result; 11050 }; 11051 function isSectionBlock(state, clientId) { 11052 if (clientId === state.editedContentOnlySection) { 11053 return false; 11054 } 11055 const blockName = getBlockName(state, clientId); 11056 if (blockName === "core/block") { 11057 return true; 11058 } 11059 const attributes = getBlockAttributes(state, clientId); 11060 const isTemplatePart8 = blockName === "core/template-part"; 11061 const isIsolatedEditor = state.settings?.[isIsolatedEditorKey]; 11062 if ((attributes?.metadata?.patternName || isTemplatePart8) && !!window?.__experimentalContentOnlyPatternInsertion && !isIsolatedEditor) { 11063 return true; 11064 } 11065 const hasContentOnlyTempateLock = getTemplateLock(state, clientId) === "contentOnly"; 11066 const rootClientId = getBlockRootClientId(state, clientId); 11067 const hasRootContentOnlyTemplateLock = getTemplateLock(state, rootClientId) === "contentOnly"; 11068 if (hasContentOnlyTempateLock && !hasRootContentOnlyTemplateLock) { 11069 return true; 11070 } 11071 return false; 11072 } 11073 function getEditedContentOnlySection(state) { 11074 return state.editedContentOnlySection; 11075 } 11076 function isWithinEditedContentOnlySection(state, clientId) { 11077 if (!state.editedContentOnlySection) { 11078 return false; 11079 } 11080 if (state.editedContentOnlySection === clientId) { 11081 return true; 11082 } 11083 let current = clientId; 11084 while (current = state.blocks.parents.get(current)) { 11085 if (state.editedContentOnlySection === current) { 11086 return true; 11087 } 11088 } 11089 return false; 11090 } 11091 var getBlockStyles = (0, import_data3.createSelector)( 11092 (state, clientIds) => clientIds.reduce((styles, clientId) => { 11093 styles[clientId] = state.blocks.attributes.get(clientId)?.style; 11094 return styles; 11095 }, {}), 11096 (state, clientIds) => [ 11097 ...clientIds.map( 11098 (clientId) => state.blocks.attributes.get(clientId)?.style 11099 ) 11100 ] 11101 ); 11102 function getSectionRootClientId(state) { 11103 return state.settings?.[sectionRootClientIdKey]; 11104 } 11105 function isZoomOut(state) { 11106 return state.zoomLevel === "auto-scaled" || state.zoomLevel < 100; 11107 } 11108 function getZoomLevel(state) { 11109 return state.zoomLevel; 11110 } 11111 function getClosestAllowedInsertionPoint(state, name, clientId = "") { 11112 const blockNames = Array.isArray(name) ? name : [name]; 11113 const areBlockNamesAllowedInClientId = (id) => blockNames.every( 11114 (currentName) => canInsertBlockType(state, currentName, id) 11115 ); 11116 if (!clientId) { 11117 if (areBlockNamesAllowedInClientId(clientId)) { 11118 return clientId; 11119 } 11120 const sectionRootClientId = getSectionRootClientId(state); 11121 if (sectionRootClientId && areBlockNamesAllowedInClientId(sectionRootClientId)) { 11122 return sectionRootClientId; 11123 } 11124 return null; 11125 } 11126 let current = clientId; 11127 while (current !== null && !areBlockNamesAllowedInClientId(current)) { 11128 const parentClientId = getBlockRootClientId(state, current); 11129 current = parentClientId; 11130 } 11131 return current; 11132 } 11133 function getClosestAllowedInsertionPointForPattern(state, pattern, clientId) { 11134 const { allowedBlockTypes } = getSettings(state); 11135 const isAllowed = checkAllowListRecursive( 11136 getGrammar(pattern), 11137 allowedBlockTypes 11138 ); 11139 if (!isAllowed) { 11140 return null; 11141 } 11142 const names = getGrammar(pattern).map(({ blockName: name }) => name); 11143 return getClosestAllowedInsertionPoint(state, names, clientId); 11144 } 11145 function getInsertionPoint(state) { 11146 return state.insertionPoint; 11147 } 11148 var isBlockHidden = (state, clientId) => { 11149 const blockName = getBlockName(state, clientId); 11150 if (!(0, import_blocks4.hasBlockSupport)(state, blockName, "visibility", true)) { 11151 return false; 11152 } 11153 const attributes = state.blocks.attributes.get(clientId); 11154 return attributes?.metadata?.blockVisibility === false; 11155 }; 11156 function hasBlockSpotlight2(state) { 11157 return !!state.hasBlockSpotlight || !!state.editedContentOnlySection; 11158 } 11159 function isEditLockedBlock(state, clientId) { 11160 const attributes = getBlockAttributes(state, clientId); 11161 return !!attributes?.lock?.edit; 11162 } 11163 function isMoveLockedBlock(state, clientId) { 11164 const attributes = getBlockAttributes(state, clientId); 11165 if (attributes?.lock?.move !== void 0) { 11166 return !!attributes?.lock?.move; 11167 } 11168 const rootClientId = getBlockRootClientId(state, clientId); 11169 const templateLock = getTemplateLock(state, rootClientId); 11170 return templateLock === "all"; 11171 } 11172 function isRemoveLockedBlock(state, clientId) { 11173 const attributes = getBlockAttributes(state, clientId); 11174 if (attributes?.lock?.remove !== void 0) { 11175 return !!attributes?.lock?.remove; 11176 } 11177 const rootClientId = getBlockRootClientId(state, clientId); 11178 const templateLock = getTemplateLock(state, rootClientId); 11179 return templateLock === "all" || templateLock === "insert"; 11180 } 11181 function isLockedBlock(state, clientId) { 11182 return isEditLockedBlock(state, clientId) || isMoveLockedBlock(state, clientId) || isRemoveLockedBlock(state, clientId); 11183 } 11184 11185 // packages/block-editor/build-module/components/inserter/block-patterns-tab/utils.js 11186 var import_i18n2 = __toESM(require_i18n()); 11187 var INSERTER_PATTERN_TYPES = { 11188 user: "user", 11189 theme: "theme", 11190 directory: "directory" 11191 }; 11192 var INSERTER_SYNC_TYPES = { 11193 full: "fully", 11194 unsynced: "unsynced" 11195 }; 11196 var allPatternsCategory = { 11197 name: "allPatterns", 11198 label: (0, import_i18n2._x)("All", "patterns") 11199 }; 11200 var myPatternsCategory = { 11201 name: "myPatterns", 11202 label: (0, import_i18n2.__)("My patterns") 11203 }; 11204 var starterPatternsCategory = { 11205 name: "core/starter-content", 11206 label: (0, import_i18n2.__)("Starter content") 11207 }; 11208 function isPatternFiltered(pattern, sourceFilter, syncFilter) { 11209 const isUserPattern = pattern.name.startsWith("core/block"); 11210 const isDirectoryPattern = pattern.source === "core" || pattern.source?.startsWith("pattern-directory"); 11211 if (sourceFilter === INSERTER_PATTERN_TYPES.theme && (isUserPattern || isDirectoryPattern)) { 11212 return true; 11213 } 11214 if (sourceFilter === INSERTER_PATTERN_TYPES.directory && (isUserPattern || !isDirectoryPattern)) { 11215 return true; 11216 } 11217 if (sourceFilter === INSERTER_PATTERN_TYPES.user && pattern.type !== INSERTER_PATTERN_TYPES.user) { 11218 return true; 11219 } 11220 if (syncFilter === INSERTER_SYNC_TYPES.full && pattern.syncStatus !== "") { 11221 return true; 11222 } 11223 if (syncFilter === INSERTER_SYNC_TYPES.unsynced && pattern.syncStatus !== "unsynced" && isUserPattern) { 11224 return true; 11225 } 11226 return false; 11227 } 11228 11229 // packages/block-editor/build-module/store/utils.js 11230 var isFiltered = Symbol("isFiltered"); 11231 var parsedPatternCache = /* @__PURE__ */ new WeakMap(); 11232 var grammarMapCache = /* @__PURE__ */ new WeakMap(); 11233 function mapUserPattern(userPattern, __experimentalUserPatternCategories = []) { 11234 return { 11235 name: `core/block/$userPattern.id}`, 11236 id: userPattern.id, 11237 type: INSERTER_PATTERN_TYPES.user, 11238 title: userPattern.title?.raw, 11239 categories: userPattern.wp_pattern_category?.map((catId) => { 11240 const category = __experimentalUserPatternCategories.find( 11241 ({ id }) => id === catId 11242 ); 11243 return category ? category.slug : catId; 11244 }), 11245 content: userPattern.content?.raw, 11246 syncStatus: userPattern.wp_pattern_sync_status 11247 }; 11248 } 11249 function parsePattern(pattern) { 11250 const blocks2 = (0, import_blocks5.parse)(pattern.content, { 11251 __unstableSkipMigrationLogs: true 11252 }); 11253 if (blocks2.length === 1) { 11254 blocks2[0].attributes = { 11255 ...blocks2[0].attributes, 11256 metadata: { 11257 ...blocks2[0].attributes.metadata || {}, 11258 categories: pattern.categories, 11259 patternName: pattern.name, 11260 name: blocks2[0].attributes.metadata?.name || pattern.title 11261 } 11262 }; 11263 } 11264 return { 11265 ...pattern, 11266 blocks: blocks2 11267 }; 11268 } 11269 function getParsedPattern(pattern) { 11270 let parsedPattern = parsedPatternCache.get(pattern); 11271 if (!parsedPattern) { 11272 parsedPattern = parsePattern(pattern); 11273 parsedPatternCache.set(pattern, parsedPattern); 11274 } 11275 return parsedPattern; 11276 } 11277 function getGrammar(pattern) { 11278 let grammarMap = grammarMapCache.get(pattern); 11279 if (!grammarMap) { 11280 grammarMap = (0, import_block_serialization_default_parser.parse)(pattern.content); 11281 grammarMap = grammarMap.filter((block) => block.blockName !== null); 11282 grammarMapCache.set(pattern, grammarMap); 11283 } 11284 return grammarMap; 11285 } 11286 var checkAllowList = (list, item, defaultResult = null) => { 11287 if (typeof list === "boolean") { 11288 return list; 11289 } 11290 if (Array.isArray(list)) { 11291 if (list.includes("core/post-content") && item === null) { 11292 return true; 11293 } 11294 return list.includes(item); 11295 } 11296 return defaultResult; 11297 }; 11298 var checkAllowListRecursive = (blocks2, allowedBlockTypes) => { 11299 if (typeof allowedBlockTypes === "boolean") { 11300 return allowedBlockTypes; 11301 } 11302 const blocksQueue = [...blocks2]; 11303 while (blocksQueue.length > 0) { 11304 const block = blocksQueue.shift(); 11305 const isAllowed = checkAllowList( 11306 allowedBlockTypes, 11307 block.name || block.blockName, 11308 true 11309 ); 11310 if (!isAllowed) { 11311 return false; 11312 } 11313 block.innerBlocks?.forEach((innerBlock) => { 11314 blocksQueue.push(innerBlock); 11315 }); 11316 } 11317 return true; 11318 }; 11319 var getAllPatternsDependants = (select3) => (state) => { 11320 return [ 11321 state.settings.__experimentalBlockPatterns, 11322 state.settings.__experimentalUserPatternCategories, 11323 state.settings.__experimentalReusableBlocks, 11324 state.settings[selectBlockPatternsKey]?.(select3), 11325 state.blockPatterns, 11326 unlock(select3(STORE_NAME)).getReusableBlocks() 11327 ]; 11328 }; 11329 var getInsertBlockTypeDependants = () => (state, rootClientId) => { 11330 return [ 11331 state.blockListSettings[rootClientId], 11332 state.blocks.byClientId.get(rootClientId), 11333 state.settings.allowedBlockTypes, 11334 state.settings.templateLock, 11335 getBlockEditingMode(state, rootClientId), 11336 getSectionRootClientId(state), 11337 isSectionBlock(state, rootClientId) 11338 ]; 11339 }; 11340 11341 // packages/block-editor/build-module/utils/sorting.js 11342 var comparator = (field, items, order) => { 11343 return (a2, b2) => { 11344 let cmpA, cmpB; 11345 if (typeof field === "function") { 11346 cmpA = field(a2); 11347 cmpB = field(b2); 11348 } else { 11349 cmpA = a2[field]; 11350 cmpB = b2[field]; 11351 } 11352 if (cmpA > cmpB) { 11353 return order === "asc" ? 1 : -1; 11354 } else if (cmpB > cmpA) { 11355 return order === "asc" ? -1 : 1; 11356 } 11357 const orderA = items.findIndex((item) => item === a2); 11358 const orderB = items.findIndex((item) => item === b2); 11359 if (orderA > orderB) { 11360 return 1; 11361 } else if (orderB > orderA) { 11362 return -1; 11363 } 11364 return 0; 11365 }; 11366 }; 11367 function orderBy(items, field, order = "asc") { 11368 return items.concat().sort(comparator(field, items, order)); 11369 } 11370 11371 // packages/block-editor/build-module/store/selectors.js 11372 var { isContentBlock: isContentBlock3 } = unlock(import_blocks6.privateApis); 11373 var MILLISECONDS_PER_HOUR = 3600 * 1e3; 11374 var MILLISECONDS_PER_DAY = 24 * 3600 * 1e3; 11375 var MILLISECONDS_PER_WEEK = 7 * 24 * 3600 * 1e3; 11376 var EMPTY_ARRAY2 = []; 11377 var EMPTY_SET = /* @__PURE__ */ new Set(); 11378 var DEFAULT_INSERTER_OPTIONS = { 11379 [isFiltered]: true 11380 }; 11381 function getBlockName(state, clientId) { 11382 const block = state.blocks.byClientId.get(clientId); 11383 const socialLinkName = "core/social-link"; 11384 if (import_element6.Platform.OS !== "web" && block?.name === socialLinkName) { 11385 const attributes = state.blocks.attributes.get(clientId); 11386 const { service } = attributes ?? {}; 11387 return service ? `$socialLinkName}-$service}` : socialLinkName; 11388 } 11389 return block ? block.name : null; 11390 } 11391 function isBlockValid(state, clientId) { 11392 const block = state.blocks.byClientId.get(clientId); 11393 return !!block && block.isValid; 11394 } 11395 function getBlockAttributes(state, clientId) { 11396 const block = state.blocks.byClientId.get(clientId); 11397 if (!block) { 11398 return null; 11399 } 11400 return state.blocks.attributes.get(clientId); 11401 } 11402 function getBlock(state, clientId) { 11403 if (!state.blocks.byClientId.has(clientId)) { 11404 return null; 11405 } 11406 return state.blocks.tree.get(clientId); 11407 } 11408 var __unstableGetBlockWithoutInnerBlocks = (0, import_data4.createSelector)( 11409 (state, clientId) => { 11410 const block = state.blocks.byClientId.get(clientId); 11411 if (!block) { 11412 return null; 11413 } 11414 return { 11415 ...block, 11416 attributes: getBlockAttributes(state, clientId) 11417 }; 11418 }, 11419 (state, clientId) => [ 11420 state.blocks.byClientId.get(clientId), 11421 state.blocks.attributes.get(clientId) 11422 ] 11423 ); 11424 function getBlocks(state, rootClientId) { 11425 const treeKey = !rootClientId || !areInnerBlocksControlled(state, rootClientId) ? rootClientId || "" : "controlled||" + rootClientId; 11426 return state.blocks.tree.get(treeKey)?.innerBlocks || EMPTY_ARRAY2; 11427 } 11428 var __unstableGetClientIdWithClientIdsTree = (0, import_data4.createSelector)( 11429 (state, clientId) => { 11430 (0, import_deprecated2.default)( 11431 "wp.data.select( 'core/block-editor' ).__unstableGetClientIdWithClientIdsTree", 11432 { 11433 since: "6.3", 11434 version: "6.5" 11435 } 11436 ); 11437 return { 11438 clientId, 11439 innerBlocks: __unstableGetClientIdsTree(state, clientId) 11440 }; 11441 }, 11442 (state) => [state.blocks.order] 11443 ); 11444 var __unstableGetClientIdsTree = (0, import_data4.createSelector)( 11445 (state, rootClientId = "") => { 11446 (0, import_deprecated2.default)( 11447 "wp.data.select( 'core/block-editor' ).__unstableGetClientIdsTree", 11448 { 11449 since: "6.3", 11450 version: "6.5" 11451 } 11452 ); 11453 return getBlockOrder(state, rootClientId).map( 11454 (clientId) => __unstableGetClientIdWithClientIdsTree(state, clientId) 11455 ); 11456 }, 11457 (state) => [state.blocks.order] 11458 ); 11459 var getClientIdsOfDescendants = (0, import_data4.createSelector)( 11460 (state, rootIds) => { 11461 rootIds = Array.isArray(rootIds) ? [...rootIds] : [rootIds]; 11462 const ids = []; 11463 for (const rootId of rootIds) { 11464 const order = state.blocks.order.get(rootId); 11465 if (order) { 11466 ids.push(...order); 11467 } 11468 } 11469 let index = 0; 11470 while (index < ids.length) { 11471 const id = ids[index]; 11472 const order = state.blocks.order.get(id); 11473 if (order) { 11474 ids.splice(index + 1, 0, ...order); 11475 } 11476 index++; 11477 } 11478 return ids; 11479 }, 11480 (state) => [state.blocks.order] 11481 ); 11482 var getClientIdsWithDescendants = (state) => getClientIdsOfDescendants(state, ""); 11483 var getGlobalBlockCount = (0, import_data4.createSelector)( 11484 (state, blockName) => { 11485 const clientIds = getClientIdsWithDescendants(state); 11486 if (!blockName) { 11487 return clientIds.length; 11488 } 11489 let count = 0; 11490 for (const clientId of clientIds) { 11491 const block = state.blocks.byClientId.get(clientId); 11492 if (block.name === blockName) { 11493 count++; 11494 } 11495 } 11496 return count; 11497 }, 11498 (state) => [state.blocks.order, state.blocks.byClientId] 11499 ); 11500 var getBlocksByName = (0, import_data4.createSelector)( 11501 (state, blockName) => { 11502 if (!blockName) { 11503 return EMPTY_ARRAY2; 11504 } 11505 const blockNames = Array.isArray(blockName) ? blockName : [blockName]; 11506 const clientIds = getClientIdsWithDescendants(state); 11507 const foundBlocks = clientIds.filter((clientId) => { 11508 const block = state.blocks.byClientId.get(clientId); 11509 return blockNames.includes(block.name); 11510 }); 11511 return foundBlocks.length > 0 ? foundBlocks : EMPTY_ARRAY2; 11512 }, 11513 (state) => [state.blocks.order, state.blocks.byClientId] 11514 ); 11515 function __experimentalGetGlobalBlocksByName(state, blockName) { 11516 (0, import_deprecated2.default)( 11517 "wp.data.select( 'core/block-editor' ).__experimentalGetGlobalBlocksByName", 11518 { 11519 since: "6.5", 11520 alternative: `wp.data.select( 'core/block-editor' ).getBlocksByName` 11521 } 11522 ); 11523 return getBlocksByName(state, blockName); 11524 } 11525 var getBlocksByClientId = (0, import_data4.createSelector)( 11526 (state, clientIds) => (Array.isArray(clientIds) ? clientIds : [clientIds]).map( 11527 (clientId) => getBlock(state, clientId) 11528 ), 11529 (state, clientIds) => (Array.isArray(clientIds) ? clientIds : [clientIds]).map( 11530 (clientId) => state.blocks.tree.get(clientId) 11531 ) 11532 ); 11533 var getBlockNamesByClientId = (0, import_data4.createSelector)( 11534 (state, clientIds) => getBlocksByClientId(state, clientIds).filter(Boolean).map((block) => block.name), 11535 (state, clientIds) => getBlocksByClientId(state, clientIds) 11536 ); 11537 function getBlockCount(state, rootClientId) { 11538 return getBlockOrder(state, rootClientId).length; 11539 } 11540 function getSelectionStart(state) { 11541 return state.selection.selectionStart; 11542 } 11543 function getSelectionEnd(state) { 11544 return state.selection.selectionEnd; 11545 } 11546 function getBlockSelectionStart(state) { 11547 return state.selection.selectionStart.clientId; 11548 } 11549 function getBlockSelectionEnd(state) { 11550 return state.selection.selectionEnd.clientId; 11551 } 11552 function getSelectedBlockCount(state) { 11553 const multiSelectedBlockCount = getMultiSelectedBlockClientIds(state).length; 11554 if (multiSelectedBlockCount) { 11555 return multiSelectedBlockCount; 11556 } 11557 return state.selection.selectionStart.clientId ? 1 : 0; 11558 } 11559 function hasSelectedBlock(state) { 11560 const { selectionStart, selectionEnd } = state.selection; 11561 return !!selectionStart.clientId && selectionStart.clientId === selectionEnd.clientId; 11562 } 11563 function getSelectedBlockClientId(state) { 11564 const { selectionStart, selectionEnd } = state.selection; 11565 const { clientId } = selectionStart; 11566 if (!clientId || clientId !== selectionEnd.clientId) { 11567 return null; 11568 } 11569 return clientId; 11570 } 11571 function getSelectedBlock(state) { 11572 const clientId = getSelectedBlockClientId(state); 11573 return clientId ? getBlock(state, clientId) : null; 11574 } 11575 function getBlockRootClientId(state, clientId) { 11576 return state.blocks.parents.get(clientId) ?? null; 11577 } 11578 var getBlockParents = (0, import_data4.createSelector)( 11579 (state, clientId, ascending = false) => { 11580 const parents = []; 11581 let current = clientId; 11582 while (current = state.blocks.parents.get(current)) { 11583 parents.push(current); 11584 } 11585 if (!parents.length) { 11586 return EMPTY_ARRAY2; 11587 } 11588 return ascending ? parents : parents.reverse(); 11589 }, 11590 (state) => [state.blocks.parents] 11591 ); 11592 var getBlockParentsByBlockName = (0, import_data4.createSelector)( 11593 (state, clientId, blockName, ascending = false) => { 11594 const parents = getBlockParents(state, clientId, ascending); 11595 const hasName = Array.isArray(blockName) ? (name) => blockName.includes(name) : (name) => blockName === name; 11596 return parents.filter((id) => hasName(getBlockName(state, id))); 11597 }, 11598 (state) => [state.blocks.parents] 11599 ); 11600 function getBlockHierarchyRootClientId(state, clientId) { 11601 let current = clientId; 11602 let parent; 11603 do { 11604 parent = current; 11605 current = state.blocks.parents.get(current); 11606 } while (current); 11607 return parent; 11608 } 11609 function getLowestCommonAncestorWithSelectedBlock(state, clientId) { 11610 const selectedId = getSelectedBlockClientId(state); 11611 const clientParents = [...getBlockParents(state, clientId), clientId]; 11612 const selectedParents = [ 11613 ...getBlockParents(state, selectedId), 11614 selectedId 11615 ]; 11616 let lowestCommonAncestor; 11617 const maxDepth = Math.min(clientParents.length, selectedParents.length); 11618 for (let index = 0; index < maxDepth; index++) { 11619 if (clientParents[index] === selectedParents[index]) { 11620 lowestCommonAncestor = clientParents[index]; 11621 } else { 11622 break; 11623 } 11624 } 11625 return lowestCommonAncestor; 11626 } 11627 function getAdjacentBlockClientId(state, startClientId, modifier = 1) { 11628 if (startClientId === void 0) { 11629 startClientId = getSelectedBlockClientId(state); 11630 } 11631 if (startClientId === void 0) { 11632 if (modifier < 0) { 11633 startClientId = getFirstMultiSelectedBlockClientId(state); 11634 } else { 11635 startClientId = getLastMultiSelectedBlockClientId(state); 11636 } 11637 } 11638 if (!startClientId) { 11639 return null; 11640 } 11641 const rootClientId = getBlockRootClientId(state, startClientId); 11642 if (rootClientId === null) { 11643 return null; 11644 } 11645 const { order } = state.blocks; 11646 const orderSet = order.get(rootClientId); 11647 const index = orderSet.indexOf(startClientId); 11648 const nextIndex = index + 1 * modifier; 11649 if (nextIndex < 0) { 11650 return null; 11651 } 11652 if (nextIndex === orderSet.length) { 11653 return null; 11654 } 11655 return orderSet[nextIndex]; 11656 } 11657 function getPreviousBlockClientId(state, startClientId) { 11658 return getAdjacentBlockClientId(state, startClientId, -1); 11659 } 11660 function getNextBlockClientId(state, startClientId) { 11661 return getAdjacentBlockClientId(state, startClientId, 1); 11662 } 11663 function getSelectedBlocksInitialCaretPosition(state) { 11664 return state.initialPosition; 11665 } 11666 var getSelectedBlockClientIds = (0, import_data4.createSelector)( 11667 (state) => { 11668 const { selectionStart, selectionEnd } = state.selection; 11669 if (!selectionStart.clientId || !selectionEnd.clientId) { 11670 return EMPTY_ARRAY2; 11671 } 11672 if (selectionStart.clientId === selectionEnd.clientId) { 11673 return [selectionStart.clientId]; 11674 } 11675 const rootClientId = getBlockRootClientId( 11676 state, 11677 selectionStart.clientId 11678 ); 11679 if (rootClientId === null) { 11680 return EMPTY_ARRAY2; 11681 } 11682 const blockOrder = getBlockOrder(state, rootClientId); 11683 const startIndex = blockOrder.indexOf(selectionStart.clientId); 11684 const endIndex = blockOrder.indexOf(selectionEnd.clientId); 11685 if (startIndex > endIndex) { 11686 return blockOrder.slice(endIndex, startIndex + 1); 11687 } 11688 return blockOrder.slice(startIndex, endIndex + 1); 11689 }, 11690 (state) => [ 11691 state.blocks.order, 11692 state.selection.selectionStart.clientId, 11693 state.selection.selectionEnd.clientId 11694 ] 11695 ); 11696 function getMultiSelectedBlockClientIds(state) { 11697 const { selectionStart, selectionEnd } = state.selection; 11698 if (selectionStart.clientId === selectionEnd.clientId) { 11699 return EMPTY_ARRAY2; 11700 } 11701 return getSelectedBlockClientIds(state); 11702 } 11703 var getMultiSelectedBlocks = (0, import_data4.createSelector)( 11704 (state) => { 11705 const multiSelectedBlockClientIds = getMultiSelectedBlockClientIds(state); 11706 if (!multiSelectedBlockClientIds.length) { 11707 return EMPTY_ARRAY2; 11708 } 11709 return multiSelectedBlockClientIds.map( 11710 (clientId) => getBlock(state, clientId) 11711 ); 11712 }, 11713 (state) => [ 11714 ...getSelectedBlockClientIds.getDependants(state), 11715 state.blocks.byClientId, 11716 state.blocks.order, 11717 state.blocks.attributes 11718 ] 11719 ); 11720 function getFirstMultiSelectedBlockClientId(state) { 11721 return getMultiSelectedBlockClientIds(state)[0] || null; 11722 } 11723 function getLastMultiSelectedBlockClientId(state) { 11724 const selectedClientIds = getMultiSelectedBlockClientIds(state); 11725 return selectedClientIds[selectedClientIds.length - 1] || null; 11726 } 11727 function isFirstMultiSelectedBlock(state, clientId) { 11728 return getFirstMultiSelectedBlockClientId(state) === clientId; 11729 } 11730 function isBlockMultiSelected(state, clientId) { 11731 return getMultiSelectedBlockClientIds(state).indexOf(clientId) !== -1; 11732 } 11733 var isAncestorMultiSelected = (0, import_data4.createSelector)( 11734 (state, clientId) => { 11735 let ancestorClientId = clientId; 11736 let isMultiSelected = false; 11737 while (ancestorClientId && !isMultiSelected) { 11738 ancestorClientId = getBlockRootClientId(state, ancestorClientId); 11739 isMultiSelected = isBlockMultiSelected(state, ancestorClientId); 11740 } 11741 return isMultiSelected; 11742 }, 11743 (state) => [ 11744 state.blocks.order, 11745 state.selection.selectionStart.clientId, 11746 state.selection.selectionEnd.clientId 11747 ] 11748 ); 11749 function getMultiSelectedBlocksStartClientId(state) { 11750 const { selectionStart, selectionEnd } = state.selection; 11751 if (selectionStart.clientId === selectionEnd.clientId) { 11752 return null; 11753 } 11754 return selectionStart.clientId || null; 11755 } 11756 function getMultiSelectedBlocksEndClientId(state) { 11757 const { selectionStart, selectionEnd } = state.selection; 11758 if (selectionStart.clientId === selectionEnd.clientId) { 11759 return null; 11760 } 11761 return selectionEnd.clientId || null; 11762 } 11763 function __unstableIsFullySelected(state) { 11764 const selectionAnchor = getSelectionStart(state); 11765 const selectionFocus = getSelectionEnd(state); 11766 return !selectionAnchor.attributeKey && !selectionFocus.attributeKey && typeof selectionAnchor.offset === "undefined" && typeof selectionFocus.offset === "undefined"; 11767 } 11768 function __unstableIsSelectionCollapsed(state) { 11769 const selectionAnchor = getSelectionStart(state); 11770 const selectionFocus = getSelectionEnd(state); 11771 return !!selectionAnchor && !!selectionFocus && selectionAnchor.clientId === selectionFocus.clientId && selectionAnchor.attributeKey === selectionFocus.attributeKey && selectionAnchor.offset === selectionFocus.offset; 11772 } 11773 function __unstableSelectionHasUnmergeableBlock(state) { 11774 return getSelectedBlockClientIds(state).some((clientId) => { 11775 const blockName = getBlockName(state, clientId); 11776 const blockType = (0, import_blocks6.getBlockType)(blockName); 11777 return !blockType.merge; 11778 }); 11779 } 11780 function __unstableIsSelectionMergeable(state, isForward) { 11781 const selectionAnchor = getSelectionStart(state); 11782 const selectionFocus = getSelectionEnd(state); 11783 if (selectionAnchor.clientId === selectionFocus.clientId) { 11784 return false; 11785 } 11786 if (!selectionAnchor.attributeKey || !selectionFocus.attributeKey || typeof selectionAnchor.offset === "undefined" || typeof selectionFocus.offset === "undefined") { 11787 return false; 11788 } 11789 const anchorRootClientId = getBlockRootClientId( 11790 state, 11791 selectionAnchor.clientId 11792 ); 11793 const focusRootClientId = getBlockRootClientId( 11794 state, 11795 selectionFocus.clientId 11796 ); 11797 if (anchorRootClientId !== focusRootClientId) { 11798 return false; 11799 } 11800 const blockOrder = getBlockOrder(state, anchorRootClientId); 11801 const anchorIndex = blockOrder.indexOf(selectionAnchor.clientId); 11802 const focusIndex = blockOrder.indexOf(selectionFocus.clientId); 11803 let selectionStart, selectionEnd; 11804 if (anchorIndex > focusIndex) { 11805 selectionStart = selectionFocus; 11806 selectionEnd = selectionAnchor; 11807 } else { 11808 selectionStart = selectionAnchor; 11809 selectionEnd = selectionFocus; 11810 } 11811 const targetBlockClientId = isForward ? selectionEnd.clientId : selectionStart.clientId; 11812 const blockToMergeClientId = isForward ? selectionStart.clientId : selectionEnd.clientId; 11813 const targetBlockName = getBlockName(state, targetBlockClientId); 11814 const targetBlockType = (0, import_blocks6.getBlockType)(targetBlockName); 11815 if (!targetBlockType.merge) { 11816 return false; 11817 } 11818 const blockToMerge = getBlock(state, blockToMergeClientId); 11819 if (blockToMerge.name === targetBlockName) { 11820 return true; 11821 } 11822 const blocksToMerge = (0, import_blocks6.switchToBlockType)(blockToMerge, targetBlockName); 11823 return blocksToMerge && blocksToMerge.length; 11824 } 11825 var __unstableGetSelectedBlocksWithPartialSelection = (state) => { 11826 const selectionAnchor = getSelectionStart(state); 11827 const selectionFocus = getSelectionEnd(state); 11828 if (selectionAnchor.clientId === selectionFocus.clientId) { 11829 return EMPTY_ARRAY2; 11830 } 11831 if (!selectionAnchor.attributeKey || !selectionFocus.attributeKey || typeof selectionAnchor.offset === "undefined" || typeof selectionFocus.offset === "undefined") { 11832 return EMPTY_ARRAY2; 11833 } 11834 const anchorRootClientId = getBlockRootClientId( 11835 state, 11836 selectionAnchor.clientId 11837 ); 11838 const focusRootClientId = getBlockRootClientId( 11839 state, 11840 selectionFocus.clientId 11841 ); 11842 if (anchorRootClientId !== focusRootClientId) { 11843 return EMPTY_ARRAY2; 11844 } 11845 const blockOrder = getBlockOrder(state, anchorRootClientId); 11846 const anchorIndex = blockOrder.indexOf(selectionAnchor.clientId); 11847 const focusIndex = blockOrder.indexOf(selectionFocus.clientId); 11848 const [selectionStart, selectionEnd] = anchorIndex > focusIndex ? [selectionFocus, selectionAnchor] : [selectionAnchor, selectionFocus]; 11849 const blockA = getBlock(state, selectionStart.clientId); 11850 const blockB = getBlock(state, selectionEnd.clientId); 11851 const htmlA = blockA.attributes[selectionStart.attributeKey]; 11852 const htmlB = blockB.attributes[selectionEnd.attributeKey]; 11853 let valueA = (0, import_rich_text.create)({ html: htmlA }); 11854 let valueB = (0, import_rich_text.create)({ html: htmlB }); 11855 valueA = (0, import_rich_text.remove)(valueA, 0, selectionStart.offset); 11856 valueB = (0, import_rich_text.remove)(valueB, selectionEnd.offset, valueB.text.length); 11857 return [ 11858 { 11859 ...blockA, 11860 attributes: { 11861 ...blockA.attributes, 11862 [selectionStart.attributeKey]: (0, import_rich_text.toHTMLString)({ 11863 value: valueA 11864 }) 11865 } 11866 }, 11867 { 11868 ...blockB, 11869 attributes: { 11870 ...blockB.attributes, 11871 [selectionEnd.attributeKey]: (0, import_rich_text.toHTMLString)({ 11872 value: valueB 11873 }) 11874 } 11875 } 11876 ]; 11877 }; 11878 function getBlockOrder(state, rootClientId) { 11879 return state.blocks.order.get(rootClientId || "") || EMPTY_ARRAY2; 11880 } 11881 function getBlockIndex(state, clientId) { 11882 const rootClientId = getBlockRootClientId(state, clientId); 11883 return getBlockOrder(state, rootClientId).indexOf(clientId); 11884 } 11885 function isBlockSelected(state, clientId) { 11886 const { selectionStart, selectionEnd } = state.selection; 11887 if (selectionStart.clientId !== selectionEnd.clientId) { 11888 return false; 11889 } 11890 return selectionStart.clientId === clientId; 11891 } 11892 function hasSelectedInnerBlock(state, clientId, deep = false) { 11893 const selectedBlockClientIds = getSelectedBlockClientIds(state); 11894 if (!selectedBlockClientIds.length) { 11895 return false; 11896 } 11897 if (deep) { 11898 return selectedBlockClientIds.some( 11899 (id) => ( 11900 // Pass true because we don't care about order and it's more 11901 // performant. 11902 getBlockParents(state, id, true).includes(clientId) 11903 ) 11904 ); 11905 } 11906 return selectedBlockClientIds.some( 11907 (id) => getBlockRootClientId(state, id) === clientId 11908 ); 11909 } 11910 function hasDraggedInnerBlock(state, clientId, deep = false) { 11911 return getBlockOrder(state, clientId).some( 11912 (innerClientId) => isBlockBeingDragged(state, innerClientId) || deep && hasDraggedInnerBlock(state, innerClientId, deep) 11913 ); 11914 } 11915 function isBlockWithinSelection(state, clientId) { 11916 if (!clientId) { 11917 return false; 11918 } 11919 const clientIds = getMultiSelectedBlockClientIds(state); 11920 const index = clientIds.indexOf(clientId); 11921 return index > -1 && index < clientIds.length - 1; 11922 } 11923 function hasMultiSelection(state) { 11924 const { selectionStart, selectionEnd } = state.selection; 11925 return selectionStart.clientId !== selectionEnd.clientId; 11926 } 11927 function isMultiSelecting2(state) { 11928 return state.isMultiSelecting; 11929 } 11930 function isSelectionEnabled2(state) { 11931 return state.isSelectionEnabled; 11932 } 11933 function getBlockMode(state, clientId) { 11934 return state.blocksMode[clientId] || "visual"; 11935 } 11936 function isTyping2(state) { 11937 return state.isTyping; 11938 } 11939 function isDraggingBlocks(state) { 11940 return !!state.draggedBlocks.length; 11941 } 11942 function getDraggedBlockClientIds(state) { 11943 return state.draggedBlocks; 11944 } 11945 function isBlockBeingDragged(state, clientId) { 11946 return state.draggedBlocks.includes(clientId); 11947 } 11948 function isAncestorBeingDragged(state, clientId) { 11949 if (!isDraggingBlocks(state)) { 11950 return false; 11951 } 11952 const parents = getBlockParents(state, clientId); 11953 return parents.some( 11954 (parentClientId) => isBlockBeingDragged(state, parentClientId) 11955 ); 11956 } 11957 function isCaretWithinFormattedText() { 11958 (0, import_deprecated2.default)( 11959 'wp.data.select( "core/block-editor" ).isCaretWithinFormattedText', 11960 { 11961 since: "6.1", 11962 version: "6.3" 11963 } 11964 ); 11965 return false; 11966 } 11967 var getBlockInsertionPoint = (0, import_data4.createSelector)( 11968 (state) => { 11969 let rootClientId, index; 11970 const { 11971 insertionCue: insertionCue2, 11972 selection: { selectionEnd } 11973 } = state; 11974 if (insertionCue2 !== null) { 11975 return insertionCue2; 11976 } 11977 const { clientId } = selectionEnd; 11978 if (clientId) { 11979 rootClientId = getBlockRootClientId(state, clientId) || void 0; 11980 index = getBlockIndex(state, selectionEnd.clientId) + 1; 11981 } else { 11982 index = getBlockOrder(state).length; 11983 } 11984 return { rootClientId, index }; 11985 }, 11986 (state) => [ 11987 state.insertionCue, 11988 state.selection.selectionEnd.clientId, 11989 state.blocks.parents, 11990 state.blocks.order 11991 ] 11992 ); 11993 function isBlockInsertionPointVisible(state) { 11994 return state.insertionCue !== null; 11995 } 11996 function isValidTemplate(state) { 11997 return state.template.isValid; 11998 } 11999 function getTemplate(state) { 12000 return state.settings.template; 12001 } 12002 function getTemplateLock(state, rootClientId) { 12003 if (!rootClientId) { 12004 return state.settings.templateLock ?? false; 12005 } 12006 const blockListTemplateLock = getBlockListSettings( 12007 state, 12008 rootClientId 12009 )?.templateLock; 12010 if (blockListTemplateLock === "contentOnly" && state.editedContentOnlySection === rootClientId) { 12011 return false; 12012 } 12013 return blockListTemplateLock ?? false; 12014 } 12015 var isBlockVisibleInTheInserter = (state, blockNameOrType, rootClientId = null) => { 12016 let blockType; 12017 let blockName; 12018 if (blockNameOrType && "object" === typeof blockNameOrType) { 12019 blockType = blockNameOrType; 12020 blockName = blockNameOrType.name; 12021 } else { 12022 blockType = (0, import_blocks6.getBlockType)(blockNameOrType); 12023 blockName = blockNameOrType; 12024 } 12025 if (!blockType) { 12026 return false; 12027 } 12028 const { allowedBlockTypes } = getSettings(state); 12029 const isBlockAllowedInEditor = checkAllowList( 12030 allowedBlockTypes, 12031 blockName, 12032 true 12033 ); 12034 if (!isBlockAllowedInEditor) { 12035 return false; 12036 } 12037 const parents = (Array.isArray(blockType.parent) ? blockType.parent : []).concat(Array.isArray(blockType.ancestor) ? blockType.ancestor : []); 12038 if (parents.length > 0) { 12039 if (parents.includes("core/post-content")) { 12040 return true; 12041 } 12042 let current = rootClientId; 12043 let hasParent = false; 12044 do { 12045 if (parents.includes(getBlockName(state, current))) { 12046 hasParent = true; 12047 break; 12048 } 12049 current = state.blocks.parents.get(current); 12050 } while (current); 12051 return hasParent; 12052 } 12053 return true; 12054 }; 12055 var canInsertBlockTypeUnmemoized = (state, blockName, rootClientId = null) => { 12056 if (!isBlockVisibleInTheInserter(state, blockName, rootClientId)) { 12057 return false; 12058 } 12059 let blockType; 12060 if (blockName && "object" === typeof blockName) { 12061 blockType = blockName; 12062 blockName = blockType.name; 12063 } else { 12064 blockType = (0, import_blocks6.getBlockType)(blockName); 12065 } 12066 const rootTemplateLock = getTemplateLock(state, rootClientId); 12067 if (rootTemplateLock && rootTemplateLock !== "contentOnly") { 12068 return false; 12069 } 12070 const blockEditingMode = getBlockEditingMode(state, rootClientId ?? ""); 12071 if (blockEditingMode === "disabled") { 12072 return false; 12073 } 12074 const parentBlockListSettings = getBlockListSettings(state, rootClientId); 12075 if (rootClientId && parentBlockListSettings === void 0) { 12076 return false; 12077 } 12078 const isContentRoleBlock = isContentBlock3(blockName); 12079 const isParentSectionBlock = !!isSectionBlock(state, rootClientId); 12080 const isBlockWithinSection = !!getParentSectionBlock( 12081 state, 12082 rootClientId 12083 ); 12084 if ((isParentSectionBlock || isBlockWithinSection) && !isContentRoleBlock) { 12085 return false; 12086 } 12087 if ((isParentSectionBlock || blockEditingMode === "contentOnly") && !isContainerInsertableToInContentOnlyMode( 12088 state, 12089 blockName, 12090 rootClientId 12091 )) { 12092 return false; 12093 } 12094 const parentName = getBlockName(state, rootClientId); 12095 const parentBlockType = (0, import_blocks6.getBlockType)(parentName); 12096 const parentAllowedChildBlocks = parentBlockType?.allowedBlocks; 12097 let hasParentAllowedBlock = checkAllowList( 12098 parentAllowedChildBlocks, 12099 blockName 12100 ); 12101 if (hasParentAllowedBlock !== false) { 12102 const parentAllowedBlocks = parentBlockListSettings?.allowedBlocks; 12103 const hasParentListAllowedBlock = checkAllowList( 12104 parentAllowedBlocks, 12105 blockName 12106 ); 12107 if (hasParentListAllowedBlock !== null) { 12108 hasParentAllowedBlock = hasParentListAllowedBlock; 12109 } 12110 } 12111 const blockAllowedParentBlocks = blockType.parent; 12112 const hasBlockAllowedParent = checkAllowList( 12113 blockAllowedParentBlocks, 12114 parentName 12115 ); 12116 let hasBlockAllowedAncestor = true; 12117 const blockAllowedAncestorBlocks = blockType.ancestor; 12118 if (blockAllowedAncestorBlocks) { 12119 const ancestors = [ 12120 rootClientId, 12121 ...getBlockParents(state, rootClientId) 12122 ]; 12123 hasBlockAllowedAncestor = ancestors.some( 12124 (ancestorClientId) => checkAllowList( 12125 blockAllowedAncestorBlocks, 12126 getBlockName(state, ancestorClientId) 12127 ) 12128 ); 12129 } 12130 const canInsert = hasBlockAllowedAncestor && (hasParentAllowedBlock === null && hasBlockAllowedParent === null || hasParentAllowedBlock === true || hasBlockAllowedParent === true); 12131 if (!canInsert) { 12132 return canInsert; 12133 } 12134 return (0, import_hooks2.applyFilters)( 12135 "blockEditor.__unstableCanInsertBlockType", 12136 canInsert, 12137 blockType, 12138 rootClientId, 12139 { 12140 // Pass bound selectors of the current registry. If we're in a nested 12141 // context, the data will differ from the one selected from the root 12142 // registry. 12143 getBlock: getBlock.bind(null, state), 12144 getBlockParentsByBlockName: getBlockParentsByBlockName.bind( 12145 null, 12146 state 12147 ) 12148 } 12149 ); 12150 }; 12151 var canInsertBlockType = (0, import_data4.createRegistrySelector)( 12152 (select3) => (0, import_data4.createSelector)( 12153 canInsertBlockTypeUnmemoized, 12154 (state, blockName, rootClientId) => getInsertBlockTypeDependants(select3)(state, rootClientId) 12155 ) 12156 ); 12157 function canInsertBlocks(state, clientIds, rootClientId = null) { 12158 return clientIds.every( 12159 (id) => canInsertBlockType(state, getBlockName(state, id), rootClientId) 12160 ); 12161 } 12162 function canRemoveBlock(state, clientId) { 12163 const attributes = getBlockAttributes(state, clientId); 12164 if (attributes === null) { 12165 return true; 12166 } 12167 if (attributes.lock?.remove !== void 0) { 12168 return !attributes.lock.remove; 12169 } 12170 const rootClientId = getBlockRootClientId(state, clientId); 12171 const rootTemplateLock = getTemplateLock(state, rootClientId); 12172 if (rootTemplateLock && rootTemplateLock !== "contentOnly") { 12173 return false; 12174 } 12175 const isBlockWithinSection = !!getParentSectionBlock(state, clientId); 12176 const isContentRoleBlock = isContentBlock3( 12177 getBlockName(state, clientId) 12178 ); 12179 if (isBlockWithinSection && !isContentRoleBlock) { 12180 return false; 12181 } 12182 const isParentSectionBlock = !!isSectionBlock(state, rootClientId); 12183 const rootBlockEditingMode = getBlockEditingMode(state, rootClientId); 12184 if ((isParentSectionBlock || rootBlockEditingMode === "contentOnly") && !isContainerInsertableToInContentOnlyMode( 12185 state, 12186 getBlockName(state, clientId), 12187 rootClientId 12188 )) { 12189 return false; 12190 } 12191 return rootBlockEditingMode !== "disabled"; 12192 } 12193 function canRemoveBlocks(state, clientIds) { 12194 return clientIds.every((clientId) => canRemoveBlock(state, clientId)); 12195 } 12196 function canMoveBlock(state, clientId) { 12197 const attributes = getBlockAttributes(state, clientId); 12198 if (attributes === null) { 12199 return true; 12200 } 12201 if (attributes.lock?.move !== void 0) { 12202 return !attributes.lock.move; 12203 } 12204 const rootClientId = getBlockRootClientId(state, clientId); 12205 const rootTemplateLock = getTemplateLock(state, rootClientId); 12206 if (rootTemplateLock === "all") { 12207 return false; 12208 } 12209 const isBlockWithinSection = !!getParentSectionBlock(state, clientId); 12210 const isContentRoleBlock = isContentBlock3( 12211 getBlockName(state, clientId) 12212 ); 12213 if (isBlockWithinSection && !isContentRoleBlock) { 12214 return false; 12215 } 12216 const isParentSectionBlock = !!isSectionBlock(state, rootClientId); 12217 const rootBlockEditingMode = getBlockEditingMode(state, rootClientId); 12218 if ((isParentSectionBlock || rootBlockEditingMode === "contentOnly") && !isContainerInsertableToInContentOnlyMode( 12219 state, 12220 getBlockName(state, clientId), 12221 rootClientId 12222 )) { 12223 return false; 12224 } 12225 return getBlockEditingMode(state, rootClientId) !== "disabled"; 12226 } 12227 function canMoveBlocks(state, clientIds) { 12228 return clientIds.every((clientId) => canMoveBlock(state, clientId)); 12229 } 12230 function canEditBlock(state, clientId) { 12231 const attributes = getBlockAttributes(state, clientId); 12232 if (attributes === null) { 12233 return true; 12234 } 12235 const { lock: lock4 } = attributes; 12236 return !lock4?.edit; 12237 } 12238 function canLockBlockType(state, nameOrType) { 12239 if (!(0, import_blocks6.hasBlockSupport)(nameOrType, "lock", true)) { 12240 return false; 12241 } 12242 return !!state.settings?.canLockBlocks; 12243 } 12244 function getInsertUsage(state, id) { 12245 return state.preferences.insertUsage?.[id] ?? null; 12246 } 12247 var canIncludeBlockTypeInInserter = (state, blockType, rootClientId) => { 12248 if (!(0, import_blocks6.hasBlockSupport)(blockType, "inserter", true)) { 12249 return false; 12250 } 12251 return canInsertBlockTypeUnmemoized(state, blockType.name, rootClientId); 12252 }; 12253 var getItemFromVariation = (state, item) => (variation) => { 12254 const variationId = `$item.id}/$variation.name}`; 12255 const { time, count = 0 } = getInsertUsage(state, variationId) || {}; 12256 return { 12257 ...item, 12258 id: variationId, 12259 icon: variation.icon || item.icon, 12260 title: variation.title || item.title, 12261 description: variation.description || item.description, 12262 category: variation.category || item.category, 12263 // If `example` is explicitly undefined for the variation, the preview will not be shown. 12264 example: variation.hasOwnProperty("example") ? variation.example : item.example, 12265 initialAttributes: { 12266 ...item.initialAttributes, 12267 ...variation.attributes 12268 }, 12269 innerBlocks: variation.innerBlocks, 12270 keywords: variation.keywords || item.keywords, 12271 frecency: calculateFrecency(time, count), 12272 // Pass through search-only flag for block-scope variations. 12273 isSearchOnly: variation.isSearchOnly 12274 }; 12275 }; 12276 var calculateFrecency = (time, count) => { 12277 if (!time) { 12278 return count; 12279 } 12280 const duration = Date.now() - time; 12281 switch (true) { 12282 case duration < MILLISECONDS_PER_HOUR: 12283 return count * 4; 12284 case duration < MILLISECONDS_PER_DAY: 12285 return count * 2; 12286 case duration < MILLISECONDS_PER_WEEK: 12287 return count / 2; 12288 default: 12289 return count / 4; 12290 } 12291 }; 12292 var buildBlockTypeItem = (state, { buildScope = "inserter" }) => (blockType) => { 12293 const id = blockType.name; 12294 let isDisabled = false; 12295 if (!(0, import_blocks6.hasBlockSupport)(blockType.name, "multiple", true)) { 12296 isDisabled = getBlocksByClientId( 12297 state, 12298 getClientIdsWithDescendants(state) 12299 ).some(({ name }) => name === blockType.name); 12300 } 12301 const { time, count = 0 } = getInsertUsage(state, id) || {}; 12302 const blockItemBase = { 12303 id, 12304 name: blockType.name, 12305 title: blockType.title, 12306 icon: blockType.icon, 12307 isDisabled, 12308 frecency: calculateFrecency(time, count) 12309 }; 12310 if (buildScope === "transform") { 12311 return blockItemBase; 12312 } 12313 const inserterVariations = (0, import_blocks6.getBlockVariations)( 12314 blockType.name, 12315 "inserter" 12316 ); 12317 const blockVariations = (0, import_blocks6.getBlockVariations)(blockType.name, "block"); 12318 const inserterVariationNames = new Set( 12319 inserterVariations.map((variation) => variation.name) 12320 ); 12321 const allVariations = [ 12322 ...inserterVariations, 12323 ...blockVariations.filter( 12324 (variation) => !inserterVariationNames.has(variation.name) 12325 ).map((variation) => ({ 12326 ...variation, 12327 isSearchOnly: true, 12328 // Block-scope `isDefault` is for the placeholder picker, 12329 // not for the inserter, so don't carry it over. 12330 isDefault: false 12331 })) 12332 ]; 12333 return { 12334 ...blockItemBase, 12335 initialAttributes: {}, 12336 description: blockType.description, 12337 category: blockType.category, 12338 keywords: blockType.keywords, 12339 parent: blockType.parent, 12340 ancestor: blockType.ancestor, 12341 variations: allVariations, 12342 example: blockType.example, 12343 utility: 1 12344 // Deprecated. 12345 }; 12346 }; 12347 var getInserterItems = (0, import_data4.createRegistrySelector)( 12348 (select3) => (0, import_data4.createSelector)( 12349 (state, rootClientId = null, options = DEFAULT_INSERTER_OPTIONS) => { 12350 const buildReusableBlockInserterItem = (reusableBlock) => { 12351 const icon = !reusableBlock.wp_pattern_sync_status ? { 12352 src: symbol_default, 12353 foreground: "var(--wp-block-synced-color)" 12354 } : symbol_default; 12355 const userPattern = mapUserPattern(reusableBlock); 12356 const { time, count = 0 } = getInsertUsage(state, userPattern.name) || {}; 12357 const frecency = calculateFrecency(time, count); 12358 return { 12359 id: userPattern.name, 12360 name: "core/block", 12361 initialAttributes: { ref: reusableBlock.id }, 12362 title: userPattern.title, 12363 icon, 12364 category: "reusable", 12365 keywords: ["reusable"], 12366 isDisabled: false, 12367 utility: 1, 12368 // Deprecated. 12369 frecency, 12370 content: userPattern.content, 12371 get blocks() { 12372 return getParsedPattern(userPattern).blocks; 12373 }, 12374 syncStatus: userPattern.syncStatus 12375 }; 12376 }; 12377 const patternInserterItems = canInsertBlockTypeUnmemoized( 12378 state, 12379 "core/block", 12380 rootClientId 12381 ) ? unlock(select3(STORE_NAME)).getReusableBlocks().map(buildReusableBlockInserterItem) : []; 12382 const buildBlockTypeInserterItem = buildBlockTypeItem(state, { 12383 buildScope: "inserter" 12384 }); 12385 let blockTypeInserterItems = (0, import_blocks6.getBlockTypes)().filter( 12386 (blockType) => (0, import_blocks6.hasBlockSupport)(blockType, "inserter", true) 12387 ).map(buildBlockTypeInserterItem); 12388 if (options[isFiltered] !== false) { 12389 blockTypeInserterItems = blockTypeInserterItems.filter( 12390 (blockType) => canIncludeBlockTypeInInserter( 12391 state, 12392 blockType, 12393 rootClientId 12394 ) 12395 ); 12396 } else { 12397 blockTypeInserterItems = blockTypeInserterItems.filter( 12398 (blockType) => isBlockVisibleInTheInserter( 12399 state, 12400 blockType, 12401 rootClientId 12402 ) 12403 ).map((blockType) => ({ 12404 ...blockType, 12405 isAllowedInCurrentRoot: canIncludeBlockTypeInInserter( 12406 state, 12407 blockType, 12408 rootClientId 12409 ) 12410 })); 12411 } 12412 const items = blockTypeInserterItems.reduce( 12413 (accumulator, item) => { 12414 const { variations = [] } = item; 12415 if (!variations.some(({ isDefault }) => isDefault)) { 12416 accumulator.push(item); 12417 } 12418 if (variations.length) { 12419 const variationMapper = getItemFromVariation( 12420 state, 12421 item 12422 ); 12423 accumulator.push( 12424 ...variations.map(variationMapper) 12425 ); 12426 } 12427 return accumulator; 12428 }, 12429 [] 12430 ); 12431 const groupByType = (blocks2, block) => { 12432 const { core, noncore } = blocks2; 12433 const type = block.name.startsWith("core/") ? core : noncore; 12434 type.push(block); 12435 return blocks2; 12436 }; 12437 const { core: coreItems, noncore: nonCoreItems } = items.reduce( 12438 groupByType, 12439 { core: [], noncore: [] } 12440 ); 12441 const sortedBlockTypes = [...coreItems, ...nonCoreItems]; 12442 return [...sortedBlockTypes, ...patternInserterItems]; 12443 }, 12444 (state, rootClientId) => [ 12445 (0, import_blocks6.getBlockTypes)(), 12446 unlock(select3(STORE_NAME)).getReusableBlocks(), 12447 state.blocks.order, 12448 state.preferences.insertUsage, 12449 ...getInsertBlockTypeDependants(select3)(state, rootClientId) 12450 ] 12451 ) 12452 ); 12453 var getBlockTransformItems = (0, import_data4.createRegistrySelector)( 12454 (select3) => (0, import_data4.createSelector)( 12455 (state, blocks2, rootClientId = null) => { 12456 const normalizedBlocks = Array.isArray(blocks2) ? blocks2 : [blocks2]; 12457 const buildBlockTypeTransformItem = buildBlockTypeItem(state, { 12458 buildScope: "transform" 12459 }); 12460 const blockTypeTransformItems = (0, import_blocks6.getBlockTypes)().filter( 12461 (blockType) => canIncludeBlockTypeInInserter( 12462 state, 12463 blockType, 12464 rootClientId 12465 ) 12466 ).map(buildBlockTypeTransformItem); 12467 const itemsByName = Object.fromEntries( 12468 Object.entries(blockTypeTransformItems).map( 12469 ([, value]) => [value.name, value] 12470 ) 12471 ); 12472 const possibleTransforms = (0, import_blocks6.getPossibleBlockTransformations)( 12473 normalizedBlocks 12474 ).reduce((accumulator, block) => { 12475 if (itemsByName[block?.name]) { 12476 accumulator.push(itemsByName[block.name]); 12477 } 12478 return accumulator; 12479 }, []); 12480 return orderBy( 12481 possibleTransforms, 12482 (block) => itemsByName[block.name].frecency, 12483 "desc" 12484 ); 12485 }, 12486 (state, blocks2, rootClientId) => [ 12487 (0, import_blocks6.getBlockTypes)(), 12488 state.preferences.insertUsage, 12489 ...getInsertBlockTypeDependants(select3)(state, rootClientId) 12490 ] 12491 ) 12492 ); 12493 var hasInserterItems = (state, rootClientId = null) => { 12494 const hasBlockType = (0, import_blocks6.getBlockTypes)().some( 12495 (blockType) => canIncludeBlockTypeInInserter(state, blockType, rootClientId) 12496 ); 12497 if (hasBlockType) { 12498 return true; 12499 } 12500 const hasReusableBlock = canInsertBlockTypeUnmemoized( 12501 state, 12502 "core/block", 12503 rootClientId 12504 ); 12505 return hasReusableBlock; 12506 }; 12507 var getAllowedBlocks = (0, import_data4.createRegistrySelector)( 12508 (select3) => (0, import_data4.createSelector)( 12509 (state, rootClientId = null) => { 12510 if (!rootClientId) { 12511 return; 12512 } 12513 const blockTypes = (0, import_blocks6.getBlockTypes)().filter( 12514 (blockType) => canIncludeBlockTypeInInserter(state, blockType, rootClientId) 12515 ); 12516 const hasReusableBlock = canInsertBlockTypeUnmemoized( 12517 state, 12518 "core/block", 12519 rootClientId 12520 ); 12521 if (hasReusableBlock) { 12522 blockTypes.push("core/block"); 12523 } 12524 return blockTypes; 12525 }, 12526 (state, rootClientId) => [ 12527 (0, import_blocks6.getBlockTypes)(), 12528 ...getInsertBlockTypeDependants(select3)(state, rootClientId) 12529 ] 12530 ) 12531 ); 12532 var __experimentalGetAllowedBlocks = (0, import_data4.createSelector)( 12533 (state, rootClientId = null) => { 12534 (0, import_deprecated2.default)( 12535 'wp.data.select( "core/block-editor" ).__experimentalGetAllowedBlocks', 12536 { 12537 alternative: 'wp.data.select( "core/block-editor" ).getAllowedBlocks', 12538 since: "6.2", 12539 version: "6.4" 12540 } 12541 ); 12542 return getAllowedBlocks(state, rootClientId); 12543 }, 12544 (state, rootClientId) => getAllowedBlocks.getDependants(state, rootClientId) 12545 ); 12546 function getDirectInsertBlock(state, rootClientId = null) { 12547 if (!rootClientId) { 12548 return; 12549 } 12550 const { defaultBlock, directInsert } = state.blockListSettings[rootClientId] ?? {}; 12551 if (!defaultBlock || !directInsert) { 12552 return; 12553 } 12554 return defaultBlock; 12555 } 12556 function __experimentalGetDirectInsertBlock(state, rootClientId = null) { 12557 (0, import_deprecated2.default)( 12558 'wp.data.select( "core/block-editor" ).__experimentalGetDirectInsertBlock', 12559 { 12560 alternative: 'wp.data.select( "core/block-editor" ).getDirectInsertBlock', 12561 since: "6.3", 12562 version: "6.4" 12563 } 12564 ); 12565 return getDirectInsertBlock(state, rootClientId); 12566 } 12567 var __experimentalGetParsedPattern = (0, import_data4.createRegistrySelector)( 12568 (select3) => (state, patternName) => { 12569 const pattern = unlock(select3(STORE_NAME)).getPatternBySlug( 12570 patternName 12571 ); 12572 return pattern ? getParsedPattern(pattern) : null; 12573 } 12574 ); 12575 var getAllowedPatternsDependants = (select3) => (state, rootClientId) => [ 12576 ...getAllPatternsDependants(select3)(state), 12577 ...getInsertBlockTypeDependants(select3)(state, rootClientId) 12578 ]; 12579 var patternsWithParsedBlocks = /* @__PURE__ */ new WeakMap(); 12580 function enhancePatternWithParsedBlocks(pattern) { 12581 let enhancedPattern = patternsWithParsedBlocks.get(pattern); 12582 if (!enhancedPattern) { 12583 enhancedPattern = { 12584 ...pattern, 12585 get blocks() { 12586 return getParsedPattern(pattern).blocks; 12587 } 12588 }; 12589 patternsWithParsedBlocks.set(pattern, enhancedPattern); 12590 } 12591 return enhancedPattern; 12592 } 12593 var __experimentalGetAllowedPatterns = (0, import_data4.createRegistrySelector)( 12594 (select3) => { 12595 return (0, import_data4.createSelector)( 12596 (state, rootClientId = null, options = DEFAULT_INSERTER_OPTIONS) => { 12597 const { getAllPatterns: getAllPatterns2 } = unlock(select3(STORE_NAME)); 12598 const patterns = getAllPatterns2(); 12599 const { allowedBlockTypes } = getSettings(state); 12600 const parsedPatterns = patterns.filter(({ inserter = true }) => !!inserter).map(enhancePatternWithParsedBlocks); 12601 const availableParsedPatterns = parsedPatterns.filter( 12602 (pattern) => checkAllowListRecursive( 12603 getGrammar(pattern), 12604 allowedBlockTypes 12605 ) 12606 ); 12607 const patternsAllowed = availableParsedPatterns.filter( 12608 (pattern) => getGrammar(pattern).every( 12609 ({ blockName: name }) => options[isFiltered] !== false ? canInsertBlockType( 12610 state, 12611 name, 12612 rootClientId 12613 ) : isBlockVisibleInTheInserter( 12614 state, 12615 name, 12616 rootClientId 12617 ) 12618 ) 12619 ); 12620 return patternsAllowed; 12621 }, 12622 getAllowedPatternsDependants(select3) 12623 ); 12624 } 12625 ); 12626 var getPatternsByBlockTypes = (0, import_data4.createRegistrySelector)( 12627 (select3) => (0, import_data4.createSelector)( 12628 (state, blockNames, rootClientId = null) => { 12629 if (!blockNames) { 12630 return EMPTY_ARRAY2; 12631 } 12632 const patterns = select3(STORE_NAME).__experimentalGetAllowedPatterns( 12633 rootClientId 12634 ); 12635 const normalizedBlockNames = Array.isArray(blockNames) ? blockNames : [blockNames]; 12636 const filteredPatterns = patterns.filter( 12637 (pattern) => pattern?.blockTypes?.some?.( 12638 (blockName) => normalizedBlockNames.includes(blockName) 12639 ) 12640 ); 12641 if (filteredPatterns.length === 0) { 12642 return EMPTY_ARRAY2; 12643 } 12644 return filteredPatterns; 12645 }, 12646 (state, blockNames, rootClientId) => getAllowedPatternsDependants(select3)(state, rootClientId) 12647 ) 12648 ); 12649 var __experimentalGetPatternsByBlockTypes = (0, import_data4.createRegistrySelector)( 12650 (select3) => { 12651 (0, import_deprecated2.default)( 12652 'wp.data.select( "core/block-editor" ).__experimentalGetPatternsByBlockTypes', 12653 { 12654 alternative: 'wp.data.select( "core/block-editor" ).getPatternsByBlockTypes', 12655 since: "6.2", 12656 version: "6.4" 12657 } 12658 ); 12659 return select3(STORE_NAME).getPatternsByBlockTypes; 12660 } 12661 ); 12662 var __experimentalGetPatternTransformItems = (0, import_data4.createRegistrySelector)( 12663 (select3) => (0, import_data4.createSelector)( 12664 (state, blocks2, rootClientId = null) => { 12665 if (!blocks2) { 12666 return EMPTY_ARRAY2; 12667 } 12668 if (blocks2.some( 12669 ({ clientId, innerBlocks }) => innerBlocks.length || areInnerBlocksControlled(state, clientId) 12670 )) { 12671 return EMPTY_ARRAY2; 12672 } 12673 const selectedBlockNames = Array.from( 12674 new Set(blocks2.map(({ name }) => name)) 12675 ); 12676 return select3(STORE_NAME).getPatternsByBlockTypes( 12677 selectedBlockNames, 12678 rootClientId 12679 ); 12680 }, 12681 (state, blocks2, rootClientId) => getAllowedPatternsDependants(select3)(state, rootClientId) 12682 ) 12683 ); 12684 function getBlockListSettings(state, clientId) { 12685 return state.blockListSettings[clientId]; 12686 } 12687 function getSettings(state) { 12688 return state.settings; 12689 } 12690 function isLastBlockChangePersistent(state) { 12691 return state.blocks.isPersistentChange; 12692 } 12693 var __experimentalGetBlockListSettingsForBlocks = (0, import_data4.createSelector)( 12694 (state, clientIds = []) => { 12695 return clientIds.reduce((blockListSettingsForBlocks, clientId) => { 12696 if (!state.blockListSettings[clientId]) { 12697 return blockListSettingsForBlocks; 12698 } 12699 return { 12700 ...blockListSettingsForBlocks, 12701 [clientId]: state.blockListSettings[clientId] 12702 }; 12703 }, {}); 12704 }, 12705 (state) => [state.blockListSettings] 12706 ); 12707 var __experimentalGetReusableBlockTitle = (0, import_data4.createRegistrySelector)( 12708 (select3) => (0, import_data4.createSelector)( 12709 (state, ref) => { 12710 (0, import_deprecated2.default)( 12711 "wp.data.select( 'core/block-editor' ).__experimentalGetReusableBlockTitle", 12712 { 12713 since: "6.6", 12714 version: "6.8" 12715 } 12716 ); 12717 const reusableBlock = unlock(select3(STORE_NAME)).getReusableBlocks().find((block) => block.id === ref); 12718 if (!reusableBlock) { 12719 return null; 12720 } 12721 return reusableBlock.title?.raw; 12722 }, 12723 () => [unlock(select3(STORE_NAME)).getReusableBlocks()] 12724 ) 12725 ); 12726 function __unstableIsLastBlockChangeIgnored(state) { 12727 return state.blocks.isIgnoredChange; 12728 } 12729 function __experimentalGetLastBlockAttributeChanges(state) { 12730 return state.lastBlockAttributesChange; 12731 } 12732 function hasBlockMovingClientId() { 12733 (0, import_deprecated2.default)( 12734 'wp.data.select( "core/block-editor" ).hasBlockMovingClientId', 12735 { 12736 since: "6.7", 12737 hint: "Block moving mode feature has been removed" 12738 } 12739 ); 12740 return false; 12741 } 12742 function didAutomaticChange(state) { 12743 return !!state.automaticChangeStatus; 12744 } 12745 function isBlockHighlighted(state, clientId) { 12746 return state.highlightedBlock === clientId; 12747 } 12748 function areInnerBlocksControlled(state, clientId) { 12749 return !!state.blocks.controlledInnerBlocks[clientId]; 12750 } 12751 var __experimentalGetActiveBlockIdByBlockNames = (0, import_data4.createSelector)( 12752 (state, validBlockNames) => { 12753 if (!validBlockNames.length) { 12754 return null; 12755 } 12756 const selectedBlockClientId = getSelectedBlockClientId(state); 12757 if (validBlockNames.includes( 12758 getBlockName(state, selectedBlockClientId) 12759 )) { 12760 return selectedBlockClientId; 12761 } 12762 const multiSelectedBlockClientIds = getMultiSelectedBlockClientIds(state); 12763 const entityAreaParents = getBlockParentsByBlockName( 12764 state, 12765 selectedBlockClientId || multiSelectedBlockClientIds[0], 12766 validBlockNames 12767 ); 12768 if (entityAreaParents) { 12769 return entityAreaParents[entityAreaParents.length - 1]; 12770 } 12771 return null; 12772 }, 12773 (state, validBlockNames) => [ 12774 state.selection.selectionStart.clientId, 12775 state.selection.selectionEnd.clientId, 12776 validBlockNames 12777 ] 12778 ); 12779 function wasBlockJustInserted(state, clientId, source) { 12780 const { lastBlockInserted: lastBlockInserted2 } = state; 12781 return lastBlockInserted2.clientIds?.includes(clientId) && lastBlockInserted2.source === source; 12782 } 12783 function isBlockVisible(state, clientId) { 12784 return state.blockVisibility?.[clientId] ?? true; 12785 } 12786 function getHoveredBlockClientId() { 12787 (0, import_deprecated2.default)( 12788 "wp.data.select( 'core/block-editor' ).getHoveredBlockClientId", 12789 { 12790 since: "6.9", 12791 version: "7.1" 12792 } 12793 ); 12794 return void 0; 12795 } 12796 var __unstableGetVisibleBlocks = (0, import_data4.createSelector)( 12797 (state) => { 12798 const visibleBlocks = new Set( 12799 Object.keys(state.blockVisibility).filter( 12800 (key) => state.blockVisibility[key] 12801 ) 12802 ); 12803 if (visibleBlocks.size === 0) { 12804 return EMPTY_SET; 12805 } 12806 return visibleBlocks; 12807 }, 12808 (state) => [state.blockVisibility] 12809 ); 12810 function __unstableHasActiveBlockOverlayActive(state, clientId) { 12811 if (getBlockEditingMode(state, clientId) !== "default") { 12812 return false; 12813 } 12814 if (!canEditBlock(state, clientId)) { 12815 return true; 12816 } 12817 if (isZoomOut(state)) { 12818 const sectionRootClientId = getSectionRootClientId(state); 12819 if (sectionRootClientId) { 12820 const sectionClientIds = getBlockOrder( 12821 state, 12822 sectionRootClientId 12823 ); 12824 if (sectionClientIds?.includes(clientId)) { 12825 return true; 12826 } 12827 } else if (clientId && !getBlockRootClientId(state, clientId)) { 12828 return true; 12829 } 12830 } 12831 const blockSupportDisable = (0, import_blocks6.hasBlockSupport)( 12832 getBlockName(state, clientId), 12833 "__experimentalDisableBlockOverlay", 12834 false 12835 ); 12836 const shouldEnableIfUnselected = blockSupportDisable ? false : areInnerBlocksControlled(state, clientId); 12837 return shouldEnableIfUnselected && !isBlockSelected(state, clientId) && !hasSelectedInnerBlock(state, clientId, true); 12838 } 12839 function __unstableIsWithinBlockOverlay(state, clientId) { 12840 let parent = state.blocks.parents.get(clientId); 12841 while (!!parent) { 12842 if (__unstableHasActiveBlockOverlayActive(state, parent)) { 12843 return true; 12844 } 12845 parent = state.blocks.parents.get(parent); 12846 } 12847 return false; 12848 } 12849 function getBlockEditingMode(state, clientId = "") { 12850 if (clientId === null) { 12851 clientId = ""; 12852 } 12853 if (state.derivedBlockEditingModes?.has(clientId)) { 12854 return state.derivedBlockEditingModes.get(clientId); 12855 } 12856 if (state.blockEditingModes.has(clientId)) { 12857 return state.blockEditingModes.get(clientId); 12858 } 12859 return "default"; 12860 } 12861 var isUngroupable = (0, import_data4.createRegistrySelector)( 12862 (select3) => (state, clientId = "") => { 12863 const _clientId = clientId || getSelectedBlockClientId(state); 12864 if (!_clientId) { 12865 return false; 12866 } 12867 if (isSectionBlock(state, _clientId)) { 12868 return false; 12869 } 12870 const { getGroupingBlockName } = select3(import_blocks6.store); 12871 const block = getBlock(state, _clientId); 12872 const groupingBlockName = getGroupingBlockName(); 12873 const _isUngroupable = block && (block.name === groupingBlockName || (0, import_blocks6.getBlockType)(block.name)?.transforms?.ungroup) && !!block.innerBlocks.length; 12874 return _isUngroupable && canRemoveBlock(state, _clientId); 12875 } 12876 ); 12877 var isGroupable = (0, import_data4.createRegistrySelector)( 12878 (select3) => (state, clientIds = EMPTY_ARRAY2) => { 12879 const { getGroupingBlockName } = select3(import_blocks6.store); 12880 const groupingBlockName = getGroupingBlockName(); 12881 const _clientIds = clientIds?.length ? clientIds : getSelectedBlockClientIds(state); 12882 const rootClientId = _clientIds?.length ? getBlockRootClientId(state, _clientIds[0]) : void 0; 12883 const groupingBlockAvailable = canInsertBlockType( 12884 state, 12885 groupingBlockName, 12886 rootClientId 12887 ); 12888 const _isGroupable = groupingBlockAvailable && _clientIds.length; 12889 return _isGroupable && canRemoveBlocks(state, _clientIds); 12890 } 12891 ); 12892 var __unstableGetContentLockingParent = (state, clientId) => { 12893 (0, import_deprecated2.default)( 12894 "wp.data.select( 'core/block-editor' ).__unstableGetContentLockingParent", 12895 { 12896 since: "6.1", 12897 version: "6.7" 12898 } 12899 ); 12900 return getContentLockingParent(state, clientId); 12901 }; 12902 function __unstableGetTemporarilyEditingAsBlocks(state) { 12903 (0, import_deprecated2.default)( 12904 "wp.data.select( 'core/block-editor' ).__unstableGetTemporarilyEditingAsBlocks", 12905 { 12906 since: "6.1", 12907 version: "6.7" 12908 } 12909 ); 12910 return getEditedContentOnlySection(state); 12911 } 12912 12913 // packages/block-editor/build-module/store/private-actions.js 12914 var private_actions_exports = {}; 12915 __export(private_actions_exports, { 12916 __experimentalUpdateSettings: () => __experimentalUpdateSettings, 12917 clearBlockRemovalPrompt: () => clearBlockRemovalPrompt, 12918 deleteStyleOverride: () => deleteStyleOverride, 12919 editContentOnlySection: () => editContentOnlySection, 12920 ensureDefaultBlock: () => ensureDefaultBlock, 12921 expandBlock: () => expandBlock, 12922 hideBlockInterface: () => hideBlockInterface, 12923 privateRemoveBlocks: () => privateRemoveBlocks, 12924 resetZoomLevel: () => resetZoomLevel, 12925 setBlockRemovalRules: () => setBlockRemovalRules, 12926 setInsertionPoint: () => setInsertionPoint, 12927 setLastFocus: () => setLastFocus, 12928 setOpenedBlockSettingsMenu: () => setOpenedBlockSettingsMenu, 12929 setStyleOverride: () => setStyleOverride, 12930 setZoomLevel: () => setZoomLevel, 12931 showBlockInterface: () => showBlockInterface, 12932 startDragging: () => startDragging, 12933 stopDragging: () => stopDragging, 12934 stopEditingContentOnlySection: () => stopEditingContentOnlySection, 12935 toggleBlockSpotlight: () => toggleBlockSpotlight 12936 }); 12937 var import_element7 = __toESM(require_element()); 12938 var import_deprecated3 = __toESM(require_deprecated()); 12939 var import_a11y2 = __toESM(require_a11y()); 12940 var import_i18n3 = __toESM(require_i18n()); 12941 var castArray = (maybeArray) => Array.isArray(maybeArray) ? maybeArray : [maybeArray]; 12942 var privateSettings = [ 12943 "inserterMediaCategories", 12944 "blockInspectorAnimation", 12945 "mediaSideload" 12946 ]; 12947 function __experimentalUpdateSettings(settings2, { stripExperimentalSettings = false, reset = false } = {}) { 12948 let incomingSettings = settings2; 12949 if (Object.hasOwn(incomingSettings, "__unstableIsPreviewMode")) { 12950 (0, import_deprecated3.default)( 12951 "__unstableIsPreviewMode argument in wp.data.dispatch('core/block-editor').updateSettings", 12952 { 12953 since: "6.8", 12954 alternative: "isPreviewMode" 12955 } 12956 ); 12957 incomingSettings = { ...incomingSettings }; 12958 incomingSettings.isPreviewMode = incomingSettings.__unstableIsPreviewMode; 12959 delete incomingSettings.__unstableIsPreviewMode; 12960 } 12961 let cleanSettings = incomingSettings; 12962 if (stripExperimentalSettings && import_element7.Platform.OS === "web") { 12963 cleanSettings = {}; 12964 for (const key in incomingSettings) { 12965 if (!privateSettings.includes(key)) { 12966 cleanSettings[key] = incomingSettings[key]; 12967 } 12968 } 12969 } 12970 return { 12971 type: "UPDATE_SETTINGS", 12972 settings: cleanSettings, 12973 reset 12974 }; 12975 } 12976 function hideBlockInterface() { 12977 return { 12978 type: "HIDE_BLOCK_INTERFACE" 12979 }; 12980 } 12981 function showBlockInterface() { 12982 return { 12983 type: "SHOW_BLOCK_INTERFACE" 12984 }; 12985 } 12986 var privateRemoveBlocks = (clientIds, selectPrevious = true, forceRemove = false) => ({ select: select3, dispatch, registry }) => { 12987 if (!clientIds || !clientIds.length) { 12988 return; 12989 } 12990 clientIds = castArray(clientIds); 12991 const canRemoveBlocks2 = select3.canRemoveBlocks(clientIds); 12992 if (!canRemoveBlocks2) { 12993 return; 12994 } 12995 const rules = !forceRemove && select3.getBlockRemovalRules(); 12996 if (rules) { 12997 let flattenBlocks22 = function(blocks2) { 12998 const result = []; 12999 const stack = [...blocks2]; 13000 while (stack.length) { 13001 const { innerBlocks, ...block } = stack.shift(); 13002 stack.push(...innerBlocks); 13003 result.push(block); 13004 } 13005 return result; 13006 }; 13007 var flattenBlocks2 = flattenBlocks22; 13008 const blockList = clientIds.map(select3.getBlock); 13009 const flattenedBlocks = flattenBlocks22(blockList); 13010 let message2; 13011 for (const rule of rules) { 13012 message2 = rule.callback(flattenedBlocks); 13013 if (message2) { 13014 dispatch( 13015 displayBlockRemovalPrompt( 13016 clientIds, 13017 selectPrevious, 13018 message2 13019 ) 13020 ); 13021 return; 13022 } 13023 } 13024 } 13025 if (selectPrevious) { 13026 dispatch.selectPreviousBlock(clientIds[0], selectPrevious); 13027 } 13028 registry.batch(() => { 13029 dispatch({ type: "REMOVE_BLOCKS", clientIds }); 13030 dispatch(ensureDefaultBlock()); 13031 }); 13032 }; 13033 var ensureDefaultBlock = () => ({ select: select3, dispatch }) => { 13034 const count = select3.getBlockCount(); 13035 if (count > 0) { 13036 return; 13037 } 13038 const { __unstableHasCustomAppender } = select3.getSettings(); 13039 if (__unstableHasCustomAppender) { 13040 return; 13041 } 13042 dispatch.insertDefaultBlock(); 13043 }; 13044 function displayBlockRemovalPrompt(clientIds, selectPrevious, message2) { 13045 return { 13046 type: "DISPLAY_BLOCK_REMOVAL_PROMPT", 13047 clientIds, 13048 selectPrevious, 13049 message: message2 13050 }; 13051 } 13052 function clearBlockRemovalPrompt() { 13053 return { 13054 type: "CLEAR_BLOCK_REMOVAL_PROMPT" 13055 }; 13056 } 13057 function setBlockRemovalRules(rules = false) { 13058 return { 13059 type: "SET_BLOCK_REMOVAL_RULES", 13060 rules 13061 }; 13062 } 13063 function setOpenedBlockSettingsMenu(clientId) { 13064 return { 13065 type: "SET_OPENED_BLOCK_SETTINGS_MENU", 13066 clientId 13067 }; 13068 } 13069 function setStyleOverride(id, style) { 13070 return { 13071 type: "SET_STYLE_OVERRIDE", 13072 id, 13073 style 13074 }; 13075 } 13076 function deleteStyleOverride(id) { 13077 return { 13078 type: "DELETE_STYLE_OVERRIDE", 13079 id 13080 }; 13081 } 13082 function setLastFocus(lastFocus2 = null) { 13083 return { 13084 type: "LAST_FOCUS", 13085 lastFocus: lastFocus2 13086 }; 13087 } 13088 function startDragging() { 13089 return { 13090 type: "START_DRAGGING" 13091 }; 13092 } 13093 function stopDragging() { 13094 return { 13095 type: "STOP_DRAGGING" 13096 }; 13097 } 13098 function expandBlock(clientId) { 13099 return { 13100 type: "SET_BLOCK_EXPANDED_IN_LIST_VIEW", 13101 clientId 13102 }; 13103 } 13104 function setInsertionPoint(value) { 13105 return { 13106 type: "SET_INSERTION_POINT", 13107 value 13108 }; 13109 } 13110 function editContentOnlySection(clientId) { 13111 return { 13112 type: "EDIT_CONTENT_ONLY_SECTION", 13113 clientId 13114 }; 13115 } 13116 function stopEditingContentOnlySection() { 13117 return { 13118 type: "EDIT_CONTENT_ONLY_SECTION" 13119 }; 13120 } 13121 var setZoomLevel = (zoom = 100) => ({ select: select3, dispatch }) => { 13122 if (zoom !== 100) { 13123 const firstSelectedClientId = select3.getBlockSelectionStart(); 13124 const sectionRootClientId = select3.getSectionRootClientId(); 13125 if (firstSelectedClientId) { 13126 let sectionClientId; 13127 if (sectionRootClientId) { 13128 const sectionClientIds = select3.getBlockOrder(sectionRootClientId); 13129 if (sectionClientIds?.includes(firstSelectedClientId)) { 13130 sectionClientId = firstSelectedClientId; 13131 } else { 13132 sectionClientId = select3.getBlockParents(firstSelectedClientId).find( 13133 (parent) => sectionClientIds.includes(parent) 13134 ); 13135 } 13136 } else { 13137 sectionClientId = select3.getBlockHierarchyRootClientId( 13138 firstSelectedClientId 13139 ); 13140 } 13141 if (sectionClientId) { 13142 dispatch.selectBlock(sectionClientId); 13143 } else { 13144 dispatch.clearSelectedBlock(); 13145 } 13146 (0, import_a11y2.speak)((0, import_i18n3.__)("You are currently in zoom-out mode.")); 13147 } 13148 } 13149 dispatch({ 13150 type: "SET_ZOOM_LEVEL", 13151 zoom 13152 }); 13153 }; 13154 function resetZoomLevel() { 13155 return { 13156 type: "RESET_ZOOM_LEVEL" 13157 }; 13158 } 13159 function toggleBlockSpotlight(clientId, hasBlockSpotlight3) { 13160 return { 13161 type: "TOGGLE_BLOCK_SPOTLIGHT", 13162 clientId, 13163 hasBlockSpotlight: hasBlockSpotlight3 13164 }; 13165 } 13166 13167 // packages/block-editor/build-module/store/actions.js 13168 var actions_exports = {}; 13169 __export(actions_exports, { 13170 __unstableDeleteSelection: () => __unstableDeleteSelection, 13171 __unstableExpandSelection: () => __unstableExpandSelection, 13172 __unstableMarkAutomaticChange: () => __unstableMarkAutomaticChange, 13173 __unstableMarkLastChangeAsPersistent: () => __unstableMarkLastChangeAsPersistent, 13174 __unstableMarkNextChangeAsNotPersistent: () => __unstableMarkNextChangeAsNotPersistent, 13175 __unstableSaveReusableBlock: () => __unstableSaveReusableBlock, 13176 __unstableSetEditorMode: () => __unstableSetEditorMode, 13177 __unstableSetTemporarilyEditingAsBlocks: () => __unstableSetTemporarilyEditingAsBlocks, 13178 __unstableSplitSelection: () => __unstableSplitSelection, 13179 clearSelectedBlock: () => clearSelectedBlock, 13180 duplicateBlocks: () => duplicateBlocks, 13181 enterFormattedText: () => enterFormattedText, 13182 exitFormattedText: () => exitFormattedText, 13183 flashBlock: () => flashBlock, 13184 hideInsertionPoint: () => hideInsertionPoint, 13185 hoverBlock: () => hoverBlock, 13186 insertAfterBlock: () => insertAfterBlock, 13187 insertBeforeBlock: () => insertBeforeBlock, 13188 insertBlock: () => insertBlock, 13189 insertBlocks: () => insertBlocks, 13190 insertDefaultBlock: () => insertDefaultBlock, 13191 mergeBlocks: () => mergeBlocks, 13192 moveBlockToPosition: () => moveBlockToPosition, 13193 moveBlocksDown: () => moveBlocksDown, 13194 moveBlocksToPosition: () => moveBlocksToPosition, 13195 moveBlocksUp: () => moveBlocksUp, 13196 multiSelect: () => multiSelect, 13197 receiveBlocks: () => receiveBlocks, 13198 registerInserterMediaCategory: () => registerInserterMediaCategory, 13199 removeBlock: () => removeBlock, 13200 removeBlocks: () => removeBlocks, 13201 replaceBlock: () => replaceBlock, 13202 replaceBlocks: () => replaceBlocks, 13203 replaceInnerBlocks: () => replaceInnerBlocks, 13204 resetBlocks: () => resetBlocks, 13205 resetSelection: () => resetSelection, 13206 selectBlock: () => selectBlock, 13207 selectNextBlock: () => selectNextBlock, 13208 selectPreviousBlock: () => selectPreviousBlock, 13209 selectionChange: () => selectionChange, 13210 setBlockEditingMode: () => setBlockEditingMode, 13211 setBlockMovingClientId: () => setBlockMovingClientId, 13212 setBlockVisibility: () => setBlockVisibility, 13213 setHasControlledInnerBlocks: () => setHasControlledInnerBlocks, 13214 setTemplateValidity: () => setTemplateValidity, 13215 showInsertionPoint: () => showInsertionPoint, 13216 startDraggingBlocks: () => startDraggingBlocks, 13217 startMultiSelect: () => startMultiSelect, 13218 startTyping: () => startTyping, 13219 stopDraggingBlocks: () => stopDraggingBlocks, 13220 stopMultiSelect: () => stopMultiSelect, 13221 stopTyping: () => stopTyping, 13222 synchronizeTemplate: () => synchronizeTemplate, 13223 toggleBlockHighlight: () => toggleBlockHighlight, 13224 toggleBlockMode: () => toggleBlockMode, 13225 toggleSelection: () => toggleSelection, 13226 unsetBlockEditingMode: () => unsetBlockEditingMode, 13227 updateBlock: () => updateBlock, 13228 updateBlockAttributes: () => updateBlockAttributes, 13229 updateBlockListSettings: () => updateBlockListSettings, 13230 updateSettings: () => updateSettings, 13231 validateBlocksToTemplate: () => validateBlocksToTemplate 13232 }); 13233 var import_blocks7 = __toESM(require_blocks()); 13234 var import_a11y3 = __toESM(require_a11y()); 13235 var import_i18n4 = __toESM(require_i18n()); 13236 var import_notices = __toESM(require_notices()); 13237 var import_rich_text3 = __toESM(require_rich_text()); 13238 var import_deprecated4 = __toESM(require_deprecated()); 13239 var import_preferences = __toESM(require_preferences()); 13240 13241 // packages/block-editor/build-module/utils/selection.js 13242 var import_rich_text2 = __toESM(require_rich_text()); 13243 var START_OF_SELECTED_AREA = "\x86"; 13244 function retrieveSelectedAttribute(blockAttributes) { 13245 if (!blockAttributes) { 13246 return; 13247 } 13248 return Object.keys(blockAttributes).find((name) => { 13249 const value = blockAttributes[name]; 13250 return (typeof value === "string" || value instanceof import_rich_text2.RichTextData) && // To do: refactor this to use rich text's selection instead, so we 13251 // no longer have to use on this hack inserting a special character. 13252 value.toString().indexOf(START_OF_SELECTED_AREA) !== -1; 13253 }); 13254 } 13255 function findRichTextAttributeKey(blockType) { 13256 for (const [key, value] of Object.entries(blockType.attributes)) { 13257 if (value.source === "rich-text" || value.source === "html") { 13258 return key; 13259 } 13260 } 13261 } 13262 13263 // packages/block-editor/build-module/store/actions.js 13264 var castArray2 = (maybeArray) => Array.isArray(maybeArray) ? maybeArray : [maybeArray]; 13265 var resetBlocks = (blocks2) => ({ dispatch }) => { 13266 dispatch({ type: "RESET_BLOCKS", blocks: blocks2 }); 13267 dispatch(validateBlocksToTemplate(blocks2)); 13268 }; 13269 var validateBlocksToTemplate = (blocks2) => ({ select: select3, dispatch }) => { 13270 const template2 = select3.getTemplate(); 13271 const templateLock = select3.getTemplateLock(); 13272 const isBlocksValidToTemplate = !template2 || templateLock !== "all" || (0, import_blocks7.doBlocksMatchTemplate)(blocks2, template2); 13273 const isValidTemplate2 = select3.isValidTemplate(); 13274 if (isBlocksValidToTemplate !== isValidTemplate2) { 13275 dispatch.setTemplateValidity(isBlocksValidToTemplate); 13276 return isBlocksValidToTemplate; 13277 } 13278 }; 13279 function resetSelection(selectionStart, selectionEnd, initialPosition2) { 13280 return { 13281 type: "RESET_SELECTION", 13282 selectionStart, 13283 selectionEnd, 13284 initialPosition: initialPosition2 13285 }; 13286 } 13287 function receiveBlocks(blocks2) { 13288 (0, import_deprecated4.default)('wp.data.dispatch( "core/block-editor" ).receiveBlocks', { 13289 since: "5.9", 13290 alternative: "resetBlocks or insertBlocks" 13291 }); 13292 return { 13293 type: "RECEIVE_BLOCKS", 13294 blocks: blocks2 13295 }; 13296 } 13297 function updateBlockAttributes(clientIds, attributes, options = { uniqueByBlock: false }) { 13298 if (typeof options === "boolean") { 13299 options = { uniqueByBlock: options }; 13300 } 13301 return { 13302 type: "UPDATE_BLOCK_ATTRIBUTES", 13303 clientIds: castArray2(clientIds), 13304 attributes, 13305 options 13306 }; 13307 } 13308 function updateBlock(clientId, updates) { 13309 return { 13310 type: "UPDATE_BLOCK", 13311 clientId, 13312 updates 13313 }; 13314 } 13315 function selectBlock(clientId, initialPosition2 = 0) { 13316 return { 13317 type: "SELECT_BLOCK", 13318 initialPosition: initialPosition2, 13319 clientId 13320 }; 13321 } 13322 function hoverBlock() { 13323 (0, import_deprecated4.default)('wp.data.dispatch( "core/block-editor" ).hoverBlock', { 13324 since: "6.9", 13325 version: "7.1" 13326 }); 13327 return { 13328 type: "DO_NOTHING" 13329 }; 13330 } 13331 var selectPreviousBlock = (clientId, fallbackToParent = false) => ({ select: select3, dispatch }) => { 13332 const previousBlockClientId = select3.getPreviousBlockClientId(clientId); 13333 if (previousBlockClientId) { 13334 dispatch.selectBlock(previousBlockClientId, -1); 13335 } else if (fallbackToParent) { 13336 const firstParentClientId = select3.getBlockRootClientId(clientId); 13337 if (firstParentClientId) { 13338 dispatch.selectBlock(firstParentClientId, -1); 13339 } 13340 } 13341 }; 13342 var selectNextBlock = (clientId) => ({ select: select3, dispatch }) => { 13343 const nextBlockClientId = select3.getNextBlockClientId(clientId); 13344 if (nextBlockClientId) { 13345 dispatch.selectBlock(nextBlockClientId); 13346 } 13347 }; 13348 function startMultiSelect() { 13349 return { 13350 type: "START_MULTI_SELECT" 13351 }; 13352 } 13353 function stopMultiSelect() { 13354 return { 13355 type: "STOP_MULTI_SELECT" 13356 }; 13357 } 13358 var multiSelect = (start2, end, __experimentalInitialPosition = 0) => ({ select: select3, dispatch }) => { 13359 const startBlockRootClientId = select3.getBlockRootClientId(start2); 13360 const endBlockRootClientId = select3.getBlockRootClientId(end); 13361 if (startBlockRootClientId !== endBlockRootClientId) { 13362 return; 13363 } 13364 dispatch({ 13365 type: "MULTI_SELECT", 13366 start: start2, 13367 end, 13368 initialPosition: __experimentalInitialPosition 13369 }); 13370 const blockCount = select3.getSelectedBlockCount(); 13371 (0, import_a11y3.speak)( 13372 (0, import_i18n4.sprintf)( 13373 /* translators: %s: number of selected blocks */ 13374 (0, import_i18n4._n)("%s block selected.", "%s blocks selected.", blockCount), 13375 blockCount 13376 ), 13377 "assertive" 13378 ); 13379 }; 13380 function clearSelectedBlock() { 13381 return { 13382 type: "CLEAR_SELECTED_BLOCK" 13383 }; 13384 } 13385 function toggleSelection(isSelectionEnabled3 = true) { 13386 return { 13387 type: "TOGGLE_SELECTION", 13388 isSelectionEnabled: isSelectionEnabled3 13389 }; 13390 } 13391 var replaceBlocks = (clientIds, blocks2, indexToSelect, initialPosition2 = 0, meta) => ({ select: select3, dispatch, registry }) => { 13392 clientIds = castArray2(clientIds); 13393 blocks2 = castArray2(blocks2); 13394 const rootClientId = select3.getBlockRootClientId(clientIds[0]); 13395 for (let index = 0; index < blocks2.length; index++) { 13396 const block = blocks2[index]; 13397 const canInsertBlock = select3.canInsertBlockType( 13398 block.name, 13399 rootClientId 13400 ); 13401 if (!canInsertBlock) { 13402 return; 13403 } 13404 } 13405 registry.batch(() => { 13406 dispatch({ 13407 type: "REPLACE_BLOCKS", 13408 clientIds, 13409 blocks: blocks2, 13410 time: Date.now(), 13411 indexToSelect, 13412 initialPosition: initialPosition2, 13413 meta 13414 }); 13415 dispatch.ensureDefaultBlock(); 13416 }); 13417 }; 13418 function replaceBlock(clientId, block) { 13419 return replaceBlocks(clientId, block); 13420 } 13421 var createOnMove = (type) => (clientIds, rootClientId) => ({ select: select3, dispatch }) => { 13422 const canMoveBlocks2 = select3.canMoveBlocks(clientIds); 13423 if (!canMoveBlocks2) { 13424 return; 13425 } 13426 dispatch({ type, clientIds: castArray2(clientIds), rootClientId }); 13427 }; 13428 var moveBlocksDown = createOnMove("MOVE_BLOCKS_DOWN"); 13429 var moveBlocksUp = createOnMove("MOVE_BLOCKS_UP"); 13430 var moveBlocksToPosition = (clientIds, fromRootClientId = "", toRootClientId = "", index) => ({ select: select3, dispatch }) => { 13431 const canMoveBlocks2 = select3.canMoveBlocks(clientIds); 13432 if (!canMoveBlocks2) { 13433 return; 13434 } 13435 if (fromRootClientId !== toRootClientId) { 13436 const canRemoveBlocks2 = select3.canRemoveBlocks(clientIds); 13437 if (!canRemoveBlocks2) { 13438 return; 13439 } 13440 const canInsertBlocks2 = select3.canInsertBlocks( 13441 clientIds, 13442 toRootClientId 13443 ); 13444 if (!canInsertBlocks2) { 13445 return; 13446 } 13447 } 13448 dispatch({ 13449 type: "MOVE_BLOCKS_TO_POSITION", 13450 fromRootClientId, 13451 toRootClientId, 13452 clientIds, 13453 index 13454 }); 13455 }; 13456 function moveBlockToPosition(clientId, fromRootClientId = "", toRootClientId = "", index) { 13457 return moveBlocksToPosition( 13458 [clientId], 13459 fromRootClientId, 13460 toRootClientId, 13461 index 13462 ); 13463 } 13464 function insertBlock(block, index, rootClientId, updateSelection, meta) { 13465 return insertBlocks( 13466 [block], 13467 index, 13468 rootClientId, 13469 updateSelection, 13470 0, 13471 meta 13472 ); 13473 } 13474 var insertBlocks = (blocks2, index, rootClientId, updateSelection = true, initialPosition2 = 0, meta) => ({ select: select3, dispatch }) => { 13475 if (initialPosition2 !== null && typeof initialPosition2 === "object") { 13476 meta = initialPosition2; 13477 initialPosition2 = 0; 13478 (0, import_deprecated4.default)( 13479 "meta argument in wp.data.dispatch('core/block-editor')", 13480 { 13481 since: "5.8", 13482 hint: "The meta argument is now the 6th argument of the function" 13483 } 13484 ); 13485 } 13486 blocks2 = castArray2(blocks2); 13487 const allowedBlocks = []; 13488 for (const block of blocks2) { 13489 const isValid2 = select3.canInsertBlockType( 13490 block.name, 13491 rootClientId 13492 ); 13493 if (isValid2) { 13494 allowedBlocks.push(block); 13495 } 13496 } 13497 if (allowedBlocks.length) { 13498 dispatch({ 13499 type: "INSERT_BLOCKS", 13500 blocks: allowedBlocks, 13501 index, 13502 rootClientId, 13503 time: Date.now(), 13504 updateSelection, 13505 initialPosition: updateSelection ? initialPosition2 : null, 13506 meta 13507 }); 13508 } 13509 }; 13510 function showInsertionPoint(rootClientId, index, __unstableOptions = {}) { 13511 const { __unstableWithInserter, operation, nearestSide } = __unstableOptions; 13512 return { 13513 type: "SHOW_INSERTION_POINT", 13514 rootClientId, 13515 index, 13516 __unstableWithInserter, 13517 operation, 13518 nearestSide 13519 }; 13520 } 13521 var hideInsertionPoint = () => ({ select: select3, dispatch }) => { 13522 if (!select3.isBlockInsertionPointVisible()) { 13523 return; 13524 } 13525 dispatch({ 13526 type: "HIDE_INSERTION_POINT" 13527 }); 13528 }; 13529 function setTemplateValidity(isValid2) { 13530 return { 13531 type: "SET_TEMPLATE_VALIDITY", 13532 isValid: isValid2 13533 }; 13534 } 13535 var synchronizeTemplate = () => ({ select: select3, dispatch }) => { 13536 dispatch({ type: "SYNCHRONIZE_TEMPLATE" }); 13537 const blocks2 = select3.getBlocks(); 13538 const template2 = select3.getTemplate(); 13539 const updatedBlockList = (0, import_blocks7.synchronizeBlocksWithTemplate)( 13540 blocks2, 13541 template2 13542 ); 13543 dispatch.resetBlocks(updatedBlockList); 13544 }; 13545 var __unstableDeleteSelection = (isForward) => ({ registry, select: select3, dispatch }) => { 13546 const selectionAnchor = select3.getSelectionStart(); 13547 const selectionFocus = select3.getSelectionEnd(); 13548 if (selectionAnchor.clientId === selectionFocus.clientId) { 13549 return; 13550 } 13551 if (!selectionAnchor.attributeKey || !selectionFocus.attributeKey || typeof selectionAnchor.offset === "undefined" || typeof selectionFocus.offset === "undefined") { 13552 return false; 13553 } 13554 const anchorRootClientId = select3.getBlockRootClientId( 13555 selectionAnchor.clientId 13556 ); 13557 const focusRootClientId = select3.getBlockRootClientId( 13558 selectionFocus.clientId 13559 ); 13560 if (anchorRootClientId !== focusRootClientId) { 13561 return; 13562 } 13563 const blockOrder = select3.getBlockOrder(anchorRootClientId); 13564 const anchorIndex = blockOrder.indexOf(selectionAnchor.clientId); 13565 const focusIndex = blockOrder.indexOf(selectionFocus.clientId); 13566 let selectionStart, selectionEnd; 13567 if (anchorIndex > focusIndex) { 13568 selectionStart = selectionFocus; 13569 selectionEnd = selectionAnchor; 13570 } else { 13571 selectionStart = selectionAnchor; 13572 selectionEnd = selectionFocus; 13573 } 13574 const targetSelection = isForward ? selectionEnd : selectionStart; 13575 const targetBlock = select3.getBlock(targetSelection.clientId); 13576 const targetBlockType = (0, import_blocks7.getBlockType)(targetBlock.name); 13577 if (!targetBlockType.merge) { 13578 return; 13579 } 13580 const selectionA = selectionStart; 13581 const selectionB = selectionEnd; 13582 const blockA = select3.getBlock(selectionA.clientId); 13583 const blockB = select3.getBlock(selectionB.clientId); 13584 const htmlA = blockA.attributes[selectionA.attributeKey]; 13585 const htmlB = blockB.attributes[selectionB.attributeKey]; 13586 let valueA = (0, import_rich_text3.create)({ html: htmlA }); 13587 let valueB = (0, import_rich_text3.create)({ html: htmlB }); 13588 valueA = (0, import_rich_text3.remove)(valueA, selectionA.offset, valueA.text.length); 13589 valueB = (0, import_rich_text3.insert)(valueB, START_OF_SELECTED_AREA, 0, selectionB.offset); 13590 const cloneA = (0, import_blocks7.cloneBlock)(blockA, { 13591 [selectionA.attributeKey]: (0, import_rich_text3.toHTMLString)({ value: valueA }) 13592 }); 13593 const cloneB = (0, import_blocks7.cloneBlock)(blockB, { 13594 [selectionB.attributeKey]: (0, import_rich_text3.toHTMLString)({ value: valueB }) 13595 }); 13596 const followingBlock = isForward ? cloneA : cloneB; 13597 const blocksWithTheSameType = blockA.name === blockB.name ? [followingBlock] : (0, import_blocks7.switchToBlockType)(followingBlock, targetBlockType.name); 13598 if (!blocksWithTheSameType || !blocksWithTheSameType.length) { 13599 return; 13600 } 13601 let updatedAttributes; 13602 if (isForward) { 13603 const blockToMerge = blocksWithTheSameType.pop(); 13604 updatedAttributes = targetBlockType.merge( 13605 blockToMerge.attributes, 13606 cloneB.attributes 13607 ); 13608 } else { 13609 const blockToMerge = blocksWithTheSameType.shift(); 13610 updatedAttributes = targetBlockType.merge( 13611 cloneA.attributes, 13612 blockToMerge.attributes 13613 ); 13614 } 13615 const newAttributeKey = retrieveSelectedAttribute(updatedAttributes); 13616 const convertedHtml = updatedAttributes[newAttributeKey]; 13617 const convertedValue = (0, import_rich_text3.create)({ html: convertedHtml }); 13618 const newOffset = convertedValue.text.indexOf(START_OF_SELECTED_AREA); 13619 const newValue = (0, import_rich_text3.remove)(convertedValue, newOffset, newOffset + 1); 13620 const newHtml = (0, import_rich_text3.toHTMLString)({ value: newValue }); 13621 updatedAttributes[newAttributeKey] = newHtml; 13622 const selectedBlockClientIds = select3.getSelectedBlockClientIds(); 13623 const replacement = [ 13624 ...isForward ? blocksWithTheSameType : [], 13625 { 13626 // Preserve the original client ID. 13627 ...targetBlock, 13628 attributes: { 13629 ...targetBlock.attributes, 13630 ...updatedAttributes 13631 } 13632 }, 13633 ...isForward ? [] : blocksWithTheSameType 13634 ]; 13635 registry.batch(() => { 13636 dispatch.selectionChange( 13637 targetBlock.clientId, 13638 newAttributeKey, 13639 newOffset, 13640 newOffset 13641 ); 13642 dispatch.replaceBlocks( 13643 selectedBlockClientIds, 13644 replacement, 13645 0, 13646 // If we don't pass the `indexToSelect` it will default to the last block. 13647 select3.getSelectedBlocksInitialCaretPosition() 13648 ); 13649 }); 13650 }; 13651 var __unstableSplitSelection = (blocks2 = []) => ({ registry, select: select3, dispatch }) => { 13652 const selectionAnchor = select3.getSelectionStart(); 13653 const selectionFocus = select3.getSelectionEnd(); 13654 const anchorRootClientId = select3.getBlockRootClientId( 13655 selectionAnchor.clientId 13656 ); 13657 const focusRootClientId = select3.getBlockRootClientId( 13658 selectionFocus.clientId 13659 ); 13660 if (anchorRootClientId !== focusRootClientId) { 13661 return; 13662 } 13663 const blockOrder = select3.getBlockOrder(anchorRootClientId); 13664 const anchorIndex = blockOrder.indexOf(selectionAnchor.clientId); 13665 const focusIndex = blockOrder.indexOf(selectionFocus.clientId); 13666 let selectionStart, selectionEnd; 13667 if (anchorIndex > focusIndex) { 13668 selectionStart = selectionFocus; 13669 selectionEnd = selectionAnchor; 13670 } else { 13671 selectionStart = selectionAnchor; 13672 selectionEnd = selectionFocus; 13673 } 13674 const selectionA = selectionStart; 13675 const selectionB = selectionEnd; 13676 const blockA = select3.getBlock(selectionA.clientId); 13677 const blockB = select3.getBlock(selectionB.clientId); 13678 const blockAType = (0, import_blocks7.getBlockType)(blockA.name); 13679 const blockBType = (0, import_blocks7.getBlockType)(blockB.name); 13680 const attributeKeyA = typeof selectionA.attributeKey === "string" ? selectionA.attributeKey : findRichTextAttributeKey(blockAType); 13681 const attributeKeyB = typeof selectionB.attributeKey === "string" ? selectionB.attributeKey : findRichTextAttributeKey(blockBType); 13682 const blockAttributes = select3.getBlockAttributes( 13683 selectionA.clientId 13684 ); 13685 const bindings = blockAttributes?.metadata?.bindings; 13686 if (bindings?.[attributeKeyA]) { 13687 if (blocks2.length) { 13688 const { createWarningNotice } = registry.dispatch(import_notices.store); 13689 createWarningNotice( 13690 (0, import_i18n4.__)( 13691 "Blocks can't be inserted into other blocks with bindings" 13692 ), 13693 { 13694 type: "snackbar" 13695 } 13696 ); 13697 return; 13698 } 13699 dispatch.insertAfterBlock(selectionA.clientId); 13700 return; 13701 } 13702 if (!attributeKeyA || !attributeKeyB || typeof selectionAnchor.offset === "undefined" || typeof selectionFocus.offset === "undefined") { 13703 return; 13704 } 13705 if (selectionA.clientId === selectionB.clientId && attributeKeyA === attributeKeyB && selectionA.offset === selectionB.offset) { 13706 if (blocks2.length) { 13707 if ((0, import_blocks7.isUnmodifiedDefaultBlock)(blockA, "content")) { 13708 dispatch.replaceBlocks( 13709 [selectionA.clientId], 13710 blocks2, 13711 blocks2.length - 1, 13712 -1 13713 ); 13714 return; 13715 } 13716 } else if (!select3.getBlockOrder(selectionA.clientId).length) { 13717 let createEmpty2 = function() { 13718 const defaultBlockName2 = (0, import_blocks7.getDefaultBlockName)(); 13719 return select3.canInsertBlockType( 13720 defaultBlockName2, 13721 anchorRootClientId 13722 ) ? (0, import_blocks7.createBlock)(defaultBlockName2) : (0, import_blocks7.createBlock)( 13723 select3.getBlockName(selectionA.clientId) 13724 ); 13725 }; 13726 var createEmpty = createEmpty2; 13727 const length = blockAttributes[attributeKeyA].length; 13728 if (selectionA.offset === 0 && length) { 13729 dispatch.insertBlocks( 13730 [createEmpty2()], 13731 select3.getBlockIndex(selectionA.clientId), 13732 anchorRootClientId, 13733 false 13734 ); 13735 return; 13736 } 13737 if (selectionA.offset === length) { 13738 dispatch.insertBlocks( 13739 [createEmpty2()], 13740 select3.getBlockIndex(selectionA.clientId) + 1, 13741 anchorRootClientId 13742 ); 13743 return; 13744 } 13745 } 13746 } 13747 const htmlA = blockA.attributes[attributeKeyA]; 13748 const htmlB = blockB.attributes[attributeKeyB]; 13749 let valueA = (0, import_rich_text3.create)({ html: htmlA }); 13750 let valueB = (0, import_rich_text3.create)({ html: htmlB }); 13751 valueA = (0, import_rich_text3.remove)(valueA, selectionA.offset, valueA.text.length); 13752 valueB = (0, import_rich_text3.remove)(valueB, 0, selectionB.offset); 13753 let head = { 13754 // Preserve the original client ID. 13755 ...blockA, 13756 // If both start and end are the same, should only copy innerBlocks 13757 // once. 13758 innerBlocks: blockA.clientId === blockB.clientId ? [] : blockA.innerBlocks, 13759 attributes: { 13760 ...blockA.attributes, 13761 [attributeKeyA]: (0, import_rich_text3.toHTMLString)({ value: valueA }) 13762 } 13763 }; 13764 let tail = { 13765 ...blockB, 13766 // Only preserve the original client ID if the end is different. 13767 clientId: blockA.clientId === blockB.clientId ? (0, import_blocks7.createBlock)(blockB.name).clientId : blockB.clientId, 13768 attributes: { 13769 ...blockB.attributes, 13770 [attributeKeyB]: (0, import_rich_text3.toHTMLString)({ value: valueB }) 13771 } 13772 }; 13773 const defaultBlockName = (0, import_blocks7.getDefaultBlockName)(); 13774 if ( 13775 // A block is only split when the selection is within the same 13776 // block. 13777 blockA.clientId === blockB.clientId && defaultBlockName && tail.name !== defaultBlockName && select3.canInsertBlockType(defaultBlockName, anchorRootClientId) 13778 ) { 13779 const switched = (0, import_blocks7.switchToBlockType)(tail, defaultBlockName); 13780 if (switched?.length === 1) { 13781 tail = switched[0]; 13782 } 13783 } 13784 if (!blocks2.length) { 13785 dispatch.replaceBlocks(select3.getSelectedBlockClientIds(), [ 13786 head, 13787 tail 13788 ]); 13789 return; 13790 } 13791 let selection2; 13792 const output = []; 13793 const clonedBlocks = [...blocks2]; 13794 const firstBlock = clonedBlocks.shift(); 13795 const headType = (0, import_blocks7.getBlockType)(head.name); 13796 const firstBlocks = headType.merge && firstBlock.name === headType.name ? [firstBlock] : (0, import_blocks7.switchToBlockType)(firstBlock, headType.name); 13797 if (firstBlocks?.length) { 13798 const first = firstBlocks.shift(); 13799 head = { 13800 ...head, 13801 attributes: { 13802 ...head.attributes, 13803 ...headType.merge(head.attributes, first.attributes) 13804 } 13805 }; 13806 output.push(head); 13807 selection2 = { 13808 clientId: head.clientId, 13809 attributeKey: attributeKeyA, 13810 offset: (0, import_rich_text3.create)({ html: head.attributes[attributeKeyA] }).text.length 13811 }; 13812 clonedBlocks.unshift(...firstBlocks); 13813 } else { 13814 if (!(0, import_blocks7.isUnmodifiedBlock)(head)) { 13815 output.push(head); 13816 } 13817 output.push(firstBlock); 13818 } 13819 const lastBlock = clonedBlocks.pop(); 13820 const tailType = (0, import_blocks7.getBlockType)(tail.name); 13821 if (clonedBlocks.length) { 13822 output.push(...clonedBlocks); 13823 } 13824 if (lastBlock) { 13825 const lastBlocks = tailType.merge && tailType.name === lastBlock.name ? [lastBlock] : (0, import_blocks7.switchToBlockType)(lastBlock, tailType.name); 13826 if (lastBlocks?.length) { 13827 const last = lastBlocks.pop(); 13828 output.push({ 13829 ...tail, 13830 attributes: { 13831 ...tail.attributes, 13832 ...tailType.merge(last.attributes, tail.attributes) 13833 } 13834 }); 13835 output.push(...lastBlocks); 13836 selection2 = { 13837 clientId: tail.clientId, 13838 attributeKey: attributeKeyB, 13839 offset: (0, import_rich_text3.create)({ 13840 html: last.attributes[attributeKeyB] 13841 }).text.length 13842 }; 13843 } else { 13844 output.push(lastBlock); 13845 if (!(0, import_blocks7.isUnmodifiedBlock)(tail)) { 13846 output.push(tail); 13847 } 13848 } 13849 } else if (!(0, import_blocks7.isUnmodifiedBlock)(tail)) { 13850 output.push(tail); 13851 } 13852 registry.batch(() => { 13853 dispatch.replaceBlocks( 13854 select3.getSelectedBlockClientIds(), 13855 output, 13856 output.length - 1, 13857 0 13858 ); 13859 if (selection2) { 13860 dispatch.selectionChange( 13861 selection2.clientId, 13862 selection2.attributeKey, 13863 selection2.offset, 13864 selection2.offset 13865 ); 13866 } 13867 }); 13868 }; 13869 var __unstableExpandSelection = () => ({ select: select3, dispatch }) => { 13870 const selectionAnchor = select3.getSelectionStart(); 13871 const selectionFocus = select3.getSelectionEnd(); 13872 dispatch.selectionChange({ 13873 start: { clientId: selectionAnchor.clientId }, 13874 end: { clientId: selectionFocus.clientId } 13875 }); 13876 }; 13877 var mergeBlocks = (firstBlockClientId, secondBlockClientId) => ({ registry, select: select3, dispatch }) => { 13878 const clientIdA = firstBlockClientId; 13879 const clientIdB = secondBlockClientId; 13880 const blockA = select3.getBlock(clientIdA); 13881 const blockAType = (0, import_blocks7.getBlockType)(blockA.name); 13882 if (!blockAType || select3.getBlockEditingMode(clientIdA) === "disabled" || select3.getBlockEditingMode(clientIdB) === "disabled") { 13883 return; 13884 } 13885 const blockB = select3.getBlock(clientIdB); 13886 if (!blockAType.merge && (0, import_blocks7.getBlockSupport)(blockA.name, "__experimentalOnMerge")) { 13887 const blocksWithTheSameType2 = (0, import_blocks7.switchToBlockType)( 13888 blockB, 13889 blockAType.name 13890 ); 13891 if (blocksWithTheSameType2?.length !== 1) { 13892 dispatch.selectBlock(blockA.clientId); 13893 return; 13894 } 13895 const [blockWithSameType] = blocksWithTheSameType2; 13896 if (blockWithSameType.innerBlocks.length < 1) { 13897 dispatch.selectBlock(blockA.clientId); 13898 return; 13899 } 13900 registry.batch(() => { 13901 dispatch.insertBlocks( 13902 blockWithSameType.innerBlocks, 13903 void 0, 13904 clientIdA 13905 ); 13906 dispatch.removeBlock(clientIdB); 13907 dispatch.selectBlock( 13908 blockWithSameType.innerBlocks[0].clientId 13909 ); 13910 const nextBlockClientId = select3.getNextBlockClientId(clientIdA); 13911 if (nextBlockClientId && select3.getBlockName(clientIdA) === select3.getBlockName(nextBlockClientId)) { 13912 const rootAttributes = select3.getBlockAttributes(clientIdA); 13913 const previousRootAttributes = select3.getBlockAttributes(nextBlockClientId); 13914 if (Object.keys(rootAttributes).every( 13915 (key) => rootAttributes[key] === previousRootAttributes[key] 13916 )) { 13917 dispatch.moveBlocksToPosition( 13918 select3.getBlockOrder(nextBlockClientId), 13919 nextBlockClientId, 13920 clientIdA 13921 ); 13922 dispatch.removeBlock(nextBlockClientId, false); 13923 } 13924 } 13925 }); 13926 return; 13927 } 13928 if ((0, import_blocks7.isUnmodifiedDefaultBlock)(blockA)) { 13929 dispatch.removeBlock( 13930 clientIdA, 13931 select3.isBlockSelected(clientIdA) 13932 ); 13933 return; 13934 } 13935 if ((0, import_blocks7.isUnmodifiedDefaultBlock)(blockB)) { 13936 dispatch.removeBlock( 13937 clientIdB, 13938 select3.isBlockSelected(clientIdB) 13939 ); 13940 return; 13941 } 13942 if (!blockAType.merge) { 13943 if ((0, import_blocks7.isUnmodifiedBlock)(blockB, "content")) { 13944 dispatch.removeBlock( 13945 clientIdB, 13946 select3.isBlockSelected(clientIdB) 13947 ); 13948 } else { 13949 dispatch.selectBlock(blockA.clientId); 13950 } 13951 return; 13952 } 13953 const blockBType = (0, import_blocks7.getBlockType)(blockB.name); 13954 const { clientId, attributeKey, offset } = select3.getSelectionStart(); 13955 const selectedBlockType = clientId === clientIdA ? blockAType : blockBType; 13956 const attributeDefinition = selectedBlockType.attributes[attributeKey]; 13957 const canRestoreTextSelection = (clientId === clientIdA || clientId === clientIdB) && attributeKey !== void 0 && offset !== void 0 && // We cannot restore text selection if the RichText identifier 13958 // is not a defined block attribute key. This can be the case if the 13959 // fallback instance ID is used to store selection (and no RichText 13960 // identifier is set), or when the identifier is wrong. 13961 !!attributeDefinition; 13962 if (!attributeDefinition) { 13963 if (typeof attributeKey === "number") { 13964 window.console.error( 13965 `RichText needs an identifier prop that is the block attribute key of the attribute it controls. Its type is expected to be a string, but was $typeof attributeKey}` 13966 ); 13967 } else { 13968 window.console.error( 13969 "The RichText identifier prop does not match any attributes defined by the block." 13970 ); 13971 } 13972 } 13973 const cloneA = (0, import_blocks7.cloneBlock)(blockA); 13974 const cloneB = (0, import_blocks7.cloneBlock)(blockB); 13975 if (canRestoreTextSelection) { 13976 const selectedBlock = clientId === clientIdA ? cloneA : cloneB; 13977 const html = selectedBlock.attributes[attributeKey]; 13978 const value = (0, import_rich_text3.insert)( 13979 (0, import_rich_text3.create)({ html }), 13980 START_OF_SELECTED_AREA, 13981 offset, 13982 offset 13983 ); 13984 selectedBlock.attributes[attributeKey] = (0, import_rich_text3.toHTMLString)({ 13985 value 13986 }); 13987 } 13988 const blocksWithTheSameType = blockA.name === blockB.name ? [cloneB] : (0, import_blocks7.switchToBlockType)(cloneB, blockA.name); 13989 if (!blocksWithTheSameType || !blocksWithTheSameType.length) { 13990 return; 13991 } 13992 const updatedAttributes = blockAType.merge( 13993 cloneA.attributes, 13994 blocksWithTheSameType[0].attributes 13995 ); 13996 if (canRestoreTextSelection) { 13997 const newAttributeKey = retrieveSelectedAttribute(updatedAttributes); 13998 const convertedHtml = updatedAttributes[newAttributeKey]; 13999 const convertedValue = (0, import_rich_text3.create)({ html: convertedHtml }); 14000 const newOffset = convertedValue.text.indexOf( 14001 START_OF_SELECTED_AREA 14002 ); 14003 const newValue = (0, import_rich_text3.remove)(convertedValue, newOffset, newOffset + 1); 14004 const newHtml = (0, import_rich_text3.toHTMLString)({ value: newValue }); 14005 updatedAttributes[newAttributeKey] = newHtml; 14006 dispatch.selectionChange( 14007 blockA.clientId, 14008 newAttributeKey, 14009 newOffset, 14010 newOffset 14011 ); 14012 } 14013 dispatch.replaceBlocks( 14014 [blockA.clientId, blockB.clientId], 14015 [ 14016 { 14017 ...blockA, 14018 attributes: { 14019 ...blockA.attributes, 14020 ...updatedAttributes 14021 } 14022 }, 14023 ...blocksWithTheSameType.slice(1) 14024 ], 14025 0 14026 // If we don't pass the `indexToSelect` it will default to the last block. 14027 ); 14028 }; 14029 var removeBlocks = (clientIds, selectPrevious = true) => privateRemoveBlocks(clientIds, selectPrevious); 14030 function removeBlock(clientId, selectPrevious) { 14031 return removeBlocks([clientId], selectPrevious); 14032 } 14033 function replaceInnerBlocks(rootClientId, blocks2, updateSelection = false, initialPosition2 = 0) { 14034 return { 14035 type: "REPLACE_INNER_BLOCKS", 14036 rootClientId, 14037 blocks: blocks2, 14038 updateSelection, 14039 initialPosition: updateSelection ? initialPosition2 : null, 14040 time: Date.now() 14041 }; 14042 } 14043 function toggleBlockMode(clientId) { 14044 return { 14045 type: "TOGGLE_BLOCK_MODE", 14046 clientId 14047 }; 14048 } 14049 function startTyping() { 14050 return { 14051 type: "START_TYPING" 14052 }; 14053 } 14054 function stopTyping() { 14055 return { 14056 type: "STOP_TYPING" 14057 }; 14058 } 14059 function startDraggingBlocks(clientIds = []) { 14060 return { 14061 type: "START_DRAGGING_BLOCKS", 14062 clientIds 14063 }; 14064 } 14065 function stopDraggingBlocks() { 14066 return { 14067 type: "STOP_DRAGGING_BLOCKS" 14068 }; 14069 } 14070 function enterFormattedText() { 14071 (0, import_deprecated4.default)('wp.data.dispatch( "core/block-editor" ).enterFormattedText', { 14072 since: "6.1", 14073 version: "6.3" 14074 }); 14075 return { 14076 type: "DO_NOTHING" 14077 }; 14078 } 14079 function exitFormattedText() { 14080 (0, import_deprecated4.default)('wp.data.dispatch( "core/block-editor" ).exitFormattedText', { 14081 since: "6.1", 14082 version: "6.3" 14083 }); 14084 return { 14085 type: "DO_NOTHING" 14086 }; 14087 } 14088 function selectionChange(clientId, attributeKey, startOffset, endOffset) { 14089 if (typeof clientId === "string") { 14090 return { 14091 type: "SELECTION_CHANGE", 14092 clientId, 14093 attributeKey, 14094 startOffset, 14095 endOffset 14096 }; 14097 } 14098 return { type: "SELECTION_CHANGE", ...clientId }; 14099 } 14100 var insertDefaultBlock = (attributes, rootClientId, index) => ({ dispatch }) => { 14101 const defaultBlockName = (0, import_blocks7.getDefaultBlockName)(); 14102 if (!defaultBlockName) { 14103 return; 14104 } 14105 const block = (0, import_blocks7.createBlock)(defaultBlockName, attributes); 14106 return dispatch.insertBlock(block, index, rootClientId); 14107 }; 14108 function updateBlockListSettings(clientId, settings2) { 14109 return { 14110 type: "UPDATE_BLOCK_LIST_SETTINGS", 14111 clientId, 14112 settings: settings2 14113 }; 14114 } 14115 function updateSettings(settings2) { 14116 return __experimentalUpdateSettings(settings2, { 14117 stripExperimentalSettings: true 14118 }); 14119 } 14120 function __unstableSaveReusableBlock(id, updatedId) { 14121 return { 14122 type: "SAVE_REUSABLE_BLOCK_SUCCESS", 14123 id, 14124 updatedId 14125 }; 14126 } 14127 function __unstableMarkLastChangeAsPersistent() { 14128 return { type: "MARK_LAST_CHANGE_AS_PERSISTENT" }; 14129 } 14130 function __unstableMarkNextChangeAsNotPersistent() { 14131 return { type: "MARK_NEXT_CHANGE_AS_NOT_PERSISTENT" }; 14132 } 14133 var __unstableMarkAutomaticChange = () => ({ dispatch }) => { 14134 dispatch({ type: "MARK_AUTOMATIC_CHANGE" }); 14135 const { requestIdleCallback = (cb) => setTimeout(cb, 100) } = window; 14136 requestIdleCallback(() => { 14137 dispatch({ type: "MARK_AUTOMATIC_CHANGE_FINAL" }); 14138 }); 14139 }; 14140 var __unstableSetEditorMode = (mode2) => ({ registry }) => { 14141 registry.dispatch(import_preferences.store).set("core", "editorTool", mode2); 14142 if (mode2 === "navigation") { 14143 (0, import_a11y3.speak)((0, import_i18n4.__)("You are currently in Write mode.")); 14144 } else if (mode2 === "edit") { 14145 (0, import_a11y3.speak)((0, import_i18n4.__)("You are currently in Design mode.")); 14146 } 14147 }; 14148 function setBlockMovingClientId() { 14149 (0, import_deprecated4.default)( 14150 'wp.data.dispatch( "core/block-editor" ).setBlockMovingClientId', 14151 { 14152 since: "6.7", 14153 hint: "Block moving mode feature has been removed" 14154 } 14155 ); 14156 return { 14157 type: "DO_NOTHING" 14158 }; 14159 } 14160 var duplicateBlocks = (clientIds, updateSelection = true) => ({ select: select3, dispatch }) => { 14161 if (!clientIds || !clientIds.length) { 14162 return; 14163 } 14164 const blocks2 = select3.getBlocksByClientId(clientIds); 14165 if (blocks2.some((block) => !block)) { 14166 return; 14167 } 14168 const blockNames = blocks2.map((block) => block.name); 14169 if (blockNames.some( 14170 (blockName) => !(0, import_blocks7.hasBlockSupport)(blockName, "multiple", true) 14171 )) { 14172 return; 14173 } 14174 const rootClientId = select3.getBlockRootClientId(clientIds[0]); 14175 const clientIdsArray = castArray2(clientIds); 14176 const lastSelectedIndex = select3.getBlockIndex( 14177 clientIdsArray[clientIdsArray.length - 1] 14178 ); 14179 const clonedBlocks = blocks2.map( 14180 (block) => (0, import_blocks7.__experimentalCloneSanitizedBlock)(block) 14181 ); 14182 dispatch.insertBlocks( 14183 clonedBlocks, 14184 lastSelectedIndex + 1, 14185 rootClientId, 14186 updateSelection 14187 ); 14188 if (clonedBlocks.length > 1 && updateSelection) { 14189 dispatch.multiSelect( 14190 clonedBlocks[0].clientId, 14191 clonedBlocks[clonedBlocks.length - 1].clientId 14192 ); 14193 } 14194 return clonedBlocks.map((block) => block.clientId); 14195 }; 14196 var insertBeforeBlock = (clientId) => ({ select: select3, dispatch }) => { 14197 if (!clientId) { 14198 return; 14199 } 14200 const rootClientId = select3.getBlockRootClientId(clientId); 14201 const isLocked = select3.getTemplateLock(rootClientId); 14202 if (isLocked) { 14203 return; 14204 } 14205 const blockIndex = select3.getBlockIndex(clientId); 14206 const directInsertBlock = rootClientId ? select3.getDirectInsertBlock(rootClientId) : null; 14207 if (!directInsertBlock) { 14208 return dispatch.insertDefaultBlock({}, rootClientId, blockIndex); 14209 } 14210 const copiedAttributes = {}; 14211 if (directInsertBlock.attributesToCopy) { 14212 const attributes = select3.getBlockAttributes(clientId); 14213 directInsertBlock.attributesToCopy.forEach((key) => { 14214 if (attributes[key]) { 14215 copiedAttributes[key] = attributes[key]; 14216 } 14217 }); 14218 } 14219 const block = (0, import_blocks7.createBlock)(directInsertBlock.name, { 14220 ...directInsertBlock.attributes, 14221 ...copiedAttributes 14222 }); 14223 return dispatch.insertBlock(block, blockIndex, rootClientId); 14224 }; 14225 var insertAfterBlock = (clientId) => ({ select: select3, dispatch }) => { 14226 if (!clientId) { 14227 return; 14228 } 14229 const rootClientId = select3.getBlockRootClientId(clientId); 14230 const isLocked = select3.getTemplateLock(rootClientId); 14231 if (isLocked) { 14232 return; 14233 } 14234 const blockIndex = select3.getBlockIndex(clientId); 14235 const directInsertBlock = rootClientId ? select3.getDirectInsertBlock(rootClientId) : null; 14236 if (!directInsertBlock) { 14237 return dispatch.insertDefaultBlock( 14238 {}, 14239 rootClientId, 14240 blockIndex + 1 14241 ); 14242 } 14243 const copiedAttributes = {}; 14244 if (directInsertBlock.attributesToCopy) { 14245 const attributes = select3.getBlockAttributes(clientId); 14246 directInsertBlock.attributesToCopy.forEach((key) => { 14247 if (attributes[key]) { 14248 copiedAttributes[key] = attributes[key]; 14249 } 14250 }); 14251 } 14252 const block = (0, import_blocks7.createBlock)(directInsertBlock.name, { 14253 ...directInsertBlock.attributes, 14254 ...copiedAttributes 14255 }); 14256 return dispatch.insertBlock(block, blockIndex + 1, rootClientId); 14257 }; 14258 function toggleBlockHighlight(clientId, isHighlighted) { 14259 return { 14260 type: "TOGGLE_BLOCK_HIGHLIGHT", 14261 clientId, 14262 isHighlighted 14263 }; 14264 } 14265 var flashBlock = (clientId, timeout = 150) => async ({ dispatch }) => { 14266 dispatch(toggleBlockHighlight(clientId, true)); 14267 await new Promise((resolve) => setTimeout(resolve, timeout)); 14268 dispatch(toggleBlockHighlight(clientId, false)); 14269 }; 14270 function setHasControlledInnerBlocks(clientId, hasControlledInnerBlocks) { 14271 return { 14272 type: "SET_HAS_CONTROLLED_INNER_BLOCKS", 14273 hasControlledInnerBlocks, 14274 clientId 14275 }; 14276 } 14277 function setBlockVisibility(updates) { 14278 return { 14279 type: "SET_BLOCK_VISIBILITY", 14280 updates 14281 }; 14282 } 14283 function __unstableSetTemporarilyEditingAsBlocks(clientId) { 14284 (0, import_deprecated4.default)( 14285 "wp.data.dispatch( 'core/block-editor' ).__unstableSetTemporarilyEditingAsBlocks", 14286 { 14287 since: "7.0" 14288 } 14289 ); 14290 return editContentOnlySection(clientId); 14291 } 14292 var registerInserterMediaCategory = (category) => ({ select: select3, dispatch }) => { 14293 if (!category || typeof category !== "object") { 14294 console.error( 14295 "Category should be an `InserterMediaCategory` object." 14296 ); 14297 return; 14298 } 14299 if (!category.name) { 14300 console.error( 14301 "Category should have a `name` that should be unique among all media categories." 14302 ); 14303 return; 14304 } 14305 if (!category.labels?.name) { 14306 console.error("Category should have a `labels.name`."); 14307 return; 14308 } 14309 if (!["image", "audio", "video"].includes(category.mediaType)) { 14310 console.error( 14311 "Category should have `mediaType` property that is one of `image|audio|video`." 14312 ); 14313 return; 14314 } 14315 if (!category.fetch || typeof category.fetch !== "function") { 14316 console.error( 14317 "Category should have a `fetch` function defined with the following signature `(InserterMediaRequest) => Promise<InserterMediaItem[]>`." 14318 ); 14319 return; 14320 } 14321 const registeredInserterMediaCategories2 = select3.getRegisteredInserterMediaCategories(); 14322 if (registeredInserterMediaCategories2.some( 14323 ({ name }) => name === category.name 14324 )) { 14325 console.error( 14326 `A category is already registered with the same name: "$category.name}".` 14327 ); 14328 return; 14329 } 14330 if (registeredInserterMediaCategories2.some( 14331 ({ labels: { name } = {} }) => name === category.labels?.name 14332 )) { 14333 console.error( 14334 `A category is already registered with the same labels.name: "$category.labels.name}".` 14335 ); 14336 return; 14337 } 14338 dispatch({ 14339 type: "REGISTER_INSERTER_MEDIA_CATEGORY", 14340 category: { ...category, isExternalResource: true } 14341 }); 14342 }; 14343 function setBlockEditingMode(clientId = "", mode2) { 14344 return { 14345 type: "SET_BLOCK_EDITING_MODE", 14346 clientId, 14347 mode: mode2 14348 }; 14349 } 14350 function unsetBlockEditingMode(clientId = "") { 14351 return { 14352 type: "UNSET_BLOCK_EDITING_MODE", 14353 clientId 14354 }; 14355 } 14356 14357 // packages/block-editor/build-module/store/index.js 14358 var storeConfig = { 14359 reducer: reducer_default, 14360 selectors: selectors_exports, 14361 actions: actions_exports 14362 }; 14363 var store = (0, import_data5.createReduxStore)(STORE_NAME, { 14364 ...storeConfig, 14365 persist: ["preferences"] 14366 }); 14367 var registeredStore = (0, import_data5.registerStore)(STORE_NAME, { 14368 ...storeConfig, 14369 persist: ["preferences"] 14370 }); 14371 unlock(registeredStore).registerPrivateActions(private_actions_exports); 14372 unlock(registeredStore).registerPrivateSelectors(private_selectors_exports); 14373 unlock(store).registerPrivateActions(private_actions_exports); 14374 unlock(store).registerPrivateSelectors(private_selectors_exports); 14375 14376 // packages/block-editor/build-module/components/warning/index.js 14377 var import_components3 = __toESM(require_components()); 14378 var import_i18n5 = __toESM(require_i18n()); 14379 var import_jsx_runtime116 = __toESM(require_jsx_runtime()); 14380 function Warning({ className, actions, children, secondaryActions }) { 14381 return /* @__PURE__ */ (0, import_jsx_runtime116.jsx)("div", { style: { display: "contents", all: "initial" }, children: /* @__PURE__ */ (0, import_jsx_runtime116.jsx)("div", { className: clsx_default(className, "block-editor-warning"), children: /* @__PURE__ */ (0, import_jsx_runtime116.jsxs)("div", { className: "block-editor-warning__contents", children: [ 14382 /* @__PURE__ */ (0, import_jsx_runtime116.jsx)("p", { className: "block-editor-warning__message", children }), 14383 (actions?.length > 0 || secondaryActions) && /* @__PURE__ */ (0, import_jsx_runtime116.jsxs)("div", { className: "block-editor-warning__actions", children: [ 14384 actions?.length > 0 && actions.map((action, i2) => /* @__PURE__ */ (0, import_jsx_runtime116.jsx)( 14385 "span", 14386 { 14387 className: "block-editor-warning__action", 14388 children: action 14389 }, 14390 i2 14391 )), 14392 secondaryActions && /* @__PURE__ */ (0, import_jsx_runtime116.jsx)( 14393 import_components3.DropdownMenu, 14394 { 14395 className: "block-editor-warning__secondary", 14396 icon: more_vertical_default, 14397 label: (0, import_i18n5.__)("More options"), 14398 popoverProps: { 14399 placement: "bottom-end", 14400 className: "block-editor-warning__dropdown" 14401 }, 14402 noIcons: true, 14403 children: () => /* @__PURE__ */ (0, import_jsx_runtime116.jsx)(import_components3.MenuGroup, { children: secondaryActions.map( 14404 (item, pos) => /* @__PURE__ */ (0, import_jsx_runtime116.jsx)( 14405 import_components3.MenuItem, 14406 { 14407 onClick: item.onClick, 14408 children: item.title 14409 }, 14410 pos 14411 ) 14412 ) }) 14413 } 14414 ) 14415 ] }) 14416 ] }) }) }); 14417 } 14418 var warning_default = Warning; 14419 14420 // packages/block-editor/build-module/components/block-edit/multiple-usage-warning.js 14421 var import_jsx_runtime117 = __toESM(require_jsx_runtime()); 14422 function MultipleUsageWarning({ 14423 originalBlockClientId, 14424 name, 14425 onReplace 14426 }) { 14427 const { selectBlock: selectBlock2 } = (0, import_data6.useDispatch)(store); 14428 const blockType = (0, import_blocks8.getBlockType)(name); 14429 return /* @__PURE__ */ (0, import_jsx_runtime117.jsxs)( 14430 warning_default, 14431 { 14432 actions: [ 14433 /* @__PURE__ */ (0, import_jsx_runtime117.jsx)( 14434 import_components4.Button, 14435 { 14436 __next40pxDefaultSize: true, 14437 variant: "secondary", 14438 onClick: () => selectBlock2(originalBlockClientId), 14439 children: (0, import_i18n6.__)("Find original") 14440 }, 14441 "find-original" 14442 ), 14443 /* @__PURE__ */ (0, import_jsx_runtime117.jsx)( 14444 import_components4.Button, 14445 { 14446 __next40pxDefaultSize: true, 14447 variant: "secondary", 14448 onClick: () => onReplace([]), 14449 children: (0, import_i18n6.__)("Remove") 14450 }, 14451 "remove" 14452 ) 14453 ], 14454 children: [ 14455 /* @__PURE__ */ (0, import_jsx_runtime117.jsxs)("strong", { children: [ 14456 blockType?.title, 14457 ": " 14458 ] }), 14459 (0, import_i18n6.__)("This block can only be used once.") 14460 ] 14461 } 14462 ); 14463 } 14464 14465 // packages/block-editor/build-module/components/block-edit/index.js 14466 var import_jsx_runtime118 = __toESM(require_jsx_runtime()); 14467 function BlockEdit({ 14468 mayDisplayControls, 14469 mayDisplayParentControls, 14470 blockEditingMode, 14471 isPreviewMode, 14472 // The remaining props are passed through the BlockEdit filters and are thus 14473 // public API! 14474 ...props 14475 }) { 14476 const { 14477 name, 14478 isSelected, 14479 clientId, 14480 attributes = {}, 14481 __unstableLayoutClassNames 14482 } = props; 14483 const { layout = null, metadata = {} } = attributes; 14484 const { bindings } = metadata; 14485 const layoutSupport = (0, import_blocks9.hasBlockSupport)(name, "layout", false) || (0, import_blocks9.hasBlockSupport)(name, "__experimentalLayout", false); 14486 const { originalBlockClientId } = (0, import_element8.useContext)(PrivateBlockContext); 14487 return /* @__PURE__ */ (0, import_jsx_runtime118.jsxs)( 14488 Provider, 14489 { 14490 value: (0, import_element8.useMemo)( 14491 () => ({ 14492 name, 14493 isSelected, 14494 clientId, 14495 layout: layoutSupport ? layout : null, 14496 __unstableLayoutClassNames, 14497 // We use symbols in favour of an __unstable prefix to avoid 14498 // usage outside of the package (this context is exposed). 14499 [mayDisplayControlsKey]: mayDisplayControls, 14500 [mayDisplayParentControlsKey]: mayDisplayParentControls, 14501 [blockEditingModeKey]: blockEditingMode, 14502 [blockBindingsKey]: bindings, 14503 [isPreviewModeKey]: isPreviewMode 14504 }), 14505 [ 14506 name, 14507 isSelected, 14508 clientId, 14509 layoutSupport, 14510 layout, 14511 __unstableLayoutClassNames, 14512 mayDisplayControls, 14513 mayDisplayParentControls, 14514 blockEditingMode, 14515 bindings, 14516 isPreviewMode 14517 ] 14518 ), 14519 children: [ 14520 /* @__PURE__ */ (0, import_jsx_runtime118.jsx)(edit_default, { ...props }), 14521 originalBlockClientId && /* @__PURE__ */ (0, import_jsx_runtime118.jsx)( 14522 MultipleUsageWarning, 14523 { 14524 originalBlockClientId, 14525 name, 14526 onReplace: props.onReplace 14527 } 14528 ) 14529 ] 14530 } 14531 ); 14532 } 14533 14534 // packages/block-editor/build-module/components/use-settings/index.js 14535 function useSettings(...paths) { 14536 const { clientId = null } = useBlockEditContext(); 14537 return (0, import_data7.useSelect)( 14538 (select3) => unlock(select3(store)).getBlockSettings( 14539 clientId, 14540 ...paths 14541 ), 14542 [clientId, ...paths] 14543 ); 14544 } 14545 function useSetting(path) { 14546 (0, import_deprecated5.default)("wp.blockEditor.useSetting", { 14547 since: "6.5", 14548 alternative: "wp.blockEditor.useSettings", 14549 note: "The new useSettings function can retrieve multiple settings at once, with better performance." 14550 }); 14551 const [value] = useSettings(path); 14552 return value; 14553 } 14554 14555 // packages/block-editor/build-module/components/colors/with-colors.js 14556 var import_jsx_runtime119 = __toESM(require_jsx_runtime()); 14557 var { kebabCase: kebabCase2 } = unlock(import_components5.privateApis); 14558 var upperFirst = ([firstLetter, ...rest]) => firstLetter.toUpperCase() + rest.join(""); 14559 var withCustomColorPalette = (colorsArray) => (0, import_compose2.createHigherOrderComponent)( 14560 (WrappedComponent) => (props) => /* @__PURE__ */ (0, import_jsx_runtime119.jsx)(WrappedComponent, { ...props, colors: colorsArray }), 14561 "withCustomColorPalette" 14562 ); 14563 var withEditorColorPalette = () => (0, import_compose2.createHigherOrderComponent)( 14564 (WrappedComponent) => (props) => { 14565 const [userPalette, themePalette, defaultPalette] = useSettings( 14566 "color.palette.custom", 14567 "color.palette.theme", 14568 "color.palette.default" 14569 ); 14570 const allColors = (0, import_element9.useMemo)( 14571 () => [ 14572 ...userPalette || [], 14573 ...themePalette || [], 14574 ...defaultPalette || [] 14575 ], 14576 [userPalette, themePalette, defaultPalette] 14577 ); 14578 return /* @__PURE__ */ (0, import_jsx_runtime119.jsx)(WrappedComponent, { ...props, colors: allColors }); 14579 }, 14580 "withEditorColorPalette" 14581 ); 14582 function createColorHOC(colorTypes, withColorPalette) { 14583 const colorMap = colorTypes.reduce((colorObject, colorType) => { 14584 return { 14585 ...colorObject, 14586 ...typeof colorType === "string" ? { [colorType]: kebabCase2(colorType) } : colorType 14587 }; 14588 }, {}); 14589 return (0, import_compose2.compose)([ 14590 withColorPalette, 14591 (WrappedComponent) => { 14592 return class extends import_element9.Component { 14593 constructor(props) { 14594 super(props); 14595 this.setters = this.createSetters(); 14596 this.colorUtils = { 14597 getMostReadableColor: this.getMostReadableColor.bind(this) 14598 }; 14599 this.state = {}; 14600 } 14601 getMostReadableColor(colorValue) { 14602 const { colors: colors2 } = this.props; 14603 return getMostReadableColor(colors2, colorValue); 14604 } 14605 createSetters() { 14606 return Object.keys(colorMap).reduce( 14607 (settersAccumulator, colorAttributeName) => { 14608 const upperFirstColorAttributeName = upperFirst(colorAttributeName); 14609 const customColorAttributeName = `custom$upperFirstColorAttributeName}`; 14610 settersAccumulator[`set$upperFirstColorAttributeName}`] = this.createSetColor( 14611 colorAttributeName, 14612 customColorAttributeName 14613 ); 14614 return settersAccumulator; 14615 }, 14616 {} 14617 ); 14618 } 14619 createSetColor(colorAttributeName, customColorAttributeName) { 14620 return (colorValue) => { 14621 const colorObject = getColorObjectByColorValue( 14622 this.props.colors, 14623 colorValue 14624 ); 14625 this.props.setAttributes({ 14626 [colorAttributeName]: colorObject && colorObject.slug ? colorObject.slug : void 0, 14627 [customColorAttributeName]: colorObject && colorObject.slug ? void 0 : colorValue 14628 }); 14629 }; 14630 } 14631 static getDerivedStateFromProps({ attributes, colors: colors2 }, previousState) { 14632 return Object.entries(colorMap).reduce( 14633 (newState, [colorAttributeName, colorContext]) => { 14634 const colorObject = getColorObjectByAttributeValues( 14635 colors2, 14636 attributes[colorAttributeName], 14637 attributes[`custom$upperFirst( 14638 colorAttributeName 14639 )}`] 14640 ); 14641 const previousColorObject = previousState[colorAttributeName]; 14642 const previousColor = previousColorObject?.color; 14643 if (previousColor === colorObject.color && previousColorObject) { 14644 newState[colorAttributeName] = previousColorObject; 14645 } else { 14646 newState[colorAttributeName] = { 14647 ...colorObject, 14648 class: getColorClassName( 14649 colorContext, 14650 colorObject.slug 14651 ) 14652 }; 14653 } 14654 return newState; 14655 }, 14656 {} 14657 ); 14658 } 14659 render() { 14660 return /* @__PURE__ */ (0, import_jsx_runtime119.jsx)( 14661 WrappedComponent, 14662 { 14663 ...{ 14664 ...this.props, 14665 colors: void 0, 14666 ...this.state, 14667 ...this.setters, 14668 colorUtils: this.colorUtils 14669 } 14670 } 14671 ); 14672 } 14673 }; 14674 } 14675 ]); 14676 } 14677 function createCustomColorsHOC(colorsArray) { 14678 return (...colorTypes) => { 14679 const withColorPalette = withCustomColorPalette(colorsArray); 14680 return (0, import_compose2.createHigherOrderComponent)( 14681 createColorHOC(colorTypes, withColorPalette), 14682 "withCustomColors" 14683 ); 14684 }; 14685 } 14686 function withColors(...colorTypes) { 14687 const withColorPalette = withEditorColorPalette(); 14688 return (0, import_compose2.createHigherOrderComponent)( 14689 createColorHOC(colorTypes, withColorPalette), 14690 "withColors" 14691 ); 14692 } 14693 14694 // packages/block-editor/build-module/components/gradients/use-gradient.js 14695 var import_element10 = __toESM(require_element()); 14696 var import_data8 = __toESM(require_data()); 14697 function __experimentalGetGradientClass(gradientSlug) { 14698 if (!gradientSlug) { 14699 return void 0; 14700 } 14701 return `has-$gradientSlug}-gradient-background`; 14702 } 14703 function getGradientValueBySlug(gradients, slug) { 14704 const gradient = gradients?.find((g2) => g2.slug === slug); 14705 return gradient && gradient.gradient; 14706 } 14707 function __experimentalGetGradientObjectByGradientValue(gradients, value) { 14708 const gradient = gradients?.find((g2) => g2.gradient === value); 14709 return gradient; 14710 } 14711 function getGradientSlugByValue(gradients, value) { 14712 const gradient = __experimentalGetGradientObjectByGradientValue( 14713 gradients, 14714 value 14715 ); 14716 return gradient && gradient.slug; 14717 } 14718 function __experimentalUseGradient({ 14719 gradientAttribute = "gradient", 14720 customGradientAttribute = "customGradient" 14721 } = {}) { 14722 const { clientId } = useBlockEditContext(); 14723 const [ 14724 userGradientPalette, 14725 themeGradientPalette, 14726 defaultGradientPalette 14727 ] = useSettings( 14728 "color.gradients.custom", 14729 "color.gradients.theme", 14730 "color.gradients.default" 14731 ); 14732 const allGradients = (0, import_element10.useMemo)( 14733 () => [ 14734 ...userGradientPalette || [], 14735 ...themeGradientPalette || [], 14736 ...defaultGradientPalette || [] 14737 ], 14738 [userGradientPalette, themeGradientPalette, defaultGradientPalette] 14739 ); 14740 const { gradient, customGradient } = (0, import_data8.useSelect)( 14741 (select3) => { 14742 const { getBlockAttributes: getBlockAttributes3 } = select3(store); 14743 const attributes = getBlockAttributes3(clientId) || {}; 14744 return { 14745 customGradient: attributes[customGradientAttribute], 14746 gradient: attributes[gradientAttribute] 14747 }; 14748 }, 14749 [clientId, gradientAttribute, customGradientAttribute] 14750 ); 14751 const { updateBlockAttributes: updateBlockAttributes2 } = (0, import_data8.useDispatch)(store); 14752 const setGradient = (0, import_element10.useCallback)( 14753 (newGradientValue) => { 14754 const slug = getGradientSlugByValue( 14755 allGradients, 14756 newGradientValue 14757 ); 14758 if (slug) { 14759 updateBlockAttributes2(clientId, { 14760 [gradientAttribute]: slug, 14761 [customGradientAttribute]: void 0 14762 }); 14763 return; 14764 } 14765 updateBlockAttributes2(clientId, { 14766 [gradientAttribute]: void 0, 14767 [customGradientAttribute]: newGradientValue 14768 }); 14769 }, 14770 [allGradients, clientId, updateBlockAttributes2] 14771 ); 14772 const gradientClass = __experimentalGetGradientClass(gradient); 14773 let gradientValue; 14774 if (gradient) { 14775 gradientValue = getGradientValueBySlug(allGradients, gradient); 14776 } else { 14777 gradientValue = customGradient; 14778 } 14779 return { gradientClass, gradientValue, setGradient }; 14780 } 14781 14782 // packages/block-editor/build-module/components/font-sizes/utils.js 14783 var import_components6 = __toESM(require_components()); 14784 var { kebabCase: kebabCase3 } = unlock(import_components6.privateApis); 14785 var getFontSize = (fontSizes, fontSizeAttribute, customFontSizeAttribute) => { 14786 if (fontSizeAttribute) { 14787 const fontSizeObject = fontSizes?.find( 14788 ({ slug }) => slug === fontSizeAttribute 14789 ); 14790 if (fontSizeObject) { 14791 return fontSizeObject; 14792 } 14793 } 14794 return { 14795 size: customFontSizeAttribute 14796 }; 14797 }; 14798 function getFontSizeObjectByValue(fontSizes, value) { 14799 const fontSizeObject = fontSizes?.find(({ size }) => size === value); 14800 if (fontSizeObject) { 14801 return fontSizeObject; 14802 } 14803 return { 14804 size: value 14805 }; 14806 } 14807 function getFontSizeClass(fontSizeSlug) { 14808 if (!fontSizeSlug) { 14809 return; 14810 } 14811 return `has-$kebabCase3(fontSizeSlug)}-font-size`; 14812 } 14813 14814 // packages/block-editor/build-module/components/font-sizes/fluid-utils.js 14815 var DEFAULT_MAXIMUM_VIEWPORT_WIDTH = "1600px"; 14816 var DEFAULT_MINIMUM_VIEWPORT_WIDTH = "320px"; 14817 var DEFAULT_SCALE_FACTOR = 1; 14818 var DEFAULT_MINIMUM_FONT_SIZE_FACTOR_MIN = 0.25; 14819 var DEFAULT_MINIMUM_FONT_SIZE_FACTOR_MAX = 0.75; 14820 var DEFAULT_MINIMUM_FONT_SIZE_LIMIT = "14px"; 14821 function getComputedFluidTypographyValue({ 14822 minimumFontSize, 14823 maximumFontSize, 14824 fontSize, 14825 minimumViewportWidth = DEFAULT_MINIMUM_VIEWPORT_WIDTH, 14826 maximumViewportWidth = DEFAULT_MAXIMUM_VIEWPORT_WIDTH, 14827 scaleFactor = DEFAULT_SCALE_FACTOR, 14828 minimumFontSizeLimit 14829 }) { 14830 minimumFontSizeLimit = !!getTypographyValueAndUnit(minimumFontSizeLimit) ? minimumFontSizeLimit : DEFAULT_MINIMUM_FONT_SIZE_LIMIT; 14831 if (fontSize) { 14832 const fontSizeParsed = getTypographyValueAndUnit(fontSize); 14833 if (!fontSizeParsed?.unit) { 14834 return null; 14835 } 14836 const minimumFontSizeLimitParsed = getTypographyValueAndUnit( 14837 minimumFontSizeLimit, 14838 { 14839 coerceTo: fontSizeParsed.unit 14840 } 14841 ); 14842 if (!!minimumFontSizeLimitParsed?.value && !minimumFontSize && !maximumFontSize) { 14843 if (fontSizeParsed?.value <= minimumFontSizeLimitParsed?.value) { 14844 return null; 14845 } 14846 } 14847 if (!maximumFontSize) { 14848 maximumFontSize = `$fontSizeParsed.value}$fontSizeParsed.unit}`; 14849 } 14850 if (!minimumFontSize) { 14851 const fontSizeValueInPx = fontSizeParsed.unit === "px" ? fontSizeParsed.value : fontSizeParsed.value * 16; 14852 const minimumFontSizeFactor = Math.min( 14853 Math.max( 14854 1 - 0.075 * Math.log2(fontSizeValueInPx), 14855 DEFAULT_MINIMUM_FONT_SIZE_FACTOR_MIN 14856 ), 14857 DEFAULT_MINIMUM_FONT_SIZE_FACTOR_MAX 14858 ); 14859 const calculatedMinimumFontSize = roundToPrecision( 14860 fontSizeParsed.value * minimumFontSizeFactor, 14861 3 14862 ); 14863 if (!!minimumFontSizeLimitParsed?.value && calculatedMinimumFontSize < minimumFontSizeLimitParsed?.value) { 14864 minimumFontSize = `$minimumFontSizeLimitParsed.value}$minimumFontSizeLimitParsed.unit}`; 14865 } else { 14866 minimumFontSize = `$calculatedMinimumFontSize}$fontSizeParsed.unit}`; 14867 } 14868 } 14869 } 14870 const minimumFontSizeParsed = getTypographyValueAndUnit(minimumFontSize); 14871 const fontSizeUnit = minimumFontSizeParsed?.unit || "rem"; 14872 const maximumFontSizeParsed = getTypographyValueAndUnit(maximumFontSize, { 14873 coerceTo: fontSizeUnit 14874 }); 14875 if (!minimumFontSizeParsed || !maximumFontSizeParsed) { 14876 return null; 14877 } 14878 const minimumFontSizeRem = getTypographyValueAndUnit(minimumFontSize, { 14879 coerceTo: "rem" 14880 }); 14881 const maximumViewportWidthParsed = getTypographyValueAndUnit( 14882 maximumViewportWidth, 14883 { coerceTo: fontSizeUnit } 14884 ); 14885 const minimumViewportWidthParsed = getTypographyValueAndUnit( 14886 minimumViewportWidth, 14887 { coerceTo: fontSizeUnit } 14888 ); 14889 if (!maximumViewportWidthParsed || !minimumViewportWidthParsed || !minimumFontSizeRem) { 14890 return null; 14891 } 14892 const linearDenominator = maximumViewportWidthParsed.value - minimumViewportWidthParsed.value; 14893 if (!linearDenominator) { 14894 return null; 14895 } 14896 const minViewportWidthOffsetValue = roundToPrecision( 14897 minimumViewportWidthParsed.value / 100, 14898 3 14899 ); 14900 const viewportWidthOffset = roundToPrecision(minViewportWidthOffsetValue, 3) + fontSizeUnit; 14901 const linearFactor = 100 * ((maximumFontSizeParsed.value - minimumFontSizeParsed.value) / linearDenominator); 14902 const linearFactorScaled = roundToPrecision( 14903 (linearFactor || 1) * scaleFactor, 14904 3 14905 ); 14906 const fluidTargetFontSize = `$minimumFontSizeRem.value}$minimumFontSizeRem.unit} + ((1vw - $viewportWidthOffset}) * $linearFactorScaled})`; 14907 return `clamp($minimumFontSize}, $fluidTargetFontSize}, $maximumFontSize})`; 14908 } 14909 function getTypographyValueAndUnit(rawValue, options = {}) { 14910 if (typeof rawValue !== "string" && typeof rawValue !== "number") { 14911 return null; 14912 } 14913 if (isFinite(rawValue)) { 14914 rawValue = `$rawValue}px`; 14915 } 14916 const { coerceTo, rootSizeValue, acceptableUnits } = { 14917 coerceTo: "", 14918 // Default browser font size. Later we could inject some JS to compute this `getComputedStyle( document.querySelector( "html" ) ).fontSize`. 14919 rootSizeValue: 16, 14920 acceptableUnits: ["rem", "px", "em"], 14921 ...options 14922 }; 14923 const acceptableUnitsGroup = acceptableUnits?.join("|"); 14924 const regexUnits = new RegExp( 14925 `^(\\d*\\.?\\d+)($acceptableUnitsGroup}){1,1}$` 14926 ); 14927 const matches = rawValue.match(regexUnits); 14928 if (!matches || matches.length < 3) { 14929 return null; 14930 } 14931 let [, value, unit] = matches; 14932 let returnValue = parseFloat(value); 14933 if ("px" === coerceTo && ("em" === unit || "rem" === unit)) { 14934 returnValue = returnValue * rootSizeValue; 14935 unit = coerceTo; 14936 } 14937 if ("px" === unit && ("em" === coerceTo || "rem" === coerceTo)) { 14938 returnValue = returnValue / rootSizeValue; 14939 unit = coerceTo; 14940 } 14941 if (("em" === coerceTo || "rem" === coerceTo) && ("em" === unit || "rem" === unit)) { 14942 unit = coerceTo; 14943 } 14944 return { 14945 value: roundToPrecision(returnValue, 3), 14946 unit 14947 }; 14948 } 14949 function roundToPrecision(value, digits = 3) { 14950 const base = Math.pow(10, digits); 14951 return Number.isFinite(value) ? parseFloat(Math.round(value * base) / base) : void 0; 14952 } 14953 14954 // packages/block-editor/build-module/components/font-sizes/font-size-picker.js 14955 var import_components7 = __toESM(require_components()); 14956 var import_jsx_runtime120 = __toESM(require_jsx_runtime()); 14957 function FontSizePicker(props) { 14958 const [fontSizes, customFontSize] = useSettings( 14959 "typography.fontSizes", 14960 "typography.customFontSize" 14961 ); 14962 return /* @__PURE__ */ (0, import_jsx_runtime120.jsx)( 14963 import_components7.FontSizePicker, 14964 { 14965 ...props, 14966 fontSizes, 14967 disableCustomFontSizes: !customFontSize 14968 } 14969 ); 14970 } 14971 var font_size_picker_default = FontSizePicker; 14972 14973 // packages/block-editor/build-module/components/font-sizes/with-font-sizes.js 14974 var import_compose3 = __toESM(require_compose()); 14975 var import_element11 = __toESM(require_element()); 14976 var import_jsx_runtime121 = __toESM(require_jsx_runtime()); 14977 var DEFAULT_FONT_SIZES = []; 14978 var upperFirst2 = ([firstLetter, ...rest]) => firstLetter.toUpperCase() + rest.join(""); 14979 var with_font_sizes_default = (...fontSizeNames) => { 14980 const fontSizeAttributeNames = fontSizeNames.reduce( 14981 (fontSizeAttributeNamesAccumulator, fontSizeAttributeName) => { 14982 fontSizeAttributeNamesAccumulator[fontSizeAttributeName] = `custom$upperFirst2(fontSizeAttributeName)}`; 14983 return fontSizeAttributeNamesAccumulator; 14984 }, 14985 {} 14986 ); 14987 return (0, import_compose3.createHigherOrderComponent)( 14988 (0, import_compose3.compose)([ 14989 (0, import_compose3.createHigherOrderComponent)( 14990 (WrappedComponent) => (props) => { 14991 const [fontSizes] = useSettings("typography.fontSizes"); 14992 return /* @__PURE__ */ (0, import_jsx_runtime121.jsx)( 14993 WrappedComponent, 14994 { 14995 ...props, 14996 fontSizes: fontSizes || DEFAULT_FONT_SIZES 14997 } 14998 ); 14999 }, 15000 "withFontSizes" 15001 ), 15002 (WrappedComponent) => { 15003 return class extends import_element11.Component { 15004 constructor(props) { 15005 super(props); 15006 this.setters = this.createSetters(); 15007 this.state = {}; 15008 } 15009 createSetters() { 15010 return Object.entries(fontSizeAttributeNames).reduce( 15011 (settersAccumulator, [ 15012 fontSizeAttributeName, 15013 customFontSizeAttributeName 15014 ]) => { 15015 const upperFirstFontSizeAttributeName = upperFirst2(fontSizeAttributeName); 15016 settersAccumulator[`set$upperFirstFontSizeAttributeName}`] = this.createSetFontSize( 15017 fontSizeAttributeName, 15018 customFontSizeAttributeName 15019 ); 15020 return settersAccumulator; 15021 }, 15022 {} 15023 ); 15024 } 15025 createSetFontSize(fontSizeAttributeName, customFontSizeAttributeName) { 15026 return (fontSizeValue) => { 15027 const fontSizeObject = this.props.fontSizes?.find( 15028 ({ size }) => size === Number(fontSizeValue) 15029 ); 15030 this.props.setAttributes({ 15031 [fontSizeAttributeName]: fontSizeObject && fontSizeObject.slug ? fontSizeObject.slug : void 0, 15032 [customFontSizeAttributeName]: fontSizeObject && fontSizeObject.slug ? void 0 : fontSizeValue 15033 }); 15034 }; 15035 } 15036 static getDerivedStateFromProps({ attributes, fontSizes }, previousState) { 15037 const didAttributesChange = (customFontSizeAttributeName, fontSizeAttributeName) => { 15038 if (previousState[fontSizeAttributeName]) { 15039 if (attributes[fontSizeAttributeName]) { 15040 return attributes[fontSizeAttributeName] !== previousState[fontSizeAttributeName].slug; 15041 } 15042 return previousState[fontSizeAttributeName].size !== attributes[customFontSizeAttributeName]; 15043 } 15044 return true; 15045 }; 15046 if (!Object.values(fontSizeAttributeNames).some( 15047 didAttributesChange 15048 )) { 15049 return null; 15050 } 15051 const newState = Object.entries( 15052 fontSizeAttributeNames 15053 ).filter( 15054 ([key, value]) => didAttributesChange(value, key) 15055 ).reduce( 15056 (newStateAccumulator, [ 15057 fontSizeAttributeName, 15058 customFontSizeAttributeName 15059 ]) => { 15060 const fontSizeAttributeValue = attributes[fontSizeAttributeName]; 15061 const fontSizeObject = getFontSize( 15062 fontSizes, 15063 fontSizeAttributeValue, 15064 attributes[customFontSizeAttributeName] 15065 ); 15066 newStateAccumulator[fontSizeAttributeName] = { 15067 ...fontSizeObject, 15068 class: getFontSizeClass( 15069 fontSizeAttributeValue 15070 ) 15071 }; 15072 return newStateAccumulator; 15073 }, 15074 {} 15075 ); 15076 return { 15077 ...previousState, 15078 ...newState 15079 }; 15080 } 15081 render() { 15082 return /* @__PURE__ */ (0, import_jsx_runtime121.jsx)( 15083 WrappedComponent, 15084 { 15085 ...{ 15086 ...this.props, 15087 fontSizes: void 0, 15088 ...this.state, 15089 ...this.setters 15090 } 15091 } 15092 ); 15093 } 15094 }; 15095 } 15096 ]), 15097 "withFontSizes" 15098 ); 15099 }; 15100 15101 // packages/block-editor/build-module/components/alignment-control/ui.js 15102 var import_i18n7 = __toESM(require_i18n()); 15103 var import_components8 = __toESM(require_components()); 15104 var import_jsx_runtime122 = __toESM(require_jsx_runtime()); 15105 var DEFAULT_ALIGNMENT_CONTROLS = [ 15106 { 15107 icon: align_left_default, 15108 title: (0, import_i18n7.__)("Align text left"), 15109 align: "left" 15110 }, 15111 { 15112 icon: align_center_default, 15113 title: (0, import_i18n7.__)("Align text center"), 15114 align: "center" 15115 }, 15116 { 15117 icon: align_right_default, 15118 title: (0, import_i18n7.__)("Align text right"), 15119 align: "right" 15120 } 15121 ]; 15122 var POPOVER_PROPS = { 15123 placement: "bottom-start" 15124 }; 15125 function AlignmentUI({ 15126 value, 15127 onChange, 15128 alignmentControls = DEFAULT_ALIGNMENT_CONTROLS, 15129 label = (0, import_i18n7.__)("Align text"), 15130 description = (0, import_i18n7.__)("Change text alignment"), 15131 isCollapsed: isCollapsed3 = true, 15132 isToolbar 15133 }) { 15134 function applyOrUnset(align) { 15135 return () => onChange(value === align ? void 0 : align); 15136 } 15137 const activeAlignment = alignmentControls.find( 15138 (control) => control.align === value 15139 ); 15140 function setIcon() { 15141 if (activeAlignment) { 15142 return activeAlignment.icon; 15143 } 15144 return (0, import_i18n7.isRTL)() ? align_right_default : align_left_default; 15145 } 15146 const UIComponent = isToolbar ? import_components8.ToolbarGroup : import_components8.ToolbarDropdownMenu; 15147 const extraProps = isToolbar ? { isCollapsed: isCollapsed3 } : { 15148 toggleProps: { 15149 description 15150 }, 15151 popoverProps: POPOVER_PROPS 15152 }; 15153 return /* @__PURE__ */ (0, import_jsx_runtime122.jsx)( 15154 UIComponent, 15155 { 15156 icon: setIcon(), 15157 label, 15158 controls: alignmentControls.map((control) => { 15159 const { align } = control; 15160 const isActive = value === align; 15161 return { 15162 ...control, 15163 isActive, 15164 role: isCollapsed3 ? "menuitemradio" : void 0, 15165 onClick: applyOrUnset(align) 15166 }; 15167 }), 15168 ...extraProps 15169 } 15170 ); 15171 } 15172 var ui_default = AlignmentUI; 15173 15174 // packages/block-editor/build-module/components/alignment-control/index.js 15175 var import_jsx_runtime123 = __toESM(require_jsx_runtime()); 15176 var AlignmentControl = (props) => { 15177 return /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(ui_default, { ...props, isToolbar: false }); 15178 }; 15179 var AlignmentToolbar = (props) => { 15180 return /* @__PURE__ */ (0, import_jsx_runtime123.jsx)(ui_default, { ...props, isToolbar: true }); 15181 }; 15182 15183 // packages/block-editor/build-module/components/autocomplete/index.js 15184 var import_hooks3 = __toESM(require_hooks()); 15185 var import_components10 = __toESM(require_components()); 15186 var import_element15 = __toESM(require_element()); 15187 var import_blocks12 = __toESM(require_blocks()); 15188 15189 // packages/block-editor/build-module/autocompleters/block.js 15190 var import_data10 = __toESM(require_data()); 15191 var import_blocks11 = __toESM(require_blocks()); 15192 var import_element14 = __toESM(require_element()); 15193 15194 // packages/block-editor/build-module/components/inserter/search-items.js 15195 var import_remove_accents = __toESM(require_remove_accents()); 15196 15197 // node_modules/tslib/tslib.es6.mjs 15198 var extendStatics = function(d2, b2) { 15199 extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d3, b3) { 15200 d3.__proto__ = b3; 15201 } || function(d3, b3) { 15202 for (var p2 in b3) if (Object.prototype.hasOwnProperty.call(b3, p2)) d3[p2] = b3[p2]; 15203 }; 15204 return extendStatics(d2, b2); 15205 }; 15206 function __extends(d2, b2) { 15207 if (typeof b2 !== "function" && b2 !== null) 15208 throw new TypeError("Class extends value " + String(b2) + " is not a constructor or null"); 15209 extendStatics(d2, b2); 15210 function __214() { 15211 this.constructor = d2; 15212 } 15213 d2.prototype = b2 === null ? Object.create(b2) : (__214.prototype = b2.prototype, new __214()); 15214 } 15215 var __assign = function() { 15216 __assign = Object.assign || function __assign2(t3) { 15217 for (var s2, i2 = 1, n2 = arguments.length; i2 < n2; i2++) { 15218 s2 = arguments[i2]; 15219 for (var p2 in s2) if (Object.prototype.hasOwnProperty.call(s2, p2)) t3[p2] = s2[p2]; 15220 } 15221 return t3; 15222 }; 15223 return __assign.apply(this, arguments); 15224 }; 15225 15226 // node_modules/lower-case/dist.es2015/index.js 15227 function lowerCase(str) { 15228 return str.toLowerCase(); 15229 } 15230 15231 // node_modules/no-case/dist.es2015/index.js 15232 var DEFAULT_SPLIT_REGEXP = [/([a-z0-9])([A-Z])/g, /([A-Z])([A-Z][a-z])/g]; 15233 var DEFAULT_STRIP_REGEXP = /[^A-Z0-9]+/gi; 15234 function noCase(input, options) { 15235 if (options === void 0) { 15236 options = {}; 15237 } 15238 var _a = options.splitRegexp, splitRegexp2 = _a === void 0 ? DEFAULT_SPLIT_REGEXP : _a, _b = options.stripRegexp, stripRegexp2 = _b === void 0 ? DEFAULT_STRIP_REGEXP : _b, _c = options.transform, transform = _c === void 0 ? lowerCase : _c, _d = options.delimiter, delimiter = _d === void 0 ? " " : _d; 15239 var result = replace(replace(input, splitRegexp2, "$1\0$2"), stripRegexp2, "\0"); 15240 var start2 = 0; 15241 var end = result.length; 15242 while (result.charAt(start2) === "\0") 15243 start2++; 15244 while (result.charAt(end - 1) === "\0") 15245 end--; 15246 return result.slice(start2, end).split("\0").map(transform).join(delimiter); 15247 } 15248 function replace(input, re, value) { 15249 if (re instanceof RegExp) 15250 return input.replace(re, value); 15251 return re.reduce(function(input2, re2) { 15252 return input2.replace(re2, value); 15253 }, input); 15254 } 15255 15256 // packages/block-editor/build-module/components/inserter/search-items.js 15257 var defaultGetName = (item) => item.name || ""; 15258 var defaultGetTitle = (item) => item.title; 15259 var defaultGetDescription = (item) => item.description || ""; 15260 var defaultGetKeywords = (item) => item.keywords || []; 15261 var defaultGetCategory = (item) => item.category; 15262 var defaultGetCollection = () => null; 15263 var splitRegexp = [ 15264 /([\p{Ll}\p{Lo}\p{N}])([\p{Lu}\p{Lt}])/gu, 15265 // One lowercase or digit, followed by one uppercase. 15266 /([\p{Lu}\p{Lt}])([\p{Lu}\p{Lt}][\p{Ll}\p{Lo}])/gu 15267 // One uppercase followed by one uppercase and one lowercase. 15268 ]; 15269 var stripRegexp = new RegExp("(\\p{C}|\\p{P}|\\p{S})+", "giu"); 15270 var extractedWords = /* @__PURE__ */ new Map(); 15271 var normalizedStrings = /* @__PURE__ */ new Map(); 15272 function extractWords(input = "") { 15273 if (extractedWords.has(input)) { 15274 return extractedWords.get(input); 15275 } 15276 const result = noCase(input, { 15277 splitRegexp, 15278 stripRegexp 15279 }).split(" ").filter(Boolean); 15280 extractedWords.set(input, result); 15281 return result; 15282 } 15283 function normalizeString(input = "") { 15284 if (normalizedStrings.has(input)) { 15285 return normalizedStrings.get(input); 15286 } 15287 let result = (0, import_remove_accents.default)(input); 15288 result = result.replace(/^\//, ""); 15289 result = result.toLowerCase(); 15290 normalizedStrings.set(input, result); 15291 return result; 15292 } 15293 var getNormalizedSearchTerms = (input = "") => { 15294 return extractWords(normalizeString(input)); 15295 }; 15296 var removeMatchingTerms = (unmatchedTerms, unprocessedTerms) => { 15297 return unmatchedTerms.filter( 15298 (term) => !getNormalizedSearchTerms(unprocessedTerms).some( 15299 (unprocessedTerm) => unprocessedTerm.includes(term) 15300 ) 15301 ); 15302 }; 15303 var searchBlockItems = (items, categories, collections, searchInput) => { 15304 const normalizedSearchTerms = getNormalizedSearchTerms(searchInput); 15305 if (normalizedSearchTerms.length === 0) { 15306 return items; 15307 } 15308 const config2 = { 15309 getCategory: (item) => categories.find(({ slug }) => slug === item.category)?.title, 15310 getCollection: (item) => collections[item.name.split("/")[0]]?.title 15311 }; 15312 return searchItems(items, searchInput, config2); 15313 }; 15314 var searchItems = (items = [], searchInput = "", config2 = {}) => { 15315 const normalizedSearchTerms = getNormalizedSearchTerms(searchInput); 15316 if (normalizedSearchTerms.length === 0) { 15317 return items; 15318 } 15319 const rankedItems = items.map((item) => { 15320 return [item, getItemSearchRank(item, searchInput, config2)]; 15321 }).filter(([, rank]) => rank > 0); 15322 rankedItems.sort(([, rank1], [, rank2]) => rank2 - rank1); 15323 return rankedItems.map(([item]) => item); 15324 }; 15325 function getItemSearchRank(item, searchTerm, config2 = {}) { 15326 const { 15327 getName = defaultGetName, 15328 getTitle = defaultGetTitle, 15329 getDescription = defaultGetDescription, 15330 getKeywords = defaultGetKeywords, 15331 getCategory = defaultGetCategory, 15332 getCollection = defaultGetCollection 15333 } = config2; 15334 const name = getName(item); 15335 const title = getTitle(item); 15336 const description = getDescription(item); 15337 const keywords = getKeywords(item); 15338 const category = getCategory(item); 15339 const collection = getCollection(item); 15340 const normalizedSearchInput = normalizeString(searchTerm); 15341 const normalizedTitle = normalizeString(title); 15342 let rank = 0; 15343 if (normalizedSearchInput === normalizedTitle) { 15344 rank += 30; 15345 } else if (normalizedTitle.startsWith(normalizedSearchInput)) { 15346 rank += 20; 15347 } else { 15348 const terms = [ 15349 name, 15350 title, 15351 description, 15352 ...keywords, 15353 category, 15354 collection 15355 ].join(" "); 15356 const normalizedSearchTerms = extractWords(normalizedSearchInput); 15357 const unmatchedTerms = removeMatchingTerms( 15358 normalizedSearchTerms, 15359 terms 15360 ); 15361 if (unmatchedTerms.length === 0) { 15362 rank += 10; 15363 } 15364 } 15365 if (rank !== 0 && name.startsWith("core/")) { 15366 const isCoreBlockVariation = name !== item.id; 15367 rank += isCoreBlockVariation ? 1 : 2; 15368 } 15369 return rank; 15370 } 15371 15372 // packages/block-editor/build-module/components/inserter/hooks/use-block-types-state.js 15373 var import_blocks10 = __toESM(require_blocks()); 15374 var import_data9 = __toESM(require_data()); 15375 var import_element12 = __toESM(require_element()); 15376 var import_notices2 = __toESM(require_notices()); 15377 var import_i18n8 = __toESM(require_i18n()); 15378 var useBlockTypesState = (rootClientId, onInsert, isQuick) => { 15379 const options = (0, import_element12.useMemo)( 15380 () => ({ [isFiltered]: !!isQuick }), 15381 [isQuick] 15382 ); 15383 const [items] = (0, import_data9.useSelect)( 15384 (select3) => [ 15385 select3(store).getInserterItems( 15386 rootClientId, 15387 options 15388 ) 15389 ], 15390 [rootClientId, options] 15391 ); 15392 const { getClosestAllowedInsertionPoint: getClosestAllowedInsertionPoint2 } = unlock( 15393 (0, import_data9.useSelect)(store) 15394 ); 15395 const { createErrorNotice } = (0, import_data9.useDispatch)(import_notices2.store); 15396 const [categories, collections] = (0, import_data9.useSelect)((select3) => { 15397 const { getCategories, getCollections } = select3(import_blocks10.store); 15398 return [getCategories(), getCollections()]; 15399 }, []); 15400 const onSelectItem = (0, import_element12.useCallback)( 15401 ({ name, initialAttributes, innerBlocks, syncStatus, content }, shouldFocusBlock) => { 15402 const destinationClientId = getClosestAllowedInsertionPoint2( 15403 name, 15404 rootClientId 15405 ); 15406 if (destinationClientId === null) { 15407 const title = (0, import_blocks10.getBlockType)(name)?.title ?? name; 15408 createErrorNotice( 15409 (0, import_i18n8.sprintf)( 15410 /* translators: %s: block pattern title. */ 15411 (0, import_i18n8.__)(`Block "%s" can't be inserted.`), 15412 title 15413 ), 15414 { 15415 type: "snackbar", 15416 id: "inserter-notice" 15417 } 15418 ); 15419 return; 15420 } 15421 const insertedBlock = syncStatus === "unsynced" ? (0, import_blocks10.parse)(content, { 15422 __unstableSkipMigrationLogs: true 15423 }) : (0, import_blocks10.createBlock)( 15424 name, 15425 initialAttributes, 15426 (0, import_blocks10.createBlocksFromInnerBlocksTemplate)(innerBlocks) 15427 ); 15428 onInsert( 15429 insertedBlock, 15430 void 0, 15431 shouldFocusBlock, 15432 destinationClientId 15433 ); 15434 }, 15435 [ 15436 getClosestAllowedInsertionPoint2, 15437 rootClientId, 15438 onInsert, 15439 createErrorNotice 15440 ] 15441 ); 15442 return [items, categories, collections, onSelectItem]; 15443 }; 15444 var use_block_types_state_default = useBlockTypesState; 15445 15446 // packages/block-editor/build-module/components/block-icon/index.js 15447 var import_components9 = __toESM(require_components()); 15448 var import_element13 = __toESM(require_element()); 15449 var import_jsx_runtime124 = __toESM(require_jsx_runtime()); 15450 function BlockIcon({ icon, showColors = false, className, context }) { 15451 if (icon?.src === "block-default") { 15452 icon = { 15453 src: block_default_default 15454 }; 15455 } 15456 const renderedIcon = /* @__PURE__ */ (0, import_jsx_runtime124.jsx)(import_components9.Icon, { icon: icon && icon.src ? icon.src : icon, context }); 15457 const style = showColors ? { 15458 backgroundColor: icon && icon.background, 15459 color: icon && icon.foreground 15460 } : {}; 15461 return /* @__PURE__ */ (0, import_jsx_runtime124.jsx)( 15462 "span", 15463 { 15464 style, 15465 className: clsx_default("block-editor-block-icon", className, { 15466 "has-colors": showColors 15467 }), 15468 children: renderedIcon 15469 } 15470 ); 15471 } 15472 var block_icon_default = (0, import_element13.memo)(BlockIcon); 15473 15474 // packages/block-editor/build-module/utils/order-inserter-block-items.js 15475 var orderInserterBlockItems = (items, priority2) => { 15476 if (!priority2) { 15477 return items; 15478 } 15479 items.sort(({ id: aName }, { id: bName }) => { 15480 let aIndex = priority2.indexOf(aName); 15481 let bIndex = priority2.indexOf(bName); 15482 if (aIndex < 0) { 15483 aIndex = priority2.length; 15484 } 15485 if (bIndex < 0) { 15486 bIndex = priority2.length; 15487 } 15488 return aIndex - bIndex; 15489 }); 15490 return items; 15491 }; 15492 15493 // packages/block-editor/build-module/autocompleters/block.js 15494 var import_jsx_runtime125 = __toESM(require_jsx_runtime()); 15495 var noop = () => { 15496 }; 15497 var SHOWN_BLOCK_TYPES = 9; 15498 function createBlockCompleter() { 15499 return { 15500 name: "blocks", 15501 className: "block-editor-autocompleters__block", 15502 triggerPrefix: "/", 15503 useItems(filterValue) { 15504 const { rootClientId, selectedBlockId, prioritizedBlocks } = (0, import_data10.useSelect)((select3) => { 15505 const { 15506 getSelectedBlockClientId: getSelectedBlockClientId2, 15507 getBlock: getBlock2, 15508 getBlockListSettings: getBlockListSettings2, 15509 getBlockRootClientId: getBlockRootClientId2 15510 } = select3(store); 15511 const { getActiveBlockVariation } = select3(import_blocks11.store); 15512 const selectedBlockClientId = getSelectedBlockClientId2(); 15513 const { name: blockName, attributes } = getBlock2( 15514 selectedBlockClientId 15515 ); 15516 const activeBlockVariation = getActiveBlockVariation( 15517 blockName, 15518 attributes 15519 ); 15520 const _rootClientId = getBlockRootClientId2( 15521 selectedBlockClientId 15522 ); 15523 return { 15524 selectedBlockId: activeBlockVariation ? `$blockName}/$activeBlockVariation.name}` : blockName, 15525 rootClientId: _rootClientId, 15526 prioritizedBlocks: getBlockListSettings2(_rootClientId)?.prioritizedInserterBlocks 15527 }; 15528 }, []); 15529 const [items, categories, collections] = use_block_types_state_default( 15530 rootClientId, 15531 noop, 15532 true 15533 ); 15534 const filteredItems = (0, import_element14.useMemo)(() => { 15535 const initialFilteredItems = !!filterValue.trim() ? searchBlockItems( 15536 items, 15537 categories, 15538 collections, 15539 filterValue 15540 ) : orderInserterBlockItems( 15541 orderBy(items, "frecency", "desc"), 15542 prioritizedBlocks 15543 ); 15544 return initialFilteredItems.filter((item) => item.id !== selectedBlockId).slice(0, SHOWN_BLOCK_TYPES); 15545 }, [ 15546 filterValue, 15547 selectedBlockId, 15548 items, 15549 categories, 15550 collections, 15551 prioritizedBlocks 15552 ]); 15553 const options = (0, import_element14.useMemo)( 15554 () => filteredItems.map((blockItem) => { 15555 const { title, icon, isDisabled } = blockItem; 15556 return { 15557 key: `block-$blockItem.id}`, 15558 value: blockItem, 15559 label: /* @__PURE__ */ (0, import_jsx_runtime125.jsxs)(import_jsx_runtime125.Fragment, { children: [ 15560 /* @__PURE__ */ (0, import_jsx_runtime125.jsx)( 15561 block_icon_default, 15562 { 15563 icon, 15564 showColors: true 15565 }, 15566 "icon" 15567 ), 15568 title 15569 ] }), 15570 isDisabled 15571 }; 15572 }), 15573 [filteredItems] 15574 ); 15575 return [options]; 15576 }, 15577 allowContext(before, after) { 15578 return !(/\S/.test(before) || /\S/.test(after)); 15579 }, 15580 getOptionCompletion(inserterItem) { 15581 const { name, initialAttributes, innerBlocks, syncStatus, blocks: blocks2 } = inserterItem; 15582 return { 15583 action: "replace", 15584 value: syncStatus === "unsynced" ? (blocks2 ?? []).map( 15585 (block) => (0, import_blocks11.cloneBlock)(block) 15586 ) : (0, import_blocks11.createBlock)( 15587 name, 15588 initialAttributes, 15589 (0, import_blocks11.createBlocksFromInnerBlocksTemplate)( 15590 innerBlocks 15591 ) 15592 ) 15593 }; 15594 } 15595 }; 15596 } 15597 var block_default = createBlockCompleter(); 15598 15599 // packages/block-editor/build-module/autocompleters/link.js 15600 var import_api_fetch = __toESM(require_api_fetch()); 15601 var import_url2 = __toESM(require_url()); 15602 var import_html_entities = __toESM(require_html_entities()); 15603 var import_jsx_runtime126 = __toESM(require_jsx_runtime()); 15604 var SHOWN_SUGGESTIONS = 10; 15605 function createLinkCompleter() { 15606 return { 15607 name: "links", 15608 className: "block-editor-autocompleters__link", 15609 triggerPrefix: "[[", 15610 options: async (letters) => { 15611 let options = await (0, import_api_fetch.default)({ 15612 path: (0, import_url2.addQueryArgs)("/wp/v2/search", { 15613 per_page: SHOWN_SUGGESTIONS, 15614 search: letters, 15615 type: "post", 15616 order_by: "menu_order" 15617 }) 15618 }); 15619 options = options.filter((option) => option.title !== ""); 15620 return options; 15621 }, 15622 getOptionKeywords(item) { 15623 const expansionWords = item.title.split(/\s+/); 15624 return [...expansionWords]; 15625 }, 15626 getOptionLabel(item) { 15627 return /* @__PURE__ */ (0, import_jsx_runtime126.jsxs)(import_jsx_runtime126.Fragment, { children: [ 15628 /* @__PURE__ */ (0, import_jsx_runtime126.jsx)( 15629 icon_default, 15630 { 15631 icon: item.subtype === "page" ? page_default : post_default 15632 }, 15633 "icon" 15634 ), 15635 (0, import_html_entities.decodeEntities)(item.title) 15636 ] }); 15637 }, 15638 getOptionCompletion(item) { 15639 return /* @__PURE__ */ (0, import_jsx_runtime126.jsx)("a", { href: item.url, children: item.title }); 15640 } 15641 }; 15642 } 15643 var link_default2 = createLinkCompleter(); 15644 15645 // packages/block-editor/build-module/components/autocomplete/index.js 15646 var import_jsx_runtime127 = __toESM(require_jsx_runtime()); 15647 var EMPTY_ARRAY3 = []; 15648 function useCompleters({ completers = EMPTY_ARRAY3 }) { 15649 const { name } = useBlockEditContext(); 15650 return (0, import_element15.useMemo)(() => { 15651 let filteredCompleters = [...completers, link_default2]; 15652 if (name === (0, import_blocks12.getDefaultBlockName)() || (0, import_blocks12.getBlockSupport)(name, "__experimentalSlashInserter", false)) { 15653 filteredCompleters = [...filteredCompleters, block_default]; 15654 } 15655 if ((0, import_hooks3.hasFilter)("editor.Autocomplete.completers")) { 15656 if (filteredCompleters === completers) { 15657 filteredCompleters = filteredCompleters.map( 15658 (completer) => ({ ...completer }) 15659 ); 15660 } 15661 filteredCompleters = (0, import_hooks3.applyFilters)( 15662 "editor.Autocomplete.completers", 15663 filteredCompleters, 15664 name 15665 ); 15666 } 15667 return filteredCompleters; 15668 }, [completers, name]); 15669 } 15670 function useBlockEditorAutocompleteProps(props) { 15671 return (0, import_components10.__unstableUseAutocompleteProps)({ 15672 ...props, 15673 completers: useCompleters(props) 15674 }); 15675 } 15676 function BlockEditorAutocomplete(props) { 15677 return /* @__PURE__ */ (0, import_jsx_runtime127.jsx)(import_components10.Autocomplete, { ...props, completers: useCompleters(props) }); 15678 } 15679 var autocomplete_default = BlockEditorAutocomplete; 15680 15681 // packages/block-editor/build-module/components/block-alignment-control/ui.js 15682 var import_i18n16 = __toESM(require_i18n()); 15683 var import_components16 = __toESM(require_components()); 15684 15685 // packages/block-editor/build-module/components/block-alignment-control/use-available-alignments.js 15686 var import_data11 = __toESM(require_data()); 15687 15688 // packages/block-editor/build-module/components/block-list/layout.js 15689 var import_element17 = __toESM(require_element()); 15690 15691 // packages/block-editor/build-module/layouts/flex.js 15692 var import_i18n11 = __toESM(require_i18n()); 15693 var import_components11 = __toESM(require_components()); 15694 15695 // packages/block-editor/build-module/layouts/utils.js 15696 var import_i18n9 = __toESM(require_i18n()); 15697 15698 // packages/block-editor/build-module/layouts/definitions.js 15699 var LAYOUT_DEFINITIONS = { 15700 default: { 15701 name: "default", 15702 slug: "flow", 15703 className: "is-layout-flow", 15704 baseStyles: [ 15705 { 15706 selector: " > .alignleft", 15707 rules: { 15708 float: "left", 15709 "margin-inline-start": "0", 15710 "margin-inline-end": "2em" 15711 } 15712 }, 15713 { 15714 selector: " > .alignright", 15715 rules: { 15716 float: "right", 15717 "margin-inline-start": "2em", 15718 "margin-inline-end": "0" 15719 } 15720 }, 15721 { 15722 selector: " > .aligncenter", 15723 rules: { 15724 "margin-left": "auto !important", 15725 "margin-right": "auto !important" 15726 } 15727 } 15728 ], 15729 spacingStyles: [ 15730 { 15731 selector: " > :first-child", 15732 rules: { 15733 "margin-block-start": "0" 15734 } 15735 }, 15736 { 15737 selector: " > :last-child", 15738 rules: { 15739 "margin-block-end": "0" 15740 } 15741 }, 15742 { 15743 selector: " > *", 15744 rules: { 15745 "margin-block-start": null, 15746 "margin-block-end": "0" 15747 } 15748 } 15749 ] 15750 }, 15751 constrained: { 15752 name: "constrained", 15753 slug: "constrained", 15754 className: "is-layout-constrained", 15755 baseStyles: [ 15756 { 15757 selector: " > .alignleft", 15758 rules: { 15759 float: "left", 15760 "margin-inline-start": "0", 15761 "margin-inline-end": "2em" 15762 } 15763 }, 15764 { 15765 selector: " > .alignright", 15766 rules: { 15767 float: "right", 15768 "margin-inline-start": "2em", 15769 "margin-inline-end": "0" 15770 } 15771 }, 15772 { 15773 selector: " > .aligncenter", 15774 rules: { 15775 "margin-left": "auto !important", 15776 "margin-right": "auto !important" 15777 } 15778 }, 15779 { 15780 selector: " > :where(:not(.alignleft):not(.alignright):not(.alignfull))", 15781 rules: { 15782 "max-width": "var(--wp--style--global--content-size)", 15783 "margin-left": "auto !important", 15784 "margin-right": "auto !important" 15785 } 15786 }, 15787 { 15788 selector: " > .alignwide", 15789 rules: { 15790 "max-width": "var(--wp--style--global--wide-size)" 15791 } 15792 } 15793 ], 15794 spacingStyles: [ 15795 { 15796 selector: " > :first-child", 15797 rules: { 15798 "margin-block-start": "0" 15799 } 15800 }, 15801 { 15802 selector: " > :last-child", 15803 rules: { 15804 "margin-block-end": "0" 15805 } 15806 }, 15807 { 15808 selector: " > *", 15809 rules: { 15810 "margin-block-start": null, 15811 "margin-block-end": "0" 15812 } 15813 } 15814 ] 15815 }, 15816 flex: { 15817 name: "flex", 15818 slug: "flex", 15819 className: "is-layout-flex", 15820 displayMode: "flex", 15821 baseStyles: [ 15822 { 15823 selector: "", 15824 rules: { 15825 "flex-wrap": "wrap", 15826 "align-items": "center" 15827 } 15828 }, 15829 { 15830 selector: " > :is(*, div)", 15831 // :is(*, div) instead of just * increases the specificity by 001. 15832 rules: { 15833 margin: "0" 15834 } 15835 } 15836 ], 15837 spacingStyles: [ 15838 { 15839 selector: "", 15840 rules: { 15841 gap: null 15842 } 15843 } 15844 ] 15845 }, 15846 grid: { 15847 name: "grid", 15848 slug: "grid", 15849 className: "is-layout-grid", 15850 displayMode: "grid", 15851 baseStyles: [ 15852 { 15853 selector: " > :is(*, div)", 15854 // :is(*, div) instead of just * increases the specificity by 001. 15855 rules: { 15856 margin: "0" 15857 } 15858 } 15859 ], 15860 spacingStyles: [ 15861 { 15862 selector: "", 15863 rules: { 15864 gap: null 15865 } 15866 } 15867 ] 15868 } 15869 }; 15870 15871 // packages/block-editor/build-module/layouts/utils.js 15872 function appendSelectors(selectors, append = "") { 15873 return selectors.split(",").map( 15874 (subselector) => `$subselector}$append ? ` $append}` : ""}` 15875 ).join(","); 15876 } 15877 function getBlockGapCSS(selector3, layoutDefinitions = LAYOUT_DEFINITIONS, layoutType, blockGapValue) { 15878 let output = ""; 15879 if (layoutDefinitions?.[layoutType]?.spacingStyles?.length && blockGapValue) { 15880 layoutDefinitions[layoutType].spacingStyles.forEach((gapStyle) => { 15881 output += `$appendSelectors( 15882 selector3, 15883 gapStyle.selector.trim() 15884 )} { `; 15885 output += Object.entries(gapStyle.rules).map( 15886 ([cssProperty, value]) => `$cssProperty}: $value ? value : blockGapValue}` 15887 ).join("; "); 15888 output += "; }"; 15889 }); 15890 } 15891 return output; 15892 } 15893 function getAlignmentsInfo(layout) { 15894 const { contentSize, wideSize, type = "default" } = layout; 15895 const alignmentInfo = {}; 15896 const sizeRegex = /^(?!0)\d+(px|em|rem|vw|vh|%|svw|lvw|dvw|svh|lvh|dvh|vi|svi|lvi|dvi|vb|svb|lvb|dvb|vmin|svmin|lvmin|dvmin|vmax|svmax|lvmax|dvmax)?$/i; 15897 if (sizeRegex.test(contentSize) && type === "constrained") { 15898 alignmentInfo.none = (0, import_i18n9.sprintf)((0, import_i18n9.__)("Max %s wide"), contentSize); 15899 } 15900 if (sizeRegex.test(wideSize)) { 15901 alignmentInfo.wide = (0, import_i18n9.sprintf)((0, import_i18n9.__)("Max %s wide"), wideSize); 15902 } 15903 return alignmentInfo; 15904 } 15905 15906 // packages/block-editor/build-module/components/spacing-sizes-control/utils.js 15907 var import_i18n10 = __toESM(require_i18n()); 15908 var RANGE_CONTROL_MAX_SIZE = 8; 15909 var ALL_SIDES = ["top", "right", "bottom", "left"]; 15910 var DEFAULT_VALUES = { 15911 top: void 0, 15912 right: void 0, 15913 bottom: void 0, 15914 left: void 0 15915 }; 15916 var ICONS = { 15917 custom: sides_all_default, 15918 axial: sides_all_default, 15919 horizontal: sides_horizontal_default, 15920 vertical: sides_vertical_default, 15921 top: sides_top_default, 15922 right: sides_right_default, 15923 bottom: sides_bottom_default, 15924 left: sides_left_default 15925 }; 15926 var LABELS = { 15927 default: (0, import_i18n10.__)("Spacing control"), 15928 top: (0, import_i18n10.__)("Top"), 15929 bottom: (0, import_i18n10.__)("Bottom"), 15930 left: (0, import_i18n10.__)("Left"), 15931 right: (0, import_i18n10.__)("Right"), 15932 mixed: (0, import_i18n10.__)("Mixed"), 15933 vertical: (0, import_i18n10.__)("Vertical"), 15934 horizontal: (0, import_i18n10.__)("Horizontal"), 15935 axial: (0, import_i18n10.__)("Horizontal & vertical"), 15936 custom: (0, import_i18n10.__)("Custom") 15937 }; 15938 var VIEWS = { 15939 axial: "axial", 15940 top: "top", 15941 right: "right", 15942 bottom: "bottom", 15943 left: "left", 15944 custom: "custom" 15945 }; 15946 function isValueSpacingPreset(value) { 15947 if (!value?.includes) { 15948 return false; 15949 } 15950 return value === "0" || value.includes("var:preset|spacing|"); 15951 } 15952 function getCustomValueFromPreset(value, spacingSizes) { 15953 if (!isValueSpacingPreset(value)) { 15954 return value; 15955 } 15956 const slug = getSpacingPresetSlug(value); 15957 const spacingSize = spacingSizes.find( 15958 (size) => String(size.slug) === slug 15959 ); 15960 return spacingSize?.size; 15961 } 15962 function getPresetValueFromCustomValue(value, spacingSizes) { 15963 if (!value || isValueSpacingPreset(value) || value === "0") { 15964 return value; 15965 } 15966 const spacingMatch = spacingSizes.find( 15967 (size) => String(size.size) === String(value) 15968 ); 15969 if (spacingMatch?.slug) { 15970 return `var:preset|spacing|$spacingMatch.slug}`; 15971 } 15972 return value; 15973 } 15974 function getSpacingPresetCssVar(value) { 15975 if (!value) { 15976 return; 15977 } 15978 const slug = value.match(/var:preset\|spacing\|(.+)/); 15979 if (!slug) { 15980 return value; 15981 } 15982 return `var(--wp--preset--spacing--$slug[1]})`; 15983 } 15984 function getSpacingPresetSlug(value) { 15985 if (!value) { 15986 return; 15987 } 15988 if (value === "0" || value === "default") { 15989 return value; 15990 } 15991 const slug = value.match(/var:preset\|spacing\|(.+)/); 15992 return slug ? slug[1] : void 0; 15993 } 15994 function hasAxisSupport(sides, axis) { 15995 if (!sides || !sides.length) { 15996 return false; 15997 } 15998 const hasHorizontalSupport = sides.includes("horizontal") || sides.includes("left") && sides.includes("right"); 15999 const hasVerticalSupport = sides.includes("vertical") || sides.includes("top") && sides.includes("bottom"); 16000 if (axis === "horizontal") { 16001 return hasHorizontalSupport; 16002 } 16003 if (axis === "vertical") { 16004 return hasVerticalSupport; 16005 } 16006 return hasHorizontalSupport || hasVerticalSupport; 16007 } 16008 function hasBalancedSidesSupport(sides = []) { 16009 const counts = { top: 0, right: 0, bottom: 0, left: 0 }; 16010 sides.forEach((side) => counts[side] += 1); 16011 return (counts.top + counts.bottom) % 2 === 0 && (counts.left + counts.right) % 2 === 0; 16012 } 16013 function getInitialView(values = {}, sides) { 16014 const { top, right, bottom, left } = values; 16015 const sideValues = [top, right, bottom, left].filter(Boolean); 16016 const hasMatchingAxialValues = top === bottom && left === right && (!!top || !!left); 16017 const hasNoValuesAndBalancedSides = !sideValues.length && hasBalancedSidesSupport(sides); 16018 const hasOnlyAxialSides = sides?.includes("horizontal") && sides?.includes("vertical") && sides?.length === 2; 16019 if (hasAxisSupport(sides) && (hasMatchingAxialValues || hasNoValuesAndBalancedSides)) { 16020 return VIEWS.axial; 16021 } 16022 if (hasOnlyAxialSides && sideValues.length === 1) { 16023 let side; 16024 Object.entries(values).some(([key, value]) => { 16025 side = key; 16026 return value !== void 0; 16027 }); 16028 return side; 16029 } 16030 if (sides?.length === 1 && !sideValues.length) { 16031 return sides[0]; 16032 } 16033 return VIEWS.custom; 16034 } 16035 16036 // packages/block-editor/build-module/hooks/gap.js 16037 function getGapBoxControlValueFromStyle(blockGapValue) { 16038 if (!blockGapValue) { 16039 return null; 16040 } 16041 const isValueString = typeof blockGapValue === "string"; 16042 return { 16043 top: isValueString ? blockGapValue : blockGapValue?.top, 16044 left: isValueString ? blockGapValue : blockGapValue?.left 16045 }; 16046 } 16047 function getGapCSSValue(blockGapValue, defaultValue = "0") { 16048 const blockGapBoxControlValue = getGapBoxControlValueFromStyle(blockGapValue); 16049 if (!blockGapBoxControlValue) { 16050 return null; 16051 } 16052 const row = getSpacingPresetCssVar(blockGapBoxControlValue?.top) || defaultValue; 16053 const column = getSpacingPresetCssVar(blockGapBoxControlValue?.left) || defaultValue; 16054 return row === column ? row : `$row} $column}`; 16055 } 16056 16057 // packages/block-editor/build-module/layouts/flex.js 16058 var import_jsx_runtime128 = __toESM(require_jsx_runtime()); 16059 var justifyContentMap = { 16060 left: "flex-start", 16061 right: "flex-end", 16062 center: "center", 16063 "space-between": "space-between" 16064 }; 16065 var alignItemsMap = { 16066 left: "flex-start", 16067 right: "flex-end", 16068 center: "center", 16069 stretch: "stretch" 16070 }; 16071 var verticalAlignmentMap = { 16072 top: "flex-start", 16073 center: "center", 16074 bottom: "flex-end", 16075 stretch: "stretch", 16076 "space-between": "space-between" 16077 }; 16078 var defaultAlignments = { 16079 horizontal: "center", 16080 vertical: "top" 16081 }; 16082 var flexWrapOptions = ["wrap", "nowrap"]; 16083 var flex_default = { 16084 name: "flex", 16085 label: (0, import_i18n11.__)("Flex"), 16086 inspectorControls: function FlexLayoutInspectorControls({ 16087 layout = {}, 16088 onChange, 16089 layoutBlockSupport = {} 16090 }) { 16091 const { allowOrientation = true, allowJustification = true } = layoutBlockSupport; 16092 return /* @__PURE__ */ (0, import_jsx_runtime128.jsxs)(import_jsx_runtime128.Fragment, { children: [ 16093 /* @__PURE__ */ (0, import_jsx_runtime128.jsxs)(import_components11.Flex, { children: [ 16094 allowJustification && /* @__PURE__ */ (0, import_jsx_runtime128.jsx)(import_components11.FlexItem, { children: /* @__PURE__ */ (0, import_jsx_runtime128.jsx)( 16095 FlexLayoutJustifyContentControl, 16096 { 16097 layout, 16098 onChange 16099 } 16100 ) }), 16101 allowOrientation && /* @__PURE__ */ (0, import_jsx_runtime128.jsx)(import_components11.FlexItem, { children: /* @__PURE__ */ (0, import_jsx_runtime128.jsx)( 16102 OrientationControl, 16103 { 16104 layout, 16105 onChange 16106 } 16107 ) }) 16108 ] }), 16109 /* @__PURE__ */ (0, import_jsx_runtime128.jsx)(FlexWrapControl, { layout, onChange }) 16110 ] }); 16111 }, 16112 toolBarControls: function FlexLayoutToolbarControls({ 16113 layout = {}, 16114 onChange, 16115 layoutBlockSupport 16116 }) { 16117 const { allowVerticalAlignment = true, allowJustification = true } = layoutBlockSupport; 16118 if (!allowJustification && !allowVerticalAlignment) { 16119 return null; 16120 } 16121 return /* @__PURE__ */ (0, import_jsx_runtime128.jsxs)(block_controls_default, { group: "block", __experimentalShareWithChildBlocks: true, children: [ 16122 allowJustification && /* @__PURE__ */ (0, import_jsx_runtime128.jsx)( 16123 FlexLayoutJustifyContentControl, 16124 { 16125 layout, 16126 onChange, 16127 isToolbar: true 16128 } 16129 ), 16130 allowVerticalAlignment && /* @__PURE__ */ (0, import_jsx_runtime128.jsx)( 16131 FlexLayoutVerticalAlignmentControl, 16132 { 16133 layout, 16134 onChange 16135 } 16136 ) 16137 ] }); 16138 }, 16139 getLayoutStyle: function getLayoutStyle({ 16140 selector: selector3, 16141 layout, 16142 style, 16143 blockName, 16144 hasBlockGapSupport, 16145 layoutDefinitions = LAYOUT_DEFINITIONS 16146 }) { 16147 const { orientation = "horizontal" } = layout; 16148 const blockGapValue = style?.spacing?.blockGap && !shouldSkipSerialization(blockName, "spacing", "blockGap") ? getGapCSSValue(style?.spacing?.blockGap, "0.5em") : void 0; 16149 const justifyContent = justifyContentMap[layout.justifyContent]; 16150 const flexWrap = flexWrapOptions.includes(layout.flexWrap) ? layout.flexWrap : "wrap"; 16151 const verticalAlignment = verticalAlignmentMap[layout.verticalAlignment]; 16152 const alignItems = alignItemsMap[layout.justifyContent] || alignItemsMap.left; 16153 let output = ""; 16154 const rules = []; 16155 if (flexWrap && flexWrap !== "wrap") { 16156 rules.push(`flex-wrap: $flexWrap}`); 16157 } 16158 if (orientation === "horizontal") { 16159 if (verticalAlignment) { 16160 rules.push(`align-items: $verticalAlignment}`); 16161 } 16162 if (justifyContent) { 16163 rules.push(`justify-content: $justifyContent}`); 16164 } 16165 } else { 16166 if (verticalAlignment) { 16167 rules.push(`justify-content: $verticalAlignment}`); 16168 } 16169 rules.push("flex-direction: column"); 16170 rules.push(`align-items: $alignItems}`); 16171 } 16172 if (rules.length) { 16173 output = `$appendSelectors(selector3)} { 16174 $rules.join("; ")}; 16175 }`; 16176 } 16177 if (hasBlockGapSupport && blockGapValue) { 16178 output += getBlockGapCSS( 16179 selector3, 16180 layoutDefinitions, 16181 "flex", 16182 blockGapValue 16183 ); 16184 } 16185 return output; 16186 }, 16187 getOrientation(layout) { 16188 const { orientation = "horizontal" } = layout; 16189 return orientation; 16190 }, 16191 getAlignments() { 16192 return []; 16193 } 16194 }; 16195 function FlexLayoutVerticalAlignmentControl({ layout, onChange }) { 16196 const { orientation = "horizontal" } = layout; 16197 const defaultVerticalAlignment = orientation === "horizontal" ? defaultAlignments.horizontal : defaultAlignments.vertical; 16198 const { verticalAlignment = defaultVerticalAlignment } = layout; 16199 const onVerticalAlignmentChange = (value) => { 16200 onChange({ 16201 ...layout, 16202 verticalAlignment: value 16203 }); 16204 }; 16205 return /* @__PURE__ */ (0, import_jsx_runtime128.jsx)( 16206 BlockVerticalAlignmentControl, 16207 { 16208 onChange: onVerticalAlignmentChange, 16209 value: verticalAlignment, 16210 controls: orientation === "horizontal" ? ["top", "center", "bottom", "stretch"] : ["top", "center", "bottom", "space-between"] 16211 } 16212 ); 16213 } 16214 var POPOVER_PROPS2 = { 16215 placement: "bottom-start" 16216 }; 16217 function FlexLayoutJustifyContentControl({ 16218 layout, 16219 onChange, 16220 isToolbar = false 16221 }) { 16222 const { justifyContent = "left", orientation = "horizontal" } = layout; 16223 const onJustificationChange = (value) => { 16224 onChange({ 16225 ...layout, 16226 justifyContent: value 16227 }); 16228 }; 16229 const allowedControls = ["left", "center", "right"]; 16230 if (orientation === "horizontal") { 16231 allowedControls.push("space-between"); 16232 } else { 16233 allowedControls.push("stretch"); 16234 } 16235 if (isToolbar) { 16236 return /* @__PURE__ */ (0, import_jsx_runtime128.jsx)( 16237 JustifyContentControl, 16238 { 16239 allowedControls, 16240 value: justifyContent, 16241 onChange: onJustificationChange, 16242 popoverProps: POPOVER_PROPS2 16243 } 16244 ); 16245 } 16246 const justificationOptions = [ 16247 { 16248 value: "left", 16249 icon: justify_left_default, 16250 label: (0, import_i18n11.__)("Justify items left") 16251 }, 16252 { 16253 value: "center", 16254 icon: justify_center_default, 16255 label: (0, import_i18n11.__)("Justify items center") 16256 }, 16257 { 16258 value: "right", 16259 icon: justify_right_default, 16260 label: (0, import_i18n11.__)("Justify items right") 16261 } 16262 ]; 16263 if (orientation === "horizontal") { 16264 justificationOptions.push({ 16265 value: "space-between", 16266 icon: justify_space_between_default, 16267 label: (0, import_i18n11.__)("Space between items") 16268 }); 16269 } else { 16270 justificationOptions.push({ 16271 value: "stretch", 16272 icon: justify_stretch_default, 16273 label: (0, import_i18n11.__)("Stretch items") 16274 }); 16275 } 16276 return /* @__PURE__ */ (0, import_jsx_runtime128.jsx)( 16277 import_components11.__experimentalToggleGroupControl, 16278 { 16279 __next40pxDefaultSize: true, 16280 label: (0, import_i18n11.__)("Justification"), 16281 value: justifyContent, 16282 onChange: onJustificationChange, 16283 className: "block-editor-hooks__flex-layout-justification-controls", 16284 children: justificationOptions.map(({ value, icon, label }) => { 16285 return /* @__PURE__ */ (0, import_jsx_runtime128.jsx)( 16286 import_components11.__experimentalToggleGroupControlOptionIcon, 16287 { 16288 value, 16289 icon, 16290 label 16291 }, 16292 value 16293 ); 16294 }) 16295 } 16296 ); 16297 } 16298 function FlexWrapControl({ layout, onChange }) { 16299 const { flexWrap = "wrap" } = layout; 16300 return /* @__PURE__ */ (0, import_jsx_runtime128.jsx)( 16301 import_components11.ToggleControl, 16302 { 16303 label: (0, import_i18n11.__)("Allow to wrap to multiple lines"), 16304 onChange: (value) => { 16305 onChange({ 16306 ...layout, 16307 flexWrap: value ? "wrap" : "nowrap" 16308 }); 16309 }, 16310 checked: flexWrap === "wrap" 16311 } 16312 ); 16313 } 16314 function OrientationControl({ layout, onChange }) { 16315 const { 16316 orientation = "horizontal", 16317 verticalAlignment, 16318 justifyContent 16319 } = layout; 16320 return /* @__PURE__ */ (0, import_jsx_runtime128.jsxs)( 16321 import_components11.__experimentalToggleGroupControl, 16322 { 16323 __next40pxDefaultSize: true, 16324 className: "block-editor-hooks__flex-layout-orientation-controls", 16325 label: (0, import_i18n11.__)("Orientation"), 16326 value: orientation, 16327 onChange: (value) => { 16328 let newVerticalAlignment = verticalAlignment; 16329 let newJustification = justifyContent; 16330 if (value === "horizontal") { 16331 if (verticalAlignment === "space-between") { 16332 newVerticalAlignment = "center"; 16333 } 16334 if (justifyContent === "stretch") { 16335 newJustification = "left"; 16336 } 16337 } else { 16338 if (verticalAlignment === "stretch") { 16339 newVerticalAlignment = "top"; 16340 } 16341 if (justifyContent === "space-between") { 16342 newJustification = "left"; 16343 } 16344 } 16345 return onChange({ 16346 ...layout, 16347 orientation: value, 16348 verticalAlignment: newVerticalAlignment, 16349 justifyContent: newJustification 16350 }); 16351 }, 16352 children: [ 16353 /* @__PURE__ */ (0, import_jsx_runtime128.jsx)( 16354 import_components11.__experimentalToggleGroupControlOptionIcon, 16355 { 16356 icon: arrow_right_default, 16357 value: "horizontal", 16358 label: (0, import_i18n11.__)("Horizontal") 16359 } 16360 ), 16361 /* @__PURE__ */ (0, import_jsx_runtime128.jsx)( 16362 import_components11.__experimentalToggleGroupControlOptionIcon, 16363 { 16364 icon: arrow_down_default, 16365 value: "vertical", 16366 label: (0, import_i18n11.__)("Vertical") 16367 } 16368 ) 16369 ] 16370 } 16371 ); 16372 } 16373 16374 // packages/block-editor/build-module/layouts/flow.js 16375 var import_i18n12 = __toESM(require_i18n()); 16376 var flow_default = { 16377 name: "default", 16378 label: (0, import_i18n12.__)("Flow"), 16379 inspectorControls: function DefaultLayoutInspectorControls() { 16380 return null; 16381 }, 16382 toolBarControls: function DefaultLayoutToolbarControls() { 16383 return null; 16384 }, 16385 getLayoutStyle: function getLayoutStyle2({ 16386 selector: selector3, 16387 style, 16388 blockName, 16389 hasBlockGapSupport, 16390 layoutDefinitions = LAYOUT_DEFINITIONS 16391 }) { 16392 const blockGapStyleValue = getGapCSSValue(style?.spacing?.blockGap); 16393 let blockGapValue = ""; 16394 if (!shouldSkipSerialization(blockName, "spacing", "blockGap")) { 16395 if (blockGapStyleValue?.top) { 16396 blockGapValue = getGapCSSValue(blockGapStyleValue?.top); 16397 } else if (typeof blockGapStyleValue === "string") { 16398 blockGapValue = getGapCSSValue(blockGapStyleValue); 16399 } 16400 } 16401 let output = ""; 16402 if (hasBlockGapSupport && blockGapValue) { 16403 output += getBlockGapCSS( 16404 selector3, 16405 layoutDefinitions, 16406 "default", 16407 blockGapValue 16408 ); 16409 } 16410 return output; 16411 }, 16412 getOrientation() { 16413 return "vertical"; 16414 }, 16415 getAlignments(layout, isBlockBasedTheme) { 16416 const alignmentInfo = getAlignmentsInfo(layout); 16417 if (layout.alignments !== void 0) { 16418 if (!layout.alignments.includes("none")) { 16419 layout.alignments.unshift("none"); 16420 } 16421 return layout.alignments.map((alignment) => ({ 16422 name: alignment, 16423 info: alignmentInfo[alignment] 16424 })); 16425 } 16426 const alignments = [ 16427 { name: "left" }, 16428 { name: "center" }, 16429 { name: "right" } 16430 ]; 16431 if (!isBlockBasedTheme) { 16432 const { contentSize, wideSize } = layout; 16433 if (contentSize) { 16434 alignments.unshift({ name: "full" }); 16435 } 16436 if (wideSize) { 16437 alignments.unshift({ 16438 name: "wide", 16439 info: alignmentInfo.wide 16440 }); 16441 } 16442 } 16443 alignments.unshift({ name: "none", info: alignmentInfo.none }); 16444 return alignments; 16445 } 16446 }; 16447 16448 // packages/block-editor/build-module/layouts/constrained.js 16449 var import_components13 = __toESM(require_components()); 16450 var import_i18n13 = __toESM(require_i18n()); 16451 var import_style_engine = __toESM(require_style_engine()); 16452 var import_jsx_runtime129 = __toESM(require_jsx_runtime()); 16453 var constrained_default = { 16454 name: "constrained", 16455 label: (0, import_i18n13.__)("Constrained"), 16456 inspectorControls: function DefaultLayoutInspectorControls2({ 16457 layout, 16458 onChange, 16459 layoutBlockSupport = {} 16460 }) { 16461 const { wideSize, contentSize, justifyContent = "center" } = layout; 16462 const { 16463 allowJustification = true, 16464 allowCustomContentAndWideSize = true 16465 } = layoutBlockSupport; 16466 const onJustificationChange = (value) => { 16467 onChange({ 16468 ...layout, 16469 justifyContent: value 16470 }); 16471 }; 16472 const justificationOptions = [ 16473 { 16474 value: "left", 16475 icon: justify_left_default, 16476 label: (0, import_i18n13.__)("Justify items left") 16477 }, 16478 { 16479 value: "center", 16480 icon: justify_center_default, 16481 label: (0, import_i18n13.__)("Justify items center") 16482 }, 16483 { 16484 value: "right", 16485 icon: justify_right_default, 16486 label: (0, import_i18n13.__)("Justify items right") 16487 } 16488 ]; 16489 const [availableUnits] = useSettings("spacing.units"); 16490 const units2 = (0, import_components13.__experimentalUseCustomUnits)({ 16491 availableUnits: availableUnits || ["%", "px", "em", "rem", "vw"] 16492 }); 16493 return /* @__PURE__ */ (0, import_jsx_runtime129.jsxs)( 16494 import_components13.__experimentalVStack, 16495 { 16496 spacing: 4, 16497 className: "block-editor-hooks__layout-constrained", 16498 children: [ 16499 allowCustomContentAndWideSize && /* @__PURE__ */ (0, import_jsx_runtime129.jsxs)(import_jsx_runtime129.Fragment, { children: [ 16500 /* @__PURE__ */ (0, import_jsx_runtime129.jsx)( 16501 import_components13.__experimentalUnitControl, 16502 { 16503 __next40pxDefaultSize: true, 16504 label: (0, import_i18n13.__)("Content width"), 16505 labelPosition: "top", 16506 value: contentSize || wideSize || "", 16507 onChange: (nextWidth) => { 16508 nextWidth = 0 > parseFloat(nextWidth) ? "0" : nextWidth; 16509 onChange({ 16510 ...layout, 16511 contentSize: nextWidth !== "" ? nextWidth : void 0 16512 }); 16513 }, 16514 units: units2, 16515 prefix: /* @__PURE__ */ (0, import_jsx_runtime129.jsx)(import_components13.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime129.jsx)(icon_default, { icon: align_none_default }) }) 16516 } 16517 ), 16518 /* @__PURE__ */ (0, import_jsx_runtime129.jsx)( 16519 import_components13.__experimentalUnitControl, 16520 { 16521 __next40pxDefaultSize: true, 16522 label: (0, import_i18n13.__)("Wide width"), 16523 labelPosition: "top", 16524 value: wideSize || contentSize || "", 16525 onChange: (nextWidth) => { 16526 nextWidth = 0 > parseFloat(nextWidth) ? "0" : nextWidth; 16527 onChange({ 16528 ...layout, 16529 wideSize: nextWidth !== "" ? nextWidth : void 0 16530 }); 16531 }, 16532 units: units2, 16533 prefix: /* @__PURE__ */ (0, import_jsx_runtime129.jsx)(import_components13.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime129.jsx)(icon_default, { icon: stretch_wide_default }) }) 16534 } 16535 ), 16536 /* @__PURE__ */ (0, import_jsx_runtime129.jsx)("p", { className: "block-editor-hooks__layout-constrained-helptext", children: (0, import_i18n13.__)( 16537 "Customize the width for all elements that are assigned to the center or wide columns." 16538 ) }) 16539 ] }), 16540 allowJustification && /* @__PURE__ */ (0, import_jsx_runtime129.jsx)( 16541 import_components13.__experimentalToggleGroupControl, 16542 { 16543 __next40pxDefaultSize: true, 16544 label: (0, import_i18n13.__)("Justification"), 16545 value: justifyContent, 16546 onChange: onJustificationChange, 16547 children: justificationOptions.map( 16548 ({ value, icon, label }) => { 16549 return /* @__PURE__ */ (0, import_jsx_runtime129.jsx)( 16550 import_components13.__experimentalToggleGroupControlOptionIcon, 16551 { 16552 value, 16553 icon, 16554 label 16555 }, 16556 value 16557 ); 16558 } 16559 ) 16560 } 16561 ) 16562 ] 16563 } 16564 ); 16565 }, 16566 toolBarControls: function DefaultLayoutToolbarControls2({ 16567 layout = {}, 16568 onChange, 16569 layoutBlockSupport 16570 }) { 16571 const { allowJustification = true } = layoutBlockSupport; 16572 if (!allowJustification) { 16573 return null; 16574 } 16575 return /* @__PURE__ */ (0, import_jsx_runtime129.jsx)(block_controls_default, { group: "block", __experimentalShareWithChildBlocks: true, children: /* @__PURE__ */ (0, import_jsx_runtime129.jsx)( 16576 DefaultLayoutJustifyContentControl, 16577 { 16578 layout, 16579 onChange 16580 } 16581 ) }); 16582 }, 16583 getLayoutStyle: function getLayoutStyle3({ 16584 selector: selector3, 16585 layout = {}, 16586 style, 16587 blockName, 16588 hasBlockGapSupport, 16589 layoutDefinitions = LAYOUT_DEFINITIONS 16590 }) { 16591 const { contentSize, wideSize, justifyContent } = layout; 16592 const blockGapStyleValue = getGapCSSValue(style?.spacing?.blockGap); 16593 let blockGapValue = ""; 16594 if (!shouldSkipSerialization(blockName, "spacing", "blockGap")) { 16595 if (blockGapStyleValue?.top) { 16596 blockGapValue = getGapCSSValue(blockGapStyleValue?.top); 16597 } else if (typeof blockGapStyleValue === "string") { 16598 blockGapValue = getGapCSSValue(blockGapStyleValue); 16599 } 16600 } 16601 const marginLeft = justifyContent === "left" ? "0 !important" : "auto !important"; 16602 const marginRight = justifyContent === "right" ? "0 !important" : "auto !important"; 16603 let output = !!contentSize || !!wideSize ? ` 16604 $appendSelectors( 16605 selector3, 16606 "> :where(:not(.alignleft):not(.alignright):not(.alignfull))" 16607 )} { 16608 max-width: $contentSize ?? wideSize}; 16609 margin-left: $marginLeft}; 16610 margin-right: $marginRight}; 16611 } 16612 $appendSelectors(selector3, "> .alignwide")} { 16613 max-width: $wideSize ?? contentSize}; 16614 } 16615 $appendSelectors(selector3, "> .alignfull")} { 16616 max-width: none; 16617 } 16618 ` : ""; 16619 if (justifyContent === "left") { 16620 output += `$appendSelectors( 16621 selector3, 16622 "> :where(:not(.alignleft):not(.alignright):not(.alignfull))" 16623 )} 16624 { margin-left: $marginLeft}; }`; 16625 } else if (justifyContent === "right") { 16626 output += `$appendSelectors( 16627 selector3, 16628 "> :where(:not(.alignleft):not(.alignright):not(.alignfull))" 16629 )} 16630 { margin-right: $marginRight}; }`; 16631 } 16632 if (style?.spacing?.padding) { 16633 const paddingValues = (0, import_style_engine.getCSSRules)(style); 16634 paddingValues.forEach((rule) => { 16635 if (rule.key === "paddingRight") { 16636 const paddingRightValue = rule.value === "0" ? "0px" : rule.value; 16637 output += ` 16638 $appendSelectors(selector3, "> .alignfull")} { 16639 margin-right: calc($paddingRightValue} * -1); 16640 } 16641 `; 16642 } else if (rule.key === "paddingLeft") { 16643 const paddingLeftValue = rule.value === "0" ? "0px" : rule.value; 16644 output += ` 16645 $appendSelectors(selector3, "> .alignfull")} { 16646 margin-left: calc($paddingLeftValue} * -1); 16647 } 16648 `; 16649 } 16650 }); 16651 } 16652 if (hasBlockGapSupport && blockGapValue) { 16653 output += getBlockGapCSS( 16654 selector3, 16655 layoutDefinitions, 16656 "constrained", 16657 blockGapValue 16658 ); 16659 } 16660 return output; 16661 }, 16662 getOrientation() { 16663 return "vertical"; 16664 }, 16665 getAlignments(layout) { 16666 const alignmentInfo = getAlignmentsInfo(layout); 16667 if (layout.alignments !== void 0) { 16668 if (!layout.alignments.includes("none")) { 16669 layout.alignments.unshift("none"); 16670 } 16671 return layout.alignments.map((alignment) => ({ 16672 name: alignment, 16673 info: alignmentInfo[alignment] 16674 })); 16675 } 16676 const { contentSize, wideSize } = layout; 16677 const alignments = [ 16678 { name: "left" }, 16679 { name: "center" }, 16680 { name: "right" } 16681 ]; 16682 if (contentSize) { 16683 alignments.unshift({ name: "full" }); 16684 } 16685 if (wideSize) { 16686 alignments.unshift({ name: "wide", info: alignmentInfo.wide }); 16687 } 16688 alignments.unshift({ name: "none", info: alignmentInfo.none }); 16689 return alignments; 16690 } 16691 }; 16692 var POPOVER_PROPS3 = { 16693 placement: "bottom-start" 16694 }; 16695 function DefaultLayoutJustifyContentControl({ layout, onChange }) { 16696 const { justifyContent = "center" } = layout; 16697 const onJustificationChange = (value) => { 16698 onChange({ 16699 ...layout, 16700 justifyContent: value 16701 }); 16702 }; 16703 const allowedControls = ["left", "center", "right"]; 16704 return /* @__PURE__ */ (0, import_jsx_runtime129.jsx)( 16705 JustifyContentControl, 16706 { 16707 allowedControls, 16708 value: justifyContent, 16709 onChange: onJustificationChange, 16710 popoverProps: POPOVER_PROPS3 16711 } 16712 ); 16713 } 16714 16715 // packages/block-editor/build-module/layouts/grid.js 16716 var import_i18n14 = __toESM(require_i18n()); 16717 var import_components15 = __toESM(require_components()); 16718 var import_element16 = __toESM(require_element()); 16719 var import_jsx_runtime130 = __toESM(require_jsx_runtime()); 16720 var RANGE_CONTROL_MAX_VALUES = { 16721 px: 600, 16722 "%": 100, 16723 vw: 100, 16724 vh: 100, 16725 em: 38, 16726 rem: 38, 16727 svw: 100, 16728 lvw: 100, 16729 dvw: 100, 16730 svh: 100, 16731 lvh: 100, 16732 dvh: 100, 16733 vi: 100, 16734 svi: 100, 16735 lvi: 100, 16736 dvi: 100, 16737 vb: 100, 16738 svb: 100, 16739 lvb: 100, 16740 dvb: 100, 16741 vmin: 100, 16742 svmin: 100, 16743 lvmin: 100, 16744 dvmin: 100, 16745 vmax: 100, 16746 svmax: 100, 16747 lvmax: 100, 16748 dvmax: 100 16749 }; 16750 var units = [ 16751 { value: "px", label: "px", default: 0 }, 16752 { value: "rem", label: "rem", default: 0 }, 16753 { value: "em", label: "em", default: 0 } 16754 ]; 16755 var grid_default2 = { 16756 name: "grid", 16757 label: (0, import_i18n14.__)("Grid"), 16758 inspectorControls: function GridLayoutInspectorControls({ 16759 layout = {}, 16760 onChange, 16761 layoutBlockSupport = {} 16762 }) { 16763 const { allowSizingOnChildren = false } = layoutBlockSupport; 16764 const showColumnsControl = true; 16765 const showMinWidthControl = !layout?.isManualPlacement || window.__experimentalEnableGridInteractivity; 16766 return /* @__PURE__ */ (0, import_jsx_runtime130.jsxs)(import_jsx_runtime130.Fragment, { children: [ 16767 window.__experimentalEnableGridInteractivity && /* @__PURE__ */ (0, import_jsx_runtime130.jsx)( 16768 GridLayoutTypeControl, 16769 { 16770 layout, 16771 onChange 16772 } 16773 ), 16774 /* @__PURE__ */ (0, import_jsx_runtime130.jsxs)(import_components15.__experimentalVStack, { spacing: 4, children: [ 16775 showColumnsControl && /* @__PURE__ */ (0, import_jsx_runtime130.jsx)( 16776 GridLayoutColumnsAndRowsControl, 16777 { 16778 layout, 16779 onChange, 16780 allowSizingOnChildren 16781 } 16782 ), 16783 showMinWidthControl && /* @__PURE__ */ (0, import_jsx_runtime130.jsx)( 16784 GridLayoutMinimumWidthControl, 16785 { 16786 layout, 16787 onChange 16788 } 16789 ) 16790 ] }) 16791 ] }); 16792 }, 16793 toolBarControls: function GridLayoutToolbarControls() { 16794 return null; 16795 }, 16796 getLayoutStyle: function getLayoutStyle4({ 16797 selector: selector3, 16798 layout, 16799 style, 16800 blockName, 16801 hasBlockGapSupport, 16802 layoutDefinitions = LAYOUT_DEFINITIONS 16803 }) { 16804 const { 16805 minimumColumnWidth = null, 16806 columnCount = null, 16807 rowCount = null 16808 } = layout; 16809 if (true) { 16810 if (minimumColumnWidth && typeof minimumColumnWidth !== "string") { 16811 throw new Error("minimumColumnWidth must be a string"); 16812 } 16813 if (columnCount && typeof columnCount !== "number") { 16814 throw new Error("columnCount must be a number"); 16815 } 16816 if (rowCount && typeof rowCount !== "number") { 16817 throw new Error("rowCount must be a number"); 16818 } 16819 } 16820 const blockGapValue = style?.spacing?.blockGap && !shouldSkipSerialization(blockName, "spacing", "blockGap") ? getGapCSSValue(style?.spacing?.blockGap, "0.5em") : void 0; 16821 let output = ""; 16822 const rules = []; 16823 if (minimumColumnWidth && columnCount > 0) { 16824 const maxValue = `max($minimumColumnWidth}, ( 100% - ($blockGapValue || "1.2rem"}*$columnCount - 1}) ) / $columnCount})`; 16825 rules.push( 16826 `grid-template-columns: repeat(auto-fill, minmax($maxValue}, 1fr))`, 16827 `container-type: inline-size` 16828 ); 16829 if (rowCount) { 16830 rules.push( 16831 `grid-template-rows: repeat($rowCount}, minmax(1rem, auto))` 16832 ); 16833 } 16834 } else if (columnCount) { 16835 rules.push( 16836 `grid-template-columns: repeat($columnCount}, minmax(0, 1fr))` 16837 ); 16838 if (rowCount) { 16839 rules.push( 16840 `grid-template-rows: repeat($rowCount}, minmax(1rem, auto))` 16841 ); 16842 } 16843 } else { 16844 rules.push( 16845 `grid-template-columns: repeat(auto-fill, minmax(min($minimumColumnWidth || "12rem"}, 100%), 1fr))`, 16846 "container-type: inline-size" 16847 ); 16848 } 16849 if (rules.length) { 16850 output = `$appendSelectors(selector3)} { $rules.join( 16851 "; " 16852 )}; }`; 16853 } 16854 if (hasBlockGapSupport && blockGapValue) { 16855 output += getBlockGapCSS( 16856 selector3, 16857 layoutDefinitions, 16858 "grid", 16859 blockGapValue 16860 ); 16861 } 16862 return output; 16863 }, 16864 getOrientation() { 16865 return "horizontal"; 16866 }, 16867 getAlignments() { 16868 return []; 16869 } 16870 }; 16871 function GridLayoutMinimumWidthControl({ layout, onChange }) { 16872 const { minimumColumnWidth, columnCount, isManualPlacement } = layout; 16873 const defaultValue = isManualPlacement || columnCount ? null : "12rem"; 16874 const value = minimumColumnWidth || defaultValue; 16875 const [quantity, unit = "rem"] = (0, import_components15.__experimentalParseQuantityAndUnitFromRawValue)(value); 16876 const handleSliderChange = (next) => { 16877 onChange({ 16878 ...layout, 16879 minimumColumnWidth: [next, unit].join("") 16880 }); 16881 }; 16882 const handleUnitChange = (newUnit) => { 16883 let newValue; 16884 if (["em", "rem"].includes(newUnit) && unit === "px") { 16885 newValue = (quantity / 16).toFixed(2) + newUnit; 16886 } else if (["em", "rem"].includes(unit) && newUnit === "px") { 16887 newValue = Math.round(quantity * 16) + newUnit; 16888 } 16889 onChange({ 16890 ...layout, 16891 minimumColumnWidth: newValue 16892 }); 16893 }; 16894 return /* @__PURE__ */ (0, import_jsx_runtime130.jsxs)("fieldset", { className: "block-editor-hooks__grid-layout-minimum-width-control", children: [ 16895 /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(import_components15.BaseControl.VisualLabel, { as: "legend", children: (0, import_i18n14.__)("Min. column width") }), 16896 /* @__PURE__ */ (0, import_jsx_runtime130.jsxs)(import_components15.Flex, { gap: 4, children: [ 16897 /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(import_components15.FlexItem, { isBlock: true, children: /* @__PURE__ */ (0, import_jsx_runtime130.jsx)( 16898 import_components15.__experimentalUnitControl, 16899 { 16900 size: "__unstable-large", 16901 onChange: (newValue) => { 16902 onChange({ 16903 ...layout, 16904 minimumColumnWidth: newValue === "" ? void 0 : newValue 16905 }); 16906 }, 16907 onUnitChange: handleUnitChange, 16908 value, 16909 units, 16910 min: 0, 16911 label: (0, import_i18n14.__)("Minimum column width"), 16912 hideLabelFromVision: true 16913 } 16914 ) }), 16915 /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(import_components15.FlexItem, { isBlock: true, children: /* @__PURE__ */ (0, import_jsx_runtime130.jsx)( 16916 import_components15.RangeControl, 16917 { 16918 __next40pxDefaultSize: true, 16919 onChange: handleSliderChange, 16920 value: quantity || 0, 16921 min: 0, 16922 max: RANGE_CONTROL_MAX_VALUES[unit] || 600, 16923 withInputField: false, 16924 label: (0, import_i18n14.__)("Minimum column width"), 16925 hideLabelFromVision: true 16926 } 16927 ) }) 16928 ] }), 16929 /* @__PURE__ */ (0, import_jsx_runtime130.jsx)("p", { className: "components-base-control__help", children: (0, import_i18n14.__)( 16930 "Columns will wrap to fewer per row when they can no longer maintain the minimum width." 16931 ) }) 16932 ] }); 16933 } 16934 function GridLayoutColumnsAndRowsControl({ 16935 layout, 16936 onChange, 16937 allowSizingOnChildren 16938 }) { 16939 const defaultColumnCount = void 0; 16940 const { 16941 columnCount = defaultColumnCount, 16942 rowCount, 16943 isManualPlacement 16944 } = layout; 16945 return /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(import_jsx_runtime130.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime130.jsxs)("fieldset", { className: "block-editor-hooks__grid-layout-columns-and-rows-controls", children: [ 16946 !isManualPlacement && /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(import_components15.BaseControl.VisualLabel, { as: "legend", children: (0, import_i18n14.__)("Max. columns") }), 16947 /* @__PURE__ */ (0, import_jsx_runtime130.jsxs)(import_components15.Flex, { gap: 4, children: [ 16948 /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(import_components15.FlexItem, { isBlock: true, children: /* @__PURE__ */ (0, import_jsx_runtime130.jsx)( 16949 import_components15.__experimentalNumberControl, 16950 { 16951 size: "__unstable-large", 16952 onChange: (value) => { 16953 const defaultNewColumnCount = isManualPlacement ? 1 : void 0; 16954 const newColumnCount = value === "" || value === "0" ? defaultNewColumnCount : parseInt(value, 10); 16955 onChange({ 16956 ...layout, 16957 columnCount: newColumnCount 16958 }); 16959 }, 16960 value: columnCount, 16961 min: 1, 16962 label: (0, import_i18n14.__)("Columns"), 16963 hideLabelFromVision: !isManualPlacement 16964 } 16965 ) }), 16966 /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(import_components15.FlexItem, { isBlock: true, children: allowSizingOnChildren && isManualPlacement ? /* @__PURE__ */ (0, import_jsx_runtime130.jsx)( 16967 import_components15.__experimentalNumberControl, 16968 { 16969 size: "__unstable-large", 16970 onChange: (value) => { 16971 const newRowCount = value === "" || value === "0" ? 1 : parseInt(value, 10); 16972 onChange({ 16973 ...layout, 16974 rowCount: newRowCount 16975 }); 16976 }, 16977 value: rowCount, 16978 min: 1, 16979 label: (0, import_i18n14.__)("Rows") 16980 } 16981 ) : /* @__PURE__ */ (0, import_jsx_runtime130.jsx)( 16982 import_components15.RangeControl, 16983 { 16984 __next40pxDefaultSize: true, 16985 value: columnCount ?? 1, 16986 onChange: (value) => onChange({ 16987 ...layout, 16988 columnCount: value === "" || value === "0" ? 1 : value 16989 }), 16990 min: 1, 16991 max: 16, 16992 withInputField: false, 16993 label: (0, import_i18n14.__)("Columns"), 16994 hideLabelFromVision: true 16995 } 16996 ) }) 16997 ] }) 16998 ] }) }); 16999 } 17000 function GridLayoutTypeControl({ layout, onChange }) { 17001 const { columnCount, rowCount, minimumColumnWidth, isManualPlacement } = layout; 17002 const [tempColumnCount, setTempColumnCount] = (0, import_element16.useState)( 17003 columnCount || 3 17004 ); 17005 const [tempRowCount, setTempRowCount] = (0, import_element16.useState)(rowCount); 17006 const [tempMinimumColumnWidth, setTempMinimumColumnWidth] = (0, import_element16.useState)( 17007 minimumColumnWidth || "12rem" 17008 ); 17009 const gridPlacement = isManualPlacement ? "manual" : "auto"; 17010 const onChangeType = (value) => { 17011 if (value === "manual") { 17012 setTempMinimumColumnWidth(minimumColumnWidth || "12rem"); 17013 } else { 17014 setTempColumnCount(columnCount || 3); 17015 setTempRowCount(rowCount); 17016 } 17017 onChange({ 17018 ...layout, 17019 columnCount: value === "manual" ? tempColumnCount : tempColumnCount, 17020 rowCount: value === "manual" ? tempRowCount : void 0, 17021 isManualPlacement: value === "manual" ? true : void 0, 17022 minimumColumnWidth: value === "auto" ? tempMinimumColumnWidth : null 17023 }); 17024 }; 17025 const helpText2 = gridPlacement === "manual" ? (0, import_i18n14.__)( 17026 "Grid items can be manually placed in any position on the grid." 17027 ) : (0, import_i18n14.__)( 17028 "Grid items are placed automatically depending on their order." 17029 ); 17030 return /* @__PURE__ */ (0, import_jsx_runtime130.jsxs)( 17031 import_components15.__experimentalToggleGroupControl, 17032 { 17033 __next40pxDefaultSize: true, 17034 label: (0, import_i18n14.__)("Grid item position"), 17035 value: gridPlacement, 17036 onChange: onChangeType, 17037 isBlock: true, 17038 help: helpText2, 17039 children: [ 17040 /* @__PURE__ */ (0, import_jsx_runtime130.jsx)( 17041 import_components15.__experimentalToggleGroupControlOption, 17042 { 17043 value: "auto", 17044 label: (0, import_i18n14.__)("Auto") 17045 }, 17046 "auto" 17047 ), 17048 /* @__PURE__ */ (0, import_jsx_runtime130.jsx)( 17049 import_components15.__experimentalToggleGroupControlOption, 17050 { 17051 value: "manual", 17052 label: (0, import_i18n14.__)("Manual") 17053 }, 17054 "manual" 17055 ) 17056 ] 17057 } 17058 ); 17059 } 17060 17061 // packages/block-editor/build-module/layouts/index.js 17062 var layoutTypes = [flow_default, flex_default, constrained_default, grid_default2]; 17063 function getLayoutType(name = "default") { 17064 return layoutTypes.find((layoutType) => layoutType.name === name); 17065 } 17066 function getLayoutTypes() { 17067 return layoutTypes; 17068 } 17069 17070 // packages/block-editor/build-module/components/block-list/layout.js 17071 var import_jsx_runtime131 = __toESM(require_jsx_runtime()); 17072 var defaultLayout = { type: "default" }; 17073 var Layout = (0, import_element17.createContext)(defaultLayout); 17074 Layout.displayName = "BlockLayoutContext"; 17075 var LayoutProvider = Layout.Provider; 17076 function useLayout() { 17077 return (0, import_element17.useContext)(Layout); 17078 } 17079 function LayoutStyle({ layout = {}, css, ...props }) { 17080 const layoutType = getLayoutType(layout.type); 17081 const [blockGapSupport] = useSettings("spacing.blockGap"); 17082 const hasBlockGapSupport = blockGapSupport !== null; 17083 if (layoutType) { 17084 if (css) { 17085 return /* @__PURE__ */ (0, import_jsx_runtime131.jsx)("style", { children: css }); 17086 } 17087 const layoutStyle = layoutType.getLayoutStyle?.({ 17088 hasBlockGapSupport, 17089 layout, 17090 ...props 17091 }); 17092 if (layoutStyle) { 17093 return /* @__PURE__ */ (0, import_jsx_runtime131.jsx)("style", { children: layoutStyle }); 17094 } 17095 } 17096 return null; 17097 } 17098 17099 // packages/block-editor/build-module/components/block-alignment-control/use-available-alignments.js 17100 var EMPTY_ARRAY4 = []; 17101 var DEFAULT_CONTROLS = ["none", "left", "center", "right", "wide", "full"]; 17102 var WIDE_CONTROLS = ["wide", "full"]; 17103 function useAvailableAlignments(controls = DEFAULT_CONTROLS) { 17104 if (!controls.includes("none")) { 17105 controls = ["none", ...controls]; 17106 } 17107 const isNoneOnly = controls.length === 1 && controls[0] === "none"; 17108 const [wideControlsEnabled, themeSupportsLayout, isBlockBasedTheme] = (0, import_data11.useSelect)( 17109 (select3) => { 17110 if (isNoneOnly) { 17111 return [false, false, false]; 17112 } 17113 const settings2 = select3(store).getSettings(); 17114 return [ 17115 settings2.alignWide ?? false, 17116 settings2.supportsLayout, 17117 settings2.__unstableIsBlockBasedTheme 17118 ]; 17119 }, 17120 [isNoneOnly] 17121 ); 17122 const layout = useLayout(); 17123 if (isNoneOnly) { 17124 return EMPTY_ARRAY4; 17125 } 17126 const layoutType = getLayoutType(layout?.type); 17127 if (themeSupportsLayout) { 17128 const layoutAlignments = layoutType.getAlignments( 17129 layout, 17130 isBlockBasedTheme 17131 ); 17132 const alignments2 = layoutAlignments.filter( 17133 (alignment) => controls.includes(alignment.name) 17134 ); 17135 if (alignments2.length === 1 && alignments2[0].name === "none") { 17136 return EMPTY_ARRAY4; 17137 } 17138 return alignments2; 17139 } 17140 if (layoutType.name !== "default" && layoutType.name !== "constrained") { 17141 return EMPTY_ARRAY4; 17142 } 17143 const alignments = controls.filter((control) => { 17144 if (layout.alignments) { 17145 return layout.alignments.includes(control); 17146 } 17147 if (!wideControlsEnabled && WIDE_CONTROLS.includes(control)) { 17148 return false; 17149 } 17150 return DEFAULT_CONTROLS.includes(control); 17151 }).map((name) => ({ name })); 17152 if (alignments.length === 1 && alignments[0].name === "none") { 17153 return EMPTY_ARRAY4; 17154 } 17155 return alignments; 17156 } 17157 17158 // packages/block-editor/build-module/components/block-alignment-control/constants.js 17159 var import_i18n15 = __toESM(require_i18n()); 17160 var BLOCK_ALIGNMENTS_CONTROLS = { 17161 none: { 17162 icon: align_none_default, 17163 title: (0, import_i18n15._x)("None", "Alignment option") 17164 }, 17165 left: { 17166 icon: position_left_default, 17167 title: (0, import_i18n15.__)("Align left") 17168 }, 17169 center: { 17170 icon: position_center_default, 17171 title: (0, import_i18n15.__)("Align center") 17172 }, 17173 right: { 17174 icon: position_right_default, 17175 title: (0, import_i18n15.__)("Align right") 17176 }, 17177 wide: { 17178 icon: stretch_wide_default, 17179 title: (0, import_i18n15.__)("Wide width") 17180 }, 17181 full: { 17182 icon: stretch_full_width_default, 17183 title: (0, import_i18n15.__)("Full width") 17184 } 17185 }; 17186 var DEFAULT_CONTROL = "none"; 17187 17188 // packages/block-editor/build-module/components/block-alignment-control/ui.js 17189 var import_jsx_runtime132 = __toESM(require_jsx_runtime()); 17190 function BlockAlignmentUI({ 17191 value, 17192 onChange, 17193 controls, 17194 isToolbar, 17195 isCollapsed: isCollapsed3 = true 17196 }) { 17197 const enabledControls = useAvailableAlignments(controls); 17198 const hasEnabledControls = !!enabledControls.length; 17199 if (!hasEnabledControls) { 17200 return null; 17201 } 17202 function onChangeAlignment(align) { 17203 onChange([value, "none"].includes(align) ? void 0 : align); 17204 } 17205 const activeAlignmentControl = BLOCK_ALIGNMENTS_CONTROLS[value]; 17206 const defaultAlignmentControl = BLOCK_ALIGNMENTS_CONTROLS[DEFAULT_CONTROL]; 17207 const UIComponent = isToolbar ? import_components16.ToolbarGroup : import_components16.ToolbarDropdownMenu; 17208 const commonProps = { 17209 icon: activeAlignmentControl ? activeAlignmentControl.icon : defaultAlignmentControl.icon, 17210 label: (0, import_i18n16.__)("Align") 17211 }; 17212 const extraProps = isToolbar ? { 17213 isCollapsed: isCollapsed3, 17214 controls: enabledControls.map(({ name: controlName }) => { 17215 return { 17216 ...BLOCK_ALIGNMENTS_CONTROLS[controlName], 17217 isActive: value === controlName || !value && controlName === "none", 17218 role: isCollapsed3 ? "menuitemradio" : void 0, 17219 onClick: () => onChangeAlignment(controlName) 17220 }; 17221 }) 17222 } : { 17223 toggleProps: { description: (0, import_i18n16.__)("Change alignment") }, 17224 children: ({ onClose }) => { 17225 return /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(import_jsx_runtime132.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(import_components16.MenuGroup, { className: "block-editor-block-alignment-control__menu-group", children: enabledControls.map( 17226 ({ name: controlName, info }) => { 17227 const { icon, title } = BLOCK_ALIGNMENTS_CONTROLS[controlName]; 17228 const isSelected = controlName === value || !value && controlName === "none"; 17229 return /* @__PURE__ */ (0, import_jsx_runtime132.jsx)( 17230 import_components16.MenuItem, 17231 { 17232 icon, 17233 iconPosition: "left", 17234 className: clsx_default( 17235 "components-dropdown-menu__menu-item", 17236 { 17237 "is-active": isSelected 17238 } 17239 ), 17240 isSelected, 17241 onClick: () => { 17242 onChangeAlignment( 17243 controlName 17244 ); 17245 onClose(); 17246 }, 17247 role: "menuitemradio", 17248 info, 17249 children: title 17250 }, 17251 controlName 17252 ); 17253 } 17254 ) }) }); 17255 } 17256 }; 17257 return /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(UIComponent, { ...commonProps, ...extraProps }); 17258 } 17259 var ui_default2 = BlockAlignmentUI; 17260 17261 // packages/block-editor/build-module/components/block-alignment-control/index.js 17262 var import_jsx_runtime133 = __toESM(require_jsx_runtime()); 17263 var BlockAlignmentControl = (props) => { 17264 return /* @__PURE__ */ (0, import_jsx_runtime133.jsx)(ui_default2, { ...props, isToolbar: false }); 17265 }; 17266 var BlockAlignmentToolbar = (props) => { 17267 return /* @__PURE__ */ (0, import_jsx_runtime133.jsx)(ui_default2, { ...props, isToolbar: true }); 17268 }; 17269 17270 // packages/block-editor/build-module/components/block-bindings/attribute-control.js 17271 var import_es63 = __toESM(require_es6()); 17272 var import_i18n17 = __toESM(require_i18n()); 17273 var import_blocks14 = __toESM(require_blocks()); 17274 var import_components18 = __toESM(require_components()); 17275 var import_data14 = __toESM(require_data()); 17276 var import_element19 = __toESM(require_element()); 17277 var import_compose5 = __toESM(require_compose()); 17278 17279 // packages/block-editor/build-module/components/block-bindings/source-fields-list.js 17280 var import_es62 = __toESM(require_es6()); 17281 var import_blocks13 = __toESM(require_blocks()); 17282 var import_components17 = __toESM(require_components()); 17283 var import_data13 = __toESM(require_data()); 17284 var import_element18 = __toESM(require_element()); 17285 var import_compose4 = __toESM(require_compose()); 17286 17287 // packages/block-editor/build-module/components/block-bindings/use-block-bindings-utils.js 17288 var import_data12 = __toESM(require_data()); 17289 function isObjectEmpty(object) { 17290 return !object || Object.keys(object).length === 0; 17291 } 17292 function useBlockBindingsUtils(clientId) { 17293 const { clientId: contextClientId } = useBlockEditContext(); 17294 const blockClientId = clientId || contextClientId; 17295 const { updateBlockAttributes: updateBlockAttributes2 } = (0, import_data12.useDispatch)(store); 17296 const { getBlockAttributes: getBlockAttributes3 } = (0, import_data12.useRegistry)().select(store); 17297 const updateBlockBindings = (bindings) => { 17298 const { metadata: { bindings: currentBindings, ...metadata } = {} } = getBlockAttributes3(blockClientId); 17299 const newBindings = { ...currentBindings }; 17300 Object.entries(bindings).forEach(([attribute, binding]) => { 17301 if (!binding && newBindings[attribute]) { 17302 delete newBindings[attribute]; 17303 return; 17304 } 17305 newBindings[attribute] = binding; 17306 }); 17307 const newMetadata = { 17308 ...metadata, 17309 bindings: newBindings 17310 }; 17311 if (isObjectEmpty(newMetadata.bindings)) { 17312 delete newMetadata.bindings; 17313 } 17314 updateBlockAttributes2(blockClientId, { 17315 metadata: isObjectEmpty(newMetadata) ? void 0 : newMetadata 17316 }); 17317 }; 17318 const removeAllBlockBindings = () => { 17319 const { metadata: { bindings, ...metadata } = {} } = getBlockAttributes3(blockClientId); 17320 updateBlockAttributes2(blockClientId, { 17321 metadata: isObjectEmpty(metadata) ? void 0 : metadata 17322 }); 17323 }; 17324 return { updateBlockBindings, removeAllBlockBindings }; 17325 } 17326 17327 // packages/block-editor/build-module/components/block-bindings/source-fields-list.js 17328 var import_jsx_runtime134 = __toESM(require_jsx_runtime()); 17329 var { Menu } = unlock(import_components17.privateApis); 17330 function BlockBindingsSourceFieldsListItem({ 17331 args, 17332 attribute, 17333 field, 17334 source, 17335 sourceKey 17336 }) { 17337 const itemBindings = (0, import_element18.useMemo)( 17338 () => ({ 17339 source: sourceKey, 17340 args: field.args || { 17341 key: field.key 17342 } 17343 }), 17344 [field.args, field.key, sourceKey] 17345 ); 17346 const blockContext = (0, import_element18.useContext)(block_context_default); 17347 const values = (0, import_data13.useSelect)( 17348 (select3) => source.getValues({ 17349 select: select3, 17350 context: blockContext, 17351 bindings: { 17352 [attribute]: itemBindings 17353 } 17354 }), 17355 [attribute, blockContext, itemBindings, source] 17356 ); 17357 const { updateBlockBindings } = useBlockBindingsUtils(); 17358 return /* @__PURE__ */ (0, import_jsx_runtime134.jsxs)( 17359 Menu.CheckboxItem, 17360 { 17361 onChange: () => { 17362 const isCurrentlySelected = (0, import_es62.default)(args, field.args) ?? // Deprecate key dependency in 7.0. 17363 field.key === args?.key; 17364 if (isCurrentlySelected) { 17365 updateBlockBindings({ 17366 [attribute]: void 0 17367 }); 17368 } else { 17369 updateBlockBindings({ 17370 [attribute]: itemBindings 17371 }); 17372 } 17373 }, 17374 name: attribute + "-binding", 17375 value: values[attribute], 17376 checked: (0, import_es62.default)(args, field.args) ?? // Deprecate key dependency in 7.0. 17377 field.key === args?.key, 17378 children: [ 17379 /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(Menu.ItemLabel, { children: field.label }), 17380 /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(Menu.ItemHelpText, { children: values[attribute] }) 17381 ] 17382 } 17383 ); 17384 } 17385 function BlockBindingsSourceFieldsList({ 17386 args, 17387 attribute, 17388 sourceKey, 17389 fields 17390 }) { 17391 const isMobile = (0, import_compose4.useViewportMatch)("medium", "<"); 17392 if (!fields || fields.length === 0) { 17393 return null; 17394 } 17395 const source = (0, import_blocks13.getBlockBindingsSource)(sourceKey); 17396 return /* @__PURE__ */ (0, import_jsx_runtime134.jsxs)( 17397 Menu, 17398 { 17399 placement: isMobile ? "bottom-start" : "left-start", 17400 children: [ 17401 /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(Menu.SubmenuTriggerItem, { children: /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(Menu.ItemLabel, { children: source.label }) }), 17402 /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(Menu.Popover, { gutter: 8, children: /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(Menu.Group, { children: fields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime134.jsx)( 17403 BlockBindingsSourceFieldsListItem, 17404 { 17405 args, 17406 attribute, 17407 field, 17408 source, 17409 sourceKey 17410 }, 17411 sourceKey + JSON.stringify(field.args) || field.key 17412 )) }) }) 17413 ] 17414 }, 17415 sourceKey 17416 ); 17417 } 17418 17419 // packages/block-editor/build-module/components/block-bindings/attribute-control.js 17420 var import_jsx_runtime135 = __toESM(require_jsx_runtime()); 17421 var { Menu: Menu2 } = unlock(import_components18.privateApis); 17422 function BlockBindingsAttributeControl({ 17423 attribute, 17424 binding, 17425 blockName 17426 }) { 17427 const { updateBlockBindings } = useBlockBindingsUtils(); 17428 const isMobile = (0, import_compose5.useViewportMatch)("medium", "<"); 17429 const blockContext = (0, import_element19.useContext)(block_context_default); 17430 const compatibleFields = (0, import_data14.useSelect)( 17431 (select3) => { 17432 const { 17433 getAllBlockBindingsSources, 17434 getBlockBindingsSourceFieldsList, 17435 getBlockType: getBlockType21 17436 } = unlock(select3(import_blocks14.store)); 17437 const _attributeType = getBlockType21(blockName).attributes?.[attribute]?.type; 17438 const attributeType = _attributeType === "rich-text" ? "string" : _attributeType; 17439 const sourceFields = {}; 17440 Object.entries(getAllBlockBindingsSources()).forEach( 17441 ([sourceName, source2]) => { 17442 const fieldsList = getBlockBindingsSourceFieldsList( 17443 source2, 17444 blockContext 17445 ); 17446 if (!fieldsList?.length) { 17447 return; 17448 } 17449 const compatibleFieldsList = fieldsList.filter( 17450 (field) => field.type === attributeType 17451 ); 17452 if (compatibleFieldsList.length) { 17453 sourceFields[sourceName] = compatibleFieldsList; 17454 } 17455 } 17456 ); 17457 return sourceFields; 17458 }, 17459 [attribute, blockName, blockContext] 17460 ); 17461 const { canUpdateBlockBindings } = (0, import_data14.useSelect)((select3) => ({ 17462 canUpdateBlockBindings: select3(store).getSettings().canUpdateBlockBindings 17463 })); 17464 const hasCompatibleFields = Object.keys(compatibleFields).length > 0; 17465 const isAttributeReadOnly = !canUpdateBlockBindings || !hasCompatibleFields; 17466 const { source: boundSourceName, args } = binding || {}; 17467 const source = (0, import_blocks14.getBlockBindingsSource)(boundSourceName); 17468 let displayText; 17469 let isValid2 = true; 17470 if (binding === void 0) { 17471 if (!hasCompatibleFields) { 17472 displayText = (0, import_i18n17.__)("No sources available"); 17473 } else { 17474 displayText = (0, import_i18n17.__)("Not connected"); 17475 } 17476 isValid2 = true; 17477 } else if (!source) { 17478 isValid2 = false; 17479 displayText = (0, import_i18n17.__)("Source not registered"); 17480 } else { 17481 displayText = compatibleFields?.[boundSourceName]?.find( 17482 (field) => (0, import_es63.default)(field.args, args) 17483 )?.label || source?.label || boundSourceName; 17484 } 17485 return /* @__PURE__ */ (0, import_jsx_runtime135.jsx)( 17486 import_components18.__experimentalToolsPanelItem, 17487 { 17488 hasValue: () => !!binding, 17489 label: attribute, 17490 onDeselect: !!hasCompatibleFields && (() => { 17491 updateBlockBindings({ 17492 [attribute]: void 0 17493 }); 17494 }), 17495 children: /* @__PURE__ */ (0, import_jsx_runtime135.jsxs)(Menu2, { placement: isMobile ? "bottom-start" : "left-start", children: [ 17496 /* @__PURE__ */ (0, import_jsx_runtime135.jsx)( 17497 Menu2.TriggerButton, 17498 { 17499 render: /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(import_components18.__experimentalItem, {}), 17500 disabled: !hasCompatibleFields, 17501 children: /* @__PURE__ */ (0, import_jsx_runtime135.jsxs)( 17502 import_components18.__experimentalVStack, 17503 { 17504 className: "block-editor-bindings__item", 17505 spacing: 0, 17506 children: [ 17507 /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(import_components18.__experimentalText, { truncate: true, children: attribute }), 17508 /* @__PURE__ */ (0, import_jsx_runtime135.jsx)( 17509 import_components18.__experimentalText, 17510 { 17511 truncate: true, 17512 variant: isValid2 ? "muted" : void 0, 17513 isDestructive: !isValid2, 17514 children: displayText 17515 } 17516 ) 17517 ] 17518 } 17519 ) 17520 } 17521 ), 17522 !isAttributeReadOnly && /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(Menu2.Popover, { gutter: isMobile ? 8 : 36, children: /* @__PURE__ */ (0, import_jsx_runtime135.jsx)( 17523 Menu2, 17524 { 17525 placement: isMobile ? "bottom-start" : "left-start", 17526 children: Object.entries(compatibleFields).map( 17527 ([sourceKey, fields]) => /* @__PURE__ */ (0, import_jsx_runtime135.jsx)( 17528 BlockBindingsSourceFieldsList, 17529 { 17530 args: binding?.args, 17531 attribute, 17532 sourceKey, 17533 fields 17534 }, 17535 sourceKey 17536 ) 17537 ) 17538 } 17539 ) }) 17540 ] }) 17541 } 17542 ); 17543 } 17544 17545 // packages/block-editor/build-module/components/block-full-height-alignment-control/index.js 17546 var import_i18n18 = __toESM(require_i18n()); 17547 var import_components19 = __toESM(require_components()); 17548 var import_jsx_runtime136 = __toESM(require_jsx_runtime()); 17549 function BlockFullHeightAlignmentControl({ 17550 isActive, 17551 label = (0, import_i18n18.__)("Full height"), 17552 onToggle, 17553 isDisabled 17554 }) { 17555 return /* @__PURE__ */ (0, import_jsx_runtime136.jsx)( 17556 import_components19.ToolbarButton, 17557 { 17558 isActive, 17559 icon: fullscreen_default, 17560 label, 17561 onClick: () => onToggle(!isActive), 17562 disabled: isDisabled 17563 } 17564 ); 17565 } 17566 var block_full_height_alignment_control_default = BlockFullHeightAlignmentControl; 17567 17568 // packages/block-editor/build-module/components/block-alignment-matrix-control/index.js 17569 var import_i18n19 = __toESM(require_i18n()); 17570 var import_keycodes = __toESM(require_keycodes()); 17571 var import_components20 = __toESM(require_components()); 17572 var import_jsx_runtime137 = __toESM(require_jsx_runtime()); 17573 var noop2 = () => { 17574 }; 17575 function BlockAlignmentMatrixControl(props) { 17576 const { 17577 label = (0, import_i18n19.__)("Change matrix alignment"), 17578 onChange = noop2, 17579 value = "center", 17580 isDisabled 17581 } = props; 17582 const icon = /* @__PURE__ */ (0, import_jsx_runtime137.jsx)(import_components20.AlignmentMatrixControl.Icon, { value }); 17583 return /* @__PURE__ */ (0, import_jsx_runtime137.jsx)( 17584 import_components20.Dropdown, 17585 { 17586 popoverProps: { placement: "bottom-start" }, 17587 renderToggle: ({ onToggle, isOpen }) => { 17588 const openOnArrowDown = (event) => { 17589 if (!isOpen && event.keyCode === import_keycodes.DOWN) { 17590 event.preventDefault(); 17591 onToggle(); 17592 } 17593 }; 17594 return /* @__PURE__ */ (0, import_jsx_runtime137.jsx)( 17595 import_components20.ToolbarButton, 17596 { 17597 onClick: onToggle, 17598 "aria-haspopup": "true", 17599 "aria-expanded": isOpen, 17600 onKeyDown: openOnArrowDown, 17601 label, 17602 icon, 17603 showTooltip: true, 17604 disabled: isDisabled 17605 } 17606 ); 17607 }, 17608 renderContent: () => /* @__PURE__ */ (0, import_jsx_runtime137.jsx)(import_components20.AlignmentMatrixControl, { onChange, value }) 17609 } 17610 ); 17611 } 17612 var block_alignment_matrix_control_default = BlockAlignmentMatrixControl; 17613 17614 // packages/block-editor/build-module/components/block-breadcrumb/index.js 17615 var import_components21 = __toESM(require_components()); 17616 var import_data16 = __toESM(require_data()); 17617 var import_i18n20 = __toESM(require_i18n()); 17618 var import_element22 = __toESM(require_element()); 17619 17620 // packages/block-editor/build-module/components/block-title/use-block-display-title.js 17621 var import_data15 = __toESM(require_data()); 17622 var import_blocks15 = __toESM(require_blocks()); 17623 function useBlockDisplayTitle({ 17624 clientId, 17625 maximumLength, 17626 context 17627 }) { 17628 const blockTitle = (0, import_data15.useSelect)( 17629 (select3) => { 17630 if (!clientId) { 17631 return null; 17632 } 17633 const { getBlockName: getBlockName2, getBlockAttributes: getBlockAttributes3 } = select3(store); 17634 const { getBlockType: getBlockType21, getActiveBlockVariation } = select3(import_blocks15.store); 17635 const blockName = getBlockName2(clientId); 17636 const blockType = getBlockType21(blockName); 17637 if (!blockType) { 17638 return null; 17639 } 17640 const attributes = getBlockAttributes3(clientId); 17641 const label = (0, import_blocks15.__experimentalGetBlockLabel)(blockType, attributes, context); 17642 if (label !== blockType.title) { 17643 return label; 17644 } 17645 const match2 = getActiveBlockVariation(blockName, attributes); 17646 return match2?.title || blockType.title; 17647 }, 17648 [clientId, context] 17649 ); 17650 if (!blockTitle) { 17651 return null; 17652 } 17653 if (maximumLength && maximumLength > 0 && blockTitle.length > maximumLength) { 17654 const omission = "..."; 17655 return blockTitle.slice(0, maximumLength - omission.length) + omission; 17656 } 17657 return blockTitle; 17658 } 17659 17660 // packages/block-editor/build-module/components/block-title/index.js 17661 function BlockTitle({ clientId, maximumLength, context }) { 17662 return useBlockDisplayTitle({ clientId, maximumLength, context }); 17663 } 17664 17665 // packages/block-editor/build-module/components/block-list/use-block-props/use-block-refs.js 17666 var import_element21 = __toESM(require_element()); 17667 var import_compose7 = __toESM(require_compose()); 17668 17669 // packages/block-editor/build-module/components/provider/block-refs-provider.js 17670 var import_element20 = __toESM(require_element()); 17671 var import_compose6 = __toESM(require_compose()); 17672 var import_jsx_runtime138 = __toESM(require_jsx_runtime()); 17673 var BlockRefs = (0, import_element20.createContext)({ refsMap: (0, import_compose6.observableMap)() }); 17674 BlockRefs.displayName = "BlockRefsContext"; 17675 function BlockRefsProvider({ children }) { 17676 const value = (0, import_element20.useMemo)(() => ({ refsMap: (0, import_compose6.observableMap)() }), []); 17677 return /* @__PURE__ */ (0, import_jsx_runtime138.jsx)(BlockRefs.Provider, { value, children }); 17678 } 17679 17680 // packages/block-editor/build-module/components/block-list/use-block-props/use-block-refs.js 17681 function useBlockRefProvider(clientId) { 17682 const { refsMap } = (0, import_element21.useContext)(BlockRefs); 17683 return (0, import_compose7.useRefEffect)( 17684 (element) => { 17685 refsMap.set(clientId, element); 17686 return () => refsMap.delete(clientId); 17687 }, 17688 [clientId] 17689 ); 17690 } 17691 function assignRef(ref, value) { 17692 if (typeof ref === "function") { 17693 ref(value); 17694 } else if (ref) { 17695 ref.current = value; 17696 } 17697 } 17698 function useBlockElementRef(clientId, ref) { 17699 const { refsMap } = (0, import_element21.useContext)(BlockRefs); 17700 (0, import_element21.useLayoutEffect)(() => { 17701 assignRef(ref, refsMap.get(clientId)); 17702 const unsubscribe = refsMap.subscribe( 17703 clientId, 17704 () => assignRef(ref, refsMap.get(clientId)) 17705 ); 17706 return () => { 17707 unsubscribe(); 17708 assignRef(ref, null); 17709 }; 17710 }, [refsMap, clientId, ref]); 17711 } 17712 function useBlockElement(clientId) { 17713 const [blockElement, setBlockElement] = (0, import_element21.useState)(null); 17714 useBlockElementRef(clientId, setBlockElement); 17715 return blockElement; 17716 } 17717 17718 // packages/block-editor/build-module/utils/get-editor-region.js 17719 function getEditorRegion(editor) { 17720 if (!editor) { 17721 return null; 17722 } 17723 const editorCanvas = Array.from( 17724 document.querySelectorAll('iframe[name="editor-canvas"]').values() 17725 ).find((iframe) => { 17726 const iframeDocument = iframe.contentDocument || iframe.contentWindow.document; 17727 return iframeDocument === editor.ownerDocument; 17728 }) ?? editor; 17729 return editorCanvas?.closest('[role="region"]') ?? editorCanvas; 17730 } 17731 17732 // packages/block-editor/build-module/components/block-breadcrumb/index.js 17733 var import_jsx_runtime139 = __toESM(require_jsx_runtime()); 17734 function BlockBreadcrumb({ rootLabelText }) { 17735 const { selectBlock: selectBlock2, clearSelectedBlock: clearSelectedBlock2 } = (0, import_data16.useDispatch)(store); 17736 const { clientId, parents, hasSelection } = (0, import_data16.useSelect)((select3) => { 17737 const { 17738 getSelectionStart: getSelectionStart2, 17739 getSelectedBlockClientId: getSelectedBlockClientId2, 17740 getEnabledBlockParents: getEnabledBlockParents2 17741 } = unlock(select3(store)); 17742 const selectedBlockClientId = getSelectedBlockClientId2(); 17743 return { 17744 parents: getEnabledBlockParents2(selectedBlockClientId), 17745 clientId: selectedBlockClientId, 17746 hasSelection: !!getSelectionStart2().clientId 17747 }; 17748 }, []); 17749 const rootLabel = rootLabelText || (0, import_i18n20._x)("Document", "noun, breadcrumb"); 17750 const blockRef = (0, import_element22.useRef)(); 17751 useBlockElementRef(clientId, blockRef); 17752 return /* @__PURE__ */ (0, import_jsx_runtime139.jsxs)( 17753 "ul", 17754 { 17755 className: "block-editor-block-breadcrumb", 17756 role: "list", 17757 "aria-label": (0, import_i18n20.__)("Block breadcrumb"), 17758 children: [ 17759 /* @__PURE__ */ (0, import_jsx_runtime139.jsxs)( 17760 "li", 17761 { 17762 className: !hasSelection ? "block-editor-block-breadcrumb__current" : void 0, 17763 "aria-current": !hasSelection ? "true" : void 0, 17764 children: [ 17765 hasSelection && /* @__PURE__ */ (0, import_jsx_runtime139.jsx)( 17766 import_components21.Button, 17767 { 17768 size: "small", 17769 className: "block-editor-block-breadcrumb__button", 17770 onClick: () => { 17771 const blockEditor = blockRef.current?.closest( 17772 ".editor-styles-wrapper" 17773 ); 17774 clearSelectedBlock2(); 17775 getEditorRegion(blockEditor)?.focus(); 17776 }, 17777 children: rootLabel 17778 } 17779 ), 17780 !hasSelection && /* @__PURE__ */ (0, import_jsx_runtime139.jsx)("span", { children: rootLabel }), 17781 !!clientId && /* @__PURE__ */ (0, import_jsx_runtime139.jsx)( 17782 icon_default, 17783 { 17784 icon: chevron_right_small_default, 17785 className: "block-editor-block-breadcrumb__separator" 17786 } 17787 ) 17788 ] 17789 } 17790 ), 17791 parents.map((parentClientId) => /* @__PURE__ */ (0, import_jsx_runtime139.jsxs)("li", { children: [ 17792 /* @__PURE__ */ (0, import_jsx_runtime139.jsx)( 17793 import_components21.Button, 17794 { 17795 size: "small", 17796 className: "block-editor-block-breadcrumb__button", 17797 onClick: () => selectBlock2(parentClientId), 17798 children: /* @__PURE__ */ (0, import_jsx_runtime139.jsx)( 17799 BlockTitle, 17800 { 17801 clientId: parentClientId, 17802 maximumLength: 35 17803 } 17804 ) 17805 } 17806 ), 17807 /* @__PURE__ */ (0, import_jsx_runtime139.jsx)( 17808 icon_default, 17809 { 17810 icon: chevron_right_small_default, 17811 className: "block-editor-block-breadcrumb__separator" 17812 } 17813 ) 17814 ] }, parentClientId)), 17815 !!clientId && /* @__PURE__ */ (0, import_jsx_runtime139.jsx)( 17816 "li", 17817 { 17818 className: "block-editor-block-breadcrumb__current", 17819 "aria-current": "true", 17820 children: /* @__PURE__ */ (0, import_jsx_runtime139.jsx)(BlockTitle, { clientId, maximumLength: 35 }) 17821 } 17822 ) 17823 ] 17824 } 17825 ); 17826 } 17827 var block_breadcrumb_default = BlockBreadcrumb; 17828 17829 // packages/block-editor/build-module/components/block-content-overlay/index.js 17830 var import_data17 = __toESM(require_data()); 17831 function useBlockOverlayActive(clientId) { 17832 return (0, import_data17.useSelect)( 17833 (select3) => { 17834 const { __unstableHasActiveBlockOverlayActive: __unstableHasActiveBlockOverlayActive2 } = select3(store); 17835 return __unstableHasActiveBlockOverlayActive2(clientId); 17836 }, 17837 [clientId] 17838 ); 17839 } 17840 17841 // packages/block-editor/build-module/components/block-canvas/index.js 17842 var import_compose66 = __toESM(require_compose()); 17843 var import_element124 = __toESM(require_element()); 17844 var import_data122 = __toESM(require_data()); 17845 17846 // packages/block-editor/build-module/components/block-list/index.js 17847 var import_data75 = __toESM(require_data()); 17848 var import_compose55 = __toESM(require_compose()); 17849 var import_element89 = __toESM(require_element()); 17850 var import_blocks42 = __toESM(require_blocks()); 17851 17852 // packages/block-editor/build-module/components/block-list/block.js 17853 var import_element31 = __toESM(require_element()); 17854 var import_blocks20 = __toESM(require_blocks()); 17855 var import_components24 = __toESM(require_components()); 17856 var import_data25 = __toESM(require_data()); 17857 var import_compose16 = __toESM(require_compose()); 17858 var import_dom7 = __toESM(require_dom()); 17859 17860 // packages/block-editor/build-module/components/block-list/block-invalid-warning.js 17861 var import_i18n22 = __toESM(require_i18n()); 17862 var import_components23 = __toESM(require_components()); 17863 var import_element24 = __toESM(require_element()); 17864 var import_blocks17 = __toESM(require_blocks()); 17865 var import_data18 = __toESM(require_data()); 17866 17867 // packages/block-editor/build-module/components/block-compare/index.js 17868 var import_character = __toESM(require_character()); 17869 var import_i18n21 = __toESM(require_i18n()); 17870 var import_blocks16 = __toESM(require_blocks()); 17871 17872 // packages/block-editor/build-module/components/block-compare/block-view.js 17873 var import_components22 = __toESM(require_components()); 17874 var import_element23 = __toESM(require_element()); 17875 var import_dom = __toESM(require_dom()); 17876 var import_jsx_runtime140 = __toESM(require_jsx_runtime()); 17877 function BlockView({ 17878 title, 17879 rawContent, 17880 renderedContent, 17881 action, 17882 actionText, 17883 className 17884 }) { 17885 return /* @__PURE__ */ (0, import_jsx_runtime140.jsxs)("div", { className, children: [ 17886 /* @__PURE__ */ (0, import_jsx_runtime140.jsxs)("div", { className: "block-editor-block-compare__content", children: [ 17887 /* @__PURE__ */ (0, import_jsx_runtime140.jsx)("h2", { className: "block-editor-block-compare__heading", children: title }), 17888 /* @__PURE__ */ (0, import_jsx_runtime140.jsx)("div", { className: "block-editor-block-compare__html", children: rawContent }), 17889 /* @__PURE__ */ (0, import_jsx_runtime140.jsx)("div", { className: "block-editor-block-compare__preview edit-post-visual-editor", children: /* @__PURE__ */ (0, import_jsx_runtime140.jsx)(import_element23.RawHTML, { children: (0, import_dom.safeHTML)(renderedContent) }) }) 17890 ] }), 17891 /* @__PURE__ */ (0, import_jsx_runtime140.jsx)("div", { className: "block-editor-block-compare__action", children: /* @__PURE__ */ (0, import_jsx_runtime140.jsx)( 17892 import_components22.Button, 17893 { 17894 __next40pxDefaultSize: true, 17895 variant: "secondary", 17896 tabIndex: "0", 17897 onClick: action, 17898 children: actionText 17899 } 17900 ) }) 17901 ] }); 17902 } 17903 17904 // packages/block-editor/build-module/components/block-compare/index.js 17905 var import_jsx_runtime141 = __toESM(require_jsx_runtime()); 17906 function BlockCompare({ 17907 block, 17908 onKeep, 17909 onConvert, 17910 convertor, 17911 convertButtonText 17912 }) { 17913 function getDifference(originalContent, newContent) { 17914 const difference2 = (0, import_character.diffChars)(originalContent, newContent); 17915 return difference2.map((item, pos) => { 17916 const classes = clsx_default({ 17917 "block-editor-block-compare__added": item.added, 17918 "block-editor-block-compare__removed": item.removed 17919 }); 17920 return /* @__PURE__ */ (0, import_jsx_runtime141.jsx)("span", { className: classes, children: item.value }, pos); 17921 }); 17922 } 17923 function getConvertedContent(convertedBlock) { 17924 const newBlocks = Array.isArray(convertedBlock) ? convertedBlock : [convertedBlock]; 17925 const newContent = newBlocks.map( 17926 (item) => (0, import_blocks16.getSaveContent)(item.name, item.attributes, item.innerBlocks) 17927 ); 17928 return newContent.join(""); 17929 } 17930 const converted = getConvertedContent(convertor(block)); 17931 const difference = getDifference(block.originalContent, converted); 17932 return /* @__PURE__ */ (0, import_jsx_runtime141.jsxs)("div", { className: "block-editor-block-compare__wrapper", children: [ 17933 /* @__PURE__ */ (0, import_jsx_runtime141.jsx)( 17934 BlockView, 17935 { 17936 title: (0, import_i18n21.__)("Current"), 17937 className: "block-editor-block-compare__current", 17938 action: onKeep, 17939 actionText: (0, import_i18n21.__)("Convert to HTML"), 17940 rawContent: block.originalContent, 17941 renderedContent: block.originalContent 17942 } 17943 ), 17944 /* @__PURE__ */ (0, import_jsx_runtime141.jsx)( 17945 BlockView, 17946 { 17947 title: (0, import_i18n21.__)("After Conversion"), 17948 className: "block-editor-block-compare__converted", 17949 action: onConvert, 17950 actionText: convertButtonText, 17951 rawContent: difference, 17952 renderedContent: converted 17953 } 17954 ) 17955 ] }); 17956 } 17957 var block_compare_default = BlockCompare; 17958 17959 // packages/block-editor/build-module/components/block-list/block-invalid-warning.js 17960 var import_jsx_runtime142 = __toESM(require_jsx_runtime()); 17961 var blockToBlocks = (block) => (0, import_blocks17.rawHandler)({ 17962 HTML: block.originalContent 17963 }); 17964 function BlockInvalidWarning({ clientId }) { 17965 const { block, canInsertHTMLBlock, canInsertClassicBlock } = (0, import_data18.useSelect)( 17966 (select3) => { 17967 const { canInsertBlockType: canInsertBlockType2, getBlock: getBlock2, getBlockRootClientId: getBlockRootClientId2 } = select3(store); 17968 const rootClientId = getBlockRootClientId2(clientId); 17969 return { 17970 block: getBlock2(clientId), 17971 canInsertHTMLBlock: canInsertBlockType2( 17972 "core/html", 17973 rootClientId 17974 ), 17975 canInsertClassicBlock: canInsertBlockType2( 17976 "core/freeform", 17977 rootClientId 17978 ) 17979 }; 17980 }, 17981 [clientId] 17982 ); 17983 const { replaceBlock: replaceBlock2 } = (0, import_data18.useDispatch)(store); 17984 const [compare2, setCompare] = (0, import_element24.useState)(false); 17985 const onCompareClose = (0, import_element24.useCallback)(() => setCompare(false), []); 17986 const convert = (0, import_element24.useMemo)( 17987 () => ({ 17988 toClassic() { 17989 const classicBlock = (0, import_blocks17.createBlock)("core/freeform", { 17990 content: block.originalContent 17991 }); 17992 return replaceBlock2(block.clientId, classicBlock); 17993 }, 17994 toHTML() { 17995 const htmlBlock = (0, import_blocks17.createBlock)("core/html", { 17996 content: block.originalContent 17997 }); 17998 return replaceBlock2(block.clientId, htmlBlock); 17999 }, 18000 toBlocks() { 18001 const newBlocks = blockToBlocks(block); 18002 return replaceBlock2(block.clientId, newBlocks); 18003 }, 18004 toRecoveredBlock() { 18005 const recoveredBlock = (0, import_blocks17.createBlock)( 18006 block.name, 18007 block.attributes, 18008 block.innerBlocks 18009 ); 18010 return replaceBlock2(block.clientId, recoveredBlock); 18011 } 18012 }), 18013 [block, replaceBlock2] 18014 ); 18015 const secondaryActions = (0, import_element24.useMemo)( 18016 () => [ 18017 { 18018 // translators: Button to fix block content 18019 title: (0, import_i18n22._x)("Resolve", "imperative verb"), 18020 onClick: () => setCompare(true) 18021 }, 18022 canInsertHTMLBlock && { 18023 title: (0, import_i18n22.__)("Convert to HTML"), 18024 onClick: convert.toHTML 18025 }, 18026 canInsertClassicBlock && { 18027 title: (0, import_i18n22.__)("Convert to Classic Block"), 18028 onClick: convert.toClassic 18029 } 18030 ].filter(Boolean), 18031 [canInsertHTMLBlock, canInsertClassicBlock, convert] 18032 ); 18033 return /* @__PURE__ */ (0, import_jsx_runtime142.jsxs)(import_jsx_runtime142.Fragment, { children: [ 18034 /* @__PURE__ */ (0, import_jsx_runtime142.jsx)( 18035 warning_default, 18036 { 18037 actions: [ 18038 /* @__PURE__ */ (0, import_jsx_runtime142.jsx)( 18039 import_components23.Button, 18040 { 18041 __next40pxDefaultSize: true, 18042 onClick: convert.toRecoveredBlock, 18043 variant: "primary", 18044 children: (0, import_i18n22.__)("Attempt recovery") 18045 }, 18046 "recover" 18047 ) 18048 ], 18049 secondaryActions, 18050 children: (0, import_i18n22.__)("Block contains unexpected or invalid content.") 18051 } 18052 ), 18053 compare2 && /* @__PURE__ */ (0, import_jsx_runtime142.jsx)( 18054 import_components23.Modal, 18055 { 18056 title: ( 18057 // translators: Dialog title to fix block content 18058 (0, import_i18n22.__)("Resolve Block") 18059 ), 18060 onRequestClose: onCompareClose, 18061 className: "block-editor-block-compare", 18062 children: /* @__PURE__ */ (0, import_jsx_runtime142.jsx)( 18063 block_compare_default, 18064 { 18065 block, 18066 onKeep: convert.toHTML, 18067 onConvert: convert.toBlocks, 18068 convertor: blockToBlocks, 18069 convertButtonText: (0, import_i18n22.__)("Convert to Blocks") 18070 } 18071 ) 18072 } 18073 ) 18074 ] }); 18075 } 18076 18077 // packages/block-editor/build-module/components/block-list/block-crash-warning.js 18078 var import_i18n23 = __toESM(require_i18n()); 18079 var import_jsx_runtime143 = __toESM(require_jsx_runtime()); 18080 var warning = /* @__PURE__ */ (0, import_jsx_runtime143.jsx)(warning_default, { className: "block-editor-block-list__block-crash-warning", children: (0, import_i18n23.__)("This block has encountered an error and cannot be previewed.") }); 18081 var block_crash_warning_default = () => warning; 18082 18083 // packages/block-editor/build-module/components/block-list/block-crash-boundary.js 18084 var import_element25 = __toESM(require_element()); 18085 var BlockCrashBoundary = class extends import_element25.Component { 18086 constructor() { 18087 super(...arguments); 18088 this.state = { 18089 hasError: false 18090 }; 18091 } 18092 componentDidCatch() { 18093 this.setState({ 18094 hasError: true 18095 }); 18096 } 18097 render() { 18098 if (this.state.hasError) { 18099 return this.props.fallback; 18100 } 18101 return this.props.children; 18102 } 18103 }; 18104 var block_crash_boundary_default = BlockCrashBoundary; 18105 18106 // packages/block-editor/build-module/components/block-list/block-html.js 18107 var import_react_autosize_textarea = __toESM(require_lib()); 18108 var import_element26 = __toESM(require_element()); 18109 var import_data19 = __toESM(require_data()); 18110 var import_blocks18 = __toESM(require_blocks()); 18111 var import_jsx_runtime144 = __toESM(require_jsx_runtime()); 18112 function BlockHTML({ clientId }) { 18113 const [html, setHtml] = (0, import_element26.useState)(""); 18114 const block = (0, import_data19.useSelect)( 18115 (select3) => select3(store).getBlock(clientId), 18116 [clientId] 18117 ); 18118 const { updateBlock: updateBlock2 } = (0, import_data19.useDispatch)(store); 18119 const onChange = () => { 18120 const blockType = (0, import_blocks18.getBlockType)(block.name); 18121 if (!blockType) { 18122 return; 18123 } 18124 const attributes = (0, import_blocks18.getBlockAttributes)( 18125 blockType, 18126 html, 18127 block.attributes 18128 ); 18129 const content = html ? html : (0, import_blocks18.getSaveContent)(blockType, attributes); 18130 const [isValid2] = html ? (0, import_blocks18.validateBlock)({ 18131 ...block, 18132 attributes, 18133 originalContent: content 18134 }) : [true]; 18135 updateBlock2(clientId, { 18136 attributes, 18137 originalContent: content, 18138 isValid: isValid2 18139 }); 18140 if (!html) { 18141 setHtml(content); 18142 } 18143 }; 18144 (0, import_element26.useEffect)(() => { 18145 setHtml((0, import_blocks18.getBlockContent)(block)); 18146 }, [block]); 18147 return /* @__PURE__ */ (0, import_jsx_runtime144.jsx)( 18148 import_react_autosize_textarea.default, 18149 { 18150 className: "block-editor-block-list__block-html-textarea", 18151 value: html, 18152 onBlur: onChange, 18153 onChange: (event) => setHtml(event.target.value) 18154 } 18155 ); 18156 } 18157 var block_html_default = BlockHTML; 18158 18159 // packages/block-editor/build-module/components/block-list/use-block-props/index.js 18160 var import_element30 = __toESM(require_element()); 18161 var import_i18n24 = __toESM(require_i18n()); 18162 var import_blocks19 = __toESM(require_blocks()); 18163 var import_compose15 = __toESM(require_compose()); 18164 var import_warning4 = __toESM(require_warning()); 18165 18166 // node_modules/@react-spring/rafz/dist/react-spring-rafz.esm.js 18167 var updateQueue = makeQueue(); 18168 var raf = (fn) => schedule(fn, updateQueue); 18169 var writeQueue = makeQueue(); 18170 raf.write = (fn) => schedule(fn, writeQueue); 18171 var onStartQueue = makeQueue(); 18172 raf.onStart = (fn) => schedule(fn, onStartQueue); 18173 var onFrameQueue = makeQueue(); 18174 raf.onFrame = (fn) => schedule(fn, onFrameQueue); 18175 var onFinishQueue = makeQueue(); 18176 raf.onFinish = (fn) => schedule(fn, onFinishQueue); 18177 var timeouts = []; 18178 raf.setTimeout = (handler, ms) => { 18179 let time = raf.now() + ms; 18180 let cancel = () => { 18181 let i2 = timeouts.findIndex((t3) => t3.cancel == cancel); 18182 if (~i2) timeouts.splice(i2, 1); 18183 pendingCount -= ~i2 ? 1 : 0; 18184 }; 18185 let timeout = { 18186 time, 18187 handler, 18188 cancel 18189 }; 18190 timeouts.splice(findTimeout(time), 0, timeout); 18191 pendingCount += 1; 18192 start(); 18193 return timeout; 18194 }; 18195 var findTimeout = (time) => ~(~timeouts.findIndex((t3) => t3.time > time) || ~timeouts.length); 18196 raf.cancel = (fn) => { 18197 onStartQueue.delete(fn); 18198 onFrameQueue.delete(fn); 18199 onFinishQueue.delete(fn); 18200 updateQueue.delete(fn); 18201 writeQueue.delete(fn); 18202 }; 18203 raf.sync = (fn) => { 18204 sync = true; 18205 raf.batchedUpdates(fn); 18206 sync = false; 18207 }; 18208 raf.throttle = (fn) => { 18209 let lastArgs; 18210 function queuedFn() { 18211 try { 18212 fn(...lastArgs); 18213 } finally { 18214 lastArgs = null; 18215 } 18216 } 18217 function throttled(...args) { 18218 lastArgs = args; 18219 raf.onStart(queuedFn); 18220 } 18221 throttled.handler = fn; 18222 throttled.cancel = () => { 18223 onStartQueue.delete(queuedFn); 18224 lastArgs = null; 18225 }; 18226 return throttled; 18227 }; 18228 var nativeRaf = typeof window != "undefined" ? window.requestAnimationFrame : () => { 18229 }; 18230 raf.use = (impl) => nativeRaf = impl; 18231 raf.now = typeof performance != "undefined" ? () => performance.now() : Date.now; 18232 raf.batchedUpdates = (fn) => fn(); 18233 raf.catch = console.error; 18234 raf.frameLoop = "always"; 18235 raf.advance = () => { 18236 if (raf.frameLoop !== "demand") { 18237 console.warn("Cannot call the manual advancement of rafz whilst frameLoop is not set as demand"); 18238 } else { 18239 update(); 18240 } 18241 }; 18242 var ts = -1; 18243 var pendingCount = 0; 18244 var sync = false; 18245 function schedule(fn, queue) { 18246 if (sync) { 18247 queue.delete(fn); 18248 fn(0); 18249 } else { 18250 queue.add(fn); 18251 start(); 18252 } 18253 } 18254 function start() { 18255 if (ts < 0) { 18256 ts = 0; 18257 if (raf.frameLoop !== "demand") { 18258 nativeRaf(loop); 18259 } 18260 } 18261 } 18262 function stop() { 18263 ts = -1; 18264 } 18265 function loop() { 18266 if (~ts) { 18267 nativeRaf(loop); 18268 raf.batchedUpdates(update); 18269 } 18270 } 18271 function update() { 18272 let prevTs = ts; 18273 ts = raf.now(); 18274 let count = findTimeout(ts); 18275 if (count) { 18276 eachSafely(timeouts.splice(0, count), (t3) => t3.handler()); 18277 pendingCount -= count; 18278 } 18279 if (!pendingCount) { 18280 stop(); 18281 return; 18282 } 18283 onStartQueue.flush(); 18284 updateQueue.flush(prevTs ? Math.min(64, ts - prevTs) : 16.667); 18285 onFrameQueue.flush(); 18286 writeQueue.flush(); 18287 onFinishQueue.flush(); 18288 } 18289 function makeQueue() { 18290 let next = /* @__PURE__ */ new Set(); 18291 let current = next; 18292 return { 18293 add(fn) { 18294 pendingCount += current == next && !next.has(fn) ? 1 : 0; 18295 next.add(fn); 18296 }, 18297 delete(fn) { 18298 pendingCount -= current == next && next.has(fn) ? 1 : 0; 18299 return next.delete(fn); 18300 }, 18301 flush(arg) { 18302 if (current.size) { 18303 next = /* @__PURE__ */ new Set(); 18304 pendingCount -= current.size; 18305 eachSafely(current, (fn) => fn(arg) && next.add(fn)); 18306 pendingCount += next.size; 18307 current = next; 18308 } 18309 } 18310 }; 18311 } 18312 function eachSafely(values, each2) { 18313 values.forEach((value) => { 18314 try { 18315 each2(value); 18316 } catch (e2) { 18317 raf.catch(e2); 18318 } 18319 }); 18320 } 18321 18322 // node_modules/@react-spring/shared/dist/react-spring-shared.esm.js 18323 var import_react = __toESM(require_react()); 18324 function noop3() { 18325 } 18326 var defineHidden = (obj, key, value) => Object.defineProperty(obj, key, { 18327 value, 18328 writable: true, 18329 configurable: true 18330 }); 18331 var is = { 18332 arr: Array.isArray, 18333 obj: (a2) => !!a2 && a2.constructor.name === "Object", 18334 fun: (a2) => typeof a2 === "function", 18335 str: (a2) => typeof a2 === "string", 18336 num: (a2) => typeof a2 === "number", 18337 und: (a2) => a2 === void 0 18338 }; 18339 function isEqual(a2, b2) { 18340 if (is.arr(a2)) { 18341 if (!is.arr(b2) || a2.length !== b2.length) return false; 18342 for (let i2 = 0; i2 < a2.length; i2++) { 18343 if (a2[i2] !== b2[i2]) return false; 18344 } 18345 return true; 18346 } 18347 return a2 === b2; 18348 } 18349 var each = (obj, fn) => obj.forEach(fn); 18350 function eachProp(obj, fn, ctx2) { 18351 if (is.arr(obj)) { 18352 for (let i2 = 0; i2 < obj.length; i2++) { 18353 fn.call(ctx2, obj[i2], `$i2}`); 18354 } 18355 return; 18356 } 18357 for (const key in obj) { 18358 if (obj.hasOwnProperty(key)) { 18359 fn.call(ctx2, obj[key], key); 18360 } 18361 } 18362 } 18363 var toArray = (a2) => is.und(a2) ? [] : is.arr(a2) ? a2 : [a2]; 18364 function flush(queue, iterator) { 18365 if (queue.size) { 18366 const items = Array.from(queue); 18367 queue.clear(); 18368 each(items, iterator); 18369 } 18370 } 18371 var flushCalls = (queue, ...args) => flush(queue, (fn) => fn(...args)); 18372 var isSSR = () => typeof window === "undefined" || !window.navigator || /ServerSideRendering|^Deno\//.test(window.navigator.userAgent); 18373 var createStringInterpolator$1; 18374 var to; 18375 var colors$1 = null; 18376 var skipAnimation = false; 18377 var willAdvance = noop3; 18378 var assign = (globals2) => { 18379 if (globals2.to) to = globals2.to; 18380 if (globals2.now) raf.now = globals2.now; 18381 if (globals2.colors !== void 0) colors$1 = globals2.colors; 18382 if (globals2.skipAnimation != null) skipAnimation = globals2.skipAnimation; 18383 if (globals2.createStringInterpolator) createStringInterpolator$1 = globals2.createStringInterpolator; 18384 if (globals2.requestAnimationFrame) raf.use(globals2.requestAnimationFrame); 18385 if (globals2.batchedUpdates) raf.batchedUpdates = globals2.batchedUpdates; 18386 if (globals2.willAdvance) willAdvance = globals2.willAdvance; 18387 if (globals2.frameLoop) raf.frameLoop = globals2.frameLoop; 18388 }; 18389 var globals = /* @__PURE__ */ Object.freeze({ 18390 __proto__: null, 18391 get createStringInterpolator() { 18392 return createStringInterpolator$1; 18393 }, 18394 get to() { 18395 return to; 18396 }, 18397 get colors() { 18398 return colors$1; 18399 }, 18400 get skipAnimation() { 18401 return skipAnimation; 18402 }, 18403 get willAdvance() { 18404 return willAdvance; 18405 }, 18406 assign 18407 }); 18408 var startQueue = /* @__PURE__ */ new Set(); 18409 var currentFrame = []; 18410 var prevFrame = []; 18411 var priority = 0; 18412 var frameLoop = { 18413 get idle() { 18414 return !startQueue.size && !currentFrame.length; 18415 }, 18416 start(animation) { 18417 if (priority > animation.priority) { 18418 startQueue.add(animation); 18419 raf.onStart(flushStartQueue); 18420 } else { 18421 startSafely(animation); 18422 raf(advance); 18423 } 18424 }, 18425 advance, 18426 sort(animation) { 18427 if (priority) { 18428 raf.onFrame(() => frameLoop.sort(animation)); 18429 } else { 18430 const prevIndex = currentFrame.indexOf(animation); 18431 if (~prevIndex) { 18432 currentFrame.splice(prevIndex, 1); 18433 startUnsafely(animation); 18434 } 18435 } 18436 }, 18437 clear() { 18438 currentFrame = []; 18439 startQueue.clear(); 18440 } 18441 }; 18442 function flushStartQueue() { 18443 startQueue.forEach(startSafely); 18444 startQueue.clear(); 18445 raf(advance); 18446 } 18447 function startSafely(animation) { 18448 if (!currentFrame.includes(animation)) startUnsafely(animation); 18449 } 18450 function startUnsafely(animation) { 18451 currentFrame.splice(findIndex(currentFrame, (other) => other.priority > animation.priority), 0, animation); 18452 } 18453 function advance(dt) { 18454 const nextFrame = prevFrame; 18455 for (let i2 = 0; i2 < currentFrame.length; i2++) { 18456 const animation = currentFrame[i2]; 18457 priority = animation.priority; 18458 if (!animation.idle) { 18459 willAdvance(animation); 18460 animation.advance(dt); 18461 if (!animation.idle) { 18462 nextFrame.push(animation); 18463 } 18464 } 18465 } 18466 priority = 0; 18467 prevFrame = currentFrame; 18468 prevFrame.length = 0; 18469 currentFrame = nextFrame; 18470 return currentFrame.length > 0; 18471 } 18472 function findIndex(arr, test) { 18473 const index = arr.findIndex(test); 18474 return index < 0 ? arr.length : index; 18475 } 18476 var colors = { 18477 transparent: 0, 18478 aliceblue: 4042850303, 18479 antiquewhite: 4209760255, 18480 aqua: 16777215, 18481 aquamarine: 2147472639, 18482 azure: 4043309055, 18483 beige: 4126530815, 18484 bisque: 4293182719, 18485 black: 255, 18486 blanchedalmond: 4293643775, 18487 blue: 65535, 18488 blueviolet: 2318131967, 18489 brown: 2771004159, 18490 burlywood: 3736635391, 18491 burntsienna: 3934150143, 18492 cadetblue: 1604231423, 18493 chartreuse: 2147418367, 18494 chocolate: 3530104575, 18495 coral: 4286533887, 18496 cornflowerblue: 1687547391, 18497 cornsilk: 4294499583, 18498 crimson: 3692313855, 18499 cyan: 16777215, 18500 darkblue: 35839, 18501 darkcyan: 9145343, 18502 darkgoldenrod: 3095792639, 18503 darkgray: 2846468607, 18504 darkgreen: 6553855, 18505 darkgrey: 2846468607, 18506 darkkhaki: 3182914559, 18507 darkmagenta: 2332068863, 18508 darkolivegreen: 1433087999, 18509 darkorange: 4287365375, 18510 darkorchid: 2570243327, 18511 darkred: 2332033279, 18512 darksalmon: 3918953215, 18513 darkseagreen: 2411499519, 18514 darkslateblue: 1211993087, 18515 darkslategray: 793726975, 18516 darkslategrey: 793726975, 18517 darkturquoise: 13554175, 18518 darkviolet: 2483082239, 18519 deeppink: 4279538687, 18520 deepskyblue: 12582911, 18521 dimgray: 1768516095, 18522 dimgrey: 1768516095, 18523 dodgerblue: 512819199, 18524 firebrick: 2988581631, 18525 floralwhite: 4294635775, 18526 forestgreen: 579543807, 18527 fuchsia: 4278255615, 18528 gainsboro: 3705462015, 18529 ghostwhite: 4177068031, 18530 gold: 4292280575, 18531 goldenrod: 3668254975, 18532 gray: 2155905279, 18533 green: 8388863, 18534 greenyellow: 2919182335, 18535 grey: 2155905279, 18536 honeydew: 4043305215, 18537 hotpink: 4285117695, 18538 indianred: 3445382399, 18539 indigo: 1258324735, 18540 ivory: 4294963455, 18541 khaki: 4041641215, 18542 lavender: 3873897215, 18543 lavenderblush: 4293981695, 18544 lawngreen: 2096890111, 18545 lemonchiffon: 4294626815, 18546 lightblue: 2916673279, 18547 lightcoral: 4034953471, 18548 lightcyan: 3774873599, 18549 lightgoldenrodyellow: 4210742015, 18550 lightgray: 3553874943, 18551 lightgreen: 2431553791, 18552 lightgrey: 3553874943, 18553 lightpink: 4290167295, 18554 lightsalmon: 4288707327, 18555 lightseagreen: 548580095, 18556 lightskyblue: 2278488831, 18557 lightslategray: 2005441023, 18558 lightslategrey: 2005441023, 18559 lightsteelblue: 2965692159, 18560 lightyellow: 4294959359, 18561 lime: 16711935, 18562 limegreen: 852308735, 18563 linen: 4210091775, 18564 magenta: 4278255615, 18565 maroon: 2147483903, 18566 mediumaquamarine: 1724754687, 18567 mediumblue: 52735, 18568 mediumorchid: 3126187007, 18569 mediumpurple: 2473647103, 18570 mediumseagreen: 1018393087, 18571 mediumslateblue: 2070474495, 18572 mediumspringgreen: 16423679, 18573 mediumturquoise: 1221709055, 18574 mediumvioletred: 3340076543, 18575 midnightblue: 421097727, 18576 mintcream: 4127193855, 18577 mistyrose: 4293190143, 18578 moccasin: 4293178879, 18579 navajowhite: 4292783615, 18580 navy: 33023, 18581 oldlace: 4260751103, 18582 olive: 2155872511, 18583 olivedrab: 1804477439, 18584 orange: 4289003775, 18585 orangered: 4282712319, 18586 orchid: 3664828159, 18587 palegoldenrod: 4008225535, 18588 palegreen: 2566625535, 18589 paleturquoise: 2951671551, 18590 palevioletred: 3681588223, 18591 papayawhip: 4293907967, 18592 peachpuff: 4292524543, 18593 peru: 3448061951, 18594 pink: 4290825215, 18595 plum: 3718307327, 18596 powderblue: 2967529215, 18597 purple: 2147516671, 18598 rebeccapurple: 1714657791, 18599 red: 4278190335, 18600 rosybrown: 3163525119, 18601 royalblue: 1097458175, 18602 saddlebrown: 2336560127, 18603 salmon: 4202722047, 18604 sandybrown: 4104413439, 18605 seagreen: 780883967, 18606 seashell: 4294307583, 18607 sienna: 2689740287, 18608 silver: 3233857791, 18609 skyblue: 2278484991, 18610 slateblue: 1784335871, 18611 slategray: 1887473919, 18612 slategrey: 1887473919, 18613 snow: 4294638335, 18614 springgreen: 16744447, 18615 steelblue: 1182971135, 18616 tan: 3535047935, 18617 teal: 8421631, 18618 thistle: 3636451583, 18619 tomato: 4284696575, 18620 turquoise: 1088475391, 18621 violet: 4001558271, 18622 wheat: 4125012991, 18623 white: 4294967295, 18624 whitesmoke: 4126537215, 18625 yellow: 4294902015, 18626 yellowgreen: 2597139199 18627 }; 18628 var NUMBER = "[-+]?\\d*\\.?\\d+"; 18629 var PERCENTAGE = NUMBER + "%"; 18630 function call(...parts) { 18631 return "\\(\\s*(" + parts.join(")\\s*,\\s*(") + ")\\s*\\)"; 18632 } 18633 var rgb = new RegExp("rgb" + call(NUMBER, NUMBER, NUMBER)); 18634 var rgba = new RegExp("rgba" + call(NUMBER, NUMBER, NUMBER, NUMBER)); 18635 var hsl = new RegExp("hsl" + call(NUMBER, PERCENTAGE, PERCENTAGE)); 18636 var hsla = new RegExp("hsla" + call(NUMBER, PERCENTAGE, PERCENTAGE, NUMBER)); 18637 var hex3 = /^#([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/; 18638 var hex4 = /^#([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/; 18639 var hex6 = /^#([0-9a-fA-F]{6})$/; 18640 var hex8 = /^#([0-9a-fA-F]{8})$/; 18641 function normalizeColor(color) { 18642 let match2; 18643 if (typeof color === "number") { 18644 return color >>> 0 === color && color >= 0 && color <= 4294967295 ? color : null; 18645 } 18646 if (match2 = hex6.exec(color)) return parseInt(match2[1] + "ff", 16) >>> 0; 18647 if (colors$1 && colors$1[color] !== void 0) { 18648 return colors$1[color]; 18649 } 18650 if (match2 = rgb.exec(color)) { 18651 return (parse255(match2[1]) << 24 | parse255(match2[2]) << 16 | parse255(match2[3]) << 8 | 255) >>> 0; 18652 } 18653 if (match2 = rgba.exec(color)) { 18654 return (parse255(match2[1]) << 24 | parse255(match2[2]) << 16 | parse255(match2[3]) << 8 | parse1(match2[4])) >>> 0; 18655 } 18656 if (match2 = hex3.exec(color)) { 18657 return parseInt(match2[1] + match2[1] + match2[2] + match2[2] + match2[3] + match2[3] + "ff", 16) >>> 0; 18658 } 18659 if (match2 = hex8.exec(color)) return parseInt(match2[1], 16) >>> 0; 18660 if (match2 = hex4.exec(color)) { 18661 return parseInt(match2[1] + match2[1] + match2[2] + match2[2] + match2[3] + match2[3] + match2[4] + match2[4], 16) >>> 0; 18662 } 18663 if (match2 = hsl.exec(color)) { 18664 return (hslToRgb(parse360(match2[1]), parsePercentage(match2[2]), parsePercentage(match2[3])) | 255) >>> 0; 18665 } 18666 if (match2 = hsla.exec(color)) { 18667 return (hslToRgb(parse360(match2[1]), parsePercentage(match2[2]), parsePercentage(match2[3])) | parse1(match2[4])) >>> 0; 18668 } 18669 return null; 18670 } 18671 function hue2rgb(p2, q, t3) { 18672 if (t3 < 0) t3 += 1; 18673 if (t3 > 1) t3 -= 1; 18674 if (t3 < 1 / 6) return p2 + (q - p2) * 6 * t3; 18675 if (t3 < 1 / 2) return q; 18676 if (t3 < 2 / 3) return p2 + (q - p2) * (2 / 3 - t3) * 6; 18677 return p2; 18678 } 18679 function hslToRgb(h2, s2, l2) { 18680 const q = l2 < 0.5 ? l2 * (1 + s2) : l2 + s2 - l2 * s2; 18681 const p2 = 2 * l2 - q; 18682 const r3 = hue2rgb(p2, q, h2 + 1 / 3); 18683 const g2 = hue2rgb(p2, q, h2); 18684 const b2 = hue2rgb(p2, q, h2 - 1 / 3); 18685 return Math.round(r3 * 255) << 24 | Math.round(g2 * 255) << 16 | Math.round(b2 * 255) << 8; 18686 } 18687 function parse255(str) { 18688 const int = parseInt(str, 10); 18689 if (int < 0) return 0; 18690 if (int > 255) return 255; 18691 return int; 18692 } 18693 function parse360(str) { 18694 const int = parseFloat(str); 18695 return (int % 360 + 360) % 360 / 360; 18696 } 18697 function parse1(str) { 18698 const num = parseFloat(str); 18699 if (num < 0) return 0; 18700 if (num > 1) return 255; 18701 return Math.round(num * 255); 18702 } 18703 function parsePercentage(str) { 18704 const int = parseFloat(str); 18705 if (int < 0) return 0; 18706 if (int > 100) return 1; 18707 return int / 100; 18708 } 18709 function colorToRgba(input) { 18710 let int32Color = normalizeColor(input); 18711 if (int32Color === null) return input; 18712 int32Color = int32Color || 0; 18713 let r3 = (int32Color & 4278190080) >>> 24; 18714 let g2 = (int32Color & 16711680) >>> 16; 18715 let b2 = (int32Color & 65280) >>> 8; 18716 let a2 = (int32Color & 255) / 255; 18717 return `rgba($r3}, $g2}, $b2}, $a2})`; 18718 } 18719 var createInterpolator = (range2, output, extrapolate) => { 18720 if (is.fun(range2)) { 18721 return range2; 18722 } 18723 if (is.arr(range2)) { 18724 return createInterpolator({ 18725 range: range2, 18726 output, 18727 extrapolate 18728 }); 18729 } 18730 if (is.str(range2.output[0])) { 18731 return createStringInterpolator$1(range2); 18732 } 18733 const config2 = range2; 18734 const outputRange = config2.output; 18735 const inputRange = config2.range || [0, 1]; 18736 const extrapolateLeft = config2.extrapolateLeft || config2.extrapolate || "extend"; 18737 const extrapolateRight = config2.extrapolateRight || config2.extrapolate || "extend"; 18738 const easing = config2.easing || ((t3) => t3); 18739 return (input) => { 18740 const range3 = findRange(input, inputRange); 18741 return interpolate(input, inputRange[range3], inputRange[range3 + 1], outputRange[range3], outputRange[range3 + 1], easing, extrapolateLeft, extrapolateRight, config2.map); 18742 }; 18743 }; 18744 function interpolate(input, inputMin, inputMax, outputMin, outputMax, easing, extrapolateLeft, extrapolateRight, map) { 18745 let result = map ? map(input) : input; 18746 if (result < inputMin) { 18747 if (extrapolateLeft === "identity") return result; 18748 else if (extrapolateLeft === "clamp") result = inputMin; 18749 } 18750 if (result > inputMax) { 18751 if (extrapolateRight === "identity") return result; 18752 else if (extrapolateRight === "clamp") result = inputMax; 18753 } 18754 if (outputMin === outputMax) return outputMin; 18755 if (inputMin === inputMax) return input <= inputMin ? outputMin : outputMax; 18756 if (inputMin === -Infinity) result = -result; 18757 else if (inputMax === Infinity) result = result - inputMin; 18758 else result = (result - inputMin) / (inputMax - inputMin); 18759 result = easing(result); 18760 if (outputMin === -Infinity) result = -result; 18761 else if (outputMax === Infinity) result = result + outputMin; 18762 else result = result * (outputMax - outputMin) + outputMin; 18763 return result; 18764 } 18765 function findRange(input, inputRange) { 18766 for (var i2 = 1; i2 < inputRange.length - 1; ++i2) if (inputRange[i2] >= input) break; 18767 return i2 - 1; 18768 } 18769 function _extends() { 18770 _extends = Object.assign ? Object.assign.bind() : function(target) { 18771 for (var i2 = 1; i2 < arguments.length; i2++) { 18772 var source = arguments[i2]; 18773 for (var key in source) { 18774 if (Object.prototype.hasOwnProperty.call(source, key)) { 18775 target[key] = source[key]; 18776 } 18777 } 18778 } 18779 return target; 18780 }; 18781 return _extends.apply(this, arguments); 18782 } 18783 var $get = Symbol.for("FluidValue.get"); 18784 var $observers = Symbol.for("FluidValue.observers"); 18785 var hasFluidValue = (arg) => Boolean(arg && arg[$get]); 18786 var getFluidValue = (arg) => arg && arg[$get] ? arg[$get]() : arg; 18787 var getFluidObservers = (target) => target[$observers] || null; 18788 function callFluidObserver(observer, event) { 18789 if (observer.eventObserved) { 18790 observer.eventObserved(event); 18791 } else { 18792 observer(event); 18793 } 18794 } 18795 function callFluidObservers(target, event) { 18796 let observers = target[$observers]; 18797 if (observers) { 18798 observers.forEach((observer) => { 18799 callFluidObserver(observer, event); 18800 }); 18801 } 18802 } 18803 var FluidValue = class { 18804 constructor(get) { 18805 this[$get] = void 0; 18806 this[$observers] = void 0; 18807 if (!get && !(get = this.get)) { 18808 throw Error("Unknown getter"); 18809 } 18810 setFluidGetter(this, get); 18811 } 18812 }; 18813 var setFluidGetter = (target, get) => setHidden(target, $get, get); 18814 function addFluidObserver(target, observer) { 18815 if (target[$get]) { 18816 let observers = target[$observers]; 18817 if (!observers) { 18818 setHidden(target, $observers, observers = /* @__PURE__ */ new Set()); 18819 } 18820 if (!observers.has(observer)) { 18821 observers.add(observer); 18822 if (target.observerAdded) { 18823 target.observerAdded(observers.size, observer); 18824 } 18825 } 18826 } 18827 return observer; 18828 } 18829 function removeFluidObserver(target, observer) { 18830 let observers = target[$observers]; 18831 if (observers && observers.has(observer)) { 18832 const count = observers.size - 1; 18833 if (count) { 18834 observers.delete(observer); 18835 } else { 18836 target[$observers] = null; 18837 } 18838 if (target.observerRemoved) { 18839 target.observerRemoved(count, observer); 18840 } 18841 } 18842 } 18843 var setHidden = (target, key, value) => Object.defineProperty(target, key, { 18844 value, 18845 writable: true, 18846 configurable: true 18847 }); 18848 var numberRegex = /[+\-]?(?:0|[1-9]\d*)(?:\.\d*)?(?:[eE][+\-]?\d+)?/g; 18849 var colorRegex = /(#(?:[0-9a-f]{2}){2,4}|(#[0-9a-f]{3})|(rgb|hsl)a?\((-?\d+%?[,\s]+){2,3}\s*[\d\.]+%?\))/gi; 18850 var unitRegex = new RegExp(`($numberRegex.source})(%|[a-z]+)`, "i"); 18851 var rgbaRegex = /rgba\(([0-9\.-]+), ([0-9\.-]+), ([0-9\.-]+), ([0-9\.-]+)\)/gi; 18852 var cssVariableRegex = /var\((--[a-zA-Z0-9-_]+),? ?([a-zA-Z0-9 ()%#.,-]+)?\)/; 18853 var variableToRgba = (input) => { 18854 const [token, fallback] = parseCSSVariable(input); 18855 if (!token || isSSR()) { 18856 return input; 18857 } 18858 const value = window.getComputedStyle(document.documentElement).getPropertyValue(token); 18859 if (value) { 18860 return value.trim(); 18861 } else if (fallback && fallback.startsWith("--")) { 18862 const _value = window.getComputedStyle(document.documentElement).getPropertyValue(fallback); 18863 if (_value) { 18864 return _value; 18865 } else { 18866 return input; 18867 } 18868 } else if (fallback && cssVariableRegex.test(fallback)) { 18869 return variableToRgba(fallback); 18870 } else if (fallback) { 18871 return fallback; 18872 } 18873 return input; 18874 }; 18875 var parseCSSVariable = (current) => { 18876 const match2 = cssVariableRegex.exec(current); 18877 if (!match2) return [,]; 18878 const [, token, fallback] = match2; 18879 return [token, fallback]; 18880 }; 18881 var namedColorRegex; 18882 var rgbaRound = (_, p1, p2, p3, p4) => `rgba($Math.round(p1)}, $Math.round(p2)}, $Math.round(p3)}, $p4})`; 18883 var createStringInterpolator = (config2) => { 18884 if (!namedColorRegex) namedColorRegex = colors$1 ? new RegExp(`($Object.keys(colors$1).join("|")})(?!\\w)`, "g") : /^\b$/; 18885 const output = config2.output.map((value) => { 18886 return getFluidValue(value).replace(cssVariableRegex, variableToRgba).replace(colorRegex, colorToRgba).replace(namedColorRegex, colorToRgba); 18887 }); 18888 const keyframes = output.map((value) => value.match(numberRegex).map(Number)); 18889 const outputRanges = keyframes[0].map((_, i2) => keyframes.map((values) => { 18890 if (!(i2 in values)) { 18891 throw Error('The arity of each "output" value must be equal'); 18892 } 18893 return values[i2]; 18894 })); 18895 const interpolators = outputRanges.map((output2) => createInterpolator(_extends({}, config2, { 18896 output: output2 18897 }))); 18898 return (input) => { 18899 var _output$find; 18900 const missingUnit = !unitRegex.test(output[0]) && ((_output$find = output.find((value) => unitRegex.test(value))) == null ? void 0 : _output$find.replace(numberRegex, "")); 18901 let i2 = 0; 18902 return output[0].replace(numberRegex, () => `$interpolators[i2++](input)}$missingUnit || ""}`).replace(rgbaRegex, rgbaRound); 18903 }; 18904 }; 18905 var prefix = "react-spring: "; 18906 var once = (fn) => { 18907 const func = fn; 18908 let called = false; 18909 if (typeof func != "function") { 18910 throw new TypeError(`$prefix}once requires a function parameter`); 18911 } 18912 return (...args) => { 18913 if (!called) { 18914 func(...args); 18915 called = true; 18916 } 18917 }; 18918 }; 18919 var warnInterpolate = once(console.warn); 18920 function deprecateInterpolate() { 18921 warnInterpolate(`$prefix}The "interpolate" function is deprecated in v9 (use "to" instead)`); 18922 } 18923 var warnDirectCall = once(console.warn); 18924 function isAnimatedString(value) { 18925 return is.str(value) && (value[0] == "#" || /\d/.test(value) || !isSSR() && cssVariableRegex.test(value) || value in (colors$1 || {})); 18926 } 18927 var useIsomorphicLayoutEffect = isSSR() ? import_react.useEffect : import_react.useLayoutEffect; 18928 var useIsMounted = () => { 18929 const isMounted = (0, import_react.useRef)(false); 18930 useIsomorphicLayoutEffect(() => { 18931 isMounted.current = true; 18932 return () => { 18933 isMounted.current = false; 18934 }; 18935 }, []); 18936 return isMounted; 18937 }; 18938 function useForceUpdate() { 18939 const update3 = (0, import_react.useState)()[1]; 18940 const isMounted = useIsMounted(); 18941 return () => { 18942 if (isMounted.current) { 18943 update3(Math.random()); 18944 } 18945 }; 18946 } 18947 function useMemoOne(getResult, inputs) { 18948 const [initial] = (0, import_react.useState)(() => ({ 18949 inputs, 18950 result: getResult() 18951 })); 18952 const committed = (0, import_react.useRef)(); 18953 const prevCache = committed.current; 18954 let cache = prevCache; 18955 if (cache) { 18956 const useCache = Boolean(inputs && cache.inputs && areInputsEqual(inputs, cache.inputs)); 18957 if (!useCache) { 18958 cache = { 18959 inputs, 18960 result: getResult() 18961 }; 18962 } 18963 } else { 18964 cache = initial; 18965 } 18966 (0, import_react.useEffect)(() => { 18967 committed.current = cache; 18968 if (prevCache == initial) { 18969 initial.inputs = initial.result = void 0; 18970 } 18971 }, [cache]); 18972 return cache.result; 18973 } 18974 function areInputsEqual(next, prev) { 18975 if (next.length !== prev.length) { 18976 return false; 18977 } 18978 for (let i2 = 0; i2 < next.length; i2++) { 18979 if (next[i2] !== prev[i2]) { 18980 return false; 18981 } 18982 } 18983 return true; 18984 } 18985 var useOnce = (effect) => (0, import_react.useEffect)(effect, emptyDeps); 18986 var emptyDeps = []; 18987 18988 // node_modules/@react-spring/core/dist/react-spring-core.esm.js 18989 var React2 = __toESM(require_react()); 18990 var import_react3 = __toESM(require_react()); 18991 18992 // node_modules/@react-spring/animated/dist/react-spring-animated.esm.js 18993 var React = __toESM(require_react()); 18994 var import_react2 = __toESM(require_react()); 18995 var $node = Symbol.for("Animated:node"); 18996 var isAnimated = (value) => !!value && value[$node] === value; 18997 var getAnimated = (owner) => owner && owner[$node]; 18998 var setAnimated = (owner, node) => defineHidden(owner, $node, node); 18999 var getPayload = (owner) => owner && owner[$node] && owner[$node].getPayload(); 19000 var Animated = class { 19001 constructor() { 19002 this.payload = void 0; 19003 setAnimated(this, this); 19004 } 19005 getPayload() { 19006 return this.payload || []; 19007 } 19008 }; 19009 var AnimatedValue = class _AnimatedValue extends Animated { 19010 constructor(_value) { 19011 super(); 19012 this.done = true; 19013 this.elapsedTime = void 0; 19014 this.lastPosition = void 0; 19015 this.lastVelocity = void 0; 19016 this.v0 = void 0; 19017 this.durationProgress = 0; 19018 this._value = _value; 19019 if (is.num(this._value)) { 19020 this.lastPosition = this._value; 19021 } 19022 } 19023 static create(value) { 19024 return new _AnimatedValue(value); 19025 } 19026 getPayload() { 19027 return [this]; 19028 } 19029 getValue() { 19030 return this._value; 19031 } 19032 setValue(value, step) { 19033 if (is.num(value)) { 19034 this.lastPosition = value; 19035 if (step) { 19036 value = Math.round(value / step) * step; 19037 if (this.done) { 19038 this.lastPosition = value; 19039 } 19040 } 19041 } 19042 if (this._value === value) { 19043 return false; 19044 } 19045 this._value = value; 19046 return true; 19047 } 19048 reset() { 19049 const { 19050 done 19051 } = this; 19052 this.done = false; 19053 if (is.num(this._value)) { 19054 this.elapsedTime = 0; 19055 this.durationProgress = 0; 19056 this.lastPosition = this._value; 19057 if (done) this.lastVelocity = null; 19058 this.v0 = null; 19059 } 19060 } 19061 }; 19062 var AnimatedString = class _AnimatedString extends AnimatedValue { 19063 constructor(value) { 19064 super(0); 19065 this._string = null; 19066 this._toString = void 0; 19067 this._toString = createInterpolator({ 19068 output: [value, value] 19069 }); 19070 } 19071 static create(value) { 19072 return new _AnimatedString(value); 19073 } 19074 getValue() { 19075 let value = this._string; 19076 return value == null ? this._string = this._toString(this._value) : value; 19077 } 19078 setValue(value) { 19079 if (is.str(value)) { 19080 if (value == this._string) { 19081 return false; 19082 } 19083 this._string = value; 19084 this._value = 1; 19085 } else if (super.setValue(value)) { 19086 this._string = null; 19087 } else { 19088 return false; 19089 } 19090 return true; 19091 } 19092 reset(goal) { 19093 if (goal) { 19094 this._toString = createInterpolator({ 19095 output: [this.getValue(), goal] 19096 }); 19097 } 19098 this._value = 0; 19099 super.reset(); 19100 } 19101 }; 19102 var TreeContext = { 19103 dependencies: null 19104 }; 19105 var AnimatedObject = class extends Animated { 19106 constructor(source) { 19107 super(); 19108 this.source = source; 19109 this.setValue(source); 19110 } 19111 getValue(animated2) { 19112 const values = {}; 19113 eachProp(this.source, (source, key) => { 19114 if (isAnimated(source)) { 19115 values[key] = source.getValue(animated2); 19116 } else if (hasFluidValue(source)) { 19117 values[key] = getFluidValue(source); 19118 } else if (!animated2) { 19119 values[key] = source; 19120 } 19121 }); 19122 return values; 19123 } 19124 setValue(source) { 19125 this.source = source; 19126 this.payload = this._makePayload(source); 19127 } 19128 reset() { 19129 if (this.payload) { 19130 each(this.payload, (node) => node.reset()); 19131 } 19132 } 19133 _makePayload(source) { 19134 if (source) { 19135 const payload = /* @__PURE__ */ new Set(); 19136 eachProp(source, this._addToPayload, payload); 19137 return Array.from(payload); 19138 } 19139 } 19140 _addToPayload(source) { 19141 if (TreeContext.dependencies && hasFluidValue(source)) { 19142 TreeContext.dependencies.add(source); 19143 } 19144 const payload = getPayload(source); 19145 if (payload) { 19146 each(payload, (node) => this.add(node)); 19147 } 19148 } 19149 }; 19150 var AnimatedArray = class _AnimatedArray extends AnimatedObject { 19151 constructor(source) { 19152 super(source); 19153 } 19154 static create(source) { 19155 return new _AnimatedArray(source); 19156 } 19157 getValue() { 19158 return this.source.map((node) => node.getValue()); 19159 } 19160 setValue(source) { 19161 const payload = this.getPayload(); 19162 if (source.length == payload.length) { 19163 return payload.map((node, i2) => node.setValue(source[i2])).some(Boolean); 19164 } 19165 super.setValue(source.map(makeAnimated)); 19166 return true; 19167 } 19168 }; 19169 function makeAnimated(value) { 19170 const nodeType = isAnimatedString(value) ? AnimatedString : AnimatedValue; 19171 return nodeType.create(value); 19172 } 19173 function getAnimatedType(value) { 19174 const parentNode = getAnimated(value); 19175 return parentNode ? parentNode.constructor : is.arr(value) ? AnimatedArray : isAnimatedString(value) ? AnimatedString : AnimatedValue; 19176 } 19177 function _extends2() { 19178 _extends2 = Object.assign ? Object.assign.bind() : function(target) { 19179 for (var i2 = 1; i2 < arguments.length; i2++) { 19180 var source = arguments[i2]; 19181 for (var key in source) { 19182 if (Object.prototype.hasOwnProperty.call(source, key)) { 19183 target[key] = source[key]; 19184 } 19185 } 19186 } 19187 return target; 19188 }; 19189 return _extends2.apply(this, arguments); 19190 } 19191 var withAnimated = (Component7, host2) => { 19192 const hasInstance = !is.fun(Component7) || Component7.prototype && Component7.prototype.isReactComponent; 19193 return (0, import_react2.forwardRef)((givenProps, givenRef) => { 19194 const instanceRef = (0, import_react2.useRef)(null); 19195 const ref = hasInstance && (0, import_react2.useCallback)((value) => { 19196 instanceRef.current = updateRef(givenRef, value); 19197 }, [givenRef]); 19198 const [props, deps] = getAnimatedState(givenProps, host2); 19199 const forceUpdate = useForceUpdate(); 19200 const callback = () => { 19201 const instance = instanceRef.current; 19202 if (hasInstance && !instance) { 19203 return; 19204 } 19205 const didUpdate = instance ? host2.applyAnimatedValues(instance, props.getValue(true)) : false; 19206 if (didUpdate === false) { 19207 forceUpdate(); 19208 } 19209 }; 19210 const observer = new PropsObserver(callback, deps); 19211 const observerRef = (0, import_react2.useRef)(); 19212 useIsomorphicLayoutEffect(() => { 19213 observerRef.current = observer; 19214 each(deps, (dep) => addFluidObserver(dep, observer)); 19215 return () => { 19216 if (observerRef.current) { 19217 each(observerRef.current.deps, (dep) => removeFluidObserver(dep, observerRef.current)); 19218 raf.cancel(observerRef.current.update); 19219 } 19220 }; 19221 }); 19222 (0, import_react2.useEffect)(callback, []); 19223 useOnce(() => () => { 19224 const observer2 = observerRef.current; 19225 each(observer2.deps, (dep) => removeFluidObserver(dep, observer2)); 19226 }); 19227 const usedProps = host2.getComponentProps(props.getValue()); 19228 return React.createElement(Component7, _extends2({}, usedProps, { 19229 ref 19230 })); 19231 }); 19232 }; 19233 var PropsObserver = class { 19234 constructor(update3, deps) { 19235 this.update = update3; 19236 this.deps = deps; 19237 } 19238 eventObserved(event) { 19239 if (event.type == "change") { 19240 raf.write(this.update); 19241 } 19242 } 19243 }; 19244 function getAnimatedState(props, host2) { 19245 const dependencies = /* @__PURE__ */ new Set(); 19246 TreeContext.dependencies = dependencies; 19247 if (props.style) props = _extends2({}, props, { 19248 style: host2.createAnimatedStyle(props.style) 19249 }); 19250 props = new AnimatedObject(props); 19251 TreeContext.dependencies = null; 19252 return [props, dependencies]; 19253 } 19254 function updateRef(ref, value) { 19255 if (ref) { 19256 if (is.fun(ref)) ref(value); 19257 else ref.current = value; 19258 } 19259 return value; 19260 } 19261 var cacheKey = Symbol.for("AnimatedComponent"); 19262 var createHost = (components, { 19263 applyAnimatedValues: _applyAnimatedValues = () => false, 19264 createAnimatedStyle: _createAnimatedStyle = (style) => new AnimatedObject(style), 19265 getComponentProps: _getComponentProps = (props) => props 19266 } = {}) => { 19267 const hostConfig = { 19268 applyAnimatedValues: _applyAnimatedValues, 19269 createAnimatedStyle: _createAnimatedStyle, 19270 getComponentProps: _getComponentProps 19271 }; 19272 const animated2 = (Component7) => { 19273 const displayName = getDisplayName(Component7) || "Anonymous"; 19274 if (is.str(Component7)) { 19275 Component7 = animated2[Component7] || (animated2[Component7] = withAnimated(Component7, hostConfig)); 19276 } else { 19277 Component7 = Component7[cacheKey] || (Component7[cacheKey] = withAnimated(Component7, hostConfig)); 19278 } 19279 Component7.displayName = `Animated($displayName})`; 19280 return Component7; 19281 }; 19282 eachProp(components, (Component7, key) => { 19283 if (is.arr(components)) { 19284 key = getDisplayName(Component7); 19285 } 19286 animated2[key] = animated2(Component7); 19287 }); 19288 return { 19289 animated: animated2 19290 }; 19291 }; 19292 var getDisplayName = (arg) => is.str(arg) ? arg : arg && is.str(arg.displayName) ? arg.displayName : is.fun(arg) && arg.name || null; 19293 19294 // node_modules/@react-spring/core/dist/react-spring-core.esm.js 19295 function _extends3() { 19296 _extends3 = Object.assign ? Object.assign.bind() : function(target) { 19297 for (var i2 = 1; i2 < arguments.length; i2++) { 19298 var source = arguments[i2]; 19299 for (var key in source) { 19300 if (Object.prototype.hasOwnProperty.call(source, key)) { 19301 target[key] = source[key]; 19302 } 19303 } 19304 } 19305 return target; 19306 }; 19307 return _extends3.apply(this, arguments); 19308 } 19309 function callProp(value, ...args) { 19310 return is.fun(value) ? value(...args) : value; 19311 } 19312 var matchProp = (value, key) => value === true || !!(key && value && (is.fun(value) ? value(key) : toArray(value).includes(key))); 19313 var resolveProp = (prop, key) => is.obj(prop) ? key && prop[key] : prop; 19314 var getDefaultProp = (props, key) => props.default === true ? props[key] : props.default ? props.default[key] : void 0; 19315 var noopTransform = (value) => value; 19316 var getDefaultProps = (props, transform = noopTransform) => { 19317 let keys = DEFAULT_PROPS; 19318 if (props.default && props.default !== true) { 19319 props = props.default; 19320 keys = Object.keys(props); 19321 } 19322 const defaults2 = {}; 19323 for (const key of keys) { 19324 const value = transform(props[key], key); 19325 if (!is.und(value)) { 19326 defaults2[key] = value; 19327 } 19328 } 19329 return defaults2; 19330 }; 19331 var DEFAULT_PROPS = ["config", "onProps", "onStart", "onChange", "onPause", "onResume", "onRest"]; 19332 var RESERVED_PROPS = { 19333 config: 1, 19334 from: 1, 19335 to: 1, 19336 ref: 1, 19337 loop: 1, 19338 reset: 1, 19339 pause: 1, 19340 cancel: 1, 19341 reverse: 1, 19342 immediate: 1, 19343 default: 1, 19344 delay: 1, 19345 onProps: 1, 19346 onStart: 1, 19347 onChange: 1, 19348 onPause: 1, 19349 onResume: 1, 19350 onRest: 1, 19351 onResolve: 1, 19352 items: 1, 19353 trail: 1, 19354 sort: 1, 19355 expires: 1, 19356 initial: 1, 19357 enter: 1, 19358 update: 1, 19359 leave: 1, 19360 children: 1, 19361 onDestroyed: 1, 19362 keys: 1, 19363 callId: 1, 19364 parentId: 1 19365 }; 19366 function getForwardProps(props) { 19367 const forward = {}; 19368 let count = 0; 19369 eachProp(props, (value, prop) => { 19370 if (!RESERVED_PROPS[prop]) { 19371 forward[prop] = value; 19372 count++; 19373 } 19374 }); 19375 if (count) { 19376 return forward; 19377 } 19378 } 19379 function inferTo(props) { 19380 const to2 = getForwardProps(props); 19381 if (to2) { 19382 const out = { 19383 to: to2 19384 }; 19385 eachProp(props, (val, key) => key in to2 || (out[key] = val)); 19386 return out; 19387 } 19388 return _extends3({}, props); 19389 } 19390 function computeGoal(value) { 19391 value = getFluidValue(value); 19392 return is.arr(value) ? value.map(computeGoal) : isAnimatedString(value) ? globals.createStringInterpolator({ 19393 range: [0, 1], 19394 output: [value, value] 19395 })(1) : value; 19396 } 19397 function isAsyncTo(to2) { 19398 return is.fun(to2) || is.arr(to2) && is.obj(to2[0]); 19399 } 19400 var config = { 19401 default: { 19402 tension: 170, 19403 friction: 26 19404 }, 19405 gentle: { 19406 tension: 120, 19407 friction: 14 19408 }, 19409 wobbly: { 19410 tension: 180, 19411 friction: 12 19412 }, 19413 stiff: { 19414 tension: 210, 19415 friction: 20 19416 }, 19417 slow: { 19418 tension: 280, 19419 friction: 60 19420 }, 19421 molasses: { 19422 tension: 280, 19423 friction: 120 19424 } 19425 }; 19426 var c1 = 1.70158; 19427 var c2 = c1 * 1.525; 19428 var c3 = c1 + 1; 19429 var c4 = 2 * Math.PI / 3; 19430 var c5 = 2 * Math.PI / 4.5; 19431 var bounceOut = (x2) => { 19432 const n1 = 7.5625; 19433 const d1 = 2.75; 19434 if (x2 < 1 / d1) { 19435 return n1 * x2 * x2; 19436 } else if (x2 < 2 / d1) { 19437 return n1 * (x2 -= 1.5 / d1) * x2 + 0.75; 19438 } else if (x2 < 2.5 / d1) { 19439 return n1 * (x2 -= 2.25 / d1) * x2 + 0.9375; 19440 } else { 19441 return n1 * (x2 -= 2.625 / d1) * x2 + 0.984375; 19442 } 19443 }; 19444 var easings = { 19445 linear: (x2) => x2, 19446 easeInQuad: (x2) => x2 * x2, 19447 easeOutQuad: (x2) => 1 - (1 - x2) * (1 - x2), 19448 easeInOutQuad: (x2) => x2 < 0.5 ? 2 * x2 * x2 : 1 - Math.pow(-2 * x2 + 2, 2) / 2, 19449 easeInCubic: (x2) => x2 * x2 * x2, 19450 easeOutCubic: (x2) => 1 - Math.pow(1 - x2, 3), 19451 easeInOutCubic: (x2) => x2 < 0.5 ? 4 * x2 * x2 * x2 : 1 - Math.pow(-2 * x2 + 2, 3) / 2, 19452 easeInQuart: (x2) => x2 * x2 * x2 * x2, 19453 easeOutQuart: (x2) => 1 - Math.pow(1 - x2, 4), 19454 easeInOutQuart: (x2) => x2 < 0.5 ? 8 * x2 * x2 * x2 * x2 : 1 - Math.pow(-2 * x2 + 2, 4) / 2, 19455 easeInQuint: (x2) => x2 * x2 * x2 * x2 * x2, 19456 easeOutQuint: (x2) => 1 - Math.pow(1 - x2, 5), 19457 easeInOutQuint: (x2) => x2 < 0.5 ? 16 * x2 * x2 * x2 * x2 * x2 : 1 - Math.pow(-2 * x2 + 2, 5) / 2, 19458 easeInSine: (x2) => 1 - Math.cos(x2 * Math.PI / 2), 19459 easeOutSine: (x2) => Math.sin(x2 * Math.PI / 2), 19460 easeInOutSine: (x2) => -(Math.cos(Math.PI * x2) - 1) / 2, 19461 easeInExpo: (x2) => x2 === 0 ? 0 : Math.pow(2, 10 * x2 - 10), 19462 easeOutExpo: (x2) => x2 === 1 ? 1 : 1 - Math.pow(2, -10 * x2), 19463 easeInOutExpo: (x2) => x2 === 0 ? 0 : x2 === 1 ? 1 : x2 < 0.5 ? Math.pow(2, 20 * x2 - 10) / 2 : (2 - Math.pow(2, -20 * x2 + 10)) / 2, 19464 easeInCirc: (x2) => 1 - Math.sqrt(1 - Math.pow(x2, 2)), 19465 easeOutCirc: (x2) => Math.sqrt(1 - Math.pow(x2 - 1, 2)), 19466 easeInOutCirc: (x2) => x2 < 0.5 ? (1 - Math.sqrt(1 - Math.pow(2 * x2, 2))) / 2 : (Math.sqrt(1 - Math.pow(-2 * x2 + 2, 2)) + 1) / 2, 19467 easeInBack: (x2) => c3 * x2 * x2 * x2 - c1 * x2 * x2, 19468 easeOutBack: (x2) => 1 + c3 * Math.pow(x2 - 1, 3) + c1 * Math.pow(x2 - 1, 2), 19469 easeInOutBack: (x2) => x2 < 0.5 ? Math.pow(2 * x2, 2) * ((c2 + 1) * 2 * x2 - c2) / 2 : (Math.pow(2 * x2 - 2, 2) * ((c2 + 1) * (x2 * 2 - 2) + c2) + 2) / 2, 19470 easeInElastic: (x2) => x2 === 0 ? 0 : x2 === 1 ? 1 : -Math.pow(2, 10 * x2 - 10) * Math.sin((x2 * 10 - 10.75) * c4), 19471 easeOutElastic: (x2) => x2 === 0 ? 0 : x2 === 1 ? 1 : Math.pow(2, -10 * x2) * Math.sin((x2 * 10 - 0.75) * c4) + 1, 19472 easeInOutElastic: (x2) => x2 === 0 ? 0 : x2 === 1 ? 1 : x2 < 0.5 ? -(Math.pow(2, 20 * x2 - 10) * Math.sin((20 * x2 - 11.125) * c5)) / 2 : Math.pow(2, -20 * x2 + 10) * Math.sin((20 * x2 - 11.125) * c5) / 2 + 1, 19473 easeInBounce: (x2) => 1 - bounceOut(1 - x2), 19474 easeOutBounce: bounceOut, 19475 easeInOutBounce: (x2) => x2 < 0.5 ? (1 - bounceOut(1 - 2 * x2)) / 2 : (1 + bounceOut(2 * x2 - 1)) / 2 19476 }; 19477 var defaults = _extends3({}, config.default, { 19478 mass: 1, 19479 damping: 1, 19480 easing: easings.linear, 19481 clamp: false 19482 }); 19483 var AnimationConfig = class { 19484 constructor() { 19485 this.tension = void 0; 19486 this.friction = void 0; 19487 this.frequency = void 0; 19488 this.damping = void 0; 19489 this.mass = void 0; 19490 this.velocity = 0; 19491 this.restVelocity = void 0; 19492 this.precision = void 0; 19493 this.progress = void 0; 19494 this.duration = void 0; 19495 this.easing = void 0; 19496 this.clamp = void 0; 19497 this.bounce = void 0; 19498 this.decay = void 0; 19499 this.round = void 0; 19500 Object.assign(this, defaults); 19501 } 19502 }; 19503 function mergeConfig(config2, newConfig, defaultConfig) { 19504 if (defaultConfig) { 19505 defaultConfig = _extends3({}, defaultConfig); 19506 sanitizeConfig(defaultConfig, newConfig); 19507 newConfig = _extends3({}, defaultConfig, newConfig); 19508 } 19509 sanitizeConfig(config2, newConfig); 19510 Object.assign(config2, newConfig); 19511 for (const key in defaults) { 19512 if (config2[key] == null) { 19513 config2[key] = defaults[key]; 19514 } 19515 } 19516 let { 19517 mass, 19518 frequency, 19519 damping 19520 } = config2; 19521 if (!is.und(frequency)) { 19522 if (frequency < 0.01) frequency = 0.01; 19523 if (damping < 0) damping = 0; 19524 config2.tension = Math.pow(2 * Math.PI / frequency, 2) * mass; 19525 config2.friction = 4 * Math.PI * damping * mass / frequency; 19526 } 19527 return config2; 19528 } 19529 function sanitizeConfig(config2, props) { 19530 if (!is.und(props.decay)) { 19531 config2.duration = void 0; 19532 } else { 19533 const isTensionConfig = !is.und(props.tension) || !is.und(props.friction); 19534 if (isTensionConfig || !is.und(props.frequency) || !is.und(props.damping) || !is.und(props.mass)) { 19535 config2.duration = void 0; 19536 config2.decay = void 0; 19537 } 19538 if (isTensionConfig) { 19539 config2.frequency = void 0; 19540 } 19541 } 19542 } 19543 var emptyArray = []; 19544 var Animation = class { 19545 constructor() { 19546 this.changed = false; 19547 this.values = emptyArray; 19548 this.toValues = null; 19549 this.fromValues = emptyArray; 19550 this.to = void 0; 19551 this.from = void 0; 19552 this.config = new AnimationConfig(); 19553 this.immediate = false; 19554 } 19555 }; 19556 function scheduleProps(callId, { 19557 key, 19558 props, 19559 defaultProps, 19560 state, 19561 actions 19562 }) { 19563 return new Promise((resolve, reject) => { 19564 var _props$cancel; 19565 let delay; 19566 let timeout; 19567 let cancel = matchProp((_props$cancel = props.cancel) != null ? _props$cancel : defaultProps == null ? void 0 : defaultProps.cancel, key); 19568 if (cancel) { 19569 onStart(); 19570 } else { 19571 if (!is.und(props.pause)) { 19572 state.paused = matchProp(props.pause, key); 19573 } 19574 let pause = defaultProps == null ? void 0 : defaultProps.pause; 19575 if (pause !== true) { 19576 pause = state.paused || matchProp(pause, key); 19577 } 19578 delay = callProp(props.delay || 0, key); 19579 if (pause) { 19580 state.resumeQueue.add(onResume); 19581 actions.pause(); 19582 } else { 19583 actions.resume(); 19584 onResume(); 19585 } 19586 } 19587 function onPause() { 19588 state.resumeQueue.add(onResume); 19589 state.timeouts.delete(timeout); 19590 timeout.cancel(); 19591 delay = timeout.time - raf.now(); 19592 } 19593 function onResume() { 19594 if (delay > 0 && !globals.skipAnimation) { 19595 state.delayed = true; 19596 timeout = raf.setTimeout(onStart, delay); 19597 state.pauseQueue.add(onPause); 19598 state.timeouts.add(timeout); 19599 } else { 19600 onStart(); 19601 } 19602 } 19603 function onStart() { 19604 if (state.delayed) { 19605 state.delayed = false; 19606 } 19607 state.pauseQueue.delete(onPause); 19608 state.timeouts.delete(timeout); 19609 if (callId <= (state.cancelId || 0)) { 19610 cancel = true; 19611 } 19612 try { 19613 actions.start(_extends3({}, props, { 19614 callId, 19615 cancel 19616 }), resolve); 19617 } catch (err) { 19618 reject(err); 19619 } 19620 } 19621 }); 19622 } 19623 var getCombinedResult = (target, results) => results.length == 1 ? results[0] : results.some((result) => result.cancelled) ? getCancelledResult(target.get()) : results.every((result) => result.noop) ? getNoopResult(target.get()) : getFinishedResult(target.get(), results.every((result) => result.finished)); 19624 var getNoopResult = (value) => ({ 19625 value, 19626 noop: true, 19627 finished: true, 19628 cancelled: false 19629 }); 19630 var getFinishedResult = (value, finished, cancelled = false) => ({ 19631 value, 19632 finished, 19633 cancelled 19634 }); 19635 var getCancelledResult = (value) => ({ 19636 value, 19637 cancelled: true, 19638 finished: false 19639 }); 19640 function runAsync(to2, props, state, target) { 19641 const { 19642 callId, 19643 parentId, 19644 onRest 19645 } = props; 19646 const { 19647 asyncTo: prevTo, 19648 promise: prevPromise 19649 } = state; 19650 if (!parentId && to2 === prevTo && !props.reset) { 19651 return prevPromise; 19652 } 19653 return state.promise = (async () => { 19654 state.asyncId = callId; 19655 state.asyncTo = to2; 19656 const defaultProps = getDefaultProps(props, (value, key) => key === "onRest" ? void 0 : value); 19657 let preventBail; 19658 let bail; 19659 const bailPromise = new Promise((resolve, reject) => (preventBail = resolve, bail = reject)); 19660 const bailIfEnded = (bailSignal) => { 19661 const bailResult = callId <= (state.cancelId || 0) && getCancelledResult(target) || callId !== state.asyncId && getFinishedResult(target, false); 19662 if (bailResult) { 19663 bailSignal.result = bailResult; 19664 bail(bailSignal); 19665 throw bailSignal; 19666 } 19667 }; 19668 const animate = (arg1, arg2) => { 19669 const bailSignal = new BailSignal(); 19670 const skipAnimationSignal = new SkipAniamtionSignal(); 19671 return (async () => { 19672 if (globals.skipAnimation) { 19673 stopAsync(state); 19674 skipAnimationSignal.result = getFinishedResult(target, false); 19675 bail(skipAnimationSignal); 19676 throw skipAnimationSignal; 19677 } 19678 bailIfEnded(bailSignal); 19679 const props2 = is.obj(arg1) ? _extends3({}, arg1) : _extends3({}, arg2, { 19680 to: arg1 19681 }); 19682 props2.parentId = callId; 19683 eachProp(defaultProps, (value, key) => { 19684 if (is.und(props2[key])) { 19685 props2[key] = value; 19686 } 19687 }); 19688 const result2 = await target.start(props2); 19689 bailIfEnded(bailSignal); 19690 if (state.paused) { 19691 await new Promise((resume) => { 19692 state.resumeQueue.add(resume); 19693 }); 19694 } 19695 return result2; 19696 })(); 19697 }; 19698 let result; 19699 if (globals.skipAnimation) { 19700 stopAsync(state); 19701 return getFinishedResult(target, false); 19702 } 19703 try { 19704 let animating; 19705 if (is.arr(to2)) { 19706 animating = (async (queue) => { 19707 for (const props2 of queue) { 19708 await animate(props2); 19709 } 19710 })(to2); 19711 } else { 19712 animating = Promise.resolve(to2(animate, target.stop.bind(target))); 19713 } 19714 await Promise.all([animating.then(preventBail), bailPromise]); 19715 result = getFinishedResult(target.get(), true, false); 19716 } catch (err) { 19717 if (err instanceof BailSignal) { 19718 result = err.result; 19719 } else if (err instanceof SkipAniamtionSignal) { 19720 result = err.result; 19721 } else { 19722 throw err; 19723 } 19724 } finally { 19725 if (callId == state.asyncId) { 19726 state.asyncId = parentId; 19727 state.asyncTo = parentId ? prevTo : void 0; 19728 state.promise = parentId ? prevPromise : void 0; 19729 } 19730 } 19731 if (is.fun(onRest)) { 19732 raf.batchedUpdates(() => { 19733 onRest(result, target, target.item); 19734 }); 19735 } 19736 return result; 19737 })(); 19738 } 19739 function stopAsync(state, cancelId) { 19740 flush(state.timeouts, (t3) => t3.cancel()); 19741 state.pauseQueue.clear(); 19742 state.resumeQueue.clear(); 19743 state.asyncId = state.asyncTo = state.promise = void 0; 19744 if (cancelId) state.cancelId = cancelId; 19745 } 19746 var BailSignal = class extends Error { 19747 constructor() { 19748 super("An async animation has been interrupted. You see this error because you forgot to use `await` or `.catch(...)` on its returned promise."); 19749 this.result = void 0; 19750 } 19751 }; 19752 var SkipAniamtionSignal = class extends Error { 19753 constructor() { 19754 super("SkipAnimationSignal"); 19755 this.result = void 0; 19756 } 19757 }; 19758 var isFrameValue = (value) => value instanceof FrameValue; 19759 var nextId$1 = 1; 19760 var FrameValue = class extends FluidValue { 19761 constructor(...args) { 19762 super(...args); 19763 this.id = nextId$1++; 19764 this.key = void 0; 19765 this._priority = 0; 19766 } 19767 get priority() { 19768 return this._priority; 19769 } 19770 set priority(priority2) { 19771 if (this._priority != priority2) { 19772 this._priority = priority2; 19773 this._onPriorityChange(priority2); 19774 } 19775 } 19776 get() { 19777 const node = getAnimated(this); 19778 return node && node.getValue(); 19779 } 19780 to(...args) { 19781 return globals.to(this, args); 19782 } 19783 interpolate(...args) { 19784 deprecateInterpolate(); 19785 return globals.to(this, args); 19786 } 19787 toJSON() { 19788 return this.get(); 19789 } 19790 observerAdded(count) { 19791 if (count == 1) this._attach(); 19792 } 19793 observerRemoved(count) { 19794 if (count == 0) this._detach(); 19795 } 19796 _attach() { 19797 } 19798 _detach() { 19799 } 19800 _onChange(value, idle = false) { 19801 callFluidObservers(this, { 19802 type: "change", 19803 parent: this, 19804 value, 19805 idle 19806 }); 19807 } 19808 _onPriorityChange(priority2) { 19809 if (!this.idle) { 19810 frameLoop.sort(this); 19811 } 19812 callFluidObservers(this, { 19813 type: "priority", 19814 parent: this, 19815 priority: priority2 19816 }); 19817 } 19818 }; 19819 var $P = Symbol.for("SpringPhase"); 19820 var HAS_ANIMATED = 1; 19821 var IS_ANIMATING = 2; 19822 var IS_PAUSED = 4; 19823 var hasAnimated = (target) => (target[$P] & HAS_ANIMATED) > 0; 19824 var isAnimating = (target) => (target[$P] & IS_ANIMATING) > 0; 19825 var isPaused = (target) => (target[$P] & IS_PAUSED) > 0; 19826 var setActiveBit = (target, active) => active ? target[$P] |= IS_ANIMATING | HAS_ANIMATED : target[$P] &= ~IS_ANIMATING; 19827 var setPausedBit = (target, paused) => paused ? target[$P] |= IS_PAUSED : target[$P] &= ~IS_PAUSED; 19828 var SpringValue = class extends FrameValue { 19829 constructor(arg1, arg2) { 19830 super(); 19831 this.key = void 0; 19832 this.animation = new Animation(); 19833 this.queue = void 0; 19834 this.defaultProps = {}; 19835 this._state = { 19836 paused: false, 19837 delayed: false, 19838 pauseQueue: /* @__PURE__ */ new Set(), 19839 resumeQueue: /* @__PURE__ */ new Set(), 19840 timeouts: /* @__PURE__ */ new Set() 19841 }; 19842 this._pendingCalls = /* @__PURE__ */ new Set(); 19843 this._lastCallId = 0; 19844 this._lastToId = 0; 19845 this._memoizedDuration = 0; 19846 if (!is.und(arg1) || !is.und(arg2)) { 19847 const props = is.obj(arg1) ? _extends3({}, arg1) : _extends3({}, arg2, { 19848 from: arg1 19849 }); 19850 if (is.und(props.default)) { 19851 props.default = true; 19852 } 19853 this.start(props); 19854 } 19855 } 19856 get idle() { 19857 return !(isAnimating(this) || this._state.asyncTo) || isPaused(this); 19858 } 19859 get goal() { 19860 return getFluidValue(this.animation.to); 19861 } 19862 get velocity() { 19863 const node = getAnimated(this); 19864 return node instanceof AnimatedValue ? node.lastVelocity || 0 : node.getPayload().map((node2) => node2.lastVelocity || 0); 19865 } 19866 get hasAnimated() { 19867 return hasAnimated(this); 19868 } 19869 get isAnimating() { 19870 return isAnimating(this); 19871 } 19872 get isPaused() { 19873 return isPaused(this); 19874 } 19875 get isDelayed() { 19876 return this._state.delayed; 19877 } 19878 advance(dt) { 19879 let idle = true; 19880 let changed = false; 19881 const anim = this.animation; 19882 let { 19883 config: config2, 19884 toValues 19885 } = anim; 19886 const payload = getPayload(anim.to); 19887 if (!payload && hasFluidValue(anim.to)) { 19888 toValues = toArray(getFluidValue(anim.to)); 19889 } 19890 anim.values.forEach((node2, i2) => { 19891 if (node2.done) return; 19892 const to2 = node2.constructor == AnimatedString ? 1 : payload ? payload[i2].lastPosition : toValues[i2]; 19893 let finished = anim.immediate; 19894 let position = to2; 19895 if (!finished) { 19896 position = node2.lastPosition; 19897 if (config2.tension <= 0) { 19898 node2.done = true; 19899 return; 19900 } 19901 let elapsed = node2.elapsedTime += dt; 19902 const from = anim.fromValues[i2]; 19903 const v0 = node2.v0 != null ? node2.v0 : node2.v0 = is.arr(config2.velocity) ? config2.velocity[i2] : config2.velocity; 19904 let velocity; 19905 const precision = config2.precision || (from == to2 ? 5e-3 : Math.min(1, Math.abs(to2 - from) * 1e-3)); 19906 if (!is.und(config2.duration)) { 19907 let p2 = 1; 19908 if (config2.duration > 0) { 19909 if (this._memoizedDuration !== config2.duration) { 19910 this._memoizedDuration = config2.duration; 19911 if (node2.durationProgress > 0) { 19912 node2.elapsedTime = config2.duration * node2.durationProgress; 19913 elapsed = node2.elapsedTime += dt; 19914 } 19915 } 19916 p2 = (config2.progress || 0) + elapsed / this._memoizedDuration; 19917 p2 = p2 > 1 ? 1 : p2 < 0 ? 0 : p2; 19918 node2.durationProgress = p2; 19919 } 19920 position = from + config2.easing(p2) * (to2 - from); 19921 velocity = (position - node2.lastPosition) / dt; 19922 finished = p2 == 1; 19923 } else if (config2.decay) { 19924 const decay = config2.decay === true ? 0.998 : config2.decay; 19925 const e2 = Math.exp(-(1 - decay) * elapsed); 19926 position = from + v0 / (1 - decay) * (1 - e2); 19927 finished = Math.abs(node2.lastPosition - position) <= precision; 19928 velocity = v0 * e2; 19929 } else { 19930 velocity = node2.lastVelocity == null ? v0 : node2.lastVelocity; 19931 const restVelocity = config2.restVelocity || precision / 10; 19932 const bounceFactor = config2.clamp ? 0 : config2.bounce; 19933 const canBounce = !is.und(bounceFactor); 19934 const isGrowing = from == to2 ? node2.v0 > 0 : from < to2; 19935 let isMoving; 19936 let isBouncing = false; 19937 const step = 1; 19938 const numSteps = Math.ceil(dt / step); 19939 for (let n2 = 0; n2 < numSteps; ++n2) { 19940 isMoving = Math.abs(velocity) > restVelocity; 19941 if (!isMoving) { 19942 finished = Math.abs(to2 - position) <= precision; 19943 if (finished) { 19944 break; 19945 } 19946 } 19947 if (canBounce) { 19948 isBouncing = position == to2 || position > to2 == isGrowing; 19949 if (isBouncing) { 19950 velocity = -velocity * bounceFactor; 19951 position = to2; 19952 } 19953 } 19954 const springForce = -config2.tension * 1e-6 * (position - to2); 19955 const dampingForce = -config2.friction * 1e-3 * velocity; 19956 const acceleration = (springForce + dampingForce) / config2.mass; 19957 velocity = velocity + acceleration * step; 19958 position = position + velocity * step; 19959 } 19960 } 19961 node2.lastVelocity = velocity; 19962 if (Number.isNaN(position)) { 19963 console.warn(`Got NaN while animating:`, this); 19964 finished = true; 19965 } 19966 } 19967 if (payload && !payload[i2].done) { 19968 finished = false; 19969 } 19970 if (finished) { 19971 node2.done = true; 19972 } else { 19973 idle = false; 19974 } 19975 if (node2.setValue(position, config2.round)) { 19976 changed = true; 19977 } 19978 }); 19979 const node = getAnimated(this); 19980 const currVal = node.getValue(); 19981 if (idle) { 19982 const finalVal = getFluidValue(anim.to); 19983 if ((currVal !== finalVal || changed) && !config2.decay) { 19984 node.setValue(finalVal); 19985 this._onChange(finalVal); 19986 } else if (changed && config2.decay) { 19987 this._onChange(currVal); 19988 } 19989 this._stop(); 19990 } else if (changed) { 19991 this._onChange(currVal); 19992 } 19993 } 19994 set(value) { 19995 raf.batchedUpdates(() => { 19996 this._stop(); 19997 this._focus(value); 19998 this._set(value); 19999 }); 20000 return this; 20001 } 20002 pause() { 20003 this._update({ 20004 pause: true 20005 }); 20006 } 20007 resume() { 20008 this._update({ 20009 pause: false 20010 }); 20011 } 20012 finish() { 20013 if (isAnimating(this)) { 20014 const { 20015 to: to2, 20016 config: config2 20017 } = this.animation; 20018 raf.batchedUpdates(() => { 20019 this._onStart(); 20020 if (!config2.decay) { 20021 this._set(to2, false); 20022 } 20023 this._stop(); 20024 }); 20025 } 20026 return this; 20027 } 20028 update(props) { 20029 const queue = this.queue || (this.queue = []); 20030 queue.push(props); 20031 return this; 20032 } 20033 start(to2, arg2) { 20034 let queue; 20035 if (!is.und(to2)) { 20036 queue = [is.obj(to2) ? to2 : _extends3({}, arg2, { 20037 to: to2 20038 })]; 20039 } else { 20040 queue = this.queue || []; 20041 this.queue = []; 20042 } 20043 return Promise.all(queue.map((props) => { 20044 const up = this._update(props); 20045 return up; 20046 })).then((results) => getCombinedResult(this, results)); 20047 } 20048 stop(cancel) { 20049 const { 20050 to: to2 20051 } = this.animation; 20052 this._focus(this.get()); 20053 stopAsync(this._state, cancel && this._lastCallId); 20054 raf.batchedUpdates(() => this._stop(to2, cancel)); 20055 return this; 20056 } 20057 reset() { 20058 this._update({ 20059 reset: true 20060 }); 20061 } 20062 eventObserved(event) { 20063 if (event.type == "change") { 20064 this._start(); 20065 } else if (event.type == "priority") { 20066 this.priority = event.priority + 1; 20067 } 20068 } 20069 _prepareNode(props) { 20070 const key = this.key || ""; 20071 let { 20072 to: to2, 20073 from 20074 } = props; 20075 to2 = is.obj(to2) ? to2[key] : to2; 20076 if (to2 == null || isAsyncTo(to2)) { 20077 to2 = void 0; 20078 } 20079 from = is.obj(from) ? from[key] : from; 20080 if (from == null) { 20081 from = void 0; 20082 } 20083 const range2 = { 20084 to: to2, 20085 from 20086 }; 20087 if (!hasAnimated(this)) { 20088 if (props.reverse) [to2, from] = [from, to2]; 20089 from = getFluidValue(from); 20090 if (!is.und(from)) { 20091 this._set(from); 20092 } else if (!getAnimated(this)) { 20093 this._set(to2); 20094 } 20095 } 20096 return range2; 20097 } 20098 _update(_ref, isLoop) { 20099 let props = _extends3({}, _ref); 20100 const { 20101 key, 20102 defaultProps 20103 } = this; 20104 if (props.default) Object.assign(defaultProps, getDefaultProps(props, (value, prop) => /^on/.test(prop) ? resolveProp(value, key) : value)); 20105 mergeActiveFn(this, props, "onProps"); 20106 sendEvent(this, "onProps", props, this); 20107 const range2 = this._prepareNode(props); 20108 if (Object.isFrozen(this)) { 20109 throw Error("Cannot animate a `SpringValue` object that is frozen. Did you forget to pass your component to `animated(...)` before animating its props?"); 20110 } 20111 const state = this._state; 20112 return scheduleProps(++this._lastCallId, { 20113 key, 20114 props, 20115 defaultProps, 20116 state, 20117 actions: { 20118 pause: () => { 20119 if (!isPaused(this)) { 20120 setPausedBit(this, true); 20121 flushCalls(state.pauseQueue); 20122 sendEvent(this, "onPause", getFinishedResult(this, checkFinished(this, this.animation.to)), this); 20123 } 20124 }, 20125 resume: () => { 20126 if (isPaused(this)) { 20127 setPausedBit(this, false); 20128 if (isAnimating(this)) { 20129 this._resume(); 20130 } 20131 flushCalls(state.resumeQueue); 20132 sendEvent(this, "onResume", getFinishedResult(this, checkFinished(this, this.animation.to)), this); 20133 } 20134 }, 20135 start: this._merge.bind(this, range2) 20136 } 20137 }).then((result) => { 20138 if (props.loop && result.finished && !(isLoop && result.noop)) { 20139 const nextProps = createLoopUpdate(props); 20140 if (nextProps) { 20141 return this._update(nextProps, true); 20142 } 20143 } 20144 return result; 20145 }); 20146 } 20147 _merge(range2, props, resolve) { 20148 if (props.cancel) { 20149 this.stop(true); 20150 return resolve(getCancelledResult(this)); 20151 } 20152 const hasToProp = !is.und(range2.to); 20153 const hasFromProp = !is.und(range2.from); 20154 if (hasToProp || hasFromProp) { 20155 if (props.callId > this._lastToId) { 20156 this._lastToId = props.callId; 20157 } else { 20158 return resolve(getCancelledResult(this)); 20159 } 20160 } 20161 const { 20162 key, 20163 defaultProps, 20164 animation: anim 20165 } = this; 20166 const { 20167 to: prevTo, 20168 from: prevFrom 20169 } = anim; 20170 let { 20171 to: to2 = prevTo, 20172 from = prevFrom 20173 } = range2; 20174 if (hasFromProp && !hasToProp && (!props.default || is.und(to2))) { 20175 to2 = from; 20176 } 20177 if (props.reverse) [to2, from] = [from, to2]; 20178 const hasFromChanged = !isEqual(from, prevFrom); 20179 if (hasFromChanged) { 20180 anim.from = from; 20181 } 20182 from = getFluidValue(from); 20183 const hasToChanged = !isEqual(to2, prevTo); 20184 if (hasToChanged) { 20185 this._focus(to2); 20186 } 20187 const hasAsyncTo = isAsyncTo(props.to); 20188 const { 20189 config: config2 20190 } = anim; 20191 const { 20192 decay, 20193 velocity 20194 } = config2; 20195 if (hasToProp || hasFromProp) { 20196 config2.velocity = 0; 20197 } 20198 if (props.config && !hasAsyncTo) { 20199 mergeConfig(config2, callProp(props.config, key), props.config !== defaultProps.config ? callProp(defaultProps.config, key) : void 0); 20200 } 20201 let node = getAnimated(this); 20202 if (!node || is.und(to2)) { 20203 return resolve(getFinishedResult(this, true)); 20204 } 20205 const reset = is.und(props.reset) ? hasFromProp && !props.default : !is.und(from) && matchProp(props.reset, key); 20206 const value = reset ? from : this.get(); 20207 const goal = computeGoal(to2); 20208 const isAnimatable = is.num(goal) || is.arr(goal) || isAnimatedString(goal); 20209 const immediate = !hasAsyncTo && (!isAnimatable || matchProp(defaultProps.immediate || props.immediate, key)); 20210 if (hasToChanged) { 20211 const nodeType = getAnimatedType(to2); 20212 if (nodeType !== node.constructor) { 20213 if (immediate) { 20214 node = this._set(goal); 20215 } else throw Error(`Cannot animate between $node.constructor.name} and $nodeType.name}, as the "to" prop suggests`); 20216 } 20217 } 20218 const goalType = node.constructor; 20219 let started = hasFluidValue(to2); 20220 let finished = false; 20221 if (!started) { 20222 const hasValueChanged = reset || !hasAnimated(this) && hasFromChanged; 20223 if (hasToChanged || hasValueChanged) { 20224 finished = isEqual(computeGoal(value), goal); 20225 started = !finished; 20226 } 20227 if (!isEqual(anim.immediate, immediate) && !immediate || !isEqual(config2.decay, decay) || !isEqual(config2.velocity, velocity)) { 20228 started = true; 20229 } 20230 } 20231 if (finished && isAnimating(this)) { 20232 if (anim.changed && !reset) { 20233 started = true; 20234 } else if (!started) { 20235 this._stop(prevTo); 20236 } 20237 } 20238 if (!hasAsyncTo) { 20239 if (started || hasFluidValue(prevTo)) { 20240 anim.values = node.getPayload(); 20241 anim.toValues = hasFluidValue(to2) ? null : goalType == AnimatedString ? [1] : toArray(goal); 20242 } 20243 if (anim.immediate != immediate) { 20244 anim.immediate = immediate; 20245 if (!immediate && !reset) { 20246 this._set(prevTo); 20247 } 20248 } 20249 if (started) { 20250 const { 20251 onRest 20252 } = anim; 20253 each(ACTIVE_EVENTS, (type) => mergeActiveFn(this, props, type)); 20254 const result = getFinishedResult(this, checkFinished(this, prevTo)); 20255 flushCalls(this._pendingCalls, result); 20256 this._pendingCalls.add(resolve); 20257 if (anim.changed) raf.batchedUpdates(() => { 20258 anim.changed = !reset; 20259 onRest == null ? void 0 : onRest(result, this); 20260 if (reset) { 20261 callProp(defaultProps.onRest, result); 20262 } else { 20263 anim.onStart == null ? void 0 : anim.onStart(result, this); 20264 } 20265 }); 20266 } 20267 } 20268 if (reset) { 20269 this._set(value); 20270 } 20271 if (hasAsyncTo) { 20272 resolve(runAsync(props.to, props, this._state, this)); 20273 } else if (started) { 20274 this._start(); 20275 } else if (isAnimating(this) && !hasToChanged) { 20276 this._pendingCalls.add(resolve); 20277 } else { 20278 resolve(getNoopResult(value)); 20279 } 20280 } 20281 _focus(value) { 20282 const anim = this.animation; 20283 if (value !== anim.to) { 20284 if (getFluidObservers(this)) { 20285 this._detach(); 20286 } 20287 anim.to = value; 20288 if (getFluidObservers(this)) { 20289 this._attach(); 20290 } 20291 } 20292 } 20293 _attach() { 20294 let priority2 = 0; 20295 const { 20296 to: to2 20297 } = this.animation; 20298 if (hasFluidValue(to2)) { 20299 addFluidObserver(to2, this); 20300 if (isFrameValue(to2)) { 20301 priority2 = to2.priority + 1; 20302 } 20303 } 20304 this.priority = priority2; 20305 } 20306 _detach() { 20307 const { 20308 to: to2 20309 } = this.animation; 20310 if (hasFluidValue(to2)) { 20311 removeFluidObserver(to2, this); 20312 } 20313 } 20314 _set(arg, idle = true) { 20315 const value = getFluidValue(arg); 20316 if (!is.und(value)) { 20317 const oldNode = getAnimated(this); 20318 if (!oldNode || !isEqual(value, oldNode.getValue())) { 20319 const nodeType = getAnimatedType(value); 20320 if (!oldNode || oldNode.constructor != nodeType) { 20321 setAnimated(this, nodeType.create(value)); 20322 } else { 20323 oldNode.setValue(value); 20324 } 20325 if (oldNode) { 20326 raf.batchedUpdates(() => { 20327 this._onChange(value, idle); 20328 }); 20329 } 20330 } 20331 } 20332 return getAnimated(this); 20333 } 20334 _onStart() { 20335 const anim = this.animation; 20336 if (!anim.changed) { 20337 anim.changed = true; 20338 sendEvent(this, "onStart", getFinishedResult(this, checkFinished(this, anim.to)), this); 20339 } 20340 } 20341 _onChange(value, idle) { 20342 if (!idle) { 20343 this._onStart(); 20344 callProp(this.animation.onChange, value, this); 20345 } 20346 callProp(this.defaultProps.onChange, value, this); 20347 super._onChange(value, idle); 20348 } 20349 _start() { 20350 const anim = this.animation; 20351 getAnimated(this).reset(getFluidValue(anim.to)); 20352 if (!anim.immediate) { 20353 anim.fromValues = anim.values.map((node) => node.lastPosition); 20354 } 20355 if (!isAnimating(this)) { 20356 setActiveBit(this, true); 20357 if (!isPaused(this)) { 20358 this._resume(); 20359 } 20360 } 20361 } 20362 _resume() { 20363 if (globals.skipAnimation) { 20364 this.finish(); 20365 } else { 20366 frameLoop.start(this); 20367 } 20368 } 20369 _stop(goal, cancel) { 20370 if (isAnimating(this)) { 20371 setActiveBit(this, false); 20372 const anim = this.animation; 20373 each(anim.values, (node) => { 20374 node.done = true; 20375 }); 20376 if (anim.toValues) { 20377 anim.onChange = anim.onPause = anim.onResume = void 0; 20378 } 20379 callFluidObservers(this, { 20380 type: "idle", 20381 parent: this 20382 }); 20383 const result = cancel ? getCancelledResult(this.get()) : getFinishedResult(this.get(), checkFinished(this, goal != null ? goal : anim.to)); 20384 flushCalls(this._pendingCalls, result); 20385 if (anim.changed) { 20386 anim.changed = false; 20387 sendEvent(this, "onRest", result, this); 20388 } 20389 } 20390 } 20391 }; 20392 function checkFinished(target, to2) { 20393 const goal = computeGoal(to2); 20394 const value = computeGoal(target.get()); 20395 return isEqual(value, goal); 20396 } 20397 function createLoopUpdate(props, loop2 = props.loop, to2 = props.to) { 20398 let loopRet = callProp(loop2); 20399 if (loopRet) { 20400 const overrides = loopRet !== true && inferTo(loopRet); 20401 const reverse = (overrides || props).reverse; 20402 const reset = !overrides || overrides.reset; 20403 return createUpdate(_extends3({}, props, { 20404 loop: loop2, 20405 default: false, 20406 pause: void 0, 20407 to: !reverse || isAsyncTo(to2) ? to2 : void 0, 20408 from: reset ? props.from : void 0, 20409 reset 20410 }, overrides)); 20411 } 20412 } 20413 function createUpdate(props) { 20414 const { 20415 to: to2, 20416 from 20417 } = props = inferTo(props); 20418 const keys = /* @__PURE__ */ new Set(); 20419 if (is.obj(to2)) findDefined(to2, keys); 20420 if (is.obj(from)) findDefined(from, keys); 20421 props.keys = keys.size ? Array.from(keys) : null; 20422 return props; 20423 } 20424 function findDefined(values, keys) { 20425 eachProp(values, (value, key) => value != null && keys.add(key)); 20426 } 20427 var ACTIVE_EVENTS = ["onStart", "onRest", "onChange", "onPause", "onResume"]; 20428 function mergeActiveFn(target, props, type) { 20429 target.animation[type] = props[type] !== getDefaultProp(props, type) ? resolveProp(props[type], target.key) : void 0; 20430 } 20431 function sendEvent(target, type, ...args) { 20432 var _target$animation$typ, _target$animation, _target$defaultProps$, _target$defaultProps; 20433 (_target$animation$typ = (_target$animation = target.animation)[type]) == null ? void 0 : _target$animation$typ.call(_target$animation, ...args); 20434 (_target$defaultProps$ = (_target$defaultProps = target.defaultProps)[type]) == null ? void 0 : _target$defaultProps$.call(_target$defaultProps, ...args); 20435 } 20436 var BATCHED_EVENTS = ["onStart", "onChange", "onRest"]; 20437 var nextId = 1; 20438 var Controller = class { 20439 constructor(props, flush2) { 20440 this.id = nextId++; 20441 this.springs = {}; 20442 this.queue = []; 20443 this.ref = void 0; 20444 this._flush = void 0; 20445 this._initialProps = void 0; 20446 this._lastAsyncId = 0; 20447 this._active = /* @__PURE__ */ new Set(); 20448 this._changed = /* @__PURE__ */ new Set(); 20449 this._started = false; 20450 this._item = void 0; 20451 this._state = { 20452 paused: false, 20453 pauseQueue: /* @__PURE__ */ new Set(), 20454 resumeQueue: /* @__PURE__ */ new Set(), 20455 timeouts: /* @__PURE__ */ new Set() 20456 }; 20457 this._events = { 20458 onStart: /* @__PURE__ */ new Map(), 20459 onChange: /* @__PURE__ */ new Map(), 20460 onRest: /* @__PURE__ */ new Map() 20461 }; 20462 this._onFrame = this._onFrame.bind(this); 20463 if (flush2) { 20464 this._flush = flush2; 20465 } 20466 if (props) { 20467 this.start(_extends3({ 20468 default: true 20469 }, props)); 20470 } 20471 } 20472 get idle() { 20473 return !this._state.asyncTo && Object.values(this.springs).every((spring) => { 20474 return spring.idle && !spring.isDelayed && !spring.isPaused; 20475 }); 20476 } 20477 get item() { 20478 return this._item; 20479 } 20480 set item(item) { 20481 this._item = item; 20482 } 20483 get() { 20484 const values = {}; 20485 this.each((spring, key) => values[key] = spring.get()); 20486 return values; 20487 } 20488 set(values) { 20489 for (const key in values) { 20490 const value = values[key]; 20491 if (!is.und(value)) { 20492 this.springs[key].set(value); 20493 } 20494 } 20495 } 20496 update(props) { 20497 if (props) { 20498 this.queue.push(createUpdate(props)); 20499 } 20500 return this; 20501 } 20502 start(props) { 20503 let { 20504 queue 20505 } = this; 20506 if (props) { 20507 queue = toArray(props).map(createUpdate); 20508 } else { 20509 this.queue = []; 20510 } 20511 if (this._flush) { 20512 return this._flush(this, queue); 20513 } 20514 prepareKeys(this, queue); 20515 return flushUpdateQueue(this, queue); 20516 } 20517 stop(arg, keys) { 20518 if (arg !== !!arg) { 20519 keys = arg; 20520 } 20521 if (keys) { 20522 const springs = this.springs; 20523 each(toArray(keys), (key) => springs[key].stop(!!arg)); 20524 } else { 20525 stopAsync(this._state, this._lastAsyncId); 20526 this.each((spring) => spring.stop(!!arg)); 20527 } 20528 return this; 20529 } 20530 pause(keys) { 20531 if (is.und(keys)) { 20532 this.start({ 20533 pause: true 20534 }); 20535 } else { 20536 const springs = this.springs; 20537 each(toArray(keys), (key) => springs[key].pause()); 20538 } 20539 return this; 20540 } 20541 resume(keys) { 20542 if (is.und(keys)) { 20543 this.start({ 20544 pause: false 20545 }); 20546 } else { 20547 const springs = this.springs; 20548 each(toArray(keys), (key) => springs[key].resume()); 20549 } 20550 return this; 20551 } 20552 each(iterator) { 20553 eachProp(this.springs, iterator); 20554 } 20555 _onFrame() { 20556 const { 20557 onStart, 20558 onChange, 20559 onRest 20560 } = this._events; 20561 const active = this._active.size > 0; 20562 const changed = this._changed.size > 0; 20563 if (active && !this._started || changed && !this._started) { 20564 this._started = true; 20565 flush(onStart, ([onStart2, result]) => { 20566 result.value = this.get(); 20567 onStart2(result, this, this._item); 20568 }); 20569 } 20570 const idle = !active && this._started; 20571 const values = changed || idle && onRest.size ? this.get() : null; 20572 if (changed && onChange.size) { 20573 flush(onChange, ([onChange2, result]) => { 20574 result.value = values; 20575 onChange2(result, this, this._item); 20576 }); 20577 } 20578 if (idle) { 20579 this._started = false; 20580 flush(onRest, ([onRest2, result]) => { 20581 result.value = values; 20582 onRest2(result, this, this._item); 20583 }); 20584 } 20585 } 20586 eventObserved(event) { 20587 if (event.type == "change") { 20588 this._changed.add(event.parent); 20589 if (!event.idle) { 20590 this._active.add(event.parent); 20591 } 20592 } else if (event.type == "idle") { 20593 this._active.delete(event.parent); 20594 } else return; 20595 raf.onFrame(this._onFrame); 20596 } 20597 }; 20598 function flushUpdateQueue(ctrl, queue) { 20599 return Promise.all(queue.map((props) => flushUpdate(ctrl, props))).then((results) => getCombinedResult(ctrl, results)); 20600 } 20601 async function flushUpdate(ctrl, props, isLoop) { 20602 const { 20603 keys, 20604 to: to2, 20605 from, 20606 loop: loop2, 20607 onRest, 20608 onResolve 20609 } = props; 20610 const defaults2 = is.obj(props.default) && props.default; 20611 if (loop2) { 20612 props.loop = false; 20613 } 20614 if (to2 === false) props.to = null; 20615 if (from === false) props.from = null; 20616 const asyncTo = is.arr(to2) || is.fun(to2) ? to2 : void 0; 20617 if (asyncTo) { 20618 props.to = void 0; 20619 props.onRest = void 0; 20620 if (defaults2) { 20621 defaults2.onRest = void 0; 20622 } 20623 } else { 20624 each(BATCHED_EVENTS, (key) => { 20625 const handler = props[key]; 20626 if (is.fun(handler)) { 20627 const queue = ctrl["_events"][key]; 20628 props[key] = ({ 20629 finished, 20630 cancelled 20631 }) => { 20632 const result2 = queue.get(handler); 20633 if (result2) { 20634 if (!finished) result2.finished = false; 20635 if (cancelled) result2.cancelled = true; 20636 } else { 20637 queue.set(handler, { 20638 value: null, 20639 finished: finished || false, 20640 cancelled: cancelled || false 20641 }); 20642 } 20643 }; 20644 if (defaults2) { 20645 defaults2[key] = props[key]; 20646 } 20647 } 20648 }); 20649 } 20650 const state = ctrl["_state"]; 20651 if (props.pause === !state.paused) { 20652 state.paused = props.pause; 20653 flushCalls(props.pause ? state.pauseQueue : state.resumeQueue); 20654 } else if (state.paused) { 20655 props.pause = true; 20656 } 20657 const promises = (keys || Object.keys(ctrl.springs)).map((key) => ctrl.springs[key].start(props)); 20658 const cancel = props.cancel === true || getDefaultProp(props, "cancel") === true; 20659 if (asyncTo || cancel && state.asyncId) { 20660 promises.push(scheduleProps(++ctrl["_lastAsyncId"], { 20661 props, 20662 state, 20663 actions: { 20664 pause: noop3, 20665 resume: noop3, 20666 start(props2, resolve) { 20667 if (cancel) { 20668 stopAsync(state, ctrl["_lastAsyncId"]); 20669 resolve(getCancelledResult(ctrl)); 20670 } else { 20671 props2.onRest = onRest; 20672 resolve(runAsync(asyncTo, props2, state, ctrl)); 20673 } 20674 } 20675 } 20676 })); 20677 } 20678 if (state.paused) { 20679 await new Promise((resume) => { 20680 state.resumeQueue.add(resume); 20681 }); 20682 } 20683 const result = getCombinedResult(ctrl, await Promise.all(promises)); 20684 if (loop2 && result.finished && !(isLoop && result.noop)) { 20685 const nextProps = createLoopUpdate(props, loop2, to2); 20686 if (nextProps) { 20687 prepareKeys(ctrl, [nextProps]); 20688 return flushUpdate(ctrl, nextProps, true); 20689 } 20690 } 20691 if (onResolve) { 20692 raf.batchedUpdates(() => onResolve(result, ctrl, ctrl.item)); 20693 } 20694 return result; 20695 } 20696 function createSpring(key, observer) { 20697 const spring = new SpringValue(); 20698 spring.key = key; 20699 if (observer) { 20700 addFluidObserver(spring, observer); 20701 } 20702 return spring; 20703 } 20704 function prepareSprings(springs, props, create6) { 20705 if (props.keys) { 20706 each(props.keys, (key) => { 20707 const spring = springs[key] || (springs[key] = create6(key)); 20708 spring["_prepareNode"](props); 20709 }); 20710 } 20711 } 20712 function prepareKeys(ctrl, queue) { 20713 each(queue, (props) => { 20714 prepareSprings(ctrl.springs, props, (key) => { 20715 return createSpring(key, ctrl); 20716 }); 20717 }); 20718 } 20719 function _objectWithoutPropertiesLoose(source, excluded) { 20720 if (source == null) return {}; 20721 var target = {}; 20722 var sourceKeys = Object.keys(source); 20723 var key, i2; 20724 for (i2 = 0; i2 < sourceKeys.length; i2++) { 20725 key = sourceKeys[i2]; 20726 if (excluded.indexOf(key) >= 0) continue; 20727 target[key] = source[key]; 20728 } 20729 return target; 20730 } 20731 var _excluded$3 = ["children"]; 20732 var SpringContext = (_ref) => { 20733 let { 20734 children 20735 } = _ref, props = _objectWithoutPropertiesLoose(_ref, _excluded$3); 20736 const inherited = (0, import_react3.useContext)(ctx); 20737 const pause = props.pause || !!inherited.pause, immediate = props.immediate || !!inherited.immediate; 20738 props = useMemoOne(() => ({ 20739 pause, 20740 immediate 20741 }), [pause, immediate]); 20742 const { 20743 Provider: Provider2 20744 } = ctx; 20745 return React2.createElement(Provider2, { 20746 value: props 20747 }, children); 20748 }; 20749 var ctx = makeContext(SpringContext, {}); 20750 SpringContext.Provider = ctx.Provider; 20751 SpringContext.Consumer = ctx.Consumer; 20752 function makeContext(target, init) { 20753 Object.assign(target, React2.createContext(init)); 20754 target.Provider._context = target; 20755 target.Consumer._context = target; 20756 return target; 20757 } 20758 var TransitionPhase; 20759 (function(TransitionPhase2) { 20760 TransitionPhase2["MOUNT"] = "mount"; 20761 TransitionPhase2["ENTER"] = "enter"; 20762 TransitionPhase2["UPDATE"] = "update"; 20763 TransitionPhase2["LEAVE"] = "leave"; 20764 })(TransitionPhase || (TransitionPhase = {})); 20765 var Interpolation = class extends FrameValue { 20766 constructor(source, args) { 20767 super(); 20768 this.key = void 0; 20769 this.idle = true; 20770 this.calc = void 0; 20771 this._active = /* @__PURE__ */ new Set(); 20772 this.source = source; 20773 this.calc = createInterpolator(...args); 20774 const value = this._get(); 20775 const nodeType = getAnimatedType(value); 20776 setAnimated(this, nodeType.create(value)); 20777 } 20778 advance(_dt) { 20779 const value = this._get(); 20780 const oldValue = this.get(); 20781 if (!isEqual(value, oldValue)) { 20782 getAnimated(this).setValue(value); 20783 this._onChange(value, this.idle); 20784 } 20785 if (!this.idle && checkIdle(this._active)) { 20786 becomeIdle(this); 20787 } 20788 } 20789 _get() { 20790 const inputs = is.arr(this.source) ? this.source.map(getFluidValue) : toArray(getFluidValue(this.source)); 20791 return this.calc(...inputs); 20792 } 20793 _start() { 20794 if (this.idle && !checkIdle(this._active)) { 20795 this.idle = false; 20796 each(getPayload(this), (node) => { 20797 node.done = false; 20798 }); 20799 if (globals.skipAnimation) { 20800 raf.batchedUpdates(() => this.advance()); 20801 becomeIdle(this); 20802 } else { 20803 frameLoop.start(this); 20804 } 20805 } 20806 } 20807 _attach() { 20808 let priority2 = 1; 20809 each(toArray(this.source), (source) => { 20810 if (hasFluidValue(source)) { 20811 addFluidObserver(source, this); 20812 } 20813 if (isFrameValue(source)) { 20814 if (!source.idle) { 20815 this._active.add(source); 20816 } 20817 priority2 = Math.max(priority2, source.priority + 1); 20818 } 20819 }); 20820 this.priority = priority2; 20821 this._start(); 20822 } 20823 _detach() { 20824 each(toArray(this.source), (source) => { 20825 if (hasFluidValue(source)) { 20826 removeFluidObserver(source, this); 20827 } 20828 }); 20829 this._active.clear(); 20830 becomeIdle(this); 20831 } 20832 eventObserved(event) { 20833 if (event.type == "change") { 20834 if (event.idle) { 20835 this.advance(); 20836 } else { 20837 this._active.add(event.parent); 20838 this._start(); 20839 } 20840 } else if (event.type == "idle") { 20841 this._active.delete(event.parent); 20842 } else if (event.type == "priority") { 20843 this.priority = toArray(this.source).reduce((highest, parent) => Math.max(highest, (isFrameValue(parent) ? parent.priority : 0) + 1), 0); 20844 } 20845 } 20846 }; 20847 function isIdle(source) { 20848 return source.idle !== false; 20849 } 20850 function checkIdle(active) { 20851 return !active.size || Array.from(active).every(isIdle); 20852 } 20853 function becomeIdle(self) { 20854 if (!self.idle) { 20855 self.idle = true; 20856 each(getPayload(self), (node) => { 20857 node.done = true; 20858 }); 20859 callFluidObservers(self, { 20860 type: "idle", 20861 parent: self 20862 }); 20863 } 20864 } 20865 globals.assign({ 20866 createStringInterpolator, 20867 to: (source, args) => new Interpolation(source, args) 20868 }); 20869 var update2 = frameLoop.advance; 20870 20871 // node_modules/@react-spring/web/dist/react-spring-web.esm.js 20872 var import_react_dom = __toESM(require_react_dom()); 20873 function _objectWithoutPropertiesLoose2(source, excluded) { 20874 if (source == null) return {}; 20875 var target = {}; 20876 var sourceKeys = Object.keys(source); 20877 var key, i2; 20878 for (i2 = 0; i2 < sourceKeys.length; i2++) { 20879 key = sourceKeys[i2]; 20880 if (excluded.indexOf(key) >= 0) continue; 20881 target[key] = source[key]; 20882 } 20883 return target; 20884 } 20885 var _excluded$2 = ["style", "children", "scrollTop", "scrollLeft"]; 20886 var isCustomPropRE = /^--/; 20887 function dangerousStyleValue(name, value) { 20888 if (value == null || typeof value === "boolean" || value === "") return ""; 20889 if (typeof value === "number" && value !== 0 && !isCustomPropRE.test(name) && !(isUnitlessNumber.hasOwnProperty(name) && isUnitlessNumber[name])) return value + "px"; 20890 return ("" + value).trim(); 20891 } 20892 var attributeCache = {}; 20893 function applyAnimatedValues(instance, props) { 20894 if (!instance.nodeType || !instance.setAttribute) { 20895 return false; 20896 } 20897 const isFilterElement = instance.nodeName === "filter" || instance.parentNode && instance.parentNode.nodeName === "filter"; 20898 const _ref = props, { 20899 style, 20900 children, 20901 scrollTop, 20902 scrollLeft 20903 } = _ref, attributes = _objectWithoutPropertiesLoose2(_ref, _excluded$2); 20904 const values = Object.values(attributes); 20905 const names = Object.keys(attributes).map((name) => isFilterElement || instance.hasAttribute(name) ? name : attributeCache[name] || (attributeCache[name] = name.replace(/([A-Z])/g, (n2) => "-" + n2.toLowerCase()))); 20906 if (children !== void 0) { 20907 instance.textContent = children; 20908 } 20909 for (let name in style) { 20910 if (style.hasOwnProperty(name)) { 20911 const value = dangerousStyleValue(name, style[name]); 20912 if (isCustomPropRE.test(name)) { 20913 instance.style.setProperty(name, value); 20914 } else { 20915 instance.style[name] = value; 20916 } 20917 } 20918 } 20919 names.forEach((name, i2) => { 20920 instance.setAttribute(name, values[i2]); 20921 }); 20922 if (scrollTop !== void 0) { 20923 instance.scrollTop = scrollTop; 20924 } 20925 if (scrollLeft !== void 0) { 20926 instance.scrollLeft = scrollLeft; 20927 } 20928 } 20929 var isUnitlessNumber = { 20930 animationIterationCount: true, 20931 borderImageOutset: true, 20932 borderImageSlice: true, 20933 borderImageWidth: true, 20934 boxFlex: true, 20935 boxFlexGroup: true, 20936 boxOrdinalGroup: true, 20937 columnCount: true, 20938 columns: true, 20939 flex: true, 20940 flexGrow: true, 20941 flexPositive: true, 20942 flexShrink: true, 20943 flexNegative: true, 20944 flexOrder: true, 20945 gridRow: true, 20946 gridRowEnd: true, 20947 gridRowSpan: true, 20948 gridRowStart: true, 20949 gridColumn: true, 20950 gridColumnEnd: true, 20951 gridColumnSpan: true, 20952 gridColumnStart: true, 20953 fontWeight: true, 20954 lineClamp: true, 20955 lineHeight: true, 20956 opacity: true, 20957 order: true, 20958 orphans: true, 20959 tabSize: true, 20960 widows: true, 20961 zIndex: true, 20962 zoom: true, 20963 fillOpacity: true, 20964 floodOpacity: true, 20965 stopOpacity: true, 20966 strokeDasharray: true, 20967 strokeDashoffset: true, 20968 strokeMiterlimit: true, 20969 strokeOpacity: true, 20970 strokeWidth: true 20971 }; 20972 var prefixKey = (prefix2, key) => prefix2 + key.charAt(0).toUpperCase() + key.substring(1); 20973 var prefixes = ["Webkit", "Ms", "Moz", "O"]; 20974 isUnitlessNumber = Object.keys(isUnitlessNumber).reduce((acc, prop) => { 20975 prefixes.forEach((prefix2) => acc[prefixKey(prefix2, prop)] = acc[prop]); 20976 return acc; 20977 }, isUnitlessNumber); 20978 var _excluded$1 = ["x", "y", "z"]; 20979 var domTransforms = /^(matrix|translate|scale|rotate|skew)/; 20980 var pxTransforms = /^(translate)/; 20981 var degTransforms = /^(rotate|skew)/; 20982 var addUnit = (value, unit) => is.num(value) && value !== 0 ? value + unit : value; 20983 var isValueIdentity = (value, id) => is.arr(value) ? value.every((v2) => isValueIdentity(v2, id)) : is.num(value) ? value === id : parseFloat(value) === id; 20984 var AnimatedStyle = class extends AnimatedObject { 20985 constructor(_ref) { 20986 let { 20987 x: x2, 20988 y: y2, 20989 z 20990 } = _ref, style = _objectWithoutPropertiesLoose2(_ref, _excluded$1); 20991 const inputs = []; 20992 const transforms = []; 20993 if (x2 || y2 || z) { 20994 inputs.push([x2 || 0, y2 || 0, z || 0]); 20995 transforms.push((xyz) => [`translate3d($xyz.map((v2) => addUnit(v2, "px")).join(",")})`, isValueIdentity(xyz, 0)]); 20996 } 20997 eachProp(style, (value, key) => { 20998 if (key === "transform") { 20999 inputs.push([value || ""]); 21000 transforms.push((transform) => [transform, transform === ""]); 21001 } else if (domTransforms.test(key)) { 21002 delete style[key]; 21003 if (is.und(value)) return; 21004 const unit = pxTransforms.test(key) ? "px" : degTransforms.test(key) ? "deg" : ""; 21005 inputs.push(toArray(value)); 21006 transforms.push(key === "rotate3d" ? ([x3, y3, z2, deg]) => [`rotate3d($x3},$y3},$z2},$addUnit(deg, unit)})`, isValueIdentity(deg, 0)] : (input) => [`$key}($input.map((v2) => addUnit(v2, unit)).join(",")})`, isValueIdentity(input, key.startsWith("scale") ? 1 : 0)]); 21007 } 21008 }); 21009 if (inputs.length) { 21010 style.transform = new FluidTransform(inputs, transforms); 21011 } 21012 super(style); 21013 } 21014 }; 21015 var FluidTransform = class extends FluidValue { 21016 constructor(inputs, transforms) { 21017 super(); 21018 this._value = null; 21019 this.inputs = inputs; 21020 this.transforms = transforms; 21021 } 21022 get() { 21023 return this._value || (this._value = this._get()); 21024 } 21025 _get() { 21026 let transform = ""; 21027 let identity2 = true; 21028 each(this.inputs, (input, i2) => { 21029 const arg1 = getFluidValue(input[0]); 21030 const [t3, id] = this.transforms[i2](is.arr(arg1) ? arg1 : input.map(getFluidValue)); 21031 transform += " " + t3; 21032 identity2 = identity2 && id; 21033 }); 21034 return identity2 ? "none" : transform; 21035 } 21036 observerAdded(count) { 21037 if (count == 1) each(this.inputs, (input) => each(input, (value) => hasFluidValue(value) && addFluidObserver(value, this))); 21038 } 21039 observerRemoved(count) { 21040 if (count == 0) each(this.inputs, (input) => each(input, (value) => hasFluidValue(value) && removeFluidObserver(value, this))); 21041 } 21042 eventObserved(event) { 21043 if (event.type == "change") { 21044 this._value = null; 21045 } 21046 callFluidObservers(this, event); 21047 } 21048 }; 21049 var primitives = ["a", "abbr", "address", "area", "article", "aside", "audio", "b", "base", "bdi", "bdo", "big", "blockquote", "body", "br", "button", "canvas", "caption", "cite", "code", "col", "colgroup", "data", "datalist", "dd", "del", "details", "dfn", "dialog", "div", "dl", "dt", "em", "embed", "fieldset", "figcaption", "figure", "footer", "form", "h1", "h2", "h3", "h4", "h5", "h6", "head", "header", "hgroup", "hr", "html", "i", "iframe", "img", "input", "ins", "kbd", "keygen", "label", "legend", "li", "link", "main", "map", "mark", "menu", "menuitem", "meta", "meter", "nav", "noscript", "object", "ol", "optgroup", "option", "output", "p", "param", "picture", "pre", "progress", "q", "rp", "rt", "ruby", "s", "samp", "script", "section", "select", "small", "source", "span", "strong", "style", "sub", "summary", "sup", "table", "tbody", "td", "textarea", "tfoot", "th", "thead", "time", "title", "tr", "track", "u", "ul", "var", "video", "wbr", "circle", "clipPath", "defs", "ellipse", "foreignObject", "g", "image", "line", "linearGradient", "mask", "path", "pattern", "polygon", "polyline", "radialGradient", "rect", "stop", "svg", "text", "tspan"]; 21050 var _excluded = ["scrollTop", "scrollLeft"]; 21051 globals.assign({ 21052 batchedUpdates: import_react_dom.unstable_batchedUpdates, 21053 createStringInterpolator, 21054 colors 21055 }); 21056 var host = createHost(primitives, { 21057 applyAnimatedValues, 21058 createAnimatedStyle: (style) => new AnimatedStyle(style), 21059 getComponentProps: (_ref) => { 21060 let props = _objectWithoutPropertiesLoose2(_ref, _excluded); 21061 return props; 21062 } 21063 }); 21064 var animated = host.animated; 21065 21066 // packages/block-editor/build-module/components/use-moving-animation/index.js 21067 var import_element27 = __toESM(require_element()); 21068 var import_dom2 = __toESM(require_dom()); 21069 var import_data20 = __toESM(require_data()); 21070 var BLOCK_ANIMATION_THRESHOLD = 200; 21071 function getAbsolutePosition(element) { 21072 return { 21073 top: element.offsetTop, 21074 left: element.offsetLeft 21075 }; 21076 } 21077 function useMovingAnimation({ triggerAnimationOnChange, clientId }) { 21078 const ref = (0, import_element27.useRef)(); 21079 const { 21080 isTyping: isTyping3, 21081 getGlobalBlockCount: getGlobalBlockCount2, 21082 isBlockSelected: isBlockSelected2, 21083 isFirstMultiSelectedBlock: isFirstMultiSelectedBlock2, 21084 isBlockMultiSelected: isBlockMultiSelected2, 21085 isAncestorMultiSelected: isAncestorMultiSelected2, 21086 isDraggingBlocks: isDraggingBlocks2 21087 } = (0, import_data20.useSelect)(store); 21088 const { previous, prevRect } = (0, import_element27.useMemo)( 21089 () => ({ 21090 previous: ref.current && getAbsolutePosition(ref.current), 21091 prevRect: ref.current && ref.current.getBoundingClientRect() 21092 }), 21093 [triggerAnimationOnChange] 21094 ); 21095 (0, import_element27.useLayoutEffect)(() => { 21096 if (!previous || !ref.current) { 21097 return; 21098 } 21099 const scrollContainer = (0, import_dom2.getScrollContainer)(ref.current); 21100 const isSelected = isBlockSelected2(clientId); 21101 const adjustScrolling = isSelected || isFirstMultiSelectedBlock2(clientId); 21102 const isDragging3 = isDraggingBlocks2(); 21103 function preserveScrollPosition() { 21104 if (isDragging3) { 21105 return; 21106 } 21107 if (adjustScrolling && prevRect) { 21108 const blockRect = ref.current.getBoundingClientRect(); 21109 const diff = blockRect.top - prevRect.top; 21110 if (diff) { 21111 scrollContainer.scrollTop += diff; 21112 } 21113 } 21114 } 21115 const disableAnimation = window.matchMedia("(prefers-reduced-motion: reduce)").matches || isTyping3() || getGlobalBlockCount2() > BLOCK_ANIMATION_THRESHOLD; 21116 if (disableAnimation) { 21117 preserveScrollPosition(); 21118 return; 21119 } 21120 const isPartOfSelection = isSelected || isBlockMultiSelected2(clientId) || isAncestorMultiSelected2(clientId); 21121 if (isPartOfSelection && isDragging3) { 21122 return; 21123 } 21124 const zIndex = isPartOfSelection ? "1" : ""; 21125 const controller = new Controller({ 21126 x: 0, 21127 y: 0, 21128 config: { mass: 5, tension: 2e3, friction: 200 }, 21129 onChange({ value }) { 21130 if (!ref.current) { 21131 return; 21132 } 21133 let { x: x22, y: y22 } = value; 21134 x22 = Math.round(x22); 21135 y22 = Math.round(y22); 21136 const finishedMoving = x22 === 0 && y22 === 0; 21137 ref.current.style.transformOrigin = "center center"; 21138 ref.current.style.transform = finishedMoving ? null : `translate3d($x22}px,$y22}px,0)`; 21139 ref.current.style.zIndex = zIndex; 21140 preserveScrollPosition(); 21141 } 21142 }); 21143 ref.current.style.transform = void 0; 21144 const destination = getAbsolutePosition(ref.current); 21145 const x2 = Math.round(previous.left - destination.left); 21146 const y2 = Math.round(previous.top - destination.top); 21147 controller.start({ x: 0, y: 0, from: { x: x2, y: y2 } }); 21148 return () => { 21149 controller.stop(); 21150 controller.set({ x: 0, y: 0 }); 21151 }; 21152 }, [ 21153 previous, 21154 prevRect, 21155 clientId, 21156 isTyping3, 21157 getGlobalBlockCount2, 21158 isBlockSelected2, 21159 isFirstMultiSelectedBlock2, 21160 isBlockMultiSelected2, 21161 isAncestorMultiSelected2, 21162 isDraggingBlocks2 21163 ]); 21164 return ref; 21165 } 21166 var use_moving_animation_default = useMovingAnimation; 21167 21168 // packages/block-editor/build-module/components/block-list/use-block-props/use-focus-first-element.js 21169 var import_element28 = __toESM(require_element()); 21170 var import_dom3 = __toESM(require_dom()); 21171 var import_data21 = __toESM(require_data()); 21172 21173 // packages/block-editor/build-module/utils/dom.js 21174 var BLOCK_SELECTOR = ".block-editor-block-list__block"; 21175 var APPENDER_SELECTOR = ".block-list-appender"; 21176 var BLOCK_APPENDER_CLASS = ".block-editor-button-block-appender"; 21177 function isInSameBlock(a2, b2) { 21178 return a2.closest(BLOCK_SELECTOR) === b2.closest(BLOCK_SELECTOR); 21179 } 21180 function isInsideRootBlock(blockElement, element) { 21181 const parentBlock = element.closest( 21182 [BLOCK_SELECTOR, APPENDER_SELECTOR, BLOCK_APPENDER_CLASS].join(",") 21183 ); 21184 return parentBlock === blockElement; 21185 } 21186 function getBlockClientId(node) { 21187 while (node && node.nodeType !== node.ELEMENT_NODE) { 21188 node = node.parentNode; 21189 } 21190 if (!node) { 21191 return; 21192 } 21193 const elementNode = ( 21194 /** @type {Element} */ 21195 node 21196 ); 21197 const blockNode = elementNode.closest(BLOCK_SELECTOR); 21198 if (!blockNode) { 21199 return; 21200 } 21201 return blockNode.id.slice("block-".length); 21202 } 21203 function rectUnion(rect1, rect2) { 21204 const left = Math.min(rect1.left, rect2.left); 21205 const right = Math.max(rect1.right, rect2.right); 21206 const bottom = Math.max(rect1.bottom, rect2.bottom); 21207 const top = Math.min(rect1.top, rect2.top); 21208 return new window.DOMRectReadOnly(left, top, right - left, bottom - top); 21209 } 21210 function isElementVisible(element) { 21211 const viewport = element.ownerDocument.defaultView; 21212 if (!viewport) { 21213 return false; 21214 } 21215 if (element.classList.contains("components-visually-hidden")) { 21216 return false; 21217 } 21218 const bounds = element.getBoundingClientRect(); 21219 if (bounds.width === 0 || bounds.height === 0) { 21220 return false; 21221 } 21222 if (element.checkVisibility) { 21223 return element.checkVisibility?.({ 21224 opacityProperty: true, 21225 contentVisibilityAuto: true, 21226 visibilityProperty: true 21227 }); 21228 } 21229 const style = viewport.getComputedStyle(element); 21230 if (style.display === "none" || style.visibility === "hidden" || style.opacity === "0") { 21231 return false; 21232 } 21233 return true; 21234 } 21235 function isScrollable(element) { 21236 const style = window.getComputedStyle(element); 21237 return style.overflowX === "auto" || style.overflowX === "scroll" || style.overflowY === "auto" || style.overflowY === "scroll"; 21238 } 21239 var WITH_OVERFLOW_ELEMENT_BLOCKS = ["core/navigation"]; 21240 function getElementBounds(element) { 21241 const viewport = element.ownerDocument.defaultView; 21242 if (!viewport) { 21243 return new window.DOMRectReadOnly(); 21244 } 21245 let bounds = element.getBoundingClientRect(); 21246 const dataType = element.getAttribute("data-type"); 21247 if (dataType && WITH_OVERFLOW_ELEMENT_BLOCKS.includes(dataType)) { 21248 const stack = [element]; 21249 let currentElement; 21250 while (currentElement = stack.pop()) { 21251 if (!isScrollable(currentElement)) { 21252 for (const child of currentElement.children) { 21253 if (isElementVisible(child)) { 21254 const childBounds = child.getBoundingClientRect(); 21255 bounds = rectUnion(bounds, childBounds); 21256 stack.push(child); 21257 } 21258 } 21259 } 21260 } 21261 } 21262 const left = Math.max(bounds.left, 0); 21263 const right = Math.min(bounds.right, viewport.innerWidth); 21264 bounds = new window.DOMRectReadOnly( 21265 left, 21266 bounds.top, 21267 right - left, 21268 bounds.height 21269 ); 21270 return bounds; 21271 } 21272 21273 // packages/block-editor/build-module/components/block-list/use-block-props/use-focus-first-element.js 21274 function useFocusFirstElement({ clientId, initialPosition: initialPosition2 }) { 21275 const ref = (0, import_element28.useRef)(); 21276 const { isBlockSelected: isBlockSelected2, isMultiSelecting: isMultiSelecting3, isZoomOut: isZoomOut2 } = unlock( 21277 (0, import_data21.useSelect)(store) 21278 ); 21279 (0, import_element28.useEffect)(() => { 21280 if (!isBlockSelected2(clientId) || isMultiSelecting3() || isZoomOut2()) { 21281 return; 21282 } 21283 if (initialPosition2 === void 0 || initialPosition2 === null) { 21284 return; 21285 } 21286 if (!ref.current) { 21287 return; 21288 } 21289 const { ownerDocument } = ref.current; 21290 if (isInsideRootBlock(ref.current, ownerDocument.activeElement)) { 21291 return; 21292 } 21293 const textInputs = import_dom3.focus.tabbable.find(ref.current).filter((node) => (0, import_dom3.isTextField)(node)); 21294 const isReverse = -1 === initialPosition2; 21295 const target = textInputs[isReverse ? textInputs.length - 1 : 0] || ref.current; 21296 if (!isInsideRootBlock(ref.current, target)) { 21297 ref.current.focus(); 21298 return; 21299 } 21300 if (!ref.current.getAttribute("contenteditable")) { 21301 const focusElement = import_dom3.focus.tabbable.findNext(ref.current); 21302 if (focusElement && isInsideRootBlock(ref.current, focusElement) && (0, import_dom3.isFormElement)(focusElement)) { 21303 focusElement.focus(); 21304 return; 21305 } 21306 } 21307 (0, import_dom3.placeCaretAtHorizontalEdge)(target, isReverse); 21308 }, [initialPosition2, clientId]); 21309 return ref; 21310 } 21311 21312 // packages/block-editor/build-module/components/block-list/use-block-props/use-is-hovered.js 21313 var import_compose8 = __toESM(require_compose()); 21314 function listener(event) { 21315 if (event.defaultPrevented) { 21316 return; 21317 } 21318 event.preventDefault(); 21319 event.currentTarget.classList.toggle( 21320 "is-hovered", 21321 event.type === "mouseover" 21322 ); 21323 } 21324 function useIsHovered({ isEnabled = true } = {}) { 21325 return (0, import_compose8.useRefEffect)( 21326 (node) => { 21327 if (!isEnabled) { 21328 return; 21329 } 21330 node.addEventListener("mouseout", listener); 21331 node.addEventListener("mouseover", listener); 21332 return () => { 21333 node.removeEventListener("mouseout", listener); 21334 node.removeEventListener("mouseover", listener); 21335 node.classList.remove("is-hovered"); 21336 }; 21337 }, 21338 [isEnabled] 21339 ); 21340 } 21341 21342 // packages/block-editor/build-module/components/block-list/use-block-props/use-focus-handler.js 21343 var import_data22 = __toESM(require_data()); 21344 var import_compose9 = __toESM(require_compose()); 21345 function useFocusHandler(clientId) { 21346 const { isBlockSelected: isBlockSelected2 } = (0, import_data22.useSelect)(store); 21347 const { selectBlock: selectBlock2, selectionChange: selectionChange2 } = (0, import_data22.useDispatch)(store); 21348 return (0, import_compose9.useRefEffect)( 21349 (node) => { 21350 function onFocus(event) { 21351 if (node.parentElement.closest('[contenteditable="true"]')) { 21352 return; 21353 } 21354 if (isBlockSelected2(clientId)) { 21355 if (!event.target.isContentEditable) { 21356 selectionChange2(clientId); 21357 } 21358 return; 21359 } 21360 if (!isInsideRootBlock(node, event.target)) { 21361 return; 21362 } 21363 selectBlock2(clientId); 21364 } 21365 node.addEventListener("focusin", onFocus); 21366 return () => { 21367 node.removeEventListener("focusin", onFocus); 21368 }; 21369 }, 21370 [isBlockSelected2, selectBlock2] 21371 ); 21372 } 21373 21374 // packages/block-editor/build-module/components/block-list/use-block-props/use-selected-block-event-handlers.js 21375 var import_dom6 = __toESM(require_dom()); 21376 var import_keycodes2 = __toESM(require_keycodes()); 21377 var import_data23 = __toESM(require_data()); 21378 var import_compose10 = __toESM(require_compose()); 21379 function isColorTransparent(color) { 21380 return !color || color === "transparent" || color === "rgba(0, 0, 0, 0)"; 21381 } 21382 function useEventHandlers({ clientId, isSelected }) { 21383 const { 21384 getBlockRootClientId: getBlockRootClientId2, 21385 isZoomOut: isZoomOut2, 21386 hasMultiSelection: hasMultiSelection2, 21387 isSectionBlock: isSectionBlock2, 21388 editedContentOnlySection: editedContentOnlySection2 21389 } = unlock((0, import_data23.useSelect)(store)); 21390 const { 21391 insertAfterBlock: insertAfterBlock2, 21392 removeBlock: removeBlock2, 21393 resetZoomLevel: resetZoomLevel2, 21394 startDraggingBlocks: startDraggingBlocks2, 21395 stopDraggingBlocks: stopDraggingBlocks2, 21396 editContentOnlySection: editContentOnlySection2 21397 } = unlock((0, import_data23.useDispatch)(store)); 21398 return (0, import_compose10.useRefEffect)( 21399 (node) => { 21400 if (!isSelected) { 21401 return; 21402 } 21403 function onKeyDown(event) { 21404 const { keyCode, target } = event; 21405 if (keyCode !== import_keycodes2.ENTER && keyCode !== import_keycodes2.BACKSPACE && keyCode !== import_keycodes2.DELETE) { 21406 return; 21407 } 21408 if (target !== node || (0, import_dom6.isTextField)(target)) { 21409 return; 21410 } 21411 event.preventDefault(); 21412 if (keyCode === import_keycodes2.ENTER && isZoomOut2()) { 21413 resetZoomLevel2(); 21414 } else if (keyCode === import_keycodes2.ENTER) { 21415 insertAfterBlock2(clientId); 21416 } else { 21417 removeBlock2(clientId); 21418 } 21419 } 21420 function onDragStart(event) { 21421 if (node !== event.target || node.isContentEditable || node.ownerDocument.activeElement !== node || hasMultiSelection2()) { 21422 event.preventDefault(); 21423 return; 21424 } 21425 const data = JSON.stringify({ 21426 type: "block", 21427 srcClientIds: [clientId], 21428 srcRootClientId: getBlockRootClientId2(clientId) 21429 }); 21430 event.dataTransfer.effectAllowed = "move"; 21431 event.dataTransfer.clearData(); 21432 event.dataTransfer.setData("wp-blocks", data); 21433 const { ownerDocument } = node; 21434 const { defaultView } = ownerDocument; 21435 const selection2 = defaultView.getSelection(); 21436 selection2.removeAllRanges(); 21437 const dragElement = ownerDocument.createElement("div"); 21438 dragElement.style.width = "1px"; 21439 dragElement.style.height = "1px"; 21440 dragElement.style.position = "fixed"; 21441 dragElement.style.visibility = "hidden"; 21442 ownerDocument.body.appendChild(dragElement); 21443 event.dataTransfer.setDragImage(dragElement, 0, 0); 21444 const rect = node.getBoundingClientRect(); 21445 const clone = node.cloneNode(true); 21446 clone.style.visibility = "hidden"; 21447 clone.style.display = "none"; 21448 const id = node.id; 21449 node.id = null; 21450 let _scale = 1; 21451 { 21452 let parentElement = node; 21453 while (parentElement = parentElement.parentElement) { 21454 const { scale } = defaultView.getComputedStyle(parentElement); 21455 if (scale && scale !== "none") { 21456 _scale = parseFloat(scale); 21457 break; 21458 } 21459 } 21460 } 21461 const inverted = 1 / _scale; 21462 node.after(clone); 21463 const originalNodeProperties = {}; 21464 for (const property of [ 21465 "transform", 21466 "transformOrigin", 21467 "transition", 21468 "zIndex", 21469 "position", 21470 "top", 21471 "left", 21472 "pointerEvents", 21473 "opacity", 21474 "backgroundColor" 21475 ]) { 21476 originalNodeProperties[property] = node.style[property]; 21477 } 21478 const originScrollTop = defaultView.scrollY; 21479 const originScrollLeft = defaultView.scrollX; 21480 const originClientX = event.clientX; 21481 const originClientY = event.clientY; 21482 node.style.position = "relative"; 21483 node.style.top = `$0}px`; 21484 node.style.left = `$0}px`; 21485 const originX = event.clientX - rect.left; 21486 const originY = event.clientY - rect.top; 21487 const dragScale = rect.height > 200 ? 200 / rect.height : 1; 21488 node.style.zIndex = "1000"; 21489 node.style.transformOrigin = `$originX * inverted}px $originY * inverted}px`; 21490 node.style.transition = "transform 0.2s ease-out"; 21491 node.style.transform = `scale($dragScale})`; 21492 node.style.opacity = "0.9"; 21493 if (isColorTransparent( 21494 defaultView.getComputedStyle(node).backgroundColor 21495 )) { 21496 let bgColor = "transparent"; 21497 let parentElement = node; 21498 while (parentElement = parentElement.parentElement) { 21499 const { backgroundColor } = defaultView.getComputedStyle(parentElement); 21500 if (!isColorTransparent(backgroundColor)) { 21501 bgColor = backgroundColor; 21502 break; 21503 } 21504 } 21505 node.style.backgroundColor = bgColor; 21506 } 21507 let hasStarted = false; 21508 function over(e2) { 21509 if (!hasStarted) { 21510 hasStarted = true; 21511 node.style.pointerEvents = "none"; 21512 } 21513 const scrollTop = defaultView.scrollY; 21514 const scrollLeft = defaultView.scrollX; 21515 node.style.top = `${(e2.clientY - originClientY + scrollTop - originScrollTop) * inverted}px`; 21516 node.style.left = `${(e2.clientX - originClientX + scrollLeft - originScrollLeft) * inverted}px`; 21517 } 21518 function end() { 21519 ownerDocument.removeEventListener("dragover", over); 21520 ownerDocument.removeEventListener("dragend", end); 21521 ownerDocument.removeEventListener("drop", end); 21522 ownerDocument.removeEventListener("scroll", over); 21523 for (const [property, value] of Object.entries( 21524 originalNodeProperties 21525 )) { 21526 node.style[property] = value; 21527 } 21528 clone.remove(); 21529 node.id = id; 21530 dragElement.remove(); 21531 stopDraggingBlocks2(); 21532 document.body.classList.remove( 21533 "is-dragging-components-draggable" 21534 ); 21535 ownerDocument.documentElement.classList.remove( 21536 "is-dragging" 21537 ); 21538 } 21539 ownerDocument.addEventListener("dragover", over); 21540 ownerDocument.addEventListener("dragend", end); 21541 ownerDocument.addEventListener("drop", end); 21542 ownerDocument.addEventListener("scroll", over); 21543 startDraggingBlocks2([clientId]); 21544 document.body.classList.add( 21545 "is-dragging-components-draggable" 21546 ); 21547 ownerDocument.documentElement.classList.add("is-dragging"); 21548 } 21549 node.addEventListener("keydown", onKeyDown); 21550 node.addEventListener("dragstart", onDragStart); 21551 function onDoubleClick(event) { 21552 const isSection = isSectionBlock2(clientId); 21553 const isAlreadyEditing = editedContentOnlySection2 === clientId; 21554 if (isSection && !isAlreadyEditing) { 21555 event.preventDefault(); 21556 editContentOnlySection2(clientId); 21557 } 21558 } 21559 if (window?.__experimentalContentOnlyPatternInsertion) { 21560 node.addEventListener("dblclick", onDoubleClick); 21561 } 21562 return () => { 21563 node.removeEventListener("keydown", onKeyDown); 21564 node.removeEventListener("dragstart", onDragStart); 21565 if (window?.__experimentalContentOnlyPatternInsertion) { 21566 node.removeEventListener("dblclick", onDoubleClick); 21567 } 21568 }; 21569 }, 21570 [ 21571 clientId, 21572 isSelected, 21573 getBlockRootClientId2, 21574 insertAfterBlock2, 21575 removeBlock2, 21576 isZoomOut2, 21577 resetZoomLevel2, 21578 hasMultiSelection2, 21579 startDraggingBlocks2, 21580 stopDraggingBlocks2, 21581 isSectionBlock2, 21582 editedContentOnlySection2, 21583 editContentOnlySection2 21584 ] 21585 ); 21586 } 21587 21588 // packages/block-editor/build-module/components/block-list/use-block-props/use-intersection-observer.js 21589 var import_compose11 = __toESM(require_compose()); 21590 var import_element29 = __toESM(require_element()); 21591 function useIntersectionObserver() { 21592 const observer = (0, import_element29.useContext)(IntersectionObserver); 21593 return (0, import_compose11.useRefEffect)( 21594 (node) => { 21595 if (observer) { 21596 observer.observe(node); 21597 return () => { 21598 observer.unobserve(node); 21599 }; 21600 } 21601 }, 21602 [observer] 21603 ); 21604 } 21605 21606 // packages/block-editor/build-module/components/block-list/use-block-props/use-scroll-into-view.js 21607 var import_compose12 = __toESM(require_compose()); 21608 function useScrollIntoView({ isSelected }) { 21609 const prefersReducedMotion = (0, import_compose12.useReducedMotion)(); 21610 return (0, import_compose12.useRefEffect)( 21611 (node) => { 21612 if (isSelected) { 21613 const { ownerDocument } = node; 21614 const { defaultView } = ownerDocument; 21615 if (!defaultView.IntersectionObserver) { 21616 return; 21617 } 21618 const observer = new defaultView.IntersectionObserver( 21619 (entries) => { 21620 if (!entries[0].isIntersecting) { 21621 node.scrollIntoView({ 21622 behavior: prefersReducedMotion ? "instant" : "smooth" 21623 }); 21624 } 21625 observer.disconnect(); 21626 } 21627 ); 21628 observer.observe(node); 21629 return () => { 21630 observer.disconnect(); 21631 }; 21632 } 21633 }, 21634 [isSelected] 21635 ); 21636 } 21637 21638 // packages/block-editor/build-module/components/use-flash-editable-blocks/index.js 21639 var import_compose13 = __toESM(require_compose()); 21640 var import_data24 = __toESM(require_data()); 21641 function useFlashEditableBlocks({ 21642 clientId = "", 21643 isEnabled = true 21644 } = {}) { 21645 const { getEnabledClientIdsTree: getEnabledClientIdsTree2 } = unlock((0, import_data24.useSelect)(store)); 21646 return (0, import_compose13.useRefEffect)( 21647 (element) => { 21648 if (!isEnabled) { 21649 return; 21650 } 21651 const flashEditableBlocks = () => { 21652 getEnabledClientIdsTree2(clientId).forEach( 21653 ({ clientId: id }) => { 21654 const block = element.querySelector( 21655 `[data-block="$id}"]` 21656 ); 21657 if (!block) { 21658 return; 21659 } 21660 block.classList.remove("has-editable-outline"); 21661 block.offsetWidth; 21662 block.classList.add("has-editable-outline"); 21663 } 21664 ); 21665 }; 21666 const handleClick = (event) => { 21667 const shouldFlash = event.target === element || event.target.classList.contains("is-root-container"); 21668 if (!shouldFlash) { 21669 return; 21670 } 21671 if (event.defaultPrevented) { 21672 return; 21673 } 21674 event.preventDefault(); 21675 flashEditableBlocks(); 21676 }; 21677 element.addEventListener("click", handleClick); 21678 return () => element.removeEventListener("click", handleClick); 21679 }, 21680 [isEnabled] 21681 ); 21682 } 21683 21684 // packages/block-editor/build-module/components/block-list/use-block-props/use-firefox-draggable-compatibility.js 21685 var import_compose14 = __toESM(require_compose()); 21686 var nodesByDocument = /* @__PURE__ */ new Map(); 21687 function add(doc, node) { 21688 let set = nodesByDocument.get(doc); 21689 if (!set) { 21690 set = /* @__PURE__ */ new Set(); 21691 nodesByDocument.set(doc, set); 21692 doc.addEventListener("pointerdown", down); 21693 } 21694 set.add(node); 21695 } 21696 function remove3(doc, node) { 21697 const set = nodesByDocument.get(doc); 21698 if (set) { 21699 set.delete(node); 21700 restore(node); 21701 if (set.size === 0) { 21702 nodesByDocument.delete(doc); 21703 doc.removeEventListener("pointerdown", down); 21704 } 21705 } 21706 } 21707 function restore(node) { 21708 const prevDraggable = node.getAttribute("data-draggable"); 21709 if (prevDraggable) { 21710 node.removeAttribute("data-draggable"); 21711 if (prevDraggable === "true" && !node.getAttribute("draggable")) { 21712 node.setAttribute("draggable", "true"); 21713 } 21714 } 21715 } 21716 function down(event) { 21717 const { target } = event; 21718 const { ownerDocument, isContentEditable, tagName } = target; 21719 const isInputOrTextArea = ["INPUT", "TEXTAREA"].includes(tagName); 21720 const nodes = nodesByDocument.get(ownerDocument); 21721 if (isContentEditable || isInputOrTextArea) { 21722 for (const node of nodes) { 21723 if (node.getAttribute("draggable") === "true" && node.contains(target)) { 21724 node.removeAttribute("draggable"); 21725 node.setAttribute("data-draggable", "true"); 21726 } 21727 } 21728 } else { 21729 for (const node of nodes) { 21730 restore(node); 21731 } 21732 } 21733 } 21734 function useFirefoxDraggableCompatibility() { 21735 return (0, import_compose14.useRefEffect)((node) => { 21736 add(node.ownerDocument, node); 21737 return () => { 21738 remove3(node.ownerDocument, node); 21739 }; 21740 }, []); 21741 } 21742 21743 // packages/block-editor/build-module/components/block-list/use-block-props/index.js 21744 function useBlockProps(props = {}, { __unstableIsHtml } = {}) { 21745 const { 21746 clientId, 21747 className, 21748 wrapperProps = {}, 21749 isAligned, 21750 index, 21751 mode: mode2, 21752 name, 21753 blockApiVersion, 21754 blockTitle, 21755 isSelected, 21756 isSubtreeDisabled, 21757 hasOverlay, 21758 initialPosition: initialPosition2, 21759 blockEditingMode, 21760 isHighlighted, 21761 isMultiSelected, 21762 isPartiallySelected, 21763 isReusable, 21764 isDragging: isDragging3, 21765 hasChildSelected, 21766 isEditingDisabled, 21767 hasEditableOutline, 21768 isEditingContentOnlySection, 21769 defaultClassName, 21770 isSectionBlock: isSectionBlock2, 21771 isWithinSectionBlock, 21772 canMove, 21773 isBlockHidden: isBlockHidden2 21774 } = (0, import_element30.useContext)(PrivateBlockContext); 21775 const blockLabel = (0, import_i18n24.sprintf)((0, import_i18n24.__)("Block: %s"), blockTitle); 21776 const htmlSuffix = mode2 === "html" && !__unstableIsHtml ? "-visual" : ""; 21777 const ffDragRef = useFirefoxDraggableCompatibility(); 21778 const isHoverEnabled = !isWithinSectionBlock; 21779 const mergedRefs = (0, import_compose15.useMergeRefs)([ 21780 props.ref, 21781 useFocusFirstElement({ clientId, initialPosition: initialPosition2 }), 21782 useBlockRefProvider(clientId), 21783 useFocusHandler(clientId), 21784 useEventHandlers({ clientId, isSelected }), 21785 useIsHovered({ isEnabled: isHoverEnabled }), 21786 useIntersectionObserver(), 21787 use_moving_animation_default({ triggerAnimationOnChange: index, clientId }), 21788 (0, import_compose15.useDisabled)({ isDisabled: !hasOverlay }), 21789 useFlashEditableBlocks({ 21790 clientId, 21791 isEnabled: isSectionBlock2 21792 }), 21793 useScrollIntoView({ isSelected }), 21794 canMove ? ffDragRef : void 0 21795 ]); 21796 const blockEditContext = useBlockEditContext(); 21797 const hasBlockBindings = !!blockEditContext[blockBindingsKey]; 21798 const bindingsStyle = hasBlockBindings ? { 21799 "--wp-admin-theme-color": "var(--wp-block-synced-color)", 21800 "--wp-admin-theme-color--rgb": "var(--wp-block-synced-color--rgb)" 21801 } : {}; 21802 if (blockApiVersion < 2 && clientId === blockEditContext.clientId) { 21803 (0, import_warning4.default)( 21804 `Block type "$name}" must support API version 2 or higher to work correctly with "useBlockProps" method.` 21805 ); 21806 } 21807 let hasNegativeMargin = false; 21808 if (wrapperProps?.style?.marginTop?.charAt(0) === "-" || wrapperProps?.style?.marginBottom?.charAt(0) === "-" || wrapperProps?.style?.marginLeft?.charAt(0) === "-" || wrapperProps?.style?.marginRight?.charAt(0) === "-") { 21809 hasNegativeMargin = true; 21810 } 21811 return { 21812 tabIndex: blockEditingMode === "disabled" ? -1 : 0, 21813 draggable: canMove && !hasChildSelected ? true : void 0, 21814 ...wrapperProps, 21815 ...props, 21816 ref: mergedRefs, 21817 id: `block-$clientId}$htmlSuffix}`, 21818 role: "document", 21819 "aria-label": blockLabel, 21820 "data-block": clientId, 21821 "data-type": name, 21822 "data-title": blockTitle, 21823 inert: isSubtreeDisabled ? "true" : void 0, 21824 className: clsx_default( 21825 "block-editor-block-list__block", 21826 { 21827 // The wp-block className is important for editor styles. 21828 "wp-block": !isAligned, 21829 "has-block-overlay": hasOverlay, 21830 "is-selected": isSelected, 21831 "is-highlighted": isHighlighted, 21832 "is-multi-selected": isMultiSelected, 21833 "is-partially-selected": isPartiallySelected, 21834 "is-reusable": isReusable, 21835 "is-dragging": isDragging3, 21836 "has-child-selected": hasChildSelected, 21837 "is-editing-disabled": isEditingDisabled, 21838 "has-editable-outline": hasEditableOutline, 21839 "has-negative-margin": hasNegativeMargin, 21840 "is-editing-content-only-section": isEditingContentOnlySection, 21841 "is-block-hidden": isBlockHidden2 21842 }, 21843 className, 21844 props.className, 21845 wrapperProps.className, 21846 defaultClassName 21847 ), 21848 style: { ...wrapperProps.style, ...props.style, ...bindingsStyle } 21849 }; 21850 } 21851 useBlockProps.save = import_blocks19.__unstableGetBlockProps; 21852 21853 // packages/block-editor/build-module/components/block-list/block.js 21854 var import_jsx_runtime145 = __toESM(require_jsx_runtime()); 21855 function mergeWrapperProps(propsA, propsB) { 21856 const newProps = { 21857 ...propsA, 21858 ...propsB 21859 }; 21860 if (propsA?.hasOwnProperty("className") && propsB?.hasOwnProperty("className")) { 21861 newProps.className = clsx_default(propsA.className, propsB.className); 21862 } 21863 if (propsA?.hasOwnProperty("style") && propsB?.hasOwnProperty("style")) { 21864 newProps.style = { ...propsA.style, ...propsB.style }; 21865 } 21866 return newProps; 21867 } 21868 function Block({ children, isHtml, ...props }) { 21869 return /* @__PURE__ */ (0, import_jsx_runtime145.jsx)("div", { ...useBlockProps(props, { __unstableIsHtml: isHtml }), children }); 21870 } 21871 function BlockListBlock({ 21872 block: { __unstableBlockSource }, 21873 mode: mode2, 21874 isLocked, 21875 canRemove, 21876 clientId, 21877 isSelected, 21878 isSelectionEnabled: isSelectionEnabled3, 21879 className, 21880 __unstableLayoutClassNames: layoutClassNames, 21881 name, 21882 isValid: isValid2, 21883 attributes, 21884 wrapperProps, 21885 setAttributes, 21886 onReplace, 21887 onRemove, 21888 onInsertBlocksAfter, 21889 onMerge, 21890 toggleSelection: toggleSelection2 21891 }) { 21892 const { 21893 mayDisplayControls, 21894 mayDisplayParentControls, 21895 themeSupportsLayout, 21896 ...context 21897 } = (0, import_element31.useContext)(PrivateBlockContext); 21898 const parentLayout = useLayout() || {}; 21899 let blockEdit = /* @__PURE__ */ (0, import_jsx_runtime145.jsx)( 21900 BlockEdit, 21901 { 21902 name, 21903 isSelected, 21904 attributes, 21905 setAttributes, 21906 insertBlocksAfter: isLocked ? void 0 : onInsertBlocksAfter, 21907 onReplace: canRemove ? onReplace : void 0, 21908 onRemove: canRemove ? onRemove : void 0, 21909 mergeBlocks: canRemove ? onMerge : void 0, 21910 clientId, 21911 isSelectionEnabled: isSelectionEnabled3, 21912 toggleSelection: toggleSelection2, 21913 __unstableLayoutClassNames: layoutClassNames, 21914 __unstableParentLayout: Object.keys(parentLayout).length ? parentLayout : void 0, 21915 mayDisplayControls, 21916 mayDisplayParentControls, 21917 blockEditingMode: context.blockEditingMode, 21918 isPreviewMode: context.isPreviewMode 21919 } 21920 ); 21921 const blockType = (0, import_blocks20.getBlockType)(name); 21922 if (blockType?.getEditWrapperProps) { 21923 wrapperProps = mergeWrapperProps( 21924 wrapperProps, 21925 blockType.getEditWrapperProps(attributes) 21926 ); 21927 } 21928 const isAligned = wrapperProps && !!wrapperProps["data-align"] && !themeSupportsLayout; 21929 const isSticky = className?.includes("is-position-sticky"); 21930 if (isAligned) { 21931 blockEdit = /* @__PURE__ */ (0, import_jsx_runtime145.jsx)( 21932 "div", 21933 { 21934 className: clsx_default("wp-block", isSticky && className), 21935 "data-align": wrapperProps["data-align"], 21936 children: blockEdit 21937 } 21938 ); 21939 } 21940 let block; 21941 if (!isValid2) { 21942 const saveContent = __unstableBlockSource ? (0, import_blocks20.serializeRawBlock)(__unstableBlockSource) : (0, import_blocks20.getSaveContent)(blockType, attributes); 21943 block = /* @__PURE__ */ (0, import_jsx_runtime145.jsxs)(Block, { className: "has-warning", children: [ 21944 /* @__PURE__ */ (0, import_jsx_runtime145.jsx)(BlockInvalidWarning, { clientId }), 21945 /* @__PURE__ */ (0, import_jsx_runtime145.jsx)(import_element31.RawHTML, { children: (0, import_dom7.safeHTML)(saveContent) }) 21946 ] }); 21947 } else if (mode2 === "html") { 21948 block = /* @__PURE__ */ (0, import_jsx_runtime145.jsxs)(import_jsx_runtime145.Fragment, { children: [ 21949 /* @__PURE__ */ (0, import_jsx_runtime145.jsx)("div", { style: { display: "none" }, children: blockEdit }), 21950 /* @__PURE__ */ (0, import_jsx_runtime145.jsx)(Block, { isHtml: true, children: /* @__PURE__ */ (0, import_jsx_runtime145.jsx)(block_html_default, { clientId }) }) 21951 ] }); 21952 } else if (blockType?.apiVersion > 1) { 21953 block = blockEdit; 21954 } else { 21955 block = /* @__PURE__ */ (0, import_jsx_runtime145.jsx)(Block, { children: blockEdit }); 21956 } 21957 const { "data-align": dataAlign, ...restWrapperProps } = wrapperProps ?? {}; 21958 const updatedWrapperProps = { 21959 ...restWrapperProps, 21960 className: clsx_default( 21961 restWrapperProps.className, 21962 dataAlign && themeSupportsLayout && `align$dataAlign}`, 21963 !(dataAlign && isSticky) && className 21964 ) 21965 }; 21966 return /* @__PURE__ */ (0, import_jsx_runtime145.jsx)( 21967 PrivateBlockContext.Provider, 21968 { 21969 value: { 21970 wrapperProps: updatedWrapperProps, 21971 isAligned, 21972 ...context 21973 }, 21974 children: /* @__PURE__ */ (0, import_jsx_runtime145.jsx)( 21975 block_crash_boundary_default, 21976 { 21977 fallback: /* @__PURE__ */ (0, import_jsx_runtime145.jsx)(Block, { className: "has-warning", children: /* @__PURE__ */ (0, import_jsx_runtime145.jsx)(block_crash_warning_default, {}) }), 21978 children: block 21979 } 21980 ) 21981 } 21982 ); 21983 } 21984 var applyWithDispatch = (0, import_data25.withDispatch)((dispatch, ownProps, registry) => { 21985 const { 21986 updateBlockAttributes: updateBlockAttributes2, 21987 insertBlocks: insertBlocks2, 21988 mergeBlocks: mergeBlocks2, 21989 replaceBlocks: replaceBlocks2, 21990 toggleSelection: toggleSelection2, 21991 __unstableMarkLastChangeAsPersistent: __unstableMarkLastChangeAsPersistent2, 21992 moveBlocksToPosition: moveBlocksToPosition2, 21993 removeBlock: removeBlock2, 21994 selectBlock: selectBlock2 21995 } = dispatch(store); 21996 return { 21997 setAttributes(nextAttributes) { 21998 const { getMultiSelectedBlockClientIds: getMultiSelectedBlockClientIds2 } = registry.select(store); 21999 const multiSelectedBlockClientIds = getMultiSelectedBlockClientIds2(); 22000 const { clientId, attributes } = ownProps; 22001 const clientIds = multiSelectedBlockClientIds.length ? multiSelectedBlockClientIds : [clientId]; 22002 const newAttributes = typeof nextAttributes === "function" ? nextAttributes(attributes) : nextAttributes; 22003 updateBlockAttributes2(clientIds, newAttributes); 22004 }, 22005 onInsertBlocks(blocks2, index) { 22006 const { rootClientId } = ownProps; 22007 insertBlocks2(blocks2, index, rootClientId); 22008 }, 22009 onInsertBlocksAfter(blocks2) { 22010 const { clientId, rootClientId } = ownProps; 22011 const { getBlockIndex: getBlockIndex2 } = registry.select(store); 22012 const index = getBlockIndex2(clientId); 22013 insertBlocks2(blocks2, index + 1, rootClientId); 22014 }, 22015 onMerge(forward) { 22016 const { clientId, rootClientId } = ownProps; 22017 const { 22018 getPreviousBlockClientId: getPreviousBlockClientId2, 22019 getNextBlockClientId: getNextBlockClientId2, 22020 getBlock: getBlock2, 22021 getBlockAttributes: getBlockAttributes3, 22022 getBlockName: getBlockName2, 22023 getBlockOrder: getBlockOrder2, 22024 getBlockIndex: getBlockIndex2, 22025 getBlockRootClientId: getBlockRootClientId2, 22026 canInsertBlockType: canInsertBlockType2 22027 } = registry.select(store); 22028 function switchToDefaultOrRemove() { 22029 const block = getBlock2(clientId); 22030 const defaultBlockName = (0, import_blocks20.getDefaultBlockName)(); 22031 const defaultBlockType = (0, import_blocks20.getBlockType)(defaultBlockName); 22032 if (getBlockName2(clientId) !== defaultBlockName) { 22033 const replacement = (0, import_blocks20.switchToBlockType)( 22034 block, 22035 defaultBlockName 22036 ); 22037 if (replacement && replacement.length) { 22038 replaceBlocks2(clientId, replacement); 22039 } 22040 } else if ((0, import_blocks20.isUnmodifiedDefaultBlock)(block)) { 22041 const nextBlockClientId = getNextBlockClientId2(clientId); 22042 if (nextBlockClientId) { 22043 registry.batch(() => { 22044 removeBlock2(clientId); 22045 selectBlock2(nextBlockClientId); 22046 }); 22047 } 22048 } else if (defaultBlockType.merge) { 22049 const attributes = defaultBlockType.merge( 22050 {}, 22051 block.attributes 22052 ); 22053 replaceBlocks2( 22054 [clientId], 22055 [(0, import_blocks20.createBlock)(defaultBlockName, attributes)] 22056 ); 22057 } 22058 } 22059 function moveFirstItemUp(_clientId, changeSelection = true) { 22060 const wrapperBlockName = getBlockName2(_clientId); 22061 const wrapperBlockType = (0, import_blocks20.getBlockType)(wrapperBlockName); 22062 const isTextualWrapper = wrapperBlockType.category === "text"; 22063 const targetRootClientId = getBlockRootClientId2(_clientId); 22064 const blockOrder = getBlockOrder2(_clientId); 22065 const [firstClientId] = blockOrder; 22066 if (blockOrder.length === 1 && (0, import_blocks20.isUnmodifiedBlock)(getBlock2(firstClientId))) { 22067 removeBlock2(_clientId); 22068 } else if (isTextualWrapper) { 22069 registry.batch(() => { 22070 if (canInsertBlockType2( 22071 getBlockName2(firstClientId), 22072 targetRootClientId 22073 )) { 22074 moveBlocksToPosition2( 22075 [firstClientId], 22076 _clientId, 22077 targetRootClientId, 22078 getBlockIndex2(_clientId) 22079 ); 22080 } else { 22081 const replacement = (0, import_blocks20.switchToBlockType)( 22082 getBlock2(firstClientId), 22083 (0, import_blocks20.getDefaultBlockName)() 22084 ); 22085 if (replacement && replacement.length && replacement.every( 22086 (block) => canInsertBlockType2( 22087 block.name, 22088 targetRootClientId 22089 ) 22090 )) { 22091 insertBlocks2( 22092 replacement, 22093 getBlockIndex2(_clientId), 22094 targetRootClientId, 22095 changeSelection 22096 ); 22097 removeBlock2(firstClientId, false); 22098 } else { 22099 switchToDefaultOrRemove(); 22100 } 22101 } 22102 if (!getBlockOrder2(_clientId).length && (0, import_blocks20.isUnmodifiedBlock)(getBlock2(_clientId))) { 22103 removeBlock2(_clientId, false); 22104 } 22105 }); 22106 } else { 22107 switchToDefaultOrRemove(); 22108 } 22109 } 22110 if (forward) { 22111 if (rootClientId) { 22112 const nextRootClientId = getNextBlockClientId2(rootClientId); 22113 if (nextRootClientId) { 22114 if (getBlockName2(rootClientId) === getBlockName2(nextRootClientId)) { 22115 const rootAttributes = getBlockAttributes3(rootClientId); 22116 const previousRootAttributes = getBlockAttributes3(nextRootClientId); 22117 if (Object.keys(rootAttributes).every( 22118 (key) => rootAttributes[key] === previousRootAttributes[key] 22119 )) { 22120 registry.batch(() => { 22121 moveBlocksToPosition2( 22122 getBlockOrder2(nextRootClientId), 22123 nextRootClientId, 22124 rootClientId 22125 ); 22126 removeBlock2(nextRootClientId, false); 22127 }); 22128 return; 22129 } 22130 } else { 22131 mergeBlocks2(rootClientId, nextRootClientId); 22132 return; 22133 } 22134 } 22135 } 22136 const nextBlockClientId = getNextBlockClientId2(clientId); 22137 if (!nextBlockClientId) { 22138 return; 22139 } 22140 if (getBlockOrder2(nextBlockClientId).length) { 22141 moveFirstItemUp(nextBlockClientId, false); 22142 } else { 22143 mergeBlocks2(clientId, nextBlockClientId); 22144 } 22145 } else { 22146 const previousBlockClientId = getPreviousBlockClientId2(clientId); 22147 if (previousBlockClientId) { 22148 mergeBlocks2(previousBlockClientId, clientId); 22149 } else if (rootClientId) { 22150 const previousRootClientId = getPreviousBlockClientId2(rootClientId); 22151 if (previousRootClientId && getBlockName2(rootClientId) === getBlockName2(previousRootClientId)) { 22152 const rootAttributes = getBlockAttributes3(rootClientId); 22153 const previousRootAttributes = getBlockAttributes3(previousRootClientId); 22154 if (Object.keys(rootAttributes).every( 22155 (key) => rootAttributes[key] === previousRootAttributes[key] 22156 )) { 22157 registry.batch(() => { 22158 moveBlocksToPosition2( 22159 getBlockOrder2(rootClientId), 22160 rootClientId, 22161 previousRootClientId 22162 ); 22163 removeBlock2(rootClientId, false); 22164 }); 22165 return; 22166 } 22167 } 22168 moveFirstItemUp(rootClientId); 22169 } else { 22170 switchToDefaultOrRemove(); 22171 } 22172 } 22173 }, 22174 onReplace(blocks2, indexToSelect, initialPosition2) { 22175 if (blocks2.length && !(0, import_blocks20.isUnmodifiedDefaultBlock)(blocks2[blocks2.length - 1])) { 22176 __unstableMarkLastChangeAsPersistent2(); 22177 } 22178 const replacementBlocks = blocks2?.length === 1 && Array.isArray(blocks2[0]) ? blocks2[0] : blocks2; 22179 replaceBlocks2( 22180 [ownProps.clientId], 22181 replacementBlocks, 22182 indexToSelect, 22183 initialPosition2 22184 ); 22185 }, 22186 onRemove() { 22187 removeBlock2(ownProps.clientId); 22188 }, 22189 toggleSelection(selectionEnabled) { 22190 toggleSelection2(selectionEnabled); 22191 } 22192 }; 22193 }); 22194 BlockListBlock = (0, import_compose16.compose)( 22195 applyWithDispatch, 22196 (0, import_components24.withFilters)("editor.BlockListBlock") 22197 )(BlockListBlock); 22198 function BlockListBlockProvider(props) { 22199 const { clientId, rootClientId } = props; 22200 const selectedProps = (0, import_data25.useSelect)( 22201 (select3) => { 22202 const { 22203 isBlockSelected: isBlockSelected2, 22204 getBlockMode: getBlockMode2, 22205 isSelectionEnabled: isSelectionEnabled22, 22206 getTemplateLock: getTemplateLock2, 22207 isSectionBlock: _isSectionBlock, 22208 getParentSectionBlock: getParentSectionBlock2, 22209 getBlockWithoutAttributes: getBlockWithoutAttributes2, 22210 getBlockAttributes: getBlockAttributes3, 22211 canRemoveBlock: canRemoveBlock2, 22212 canMoveBlock: canMoveBlock2, 22213 getSettings: getSettings8, 22214 getEditedContentOnlySection: getEditedContentOnlySection2, 22215 getBlockEditingMode: getBlockEditingMode2, 22216 getBlockName: getBlockName2, 22217 isFirstMultiSelectedBlock: isFirstMultiSelectedBlock2, 22218 getMultiSelectedBlockClientIds: getMultiSelectedBlockClientIds2, 22219 hasSelectedInnerBlock: hasSelectedInnerBlock2, 22220 getBlocksByName: getBlocksByName2, 22221 getBlockIndex: getBlockIndex2, 22222 isBlockMultiSelected: isBlockMultiSelected2, 22223 isBlockSubtreeDisabled: isBlockSubtreeDisabled2, 22224 isBlockHighlighted: isBlockHighlighted2, 22225 __unstableIsFullySelected: __unstableIsFullySelected2, 22226 __unstableSelectionHasUnmergeableBlock: __unstableSelectionHasUnmergeableBlock2, 22227 isBlockBeingDragged: isBlockBeingDragged2, 22228 isDragging: isDragging22, 22229 __unstableHasActiveBlockOverlayActive: __unstableHasActiveBlockOverlayActive2, 22230 getSelectedBlocksInitialCaretPosition: getSelectedBlocksInitialCaretPosition2 22231 } = unlock(select3(store)); 22232 const blockWithoutAttributes2 = getBlockWithoutAttributes2(clientId); 22233 if (!blockWithoutAttributes2) { 22234 return; 22235 } 22236 const { 22237 hasBlockSupport: _hasBlockSupport, 22238 getActiveBlockVariation 22239 } = select3(import_blocks20.store); 22240 const attributes2 = getBlockAttributes3(clientId); 22241 const { name: blockName, isValid: isValid22 } = blockWithoutAttributes2; 22242 const blockType = (0, import_blocks20.getBlockType)(blockName); 22243 const { 22244 supportsLayout, 22245 isPreviewMode: isPreviewMode2, 22246 __experimentalBlockBindingsSupportedAttributes 22247 } = getSettings8(); 22248 const bindableAttributes2 = __experimentalBlockBindingsSupportedAttributes?.[blockName]; 22249 const hasLightBlockWrapper = blockType?.apiVersion > 1; 22250 const previewContext = { 22251 isPreviewMode: isPreviewMode2, 22252 blockWithoutAttributes: blockWithoutAttributes2, 22253 name: blockName, 22254 attributes: attributes2, 22255 isValid: isValid22, 22256 themeSupportsLayout: supportsLayout, 22257 index: getBlockIndex2(clientId), 22258 isReusable: (0, import_blocks20.isReusableBlock)(blockType), 22259 className: hasLightBlockWrapper ? attributes2.className : void 0, 22260 defaultClassName: hasLightBlockWrapper ? (0, import_blocks20.getBlockDefaultClassName)(blockName) : void 0, 22261 blockTitle: blockType?.title, 22262 isBlockHidden: attributes2?.metadata?.blockVisibility === false, 22263 bindableAttributes: bindableAttributes2 22264 }; 22265 if (isPreviewMode2) { 22266 return previewContext; 22267 } 22268 const { isBlockHidden: _isBlockHidden } = unlock( 22269 select3(store) 22270 ); 22271 const _isSelected = isBlockSelected2(clientId); 22272 const canRemove2 = canRemoveBlock2(clientId); 22273 const canMove2 = canMoveBlock2(clientId); 22274 const match2 = getActiveBlockVariation(blockName, attributes2); 22275 const isMultiSelected2 = isBlockMultiSelected2(clientId); 22276 const checkDeep = true; 22277 const isAncestorOfSelectedBlock = hasSelectedInnerBlock2( 22278 clientId, 22279 checkDeep 22280 ); 22281 const blockEditingMode2 = getBlockEditingMode2(clientId); 22282 const multiple = (0, import_blocks20.hasBlockSupport)(blockName, "multiple", true); 22283 const blocksWithSameName = multiple ? [] : getBlocksByName2(blockName); 22284 const isInvalid = blocksWithSameName.length && blocksWithSameName[0] !== clientId; 22285 return { 22286 ...previewContext, 22287 mode: getBlockMode2(clientId), 22288 isSelectionEnabled: isSelectionEnabled22(), 22289 isLocked: !!getTemplateLock2(rootClientId), 22290 isSectionBlock: _isSectionBlock(clientId), 22291 isWithinSectionBlock: _isSectionBlock(clientId) || !!getParentSectionBlock2(clientId), 22292 canRemove: canRemove2, 22293 canMove: canMove2, 22294 isSelected: _isSelected, 22295 isEditingContentOnlySection: getEditedContentOnlySection2() === clientId, 22296 blockEditingMode: blockEditingMode2, 22297 mayDisplayControls: _isSelected || isFirstMultiSelectedBlock2(clientId) && getMultiSelectedBlockClientIds2().every( 22298 (id) => getBlockName2(id) === blockName 22299 ), 22300 mayDisplayParentControls: _hasBlockSupport( 22301 getBlockName2(clientId), 22302 "__experimentalExposeControlsToChildren", 22303 false 22304 ) && hasSelectedInnerBlock2(clientId), 22305 blockApiVersion: blockType?.apiVersion || 1, 22306 blockTitle: match2?.title || blockType?.title, 22307 isSubtreeDisabled: blockEditingMode2 === "disabled" && isBlockSubtreeDisabled2(clientId), 22308 hasOverlay: __unstableHasActiveBlockOverlayActive2(clientId) && !isDragging22(), 22309 initialPosition: _isSelected ? getSelectedBlocksInitialCaretPosition2() : void 0, 22310 isHighlighted: isBlockHighlighted2(clientId), 22311 isMultiSelected: isMultiSelected2, 22312 isPartiallySelected: isMultiSelected2 && !__unstableIsFullySelected2() && !__unstableSelectionHasUnmergeableBlock2(), 22313 isDragging: isBlockBeingDragged2(clientId), 22314 hasChildSelected: isAncestorOfSelectedBlock, 22315 isEditingDisabled: blockEditingMode2 === "disabled", 22316 hasEditableOutline: blockEditingMode2 !== "disabled" && getBlockEditingMode2(rootClientId) === "disabled", 22317 originalBlockClientId: isInvalid ? blocksWithSameName[0] : false, 22318 isBlockHidden: _isBlockHidden(clientId) 22319 }; 22320 }, 22321 [clientId, rootClientId] 22322 ); 22323 const { 22324 isPreviewMode, 22325 // Fill values that end up as a public API and may not be defined in 22326 // preview mode. 22327 mode: mode2 = "visual", 22328 isSelectionEnabled: isSelectionEnabled3 = false, 22329 isLocked = false, 22330 canRemove = false, 22331 canMove = false, 22332 blockWithoutAttributes, 22333 name, 22334 attributes, 22335 isValid: isValid2, 22336 isSelected = false, 22337 themeSupportsLayout, 22338 isEditingContentOnlySection, 22339 blockEditingMode, 22340 mayDisplayControls, 22341 mayDisplayParentControls, 22342 index, 22343 blockApiVersion, 22344 blockTitle, 22345 isSubtreeDisabled, 22346 hasOverlay, 22347 initialPosition: initialPosition2, 22348 isHighlighted, 22349 isMultiSelected, 22350 isPartiallySelected, 22351 isReusable, 22352 isDragging: isDragging3, 22353 hasChildSelected, 22354 isSectionBlock: isSectionBlock2, 22355 isWithinSectionBlock, 22356 isEditingDisabled, 22357 hasEditableOutline, 22358 className, 22359 defaultClassName, 22360 originalBlockClientId, 22361 isBlockHidden: isBlockHidden2, 22362 bindableAttributes 22363 } = selectedProps; 22364 const block = (0, import_element31.useMemo)( 22365 () => ({ ...blockWithoutAttributes, attributes }), 22366 [blockWithoutAttributes, attributes] 22367 ); 22368 if (!selectedProps) { 22369 return null; 22370 } 22371 const privateContext = { 22372 isPreviewMode, 22373 clientId, 22374 className, 22375 index, 22376 mode: mode2, 22377 name, 22378 blockApiVersion, 22379 blockTitle, 22380 isSelected, 22381 isSubtreeDisabled, 22382 hasOverlay, 22383 initialPosition: initialPosition2, 22384 blockEditingMode, 22385 isHighlighted, 22386 isMultiSelected, 22387 isPartiallySelected, 22388 isReusable, 22389 isDragging: isDragging3, 22390 hasChildSelected, 22391 isSectionBlock: isSectionBlock2, 22392 isWithinSectionBlock, 22393 isEditingDisabled, 22394 hasEditableOutline, 22395 isEditingContentOnlySection, 22396 defaultClassName, 22397 mayDisplayControls, 22398 mayDisplayParentControls, 22399 originalBlockClientId, 22400 themeSupportsLayout, 22401 canMove, 22402 isBlockHidden: isBlockHidden2, 22403 bindableAttributes 22404 }; 22405 if (isBlockHidden2 && !isSelected && !isMultiSelected && !hasChildSelected) { 22406 return null; 22407 } 22408 return /* @__PURE__ */ (0, import_jsx_runtime145.jsx)(PrivateBlockContext.Provider, { value: privateContext, children: /* @__PURE__ */ (0, import_jsx_runtime145.jsx)( 22409 BlockListBlock, 22410 { 22411 ...props, 22412 ...{ 22413 mode: mode2, 22414 isSelectionEnabled: isSelectionEnabled3, 22415 isLocked, 22416 canRemove, 22417 canMove, 22418 // Users of the editor.BlockListBlock filter used to be able 22419 // to access the block prop. Ideally these blocks would rely 22420 // on the clientId prop only. This is kept for backward 22421 // compatibility reasons. 22422 block, 22423 name, 22424 attributes, 22425 isValid: isValid2, 22426 isSelected 22427 } 22428 } 22429 ) }); 22430 } 22431 var block_default2 = (0, import_element31.memo)(BlockListBlockProvider); 22432 22433 // packages/block-editor/build-module/components/block-list-appender/index.js 22434 var import_data61 = __toESM(require_data()); 22435 var import_blocks36 = __toESM(require_blocks()); 22436 22437 // packages/block-editor/build-module/components/default-block-appender/index.js 22438 var import_i18n60 = __toESM(require_i18n()); 22439 var import_html_entities2 = __toESM(require_html_entities()); 22440 var import_data60 = __toESM(require_data()); 22441 var import_keycodes7 = __toESM(require_keycodes()); 22442 22443 // packages/block-editor/build-module/components/inserter/index.js 22444 var import_a11y10 = __toESM(require_a11y()); 22445 var import_i18n59 = __toESM(require_i18n()); 22446 var import_components58 = __toESM(require_components()); 22447 var import_element76 = __toESM(require_element()); 22448 var import_data59 = __toESM(require_data()); 22449 var import_compose44 = __toESM(require_compose()); 22450 var import_blocks35 = __toESM(require_blocks()); 22451 22452 // packages/block-editor/build-module/components/inserter/menu.js 22453 var import_element74 = __toESM(require_element()); 22454 var import_components56 = __toESM(require_components()); 22455 var import_i18n57 = __toESM(require_i18n()); 22456 var import_compose43 = __toESM(require_compose()); 22457 var import_data57 = __toESM(require_data()); 22458 22459 // packages/block-editor/build-module/components/inserter/tips.js 22460 var import_i18n25 = __toESM(require_i18n()); 22461 var import_element32 = __toESM(require_element()); 22462 var import_components25 = __toESM(require_components()); 22463 var import_jsx_runtime146 = __toESM(require_jsx_runtime()); 22464 var globalTips = [ 22465 (0, import_element32.createInterpolateElement)( 22466 (0, import_i18n25.__)( 22467 "While writing, you can press <kbd>/</kbd> to quickly insert new blocks." 22468 ), 22469 { kbd: /* @__PURE__ */ (0, import_jsx_runtime146.jsx)("kbd", {}) } 22470 ), 22471 (0, import_element32.createInterpolateElement)( 22472 (0, import_i18n25.__)( 22473 "Indent a list by pressing <kbd>space</kbd> at the beginning of a line." 22474 ), 22475 { kbd: /* @__PURE__ */ (0, import_jsx_runtime146.jsx)("kbd", {}) } 22476 ), 22477 (0, import_element32.createInterpolateElement)( 22478 (0, import_i18n25.__)( 22479 "Outdent a list by pressing <kbd>backspace</kbd> at the beginning of a line." 22480 ), 22481 { kbd: /* @__PURE__ */ (0, import_jsx_runtime146.jsx)("kbd", {}) } 22482 ), 22483 (0, import_i18n25.__)("Drag files into the editor to automatically insert media blocks."), 22484 (0, import_i18n25.__)("Change a block's type by pressing the block icon on the toolbar.") 22485 ]; 22486 function Tips() { 22487 const [randomIndex] = (0, import_element32.useState)( 22488 Math.floor(Math.random() * globalTips.length) 22489 ); 22490 return /* @__PURE__ */ (0, import_jsx_runtime146.jsx)(import_components25.Tip, { children: globalTips[randomIndex] }); 22491 } 22492 var tips_default = Tips; 22493 22494 // packages/block-editor/build-module/components/inserter/preview-panel.js 22495 var import_blocks26 = __toESM(require_blocks()); 22496 var import_element49 = __toESM(require_element()); 22497 var import_i18n35 = __toESM(require_i18n()); 22498 22499 // packages/block-editor/build-module/components/block-card/index.js 22500 var import_components26 = __toESM(require_components()); 22501 var import_data26 = __toESM(require_data()); 22502 var import_deprecated6 = __toESM(require_deprecated()); 22503 var import_i18n26 = __toESM(require_i18n()); 22504 var import_jsx_runtime147 = __toESM(require_jsx_runtime()); 22505 var { Badge } = unlock(import_components26.privateApis); 22506 function OptionalParentSelectButton({ children, onClick }) { 22507 if (!onClick) { 22508 return children; 22509 } 22510 return /* @__PURE__ */ (0, import_jsx_runtime147.jsx)( 22511 import_components26.Button, 22512 { 22513 __next40pxDefaultSize: true, 22514 className: "block-editor-block-card__parent-select-button", 22515 onClick, 22516 children 22517 } 22518 ); 22519 } 22520 function BlockCard({ 22521 title, 22522 icon, 22523 description, 22524 blockType, 22525 className, 22526 name, 22527 allowParentNavigation, 22528 parentClientId, 22529 isChild, 22530 children, 22531 clientId 22532 }) { 22533 if (blockType) { 22534 (0, import_deprecated6.default)("`blockType` property in `BlockCard component`", { 22535 since: "5.7", 22536 alternative: "`title, icon and description` properties" 22537 }); 22538 ({ title, icon, description } = blockType); 22539 } 22540 const parentNavBlockClientId = (0, import_data26.useSelect)( 22541 (select3) => { 22542 if (parentClientId || isChild || !allowParentNavigation) { 22543 return; 22544 } 22545 const { getBlockParentsByBlockName: getBlockParentsByBlockName2 } = select3(store); 22546 return getBlockParentsByBlockName2( 22547 clientId, 22548 "core/navigation", 22549 true 22550 )[0]; 22551 }, 22552 [clientId, allowParentNavigation, isChild, parentClientId] 22553 ); 22554 const { selectBlock: selectBlock2 } = (0, import_data26.useDispatch)(store); 22555 const TitleElement = parentClientId ? "div" : "h2"; 22556 return /* @__PURE__ */ (0, import_jsx_runtime147.jsxs)( 22557 "div", 22558 { 22559 className: clsx_default( 22560 "block-editor-block-card", 22561 { 22562 "is-parent": parentClientId, 22563 "is-child": isChild 22564 }, 22565 className 22566 ), 22567 children: [ 22568 parentNavBlockClientId && // This is only used by the Navigation block for now. It's not ideal having Navigation block specific code here. 22569 /* @__PURE__ */ (0, import_jsx_runtime147.jsx)( 22570 import_components26.Button, 22571 { 22572 onClick: () => selectBlock2(parentNavBlockClientId), 22573 label: parentNavBlockClientId ? (0, import_i18n26.__)("Go to parent Navigation block") : ( 22574 // TODO - improve copy, not sure that we should use the term 'section' 22575 (0, import_i18n26.__)("Go to parent section") 22576 ), 22577 style: ( 22578 // TODO: This style override is also used in ToolsPanelHeader. 22579 // It should be supported out-of-the-box by Button. 22580 { minWidth: 24, padding: 0 } 22581 ), 22582 icon: (0, import_i18n26.isRTL)() ? chevron_right_default : chevron_left_default, 22583 size: "small" 22584 } 22585 ), 22586 isChild && /* @__PURE__ */ (0, import_jsx_runtime147.jsx)("span", { className: "block-editor-block-card__child-indicator-icon", children: /* @__PURE__ */ (0, import_jsx_runtime147.jsx)(import_components26.Icon, { icon: (0, import_i18n26.isRTL)() ? arrow_left_default : arrow_right_default }) }), 22587 /* @__PURE__ */ (0, import_jsx_runtime147.jsxs)( 22588 OptionalParentSelectButton, 22589 { 22590 onClick: parentClientId ? () => { 22591 selectBlock2(parentClientId); 22592 } : void 0, 22593 children: [ 22594 /* @__PURE__ */ (0, import_jsx_runtime147.jsx)(block_icon_default, { icon, showColors: true }), 22595 /* @__PURE__ */ (0, import_jsx_runtime147.jsxs)(import_components26.__experimentalVStack, { spacing: 1, children: [ 22596 /* @__PURE__ */ (0, import_jsx_runtime147.jsxs)(TitleElement, { className: "block-editor-block-card__title", children: [ 22597 /* @__PURE__ */ (0, import_jsx_runtime147.jsx)("span", { className: "block-editor-block-card__name", children: !!name?.length ? name : title }), 22598 !parentClientId && !isChild && !!name?.length && /* @__PURE__ */ (0, import_jsx_runtime147.jsx)(Badge, { children: title }) 22599 ] }), 22600 !parentClientId && !isChild && description && /* @__PURE__ */ (0, import_jsx_runtime147.jsx)(import_components26.__experimentalText, { className: "block-editor-block-card__description", children: description }), 22601 children 22602 ] }) 22603 ] 22604 } 22605 ) 22606 ] 22607 } 22608 ); 22609 } 22610 var block_card_default = BlockCard; 22611 22612 // packages/block-editor/build-module/components/block-preview/index.js 22613 var import_compose32 = __toESM(require_compose()); 22614 var import_data48 = __toESM(require_data()); 22615 var import_element48 = __toESM(require_element()); 22616 var import_deprecated7 = __toESM(require_deprecated()); 22617 22618 // packages/block-editor/build-module/components/provider/index.js 22619 var import_data33 = __toESM(require_data()); 22620 var import_element39 = __toESM(require_element()); 22621 var import_components27 = __toESM(require_components()); 22622 22623 // packages/upload-media/build-module/store/index.js 22624 var import_data27 = __toESM(require_data()); 22625 22626 // packages/upload-media/build-module/store/types.js 22627 var Type = /* @__PURE__ */ ((Type2) => { 22628 Type2["Unknown"] = "REDUX_UNKNOWN"; 22629 Type2["Add"] = "ADD_ITEM"; 22630 Type2["Prepare"] = "PREPARE_ITEM"; 22631 Type2["Cancel"] = "CANCEL_ITEM"; 22632 Type2["Remove"] = "REMOVE_ITEM"; 22633 Type2["PauseItem"] = "PAUSE_ITEM"; 22634 Type2["ResumeItem"] = "RESUME_ITEM"; 22635 Type2["PauseQueue"] = "PAUSE_QUEUE"; 22636 Type2["ResumeQueue"] = "RESUME_QUEUE"; 22637 Type2["OperationStart"] = "OPERATION_START"; 22638 Type2["OperationFinish"] = "OPERATION_FINISH"; 22639 Type2["AddOperations"] = "ADD_OPERATIONS"; 22640 Type2["CacheBlobUrl"] = "CACHE_BLOB_URL"; 22641 Type2["RevokeBlobUrls"] = "REVOKE_BLOB_URLS"; 22642 Type2["UpdateSettings"] = "UPDATE_SETTINGS"; 22643 return Type2; 22644 })(Type || {}); 22645 var ItemStatus = /* @__PURE__ */ ((ItemStatus2) => { 22646 ItemStatus2["Processing"] = "PROCESSING"; 22647 ItemStatus2["Paused"] = "PAUSED"; 22648 return ItemStatus2; 22649 })(ItemStatus || {}); 22650 var OperationType = /* @__PURE__ */ ((OperationType2) => { 22651 OperationType2["Prepare"] = "PREPARE"; 22652 OperationType2["Upload"] = "UPLOAD"; 22653 return OperationType2; 22654 })(OperationType || {}); 22655 22656 // packages/upload-media/build-module/store/reducer.js 22657 var noop4 = () => { 22658 }; 22659 var DEFAULT_STATE = { 22660 queue: [], 22661 queueStatus: "active", 22662 blobUrls: {}, 22663 settings: { 22664 mediaUpload: noop4 22665 } 22666 }; 22667 function reducer(state = DEFAULT_STATE, action = { type: Type.Unknown }) { 22668 switch (action.type) { 22669 case Type.PauseQueue: { 22670 return { 22671 ...state, 22672 queueStatus: "paused" 22673 }; 22674 } 22675 case Type.ResumeQueue: { 22676 return { 22677 ...state, 22678 queueStatus: "active" 22679 }; 22680 } 22681 case Type.Add: 22682 return { 22683 ...state, 22684 queue: [...state.queue, action.item] 22685 }; 22686 case Type.Cancel: 22687 return { 22688 ...state, 22689 queue: state.queue.map( 22690 (item) => item.id === action.id ? { 22691 ...item, 22692 error: action.error 22693 } : item 22694 ) 22695 }; 22696 case Type.Remove: 22697 return { 22698 ...state, 22699 queue: state.queue.filter((item) => item.id !== action.id) 22700 }; 22701 case Type.OperationStart: { 22702 return { 22703 ...state, 22704 queue: state.queue.map( 22705 (item) => item.id === action.id ? { 22706 ...item, 22707 currentOperation: action.operation 22708 } : item 22709 ) 22710 }; 22711 } 22712 case Type.AddOperations: 22713 return { 22714 ...state, 22715 queue: state.queue.map((item) => { 22716 if (item.id !== action.id) { 22717 return item; 22718 } 22719 return { 22720 ...item, 22721 operations: [ 22722 ...item.operations || [], 22723 ...action.operations 22724 ] 22725 }; 22726 }) 22727 }; 22728 case Type.OperationFinish: 22729 return { 22730 ...state, 22731 queue: state.queue.map((item) => { 22732 if (item.id !== action.id) { 22733 return item; 22734 } 22735 const operations = item.operations ? item.operations.slice(1) : []; 22736 const attachment = item.attachment || action.item.attachment ? { 22737 ...item.attachment, 22738 ...action.item.attachment 22739 } : void 0; 22740 return { 22741 ...item, 22742 currentOperation: void 0, 22743 operations, 22744 ...action.item, 22745 attachment, 22746 additionalData: { 22747 ...item.additionalData, 22748 ...action.item.additionalData 22749 } 22750 }; 22751 }) 22752 }; 22753 case Type.CacheBlobUrl: { 22754 const blobUrls = state.blobUrls[action.id] || []; 22755 return { 22756 ...state, 22757 blobUrls: { 22758 ...state.blobUrls, 22759 [action.id]: [...blobUrls, action.blobUrl] 22760 } 22761 }; 22762 } 22763 case Type.RevokeBlobUrls: { 22764 const newBlobUrls = { ...state.blobUrls }; 22765 delete newBlobUrls[action.id]; 22766 return { 22767 ...state, 22768 blobUrls: newBlobUrls 22769 }; 22770 } 22771 case Type.UpdateSettings: { 22772 return { 22773 ...state, 22774 settings: { 22775 ...state.settings, 22776 ...action.settings 22777 } 22778 }; 22779 } 22780 } 22781 return state; 22782 } 22783 var reducer_default2 = reducer; 22784 22785 // packages/upload-media/build-module/store/selectors.js 22786 var selectors_exports2 = {}; 22787 __export(selectors_exports2, { 22788 getItems: () => getItems, 22789 getSettings: () => getSettings2, 22790 isUploading: () => isUploading, 22791 isUploadingById: () => isUploadingById, 22792 isUploadingByUrl: () => isUploadingByUrl 22793 }); 22794 function getItems(state) { 22795 return state.queue; 22796 } 22797 function isUploading(state) { 22798 return state.queue.length >= 1; 22799 } 22800 function isUploadingByUrl(state, url) { 22801 return state.queue.some( 22802 (item) => item.attachment?.url === url || item.sourceUrl === url 22803 ); 22804 } 22805 function isUploadingById(state, attachmentId) { 22806 return state.queue.some( 22807 (item) => item.attachment?.id === attachmentId || item.sourceAttachmentId === attachmentId 22808 ); 22809 } 22810 function getSettings2(state) { 22811 return state.settings; 22812 } 22813 22814 // packages/upload-media/build-module/store/private-selectors.js 22815 var private_selectors_exports2 = {}; 22816 __export(private_selectors_exports2, { 22817 getAllItems: () => getAllItems, 22818 getBlobUrls: () => getBlobUrls, 22819 getItem: () => getItem, 22820 getPausedUploadForPost: () => getPausedUploadForPost, 22821 isBatchUploaded: () => isBatchUploaded, 22822 isPaused: () => isPaused2, 22823 isUploadingToPost: () => isUploadingToPost 22824 }); 22825 function getAllItems(state) { 22826 return state.queue; 22827 } 22828 function getItem(state, id) { 22829 return state.queue.find((item) => item.id === id); 22830 } 22831 function isBatchUploaded(state, batchId) { 22832 const batchItems = state.queue.filter( 22833 (item) => batchId === item.batchId 22834 ); 22835 return batchItems.length === 0; 22836 } 22837 function isUploadingToPost(state, postOrAttachmentId) { 22838 return state.queue.some( 22839 (item) => item.currentOperation === OperationType.Upload && item.additionalData.post === postOrAttachmentId 22840 ); 22841 } 22842 function getPausedUploadForPost(state, postOrAttachmentId) { 22843 return state.queue.find( 22844 (item) => item.status === ItemStatus.Paused && item.additionalData.post === postOrAttachmentId 22845 ); 22846 } 22847 function isPaused2(state) { 22848 return state.queueStatus === "paused"; 22849 } 22850 function getBlobUrls(state, id) { 22851 return state.blobUrls[id] || []; 22852 } 22853 22854 // packages/upload-media/build-module/store/actions.js 22855 var actions_exports2 = {}; 22856 __export(actions_exports2, { 22857 addItems: () => addItems, 22858 cancelItem: () => cancelItem 22859 }); 22860 22861 // node_modules/uuid/dist/esm-browser/rng.js 22862 var getRandomValues; 22863 var rnds8 = new Uint8Array(16); 22864 function rng() { 22865 if (!getRandomValues) { 22866 getRandomValues = typeof crypto !== "undefined" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto); 22867 if (!getRandomValues) { 22868 throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported"); 22869 } 22870 } 22871 return getRandomValues(rnds8); 22872 } 22873 22874 // node_modules/uuid/dist/esm-browser/stringify.js 22875 var byteToHex = []; 22876 for (let i2 = 0; i2 < 256; ++i2) { 22877 byteToHex.push((i2 + 256).toString(16).slice(1)); 22878 } 22879 function unsafeStringify(arr, offset = 0) { 22880 return byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + "-" + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + "-" + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + "-" + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + "-" + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]; 22881 } 22882 22883 // node_modules/uuid/dist/esm-browser/native.js 22884 var randomUUID = typeof crypto !== "undefined" && crypto.randomUUID && crypto.randomUUID.bind(crypto); 22885 var native_default = { 22886 randomUUID 22887 }; 22888 22889 // node_modules/uuid/dist/esm-browser/v4.js 22890 function v4(options, buf, offset) { 22891 if (native_default.randomUUID && !buf && !options) { 22892 return native_default.randomUUID(); 22893 } 22894 options = options || {}; 22895 const rnds = options.random || (options.rng || rng)(); 22896 rnds[6] = rnds[6] & 15 | 64; 22897 rnds[8] = rnds[8] & 63 | 128; 22898 if (buf) { 22899 offset = offset || 0; 22900 for (let i2 = 0; i2 < 16; ++i2) { 22901 buf[offset + i2] = rnds[i2]; 22902 } 22903 return buf; 22904 } 22905 return unsafeStringify(rnds); 22906 } 22907 var v4_default = v4; 22908 22909 // packages/upload-media/build-module/validate-mime-type.js 22910 var import_i18n27 = __toESM(require_i18n()); 22911 22912 // packages/upload-media/build-module/upload-error.js 22913 var UploadError = class extends Error { 22914 code; 22915 file; 22916 constructor({ code, message: message2, file, cause }) { 22917 super(message2, { cause }); 22918 Object.setPrototypeOf(this, new.target.prototype); 22919 this.code = code; 22920 this.file = file; 22921 } 22922 }; 22923 22924 // packages/upload-media/build-module/validate-mime-type.js 22925 function validateMimeType(file, allowedTypes) { 22926 if (!allowedTypes) { 22927 return; 22928 } 22929 const isAllowedType = allowedTypes.some((allowedType) => { 22930 if (allowedType.includes("/")) { 22931 return allowedType === file.type; 22932 } 22933 return file.type.startsWith(`$allowedType}/`); 22934 }); 22935 if (file.type && !isAllowedType) { 22936 throw new UploadError({ 22937 code: "MIME_TYPE_NOT_SUPPORTED", 22938 message: (0, import_i18n27.sprintf)( 22939 // translators: %s: file name. 22940 (0, import_i18n27.__)("%s: Sorry, this file type is not supported here."), 22941 file.name 22942 ), 22943 file 22944 }); 22945 } 22946 } 22947 22948 // packages/upload-media/build-module/validate-mime-type-for-user.js 22949 var import_i18n28 = __toESM(require_i18n()); 22950 22951 // packages/upload-media/build-module/get-mime-types-array.js 22952 function getMimeTypesArray(wpMimeTypesObject) { 22953 if (!wpMimeTypesObject) { 22954 return null; 22955 } 22956 return Object.entries(wpMimeTypesObject).flatMap( 22957 ([extensionsString, mime]) => { 22958 const [type] = mime.split("/"); 22959 const extensions = extensionsString.split("|"); 22960 return [ 22961 mime, 22962 ...extensions.map( 22963 (extension) => `$type}/$extension}` 22964 ) 22965 ]; 22966 } 22967 ); 22968 } 22969 22970 // packages/upload-media/build-module/validate-mime-type-for-user.js 22971 function validateMimeTypeForUser(file, wpAllowedMimeTypes) { 22972 const allowedMimeTypesForUser = getMimeTypesArray(wpAllowedMimeTypes); 22973 if (!allowedMimeTypesForUser) { 22974 return; 22975 } 22976 const isAllowedMimeTypeForUser = allowedMimeTypesForUser.includes( 22977 file.type 22978 ); 22979 if (file.type && !isAllowedMimeTypeForUser) { 22980 throw new UploadError({ 22981 code: "MIME_TYPE_NOT_ALLOWED_FOR_USER", 22982 message: (0, import_i18n28.sprintf)( 22983 // translators: %s: file name. 22984 (0, import_i18n28.__)( 22985 "%s: Sorry, you are not allowed to upload this file type." 22986 ), 22987 file.name 22988 ), 22989 file 22990 }); 22991 } 22992 } 22993 22994 // packages/upload-media/build-module/validate-file-size.js 22995 var import_i18n29 = __toESM(require_i18n()); 22996 function validateFileSize(file, maxUploadFileSize) { 22997 if (file.size <= 0) { 22998 throw new UploadError({ 22999 code: "EMPTY_FILE", 23000 message: (0, import_i18n29.sprintf)( 23001 // translators: %s: file name. 23002 (0, import_i18n29.__)("%s: This file is empty."), 23003 file.name 23004 ), 23005 file 23006 }); 23007 } 23008 if (maxUploadFileSize && file.size > maxUploadFileSize) { 23009 throw new UploadError({ 23010 code: "SIZE_ABOVE_LIMIT", 23011 message: (0, import_i18n29.sprintf)( 23012 // translators: %s: file name. 23013 (0, import_i18n29.__)( 23014 "%s: This file exceeds the maximum upload size for this site." 23015 ), 23016 file.name 23017 ), 23018 file 23019 }); 23020 } 23021 } 23022 23023 // packages/upload-media/build-module/store/actions.js 23024 function addItems({ 23025 files, 23026 onChange, 23027 onSuccess, 23028 onError, 23029 onBatchSuccess, 23030 additionalData, 23031 allowedTypes 23032 }) { 23033 return async ({ select: select3, dispatch }) => { 23034 const batchId = v4_default(); 23035 for (const file of files) { 23036 try { 23037 validateMimeType(file, allowedTypes); 23038 validateMimeTypeForUser( 23039 file, 23040 select3.getSettings().allowedMimeTypes 23041 ); 23042 } catch (error) { 23043 onError?.(error); 23044 continue; 23045 } 23046 try { 23047 validateFileSize( 23048 file, 23049 select3.getSettings().maxUploadFileSize 23050 ); 23051 } catch (error) { 23052 onError?.(error); 23053 continue; 23054 } 23055 dispatch.addItem({ 23056 file, 23057 batchId, 23058 onChange, 23059 onSuccess, 23060 onBatchSuccess, 23061 onError, 23062 additionalData 23063 }); 23064 } 23065 }; 23066 } 23067 function cancelItem(id, error, silent = false) { 23068 return async ({ select: select3, dispatch }) => { 23069 const item = select3.getItem(id); 23070 if (!item) { 23071 return; 23072 } 23073 item.abortController?.abort(); 23074 if (!silent) { 23075 const { onError } = item; 23076 onError?.(error ?? new Error("Upload cancelled")); 23077 if (!onError && error) { 23078 console.error("Upload cancelled", error); 23079 } 23080 } 23081 dispatch({ 23082 type: Type.Cancel, 23083 id, 23084 error 23085 }); 23086 dispatch.removeItem(id); 23087 dispatch.revokeBlobUrls(id); 23088 if (item.batchId && select3.isBatchUploaded(item.batchId)) { 23089 item.onBatchSuccess?.(); 23090 } 23091 }; 23092 } 23093 23094 // packages/upload-media/build-module/store/private-actions.js 23095 var private_actions_exports2 = {}; 23096 __export(private_actions_exports2, { 23097 addItem: () => addItem, 23098 finishOperation: () => finishOperation, 23099 pauseQueue: () => pauseQueue, 23100 prepareItem: () => prepareItem, 23101 processItem: () => processItem, 23102 removeItem: () => removeItem, 23103 resumeQueue: () => resumeQueue, 23104 revokeBlobUrls: () => revokeBlobUrls, 23105 updateSettings: () => updateSettings2, 23106 uploadItem: () => uploadItem 23107 }); 23108 var import_blob = __toESM(require_blob()); 23109 23110 // packages/upload-media/build-module/utils.js 23111 var import_url3 = __toESM(require_url()); 23112 var import_i18n30 = __toESM(require_i18n()); 23113 function convertBlobToFile(fileOrBlob) { 23114 if (fileOrBlob instanceof File) { 23115 return fileOrBlob; 23116 } 23117 const ext = fileOrBlob.type.split("/")[1]; 23118 const mediaType = "application/pdf" === fileOrBlob.type ? "document" : fileOrBlob.type.split("/")[0]; 23119 return new File([fileOrBlob], `$mediaType}.$ext}`, { 23120 type: fileOrBlob.type 23121 }); 23122 } 23123 function renameFile(file, name) { 23124 return new File([file], name, { 23125 type: file.type, 23126 lastModified: file.lastModified 23127 }); 23128 } 23129 function cloneFile(file) { 23130 return renameFile(file, file.name); 23131 } 23132 23133 // packages/upload-media/build-module/stub-file.js 23134 var StubFile = class extends File { 23135 constructor(fileName = "stub-file") { 23136 super([], fileName); 23137 } 23138 }; 23139 23140 // packages/upload-media/build-module/store/private-actions.js 23141 function addItem({ 23142 file: fileOrBlob, 23143 batchId, 23144 onChange, 23145 onSuccess, 23146 onBatchSuccess, 23147 onError, 23148 additionalData = {}, 23149 sourceUrl, 23150 sourceAttachmentId, 23151 abortController, 23152 operations 23153 }) { 23154 return async ({ dispatch }) => { 23155 const itemId = v4_default(); 23156 const file = convertBlobToFile(fileOrBlob); 23157 let blobUrl; 23158 if (!(file instanceof StubFile)) { 23159 blobUrl = (0, import_blob.createBlobURL)(file); 23160 dispatch({ 23161 type: Type.CacheBlobUrl, 23162 id: itemId, 23163 blobUrl 23164 }); 23165 } 23166 dispatch({ 23167 type: Type.Add, 23168 item: { 23169 id: itemId, 23170 batchId, 23171 status: ItemStatus.Processing, 23172 sourceFile: cloneFile(file), 23173 file, 23174 attachment: { 23175 url: blobUrl 23176 }, 23177 additionalData: { 23178 convert_format: false, 23179 ...additionalData 23180 }, 23181 onChange, 23182 onSuccess, 23183 onBatchSuccess, 23184 onError, 23185 sourceUrl, 23186 sourceAttachmentId, 23187 abortController: abortController || new AbortController(), 23188 operations: Array.isArray(operations) ? operations : [OperationType.Prepare] 23189 } 23190 }); 23191 dispatch.processItem(itemId); 23192 }; 23193 } 23194 function processItem(id) { 23195 return async ({ select: select3, dispatch }) => { 23196 if (select3.isPaused()) { 23197 return; 23198 } 23199 const item = select3.getItem(id); 23200 const { attachment, onChange, onSuccess, onBatchSuccess, batchId } = item; 23201 const operation = Array.isArray(item.operations?.[0]) ? item.operations[0][0] : item.operations?.[0]; 23202 if (attachment) { 23203 onChange?.([attachment]); 23204 } 23205 if (!operation) { 23206 if (attachment) { 23207 onSuccess?.([attachment]); 23208 } 23209 dispatch.revokeBlobUrls(id); 23210 if (batchId && select3.isBatchUploaded(batchId)) { 23211 onBatchSuccess?.(); 23212 } 23213 return; 23214 } 23215 if (!operation) { 23216 return; 23217 } 23218 dispatch({ 23219 type: Type.OperationStart, 23220 id, 23221 operation 23222 }); 23223 switch (operation) { 23224 case OperationType.Prepare: 23225 dispatch.prepareItem(item.id); 23226 break; 23227 case OperationType.Upload: 23228 dispatch.uploadItem(id); 23229 break; 23230 } 23231 }; 23232 } 23233 function pauseQueue() { 23234 return { 23235 type: Type.PauseQueue 23236 }; 23237 } 23238 function resumeQueue() { 23239 return async ({ select: select3, dispatch }) => { 23240 dispatch({ 23241 type: Type.ResumeQueue 23242 }); 23243 for (const item of select3.getAllItems()) { 23244 dispatch.processItem(item.id); 23245 } 23246 }; 23247 } 23248 function removeItem(id) { 23249 return async ({ select: select3, dispatch }) => { 23250 const item = select3.getItem(id); 23251 if (!item) { 23252 return; 23253 } 23254 dispatch({ 23255 type: Type.Remove, 23256 id 23257 }); 23258 }; 23259 } 23260 function finishOperation(id, updates) { 23261 return async ({ dispatch }) => { 23262 dispatch({ 23263 type: Type.OperationFinish, 23264 id, 23265 item: updates 23266 }); 23267 dispatch.processItem(id); 23268 }; 23269 } 23270 function prepareItem(id) { 23271 return async ({ dispatch }) => { 23272 const operations = [OperationType.Upload]; 23273 dispatch({ 23274 type: Type.AddOperations, 23275 id, 23276 operations 23277 }); 23278 dispatch.finishOperation(id, {}); 23279 }; 23280 } 23281 function uploadItem(id) { 23282 return async ({ select: select3, dispatch }) => { 23283 const item = select3.getItem(id); 23284 select3.getSettings().mediaUpload({ 23285 filesList: [item.file], 23286 additionalData: item.additionalData, 23287 signal: item.abortController?.signal, 23288 onFileChange: ([attachment]) => { 23289 if (!(0, import_blob.isBlobURL)(attachment.url)) { 23290 dispatch.finishOperation(id, { 23291 attachment 23292 }); 23293 } 23294 }, 23295 onSuccess: ([attachment]) => { 23296 dispatch.finishOperation(id, { 23297 attachment 23298 }); 23299 }, 23300 onError: (error) => { 23301 dispatch.cancelItem(id, error); 23302 } 23303 }); 23304 }; 23305 } 23306 function revokeBlobUrls(id) { 23307 return async ({ select: select3, dispatch }) => { 23308 const blobUrls = select3.getBlobUrls(id); 23309 for (const blobUrl of blobUrls) { 23310 (0, import_blob.revokeBlobURL)(blobUrl); 23311 } 23312 dispatch({ 23313 type: Type.RevokeBlobUrls, 23314 id 23315 }); 23316 }; 23317 } 23318 function updateSettings2(settings2) { 23319 return { 23320 type: Type.UpdateSettings, 23321 settings: settings2 23322 }; 23323 } 23324 23325 // packages/upload-media/build-module/lock-unlock.js 23326 var import_private_apis2 = __toESM(require_private_apis()); 23327 var { lock: lock2, unlock: unlock2 } = (0, import_private_apis2.__dangerousOptInToUnstableAPIsOnlyForCoreModules)( 23328 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.", 23329 "@wordpress/upload-media" 23330 ); 23331 23332 // packages/upload-media/build-module/store/constants.js 23333 var STORE_NAME2 = "core/upload-media"; 23334 23335 // packages/upload-media/build-module/store/index.js 23336 var storeConfig2 = { 23337 reducer: reducer_default2, 23338 selectors: selectors_exports2, 23339 actions: actions_exports2 23340 }; 23341 var store2 = (0, import_data27.createReduxStore)(STORE_NAME2, { 23342 reducer: reducer_default2, 23343 selectors: selectors_exports2, 23344 actions: actions_exports2 23345 }); 23346 (0, import_data27.register)(store2); 23347 unlock2(store2).registerPrivateActions(private_actions_exports2); 23348 unlock2(store2).registerPrivateSelectors(private_selectors_exports2); 23349 23350 // packages/upload-media/build-module/components/provider/index.js 23351 var import_element34 = __toESM(require_element()); 23352 var import_data29 = __toESM(require_data()); 23353 23354 // packages/upload-media/build-module/components/provider/with-registry-provider.js 23355 var import_element33 = __toESM(require_element()); 23356 var import_data28 = __toESM(require_data()); 23357 var import_compose17 = __toESM(require_compose()); 23358 var import_jsx_runtime148 = __toESM(require_jsx_runtime()); 23359 function getSubRegistry(subRegistries, registry, useSubRegistry) { 23360 if (!useSubRegistry) { 23361 return registry; 23362 } 23363 let subRegistry = subRegistries.get(registry); 23364 if (!subRegistry) { 23365 subRegistry = (0, import_data28.createRegistry)({}, registry); 23366 subRegistry.registerStore(STORE_NAME2, storeConfig2); 23367 subRegistries.set(registry, subRegistry); 23368 } 23369 return subRegistry; 23370 } 23371 var withRegistryProvider = (0, import_compose17.createHigherOrderComponent)( 23372 (WrappedComponent) => ({ useSubRegistry = true, ...props }) => { 23373 const registry = (0, import_data28.useRegistry)(); 23374 const [subRegistries] = (0, import_element33.useState)(() => /* @__PURE__ */ new WeakMap()); 23375 const subRegistry = getSubRegistry( 23376 subRegistries, 23377 registry, 23378 useSubRegistry 23379 ); 23380 if (subRegistry === registry) { 23381 return /* @__PURE__ */ (0, import_jsx_runtime148.jsx)(WrappedComponent, { registry, ...props }); 23382 } 23383 return /* @__PURE__ */ (0, import_jsx_runtime148.jsx)(import_data28.RegistryProvider, { value: subRegistry, children: /* @__PURE__ */ (0, import_jsx_runtime148.jsx)(WrappedComponent, { registry: subRegistry, ...props }) }); 23384 }, 23385 "withRegistryProvider" 23386 ); 23387 var with_registry_provider_default = withRegistryProvider; 23388 23389 // packages/upload-media/build-module/components/provider/index.js 23390 var import_jsx_runtime149 = __toESM(require_jsx_runtime()); 23391 var MediaUploadProvider = with_registry_provider_default((props) => { 23392 const { children, settings: settings2 } = props; 23393 const { updateSettings: updateSettings3 } = unlock2((0, import_data29.useDispatch)(store2)); 23394 (0, import_element34.useEffect)(() => { 23395 updateSettings3(settings2); 23396 }, [settings2, updateSettings3]); 23397 return /* @__PURE__ */ (0, import_jsx_runtime149.jsx)(import_jsx_runtime149.Fragment, { children }); 23398 }); 23399 var provider_default = MediaUploadProvider; 23400 23401 // packages/block-editor/build-module/components/provider/with-registry-provider.js 23402 var import_element35 = __toESM(require_element()); 23403 var import_data30 = __toESM(require_data()); 23404 var import_compose18 = __toESM(require_compose()); 23405 var import_jsx_runtime150 = __toESM(require_jsx_runtime()); 23406 function getSubRegistry2(subRegistries, registry, useSubRegistry) { 23407 if (!useSubRegistry) { 23408 return registry; 23409 } 23410 let subRegistry = subRegistries.get(registry); 23411 if (!subRegistry) { 23412 subRegistry = (0, import_data30.createRegistry)({}, registry); 23413 subRegistry.registerStore(STORE_NAME, storeConfig); 23414 subRegistries.set(registry, subRegistry); 23415 } 23416 return subRegistry; 23417 } 23418 var withRegistryProvider2 = (0, import_compose18.createHigherOrderComponent)( 23419 (WrappedComponent) => ({ useSubRegistry = true, ...props }) => { 23420 const registry = (0, import_data30.useRegistry)(); 23421 const [subRegistries] = (0, import_element35.useState)(() => /* @__PURE__ */ new WeakMap()); 23422 const subRegistry = getSubRegistry2( 23423 subRegistries, 23424 registry, 23425 useSubRegistry 23426 ); 23427 if (subRegistry === registry) { 23428 return /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(WrappedComponent, { registry, ...props }); 23429 } 23430 return /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(import_data30.RegistryProvider, { value: subRegistry, children: /* @__PURE__ */ (0, import_jsx_runtime150.jsx)(WrappedComponent, { registry: subRegistry, ...props }) }); 23431 }, 23432 "withRegistryProvider" 23433 ); 23434 var with_registry_provider_default2 = withRegistryProvider2; 23435 23436 // packages/block-editor/build-module/components/provider/use-block-sync.js 23437 var import_element36 = __toESM(require_element()); 23438 var import_data31 = __toESM(require_data()); 23439 var import_blocks21 = __toESM(require_blocks()); 23440 var noop5 = () => { 23441 }; 23442 function useBlockSync({ 23443 clientId = null, 23444 value: controlledBlocks, 23445 selection: controlledSelection, 23446 onChange = noop5, 23447 onInput = noop5 23448 }) { 23449 const registry = (0, import_data31.useRegistry)(); 23450 const { 23451 resetBlocks: resetBlocks2, 23452 resetSelection: resetSelection2, 23453 replaceInnerBlocks: replaceInnerBlocks2, 23454 setHasControlledInnerBlocks: setHasControlledInnerBlocks2, 23455 __unstableMarkNextChangeAsNotPersistent: __unstableMarkNextChangeAsNotPersistent2 23456 } = registry.dispatch(store); 23457 const { getBlockName: getBlockName2, getBlocks: getBlocks2, getSelectionStart: getSelectionStart2, getSelectionEnd: getSelectionEnd2 } = registry.select(store); 23458 const isControlled = (0, import_data31.useSelect)( 23459 (select3) => { 23460 return !clientId || select3(store).areInnerBlocksControlled(clientId); 23461 }, 23462 [clientId] 23463 ); 23464 const pendingChangesRef = (0, import_element36.useRef)({ incoming: null, outgoing: [] }); 23465 const subscribedRef = (0, import_element36.useRef)(false); 23466 const setControlledBlocks = () => { 23467 if (!controlledBlocks) { 23468 return; 23469 } 23470 __unstableMarkNextChangeAsNotPersistent2(); 23471 if (clientId) { 23472 registry.batch(() => { 23473 setHasControlledInnerBlocks2(clientId, true); 23474 const storeBlocks = controlledBlocks.map( 23475 (block) => (0, import_blocks21.cloneBlock)(block) 23476 ); 23477 if (subscribedRef.current) { 23478 pendingChangesRef.current.incoming = storeBlocks; 23479 } 23480 __unstableMarkNextChangeAsNotPersistent2(); 23481 replaceInnerBlocks2(clientId, storeBlocks); 23482 }); 23483 } else { 23484 if (subscribedRef.current) { 23485 pendingChangesRef.current.incoming = controlledBlocks; 23486 } 23487 resetBlocks2(controlledBlocks); 23488 } 23489 }; 23490 const unsetControlledBlocks = () => { 23491 __unstableMarkNextChangeAsNotPersistent2(); 23492 if (clientId) { 23493 setHasControlledInnerBlocks2(clientId, false); 23494 __unstableMarkNextChangeAsNotPersistent2(); 23495 replaceInnerBlocks2(clientId, []); 23496 } else { 23497 resetBlocks2([]); 23498 } 23499 }; 23500 const onInputRef = (0, import_element36.useRef)(onInput); 23501 const onChangeRef = (0, import_element36.useRef)(onChange); 23502 (0, import_element36.useEffect)(() => { 23503 onInputRef.current = onInput; 23504 onChangeRef.current = onChange; 23505 }, [onInput, onChange]); 23506 (0, import_element36.useEffect)(() => { 23507 if (pendingChangesRef.current.outgoing.includes(controlledBlocks)) { 23508 if (pendingChangesRef.current.outgoing[pendingChangesRef.current.outgoing.length - 1] === controlledBlocks) { 23509 pendingChangesRef.current.outgoing = []; 23510 } 23511 } else if (getBlocks2(clientId) !== controlledBlocks) { 23512 pendingChangesRef.current.outgoing = []; 23513 setControlledBlocks(); 23514 if (controlledSelection) { 23515 resetSelection2( 23516 controlledSelection.selectionStart, 23517 controlledSelection.selectionEnd, 23518 controlledSelection.initialPosition 23519 ); 23520 } 23521 } 23522 }, [controlledBlocks, clientId]); 23523 const isMountedRef = (0, import_element36.useRef)(false); 23524 (0, import_element36.useEffect)(() => { 23525 if (!isMountedRef.current) { 23526 isMountedRef.current = true; 23527 return; 23528 } 23529 if (!isControlled) { 23530 pendingChangesRef.current.outgoing = []; 23531 setControlledBlocks(); 23532 } 23533 }, [isControlled]); 23534 (0, import_element36.useEffect)(() => { 23535 const { 23536 getSelectedBlocksInitialCaretPosition: getSelectedBlocksInitialCaretPosition2, 23537 isLastBlockChangePersistent: isLastBlockChangePersistent2, 23538 __unstableIsLastBlockChangeIgnored: __unstableIsLastBlockChangeIgnored2, 23539 areInnerBlocksControlled: areInnerBlocksControlled2 23540 } = registry.select(store); 23541 let blocks2 = getBlocks2(clientId); 23542 let isPersistent = isLastBlockChangePersistent2(); 23543 let previousAreBlocksDifferent = false; 23544 subscribedRef.current = true; 23545 const unsubscribe = registry.subscribe(() => { 23546 if (clientId !== null && getBlockName2(clientId) === null) { 23547 return; 23548 } 23549 const isStillControlled = !clientId || areInnerBlocksControlled2(clientId); 23550 if (!isStillControlled) { 23551 return; 23552 } 23553 const newIsPersistent = isLastBlockChangePersistent2(); 23554 const newBlocks = getBlocks2(clientId); 23555 const areBlocksDifferent = newBlocks !== blocks2; 23556 blocks2 = newBlocks; 23557 if (areBlocksDifferent && (pendingChangesRef.current.incoming || __unstableIsLastBlockChangeIgnored2())) { 23558 pendingChangesRef.current.incoming = null; 23559 isPersistent = newIsPersistent; 23560 return; 23561 } 23562 const didPersistenceChange = previousAreBlocksDifferent && !areBlocksDifferent && newIsPersistent && !isPersistent; 23563 if (areBlocksDifferent || didPersistenceChange) { 23564 isPersistent = newIsPersistent; 23565 pendingChangesRef.current.outgoing.push(blocks2); 23566 const updateParent = isPersistent ? onChangeRef.current : onInputRef.current; 23567 updateParent(blocks2, { 23568 selection: { 23569 selectionStart: getSelectionStart2(), 23570 selectionEnd: getSelectionEnd2(), 23571 initialPosition: getSelectedBlocksInitialCaretPosition2() 23572 } 23573 }); 23574 } 23575 previousAreBlocksDifferent = areBlocksDifferent; 23576 }, store); 23577 return () => { 23578 subscribedRef.current = false; 23579 unsubscribe(); 23580 }; 23581 }, [registry, clientId]); 23582 (0, import_element36.useEffect)(() => { 23583 return () => { 23584 unsetControlledBlocks(); 23585 }; 23586 }, []); 23587 } 23588 23589 // packages/block-editor/build-module/components/keyboard-shortcuts/index.js 23590 var import_element37 = __toESM(require_element()); 23591 var import_data32 = __toESM(require_data()); 23592 var import_keyboard_shortcuts = __toESM(require_keyboard_shortcuts()); 23593 var import_i18n31 = __toESM(require_i18n()); 23594 function KeyboardShortcuts() { 23595 return null; 23596 } 23597 function KeyboardShortcutsRegister() { 23598 const { registerShortcut } = (0, import_data32.useDispatch)(import_keyboard_shortcuts.store); 23599 (0, import_element37.useEffect)(() => { 23600 registerShortcut({ 23601 name: "core/block-editor/copy", 23602 category: "block", 23603 description: (0, import_i18n31.__)("Copy the selected block(s)."), 23604 keyCombination: { 23605 modifier: "primary", 23606 character: "c" 23607 } 23608 }); 23609 registerShortcut({ 23610 name: "core/block-editor/cut", 23611 category: "block", 23612 description: (0, import_i18n31.__)("Cut the selected block(s)."), 23613 keyCombination: { 23614 modifier: "primary", 23615 character: "x" 23616 } 23617 }); 23618 registerShortcut({ 23619 name: "core/block-editor/paste", 23620 category: "block", 23621 description: (0, import_i18n31.__)("Paste the selected block(s)."), 23622 keyCombination: { 23623 modifier: "primary", 23624 character: "v" 23625 } 23626 }); 23627 registerShortcut({ 23628 name: "core/block-editor/duplicate", 23629 category: "block", 23630 description: (0, import_i18n31.__)("Duplicate the selected block(s)."), 23631 keyCombination: { 23632 modifier: "primaryShift", 23633 character: "d" 23634 } 23635 }); 23636 registerShortcut({ 23637 name: "core/block-editor/remove", 23638 category: "block", 23639 description: (0, import_i18n31.__)("Remove the selected block(s)."), 23640 keyCombination: { 23641 modifier: "access", 23642 character: "z" 23643 } 23644 }); 23645 registerShortcut({ 23646 name: "core/block-editor/paste-styles", 23647 category: "block", 23648 description: (0, import_i18n31.__)( 23649 "Paste the copied style to the selected block(s)." 23650 ), 23651 keyCombination: { 23652 modifier: "primaryAlt", 23653 character: "v" 23654 } 23655 }); 23656 registerShortcut({ 23657 name: "core/block-editor/insert-before", 23658 category: "block", 23659 description: (0, import_i18n31.__)( 23660 "Insert a new block before the selected block(s)." 23661 ), 23662 keyCombination: { 23663 modifier: "primaryAlt", 23664 character: "t" 23665 } 23666 }); 23667 registerShortcut({ 23668 name: "core/block-editor/insert-after", 23669 category: "block", 23670 description: (0, import_i18n31.__)( 23671 "Insert a new block after the selected block(s)." 23672 ), 23673 keyCombination: { 23674 modifier: "primaryAlt", 23675 character: "y" 23676 } 23677 }); 23678 registerShortcut({ 23679 name: "core/block-editor/delete-multi-selection", 23680 category: "block", 23681 description: (0, import_i18n31.__)("Delete selection."), 23682 keyCombination: { 23683 character: "del" 23684 }, 23685 aliases: [ 23686 { 23687 character: "backspace" 23688 } 23689 ] 23690 }); 23691 registerShortcut({ 23692 name: "core/block-editor/stop-editing-as-blocks", 23693 category: "block", 23694 description: (0, import_i18n31.__)("Finish editing a design."), 23695 keyCombination: { 23696 character: "escape" 23697 } 23698 }); 23699 registerShortcut({ 23700 name: "core/block-editor/select-all", 23701 category: "selection", 23702 description: (0, import_i18n31.__)( 23703 "Select all text when typing. Press again to select all blocks." 23704 ), 23705 keyCombination: { 23706 modifier: "primary", 23707 character: "a" 23708 } 23709 }); 23710 registerShortcut({ 23711 name: "core/block-editor/unselect", 23712 category: "selection", 23713 description: (0, import_i18n31.__)("Clear selection."), 23714 keyCombination: { 23715 character: "escape" 23716 } 23717 }); 23718 registerShortcut({ 23719 name: "core/block-editor/multi-text-selection", 23720 category: "selection", 23721 description: (0, import_i18n31.__)("Select text across multiple blocks."), 23722 keyCombination: { 23723 modifier: "shift", 23724 character: "arrow" 23725 } 23726 }); 23727 registerShortcut({ 23728 name: "core/block-editor/focus-toolbar", 23729 category: "global", 23730 description: (0, import_i18n31.__)("Navigate to the nearest toolbar."), 23731 keyCombination: { 23732 modifier: "alt", 23733 character: "F10" 23734 } 23735 }); 23736 registerShortcut({ 23737 name: "core/block-editor/move-up", 23738 category: "block", 23739 description: (0, import_i18n31.__)("Move the selected block(s) up."), 23740 keyCombination: { 23741 modifier: "secondary", 23742 character: "t" 23743 } 23744 }); 23745 registerShortcut({ 23746 name: "core/block-editor/move-down", 23747 category: "block", 23748 description: (0, import_i18n31.__)("Move the selected block(s) down."), 23749 keyCombination: { 23750 modifier: "secondary", 23751 character: "y" 23752 } 23753 }); 23754 registerShortcut({ 23755 name: "core/block-editor/collapse-list-view", 23756 category: "list-view", 23757 description: (0, import_i18n31.__)("Collapse all other items."), 23758 keyCombination: { 23759 modifier: "alt", 23760 character: "l" 23761 } 23762 }); 23763 registerShortcut({ 23764 name: "core/block-editor/group", 23765 category: "block", 23766 description: (0, import_i18n31.__)( 23767 "Create a group block from the selected multiple blocks." 23768 ), 23769 keyCombination: { 23770 modifier: "primary", 23771 character: "g" 23772 } 23773 }); 23774 registerShortcut({ 23775 name: "core/block-editor/toggle-block-visibility", 23776 category: "block", 23777 description: (0, import_i18n31.__)("Show or hide the selected block(s)."), 23778 keyCombination: { 23779 modifier: "primaryShift", 23780 character: "h" 23781 } 23782 }); 23783 }, [registerShortcut]); 23784 return null; 23785 } 23786 KeyboardShortcuts.Register = KeyboardShortcutsRegister; 23787 var keyboard_shortcuts_default = KeyboardShortcuts; 23788 23789 // packages/block-editor/build-module/components/provider/use-media-upload-settings.js 23790 var import_element38 = __toESM(require_element()); 23791 function useMediaUploadSettings(settings2 = {}) { 23792 return (0, import_element38.useMemo)( 23793 () => ({ 23794 mediaUpload: settings2.mediaUpload, 23795 mediaSideload: settings2.mediaSideload, 23796 maxUploadFileSize: settings2.maxUploadFileSize, 23797 allowedMimeTypes: settings2.allowedMimeTypes 23798 }), 23799 [settings2] 23800 ); 23801 } 23802 var use_media_upload_settings_default = useMediaUploadSettings; 23803 23804 // packages/block-editor/build-module/components/provider/index.js 23805 var import_jsx_runtime151 = __toESM(require_jsx_runtime()); 23806 var noop6 = () => { 23807 }; 23808 function mediaUpload(registry, { 23809 allowedTypes, 23810 additionalData = {}, 23811 filesList, 23812 onError = noop6, 23813 onFileChange, 23814 onSuccess, 23815 onBatchSuccess 23816 }) { 23817 void registry.dispatch(store2).addItems({ 23818 files: filesList, 23819 onChange: onFileChange, 23820 onSuccess, 23821 onBatchSuccess, 23822 onError: ({ message: message2 }) => onError(message2), 23823 additionalData, 23824 allowedTypes 23825 }); 23826 } 23827 var ExperimentalBlockEditorProvider = with_registry_provider_default2( 23828 (props) => { 23829 const { 23830 settings: _settings, 23831 registry, 23832 stripExperimentalSettings = false 23833 } = props; 23834 const mediaUploadSettings = use_media_upload_settings_default(_settings); 23835 let settings2 = _settings; 23836 if (window.__experimentalMediaProcessing && _settings.mediaUpload) { 23837 settings2 = (0, import_element39.useMemo)( 23838 () => ({ 23839 ..._settings, 23840 mediaUpload: mediaUpload.bind(null, registry) 23841 }), 23842 [_settings, registry] 23843 ); 23844 } 23845 const { __experimentalUpdateSettings: __experimentalUpdateSettings2 } = unlock( 23846 (0, import_data33.useDispatch)(store) 23847 ); 23848 (0, import_element39.useEffect)(() => { 23849 __experimentalUpdateSettings2( 23850 { 23851 ...settings2, 23852 __internalIsInitialized: true 23853 }, 23854 { 23855 stripExperimentalSettings, 23856 reset: true 23857 } 23858 ); 23859 }, [ 23860 settings2, 23861 stripExperimentalSettings, 23862 __experimentalUpdateSettings2 23863 ]); 23864 useBlockSync(props); 23865 const children = /* @__PURE__ */ (0, import_jsx_runtime151.jsxs)(import_components27.SlotFillProvider, { passthrough: true, children: [ 23866 !settings2?.isPreviewMode && /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(keyboard_shortcuts_default.Register, {}), 23867 /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(BlockRefsProvider, { children: props.children }) 23868 ] }); 23869 if (window.__experimentalMediaProcessing) { 23870 return /* @__PURE__ */ (0, import_jsx_runtime151.jsx)( 23871 provider_default, 23872 { 23873 settings: mediaUploadSettings, 23874 useSubRegistry: false, 23875 children 23876 } 23877 ); 23878 } 23879 return children; 23880 } 23881 ); 23882 var BlockEditorProvider = (props) => { 23883 return /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(ExperimentalBlockEditorProvider, { ...props, stripExperimentalSettings: true, children: props.children }); 23884 }; 23885 var provider_default2 = BlockEditorProvider; 23886 23887 // packages/block-editor/build-module/components/block-preview/auto.js 23888 var import_compose31 = __toESM(require_compose()); 23889 var import_data47 = __toESM(require_data()); 23890 var import_element46 = __toESM(require_element()); 23891 var import_components30 = __toESM(require_components()); 23892 23893 // packages/block-editor/build-module/components/iframe/index.js 23894 var import_element44 = __toESM(require_element()); 23895 var import_i18n34 = __toESM(require_i18n()); 23896 var import_compose30 = __toESM(require_compose()); 23897 var import_components28 = __toESM(require_components()); 23898 var import_data45 = __toESM(require_data()); 23899 23900 // packages/block-editor/build-module/components/writing-flow/index.js 23901 var import_data44 = __toESM(require_data()); 23902 var import_i18n33 = __toESM(require_i18n()); 23903 var import_compose28 = __toESM(require_compose()); 23904 var import_element42 = __toESM(require_element()); 23905 23906 // packages/block-editor/build-module/components/writing-flow/use-multi-selection.js 23907 var import_compose19 = __toESM(require_compose()); 23908 var import_data34 = __toESM(require_data()); 23909 function selector(select3) { 23910 const { 23911 isMultiSelecting: isMultiSelecting3, 23912 getMultiSelectedBlockClientIds: getMultiSelectedBlockClientIds2, 23913 hasMultiSelection: hasMultiSelection2, 23914 getSelectedBlockClientId: getSelectedBlockClientId2, 23915 getSelectedBlocksInitialCaretPosition: getSelectedBlocksInitialCaretPosition2, 23916 __unstableIsFullySelected: __unstableIsFullySelected2 23917 } = select3(store); 23918 return { 23919 isMultiSelecting: isMultiSelecting3(), 23920 multiSelectedBlockClientIds: getMultiSelectedBlockClientIds2(), 23921 hasMultiSelection: hasMultiSelection2(), 23922 selectedBlockClientId: getSelectedBlockClientId2(), 23923 initialPosition: getSelectedBlocksInitialCaretPosition2(), 23924 isFullSelection: __unstableIsFullySelected2() 23925 }; 23926 } 23927 function useMultiSelection() { 23928 const { 23929 initialPosition: initialPosition2, 23930 isMultiSelecting: isMultiSelecting3, 23931 multiSelectedBlockClientIds, 23932 hasMultiSelection: hasMultiSelection2, 23933 selectedBlockClientId, 23934 isFullSelection 23935 } = (0, import_data34.useSelect)(selector, []); 23936 return (0, import_compose19.useRefEffect)( 23937 (node) => { 23938 const { ownerDocument } = node; 23939 const { defaultView } = ownerDocument; 23940 if (initialPosition2 === void 0 || initialPosition2 === null) { 23941 return; 23942 } 23943 if (!hasMultiSelection2 || isMultiSelecting3) { 23944 return; 23945 } 23946 const { length } = multiSelectedBlockClientIds; 23947 if (length < 2) { 23948 return; 23949 } 23950 if (!isFullSelection) { 23951 return; 23952 } 23953 node.contentEditable = true; 23954 node.focus(); 23955 defaultView.getSelection().removeAllRanges(); 23956 }, 23957 [ 23958 hasMultiSelection2, 23959 isMultiSelecting3, 23960 multiSelectedBlockClientIds, 23961 selectedBlockClientId, 23962 initialPosition2, 23963 isFullSelection 23964 ] 23965 ); 23966 } 23967 23968 // packages/block-editor/build-module/components/writing-flow/use-tab-nav.js 23969 var import_dom8 = __toESM(require_dom()); 23970 var import_keycodes3 = __toESM(require_keycodes()); 23971 var import_data35 = __toESM(require_data()); 23972 var import_compose20 = __toESM(require_compose()); 23973 var import_element40 = __toESM(require_element()); 23974 var import_jsx_runtime152 = __toESM(require_jsx_runtime()); 23975 function useTabNav() { 23976 const containerRef = ( 23977 /** @type {typeof useRef<HTMLElement>} */ 23978 (0, import_element40.useRef)() 23979 ); 23980 const focusCaptureBeforeRef = (0, import_element40.useRef)(); 23981 const focusCaptureAfterRef = (0, import_element40.useRef)(); 23982 const { 23983 hasMultiSelection: hasMultiSelection2, 23984 getSelectedBlockClientId: getSelectedBlockClientId2, 23985 getBlockCount: getBlockCount2, 23986 getBlockOrder: getBlockOrder2, 23987 getLastFocus: getLastFocus2, 23988 getSectionRootClientId: getSectionRootClientId2, 23989 isZoomOut: isZoomOut2 23990 } = unlock((0, import_data35.useSelect)(store)); 23991 const { setLastFocus: setLastFocus2 } = unlock((0, import_data35.useDispatch)(store)); 23992 const noCaptureRef = (0, import_element40.useRef)(); 23993 function onFocusCapture(event) { 23994 const canvasElement = containerRef.current.ownerDocument === event.target.ownerDocument ? containerRef.current : containerRef.current.ownerDocument.defaultView.frameElement; 23995 if (noCaptureRef.current) { 23996 noCaptureRef.current = null; 23997 } else if (hasMultiSelection2()) { 23998 containerRef.current.focus(); 23999 } else if (getSelectedBlockClientId2()) { 24000 if (getLastFocus2()?.current) { 24001 getLastFocus2().current.focus(); 24002 } else { 24003 containerRef.current.querySelector( 24004 `[data-block="$getSelectedBlockClientId2()}"]` 24005 ).focus(); 24006 } 24007 } else if (isZoomOut2()) { 24008 const sectionRootClientId = getSectionRootClientId2(); 24009 const sectionBlocks = getBlockOrder2(sectionRootClientId); 24010 if (sectionBlocks.length) { 24011 containerRef.current.querySelector(`[data-block="$sectionBlocks[0]}"]`).focus(); 24012 } else if (sectionRootClientId) { 24013 containerRef.current.querySelector(`[data-block="$sectionRootClientId}"]`).focus(); 24014 } else { 24015 canvasElement.focus(); 24016 } 24017 } else { 24018 const isBefore = ( 24019 // eslint-disable-next-line no-bitwise 24020 event.target.compareDocumentPosition(canvasElement) & event.target.DOCUMENT_POSITION_FOLLOWING 24021 ); 24022 const tabbables = import_dom8.focus.tabbable.find(containerRef.current); 24023 if (tabbables.length) { 24024 const next = isBefore ? tabbables[0] : tabbables[tabbables.length - 1]; 24025 next.focus(); 24026 } 24027 } 24028 } 24029 const before = /* @__PURE__ */ (0, import_jsx_runtime152.jsx)( 24030 "div", 24031 { 24032 ref: focusCaptureBeforeRef, 24033 tabIndex: "0", 24034 onFocus: onFocusCapture 24035 } 24036 ); 24037 const after = /* @__PURE__ */ (0, import_jsx_runtime152.jsx)( 24038 "div", 24039 { 24040 ref: focusCaptureAfterRef, 24041 tabIndex: "0", 24042 onFocus: onFocusCapture 24043 } 24044 ); 24045 const ref = (0, import_compose20.useRefEffect)((node) => { 24046 function onKeyDown(event) { 24047 if (event.defaultPrevented) { 24048 return; 24049 } 24050 if (event.keyCode !== import_keycodes3.TAB) { 24051 return; 24052 } 24053 if ( 24054 // Bails in case the focus capture elements aren’t present. They 24055 // may be omitted to avoid silent tab stops in preview mode. 24056 // See: https://github.com/WordPress/gutenberg/pull/59317 24057 !focusCaptureAfterRef.current || !focusCaptureBeforeRef.current 24058 ) { 24059 return; 24060 } 24061 const { target, shiftKey: isShift } = event; 24062 const direction = isShift ? "findPrevious" : "findNext"; 24063 const nextTabbable = import_dom8.focus.tabbable[direction](target); 24064 const currentBlock = target.closest("[data-block]"); 24065 const isElementPartOfSelectedBlock = currentBlock && nextTabbable && (isInSameBlock(currentBlock, nextTabbable) || isInsideRootBlock(currentBlock, nextTabbable)); 24066 if ((0, import_dom8.isFormElement)(nextTabbable) && isElementPartOfSelectedBlock) { 24067 return; 24068 } 24069 const next = isShift ? focusCaptureBeforeRef : focusCaptureAfterRef; 24070 noCaptureRef.current = true; 24071 next.current.focus({ preventScroll: true }); 24072 } 24073 function onFocusOut(event) { 24074 setLastFocus2({ ...getLastFocus2(), current: event.target }); 24075 const { ownerDocument: ownerDocument2 } = node; 24076 if (!event.relatedTarget && event.target.hasAttribute("data-block") && ownerDocument2.activeElement === ownerDocument2.body && getBlockCount2() === 0) { 24077 node.focus(); 24078 } 24079 } 24080 function preventScrollOnTab(event) { 24081 if (event.keyCode !== import_keycodes3.TAB) { 24082 return; 24083 } 24084 if (event.target?.getAttribute("role") === "region") { 24085 return; 24086 } 24087 if (containerRef.current === event.target) { 24088 return; 24089 } 24090 const isShift = event.shiftKey; 24091 const direction = isShift ? "findPrevious" : "findNext"; 24092 const target = import_dom8.focus.tabbable[direction](event.target); 24093 if (target === focusCaptureBeforeRef.current || target === focusCaptureAfterRef.current) { 24094 event.preventDefault(); 24095 target.focus({ preventScroll: true }); 24096 } 24097 } 24098 const { ownerDocument } = node; 24099 const { defaultView } = ownerDocument; 24100 defaultView.addEventListener("keydown", preventScrollOnTab); 24101 node.addEventListener("keydown", onKeyDown); 24102 node.addEventListener("focusout", onFocusOut); 24103 return () => { 24104 defaultView.removeEventListener("keydown", preventScrollOnTab); 24105 node.removeEventListener("keydown", onKeyDown); 24106 node.removeEventListener("focusout", onFocusOut); 24107 }; 24108 }, []); 24109 const mergedRefs = (0, import_compose20.useMergeRefs)([containerRef, ref]); 24110 return [before, mergedRefs, after]; 24111 } 24112 24113 // packages/block-editor/build-module/components/writing-flow/use-arrow-nav.js 24114 var import_dom10 = __toESM(require_dom()); 24115 var import_keycodes4 = __toESM(require_keycodes()); 24116 var import_data36 = __toESM(require_data()); 24117 var import_compose21 = __toESM(require_compose()); 24118 function isNavigationCandidate(element, keyCode, hasModifier) { 24119 const isVertical = keyCode === import_keycodes4.UP || keyCode === import_keycodes4.DOWN; 24120 const { tagName } = element; 24121 const elementType = element.getAttribute("type"); 24122 if (isVertical && !hasModifier) { 24123 if (tagName === "INPUT") { 24124 const verticalInputTypes = [ 24125 "date", 24126 "datetime-local", 24127 "month", 24128 "number", 24129 "range", 24130 "time", 24131 "week" 24132 ]; 24133 return !verticalInputTypes.includes(elementType); 24134 } 24135 return true; 24136 } 24137 if (tagName === "INPUT") { 24138 const simpleInputTypes = [ 24139 "button", 24140 "checkbox", 24141 "number", 24142 "color", 24143 "file", 24144 "image", 24145 "radio", 24146 "reset", 24147 "submit" 24148 ]; 24149 return simpleInputTypes.includes(elementType); 24150 } 24151 return tagName !== "TEXTAREA"; 24152 } 24153 function getClosestTabbable(target, isReverse, containerElement, onlyVertical) { 24154 let focusableNodes = import_dom10.focus.focusable.find(containerElement); 24155 if (isReverse) { 24156 focusableNodes.reverse(); 24157 } 24158 focusableNodes = focusableNodes.slice( 24159 focusableNodes.indexOf(target) + 1 24160 ); 24161 let targetRect; 24162 if (onlyVertical) { 24163 targetRect = target.getBoundingClientRect(); 24164 } 24165 function isTabCandidate(node) { 24166 if (node.closest("[inert]")) { 24167 return; 24168 } 24169 if (node.children.length === 1 && isInSameBlock(node, node.firstElementChild) && node.firstElementChild.getAttribute("contenteditable") === "true") { 24170 return; 24171 } 24172 if (!import_dom10.focus.tabbable.isTabbableIndex(node)) { 24173 return false; 24174 } 24175 if (node.isContentEditable && node.contentEditable !== "true") { 24176 return false; 24177 } 24178 if (onlyVertical) { 24179 const nodeRect = node.getBoundingClientRect(); 24180 if (nodeRect.left >= targetRect.right || nodeRect.right <= targetRect.left) { 24181 return false; 24182 } 24183 } 24184 return true; 24185 } 24186 return focusableNodes.find(isTabCandidate); 24187 } 24188 function useArrowNav() { 24189 const { 24190 getMultiSelectedBlocksStartClientId: getMultiSelectedBlocksStartClientId2, 24191 getMultiSelectedBlocksEndClientId: getMultiSelectedBlocksEndClientId2, 24192 getSettings: getSettings8, 24193 hasMultiSelection: hasMultiSelection2, 24194 __unstableIsFullySelected: __unstableIsFullySelected2 24195 } = (0, import_data36.useSelect)(store); 24196 const { selectBlock: selectBlock2 } = (0, import_data36.useDispatch)(store); 24197 return (0, import_compose21.useRefEffect)((node) => { 24198 let verticalRect; 24199 function onMouseDown() { 24200 verticalRect = null; 24201 } 24202 function isClosestTabbableABlock(target, isReverse) { 24203 const closestTabbable = getClosestTabbable( 24204 target, 24205 isReverse, 24206 node 24207 ); 24208 return closestTabbable && getBlockClientId(closestTabbable); 24209 } 24210 function onKeyDown(event) { 24211 if (event.defaultPrevented) { 24212 return; 24213 } 24214 const { keyCode, target, shiftKey, ctrlKey, altKey, metaKey } = event; 24215 const isUp = keyCode === import_keycodes4.UP; 24216 const isDown = keyCode === import_keycodes4.DOWN; 24217 const isLeft = keyCode === import_keycodes4.LEFT; 24218 const isRight = keyCode === import_keycodes4.RIGHT; 24219 const isReverse = isUp || isLeft; 24220 const isHorizontal = isLeft || isRight; 24221 const isVertical = isUp || isDown; 24222 const isNav = isHorizontal || isVertical; 24223 const hasModifier = shiftKey || ctrlKey || altKey || metaKey; 24224 const isNavEdge = isVertical ? import_dom10.isVerticalEdge : import_dom10.isHorizontalEdge; 24225 const { ownerDocument } = node; 24226 const { defaultView } = ownerDocument; 24227 if (!isNav) { 24228 return; 24229 } 24230 if (hasMultiSelection2()) { 24231 if (shiftKey) { 24232 return; 24233 } 24234 if (!__unstableIsFullySelected2()) { 24235 return; 24236 } 24237 event.preventDefault(); 24238 if (isReverse) { 24239 selectBlock2(getMultiSelectedBlocksStartClientId2()); 24240 } else { 24241 selectBlock2(getMultiSelectedBlocksEndClientId2(), -1); 24242 } 24243 return; 24244 } 24245 if (!isNavigationCandidate(target, keyCode, hasModifier)) { 24246 return; 24247 } 24248 if (!isVertical) { 24249 verticalRect = null; 24250 } else if (!verticalRect) { 24251 verticalRect = (0, import_dom10.computeCaretRect)(defaultView); 24252 } 24253 const isReverseDir = (0, import_dom10.isRTL)(target) ? !isReverse : isReverse; 24254 const { keepCaretInsideBlock } = getSettings8(); 24255 if (shiftKey) { 24256 if (isClosestTabbableABlock(target, isReverse) && isNavEdge(target, isReverse)) { 24257 node.contentEditable = true; 24258 node.focus(); 24259 } 24260 } else if (isVertical && (0, import_dom10.isVerticalEdge)(target, isReverse) && // When Alt is pressed, only intercept if the caret is also at 24261 // the horizontal edge. 24262 (altKey ? (0, import_dom10.isHorizontalEdge)(target, isReverseDir) : true) && !keepCaretInsideBlock) { 24263 const closestTabbable = getClosestTabbable( 24264 target, 24265 isReverse, 24266 node, 24267 true 24268 ); 24269 if (closestTabbable) { 24270 (0, import_dom10.placeCaretAtVerticalEdge)( 24271 closestTabbable, 24272 // When Alt is pressed, place the caret at the furthest 24273 // horizontal edge and the furthest vertical edge. 24274 altKey ? !isReverse : isReverse, 24275 altKey ? void 0 : verticalRect 24276 ); 24277 event.preventDefault(); 24278 } 24279 } else if (isHorizontal && defaultView.getSelection().isCollapsed && (0, import_dom10.isHorizontalEdge)(target, isReverseDir) && !keepCaretInsideBlock) { 24280 const closestTabbable = getClosestTabbable( 24281 target, 24282 isReverseDir, 24283 node 24284 ); 24285 (0, import_dom10.placeCaretAtHorizontalEdge)(closestTabbable, isReverse); 24286 event.preventDefault(); 24287 } 24288 } 24289 node.addEventListener("mousedown", onMouseDown); 24290 node.addEventListener("keydown", onKeyDown); 24291 return () => { 24292 node.removeEventListener("mousedown", onMouseDown); 24293 node.removeEventListener("keydown", onKeyDown); 24294 }; 24295 }, []); 24296 } 24297 24298 // packages/block-editor/build-module/components/writing-flow/use-select-all.js 24299 var import_dom12 = __toESM(require_dom()); 24300 var import_data37 = __toESM(require_data()); 24301 var import_keyboard_shortcuts3 = __toESM(require_keyboard_shortcuts()); 24302 var import_compose22 = __toESM(require_compose()); 24303 function useSelectAll() { 24304 const { getBlockOrder: getBlockOrder2, getSelectedBlockClientIds: getSelectedBlockClientIds2, getBlockRootClientId: getBlockRootClientId2 } = (0, import_data37.useSelect)(store); 24305 const { multiSelect: multiSelect2, selectBlock: selectBlock2 } = (0, import_data37.useDispatch)(store); 24306 const isMatch = (0, import_keyboard_shortcuts3.__unstableUseShortcutEventMatch)(); 24307 return (0, import_compose22.useRefEffect)((node) => { 24308 function onKeyDown(event) { 24309 if (!isMatch("core/block-editor/select-all", event)) { 24310 return; 24311 } 24312 const selectedClientIds = getSelectedBlockClientIds2(); 24313 if (selectedClientIds.length < 2 && !(0, import_dom12.isEntirelySelected)(event.target)) { 24314 return; 24315 } 24316 event.preventDefault(); 24317 const [firstSelectedClientId] = selectedClientIds; 24318 const rootClientId = getBlockRootClientId2(firstSelectedClientId); 24319 const blockClientIds = getBlockOrder2(rootClientId); 24320 if (selectedClientIds.length === blockClientIds.length) { 24321 if (rootClientId) { 24322 node.ownerDocument.defaultView.getSelection().removeAllRanges(); 24323 selectBlock2(rootClientId); 24324 } 24325 return; 24326 } 24327 multiSelect2( 24328 blockClientIds[0], 24329 blockClientIds[blockClientIds.length - 1] 24330 ); 24331 } 24332 node.addEventListener("keydown", onKeyDown); 24333 return () => { 24334 node.removeEventListener("keydown", onKeyDown); 24335 }; 24336 }, []); 24337 } 24338 24339 // packages/block-editor/build-module/components/writing-flow/use-drag-selection.js 24340 var import_data38 = __toESM(require_data()); 24341 var import_compose23 = __toESM(require_compose()); 24342 function setContentEditableWrapper(node, value) { 24343 node.contentEditable = value; 24344 if (value) { 24345 node.focus(); 24346 } 24347 } 24348 function useDragSelection() { 24349 const { startMultiSelect: startMultiSelect2, stopMultiSelect: stopMultiSelect2 } = (0, import_data38.useDispatch)(store); 24350 const { 24351 isSelectionEnabled: isSelectionEnabled3, 24352 hasSelectedBlock: hasSelectedBlock2, 24353 isDraggingBlocks: isDraggingBlocks2, 24354 isMultiSelecting: isMultiSelecting3 24355 } = (0, import_data38.useSelect)(store); 24356 return (0, import_compose23.useRefEffect)( 24357 (node) => { 24358 const { ownerDocument } = node; 24359 const { defaultView } = ownerDocument; 24360 let anchorElement; 24361 let rafId; 24362 function onMouseUp() { 24363 stopMultiSelect2(); 24364 defaultView.removeEventListener("mouseup", onMouseUp); 24365 rafId = defaultView.requestAnimationFrame(() => { 24366 if (!hasSelectedBlock2()) { 24367 return; 24368 } 24369 setContentEditableWrapper(node, false); 24370 const selection2 = defaultView.getSelection(); 24371 if (selection2.rangeCount) { 24372 const range2 = selection2.getRangeAt(0); 24373 const { commonAncestorContainer } = range2; 24374 const clonedRange = range2.cloneRange(); 24375 if (anchorElement.contains(commonAncestorContainer)) { 24376 anchorElement.focus(); 24377 selection2.removeAllRanges(); 24378 selection2.addRange(clonedRange); 24379 } 24380 } 24381 }); 24382 } 24383 let lastMouseDownTarget; 24384 function onMouseDown({ target }) { 24385 lastMouseDownTarget = target; 24386 } 24387 function onMouseLeave({ buttons, target, relatedTarget }) { 24388 if (!target.contains(lastMouseDownTarget)) { 24389 return; 24390 } 24391 if (target.contains(relatedTarget)) { 24392 return; 24393 } 24394 if (isDraggingBlocks2()) { 24395 return; 24396 } 24397 if (buttons !== 1) { 24398 return; 24399 } 24400 if (isMultiSelecting3()) { 24401 return; 24402 } 24403 if (node === target) { 24404 return; 24405 } 24406 if (target.getAttribute("contenteditable") !== "true") { 24407 return; 24408 } 24409 if (!isSelectionEnabled3()) { 24410 return; 24411 } 24412 anchorElement = target; 24413 startMultiSelect2(); 24414 defaultView.addEventListener("mouseup", onMouseUp); 24415 setContentEditableWrapper(node, true); 24416 } 24417 node.addEventListener("mouseout", onMouseLeave); 24418 node.addEventListener("mousedown", onMouseDown); 24419 return () => { 24420 node.removeEventListener("mouseout", onMouseLeave); 24421 defaultView.removeEventListener("mouseup", onMouseUp); 24422 defaultView.cancelAnimationFrame(rafId); 24423 }; 24424 }, 24425 [ 24426 startMultiSelect2, 24427 stopMultiSelect2, 24428 isSelectionEnabled3, 24429 hasSelectedBlock2 24430 ] 24431 ); 24432 } 24433 24434 // packages/block-editor/build-module/components/writing-flow/use-selection-observer.js 24435 var import_data39 = __toESM(require_data()); 24436 var import_compose24 = __toESM(require_compose()); 24437 var import_rich_text4 = __toESM(require_rich_text()); 24438 var import_dom13 = __toESM(require_dom()); 24439 function extractSelectionStartNode(selection2) { 24440 const { anchorNode, anchorOffset } = selection2; 24441 if (anchorNode.nodeType === anchorNode.TEXT_NODE) { 24442 return anchorNode; 24443 } 24444 if (anchorOffset === 0) { 24445 return anchorNode; 24446 } 24447 return anchorNode.childNodes[anchorOffset - 1]; 24448 } 24449 function extractSelectionEndNode(selection2) { 24450 const { focusNode, focusOffset } = selection2; 24451 if (focusNode.nodeType === focusNode.TEXT_NODE) { 24452 return focusNode; 24453 } 24454 if (focusOffset === focusNode.childNodes.length) { 24455 return focusNode; 24456 } 24457 if (focusOffset === 0 && (0, import_dom13.isSelectionForward)(selection2)) { 24458 return focusNode.previousSibling ?? focusNode.parentElement; 24459 } 24460 return focusNode.childNodes[focusOffset]; 24461 } 24462 function findDepth(a2, b2) { 24463 let depth = 0; 24464 while (a2[depth] === b2[depth]) { 24465 depth++; 24466 } 24467 return depth; 24468 } 24469 function setContentEditableWrapper2(node, value) { 24470 if (node.contentEditable !== String(value)) { 24471 node.contentEditable = value; 24472 if (value) { 24473 node.focus(); 24474 } 24475 } 24476 } 24477 function getRichTextElement(node) { 24478 const element = node.nodeType === node.ELEMENT_NODE ? node : node.parentElement; 24479 return element?.closest("[data-wp-block-attribute-key]"); 24480 } 24481 function useSelectionObserver() { 24482 const { multiSelect: multiSelect2, selectBlock: selectBlock2, selectionChange: selectionChange2 } = (0, import_data39.useDispatch)(store); 24483 const { getBlockParents: getBlockParents2, getBlockSelectionStart: getBlockSelectionStart2, isMultiSelecting: isMultiSelecting3 } = (0, import_data39.useSelect)(store); 24484 return (0, import_compose24.useRefEffect)( 24485 (node) => { 24486 const { ownerDocument } = node; 24487 const { defaultView } = ownerDocument; 24488 function onSelectionChange(event) { 24489 const selection2 = defaultView.getSelection(); 24490 if (!selection2.rangeCount) { 24491 return; 24492 } 24493 const startNode = extractSelectionStartNode(selection2); 24494 const endNode = extractSelectionEndNode(selection2); 24495 if (!node.contains(startNode) || !node.contains(endNode)) { 24496 return; 24497 } 24498 const isClickShift = event.shiftKey && event.type === "mouseup"; 24499 if (selection2.isCollapsed && !isClickShift) { 24500 if (node.contentEditable === "true" && !isMultiSelecting3()) { 24501 setContentEditableWrapper2(node, false); 24502 let element = startNode.nodeType === startNode.ELEMENT_NODE ? startNode : startNode.parentElement; 24503 element = element?.closest("[contenteditable]"); 24504 element?.focus(); 24505 } 24506 return; 24507 } 24508 let startClientId = getBlockClientId(startNode); 24509 let endClientId = getBlockClientId(endNode); 24510 if (isClickShift) { 24511 const selectedClientId = getBlockSelectionStart2(); 24512 const clickedClientId = getBlockClientId(event.target); 24513 const focusNodeIsNonSelectable = clickedClientId !== endClientId; 24514 if (startClientId === endClientId && selection2.isCollapsed || !endClientId || focusNodeIsNonSelectable) { 24515 endClientId = clickedClientId; 24516 } 24517 if (startClientId !== selectedClientId) { 24518 startClientId = selectedClientId; 24519 } 24520 } 24521 if (startClientId === void 0 && endClientId === void 0) { 24522 setContentEditableWrapper2(node, false); 24523 return; 24524 } 24525 const isSingularSelection = startClientId === endClientId; 24526 if (isSingularSelection) { 24527 if (!isMultiSelecting3()) { 24528 selectBlock2(startClientId); 24529 } else { 24530 multiSelect2(startClientId, startClientId); 24531 } 24532 } else { 24533 const startPath = [ 24534 ...getBlockParents2(startClientId), 24535 startClientId 24536 ]; 24537 const endPath = [ 24538 ...getBlockParents2(endClientId), 24539 endClientId 24540 ]; 24541 const depth = findDepth(startPath, endPath); 24542 if (startPath[depth] !== startClientId || endPath[depth] !== endClientId) { 24543 multiSelect2(startPath[depth], endPath[depth]); 24544 return; 24545 } 24546 const richTextElementStart = getRichTextElement(startNode); 24547 const richTextElementEnd = getRichTextElement(endNode); 24548 if (richTextElementStart && richTextElementEnd) { 24549 const range2 = selection2.getRangeAt(0); 24550 const richTextDataStart = (0, import_rich_text4.create)({ 24551 element: richTextElementStart, 24552 range: range2, 24553 __unstableIsEditableTree: true 24554 }); 24555 const richTextDataEnd = (0, import_rich_text4.create)({ 24556 element: richTextElementEnd, 24557 range: range2, 24558 __unstableIsEditableTree: true 24559 }); 24560 const startOffset = richTextDataStart.start ?? richTextDataStart.end; 24561 const endOffset = richTextDataEnd.start ?? richTextDataEnd.end; 24562 selectionChange2({ 24563 start: { 24564 clientId: startClientId, 24565 attributeKey: richTextElementStart.dataset.wpBlockAttributeKey, 24566 offset: startOffset 24567 }, 24568 end: { 24569 clientId: endClientId, 24570 attributeKey: richTextElementEnd.dataset.wpBlockAttributeKey, 24571 offset: endOffset 24572 } 24573 }); 24574 } else { 24575 multiSelect2(startClientId, endClientId); 24576 } 24577 } 24578 } 24579 ownerDocument.addEventListener( 24580 "selectionchange", 24581 onSelectionChange 24582 ); 24583 defaultView.addEventListener("mouseup", onSelectionChange); 24584 return () => { 24585 ownerDocument.removeEventListener( 24586 "selectionchange", 24587 onSelectionChange 24588 ); 24589 defaultView.removeEventListener("mouseup", onSelectionChange); 24590 }; 24591 }, 24592 [multiSelect2, selectBlock2, selectionChange2, getBlockParents2] 24593 ); 24594 } 24595 24596 // packages/block-editor/build-module/components/writing-flow/use-click-selection.js 24597 var import_data40 = __toESM(require_data()); 24598 var import_compose25 = __toESM(require_compose()); 24599 function useClickSelection() { 24600 const { selectBlock: selectBlock2 } = (0, import_data40.useDispatch)(store); 24601 const { isSelectionEnabled: isSelectionEnabled3, getBlockSelectionStart: getBlockSelectionStart2, hasMultiSelection: hasMultiSelection2 } = (0, import_data40.useSelect)(store); 24602 return (0, import_compose25.useRefEffect)( 24603 (node) => { 24604 function onMouseDown(event) { 24605 if (!isSelectionEnabled3() || event.button !== 0) { 24606 return; 24607 } 24608 const startClientId = getBlockSelectionStart2(); 24609 const clickedClientId = getBlockClientId(event.target); 24610 if (event.shiftKey) { 24611 if (startClientId && startClientId !== clickedClientId) { 24612 node.contentEditable = true; 24613 node.focus(); 24614 } 24615 } else if (hasMultiSelection2()) { 24616 selectBlock2(clickedClientId); 24617 } 24618 } 24619 node.addEventListener("mousedown", onMouseDown); 24620 return () => { 24621 node.removeEventListener("mousedown", onMouseDown); 24622 }; 24623 }, 24624 [ 24625 selectBlock2, 24626 isSelectionEnabled3, 24627 getBlockSelectionStart2, 24628 hasMultiSelection2 24629 ] 24630 ); 24631 } 24632 24633 // packages/block-editor/build-module/components/writing-flow/use-input.js 24634 var import_data41 = __toESM(require_data()); 24635 var import_compose26 = __toESM(require_compose()); 24636 var import_keycodes5 = __toESM(require_keycodes()); 24637 var import_blocks22 = __toESM(require_blocks()); 24638 function useInput() { 24639 const { 24640 __unstableIsFullySelected: __unstableIsFullySelected2, 24641 getSelectedBlockClientIds: getSelectedBlockClientIds2, 24642 getSelectedBlockClientId: getSelectedBlockClientId2, 24643 __unstableIsSelectionMergeable: __unstableIsSelectionMergeable2, 24644 hasMultiSelection: hasMultiSelection2, 24645 getBlockName: getBlockName2, 24646 canInsertBlockType: canInsertBlockType2, 24647 getBlockRootClientId: getBlockRootClientId2, 24648 getSelectionStart: getSelectionStart2, 24649 getSelectionEnd: getSelectionEnd2, 24650 getBlockAttributes: getBlockAttributes3 24651 } = (0, import_data41.useSelect)(store); 24652 const { 24653 replaceBlocks: replaceBlocks2, 24654 __unstableSplitSelection: __unstableSplitSelection2, 24655 removeBlocks: removeBlocks2, 24656 __unstableDeleteSelection: __unstableDeleteSelection2, 24657 __unstableExpandSelection: __unstableExpandSelection2, 24658 __unstableMarkAutomaticChange: __unstableMarkAutomaticChange2 24659 } = (0, import_data41.useDispatch)(store); 24660 return (0, import_compose26.useRefEffect)((node) => { 24661 function onBeforeInput(event) { 24662 if (node.contentEditable === "true") { 24663 event.preventDefault(); 24664 } 24665 } 24666 function onKeyDown(event) { 24667 if (event.defaultPrevented) { 24668 return; 24669 } 24670 if (!hasMultiSelection2()) { 24671 if (event.keyCode === import_keycodes5.ENTER) { 24672 if (event.shiftKey || __unstableIsFullySelected2()) { 24673 return; 24674 } 24675 const clientId = getSelectedBlockClientId2(); 24676 const blockName = getBlockName2(clientId); 24677 const selectionStart = getSelectionStart2(); 24678 const selectionEnd = getSelectionEnd2(); 24679 if (selectionStart.attributeKey === selectionEnd.attributeKey) { 24680 const selectedAttributeValue = getBlockAttributes3(clientId)[selectionStart.attributeKey]; 24681 const transforms = (0, import_blocks22.getBlockTransforms)("from").filter( 24682 ({ type }) => type === "enter" 24683 ); 24684 const transformation = (0, import_blocks22.findTransform)( 24685 transforms, 24686 (item) => { 24687 return item.regExp.test( 24688 selectedAttributeValue 24689 ); 24690 } 24691 ); 24692 if (transformation) { 24693 replaceBlocks2( 24694 clientId, 24695 transformation.transform({ 24696 content: selectedAttributeValue 24697 }) 24698 ); 24699 __unstableMarkAutomaticChange2(); 24700 return; 24701 } 24702 } 24703 if (!(0, import_blocks22.hasBlockSupport)(blockName, "splitting", false) && !event.__deprecatedOnSplit) { 24704 return; 24705 } 24706 if (canInsertBlockType2( 24707 blockName, 24708 getBlockRootClientId2(clientId) 24709 )) { 24710 __unstableSplitSelection2(); 24711 event.preventDefault(); 24712 } 24713 } 24714 return; 24715 } 24716 if (event.keyCode === import_keycodes5.ENTER) { 24717 node.contentEditable = false; 24718 event.preventDefault(); 24719 if (__unstableIsFullySelected2()) { 24720 replaceBlocks2( 24721 getSelectedBlockClientIds2(), 24722 (0, import_blocks22.createBlock)((0, import_blocks22.getDefaultBlockName)()) 24723 ); 24724 } else { 24725 __unstableSplitSelection2(); 24726 } 24727 } else if (event.keyCode === import_keycodes5.BACKSPACE || event.keyCode === import_keycodes5.DELETE) { 24728 node.contentEditable = false; 24729 event.preventDefault(); 24730 if (__unstableIsFullySelected2()) { 24731 removeBlocks2(getSelectedBlockClientIds2()); 24732 } else if (__unstableIsSelectionMergeable2()) { 24733 __unstableDeleteSelection2(event.keyCode === import_keycodes5.DELETE); 24734 } else { 24735 __unstableExpandSelection2(); 24736 } 24737 } else if ( 24738 // If key.length is longer than 1, it's a control key that doesn't 24739 // input anything. 24740 event.key.length === 1 && !(event.metaKey || event.ctrlKey) 24741 ) { 24742 node.contentEditable = false; 24743 if (__unstableIsSelectionMergeable2()) { 24744 __unstableDeleteSelection2(event.keyCode === import_keycodes5.DELETE); 24745 } else { 24746 event.preventDefault(); 24747 node.ownerDocument.defaultView.getSelection().removeAllRanges(); 24748 } 24749 } 24750 } 24751 function onCompositionStart(event) { 24752 if (!hasMultiSelection2()) { 24753 return; 24754 } 24755 node.contentEditable = false; 24756 if (__unstableIsSelectionMergeable2()) { 24757 __unstableDeleteSelection2(); 24758 } else { 24759 event.preventDefault(); 24760 node.ownerDocument.defaultView.getSelection().removeAllRanges(); 24761 } 24762 } 24763 node.addEventListener("beforeinput", onBeforeInput); 24764 node.addEventListener("keydown", onKeyDown); 24765 node.addEventListener("compositionstart", onCompositionStart); 24766 return () => { 24767 node.removeEventListener("beforeinput", onBeforeInput); 24768 node.removeEventListener("keydown", onKeyDown); 24769 node.removeEventListener("compositionstart", onCompositionStart); 24770 }; 24771 }, []); 24772 } 24773 24774 // packages/block-editor/build-module/components/writing-flow/use-clipboard-handler.js 24775 var import_blocks25 = __toESM(require_blocks()); 24776 var import_dom18 = __toESM(require_dom()); 24777 var import_data43 = __toESM(require_data()); 24778 var import_compose27 = __toESM(require_compose()); 24779 24780 // packages/block-editor/build-module/utils/use-notify-copy.js 24781 var import_element41 = __toESM(require_element()); 24782 var import_blocks23 = __toESM(require_blocks()); 24783 var import_data42 = __toESM(require_data()); 24784 var import_i18n32 = __toESM(require_i18n()); 24785 var import_notices3 = __toESM(require_notices()); 24786 function useNotifyCopy() { 24787 const { getBlockName: getBlockName2 } = (0, import_data42.useSelect)(store); 24788 const { getBlockType: getBlockType21 } = (0, import_data42.useSelect)(import_blocks23.store); 24789 const { createSuccessNotice } = (0, import_data42.useDispatch)(import_notices3.store); 24790 return (0, import_element41.useCallback)( 24791 (eventType, selectedBlockClientIds) => { 24792 let notice = ""; 24793 if (eventType === "copyStyles") { 24794 notice = (0, import_i18n32.__)("Styles copied to clipboard."); 24795 } else if (selectedBlockClientIds.length === 1) { 24796 const clientId = selectedBlockClientIds[0]; 24797 const title = getBlockType21(getBlockName2(clientId))?.title; 24798 if (eventType === "copy") { 24799 notice = (0, import_i18n32.sprintf)( 24800 // Translators: %s: Name of the block being copied, e.g. "Paragraph". 24801 (0, import_i18n32.__)('Copied "%s" to clipboard.'), 24802 title 24803 ); 24804 } else { 24805 notice = (0, import_i18n32.sprintf)( 24806 // Translators: %s: Name of the block being cut, e.g. "Paragraph". 24807 (0, import_i18n32.__)('Moved "%s" to clipboard.'), 24808 title 24809 ); 24810 } 24811 } else if (eventType === "copy") { 24812 notice = (0, import_i18n32.sprintf)( 24813 // Translators: %d: Number of blocks being copied. 24814 (0, import_i18n32._n)( 24815 "Copied %d block to clipboard.", 24816 "Copied %d blocks to clipboard.", 24817 selectedBlockClientIds.length 24818 ), 24819 selectedBlockClientIds.length 24820 ); 24821 } else { 24822 notice = (0, import_i18n32.sprintf)( 24823 // Translators: %d: Number of blocks being moved. 24824 (0, import_i18n32._n)( 24825 "Moved %d block to clipboard.", 24826 "Moved %d blocks to clipboard.", 24827 selectedBlockClientIds.length 24828 ), 24829 selectedBlockClientIds.length 24830 ); 24831 } 24832 createSuccessNotice(notice, { 24833 type: "snackbar" 24834 }); 24835 }, 24836 [createSuccessNotice, getBlockName2, getBlockType21] 24837 ); 24838 } 24839 24840 // packages/block-editor/build-module/components/writing-flow/utils.js 24841 var import_dom17 = __toESM(require_dom()); 24842 var import_blocks24 = __toESM(require_blocks()); 24843 24844 // packages/block-editor/build-module/utils/pasting.js 24845 var import_dom16 = __toESM(require_dom()); 24846 function removeWindowsFragments(html) { 24847 const startStr = "<!--StartFragment-->"; 24848 const startIdx = html.indexOf(startStr); 24849 if (startIdx > -1) { 24850 html = html.substring(startIdx + startStr.length); 24851 } else { 24852 return html; 24853 } 24854 const endStr = "<!--EndFragment-->"; 24855 const endIdx = html.indexOf(endStr); 24856 if (endIdx > -1) { 24857 html = html.substring(0, endIdx); 24858 } 24859 return html; 24860 } 24861 function removeCharsetMetaTag(html) { 24862 const metaTag = `<meta charset='utf-8'>`; 24863 if (html.startsWith(metaTag)) { 24864 return html.slice(metaTag.length); 24865 } 24866 return html; 24867 } 24868 function getPasteEventData({ clipboardData }) { 24869 let plainText = ""; 24870 let html = ""; 24871 try { 24872 plainText = clipboardData.getData("text/plain"); 24873 html = clipboardData.getData("text/html"); 24874 } catch (error) { 24875 return; 24876 } 24877 html = removeWindowsFragments(html); 24878 html = removeCharsetMetaTag(html); 24879 const files = (0, import_dom16.getFilesFromDataTransfer)(clipboardData); 24880 if (files.length && !shouldDismissPastedFiles(files, html)) { 24881 return { files }; 24882 } 24883 return { html, plainText, files: [] }; 24884 } 24885 function shouldDismissPastedFiles(files, html) { 24886 if (html && files?.length === 1 && files[0].type.indexOf("image/") === 0) { 24887 const IMAGE_TAG = /<\s*img\b/gi; 24888 if (html.match(IMAGE_TAG)?.length !== 1) { 24889 return true; 24890 } 24891 const IMG_WITH_LOCAL_SRC = /<\s*img\b[^>]*\bsrc="file:\/\//i; 24892 if (html.match(IMG_WITH_LOCAL_SRC)) { 24893 return true; 24894 } 24895 } 24896 return false; 24897 } 24898 24899 // packages/block-editor/build-module/components/writing-flow/utils.js 24900 var requiresWrapperOnCopy = Symbol("requiresWrapperOnCopy"); 24901 function setClipboardBlocks(event, blocks2, registry) { 24902 let _blocks = blocks2; 24903 const [firstBlock] = blocks2; 24904 if (firstBlock) { 24905 const firstBlockType = registry.select(import_blocks24.store).getBlockType(firstBlock.name); 24906 if (firstBlockType[requiresWrapperOnCopy]) { 24907 const { getBlockRootClientId: getBlockRootClientId2, getBlockName: getBlockName2, getBlockAttributes: getBlockAttributes3 } = registry.select(store); 24908 const wrapperBlockClientId = getBlockRootClientId2( 24909 firstBlock.clientId 24910 ); 24911 const wrapperBlockName = getBlockName2(wrapperBlockClientId); 24912 if (wrapperBlockName) { 24913 _blocks = (0, import_blocks24.createBlock)( 24914 wrapperBlockName, 24915 getBlockAttributes3(wrapperBlockClientId), 24916 _blocks 24917 ); 24918 } 24919 } 24920 } 24921 const serialized = (0, import_blocks24.serialize)(_blocks); 24922 event.clipboardData.setData("text/plain", toPlainText(serialized)); 24923 event.clipboardData.setData("text/html", serialized); 24924 } 24925 function getPasteBlocks(event, canUserUseUnfilteredHTML) { 24926 const { plainText, html, files } = getPasteEventData(event); 24927 let blocks2 = []; 24928 if (files.length) { 24929 const fromTransforms = (0, import_blocks24.getBlockTransforms)("from"); 24930 blocks2 = files.reduce((accumulator, file) => { 24931 const transformation = (0, import_blocks24.findTransform)( 24932 fromTransforms, 24933 (transform) => transform.type === "files" && transform.isMatch([file]) 24934 ); 24935 if (transformation) { 24936 accumulator.push(transformation.transform([file])); 24937 } 24938 return accumulator; 24939 }, []).flat(); 24940 } else { 24941 blocks2 = (0, import_blocks24.pasteHandler)({ 24942 HTML: html, 24943 plainText, 24944 mode: "BLOCKS", 24945 canUserUseUnfilteredHTML 24946 }); 24947 } 24948 return blocks2; 24949 } 24950 function toPlainText(html) { 24951 html = html.replace(/<br>/g, "\n"); 24952 const plainText = (0, import_dom17.__unstableStripHTML)(html).trim(); 24953 return plainText.replace(/\n\n+/g, "\n\n"); 24954 } 24955 24956 // packages/block-editor/build-module/components/writing-flow/use-clipboard-handler.js 24957 function useClipboardHandler() { 24958 const registry = (0, import_data43.useRegistry)(); 24959 const { 24960 getBlocksByClientId: getBlocksByClientId2, 24961 getSelectedBlockClientIds: getSelectedBlockClientIds2, 24962 hasMultiSelection: hasMultiSelection2, 24963 getSettings: getSettings8, 24964 getBlockName: getBlockName2, 24965 __unstableIsFullySelected: __unstableIsFullySelected2, 24966 __unstableIsSelectionCollapsed: __unstableIsSelectionCollapsed2, 24967 __unstableIsSelectionMergeable: __unstableIsSelectionMergeable2, 24968 __unstableGetSelectedBlocksWithPartialSelection: __unstableGetSelectedBlocksWithPartialSelection2, 24969 canInsertBlockType: canInsertBlockType2, 24970 getBlockRootClientId: getBlockRootClientId2 24971 } = (0, import_data43.useSelect)(store); 24972 const { 24973 flashBlock: flashBlock2, 24974 removeBlocks: removeBlocks2, 24975 replaceBlocks: replaceBlocks2, 24976 __unstableDeleteSelection: __unstableDeleteSelection2, 24977 __unstableExpandSelection: __unstableExpandSelection2, 24978 __unstableSplitSelection: __unstableSplitSelection2 24979 } = (0, import_data43.useDispatch)(store); 24980 const notifyCopy = useNotifyCopy(); 24981 return (0, import_compose27.useRefEffect)((node) => { 24982 function handler(event) { 24983 if (event.defaultPrevented) { 24984 return; 24985 } 24986 const selectedBlockClientIds = getSelectedBlockClientIds2(); 24987 if (selectedBlockClientIds.length === 0) { 24988 return; 24989 } 24990 if (!hasMultiSelection2()) { 24991 const { target } = event; 24992 const { ownerDocument } = target; 24993 const hasSelection = event.type === "copy" || event.type === "cut" ? (0, import_dom18.documentHasUncollapsedSelection)(ownerDocument) : (0, import_dom18.documentHasSelection)(ownerDocument) && !ownerDocument.activeElement.isContentEditable; 24994 if (hasSelection) { 24995 return; 24996 } 24997 } 24998 const { activeElement } = event.target.ownerDocument; 24999 if (!node.contains(activeElement)) { 25000 return; 25001 } 25002 const isSelectionMergeable = __unstableIsSelectionMergeable2(); 25003 const shouldHandleWholeBlocks = __unstableIsSelectionCollapsed2() || __unstableIsFullySelected2(); 25004 const expandSelectionIsNeeded = !shouldHandleWholeBlocks && !isSelectionMergeable; 25005 if (event.type === "copy" || event.type === "cut") { 25006 event.preventDefault(); 25007 if (selectedBlockClientIds.length === 1) { 25008 flashBlock2(selectedBlockClientIds[0]); 25009 } 25010 if (expandSelectionIsNeeded) { 25011 __unstableExpandSelection2(); 25012 } else { 25013 notifyCopy(event.type, selectedBlockClientIds); 25014 let blocks2; 25015 if (shouldHandleWholeBlocks) { 25016 blocks2 = getBlocksByClientId2(selectedBlockClientIds); 25017 } else { 25018 const [head, tail] = __unstableGetSelectedBlocksWithPartialSelection2(); 25019 const inBetweenBlocks = getBlocksByClientId2( 25020 selectedBlockClientIds.slice( 25021 1, 25022 selectedBlockClientIds.length - 1 25023 ) 25024 ); 25025 blocks2 = [head, ...inBetweenBlocks, tail]; 25026 } 25027 setClipboardBlocks(event, blocks2, registry); 25028 } 25029 } 25030 if (event.type === "cut") { 25031 if (shouldHandleWholeBlocks && !expandSelectionIsNeeded) { 25032 removeBlocks2(selectedBlockClientIds); 25033 } else { 25034 event.target.ownerDocument.activeElement.contentEditable = false; 25035 __unstableDeleteSelection2(); 25036 } 25037 } else if (event.type === "paste") { 25038 const { 25039 __experimentalCanUserUseUnfilteredHTML: canUserUseUnfilteredHTML, 25040 mediaUpload: mediaUpload2 25041 } = getSettings8(); 25042 const isInternal = event.clipboardData.getData("rich-text") === "true"; 25043 if (isInternal) { 25044 return; 25045 } 25046 const { plainText, html, files } = getPasteEventData(event); 25047 const isFullySelected = __unstableIsFullySelected2(); 25048 let blocks2 = []; 25049 if (files.length) { 25050 if (!mediaUpload2) { 25051 event.preventDefault(); 25052 return; 25053 } 25054 const fromTransforms = (0, import_blocks25.getBlockTransforms)("from"); 25055 blocks2 = files.reduce((accumulator, file) => { 25056 const transformation = (0, import_blocks25.findTransform)( 25057 fromTransforms, 25058 (transform) => transform.type === "files" && transform.isMatch([file]) 25059 ); 25060 if (transformation) { 25061 accumulator.push( 25062 transformation.transform([file]) 25063 ); 25064 } 25065 return accumulator; 25066 }, []).flat(); 25067 } else { 25068 blocks2 = (0, import_blocks25.pasteHandler)({ 25069 HTML: html, 25070 plainText, 25071 mode: isFullySelected ? "BLOCKS" : "AUTO", 25072 canUserUseUnfilteredHTML 25073 }); 25074 } 25075 if (typeof blocks2 === "string") { 25076 return; 25077 } 25078 if (isFullySelected) { 25079 replaceBlocks2( 25080 selectedBlockClientIds, 25081 blocks2, 25082 blocks2.length - 1, 25083 -1 25084 ); 25085 event.preventDefault(); 25086 return; 25087 } 25088 if (!hasMultiSelection2() && !(0, import_blocks25.hasBlockSupport)( 25089 getBlockName2(selectedBlockClientIds[0]), 25090 "splitting", 25091 false 25092 ) && !event.__deprecatedOnSplit) { 25093 return; 25094 } 25095 const [firstSelectedClientId] = selectedBlockClientIds; 25096 const rootClientId = getBlockRootClientId2( 25097 firstSelectedClientId 25098 ); 25099 const newBlocks = []; 25100 for (const block of blocks2) { 25101 if (canInsertBlockType2(block.name, rootClientId)) { 25102 newBlocks.push(block); 25103 } else { 25104 const rootBlockName = getBlockName2(rootClientId); 25105 const switchedBlocks = block.name !== rootBlockName ? (0, import_blocks25.switchToBlockType)(block, rootBlockName) : [block]; 25106 if (!switchedBlocks) { 25107 return; 25108 } 25109 for (const switchedBlock of switchedBlocks) { 25110 for (const innerBlock of switchedBlock.innerBlocks) { 25111 newBlocks.push(innerBlock); 25112 } 25113 } 25114 } 25115 } 25116 __unstableSplitSelection2(newBlocks); 25117 event.preventDefault(); 25118 } 25119 } 25120 node.ownerDocument.addEventListener("copy", handler); 25121 node.ownerDocument.addEventListener("cut", handler); 25122 node.ownerDocument.addEventListener("paste", handler); 25123 return () => { 25124 node.ownerDocument.removeEventListener("copy", handler); 25125 node.ownerDocument.removeEventListener("cut", handler); 25126 node.ownerDocument.removeEventListener("paste", handler); 25127 }; 25128 }, []); 25129 } 25130 25131 // packages/block-editor/build-module/components/writing-flow/index.js 25132 var import_jsx_runtime153 = __toESM(require_jsx_runtime()); 25133 function useWritingFlow() { 25134 const [before, ref, after] = useTabNav(); 25135 const hasMultiSelection2 = (0, import_data44.useSelect)( 25136 (select3) => select3(store).hasMultiSelection(), 25137 [] 25138 ); 25139 return [ 25140 before, 25141 (0, import_compose28.useMergeRefs)([ 25142 ref, 25143 useClipboardHandler(), 25144 useInput(), 25145 useDragSelection(), 25146 useSelectionObserver(), 25147 useClickSelection(), 25148 useMultiSelection(), 25149 useSelectAll(), 25150 useArrowNav(), 25151 (0, import_compose28.useRefEffect)( 25152 (node) => { 25153 node.tabIndex = 0; 25154 node.dataset.hasMultiSelection = hasMultiSelection2; 25155 if (!hasMultiSelection2) { 25156 return () => { 25157 delete node.dataset.hasMultiSelection; 25158 }; 25159 } 25160 node.setAttribute( 25161 "aria-label", 25162 (0, import_i18n33.__)("Multiple selected blocks") 25163 ); 25164 return () => { 25165 delete node.dataset.hasMultiSelection; 25166 node.removeAttribute("aria-label"); 25167 }; 25168 }, 25169 [hasMultiSelection2] 25170 ) 25171 ]), 25172 after 25173 ]; 25174 } 25175 function WritingFlow({ children, ...props }, forwardedRef) { 25176 const [before, ref, after] = useWritingFlow(); 25177 return /* @__PURE__ */ (0, import_jsx_runtime153.jsxs)(import_jsx_runtime153.Fragment, { children: [ 25178 before, 25179 /* @__PURE__ */ (0, import_jsx_runtime153.jsx)( 25180 "div", 25181 { 25182 ...props, 25183 ref: (0, import_compose28.useMergeRefs)([ref, forwardedRef]), 25184 className: clsx_default( 25185 props.className, 25186 "block-editor-writing-flow" 25187 ), 25188 children 25189 } 25190 ), 25191 after 25192 ] }); 25193 } 25194 var writing_flow_default = (0, import_element42.forwardRef)(WritingFlow); 25195 25196 // packages/block-editor/build-module/components/iframe/get-compatibility-styles.js 25197 var compatibilityStyles = null; 25198 function getCompatibilityStyles() { 25199 if (compatibilityStyles) { 25200 return compatibilityStyles; 25201 } 25202 compatibilityStyles = Array.from(document.styleSheets).reduce( 25203 (accumulator, styleSheet) => { 25204 try { 25205 styleSheet.cssRules; 25206 } catch (e2) { 25207 return accumulator; 25208 } 25209 const { ownerNode, cssRules } = styleSheet; 25210 if (ownerNode === null) { 25211 return accumulator; 25212 } 25213 if (!cssRules) { 25214 return accumulator; 25215 } 25216 if (ownerNode.id.startsWith("wp-")) { 25217 return accumulator; 25218 } 25219 if (!ownerNode.id) { 25220 return accumulator; 25221 } 25222 function matchFromRules(_cssRules) { 25223 return Array.from(_cssRules).find( 25224 ({ 25225 selectorText, 25226 conditionText, 25227 cssRules: __cssRules 25228 }) => { 25229 if (conditionText) { 25230 return matchFromRules(__cssRules); 25231 } 25232 return selectorText && (selectorText.includes( 25233 ".editor-styles-wrapper" 25234 ) || selectorText.includes(".wp-block")); 25235 } 25236 ); 25237 } 25238 if (matchFromRules(cssRules)) { 25239 const isInline = ownerNode.tagName === "STYLE"; 25240 if (isInline) { 25241 const mainStylesCssId = ownerNode.id.replace( 25242 "-inline-css", 25243 "-css" 25244 ); 25245 const mainStylesElement = document.getElementById(mainStylesCssId); 25246 if (mainStylesElement) { 25247 accumulator.push(mainStylesElement.cloneNode(true)); 25248 } 25249 } 25250 accumulator.push(ownerNode.cloneNode(true)); 25251 if (!isInline) { 25252 const inlineStylesCssId = ownerNode.id.replace( 25253 "-css", 25254 "-inline-css" 25255 ); 25256 const inlineStylesElement = document.getElementById(inlineStylesCssId); 25257 if (inlineStylesElement) { 25258 accumulator.push( 25259 inlineStylesElement.cloneNode(true) 25260 ); 25261 } 25262 } 25263 } 25264 return accumulator; 25265 }, 25266 [] 25267 ); 25268 return compatibilityStyles; 25269 } 25270 25271 // packages/block-editor/build-module/components/iframe/use-scale-canvas.js 25272 var import_element43 = __toESM(require_element()); 25273 var import_compose29 = __toESM(require_compose()); 25274 function calculateScale({ 25275 frameSize, 25276 containerWidth, 25277 maxContainerWidth, 25278 scaleContainerWidth 25279 }) { 25280 return (Math.min(containerWidth, maxContainerWidth) - frameSize * 2) / scaleContainerWidth; 25281 } 25282 function computeScrollHeightNext(transitionFrom, transitionTo) { 25283 const { scaleValue: prevScale, scrollHeight: prevScrollHeight } = transitionFrom; 25284 const { frameSize, scaleValue } = transitionTo; 25285 return prevScrollHeight * (scaleValue / prevScale) + frameSize * 2; 25286 } 25287 function computeScrollTopNext(transitionFrom, transitionTo) { 25288 const { 25289 containerHeight: prevContainerHeight, 25290 frameSize: prevFrameSize, 25291 scaleValue: prevScale, 25292 scrollTop: prevScrollTop 25293 } = transitionFrom; 25294 const { containerHeight, frameSize, scaleValue, scrollHeight } = transitionTo; 25295 let scrollTopNext = prevScrollTop; 25296 scrollTopNext = (scrollTopNext + prevContainerHeight / 2 - prevFrameSize) / prevScale - prevContainerHeight / 2; 25297 scrollTopNext = (scrollTopNext + containerHeight / 2) * scaleValue + frameSize - containerHeight / 2; 25298 scrollTopNext = prevScrollTop <= prevFrameSize ? 0 : scrollTopNext; 25299 const maxScrollTop = scrollHeight - containerHeight; 25300 return Math.round( 25301 Math.min(Math.max(0, scrollTopNext), Math.max(0, maxScrollTop)) 25302 ); 25303 } 25304 function getAnimationKeyframes(transitionFrom, transitionTo) { 25305 const { 25306 scaleValue: prevScale, 25307 frameSize: prevFrameSize, 25308 scrollTop 25309 } = transitionFrom; 25310 const { scaleValue, frameSize, scrollTop: scrollTopNext } = transitionTo; 25311 return [ 25312 { 25313 translate: `0 0`, 25314 scale: prevScale, 25315 paddingTop: `$prevFrameSize / prevScale}px`, 25316 paddingBottom: `$prevFrameSize / prevScale}px` 25317 }, 25318 { 25319 translate: `0 $scrollTop - scrollTopNext}px`, 25320 scale: scaleValue, 25321 paddingTop: `$frameSize / scaleValue}px`, 25322 paddingBottom: `$frameSize / scaleValue}px` 25323 } 25324 ]; 25325 } 25326 function useScaleCanvas({ 25327 frameSize, 25328 iframeDocument, 25329 maxContainerWidth = 750, 25330 scale 25331 }) { 25332 const [contentResizeListener, { height: contentHeight }] = (0, import_compose29.useResizeObserver)(); 25333 const [ 25334 containerResizeListener, 25335 { width: containerWidth, height: containerHeight } 25336 ] = (0, import_compose29.useResizeObserver)(); 25337 const initialContainerWidthRef = (0, import_element43.useRef)(0); 25338 const isZoomedOut = scale !== 1; 25339 const prefersReducedMotion = (0, import_compose29.useReducedMotion)(); 25340 const isAutoScaled = scale === "auto-scaled"; 25341 const startAnimationRef = (0, import_element43.useRef)(false); 25342 const animationRef = (0, import_element43.useRef)(null); 25343 (0, import_element43.useEffect)(() => { 25344 if (!isZoomedOut) { 25345 initialContainerWidthRef.current = containerWidth; 25346 } 25347 }, [containerWidth, isZoomedOut]); 25348 const scaleContainerWidth = Math.max( 25349 initialContainerWidthRef.current, 25350 containerWidth 25351 ); 25352 const scaleValue = isAutoScaled ? calculateScale({ 25353 frameSize, 25354 containerWidth, 25355 maxContainerWidth, 25356 scaleContainerWidth 25357 }) : scale; 25358 const transitionFromRef = (0, import_element43.useRef)({ 25359 scaleValue, 25360 frameSize, 25361 containerHeight: 0, 25362 scrollTop: 0, 25363 scrollHeight: 0 25364 }); 25365 const transitionToRef = (0, import_element43.useRef)({ 25366 scaleValue, 25367 frameSize, 25368 containerHeight: 0, 25369 scrollTop: 0, 25370 scrollHeight: 0 25371 }); 25372 const startZoomOutAnimation = (0, import_element43.useCallback)(() => { 25373 const { scrollTop } = transitionFromRef.current; 25374 const { scrollTop: scrollTopNext } = transitionToRef.current; 25375 iframeDocument.documentElement.style.setProperty( 25376 "--wp-block-editor-iframe-zoom-out-scroll-top", 25377 `$scrollTop}px` 25378 ); 25379 iframeDocument.documentElement.style.setProperty( 25380 "--wp-block-editor-iframe-zoom-out-scroll-top-next", 25381 `$scrollTopNext}px` 25382 ); 25383 iframeDocument.documentElement.style.setProperty( 25384 "--wp-block-editor-iframe-zoom-out-overflow-behavior", 25385 transitionFromRef.current.scrollHeight === transitionFromRef.current.containerHeight ? "auto" : "scroll" 25386 ); 25387 iframeDocument.documentElement.classList.add("zoom-out-animation"); 25388 return iframeDocument.documentElement.animate( 25389 getAnimationKeyframes( 25390 transitionFromRef.current, 25391 transitionToRef.current 25392 ), 25393 { 25394 easing: "cubic-bezier(0.46, 0.03, 0.52, 0.96)", 25395 duration: 400 25396 } 25397 ); 25398 }, [iframeDocument]); 25399 const finishZoomOutAnimation = (0, import_element43.useCallback)(() => { 25400 startAnimationRef.current = false; 25401 animationRef.current = null; 25402 iframeDocument.documentElement.style.setProperty( 25403 "--wp-block-editor-iframe-zoom-out-scale", 25404 transitionToRef.current.scaleValue 25405 ); 25406 iframeDocument.documentElement.style.setProperty( 25407 "--wp-block-editor-iframe-zoom-out-frame-size", 25408 `$transitionToRef.current.frameSize}px` 25409 ); 25410 iframeDocument.documentElement.classList.remove("zoom-out-animation"); 25411 iframeDocument.documentElement.scrollTop = transitionToRef.current.scrollTop; 25412 iframeDocument.documentElement.style.removeProperty( 25413 "--wp-block-editor-iframe-zoom-out-scroll-top" 25414 ); 25415 iframeDocument.documentElement.style.removeProperty( 25416 "--wp-block-editor-iframe-zoom-out-scroll-top-next" 25417 ); 25418 iframeDocument.documentElement.style.removeProperty( 25419 "--wp-block-editor-iframe-zoom-out-overflow-behavior" 25420 ); 25421 transitionFromRef.current = transitionToRef.current; 25422 }, [iframeDocument]); 25423 const previousIsZoomedOut = (0, import_element43.useRef)(false); 25424 (0, import_element43.useEffect)(() => { 25425 const trigger = iframeDocument && previousIsZoomedOut.current !== isZoomedOut; 25426 previousIsZoomedOut.current = isZoomedOut; 25427 if (!trigger) { 25428 return; 25429 } 25430 startAnimationRef.current = true; 25431 if (!isZoomedOut) { 25432 return; 25433 } 25434 iframeDocument.documentElement.classList.add("is-zoomed-out"); 25435 return () => { 25436 iframeDocument.documentElement.classList.remove("is-zoomed-out"); 25437 }; 25438 }, [iframeDocument, isZoomedOut]); 25439 (0, import_element43.useEffect)(() => { 25440 if (!iframeDocument) { 25441 return; 25442 } 25443 if (isAutoScaled && transitionFromRef.current.scaleValue !== 1) { 25444 transitionFromRef.current.scaleValue = calculateScale({ 25445 frameSize: transitionFromRef.current.frameSize, 25446 containerWidth, 25447 maxContainerWidth, 25448 scaleContainerWidth: containerWidth 25449 }); 25450 } 25451 if (scaleValue < 1) { 25452 if (!startAnimationRef.current) { 25453 iframeDocument.documentElement.style.setProperty( 25454 "--wp-block-editor-iframe-zoom-out-scale", 25455 scaleValue 25456 ); 25457 iframeDocument.documentElement.style.setProperty( 25458 "--wp-block-editor-iframe-zoom-out-frame-size", 25459 `$frameSize}px` 25460 ); 25461 } 25462 iframeDocument.documentElement.style.setProperty( 25463 "--wp-block-editor-iframe-zoom-out-content-height", 25464 `$contentHeight}px` 25465 ); 25466 iframeDocument.documentElement.style.setProperty( 25467 "--wp-block-editor-iframe-zoom-out-inner-height", 25468 `$containerHeight}px` 25469 ); 25470 iframeDocument.documentElement.style.setProperty( 25471 "--wp-block-editor-iframe-zoom-out-container-width", 25472 `$containerWidth}px` 25473 ); 25474 iframeDocument.documentElement.style.setProperty( 25475 "--wp-block-editor-iframe-zoom-out-scale-container-width", 25476 `$scaleContainerWidth}px` 25477 ); 25478 } 25479 if (startAnimationRef.current) { 25480 startAnimationRef.current = false; 25481 if (animationRef.current) { 25482 animationRef.current.reverse(); 25483 const tempTransitionFrom = transitionFromRef.current; 25484 const tempTransitionTo = transitionToRef.current; 25485 transitionFromRef.current = tempTransitionTo; 25486 transitionToRef.current = tempTransitionFrom; 25487 } else { 25488 transitionFromRef.current.scrollTop = iframeDocument.documentElement.scrollTop; 25489 transitionFromRef.current.scrollHeight = iframeDocument.documentElement.scrollHeight; 25490 transitionFromRef.current.containerHeight = containerHeight; 25491 transitionToRef.current = { 25492 scaleValue, 25493 frameSize, 25494 containerHeight: iframeDocument.documentElement.clientHeight 25495 // use clientHeight to get the actual height of the new container after zoom state changes have rendered, as it will be the most up-to-date. 25496 }; 25497 transitionToRef.current.scrollHeight = computeScrollHeightNext( 25498 transitionFromRef.current, 25499 transitionToRef.current 25500 ); 25501 transitionToRef.current.scrollTop = computeScrollTopNext( 25502 transitionFromRef.current, 25503 transitionToRef.current 25504 ); 25505 animationRef.current = startZoomOutAnimation(); 25506 if (prefersReducedMotion) { 25507 finishZoomOutAnimation(); 25508 } else { 25509 animationRef.current.onfinish = finishZoomOutAnimation; 25510 } 25511 } 25512 } 25513 }, [ 25514 startZoomOutAnimation, 25515 finishZoomOutAnimation, 25516 prefersReducedMotion, 25517 isAutoScaled, 25518 scaleValue, 25519 frameSize, 25520 iframeDocument, 25521 contentHeight, 25522 containerWidth, 25523 containerHeight, 25524 maxContainerWidth, 25525 scaleContainerWidth 25526 ]); 25527 return { 25528 isZoomedOut, 25529 scaleContainerWidth, 25530 contentResizeListener, 25531 containerResizeListener 25532 }; 25533 } 25534 25535 // packages/block-editor/build-module/components/iframe/index.js 25536 var import_jsx_runtime154 = __toESM(require_jsx_runtime()); 25537 function bubbleEvent(event, Constructor, frame) { 25538 const init = {}; 25539 for (const key in event) { 25540 init[key] = event[key]; 25541 } 25542 if (event instanceof frame.contentDocument.defaultView.MouseEvent) { 25543 const rect = frame.getBoundingClientRect(); 25544 init.clientX += rect.left; 25545 init.clientY += rect.top; 25546 } 25547 const newEvent = new Constructor(event.type, init); 25548 if (init.defaultPrevented) { 25549 newEvent.preventDefault(); 25550 } 25551 const cancelled = !frame.dispatchEvent(newEvent); 25552 if (cancelled) { 25553 event.preventDefault(); 25554 } 25555 } 25556 function useBubbleEvents(iframeDocument) { 25557 return (0, import_compose30.useRefEffect)(() => { 25558 const { defaultView } = iframeDocument; 25559 if (!defaultView) { 25560 return; 25561 } 25562 const { frameElement } = defaultView; 25563 const html = iframeDocument.documentElement; 25564 const eventTypes = ["dragover", "mousemove"]; 25565 const handlers = {}; 25566 for (const name of eventTypes) { 25567 handlers[name] = (event) => { 25568 const prototype = Object.getPrototypeOf(event); 25569 const constructorName = prototype.constructor.name; 25570 const Constructor = window[constructorName]; 25571 bubbleEvent(event, Constructor, frameElement); 25572 }; 25573 html.addEventListener(name, handlers[name]); 25574 } 25575 return () => { 25576 for (const name of eventTypes) { 25577 html.removeEventListener(name, handlers[name]); 25578 } 25579 }; 25580 }); 25581 } 25582 function Iframe({ 25583 contentRef, 25584 children, 25585 tabIndex = 0, 25586 scale = 1, 25587 frameSize = 0, 25588 readonly, 25589 forwardedRef: ref, 25590 title = (0, import_i18n34.__)("Editor canvas"), 25591 ...props 25592 }) { 25593 const { resolvedAssets, isPreviewMode } = (0, import_data45.useSelect)((select3) => { 25594 const { getSettings: getSettings8 } = select3(store); 25595 const settings2 = getSettings8(); 25596 return { 25597 resolvedAssets: settings2.__unstableResolvedAssets, 25598 isPreviewMode: settings2.isPreviewMode 25599 }; 25600 }, []); 25601 const { styles = "", scripts = "" } = resolvedAssets; 25602 const [iframeDocument, setIframeDocument] = (0, import_element44.useState)(); 25603 const [bodyClasses, setBodyClasses] = (0, import_element44.useState)([]); 25604 const [before, writingFlowRef, after] = useWritingFlow(); 25605 const setRef = (0, import_compose30.useRefEffect)((node) => { 25606 node._load = () => { 25607 setIframeDocument(node.contentDocument); 25608 }; 25609 let iFrameDocument; 25610 function preventFileDropDefault(event) { 25611 event.preventDefault(); 25612 } 25613 function interceptLinkClicks(event) { 25614 if (event.target.tagName === "A" && event.target.getAttribute("href")?.startsWith("#")) { 25615 event.preventDefault(); 25616 iFrameDocument.defaultView.location.hash = event.target.getAttribute("href").slice(1); 25617 } 25618 } 25619 const { ownerDocument } = node; 25620 setBodyClasses( 25621 Array.from(ownerDocument.body.classList).filter( 25622 (name) => name.startsWith("admin-color-") || name.startsWith("post-type-") || name === "wp-embed-responsive" 25623 ) 25624 ); 25625 function onLoad() { 25626 const { contentDocument } = node; 25627 const { documentElement } = contentDocument; 25628 iFrameDocument = contentDocument; 25629 documentElement.classList.add("block-editor-iframe__html"); 25630 contentDocument.dir = ownerDocument.dir; 25631 for (const compatStyle of getCompatibilityStyles()) { 25632 if (contentDocument.getElementById(compatStyle.id)) { 25633 continue; 25634 } 25635 contentDocument.head.appendChild( 25636 compatStyle.cloneNode(true) 25637 ); 25638 if (!isPreviewMode) { 25639 console.warn( 25640 `$compatStyle.id} was added to the iframe incorrectly. Please use block.json or enqueue_block_assets to add styles to the iframe.`, 25641 compatStyle 25642 ); 25643 } 25644 } 25645 iFrameDocument.addEventListener( 25646 "dragover", 25647 preventFileDropDefault, 25648 false 25649 ); 25650 iFrameDocument.addEventListener( 25651 "drop", 25652 preventFileDropDefault, 25653 false 25654 ); 25655 iFrameDocument.addEventListener("click", interceptLinkClicks); 25656 } 25657 node.addEventListener("load", onLoad); 25658 return () => { 25659 delete node._load; 25660 node.removeEventListener("load", onLoad); 25661 iFrameDocument?.removeEventListener( 25662 "dragover", 25663 preventFileDropDefault 25664 ); 25665 iFrameDocument?.removeEventListener( 25666 "drop", 25667 preventFileDropDefault 25668 ); 25669 iFrameDocument?.removeEventListener("click", interceptLinkClicks); 25670 }; 25671 }, []); 25672 const { 25673 contentResizeListener, 25674 containerResizeListener, 25675 isZoomedOut, 25676 scaleContainerWidth 25677 } = useScaleCanvas({ 25678 scale, 25679 frameSize: parseInt(frameSize), 25680 iframeDocument 25681 }); 25682 const disabledRef = (0, import_compose30.useDisabled)({ isDisabled: !readonly }); 25683 const bodyRef = (0, import_compose30.useMergeRefs)([ 25684 useBubbleEvents(iframeDocument), 25685 contentRef, 25686 writingFlowRef, 25687 disabledRef 25688 ]); 25689 const html = `<!doctype html> 25690 <html> 25691 <head> 25692 <meta charset="utf-8"> 25693 <base href="$window.location.origin}"> 25694 <script>window.frameElement._load()<\/script> 25695 <style> 25696 html{ 25697 height: auto !important; 25698 min-height: 100%; 25699 } 25700 /* Lowest specificity to not override global styles */ 25701 :where(body) { 25702 margin: 0; 25703 /* Default background color in case zoom out mode background 25704 colors the html element */ 25705 background-color: white; 25706 } 25707 </style> 25708 $styles} 25709 $scripts} 25710 </head> 25711 <body> 25712 <script>document.currentScript.parentElement.remove()<\/script> 25713 </body> 25714 </html>`; 25715 const [src, cleanup] = (0, import_element44.useMemo)(() => { 25716 const _src = URL.createObjectURL( 25717 new window.Blob([html], { type: "text/html" }) 25718 ); 25719 return [_src, () => URL.revokeObjectURL(_src)]; 25720 }, [html]); 25721 (0, import_element44.useEffect)(() => cleanup, [cleanup]); 25722 const shouldRenderFocusCaptureElements = tabIndex >= 0 && !isPreviewMode; 25723 const iframe = /* @__PURE__ */ (0, import_jsx_runtime154.jsxs)(import_jsx_runtime154.Fragment, { children: [ 25724 shouldRenderFocusCaptureElements && before, 25725 /* @__PURE__ */ (0, import_jsx_runtime154.jsx)( 25726 "iframe", 25727 { 25728 ...props, 25729 style: { 25730 ...props.style, 25731 height: props.style?.height, 25732 border: 0 25733 }, 25734 ref: (0, import_compose30.useMergeRefs)([ref, setRef]), 25735 tabIndex, 25736 src, 25737 title, 25738 onKeyDown: (event) => { 25739 if (props.onKeyDown) { 25740 props.onKeyDown(event); 25741 } 25742 if (event.currentTarget.ownerDocument !== event.target.ownerDocument) { 25743 const { stopPropagation } = event.nativeEvent; 25744 event.nativeEvent.stopPropagation = () => { 25745 }; 25746 event.stopPropagation(); 25747 event.nativeEvent.stopPropagation = stopPropagation; 25748 bubbleEvent( 25749 event, 25750 window.KeyboardEvent, 25751 event.currentTarget 25752 ); 25753 } 25754 }, 25755 children: iframeDocument && (0, import_element44.createPortal)( 25756 /* @__PURE__ */ (0, import_jsx_runtime154.jsxs)( 25757 "body", 25758 { 25759 ref: bodyRef, 25760 className: clsx_default( 25761 "block-editor-iframe__body", 25762 "editor-styles-wrapper", 25763 ...bodyClasses 25764 ), 25765 children: [ 25766 contentResizeListener, 25767 /* @__PURE__ */ (0, import_jsx_runtime154.jsx)(import_components28.__experimentalStyleProvider, { document: iframeDocument, children }) 25768 ] 25769 } 25770 ), 25771 iframeDocument.documentElement 25772 ) 25773 } 25774 ), 25775 shouldRenderFocusCaptureElements && after 25776 ] }); 25777 return /* @__PURE__ */ (0, import_jsx_runtime154.jsxs)("div", { className: "block-editor-iframe__container", children: [ 25778 containerResizeListener, 25779 /* @__PURE__ */ (0, import_jsx_runtime154.jsx)( 25780 "div", 25781 { 25782 className: clsx_default( 25783 "block-editor-iframe__scale-container", 25784 isZoomedOut && "is-zoomed-out" 25785 ), 25786 style: { 25787 "--wp-block-editor-iframe-zoom-out-scale-container-width": isZoomedOut && `$scaleContainerWidth}px` 25788 }, 25789 children: iframe 25790 } 25791 ) 25792 ] }); 25793 } 25794 function IframeIfReady(props, ref) { 25795 const isInitialised = (0, import_data45.useSelect)( 25796 (select3) => select3(store).getSettings().__internalIsInitialized, 25797 [] 25798 ); 25799 if (!isInitialised) { 25800 return null; 25801 } 25802 return /* @__PURE__ */ (0, import_jsx_runtime154.jsx)(Iframe, { ...props, forwardedRef: ref }); 25803 } 25804 var iframe_default = (0, import_element44.forwardRef)(IframeIfReady); 25805 25806 // packages/block-editor/build-module/components/editor-styles/index.js 25807 var import_components29 = __toESM(require_components()); 25808 var import_element45 = __toESM(require_element()); 25809 var import_data46 = __toESM(require_data()); 25810 25811 // node_modules/parsel-js/dist/parsel.js 25812 var TOKENS = { 25813 attribute: /\[\s*(?:(?<namespace>\*|[-\w\P{ASCII}]*)\|)?(?<name>[-\w\P{ASCII}]+)\s*(?:(?<operator>\W?=)\s*(?<value>.+?)\s*(\s(?<caseSensitive>[iIsS]))?\s*)?\]/gu, 25814 id: /#(?<name>[-\w\P{ASCII}]+)/gu, 25815 class: /\.(?<name>[-\w\P{ASCII}]+)/gu, 25816 comma: /\s*,\s*/g, 25817 combinator: /\s*[\s>+~]\s*/g, 25818 "pseudo-element": /::(?<name>[-\w\P{ASCII}]+)(?:\((?<argument>¶*)\))?/gu, 25819 "pseudo-class": /:(?<name>[-\w\P{ASCII}]+)(?:\((?<argument>¶*)\))?/gu, 25820 universal: /(?:(?<namespace>\*|[-\w\P{ASCII}]*)\|)?\*/gu, 25821 type: /(?:(?<namespace>\*|[-\w\P{ASCII}]*)\|)?(?<name>[-\w\P{ASCII}]+)/gu 25822 // this must be last 25823 }; 25824 var TRIM_TOKENS = /* @__PURE__ */ new Set(["combinator", "comma"]); 25825 var getArgumentPatternByType = (type) => { 25826 switch (type) { 25827 case "pseudo-element": 25828 case "pseudo-class": 25829 return new RegExp(TOKENS[type].source.replace("(?<argument>\xB6*)", "(?<argument>.*)"), "gu"); 25830 default: 25831 return TOKENS[type]; 25832 } 25833 }; 25834 function gobbleParens(text, offset) { 25835 let nesting = 0; 25836 let result = ""; 25837 for (; offset < text.length; offset++) { 25838 const char = text[offset]; 25839 switch (char) { 25840 case "(": 25841 ++nesting; 25842 break; 25843 case ")": 25844 --nesting; 25845 break; 25846 } 25847 result += char; 25848 if (nesting === 0) { 25849 return result; 25850 } 25851 } 25852 return result; 25853 } 25854 function tokenizeBy(text, grammar = TOKENS) { 25855 if (!text) { 25856 return []; 25857 } 25858 const tokens = [text]; 25859 for (const [type, pattern] of Object.entries(grammar)) { 25860 for (let i2 = 0; i2 < tokens.length; i2++) { 25861 const token = tokens[i2]; 25862 if (typeof token !== "string") { 25863 continue; 25864 } 25865 pattern.lastIndex = 0; 25866 const match2 = pattern.exec(token); 25867 if (!match2) { 25868 continue; 25869 } 25870 const from = match2.index - 1; 25871 const args = []; 25872 const content = match2[0]; 25873 const before = token.slice(0, from + 1); 25874 if (before) { 25875 args.push(before); 25876 } 25877 args.push({ 25878 ...match2.groups, 25879 type, 25880 content 25881 }); 25882 const after = token.slice(from + content.length + 1); 25883 if (after) { 25884 args.push(after); 25885 } 25886 tokens.splice(i2, 1, ...args); 25887 } 25888 } 25889 let offset = 0; 25890 for (const token of tokens) { 25891 switch (typeof token) { 25892 case "string": 25893 throw new Error(`Unexpected sequence $token} found at index $offset}`); 25894 case "object": 25895 offset += token.content.length; 25896 token.pos = [offset - token.content.length, offset]; 25897 if (TRIM_TOKENS.has(token.type)) { 25898 token.content = token.content.trim() || " "; 25899 } 25900 break; 25901 } 25902 } 25903 return tokens; 25904 } 25905 var STRING_PATTERN = /(['"])([^\\\n]+?)\1/g; 25906 var ESCAPE_PATTERN = /\\./g; 25907 function tokenize(selector3, grammar = TOKENS) { 25908 selector3 = selector3.trim(); 25909 if (selector3 === "") { 25910 return []; 25911 } 25912 const replacements = []; 25913 selector3 = selector3.replace(ESCAPE_PATTERN, (value, offset) => { 25914 replacements.push({ value, offset }); 25915 return "\uE000".repeat(value.length); 25916 }); 25917 selector3 = selector3.replace(STRING_PATTERN, (value, quote, content, offset) => { 25918 replacements.push({ value, offset }); 25919 return `$quote}${"\uE001".repeat(content.length)}$quote}`; 25920 }); 25921 { 25922 let pos = 0; 25923 let offset; 25924 while ((offset = selector3.indexOf("(", pos)) > -1) { 25925 const value = gobbleParens(selector3, offset); 25926 replacements.push({ value, offset }); 25927 selector3 = `$selector3.substring(0, offset)}(${"\xB6".repeat(value.length - 2)})$selector3.substring(offset + value.length)}`; 25928 pos = offset + value.length; 25929 } 25930 } 25931 const tokens = tokenizeBy(selector3, grammar); 25932 const changedTokens = /* @__PURE__ */ new Set(); 25933 for (const replacement of replacements.reverse()) { 25934 for (const token of tokens) { 25935 const { offset, value } = replacement; 25936 if (!(token.pos[0] <= offset && offset + value.length <= token.pos[1])) { 25937 continue; 25938 } 25939 const { content } = token; 25940 const tokenOffset = offset - token.pos[0]; 25941 token.content = content.slice(0, tokenOffset) + value + content.slice(tokenOffset + value.length); 25942 if (token.content !== content) { 25943 changedTokens.add(token); 25944 } 25945 } 25946 } 25947 for (const token of changedTokens) { 25948 const pattern = getArgumentPatternByType(token.type); 25949 if (!pattern) { 25950 throw new Error(`Unknown token type: $token.type}`); 25951 } 25952 pattern.lastIndex = 0; 25953 const match2 = pattern.exec(token.content); 25954 if (!match2) { 25955 throw new Error(`Unable to parse content for $token.type}: $token.content}`); 25956 } 25957 Object.assign(token, match2.groups); 25958 } 25959 return tokens; 25960 } 25961 function* flatten(node, parent) { 25962 switch (node.type) { 25963 case "list": 25964 for (let child of node.list) { 25965 yield* flatten(child, node); 25966 } 25967 break; 25968 case "complex": 25969 yield* flatten(node.left, node); 25970 yield* flatten(node.right, node); 25971 break; 25972 case "compound": 25973 yield* node.list.map((token) => [token, node]); 25974 break; 25975 default: 25976 yield [node, parent]; 25977 } 25978 } 25979 function stringify(listOrNode) { 25980 let tokens; 25981 if (Array.isArray(listOrNode)) { 25982 tokens = listOrNode; 25983 } else { 25984 tokens = [...flatten(listOrNode)].map(([token]) => token); 25985 } 25986 return tokens.map((token) => token.content).join(""); 25987 } 25988 25989 // packages/block-editor/build-module/utils/transform-styles/index.js 25990 var import_processor = __toESM(require_processor()); 25991 var import_css_syntax_error = __toESM(require_css_syntax_error()); 25992 var import_postcss_prefix_selector = __toESM(require_postcss_prefix_selector()); 25993 var import_postcss_urlrebase = __toESM(require_postcss_urlrebase()); 25994 var cacheByWrapperSelector = /* @__PURE__ */ new Map(); 25995 var ROOT_SELECTOR_TOKENS = [ 25996 { type: "type", content: "body" }, 25997 { type: "type", content: "html" }, 25998 { type: "pseudo-class", content: ":root" }, 25999 { type: "pseudo-class", content: ":where(body)" }, 26000 { type: "pseudo-class", content: ":where(:root)" }, 26001 { type: "pseudo-class", content: ":where(html)" } 26002 ]; 26003 function prefixRootSelector(prefix2, selector3) { 26004 const tokenized = tokenize(selector3); 26005 const lastRootIndex = tokenized.findLastIndex(({ content, type }) => { 26006 return ROOT_SELECTOR_TOKENS.some( 26007 (rootSelector) => content === rootSelector.content && type === rootSelector.type 26008 ); 26009 }); 26010 let insertionPoint2 = -1; 26011 for (let i2 = lastRootIndex + 1; i2 < tokenized.length; i2++) { 26012 if (tokenized[i2].type === "combinator") { 26013 insertionPoint2 = i2; 26014 break; 26015 } 26016 } 26017 const tokenizedPrefix = tokenize(prefix2); 26018 tokenized.splice( 26019 // Insert at the insertion point, or the end. 26020 insertionPoint2 === -1 ? tokenized.length : insertionPoint2, 26021 0, 26022 { 26023 type: "combinator", 26024 content: " " 26025 }, 26026 ...tokenizedPrefix 26027 ); 26028 return stringify(tokenized); 26029 } 26030 function transformStyle({ css, ignoredSelectors = [], baseURL }, wrapperSelector = "", transformOptions) { 26031 if (!wrapperSelector && !baseURL) { 26032 return css; 26033 } 26034 try { 26035 const excludedSelectors = [ 26036 ...ignoredSelectors, 26037 ...transformOptions?.ignoredSelectors ?? [], 26038 wrapperSelector 26039 ]; 26040 return new import_processor.default( 26041 [ 26042 wrapperSelector && (0, import_postcss_prefix_selector.default)({ 26043 prefix: wrapperSelector, 26044 transform(prefix2, selector3, prefixedSelector) { 26045 if (excludedSelectors.some( 26046 (excludedSelector) => excludedSelector instanceof RegExp ? selector3.match(excludedSelector) : selector3.includes(excludedSelector) 26047 )) { 26048 return selector3; 26049 } 26050 const hasRootSelector = ROOT_SELECTOR_TOKENS.some( 26051 (rootSelector) => selector3.startsWith(rootSelector.content) 26052 ); 26053 if (hasRootSelector) { 26054 return prefixRootSelector(prefix2, selector3); 26055 } 26056 return prefixedSelector; 26057 } 26058 }), 26059 baseURL && (0, import_postcss_urlrebase.default)({ rootUrl: baseURL }) 26060 ].filter(Boolean) 26061 ).process(css, {}).css; 26062 } catch (error) { 26063 if (error instanceof import_css_syntax_error.default) { 26064 console.warn( 26065 "wp.blockEditor.transformStyles Failed to transform CSS.", 26066 error.message + "\n" + error.showSourceCode(false) 26067 ); 26068 } else { 26069 console.warn( 26070 "wp.blockEditor.transformStyles Failed to transform CSS.", 26071 error 26072 ); 26073 } 26074 return null; 26075 } 26076 } 26077 var transformStyles = (styles, wrapperSelector = "", transformOptions) => { 26078 let cache = cacheByWrapperSelector.get(wrapperSelector); 26079 if (!cache) { 26080 cache = /* @__PURE__ */ new WeakMap(); 26081 cacheByWrapperSelector.set(wrapperSelector, cache); 26082 } 26083 return styles.map((style) => { 26084 let css = cache.get(style); 26085 if (!css) { 26086 css = transformStyle(style, wrapperSelector, transformOptions); 26087 cache.set(style, css); 26088 } 26089 return css; 26090 }); 26091 }; 26092 var transform_styles_default = transformStyles; 26093 26094 // packages/block-editor/build-module/components/editor-styles/index.js 26095 var import_jsx_runtime155 = __toESM(require_jsx_runtime()); 26096 k([names_default, a11y_default]); 26097 function useDarkThemeBodyClassName(styles, scope) { 26098 return (0, import_element45.useCallback)( 26099 (node) => { 26100 if (!node) { 26101 return; 26102 } 26103 const { ownerDocument } = node; 26104 const { defaultView, body } = ownerDocument; 26105 const canvas = scope ? ownerDocument.querySelector(scope) : body; 26106 let backgroundColor; 26107 if (!canvas) { 26108 const tempCanvas = ownerDocument.createElement("div"); 26109 tempCanvas.classList.add("editor-styles-wrapper"); 26110 body.appendChild(tempCanvas); 26111 backgroundColor = defaultView?.getComputedStyle(tempCanvas, null).getPropertyValue("background-color"); 26112 body.removeChild(tempCanvas); 26113 } else { 26114 backgroundColor = defaultView?.getComputedStyle(canvas, null).getPropertyValue("background-color"); 26115 } 26116 const colordBackgroundColor = w(backgroundColor); 26117 if (colordBackgroundColor.luminance() > 0.5 || colordBackgroundColor.alpha() === 0) { 26118 body.classList.remove("is-dark-theme"); 26119 } else { 26120 body.classList.add("is-dark-theme"); 26121 } 26122 }, 26123 [styles, scope] 26124 ); 26125 } 26126 function EditorStyles({ styles, scope, transformOptions }) { 26127 const overrides = (0, import_data46.useSelect)( 26128 (select3) => unlock(select3(store)).getStyleOverrides(), 26129 [] 26130 ); 26131 const [transformedStyles, transformedSvgs] = (0, import_element45.useMemo)(() => { 26132 const _styles = Object.values(styles ?? []); 26133 for (const [id, override] of overrides) { 26134 const index = _styles.findIndex(({ id: _id }) => id === _id); 26135 const overrideWithId = { ...override, id }; 26136 if (index === -1) { 26137 _styles.push(overrideWithId); 26138 } else { 26139 _styles[index] = overrideWithId; 26140 } 26141 } 26142 return [ 26143 transform_styles_default( 26144 _styles.filter((style) => style?.css), 26145 scope, 26146 transformOptions 26147 ), 26148 _styles.filter((style) => style.__unstableType === "svgs").map((style) => style.assets).join("") 26149 ]; 26150 }, [styles, overrides, scope, transformOptions]); 26151 return /* @__PURE__ */ (0, import_jsx_runtime155.jsxs)(import_jsx_runtime155.Fragment, { children: [ 26152 /* @__PURE__ */ (0, import_jsx_runtime155.jsx)( 26153 "style", 26154 { 26155 ref: useDarkThemeBodyClassName(transformedStyles, scope) 26156 } 26157 ), 26158 transformedStyles.map((css, index) => /* @__PURE__ */ (0, import_jsx_runtime155.jsx)("style", { children: css }, index)), 26159 /* @__PURE__ */ (0, import_jsx_runtime155.jsx)( 26160 import_components29.SVG, 26161 { 26162 xmlns: "http://www.w3.org/2000/svg", 26163 viewBox: "0 0 0 0", 26164 width: "0", 26165 height: "0", 26166 role: "none", 26167 style: { 26168 visibility: "hidden", 26169 position: "absolute", 26170 left: "-9999px", 26171 overflow: "hidden" 26172 }, 26173 dangerouslySetInnerHTML: { __html: transformedSvgs } 26174 } 26175 ) 26176 ] }); 26177 } 26178 var editor_styles_default = (0, import_element45.memo)(EditorStyles); 26179 26180 // packages/block-editor/build-module/components/block-preview/auto.js 26181 var import_jsx_runtime156 = __toESM(require_jsx_runtime()); 26182 var MemoizedBlockList = (0, import_element46.memo)(BlockList); 26183 var MAX_HEIGHT = 2e3; 26184 var EMPTY_ADDITIONAL_STYLES = []; 26185 function ScaledBlockPreview({ 26186 viewportWidth, 26187 containerWidth, 26188 minHeight, 26189 additionalStyles = EMPTY_ADDITIONAL_STYLES 26190 }) { 26191 if (!viewportWidth) { 26192 viewportWidth = containerWidth; 26193 } 26194 const [contentResizeListener, { height: contentHeight }] = (0, import_compose31.useResizeObserver)(); 26195 const { styles } = (0, import_data47.useSelect)((select3) => { 26196 const settings2 = select3(store).getSettings(); 26197 return { 26198 styles: settings2.styles 26199 }; 26200 }, []); 26201 const editorStyles = (0, import_element46.useMemo)(() => { 26202 if (styles) { 26203 return [ 26204 ...styles, 26205 { 26206 css: "body{height:auto;overflow:hidden;border:none;padding:0;}", 26207 __unstableType: "presets" 26208 }, 26209 ...additionalStyles 26210 ]; 26211 } 26212 return styles; 26213 }, [styles, additionalStyles]); 26214 const scale = containerWidth / viewportWidth; 26215 const aspectRatio = contentHeight ? containerWidth / (contentHeight * scale) : 0; 26216 return /* @__PURE__ */ (0, import_jsx_runtime156.jsx)( 26217 import_components30.Disabled, 26218 { 26219 className: "block-editor-block-preview__content", 26220 style: { 26221 transform: `scale($scale})`, 26222 // Using width + aspect-ratio instead of height here triggers browsers' native 26223 // handling of scrollbar's visibility. It prevents the flickering issue seen 26224 // in https://github.com/WordPress/gutenberg/issues/52027. 26225 // See https://github.com/WordPress/gutenberg/pull/52921 for more info. 26226 aspectRatio, 26227 maxHeight: contentHeight > MAX_HEIGHT ? MAX_HEIGHT * scale : void 0, 26228 minHeight 26229 }, 26230 children: /* @__PURE__ */ (0, import_jsx_runtime156.jsxs)( 26231 iframe_default, 26232 { 26233 contentRef: (0, import_compose31.useRefEffect)((bodyElement) => { 26234 const { 26235 ownerDocument: { documentElement } 26236 } = bodyElement; 26237 documentElement.classList.add( 26238 "block-editor-block-preview__content-iframe" 26239 ); 26240 documentElement.style.position = "absolute"; 26241 documentElement.style.width = "100%"; 26242 bodyElement.style.boxSizing = "border-box"; 26243 bodyElement.style.position = "absolute"; 26244 bodyElement.style.width = "100%"; 26245 }, []), 26246 "aria-hidden": true, 26247 tabIndex: -1, 26248 style: { 26249 position: "absolute", 26250 width: viewportWidth, 26251 height: contentHeight, 26252 pointerEvents: "none", 26253 // This is a catch-all max-height for patterns. 26254 // See: https://github.com/WordPress/gutenberg/pull/38175. 26255 maxHeight: MAX_HEIGHT, 26256 minHeight: scale !== 0 && scale < 1 && minHeight ? minHeight / scale : minHeight 26257 }, 26258 children: [ 26259 /* @__PURE__ */ (0, import_jsx_runtime156.jsx)(editor_styles_default, { styles: editorStyles }), 26260 contentResizeListener, 26261 /* @__PURE__ */ (0, import_jsx_runtime156.jsx)(MemoizedBlockList, { renderAppender: false }) 26262 ] 26263 } 26264 ) 26265 } 26266 ); 26267 } 26268 function AutoBlockPreview(props) { 26269 const [containerResizeListener, { width: containerWidth }] = (0, import_compose31.useResizeObserver)(); 26270 return /* @__PURE__ */ (0, import_jsx_runtime156.jsxs)(import_jsx_runtime156.Fragment, { children: [ 26271 /* @__PURE__ */ (0, import_jsx_runtime156.jsx)("div", { style: { position: "relative", width: "100%", height: 0 }, children: containerResizeListener }), 26272 /* @__PURE__ */ (0, import_jsx_runtime156.jsx)("div", { className: "block-editor-block-preview__container", children: !!containerWidth && /* @__PURE__ */ (0, import_jsx_runtime156.jsx)( 26273 ScaledBlockPreview, 26274 { 26275 ...props, 26276 containerWidth 26277 } 26278 ) }) 26279 ] }); 26280 } 26281 26282 // packages/block-editor/build-module/components/block-preview/async.js 26283 var import_element47 = __toESM(require_element()); 26284 var import_priority_queue = __toESM(require_priority_queue()); 26285 var blockPreviewQueue = (0, import_priority_queue.createQueue)(); 26286 function Async({ children, placeholder }) { 26287 const [shouldRender, setShouldRender] = (0, import_element47.useState)(false); 26288 (0, import_element47.useEffect)(() => { 26289 const context = {}; 26290 blockPreviewQueue.add(context, () => { 26291 (0, import_element47.flushSync)(() => { 26292 setShouldRender(true); 26293 }); 26294 }); 26295 return () => { 26296 blockPreviewQueue.cancel(context); 26297 }; 26298 }, []); 26299 if (!shouldRender) { 26300 return placeholder; 26301 } 26302 return children; 26303 } 26304 26305 // packages/block-editor/build-module/components/block-preview/index.js 26306 var import_jsx_runtime157 = __toESM(require_jsx_runtime()); 26307 var EMPTY_ADDITIONAL_STYLES2 = []; 26308 function BlockPreview({ 26309 blocks: blocks2, 26310 viewportWidth = 1200, 26311 minHeight, 26312 additionalStyles = EMPTY_ADDITIONAL_STYLES2, 26313 // Deprecated props: 26314 __experimentalMinHeight, 26315 __experimentalPadding 26316 }) { 26317 if (__experimentalMinHeight) { 26318 minHeight = __experimentalMinHeight; 26319 (0, import_deprecated7.default)("The __experimentalMinHeight prop", { 26320 since: "6.2", 26321 version: "6.4", 26322 alternative: "minHeight" 26323 }); 26324 } 26325 if (__experimentalPadding) { 26326 additionalStyles = [ 26327 ...additionalStyles, 26328 { css: `body { padding: $__experimentalPadding}px; }` } 26329 ]; 26330 (0, import_deprecated7.default)("The __experimentalPadding prop of BlockPreview", { 26331 since: "6.2", 26332 version: "6.4", 26333 alternative: "additionalStyles" 26334 }); 26335 } 26336 const originalSettings = (0, import_data48.useSelect)( 26337 (select3) => select3(store).getSettings(), 26338 [] 26339 ); 26340 const settings2 = (0, import_element48.useMemo)( 26341 () => ({ 26342 ...originalSettings, 26343 focusMode: false, 26344 // Disable "Spotlight mode". 26345 isPreviewMode: true 26346 }), 26347 [originalSettings] 26348 ); 26349 const renderedBlocks = (0, import_element48.useMemo)( 26350 () => Array.isArray(blocks2) ? blocks2 : [blocks2], 26351 [blocks2] 26352 ); 26353 if (!blocks2 || blocks2.length === 0) { 26354 return null; 26355 } 26356 return /* @__PURE__ */ (0, import_jsx_runtime157.jsx)( 26357 ExperimentalBlockEditorProvider, 26358 { 26359 value: renderedBlocks, 26360 settings: settings2, 26361 children: /* @__PURE__ */ (0, import_jsx_runtime157.jsx)( 26362 AutoBlockPreview, 26363 { 26364 viewportWidth, 26365 minHeight, 26366 additionalStyles 26367 } 26368 ) 26369 } 26370 ); 26371 } 26372 var MemoizedBlockPreview = (0, import_element48.memo)(BlockPreview); 26373 MemoizedBlockPreview.Async = Async; 26374 var block_preview_default = MemoizedBlockPreview; 26375 function useBlockPreview({ blocks: blocks2, props = {}, layout }) { 26376 const originalSettings = (0, import_data48.useSelect)( 26377 (select3) => select3(store).getSettings(), 26378 [] 26379 ); 26380 const settings2 = (0, import_element48.useMemo)( 26381 () => ({ 26382 ...originalSettings, 26383 styles: void 0, 26384 // Clear styles included by the parent settings, as they are already output by the parent's EditorStyles. 26385 focusMode: false, 26386 // Disable "Spotlight mode". 26387 isPreviewMode: true 26388 }), 26389 [originalSettings] 26390 ); 26391 const disabledRef = (0, import_compose32.useDisabled)(); 26392 const ref = (0, import_compose32.useMergeRefs)([props.ref, disabledRef]); 26393 const renderedBlocks = (0, import_element48.useMemo)( 26394 () => Array.isArray(blocks2) ? blocks2 : [blocks2], 26395 [blocks2] 26396 ); 26397 const children = /* @__PURE__ */ (0, import_jsx_runtime157.jsxs)( 26398 ExperimentalBlockEditorProvider, 26399 { 26400 value: renderedBlocks, 26401 settings: settings2, 26402 children: [ 26403 /* @__PURE__ */ (0, import_jsx_runtime157.jsx)(editor_styles_default, {}), 26404 /* @__PURE__ */ (0, import_jsx_runtime157.jsx)(BlockListItems, { renderAppender: false, layout }) 26405 ] 26406 } 26407 ); 26408 return { 26409 ...props, 26410 ref, 26411 className: clsx_default( 26412 props.className, 26413 "block-editor-block-preview__live-content", 26414 "components-disabled" 26415 ), 26416 children: blocks2?.length ? children : null 26417 }; 26418 } 26419 26420 // packages/block-editor/build-module/components/inserter/preview-panel.js 26421 var import_jsx_runtime158 = __toESM(require_jsx_runtime()); 26422 function InserterPreviewPanel({ item }) { 26423 const { name, title, icon, description, initialAttributes, example } = item; 26424 const isReusable = (0, import_blocks26.isReusableBlock)(item); 26425 const blocks2 = (0, import_element49.useMemo)(() => { 26426 if (!example) { 26427 return (0, import_blocks26.createBlock)(name, initialAttributes); 26428 } 26429 return (0, import_blocks26.getBlockFromExample)(name, { 26430 attributes: { 26431 ...example.attributes, 26432 ...initialAttributes 26433 }, 26434 innerBlocks: example.innerBlocks 26435 }); 26436 }, [name, example, initialAttributes]); 26437 const previewHeight = 144; 26438 const sidebarWidth = 280; 26439 const viewportWidth = example?.viewportWidth ?? 500; 26440 const scale = sidebarWidth / viewportWidth; 26441 const minHeight = scale !== 0 && scale < 1 && previewHeight ? previewHeight / scale : previewHeight; 26442 return /* @__PURE__ */ (0, import_jsx_runtime158.jsxs)("div", { className: "block-editor-inserter__preview-container", children: [ 26443 /* @__PURE__ */ (0, import_jsx_runtime158.jsx)("div", { className: "block-editor-inserter__preview", children: isReusable || example ? /* @__PURE__ */ (0, import_jsx_runtime158.jsx)("div", { className: "block-editor-inserter__preview-content", children: /* @__PURE__ */ (0, import_jsx_runtime158.jsx)( 26444 block_preview_default, 26445 { 26446 blocks: blocks2, 26447 viewportWidth, 26448 minHeight: previewHeight, 26449 additionalStyles: ( 26450 //We want this CSS to be in sync with the one in BlockPreviewPanel. 26451 [ 26452 { 26453 css: ` 26454 body { 26455 padding: 24px; 26456 min-height:$Math.round(minHeight)}px; 26457 display:flex; 26458 align-items:center; 26459 } 26460 .is-root-container { width: 100%; } 26461 ` 26462 } 26463 ] 26464 ) 26465 } 26466 ) }) : /* @__PURE__ */ (0, import_jsx_runtime158.jsx)("div", { className: "block-editor-inserter__preview-content-missing", children: (0, import_i18n35.__)("No preview available.") }) }), 26467 !isReusable && /* @__PURE__ */ (0, import_jsx_runtime158.jsx)( 26468 block_card_default, 26469 { 26470 title, 26471 icon, 26472 description 26473 } 26474 ) 26475 ] }); 26476 } 26477 var preview_panel_default = InserterPreviewPanel; 26478 26479 // packages/block-editor/build-module/components/inserter/block-types-tab.js 26480 var import_i18n39 = __toESM(require_i18n()); 26481 var import_element56 = __toESM(require_element()); 26482 var import_compose34 = __toESM(require_compose()); 26483 26484 // packages/block-editor/build-module/components/block-types-list/index.js 26485 var import_blocks29 = __toESM(require_blocks()); 26486 var import_compose33 = __toESM(require_compose()); 26487 26488 // packages/block-editor/build-module/components/inserter-list-item/index.js 26489 var import_element55 = __toESM(require_element()); 26490 var import_blocks28 = __toESM(require_blocks()); 26491 var import_components36 = __toESM(require_components()); 26492 var import_keycodes6 = __toESM(require_keycodes()); 26493 26494 // packages/block-editor/build-module/components/inserter-listbox/index.js 26495 var import_components33 = __toESM(require_components()); 26496 var import_element53 = __toESM(require_element()); 26497 26498 // packages/block-editor/build-module/components/inserter-listbox/group.js 26499 var import_element50 = __toESM(require_element()); 26500 var import_i18n36 = __toESM(require_i18n()); 26501 var import_a11y5 = __toESM(require_a11y()); 26502 var import_jsx_runtime159 = __toESM(require_jsx_runtime()); 26503 function InserterListboxGroup(props, ref) { 26504 const [shouldSpeak, setShouldSpeak] = (0, import_element50.useState)(false); 26505 (0, import_element50.useEffect)(() => { 26506 if (shouldSpeak) { 26507 (0, import_a11y5.speak)( 26508 (0, import_i18n36.__)("Use left and right arrow keys to move through blocks") 26509 ); 26510 } 26511 }, [shouldSpeak]); 26512 return /* @__PURE__ */ (0, import_jsx_runtime159.jsx)( 26513 "div", 26514 { 26515 ref, 26516 role: "listbox", 26517 "aria-orientation": "horizontal", 26518 onFocus: () => { 26519 setShouldSpeak(true); 26520 }, 26521 onBlur: (event) => { 26522 const focusingOutsideGroup = !event.currentTarget.contains( 26523 event.relatedTarget 26524 ); 26525 if (focusingOutsideGroup) { 26526 setShouldSpeak(false); 26527 } 26528 }, 26529 ...props 26530 } 26531 ); 26532 } 26533 var group_default2 = (0, import_element50.forwardRef)(InserterListboxGroup); 26534 26535 // packages/block-editor/build-module/components/inserter-listbox/row.js 26536 var import_element51 = __toESM(require_element()); 26537 var import_components31 = __toESM(require_components()); 26538 var import_jsx_runtime160 = __toESM(require_jsx_runtime()); 26539 function InserterListboxRow(props, ref) { 26540 return /* @__PURE__ */ (0, import_jsx_runtime160.jsx)(import_components31.Composite.Group, { role: "presentation", ref, ...props }); 26541 } 26542 var row_default2 = (0, import_element51.forwardRef)(InserterListboxRow); 26543 26544 // packages/block-editor/build-module/components/inserter-listbox/item.js 26545 var import_components32 = __toESM(require_components()); 26546 var import_element52 = __toESM(require_element()); 26547 var import_jsx_runtime161 = __toESM(require_jsx_runtime()); 26548 function InserterListboxItem({ isFirst, as: Component7, children, ...props }, ref) { 26549 return /* @__PURE__ */ (0, import_jsx_runtime161.jsx)( 26550 import_components32.Composite.Item, 26551 { 26552 ref, 26553 role: "option", 26554 accessibleWhenDisabled: true, 26555 ...props, 26556 render: (htmlProps) => { 26557 const propsWithTabIndex = { 26558 ...htmlProps, 26559 tabIndex: isFirst ? 0 : htmlProps.tabIndex 26560 }; 26561 if (Component7) { 26562 return /* @__PURE__ */ (0, import_jsx_runtime161.jsx)(Component7, { ...propsWithTabIndex, children }); 26563 } 26564 if (typeof children === "function") { 26565 return children(propsWithTabIndex); 26566 } 26567 return /* @__PURE__ */ (0, import_jsx_runtime161.jsx)(import_components32.Button, { __next40pxDefaultSize: true, ...propsWithTabIndex, children }); 26568 } 26569 } 26570 ); 26571 } 26572 var item_default = (0, import_element52.forwardRef)(InserterListboxItem); 26573 26574 // packages/block-editor/build-module/components/inserter-listbox/index.js 26575 var import_jsx_runtime162 = __toESM(require_jsx_runtime()); 26576 function InserterListBoxWrapper({ key, children }) { 26577 return /* @__PURE__ */ (0, import_jsx_runtime162.jsx)(import_element53.Fragment, { children }, key); 26578 } 26579 function InserterListbox({ children }) { 26580 return /* @__PURE__ */ (0, import_jsx_runtime162.jsx)( 26581 import_components33.Composite, 26582 { 26583 focusShift: true, 26584 focusWrap: "horizontal", 26585 render: InserterListBoxWrapper, 26586 children 26587 } 26588 ); 26589 } 26590 var inserter_listbox_default = InserterListbox; 26591 26592 // packages/block-editor/build-module/components/inserter-draggable-blocks/index.js 26593 var import_components35 = __toESM(require_components()); 26594 var import_blocks27 = __toESM(require_blocks()); 26595 var import_data49 = __toESM(require_data()); 26596 var import_element54 = __toESM(require_element()); 26597 26598 // packages/block-editor/build-module/components/block-draggable/draggable-chip.js 26599 var import_i18n37 = __toESM(require_i18n()); 26600 var import_components34 = __toESM(require_components()); 26601 var import_jsx_runtime163 = __toESM(require_jsx_runtime()); 26602 function BlockDraggableChip({ 26603 count, 26604 icon, 26605 isPattern, 26606 fadeWhenDisabled 26607 }) { 26608 const patternLabel = isPattern && (0, import_i18n37.__)("Pattern"); 26609 return /* @__PURE__ */ (0, import_jsx_runtime163.jsx)("div", { className: "block-editor-block-draggable-chip-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime163.jsx)( 26610 "div", 26611 { 26612 className: "block-editor-block-draggable-chip", 26613 "data-testid": "block-draggable-chip", 26614 children: /* @__PURE__ */ (0, import_jsx_runtime163.jsxs)( 26615 import_components34.Flex, 26616 { 26617 justify: "center", 26618 className: "block-editor-block-draggable-chip__content", 26619 children: [ 26620 /* @__PURE__ */ (0, import_jsx_runtime163.jsx)(import_components34.FlexItem, { children: icon ? /* @__PURE__ */ (0, import_jsx_runtime163.jsx)(block_icon_default, { icon }) : patternLabel || (0, import_i18n37.sprintf)( 26621 /* translators: %d: Number of blocks. */ 26622 (0, import_i18n37._n)("%d block", "%d blocks", count), 26623 count 26624 ) }), 26625 /* @__PURE__ */ (0, import_jsx_runtime163.jsx)(import_components34.FlexItem, { children: /* @__PURE__ */ (0, import_jsx_runtime163.jsx)(block_icon_default, { icon: drag_handle_default }) }), 26626 fadeWhenDisabled && /* @__PURE__ */ (0, import_jsx_runtime163.jsx)(import_components34.FlexItem, { className: "block-editor-block-draggable-chip__disabled", children: /* @__PURE__ */ (0, import_jsx_runtime163.jsx)("span", { className: "block-editor-block-draggable-chip__disabled-icon" }) }) 26627 ] 26628 } 26629 ) 26630 } 26631 ) }); 26632 } 26633 26634 // packages/block-editor/build-module/components/inserter-draggable-blocks/index.js 26635 var import_jsx_runtime164 = __toESM(require_jsx_runtime()); 26636 var InserterDraggableBlocks = ({ 26637 isEnabled, 26638 blocks: blocks2, 26639 icon, 26640 children, 26641 pattern 26642 }) => { 26643 const blockName = blocks2.length === 1 ? blocks2[0].name : void 0; 26644 const blockTypeIcon = (0, import_data49.useSelect)( 26645 (select3) => { 26646 return blockName && select3(import_blocks27.store).getBlockType(blockName)?.icon; 26647 }, 26648 [blockName] 26649 ); 26650 const { startDragging: startDragging2, stopDragging: stopDragging2 } = unlock( 26651 (0, import_data49.useDispatch)(store) 26652 ); 26653 const patternBlock = (0, import_element54.useMemo)(() => { 26654 return pattern?.type === INSERTER_PATTERN_TYPES.user && pattern?.syncStatus !== "unsynced" ? [(0, import_blocks27.createBlock)("core/block", { ref: pattern.id })] : void 0; 26655 }, [pattern?.type, pattern?.syncStatus, pattern?.id]); 26656 if (!isEnabled) { 26657 return children({ 26658 draggable: false, 26659 onDragStart: void 0, 26660 onDragEnd: void 0 26661 }); 26662 } 26663 const draggableBlocks = patternBlock ?? blocks2; 26664 return /* @__PURE__ */ (0, import_jsx_runtime164.jsx)( 26665 import_components35.Draggable, 26666 { 26667 __experimentalTransferDataType: "wp-blocks", 26668 transferData: { type: "inserter", blocks: draggableBlocks }, 26669 onDragStart: (event) => { 26670 startDragging2(); 26671 const addedTypes = /* @__PURE__ */ new Set(); 26672 for (const block of draggableBlocks) { 26673 const type = `wp-block:$block.name}`; 26674 if (!addedTypes.has(type)) { 26675 event.dataTransfer.items.add("", type); 26676 addedTypes.add(type); 26677 } 26678 } 26679 }, 26680 onDragEnd: () => { 26681 stopDragging2(); 26682 }, 26683 __experimentalDragComponent: /* @__PURE__ */ (0, import_jsx_runtime164.jsx)( 26684 BlockDraggableChip, 26685 { 26686 count: blocks2.length, 26687 icon: icon || !pattern && blockTypeIcon, 26688 isPattern: !!pattern 26689 } 26690 ), 26691 children: ({ onDraggableStart, onDraggableEnd }) => { 26692 return children({ 26693 draggable: true, 26694 onDragStart: onDraggableStart, 26695 onDragEnd: onDraggableEnd 26696 }); 26697 } 26698 } 26699 ); 26700 }; 26701 var inserter_draggable_blocks_default = InserterDraggableBlocks; 26702 26703 // packages/block-editor/build-module/components/inserter-list-item/index.js 26704 var import_jsx_runtime165 = __toESM(require_jsx_runtime()); 26705 function InserterListItem({ 26706 className, 26707 isFirst, 26708 item, 26709 onSelect, 26710 onHover, 26711 isDraggable, 26712 ...props 26713 }) { 26714 const isDraggingRef = (0, import_element55.useRef)(false); 26715 const itemIconStyle = item.icon ? { 26716 backgroundColor: item.icon.background, 26717 color: item.icon.foreground 26718 } : {}; 26719 const blocks2 = (0, import_element55.useMemo)( 26720 () => [ 26721 (0, import_blocks28.createBlock)( 26722 item.name, 26723 item.initialAttributes, 26724 (0, import_blocks28.createBlocksFromInnerBlocksTemplate)(item.innerBlocks) 26725 ) 26726 ], 26727 [item.name, item.initialAttributes, item.innerBlocks] 26728 ); 26729 const isSynced = (0, import_blocks28.isReusableBlock)(item) && item.syncStatus !== "unsynced" || (0, import_blocks28.isTemplatePart)(item); 26730 return /* @__PURE__ */ (0, import_jsx_runtime165.jsx)( 26731 inserter_draggable_blocks_default, 26732 { 26733 isEnabled: isDraggable && !item.isDisabled, 26734 blocks: blocks2, 26735 icon: item.icon, 26736 children: ({ draggable, onDragStart, onDragEnd }) => /* @__PURE__ */ (0, import_jsx_runtime165.jsx)( 26737 "div", 26738 { 26739 className: clsx_default( 26740 "block-editor-block-types-list__list-item", 26741 { 26742 "is-synced": isSynced 26743 } 26744 ), 26745 draggable, 26746 onDragStart: (event) => { 26747 isDraggingRef.current = true; 26748 if (onDragStart) { 26749 onHover(null); 26750 onDragStart(event); 26751 } 26752 }, 26753 onDragEnd: (event) => { 26754 isDraggingRef.current = false; 26755 if (onDragEnd) { 26756 onDragEnd(event); 26757 } 26758 }, 26759 children: /* @__PURE__ */ (0, import_jsx_runtime165.jsxs)( 26760 item_default, 26761 { 26762 isFirst, 26763 className: clsx_default( 26764 "block-editor-block-types-list__item", 26765 className 26766 ), 26767 disabled: item.isDisabled, 26768 onClick: (event) => { 26769 event.preventDefault(); 26770 onSelect( 26771 item, 26772 (0, import_keycodes6.isAppleOS)() ? event.metaKey : event.ctrlKey 26773 ); 26774 onHover(null); 26775 }, 26776 onKeyDown: (event) => { 26777 const { keyCode } = event; 26778 if (keyCode === import_keycodes6.ENTER) { 26779 event.preventDefault(); 26780 onSelect( 26781 item, 26782 (0, import_keycodes6.isAppleOS)() ? event.metaKey : event.ctrlKey 26783 ); 26784 onHover(null); 26785 } 26786 }, 26787 onMouseEnter: () => { 26788 if (isDraggingRef.current) { 26789 return; 26790 } 26791 onHover(item); 26792 }, 26793 onMouseLeave: () => onHover(null), 26794 ...props, 26795 children: [ 26796 /* @__PURE__ */ (0, import_jsx_runtime165.jsx)( 26797 "span", 26798 { 26799 className: "block-editor-block-types-list__item-icon", 26800 style: itemIconStyle, 26801 children: /* @__PURE__ */ (0, import_jsx_runtime165.jsx)(block_icon_default, { icon: item.icon, showColors: true }) 26802 } 26803 ), 26804 /* @__PURE__ */ (0, import_jsx_runtime165.jsx)("span", { className: "block-editor-block-types-list__item-title", children: /* @__PURE__ */ (0, import_jsx_runtime165.jsx)(import_components36.__experimentalTruncate, { numberOfLines: 3, children: item.title }) }) 26805 ] 26806 } 26807 ) 26808 } 26809 ) 26810 } 26811 ); 26812 } 26813 var inserter_list_item_default = (0, import_element55.memo)(InserterListItem); 26814 26815 // packages/block-editor/build-module/components/block-types-list/index.js 26816 var import_jsx_runtime166 = __toESM(require_jsx_runtime()); 26817 function chunk(array, size) { 26818 const chunks = []; 26819 for (let i2 = 0, j2 = array.length; i2 < j2; i2 += size) { 26820 chunks.push(array.slice(i2, i2 + size)); 26821 } 26822 return chunks; 26823 } 26824 function BlockTypesList({ 26825 items = [], 26826 onSelect, 26827 onHover = () => { 26828 }, 26829 children, 26830 label, 26831 isDraggable = true 26832 }) { 26833 const className = "block-editor-block-types-list"; 26834 const listId = (0, import_compose33.useInstanceId)(BlockTypesList, className); 26835 return /* @__PURE__ */ (0, import_jsx_runtime166.jsxs)(group_default2, { className, "aria-label": label, children: [ 26836 chunk(items, 3).map((row, i2) => /* @__PURE__ */ (0, import_jsx_runtime166.jsx)(row_default2, { children: row.map((item, j2) => /* @__PURE__ */ (0, import_jsx_runtime166.jsx)( 26837 inserter_list_item_default, 26838 { 26839 item, 26840 className: (0, import_blocks29.getBlockMenuDefaultClassName)( 26841 item.id 26842 ), 26843 onSelect, 26844 onHover, 26845 isDraggable: isDraggable && !item.isDisabled, 26846 isFirst: i2 === 0 && j2 === 0, 26847 rowId: `$listId}-$i2}` 26848 }, 26849 item.id 26850 )) }, i2)), 26851 children 26852 ] }); 26853 } 26854 var block_types_list_default = BlockTypesList; 26855 26856 // packages/block-editor/build-module/components/inserter/panel.js 26857 var import_components37 = __toESM(require_components()); 26858 var import_jsx_runtime167 = __toESM(require_jsx_runtime()); 26859 function InserterPanel({ title, icon, children }) { 26860 return /* @__PURE__ */ (0, import_jsx_runtime167.jsxs)(import_jsx_runtime167.Fragment, { children: [ 26861 /* @__PURE__ */ (0, import_jsx_runtime167.jsxs)("div", { className: "block-editor-inserter__panel-header", children: [ 26862 /* @__PURE__ */ (0, import_jsx_runtime167.jsx)("h2", { className: "block-editor-inserter__panel-title", children: title }), 26863 /* @__PURE__ */ (0, import_jsx_runtime167.jsx)(import_components37.Icon, { icon }) 26864 ] }), 26865 /* @__PURE__ */ (0, import_jsx_runtime167.jsx)("div", { className: "block-editor-inserter__panel-content", children }) 26866 ] }); 26867 } 26868 var panel_default = InserterPanel; 26869 26870 // packages/block-editor/build-module/components/inserter/no-results.js 26871 var import_i18n38 = __toESM(require_i18n()); 26872 var import_jsx_runtime168 = __toESM(require_jsx_runtime()); 26873 function InserterNoResults() { 26874 return /* @__PURE__ */ (0, import_jsx_runtime168.jsx)("div", { className: "block-editor-inserter__no-results", children: /* @__PURE__ */ (0, import_jsx_runtime168.jsx)("p", { children: (0, import_i18n38.__)("No results found.") }) }); 26875 } 26876 var no_results_default = InserterNoResults; 26877 26878 // packages/block-editor/build-module/components/inserter/block-types-tab.js 26879 var import_jsx_runtime169 = __toESM(require_jsx_runtime()); 26880 var getBlockNamespace = (item) => item.name.split("/")[0]; 26881 var MAX_SUGGESTED_ITEMS = 6; 26882 var EMPTY_ARRAY5 = []; 26883 function BlockTypesTabPanel({ 26884 items, 26885 collections, 26886 categories, 26887 onSelectItem, 26888 onHover, 26889 showMostUsedBlocks, 26890 className 26891 }) { 26892 const suggestedItems = (0, import_element56.useMemo)(() => { 26893 return orderBy(items, "frecency", "desc").slice( 26894 0, 26895 MAX_SUGGESTED_ITEMS 26896 ); 26897 }, [items]); 26898 const uncategorizedItems = (0, import_element56.useMemo)(() => { 26899 return items.filter((item) => !item.category); 26900 }, [items]); 26901 const itemsPerCollection = (0, import_element56.useMemo)(() => { 26902 const result = { ...collections }; 26903 Object.keys(collections).forEach((namespace) => { 26904 result[namespace] = items.filter( 26905 (item) => getBlockNamespace(item) === namespace 26906 ); 26907 if (result[namespace].length === 0) { 26908 delete result[namespace]; 26909 } 26910 }); 26911 return result; 26912 }, [items, collections]); 26913 (0, import_element56.useEffect)(() => () => onHover(null), []); 26914 const currentlyRenderedCategories = (0, import_compose34.useAsyncList)(categories); 26915 const didRenderAllCategories = categories.length === currentlyRenderedCategories.length; 26916 const collectionEntries = (0, import_element56.useMemo)(() => { 26917 return Object.entries(collections); 26918 }, [collections]); 26919 const currentlyRenderedCollections = (0, import_compose34.useAsyncList)( 26920 didRenderAllCategories ? collectionEntries : EMPTY_ARRAY5 26921 ); 26922 return /* @__PURE__ */ (0, import_jsx_runtime169.jsxs)("div", { className, children: [ 26923 showMostUsedBlocks && // Only show the most used blocks if the total amount of block 26924 // is larger than 1 row, otherwise it is not so useful. 26925 items.length > 3 && !!suggestedItems.length && /* @__PURE__ */ (0, import_jsx_runtime169.jsx)(panel_default, { title: (0, import_i18n39._x)("Most used", "blocks"), children: /* @__PURE__ */ (0, import_jsx_runtime169.jsx)( 26926 block_types_list_default, 26927 { 26928 items: suggestedItems, 26929 onSelect: onSelectItem, 26930 onHover, 26931 label: (0, import_i18n39._x)("Most used", "blocks") 26932 } 26933 ) }), 26934 currentlyRenderedCategories.map((category) => { 26935 const categoryItems = items.filter( 26936 (item) => item.category === category.slug 26937 ); 26938 if (!categoryItems || !categoryItems.length) { 26939 return null; 26940 } 26941 return /* @__PURE__ */ (0, import_jsx_runtime169.jsx)( 26942 panel_default, 26943 { 26944 title: category.title, 26945 icon: category.icon, 26946 children: /* @__PURE__ */ (0, import_jsx_runtime169.jsx)( 26947 block_types_list_default, 26948 { 26949 items: categoryItems, 26950 onSelect: onSelectItem, 26951 onHover, 26952 label: category.title 26953 } 26954 ) 26955 }, 26956 category.slug 26957 ); 26958 }), 26959 didRenderAllCategories && uncategorizedItems.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime169.jsx)( 26960 panel_default, 26961 { 26962 className: "block-editor-inserter__uncategorized-blocks-panel", 26963 title: (0, import_i18n39.__)("Uncategorized"), 26964 children: /* @__PURE__ */ (0, import_jsx_runtime169.jsx)( 26965 block_types_list_default, 26966 { 26967 items: uncategorizedItems, 26968 onSelect: onSelectItem, 26969 onHover, 26970 label: (0, import_i18n39.__)("Uncategorized") 26971 } 26972 ) 26973 } 26974 ), 26975 currentlyRenderedCollections.map( 26976 ([namespace, collection]) => { 26977 const collectionItems = itemsPerCollection[namespace]; 26978 if (!collectionItems || !collectionItems.length) { 26979 return null; 26980 } 26981 return /* @__PURE__ */ (0, import_jsx_runtime169.jsx)( 26982 panel_default, 26983 { 26984 title: collection.title, 26985 icon: collection.icon, 26986 children: /* @__PURE__ */ (0, import_jsx_runtime169.jsx)( 26987 block_types_list_default, 26988 { 26989 items: collectionItems, 26990 onSelect: onSelectItem, 26991 onHover, 26992 label: collection.title 26993 } 26994 ) 26995 }, 26996 namespace 26997 ); 26998 } 26999 ) 27000 ] }); 27001 } 27002 function BlockTypesTab({ rootClientId, onInsert, onHover, showMostUsedBlocks }, ref) { 27003 const [items, categories, collections, onSelectItem] = use_block_types_state_default( 27004 rootClientId, 27005 onInsert 27006 ); 27007 if (!items.length) { 27008 return /* @__PURE__ */ (0, import_jsx_runtime169.jsx)(no_results_default, {}); 27009 } 27010 const itemsForCurrentRoot = []; 27011 const itemsRemaining = []; 27012 for (const item of items) { 27013 if (item.category === "reusable") { 27014 continue; 27015 } 27016 if (item.isSearchOnly) { 27017 continue; 27018 } 27019 if (item.isAllowedInCurrentRoot) { 27020 itemsForCurrentRoot.push(item); 27021 } else { 27022 itemsRemaining.push(item); 27023 } 27024 } 27025 return /* @__PURE__ */ (0, import_jsx_runtime169.jsx)(inserter_listbox_default, { children: /* @__PURE__ */ (0, import_jsx_runtime169.jsxs)("div", { ref, children: [ 27026 !!itemsForCurrentRoot.length && /* @__PURE__ */ (0, import_jsx_runtime169.jsx)(import_jsx_runtime169.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime169.jsx)( 27027 BlockTypesTabPanel, 27028 { 27029 items: itemsForCurrentRoot, 27030 categories, 27031 collections, 27032 onSelectItem, 27033 onHover, 27034 showMostUsedBlocks, 27035 className: "block-editor-inserter__insertable-blocks-at-selection" 27036 } 27037 ) }), 27038 /* @__PURE__ */ (0, import_jsx_runtime169.jsx)( 27039 BlockTypesTabPanel, 27040 { 27041 items: itemsRemaining, 27042 categories, 27043 collections, 27044 onSelectItem, 27045 onHover, 27046 showMostUsedBlocks, 27047 className: "block-editor-inserter__all-blocks" 27048 } 27049 ) 27050 ] }) }); 27051 } 27052 var block_types_tab_default = (0, import_element56.forwardRef)(BlockTypesTab); 27053 27054 // packages/block-editor/build-module/components/inserter/block-patterns-tab/index.js 27055 var import_element67 = __toESM(require_element()); 27056 var import_compose39 = __toESM(require_compose()); 27057 var import_components47 = __toESM(require_components()); 27058 var import_i18n51 = __toESM(require_i18n()); 27059 27060 // packages/block-editor/build-module/components/inserter/block-patterns-explorer/index.js 27061 var import_components42 = __toESM(require_components()); 27062 var import_element63 = __toESM(require_element()); 27063 var import_i18n47 = __toESM(require_i18n()); 27064 27065 // packages/block-editor/build-module/components/inserter/block-patterns-explorer/pattern-explorer-sidebar.js 27066 var import_components38 = __toESM(require_components()); 27067 var import_i18n40 = __toESM(require_i18n()); 27068 var import_jsx_runtime170 = __toESM(require_jsx_runtime()); 27069 function PatternCategoriesList({ 27070 selectedCategory, 27071 patternCategories, 27072 onClickCategory 27073 }) { 27074 const baseClassName = "block-editor-block-patterns-explorer__sidebar"; 27075 return /* @__PURE__ */ (0, import_jsx_runtime170.jsx)("div", { className: `$baseClassName}__categories-list`, children: patternCategories.map(({ name, label }) => { 27076 return /* @__PURE__ */ (0, import_jsx_runtime170.jsx)( 27077 import_components38.Button, 27078 { 27079 __next40pxDefaultSize: true, 27080 label, 27081 className: `$baseClassName}__categories-list__item`, 27082 isPressed: selectedCategory === name, 27083 onClick: () => { 27084 onClickCategory(name); 27085 }, 27086 children: label 27087 }, 27088 name 27089 ); 27090 }) }); 27091 } 27092 function PatternsExplorerSearch({ searchValue, setSearchValue }) { 27093 const baseClassName = "block-editor-block-patterns-explorer__search"; 27094 return /* @__PURE__ */ (0, import_jsx_runtime170.jsx)("div", { className: baseClassName, children: /* @__PURE__ */ (0, import_jsx_runtime170.jsx)( 27095 import_components38.SearchControl, 27096 { 27097 onChange: setSearchValue, 27098 value: searchValue, 27099 label: (0, import_i18n40.__)("Search"), 27100 placeholder: (0, import_i18n40.__)("Search") 27101 } 27102 ) }); 27103 } 27104 function PatternExplorerSidebar({ 27105 selectedCategory, 27106 patternCategories, 27107 onClickCategory, 27108 searchValue, 27109 setSearchValue 27110 }) { 27111 const baseClassName = "block-editor-block-patterns-explorer__sidebar"; 27112 return /* @__PURE__ */ (0, import_jsx_runtime170.jsxs)("div", { className: baseClassName, children: [ 27113 /* @__PURE__ */ (0, import_jsx_runtime170.jsx)( 27114 PatternsExplorerSearch, 27115 { 27116 searchValue, 27117 setSearchValue 27118 } 27119 ), 27120 !searchValue && /* @__PURE__ */ (0, import_jsx_runtime170.jsx)( 27121 PatternCategoriesList, 27122 { 27123 selectedCategory, 27124 patternCategories, 27125 onClickCategory 27126 } 27127 ) 27128 ] }); 27129 } 27130 var pattern_explorer_sidebar_default = PatternExplorerSidebar; 27131 27132 // packages/block-editor/build-module/components/inserter/block-patterns-explorer/pattern-list.js 27133 var import_element61 = __toESM(require_element()); 27134 var import_i18n45 = __toESM(require_i18n()); 27135 var import_compose37 = __toESM(require_compose()); 27136 var import_components41 = __toESM(require_components()); 27137 var import_a11y7 = __toESM(require_a11y()); 27138 27139 // packages/block-editor/build-module/components/block-patterns-list/index.js 27140 var import_blocks30 = __toESM(require_blocks()); 27141 var import_element57 = __toESM(require_element()); 27142 var import_components40 = __toESM(require_components()); 27143 var import_compose35 = __toESM(require_compose()); 27144 var import_i18n42 = __toESM(require_i18n()); 27145 27146 // packages/block-editor/build-module/components/block-patterns-paging/index.js 27147 var import_components39 = __toESM(require_components()); 27148 var import_i18n41 = __toESM(require_i18n()); 27149 var import_jsx_runtime171 = __toESM(require_jsx_runtime()); 27150 function Pagination({ 27151 currentPage, 27152 numPages, 27153 changePage, 27154 totalItems 27155 }) { 27156 return /* @__PURE__ */ (0, import_jsx_runtime171.jsxs)(import_components39.__experimentalVStack, { className: "block-editor-patterns__grid-pagination-wrapper", children: [ 27157 /* @__PURE__ */ (0, import_jsx_runtime171.jsx)(import_components39.__experimentalText, { variant: "muted", children: (0, import_i18n41.sprintf)( 27158 // translators: %s: Total number of patterns. 27159 (0, import_i18n41._n)("%s item", "%s items", totalItems), 27160 totalItems 27161 ) }), 27162 numPages > 1 && /* @__PURE__ */ (0, import_jsx_runtime171.jsxs)( 27163 import_components39.__experimentalHStack, 27164 { 27165 expanded: false, 27166 spacing: 3, 27167 justify: "flex-start", 27168 className: "block-editor-patterns__grid-pagination", 27169 children: [ 27170 /* @__PURE__ */ (0, import_jsx_runtime171.jsxs)( 27171 import_components39.__experimentalHStack, 27172 { 27173 expanded: false, 27174 spacing: 1, 27175 className: "block-editor-patterns__grid-pagination-previous", 27176 children: [ 27177 /* @__PURE__ */ (0, import_jsx_runtime171.jsx)( 27178 import_components39.Button, 27179 { 27180 variant: "tertiary", 27181 onClick: () => changePage(1), 27182 disabled: currentPage === 1, 27183 "aria-label": (0, import_i18n41.__)("First page"), 27184 size: "compact", 27185 accessibleWhenDisabled: true, 27186 className: "block-editor-patterns__grid-pagination-button", 27187 children: /* @__PURE__ */ (0, import_jsx_runtime171.jsx)("span", { children: "\xAB" }) 27188 } 27189 ), 27190 /* @__PURE__ */ (0, import_jsx_runtime171.jsx)( 27191 import_components39.Button, 27192 { 27193 variant: "tertiary", 27194 onClick: () => changePage(currentPage - 1), 27195 disabled: currentPage === 1, 27196 "aria-label": (0, import_i18n41.__)("Previous page"), 27197 size: "compact", 27198 accessibleWhenDisabled: true, 27199 className: "block-editor-patterns__grid-pagination-button", 27200 children: /* @__PURE__ */ (0, import_jsx_runtime171.jsx)("span", { children: "\u2039" }) 27201 } 27202 ) 27203 ] 27204 } 27205 ), 27206 /* @__PURE__ */ (0, import_jsx_runtime171.jsx)(import_components39.__experimentalText, { variant: "muted", children: (0, import_i18n41.sprintf)( 27207 // translators: 1: Current page number. 2: Total number of pages. 27208 (0, import_i18n41._x)("%1$s of %2$s", "paging"), 27209 currentPage, 27210 numPages 27211 ) }), 27212 /* @__PURE__ */ (0, import_jsx_runtime171.jsxs)( 27213 import_components39.__experimentalHStack, 27214 { 27215 expanded: false, 27216 spacing: 1, 27217 className: "block-editor-patterns__grid-pagination-next", 27218 children: [ 27219 /* @__PURE__ */ (0, import_jsx_runtime171.jsx)( 27220 import_components39.Button, 27221 { 27222 variant: "tertiary", 27223 onClick: () => changePage(currentPage + 1), 27224 disabled: currentPage === numPages, 27225 "aria-label": (0, import_i18n41.__)("Next page"), 27226 size: "compact", 27227 accessibleWhenDisabled: true, 27228 className: "block-editor-patterns__grid-pagination-button", 27229 children: /* @__PURE__ */ (0, import_jsx_runtime171.jsx)("span", { children: "\u203A" }) 27230 } 27231 ), 27232 /* @__PURE__ */ (0, import_jsx_runtime171.jsx)( 27233 import_components39.Button, 27234 { 27235 variant: "tertiary", 27236 onClick: () => changePage(numPages), 27237 disabled: currentPage === numPages, 27238 "aria-label": (0, import_i18n41.__)("Last page"), 27239 size: "compact", 27240 accessibleWhenDisabled: true, 27241 className: "block-editor-patterns__grid-pagination-button", 27242 children: /* @__PURE__ */ (0, import_jsx_runtime171.jsx)("span", { children: "\xBB" }) 27243 } 27244 ) 27245 ] 27246 } 27247 ) 27248 ] 27249 } 27250 ) 27251 ] }); 27252 } 27253 27254 // packages/block-editor/build-module/components/block-patterns-list/index.js 27255 var import_jsx_runtime172 = __toESM(require_jsx_runtime()); 27256 var WithToolTip = ({ showTooltip, title, children }) => { 27257 if (showTooltip) { 27258 return /* @__PURE__ */ (0, import_jsx_runtime172.jsx)(import_components40.Tooltip, { text: title, children }); 27259 } 27260 return /* @__PURE__ */ (0, import_jsx_runtime172.jsx)(import_jsx_runtime172.Fragment, { children }); 27261 }; 27262 function BlockPattern({ 27263 id, 27264 isDraggable, 27265 pattern, 27266 onClick, 27267 onHover, 27268 showTitlesAsTooltip, 27269 category, 27270 isSelected 27271 }) { 27272 const [isDragging3, setIsDragging] = (0, import_element57.useState)(false); 27273 const { blocks: blocks2, viewportWidth } = pattern; 27274 const instanceId = (0, import_compose35.useInstanceId)(BlockPattern); 27275 const descriptionId = `block-editor-block-patterns-list__item-description-$instanceId}`; 27276 const isUserPattern = pattern.type === INSERTER_PATTERN_TYPES.user; 27277 const patternBlocks = (0, import_element57.useMemo)(() => { 27278 if (!category || !isDraggable) { 27279 return blocks2; 27280 } 27281 return (blocks2 ?? []).map((block) => { 27282 const clonedBlock = (0, import_blocks30.cloneBlock)(block); 27283 if (clonedBlock.attributes.metadata?.categories?.includes( 27284 category 27285 )) { 27286 clonedBlock.attributes.metadata.categories = [category]; 27287 } 27288 return clonedBlock; 27289 }); 27290 }, [blocks2, isDraggable, category]); 27291 return /* @__PURE__ */ (0, import_jsx_runtime172.jsx)( 27292 inserter_draggable_blocks_default, 27293 { 27294 isEnabled: isDraggable, 27295 blocks: patternBlocks, 27296 pattern, 27297 children: ({ draggable, onDragStart, onDragEnd }) => /* @__PURE__ */ (0, import_jsx_runtime172.jsx)( 27298 "div", 27299 { 27300 className: "block-editor-block-patterns-list__list-item", 27301 draggable, 27302 onDragStart: (event) => { 27303 setIsDragging(true); 27304 if (onDragStart) { 27305 onHover?.(null); 27306 onDragStart(event); 27307 } 27308 }, 27309 onDragEnd: (event) => { 27310 setIsDragging(false); 27311 if (onDragEnd) { 27312 onDragEnd(event); 27313 } 27314 }, 27315 children: /* @__PURE__ */ (0, import_jsx_runtime172.jsx)( 27316 WithToolTip, 27317 { 27318 showTooltip: showTitlesAsTooltip && !isUserPattern, 27319 title: pattern.title, 27320 children: /* @__PURE__ */ (0, import_jsx_runtime172.jsxs)( 27321 import_components40.Composite.Item, 27322 { 27323 render: /* @__PURE__ */ (0, import_jsx_runtime172.jsx)( 27324 "div", 27325 { 27326 role: "option", 27327 "aria-label": pattern.title, 27328 "aria-describedby": pattern.description ? descriptionId : void 0, 27329 className: clsx_default( 27330 "block-editor-block-patterns-list__item", 27331 { 27332 "block-editor-block-patterns-list__list-item-synced": pattern.type === INSERTER_PATTERN_TYPES.user && !pattern.syncStatus, 27333 "is-selected": isSelected 27334 } 27335 ) 27336 } 27337 ), 27338 id, 27339 onClick: () => { 27340 onClick(pattern, blocks2); 27341 onHover?.(null); 27342 }, 27343 onMouseEnter: () => { 27344 if (isDragging3) { 27345 return; 27346 } 27347 onHover?.(pattern); 27348 }, 27349 onMouseLeave: () => onHover?.(null), 27350 children: [ 27351 /* @__PURE__ */ (0, import_jsx_runtime172.jsx)( 27352 block_preview_default.Async, 27353 { 27354 placeholder: /* @__PURE__ */ (0, import_jsx_runtime172.jsx)(BlockPatternPlaceholder, {}), 27355 children: /* @__PURE__ */ (0, import_jsx_runtime172.jsx)( 27356 block_preview_default, 27357 { 27358 blocks: blocks2, 27359 viewportWidth 27360 } 27361 ) 27362 } 27363 ), 27364 (!showTitlesAsTooltip || isUserPattern) && /* @__PURE__ */ (0, import_jsx_runtime172.jsxs)( 27365 import_components40.__experimentalHStack, 27366 { 27367 className: "block-editor-patterns__pattern-details", 27368 spacing: 2, 27369 children: [ 27370 isUserPattern && !pattern.syncStatus && /* @__PURE__ */ (0, import_jsx_runtime172.jsx)("div", { className: "block-editor-patterns__pattern-icon-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime172.jsx)( 27371 icon_default, 27372 { 27373 className: "block-editor-patterns__pattern-icon", 27374 icon: symbol_default 27375 } 27376 ) }), 27377 /* @__PURE__ */ (0, import_jsx_runtime172.jsx)("div", { className: "block-editor-block-patterns-list__item-title", children: pattern.title }) 27378 ] 27379 } 27380 ), 27381 !!pattern.description && /* @__PURE__ */ (0, import_jsx_runtime172.jsx)(import_components40.VisuallyHidden, { id: descriptionId, children: pattern.description }) 27382 ] 27383 } 27384 ) 27385 } 27386 ) 27387 } 27388 ) 27389 } 27390 ); 27391 } 27392 function BlockPatternPlaceholder() { 27393 return /* @__PURE__ */ (0, import_jsx_runtime172.jsx)("div", { className: "block-editor-block-patterns-list__item is-placeholder" }); 27394 } 27395 function BlockPatternsList({ 27396 isDraggable, 27397 blockPatterns, 27398 onHover, 27399 onClickPattern, 27400 orientation, 27401 label = (0, import_i18n42.__)("Block patterns"), 27402 category, 27403 showTitlesAsTooltip, 27404 pagingProps 27405 }, ref) { 27406 const [activeCompositeId, setActiveCompositeId] = (0, import_element57.useState)(void 0); 27407 const [activePattern, setActivePattern] = (0, import_element57.useState)(null); 27408 (0, import_element57.useEffect)(() => { 27409 const firstCompositeItemId = blockPatterns[0]?.name; 27410 setActiveCompositeId(firstCompositeItemId); 27411 }, [blockPatterns]); 27412 const handleClickPattern = (pattern, blocks2) => { 27413 setActivePattern(pattern.name); 27414 onClickPattern(pattern, blocks2); 27415 }; 27416 return /* @__PURE__ */ (0, import_jsx_runtime172.jsxs)( 27417 import_components40.Composite, 27418 { 27419 orientation, 27420 activeId: activeCompositeId, 27421 setActiveId: setActiveCompositeId, 27422 role: "listbox", 27423 className: "block-editor-block-patterns-list", 27424 "aria-label": label, 27425 ref, 27426 children: [ 27427 blockPatterns.map((pattern) => /* @__PURE__ */ (0, import_jsx_runtime172.jsx)( 27428 BlockPattern, 27429 { 27430 id: pattern.name, 27431 pattern, 27432 onClick: handleClickPattern, 27433 onHover, 27434 isDraggable, 27435 showTitlesAsTooltip, 27436 category, 27437 isSelected: !!activePattern && activePattern === pattern.name 27438 }, 27439 pattern.name 27440 )), 27441 pagingProps && /* @__PURE__ */ (0, import_jsx_runtime172.jsx)(Pagination, { ...pagingProps }) 27442 ] 27443 } 27444 ); 27445 } 27446 var block_patterns_list_default = (0, import_element57.forwardRef)(BlockPatternsList); 27447 27448 // packages/block-editor/build-module/components/inserter/hooks/use-insertion-point.js 27449 var import_data50 = __toESM(require_data()); 27450 var import_blocks31 = __toESM(require_blocks()); 27451 var import_i18n43 = __toESM(require_i18n()); 27452 var import_a11y6 = __toESM(require_a11y()); 27453 var import_element58 = __toESM(require_element()); 27454 function getIndex({ 27455 destinationRootClientId, 27456 destinationIndex, 27457 rootClientId, 27458 registry 27459 }) { 27460 if (rootClientId === destinationRootClientId) { 27461 return destinationIndex; 27462 } 27463 const parents = [ 27464 "", 27465 ...registry.select(store).getBlockParents(destinationRootClientId), 27466 destinationRootClientId 27467 ]; 27468 const parentIndex = parents.indexOf(rootClientId); 27469 if (parentIndex !== -1) { 27470 return registry.select(store).getBlockIndex(parents[parentIndex + 1]) + 1; 27471 } 27472 return registry.select(store).getBlockOrder(rootClientId).length; 27473 } 27474 function useInsertionPoint({ 27475 rootClientId = "", 27476 insertionIndex, 27477 clientId, 27478 isAppender, 27479 onSelect, 27480 shouldFocusBlock = true, 27481 selectBlockOnInsert = true 27482 }) { 27483 const registry = (0, import_data50.useRegistry)(); 27484 const { 27485 getSelectedBlock: getSelectedBlock2, 27486 getClosestAllowedInsertionPoint: getClosestAllowedInsertionPoint2, 27487 isBlockInsertionPointVisible: isBlockInsertionPointVisible2 27488 } = unlock((0, import_data50.useSelect)(store)); 27489 const { destinationRootClientId, destinationIndex } = (0, import_data50.useSelect)( 27490 (select3) => { 27491 const { 27492 getSelectedBlockClientId: getSelectedBlockClientId2, 27493 getBlockRootClientId: getBlockRootClientId2, 27494 getBlockIndex: getBlockIndex2, 27495 getBlockOrder: getBlockOrder2, 27496 getInsertionPoint: getInsertionPoint2 27497 } = unlock(select3(store)); 27498 const selectedBlockClientId = getSelectedBlockClientId2(); 27499 let _destinationRootClientId = rootClientId; 27500 let _destinationIndex; 27501 const insertionPoint2 = getInsertionPoint2(); 27502 if (insertionIndex !== void 0) { 27503 _destinationIndex = insertionIndex; 27504 } else if (insertionPoint2 && insertionPoint2.hasOwnProperty("index")) { 27505 _destinationRootClientId = insertionPoint2?.rootClientId ? insertionPoint2.rootClientId : rootClientId; 27506 _destinationIndex = insertionPoint2.index; 27507 } else if (clientId) { 27508 _destinationIndex = getBlockIndex2(clientId); 27509 } else if (!isAppender && selectedBlockClientId) { 27510 _destinationRootClientId = getBlockRootClientId2( 27511 selectedBlockClientId 27512 ); 27513 _destinationIndex = getBlockIndex2(selectedBlockClientId) + 1; 27514 } else { 27515 _destinationIndex = getBlockOrder2( 27516 _destinationRootClientId 27517 ).length; 27518 } 27519 return { 27520 destinationRootClientId: _destinationRootClientId, 27521 destinationIndex: _destinationIndex 27522 }; 27523 }, 27524 [rootClientId, insertionIndex, clientId, isAppender] 27525 ); 27526 const { 27527 replaceBlocks: replaceBlocks2, 27528 insertBlocks: insertBlocks2, 27529 showInsertionPoint: showInsertionPoint2, 27530 hideInsertionPoint: hideInsertionPoint2, 27531 setLastFocus: setLastFocus2 27532 } = unlock((0, import_data50.useDispatch)(store)); 27533 const onInsertBlocks = (0, import_element58.useCallback)( 27534 (blocks2, meta, shouldForceFocusBlock = false, _rootClientId) => { 27535 if (shouldForceFocusBlock || shouldFocusBlock || selectBlockOnInsert) { 27536 setLastFocus2(null); 27537 } 27538 const selectedBlock = getSelectedBlock2(); 27539 if (!isAppender && selectedBlock && (0, import_blocks31.isUnmodifiedDefaultBlock)(selectedBlock, "content")) { 27540 replaceBlocks2( 27541 selectedBlock.clientId, 27542 blocks2, 27543 null, 27544 shouldFocusBlock || shouldForceFocusBlock ? 0 : null, 27545 meta 27546 ); 27547 } else { 27548 insertBlocks2( 27549 blocks2, 27550 isAppender || _rootClientId === void 0 ? destinationIndex : getIndex({ 27551 destinationRootClientId, 27552 destinationIndex, 27553 rootClientId: _rootClientId, 27554 registry 27555 }), 27556 isAppender || _rootClientId === void 0 ? destinationRootClientId : _rootClientId, 27557 selectBlockOnInsert, 27558 shouldFocusBlock || shouldForceFocusBlock ? 0 : null, 27559 meta 27560 ); 27561 } 27562 const blockLength = Array.isArray(blocks2) ? blocks2.length : 1; 27563 const message2 = (0, import_i18n43.sprintf)( 27564 // translators: %d: the name of the block that has been added 27565 (0, import_i18n43._n)("%d block added.", "%d blocks added.", blockLength), 27566 blockLength 27567 ); 27568 (0, import_a11y6.speak)(message2); 27569 if (onSelect) { 27570 onSelect(blocks2); 27571 } 27572 }, 27573 [ 27574 isAppender, 27575 getSelectedBlock2, 27576 replaceBlocks2, 27577 insertBlocks2, 27578 destinationRootClientId, 27579 destinationIndex, 27580 onSelect, 27581 shouldFocusBlock, 27582 selectBlockOnInsert, 27583 setLastFocus2, 27584 registry 27585 ] 27586 ); 27587 const onToggleInsertionPoint = (0, import_element58.useCallback)( 27588 (item) => { 27589 if (item && !isBlockInsertionPointVisible2()) { 27590 const allowedDestinationRootClientId = getClosestAllowedInsertionPoint2( 27591 item.name, 27592 destinationRootClientId 27593 ); 27594 if (allowedDestinationRootClientId !== null) { 27595 showInsertionPoint2( 27596 allowedDestinationRootClientId, 27597 getIndex({ 27598 destinationRootClientId, 27599 destinationIndex, 27600 rootClientId: allowedDestinationRootClientId, 27601 registry 27602 }) 27603 ); 27604 } 27605 } else { 27606 hideInsertionPoint2(); 27607 } 27608 }, 27609 [ 27610 getClosestAllowedInsertionPoint2, 27611 isBlockInsertionPointVisible2, 27612 showInsertionPoint2, 27613 hideInsertionPoint2, 27614 destinationRootClientId, 27615 destinationIndex, 27616 registry 27617 ] 27618 ); 27619 return [destinationRootClientId, onInsertBlocks, onToggleInsertionPoint]; 27620 } 27621 var use_insertion_point_default = useInsertionPoint; 27622 27623 // packages/block-editor/build-module/components/inserter/hooks/use-patterns-state.js 27624 var import_element59 = __toESM(require_element()); 27625 var import_blocks32 = __toESM(require_blocks()); 27626 var import_data51 = __toESM(require_data()); 27627 var import_i18n44 = __toESM(require_i18n()); 27628 var import_notices4 = __toESM(require_notices()); 27629 var usePatternsState = (onInsert, rootClientId, selectedCategory, isQuick) => { 27630 const options = (0, import_element59.useMemo)( 27631 () => ({ [isFiltered]: !!isQuick }), 27632 [isQuick] 27633 ); 27634 const { patternCategories, patterns, userPatternCategories } = (0, import_data51.useSelect)( 27635 (select3) => { 27636 const { getSettings: getSettings8, __experimentalGetAllowedPatterns: __experimentalGetAllowedPatterns2 } = unlock( 27637 select3(store) 27638 ); 27639 const { 27640 __experimentalUserPatternCategories, 27641 __experimentalBlockPatternCategories 27642 } = getSettings8(); 27643 return { 27644 patterns: __experimentalGetAllowedPatterns2( 27645 rootClientId, 27646 options 27647 ), 27648 userPatternCategories: __experimentalUserPatternCategories, 27649 patternCategories: __experimentalBlockPatternCategories 27650 }; 27651 }, 27652 [rootClientId, options] 27653 ); 27654 const { getClosestAllowedInsertionPointForPattern: getClosestAllowedInsertionPointForPattern2 } = unlock( 27655 (0, import_data51.useSelect)(store) 27656 ); 27657 const allCategories = (0, import_element59.useMemo)(() => { 27658 const categories = [...patternCategories]; 27659 userPatternCategories?.forEach((userCategory) => { 27660 if (!categories.find( 27661 (existingCategory) => existingCategory.name === userCategory.name 27662 )) { 27663 categories.push(userCategory); 27664 } 27665 }); 27666 return categories; 27667 }, [patternCategories, userPatternCategories]); 27668 const { createSuccessNotice } = (0, import_data51.useDispatch)(import_notices4.store); 27669 const onClickPattern = (0, import_element59.useCallback)( 27670 (pattern, blocks2) => { 27671 const destinationRootClientId = isQuick ? rootClientId : getClosestAllowedInsertionPointForPattern2( 27672 pattern, 27673 rootClientId 27674 ); 27675 if (destinationRootClientId === null) { 27676 return; 27677 } 27678 const patternBlocks = pattern.type === INSERTER_PATTERN_TYPES.user && pattern.syncStatus !== "unsynced" ? [(0, import_blocks32.createBlock)("core/block", { ref: pattern.id })] : blocks2; 27679 onInsert( 27680 (patternBlocks ?? []).map((block) => { 27681 const clonedBlock = (0, import_blocks32.cloneBlock)(block); 27682 if (clonedBlock.attributes.metadata?.categories?.includes( 27683 selectedCategory 27684 )) { 27685 clonedBlock.attributes.metadata.categories = [ 27686 selectedCategory 27687 ]; 27688 } 27689 return clonedBlock; 27690 }), 27691 pattern.name, 27692 false, 27693 destinationRootClientId 27694 ); 27695 createSuccessNotice( 27696 (0, import_i18n44.sprintf)( 27697 /* translators: %s: block pattern title. */ 27698 (0, import_i18n44.__)('Block pattern "%s" inserted.'), 27699 pattern.title 27700 ), 27701 { 27702 type: "snackbar", 27703 id: "inserter-notice" 27704 } 27705 ); 27706 }, 27707 [ 27708 createSuccessNotice, 27709 onInsert, 27710 selectedCategory, 27711 rootClientId, 27712 getClosestAllowedInsertionPointForPattern2, 27713 isQuick 27714 ] 27715 ); 27716 return [patterns, allCategories, onClickPattern]; 27717 }; 27718 var use_patterns_state_default = usePatternsState; 27719 27720 // packages/block-editor/build-module/components/inserter/hooks/use-patterns-paging.js 27721 var import_element60 = __toESM(require_element()); 27722 var import_compose36 = __toESM(require_compose()); 27723 var import_dom19 = __toESM(require_dom()); 27724 var PAGE_SIZE = 20; 27725 function usePatternsPaging(currentCategoryPatterns, currentCategory, scrollContainerRef, currentFilter = "") { 27726 const [currentPage, setCurrentPage] = (0, import_element60.useState)(1); 27727 const previousCategory = (0, import_compose36.usePrevious)(currentCategory); 27728 const previousFilter = (0, import_compose36.usePrevious)(currentFilter); 27729 if ((previousCategory !== currentCategory || previousFilter !== currentFilter) && currentPage !== 1) { 27730 setCurrentPage(1); 27731 } 27732 const totalItems = currentCategoryPatterns.length; 27733 const pageIndex = currentPage - 1; 27734 const categoryPatterns = (0, import_element60.useMemo)(() => { 27735 return currentCategoryPatterns.slice( 27736 pageIndex * PAGE_SIZE, 27737 pageIndex * PAGE_SIZE + PAGE_SIZE 27738 ); 27739 }, [pageIndex, currentCategoryPatterns]); 27740 const numPages = Math.ceil(currentCategoryPatterns.length / PAGE_SIZE); 27741 const changePage = (page) => { 27742 const scrollContainer = (0, import_dom19.getScrollContainer)( 27743 scrollContainerRef?.current 27744 ); 27745 scrollContainer?.scrollTo(0, 0); 27746 setCurrentPage(page); 27747 }; 27748 (0, import_element60.useEffect)( 27749 function scrollToTopOnCategoryChange() { 27750 const scrollContainer = (0, import_dom19.getScrollContainer)( 27751 scrollContainerRef?.current 27752 ); 27753 scrollContainer?.scrollTo(0, 0); 27754 }, 27755 [currentCategory, scrollContainerRef] 27756 ); 27757 return { 27758 totalItems, 27759 categoryPatterns, 27760 numPages, 27761 changePage, 27762 currentPage 27763 }; 27764 } 27765 27766 // packages/block-editor/build-module/components/inserter/block-patterns-explorer/pattern-list.js 27767 var import_jsx_runtime173 = __toESM(require_jsx_runtime()); 27768 function PatternsListHeader({ filterValue, filteredBlockPatternsLength }) { 27769 if (!filterValue) { 27770 return null; 27771 } 27772 return /* @__PURE__ */ (0, import_jsx_runtime173.jsx)( 27773 import_components41.__experimentalHeading, 27774 { 27775 level: 2, 27776 lineHeight: "48px", 27777 className: "block-editor-block-patterns-explorer__search-results-count", 27778 children: (0, import_i18n45.sprintf)( 27779 /* translators: %d: number of patterns. */ 27780 (0, import_i18n45._n)( 27781 "%d pattern found", 27782 "%d patterns found", 27783 filteredBlockPatternsLength 27784 ), 27785 filteredBlockPatternsLength 27786 ) 27787 } 27788 ); 27789 } 27790 function PatternList({ 27791 searchValue, 27792 selectedCategory, 27793 patternCategories, 27794 rootClientId, 27795 onModalClose 27796 }) { 27797 const container = (0, import_element61.useRef)(); 27798 const debouncedSpeak = (0, import_compose37.useDebounce)(import_a11y7.speak, 500); 27799 const [destinationRootClientId, onInsertBlocks] = use_insertion_point_default({ 27800 rootClientId, 27801 shouldFocusBlock: true 27802 }); 27803 const [patterns, , onClickPattern] = use_patterns_state_default( 27804 onInsertBlocks, 27805 destinationRootClientId, 27806 selectedCategory 27807 ); 27808 const registeredPatternCategories = (0, import_element61.useMemo)( 27809 () => patternCategories.map( 27810 (patternCategory) => patternCategory.name 27811 ), 27812 [patternCategories] 27813 ); 27814 const filteredBlockPatterns = (0, import_element61.useMemo)(() => { 27815 const filteredPatterns = patterns.filter((pattern) => { 27816 if (selectedCategory === allPatternsCategory.name) { 27817 return true; 27818 } 27819 if (selectedCategory === myPatternsCategory.name && pattern.type === INSERTER_PATTERN_TYPES.user) { 27820 return true; 27821 } 27822 if (selectedCategory === starterPatternsCategory.name && pattern.blockTypes?.includes("core/post-content")) { 27823 return true; 27824 } 27825 if (selectedCategory === "uncategorized") { 27826 const hasKnownCategory = pattern.categories?.some( 27827 (category) => registeredPatternCategories.includes(category) 27828 ) ?? false; 27829 return !pattern.categories?.length || !hasKnownCategory; 27830 } 27831 return pattern.categories?.includes(selectedCategory); 27832 }); 27833 if (!searchValue) { 27834 return filteredPatterns; 27835 } 27836 return searchItems(filteredPatterns, searchValue); 27837 }, [ 27838 searchValue, 27839 patterns, 27840 selectedCategory, 27841 registeredPatternCategories 27842 ]); 27843 (0, import_element61.useEffect)(() => { 27844 if (!searchValue) { 27845 return; 27846 } 27847 const count = filteredBlockPatterns.length; 27848 const resultsFoundMessage = (0, import_i18n45.sprintf)( 27849 /* translators: %d: number of results. */ 27850 (0, import_i18n45._n)("%d result found.", "%d results found.", count), 27851 count 27852 ); 27853 debouncedSpeak(resultsFoundMessage); 27854 }, [searchValue, debouncedSpeak, filteredBlockPatterns.length]); 27855 const pagingProps = usePatternsPaging( 27856 filteredBlockPatterns, 27857 selectedCategory, 27858 container 27859 ); 27860 const [previousSearchValue, setPreviousSearchValue] = (0, import_element61.useState)(searchValue); 27861 if (searchValue !== previousSearchValue) { 27862 setPreviousSearchValue(searchValue); 27863 pagingProps.changePage(1); 27864 } 27865 const hasItems = !!filteredBlockPatterns?.length; 27866 return /* @__PURE__ */ (0, import_jsx_runtime173.jsxs)( 27867 "div", 27868 { 27869 className: "block-editor-block-patterns-explorer__list", 27870 ref: container, 27871 children: [ 27872 /* @__PURE__ */ (0, import_jsx_runtime173.jsx)( 27873 PatternsListHeader, 27874 { 27875 filterValue: searchValue, 27876 filteredBlockPatternsLength: filteredBlockPatterns.length 27877 } 27878 ), 27879 /* @__PURE__ */ (0, import_jsx_runtime173.jsx)(inserter_listbox_default, { children: hasItems && /* @__PURE__ */ (0, import_jsx_runtime173.jsxs)(import_jsx_runtime173.Fragment, { children: [ 27880 /* @__PURE__ */ (0, import_jsx_runtime173.jsx)( 27881 block_patterns_list_default, 27882 { 27883 blockPatterns: pagingProps.categoryPatterns, 27884 onClickPattern: (pattern, blocks2) => { 27885 onClickPattern(pattern, blocks2); 27886 onModalClose(); 27887 }, 27888 isDraggable: false 27889 } 27890 ), 27891 /* @__PURE__ */ (0, import_jsx_runtime173.jsx)(Pagination, { ...pagingProps }) 27892 ] }) }) 27893 ] 27894 } 27895 ); 27896 } 27897 var pattern_list_default = PatternList; 27898 27899 // packages/block-editor/build-module/components/inserter/block-patterns-tab/use-pattern-categories.js 27900 var import_element62 = __toESM(require_element()); 27901 var import_i18n46 = __toESM(require_i18n()); 27902 var import_a11y8 = __toESM(require_a11y()); 27903 function hasRegisteredCategory(pattern, allCategories) { 27904 if (!pattern.categories || !pattern.categories.length) { 27905 return false; 27906 } 27907 return pattern.categories.some( 27908 (cat) => allCategories.some((category) => category.name === cat) 27909 ); 27910 } 27911 function usePatternCategories(rootClientId, sourceFilter = "all") { 27912 const [patterns, allCategories] = use_patterns_state_default( 27913 void 0, 27914 rootClientId 27915 ); 27916 const filteredPatterns = (0, import_element62.useMemo)( 27917 () => sourceFilter === "all" ? patterns : patterns.filter( 27918 (pattern) => !isPatternFiltered(pattern, sourceFilter) 27919 ), 27920 [sourceFilter, patterns] 27921 ); 27922 const populatedCategories = (0, import_element62.useMemo)(() => { 27923 const categories = allCategories.filter( 27924 (category) => filteredPatterns.some( 27925 (pattern) => pattern.categories?.includes(category.name) 27926 ) 27927 ).sort((a2, b2) => a2.label.localeCompare(b2.label)); 27928 if (filteredPatterns.some( 27929 (pattern) => !hasRegisteredCategory(pattern, allCategories) 27930 ) && !categories.find( 27931 (category) => category.name === "uncategorized" 27932 )) { 27933 categories.push({ 27934 name: "uncategorized", 27935 label: (0, import_i18n46._x)("Uncategorized") 27936 }); 27937 } 27938 if (filteredPatterns.some( 27939 (pattern) => pattern.blockTypes?.includes("core/post-content") 27940 )) { 27941 categories.unshift(starterPatternsCategory); 27942 } 27943 if (filteredPatterns.some( 27944 (pattern) => pattern.type === INSERTER_PATTERN_TYPES.user 27945 )) { 27946 categories.unshift(myPatternsCategory); 27947 } 27948 if (filteredPatterns.length > 0) { 27949 categories.unshift({ 27950 name: allPatternsCategory.name, 27951 label: allPatternsCategory.label 27952 }); 27953 } 27954 (0, import_a11y8.speak)( 27955 (0, import_i18n46.sprintf)( 27956 /* translators: %d: number of categories . */ 27957 (0, import_i18n46._n)( 27958 "%d category button displayed.", 27959 "%d category buttons displayed.", 27960 categories.length 27961 ), 27962 categories.length 27963 ) 27964 ); 27965 return categories; 27966 }, [allCategories, filteredPatterns]); 27967 return populatedCategories; 27968 } 27969 27970 // packages/block-editor/build-module/components/inserter/block-patterns-explorer/index.js 27971 var import_jsx_runtime174 = __toESM(require_jsx_runtime()); 27972 function PatternsExplorer({ initialCategory, rootClientId, onModalClose }) { 27973 const [searchValue, setSearchValue] = (0, import_element63.useState)(""); 27974 const [selectedCategory, setSelectedCategory] = (0, import_element63.useState)( 27975 initialCategory?.name 27976 ); 27977 const patternCategories = usePatternCategories(rootClientId); 27978 return /* @__PURE__ */ (0, import_jsx_runtime174.jsxs)("div", { className: "block-editor-block-patterns-explorer", children: [ 27979 /* @__PURE__ */ (0, import_jsx_runtime174.jsx)( 27980 pattern_explorer_sidebar_default, 27981 { 27982 selectedCategory, 27983 patternCategories, 27984 onClickCategory: setSelectedCategory, 27985 searchValue, 27986 setSearchValue 27987 } 27988 ), 27989 /* @__PURE__ */ (0, import_jsx_runtime174.jsx)( 27990 pattern_list_default, 27991 { 27992 searchValue, 27993 selectedCategory, 27994 patternCategories, 27995 rootClientId, 27996 onModalClose 27997 } 27998 ) 27999 ] }); 28000 } 28001 function PatternsExplorerModal({ onModalClose, ...restProps }) { 28002 return /* @__PURE__ */ (0, import_jsx_runtime174.jsx)( 28003 import_components42.Modal, 28004 { 28005 title: (0, import_i18n47.__)("Patterns"), 28006 onRequestClose: onModalClose, 28007 isFullScreen: true, 28008 children: /* @__PURE__ */ (0, import_jsx_runtime174.jsx)(PatternsExplorer, { onModalClose, ...restProps }) 28009 } 28010 ); 28011 } 28012 var block_patterns_explorer_default = PatternsExplorerModal; 28013 28014 // packages/block-editor/build-module/components/inserter/mobile-tab-navigation.js 28015 var import_i18n48 = __toESM(require_i18n()); 28016 var import_components43 = __toESM(require_components()); 28017 var import_jsx_runtime175 = __toESM(require_jsx_runtime()); 28018 function ScreenHeader({ title }) { 28019 return /* @__PURE__ */ (0, import_jsx_runtime175.jsx)(import_components43.__experimentalVStack, { spacing: 0, children: /* @__PURE__ */ (0, import_jsx_runtime175.jsx)(import_components43.__experimentalView, { children: /* @__PURE__ */ (0, import_jsx_runtime175.jsx)(import_components43.__experimentalSpacer, { marginBottom: 0, paddingX: 4, paddingY: 3, children: /* @__PURE__ */ (0, import_jsx_runtime175.jsxs)(import_components43.__experimentalHStack, { spacing: 2, children: [ 28020 /* @__PURE__ */ (0, import_jsx_runtime175.jsx)( 28021 import_components43.Navigator.BackButton, 28022 { 28023 style: ( 28024 // TODO: This style override is also used in ToolsPanelHeader. 28025 // It should be supported out-of-the-box by Button. 28026 { minWidth: 24, padding: 0 } 28027 ), 28028 icon: (0, import_i18n48.isRTL)() ? chevron_right_default : chevron_left_default, 28029 size: "small", 28030 label: (0, import_i18n48.__)("Back") 28031 } 28032 ), 28033 /* @__PURE__ */ (0, import_jsx_runtime175.jsx)(import_components43.__experimentalSpacer, { children: /* @__PURE__ */ (0, import_jsx_runtime175.jsx)(import_components43.__experimentalHeading, { level: 5, children: title }) }) 28034 ] }) }) }) }); 28035 } 28036 function MobileTabNavigation({ categories, children }) { 28037 return /* @__PURE__ */ (0, import_jsx_runtime175.jsxs)( 28038 import_components43.Navigator, 28039 { 28040 initialPath: "/", 28041 className: "block-editor-inserter__mobile-tab-navigation", 28042 children: [ 28043 /* @__PURE__ */ (0, import_jsx_runtime175.jsx)(import_components43.Navigator.Screen, { path: "/", children: /* @__PURE__ */ (0, import_jsx_runtime175.jsx)(import_components43.__experimentalItemGroup, { children: categories.map((category) => /* @__PURE__ */ (0, import_jsx_runtime175.jsx)( 28044 import_components43.Navigator.Button, 28045 { 28046 path: `/category/$category.name}`, 28047 as: import_components43.__experimentalItem, 28048 isAction: true, 28049 children: /* @__PURE__ */ (0, import_jsx_runtime175.jsxs)(import_components43.__experimentalHStack, { children: [ 28050 /* @__PURE__ */ (0, import_jsx_runtime175.jsx)(import_components43.FlexBlock, { children: category.label }), 28051 /* @__PURE__ */ (0, import_jsx_runtime175.jsx)( 28052 icon_default, 28053 { 28054 icon: (0, import_i18n48.isRTL)() ? chevron_left_default : chevron_right_default 28055 } 28056 ) 28057 ] }) 28058 }, 28059 category.name 28060 )) }) }), 28061 categories.map((category) => /* @__PURE__ */ (0, import_jsx_runtime175.jsxs)( 28062 import_components43.Navigator.Screen, 28063 { 28064 path: `/category/$category.name}`, 28065 children: [ 28066 /* @__PURE__ */ (0, import_jsx_runtime175.jsx)(ScreenHeader, { title: (0, import_i18n48.__)("Back") }), 28067 children(category) 28068 ] 28069 }, 28070 category.name 28071 )) 28072 ] 28073 } 28074 ); 28075 } 28076 28077 // packages/block-editor/build-module/components/inserter/block-patterns-tab/pattern-category-previews.js 28078 var import_element65 = __toESM(require_element()); 28079 var import_i18n50 = __toESM(require_i18n()); 28080 var import_components45 = __toESM(require_components()); 28081 28082 // packages/block-editor/build-module/components/inserter/block-patterns-tab/patterns-filter.js 28083 var import_components44 = __toESM(require_components()); 28084 var import_i18n49 = __toESM(require_i18n()); 28085 var import_element64 = __toESM(require_element()); 28086 var import_jsx_runtime176 = __toESM(require_jsx_runtime()); 28087 var getShouldDisableSyncFilter = (sourceFilter) => sourceFilter !== "all" && sourceFilter !== "user"; 28088 var getShouldHideSourcesFilter = (category) => { 28089 return category.name === myPatternsCategory.name; 28090 }; 28091 var PATTERN_SOURCE_MENU_OPTIONS = [ 28092 { 28093 value: "all", 28094 label: (0, import_i18n49._x)("All", "patterns") 28095 }, 28096 { 28097 value: INSERTER_PATTERN_TYPES.directory, 28098 label: (0, import_i18n49.__)("Pattern Directory") 28099 }, 28100 { 28101 value: INSERTER_PATTERN_TYPES.theme, 28102 label: (0, import_i18n49.__)("Theme & Plugins") 28103 }, 28104 { 28105 value: INSERTER_PATTERN_TYPES.user, 28106 label: (0, import_i18n49.__)("User") 28107 } 28108 ]; 28109 function PatternsFilter({ 28110 setPatternSyncFilter, 28111 setPatternSourceFilter, 28112 patternSyncFilter, 28113 patternSourceFilter, 28114 scrollContainerRef, 28115 category 28116 }) { 28117 const currentPatternSourceFilter = category.name === myPatternsCategory.name ? INSERTER_PATTERN_TYPES.user : patternSourceFilter; 28118 const shouldDisableSyncFilter = getShouldDisableSyncFilter( 28119 currentPatternSourceFilter 28120 ); 28121 const shouldHideSourcesFilter = getShouldHideSourcesFilter(category); 28122 const patternSyncMenuOptions = (0, import_element64.useMemo)( 28123 () => [ 28124 { 28125 value: "all", 28126 label: (0, import_i18n49._x)("All", "patterns") 28127 }, 28128 { 28129 value: INSERTER_SYNC_TYPES.full, 28130 label: (0, import_i18n49._x)("Synced", "patterns"), 28131 disabled: shouldDisableSyncFilter 28132 }, 28133 { 28134 value: INSERTER_SYNC_TYPES.unsynced, 28135 label: (0, import_i18n49._x)("Not synced", "patterns"), 28136 disabled: shouldDisableSyncFilter 28137 } 28138 ], 28139 [shouldDisableSyncFilter] 28140 ); 28141 function handleSetSourceFilterChange(newSourceFilter) { 28142 setPatternSourceFilter(newSourceFilter); 28143 if (getShouldDisableSyncFilter(newSourceFilter)) { 28144 setPatternSyncFilter("all"); 28145 } 28146 } 28147 return /* @__PURE__ */ (0, import_jsx_runtime176.jsx)(import_jsx_runtime176.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime176.jsx)( 28148 import_components44.DropdownMenu, 28149 { 28150 popoverProps: { 28151 placement: "right-end" 28152 }, 28153 label: (0, import_i18n49.__)("Filter patterns"), 28154 toggleProps: { size: "compact" }, 28155 icon: /* @__PURE__ */ (0, import_jsx_runtime176.jsx)( 28156 icon_default, 28157 { 28158 icon: /* @__PURE__ */ (0, import_jsx_runtime176.jsx)( 28159 import_components44.SVG, 28160 { 28161 width: "24", 28162 height: "24", 28163 viewBox: "0 0 24 24", 28164 fill: "none", 28165 xmlns: "http://www.w3.org/2000/svg", 28166 children: /* @__PURE__ */ (0, import_jsx_runtime176.jsx)( 28167 import_components44.Path, 28168 { 28169 d: "M10 17.5H14V16H10V17.5ZM6 6V7.5H18V6H6ZM8 12.5H16V11H8V12.5Z", 28170 fill: "currentColor" 28171 } 28172 ) 28173 } 28174 ) 28175 } 28176 ), 28177 children: () => /* @__PURE__ */ (0, import_jsx_runtime176.jsxs)(import_jsx_runtime176.Fragment, { children: [ 28178 !shouldHideSourcesFilter && /* @__PURE__ */ (0, import_jsx_runtime176.jsx)(import_components44.MenuGroup, { label: (0, import_i18n49.__)("Source"), children: /* @__PURE__ */ (0, import_jsx_runtime176.jsx)( 28179 import_components44.MenuItemsChoice, 28180 { 28181 choices: PATTERN_SOURCE_MENU_OPTIONS, 28182 onSelect: (value) => { 28183 handleSetSourceFilterChange(value); 28184 scrollContainerRef.current?.scrollTo( 28185 0, 28186 0 28187 ); 28188 }, 28189 value: currentPatternSourceFilter 28190 } 28191 ) }), 28192 /* @__PURE__ */ (0, import_jsx_runtime176.jsx)(import_components44.MenuGroup, { label: (0, import_i18n49.__)("Type"), children: /* @__PURE__ */ (0, import_jsx_runtime176.jsx)( 28193 import_components44.MenuItemsChoice, 28194 { 28195 choices: patternSyncMenuOptions, 28196 onSelect: (value) => { 28197 setPatternSyncFilter(value); 28198 scrollContainerRef.current?.scrollTo( 28199 0, 28200 0 28201 ); 28202 }, 28203 value: patternSyncFilter 28204 } 28205 ) }), 28206 /* @__PURE__ */ (0, import_jsx_runtime176.jsx)("div", { className: "block-editor-inserter__patterns-filter-help", children: (0, import_element64.createInterpolateElement)( 28207 (0, import_i18n49.__)( 28208 "Patterns are available from the <Link>WordPress.org Pattern Directory</Link>, bundled in the active theme, or created by users on this site. Only patterns created on this site can be synced." 28209 ), 28210 { 28211 Link: /* @__PURE__ */ (0, import_jsx_runtime176.jsx)( 28212 import_components44.ExternalLink, 28213 { 28214 href: (0, import_i18n49.__)( 28215 "https://wordpress.org/patterns/" 28216 ) 28217 } 28218 ) 28219 } 28220 ) }) 28221 ] }) 28222 } 28223 ) }); 28224 } 28225 28226 // packages/block-editor/build-module/components/inserter/block-patterns-tab/pattern-category-previews.js 28227 var import_jsx_runtime177 = __toESM(require_jsx_runtime()); 28228 var noop7 = () => { 28229 }; 28230 function PatternCategoryPreviews({ 28231 rootClientId, 28232 onInsert, 28233 onHover = noop7, 28234 category, 28235 showTitlesAsTooltip 28236 }) { 28237 const [allPatterns, , onClickPattern] = use_patterns_state_default( 28238 onInsert, 28239 rootClientId, 28240 category?.name 28241 ); 28242 const [patternSyncFilter, setPatternSyncFilter] = (0, import_element65.useState)("all"); 28243 const [patternSourceFilter, setPatternSourceFilter] = (0, import_element65.useState)("all"); 28244 const availableCategories = usePatternCategories( 28245 rootClientId, 28246 patternSourceFilter 28247 ); 28248 const scrollContainerRef = (0, import_element65.useRef)(); 28249 const currentCategoryPatterns = (0, import_element65.useMemo)( 28250 () => allPatterns.filter((pattern) => { 28251 if (isPatternFiltered( 28252 pattern, 28253 patternSourceFilter, 28254 patternSyncFilter 28255 )) { 28256 return false; 28257 } 28258 if (category.name === allPatternsCategory.name) { 28259 return true; 28260 } 28261 if (category.name === myPatternsCategory.name && pattern.type === INSERTER_PATTERN_TYPES.user) { 28262 return true; 28263 } 28264 if (category.name === starterPatternsCategory.name && pattern.blockTypes?.includes("core/post-content")) { 28265 return true; 28266 } 28267 if (category.name === "uncategorized") { 28268 if (!pattern.categories) { 28269 return true; 28270 } 28271 return !pattern.categories.some( 28272 (catName) => availableCategories.some((c6) => c6.name === catName) 28273 ); 28274 } 28275 return pattern.categories?.includes(category.name); 28276 }), 28277 [ 28278 allPatterns, 28279 availableCategories, 28280 category.name, 28281 patternSourceFilter, 28282 patternSyncFilter 28283 ] 28284 ); 28285 const pagingProps = usePatternsPaging( 28286 currentCategoryPatterns, 28287 category, 28288 scrollContainerRef 28289 ); 28290 const { changePage } = pagingProps; 28291 (0, import_element65.useEffect)(() => () => onHover(null), []); 28292 const onSetPatternSyncFilter = (0, import_element65.useCallback)( 28293 (value) => { 28294 setPatternSyncFilter(value); 28295 changePage(1); 28296 }, 28297 [setPatternSyncFilter, changePage] 28298 ); 28299 const onSetPatternSourceFilter = (0, import_element65.useCallback)( 28300 (value) => { 28301 setPatternSourceFilter(value); 28302 changePage(1); 28303 }, 28304 [setPatternSourceFilter, changePage] 28305 ); 28306 return /* @__PURE__ */ (0, import_jsx_runtime177.jsxs)(import_jsx_runtime177.Fragment, { children: [ 28307 /* @__PURE__ */ (0, import_jsx_runtime177.jsxs)( 28308 import_components45.__experimentalVStack, 28309 { 28310 spacing: 2, 28311 className: "block-editor-inserter__patterns-category-panel-header", 28312 children: [ 28313 /* @__PURE__ */ (0, import_jsx_runtime177.jsxs)(import_components45.__experimentalHStack, { children: [ 28314 /* @__PURE__ */ (0, import_jsx_runtime177.jsx)(import_components45.FlexBlock, { children: /* @__PURE__ */ (0, import_jsx_runtime177.jsx)( 28315 import_components45.__experimentalHeading, 28316 { 28317 className: "block-editor-inserter__patterns-category-panel-title", 28318 size: 13, 28319 level: 4, 28320 as: "div", 28321 children: category.label 28322 } 28323 ) }), 28324 /* @__PURE__ */ (0, import_jsx_runtime177.jsx)( 28325 PatternsFilter, 28326 { 28327 patternSyncFilter, 28328 patternSourceFilter, 28329 setPatternSyncFilter: onSetPatternSyncFilter, 28330 setPatternSourceFilter: onSetPatternSourceFilter, 28331 scrollContainerRef, 28332 category 28333 } 28334 ) 28335 ] }), 28336 !currentCategoryPatterns.length && /* @__PURE__ */ (0, import_jsx_runtime177.jsx)( 28337 import_components45.__experimentalText, 28338 { 28339 variant: "muted", 28340 className: "block-editor-inserter__patterns-category-no-results", 28341 children: (0, import_i18n50.__)("No results found") 28342 } 28343 ) 28344 ] 28345 } 28346 ), 28347 currentCategoryPatterns.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime177.jsxs)(import_jsx_runtime177.Fragment, { children: [ 28348 /* @__PURE__ */ (0, import_jsx_runtime177.jsx)( 28349 import_components45.__experimentalText, 28350 { 28351 size: "12", 28352 as: "p", 28353 className: "block-editor-inserter__help-text", 28354 children: (0, import_i18n50.__)("Drag and drop patterns into the canvas.") 28355 } 28356 ), 28357 /* @__PURE__ */ (0, import_jsx_runtime177.jsx)( 28358 block_patterns_list_default, 28359 { 28360 ref: scrollContainerRef, 28361 blockPatterns: pagingProps.categoryPatterns, 28362 onClickPattern, 28363 onHover, 28364 label: category.label, 28365 orientation: "vertical", 28366 category: category.name, 28367 isDraggable: true, 28368 showTitlesAsTooltip, 28369 patternFilter: patternSourceFilter, 28370 pagingProps 28371 } 28372 ) 28373 ] }) 28374 ] }); 28375 } 28376 28377 // packages/block-editor/build-module/components/inserter/category-tabs/index.js 28378 var import_compose38 = __toESM(require_compose()); 28379 var import_components46 = __toESM(require_components()); 28380 var import_element66 = __toESM(require_element()); 28381 var import_jsx_runtime178 = __toESM(require_jsx_runtime()); 28382 var { Tabs } = unlock(import_components46.privateApis); 28383 function CategoryTabs({ 28384 categories, 28385 selectedCategory, 28386 onSelectCategory, 28387 children 28388 }) { 28389 const ANIMATION_DURATION = 0.25; 28390 const disableMotion = (0, import_compose38.useReducedMotion)(); 28391 const defaultTransition = { 28392 type: "tween", 28393 duration: disableMotion ? 0 : ANIMATION_DURATION, 28394 ease: [0.6, 0, 0.4, 1] 28395 }; 28396 const previousSelectedCategory = (0, import_compose38.usePrevious)(selectedCategory); 28397 const selectedTabId = selectedCategory ? selectedCategory.name : null; 28398 const [activeTabId, setActiveId] = (0, import_element66.useState)(); 28399 const firstTabId = categories?.[0]?.name; 28400 if (selectedTabId === null && !activeTabId && firstTabId) { 28401 setActiveId(firstTabId); 28402 } 28403 return /* @__PURE__ */ (0, import_jsx_runtime178.jsxs)( 28404 Tabs, 28405 { 28406 selectOnMove: false, 28407 selectedTabId, 28408 orientation: "vertical", 28409 onSelect: (categoryId) => { 28410 onSelectCategory( 28411 categories.find( 28412 (category) => category.name === categoryId 28413 ) 28414 ); 28415 }, 28416 activeTabId, 28417 onActiveTabIdChange: setActiveId, 28418 children: [ 28419 /* @__PURE__ */ (0, import_jsx_runtime178.jsx)(Tabs.TabList, { className: "block-editor-inserter__category-tablist", children: categories.map((category) => /* @__PURE__ */ (0, import_jsx_runtime178.jsx)( 28420 Tabs.Tab, 28421 { 28422 tabId: category.name, 28423 "aria-current": category === selectedCategory ? "true" : void 0, 28424 children: category.label 28425 }, 28426 category.name 28427 )) }), 28428 categories.map((category) => /* @__PURE__ */ (0, import_jsx_runtime178.jsx)( 28429 Tabs.TabPanel, 28430 { 28431 tabId: category.name, 28432 focusable: false, 28433 children: /* @__PURE__ */ (0, import_jsx_runtime178.jsx)( 28434 import_components46.__unstableMotion.div, 28435 { 28436 className: "block-editor-inserter__category-panel", 28437 initial: !previousSelectedCategory ? "closed" : "open", 28438 animate: "open", 28439 variants: { 28440 open: { 28441 transform: "translateX( 0 )", 28442 transitionEnd: { 28443 zIndex: "1" 28444 } 28445 }, 28446 closed: { 28447 transform: "translateX( -100% )", 28448 zIndex: "-1" 28449 } 28450 }, 28451 transition: defaultTransition, 28452 children 28453 } 28454 ) 28455 }, 28456 category.name 28457 )) 28458 ] 28459 } 28460 ); 28461 } 28462 var category_tabs_default = CategoryTabs; 28463 28464 // packages/block-editor/build-module/components/inserter/block-patterns-tab/index.js 28465 var import_jsx_runtime179 = __toESM(require_jsx_runtime()); 28466 function BlockPatternsTab({ 28467 onSelectCategory, 28468 selectedCategory, 28469 onInsert, 28470 rootClientId, 28471 children 28472 }) { 28473 const [showPatternsExplorer, setShowPatternsExplorer] = (0, import_element67.useState)(false); 28474 const categories = usePatternCategories(rootClientId); 28475 const isMobile = (0, import_compose39.useViewportMatch)("medium", "<"); 28476 if (!categories.length) { 28477 return /* @__PURE__ */ (0, import_jsx_runtime179.jsx)(no_results_default, {}); 28478 } 28479 return /* @__PURE__ */ (0, import_jsx_runtime179.jsxs)(import_jsx_runtime179.Fragment, { children: [ 28480 !isMobile && /* @__PURE__ */ (0, import_jsx_runtime179.jsxs)("div", { className: "block-editor-inserter__block-patterns-tabs-container", children: [ 28481 /* @__PURE__ */ (0, import_jsx_runtime179.jsx)( 28482 category_tabs_default, 28483 { 28484 categories, 28485 selectedCategory, 28486 onSelectCategory, 28487 children 28488 } 28489 ), 28490 /* @__PURE__ */ (0, import_jsx_runtime179.jsx)( 28491 import_components47.Button, 28492 { 28493 __next40pxDefaultSize: true, 28494 className: "block-editor-inserter__patterns-explore-button", 28495 onClick: () => setShowPatternsExplorer(true), 28496 variant: "secondary", 28497 children: (0, import_i18n51.__)("Explore all patterns") 28498 } 28499 ) 28500 ] }), 28501 isMobile && /* @__PURE__ */ (0, import_jsx_runtime179.jsx)(MobileTabNavigation, { categories, children: (category) => /* @__PURE__ */ (0, import_jsx_runtime179.jsx)("div", { className: "block-editor-inserter__category-panel", children: /* @__PURE__ */ (0, import_jsx_runtime179.jsx)( 28502 PatternCategoryPreviews, 28503 { 28504 onInsert, 28505 rootClientId, 28506 category 28507 }, 28508 category.name 28509 ) }) }), 28510 showPatternsExplorer && /* @__PURE__ */ (0, import_jsx_runtime179.jsx)( 28511 block_patterns_explorer_default, 28512 { 28513 initialCategory: selectedCategory || categories[0], 28514 patternCategories: categories, 28515 onModalClose: () => setShowPatternsExplorer(false), 28516 rootClientId 28517 } 28518 ) 28519 ] }); 28520 } 28521 var block_patterns_tab_default = BlockPatternsTab; 28522 28523 // packages/block-editor/build-module/components/inserter/media-tab/media-tab.js 28524 var import_i18n55 = __toESM(require_i18n()); 28525 var import_compose41 = __toESM(require_compose()); 28526 var import_components52 = __toESM(require_components()); 28527 var import_element70 = __toESM(require_element()); 28528 28529 // packages/block-editor/build-module/components/inserter/media-tab/media-panel.js 28530 var import_components50 = __toESM(require_components()); 28531 var import_i18n54 = __toESM(require_i18n()); 28532 var import_compose40 = __toESM(require_compose()); 28533 28534 // packages/block-editor/build-module/components/inserter/media-tab/media-list.js 28535 var import_components49 = __toESM(require_components()); 28536 var import_i18n53 = __toESM(require_i18n()); 28537 28538 // packages/block-editor/build-module/components/inserter/media-tab/media-preview.js 28539 var import_components48 = __toESM(require_components()); 28540 var import_i18n52 = __toESM(require_i18n()); 28541 var import_element68 = __toESM(require_element()); 28542 var import_blocks34 = __toESM(require_blocks()); 28543 var import_data52 = __toESM(require_data()); 28544 var import_notices5 = __toESM(require_notices()); 28545 var import_blob2 = __toESM(require_blob()); 28546 var import_url4 = __toESM(require_url()); 28547 28548 // packages/block-editor/build-module/components/inserter/media-tab/utils.js 28549 var import_blocks33 = __toESM(require_blocks()); 28550 var import_jsx_runtime180 = __toESM(require_jsx_runtime()); 28551 var mediaTypeTag = { image: "img", video: "video", audio: "audio" }; 28552 function getBlockAndPreviewFromMedia(media, mediaType) { 28553 const attributes = { 28554 id: media.id || void 0, 28555 caption: media.caption || void 0 28556 }; 28557 const mediaSrc = media.url; 28558 const alt = media.alt || void 0; 28559 if (mediaType === "image") { 28560 attributes.url = mediaSrc; 28561 attributes.alt = alt; 28562 } else if (["video", "audio"].includes(mediaType)) { 28563 attributes.src = mediaSrc; 28564 } 28565 const PreviewTag = mediaTypeTag[mediaType]; 28566 const preview = /* @__PURE__ */ (0, import_jsx_runtime180.jsx)( 28567 PreviewTag, 28568 { 28569 src: media.previewUrl || mediaSrc, 28570 alt, 28571 controls: mediaType === "audio" ? true : void 0, 28572 inert: "true", 28573 onError: ({ currentTarget }) => { 28574 if (currentTarget.src === media.previewUrl) { 28575 currentTarget.src = mediaSrc; 28576 } 28577 } 28578 } 28579 ); 28580 return [(0, import_blocks33.createBlock)(`core/$mediaType}`, attributes), preview]; 28581 } 28582 28583 // packages/block-editor/build-module/components/inserter/media-tab/media-preview.js 28584 var import_jsx_runtime181 = __toESM(require_jsx_runtime()); 28585 var ALLOWED_MEDIA_TYPES = ["image"]; 28586 var MEDIA_OPTIONS_POPOVER_PROPS = { 28587 placement: "bottom-end", 28588 className: "block-editor-inserter__media-list__item-preview-options__popover" 28589 }; 28590 function MediaPreviewOptions({ category, media }) { 28591 if (!category.getReportUrl) { 28592 return null; 28593 } 28594 const reportUrl = category.getReportUrl(media); 28595 return /* @__PURE__ */ (0, import_jsx_runtime181.jsx)( 28596 import_components48.DropdownMenu, 28597 { 28598 className: "block-editor-inserter__media-list__item-preview-options", 28599 label: (0, import_i18n52.__)("Options"), 28600 popoverProps: MEDIA_OPTIONS_POPOVER_PROPS, 28601 icon: more_vertical_default, 28602 children: () => /* @__PURE__ */ (0, import_jsx_runtime181.jsx)(import_components48.MenuGroup, { children: /* @__PURE__ */ (0, import_jsx_runtime181.jsx)( 28603 import_components48.MenuItem, 28604 { 28605 onClick: () => window.open(reportUrl, "_blank").focus(), 28606 icon: external_default, 28607 children: (0, import_i18n52.sprintf)( 28608 /* translators: %s: The media type to report e.g: "image", "video", "audio" */ 28609 (0, import_i18n52.__)("Report %s"), 28610 category.mediaType 28611 ) 28612 } 28613 ) }) 28614 } 28615 ); 28616 } 28617 function InsertExternalImageModal({ onClose, onSubmit }) { 28618 return /* @__PURE__ */ (0, import_jsx_runtime181.jsxs)( 28619 import_components48.Modal, 28620 { 28621 title: (0, import_i18n52.__)("Insert external image"), 28622 onRequestClose: onClose, 28623 className: "block-editor-inserter-media-tab-media-preview-inserter-external-image-modal", 28624 children: [ 28625 /* @__PURE__ */ (0, import_jsx_runtime181.jsxs)(import_components48.__experimentalVStack, { spacing: 3, children: [ 28626 /* @__PURE__ */ (0, import_jsx_runtime181.jsx)("p", { children: (0, import_i18n52.__)( 28627 "This image cannot be uploaded to your Media Library, but it can still be inserted as an external image." 28628 ) }), 28629 /* @__PURE__ */ (0, import_jsx_runtime181.jsx)("p", { children: (0, import_i18n52.__)( 28630 "External images can be removed by the external provider without warning and could even have legal compliance issues related to privacy legislation." 28631 ) }) 28632 ] }), 28633 /* @__PURE__ */ (0, import_jsx_runtime181.jsxs)( 28634 import_components48.Flex, 28635 { 28636 className: "block-editor-block-lock-modal__actions", 28637 justify: "flex-end", 28638 expanded: false, 28639 children: [ 28640 /* @__PURE__ */ (0, import_jsx_runtime181.jsx)(import_components48.FlexItem, { children: /* @__PURE__ */ (0, import_jsx_runtime181.jsx)( 28641 import_components48.Button, 28642 { 28643 __next40pxDefaultSize: true, 28644 variant: "tertiary", 28645 onClick: onClose, 28646 children: (0, import_i18n52.__)("Cancel") 28647 } 28648 ) }), 28649 /* @__PURE__ */ (0, import_jsx_runtime181.jsx)(import_components48.FlexItem, { children: /* @__PURE__ */ (0, import_jsx_runtime181.jsx)( 28650 import_components48.Button, 28651 { 28652 __next40pxDefaultSize: true, 28653 variant: "primary", 28654 onClick: onSubmit, 28655 children: (0, import_i18n52.__)("Insert") 28656 } 28657 ) }) 28658 ] 28659 } 28660 ) 28661 ] 28662 } 28663 ); 28664 } 28665 function MediaPreview({ media, onClick, category }) { 28666 const [showExternalUploadModal, setShowExternalUploadModal] = (0, import_element68.useState)(false); 28667 const [isHovered, setIsHovered] = (0, import_element68.useState)(false); 28668 const [isInserting, setIsInserting] = (0, import_element68.useState)(false); 28669 const [block, preview] = (0, import_element68.useMemo)( 28670 () => getBlockAndPreviewFromMedia(media, category.mediaType), 28671 [media, category.mediaType] 28672 ); 28673 const { createErrorNotice, createSuccessNotice } = (0, import_data52.useDispatch)(import_notices5.store); 28674 const { getSettings: getSettings8, getBlock: getBlock2 } = (0, import_data52.useSelect)(store); 28675 const { updateBlockAttributes: updateBlockAttributes2 } = (0, import_data52.useDispatch)(store); 28676 const onMediaInsert = (0, import_element68.useCallback)( 28677 (previewBlock) => { 28678 if (isInserting) { 28679 return; 28680 } 28681 const settings2 = getSettings8(); 28682 const clonedBlock = (0, import_blocks34.cloneBlock)(previewBlock); 28683 const { id, url, caption } = clonedBlock.attributes; 28684 if (!id && !settings2.mediaUpload) { 28685 setShowExternalUploadModal(true); 28686 return; 28687 } 28688 if (!!id) { 28689 onClick(clonedBlock); 28690 return; 28691 } 28692 setIsInserting(true); 28693 window.fetch(url).then((response) => response.blob()).then((blob) => { 28694 const fileName = (0, import_url4.getFilename)(url) || "image.jpg"; 28695 const file = new File([blob], fileName, { 28696 type: blob.type 28697 }); 28698 settings2.mediaUpload({ 28699 filesList: [file], 28700 additionalData: { caption }, 28701 onFileChange([img]) { 28702 if ((0, import_blob2.isBlobURL)(img.url)) { 28703 return; 28704 } 28705 if (!getBlock2(clonedBlock.clientId)) { 28706 onClick({ 28707 ...clonedBlock, 28708 attributes: { 28709 ...clonedBlock.attributes, 28710 id: img.id, 28711 url: img.url 28712 } 28713 }); 28714 createSuccessNotice( 28715 (0, import_i18n52.__)("Image uploaded and inserted."), 28716 { type: "snackbar", id: "inserter-notice" } 28717 ); 28718 } else { 28719 updateBlockAttributes2(clonedBlock.clientId, { 28720 ...clonedBlock.attributes, 28721 id: img.id, 28722 url: img.url 28723 }); 28724 } 28725 setIsInserting(false); 28726 }, 28727 allowedTypes: ALLOWED_MEDIA_TYPES, 28728 onError(message2) { 28729 createErrorNotice(message2, { 28730 type: "snackbar", 28731 id: "inserter-notice" 28732 }); 28733 setIsInserting(false); 28734 } 28735 }); 28736 }).catch(() => { 28737 setShowExternalUploadModal(true); 28738 setIsInserting(false); 28739 }); 28740 }, 28741 [ 28742 isInserting, 28743 getSettings8, 28744 onClick, 28745 createSuccessNotice, 28746 updateBlockAttributes2, 28747 createErrorNotice, 28748 getBlock2 28749 ] 28750 ); 28751 const title = typeof media.title === "string" ? media.title : media.title?.rendered || (0, import_i18n52.__)("no title"); 28752 const onMouseEnter = (0, import_element68.useCallback)(() => setIsHovered(true), []); 28753 const onMouseLeave = (0, import_element68.useCallback)(() => setIsHovered(false), []); 28754 return /* @__PURE__ */ (0, import_jsx_runtime181.jsxs)(import_jsx_runtime181.Fragment, { children: [ 28755 /* @__PURE__ */ (0, import_jsx_runtime181.jsx)(inserter_draggable_blocks_default, { isEnabled: true, blocks: [block], children: ({ draggable, onDragStart, onDragEnd }) => /* @__PURE__ */ (0, import_jsx_runtime181.jsx)( 28756 "div", 28757 { 28758 className: clsx_default( 28759 "block-editor-inserter__media-list__list-item", 28760 { 28761 "is-hovered": isHovered 28762 } 28763 ), 28764 draggable, 28765 onDragStart, 28766 onDragEnd, 28767 children: /* @__PURE__ */ (0, import_jsx_runtime181.jsxs)( 28768 "div", 28769 { 28770 onMouseEnter, 28771 onMouseLeave, 28772 children: [ 28773 /* @__PURE__ */ (0, import_jsx_runtime181.jsx)(import_components48.Tooltip, { text: title, children: /* @__PURE__ */ (0, import_jsx_runtime181.jsx)( 28774 import_components48.Composite.Item, 28775 { 28776 render: /* @__PURE__ */ (0, import_jsx_runtime181.jsx)( 28777 "div", 28778 { 28779 "aria-label": title, 28780 role: "option", 28781 className: "block-editor-inserter__media-list__item" 28782 } 28783 ), 28784 onClick: () => onMediaInsert(block), 28785 children: /* @__PURE__ */ (0, import_jsx_runtime181.jsxs)("div", { className: "block-editor-inserter__media-list__item-preview", children: [ 28786 preview, 28787 isInserting && /* @__PURE__ */ (0, import_jsx_runtime181.jsx)("div", { className: "block-editor-inserter__media-list__item-preview-spinner", children: /* @__PURE__ */ (0, import_jsx_runtime181.jsx)(import_components48.Spinner, {}) }) 28788 ] }) 28789 } 28790 ) }), 28791 !isInserting && /* @__PURE__ */ (0, import_jsx_runtime181.jsx)( 28792 MediaPreviewOptions, 28793 { 28794 category, 28795 media 28796 } 28797 ) 28798 ] 28799 } 28800 ) 28801 } 28802 ) }), 28803 showExternalUploadModal && /* @__PURE__ */ (0, import_jsx_runtime181.jsx)( 28804 InsertExternalImageModal, 28805 { 28806 onClose: () => setShowExternalUploadModal(false), 28807 onSubmit: () => { 28808 onClick((0, import_blocks34.cloneBlock)(block)); 28809 createSuccessNotice((0, import_i18n52.__)("Image inserted."), { 28810 type: "snackbar", 28811 id: "inserter-notice" 28812 }); 28813 setShowExternalUploadModal(false); 28814 } 28815 } 28816 ) 28817 ] }); 28818 } 28819 28820 // packages/block-editor/build-module/components/inserter/media-tab/media-list.js 28821 var import_jsx_runtime182 = __toESM(require_jsx_runtime()); 28822 function MediaList({ 28823 mediaList, 28824 category, 28825 onClick, 28826 label = (0, import_i18n53.__)("Media List") 28827 }) { 28828 return /* @__PURE__ */ (0, import_jsx_runtime182.jsx)( 28829 import_components49.Composite, 28830 { 28831 role: "listbox", 28832 className: "block-editor-inserter__media-list", 28833 "aria-label": label, 28834 children: mediaList.map((media, index) => /* @__PURE__ */ (0, import_jsx_runtime182.jsx)( 28835 MediaPreview, 28836 { 28837 media, 28838 category, 28839 onClick 28840 }, 28841 media.id || media.sourceId || index 28842 )) 28843 } 28844 ); 28845 } 28846 var media_list_default = MediaList; 28847 28848 // packages/block-editor/build-module/components/inserter/media-tab/hooks.js 28849 var import_element69 = __toESM(require_element()); 28850 var import_data53 = __toESM(require_data()); 28851 function useMediaResults(category, query = {}) { 28852 const [mediaList, setMediaList] = (0, import_element69.useState)(); 28853 const [isLoading, setIsLoading] = (0, import_element69.useState)(false); 28854 const lastRequestRef = (0, import_element69.useRef)(); 28855 (0, import_element69.useEffect)(() => { 28856 (async () => { 28857 const key = JSON.stringify({ 28858 category: category.name, 28859 ...query 28860 }); 28861 lastRequestRef.current = key; 28862 setIsLoading(true); 28863 setMediaList([]); 28864 const _media = await category.fetch?.(query); 28865 if (key === lastRequestRef.current) { 28866 setMediaList(_media); 28867 setIsLoading(false); 28868 } 28869 })(); 28870 }, [category.name, ...Object.values(query)]); 28871 return { mediaList, isLoading }; 28872 } 28873 function useMediaCategories(rootClientId) { 28874 const [categories, setCategories] = (0, import_element69.useState)([]); 28875 const inserterMediaCategories = (0, import_data53.useSelect)( 28876 (select3) => unlock(select3(store)).getInserterMediaCategories(), 28877 [] 28878 ); 28879 const { canInsertImage, canInsertVideo, canInsertAudio } = (0, import_data53.useSelect)( 28880 (select3) => { 28881 const { canInsertBlockType: canInsertBlockType2 } = select3(store); 28882 return { 28883 canInsertImage: canInsertBlockType2( 28884 "core/image", 28885 rootClientId 28886 ), 28887 canInsertVideo: canInsertBlockType2( 28888 "core/video", 28889 rootClientId 28890 ), 28891 canInsertAudio: canInsertBlockType2( 28892 "core/audio", 28893 rootClientId 28894 ) 28895 }; 28896 }, 28897 [rootClientId] 28898 ); 28899 (0, import_element69.useEffect)(() => { 28900 (async () => { 28901 const _categories = []; 28902 if (!inserterMediaCategories) { 28903 return; 28904 } 28905 const categoriesHaveMedia = new Map( 28906 await Promise.all( 28907 inserterMediaCategories.map(async (category) => { 28908 if (category.isExternalResource) { 28909 return [category.name, true]; 28910 } 28911 let results = []; 28912 try { 28913 results = await category.fetch({ 28914 per_page: 1 28915 }); 28916 } catch (e2) { 28917 } 28918 return [category.name, !!results.length]; 28919 }) 28920 ) 28921 ); 28922 const canInsertMediaType = { 28923 image: canInsertImage, 28924 video: canInsertVideo, 28925 audio: canInsertAudio 28926 }; 28927 inserterMediaCategories.forEach((category) => { 28928 if (canInsertMediaType[category.mediaType] && categoriesHaveMedia.get(category.name)) { 28929 _categories.push(category); 28930 } 28931 }); 28932 if (!!_categories.length) { 28933 setCategories(_categories); 28934 } 28935 })(); 28936 }, [ 28937 canInsertImage, 28938 canInsertVideo, 28939 canInsertAudio, 28940 inserterMediaCategories 28941 ]); 28942 return categories; 28943 } 28944 28945 // packages/block-editor/build-module/components/inserter/media-tab/media-panel.js 28946 var import_jsx_runtime183 = __toESM(require_jsx_runtime()); 28947 var INITIAL_MEDIA_ITEMS_PER_PAGE = 10; 28948 function MediaCategoryPanel({ rootClientId, onInsert, category }) { 28949 const [search, setSearch, debouncedSearch] = (0, import_compose40.useDebouncedInput)(); 28950 const { mediaList, isLoading } = useMediaResults(category, { 28951 per_page: !!debouncedSearch ? 20 : INITIAL_MEDIA_ITEMS_PER_PAGE, 28952 search: debouncedSearch 28953 }); 28954 const baseCssClass = "block-editor-inserter__media-panel"; 28955 const searchLabel = category.labels.search_items || (0, import_i18n54.__)("Search"); 28956 return /* @__PURE__ */ (0, import_jsx_runtime183.jsxs)("div", { className: baseCssClass, children: [ 28957 /* @__PURE__ */ (0, import_jsx_runtime183.jsx)( 28958 import_components50.SearchControl, 28959 { 28960 className: `$baseCssClass}-search`, 28961 onChange: setSearch, 28962 value: search, 28963 label: searchLabel, 28964 placeholder: searchLabel 28965 } 28966 ), 28967 isLoading && /* @__PURE__ */ (0, import_jsx_runtime183.jsx)("div", { className: `$baseCssClass}-spinner`, children: /* @__PURE__ */ (0, import_jsx_runtime183.jsx)(import_components50.Spinner, {}) }), 28968 !isLoading && !mediaList?.length && /* @__PURE__ */ (0, import_jsx_runtime183.jsx)(no_results_default, {}), 28969 !isLoading && !!mediaList?.length && /* @__PURE__ */ (0, import_jsx_runtime183.jsx)( 28970 media_list_default, 28971 { 28972 rootClientId, 28973 onClick: onInsert, 28974 mediaList, 28975 category 28976 } 28977 ) 28978 ] }); 28979 } 28980 28981 // packages/block-editor/build-module/components/media-upload/check.js 28982 var import_data54 = __toESM(require_data()); 28983 function MediaUploadCheck({ fallback = null, children }) { 28984 const hasUploadPermissions = (0, import_data54.useSelect)((select3) => { 28985 const { getSettings: getSettings8 } = select3(store); 28986 return !!getSettings8().mediaUpload; 28987 }, []); 28988 return hasUploadPermissions ? children : fallback; 28989 } 28990 var check_default2 = MediaUploadCheck; 28991 28992 // packages/block-editor/build-module/components/media-upload/index.js 28993 var import_components51 = __toESM(require_components()); 28994 var MediaUpload = () => null; 28995 var media_upload_default = (0, import_components51.withFilters)("editor.MediaUpload")(MediaUpload); 28996 28997 // packages/block-editor/build-module/components/inserter/media-tab/media-tab.js 28998 var import_jsx_runtime184 = __toESM(require_jsx_runtime()); 28999 var ALLOWED_MEDIA_TYPES2 = ["image", "video", "audio"]; 29000 function MediaTab({ 29001 rootClientId, 29002 selectedCategory, 29003 onSelectCategory, 29004 onInsert, 29005 children 29006 }) { 29007 const mediaCategories = useMediaCategories(rootClientId); 29008 const isMobile = (0, import_compose41.useViewportMatch)("medium", "<"); 29009 const baseCssClass = "block-editor-inserter__media-tabs"; 29010 const onSelectMedia = (0, import_element70.useCallback)( 29011 (media) => { 29012 if (!media?.url) { 29013 return; 29014 } 29015 const mediaType = window.__experimentalDataViewsMediaModal && media.mime_type ? media.mime_type.split("/")[0] : media.type; 29016 const [block] = getBlockAndPreviewFromMedia(media, mediaType); 29017 onInsert(block); 29018 }, 29019 [onInsert] 29020 ); 29021 const categories = (0, import_element70.useMemo)( 29022 () => mediaCategories.map((mediaCategory) => ({ 29023 ...mediaCategory, 29024 label: mediaCategory.labels.name 29025 })), 29026 [mediaCategories] 29027 ); 29028 if (!categories.length) { 29029 return /* @__PURE__ */ (0, import_jsx_runtime184.jsx)(no_results_default, {}); 29030 } 29031 return /* @__PURE__ */ (0, import_jsx_runtime184.jsxs)(import_jsx_runtime184.Fragment, { children: [ 29032 !isMobile && /* @__PURE__ */ (0, import_jsx_runtime184.jsxs)("div", { className: `$baseCssClass}-container`, children: [ 29033 /* @__PURE__ */ (0, import_jsx_runtime184.jsx)( 29034 category_tabs_default, 29035 { 29036 categories, 29037 selectedCategory, 29038 onSelectCategory, 29039 children 29040 } 29041 ), 29042 /* @__PURE__ */ (0, import_jsx_runtime184.jsx)(check_default2, { children: /* @__PURE__ */ (0, import_jsx_runtime184.jsx)( 29043 media_upload_default, 29044 { 29045 multiple: false, 29046 onSelect: onSelectMedia, 29047 allowedTypes: ALLOWED_MEDIA_TYPES2, 29048 render: ({ open }) => /* @__PURE__ */ (0, import_jsx_runtime184.jsx)( 29049 import_components52.Button, 29050 { 29051 __next40pxDefaultSize: true, 29052 onClick: (event) => { 29053 event.target.focus(); 29054 open(); 29055 }, 29056 className: "block-editor-inserter__media-library-button", 29057 variant: "secondary", 29058 "data-unstable-ignore-focus-outside-for-relatedtarget": ".media-modal", 29059 children: (0, import_i18n55.__)("Open Media Library") 29060 } 29061 ) 29062 } 29063 ) }) 29064 ] }), 29065 isMobile && /* @__PURE__ */ (0, import_jsx_runtime184.jsx)(MobileTabNavigation, { categories, children: (category) => /* @__PURE__ */ (0, import_jsx_runtime184.jsx)( 29066 MediaCategoryPanel, 29067 { 29068 onInsert, 29069 rootClientId, 29070 category 29071 } 29072 ) }) 29073 ] }); 29074 } 29075 var media_tab_default = MediaTab; 29076 29077 // packages/block-editor/build-module/components/inserter/search-results.js 29078 var import_element71 = __toESM(require_element()); 29079 var import_i18n56 = __toESM(require_i18n()); 29080 var import_components54 = __toESM(require_components()); 29081 var import_compose42 = __toESM(require_compose()); 29082 var import_a11y9 = __toESM(require_a11y()); 29083 var import_data55 = __toESM(require_data()); 29084 29085 // packages/block-editor/build-module/components/inserter-menu-extension/index.js 29086 var import_components53 = __toESM(require_components()); 29087 var { Fill: __unstableInserterMenuExtension, Slot } = (0, import_components53.createSlotFill)( 29088 "__unstableInserterMenuExtension" 29089 ); 29090 __unstableInserterMenuExtension.Slot = Slot; 29091 var inserter_menu_extension_default = __unstableInserterMenuExtension; 29092 29093 // packages/block-editor/build-module/components/inserter/search-results.js 29094 var import_jsx_runtime185 = __toESM(require_jsx_runtime()); 29095 var INITIAL_INSERTER_RESULTS = 9; 29096 var EMPTY_ARRAY6 = []; 29097 function InserterSearchResults({ 29098 filterValue, 29099 onSelect, 29100 onHover, 29101 onHoverPattern, 29102 rootClientId, 29103 clientId, 29104 isAppender, 29105 __experimentalInsertionIndex, 29106 maxBlockPatterns, 29107 maxBlockTypes, 29108 showBlockDirectory = false, 29109 isDraggable = true, 29110 shouldFocusBlock = true, 29111 prioritizePatterns, 29112 selectBlockOnInsert, 29113 isQuick 29114 }) { 29115 const debouncedSpeak = (0, import_compose42.useDebounce)(import_a11y9.speak, 500); 29116 const { prioritizedBlocks } = (0, import_data55.useSelect)( 29117 (select3) => { 29118 const blockListSettings2 = select3(store).getBlockListSettings(rootClientId); 29119 return { 29120 prioritizedBlocks: blockListSettings2?.prioritizedInserterBlocks || EMPTY_ARRAY6 29121 }; 29122 }, 29123 [rootClientId] 29124 ); 29125 const [destinationRootClientId, onInsertBlocks] = use_insertion_point_default({ 29126 onSelect, 29127 rootClientId, 29128 clientId, 29129 isAppender, 29130 insertionIndex: __experimentalInsertionIndex, 29131 shouldFocusBlock, 29132 selectBlockOnInsert 29133 }); 29134 const [ 29135 blockTypes, 29136 blockTypeCategories, 29137 blockTypeCollections, 29138 onSelectBlockType 29139 ] = use_block_types_state_default(destinationRootClientId, onInsertBlocks, isQuick); 29140 const [patterns, , onClickPattern] = use_patterns_state_default( 29141 onInsertBlocks, 29142 destinationRootClientId, 29143 void 0, 29144 isQuick 29145 ); 29146 const filteredBlockPatterns = (0, import_element71.useMemo)(() => { 29147 if (maxBlockPatterns === 0) { 29148 return []; 29149 } 29150 const results = searchItems(patterns, filterValue); 29151 return maxBlockPatterns !== void 0 ? results.slice(0, maxBlockPatterns) : results; 29152 }, [filterValue, patterns, maxBlockPatterns]); 29153 let maxBlockTypesToShow = maxBlockTypes; 29154 if (prioritizePatterns && filteredBlockPatterns.length > 2) { 29155 maxBlockTypesToShow = 0; 29156 } 29157 const filteredBlockTypes = (0, import_element71.useMemo)(() => { 29158 if (maxBlockTypesToShow === 0) { 29159 return []; 29160 } 29161 const nonPatternBlockTypes = blockTypes.filter( 29162 (blockType) => blockType.name !== "core/block" 29163 ); 29164 let orderedItems = orderBy(nonPatternBlockTypes, "frecency", "desc"); 29165 if (!filterValue && prioritizedBlocks.length) { 29166 orderedItems = orderInserterBlockItems( 29167 orderedItems, 29168 prioritizedBlocks 29169 ); 29170 } 29171 const results = searchBlockItems( 29172 orderedItems, 29173 blockTypeCategories, 29174 blockTypeCollections, 29175 filterValue 29176 ); 29177 return maxBlockTypesToShow !== void 0 ? results.slice(0, maxBlockTypesToShow) : results; 29178 }, [ 29179 filterValue, 29180 blockTypes, 29181 blockTypeCategories, 29182 blockTypeCollections, 29183 maxBlockTypesToShow, 29184 prioritizedBlocks 29185 ]); 29186 (0, import_element71.useEffect)(() => { 29187 if (!filterValue) { 29188 return; 29189 } 29190 const count = filteredBlockTypes.length + filteredBlockPatterns.length; 29191 const resultsFoundMessage = (0, import_i18n56.sprintf)( 29192 /* translators: %d: number of results. */ 29193 (0, import_i18n56._n)("%d result found.", "%d results found.", count), 29194 count 29195 ); 29196 debouncedSpeak(resultsFoundMessage); 29197 }, [ 29198 filterValue, 29199 debouncedSpeak, 29200 filteredBlockTypes, 29201 filteredBlockPatterns 29202 ]); 29203 const currentShownBlockTypes = (0, import_compose42.useAsyncList)(filteredBlockTypes, { 29204 step: INITIAL_INSERTER_RESULTS 29205 }); 29206 const hasItems = filteredBlockTypes.length > 0 || filteredBlockPatterns.length > 0; 29207 const blocksUI = !!filteredBlockTypes.length && /* @__PURE__ */ (0, import_jsx_runtime185.jsx)( 29208 panel_default, 29209 { 29210 title: /* @__PURE__ */ (0, import_jsx_runtime185.jsx)(import_components54.VisuallyHidden, { children: (0, import_i18n56.__)("Blocks") }), 29211 children: /* @__PURE__ */ (0, import_jsx_runtime185.jsx)( 29212 block_types_list_default, 29213 { 29214 items: currentShownBlockTypes, 29215 onSelect: onSelectBlockType, 29216 onHover, 29217 label: (0, import_i18n56.__)("Blocks"), 29218 isDraggable 29219 } 29220 ) 29221 } 29222 ); 29223 const patternsUI = !!filteredBlockPatterns.length && /* @__PURE__ */ (0, import_jsx_runtime185.jsx)( 29224 panel_default, 29225 { 29226 title: /* @__PURE__ */ (0, import_jsx_runtime185.jsx)(import_components54.VisuallyHidden, { children: (0, import_i18n56.__)("Block patterns") }), 29227 children: /* @__PURE__ */ (0, import_jsx_runtime185.jsx)("div", { className: "block-editor-inserter__quick-inserter-patterns", children: /* @__PURE__ */ (0, import_jsx_runtime185.jsx)( 29228 block_patterns_list_default, 29229 { 29230 blockPatterns: filteredBlockPatterns, 29231 onClickPattern, 29232 onHover: onHoverPattern, 29233 isDraggable 29234 } 29235 ) }) 29236 } 29237 ); 29238 return /* @__PURE__ */ (0, import_jsx_runtime185.jsxs)(inserter_listbox_default, { children: [ 29239 !showBlockDirectory && !hasItems && /* @__PURE__ */ (0, import_jsx_runtime185.jsx)(no_results_default, {}), 29240 prioritizePatterns ? patternsUI : blocksUI, 29241 !!filteredBlockTypes.length && !!filteredBlockPatterns.length && /* @__PURE__ */ (0, import_jsx_runtime185.jsx)("div", { className: "block-editor-inserter__quick-inserter-separator" }), 29242 prioritizePatterns ? blocksUI : patternsUI, 29243 showBlockDirectory && /* @__PURE__ */ (0, import_jsx_runtime185.jsx)( 29244 inserter_menu_extension_default.Slot, 29245 { 29246 fillProps: { 29247 onSelect: onSelectBlockType, 29248 onHover, 29249 filterValue, 29250 hasItems, 29251 rootClientId: destinationRootClientId 29252 }, 29253 children: (fills) => { 29254 if (fills.length) { 29255 return fills; 29256 } 29257 if (!hasItems) { 29258 return /* @__PURE__ */ (0, import_jsx_runtime185.jsx)(no_results_default, {}); 29259 } 29260 return null; 29261 } 29262 } 29263 ) 29264 ] }); 29265 } 29266 var search_results_default = InserterSearchResults; 29267 29268 // packages/block-editor/build-module/components/tabbed-sidebar/index.js 29269 var import_components55 = __toESM(require_components()); 29270 var import_element72 = __toESM(require_element()); 29271 var import_jsx_runtime186 = __toESM(require_jsx_runtime()); 29272 var { Tabs: Tabs2 } = unlock(import_components55.privateApis); 29273 function TabbedSidebar({ defaultTabId, onClose, onSelect, selectedTab, tabs, closeButtonLabel }, ref) { 29274 return /* @__PURE__ */ (0, import_jsx_runtime186.jsx)("div", { className: "block-editor-tabbed-sidebar", children: /* @__PURE__ */ (0, import_jsx_runtime186.jsxs)( 29275 Tabs2, 29276 { 29277 selectOnMove: false, 29278 defaultTabId, 29279 onSelect, 29280 selectedTabId: selectedTab, 29281 children: [ 29282 /* @__PURE__ */ (0, import_jsx_runtime186.jsxs)("div", { className: "block-editor-tabbed-sidebar__tablist-and-close-button", children: [ 29283 /* @__PURE__ */ (0, import_jsx_runtime186.jsx)( 29284 import_components55.Button, 29285 { 29286 className: "block-editor-tabbed-sidebar__close-button", 29287 icon: close_small_default, 29288 label: closeButtonLabel, 29289 onClick: () => onClose(), 29290 size: "compact" 29291 } 29292 ), 29293 /* @__PURE__ */ (0, import_jsx_runtime186.jsx)( 29294 Tabs2.TabList, 29295 { 29296 className: "block-editor-tabbed-sidebar__tablist", 29297 ref, 29298 children: tabs.map((tab) => /* @__PURE__ */ (0, import_jsx_runtime186.jsx)( 29299 Tabs2.Tab, 29300 { 29301 tabId: tab.name, 29302 className: "block-editor-tabbed-sidebar__tab", 29303 children: tab.title 29304 }, 29305 tab.name 29306 )) 29307 } 29308 ) 29309 ] }), 29310 tabs.map((tab) => /* @__PURE__ */ (0, import_jsx_runtime186.jsx)( 29311 Tabs2.TabPanel, 29312 { 29313 tabId: tab.name, 29314 focusable: false, 29315 className: "block-editor-tabbed-sidebar__tabpanel", 29316 ref: tab.panelRef, 29317 children: tab.panel 29318 }, 29319 tab.name 29320 )) 29321 ] 29322 } 29323 ) }); 29324 } 29325 var tabbed_sidebar_default = (0, import_element72.forwardRef)(TabbedSidebar); 29326 29327 // packages/block-editor/build-module/hooks/use-zoom-out.js 29328 var import_data56 = __toESM(require_data()); 29329 var import_element73 = __toESM(require_element()); 29330 function useZoomOut(enabled = true) { 29331 const { setZoomLevel: setZoomLevel2, resetZoomLevel: resetZoomLevel2 } = unlock( 29332 (0, import_data56.useDispatch)(store) 29333 ); 29334 const { isZoomedOut, isZoomOut: isZoomOut2 } = (0, import_data56.useSelect)((select3) => { 29335 const { isZoomOut: _isZoomOut } = unlock(select3(store)); 29336 return { 29337 isZoomedOut: _isZoomOut(), 29338 isZoomOut: _isZoomOut 29339 }; 29340 }, []); 29341 const controlZoomLevelRef = (0, import_element73.useRef)(false); 29342 const isEnabledRef = (0, import_element73.useRef)(enabled); 29343 (0, import_element73.useEffect)(() => { 29344 if (isZoomedOut !== isEnabledRef.current) { 29345 controlZoomLevelRef.current = false; 29346 } 29347 }, [isZoomedOut]); 29348 (0, import_element73.useEffect)(() => { 29349 isEnabledRef.current = enabled; 29350 if (enabled !== isZoomOut2()) { 29351 controlZoomLevelRef.current = true; 29352 if (enabled) { 29353 setZoomLevel2("auto-scaled"); 29354 } else { 29355 resetZoomLevel2(); 29356 } 29357 } 29358 return () => { 29359 if (controlZoomLevelRef.current && isZoomOut2()) { 29360 resetZoomLevel2(); 29361 } 29362 }; 29363 }, [enabled, isZoomOut2, resetZoomLevel2, setZoomLevel2]); 29364 } 29365 29366 // packages/block-editor/build-module/components/inserter/menu.js 29367 var import_jsx_runtime187 = __toESM(require_jsx_runtime()); 29368 var NOOP = () => { 29369 }; 29370 function InserterMenu({ 29371 rootClientId, 29372 clientId, 29373 isAppender, 29374 __experimentalInsertionIndex, 29375 onSelect, 29376 showInserterHelpPanel, 29377 showMostUsedBlocks, 29378 __experimentalFilterValue = "", 29379 shouldFocusBlock = true, 29380 onPatternCategorySelection, 29381 onClose, 29382 __experimentalInitialTab, 29383 __experimentalInitialCategory 29384 }, ref) { 29385 const { isZoomOutMode, hasSectionRootClientId } = (0, import_data57.useSelect)((select3) => { 29386 const { isZoomOut: isZoomOut2, getSectionRootClientId: getSectionRootClientId2 } = unlock( 29387 select3(store) 29388 ); 29389 return { 29390 isZoomOutMode: isZoomOut2(), 29391 hasSectionRootClientId: !!getSectionRootClientId2() 29392 }; 29393 }, []); 29394 const [filterValue, setFilterValue, delayedFilterValue] = (0, import_compose43.useDebouncedInput)(__experimentalFilterValue); 29395 const [hoveredItem, setHoveredItem] = (0, import_element74.useState)(null); 29396 const [selectedPatternCategory, setSelectedPatternCategory] = (0, import_element74.useState)( 29397 __experimentalInitialCategory 29398 ); 29399 const [patternFilter, setPatternFilter] = (0, import_element74.useState)("all"); 29400 const [selectedMediaCategory, setSelectedMediaCategory] = (0, import_element74.useState)(null); 29401 const isLargeViewport = (0, import_compose43.useViewportMatch)("large"); 29402 function getInitialTab() { 29403 if (__experimentalInitialTab) { 29404 return __experimentalInitialTab; 29405 } 29406 if (isZoomOutMode) { 29407 return "patterns"; 29408 } 29409 return "blocks"; 29410 } 29411 const [selectedTab, setSelectedTab] = (0, import_element74.useState)(getInitialTab()); 29412 const shouldUseZoomOut = hasSectionRootClientId && (selectedTab === "patterns" || selectedTab === "media"); 29413 useZoomOut(shouldUseZoomOut && isLargeViewport); 29414 const [destinationRootClientId, onInsertBlocks, onToggleInsertionPoint] = use_insertion_point_default({ 29415 rootClientId, 29416 clientId, 29417 isAppender, 29418 insertionIndex: __experimentalInsertionIndex, 29419 shouldFocusBlock 29420 }); 29421 const blockTypesTabRef = (0, import_element74.useRef)(); 29422 const onInsert = (0, import_element74.useCallback)( 29423 (blocks2, meta, shouldForceFocusBlock, _rootClientId) => { 29424 onInsertBlocks( 29425 blocks2, 29426 meta, 29427 shouldForceFocusBlock, 29428 _rootClientId 29429 ); 29430 onSelect(blocks2); 29431 window.requestAnimationFrame(() => { 29432 if (!shouldFocusBlock && !blockTypesTabRef.current?.contains( 29433 ref.current.ownerDocument.activeElement 29434 )) { 29435 blockTypesTabRef.current?.querySelector("button").focus(); 29436 } 29437 }); 29438 }, 29439 [onInsertBlocks, onSelect, shouldFocusBlock] 29440 ); 29441 const onInsertPattern = (0, import_element74.useCallback)( 29442 (blocks2, patternName, ...args) => { 29443 onToggleInsertionPoint(false); 29444 onInsertBlocks(blocks2, { patternName }, ...args); 29445 onSelect(); 29446 }, 29447 [onInsertBlocks, onSelect] 29448 ); 29449 const onHover = (0, import_element74.useCallback)( 29450 (item) => { 29451 onToggleInsertionPoint(item); 29452 setHoveredItem(item); 29453 }, 29454 [onToggleInsertionPoint, setHoveredItem] 29455 ); 29456 const onClickPatternCategory = (0, import_element74.useCallback)( 29457 (patternCategory, filter) => { 29458 setSelectedPatternCategory(patternCategory); 29459 setPatternFilter(filter); 29460 onPatternCategorySelection?.(); 29461 }, 29462 [setSelectedPatternCategory, onPatternCategorySelection] 29463 ); 29464 const showPatternPanel = selectedTab === "patterns" && !delayedFilterValue && !!selectedPatternCategory; 29465 const showMediaPanel = selectedTab === "media" && !!selectedMediaCategory; 29466 const inserterSearch = (0, import_element74.useMemo)(() => { 29467 if (selectedTab === "media") { 29468 return null; 29469 } 29470 return /* @__PURE__ */ (0, import_jsx_runtime187.jsxs)(import_jsx_runtime187.Fragment, { children: [ 29471 /* @__PURE__ */ (0, import_jsx_runtime187.jsx)( 29472 import_components56.SearchControl, 29473 { 29474 className: "block-editor-inserter__search", 29475 onChange: (value) => { 29476 if (hoveredItem) { 29477 setHoveredItem(null); 29478 } 29479 setFilterValue(value); 29480 }, 29481 value: filterValue, 29482 label: (0, import_i18n57.__)("Search"), 29483 placeholder: (0, import_i18n57.__)("Search") 29484 } 29485 ), 29486 !!delayedFilterValue && /* @__PURE__ */ (0, import_jsx_runtime187.jsx)( 29487 search_results_default, 29488 { 29489 filterValue: delayedFilterValue, 29490 onSelect, 29491 onHover, 29492 rootClientId, 29493 clientId, 29494 isAppender, 29495 __experimentalInsertionIndex, 29496 showBlockDirectory: true, 29497 shouldFocusBlock, 29498 prioritizePatterns: selectedTab === "patterns" 29499 } 29500 ) 29501 ] }); 29502 }, [ 29503 selectedTab, 29504 hoveredItem, 29505 setHoveredItem, 29506 setFilterValue, 29507 filterValue, 29508 delayedFilterValue, 29509 onSelect, 29510 onHover, 29511 shouldFocusBlock, 29512 clientId, 29513 rootClientId, 29514 __experimentalInsertionIndex, 29515 isAppender 29516 ]); 29517 const blocksTab = (0, import_element74.useMemo)(() => { 29518 return /* @__PURE__ */ (0, import_jsx_runtime187.jsxs)(import_jsx_runtime187.Fragment, { children: [ 29519 /* @__PURE__ */ (0, import_jsx_runtime187.jsx)("div", { className: "block-editor-inserter__block-list", children: /* @__PURE__ */ (0, import_jsx_runtime187.jsx)( 29520 block_types_tab_default, 29521 { 29522 ref: blockTypesTabRef, 29523 rootClientId: destinationRootClientId, 29524 onInsert, 29525 onHover, 29526 showMostUsedBlocks 29527 } 29528 ) }), 29529 showInserterHelpPanel && /* @__PURE__ */ (0, import_jsx_runtime187.jsxs)("div", { className: "block-editor-inserter__tips", children: [ 29530 /* @__PURE__ */ (0, import_jsx_runtime187.jsx)(import_components56.VisuallyHidden, { as: "h2", children: (0, import_i18n57.__)("A tip for using the block editor") }), 29531 /* @__PURE__ */ (0, import_jsx_runtime187.jsx)(tips_default, {}) 29532 ] }) 29533 ] }); 29534 }, [ 29535 destinationRootClientId, 29536 onInsert, 29537 onHover, 29538 showMostUsedBlocks, 29539 showInserterHelpPanel 29540 ]); 29541 const patternsTab = (0, import_element74.useMemo)(() => { 29542 return /* @__PURE__ */ (0, import_jsx_runtime187.jsx)( 29543 block_patterns_tab_default, 29544 { 29545 rootClientId: destinationRootClientId, 29546 onInsert: onInsertPattern, 29547 onSelectCategory: onClickPatternCategory, 29548 selectedCategory: selectedPatternCategory, 29549 children: showPatternPanel && /* @__PURE__ */ (0, import_jsx_runtime187.jsx)( 29550 PatternCategoryPreviews, 29551 { 29552 rootClientId: destinationRootClientId, 29553 onInsert: onInsertPattern, 29554 category: selectedPatternCategory, 29555 patternFilter, 29556 showTitlesAsTooltip: true 29557 } 29558 ) 29559 } 29560 ); 29561 }, [ 29562 destinationRootClientId, 29563 onInsertPattern, 29564 onClickPatternCategory, 29565 patternFilter, 29566 selectedPatternCategory, 29567 showPatternPanel 29568 ]); 29569 const mediaTab = (0, import_element74.useMemo)(() => { 29570 return /* @__PURE__ */ (0, import_jsx_runtime187.jsx)( 29571 media_tab_default, 29572 { 29573 rootClientId: destinationRootClientId, 29574 selectedCategory: selectedMediaCategory, 29575 onSelectCategory: setSelectedMediaCategory, 29576 onInsert, 29577 children: showMediaPanel && /* @__PURE__ */ (0, import_jsx_runtime187.jsx)( 29578 MediaCategoryPanel, 29579 { 29580 rootClientId: destinationRootClientId, 29581 onInsert, 29582 category: selectedMediaCategory 29583 } 29584 ) 29585 } 29586 ); 29587 }, [ 29588 destinationRootClientId, 29589 onInsert, 29590 selectedMediaCategory, 29591 setSelectedMediaCategory, 29592 showMediaPanel 29593 ]); 29594 const handleSetSelectedTab = (value) => { 29595 if (value !== "patterns") { 29596 setSelectedPatternCategory(null); 29597 } 29598 setSelectedTab(value); 29599 }; 29600 const tabsRef = (0, import_element74.useRef)(); 29601 (0, import_element74.useLayoutEffect)(() => { 29602 if (tabsRef.current) { 29603 window.requestAnimationFrame(() => { 29604 tabsRef.current.querySelector('[role="tab"][aria-selected="true"]')?.focus(); 29605 }); 29606 } 29607 }, []); 29608 return /* @__PURE__ */ (0, import_jsx_runtime187.jsxs)( 29609 "div", 29610 { 29611 className: clsx_default("block-editor-inserter__menu", { 29612 "show-panel": showPatternPanel || showMediaPanel, 29613 "is-zoom-out": isZoomOutMode 29614 }), 29615 ref, 29616 children: [ 29617 /* @__PURE__ */ (0, import_jsx_runtime187.jsx)("div", { className: "block-editor-inserter__main-area", children: /* @__PURE__ */ (0, import_jsx_runtime187.jsx)( 29618 tabbed_sidebar_default, 29619 { 29620 ref: tabsRef, 29621 onSelect: handleSetSelectedTab, 29622 onClose, 29623 selectedTab, 29624 closeButtonLabel: (0, import_i18n57.__)("Close Block Inserter"), 29625 tabs: [ 29626 { 29627 name: "blocks", 29628 title: (0, import_i18n57.__)("Blocks"), 29629 panel: /* @__PURE__ */ (0, import_jsx_runtime187.jsxs)(import_jsx_runtime187.Fragment, { children: [ 29630 inserterSearch, 29631 selectedTab === "blocks" && !delayedFilterValue && blocksTab 29632 ] }) 29633 }, 29634 { 29635 name: "patterns", 29636 title: (0, import_i18n57.__)("Patterns"), 29637 panel: /* @__PURE__ */ (0, import_jsx_runtime187.jsxs)(import_jsx_runtime187.Fragment, { children: [ 29638 inserterSearch, 29639 selectedTab === "patterns" && !delayedFilterValue && patternsTab 29640 ] }) 29641 }, 29642 { 29643 name: "media", 29644 title: (0, import_i18n57.__)("Media"), 29645 panel: /* @__PURE__ */ (0, import_jsx_runtime187.jsxs)(import_jsx_runtime187.Fragment, { children: [ 29646 inserterSearch, 29647 mediaTab 29648 ] }) 29649 } 29650 ] 29651 } 29652 ) }), 29653 showInserterHelpPanel && hoveredItem && /* @__PURE__ */ (0, import_jsx_runtime187.jsx)( 29654 import_components56.Popover, 29655 { 29656 className: "block-editor-inserter__preview-container__popover", 29657 placement: "right-start", 29658 offset: 16, 29659 focusOnMount: false, 29660 animate: false, 29661 children: /* @__PURE__ */ (0, import_jsx_runtime187.jsx)(preview_panel_default, { item: hoveredItem }) 29662 } 29663 ) 29664 ] 29665 } 29666 ); 29667 } 29668 var PrivateInserterMenu = (0, import_element74.forwardRef)(InserterMenu); 29669 function PublicInserterMenu(props, ref) { 29670 return /* @__PURE__ */ (0, import_jsx_runtime187.jsx)( 29671 PrivateInserterMenu, 29672 { 29673 ...props, 29674 onPatternCategorySelection: NOOP, 29675 ref 29676 } 29677 ); 29678 } 29679 var menu_default = (0, import_element74.forwardRef)(PublicInserterMenu); 29680 29681 // packages/block-editor/build-module/components/inserter/quick-inserter.js 29682 var import_element75 = __toESM(require_element()); 29683 var import_i18n58 = __toESM(require_i18n()); 29684 var import_components57 = __toESM(require_components()); 29685 var import_data58 = __toESM(require_data()); 29686 var import_jsx_runtime188 = __toESM(require_jsx_runtime()); 29687 var SEARCH_THRESHOLD = 6; 29688 var SHOWN_BLOCK_TYPES2 = 6; 29689 var SHOWN_BLOCK_PATTERNS = 2; 29690 function QuickInserter({ 29691 onSelect, 29692 rootClientId, 29693 clientId, 29694 isAppender, 29695 selectBlockOnInsert, 29696 hasSearch = true 29697 }) { 29698 const [filterValue, setFilterValue] = (0, import_element75.useState)(""); 29699 const [destinationRootClientId, onInsertBlocks] = use_insertion_point_default({ 29700 onSelect, 29701 rootClientId, 29702 clientId, 29703 isAppender, 29704 selectBlockOnInsert 29705 }); 29706 const [blockTypes] = use_block_types_state_default( 29707 destinationRootClientId, 29708 onInsertBlocks, 29709 true 29710 ); 29711 const { setInserterIsOpened, insertionIndex } = (0, import_data58.useSelect)( 29712 (select3) => { 29713 const { getSettings: getSettings8, getBlockIndex: getBlockIndex2, getBlockCount: getBlockCount2 } = select3(store); 29714 const settings2 = getSettings8(); 29715 const index = getBlockIndex2(clientId); 29716 const blockCount = getBlockCount2(); 29717 return { 29718 setInserterIsOpened: settings2.__experimentalSetIsInserterOpened, 29719 insertionIndex: index === -1 ? blockCount : index 29720 }; 29721 }, 29722 [clientId] 29723 ); 29724 const showSearch = hasSearch && blockTypes.length > SEARCH_THRESHOLD; 29725 (0, import_element75.useEffect)(() => { 29726 if (setInserterIsOpened) { 29727 setInserterIsOpened(false); 29728 } 29729 }, [setInserterIsOpened]); 29730 const onBrowseAll = () => { 29731 setInserterIsOpened({ 29732 filterValue, 29733 onSelect, 29734 rootClientId, 29735 insertionIndex 29736 }); 29737 }; 29738 return /* @__PURE__ */ (0, import_jsx_runtime188.jsxs)( 29739 "div", 29740 { 29741 className: clsx_default("block-editor-inserter__quick-inserter", { 29742 "has-search": showSearch, 29743 "has-expand": setInserterIsOpened 29744 }), 29745 children: [ 29746 showSearch && /* @__PURE__ */ (0, import_jsx_runtime188.jsx)( 29747 import_components57.SearchControl, 29748 { 29749 className: "block-editor-inserter__search", 29750 value: filterValue, 29751 onChange: (value) => { 29752 setFilterValue(value); 29753 }, 29754 label: (0, import_i18n58.__)("Search"), 29755 placeholder: (0, import_i18n58.__)("Search") 29756 } 29757 ), 29758 /* @__PURE__ */ (0, import_jsx_runtime188.jsx)("div", { className: "block-editor-inserter__quick-inserter-results", children: /* @__PURE__ */ (0, import_jsx_runtime188.jsx)( 29759 search_results_default, 29760 { 29761 filterValue, 29762 onSelect, 29763 rootClientId, 29764 clientId, 29765 isAppender, 29766 maxBlockPatterns: !!filterValue ? SHOWN_BLOCK_PATTERNS : 0, 29767 maxBlockTypes: SHOWN_BLOCK_TYPES2, 29768 isDraggable: false, 29769 selectBlockOnInsert, 29770 isQuick: true 29771 } 29772 ) }), 29773 setInserterIsOpened && /* @__PURE__ */ (0, import_jsx_runtime188.jsx)( 29774 import_components57.Button, 29775 { 29776 __next40pxDefaultSize: true, 29777 className: "block-editor-inserter__quick-inserter-expand", 29778 onClick: onBrowseAll, 29779 "aria-label": (0, import_i18n58.__)( 29780 "Browse all. This will open the main inserter panel in the editor toolbar." 29781 ), 29782 children: (0, import_i18n58.__)("Browse all") 29783 } 29784 ) 29785 ] 29786 } 29787 ); 29788 } 29789 29790 // packages/block-editor/build-module/components/inserter/index.js 29791 var import_jsx_runtime189 = __toESM(require_jsx_runtime()); 29792 var defaultRenderToggle = ({ 29793 onToggle, 29794 disabled, 29795 isOpen, 29796 blockTitle, 29797 hasSingleBlockType, 29798 toggleProps = {} 29799 }) => { 29800 const { 29801 as: Wrapper = import_components58.Button, 29802 label: labelProp, 29803 onClick, 29804 ...rest 29805 } = toggleProps; 29806 let label = labelProp; 29807 if (!label && hasSingleBlockType) { 29808 label = (0, import_i18n59.sprintf)( 29809 // translators: %s: the name of the block when there is only one 29810 (0, import_i18n59._x)("Add %s", "directly add the only allowed block"), 29811 blockTitle 29812 ); 29813 } else if (!label) { 29814 label = (0, import_i18n59._x)("Add block", "Generic label for block inserter button"); 29815 } 29816 function handleClick(event) { 29817 if (onToggle) { 29818 onToggle(event); 29819 } 29820 if (onClick) { 29821 onClick(event); 29822 } 29823 } 29824 return /* @__PURE__ */ (0, import_jsx_runtime189.jsx)( 29825 Wrapper, 29826 { 29827 __next40pxDefaultSize: toggleProps.as ? void 0 : true, 29828 icon: plus_default, 29829 label, 29830 tooltipPosition: "bottom", 29831 onClick: handleClick, 29832 className: "block-editor-inserter__toggle", 29833 "aria-haspopup": !hasSingleBlockType ? "true" : false, 29834 "aria-expanded": !hasSingleBlockType ? isOpen : false, 29835 disabled, 29836 ...rest 29837 } 29838 ); 29839 }; 29840 var Inserter = class extends import_element76.Component { 29841 constructor() { 29842 super(...arguments); 29843 this.onToggle = this.onToggle.bind(this); 29844 this.renderToggle = this.renderToggle.bind(this); 29845 this.renderContent = this.renderContent.bind(this); 29846 } 29847 onToggle(isOpen) { 29848 const { onToggle } = this.props; 29849 if (onToggle) { 29850 onToggle(isOpen); 29851 } 29852 } 29853 /** 29854 * Render callback to display Dropdown toggle element. 29855 * 29856 * @param {Object} options 29857 * @param {Function} options.onToggle Callback to invoke when toggle is 29858 * pressed. 29859 * @param {boolean} options.isOpen Whether dropdown is currently open. 29860 * 29861 * @return {Element} Dropdown toggle element. 29862 */ 29863 renderToggle({ onToggle, isOpen }) { 29864 const { 29865 disabled, 29866 blockTitle, 29867 hasSingleBlockType, 29868 directInsertBlock, 29869 toggleProps, 29870 hasItems, 29871 renderToggle: renderToggle3 = defaultRenderToggle 29872 } = this.props; 29873 return renderToggle3({ 29874 onToggle, 29875 isOpen, 29876 disabled: disabled || !hasItems, 29877 blockTitle, 29878 hasSingleBlockType, 29879 directInsertBlock, 29880 toggleProps 29881 }); 29882 } 29883 /** 29884 * Render callback to display Dropdown content element. 29885 * 29886 * @param {Object} options 29887 * @param {Function} options.onClose Callback to invoke when dropdown is 29888 * closed. 29889 * 29890 * @return {Element} Dropdown content element. 29891 */ 29892 renderContent({ onClose }) { 29893 const { 29894 rootClientId, 29895 clientId, 29896 isAppender, 29897 showInserterHelpPanel, 29898 // This prop is experimental to give some time for the quick inserter to mature 29899 // Feel free to make them stable after a few releases. 29900 __experimentalIsQuick: isQuick, 29901 onSelectOrClose, 29902 selectBlockOnInsert 29903 } = this.props; 29904 if (isQuick) { 29905 return /* @__PURE__ */ (0, import_jsx_runtime189.jsx)( 29906 QuickInserter, 29907 { 29908 onSelect: (blocks2) => { 29909 const firstBlock = Array.isArray(blocks2) && blocks2?.length ? blocks2[0] : blocks2; 29910 if (onSelectOrClose && typeof onSelectOrClose === "function") { 29911 onSelectOrClose(firstBlock); 29912 } 29913 onClose(); 29914 }, 29915 rootClientId, 29916 clientId, 29917 isAppender, 29918 selectBlockOnInsert 29919 } 29920 ); 29921 } 29922 return /* @__PURE__ */ (0, import_jsx_runtime189.jsx)( 29923 menu_default, 29924 { 29925 onSelect: () => { 29926 onClose(); 29927 }, 29928 rootClientId, 29929 clientId, 29930 isAppender, 29931 showInserterHelpPanel 29932 } 29933 ); 29934 } 29935 render() { 29936 const { 29937 position, 29938 hasSingleBlockType, 29939 directInsertBlock, 29940 insertOnlyAllowedBlock, 29941 __experimentalIsQuick: isQuick, 29942 onSelectOrClose 29943 } = this.props; 29944 if (hasSingleBlockType || directInsertBlock) { 29945 return this.renderToggle({ onToggle: insertOnlyAllowedBlock }); 29946 } 29947 return /* @__PURE__ */ (0, import_jsx_runtime189.jsx)( 29948 import_components58.Dropdown, 29949 { 29950 className: "block-editor-inserter", 29951 contentClassName: clsx_default("block-editor-inserter__popover", { 29952 "is-quick": isQuick 29953 }), 29954 popoverProps: { position, shift: true }, 29955 onToggle: this.onToggle, 29956 expandOnMobile: true, 29957 headerTitle: (0, import_i18n59.__)("Add a block"), 29958 renderToggle: this.renderToggle, 29959 renderContent: this.renderContent, 29960 onClose: onSelectOrClose 29961 } 29962 ); 29963 } 29964 }; 29965 var inserter_default = (0, import_compose44.compose)([ 29966 (0, import_data59.withSelect)( 29967 (select3, { clientId, rootClientId, shouldDirectInsert = true }) => { 29968 const { 29969 getBlockRootClientId: getBlockRootClientId2, 29970 hasInserterItems: hasInserterItems2, 29971 getAllowedBlocks: getAllowedBlocks2, 29972 getDirectInsertBlock: getDirectInsertBlock2 29973 } = select3(store); 29974 const { getBlockVariations: getBlockVariations2 } = select3(import_blocks35.store); 29975 rootClientId = rootClientId || getBlockRootClientId2(clientId) || void 0; 29976 const allowedBlocks = getAllowedBlocks2(rootClientId); 29977 const directInsertBlock = shouldDirectInsert && getDirectInsertBlock2(rootClientId); 29978 const hasSingleBlockType = allowedBlocks?.length === 1 && getBlockVariations2(allowedBlocks[0].name, "inserter")?.length === 0; 29979 let allowedBlockType = false; 29980 if (hasSingleBlockType) { 29981 allowedBlockType = allowedBlocks[0]; 29982 } 29983 return { 29984 hasItems: hasInserterItems2(rootClientId), 29985 hasSingleBlockType, 29986 blockTitle: allowedBlockType ? allowedBlockType.title : "", 29987 allowedBlockType, 29988 directInsertBlock, 29989 rootClientId 29990 }; 29991 } 29992 ), 29993 (0, import_data59.withDispatch)((dispatch, ownProps, { select: select3 }) => { 29994 return { 29995 insertOnlyAllowedBlock() { 29996 const { 29997 rootClientId, 29998 clientId, 29999 isAppender, 30000 hasSingleBlockType, 30001 allowedBlockType, 30002 directInsertBlock, 30003 onSelectOrClose, 30004 selectBlockOnInsert 30005 } = ownProps; 30006 if (!hasSingleBlockType && !directInsertBlock) { 30007 return; 30008 } 30009 function getAdjacentBlockAttributes(attributesToCopy) { 30010 const { getBlock: getBlock2, getPreviousBlockClientId: getPreviousBlockClientId2 } = select3(store); 30011 if (!attributesToCopy || !clientId && !rootClientId) { 30012 return {}; 30013 } 30014 const result = {}; 30015 let adjacentAttributes = {}; 30016 if (!clientId) { 30017 const parentBlock = getBlock2(rootClientId); 30018 if (parentBlock?.innerBlocks?.length) { 30019 const lastInnerBlock = parentBlock.innerBlocks[parentBlock.innerBlocks.length - 1]; 30020 if (directInsertBlock && directInsertBlock?.name === lastInnerBlock.name) { 30021 adjacentAttributes = lastInnerBlock.attributes; 30022 } 30023 } 30024 } else { 30025 const currentBlock = getBlock2(clientId); 30026 const previousBlock = getBlock2( 30027 getPreviousBlockClientId2(clientId) 30028 ); 30029 if (currentBlock?.name === previousBlock?.name) { 30030 adjacentAttributes = previousBlock?.attributes || {}; 30031 } 30032 } 30033 attributesToCopy.forEach((attribute) => { 30034 if (adjacentAttributes.hasOwnProperty(attribute)) { 30035 result[attribute] = adjacentAttributes[attribute]; 30036 } 30037 }); 30038 return result; 30039 } 30040 function getInsertionIndex() { 30041 const { 30042 getBlockIndex: getBlockIndex2, 30043 getBlockSelectionEnd: getBlockSelectionEnd2, 30044 getBlockOrder: getBlockOrder2, 30045 getBlockRootClientId: getBlockRootClientId2 30046 } = select3(store); 30047 if (clientId) { 30048 return getBlockIndex2(clientId); 30049 } 30050 const end = getBlockSelectionEnd2(); 30051 if (!isAppender && end && getBlockRootClientId2(end) === rootClientId) { 30052 return getBlockIndex2(end) + 1; 30053 } 30054 return getBlockOrder2(rootClientId).length; 30055 } 30056 const { insertBlock: insertBlock2 } = dispatch(store); 30057 let blockToInsert; 30058 if (directInsertBlock) { 30059 const newAttributes = getAdjacentBlockAttributes( 30060 directInsertBlock.attributesToCopy 30061 ); 30062 blockToInsert = (0, import_blocks35.createBlock)(directInsertBlock.name, { 30063 ...directInsertBlock.attributes || {}, 30064 ...newAttributes 30065 }); 30066 } else { 30067 blockToInsert = (0, import_blocks35.createBlock)(allowedBlockType.name); 30068 } 30069 insertBlock2( 30070 blockToInsert, 30071 getInsertionIndex(), 30072 rootClientId, 30073 selectBlockOnInsert 30074 ); 30075 if (onSelectOrClose) { 30076 onSelectOrClose(blockToInsert); 30077 } 30078 const message2 = (0, import_i18n59.sprintf)( 30079 // translators: %s: the name of the block that has been added 30080 (0, import_i18n59.__)("%s block added"), 30081 allowedBlockType.title 30082 ); 30083 (0, import_a11y10.speak)(message2); 30084 } 30085 }; 30086 }), 30087 // The global inserter should always be visible, we are using ( ! isAppender && ! rootClientId && ! clientId ) as 30088 // a way to detect the global Inserter. 30089 (0, import_compose44.ifCondition)( 30090 ({ hasItems, isAppender, rootClientId, clientId }) => hasItems || !isAppender && !rootClientId && !clientId 30091 ) 30092 ])(Inserter); 30093 30094 // packages/block-editor/build-module/components/default-block-appender/index.js 30095 var import_jsx_runtime190 = __toESM(require_jsx_runtime()); 30096 var ZWNBSP = "\uFEFF"; 30097 function DefaultBlockAppender({ rootClientId }) { 30098 const { showPrompt, isLocked, placeholder, isManualGrid } = (0, import_data60.useSelect)( 30099 (select3) => { 30100 const { 30101 getBlockCount: getBlockCount2, 30102 getSettings: getSettings8, 30103 getTemplateLock: getTemplateLock2, 30104 getBlockAttributes: getBlockAttributes3 30105 } = select3(store); 30106 const isEmpty4 = !getBlockCount2(rootClientId); 30107 const { bodyPlaceholder } = getSettings8(); 30108 return { 30109 showPrompt: isEmpty4, 30110 isLocked: !!getTemplateLock2(rootClientId), 30111 placeholder: bodyPlaceholder, 30112 isManualGrid: getBlockAttributes3(rootClientId)?.layout?.isManualPlacement 30113 }; 30114 }, 30115 [rootClientId] 30116 ); 30117 const { insertDefaultBlock: insertDefaultBlock2, startTyping: startTyping2 } = (0, import_data60.useDispatch)(store); 30118 if (isLocked || isManualGrid) { 30119 return null; 30120 } 30121 const value = (0, import_html_entities2.decodeEntities)(placeholder) || (0, import_i18n60.__)("Type / to choose a block"); 30122 const onAppend = () => { 30123 insertDefaultBlock2(void 0, rootClientId); 30124 startTyping2(); 30125 }; 30126 return /* @__PURE__ */ (0, import_jsx_runtime190.jsxs)( 30127 "div", 30128 { 30129 "data-root-client-id": rootClientId || "", 30130 className: clsx_default("block-editor-default-block-appender", { 30131 "has-visible-prompt": showPrompt 30132 }), 30133 children: [ 30134 /* @__PURE__ */ (0, import_jsx_runtime190.jsx)( 30135 "p", 30136 { 30137 tabIndex: "0", 30138 role: "button", 30139 "aria-label": (0, import_i18n60.__)("Add default block"), 30140 className: "block-editor-default-block-appender__content", 30141 onKeyDown: (event) => { 30142 if (import_keycodes7.ENTER === event.keyCode || import_keycodes7.SPACE === event.keyCode) { 30143 onAppend(); 30144 } 30145 }, 30146 onClick: () => onAppend(), 30147 onFocus: () => { 30148 if (showPrompt) { 30149 onAppend(); 30150 } 30151 }, 30152 children: showPrompt ? value : ZWNBSP 30153 } 30154 ), 30155 /* @__PURE__ */ (0, import_jsx_runtime190.jsx)( 30156 inserter_default, 30157 { 30158 rootClientId, 30159 position: "bottom right", 30160 isAppender: true, 30161 __experimentalIsQuick: true 30162 } 30163 ) 30164 ] 30165 } 30166 ); 30167 } 30168 30169 // packages/block-editor/build-module/components/button-block-appender/index.js 30170 var import_components59 = __toESM(require_components()); 30171 var import_element77 = __toESM(require_element()); 30172 var import_i18n61 = __toESM(require_i18n()); 30173 var import_deprecated8 = __toESM(require_deprecated()); 30174 var import_jsx_runtime191 = __toESM(require_jsx_runtime()); 30175 function ButtonBlockAppender({ rootClientId, className, onFocus, tabIndex, onSelect }, ref) { 30176 return /* @__PURE__ */ (0, import_jsx_runtime191.jsx)( 30177 inserter_default, 30178 { 30179 position: "bottom center", 30180 rootClientId, 30181 __experimentalIsQuick: true, 30182 onSelectOrClose: (...args) => { 30183 if (onSelect && typeof onSelect === "function") { 30184 onSelect(...args); 30185 } 30186 }, 30187 renderToggle: ({ 30188 onToggle, 30189 disabled, 30190 isOpen, 30191 blockTitle, 30192 hasSingleBlockType 30193 }) => { 30194 const isToggleButton = !hasSingleBlockType; 30195 const label = hasSingleBlockType ? (0, import_i18n61.sprintf)( 30196 // translators: %s: the name of the block when there is only one 30197 (0, import_i18n61._x)( 30198 "Add %s", 30199 "directly add the only allowed block" 30200 ), 30201 blockTitle 30202 ) : (0, import_i18n61._x)( 30203 "Add block", 30204 "Generic label for block inserter button" 30205 ); 30206 return /* @__PURE__ */ (0, import_jsx_runtime191.jsx)( 30207 import_components59.Button, 30208 { 30209 __next40pxDefaultSize: true, 30210 ref, 30211 onFocus, 30212 tabIndex, 30213 className: clsx_default( 30214 className, 30215 "block-editor-button-block-appender" 30216 ), 30217 onClick: onToggle, 30218 "aria-haspopup": isToggleButton ? "true" : void 0, 30219 "aria-expanded": isToggleButton ? isOpen : void 0, 30220 disabled, 30221 label, 30222 showTooltip: true, 30223 children: /* @__PURE__ */ (0, import_jsx_runtime191.jsx)(icon_default, { icon: plus_default }) 30224 } 30225 ); 30226 }, 30227 isAppender: true 30228 } 30229 ); 30230 } 30231 var ButtonBlockerAppender = (0, import_element77.forwardRef)((props, ref) => { 30232 (0, import_deprecated8.default)(`wp.blockEditor.ButtonBlockerAppender`, { 30233 alternative: "wp.blockEditor.ButtonBlockAppender", 30234 since: "5.9" 30235 }); 30236 return ButtonBlockAppender(props, ref); 30237 }); 30238 var button_block_appender_default = (0, import_element77.forwardRef)(ButtonBlockAppender); 30239 30240 // packages/block-editor/build-module/components/block-list-appender/index.js 30241 var import_jsx_runtime192 = __toESM(require_jsx_runtime()); 30242 function DefaultAppender({ rootClientId }) { 30243 const canInsertDefaultBlock = (0, import_data61.useSelect)( 30244 (select3) => select3(store).canInsertBlockType( 30245 (0, import_blocks36.getDefaultBlockName)(), 30246 rootClientId 30247 ) 30248 ); 30249 if (canInsertDefaultBlock) { 30250 return /* @__PURE__ */ (0, import_jsx_runtime192.jsx)(DefaultBlockAppender, { rootClientId }); 30251 } 30252 return /* @__PURE__ */ (0, import_jsx_runtime192.jsx)( 30253 button_block_appender_default, 30254 { 30255 rootClientId, 30256 className: "block-list-appender__toggle" 30257 } 30258 ); 30259 } 30260 function BlockListAppender({ 30261 rootClientId, 30262 CustomAppender, 30263 className, 30264 tagName: TagName = "div" 30265 }) { 30266 const isDragOver = (0, import_data61.useSelect)( 30267 (select3) => { 30268 const { 30269 getBlockInsertionPoint: getBlockInsertionPoint2, 30270 isBlockInsertionPointVisible: isBlockInsertionPointVisible2, 30271 getBlockCount: getBlockCount2 30272 } = select3(store); 30273 const insertionPoint2 = getBlockInsertionPoint2(); 30274 return isBlockInsertionPointVisible2() && rootClientId === insertionPoint2?.rootClientId && getBlockCount2(rootClientId) === 0; 30275 }, 30276 [rootClientId] 30277 ); 30278 return /* @__PURE__ */ (0, import_jsx_runtime192.jsx)( 30279 TagName, 30280 { 30281 tabIndex: -1, 30282 className: clsx_default("block-list-appender wp-block", className, { 30283 "is-drag-over": isDragOver 30284 }), 30285 contentEditable: false, 30286 "data-block": true, 30287 children: CustomAppender ? /* @__PURE__ */ (0, import_jsx_runtime192.jsx)(CustomAppender, {}) : /* @__PURE__ */ (0, import_jsx_runtime192.jsx)(DefaultAppender, { rootClientId }) 30288 } 30289 ); 30290 } 30291 30292 // packages/block-editor/build-module/components/block-list/use-in-between-inserter.js 30293 var import_compose49 = __toESM(require_compose()); 30294 var import_data65 = __toESM(require_data()); 30295 var import_element82 = __toESM(require_element()); 30296 var import_i18n63 = __toESM(require_i18n()); 30297 30298 // packages/block-editor/build-module/components/block-tools/insertion-point.js 30299 var import_data64 = __toESM(require_data()); 30300 var import_element81 = __toESM(require_element()); 30301 var import_components63 = __toESM(require_components()); 30302 var import_compose48 = __toESM(require_compose()); 30303 30304 // packages/block-editor/build-module/components/block-popover/inbetween.js 30305 var import_data62 = __toESM(require_data()); 30306 var import_element78 = __toESM(require_element()); 30307 var import_components60 = __toESM(require_components()); 30308 var import_i18n62 = __toESM(require_i18n()); 30309 30310 // packages/block-editor/build-module/components/block-popover/use-popover-scroll.js 30311 var import_compose45 = __toESM(require_compose()); 30312 var import_dom20 = __toESM(require_dom()); 30313 var scrollContainerCache = /* @__PURE__ */ new WeakMap(); 30314 function usePopoverScroll(contentRef) { 30315 const effect = (0, import_compose45.useRefEffect)( 30316 (node) => { 30317 function onWheel(event) { 30318 const { deltaX, deltaY, target } = event; 30319 const contentEl = contentRef.current; 30320 let scrollContainer = scrollContainerCache.get(contentEl); 30321 if (!scrollContainer) { 30322 scrollContainer = (0, import_dom20.getScrollContainer)(contentEl); 30323 scrollContainerCache.set(contentEl, scrollContainer); 30324 } 30325 const eventScrollContainer = (0, import_dom20.getScrollContainer)(target); 30326 if (!node.contains(eventScrollContainer)) { 30327 scrollContainer.scrollBy(deltaX, deltaY); 30328 } 30329 } 30330 const options = { passive: true }; 30331 node.addEventListener("wheel", onWheel, options); 30332 return () => { 30333 node.removeEventListener("wheel", onWheel, options); 30334 }; 30335 }, 30336 [contentRef] 30337 ); 30338 return contentRef ? effect : null; 30339 } 30340 var use_popover_scroll_default = usePopoverScroll; 30341 30342 // packages/block-editor/build-module/components/block-popover/inbetween.js 30343 var import_jsx_runtime193 = __toESM(require_jsx_runtime()); 30344 var MAX_POPOVER_RECOMPUTE_COUNTER = Number.MAX_SAFE_INTEGER; 30345 function BlockPopoverInbetween({ 30346 previousClientId, 30347 nextClientId, 30348 children, 30349 __unstablePopoverSlot, 30350 __unstableContentRef, 30351 operation = "insert", 30352 nearestSide = "right", 30353 ...props 30354 }) { 30355 const [popoverRecomputeCounter, forcePopoverRecompute] = (0, import_element78.useReducer)( 30356 // Module is there to make sure that the counter doesn't overflow. 30357 (s2) => (s2 + 1) % MAX_POPOVER_RECOMPUTE_COUNTER, 30358 0 30359 ); 30360 const { orientation, rootClientId, isVisible } = (0, import_data62.useSelect)( 30361 (select3) => { 30362 const { 30363 getBlockListSettings: getBlockListSettings2, 30364 getBlockRootClientId: getBlockRootClientId2, 30365 isBlockVisible: isBlockVisible2 30366 } = select3(store); 30367 const _rootClientId = getBlockRootClientId2( 30368 previousClientId ?? nextClientId 30369 ); 30370 return { 30371 orientation: getBlockListSettings2(_rootClientId)?.orientation || "vertical", 30372 rootClientId: _rootClientId, 30373 isVisible: isBlockVisible2(previousClientId) && isBlockVisible2(nextClientId) 30374 }; 30375 }, 30376 [previousClientId, nextClientId] 30377 ); 30378 const previousElement = useBlockElement(previousClientId); 30379 const nextElement = useBlockElement(nextClientId); 30380 const isVertical = orientation === "vertical"; 30381 const popoverAnchor = (0, import_element78.useMemo)(() => { 30382 if ( 30383 // popoverRecomputeCounter is by definition always equal or greater than 0. 30384 // This check is only there to satisfy the correctness of the 30385 // exhaustive-deps rule for the `useMemo` hook. 30386 popoverRecomputeCounter < 0 || !previousElement && !nextElement || !isVisible 30387 ) { 30388 return void 0; 30389 } 30390 const contextElement = operation === "group" ? nextElement || previousElement : previousElement || nextElement; 30391 return { 30392 contextElement, 30393 getBoundingClientRect() { 30394 const previousRect = previousElement ? previousElement.getBoundingClientRect() : null; 30395 const nextRect = nextElement ? nextElement.getBoundingClientRect() : null; 30396 let left = 0; 30397 let top = 0; 30398 let width = 0; 30399 let height = 0; 30400 if (operation === "group") { 30401 const targetRect = nextRect || previousRect; 30402 top = targetRect.top; 30403 width = 0; 30404 height = targetRect.bottom - targetRect.top; 30405 left = nearestSide === "left" ? targetRect.left - 2 : targetRect.right - 2; 30406 } else if (isVertical) { 30407 top = previousRect ? previousRect.bottom : nextRect.top; 30408 width = previousRect ? previousRect.width : nextRect.width; 30409 height = nextRect && previousRect ? nextRect.top - previousRect.bottom : 0; 30410 left = previousRect ? previousRect.left : nextRect.left; 30411 } else { 30412 top = previousRect ? previousRect.top : nextRect.top; 30413 height = previousRect ? previousRect.height : nextRect.height; 30414 if ((0, import_i18n62.isRTL)()) { 30415 left = nextRect ? nextRect.right : previousRect.left; 30416 width = previousRect && nextRect ? previousRect.left - nextRect.right : 0; 30417 } else { 30418 left = previousRect ? previousRect.right : nextRect.left; 30419 width = previousRect && nextRect ? nextRect.left - previousRect.right : 0; 30420 } 30421 width = Math.max(width, 0); 30422 } 30423 return new window.DOMRect(left, top, width, height); 30424 } 30425 }; 30426 }, [ 30427 previousElement, 30428 nextElement, 30429 popoverRecomputeCounter, 30430 isVertical, 30431 isVisible, 30432 operation, 30433 nearestSide 30434 ]); 30435 const popoverScrollRef = use_popover_scroll_default(__unstableContentRef); 30436 (0, import_element78.useLayoutEffect)(() => { 30437 if (!previousElement) { 30438 return; 30439 } 30440 const observer = new window.MutationObserver(forcePopoverRecompute); 30441 observer.observe(previousElement, { attributes: true }); 30442 return () => { 30443 observer.disconnect(); 30444 }; 30445 }, [previousElement]); 30446 (0, import_element78.useLayoutEffect)(() => { 30447 if (!nextElement) { 30448 return; 30449 } 30450 const observer = new window.MutationObserver(forcePopoverRecompute); 30451 observer.observe(nextElement, { attributes: true }); 30452 return () => { 30453 observer.disconnect(); 30454 }; 30455 }, [nextElement]); 30456 (0, import_element78.useLayoutEffect)(() => { 30457 if (!previousElement) { 30458 return; 30459 } 30460 previousElement.ownerDocument.defaultView.addEventListener( 30461 "resize", 30462 forcePopoverRecompute 30463 ); 30464 return () => { 30465 previousElement.ownerDocument.defaultView?.removeEventListener( 30466 "resize", 30467 forcePopoverRecompute 30468 ); 30469 }; 30470 }, [previousElement]); 30471 if (!previousElement && !nextElement || !isVisible) { 30472 return null; 30473 } 30474 return /* @__PURE__ */ (0, import_jsx_runtime193.jsx)( 30475 import_components60.Popover, 30476 { 30477 ref: popoverScrollRef, 30478 animate: false, 30479 anchor: popoverAnchor, 30480 focusOnMount: false, 30481 __unstableSlotName: __unstablePopoverSlot, 30482 inline: !__unstablePopoverSlot, 30483 ...props, 30484 className: clsx_default( 30485 "block-editor-block-popover", 30486 "block-editor-block-popover__inbetween", 30487 props.className 30488 ), 30489 resize: false, 30490 flip: false, 30491 placement: "overlay", 30492 variant: "unstyled", 30493 children: /* @__PURE__ */ (0, import_jsx_runtime193.jsx)("div", { className: "block-editor-block-popover__inbetween-container", children }) 30494 }, 30495 nextClientId + "--" + rootClientId 30496 ); 30497 } 30498 var inbetween_default = BlockPopoverInbetween; 30499 30500 // packages/block-editor/build-module/components/block-popover/drop-zone.js 30501 var import_data63 = __toESM(require_data()); 30502 var import_compose47 = __toESM(require_compose()); 30503 var import_components62 = __toESM(require_components()); 30504 30505 // packages/block-editor/build-module/components/block-popover/cover.js 30506 var import_element80 = __toESM(require_element()); 30507 30508 // packages/block-editor/build-module/components/block-popover/index.js 30509 var import_compose46 = __toESM(require_compose()); 30510 var import_components61 = __toESM(require_components()); 30511 var import_element79 = __toESM(require_element()); 30512 var import_jsx_runtime194 = __toESM(require_jsx_runtime()); 30513 var MAX_POPOVER_RECOMPUTE_COUNTER2 = Number.MAX_SAFE_INTEGER; 30514 function BlockPopover({ 30515 clientId, 30516 bottomClientId, 30517 children, 30518 __unstablePopoverSlot, 30519 __unstableContentRef, 30520 shift = true, 30521 ...props 30522 }, ref) { 30523 const selectedElement = useBlockElement(clientId); 30524 const lastSelectedElement = useBlockElement(bottomClientId ?? clientId); 30525 const mergedRefs = (0, import_compose46.useMergeRefs)([ 30526 ref, 30527 use_popover_scroll_default(__unstableContentRef) 30528 ]); 30529 const [ 30530 popoverDimensionsRecomputeCounter, 30531 forceRecomputePopoverDimensions 30532 ] = (0, import_element79.useReducer)( 30533 // Module is there to make sure that the counter doesn't overflow. 30534 (s2) => (s2 + 1) % MAX_POPOVER_RECOMPUTE_COUNTER2, 30535 0 30536 ); 30537 (0, import_element79.useLayoutEffect)(() => { 30538 if (!selectedElement) { 30539 return; 30540 } 30541 const observer = new window.MutationObserver( 30542 forceRecomputePopoverDimensions 30543 ); 30544 observer.observe(selectedElement, { attributes: true }); 30545 return () => { 30546 observer.disconnect(); 30547 }; 30548 }, [selectedElement]); 30549 const popoverAnchor = (0, import_element79.useMemo)(() => { 30550 if ( 30551 // popoverDimensionsRecomputeCounter is by definition always equal or greater 30552 // than 0. This check is only there to satisfy the correctness of the 30553 // exhaustive-deps rule for the `useMemo` hook. 30554 popoverDimensionsRecomputeCounter < 0 || !selectedElement || bottomClientId && !lastSelectedElement 30555 ) { 30556 return void 0; 30557 } 30558 return { 30559 getBoundingClientRect() { 30560 return lastSelectedElement ? rectUnion( 30561 getElementBounds(selectedElement), 30562 getElementBounds(lastSelectedElement) 30563 ) : getElementBounds(selectedElement); 30564 }, 30565 contextElement: selectedElement 30566 }; 30567 }, [ 30568 popoverDimensionsRecomputeCounter, 30569 selectedElement, 30570 bottomClientId, 30571 lastSelectedElement 30572 ]); 30573 if (!selectedElement || bottomClientId && !lastSelectedElement) { 30574 return null; 30575 } 30576 return /* @__PURE__ */ (0, import_jsx_runtime194.jsx)( 30577 import_components61.Popover, 30578 { 30579 ref: mergedRefs, 30580 animate: false, 30581 focusOnMount: false, 30582 anchor: popoverAnchor, 30583 __unstableSlotName: __unstablePopoverSlot, 30584 inline: !__unstablePopoverSlot, 30585 placement: "top-start", 30586 resize: false, 30587 flip: false, 30588 shift, 30589 ...props, 30590 className: clsx_default("block-editor-block-popover", props.className), 30591 variant: "unstyled", 30592 children 30593 } 30594 ); 30595 } 30596 var PrivateBlockPopover = (0, import_element79.forwardRef)(BlockPopover); 30597 var PublicBlockPopover = ({ clientId, bottomClientId, children, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime194.jsx)( 30598 PrivateBlockPopover, 30599 { 30600 ...props, 30601 bottomClientId, 30602 clientId, 30603 __unstableContentRef: void 0, 30604 __unstablePopoverSlot: void 0, 30605 ref, 30606 children 30607 } 30608 ); 30609 var block_popover_default = (0, import_element79.forwardRef)(PublicBlockPopover); 30610 30611 // packages/block-editor/build-module/components/block-popover/cover.js 30612 var import_jsx_runtime195 = __toESM(require_jsx_runtime()); 30613 function BlockPopoverCover({ 30614 clientId, 30615 bottomClientId, 30616 children, 30617 shift = false, 30618 additionalStyles, 30619 ...props 30620 }, ref) { 30621 bottomClientId ??= clientId; 30622 const selectedElement = useBlockElement(clientId); 30623 return /* @__PURE__ */ (0, import_jsx_runtime195.jsx)( 30624 PrivateBlockPopover, 30625 { 30626 ref, 30627 clientId, 30628 bottomClientId, 30629 shift, 30630 ...props, 30631 children: selectedElement && clientId === bottomClientId ? /* @__PURE__ */ (0, import_jsx_runtime195.jsx)( 30632 CoverContainer, 30633 { 30634 selectedElement, 30635 additionalStyles, 30636 children 30637 } 30638 ) : children 30639 } 30640 ); 30641 } 30642 function CoverContainer({ 30643 selectedElement, 30644 additionalStyles = {}, 30645 children 30646 }) { 30647 const [width, setWidth] = (0, import_element80.useState)(selectedElement.offsetWidth); 30648 const [height, setHeight] = (0, import_element80.useState)(selectedElement.offsetHeight); 30649 (0, import_element80.useEffect)(() => { 30650 const observer = new window.ResizeObserver(() => { 30651 setWidth(selectedElement.offsetWidth); 30652 setHeight(selectedElement.offsetHeight); 30653 }); 30654 observer.observe(selectedElement, { box: "border-box" }); 30655 return () => observer.disconnect(); 30656 }, [selectedElement]); 30657 const style = (0, import_element80.useMemo)(() => { 30658 return { 30659 position: "absolute", 30660 width, 30661 height, 30662 ...additionalStyles 30663 }; 30664 }, [width, height, additionalStyles]); 30665 return /* @__PURE__ */ (0, import_jsx_runtime195.jsx)("div", { style, children }); 30666 } 30667 var cover_default = (0, import_element80.forwardRef)(BlockPopoverCover); 30668 30669 // packages/block-editor/build-module/components/block-popover/drop-zone.js 30670 var import_jsx_runtime196 = __toESM(require_jsx_runtime()); 30671 var animateVariants = { 30672 hide: { opacity: 0, scaleY: 0.75 }, 30673 show: { opacity: 1, scaleY: 1 }, 30674 exit: { opacity: 0, scaleY: 0.9 } 30675 }; 30676 function BlockDropZonePopover({ 30677 __unstablePopoverSlot, 30678 __unstableContentRef 30679 }) { 30680 const { clientId } = (0, import_data63.useSelect)((select3) => { 30681 const { getBlockOrder: getBlockOrder2, getBlockInsertionPoint: getBlockInsertionPoint2 } = select3(store); 30682 const insertionPoint2 = getBlockInsertionPoint2(); 30683 const order = getBlockOrder2(insertionPoint2.rootClientId); 30684 if (!order.length) { 30685 return {}; 30686 } 30687 return { 30688 clientId: order[insertionPoint2.index] 30689 }; 30690 }, []); 30691 const reducedMotion = (0, import_compose47.useReducedMotion)(); 30692 return /* @__PURE__ */ (0, import_jsx_runtime196.jsx)( 30693 cover_default, 30694 { 30695 clientId, 30696 __unstablePopoverSlot, 30697 __unstableContentRef, 30698 className: "block-editor-block-popover__drop-zone", 30699 children: /* @__PURE__ */ (0, import_jsx_runtime196.jsx)( 30700 import_components62.__unstableMotion.div, 30701 { 30702 "data-testid": "block-popover-drop-zone", 30703 initial: reducedMotion ? animateVariants.show : animateVariants.hide, 30704 animate: animateVariants.show, 30705 exit: reducedMotion ? animateVariants.show : animateVariants.exit, 30706 className: "block-editor-block-popover__drop-zone-foreground" 30707 } 30708 ) 30709 } 30710 ); 30711 } 30712 var drop_zone_default = BlockDropZonePopover; 30713 30714 // packages/block-editor/build-module/components/block-tools/insertion-point.js 30715 var import_jsx_runtime197 = __toESM(require_jsx_runtime()); 30716 var InsertionPointOpenRef = (0, import_element81.createContext)(); 30717 InsertionPointOpenRef.displayName = "InsertionPointOpenRefContext"; 30718 function InbetweenInsertionPointPopover({ 30719 __unstablePopoverSlot, 30720 __unstableContentRef, 30721 operation = "insert", 30722 nearestSide = "right" 30723 }) { 30724 const { selectBlock: selectBlock2, hideInsertionPoint: hideInsertionPoint2 } = (0, import_data64.useDispatch)(store); 30725 const openRef = (0, import_element81.useContext)(InsertionPointOpenRef); 30726 const ref = (0, import_element81.useRef)(); 30727 const { 30728 orientation, 30729 previousClientId, 30730 nextClientId, 30731 rootClientId, 30732 isInserterShown, 30733 isDistractionFree, 30734 isZoomOutMode 30735 } = (0, import_data64.useSelect)((select3) => { 30736 const { 30737 getBlockOrder: getBlockOrder2, 30738 getBlockListSettings: getBlockListSettings2, 30739 getBlockInsertionPoint: getBlockInsertionPoint2, 30740 isBlockBeingDragged: isBlockBeingDragged2, 30741 getPreviousBlockClientId: getPreviousBlockClientId2, 30742 getNextBlockClientId: getNextBlockClientId2, 30743 getSettings: getSettings8, 30744 isZoomOut: isZoomOut2 30745 } = unlock(select3(store)); 30746 const insertionPoint2 = getBlockInsertionPoint2(); 30747 const order = getBlockOrder2(insertionPoint2.rootClientId); 30748 if (!order.length) { 30749 return {}; 30750 } 30751 let _previousClientId = order[insertionPoint2.index - 1]; 30752 let _nextClientId = order[insertionPoint2.index]; 30753 while (isBlockBeingDragged2(_previousClientId)) { 30754 _previousClientId = getPreviousBlockClientId2(_previousClientId); 30755 } 30756 while (isBlockBeingDragged2(_nextClientId)) { 30757 _nextClientId = getNextBlockClientId2(_nextClientId); 30758 } 30759 const settings2 = getSettings8(); 30760 return { 30761 previousClientId: _previousClientId, 30762 nextClientId: _nextClientId, 30763 orientation: getBlockListSettings2(insertionPoint2.rootClientId)?.orientation || "vertical", 30764 rootClientId: insertionPoint2.rootClientId, 30765 isDistractionFree: settings2.isDistractionFree, 30766 isInserterShown: insertionPoint2?.__unstableWithInserter, 30767 isZoomOutMode: isZoomOut2() 30768 }; 30769 }, []); 30770 const { getBlockEditingMode: getBlockEditingMode2 } = (0, import_data64.useSelect)(store); 30771 const disableMotion = (0, import_compose48.useReducedMotion)(); 30772 function onClick(event) { 30773 if (event.target === ref.current && nextClientId && getBlockEditingMode2(nextClientId) !== "disabled") { 30774 selectBlock2(nextClientId, -1); 30775 } 30776 } 30777 function maybeHideInserterPoint(event) { 30778 if (event.target === ref.current && !openRef.current) { 30779 hideInsertionPoint2(); 30780 } 30781 } 30782 function onFocus(event) { 30783 if (event.target !== ref.current) { 30784 openRef.current = true; 30785 } 30786 } 30787 const maybeResetOpenRef = (0, import_element81.useCallback)( 30788 (node) => { 30789 if (!node && openRef.current) { 30790 openRef.current = false; 30791 } 30792 }, 30793 [openRef] 30794 ); 30795 const lineVariants = { 30796 // Initial position starts from the center and invisible. 30797 start: { 30798 opacity: 0, 30799 scale: 0 30800 }, 30801 // The line expands to fill the container. If the inserter is visible it 30802 // is delayed so it appears orchestrated. 30803 rest: { 30804 opacity: 1, 30805 scale: 1, 30806 transition: { delay: isInserterShown ? 0.5 : 0, type: "tween" } 30807 }, 30808 hover: { 30809 opacity: 1, 30810 scale: 1, 30811 transition: { delay: 0.5, type: "tween" } 30812 } 30813 }; 30814 const inserterVariants = { 30815 start: { 30816 scale: disableMotion ? 1 : 0 30817 }, 30818 rest: { 30819 scale: 1, 30820 transition: { delay: 0.4, type: "tween" } 30821 } 30822 }; 30823 if (isDistractionFree) { 30824 return null; 30825 } 30826 if (isZoomOutMode && operation !== "insert") { 30827 return null; 30828 } 30829 const orientationClassname = orientation === "horizontal" || operation === "group" ? "is-horizontal" : "is-vertical"; 30830 const className = clsx_default( 30831 "block-editor-block-list__insertion-point", 30832 orientationClassname 30833 ); 30834 return /* @__PURE__ */ (0, import_jsx_runtime197.jsx)( 30835 inbetween_default, 30836 { 30837 previousClientId, 30838 nextClientId, 30839 __unstablePopoverSlot, 30840 __unstableContentRef, 30841 operation, 30842 nearestSide, 30843 children: /* @__PURE__ */ (0, import_jsx_runtime197.jsxs)( 30844 import_components63.__unstableMotion.div, 30845 { 30846 layout: !disableMotion, 30847 initial: disableMotion ? "rest" : "start", 30848 animate: "rest", 30849 whileHover: "hover", 30850 whileTap: "pressed", 30851 exit: "start", 30852 ref, 30853 tabIndex: -1, 30854 onClick, 30855 onFocus, 30856 className: clsx_default(className, { 30857 "is-with-inserter": isInserterShown 30858 }), 30859 onHoverEnd: maybeHideInserterPoint, 30860 children: [ 30861 /* @__PURE__ */ (0, import_jsx_runtime197.jsx)( 30862 import_components63.__unstableMotion.div, 30863 { 30864 variants: lineVariants, 30865 className: "block-editor-block-list__insertion-point-indicator", 30866 "data-testid": "block-list-insertion-point-indicator" 30867 } 30868 ), 30869 isInserterShown && /* @__PURE__ */ (0, import_jsx_runtime197.jsx)( 30870 import_components63.__unstableMotion.div, 30871 { 30872 variants: inserterVariants, 30873 className: clsx_default( 30874 "block-editor-block-list__insertion-point-inserter" 30875 ), 30876 children: /* @__PURE__ */ (0, import_jsx_runtime197.jsx)( 30877 inserter_default, 30878 { 30879 ref: maybeResetOpenRef, 30880 position: "bottom center", 30881 clientId: nextClientId, 30882 rootClientId, 30883 __experimentalIsQuick: true, 30884 onToggle: (isOpen) => { 30885 openRef.current = isOpen; 30886 }, 30887 onSelectOrClose: () => { 30888 openRef.current = false; 30889 } 30890 } 30891 ) 30892 } 30893 ) 30894 ] 30895 } 30896 ) 30897 } 30898 ); 30899 } 30900 function InsertionPoint(props) { 30901 const { insertionPoint: insertionPoint2, isVisible, isBlockListEmpty } = (0, import_data64.useSelect)( 30902 (select3) => { 30903 const { 30904 getBlockInsertionPoint: getBlockInsertionPoint2, 30905 isBlockInsertionPointVisible: isBlockInsertionPointVisible2, 30906 getBlockCount: getBlockCount2 30907 } = select3(store); 30908 const blockInsertionPoint = getBlockInsertionPoint2(); 30909 return { 30910 insertionPoint: blockInsertionPoint, 30911 isVisible: isBlockInsertionPointVisible2(), 30912 isBlockListEmpty: getBlockCount2(blockInsertionPoint?.rootClientId) === 0 30913 }; 30914 }, 30915 [] 30916 ); 30917 if (!isVisible || // Don't render the insertion point if the block list is empty. 30918 // The insertion point will be represented by the appender instead. 30919 isBlockListEmpty) { 30920 return null; 30921 } 30922 return insertionPoint2.operation === "replace" ? /* @__PURE__ */ (0, import_jsx_runtime197.jsx)( 30923 drop_zone_default, 30924 { 30925 ...props 30926 }, 30927 `$insertionPoint2.rootClientId}-$insertionPoint2.index}` 30928 ) : /* @__PURE__ */ (0, import_jsx_runtime197.jsx)( 30929 InbetweenInsertionPointPopover, 30930 { 30931 operation: insertionPoint2.operation, 30932 nearestSide: insertionPoint2.nearestSide, 30933 ...props 30934 } 30935 ); 30936 } 30937 30938 // packages/block-editor/build-module/components/block-list/use-in-between-inserter.js 30939 function useInBetweenInserter() { 30940 const openRef = (0, import_element82.useContext)(InsertionPointOpenRef); 30941 const isInBetweenInserterDisabled = (0, import_data65.useSelect)( 30942 (select3) => select3(store).getSettings().isDistractionFree || unlock(select3(store)).isZoomOut(), 30943 [] 30944 ); 30945 const { 30946 getBlockListSettings: getBlockListSettings2, 30947 getBlockIndex: getBlockIndex2, 30948 isMultiSelecting: isMultiSelecting3, 30949 getSelectedBlockClientIds: getSelectedBlockClientIds2, 30950 getSettings: getSettings8, 30951 getTemplateLock: getTemplateLock2, 30952 __unstableIsWithinBlockOverlay: __unstableIsWithinBlockOverlay2, 30953 getBlockEditingMode: getBlockEditingMode2, 30954 getBlockName: getBlockName2, 30955 getBlockAttributes: getBlockAttributes3, 30956 getParentSectionBlock: getParentSectionBlock2 30957 } = unlock((0, import_data65.useSelect)(store)); 30958 const { showInsertionPoint: showInsertionPoint2, hideInsertionPoint: hideInsertionPoint2 } = (0, import_data65.useDispatch)(store); 30959 return (0, import_compose49.useRefEffect)( 30960 (node) => { 30961 if (isInBetweenInserterDisabled) { 30962 return; 30963 } 30964 function onMouseMove(event) { 30965 if (openRef === void 0 || openRef.current) { 30966 return; 30967 } 30968 if (event.target.nodeType === event.target.TEXT_NODE) { 30969 return; 30970 } 30971 if (isMultiSelecting3()) { 30972 return; 30973 } 30974 if (!event.target.classList.contains( 30975 "block-editor-block-list__layout" 30976 )) { 30977 hideInsertionPoint2(); 30978 return; 30979 } 30980 let rootClientId; 30981 if (!event.target.classList.contains("is-root-container")) { 30982 const blockElement = !!event.target.getAttribute( 30983 "data-block" 30984 ) ? event.target : event.target.closest("[data-block]"); 30985 rootClientId = blockElement.getAttribute("data-block"); 30986 } 30987 if (getTemplateLock2(rootClientId) || getBlockEditingMode2(rootClientId) === "disabled" || getBlockName2(rootClientId) === "core/block" || rootClientId && getBlockAttributes3(rootClientId).layout?.isManualPlacement) { 30988 return; 30989 } 30990 const blockListSettings2 = getBlockListSettings2(rootClientId); 30991 const orientation = blockListSettings2?.orientation || "vertical"; 30992 const captureToolbars = !!blockListSettings2?.__experimentalCaptureToolbars; 30993 const offsetTop = event.clientY; 30994 const offsetLeft = event.clientX; 30995 const children = Array.from(event.target.children); 30996 let element = children.find((blockEl) => { 30997 const blockElRect = blockEl.getBoundingClientRect(); 30998 return blockEl.classList.contains("wp-block") && orientation === "vertical" && blockElRect.top > offsetTop || blockEl.classList.contains("wp-block") && orientation === "horizontal" && ((0, import_i18n63.isRTL)() ? blockElRect.right < offsetLeft : blockElRect.left > offsetLeft); 30999 }); 31000 if (!element) { 31001 hideInsertionPoint2(); 31002 return; 31003 } 31004 if (!element.id) { 31005 element = element.firstElementChild; 31006 if (!element) { 31007 hideInsertionPoint2(); 31008 return; 31009 } 31010 } 31011 const clientId = element.id.slice("block-".length); 31012 if (!clientId || __unstableIsWithinBlockOverlay2(clientId) || !!getParentSectionBlock2(clientId)) { 31013 return; 31014 } 31015 if (getSelectedBlockClientIds2().includes(clientId) && orientation === "vertical" && !captureToolbars && !getSettings8().hasFixedToolbar) { 31016 return; 31017 } 31018 const elementRect = element.getBoundingClientRect(); 31019 if (orientation === "horizontal" && (event.clientY > elementRect.bottom || event.clientY < elementRect.top) || orientation === "vertical" && (event.clientX > elementRect.right || event.clientX < elementRect.left)) { 31020 hideInsertionPoint2(); 31021 return; 31022 } 31023 const index = getBlockIndex2(clientId); 31024 if (index === 0) { 31025 hideInsertionPoint2(); 31026 return; 31027 } 31028 showInsertionPoint2(rootClientId, index, { 31029 __unstableWithInserter: true 31030 }); 31031 } 31032 node.addEventListener("mousemove", onMouseMove); 31033 return () => { 31034 node.removeEventListener("mousemove", onMouseMove); 31035 }; 31036 }, 31037 [ 31038 openRef, 31039 getBlockListSettings2, 31040 getBlockIndex2, 31041 isMultiSelecting3, 31042 showInsertionPoint2, 31043 hideInsertionPoint2, 31044 getSelectedBlockClientIds2, 31045 isInBetweenInserterDisabled 31046 ] 31047 ); 31048 } 31049 31050 // packages/block-editor/build-module/components/block-selection-clearer/index.js 31051 var import_data66 = __toESM(require_data()); 31052 var import_compose50 = __toESM(require_compose()); 31053 var import_jsx_runtime198 = __toESM(require_jsx_runtime()); 31054 function useBlockSelectionClearer() { 31055 const { getSettings: getSettings8, hasSelectedBlock: hasSelectedBlock2, hasMultiSelection: hasMultiSelection2 } = (0, import_data66.useSelect)(store); 31056 const { clearSelectedBlock: clearSelectedBlock2 } = (0, import_data66.useDispatch)(store); 31057 const { clearBlockSelection: isEnabled } = getSettings8(); 31058 return (0, import_compose50.useRefEffect)( 31059 (node) => { 31060 if (!isEnabled) { 31061 return; 31062 } 31063 function onMouseDown(event) { 31064 if (!hasSelectedBlock2() && !hasMultiSelection2()) { 31065 return; 31066 } 31067 if (event.target !== node) { 31068 return; 31069 } 31070 clearSelectedBlock2(); 31071 } 31072 node.addEventListener("mousedown", onMouseDown); 31073 return () => { 31074 node.removeEventListener("mousedown", onMouseDown); 31075 }; 31076 }, 31077 [hasSelectedBlock2, hasMultiSelection2, clearSelectedBlock2, isEnabled] 31078 ); 31079 } 31080 function BlockSelectionClearer(props) { 31081 return /* @__PURE__ */ (0, import_jsx_runtime198.jsx)("div", { ref: useBlockSelectionClearer(), ...props }); 31082 } 31083 31084 // packages/block-editor/build-module/components/inner-blocks/index.js 31085 var import_compose52 = __toESM(require_compose()); 31086 var import_element87 = __toESM(require_element()); 31087 var import_data72 = __toESM(require_data()); 31088 var import_blocks41 = __toESM(require_blocks()); 31089 31090 // packages/block-editor/build-module/components/inner-blocks/button-block-appender.js 31091 var import_jsx_runtime199 = __toESM(require_jsx_runtime()); 31092 function ButtonBlockAppender2({ 31093 showSeparator, 31094 isFloating, 31095 onAddBlock, 31096 isToggle 31097 }) { 31098 const { clientId } = useBlockEditContext(); 31099 return /* @__PURE__ */ (0, import_jsx_runtime199.jsx)( 31100 button_block_appender_default, 31101 { 31102 className: clsx_default({ 31103 "block-list-appender__toggle": isToggle 31104 }), 31105 rootClientId: clientId, 31106 showSeparator, 31107 isFloating, 31108 onAddBlock 31109 } 31110 ); 31111 } 31112 31113 // packages/block-editor/build-module/components/inner-blocks/default-block-appender.js 31114 var import_jsx_runtime200 = __toESM(require_jsx_runtime()); 31115 function DefaultBlockAppender2() { 31116 const { clientId } = useBlockEditContext(); 31117 return /* @__PURE__ */ (0, import_jsx_runtime200.jsx)(DefaultBlockAppender, { rootClientId: clientId }); 31118 } 31119 31120 // packages/block-editor/build-module/components/inner-blocks/use-nested-settings-update.js 31121 var import_element83 = __toESM(require_element()); 31122 var import_data67 = __toESM(require_data()); 31123 var import_deprecated9 = __toESM(require_deprecated()); 31124 var import_is_shallow_equal = __toESM(require_is_shallow_equal()); 31125 var pendingSettingsUpdates = /* @__PURE__ */ new WeakMap(); 31126 function createShallowMemo() { 31127 let value; 31128 return (newValue) => { 31129 if (value === void 0 || !(0, import_is_shallow_equal.default)(value, newValue)) { 31130 value = newValue; 31131 } 31132 return value; 31133 }; 31134 } 31135 function useShallowMemo(value) { 31136 const [memo11] = (0, import_element83.useState)(createShallowMemo); 31137 return memo11(value); 31138 } 31139 function useNestedSettingsUpdate(clientId, parentLock, allowedBlocks, prioritizedInserterBlocks, defaultBlock, directInsert, __experimentalDefaultBlock, __experimentalDirectInsert, templateLock, captureToolbars, orientation, layout) { 31140 const registry = (0, import_data67.useRegistry)(); 31141 const _allowedBlocks = useShallowMemo(allowedBlocks); 31142 const _prioritizedInserterBlocks = useShallowMemo( 31143 prioritizedInserterBlocks 31144 ); 31145 const _templateLock = templateLock === void 0 || parentLock === "contentOnly" ? parentLock : templateLock; 31146 (0, import_element83.useLayoutEffect)(() => { 31147 const newSettings = { 31148 allowedBlocks: _allowedBlocks, 31149 prioritizedInserterBlocks: _prioritizedInserterBlocks, 31150 templateLock: _templateLock 31151 }; 31152 if (captureToolbars !== void 0) { 31153 newSettings.__experimentalCaptureToolbars = captureToolbars; 31154 } 31155 if (orientation !== void 0) { 31156 newSettings.orientation = orientation; 31157 } else { 31158 const layoutType = getLayoutType(layout?.type); 31159 newSettings.orientation = layoutType.getOrientation(layout); 31160 } 31161 if (__experimentalDefaultBlock !== void 0) { 31162 (0, import_deprecated9.default)("__experimentalDefaultBlock", { 31163 alternative: "defaultBlock", 31164 since: "6.3", 31165 version: "6.4" 31166 }); 31167 newSettings.defaultBlock = __experimentalDefaultBlock; 31168 } 31169 if (defaultBlock !== void 0) { 31170 newSettings.defaultBlock = defaultBlock; 31171 } 31172 if (__experimentalDirectInsert !== void 0) { 31173 (0, import_deprecated9.default)("__experimentalDirectInsert", { 31174 alternative: "directInsert", 31175 since: "6.3", 31176 version: "6.4" 31177 }); 31178 newSettings.directInsert = __experimentalDirectInsert; 31179 } 31180 if (directInsert !== void 0) { 31181 newSettings.directInsert = directInsert; 31182 } 31183 if (newSettings.directInsert !== void 0 && typeof newSettings.directInsert !== "boolean") { 31184 (0, import_deprecated9.default)("Using `Function` as a `directInsert` argument", { 31185 alternative: "`boolean` values", 31186 since: "6.5" 31187 }); 31188 } 31189 if (!pendingSettingsUpdates.get(registry)) { 31190 pendingSettingsUpdates.set(registry, {}); 31191 } 31192 pendingSettingsUpdates.get(registry)[clientId] = newSettings; 31193 window.queueMicrotask(() => { 31194 const settings2 = pendingSettingsUpdates.get(registry); 31195 if (Object.keys(settings2).length) { 31196 const { updateBlockListSettings: updateBlockListSettings2 } = registry.dispatch(store); 31197 updateBlockListSettings2(settings2); 31198 pendingSettingsUpdates.set(registry, {}); 31199 } 31200 }); 31201 }, [ 31202 clientId, 31203 _allowedBlocks, 31204 _prioritizedInserterBlocks, 31205 _templateLock, 31206 defaultBlock, 31207 directInsert, 31208 __experimentalDefaultBlock, 31209 __experimentalDirectInsert, 31210 captureToolbars, 31211 orientation, 31212 layout, 31213 registry 31214 ]); 31215 } 31216 31217 // packages/block-editor/build-module/components/inner-blocks/use-inner-block-template-sync.js 31218 var import_es64 = __toESM(require_es6()); 31219 var import_element84 = __toESM(require_element()); 31220 var import_data68 = __toESM(require_data()); 31221 var import_blocks37 = __toESM(require_blocks()); 31222 function useInnerBlockTemplateSync(clientId, template2, templateLock, templateInsertUpdatesSelection) { 31223 const registry = (0, import_data68.useRegistry)(); 31224 const existingTemplateRef = (0, import_element84.useRef)(null); 31225 (0, import_element84.useLayoutEffect)(() => { 31226 let isCancelled = false; 31227 const { 31228 getBlocks: getBlocks2, 31229 getSelectedBlocksInitialCaretPosition: getSelectedBlocksInitialCaretPosition2, 31230 isBlockSelected: isBlockSelected2 31231 } = registry.select(store); 31232 const { replaceInnerBlocks: replaceInnerBlocks2, __unstableMarkNextChangeAsNotPersistent: __unstableMarkNextChangeAsNotPersistent2 } = registry.dispatch(store); 31233 window.queueMicrotask(() => { 31234 if (isCancelled) { 31235 return; 31236 } 31237 const currentInnerBlocks = getBlocks2(clientId); 31238 const shouldApplyTemplate = currentInnerBlocks.length === 0 || templateLock === "all" || templateLock === "contentOnly"; 31239 const hasTemplateChanged = !(0, import_es64.default)( 31240 template2, 31241 existingTemplateRef.current 31242 ); 31243 if (!shouldApplyTemplate || !hasTemplateChanged) { 31244 return; 31245 } 31246 existingTemplateRef.current = template2; 31247 const nextBlocks = (0, import_blocks37.synchronizeBlocksWithTemplate)( 31248 currentInnerBlocks, 31249 template2 31250 ); 31251 if (!(0, import_es64.default)(nextBlocks, currentInnerBlocks)) { 31252 __unstableMarkNextChangeAsNotPersistent2(); 31253 replaceInnerBlocks2( 31254 clientId, 31255 nextBlocks, 31256 currentInnerBlocks.length === 0 && templateInsertUpdatesSelection && nextBlocks.length !== 0 && isBlockSelected2(clientId), 31257 // This ensures the "initialPosition" doesn't change when applying the template 31258 // If we're supposed to focus the block, we'll focus the first inner block 31259 // otherwise, we won't apply any auto-focus. 31260 // This ensures for instance that the focus stays in the inserter when inserting the "buttons" block. 31261 getSelectedBlocksInitialCaretPosition2() 31262 ); 31263 } 31264 }); 31265 return () => { 31266 isCancelled = true; 31267 }; 31268 }, [ 31269 template2, 31270 templateLock, 31271 clientId, 31272 registry, 31273 templateInsertUpdatesSelection 31274 ]); 31275 } 31276 31277 // packages/block-editor/build-module/components/inner-blocks/use-block-context.js 31278 var import_blocks38 = __toESM(require_blocks()); 31279 var import_data69 = __toESM(require_data()); 31280 function useBlockContext(clientId) { 31281 return (0, import_data69.useSelect)( 31282 (select3) => { 31283 const block = select3(store).getBlock(clientId); 31284 if (!block) { 31285 return void 0; 31286 } 31287 const blockType = select3(import_blocks38.store).getBlockType(block.name); 31288 if (!blockType) { 31289 return void 0; 31290 } 31291 if (Object.keys(blockType.providesContext).length === 0) { 31292 return void 0; 31293 } 31294 return Object.fromEntries( 31295 Object.entries(blockType.providesContext).map( 31296 ([contextName, attributeName]) => [ 31297 contextName, 31298 block.attributes[attributeName] 31299 ] 31300 ) 31301 ); 31302 }, 31303 [clientId] 31304 ); 31305 } 31306 31307 // packages/block-editor/build-module/components/use-block-drop-zone/index.js 31308 var import_data71 = __toESM(require_data()); 31309 var import_element86 = __toESM(require_element()); 31310 var import_compose51 = __toESM(require_compose()); 31311 var import_i18n64 = __toESM(require_i18n()); 31312 var import_blocks40 = __toESM(require_blocks()); 31313 31314 // packages/block-editor/build-module/components/use-on-block-drop/index.js 31315 var import_element85 = __toESM(require_element()); 31316 var import_blocks39 = __toESM(require_blocks()); 31317 var import_data70 = __toESM(require_data()); 31318 var import_dom22 = __toESM(require_dom()); 31319 function parseDropEvent(event) { 31320 let result = { 31321 srcRootClientId: null, 31322 srcClientIds: null, 31323 srcIndex: null, 31324 type: null, 31325 blocks: null 31326 }; 31327 if (!event.dataTransfer) { 31328 return result; 31329 } 31330 try { 31331 result = Object.assign( 31332 result, 31333 JSON.parse(event.dataTransfer.getData("wp-blocks")) 31334 ); 31335 } catch (err) { 31336 return result; 31337 } 31338 return result; 31339 } 31340 function onBlockDrop(targetRootClientId, targetBlockIndex, getBlockIndex2, getClientIdsOfDescendants2, moveBlocks, insertOrReplaceBlocks, clearSelectedBlock2, operation, getBlock2) { 31341 return (event) => { 31342 const { 31343 srcRootClientId: sourceRootClientId, 31344 srcClientIds: sourceClientIds, 31345 type: dropType, 31346 blocks: blocks2 31347 } = parseDropEvent(event); 31348 if (dropType === "inserter") { 31349 clearSelectedBlock2(); 31350 const blocksToInsert = blocks2.map( 31351 (block) => (0, import_blocks39.cloneBlock)(block) 31352 ); 31353 insertOrReplaceBlocks(blocksToInsert, true, null); 31354 } 31355 if (dropType === "block") { 31356 const sourceBlockIndex = getBlockIndex2(sourceClientIds[0]); 31357 if (sourceRootClientId === targetRootClientId && sourceBlockIndex === targetBlockIndex) { 31358 return; 31359 } 31360 if (sourceClientIds.includes(targetRootClientId) || getClientIdsOfDescendants2(sourceClientIds).some( 31361 (id) => id === targetRootClientId 31362 )) { 31363 return; 31364 } 31365 if (operation === "group") { 31366 const blocksToInsert = sourceClientIds.map( 31367 (clientId) => getBlock2(clientId) 31368 ); 31369 insertOrReplaceBlocks( 31370 blocksToInsert, 31371 true, 31372 null, 31373 sourceClientIds 31374 ); 31375 return; 31376 } 31377 const isAtSameLevel = sourceRootClientId === targetRootClientId; 31378 const draggedBlockCount = sourceClientIds.length; 31379 const insertIndex = isAtSameLevel && sourceBlockIndex < targetBlockIndex ? targetBlockIndex - draggedBlockCount : targetBlockIndex; 31380 moveBlocks(sourceClientIds, sourceRootClientId, insertIndex); 31381 } 31382 }; 31383 } 31384 function onFilesDrop(targetRootClientId, getSettings8, updateBlockAttributes2, canInsertBlockType2, insertOrReplaceBlocks) { 31385 return (files) => { 31386 if (!getSettings8().mediaUpload) { 31387 return; 31388 } 31389 const transformation = (0, import_blocks39.findTransform)( 31390 (0, import_blocks39.getBlockTransforms)("from"), 31391 (transform) => transform.type === "files" && canInsertBlockType2(transform.blockName, targetRootClientId) && transform.isMatch(files) 31392 ); 31393 if (transformation) { 31394 const blocks2 = transformation.transform( 31395 files, 31396 updateBlockAttributes2 31397 ); 31398 insertOrReplaceBlocks(blocks2); 31399 } 31400 }; 31401 } 31402 function onHTMLDrop(insertOrReplaceBlocks) { 31403 return (HTML) => { 31404 const blocks2 = (0, import_blocks39.pasteHandler)({ HTML, mode: "BLOCKS" }); 31405 if (blocks2.length) { 31406 insertOrReplaceBlocks(blocks2); 31407 } 31408 }; 31409 } 31410 function useOnBlockDrop(targetRootClientId, targetBlockIndex, options = {}) { 31411 const { operation = "insert", nearestSide = "right" } = options; 31412 const { 31413 canInsertBlockType: canInsertBlockType2, 31414 getBlockIndex: getBlockIndex2, 31415 getClientIdsOfDescendants: getClientIdsOfDescendants2, 31416 getBlockOrder: getBlockOrder2, 31417 getBlocksByClientId: getBlocksByClientId2, 31418 getSettings: getSettings8, 31419 getBlock: getBlock2 31420 } = (0, import_data70.useSelect)(store); 31421 const { getGroupingBlockName } = (0, import_data70.useSelect)(import_blocks39.store); 31422 const { 31423 insertBlocks: insertBlocks2, 31424 moveBlocksToPosition: moveBlocksToPosition2, 31425 updateBlockAttributes: updateBlockAttributes2, 31426 clearSelectedBlock: clearSelectedBlock2, 31427 replaceBlocks: replaceBlocks2, 31428 removeBlocks: removeBlocks2 31429 } = (0, import_data70.useDispatch)(store); 31430 const registry = (0, import_data70.useRegistry)(); 31431 const insertOrReplaceBlocks = (0, import_element85.useCallback)( 31432 (blocks2, updateSelection = true, initialPosition2 = 0, clientIdsToReplace = []) => { 31433 if (!Array.isArray(blocks2)) { 31434 blocks2 = [blocks2]; 31435 } 31436 const clientIds = getBlockOrder2(targetRootClientId); 31437 const clientId = clientIds[targetBlockIndex]; 31438 if (operation === "replace") { 31439 replaceBlocks2(clientId, blocks2, void 0, initialPosition2); 31440 } else if (operation === "group") { 31441 const targetBlock = getBlock2(clientId); 31442 if (nearestSide === "left") { 31443 blocks2.push(targetBlock); 31444 } else { 31445 blocks2.unshift(targetBlock); 31446 } 31447 const groupInnerBlocks = blocks2.map((block) => { 31448 return (0, import_blocks39.createBlock)( 31449 block.name, 31450 block.attributes, 31451 block.innerBlocks 31452 ); 31453 }); 31454 const areAllImages = blocks2.every((block) => { 31455 return block.name === "core/image"; 31456 }); 31457 const galleryBlock = canInsertBlockType2( 31458 "core/gallery", 31459 targetRootClientId 31460 ); 31461 const wrappedBlocks = (0, import_blocks39.createBlock)( 31462 areAllImages && galleryBlock ? "core/gallery" : getGroupingBlockName(), 31463 { 31464 layout: { 31465 type: "flex", 31466 flexWrap: areAllImages && galleryBlock ? null : "nowrap" 31467 } 31468 }, 31469 groupInnerBlocks 31470 ); 31471 replaceBlocks2( 31472 [clientId, ...clientIdsToReplace], 31473 wrappedBlocks, 31474 void 0, 31475 initialPosition2 31476 ); 31477 } else { 31478 insertBlocks2( 31479 blocks2, 31480 targetBlockIndex, 31481 targetRootClientId, 31482 updateSelection, 31483 initialPosition2 31484 ); 31485 } 31486 }, 31487 [ 31488 getBlockOrder2, 31489 targetRootClientId, 31490 targetBlockIndex, 31491 operation, 31492 replaceBlocks2, 31493 getBlock2, 31494 nearestSide, 31495 canInsertBlockType2, 31496 getGroupingBlockName, 31497 insertBlocks2 31498 ] 31499 ); 31500 const moveBlocks = (0, import_element85.useCallback)( 31501 (sourceClientIds, sourceRootClientId, insertIndex) => { 31502 if (operation === "replace") { 31503 const sourceBlocks = getBlocksByClientId2(sourceClientIds); 31504 const targetBlockClientIds = getBlockOrder2(targetRootClientId); 31505 const targetBlockClientId = targetBlockClientIds[targetBlockIndex]; 31506 registry.batch(() => { 31507 removeBlocks2(sourceClientIds, false); 31508 replaceBlocks2( 31509 targetBlockClientId, 31510 sourceBlocks, 31511 void 0, 31512 0 31513 ); 31514 }); 31515 } else { 31516 moveBlocksToPosition2( 31517 sourceClientIds, 31518 sourceRootClientId, 31519 targetRootClientId, 31520 insertIndex 31521 ); 31522 } 31523 }, 31524 [ 31525 operation, 31526 getBlockOrder2, 31527 getBlocksByClientId2, 31528 moveBlocksToPosition2, 31529 registry, 31530 removeBlocks2, 31531 replaceBlocks2, 31532 targetBlockIndex, 31533 targetRootClientId 31534 ] 31535 ); 31536 const _onDrop = onBlockDrop( 31537 targetRootClientId, 31538 targetBlockIndex, 31539 getBlockIndex2, 31540 getClientIdsOfDescendants2, 31541 moveBlocks, 31542 insertOrReplaceBlocks, 31543 clearSelectedBlock2, 31544 operation, 31545 getBlock2 31546 ); 31547 const _onFilesDrop = onFilesDrop( 31548 targetRootClientId, 31549 getSettings8, 31550 updateBlockAttributes2, 31551 canInsertBlockType2, 31552 insertOrReplaceBlocks 31553 ); 31554 const _onHTMLDrop = onHTMLDrop(insertOrReplaceBlocks); 31555 return (event) => { 31556 const files = (0, import_dom22.getFilesFromDataTransfer)(event.dataTransfer); 31557 const html = event.dataTransfer.getData("text/html"); 31558 if (html) { 31559 _onHTMLDrop(html); 31560 } else if (files.length) { 31561 _onFilesDrop(files); 31562 } else { 31563 _onDrop(event); 31564 } 31565 }; 31566 } 31567 31568 // packages/block-editor/build-module/utils/math.js 31569 function getDistanceFromPointToEdge(point, rect, edge) { 31570 const isHorizontal = edge === "top" || edge === "bottom"; 31571 const { x: x2, y: y2 } = point; 31572 const pointLateralPosition = isHorizontal ? x2 : y2; 31573 const pointForwardPosition = isHorizontal ? y2 : x2; 31574 const edgeStart = isHorizontal ? rect.left : rect.top; 31575 const edgeEnd = isHorizontal ? rect.right : rect.bottom; 31576 const edgeForwardPosition = rect[edge]; 31577 let edgeLateralPosition; 31578 if (pointLateralPosition >= edgeStart && pointLateralPosition <= edgeEnd) { 31579 edgeLateralPosition = pointLateralPosition; 31580 } else if (pointLateralPosition < edgeEnd) { 31581 edgeLateralPosition = edgeStart; 31582 } else { 31583 edgeLateralPosition = edgeEnd; 31584 } 31585 return Math.sqrt( 31586 (pointLateralPosition - edgeLateralPosition) ** 2 + (pointForwardPosition - edgeForwardPosition) ** 2 31587 ); 31588 } 31589 function getDistanceToNearestEdge(point, rect, allowedEdges = ["top", "bottom", "left", "right"]) { 31590 let candidateDistance; 31591 let candidateEdge; 31592 allowedEdges.forEach((edge) => { 31593 const distance = getDistanceFromPointToEdge(point, rect, edge); 31594 if (candidateDistance === void 0 || distance < candidateDistance) { 31595 candidateDistance = distance; 31596 candidateEdge = edge; 31597 } 31598 }); 31599 return [candidateDistance, candidateEdge]; 31600 } 31601 function isPointContainedByRect(point, rect) { 31602 return rect.left <= point.x && rect.right >= point.x && rect.top <= point.y && rect.bottom >= point.y; 31603 } 31604 function isPointWithinTopAndBottomBoundariesOfRect(point, rect) { 31605 return rect.top <= point.y && rect.bottom >= point.y; 31606 } 31607 31608 // packages/block-editor/build-module/components/use-block-drop-zone/index.js 31609 var THRESHOLD_DISTANCE = 30; 31610 var MINIMUM_HEIGHT_FOR_THRESHOLD = 120; 31611 var MINIMUM_WIDTH_FOR_THRESHOLD = 120; 31612 function getDropTargetPosition(blocksData, position, orientation = "vertical", options = {}) { 31613 const allowedEdges = orientation === "horizontal" ? ["left", "right"] : ["top", "bottom"]; 31614 let nearestIndex = 0; 31615 let insertPosition = "before"; 31616 let minDistance = Infinity; 31617 let targetBlockIndex = null; 31618 let nearestSide = "right"; 31619 const { 31620 dropZoneElement, 31621 parentBlockOrientation, 31622 rootBlockIndex = 0 31623 } = options; 31624 if (dropZoneElement && parentBlockOrientation !== "horizontal") { 31625 const rect = dropZoneElement.getBoundingClientRect(); 31626 const [distance, edge] = getDistanceToNearestEdge(position, rect, [ 31627 "top", 31628 "bottom" 31629 ]); 31630 if (rect.height > MINIMUM_HEIGHT_FOR_THRESHOLD && distance < THRESHOLD_DISTANCE) { 31631 if (edge === "top") { 31632 return [rootBlockIndex, "before"]; 31633 } 31634 if (edge === "bottom") { 31635 return [rootBlockIndex + 1, "after"]; 31636 } 31637 } 31638 } 31639 const isRightToLeft = (0, import_i18n64.isRTL)(); 31640 if (dropZoneElement && parentBlockOrientation === "horizontal") { 31641 const rect = dropZoneElement.getBoundingClientRect(); 31642 const [distance, edge] = getDistanceToNearestEdge(position, rect, [ 31643 "left", 31644 "right" 31645 ]); 31646 if (rect.width > MINIMUM_WIDTH_FOR_THRESHOLD && distance < THRESHOLD_DISTANCE) { 31647 if (isRightToLeft && edge === "right" || !isRightToLeft && edge === "left") { 31648 return [rootBlockIndex, "before"]; 31649 } 31650 if (isRightToLeft && edge === "left" || !isRightToLeft && edge === "right") { 31651 return [rootBlockIndex + 1, "after"]; 31652 } 31653 } 31654 } 31655 blocksData.forEach( 31656 ({ 31657 isUnmodifiedDefaultBlock: isUnmodifiedDefaultBlock5, 31658 getBoundingClientRect, 31659 blockIndex, 31660 blockOrientation 31661 }) => { 31662 const rect = getBoundingClientRect(); 31663 if (!rect) { 31664 return; 31665 } 31666 let [distance, edge] = getDistanceToNearestEdge( 31667 position, 31668 rect, 31669 allowedEdges 31670 ); 31671 const [sideDistance, sideEdge] = getDistanceToNearestEdge( 31672 position, 31673 rect, 31674 ["left", "right"] 31675 ); 31676 const isPointInsideRect = isPointContainedByRect(position, rect); 31677 if (isUnmodifiedDefaultBlock5 && isPointInsideRect) { 31678 distance = 0; 31679 } else if (orientation === "vertical" && blockOrientation !== "horizontal" && (isPointInsideRect && sideDistance < THRESHOLD_DISTANCE || !isPointInsideRect && isPointWithinTopAndBottomBoundariesOfRect( 31680 position, 31681 rect 31682 ))) { 31683 targetBlockIndex = blockIndex; 31684 nearestSide = sideEdge; 31685 } 31686 if (distance < minDistance) { 31687 insertPosition = edge === "bottom" || !isRightToLeft && edge === "right" || isRightToLeft && edge === "left" ? "after" : "before"; 31688 minDistance = distance; 31689 nearestIndex = blockIndex; 31690 } 31691 } 31692 ); 31693 const adjacentIndex = nearestIndex + (insertPosition === "after" ? 1 : -1); 31694 const isNearestBlockUnmodifiedDefaultBlock = !!blocksData[nearestIndex]?.isUnmodifiedDefaultBlock; 31695 const isAdjacentBlockUnmodifiedDefaultBlock = !!blocksData[adjacentIndex]?.isUnmodifiedDefaultBlock; 31696 if (targetBlockIndex !== null) { 31697 return [targetBlockIndex, "group", nearestSide]; 31698 } 31699 if (!isNearestBlockUnmodifiedDefaultBlock && !isAdjacentBlockUnmodifiedDefaultBlock) { 31700 const insertionIndex = insertPosition === "after" ? nearestIndex + 1 : nearestIndex; 31701 return [insertionIndex, "insert"]; 31702 } 31703 return [ 31704 isNearestBlockUnmodifiedDefaultBlock ? nearestIndex : adjacentIndex, 31705 "replace" 31706 ]; 31707 } 31708 function isDropTargetValid(getBlockType21, allowedBlocks, draggedBlockNames, targetBlockName) { 31709 let areBlocksAllowed = true; 31710 if (allowedBlocks) { 31711 const allowedBlockNames = allowedBlocks?.map(({ name }) => name); 31712 areBlocksAllowed = draggedBlockNames.every( 31713 (name) => allowedBlockNames?.includes(name) 31714 ); 31715 } 31716 const draggedBlockTypes = draggedBlockNames.map( 31717 (name) => getBlockType21(name) 31718 ); 31719 const targetMatchesDraggedBlockParents = draggedBlockTypes.every( 31720 (block) => { 31721 const [allowedParentName] = block?.parent || []; 31722 if (!allowedParentName) { 31723 return true; 31724 } 31725 return allowedParentName === targetBlockName; 31726 } 31727 ); 31728 return areBlocksAllowed && targetMatchesDraggedBlockParents; 31729 } 31730 function isInsertionPoint(targetToCheck, ownerDocument) { 31731 const { defaultView } = ownerDocument; 31732 return !!(defaultView && targetToCheck instanceof defaultView.HTMLElement && targetToCheck.closest("[data-is-insertion-point]")); 31733 } 31734 function useBlockDropZone({ 31735 dropZoneElement, 31736 // An undefined value represents a top-level block. Default to an empty 31737 // string for this so that `targetRootClientId` can be easily compared to 31738 // values returned by the `getRootBlockClientId` selector, which also uses 31739 // an empty string to represent top-level blocks. 31740 rootClientId: targetRootClientId = "", 31741 parentClientId: parentBlockClientId = "", 31742 isDisabled = false 31743 } = {}) { 31744 const registry = (0, import_data71.useRegistry)(); 31745 const [dropTarget, setDropTarget] = (0, import_element86.useState)({ 31746 index: null, 31747 operation: "insert" 31748 }); 31749 const { getBlockType: getBlockType21, getBlockVariations: getBlockVariations2, getGroupingBlockName } = (0, import_data71.useSelect)(import_blocks40.store); 31750 const { 31751 canInsertBlockType: canInsertBlockType2, 31752 getBlockListSettings: getBlockListSettings2, 31753 getBlocks: getBlocks2, 31754 getBlockIndex: getBlockIndex2, 31755 getDraggedBlockClientIds: getDraggedBlockClientIds2, 31756 getBlockNamesByClientId: getBlockNamesByClientId2, 31757 getAllowedBlocks: getAllowedBlocks2, 31758 isDragging: isDragging3, 31759 isGroupable: isGroupable2, 31760 isZoomOut: isZoomOut2, 31761 getSectionRootClientId: getSectionRootClientId2, 31762 getBlockParents: getBlockParents2 31763 } = unlock((0, import_data71.useSelect)(store)); 31764 const { 31765 showInsertionPoint: showInsertionPoint2, 31766 hideInsertionPoint: hideInsertionPoint2, 31767 startDragging: startDragging2, 31768 stopDragging: stopDragging2 31769 } = unlock((0, import_data71.useDispatch)(store)); 31770 const onBlockDrop2 = useOnBlockDrop( 31771 dropTarget.operation === "before" || dropTarget.operation === "after" ? parentBlockClientId : targetRootClientId, 31772 dropTarget.index, 31773 { 31774 operation: dropTarget.operation, 31775 nearestSide: dropTarget.nearestSide 31776 } 31777 ); 31778 const throttled = (0, import_compose51.useThrottle)( 31779 (0, import_element86.useCallback)( 31780 (event, ownerDocument) => { 31781 if (!isDragging3()) { 31782 startDragging2(); 31783 } 31784 const draggedBlockClientIds = getDraggedBlockClientIds2(); 31785 const targetParents = [ 31786 targetRootClientId, 31787 ...getBlockParents2(targetRootClientId, true) 31788 ]; 31789 const isTargetWithinDraggedBlocks = draggedBlockClientIds.some( 31790 (clientId) => targetParents.includes(clientId) 31791 ); 31792 if (isTargetWithinDraggedBlocks) { 31793 return; 31794 } 31795 const allowedBlocks = getAllowedBlocks2(targetRootClientId); 31796 const targetBlockName = getBlockNamesByClientId2([ 31797 targetRootClientId 31798 ])[0]; 31799 const draggedBlockNames = getBlockNamesByClientId2( 31800 draggedBlockClientIds 31801 ); 31802 const isBlockDroppingAllowed = isDropTargetValid( 31803 getBlockType21, 31804 allowedBlocks, 31805 draggedBlockNames, 31806 targetBlockName 31807 ); 31808 if (!isBlockDroppingAllowed) { 31809 return; 31810 } 31811 const sectionRootClientId = getSectionRootClientId2(); 31812 if (isZoomOut2() && sectionRootClientId !== targetRootClientId) { 31813 return; 31814 } 31815 const blocks2 = getBlocks2(targetRootClientId).filter((block) => { 31816 return !((0, import_blocks40.hasBlockSupport)(block.name, "visibility", true) && block.attributes?.metadata?.blockVisibility === false); 31817 }); 31818 if (blocks2.length === 0) { 31819 registry.batch(() => { 31820 setDropTarget({ 31821 index: 0, 31822 operation: "insert" 31823 }); 31824 showInsertionPoint2(targetRootClientId, 0, { 31825 operation: "insert" 31826 }); 31827 }); 31828 return; 31829 } 31830 const blocksData = blocks2.map((block) => { 31831 const clientId = block.clientId; 31832 return { 31833 isUnmodifiedDefaultBlock: (0, import_blocks40.isUnmodifiedDefaultBlock)(block), 31834 getBoundingClientRect: () => { 31835 const blockElement = ownerDocument.getElementById( 31836 `block-$clientId}` 31837 ); 31838 return blockElement ? blockElement.getBoundingClientRect() : null; 31839 }, 31840 blockIndex: getBlockIndex2(clientId), 31841 blockOrientation: getBlockListSettings2(clientId)?.orientation 31842 }; 31843 }); 31844 const dropTargetPosition = getDropTargetPosition( 31845 blocksData, 31846 { x: event.clientX, y: event.clientY }, 31847 getBlockListSettings2(targetRootClientId)?.orientation, 31848 { 31849 dropZoneElement, 31850 parentBlockClientId, 31851 parentBlockOrientation: parentBlockClientId ? getBlockListSettings2(parentBlockClientId)?.orientation : void 0, 31852 rootBlockIndex: getBlockIndex2(targetRootClientId) 31853 } 31854 ); 31855 const [targetIndex, operation, nearestSide] = dropTargetPosition; 31856 const isTargetIndexEmptyDefaultBlock = blocksData[targetIndex]?.isUnmodifiedDefaultBlock; 31857 if (isZoomOut2() && !isTargetIndexEmptyDefaultBlock && operation !== "insert") { 31858 return; 31859 } 31860 if (operation === "group") { 31861 const targetBlock = blocks2[targetIndex]; 31862 const areAllImages = [ 31863 targetBlock.name, 31864 ...draggedBlockNames 31865 ].every((name) => name === "core/image"); 31866 const canInsertGalleryBlock = canInsertBlockType2( 31867 "core/gallery", 31868 targetRootClientId 31869 ); 31870 const areGroupableBlocks = isGroupable2([ 31871 targetBlock.clientId, 31872 getDraggedBlockClientIds2() 31873 ]); 31874 const groupBlockVariations = getBlockVariations2( 31875 getGroupingBlockName(), 31876 "block" 31877 ); 31878 const canInsertRow = groupBlockVariations && groupBlockVariations.find( 31879 ({ name }) => name === "group-row" 31880 ); 31881 if (areAllImages && !canInsertGalleryBlock && (!areGroupableBlocks || !canInsertRow)) { 31882 return; 31883 } 31884 if (!areAllImages && (!areGroupableBlocks || !canInsertRow)) { 31885 return; 31886 } 31887 } 31888 registry.batch(() => { 31889 setDropTarget({ 31890 index: targetIndex, 31891 operation, 31892 nearestSide 31893 }); 31894 const insertionPointClientId = [ 31895 "before", 31896 "after" 31897 ].includes(operation) ? parentBlockClientId : targetRootClientId; 31898 showInsertionPoint2(insertionPointClientId, targetIndex, { 31899 operation, 31900 nearestSide 31901 }); 31902 }); 31903 }, 31904 [ 31905 isDragging3, 31906 getAllowedBlocks2, 31907 targetRootClientId, 31908 getBlockNamesByClientId2, 31909 getDraggedBlockClientIds2, 31910 getBlockType21, 31911 getSectionRootClientId2, 31912 isZoomOut2, 31913 getBlocks2, 31914 getBlockListSettings2, 31915 dropZoneElement, 31916 parentBlockClientId, 31917 getBlockIndex2, 31918 registry, 31919 startDragging2, 31920 showInsertionPoint2, 31921 canInsertBlockType2, 31922 isGroupable2, 31923 getBlockVariations2, 31924 getGroupingBlockName 31925 ] 31926 ), 31927 200 31928 ); 31929 return (0, import_compose51.__experimentalUseDropZone)({ 31930 dropZoneElement, 31931 isDisabled, 31932 onDrop: onBlockDrop2, 31933 onDragOver(event) { 31934 throttled(event, event.currentTarget.ownerDocument); 31935 }, 31936 onDragLeave(event) { 31937 const { ownerDocument } = event.currentTarget; 31938 if (isInsertionPoint(event.relatedTarget, ownerDocument) || isInsertionPoint(event.target, ownerDocument)) { 31939 return; 31940 } 31941 throttled.cancel(); 31942 hideInsertionPoint2(); 31943 }, 31944 onDragEnd() { 31945 throttled.cancel(); 31946 stopDragging2(); 31947 hideInsertionPoint2(); 31948 } 31949 }); 31950 } 31951 31952 // packages/block-editor/build-module/components/inner-blocks/index.js 31953 var import_jsx_runtime201 = __toESM(require_jsx_runtime()); 31954 var EMPTY_OBJECT = {}; 31955 function BlockContext({ children, clientId }) { 31956 const context = useBlockContext(clientId); 31957 return /* @__PURE__ */ (0, import_jsx_runtime201.jsx)(BlockContextProvider, { value: context, children }); 31958 } 31959 var BlockListItemsMemo = (0, import_element87.memo)(BlockListItems); 31960 function UncontrolledInnerBlocks(props) { 31961 const { 31962 clientId, 31963 allowedBlocks, 31964 prioritizedInserterBlocks, 31965 defaultBlock, 31966 directInsert, 31967 __experimentalDefaultBlock, 31968 __experimentalDirectInsert, 31969 template: template2, 31970 templateLock, 31971 wrapperRef, 31972 templateInsertUpdatesSelection, 31973 __experimentalCaptureToolbars: captureToolbars, 31974 __experimentalAppenderTagName, 31975 renderAppender, 31976 orientation, 31977 placeholder, 31978 layout, 31979 name, 31980 blockType, 31981 parentLock, 31982 defaultLayout: defaultLayout2 31983 } = props; 31984 useNestedSettingsUpdate( 31985 clientId, 31986 parentLock, 31987 allowedBlocks, 31988 prioritizedInserterBlocks, 31989 defaultBlock, 31990 directInsert, 31991 __experimentalDefaultBlock, 31992 __experimentalDirectInsert, 31993 templateLock, 31994 captureToolbars, 31995 orientation, 31996 layout 31997 ); 31998 useInnerBlockTemplateSync( 31999 clientId, 32000 template2, 32001 templateLock, 32002 templateInsertUpdatesSelection 32003 ); 32004 const defaultLayoutBlockSupport = (0, import_blocks41.getBlockSupport)(name, "layout") || (0, import_blocks41.getBlockSupport)(name, "__experimentalLayout") || EMPTY_OBJECT; 32005 const { allowSizingOnChildren = false } = defaultLayoutBlockSupport; 32006 const usedLayout = layout || defaultLayoutBlockSupport; 32007 const memoedLayout = (0, import_element87.useMemo)( 32008 () => ({ 32009 // Default layout will know about any content/wide size defined by the theme. 32010 ...defaultLayout2, 32011 ...usedLayout, 32012 ...allowSizingOnChildren && { 32013 allowSizingOnChildren: true 32014 } 32015 }), 32016 [defaultLayout2, usedLayout, allowSizingOnChildren] 32017 ); 32018 const items = /* @__PURE__ */ (0, import_jsx_runtime201.jsx)( 32019 BlockListItemsMemo, 32020 { 32021 rootClientId: clientId, 32022 renderAppender, 32023 __experimentalAppenderTagName, 32024 layout: memoedLayout, 32025 wrapperRef, 32026 placeholder 32027 } 32028 ); 32029 if (!blockType?.providesContext || Object.keys(blockType.providesContext).length === 0) { 32030 return items; 32031 } 32032 return /* @__PURE__ */ (0, import_jsx_runtime201.jsx)(BlockContext, { clientId, children: items }); 32033 } 32034 function ControlledInnerBlocks(props) { 32035 useBlockSync(props); 32036 return /* @__PURE__ */ (0, import_jsx_runtime201.jsx)(UncontrolledInnerBlocks, { ...props }); 32037 } 32038 var ForwardedInnerBlocks = (0, import_element87.forwardRef)((props, ref) => { 32039 const innerBlocksProps = useInnerBlocksProps({ ref }, props); 32040 return /* @__PURE__ */ (0, import_jsx_runtime201.jsx)("div", { className: "block-editor-inner-blocks", children: /* @__PURE__ */ (0, import_jsx_runtime201.jsx)("div", { ...innerBlocksProps }) }); 32041 }); 32042 function useInnerBlocksProps(props = {}, options = {}) { 32043 const { 32044 __unstableDisableLayoutClassNames, 32045 __unstableDisableDropZone, 32046 dropZoneElement 32047 } = options; 32048 const { 32049 clientId, 32050 layout = null, 32051 __unstableLayoutClassNames: layoutClassNames = "" 32052 } = useBlockEditContext(); 32053 const selected = (0, import_data72.useSelect)( 32054 (select3) => { 32055 const { 32056 getBlockName: getBlockName2, 32057 isZoomOut: isZoomOut2, 32058 getTemplateLock: getTemplateLock2, 32059 getBlockRootClientId: getBlockRootClientId2, 32060 getBlockEditingMode: getBlockEditingMode2, 32061 getBlockSettings: getBlockSettings2, 32062 getSectionRootClientId: getSectionRootClientId2 32063 } = unlock(select3(store)); 32064 if (!clientId) { 32065 const sectionRootClientId = getSectionRootClientId2(); 32066 return { 32067 isDropZoneDisabled: isZoomOut2() && sectionRootClientId !== "" 32068 }; 32069 } 32070 const { hasBlockSupport: hasBlockSupport44, getBlockType: getBlockType21 } = select3(import_blocks41.store); 32071 const blockName = getBlockName2(clientId); 32072 const blockEditingMode = getBlockEditingMode2(clientId); 32073 const parentClientId2 = getBlockRootClientId2(clientId); 32074 const [defaultLayout22] = getBlockSettings2(clientId, "layout"); 32075 let _isDropZoneDisabled = blockEditingMode === "disabled"; 32076 if (isZoomOut2()) { 32077 const sectionRootClientId = getSectionRootClientId2(); 32078 _isDropZoneDisabled = clientId !== sectionRootClientId; 32079 } 32080 return { 32081 __experimentalCaptureToolbars: hasBlockSupport44( 32082 blockName, 32083 "__experimentalExposeControlsToChildren", 32084 false 32085 ), 32086 name: blockName, 32087 blockType: getBlockType21(blockName), 32088 parentLock: getTemplateLock2(parentClientId2), 32089 parentClientId: parentClientId2, 32090 isDropZoneDisabled: _isDropZoneDisabled, 32091 defaultLayout: defaultLayout22 32092 }; 32093 }, 32094 [clientId] 32095 ); 32096 const { 32097 __experimentalCaptureToolbars, 32098 name, 32099 blockType, 32100 parentLock, 32101 parentClientId, 32102 isDropZoneDisabled, 32103 defaultLayout: defaultLayout2 32104 } = selected; 32105 const blockDropZoneRef = useBlockDropZone({ 32106 dropZoneElement, 32107 rootClientId: clientId, 32108 parentClientId 32109 }); 32110 const ref = (0, import_compose52.useMergeRefs)([ 32111 props.ref, 32112 __unstableDisableDropZone || isDropZoneDisabled || layout?.isManualPlacement && window.__experimentalEnableGridInteractivity ? null : blockDropZoneRef 32113 ]); 32114 const innerBlocksProps = { 32115 __experimentalCaptureToolbars, 32116 layout, 32117 name, 32118 blockType, 32119 parentLock, 32120 defaultLayout: defaultLayout2, 32121 ...options 32122 }; 32123 const InnerBlocks = innerBlocksProps.value && innerBlocksProps.onChange ? ControlledInnerBlocks : UncontrolledInnerBlocks; 32124 return { 32125 ...props, 32126 ref, 32127 className: clsx_default( 32128 props.className, 32129 "block-editor-block-list__layout", 32130 __unstableDisableLayoutClassNames ? "" : layoutClassNames 32131 ), 32132 children: clientId ? /* @__PURE__ */ (0, import_jsx_runtime201.jsx)(InnerBlocks, { ...innerBlocksProps, clientId }) : /* @__PURE__ */ (0, import_jsx_runtime201.jsx)(BlockListItems, { ...options }) 32133 }; 32134 } 32135 useInnerBlocksProps.save = import_blocks41.__unstableGetInnerBlocksProps; 32136 ForwardedInnerBlocks.DefaultBlockAppender = DefaultBlockAppender2; 32137 ForwardedInnerBlocks.ButtonBlockAppender = ButtonBlockAppender2; 32138 ForwardedInnerBlocks.Content = () => useInnerBlocksProps.save().children; 32139 var inner_blocks_default = ForwardedInnerBlocks; 32140 32141 // packages/block-editor/build-module/components/observe-typing/index.js 32142 var import_compose53 = __toESM(require_compose()); 32143 var import_data73 = __toESM(require_data()); 32144 var import_dom23 = __toESM(require_dom()); 32145 var import_keycodes8 = __toESM(require_keycodes()); 32146 var import_jsx_runtime202 = __toESM(require_jsx_runtime()); 32147 var KEY_DOWN_ELIGIBLE_KEY_CODES = /* @__PURE__ */ new Set([ 32148 import_keycodes8.UP, 32149 import_keycodes8.RIGHT, 32150 import_keycodes8.DOWN, 32151 import_keycodes8.LEFT, 32152 import_keycodes8.ENTER, 32153 import_keycodes8.BACKSPACE 32154 ]); 32155 function isKeyDownEligibleForStartTyping(event) { 32156 const { keyCode, shiftKey } = event; 32157 return !shiftKey && KEY_DOWN_ELIGIBLE_KEY_CODES.has(keyCode); 32158 } 32159 function useMouseMoveTypingReset() { 32160 const isTyping3 = (0, import_data73.useSelect)( 32161 (select3) => select3(store).isTyping(), 32162 [] 32163 ); 32164 const { stopTyping: stopTyping2 } = (0, import_data73.useDispatch)(store); 32165 return (0, import_compose53.useRefEffect)( 32166 (node) => { 32167 if (!isTyping3) { 32168 return; 32169 } 32170 const { ownerDocument } = node; 32171 let lastClientX; 32172 let lastClientY; 32173 function stopTypingOnMouseMove(event) { 32174 const { clientX, clientY } = event; 32175 if (lastClientX && lastClientY && (lastClientX !== clientX || lastClientY !== clientY)) { 32176 stopTyping2(); 32177 } 32178 lastClientX = clientX; 32179 lastClientY = clientY; 32180 } 32181 ownerDocument.addEventListener( 32182 "mousemove", 32183 stopTypingOnMouseMove 32184 ); 32185 return () => { 32186 ownerDocument.removeEventListener( 32187 "mousemove", 32188 stopTypingOnMouseMove 32189 ); 32190 }; 32191 }, 32192 [isTyping3, stopTyping2] 32193 ); 32194 } 32195 function useTypingObserver() { 32196 const { isTyping: isTyping3 } = (0, import_data73.useSelect)((select3) => { 32197 const { isTyping: _isTyping } = select3(store); 32198 return { 32199 isTyping: _isTyping() 32200 }; 32201 }, []); 32202 const { startTyping: startTyping2, stopTyping: stopTyping2 } = (0, import_data73.useDispatch)(store); 32203 const ref1 = useMouseMoveTypingReset(); 32204 const ref2 = (0, import_compose53.useRefEffect)( 32205 (node) => { 32206 const { ownerDocument } = node; 32207 const { defaultView } = ownerDocument; 32208 const selection2 = defaultView.getSelection(); 32209 if (isTyping3) { 32210 let stopTypingOnNonTextField2 = function(event) { 32211 const { target } = event; 32212 timerId = defaultView.setTimeout(() => { 32213 if (!(0, import_dom23.isTextField)(target)) { 32214 stopTyping2(); 32215 } 32216 }); 32217 }, stopTypingOnEscapeKey2 = function(event) { 32218 const { keyCode } = event; 32219 if (keyCode === import_keycodes8.ESCAPE || keyCode === import_keycodes8.TAB) { 32220 stopTyping2(); 32221 } 32222 }, stopTypingOnSelectionUncollapse2 = function() { 32223 if (!selection2.isCollapsed) { 32224 stopTyping2(); 32225 } 32226 }; 32227 var stopTypingOnNonTextField = stopTypingOnNonTextField2, stopTypingOnEscapeKey = stopTypingOnEscapeKey2, stopTypingOnSelectionUncollapse = stopTypingOnSelectionUncollapse2; 32228 let timerId; 32229 node.addEventListener("focus", stopTypingOnNonTextField2); 32230 node.addEventListener("keydown", stopTypingOnEscapeKey2); 32231 ownerDocument.addEventListener( 32232 "selectionchange", 32233 stopTypingOnSelectionUncollapse2 32234 ); 32235 return () => { 32236 defaultView.clearTimeout(timerId); 32237 node.removeEventListener( 32238 "focus", 32239 stopTypingOnNonTextField2 32240 ); 32241 node.removeEventListener( 32242 "keydown", 32243 stopTypingOnEscapeKey2 32244 ); 32245 ownerDocument.removeEventListener( 32246 "selectionchange", 32247 stopTypingOnSelectionUncollapse2 32248 ); 32249 }; 32250 } 32251 function startTypingInTextField(event) { 32252 const { type, target } = event; 32253 if (!(0, import_dom23.isTextField)(target) || !node.contains(target)) { 32254 return; 32255 } 32256 if (type === "keydown" && !isKeyDownEligibleForStartTyping(event)) { 32257 return; 32258 } 32259 startTyping2(); 32260 } 32261 node.addEventListener("keypress", startTypingInTextField); 32262 node.addEventListener("keydown", startTypingInTextField); 32263 return () => { 32264 node.removeEventListener("keypress", startTypingInTextField); 32265 node.removeEventListener("keydown", startTypingInTextField); 32266 }; 32267 }, 32268 [isTyping3, startTyping2, stopTyping2] 32269 ); 32270 return (0, import_compose53.useMergeRefs)([ref1, ref2]); 32271 } 32272 function ObserveTyping({ children }) { 32273 return /* @__PURE__ */ (0, import_jsx_runtime202.jsx)("div", { ref: useTypingObserver(), children }); 32274 } 32275 var observe_typing_default = ObserveTyping; 32276 32277 // packages/block-editor/build-module/components/block-list/zoom-out-separator.js 32278 var import_components64 = __toESM(require_components()); 32279 var import_compose54 = __toESM(require_compose()); 32280 var import_data74 = __toESM(require_data()); 32281 var import_element88 = __toESM(require_element()); 32282 var import_i18n65 = __toESM(require_i18n()); 32283 var import_jsx_runtime203 = __toESM(require_jsx_runtime()); 32284 function ZoomOutSeparator({ 32285 clientId, 32286 rootClientId = "", 32287 position = "top" 32288 }) { 32289 const [isDraggedOver, setIsDraggedOver] = (0, import_element88.useState)(false); 32290 const { 32291 sectionRootClientId, 32292 sectionClientIds, 32293 insertionPoint: insertionPoint2, 32294 blockInsertionPointVisible, 32295 blockInsertionPoint, 32296 blocksBeingDragged 32297 } = (0, import_data74.useSelect)((select3) => { 32298 const { 32299 getInsertionPoint: getInsertionPoint2, 32300 getBlockOrder: getBlockOrder2, 32301 getSectionRootClientId: getSectionRootClientId2, 32302 isBlockInsertionPointVisible: isBlockInsertionPointVisible2, 32303 getBlockInsertionPoint: getBlockInsertionPoint2, 32304 getDraggedBlockClientIds: getDraggedBlockClientIds2 32305 } = unlock(select3(store)); 32306 const root = getSectionRootClientId2(); 32307 const sectionRootClientIds = getBlockOrder2(root); 32308 return { 32309 sectionRootClientId: root, 32310 sectionClientIds: sectionRootClientIds, 32311 insertionPoint: getInsertionPoint2(), 32312 blockInsertionPoint: getBlockInsertionPoint2(), 32313 blockInsertionPointVisible: isBlockInsertionPointVisible2(), 32314 blocksBeingDragged: getDraggedBlockClientIds2() 32315 }; 32316 }, []); 32317 const isReducedMotion = (0, import_compose54.useReducedMotion)(); 32318 if (!clientId) { 32319 return; 32320 } 32321 let isVisible = false; 32322 const isSectionBlock2 = rootClientId === sectionRootClientId && sectionClientIds && sectionClientIds.includes(clientId); 32323 if (!isSectionBlock2) { 32324 return null; 32325 } 32326 const hasTopInsertionPoint = insertionPoint2?.index === 0 && clientId === sectionClientIds[insertionPoint2.index]; 32327 const hasBottomInsertionPoint = insertionPoint2 && insertionPoint2.hasOwnProperty("index") && clientId === sectionClientIds[insertionPoint2.index - 1]; 32328 if (position === "top") { 32329 isVisible = hasTopInsertionPoint || blockInsertionPointVisible && blockInsertionPoint.index === 0 && clientId === sectionClientIds[blockInsertionPoint.index]; 32330 } 32331 if (position === "bottom") { 32332 isVisible = hasBottomInsertionPoint || blockInsertionPointVisible && clientId === sectionClientIds[blockInsertionPoint.index - 1]; 32333 } 32334 const blockBeingDraggedClientId = blocksBeingDragged[0]; 32335 const isCurrentBlockBeingDragged = blocksBeingDragged.includes(clientId); 32336 const blockBeingDraggedIndex = sectionClientIds.indexOf( 32337 blockBeingDraggedClientId 32338 ); 32339 const blockBeingDraggedPreviousSiblingClientId = blockBeingDraggedIndex > 0 ? sectionClientIds[blockBeingDraggedIndex - 1] : null; 32340 const isCurrentBlockPreviousSiblingOfBlockBeingDragged = blockBeingDraggedPreviousSiblingClientId === clientId; 32341 if (isCurrentBlockBeingDragged || isCurrentBlockPreviousSiblingOfBlockBeingDragged) { 32342 isVisible = false; 32343 } 32344 return /* @__PURE__ */ (0, import_jsx_runtime203.jsx)(import_components64.__unstableAnimatePresence, { children: isVisible && /* @__PURE__ */ (0, import_jsx_runtime203.jsx)( 32345 import_components64.__unstableMotion.div, 32346 { 32347 initial: { height: 0 }, 32348 animate: { 32349 // Use a height equal to that of the zoom out frame size. 32350 height: "calc(1 * var(--wp-block-editor-iframe-zoom-out-frame-size) / var(--wp-block-editor-iframe-zoom-out-scale)" 32351 }, 32352 exit: { height: 0 }, 32353 transition: { 32354 type: "tween", 32355 duration: isReducedMotion ? 0 : 0.2, 32356 ease: [0.6, 0, 0.4, 1] 32357 }, 32358 className: clsx_default( 32359 "block-editor-block-list__zoom-out-separator", 32360 { 32361 "is-dragged-over": isDraggedOver 32362 } 32363 ), 32364 "data-is-insertion-point": "true", 32365 onDragOver: () => setIsDraggedOver(true), 32366 onDragLeave: () => setIsDraggedOver(false), 32367 children: /* @__PURE__ */ (0, import_jsx_runtime203.jsx)( 32368 import_components64.__unstableMotion.div, 32369 { 32370 initial: { opacity: 0 }, 32371 animate: { opacity: 1 }, 32372 exit: { opacity: 0, transition: { delay: -0.125 } }, 32373 transition: { 32374 ease: "linear", 32375 duration: 0.1, 32376 delay: 0.125 32377 }, 32378 children: (0, import_i18n65.__)("Drop pattern.") 32379 } 32380 ) 32381 } 32382 ) }); 32383 } 32384 32385 // packages/block-editor/build-module/components/block-list/index.js 32386 var import_jsx_runtime204 = __toESM(require_jsx_runtime()); 32387 var IntersectionObserver = (0, import_element89.createContext)(); 32388 IntersectionObserver.displayName = "IntersectionObserverContext"; 32389 var pendingBlockVisibilityUpdatesPerRegistry = /* @__PURE__ */ new WeakMap(); 32390 var delayedBlockVisibilityDebounceOptions = { 32391 trailing: true 32392 }; 32393 function Root({ className, ...settings2 }) { 32394 const { isOutlineMode, isFocusMode, editedContentOnlySection: editedContentOnlySection2 } = (0, import_data75.useSelect)( 32395 (select3) => { 32396 const { 32397 getSettings: getSettings8, 32398 isTyping: isTyping3, 32399 hasBlockSpotlight: hasBlockSpotlight3, 32400 getEditedContentOnlySection: getEditedContentOnlySection2 32401 } = unlock(select3(store)); 32402 const { outlineMode, focusMode } = getSettings8(); 32403 return { 32404 isOutlineMode: outlineMode && !isTyping3(), 32405 isFocusMode: focusMode || hasBlockSpotlight3(), 32406 editedContentOnlySection: getEditedContentOnlySection2() 32407 }; 32408 }, 32409 [] 32410 ); 32411 const registry = (0, import_data75.useRegistry)(); 32412 const { setBlockVisibility: setBlockVisibility2 } = (0, import_data75.useDispatch)(store); 32413 const delayedBlockVisibilityUpdates = (0, import_compose55.useDebounce)( 32414 (0, import_element89.useCallback)(() => { 32415 const updates = {}; 32416 pendingBlockVisibilityUpdatesPerRegistry.get(registry).forEach(([id, isIntersecting]) => { 32417 updates[id] = isIntersecting; 32418 }); 32419 setBlockVisibility2(updates); 32420 }, [registry]), 32421 300, 32422 delayedBlockVisibilityDebounceOptions 32423 ); 32424 const intersectionObserver = (0, import_element89.useMemo)(() => { 32425 const { IntersectionObserver: Observer } = window; 32426 if (!Observer) { 32427 return; 32428 } 32429 return new Observer((entries) => { 32430 if (!pendingBlockVisibilityUpdatesPerRegistry.get(registry)) { 32431 pendingBlockVisibilityUpdatesPerRegistry.set(registry, []); 32432 } 32433 for (const entry of entries) { 32434 const clientId = entry.target.getAttribute("data-block"); 32435 pendingBlockVisibilityUpdatesPerRegistry.get(registry).push([clientId, entry.isIntersecting]); 32436 } 32437 delayedBlockVisibilityUpdates(); 32438 }); 32439 }, []); 32440 const innerBlocksProps = useInnerBlocksProps( 32441 { 32442 ref: (0, import_compose55.useMergeRefs)([ 32443 useBlockSelectionClearer(), 32444 useInBetweenInserter(), 32445 useTypingObserver() 32446 ]), 32447 className: clsx_default("is-root-container", className, { 32448 "is-outline-mode": isOutlineMode, 32449 "is-focus-mode": isFocusMode 32450 }) 32451 }, 32452 settings2 32453 ); 32454 return /* @__PURE__ */ (0, import_jsx_runtime204.jsxs)(IntersectionObserver.Provider, { value: intersectionObserver, children: [ 32455 /* @__PURE__ */ (0, import_jsx_runtime204.jsx)("div", { ...innerBlocksProps }), 32456 !!editedContentOnlySection2 && /* @__PURE__ */ (0, import_jsx_runtime204.jsx)( 32457 StopEditingContentOnlySectionOnOutsideSelect, 32458 { 32459 clientId: editedContentOnlySection2 32460 } 32461 ) 32462 ] }); 32463 } 32464 function StopEditingContentOnlySectionOnOutsideSelect({ clientId }) { 32465 const { stopEditingContentOnlySection: stopEditingContentOnlySection2 } = unlock( 32466 (0, import_data75.useDispatch)(store) 32467 ); 32468 const isBlockOrDescendantSelected = (0, import_data75.useSelect)( 32469 (select3) => { 32470 const { 32471 isBlockSelected: isBlockSelected2, 32472 hasSelectedInnerBlock: hasSelectedInnerBlock2, 32473 getBlockSelectionStart: getBlockSelectionStart2 32474 } = select3(store); 32475 return !getBlockSelectionStart2() || isBlockSelected2(clientId) || hasSelectedInnerBlock2(clientId, true); 32476 }, 32477 [clientId] 32478 ); 32479 (0, import_element89.useEffect)(() => { 32480 if (!isBlockOrDescendantSelected) { 32481 stopEditingContentOnlySection2(); 32482 } 32483 }, [isBlockOrDescendantSelected, stopEditingContentOnlySection2]); 32484 return null; 32485 } 32486 function BlockList(settings2) { 32487 return /* @__PURE__ */ (0, import_jsx_runtime204.jsx)(Provider, { value: DEFAULT_BLOCK_EDIT_CONTEXT, children: /* @__PURE__ */ (0, import_jsx_runtime204.jsx)(Root, { ...settings2 }) }); 32488 } 32489 var EMPTY_ARRAY7 = []; 32490 var EMPTY_SET2 = /* @__PURE__ */ new Set(); 32491 function Items({ 32492 placeholder, 32493 rootClientId, 32494 renderAppender: CustomAppender, 32495 __experimentalAppenderTagName, 32496 layout = defaultLayout 32497 }) { 32498 const hasAppender = CustomAppender !== false; 32499 const hasCustomAppender = !!CustomAppender; 32500 const { 32501 order, 32502 isZoomOut: isZoomOut2, 32503 selectedBlocks, 32504 visibleBlocks, 32505 shouldRenderAppender 32506 } = (0, import_data75.useSelect)( 32507 (select3) => { 32508 const { 32509 getSettings: getSettings8, 32510 getBlockOrder: getBlockOrder2, 32511 getSelectedBlockClientIds: getSelectedBlockClientIds2, 32512 __unstableGetVisibleBlocks: __unstableGetVisibleBlocks2, 32513 getTemplateLock: getTemplateLock2, 32514 getBlockEditingMode: getBlockEditingMode2, 32515 isSectionBlock: isSectionBlock2, 32516 isContainerInsertableToInContentOnlyMode: isContainerInsertableToInContentOnlyMode2, 32517 getBlockName: getBlockName2, 32518 isZoomOut: _isZoomOut, 32519 canInsertBlockType: canInsertBlockType2 32520 } = unlock(select3(store)); 32521 const _order = getBlockOrder2(rootClientId); 32522 if (getSettings8().isPreviewMode) { 32523 return { 32524 order: _order, 32525 selectedBlocks: EMPTY_ARRAY7, 32526 visibleBlocks: EMPTY_SET2 32527 }; 32528 } 32529 const selectedBlockClientIds = getSelectedBlockClientIds2(); 32530 const selectedBlockClientId = selectedBlockClientIds[0]; 32531 const showRootAppender = !rootClientId && !selectedBlockClientId && (!_order.length || !canInsertBlockType2( 32532 (0, import_blocks42.getDefaultBlockName)(), 32533 rootClientId 32534 )); 32535 const hasSelectedRoot = !!(rootClientId && selectedBlockClientId && rootClientId === selectedBlockClientId); 32536 const templateLock = getTemplateLock2(rootClientId); 32537 return { 32538 order: _order, 32539 selectedBlocks: selectedBlockClientIds, 32540 visibleBlocks: __unstableGetVisibleBlocks2(), 32541 isZoomOut: _isZoomOut(), 32542 shouldRenderAppender: (!isSectionBlock2(rootClientId) || isContainerInsertableToInContentOnlyMode2( 32543 getBlockName2(selectedBlockClientId), 32544 rootClientId 32545 )) && getBlockEditingMode2(rootClientId) !== "disabled" && (!templateLock || templateLock === "contentOnly") && hasAppender && !_isZoomOut() && (hasCustomAppender || hasSelectedRoot || showRootAppender) 32546 }; 32547 }, 32548 [rootClientId, hasAppender, hasCustomAppender] 32549 ); 32550 return /* @__PURE__ */ (0, import_jsx_runtime204.jsxs)(LayoutProvider, { value: layout, children: [ 32551 order.map((clientId) => /* @__PURE__ */ (0, import_jsx_runtime204.jsxs)( 32552 import_data75.AsyncModeProvider, 32553 { 32554 value: ( 32555 // Only provide data asynchronously if the block is 32556 // not visible and not selected. 32557 !visibleBlocks.has(clientId) && !selectedBlocks.includes(clientId) 32558 ), 32559 children: [ 32560 isZoomOut2 && /* @__PURE__ */ (0, import_jsx_runtime204.jsx)( 32561 ZoomOutSeparator, 32562 { 32563 clientId, 32564 rootClientId, 32565 position: "top" 32566 } 32567 ), 32568 /* @__PURE__ */ (0, import_jsx_runtime204.jsx)( 32569 block_default2, 32570 { 32571 rootClientId, 32572 clientId 32573 } 32574 ), 32575 isZoomOut2 && /* @__PURE__ */ (0, import_jsx_runtime204.jsx)( 32576 ZoomOutSeparator, 32577 { 32578 clientId, 32579 rootClientId, 32580 position: "bottom" 32581 } 32582 ) 32583 ] 32584 }, 32585 clientId 32586 )), 32587 order.length < 1 && placeholder, 32588 shouldRenderAppender && /* @__PURE__ */ (0, import_jsx_runtime204.jsx)( 32589 BlockListAppender, 32590 { 32591 tagName: __experimentalAppenderTagName, 32592 rootClientId, 32593 CustomAppender 32594 } 32595 ) 32596 ] }); 32597 } 32598 function BlockListItems(props) { 32599 return /* @__PURE__ */ (0, import_jsx_runtime204.jsx)(import_data75.AsyncModeProvider, { value: false, children: /* @__PURE__ */ (0, import_jsx_runtime204.jsx)(Items, { ...props }) }); 32600 } 32601 32602 // packages/block-editor/build-module/components/block-tools/index.js 32603 var import_data120 = __toESM(require_data()); 32604 var import_dom28 = __toESM(require_dom()); 32605 var import_components114 = __toESM(require_components()); 32606 var import_keyboard_shortcuts8 = __toESM(require_keyboard_shortcuts()); 32607 var import_element123 = __toESM(require_element()); 32608 var import_blocks74 = __toESM(require_blocks()); 32609 var import_a11y12 = __toESM(require_a11y()); 32610 var import_i18n101 = __toESM(require_i18n()); 32611 32612 // packages/block-editor/build-module/components/block-tools/use-block-toolbar-popover-props.js 32613 var import_compose58 = __toESM(require_compose()); 32614 var import_data79 = __toESM(require_data()); 32615 var import_dom24 = __toESM(require_dom()); 32616 var import_element94 = __toESM(require_element()); 32617 32618 // packages/block-editor/build-module/hooks/position.js 32619 var import_i18n67 = __toESM(require_i18n()); 32620 var import_blocks44 = __toESM(require_blocks()); 32621 var import_components70 = __toESM(require_components()); 32622 var import_compose57 = __toESM(require_compose()); 32623 var import_data78 = __toESM(require_data()); 32624 var import_element93 = __toESM(require_element()); 32625 32626 // packages/block-editor/build-module/components/inspector-controls/fill.js 32627 var import_components66 = __toESM(require_components()); 32628 var import_warning5 = __toESM(require_warning()); 32629 var import_deprecated10 = __toESM(require_deprecated()); 32630 var import_element90 = __toESM(require_element()); 32631 32632 // packages/block-editor/build-module/components/inspector-controls/groups.js 32633 var import_components65 = __toESM(require_components()); 32634 var InspectorControlsDefault = (0, import_components65.createSlotFill)("InspectorControls"); 32635 var InspectorControlsAdvanced = (0, import_components65.createSlotFill)("InspectorAdvancedControls"); 32636 var InspectorControlsBindings = (0, import_components65.createSlotFill)("InspectorControlsBindings"); 32637 var InspectorControlsBackground = (0, import_components65.createSlotFill)( 32638 "InspectorControlsBackground" 32639 ); 32640 var InspectorControlsBorder = (0, import_components65.createSlotFill)("InspectorControlsBorder"); 32641 var InspectorControlsColor = (0, import_components65.createSlotFill)("InspectorControlsColor"); 32642 var InspectorControlsFilter = (0, import_components65.createSlotFill)("InspectorControlsFilter"); 32643 var InspectorControlsDimensions = (0, import_components65.createSlotFill)( 32644 "InspectorControlsDimensions" 32645 ); 32646 var InspectorControlsPosition = (0, import_components65.createSlotFill)("InspectorControlsPosition"); 32647 var InspectorControlsTypography = (0, import_components65.createSlotFill)( 32648 "InspectorControlsTypography" 32649 ); 32650 var InspectorControlsListView = (0, import_components65.createSlotFill)("InspectorControlsListView"); 32651 var InspectorControlsStyles = (0, import_components65.createSlotFill)("InspectorControlsStyles"); 32652 var InspectorControlsEffects = (0, import_components65.createSlotFill)("InspectorControlsEffects"); 32653 var groups = { 32654 default: InspectorControlsDefault, 32655 advanced: InspectorControlsAdvanced, 32656 background: InspectorControlsBackground, 32657 bindings: InspectorControlsBindings, 32658 border: InspectorControlsBorder, 32659 color: InspectorControlsColor, 32660 dimensions: InspectorControlsDimensions, 32661 effects: InspectorControlsEffects, 32662 filter: InspectorControlsFilter, 32663 list: InspectorControlsListView, 32664 position: InspectorControlsPosition, 32665 settings: InspectorControlsDefault, 32666 // Alias for default. 32667 styles: InspectorControlsStyles, 32668 typography: InspectorControlsTypography 32669 }; 32670 var groups_default = groups; 32671 var PrivateInspectorControlsAllowedBlocks = (0, import_components65.createSlotFill)( 32672 Symbol("PrivateInspectorControlsAllowedBlocks") 32673 ); 32674 32675 // packages/block-editor/build-module/components/inspector-controls/fill.js 32676 var import_jsx_runtime205 = __toESM(require_jsx_runtime()); 32677 function InspectorControlsFill({ 32678 children, 32679 group = "default", 32680 __experimentalGroup, 32681 resetAllFilter 32682 }) { 32683 if (__experimentalGroup) { 32684 (0, import_deprecated10.default)( 32685 "`__experimentalGroup` property in `InspectorControlsFill`", 32686 { 32687 since: "6.2", 32688 version: "6.4", 32689 alternative: "`group`" 32690 } 32691 ); 32692 group = __experimentalGroup; 32693 } 32694 const context = useBlockEditContext(); 32695 const Fill3 = groups_default[group]?.Fill; 32696 if (!Fill3) { 32697 (0, import_warning5.default)(`Unknown InspectorControls group "$group}" provided.`); 32698 return null; 32699 } 32700 if (!context[mayDisplayControlsKey]) { 32701 return null; 32702 } 32703 return /* @__PURE__ */ (0, import_jsx_runtime205.jsx)(import_components66.__experimentalStyleProvider, { document, children: /* @__PURE__ */ (0, import_jsx_runtime205.jsx)(Fill3, { children: (fillProps) => { 32704 return /* @__PURE__ */ (0, import_jsx_runtime205.jsx)( 32705 ToolsPanelInspectorControl, 32706 { 32707 fillProps, 32708 children, 32709 resetAllFilter 32710 } 32711 ); 32712 } }) }); 32713 } 32714 function RegisterResetAll({ resetAllFilter, children }) { 32715 const { registerResetAllFilter, deregisterResetAllFilter } = (0, import_element90.useContext)(import_components66.__experimentalToolsPanelContext); 32716 (0, import_element90.useEffect)(() => { 32717 if (resetAllFilter && registerResetAllFilter && deregisterResetAllFilter) { 32718 registerResetAllFilter(resetAllFilter); 32719 return () => { 32720 deregisterResetAllFilter(resetAllFilter); 32721 }; 32722 } 32723 }, [resetAllFilter, registerResetAllFilter, deregisterResetAllFilter]); 32724 return children; 32725 } 32726 function ToolsPanelInspectorControl({ children, resetAllFilter, fillProps }) { 32727 const { forwardedContext = [] } = fillProps; 32728 const innerMarkup = /* @__PURE__ */ (0, import_jsx_runtime205.jsx)(RegisterResetAll, { resetAllFilter, children }); 32729 return forwardedContext.reduce( 32730 (inner, [Provider2, props]) => /* @__PURE__ */ (0, import_jsx_runtime205.jsx)(Provider2, { ...props, children: inner }), 32731 innerMarkup 32732 ); 32733 } 32734 32735 // packages/block-editor/build-module/components/inspector-controls/slot.js 32736 var import_components69 = __toESM(require_components()); 32737 var import_warning6 = __toESM(require_warning()); 32738 var import_deprecated11 = __toESM(require_deprecated()); 32739 32740 // packages/block-editor/build-module/components/inspector-controls/block-support-tools-panel.js 32741 var import_components67 = __toESM(require_components()); 32742 var import_data76 = __toESM(require_data()); 32743 var import_element91 = __toESM(require_element()); 32744 32745 // packages/block-editor/build-module/components/global-styles/utils.js 32746 var import_compose56 = __toESM(require_compose()); 32747 function useToolsPanelDropdownMenuProps() { 32748 const isMobile = (0, import_compose56.useViewportMatch)("medium", "<"); 32749 return !isMobile ? { 32750 popoverProps: { 32751 placement: "left-start", 32752 // For non-mobile, inner sidebar width (248px) - button width (24px) - border (1px) + padding (16px) + spacing (20px) 32753 offset: 259 32754 } 32755 } : {}; 32756 } 32757 function scopeSelector(scope, selector3) { 32758 if (!scope || !selector3) { 32759 return selector3; 32760 } 32761 const scopes = scope.split(","); 32762 const selectors = selector3.split(","); 32763 const selectorsScoped = []; 32764 scopes.forEach((outer) => { 32765 selectors.forEach((inner) => { 32766 selectorsScoped.push(`$outer.trim()} $inner.trim()}`); 32767 }); 32768 }); 32769 return selectorsScoped.join(", "); 32770 } 32771 32772 // packages/block-editor/build-module/components/inspector-controls/block-support-tools-panel.js 32773 var import_jsx_runtime206 = __toESM(require_jsx_runtime()); 32774 function BlockSupportToolsPanel({ children, group, label }) { 32775 const { updateBlockAttributes: updateBlockAttributes2 } = (0, import_data76.useDispatch)(store); 32776 const { 32777 getBlockAttributes: getBlockAttributes3, 32778 getMultiSelectedBlockClientIds: getMultiSelectedBlockClientIds2, 32779 getSelectedBlockClientId: getSelectedBlockClientId2, 32780 hasMultiSelection: hasMultiSelection2 32781 } = (0, import_data76.useSelect)(store); 32782 const dropdownMenuProps = useToolsPanelDropdownMenuProps(); 32783 const panelId = getSelectedBlockClientId2(); 32784 const resetAll = (0, import_element91.useCallback)( 32785 (resetFilters = []) => { 32786 const newAttributes = {}; 32787 const clientIds = hasMultiSelection2() ? getMultiSelectedBlockClientIds2() : [panelId]; 32788 clientIds.forEach((clientId) => { 32789 const { style } = getBlockAttributes3(clientId); 32790 let newBlockAttributes = { style }; 32791 resetFilters.forEach((resetFilter) => { 32792 newBlockAttributes = { 32793 ...newBlockAttributes, 32794 ...resetFilter(newBlockAttributes) 32795 }; 32796 }); 32797 newBlockAttributes = { 32798 ...newBlockAttributes, 32799 style: cleanEmptyObject(newBlockAttributes.style) 32800 }; 32801 newAttributes[clientId] = newBlockAttributes; 32802 }); 32803 updateBlockAttributes2(clientIds, newAttributes, true); 32804 }, 32805 [ 32806 getBlockAttributes3, 32807 getMultiSelectedBlockClientIds2, 32808 hasMultiSelection2, 32809 panelId, 32810 updateBlockAttributes2 32811 ] 32812 ); 32813 return /* @__PURE__ */ (0, import_jsx_runtime206.jsx)( 32814 import_components67.__experimentalToolsPanel, 32815 { 32816 className: `$group}-block-support-panel`, 32817 label, 32818 resetAll, 32819 panelId, 32820 hasInnerWrapper: true, 32821 shouldRenderPlaceholderItems: true, 32822 __experimentalFirstVisibleItemClass: "first", 32823 __experimentalLastVisibleItemClass: "last", 32824 dropdownMenuProps, 32825 children 32826 }, 32827 panelId 32828 ); 32829 } 32830 32831 // packages/block-editor/build-module/components/inspector-controls/block-support-slot-container.js 32832 var import_components68 = __toESM(require_components()); 32833 var import_element92 = __toESM(require_element()); 32834 var import_jsx_runtime207 = __toESM(require_jsx_runtime()); 32835 function BlockSupportSlotContainer({ 32836 Slot: Slot6, 32837 fillProps, 32838 ...props 32839 }) { 32840 const toolsPanelContext = (0, import_element92.useContext)(import_components68.__experimentalToolsPanelContext); 32841 const computedFillProps = (0, import_element92.useMemo)( 32842 () => ({ 32843 ...fillProps ?? {}, 32844 forwardedContext: [ 32845 ...fillProps?.forwardedContext ?? [], 32846 [import_components68.__experimentalToolsPanelContext.Provider, { value: toolsPanelContext }] 32847 ] 32848 }), 32849 [toolsPanelContext, fillProps] 32850 ); 32851 return /* @__PURE__ */ (0, import_jsx_runtime207.jsx)(Slot6, { ...props, fillProps: computedFillProps, bubblesVirtually: true }); 32852 } 32853 32854 // packages/block-editor/build-module/components/inspector-controls/slot.js 32855 var import_jsx_runtime208 = __toESM(require_jsx_runtime()); 32856 function InspectorControlsSlot({ 32857 __experimentalGroup, 32858 group = "default", 32859 label, 32860 fillProps, 32861 ...props 32862 }) { 32863 if (__experimentalGroup) { 32864 (0, import_deprecated11.default)( 32865 "`__experimentalGroup` property in `InspectorControlsSlot`", 32866 { 32867 since: "6.2", 32868 version: "6.4", 32869 alternative: "`group`" 32870 } 32871 ); 32872 group = __experimentalGroup; 32873 } 32874 const slotFill = groups_default[group]; 32875 const fills = (0, import_components69.__experimentalUseSlotFills)(slotFill?.name); 32876 if (!slotFill) { 32877 (0, import_warning6.default)(`Unknown InspectorControls group "$group}" provided.`); 32878 return null; 32879 } 32880 if (!fills?.length) { 32881 return null; 32882 } 32883 const { Slot: Slot6 } = slotFill; 32884 if (label) { 32885 return /* @__PURE__ */ (0, import_jsx_runtime208.jsx)(BlockSupportToolsPanel, { group, label, children: /* @__PURE__ */ (0, import_jsx_runtime208.jsx)( 32886 BlockSupportSlotContainer, 32887 { 32888 ...props, 32889 fillProps, 32890 Slot: Slot6 32891 } 32892 ) }); 32893 } 32894 return /* @__PURE__ */ (0, import_jsx_runtime208.jsx)(Slot6, { ...props, fillProps, bubblesVirtually: true }); 32895 } 32896 32897 // packages/block-editor/build-module/components/inspector-controls/index.js 32898 var import_jsx_runtime209 = __toESM(require_jsx_runtime()); 32899 var InspectorControls = InspectorControlsFill; 32900 InspectorControls.Slot = InspectorControlsSlot; 32901 var InspectorAdvancedControls = (props) => { 32902 return /* @__PURE__ */ (0, import_jsx_runtime209.jsx)(InspectorControlsFill, { ...props, group: "advanced" }); 32903 }; 32904 InspectorAdvancedControls.Slot = (props) => { 32905 return /* @__PURE__ */ (0, import_jsx_runtime209.jsx)(InspectorControlsSlot, { ...props, group: "advanced" }); 32906 }; 32907 InspectorAdvancedControls.slotName = "InspectorAdvancedControls"; 32908 var inspector_controls_default = InspectorControls; 32909 32910 // packages/block-editor/build-module/components/use-block-display-information/index.js 32911 var import_data77 = __toESM(require_data()); 32912 var import_blocks43 = __toESM(require_blocks()); 32913 var import_i18n66 = __toESM(require_i18n()); 32914 function getPositionTypeLabel(attributes) { 32915 const positionType = attributes?.style?.position?.type; 32916 if (positionType === "sticky") { 32917 return (0, import_i18n66.__)("Sticky"); 32918 } 32919 if (positionType === "fixed") { 32920 return (0, import_i18n66.__)("Fixed"); 32921 } 32922 return null; 32923 } 32924 function useBlockDisplayInformation(clientId) { 32925 return (0, import_data77.useSelect)( 32926 (select3) => { 32927 if (!clientId) { 32928 return null; 32929 } 32930 const { 32931 getBlockName: getBlockName2, 32932 getBlockAttributes: getBlockAttributes3, 32933 __experimentalGetParsedPattern: __experimentalGetParsedPattern2 32934 } = select3(store); 32935 const { getBlockType: getBlockType21, getActiveBlockVariation } = select3(import_blocks43.store); 32936 const blockName = getBlockName2(clientId); 32937 const blockType = getBlockType21(blockName); 32938 if (!blockType) { 32939 return null; 32940 } 32941 const attributes = getBlockAttributes3(clientId); 32942 const patternName = attributes?.metadata?.patternName; 32943 if (patternName && window?.__experimentalContentOnlyPatternInsertion) { 32944 const pattern = __experimentalGetParsedPattern2(patternName); 32945 const positionLabel2 = getPositionTypeLabel(attributes); 32946 return { 32947 isSynced: false, 32948 title: (0, import_i18n66.__)("Pattern"), 32949 icon: symbol_default, 32950 description: pattern?.description || (0, import_i18n66.__)("A block pattern."), 32951 anchor: attributes?.anchor, 32952 positionLabel: positionLabel2, 32953 positionType: attributes?.style?.position?.type, 32954 name: pattern?.title || attributes?.metadata?.name 32955 }; 32956 } 32957 const match2 = getActiveBlockVariation(blockName, attributes); 32958 const isSynced = (0, import_blocks43.isReusableBlock)(blockType) || (0, import_blocks43.isTemplatePart)(blockType); 32959 const syncedTitle = isSynced ? (0, import_blocks43.__experimentalGetBlockLabel)(blockType, attributes) : void 0; 32960 const title = syncedTitle || blockType.title; 32961 const positionLabel = getPositionTypeLabel(attributes); 32962 const blockTypeInfo = { 32963 isSynced, 32964 title, 32965 icon: blockType.icon, 32966 description: blockType.description, 32967 anchor: attributes?.anchor, 32968 positionLabel, 32969 positionType: attributes?.style?.position?.type, 32970 name: attributes?.metadata?.name 32971 }; 32972 if (!match2) { 32973 return blockTypeInfo; 32974 } 32975 return { 32976 isSynced, 32977 title: match2.title || blockType.title, 32978 icon: match2.icon || blockType.icon, 32979 description: match2.description || blockType.description, 32980 anchor: attributes?.anchor, 32981 positionLabel, 32982 positionType: attributes?.style?.position?.type, 32983 name: attributes?.metadata?.name 32984 }; 32985 }, 32986 [clientId] 32987 ); 32988 } 32989 32990 // packages/block-editor/build-module/hooks/position.js 32991 var import_jsx_runtime210 = __toESM(require_jsx_runtime()); 32992 var POSITION_SUPPORT_KEY = "position"; 32993 var DEFAULT_OPTION = { 32994 key: "default", 32995 value: "", 32996 name: (0, import_i18n67.__)("Default") 32997 }; 32998 var STICKY_OPTION = { 32999 key: "sticky", 33000 value: "sticky", 33001 name: (0, import_i18n67._x)("Sticky", "Name for the value of the CSS position property"), 33002 hint: (0, import_i18n67.__)( 33003 "The block will stick to the top of the window instead of scrolling." 33004 ) 33005 }; 33006 var FIXED_OPTION = { 33007 key: "fixed", 33008 value: "fixed", 33009 name: (0, import_i18n67._x)("Fixed", "Name for the value of the CSS position property"), 33010 hint: (0, import_i18n67.__)("The block will not move when the page is scrolled.") 33011 }; 33012 var POSITION_SIDES = ["top", "right", "bottom", "left"]; 33013 var VALID_POSITION_TYPES = ["sticky", "fixed"]; 33014 function getPositionCSS({ selector: selector3, style }) { 33015 let output = ""; 33016 const { type: positionType } = style?.position || {}; 33017 if (!VALID_POSITION_TYPES.includes(positionType)) { 33018 return output; 33019 } 33020 output += `$selector3} {`; 33021 output += `position: $positionType};`; 33022 POSITION_SIDES.forEach((side) => { 33023 if (style?.position?.[side] !== void 0) { 33024 output += `$side}: $style.position[side]};`; 33025 } 33026 }); 33027 if (positionType === "sticky" || positionType === "fixed") { 33028 output += `z-index: 10`; 33029 } 33030 output += `}`; 33031 return output; 33032 } 33033 function hasStickyPositionSupport(blockType) { 33034 const support = (0, import_blocks44.getBlockSupport)(blockType, POSITION_SUPPORT_KEY); 33035 return !!(true === support || support?.sticky); 33036 } 33037 function hasFixedPositionSupport(blockType) { 33038 const support = (0, import_blocks44.getBlockSupport)(blockType, POSITION_SUPPORT_KEY); 33039 return !!(true === support || support?.fixed); 33040 } 33041 function hasPositionSupport(blockType) { 33042 const support = (0, import_blocks44.getBlockSupport)(blockType, POSITION_SUPPORT_KEY); 33043 return !!support; 33044 } 33045 function hasStickyOrFixedPositionValue(attributes) { 33046 const positionType = attributes?.style?.position?.type; 33047 return positionType === "sticky" || positionType === "fixed"; 33048 } 33049 function useIsPositionDisabled({ name: blockName } = {}) { 33050 const [allowFixed, allowSticky] = useSettings( 33051 "position.fixed", 33052 "position.sticky" 33053 ); 33054 const isDisabled = !allowFixed && !allowSticky; 33055 return !hasPositionSupport(blockName) || isDisabled; 33056 } 33057 function PositionPanelPure({ 33058 style = {}, 33059 clientId, 33060 name: blockName, 33061 setAttributes 33062 }) { 33063 const allowFixed = hasFixedPositionSupport(blockName); 33064 const allowSticky = hasStickyPositionSupport(blockName); 33065 const value = style?.position?.type; 33066 const { firstParentClientId } = (0, import_data78.useSelect)( 33067 (select3) => { 33068 const { getBlockParents: getBlockParents2 } = select3(store); 33069 const parents = getBlockParents2(clientId); 33070 return { firstParentClientId: parents[parents.length - 1] }; 33071 }, 33072 [clientId] 33073 ); 33074 const blockInformation = useBlockDisplayInformation(firstParentClientId); 33075 const stickyHelpText = allowSticky && value === STICKY_OPTION.value && blockInformation ? (0, import_i18n67.sprintf)( 33076 /* translators: %s: the name of the parent block. */ 33077 (0, import_i18n67.__)( 33078 "The block will stick to the scrollable area of the parent %s block." 33079 ), 33080 blockInformation.title 33081 ) : null; 33082 const options = (0, import_element93.useMemo)(() => { 33083 const availableOptions = [DEFAULT_OPTION]; 33084 if (allowSticky || value === STICKY_OPTION.value) { 33085 availableOptions.push(STICKY_OPTION); 33086 } 33087 if (allowFixed || value === FIXED_OPTION.value) { 33088 availableOptions.push(FIXED_OPTION); 33089 } 33090 return availableOptions; 33091 }, [allowFixed, allowSticky, value]); 33092 const onChangeType = (next) => { 33093 const placementValue = "0px"; 33094 const newStyle = { 33095 ...style, 33096 position: { 33097 ...style?.position, 33098 type: next, 33099 top: next === "sticky" || next === "fixed" ? placementValue : void 0 33100 } 33101 }; 33102 setAttributes({ 33103 style: cleanEmptyObject(newStyle) 33104 }); 33105 }; 33106 const selectedOption = value ? options.find((option) => option.value === value) || DEFAULT_OPTION : DEFAULT_OPTION; 33107 return import_element93.Platform.select({ 33108 web: options.length > 1 ? /* @__PURE__ */ (0, import_jsx_runtime210.jsx)(inspector_controls_default, { group: "position", children: /* @__PURE__ */ (0, import_jsx_runtime210.jsx)(import_components70.BaseControl, { help: stickyHelpText, children: /* @__PURE__ */ (0, import_jsx_runtime210.jsx)( 33109 import_components70.CustomSelectControl, 33110 { 33111 __next40pxDefaultSize: true, 33112 label: (0, import_i18n67.__)("Position"), 33113 hideLabelFromVision: true, 33114 describedBy: (0, import_i18n67.sprintf)( 33115 // translators: %s: Currently selected position. 33116 (0, import_i18n67.__)("Currently selected position: %s"), 33117 selectedOption.name 33118 ), 33119 options, 33120 value: selectedOption, 33121 onChange: ({ selectedItem }) => { 33122 onChangeType(selectedItem.value); 33123 }, 33124 size: "__unstable-large" 33125 } 33126 ) }) }) : null, 33127 native: null 33128 }); 33129 } 33130 var position_default = { 33131 edit: function Edit2(props) { 33132 const isPositionDisabled = useIsPositionDisabled(props); 33133 if (isPositionDisabled) { 33134 return null; 33135 } 33136 return /* @__PURE__ */ (0, import_jsx_runtime210.jsx)(PositionPanelPure, { ...props }); 33137 }, 33138 useBlockProps: useBlockProps2, 33139 attributeKeys: ["style"], 33140 hasSupport(name) { 33141 return (0, import_blocks44.hasBlockSupport)(name, POSITION_SUPPORT_KEY); 33142 } 33143 }; 33144 var POSITION_BLOCK_PROPS_REFERENCE = {}; 33145 function useBlockProps2({ name, style }) { 33146 const hasPositionBlockSupport = (0, import_blocks44.hasBlockSupport)( 33147 name, 33148 POSITION_SUPPORT_KEY 33149 ); 33150 const isPositionDisabled = useIsPositionDisabled({ name }); 33151 const allowPositionStyles = hasPositionBlockSupport && !isPositionDisabled; 33152 const id = (0, import_compose57.useInstanceId)(POSITION_BLOCK_PROPS_REFERENCE); 33153 const positionSelector = `.wp-container-$id}.wp-container-$id}`; 33154 let css; 33155 if (allowPositionStyles) { 33156 css = getPositionCSS({ 33157 selector: positionSelector, 33158 style 33159 }) || ""; 33160 } 33161 const className = clsx_default({ 33162 [`wp-container-$id}`]: allowPositionStyles && !!css, 33163 // Only attach a container class if there is generated CSS to be attached. 33164 [`is-position-$style?.position?.type}`]: allowPositionStyles && !!css && !!style?.position?.type 33165 }); 33166 useStyleOverride({ css }); 33167 return { className }; 33168 } 33169 33170 // packages/block-editor/build-module/components/block-tools/use-block-toolbar-popover-props.js 33171 var COMMON_PROPS = { 33172 placement: "top-start" 33173 }; 33174 var DEFAULT_PROPS2 = { 33175 ...COMMON_PROPS, 33176 flip: false, 33177 shift: true 33178 }; 33179 var RESTRICTED_HEIGHT_PROPS = { 33180 ...COMMON_PROPS, 33181 flip: true, 33182 shift: false 33183 }; 33184 function getProps(contentElement, selectedBlockElement, scrollContainer, toolbarHeight, isSticky) { 33185 if (!contentElement || !selectedBlockElement) { 33186 return DEFAULT_PROPS2; 33187 } 33188 const scrollTop = scrollContainer?.scrollTop || 0; 33189 const blockRect = getElementBounds(selectedBlockElement); 33190 const contentRect = contentElement.getBoundingClientRect(); 33191 const topOfContentElementInViewport = scrollTop + contentRect.top; 33192 const viewportHeight = contentElement.ownerDocument.documentElement.clientHeight; 33193 const restrictedTopArea = topOfContentElementInViewport + toolbarHeight; 33194 const hasSpaceForToolbarAbove = blockRect.top > restrictedTopArea; 33195 const isBlockTallerThanViewport = blockRect.height > viewportHeight - toolbarHeight; 33196 if (!isSticky && (hasSpaceForToolbarAbove || isBlockTallerThanViewport)) { 33197 return DEFAULT_PROPS2; 33198 } 33199 return RESTRICTED_HEIGHT_PROPS; 33200 } 33201 function useBlockToolbarPopoverProps({ 33202 contentElement, 33203 clientId 33204 }) { 33205 const selectedBlockElement = useBlockElement(clientId); 33206 const [toolbarHeight, setToolbarHeight] = (0, import_element94.useState)(0); 33207 const { blockIndex, isSticky } = (0, import_data79.useSelect)( 33208 (select3) => { 33209 const { getBlockIndex: getBlockIndex2, getBlockAttributes: getBlockAttributes3 } = select3(store); 33210 return { 33211 blockIndex: getBlockIndex2(clientId), 33212 isSticky: hasStickyOrFixedPositionValue( 33213 getBlockAttributes3(clientId) 33214 ) 33215 }; 33216 }, 33217 [clientId] 33218 ); 33219 const scrollContainer = (0, import_element94.useMemo)(() => { 33220 if (!contentElement) { 33221 return; 33222 } 33223 return (0, import_dom24.getScrollContainer)(contentElement); 33224 }, [contentElement]); 33225 const [props, setProps] = (0, import_element94.useState)( 33226 () => getProps( 33227 contentElement, 33228 selectedBlockElement, 33229 scrollContainer, 33230 toolbarHeight, 33231 isSticky 33232 ) 33233 ); 33234 const popoverRef = (0, import_compose58.useRefEffect)((popoverNode) => { 33235 setToolbarHeight(popoverNode.offsetHeight); 33236 }, []); 33237 const updateProps = (0, import_element94.useCallback)( 33238 () => setProps( 33239 getProps( 33240 contentElement, 33241 selectedBlockElement, 33242 scrollContainer, 33243 toolbarHeight, 33244 isSticky 33245 ) 33246 ), 33247 [contentElement, selectedBlockElement, scrollContainer, toolbarHeight] 33248 ); 33249 (0, import_element94.useLayoutEffect)(updateProps, [blockIndex, updateProps]); 33250 (0, import_element94.useLayoutEffect)(() => { 33251 if (!contentElement || !selectedBlockElement) { 33252 return; 33253 } 33254 const contentView = contentElement?.ownerDocument?.defaultView; 33255 contentView?.addEventHandler?.("resize", updateProps); 33256 let resizeObserver; 33257 const blockView = selectedBlockElement?.ownerDocument?.defaultView; 33258 if (blockView.ResizeObserver) { 33259 resizeObserver = new blockView.ResizeObserver(updateProps); 33260 resizeObserver.observe(selectedBlockElement); 33261 } 33262 return () => { 33263 contentView?.removeEventHandler?.("resize", updateProps); 33264 if (resizeObserver) { 33265 resizeObserver.disconnect(); 33266 } 33267 }; 33268 }, [updateProps, contentElement, selectedBlockElement]); 33269 return { 33270 ...props, 33271 ref: popoverRef 33272 }; 33273 } 33274 33275 // packages/block-editor/build-module/components/block-tools/use-selected-block-tool-props.js 33276 var import_data80 = __toESM(require_data()); 33277 function useSelectedBlockToolProps(clientId) { 33278 const selectedBlockProps = (0, import_data80.useSelect)( 33279 (select3) => { 33280 const { 33281 getBlockRootClientId: getBlockRootClientId2, 33282 getBlockParents: getBlockParents2, 33283 __experimentalGetBlockListSettingsForBlocks: __experimentalGetBlockListSettingsForBlocks2, 33284 isBlockInsertionPointVisible: isBlockInsertionPointVisible2, 33285 getBlockInsertionPoint: getBlockInsertionPoint2, 33286 getBlockOrder: getBlockOrder2, 33287 hasMultiSelection: hasMultiSelection2, 33288 getLastMultiSelectedBlockClientId: getLastMultiSelectedBlockClientId2 33289 } = select3(store); 33290 const blockParentsClientIds = getBlockParents2(clientId); 33291 const parentBlockListSettings = __experimentalGetBlockListSettingsForBlocks2( 33292 blockParentsClientIds 33293 ); 33294 const capturingClientId = blockParentsClientIds.find( 33295 (parentClientId) => parentBlockListSettings[parentClientId]?.__experimentalCaptureToolbars 33296 ); 33297 let isInsertionPointVisible = false; 33298 if (isBlockInsertionPointVisible2()) { 33299 const insertionPoint2 = getBlockInsertionPoint2(); 33300 const order = getBlockOrder2(insertionPoint2.rootClientId); 33301 isInsertionPointVisible = order[insertionPoint2.index] === clientId; 33302 } 33303 return { 33304 capturingClientId, 33305 isInsertionPointVisible, 33306 lastClientId: hasMultiSelection2() ? getLastMultiSelectedBlockClientId2() : null, 33307 rootClientId: getBlockRootClientId2(clientId) 33308 }; 33309 }, 33310 [clientId] 33311 ); 33312 return selectedBlockProps; 33313 } 33314 33315 // packages/block-editor/build-module/components/block-tools/empty-block-inserter.js 33316 var import_jsx_runtime211 = __toESM(require_jsx_runtime()); 33317 function EmptyBlockInserter({ 33318 clientId, 33319 __unstableContentRef 33320 }) { 33321 const { 33322 capturingClientId, 33323 isInsertionPointVisible, 33324 lastClientId, 33325 rootClientId 33326 } = useSelectedBlockToolProps(clientId); 33327 const popoverProps3 = useBlockToolbarPopoverProps({ 33328 contentElement: __unstableContentRef?.current, 33329 clientId 33330 }); 33331 return /* @__PURE__ */ (0, import_jsx_runtime211.jsx)( 33332 cover_default, 33333 { 33334 clientId: capturingClientId || clientId, 33335 bottomClientId: lastClientId, 33336 className: clsx_default( 33337 "block-editor-block-list__block-side-inserter-popover", 33338 { 33339 "is-insertion-point-visible": isInsertionPointVisible 33340 } 33341 ), 33342 __unstableContentRef, 33343 ...popoverProps3, 33344 children: /* @__PURE__ */ (0, import_jsx_runtime211.jsx)("div", { className: "block-editor-block-list__empty-block-inserter", children: /* @__PURE__ */ (0, import_jsx_runtime211.jsx)( 33345 inserter_default, 33346 { 33347 position: "bottom right", 33348 rootClientId, 33349 clientId, 33350 __experimentalIsQuick: true 33351 } 33352 ) }) 33353 } 33354 ); 33355 } 33356 33357 // packages/block-editor/build-module/components/block-tools/block-toolbar-popover.js 33358 var import_data117 = __toESM(require_data()); 33359 var import_element121 = __toESM(require_element()); 33360 var import_keyboard_shortcuts7 = __toESM(require_keyboard_shortcuts()); 33361 33362 // packages/block-editor/build-module/components/block-toolbar/index.js 33363 var import_i18n99 = __toESM(require_i18n()); 33364 var import_data116 = __toESM(require_data()); 33365 var import_element120 = __toESM(require_element()); 33366 var import_compose65 = __toESM(require_compose()); 33367 var import_blocks72 = __toESM(require_blocks()); 33368 var import_components112 = __toESM(require_components()); 33369 33370 // packages/block-editor/build-module/components/block-mover/index.js 33371 var import_components73 = __toESM(require_components()); 33372 var import_data83 = __toESM(require_data()); 33373 var import_i18n70 = __toESM(require_i18n()); 33374 33375 // packages/block-editor/build-module/components/block-draggable/index.js 33376 var import_blocks45 = __toESM(require_blocks()); 33377 var import_components71 = __toESM(require_components()); 33378 var import_data81 = __toESM(require_data()); 33379 var import_element96 = __toESM(require_element()); 33380 var import_compose59 = __toESM(require_compose()); 33381 33382 // packages/block-editor/build-module/components/block-draggable/use-scroll-when-dragging.js 33383 var import_dom26 = __toESM(require_dom()); 33384 var import_element95 = __toESM(require_element()); 33385 var SCROLL_INACTIVE_DISTANCE_PX = 50; 33386 var SCROLL_INTERVAL_MS = 25; 33387 var PIXELS_PER_SECOND_PER_PERCENTAGE = 1e3; 33388 var VELOCITY_MULTIPLIER = PIXELS_PER_SECOND_PER_PERCENTAGE * (SCROLL_INTERVAL_MS / 1e3); 33389 function useScrollWhenDragging() { 33390 const dragStartYRef = (0, import_element95.useRef)(null); 33391 const velocityYRef = (0, import_element95.useRef)(null); 33392 const scrollParentYRef = (0, import_element95.useRef)(null); 33393 const scrollEditorIntervalRef = (0, import_element95.useRef)(null); 33394 (0, import_element95.useEffect)( 33395 () => () => { 33396 if (scrollEditorIntervalRef.current) { 33397 clearInterval(scrollEditorIntervalRef.current); 33398 scrollEditorIntervalRef.current = null; 33399 } 33400 }, 33401 [] 33402 ); 33403 const startScrolling = (0, import_element95.useCallback)((event) => { 33404 dragStartYRef.current = event.clientY; 33405 scrollParentYRef.current = (0, import_dom26.getScrollContainer)(event.target); 33406 scrollEditorIntervalRef.current = setInterval(() => { 33407 if (scrollParentYRef.current && velocityYRef.current) { 33408 const newTop = scrollParentYRef.current.scrollTop + velocityYRef.current; 33409 scrollParentYRef.current.scroll({ 33410 top: newTop 33411 }); 33412 } 33413 }, SCROLL_INTERVAL_MS); 33414 }, []); 33415 const scrollOnDragOver = (0, import_element95.useCallback)((event) => { 33416 if (!scrollParentYRef.current) { 33417 return; 33418 } 33419 const scrollParentHeight = scrollParentYRef.current.offsetHeight; 33420 const offsetDragStartPosition = dragStartYRef.current - scrollParentYRef.current.offsetTop; 33421 const offsetDragPosition = event.clientY - scrollParentYRef.current.offsetTop; 33422 if (event.clientY > offsetDragStartPosition) { 33423 const moveableDistance = Math.max( 33424 scrollParentHeight - offsetDragStartPosition - SCROLL_INACTIVE_DISTANCE_PX, 33425 0 33426 ); 33427 const dragDistance = Math.max( 33428 offsetDragPosition - offsetDragStartPosition - SCROLL_INACTIVE_DISTANCE_PX, 33429 0 33430 ); 33431 const distancePercentage = moveableDistance === 0 || dragDistance === 0 ? 0 : dragDistance / moveableDistance; 33432 velocityYRef.current = VELOCITY_MULTIPLIER * distancePercentage; 33433 } else if (event.clientY < offsetDragStartPosition) { 33434 const moveableDistance = Math.max( 33435 offsetDragStartPosition - SCROLL_INACTIVE_DISTANCE_PX, 33436 0 33437 ); 33438 const dragDistance = Math.max( 33439 offsetDragStartPosition - offsetDragPosition - SCROLL_INACTIVE_DISTANCE_PX, 33440 0 33441 ); 33442 const distancePercentage = moveableDistance === 0 || dragDistance === 0 ? 0 : dragDistance / moveableDistance; 33443 velocityYRef.current = -VELOCITY_MULTIPLIER * distancePercentage; 33444 } else { 33445 velocityYRef.current = 0; 33446 } 33447 }, []); 33448 const stopScrolling = () => { 33449 dragStartYRef.current = null; 33450 scrollParentYRef.current = null; 33451 if (scrollEditorIntervalRef.current) { 33452 clearInterval(scrollEditorIntervalRef.current); 33453 scrollEditorIntervalRef.current = null; 33454 } 33455 }; 33456 return [startScrolling, scrollOnDragOver, stopScrolling]; 33457 } 33458 33459 // packages/block-editor/build-module/components/block-draggable/index.js 33460 var import_jsx_runtime212 = __toESM(require_jsx_runtime()); 33461 var BlockDraggable = ({ 33462 appendToOwnerDocument, 33463 children, 33464 clientIds, 33465 cloneClassname, 33466 elementId, 33467 onDragStart, 33468 onDragEnd, 33469 fadeWhenDisabled = false, 33470 dragComponent 33471 }) => { 33472 const { 33473 srcRootClientId, 33474 isDraggable, 33475 icon, 33476 visibleInserter, 33477 getBlockType: getBlockType21 33478 } = (0, import_data81.useSelect)( 33479 (select3) => { 33480 const { 33481 canMoveBlocks: canMoveBlocks2, 33482 getBlockRootClientId: getBlockRootClientId22, 33483 getBlockName: getBlockName2, 33484 getBlockAttributes: getBlockAttributes3, 33485 isBlockInsertionPointVisible: isBlockInsertionPointVisible2 33486 } = select3(store); 33487 const { getBlockType: _getBlockType, getActiveBlockVariation } = select3(import_blocks45.store); 33488 const rootClientId = getBlockRootClientId22(clientIds[0]); 33489 const blockName = getBlockName2(clientIds[0]); 33490 const variation = getActiveBlockVariation( 33491 blockName, 33492 getBlockAttributes3(clientIds[0]) 33493 ); 33494 return { 33495 srcRootClientId: rootClientId, 33496 isDraggable: canMoveBlocks2(clientIds), 33497 icon: variation?.icon || _getBlockType(blockName)?.icon, 33498 visibleInserter: isBlockInsertionPointVisible2(), 33499 getBlockType: _getBlockType 33500 }; 33501 }, 33502 [clientIds] 33503 ); 33504 const isDraggingRef = (0, import_element96.useRef)(false); 33505 const [startScrolling, scrollOnDragOver, stopScrolling] = useScrollWhenDragging(); 33506 const { getAllowedBlocks: getAllowedBlocks2, getBlockNamesByClientId: getBlockNamesByClientId2, getBlockRootClientId: getBlockRootClientId2 } = (0, import_data81.useSelect)(store); 33507 const { startDraggingBlocks: startDraggingBlocks2, stopDraggingBlocks: stopDraggingBlocks2 } = (0, import_data81.useDispatch)(store); 33508 (0, import_element96.useEffect)(() => { 33509 return () => { 33510 if (isDraggingRef.current) { 33511 stopDraggingBlocks2(); 33512 } 33513 }; 33514 }, []); 33515 const blockEl = useBlockElement(clientIds[0]); 33516 const editorRoot = blockEl?.closest("body"); 33517 (0, import_element96.useEffect)(() => { 33518 if (!editorRoot || !fadeWhenDisabled) { 33519 return; 33520 } 33521 const onDragOver = (event) => { 33522 if (!event.target.closest("[data-block]")) { 33523 return; 33524 } 33525 const draggedBlockNames = getBlockNamesByClientId2(clientIds); 33526 const targetClientId = event.target.closest("[data-block]").getAttribute("data-block"); 33527 const allowedBlocks = getAllowedBlocks2(targetClientId); 33528 const targetBlockName = getBlockNamesByClientId2([ 33529 targetClientId 33530 ])[0]; 33531 let dropTargetValid; 33532 if (allowedBlocks?.length === 0) { 33533 const targetRootClientId = getBlockRootClientId2(targetClientId); 33534 const targetRootBlockName = getBlockNamesByClientId2([ 33535 targetRootClientId 33536 ])[0]; 33537 const rootAllowedBlocks = getAllowedBlocks2(targetRootClientId); 33538 dropTargetValid = isDropTargetValid( 33539 getBlockType21, 33540 rootAllowedBlocks, 33541 draggedBlockNames, 33542 targetRootBlockName 33543 ); 33544 } else { 33545 dropTargetValid = isDropTargetValid( 33546 getBlockType21, 33547 allowedBlocks, 33548 draggedBlockNames, 33549 targetBlockName 33550 ); 33551 } 33552 if (!dropTargetValid && !visibleInserter) { 33553 window?.document?.body?.classList?.add( 33554 "block-draggable-invalid-drag-token" 33555 ); 33556 } else { 33557 window?.document?.body?.classList?.remove( 33558 "block-draggable-invalid-drag-token" 33559 ); 33560 } 33561 }; 33562 const throttledOnDragOver = (0, import_compose59.throttle)(onDragOver, 200); 33563 editorRoot.addEventListener("dragover", throttledOnDragOver); 33564 return () => { 33565 editorRoot.removeEventListener("dragover", throttledOnDragOver); 33566 }; 33567 }, [ 33568 clientIds, 33569 editorRoot, 33570 fadeWhenDisabled, 33571 getAllowedBlocks2, 33572 getBlockNamesByClientId2, 33573 getBlockRootClientId2, 33574 getBlockType21, 33575 visibleInserter 33576 ]); 33577 if (!isDraggable) { 33578 return children({ draggable: false }); 33579 } 33580 const transferData = { 33581 type: "block", 33582 srcClientIds: clientIds, 33583 srcRootClientId 33584 }; 33585 return /* @__PURE__ */ (0, import_jsx_runtime212.jsx)( 33586 import_components71.Draggable, 33587 { 33588 appendToOwnerDocument, 33589 cloneClassname, 33590 __experimentalTransferDataType: "wp-blocks", 33591 transferData, 33592 onDragStart: (event) => { 33593 window.requestAnimationFrame(() => { 33594 startDraggingBlocks2(clientIds); 33595 isDraggingRef.current = true; 33596 startScrolling(event); 33597 if (onDragStart) { 33598 onDragStart(); 33599 } 33600 }); 33601 }, 33602 onDragOver: scrollOnDragOver, 33603 onDragEnd: () => { 33604 stopDraggingBlocks2(); 33605 isDraggingRef.current = false; 33606 stopScrolling(); 33607 if (onDragEnd) { 33608 onDragEnd(); 33609 } 33610 }, 33611 __experimentalDragComponent: ( 33612 // Check against `undefined` so that `null` can be used to disable 33613 // the default drag component. 33614 dragComponent !== void 0 ? dragComponent : /* @__PURE__ */ (0, import_jsx_runtime212.jsx)( 33615 BlockDraggableChip, 33616 { 33617 count: clientIds.length, 33618 icon, 33619 fadeWhenDisabled: true 33620 } 33621 ) 33622 ), 33623 elementId, 33624 children: ({ onDraggableStart, onDraggableEnd }) => { 33625 return children({ 33626 draggable: true, 33627 onDragStart: onDraggableStart, 33628 onDragEnd: onDraggableEnd 33629 }); 33630 } 33631 } 33632 ); 33633 }; 33634 var block_draggable_default = BlockDraggable; 33635 33636 // packages/block-editor/build-module/components/block-mover/button.js 33637 var import_blocks46 = __toESM(require_blocks()); 33638 var import_components72 = __toESM(require_components()); 33639 var import_compose60 = __toESM(require_compose()); 33640 var import_data82 = __toESM(require_data()); 33641 var import_element97 = __toESM(require_element()); 33642 var import_i18n69 = __toESM(require_i18n()); 33643 33644 // packages/block-editor/build-module/components/block-mover/mover-description.js 33645 var import_i18n68 = __toESM(require_i18n()); 33646 var getMovementDirection = (moveDirection, orientation) => { 33647 if (moveDirection === "up") { 33648 if (orientation === "horizontal") { 33649 return (0, import_i18n68.isRTL)() ? "right" : "left"; 33650 } 33651 return "up"; 33652 } else if (moveDirection === "down") { 33653 if (orientation === "horizontal") { 33654 return (0, import_i18n68.isRTL)() ? "left" : "right"; 33655 } 33656 return "down"; 33657 } 33658 return null; 33659 }; 33660 function getBlockMoverDescription(selectedCount, type, firstIndex, isFirst, isLast, dir, orientation) { 33661 const position = firstIndex + 1; 33662 if (selectedCount > 1) { 33663 return getMultiBlockMoverDescription( 33664 selectedCount, 33665 firstIndex, 33666 isFirst, 33667 isLast, 33668 dir, 33669 orientation 33670 ); 33671 } 33672 if (isFirst && isLast) { 33673 return (0, import_i18n68.sprintf)( 33674 // translators: %s: Type of block (i.e. Text, Image etc) 33675 (0, import_i18n68.__)("Block %s is the only block, and cannot be moved"), 33676 type 33677 ); 33678 } 33679 if (dir > 0 && !isLast) { 33680 const movementDirection = getMovementDirection("down", orientation); 33681 if (movementDirection === "down") { 33682 return (0, import_i18n68.sprintf)( 33683 // translators: 1: Type of block (i.e. Text, Image etc), 2: Position of selected block, 3: New position 33684 (0, import_i18n68.__)( 33685 "Move %1$s block from position %2$d down to position %3$d" 33686 ), 33687 type, 33688 position, 33689 position + 1 33690 ); 33691 } 33692 if (movementDirection === "left") { 33693 return (0, import_i18n68.sprintf)( 33694 // translators: 1: Type of block (i.e. Text, Image etc), 2: Position of selected block, 3: New position 33695 (0, import_i18n68.__)( 33696 "Move %1$s block from position %2$d left to position %3$d" 33697 ), 33698 type, 33699 position, 33700 position + 1 33701 ); 33702 } 33703 if (movementDirection === "right") { 33704 return (0, import_i18n68.sprintf)( 33705 // translators: 1: Type of block (i.e. Text, Image etc), 2: Position of selected block, 3: New position 33706 (0, import_i18n68.__)( 33707 "Move %1$s block from position %2$d right to position %3$d" 33708 ), 33709 type, 33710 position, 33711 position + 1 33712 ); 33713 } 33714 } 33715 if (dir > 0 && isLast) { 33716 const movementDirection = getMovementDirection("down", orientation); 33717 if (movementDirection === "down") { 33718 return (0, import_i18n68.sprintf)( 33719 // translators: 1: Type of block (i.e. Text, Image etc) 33720 (0, import_i18n68.__)( 33721 "Block %1$s is at the end of the content and can\u2019t be moved down" 33722 ), 33723 type 33724 ); 33725 } 33726 if (movementDirection === "left") { 33727 return (0, import_i18n68.sprintf)( 33728 // translators: 1: Type of block (i.e. Text, Image etc) 33729 (0, import_i18n68.__)( 33730 "Block %1$s is at the end of the content and can\u2019t be moved left" 33731 ), 33732 type 33733 ); 33734 } 33735 if (movementDirection === "right") { 33736 return (0, import_i18n68.sprintf)( 33737 // translators: 1: Type of block (i.e. Text, Image etc) 33738 (0, import_i18n68.__)( 33739 "Block %1$s is at the end of the content and can\u2019t be moved right" 33740 ), 33741 type 33742 ); 33743 } 33744 } 33745 if (dir < 0 && !isFirst) { 33746 const movementDirection = getMovementDirection("up", orientation); 33747 if (movementDirection === "up") { 33748 return (0, import_i18n68.sprintf)( 33749 // translators: 1: Type of block (i.e. Text, Image etc), 2: Position of selected block, 3: New position 33750 (0, import_i18n68.__)("Move %1$s block from position %2$d up to position %3$d"), 33751 type, 33752 position, 33753 position - 1 33754 ); 33755 } 33756 if (movementDirection === "left") { 33757 return (0, import_i18n68.sprintf)( 33758 // translators: 1: Type of block (i.e. Text, Image etc), 2: Position of selected block, 3: New position 33759 (0, import_i18n68.__)( 33760 "Move %1$s block from position %2$d left to position %3$d" 33761 ), 33762 type, 33763 position, 33764 position - 1 33765 ); 33766 } 33767 if (movementDirection === "right") { 33768 return (0, import_i18n68.sprintf)( 33769 // translators: 1: Type of block (i.e. Text, Image etc), 2: Position of selected block, 3: New position 33770 (0, import_i18n68.__)( 33771 "Move %1$s block from position %2$d right to position %3$d" 33772 ), 33773 type, 33774 position, 33775 position - 1 33776 ); 33777 } 33778 } 33779 if (dir < 0 && isFirst) { 33780 const movementDirection = getMovementDirection("up", orientation); 33781 if (movementDirection === "up") { 33782 return (0, import_i18n68.sprintf)( 33783 // translators: 1: Type of block (i.e. Text, Image etc) 33784 (0, import_i18n68.__)( 33785 "Block %1$s is at the beginning of the content and can\u2019t be moved up" 33786 ), 33787 type 33788 ); 33789 } 33790 if (movementDirection === "left") { 33791 return (0, import_i18n68.sprintf)( 33792 // translators: 1: Type of block (i.e. Text, Image etc) 33793 (0, import_i18n68.__)( 33794 "Block %1$s is at the beginning of the content and can\u2019t be moved left" 33795 ), 33796 type 33797 ); 33798 } 33799 if (movementDirection === "right") { 33800 return (0, import_i18n68.sprintf)( 33801 // translators: 1: Type of block (i.e. Text, Image etc) 33802 (0, import_i18n68.__)( 33803 "Block %1$s is at the beginning of the content and can\u2019t be moved right" 33804 ), 33805 type 33806 ); 33807 } 33808 } 33809 } 33810 function getMultiBlockMoverDescription(selectedCount, firstIndex, isFirst, isLast, dir, orientation) { 33811 const position = firstIndex + 1; 33812 if (isFirst && isLast) { 33813 return (0, import_i18n68.__)("All blocks are selected, and cannot be moved"); 33814 } 33815 if (dir > 0 && !isLast) { 33816 const movementDirection = getMovementDirection("down", orientation); 33817 if (movementDirection === "down") { 33818 return (0, import_i18n68.sprintf)( 33819 // translators: 1: Number of selected blocks, 2: Position of selected blocks 33820 (0, import_i18n68.__)("Move %1$d blocks from position %2$d down by one place"), 33821 selectedCount, 33822 position 33823 ); 33824 } 33825 if (movementDirection === "left") { 33826 return (0, import_i18n68.sprintf)( 33827 // translators: 1: Number of selected blocks, 2: Position of selected blocks 33828 (0, import_i18n68.__)("Move %1$d blocks from position %2$d left by one place"), 33829 selectedCount, 33830 position 33831 ); 33832 } 33833 if (movementDirection === "right") { 33834 return (0, import_i18n68.sprintf)( 33835 // translators: 1: Number of selected blocks, 2: Position of selected blocks 33836 (0, import_i18n68.__)("Move %1$d blocks from position %2$d right by one place"), 33837 selectedCount, 33838 position 33839 ); 33840 } 33841 } 33842 if (dir > 0 && isLast) { 33843 const movementDirection = getMovementDirection("down", orientation); 33844 if (movementDirection === "down") { 33845 return (0, import_i18n68.__)( 33846 "Blocks cannot be moved down as they are already at the bottom" 33847 ); 33848 } 33849 if (movementDirection === "left") { 33850 return (0, import_i18n68.__)( 33851 "Blocks cannot be moved left as they are already are at the leftmost position" 33852 ); 33853 } 33854 if (movementDirection === "right") { 33855 return (0, import_i18n68.__)( 33856 "Blocks cannot be moved right as they are already are at the rightmost position" 33857 ); 33858 } 33859 } 33860 if (dir < 0 && !isFirst) { 33861 const movementDirection = getMovementDirection("up", orientation); 33862 if (movementDirection === "up") { 33863 return (0, import_i18n68.sprintf)( 33864 // translators: 1: Number of selected blocks, 2: Position of selected blocks 33865 (0, import_i18n68.__)("Move %1$d blocks from position %2$d up by one place"), 33866 selectedCount, 33867 position 33868 ); 33869 } 33870 if (movementDirection === "left") { 33871 return (0, import_i18n68.sprintf)( 33872 // translators: 1: Number of selected blocks, 2: Position of selected blocks 33873 (0, import_i18n68.__)("Move %1$d blocks from position %2$d left by one place"), 33874 selectedCount, 33875 position 33876 ); 33877 } 33878 if (movementDirection === "right") { 33879 return (0, import_i18n68.sprintf)( 33880 // translators: 1: Number of selected blocks, 2: Position of selected blocks 33881 (0, import_i18n68.__)("Move %1$d blocks from position %2$d right by one place"), 33882 selectedCount, 33883 position 33884 ); 33885 } 33886 } 33887 if (dir < 0 && isFirst) { 33888 const movementDirection = getMovementDirection("up", orientation); 33889 if (movementDirection === "up") { 33890 return (0, import_i18n68.__)( 33891 "Blocks cannot be moved up as they are already at the top" 33892 ); 33893 } 33894 if (movementDirection === "left") { 33895 return (0, import_i18n68.__)( 33896 "Blocks cannot be moved left as they are already are at the leftmost position" 33897 ); 33898 } 33899 if (movementDirection === "right") { 33900 return (0, import_i18n68.__)( 33901 "Blocks cannot be moved right as they are already are at the rightmost position" 33902 ); 33903 } 33904 } 33905 } 33906 33907 // packages/block-editor/build-module/components/block-mover/button.js 33908 var import_jsx_runtime213 = __toESM(require_jsx_runtime()); 33909 var getArrowIcon = (direction, orientation) => { 33910 if (direction === "up") { 33911 if (orientation === "horizontal") { 33912 return (0, import_i18n69.isRTL)() ? chevron_right_default : chevron_left_default; 33913 } 33914 return chevron_up_default; 33915 } else if (direction === "down") { 33916 if (orientation === "horizontal") { 33917 return (0, import_i18n69.isRTL)() ? chevron_left_default : chevron_right_default; 33918 } 33919 return chevron_down_default; 33920 } 33921 return null; 33922 }; 33923 var getMovementDirectionLabel = (moveDirection, orientation) => { 33924 if (moveDirection === "up") { 33925 if (orientation === "horizontal") { 33926 return (0, import_i18n69.isRTL)() ? (0, import_i18n69.__)("Move right") : (0, import_i18n69.__)("Move left"); 33927 } 33928 return (0, import_i18n69.__)("Move up"); 33929 } else if (moveDirection === "down") { 33930 if (orientation === "horizontal") { 33931 return (0, import_i18n69.isRTL)() ? (0, import_i18n69.__)("Move left") : (0, import_i18n69.__)("Move right"); 33932 } 33933 return (0, import_i18n69.__)("Move down"); 33934 } 33935 return null; 33936 }; 33937 var BlockMoverButton = (0, import_element97.forwardRef)( 33938 ({ clientIds, direction, orientation: moverOrientation, ...props }, ref) => { 33939 const instanceId = (0, import_compose60.useInstanceId)(BlockMoverButton); 33940 const normalizedClientIds = Array.isArray(clientIds) ? clientIds : [clientIds]; 33941 const blocksCount = normalizedClientIds.length; 33942 const { disabled } = props; 33943 const { 33944 blockType, 33945 isDisabled, 33946 rootClientId, 33947 isFirst, 33948 isLast, 33949 firstIndex, 33950 orientation = "vertical" 33951 } = (0, import_data82.useSelect)( 33952 (select3) => { 33953 const { 33954 getBlockIndex: getBlockIndex2, 33955 getBlockRootClientId: getBlockRootClientId2, 33956 getBlockOrder: getBlockOrder2, 33957 getBlock: getBlock2, 33958 getBlockListSettings: getBlockListSettings2 33959 } = select3(store); 33960 const firstClientId = normalizedClientIds[0]; 33961 const blockRootClientId = getBlockRootClientId2(firstClientId); 33962 const firstBlockIndex = getBlockIndex2(firstClientId); 33963 const lastBlockIndex = getBlockIndex2( 33964 normalizedClientIds[normalizedClientIds.length - 1] 33965 ); 33966 const blockOrder = getBlockOrder2(blockRootClientId); 33967 const block = getBlock2(firstClientId); 33968 const isFirstBlock = firstBlockIndex === 0; 33969 const isLastBlock = lastBlockIndex === blockOrder.length - 1; 33970 const { orientation: blockListOrientation } = getBlockListSettings2(blockRootClientId) || {}; 33971 return { 33972 blockType: block ? (0, import_blocks46.getBlockType)(block.name) : null, 33973 isDisabled: disabled || (direction === "up" ? isFirstBlock : isLastBlock), 33974 rootClientId: blockRootClientId, 33975 firstIndex: firstBlockIndex, 33976 isFirst: isFirstBlock, 33977 isLast: isLastBlock, 33978 orientation: moverOrientation || blockListOrientation 33979 }; 33980 }, 33981 [clientIds, direction] 33982 ); 33983 const { moveBlocksDown: moveBlocksDown2, moveBlocksUp: moveBlocksUp2 } = (0, import_data82.useDispatch)(store); 33984 const moverFunction = direction === "up" ? moveBlocksUp2 : moveBlocksDown2; 33985 const onClick = (event) => { 33986 moverFunction(clientIds, rootClientId); 33987 if (props.onClick) { 33988 props.onClick(event); 33989 } 33990 }; 33991 const descriptionId = `block-editor-block-mover-button__description-$instanceId}`; 33992 return /* @__PURE__ */ (0, import_jsx_runtime213.jsxs)(import_jsx_runtime213.Fragment, { children: [ 33993 /* @__PURE__ */ (0, import_jsx_runtime213.jsx)( 33994 import_components72.Button, 33995 { 33996 __next40pxDefaultSize: true, 33997 ref, 33998 className: clsx_default( 33999 "block-editor-block-mover-button", 34000 `is-$direction}-button` 34001 ), 34002 icon: getArrowIcon(direction, orientation), 34003 label: getMovementDirectionLabel( 34004 direction, 34005 orientation 34006 ), 34007 "aria-describedby": descriptionId, 34008 ...props, 34009 onClick: isDisabled ? null : onClick, 34010 disabled: isDisabled, 34011 accessibleWhenDisabled: true 34012 } 34013 ), 34014 /* @__PURE__ */ (0, import_jsx_runtime213.jsx)(import_components72.VisuallyHidden, { id: descriptionId, children: getBlockMoverDescription( 34015 blocksCount, 34016 blockType && blockType.title, 34017 firstIndex, 34018 isFirst, 34019 isLast, 34020 direction === "up" ? -1 : 1, 34021 orientation 34022 ) }) 34023 ] }); 34024 } 34025 ); 34026 var BlockMoverUpButton = (0, import_element97.forwardRef)((props, ref) => { 34027 return /* @__PURE__ */ (0, import_jsx_runtime213.jsx)(BlockMoverButton, { direction: "up", ref, ...props }); 34028 }); 34029 var BlockMoverDownButton = (0, import_element97.forwardRef)((props, ref) => { 34030 return /* @__PURE__ */ (0, import_jsx_runtime213.jsx)(BlockMoverButton, { direction: "down", ref, ...props }); 34031 }); 34032 34033 // packages/block-editor/build-module/components/block-mover/index.js 34034 var import_jsx_runtime214 = __toESM(require_jsx_runtime()); 34035 function BlockMover({ 34036 clientIds, 34037 hideDragHandle, 34038 isBlockMoverUpButtonDisabled, 34039 isBlockMoverDownButtonDisabled 34040 }) { 34041 const { 34042 canMove, 34043 rootClientId, 34044 isFirst, 34045 isLast, 34046 orientation, 34047 isManualGrid 34048 } = (0, import_data83.useSelect)( 34049 (select3) => { 34050 const { 34051 getBlockIndex: getBlockIndex2, 34052 getBlockListSettings: getBlockListSettings2, 34053 canMoveBlocks: canMoveBlocks2, 34054 getBlockOrder: getBlockOrder2, 34055 getBlockRootClientId: getBlockRootClientId2, 34056 getBlockAttributes: getBlockAttributes3 34057 } = select3(store); 34058 const normalizedClientIds = Array.isArray(clientIds) ? clientIds : [clientIds]; 34059 const firstClientId = normalizedClientIds[0]; 34060 const _rootClientId = getBlockRootClientId2(firstClientId); 34061 const firstIndex = getBlockIndex2(firstClientId); 34062 const lastIndex = getBlockIndex2( 34063 normalizedClientIds[normalizedClientIds.length - 1] 34064 ); 34065 const blockOrder = getBlockOrder2(_rootClientId); 34066 const { layout = {} } = getBlockAttributes3(_rootClientId) ?? {}; 34067 return { 34068 canMove: canMoveBlocks2(clientIds), 34069 rootClientId: _rootClientId, 34070 isFirst: firstIndex === 0, 34071 isLast: lastIndex === blockOrder.length - 1, 34072 orientation: getBlockListSettings2(_rootClientId)?.orientation, 34073 isManualGrid: layout.type === "grid" && layout.isManualPlacement && window.__experimentalEnableGridInteractivity 34074 }; 34075 }, 34076 [clientIds] 34077 ); 34078 if (!canMove || isFirst && isLast && !rootClientId || hideDragHandle && isManualGrid) { 34079 return null; 34080 } 34081 return /* @__PURE__ */ (0, import_jsx_runtime214.jsxs)( 34082 import_components73.ToolbarGroup, 34083 { 34084 className: clsx_default("block-editor-block-mover", { 34085 "is-horizontal": orientation === "horizontal" 34086 }), 34087 children: [ 34088 !hideDragHandle && /* @__PURE__ */ (0, import_jsx_runtime214.jsx)(block_draggable_default, { clientIds, fadeWhenDisabled: true, children: (draggableProps) => /* @__PURE__ */ (0, import_jsx_runtime214.jsx)( 34089 import_components73.Button, 34090 { 34091 __next40pxDefaultSize: true, 34092 icon: drag_handle_default, 34093 className: "block-editor-block-mover__drag-handle", 34094 label: (0, import_i18n70.__)("Drag"), 34095 tabIndex: "-1", 34096 ...draggableProps 34097 } 34098 ) }), 34099 !isManualGrid && /* @__PURE__ */ (0, import_jsx_runtime214.jsxs)("div", { className: "block-editor-block-mover__move-button-container", children: [ 34100 /* @__PURE__ */ (0, import_jsx_runtime214.jsx)(import_components73.ToolbarItem, { children: (itemProps) => /* @__PURE__ */ (0, import_jsx_runtime214.jsx)( 34101 BlockMoverUpButton, 34102 { 34103 disabled: isBlockMoverUpButtonDisabled, 34104 clientIds, 34105 ...itemProps 34106 } 34107 ) }), 34108 /* @__PURE__ */ (0, import_jsx_runtime214.jsx)(import_components73.ToolbarItem, { children: (itemProps) => /* @__PURE__ */ (0, import_jsx_runtime214.jsx)( 34109 BlockMoverDownButton, 34110 { 34111 disabled: isBlockMoverDownButtonDisabled, 34112 clientIds, 34113 ...itemProps 34114 } 34115 ) }) 34116 ] }) 34117 ] 34118 } 34119 ); 34120 } 34121 var block_mover_default = BlockMover; 34122 34123 // packages/block-editor/build-module/components/block-parent-selector/index.js 34124 var import_components74 = __toESM(require_components()); 34125 var import_data85 = __toESM(require_data()); 34126 var import_i18n71 = __toESM(require_i18n()); 34127 var import_element99 = __toESM(require_element()); 34128 34129 // packages/block-editor/build-module/components/block-toolbar/utils.js 34130 var import_data84 = __toESM(require_data()); 34131 var import_element98 = __toESM(require_element()); 34132 var { clearTimeout: clearTimeout2, setTimeout: setTimeout2 } = window; 34133 var DEBOUNCE_TIMEOUT = 200; 34134 function useDebouncedShowGestures({ 34135 ref, 34136 isFocused, 34137 highlightParent, 34138 debounceTimeout = DEBOUNCE_TIMEOUT 34139 }) { 34140 const { getSelectedBlockClientId: getSelectedBlockClientId2, getBlockRootClientId: getBlockRootClientId2 } = (0, import_data84.useSelect)(store); 34141 const { toggleBlockHighlight: toggleBlockHighlight2 } = (0, import_data84.useDispatch)(store); 34142 const timeoutRef = (0, import_element98.useRef)(); 34143 const isDistractionFree = (0, import_data84.useSelect)( 34144 (select3) => select3(store).getSettings().isDistractionFree, 34145 [] 34146 ); 34147 const handleOnChange = (nextIsFocused) => { 34148 if (nextIsFocused && isDistractionFree) { 34149 return; 34150 } 34151 const selectedBlockClientId = getSelectedBlockClientId2(); 34152 const clientId = highlightParent ? getBlockRootClientId2(selectedBlockClientId) : selectedBlockClientId; 34153 toggleBlockHighlight2(clientId, nextIsFocused); 34154 }; 34155 const getIsHovered = () => { 34156 return ref?.current && ref.current.matches(":hover"); 34157 }; 34158 const shouldHideGestures = () => { 34159 const isHovered = getIsHovered(); 34160 return !isFocused && !isHovered; 34161 }; 34162 const clearTimeoutRef = () => { 34163 const timeout = timeoutRef.current; 34164 if (timeout && clearTimeout2) { 34165 clearTimeout2(timeout); 34166 } 34167 }; 34168 const debouncedShowGestures = (event) => { 34169 if (event) { 34170 event.stopPropagation(); 34171 } 34172 clearTimeoutRef(); 34173 handleOnChange(true); 34174 }; 34175 const debouncedHideGestures = (event) => { 34176 if (event) { 34177 event.stopPropagation(); 34178 } 34179 clearTimeoutRef(); 34180 timeoutRef.current = setTimeout2(() => { 34181 if (shouldHideGestures()) { 34182 handleOnChange(false); 34183 } 34184 }, debounceTimeout); 34185 }; 34186 (0, import_element98.useEffect)( 34187 () => () => { 34188 handleOnChange(false); 34189 clearTimeoutRef(); 34190 }, 34191 [] 34192 ); 34193 return { 34194 debouncedShowGestures, 34195 debouncedHideGestures 34196 }; 34197 } 34198 function useShowHoveredOrFocusedGestures({ 34199 ref, 34200 highlightParent = false, 34201 debounceTimeout = DEBOUNCE_TIMEOUT 34202 }) { 34203 const [isFocused, setIsFocused] = (0, import_element98.useState)(false); 34204 const { debouncedShowGestures, debouncedHideGestures } = useDebouncedShowGestures({ 34205 ref, 34206 debounceTimeout, 34207 isFocused, 34208 highlightParent 34209 }); 34210 const registerRef = (0, import_element98.useRef)(false); 34211 const isFocusedWithin = () => { 34212 return ref?.current && ref.current.contains(ref.current.ownerDocument.activeElement); 34213 }; 34214 (0, import_element98.useEffect)(() => { 34215 const node = ref.current; 34216 const handleOnFocus = () => { 34217 if (isFocusedWithin()) { 34218 setIsFocused(true); 34219 debouncedShowGestures(); 34220 } 34221 }; 34222 const handleOnBlur = () => { 34223 if (!isFocusedWithin()) { 34224 setIsFocused(false); 34225 debouncedHideGestures(); 34226 } 34227 }; 34228 if (node && !registerRef.current) { 34229 node.addEventListener("focus", handleOnFocus, true); 34230 node.addEventListener("blur", handleOnBlur, true); 34231 registerRef.current = true; 34232 } 34233 return () => { 34234 if (node) { 34235 node.removeEventListener("focus", handleOnFocus); 34236 node.removeEventListener("blur", handleOnBlur); 34237 } 34238 }; 34239 }, [ 34240 ref, 34241 registerRef, 34242 setIsFocused, 34243 debouncedShowGestures, 34244 debouncedHideGestures 34245 ]); 34246 return { 34247 onMouseMove: debouncedShowGestures, 34248 onMouseLeave: debouncedHideGestures 34249 }; 34250 } 34251 34252 // packages/block-editor/build-module/components/block-parent-selector/index.js 34253 var import_jsx_runtime215 = __toESM(require_jsx_runtime()); 34254 function BlockParentSelector() { 34255 const { selectBlock: selectBlock2 } = (0, import_data85.useDispatch)(store); 34256 const { parentClientId } = (0, import_data85.useSelect)((select3) => { 34257 const { 34258 getBlockParents: getBlockParents2, 34259 getSelectedBlockClientId: getSelectedBlockClientId2, 34260 getParentSectionBlock: getParentSectionBlock2 34261 } = unlock(select3(store)); 34262 const selectedBlockClientId = getSelectedBlockClientId2(); 34263 const parentSection = getParentSectionBlock2(selectedBlockClientId); 34264 const parents = getBlockParents2(selectedBlockClientId); 34265 const _parentClientId = parentSection ?? parents[parents.length - 1]; 34266 return { 34267 parentClientId: _parentClientId 34268 }; 34269 }, []); 34270 const blockInformation = useBlockDisplayInformation(parentClientId); 34271 const nodeRef = (0, import_element99.useRef)(); 34272 const showHoveredOrFocusedGestures = useShowHoveredOrFocusedGestures({ 34273 ref: nodeRef, 34274 highlightParent: true 34275 }); 34276 return /* @__PURE__ */ (0, import_jsx_runtime215.jsx)( 34277 "div", 34278 { 34279 className: "block-editor-block-parent-selector", 34280 ref: nodeRef, 34281 ...showHoveredOrFocusedGestures, 34282 children: /* @__PURE__ */ (0, import_jsx_runtime215.jsx)( 34283 import_components74.ToolbarButton, 34284 { 34285 className: "block-editor-block-parent-selector__button", 34286 onClick: () => selectBlock2(parentClientId), 34287 label: (0, import_i18n71.sprintf)( 34288 /* translators: %s: Name of the block's parent. */ 34289 (0, import_i18n71.__)("Select parent block: %s"), 34290 blockInformation?.title 34291 ), 34292 showTooltip: true, 34293 icon: /* @__PURE__ */ (0, import_jsx_runtime215.jsx)(block_icon_default, { icon: blockInformation?.icon }) 34294 } 34295 ) 34296 }, 34297 parentClientId 34298 ); 34299 } 34300 34301 // packages/block-editor/build-module/components/block-controls/fill.js 34302 var import_components76 = __toESM(require_components()); 34303 34304 // packages/block-editor/build-module/components/block-controls/groups.js 34305 var import_components75 = __toESM(require_components()); 34306 var BlockControlsDefault = (0, import_components75.createSlotFill)("BlockControls"); 34307 var BlockControlsBlock = (0, import_components75.createSlotFill)("BlockControlsBlock"); 34308 var BlockControlsInline = (0, import_components75.createSlotFill)("BlockFormatControls"); 34309 var BlockControlsOther = (0, import_components75.createSlotFill)("BlockControlsOther"); 34310 var BlockControlsParent = (0, import_components75.createSlotFill)("BlockControlsParent"); 34311 var groups2 = { 34312 default: BlockControlsDefault, 34313 block: BlockControlsBlock, 34314 inline: BlockControlsInline, 34315 other: BlockControlsOther, 34316 parent: BlockControlsParent 34317 }; 34318 var groups_default2 = groups2; 34319 34320 // packages/block-editor/build-module/components/block-controls/hook.js 34321 function useBlockControlsFill(group, shareWithChildBlocks) { 34322 const context = useBlockEditContext(); 34323 if (context[mayDisplayControlsKey]) { 34324 return groups_default2[group]?.Fill; 34325 } 34326 if (context[mayDisplayParentControlsKey] && shareWithChildBlocks) { 34327 return groups_default2.parent.Fill; 34328 } 34329 return null; 34330 } 34331 34332 // packages/block-editor/build-module/components/block-controls/fill.js 34333 var import_jsx_runtime216 = __toESM(require_jsx_runtime()); 34334 function BlockControlsFill({ 34335 group = "default", 34336 controls, 34337 children, 34338 __experimentalShareWithChildBlocks = false 34339 }) { 34340 const Fill3 = useBlockControlsFill( 34341 group, 34342 __experimentalShareWithChildBlocks 34343 ); 34344 if (!Fill3) { 34345 return null; 34346 } 34347 const innerMarkup = /* @__PURE__ */ (0, import_jsx_runtime216.jsxs)(import_jsx_runtime216.Fragment, { children: [ 34348 group === "default" && /* @__PURE__ */ (0, import_jsx_runtime216.jsx)(import_components76.ToolbarGroup, { controls }), 34349 children 34350 ] }); 34351 return /* @__PURE__ */ (0, import_jsx_runtime216.jsx)(import_components76.__experimentalStyleProvider, { document, children: /* @__PURE__ */ (0, import_jsx_runtime216.jsx)(Fill3, { children: (fillProps) => { 34352 const { forwardedContext = [] } = fillProps; 34353 return forwardedContext.reduce( 34354 (inner, [Provider2, props]) => /* @__PURE__ */ (0, import_jsx_runtime216.jsx)(Provider2, { ...props, children: inner }), 34355 innerMarkup 34356 ); 34357 } }) }); 34358 } 34359 34360 // packages/block-editor/build-module/components/block-controls/slot.js 34361 var import_element100 = __toESM(require_element()); 34362 var import_components77 = __toESM(require_components()); 34363 var import_warning7 = __toESM(require_warning()); 34364 var import_jsx_runtime217 = __toESM(require_jsx_runtime()); 34365 var { ComponentsContext } = unlock(import_components77.privateApis); 34366 function BlockControlsSlot({ group = "default", ...props }) { 34367 const toolbarState = (0, import_element100.useContext)(import_components77.__experimentalToolbarContext); 34368 const contextState = (0, import_element100.useContext)(ComponentsContext); 34369 const fillProps = (0, import_element100.useMemo)( 34370 () => ({ 34371 forwardedContext: [ 34372 [import_components77.__experimentalToolbarContext.Provider, { value: toolbarState }], 34373 [ComponentsContext.Provider, { value: contextState }] 34374 ] 34375 }), 34376 [toolbarState, contextState] 34377 ); 34378 const slotFill = groups_default2[group]; 34379 const fills = (0, import_components77.__experimentalUseSlotFills)(slotFill.name); 34380 if (!slotFill) { 34381 (0, import_warning7.default)(`Unknown BlockControls group "$group}" provided.`); 34382 return null; 34383 } 34384 if (!fills?.length) { 34385 return null; 34386 } 34387 const { Slot: Slot6 } = slotFill; 34388 const slot = /* @__PURE__ */ (0, import_jsx_runtime217.jsx)(Slot6, { ...props, bubblesVirtually: true, fillProps }); 34389 if (group === "default") { 34390 return slot; 34391 } 34392 return /* @__PURE__ */ (0, import_jsx_runtime217.jsx)(import_components77.ToolbarGroup, { children: slot }); 34393 } 34394 34395 // packages/block-editor/build-module/components/block-controls/index.js 34396 var import_jsx_runtime218 = __toESM(require_jsx_runtime()); 34397 var BlockControls = BlockControlsFill; 34398 BlockControls.Slot = BlockControlsSlot; 34399 var BlockFormatControls = (props) => { 34400 return /* @__PURE__ */ (0, import_jsx_runtime218.jsx)(BlockControlsFill, { group: "inline", ...props }); 34401 }; 34402 BlockFormatControls.Slot = (props) => { 34403 return /* @__PURE__ */ (0, import_jsx_runtime218.jsx)(BlockControlsSlot, { group: "inline", ...props }); 34404 }; 34405 var block_controls_default = BlockControls; 34406 34407 // packages/block-editor/build-module/components/block-toolbar/block-toolbar-last-item.js 34408 var import_components78 = __toESM(require_components()); 34409 var { Fill: __unstableBlockToolbarLastItem, Slot: Slot2 } = (0, import_components78.createSlotFill)( 34410 "__unstableBlockToolbarLastItem" 34411 ); 34412 __unstableBlockToolbarLastItem.Slot = Slot2; 34413 var block_toolbar_last_item_default = __unstableBlockToolbarLastItem; 34414 34415 // packages/block-editor/build-module/components/block-settings-menu/index.js 34416 var import_components98 = __toESM(require_components()); 34417 34418 // packages/block-editor/build-module/components/block-settings-menu/block-settings-dropdown.js 34419 var import_blocks60 = __toESM(require_blocks()); 34420 var import_components96 = __toESM(require_components()); 34421 var import_data103 = __toESM(require_data()); 34422 var import_element110 = __toESM(require_element()); 34423 var import_i18n87 = __toESM(require_i18n()); 34424 var import_keyboard_shortcuts5 = __toESM(require_keyboard_shortcuts()); 34425 var import_compose62 = __toESM(require_compose()); 34426 34427 // packages/block-editor/build-module/components/block-actions/index.js 34428 var import_data87 = __toESM(require_data()); 34429 var import_blocks49 = __toESM(require_blocks()); 34430 34431 // packages/block-editor/build-module/components/use-paste-styles/index.js 34432 var import_element102 = __toESM(require_element()); 34433 var import_blocks48 = __toESM(require_blocks()); 34434 var import_data86 = __toESM(require_data()); 34435 var import_notices6 = __toESM(require_notices()); 34436 var import_i18n72 = __toESM(require_i18n()); 34437 34438 // packages/block-editor/build-module/hooks/supports.js 34439 var import_blocks47 = __toESM(require_blocks()); 34440 var import_element101 = __toESM(require_element()); 34441 var ALIGN_SUPPORT_KEY = "align"; 34442 var BORDER_SUPPORT_KEY = "__experimentalBorder"; 34443 var COLOR_SUPPORT_KEY = "color"; 34444 var CUSTOM_CLASS_NAME_SUPPORT_KEY = "customClassName"; 34445 var FONT_FAMILY_SUPPORT_KEY = "typography.__experimentalFontFamily"; 34446 var FONT_SIZE_SUPPORT_KEY = "typography.fontSize"; 34447 var LINE_HEIGHT_SUPPORT_KEY = "typography.lineHeight"; 34448 var FONT_STYLE_SUPPORT_KEY = "typography.__experimentalFontStyle"; 34449 var FONT_WEIGHT_SUPPORT_KEY = "typography.__experimentalFontWeight"; 34450 var TEXT_ALIGN_SUPPORT_KEY = "typography.textAlign"; 34451 var TEXT_COLUMNS_SUPPORT_KEY = "typography.textColumns"; 34452 var TEXT_DECORATION_SUPPORT_KEY = "typography.__experimentalTextDecoration"; 34453 var WRITING_MODE_SUPPORT_KEY = "typography.__experimentalWritingMode"; 34454 var TEXT_TRANSFORM_SUPPORT_KEY = "typography.__experimentalTextTransform"; 34455 var LETTER_SPACING_SUPPORT_KEY = "typography.__experimentalLetterSpacing"; 34456 var LAYOUT_SUPPORT_KEY = "layout"; 34457 var TYPOGRAPHY_SUPPORT_KEYS = [ 34458 LINE_HEIGHT_SUPPORT_KEY, 34459 FONT_SIZE_SUPPORT_KEY, 34460 FONT_STYLE_SUPPORT_KEY, 34461 FONT_WEIGHT_SUPPORT_KEY, 34462 FONT_FAMILY_SUPPORT_KEY, 34463 TEXT_ALIGN_SUPPORT_KEY, 34464 TEXT_COLUMNS_SUPPORT_KEY, 34465 TEXT_DECORATION_SUPPORT_KEY, 34466 TEXT_TRANSFORM_SUPPORT_KEY, 34467 WRITING_MODE_SUPPORT_KEY, 34468 LETTER_SPACING_SUPPORT_KEY 34469 ]; 34470 var EFFECTS_SUPPORT_KEYS = ["shadow"]; 34471 var SPACING_SUPPORT_KEY = "spacing"; 34472 var styleSupportKeys = [ 34473 ...EFFECTS_SUPPORT_KEYS, 34474 ...TYPOGRAPHY_SUPPORT_KEYS, 34475 BORDER_SUPPORT_KEY, 34476 COLOR_SUPPORT_KEY, 34477 SPACING_SUPPORT_KEY 34478 ]; 34479 var hasAlignSupport = (nameOrType) => (0, import_blocks47.hasBlockSupport)(nameOrType, ALIGN_SUPPORT_KEY); 34480 function hasBorderSupport(nameOrType, feature = "any") { 34481 if (import_element101.Platform.OS !== "web") { 34482 return false; 34483 } 34484 const support = (0, import_blocks47.getBlockSupport)(nameOrType, BORDER_SUPPORT_KEY); 34485 if (support === true) { 34486 return true; 34487 } 34488 if (feature === "any") { 34489 return !!(support?.color || support?.radius || support?.width || support?.style); 34490 } 34491 return !!support?.[feature]; 34492 } 34493 var hasGradientSupport = (nameOrType) => { 34494 const colorSupport = (0, import_blocks47.getBlockSupport)(nameOrType, COLOR_SUPPORT_KEY); 34495 return colorSupport !== null && typeof colorSupport === "object" && !!colorSupport.gradients; 34496 }; 34497 var hasBackgroundColorSupport = (nameOrType) => { 34498 const colorSupport = (0, import_blocks47.getBlockSupport)(nameOrType, COLOR_SUPPORT_KEY); 34499 return colorSupport && colorSupport.background !== false; 34500 }; 34501 var hasTextAlignSupport = (nameOrType) => (0, import_blocks47.hasBlockSupport)(nameOrType, TEXT_ALIGN_SUPPORT_KEY); 34502 var hasTextColorSupport = (nameOrType) => { 34503 const colorSupport = (0, import_blocks47.getBlockSupport)(nameOrType, COLOR_SUPPORT_KEY); 34504 return colorSupport && colorSupport.text !== false; 34505 }; 34506 var hasCustomClassNameSupport = (nameOrType) => (0, import_blocks47.hasBlockSupport)(nameOrType, CUSTOM_CLASS_NAME_SUPPORT_KEY, true); 34507 var hasFontFamilySupport = (nameOrType) => (0, import_blocks47.hasBlockSupport)(nameOrType, FONT_FAMILY_SUPPORT_KEY); 34508 var hasFontSizeSupport = (nameOrType) => (0, import_blocks47.hasBlockSupport)(nameOrType, FONT_SIZE_SUPPORT_KEY); 34509 var hasLayoutSupport = (nameOrType) => (0, import_blocks47.hasBlockSupport)(nameOrType, LAYOUT_SUPPORT_KEY); 34510 var hasStyleSupport = (nameOrType) => styleSupportKeys.some((key) => (0, import_blocks47.hasBlockSupport)(nameOrType, key)); 34511 34512 // packages/block-editor/build-module/components/use-paste-styles/index.js 34513 function hasSerializedBlocks(text) { 34514 try { 34515 const blocks2 = (0, import_blocks48.parse)(text, { 34516 __unstableSkipMigrationLogs: true, 34517 __unstableSkipAutop: true 34518 }); 34519 if (blocks2.length === 1 && blocks2[0].name === "core/freeform") { 34520 return false; 34521 } 34522 return true; 34523 } catch (err) { 34524 return false; 34525 } 34526 } 34527 var STYLE_ATTRIBUTES = { 34528 align: hasAlignSupport, 34529 borderColor: (nameOrType) => hasBorderSupport(nameOrType, "color"), 34530 backgroundColor: hasBackgroundColorSupport, 34531 textAlign: hasTextAlignSupport, 34532 textColor: hasTextColorSupport, 34533 gradient: hasGradientSupport, 34534 className: hasCustomClassNameSupport, 34535 fontFamily: hasFontFamilySupport, 34536 fontSize: hasFontSizeSupport, 34537 layout: hasLayoutSupport, 34538 style: hasStyleSupport 34539 }; 34540 function getStyleAttributes(sourceBlock, targetBlock) { 34541 return Object.entries(STYLE_ATTRIBUTES).reduce( 34542 (attributes, [attributeKey, hasSupport]) => { 34543 if (hasSupport(sourceBlock.name) && hasSupport(targetBlock.name)) { 34544 attributes[attributeKey] = sourceBlock.attributes[attributeKey]; 34545 } 34546 return attributes; 34547 }, 34548 {} 34549 ); 34550 } 34551 function recursivelyUpdateBlockAttributes(targetBlocks, sourceBlocks, updateBlockAttributes2) { 34552 for (let index = 0; index < Math.min(sourceBlocks.length, targetBlocks.length); index += 1) { 34553 updateBlockAttributes2( 34554 targetBlocks[index].clientId, 34555 getStyleAttributes(sourceBlocks[index], targetBlocks[index]) 34556 ); 34557 recursivelyUpdateBlockAttributes( 34558 targetBlocks[index].innerBlocks, 34559 sourceBlocks[index].innerBlocks, 34560 updateBlockAttributes2 34561 ); 34562 } 34563 } 34564 function usePasteStyles() { 34565 const registry = (0, import_data86.useRegistry)(); 34566 const { updateBlockAttributes: updateBlockAttributes2 } = (0, import_data86.useDispatch)(store); 34567 const { createSuccessNotice, createWarningNotice, createErrorNotice } = (0, import_data86.useDispatch)(import_notices6.store); 34568 return (0, import_element102.useCallback)( 34569 async (targetBlocks) => { 34570 let html = ""; 34571 try { 34572 if (!window.navigator.clipboard) { 34573 createErrorNotice( 34574 (0, import_i18n72.__)( 34575 "Unable to paste styles. This feature is only available on secure (https) sites in supporting browsers." 34576 ), 34577 { type: "snackbar" } 34578 ); 34579 return; 34580 } 34581 html = await window.navigator.clipboard.readText(); 34582 } catch (error) { 34583 createErrorNotice( 34584 (0, import_i18n72.__)( 34585 "Unable to paste styles. Please allow browser clipboard permissions before continuing." 34586 ), 34587 { 34588 type: "snackbar" 34589 } 34590 ); 34591 return; 34592 } 34593 if (!html || !hasSerializedBlocks(html)) { 34594 createWarningNotice( 34595 (0, import_i18n72.__)( 34596 "Unable to paste styles. Block styles couldn't be found within the copied content." 34597 ), 34598 { 34599 type: "snackbar" 34600 } 34601 ); 34602 return; 34603 } 34604 const copiedBlocks = (0, import_blocks48.parse)(html); 34605 if (copiedBlocks.length === 1) { 34606 registry.batch(() => { 34607 recursivelyUpdateBlockAttributes( 34608 targetBlocks, 34609 targetBlocks.map(() => copiedBlocks[0]), 34610 updateBlockAttributes2 34611 ); 34612 }); 34613 } else { 34614 registry.batch(() => { 34615 recursivelyUpdateBlockAttributes( 34616 targetBlocks, 34617 copiedBlocks, 34618 updateBlockAttributes2 34619 ); 34620 }); 34621 } 34622 if (targetBlocks.length === 1) { 34623 const title = (0, import_blocks48.getBlockType)(targetBlocks[0].name)?.title; 34624 createSuccessNotice( 34625 (0, import_i18n72.sprintf)( 34626 // Translators: %s: Name of the block being pasted, e.g. "Paragraph". 34627 (0, import_i18n72.__)("Pasted styles to %s."), 34628 title 34629 ), 34630 { type: "snackbar" } 34631 ); 34632 } else { 34633 createSuccessNotice( 34634 (0, import_i18n72.sprintf)( 34635 // Translators: %d: The number of the blocks. 34636 (0, import_i18n72.__)("Pasted styles to %d blocks."), 34637 targetBlocks.length 34638 ), 34639 { type: "snackbar" } 34640 ); 34641 } 34642 }, 34643 [ 34644 registry.batch, 34645 updateBlockAttributes2, 34646 createSuccessNotice, 34647 createWarningNotice, 34648 createErrorNotice 34649 ] 34650 ); 34651 } 34652 34653 // packages/block-editor/build-module/components/block-actions/index.js 34654 function BlockActions({ 34655 clientIds, 34656 children, 34657 __experimentalUpdateSelection: updateSelection 34658 }) { 34659 const { getDefaultBlockName: getDefaultBlockName7, getGroupingBlockName } = (0, import_data87.useSelect)(import_blocks49.store); 34660 const selected = (0, import_data87.useSelect)( 34661 (select3) => { 34662 const { 34663 canInsertBlockType: canInsertBlockType2, 34664 getBlockRootClientId: getBlockRootClientId2, 34665 getBlocksByClientId: getBlocksByClientId22, 34666 getDirectInsertBlock: getDirectInsertBlock2, 34667 canRemoveBlocks: canRemoveBlocks2 34668 } = select3(store); 34669 const blocks2 = getBlocksByClientId22(clientIds); 34670 const rootClientId = getBlockRootClientId2(clientIds[0]); 34671 const canInsertDefaultBlock = canInsertBlockType2( 34672 getDefaultBlockName7(), 34673 rootClientId 34674 ); 34675 const directInsertBlock = rootClientId ? getDirectInsertBlock2(rootClientId) : null; 34676 return { 34677 canRemove: canRemoveBlocks2(clientIds), 34678 canInsertBlock: blocks2.every((block) => { 34679 return (canInsertDefaultBlock || !!directInsertBlock) && canInsertBlockType2(block.name, rootClientId); 34680 }), 34681 canCopyStyles: blocks2.every((block) => { 34682 return !!block && ((0, import_blocks49.hasBlockSupport)(block.name, "color") || (0, import_blocks49.hasBlockSupport)(block.name, "typography")); 34683 }), 34684 canDuplicate: blocks2.every((block) => { 34685 return !!block && (0, import_blocks49.hasBlockSupport)(block.name, "multiple", true) && canInsertBlockType2(block.name, rootClientId); 34686 }) 34687 }; 34688 }, 34689 [clientIds, getDefaultBlockName7] 34690 ); 34691 const { getBlocksByClientId: getBlocksByClientId2, getBlocks: getBlocks2 } = (0, import_data87.useSelect)(store); 34692 const { canRemove, canInsertBlock, canCopyStyles, canDuplicate } = selected; 34693 const { 34694 removeBlocks: removeBlocks2, 34695 replaceBlocks: replaceBlocks2, 34696 duplicateBlocks: duplicateBlocks2, 34697 insertAfterBlock: insertAfterBlock2, 34698 insertBeforeBlock: insertBeforeBlock2, 34699 flashBlock: flashBlock2 34700 } = (0, import_data87.useDispatch)(store); 34701 const pasteStyles = usePasteStyles(); 34702 return children({ 34703 canCopyStyles, 34704 canDuplicate, 34705 canInsertBlock, 34706 canRemove, 34707 onDuplicate() { 34708 return duplicateBlocks2(clientIds, updateSelection); 34709 }, 34710 onRemove() { 34711 return removeBlocks2(clientIds, updateSelection); 34712 }, 34713 onInsertBefore() { 34714 insertBeforeBlock2(clientIds[0]); 34715 }, 34716 onInsertAfter() { 34717 insertAfterBlock2(clientIds[clientIds.length - 1]); 34718 }, 34719 onGroup() { 34720 if (!clientIds.length) { 34721 return; 34722 } 34723 const groupingBlockName = getGroupingBlockName(); 34724 const newBlocks = (0, import_blocks49.switchToBlockType)( 34725 getBlocksByClientId2(clientIds), 34726 groupingBlockName 34727 ); 34728 if (!newBlocks) { 34729 return; 34730 } 34731 replaceBlocks2(clientIds, newBlocks); 34732 }, 34733 onUngroup() { 34734 if (!clientIds.length) { 34735 return; 34736 } 34737 const innerBlocks = getBlocks2(clientIds[0]); 34738 if (!innerBlocks.length) { 34739 return; 34740 } 34741 replaceBlocks2(clientIds, innerBlocks); 34742 }, 34743 onCopy() { 34744 if (clientIds.length === 1) { 34745 flashBlock2(clientIds[0]); 34746 } 34747 }, 34748 async onPasteStyles() { 34749 await pasteStyles(getBlocksByClientId2(clientIds)); 34750 } 34751 }); 34752 } 34753 34754 // packages/block-editor/build-module/components/collab/block-comment-icon-slot.js 34755 var import_components79 = __toESM(require_components()); 34756 var CommentIconSlotFill = (0, import_components79.createSlotFill)(Symbol("CommentIconSlotFill")); 34757 var block_comment_icon_slot_default = CommentIconSlotFill; 34758 34759 // packages/block-editor/build-module/components/block-settings-menu/block-html-convert-button.js 34760 var import_i18n73 = __toESM(require_i18n()); 34761 var import_components80 = __toESM(require_components()); 34762 var import_blocks50 = __toESM(require_blocks()); 34763 var import_data88 = __toESM(require_data()); 34764 var import_jsx_runtime219 = __toESM(require_jsx_runtime()); 34765 function BlockHTMLConvertButton({ clientId }) { 34766 const block = (0, import_data88.useSelect)( 34767 (select3) => select3(store).getBlock(clientId), 34768 [clientId] 34769 ); 34770 const { replaceBlocks: replaceBlocks2 } = (0, import_data88.useDispatch)(store); 34771 if (!block || block.name !== "core/html") { 34772 return null; 34773 } 34774 return /* @__PURE__ */ (0, import_jsx_runtime219.jsx)( 34775 import_components80.MenuItem, 34776 { 34777 onClick: () => replaceBlocks2( 34778 clientId, 34779 (0, import_blocks50.rawHandler)({ HTML: (0, import_blocks50.getBlockContent)(block) }) 34780 ), 34781 children: (0, import_i18n73.__)("Convert to Blocks") 34782 } 34783 ); 34784 } 34785 var block_html_convert_button_default = BlockHTMLConvertButton; 34786 34787 // packages/block-editor/build-module/components/block-settings-menu/block-settings-menu-first-item.js 34788 var import_components81 = __toESM(require_components()); 34789 var { Fill: __unstableBlockSettingsMenuFirstItem, Slot: Slot3 } = (0, import_components81.createSlotFill)( 34790 "__unstableBlockSettingsMenuFirstItem" 34791 ); 34792 __unstableBlockSettingsMenuFirstItem.Slot = Slot3; 34793 var block_settings_menu_first_item_default = __unstableBlockSettingsMenuFirstItem; 34794 34795 // packages/block-editor/build-module/components/block-settings-menu-controls/index.js 34796 var import_components94 = __toESM(require_components()); 34797 var import_blocks59 = __toESM(require_blocks()); 34798 var import_data101 = __toESM(require_data()); 34799 34800 // packages/block-editor/build-module/components/convert-to-group-buttons/index.js 34801 var import_components83 = __toESM(require_components()); 34802 var import_i18n75 = __toESM(require_i18n()); 34803 var import_blocks53 = __toESM(require_blocks()); 34804 var import_data91 = __toESM(require_data()); 34805 var import_keycodes9 = __toESM(require_keycodes()); 34806 34807 // packages/block-editor/build-module/components/convert-to-group-buttons/use-convert-to-group-button-props.js 34808 var import_blocks51 = __toESM(require_blocks()); 34809 var import_data89 = __toESM(require_data()); 34810 function useConvertToGroupButtonProps(selectedClientIds) { 34811 return (0, import_data89.useSelect)( 34812 (select3) => { 34813 const { 34814 getBlocksByClientId: getBlocksByClientId2, 34815 getSelectedBlockClientIds: getSelectedBlockClientIds2, 34816 isUngroupable: isUngroupable2, 34817 isGroupable: isGroupable2 34818 } = select3(store); 34819 const { getGroupingBlockName, getBlockType: getBlockType21 } = select3(import_blocks51.store); 34820 const clientIds = selectedClientIds?.length ? selectedClientIds : getSelectedBlockClientIds2(); 34821 const blocksSelection = getBlocksByClientId2(clientIds); 34822 const [firstSelectedBlock] = blocksSelection; 34823 const _isUngroupable = clientIds.length === 1 && isUngroupable2(clientIds[0]); 34824 return { 34825 clientIds, 34826 isGroupable: isGroupable2(clientIds), 34827 isUngroupable: _isUngroupable, 34828 blocksSelection, 34829 groupingBlockName: getGroupingBlockName(), 34830 onUngroup: _isUngroupable && getBlockType21(firstSelectedBlock.name)?.transforms?.ungroup 34831 }; 34832 }, 34833 [selectedClientIds] 34834 ); 34835 } 34836 34837 // packages/block-editor/build-module/components/convert-to-group-buttons/toolbar.js 34838 var import_data90 = __toESM(require_data()); 34839 var import_blocks52 = __toESM(require_blocks()); 34840 var import_components82 = __toESM(require_components()); 34841 var import_i18n74 = __toESM(require_i18n()); 34842 var import_jsx_runtime220 = __toESM(require_jsx_runtime()); 34843 var layouts = { 34844 group: { type: "constrained" }, 34845 row: { type: "flex", flexWrap: "nowrap" }, 34846 stack: { type: "flex", orientation: "vertical" }, 34847 grid: { type: "grid" } 34848 }; 34849 function BlockGroupToolbar() { 34850 const { blocksSelection, clientIds, groupingBlockName, isGroupable: isGroupable2 } = useConvertToGroupButtonProps(); 34851 const { replaceBlocks: replaceBlocks2 } = (0, import_data90.useDispatch)(store); 34852 const { canRemove, variations } = (0, import_data90.useSelect)( 34853 (select3) => { 34854 const { canRemoveBlocks: canRemoveBlocks2 } = select3(store); 34855 const { getBlockVariations: getBlockVariations2 } = select3(import_blocks52.store); 34856 return { 34857 canRemove: canRemoveBlocks2(clientIds), 34858 variations: getBlockVariations2( 34859 groupingBlockName, 34860 "transform" 34861 ) 34862 }; 34863 }, 34864 [clientIds, groupingBlockName] 34865 ); 34866 const onConvertToGroup = (layout) => { 34867 const newBlocks = (0, import_blocks52.switchToBlockType)( 34868 blocksSelection, 34869 groupingBlockName 34870 ); 34871 if (typeof layout !== "string") { 34872 layout = "group"; 34873 } 34874 if (newBlocks && newBlocks.length > 0) { 34875 newBlocks[0].attributes.layout = layouts[layout]; 34876 replaceBlocks2(clientIds, newBlocks); 34877 } 34878 }; 34879 const onConvertToRow = () => onConvertToGroup("row"); 34880 const onConvertToStack = () => onConvertToGroup("stack"); 34881 const onConvertToGrid = () => onConvertToGroup("grid"); 34882 if (!isGroupable2 || !canRemove) { 34883 return null; 34884 } 34885 const canInsertRow = !!variations.find( 34886 ({ name }) => name === "group-row" 34887 ); 34888 const canInsertStack = !!variations.find( 34889 ({ name }) => name === "group-stack" 34890 ); 34891 const canInsertGrid = !!variations.find( 34892 ({ name }) => name === "group-grid" 34893 ); 34894 return /* @__PURE__ */ (0, import_jsx_runtime220.jsxs)(import_components82.ToolbarGroup, { children: [ 34895 /* @__PURE__ */ (0, import_jsx_runtime220.jsx)( 34896 import_components82.ToolbarButton, 34897 { 34898 icon: group_default, 34899 label: (0, import_i18n74._x)("Group", "action: convert blocks to group"), 34900 onClick: onConvertToGroup 34901 } 34902 ), 34903 canInsertRow && /* @__PURE__ */ (0, import_jsx_runtime220.jsx)( 34904 import_components82.ToolbarButton, 34905 { 34906 icon: row_default, 34907 label: (0, import_i18n74._x)("Row", "action: convert blocks to row"), 34908 onClick: onConvertToRow 34909 } 34910 ), 34911 canInsertStack && /* @__PURE__ */ (0, import_jsx_runtime220.jsx)( 34912 import_components82.ToolbarButton, 34913 { 34914 icon: stack_default, 34915 label: (0, import_i18n74._x)("Stack", "action: convert blocks to stack"), 34916 onClick: onConvertToStack 34917 } 34918 ), 34919 canInsertGrid && /* @__PURE__ */ (0, import_jsx_runtime220.jsx)( 34920 import_components82.ToolbarButton, 34921 { 34922 icon: grid_default, 34923 label: (0, import_i18n74._x)("Grid", "action: convert blocks to grid"), 34924 onClick: onConvertToGrid 34925 } 34926 ) 34927 ] }); 34928 } 34929 var toolbar_default = BlockGroupToolbar; 34930 34931 // packages/block-editor/build-module/components/convert-to-group-buttons/index.js 34932 var import_jsx_runtime221 = __toESM(require_jsx_runtime()); 34933 function ConvertToGroupButton({ 34934 clientIds, 34935 isGroupable: isGroupable2, 34936 isUngroupable: isUngroupable2, 34937 onUngroup, 34938 blocksSelection, 34939 groupingBlockName, 34940 onClose = () => { 34941 } 34942 }) { 34943 const { getSelectedBlockClientIds: getSelectedBlockClientIds2 } = (0, import_data91.useSelect)(store); 34944 const { replaceBlocks: replaceBlocks2 } = (0, import_data91.useDispatch)(store); 34945 const onConvertToGroup = () => { 34946 const newBlocks = (0, import_blocks53.switchToBlockType)( 34947 blocksSelection, 34948 groupingBlockName 34949 ); 34950 if (newBlocks) { 34951 replaceBlocks2(clientIds, newBlocks); 34952 } 34953 }; 34954 const onConvertFromGroup = () => { 34955 let innerBlocks = blocksSelection[0].innerBlocks; 34956 if (!innerBlocks.length) { 34957 return; 34958 } 34959 if (onUngroup) { 34960 innerBlocks = onUngroup( 34961 blocksSelection[0].attributes, 34962 blocksSelection[0].innerBlocks 34963 ); 34964 } 34965 replaceBlocks2(clientIds, innerBlocks); 34966 }; 34967 if (!isGroupable2 && !isUngroupable2) { 34968 return null; 34969 } 34970 const selectedBlockClientIds = getSelectedBlockClientIds2(); 34971 return /* @__PURE__ */ (0, import_jsx_runtime221.jsxs)(import_jsx_runtime221.Fragment, { children: [ 34972 isGroupable2 && /* @__PURE__ */ (0, import_jsx_runtime221.jsx)( 34973 import_components83.MenuItem, 34974 { 34975 shortcut: selectedBlockClientIds.length > 1 ? import_keycodes9.displayShortcut.primary("g") : void 0, 34976 onClick: () => { 34977 onConvertToGroup(); 34978 onClose(); 34979 }, 34980 children: (0, import_i18n75._x)("Group", "verb") 34981 } 34982 ), 34983 isUngroupable2 && /* @__PURE__ */ (0, import_jsx_runtime221.jsx)( 34984 import_components83.MenuItem, 34985 { 34986 onClick: () => { 34987 onConvertFromGroup(); 34988 onClose(); 34989 }, 34990 children: (0, import_i18n75._x)( 34991 "Ungroup", 34992 "Ungrouping blocks from within a grouping block back into individual blocks within the Editor" 34993 ) 34994 } 34995 ) 34996 ] }); 34997 } 34998 34999 // packages/block-editor/build-module/components/block-lock/menu-item.js 35000 var import_i18n77 = __toESM(require_i18n()); 35001 var import_element104 = __toESM(require_element()); 35002 var import_components85 = __toESM(require_components()); 35003 35004 // packages/block-editor/build-module/components/block-lock/use-block-lock.js 35005 var import_data92 = __toESM(require_data()); 35006 function useBlockLock(clientId) { 35007 return (0, import_data92.useSelect)( 35008 (select3) => { 35009 const { 35010 canLockBlockType: canLockBlockType2, 35011 getBlockName: getBlockName2, 35012 isEditLockedBlock: isEditLockedBlock2, 35013 isMoveLockedBlock: isMoveLockedBlock2, 35014 isRemoveLockedBlock: isRemoveLockedBlock2, 35015 isLockedBlock: isLockedBlock2 35016 } = unlock(select3(store)); 35017 return { 35018 isEditLocked: isEditLockedBlock2(clientId), 35019 isMoveLocked: isMoveLockedBlock2(clientId), 35020 isRemoveLocked: isRemoveLockedBlock2(clientId), 35021 canLock: canLockBlockType2(getBlockName2(clientId)), 35022 isLocked: isLockedBlock2(clientId) 35023 }; 35024 }, 35025 [clientId] 35026 ); 35027 } 35028 35029 // packages/block-editor/build-module/components/block-lock/modal.js 35030 var import_i18n76 = __toESM(require_i18n()); 35031 var import_element103 = __toESM(require_element()); 35032 var import_components84 = __toESM(require_components()); 35033 var import_data93 = __toESM(require_data()); 35034 var import_blocks54 = __toESM(require_blocks()); 35035 var import_jsx_runtime222 = __toESM(require_jsx_runtime()); 35036 var ALLOWS_EDIT_LOCKING = ["core/navigation"]; 35037 function getTemplateLockValue(lock4) { 35038 if (lock4.remove && lock4.move) { 35039 return "all"; 35040 } 35041 if (lock4.remove && !lock4.move) { 35042 return "insert"; 35043 } 35044 return false; 35045 } 35046 function BlockLockModal({ clientId, onClose }) { 35047 const [lock4, setLock] = (0, import_element103.useState)({ move: false, remove: false }); 35048 const { isEditLocked, isMoveLocked, isRemoveLocked } = useBlockLock(clientId); 35049 const { allowsEditLocking, templateLock, hasTemplateLock } = (0, import_data93.useSelect)( 35050 (select3) => { 35051 const { getBlockName: getBlockName2, getBlockAttributes: getBlockAttributes3 } = select3(store); 35052 const blockName = getBlockName2(clientId); 35053 const blockType = (0, import_blocks54.getBlockType)(blockName); 35054 return { 35055 allowsEditLocking: ALLOWS_EDIT_LOCKING.includes(blockName), 35056 templateLock: getBlockAttributes3(clientId)?.templateLock, 35057 hasTemplateLock: !!blockType?.attributes?.templateLock 35058 }; 35059 }, 35060 [clientId] 35061 ); 35062 const [applyTemplateLock, setApplyTemplateLock] = (0, import_element103.useState)( 35063 !!templateLock 35064 ); 35065 const { updateBlockAttributes: updateBlockAttributes2 } = (0, import_data93.useDispatch)(store); 35066 const blockInformation = useBlockDisplayInformation(clientId); 35067 (0, import_element103.useEffect)(() => { 35068 setLock({ 35069 move: isMoveLocked, 35070 remove: isRemoveLocked, 35071 ...allowsEditLocking ? { edit: isEditLocked } : {} 35072 }); 35073 }, [isEditLocked, isMoveLocked, isRemoveLocked, allowsEditLocking]); 35074 const isAllChecked = Object.values(lock4).every(Boolean); 35075 const isMixed = Object.values(lock4).some(Boolean) && !isAllChecked; 35076 return /* @__PURE__ */ (0, import_jsx_runtime222.jsx)( 35077 import_components84.Modal, 35078 { 35079 title: (0, import_i18n76.sprintf)( 35080 /* translators: %s: Name of the block. */ 35081 (0, import_i18n76.__)("Lock %s"), 35082 blockInformation.title 35083 ), 35084 overlayClassName: "block-editor-block-lock-modal", 35085 onRequestClose: onClose, 35086 size: "small", 35087 children: /* @__PURE__ */ (0, import_jsx_runtime222.jsxs)( 35088 "form", 35089 { 35090 onSubmit: (event) => { 35091 event.preventDefault(); 35092 updateBlockAttributes2([clientId], { 35093 lock: lock4, 35094 templateLock: applyTemplateLock ? getTemplateLockValue(lock4) : void 0 35095 }); 35096 onClose(); 35097 }, 35098 children: [ 35099 /* @__PURE__ */ (0, import_jsx_runtime222.jsxs)("fieldset", { className: "block-editor-block-lock-modal__options", children: [ 35100 /* @__PURE__ */ (0, import_jsx_runtime222.jsx)("legend", { children: (0, import_i18n76.__)("Select the features you want to lock") }), 35101 /* @__PURE__ */ (0, import_jsx_runtime222.jsx)( 35102 "ul", 35103 { 35104 role: "list", 35105 className: "block-editor-block-lock-modal__checklist", 35106 children: /* @__PURE__ */ (0, import_jsx_runtime222.jsxs)("li", { children: [ 35107 /* @__PURE__ */ (0, import_jsx_runtime222.jsx)( 35108 import_components84.CheckboxControl, 35109 { 35110 className: "block-editor-block-lock-modal__options-all", 35111 label: (0, import_i18n76.__)("Lock all"), 35112 checked: isAllChecked, 35113 indeterminate: isMixed, 35114 onChange: (newValue) => setLock({ 35115 move: newValue, 35116 remove: newValue, 35117 ...allowsEditLocking ? { edit: newValue } : {} 35118 }) 35119 } 35120 ), 35121 /* @__PURE__ */ (0, import_jsx_runtime222.jsxs)( 35122 "ul", 35123 { 35124 role: "list", 35125 className: "block-editor-block-lock-modal__checklist", 35126 children: [ 35127 allowsEditLocking && /* @__PURE__ */ (0, import_jsx_runtime222.jsxs)("li", { className: "block-editor-block-lock-modal__checklist-item", children: [ 35128 /* @__PURE__ */ (0, import_jsx_runtime222.jsx)( 35129 import_components84.CheckboxControl, 35130 { 35131 label: (0, import_i18n76.__)("Lock editing"), 35132 checked: !!lock4.edit, 35133 onChange: (edit) => setLock((prevLock) => ({ 35134 ...prevLock, 35135 edit 35136 })) 35137 } 35138 ), 35139 /* @__PURE__ */ (0, import_jsx_runtime222.jsx)( 35140 import_components84.Icon, 35141 { 35142 className: "block-editor-block-lock-modal__lock-icon", 35143 icon: lock4.edit ? lock_default : unlock_default 35144 } 35145 ) 35146 ] }), 35147 /* @__PURE__ */ (0, import_jsx_runtime222.jsxs)("li", { className: "block-editor-block-lock-modal__checklist-item", children: [ 35148 /* @__PURE__ */ (0, import_jsx_runtime222.jsx)( 35149 import_components84.CheckboxControl, 35150 { 35151 label: (0, import_i18n76.__)("Lock movement"), 35152 checked: lock4.move, 35153 onChange: (move) => setLock((prevLock) => ({ 35154 ...prevLock, 35155 move 35156 })) 35157 } 35158 ), 35159 /* @__PURE__ */ (0, import_jsx_runtime222.jsx)( 35160 import_components84.Icon, 35161 { 35162 className: "block-editor-block-lock-modal__lock-icon", 35163 icon: lock4.move ? lock_default : unlock_default 35164 } 35165 ) 35166 ] }), 35167 /* @__PURE__ */ (0, import_jsx_runtime222.jsxs)("li", { className: "block-editor-block-lock-modal__checklist-item", children: [ 35168 /* @__PURE__ */ (0, import_jsx_runtime222.jsx)( 35169 import_components84.CheckboxControl, 35170 { 35171 label: (0, import_i18n76.__)("Lock removal"), 35172 checked: lock4.remove, 35173 onChange: (remove5) => setLock((prevLock) => ({ 35174 ...prevLock, 35175 remove: remove5 35176 })) 35177 } 35178 ), 35179 /* @__PURE__ */ (0, import_jsx_runtime222.jsx)( 35180 import_components84.Icon, 35181 { 35182 className: "block-editor-block-lock-modal__lock-icon", 35183 icon: lock4.remove ? lock_default : unlock_default 35184 } 35185 ) 35186 ] }) 35187 ] 35188 } 35189 ) 35190 ] }) 35191 } 35192 ), 35193 hasTemplateLock && /* @__PURE__ */ (0, import_jsx_runtime222.jsx)( 35194 import_components84.ToggleControl, 35195 { 35196 className: "block-editor-block-lock-modal__template-lock", 35197 label: (0, import_i18n76.__)("Apply to all blocks inside"), 35198 checked: applyTemplateLock, 35199 disabled: lock4.move && !lock4.remove, 35200 onChange: () => setApplyTemplateLock(!applyTemplateLock) 35201 } 35202 ) 35203 ] }), 35204 /* @__PURE__ */ (0, import_jsx_runtime222.jsxs)( 35205 import_components84.Flex, 35206 { 35207 className: "block-editor-block-lock-modal__actions", 35208 justify: "flex-end", 35209 expanded: false, 35210 children: [ 35211 /* @__PURE__ */ (0, import_jsx_runtime222.jsx)(import_components84.FlexItem, { children: /* @__PURE__ */ (0, import_jsx_runtime222.jsx)( 35212 import_components84.Button, 35213 { 35214 variant: "tertiary", 35215 onClick: onClose, 35216 __next40pxDefaultSize: true, 35217 children: (0, import_i18n76.__)("Cancel") 35218 } 35219 ) }), 35220 /* @__PURE__ */ (0, import_jsx_runtime222.jsx)(import_components84.FlexItem, { children: /* @__PURE__ */ (0, import_jsx_runtime222.jsx)( 35221 import_components84.Button, 35222 { 35223 variant: "primary", 35224 type: "submit", 35225 __next40pxDefaultSize: true, 35226 children: (0, import_i18n76.__)("Apply") 35227 } 35228 ) }) 35229 ] 35230 } 35231 ) 35232 ] 35233 } 35234 ) 35235 } 35236 ); 35237 } 35238 35239 // packages/block-editor/build-module/components/block-lock/menu-item.js 35240 var import_jsx_runtime223 = __toESM(require_jsx_runtime()); 35241 function BlockLockMenuItem({ clientId }) { 35242 const { canLock, isLocked } = useBlockLock(clientId); 35243 const [isModalOpen, toggleModal] = (0, import_element104.useReducer)( 35244 (isActive) => !isActive, 35245 false 35246 ); 35247 if (!canLock) { 35248 return null; 35249 } 35250 const label = isLocked ? (0, import_i18n77.__)("Unlock") : (0, import_i18n77.__)("Lock"); 35251 return /* @__PURE__ */ (0, import_jsx_runtime223.jsxs)(import_jsx_runtime223.Fragment, { children: [ 35252 /* @__PURE__ */ (0, import_jsx_runtime223.jsx)( 35253 import_components85.MenuItem, 35254 { 35255 icon: isLocked ? unlock_default : lock_outline_default, 35256 onClick: toggleModal, 35257 "aria-expanded": isModalOpen, 35258 "aria-haspopup": "dialog", 35259 children: label 35260 } 35261 ), 35262 isModalOpen && /* @__PURE__ */ (0, import_jsx_runtime223.jsx)(BlockLockModal, { clientId, onClose: toggleModal }) 35263 ] }); 35264 } 35265 35266 // packages/block-editor/build-module/components/block-lock/toolbar.js 35267 var import_i18n78 = __toESM(require_i18n()); 35268 var import_components86 = __toESM(require_components()); 35269 var import_element105 = __toESM(require_element()); 35270 var import_jsx_runtime224 = __toESM(require_jsx_runtime()); 35271 function BlockLockToolbar({ clientId }) { 35272 const { canLock, isLocked } = useBlockLock(clientId); 35273 const [isModalOpen, toggleModal] = (0, import_element105.useReducer)( 35274 (isActive) => !isActive, 35275 false 35276 ); 35277 const hasLockButtonShownRef = (0, import_element105.useRef)(false); 35278 (0, import_element105.useEffect)(() => { 35279 if (isLocked) { 35280 hasLockButtonShownRef.current = true; 35281 } 35282 }, [isLocked]); 35283 if (!isLocked && !hasLockButtonShownRef.current) { 35284 return null; 35285 } 35286 let label = isLocked ? (0, import_i18n78.__)("Unlock") : (0, import_i18n78.__)("Lock"); 35287 if (!canLock && isLocked) { 35288 label = (0, import_i18n78.__)("Locked"); 35289 } 35290 return /* @__PURE__ */ (0, import_jsx_runtime224.jsxs)(import_jsx_runtime224.Fragment, { children: [ 35291 /* @__PURE__ */ (0, import_jsx_runtime224.jsx)(import_components86.ToolbarGroup, { className: "block-editor-block-lock-toolbar", children: /* @__PURE__ */ (0, import_jsx_runtime224.jsx)( 35292 import_components86.ToolbarButton, 35293 { 35294 disabled: !canLock, 35295 icon: isLocked ? lock_default : unlock_default, 35296 label, 35297 onClick: toggleModal, 35298 "aria-expanded": isModalOpen, 35299 "aria-haspopup": "dialog" 35300 } 35301 ) }), 35302 isModalOpen && /* @__PURE__ */ (0, import_jsx_runtime224.jsx)(BlockLockModal, { clientId, onClose: toggleModal }) 35303 ] }); 35304 } 35305 35306 // packages/block-editor/build-module/components/block-settings-menu/block-mode-toggle.js 35307 var import_i18n79 = __toESM(require_i18n()); 35308 var import_components87 = __toESM(require_components()); 35309 var import_blocks55 = __toESM(require_blocks()); 35310 var import_data94 = __toESM(require_data()); 35311 var import_jsx_runtime225 = __toESM(require_jsx_runtime()); 35312 var noop8 = () => { 35313 }; 35314 function BlockModeToggle({ clientId, onToggle = noop8 }) { 35315 const { blockType, mode: mode2, enabled } = (0, import_data94.useSelect)( 35316 (select3) => { 35317 const { getBlock: getBlock2, getBlockMode: getBlockMode2, getSettings: getSettings8 } = select3(store); 35318 const block = getBlock2(clientId); 35319 return { 35320 mode: getBlockMode2(clientId), 35321 blockType: block ? (0, import_blocks55.getBlockType)(block.name) : null, 35322 enabled: getSettings8().codeEditingEnabled && !!block?.isValid 35323 }; 35324 }, 35325 [clientId] 35326 ); 35327 const { toggleBlockMode: toggleBlockMode2 } = (0, import_data94.useDispatch)(store); 35328 if (!blockType || !(0, import_blocks55.hasBlockSupport)(blockType, "html", true) || !enabled) { 35329 return null; 35330 } 35331 const label = mode2 === "visual" ? (0, import_i18n79.__)("Edit as HTML") : (0, import_i18n79.__)("Edit visually"); 35332 return /* @__PURE__ */ (0, import_jsx_runtime225.jsx)( 35333 import_components87.MenuItem, 35334 { 35335 onClick: () => { 35336 toggleBlockMode2(clientId); 35337 onToggle(); 35338 }, 35339 children: label 35340 } 35341 ); 35342 } 35343 35344 // packages/block-editor/build-module/components/content-lock/modify-content-lock-menu-item.js 35345 var import_components88 = __toESM(require_components()); 35346 var import_data95 = __toESM(require_data()); 35347 var import_i18n80 = __toESM(require_i18n()); 35348 var import_jsx_runtime226 = __toESM(require_jsx_runtime()); 35349 function ModifyContentOnlySectionMenuItem({ clientId, onClose }) { 35350 const { templateLock, isLockedByParent, isEditingContentOnlySection } = (0, import_data95.useSelect)( 35351 (select3) => { 35352 const { 35353 getContentLockingParent: getContentLockingParent2, 35354 getTemplateLock: getTemplateLock2, 35355 getEditedContentOnlySection: getEditedContentOnlySection2 35356 } = unlock(select3(store)); 35357 return { 35358 templateLock: getTemplateLock2(clientId), 35359 isLockedByParent: !!getContentLockingParent2(clientId), 35360 isEditingContentOnlySection: getEditedContentOnlySection2() === clientId 35361 }; 35362 }, 35363 [clientId] 35364 ); 35365 const blockEditorActions = (0, import_data95.useDispatch)(store); 35366 const isContentLocked = !isLockedByParent && templateLock === "contentOnly"; 35367 if (window?.__experimentalContentOnlyPatternInsertion || !isContentLocked && !isEditingContentOnlySection) { 35368 return null; 35369 } 35370 const { editContentOnlySection: editContentOnlySection2 } = unlock(blockEditorActions); 35371 const showContentOnlyModifyButton = !isEditingContentOnlySection && isContentLocked; 35372 return showContentOnlyModifyButton && /* @__PURE__ */ (0, import_jsx_runtime226.jsx)( 35373 import_components88.MenuItem, 35374 { 35375 onClick: () => { 35376 editContentOnlySection2(clientId); 35377 onClose(); 35378 }, 35379 children: (0, import_i18n80._x)("Modify", "Unlock content locked blocks") 35380 } 35381 ); 35382 } 35383 35384 // packages/block-editor/build-module/components/block-rename/rename-control.js 35385 var import_components90 = __toESM(require_components()); 35386 var import_i18n82 = __toESM(require_i18n()); 35387 var import_element107 = __toESM(require_element()); 35388 35389 // packages/block-editor/build-module/components/block-rename/modal.js 35390 var import_components89 = __toESM(require_components()); 35391 var import_i18n81 = __toESM(require_i18n()); 35392 var import_element106 = __toESM(require_element()); 35393 var import_a11y11 = __toESM(require_a11y()); 35394 var import_data96 = __toESM(require_data()); 35395 35396 // packages/block-editor/build-module/components/block-rename/is-empty-string.js 35397 function isEmptyString(testString) { 35398 return testString?.trim()?.length === 0; 35399 } 35400 35401 // packages/block-editor/build-module/components/block-rename/modal.js 35402 var import_jsx_runtime227 = __toESM(require_jsx_runtime()); 35403 function BlockRenameModal({ clientId, onClose }) { 35404 const [editedBlockName, setEditedBlockName] = (0, import_element106.useState)(); 35405 const blockInformation = useBlockDisplayInformation(clientId); 35406 const { metadata } = (0, import_data96.useSelect)( 35407 (select3) => { 35408 const { getBlockAttributes: getBlockAttributes3 } = select3(store); 35409 return { 35410 metadata: getBlockAttributes3(clientId)?.metadata 35411 }; 35412 }, 35413 [clientId] 35414 ); 35415 const { updateBlockAttributes: updateBlockAttributes2 } = (0, import_data96.useDispatch)(store); 35416 const blockName = metadata?.name || ""; 35417 const originalBlockName = blockInformation?.title; 35418 const hasOverridesWarning = !!blockName && !!metadata?.bindings && Object.values(metadata.bindings).some( 35419 (binding) => binding.source === "core/pattern-overrides" 35420 ); 35421 const nameHasChanged = editedBlockName !== void 0 && editedBlockName !== blockName; 35422 const nameIsOriginal = editedBlockName === originalBlockName; 35423 const nameIsEmpty = isEmptyString(editedBlockName); 35424 const isNameValid = nameHasChanged || nameIsOriginal; 35425 const autoSelectInputText = (event) => event.target.select(); 35426 const handleSubmit = () => { 35427 const newName = nameIsOriginal || nameIsEmpty ? void 0 : editedBlockName; 35428 const message2 = nameIsOriginal || nameIsEmpty ? (0, import_i18n81.sprintf)( 35429 /* translators: %s: new name/label for the block */ 35430 (0, import_i18n81.__)('Block name reset to: "%s".'), 35431 editedBlockName 35432 ) : (0, import_i18n81.sprintf)( 35433 /* translators: %s: new name/label for the block */ 35434 (0, import_i18n81.__)('Block name changed to: "%s".'), 35435 editedBlockName 35436 ); 35437 (0, import_a11y11.speak)(message2, "assertive"); 35438 updateBlockAttributes2([clientId], { 35439 metadata: cleanEmptyObject({ 35440 ...metadata, 35441 name: newName 35442 }) 35443 }); 35444 onClose(); 35445 }; 35446 return /* @__PURE__ */ (0, import_jsx_runtime227.jsx)( 35447 import_components89.Modal, 35448 { 35449 title: (0, import_i18n81.__)("Rename"), 35450 onRequestClose: onClose, 35451 overlayClassName: "block-editor-block-rename-modal", 35452 focusOnMount: "firstContentElement", 35453 size: "small", 35454 children: /* @__PURE__ */ (0, import_jsx_runtime227.jsx)( 35455 "form", 35456 { 35457 onSubmit: (e2) => { 35458 e2.preventDefault(); 35459 if (!isNameValid) { 35460 return; 35461 } 35462 handleSubmit(); 35463 }, 35464 children: /* @__PURE__ */ (0, import_jsx_runtime227.jsxs)(import_components89.__experimentalVStack, { spacing: "3", children: [ 35465 /* @__PURE__ */ (0, import_jsx_runtime227.jsx)( 35466 import_components89.TextControl, 35467 { 35468 __next40pxDefaultSize: true, 35469 value: editedBlockName ?? blockName, 35470 label: (0, import_i18n81.__)("Name"), 35471 help: hasOverridesWarning ? (0, import_i18n81.__)( 35472 "This block allows overrides. Changing the name can cause problems with content entered into instances of this pattern." 35473 ) : void 0, 35474 placeholder: originalBlockName, 35475 onChange: setEditedBlockName, 35476 onFocus: autoSelectInputText 35477 } 35478 ), 35479 /* @__PURE__ */ (0, import_jsx_runtime227.jsxs)(import_components89.__experimentalHStack, { justify: "right", children: [ 35480 /* @__PURE__ */ (0, import_jsx_runtime227.jsx)( 35481 import_components89.Button, 35482 { 35483 __next40pxDefaultSize: true, 35484 variant: "tertiary", 35485 onClick: onClose, 35486 children: (0, import_i18n81.__)("Cancel") 35487 } 35488 ), 35489 /* @__PURE__ */ (0, import_jsx_runtime227.jsx)( 35490 import_components89.Button, 35491 { 35492 __next40pxDefaultSize: true, 35493 accessibleWhenDisabled: true, 35494 disabled: !isNameValid, 35495 variant: "primary", 35496 type: "submit", 35497 children: (0, import_i18n81.__)("Save") 35498 } 35499 ) 35500 ] }) 35501 ] }) 35502 } 35503 ) 35504 } 35505 ); 35506 } 35507 35508 // packages/block-editor/build-module/components/block-rename/rename-control.js 35509 var import_jsx_runtime228 = __toESM(require_jsx_runtime()); 35510 function BlockRenameControl({ clientId }) { 35511 const [renamingBlock, setRenamingBlock] = (0, import_element107.useState)(false); 35512 return /* @__PURE__ */ (0, import_jsx_runtime228.jsxs)(import_jsx_runtime228.Fragment, { children: [ 35513 /* @__PURE__ */ (0, import_jsx_runtime228.jsx)( 35514 import_components90.MenuItem, 35515 { 35516 onClick: () => { 35517 setRenamingBlock(true); 35518 }, 35519 "aria-expanded": renamingBlock, 35520 "aria-haspopup": "dialog", 35521 children: (0, import_i18n82.__)("Rename") 35522 } 35523 ), 35524 renamingBlock && /* @__PURE__ */ (0, import_jsx_runtime228.jsx)( 35525 BlockRenameModal, 35526 { 35527 clientId, 35528 onClose: () => setRenamingBlock(false) 35529 } 35530 ) 35531 ] }); 35532 } 35533 35534 // packages/block-editor/build-module/components/block-rename/use-block-rename.js 35535 var import_blocks56 = __toESM(require_blocks()); 35536 function useBlockRename(name) { 35537 return { 35538 canRename: (0, import_blocks56.getBlockSupport)(name, "renaming", true) 35539 }; 35540 } 35541 35542 // packages/block-editor/build-module/components/block-visibility/menu-item.js 35543 var import_i18n83 = __toESM(require_i18n()); 35544 var import_components91 = __toESM(require_components()); 35545 var import_data97 = __toESM(require_data()); 35546 var import_notices7 = __toESM(require_notices()); 35547 var import_keyboard_shortcuts4 = __toESM(require_keyboard_shortcuts()); 35548 var import_jsx_runtime229 = __toESM(require_jsx_runtime()); 35549 function BlockVisibilityMenuItem({ clientIds }) { 35550 const { updateBlockAttributes: updateBlockAttributes2 } = (0, import_data97.useDispatch)(store); 35551 const { createSuccessNotice } = (0, import_data97.useDispatch)(import_notices7.store); 35552 const blocks2 = (0, import_data97.useSelect)( 35553 (select3) => { 35554 return select3(store).getBlocksByClientId(clientIds); 35555 }, 35556 [clientIds] 35557 ); 35558 const listViewShortcut = (0, import_data97.useSelect)((select3) => { 35559 return select3(import_keyboard_shortcuts4.store).getShortcutRepresentation( 35560 "core/editor/toggle-list-view" 35561 ); 35562 }, []); 35563 const hasHiddenBlock = blocks2.some( 35564 (block) => block.attributes.metadata?.blockVisibility === false 35565 ); 35566 const toggleBlockVisibility = () => { 35567 const isHiding = !hasHiddenBlock; 35568 const attributesByClientId = Object.fromEntries( 35569 blocks2?.map(({ clientId, attributes }) => [ 35570 clientId, 35571 { 35572 metadata: cleanEmptyObject({ 35573 ...attributes?.metadata, 35574 blockVisibility: isHiding ? false : void 0 35575 }) 35576 } 35577 ]) 35578 ); 35579 updateBlockAttributes2(clientIds, attributesByClientId, { 35580 uniqueByBlock: true 35581 }); 35582 if (isHiding) { 35583 if (blocks2.length > 1) { 35584 createSuccessNotice( 35585 (0, import_i18n83.sprintf)( 35586 // translators: %s: The shortcut key to access the List View. 35587 (0, import_i18n83.__)( 35588 "Blocks hidden. You can access them via the List View (%s)." 35589 ), 35590 listViewShortcut 35591 ), 35592 { 35593 id: "block-visibility-hidden", 35594 type: "snackbar" 35595 } 35596 ); 35597 } else { 35598 createSuccessNotice( 35599 (0, import_i18n83.sprintf)( 35600 // translators: %s: The shortcut key to access the List View. 35601 (0, import_i18n83.__)( 35602 "Block hidden. You can access it via the List View (%s)." 35603 ), 35604 listViewShortcut 35605 ), 35606 { 35607 id: "block-visibility-hidden", 35608 type: "snackbar" 35609 } 35610 ); 35611 } 35612 } 35613 }; 35614 return /* @__PURE__ */ (0, import_jsx_runtime229.jsx)( 35615 import_components91.MenuItem, 35616 { 35617 icon: hasHiddenBlock ? seen_default : unseen_default, 35618 onClick: toggleBlockVisibility, 35619 children: hasHiddenBlock ? (0, import_i18n83.__)("Show") : (0, import_i18n83.__)("Hide") 35620 } 35621 ); 35622 } 35623 35624 // packages/block-editor/build-module/components/block-visibility/toolbar.js 35625 var import_i18n84 = __toESM(require_i18n()); 35626 var import_components92 = __toESM(require_components()); 35627 var import_element108 = __toESM(require_element()); 35628 var import_data98 = __toESM(require_data()); 35629 var import_blocks57 = __toESM(require_blocks()); 35630 var import_jsx_runtime230 = __toESM(require_jsx_runtime()); 35631 function BlockVisibilityToolbar({ clientIds }) { 35632 const { blocks: blocks2, canToggleBlockVisibility } = (0, import_data98.useSelect)( 35633 (select3) => { 35634 const { getBlockName: getBlockName2, getBlocksByClientId: getBlocksByClientId2 } = select3(store); 35635 const _blocks = getBlocksByClientId2(clientIds); 35636 return { 35637 blocks: _blocks, 35638 canToggleBlockVisibility: _blocks.every( 35639 ({ clientId }) => (0, import_blocks57.hasBlockSupport)( 35640 getBlockName2(clientId), 35641 "visibility", 35642 true 35643 ) 35644 ) 35645 }; 35646 }, 35647 [clientIds] 35648 ); 35649 const hasHiddenBlock = blocks2.some( 35650 (block) => block.attributes.metadata?.blockVisibility === false 35651 ); 35652 const hasBlockVisibilityButtonShownRef = (0, import_element108.useRef)(false); 35653 const { updateBlockAttributes: updateBlockAttributes2 } = (0, import_data98.useDispatch)(store); 35654 (0, import_element108.useEffect)(() => { 35655 if (hasHiddenBlock) { 35656 hasBlockVisibilityButtonShownRef.current = true; 35657 } 35658 }, [hasHiddenBlock]); 35659 if (!hasHiddenBlock && !hasBlockVisibilityButtonShownRef.current) { 35660 return null; 35661 } 35662 const toggleBlockVisibility = () => { 35663 const attributesByClientId = Object.fromEntries( 35664 blocks2?.map(({ clientId, attributes }) => [ 35665 clientId, 35666 { 35667 metadata: cleanEmptyObject({ 35668 ...attributes?.metadata, 35669 blockVisibility: hasHiddenBlock ? void 0 : false 35670 }) 35671 } 35672 ]) 35673 ); 35674 updateBlockAttributes2(clientIds, attributesByClientId, { 35675 uniqueByBlock: true 35676 }); 35677 }; 35678 return /* @__PURE__ */ (0, import_jsx_runtime230.jsx)(import_jsx_runtime230.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime230.jsx)(import_components92.ToolbarGroup, { className: "block-editor-block-lock-toolbar", children: /* @__PURE__ */ (0, import_jsx_runtime230.jsx)( 35679 import_components92.ToolbarButton, 35680 { 35681 disabled: !canToggleBlockVisibility, 35682 icon: hasHiddenBlock ? unseen_default : seen_default, 35683 label: hasHiddenBlock ? (0, import_i18n84.__)("Hidden") : (0, import_i18n84.__)("Visible"), 35684 onClick: toggleBlockVisibility 35685 } 35686 ) }) }); 35687 } 35688 35689 // packages/block-editor/build-module/components/block-settings-menu-controls/edit-section-menu-item.js 35690 var import_components93 = __toESM(require_components()); 35691 var import_i18n85 = __toESM(require_i18n()); 35692 var import_data100 = __toESM(require_data()); 35693 var import_blocks58 = __toESM(require_blocks()); 35694 35695 // packages/block-editor/build-module/hooks/use-content-only-section-edit.js 35696 var import_data99 = __toESM(require_data()); 35697 function useContentOnlySectionEdit(clientId) { 35698 const { 35699 isSectionBlock: isSectionBlock2, 35700 isWithinSection, 35701 isWithinEditedSection, 35702 isEditingContentOnlySection, 35703 editedContentOnlySection: editedContentOnlySection2 35704 } = (0, import_data99.useSelect)( 35705 (select3) => { 35706 const { 35707 isSectionBlock: _isSectionBlock, 35708 getParentSectionBlock: getParentSectionBlock2, 35709 getEditedContentOnlySection: getEditedContentOnlySection2, 35710 isWithinEditedContentOnlySection: isWithinEditedContentOnlySection2 35711 } = unlock(select3(store)); 35712 const editedSection = getEditedContentOnlySection2(); 35713 return { 35714 isSectionBlock: _isSectionBlock(clientId), 35715 isWithinSection: _isSectionBlock(clientId) || !!getParentSectionBlock2(clientId), 35716 isWithinEditedSection: isWithinEditedContentOnlySection2(clientId), 35717 isEditingContentOnlySection: editedSection === clientId, 35718 editedContentOnlySection: editedSection 35719 }; 35720 }, 35721 [clientId] 35722 ); 35723 const blockEditorActions = (0, import_data99.useDispatch)(store); 35724 const { editContentOnlySection: editContentOnlySection2, stopEditingContentOnlySection: stopEditingContentOnlySection2 } = unlock(blockEditorActions); 35725 return { 35726 isSectionBlock: isSectionBlock2, 35727 isWithinSection, 35728 isWithinEditedSection, 35729 isEditingContentOnlySection, 35730 editedContentOnlySection: editedContentOnlySection2, 35731 editContentOnlySection: editContentOnlySection2, 35732 stopEditingContentOnlySection: stopEditingContentOnlySection2 35733 }; 35734 } 35735 35736 // packages/block-editor/build-module/components/block-settings-menu-controls/edit-section-menu-item.js 35737 var import_jsx_runtime231 = __toESM(require_jsx_runtime()); 35738 function EditSectionMenuItem({ clientId, onClose }) { 35739 const { 35740 isSectionBlock: isSectionBlock2, 35741 isEditingContentOnlySection, 35742 editContentOnlySection: editContentOnlySection2 35743 } = useContentOnlySectionEdit(clientId); 35744 const { block, onNavigateToEntityRecord } = (0, import_data100.useSelect)( 35745 (select3) => { 35746 const { getBlock: getBlock2, getSettings: getSettings8 } = select3(store); 35747 return { 35748 block: getBlock2(clientId), 35749 onNavigateToEntityRecord: getSettings8().onNavigateToEntityRecord 35750 }; 35751 }, 35752 [clientId] 35753 ); 35754 if (!window?.__experimentalContentOnlyPatternInsertion || !isSectionBlock2 || isEditingContentOnlySection) { 35755 return null; 35756 } 35757 const blockAttributes = block?.attributes || {}; 35758 const isSyncedPattern = (0, import_blocks58.isReusableBlock)(block); 35759 const isTemplatePartBlock = (0, import_blocks58.isTemplatePart)(block); 35760 const shouldNavigateToIsolatedEditor = (isSyncedPattern || isTemplatePartBlock) && onNavigateToEntityRecord; 35761 const handleClick = () => { 35762 if (shouldNavigateToIsolatedEditor) { 35763 if (isSyncedPattern) { 35764 onNavigateToEntityRecord({ 35765 postId: blockAttributes.ref, 35766 postType: "wp_block" 35767 }); 35768 } else if (isTemplatePartBlock) { 35769 const { theme, slug } = blockAttributes; 35770 const templatePartId = theme && slug ? `$theme}//${slug}` : null; 35771 if (templatePartId) { 35772 onNavigateToEntityRecord({ 35773 postId: templatePartId, 35774 postType: "wp_template_part" 35775 }); 35776 } 35777 } 35778 } else { 35779 editContentOnlySection2(clientId); 35780 } 35781 onClose(); 35782 }; 35783 return /* @__PURE__ */ (0, import_jsx_runtime231.jsx)(import_components93.MenuItem, { onClick: handleClick, children: (0, import_i18n85._x)("Edit section", "Editing a section in the Editor") }); 35784 } 35785 35786 // packages/block-editor/build-module/components/block-settings-menu-controls/index.js 35787 var import_jsx_runtime232 = __toESM(require_jsx_runtime()); 35788 var { Fill, Slot: Slot4 } = (0, import_components94.createSlotFill)("BlockSettingsMenuControls"); 35789 var BlockSettingsMenuControlsSlot = ({ fillProps, clientIds = null }) => { 35790 const { 35791 selectedBlocks, 35792 selectedClientIds, 35793 isContentOnly, 35794 canToggleSelectedBlocksVisibility 35795 } = (0, import_data101.useSelect)( 35796 (select3) => { 35797 const { 35798 getBlocksByClientId: getBlocksByClientId2, 35799 getBlockNamesByClientId: getBlockNamesByClientId2, 35800 getSelectedBlockClientIds: getSelectedBlockClientIds2, 35801 getBlockEditingMode: getBlockEditingMode2 35802 } = select3(store); 35803 const ids = clientIds !== null ? clientIds : getSelectedBlockClientIds2(); 35804 return { 35805 selectedBlocks: getBlockNamesByClientId2(ids), 35806 selectedClientIds: ids, 35807 isContentOnly: getBlockEditingMode2(ids[0]) === "contentOnly", 35808 canToggleSelectedBlocksVisibility: getBlocksByClientId2( 35809 ids 35810 ).every( 35811 (block) => (0, import_blocks59.hasBlockSupport)(block.name, "visibility", true) 35812 ) 35813 }; 35814 }, 35815 [clientIds] 35816 ); 35817 const { canLock } = useBlockLock(selectedClientIds[0]); 35818 const { canRename } = useBlockRename(selectedBlocks[0]); 35819 const showLockButton = selectedClientIds.length === 1 && canLock && !isContentOnly; 35820 const showRenameButton = selectedClientIds.length === 1 && canRename && !isContentOnly; 35821 const showVisibilityButton = canToggleSelectedBlocksVisibility && !isContentOnly; 35822 const convertToGroupButtonProps = useConvertToGroupButtonProps(selectedClientIds); 35823 const { isGroupable: isGroupable2, isUngroupable: isUngroupable2 } = convertToGroupButtonProps; 35824 const showConvertToGroupButton = (isGroupable2 || isUngroupable2) && !isContentOnly; 35825 return /* @__PURE__ */ (0, import_jsx_runtime232.jsx)( 35826 Slot4, 35827 { 35828 fillProps: { 35829 ...fillProps, 35830 selectedBlocks, 35831 selectedClientIds 35832 }, 35833 children: (fills) => { 35834 if (!fills?.length > 0 && !showConvertToGroupButton && !showLockButton) { 35835 return null; 35836 } 35837 return /* @__PURE__ */ (0, import_jsx_runtime232.jsxs)(import_components94.MenuGroup, { children: [ 35838 showConvertToGroupButton && /* @__PURE__ */ (0, import_jsx_runtime232.jsx)( 35839 ConvertToGroupButton, 35840 { 35841 ...convertToGroupButtonProps, 35842 onClose: fillProps?.onClose 35843 } 35844 ), 35845 selectedClientIds.length === 1 && /* @__PURE__ */ (0, import_jsx_runtime232.jsx)( 35846 EditSectionMenuItem, 35847 { 35848 clientId: selectedClientIds[0], 35849 onClose: fillProps?.onClose 35850 } 35851 ), 35852 showLockButton && /* @__PURE__ */ (0, import_jsx_runtime232.jsx)( 35853 BlockLockMenuItem, 35854 { 35855 clientId: selectedClientIds[0] 35856 } 35857 ), 35858 showRenameButton && /* @__PURE__ */ (0, import_jsx_runtime232.jsx)( 35859 BlockRenameControl, 35860 { 35861 clientId: selectedClientIds[0] 35862 } 35863 ), 35864 showVisibilityButton && /* @__PURE__ */ (0, import_jsx_runtime232.jsx)( 35865 BlockVisibilityMenuItem, 35866 { 35867 clientIds: selectedClientIds 35868 } 35869 ), 35870 fills, 35871 selectedClientIds.length === 1 && /* @__PURE__ */ (0, import_jsx_runtime232.jsx)( 35872 ModifyContentOnlySectionMenuItem, 35873 { 35874 clientId: selectedClientIds[0], 35875 onClose: fillProps?.onClose 35876 } 35877 ), 35878 fillProps?.count === 1 && !isContentOnly && /* @__PURE__ */ (0, import_jsx_runtime232.jsx)( 35879 BlockModeToggle, 35880 { 35881 clientId: fillProps?.firstBlockClientId, 35882 onToggle: fillProps?.onClose 35883 } 35884 ) 35885 ] }); 35886 } 35887 } 35888 ); 35889 }; 35890 function BlockSettingsMenuControls({ ...props }) { 35891 return /* @__PURE__ */ (0, import_jsx_runtime232.jsx)(import_components94.__experimentalStyleProvider, { document, children: /* @__PURE__ */ (0, import_jsx_runtime232.jsx)(Fill, { ...props }) }); 35892 } 35893 BlockSettingsMenuControls.Slot = BlockSettingsMenuControlsSlot; 35894 var block_settings_menu_controls_default = BlockSettingsMenuControls; 35895 35896 // packages/block-editor/build-module/components/block-settings-menu/block-parent-selector-menu-item.js 35897 var import_element109 = __toESM(require_element()); 35898 var import_components95 = __toESM(require_components()); 35899 var import_compose61 = __toESM(require_compose()); 35900 var import_data102 = __toESM(require_data()); 35901 var import_i18n86 = __toESM(require_i18n()); 35902 var import_jsx_runtime233 = __toESM(require_jsx_runtime()); 35903 function BlockParentSelectorMenuItem({ 35904 parentClientId, 35905 parentBlockType 35906 }) { 35907 const isSmallViewport = (0, import_compose61.useViewportMatch)("medium", "<"); 35908 const { selectBlock: selectBlock2 } = (0, import_data102.useDispatch)(store); 35909 const menuItemRef = (0, import_element109.useRef)(); 35910 const gesturesProps = useShowHoveredOrFocusedGestures({ 35911 ref: menuItemRef, 35912 highlightParent: true 35913 }); 35914 if (!isSmallViewport) { 35915 return null; 35916 } 35917 return /* @__PURE__ */ (0, import_jsx_runtime233.jsx)( 35918 import_components95.MenuItem, 35919 { 35920 ...gesturesProps, 35921 ref: menuItemRef, 35922 icon: /* @__PURE__ */ (0, import_jsx_runtime233.jsx)(block_icon_default, { icon: parentBlockType.icon }), 35923 onClick: () => selectBlock2(parentClientId), 35924 children: (0, import_i18n86.sprintf)( 35925 /* translators: %s: Name of the block's parent. */ 35926 (0, import_i18n86.__)("Select parent block (%s)"), 35927 parentBlockType.title 35928 ) 35929 } 35930 ); 35931 } 35932 35933 // packages/block-editor/build-module/components/block-settings-menu/block-settings-dropdown.js 35934 var import_jsx_runtime234 = __toESM(require_jsx_runtime()); 35935 var POPOVER_PROPS4 = { 35936 className: "block-editor-block-settings-menu__popover", 35937 placement: "bottom-start" 35938 }; 35939 function CopyMenuItem({ 35940 clientIds, 35941 onCopy, 35942 label, 35943 shortcut, 35944 eventType = "copy", 35945 __experimentalUpdateSelection: updateSelection = false 35946 }) { 35947 const { getBlocksByClientId: getBlocksByClientId2 } = (0, import_data103.useSelect)(store); 35948 const { removeBlocks: removeBlocks2 } = (0, import_data103.useDispatch)(store); 35949 const notifyCopy = useNotifyCopy(); 35950 const ref = (0, import_compose62.useCopyToClipboard)( 35951 () => (0, import_blocks60.serialize)(getBlocksByClientId2(clientIds)), 35952 () => { 35953 switch (eventType) { 35954 case "copy": 35955 case "copyStyles": 35956 onCopy(); 35957 notifyCopy(eventType, clientIds); 35958 break; 35959 case "cut": 35960 notifyCopy(eventType, clientIds); 35961 removeBlocks2(clientIds, updateSelection); 35962 break; 35963 default: 35964 break; 35965 } 35966 } 35967 ); 35968 const copyMenuItemLabel = label ? label : (0, import_i18n87.__)("Copy"); 35969 return /* @__PURE__ */ (0, import_jsx_runtime234.jsx)(import_components96.MenuItem, { ref, shortcut, children: copyMenuItemLabel }); 35970 } 35971 function BlockSettingsDropdown({ 35972 block, 35973 clientIds, 35974 children, 35975 __experimentalSelectBlock, 35976 ...props 35977 }) { 35978 const currentClientId = block?.clientId; 35979 const count = clientIds.length; 35980 const firstBlockClientId = clientIds[0]; 35981 const { 35982 firstParentClientId, 35983 parentBlockType, 35984 previousBlockClientId, 35985 selectedBlockClientIds, 35986 openedBlockSettingsMenu: openedBlockSettingsMenu2, 35987 isContentOnly, 35988 isZoomOut: isZoomOut2 35989 } = (0, import_data103.useSelect)( 35990 (select3) => { 35991 const { 35992 getBlockName: getBlockName2, 35993 getBlockRootClientId: getBlockRootClientId2, 35994 getPreviousBlockClientId: getPreviousBlockClientId2, 35995 getSelectedBlockClientIds: getSelectedBlockClientIds22, 35996 getBlockAttributes: getBlockAttributes3, 35997 getOpenedBlockSettingsMenu: getOpenedBlockSettingsMenu2, 35998 getBlockEditingMode: getBlockEditingMode2, 35999 isZoomOut: _isZoomOut 36000 } = unlock(select3(store)); 36001 const { getActiveBlockVariation } = select3(import_blocks60.store); 36002 const _firstParentClientId = getBlockRootClientId2(firstBlockClientId); 36003 const parentBlockName = _firstParentClientId && getBlockName2(_firstParentClientId); 36004 return { 36005 firstParentClientId: _firstParentClientId, 36006 parentBlockType: _firstParentClientId && (getActiveBlockVariation( 36007 parentBlockName, 36008 getBlockAttributes3(_firstParentClientId) 36009 ) || (0, import_blocks60.getBlockType)(parentBlockName)), 36010 previousBlockClientId: getPreviousBlockClientId2(firstBlockClientId), 36011 selectedBlockClientIds: getSelectedBlockClientIds22(), 36012 openedBlockSettingsMenu: getOpenedBlockSettingsMenu2(), 36013 isContentOnly: getBlockEditingMode2(firstBlockClientId) === "contentOnly", 36014 isZoomOut: _isZoomOut() 36015 }; 36016 }, 36017 [firstBlockClientId] 36018 ); 36019 const { getBlockOrder: getBlockOrder2, getSelectedBlockClientIds: getSelectedBlockClientIds2 } = (0, import_data103.useSelect)(store); 36020 const { setOpenedBlockSettingsMenu: setOpenedBlockSettingsMenu2 } = unlock( 36021 (0, import_data103.useDispatch)(store) 36022 ); 36023 const shortcuts = (0, import_data103.useSelect)((select3) => { 36024 const { getShortcutRepresentation } = select3(import_keyboard_shortcuts5.store); 36025 return { 36026 copy: getShortcutRepresentation("core/block-editor/copy"), 36027 cut: getShortcutRepresentation("core/block-editor/cut"), 36028 duplicate: getShortcutRepresentation( 36029 "core/block-editor/duplicate" 36030 ), 36031 remove: getShortcutRepresentation("core/block-editor/remove"), 36032 insertAfter: getShortcutRepresentation( 36033 "core/block-editor/insert-after" 36034 ), 36035 insertBefore: getShortcutRepresentation( 36036 "core/block-editor/insert-before" 36037 ) 36038 }; 36039 }, []); 36040 const hasSelectedBlocks = selectedBlockClientIds.length > 0; 36041 async function updateSelectionAfterDuplicate(clientIdsPromise) { 36042 if (!__experimentalSelectBlock) { 36043 return; 36044 } 36045 const ids = await clientIdsPromise; 36046 if (ids && ids[0]) { 36047 __experimentalSelectBlock(ids[0], false); 36048 } 36049 } 36050 function updateSelectionAfterRemove() { 36051 if (!__experimentalSelectBlock) { 36052 return; 36053 } 36054 let blockToFocus = previousBlockClientId || firstParentClientId; 36055 if (!blockToFocus) { 36056 blockToFocus = getBlockOrder2()[0]; 36057 } 36058 const shouldUpdateSelection = hasSelectedBlocks && getSelectedBlockClientIds2().length === 0; 36059 __experimentalSelectBlock(blockToFocus, shouldUpdateSelection); 36060 } 36061 const parentBlockIsSelected = selectedBlockClientIds?.includes(firstParentClientId); 36062 const open = !currentClientId ? void 0 : openedBlockSettingsMenu2 === currentClientId || false; 36063 function onToggle(localOpen) { 36064 if (localOpen && openedBlockSettingsMenu2 !== currentClientId) { 36065 setOpenedBlockSettingsMenu2(currentClientId); 36066 } else if (!localOpen && openedBlockSettingsMenu2 && openedBlockSettingsMenu2 === currentClientId) { 36067 setOpenedBlockSettingsMenu2(void 0); 36068 } 36069 } 36070 const shouldShowBlockParentMenuItem = !parentBlockIsSelected && !!firstParentClientId; 36071 return /* @__PURE__ */ (0, import_jsx_runtime234.jsx)( 36072 BlockActions, 36073 { 36074 clientIds, 36075 __experimentalUpdateSelection: !__experimentalSelectBlock, 36076 children: ({ 36077 canCopyStyles, 36078 canDuplicate, 36079 canInsertBlock, 36080 canRemove, 36081 onDuplicate, 36082 onInsertAfter, 36083 onInsertBefore, 36084 onRemove, 36085 onCopy, 36086 onPasteStyles 36087 }) => { 36088 const isEmpty4 = !canRemove && !canDuplicate && !canInsertBlock && isContentOnly; 36089 if (isEmpty4) { 36090 return null; 36091 } 36092 return /* @__PURE__ */ (0, import_jsx_runtime234.jsx)( 36093 import_components96.DropdownMenu, 36094 { 36095 icon: more_vertical_default, 36096 label: (0, import_i18n87.__)("Options"), 36097 className: "block-editor-block-settings-menu", 36098 popoverProps: POPOVER_PROPS4, 36099 open, 36100 onToggle, 36101 noIcons: true, 36102 ...props, 36103 children: ({ onClose }) => /* @__PURE__ */ (0, import_jsx_runtime234.jsxs)(import_jsx_runtime234.Fragment, { children: [ 36104 /* @__PURE__ */ (0, import_jsx_runtime234.jsxs)(import_components96.MenuGroup, { children: [ 36105 /* @__PURE__ */ (0, import_jsx_runtime234.jsx)( 36106 block_settings_menu_first_item_default.Slot, 36107 { 36108 fillProps: { onClose } 36109 } 36110 ), 36111 shouldShowBlockParentMenuItem && /* @__PURE__ */ (0, import_jsx_runtime234.jsx)( 36112 BlockParentSelectorMenuItem, 36113 { 36114 parentClientId: firstParentClientId, 36115 parentBlockType 36116 } 36117 ), 36118 count === 1 && /* @__PURE__ */ (0, import_jsx_runtime234.jsx)( 36119 block_html_convert_button_default, 36120 { 36121 clientId: firstBlockClientId 36122 } 36123 ), 36124 !isContentOnly && /* @__PURE__ */ (0, import_jsx_runtime234.jsx)( 36125 CopyMenuItem, 36126 { 36127 clientIds, 36128 onCopy, 36129 shortcut: shortcuts.copy 36130 } 36131 ), 36132 !isContentOnly && /* @__PURE__ */ (0, import_jsx_runtime234.jsx)( 36133 CopyMenuItem, 36134 { 36135 clientIds, 36136 label: (0, import_i18n87.__)("Cut"), 36137 eventType: "cut", 36138 shortcut: shortcuts.cut, 36139 __experimentalUpdateSelection: !__experimentalSelectBlock 36140 } 36141 ), 36142 canDuplicate && /* @__PURE__ */ (0, import_jsx_runtime234.jsx)( 36143 import_components96.MenuItem, 36144 { 36145 onClick: (0, import_compose62.pipe)( 36146 onClose, 36147 onDuplicate, 36148 updateSelectionAfterDuplicate 36149 ), 36150 shortcut: shortcuts.duplicate, 36151 children: (0, import_i18n87.__)("Duplicate") 36152 } 36153 ), 36154 canInsertBlock && !isZoomOut2 && /* @__PURE__ */ (0, import_jsx_runtime234.jsxs)(import_jsx_runtime234.Fragment, { children: [ 36155 /* @__PURE__ */ (0, import_jsx_runtime234.jsx)( 36156 import_components96.MenuItem, 36157 { 36158 onClick: (0, import_compose62.pipe)( 36159 onClose, 36160 onInsertBefore 36161 ), 36162 shortcut: shortcuts.insertBefore, 36163 children: (0, import_i18n87.__)("Add before") 36164 } 36165 ), 36166 /* @__PURE__ */ (0, import_jsx_runtime234.jsx)( 36167 import_components96.MenuItem, 36168 { 36169 onClick: (0, import_compose62.pipe)( 36170 onClose, 36171 onInsertAfter 36172 ), 36173 shortcut: shortcuts.insertAfter, 36174 children: (0, import_i18n87.__)("Add after") 36175 } 36176 ) 36177 ] }), 36178 count === 1 && /* @__PURE__ */ (0, import_jsx_runtime234.jsx)( 36179 block_comment_icon_slot_default.Slot, 36180 { 36181 fillProps: { 36182 clientId: firstBlockClientId, 36183 onClose 36184 } 36185 } 36186 ) 36187 ] }), 36188 canCopyStyles && !isContentOnly && /* @__PURE__ */ (0, import_jsx_runtime234.jsxs)(import_components96.MenuGroup, { children: [ 36189 /* @__PURE__ */ (0, import_jsx_runtime234.jsx)( 36190 CopyMenuItem, 36191 { 36192 clientIds, 36193 onCopy, 36194 label: (0, import_i18n87.__)("Copy styles"), 36195 eventType: "copyStyles" 36196 } 36197 ), 36198 /* @__PURE__ */ (0, import_jsx_runtime234.jsx)(import_components96.MenuItem, { onClick: onPasteStyles, children: (0, import_i18n87.__)("Paste styles") }) 36199 ] }), 36200 !isContentOnly && /* @__PURE__ */ (0, import_jsx_runtime234.jsx)( 36201 block_settings_menu_controls_default.Slot, 36202 { 36203 fillProps: { 36204 onClose, 36205 count, 36206 firstBlockClientId 36207 }, 36208 clientIds 36209 } 36210 ), 36211 typeof children === "function" ? children({ onClose }) : import_element110.Children.map( 36212 (child) => (0, import_element110.cloneElement)(child, { onClose }) 36213 ), 36214 canRemove && /* @__PURE__ */ (0, import_jsx_runtime234.jsx)(import_components96.MenuGroup, { children: /* @__PURE__ */ (0, import_jsx_runtime234.jsx)( 36215 import_components96.MenuItem, 36216 { 36217 onClick: (0, import_compose62.pipe)( 36218 onClose, 36219 onRemove, 36220 updateSelectionAfterRemove 36221 ), 36222 shortcut: shortcuts.remove, 36223 children: (0, import_i18n87.__)("Delete") 36224 } 36225 ) }) 36226 ] }) 36227 } 36228 ); 36229 } 36230 } 36231 ); 36232 } 36233 var block_settings_dropdown_default = BlockSettingsDropdown; 36234 36235 // packages/block-editor/build-module/components/collab/block-comment-icon-toolbar-slot.js 36236 var import_components97 = __toESM(require_components()); 36237 var CommentIconToolbarSlotFill = (0, import_components97.createSlotFill)( 36238 Symbol("CommentIconToolbarSlotFill") 36239 ); 36240 var block_comment_icon_toolbar_slot_default = CommentIconToolbarSlotFill; 36241 36242 // packages/block-editor/build-module/components/block-settings-menu/index.js 36243 var import_jsx_runtime235 = __toESM(require_jsx_runtime()); 36244 function BlockSettingsMenu({ clientIds, ...props }) { 36245 return /* @__PURE__ */ (0, import_jsx_runtime235.jsxs)(import_components98.ToolbarGroup, { children: [ 36246 /* @__PURE__ */ (0, import_jsx_runtime235.jsx)(block_comment_icon_toolbar_slot_default.Slot, {}), 36247 /* @__PURE__ */ (0, import_jsx_runtime235.jsx)(import_components98.ToolbarItem, { children: (toggleProps) => /* @__PURE__ */ (0, import_jsx_runtime235.jsx)( 36248 block_settings_dropdown_default, 36249 { 36250 clientIds, 36251 toggleProps, 36252 ...props 36253 } 36254 ) }) 36255 ] }); 36256 } 36257 var block_settings_menu_default = BlockSettingsMenu; 36258 36259 // packages/block-editor/build-module/components/block-edit-visually-button/index.js 36260 var import_components99 = __toESM(require_components()); 36261 var import_i18n88 = __toESM(require_i18n()); 36262 var import_data104 = __toESM(require_data()); 36263 var import_jsx_runtime236 = __toESM(require_jsx_runtime()); 36264 function BlockEditVisuallyButton({ clientIds }) { 36265 const clientId = clientIds.length === 1 ? clientIds[0] : void 0; 36266 const canEditVisually = (0, import_data104.useSelect)( 36267 (select3) => !!clientId && select3(store).getBlockMode(clientId) === "html", 36268 [clientId] 36269 ); 36270 const { toggleBlockMode: toggleBlockMode2 } = (0, import_data104.useDispatch)(store); 36271 if (!canEditVisually) { 36272 return null; 36273 } 36274 return /* @__PURE__ */ (0, import_jsx_runtime236.jsx)(import_components99.ToolbarGroup, { children: /* @__PURE__ */ (0, import_jsx_runtime236.jsx)( 36275 import_components99.ToolbarButton, 36276 { 36277 onClick: () => { 36278 toggleBlockMode2(clientId); 36279 }, 36280 children: (0, import_i18n88.__)("Edit visually") 36281 } 36282 ) }); 36283 } 36284 36285 // packages/block-editor/build-module/components/navigable-toolbar/index.js 36286 var import_components100 = __toESM(require_components()); 36287 var import_element111 = __toESM(require_element()); 36288 var import_data105 = __toESM(require_data()); 36289 var import_deprecated12 = __toESM(require_deprecated()); 36290 var import_dom27 = __toESM(require_dom()); 36291 var import_keyboard_shortcuts6 = __toESM(require_keyboard_shortcuts()); 36292 var import_keycodes10 = __toESM(require_keycodes()); 36293 var import_jsx_runtime237 = __toESM(require_jsx_runtime()); 36294 function hasOnlyToolbarItem(elements) { 36295 const dataProp = "toolbarItem"; 36296 return !elements.some((element) => !(dataProp in element.dataset)); 36297 } 36298 function getAllFocusableToolbarItemsIn(container) { 36299 return Array.from( 36300 container.querySelectorAll("[data-toolbar-item]:not([disabled])") 36301 ); 36302 } 36303 function hasFocusWithin(container) { 36304 return container.contains(container.ownerDocument.activeElement); 36305 } 36306 function focusFirstTabbableIn(container) { 36307 const [firstTabbable] = import_dom27.focus.tabbable.find(container); 36308 if (firstTabbable) { 36309 firstTabbable.focus({ 36310 // When focusing newly mounted toolbars, 36311 // the position of the popover is often not right on the first render 36312 // This prevents the layout shifts when focusing the dialogs. 36313 preventScroll: true 36314 }); 36315 } 36316 } 36317 function useIsAccessibleToolbar(toolbarRef) { 36318 const initialAccessibleToolbarState = true; 36319 const [isAccessibleToolbar, setIsAccessibleToolbar] = (0, import_element111.useState)( 36320 initialAccessibleToolbarState 36321 ); 36322 const determineIsAccessibleToolbar = (0, import_element111.useCallback)(() => { 36323 const tabbables = import_dom27.focus.tabbable.find(toolbarRef.current); 36324 const onlyToolbarItem = hasOnlyToolbarItem(tabbables); 36325 if (!onlyToolbarItem) { 36326 (0, import_deprecated12.default)("Using custom components as toolbar controls", { 36327 since: "5.6", 36328 alternative: "ToolbarItem, ToolbarButton or ToolbarDropdownMenu components", 36329 link: "https://developer.wordpress.org/block-editor/components/toolbar-button/#inside-blockcontrols" 36330 }); 36331 } 36332 setIsAccessibleToolbar(onlyToolbarItem); 36333 }, [toolbarRef]); 36334 (0, import_element111.useLayoutEffect)(() => { 36335 const observer = new window.MutationObserver( 36336 determineIsAccessibleToolbar 36337 ); 36338 observer.observe(toolbarRef.current, { 36339 childList: true, 36340 subtree: true 36341 }); 36342 return () => observer.disconnect(); 36343 }, [determineIsAccessibleToolbar, isAccessibleToolbar, toolbarRef]); 36344 return isAccessibleToolbar; 36345 } 36346 function useToolbarFocus({ 36347 toolbarRef, 36348 focusOnMount, 36349 isAccessibleToolbar, 36350 defaultIndex, 36351 onIndexChange, 36352 shouldUseKeyboardFocusShortcut, 36353 focusEditorOnEscape 36354 }) { 36355 const [initialFocusOnMount] = (0, import_element111.useState)(focusOnMount); 36356 const [initialIndex] = (0, import_element111.useState)(defaultIndex); 36357 const focusToolbar = (0, import_element111.useCallback)(() => { 36358 focusFirstTabbableIn(toolbarRef.current); 36359 }, [toolbarRef]); 36360 const focusToolbarViaShortcut = () => { 36361 if (shouldUseKeyboardFocusShortcut) { 36362 focusToolbar(); 36363 } 36364 }; 36365 (0, import_keyboard_shortcuts6.useShortcut)("core/block-editor/focus-toolbar", focusToolbarViaShortcut); 36366 (0, import_element111.useEffect)(() => { 36367 if (initialFocusOnMount) { 36368 focusToolbar(); 36369 } 36370 }, [isAccessibleToolbar, initialFocusOnMount, focusToolbar]); 36371 (0, import_element111.useEffect)(() => { 36372 const navigableToolbarRef = toolbarRef.current; 36373 let raf2 = 0; 36374 if (!initialFocusOnMount && !hasFocusWithin(navigableToolbarRef)) { 36375 raf2 = window.requestAnimationFrame(() => { 36376 const items = getAllFocusableToolbarItemsIn(navigableToolbarRef); 36377 const index = initialIndex || 0; 36378 if (items[index] && hasFocusWithin(navigableToolbarRef)) { 36379 items[index].focus({ 36380 // When focusing newly mounted toolbars, 36381 // the position of the popover is often not right on the first render 36382 // This prevents the layout shifts when focusing the dialogs. 36383 preventScroll: true 36384 }); 36385 } 36386 }); 36387 } 36388 return () => { 36389 window.cancelAnimationFrame(raf2); 36390 if (!onIndexChange || !navigableToolbarRef) { 36391 return; 36392 } 36393 const items = getAllFocusableToolbarItemsIn(navigableToolbarRef); 36394 const index = items.findIndex((item) => item.tabIndex === 0); 36395 onIndexChange(index); 36396 }; 36397 }, [initialIndex, initialFocusOnMount, onIndexChange, toolbarRef]); 36398 const { getLastFocus: getLastFocus2 } = unlock((0, import_data105.useSelect)(store)); 36399 (0, import_element111.useEffect)(() => { 36400 const navigableToolbarRef = toolbarRef.current; 36401 if (focusEditorOnEscape) { 36402 const handleKeyDown = (event) => { 36403 const lastFocus2 = getLastFocus2(); 36404 if (event.keyCode === import_keycodes10.ESCAPE && lastFocus2?.current) { 36405 event.preventDefault(); 36406 lastFocus2.current.focus(); 36407 } 36408 }; 36409 navigableToolbarRef.addEventListener("keydown", handleKeyDown); 36410 return () => { 36411 navigableToolbarRef.removeEventListener( 36412 "keydown", 36413 handleKeyDown 36414 ); 36415 }; 36416 } 36417 }, [focusEditorOnEscape, getLastFocus2, toolbarRef]); 36418 } 36419 function NavigableToolbar({ 36420 children, 36421 focusOnMount, 36422 focusEditorOnEscape = false, 36423 shouldUseKeyboardFocusShortcut = true, 36424 __experimentalInitialIndex: initialIndex, 36425 __experimentalOnIndexChange: onIndexChange, 36426 orientation = "horizontal", 36427 ...props 36428 }) { 36429 const toolbarRef = (0, import_element111.useRef)(); 36430 const isAccessibleToolbar = useIsAccessibleToolbar(toolbarRef); 36431 useToolbarFocus({ 36432 toolbarRef, 36433 focusOnMount, 36434 defaultIndex: initialIndex, 36435 onIndexChange, 36436 isAccessibleToolbar, 36437 shouldUseKeyboardFocusShortcut, 36438 focusEditorOnEscape 36439 }); 36440 if (isAccessibleToolbar) { 36441 return /* @__PURE__ */ (0, import_jsx_runtime237.jsx)( 36442 import_components100.Toolbar, 36443 { 36444 label: props["aria-label"], 36445 ref: toolbarRef, 36446 orientation, 36447 ...props, 36448 children 36449 } 36450 ); 36451 } 36452 return /* @__PURE__ */ (0, import_jsx_runtime237.jsx)( 36453 import_components100.NavigableMenu, 36454 { 36455 orientation, 36456 role: "toolbar", 36457 ref: toolbarRef, 36458 ...props, 36459 children 36460 } 36461 ); 36462 } 36463 36464 // packages/block-editor/build-module/components/block-toolbar/use-has-block-toolbar.js 36465 var import_data106 = __toESM(require_data()); 36466 var import_blocks61 = __toESM(require_blocks()); 36467 function useHasBlockToolbar() { 36468 const enabled = (0, import_data106.useSelect)((select3) => { 36469 const { getBlockEditingMode: getBlockEditingMode2, getBlockName: getBlockName2, getBlockSelectionStart: getBlockSelectionStart2 } = select3(store); 36470 const selectedBlockClientId = getBlockSelectionStart2(); 36471 const blockType = selectedBlockClientId && (0, import_blocks61.getBlockType)(getBlockName2(selectedBlockClientId)); 36472 return blockType && (0, import_blocks61.hasBlockSupport)(blockType, "__experimentalToolbar", true) && getBlockEditingMode2(selectedBlockClientId) !== "disabled"; 36473 }, []); 36474 return enabled; 36475 } 36476 36477 // packages/block-editor/build-module/components/block-toolbar/change-design.js 36478 var import_components101 = __toESM(require_components()); 36479 var import_i18n89 = __toESM(require_i18n()); 36480 var import_blocks62 = __toESM(require_blocks()); 36481 var import_element112 = __toESM(require_element()); 36482 var import_data107 = __toESM(require_data()); 36483 var import_jsx_runtime238 = __toESM(require_jsx_runtime()); 36484 var EMPTY_ARRAY8 = []; 36485 var MAX_PATTERNS_TO_SHOW = 6; 36486 var POPOVER_PROPS5 = { 36487 placement: "bottom-start" 36488 }; 36489 function ChangeDesign({ clientId }) { 36490 const { categories, currentPatternName, patterns } = (0, import_data107.useSelect)( 36491 (select3) => { 36492 const { 36493 getBlockAttributes: getBlockAttributes3, 36494 getBlockRootClientId: getBlockRootClientId2, 36495 __experimentalGetAllowedPatterns: __experimentalGetAllowedPatterns2 36496 } = select3(store); 36497 const attributes = getBlockAttributes3(clientId); 36498 const _categories = attributes?.metadata?.categories || EMPTY_ARRAY8; 36499 const rootBlock = getBlockRootClientId2(clientId); 36500 const _patterns = _categories.length > 0 ? __experimentalGetAllowedPatterns2(rootBlock) : EMPTY_ARRAY8; 36501 return { 36502 categories: _categories, 36503 currentPatternName: attributes?.metadata?.patternName, 36504 patterns: _patterns 36505 }; 36506 }, 36507 [clientId] 36508 ); 36509 const { replaceBlocks: replaceBlocks2 } = (0, import_data107.useDispatch)(store); 36510 const sameCategoryPatternsWithSingleWrapper = (0, import_element112.useMemo)(() => { 36511 if (categories.length === 0 || !patterns || patterns.length === 0) { 36512 return EMPTY_ARRAY8; 36513 } 36514 return patterns.filter((pattern) => { 36515 const isCorePattern = pattern.source === "core" || pattern.source?.startsWith("pattern-directory") && pattern.source !== "pattern-directory/theme"; 36516 return ( 36517 // Check if the pattern has only one top level block, 36518 // otherwise we may switch to a pattern that doesn't have replacement suggestions. 36519 pattern.blocks.length === 1 && // We exclude the core patterns and pattern directory patterns that are not theme patterns. 36520 !isCorePattern && // Exclude current pattern. 36521 currentPatternName !== pattern.name && pattern.categories?.some((category) => { 36522 return categories.includes(category); 36523 }) && // Check if the pattern is not a synced pattern. 36524 (pattern.syncStatus === "unsynced" || !pattern.id) 36525 ); 36526 }).slice(0, MAX_PATTERNS_TO_SHOW); 36527 }, [categories, currentPatternName, patterns]); 36528 if (sameCategoryPatternsWithSingleWrapper.length < 2) { 36529 return null; 36530 } 36531 const onClickPattern = (pattern) => { 36532 const newBlocks = (pattern.blocks ?? []).map((block) => { 36533 return (0, import_blocks62.cloneBlock)(block); 36534 }); 36535 newBlocks[0].attributes.metadata = { 36536 ...newBlocks[0].attributes.metadata, 36537 categories 36538 }; 36539 replaceBlocks2(clientId, newBlocks); 36540 }; 36541 return /* @__PURE__ */ (0, import_jsx_runtime238.jsx)( 36542 import_components101.Dropdown, 36543 { 36544 popoverProps: POPOVER_PROPS5, 36545 renderToggle: ({ onToggle, isOpen }) => { 36546 return /* @__PURE__ */ (0, import_jsx_runtime238.jsx)(import_components101.ToolbarGroup, { children: /* @__PURE__ */ (0, import_jsx_runtime238.jsx)( 36547 import_components101.ToolbarButton, 36548 { 36549 onClick: () => onToggle(!isOpen), 36550 "aria-expanded": isOpen, 36551 children: (0, import_i18n89.__)("Change design") 36552 } 36553 ) }); 36554 }, 36555 renderContent: () => /* @__PURE__ */ (0, import_jsx_runtime238.jsx)( 36556 import_components101.__experimentalDropdownContentWrapper, 36557 { 36558 className: "block-editor-block-toolbar-change-design-content-wrapper", 36559 paddingSize: "none", 36560 children: /* @__PURE__ */ (0, import_jsx_runtime238.jsx)( 36561 block_patterns_list_default, 36562 { 36563 blockPatterns: sameCategoryPatternsWithSingleWrapper, 36564 onClickPattern, 36565 showTitlesAsTooltip: true 36566 } 36567 ) 36568 } 36569 ) 36570 } 36571 ); 36572 } 36573 36574 // packages/block-editor/build-module/components/block-toolbar/switch-section-style.js 36575 var import_components102 = __toESM(require_components()); 36576 var import_i18n91 = __toESM(require_i18n()); 36577 var import_data111 = __toESM(require_data()); 36578 36579 // packages/block-editor/build-module/components/block-styles/use-styles-for-block.js 36580 var import_data108 = __toESM(require_data()); 36581 var import_blocks63 = __toESM(require_blocks()); 36582 var import_element113 = __toESM(require_element()); 36583 36584 // packages/block-editor/build-module/components/block-styles/utils.js 36585 var import_token_list = __toESM(require_token_list()); 36586 var import_i18n90 = __toESM(require_i18n()); 36587 function getActiveStyle(styles, className) { 36588 for (const style of new import_token_list.default(className).values()) { 36589 if (style.indexOf("is-style-") === -1) { 36590 continue; 36591 } 36592 const potentialStyleName = style.substring(9); 36593 const activeStyle = styles?.find( 36594 ({ name }) => name === potentialStyleName 36595 ); 36596 if (activeStyle) { 36597 return activeStyle; 36598 } 36599 } 36600 return getDefaultStyle(styles); 36601 } 36602 function replaceActiveStyle(className, activeStyle, newStyle) { 36603 const list = new import_token_list.default(className); 36604 if (activeStyle) { 36605 list.remove("is-style-" + activeStyle.name); 36606 } 36607 list.add("is-style-" + newStyle.name); 36608 return list.value; 36609 } 36610 function getRenderedStyles(styles) { 36611 if (!styles || styles.length === 0) { 36612 return []; 36613 } 36614 return getDefaultStyle(styles) ? styles : [ 36615 { 36616 name: "default", 36617 label: (0, import_i18n90._x)("Default", "block style"), 36618 isDefault: true 36619 }, 36620 ...styles 36621 ]; 36622 } 36623 function getDefaultStyle(styles) { 36624 return styles?.find((style) => style.isDefault); 36625 } 36626 36627 // packages/block-editor/build-module/components/block-styles/use-styles-for-block.js 36628 function useGenericPreviewBlock(block, type) { 36629 return (0, import_element113.useMemo)(() => { 36630 const example = type?.example; 36631 const blockName = type?.name; 36632 if (example && blockName) { 36633 return (0, import_blocks63.getBlockFromExample)(blockName, { 36634 attributes: example.attributes, 36635 innerBlocks: example.innerBlocks 36636 }); 36637 } 36638 if (block) { 36639 return (0, import_blocks63.cloneBlock)(block); 36640 } 36641 }, [block, type?.example, type?.name]); 36642 } 36643 function useStylesForBlocks({ clientId, onSwitch }) { 36644 const selector3 = (select3) => { 36645 const { getBlock: getBlock2 } = select3(store); 36646 const block2 = getBlock2(clientId); 36647 if (!block2) { 36648 return {}; 36649 } 36650 const blockType2 = (0, import_blocks63.getBlockType)(block2.name); 36651 const { getBlockStyles: getBlockStyles2 } = select3(import_blocks63.store); 36652 return { 36653 block: !blockType2?.example ? block2 : null, 36654 blockType: blockType2, 36655 styles: getBlockStyles2(block2.name), 36656 className: block2.attributes.className || "" 36657 }; 36658 }; 36659 const { styles, block, blockType, className } = (0, import_data108.useSelect)(selector3, [ 36660 clientId 36661 ]); 36662 const { updateBlockAttributes: updateBlockAttributes2 } = (0, import_data108.useDispatch)(store); 36663 const stylesToRender = getRenderedStyles(styles); 36664 const activeStyle = getActiveStyle(stylesToRender, className); 36665 const genericPreviewBlock = useGenericPreviewBlock(block, blockType); 36666 const onSelect = (style) => { 36667 const styleClassName = replaceActiveStyle( 36668 className, 36669 activeStyle, 36670 style 36671 ); 36672 updateBlockAttributes2(clientId, { 36673 className: styleClassName 36674 }); 36675 onSwitch(); 36676 }; 36677 return { 36678 onSelect, 36679 stylesToRender, 36680 activeStyle, 36681 genericPreviewBlock, 36682 className 36683 }; 36684 } 36685 36686 // packages/block-editor/build-module/hooks/block-style-variation.js 36687 var import_blocks65 = __toESM(require_blocks()); 36688 var import_data110 = __toESM(require_data()); 36689 var import_element114 = __toESM(require_element()); 36690 36691 // packages/global-styles-engine/build-module/utils/object.js 36692 function setImmutably2(object, path, value) { 36693 path = Array.isArray(path) ? [...path] : [path]; 36694 object = Array.isArray(object) ? [...object] : { ...object }; 36695 const leaf = path.pop(); 36696 let prev = object; 36697 for (const key of path) { 36698 const lvl = prev[key]; 36699 prev = prev[key] = Array.isArray(lvl) ? [...lvl] : { ...lvl }; 36700 } 36701 prev[leaf] = value; 36702 return object; 36703 } 36704 var getValueFromObjectPath2 = (object, path, defaultValue) => { 36705 const arrayPath = Array.isArray(path) ? path : path.split("."); 36706 let value = object; 36707 arrayPath.forEach((fieldName) => { 36708 value = value?.[fieldName]; 36709 }); 36710 return value ?? defaultValue; 36711 }; 36712 36713 // packages/global-styles-engine/build-module/utils/common.js 36714 var import_style_engine2 = __toESM(require_style_engine()); 36715 36716 // packages/global-styles-engine/build-module/utils/fluid.js 36717 var DEFAULT_MAXIMUM_VIEWPORT_WIDTH2 = "1600px"; 36718 var DEFAULT_MINIMUM_VIEWPORT_WIDTH2 = "320px"; 36719 var DEFAULT_SCALE_FACTOR2 = 1; 36720 var DEFAULT_MINIMUM_FONT_SIZE_FACTOR_MIN2 = 0.25; 36721 var DEFAULT_MINIMUM_FONT_SIZE_FACTOR_MAX2 = 0.75; 36722 var DEFAULT_MINIMUM_FONT_SIZE_LIMIT2 = "14px"; 36723 function getComputedFluidTypographyValue2({ 36724 minimumFontSize, 36725 maximumFontSize, 36726 fontSize, 36727 minimumViewportWidth = DEFAULT_MINIMUM_VIEWPORT_WIDTH2, 36728 maximumViewportWidth = DEFAULT_MAXIMUM_VIEWPORT_WIDTH2, 36729 scaleFactor = DEFAULT_SCALE_FACTOR2, 36730 minimumFontSizeLimit 36731 }) { 36732 minimumFontSizeLimit = !!getTypographyValueAndUnit2(minimumFontSizeLimit) ? minimumFontSizeLimit : DEFAULT_MINIMUM_FONT_SIZE_LIMIT2; 36733 if (fontSize) { 36734 const fontSizeParsed = getTypographyValueAndUnit2(fontSize); 36735 if (!fontSizeParsed?.unit || !fontSizeParsed?.value) { 36736 return null; 36737 } 36738 const minimumFontSizeLimitParsed = getTypographyValueAndUnit2( 36739 minimumFontSizeLimit, 36740 { 36741 coerceTo: fontSizeParsed.unit 36742 } 36743 ); 36744 if (!!minimumFontSizeLimitParsed?.value && !minimumFontSize && !maximumFontSize) { 36745 if (fontSizeParsed?.value <= minimumFontSizeLimitParsed?.value) { 36746 return null; 36747 } 36748 } 36749 if (!maximumFontSize) { 36750 maximumFontSize = `$fontSizeParsed.value}$fontSizeParsed.unit}`; 36751 } 36752 if (!minimumFontSize) { 36753 const fontSizeValueInPx = fontSizeParsed.unit === "px" ? fontSizeParsed.value : fontSizeParsed.value * 16; 36754 const minimumFontSizeFactor = Math.min( 36755 Math.max( 36756 1 - 0.075 * Math.log2(fontSizeValueInPx), 36757 DEFAULT_MINIMUM_FONT_SIZE_FACTOR_MIN2 36758 ), 36759 DEFAULT_MINIMUM_FONT_SIZE_FACTOR_MAX2 36760 ); 36761 const calculatedMinimumFontSize = roundToPrecision2( 36762 fontSizeParsed.value * minimumFontSizeFactor, 36763 3 36764 ); 36765 if (!!minimumFontSizeLimitParsed?.value && calculatedMinimumFontSize < minimumFontSizeLimitParsed?.value) { 36766 minimumFontSize = `$minimumFontSizeLimitParsed.value}$minimumFontSizeLimitParsed.unit}`; 36767 } else { 36768 minimumFontSize = `$calculatedMinimumFontSize}$fontSizeParsed.unit}`; 36769 } 36770 } 36771 } 36772 const minimumFontSizeParsed = getTypographyValueAndUnit2(minimumFontSize); 36773 const fontSizeUnit = minimumFontSizeParsed?.unit || "rem"; 36774 const maximumFontSizeParsed = getTypographyValueAndUnit2(maximumFontSize, { 36775 coerceTo: fontSizeUnit 36776 }); 36777 if (!minimumFontSizeParsed || !maximumFontSizeParsed) { 36778 return null; 36779 } 36780 const minimumFontSizeRem = getTypographyValueAndUnit2(minimumFontSize, { 36781 coerceTo: "rem" 36782 }); 36783 const maximumViewportWidthParsed = getTypographyValueAndUnit2( 36784 maximumViewportWidth, 36785 { coerceTo: fontSizeUnit } 36786 ); 36787 const minimumViewportWidthParsed = getTypographyValueAndUnit2( 36788 minimumViewportWidth, 36789 { coerceTo: fontSizeUnit } 36790 ); 36791 if (!maximumViewportWidthParsed || !minimumViewportWidthParsed || !minimumFontSizeRem) { 36792 return null; 36793 } 36794 const linearDenominator = maximumViewportWidthParsed.value - minimumViewportWidthParsed.value; 36795 if (!linearDenominator) { 36796 return null; 36797 } 36798 const minViewportWidthOffsetValue = roundToPrecision2( 36799 minimumViewportWidthParsed.value / 100, 36800 3 36801 ); 36802 const viewportWidthOffset = roundToPrecision2(minViewportWidthOffsetValue, 3) + fontSizeUnit; 36803 const linearFactor = 100 * ((maximumFontSizeParsed.value - minimumFontSizeParsed.value) / linearDenominator); 36804 const linearFactorScaled = roundToPrecision2( 36805 (linearFactor || 1) * scaleFactor, 36806 3 36807 ); 36808 const fluidTargetFontSize = `$minimumFontSizeRem.value}$minimumFontSizeRem.unit} + ((1vw - $viewportWidthOffset}) * $linearFactorScaled})`; 36809 return `clamp($minimumFontSize}, $fluidTargetFontSize}, $maximumFontSize})`; 36810 } 36811 function getTypographyValueAndUnit2(rawValue, options = {}) { 36812 if (typeof rawValue !== "string" && typeof rawValue !== "number") { 36813 return null; 36814 } 36815 if (isFinite(rawValue)) { 36816 rawValue = `$rawValue}px`; 36817 } 36818 const { coerceTo, rootSizeValue, acceptableUnits } = { 36819 coerceTo: "", 36820 // Default browser font size. Later we could inject some JS to compute this `getComputedStyle( document.querySelector( "html" ) ).fontSize`. 36821 rootSizeValue: 16, 36822 acceptableUnits: ["rem", "px", "em"], 36823 ...options 36824 }; 36825 const acceptableUnitsGroup = acceptableUnits?.join("|"); 36826 const regexUnits = new RegExp( 36827 `^(\\d*\\.?\\d+)($acceptableUnitsGroup}){1,1}$` 36828 ); 36829 const matches = rawValue.toString().match(regexUnits); 36830 if (!matches || matches.length < 3) { 36831 return null; 36832 } 36833 let [, value, unit] = matches; 36834 let returnValue = parseFloat(value); 36835 if ("px" === coerceTo && ("em" === unit || "rem" === unit)) { 36836 returnValue = returnValue * rootSizeValue; 36837 unit = coerceTo; 36838 } 36839 if ("px" === unit && ("em" === coerceTo || "rem" === coerceTo)) { 36840 returnValue = returnValue / rootSizeValue; 36841 unit = coerceTo; 36842 } 36843 if (("em" === coerceTo || "rem" === coerceTo) && ("em" === unit || "rem" === unit)) { 36844 unit = coerceTo; 36845 } 36846 if (!unit) { 36847 return null; 36848 } 36849 return { 36850 value: roundToPrecision2(returnValue, 3), 36851 unit 36852 }; 36853 } 36854 function roundToPrecision2(value, digits = 3) { 36855 const base = Math.pow(10, digits); 36856 return Math.round(value * base) / base; 36857 } 36858 36859 // packages/global-styles-engine/build-module/utils/typography.js 36860 function isFluidTypographyEnabled(typographySettings) { 36861 const fluidSettings = typographySettings?.fluid; 36862 return true === fluidSettings || fluidSettings && typeof fluidSettings === "object" && Object.keys(fluidSettings).length > 0; 36863 } 36864 function getFluidTypographyOptionsFromSettings(settings2) { 36865 const typographySettings = settings2?.typography ?? {}; 36866 const layoutSettings = settings2?.layout; 36867 const defaultMaxViewportWidth = getTypographyValueAndUnit2( 36868 layoutSettings?.wideSize 36869 ) ? layoutSettings?.wideSize : null; 36870 return isFluidTypographyEnabled(typographySettings) && defaultMaxViewportWidth ? { 36871 fluid: { 36872 maxViewportWidth: defaultMaxViewportWidth, 36873 ...typeof typographySettings.fluid === "object" ? typographySettings.fluid : {} 36874 } 36875 } : { 36876 fluid: typographySettings?.fluid 36877 }; 36878 } 36879 function getTypographyFontSizeValue(preset, settings2) { 36880 const { size: defaultSize } = preset; 36881 if (!defaultSize || "0" === defaultSize || false === preset?.fluid) { 36882 return defaultSize; 36883 } 36884 if (!isFluidTypographyEnabled(settings2?.typography) && !isFluidTypographyEnabled(preset)) { 36885 return defaultSize; 36886 } 36887 const fluidTypographySettings = getFluidTypographyOptionsFromSettings(settings2)?.fluid ?? {}; 36888 const fluidFontSizeValue = getComputedFluidTypographyValue2({ 36889 minimumFontSize: typeof preset?.fluid === "boolean" ? void 0 : preset?.fluid?.min, 36890 maximumFontSize: typeof preset?.fluid === "boolean" ? void 0 : preset?.fluid?.max, 36891 fontSize: defaultSize, 36892 minimumFontSizeLimit: typeof fluidTypographySettings === "object" ? fluidTypographySettings?.minFontSize : void 0, 36893 maximumViewportWidth: typeof fluidTypographySettings === "object" ? fluidTypographySettings?.maxViewportWidth : void 0, 36894 minimumViewportWidth: typeof fluidTypographySettings === "object" ? fluidTypographySettings?.minViewportWidth : void 0 36895 }); 36896 if (!!fluidFontSizeValue) { 36897 return fluidFontSizeValue; 36898 } 36899 return defaultSize; 36900 } 36901 36902 // packages/global-styles-engine/build-module/utils/common.js 36903 var ROOT_BLOCK_SELECTOR = "body"; 36904 var ROOT_CSS_PROPERTIES_SELECTOR = ":root"; 36905 var PRESET_METADATA = [ 36906 { 36907 path: ["color", "palette"], 36908 valueKey: "color", 36909 cssVarInfix: "color", 36910 classes: [ 36911 { classSuffix: "color", propertyName: "color" }, 36912 { 36913 classSuffix: "background-color", 36914 propertyName: "background-color" 36915 }, 36916 { 36917 classSuffix: "border-color", 36918 propertyName: "border-color" 36919 } 36920 ] 36921 }, 36922 { 36923 path: ["color", "gradients"], 36924 valueKey: "gradient", 36925 cssVarInfix: "gradient", 36926 classes: [ 36927 { 36928 classSuffix: "gradient-background", 36929 propertyName: "background" 36930 } 36931 ] 36932 }, 36933 { 36934 path: ["color", "duotone"], 36935 valueKey: "colors", 36936 cssVarInfix: "duotone", 36937 valueFunc: ({ slug }) => `url( '#wp-duotone-$slug}' )`, 36938 classes: [] 36939 }, 36940 { 36941 path: ["shadow", "presets"], 36942 valueKey: "shadow", 36943 cssVarInfix: "shadow", 36944 classes: [] 36945 }, 36946 { 36947 path: ["typography", "fontSizes"], 36948 valueFunc: (preset, settings2) => getTypographyFontSizeValue(preset, settings2), 36949 valueKey: "size", 36950 cssVarInfix: "font-size", 36951 classes: [{ classSuffix: "font-size", propertyName: "font-size" }] 36952 }, 36953 { 36954 path: ["typography", "fontFamilies"], 36955 valueKey: "fontFamily", 36956 cssVarInfix: "font-family", 36957 classes: [ 36958 { classSuffix: "font-family", propertyName: "font-family" } 36959 ] 36960 }, 36961 { 36962 path: ["spacing", "spacingSizes"], 36963 valueKey: "size", 36964 cssVarInfix: "spacing", 36965 valueFunc: ({ size }) => size, 36966 classes: [] 36967 }, 36968 { 36969 path: ["border", "radiusSizes"], 36970 valueKey: "size", 36971 cssVarInfix: "border-radius", 36972 classes: [] 36973 }, 36974 { 36975 path: ["dimensions", "dimensionSizes"], 36976 valueKey: "size", 36977 cssVarInfix: "dimension", 36978 classes: [] 36979 } 36980 ]; 36981 function scopeSelector2(scope, selector3) { 36982 if (!scope || !selector3) { 36983 return selector3; 36984 } 36985 const scopes = scope.split(","); 36986 const selectors = selector3.split(","); 36987 const selectorsScoped = []; 36988 scopes.forEach((outer) => { 36989 selectors.forEach((inner) => { 36990 selectorsScoped.push(`$outer.trim()} $inner.trim()}`); 36991 }); 36992 }); 36993 return selectorsScoped.join(", "); 36994 } 36995 function scopeFeatureSelectors(scope, selectors) { 36996 if (!scope || !selectors) { 36997 return; 36998 } 36999 const featureSelectors = {}; 37000 Object.entries(selectors).forEach(([feature, selector3]) => { 37001 if (typeof selector3 === "string") { 37002 featureSelectors[feature] = scopeSelector2(scope, selector3); 37003 } 37004 if (typeof selector3 === "object") { 37005 featureSelectors[feature] = {}; 37006 Object.entries(selector3).forEach( 37007 ([subfeature, subfeatureSelector]) => { 37008 featureSelectors[feature][subfeature] = scopeSelector2( 37009 scope, 37010 subfeatureSelector 37011 ); 37012 } 37013 ); 37014 } 37015 }); 37016 return featureSelectors; 37017 } 37018 function appendToSelector(selector3, toAppend) { 37019 if (!selector3.includes(",")) { 37020 return selector3 + toAppend; 37021 } 37022 const selectors = selector3.split(","); 37023 const newSelectors = selectors.map((sel) => sel + toAppend); 37024 return newSelectors.join(","); 37025 } 37026 function getBlockStyleVariationSelector(variation, blockSelector) { 37027 const variationClass = `.is-style-$variation}`; 37028 if (!blockSelector) { 37029 return variationClass; 37030 } 37031 const ancestorRegex = /((?::\([^)]+\))?\s*)([^\s:]+)/; 37032 const addVariationClass = (_match, group1, group2) => { 37033 return group1 + group2 + variationClass; 37034 }; 37035 const result = blockSelector.split(",").map((part) => part.replace(ancestorRegex, addVariationClass)); 37036 return result.join(","); 37037 } 37038 function getResolvedRefValue(ruleValue, tree) { 37039 if (!ruleValue || !tree) { 37040 return ruleValue; 37041 } 37042 if (typeof ruleValue === "object" && "ref" in ruleValue && ruleValue?.ref) { 37043 const resolvedRuleValue = (0, import_style_engine2.getCSSValueFromRawStyle)( 37044 getValueFromObjectPath2(tree, ruleValue.ref) 37045 ); 37046 if (typeof resolvedRuleValue === "object" && resolvedRuleValue !== null && "ref" in resolvedRuleValue && resolvedRuleValue?.ref) { 37047 return void 0; 37048 } 37049 if (resolvedRuleValue === void 0) { 37050 return ruleValue; 37051 } 37052 return resolvedRuleValue; 37053 } 37054 return ruleValue; 37055 } 37056 function getResolvedThemeFilePath(file, themeFileURIs) { 37057 if (!file || !themeFileURIs || !Array.isArray(themeFileURIs)) { 37058 return file; 37059 } 37060 const uri = themeFileURIs.find( 37061 (themeFileUri) => themeFileUri?.name === file 37062 ); 37063 if (!uri?.href) { 37064 return file; 37065 } 37066 return uri?.href; 37067 } 37068 function getResolvedValue(ruleValue, tree) { 37069 if (!ruleValue || !tree) { 37070 return ruleValue; 37071 } 37072 const resolvedValue = getResolvedRefValue(ruleValue, tree); 37073 if (typeof resolvedValue === "object" && resolvedValue !== null && "url" in resolvedValue && resolvedValue?.url) { 37074 resolvedValue.url = getResolvedThemeFilePath( 37075 resolvedValue.url, 37076 tree?._links?.["wp:theme-file"] 37077 ); 37078 } 37079 return resolvedValue; 37080 } 37081 function findInPresetsBy(settings2, blockName, presetPath = [], presetProperty = "slug", presetValueValue) { 37082 const orderedPresetsByOrigin = [ 37083 blockName ? getValueFromObjectPath2(settings2, [ 37084 "blocks", 37085 blockName, 37086 ...presetPath 37087 ]) : void 0, 37088 getValueFromObjectPath2(settings2, presetPath) 37089 ].filter(Boolean); 37090 for (const presetByOrigin of orderedPresetsByOrigin) { 37091 if (presetByOrigin) { 37092 const origins = ["custom", "theme", "default"]; 37093 for (const origin of origins) { 37094 const presets = presetByOrigin[origin]; 37095 if (presets) { 37096 const presetObject = presets.find( 37097 (preset) => preset[presetProperty] === presetValueValue 37098 ); 37099 if (presetObject) { 37100 if (presetProperty === "slug") { 37101 return presetObject; 37102 } 37103 const highestPresetObjectWithSameSlug = findInPresetsBy( 37104 settings2, 37105 blockName, 37106 presetPath, 37107 "slug", 37108 presetObject.slug 37109 ); 37110 if (highestPresetObjectWithSameSlug[presetProperty] === presetObject[presetProperty]) { 37111 return presetObject; 37112 } 37113 return void 0; 37114 } 37115 } 37116 } 37117 } 37118 } 37119 } 37120 function getValueFromPresetVariable(features, blockName, variable, [presetType, slug] = []) { 37121 const metadata = PRESET_METADATA.find( 37122 (data) => data.cssVarInfix === presetType 37123 ); 37124 if (!metadata || !features.settings) { 37125 return variable; 37126 } 37127 const presetObject = findInPresetsBy( 37128 features.settings, 37129 blockName, 37130 metadata.path, 37131 "slug", 37132 slug 37133 ); 37134 if (presetObject) { 37135 const { valueKey } = metadata; 37136 const result = presetObject[valueKey]; 37137 return getValueFromVariable(features, blockName, result); 37138 } 37139 return variable; 37140 } 37141 function getValueFromCustomVariable(features, blockName, variable, path = []) { 37142 const result = (blockName ? getValueFromObjectPath2(features?.settings ?? {}, [ 37143 "blocks", 37144 blockName, 37145 "custom", 37146 ...path 37147 ]) : void 0) ?? getValueFromObjectPath2(features?.settings ?? {}, [ 37148 "custom", 37149 ...path 37150 ]); 37151 if (!result) { 37152 return variable; 37153 } 37154 return getValueFromVariable(features, blockName, result); 37155 } 37156 function getValueFromVariable(features, blockName, variable) { 37157 if (!variable || typeof variable !== "string") { 37158 if (typeof variable === "object" && variable !== null && "ref" in variable && typeof variable.ref === "string") { 37159 const resolvedVariable = getValueFromObjectPath2( 37160 features, 37161 variable.ref 37162 ); 37163 if (!resolvedVariable || typeof resolvedVariable === "object" && "ref" in resolvedVariable) { 37164 return resolvedVariable; 37165 } 37166 variable = resolvedVariable; 37167 } else { 37168 return variable; 37169 } 37170 } 37171 const USER_VALUE_PREFIX = "var:"; 37172 const THEME_VALUE_PREFIX = "var(--wp--"; 37173 const THEME_VALUE_SUFFIX = ")"; 37174 let parsedVar; 37175 if (variable.startsWith(USER_VALUE_PREFIX)) { 37176 parsedVar = variable.slice(USER_VALUE_PREFIX.length).split("|"); 37177 } else if (variable.startsWith(THEME_VALUE_PREFIX) && variable.endsWith(THEME_VALUE_SUFFIX)) { 37178 parsedVar = variable.slice(THEME_VALUE_PREFIX.length, -THEME_VALUE_SUFFIX.length).split("--"); 37179 } else { 37180 return variable; 37181 } 37182 const [type, ...path] = parsedVar; 37183 if (type === "preset") { 37184 return getValueFromPresetVariable( 37185 features, 37186 blockName, 37187 variable, 37188 path 37189 ); 37190 } 37191 if (type === "custom") { 37192 return getValueFromCustomVariable( 37193 features, 37194 blockName, 37195 variable, 37196 path 37197 ); 37198 } 37199 return variable; 37200 } 37201 37202 // packages/global-styles-engine/build-module/core/render.js 37203 var import_blocks64 = __toESM(require_blocks()); 37204 var import_style_engine3 = __toESM(require_style_engine()); 37205 var import_data109 = __toESM(require_data()); 37206 37207 // packages/global-styles-engine/build-module/core/selectors.js 37208 function getBlockSelector(blockType, target = "root", options = {}) { 37209 if (!target) { 37210 return null; 37211 } 37212 const { fallback = false } = options; 37213 const { name, selectors, supports } = blockType; 37214 const hasSelectors = selectors && Object.keys(selectors).length > 0; 37215 const path = Array.isArray(target) ? target.join(".") : target; 37216 let rootSelector = null; 37217 if (hasSelectors && selectors.root) { 37218 rootSelector = selectors?.root; 37219 } else if (supports?.__experimentalSelector) { 37220 rootSelector = supports.__experimentalSelector; 37221 } else { 37222 rootSelector = ".wp-block-" + name.replace("core/", "").replace("/", "-"); 37223 } 37224 if (path === "root") { 37225 return rootSelector; 37226 } 37227 const pathArray = Array.isArray(target) ? target : target.split("."); 37228 if (pathArray.length === 1) { 37229 const fallbackSelector = fallback ? rootSelector : null; 37230 if (hasSelectors) { 37231 const featureSelector2 = getValueFromObjectPath2( 37232 selectors, 37233 `$path}.root`, 37234 null 37235 ) || getValueFromObjectPath2(selectors, path, null); 37236 return featureSelector2 || fallbackSelector; 37237 } 37238 const featureSelector = supports ? getValueFromObjectPath2( 37239 supports, 37240 `$path}.__experimentalSelector`, 37241 null 37242 ) : void 0; 37243 if (!featureSelector) { 37244 return fallbackSelector; 37245 } 37246 return scopeSelector2(rootSelector, featureSelector); 37247 } 37248 let subfeatureSelector; 37249 if (hasSelectors) { 37250 subfeatureSelector = getValueFromObjectPath2(selectors, path, null); 37251 } 37252 if (subfeatureSelector) { 37253 return subfeatureSelector; 37254 } 37255 if (fallback) { 37256 return getBlockSelector(blockType, pathArray[0], options); 37257 } 37258 return null; 37259 } 37260 37261 // packages/global-styles-engine/build-module/utils/string.js 37262 function kebabCase4(str) { 37263 return str.replace(/([a-z])([A-Z])/g, "$1-$2").replace(/([0-9])([a-zA-Z])/g, "$1-$2").replace(/([a-zA-Z])([0-9])/g, "$1-$2").replace(/[\s_]+/g, "-").toLowerCase(); 37264 } 37265 37266 // packages/global-styles-engine/build-module/utils/spacing.js 37267 function getSpacingPresetCssVar2(value) { 37268 if (!value) { 37269 return; 37270 } 37271 const slug = value.match(/var:preset\|spacing\|(.+)/); 37272 if (!slug) { 37273 return value; 37274 } 37275 return `var(--wp--preset--spacing--$slug[1]})`; 37276 } 37277 37278 // packages/global-styles-engine/build-module/utils/gap.js 37279 function getGapBoxControlValueFromStyle2(blockGapValue) { 37280 if (!blockGapValue) { 37281 return null; 37282 } 37283 const isValueString = typeof blockGapValue === "string"; 37284 return { 37285 top: isValueString ? blockGapValue : blockGapValue?.top, 37286 left: isValueString ? blockGapValue : blockGapValue?.left 37287 }; 37288 } 37289 function getGapCSSValue2(blockGapValue, defaultValue = "0") { 37290 const blockGapBoxControlValue = getGapBoxControlValueFromStyle2(blockGapValue); 37291 if (!blockGapBoxControlValue) { 37292 return null; 37293 } 37294 const row = getSpacingPresetCssVar2(blockGapBoxControlValue?.top) || defaultValue; 37295 const column = getSpacingPresetCssVar2(blockGapBoxControlValue?.left) || defaultValue; 37296 return row === column ? row : `$row} $column}`; 37297 } 37298 37299 // packages/global-styles-engine/build-module/utils/background.js 37300 var BACKGROUND_BLOCK_DEFAULT_VALUES = { 37301 backgroundSize: "cover", 37302 backgroundPosition: "50% 50%" 37303 // used only when backgroundSize is 'contain'. 37304 }; 37305 function setBackgroundStyleDefaults(backgroundStyle) { 37306 if (!backgroundStyle || // @ts-expect-error 37307 !backgroundStyle?.backgroundImage?.url) { 37308 return; 37309 } 37310 let backgroundStylesWithDefaults; 37311 if (!backgroundStyle?.backgroundSize) { 37312 backgroundStylesWithDefaults = { 37313 backgroundSize: BACKGROUND_BLOCK_DEFAULT_VALUES.backgroundSize 37314 }; 37315 } 37316 if ("contain" === backgroundStyle?.backgroundSize && !backgroundStyle?.backgroundPosition) { 37317 backgroundStylesWithDefaults = { 37318 backgroundPosition: BACKGROUND_BLOCK_DEFAULT_VALUES.backgroundPosition 37319 }; 37320 } 37321 return backgroundStylesWithDefaults; 37322 } 37323 37324 // packages/global-styles-engine/build-module/utils/layout.js 37325 var LAYOUT_DEFINITIONS2 = { 37326 default: { 37327 name: "default", 37328 slug: "flow", 37329 className: "is-layout-flow", 37330 baseStyles: [ 37331 { 37332 selector: " > .alignleft", 37333 rules: { 37334 float: "left", 37335 "margin-inline-start": "0", 37336 "margin-inline-end": "2em" 37337 } 37338 }, 37339 { 37340 selector: " > .alignright", 37341 rules: { 37342 float: "right", 37343 "margin-inline-start": "2em", 37344 "margin-inline-end": "0" 37345 } 37346 }, 37347 { 37348 selector: " > .aligncenter", 37349 rules: { 37350 "margin-left": "auto !important", 37351 "margin-right": "auto !important" 37352 } 37353 } 37354 ], 37355 spacingStyles: [ 37356 { 37357 selector: " > :first-child", 37358 rules: { 37359 "margin-block-start": "0" 37360 } 37361 }, 37362 { 37363 selector: " > :last-child", 37364 rules: { 37365 "margin-block-end": "0" 37366 } 37367 }, 37368 { 37369 selector: " > *", 37370 rules: { 37371 "margin-block-start": null, 37372 "margin-block-end": "0" 37373 } 37374 } 37375 ] 37376 }, 37377 constrained: { 37378 name: "constrained", 37379 slug: "constrained", 37380 className: "is-layout-constrained", 37381 baseStyles: [ 37382 { 37383 selector: " > .alignleft", 37384 rules: { 37385 float: "left", 37386 "margin-inline-start": "0", 37387 "margin-inline-end": "2em" 37388 } 37389 }, 37390 { 37391 selector: " > .alignright", 37392 rules: { 37393 float: "right", 37394 "margin-inline-start": "2em", 37395 "margin-inline-end": "0" 37396 } 37397 }, 37398 { 37399 selector: " > .aligncenter", 37400 rules: { 37401 "margin-left": "auto !important", 37402 "margin-right": "auto !important" 37403 } 37404 }, 37405 { 37406 selector: " > :where(:not(.alignleft):not(.alignright):not(.alignfull))", 37407 rules: { 37408 "max-width": "var(--wp--style--global--content-size)", 37409 "margin-left": "auto !important", 37410 "margin-right": "auto !important" 37411 } 37412 }, 37413 { 37414 selector: " > .alignwide", 37415 rules: { 37416 "max-width": "var(--wp--style--global--wide-size)" 37417 } 37418 } 37419 ], 37420 spacingStyles: [ 37421 { 37422 selector: " > :first-child", 37423 rules: { 37424 "margin-block-start": "0" 37425 } 37426 }, 37427 { 37428 selector: " > :last-child", 37429 rules: { 37430 "margin-block-end": "0" 37431 } 37432 }, 37433 { 37434 selector: " > *", 37435 rules: { 37436 "margin-block-start": null, 37437 "margin-block-end": "0" 37438 } 37439 } 37440 ] 37441 }, 37442 flex: { 37443 name: "flex", 37444 slug: "flex", 37445 className: "is-layout-flex", 37446 displayMode: "flex", 37447 baseStyles: [ 37448 { 37449 selector: "", 37450 rules: { 37451 "flex-wrap": "wrap", 37452 "align-items": "center" 37453 } 37454 }, 37455 { 37456 selector: " > :is(*, div)", 37457 // :is(*, div) instead of just * increases the specificity by 001. 37458 rules: { 37459 margin: "0" 37460 } 37461 } 37462 ], 37463 spacingStyles: [ 37464 { 37465 selector: "", 37466 rules: { 37467 gap: null 37468 } 37469 } 37470 ] 37471 }, 37472 grid: { 37473 name: "grid", 37474 slug: "grid", 37475 className: "is-layout-grid", 37476 displayMode: "grid", 37477 baseStyles: [ 37478 { 37479 selector: " > :is(*, div)", 37480 // :is(*, div) instead of just * increases the specificity by 001. 37481 rules: { 37482 margin: "0" 37483 } 37484 } 37485 ], 37486 spacingStyles: [ 37487 { 37488 selector: "", 37489 rules: { 37490 gap: null 37491 } 37492 } 37493 ] 37494 } 37495 }; 37496 37497 // packages/global-styles-engine/build-module/core/render.js 37498 var ELEMENT_CLASS_NAMES = { 37499 button: "wp-element-button", 37500 caption: "wp-element-caption" 37501 }; 37502 var BLOCK_SUPPORT_FEATURE_LEVEL_SELECTORS = { 37503 __experimentalBorder: "border", 37504 color: "color", 37505 dimensions: "dimensions", 37506 spacing: "spacing", 37507 typography: "typography" 37508 }; 37509 function getPresetsClasses(blockSelector = "*", blockPresets = {}) { 37510 return PRESET_METADATA.reduce( 37511 (declarations, { path, cssVarInfix, classes }) => { 37512 if (!classes) { 37513 return declarations; 37514 } 37515 const presetByOrigin = getValueFromObjectPath2( 37516 blockPresets, 37517 path, 37518 [] 37519 ); 37520 ["default", "theme", "custom"].forEach((origin) => { 37521 if (presetByOrigin[origin]) { 37522 presetByOrigin[origin].forEach( 37523 ({ slug }) => { 37524 classes.forEach( 37525 ({ 37526 classSuffix, 37527 propertyName 37528 }) => { 37529 const classSelectorToUse = `.has-$kebabCase4( 37530 slug 37531 )}-$classSuffix}`; 37532 const selectorToUse = blockSelector.split(",").map( 37533 (selector3) => `$selector3}$classSelectorToUse}` 37534 ).join(","); 37535 const value = `var(--wp--preset--$cssVarInfix}--$kebabCase4( 37536 slug 37537 )})`; 37538 declarations += `$selectorToUse}{$propertyName}: $value} !important;}`; 37539 } 37540 ); 37541 } 37542 ); 37543 } 37544 }); 37545 return declarations; 37546 }, 37547 "" 37548 ); 37549 } 37550 function concatFeatureVariationSelectorString(featureSelector, styleVariationSelector) { 37551 const featureSelectors = featureSelector.split(","); 37552 const combinedSelectors = []; 37553 featureSelectors.forEach((selector3) => { 37554 combinedSelectors.push( 37555 `$styleVariationSelector.trim()}$selector3.trim()}` 37556 ); 37557 }); 37558 return combinedSelectors.join(", "); 37559 } 37560 var getFeatureDeclarations = (selectors, styles) => { 37561 const declarations = {}; 37562 Object.entries(selectors).forEach(([feature, selector3]) => { 37563 if (feature === "root" || !styles?.[feature]) { 37564 return; 37565 } 37566 const isShorthand = typeof selector3 === "string"; 37567 if (!isShorthand && typeof selector3 === "object" && selector3 !== null) { 37568 Object.entries(selector3).forEach( 37569 ([subfeature, subfeatureSelector]) => { 37570 if (subfeature === "root" || !styles?.[feature][subfeature]) { 37571 return; 37572 } 37573 const subfeatureStyles = { 37574 [feature]: { 37575 [subfeature]: styles[feature][subfeature] 37576 } 37577 }; 37578 const newDeclarations = getStylesDeclarations(subfeatureStyles); 37579 declarations[subfeatureSelector] = [ 37580 ...declarations[subfeatureSelector] || [], 37581 ...newDeclarations 37582 ]; 37583 delete styles[feature][subfeature]; 37584 } 37585 ); 37586 } 37587 if (isShorthand || typeof selector3 === "object" && selector3 !== null && "root" in selector3) { 37588 const featureSelector = isShorthand ? selector3 : selector3.root; 37589 const featureStyles = { [feature]: styles[feature] }; 37590 const newDeclarations = getStylesDeclarations(featureStyles); 37591 declarations[featureSelector] = [ 37592 ...declarations[featureSelector] || [], 37593 ...newDeclarations 37594 ]; 37595 delete styles[feature]; 37596 } 37597 }); 37598 return declarations; 37599 }; 37600 function getStylesDeclarations(blockStyles = {}, selector3 = "", useRootPaddingAlign, tree = {}, disableRootPadding = false) { 37601 const isRoot = ROOT_BLOCK_SELECTOR === selector3; 37602 const output = Object.entries( 37603 import_blocks64.__EXPERIMENTAL_STYLE_PROPERTY 37604 ).reduce( 37605 (declarations, [key, { value, properties, useEngine, rootOnly }]) => { 37606 if (rootOnly && !isRoot) { 37607 return declarations; 37608 } 37609 const pathToValue = value; 37610 if (pathToValue[0] === "elements" || useEngine) { 37611 return declarations; 37612 } 37613 const styleValue = getValueFromObjectPath2( 37614 blockStyles, 37615 pathToValue 37616 ); 37617 if (key === "--wp--style--root--padding" && (typeof styleValue === "string" || !useRootPaddingAlign)) { 37618 return declarations; 37619 } 37620 if (properties && typeof styleValue !== "string") { 37621 Object.entries(properties).forEach((entry) => { 37622 const [name, prop] = entry; 37623 if (!getValueFromObjectPath2(styleValue, [prop], false)) { 37624 return; 37625 } 37626 const cssProperty = name.startsWith("--") ? name : kebabCase4(name); 37627 declarations.push( 37628 `$cssProperty}: ${(0, import_style_engine3.getCSSValueFromRawStyle)( 37629 getValueFromObjectPath2(styleValue, [prop]) 37630 )}` 37631 ); 37632 }); 37633 } else if (getValueFromObjectPath2(blockStyles, pathToValue, false)) { 37634 const cssProperty = key.startsWith("--") ? key : kebabCase4(key); 37635 declarations.push( 37636 `$cssProperty}: ${(0, import_style_engine3.getCSSValueFromRawStyle)( 37637 getValueFromObjectPath2(blockStyles, pathToValue) 37638 )}` 37639 ); 37640 } 37641 return declarations; 37642 }, 37643 [] 37644 ); 37645 if (!!blockStyles.background) { 37646 if (blockStyles.background?.backgroundImage) { 37647 blockStyles.background.backgroundImage = getResolvedValue( 37648 blockStyles.background.backgroundImage, 37649 tree 37650 ); 37651 } 37652 if (!isRoot && !!blockStyles.background?.backgroundImage?.id) { 37653 blockStyles = { 37654 ...blockStyles, 37655 background: { 37656 ...blockStyles.background, 37657 ...setBackgroundStyleDefaults(blockStyles.background) 37658 } 37659 }; 37660 } 37661 } 37662 const extraRules = (0, import_style_engine3.getCSSRules)(blockStyles); 37663 extraRules.forEach((rule) => { 37664 if (isRoot && (useRootPaddingAlign || disableRootPadding) && rule.key.startsWith("padding")) { 37665 return; 37666 } 37667 const cssProperty = rule.key.startsWith("--") ? rule.key : kebabCase4(rule.key); 37668 let ruleValue = getResolvedValue(rule.value, tree); 37669 if (cssProperty === "font-size") { 37670 ruleValue = getTypographyFontSizeValue( 37671 { name: "", slug: "", size: ruleValue }, 37672 tree?.settings 37673 ); 37674 } 37675 if (cssProperty === "aspect-ratio") { 37676 output.push("min-height: unset"); 37677 } 37678 output.push(`$cssProperty}: $ruleValue}`); 37679 }); 37680 return output; 37681 } 37682 function getLayoutStyles({ 37683 layoutDefinitions = LAYOUT_DEFINITIONS2, 37684 style, 37685 selector: selector3, 37686 hasBlockGapSupport, 37687 hasFallbackGapSupport, 37688 fallbackGapValue 37689 }) { 37690 let ruleset = ""; 37691 let gapValue = hasBlockGapSupport ? getGapCSSValue2(style?.spacing?.blockGap) : ""; 37692 if (hasFallbackGapSupport) { 37693 if (selector3 === ROOT_BLOCK_SELECTOR) { 37694 gapValue = !gapValue ? "0.5em" : gapValue; 37695 } else if (!hasBlockGapSupport && fallbackGapValue) { 37696 gapValue = fallbackGapValue; 37697 } 37698 } 37699 if (gapValue && layoutDefinitions) { 37700 Object.values(layoutDefinitions).forEach( 37701 ({ className, name, spacingStyles }) => { 37702 if (!hasBlockGapSupport && "flex" !== name && "grid" !== name) { 37703 return; 37704 } 37705 if (spacingStyles?.length) { 37706 spacingStyles.forEach((spacingStyle) => { 37707 const declarations = []; 37708 if (spacingStyle.rules) { 37709 Object.entries(spacingStyle.rules).forEach( 37710 ([cssProperty, cssValue]) => { 37711 declarations.push( 37712 `$cssProperty}: $cssValue ? cssValue : gapValue}` 37713 ); 37714 } 37715 ); 37716 } 37717 if (declarations.length) { 37718 let combinedSelector = ""; 37719 if (!hasBlockGapSupport) { 37720 combinedSelector = selector3 === ROOT_BLOCK_SELECTOR ? `:where(.$className}$spacingStyle?.selector || ""})` : `:where($selector3}.$className}$spacingStyle?.selector || ""})`; 37721 } else { 37722 combinedSelector = selector3 === ROOT_BLOCK_SELECTOR ? `:root :where(.$className})$spacingStyle?.selector || ""}` : `:root :where($selector3}-$className})$spacingStyle?.selector || ""}`; 37723 } 37724 ruleset += `$combinedSelector} { $declarations.join( 37725 "; " 37726 )}; }`; 37727 } 37728 }); 37729 } 37730 } 37731 ); 37732 if (selector3 === ROOT_BLOCK_SELECTOR && hasBlockGapSupport) { 37733 ruleset += `$ROOT_CSS_PROPERTIES_SELECTOR} { --wp--style--block-gap: $gapValue}; }`; 37734 } 37735 } 37736 if (selector3 === ROOT_BLOCK_SELECTOR && layoutDefinitions) { 37737 const validDisplayModes = ["block", "flex", "grid"]; 37738 Object.values(layoutDefinitions).forEach( 37739 ({ className, displayMode, baseStyles }) => { 37740 if (displayMode && validDisplayModes.includes(displayMode)) { 37741 ruleset += `$selector3} .$className} { display:$displayMode}; }`; 37742 } 37743 if (baseStyles?.length) { 37744 baseStyles.forEach((baseStyle) => { 37745 const declarations = []; 37746 if (baseStyle.rules) { 37747 Object.entries(baseStyle.rules).forEach( 37748 ([cssProperty, cssValue]) => { 37749 declarations.push( 37750 `$cssProperty}: $cssValue}` 37751 ); 37752 } 37753 ); 37754 } 37755 if (declarations.length) { 37756 const combinedSelector = `.$className}$baseStyle?.selector || ""}`; 37757 ruleset += `$combinedSelector} { $declarations.join( 37758 "; " 37759 )}; }`; 37760 } 37761 }); 37762 } 37763 } 37764 ); 37765 } 37766 return ruleset; 37767 } 37768 var STYLE_KEYS = [ 37769 "border", 37770 "color", 37771 "dimensions", 37772 "spacing", 37773 "typography", 37774 "filter", 37775 "outline", 37776 "shadow", 37777 "background" 37778 ]; 37779 function pickStyleKeys(treeToPickFrom) { 37780 if (!treeToPickFrom) { 37781 return {}; 37782 } 37783 const entries = Object.entries(treeToPickFrom); 37784 const pickedEntries = entries.filter( 37785 ([key]) => STYLE_KEYS.includes(key) 37786 ); 37787 const clonedEntries = pickedEntries.map(([key, style]) => [ 37788 key, 37789 JSON.parse(JSON.stringify(style)) 37790 ]); 37791 return Object.fromEntries(clonedEntries); 37792 } 37793 var getNodesWithStyles = (tree, blockSelectors) => { 37794 const nodes = []; 37795 if (!tree?.styles) { 37796 return nodes; 37797 } 37798 const styles = pickStyleKeys(tree.styles); 37799 if (styles) { 37800 nodes.push({ 37801 styles, 37802 selector: ROOT_BLOCK_SELECTOR, 37803 // Root selector (body) styles should not be wrapped in `:root where()` to keep 37804 // specificity at (0,0,1) and maintain backwards compatibility. 37805 skipSelectorWrapper: true 37806 }); 37807 } 37808 Object.entries(import_blocks64.__EXPERIMENTAL_ELEMENTS).forEach(([name, selector3]) => { 37809 if (tree.styles?.elements?.[name]) { 37810 nodes.push({ 37811 styles: tree.styles?.elements?.[name] ?? {}, 37812 selector: selector3, 37813 // Top level elements that don't use a class name should not receive the 37814 // `:root :where()` wrapper to maintain backwards compatibility. 37815 skipSelectorWrapper: !ELEMENT_CLASS_NAMES[name] 37816 }); 37817 } 37818 }); 37819 Object.entries(tree.styles?.blocks ?? {}).forEach( 37820 ([blockName, node]) => { 37821 const blockStyles = pickStyleKeys(node); 37822 const typedNode = node; 37823 if (typedNode?.variations) { 37824 const variations = {}; 37825 Object.entries(typedNode.variations).forEach( 37826 ([variationName, variation]) => { 37827 const typedVariation = variation; 37828 variations[variationName] = pickStyleKeys(typedVariation); 37829 if (typedVariation?.css) { 37830 variations[variationName].css = typedVariation.css; 37831 } 37832 const variationSelector = typeof blockSelectors !== "string" ? blockSelectors[blockName]?.styleVariationSelectors?.[variationName] : void 0; 37833 Object.entries( 37834 typedVariation?.elements ?? {} 37835 ).forEach(([element, elementStyles]) => { 37836 if (elementStyles && import_blocks64.__EXPERIMENTAL_ELEMENTS[element]) { 37837 nodes.push({ 37838 styles: elementStyles, 37839 selector: scopeSelector2( 37840 variationSelector, 37841 import_blocks64.__EXPERIMENTAL_ELEMENTS[element] 37842 ) 37843 }); 37844 } 37845 }); 37846 Object.entries(typedVariation?.blocks ?? {}).forEach( 37847 ([ 37848 variationBlockName, 37849 variationBlockStyles 37850 ]) => { 37851 const variationBlockSelector = typeof blockSelectors !== "string" ? scopeSelector2( 37852 variationSelector, 37853 blockSelectors[variationBlockName]?.selector 37854 ) : void 0; 37855 const variationDuotoneSelector = typeof blockSelectors !== "string" ? scopeSelector2( 37856 variationSelector, 37857 blockSelectors[variationBlockName]?.duotoneSelector 37858 ) : void 0; 37859 const variationFeatureSelectors = typeof blockSelectors !== "string" ? scopeFeatureSelectors( 37860 variationSelector, 37861 blockSelectors[variationBlockName]?.featureSelectors ?? {} 37862 ) : void 0; 37863 const variationBlockStyleNodes = pickStyleKeys(variationBlockStyles); 37864 if (variationBlockStyles?.css) { 37865 variationBlockStyleNodes.css = variationBlockStyles.css; 37866 } 37867 if (!variationBlockSelector || typeof blockSelectors === "string") { 37868 return; 37869 } 37870 nodes.push({ 37871 selector: variationBlockSelector, 37872 duotoneSelector: variationDuotoneSelector, 37873 featureSelectors: variationFeatureSelectors, 37874 fallbackGapValue: blockSelectors[variationBlockName]?.fallbackGapValue, 37875 hasLayoutSupport: blockSelectors[variationBlockName]?.hasLayoutSupport, 37876 styles: variationBlockStyleNodes 37877 }); 37878 Object.entries( 37879 variationBlockStyles.elements ?? {} 37880 ).forEach( 37881 ([ 37882 variationBlockElement, 37883 variationBlockElementStyles 37884 ]) => { 37885 if (variationBlockElementStyles && import_blocks64.__EXPERIMENTAL_ELEMENTS[variationBlockElement]) { 37886 nodes.push({ 37887 styles: variationBlockElementStyles, 37888 selector: scopeSelector2( 37889 variationBlockSelector, 37890 import_blocks64.__EXPERIMENTAL_ELEMENTS[variationBlockElement] 37891 ) 37892 }); 37893 } 37894 } 37895 ); 37896 } 37897 ); 37898 } 37899 ); 37900 blockStyles.variations = variations; 37901 } 37902 if (typeof blockSelectors !== "string" && blockSelectors?.[blockName]?.selector) { 37903 nodes.push({ 37904 duotoneSelector: blockSelectors[blockName].duotoneSelector, 37905 fallbackGapValue: blockSelectors[blockName].fallbackGapValue, 37906 hasLayoutSupport: blockSelectors[blockName].hasLayoutSupport, 37907 selector: blockSelectors[blockName].selector, 37908 styles: blockStyles, 37909 featureSelectors: blockSelectors[blockName].featureSelectors, 37910 styleVariationSelectors: blockSelectors[blockName].styleVariationSelectors 37911 }); 37912 } 37913 Object.entries(typedNode?.elements ?? {}).forEach( 37914 ([elementName, value]) => { 37915 if (typeof blockSelectors !== "string" && value && blockSelectors?.[blockName] && import_blocks64.__EXPERIMENTAL_ELEMENTS[elementName]) { 37916 nodes.push({ 37917 styles: value, 37918 selector: blockSelectors[blockName]?.selector.split(",").map((sel) => { 37919 const elementSelectors = import_blocks64.__EXPERIMENTAL_ELEMENTS[elementName].split(","); 37920 return elementSelectors.map( 37921 (elementSelector) => sel + " " + elementSelector 37922 ); 37923 }).join(",") 37924 }); 37925 } 37926 } 37927 ); 37928 } 37929 ); 37930 return nodes; 37931 }; 37932 var getNodesWithSettings = (tree, blockSelectors) => { 37933 const nodes = []; 37934 if (!tree?.settings) { 37935 return nodes; 37936 } 37937 const pickPresets = (treeToPickFrom) => { 37938 let presets2 = {}; 37939 PRESET_METADATA.forEach(({ path }) => { 37940 const value = getValueFromObjectPath2(treeToPickFrom, path, false); 37941 if (value !== false) { 37942 presets2 = setImmutably2(presets2, path, value); 37943 } 37944 }); 37945 return presets2; 37946 }; 37947 const presets = pickPresets(tree.settings); 37948 const custom = tree.settings?.custom; 37949 if (Object.keys(presets).length > 0 || custom) { 37950 nodes.push({ 37951 presets, 37952 custom, 37953 selector: ROOT_CSS_PROPERTIES_SELECTOR 37954 }); 37955 } 37956 Object.entries(tree.settings?.blocks ?? {}).forEach( 37957 ([blockName, node]) => { 37958 const blockCustom = node.custom; 37959 if (typeof blockSelectors === "string" || !blockSelectors[blockName]) { 37960 return; 37961 } 37962 const blockPresets = pickPresets(node); 37963 if (Object.keys(blockPresets).length > 0 || blockCustom) { 37964 nodes.push({ 37965 presets: blockPresets, 37966 custom: blockCustom, 37967 selector: blockSelectors[blockName]?.selector 37968 }); 37969 } 37970 } 37971 ); 37972 return nodes; 37973 }; 37974 var transformToStyles = (tree, blockSelectors, hasBlockGapSupport, hasFallbackGapSupport, disableLayoutStyles = false, disableRootPadding = false, styleOptions = {}) => { 37975 const options = { 37976 blockGap: true, 37977 blockStyles: true, 37978 layoutStyles: true, 37979 marginReset: true, 37980 presets: true, 37981 rootPadding: true, 37982 variationStyles: false, 37983 ...styleOptions 37984 }; 37985 const nodesWithStyles = getNodesWithStyles(tree, blockSelectors); 37986 const nodesWithSettings = getNodesWithSettings(tree, blockSelectors); 37987 const useRootPaddingAlign = tree?.settings?.useRootPaddingAwareAlignments; 37988 const { contentSize, wideSize } = tree?.settings?.layout || {}; 37989 const hasBodyStyles = options.marginReset || options.rootPadding || options.layoutStyles; 37990 let ruleset = ""; 37991 if (options.presets && (contentSize || wideSize)) { 37992 ruleset += `$ROOT_CSS_PROPERTIES_SELECTOR} {`; 37993 ruleset = contentSize ? ruleset + ` --wp--style--global--content-size: $contentSize};` : ruleset; 37994 ruleset = wideSize ? ruleset + ` --wp--style--global--wide-size: $wideSize};` : ruleset; 37995 ruleset += "}"; 37996 } 37997 if (hasBodyStyles) { 37998 ruleset += ":where(body) {margin: 0;"; 37999 if (options.rootPadding && useRootPaddingAlign) { 38000 ruleset += `padding-right: 0; padding-left: 0; padding-top: var(--wp--style--root--padding-top); padding-bottom: var(--wp--style--root--padding-bottom) } 38001 .has-global-padding { padding-right: var(--wp--style--root--padding-right); padding-left: var(--wp--style--root--padding-left); } 38002 .has-global-padding > .alignfull { margin-right: calc(var(--wp--style--root--padding-right) * -1); margin-left: calc(var(--wp--style--root--padding-left) * -1); } 38003 .has-global-padding :where(:not(.alignfull.is-layout-flow) > .has-global-padding:not(.wp-block-block, .alignfull)) { padding-right: 0; padding-left: 0; } 38004 .has-global-padding :where(:not(.alignfull.is-layout-flow) > .has-global-padding:not(.wp-block-block, .alignfull)) > .alignfull { margin-left: 0; margin-right: 0; 38005 `; 38006 } 38007 ruleset += "}"; 38008 } 38009 if (options.blockStyles) { 38010 nodesWithStyles.forEach( 38011 ({ 38012 selector: selector3, 38013 duotoneSelector, 38014 styles, 38015 fallbackGapValue, 38016 hasLayoutSupport: hasLayoutSupport2, 38017 featureSelectors, 38018 styleVariationSelectors, 38019 skipSelectorWrapper 38020 }) => { 38021 if (featureSelectors) { 38022 const featureDeclarations = getFeatureDeclarations( 38023 featureSelectors, 38024 styles 38025 ); 38026 Object.entries(featureDeclarations).forEach( 38027 ([cssSelector, declarations]) => { 38028 if (declarations.length) { 38029 const rules = declarations.join(";"); 38030 ruleset += `:root :where($cssSelector}){$rules};}`; 38031 } 38032 } 38033 ); 38034 } 38035 if (duotoneSelector) { 38036 const duotoneStyles = {}; 38037 if (styles?.filter) { 38038 duotoneStyles.filter = styles.filter; 38039 delete styles.filter; 38040 } 38041 const duotoneDeclarations = getStylesDeclarations(duotoneStyles); 38042 if (duotoneDeclarations.length) { 38043 ruleset += `$duotoneSelector}{$duotoneDeclarations.join( 38044 ";" 38045 )};}`; 38046 } 38047 } 38048 if (!disableLayoutStyles && (ROOT_BLOCK_SELECTOR === selector3 || hasLayoutSupport2)) { 38049 ruleset += getLayoutStyles({ 38050 style: styles, 38051 selector: selector3, 38052 hasBlockGapSupport, 38053 hasFallbackGapSupport, 38054 fallbackGapValue 38055 }); 38056 } 38057 const styleDeclarations = getStylesDeclarations( 38058 styles, 38059 selector3, 38060 useRootPaddingAlign, 38061 tree, 38062 disableRootPadding 38063 ); 38064 if (styleDeclarations?.length) { 38065 const generalSelector = skipSelectorWrapper ? selector3 : `:root :where($selector3})`; 38066 ruleset += `$generalSelector}{$styleDeclarations.join( 38067 ";" 38068 )};}`; 38069 } 38070 if (styles?.css) { 38071 ruleset += processCSSNesting( 38072 styles.css, 38073 `:root :where($selector3})` 38074 ); 38075 } 38076 if (options.variationStyles && styleVariationSelectors) { 38077 Object.entries(styleVariationSelectors).forEach( 38078 ([styleVariationName, styleVariationSelector]) => { 38079 const styleVariations = styles?.variations?.[styleVariationName]; 38080 if (styleVariations) { 38081 if (featureSelectors) { 38082 const featureDeclarations = getFeatureDeclarations( 38083 featureSelectors, 38084 styleVariations 38085 ); 38086 Object.entries( 38087 featureDeclarations 38088 ).forEach( 38089 ([baseSelector, declarations]) => { 38090 if (declarations.length) { 38091 const cssSelector = concatFeatureVariationSelectorString( 38092 baseSelector, 38093 styleVariationSelector 38094 ); 38095 const rules = declarations.join(";"); 38096 ruleset += `:root :where($cssSelector}){$rules};}`; 38097 } 38098 } 38099 ); 38100 } 38101 const styleVariationDeclarations = getStylesDeclarations( 38102 styleVariations, 38103 styleVariationSelector, 38104 useRootPaddingAlign, 38105 tree 38106 ); 38107 if (styleVariationDeclarations.length) { 38108 ruleset += `:root :where($styleVariationSelector}){$styleVariationDeclarations.join( 38109 ";" 38110 )};}`; 38111 } 38112 if (styleVariations?.css) { 38113 ruleset += processCSSNesting( 38114 styleVariations.css, 38115 `:root :where($styleVariationSelector})` 38116 ); 38117 } 38118 } 38119 } 38120 ); 38121 } 38122 const pseudoSelectorStyles = Object.entries(styles).filter( 38123 ([key]) => key.startsWith(":") 38124 ); 38125 if (pseudoSelectorStyles?.length) { 38126 pseudoSelectorStyles.forEach( 38127 ([pseudoKey, pseudoStyle]) => { 38128 const pseudoDeclarations = getStylesDeclarations(pseudoStyle); 38129 if (!pseudoDeclarations?.length) { 38130 return; 38131 } 38132 const _selector = selector3.split(",").map((sel) => sel + pseudoKey).join(","); 38133 const pseudoRule = `:root :where($_selector}){$pseudoDeclarations.join( 38134 ";" 38135 )};}`; 38136 ruleset += pseudoRule; 38137 } 38138 ); 38139 } 38140 } 38141 ); 38142 } 38143 if (options.layoutStyles) { 38144 ruleset = ruleset + ".wp-site-blocks > .alignleft { float: left; margin-right: 2em; }"; 38145 ruleset = ruleset + ".wp-site-blocks > .alignright { float: right; margin-left: 2em; }"; 38146 ruleset = ruleset + ".wp-site-blocks > .aligncenter { justify-content: center; margin-left: auto; margin-right: auto; }"; 38147 } 38148 if (options.blockGap && hasBlockGapSupport) { 38149 const gapValue = getGapCSSValue2(tree?.styles?.spacing?.blockGap) || "0.5em"; 38150 ruleset = ruleset + `:root :where(.wp-site-blocks) > * { margin-block-start: $gapValue}; margin-block-end: 0; }`; 38151 ruleset = ruleset + ":root :where(.wp-site-blocks) > :first-child { margin-block-start: 0; }"; 38152 ruleset = ruleset + ":root :where(.wp-site-blocks) > :last-child { margin-block-end: 0; }"; 38153 } 38154 if (options.presets) { 38155 nodesWithSettings.forEach(({ selector: selector3, presets }) => { 38156 if (ROOT_BLOCK_SELECTOR === selector3 || ROOT_CSS_PROPERTIES_SELECTOR === selector3) { 38157 selector3 = ""; 38158 } 38159 const classes = getPresetsClasses(selector3, presets); 38160 if (classes.length > 0) { 38161 ruleset += classes; 38162 } 38163 }); 38164 } 38165 return ruleset; 38166 }; 38167 var getSelectorsConfig = (blockType, rootSelector) => { 38168 if (blockType?.selectors && Object.keys(blockType.selectors).length > 0) { 38169 return blockType.selectors; 38170 } 38171 const config2 = { 38172 root: rootSelector 38173 }; 38174 Object.entries(BLOCK_SUPPORT_FEATURE_LEVEL_SELECTORS).forEach( 38175 ([featureKey, featureName]) => { 38176 const featureSelector = getBlockSelector(blockType, featureKey); 38177 if (featureSelector) { 38178 config2[featureName] = featureSelector; 38179 } 38180 } 38181 ); 38182 return config2; 38183 }; 38184 var getBlockSelectors = (blockTypes, variationInstanceId) => { 38185 const { getBlockStyles: getBlockStyles2 } = (0, import_data109.select)(import_blocks64.store); 38186 const result = {}; 38187 blockTypes.forEach((blockType) => { 38188 const name = blockType.name; 38189 const selector3 = getBlockSelector(blockType); 38190 if (!selector3) { 38191 return; 38192 } 38193 let duotoneSelector = getBlockSelector(blockType, "filter.duotone"); 38194 if (!duotoneSelector) { 38195 const rootSelector = getBlockSelector(blockType); 38196 const duotoneSupport = (0, import_blocks64.getBlockSupport)( 38197 blockType, 38198 "color.__experimentalDuotone", 38199 false 38200 ); 38201 duotoneSelector = duotoneSupport && rootSelector && scopeSelector2(rootSelector, duotoneSupport); 38202 } 38203 const hasLayoutSupport2 = !!blockType?.supports?.layout || !!blockType?.supports?.__experimentalLayout; 38204 const fallbackGapValue = ( 38205 // @ts-expect-error 38206 blockType?.supports?.spacing?.blockGap?.__experimentalDefault 38207 ); 38208 const blockStyleVariations = getBlockStyles2(name); 38209 const styleVariationSelectors = {}; 38210 blockStyleVariations?.forEach((variation) => { 38211 const variationSuffix = variationInstanceId ? `-$variationInstanceId}` : ""; 38212 const variationName = `$variation.name}$variationSuffix}`; 38213 const styleVariationSelector = getBlockStyleVariationSelector( 38214 variationName, 38215 selector3 38216 ); 38217 styleVariationSelectors[variationName] = styleVariationSelector; 38218 }); 38219 const featureSelectors = getSelectorsConfig(blockType, selector3); 38220 result[name] = { 38221 duotoneSelector: duotoneSelector ?? void 0, 38222 fallbackGapValue, 38223 featureSelectors: Object.keys(featureSelectors).length ? featureSelectors : void 0, 38224 hasLayoutSupport: hasLayoutSupport2, 38225 name, 38226 selector: selector3, 38227 styleVariationSelectors: blockStyleVariations?.length ? styleVariationSelectors : void 0 38228 }; 38229 }); 38230 return result; 38231 }; 38232 function processCSSNesting(css, blockSelector) { 38233 let processedCSS = ""; 38234 if (!css || css.trim() === "") { 38235 return processedCSS; 38236 } 38237 const parts = css.split("&"); 38238 parts.forEach((part) => { 38239 if (!part || part.trim() === "") { 38240 return; 38241 } 38242 const isRootCss = !part.includes("{"); 38243 if (isRootCss) { 38244 processedCSS += `:root :where($blockSelector}){$part.trim()}}`; 38245 } else { 38246 const splitPart = part.replace("}", "").split("{"); 38247 if (splitPart.length !== 2) { 38248 return; 38249 } 38250 const [nestedSelector, cssValue] = splitPart; 38251 const matches = nestedSelector.match(/([>+~\s]*::[a-zA-Z-]+)/); 38252 const pseudoPart = matches ? matches[1] : ""; 38253 const withoutPseudoElement = matches ? nestedSelector.replace(pseudoPart, "").trim() : nestedSelector.trim(); 38254 let combinedSelector; 38255 if (withoutPseudoElement === "") { 38256 combinedSelector = blockSelector; 38257 } else { 38258 combinedSelector = nestedSelector.startsWith(" ") ? scopeSelector2(blockSelector, withoutPseudoElement) : appendToSelector(blockSelector, withoutPseudoElement); 38259 } 38260 processedCSS += `:root :where($combinedSelector})$pseudoPart}{$cssValue.trim()}}`; 38261 } 38262 }); 38263 return processedCSS; 38264 } 38265 38266 // packages/block-editor/build-module/hooks/block-style-variation.js 38267 var import_jsx_runtime239 = __toESM(require_jsx_runtime()); 38268 var VARIATION_PREFIX = "is-style-"; 38269 function getVariationMatches(className) { 38270 if (!className) { 38271 return []; 38272 } 38273 return className.split(/\s+/).reduce((matches, name) => { 38274 if (name.startsWith(VARIATION_PREFIX)) { 38275 const match2 = name.slice(VARIATION_PREFIX.length); 38276 if (match2 !== "default") { 38277 matches.push(match2); 38278 } 38279 } 38280 return matches; 38281 }, []); 38282 } 38283 function getVariationNameFromClass(className, registeredStyles = []) { 38284 const matches = getVariationMatches(className); 38285 if (!matches) { 38286 return null; 38287 } 38288 for (const variation of matches) { 38289 if (registeredStyles.some((style) => style.name === variation)) { 38290 return variation; 38291 } 38292 } 38293 return null; 38294 } 38295 function OverrideStyles({ override }) { 38296 usePrivateStyleOverride(override); 38297 } 38298 function __unstableBlockStyleVariationOverridesWithConfig({ config: config2 }) { 38299 const { getBlockStyles: getBlockStyles2, overrides } = (0, import_data110.useSelect)( 38300 (select3) => ({ 38301 getBlockStyles: select3(import_blocks65.store).getBlockStyles, 38302 overrides: unlock(select3(store)).getStyleOverrides() 38303 }), 38304 [] 38305 ); 38306 const { getBlockName: getBlockName2 } = (0, import_data110.useSelect)(store); 38307 const overridesWithConfig = (0, import_element114.useMemo)(() => { 38308 if (!overrides?.length) { 38309 return; 38310 } 38311 const newOverrides = []; 38312 const overriddenClientIds = []; 38313 for (const [, override] of overrides) { 38314 if (override?.variation && override?.clientId && /* 38315 * Because this component overwrites existing style overrides, 38316 * filter out any overrides that are already present in the store. 38317 */ 38318 !overriddenClientIds.includes(override.clientId)) { 38319 const blockName = getBlockName2(override.clientId); 38320 const configStyles = config2?.styles?.blocks?.[blockName]?.variations?.[override.variation]; 38321 if (configStyles) { 38322 const variationConfig = { 38323 settings: config2?.settings, 38324 // The variation style data is all that is needed to generate 38325 // the styles for the current application to a block. The variation 38326 // name is updated to match the instance specific class name. 38327 styles: { 38328 blocks: { 38329 [blockName]: { 38330 variations: { 38331 [`$override.variation}-$override.clientId}`]: configStyles 38332 } 38333 } 38334 } 38335 } 38336 }; 38337 const blockSelectors = getBlockSelectors( 38338 (0, import_blocks65.getBlockTypes)(), 38339 override.clientId 38340 ); 38341 const hasBlockGapSupport = false; 38342 const hasFallbackGapSupport = true; 38343 const disableLayoutStyles = true; 38344 const disableRootPadding = true; 38345 const variationStyles = transformToStyles( 38346 variationConfig, 38347 blockSelectors, 38348 hasBlockGapSupport, 38349 hasFallbackGapSupport, 38350 disableLayoutStyles, 38351 disableRootPadding, 38352 { 38353 blockGap: false, 38354 blockStyles: true, 38355 layoutStyles: false, 38356 marginReset: false, 38357 presets: false, 38358 rootPadding: false, 38359 variationStyles: true 38360 } 38361 ); 38362 newOverrides.push({ 38363 id: `$override.variation}-$override.clientId}`, 38364 css: variationStyles, 38365 __unstableType: "variation", 38366 variation: override.variation, 38367 // The clientId will be stored with the override and used to ensure 38368 // the order of overrides matches the order of blocks so that the 38369 // correct CSS cascade is maintained. 38370 clientId: override.clientId 38371 }); 38372 overriddenClientIds.push(override.clientId); 38373 } 38374 } 38375 } 38376 return newOverrides; 38377 }, [config2, overrides, getBlockStyles2, getBlockName2]); 38378 if (!overridesWithConfig || !overridesWithConfig.length) { 38379 return; 38380 } 38381 return /* @__PURE__ */ (0, import_jsx_runtime239.jsx)(import_jsx_runtime239.Fragment, { children: overridesWithConfig.map((override) => /* @__PURE__ */ (0, import_jsx_runtime239.jsx)(OverrideStyles, { override }, override.id)) }); 38382 } 38383 function getVariationStylesWithRefValues(globalStyles, name, variation) { 38384 if (!globalStyles?.styles?.blocks?.[name]?.variations?.[variation]) { 38385 return; 38386 } 38387 const replaceRefs = (variationStyles) => { 38388 Object.keys(variationStyles).forEach((key) => { 38389 const value = variationStyles[key]; 38390 if (typeof value === "object" && value !== null) { 38391 if (value.ref !== void 0) { 38392 if (typeof value.ref !== "string" || value.ref.trim() === "") { 38393 delete variationStyles[key]; 38394 } else { 38395 const refValue = getValueFromObjectPath( 38396 globalStyles, 38397 value.ref 38398 ); 38399 if (refValue) { 38400 variationStyles[key] = refValue; 38401 } else { 38402 delete variationStyles[key]; 38403 } 38404 } 38405 } else { 38406 replaceRefs(value); 38407 if (Object.keys(value).length === 0) { 38408 delete variationStyles[key]; 38409 } 38410 } 38411 } 38412 }); 38413 }; 38414 const styles = JSON.parse( 38415 JSON.stringify( 38416 globalStyles.styles.blocks[name].variations[variation] 38417 ) 38418 ); 38419 replaceRefs(styles); 38420 return styles; 38421 } 38422 function useBlockStyleVariation(name, variation, clientId) { 38423 const { globalSettings, globalStyles } = (0, import_data110.useSelect)((select3) => { 38424 const settings2 = select3(store).getSettings(); 38425 return { 38426 globalSettings: settings2.__experimentalFeatures, 38427 globalStyles: settings2[globalStylesDataKey] 38428 }; 38429 }, []); 38430 return (0, import_element114.useMemo)(() => { 38431 const variationStyles = getVariationStylesWithRefValues( 38432 { 38433 settings: globalSettings, 38434 styles: globalStyles 38435 }, 38436 name, 38437 variation 38438 ); 38439 return { 38440 settings: globalSettings, 38441 // The variation style data is all that is needed to generate 38442 // the styles for the current application to a block. The variation 38443 // name is updated to match the instance specific class name. 38444 styles: { 38445 blocks: { 38446 [name]: { 38447 variations: { 38448 [`$variation}-$clientId}`]: variationStyles 38449 } 38450 } 38451 } 38452 } 38453 }; 38454 }, [globalSettings, globalStyles, variation, clientId, name]); 38455 } 38456 function useBlockProps3({ name, className, clientId }) { 38457 const { getBlockStyles: getBlockStyles2 } = (0, import_data110.useSelect)(import_blocks65.store); 38458 const registeredStyles = getBlockStyles2(name); 38459 const variation = getVariationNameFromClass(className, registeredStyles); 38460 const variationClass = `$VARIATION_PREFIX}$variation}-$clientId}`; 38461 const { settings: settings2, styles } = useBlockStyleVariation( 38462 name, 38463 variation, 38464 clientId 38465 ); 38466 const variationStyles = (0, import_element114.useMemo)(() => { 38467 if (!variation) { 38468 return; 38469 } 38470 const variationConfig = { settings: settings2, styles }; 38471 const blockSelectors = getBlockSelectors((0, import_blocks65.getBlockTypes)(), clientId); 38472 const hasBlockGapSupport = false; 38473 const hasFallbackGapSupport = true; 38474 const disableLayoutStyles = true; 38475 const disableRootPadding = true; 38476 return transformToStyles( 38477 variationConfig, 38478 blockSelectors, 38479 hasBlockGapSupport, 38480 hasFallbackGapSupport, 38481 disableLayoutStyles, 38482 disableRootPadding, 38483 { 38484 blockGap: false, 38485 blockStyles: true, 38486 layoutStyles: false, 38487 marginReset: false, 38488 presets: false, 38489 rootPadding: false, 38490 variationStyles: true 38491 } 38492 ); 38493 }, [variation, settings2, styles, clientId]); 38494 usePrivateStyleOverride({ 38495 id: `variation-$clientId}`, 38496 css: variationStyles, 38497 __unstableType: "variation", 38498 variation, 38499 // The clientId will be stored with the override and used to ensure 38500 // the order of overrides matches the order of blocks so that the 38501 // correct CSS cascade is maintained. 38502 clientId 38503 }); 38504 return variation ? { className: variationClass } : {}; 38505 } 38506 var block_style_variation_default = { 38507 hasSupport: () => true, 38508 attributeKeys: ["className"], 38509 isMatch: ({ className }) => getVariationMatches(className).length > 0, 38510 useBlockProps: useBlockProps3 38511 }; 38512 38513 // packages/block-editor/build-module/components/block-toolbar/switch-section-style.js 38514 var import_jsx_runtime240 = __toESM(require_jsx_runtime()); 38515 var styleIcon = /* @__PURE__ */ (0, import_jsx_runtime240.jsxs)( 38516 import_components102.SVG, 38517 { 38518 viewBox: "0 0 24 24", 38519 xmlns: "http://www.w3.org/2000/svg", 38520 width: "24", 38521 height: "24", 38522 "aria-hidden": "true", 38523 focusable: "false", 38524 children: [ 38525 /* @__PURE__ */ (0, import_jsx_runtime240.jsx)(import_components102.Path, { d: "M17.2 10.9c-.5-1-1.2-2.1-2.1-3.2-.6-.9-1.3-1.7-2.1-2.6L12 4l-1 1.1c-.6.9-1.3 1.7-2 2.6-.8 1.2-1.5 2.3-2 3.2-.6 1.2-1 2.2-1 3 0 3.4 2.7 6.1 6.1 6.1s6.1-2.7 6.1-6.1c0-.8-.3-1.8-1-3z" }), 38526 /* @__PURE__ */ (0, import_jsx_runtime240.jsx)( 38527 import_components102.Path, 38528 { 38529 stroke: "currentColor", 38530 strokeWidth: "1.5", 38531 d: "M17.2 10.9c-.5-1-1.2-2.1-2.1-3.2-.6-.9-1.3-1.7-2.1-2.6L12 4l-1 1.1c-.6.9-1.3 1.7-2 2.6-.8 1.2-1.5 2.3-2 3.2-.6 1.2-1 2.2-1 3 0 3.4 2.7 6.1 6.1 6.1s6.1-2.7 6.1-6.1c0-.8-.3-1.8-1-3z" 38532 } 38533 ) 38534 ] 38535 } 38536 ); 38537 function SwitchSectionStyle({ clientId }) { 38538 const { stylesToRender, activeStyle, className } = useStylesForBlocks({ 38539 clientId 38540 }); 38541 const { updateBlockAttributes: updateBlockAttributes2 } = (0, import_data111.useDispatch)(store); 38542 const { globalSettings, globalStyles, blockName } = (0, import_data111.useSelect)( 38543 (select3) => { 38544 const settings2 = select3(store).getSettings(); 38545 return { 38546 globalSettings: settings2.__experimentalFeatures, 38547 globalStyles: settings2[globalStylesDataKey], 38548 blockName: select3(store).getBlockName(clientId) 38549 }; 38550 }, 38551 [clientId] 38552 ); 38553 const activeStyleBackground = activeStyle?.name ? getVariationStylesWithRefValues( 38554 { 38555 settings: globalSettings, 38556 styles: globalStyles 38557 }, 38558 blockName, 38559 activeStyle.name 38560 )?.color?.background : void 0; 38561 if (!stylesToRender || stylesToRender.length === 0) { 38562 return null; 38563 } 38564 const handleStyleSwitch = () => { 38565 const currentIndex = stylesToRender.findIndex( 38566 (style) => style.name === activeStyle.name 38567 ); 38568 const nextIndex = (currentIndex + 1) % stylesToRender.length; 38569 const nextStyle = stylesToRender[nextIndex]; 38570 const styleClassName = replaceActiveStyle( 38571 className, 38572 activeStyle, 38573 nextStyle 38574 ); 38575 updateBlockAttributes2(clientId, { 38576 className: styleClassName 38577 }); 38578 }; 38579 return /* @__PURE__ */ (0, import_jsx_runtime240.jsx)(import_components102.ToolbarGroup, { children: /* @__PURE__ */ (0, import_jsx_runtime240.jsx)( 38580 import_components102.ToolbarButton, 38581 { 38582 onClick: handleStyleSwitch, 38583 label: (0, import_i18n91.__)("Shuffle styles"), 38584 children: /* @__PURE__ */ (0, import_jsx_runtime240.jsx)( 38585 import_components102.Icon, 38586 { 38587 icon: styleIcon, 38588 style: { 38589 fill: activeStyleBackground || "transparent" 38590 } 38591 } 38592 ) 38593 } 38594 ) }); 38595 } 38596 var switch_section_style_default = SwitchSectionStyle; 38597 38598 // packages/block-editor/build-module/components/block-toolbar/block-toolbar-icon.js 38599 var import_components111 = __toESM(require_components()); 38600 var import_i18n98 = __toESM(require_i18n()); 38601 var import_data115 = __toESM(require_data()); 38602 var import_blocks71 = __toESM(require_blocks()); 38603 var import_preferences2 = __toESM(require_preferences()); 38604 38605 // packages/block-editor/build-module/components/block-switcher/index.js 38606 var import_i18n96 = __toESM(require_i18n()); 38607 var import_components109 = __toESM(require_components()); 38608 var import_blocks70 = __toESM(require_blocks()); 38609 var import_data113 = __toESM(require_data()); 38610 38611 // packages/block-editor/build-module/components/block-switcher/block-transformations-menu.js 38612 var import_i18n93 = __toESM(require_i18n()); 38613 var import_components105 = __toESM(require_components()); 38614 var import_blocks67 = __toESM(require_blocks()); 38615 var import_element116 = __toESM(require_element()); 38616 38617 // packages/block-editor/build-module/components/block-switcher/preview-block-popover.js 38618 var import_i18n92 = __toESM(require_i18n()); 38619 var import_components103 = __toESM(require_components()); 38620 var import_compose63 = __toESM(require_compose()); 38621 var import_jsx_runtime241 = __toESM(require_jsx_runtime()); 38622 function PreviewBlockPopover({ blocks: blocks2 }) { 38623 const isMobile = (0, import_compose63.useViewportMatch)("medium", "<"); 38624 if (isMobile) { 38625 return null; 38626 } 38627 return /* @__PURE__ */ (0, import_jsx_runtime241.jsx)("div", { className: "block-editor-block-switcher__popover-preview-container", children: /* @__PURE__ */ (0, import_jsx_runtime241.jsx)( 38628 import_components103.Popover, 38629 { 38630 className: "block-editor-block-switcher__popover-preview", 38631 placement: "right-start", 38632 focusOnMount: false, 38633 offset: 16, 38634 children: /* @__PURE__ */ (0, import_jsx_runtime241.jsxs)("div", { className: "block-editor-block-switcher__preview", children: [ 38635 /* @__PURE__ */ (0, import_jsx_runtime241.jsx)("div", { className: "block-editor-block-switcher__preview-title", children: (0, import_i18n92.__)("Preview") }), 38636 /* @__PURE__ */ (0, import_jsx_runtime241.jsx)(block_preview_default, { viewportWidth: 601, blocks: blocks2 }) 38637 ] }) 38638 } 38639 ) }); 38640 } 38641 38642 // packages/block-editor/build-module/components/block-switcher/block-variation-transformations.js 38643 var import_components104 = __toESM(require_components()); 38644 var import_blocks66 = __toESM(require_blocks()); 38645 var import_data112 = __toESM(require_data()); 38646 var import_element115 = __toESM(require_element()); 38647 var import_jsx_runtime242 = __toESM(require_jsx_runtime()); 38648 var EMPTY_OBJECT2 = {}; 38649 function useBlockVariationTransforms({ clientIds, blocks: blocks2 }) { 38650 const { activeBlockVariation, blockVariationTransformations } = (0, import_data112.useSelect)( 38651 (select3) => { 38652 const { getBlockAttributes: getBlockAttributes3, canRemoveBlocks: canRemoveBlocks2 } = select3(store); 38653 const { getActiveBlockVariation, getBlockVariations: getBlockVariations2 } = select3(import_blocks66.store); 38654 const canRemove = canRemoveBlocks2(clientIds); 38655 if (blocks2.length !== 1 || !canRemove) { 38656 return EMPTY_OBJECT2; 38657 } 38658 const [firstBlock] = blocks2; 38659 return { 38660 blockVariationTransformations: getBlockVariations2( 38661 firstBlock.name, 38662 "transform" 38663 ), 38664 activeBlockVariation: getActiveBlockVariation( 38665 firstBlock.name, 38666 getBlockAttributes3(firstBlock.clientId) 38667 ) 38668 }; 38669 }, 38670 [clientIds, blocks2] 38671 ); 38672 const transformations = (0, import_element115.useMemo)(() => { 38673 return blockVariationTransformations?.filter( 38674 ({ name }) => name !== activeBlockVariation?.name 38675 ); 38676 }, [blockVariationTransformations, activeBlockVariation]); 38677 return transformations; 38678 } 38679 var BlockVariationTransformations = ({ 38680 transformations, 38681 onSelect, 38682 blocks: blocks2 38683 }) => { 38684 const [hoveredTransformItemName, setHoveredTransformItemName] = (0, import_element115.useState)(); 38685 return /* @__PURE__ */ (0, import_jsx_runtime242.jsxs)(import_jsx_runtime242.Fragment, { children: [ 38686 hoveredTransformItemName && /* @__PURE__ */ (0, import_jsx_runtime242.jsx)( 38687 PreviewBlockPopover, 38688 { 38689 blocks: (0, import_blocks66.cloneBlock)( 38690 blocks2[0], 38691 transformations.find( 38692 ({ name }) => name === hoveredTransformItemName 38693 ).attributes 38694 ) 38695 } 38696 ), 38697 transformations?.map((item) => /* @__PURE__ */ (0, import_jsx_runtime242.jsx)( 38698 BlockVariationTransformationItem, 38699 { 38700 item, 38701 onSelect, 38702 setHoveredTransformItemName 38703 }, 38704 item.name 38705 )) 38706 ] }); 38707 }; 38708 function BlockVariationTransformationItem({ 38709 item, 38710 onSelect, 38711 setHoveredTransformItemName 38712 }) { 38713 const { name, icon, title } = item; 38714 return /* @__PURE__ */ (0, import_jsx_runtime242.jsxs)( 38715 import_components104.MenuItem, 38716 { 38717 className: (0, import_blocks66.getBlockMenuDefaultClassName)(name), 38718 onClick: (event) => { 38719 event.preventDefault(); 38720 onSelect(name); 38721 }, 38722 onMouseLeave: () => setHoveredTransformItemName(null), 38723 onMouseEnter: () => setHoveredTransformItemName(name), 38724 children: [ 38725 /* @__PURE__ */ (0, import_jsx_runtime242.jsx)(block_icon_default, { icon, showColors: true }), 38726 title 38727 ] 38728 } 38729 ); 38730 } 38731 var block_variation_transformations_default = BlockVariationTransformations; 38732 38733 // packages/block-editor/build-module/components/block-switcher/block-transformations-menu.js 38734 var import_jsx_runtime243 = __toESM(require_jsx_runtime()); 38735 function useGroupedTransforms(possibleBlockTransformations) { 38736 const priorityContentTransformationBlocks = { 38737 "core/paragraph": 1, 38738 "core/heading": 2, 38739 "core/list": 3, 38740 "core/quote": 4 38741 }; 38742 const transformations = (0, import_element116.useMemo)(() => { 38743 const priorityTextTransformsNames = Object.keys( 38744 priorityContentTransformationBlocks 38745 ); 38746 const groupedPossibleTransforms = possibleBlockTransformations.reduce( 38747 (accumulator, item) => { 38748 const { name } = item; 38749 if (priorityTextTransformsNames.includes(name)) { 38750 accumulator.priorityTextTransformations.push(item); 38751 } else { 38752 accumulator.restTransformations.push(item); 38753 } 38754 return accumulator; 38755 }, 38756 { priorityTextTransformations: [], restTransformations: [] } 38757 ); 38758 if (groupedPossibleTransforms.priorityTextTransformations.length === 1 && groupedPossibleTransforms.priorityTextTransformations[0].name === "core/quote") { 38759 const singleQuote = groupedPossibleTransforms.priorityTextTransformations.pop(); 38760 groupedPossibleTransforms.restTransformations.push(singleQuote); 38761 } 38762 return groupedPossibleTransforms; 38763 }, [possibleBlockTransformations]); 38764 transformations.priorityTextTransformations.sort( 38765 ({ name: currentName }, { name: nextName }) => { 38766 return priorityContentTransformationBlocks[currentName] < priorityContentTransformationBlocks[nextName] ? -1 : 1; 38767 } 38768 ); 38769 return transformations; 38770 } 38771 var BlockTransformationsMenu = ({ 38772 className, 38773 possibleBlockTransformations, 38774 possibleBlockVariationTransformations, 38775 onSelect, 38776 onSelectVariation, 38777 blocks: blocks2 38778 }) => { 38779 const [hoveredTransformItemName, setHoveredTransformItemName] = (0, import_element116.useState)(); 38780 const { priorityTextTransformations, restTransformations } = useGroupedTransforms(possibleBlockTransformations); 38781 const hasBothContentTransformations = priorityTextTransformations.length && restTransformations.length; 38782 const restTransformItems = !!restTransformations.length && /* @__PURE__ */ (0, import_jsx_runtime243.jsx)( 38783 RestTransformationItems, 38784 { 38785 restTransformations, 38786 onSelect, 38787 setHoveredTransformItemName 38788 } 38789 ); 38790 return /* @__PURE__ */ (0, import_jsx_runtime243.jsxs)(import_jsx_runtime243.Fragment, { children: [ 38791 /* @__PURE__ */ (0, import_jsx_runtime243.jsxs)(import_components105.MenuGroup, { label: (0, import_i18n93.__)("Transform to"), className, children: [ 38792 hoveredTransformItemName && /* @__PURE__ */ (0, import_jsx_runtime243.jsx)( 38793 PreviewBlockPopover, 38794 { 38795 blocks: (0, import_blocks67.switchToBlockType)( 38796 blocks2, 38797 hoveredTransformItemName 38798 ) 38799 } 38800 ), 38801 !!possibleBlockVariationTransformations?.length && /* @__PURE__ */ (0, import_jsx_runtime243.jsx)( 38802 block_variation_transformations_default, 38803 { 38804 transformations: possibleBlockVariationTransformations, 38805 blocks: blocks2, 38806 onSelect: onSelectVariation 38807 } 38808 ), 38809 priorityTextTransformations.map((item) => /* @__PURE__ */ (0, import_jsx_runtime243.jsx)( 38810 BlockTransformationItem, 38811 { 38812 item, 38813 onSelect, 38814 setHoveredTransformItemName 38815 }, 38816 item.name 38817 )), 38818 !hasBothContentTransformations && restTransformItems 38819 ] }), 38820 !!hasBothContentTransformations && /* @__PURE__ */ (0, import_jsx_runtime243.jsx)(import_components105.MenuGroup, { className, children: restTransformItems }) 38821 ] }); 38822 }; 38823 function RestTransformationItems({ 38824 restTransformations, 38825 onSelect, 38826 setHoveredTransformItemName 38827 }) { 38828 return restTransformations.map((item) => /* @__PURE__ */ (0, import_jsx_runtime243.jsx)( 38829 BlockTransformationItem, 38830 { 38831 item, 38832 onSelect, 38833 setHoveredTransformItemName 38834 }, 38835 item.name 38836 )); 38837 } 38838 function BlockTransformationItem({ 38839 item, 38840 onSelect, 38841 setHoveredTransformItemName 38842 }) { 38843 const { name, icon, title, isDisabled } = item; 38844 return /* @__PURE__ */ (0, import_jsx_runtime243.jsxs)( 38845 import_components105.MenuItem, 38846 { 38847 className: (0, import_blocks67.getBlockMenuDefaultClassName)(name), 38848 onClick: (event) => { 38849 event.preventDefault(); 38850 onSelect(name); 38851 }, 38852 disabled: isDisabled, 38853 onMouseLeave: () => setHoveredTransformItemName(null), 38854 onMouseEnter: () => setHoveredTransformItemName(name), 38855 children: [ 38856 /* @__PURE__ */ (0, import_jsx_runtime243.jsx)(block_icon_default, { icon, showColors: true }), 38857 title 38858 ] 38859 } 38860 ); 38861 } 38862 var block_transformations_menu_default = BlockTransformationsMenu; 38863 38864 // packages/block-editor/build-module/components/block-switcher/block-styles-menu.js 38865 var import_i18n94 = __toESM(require_i18n()); 38866 var import_components107 = __toESM(require_components()); 38867 38868 // packages/block-editor/build-module/components/block-styles/menu-items.js 38869 var import_components106 = __toESM(require_components()); 38870 var import_jsx_runtime244 = __toESM(require_jsx_runtime()); 38871 var noop9 = () => { 38872 }; 38873 function BlockStylesMenuItems({ clientId, onSwitch = noop9 }) { 38874 const { onSelect, stylesToRender, activeStyle } = useStylesForBlocks({ 38875 clientId, 38876 onSwitch 38877 }); 38878 if (!stylesToRender || stylesToRender.length === 0) { 38879 return null; 38880 } 38881 return /* @__PURE__ */ (0, import_jsx_runtime244.jsx)(import_jsx_runtime244.Fragment, { children: stylesToRender.map((style) => { 38882 const menuItemText = style.label || style.name; 38883 return /* @__PURE__ */ (0, import_jsx_runtime244.jsx)( 38884 import_components106.MenuItem, 38885 { 38886 icon: activeStyle.name === style.name ? check_default : null, 38887 onClick: () => onSelect(style), 38888 children: /* @__PURE__ */ (0, import_jsx_runtime244.jsx)( 38889 import_components106.__experimentalText, 38890 { 38891 as: "span", 38892 limit: 18, 38893 ellipsizeMode: "tail", 38894 truncate: true, 38895 children: menuItemText 38896 } 38897 ) 38898 }, 38899 style.name 38900 ); 38901 }) }); 38902 } 38903 38904 // packages/block-editor/build-module/components/block-switcher/block-styles-menu.js 38905 var import_jsx_runtime245 = __toESM(require_jsx_runtime()); 38906 function BlockStylesMenu({ hoveredBlock, onSwitch }) { 38907 const { clientId } = hoveredBlock; 38908 return /* @__PURE__ */ (0, import_jsx_runtime245.jsx)( 38909 import_components107.MenuGroup, 38910 { 38911 label: (0, import_i18n94.__)("Styles"), 38912 className: "block-editor-block-switcher__styles__menugroup", 38913 children: /* @__PURE__ */ (0, import_jsx_runtime245.jsx)(BlockStylesMenuItems, { clientId, onSwitch }) 38914 } 38915 ); 38916 } 38917 38918 // packages/block-editor/build-module/components/block-switcher/pattern-transformations-menu.js 38919 var import_i18n95 = __toESM(require_i18n()); 38920 var import_element118 = __toESM(require_element()); 38921 var import_compose64 = __toESM(require_compose()); 38922 var import_components108 = __toESM(require_components()); 38923 38924 // packages/block-editor/build-module/components/block-switcher/use-transformed-patterns.js 38925 var import_element117 = __toESM(require_element()); 38926 var import_blocks69 = __toESM(require_blocks()); 38927 38928 // packages/block-editor/build-module/components/block-switcher/utils.js 38929 var import_blocks68 = __toESM(require_blocks()); 38930 var getMatchingBlockByName = (block, selectedBlockName, consumedBlocks = /* @__PURE__ */ new Set()) => { 38931 const { clientId, name, innerBlocks = [] } = block; 38932 if (consumedBlocks.has(clientId)) { 38933 return; 38934 } 38935 if (name === selectedBlockName) { 38936 return block; 38937 } 38938 for (const innerBlock of innerBlocks) { 38939 const match2 = getMatchingBlockByName( 38940 innerBlock, 38941 selectedBlockName, 38942 consumedBlocks 38943 ); 38944 if (match2) { 38945 return match2; 38946 } 38947 } 38948 }; 38949 var getRetainedBlockAttributes = (name, attributes) => { 38950 const contentAttributes = (0, import_blocks68.getBlockAttributesNamesByRole)(name, "content"); 38951 if (!contentAttributes?.length) { 38952 return attributes; 38953 } 38954 return contentAttributes.reduce((_accumulator, attribute) => { 38955 if (attributes[attribute]) { 38956 _accumulator[attribute] = attributes[attribute]; 38957 } 38958 return _accumulator; 38959 }, {}); 38960 }; 38961 38962 // packages/block-editor/build-module/components/block-switcher/use-transformed-patterns.js 38963 var transformMatchingBlock = (match2, selectedBlock) => { 38964 const retainedBlockAttributes = getRetainedBlockAttributes( 38965 selectedBlock.name, 38966 selectedBlock.attributes 38967 ); 38968 match2.attributes = { 38969 ...match2.attributes, 38970 ...retainedBlockAttributes 38971 }; 38972 }; 38973 var getPatternTransformedBlocks = (selectedBlocks, patternBlocks) => { 38974 const _patternBlocks = patternBlocks.map( 38975 (block) => (0, import_blocks69.cloneBlock)(block) 38976 ); 38977 const consumedBlocks = /* @__PURE__ */ new Set(); 38978 for (const selectedBlock of selectedBlocks) { 38979 let isMatch = false; 38980 for (const patternBlock of _patternBlocks) { 38981 const match2 = getMatchingBlockByName( 38982 patternBlock, 38983 selectedBlock.name, 38984 consumedBlocks 38985 ); 38986 if (!match2) { 38987 continue; 38988 } 38989 isMatch = true; 38990 consumedBlocks.add(match2.clientId); 38991 transformMatchingBlock(match2, selectedBlock); 38992 break; 38993 } 38994 if (!isMatch) { 38995 return; 38996 } 38997 } 38998 return _patternBlocks; 38999 }; 39000 var useTransformedPatterns = (patterns, selectedBlocks) => { 39001 return (0, import_element117.useMemo)( 39002 () => patterns.reduce((accumulator, _pattern) => { 39003 const transformedBlocks = getPatternTransformedBlocks( 39004 selectedBlocks, 39005 _pattern.blocks 39006 ); 39007 if (transformedBlocks) { 39008 accumulator.push({ 39009 ..._pattern, 39010 transformedBlocks 39011 }); 39012 } 39013 return accumulator; 39014 }, []), 39015 [patterns, selectedBlocks] 39016 ); 39017 }; 39018 var use_transformed_patterns_default = useTransformedPatterns; 39019 39020 // packages/block-editor/build-module/components/block-switcher/pattern-transformations-menu.js 39021 var import_jsx_runtime246 = __toESM(require_jsx_runtime()); 39022 function PatternTransformationsMenu({ 39023 blocks: blocks2, 39024 patterns: statePatterns, 39025 onSelect 39026 }) { 39027 const [showTransforms, setShowTransforms] = (0, import_element118.useState)(false); 39028 const patterns = use_transformed_patterns_default(statePatterns, blocks2); 39029 if (!patterns.length) { 39030 return null; 39031 } 39032 return /* @__PURE__ */ (0, import_jsx_runtime246.jsxs)(import_components108.MenuGroup, { className: "block-editor-block-switcher__pattern__transforms__menugroup", children: [ 39033 showTransforms && /* @__PURE__ */ (0, import_jsx_runtime246.jsx)( 39034 PreviewPatternsPopover, 39035 { 39036 patterns, 39037 onSelect 39038 } 39039 ), 39040 /* @__PURE__ */ (0, import_jsx_runtime246.jsx)( 39041 import_components108.MenuItem, 39042 { 39043 onClick: (event) => { 39044 event.preventDefault(); 39045 setShowTransforms(!showTransforms); 39046 }, 39047 icon: chevron_right_default, 39048 children: (0, import_i18n95.__)("Patterns") 39049 } 39050 ) 39051 ] }); 39052 } 39053 function PreviewPatternsPopover({ patterns, onSelect }) { 39054 const isMobile = (0, import_compose64.useViewportMatch)("medium", "<"); 39055 return /* @__PURE__ */ (0, import_jsx_runtime246.jsx)("div", { className: "block-editor-block-switcher__popover-preview-container", children: /* @__PURE__ */ (0, import_jsx_runtime246.jsx)( 39056 import_components108.Popover, 39057 { 39058 className: "block-editor-block-switcher__popover-preview", 39059 placement: isMobile ? "bottom" : "right-start", 39060 offset: 16, 39061 children: /* @__PURE__ */ (0, import_jsx_runtime246.jsx)("div", { className: "block-editor-block-switcher__preview is-pattern-list-preview", children: /* @__PURE__ */ (0, import_jsx_runtime246.jsx)( 39062 BlockPatternsList2, 39063 { 39064 patterns, 39065 onSelect 39066 } 39067 ) }) 39068 } 39069 ) }); 39070 } 39071 function BlockPatternsList2({ patterns, onSelect }) { 39072 return /* @__PURE__ */ (0, import_jsx_runtime246.jsx)( 39073 import_components108.Composite, 39074 { 39075 role: "listbox", 39076 className: "block-editor-block-switcher__preview-patterns-container", 39077 "aria-label": (0, import_i18n95.__)("Patterns list"), 39078 children: patterns.map((pattern) => /* @__PURE__ */ (0, import_jsx_runtime246.jsx)( 39079 BlockPattern2, 39080 { 39081 pattern, 39082 onSelect 39083 }, 39084 pattern.name 39085 )) 39086 } 39087 ); 39088 } 39089 function BlockPattern2({ pattern, onSelect }) { 39090 const baseClassName = "block-editor-block-switcher__preview-patterns-container"; 39091 const descriptionId = (0, import_compose64.useInstanceId)( 39092 BlockPattern2, 39093 `$baseClassName}-list__item-description` 39094 ); 39095 return /* @__PURE__ */ (0, import_jsx_runtime246.jsxs)("div", { className: `$baseClassName}-list__list-item`, children: [ 39096 /* @__PURE__ */ (0, import_jsx_runtime246.jsxs)( 39097 import_components108.Composite.Item, 39098 { 39099 render: /* @__PURE__ */ (0, import_jsx_runtime246.jsx)( 39100 "div", 39101 { 39102 role: "option", 39103 "aria-label": pattern.title, 39104 "aria-describedby": pattern.description ? descriptionId : void 0, 39105 className: `$baseClassName}-list__item` 39106 } 39107 ), 39108 onClick: () => onSelect(pattern.transformedBlocks), 39109 children: [ 39110 /* @__PURE__ */ (0, import_jsx_runtime246.jsx)( 39111 block_preview_default, 39112 { 39113 blocks: pattern.transformedBlocks, 39114 viewportWidth: pattern.viewportWidth || 500 39115 } 39116 ), 39117 /* @__PURE__ */ (0, import_jsx_runtime246.jsx)("div", { className: `$baseClassName}-list__item-title`, children: pattern.title }) 39118 ] 39119 } 39120 ), 39121 !!pattern.description && /* @__PURE__ */ (0, import_jsx_runtime246.jsx)(import_components108.VisuallyHidden, { id: descriptionId, children: pattern.description }) 39122 ] }); 39123 } 39124 var pattern_transformations_menu_default = PatternTransformationsMenu; 39125 39126 // packages/block-editor/build-module/components/block-switcher/index.js 39127 var import_jsx_runtime247 = __toESM(require_jsx_runtime()); 39128 function BlockSwitcherDropdownMenuContents({ onClose, clientIds }) { 39129 const { replaceBlocks: replaceBlocks2, multiSelect: multiSelect2, updateBlockAttributes: updateBlockAttributes2 } = (0, import_data113.useDispatch)(store); 39130 const { 39131 possibleBlockTransformations, 39132 patterns, 39133 blocks: blocks2, 39134 isUsingBindings, 39135 canRemove, 39136 hasBlockStyles 39137 } = (0, import_data113.useSelect)( 39138 (select3) => { 39139 const { 39140 getBlockAttributes: getBlockAttributes3, 39141 getBlocksByClientId: getBlocksByClientId2, 39142 getBlockRootClientId: getBlockRootClientId2, 39143 getBlockTransformItems: getBlockTransformItems2, 39144 __experimentalGetPatternTransformItems: __experimentalGetPatternTransformItems2, 39145 canRemoveBlocks: canRemoveBlocks2, 39146 getBlockName: getBlockName2 39147 } = select3(store); 39148 const { getBlockStyles: getBlockStyles2 } = select3(import_blocks70.store); 39149 const rootClientId = getBlockRootClientId2(clientIds[0]); 39150 const _blocks = getBlocksByClientId2(clientIds); 39151 const _isSingleBlock = clientIds.length === 1; 39152 const _blockName = _isSingleBlock && getBlockName2(clientIds[0]); 39153 const _hasBlockStyles = _isSingleBlock && !!getBlockStyles2(_blockName)?.length; 39154 return { 39155 blocks: _blocks, 39156 possibleBlockTransformations: getBlockTransformItems2( 39157 _blocks, 39158 rootClientId 39159 ), 39160 patterns: __experimentalGetPatternTransformItems2( 39161 _blocks, 39162 rootClientId 39163 ), 39164 isUsingBindings: clientIds.every( 39165 (clientId) => !!getBlockAttributes3(clientId)?.metadata?.bindings 39166 ), 39167 canRemove: canRemoveBlocks2(clientIds), 39168 hasBlockStyles: _hasBlockStyles 39169 }; 39170 }, 39171 [clientIds] 39172 ); 39173 const blockVariationTransformations = useBlockVariationTransforms({ 39174 clientIds, 39175 blocks: blocks2 39176 }); 39177 function selectForMultipleBlocks(insertedBlocks) { 39178 if (insertedBlocks.length > 1) { 39179 multiSelect2( 39180 insertedBlocks[0].clientId, 39181 insertedBlocks[insertedBlocks.length - 1].clientId 39182 ); 39183 } 39184 } 39185 function onBlockTransform(name) { 39186 const newBlocks = (0, import_blocks70.switchToBlockType)(blocks2, name); 39187 replaceBlocks2(clientIds, newBlocks); 39188 selectForMultipleBlocks(newBlocks); 39189 } 39190 function onBlockVariationTransform(name) { 39191 updateBlockAttributes2(blocks2[0].clientId, { 39192 ...blockVariationTransformations.find( 39193 ({ name: variationName }) => variationName === name 39194 ).attributes 39195 }); 39196 } 39197 function onPatternTransform(transformedBlocks) { 39198 replaceBlocks2(clientIds, transformedBlocks); 39199 selectForMultipleBlocks(transformedBlocks); 39200 } 39201 const isSingleBlock = blocks2.length === 1; 39202 const isSynced = isSingleBlock && ((0, import_blocks70.isTemplatePart)(blocks2[0]) || (0, import_blocks70.isReusableBlock)(blocks2[0])); 39203 const hasPossibleBlockTransformations = !!possibleBlockTransformations?.length && canRemove && !isSynced; 39204 const hasPossibleBlockVariationTransformations = !!blockVariationTransformations?.length; 39205 const hasPatternTransformation = !!patterns?.length && canRemove; 39206 const hasBlockOrBlockVariationTransforms = hasPossibleBlockTransformations || hasPossibleBlockVariationTransformations; 39207 const hasContents = hasBlockStyles || hasBlockOrBlockVariationTransforms || hasPatternTransformation; 39208 if (!hasContents) { 39209 return /* @__PURE__ */ (0, import_jsx_runtime247.jsx)("p", { className: "block-editor-block-switcher__no-transforms", children: (0, import_i18n96.__)("No transforms.") }); 39210 } 39211 const connectedBlockDescription = isSingleBlock ? (0, import_i18n96._x)( 39212 "This block is connected.", 39213 "block toolbar button label and description" 39214 ) : (0, import_i18n96._x)( 39215 "These blocks are connected.", 39216 "block toolbar button label and description" 39217 ); 39218 return /* @__PURE__ */ (0, import_jsx_runtime247.jsxs)("div", { className: "block-editor-block-switcher__container", children: [ 39219 hasPatternTransformation && /* @__PURE__ */ (0, import_jsx_runtime247.jsx)( 39220 pattern_transformations_menu_default, 39221 { 39222 blocks: blocks2, 39223 patterns, 39224 onSelect: (transformedBlocks) => { 39225 onPatternTransform(transformedBlocks); 39226 onClose(); 39227 } 39228 } 39229 ), 39230 hasBlockOrBlockVariationTransforms && /* @__PURE__ */ (0, import_jsx_runtime247.jsx)( 39231 block_transformations_menu_default, 39232 { 39233 className: "block-editor-block-switcher__transforms__menugroup", 39234 possibleBlockTransformations, 39235 possibleBlockVariationTransformations: blockVariationTransformations, 39236 blocks: blocks2, 39237 onSelect: (name) => { 39238 onBlockTransform(name); 39239 onClose(); 39240 }, 39241 onSelectVariation: (name) => { 39242 onBlockVariationTransform(name); 39243 onClose(); 39244 } 39245 } 39246 ), 39247 hasBlockStyles && /* @__PURE__ */ (0, import_jsx_runtime247.jsx)( 39248 BlockStylesMenu, 39249 { 39250 hoveredBlock: blocks2[0], 39251 onSwitch: onClose 39252 } 39253 ), 39254 isUsingBindings && /* @__PURE__ */ (0, import_jsx_runtime247.jsx)(import_components109.MenuGroup, { children: /* @__PURE__ */ (0, import_jsx_runtime247.jsx)(import_components109.__experimentalText, { className: "block-editor-block-switcher__binding-indicator", children: connectedBlockDescription }) }) 39255 ] }); 39256 } 39257 var BlockSwitcher = ({ children, clientIds, label, text }) => { 39258 const isSingleBlock = clientIds.length === 1; 39259 const blockSwitcherDescription = isSingleBlock ? (0, import_i18n96.__)("Change block type or style") : (0, import_i18n96.sprintf)( 39260 /* translators: %d: number of blocks. */ 39261 (0, import_i18n96._n)( 39262 "Change type of %d block", 39263 "Change type of %d blocks", 39264 clientIds.length 39265 ), 39266 clientIds.length 39267 ); 39268 return /* @__PURE__ */ (0, import_jsx_runtime247.jsx)(import_components109.ToolbarGroup, { children: /* @__PURE__ */ (0, import_jsx_runtime247.jsx)(import_components109.ToolbarItem, { children: (toggleProps) => /* @__PURE__ */ (0, import_jsx_runtime247.jsx)( 39269 import_components109.DropdownMenu, 39270 { 39271 className: "block-editor-block-switcher", 39272 label, 39273 popoverProps: { 39274 placement: "bottom-start", 39275 className: "block-editor-block-switcher__popover" 39276 }, 39277 icon: children, 39278 text, 39279 toggleProps: { 39280 description: blockSwitcherDescription, 39281 ...toggleProps 39282 }, 39283 menuProps: { orientation: "both" }, 39284 children: ({ onClose }) => /* @__PURE__ */ (0, import_jsx_runtime247.jsx)( 39285 BlockSwitcherDropdownMenuContents, 39286 { 39287 onClose, 39288 clientIds 39289 } 39290 ) 39291 } 39292 ) }) }); 39293 }; 39294 var block_switcher_default = BlockSwitcher; 39295 39296 // packages/block-editor/build-module/components/block-toolbar/pattern-overrides-dropdown.js 39297 var import_components110 = __toESM(require_components()); 39298 var import_i18n97 = __toESM(require_i18n()); 39299 var import_element119 = __toESM(require_element()); 39300 var import_data114 = __toESM(require_data()); 39301 var import_jsx_runtime248 = __toESM(require_jsx_runtime()); 39302 function PatternOverridesPopoverContent({ clientIds, blockTitle }) { 39303 const blockMetaName = (0, import_data114.useSelect)( 39304 (select3) => { 39305 const { getBlockAttributes: getBlockAttributes3 } = select3(store); 39306 return getBlockAttributes3(clientIds?.[0])?.metadata?.name; 39307 }, 39308 [clientIds] 39309 ); 39310 const isSingleBlock = clientIds.length === 1; 39311 let description; 39312 if (isSingleBlock && blockMetaName) { 39313 description = (0, import_i18n97.sprintf)( 39314 /* translators: 1: The block type's name. 2: The block's user-provided name (the same as the override name). */ 39315 (0, import_i18n97.__)('This %1$s is editable using the "%2$s" override.'), 39316 blockTitle.toLowerCase(), 39317 blockMetaName 39318 ); 39319 } else { 39320 description = (0, import_i18n97.__)("These blocks are editable using overrides."); 39321 } 39322 return /* @__PURE__ */ (0, import_jsx_runtime248.jsx)(import_components110.__experimentalText, { children: description }); 39323 } 39324 function PatternOverridesDropdown({ 39325 icon, 39326 clientIds, 39327 blockTitle, 39328 label 39329 }) { 39330 const [isOpen, setIsOpen] = (0, import_element119.useState)(false); 39331 const anchorRef = (0, import_element119.useRef)(); 39332 return /* @__PURE__ */ (0, import_jsx_runtime248.jsxs)(import_jsx_runtime248.Fragment, { children: [ 39333 /* @__PURE__ */ (0, import_jsx_runtime248.jsx)( 39334 import_components110.ToolbarButton, 39335 { 39336 ref: anchorRef, 39337 className: "block-editor-block-toolbar__pattern-overrides-indicator", 39338 icon, 39339 label, 39340 onClick: () => setIsOpen(!isOpen), 39341 "aria-expanded": isOpen 39342 } 39343 ), 39344 isOpen && /* @__PURE__ */ (0, import_jsx_runtime248.jsx)( 39345 import_components110.Popover, 39346 { 39347 anchor: anchorRef.current, 39348 onClose: () => setIsOpen(false), 39349 placement: "bottom-start", 39350 offset: 16, 39351 className: "block-editor-block-toolbar__pattern-overrides-popover", 39352 children: /* @__PURE__ */ (0, import_jsx_runtime248.jsx)( 39353 PatternOverridesPopoverContent, 39354 { 39355 clientIds, 39356 blockTitle 39357 } 39358 ) 39359 } 39360 ) 39361 ] }); 39362 } 39363 39364 // packages/block-editor/build-module/components/block-toolbar/block-toolbar-icon.js 39365 var import_jsx_runtime249 = __toESM(require_jsx_runtime()); 39366 function getBlockIconVariant({ select: select3, clientIds }) { 39367 const { 39368 getBlockName: getBlockName2, 39369 getBlockAttributes: getBlockAttributes3, 39370 getBlockParentsByBlockName: getBlockParentsByBlockName2, 39371 canRemoveBlocks: canRemoveBlocks2, 39372 getTemplateLock: getTemplateLock2, 39373 getBlockEditingMode: getBlockEditingMode2 39374 } = unlock(select3(store)); 39375 const { getBlockStyles: getBlockStyles2 } = select3(import_blocks71.store); 39376 const hasTemplateLock = clientIds.some( 39377 (id) => getTemplateLock2(id) === "contentOnly" 39378 ); 39379 const isSingleBlock = clientIds.length === 1; 39380 const blockName = isSingleBlock && getBlockName2(clientIds[0]); 39381 const hasBlockStyles = isSingleBlock && !!getBlockStyles2(blockName)?.length; 39382 const hasPatternNameInSelection = clientIds.some( 39383 (id) => !!getBlockAttributes3(id)?.metadata?.patternName 39384 ); 39385 const hasPatternOverrides = clientIds.every( 39386 (clientId) => hasPatternOverridesDefaultBinding( 39387 getBlockAttributes3(clientId)?.metadata?.bindings 39388 ) 39389 ); 39390 const hasParentPattern = clientIds.every( 39391 (clientId) => getBlockParentsByBlockName2(clientId, "core/block", true).length > 0 39392 ); 39393 const canRemove = canRemoveBlocks2(clientIds); 39394 const isDefaultEditingMode = getBlockEditingMode2(clientIds[0]) === "default"; 39395 const _hideTransformsForSections = window?.__experimentalContentOnlyPatternInsertion && hasPatternNameInSelection; 39396 const _showBlockSwitcher = !_hideTransformsForSections && isDefaultEditingMode && (hasBlockStyles || canRemove) && !hasTemplateLock; 39397 const _showPatternOverrides = hasPatternOverrides && hasParentPattern; 39398 if (_showBlockSwitcher) { 39399 return "switcher"; 39400 } else if (_showPatternOverrides) { 39401 return "pattern-overrides"; 39402 } 39403 return "default"; 39404 } 39405 function getBlockIcon({ select: select3, clientIds }) { 39406 const { getBlockName: getBlockName2, getBlockAttributes: getBlockAttributes3 } = unlock( 39407 select3(store) 39408 ); 39409 const _isSingleBlock = clientIds.length === 1; 39410 const firstClientId = clientIds[0]; 39411 const blockAttributes = getBlockAttributes3(firstClientId); 39412 if (_isSingleBlock && blockAttributes?.metadata?.patternName && window?.__experimentalContentOnlyPatternInsertion) { 39413 return symbol_default; 39414 } 39415 const blockName = getBlockName2(firstClientId); 39416 const blockType = (0, import_blocks71.getBlockType)(blockName); 39417 if (_isSingleBlock) { 39418 const { getActiveBlockVariation } = select3(import_blocks71.store); 39419 const match2 = getActiveBlockVariation(blockName, blockAttributes); 39420 return match2?.icon || blockType?.icon; 39421 } 39422 const blockNames = clientIds.map((id) => getBlockName2(id)); 39423 const isSelectionOfSameType = new Set(blockNames).size === 1; 39424 return isSelectionOfSameType ? blockType?.icon : copy_default; 39425 } 39426 function BlockToolbarIcon({ clientIds, isSynced }) { 39427 const { icon, showIconLabels, variant } = (0, import_data115.useSelect)( 39428 (select3) => { 39429 return { 39430 icon: getBlockIcon({ select: select3, clientIds }), 39431 showIconLabels: select3(import_preferences2.store).get( 39432 "core", 39433 "showIconLabels" 39434 ), 39435 variant: getBlockIconVariant({ 39436 select: select3, 39437 clientIds 39438 }) 39439 }; 39440 }, 39441 [clientIds] 39442 ); 39443 const blockTitle = useBlockDisplayTitle({ 39444 clientId: clientIds?.[0], 39445 maximumLength: 35 39446 }); 39447 const isSingleBlock = clientIds.length === 1; 39448 const showBlockTitle = isSingleBlock && isSynced && !showIconLabels; 39449 const label = isSingleBlock ? blockTitle : (0, import_i18n98.__)("Multiple blocks selected"); 39450 const text = showBlockTitle && blockTitle ? blockTitle : void 0; 39451 const BlockIconElement = /* @__PURE__ */ (0, import_jsx_runtime249.jsx)( 39452 block_icon_default, 39453 { 39454 className: "block-editor-block-toolbar__block-icon", 39455 icon 39456 } 39457 ); 39458 if (variant === "switcher") { 39459 return /* @__PURE__ */ (0, import_jsx_runtime249.jsx)( 39460 block_switcher_default, 39461 { 39462 clientIds, 39463 label, 39464 text, 39465 children: BlockIconElement 39466 } 39467 ); 39468 } 39469 if (variant === "pattern-overrides") { 39470 return /* @__PURE__ */ (0, import_jsx_runtime249.jsx)( 39471 PatternOverridesDropdown, 39472 { 39473 icon: BlockIconElement, 39474 clientIds, 39475 blockTitle, 39476 label 39477 } 39478 ); 39479 } 39480 return /* @__PURE__ */ (0, import_jsx_runtime249.jsx)( 39481 import_components111.ToolbarButton, 39482 { 39483 disabled: true, 39484 className: "block-editor-block-toolbar__block-icon-button", 39485 title: label, 39486 icon: BlockIconElement, 39487 text 39488 } 39489 ); 39490 } 39491 39492 // packages/block-editor/build-module/components/block-toolbar/index.js 39493 var import_jsx_runtime250 = __toESM(require_jsx_runtime()); 39494 function PrivateBlockToolbar({ 39495 hideDragHandle, 39496 focusOnMount, 39497 __experimentalInitialIndex, 39498 __experimentalOnIndexChange, 39499 variant = "unstyled" 39500 }) { 39501 const { 39502 blockClientId, 39503 blockClientIds, 39504 isDefaultEditingMode, 39505 blockType, 39506 toolbarKey, 39507 shouldShowVisualToolbar, 39508 showParentSelector, 39509 isUsingBindings, 39510 isSectionContainer, 39511 hasContentOnlyLocking, 39512 showShuffleButton, 39513 showSlots, 39514 showGroupButtons, 39515 showLockButtons, 39516 showBlockVisibilityButton, 39517 showSwitchSectionStyleButton 39518 } = (0, import_data116.useSelect)((select3) => { 39519 const { 39520 getBlockName: getBlockName2, 39521 getBlockMode: getBlockMode2, 39522 getBlockParents: getBlockParents2, 39523 getSelectedBlockClientIds: getSelectedBlockClientIds2, 39524 isBlockValid: isBlockValid2, 39525 getBlockEditingMode: getBlockEditingMode2, 39526 getBlockAttributes: getBlockAttributes3, 39527 getTemplateLock: getTemplateLock2, 39528 getParentSectionBlock: getParentSectionBlock2, 39529 isZoomOut: isZoomOut2, 39530 isSectionBlock: isSectionBlock2 39531 } = unlock(select3(store)); 39532 const selectedBlockClientIds = getSelectedBlockClientIds2(); 39533 const selectedBlockClientId = selectedBlockClientIds[0]; 39534 const parents = getBlockParents2(selectedBlockClientId); 39535 const parentSection = getParentSectionBlock2(selectedBlockClientId); 39536 const parentClientId = parentSection ?? parents[parents.length - 1]; 39537 const parentBlockName = getBlockName2(parentClientId); 39538 const parentBlockType = (0, import_blocks72.getBlockType)(parentBlockName); 39539 const editingMode = getBlockEditingMode2(selectedBlockClientId); 39540 const _isDefaultEditingMode = editingMode === "default"; 39541 const _blockName = getBlockName2(selectedBlockClientId); 39542 const isValid2 = selectedBlockClientIds.every( 39543 (id) => isBlockValid2(id) 39544 ); 39545 const isVisual = selectedBlockClientIds.every( 39546 (id) => getBlockMode2(id) === "visual" 39547 ); 39548 const _isUsingBindings = selectedBlockClientIds.every( 39549 (clientId) => !!getBlockAttributes3(clientId)?.metadata?.bindings 39550 ); 39551 const _hasTemplateLock = selectedBlockClientIds.some( 39552 (id) => getTemplateLock2(id) === "contentOnly" 39553 ); 39554 const _isZoomOut = isZoomOut2(); 39555 const _isSectionBlock = isSectionBlock2(selectedBlockClientId); 39556 const _showSwitchSectionStyleButton = window?.__experimentalContentOnlyPatternInsertion && (_isZoomOut || _isSectionBlock); 39557 return { 39558 blockClientId: selectedBlockClientId, 39559 blockClientIds: selectedBlockClientIds, 39560 isDefaultEditingMode: _isDefaultEditingMode, 39561 blockType: selectedBlockClientId && (0, import_blocks72.getBlockType)(_blockName), 39562 shouldShowVisualToolbar: isValid2 && isVisual, 39563 toolbarKey: `$selectedBlockClientId}$parentClientId}`, 39564 showParentSelector: !_isZoomOut && parentBlockType && editingMode !== "contentOnly" && getBlockEditingMode2(parentClientId) !== "disabled" && (0, import_blocks72.hasBlockSupport)( 39565 parentBlockType, 39566 "__experimentalParentSelector", 39567 true 39568 ) && selectedBlockClientIds.length === 1, 39569 isUsingBindings: _isUsingBindings, 39570 isSectionContainer: _isSectionBlock, 39571 hasContentOnlyLocking: _hasTemplateLock, 39572 showShuffleButton: _isZoomOut, 39573 showSlots: !_isZoomOut, 39574 showGroupButtons: !_isZoomOut, 39575 showLockButtons: !_isZoomOut, 39576 showBlockVisibilityButton: !_isZoomOut, 39577 showSwitchSectionStyleButton: _showSwitchSectionStyleButton 39578 }; 39579 }, []); 39580 const toolbarWrapperRef = (0, import_element120.useRef)(null); 39581 const nodeRef = (0, import_element120.useRef)(); 39582 const showHoveredOrFocusedGestures = useShowHoveredOrFocusedGestures({ 39583 ref: nodeRef 39584 }); 39585 const isLargeViewport = !(0, import_compose65.useViewportMatch)("medium", "<"); 39586 const hasBlockToolbar = useHasBlockToolbar(); 39587 if (!hasBlockToolbar) { 39588 return null; 39589 } 39590 const isMultiToolbar = blockClientIds.length > 1; 39591 const isSynced = (0, import_blocks72.isReusableBlock)(blockType) || (0, import_blocks72.isTemplatePart)(blockType); 39592 const classes = clsx_default("block-editor-block-contextual-toolbar", { 39593 "has-parent": showParentSelector 39594 }); 39595 const innerClasses = clsx_default("block-editor-block-toolbar", { 39596 "is-synced": isSynced, 39597 "is-connected": isUsingBindings 39598 }); 39599 return /* @__PURE__ */ (0, import_jsx_runtime250.jsx)( 39600 NavigableToolbar, 39601 { 39602 focusEditorOnEscape: true, 39603 className: classes, 39604 "aria-label": (0, import_i18n99.__)("Block tools"), 39605 variant: variant === "toolbar" ? void 0 : variant, 39606 focusOnMount, 39607 __experimentalInitialIndex, 39608 __experimentalOnIndexChange, 39609 children: /* @__PURE__ */ (0, import_jsx_runtime250.jsxs)("div", { ref: toolbarWrapperRef, className: innerClasses, children: [ 39610 showParentSelector && !isMultiToolbar && isLargeViewport && /* @__PURE__ */ (0, import_jsx_runtime250.jsx)(BlockParentSelector, {}), 39611 (shouldShowVisualToolbar || isMultiToolbar) && /* @__PURE__ */ (0, import_jsx_runtime250.jsx)("div", { ref: nodeRef, ...showHoveredOrFocusedGestures, children: /* @__PURE__ */ (0, import_jsx_runtime250.jsxs)(import_components112.ToolbarGroup, { className: "block-editor-block-toolbar__block-controls", children: [ 39612 /* @__PURE__ */ (0, import_jsx_runtime250.jsx)( 39613 BlockToolbarIcon, 39614 { 39615 clientIds: blockClientIds, 39616 isSynced 39617 } 39618 ), 39619 isDefaultEditingMode && showBlockVisibilityButton && /* @__PURE__ */ (0, import_jsx_runtime250.jsx)( 39620 BlockVisibilityToolbar, 39621 { 39622 clientIds: blockClientIds 39623 } 39624 ), 39625 !isMultiToolbar && isDefaultEditingMode && showLockButtons && /* @__PURE__ */ (0, import_jsx_runtime250.jsx)( 39626 BlockLockToolbar, 39627 { 39628 clientId: blockClientId 39629 } 39630 ), 39631 /* @__PURE__ */ (0, import_jsx_runtime250.jsx)( 39632 block_mover_default, 39633 { 39634 clientIds: blockClientIds, 39635 hideDragHandle 39636 } 39637 ) 39638 ] }) }), 39639 !hasContentOnlyLocking && shouldShowVisualToolbar && isMultiToolbar && showGroupButtons && /* @__PURE__ */ (0, import_jsx_runtime250.jsx)(toolbar_default, {}), 39640 showShuffleButton && /* @__PURE__ */ (0, import_jsx_runtime250.jsx)(ChangeDesign, { clientId: blockClientIds[0] }), 39641 showSwitchSectionStyleButton && /* @__PURE__ */ (0, import_jsx_runtime250.jsx)(switch_section_style_default, { clientId: blockClientIds[0] }), 39642 shouldShowVisualToolbar && showSlots && /* @__PURE__ */ (0, import_jsx_runtime250.jsxs)(import_jsx_runtime250.Fragment, { children: [ 39643 !isSectionContainer && /* @__PURE__ */ (0, import_jsx_runtime250.jsxs)(import_jsx_runtime250.Fragment, { children: [ 39644 /* @__PURE__ */ (0, import_jsx_runtime250.jsx)( 39645 block_controls_default.Slot, 39646 { 39647 group: "parent", 39648 className: "block-editor-block-toolbar__slot" 39649 } 39650 ), 39651 /* @__PURE__ */ (0, import_jsx_runtime250.jsx)( 39652 block_controls_default.Slot, 39653 { 39654 group: "block", 39655 className: "block-editor-block-toolbar__slot" 39656 } 39657 ), 39658 /* @__PURE__ */ (0, import_jsx_runtime250.jsx)(block_controls_default.Slot, { className: "block-editor-block-toolbar__slot" }), 39659 /* @__PURE__ */ (0, import_jsx_runtime250.jsx)( 39660 block_controls_default.Slot, 39661 { 39662 group: "inline", 39663 className: "block-editor-block-toolbar__slot" 39664 } 39665 ) 39666 ] }), 39667 /* @__PURE__ */ (0, import_jsx_runtime250.jsx)( 39668 block_controls_default.Slot, 39669 { 39670 group: "other", 39671 className: "block-editor-block-toolbar__slot" 39672 } 39673 ), 39674 /* @__PURE__ */ (0, import_jsx_runtime250.jsx)(block_toolbar_last_item_default.Slot, {}) 39675 ] }), 39676 /* @__PURE__ */ (0, import_jsx_runtime250.jsx)(BlockEditVisuallyButton, { clientIds: blockClientIds }), 39677 /* @__PURE__ */ (0, import_jsx_runtime250.jsx)(block_settings_menu_default, { clientIds: blockClientIds }) 39678 ] }) 39679 }, 39680 toolbarKey 39681 ); 39682 } 39683 function BlockToolbar({ hideDragHandle, variant }) { 39684 return /* @__PURE__ */ (0, import_jsx_runtime250.jsx)( 39685 PrivateBlockToolbar, 39686 { 39687 hideDragHandle, 39688 variant, 39689 focusOnMount: void 0, 39690 __experimentalInitialIndex: void 0, 39691 __experimentalOnIndexChange: void 0 39692 } 39693 ); 39694 } 39695 39696 // packages/block-editor/build-module/components/block-tools/block-toolbar-popover.js 39697 var import_jsx_runtime251 = __toESM(require_jsx_runtime()); 39698 function BlockToolbarPopover({ 39699 clientId, 39700 isTyping: isTyping3, 39701 __unstableContentRef 39702 }) { 39703 const { capturingClientId, isInsertionPointVisible, lastClientId } = useSelectedBlockToolProps(clientId); 39704 const initialToolbarItemIndexRef = (0, import_element121.useRef)(); 39705 (0, import_element121.useEffect)(() => { 39706 initialToolbarItemIndexRef.current = void 0; 39707 }, [clientId]); 39708 const { stopTyping: stopTyping2 } = (0, import_data117.useDispatch)(store); 39709 const isToolbarForcedRef = (0, import_element121.useRef)(false); 39710 (0, import_keyboard_shortcuts7.useShortcut)("core/block-editor/focus-toolbar", () => { 39711 isToolbarForcedRef.current = true; 39712 stopTyping2(true); 39713 }); 39714 (0, import_element121.useEffect)(() => { 39715 isToolbarForcedRef.current = false; 39716 }); 39717 const clientIdToPositionOver = capturingClientId || clientId; 39718 const popoverProps3 = useBlockToolbarPopoverProps({ 39719 contentElement: __unstableContentRef?.current, 39720 clientId: clientIdToPositionOver 39721 }); 39722 return !isTyping3 && /* @__PURE__ */ (0, import_jsx_runtime251.jsx)( 39723 PrivateBlockPopover, 39724 { 39725 clientId: clientIdToPositionOver, 39726 bottomClientId: lastClientId, 39727 className: clsx_default("block-editor-block-list__block-popover", { 39728 "is-insertion-point-visible": isInsertionPointVisible 39729 }), 39730 resize: false, 39731 ...popoverProps3, 39732 __unstableContentRef, 39733 children: /* @__PURE__ */ (0, import_jsx_runtime251.jsx)( 39734 PrivateBlockToolbar, 39735 { 39736 focusOnMount: isToolbarForcedRef.current, 39737 __experimentalInitialIndex: initialToolbarItemIndexRef.current, 39738 __experimentalOnIndexChange: (index) => { 39739 initialToolbarItemIndexRef.current = index; 39740 }, 39741 variant: "toolbar" 39742 } 39743 ) 39744 } 39745 ); 39746 } 39747 39748 // packages/block-editor/build-module/components/block-tools/zoom-out-mode-inserters.js 39749 var import_data118 = __toESM(require_data()); 39750 var import_element122 = __toESM(require_element()); 39751 39752 // packages/block-editor/build-module/components/block-tools/zoom-out-mode-inserter-button.js 39753 var import_components113 = __toESM(require_components()); 39754 var import_i18n100 = __toESM(require_i18n()); 39755 var import_jsx_runtime252 = __toESM(require_jsx_runtime()); 39756 function ZoomOutModeInserterButton({ onClick }) { 39757 return /* @__PURE__ */ (0, import_jsx_runtime252.jsx)( 39758 import_components113.Button, 39759 { 39760 variant: "primary", 39761 icon: plus_default, 39762 size: "compact", 39763 className: clsx_default( 39764 "block-editor-button-pattern-inserter__button", 39765 "block-editor-block-tools__zoom-out-mode-inserter-button" 39766 ), 39767 onClick, 39768 label: (0, import_i18n100._x)( 39769 "Add pattern", 39770 "Generic label for pattern inserter button" 39771 ) 39772 } 39773 ); 39774 } 39775 var zoom_out_mode_inserter_button_default = ZoomOutModeInserterButton; 39776 39777 // packages/block-editor/build-module/components/block-tools/zoom-out-mode-inserters.js 39778 var import_jsx_runtime253 = __toESM(require_jsx_runtime()); 39779 function ZoomOutModeInserters() { 39780 const [isReady, setIsReady] = (0, import_element122.useState)(false); 39781 const { 39782 hasSelection, 39783 blockOrder, 39784 setInserterIsOpened, 39785 sectionRootClientId, 39786 selectedBlockClientId, 39787 blockInsertionPoint, 39788 insertionPointVisible 39789 } = (0, import_data118.useSelect)((select3) => { 39790 const { 39791 getSettings: getSettings8, 39792 getBlockOrder: getBlockOrder2, 39793 getSelectionStart: getSelectionStart2, 39794 getSelectedBlockClientId: getSelectedBlockClientId2, 39795 getSectionRootClientId: getSectionRootClientId2, 39796 getBlockInsertionPoint: getBlockInsertionPoint2, 39797 isBlockInsertionPointVisible: isBlockInsertionPointVisible2 39798 } = unlock(select3(store)); 39799 const root = getSectionRootClientId2(); 39800 return { 39801 hasSelection: !!getSelectionStart2().clientId, 39802 blockOrder: getBlockOrder2(root), 39803 sectionRootClientId: root, 39804 setInserterIsOpened: getSettings8().__experimentalSetIsInserterOpened, 39805 selectedBlockClientId: getSelectedBlockClientId2(), 39806 blockInsertionPoint: getBlockInsertionPoint2(), 39807 insertionPointVisible: isBlockInsertionPointVisible2() 39808 }; 39809 }, []); 39810 const { showInsertionPoint: showInsertionPoint2 } = unlock((0, import_data118.useDispatch)(store)); 39811 (0, import_element122.useEffect)(() => { 39812 const timeout = setTimeout(() => { 39813 setIsReady(true); 39814 }, 500); 39815 return () => { 39816 clearTimeout(timeout); 39817 }; 39818 }, []); 39819 if (!isReady || !hasSelection) { 39820 return null; 39821 } 39822 const previousClientId = selectedBlockClientId; 39823 const index = blockOrder.findIndex( 39824 (clientId) => selectedBlockClientId === clientId 39825 ); 39826 const insertionIndex = index + 1; 39827 const nextClientId = blockOrder[insertionIndex]; 39828 if (insertionPointVisible && blockInsertionPoint?.index === insertionIndex) { 39829 return null; 39830 } 39831 return /* @__PURE__ */ (0, import_jsx_runtime253.jsx)( 39832 inbetween_default, 39833 { 39834 previousClientId, 39835 nextClientId, 39836 children: /* @__PURE__ */ (0, import_jsx_runtime253.jsx)( 39837 zoom_out_mode_inserter_button_default, 39838 { 39839 onClick: () => { 39840 setInserterIsOpened({ 39841 rootClientId: sectionRootClientId, 39842 insertionIndex, 39843 tab: "patterns", 39844 category: "all" 39845 }); 39846 showInsertionPoint2(sectionRootClientId, insertionIndex, { 39847 operation: "insert" 39848 }); 39849 } 39850 } 39851 ) 39852 } 39853 ); 39854 } 39855 var zoom_out_mode_inserters_default = ZoomOutModeInserters; 39856 39857 // packages/block-editor/build-module/components/block-tools/use-show-block-tools.js 39858 var import_data119 = __toESM(require_data()); 39859 var import_blocks73 = __toESM(require_blocks()); 39860 function useShowBlockTools() { 39861 return (0, import_data119.useSelect)((select3) => { 39862 const { 39863 getSelectedBlockClientId: getSelectedBlockClientId2, 39864 getFirstMultiSelectedBlockClientId: getFirstMultiSelectedBlockClientId2, 39865 getBlock: getBlock2, 39866 getBlockMode: getBlockMode2, 39867 getSettings: getSettings8, 39868 isTyping: isTyping3, 39869 isBlockInterfaceHidden: isBlockInterfaceHidden3 39870 } = unlock(select3(store)); 39871 const clientId = getSelectedBlockClientId2() || getFirstMultiSelectedBlockClientId2(); 39872 const block = getBlock2(clientId); 39873 const hasSelectedBlock2 = !!clientId && !!block; 39874 const isEmptyDefaultBlock = hasSelectedBlock2 && (0, import_blocks73.isUnmodifiedDefaultBlock)(block, "content") && getBlockMode2(clientId) !== "html"; 39875 const _showEmptyBlockSideInserter = clientId && !isTyping3() && isEmptyDefaultBlock; 39876 const _showBlockToolbarPopover = !isBlockInterfaceHidden3() && !getSettings8().hasFixedToolbar && !_showEmptyBlockSideInserter && hasSelectedBlock2 && !isEmptyDefaultBlock; 39877 return { 39878 showEmptyBlockSideInserter: _showEmptyBlockSideInserter, 39879 showBlockToolbarPopover: _showBlockToolbarPopover 39880 }; 39881 }, []); 39882 } 39883 39884 // packages/block-editor/build-module/components/block-tools/index.js 39885 var import_jsx_runtime254 = __toESM(require_jsx_runtime()); 39886 function selector2(select3) { 39887 const { 39888 getSelectedBlockClientId: getSelectedBlockClientId2, 39889 getFirstMultiSelectedBlockClientId: getFirstMultiSelectedBlockClientId2, 39890 getSettings: getSettings8, 39891 isTyping: isTyping3, 39892 isDragging: isDragging3, 39893 isZoomOut: isZoomOut2 39894 } = unlock(select3(store)); 39895 const clientId = getSelectedBlockClientId2() || getFirstMultiSelectedBlockClientId2(); 39896 return { 39897 clientId, 39898 hasFixedToolbar: getSettings8().hasFixedToolbar, 39899 isTyping: isTyping3(), 39900 isZoomOutMode: isZoomOut2(), 39901 isDragging: isDragging3() 39902 }; 39903 } 39904 function BlockTools({ 39905 children, 39906 __unstableContentRef, 39907 ...props 39908 }) { 39909 const { clientId, hasFixedToolbar, isTyping: isTyping3, isZoomOutMode, isDragging: isDragging3 } = (0, import_data120.useSelect)(selector2, []); 39910 const isMatch = (0, import_keyboard_shortcuts8.__unstableUseShortcutEventMatch)(); 39911 const { 39912 getBlocksByClientId: getBlocksByClientId2, 39913 getSelectedBlockClientIds: getSelectedBlockClientIds2, 39914 getBlockRootClientId: getBlockRootClientId2, 39915 isGroupable: isGroupable2, 39916 getBlockName: getBlockName2, 39917 getEditedContentOnlySection: getEditedContentOnlySection2 39918 } = unlock((0, import_data120.useSelect)(store)); 39919 const { getGroupingBlockName } = (0, import_data120.useSelect)(import_blocks74.store); 39920 const { showEmptyBlockSideInserter, showBlockToolbarPopover } = useShowBlockTools(); 39921 const pasteStyles = usePasteStyles(); 39922 const { 39923 duplicateBlocks: duplicateBlocks2, 39924 removeBlocks: removeBlocks2, 39925 replaceBlocks: replaceBlocks2, 39926 insertAfterBlock: insertAfterBlock2, 39927 insertBeforeBlock: insertBeforeBlock2, 39928 selectBlock: selectBlock2, 39929 moveBlocksUp: moveBlocksUp2, 39930 moveBlocksDown: moveBlocksDown2, 39931 expandBlock: expandBlock2, 39932 updateBlockAttributes: updateBlockAttributes2, 39933 stopEditingContentOnlySection: stopEditingContentOnlySection2 39934 } = unlock((0, import_data120.useDispatch)(store)); 39935 function onKeyDown(event) { 39936 if (event.defaultPrevented) { 39937 return; 39938 } 39939 if (isMatch("core/block-editor/move-up", event) || isMatch("core/block-editor/move-down", event)) { 39940 const clientIds = getSelectedBlockClientIds2(); 39941 if (clientIds.length) { 39942 event.preventDefault(); 39943 const rootClientId = getBlockRootClientId2(clientIds[0]); 39944 const direction = isMatch("core/block-editor/move-up", event) ? "up" : "down"; 39945 if (direction === "up") { 39946 moveBlocksUp2(clientIds, rootClientId); 39947 } else { 39948 moveBlocksDown2(clientIds, rootClientId); 39949 } 39950 const blockLength = Array.isArray(clientIds) ? clientIds.length : 1; 39951 const message2 = (0, import_i18n101.sprintf)( 39952 // translators: %d: the name of the block that has been moved 39953 (0, import_i18n101._n)( 39954 "%d block moved.", 39955 "%d blocks moved.", 39956 clientIds.length 39957 ), 39958 blockLength 39959 ); 39960 (0, import_a11y12.speak)(message2); 39961 } 39962 } else if (isMatch("core/block-editor/duplicate", event)) { 39963 const clientIds = getSelectedBlockClientIds2(); 39964 if (clientIds.length) { 39965 event.preventDefault(); 39966 duplicateBlocks2(clientIds); 39967 } 39968 } else if (isMatch("core/block-editor/remove", event)) { 39969 const clientIds = getSelectedBlockClientIds2(); 39970 if (clientIds.length) { 39971 event.preventDefault(); 39972 removeBlocks2(clientIds); 39973 } 39974 } else if (isMatch("core/block-editor/paste-styles", event)) { 39975 const clientIds = getSelectedBlockClientIds2(); 39976 if (clientIds.length) { 39977 event.preventDefault(); 39978 const blocks2 = getBlocksByClientId2(clientIds); 39979 pasteStyles(blocks2); 39980 } 39981 } else if (isMatch("core/block-editor/insert-after", event)) { 39982 const clientIds = getSelectedBlockClientIds2(); 39983 if (clientIds.length) { 39984 event.preventDefault(); 39985 insertAfterBlock2(clientIds[clientIds.length - 1]); 39986 } 39987 } else if (isMatch("core/block-editor/insert-before", event)) { 39988 const clientIds = getSelectedBlockClientIds2(); 39989 if (clientIds.length) { 39990 event.preventDefault(); 39991 insertBeforeBlock2(clientIds[0]); 39992 } 39993 } else if (isMatch("core/block-editor/unselect", event)) { 39994 if (event.target.closest("[role=toolbar]")) { 39995 return; 39996 } 39997 const clientIds = getSelectedBlockClientIds2(); 39998 if (clientIds.length > 1) { 39999 event.preventDefault(); 40000 selectBlock2(clientIds[0]); 40001 } 40002 } else if (isMatch("core/block-editor/collapse-list-view", event)) { 40003 if ((0, import_dom28.isTextField)(event.target) || (0, import_dom28.isTextField)( 40004 event.target?.contentWindow?.document?.activeElement 40005 )) { 40006 return; 40007 } 40008 event.preventDefault(); 40009 expandBlock2(clientId); 40010 } else if (isMatch("core/block-editor/group", event)) { 40011 const clientIds = getSelectedBlockClientIds2(); 40012 if (clientIds.length > 1 && isGroupable2(clientIds)) { 40013 event.preventDefault(); 40014 const blocks2 = getBlocksByClientId2(clientIds); 40015 const groupingBlockName = getGroupingBlockName(); 40016 const newBlocks = (0, import_blocks74.switchToBlockType)( 40017 blocks2, 40018 groupingBlockName 40019 ); 40020 replaceBlocks2(clientIds, newBlocks); 40021 (0, import_a11y12.speak)((0, import_i18n101.__)("Selected blocks are grouped.")); 40022 } 40023 } else if (isMatch("core/block-editor/toggle-block-visibility", event)) { 40024 const clientIds = getSelectedBlockClientIds2(); 40025 if (clientIds.length) { 40026 event.preventDefault(); 40027 const blocks2 = getBlocksByClientId2(clientIds); 40028 const canToggleBlockVisibility = blocks2.every( 40029 (block) => (0, import_blocks74.hasBlockSupport)( 40030 getBlockName2(block.clientId), 40031 "visibility", 40032 true 40033 ) 40034 ); 40035 if (!canToggleBlockVisibility) { 40036 return; 40037 } 40038 const hasHiddenBlock = blocks2.some( 40039 (block) => block.attributes.metadata?.blockVisibility === false 40040 ); 40041 const attributesByClientId = Object.fromEntries( 40042 blocks2.map(({ clientId: mapClientId, attributes }) => [ 40043 mapClientId, 40044 { 40045 metadata: cleanEmptyObject({ 40046 ...attributes?.metadata, 40047 blockVisibility: hasHiddenBlock ? void 0 : false 40048 }) 40049 } 40050 ]) 40051 ); 40052 updateBlockAttributes2(clientIds, attributesByClientId, { 40053 uniqueByBlock: true 40054 }); 40055 } 40056 } 40057 if (isMatch("core/block-editor/stop-editing-as-blocks", event)) { 40058 if (getEditedContentOnlySection2()) { 40059 stopEditingContentOnlySection2(); 40060 } 40061 } 40062 } 40063 const blockToolbarRef = use_popover_scroll_default(__unstableContentRef); 40064 const blockToolbarAfterRef = use_popover_scroll_default(__unstableContentRef); 40065 return ( 40066 // eslint-disable-next-line jsx-a11y/no-static-element-interactions 40067 /* @__PURE__ */ (0, import_jsx_runtime254.jsx)( 40068 "div", 40069 { 40070 ...props, 40071 onKeyDown, 40072 className: clsx_default(props.className, { 40073 "block-editor-block-tools--is-dragging": isDragging3 40074 }), 40075 children: /* @__PURE__ */ (0, import_jsx_runtime254.jsxs)(InsertionPointOpenRef.Provider, { value: (0, import_element123.useRef)(false), children: [ 40076 !isTyping3 && !isZoomOutMode && /* @__PURE__ */ (0, import_jsx_runtime254.jsx)( 40077 InsertionPoint, 40078 { 40079 __unstableContentRef 40080 } 40081 ), 40082 showEmptyBlockSideInserter && /* @__PURE__ */ (0, import_jsx_runtime254.jsx)( 40083 EmptyBlockInserter, 40084 { 40085 __unstableContentRef, 40086 clientId 40087 } 40088 ), 40089 showBlockToolbarPopover && /* @__PURE__ */ (0, import_jsx_runtime254.jsx)( 40090 BlockToolbarPopover, 40091 { 40092 __unstableContentRef, 40093 clientId, 40094 isTyping: isTyping3 40095 } 40096 ), 40097 !isZoomOutMode && !hasFixedToolbar && /* @__PURE__ */ (0, import_jsx_runtime254.jsx)( 40098 import_components114.Popover.Slot, 40099 { 40100 name: "block-toolbar", 40101 ref: blockToolbarRef 40102 } 40103 ), 40104 children, 40105 /* @__PURE__ */ (0, import_jsx_runtime254.jsx)( 40106 import_components114.Popover.Slot, 40107 { 40108 name: "__unstable-block-tools-after", 40109 ref: blockToolbarAfterRef 40110 } 40111 ), 40112 isZoomOutMode && !isDragging3 && /* @__PURE__ */ (0, import_jsx_runtime254.jsx)( 40113 zoom_out_mode_inserters_default, 40114 { 40115 __unstableContentRef 40116 } 40117 ) 40118 ] }) 40119 } 40120 ) 40121 ); 40122 } 40123 40124 // packages/block-editor/build-module/components/use-block-commands/index.js 40125 var import_i18n102 = __toESM(require_i18n()); 40126 var import_blocks75 = __toESM(require_blocks()); 40127 var import_data121 = __toESM(require_data()); 40128 var import_commands = __toESM(require_commands()); 40129 var import_jsx_runtime255 = __toESM(require_jsx_runtime()); 40130 var getTransformCommands = () => function useTransformCommands() { 40131 const { replaceBlocks: replaceBlocks2, multiSelect: multiSelect2 } = (0, import_data121.useDispatch)(store); 40132 const { 40133 blocks: blocks2, 40134 clientIds, 40135 canRemove, 40136 possibleBlockTransformations, 40137 invalidSelection 40138 } = (0, import_data121.useSelect)((select3) => { 40139 const { 40140 getBlockRootClientId: getBlockRootClientId2, 40141 getBlockTransformItems: getBlockTransformItems2, 40142 getSelectedBlockClientIds: getSelectedBlockClientIds2, 40143 getBlocksByClientId: getBlocksByClientId2, 40144 canRemoveBlocks: canRemoveBlocks2 40145 } = select3(store); 40146 const selectedBlockClientIds = getSelectedBlockClientIds2(); 40147 const selectedBlocks = getBlocksByClientId2( 40148 selectedBlockClientIds 40149 ); 40150 if (selectedBlocks.filter((block) => !block).length > 0) { 40151 return { 40152 invalidSelection: true 40153 }; 40154 } 40155 const rootClientId = getBlockRootClientId2( 40156 selectedBlockClientIds[0] 40157 ); 40158 return { 40159 blocks: selectedBlocks, 40160 clientIds: selectedBlockClientIds, 40161 possibleBlockTransformations: getBlockTransformItems2( 40162 selectedBlocks, 40163 rootClientId 40164 ), 40165 canRemove: canRemoveBlocks2(selectedBlockClientIds), 40166 invalidSelection: false 40167 }; 40168 }, []); 40169 if (invalidSelection) { 40170 return { 40171 isLoading: false, 40172 commands: [] 40173 }; 40174 } 40175 const isTemplate = blocks2.length === 1 && (0, import_blocks75.isTemplatePart)(blocks2[0]); 40176 function selectForMultipleBlocks(insertedBlocks) { 40177 if (insertedBlocks.length > 1) { 40178 multiSelect2( 40179 insertedBlocks[0].clientId, 40180 insertedBlocks[insertedBlocks.length - 1].clientId 40181 ); 40182 } 40183 } 40184 function onBlockTransform(name) { 40185 const newBlocks = (0, import_blocks75.switchToBlockType)(blocks2, name); 40186 replaceBlocks2(clientIds, newBlocks); 40187 selectForMultipleBlocks(newBlocks); 40188 } 40189 const hasPossibleBlockTransformations = !!possibleBlockTransformations.length && canRemove && !isTemplate; 40190 if (!clientIds || clientIds.length < 1 || !hasPossibleBlockTransformations) { 40191 return { isLoading: false, commands: [] }; 40192 } 40193 const commands = possibleBlockTransformations.map( 40194 (transformation) => { 40195 const { name, title, icon } = transformation; 40196 return { 40197 name: "core/block-editor/transform-to-" + name.replace("/", "-"), 40198 /* translators: %s: Block or block variation name. */ 40199 label: (0, import_i18n102.sprintf)((0, import_i18n102.__)("Transform to %s"), title), 40200 icon: /* @__PURE__ */ (0, import_jsx_runtime255.jsx)(block_icon_default, { icon }), 40201 callback: ({ close }) => { 40202 onBlockTransform(name); 40203 close(); 40204 } 40205 }; 40206 } 40207 ); 40208 return { isLoading: false, commands }; 40209 }; 40210 var getQuickActionsCommands = () => function useQuickActionsCommands() { 40211 const { clientIds, isUngroupable: isUngroupable2, isGroupable: isGroupable2 } = (0, import_data121.useSelect)( 40212 (select3) => { 40213 const { 40214 getSelectedBlockClientIds: getSelectedBlockClientIds2, 40215 isUngroupable: _isUngroupable, 40216 isGroupable: _isGroupable 40217 } = select3(store); 40218 const selectedBlockClientIds = getSelectedBlockClientIds2(); 40219 return { 40220 clientIds: selectedBlockClientIds, 40221 isUngroupable: _isUngroupable(), 40222 isGroupable: _isGroupable() 40223 }; 40224 }, 40225 [] 40226 ); 40227 const { 40228 canInsertBlockType: canInsertBlockType2, 40229 getBlockRootClientId: getBlockRootClientId2, 40230 getBlocksByClientId: getBlocksByClientId2, 40231 canRemoveBlocks: canRemoveBlocks2, 40232 getBlockName: getBlockName2 40233 } = (0, import_data121.useSelect)(store); 40234 const { getDefaultBlockName: getDefaultBlockName7, getGroupingBlockName } = (0, import_data121.useSelect)(import_blocks75.store); 40235 const blocks2 = getBlocksByClientId2(clientIds); 40236 const { 40237 removeBlocks: removeBlocks2, 40238 replaceBlocks: replaceBlocks2, 40239 duplicateBlocks: duplicateBlocks2, 40240 insertAfterBlock: insertAfterBlock2, 40241 insertBeforeBlock: insertBeforeBlock2, 40242 updateBlockAttributes: updateBlockAttributes2 40243 } = (0, import_data121.useDispatch)(store); 40244 const onGroup = () => { 40245 if (!blocks2.length) { 40246 return; 40247 } 40248 const groupingBlockName = getGroupingBlockName(); 40249 const newBlocks = (0, import_blocks75.switchToBlockType)(blocks2, groupingBlockName); 40250 if (!newBlocks) { 40251 return; 40252 } 40253 replaceBlocks2(clientIds, newBlocks); 40254 }; 40255 const onUngroup = () => { 40256 if (!blocks2.length) { 40257 return; 40258 } 40259 const innerBlocks = blocks2[0].innerBlocks; 40260 if (!innerBlocks.length) { 40261 return; 40262 } 40263 replaceBlocks2(clientIds, innerBlocks); 40264 }; 40265 if (!clientIds || clientIds.length < 1) { 40266 return { isLoading: false, commands: [] }; 40267 } 40268 const rootClientId = getBlockRootClientId2(clientIds[0]); 40269 const canInsertDefaultBlock = canInsertBlockType2( 40270 getDefaultBlockName7(), 40271 rootClientId 40272 ); 40273 const canDuplicate = blocks2.every((block) => { 40274 return !!block && (0, import_blocks75.hasBlockSupport)(block.name, "multiple", true) && canInsertBlockType2(block.name, rootClientId); 40275 }); 40276 const canRemove = canRemoveBlocks2(clientIds); 40277 const canToggleBlockVisibility = blocks2.every( 40278 ({ clientId }) => (0, import_blocks75.hasBlockSupport)(getBlockName2(clientId), "visibility", true) 40279 ); 40280 const commands = []; 40281 if (canDuplicate) { 40282 commands.push({ 40283 name: "duplicate", 40284 label: (0, import_i18n102.__)("Duplicate"), 40285 callback: () => duplicateBlocks2(clientIds, true), 40286 icon: copy_default 40287 }); 40288 } 40289 if (canInsertDefaultBlock) { 40290 commands.push( 40291 { 40292 name: "add-before", 40293 label: (0, import_i18n102.__)("Add before"), 40294 callback: () => { 40295 const clientId = Array.isArray(clientIds) ? clientIds[0] : clientId; 40296 insertBeforeBlock2(clientId); 40297 }, 40298 icon: plus_default 40299 }, 40300 { 40301 name: "add-after", 40302 label: (0, import_i18n102.__)("Add after"), 40303 callback: () => { 40304 const clientId = Array.isArray(clientIds) ? clientIds[clientIds.length - 1] : clientId; 40305 insertAfterBlock2(clientId); 40306 }, 40307 icon: plus_default 40308 } 40309 ); 40310 } 40311 if (isGroupable2) { 40312 commands.push({ 40313 name: "Group", 40314 label: (0, import_i18n102.__)("Group"), 40315 callback: onGroup, 40316 icon: group_default 40317 }); 40318 } 40319 if (isUngroupable2) { 40320 commands.push({ 40321 name: "ungroup", 40322 label: (0, import_i18n102.__)("Ungroup"), 40323 callback: onUngroup, 40324 icon: ungroup_default 40325 }); 40326 } 40327 if (canRemove) { 40328 commands.push({ 40329 name: "remove", 40330 label: (0, import_i18n102.__)("Delete"), 40331 callback: () => removeBlocks2(clientIds, true), 40332 icon: trash_default 40333 }); 40334 } 40335 if (canToggleBlockVisibility) { 40336 const hasHiddenBlock = blocks2.some( 40337 (block) => block.attributes.metadata?.blockVisibility === false 40338 ); 40339 commands.push({ 40340 name: "core/toggle-block-visibility", 40341 label: hasHiddenBlock ? (0, import_i18n102.__)("Show") : (0, import_i18n102.__)("Hide"), 40342 callback: () => { 40343 const attributesByClientId = Object.fromEntries( 40344 blocks2?.map(({ clientId, attributes }) => [ 40345 clientId, 40346 { 40347 metadata: cleanEmptyObject({ 40348 ...attributes?.metadata, 40349 blockVisibility: hasHiddenBlock ? void 0 : false 40350 }) 40351 } 40352 ]) 40353 ); 40354 updateBlockAttributes2(clientIds, attributesByClientId, { 40355 uniqueByBlock: true 40356 }); 40357 }, 40358 icon: hasHiddenBlock ? seen_default : unseen_default 40359 }); 40360 } 40361 return { 40362 isLoading: false, 40363 commands: commands.map((command) => ({ 40364 ...command, 40365 name: "core/block-editor/action-" + command.name, 40366 callback: ({ close }) => { 40367 command.callback(); 40368 close(); 40369 } 40370 })) 40371 }; 40372 }; 40373 var useBlockCommands = () => { 40374 (0, import_commands.useCommandLoader)({ 40375 name: "core/block-editor/blockTransforms", 40376 hook: getTransformCommands() 40377 }); 40378 (0, import_commands.useCommandLoader)({ 40379 name: "core/block-editor/blockQuickActions", 40380 hook: getQuickActionsCommands(), 40381 context: "block-selection-edit" 40382 }); 40383 }; 40384 40385 // packages/block-editor/build-module/components/block-canvas/index.js 40386 var import_jsx_runtime256 = __toESM(require_jsx_runtime()); 40387 var EDITOR_STYLE_TRANSFORM_OPTIONS = { 40388 // Don't transform selectors that already specify `.editor-styles-wrapper`. 40389 ignoredSelectors: [/\.editor-styles-wrapper/gi] 40390 }; 40391 function ExperimentalBlockCanvas({ 40392 shouldIframe = true, 40393 height = "300px", 40394 children = /* @__PURE__ */ (0, import_jsx_runtime256.jsx)(BlockList, {}), 40395 styles, 40396 contentRef: contentRefProp, 40397 iframeProps 40398 }) { 40399 useBlockCommands(); 40400 const isTabletViewport = (0, import_compose66.useViewportMatch)("medium", "<"); 40401 const resetTypingRef = useMouseMoveTypingReset(); 40402 const clearerRef = useBlockSelectionClearer(); 40403 const localRef = (0, import_element124.useRef)(); 40404 const contentRef = (0, import_compose66.useMergeRefs)([contentRefProp, clearerRef, localRef]); 40405 const zoomLevel2 = (0, import_data122.useSelect)( 40406 (select3) => unlock(select3(store)).getZoomLevel(), 40407 [] 40408 ); 40409 const zoomOutIframeProps = zoomLevel2 !== 100 && !isTabletViewport ? { 40410 scale: zoomLevel2, 40411 frameSize: "40px" 40412 } : {}; 40413 if (!shouldIframe) { 40414 return /* @__PURE__ */ (0, import_jsx_runtime256.jsxs)( 40415 BlockTools, 40416 { 40417 __unstableContentRef: localRef, 40418 style: { height, display: "flex" }, 40419 children: [ 40420 /* @__PURE__ */ (0, import_jsx_runtime256.jsx)( 40421 editor_styles_default, 40422 { 40423 styles, 40424 scope: ":where(.editor-styles-wrapper)", 40425 transformOptions: EDITOR_STYLE_TRANSFORM_OPTIONS 40426 } 40427 ), 40428 /* @__PURE__ */ (0, import_jsx_runtime256.jsx)( 40429 writing_flow_default, 40430 { 40431 ref: contentRef, 40432 className: "editor-styles-wrapper", 40433 tabIndex: -1, 40434 style: { 40435 height: "100%", 40436 width: "100%" 40437 }, 40438 children 40439 } 40440 ) 40441 ] 40442 } 40443 ); 40444 } 40445 return /* @__PURE__ */ (0, import_jsx_runtime256.jsx)( 40446 BlockTools, 40447 { 40448 __unstableContentRef: localRef, 40449 style: { height, display: "flex" }, 40450 children: /* @__PURE__ */ (0, import_jsx_runtime256.jsxs)( 40451 iframe_default, 40452 { 40453 ...iframeProps, 40454 ...zoomOutIframeProps, 40455 ref: resetTypingRef, 40456 contentRef, 40457 style: { 40458 ...iframeProps?.style 40459 }, 40460 name: "editor-canvas", 40461 children: [ 40462 /* @__PURE__ */ (0, import_jsx_runtime256.jsx)(editor_styles_default, { styles }), 40463 children 40464 ] 40465 } 40466 ) 40467 } 40468 ); 40469 } 40470 function BlockCanvas({ children, height, styles }) { 40471 return /* @__PURE__ */ (0, import_jsx_runtime256.jsx)(ExperimentalBlockCanvas, { height, styles, children }); 40472 } 40473 var block_canvas_default = BlockCanvas; 40474 40475 // packages/block-editor/build-module/components/color-style-selector/index.js 40476 var import_components115 = __toESM(require_components()); 40477 var import_i18n103 = __toESM(require_i18n()); 40478 var import_keycodes11 = __toESM(require_keycodes()); 40479 var import_deprecated13 = __toESM(require_deprecated()); 40480 var import_jsx_runtime257 = __toESM(require_jsx_runtime()); 40481 var ColorSelectorSVGIcon = () => /* @__PURE__ */ (0, import_jsx_runtime257.jsx)(import_components115.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 20 20", children: /* @__PURE__ */ (0, import_jsx_runtime257.jsx)(import_components115.Path, { d: "M7.434 5l3.18 9.16H8.538l-.692-2.184H4.628l-.705 2.184H2L5.18 5h2.254zm-1.13 1.904h-.115l-1.148 3.593H7.44L6.304 6.904zM14.348 7.006c1.853 0 2.9.876 2.9 2.374v4.78h-1.79v-.914h-.114c-.362.64-1.123 1.022-2.031 1.022-1.346 0-2.292-.826-2.292-2.108 0-1.27.972-2.006 2.71-2.107l1.696-.102V9.38c0-.584-.42-.914-1.18-.914-.667 0-1.112.228-1.264.647h-1.701c.12-1.295 1.307-2.107 3.066-2.107zm1.079 4.1l-1.416.09c-.793.056-1.18.342-1.18.844 0 .52.45.837 1.091.837.857 0 1.505-.545 1.505-1.256v-.515z" }) }); 40482 var ColorSelectorIcon = ({ style, className }) => { 40483 return /* @__PURE__ */ (0, import_jsx_runtime257.jsx)("div", { className: "block-library-colors-selector__icon-container", children: /* @__PURE__ */ (0, import_jsx_runtime257.jsx)( 40484 "div", 40485 { 40486 className: `$className} block-library-colors-selector__state-selection`, 40487 style, 40488 children: /* @__PURE__ */ (0, import_jsx_runtime257.jsx)(ColorSelectorSVGIcon, {}) 40489 } 40490 ) }); 40491 }; 40492 var renderToggleComponent = ({ TextColor, BackgroundColor }) => ({ onToggle, isOpen }) => { 40493 const openOnArrowDown = (event) => { 40494 if (!isOpen && event.keyCode === import_keycodes11.DOWN) { 40495 event.preventDefault(); 40496 onToggle(); 40497 } 40498 }; 40499 return /* @__PURE__ */ (0, import_jsx_runtime257.jsx)(import_components115.ToolbarGroup, { children: /* @__PURE__ */ (0, import_jsx_runtime257.jsx)( 40500 import_components115.ToolbarButton, 40501 { 40502 className: "components-toolbar__control block-library-colors-selector__toggle", 40503 label: (0, import_i18n103.__)("Open Colors Selector"), 40504 onClick: onToggle, 40505 onKeyDown: openOnArrowDown, 40506 icon: /* @__PURE__ */ (0, import_jsx_runtime257.jsx)(BackgroundColor, { children: /* @__PURE__ */ (0, import_jsx_runtime257.jsx)(TextColor, { children: /* @__PURE__ */ (0, import_jsx_runtime257.jsx)(ColorSelectorIcon, {}) }) }) 40507 } 40508 ) }); 40509 }; 40510 var BlockColorsStyleSelector = ({ children, ...other }) => { 40511 (0, import_deprecated13.default)(`wp.blockEditor.BlockColorsStyleSelector`, { 40512 alternative: "block supports API", 40513 since: "6.1", 40514 version: "6.3" 40515 }); 40516 return /* @__PURE__ */ (0, import_jsx_runtime257.jsx)( 40517 import_components115.Dropdown, 40518 { 40519 popoverProps: { placement: "bottom-start" }, 40520 className: "block-library-colors-selector", 40521 contentClassName: "block-library-colors-selector__popover", 40522 renderToggle: renderToggleComponent(other), 40523 renderContent: () => children 40524 } 40525 ); 40526 }; 40527 var color_style_selector_default = BlockColorsStyleSelector; 40528 40529 // packages/block-editor/build-module/components/block-navigation/dropdown.js 40530 var import_deprecated15 = __toESM(require_deprecated()); 40531 var import_components122 = __toESM(require_components()); 40532 var import_i18n112 = __toESM(require_i18n()); 40533 var import_data135 = __toESM(require_data()); 40534 var import_element142 = __toESM(require_element()); 40535 40536 // packages/block-editor/build-module/components/list-view/index.js 40537 var import_compose72 = __toESM(require_compose()); 40538 var import_components121 = __toESM(require_components()); 40539 var import_data134 = __toESM(require_data()); 40540 var import_deprecated14 = __toESM(require_deprecated()); 40541 var import_element141 = __toESM(require_element()); 40542 var import_i18n111 = __toESM(require_i18n()); 40543 40544 // packages/block-editor/build-module/components/list-view/branch.js 40545 var import_components119 = __toESM(require_components()); 40546 var import_element134 = __toESM(require_element()); 40547 var import_data127 = __toESM(require_data()); 40548 40549 // packages/block-editor/build-module/components/list-view/appender.js 40550 var import_compose67 = __toESM(require_compose()); 40551 var import_a11y13 = __toESM(require_a11y()); 40552 var import_data123 = __toESM(require_data()); 40553 var import_element127 = __toESM(require_element()); 40554 var import_i18n104 = __toESM(require_i18n()); 40555 40556 // packages/block-editor/build-module/components/list-view/context.js 40557 var import_element125 = __toESM(require_element()); 40558 var ListViewContext = (0, import_element125.createContext)({}); 40559 ListViewContext.displayName = "ListViewContext"; 40560 var useListViewContext = () => (0, import_element125.useContext)(ListViewContext); 40561 40562 // packages/block-editor/build-module/components/list-view/aria-referenced-text.js 40563 var import_element126 = __toESM(require_element()); 40564 var import_jsx_runtime258 = __toESM(require_jsx_runtime()); 40565 function AriaReferencedText({ children, ...props }) { 40566 const ref = (0, import_element126.useRef)(); 40567 (0, import_element126.useEffect)(() => { 40568 if (ref.current) { 40569 ref.current.textContent = ref.current.textContent; 40570 } 40571 }, [children]); 40572 return /* @__PURE__ */ (0, import_jsx_runtime258.jsx)("div", { hidden: true, ...props, ref, children }); 40573 } 40574 40575 // packages/block-editor/build-module/components/list-view/appender.js 40576 var import_jsx_runtime259 = __toESM(require_jsx_runtime()); 40577 var Appender = (0, import_element127.forwardRef)( 40578 ({ nestingLevel, blockCount, clientId, ...props }, ref) => { 40579 const { insertedBlock, setInsertedBlock } = useListViewContext(); 40580 const instanceId = (0, import_compose67.useInstanceId)(Appender); 40581 const { directInsert, hideInserter } = (0, import_data123.useSelect)( 40582 (select3) => { 40583 const { getBlockListSettings: getBlockListSettings2, getTemplateLock: getTemplateLock2, isZoomOut: isZoomOut2 } = unlock(select3(store)); 40584 const settings2 = getBlockListSettings2(clientId); 40585 const directInsertValue = settings2?.directInsert || false; 40586 const hideInserterValue = !!getTemplateLock2(clientId) || isZoomOut2(); 40587 return { 40588 directInsert: directInsertValue, 40589 hideInserter: hideInserterValue 40590 }; 40591 }, 40592 [clientId] 40593 ); 40594 const blockTitle = useBlockDisplayTitle({ 40595 clientId, 40596 context: "list-view" 40597 }); 40598 const insertedBlockTitle = useBlockDisplayTitle({ 40599 clientId: insertedBlock?.clientId, 40600 context: "list-view" 40601 }); 40602 (0, import_element127.useEffect)(() => { 40603 if (!insertedBlockTitle?.length) { 40604 return; 40605 } 40606 (0, import_a11y13.speak)( 40607 (0, import_i18n104.sprintf)( 40608 // translators: %s: name of block being inserted (i.e. Paragraph, Image, Group etc) 40609 (0, import_i18n104.__)("%s block inserted"), 40610 insertedBlockTitle 40611 ), 40612 "assertive" 40613 ); 40614 }, [insertedBlockTitle]); 40615 if (hideInserter) { 40616 return null; 40617 } 40618 const descriptionId = `list-view-appender__$instanceId}`; 40619 const description = (0, import_i18n104.sprintf)( 40620 /* translators: 1: The name of the block. 2: The numerical position of the block. 3: The level of nesting for the block. */ 40621 (0, import_i18n104.__)("Append to %1$s block at position %2$d, Level %3$d"), 40622 blockTitle, 40623 blockCount + 1, 40624 nestingLevel 40625 ); 40626 return /* @__PURE__ */ (0, import_jsx_runtime259.jsxs)("div", { className: "list-view-appender", children: [ 40627 /* @__PURE__ */ (0, import_jsx_runtime259.jsx)( 40628 inserter_default, 40629 { 40630 ref, 40631 rootClientId: clientId, 40632 position: "bottom right", 40633 isAppender: true, 40634 selectBlockOnInsert: false, 40635 shouldDirectInsert: directInsert, 40636 __experimentalIsQuick: true, 40637 ...props, 40638 toggleProps: { "aria-describedby": descriptionId }, 40639 onSelectOrClose: (maybeInsertedBlock) => { 40640 if (maybeInsertedBlock?.clientId) { 40641 setInsertedBlock(maybeInsertedBlock); 40642 } 40643 } 40644 } 40645 ), 40646 /* @__PURE__ */ (0, import_jsx_runtime259.jsx)(AriaReferencedText, { id: descriptionId, children: description }) 40647 ] }); 40648 } 40649 ); 40650 40651 // packages/block-editor/build-module/components/list-view/block.js 40652 var import_blocks77 = __toESM(require_blocks()); 40653 var import_components118 = __toESM(require_components()); 40654 var import_compose69 = __toESM(require_compose()); 40655 var import_element133 = __toESM(require_element()); 40656 var import_data126 = __toESM(require_data()); 40657 var import_i18n107 = __toESM(require_i18n()); 40658 var import_keycodes13 = __toESM(require_keycodes()); 40659 var import_is_shallow_equal2 = __toESM(require_is_shallow_equal()); 40660 var import_keyboard_shortcuts9 = __toESM(require_keyboard_shortcuts()); 40661 var import_a11y14 = __toESM(require_a11y()); 40662 40663 // packages/block-editor/build-module/components/list-view/leaf.js 40664 var import_components116 = __toESM(require_components()); 40665 var import_compose68 = __toESM(require_compose()); 40666 var import_element128 = __toESM(require_element()); 40667 var import_jsx_runtime260 = __toESM(require_jsx_runtime()); 40668 var AnimatedTreeGridRow = animated(import_components116.__experimentalTreeGridRow); 40669 var ListViewLeaf = (0, import_element128.forwardRef)( 40670 ({ 40671 isDragged, 40672 isSelected, 40673 position, 40674 level, 40675 rowCount, 40676 children, 40677 className, 40678 path, 40679 ...props 40680 }, ref) => { 40681 const animationRef = use_moving_animation_default({ 40682 clientId: props["data-block"], 40683 enableAnimation: true, 40684 triggerAnimationOnChange: path 40685 }); 40686 const mergedRef = (0, import_compose68.useMergeRefs)([ref, animationRef]); 40687 return /* @__PURE__ */ (0, import_jsx_runtime260.jsx)( 40688 AnimatedTreeGridRow, 40689 { 40690 ref: mergedRef, 40691 className: clsx_default("block-editor-list-view-leaf", className), 40692 level, 40693 positionInSet: position, 40694 setSize: rowCount, 40695 isExpanded: void 0, 40696 ...props, 40697 children 40698 } 40699 ); 40700 } 40701 ); 40702 var leaf_default = ListViewLeaf; 40703 40704 // packages/block-editor/build-module/components/list-view/use-list-view-scroll-into-view.js 40705 var import_dom29 = __toESM(require_dom()); 40706 var import_element129 = __toESM(require_element()); 40707 function useListViewScrollIntoView({ 40708 isSelected, 40709 selectedClientIds, 40710 rowItemRef 40711 }) { 40712 const isSingleSelection = selectedClientIds.length === 1; 40713 (0, import_element129.useLayoutEffect)(() => { 40714 if (!isSelected || !isSingleSelection || !rowItemRef.current) { 40715 return; 40716 } 40717 const scrollContainer = (0, import_dom29.getScrollContainer)(rowItemRef.current); 40718 const { ownerDocument } = rowItemRef.current; 40719 const windowScroll = scrollContainer === ownerDocument.body || scrollContainer === ownerDocument.documentElement; 40720 if (windowScroll || !scrollContainer) { 40721 return; 40722 } 40723 const rowRect = rowItemRef.current.getBoundingClientRect(); 40724 const scrollContainerRect = scrollContainer.getBoundingClientRect(); 40725 if (rowRect.top < scrollContainerRect.top || rowRect.bottom > scrollContainerRect.bottom) { 40726 rowItemRef.current.scrollIntoView(); 40727 } 40728 }, [isSelected, isSingleSelection, rowItemRef]); 40729 } 40730 40731 // packages/block-editor/build-module/components/list-view/block-contents.js 40732 var import_element132 = __toESM(require_element()); 40733 40734 // packages/block-editor/build-module/components/list-view/block-select-button.js 40735 var import_components117 = __toESM(require_components()); 40736 var import_element131 = __toESM(require_element()); 40737 var import_keycodes12 = __toESM(require_keycodes()); 40738 var import_data125 = __toESM(require_data()); 40739 var import_blocks76 = __toESM(require_blocks()); 40740 40741 // packages/block-editor/build-module/components/list-view/expander.js 40742 var import_i18n105 = __toESM(require_i18n()); 40743 var import_jsx_runtime261 = __toESM(require_jsx_runtime()); 40744 function ListViewExpander({ onClick }) { 40745 return ( 40746 // Keyboard events are handled by TreeGrid see: components/src/tree-grid/index.js 40747 // 40748 // The expander component is implemented as a pseudo element in the w3 example 40749 // https://www.w3.org/TR/wai-aria-practices/examples/treegrid/treegrid-1.html 40750 // 40751 // We've mimicked this by adding an icon with aria-hidden set to true to hide this from the accessibility tree. 40752 // For the current tree grid implementation, please do not try to make this a button. 40753 /* @__PURE__ */ (0, import_jsx_runtime261.jsx)( 40754 "span", 40755 { 40756 className: "block-editor-list-view__expander", 40757 onClick: (event) => onClick(event, { forceToggle: true }), 40758 "aria-hidden": "true", 40759 "data-testid": "list-view-expander", 40760 children: /* @__PURE__ */ (0, import_jsx_runtime261.jsx)(icon_default, { icon: (0, import_i18n105.isRTL)() ? chevron_left_small_default : chevron_right_small_default }) 40761 } 40762 ) 40763 ); 40764 } 40765 40766 // packages/block-editor/build-module/components/list-view/use-list-view-images.js 40767 var import_element130 = __toESM(require_element()); 40768 var import_data124 = __toESM(require_data()); 40769 var MAX_IMAGES = 3; 40770 var IMAGE_GETTERS = { 40771 "core/image": ({ clientId, attributes }) => { 40772 if (attributes.url) { 40773 return { 40774 url: attributes.url, 40775 alt: attributes.alt || "", 40776 clientId 40777 }; 40778 } 40779 }, 40780 "core/cover": ({ clientId, attributes }) => { 40781 if (attributes.backgroundType === "image" && attributes.url) { 40782 return { 40783 url: attributes.url, 40784 alt: attributes.alt || "", 40785 clientId 40786 }; 40787 } 40788 }, 40789 "core/media-text": ({ clientId, attributes }) => { 40790 if (attributes.mediaType === "image" && attributes.mediaUrl) { 40791 return { 40792 url: attributes.mediaUrl, 40793 alt: attributes.mediaAlt || "", 40794 clientId 40795 }; 40796 } 40797 }, 40798 "core/gallery": ({ innerBlocks }) => { 40799 const images = []; 40800 const getValues = !!innerBlocks?.length ? IMAGE_GETTERS[innerBlocks[0].name] : void 0; 40801 if (!getValues) { 40802 return images; 40803 } 40804 for (const innerBlock of innerBlocks) { 40805 const img = getValues(innerBlock); 40806 if (img) { 40807 images.push(img); 40808 } 40809 if (images.length >= MAX_IMAGES) { 40810 return images; 40811 } 40812 } 40813 return images; 40814 } 40815 }; 40816 function getImagesFromBlock(block, isExpanded) { 40817 const getImages = IMAGE_GETTERS[block.name]; 40818 const images = !!getImages ? getImages(block) : void 0; 40819 if (!images) { 40820 return []; 40821 } 40822 if (!Array.isArray(images)) { 40823 return [images]; 40824 } 40825 return isExpanded ? [] : images; 40826 } 40827 function useListViewImages({ clientId, isExpanded }) { 40828 const { block } = (0, import_data124.useSelect)( 40829 (select3) => { 40830 return { block: select3(store).getBlock(clientId) }; 40831 }, 40832 [clientId] 40833 ); 40834 const images = (0, import_element130.useMemo)(() => { 40835 return getImagesFromBlock(block, isExpanded); 40836 }, [block, isExpanded]); 40837 return images; 40838 } 40839 40840 // packages/block-editor/build-module/components/list-view/block-select-button.js 40841 var import_jsx_runtime262 = __toESM(require_jsx_runtime()); 40842 var { Badge: Badge2 } = unlock(import_components117.privateApis); 40843 function ListViewBlockSelectButton({ 40844 className, 40845 block: { clientId }, 40846 onClick, 40847 onContextMenu, 40848 onMouseDown, 40849 onToggleExpanded, 40850 tabIndex, 40851 onFocus, 40852 onDragStart, 40853 onDragEnd, 40854 draggable, 40855 isExpanded, 40856 ariaDescribedBy 40857 }, ref) { 40858 const blockInformation = useBlockDisplayInformation(clientId); 40859 const blockTitle = useBlockDisplayTitle({ 40860 clientId, 40861 context: "list-view" 40862 }); 40863 const { isLocked } = useBlockLock(clientId); 40864 const { canToggleBlockVisibility, isBlockHidden: isBlockHidden2, hasPatternName } = (0, import_data125.useSelect)( 40865 (select3) => { 40866 const { getBlockName: getBlockName2, getBlockAttributes: getBlockAttributes3 } = select3(store); 40867 const { isBlockHidden: _isBlockHidden } = unlock( 40868 select3(store) 40869 ); 40870 const blockAttributes = getBlockAttributes3(clientId); 40871 return { 40872 canToggleBlockVisibility: (0, import_blocks76.hasBlockSupport)( 40873 getBlockName2(clientId), 40874 "visibility", 40875 true 40876 ), 40877 isBlockHidden: _isBlockHidden(clientId), 40878 hasPatternName: !!blockAttributes?.metadata?.patternName 40879 }; 40880 }, 40881 [clientId] 40882 ); 40883 const shouldShowLockIcon = isLocked; 40884 const shouldShowBlockVisibilityIcon = canToggleBlockVisibility && isBlockHidden2; 40885 const isSticky = blockInformation?.positionType === "sticky"; 40886 const images = useListViewImages({ clientId, isExpanded }); 40887 const onDragStartHandler = (event) => { 40888 event.dataTransfer.clearData(); 40889 onDragStart?.(event); 40890 }; 40891 function onKeyDown(event) { 40892 if (event.keyCode === import_keycodes12.ENTER || event.keyCode === import_keycodes12.SPACE) { 40893 onClick(event); 40894 } 40895 } 40896 return /* @__PURE__ */ (0, import_jsx_runtime262.jsxs)( 40897 "a", 40898 { 40899 className: clsx_default( 40900 "block-editor-list-view-block-select-button", 40901 className 40902 ), 40903 onClick, 40904 onContextMenu, 40905 onKeyDown, 40906 onMouseDown, 40907 ref, 40908 tabIndex, 40909 onFocus, 40910 onDragStart: onDragStartHandler, 40911 onDragEnd, 40912 draggable, 40913 href: `#block-$clientId}`, 40914 "aria-describedby": ariaDescribedBy, 40915 "aria-expanded": isExpanded, 40916 children: [ 40917 /* @__PURE__ */ (0, import_jsx_runtime262.jsx)(ListViewExpander, { onClick: onToggleExpanded }), 40918 /* @__PURE__ */ (0, import_jsx_runtime262.jsx)( 40919 block_icon_default, 40920 { 40921 icon: hasPatternName ? symbol_default : blockInformation?.icon, 40922 showColors: true, 40923 context: "list-view" 40924 } 40925 ), 40926 /* @__PURE__ */ (0, import_jsx_runtime262.jsxs)( 40927 import_components117.__experimentalHStack, 40928 { 40929 alignment: "center", 40930 className: "block-editor-list-view-block-select-button__label-wrapper", 40931 justify: "flex-start", 40932 spacing: 1, 40933 children: [ 40934 /* @__PURE__ */ (0, import_jsx_runtime262.jsx)("span", { className: "block-editor-list-view-block-select-button__title", children: /* @__PURE__ */ (0, import_jsx_runtime262.jsx)(import_components117.__experimentalTruncate, { ellipsizeMode: "auto", children: blockTitle }) }), 40935 blockInformation?.anchor && /* @__PURE__ */ (0, import_jsx_runtime262.jsx)("span", { className: "block-editor-list-view-block-select-button__anchor-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime262.jsx)(Badge2, { className: "block-editor-list-view-block-select-button__anchor", children: blockInformation.anchor }) }), 40936 isSticky && /* @__PURE__ */ (0, import_jsx_runtime262.jsx)("span", { className: "block-editor-list-view-block-select-button__sticky", children: /* @__PURE__ */ (0, import_jsx_runtime262.jsx)(icon_default, { icon: pin_small_default }) }), 40937 images.length ? /* @__PURE__ */ (0, import_jsx_runtime262.jsx)( 40938 "span", 40939 { 40940 className: "block-editor-list-view-block-select-button__images", 40941 "aria-hidden": true, 40942 children: images.map((image, index) => /* @__PURE__ */ (0, import_jsx_runtime262.jsx)( 40943 "span", 40944 { 40945 className: "block-editor-list-view-block-select-button__image", 40946 style: { 40947 backgroundImage: `url($image.url})`, 40948 zIndex: images.length - index 40949 // Ensure the first image is on top, and subsequent images are behind. 40950 } 40951 }, 40952 image.clientId 40953 )) 40954 } 40955 ) : null, 40956 shouldShowBlockVisibilityIcon && /* @__PURE__ */ (0, import_jsx_runtime262.jsx)("span", { className: "block-editor-list-view-block-select-button__block-visibility", children: /* @__PURE__ */ (0, import_jsx_runtime262.jsx)(icon_default, { icon: unseen_default }) }), 40957 shouldShowLockIcon && /* @__PURE__ */ (0, import_jsx_runtime262.jsx)("span", { className: "block-editor-list-view-block-select-button__lock", children: /* @__PURE__ */ (0, import_jsx_runtime262.jsx)(icon_default, { icon: lock_small_default }) }) 40958 ] 40959 } 40960 ) 40961 ] 40962 } 40963 ); 40964 } 40965 var block_select_button_default = (0, import_element131.forwardRef)(ListViewBlockSelectButton); 40966 40967 // packages/block-editor/build-module/components/list-view/block-contents.js 40968 var import_jsx_runtime263 = __toESM(require_jsx_runtime()); 40969 var ListViewBlockContents = (0, import_element132.forwardRef)( 40970 ({ 40971 onClick, 40972 onToggleExpanded, 40973 block, 40974 isSelected, 40975 position, 40976 siblingBlockCount, 40977 level, 40978 isExpanded, 40979 selectedClientIds, 40980 ...props 40981 }, ref) => { 40982 const { clientId } = block; 40983 const { AdditionalBlockContent, insertedBlock, setInsertedBlock } = useListViewContext(); 40984 const draggableClientIds = selectedClientIds.includes(clientId) ? selectedClientIds : [clientId]; 40985 return /* @__PURE__ */ (0, import_jsx_runtime263.jsxs)(import_jsx_runtime263.Fragment, { children: [ 40986 AdditionalBlockContent && /* @__PURE__ */ (0, import_jsx_runtime263.jsx)( 40987 AdditionalBlockContent, 40988 { 40989 block, 40990 insertedBlock, 40991 setInsertedBlock 40992 } 40993 ), 40994 /* @__PURE__ */ (0, import_jsx_runtime263.jsx)( 40995 block_draggable_default, 40996 { 40997 appendToOwnerDocument: true, 40998 clientIds: draggableClientIds, 40999 cloneClassname: "block-editor-list-view-draggable-chip", 41000 children: ({ draggable, onDragStart, onDragEnd }) => /* @__PURE__ */ (0, import_jsx_runtime263.jsx)( 41001 block_select_button_default, 41002 { 41003 ref, 41004 className: "block-editor-list-view-block-contents", 41005 block, 41006 onClick, 41007 onToggleExpanded, 41008 isSelected, 41009 position, 41010 siblingBlockCount, 41011 level, 41012 draggable, 41013 onDragStart, 41014 onDragEnd, 41015 isExpanded, 41016 ...props 41017 } 41018 ) 41019 } 41020 ) 41021 ] }); 41022 } 41023 ); 41024 var block_contents_default = ListViewBlockContents; 41025 41026 // packages/block-editor/build-module/components/list-view/utils.js 41027 var import_i18n106 = __toESM(require_i18n()); 41028 var import_dom30 = __toESM(require_dom()); 41029 var getBlockPositionDescription = (position, siblingCount, level) => (0, import_i18n106.sprintf)( 41030 /* translators: 1: The numerical position of the block. 2: The total number of blocks. 3. The level of nesting for the block. */ 41031 (0, import_i18n106.__)("Block %1$d of %2$d, Level %3$d."), 41032 position, 41033 siblingCount, 41034 level 41035 ); 41036 var getBlockPropertiesDescription = (blockInformation, isLocked) => [ 41037 blockInformation?.positionLabel ? `${(0, import_i18n106.sprintf)( 41038 // translators: %s: Position of selected block, e.g. "Sticky" or "Fixed". 41039 (0, import_i18n106.__)("Position: %s"), 41040 blockInformation.positionLabel 41041 )}.` : void 0, 41042 isLocked ? (0, import_i18n106.__)("This block is locked.") : void 0 41043 ].filter(Boolean).join(" "); 41044 var isClientIdSelected = (clientId, selectedBlockClientIds) => Array.isArray(selectedBlockClientIds) && selectedBlockClientIds.length ? selectedBlockClientIds.indexOf(clientId) !== -1 : selectedBlockClientIds === clientId; 41045 function getCommonDepthClientIds(startId, endId, startParents, endParents) { 41046 const startPath = [...startParents, startId]; 41047 const endPath = [...endParents, endId]; 41048 const depth = Math.min(startPath.length, endPath.length) - 1; 41049 const start2 = startPath[depth]; 41050 const end = endPath[depth]; 41051 return { 41052 start: start2, 41053 end 41054 }; 41055 } 41056 function focusListItem(focusClientId, treeGridElement) { 41057 const getFocusElement = () => { 41058 const row = treeGridElement?.querySelector( 41059 `[role=row][data-block="$focusClientId}"]` 41060 ); 41061 if (!row) { 41062 return null; 41063 } 41064 return import_dom30.focus.focusable.find(row)[0]; 41065 }; 41066 let focusElement = getFocusElement(); 41067 if (focusElement) { 41068 focusElement.focus(); 41069 } else { 41070 window.requestAnimationFrame(() => { 41071 focusElement = getFocusElement(); 41072 if (focusElement) { 41073 focusElement.focus(); 41074 } 41075 }); 41076 } 41077 } 41078 function getDragDisplacementValues({ 41079 blockIndexes, 41080 blockDropTargetIndex, 41081 blockDropPosition, 41082 clientId, 41083 firstDraggedBlockIndex, 41084 isDragged 41085 }) { 41086 let displacement; 41087 let isNesting; 41088 let isAfterDraggedBlocks; 41089 if (!isDragged) { 41090 isNesting = false; 41091 const thisBlockIndex = blockIndexes[clientId]; 41092 isAfterDraggedBlocks = thisBlockIndex > firstDraggedBlockIndex; 41093 if (blockDropTargetIndex !== void 0 && blockDropTargetIndex !== null && firstDraggedBlockIndex !== void 0) { 41094 if (thisBlockIndex !== void 0) { 41095 if (thisBlockIndex >= firstDraggedBlockIndex && thisBlockIndex < blockDropTargetIndex) { 41096 displacement = "up"; 41097 } else if (thisBlockIndex < firstDraggedBlockIndex && thisBlockIndex >= blockDropTargetIndex) { 41098 displacement = "down"; 41099 } else { 41100 displacement = "normal"; 41101 } 41102 isNesting = typeof blockDropTargetIndex === "number" && blockDropTargetIndex - 1 === thisBlockIndex && blockDropPosition === "inside"; 41103 } 41104 } else if (blockDropTargetIndex === null && firstDraggedBlockIndex !== void 0) { 41105 if (thisBlockIndex !== void 0 && thisBlockIndex >= firstDraggedBlockIndex) { 41106 displacement = "up"; 41107 } else { 41108 displacement = "normal"; 41109 } 41110 } else if (blockDropTargetIndex !== void 0 && blockDropTargetIndex !== null && firstDraggedBlockIndex === void 0) { 41111 if (thisBlockIndex !== void 0) { 41112 if (thisBlockIndex < blockDropTargetIndex) { 41113 displacement = "normal"; 41114 } else { 41115 displacement = "down"; 41116 } 41117 } 41118 } else if (blockDropTargetIndex === null) { 41119 displacement = "normal"; 41120 } 41121 } 41122 return { 41123 displacement, 41124 isNesting, 41125 isAfterDraggedBlocks 41126 }; 41127 } 41128 41129 // packages/block-editor/build-module/components/list-view/block.js 41130 var import_jsx_runtime264 = __toESM(require_jsx_runtime()); 41131 function ListViewBlock({ 41132 block: { clientId }, 41133 displacement, 41134 isAfterDraggedBlocks, 41135 isDragged, 41136 isNesting, 41137 isSelected, 41138 isBranchSelected, 41139 selectBlock: selectBlock2, 41140 position, 41141 level, 41142 rowCount, 41143 siblingBlockCount, 41144 showBlockMovers, 41145 path, 41146 isExpanded, 41147 selectedClientIds, 41148 isSyncedBranch 41149 }) { 41150 const cellRef = (0, import_element133.useRef)(null); 41151 const rowRef = (0, import_element133.useRef)(null); 41152 const settingsRef = (0, import_element133.useRef)(null); 41153 const [isHovered, setIsHovered] = (0, import_element133.useState)(false); 41154 const [settingsAnchorRect, setSettingsAnchorRect] = (0, import_element133.useState)(); 41155 const { isLocked } = useBlockLock(clientId); 41156 const isFirstSelectedBlock = isSelected && selectedClientIds[0] === clientId; 41157 const isLastSelectedBlock = isSelected && selectedClientIds[selectedClientIds.length - 1] === clientId; 41158 const { 41159 toggleBlockHighlight: toggleBlockHighlight2, 41160 duplicateBlocks: duplicateBlocks2, 41161 multiSelect: multiSelect2, 41162 replaceBlocks: replaceBlocks2, 41163 removeBlocks: removeBlocks2, 41164 insertAfterBlock: insertAfterBlock2, 41165 insertBeforeBlock: insertBeforeBlock2, 41166 setOpenedBlockSettingsMenu: setOpenedBlockSettingsMenu2, 41167 updateBlockAttributes: updateBlockAttributes2 41168 } = unlock((0, import_data126.useDispatch)(store)); 41169 const debouncedToggleBlockHighlight = (0, import_compose69.useDebounce)( 41170 toggleBlockHighlight2, 41171 50 41172 ); 41173 const { 41174 canInsertBlockType: canInsertBlockType2, 41175 getSelectedBlockClientIds: getSelectedBlockClientIds2, 41176 getPreviousBlockClientId: getPreviousBlockClientId2, 41177 getBlockRootClientId: getBlockRootClientId2, 41178 getBlockOrder: getBlockOrder2, 41179 getBlockParents: getBlockParents2, 41180 getBlocksByClientId: getBlocksByClientId2, 41181 canEditBlock: canEditBlock2, 41182 canMoveBlock: canMoveBlock2, 41183 canRemoveBlocks: canRemoveBlocks2, 41184 isGroupable: isGroupable2 41185 } = (0, import_data126.useSelect)(store); 41186 const { getGroupingBlockName } = (0, import_data126.useSelect)(import_blocks77.store); 41187 const blockInformation = useBlockDisplayInformation(clientId); 41188 const pasteStyles = usePasteStyles(); 41189 const { block, blockName, allowRightClickOverrides, isBlockHidden: isBlockHidden2 } = (0, import_data126.useSelect)( 41190 (select3) => { 41191 const { getBlock: getBlock2, getBlockName: getBlockName2, getSettings: getSettings8 } = select3(store); 41192 const { isBlockHidden: _isBlockHidden } = unlock( 41193 select3(store) 41194 ); 41195 return { 41196 block: getBlock2(clientId), 41197 blockName: getBlockName2(clientId), 41198 allowRightClickOverrides: getSettings8().allowRightClickOverrides, 41199 isBlockHidden: _isBlockHidden(clientId) 41200 }; 41201 }, 41202 [clientId] 41203 ); 41204 const showBlockActions = ( 41205 // When a block hides its toolbar it also hides the block settings menu, 41206 // since that menu is part of the toolbar in the editor canvas. 41207 // List View respects this by also hiding the block settings menu. 41208 (0, import_blocks77.hasBlockSupport)(blockName, "__experimentalToolbar", true) 41209 ); 41210 const instanceId = (0, import_compose69.useInstanceId)(ListViewBlock); 41211 const descriptionId = `list-view-block-select-button__description-$instanceId}`; 41212 const { 41213 expand, 41214 collapse, 41215 collapseAll, 41216 BlockSettingsMenu: BlockSettingsMenu2, 41217 listViewInstanceId, 41218 expandedState, 41219 setInsertedBlock, 41220 treeGridElementRef, 41221 rootClientId 41222 } = useListViewContext(); 41223 const isMatch = (0, import_keyboard_shortcuts9.__unstableUseShortcutEventMatch)(); 41224 function getBlocksToUpdate() { 41225 const selectedBlockClientIds = getSelectedBlockClientIds2(); 41226 const isUpdatingSelectedBlocks = selectedBlockClientIds.includes(clientId); 41227 const firstBlockClientId = isUpdatingSelectedBlocks ? selectedBlockClientIds[0] : clientId; 41228 const firstBlockRootClientId = getBlockRootClientId2(firstBlockClientId); 41229 const blocksToUpdate = isUpdatingSelectedBlocks ? selectedBlockClientIds : [clientId]; 41230 return { 41231 blocksToUpdate, 41232 firstBlockClientId, 41233 firstBlockRootClientId, 41234 selectedBlockClientIds 41235 }; 41236 } 41237 async function onKeyDown(event) { 41238 if (event.defaultPrevented) { 41239 return; 41240 } 41241 if (event.target.closest("[role=dialog]")) { 41242 return; 41243 } 41244 const isDeleteKey = [import_keycodes13.BACKSPACE, import_keycodes13.DELETE].includes(event.keyCode); 41245 if (isMatch("core/block-editor/unselect", event) && selectedClientIds.length > 0) { 41246 event.stopPropagation(); 41247 event.preventDefault(); 41248 selectBlock2(event, void 0); 41249 } else if (isDeleteKey || isMatch("core/block-editor/remove", event)) { 41250 const { 41251 blocksToUpdate: blocksToDelete, 41252 firstBlockClientId, 41253 firstBlockRootClientId, 41254 selectedBlockClientIds 41255 } = getBlocksToUpdate(); 41256 if (!canRemoveBlocks2(blocksToDelete)) { 41257 return; 41258 } 41259 let blockToFocus = getPreviousBlockClientId2(firstBlockClientId) ?? // If the previous block is not found (when the first block is deleted), 41260 // fallback to focus the parent block. 41261 firstBlockRootClientId; 41262 removeBlocks2(blocksToDelete, false); 41263 const shouldUpdateSelection = selectedBlockClientIds.length > 0 && getSelectedBlockClientIds2().length === 0; 41264 if (!blockToFocus) { 41265 blockToFocus = getBlockOrder2()[0]; 41266 } 41267 updateFocusAndSelection(blockToFocus, shouldUpdateSelection); 41268 } else if (isMatch("core/block-editor/paste-styles", event)) { 41269 event.preventDefault(); 41270 const { blocksToUpdate } = getBlocksToUpdate(); 41271 const blocks2 = getBlocksByClientId2(blocksToUpdate); 41272 pasteStyles(blocks2); 41273 } else if (isMatch("core/block-editor/duplicate", event)) { 41274 event.preventDefault(); 41275 const { blocksToUpdate, firstBlockRootClientId } = getBlocksToUpdate(); 41276 const canDuplicate = getBlocksByClientId2(blocksToUpdate).every( 41277 (blockToUpdate) => { 41278 return !!blockToUpdate && (0, import_blocks77.hasBlockSupport)( 41279 blockToUpdate.name, 41280 "multiple", 41281 true 41282 ) && canInsertBlockType2( 41283 blockToUpdate.name, 41284 firstBlockRootClientId 41285 ); 41286 } 41287 ); 41288 if (canDuplicate) { 41289 const updatedBlocks = await duplicateBlocks2( 41290 blocksToUpdate, 41291 false 41292 ); 41293 if (updatedBlocks?.length) { 41294 updateFocusAndSelection(updatedBlocks[0], false); 41295 } 41296 } 41297 } else if (isMatch("core/block-editor/insert-before", event)) { 41298 event.preventDefault(); 41299 const { blocksToUpdate } = getBlocksToUpdate(); 41300 await insertBeforeBlock2(blocksToUpdate[0]); 41301 const newlySelectedBlocks = getSelectedBlockClientIds2(); 41302 setOpenedBlockSettingsMenu2(void 0); 41303 updateFocusAndSelection(newlySelectedBlocks[0], false); 41304 } else if (isMatch("core/block-editor/insert-after", event)) { 41305 event.preventDefault(); 41306 const { blocksToUpdate } = getBlocksToUpdate(); 41307 await insertAfterBlock2(blocksToUpdate.at(-1)); 41308 const newlySelectedBlocks = getSelectedBlockClientIds2(); 41309 setOpenedBlockSettingsMenu2(void 0); 41310 updateFocusAndSelection(newlySelectedBlocks[0], false); 41311 } else if (isMatch("core/block-editor/select-all", event)) { 41312 event.preventDefault(); 41313 const { firstBlockRootClientId, selectedBlockClientIds } = getBlocksToUpdate(); 41314 const blockClientIds = getBlockOrder2(firstBlockRootClientId); 41315 if (!blockClientIds.length) { 41316 return; 41317 } 41318 if ((0, import_is_shallow_equal2.default)(selectedBlockClientIds, blockClientIds)) { 41319 if (firstBlockRootClientId && firstBlockRootClientId !== rootClientId) { 41320 updateFocusAndSelection(firstBlockRootClientId, true); 41321 return; 41322 } 41323 } 41324 multiSelect2( 41325 blockClientIds[0], 41326 blockClientIds[blockClientIds.length - 1], 41327 null 41328 ); 41329 } else if (isMatch("core/block-editor/collapse-list-view", event)) { 41330 event.preventDefault(); 41331 const { firstBlockClientId } = getBlocksToUpdate(); 41332 const blockParents = getBlockParents2(firstBlockClientId, false); 41333 collapseAll(); 41334 expand(blockParents); 41335 } else if (isMatch("core/block-editor/group", event)) { 41336 const { blocksToUpdate } = getBlocksToUpdate(); 41337 if (blocksToUpdate.length > 1 && isGroupable2(blocksToUpdate)) { 41338 event.preventDefault(); 41339 const blocks2 = getBlocksByClientId2(blocksToUpdate); 41340 const groupingBlockName = getGroupingBlockName(); 41341 const newBlocks = (0, import_blocks77.switchToBlockType)( 41342 blocks2, 41343 groupingBlockName 41344 ); 41345 replaceBlocks2(blocksToUpdate, newBlocks); 41346 (0, import_a11y14.speak)((0, import_i18n107.__)("Selected blocks are grouped.")); 41347 const newlySelectedBlocks = getSelectedBlockClientIds2(); 41348 setOpenedBlockSettingsMenu2(void 0); 41349 updateFocusAndSelection(newlySelectedBlocks[0], false); 41350 } 41351 } else if (isMatch("core/block-editor/toggle-block-visibility", event)) { 41352 event.preventDefault(); 41353 const { blocksToUpdate } = getBlocksToUpdate(); 41354 const blocks2 = getBlocksByClientId2(blocksToUpdate); 41355 const canToggleVisibility = blocks2.every( 41356 (blockToUpdate) => (0, import_blocks77.hasBlockSupport)(blockToUpdate.name, "visibility", true) 41357 ); 41358 if (!canToggleVisibility) { 41359 return; 41360 } 41361 const hasHiddenBlock = blocks2.some( 41362 (blockToUpdate) => blockToUpdate.attributes.metadata?.blockVisibility === false 41363 ); 41364 const attributesByClientId = Object.fromEntries( 41365 blocks2.map(({ clientId: mapClientId, attributes }) => [ 41366 mapClientId, 41367 { 41368 metadata: cleanEmptyObject({ 41369 ...attributes?.metadata, 41370 blockVisibility: hasHiddenBlock ? void 0 : false 41371 }) 41372 } 41373 ]) 41374 ); 41375 updateBlockAttributes2(blocksToUpdate, attributesByClientId, { 41376 uniqueByBlock: true 41377 }); 41378 } 41379 } 41380 const onMouseEnter = (0, import_element133.useCallback)(() => { 41381 setIsHovered(true); 41382 debouncedToggleBlockHighlight(clientId, true); 41383 }, [clientId, setIsHovered, debouncedToggleBlockHighlight]); 41384 const onMouseLeave = (0, import_element133.useCallback)(() => { 41385 setIsHovered(false); 41386 debouncedToggleBlockHighlight(clientId, false); 41387 }, [clientId, setIsHovered, debouncedToggleBlockHighlight]); 41388 const selectEditorBlock = (0, import_element133.useCallback)( 41389 (event) => { 41390 selectBlock2(event, clientId); 41391 event.preventDefault(); 41392 }, 41393 [clientId, selectBlock2] 41394 ); 41395 const updateFocusAndSelection = (0, import_element133.useCallback)( 41396 (focusClientId, shouldSelectBlock) => { 41397 if (shouldSelectBlock) { 41398 selectBlock2(void 0, focusClientId, null, null); 41399 } 41400 focusListItem(focusClientId, treeGridElementRef?.current); 41401 }, 41402 [selectBlock2, treeGridElementRef] 41403 ); 41404 const toggleExpanded = (0, import_element133.useCallback)( 41405 (event) => { 41406 event.preventDefault(); 41407 event.stopPropagation(); 41408 if (isExpanded === true) { 41409 collapse(clientId); 41410 } else if (isExpanded === false) { 41411 expand(clientId); 41412 } 41413 }, 41414 [clientId, expand, collapse, isExpanded] 41415 ); 41416 const onContextMenu = (0, import_element133.useCallback)( 41417 (event) => { 41418 if (showBlockActions && allowRightClickOverrides) { 41419 settingsRef.current?.click(); 41420 setSettingsAnchorRect( 41421 new window.DOMRect(event.clientX, event.clientY, 0, 0) 41422 ); 41423 event.preventDefault(); 41424 } 41425 }, 41426 [allowRightClickOverrides, settingsRef, showBlockActions] 41427 ); 41428 const onMouseDown = (0, import_element133.useCallback)( 41429 (event) => { 41430 if (allowRightClickOverrides && event.button === 2) { 41431 event.preventDefault(); 41432 } 41433 }, 41434 [allowRightClickOverrides] 41435 ); 41436 const settingsPopoverAnchor = (0, import_element133.useMemo)(() => { 41437 const { ownerDocument } = rowRef?.current || {}; 41438 if (!settingsAnchorRect || !ownerDocument) { 41439 return void 0; 41440 } 41441 return { 41442 ownerDocument, 41443 getBoundingClientRect() { 41444 return settingsAnchorRect; 41445 } 41446 }; 41447 }, [settingsAnchorRect]); 41448 const clearSettingsAnchorRect = (0, import_element133.useCallback)(() => { 41449 setSettingsAnchorRect(void 0); 41450 }, [setSettingsAnchorRect]); 41451 useListViewScrollIntoView({ 41452 isSelected, 41453 rowItemRef: rowRef, 41454 selectedClientIds 41455 }); 41456 if (!block) { 41457 return null; 41458 } 41459 const blockPositionDescription = getBlockPositionDescription( 41460 position, 41461 siblingBlockCount, 41462 level 41463 ); 41464 const blockPropertiesDescription = getBlockPropertiesDescription( 41465 blockInformation, 41466 isLocked 41467 ); 41468 const blockVisibilityDescription = isBlockHidden2 ? (0, import_i18n107.__)("Block is hidden.") : null; 41469 const hasSiblings = siblingBlockCount > 0; 41470 const hasRenderedMovers = showBlockMovers && hasSiblings; 41471 const moverCellClassName = clsx_default( 41472 "block-editor-list-view-block__mover-cell", 41473 { "is-visible": isHovered || isSelected } 41474 ); 41475 const listViewBlockSettingsClassName = clsx_default( 41476 "block-editor-list-view-block__menu-cell", 41477 { "is-visible": isHovered || isFirstSelectedBlock } 41478 ); 41479 let colSpan; 41480 if (hasRenderedMovers) { 41481 colSpan = 2; 41482 } else if (!showBlockActions) { 41483 colSpan = 3; 41484 } 41485 const classes = clsx_default({ 41486 "is-selected": isSelected, 41487 "is-first-selected": isFirstSelectedBlock, 41488 "is-last-selected": isLastSelectedBlock, 41489 "is-branch-selected": isBranchSelected, 41490 "is-synced-branch": isSyncedBranch, 41491 "is-dragging": isDragged, 41492 "has-single-cell": !showBlockActions, 41493 "is-synced": blockInformation?.isSynced, 41494 "is-draggable": canMoveBlock2, 41495 "is-displacement-normal": displacement === "normal", 41496 "is-displacement-up": displacement === "up", 41497 "is-displacement-down": displacement === "down", 41498 "is-after-dragged-blocks": isAfterDraggedBlocks, 41499 "is-nesting": isNesting 41500 }); 41501 const dropdownClientIds = selectedClientIds.includes(clientId) ? selectedClientIds : [clientId]; 41502 const currentlyEditingBlockInCanvas = isSelected && selectedClientIds.length === 1; 41503 return /* @__PURE__ */ (0, import_jsx_runtime264.jsxs)( 41504 leaf_default, 41505 { 41506 className: classes, 41507 isDragged, 41508 onKeyDown, 41509 onMouseEnter, 41510 onMouseLeave, 41511 onFocus: onMouseEnter, 41512 onBlur: onMouseLeave, 41513 level, 41514 position, 41515 rowCount, 41516 path, 41517 id: `list-view-$listViewInstanceId}-block-$clientId}`, 41518 "data-block": clientId, 41519 "data-expanded": canEditBlock2 ? isExpanded : void 0, 41520 ref: rowRef, 41521 children: [ 41522 /* @__PURE__ */ (0, import_jsx_runtime264.jsx)( 41523 import_components118.__experimentalTreeGridCell, 41524 { 41525 className: "block-editor-list-view-block__contents-cell", 41526 colSpan, 41527 ref: cellRef, 41528 "aria-selected": !!isSelected, 41529 children: ({ ref, tabIndex, onFocus }) => /* @__PURE__ */ (0, import_jsx_runtime264.jsxs)("div", { className: "block-editor-list-view-block__contents-container", children: [ 41530 /* @__PURE__ */ (0, import_jsx_runtime264.jsx)( 41531 block_contents_default, 41532 { 41533 block, 41534 onClick: selectEditorBlock, 41535 onContextMenu, 41536 onMouseDown, 41537 onToggleExpanded: toggleExpanded, 41538 isSelected, 41539 position, 41540 siblingBlockCount, 41541 level, 41542 ref, 41543 tabIndex: currentlyEditingBlockInCanvas ? 0 : tabIndex, 41544 onFocus, 41545 isExpanded: canEditBlock2 ? isExpanded : void 0, 41546 selectedClientIds, 41547 ariaDescribedBy: descriptionId 41548 } 41549 ), 41550 /* @__PURE__ */ (0, import_jsx_runtime264.jsx)(AriaReferencedText, { id: descriptionId, children: [ 41551 blockPositionDescription, 41552 blockPropertiesDescription, 41553 blockVisibilityDescription 41554 ].filter(Boolean).join(" ") }) 41555 ] }) 41556 } 41557 ), 41558 hasRenderedMovers && /* @__PURE__ */ (0, import_jsx_runtime264.jsx)(import_jsx_runtime264.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime264.jsxs)( 41559 import_components118.__experimentalTreeGridCell, 41560 { 41561 className: moverCellClassName, 41562 withoutGridItem: true, 41563 children: [ 41564 /* @__PURE__ */ (0, import_jsx_runtime264.jsx)(import_components118.__experimentalTreeGridItem, { children: ({ ref, tabIndex, onFocus }) => /* @__PURE__ */ (0, import_jsx_runtime264.jsx)( 41565 BlockMoverUpButton, 41566 { 41567 orientation: "vertical", 41568 clientIds: [clientId], 41569 ref, 41570 tabIndex, 41571 onFocus 41572 } 41573 ) }), 41574 /* @__PURE__ */ (0, import_jsx_runtime264.jsx)(import_components118.__experimentalTreeGridItem, { children: ({ ref, tabIndex, onFocus }) => /* @__PURE__ */ (0, import_jsx_runtime264.jsx)( 41575 BlockMoverDownButton, 41576 { 41577 orientation: "vertical", 41578 clientIds: [clientId], 41579 ref, 41580 tabIndex, 41581 onFocus 41582 } 41583 ) }) 41584 ] 41585 } 41586 ) }), 41587 showBlockActions && BlockSettingsMenu2 && /* @__PURE__ */ (0, import_jsx_runtime264.jsx)( 41588 import_components118.__experimentalTreeGridCell, 41589 { 41590 className: listViewBlockSettingsClassName, 41591 "aria-selected": !!isSelected, 41592 ref: settingsRef, 41593 children: ({ ref, tabIndex, onFocus }) => /* @__PURE__ */ (0, import_jsx_runtime264.jsx)( 41594 BlockSettingsMenu2, 41595 { 41596 clientIds: dropdownClientIds, 41597 block, 41598 icon: more_vertical_default, 41599 label: (0, import_i18n107.__)("Options"), 41600 popoverProps: { 41601 anchor: settingsPopoverAnchor 41602 // Used to position the settings at the cursor on right-click. 41603 }, 41604 toggleProps: { 41605 ref, 41606 className: "block-editor-list-view-block__menu", 41607 tabIndex, 41608 onClick: clearSettingsAnchorRect, 41609 onFocus, 41610 size: "small" 41611 }, 41612 disableOpenOnArrowDown: true, 41613 expand, 41614 expandedState, 41615 setInsertedBlock, 41616 __experimentalSelectBlock: updateFocusAndSelection 41617 } 41618 ) 41619 } 41620 ) 41621 ] 41622 } 41623 ); 41624 } 41625 var block_default3 = (0, import_element133.memo)(ListViewBlock); 41626 41627 // packages/block-editor/build-module/components/list-view/branch.js 41628 var import_jsx_runtime265 = __toESM(require_jsx_runtime()); 41629 function countBlocks(block, expandedState, draggedClientIds, isExpandedByDefault) { 41630 const isDragged = draggedClientIds?.includes(block.clientId); 41631 if (isDragged) { 41632 return 0; 41633 } 41634 const isExpanded = expandedState[block.clientId] ?? isExpandedByDefault; 41635 if (isExpanded) { 41636 return 1 + block.innerBlocks.reduce( 41637 countReducer( 41638 expandedState, 41639 draggedClientIds, 41640 isExpandedByDefault 41641 ), 41642 0 41643 ); 41644 } 41645 return 1; 41646 } 41647 var countReducer = (expandedState, draggedClientIds, isExpandedByDefault) => (count, block) => { 41648 const isDragged = draggedClientIds?.includes(block.clientId); 41649 if (isDragged) { 41650 return count; 41651 } 41652 const isExpanded = expandedState[block.clientId] ?? isExpandedByDefault; 41653 if (isExpanded && block.innerBlocks.length > 0) { 41654 return count + countBlocks( 41655 block, 41656 expandedState, 41657 draggedClientIds, 41658 isExpandedByDefault 41659 ); 41660 } 41661 return count + 1; 41662 }; 41663 var noop10 = () => { 41664 }; 41665 function ListViewBranch(props) { 41666 const { 41667 blocks: blocks2, 41668 selectBlock: selectBlock2 = noop10, 41669 showBlockMovers, 41670 selectedClientIds, 41671 level = 1, 41672 path = "", 41673 isBranchSelected = false, 41674 listPosition = 0, 41675 fixedListWindow, 41676 isExpanded, 41677 parentId, 41678 shouldShowInnerBlocks = true, 41679 isSyncedBranch = false, 41680 showAppender: showAppenderProp = true 41681 } = props; 41682 const parentBlockInformation = useBlockDisplayInformation(parentId); 41683 const syncedBranch = isSyncedBranch || !!parentBlockInformation?.isSynced; 41684 const canParentExpand = (0, import_data127.useSelect)( 41685 (select3) => { 41686 if (!parentId) { 41687 return true; 41688 } 41689 return select3(store).canEditBlock(parentId); 41690 }, 41691 [parentId] 41692 ); 41693 const { 41694 blockDropPosition, 41695 blockDropTargetIndex, 41696 firstDraggedBlockIndex, 41697 blockIndexes, 41698 expandedState, 41699 draggedClientIds 41700 } = useListViewContext(); 41701 const nextPositionRef = (0, import_element134.useRef)(); 41702 if (!canParentExpand) { 41703 return null; 41704 } 41705 const showAppender = showAppenderProp && level === 1; 41706 const filteredBlocks = blocks2.filter(Boolean); 41707 const blockCount = filteredBlocks.length; 41708 const rowCount = showAppender ? blockCount + 1 : blockCount; 41709 nextPositionRef.current = listPosition; 41710 return /* @__PURE__ */ (0, import_jsx_runtime265.jsxs)(import_jsx_runtime265.Fragment, { children: [ 41711 filteredBlocks.map((block, index) => { 41712 const { clientId, innerBlocks } = block; 41713 if (index > 0) { 41714 nextPositionRef.current += countBlocks( 41715 filteredBlocks[index - 1], 41716 expandedState, 41717 draggedClientIds, 41718 isExpanded 41719 ); 41720 } 41721 const isDragged = !!draggedClientIds?.includes(clientId); 41722 const { displacement, isAfterDraggedBlocks, isNesting } = getDragDisplacementValues({ 41723 blockIndexes, 41724 blockDropTargetIndex, 41725 blockDropPosition, 41726 clientId, 41727 firstDraggedBlockIndex, 41728 isDragged 41729 }); 41730 const { itemInView } = fixedListWindow; 41731 const blockInView = itemInView(nextPositionRef.current); 41732 const position = index + 1; 41733 const updatedPath = path.length > 0 ? `$path}_$position}` : `$position}`; 41734 const hasNestedBlocks = !!innerBlocks?.length; 41735 const shouldExpand = hasNestedBlocks && shouldShowInnerBlocks ? expandedState[clientId] ?? isExpanded : void 0; 41736 const isSelected = isClientIdSelected( 41737 clientId, 41738 selectedClientIds 41739 ); 41740 const isSelectedBranch = isBranchSelected || isSelected && hasNestedBlocks; 41741 const showBlock = isDragged || blockInView || isSelected && clientId === selectedClientIds[0] || index === 0 || index === blockCount - 1; 41742 return /* @__PURE__ */ (0, import_jsx_runtime265.jsxs)(import_data127.AsyncModeProvider, { value: !isSelected, children: [ 41743 showBlock && /* @__PURE__ */ (0, import_jsx_runtime265.jsx)( 41744 block_default3, 41745 { 41746 block, 41747 selectBlock: selectBlock2, 41748 isSelected, 41749 isBranchSelected: isSelectedBranch, 41750 isDragged, 41751 level, 41752 position, 41753 rowCount, 41754 siblingBlockCount: blockCount, 41755 showBlockMovers, 41756 path: updatedPath, 41757 isExpanded: isDragged ? false : shouldExpand, 41758 listPosition: nextPositionRef.current, 41759 selectedClientIds, 41760 isSyncedBranch: syncedBranch, 41761 displacement, 41762 isAfterDraggedBlocks, 41763 isNesting 41764 } 41765 ), 41766 !showBlock && /* @__PURE__ */ (0, import_jsx_runtime265.jsx)("tr", { children: /* @__PURE__ */ (0, import_jsx_runtime265.jsx)("td", { className: "block-editor-list-view-placeholder" }) }), 41767 hasNestedBlocks && shouldExpand && !isDragged && /* @__PURE__ */ (0, import_jsx_runtime265.jsx)( 41768 ListViewBranch, 41769 { 41770 parentId: clientId, 41771 blocks: innerBlocks, 41772 selectBlock: selectBlock2, 41773 showBlockMovers, 41774 level: level + 1, 41775 path: updatedPath, 41776 listPosition: nextPositionRef.current + 1, 41777 fixedListWindow, 41778 isBranchSelected: isSelectedBranch, 41779 selectedClientIds, 41780 isExpanded, 41781 isSyncedBranch: syncedBranch 41782 } 41783 ) 41784 ] }, clientId); 41785 }), 41786 showAppender && /* @__PURE__ */ (0, import_jsx_runtime265.jsx)( 41787 import_components119.__experimentalTreeGridRow, 41788 { 41789 level, 41790 setSize: rowCount, 41791 positionInSet: rowCount, 41792 isExpanded: true, 41793 children: /* @__PURE__ */ (0, import_jsx_runtime265.jsx)(import_components119.__experimentalTreeGridCell, { children: (treeGridCellProps) => /* @__PURE__ */ (0, import_jsx_runtime265.jsx)( 41794 Appender, 41795 { 41796 clientId: parentId, 41797 nestingLevel: level, 41798 blockCount, 41799 ...treeGridCellProps 41800 } 41801 ) }) 41802 } 41803 ) 41804 ] }); 41805 } 41806 var branch_default = (0, import_element134.memo)(ListViewBranch); 41807 41808 // packages/block-editor/build-module/components/list-view/drop-indicator.js 41809 var import_components120 = __toESM(require_components()); 41810 var import_dom31 = __toESM(require_dom()); 41811 var import_element135 = __toESM(require_element()); 41812 var import_i18n108 = __toESM(require_i18n()); 41813 var import_jsx_runtime266 = __toESM(require_jsx_runtime()); 41814 function ListViewDropIndicatorPreview({ 41815 draggedBlockClientId, 41816 listViewRef, 41817 blockDropTarget 41818 }) { 41819 const blockInformation = useBlockDisplayInformation(draggedBlockClientId); 41820 const blockTitle = useBlockDisplayTitle({ 41821 clientId: draggedBlockClientId, 41822 context: "list-view" 41823 }); 41824 const { rootClientId, clientId, dropPosition } = blockDropTarget || {}; 41825 const [rootBlockElement, blockElement] = (0, import_element135.useMemo)(() => { 41826 if (!listViewRef.current) { 41827 return []; 41828 } 41829 const _rootBlockElement = rootClientId ? listViewRef.current.querySelector( 41830 `[data-block="$rootClientId}"]` 41831 ) : void 0; 41832 const _blockElement = clientId ? listViewRef.current.querySelector( 41833 `[data-block="$clientId}"]` 41834 ) : void 0; 41835 return [_rootBlockElement, _blockElement]; 41836 }, [listViewRef, rootClientId, clientId]); 41837 const targetElement = blockElement || rootBlockElement; 41838 const rtl = (0, import_i18n108.isRTL)(); 41839 const getDropIndicatorWidth = (0, import_element135.useCallback)( 41840 (targetElementRect, indent) => { 41841 if (!targetElement) { 41842 return 0; 41843 } 41844 let width = targetElement.offsetWidth; 41845 const scrollContainer = (0, import_dom31.getScrollContainer)( 41846 targetElement, 41847 "horizontal" 41848 ); 41849 const ownerDocument = targetElement.ownerDocument; 41850 const windowScroll = scrollContainer === ownerDocument.body || scrollContainer === ownerDocument.documentElement; 41851 if (scrollContainer && !windowScroll) { 41852 const scrollContainerRect = scrollContainer.getBoundingClientRect(); 41853 const distanceBetweenContainerAndTarget = (0, import_i18n108.isRTL)() ? scrollContainerRect.right - targetElementRect.right : targetElementRect.left - scrollContainerRect.left; 41854 const scrollContainerWidth = scrollContainer.clientWidth; 41855 if (scrollContainerWidth < width + distanceBetweenContainerAndTarget) { 41856 width = scrollContainerWidth - distanceBetweenContainerAndTarget; 41857 } 41858 if (!rtl && targetElementRect.left + indent < scrollContainerRect.left) { 41859 width -= scrollContainerRect.left - targetElementRect.left; 41860 return width; 41861 } 41862 if (rtl && targetElementRect.right - indent > scrollContainerRect.right) { 41863 width -= targetElementRect.right - scrollContainerRect.right; 41864 return width; 41865 } 41866 } 41867 return width - indent; 41868 }, 41869 [rtl, targetElement] 41870 ); 41871 const style = (0, import_element135.useMemo)(() => { 41872 if (!targetElement) { 41873 return {}; 41874 } 41875 const targetElementRect = targetElement.getBoundingClientRect(); 41876 return { 41877 width: getDropIndicatorWidth(targetElementRect, 0) 41878 }; 41879 }, [getDropIndicatorWidth, targetElement]); 41880 const horizontalScrollOffsetStyle = (0, import_element135.useMemo)(() => { 41881 if (!targetElement) { 41882 return {}; 41883 } 41884 const scrollContainer = (0, import_dom31.getScrollContainer)(targetElement); 41885 const ownerDocument = targetElement.ownerDocument; 41886 const windowScroll = scrollContainer === ownerDocument.body || scrollContainer === ownerDocument.documentElement; 41887 if (scrollContainer && !windowScroll) { 41888 const scrollContainerRect = scrollContainer.getBoundingClientRect(); 41889 const targetElementRect = targetElement.getBoundingClientRect(); 41890 const distanceBetweenContainerAndTarget = rtl ? scrollContainerRect.right - targetElementRect.right : targetElementRect.left - scrollContainerRect.left; 41891 if (!rtl && scrollContainerRect.left > targetElementRect.left) { 41892 return { 41893 transform: `translateX( $distanceBetweenContainerAndTarget}px )` 41894 }; 41895 } 41896 if (rtl && scrollContainerRect.right < targetElementRect.right) { 41897 return { 41898 transform: `translateX( $distanceBetweenContainerAndTarget * -1}px )` 41899 }; 41900 } 41901 } 41902 return {}; 41903 }, [rtl, targetElement]); 41904 const ariaLevel = (0, import_element135.useMemo)(() => { 41905 if (!rootBlockElement) { 41906 return 1; 41907 } 41908 const _ariaLevel = parseInt( 41909 rootBlockElement.getAttribute("aria-level"), 41910 10 41911 ); 41912 return _ariaLevel ? _ariaLevel + 1 : 1; 41913 }, [rootBlockElement]); 41914 const hasAdjacentSelectedBranch = (0, import_element135.useMemo)(() => { 41915 if (!targetElement) { 41916 return false; 41917 } 41918 return targetElement.classList.contains("is-branch-selected"); 41919 }, [targetElement]); 41920 const popoverAnchor = (0, import_element135.useMemo)(() => { 41921 const isValidDropPosition = dropPosition === "top" || dropPosition === "bottom" || dropPosition === "inside"; 41922 if (!targetElement || !isValidDropPosition) { 41923 return void 0; 41924 } 41925 return { 41926 contextElement: targetElement, 41927 getBoundingClientRect() { 41928 const rect = targetElement.getBoundingClientRect(); 41929 let left = rect.left; 41930 let top = 0; 41931 const scrollContainer = (0, import_dom31.getScrollContainer)( 41932 targetElement, 41933 "horizontal" 41934 ); 41935 const doc = targetElement.ownerDocument; 41936 const windowScroll = scrollContainer === doc.body || scrollContainer === doc.documentElement; 41937 if (scrollContainer && !windowScroll) { 41938 const scrollContainerRect = scrollContainer.getBoundingClientRect(); 41939 const scrollbarWidth = rtl ? scrollContainer.offsetWidth - scrollContainer.clientWidth : 0; 41940 if (left < scrollContainerRect.left + scrollbarWidth) { 41941 left = scrollContainerRect.left + scrollbarWidth; 41942 } 41943 } 41944 if (dropPosition === "top") { 41945 top = rect.top - rect.height * 2; 41946 } else { 41947 top = rect.top; 41948 } 41949 const width = getDropIndicatorWidth(rect, 0); 41950 const height = rect.height; 41951 return new window.DOMRect(left, top, width, height); 41952 } 41953 }; 41954 }, [targetElement, dropPosition, getDropIndicatorWidth, rtl]); 41955 if (!targetElement) { 41956 return null; 41957 } 41958 return /* @__PURE__ */ (0, import_jsx_runtime266.jsx)( 41959 import_components120.Popover, 41960 { 41961 animate: false, 41962 anchor: popoverAnchor, 41963 focusOnMount: false, 41964 className: "block-editor-list-view-drop-indicator--preview", 41965 variant: "unstyled", 41966 flip: false, 41967 resize: true, 41968 children: /* @__PURE__ */ (0, import_jsx_runtime266.jsx)( 41969 "div", 41970 { 41971 style, 41972 className: clsx_default( 41973 "block-editor-list-view-drop-indicator__line", 41974 { 41975 "block-editor-list-view-drop-indicator__line--darker": hasAdjacentSelectedBranch 41976 } 41977 ), 41978 children: /* @__PURE__ */ (0, import_jsx_runtime266.jsxs)( 41979 "div", 41980 { 41981 className: "block-editor-list-view-leaf", 41982 "aria-level": ariaLevel, 41983 children: [ 41984 /* @__PURE__ */ (0, import_jsx_runtime266.jsxs)( 41985 "div", 41986 { 41987 className: clsx_default( 41988 "block-editor-list-view-block-select-button", 41989 "block-editor-list-view-block-contents" 41990 ), 41991 style: horizontalScrollOffsetStyle, 41992 children: [ 41993 /* @__PURE__ */ (0, import_jsx_runtime266.jsx)(ListViewExpander, { onClick: () => { 41994 } }), 41995 /* @__PURE__ */ (0, import_jsx_runtime266.jsx)( 41996 block_icon_default, 41997 { 41998 icon: blockInformation?.icon, 41999 showColors: true, 42000 context: "list-view" 42001 } 42002 ), 42003 /* @__PURE__ */ (0, import_jsx_runtime266.jsx)( 42004 import_components120.__experimentalHStack, 42005 { 42006 alignment: "center", 42007 className: "block-editor-list-view-block-select-button__label-wrapper", 42008 justify: "flex-start", 42009 spacing: 1, 42010 children: /* @__PURE__ */ (0, import_jsx_runtime266.jsx)("span", { className: "block-editor-list-view-block-select-button__title", children: /* @__PURE__ */ (0, import_jsx_runtime266.jsx)(import_components120.__experimentalTruncate, { ellipsizeMode: "auto", children: blockTitle }) }) 42011 } 42012 ) 42013 ] 42014 } 42015 ), 42016 /* @__PURE__ */ (0, import_jsx_runtime266.jsx)("div", { className: "block-editor-list-view-block__menu-cell" }) 42017 ] 42018 } 42019 ) 42020 } 42021 ) 42022 } 42023 ); 42024 } 42025 42026 // packages/block-editor/build-module/components/list-view/use-block-selection.js 42027 var import_a11y15 = __toESM(require_a11y()); 42028 var import_i18n109 = __toESM(require_i18n()); 42029 var import_data128 = __toESM(require_data()); 42030 var import_element136 = __toESM(require_element()); 42031 var import_keycodes14 = __toESM(require_keycodes()); 42032 var import_blocks78 = __toESM(require_blocks()); 42033 function useBlockSelection() { 42034 const { clearSelectedBlock: clearSelectedBlock2, multiSelect: multiSelect2, selectBlock: selectBlock2 } = (0, import_data128.useDispatch)(store); 42035 const { 42036 getBlockName: getBlockName2, 42037 getBlockParents: getBlockParents2, 42038 getBlockSelectionStart: getBlockSelectionStart2, 42039 getSelectedBlockClientIds: getSelectedBlockClientIds2, 42040 hasMultiSelection: hasMultiSelection2, 42041 hasSelectedBlock: hasSelectedBlock2 42042 } = (0, import_data128.useSelect)(store); 42043 const { getBlockType: getBlockType21 } = (0, import_data128.useSelect)(import_blocks78.store); 42044 const updateBlockSelection = (0, import_element136.useCallback)( 42045 async (event, clientId, destinationClientId, focusPosition) => { 42046 if (!event?.shiftKey && event?.keyCode !== import_keycodes14.ESCAPE) { 42047 selectBlock2(clientId, focusPosition); 42048 return; 42049 } 42050 event.preventDefault(); 42051 const isOnlyDeselection = event.type === "keydown" && event.keyCode === import_keycodes14.ESCAPE; 42052 const isKeyPress = event.type === "keydown" && (event.keyCode === import_keycodes14.UP || event.keyCode === import_keycodes14.DOWN || event.keyCode === import_keycodes14.HOME || event.keyCode === import_keycodes14.END); 42053 if (!isKeyPress && !hasSelectedBlock2() && !hasMultiSelection2()) { 42054 selectBlock2(clientId, null); 42055 return; 42056 } 42057 const selectedBlocks = getSelectedBlockClientIds2(); 42058 const clientIdWithParents = [ 42059 ...getBlockParents2(clientId), 42060 clientId 42061 ]; 42062 if (isOnlyDeselection || isKeyPress && !selectedBlocks.some( 42063 (blockId) => clientIdWithParents.includes(blockId) 42064 )) { 42065 await clearSelectedBlock2(); 42066 } 42067 if (!isOnlyDeselection) { 42068 let startTarget = getBlockSelectionStart2(); 42069 let endTarget = clientId; 42070 if (isKeyPress) { 42071 if (!hasSelectedBlock2() && !hasMultiSelection2()) { 42072 startTarget = clientId; 42073 } 42074 if (destinationClientId) { 42075 endTarget = destinationClientId; 42076 } 42077 } 42078 const startParents = getBlockParents2(startTarget); 42079 const endParents = getBlockParents2(endTarget); 42080 const { start: start2, end } = getCommonDepthClientIds( 42081 startTarget, 42082 endTarget, 42083 startParents, 42084 endParents 42085 ); 42086 await multiSelect2(start2, end, null); 42087 } 42088 const updatedSelectedBlocks = getSelectedBlockClientIds2(); 42089 if ((event.keyCode === import_keycodes14.HOME || event.keyCode === import_keycodes14.END) && updatedSelectedBlocks.length > 1) { 42090 return; 42091 } 42092 const selectionDiff = selectedBlocks.filter( 42093 (blockId) => !updatedSelectedBlocks.includes(blockId) 42094 ); 42095 let label; 42096 if (selectionDiff.length === 1) { 42097 const title = getBlockType21( 42098 getBlockName2(selectionDiff[0]) 42099 )?.title; 42100 if (title) { 42101 label = (0, import_i18n109.sprintf)( 42102 /* translators: %s: block name */ 42103 (0, import_i18n109.__)("%s deselected."), 42104 title 42105 ); 42106 } 42107 } else if (selectionDiff.length > 1) { 42108 label = (0, import_i18n109.sprintf)( 42109 /* translators: %s: number of deselected blocks */ 42110 (0, import_i18n109.__)("%s blocks deselected."), 42111 selectionDiff.length 42112 ); 42113 } 42114 if (label) { 42115 (0, import_a11y15.speak)(label, "assertive"); 42116 } 42117 }, 42118 [ 42119 clearSelectedBlock2, 42120 getBlockName2, 42121 getBlockType21, 42122 getBlockParents2, 42123 getBlockSelectionStart2, 42124 getSelectedBlockClientIds2, 42125 hasMultiSelection2, 42126 hasSelectedBlock2, 42127 multiSelect2, 42128 selectBlock2 42129 ] 42130 ); 42131 return { 42132 updateBlockSelection 42133 }; 42134 } 42135 42136 // packages/block-editor/build-module/components/list-view/use-list-view-block-indexes.js 42137 var import_element137 = __toESM(require_element()); 42138 function useListViewBlockIndexes(blocks2) { 42139 const blockIndexes = (0, import_element137.useMemo)(() => { 42140 const indexes = {}; 42141 let currentGlobalIndex = 0; 42142 const traverseBlocks = (blockList) => { 42143 blockList.forEach((block) => { 42144 indexes[block.clientId] = currentGlobalIndex; 42145 currentGlobalIndex++; 42146 if (block.innerBlocks.length > 0) { 42147 traverseBlocks(block.innerBlocks); 42148 } 42149 }); 42150 }; 42151 traverseBlocks(blocks2); 42152 return indexes; 42153 }, [blocks2]); 42154 return blockIndexes; 42155 } 42156 42157 // packages/block-editor/build-module/components/list-view/use-list-view-client-ids.js 42158 var import_data129 = __toESM(require_data()); 42159 function useListViewClientIds({ blocks: blocks2, rootClientId }) { 42160 return (0, import_data129.useSelect)( 42161 (select3) => { 42162 const { 42163 getDraggedBlockClientIds: getDraggedBlockClientIds2, 42164 getSelectedBlockClientIds: getSelectedBlockClientIds2, 42165 getEnabledClientIdsTree: getEnabledClientIdsTree2 42166 } = unlock(select3(store)); 42167 return { 42168 selectedClientIds: getSelectedBlockClientIds2(), 42169 draggedClientIds: getDraggedBlockClientIds2(), 42170 clientIdsTree: blocks2 ?? getEnabledClientIdsTree2(rootClientId) 42171 }; 42172 }, 42173 [blocks2, rootClientId] 42174 ); 42175 } 42176 42177 // packages/block-editor/build-module/components/list-view/use-list-view-collapse-items.js 42178 var import_element138 = __toESM(require_element()); 42179 var import_data130 = __toESM(require_data()); 42180 function useListViewCollapseItems({ collapseAll, expand }) { 42181 const { expandedBlock: expandedBlock2, getBlockParents: getBlockParents2 } = (0, import_data130.useSelect)((select3) => { 42182 const { getBlockParents: _getBlockParents, getExpandedBlock: getExpandedBlock2 } = unlock( 42183 select3(store) 42184 ); 42185 return { 42186 expandedBlock: getExpandedBlock2(), 42187 getBlockParents: _getBlockParents 42188 }; 42189 }, []); 42190 (0, import_element138.useEffect)(() => { 42191 if (expandedBlock2) { 42192 const blockParents = getBlockParents2(expandedBlock2, false); 42193 collapseAll(); 42194 expand(blockParents); 42195 } 42196 }, [collapseAll, expand, expandedBlock2, getBlockParents2]); 42197 } 42198 42199 // packages/block-editor/build-module/components/list-view/use-list-view-drop-zone.js 42200 var import_data131 = __toESM(require_data()); 42201 var import_element139 = __toESM(require_element()); 42202 var import_compose70 = __toESM(require_compose()); 42203 var import_i18n110 = __toESM(require_i18n()); 42204 var NESTING_LEVEL_INDENTATION = 24; 42205 function isUpGesture(point, rect, nestingLevel = 1, rtl = false) { 42206 const blockIndentPosition = rtl ? rect.right - nestingLevel * NESTING_LEVEL_INDENTATION : rect.left + nestingLevel * NESTING_LEVEL_INDENTATION; 42207 return rtl ? point.x > blockIndentPosition : point.x < blockIndentPosition; 42208 } 42209 function getDesiredRelativeParentLevel(point, rect, nestingLevel = 1, rtl = false) { 42210 const blockIndentPosition = rtl ? rect.right - nestingLevel * NESTING_LEVEL_INDENTATION : rect.left + nestingLevel * NESTING_LEVEL_INDENTATION; 42211 const distanceBetweenPointAndBlockIndentPosition = rtl ? blockIndentPosition - point.x : point.x - blockIndentPosition; 42212 const desiredParentLevel = Math.round( 42213 distanceBetweenPointAndBlockIndentPosition / NESTING_LEVEL_INDENTATION 42214 ); 42215 return Math.abs(desiredParentLevel); 42216 } 42217 function getCandidateBlockParents(candidateBlockData, blocksData) { 42218 const candidateBlockParents = []; 42219 let currentBlockData = candidateBlockData; 42220 while (currentBlockData) { 42221 candidateBlockParents.push({ ...currentBlockData }); 42222 currentBlockData = blocksData.find( 42223 (blockData) => blockData.clientId === currentBlockData.rootClientId 42224 ); 42225 } 42226 return candidateBlockParents; 42227 } 42228 function getNextNonDraggedBlock(blocksData, index) { 42229 const nextBlockData = blocksData[index + 1]; 42230 if (nextBlockData && nextBlockData.isDraggedBlock) { 42231 return getNextNonDraggedBlock(blocksData, index + 1); 42232 } 42233 return nextBlockData; 42234 } 42235 function isNestingGesture(point, rect, nestingLevel = 1, rtl = false) { 42236 const blockIndentPosition = rtl ? rect.right - nestingLevel * NESTING_LEVEL_INDENTATION : rect.left + nestingLevel * NESTING_LEVEL_INDENTATION; 42237 const isNestingHorizontalGesture = rtl ? point.x < blockIndentPosition - NESTING_LEVEL_INDENTATION : point.x > blockIndentPosition + NESTING_LEVEL_INDENTATION; 42238 return isNestingHorizontalGesture && point.y < rect.bottom; 42239 } 42240 var ALLOWED_DROP_EDGES = ["top", "bottom"]; 42241 function getListViewDropTarget(blocksData, position, rtl = false) { 42242 let candidateEdge; 42243 let candidateBlockData; 42244 let candidateDistance; 42245 let candidateRect; 42246 let candidateBlockIndex; 42247 for (let i2 = 0; i2 < blocksData.length; i2++) { 42248 const blockData = blocksData[i2]; 42249 if (blockData.isDraggedBlock) { 42250 continue; 42251 } 42252 const rect = blockData.element.getBoundingClientRect(); 42253 const [distance, edge] = getDistanceToNearestEdge( 42254 position, 42255 rect, 42256 ALLOWED_DROP_EDGES 42257 ); 42258 const isCursorWithinBlock = isPointContainedByRect(position, rect); 42259 if (candidateDistance === void 0 || distance < candidateDistance || isCursorWithinBlock) { 42260 candidateDistance = distance; 42261 const index = blocksData.indexOf(blockData); 42262 const previousBlockData = blocksData[index - 1]; 42263 if (edge === "top" && previousBlockData && previousBlockData.rootClientId === blockData.rootClientId && !previousBlockData.isDraggedBlock) { 42264 candidateBlockData = previousBlockData; 42265 candidateEdge = "bottom"; 42266 candidateRect = previousBlockData.element.getBoundingClientRect(); 42267 candidateBlockIndex = index - 1; 42268 } else { 42269 candidateBlockData = blockData; 42270 candidateEdge = edge; 42271 candidateRect = rect; 42272 candidateBlockIndex = index; 42273 } 42274 if (isCursorWithinBlock) { 42275 break; 42276 } 42277 } 42278 } 42279 if (!candidateBlockData) { 42280 return; 42281 } 42282 const candidateBlockParents = getCandidateBlockParents( 42283 candidateBlockData, 42284 blocksData 42285 ); 42286 const isDraggingBelow = candidateEdge === "bottom"; 42287 if (isDraggingBelow && candidateBlockData.canInsertDraggedBlocksAsChild && (candidateBlockData.innerBlockCount > 0 && candidateBlockData.isExpanded || isNestingGesture( 42288 position, 42289 candidateRect, 42290 candidateBlockParents.length, 42291 rtl 42292 ))) { 42293 const newBlockIndex = candidateBlockData.isExpanded ? 0 : candidateBlockData.innerBlockCount || 0; 42294 return { 42295 rootClientId: candidateBlockData.clientId, 42296 clientId: candidateBlockData.clientId, 42297 blockIndex: newBlockIndex, 42298 dropPosition: "inside" 42299 }; 42300 } 42301 if (isDraggingBelow && candidateBlockData.rootClientId && isUpGesture( 42302 position, 42303 candidateRect, 42304 candidateBlockParents.length, 42305 rtl 42306 )) { 42307 const nextBlock = getNextNonDraggedBlock( 42308 blocksData, 42309 candidateBlockIndex 42310 ); 42311 const currentLevel = candidateBlockData.nestingLevel; 42312 const nextLevel = nextBlock ? nextBlock.nestingLevel : 1; 42313 if (currentLevel && nextLevel) { 42314 const desiredRelativeLevel = getDesiredRelativeParentLevel( 42315 position, 42316 candidateRect, 42317 candidateBlockParents.length, 42318 rtl 42319 ); 42320 const targetParentIndex = Math.max( 42321 Math.min(desiredRelativeLevel, currentLevel - nextLevel), 42322 0 42323 ); 42324 if (candidateBlockParents[targetParentIndex]) { 42325 let newBlockIndex = candidateBlockData.blockIndex; 42326 if (candidateBlockParents[targetParentIndex].nestingLevel === nextBlock?.nestingLevel) { 42327 newBlockIndex = nextBlock?.blockIndex; 42328 } else { 42329 for (let i2 = candidateBlockIndex; i2 >= 0; i2--) { 42330 const blockData = blocksData[i2]; 42331 if (blockData.rootClientId === candidateBlockParents[targetParentIndex].rootClientId) { 42332 newBlockIndex = blockData.blockIndex + 1; 42333 break; 42334 } 42335 } 42336 } 42337 return { 42338 rootClientId: candidateBlockParents[targetParentIndex].rootClientId, 42339 clientId: candidateBlockData.clientId, 42340 blockIndex: newBlockIndex, 42341 dropPosition: candidateEdge 42342 }; 42343 } 42344 } 42345 } 42346 if (!candidateBlockData.canInsertDraggedBlocksAsSibling) { 42347 return; 42348 } 42349 const offset = isDraggingBelow ? 1 : 0; 42350 return { 42351 rootClientId: candidateBlockData.rootClientId, 42352 clientId: candidateBlockData.clientId, 42353 blockIndex: candidateBlockData.blockIndex + offset, 42354 dropPosition: candidateEdge 42355 }; 42356 } 42357 var EXPAND_THROTTLE_OPTIONS = { 42358 leading: false, 42359 // Don't call the function immediately on the first call. 42360 trailing: true 42361 // Do call the function on the last call. 42362 }; 42363 function useListViewDropZone({ 42364 dropZoneElement, 42365 expandedState, 42366 setExpandedState 42367 }) { 42368 const { 42369 getBlockRootClientId: getBlockRootClientId2, 42370 getBlockIndex: getBlockIndex2, 42371 getBlockCount: getBlockCount2, 42372 getDraggedBlockClientIds: getDraggedBlockClientIds2, 42373 canInsertBlocks: canInsertBlocks2 42374 } = (0, import_data131.useSelect)(store); 42375 const [target, setTarget] = (0, import_element139.useState)(); 42376 const { rootClientId: targetRootClientId, blockIndex: targetBlockIndex } = target || {}; 42377 const onBlockDrop2 = useOnBlockDrop(targetRootClientId, targetBlockIndex); 42378 const rtl = (0, import_i18n110.isRTL)(); 42379 const previousRootClientId = (0, import_compose70.usePrevious)(targetRootClientId); 42380 const maybeExpandBlock = (0, import_element139.useCallback)( 42381 (_expandedState, _target) => { 42382 const { rootClientId } = _target || {}; 42383 if (!rootClientId) { 42384 return; 42385 } 42386 if (_target?.dropPosition === "inside" && !_expandedState[rootClientId]) { 42387 setExpandedState({ 42388 type: "expand", 42389 clientIds: [rootClientId] 42390 }); 42391 } 42392 }, 42393 [setExpandedState] 42394 ); 42395 const throttledMaybeExpandBlock = (0, import_compose70.useThrottle)( 42396 maybeExpandBlock, 42397 500, 42398 EXPAND_THROTTLE_OPTIONS 42399 ); 42400 (0, import_element139.useEffect)(() => { 42401 if (target?.dropPosition !== "inside" || previousRootClientId !== target?.rootClientId) { 42402 throttledMaybeExpandBlock.cancel(); 42403 return; 42404 } 42405 throttledMaybeExpandBlock(expandedState, target); 42406 }, [ 42407 expandedState, 42408 previousRootClientId, 42409 target, 42410 throttledMaybeExpandBlock 42411 ]); 42412 const draggedBlockClientIds = getDraggedBlockClientIds2(); 42413 const throttled = (0, import_compose70.useThrottle)( 42414 (0, import_element139.useCallback)( 42415 (event, currentTarget) => { 42416 const position = { x: event.clientX, y: event.clientY }; 42417 const isBlockDrag = !!draggedBlockClientIds?.length; 42418 const blockElements = Array.from( 42419 currentTarget.querySelectorAll("[data-block]") 42420 ); 42421 const blocksData = blockElements.map((blockElement) => { 42422 const clientId = blockElement.dataset.block; 42423 const isExpanded = blockElement.dataset.expanded === "true"; 42424 const isDraggedBlock = blockElement.classList.contains("is-dragging"); 42425 const nestingLevel = parseInt( 42426 blockElement.getAttribute("aria-level"), 42427 10 42428 ); 42429 const rootClientId = getBlockRootClientId2(clientId); 42430 return { 42431 clientId, 42432 isExpanded, 42433 rootClientId, 42434 blockIndex: getBlockIndex2(clientId), 42435 element: blockElement, 42436 nestingLevel: nestingLevel || void 0, 42437 isDraggedBlock: isBlockDrag ? isDraggedBlock : false, 42438 innerBlockCount: getBlockCount2(clientId), 42439 canInsertDraggedBlocksAsSibling: isBlockDrag ? canInsertBlocks2( 42440 draggedBlockClientIds, 42441 rootClientId 42442 ) : true, 42443 canInsertDraggedBlocksAsChild: isBlockDrag ? canInsertBlocks2(draggedBlockClientIds, clientId) : true 42444 }; 42445 }); 42446 const newTarget = getListViewDropTarget( 42447 blocksData, 42448 position, 42449 rtl 42450 ); 42451 if (newTarget) { 42452 setTarget(newTarget); 42453 } 42454 }, 42455 [ 42456 canInsertBlocks2, 42457 draggedBlockClientIds, 42458 getBlockCount2, 42459 getBlockIndex2, 42460 getBlockRootClientId2, 42461 rtl 42462 ] 42463 ), 42464 50 42465 ); 42466 const ref = (0, import_compose70.__experimentalUseDropZone)({ 42467 dropZoneElement, 42468 onDrop(event) { 42469 throttled.cancel(); 42470 if (target) { 42471 onBlockDrop2(event); 42472 } 42473 setTarget(void 0); 42474 }, 42475 onDragLeave() { 42476 throttled.cancel(); 42477 setTarget(null); 42478 }, 42479 onDragOver(event) { 42480 throttled(event, event.currentTarget); 42481 }, 42482 onDragEnd() { 42483 throttled.cancel(); 42484 setTarget(void 0); 42485 } 42486 }); 42487 return { ref, target }; 42488 } 42489 42490 // packages/block-editor/build-module/components/list-view/use-list-view-expand-selected-item.js 42491 var import_element140 = __toESM(require_element()); 42492 var import_data132 = __toESM(require_data()); 42493 function useListViewExpandSelectedItem({ 42494 firstSelectedBlockClientId, 42495 setExpandedState 42496 }) { 42497 const [selectedTreeId, setSelectedTreeId] = (0, import_element140.useState)(null); 42498 const { selectedBlockParentClientIds } = (0, import_data132.useSelect)( 42499 (select3) => { 42500 const { getBlockParents: getBlockParents2 } = select3(store); 42501 return { 42502 selectedBlockParentClientIds: getBlockParents2( 42503 firstSelectedBlockClientId, 42504 false 42505 ) 42506 }; 42507 }, 42508 [firstSelectedBlockClientId] 42509 ); 42510 (0, import_element140.useEffect)(() => { 42511 if (selectedTreeId === firstSelectedBlockClientId) { 42512 return; 42513 } 42514 if (selectedBlockParentClientIds?.length) { 42515 setExpandedState({ 42516 type: "expand", 42517 clientIds: selectedBlockParentClientIds 42518 }); 42519 } 42520 }, [ 42521 firstSelectedBlockClientId, 42522 selectedBlockParentClientIds, 42523 selectedTreeId, 42524 setExpandedState 42525 ]); 42526 return { 42527 setSelectedTreeId 42528 }; 42529 } 42530 42531 // packages/block-editor/build-module/components/list-view/use-clipboard-handler.js 42532 var import_data133 = __toESM(require_data()); 42533 var import_compose71 = __toESM(require_compose()); 42534 function useClipboardHandler2({ selectBlock: selectBlock2 }) { 42535 const registry = (0, import_data133.useRegistry)(); 42536 const { 42537 getBlockOrder: getBlockOrder2, 42538 getBlockRootClientId: getBlockRootClientId2, 42539 getBlocksByClientId: getBlocksByClientId2, 42540 getPreviousBlockClientId: getPreviousBlockClientId2, 42541 getSelectedBlockClientIds: getSelectedBlockClientIds2, 42542 getSettings: getSettings8, 42543 canInsertBlockType: canInsertBlockType2, 42544 canRemoveBlocks: canRemoveBlocks2 42545 } = (0, import_data133.useSelect)(store); 42546 const { flashBlock: flashBlock2, removeBlocks: removeBlocks2, replaceBlocks: replaceBlocks2, insertBlocks: insertBlocks2 } = (0, import_data133.useDispatch)(store); 42547 const notifyCopy = useNotifyCopy(); 42548 return (0, import_compose71.useRefEffect)((node) => { 42549 function updateFocusAndSelection(focusClientId, shouldSelectBlock) { 42550 if (shouldSelectBlock) { 42551 selectBlock2(void 0, focusClientId, null, null); 42552 } 42553 focusListItem(focusClientId, node); 42554 } 42555 function getBlocksToUpdate(clientId) { 42556 const selectedBlockClientIds = getSelectedBlockClientIds2(); 42557 const isUpdatingSelectedBlocks = selectedBlockClientIds.includes(clientId); 42558 const firstBlockClientId = isUpdatingSelectedBlocks ? selectedBlockClientIds[0] : clientId; 42559 const firstBlockRootClientId = getBlockRootClientId2(firstBlockClientId); 42560 const blocksToUpdate = isUpdatingSelectedBlocks ? selectedBlockClientIds : [clientId]; 42561 return { 42562 blocksToUpdate, 42563 firstBlockClientId, 42564 firstBlockRootClientId, 42565 originallySelectedBlockClientIds: selectedBlockClientIds 42566 }; 42567 } 42568 function handler(event) { 42569 if (event.defaultPrevented) { 42570 return; 42571 } 42572 if (!node.contains(event.target.ownerDocument.activeElement)) { 42573 return; 42574 } 42575 const listViewRow = event.target.ownerDocument.activeElement?.closest( 42576 "[role=row]" 42577 ); 42578 const clientId = listViewRow?.dataset?.block; 42579 if (!clientId) { 42580 return; 42581 } 42582 const { 42583 blocksToUpdate: selectedBlockClientIds, 42584 firstBlockClientId, 42585 firstBlockRootClientId, 42586 originallySelectedBlockClientIds 42587 } = getBlocksToUpdate(clientId); 42588 if (selectedBlockClientIds.length === 0) { 42589 return; 42590 } 42591 event.preventDefault(); 42592 if (event.type === "copy" || event.type === "cut") { 42593 if (selectedBlockClientIds.length === 1) { 42594 flashBlock2(selectedBlockClientIds[0]); 42595 } 42596 notifyCopy(event.type, selectedBlockClientIds); 42597 const blocks2 = getBlocksByClientId2(selectedBlockClientIds); 42598 setClipboardBlocks(event, blocks2, registry); 42599 } 42600 if (event.type === "cut") { 42601 if (!canRemoveBlocks2(selectedBlockClientIds)) { 42602 return; 42603 } 42604 let blockToFocus = getPreviousBlockClientId2(firstBlockClientId) ?? // If the previous block is not found (when the first block is deleted), 42605 // fallback to focus the parent block. 42606 firstBlockRootClientId; 42607 removeBlocks2(selectedBlockClientIds, false); 42608 const shouldUpdateSelection = originallySelectedBlockClientIds.length > 0 && getSelectedBlockClientIds2().length === 0; 42609 if (!blockToFocus) { 42610 blockToFocus = getBlockOrder2()[0]; 42611 } 42612 updateFocusAndSelection(blockToFocus, shouldUpdateSelection); 42613 } else if (event.type === "paste") { 42614 const { 42615 __experimentalCanUserUseUnfilteredHTML: canUserUseUnfilteredHTML 42616 } = getSettings8(); 42617 const blocks2 = getPasteBlocks( 42618 event, 42619 canUserUseUnfilteredHTML 42620 ); 42621 if (selectedBlockClientIds.length === 1) { 42622 const [selectedBlockClientId] = selectedBlockClientIds; 42623 if (blocks2.every( 42624 (block) => canInsertBlockType2( 42625 block.name, 42626 selectedBlockClientId 42627 ) 42628 )) { 42629 insertBlocks2( 42630 blocks2, 42631 void 0, 42632 selectedBlockClientId 42633 ); 42634 updateFocusAndSelection(blocks2[0]?.clientId, false); 42635 return; 42636 } 42637 } 42638 replaceBlocks2( 42639 selectedBlockClientIds, 42640 blocks2, 42641 blocks2.length - 1, 42642 -1 42643 ); 42644 updateFocusAndSelection(blocks2[0]?.clientId, false); 42645 } 42646 } 42647 node.ownerDocument.addEventListener("copy", handler); 42648 node.ownerDocument.addEventListener("cut", handler); 42649 node.ownerDocument.addEventListener("paste", handler); 42650 return () => { 42651 node.ownerDocument.removeEventListener("copy", handler); 42652 node.ownerDocument.removeEventListener("cut", handler); 42653 node.ownerDocument.removeEventListener("paste", handler); 42654 }; 42655 }, []); 42656 } 42657 42658 // packages/block-editor/build-module/components/list-view/index.js 42659 var import_jsx_runtime267 = __toESM(require_jsx_runtime()); 42660 var expanded = (state, action) => { 42661 if (action.type === "clear") { 42662 return {}; 42663 } 42664 if (Array.isArray(action.clientIds)) { 42665 return { 42666 ...state, 42667 ...action.clientIds.reduce( 42668 (newState, id) => ({ 42669 ...newState, 42670 [id]: action.type === "expand" 42671 }), 42672 {} 42673 ) 42674 }; 42675 } 42676 return state; 42677 }; 42678 var BLOCK_LIST_ITEM_HEIGHT = 32; 42679 function ListViewComponent({ 42680 id, 42681 blocks: blocks2, 42682 dropZoneElement, 42683 showBlockMovers = false, 42684 isExpanded = false, 42685 showAppender = false, 42686 blockSettingsMenu: BlockSettingsMenu2 = BlockSettingsDropdown, 42687 rootClientId, 42688 description, 42689 onSelect, 42690 additionalBlockContent: AdditionalBlockContent 42691 }, ref) { 42692 if (blocks2) { 42693 (0, import_deprecated14.default)( 42694 "`blocks` property in `wp.blockEditor.__experimentalListView`", 42695 { 42696 since: "6.3", 42697 alternative: "`rootClientId` property" 42698 } 42699 ); 42700 } 42701 const instanceId = (0, import_compose72.useInstanceId)(ListViewComponent); 42702 const { clientIdsTree, draggedClientIds, selectedClientIds } = useListViewClientIds({ blocks: blocks2, rootClientId }); 42703 const blockIndexes = useListViewBlockIndexes(clientIdsTree); 42704 const { getBlock: getBlock2 } = (0, import_data134.useSelect)(store); 42705 const { visibleBlockCount } = (0, import_data134.useSelect)( 42706 (select3) => { 42707 const { getGlobalBlockCount: getGlobalBlockCount2, getClientIdsOfDescendants: getClientIdsOfDescendants2 } = select3(store); 42708 const draggedBlockCount = draggedClientIds?.length > 0 ? getClientIdsOfDescendants2(draggedClientIds).length + 1 : 0; 42709 return { 42710 visibleBlockCount: getGlobalBlockCount2() - draggedBlockCount 42711 }; 42712 }, 42713 [draggedClientIds] 42714 ); 42715 const { updateBlockSelection } = useBlockSelection(); 42716 const [expandedState, setExpandedState] = (0, import_element141.useReducer)(expanded, {}); 42717 const [insertedBlock, setInsertedBlock] = (0, import_element141.useState)(null); 42718 const { setSelectedTreeId } = useListViewExpandSelectedItem({ 42719 firstSelectedBlockClientId: selectedClientIds[0], 42720 setExpandedState 42721 }); 42722 const selectEditorBlock = (0, import_element141.useCallback)( 42723 /** 42724 * @param {MouseEvent | KeyboardEvent | undefined} event 42725 * @param {string} blockClientId 42726 * @param {null | undefined | -1 | 1} focusPosition 42727 */ 42728 (event, blockClientId, focusPosition) => { 42729 updateBlockSelection(event, blockClientId, null, focusPosition); 42730 setSelectedTreeId(blockClientId); 42731 if (onSelect) { 42732 onSelect(getBlock2(blockClientId)); 42733 } 42734 }, 42735 [setSelectedTreeId, updateBlockSelection, onSelect, getBlock2] 42736 ); 42737 const { ref: dropZoneRef, target: blockDropTarget } = useListViewDropZone({ 42738 dropZoneElement, 42739 expandedState, 42740 setExpandedState 42741 }); 42742 const elementRef = (0, import_element141.useRef)(); 42743 const clipBoardRef = useClipboardHandler2({ 42744 selectBlock: selectEditorBlock 42745 }); 42746 const treeGridRef = (0, import_compose72.useMergeRefs)([ 42747 clipBoardRef, 42748 elementRef, 42749 dropZoneRef, 42750 ref 42751 ]); 42752 (0, import_element141.useEffect)(() => { 42753 if (selectedClientIds?.length) { 42754 focusListItem(selectedClientIds[0], elementRef?.current); 42755 } 42756 }, []); 42757 const expand = (0, import_element141.useCallback)( 42758 (clientId) => { 42759 if (!clientId) { 42760 return; 42761 } 42762 const clientIds = Array.isArray(clientId) ? clientId : [clientId]; 42763 setExpandedState({ type: "expand", clientIds }); 42764 }, 42765 [setExpandedState] 42766 ); 42767 const collapse = (0, import_element141.useCallback)( 42768 (clientId) => { 42769 if (!clientId) { 42770 return; 42771 } 42772 setExpandedState({ type: "collapse", clientIds: [clientId] }); 42773 }, 42774 [setExpandedState] 42775 ); 42776 const collapseAll = (0, import_element141.useCallback)(() => { 42777 setExpandedState({ type: "clear" }); 42778 }, [setExpandedState]); 42779 const expandRow = (0, import_element141.useCallback)( 42780 (row) => { 42781 expand(row?.dataset?.block); 42782 }, 42783 [expand] 42784 ); 42785 const collapseRow = (0, import_element141.useCallback)( 42786 (row) => { 42787 collapse(row?.dataset?.block); 42788 }, 42789 [collapse] 42790 ); 42791 const focusRow = (0, import_element141.useCallback)( 42792 (event, startRow, endRow) => { 42793 if (event.shiftKey) { 42794 updateBlockSelection( 42795 event, 42796 startRow?.dataset?.block, 42797 endRow?.dataset?.block 42798 ); 42799 } 42800 }, 42801 [updateBlockSelection] 42802 ); 42803 useListViewCollapseItems({ 42804 collapseAll, 42805 expand 42806 }); 42807 const firstDraggedBlockClientId = draggedClientIds?.[0]; 42808 const { blockDropTargetIndex, blockDropPosition, firstDraggedBlockIndex } = (0, import_element141.useMemo)(() => { 42809 let _blockDropTargetIndex, _firstDraggedBlockIndex; 42810 if (blockDropTarget?.clientId) { 42811 const foundBlockIndex = blockIndexes[blockDropTarget.clientId]; 42812 _blockDropTargetIndex = foundBlockIndex === void 0 || blockDropTarget?.dropPosition === "top" ? foundBlockIndex : foundBlockIndex + 1; 42813 } else if (blockDropTarget === null) { 42814 _blockDropTargetIndex = null; 42815 } 42816 if (firstDraggedBlockClientId) { 42817 const foundBlockIndex = blockIndexes[firstDraggedBlockClientId]; 42818 _firstDraggedBlockIndex = foundBlockIndex === void 0 || blockDropTarget?.dropPosition === "top" ? foundBlockIndex : foundBlockIndex + 1; 42819 } 42820 return { 42821 blockDropTargetIndex: _blockDropTargetIndex, 42822 blockDropPosition: blockDropTarget?.dropPosition, 42823 firstDraggedBlockIndex: _firstDraggedBlockIndex 42824 }; 42825 }, [blockDropTarget, blockIndexes, firstDraggedBlockClientId]); 42826 const contextValue = (0, import_element141.useMemo)( 42827 () => ({ 42828 blockDropPosition, 42829 blockDropTargetIndex, 42830 blockIndexes, 42831 draggedClientIds, 42832 expandedState, 42833 expand, 42834 firstDraggedBlockIndex, 42835 collapse, 42836 collapseAll, 42837 BlockSettingsMenu: BlockSettingsMenu2, 42838 listViewInstanceId: instanceId, 42839 AdditionalBlockContent, 42840 insertedBlock, 42841 setInsertedBlock, 42842 treeGridElementRef: elementRef, 42843 rootClientId 42844 }), 42845 [ 42846 blockDropPosition, 42847 blockDropTargetIndex, 42848 blockIndexes, 42849 draggedClientIds, 42850 expandedState, 42851 expand, 42852 firstDraggedBlockIndex, 42853 collapse, 42854 collapseAll, 42855 BlockSettingsMenu2, 42856 instanceId, 42857 AdditionalBlockContent, 42858 insertedBlock, 42859 setInsertedBlock, 42860 rootClientId 42861 ] 42862 ); 42863 const [fixedListWindow] = (0, import_compose72.__experimentalUseFixedWindowList)( 42864 elementRef, 42865 BLOCK_LIST_ITEM_HEIGHT, 42866 visibleBlockCount, 42867 { 42868 // Ensure that the windowing logic is recalculated when the expanded state changes. 42869 // This is necessary because expanding a collapsed block in a short list view can 42870 // switch the list view to a tall list view with a scrollbar, and vice versa. 42871 // When this happens, the windowing logic needs to be recalculated to ensure that 42872 // the correct number of blocks are rendered, by rechecking for a scroll container. 42873 expandedState, 42874 useWindowing: true, 42875 windowOverscan: 40 42876 } 42877 ); 42878 if (!clientIdsTree.length && !showAppender) { 42879 return null; 42880 } 42881 const describedById = description && `block-editor-list-view-description-$instanceId}`; 42882 return /* @__PURE__ */ (0, import_jsx_runtime267.jsxs)(import_data134.AsyncModeProvider, { value: true, children: [ 42883 /* @__PURE__ */ (0, import_jsx_runtime267.jsx)( 42884 ListViewDropIndicatorPreview, 42885 { 42886 draggedBlockClientId: firstDraggedBlockClientId, 42887 listViewRef: elementRef, 42888 blockDropTarget 42889 } 42890 ), 42891 description && /* @__PURE__ */ (0, import_jsx_runtime267.jsx)(import_components121.VisuallyHidden, { id: describedById, children: description }), 42892 /* @__PURE__ */ (0, import_jsx_runtime267.jsx)( 42893 import_components121.__experimentalTreeGrid, 42894 { 42895 id, 42896 className: clsx_default("block-editor-list-view-tree", { 42897 "is-dragging": draggedClientIds?.length > 0 && blockDropTargetIndex !== void 0 42898 }), 42899 "aria-label": (0, import_i18n111.__)("Block navigation structure"), 42900 ref: treeGridRef, 42901 onCollapseRow: collapseRow, 42902 onExpandRow: expandRow, 42903 onFocusRow: focusRow, 42904 applicationAriaLabel: (0, import_i18n111.__)("Block navigation structure"), 42905 "aria-describedby": describedById, 42906 style: { 42907 "--wp-admin--list-view-dragged-items-height": draggedClientIds?.length ? `$BLOCK_LIST_ITEM_HEIGHT * (draggedClientIds.length - 1)}px` : null 42908 }, 42909 children: /* @__PURE__ */ (0, import_jsx_runtime267.jsx)(ListViewContext.Provider, { value: contextValue, children: /* @__PURE__ */ (0, import_jsx_runtime267.jsx)( 42910 branch_default, 42911 { 42912 blocks: clientIdsTree, 42913 parentId: rootClientId, 42914 selectBlock: selectEditorBlock, 42915 showBlockMovers, 42916 fixedListWindow, 42917 selectedClientIds, 42918 isExpanded, 42919 showAppender 42920 } 42921 ) }) 42922 } 42923 ) 42924 ] }); 42925 } 42926 var PrivateListView = (0, import_element141.forwardRef)(ListViewComponent); 42927 var list_view_default2 = (0, import_element141.forwardRef)((props, ref) => { 42928 return /* @__PURE__ */ (0, import_jsx_runtime267.jsx)( 42929 PrivateListView, 42930 { 42931 ref, 42932 ...props, 42933 showAppender: false, 42934 rootClientId: null, 42935 onSelect: null, 42936 additionalBlockContent: null, 42937 blockSettingsMenu: void 0 42938 } 42939 ); 42940 }); 42941 42942 // packages/block-editor/build-module/components/block-navigation/dropdown.js 42943 var import_jsx_runtime268 = __toESM(require_jsx_runtime()); 42944 function BlockNavigationDropdownToggle({ 42945 isEnabled, 42946 onToggle, 42947 isOpen, 42948 innerRef, 42949 ...props 42950 }) { 42951 return /* @__PURE__ */ (0, import_jsx_runtime268.jsx)( 42952 import_components122.Button, 42953 { 42954 __next40pxDefaultSize: true, 42955 ...props, 42956 ref: innerRef, 42957 icon: list_view_default, 42958 "aria-expanded": isOpen, 42959 "aria-haspopup": "true", 42960 onClick: isEnabled ? onToggle : void 0, 42961 label: (0, import_i18n112.__)("List view"), 42962 className: "block-editor-block-navigation", 42963 "aria-disabled": !isEnabled 42964 } 42965 ); 42966 } 42967 function BlockNavigationDropdown({ isDisabled, ...props }, ref) { 42968 (0, import_deprecated15.default)("wp.blockEditor.BlockNavigationDropdown", { 42969 since: "6.1", 42970 alternative: "wp.components.Dropdown and wp.blockEditor.ListView" 42971 }); 42972 const hasBlocks = (0, import_data135.useSelect)( 42973 (select3) => !!select3(store).getBlockCount(), 42974 [] 42975 ); 42976 const isEnabled = hasBlocks && !isDisabled; 42977 return /* @__PURE__ */ (0, import_jsx_runtime268.jsx)( 42978 import_components122.Dropdown, 42979 { 42980 contentClassName: "block-editor-block-navigation__popover", 42981 popoverProps: { placement: "bottom-start" }, 42982 renderToggle: ({ isOpen, onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime268.jsx)( 42983 BlockNavigationDropdownToggle, 42984 { 42985 ...props, 42986 innerRef: ref, 42987 isOpen, 42988 onToggle, 42989 isEnabled 42990 } 42991 ), 42992 renderContent: () => /* @__PURE__ */ (0, import_jsx_runtime268.jsxs)("div", { className: "block-editor-block-navigation__container", children: [ 42993 /* @__PURE__ */ (0, import_jsx_runtime268.jsx)("p", { className: "block-editor-block-navigation__label", children: (0, import_i18n112.__)("List view") }), 42994 /* @__PURE__ */ (0, import_jsx_runtime268.jsx)(list_view_default2, {}) 42995 ] }) 42996 } 42997 ); 42998 } 42999 var dropdown_default = (0, import_element142.forwardRef)(BlockNavigationDropdown); 43000 43001 // packages/block-editor/build-module/components/block-styles/index.js 43002 var import_element144 = __toESM(require_element()); 43003 var import_compose73 = __toESM(require_compose()); 43004 var import_components123 = __toESM(require_components()); 43005 43006 // packages/block-editor/build-module/components/block-styles/preview-panel.js 43007 var import_element143 = __toESM(require_element()); 43008 var import_jsx_runtime269 = __toESM(require_jsx_runtime()); 43009 function BlockStylesPreviewPanel({ 43010 genericPreviewBlock, 43011 style, 43012 className, 43013 activeStyle 43014 }) { 43015 const styleClassName = replaceActiveStyle(className, activeStyle, style); 43016 const previewBlocks = (0, import_element143.useMemo)(() => { 43017 return { 43018 name: genericPreviewBlock.name, 43019 title: style.label || style.name, 43020 description: style.description, 43021 initialAttributes: { 43022 ...genericPreviewBlock.attributes, 43023 className: styleClassName + " block-editor-block-styles__block-preview-container" 43024 }, 43025 example: genericPreviewBlock 43026 }; 43027 }, [genericPreviewBlock, style, styleClassName]); 43028 return /* @__PURE__ */ (0, import_jsx_runtime269.jsx)(preview_panel_default, { item: previewBlocks }); 43029 } 43030 43031 // packages/block-editor/build-module/components/block-styles/index.js 43032 var import_jsx_runtime270 = __toESM(require_jsx_runtime()); 43033 var noop11 = () => { 43034 }; 43035 function BlockStyles({ clientId, onSwitch = noop11, onHoverClassName = noop11 }) { 43036 const { 43037 onSelect, 43038 stylesToRender, 43039 activeStyle, 43040 genericPreviewBlock, 43041 className: previewClassName 43042 } = useStylesForBlocks({ 43043 clientId, 43044 onSwitch 43045 }); 43046 const [hoveredStyle, setHoveredStyle] = (0, import_element144.useState)(null); 43047 const isMobileViewport = (0, import_compose73.useViewportMatch)("medium", "<"); 43048 if (!stylesToRender || stylesToRender.length === 0) { 43049 return null; 43050 } 43051 const debouncedSetHoveredStyle = (0, import_compose73.debounce)(setHoveredStyle, 250); 43052 const onSelectStylePreview = (style) => { 43053 onSelect(style); 43054 onHoverClassName(null); 43055 setHoveredStyle(null); 43056 debouncedSetHoveredStyle.cancel(); 43057 }; 43058 const styleItemHandler = (item) => { 43059 if (hoveredStyle === item) { 43060 debouncedSetHoveredStyle.cancel(); 43061 return; 43062 } 43063 debouncedSetHoveredStyle(item); 43064 onHoverClassName(item?.name ?? null); 43065 }; 43066 return /* @__PURE__ */ (0, import_jsx_runtime270.jsxs)("div", { className: "block-editor-block-styles", children: [ 43067 /* @__PURE__ */ (0, import_jsx_runtime270.jsx)("div", { className: "block-editor-block-styles__variants", children: stylesToRender.map((style) => { 43068 const buttonText = style.label || style.name; 43069 return /* @__PURE__ */ (0, import_jsx_runtime270.jsx)( 43070 import_components123.Button, 43071 { 43072 __next40pxDefaultSize: true, 43073 className: clsx_default( 43074 "block-editor-block-styles__item", 43075 { 43076 "is-active": activeStyle.name === style.name 43077 } 43078 ), 43079 variant: "secondary", 43080 label: buttonText, 43081 onMouseEnter: () => styleItemHandler(style), 43082 onFocus: () => styleItemHandler(style), 43083 onMouseLeave: () => styleItemHandler(null), 43084 onBlur: () => styleItemHandler(null), 43085 onClick: () => onSelectStylePreview(style), 43086 "aria-current": activeStyle.name === style.name, 43087 children: /* @__PURE__ */ (0, import_jsx_runtime270.jsx)( 43088 import_components123.__experimentalTruncate, 43089 { 43090 numberOfLines: 1, 43091 className: "block-editor-block-styles__item-text", 43092 children: buttonText 43093 } 43094 ) 43095 }, 43096 style.name 43097 ); 43098 }) }), 43099 hoveredStyle && !isMobileViewport && /* @__PURE__ */ (0, import_jsx_runtime270.jsx)( 43100 import_components123.Popover, 43101 { 43102 placement: "left-start", 43103 offset: 34, 43104 focusOnMount: false, 43105 children: /* @__PURE__ */ (0, import_jsx_runtime270.jsx)( 43106 "div", 43107 { 43108 className: "block-editor-block-styles__preview-panel", 43109 onMouseLeave: () => styleItemHandler(null), 43110 children: /* @__PURE__ */ (0, import_jsx_runtime270.jsx)( 43111 BlockStylesPreviewPanel, 43112 { 43113 activeStyle, 43114 className: previewClassName, 43115 genericPreviewBlock, 43116 style: hoveredStyle 43117 } 43118 ) 43119 } 43120 ) 43121 } 43122 ) 43123 ] }); 43124 } 43125 var block_styles_default = BlockStyles; 43126 43127 // packages/block-editor/build-module/components/block-heading-level-dropdown/index.js 43128 var import_components125 = __toESM(require_components()); 43129 var import_i18n113 = __toESM(require_i18n()); 43130 43131 // packages/block-editor/build-module/components/block-heading-level-dropdown/heading-level-icon.js 43132 var import_components124 = __toESM(require_components()); 43133 var import_jsx_runtime271 = __toESM(require_jsx_runtime()); 43134 var LEVEL_TO_PATH = { 43135 0: paragraph_default, 43136 1: heading_level_1_default, 43137 2: heading_level_2_default, 43138 3: heading_level_3_default, 43139 4: heading_level_4_default, 43140 5: heading_level_5_default, 43141 6: heading_level_6_default 43142 }; 43143 function HeadingLevelIcon({ level }) { 43144 if (LEVEL_TO_PATH[level]) { 43145 return /* @__PURE__ */ (0, import_jsx_runtime271.jsx)(import_components124.Icon, { icon: LEVEL_TO_PATH[level] }); 43146 } 43147 return null; 43148 } 43149 43150 // packages/block-editor/build-module/components/block-heading-level-dropdown/index.js 43151 var import_jsx_runtime272 = __toESM(require_jsx_runtime()); 43152 var HEADING_LEVELS = [1, 2, 3, 4, 5, 6]; 43153 var POPOVER_PROPS6 = { 43154 className: "block-library-heading-level-dropdown" 43155 }; 43156 function HeadingLevelDropdown({ 43157 options = HEADING_LEVELS, 43158 value, 43159 onChange 43160 }) { 43161 const validOptions = options.filter( 43162 (option) => option === 0 || HEADING_LEVELS.includes(option) 43163 ).sort((a2, b2) => a2 - b2); 43164 return /* @__PURE__ */ (0, import_jsx_runtime272.jsx)( 43165 import_components125.ToolbarDropdownMenu, 43166 { 43167 popoverProps: POPOVER_PROPS6, 43168 icon: /* @__PURE__ */ (0, import_jsx_runtime272.jsx)(HeadingLevelIcon, { level: value }), 43169 label: (0, import_i18n113.__)("Change level"), 43170 controls: validOptions.map((targetLevel) => { 43171 const isActive = targetLevel === value; 43172 return { 43173 icon: /* @__PURE__ */ (0, import_jsx_runtime272.jsx)(HeadingLevelIcon, { level: targetLevel }), 43174 title: targetLevel === 0 ? (0, import_i18n113.__)("Paragraph") : (0, import_i18n113.sprintf)( 43175 // translators: %d: heading level e.g: "1", "2", "3" 43176 (0, import_i18n113.__)("Heading %d"), 43177 targetLevel 43178 ), 43179 isActive, 43180 onClick() { 43181 onChange(targetLevel); 43182 }, 43183 role: "menuitemradio" 43184 }; 43185 }) 43186 } 43187 ); 43188 } 43189 43190 // packages/block-editor/build-module/components/block-variation-picker/index.js 43191 var import_i18n114 = __toESM(require_i18n()); 43192 var import_components126 = __toESM(require_components()); 43193 var import_jsx_runtime273 = __toESM(require_jsx_runtime()); 43194 function BlockVariationPicker({ 43195 icon = layout_default, 43196 label = (0, import_i18n114.__)("Choose variation"), 43197 instructions = (0, import_i18n114.__)("Select a variation to start with:"), 43198 variations, 43199 onSelect, 43200 allowSkip 43201 }) { 43202 const classes = clsx_default("block-editor-block-variation-picker", { 43203 "has-many-variations": variations.length > 4 43204 }); 43205 return /* @__PURE__ */ (0, import_jsx_runtime273.jsxs)( 43206 import_components126.Placeholder, 43207 { 43208 icon, 43209 label, 43210 instructions, 43211 className: classes, 43212 children: [ 43213 /* @__PURE__ */ (0, import_jsx_runtime273.jsx)( 43214 "ul", 43215 { 43216 className: "block-editor-block-variation-picker__variations", 43217 role: "list", 43218 "aria-label": (0, import_i18n114.__)("Block variations"), 43219 children: variations.map((variation) => /* @__PURE__ */ (0, import_jsx_runtime273.jsxs)("li", { children: [ 43220 /* @__PURE__ */ (0, import_jsx_runtime273.jsx)( 43221 import_components126.Button, 43222 { 43223 __next40pxDefaultSize: true, 43224 variant: "tertiary", 43225 icon: variation.icon && variation.icon.src ? variation.icon.src : variation.icon, 43226 iconSize: 48, 43227 onClick: () => onSelect(variation), 43228 className: "block-editor-block-variation-picker__variation", 43229 label: variation.description || variation.title 43230 } 43231 ), 43232 /* @__PURE__ */ (0, import_jsx_runtime273.jsx)("span", { className: "block-editor-block-variation-picker__variation-label", children: variation.title }) 43233 ] }, variation.name)) 43234 } 43235 ), 43236 allowSkip && /* @__PURE__ */ (0, import_jsx_runtime273.jsx)("div", { className: "block-editor-block-variation-picker__skip", children: /* @__PURE__ */ (0, import_jsx_runtime273.jsx)( 43237 import_components126.Button, 43238 { 43239 __next40pxDefaultSize: true, 43240 variant: "link", 43241 onClick: () => onSelect(), 43242 children: (0, import_i18n114.__)("Skip") 43243 } 43244 ) }) 43245 ] 43246 } 43247 ); 43248 } 43249 var block_variation_picker_default = BlockVariationPicker; 43250 43251 // packages/block-editor/build-module/components/block-pattern-setup/index.js 43252 var import_data137 = __toESM(require_data()); 43253 var import_blocks79 = __toESM(require_blocks()); 43254 var import_components128 = __toESM(require_components()); 43255 var import_element145 = __toESM(require_element()); 43256 var import_compose74 = __toESM(require_compose()); 43257 var import_i18n116 = __toESM(require_i18n()); 43258 43259 // packages/block-editor/build-module/components/block-pattern-setup/setup-toolbar.js 43260 var import_i18n115 = __toESM(require_i18n()); 43261 var import_components127 = __toESM(require_components()); 43262 43263 // packages/block-editor/build-module/components/block-pattern-setup/constants.js 43264 var VIEWMODES = { 43265 carousel: "carousel", 43266 grid: "grid" 43267 }; 43268 43269 // packages/block-editor/build-module/components/block-pattern-setup/setup-toolbar.js 43270 var import_jsx_runtime274 = __toESM(require_jsx_runtime()); 43271 var Actions = ({ onBlockPatternSelect }) => /* @__PURE__ */ (0, import_jsx_runtime274.jsx)("div", { className: "block-editor-block-pattern-setup__actions", children: /* @__PURE__ */ (0, import_jsx_runtime274.jsx)( 43272 import_components127.Button, 43273 { 43274 __next40pxDefaultSize: true, 43275 variant: "primary", 43276 onClick: onBlockPatternSelect, 43277 children: (0, import_i18n115.__)("Choose") 43278 } 43279 ) }); 43280 var CarouselNavigation = ({ 43281 handlePrevious, 43282 handleNext, 43283 activeSlide, 43284 totalSlides 43285 }) => /* @__PURE__ */ (0, import_jsx_runtime274.jsxs)("div", { className: "block-editor-block-pattern-setup__navigation", children: [ 43286 /* @__PURE__ */ (0, import_jsx_runtime274.jsx)( 43287 import_components127.Button, 43288 { 43289 size: "compact", 43290 icon: (0, import_i18n115.isRTL)() ? chevron_right_default : chevron_left_default, 43291 label: (0, import_i18n115.__)("Previous pattern"), 43292 onClick: handlePrevious, 43293 disabled: activeSlide === 0, 43294 accessibleWhenDisabled: true 43295 } 43296 ), 43297 /* @__PURE__ */ (0, import_jsx_runtime274.jsx)( 43298 import_components127.Button, 43299 { 43300 size: "compact", 43301 icon: (0, import_i18n115.isRTL)() ? chevron_left_default : chevron_right_default, 43302 label: (0, import_i18n115.__)("Next pattern"), 43303 onClick: handleNext, 43304 disabled: activeSlide === totalSlides - 1, 43305 accessibleWhenDisabled: true 43306 } 43307 ) 43308 ] }); 43309 var SetupToolbar = ({ 43310 viewMode, 43311 setViewMode, 43312 handlePrevious, 43313 handleNext, 43314 activeSlide, 43315 totalSlides, 43316 onBlockPatternSelect 43317 }) => { 43318 const isCarouselView = viewMode === VIEWMODES.carousel; 43319 const displayControls = /* @__PURE__ */ (0, import_jsx_runtime274.jsxs)("div", { className: "block-editor-block-pattern-setup__display-controls", children: [ 43320 /* @__PURE__ */ (0, import_jsx_runtime274.jsx)( 43321 import_components127.Button, 43322 { 43323 size: "compact", 43324 icon: stretch_full_width_default, 43325 label: (0, import_i18n115.__)("Carousel view"), 43326 onClick: () => setViewMode(VIEWMODES.carousel), 43327 isPressed: isCarouselView 43328 } 43329 ), 43330 /* @__PURE__ */ (0, import_jsx_runtime274.jsx)( 43331 import_components127.Button, 43332 { 43333 size: "compact", 43334 icon: grid_default, 43335 label: (0, import_i18n115.__)("Grid view"), 43336 onClick: () => setViewMode(VIEWMODES.grid), 43337 isPressed: viewMode === VIEWMODES.grid 43338 } 43339 ) 43340 ] }); 43341 return /* @__PURE__ */ (0, import_jsx_runtime274.jsxs)("div", { className: "block-editor-block-pattern-setup__toolbar", children: [ 43342 isCarouselView && /* @__PURE__ */ (0, import_jsx_runtime274.jsx)( 43343 CarouselNavigation, 43344 { 43345 handlePrevious, 43346 handleNext, 43347 activeSlide, 43348 totalSlides 43349 } 43350 ), 43351 displayControls, 43352 isCarouselView && /* @__PURE__ */ (0, import_jsx_runtime274.jsx)(Actions, { onBlockPatternSelect }) 43353 ] }); 43354 }; 43355 var setup_toolbar_default = SetupToolbar; 43356 43357 // packages/block-editor/build-module/components/block-pattern-setup/use-patterns-setup.js 43358 var import_data136 = __toESM(require_data()); 43359 function usePatternsSetup(clientId, blockName, filterPatternsFn) { 43360 return (0, import_data136.useSelect)( 43361 (select3) => { 43362 const { 43363 getBlockRootClientId: getBlockRootClientId2, 43364 getPatternsByBlockTypes: getPatternsByBlockTypes2, 43365 __experimentalGetAllowedPatterns: __experimentalGetAllowedPatterns2 43366 } = select3(store); 43367 const rootClientId = getBlockRootClientId2(clientId); 43368 if (filterPatternsFn) { 43369 return __experimentalGetAllowedPatterns2(rootClientId).filter( 43370 filterPatternsFn 43371 ); 43372 } 43373 return getPatternsByBlockTypes2(blockName, rootClientId); 43374 }, 43375 [clientId, blockName, filterPatternsFn] 43376 ); 43377 } 43378 var use_patterns_setup_default = usePatternsSetup; 43379 43380 // packages/block-editor/build-module/components/block-pattern-setup/index.js 43381 var import_jsx_runtime275 = __toESM(require_jsx_runtime()); 43382 var SetupContent = ({ 43383 viewMode, 43384 activeSlide, 43385 patterns, 43386 onBlockPatternSelect, 43387 showTitles 43388 }) => { 43389 const containerClass = "block-editor-block-pattern-setup__container"; 43390 if (viewMode === VIEWMODES.carousel) { 43391 const slideClass = /* @__PURE__ */ new Map([ 43392 [activeSlide, "active-slide"], 43393 [activeSlide - 1, "previous-slide"], 43394 [activeSlide + 1, "next-slide"] 43395 ]); 43396 return /* @__PURE__ */ (0, import_jsx_runtime275.jsx)("div", { className: "block-editor-block-pattern-setup__carousel", children: /* @__PURE__ */ (0, import_jsx_runtime275.jsx)("div", { className: containerClass, children: /* @__PURE__ */ (0, import_jsx_runtime275.jsx)("div", { className: "carousel-container", children: patterns.map((pattern, index) => /* @__PURE__ */ (0, import_jsx_runtime275.jsx)( 43397 BlockPatternSlide, 43398 { 43399 active: index === activeSlide, 43400 className: slideClass.get(index) || "", 43401 pattern 43402 }, 43403 pattern.name 43404 )) }) }) }); 43405 } 43406 return /* @__PURE__ */ (0, import_jsx_runtime275.jsx)("div", { className: "block-editor-block-pattern-setup__grid", children: /* @__PURE__ */ (0, import_jsx_runtime275.jsx)( 43407 import_components128.Composite, 43408 { 43409 role: "listbox", 43410 className: containerClass, 43411 "aria-label": (0, import_i18n116.__)("Patterns list"), 43412 children: patterns.map((pattern) => /* @__PURE__ */ (0, import_jsx_runtime275.jsx)( 43413 BlockPattern3, 43414 { 43415 pattern, 43416 onSelect: onBlockPatternSelect, 43417 showTitles 43418 }, 43419 pattern.name 43420 )) 43421 } 43422 ) }); 43423 }; 43424 function BlockPattern3({ pattern, onSelect, showTitles }) { 43425 const baseClassName = "block-editor-block-pattern-setup-list"; 43426 const { blocks: blocks2, description, viewportWidth = 700 } = pattern; 43427 const descriptionId = (0, import_compose74.useInstanceId)( 43428 BlockPattern3, 43429 `$baseClassName}__item-description` 43430 ); 43431 return /* @__PURE__ */ (0, import_jsx_runtime275.jsx)("div", { className: `$baseClassName}__list-item`, children: /* @__PURE__ */ (0, import_jsx_runtime275.jsxs)( 43432 import_components128.Composite.Item, 43433 { 43434 render: /* @__PURE__ */ (0, import_jsx_runtime275.jsx)( 43435 "div", 43436 { 43437 "aria-describedby": description ? descriptionId : void 0, 43438 "aria-label": pattern.title, 43439 className: `$baseClassName}__item` 43440 } 43441 ), 43442 id: `$baseClassName}__pattern__$pattern.name}`, 43443 role: "option", 43444 onClick: () => onSelect(blocks2), 43445 children: [ 43446 /* @__PURE__ */ (0, import_jsx_runtime275.jsx)( 43447 block_preview_default, 43448 { 43449 blocks: blocks2, 43450 viewportWidth 43451 } 43452 ), 43453 showTitles && /* @__PURE__ */ (0, import_jsx_runtime275.jsx)("div", { className: `$baseClassName}__item-title`, children: pattern.title }), 43454 !!description && /* @__PURE__ */ (0, import_jsx_runtime275.jsx)(import_components128.VisuallyHidden, { id: descriptionId, children: description }) 43455 ] 43456 } 43457 ) }); 43458 } 43459 function BlockPatternSlide({ active, className, pattern, minHeight }) { 43460 const { blocks: blocks2, title, description } = pattern; 43461 const descriptionId = (0, import_compose74.useInstanceId)( 43462 BlockPatternSlide, 43463 "block-editor-block-pattern-setup-list__item-description" 43464 ); 43465 return /* @__PURE__ */ (0, import_jsx_runtime275.jsxs)( 43466 "div", 43467 { 43468 "aria-hidden": !active, 43469 role: "img", 43470 className: `pattern-slide $className}`, 43471 "aria-label": title, 43472 "aria-describedby": description ? descriptionId : void 0, 43473 children: [ 43474 /* @__PURE__ */ (0, import_jsx_runtime275.jsx)(block_preview_default, { blocks: blocks2, minHeight }), 43475 !!description && /* @__PURE__ */ (0, import_jsx_runtime275.jsx)(import_components128.VisuallyHidden, { id: descriptionId, children: description }) 43476 ] 43477 } 43478 ); 43479 } 43480 var BlockPatternSetup = ({ 43481 clientId, 43482 blockName, 43483 filterPatternsFn, 43484 onBlockPatternSelect, 43485 initialViewMode = VIEWMODES.carousel, 43486 showTitles = false 43487 }) => { 43488 const [viewMode, setViewMode] = (0, import_element145.useState)(initialViewMode); 43489 const [activeSlide, setActiveSlide] = (0, import_element145.useState)(0); 43490 const { replaceBlock: replaceBlock2 } = (0, import_data137.useDispatch)(store); 43491 const patterns = use_patterns_setup_default(clientId, blockName, filterPatternsFn); 43492 if (!patterns?.length) { 43493 return null; 43494 } 43495 const onBlockPatternSelectDefault = (blocks2) => { 43496 const clonedBlocks = blocks2.map((block) => (0, import_blocks79.cloneBlock)(block)); 43497 replaceBlock2(clientId, clonedBlocks); 43498 }; 43499 const onPatternSelectCallback = onBlockPatternSelect || onBlockPatternSelectDefault; 43500 return /* @__PURE__ */ (0, import_jsx_runtime275.jsx)(import_jsx_runtime275.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime275.jsxs)( 43501 "div", 43502 { 43503 className: `block-editor-block-pattern-setup view-mode-$viewMode}`, 43504 children: [ 43505 /* @__PURE__ */ (0, import_jsx_runtime275.jsx)( 43506 SetupContent, 43507 { 43508 viewMode, 43509 activeSlide, 43510 patterns, 43511 onBlockPatternSelect: onPatternSelectCallback, 43512 showTitles 43513 } 43514 ), 43515 /* @__PURE__ */ (0, import_jsx_runtime275.jsx)( 43516 setup_toolbar_default, 43517 { 43518 viewMode, 43519 setViewMode, 43520 activeSlide, 43521 totalSlides: patterns.length, 43522 handleNext: () => { 43523 setActiveSlide( 43524 (active) => Math.min(active + 1, patterns.length - 1) 43525 ); 43526 }, 43527 handlePrevious: () => { 43528 setActiveSlide( 43529 (active) => Math.max(active - 1, 0) 43530 ); 43531 }, 43532 onBlockPatternSelect: () => { 43533 onPatternSelectCallback( 43534 patterns[activeSlide].blocks 43535 ); 43536 } 43537 } 43538 ) 43539 ] 43540 } 43541 ) }); 43542 }; 43543 var block_pattern_setup_default = BlockPatternSetup; 43544 43545 // packages/block-editor/build-module/components/block-variation-transforms/index.js 43546 var import_blocks80 = __toESM(require_blocks()); 43547 var import_i18n117 = __toESM(require_i18n()); 43548 var import_components129 = __toESM(require_components()); 43549 var import_data138 = __toESM(require_data()); 43550 var import_element146 = __toESM(require_element()); 43551 var import_jsx_runtime276 = __toESM(require_jsx_runtime()); 43552 var { Menu: Menu3 } = unlock(import_components129.privateApis); 43553 function VariationsButtons({ 43554 className, 43555 onSelectVariation, 43556 selectedValue, 43557 variations 43558 }) { 43559 return /* @__PURE__ */ (0, import_jsx_runtime276.jsxs)("fieldset", { className, children: [ 43560 /* @__PURE__ */ (0, import_jsx_runtime276.jsx)(import_components129.VisuallyHidden, { as: "legend", children: (0, import_i18n117.__)("Transform to variation") }), 43561 variations.map((variation) => /* @__PURE__ */ (0, import_jsx_runtime276.jsx)( 43562 import_components129.Button, 43563 { 43564 __next40pxDefaultSize: true, 43565 size: "compact", 43566 icon: /* @__PURE__ */ (0, import_jsx_runtime276.jsx)(block_icon_default, { icon: variation.icon, showColors: true }), 43567 isPressed: selectedValue === variation.name, 43568 label: selectedValue === variation.name ? variation.title : (0, import_i18n117.sprintf)( 43569 /* translators: %s: Block or block variation name. */ 43570 (0, import_i18n117.__)("Transform to %s"), 43571 variation.title 43572 ), 43573 onClick: () => onSelectVariation(variation.name), 43574 "aria-label": variation.title, 43575 showTooltip: true 43576 }, 43577 variation.name 43578 )) 43579 ] }); 43580 } 43581 function VariationsDropdown({ 43582 className, 43583 onSelectVariation, 43584 selectedValue, 43585 variations 43586 }) { 43587 return /* @__PURE__ */ (0, import_jsx_runtime276.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime276.jsxs)(Menu3, { children: [ 43588 /* @__PURE__ */ (0, import_jsx_runtime276.jsx)( 43589 Menu3.TriggerButton, 43590 { 43591 render: /* @__PURE__ */ (0, import_jsx_runtime276.jsx)( 43592 import_components129.Button, 43593 { 43594 className: "block-editor-block-variation-transforms__button", 43595 __next40pxDefaultSize: true, 43596 variant: "secondary", 43597 children: (0, import_i18n117.__)("Transform to variation") 43598 } 43599 ) 43600 } 43601 ), 43602 /* @__PURE__ */ (0, import_jsx_runtime276.jsx)(Menu3.Popover, { position: "bottom", children: /* @__PURE__ */ (0, import_jsx_runtime276.jsx)(Menu3.Group, { children: variations.map((variation) => /* @__PURE__ */ (0, import_jsx_runtime276.jsxs)( 43603 Menu3.RadioItem, 43604 { 43605 value: variation.name, 43606 checked: selectedValue === variation.name, 43607 onChange: () => onSelectVariation(variation.name), 43608 children: [ 43609 /* @__PURE__ */ (0, import_jsx_runtime276.jsx)(Menu3.ItemLabel, { children: variation.title }), 43610 variation.description && /* @__PURE__ */ (0, import_jsx_runtime276.jsx)(Menu3.ItemHelpText, { children: variation.description }) 43611 ] 43612 }, 43613 variation.name 43614 )) }) }) 43615 ] }) }); 43616 } 43617 function VariationsToggleGroupControl({ 43618 className, 43619 onSelectVariation, 43620 selectedValue, 43621 variations 43622 }) { 43623 return /* @__PURE__ */ (0, import_jsx_runtime276.jsx)("div", { className, children: /* @__PURE__ */ (0, import_jsx_runtime276.jsx)( 43624 import_components129.__experimentalToggleGroupControl, 43625 { 43626 label: (0, import_i18n117.__)("Transform to variation"), 43627 value: selectedValue, 43628 hideLabelFromVision: true, 43629 onChange: onSelectVariation, 43630 __next40pxDefaultSize: true, 43631 children: variations.map((variation) => /* @__PURE__ */ (0, import_jsx_runtime276.jsx)( 43632 import_components129.__experimentalToggleGroupControlOptionIcon, 43633 { 43634 icon: /* @__PURE__ */ (0, import_jsx_runtime276.jsx)(block_icon_default, { icon: variation.icon, showColors: true }), 43635 value: variation.name, 43636 label: selectedValue === variation.name ? variation.title : (0, import_i18n117.sprintf)( 43637 /* translators: %s: Block or block variation name. */ 43638 (0, import_i18n117.__)("Transform to %s"), 43639 variation.title 43640 ) 43641 }, 43642 variation.name 43643 )) 43644 } 43645 ) }); 43646 } 43647 function __experimentalBlockVariationTransforms({ blockClientId }) { 43648 const { updateBlockAttributes: updateBlockAttributes2 } = (0, import_data138.useDispatch)(store); 43649 const { activeBlockVariation, variations, isContentOnly, isSection } = (0, import_data138.useSelect)( 43650 (select3) => { 43651 const { getActiveBlockVariation, getBlockVariations: getBlockVariations2 } = select3(import_blocks80.store); 43652 const { 43653 getBlockName: getBlockName2, 43654 getBlockAttributes: getBlockAttributes3, 43655 getBlockEditingMode: getBlockEditingMode2, 43656 isSectionBlock: isSectionBlock2 43657 } = unlock(select3(store)); 43658 const name = blockClientId && getBlockName2(blockClientId); 43659 const { hasContentRoleAttribute } = unlock( 43660 select3(import_blocks80.store) 43661 ); 43662 const isContentBlock4 = hasContentRoleAttribute(name); 43663 return { 43664 activeBlockVariation: getActiveBlockVariation( 43665 name, 43666 getBlockAttributes3(blockClientId), 43667 "transform" 43668 ), 43669 variations: name && getBlockVariations2(name, "transform"), 43670 isContentOnly: getBlockEditingMode2(blockClientId) === "contentOnly" && !isContentBlock4, 43671 isSection: isSectionBlock2(blockClientId) 43672 }; 43673 }, 43674 [blockClientId] 43675 ); 43676 const selectedValue = activeBlockVariation?.name; 43677 const hasUniqueIcons = (0, import_element146.useMemo)(() => { 43678 const variationIcons = /* @__PURE__ */ new Set(); 43679 if (!variations) { 43680 return false; 43681 } 43682 variations.forEach((variation) => { 43683 if (variation.icon) { 43684 variationIcons.add(variation.icon?.src || variation.icon); 43685 } 43686 }); 43687 return variationIcons.size === variations.length; 43688 }, [variations]); 43689 const onSelectVariation = (variationName) => { 43690 updateBlockAttributes2(blockClientId, { 43691 ...variations.find(({ name }) => name === variationName).attributes 43692 }); 43693 }; 43694 const hideVariationsForSections = window?.__experimentalContentOnlyPatternInsertion && isSection; 43695 if (!variations?.length || isContentOnly || hideVariationsForSections) { 43696 return null; 43697 } 43698 const baseClass = "block-editor-block-variation-transforms"; 43699 const showButtons = variations.length > 5; 43700 const ButtonComponent = showButtons ? VariationsButtons : VariationsToggleGroupControl; 43701 const Component7 = hasUniqueIcons ? ButtonComponent : VariationsDropdown; 43702 return /* @__PURE__ */ (0, import_jsx_runtime276.jsx)( 43703 Component7, 43704 { 43705 className: baseClass, 43706 onSelectVariation, 43707 selectedValue, 43708 variations 43709 } 43710 ); 43711 } 43712 var block_variation_transforms_default = __experimentalBlockVariationTransforms; 43713 43714 // packages/block-editor/build-module/components/block-vertical-alignment-control/ui.js 43715 var import_i18n118 = __toESM(require_i18n()); 43716 var import_components130 = __toESM(require_components()); 43717 var import_jsx_runtime277 = __toESM(require_jsx_runtime()); 43718 var BLOCK_ALIGNMENTS_CONTROLS2 = { 43719 top: { 43720 icon: justify_top_default, 43721 title: (0, import_i18n118._x)("Align top", "Block vertical alignment setting") 43722 }, 43723 center: { 43724 icon: justify_center_vertical_default, 43725 title: (0, import_i18n118._x)("Align middle", "Block vertical alignment setting") 43726 }, 43727 bottom: { 43728 icon: justify_bottom_default, 43729 title: (0, import_i18n118._x)("Align bottom", "Block vertical alignment setting") 43730 }, 43731 stretch: { 43732 icon: justify_stretch_vertical_default, 43733 title: (0, import_i18n118._x)("Stretch to fill", "Block vertical alignment setting") 43734 }, 43735 "space-between": { 43736 icon: justify_space_between_vertical_default, 43737 title: (0, import_i18n118._x)("Space between", "Block vertical alignment setting") 43738 } 43739 }; 43740 var DEFAULT_CONTROLS2 = ["top", "center", "bottom"]; 43741 var DEFAULT_CONTROL2 = "top"; 43742 function BlockVerticalAlignmentUI({ 43743 value, 43744 onChange, 43745 controls = DEFAULT_CONTROLS2, 43746 isCollapsed: isCollapsed3 = true, 43747 isToolbar 43748 }) { 43749 function applyOrUnset(align) { 43750 return () => onChange(value === align ? void 0 : align); 43751 } 43752 const activeAlignment = BLOCK_ALIGNMENTS_CONTROLS2[value]; 43753 const defaultAlignmentControl = BLOCK_ALIGNMENTS_CONTROLS2[DEFAULT_CONTROL2]; 43754 const UIComponent = isToolbar ? import_components130.ToolbarGroup : import_components130.ToolbarDropdownMenu; 43755 const extraProps = isToolbar ? { isCollapsed: isCollapsed3 } : {}; 43756 return /* @__PURE__ */ (0, import_jsx_runtime277.jsx)( 43757 UIComponent, 43758 { 43759 icon: activeAlignment ? activeAlignment.icon : defaultAlignmentControl.icon, 43760 label: (0, import_i18n118._x)( 43761 "Change vertical alignment", 43762 "Block vertical alignment setting label" 43763 ), 43764 controls: controls.map((control) => { 43765 return { 43766 ...BLOCK_ALIGNMENTS_CONTROLS2[control], 43767 isActive: value === control, 43768 role: isCollapsed3 ? "menuitemradio" : void 0, 43769 onClick: applyOrUnset(control) 43770 }; 43771 }), 43772 ...extraProps 43773 } 43774 ); 43775 } 43776 var ui_default3 = BlockVerticalAlignmentUI; 43777 43778 // packages/block-editor/build-module/components/block-vertical-alignment-control/index.js 43779 var import_jsx_runtime278 = __toESM(require_jsx_runtime()); 43780 var BlockVerticalAlignmentControl = (props) => { 43781 return /* @__PURE__ */ (0, import_jsx_runtime278.jsx)(ui_default3, { ...props, isToolbar: false }); 43782 }; 43783 var BlockVerticalAlignmentToolbar = (props) => { 43784 return /* @__PURE__ */ (0, import_jsx_runtime278.jsx)(ui_default3, { ...props, isToolbar: true }); 43785 }; 43786 43787 // packages/block-editor/build-module/components/border-radius-control/index.js 43788 var import_components135 = __toESM(require_components()); 43789 var import_element148 = __toESM(require_element()); 43790 var import_i18n122 = __toESM(require_i18n()); 43791 43792 // packages/block-editor/build-module/components/border-radius-control/linked-button.js 43793 var import_components131 = __toESM(require_components()); 43794 var import_i18n119 = __toESM(require_i18n()); 43795 var import_jsx_runtime279 = __toESM(require_jsx_runtime()); 43796 function LinkedButton({ isLinked, ...props }) { 43797 const label = isLinked ? (0, import_i18n119.__)("Unlink radii") : (0, import_i18n119.__)("Link radii"); 43798 return /* @__PURE__ */ (0, import_jsx_runtime279.jsx)( 43799 import_components131.Button, 43800 { 43801 ...props, 43802 className: "components-border-radius-control__linked-button", 43803 size: "small", 43804 icon: isLinked ? link_default : link_off_default, 43805 iconSize: 24, 43806 label 43807 } 43808 ); 43809 } 43810 43811 // packages/block-editor/build-module/components/border-radius-control/utils.js 43812 var import_components132 = __toESM(require_components()); 43813 function mode(inputArray) { 43814 const arr = [...inputArray]; 43815 return arr.sort( 43816 (a2, b2) => inputArray.filter((v2) => v2 === b2).length - inputArray.filter((v2) => v2 === a2).length 43817 ).shift(); 43818 } 43819 function getAllValue(values = {}) { 43820 if (typeof values === "string") { 43821 return values; 43822 } 43823 const parsedQuantitiesAndUnits = Object.values(values).map((value2) => { 43824 const newValue = (0, import_components132.__experimentalParseQuantityAndUnitFromRawValue)(value2); 43825 if (typeof value2 === "string" && newValue[0] === void 0) { 43826 return [value2, ""]; 43827 } 43828 return newValue; 43829 }); 43830 const allValues = parsedQuantitiesAndUnits.map( 43831 (value2) => value2[0] ?? "" 43832 ); 43833 const allUnits = parsedQuantitiesAndUnits.map((value2) => value2[1]); 43834 const value = allValues.every((v2) => v2 === allValues[0]) ? allValues[0] : ""; 43835 const unit = mode(allUnits); 43836 const allValue = value === 0 || value ? `$value}$unit || ""}` : void 0; 43837 return allValue; 43838 } 43839 function hasMixedValues(values = {}) { 43840 if (typeof values === "string") { 43841 return false; 43842 } 43843 if (!values || typeof values !== "object") { 43844 return false; 43845 } 43846 const cornerValues = Object.values(values); 43847 if (cornerValues.length === 0) { 43848 return false; 43849 } 43850 const firstValue = cornerValues[0]; 43851 const allSame = cornerValues.every((value) => value === firstValue); 43852 return !allSame; 43853 } 43854 function hasDefinedValues(values) { 43855 if (!values) { 43856 return false; 43857 } 43858 if (typeof values === "string") { 43859 return true; 43860 } 43861 const filteredValues = Object.values(values).filter((value) => { 43862 return !!value || value === 0; 43863 }); 43864 return !!filteredValues.length; 43865 } 43866 43867 // packages/block-editor/build-module/components/preset-input-control/index.js 43868 var import_components134 = __toESM(require_components()); 43869 var import_compose75 = __toESM(require_compose()); 43870 var import_i18n120 = __toESM(require_i18n()); 43871 var import_element147 = __toESM(require_element()); 43872 43873 // packages/block-editor/build-module/components/preset-input-control/constants.js 43874 var ICON_SIZE = 24; 43875 var RANGE_CONTROL_MAX_SIZE2 = 8; 43876 var CUSTOM_VALUE_SETTINGS = { 43877 px: { max: 300, steps: 1 }, 43878 "%": { max: 100, steps: 1 }, 43879 vw: { max: 100, steps: 1 }, 43880 vh: { max: 100, steps: 1 }, 43881 em: { max: 10, steps: 0.1 }, 43882 rem: { max: 10, steps: 0.1 }, 43883 svw: { max: 100, steps: 1 }, 43884 lvw: { max: 100, steps: 1 }, 43885 dvw: { max: 100, steps: 1 }, 43886 svh: { max: 100, steps: 1 }, 43887 lvh: { max: 100, steps: 1 }, 43888 dvh: { max: 100, steps: 1 }, 43889 vi: { max: 100, steps: 1 }, 43890 svi: { max: 100, steps: 1 }, 43891 lvi: { max: 100, steps: 1 }, 43892 dvi: { max: 100, steps: 1 }, 43893 vb: { max: 100, steps: 1 }, 43894 svb: { max: 100, steps: 1 }, 43895 lvb: { max: 100, steps: 1 }, 43896 dvb: { max: 100, steps: 1 }, 43897 vmin: { max: 100, steps: 1 }, 43898 svmin: { max: 100, steps: 1 }, 43899 lvmin: { max: 100, steps: 1 }, 43900 dvmin: { max: 100, steps: 1 }, 43901 vmax: { max: 100, steps: 1 }, 43902 svmax: { max: 100, steps: 1 }, 43903 lvmax: { max: 100, steps: 1 }, 43904 dvmax: { max: 100, steps: 1 } 43905 }; 43906 43907 // packages/block-editor/build-module/components/preset-input-control/utils.js 43908 var isValuePreset = (value, slug) => { 43909 if (!value?.includes) { 43910 return false; 43911 } 43912 return value === "0" || value.includes(`var:preset|$slug}|`); 43913 }; 43914 function getPresetSlug(value, presetType) { 43915 if (!value) { 43916 return; 43917 } 43918 if (value === "0" || value === "default") { 43919 return value; 43920 } 43921 const slug = value.match( 43922 new RegExp(`var:preset\\|$presetType}\\|(.+)`) 43923 ); 43924 return slug ? slug[1] : void 0; 43925 } 43926 function getSliderValueFromPreset(presetValue, presets, presetType) { 43927 if (presetValue === void 0) { 43928 return 0; 43929 } 43930 const slug = parseFloat(presetValue, 10) === 0 ? "0" : getPresetSlug(presetValue, presetType); 43931 const sliderValue = presets.findIndex((size) => { 43932 return String(size.slug) === slug; 43933 }); 43934 return sliderValue !== -1 ? sliderValue : NaN; 43935 } 43936 function getCustomValueFromPreset2(value, presets, presetType) { 43937 if (!isValuePreset(value, presetType)) { 43938 return value; 43939 } 43940 const slug = parseFloat(value, 10) === 0 ? "0" : getPresetSlug(value, presetType); 43941 const preset = presets.find((size) => String(size.slug) === slug); 43942 return preset?.size; 43943 } 43944 function getPresetValueFromCustomValue2(value, spacingSizes, presetType) { 43945 if (!value || isValuePreset(value, presetType) || value === "0") { 43946 return value; 43947 } 43948 const spacingMatch = spacingSizes.find( 43949 (size) => String(size.size) === String(value) 43950 ); 43951 if (spacingMatch?.slug) { 43952 return `var:preset|$presetType}|$spacingMatch.slug}`; 43953 } 43954 return value; 43955 } 43956 43957 // packages/block-editor/build-module/components/preset-input-control/custom-value-controls.js 43958 var import_components133 = __toESM(require_components()); 43959 var import_jsx_runtime280 = __toESM(require_jsx_runtime()); 43960 function CustomValueControls({ 43961 allowNegativeOnDrag, 43962 ariaLabel, 43963 allPlaceholder, 43964 minValue, 43965 parsedQuantity, 43966 computedUnit, 43967 units: units2, 43968 isMixed, 43969 step, 43970 max, 43971 showTooltip, 43972 value, 43973 minimumCustomValue, 43974 onCustomValueChange, 43975 onCustomValueSliderChange, 43976 onUnitChange, 43977 onMouseOut, 43978 onMouseOver, 43979 setMinValue 43980 }) { 43981 const unitControl = /* @__PURE__ */ (0, import_jsx_runtime280.jsx)( 43982 import_components133.__experimentalUnitControl, 43983 { 43984 className: "preset-input-control__unit-control", 43985 disableUnits: isMixed, 43986 hideLabelFromVision: true, 43987 label: ariaLabel, 43988 min: minValue, 43989 onChange: onCustomValueChange, 43990 onUnitChange, 43991 onBlur: onMouseOut, 43992 onFocus: onMouseOver, 43993 onMouseOut, 43994 onMouseOver, 43995 size: "__unstable-large", 43996 units: units2, 43997 value: [parsedQuantity, computedUnit].join(""), 43998 placeholder: allPlaceholder, 43999 onDragStart: () => { 44000 if (allowNegativeOnDrag && value?.charAt(0) === "-") { 44001 setMinValue(0); 44002 } 44003 }, 44004 onDrag: () => { 44005 if (allowNegativeOnDrag && value?.charAt(0) === "-") { 44006 setMinValue(0); 44007 } 44008 }, 44009 onDragEnd: () => { 44010 if (allowNegativeOnDrag) { 44011 setMinValue(minimumCustomValue); 44012 } 44013 } 44014 } 44015 ); 44016 const wrappedUnitControl = showTooltip ? /* @__PURE__ */ (0, import_jsx_runtime280.jsx)(import_components133.Tooltip, { text: ariaLabel, placement: "top", children: /* @__PURE__ */ (0, import_jsx_runtime280.jsx)("div", { className: "preset-input-control__tooltip-wrapper", children: unitControl }) }) : unitControl; 44017 return /* @__PURE__ */ (0, import_jsx_runtime280.jsxs)(import_jsx_runtime280.Fragment, { children: [ 44018 wrappedUnitControl, 44019 /* @__PURE__ */ (0, import_jsx_runtime280.jsx)( 44020 import_components133.RangeControl, 44021 { 44022 className: "preset-input-control__custom-value-range", 44023 hideLabelFromVision: true, 44024 initialPosition: 0, 44025 label: ariaLabel, 44026 max, 44027 min: 0, 44028 onBlur: onMouseOut, 44029 onChange: onCustomValueSliderChange, 44030 onFocus: onMouseOver, 44031 onMouseOut, 44032 onMouseOver, 44033 step, 44034 value: parsedQuantity, 44035 withInputField: false, 44036 __next40pxDefaultSize: true 44037 } 44038 ) 44039 ] }); 44040 } 44041 44042 // packages/block-editor/build-module/components/preset-input-control/index.js 44043 var import_jsx_runtime281 = __toESM(require_jsx_runtime()); 44044 function PresetInputControl({ 44045 allowNegativeOnDrag = false, 44046 ariaLabel, 44047 className: classNameProp, 44048 customValueSettings = CUSTOM_VALUE_SETTINGS, 44049 disableCustomValues, 44050 icon, 44051 isMixed, 44052 value: valueProp, 44053 minimumCustomValue, 44054 onChange, 44055 onMouseOut, 44056 onMouseOver, 44057 onUnitChange, 44058 presets = [], 44059 presetType, 44060 selectedUnit, 44061 showTooltip, 44062 units: units2 44063 }) { 44064 const value = (0, import_element147.useMemo)( 44065 () => getPresetValueFromCustomValue2(valueProp, presets, presetType), 44066 [valueProp, presets, presetType] 44067 ); 44068 const className = classNameProp ?? "preset-input-control"; 44069 const marks = presets.slice(1, presets.length - 1).map((_newValue, index) => ({ 44070 value: index + 1, 44071 label: void 0 44072 })); 44073 const hasPresets = marks.length > 0; 44074 const showRangeControl = presets.length <= RANGE_CONTROL_MAX_SIZE2; 44075 const allPlaceholder = isMixed ? (0, import_i18n120.__)("Mixed") : null; 44076 const [minValue, setMinValue] = (0, import_element147.useState)(minimumCustomValue); 44077 const [showCustomValueControl, setShowCustomValueControl] = (0, import_element147.useState)( 44078 !disableCustomValues && value !== void 0 && !isValuePreset(value, presetType) 44079 ); 44080 let currentValue = null; 44081 const previousValue = (0, import_compose75.usePrevious)(value); 44082 (0, import_element147.useEffect)(() => { 44083 if (!!value && previousValue !== value && !isValuePreset(value, presetType) && showCustomValueControl !== true) { 44084 setShowCustomValueControl(true); 44085 } 44086 }, [value, previousValue, presetType, showCustomValueControl]); 44087 const showCustomValueInSelectList = !showRangeControl && !showCustomValueControl && value !== void 0 && (!isValuePreset(value, presetType) || isValuePreset(value, presetType) && isMixed); 44088 let selectListOptions = presets; 44089 if (showCustomValueInSelectList) { 44090 selectListOptions = [ 44091 ...presets, 44092 { 44093 name: !isMixed ? ( 44094 // translators: %s: A custom measurement, e.g. a number followed by a unit like 12px. 44095 (0, import_i18n120.sprintf)((0, import_i18n120.__)("Custom (%s)"), value) 44096 ) : (0, import_i18n120.__)("Mixed"), 44097 slug: "custom", 44098 size: value 44099 } 44100 ]; 44101 currentValue = selectListOptions.length - 1; 44102 } else if (!isMixed) { 44103 currentValue = !showCustomValueControl ? getSliderValueFromPreset(value, presets, presetType) : getCustomValueFromPreset2(value, presets, presetType); 44104 } 44105 const options = selectListOptions.map((size, index) => ({ 44106 key: index, 44107 name: size.name 44108 })); 44109 const resolvedPresetValue = isValuePreset(value, presetType) ? getCustomValueFromPreset2(value, presets, presetType) : value; 44110 const [parsedQuantity, parsedUnit] = (0, import_components134.__experimentalParseQuantityAndUnitFromRawValue)(resolvedPresetValue); 44111 const computedUnit = parsedUnit || selectedUnit || "px"; 44112 const unitConfig = units2?.find((item) => item.value === computedUnit); 44113 const step = unitConfig?.step ?? customValueSettings[computedUnit]?.steps ?? 0.1; 44114 const max = unitConfig?.max ?? customValueSettings[computedUnit]?.max ?? 10; 44115 const handleCustomValueChange = (newValue) => { 44116 const isNumeric = !isNaN(parseFloat(newValue)); 44117 const newCustomValue = isNumeric ? newValue : void 0; 44118 if (newCustomValue !== void 0) { 44119 onChange(newCustomValue); 44120 } 44121 }; 44122 const handleCustomValueSliderChange = (next) => { 44123 onChange([next, computedUnit].join("")); 44124 }; 44125 const customTooltipContent = (newValue) => value === void 0 ? void 0 : presets[newValue]?.name; 44126 const getNewPresetValue = (next, controlType) => { 44127 const newValue = parseInt(next, 10); 44128 if (controlType === "selectList") { 44129 if (newValue === 0 && presets[0]?.slug === "0") { 44130 return "0"; 44131 } 44132 if (newValue === 0) { 44133 return void 0; 44134 } 44135 } else if (newValue === 0) { 44136 return "0"; 44137 } 44138 return `var:preset|$presetType}|$presets[next]?.slug}`; 44139 }; 44140 return /* @__PURE__ */ (0, import_jsx_runtime281.jsxs)( 44141 import_components134.__experimentalHStack, 44142 { 44143 className: `preset-input-control__wrapper $className}__wrapper`, 44144 children: [ 44145 icon && /* @__PURE__ */ (0, import_jsx_runtime281.jsx)( 44146 import_components134.Icon, 44147 { 44148 className: "preset-input-control__icon", 44149 icon, 44150 size: ICON_SIZE 44151 } 44152 ), 44153 (!hasPresets || showCustomValueControl) && /* @__PURE__ */ (0, import_jsx_runtime281.jsx)( 44154 CustomValueControls, 44155 { 44156 allowNegativeOnDrag, 44157 ariaLabel, 44158 allPlaceholder, 44159 minValue, 44160 parsedQuantity, 44161 computedUnit, 44162 units: units2, 44163 isMixed, 44164 step, 44165 max, 44166 showTooltip, 44167 value, 44168 minimumCustomValue, 44169 onCustomValueChange: handleCustomValueChange, 44170 onCustomValueSliderChange: handleCustomValueSliderChange, 44171 onUnitChange, 44172 onMouseOut, 44173 onMouseOver, 44174 setMinValue 44175 } 44176 ), 44177 hasPresets && showRangeControl && !showCustomValueControl && /* @__PURE__ */ (0, import_jsx_runtime281.jsx)( 44178 import_components134.RangeControl, 44179 { 44180 "aria-valuenow": currentValue, 44181 "aria-valuetext": presets[currentValue]?.name, 44182 className: "preset-input-control__preset-range", 44183 hideLabelFromVision: true, 44184 initialPosition: 0, 44185 label: ariaLabel, 44186 max: presets.length - 1, 44187 marks, 44188 min: 0, 44189 onBlur: onMouseOut, 44190 onChange: (newValue) => onChange(getNewPresetValue(newValue)), 44191 onFocus: onMouseOver, 44192 onMouseDown: (event) => { 44193 const nearStart = event?.nativeEvent?.offsetX < 35; 44194 if (nearStart && value === void 0) { 44195 onChange("0"); 44196 } 44197 }, 44198 onMouseOut, 44199 onMouseOver, 44200 renderTooltipContent: customTooltipContent, 44201 step: 1, 44202 value: currentValue, 44203 withInputField: false, 44204 __next40pxDefaultSize: true 44205 } 44206 ), 44207 hasPresets && !showRangeControl && !showCustomValueControl && /* @__PURE__ */ (0, import_jsx_runtime281.jsx)( 44208 import_components134.CustomSelectControl, 44209 { 44210 className: "preset-input-control__custom-select-control", 44211 hideLabelFromVision: true, 44212 label: ariaLabel, 44213 onBlur: onMouseOut, 44214 onChange: (selection2) => { 44215 if (showCustomValueInSelectList && selection2.selectedItem.key === options.length - 1) { 44216 setShowCustomValueControl(true); 44217 } else { 44218 onChange( 44219 getNewPresetValue( 44220 selection2.selectedItem.key, 44221 "selectList" 44222 ) 44223 ); 44224 } 44225 }, 44226 onFocus: onMouseOver, 44227 onMouseOut, 44228 onMouseOver, 44229 options, 44230 size: "__unstable-large", 44231 value: ( 44232 // passing empty string as a fallback to continue using the 44233 // component in controlled mode 44234 options.find( 44235 (option) => option.key === currentValue 44236 ) || "" 44237 ) 44238 } 44239 ), 44240 hasPresets && !disableCustomValues && /* @__PURE__ */ (0, import_jsx_runtime281.jsx)( 44241 import_components134.Button, 44242 { 44243 className: "preset-input-control__custom-toggle", 44244 icon: settings_default, 44245 iconSize: ICON_SIZE, 44246 isPressed: showCustomValueControl, 44247 label: showCustomValueControl ? (0, import_i18n120.__)("Use preset") : (0, import_i18n120.__)("Set custom value"), 44248 onClick: () => { 44249 setShowCustomValueControl(!showCustomValueControl); 44250 }, 44251 size: "small" 44252 } 44253 ) 44254 ] 44255 } 44256 ); 44257 } 44258 44259 // packages/block-editor/build-module/components/border-radius-control/constants.js 44260 var import_i18n121 = __toESM(require_i18n()); 44261 var RANGE_CONTROL_MAX_SIZE3 = 8; 44262 var EMPTY_ARRAY9 = []; 44263 var CORNERS = { 44264 all: (0, import_i18n121.__)("Border radius"), 44265 topLeft: (0, import_i18n121.__)("Top left"), 44266 topRight: (0, import_i18n121.__)("Top right"), 44267 bottomLeft: (0, import_i18n121.__)("Bottom left"), 44268 bottomRight: (0, import_i18n121.__)("Bottom right") 44269 }; 44270 var ICONS2 = { 44271 all: corner_all_default, 44272 topLeft: corner_top_left_default, 44273 topRight: corner_top_right_default, 44274 bottomLeft: corner_bottom_left_default, 44275 bottomRight: corner_bottom_right_default 44276 }; 44277 var MIN_BORDER_RADIUS_VALUE = 0; 44278 44279 // packages/block-editor/build-module/components/border-radius-control/index.js 44280 var import_jsx_runtime282 = __toESM(require_jsx_runtime()); 44281 function useBorderRadiusSizes(presets) { 44282 const defaultSizes = presets?.default ?? EMPTY_ARRAY9; 44283 const customSizes = presets?.custom ?? EMPTY_ARRAY9; 44284 const themeSizes = presets?.theme ?? EMPTY_ARRAY9; 44285 return (0, import_element148.useMemo)(() => { 44286 const sizes = [ 44287 { name: (0, import_i18n122.__)("None"), slug: "0", size: 0 }, 44288 ...customSizes, 44289 ...themeSizes, 44290 ...defaultSizes 44291 ]; 44292 return sizes.length > RANGE_CONTROL_MAX_SIZE3 ? [ 44293 { 44294 name: (0, import_i18n122.__)("Default"), 44295 slug: "default", 44296 size: void 0 44297 }, 44298 ...sizes 44299 ] : sizes; 44300 }, [customSizes, themeSizes, defaultSizes]); 44301 } 44302 function getCornerValue(values, corner) { 44303 if (corner === "all") { 44304 return getAllValue(values); 44305 } 44306 if (typeof values === "string") { 44307 return values; 44308 } 44309 return values?.[corner]; 44310 } 44311 function getCornerUnit(selectedUnits, corner) { 44312 if (corner === "all") { 44313 return selectedUnits.flat; 44314 } 44315 return selectedUnits[corner]; 44316 } 44317 function createCornerChangeHandler(corner, values, onChange) { 44318 return (newValue) => { 44319 if (corner === "all") { 44320 onChange({ 44321 topLeft: newValue, 44322 topRight: newValue, 44323 bottomLeft: newValue, 44324 bottomRight: newValue 44325 }); 44326 } else { 44327 const currentValues = typeof values !== "string" ? values || {} : { 44328 topLeft: values, 44329 topRight: values, 44330 bottomLeft: values, 44331 bottomRight: values 44332 }; 44333 onChange({ 44334 ...currentValues, 44335 [corner]: newValue 44336 }); 44337 } 44338 }; 44339 } 44340 function createCornerUnitChangeHandler(corner, selectedUnits, setSelectedUnits) { 44341 return (newUnit) => { 44342 const newUnits = { ...selectedUnits }; 44343 if (corner === "all") { 44344 newUnits.flat = newUnit; 44345 newUnits.topLeft = newUnit; 44346 newUnits.topRight = newUnit; 44347 newUnits.bottomLeft = newUnit; 44348 newUnits.bottomRight = newUnit; 44349 } else { 44350 newUnits[corner] = newUnit; 44351 } 44352 setSelectedUnits(newUnits); 44353 }; 44354 } 44355 function BorderRadiusControl({ onChange, values, presets }) { 44356 const [isLinked, setIsLinked] = (0, import_element148.useState)( 44357 !hasDefinedValues(values) || !hasMixedValues(values) 44358 ); 44359 const options = useBorderRadiusSizes(presets); 44360 const [selectedUnits, setSelectedUnits] = (0, import_element148.useState)({ 44361 flat: typeof values === "string" ? (0, import_components135.__experimentalParseQuantityAndUnitFromRawValue)(values)[1] : void 0, 44362 topLeft: (0, import_components135.__experimentalParseQuantityAndUnitFromRawValue)(values?.topLeft)[1], 44363 topRight: (0, import_components135.__experimentalParseQuantityAndUnitFromRawValue)(values?.topRight)[1], 44364 bottomLeft: (0, import_components135.__experimentalParseQuantityAndUnitFromRawValue)(values?.bottomLeft)[1], 44365 bottomRight: (0, import_components135.__experimentalParseQuantityAndUnitFromRawValue)( 44366 values?.bottomRight 44367 )[1] 44368 }); 44369 const [availableUnits] = useSettings("spacing.units"); 44370 const units2 = (0, import_components135.__experimentalUseCustomUnits)({ 44371 availableUnits: availableUnits || ["px", "em", "rem"] 44372 }); 44373 const toggleLinked = () => setIsLinked(!isLinked); 44374 return /* @__PURE__ */ (0, import_jsx_runtime282.jsxs)("fieldset", { className: "components-border-radius-control", children: [ 44375 /* @__PURE__ */ (0, import_jsx_runtime282.jsxs)(import_components135.__experimentalHStack, { className: "components-border-radius-control__header", children: [ 44376 /* @__PURE__ */ (0, import_jsx_runtime282.jsx)(import_components135.BaseControl.VisualLabel, { as: "legend", children: (0, import_i18n122.__)("Radius") }), 44377 /* @__PURE__ */ (0, import_jsx_runtime282.jsx)(LinkedButton, { onClick: toggleLinked, isLinked }) 44378 ] }), 44379 isLinked ? /* @__PURE__ */ (0, import_jsx_runtime282.jsx)( 44380 PresetInputControl, 44381 { 44382 ariaLabel: CORNERS.all, 44383 className: "components-border-radius-control", 44384 icon: ICONS2.all, 44385 minimumCustomValue: MIN_BORDER_RADIUS_VALUE, 44386 onChange: createCornerChangeHandler( 44387 "all", 44388 values, 44389 onChange 44390 ), 44391 onUnitChange: createCornerUnitChangeHandler( 44392 "all", 44393 selectedUnits, 44394 setSelectedUnits 44395 ), 44396 presets: options, 44397 presetType: "border-radius", 44398 selectedUnit: getCornerUnit(selectedUnits, "all"), 44399 showTooltip: true, 44400 units: units2, 44401 value: getCornerValue(values, "all") 44402 } 44403 ) : /* @__PURE__ */ (0, import_jsx_runtime282.jsx)(import_components135.__experimentalVStack, { children: [ 44404 "topLeft", 44405 "topRight", 44406 "bottomLeft", 44407 "bottomRight" 44408 ].map((corner) => /* @__PURE__ */ (0, import_jsx_runtime282.jsx)( 44409 PresetInputControl, 44410 { 44411 ariaLabel: CORNERS[corner], 44412 className: "components-border-radius-control", 44413 icon: ICONS2[corner], 44414 minimumCustomValue: MIN_BORDER_RADIUS_VALUE, 44415 onChange: createCornerChangeHandler( 44416 corner, 44417 values, 44418 onChange 44419 ), 44420 onUnitChange: createCornerUnitChangeHandler( 44421 corner, 44422 selectedUnits, 44423 setSelectedUnits 44424 ), 44425 presets: options, 44426 presetType: "border-radius", 44427 selectedUnit: getCornerUnit( 44428 selectedUnits, 44429 corner 44430 ), 44431 showTooltip: true, 44432 units: units2, 44433 value: getCornerValue(values, corner) 44434 }, 44435 corner 44436 )) }) 44437 ] }); 44438 } 44439 44440 // packages/block-editor/build-module/components/color-palette/index.js 44441 var import_components136 = __toESM(require_components()); 44442 44443 // packages/block-editor/build-module/components/color-palette/with-color-context.js 44444 var import_compose76 = __toESM(require_compose()); 44445 var import_jsx_runtime283 = __toESM(require_jsx_runtime()); 44446 var with_color_context_default = (0, import_compose76.createHigherOrderComponent)((WrappedComponent) => { 44447 return (props) => { 44448 const [ 44449 defaultColors, 44450 themeColors, 44451 customColors, 44452 enableCustomColors, 44453 enableDefaultColors 44454 ] = useSettings( 44455 "color.palette.default", 44456 "color.palette.theme", 44457 "color.palette.custom", 44458 "color.custom", 44459 "color.defaultPalette" 44460 ); 44461 const _colors = enableDefaultColors ? [ 44462 ...themeColors || [], 44463 ...defaultColors || [], 44464 ...customColors || [] 44465 ] : [...themeColors || [], ...customColors || []]; 44466 const { colors: colors2 = _colors, disableCustomColors = !enableCustomColors } = props; 44467 const hasColorsToChoose = colors2 && colors2.length > 0 || !disableCustomColors; 44468 return /* @__PURE__ */ (0, import_jsx_runtime283.jsx)( 44469 WrappedComponent, 44470 { 44471 ...{ 44472 ...props, 44473 colors: colors2, 44474 disableCustomColors, 44475 hasColorsToChoose 44476 } 44477 } 44478 ); 44479 }; 44480 }, "withColorContext"); 44481 44482 // packages/block-editor/build-module/components/color-palette/index.js 44483 var color_palette_default = with_color_context_default(import_components136.ColorPalette); 44484 44485 // packages/block-editor/build-module/components/colors-gradients/control.js 44486 var import_i18n123 = __toESM(require_i18n()); 44487 var import_components137 = __toESM(require_components()); 44488 var import_jsx_runtime284 = __toESM(require_jsx_runtime()); 44489 var { Tabs: Tabs3 } = unlock(import_components137.privateApis); 44490 var colorsAndGradientKeys = [ 44491 "colors", 44492 "disableCustomColors", 44493 "gradients", 44494 "disableCustomGradients" 44495 ]; 44496 var TAB_IDS = { color: "color", gradient: "gradient" }; 44497 function ColorGradientControlInner({ 44498 colors: colors2, 44499 gradients, 44500 disableCustomColors, 44501 disableCustomGradients, 44502 __experimentalIsRenderedInSidebar, 44503 className, 44504 label, 44505 onColorChange, 44506 onGradientChange, 44507 colorValue, 44508 gradientValue, 44509 clearable, 44510 showTitle = true, 44511 enableAlpha, 44512 headingLevel 44513 }) { 44514 const canChooseAColor = onColorChange && (colors2 && colors2.length > 0 || !disableCustomColors); 44515 const canChooseAGradient = onGradientChange && (gradients && gradients.length > 0 || !disableCustomGradients); 44516 if (!canChooseAColor && !canChooseAGradient) { 44517 return null; 44518 } 44519 const tabPanels = { 44520 [TAB_IDS.color]: /* @__PURE__ */ (0, import_jsx_runtime284.jsx)( 44521 import_components137.ColorPalette, 44522 { 44523 value: colorValue, 44524 onChange: canChooseAGradient ? (newColor) => { 44525 onColorChange(newColor); 44526 onGradientChange(); 44527 } : onColorChange, 44528 ...{ colors: colors2, disableCustomColors }, 44529 __experimentalIsRenderedInSidebar, 44530 clearable, 44531 enableAlpha, 44532 headingLevel 44533 } 44534 ), 44535 [TAB_IDS.gradient]: /* @__PURE__ */ (0, import_jsx_runtime284.jsx)( 44536 import_components137.GradientPicker, 44537 { 44538 value: gradientValue, 44539 onChange: canChooseAColor ? (newGradient) => { 44540 onGradientChange(newGradient); 44541 onColorChange(); 44542 } : onGradientChange, 44543 ...{ gradients, disableCustomGradients }, 44544 __experimentalIsRenderedInSidebar, 44545 clearable, 44546 headingLevel 44547 } 44548 ) 44549 }; 44550 const renderPanelType = (type) => /* @__PURE__ */ (0, import_jsx_runtime284.jsx)("div", { className: "block-editor-color-gradient-control__panel", children: tabPanels[type] }); 44551 return /* @__PURE__ */ (0, import_jsx_runtime284.jsx)( 44552 import_components137.BaseControl, 44553 { 44554 className: clsx_default( 44555 "block-editor-color-gradient-control", 44556 className 44557 ), 44558 children: /* @__PURE__ */ (0, import_jsx_runtime284.jsx)("fieldset", { className: "block-editor-color-gradient-control__fieldset", children: /* @__PURE__ */ (0, import_jsx_runtime284.jsxs)(import_components137.__experimentalVStack, { spacing: 1, children: [ 44559 showTitle && /* @__PURE__ */ (0, import_jsx_runtime284.jsx)("legend", { children: /* @__PURE__ */ (0, import_jsx_runtime284.jsx)("div", { className: "block-editor-color-gradient-control__color-indicator", children: /* @__PURE__ */ (0, import_jsx_runtime284.jsx)(import_components137.BaseControl.VisualLabel, { children: label }) }) }), 44560 canChooseAColor && canChooseAGradient && /* @__PURE__ */ (0, import_jsx_runtime284.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime284.jsxs)( 44561 Tabs3, 44562 { 44563 defaultTabId: gradientValue ? TAB_IDS.gradient : !!canChooseAColor && TAB_IDS.color, 44564 children: [ 44565 /* @__PURE__ */ (0, import_jsx_runtime284.jsxs)(Tabs3.TabList, { children: [ 44566 /* @__PURE__ */ (0, import_jsx_runtime284.jsx)(Tabs3.Tab, { tabId: TAB_IDS.color, children: (0, import_i18n123.__)("Color") }), 44567 /* @__PURE__ */ (0, import_jsx_runtime284.jsx)(Tabs3.Tab, { tabId: TAB_IDS.gradient, children: (0, import_i18n123.__)("Gradient") }) 44568 ] }), 44569 /* @__PURE__ */ (0, import_jsx_runtime284.jsx)( 44570 Tabs3.TabPanel, 44571 { 44572 tabId: TAB_IDS.color, 44573 className: "block-editor-color-gradient-control__panel", 44574 focusable: false, 44575 children: tabPanels.color 44576 } 44577 ), 44578 /* @__PURE__ */ (0, import_jsx_runtime284.jsx)( 44579 Tabs3.TabPanel, 44580 { 44581 tabId: TAB_IDS.gradient, 44582 className: "block-editor-color-gradient-control__panel", 44583 focusable: false, 44584 children: tabPanels.gradient 44585 } 44586 ) 44587 ] 44588 } 44589 ) }), 44590 !canChooseAGradient && renderPanelType(TAB_IDS.color), 44591 !canChooseAColor && renderPanelType(TAB_IDS.gradient) 44592 ] }) }) 44593 } 44594 ); 44595 } 44596 function ColorGradientControlSelect(props) { 44597 const [colors2, gradients, customColors, customGradients] = useSettings( 44598 "color.palette", 44599 "color.gradients", 44600 "color.custom", 44601 "color.customGradient" 44602 ); 44603 return /* @__PURE__ */ (0, import_jsx_runtime284.jsx)( 44604 ColorGradientControlInner, 44605 { 44606 colors: colors2, 44607 gradients, 44608 disableCustomColors: !customColors, 44609 disableCustomGradients: !customGradients, 44610 ...props 44611 } 44612 ); 44613 } 44614 function ColorGradientControl(props) { 44615 if (colorsAndGradientKeys.every((key) => props.hasOwnProperty(key))) { 44616 return /* @__PURE__ */ (0, import_jsx_runtime284.jsx)(ColorGradientControlInner, { ...props }); 44617 } 44618 return /* @__PURE__ */ (0, import_jsx_runtime284.jsx)(ColorGradientControlSelect, { ...props }); 44619 } 44620 var control_default = ColorGradientControl; 44621 44622 // packages/block-editor/build-module/components/color-palette/control.js 44623 var import_jsx_runtime285 = __toESM(require_jsx_runtime()); 44624 function ColorPaletteControl({ 44625 onChange, 44626 value, 44627 ...otherProps 44628 }) { 44629 return /* @__PURE__ */ (0, import_jsx_runtime285.jsx)( 44630 control_default, 44631 { 44632 ...otherProps, 44633 onColorChange: onChange, 44634 colorValue: value, 44635 gradients: [], 44636 disableCustomGradients: true 44637 } 44638 ); 44639 } 44640 44641 // packages/block-editor/build-module/components/contrast-checker/index.js 44642 var import_i18n124 = __toESM(require_i18n()); 44643 var import_components138 = __toESM(require_components()); 44644 var import_a11y17 = __toESM(require_a11y()); 44645 var import_jsx_runtime286 = __toESM(require_jsx_runtime()); 44646 k([names_default, a11y_default]); 44647 function ContrastChecker({ 44648 backgroundColor, 44649 fallbackBackgroundColor, 44650 fallbackTextColor, 44651 fallbackLinkColor, 44652 fontSize, 44653 // Font size value in pixels. 44654 isLargeText, 44655 textColor, 44656 linkColor, 44657 enableAlphaChecker = false 44658 }) { 44659 const currentBackgroundColor = backgroundColor || fallbackBackgroundColor; 44660 if (!currentBackgroundColor) { 44661 return null; 44662 } 44663 const currentTextColor = textColor || fallbackTextColor; 44664 const currentLinkColor = linkColor || fallbackLinkColor; 44665 if (!currentTextColor && !currentLinkColor) { 44666 return null; 44667 } 44668 const textColors = [ 44669 { 44670 color: currentTextColor, 44671 description: (0, import_i18n124.__)("text color") 44672 }, 44673 { 44674 color: currentLinkColor, 44675 description: (0, import_i18n124.__)("link color") 44676 } 44677 ]; 44678 const colordBackgroundColor = w(currentBackgroundColor); 44679 const backgroundColorHasTransparency = colordBackgroundColor.alpha() < 1; 44680 const backgroundColorBrightness = colordBackgroundColor.brightness(); 44681 const isReadableOptions = { 44682 level: "AA", 44683 size: isLargeText || isLargeText !== false && fontSize >= 24 ? "large" : "small" 44684 }; 44685 let message2 = ""; 44686 let speakMessage = ""; 44687 for (const item of textColors) { 44688 if (!item.color) { 44689 continue; 44690 } 44691 const colordTextColor = w(item.color); 44692 const isColordTextReadable = colordTextColor.isReadable( 44693 colordBackgroundColor, 44694 isReadableOptions 44695 ); 44696 const textHasTransparency = colordTextColor.alpha() < 1; 44697 if (!isColordTextReadable) { 44698 if (backgroundColorHasTransparency || textHasTransparency) { 44699 continue; 44700 } 44701 message2 = backgroundColorBrightness < colordTextColor.brightness() ? (0, import_i18n124.sprintf)( 44702 // translators: %s is a type of text color, e.g., "text color" or "link color". 44703 (0, import_i18n124.__)( 44704 "This color combination may be hard for people to read. Try using a darker background color and/or a brighter %s." 44705 ), 44706 item.description 44707 ) : (0, import_i18n124.sprintf)( 44708 // translators: %s is a type of text color, e.g., "text color" or "link color". 44709 (0, import_i18n124.__)( 44710 "This color combination may be hard for people to read. Try using a brighter background color and/or a darker %s." 44711 ), 44712 item.description 44713 ); 44714 speakMessage = (0, import_i18n124.__)( 44715 "This color combination may be hard for people to read." 44716 ); 44717 break; 44718 } 44719 if (textHasTransparency && enableAlphaChecker) { 44720 message2 = (0, import_i18n124.__)("Transparent text may be hard for people to read."); 44721 speakMessage = (0, import_i18n124.__)( 44722 "Transparent text may be hard for people to read." 44723 ); 44724 } 44725 } 44726 if (!message2) { 44727 return null; 44728 } 44729 (0, import_a11y17.speak)(speakMessage); 44730 return /* @__PURE__ */ (0, import_jsx_runtime286.jsx)("div", { className: "block-editor-contrast-checker", children: /* @__PURE__ */ (0, import_jsx_runtime286.jsx)( 44731 import_components138.Notice, 44732 { 44733 spokenMessage: null, 44734 status: "warning", 44735 isDismissible: false, 44736 children: message2 44737 } 44738 ) }); 44739 } 44740 var contrast_checker_default = ContrastChecker; 44741 44742 // packages/block-editor/build-module/components/date-format-picker/index.js 44743 var import_i18n125 = __toESM(require_i18n()); 44744 var import_date = __toESM(require_date()); 44745 var import_element149 = __toESM(require_element()); 44746 var import_components139 = __toESM(require_components()); 44747 var import_jsx_runtime287 = __toESM(require_jsx_runtime()); 44748 var exampleDate = /* @__PURE__ */ new Date(); 44749 exampleDate.setDate(20); 44750 exampleDate.setMonth(exampleDate.getMonth() - 3); 44751 if (exampleDate.getMonth() === 4) { 44752 exampleDate.setMonth(3); 44753 } 44754 function DateFormatPicker({ 44755 format: format6, 44756 defaultFormat, 44757 onChange 44758 }) { 44759 return /* @__PURE__ */ (0, import_jsx_runtime287.jsxs)( 44760 import_components139.__experimentalVStack, 44761 { 44762 as: "fieldset", 44763 spacing: 4, 44764 className: "block-editor-date-format-picker", 44765 children: [ 44766 /* @__PURE__ */ (0, import_jsx_runtime287.jsx)(import_components139.VisuallyHidden, { as: "legend", children: (0, import_i18n125.__)("Date format") }), 44767 /* @__PURE__ */ (0, import_jsx_runtime287.jsx)( 44768 import_components139.ToggleControl, 44769 { 44770 label: (0, import_i18n125.__)("Default format"), 44771 help: `${(0, import_i18n125.__)("Example:")} ${(0, import_date.dateI18n)( 44772 defaultFormat, 44773 exampleDate 44774 )}`, 44775 checked: !format6, 44776 onChange: (checked) => onChange(checked ? null : defaultFormat) 44777 } 44778 ), 44779 format6 && /* @__PURE__ */ (0, import_jsx_runtime287.jsx)(NonDefaultControls, { format: format6, onChange }) 44780 ] 44781 } 44782 ); 44783 } 44784 function NonDefaultControls({ format: format6, onChange }) { 44785 const suggestedFormats = [ 44786 .../* @__PURE__ */ new Set([ 44787 /* translators: See https://www.php.net/manual/datetime.format.php */ 44788 "Y-m-d", 44789 /* translators: See https://www.php.net/manual/datetime.format.php */ 44790 (0, import_i18n125._x)("n/j/Y", "short date format"), 44791 /* translators: See https://www.php.net/manual/datetime.format.php */ 44792 (0, import_i18n125._x)("n/j/Y g:i A", "short date format with time"), 44793 /* translators: See https://www.php.net/manual/datetime.format.php */ 44794 (0, import_i18n125._x)("M j, Y", "medium date format"), 44795 /* translators: See https://www.php.net/manual/datetime.format.php */ 44796 (0, import_i18n125._x)("M j, Y g:i A", "medium date format with time"), 44797 /* translators: See https://www.php.net/manual/datetime.format.php */ 44798 (0, import_i18n125._x)("F j, Y", "long date format"), 44799 /* translators: See https://www.php.net/manual/datetime.format.php */ 44800 (0, import_i18n125._x)("M j", "short date format without the year") 44801 ]) 44802 ]; 44803 const suggestedOptions = [ 44804 ...suggestedFormats.map((suggestedFormat, index) => ({ 44805 key: `suggested-$index}`, 44806 name: (0, import_date.dateI18n)(suggestedFormat, exampleDate), 44807 format: suggestedFormat 44808 })), 44809 { 44810 key: "human-diff", 44811 name: (0, import_date.humanTimeDiff)(exampleDate), 44812 format: "human-diff" 44813 } 44814 ]; 44815 const customOption = { 44816 key: "custom", 44817 name: (0, import_i18n125.__)("Custom"), 44818 className: "block-editor-date-format-picker__custom-format-select-control__custom-option", 44819 hint: (0, import_i18n125.__)("Enter your own date format") 44820 }; 44821 const [isCustom, setIsCustom] = (0, import_element149.useState)( 44822 () => !!format6 && !suggestedOptions.some((option) => option.format === format6) 44823 ); 44824 return /* @__PURE__ */ (0, import_jsx_runtime287.jsxs)(import_components139.__experimentalVStack, { children: [ 44825 /* @__PURE__ */ (0, import_jsx_runtime287.jsx)( 44826 import_components139.CustomSelectControl, 44827 { 44828 __next40pxDefaultSize: true, 44829 label: (0, import_i18n125.__)("Choose a format"), 44830 options: [...suggestedOptions, customOption], 44831 value: isCustom ? customOption : suggestedOptions.find( 44832 (option) => option.format === format6 44833 ) ?? customOption, 44834 onChange: ({ selectedItem }) => { 44835 if (selectedItem === customOption) { 44836 setIsCustom(true); 44837 } else { 44838 setIsCustom(false); 44839 onChange(selectedItem.format); 44840 } 44841 } 44842 } 44843 ), 44844 isCustom && /* @__PURE__ */ (0, import_jsx_runtime287.jsx)( 44845 import_components139.TextControl, 44846 { 44847 __next40pxDefaultSize: true, 44848 label: (0, import_i18n125.__)("Custom format"), 44849 hideLabelFromVision: true, 44850 help: (0, import_element149.createInterpolateElement)( 44851 (0, import_i18n125.__)( 44852 "Enter a date or time <Link>format string</Link>." 44853 ), 44854 { 44855 Link: /* @__PURE__ */ (0, import_jsx_runtime287.jsx)( 44856 import_components139.ExternalLink, 44857 { 44858 href: (0, import_i18n125.__)( 44859 "https://wordpress.org/documentation/article/customize-date-and-time-format/" 44860 ) 44861 } 44862 ) 44863 } 44864 ), 44865 value: format6, 44866 onChange: (value) => onChange(value) 44867 } 44868 ) 44869 ] }); 44870 } 44871 44872 // packages/block-editor/build-module/components/duotone-control/index.js 44873 var import_components140 = __toESM(require_components()); 44874 var import_i18n126 = __toESM(require_i18n()); 44875 var import_keycodes15 = __toESM(require_keycodes()); 44876 var import_compose77 = __toESM(require_compose()); 44877 var import_jsx_runtime288 = __toESM(require_jsx_runtime()); 44878 function DuotoneControl({ 44879 id: idProp, 44880 colorPalette, 44881 duotonePalette, 44882 disableCustomColors, 44883 disableCustomDuotone, 44884 value, 44885 onChange 44886 }) { 44887 let toolbarIcon; 44888 if (value === "unset") { 44889 toolbarIcon = /* @__PURE__ */ (0, import_jsx_runtime288.jsx)(import_components140.ColorIndicator, { className: "block-editor-duotone-control__unset-indicator" }); 44890 } else if (value) { 44891 toolbarIcon = /* @__PURE__ */ (0, import_jsx_runtime288.jsx)(import_components140.DuotoneSwatch, { values: value }); 44892 } else { 44893 toolbarIcon = /* @__PURE__ */ (0, import_jsx_runtime288.jsx)(icon_default, { icon: filter_default }); 44894 } 44895 const actionLabel = (0, import_i18n126.__)("Apply duotone filter"); 44896 const id = (0, import_compose77.useInstanceId)(DuotoneControl, "duotone-control", idProp); 44897 const descriptionId = `$id}__description`; 44898 return /* @__PURE__ */ (0, import_jsx_runtime288.jsx)( 44899 import_components140.Dropdown, 44900 { 44901 popoverProps: { 44902 className: "block-editor-duotone-control__popover", 44903 headerTitle: (0, import_i18n126.__)("Duotone") 44904 }, 44905 renderToggle: ({ isOpen, onToggle }) => { 44906 const openOnArrowDown = (event) => { 44907 if (!isOpen && event.keyCode === import_keycodes15.DOWN) { 44908 event.preventDefault(); 44909 onToggle(); 44910 } 44911 }; 44912 return /* @__PURE__ */ (0, import_jsx_runtime288.jsx)( 44913 import_components140.ToolbarButton, 44914 { 44915 showTooltip: true, 44916 onClick: onToggle, 44917 "aria-haspopup": "true", 44918 "aria-expanded": isOpen, 44919 onKeyDown: openOnArrowDown, 44920 label: actionLabel, 44921 icon: toolbarIcon 44922 } 44923 ); 44924 }, 44925 renderContent: () => /* @__PURE__ */ (0, import_jsx_runtime288.jsxs)(import_components140.MenuGroup, { label: (0, import_i18n126.__)("Duotone"), children: [ 44926 /* @__PURE__ */ (0, import_jsx_runtime288.jsx)("p", { children: (0, import_i18n126.__)( 44927 "Create a two-tone color effect without losing your original image." 44928 ) }), 44929 /* @__PURE__ */ (0, import_jsx_runtime288.jsx)( 44930 import_components140.DuotonePicker, 44931 { 44932 "aria-label": actionLabel, 44933 "aria-describedby": descriptionId, 44934 colorPalette, 44935 duotonePalette, 44936 disableCustomColors, 44937 disableCustomDuotone, 44938 value, 44939 onChange 44940 } 44941 ) 44942 ] }) 44943 } 44944 ); 44945 } 44946 var duotone_control_default = DuotoneControl; 44947 44948 // packages/block-editor/build-module/components/font-appearance-control/index.js 44949 var import_components141 = __toESM(require_components()); 44950 var import_deprecated16 = __toESM(require_deprecated()); 44951 var import_element150 = __toESM(require_element()); 44952 var import_i18n130 = __toESM(require_i18n()); 44953 44954 // packages/block-editor/build-module/utils/get-font-styles-and-weights.js 44955 var import_i18n129 = __toESM(require_i18n()); 44956 44957 // packages/block-editor/build-module/utils/format-font-style.js 44958 var import_i18n127 = __toESM(require_i18n()); 44959 function formatFontStyle(fontStyle) { 44960 if (!fontStyle) { 44961 return {}; 44962 } 44963 if (typeof fontStyle === "object") { 44964 return fontStyle; 44965 } 44966 let name; 44967 switch (fontStyle) { 44968 case "normal": 44969 name = (0, import_i18n127._x)("Regular", "font style"); 44970 break; 44971 case "italic": 44972 name = (0, import_i18n127._x)("Italic", "font style"); 44973 break; 44974 case "oblique": 44975 name = (0, import_i18n127._x)("Oblique", "font style"); 44976 break; 44977 default: 44978 name = fontStyle; 44979 break; 44980 } 44981 return { name, value: fontStyle }; 44982 } 44983 44984 // packages/block-editor/build-module/utils/format-font-weight.js 44985 var import_i18n128 = __toESM(require_i18n()); 44986 function formatFontWeight(fontWeight) { 44987 if (!fontWeight) { 44988 return {}; 44989 } 44990 if (typeof fontWeight === "object") { 44991 return fontWeight; 44992 } 44993 let name; 44994 switch (fontWeight) { 44995 case "normal": 44996 case "400": 44997 name = (0, import_i18n128._x)("Regular", "font weight"); 44998 break; 44999 case "bold": 45000 case "700": 45001 name = (0, import_i18n128._x)("Bold", "font weight"); 45002 break; 45003 case "100": 45004 name = (0, import_i18n128._x)("Thin", "font weight"); 45005 break; 45006 case "200": 45007 name = (0, import_i18n128._x)("Extra Light", "font weight"); 45008 break; 45009 case "300": 45010 name = (0, import_i18n128._x)("Light", "font weight"); 45011 break; 45012 case "500": 45013 name = (0, import_i18n128._x)("Medium", "font weight"); 45014 break; 45015 case "600": 45016 name = (0, import_i18n128._x)("Semi Bold", "font weight"); 45017 break; 45018 case "800": 45019 name = (0, import_i18n128._x)("Extra Bold", "font weight"); 45020 break; 45021 case "900": 45022 name = (0, import_i18n128._x)("Black", "font weight"); 45023 break; 45024 case "1000": 45025 name = (0, import_i18n128._x)("Extra Black", "font weight"); 45026 break; 45027 default: 45028 name = fontWeight; 45029 break; 45030 } 45031 return { name, value: fontWeight }; 45032 } 45033 45034 // packages/block-editor/build-module/utils/get-font-styles-and-weights.js 45035 var FONT_STYLES = [ 45036 { 45037 name: (0, import_i18n129._x)("Regular", "font style"), 45038 value: "normal" 45039 }, 45040 { 45041 name: (0, import_i18n129._x)("Italic", "font style"), 45042 value: "italic" 45043 } 45044 ]; 45045 var FONT_WEIGHTS = [ 45046 { 45047 name: (0, import_i18n129._x)("Thin", "font weight"), 45048 value: "100" 45049 }, 45050 { 45051 name: (0, import_i18n129._x)("Extra Light", "font weight"), 45052 value: "200" 45053 }, 45054 { 45055 name: (0, import_i18n129._x)("Light", "font weight"), 45056 value: "300" 45057 }, 45058 { 45059 name: (0, import_i18n129._x)("Regular", "font weight"), 45060 value: "400" 45061 }, 45062 { 45063 name: (0, import_i18n129._x)("Medium", "font weight"), 45064 value: "500" 45065 }, 45066 { 45067 name: (0, import_i18n129._x)("Semi Bold", "font weight"), 45068 value: "600" 45069 }, 45070 { 45071 name: (0, import_i18n129._x)("Bold", "font weight"), 45072 value: "700" 45073 }, 45074 { 45075 name: (0, import_i18n129._x)("Extra Bold", "font weight"), 45076 value: "800" 45077 }, 45078 { 45079 name: (0, import_i18n129._x)("Black", "font weight"), 45080 value: "900" 45081 }, 45082 { 45083 name: (0, import_i18n129._x)("Extra Black", "font weight"), 45084 value: "1000" 45085 } 45086 ]; 45087 function getFontStylesAndWeights(fontFamilyFaces) { 45088 let fontStyles = []; 45089 let fontWeights = []; 45090 const combinedStyleAndWeightOptions = []; 45091 const isSystemFont = !fontFamilyFaces || fontFamilyFaces?.length === 0; 45092 let isVariableFont = false; 45093 fontFamilyFaces?.forEach((face) => { 45094 if ("string" === typeof face.fontWeight && /\s/.test(face.fontWeight.trim())) { 45095 isVariableFont = true; 45096 let [startValue, endValue] = face.fontWeight.split(" "); 45097 startValue = parseInt(startValue.slice(0, 1)); 45098 if (endValue === "1000") { 45099 endValue = 10; 45100 } else { 45101 endValue = parseInt(endValue.slice(0, 1)); 45102 } 45103 for (let i2 = startValue; i2 <= endValue; i2++) { 45104 const fontWeightValue = `$i2.toString()}00`; 45105 if (!fontWeights.some( 45106 (weight) => weight.value === fontWeightValue 45107 )) { 45108 fontWeights.push(formatFontWeight(fontWeightValue)); 45109 } 45110 } 45111 } 45112 const fontWeight = formatFontWeight( 45113 "number" === typeof face.fontWeight ? face.fontWeight.toString() : face.fontWeight 45114 ); 45115 const fontStyle = formatFontStyle(face.fontStyle); 45116 if (fontStyle && Object.keys(fontStyle).length) { 45117 if (!fontStyles.some( 45118 (style) => style.value === fontStyle.value 45119 )) { 45120 fontStyles.push(fontStyle); 45121 } 45122 } 45123 if (fontWeight && Object.keys(fontWeight).length) { 45124 if (!fontWeights.some( 45125 (weight) => weight.value === fontWeight.value 45126 )) { 45127 if (!isVariableFont) { 45128 fontWeights.push(fontWeight); 45129 } 45130 } 45131 } 45132 }); 45133 if (!fontWeights.some((weight) => weight.value >= "600")) { 45134 fontWeights.push({ 45135 name: (0, import_i18n129._x)("Bold", "font weight"), 45136 value: "700" 45137 }); 45138 } 45139 if (!fontStyles.some((style) => style.value === "italic")) { 45140 fontStyles.push({ 45141 name: (0, import_i18n129._x)("Italic", "font style"), 45142 value: "italic" 45143 }); 45144 } 45145 if (isSystemFont) { 45146 fontStyles = FONT_STYLES; 45147 fontWeights = FONT_WEIGHTS; 45148 } 45149 fontStyles = fontStyles.length === 0 ? FONT_STYLES : fontStyles; 45150 fontWeights = fontWeights.length === 0 ? FONT_WEIGHTS : fontWeights; 45151 fontStyles.forEach(({ name: styleName, value: styleValue }) => { 45152 fontWeights.forEach(({ name: weightName, value: weightValue }) => { 45153 const optionName = styleValue === "normal" ? weightName : (0, import_i18n129.sprintf)( 45154 /* translators: 1: Font weight name. 2: Font style name. */ 45155 (0, import_i18n129._x)("%1$s %2$s", "font"), 45156 weightName, 45157 styleName 45158 ); 45159 combinedStyleAndWeightOptions.push({ 45160 key: `$styleValue}-$weightValue}`, 45161 name: optionName, 45162 style: { 45163 fontStyle: styleValue, 45164 fontWeight: weightValue 45165 } 45166 }); 45167 }); 45168 }); 45169 return { 45170 fontStyles, 45171 fontWeights, 45172 combinedStyleAndWeightOptions, 45173 isSystemFont, 45174 isVariableFont 45175 }; 45176 } 45177 45178 // packages/block-editor/build-module/components/font-appearance-control/index.js 45179 var import_jsx_runtime289 = __toESM(require_jsx_runtime()); 45180 var getFontAppearanceLabel = (hasFontStyles, hasFontWeights) => { 45181 if (!hasFontStyles) { 45182 return (0, import_i18n130.__)("Font weight"); 45183 } 45184 if (!hasFontWeights) { 45185 return (0, import_i18n130.__)("Font style"); 45186 } 45187 return (0, import_i18n130.__)("Appearance"); 45188 }; 45189 function FontAppearanceControl(props) { 45190 const { 45191 /** Start opting into the larger default height that will become the default size in a future version. */ 45192 __next40pxDefaultSize = false, 45193 onChange, 45194 hasFontStyles = true, 45195 hasFontWeights = true, 45196 fontFamilyFaces, 45197 value: { fontStyle, fontWeight }, 45198 ...otherProps 45199 } = props; 45200 const hasStylesOrWeights = hasFontStyles || hasFontWeights; 45201 const label = getFontAppearanceLabel(hasFontStyles, hasFontWeights); 45202 const defaultOption = { 45203 key: "default", 45204 name: (0, import_i18n130.__)("Default"), 45205 style: { fontStyle: void 0, fontWeight: void 0 } 45206 }; 45207 const { fontStyles, fontWeights, combinedStyleAndWeightOptions } = getFontStylesAndWeights(fontFamilyFaces); 45208 const combineOptions = () => { 45209 const combinedOptions = [defaultOption]; 45210 if (combinedStyleAndWeightOptions) { 45211 combinedOptions.push(...combinedStyleAndWeightOptions); 45212 } 45213 return combinedOptions; 45214 }; 45215 const styleOptions = () => { 45216 const combinedOptions = [defaultOption]; 45217 fontStyles.forEach(({ name, value }) => { 45218 combinedOptions.push({ 45219 key: value, 45220 name, 45221 style: { fontStyle: value, fontWeight: void 0 } 45222 }); 45223 }); 45224 return combinedOptions; 45225 }; 45226 const weightOptions = () => { 45227 const combinedOptions = [defaultOption]; 45228 fontWeights.forEach(({ name, value }) => { 45229 combinedOptions.push({ 45230 key: value, 45231 name, 45232 style: { fontStyle: void 0, fontWeight: value } 45233 }); 45234 }); 45235 return combinedOptions; 45236 }; 45237 const selectOptions = (0, import_element150.useMemo)(() => { 45238 if (hasFontStyles && hasFontWeights) { 45239 return combineOptions(); 45240 } 45241 return hasFontStyles ? styleOptions() : weightOptions(); 45242 }, [ 45243 props.options, 45244 fontStyles, 45245 fontWeights, 45246 combinedStyleAndWeightOptions 45247 ]); 45248 const currentSelection = selectOptions.find( 45249 (option) => option.style.fontStyle === fontStyle && option.style.fontWeight === fontWeight 45250 ) || selectOptions[0]; 45251 const getDescribedBy = () => { 45252 if (!currentSelection) { 45253 return (0, import_i18n130.__)("No selected font appearance"); 45254 } 45255 if (!hasFontStyles) { 45256 return (0, import_i18n130.sprintf)( 45257 // translators: %s: Currently selected font weight. 45258 (0, import_i18n130.__)("Currently selected font weight: %s"), 45259 currentSelection.name 45260 ); 45261 } 45262 if (!hasFontWeights) { 45263 return (0, import_i18n130.sprintf)( 45264 // translators: %s: Currently selected font style. 45265 (0, import_i18n130.__)("Currently selected font style: %s"), 45266 currentSelection.name 45267 ); 45268 } 45269 return (0, import_i18n130.sprintf)( 45270 // translators: %s: Currently selected font appearance. 45271 (0, import_i18n130.__)("Currently selected font appearance: %s"), 45272 currentSelection.name 45273 ); 45274 }; 45275 if (!__next40pxDefaultSize && (otherProps.size === void 0 || otherProps.size === "default")) { 45276 (0, import_deprecated16.default)( 45277 `36px default size for wp.blockEditor.__experimentalFontAppearanceControl`, 45278 { 45279 since: "6.8", 45280 version: "7.1", 45281 hint: "Set the `__next40pxDefaultSize` prop to true to start opting into the new default size, which will become the default in a future version." 45282 } 45283 ); 45284 } 45285 return hasStylesOrWeights && /* @__PURE__ */ (0, import_jsx_runtime289.jsx)( 45286 import_components141.CustomSelectControl, 45287 { 45288 ...otherProps, 45289 className: "components-font-appearance-control", 45290 __next40pxDefaultSize, 45291 __shouldNotWarnDeprecated36pxSize: true, 45292 label, 45293 describedBy: getDescribedBy(), 45294 options: selectOptions, 45295 value: currentSelection, 45296 onChange: ({ selectedItem }) => onChange(selectedItem.style) 45297 } 45298 ); 45299 } 45300 45301 // packages/block-editor/build-module/components/font-family/index.js 45302 var import_components142 = __toESM(require_components()); 45303 var import_deprecated17 = __toESM(require_deprecated()); 45304 var import_i18n131 = __toESM(require_i18n()); 45305 var import_jsx_runtime290 = __toESM(require_jsx_runtime()); 45306 function FontFamilyControl({ 45307 /** Start opting into the larger default height that will become the default size in a future version. */ 45308 __next40pxDefaultSize = false, 45309 value = "", 45310 onChange, 45311 fontFamilies, 45312 className, 45313 ...props 45314 }) { 45315 const [blockLevelFontFamilies] = useSettings("typography.fontFamilies"); 45316 if (!fontFamilies) { 45317 fontFamilies = blockLevelFontFamilies; 45318 } 45319 if (!fontFamilies || fontFamilies.length === 0) { 45320 return null; 45321 } 45322 const options = [ 45323 { 45324 key: "", 45325 name: (0, import_i18n131.__)("Default") 45326 }, 45327 ...fontFamilies.map(({ fontFamily, name }) => ({ 45328 key: fontFamily, 45329 name: name || fontFamily, 45330 style: { fontFamily } 45331 })) 45332 ]; 45333 if (!__next40pxDefaultSize && (props.size === void 0 || props.size === "default")) { 45334 (0, import_deprecated17.default)( 45335 `36px default size for wp.blockEditor.__experimentalFontFamilyControl`, 45336 { 45337 since: "6.8", 45338 version: "7.1", 45339 hint: "Set the `__next40pxDefaultSize` prop to true to start opting into the new default size, which will become the default in a future version." 45340 } 45341 ); 45342 } 45343 const selectedValue = options.find((option) => option.key === value) ?? ""; 45344 return /* @__PURE__ */ (0, import_jsx_runtime290.jsx)( 45345 import_components142.CustomSelectControl, 45346 { 45347 __next40pxDefaultSize, 45348 __shouldNotWarnDeprecated36pxSize: true, 45349 label: (0, import_i18n131.__)("Font"), 45350 value: selectedValue, 45351 onChange: ({ selectedItem }) => onChange(selectedItem.key), 45352 options, 45353 className: clsx_default("block-editor-font-family-control", className), 45354 ...props 45355 } 45356 ); 45357 } 45358 45359 // packages/block-editor/build-module/components/letter-spacing-control/index.js 45360 var import_components143 = __toESM(require_components()); 45361 var import_deprecated18 = __toESM(require_deprecated()); 45362 var import_i18n132 = __toESM(require_i18n()); 45363 var import_jsx_runtime291 = __toESM(require_jsx_runtime()); 45364 function LetterSpacingControl({ 45365 __next40pxDefaultSize = false, 45366 value, 45367 onChange, 45368 __unstableInputWidth = "60px", 45369 ...otherProps 45370 }) { 45371 const [availableUnits] = useSettings("spacing.units"); 45372 const units2 = (0, import_components143.__experimentalUseCustomUnits)({ 45373 availableUnits: availableUnits || ["px", "em", "rem"], 45374 defaultValues: { px: 2, em: 0.2, rem: 0.2 } 45375 }); 45376 if (!__next40pxDefaultSize && (otherProps.size === void 0 || otherProps.size === "default")) { 45377 (0, import_deprecated18.default)( 45378 `36px default size for wp.blockEditor.__experimentalLetterSpacingControl`, 45379 { 45380 since: "6.8", 45381 version: "7.1", 45382 hint: "Set the `__next40pxDefaultSize` prop to true to start opting into the new default size, which will become the default in a future version." 45383 } 45384 ); 45385 } 45386 return /* @__PURE__ */ (0, import_jsx_runtime291.jsx)( 45387 import_components143.__experimentalUnitControl, 45388 { 45389 __next40pxDefaultSize, 45390 __shouldNotWarnDeprecated36pxSize: true, 45391 ...otherProps, 45392 label: (0, import_i18n132.__)("Letter spacing"), 45393 value, 45394 __unstableInputWidth, 45395 units: units2, 45396 onChange 45397 } 45398 ); 45399 } 45400 45401 // packages/block-editor/build-module/components/text-decoration-control/index.js 45402 var import_i18n133 = __toESM(require_i18n()); 45403 var import_components144 = __toESM(require_components()); 45404 var import_jsx_runtime292 = __toESM(require_jsx_runtime()); 45405 var TEXT_DECORATIONS = [ 45406 { 45407 label: (0, import_i18n133.__)("None"), 45408 value: "none", 45409 icon: reset_default 45410 }, 45411 { 45412 label: (0, import_i18n133.__)("Underline"), 45413 value: "underline", 45414 icon: format_underline_default 45415 }, 45416 { 45417 label: (0, import_i18n133.__)("Strikethrough"), 45418 value: "line-through", 45419 icon: format_strikethrough_default 45420 } 45421 ]; 45422 function TextDecorationControl({ 45423 value, 45424 onChange, 45425 className 45426 }) { 45427 return /* @__PURE__ */ (0, import_jsx_runtime292.jsx)( 45428 import_components144.__experimentalToggleGroupControl, 45429 { 45430 isDeselectable: true, 45431 __next40pxDefaultSize: true, 45432 label: (0, import_i18n133.__)("Decoration"), 45433 className: clsx_default( 45434 "block-editor-text-decoration-control", 45435 className 45436 ), 45437 value, 45438 onChange: (newValue) => { 45439 onChange(newValue === value ? void 0 : newValue); 45440 }, 45441 children: TEXT_DECORATIONS.map((option) => { 45442 return /* @__PURE__ */ (0, import_jsx_runtime292.jsx)( 45443 import_components144.__experimentalToggleGroupControlOptionIcon, 45444 { 45445 value: option.value, 45446 icon: option.icon, 45447 label: option.label 45448 }, 45449 option.value 45450 ); 45451 }) 45452 } 45453 ); 45454 } 45455 45456 // packages/block-editor/build-module/components/text-transform-control/index.js 45457 var import_i18n134 = __toESM(require_i18n()); 45458 var import_components145 = __toESM(require_components()); 45459 var import_jsx_runtime293 = __toESM(require_jsx_runtime()); 45460 var TEXT_TRANSFORMS = [ 45461 { 45462 label: (0, import_i18n134.__)("None"), 45463 value: "none", 45464 icon: reset_default 45465 }, 45466 { 45467 label: (0, import_i18n134.__)("Uppercase"), 45468 value: "uppercase", 45469 icon: format_uppercase_default 45470 }, 45471 { 45472 label: (0, import_i18n134.__)("Lowercase"), 45473 value: "lowercase", 45474 icon: format_lowercase_default 45475 }, 45476 { 45477 label: (0, import_i18n134.__)("Capitalize"), 45478 value: "capitalize", 45479 icon: format_capitalize_default 45480 } 45481 ]; 45482 function TextTransformControl({ className, value, onChange }) { 45483 return /* @__PURE__ */ (0, import_jsx_runtime293.jsx)( 45484 import_components145.__experimentalToggleGroupControl, 45485 { 45486 isDeselectable: true, 45487 __next40pxDefaultSize: true, 45488 label: (0, import_i18n134.__)("Letter case"), 45489 className: clsx_default( 45490 "block-editor-text-transform-control", 45491 className 45492 ), 45493 value, 45494 onChange: (newValue) => { 45495 onChange(newValue === value ? void 0 : newValue); 45496 }, 45497 children: TEXT_TRANSFORMS.map((option) => { 45498 return /* @__PURE__ */ (0, import_jsx_runtime293.jsx)( 45499 import_components145.__experimentalToggleGroupControlOptionIcon, 45500 { 45501 value: option.value, 45502 icon: option.icon, 45503 label: option.label 45504 }, 45505 option.value 45506 ); 45507 }) 45508 } 45509 ); 45510 } 45511 45512 // packages/block-editor/build-module/components/writing-mode-control/index.js 45513 var import_i18n135 = __toESM(require_i18n()); 45514 var import_components146 = __toESM(require_components()); 45515 var import_jsx_runtime294 = __toESM(require_jsx_runtime()); 45516 var WRITING_MODES = [ 45517 { 45518 label: (0, import_i18n135.__)("Horizontal"), 45519 value: "horizontal-tb", 45520 icon: text_horizontal_default 45521 }, 45522 { 45523 label: (0, import_i18n135.__)("Vertical"), 45524 value: (0, import_i18n135.isRTL)() ? "vertical-lr" : "vertical-rl", 45525 icon: text_vertical_default 45526 } 45527 ]; 45528 function WritingModeControl({ className, value, onChange }) { 45529 return /* @__PURE__ */ (0, import_jsx_runtime294.jsx)( 45530 import_components146.__experimentalToggleGroupControl, 45531 { 45532 isDeselectable: true, 45533 __next40pxDefaultSize: true, 45534 label: (0, import_i18n135.__)("Orientation"), 45535 className: clsx_default("block-editor-writing-mode-control", className), 45536 value, 45537 onChange: (newValue) => { 45538 onChange(newValue === value ? void 0 : newValue); 45539 }, 45540 children: WRITING_MODES.map((option) => { 45541 return /* @__PURE__ */ (0, import_jsx_runtime294.jsx)( 45542 import_components146.__experimentalToggleGroupControlOptionIcon, 45543 { 45544 value: option.value, 45545 icon: option.icon, 45546 label: option.label 45547 }, 45548 option.value 45549 ); 45550 }) 45551 } 45552 ); 45553 } 45554 45555 // packages/block-editor/build-module/components/colors-gradients/dropdown.js 45556 var import_components147 = __toESM(require_components()); 45557 var import_element151 = __toESM(require_element()); 45558 var import_i18n136 = __toESM(require_i18n()); 45559 var import_jsx_runtime295 = __toESM(require_jsx_runtime()); 45560 var WithToolsPanelItem = ({ setting, children, panelId, ...props }) => { 45561 const clearValue = () => { 45562 if (setting.colorValue) { 45563 setting.onColorChange(); 45564 } else if (setting.gradientValue) { 45565 setting.onGradientChange(); 45566 } 45567 }; 45568 return /* @__PURE__ */ (0, import_jsx_runtime295.jsx)( 45569 import_components147.__experimentalToolsPanelItem, 45570 { 45571 hasValue: () => { 45572 return !!setting.colorValue || !!setting.gradientValue; 45573 }, 45574 label: setting.label, 45575 onDeselect: clearValue, 45576 isShownByDefault: setting.isShownByDefault !== void 0 ? setting.isShownByDefault : true, 45577 ...props, 45578 className: "block-editor-tools-panel-color-gradient-settings__item", 45579 panelId, 45580 resetAllFilter: setting.resetAllFilter, 45581 children 45582 } 45583 ); 45584 }; 45585 var LabeledColorIndicator = ({ colorValue, label }) => /* @__PURE__ */ (0, import_jsx_runtime295.jsxs)(import_components147.__experimentalHStack, { justify: "flex-start", children: [ 45586 /* @__PURE__ */ (0, import_jsx_runtime295.jsx)( 45587 import_components147.ColorIndicator, 45588 { 45589 className: "block-editor-panel-color-gradient-settings__color-indicator", 45590 colorValue 45591 } 45592 ), 45593 /* @__PURE__ */ (0, import_jsx_runtime295.jsx)( 45594 import_components147.FlexItem, 45595 { 45596 className: "block-editor-panel-color-gradient-settings__color-name", 45597 title: label, 45598 children: label 45599 } 45600 ) 45601 ] }); 45602 var renderToggle = (settings2) => ({ onToggle, isOpen }) => { 45603 const { 45604 clearable, 45605 colorValue, 45606 gradientValue, 45607 onColorChange, 45608 onGradientChange, 45609 label 45610 } = settings2; 45611 const colorButtonRef = (0, import_element151.useRef)(void 0); 45612 const toggleProps = { 45613 onClick: onToggle, 45614 className: clsx_default( 45615 "block-editor-panel-color-gradient-settings__dropdown", 45616 { "is-open": isOpen } 45617 ), 45618 "aria-expanded": isOpen, 45619 ref: colorButtonRef 45620 }; 45621 const clearValue = () => { 45622 if (colorValue) { 45623 onColorChange(); 45624 } else if (gradientValue) { 45625 onGradientChange(); 45626 } 45627 }; 45628 const value = colorValue ?? gradientValue; 45629 return /* @__PURE__ */ (0, import_jsx_runtime295.jsxs)(import_jsx_runtime295.Fragment, { children: [ 45630 /* @__PURE__ */ (0, import_jsx_runtime295.jsx)(import_components147.Button, { __next40pxDefaultSize: true, ...toggleProps, children: /* @__PURE__ */ (0, import_jsx_runtime295.jsx)( 45631 LabeledColorIndicator, 45632 { 45633 colorValue: value, 45634 label 45635 } 45636 ) }), 45637 clearable && value && /* @__PURE__ */ (0, import_jsx_runtime295.jsx)( 45638 import_components147.Button, 45639 { 45640 __next40pxDefaultSize: true, 45641 label: (0, import_i18n136.__)("Reset"), 45642 className: "block-editor-panel-color-gradient-settings__reset", 45643 size: "small", 45644 icon: reset_default, 45645 onClick: () => { 45646 clearValue(); 45647 if (isOpen) { 45648 onToggle(); 45649 } 45650 colorButtonRef.current?.focus(); 45651 } 45652 } 45653 ) 45654 ] }); 45655 }; 45656 function ColorGradientSettingsDropdown({ 45657 colors: colors2, 45658 disableCustomColors, 45659 disableCustomGradients, 45660 enableAlpha, 45661 gradients, 45662 settings: settings2, 45663 __experimentalIsRenderedInSidebar, 45664 ...props 45665 }) { 45666 let popoverProps3; 45667 if (__experimentalIsRenderedInSidebar) { 45668 popoverProps3 = { 45669 placement: "left-start", 45670 offset: 36, 45671 shift: true 45672 }; 45673 } 45674 return /* @__PURE__ */ (0, import_jsx_runtime295.jsx)(import_jsx_runtime295.Fragment, { children: settings2.map((setting, index) => { 45675 const controlProps = { 45676 clearable: false, 45677 colorValue: setting.colorValue, 45678 colors: colors2, 45679 disableCustomColors, 45680 disableCustomGradients, 45681 enableAlpha, 45682 gradientValue: setting.gradientValue, 45683 gradients, 45684 label: setting.label, 45685 onColorChange: setting.onColorChange, 45686 onGradientChange: setting.onGradientChange, 45687 showTitle: false, 45688 __experimentalIsRenderedInSidebar, 45689 ...setting 45690 }; 45691 const toggleSettings = { 45692 clearable: setting.clearable, 45693 label: setting.label, 45694 colorValue: setting.colorValue, 45695 gradientValue: setting.gradientValue, 45696 onColorChange: setting.onColorChange, 45697 onGradientChange: setting.onGradientChange 45698 }; 45699 return setting && // If not in an `ItemGroup` wrap the dropdown in a 45700 // `ToolsPanelItem` 45701 /* @__PURE__ */ (0, import_jsx_runtime295.jsx)( 45702 WithToolsPanelItem, 45703 { 45704 setting, 45705 ...props, 45706 children: /* @__PURE__ */ (0, import_jsx_runtime295.jsx)( 45707 import_components147.Dropdown, 45708 { 45709 popoverProps: popoverProps3, 45710 className: "block-editor-tools-panel-color-gradient-settings__dropdown", 45711 renderToggle: renderToggle(toggleSettings), 45712 renderContent: () => /* @__PURE__ */ (0, import_jsx_runtime295.jsx)(import_components147.__experimentalDropdownContentWrapper, { paddingSize: "none", children: /* @__PURE__ */ (0, import_jsx_runtime295.jsx)("div", { className: "block-editor-panel-color-gradient-settings__dropdown-content", children: /* @__PURE__ */ (0, import_jsx_runtime295.jsx)( 45713 control_default, 45714 { 45715 ...controlProps 45716 } 45717 ) }) }) 45718 } 45719 ) 45720 }, 45721 index 45722 ); 45723 }) }); 45724 } 45725 45726 // packages/block-editor/build-module/components/colors-gradients/panel-color-gradient-settings.js 45727 var import_components148 = __toESM(require_components()); 45728 var import_data139 = __toESM(require_data()); 45729 var import_compose78 = __toESM(require_compose()); 45730 45731 // packages/block-editor/build-module/components/colors-gradients/use-multiple-origin-colors-and-gradients.js 45732 var import_element152 = __toESM(require_element()); 45733 var import_i18n137 = __toESM(require_i18n()); 45734 function useMultipleOriginColorsAndGradients() { 45735 const [ 45736 enableCustomColors, 45737 customColors, 45738 themeColors, 45739 defaultColors, 45740 shouldDisplayDefaultColors, 45741 enableCustomGradients, 45742 customGradients, 45743 themeGradients, 45744 defaultGradients, 45745 shouldDisplayDefaultGradients 45746 ] = useSettings( 45747 "color.custom", 45748 "color.palette.custom", 45749 "color.palette.theme", 45750 "color.palette.default", 45751 "color.defaultPalette", 45752 "color.customGradient", 45753 "color.gradients.custom", 45754 "color.gradients.theme", 45755 "color.gradients.default", 45756 "color.defaultGradients" 45757 ); 45758 const colorGradientSettings = { 45759 disableCustomColors: !enableCustomColors, 45760 disableCustomGradients: !enableCustomGradients 45761 }; 45762 colorGradientSettings.colors = (0, import_element152.useMemo)(() => { 45763 const result = []; 45764 if (themeColors && themeColors.length) { 45765 result.push({ 45766 name: (0, import_i18n137._x)( 45767 "Theme", 45768 "Indicates this palette comes from the theme." 45769 ), 45770 slug: "theme", 45771 colors: themeColors 45772 }); 45773 } 45774 if (shouldDisplayDefaultColors && defaultColors && defaultColors.length) { 45775 result.push({ 45776 name: (0, import_i18n137._x)( 45777 "Default", 45778 "Indicates this palette comes from WordPress." 45779 ), 45780 slug: "default", 45781 colors: defaultColors 45782 }); 45783 } 45784 if (customColors && customColors.length) { 45785 result.push({ 45786 name: (0, import_i18n137._x)( 45787 "Custom", 45788 "Indicates this palette is created by the user." 45789 ), 45790 slug: "custom", 45791 colors: customColors 45792 }); 45793 } 45794 return result; 45795 }, [ 45796 customColors, 45797 themeColors, 45798 defaultColors, 45799 shouldDisplayDefaultColors 45800 ]); 45801 colorGradientSettings.gradients = (0, import_element152.useMemo)(() => { 45802 const result = []; 45803 if (themeGradients && themeGradients.length) { 45804 result.push({ 45805 name: (0, import_i18n137._x)( 45806 "Theme", 45807 "Indicates this palette comes from the theme." 45808 ), 45809 slug: "theme", 45810 gradients: themeGradients 45811 }); 45812 } 45813 if (shouldDisplayDefaultGradients && defaultGradients && defaultGradients.length) { 45814 result.push({ 45815 name: (0, import_i18n137._x)( 45816 "Default", 45817 "Indicates this palette comes from WordPress." 45818 ), 45819 slug: "default", 45820 gradients: defaultGradients 45821 }); 45822 } 45823 if (customGradients && customGradients.length) { 45824 result.push({ 45825 name: (0, import_i18n137._x)( 45826 "Custom", 45827 "Indicates this palette is created by the user." 45828 ), 45829 slug: "custom", 45830 gradients: customGradients 45831 }); 45832 } 45833 return result; 45834 }, [ 45835 customGradients, 45836 themeGradients, 45837 defaultGradients, 45838 shouldDisplayDefaultGradients 45839 ]); 45840 colorGradientSettings.hasColorsOrGradients = !!colorGradientSettings.colors.length || !!colorGradientSettings.gradients.length; 45841 return colorGradientSettings; 45842 } 45843 45844 // packages/block-editor/build-module/components/colors-gradients/panel-color-gradient-settings.js 45845 var import_jsx_runtime296 = __toESM(require_jsx_runtime()); 45846 var colorsAndGradientKeys2 = [ 45847 "colors", 45848 "disableCustomColors", 45849 "gradients", 45850 "disableCustomGradients" 45851 ]; 45852 var PanelColorGradientSettingsInner = ({ 45853 className, 45854 colors: colors2, 45855 gradients, 45856 disableCustomColors, 45857 disableCustomGradients, 45858 children, 45859 settings: settings2, 45860 title, 45861 showTitle = true, 45862 __experimentalIsRenderedInSidebar, 45863 enableAlpha 45864 }) => { 45865 const panelId = (0, import_compose78.useInstanceId)(PanelColorGradientSettingsInner); 45866 const { batch } = (0, import_data139.useRegistry)(); 45867 if ((!colors2 || colors2.length === 0) && (!gradients || gradients.length === 0) && disableCustomColors && disableCustomGradients && settings2?.every( 45868 (setting) => (!setting.colors || setting.colors.length === 0) && (!setting.gradients || setting.gradients.length === 0) && (setting.disableCustomColors === void 0 || setting.disableCustomColors) && (setting.disableCustomGradients === void 0 || setting.disableCustomGradients) 45869 )) { 45870 return null; 45871 } 45872 return /* @__PURE__ */ (0, import_jsx_runtime296.jsxs)( 45873 import_components148.__experimentalToolsPanel, 45874 { 45875 className: clsx_default( 45876 "block-editor-panel-color-gradient-settings", 45877 className 45878 ), 45879 label: showTitle ? title : void 0, 45880 resetAll: () => { 45881 batch(() => { 45882 settings2.forEach( 45883 ({ 45884 colorValue, 45885 gradientValue, 45886 onColorChange, 45887 onGradientChange 45888 }) => { 45889 if (colorValue) { 45890 onColorChange(); 45891 } else if (gradientValue) { 45892 onGradientChange(); 45893 } 45894 } 45895 ); 45896 }); 45897 }, 45898 panelId, 45899 __experimentalFirstVisibleItemClass: "first", 45900 __experimentalLastVisibleItemClass: "last", 45901 children: [ 45902 /* @__PURE__ */ (0, import_jsx_runtime296.jsx)( 45903 ColorGradientSettingsDropdown, 45904 { 45905 settings: settings2, 45906 panelId, 45907 ...{ 45908 colors: colors2, 45909 gradients, 45910 disableCustomColors, 45911 disableCustomGradients, 45912 __experimentalIsRenderedInSidebar, 45913 enableAlpha 45914 } 45915 } 45916 ), 45917 !!children && /* @__PURE__ */ (0, import_jsx_runtime296.jsxs)(import_jsx_runtime296.Fragment, { children: [ 45918 /* @__PURE__ */ (0, import_jsx_runtime296.jsx)(import_components148.__experimentalSpacer, { marginY: 4 }), 45919 " ", 45920 children 45921 ] }) 45922 ] 45923 } 45924 ); 45925 }; 45926 var PanelColorGradientSettingsSelect = (props) => { 45927 const colorGradientSettings = useMultipleOriginColorsAndGradients(); 45928 return /* @__PURE__ */ (0, import_jsx_runtime296.jsx)( 45929 PanelColorGradientSettingsInner, 45930 { 45931 ...{ ...colorGradientSettings, ...props } 45932 } 45933 ); 45934 }; 45935 var PanelColorGradientSettings = (props) => { 45936 if (colorsAndGradientKeys2.every((key) => props.hasOwnProperty(key))) { 45937 return /* @__PURE__ */ (0, import_jsx_runtime296.jsx)(PanelColorGradientSettingsInner, { ...props }); 45938 } 45939 return /* @__PURE__ */ (0, import_jsx_runtime296.jsx)(PanelColorGradientSettingsSelect, { ...props }); 45940 }; 45941 var panel_color_gradient_settings_default = PanelColorGradientSettings; 45942 45943 // packages/block-editor/build-module/components/dimension-control/index.js 45944 var import_element153 = __toESM(require_element()); 45945 var import_components149 = __toESM(require_components()); 45946 var import_i18n138 = __toESM(require_i18n()); 45947 var import_jsx_runtime297 = __toESM(require_jsx_runtime()); 45948 var EMPTY_ARRAY10 = []; 45949 var DIMENSION_CUSTOM_VALUE_SETTINGS = { 45950 ...CUSTOM_VALUE_SETTINGS, 45951 px: { max: 1e3, steps: 1 }, 45952 em: { max: 50, steps: 0.1 }, 45953 rem: { max: 50, steps: 0.1 } 45954 }; 45955 function useDimensionSizes(presets) { 45956 const defaultSizes = presets?.default ?? EMPTY_ARRAY10; 45957 const customSizes = presets?.custom ?? EMPTY_ARRAY10; 45958 const themeSizes = presets?.theme ?? EMPTY_ARRAY10; 45959 return (0, import_element153.useMemo)(() => { 45960 const sizes = [ 45961 { name: (0, import_i18n138.__)("None"), slug: "0", size: 0 }, 45962 ...customSizes, 45963 ...themeSizes, 45964 ...defaultSizes 45965 ]; 45966 return sizes; 45967 }, [customSizes, themeSizes, defaultSizes]); 45968 } 45969 function DimensionControl({ 45970 label = (0, import_i18n138.__)("Dimension"), 45971 onChange, 45972 value 45973 }) { 45974 const [dimensionSizes, availableUnits] = useSettings( 45975 "dimensions.dimensionSizes", 45976 "spacing.units" 45977 ); 45978 const units2 = (0, import_components149.__experimentalUseCustomUnits)({ 45979 availableUnits: availableUnits || [ 45980 "%", 45981 "px", 45982 "em", 45983 "rem", 45984 "vh", 45985 "vw" 45986 ] 45987 }); 45988 const options = useDimensionSizes(dimensionSizes); 45989 const [selectedUnit, setSelectedUnit] = (0, import_element153.useState)(() => { 45990 const [, unit] = (0, import_components149.__experimentalParseQuantityAndUnitFromRawValue)(value); 45991 return unit || units2[0]?.value || "px"; 45992 }); 45993 const handleUnitChange = (newUnit) => { 45994 const [currentValue, currentUnit] = (0, import_components149.__experimentalParseQuantityAndUnitFromRawValue)(value); 45995 if (["em", "rem"].includes(newUnit) && currentUnit === "px") { 45996 onChange((currentValue / 16).toFixed(2) + newUnit); 45997 } else if (["em", "rem"].includes(currentUnit) && newUnit === "px") { 45998 onChange(Math.round(currentValue * 16) + newUnit); 45999 } else if ([ 46000 "%", 46001 "vw", 46002 "svw", 46003 "lvw", 46004 "dvw", 46005 "vh", 46006 "svh", 46007 "lvh", 46008 "dvh", 46009 "vi", 46010 "svi", 46011 "lvi", 46012 "dvi", 46013 "vb", 46014 "svb", 46015 "lvb", 46016 "dvb", 46017 "vmin", 46018 "svmin", 46019 "lvmin", 46020 "dvmin", 46021 "vmax", 46022 "svmax", 46023 "lvmax", 46024 "dvmax" 46025 ].includes(newUnit) && currentValue > 100) { 46026 onChange(100 + newUnit); 46027 } 46028 setSelectedUnit(newUnit); 46029 }; 46030 return /* @__PURE__ */ (0, import_jsx_runtime297.jsxs)("fieldset", { className: "block-editor-dimension-control", children: [ 46031 /* @__PURE__ */ (0, import_jsx_runtime297.jsx)(import_components149.BaseControl.VisualLabel, { as: "legend", children: label }), 46032 /* @__PURE__ */ (0, import_jsx_runtime297.jsx)( 46033 PresetInputControl, 46034 { 46035 ariaLabel: label, 46036 className: "block-editor-dimension-control", 46037 customValueSettings: DIMENSION_CUSTOM_VALUE_SETTINGS, 46038 minimumCustomValue: 0, 46039 onChange, 46040 onUnitChange: handleUnitChange, 46041 presets: options, 46042 presetType: "dimension", 46043 selectedUnit, 46044 showTooltip: true, 46045 units: units2, 46046 value 46047 } 46048 ) 46049 ] }); 46050 } 46051 46052 // packages/block-editor/build-module/components/height-control/index.js 46053 var import_element154 = __toESM(require_element()); 46054 var import_components150 = __toESM(require_components()); 46055 var import_i18n139 = __toESM(require_i18n()); 46056 var import_deprecated19 = __toESM(require_deprecated()); 46057 var import_jsx_runtime298 = __toESM(require_jsx_runtime()); 46058 var RANGE_CONTROL_CUSTOM_SETTINGS = { 46059 px: { max: 1e3, step: 1 }, 46060 "%": { max: 100, step: 1 }, 46061 vw: { max: 100, step: 1 }, 46062 vh: { max: 100, step: 1 }, 46063 em: { max: 50, step: 0.1 }, 46064 rem: { max: 50, step: 0.1 }, 46065 svw: { max: 100, step: 1 }, 46066 lvw: { max: 100, step: 1 }, 46067 dvw: { max: 100, step: 1 }, 46068 svh: { max: 100, step: 1 }, 46069 lvh: { max: 100, step: 1 }, 46070 dvh: { max: 100, step: 1 }, 46071 vi: { max: 100, step: 1 }, 46072 svi: { max: 100, step: 1 }, 46073 lvi: { max: 100, step: 1 }, 46074 dvi: { max: 100, step: 1 }, 46075 vb: { max: 100, step: 1 }, 46076 svb: { max: 100, step: 1 }, 46077 lvb: { max: 100, step: 1 }, 46078 dvb: { max: 100, step: 1 }, 46079 vmin: { max: 100, step: 1 }, 46080 svmin: { max: 100, step: 1 }, 46081 lvmin: { max: 100, step: 1 }, 46082 dvmin: { max: 100, step: 1 }, 46083 vmax: { max: 100, step: 1 }, 46084 svmax: { max: 100, step: 1 }, 46085 lvmax: { max: 100, step: 1 }, 46086 dvmax: { max: 100, step: 1 } 46087 }; 46088 function HeightControl({ 46089 label = (0, import_i18n139.__)("Height"), 46090 onChange, 46091 value 46092 }) { 46093 (0, import_deprecated19.default)("wp.blockEditor.HeightControl", { 46094 since: "7.0", 46095 version: "7.2", 46096 alternative: "wp.blockEditor.DimensionControl" 46097 }); 46098 const customRangeValue = parseFloat(value); 46099 const [availableUnits] = useSettings("spacing.units"); 46100 const units2 = (0, import_components150.__experimentalUseCustomUnits)({ 46101 availableUnits: availableUnits || [ 46102 "%", 46103 "px", 46104 "em", 46105 "rem", 46106 "vh", 46107 "vw" 46108 ] 46109 }); 46110 const selectedUnit = (0, import_element154.useMemo)( 46111 () => (0, import_components150.__experimentalParseQuantityAndUnitFromRawValue)(value), 46112 [value] 46113 )[1] || units2[0]?.value || "px"; 46114 const handleSliderChange = (next) => { 46115 onChange([next, selectedUnit].join("")); 46116 }; 46117 const handleUnitChange = (newUnit) => { 46118 const [currentValue, currentUnit] = (0, import_components150.__experimentalParseQuantityAndUnitFromRawValue)(value); 46119 if (["em", "rem"].includes(newUnit) && currentUnit === "px") { 46120 onChange((currentValue / 16).toFixed(2) + newUnit); 46121 } else if (["em", "rem"].includes(currentUnit) && newUnit === "px") { 46122 onChange(Math.round(currentValue * 16) + newUnit); 46123 } else if ([ 46124 "%", 46125 "vw", 46126 "svw", 46127 "lvw", 46128 "dvw", 46129 "vh", 46130 "svh", 46131 "lvh", 46132 "dvh", 46133 "vi", 46134 "svi", 46135 "lvi", 46136 "dvi", 46137 "vb", 46138 "svb", 46139 "lvb", 46140 "dvb", 46141 "vmin", 46142 "svmin", 46143 "lvmin", 46144 "dvmin", 46145 "vmax", 46146 "svmax", 46147 "lvmax", 46148 "dvmax" 46149 ].includes(newUnit) && currentValue > 100) { 46150 onChange(100 + newUnit); 46151 } 46152 }; 46153 return /* @__PURE__ */ (0, import_jsx_runtime298.jsxs)("fieldset", { className: "block-editor-height-control", children: [ 46154 /* @__PURE__ */ (0, import_jsx_runtime298.jsx)(import_components150.BaseControl.VisualLabel, { as: "legend", children: label }), 46155 /* @__PURE__ */ (0, import_jsx_runtime298.jsxs)(import_components150.Flex, { children: [ 46156 /* @__PURE__ */ (0, import_jsx_runtime298.jsx)(import_components150.FlexItem, { isBlock: true, children: /* @__PURE__ */ (0, import_jsx_runtime298.jsx)( 46157 import_components150.__experimentalUnitControl, 46158 { 46159 value, 46160 units: units2, 46161 onChange, 46162 onUnitChange: handleUnitChange, 46163 min: 0, 46164 size: "__unstable-large", 46165 label, 46166 hideLabelFromVision: true 46167 } 46168 ) }), 46169 /* @__PURE__ */ (0, import_jsx_runtime298.jsx)(import_components150.FlexItem, { isBlock: true, children: /* @__PURE__ */ (0, import_jsx_runtime298.jsx)(import_components150.__experimentalSpacer, { marginX: 2, marginBottom: 0, children: /* @__PURE__ */ (0, import_jsx_runtime298.jsx)( 46170 import_components150.RangeControl, 46171 { 46172 __next40pxDefaultSize: true, 46173 value: customRangeValue, 46174 min: 0, 46175 max: RANGE_CONTROL_CUSTOM_SETTINGS[selectedUnit]?.max ?? 100, 46176 step: RANGE_CONTROL_CUSTOM_SETTINGS[selectedUnit]?.step ?? 0.1, 46177 withInputField: false, 46178 onChange: handleSliderChange, 46179 label, 46180 hideLabelFromVision: true 46181 } 46182 ) }) }) 46183 ] }) 46184 ] }); 46185 } 46186 46187 // packages/block-editor/build-module/components/image-editor/index.js 46188 var import_components156 = __toESM(require_components()); 46189 46190 // node_modules/react-easy-crop/index.module.js 46191 var React3 = __toESM(require_react()); 46192 var import_normalize_wheel = __toESM(require_normalize_wheel()); 46193 function getCropSize(mediaWidth, mediaHeight, containerWidth, containerHeight, aspect, rotation) { 46194 if (rotation === void 0) { 46195 rotation = 0; 46196 } 46197 var _a = rotateSize(mediaWidth, mediaHeight, rotation), width = _a.width, height = _a.height; 46198 var fittingWidth = Math.min(width, containerWidth); 46199 var fittingHeight = Math.min(height, containerHeight); 46200 if (fittingWidth > fittingHeight * aspect) { 46201 return { 46202 width: fittingHeight * aspect, 46203 height: fittingHeight 46204 }; 46205 } 46206 return { 46207 width: fittingWidth, 46208 height: fittingWidth / aspect 46209 }; 46210 } 46211 function getMediaZoom(mediaSize) { 46212 return mediaSize.width > mediaSize.height ? mediaSize.width / mediaSize.naturalWidth : mediaSize.height / mediaSize.naturalHeight; 46213 } 46214 function restrictPosition(position, mediaSize, cropSize, zoom, rotation) { 46215 if (rotation === void 0) { 46216 rotation = 0; 46217 } 46218 var _a = rotateSize(mediaSize.width, mediaSize.height, rotation), width = _a.width, height = _a.height; 46219 return { 46220 x: restrictPositionCoord(position.x, width, cropSize.width, zoom), 46221 y: restrictPositionCoord(position.y, height, cropSize.height, zoom) 46222 }; 46223 } 46224 function restrictPositionCoord(position, mediaSize, cropSize, zoom) { 46225 var maxPosition = mediaSize * zoom / 2 - cropSize / 2; 46226 return clamp(position, -maxPosition, maxPosition); 46227 } 46228 function getDistanceBetweenPoints(pointA, pointB) { 46229 return Math.sqrt(Math.pow(pointA.y - pointB.y, 2) + Math.pow(pointA.x - pointB.x, 2)); 46230 } 46231 function getRotationBetweenPoints(pointA, pointB) { 46232 return Math.atan2(pointB.y - pointA.y, pointB.x - pointA.x) * 180 / Math.PI; 46233 } 46234 function computeCroppedArea(crop, mediaSize, cropSize, aspect, zoom, rotation, restrictPosition2) { 46235 if (rotation === void 0) { 46236 rotation = 0; 46237 } 46238 if (restrictPosition2 === void 0) { 46239 restrictPosition2 = true; 46240 } 46241 var limitAreaFn = restrictPosition2 ? limitArea : noOp; 46242 var mediaBBoxSize = rotateSize(mediaSize.width, mediaSize.height, rotation); 46243 var mediaNaturalBBoxSize = rotateSize(mediaSize.naturalWidth, mediaSize.naturalHeight, rotation); 46244 var croppedAreaPercentages = { 46245 x: limitAreaFn(100, ((mediaBBoxSize.width - cropSize.width / zoom) / 2 - crop.x / zoom) / mediaBBoxSize.width * 100), 46246 y: limitAreaFn(100, ((mediaBBoxSize.height - cropSize.height / zoom) / 2 - crop.y / zoom) / mediaBBoxSize.height * 100), 46247 width: limitAreaFn(100, cropSize.width / mediaBBoxSize.width * 100 / zoom), 46248 height: limitAreaFn(100, cropSize.height / mediaBBoxSize.height * 100 / zoom) 46249 }; 46250 var widthInPixels = Math.round(limitAreaFn(mediaNaturalBBoxSize.width, croppedAreaPercentages.width * mediaNaturalBBoxSize.width / 100)); 46251 var heightInPixels = Math.round(limitAreaFn(mediaNaturalBBoxSize.height, croppedAreaPercentages.height * mediaNaturalBBoxSize.height / 100)); 46252 var isImgWiderThanHigh = mediaNaturalBBoxSize.width >= mediaNaturalBBoxSize.height * aspect; 46253 var sizePixels = isImgWiderThanHigh ? { 46254 width: Math.round(heightInPixels * aspect), 46255 height: heightInPixels 46256 } : { 46257 width: widthInPixels, 46258 height: Math.round(widthInPixels / aspect) 46259 }; 46260 var croppedAreaPixels = __assign(__assign({}, sizePixels), { 46261 x: Math.round(limitAreaFn(mediaNaturalBBoxSize.width - sizePixels.width, croppedAreaPercentages.x * mediaNaturalBBoxSize.width / 100)), 46262 y: Math.round(limitAreaFn(mediaNaturalBBoxSize.height - sizePixels.height, croppedAreaPercentages.y * mediaNaturalBBoxSize.height / 100)) 46263 }); 46264 return { 46265 croppedAreaPercentages, 46266 croppedAreaPixels 46267 }; 46268 } 46269 function limitArea(max, value) { 46270 return Math.min(max, Math.max(0, value)); 46271 } 46272 function noOp(_max, value) { 46273 return value; 46274 } 46275 function getInitialCropFromCroppedAreaPercentages(croppedAreaPercentages, mediaSize, rotation, cropSize, minZoom, maxZoom) { 46276 var mediaBBoxSize = rotateSize(mediaSize.width, mediaSize.height, rotation); 46277 var zoom = clamp(cropSize.width / mediaBBoxSize.width * (100 / croppedAreaPercentages.width), minZoom, maxZoom); 46278 var crop = { 46279 x: zoom * mediaBBoxSize.width / 2 - cropSize.width / 2 - mediaBBoxSize.width * zoom * (croppedAreaPercentages.x / 100), 46280 y: zoom * mediaBBoxSize.height / 2 - cropSize.height / 2 - mediaBBoxSize.height * zoom * (croppedAreaPercentages.y / 100) 46281 }; 46282 return { 46283 crop, 46284 zoom 46285 }; 46286 } 46287 function getZoomFromCroppedAreaPixels(croppedAreaPixels, mediaSize, cropSize) { 46288 var mediaZoom = getMediaZoom(mediaSize); 46289 return cropSize.height > cropSize.width ? cropSize.height / (croppedAreaPixels.height * mediaZoom) : cropSize.width / (croppedAreaPixels.width * mediaZoom); 46290 } 46291 function getInitialCropFromCroppedAreaPixels(croppedAreaPixels, mediaSize, rotation, cropSize, minZoom, maxZoom) { 46292 if (rotation === void 0) { 46293 rotation = 0; 46294 } 46295 var mediaNaturalBBoxSize = rotateSize(mediaSize.naturalWidth, mediaSize.naturalHeight, rotation); 46296 var zoom = clamp(getZoomFromCroppedAreaPixels(croppedAreaPixels, mediaSize, cropSize), minZoom, maxZoom); 46297 var cropZoom = cropSize.height > cropSize.width ? cropSize.height / croppedAreaPixels.height : cropSize.width / croppedAreaPixels.width; 46298 var crop = { 46299 x: ((mediaNaturalBBoxSize.width - croppedAreaPixels.width) / 2 - croppedAreaPixels.x) * cropZoom, 46300 y: ((mediaNaturalBBoxSize.height - croppedAreaPixels.height) / 2 - croppedAreaPixels.y) * cropZoom 46301 }; 46302 return { 46303 crop, 46304 zoom 46305 }; 46306 } 46307 function getCenter(a2, b2) { 46308 return { 46309 x: (b2.x + a2.x) / 2, 46310 y: (b2.y + a2.y) / 2 46311 }; 46312 } 46313 function getRadianAngle(degreeValue) { 46314 return degreeValue * Math.PI / 180; 46315 } 46316 function rotateSize(width, height, rotation) { 46317 var rotRad = getRadianAngle(rotation); 46318 return { 46319 width: Math.abs(Math.cos(rotRad) * width) + Math.abs(Math.sin(rotRad) * height), 46320 height: Math.abs(Math.sin(rotRad) * width) + Math.abs(Math.cos(rotRad) * height) 46321 }; 46322 } 46323 function clamp(value, min, max) { 46324 return Math.min(Math.max(value, min), max); 46325 } 46326 function classNames() { 46327 var args = []; 46328 for (var _i = 0; _i < arguments.length; _i++) { 46329 args[_i] = arguments[_i]; 46330 } 46331 return args.filter(function(value) { 46332 if (typeof value === "string" && value.length > 0) { 46333 return true; 46334 } 46335 return false; 46336 }).join(" ").trim(); 46337 } 46338 var css_248z = ".reactEasyCrop_Container {\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n overflow: hidden;\n user-select: none;\n touch-action: none;\n cursor: move;\n display: flex;\n justify-content: center;\n align-items: center;\n}\n\n.reactEasyCrop_Image,\n.reactEasyCrop_Video {\n will-change: transform; /* this improves performances and prevent painting issues on iOS Chrome */\n}\n\n.reactEasyCrop_Contain {\n max-width: 100%;\n max-height: 100%;\n margin: auto;\n position: absolute;\n top: 0;\n bottom: 0;\n left: 0;\n right: 0;\n}\n.reactEasyCrop_Cover_Horizontal {\n width: 100%;\n height: auto;\n}\n.reactEasyCrop_Cover_Vertical {\n width: auto;\n height: 100%;\n}\n\n.reactEasyCrop_CropArea {\n position: absolute;\n left: 50%;\n top: 50%;\n transform: translate(-50%, -50%);\n border: 1px solid rgba(255, 255, 255, 0.5);\n box-sizing: border-box;\n box-shadow: 0 0 0 9999em;\n color: rgba(0, 0, 0, 0.5);\n overflow: hidden;\n}\n\n.reactEasyCrop_CropAreaRound {\n border-radius: 50%;\n}\n\n.reactEasyCrop_CropAreaGrid::before {\n content: ' ';\n box-sizing: border-box;\n position: absolute;\n border: 1px solid rgba(255, 255, 255, 0.5);\n top: 0;\n bottom: 0;\n left: 33.33%;\n right: 33.33%;\n border-top: 0;\n border-bottom: 0;\n}\n\n.reactEasyCrop_CropAreaGrid::after {\n content: ' ';\n box-sizing: border-box;\n position: absolute;\n border: 1px solid rgba(255, 255, 255, 0.5);\n top: 33.33%;\n bottom: 33.33%;\n left: 0;\n right: 0;\n border-left: 0;\n border-right: 0;\n}\n"; 46339 var MIN_ZOOM = 1; 46340 var MAX_ZOOM = 3; 46341 var KEYBOARD_STEP = 1; 46342 var Cropper = ( 46343 /** @class */ 46344 (function(_super) { 46345 __extends(Cropper2, _super); 46346 function Cropper2() { 46347 var _this = _super !== null && _super.apply(this, arguments) || this; 46348 _this.cropperRef = React3.createRef(); 46349 _this.imageRef = React3.createRef(); 46350 _this.videoRef = React3.createRef(); 46351 _this.containerPosition = { 46352 x: 0, 46353 y: 0 46354 }; 46355 _this.containerRef = null; 46356 _this.styleRef = null; 46357 _this.containerRect = null; 46358 _this.mediaSize = { 46359 width: 0, 46360 height: 0, 46361 naturalWidth: 0, 46362 naturalHeight: 0 46363 }; 46364 _this.dragStartPosition = { 46365 x: 0, 46366 y: 0 46367 }; 46368 _this.dragStartCrop = { 46369 x: 0, 46370 y: 0 46371 }; 46372 _this.gestureZoomStart = 0; 46373 _this.gestureRotationStart = 0; 46374 _this.isTouching = false; 46375 _this.lastPinchDistance = 0; 46376 _this.lastPinchRotation = 0; 46377 _this.rafDragTimeout = null; 46378 _this.rafPinchTimeout = null; 46379 _this.wheelTimer = null; 46380 _this.currentDoc = typeof document !== "undefined" ? document : null; 46381 _this.currentWindow = typeof window !== "undefined" ? window : null; 46382 _this.resizeObserver = null; 46383 _this.previousCropSize = null; 46384 _this.isInitialized = false; 46385 _this.state = { 46386 cropSize: null, 46387 hasWheelJustStarted: false, 46388 mediaObjectFit: void 0 46389 }; 46390 _this.initResizeObserver = function() { 46391 if (typeof window.ResizeObserver === "undefined" || !_this.containerRef) { 46392 return; 46393 } 46394 var isFirstResize = true; 46395 _this.resizeObserver = new window.ResizeObserver(function(entries) { 46396 if (isFirstResize) { 46397 isFirstResize = false; 46398 return; 46399 } 46400 _this.computeSizes(); 46401 }); 46402 _this.resizeObserver.observe(_this.containerRef); 46403 }; 46404 _this.preventZoomSafari = function(e2) { 46405 return e2.preventDefault(); 46406 }; 46407 _this.cleanEvents = function() { 46408 if (!_this.currentDoc) return; 46409 _this.currentDoc.removeEventListener("mousemove", _this.onMouseMove); 46410 _this.currentDoc.removeEventListener("mouseup", _this.onDragStopped); 46411 _this.currentDoc.removeEventListener("touchmove", _this.onTouchMove); 46412 _this.currentDoc.removeEventListener("touchend", _this.onDragStopped); 46413 _this.currentDoc.removeEventListener("gesturechange", _this.onGestureChange); 46414 _this.currentDoc.removeEventListener("gestureend", _this.onGestureEnd); 46415 _this.currentDoc.removeEventListener("scroll", _this.onScroll); 46416 }; 46417 _this.clearScrollEvent = function() { 46418 if (_this.containerRef) _this.containerRef.removeEventListener("wheel", _this.onWheel); 46419 if (_this.wheelTimer) { 46420 clearTimeout(_this.wheelTimer); 46421 } 46422 }; 46423 _this.onMediaLoad = function() { 46424 var cropSize = _this.computeSizes(); 46425 if (cropSize) { 46426 _this.previousCropSize = cropSize; 46427 _this.emitCropData(); 46428 _this.setInitialCrop(cropSize); 46429 _this.isInitialized = true; 46430 } 46431 if (_this.props.onMediaLoaded) { 46432 _this.props.onMediaLoaded(_this.mediaSize); 46433 } 46434 }; 46435 _this.setInitialCrop = function(cropSize) { 46436 if (_this.props.initialCroppedAreaPercentages) { 46437 var _a = getInitialCropFromCroppedAreaPercentages(_this.props.initialCroppedAreaPercentages, _this.mediaSize, _this.props.rotation, cropSize, _this.props.minZoom, _this.props.maxZoom), crop = _a.crop, zoom = _a.zoom; 46438 _this.props.onCropChange(crop); 46439 _this.props.onZoomChange && _this.props.onZoomChange(zoom); 46440 } else if (_this.props.initialCroppedAreaPixels) { 46441 var _b = getInitialCropFromCroppedAreaPixels(_this.props.initialCroppedAreaPixels, _this.mediaSize, _this.props.rotation, cropSize, _this.props.minZoom, _this.props.maxZoom), crop = _b.crop, zoom = _b.zoom; 46442 _this.props.onCropChange(crop); 46443 _this.props.onZoomChange && _this.props.onZoomChange(zoom); 46444 } 46445 }; 46446 _this.computeSizes = function() { 46447 var _a, _b, _c, _d, _e, _f; 46448 var mediaRef = _this.imageRef.current || _this.videoRef.current; 46449 if (mediaRef && _this.containerRef) { 46450 _this.containerRect = _this.containerRef.getBoundingClientRect(); 46451 _this.saveContainerPosition(); 46452 var containerAspect = _this.containerRect.width / _this.containerRect.height; 46453 var naturalWidth = ((_a = _this.imageRef.current) === null || _a === void 0 ? void 0 : _a.naturalWidth) || ((_b = _this.videoRef.current) === null || _b === void 0 ? void 0 : _b.videoWidth) || 0; 46454 var naturalHeight = ((_c = _this.imageRef.current) === null || _c === void 0 ? void 0 : _c.naturalHeight) || ((_d = _this.videoRef.current) === null || _d === void 0 ? void 0 : _d.videoHeight) || 0; 46455 var isMediaScaledDown = mediaRef.offsetWidth < naturalWidth || mediaRef.offsetHeight < naturalHeight; 46456 var mediaAspect = naturalWidth / naturalHeight; 46457 var renderedMediaSize = void 0; 46458 if (isMediaScaledDown) { 46459 switch (_this.state.mediaObjectFit) { 46460 default: 46461 case "contain": 46462 renderedMediaSize = containerAspect > mediaAspect ? { 46463 width: _this.containerRect.height * mediaAspect, 46464 height: _this.containerRect.height 46465 } : { 46466 width: _this.containerRect.width, 46467 height: _this.containerRect.width / mediaAspect 46468 }; 46469 break; 46470 case "horizontal-cover": 46471 renderedMediaSize = { 46472 width: _this.containerRect.width, 46473 height: _this.containerRect.width / mediaAspect 46474 }; 46475 break; 46476 case "vertical-cover": 46477 renderedMediaSize = { 46478 width: _this.containerRect.height * mediaAspect, 46479 height: _this.containerRect.height 46480 }; 46481 break; 46482 } 46483 } else { 46484 renderedMediaSize = { 46485 width: mediaRef.offsetWidth, 46486 height: mediaRef.offsetHeight 46487 }; 46488 } 46489 _this.mediaSize = __assign(__assign({}, renderedMediaSize), { 46490 naturalWidth, 46491 naturalHeight 46492 }); 46493 if (_this.props.setMediaSize) { 46494 _this.props.setMediaSize(_this.mediaSize); 46495 } 46496 var cropSize = _this.props.cropSize ? _this.props.cropSize : getCropSize(_this.mediaSize.width, _this.mediaSize.height, _this.containerRect.width, _this.containerRect.height, _this.props.aspect, _this.props.rotation); 46497 if (((_e = _this.state.cropSize) === null || _e === void 0 ? void 0 : _e.height) !== cropSize.height || ((_f = _this.state.cropSize) === null || _f === void 0 ? void 0 : _f.width) !== cropSize.width) { 46498 _this.props.onCropSizeChange && _this.props.onCropSizeChange(cropSize); 46499 } 46500 _this.setState({ 46501 cropSize 46502 }, _this.recomputeCropPosition); 46503 if (_this.props.setCropSize) { 46504 _this.props.setCropSize(cropSize); 46505 } 46506 return cropSize; 46507 } 46508 }; 46509 _this.saveContainerPosition = function() { 46510 if (_this.containerRef) { 46511 var bounds = _this.containerRef.getBoundingClientRect(); 46512 _this.containerPosition = { 46513 x: bounds.left, 46514 y: bounds.top 46515 }; 46516 } 46517 }; 46518 _this.onMouseDown = function(e2) { 46519 if (!_this.currentDoc) return; 46520 e2.preventDefault(); 46521 _this.currentDoc.addEventListener("mousemove", _this.onMouseMove); 46522 _this.currentDoc.addEventListener("mouseup", _this.onDragStopped); 46523 _this.saveContainerPosition(); 46524 _this.onDragStart(Cropper2.getMousePoint(e2)); 46525 }; 46526 _this.onMouseMove = function(e2) { 46527 return _this.onDrag(Cropper2.getMousePoint(e2)); 46528 }; 46529 _this.onScroll = function(e2) { 46530 if (!_this.currentDoc) return; 46531 e2.preventDefault(); 46532 _this.saveContainerPosition(); 46533 }; 46534 _this.onTouchStart = function(e2) { 46535 if (!_this.currentDoc) return; 46536 _this.isTouching = true; 46537 if (_this.props.onTouchRequest && !_this.props.onTouchRequest(e2)) { 46538 return; 46539 } 46540 _this.currentDoc.addEventListener("touchmove", _this.onTouchMove, { 46541 passive: false 46542 }); 46543 _this.currentDoc.addEventListener("touchend", _this.onDragStopped); 46544 _this.saveContainerPosition(); 46545 if (e2.touches.length === 2) { 46546 _this.onPinchStart(e2); 46547 } else if (e2.touches.length === 1) { 46548 _this.onDragStart(Cropper2.getTouchPoint(e2.touches[0])); 46549 } 46550 }; 46551 _this.onTouchMove = function(e2) { 46552 e2.preventDefault(); 46553 if (e2.touches.length === 2) { 46554 _this.onPinchMove(e2); 46555 } else if (e2.touches.length === 1) { 46556 _this.onDrag(Cropper2.getTouchPoint(e2.touches[0])); 46557 } 46558 }; 46559 _this.onGestureStart = function(e2) { 46560 if (!_this.currentDoc) return; 46561 e2.preventDefault(); 46562 _this.currentDoc.addEventListener("gesturechange", _this.onGestureChange); 46563 _this.currentDoc.addEventListener("gestureend", _this.onGestureEnd); 46564 _this.gestureZoomStart = _this.props.zoom; 46565 _this.gestureRotationStart = _this.props.rotation; 46566 }; 46567 _this.onGestureChange = function(e2) { 46568 e2.preventDefault(); 46569 if (_this.isTouching) { 46570 return; 46571 } 46572 var point = Cropper2.getMousePoint(e2); 46573 var newZoom = _this.gestureZoomStart - 1 + e2.scale; 46574 _this.setNewZoom(newZoom, point, { 46575 shouldUpdatePosition: true 46576 }); 46577 if (_this.props.onRotationChange) { 46578 var newRotation = _this.gestureRotationStart + e2.rotation; 46579 _this.props.onRotationChange(newRotation); 46580 } 46581 }; 46582 _this.onGestureEnd = function(e2) { 46583 _this.cleanEvents(); 46584 }; 46585 _this.onDragStart = function(_a) { 46586 var _b, _c; 46587 var x2 = _a.x, y2 = _a.y; 46588 _this.dragStartPosition = { 46589 x: x2, 46590 y: y2 46591 }; 46592 _this.dragStartCrop = __assign({}, _this.props.crop); 46593 (_c = (_b = _this.props).onInteractionStart) === null || _c === void 0 ? void 0 : _c.call(_b); 46594 }; 46595 _this.onDrag = function(_a) { 46596 var x2 = _a.x, y2 = _a.y; 46597 if (!_this.currentWindow) return; 46598 if (_this.rafDragTimeout) _this.currentWindow.cancelAnimationFrame(_this.rafDragTimeout); 46599 _this.rafDragTimeout = _this.currentWindow.requestAnimationFrame(function() { 46600 if (!_this.state.cropSize) return; 46601 if (x2 === void 0 || y2 === void 0) return; 46602 var offsetX = x2 - _this.dragStartPosition.x; 46603 var offsetY = y2 - _this.dragStartPosition.y; 46604 var requestedPosition = { 46605 x: _this.dragStartCrop.x + offsetX, 46606 y: _this.dragStartCrop.y + offsetY 46607 }; 46608 var newPosition = _this.props.restrictPosition ? restrictPosition(requestedPosition, _this.mediaSize, _this.state.cropSize, _this.props.zoom, _this.props.rotation) : requestedPosition; 46609 _this.props.onCropChange(newPosition); 46610 }); 46611 }; 46612 _this.onDragStopped = function() { 46613 var _a, _b; 46614 _this.isTouching = false; 46615 _this.cleanEvents(); 46616 _this.emitCropData(); 46617 (_b = (_a = _this.props).onInteractionEnd) === null || _b === void 0 ? void 0 : _b.call(_a); 46618 }; 46619 _this.onWheel = function(e2) { 46620 if (!_this.currentWindow) return; 46621 if (_this.props.onWheelRequest && !_this.props.onWheelRequest(e2)) { 46622 return; 46623 } 46624 e2.preventDefault(); 46625 var point = Cropper2.getMousePoint(e2); 46626 var pixelY = (0, import_normalize_wheel.default)(e2).pixelY; 46627 var newZoom = _this.props.zoom - pixelY * _this.props.zoomSpeed / 200; 46628 _this.setNewZoom(newZoom, point, { 46629 shouldUpdatePosition: true 46630 }); 46631 if (!_this.state.hasWheelJustStarted) { 46632 _this.setState({ 46633 hasWheelJustStarted: true 46634 }, function() { 46635 var _a, _b; 46636 return (_b = (_a = _this.props).onInteractionStart) === null || _b === void 0 ? void 0 : _b.call(_a); 46637 }); 46638 } 46639 if (_this.wheelTimer) { 46640 clearTimeout(_this.wheelTimer); 46641 } 46642 _this.wheelTimer = _this.currentWindow.setTimeout(function() { 46643 return _this.setState({ 46644 hasWheelJustStarted: false 46645 }, function() { 46646 var _a, _b; 46647 return (_b = (_a = _this.props).onInteractionEnd) === null || _b === void 0 ? void 0 : _b.call(_a); 46648 }); 46649 }, 250); 46650 }; 46651 _this.getPointOnContainer = function(_a, containerTopLeft) { 46652 var x2 = _a.x, y2 = _a.y; 46653 if (!_this.containerRect) { 46654 throw new Error("The Cropper is not mounted"); 46655 } 46656 return { 46657 x: _this.containerRect.width / 2 - (x2 - containerTopLeft.x), 46658 y: _this.containerRect.height / 2 - (y2 - containerTopLeft.y) 46659 }; 46660 }; 46661 _this.getPointOnMedia = function(_a) { 46662 var x2 = _a.x, y2 = _a.y; 46663 var _b = _this.props, crop = _b.crop, zoom = _b.zoom; 46664 return { 46665 x: (x2 + crop.x) / zoom, 46666 y: (y2 + crop.y) / zoom 46667 }; 46668 }; 46669 _this.setNewZoom = function(zoom, point, _a) { 46670 var _b = _a === void 0 ? {} : _a, _c = _b.shouldUpdatePosition, shouldUpdatePosition = _c === void 0 ? true : _c; 46671 if (!_this.state.cropSize || !_this.props.onZoomChange) return; 46672 var newZoom = clamp(zoom, _this.props.minZoom, _this.props.maxZoom); 46673 if (shouldUpdatePosition) { 46674 var zoomPoint = _this.getPointOnContainer(point, _this.containerPosition); 46675 var zoomTarget = _this.getPointOnMedia(zoomPoint); 46676 var requestedPosition = { 46677 x: zoomTarget.x * newZoom - zoomPoint.x, 46678 y: zoomTarget.y * newZoom - zoomPoint.y 46679 }; 46680 var newPosition = _this.props.restrictPosition ? restrictPosition(requestedPosition, _this.mediaSize, _this.state.cropSize, newZoom, _this.props.rotation) : requestedPosition; 46681 _this.props.onCropChange(newPosition); 46682 } 46683 _this.props.onZoomChange(newZoom); 46684 }; 46685 _this.getCropData = function() { 46686 if (!_this.state.cropSize) { 46687 return null; 46688 } 46689 var restrictedPosition = _this.props.restrictPosition ? restrictPosition(_this.props.crop, _this.mediaSize, _this.state.cropSize, _this.props.zoom, _this.props.rotation) : _this.props.crop; 46690 return computeCroppedArea(restrictedPosition, _this.mediaSize, _this.state.cropSize, _this.getAspect(), _this.props.zoom, _this.props.rotation, _this.props.restrictPosition); 46691 }; 46692 _this.emitCropData = function() { 46693 var cropData = _this.getCropData(); 46694 if (!cropData) return; 46695 var croppedAreaPercentages = cropData.croppedAreaPercentages, croppedAreaPixels = cropData.croppedAreaPixels; 46696 if (_this.props.onCropComplete) { 46697 _this.props.onCropComplete(croppedAreaPercentages, croppedAreaPixels); 46698 } 46699 if (_this.props.onCropAreaChange) { 46700 _this.props.onCropAreaChange(croppedAreaPercentages, croppedAreaPixels); 46701 } 46702 }; 46703 _this.emitCropAreaChange = function() { 46704 var cropData = _this.getCropData(); 46705 if (!cropData) return; 46706 var croppedAreaPercentages = cropData.croppedAreaPercentages, croppedAreaPixels = cropData.croppedAreaPixels; 46707 if (_this.props.onCropAreaChange) { 46708 _this.props.onCropAreaChange(croppedAreaPercentages, croppedAreaPixels); 46709 } 46710 }; 46711 _this.recomputeCropPosition = function() { 46712 if (!_this.state.cropSize) return; 46713 var adjustedCrop = _this.props.crop; 46714 if (_this.isInitialized && _this.previousCropSize) { 46715 var sizeChanged = Math.abs(_this.previousCropSize.width - _this.state.cropSize.width) > 1e-6 || Math.abs(_this.previousCropSize.height - _this.state.cropSize.height) > 1e-6; 46716 if (sizeChanged) { 46717 var scaleX = _this.state.cropSize.width / _this.previousCropSize.width; 46718 var scaleY = _this.state.cropSize.height / _this.previousCropSize.height; 46719 adjustedCrop = { 46720 x: _this.props.crop.x * scaleX, 46721 y: _this.props.crop.y * scaleY 46722 }; 46723 } 46724 } 46725 var newPosition = _this.props.restrictPosition ? restrictPosition(adjustedCrop, _this.mediaSize, _this.state.cropSize, _this.props.zoom, _this.props.rotation) : adjustedCrop; 46726 _this.previousCropSize = _this.state.cropSize; 46727 _this.props.onCropChange(newPosition); 46728 _this.emitCropData(); 46729 }; 46730 _this.onKeyDown = function(event) { 46731 var _a, _b; 46732 var _c = _this.props, crop = _c.crop, onCropChange = _c.onCropChange, keyboardStep = _c.keyboardStep, zoom = _c.zoom, rotation = _c.rotation; 46733 var step = keyboardStep; 46734 if (!_this.state.cropSize) return; 46735 if (event.shiftKey) { 46736 step *= 0.2; 46737 } 46738 var newCrop = __assign({}, crop); 46739 switch (event.key) { 46740 case "ArrowUp": 46741 newCrop.y -= step; 46742 event.preventDefault(); 46743 break; 46744 case "ArrowDown": 46745 newCrop.y += step; 46746 event.preventDefault(); 46747 break; 46748 case "ArrowLeft": 46749 newCrop.x -= step; 46750 event.preventDefault(); 46751 break; 46752 case "ArrowRight": 46753 newCrop.x += step; 46754 event.preventDefault(); 46755 break; 46756 default: 46757 return; 46758 } 46759 if (_this.props.restrictPosition) { 46760 newCrop = restrictPosition(newCrop, _this.mediaSize, _this.state.cropSize, zoom, rotation); 46761 } 46762 if (!event.repeat) { 46763 (_b = (_a = _this.props).onInteractionStart) === null || _b === void 0 ? void 0 : _b.call(_a); 46764 } 46765 onCropChange(newCrop); 46766 }; 46767 _this.onKeyUp = function(event) { 46768 var _a, _b; 46769 switch (event.key) { 46770 case "ArrowUp": 46771 case "ArrowDown": 46772 case "ArrowLeft": 46773 case "ArrowRight": 46774 event.preventDefault(); 46775 break; 46776 default: 46777 return; 46778 } 46779 _this.emitCropData(); 46780 (_b = (_a = _this.props).onInteractionEnd) === null || _b === void 0 ? void 0 : _b.call(_a); 46781 }; 46782 return _this; 46783 } 46784 Cropper2.prototype.componentDidMount = function() { 46785 if (!this.currentDoc || !this.currentWindow) return; 46786 if (this.containerRef) { 46787 if (this.containerRef.ownerDocument) { 46788 this.currentDoc = this.containerRef.ownerDocument; 46789 } 46790 if (this.currentDoc.defaultView) { 46791 this.currentWindow = this.currentDoc.defaultView; 46792 } 46793 this.initResizeObserver(); 46794 if (typeof window.ResizeObserver === "undefined") { 46795 this.currentWindow.addEventListener("resize", this.computeSizes); 46796 } 46797 this.props.zoomWithScroll && this.containerRef.addEventListener("wheel", this.onWheel, { 46798 passive: false 46799 }); 46800 this.containerRef.addEventListener("gesturestart", this.onGestureStart); 46801 } 46802 this.currentDoc.addEventListener("scroll", this.onScroll); 46803 if (!this.props.disableAutomaticStylesInjection) { 46804 this.styleRef = this.currentDoc.createElement("style"); 46805 this.styleRef.setAttribute("type", "text/css"); 46806 if (this.props.nonce) { 46807 this.styleRef.setAttribute("nonce", this.props.nonce); 46808 } 46809 this.styleRef.innerHTML = css_248z; 46810 this.currentDoc.head.appendChild(this.styleRef); 46811 } 46812 if (this.imageRef.current && this.imageRef.current.complete) { 46813 this.onMediaLoad(); 46814 } 46815 if (this.props.setImageRef) { 46816 this.props.setImageRef(this.imageRef); 46817 } 46818 if (this.props.setVideoRef) { 46819 this.props.setVideoRef(this.videoRef); 46820 } 46821 if (this.props.setCropperRef) { 46822 this.props.setCropperRef(this.cropperRef); 46823 } 46824 }; 46825 Cropper2.prototype.componentWillUnmount = function() { 46826 var _a, _b; 46827 if (!this.currentDoc || !this.currentWindow) return; 46828 if (typeof window.ResizeObserver === "undefined") { 46829 this.currentWindow.removeEventListener("resize", this.computeSizes); 46830 } 46831 (_a = this.resizeObserver) === null || _a === void 0 ? void 0 : _a.disconnect(); 46832 if (this.containerRef) { 46833 this.containerRef.removeEventListener("gesturestart", this.preventZoomSafari); 46834 } 46835 if (this.styleRef) { 46836 (_b = this.styleRef.parentNode) === null || _b === void 0 ? void 0 : _b.removeChild(this.styleRef); 46837 } 46838 this.cleanEvents(); 46839 this.props.zoomWithScroll && this.clearScrollEvent(); 46840 }; 46841 Cropper2.prototype.componentDidUpdate = function(prevProps) { 46842 var _a, _b, _c, _d, _e, _f, _g, _h, _j; 46843 if (prevProps.rotation !== this.props.rotation) { 46844 this.computeSizes(); 46845 this.recomputeCropPosition(); 46846 } else if (prevProps.aspect !== this.props.aspect) { 46847 this.computeSizes(); 46848 } else if (prevProps.objectFit !== this.props.objectFit) { 46849 this.computeSizes(); 46850 } else if (prevProps.zoom !== this.props.zoom) { 46851 this.recomputeCropPosition(); 46852 } else if (((_a = prevProps.cropSize) === null || _a === void 0 ? void 0 : _a.height) !== ((_b = this.props.cropSize) === null || _b === void 0 ? void 0 : _b.height) || ((_c = prevProps.cropSize) === null || _c === void 0 ? void 0 : _c.width) !== ((_d = this.props.cropSize) === null || _d === void 0 ? void 0 : _d.width)) { 46853 this.computeSizes(); 46854 } else if (((_e = prevProps.crop) === null || _e === void 0 ? void 0 : _e.x) !== ((_f = this.props.crop) === null || _f === void 0 ? void 0 : _f.x) || ((_g = prevProps.crop) === null || _g === void 0 ? void 0 : _g.y) !== ((_h = this.props.crop) === null || _h === void 0 ? void 0 : _h.y)) { 46855 this.emitCropAreaChange(); 46856 } 46857 if (prevProps.zoomWithScroll !== this.props.zoomWithScroll && this.containerRef) { 46858 this.props.zoomWithScroll ? this.containerRef.addEventListener("wheel", this.onWheel, { 46859 passive: false 46860 }) : this.clearScrollEvent(); 46861 } 46862 if (prevProps.video !== this.props.video) { 46863 (_j = this.videoRef.current) === null || _j === void 0 ? void 0 : _j.load(); 46864 } 46865 var objectFit = this.getObjectFit(); 46866 if (objectFit !== this.state.mediaObjectFit) { 46867 this.setState({ 46868 mediaObjectFit: objectFit 46869 }, this.computeSizes); 46870 } 46871 }; 46872 Cropper2.prototype.getAspect = function() { 46873 var _a = this.props, cropSize = _a.cropSize, aspect = _a.aspect; 46874 if (cropSize) { 46875 return cropSize.width / cropSize.height; 46876 } 46877 return aspect; 46878 }; 46879 Cropper2.prototype.getObjectFit = function() { 46880 var _a, _b, _c, _d; 46881 if (this.props.objectFit === "cover") { 46882 var mediaRef = this.imageRef.current || this.videoRef.current; 46883 if (mediaRef && this.containerRef) { 46884 this.containerRect = this.containerRef.getBoundingClientRect(); 46885 var containerAspect = this.containerRect.width / this.containerRect.height; 46886 var naturalWidth = ((_a = this.imageRef.current) === null || _a === void 0 ? void 0 : _a.naturalWidth) || ((_b = this.videoRef.current) === null || _b === void 0 ? void 0 : _b.videoWidth) || 0; 46887 var naturalHeight = ((_c = this.imageRef.current) === null || _c === void 0 ? void 0 : _c.naturalHeight) || ((_d = this.videoRef.current) === null || _d === void 0 ? void 0 : _d.videoHeight) || 0; 46888 var mediaAspect = naturalWidth / naturalHeight; 46889 return mediaAspect < containerAspect ? "horizontal-cover" : "vertical-cover"; 46890 } 46891 return "horizontal-cover"; 46892 } 46893 return this.props.objectFit; 46894 }; 46895 Cropper2.prototype.onPinchStart = function(e2) { 46896 var pointA = Cropper2.getTouchPoint(e2.touches[0]); 46897 var pointB = Cropper2.getTouchPoint(e2.touches[1]); 46898 this.lastPinchDistance = getDistanceBetweenPoints(pointA, pointB); 46899 this.lastPinchRotation = getRotationBetweenPoints(pointA, pointB); 46900 this.onDragStart(getCenter(pointA, pointB)); 46901 }; 46902 Cropper2.prototype.onPinchMove = function(e2) { 46903 var _this = this; 46904 if (!this.currentDoc || !this.currentWindow) return; 46905 var pointA = Cropper2.getTouchPoint(e2.touches[0]); 46906 var pointB = Cropper2.getTouchPoint(e2.touches[1]); 46907 var center = getCenter(pointA, pointB); 46908 this.onDrag(center); 46909 if (this.rafPinchTimeout) this.currentWindow.cancelAnimationFrame(this.rafPinchTimeout); 46910 this.rafPinchTimeout = this.currentWindow.requestAnimationFrame(function() { 46911 var distance = getDistanceBetweenPoints(pointA, pointB); 46912 var newZoom = _this.props.zoom * (distance / _this.lastPinchDistance); 46913 _this.setNewZoom(newZoom, center, { 46914 shouldUpdatePosition: false 46915 }); 46916 _this.lastPinchDistance = distance; 46917 var rotation = getRotationBetweenPoints(pointA, pointB); 46918 var newRotation = _this.props.rotation + (rotation - _this.lastPinchRotation); 46919 _this.props.onRotationChange && _this.props.onRotationChange(newRotation); 46920 _this.lastPinchRotation = rotation; 46921 }); 46922 }; 46923 Cropper2.prototype.render = function() { 46924 var _this = this; 46925 var _a; 46926 var _b = this.props, image = _b.image, video = _b.video, mediaProps = _b.mediaProps, cropperProps = _b.cropperProps, transform = _b.transform, _c = _b.crop, x2 = _c.x, y2 = _c.y, rotation = _b.rotation, zoom = _b.zoom, cropShape = _b.cropShape, showGrid = _b.showGrid, roundCropAreaPixels = _b.roundCropAreaPixels, _d = _b.style, containerStyle = _d.containerStyle, cropAreaStyle = _d.cropAreaStyle, mediaStyle = _d.mediaStyle, _e = _b.classes, containerClassName = _e.containerClassName, cropAreaClassName = _e.cropAreaClassName, mediaClassName = _e.mediaClassName; 46927 var objectFit = (_a = this.state.mediaObjectFit) !== null && _a !== void 0 ? _a : this.getObjectFit(); 46928 return React3.createElement("div", { 46929 onMouseDown: this.onMouseDown, 46930 onTouchStart: this.onTouchStart, 46931 ref: function ref(el) { 46932 return _this.containerRef = el; 46933 }, 46934 "data-testid": "container", 46935 style: containerStyle, 46936 className: classNames("reactEasyCrop_Container", containerClassName) 46937 }, image ? React3.createElement("img", __assign({ 46938 alt: "", 46939 className: classNames("reactEasyCrop_Image", objectFit === "contain" && "reactEasyCrop_Contain", objectFit === "horizontal-cover" && "reactEasyCrop_Cover_Horizontal", objectFit === "vertical-cover" && "reactEasyCrop_Cover_Vertical", mediaClassName) 46940 }, mediaProps, { 46941 src: image, 46942 ref: this.imageRef, 46943 style: __assign(__assign({}, mediaStyle), { 46944 transform: transform || "translate(".concat(x2, "px, ").concat(y2, "px) rotate(").concat(rotation, "deg) scale(").concat(zoom, ")") 46945 }), 46946 onLoad: this.onMediaLoad 46947 })) : video && React3.createElement("video", __assign({ 46948 autoPlay: true, 46949 playsInline: true, 46950 loop: true, 46951 muted: true, 46952 className: classNames("reactEasyCrop_Video", objectFit === "contain" && "reactEasyCrop_Contain", objectFit === "horizontal-cover" && "reactEasyCrop_Cover_Horizontal", objectFit === "vertical-cover" && "reactEasyCrop_Cover_Vertical", mediaClassName) 46953 }, mediaProps, { 46954 ref: this.videoRef, 46955 onLoadedMetadata: this.onMediaLoad, 46956 style: __assign(__assign({}, mediaStyle), { 46957 transform: transform || "translate(".concat(x2, "px, ").concat(y2, "px) rotate(").concat(rotation, "deg) scale(").concat(zoom, ")") 46958 }), 46959 controls: false 46960 }), (Array.isArray(video) ? video : [{ 46961 src: video 46962 }]).map(function(item) { 46963 return React3.createElement("source", __assign({ 46964 key: item.src 46965 }, item)); 46966 })), this.state.cropSize && React3.createElement("div", __assign({ 46967 ref: this.cropperRef, 46968 style: __assign(__assign({}, cropAreaStyle), { 46969 width: roundCropAreaPixels ? Math.round(this.state.cropSize.width) : this.state.cropSize.width, 46970 height: roundCropAreaPixels ? Math.round(this.state.cropSize.height) : this.state.cropSize.height 46971 }), 46972 tabIndex: 0, 46973 onKeyDown: this.onKeyDown, 46974 onKeyUp: this.onKeyUp, 46975 "data-testid": "cropper", 46976 className: classNames("reactEasyCrop_CropArea", cropShape === "round" && "reactEasyCrop_CropAreaRound", showGrid && "reactEasyCrop_CropAreaGrid", cropAreaClassName) 46977 }, cropperProps))); 46978 }; 46979 Cropper2.defaultProps = { 46980 zoom: 1, 46981 rotation: 0, 46982 aspect: 4 / 3, 46983 maxZoom: MAX_ZOOM, 46984 minZoom: MIN_ZOOM, 46985 cropShape: "rect", 46986 objectFit: "contain", 46987 showGrid: true, 46988 style: {}, 46989 classes: {}, 46990 mediaProps: {}, 46991 cropperProps: {}, 46992 zoomSpeed: 1, 46993 restrictPosition: true, 46994 zoomWithScroll: true, 46995 keyboardStep: KEYBOARD_STEP 46996 }; 46997 Cropper2.getMousePoint = function(e2) { 46998 return { 46999 x: Number(e2.clientX), 47000 y: Number(e2.clientY) 47001 }; 47002 }; 47003 Cropper2.getTouchPoint = function(touch) { 47004 return { 47005 x: Number(touch.clientX), 47006 y: Number(touch.clientY) 47007 }; 47008 }; 47009 return Cropper2; 47010 })(React3.Component) 47011 ); 47012 47013 // packages/image-cropper/build-module/components/image-cropper/index.js 47014 var import_element157 = __toESM(require_element()); 47015 47016 // packages/image-cropper/build-module/provider/index.js 47017 var import_element156 = __toESM(require_element()); 47018 47019 // node_modules/dequal/dist/index.mjs 47020 var has = Object.prototype.hasOwnProperty; 47021 function find(iter, tar, key) { 47022 for (key of iter.keys()) { 47023 if (dequal(key, tar)) return key; 47024 } 47025 } 47026 function dequal(foo, bar) { 47027 var ctor, len, tmp; 47028 if (foo === bar) return true; 47029 if (foo && bar && (ctor = foo.constructor) === bar.constructor) { 47030 if (ctor === Date) return foo.getTime() === bar.getTime(); 47031 if (ctor === RegExp) return foo.toString() === bar.toString(); 47032 if (ctor === Array) { 47033 if ((len = foo.length) === bar.length) { 47034 while (len-- && dequal(foo[len], bar[len])) ; 47035 } 47036 return len === -1; 47037 } 47038 if (ctor === Set) { 47039 if (foo.size !== bar.size) { 47040 return false; 47041 } 47042 for (len of foo) { 47043 tmp = len; 47044 if (tmp && typeof tmp === "object") { 47045 tmp = find(bar, tmp); 47046 if (!tmp) return false; 47047 } 47048 if (!bar.has(tmp)) return false; 47049 } 47050 return true; 47051 } 47052 if (ctor === Map) { 47053 if (foo.size !== bar.size) { 47054 return false; 47055 } 47056 for (len of foo) { 47057 tmp = len[0]; 47058 if (tmp && typeof tmp === "object") { 47059 tmp = find(bar, tmp); 47060 if (!tmp) return false; 47061 } 47062 if (!dequal(len[1], bar.get(tmp))) { 47063 return false; 47064 } 47065 } 47066 return true; 47067 } 47068 if (ctor === ArrayBuffer) { 47069 foo = new Uint8Array(foo); 47070 bar = new Uint8Array(bar); 47071 } else if (ctor === DataView) { 47072 if ((len = foo.byteLength) === bar.byteLength) { 47073 while (len-- && foo.getInt8(len) === bar.getInt8(len)) ; 47074 } 47075 return len === -1; 47076 } 47077 if (ArrayBuffer.isView(foo)) { 47078 if ((len = foo.byteLength) === bar.byteLength) { 47079 while (len-- && foo[len] === bar[len]) ; 47080 } 47081 return len === -1; 47082 } 47083 if (!ctor || typeof foo === "object") { 47084 len = 0; 47085 for (ctor in foo) { 47086 if (has.call(foo, ctor) && ++len && !has.call(bar, ctor)) return false; 47087 if (!(ctor in bar) || !dequal(foo[ctor], bar[ctor])) return false; 47088 } 47089 return Object.keys(bar).length === len; 47090 } 47091 } 47092 return foo !== foo && bar !== bar; 47093 } 47094 47095 // packages/image-cropper/build-module/provider/use-image-cropper.js 47096 var import_element155 = __toESM(require_element()); 47097 47098 // packages/image-cropper/build-module/constants.js 47099 var MIN_ZOOM2 = 1; 47100 var MAX_ZOOM2 = 5; 47101 47102 // packages/image-cropper/build-module/utils.js 47103 var normalizeRotation = (rotation) => { 47104 if (rotation >= 0) { 47105 return rotation % 360; 47106 } 47107 return (360 + rotation % 360) % 360; 47108 }; 47109 var createImage = (url) => new Promise((resolve, reject) => { 47110 const image = new Image(); 47111 image.addEventListener("load", () => resolve(image)); 47112 image.addEventListener("error", (error) => reject(error)); 47113 image.setAttribute("crossOrigin", "anonymous"); 47114 image.src = url; 47115 }); 47116 function getRadianAngle2(degreeValue) { 47117 return degreeValue * Math.PI / 180; 47118 } 47119 function rotateSize2(width, height, rotation) { 47120 const rotRad = getRadianAngle2(rotation); 47121 return { 47122 width: Math.abs(Math.cos(rotRad) * width) + Math.abs(Math.sin(rotRad) * height), 47123 height: Math.abs(Math.sin(rotRad) * width) + Math.abs(Math.cos(rotRad) * height) 47124 }; 47125 } 47126 async function getCroppedImage(imageSrc, pixelCrop, rotation = 0, flip = { horizontal: false, vertical: false }) { 47127 try { 47128 const image = await createImage(imageSrc); 47129 const canvas = document.createElement("canvas"); 47130 const ctx2 = canvas.getContext("2d"); 47131 if (!ctx2) { 47132 return null; 47133 } 47134 const rotRad = getRadianAngle2(rotation); 47135 const { width: boundingBoxWidth, height: boundingBoxHeight } = rotateSize2(image.width, image.height, rotation); 47136 canvas.width = boundingBoxWidth; 47137 canvas.height = boundingBoxHeight; 47138 ctx2.translate(boundingBoxWidth / 2, boundingBoxHeight / 2); 47139 ctx2.rotate(rotRad); 47140 ctx2.scale(flip.horizontal ? -1 : 1, flip.vertical ? -1 : 1); 47141 ctx2.translate(-image.width / 2, -image.height / 2); 47142 ctx2.drawImage(image, 0, 0); 47143 const croppedCanvas = document.createElement("canvas"); 47144 const croppedCtx = croppedCanvas.getContext("2d"); 47145 if (!croppedCtx) { 47146 return null; 47147 } 47148 croppedCanvas.width = pixelCrop.width; 47149 croppedCanvas.height = pixelCrop.height; 47150 croppedCtx.drawImage( 47151 canvas, 47152 pixelCrop.x, 47153 pixelCrop.y, 47154 pixelCrop.width, 47155 pixelCrop.height, 47156 0, 47157 0, 47158 pixelCrop.width, 47159 pixelCrop.height 47160 ); 47161 return new Promise((resolve) => { 47162 croppedCanvas.toBlob((file) => { 47163 if (file) { 47164 resolve(URL.createObjectURL(file)); 47165 } 47166 }, "image/jpeg"); 47167 }); 47168 } catch { 47169 return null; 47170 } 47171 } 47172 47173 // packages/image-cropper/build-module/provider/use-image-cropper.js 47174 var DEFAULT_INITIAL_STATE = { 47175 crop: { 47176 x: 0, 47177 y: 0, 47178 width: 100, 47179 height: 100 47180 }, 47181 zoom: MIN_ZOOM2, 47182 rotation: 0, 47183 aspectRatio: 1, 47184 flip: { 47185 horizontal: false, 47186 vertical: false 47187 } 47188 }; 47189 var DEFAULT_CROP_MEDIA_POSITION = { 47190 x: 0, 47191 y: 0 47192 }; 47193 var DEFAULT_CROPPER_STATE = { 47194 crop: DEFAULT_CROP_MEDIA_POSITION, 47195 croppedArea: DEFAULT_INITIAL_STATE.crop, 47196 croppedAreaPixels: null, 47197 zoom: DEFAULT_INITIAL_STATE.zoom, 47198 rotation: DEFAULT_INITIAL_STATE.rotation, 47199 flip: DEFAULT_INITIAL_STATE.flip, 47200 aspectRatio: DEFAULT_INITIAL_STATE.aspectRatio, 47201 mediaSize: null 47202 }; 47203 function useCropper() { 47204 const [cropperState, setInternalCropperState] = (0, import_element155.useState)( 47205 DEFAULT_CROPPER_STATE 47206 ); 47207 const [resetState, setInternalResetState] = (0, import_element155.useState)(null); 47208 const setCropperState = (0, import_element155.useCallback)( 47209 (newState) => { 47210 setInternalCropperState((prev) => { 47211 const updates = typeof newState === "function" ? newState(prev) : newState; 47212 const normalizedUpdates = { ...updates }; 47213 if ("rotation" in normalizedUpdates && normalizedUpdates.rotation !== void 0) { 47214 normalizedUpdates.rotation = normalizeRotation( 47215 normalizedUpdates.rotation 47216 ); 47217 } 47218 return { ...prev, ...normalizedUpdates }; 47219 }); 47220 }, 47221 [] 47222 ); 47223 const setResetState = (0, import_element155.useCallback)( 47224 (newResetState = null) => { 47225 if (!newResetState) { 47226 setInternalResetState(null); 47227 setCropperState(DEFAULT_CROPPER_STATE); 47228 return; 47229 } 47230 if (typeof newResetState === "object") { 47231 const initialState = { 47232 ...DEFAULT_INITIAL_STATE, 47233 ...newResetState 47234 }; 47235 setInternalResetState(initialState); 47236 setCropperState(initialState); 47237 } 47238 }, 47239 [setCropperState, setInternalResetState] 47240 ); 47241 const reset = (0, import_element155.useCallback)(() => { 47242 if (resetState) { 47243 const resetUpdates = { 47244 // Reset media position to center 47245 crop: { x: 0, y: 0 }, 47246 // Reset cropped area pixels (will be recalculated) 47247 croppedAreaPixels: null 47248 }; 47249 if (resetState.crop) { 47250 resetUpdates.croppedArea = resetState.crop; 47251 } 47252 if (resetState.zoom !== void 0) { 47253 resetUpdates.zoom = resetState.zoom; 47254 } 47255 if (resetState.rotation !== void 0) { 47256 resetUpdates.rotation = resetState.rotation; 47257 } 47258 if (resetState.aspectRatio !== void 0) { 47259 resetUpdates.aspectRatio = resetState.aspectRatio; 47260 } 47261 if (resetState.flip !== void 0) { 47262 resetUpdates.flip = resetState.flip; 47263 } 47264 setCropperState(resetUpdates); 47265 } else { 47266 setCropperState({ ...DEFAULT_CROPPER_STATE }); 47267 } 47268 }, [resetState, setCropperState]); 47269 const isDirty = (0, import_element155.useMemo)(() => { 47270 if (resetState) { 47271 const currentState2 = { 47272 crop: cropperState.croppedAreaPixels || cropperState.croppedArea, 47273 zoom: cropperState.zoom, 47274 rotation: normalizeRotation(cropperState.rotation), 47275 aspectRatio: cropperState.aspectRatio, 47276 flip: cropperState.flip 47277 }; 47278 return false === dequal(currentState2, resetState); 47279 } 47280 const currentState = { 47281 crop: cropperState.croppedArea, 47282 zoom: cropperState.zoom, 47283 rotation: normalizeRotation(cropperState.rotation), 47284 aspectRatio: cropperState.aspectRatio, 47285 flip: cropperState.flip 47286 }; 47287 return false === dequal(currentState, DEFAULT_INITIAL_STATE); 47288 }, [cropperState, resetState]); 47289 const getCroppedImage2 = (0, import_element155.useCallback)( 47290 async (src) => { 47291 if (!cropperState.croppedAreaPixels) { 47292 return null; 47293 } 47294 return getCroppedImage( 47295 src, 47296 cropperState.croppedAreaPixels, 47297 cropperState.rotation, 47298 cropperState.flip 47299 ); 47300 }, 47301 [ 47302 cropperState.croppedAreaPixels, 47303 cropperState.rotation, 47304 cropperState.flip 47305 ] 47306 ); 47307 return (0, import_element155.useMemo)( 47308 () => ({ 47309 cropperState, 47310 setCropperState, 47311 resetState, 47312 setResetState, 47313 isDirty, 47314 reset, 47315 getCroppedImage: getCroppedImage2 47316 }), 47317 [ 47318 cropperState, 47319 setCropperState, 47320 resetState, 47321 setResetState, 47322 isDirty, 47323 reset, 47324 getCroppedImage2 47325 ] 47326 ); 47327 } 47328 47329 // packages/image-cropper/build-module/provider/index.js 47330 var import_jsx_runtime299 = __toESM(require_jsx_runtime()); 47331 var ImageCropperContext = (0, import_element156.createContext)({ 47332 cropperState: { 47333 crop: { x: 0, y: 0 }, 47334 croppedArea: { x: 0, y: 0, width: 100, height: 100 }, 47335 croppedAreaPixels: null, 47336 zoom: MIN_ZOOM2, 47337 rotation: 0, 47338 aspectRatio: 1, 47339 flip: { horizontal: false, vertical: false }, 47340 mediaSize: null 47341 }, 47342 setCropperState: () => { 47343 }, 47344 resetState: null, 47345 setResetState: () => { 47346 }, 47347 isDirty: false, 47348 reset: () => { 47349 }, 47350 getCroppedImage: () => Promise.resolve(null) 47351 }); 47352 function ImageCropperProvider({ 47353 children 47354 }) { 47355 const cropperApi = useCropper(); 47356 const contextValue = (0, import_element156.useMemo)(() => { 47357 return { 47358 ...cropperApi 47359 }; 47360 }, [cropperApi]); 47361 return /* @__PURE__ */ (0, import_jsx_runtime299.jsx)(ImageCropperContext.Provider, { value: contextValue, children }); 47362 } 47363 var useImageCropper = () => { 47364 const context = (0, import_element156.useContext)(ImageCropperContext); 47365 if (!context) { 47366 throw new Error("Missing ImageCropperContext"); 47367 } 47368 return context; 47369 }; 47370 47371 // packages/image-cropper/build-module/components/image-cropper/index.js 47372 var import_jsx_runtime300 = __toESM(require_jsx_runtime()); 47373 function ImageCropper({ 47374 src, 47375 onLoad, 47376 minZoom = MIN_ZOOM2, 47377 maxZoom = MAX_ZOOM2, 47378 ...props 47379 }) { 47380 const { cropperState, setCropperState } = useImageCropper(); 47381 const { crop, zoom, rotation, aspectRatio, flip } = cropperState; 47382 const setCrop = (newCrop) => setCropperState({ crop: newCrop }); 47383 const setZoom = (newZoom) => setCropperState({ zoom: newZoom }); 47384 const setRotation = (newRotation) => setCropperState({ rotation: newRotation }); 47385 const setMediaSize = (newMediaSize) => setCropperState({ mediaSize: newMediaSize }); 47386 const onCropComplete = (0, import_element157.useCallback)( 47387 (areaPercentage, areaPixels) => { 47388 setCropperState({ 47389 croppedArea: areaPercentage, 47390 croppedAreaPixels: areaPixels 47391 }); 47392 }, 47393 [setCropperState] 47394 ); 47395 return /* @__PURE__ */ (0, import_jsx_runtime300.jsx)( 47396 Cropper, 47397 { 47398 classes: { 47399 containerClassName: "image-cropper__container", 47400 cropAreaClassName: "image-cropper__crop-area", 47401 mediaClassName: "image-cropper__image" 47402 }, 47403 minZoom, 47404 maxZoom, 47405 rotation, 47406 image: src, 47407 setMediaSize, 47408 crop, 47409 zoom, 47410 aspect: aspectRatio, 47411 onCropChange: setCrop, 47412 onZoomChange: setZoom, 47413 onCropComplete, 47414 onMediaLoaded: (loadedMediaSize) => { 47415 onLoad?.(loadedMediaSize); 47416 }, 47417 onRotationChange: setRotation, 47418 transform: [ 47419 `translate($crop.x}px, $crop.y}px)`, 47420 `rotateZ($rotation}deg)`, 47421 `rotateY($flip.horizontal ? 180 : 0}deg)`, 47422 `rotateX($flip.vertical ? 180 : 0}deg)`, 47423 `scale($zoom})` 47424 ].join(" "), 47425 ...props 47426 } 47427 ); 47428 } 47429 47430 // packages/block-editor/build-module/components/image-editor/aspect-ratio-dropdown.js 47431 var import_components151 = __toESM(require_components()); 47432 var import_i18n141 = __toESM(require_i18n()); 47433 47434 // packages/block-editor/build-module/components/image-editor/constants.js 47435 var MIN_ZOOM3 = 100; 47436 var MAX_ZOOM3 = 300; 47437 var POPOVER_PROPS7 = { 47438 placement: "bottom-start" 47439 }; 47440 47441 // packages/block-editor/build-module/components/image-editor/context.js 47442 var import_element160 = __toESM(require_element()); 47443 47444 // packages/block-editor/build-module/components/image-editor/use-save-image.js 47445 var import_data140 = __toESM(require_data()); 47446 var import_element158 = __toESM(require_element()); 47447 var import_i18n140 = __toESM(require_i18n()); 47448 var import_notices8 = __toESM(require_notices()); 47449 var import_dom32 = __toESM(require_dom()); 47450 var messages = { 47451 crop: (0, import_i18n140.__)("Image cropped."), 47452 rotate: (0, import_i18n140.__)("Image rotated."), 47453 cropAndRotate: (0, import_i18n140.__)("Image cropped and rotated.") 47454 }; 47455 function useSaveImage({ 47456 crop, 47457 rotation, 47458 url, 47459 id, 47460 onSaveImage, 47461 onFinishEditing 47462 }) { 47463 const { createErrorNotice, createSuccessNotice } = (0, import_data140.useDispatch)(import_notices8.store); 47464 const [isInProgress, setIsInProgress] = (0, import_element158.useState)(false); 47465 const { editMediaEntity } = (0, import_data140.useSelect)((select3) => { 47466 const settings2 = select3(store).getSettings(); 47467 return { 47468 editMediaEntity: settings2?.[mediaEditKey] 47469 }; 47470 }, []); 47471 const cancel = (0, import_element158.useCallback)(() => { 47472 setIsInProgress(false); 47473 onFinishEditing(); 47474 }, [onFinishEditing]); 47475 const apply = (0, import_element158.useCallback)(async () => { 47476 if (!editMediaEntity) { 47477 onFinishEditing(); 47478 createErrorNotice( 47479 (0, import_i18n140.__)("Sorry, you are not allowed to edit images on this site."), 47480 { 47481 id: "image-editing-error", 47482 type: "snackbar" 47483 } 47484 ); 47485 return; 47486 } 47487 setIsInProgress(true); 47488 const modifiers = []; 47489 if (rotation > 0) { 47490 modifiers.push({ 47491 type: "rotate", 47492 args: { 47493 angle: rotation 47494 } 47495 }); 47496 } 47497 if (crop.width < 99.9 || crop.height < 99.9) { 47498 modifiers.push({ 47499 type: "crop", 47500 args: { 47501 left: crop.x, 47502 top: crop.y, 47503 width: crop.width, 47504 height: crop.height 47505 } 47506 }); 47507 } 47508 if (modifiers.length === 0) { 47509 setIsInProgress(false); 47510 onFinishEditing(); 47511 return; 47512 } 47513 const modifierType = modifiers.length === 1 ? modifiers[0].type : "cropAndRotate"; 47514 try { 47515 const savedImage = await editMediaEntity( 47516 id, 47517 { 47518 src: url, 47519 modifiers 47520 }, 47521 { throwOnError: true } 47522 ); 47523 if (savedImage) { 47524 onSaveImage({ 47525 id: savedImage.id, 47526 url: savedImage.source_url 47527 }); 47528 createSuccessNotice(messages[modifierType], { 47529 type: "snackbar", 47530 actions: [ 47531 { 47532 label: (0, import_i18n140.__)("Undo"), 47533 onClick: () => { 47534 onSaveImage({ 47535 id, 47536 url 47537 }); 47538 } 47539 } 47540 ] 47541 }); 47542 } 47543 } catch (error) { 47544 createErrorNotice( 47545 (0, import_i18n140.sprintf)( 47546 /* translators: %s: Error message. */ 47547 (0, import_i18n140.__)("Could not edit image. %s"), 47548 (0, import_dom32.__unstableStripHTML)(error.message) 47549 ), 47550 { 47551 id: "image-editing-error", 47552 type: "snackbar" 47553 } 47554 ); 47555 } finally { 47556 setIsInProgress(false); 47557 onFinishEditing(); 47558 } 47559 }, [ 47560 crop, 47561 rotation, 47562 id, 47563 url, 47564 onSaveImage, 47565 createErrorNotice, 47566 createSuccessNotice, 47567 onFinishEditing, 47568 editMediaEntity 47569 ]); 47570 return (0, import_element158.useMemo)( 47571 () => ({ 47572 isInProgress, 47573 apply, 47574 cancel 47575 }), 47576 [isInProgress, apply, cancel] 47577 ); 47578 } 47579 47580 // packages/block-editor/build-module/components/image-editor/use-transform-image.js 47581 var import_element159 = __toESM(require_element()); 47582 var import_hooks6 = __toESM(require_hooks()); 47583 function useTransformImage({ 47584 url, 47585 naturalWidth, 47586 naturalHeight 47587 }) { 47588 const [editedUrl, setEditedUrl] = (0, import_element159.useState)(); 47589 const { cropperState, setCropperState } = useImageCropper(); 47590 const { zoom, aspectRatio, crop, croppedArea } = cropperState; 47591 const setZoom = (0, import_element159.useCallback)( 47592 (newZoom) => { 47593 setCropperState({ zoom: newZoom }); 47594 }, 47595 [setCropperState] 47596 ); 47597 const setAspectRatio = (0, import_element159.useCallback)( 47598 (newAspect) => { 47599 setCropperState({ aspectRatio: newAspect }); 47600 }, 47601 [setCropperState] 47602 ); 47603 const defaultAspect = naturalWidth / naturalHeight; 47604 const rotatedAspect = naturalHeight / naturalWidth; 47605 (0, import_element159.useEffect)(() => { 47606 setAspectRatio(defaultAspect); 47607 }, []); 47608 const [internalRotation, setInternalRotation] = (0, import_element159.useState)(0); 47609 const rotateClockwise = (0, import_element159.useCallback)(() => { 47610 const angle = (internalRotation + 90) % 360; 47611 let naturalAspectRatio = defaultAspect; 47612 const isDefaultAspect = defaultAspect === aspectRatio || rotatedAspect === aspectRatio; 47613 const shouldResetAspect = zoom !== 1 || !isDefaultAspect; 47614 if (internalRotation % 180 === 90) { 47615 naturalAspectRatio = 1 / defaultAspect; 47616 } 47617 if (angle === 0) { 47618 setEditedUrl(); 47619 setInternalRotation(angle); 47620 const newAspectRatio = shouldResetAspect ? aspectRatio : defaultAspect; 47621 setCropperState({ 47622 aspectRatio: newAspectRatio, 47623 crop: { 47624 x: -(crop.y * naturalAspectRatio), 47625 y: crop.x * naturalAspectRatio 47626 } 47627 }); 47628 return; 47629 } 47630 function editImage(event) { 47631 const canvas = document.createElement("canvas"); 47632 let translateX = 0; 47633 let translateY = 0; 47634 if (angle % 180) { 47635 canvas.width = event.target.height; 47636 canvas.height = event.target.width; 47637 } else { 47638 canvas.width = event.target.width; 47639 canvas.height = event.target.height; 47640 } 47641 if (angle === 90 || angle === 180) { 47642 translateX = canvas.width; 47643 } 47644 if (angle === 270 || angle === 180) { 47645 translateY = canvas.height; 47646 } 47647 const context = canvas.getContext("2d"); 47648 context.translate(translateX, translateY); 47649 context.rotate(angle * Math.PI / 180); 47650 context.drawImage(event.target, 0, 0); 47651 canvas.toBlob((blob) => { 47652 setEditedUrl(URL.createObjectURL(blob)); 47653 setInternalRotation(angle); 47654 const newAspectRatio = shouldResetAspect ? aspectRatio : canvas.width / canvas.height; 47655 setCropperState({ 47656 aspectRatio: newAspectRatio, 47657 crop: { 47658 x: -(crop.y * naturalAspectRatio), 47659 y: crop.x * naturalAspectRatio 47660 } 47661 }); 47662 }); 47663 } 47664 const el = new window.Image(); 47665 el.src = url; 47666 el.onload = editImage; 47667 const imgCrossOrigin = (0, import_hooks6.applyFilters)( 47668 "media.crossOrigin", 47669 void 0, 47670 url 47671 ); 47672 if (typeof imgCrossOrigin === "string") { 47673 el.crossOrigin = imgCrossOrigin; 47674 } 47675 }, [ 47676 internalRotation, 47677 defaultAspect, 47678 url, 47679 setCropperState, 47680 crop, 47681 zoom, 47682 aspectRatio, 47683 rotatedAspect, 47684 setInternalRotation 47685 ]); 47686 return (0, import_element159.useMemo)( 47687 () => ({ 47688 editedUrl, 47689 setEditedUrl, 47690 crop: croppedArea, 47691 zoom, 47692 setZoom, 47693 rotation: internalRotation, 47694 rotateClockwise, 47695 aspect: aspectRatio, 47696 setAspect: setAspectRatio, 47697 defaultAspect 47698 }), 47699 [ 47700 editedUrl, 47701 croppedArea, 47702 zoom, 47703 setZoom, 47704 internalRotation, 47705 rotateClockwise, 47706 aspectRatio, 47707 setAspectRatio, 47708 defaultAspect 47709 ] 47710 ); 47711 } 47712 47713 // packages/block-editor/build-module/components/image-editor/context.js 47714 var import_jsx_runtime301 = __toESM(require_jsx_runtime()); 47715 var ImageEditingContext = (0, import_element160.createContext)({}); 47716 ImageEditingContext.displayName = "ImageEditingContext"; 47717 var useImageEditingContext = () => (0, import_element160.useContext)(ImageEditingContext); 47718 function ImageEditingProvider({ 47719 id, 47720 url, 47721 naturalWidth, 47722 naturalHeight, 47723 onFinishEditing, 47724 onSaveImage, 47725 children 47726 }) { 47727 const transformImage = useTransformImage({ 47728 url, 47729 naturalWidth, 47730 naturalHeight 47731 }); 47732 const saveImage = useSaveImage({ 47733 id, 47734 url, 47735 onSaveImage, 47736 onFinishEditing, 47737 ...transformImage 47738 }); 47739 const providerValue = (0, import_element160.useMemo)( 47740 () => ({ 47741 ...transformImage, 47742 ...saveImage 47743 }), 47744 [transformImage, saveImage] 47745 ); 47746 return /* @__PURE__ */ (0, import_jsx_runtime301.jsx)(ImageEditingContext.Provider, { value: providerValue, children }); 47747 } 47748 47749 // packages/block-editor/build-module/components/image-editor/aspect-ratio-dropdown.js 47750 var import_jsx_runtime302 = __toESM(require_jsx_runtime()); 47751 function AspectRatioGroup({ 47752 aspectRatios, 47753 isDisabled, 47754 label, 47755 onClick, 47756 value 47757 }) { 47758 return /* @__PURE__ */ (0, import_jsx_runtime302.jsx)(import_components151.MenuGroup, { label, children: aspectRatios.map(({ name, slug, ratio }) => /* @__PURE__ */ (0, import_jsx_runtime302.jsx)( 47759 import_components151.MenuItem, 47760 { 47761 disabled: isDisabled, 47762 onClick: () => { 47763 onClick(ratio); 47764 }, 47765 role: "menuitemradio", 47766 isSelected: ratio === value, 47767 icon: ratio === value ? check_default : void 0, 47768 children: name 47769 }, 47770 slug 47771 )) }); 47772 } 47773 function ratioToNumber(str) { 47774 const [a2, b2, ...rest] = str.split("/").map(Number); 47775 if (a2 <= 0 || b2 <= 0 || Number.isNaN(a2) || Number.isNaN(b2) || rest.length) { 47776 return NaN; 47777 } 47778 return b2 ? a2 / b2 : a2; 47779 } 47780 function presetRatioAsNumber({ ratio, ...rest }) { 47781 return { 47782 ratio: ratioToNumber(ratio), 47783 ...rest 47784 }; 47785 } 47786 function AspectRatioDropdown({ toggleProps }) { 47787 const { isInProgress, aspect, setAspect, defaultAspect } = useImageEditingContext(); 47788 const [defaultRatios, themeRatios, showDefaultRatios] = useSettings( 47789 "dimensions.aspectRatios.default", 47790 "dimensions.aspectRatios.theme", 47791 "dimensions.defaultAspectRatios" 47792 ); 47793 return /* @__PURE__ */ (0, import_jsx_runtime302.jsx)( 47794 import_components151.DropdownMenu, 47795 { 47796 icon: aspect_ratio_default, 47797 label: (0, import_i18n141.__)("Aspect Ratio"), 47798 popoverProps: POPOVER_PROPS7, 47799 toggleProps, 47800 children: ({ onClose }) => /* @__PURE__ */ (0, import_jsx_runtime302.jsxs)(import_jsx_runtime302.Fragment, { children: [ 47801 /* @__PURE__ */ (0, import_jsx_runtime302.jsx)( 47802 AspectRatioGroup, 47803 { 47804 isDisabled: isInProgress, 47805 onClick: (newAspect) => { 47806 setAspect(newAspect); 47807 onClose(); 47808 }, 47809 value: aspect, 47810 aspectRatios: [ 47811 // All ratios should be mirrored in AspectRatioTool in @wordpress/block-editor. 47812 { 47813 slug: "original", 47814 name: (0, import_i18n141.__)("Original"), 47815 ratio: defaultAspect 47816 }, 47817 ...showDefaultRatios ? defaultRatios.map(presetRatioAsNumber).filter(({ ratio }) => ratio === 1) : [] 47818 ] 47819 } 47820 ), 47821 themeRatios?.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime302.jsx)( 47822 AspectRatioGroup, 47823 { 47824 label: (0, import_i18n141.__)("Theme"), 47825 isDisabled: isInProgress, 47826 onClick: (newAspect) => { 47827 setAspect(newAspect); 47828 onClose(); 47829 }, 47830 value: aspect, 47831 aspectRatios: themeRatios 47832 } 47833 ), 47834 showDefaultRatios && /* @__PURE__ */ (0, import_jsx_runtime302.jsx)( 47835 AspectRatioGroup, 47836 { 47837 label: (0, import_i18n141.__)("Landscape"), 47838 isDisabled: isInProgress, 47839 onClick: (newAspect) => { 47840 setAspect(newAspect); 47841 onClose(); 47842 }, 47843 value: aspect, 47844 aspectRatios: defaultRatios.map(presetRatioAsNumber).filter(({ ratio }) => ratio > 1) 47845 } 47846 ), 47847 showDefaultRatios && /* @__PURE__ */ (0, import_jsx_runtime302.jsx)( 47848 AspectRatioGroup, 47849 { 47850 label: (0, import_i18n141.__)("Portrait"), 47851 isDisabled: isInProgress, 47852 onClick: (newAspect) => { 47853 setAspect(newAspect); 47854 onClose(); 47855 }, 47856 value: aspect, 47857 aspectRatios: defaultRatios.map(presetRatioAsNumber).filter(({ ratio }) => ratio < 1) 47858 } 47859 ) 47860 ] }) 47861 } 47862 ); 47863 } 47864 47865 // packages/block-editor/build-module/components/image-editor/cropper.js 47866 var import_components152 = __toESM(require_components()); 47867 var import_compose79 = __toESM(require_compose()); 47868 var import_jsx_runtime303 = __toESM(require_jsx_runtime()); 47869 function ImageCropper2({ 47870 url, 47871 width, 47872 height, 47873 naturalHeight, 47874 naturalWidth, 47875 borderProps 47876 }) { 47877 const { isInProgress, editedUrl, rotation } = useImageEditingContext(); 47878 const [contentResizeListener, { width: clientWidth }] = (0, import_compose79.useResizeObserver)(); 47879 let editedHeight = height || clientWidth * naturalHeight / naturalWidth; 47880 if (rotation % 180 === 90) { 47881 editedHeight = clientWidth * naturalWidth / naturalHeight; 47882 } 47883 const area = /* @__PURE__ */ (0, import_jsx_runtime303.jsxs)( 47884 "div", 47885 { 47886 className: clsx_default( 47887 "wp-block-image__crop-area", 47888 borderProps?.className, 47889 { 47890 "is-applying": isInProgress 47891 } 47892 ), 47893 style: { 47894 ...borderProps?.style, 47895 width: width || clientWidth, 47896 height: editedHeight 47897 }, 47898 children: [ 47899 /* @__PURE__ */ (0, import_jsx_runtime303.jsx)(ImageCropper, { src: editedUrl || url }), 47900 isInProgress && /* @__PURE__ */ (0, import_jsx_runtime303.jsx)(import_components152.Spinner, {}) 47901 ] 47902 } 47903 ); 47904 return /* @__PURE__ */ (0, import_jsx_runtime303.jsxs)(import_jsx_runtime303.Fragment, { children: [ 47905 contentResizeListener, 47906 area 47907 ] }); 47908 } 47909 47910 // packages/block-editor/build-module/components/image-editor/zoom-dropdown.js 47911 var import_components153 = __toESM(require_components()); 47912 var import_i18n142 = __toESM(require_i18n()); 47913 var import_jsx_runtime304 = __toESM(require_jsx_runtime()); 47914 function ZoomDropdown() { 47915 const { isInProgress, zoom, setZoom } = useImageEditingContext(); 47916 return /* @__PURE__ */ (0, import_jsx_runtime304.jsx)( 47917 import_components153.Dropdown, 47918 { 47919 contentClassName: "wp-block-image__zoom", 47920 popoverProps: POPOVER_PROPS7, 47921 renderToggle: ({ isOpen, onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime304.jsx)( 47922 import_components153.ToolbarButton, 47923 { 47924 icon: search_default, 47925 label: (0, import_i18n142.__)("Zoom"), 47926 onClick: onToggle, 47927 "aria-expanded": isOpen, 47928 disabled: isInProgress 47929 } 47930 ), 47931 renderContent: () => /* @__PURE__ */ (0, import_jsx_runtime304.jsx)(import_components153.__experimentalDropdownContentWrapper, { paddingSize: "medium", children: /* @__PURE__ */ (0, import_jsx_runtime304.jsx)( 47932 import_components153.RangeControl, 47933 { 47934 __next40pxDefaultSize: true, 47935 label: (0, import_i18n142.__)("Zoom"), 47936 min: MIN_ZOOM3, 47937 max: MAX_ZOOM3, 47938 value: Math.round(zoom * 100), 47939 onChange: (newZoom) => setZoom(newZoom / 100) 47940 } 47941 ) }) 47942 } 47943 ); 47944 } 47945 47946 // packages/block-editor/build-module/components/image-editor/rotation-button.js 47947 var import_components154 = __toESM(require_components()); 47948 var import_i18n143 = __toESM(require_i18n()); 47949 var import_jsx_runtime305 = __toESM(require_jsx_runtime()); 47950 function RotationButton() { 47951 const { isInProgress, rotateClockwise } = useImageEditingContext(); 47952 return /* @__PURE__ */ (0, import_jsx_runtime305.jsx)( 47953 import_components154.ToolbarButton, 47954 { 47955 icon: rotate_right_default, 47956 label: (0, import_i18n143.__)("Rotate"), 47957 onClick: rotateClockwise, 47958 disabled: isInProgress 47959 } 47960 ); 47961 } 47962 47963 // packages/block-editor/build-module/components/image-editor/form-controls.js 47964 var import_components155 = __toESM(require_components()); 47965 var import_i18n144 = __toESM(require_i18n()); 47966 var import_jsx_runtime306 = __toESM(require_jsx_runtime()); 47967 function FormControls() { 47968 const { isInProgress, apply, cancel } = useImageEditingContext(); 47969 return /* @__PURE__ */ (0, import_jsx_runtime306.jsxs)(import_jsx_runtime306.Fragment, { children: [ 47970 /* @__PURE__ */ (0, import_jsx_runtime306.jsx)(import_components155.ToolbarButton, { onClick: apply, disabled: isInProgress, children: (0, import_i18n144.__)("Apply") }), 47971 /* @__PURE__ */ (0, import_jsx_runtime306.jsx)(import_components155.ToolbarButton, { onClick: cancel, children: (0, import_i18n144.__)("Cancel") }) 47972 ] }); 47973 } 47974 47975 // packages/block-editor/build-module/components/image-editor/index.js 47976 var import_jsx_runtime307 = __toESM(require_jsx_runtime()); 47977 function ImageEditor({ 47978 id, 47979 url, 47980 width, 47981 height, 47982 naturalHeight, 47983 naturalWidth, 47984 onSaveImage, 47985 onFinishEditing, 47986 borderProps 47987 }) { 47988 return /* @__PURE__ */ (0, import_jsx_runtime307.jsx)(ImageCropperProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime307.jsxs)( 47989 ImageEditingProvider, 47990 { 47991 id, 47992 url, 47993 naturalWidth, 47994 naturalHeight, 47995 onSaveImage, 47996 onFinishEditing, 47997 children: [ 47998 /* @__PURE__ */ (0, import_jsx_runtime307.jsx)( 47999 ImageCropper2, 48000 { 48001 borderProps, 48002 url, 48003 width, 48004 height, 48005 naturalHeight, 48006 naturalWidth 48007 } 48008 ), 48009 /* @__PURE__ */ (0, import_jsx_runtime307.jsxs)(block_controls_default, { children: [ 48010 /* @__PURE__ */ (0, import_jsx_runtime307.jsxs)(import_components156.ToolbarGroup, { children: [ 48011 /* @__PURE__ */ (0, import_jsx_runtime307.jsx)(ZoomDropdown, {}), 48012 /* @__PURE__ */ (0, import_jsx_runtime307.jsx)(import_components156.ToolbarItem, { children: (toggleProps) => /* @__PURE__ */ (0, import_jsx_runtime307.jsx)( 48013 AspectRatioDropdown, 48014 { 48015 toggleProps 48016 } 48017 ) }), 48018 /* @__PURE__ */ (0, import_jsx_runtime307.jsx)(RotationButton, {}) 48019 ] }), 48020 /* @__PURE__ */ (0, import_jsx_runtime307.jsx)(import_components156.ToolbarGroup, { children: /* @__PURE__ */ (0, import_jsx_runtime307.jsx)(FormControls, {}) }) 48021 ] }) 48022 ] 48023 } 48024 ) }); 48025 } 48026 48027 // packages/block-editor/build-module/components/image-size-control/index.js 48028 var import_components157 = __toESM(require_components()); 48029 var import_i18n145 = __toESM(require_i18n()); 48030 48031 // packages/block-editor/build-module/components/image-size-control/use-dimension-handler.js 48032 var import_element161 = __toESM(require_element()); 48033 function useDimensionHandler(customHeight, customWidth, defaultHeight, defaultWidth, onChange) { 48034 const [currentWidth, setCurrentWidth] = (0, import_element161.useState)( 48035 customWidth ?? defaultWidth ?? "" 48036 ); 48037 const [currentHeight, setCurrentHeight] = (0, import_element161.useState)( 48038 customHeight ?? defaultHeight ?? "" 48039 ); 48040 (0, import_element161.useEffect)(() => { 48041 if (customWidth === void 0 && defaultWidth !== void 0) { 48042 setCurrentWidth(defaultWidth); 48043 } 48044 if (customHeight === void 0 && defaultHeight !== void 0) { 48045 setCurrentHeight(defaultHeight); 48046 } 48047 }, [defaultWidth, defaultHeight]); 48048 (0, import_element161.useEffect)(() => { 48049 if (customWidth !== void 0 && Number.parseInt(customWidth) !== Number.parseInt(currentWidth)) { 48050 setCurrentWidth(customWidth); 48051 } 48052 if (customHeight !== void 0 && Number.parseInt(customHeight) !== Number.parseInt(currentHeight)) { 48053 setCurrentHeight(customHeight); 48054 } 48055 }, [customWidth, customHeight]); 48056 const updateDimension = (dimension, value) => { 48057 const parsedValue = value === "" ? void 0 : parseInt(value, 10); 48058 if (dimension === "width") { 48059 setCurrentWidth(parsedValue); 48060 } else { 48061 setCurrentHeight(parsedValue); 48062 } 48063 onChange({ 48064 [dimension]: parsedValue 48065 }); 48066 }; 48067 const updateDimensions = (nextHeight, nextWidth) => { 48068 setCurrentHeight(nextHeight ?? defaultHeight); 48069 setCurrentWidth(nextWidth ?? defaultWidth); 48070 onChange({ height: nextHeight, width: nextWidth }); 48071 }; 48072 return { 48073 currentHeight, 48074 currentWidth, 48075 updateDimension, 48076 updateDimensions 48077 }; 48078 } 48079 48080 // packages/block-editor/build-module/components/image-size-control/index.js 48081 var import_jsx_runtime308 = __toESM(require_jsx_runtime()); 48082 var IMAGE_SIZE_PRESETS = [25, 50, 75, 100]; 48083 var noop12 = () => { 48084 }; 48085 function getScaledWidthAndHeight(scale, imageWidth, imageHeight) { 48086 const scaledWidth = Math.round(imageWidth * (scale / 100)); 48087 const scaledHeight = Math.round(imageHeight * (scale / 100)); 48088 return { 48089 scaledWidth, 48090 scaledHeight 48091 }; 48092 } 48093 function ImageSizeControl({ 48094 imageSizeHelp, 48095 imageWidth, 48096 imageHeight, 48097 imageSizeOptions = [], 48098 isResizable = true, 48099 slug, 48100 width, 48101 height, 48102 onChange, 48103 onChangeImage = noop12 48104 }) { 48105 const { currentHeight, currentWidth, updateDimension, updateDimensions } = useDimensionHandler(height, width, imageHeight, imageWidth, onChange); 48106 const handleUpdateDimensions = (scale) => { 48107 if (void 0 === scale) { 48108 updateDimensions(); 48109 return; 48110 } 48111 const { scaledWidth, scaledHeight } = getScaledWidthAndHeight( 48112 scale, 48113 imageWidth, 48114 imageHeight 48115 ); 48116 updateDimensions(scaledHeight, scaledWidth); 48117 }; 48118 const selectedValue = IMAGE_SIZE_PRESETS.find((scale) => { 48119 const { scaledWidth, scaledHeight } = getScaledWidthAndHeight( 48120 scale, 48121 imageWidth, 48122 imageHeight 48123 ); 48124 return currentWidth === scaledWidth && currentHeight === scaledHeight; 48125 }); 48126 return /* @__PURE__ */ (0, import_jsx_runtime308.jsxs)(import_components157.__experimentalVStack, { className: "block-editor-image-size-control", spacing: "4", children: [ 48127 imageSizeOptions && imageSizeOptions.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime308.jsx)( 48128 import_components157.SelectControl, 48129 { 48130 label: (0, import_i18n145.__)("Resolution"), 48131 value: slug, 48132 options: imageSizeOptions, 48133 onChange: onChangeImage, 48134 help: imageSizeHelp, 48135 size: "__unstable-large" 48136 } 48137 ), 48138 isResizable && /* @__PURE__ */ (0, import_jsx_runtime308.jsxs)(import_jsx_runtime308.Fragment, { children: [ 48139 /* @__PURE__ */ (0, import_jsx_runtime308.jsxs)(import_components157.__experimentalHStack, { align: "baseline", spacing: "4", children: [ 48140 /* @__PURE__ */ (0, import_jsx_runtime308.jsx)( 48141 import_components157.__experimentalNumberControl, 48142 { 48143 label: (0, import_i18n145.__)("Width"), 48144 value: currentWidth, 48145 min: 1, 48146 onChange: (value) => updateDimension("width", value), 48147 size: "__unstable-large" 48148 } 48149 ), 48150 /* @__PURE__ */ (0, import_jsx_runtime308.jsx)( 48151 import_components157.__experimentalNumberControl, 48152 { 48153 label: (0, import_i18n145.__)("Height"), 48154 value: currentHeight, 48155 min: 1, 48156 onChange: (value) => updateDimension("height", value), 48157 size: "__unstable-large" 48158 } 48159 ) 48160 ] }), 48161 /* @__PURE__ */ (0, import_jsx_runtime308.jsx)( 48162 import_components157.__experimentalToggleGroupControl, 48163 { 48164 label: (0, import_i18n145.__)("Image size presets"), 48165 hideLabelFromVision: true, 48166 onChange: handleUpdateDimensions, 48167 value: selectedValue, 48168 isBlock: true, 48169 __next40pxDefaultSize: true, 48170 children: IMAGE_SIZE_PRESETS.map((scale) => { 48171 return /* @__PURE__ */ (0, import_jsx_runtime308.jsx)( 48172 import_components157.__experimentalToggleGroupControlOption, 48173 { 48174 value: scale, 48175 label: (0, import_i18n145.sprintf)( 48176 /* translators: %d: Percentage value. */ 48177 (0, import_i18n145.__)("%d%%"), 48178 scale 48179 ) 48180 }, 48181 scale 48182 ); 48183 }) 48184 } 48185 ) 48186 ] }) 48187 ] }); 48188 } 48189 48190 // packages/block-editor/build-module/components/justify-content-control/ui.js 48191 var import_components158 = __toESM(require_components()); 48192 var import_i18n146 = __toESM(require_i18n()); 48193 var import_jsx_runtime309 = __toESM(require_jsx_runtime()); 48194 var icons = { 48195 left: justify_left_default, 48196 center: justify_center_default, 48197 right: justify_right_default, 48198 "space-between": justify_space_between_default, 48199 stretch: justify_stretch_default 48200 }; 48201 function JustifyContentUI({ 48202 allowedControls = ["left", "center", "right", "space-between"], 48203 isCollapsed: isCollapsed3 = true, 48204 onChange, 48205 value, 48206 popoverProps: popoverProps3, 48207 isToolbar 48208 }) { 48209 const handleClick = (next) => { 48210 if (next === value) { 48211 onChange(void 0); 48212 } else { 48213 onChange(next); 48214 } 48215 }; 48216 const icon = value ? icons[value] : icons.left; 48217 const allControls = [ 48218 { 48219 name: "left", 48220 icon: justify_left_default, 48221 title: (0, import_i18n146.__)("Justify items left"), 48222 isActive: "left" === value, 48223 onClick: () => handleClick("left") 48224 }, 48225 { 48226 name: "center", 48227 icon: justify_center_default, 48228 title: (0, import_i18n146.__)("Justify items center"), 48229 isActive: "center" === value, 48230 onClick: () => handleClick("center") 48231 }, 48232 { 48233 name: "right", 48234 icon: justify_right_default, 48235 title: (0, import_i18n146.__)("Justify items right"), 48236 isActive: "right" === value, 48237 onClick: () => handleClick("right") 48238 }, 48239 { 48240 name: "space-between", 48241 icon: justify_space_between_default, 48242 title: (0, import_i18n146.__)("Space between items"), 48243 isActive: "space-between" === value, 48244 onClick: () => handleClick("space-between") 48245 }, 48246 { 48247 name: "stretch", 48248 icon: justify_stretch_default, 48249 title: (0, import_i18n146.__)("Stretch items"), 48250 isActive: "stretch" === value, 48251 onClick: () => handleClick("stretch") 48252 } 48253 ]; 48254 const UIComponent = isToolbar ? import_components158.ToolbarGroup : import_components158.ToolbarDropdownMenu; 48255 const extraProps = isToolbar ? { isCollapsed: isCollapsed3 } : {}; 48256 return /* @__PURE__ */ (0, import_jsx_runtime309.jsx)( 48257 UIComponent, 48258 { 48259 icon, 48260 popoverProps: popoverProps3, 48261 label: (0, import_i18n146.__)("Change items justification"), 48262 controls: allControls.filter( 48263 (elem) => allowedControls.includes(elem.name) 48264 ), 48265 ...extraProps 48266 } 48267 ); 48268 } 48269 var ui_default4 = JustifyContentUI; 48270 48271 // packages/block-editor/build-module/components/justify-content-control/index.js 48272 var import_jsx_runtime310 = __toESM(require_jsx_runtime()); 48273 var JustifyContentControl = (props) => { 48274 return /* @__PURE__ */ (0, import_jsx_runtime310.jsx)(ui_default4, { ...props, isToolbar: false }); 48275 }; 48276 var JustifyToolbar = (props) => { 48277 return /* @__PURE__ */ (0, import_jsx_runtime310.jsx)(ui_default4, { ...props, isToolbar: true }); 48278 }; 48279 48280 // packages/block-editor/build-module/components/link-control/index.js 48281 var import_components166 = __toESM(require_components()); 48282 var import_i18n156 = __toESM(require_i18n()); 48283 var import_element169 = __toESM(require_element()); 48284 var import_compose83 = __toESM(require_compose()); 48285 var import_dom35 = __toESM(require_dom()); 48286 var import_keycodes16 = __toESM(require_keycodes()); 48287 var import_is_shallow_equal3 = __toESM(require_is_shallow_equal()); 48288 var import_data144 = __toESM(require_data()); 48289 var import_preferences4 = __toESM(require_preferences()); 48290 var import_deprecated23 = __toESM(require_deprecated()); 48291 48292 // packages/block-editor/build-module/components/link-control/settings-drawer.js 48293 var import_components159 = __toESM(require_components()); 48294 var import_compose80 = __toESM(require_compose()); 48295 var import_i18n147 = __toESM(require_i18n()); 48296 var import_element162 = __toESM(require_element()); 48297 var import_jsx_runtime311 = __toESM(require_jsx_runtime()); 48298 function LinkSettingsDrawer({ children, settingsOpen, setSettingsOpen }) { 48299 const prefersReducedMotion = (0, import_compose80.useReducedMotion)(); 48300 const MaybeAnimatePresence = prefersReducedMotion ? import_element162.Fragment : import_components159.__unstableAnimatePresence; 48301 const MaybeMotionDiv = prefersReducedMotion ? "div" : import_components159.__unstableMotion.div; 48302 const id = (0, import_compose80.useInstanceId)(LinkSettingsDrawer); 48303 const settingsDrawerId = `link-control-settings-drawer-$id}`; 48304 return /* @__PURE__ */ (0, import_jsx_runtime311.jsxs)(import_jsx_runtime311.Fragment, { children: [ 48305 /* @__PURE__ */ (0, import_jsx_runtime311.jsx)( 48306 import_components159.Button, 48307 { 48308 __next40pxDefaultSize: true, 48309 className: "block-editor-link-control__drawer-toggle", 48310 "aria-expanded": settingsOpen, 48311 onClick: () => setSettingsOpen(!settingsOpen), 48312 icon: (0, import_i18n147.isRTL)() ? chevron_left_small_default : chevron_right_small_default, 48313 "aria-controls": settingsDrawerId, 48314 children: (0, import_i18n147._x)("Advanced", "Additional link settings") 48315 } 48316 ), 48317 /* @__PURE__ */ (0, import_jsx_runtime311.jsx)(MaybeAnimatePresence, { children: settingsOpen && /* @__PURE__ */ (0, import_jsx_runtime311.jsx)( 48318 MaybeMotionDiv, 48319 { 48320 className: "block-editor-link-control__drawer", 48321 hidden: !settingsOpen, 48322 id: settingsDrawerId, 48323 initial: "collapsed", 48324 animate: "open", 48325 exit: "collapsed", 48326 variants: { 48327 open: { opacity: 1, height: "auto" }, 48328 collapsed: { opacity: 0, height: 0 } 48329 }, 48330 transition: { 48331 duration: 0.1 48332 }, 48333 children: /* @__PURE__ */ (0, import_jsx_runtime311.jsx)("div", { className: "block-editor-link-control__drawer-inner", children }) 48334 } 48335 ) }) 48336 ] }); 48337 } 48338 var settings_drawer_default = LinkSettingsDrawer; 48339 48340 // packages/block-editor/build-module/components/link-control/search-input.js 48341 var import_element165 = __toESM(require_element()); 48342 var import_i18n152 = __toESM(require_i18n()); 48343 var import_deprecated22 = __toESM(require_deprecated()); 48344 48345 // packages/block-editor/build-module/components/link-control/search-results.js 48346 var import_i18n151 = __toESM(require_i18n()); 48347 var import_components162 = __toESM(require_components()); 48348 48349 // packages/block-editor/build-module/components/link-control/search-create-button.js 48350 var import_i18n148 = __toESM(require_i18n()); 48351 var import_components160 = __toESM(require_components()); 48352 var import_element163 = __toESM(require_element()); 48353 var import_jsx_runtime312 = __toESM(require_jsx_runtime()); 48354 var LinkControlSearchCreate = ({ 48355 searchTerm, 48356 onClick, 48357 itemProps, 48358 buttonText 48359 }) => { 48360 if (!searchTerm) { 48361 return null; 48362 } 48363 let text; 48364 if (buttonText) { 48365 text = typeof buttonText === "function" ? buttonText(searchTerm) : buttonText; 48366 } else { 48367 text = (0, import_element163.createInterpolateElement)( 48368 (0, import_i18n148.sprintf)( 48369 /* translators: %s: search term. */ 48370 (0, import_i18n148.__)("Create: <mark>%s</mark>"), 48371 searchTerm 48372 ), 48373 { mark: /* @__PURE__ */ (0, import_jsx_runtime312.jsx)("mark", {}) } 48374 ); 48375 } 48376 return /* @__PURE__ */ (0, import_jsx_runtime312.jsx)( 48377 import_components160.MenuItem, 48378 { 48379 ...itemProps, 48380 iconPosition: "left", 48381 icon: plus_default, 48382 className: "block-editor-link-control__search-item", 48383 onClick, 48384 children: text 48385 } 48386 ); 48387 }; 48388 var search_create_button_default = LinkControlSearchCreate; 48389 48390 // packages/block-editor/build-module/components/link-control/search-item.js 48391 var import_i18n149 = __toESM(require_i18n()); 48392 var import_components161 = __toESM(require_components()); 48393 var import_dom33 = __toESM(require_dom()); 48394 var import_url5 = __toESM(require_url()); 48395 var import_compose81 = __toESM(require_compose()); 48396 var import_deprecated20 = __toESM(require_deprecated()); 48397 var import_jsx_runtime313 = __toESM(require_jsx_runtime()); 48398 var TYPES = { 48399 post: { 48400 icon: post_list_default, 48401 label: (0, import_i18n149.__)("Post") 48402 }, 48403 page: { 48404 icon: page_default, 48405 label: (0, import_i18n149.__)("Page") 48406 }, 48407 post_tag: { 48408 icon: tag_default, 48409 label: (0, import_i18n149.__)("Tag") 48410 }, 48411 category: { 48412 icon: category_default, 48413 label: (0, import_i18n149.__)("Category") 48414 }, 48415 attachment: { 48416 icon: file_default, 48417 label: (0, import_i18n149.__)("Attachment") 48418 } 48419 }; 48420 function SearchItemIcon({ isURL: isURL3, suggestion }) { 48421 let icon = null; 48422 if (isURL3) { 48423 icon = globe_default; 48424 } else if (suggestion.type in TYPES) { 48425 icon = TYPES[suggestion.type].icon; 48426 if (suggestion.type === "page") { 48427 if (suggestion.isFrontPage) { 48428 icon = home_default; 48429 } 48430 if (suggestion.isBlogHome) { 48431 icon = verse_default; 48432 } 48433 } 48434 } 48435 if (icon) { 48436 return /* @__PURE__ */ (0, import_jsx_runtime313.jsx)( 48437 icon_default, 48438 { 48439 className: "block-editor-link-control__search-item-icon", 48440 icon 48441 } 48442 ); 48443 } 48444 return null; 48445 } 48446 function addLeadingSlash(url) { 48447 const trimmedURL = url?.trim(); 48448 if (!trimmedURL?.length) { 48449 return url; 48450 } 48451 return url?.replace(/^\/?/, "/"); 48452 } 48453 function removeTrailingSlash(url) { 48454 const trimmedURL = url?.trim(); 48455 if (!trimmedURL?.length) { 48456 return url; 48457 } 48458 return url?.replace(/\/$/, ""); 48459 } 48460 var partialRight = (fn, ...partialArgs) => (...args) => fn(...args, ...partialArgs); 48461 var defaultTo = (d2) => (v2) => { 48462 return v2 === null || v2 === void 0 || v2 !== v2 ? d2 : v2; 48463 }; 48464 function getURLForDisplay(url) { 48465 if (!url) { 48466 return url; 48467 } 48468 return (0, import_compose81.pipe)( 48469 import_url5.safeDecodeURI, 48470 import_url5.getPath, 48471 defaultTo(""), 48472 partialRight(import_url5.filterURLForDisplay, 24), 48473 removeTrailingSlash, 48474 addLeadingSlash 48475 )(url); 48476 } 48477 var LinkControlSearchItem = ({ 48478 itemProps, 48479 suggestion, 48480 searchTerm, 48481 onClick, 48482 isURL: isURL3 = false, 48483 shouldShowType = false 48484 }) => { 48485 const info = isURL3 ? (0, import_i18n149.__)("Press ENTER to add this link") : getURLForDisplay(suggestion.url); 48486 return /* @__PURE__ */ (0, import_jsx_runtime313.jsx)( 48487 import_components161.MenuItem, 48488 { 48489 ...itemProps, 48490 info, 48491 iconPosition: "left", 48492 icon: /* @__PURE__ */ (0, import_jsx_runtime313.jsx)(SearchItemIcon, { suggestion, isURL: isURL3 }), 48493 onClick, 48494 shortcut: shouldShowType && getVisualTypeName(suggestion), 48495 className: "block-editor-link-control__search-item", 48496 children: /* @__PURE__ */ (0, import_jsx_runtime313.jsx)( 48497 import_components161.TextHighlight, 48498 { 48499 text: (0, import_dom33.__unstableStripHTML)(suggestion.title), 48500 highlight: searchTerm 48501 } 48502 ) 48503 } 48504 ); 48505 }; 48506 function getVisualTypeName(suggestion) { 48507 if (suggestion.isFrontPage) { 48508 return (0, import_i18n149.__)("Front page"); 48509 } 48510 if (suggestion.isBlogHome) { 48511 return (0, import_i18n149.__)("Blog home"); 48512 } 48513 if (suggestion.type in TYPES) { 48514 return TYPES[suggestion.type].label; 48515 } 48516 return suggestion.type; 48517 } 48518 var search_item_default = LinkControlSearchItem; 48519 var __experimentalLinkControlSearchItem = (props) => { 48520 (0, import_deprecated20.default)("wp.blockEditor.__experimentalLinkControlSearchItem", { 48521 since: "6.8" 48522 }); 48523 return /* @__PURE__ */ (0, import_jsx_runtime313.jsx)(LinkControlSearchItem, { ...props }); 48524 }; 48525 48526 // packages/block-editor/build-module/components/link-control/constants.js 48527 var import_i18n150 = __toESM(require_i18n()); 48528 var CREATE_TYPE = "__CREATE__"; 48529 var TEL_TYPE = "tel"; 48530 var URL_TYPE = "link"; 48531 var MAILTO_TYPE = "mailto"; 48532 var INTERNAL_TYPE = "internal"; 48533 var LINK_ENTRY_TYPES = [ 48534 URL_TYPE, 48535 MAILTO_TYPE, 48536 TEL_TYPE, 48537 INTERNAL_TYPE 48538 ]; 48539 var DEFAULT_LINK_SETTINGS = [ 48540 { 48541 id: "opensInNewTab", 48542 title: (0, import_i18n150.__)("Open in new tab") 48543 } 48544 ]; 48545 48546 // packages/block-editor/build-module/components/link-control/search-results.js 48547 var import_deprecated21 = __toESM(require_deprecated()); 48548 var import_jsx_runtime314 = __toESM(require_jsx_runtime()); 48549 function LinkControlSearchResults({ 48550 withCreateSuggestion, 48551 currentInputValue, 48552 handleSuggestionClick, 48553 suggestionsListProps, 48554 buildSuggestionItemProps, 48555 suggestions, 48556 selectedSuggestion, 48557 isLoading, 48558 isInitialSuggestions, 48559 createSuggestionButtonText, 48560 suggestionsQuery 48561 }) { 48562 const resultsListClasses = clsx_default( 48563 "block-editor-link-control__search-results", 48564 { 48565 "is-loading": isLoading 48566 } 48567 ); 48568 const isSingleDirectEntryResult = suggestions.length === 1 && LINK_ENTRY_TYPES.includes(suggestions[0].type); 48569 const shouldShowCreateSuggestion = withCreateSuggestion && !isSingleDirectEntryResult && !isInitialSuggestions; 48570 const shouldShowSuggestionsTypes = !suggestionsQuery?.type; 48571 const labelText = isInitialSuggestions ? (0, import_i18n151.__)("Suggestions") : (0, import_i18n151.sprintf)( 48572 /* translators: %s: search term. */ 48573 (0, import_i18n151.__)('Search results for "%s"'), 48574 currentInputValue 48575 ); 48576 return /* @__PURE__ */ (0, import_jsx_runtime314.jsx)("div", { className: "block-editor-link-control__search-results-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime314.jsx)( 48577 "div", 48578 { 48579 ...suggestionsListProps, 48580 className: resultsListClasses, 48581 "aria-label": labelText, 48582 children: /* @__PURE__ */ (0, import_jsx_runtime314.jsx)(import_components162.MenuGroup, { children: suggestions.map((suggestion, index) => { 48583 if (shouldShowCreateSuggestion && CREATE_TYPE === suggestion.type) { 48584 return /* @__PURE__ */ (0, import_jsx_runtime314.jsx)( 48585 search_create_button_default, 48586 { 48587 searchTerm: currentInputValue, 48588 buttonText: createSuggestionButtonText, 48589 onClick: () => handleSuggestionClick(suggestion), 48590 itemProps: buildSuggestionItemProps( 48591 suggestion, 48592 index 48593 ), 48594 isSelected: index === selectedSuggestion 48595 }, 48596 suggestion.type 48597 ); 48598 } 48599 if (CREATE_TYPE === suggestion.type) { 48600 return null; 48601 } 48602 return /* @__PURE__ */ (0, import_jsx_runtime314.jsx)( 48603 search_item_default, 48604 { 48605 itemProps: buildSuggestionItemProps( 48606 suggestion, 48607 index 48608 ), 48609 suggestion, 48610 index, 48611 onClick: () => { 48612 handleSuggestionClick(suggestion); 48613 }, 48614 isSelected: index === selectedSuggestion, 48615 isURL: LINK_ENTRY_TYPES.includes( 48616 suggestion.type 48617 ), 48618 searchTerm: currentInputValue, 48619 shouldShowType: shouldShowSuggestionsTypes, 48620 isFrontPage: suggestion?.isFrontPage, 48621 isBlogHome: suggestion?.isBlogHome 48622 }, 48623 `$suggestion.id}-$suggestion.type}` 48624 ); 48625 }) }) 48626 } 48627 ) }); 48628 } 48629 var search_results_default2 = LinkControlSearchResults; 48630 var __experimentalLinkControlSearchResults = (props) => { 48631 (0, import_deprecated21.default)("wp.blockEditor.__experimentalLinkControlSearchResults", { 48632 since: "6.8" 48633 }); 48634 return /* @__PURE__ */ (0, import_jsx_runtime314.jsx)(LinkControlSearchResults, { ...props }); 48635 }; 48636 48637 // packages/block-editor/build-module/components/link-control/use-search-handler.js 48638 var import_url6 = __toESM(require_url()); 48639 var import_element164 = __toESM(require_element()); 48640 var import_data141 = __toESM(require_data()); 48641 var handleNoop = () => Promise.resolve([]); 48642 var handleDirectEntry = (val) => { 48643 let type = URL_TYPE; 48644 const protocol = (0, import_url6.getProtocol)(val) || ""; 48645 if (protocol.includes("mailto")) { 48646 type = MAILTO_TYPE; 48647 } 48648 if (protocol.includes("tel")) { 48649 type = TEL_TYPE; 48650 } 48651 if (val?.startsWith("#")) { 48652 type = INTERNAL_TYPE; 48653 } 48654 return Promise.resolve([ 48655 { 48656 id: val, 48657 title: val, 48658 url: type === "URL" ? (0, import_url6.prependHTTP)(val) : val, 48659 type 48660 } 48661 ]); 48662 }; 48663 var handleEntitySearch = async (val, suggestionsQuery, fetchSearchSuggestions, withCreateSuggestion, pageOnFront, pageForPosts) => { 48664 const { isInitialSuggestions } = suggestionsQuery; 48665 const results = await fetchSearchSuggestions(val, suggestionsQuery); 48666 results.map((result) => { 48667 if (Number(result.id) === pageOnFront) { 48668 result.isFrontPage = true; 48669 return result; 48670 } else if (Number(result.id) === pageForPosts) { 48671 result.isBlogHome = true; 48672 return result; 48673 } 48674 return result; 48675 }); 48676 if (isInitialSuggestions) { 48677 return results; 48678 } 48679 return isURLLike(val) || !withCreateSuggestion ? results : results.concat({ 48680 // the `id` prop is intentionally omitted here because it 48681 // is never exposed as part of the component's public API. 48682 // see: https://github.com/WordPress/gutenberg/pull/19775#discussion_r378931316. 48683 title: val, 48684 // Must match the existing `<input>`s text value. 48685 url: val, 48686 // Must match the existing `<input>`s text value. 48687 type: CREATE_TYPE 48688 }); 48689 }; 48690 function useSearchHandler(suggestionsQuery, allowDirectEntry, withCreateSuggestion) { 48691 const { fetchSearchSuggestions, pageOnFront, pageForPosts } = (0, import_data141.useSelect)( 48692 (select3) => { 48693 const { getSettings: getSettings8 } = select3(store); 48694 return { 48695 pageOnFront: getSettings8().pageOnFront, 48696 pageForPosts: getSettings8().pageForPosts, 48697 fetchSearchSuggestions: getSettings8().__experimentalFetchLinkSuggestions 48698 }; 48699 }, 48700 [] 48701 ); 48702 const directEntryHandler = allowDirectEntry ? handleDirectEntry : handleNoop; 48703 return (0, import_element164.useCallback)( 48704 (val, { isInitialSuggestions }) => { 48705 return isURLLike(val) ? directEntryHandler(val, { isInitialSuggestions }) : handleEntitySearch( 48706 val, 48707 { ...suggestionsQuery, isInitialSuggestions }, 48708 fetchSearchSuggestions, 48709 withCreateSuggestion, 48710 pageOnFront, 48711 pageForPosts 48712 ); 48713 }, 48714 [ 48715 directEntryHandler, 48716 fetchSearchSuggestions, 48717 pageOnFront, 48718 pageForPosts, 48719 suggestionsQuery, 48720 withCreateSuggestion 48721 ] 48722 ); 48723 } 48724 48725 // packages/block-editor/build-module/components/link-control/search-input.js 48726 var import_jsx_runtime315 = __toESM(require_jsx_runtime()); 48727 var noopSearchHandler = () => Promise.resolve([]); 48728 var noop13 = () => { 48729 }; 48730 var LinkControlSearchInput = (0, import_element165.forwardRef)( 48731 ({ 48732 value, 48733 children, 48734 currentLink = {}, 48735 className = null, 48736 placeholder = null, 48737 withCreateSuggestion = false, 48738 onCreateSuggestion = noop13, 48739 onChange = noop13, 48740 onSelect = noop13, 48741 showSuggestions = true, 48742 renderSuggestions = (props) => /* @__PURE__ */ (0, import_jsx_runtime315.jsx)(search_results_default2, { ...props }), 48743 fetchSuggestions = null, 48744 allowDirectEntry = true, 48745 showInitialSuggestions = false, 48746 suggestionsQuery = {}, 48747 withURLSuggestion = true, 48748 createSuggestionButtonText, 48749 hideLabelFromVision = false, 48750 suffix, 48751 isEntity = false 48752 }, ref) => { 48753 const genericSearchHandler = useSearchHandler( 48754 suggestionsQuery, 48755 allowDirectEntry, 48756 withCreateSuggestion, 48757 withURLSuggestion 48758 ); 48759 const searchHandler = showSuggestions ? fetchSuggestions || genericSearchHandler : noopSearchHandler; 48760 const [focusedSuggestion, setFocusedSuggestion] = (0, import_element165.useState)(); 48761 const onInputChange = (selection2, suggestion) => { 48762 onChange(selection2); 48763 setFocusedSuggestion(suggestion); 48764 }; 48765 const handleRenderSuggestions = (props) => renderSuggestions({ 48766 ...props, 48767 withCreateSuggestion, 48768 createSuggestionButtonText, 48769 suggestionsQuery, 48770 handleSuggestionClick: (suggestion) => { 48771 if (props.handleSuggestionClick) { 48772 props.handleSuggestionClick(suggestion); 48773 } 48774 onSuggestionSelected(suggestion); 48775 } 48776 }); 48777 const onSuggestionSelected = async (selectedSuggestion) => { 48778 let suggestion = selectedSuggestion; 48779 if (CREATE_TYPE === selectedSuggestion.type) { 48780 try { 48781 suggestion = await onCreateSuggestion( 48782 selectedSuggestion.title 48783 ); 48784 if (suggestion?.url) { 48785 onSelect(suggestion); 48786 } 48787 } catch (e2) { 48788 } 48789 return; 48790 } 48791 if (allowDirectEntry || suggestion && Object.keys(suggestion).length >= 1) { 48792 const { id, url, kind, type, ...restLinkProps } = currentLink ?? {}; 48793 onSelect( 48794 // Some direct entries don't have types or IDs, and we still need to clear the previous ones. 48795 { ...restLinkProps, ...suggestion }, 48796 suggestion 48797 ); 48798 } 48799 }; 48800 const _placeholder = placeholder ?? (0, import_i18n152.__)("Search or type URL"); 48801 const label = hideLabelFromVision && placeholder !== "" ? _placeholder : (0, import_i18n152.__)("Link"); 48802 return /* @__PURE__ */ (0, import_jsx_runtime315.jsxs)("div", { className: "block-editor-link-control__search-input-container", children: [ 48803 /* @__PURE__ */ (0, import_jsx_runtime315.jsx)( 48804 url_input_default, 48805 { 48806 disableSuggestions: currentLink?.url === value, 48807 label, 48808 hideLabelFromVision, 48809 className, 48810 value, 48811 onChange: onInputChange, 48812 placeholder: _placeholder, 48813 __experimentalRenderSuggestions: showSuggestions ? handleRenderSuggestions : null, 48814 __experimentalFetchLinkSuggestions: searchHandler, 48815 __experimentalHandleURLSuggestions: true, 48816 __experimentalShowInitialSuggestions: showInitialSuggestions, 48817 onSubmit: (suggestion, event) => { 48818 const hasSuggestion = suggestion || focusedSuggestion; 48819 if (!hasSuggestion && !value?.trim()?.length) { 48820 event.preventDefault(); 48821 } else { 48822 onSuggestionSelected( 48823 hasSuggestion || { url: value } 48824 ); 48825 } 48826 }, 48827 inputRef: ref, 48828 suffix, 48829 disabled: isEntity 48830 } 48831 ), 48832 children 48833 ] }); 48834 } 48835 ); 48836 var search_input_default = LinkControlSearchInput; 48837 var __experimentalLinkControlSearchInput = (props) => { 48838 (0, import_deprecated22.default)("wp.blockEditor.__experimentalLinkControlSearchInput", { 48839 since: "6.8" 48840 }); 48841 return /* @__PURE__ */ (0, import_jsx_runtime315.jsx)(LinkControlSearchInput, { ...props }); 48842 }; 48843 48844 // packages/block-editor/build-module/components/link-control/link-preview.js 48845 var import_i18n153 = __toESM(require_i18n()); 48846 var import_components164 = __toESM(require_components()); 48847 var import_compose82 = __toESM(require_compose()); 48848 var import_url7 = __toESM(require_url()); 48849 var import_dom34 = __toESM(require_dom()); 48850 var import_data143 = __toESM(require_data()); 48851 var import_notices9 = __toESM(require_notices()); 48852 var import_preferences3 = __toESM(require_preferences()); 48853 48854 // packages/block-editor/build-module/components/link-control/viewer-slot.js 48855 var import_components163 = __toESM(require_components()); 48856 var { Slot: ViewerSlot, Fill: ViewerFill } = (0, import_components163.createSlotFill)( 48857 "BlockEditorLinkControlViewer" 48858 ); 48859 48860 // packages/block-editor/build-module/components/link-control/use-rich-url-data.js 48861 var import_data142 = __toESM(require_data()); 48862 var import_element166 = __toESM(require_element()); 48863 function reducer2(state, action) { 48864 switch (action.type) { 48865 case "RESOLVED": 48866 return { 48867 ...state, 48868 isFetching: false, 48869 richData: action.richData 48870 }; 48871 case "ERROR": 48872 return { 48873 ...state, 48874 isFetching: false, 48875 richData: null 48876 }; 48877 case "LOADING": 48878 return { 48879 ...state, 48880 isFetching: true 48881 }; 48882 default: 48883 throw new Error(`Unexpected action type $action.type}`); 48884 } 48885 } 48886 function useRemoteUrlData(url) { 48887 const [state, dispatch] = (0, import_element166.useReducer)(reducer2, { 48888 richData: null, 48889 isFetching: false 48890 }); 48891 const { fetchRichUrlData } = (0, import_data142.useSelect)((select3) => { 48892 const { getSettings: getSettings8 } = select3(store); 48893 return { 48894 fetchRichUrlData: getSettings8().__experimentalFetchRichUrlData 48895 }; 48896 }, []); 48897 (0, import_element166.useEffect)(() => { 48898 if (url?.length && fetchRichUrlData && typeof AbortController !== "undefined") { 48899 dispatch({ 48900 type: "LOADING" 48901 }); 48902 const controller = new window.AbortController(); 48903 const signal = controller.signal; 48904 fetchRichUrlData(url, { 48905 signal 48906 }).then((urlData) => { 48907 dispatch({ 48908 type: "RESOLVED", 48909 richData: urlData 48910 }); 48911 }).catch(() => { 48912 if (!signal.aborted) { 48913 dispatch({ 48914 type: "ERROR" 48915 }); 48916 } 48917 }); 48918 return () => { 48919 controller.abort(); 48920 }; 48921 } 48922 }, [url]); 48923 return state; 48924 } 48925 var use_rich_url_data_default = useRemoteUrlData; 48926 48927 // packages/block-editor/build-module/components/link-control/link-preview.js 48928 var import_jsx_runtime316 = __toESM(require_jsx_runtime()); 48929 function filterTitleForDisplay(title) { 48930 return title.replace(/^[a-z\-.\+]+[0-9]*:(\/\/)?/i, "").replace(/^www\./i, ""); 48931 } 48932 function LinkPreview({ 48933 value, 48934 onEditClick, 48935 hasRichPreviews = false, 48936 hasUnlinkControl = false, 48937 onRemove 48938 }) { 48939 const showIconLabels = (0, import_data143.useSelect)( 48940 (select3) => select3(import_preferences3.store).get("core", "showIconLabels"), 48941 [] 48942 ); 48943 const showRichPreviews = hasRichPreviews ? value?.url : null; 48944 const { richData, isFetching } = use_rich_url_data_default(showRichPreviews); 48945 const hasRichData = richData && Object.keys(richData).length; 48946 const displayURL = value && (0, import_url7.filterURLForDisplay)((0, import_url7.safeDecodeURI)(value.url), 24) || ""; 48947 const isEmptyURL = !value?.url?.length; 48948 const displayTitle = !isEmptyURL && (0, import_dom34.__unstableStripHTML)(richData?.title || value?.title || displayURL); 48949 const isUrlRedundant = !value?.url || filterTitleForDisplay(displayTitle) === displayURL; 48950 let icon; 48951 if (richData?.icon) { 48952 icon = /* @__PURE__ */ (0, import_jsx_runtime316.jsx)("img", { src: richData?.icon, alt: "" }); 48953 } else if (isEmptyURL) { 48954 icon = /* @__PURE__ */ (0, import_jsx_runtime316.jsx)(icon_default, { icon: info_default, size: 32 }); 48955 } else { 48956 icon = /* @__PURE__ */ (0, import_jsx_runtime316.jsx)(icon_default, { icon: globe_default }); 48957 } 48958 const { createNotice } = (0, import_data143.useDispatch)(import_notices9.store); 48959 const ref = (0, import_compose82.useCopyToClipboard)(value.url, () => { 48960 createNotice("info", (0, import_i18n153.__)("Link copied to clipboard."), { 48961 isDismissible: true, 48962 type: "snackbar" 48963 }); 48964 }); 48965 return /* @__PURE__ */ (0, import_jsx_runtime316.jsx)( 48966 import_components164.Flex, 48967 { 48968 role: "group", 48969 "aria-label": (0, import_i18n153.__)("Manage link"), 48970 className: clsx_default("block-editor-link-control__preview", { 48971 "is-current": true, 48972 "is-rich": hasRichData, 48973 "is-fetching": !!isFetching, 48974 "is-preview": true, 48975 "is-error": isEmptyURL, 48976 "is-url-title": displayTitle === displayURL 48977 }), 48978 children: /* @__PURE__ */ (0, import_jsx_runtime316.jsxs)(import_components164.Flex, { gap: 0, children: [ 48979 /* @__PURE__ */ (0, import_jsx_runtime316.jsxs)( 48980 import_components164.Flex, 48981 { 48982 className: "block-editor-link-control__link-information", 48983 role: "figure", 48984 "aria-label": ( 48985 /* translators: Accessibility text for the link preview when editing a link. */ 48986 (0, import_i18n153.__)("Link information") 48987 ), 48988 justify: "start", 48989 children: [ 48990 /* @__PURE__ */ (0, import_jsx_runtime316.jsx)( 48991 import_components164.Flex, 48992 { 48993 className: clsx_default( 48994 "block-editor-link-control__preview-icon", 48995 { 48996 "is-image": richData?.icon 48997 } 48998 ), 48999 justify: "center", 49000 children: icon 49001 } 49002 ), 49003 /* @__PURE__ */ (0, import_jsx_runtime316.jsx)( 49004 import_components164.Flex, 49005 { 49006 className: "block-editor-link-control__preview-details", 49007 direction: "column", 49008 gap: 1, 49009 children: !isEmptyURL ? /* @__PURE__ */ (0, import_jsx_runtime316.jsxs)(import_jsx_runtime316.Fragment, { children: [ 49010 /* @__PURE__ */ (0, import_jsx_runtime316.jsx)( 49011 import_components164.ExternalLink, 49012 { 49013 className: "block-editor-link-control__preview-title", 49014 href: value.url, 49015 children: /* @__PURE__ */ (0, import_jsx_runtime316.jsx)(import_components164.__experimentalTruncate, { numberOfLines: 1, children: displayTitle }) 49016 } 49017 ), 49018 !isUrlRedundant && /* @__PURE__ */ (0, import_jsx_runtime316.jsx)("span", { className: "block-editor-link-control__preview-info", children: /* @__PURE__ */ (0, import_jsx_runtime316.jsx)(import_components164.__experimentalTruncate, { numberOfLines: 1, children: displayURL }) }) 49019 ] }) : /* @__PURE__ */ (0, import_jsx_runtime316.jsx)("span", { className: "block-editor-link-control__preview-error-notice", children: (0, import_i18n153.__)("Link is empty") }) 49020 } 49021 ) 49022 ] 49023 } 49024 ), 49025 /* @__PURE__ */ (0, import_jsx_runtime316.jsx)( 49026 import_components164.Button, 49027 { 49028 icon: pencil_default, 49029 label: (0, import_i18n153.__)("Edit link"), 49030 onClick: onEditClick, 49031 size: "compact", 49032 showTooltip: !showIconLabels 49033 } 49034 ), 49035 hasUnlinkControl && /* @__PURE__ */ (0, import_jsx_runtime316.jsx)( 49036 import_components164.Button, 49037 { 49038 icon: link_off_default, 49039 label: (0, import_i18n153.__)("Remove link"), 49040 onClick: onRemove, 49041 size: "compact", 49042 showTooltip: !showIconLabels 49043 } 49044 ), 49045 /* @__PURE__ */ (0, import_jsx_runtime316.jsx)( 49046 import_components164.Button, 49047 { 49048 icon: copy_small_default, 49049 label: (0, import_i18n153.__)("Copy link"), 49050 ref, 49051 accessibleWhenDisabled: true, 49052 disabled: isEmptyURL, 49053 size: "compact", 49054 showTooltip: !showIconLabels 49055 } 49056 ), 49057 /* @__PURE__ */ (0, import_jsx_runtime316.jsx)(ViewerSlot, { fillProps: value }) 49058 ] }) 49059 } 49060 ); 49061 } 49062 49063 // packages/block-editor/build-module/components/link-control/settings.js 49064 var import_i18n154 = __toESM(require_i18n()); 49065 var import_components165 = __toESM(require_components()); 49066 var import_jsx_runtime317 = __toESM(require_jsx_runtime()); 49067 var noop14 = () => { 49068 }; 49069 var LinkControlSettings = ({ value, onChange = noop14, settings: settings2 }) => { 49070 if (!settings2 || !settings2.length) { 49071 return null; 49072 } 49073 const handleSettingChange = (setting) => (newValue) => { 49074 onChange({ 49075 ...value, 49076 [setting.id]: newValue 49077 }); 49078 }; 49079 const theSettings = settings2.map((setting) => { 49080 if ("render" in setting) { 49081 if (typeof setting.render === "function") { 49082 const renderedContent = setting.render( 49083 setting, 49084 value, 49085 onChange 49086 ); 49087 return /* @__PURE__ */ (0, import_jsx_runtime317.jsx)( 49088 "div", 49089 { 49090 className: "block-editor-link-control__setting", 49091 children: renderedContent 49092 }, 49093 setting.id 49094 ); 49095 } 49096 return null; 49097 } 49098 return /* @__PURE__ */ (0, import_jsx_runtime317.jsx)( 49099 import_components165.CheckboxControl, 49100 { 49101 className: "block-editor-link-control__setting", 49102 label: setting.title, 49103 onChange: handleSettingChange(setting), 49104 checked: value ? !!value[setting.id] : false, 49105 help: setting?.help 49106 }, 49107 setting.id 49108 ); 49109 }).filter(Boolean); 49110 return /* @__PURE__ */ (0, import_jsx_runtime317.jsxs)("fieldset", { className: "block-editor-link-control__settings", children: [ 49111 /* @__PURE__ */ (0, import_jsx_runtime317.jsx)(import_components165.VisuallyHidden, { as: "legend", children: (0, import_i18n154.__)("Currently selected link settings") }), 49112 theSettings 49113 ] }); 49114 }; 49115 var settings_default2 = LinkControlSettings; 49116 49117 // packages/block-editor/build-module/components/link-control/use-create-page.js 49118 var import_i18n155 = __toESM(require_i18n()); 49119 var import_element167 = __toESM(require_element()); 49120 function useCreatePage(handleCreatePage) { 49121 const cancelableCreateSuggestion = (0, import_element167.useRef)(); 49122 const [isCreatingPage, setIsCreatingPage] = (0, import_element167.useState)(false); 49123 const [errorMessage, setErrorMessage] = (0, import_element167.useState)(null); 49124 const createPage = async function(suggestionTitle) { 49125 setIsCreatingPage(true); 49126 setErrorMessage(null); 49127 try { 49128 cancelableCreateSuggestion.current = makeCancelable( 49129 // Using Promise.resolve to allow createSuggestion to return a 49130 // non-Promise based value. 49131 Promise.resolve(handleCreatePage(suggestionTitle)) 49132 ); 49133 return await cancelableCreateSuggestion.current.promise; 49134 } catch (error) { 49135 if (error && error.isCanceled) { 49136 return; 49137 } 49138 setErrorMessage( 49139 error.message || (0, import_i18n155.__)( 49140 "An unknown error occurred during creation. Please try again." 49141 ) 49142 ); 49143 throw error; 49144 } finally { 49145 setIsCreatingPage(false); 49146 } 49147 }; 49148 (0, import_element167.useEffect)(() => { 49149 return () => { 49150 if (cancelableCreateSuggestion.current) { 49151 cancelableCreateSuggestion.current.cancel(); 49152 } 49153 }; 49154 }, []); 49155 return { 49156 createPage, 49157 isCreatingPage, 49158 errorMessage 49159 }; 49160 } 49161 var makeCancelable = (promise) => { 49162 let hasCanceled_ = false; 49163 const wrappedPromise = new Promise((resolve, reject) => { 49164 promise.then( 49165 (val) => hasCanceled_ ? reject({ isCanceled: true }) : resolve(val), 49166 (error) => hasCanceled_ ? reject({ isCanceled: true }) : reject(error) 49167 ); 49168 }); 49169 return { 49170 promise: wrappedPromise, 49171 cancel() { 49172 hasCanceled_ = true; 49173 } 49174 }; 49175 }; 49176 49177 // packages/block-editor/build-module/components/link-control/use-internal-value.js 49178 var import_element168 = __toESM(require_element()); 49179 var import_fast_deep_equal = __toESM(require_fast_deep_equal()); 49180 function useInternalValue(value) { 49181 const [internalValue, setInternalValue] = (0, import_element168.useState)(value || {}); 49182 const [previousValue, setPreviousValue] = (0, import_element168.useState)(value); 49183 if (!(0, import_fast_deep_equal.default)(value, previousValue)) { 49184 setPreviousValue(value); 49185 setInternalValue(value); 49186 } 49187 const setInternalURLInputValue = (nextValue) => { 49188 setInternalValue({ 49189 ...internalValue, 49190 url: nextValue 49191 }); 49192 }; 49193 const setInternalTextInputValue = (nextValue) => { 49194 setInternalValue({ 49195 ...internalValue, 49196 title: nextValue 49197 }); 49198 }; 49199 const createSetInternalSettingValueHandler = (settingsKeys) => (nextValue) => { 49200 const settingsUpdates = Object.keys(nextValue).reduce( 49201 (acc, key) => { 49202 if (settingsKeys.includes(key)) { 49203 acc[key] = nextValue[key]; 49204 } 49205 return acc; 49206 }, 49207 {} 49208 ); 49209 setInternalValue({ 49210 ...internalValue, 49211 ...settingsUpdates 49212 }); 49213 }; 49214 return [ 49215 internalValue, 49216 setInternalValue, 49217 setInternalURLInputValue, 49218 setInternalTextInputValue, 49219 createSetInternalSettingValueHandler 49220 ]; 49221 } 49222 49223 // packages/block-editor/build-module/components/link-control/index.js 49224 var import_jsx_runtime318 = __toESM(require_jsx_runtime()); 49225 var noop15 = () => { 49226 }; 49227 var PREFERENCE_SCOPE = "core/block-editor"; 49228 var PREFERENCE_KEY = "linkControlSettingsDrawer"; 49229 function LinkControl({ 49230 searchInputPlaceholder, 49231 value, 49232 settings: settings2 = DEFAULT_LINK_SETTINGS, 49233 onChange = noop15, 49234 onRemove, 49235 onCancel, 49236 noDirectEntry = false, 49237 showSuggestions = true, 49238 showInitialSuggestions, 49239 forceIsEditingLink, 49240 createSuggestion, 49241 withCreateSuggestion, 49242 inputValue: propInputValue = "", 49243 suggestionsQuery = {}, 49244 noURLSuggestion = false, 49245 createSuggestionButtonText, 49246 hasRichPreviews = false, 49247 hasTextControl = false, 49248 renderControlBottom = null, 49249 handleEntities = false 49250 }) { 49251 if (withCreateSuggestion === void 0 && createSuggestion) { 49252 withCreateSuggestion = true; 49253 } 49254 const [settingsOpen, setSettingsOpen] = (0, import_element169.useState)(false); 49255 const { advancedSettingsPreference } = (0, import_data144.useSelect)((select3) => { 49256 const prefsStore = select3(import_preferences4.store); 49257 return { 49258 advancedSettingsPreference: prefsStore.get(PREFERENCE_SCOPE, PREFERENCE_KEY) ?? false 49259 }; 49260 }, []); 49261 const { set: setPreference } = (0, import_data144.useDispatch)(import_preferences4.store); 49262 const setSettingsOpenWithPreference = (prefVal) => { 49263 if (setPreference) { 49264 setPreference(PREFERENCE_SCOPE, PREFERENCE_KEY, prefVal); 49265 } 49266 setSettingsOpen(prefVal); 49267 }; 49268 const isSettingsOpen = advancedSettingsPreference || settingsOpen; 49269 const isMountingRef = (0, import_element169.useRef)(true); 49270 const wrapperNode = (0, import_element169.useRef)(); 49271 const textInputRef = (0, import_element169.useRef)(); 49272 const searchInputRef = (0, import_element169.useRef)(); 49273 const entityUrlFallbackRef = (0, import_element169.useRef)(); 49274 const settingsKeys = settings2.map(({ id }) => id); 49275 const [ 49276 internalControlValue, 49277 setInternalControlValue, 49278 setInternalURLInputValue, 49279 setInternalTextInputValue, 49280 createSetInternalSettingValueHandler 49281 ] = useInternalValue(value); 49282 const isEntity = handleEntities && !!internalControlValue?.id; 49283 const baseId = (0, import_compose83.useInstanceId)(LinkControl, "link-control"); 49284 const helpTextId = isEntity ? `$baseId}__help` : null; 49285 const valueHasChanges = value && !(0, import_is_shallow_equal3.isShallowEqualObjects)(internalControlValue, value); 49286 const [isEditingLink, setIsEditingLink] = (0, import_element169.useState)( 49287 forceIsEditingLink !== void 0 ? forceIsEditingLink : !value || !value.url 49288 ); 49289 const { createPage, isCreatingPage, errorMessage } = useCreatePage(createSuggestion); 49290 (0, import_element169.useEffect)(() => { 49291 if (forceIsEditingLink === void 0) { 49292 return; 49293 } 49294 setIsEditingLink(forceIsEditingLink); 49295 }, [forceIsEditingLink]); 49296 (0, import_element169.useEffect)(() => { 49297 if (isMountingRef.current) { 49298 return; 49299 } 49300 const nextFocusTarget = import_dom35.focus.focusable.find(wrapperNode.current)[0] || wrapperNode.current; 49301 nextFocusTarget.focus(); 49302 }, [isEditingLink, isCreatingPage]); 49303 (0, import_element169.useEffect)(() => { 49304 isMountingRef.current = false; 49305 return () => { 49306 isMountingRef.current = true; 49307 }; 49308 }, []); 49309 const hasLinkValue = value?.url?.trim()?.length > 0; 49310 const stopEditing = () => { 49311 setIsEditingLink(false); 49312 }; 49313 const handleSelectSuggestion = (updatedValue) => { 49314 if (updatedValue?.kind === "taxonomy" && updatedValue?.url) { 49315 entityUrlFallbackRef.current = updatedValue.url; 49316 } 49317 const nonSettingsChanges = Object.keys(updatedValue).reduce( 49318 (acc, key) => { 49319 if (!settingsKeys.includes(key)) { 49320 acc[key] = updatedValue[key]; 49321 } 49322 return acc; 49323 }, 49324 {} 49325 ); 49326 onChange({ 49327 ...internalControlValue, 49328 ...nonSettingsChanges, 49329 // As title is not a setting, it must be manually applied 49330 // in such a way as to preserve the users changes over 49331 // any "title" value provided by the "suggestion". 49332 title: internalControlValue?.title || updatedValue?.title 49333 }); 49334 stopEditing(); 49335 }; 49336 const handleSubmit = () => { 49337 if (valueHasChanges) { 49338 onChange({ 49339 ...value, 49340 ...internalControlValue, 49341 url: currentUrlInputValue 49342 }); 49343 } 49344 stopEditing(); 49345 }; 49346 const handleSubmitWithEnter = (event) => { 49347 const { keyCode } = event; 49348 if (keyCode === import_keycodes16.ENTER && !currentInputIsEmpty) { 49349 event.preventDefault(); 49350 handleSubmit(); 49351 } 49352 }; 49353 const resetInternalValues = () => { 49354 setInternalControlValue(value); 49355 }; 49356 const handleCancel = (event) => { 49357 event.preventDefault(); 49358 event.stopPropagation(); 49359 resetInternalValues(); 49360 if (hasLinkValue) { 49361 stopEditing(); 49362 } else { 49363 onRemove?.(); 49364 } 49365 onCancel?.(); 49366 }; 49367 const [shouldFocusSearchInput, setShouldFocusSearchInput] = (0, import_element169.useState)(false); 49368 const handleUnlink = () => { 49369 const { id, kind, type, ...restValue } = internalControlValue; 49370 setInternalControlValue({ 49371 ...restValue, 49372 id: void 0, 49373 kind: void 0, 49374 type: void 0, 49375 url: void 0 49376 }); 49377 setShouldFocusSearchInput(true); 49378 }; 49379 (0, import_element169.useEffect)(() => { 49380 if (shouldFocusSearchInput) { 49381 searchInputRef.current?.focus(); 49382 setShouldFocusSearchInput(false); 49383 } 49384 }, [shouldFocusSearchInput]); 49385 const currentUrlInputValue = propInputValue || internalControlValue?.url || ""; 49386 const currentInputIsEmpty = !currentUrlInputValue?.trim()?.length; 49387 const shownUnlinkControl = onRemove && value && !isEditingLink && !isCreatingPage; 49388 const showActions = isEditingLink && hasLinkValue; 49389 const showTextControl = hasLinkValue && hasTextControl; 49390 const isEditing = (isEditingLink || !value) && !isCreatingPage; 49391 const isDisabled = !valueHasChanges || currentInputIsEmpty; 49392 const showSettings = !!settings2?.length && isEditingLink && hasLinkValue; 49393 const previewValue = (0, import_element169.useMemo)(() => { 49394 if (value?.kind === "taxonomy" && !value?.url && entityUrlFallbackRef.current) { 49395 return { 49396 ...value, 49397 url: entityUrlFallbackRef.current 49398 }; 49399 } 49400 return value; 49401 }, [value]); 49402 return /* @__PURE__ */ (0, import_jsx_runtime318.jsxs)( 49403 "div", 49404 { 49405 tabIndex: -1, 49406 ref: wrapperNode, 49407 className: "block-editor-link-control", 49408 children: [ 49409 isCreatingPage && /* @__PURE__ */ (0, import_jsx_runtime318.jsxs)("div", { className: "block-editor-link-control__loading", children: [ 49410 /* @__PURE__ */ (0, import_jsx_runtime318.jsx)(import_components166.Spinner, {}), 49411 " ", 49412 (0, import_i18n156.__)("Creating"), 49413 "\u2026" 49414 ] }), 49415 isEditing && /* @__PURE__ */ (0, import_jsx_runtime318.jsxs)(import_jsx_runtime318.Fragment, { children: [ 49416 /* @__PURE__ */ (0, import_jsx_runtime318.jsxs)( 49417 "div", 49418 { 49419 className: clsx_default({ 49420 "block-editor-link-control__search-input-wrapper": true, 49421 "has-text-control": showTextControl, 49422 "has-actions": showActions 49423 }), 49424 children: [ 49425 showTextControl && /* @__PURE__ */ (0, import_jsx_runtime318.jsx)( 49426 import_components166.TextControl, 49427 { 49428 ref: textInputRef, 49429 className: "block-editor-link-control__field block-editor-link-control__text-content", 49430 label: (0, import_i18n156.__)("Text"), 49431 value: internalControlValue?.title, 49432 onChange: setInternalTextInputValue, 49433 onKeyDown: handleSubmitWithEnter, 49434 __next40pxDefaultSize: true 49435 } 49436 ), 49437 /* @__PURE__ */ (0, import_jsx_runtime318.jsx)( 49438 search_input_default, 49439 { 49440 ref: searchInputRef, 49441 currentLink: value, 49442 className: "block-editor-link-control__field block-editor-link-control__search-input", 49443 placeholder: searchInputPlaceholder, 49444 value: currentUrlInputValue, 49445 withCreateSuggestion, 49446 onCreateSuggestion: createPage, 49447 onChange: setInternalURLInputValue, 49448 onSelect: handleSelectSuggestion, 49449 showInitialSuggestions, 49450 allowDirectEntry: !noDirectEntry, 49451 showSuggestions, 49452 suggestionsQuery, 49453 withURLSuggestion: !noURLSuggestion, 49454 createSuggestionButtonText, 49455 hideLabelFromVision: !showTextControl, 49456 isEntity, 49457 suffix: /* @__PURE__ */ (0, import_jsx_runtime318.jsx)( 49458 SearchSuffixControl, 49459 { 49460 isEntity, 49461 showActions, 49462 isDisabled, 49463 onUnlink: handleUnlink, 49464 onSubmit: handleSubmit, 49465 helpTextId 49466 } 49467 ) 49468 } 49469 ), 49470 isEntity && helpTextId && /* @__PURE__ */ (0, import_jsx_runtime318.jsx)( 49471 "p", 49472 { 49473 id: helpTextId, 49474 className: "block-editor-link-control__help", 49475 children: (0, import_i18n156.sprintf)( 49476 /* translators: %s: entity type (e.g., page, post) */ 49477 (0, import_i18n156.__)("Synced with the selected %s."), 49478 internalControlValue?.type || "item" 49479 ) 49480 } 49481 ) 49482 ] 49483 } 49484 ), 49485 errorMessage && /* @__PURE__ */ (0, import_jsx_runtime318.jsx)( 49486 import_components166.Notice, 49487 { 49488 className: "block-editor-link-control__search-error", 49489 status: "error", 49490 isDismissible: false, 49491 children: errorMessage 49492 } 49493 ) 49494 ] }), 49495 value && !isEditingLink && !isCreatingPage && /* @__PURE__ */ (0, import_jsx_runtime318.jsx)( 49496 LinkPreview, 49497 { 49498 value: previewValue, 49499 onEditClick: () => setIsEditingLink(true), 49500 hasRichPreviews, 49501 hasUnlinkControl: shownUnlinkControl, 49502 onRemove: () => { 49503 onRemove(); 49504 setIsEditingLink(true); 49505 } 49506 }, 49507 previewValue?.url 49508 ), 49509 showSettings && /* @__PURE__ */ (0, import_jsx_runtime318.jsx)("div", { className: "block-editor-link-control__tools", children: !currentInputIsEmpty && /* @__PURE__ */ (0, import_jsx_runtime318.jsx)( 49510 settings_drawer_default, 49511 { 49512 settingsOpen: isSettingsOpen, 49513 setSettingsOpen: setSettingsOpenWithPreference, 49514 children: /* @__PURE__ */ (0, import_jsx_runtime318.jsx)( 49515 settings_default2, 49516 { 49517 value: internalControlValue, 49518 settings: settings2, 49519 onChange: createSetInternalSettingValueHandler( 49520 settingsKeys 49521 ) 49522 } 49523 ) 49524 } 49525 ) }), 49526 showActions && /* @__PURE__ */ (0, import_jsx_runtime318.jsxs)( 49527 import_components166.__experimentalHStack, 49528 { 49529 justify: "right", 49530 className: "block-editor-link-control__search-actions", 49531 children: [ 49532 /* @__PURE__ */ (0, import_jsx_runtime318.jsx)( 49533 import_components166.Button, 49534 { 49535 __next40pxDefaultSize: true, 49536 variant: "tertiary", 49537 onClick: handleCancel, 49538 children: (0, import_i18n156.__)("Cancel") 49539 } 49540 ), 49541 /* @__PURE__ */ (0, import_jsx_runtime318.jsx)( 49542 import_components166.Button, 49543 { 49544 __next40pxDefaultSize: true, 49545 variant: "primary", 49546 onClick: isDisabled ? noop15 : handleSubmit, 49547 className: "block-editor-link-control__search-submit", 49548 "aria-disabled": isDisabled, 49549 children: (0, import_i18n156.__)("Apply") 49550 } 49551 ) 49552 ] 49553 } 49554 ), 49555 !isCreatingPage && renderControlBottom && renderControlBottom() 49556 ] 49557 } 49558 ); 49559 } 49560 function SearchSuffixControl({ 49561 isEntity, 49562 showActions, 49563 isDisabled, 49564 onUnlink, 49565 onSubmit, 49566 helpTextId 49567 }) { 49568 if (isEntity) { 49569 return /* @__PURE__ */ (0, import_jsx_runtime318.jsx)( 49570 import_components166.Button, 49571 { 49572 icon: link_off_default, 49573 onClick: onUnlink, 49574 "aria-describedby": helpTextId, 49575 showTooltip: true, 49576 label: (0, import_i18n156.__)("Unsync and edit"), 49577 __next40pxDefaultSize: true 49578 } 49579 ); 49580 } 49581 if (showActions) { 49582 return void 0; 49583 } 49584 return /* @__PURE__ */ (0, import_jsx_runtime318.jsx)(import_components166.__experimentalInputControlSuffixWrapper, { variant: "control", children: /* @__PURE__ */ (0, import_jsx_runtime318.jsx)( 49585 import_components166.Button, 49586 { 49587 onClick: isDisabled ? noop15 : onSubmit, 49588 label: (0, import_i18n156.__)("Submit"), 49589 icon: keyboard_return_default, 49590 className: "block-editor-link-control__search-submit", 49591 "aria-disabled": isDisabled, 49592 size: "small" 49593 } 49594 ) }); 49595 } 49596 LinkControl.ViewerFill = ViewerFill; 49597 LinkControl.DEFAULT_LINK_SETTINGS = DEFAULT_LINK_SETTINGS; 49598 var DeprecatedExperimentalLinkControl = (props) => { 49599 (0, import_deprecated23.default)("wp.blockEditor.__experimentalLinkControl", { 49600 since: "6.8", 49601 alternative: "wp.blockEditor.LinkControl" 49602 }); 49603 return /* @__PURE__ */ (0, import_jsx_runtime318.jsx)(LinkControl, { ...props }); 49604 }; 49605 DeprecatedExperimentalLinkControl.ViewerFill = LinkControl.ViewerFill; 49606 DeprecatedExperimentalLinkControl.DEFAULT_LINK_SETTINGS = LinkControl.DEFAULT_LINK_SETTINGS; 49607 var link_control_default = LinkControl; 49608 49609 // packages/block-editor/build-module/components/line-height-control/index.js 49610 var import_i18n157 = __toESM(require_i18n()); 49611 var import_components167 = __toESM(require_components()); 49612 var import_deprecated24 = __toESM(require_deprecated()); 49613 49614 // packages/block-editor/build-module/components/line-height-control/utils.js 49615 var BASE_DEFAULT_VALUE = 1.5; 49616 var STEP = 0.01; 49617 var SPIN_FACTOR = 10; 49618 var RESET_VALUE = ""; 49619 function isLineHeightDefined(lineHeight) { 49620 return lineHeight !== void 0 && lineHeight !== RESET_VALUE; 49621 } 49622 49623 // packages/block-editor/build-module/components/line-height-control/index.js 49624 var import_jsx_runtime319 = __toESM(require_jsx_runtime()); 49625 var LineHeightControl = ({ 49626 /** Start opting into the larger default height that will become the default size in a future version. */ 49627 __next40pxDefaultSize = false, 49628 value: lineHeight, 49629 onChange, 49630 __unstableInputWidth = "60px", 49631 ...otherProps 49632 }) => { 49633 const isDefined = isLineHeightDefined(lineHeight); 49634 const adjustNextValue = (nextValue, wasTypedOrPasted) => { 49635 if (isDefined) { 49636 return nextValue; 49637 } 49638 const spin = STEP * SPIN_FACTOR; 49639 switch (`$nextValue}`) { 49640 case `$spin}`: 49641 return BASE_DEFAULT_VALUE + spin; 49642 case "0": { 49643 if (wasTypedOrPasted) { 49644 return nextValue; 49645 } 49646 return BASE_DEFAULT_VALUE - spin; 49647 } 49648 case "": 49649 return BASE_DEFAULT_VALUE; 49650 default: 49651 return nextValue; 49652 } 49653 }; 49654 const stateReducer = (state, action) => { 49655 const wasTypedOrPasted = ["insertText", "insertFromPaste"].includes( 49656 action.payload.event.nativeEvent?.inputType 49657 ); 49658 const value2 = adjustNextValue(state.value, wasTypedOrPasted); 49659 return { ...state, value: value2 }; 49660 }; 49661 const value = isDefined ? lineHeight : RESET_VALUE; 49662 const handleOnChange = (nextValue, { event }) => { 49663 if (nextValue === "") { 49664 onChange(); 49665 return; 49666 } 49667 if (event.type === "click") { 49668 onChange(adjustNextValue(`$nextValue}`, false)); 49669 return; 49670 } 49671 onChange(`$nextValue}`); 49672 }; 49673 if (!__next40pxDefaultSize && (otherProps.size === void 0 || otherProps.size === "default")) { 49674 (0, import_deprecated24.default)(`36px default size for wp.blockEditor.LineHeightControl`, { 49675 since: "6.8", 49676 version: "7.1", 49677 hint: "Set the `__next40pxDefaultSize` prop to true to start opting into the new default size, which will become the default in a future version." 49678 }); 49679 } 49680 return /* @__PURE__ */ (0, import_jsx_runtime319.jsx)("div", { className: "block-editor-line-height-control", children: /* @__PURE__ */ (0, import_jsx_runtime319.jsx)( 49681 import_components167.__experimentalNumberControl, 49682 { 49683 ...otherProps, 49684 __shouldNotWarnDeprecated36pxSize: true, 49685 __next40pxDefaultSize, 49686 __unstableInputWidth, 49687 __unstableStateReducer: stateReducer, 49688 onChange: handleOnChange, 49689 label: (0, import_i18n157.__)("Line height"), 49690 placeholder: BASE_DEFAULT_VALUE, 49691 step: STEP, 49692 spinFactor: SPIN_FACTOR, 49693 value, 49694 min: 0, 49695 spinControls: "custom" 49696 } 49697 ) }); 49698 }; 49699 var line_height_control_default = LineHeightControl; 49700 49701 // packages/block-editor/build-module/components/media-replace-flow/index.js 49702 var import_i18n158 = __toESM(require_i18n()); 49703 var import_a11y18 = __toESM(require_a11y()); 49704 var import_components168 = __toESM(require_components()); 49705 var import_data145 = __toESM(require_data()); 49706 var import_keycodes17 = __toESM(require_keycodes()); 49707 var import_compose84 = __toESM(require_compose()); 49708 var import_dom36 = __toESM(require_dom()); 49709 var import_notices10 = __toESM(require_notices()); 49710 var import_element170 = __toESM(require_element()); 49711 49712 // packages/block-editor/build-module/components/media-placeholder/utils.js 49713 function getComputedAcceptAttribute(allowedTypes, allowedMimeTypes, accept) { 49714 if (accept) { 49715 return accept; 49716 } 49717 if (!allowedMimeTypes || typeof allowedMimeTypes !== "object" || Object.keys(allowedMimeTypes).length === 0) { 49718 if (allowedTypes && allowedTypes.length > 0) { 49719 return allowedTypes.map((type) => `$type}/*`).join(","); 49720 } 49721 return void 0; 49722 } 49723 if (!allowedTypes || allowedTypes.length === 0) { 49724 return void 0; 49725 } 49726 const acceptedMimeTypes = []; 49727 for (const [, mimeType] of Object.entries(allowedMimeTypes)) { 49728 const isAllowed = allowedTypes.some((allowedType) => { 49729 if (allowedType.includes("/")) { 49730 return mimeType === allowedType; 49731 } 49732 return mimeType.startsWith(`${allowedType}/`); 49733 }); 49734 if (isAllowed) { 49735 acceptedMimeTypes.push(mimeType); 49736 } 49737 } 49738 if (acceptedMimeTypes.length > 0) { 49739 return acceptedMimeTypes.join(","); 49740 } 49741 return allowedTypes.map((type) => `${type}/*`).join(","); 49742 } 49743 49744 // packages/block-editor/build-module/components/media-replace-flow/index.js 49745 var import_jsx_runtime320 = __toESM(require_jsx_runtime()); 49746 var noop16 = () => { 49747 }; 49748 var uniqueId = 0; 49749 var MediaReplaceFlow = ({ 49750 mediaURL, 49751 mediaId, 49752 mediaIds, 49753 allowedTypes, 49754 accept, 49755 onError, 49756 onSelect, 49757 onSelectURL, 49758 onReset, 49759 onToggleFeaturedImage, 49760 useFeaturedImage, 49761 onFilesUpload = noop16, 49762 name = (0, import_i18n158.__)("Replace"), 49763 createNotice, 49764 removeNotice, 49765 children, 49766 multiple = false, 49767 addToGallery, 49768 handleUpload = true, 49769 popoverProps: popoverProps3, 49770 renderToggle: renderToggle3, 49771 className 49772 }) => { 49773 const { mediaUpload: mediaUpload2, allowedMimeTypes } = (0, import_data145.useSelect)((select3) => { 49774 const { getSettings: getSettings8 } = select3(store); 49775 const settings2 = getSettings8(); 49776 return { 49777 mediaUpload: settings2.mediaUpload, 49778 allowedMimeTypes: settings2.allowedMimeTypes 49779 }; 49780 }, []); 49781 const errorNoticeID = `block-editor/media-replace-flow/error-notice/${++uniqueId}`; 49782 const computedAccept = (0, import_element170.useMemo)( 49783 () => getComputedAcceptAttribute( 49784 allowedTypes, 49785 allowedMimeTypes, 49786 accept 49787 ), 49788 [allowedTypes, allowedMimeTypes, accept] 49789 ); 49790 const onUploadError = (message2) => { 49791 const safeMessage = (0, import_dom36.__unstableStripHTML)(message2); 49792 if (onError) { 49793 onError(safeMessage); 49794 return; 49795 } 49796 setTimeout(() => { 49797 createNotice("error", safeMessage, { 49798 speak: true, 49799 id: errorNoticeID, 49800 isDismissible: true 49801 }); 49802 }, 1e3); 49803 }; 49804 const selectMedia = (media, closeMenu) => { 49805 if (useFeaturedImage && onToggleFeaturedImage) { 49806 onToggleFeaturedImage(); 49807 } 49808 closeMenu(); 49809 onSelect(media); 49810 (0, import_a11y18.speak)((0, import_i18n158.__)("The media file has been replaced")); 49811 removeNotice(errorNoticeID); 49812 }; 49813 const uploadFiles = (event, closeMenu) => { 49814 const files = event.target.files; 49815 if (!handleUpload) { 49816 closeMenu(); 49817 return onSelect(files); 49818 } 49819 onFilesUpload(files); 49820 mediaUpload2({ 49821 allowedTypes, 49822 filesList: files, 49823 onFileChange: ([media]) => { 49824 selectMedia(media, closeMenu); 49825 }, 49826 onError: onUploadError 49827 }); 49828 }; 49829 const openOnArrowDown = (event) => { 49830 if (event.keyCode === import_keycodes17.DOWN) { 49831 event.preventDefault(); 49832 event.target.click(); 49833 } 49834 }; 49835 const onlyAllowsImages = () => { 49836 if (!allowedTypes || allowedTypes.length === 0) { 49837 return false; 49838 } 49839 return allowedTypes.every( 49840 (allowedType) => allowedType === "image" || allowedType.startsWith("image/") 49841 ); 49842 }; 49843 const gallery = multiple && onlyAllowsImages(); 49844 return /* @__PURE__ */ (0, import_jsx_runtime320.jsx)( 49845 import_components168.Dropdown, 49846 { 49847 popoverProps: popoverProps3, 49848 className, 49849 contentClassName: "block-editor-media-replace-flow__options", 49850 renderToggle: ({ isOpen, onToggle }) => { 49851 if (renderToggle3) { 49852 return renderToggle3({ 49853 "aria-expanded": isOpen, 49854 "aria-haspopup": "true", 49855 onClick: onToggle, 49856 onKeyDown: openOnArrowDown, 49857 children: name 49858 }); 49859 } 49860 return /* @__PURE__ */ (0, import_jsx_runtime320.jsx)( 49861 import_components168.ToolbarButton, 49862 { 49863 "aria-expanded": isOpen, 49864 "aria-haspopup": "true", 49865 onClick: onToggle, 49866 onKeyDown: openOnArrowDown, 49867 children: name 49868 } 49869 ); 49870 }, 49871 renderContent: ({ onClose }) => /* @__PURE__ */ (0, import_jsx_runtime320.jsxs)(import_jsx_runtime320.Fragment, { children: [ 49872 /* @__PURE__ */ (0, import_jsx_runtime320.jsxs)(import_components168.NavigableMenu, { className: "block-editor-media-replace-flow__media-upload-menu", children: [ 49873 /* @__PURE__ */ (0, import_jsx_runtime320.jsxs)(check_default2, { children: [ 49874 /* @__PURE__ */ (0, import_jsx_runtime320.jsx)( 49875 media_upload_default, 49876 { 49877 gallery, 49878 addToGallery, 49879 multiple, 49880 value: multiple ? mediaIds : mediaId, 49881 onSelect: (media) => selectMedia(media, onClose), 49882 allowedTypes, 49883 render: ({ open }) => /* @__PURE__ */ (0, import_jsx_runtime320.jsx)( 49884 import_components168.MenuItem, 49885 { 49886 icon: media_default, 49887 onClick: open, 49888 children: (0, import_i18n158.__)("Open Media Library") 49889 } 49890 ) 49891 } 49892 ), 49893 /* @__PURE__ */ (0, import_jsx_runtime320.jsx)( 49894 import_components168.FormFileUpload, 49895 { 49896 onChange: (event) => { 49897 uploadFiles(event, onClose); 49898 }, 49899 accept: computedAccept, 49900 multiple: !!multiple, 49901 render: ({ openFileDialog }) => { 49902 return /* @__PURE__ */ (0, import_jsx_runtime320.jsx)( 49903 import_components168.MenuItem, 49904 { 49905 icon: upload_default, 49906 onClick: () => { 49907 openFileDialog(); 49908 }, 49909 children: (0, import_i18n158._x)("Upload", "verb") 49910 } 49911 ); 49912 } 49913 } 49914 ) 49915 ] }), 49916 onToggleFeaturedImage && /* @__PURE__ */ (0, import_jsx_runtime320.jsx)( 49917 import_components168.MenuItem, 49918 { 49919 icon: post_featured_image_default, 49920 onClick: onToggleFeaturedImage, 49921 isPressed: useFeaturedImage, 49922 children: (0, import_i18n158.__)("Use featured image") 49923 } 49924 ), 49925 mediaURL && onReset && /* @__PURE__ */ (0, import_jsx_runtime320.jsx)( 49926 import_components168.MenuItem, 49927 { 49928 onClick: () => { 49929 onReset(); 49930 onClose(); 49931 }, 49932 children: (0, import_i18n158.__)("Reset") 49933 } 49934 ), 49935 typeof children === "function" ? children({ onClose }) : children 49936 ] }), 49937 onSelectURL && /* @__PURE__ */ (0, import_jsx_runtime320.jsxs)("form", { className: "block-editor-media-flow__url-input", children: [ 49938 /* @__PURE__ */ (0, import_jsx_runtime320.jsx)("span", { className: "block-editor-media-replace-flow__image-url-label", children: (0, import_i18n158.__)("Current media URL:") }), 49939 /* @__PURE__ */ (0, import_jsx_runtime320.jsx)( 49940 link_control_default, 49941 { 49942 value: { url: mediaURL }, 49943 settings: [], 49944 showSuggestions: false, 49945 onChange: ({ url }) => { 49946 onSelectURL(url); 49947 }, 49948 searchInputPlaceholder: (0, import_i18n158.__)( 49949 "Paste or type URL" 49950 ) 49951 } 49952 ) 49953 ] }) 49954 ] }) 49955 } 49956 ); 49957 }; 49958 var media_replace_flow_default = (0, import_compose84.compose)([ 49959 (0, import_data145.withDispatch)((dispatch) => { 49960 const { createNotice, removeNotice } = dispatch(import_notices10.store); 49961 return { 49962 createNotice, 49963 removeNotice 49964 }; 49965 }), 49966 (0, import_components168.withFilters)("editor.MediaReplaceFlow") 49967 ])(MediaReplaceFlow); 49968 49969 // packages/block-editor/build-module/components/media-placeholder/index.js 49970 var import_components174 = __toESM(require_components()); 49971 var import_i18n163 = __toESM(require_i18n()); 49972 var import_element173 = __toESM(require_element()); 49973 var import_data147 = __toESM(require_data()); 49974 var import_deprecated26 = __toESM(require_deprecated()); 49975 49976 // packages/block-editor/build-module/components/url-popover/index.js 49977 var import_i18n162 = __toESM(require_i18n()); 49978 var import_element172 = __toESM(require_element()); 49979 var import_components173 = __toESM(require_components()); 49980 var import_deprecated25 = __toESM(require_deprecated()); 49981 49982 // packages/block-editor/build-module/components/url-popover/link-viewer.js 49983 var import_i18n159 = __toESM(require_i18n()); 49984 var import_components170 = __toESM(require_components()); 49985 49986 // packages/block-editor/build-module/components/url-popover/link-viewer-url.js 49987 var import_components169 = __toESM(require_components()); 49988 var import_url8 = __toESM(require_url()); 49989 var import_jsx_runtime321 = __toESM(require_jsx_runtime()); 49990 function LinkViewerURL({ url, urlLabel, className }) { 49991 const linkClassName = clsx_default( 49992 className, 49993 "block-editor-url-popover__link-viewer-url" 49994 ); 49995 if (!url) { 49996 return /* @__PURE__ */ (0, import_jsx_runtime321.jsx)("span", { className: linkClassName }); 49997 } 49998 return /* @__PURE__ */ (0, import_jsx_runtime321.jsx)(import_components169.ExternalLink, { className: linkClassName, href: url, children: urlLabel || (0, import_url8.filterURLForDisplay)((0, import_url8.safeDecodeURI)(url)) }); 49999 } 50000 50001 // packages/block-editor/build-module/components/url-popover/link-viewer.js 50002 var import_jsx_runtime322 = __toESM(require_jsx_runtime()); 50003 function LinkViewer({ 50004 className, 50005 linkClassName, 50006 onEditLinkClick, 50007 url, 50008 urlLabel, 50009 ...props 50010 }) { 50011 return /* @__PURE__ */ (0, import_jsx_runtime322.jsxs)( 50012 "div", 50013 { 50014 className: clsx_default( 50015 "block-editor-url-popover__link-viewer", 50016 className 50017 ), 50018 ...props, 50019 children: [ 50020 /* @__PURE__ */ (0, import_jsx_runtime322.jsx)( 50021 LinkViewerURL, 50022 { 50023 url, 50024 urlLabel, 50025 className: linkClassName 50026 } 50027 ), 50028 onEditLinkClick && /* @__PURE__ */ (0, import_jsx_runtime322.jsx)( 50029 import_components170.Button, 50030 { 50031 icon: pencil_default, 50032 label: (0, import_i18n159.__)("Edit"), 50033 onClick: onEditLinkClick, 50034 size: "compact" 50035 } 50036 ) 50037 ] 50038 } 50039 ); 50040 } 50041 50042 // packages/block-editor/build-module/components/url-popover/link-editor.js 50043 var import_i18n161 = __toESM(require_i18n()); 50044 var import_components172 = __toESM(require_components()); 50045 50046 // packages/block-editor/build-module/components/url-input/index.js 50047 var import_i18n160 = __toESM(require_i18n()); 50048 var import_element171 = __toESM(require_element()); 50049 var import_keycodes18 = __toESM(require_keycodes()); 50050 var import_components171 = __toESM(require_components()); 50051 var import_compose85 = __toESM(require_compose()); 50052 var import_data146 = __toESM(require_data()); 50053 var import_url9 = __toESM(require_url()); 50054 var import_jsx_runtime323 = __toESM(require_jsx_runtime()); 50055 var import_react4 = __toESM(require_react()); 50056 function isFunction(maybeFunc) { 50057 return typeof maybeFunc === "function"; 50058 } 50059 var URLInput = class extends import_element171.Component { 50060 constructor(props) { 50061 super(props); 50062 this.onChange = this.onChange.bind(this); 50063 this.onFocus = this.onFocus.bind(this); 50064 this.onKeyDown = this.onKeyDown.bind(this); 50065 this.selectLink = this.selectLink.bind(this); 50066 this.handleOnClick = this.handleOnClick.bind(this); 50067 this.bindSuggestionNode = this.bindSuggestionNode.bind(this); 50068 this.autocompleteRef = props.autocompleteRef || (0, import_element171.createRef)(); 50069 this.inputRef = props.inputRef || (0, import_element171.createRef)(); 50070 this.updateSuggestions = (0, import_compose85.debounce)( 50071 this.updateSuggestions.bind(this), 50072 200 50073 ); 50074 this.suggestionNodes = []; 50075 this.suggestionsRequest = null; 50076 this.state = { 50077 suggestions: [], 50078 showSuggestions: false, 50079 suggestionsValue: null, 50080 selectedSuggestion: null, 50081 suggestionsListboxId: "", 50082 suggestionOptionIdPrefix: "" 50083 }; 50084 } 50085 componentDidUpdate(prevProps) { 50086 const { showSuggestions, selectedSuggestion } = this.state; 50087 const { value, __experimentalShowInitialSuggestions = false } = this.props; 50088 if (showSuggestions && selectedSuggestion !== null && this.suggestionNodes[selectedSuggestion]) { 50089 this.suggestionNodes[selectedSuggestion].scrollIntoView({ 50090 behavior: "instant", 50091 block: "nearest", 50092 inline: "nearest" 50093 }); 50094 } 50095 if (prevProps.value !== value && !this.props.disableSuggestions) { 50096 if (value?.length) { 50097 this.updateSuggestions(value); 50098 } else if (__experimentalShowInitialSuggestions) { 50099 this.updateSuggestions(); 50100 } 50101 } 50102 } 50103 componentDidMount() { 50104 if (this.shouldShowInitialSuggestions()) { 50105 this.updateSuggestions(); 50106 } 50107 } 50108 componentWillUnmount() { 50109 this.suggestionsRequest?.cancel?.(); 50110 this.suggestionsRequest = null; 50111 } 50112 bindSuggestionNode(index) { 50113 return (ref) => { 50114 this.suggestionNodes[index] = ref; 50115 }; 50116 } 50117 shouldShowInitialSuggestions() { 50118 const { __experimentalShowInitialSuggestions = false, value } = this.props; 50119 return __experimentalShowInitialSuggestions && !(value && value.length); 50120 } 50121 updateSuggestions(value = "") { 50122 const { 50123 __experimentalFetchLinkSuggestions: fetchLinkSuggestions, 50124 __experimentalHandleURLSuggestions: handleURLSuggestions 50125 } = this.props; 50126 if (!fetchLinkSuggestions) { 50127 return; 50128 } 50129 const isInitialSuggestions = !value?.length; 50130 value = value.trim(); 50131 if (!isInitialSuggestions && (value.length < 2 || !handleURLSuggestions && (0, import_url9.isURL)(value))) { 50132 this.suggestionsRequest?.cancel?.(); 50133 this.suggestionsRequest = null; 50134 this.setState({ 50135 suggestions: [], 50136 showSuggestions: false, 50137 suggestionsValue: value, 50138 selectedSuggestion: null, 50139 loading: false 50140 }); 50141 return; 50142 } 50143 this.setState({ 50144 selectedSuggestion: null, 50145 loading: true 50146 }); 50147 const request = fetchLinkSuggestions(value, { 50148 isInitialSuggestions 50149 }); 50150 request.then((suggestions) => { 50151 if (this.suggestionsRequest !== request) { 50152 return; 50153 } 50154 this.setState({ 50155 suggestions, 50156 suggestionsValue: value, 50157 loading: false, 50158 showSuggestions: !!suggestions.length 50159 }); 50160 if (!!suggestions.length) { 50161 this.props.debouncedSpeak( 50162 (0, import_i18n160.sprintf)( 50163 /* translators: %d: number of results. */ 50164 (0, import_i18n160._n)( 50165 "%d result found, use up and down arrow keys to navigate.", 50166 "%d results found, use up and down arrow keys to navigate.", 50167 suggestions.length 50168 ), 50169 suggestions.length 50170 ), 50171 "assertive" 50172 ); 50173 } else { 50174 this.props.debouncedSpeak( 50175 (0, import_i18n160.__)("No results."), 50176 "assertive" 50177 ); 50178 } 50179 }).catch(() => { 50180 if (this.suggestionsRequest !== request) { 50181 return; 50182 } 50183 this.setState({ 50184 loading: false 50185 }); 50186 }).finally(() => { 50187 if (this.suggestionsRequest === request) { 50188 this.suggestionsRequest = null; 50189 } 50190 }); 50191 this.suggestionsRequest = request; 50192 } 50193 onChange(newValue) { 50194 this.props.onChange(newValue); 50195 } 50196 onFocus() { 50197 const { suggestions } = this.state; 50198 const { disableSuggestions, value } = this.props; 50199 if (value && !disableSuggestions && !(suggestions && suggestions.length) && this.suggestionsRequest === null) { 50200 this.updateSuggestions(value); 50201 } 50202 } 50203 onKeyDown(event) { 50204 this.props.onKeyDown?.(event); 50205 const { showSuggestions, selectedSuggestion, suggestions, loading } = this.state; 50206 if (!showSuggestions || !suggestions.length || loading) { 50207 switch (event.keyCode) { 50208 // When UP is pressed, if the caret is at the start of the text, move it to the 0 50209 // position. 50210 case import_keycodes18.UP: { 50211 if (0 !== event.target.selectionStart) { 50212 event.preventDefault(); 50213 event.target.setSelectionRange(0, 0); 50214 } 50215 break; 50216 } 50217 // When DOWN is pressed, if the caret is not at the end of the text, move it to the 50218 // last position. 50219 case import_keycodes18.DOWN: { 50220 if (this.props.value.length !== event.target.selectionStart) { 50221 event.preventDefault(); 50222 event.target.setSelectionRange( 50223 this.props.value.length, 50224 this.props.value.length 50225 ); 50226 } 50227 break; 50228 } 50229 // Submitting while loading should trigger onSubmit. 50230 case import_keycodes18.ENTER: { 50231 if (this.props.onSubmit) { 50232 event.preventDefault(); 50233 this.props.onSubmit(null, event); 50234 } 50235 break; 50236 } 50237 } 50238 return; 50239 } 50240 const suggestion = this.state.suggestions[this.state.selectedSuggestion]; 50241 switch (event.keyCode) { 50242 case import_keycodes18.UP: { 50243 event.preventDefault(); 50244 const previousIndex = !selectedSuggestion ? suggestions.length - 1 : selectedSuggestion - 1; 50245 this.setState({ 50246 selectedSuggestion: previousIndex 50247 }); 50248 break; 50249 } 50250 case import_keycodes18.DOWN: { 50251 event.preventDefault(); 50252 const nextIndex = selectedSuggestion === null || selectedSuggestion === suggestions.length - 1 ? 0 : selectedSuggestion + 1; 50253 this.setState({ 50254 selectedSuggestion: nextIndex 50255 }); 50256 break; 50257 } 50258 case import_keycodes18.TAB: { 50259 if (this.state.selectedSuggestion !== null) { 50260 this.selectLink(suggestion); 50261 this.props.speak((0, import_i18n160.__)("Link selected.")); 50262 } 50263 break; 50264 } 50265 case import_keycodes18.ENTER: { 50266 event.preventDefault(); 50267 if (this.state.selectedSuggestion !== null) { 50268 this.selectLink(suggestion); 50269 if (this.props.onSubmit) { 50270 this.props.onSubmit(suggestion, event); 50271 } 50272 } else if (this.props.onSubmit) { 50273 this.props.onSubmit(null, event); 50274 } 50275 break; 50276 } 50277 } 50278 } 50279 selectLink(suggestion) { 50280 this.props.onChange(suggestion.url, suggestion); 50281 this.setState({ 50282 selectedSuggestion: null, 50283 showSuggestions: false 50284 }); 50285 } 50286 handleOnClick(suggestion) { 50287 this.selectLink(suggestion); 50288 this.inputRef.current.focus(); 50289 } 50290 static getDerivedStateFromProps({ 50291 value, 50292 instanceId, 50293 disableSuggestions, 50294 __experimentalShowInitialSuggestions = false 50295 }, { showSuggestions }) { 50296 let shouldShowSuggestions = showSuggestions; 50297 const hasValue = value && value.length; 50298 if (!__experimentalShowInitialSuggestions && !hasValue) { 50299 shouldShowSuggestions = false; 50300 } 50301 if (disableSuggestions === true) { 50302 shouldShowSuggestions = false; 50303 } 50304 return { 50305 showSuggestions: shouldShowSuggestions, 50306 suggestionsListboxId: `block-editor-url-input-suggestions-$instanceId}`, 50307 suggestionOptionIdPrefix: `block-editor-url-input-suggestion-$instanceId}` 50308 }; 50309 } 50310 render() { 50311 return /* @__PURE__ */ (0, import_jsx_runtime323.jsxs)(import_jsx_runtime323.Fragment, { children: [ 50312 this.renderControl(), 50313 this.renderSuggestions() 50314 ] }); 50315 } 50316 renderControl() { 50317 const { 50318 label = null, 50319 className, 50320 isFullWidth, 50321 instanceId, 50322 placeholder = (0, import_i18n160.__)("Paste URL or type to search"), 50323 __experimentalRenderControl: renderControl, 50324 value = "", 50325 hideLabelFromVision = false, 50326 help = null, 50327 disabled = false 50328 } = this.props; 50329 const { 50330 loading, 50331 showSuggestions, 50332 selectedSuggestion, 50333 suggestionsListboxId, 50334 suggestionOptionIdPrefix 50335 } = this.state; 50336 const inputId = `url-input-control-$instanceId}`; 50337 const controlProps = { 50338 id: inputId, 50339 // Passes attribute to label for the for attribute 50340 label, 50341 className: clsx_default("block-editor-url-input", className, { 50342 "is-full-width": isFullWidth 50343 }), 50344 hideLabelFromVision 50345 }; 50346 const inputProps = { 50347 id: inputId, 50348 value, 50349 required: true, 50350 type: "text", 50351 onChange: disabled ? () => { 50352 } : this.onChange, 50353 // Disable onChange when disabled 50354 onFocus: disabled ? () => { 50355 } : this.onFocus, 50356 // Disable onFocus when disabled 50357 placeholder, 50358 onKeyDown: disabled ? () => { 50359 } : this.onKeyDown, 50360 // Disable onKeyDown when disabled 50361 role: "combobox", 50362 "aria-label": label ? void 0 : (0, import_i18n160.__)("URL"), 50363 // Ensure input always has an accessible label 50364 "aria-expanded": showSuggestions, 50365 "aria-autocomplete": "list", 50366 "aria-owns": suggestionsListboxId, 50367 "aria-activedescendant": selectedSuggestion !== null ? `$suggestionOptionIdPrefix}-$selectedSuggestion}` : void 0, 50368 ref: this.inputRef, 50369 disabled, 50370 suffix: this.props.suffix, 50371 help 50372 }; 50373 if (renderControl) { 50374 return renderControl(controlProps, inputProps, loading); 50375 } 50376 return /* @__PURE__ */ (0, import_jsx_runtime323.jsxs)(import_components171.BaseControl, { ...controlProps, children: [ 50377 /* @__PURE__ */ (0, import_jsx_runtime323.jsx)(import_components171.__experimentalInputControl, { ...inputProps, __next40pxDefaultSize: true }), 50378 loading && /* @__PURE__ */ (0, import_jsx_runtime323.jsx)(import_components171.Spinner, {}) 50379 ] }); 50380 } 50381 renderSuggestions() { 50382 const { 50383 className, 50384 __experimentalRenderSuggestions: renderSuggestions 50385 } = this.props; 50386 const { 50387 showSuggestions, 50388 suggestions, 50389 suggestionsValue, 50390 selectedSuggestion, 50391 suggestionsListboxId, 50392 suggestionOptionIdPrefix, 50393 loading 50394 } = this.state; 50395 if (!showSuggestions || suggestions.length === 0) { 50396 return null; 50397 } 50398 const suggestionsListProps = { 50399 id: suggestionsListboxId, 50400 ref: this.autocompleteRef, 50401 role: "listbox" 50402 }; 50403 const buildSuggestionItemProps = (suggestion, index) => { 50404 return { 50405 role: "option", 50406 tabIndex: "-1", 50407 id: `$suggestionOptionIdPrefix}-$index}`, 50408 ref: this.bindSuggestionNode(index), 50409 "aria-selected": index === selectedSuggestion ? true : void 0 50410 }; 50411 }; 50412 if (isFunction(renderSuggestions)) { 50413 return renderSuggestions({ 50414 suggestions, 50415 selectedSuggestion, 50416 suggestionsListProps, 50417 buildSuggestionItemProps, 50418 isLoading: loading, 50419 handleSuggestionClick: this.handleOnClick, 50420 isInitialSuggestions: !suggestionsValue?.length, 50421 currentInputValue: suggestionsValue 50422 }); 50423 } 50424 return /* @__PURE__ */ (0, import_jsx_runtime323.jsx)(import_components171.Popover, { placement: "bottom", focusOnMount: false, children: /* @__PURE__ */ (0, import_jsx_runtime323.jsx)( 50425 "div", 50426 { 50427 ...suggestionsListProps, 50428 className: clsx_default("block-editor-url-input__suggestions", { 50429 [`$className}__suggestions`]: className 50430 }), 50431 children: suggestions.map((suggestion, index) => /* @__PURE__ */ (0, import_react4.createElement)( 50432 import_components171.Button, 50433 { 50434 __next40pxDefaultSize: true, 50435 ...buildSuggestionItemProps(suggestion, index), 50436 key: suggestion.id, 50437 className: clsx_default( 50438 "block-editor-url-input__suggestion", 50439 { 50440 "is-selected": index === selectedSuggestion 50441 } 50442 ), 50443 onClick: () => this.handleOnClick(suggestion) 50444 }, 50445 suggestion.title 50446 )) 50447 } 50448 ) }); 50449 } 50450 }; 50451 var url_input_default = (0, import_compose85.compose)( 50452 import_compose85.withSafeTimeout, 50453 import_components171.withSpokenMessages, 50454 import_compose85.withInstanceId, 50455 (0, import_data146.withSelect)((select3, props) => { 50456 if (isFunction(props.__experimentalFetchLinkSuggestions)) { 50457 return; 50458 } 50459 const { getSettings: getSettings8 } = select3(store); 50460 return { 50461 __experimentalFetchLinkSuggestions: getSettings8().__experimentalFetchLinkSuggestions 50462 }; 50463 }) 50464 )(URLInput); 50465 50466 // packages/block-editor/build-module/components/url-popover/link-editor.js 50467 var import_jsx_runtime324 = __toESM(require_jsx_runtime()); 50468 function LinkEditor({ 50469 autocompleteRef, 50470 className, 50471 onChangeInputValue, 50472 value, 50473 ...props 50474 }) { 50475 return /* @__PURE__ */ (0, import_jsx_runtime324.jsxs)( 50476 "form", 50477 { 50478 className: clsx_default( 50479 "block-editor-url-popover__link-editor", 50480 className 50481 ), 50482 ...props, 50483 children: [ 50484 /* @__PURE__ */ (0, import_jsx_runtime324.jsx)( 50485 url_input_default, 50486 { 50487 value, 50488 onChange: onChangeInputValue, 50489 autocompleteRef 50490 } 50491 ), 50492 /* @__PURE__ */ (0, import_jsx_runtime324.jsx)( 50493 import_components172.Button, 50494 { 50495 icon: keyboard_return_default, 50496 label: (0, import_i18n161.__)("Apply"), 50497 type: "submit", 50498 size: "compact" 50499 } 50500 ) 50501 ] 50502 } 50503 ); 50504 } 50505 50506 // packages/block-editor/build-module/components/url-popover/index.js 50507 var import_jsx_runtime325 = __toESM(require_jsx_runtime()); 50508 var { __experimentalPopoverLegacyPositionToPlacement } = unlock( 50509 import_components173.privateApis 50510 ); 50511 var DEFAULT_PLACEMENT = "bottom"; 50512 var URLPopover = (0, import_element172.forwardRef)( 50513 ({ 50514 additionalControls, 50515 children, 50516 renderSettings, 50517 // The DEFAULT_PLACEMENT value is assigned inside the function's body 50518 placement, 50519 focusOnMount = "firstElement", 50520 // Deprecated 50521 position, 50522 // Rest 50523 ...popoverProps3 50524 }, ref) => { 50525 if (position !== void 0) { 50526 (0, import_deprecated25.default)("`position` prop in wp.blockEditor.URLPopover", { 50527 since: "6.2", 50528 alternative: "`placement` prop" 50529 }); 50530 } 50531 let computedPlacement; 50532 if (placement !== void 0) { 50533 computedPlacement = placement; 50534 } else if (position !== void 0) { 50535 computedPlacement = __experimentalPopoverLegacyPositionToPlacement(position); 50536 } 50537 computedPlacement = computedPlacement || DEFAULT_PLACEMENT; 50538 const [isSettingsExpanded, setIsSettingsExpanded] = (0, import_element172.useState)(false); 50539 const showSettings = !!renderSettings && isSettingsExpanded; 50540 const toggleSettingsVisibility = () => { 50541 setIsSettingsExpanded(!isSettingsExpanded); 50542 }; 50543 return /* @__PURE__ */ (0, import_jsx_runtime325.jsxs)( 50544 import_components173.Popover, 50545 { 50546 ref, 50547 role: "dialog", 50548 "aria-modal": "true", 50549 "aria-label": (0, import_i18n162.__)("Edit URL"), 50550 className: "block-editor-url-popover", 50551 focusOnMount, 50552 placement: computedPlacement, 50553 shift: true, 50554 variant: "toolbar", 50555 ...popoverProps3, 50556 children: [ 50557 /* @__PURE__ */ (0, import_jsx_runtime325.jsx)("div", { className: "block-editor-url-popover__input-container", children: /* @__PURE__ */ (0, import_jsx_runtime325.jsxs)("div", { className: "block-editor-url-popover__row", children: [ 50558 children, 50559 !!renderSettings && /* @__PURE__ */ (0, import_jsx_runtime325.jsx)( 50560 import_components173.Button, 50561 { 50562 className: "block-editor-url-popover__settings-toggle", 50563 icon: chevron_down_default, 50564 label: (0, import_i18n162.__)("Link settings"), 50565 onClick: toggleSettingsVisibility, 50566 "aria-expanded": isSettingsExpanded, 50567 size: "compact" 50568 } 50569 ) 50570 ] }) }), 50571 showSettings && /* @__PURE__ */ (0, import_jsx_runtime325.jsx)("div", { className: "block-editor-url-popover__settings", children: renderSettings() }), 50572 additionalControls && !showSettings && /* @__PURE__ */ (0, import_jsx_runtime325.jsx)("div", { className: "block-editor-url-popover__additional-controls", children: additionalControls }) 50573 ] 50574 } 50575 ); 50576 } 50577 ); 50578 URLPopover.LinkEditor = LinkEditor; 50579 URLPopover.LinkViewer = LinkViewer; 50580 var url_popover_default = URLPopover; 50581 50582 // packages/block-editor/build-module/components/media-placeholder/index.js 50583 var import_jsx_runtime326 = __toESM(require_jsx_runtime()); 50584 var noop17 = () => { 50585 }; 50586 var InsertFromURLPopover = ({ 50587 src, 50588 onChange, 50589 onSubmit, 50590 onClose, 50591 popoverAnchor 50592 }) => /* @__PURE__ */ (0, import_jsx_runtime326.jsx)(url_popover_default, { anchor: popoverAnchor, onClose, children: /* @__PURE__ */ (0, import_jsx_runtime326.jsx)( 50593 "form", 50594 { 50595 className: "block-editor-media-placeholder__url-input-form", 50596 onSubmit, 50597 children: /* @__PURE__ */ (0, import_jsx_runtime326.jsx)( 50598 import_components174.__experimentalInputControl, 50599 { 50600 __next40pxDefaultSize: true, 50601 label: (0, import_i18n163.__)("URL"), 50602 type: "text", 50603 hideLabelFromVision: true, 50604 placeholder: (0, import_i18n163.__)("Paste or type URL"), 50605 onChange, 50606 value: src, 50607 suffix: /* @__PURE__ */ (0, import_jsx_runtime326.jsx)(import_components174.__experimentalInputControlSuffixWrapper, { variant: "control", children: /* @__PURE__ */ (0, import_jsx_runtime326.jsx)( 50608 import_components174.Button, 50609 { 50610 size: "small", 50611 icon: keyboard_return_default, 50612 label: (0, import_i18n163.__)("Apply"), 50613 type: "submit" 50614 } 50615 ) }) 50616 } 50617 ) 50618 } 50619 ) }); 50620 var URLSelectionUI = ({ src, onChangeSrc, onSelectURL }) => { 50621 const [popoverAnchor, setPopoverAnchor] = (0, import_element173.useState)(null); 50622 const [isURLInputVisible, setIsURLInputVisible] = (0, import_element173.useState)(false); 50623 const openURLInput = () => { 50624 setIsURLInputVisible(true); 50625 }; 50626 const closeURLInput = () => { 50627 setIsURLInputVisible(false); 50628 popoverAnchor?.focus(); 50629 }; 50630 const onSubmitSrc = (event) => { 50631 event.preventDefault(); 50632 if (src && onSelectURL) { 50633 onSelectURL(src); 50634 closeURLInput(); 50635 } 50636 }; 50637 return /* @__PURE__ */ (0, import_jsx_runtime326.jsxs)("div", { className: "block-editor-media-placeholder__url-input-container", children: [ 50638 /* @__PURE__ */ (0, import_jsx_runtime326.jsx)( 50639 import_components174.Button, 50640 { 50641 __next40pxDefaultSize: true, 50642 className: "block-editor-media-placeholder__button", 50643 onClick: openURLInput, 50644 isPressed: isURLInputVisible, 50645 variant: "secondary", 50646 "aria-haspopup": "dialog", 50647 ref: setPopoverAnchor, 50648 children: (0, import_i18n163.__)("Insert from URL") 50649 } 50650 ), 50651 isURLInputVisible && /* @__PURE__ */ (0, import_jsx_runtime326.jsx)( 50652 InsertFromURLPopover, 50653 { 50654 src, 50655 onChange: onChangeSrc, 50656 onSubmit: onSubmitSrc, 50657 onClose: closeURLInput, 50658 popoverAnchor 50659 } 50660 ) 50661 ] }); 50662 }; 50663 function MediaPlaceholder({ 50664 value = {}, 50665 allowedTypes, 50666 className, 50667 icon, 50668 labels = {}, 50669 mediaPreview, 50670 notices, 50671 isAppender, 50672 accept, 50673 addToGallery, 50674 multiple = false, 50675 handleUpload = true, 50676 disableDropZone, 50677 disableMediaButtons, 50678 onError, 50679 onSelect, 50680 onCancel, 50681 onSelectURL, 50682 onToggleFeaturedImage, 50683 onDoubleClick, 50684 onFilesPreUpload = noop17, 50685 onHTMLDrop: deprecatedOnHTMLDrop, 50686 children, 50687 mediaLibraryButton, 50688 placeholder, 50689 style 50690 }) { 50691 if (deprecatedOnHTMLDrop) { 50692 (0, import_deprecated26.default)("wp.blockEditor.MediaPlaceholder onHTMLDrop prop", { 50693 since: "6.2", 50694 version: "6.4" 50695 }); 50696 } 50697 const { mediaUpload: mediaUpload2, allowedMimeTypes } = (0, import_data147.useSelect)((select3) => { 50698 const { getSettings: getSettings8 } = select3(store); 50699 const settings2 = getSettings8(); 50700 return { 50701 mediaUpload: settings2.mediaUpload, 50702 allowedMimeTypes: settings2.allowedMimeTypes 50703 }; 50704 }, []); 50705 const [src, setSrc] = (0, import_element173.useState)(""); 50706 (0, import_element173.useEffect)(() => { 50707 setSrc(value?.src ?? ""); 50708 }, [value?.src]); 50709 const computedAccept = (0, import_element173.useMemo)( 50710 () => getComputedAcceptAttribute( 50711 allowedTypes, 50712 allowedMimeTypes, 50713 accept 50714 ), 50715 [allowedTypes, allowedMimeTypes, accept] 50716 ); 50717 const onlyAllowsImages = () => { 50718 if (!allowedTypes || allowedTypes.length === 0) { 50719 return false; 50720 } 50721 return allowedTypes.every( 50722 (allowedType) => allowedType === "image" || allowedType.startsWith("image/") 50723 ); 50724 }; 50725 const onFilesUpload = (files) => { 50726 if (!handleUpload || typeof handleUpload === "function" && !handleUpload(files)) { 50727 return onSelect(files); 50728 } 50729 onFilesPreUpload(files); 50730 let setMedia; 50731 if (multiple) { 50732 if (addToGallery) { 50733 let lastMediaPassed = []; 50734 setMedia = (newMedia) => { 50735 const filteredMedia = (value ?? []).filter((item) => { 50736 if (item.id) { 50737 return !lastMediaPassed.some( 50738 // Be sure to convert to number for comparison. 50739 ({ id }) => Number(id) === Number(item.id) 50740 ); 50741 } 50742 return !lastMediaPassed.some( 50743 ({ urlSlug }) => item.url.includes(urlSlug) 50744 ); 50745 }); 50746 onSelect(filteredMedia.concat(newMedia)); 50747 lastMediaPassed = newMedia.map((media) => { 50748 const cutOffIndex = media.url.lastIndexOf("."); 50749 const urlSlug = media.url.slice(0, cutOffIndex); 50750 return { id: media.id, urlSlug }; 50751 }); 50752 }; 50753 } else { 50754 setMedia = onSelect; 50755 } 50756 } else { 50757 setMedia = ([media]) => onSelect(media); 50758 } 50759 mediaUpload2({ 50760 allowedTypes, 50761 filesList: files, 50762 onFileChange: setMedia, 50763 onError, 50764 multiple 50765 }); 50766 }; 50767 async function handleBlocksDrop(event) { 50768 const { blocks: blocks2 } = parseDropEvent(event); 50769 if (!blocks2?.length) { 50770 return; 50771 } 50772 const uploadedMediaList = await Promise.all( 50773 blocks2.map((block) => { 50774 const blockType = block.name.split("/")[1]; 50775 if (block.attributes.id) { 50776 block.attributes.type = blockType; 50777 return block.attributes; 50778 } 50779 return new Promise((resolve, reject) => { 50780 window.fetch(block.attributes.url).then((response) => response.blob()).then( 50781 (blob) => mediaUpload2({ 50782 filesList: [blob], 50783 additionalData: { 50784 title: block.attributes.title, 50785 alt_text: block.attributes.alt, 50786 caption: block.attributes.caption, 50787 type: blockType 50788 }, 50789 onFileChange: ([media]) => { 50790 if (media.id) { 50791 resolve(media); 50792 } 50793 }, 50794 allowedTypes, 50795 onError: reject 50796 }) 50797 ).catch(() => resolve(block.attributes.url)); 50798 }); 50799 }) 50800 ).catch((err) => onError(err)); 50801 if (!uploadedMediaList?.length) { 50802 return; 50803 } 50804 onSelect(multiple ? uploadedMediaList : uploadedMediaList[0]); 50805 } 50806 const onUpload = (event) => { 50807 onFilesUpload(event.target.files); 50808 }; 50809 const defaultRenderPlaceholder = (content) => { 50810 let { instructions, title } = labels; 50811 if (!mediaUpload2 && !onSelectURL) { 50812 instructions = (0, import_i18n163.__)( 50813 "To edit this block, you need permission to upload media." 50814 ); 50815 } 50816 if (instructions === void 0 || title === void 0) { 50817 const typesAllowed = allowedTypes ?? []; 50818 const [firstAllowedType] = typesAllowed; 50819 const isOneType = 1 === typesAllowed.length; 50820 const isAudio = isOneType && "audio" === firstAllowedType; 50821 const isImage = isOneType && "image" === firstAllowedType; 50822 const isVideo = isOneType && "video" === firstAllowedType; 50823 if (instructions === void 0 && mediaUpload2) { 50824 instructions = (0, import_i18n163.__)( 50825 "Drag and drop an image or video, upload, or choose from your library." 50826 ); 50827 if (isAudio) { 50828 instructions = (0, import_i18n163.__)( 50829 "Drag and drop an audio file, upload, or choose from your library." 50830 ); 50831 } else if (isImage) { 50832 instructions = (0, import_i18n163.__)( 50833 "Drag and drop an image, upload, or choose from your library." 50834 ); 50835 } else if (isVideo) { 50836 instructions = (0, import_i18n163.__)( 50837 "Drag and drop a video, upload, or choose from your library." 50838 ); 50839 } 50840 } 50841 if (title === void 0) { 50842 title = (0, import_i18n163.__)("Media"); 50843 if (isAudio) { 50844 title = (0, import_i18n163.__)("Audio"); 50845 } else if (isImage) { 50846 title = (0, import_i18n163.__)("Image"); 50847 } else if (isVideo) { 50848 title = (0, import_i18n163.__)("Video"); 50849 } 50850 } 50851 } 50852 const placeholderClassName = clsx_default( 50853 "block-editor-media-placeholder", 50854 className, 50855 { 50856 "is-appender": isAppender 50857 } 50858 ); 50859 return /* @__PURE__ */ (0, import_jsx_runtime326.jsxs)( 50860 import_components174.Placeholder, 50861 { 50862 icon, 50863 label: title, 50864 instructions, 50865 className: placeholderClassName, 50866 notices, 50867 onDoubleClick, 50868 preview: mediaPreview, 50869 style, 50870 children: [ 50871 content, 50872 children 50873 ] 50874 } 50875 ); 50876 }; 50877 const renderPlaceholder = placeholder ?? defaultRenderPlaceholder; 50878 const renderDropZone = () => { 50879 if (disableDropZone) { 50880 return null; 50881 } 50882 return /* @__PURE__ */ (0, import_jsx_runtime326.jsx)( 50883 import_components174.DropZone, 50884 { 50885 onFilesDrop: onFilesUpload, 50886 onDrop: handleBlocksDrop, 50887 isEligible: (dataTransfer) => { 50888 const prefix2 = "wp-block:core/"; 50889 const types = []; 50890 for (const type of dataTransfer.types) { 50891 if (type.startsWith(prefix2)) { 50892 types.push(type.slice(prefix2.length)); 50893 } 50894 } 50895 return types.every( 50896 (type) => allowedTypes.includes(type) 50897 ) && (multiple ? true : types.length === 1); 50898 } 50899 } 50900 ); 50901 }; 50902 const renderCancelLink = () => { 50903 return onCancel && /* @__PURE__ */ (0, import_jsx_runtime326.jsx)( 50904 import_components174.Button, 50905 { 50906 __next40pxDefaultSize: true, 50907 className: "block-editor-media-placeholder__cancel-button", 50908 title: (0, import_i18n163.__)("Cancel"), 50909 variant: "link", 50910 onClick: onCancel, 50911 children: (0, import_i18n163.__)("Cancel") 50912 } 50913 ); 50914 }; 50915 const renderUrlSelectionUI = () => { 50916 return onSelectURL && /* @__PURE__ */ (0, import_jsx_runtime326.jsx)( 50917 URLSelectionUI, 50918 { 50919 src, 50920 onChangeSrc: setSrc, 50921 onSelectURL 50922 } 50923 ); 50924 }; 50925 const renderFeaturedImageToggle = () => { 50926 return onToggleFeaturedImage && /* @__PURE__ */ (0, import_jsx_runtime326.jsx)("div", { className: "block-editor-media-placeholder__url-input-container", children: /* @__PURE__ */ (0, import_jsx_runtime326.jsx)( 50927 import_components174.Button, 50928 { 50929 __next40pxDefaultSize: true, 50930 className: "block-editor-media-placeholder__button", 50931 onClick: onToggleFeaturedImage, 50932 variant: "secondary", 50933 children: (0, import_i18n163.__)("Use featured image") 50934 } 50935 ) }); 50936 }; 50937 const renderMediaUploadChecked = () => { 50938 const defaultButton = ({ open }) => { 50939 return /* @__PURE__ */ (0, import_jsx_runtime326.jsx)( 50940 import_components174.Button, 50941 { 50942 __next40pxDefaultSize: true, 50943 variant: "secondary", 50944 onClick: () => { 50945 open(); 50946 }, 50947 children: (0, import_i18n163.__)("Media Library") 50948 } 50949 ); 50950 }; 50951 const libraryButton = mediaLibraryButton ?? defaultButton; 50952 const uploadMediaLibraryButton = /* @__PURE__ */ (0, import_jsx_runtime326.jsx)( 50953 media_upload_default, 50954 { 50955 addToGallery, 50956 gallery: multiple && onlyAllowsImages(), 50957 multiple, 50958 onSelect, 50959 allowedTypes, 50960 mode: "browse", 50961 value: Array.isArray(value) ? value.map(({ id }) => id) : value.id, 50962 render: libraryButton 50963 } 50964 ); 50965 if (mediaUpload2 && isAppender) { 50966 return /* @__PURE__ */ (0, import_jsx_runtime326.jsxs)(import_jsx_runtime326.Fragment, { children: [ 50967 renderDropZone(), 50968 /* @__PURE__ */ (0, import_jsx_runtime326.jsx)( 50969 import_components174.FormFileUpload, 50970 { 50971 onChange: onUpload, 50972 accept: computedAccept, 50973 multiple: !!multiple, 50974 render: ({ openFileDialog }) => { 50975 const content = /* @__PURE__ */ (0, import_jsx_runtime326.jsxs)(import_jsx_runtime326.Fragment, { children: [ 50976 /* @__PURE__ */ (0, import_jsx_runtime326.jsx)( 50977 import_components174.Button, 50978 { 50979 __next40pxDefaultSize: true, 50980 variant: "primary", 50981 className: clsx_default( 50982 "block-editor-media-placeholder__button", 50983 "block-editor-media-placeholder__upload-button" 50984 ), 50985 onClick: openFileDialog, 50986 children: (0, import_i18n163._x)("Upload", "verb") 50987 } 50988 ), 50989 uploadMediaLibraryButton, 50990 renderUrlSelectionUI(), 50991 renderFeaturedImageToggle(), 50992 renderCancelLink() 50993 ] }); 50994 return renderPlaceholder(content); 50995 } 50996 } 50997 ) 50998 ] }); 50999 } 51000 if (mediaUpload2) { 51001 const content = /* @__PURE__ */ (0, import_jsx_runtime326.jsxs)(import_jsx_runtime326.Fragment, { children: [ 51002 renderDropZone(), 51003 /* @__PURE__ */ (0, import_jsx_runtime326.jsx)( 51004 import_components174.FormFileUpload, 51005 { 51006 render: ({ openFileDialog }) => /* @__PURE__ */ (0, import_jsx_runtime326.jsx)( 51007 import_components174.Button, 51008 { 51009 __next40pxDefaultSize: true, 51010 onClick: openFileDialog, 51011 variant: "primary", 51012 className: clsx_default( 51013 "block-editor-media-placeholder__button", 51014 "block-editor-media-placeholder__upload-button" 51015 ), 51016 children: (0, import_i18n163._x)("Upload", "verb") 51017 } 51018 ), 51019 onChange: onUpload, 51020 accept: computedAccept, 51021 multiple: !!multiple 51022 } 51023 ), 51024 uploadMediaLibraryButton, 51025 renderUrlSelectionUI(), 51026 renderFeaturedImageToggle(), 51027 renderCancelLink() 51028 ] }); 51029 return renderPlaceholder(content); 51030 } 51031 return renderPlaceholder(uploadMediaLibraryButton); 51032 }; 51033 if (disableMediaButtons) { 51034 return /* @__PURE__ */ (0, import_jsx_runtime326.jsx)(check_default2, { children: renderDropZone() }); 51035 } 51036 return /* @__PURE__ */ (0, import_jsx_runtime326.jsx)( 51037 check_default2, 51038 { 51039 fallback: renderPlaceholder(renderUrlSelectionUI()), 51040 children: renderMediaUploadChecked() 51041 } 51042 ); 51043 } 51044 var media_placeholder_default = (0, import_components174.withFilters)("editor.MediaPlaceholder")(MediaPlaceholder); 51045 51046 // packages/block-editor/build-module/components/panel-color-settings/index.js 51047 var import_jsx_runtime327 = __toESM(require_jsx_runtime()); 51048 var PanelColorSettings = ({ colorSettings, ...props }) => { 51049 const settings2 = colorSettings.map((setting) => { 51050 if (!setting) { 51051 return setting; 51052 } 51053 const { value, onChange, ...otherSettings } = setting; 51054 return { 51055 ...otherSettings, 51056 colorValue: value, 51057 onColorChange: onChange 51058 }; 51059 }); 51060 return /* @__PURE__ */ (0, import_jsx_runtime327.jsx)( 51061 panel_color_gradient_settings_default, 51062 { 51063 settings: settings2, 51064 gradients: [], 51065 disableCustomGradients: true, 51066 ...props 51067 } 51068 ); 51069 }; 51070 var panel_color_settings_default = PanelColorSettings; 51071 51072 // packages/block-editor/build-module/components/plain-text/index.js 51073 var import_react_autosize_textarea2 = __toESM(require_lib()); 51074 var import_element186 = __toESM(require_element()); 51075 51076 // packages/block-editor/build-module/components/editable-text/index.js 51077 var import_element185 = __toESM(require_element()); 51078 51079 // packages/block-editor/build-module/components/rich-text/index.js 51080 var import_es65 = __toESM(require_es6()); 51081 var import_element184 = __toESM(require_element()); 51082 var import_data151 = __toESM(require_data()); 51083 var import_compose87 = __toESM(require_compose()); 51084 var import_rich_text15 = __toESM(require_rich_text()); 51085 var import_components178 = __toESM(require_components()); 51086 var import_blocks86 = __toESM(require_blocks()); 51087 var import_deprecated30 = __toESM(require_deprecated()); 51088 var import_i18n166 = __toESM(require_i18n()); 51089 51090 // packages/block-editor/build-module/components/rich-text/format-toolbar-container.js 51091 var import_i18n165 = __toESM(require_i18n()); 51092 var import_components176 = __toESM(require_components()); 51093 51094 // packages/block-editor/build-module/components/rich-text/format-toolbar/index.js 51095 var import_i18n164 = __toESM(require_i18n()); 51096 var import_components175 = __toESM(require_components()); 51097 var import_jsx_runtime328 = __toESM(require_jsx_runtime()); 51098 var POPOVER_PROPS8 = { 51099 placement: "bottom-start" 51100 }; 51101 var FormatToolbar = () => { 51102 return /* @__PURE__ */ (0, import_jsx_runtime328.jsxs)(import_jsx_runtime328.Fragment, { children: [ 51103 ["bold", "italic", "link", "unknown"].map((format6) => /* @__PURE__ */ (0, import_jsx_runtime328.jsx)( 51104 import_components175.Slot, 51105 { 51106 name: `RichText.ToolbarControls.$format6}` 51107 }, 51108 format6 51109 )), 51110 /* @__PURE__ */ (0, import_jsx_runtime328.jsx)(import_components175.Slot, { name: "RichText.ToolbarControls", children: (fills) => { 51111 if (!fills.length) { 51112 return null; 51113 } 51114 const allProps = fills.map(([{ props }]) => props); 51115 const hasActive = allProps.some( 51116 ({ isActive }) => isActive 51117 ); 51118 return /* @__PURE__ */ (0, import_jsx_runtime328.jsx)(import_components175.ToolbarItem, { children: (toggleProps) => /* @__PURE__ */ (0, import_jsx_runtime328.jsx)( 51119 import_components175.DropdownMenu, 51120 { 51121 icon: chevron_down_default, 51122 label: (0, import_i18n164.__)("More"), 51123 toggleProps: { 51124 ...toggleProps, 51125 className: clsx_default( 51126 toggleProps.className, 51127 { "is-pressed": hasActive } 51128 ), 51129 description: (0, import_i18n164.__)( 51130 "Displays more block tools" 51131 ) 51132 }, 51133 controls: orderBy( 51134 fills.map(([{ props }]) => props), 51135 "title" 51136 ), 51137 popoverProps: POPOVER_PROPS8 51138 } 51139 ) }); 51140 } }) 51141 ] }); 51142 }; 51143 var format_toolbar_default = FormatToolbar; 51144 51145 // packages/block-editor/build-module/components/rich-text/format-toolbar-container.js 51146 var import_jsx_runtime329 = __toESM(require_jsx_runtime()); 51147 function InlineToolbar({ popoverAnchor }) { 51148 return /* @__PURE__ */ (0, import_jsx_runtime329.jsx)( 51149 import_components176.Popover, 51150 { 51151 placement: "top", 51152 focusOnMount: false, 51153 anchor: popoverAnchor, 51154 className: "block-editor-rich-text__inline-format-toolbar", 51155 __unstableSlotName: "block-toolbar", 51156 children: /* @__PURE__ */ (0, import_jsx_runtime329.jsx)( 51157 NavigableToolbar, 51158 { 51159 className: "block-editor-rich-text__inline-format-toolbar-group", 51160 "aria-label": (0, import_i18n165.__)("Format tools"), 51161 children: /* @__PURE__ */ (0, import_jsx_runtime329.jsx)(import_components176.ToolbarGroup, { children: /* @__PURE__ */ (0, import_jsx_runtime329.jsx)(format_toolbar_default, {}) }) 51162 } 51163 ) 51164 } 51165 ); 51166 } 51167 var FormatToolbarContainer = ({ inline, editableContentElement }) => { 51168 if (inline) { 51169 return /* @__PURE__ */ (0, import_jsx_runtime329.jsx)(InlineToolbar, { popoverAnchor: editableContentElement }); 51170 } 51171 return /* @__PURE__ */ (0, import_jsx_runtime329.jsx)(block_controls_default, { group: "inline", children: /* @__PURE__ */ (0, import_jsx_runtime329.jsx)(format_toolbar_default, {}) }); 51172 }; 51173 var format_toolbar_container_default = FormatToolbarContainer; 51174 51175 // packages/block-editor/build-module/components/rich-text/use-mark-persistent.js 51176 var import_element174 = __toESM(require_element()); 51177 var import_data148 = __toESM(require_data()); 51178 function useMarkPersistent({ html, value }) { 51179 const previousTextRef = (0, import_element174.useRef)(); 51180 const hasActiveFormats = !!value.activeFormats?.length; 51181 const { __unstableMarkLastChangeAsPersistent: __unstableMarkLastChangeAsPersistent2 } = (0, import_data148.useDispatch)(store); 51182 (0, import_element174.useLayoutEffect)(() => { 51183 if (!previousTextRef.current) { 51184 previousTextRef.current = value.text; 51185 return; 51186 } 51187 if (previousTextRef.current !== value.text) { 51188 const timeout = window.setTimeout(() => { 51189 __unstableMarkLastChangeAsPersistent2(); 51190 }, 1e3); 51191 previousTextRef.current = value.text; 51192 return () => { 51193 window.clearTimeout(timeout); 51194 }; 51195 } 51196 __unstableMarkLastChangeAsPersistent2(); 51197 }, [html, hasActiveFormats]); 51198 } 51199 51200 // packages/block-editor/build-module/components/rich-text/use-format-types.js 51201 var import_element175 = __toESM(require_element()); 51202 var import_data149 = __toESM(require_data()); 51203 var import_rich_text5 = __toESM(require_rich_text()); 51204 function formatTypesSelector(select3) { 51205 return select3(import_rich_text5.store).getFormatTypes(); 51206 } 51207 var interactiveContentTags = /* @__PURE__ */ new Set([ 51208 "a", 51209 "audio", 51210 "button", 51211 "details", 51212 "embed", 51213 "iframe", 51214 "input", 51215 "label", 51216 "select", 51217 "textarea", 51218 "video" 51219 ]); 51220 function prefixSelectKeys(selected, prefix2) { 51221 if (typeof selected !== "object") { 51222 return { [prefix2]: selected }; 51223 } 51224 return Object.fromEntries( 51225 Object.entries(selected).map(([key, value]) => [ 51226 `$prefix2}.$key}`, 51227 value 51228 ]) 51229 ); 51230 } 51231 function getPrefixedSelectKeys(selected, prefix2) { 51232 if (selected[prefix2]) { 51233 return selected[prefix2]; 51234 } 51235 return Object.keys(selected).filter((key) => key.startsWith(prefix2 + ".")).reduce((accumulator, key) => { 51236 accumulator[key.slice(prefix2.length + 1)] = selected[key]; 51237 return accumulator; 51238 }, {}); 51239 } 51240 function useFormatTypes({ 51241 clientId, 51242 identifier, 51243 allowedFormats, 51244 withoutInteractiveFormatting, 51245 disableNoneEssentialFormatting = false 51246 }) { 51247 const allFormatTypes = (0, import_data149.useSelect)(formatTypesSelector, []); 51248 const formatTypes = (0, import_element175.useMemo)(() => { 51249 return allFormatTypes.filter( 51250 ({ 51251 name, 51252 interactive, 51253 tagName, 51254 [essentialFormatKey]: isEssential 51255 }) => { 51256 if (allowedFormats && !allowedFormats.includes(name)) { 51257 return false; 51258 } 51259 if (disableNoneEssentialFormatting && !isEssential) { 51260 return false; 51261 } 51262 if (withoutInteractiveFormatting && (interactive || interactiveContentTags.has(tagName))) { 51263 return false; 51264 } 51265 return true; 51266 } 51267 ); 51268 }, [ 51269 allFormatTypes, 51270 allowedFormats, 51271 disableNoneEssentialFormatting, 51272 withoutInteractiveFormatting 51273 ]); 51274 const keyedSelected = (0, import_data149.useSelect)( 51275 (select3) => formatTypes.reduce((accumulator, type) => { 51276 if (!type.__experimentalGetPropsForEditableTreePreparation) { 51277 return accumulator; 51278 } 51279 return { 51280 ...accumulator, 51281 ...prefixSelectKeys( 51282 type.__experimentalGetPropsForEditableTreePreparation( 51283 select3, 51284 { 51285 richTextIdentifier: identifier, 51286 blockClientId: clientId 51287 } 51288 ), 51289 type.name 51290 ) 51291 }; 51292 }, {}), 51293 [formatTypes, clientId, identifier] 51294 ); 51295 const dispatch = (0, import_data149.useDispatch)(); 51296 const prepareHandlers = []; 51297 const valueHandlers = []; 51298 const changeHandlers = []; 51299 const dependencies = []; 51300 for (const key in keyedSelected) { 51301 dependencies.push(keyedSelected[key]); 51302 } 51303 formatTypes.forEach((type) => { 51304 if (type.__experimentalCreatePrepareEditableTree) { 51305 const handler = type.__experimentalCreatePrepareEditableTree( 51306 getPrefixedSelectKeys(keyedSelected, type.name), 51307 { 51308 richTextIdentifier: identifier, 51309 blockClientId: clientId 51310 } 51311 ); 51312 if (type.__experimentalCreateOnChangeEditableValue) { 51313 valueHandlers.push(handler); 51314 } else { 51315 prepareHandlers.push(handler); 51316 } 51317 } 51318 if (type.__experimentalCreateOnChangeEditableValue) { 51319 let dispatchers = {}; 51320 if (type.__experimentalGetPropsForEditableTreeChangeHandler) { 51321 dispatchers = type.__experimentalGetPropsForEditableTreeChangeHandler( 51322 dispatch, 51323 { 51324 richTextIdentifier: identifier, 51325 blockClientId: clientId 51326 } 51327 ); 51328 } 51329 const selected = getPrefixedSelectKeys(keyedSelected, type.name); 51330 changeHandlers.push( 51331 type.__experimentalCreateOnChangeEditableValue( 51332 { 51333 ...typeof selected === "object" ? selected : {}, 51334 ...dispatchers 51335 }, 51336 { 51337 richTextIdentifier: identifier, 51338 blockClientId: clientId 51339 } 51340 ) 51341 ); 51342 } 51343 }); 51344 return { 51345 formatTypes, 51346 prepareHandlers, 51347 valueHandlers, 51348 changeHandlers, 51349 dependencies 51350 }; 51351 } 51352 51353 // packages/block-editor/build-module/components/rich-text/event-listeners/index.js 51354 var import_element177 = __toESM(require_element()); 51355 var import_compose86 = __toESM(require_compose()); 51356 51357 // packages/block-editor/build-module/components/rich-text/event-listeners/before-input-rules.js 51358 var import_rich_text6 = __toESM(require_rich_text()); 51359 var import_hooks7 = __toESM(require_hooks()); 51360 var wrapSelectionSettings = ["`", '"', "'", "\u201C\u201D", "\u2018\u2019"]; 51361 var before_input_rules_default = (props) => (element) => { 51362 function onInput(event) { 51363 const { inputType, data } = event; 51364 const { value, onChange, registry } = props.current; 51365 if (inputType !== "insertText") { 51366 return; 51367 } 51368 if ((0, import_rich_text6.isCollapsed)(value)) { 51369 return; 51370 } 51371 const pair = (0, import_hooks7.applyFilters)( 51372 "blockEditor.wrapSelectionSettings", 51373 wrapSelectionSettings 51374 ).find( 51375 ([startChar2, endChar2]) => startChar2 === data || endChar2 === data 51376 ); 51377 if (!pair) { 51378 return; 51379 } 51380 const [startChar, endChar = startChar] = pair; 51381 const start2 = value.start; 51382 const end = value.end + startChar.length; 51383 let newValue = (0, import_rich_text6.insert)(value, startChar, start2, start2); 51384 newValue = (0, import_rich_text6.insert)(newValue, endChar, end, end); 51385 const { 51386 __unstableMarkLastChangeAsPersistent: __unstableMarkLastChangeAsPersistent2, 51387 __unstableMarkAutomaticChange: __unstableMarkAutomaticChange2 51388 } = registry.dispatch(store); 51389 __unstableMarkLastChangeAsPersistent2(); 51390 onChange(newValue); 51391 __unstableMarkAutomaticChange2(); 51392 const init = {}; 51393 for (const key in event) { 51394 init[key] = event[key]; 51395 } 51396 init.data = endChar; 51397 const { ownerDocument } = element; 51398 const { defaultView } = ownerDocument; 51399 const newEvent = new defaultView.InputEvent("input", init); 51400 window.queueMicrotask(() => { 51401 event.target.dispatchEvent(newEvent); 51402 }); 51403 event.preventDefault(); 51404 } 51405 element.addEventListener("beforeinput", onInput); 51406 return () => { 51407 element.removeEventListener("beforeinput", onInput); 51408 }; 51409 }; 51410 51411 // packages/block-editor/build-module/components/rich-text/event-listeners/input-rules.js 51412 var import_rich_text8 = __toESM(require_rich_text()); 51413 var import_blocks81 = __toESM(require_blocks()); 51414 51415 // packages/block-editor/build-module/components/rich-text/prevent-event-discovery.js 51416 var import_rich_text7 = __toESM(require_rich_text()); 51417 function preventEventDiscovery(value) { 51418 const searchText = "tales of gutenberg"; 51419 const addText = " \u{1F421}\u{1F422}\u{1F980}\u{1F424}\u{1F98B}\u{1F418}\u{1F427}\u{1F439}\u{1F981}\u{1F984}\u{1F98D}\u{1F43C}\u{1F43F}\u{1F383}\u{1F434}\u{1F41D}\u{1F406}\u{1F995}\u{1F994}\u{1F331}\u{1F347}\u03C0\u{1F34C}\u{1F409}\u{1F4A7}\u{1F968}\u{1F30C}\u{1F342}\u{1F360}\u{1F966}\u{1F95A}\u{1F95D}\u{1F39F}\u{1F965}\u{1F952}\u{1F6F5}\u{1F956}\u{1F352}\u{1F36F}\u{1F3BE}\u{1F3B2}\u{1F43A}\u{1F41A}\u{1F42E}\u231B\uFE0F"; 51420 const { start: start2, text } = value; 51421 if (start2 < searchText.length) { 51422 return value; 51423 } 51424 const charactersBefore = text.slice(start2 - searchText.length, start2); 51425 if (charactersBefore.toLowerCase() !== searchText) { 51426 return value; 51427 } 51428 return (0, import_rich_text7.insert)(value, addText); 51429 } 51430 51431 // packages/block-editor/build-module/components/rich-text/event-listeners/input-rules.js 51432 function findSelection(blocks2) { 51433 let i2 = blocks2.length; 51434 while (i2--) { 51435 const attributeKey = retrieveSelectedAttribute( 51436 blocks2[i2].attributes 51437 ); 51438 if (attributeKey) { 51439 blocks2[i2].attributes[attributeKey] = blocks2[i2].attributes[attributeKey].toString().replace(START_OF_SELECTED_AREA, ""); 51440 return [blocks2[i2].clientId, attributeKey, 0, 0]; 51441 } 51442 const nestedSelection = findSelection(blocks2[i2].innerBlocks); 51443 if (nestedSelection) { 51444 return nestedSelection; 51445 } 51446 } 51447 return []; 51448 } 51449 var input_rules_default = (props) => (element) => { 51450 function inputRule() { 51451 const { getValue, onReplace, selectionChange: selectionChange2, registry } = props.current; 51452 if (!onReplace) { 51453 return; 51454 } 51455 const value = getValue(); 51456 const { start: start2, text } = value; 51457 const characterBefore = text.slice(start2 - 1, start2); 51458 if (characterBefore !== " ") { 51459 return; 51460 } 51461 const trimmedTextBefore = text.slice(0, start2).trim(); 51462 const prefixTransforms = (0, import_blocks81.getBlockTransforms)("from").filter( 51463 ({ type }) => type === "prefix" 51464 ); 51465 const transformation = (0, import_blocks81.findTransform)( 51466 prefixTransforms, 51467 ({ prefix: prefix2 }) => { 51468 return trimmedTextBefore === prefix2; 51469 } 51470 ); 51471 if (!transformation) { 51472 return; 51473 } 51474 const content = (0, import_rich_text8.toHTMLString)({ 51475 value: (0, import_rich_text8.insert)(value, START_OF_SELECTED_AREA, 0, start2) 51476 }); 51477 const block = transformation.transform(content); 51478 selectionChange2(...findSelection([block])); 51479 onReplace([block]); 51480 registry.dispatch(store).__unstableMarkAutomaticChange(); 51481 return true; 51482 } 51483 function onInput(event) { 51484 const { inputType, type } = event; 51485 const { 51486 getValue, 51487 onChange, 51488 __unstableAllowPrefixTransformations, 51489 formatTypes, 51490 registry 51491 } = props.current; 51492 if (inputType !== "insertText" && type !== "compositionend") { 51493 return; 51494 } 51495 if (__unstableAllowPrefixTransformations && inputRule()) { 51496 return; 51497 } 51498 const value = getValue(); 51499 const transformed = formatTypes.reduce( 51500 (accumulator, { __unstableInputRule }) => { 51501 if (__unstableInputRule) { 51502 accumulator = __unstableInputRule(accumulator); 51503 } 51504 return accumulator; 51505 }, 51506 preventEventDiscovery(value) 51507 ); 51508 const { 51509 __unstableMarkLastChangeAsPersistent: __unstableMarkLastChangeAsPersistent2, 51510 __unstableMarkAutomaticChange: __unstableMarkAutomaticChange2 51511 } = registry.dispatch(store); 51512 if (transformed !== value) { 51513 __unstableMarkLastChangeAsPersistent2(); 51514 onChange({ 51515 ...transformed, 51516 activeFormats: value.activeFormats 51517 }); 51518 __unstableMarkAutomaticChange2(); 51519 } 51520 } 51521 element.addEventListener("input", onInput); 51522 element.addEventListener("compositionend", onInput); 51523 return () => { 51524 element.removeEventListener("input", onInput); 51525 element.removeEventListener("compositionend", onInput); 51526 }; 51527 }; 51528 51529 // packages/block-editor/build-module/components/rich-text/event-listeners/insert-replacement-text.js 51530 var insert_replacement_text_default = (props) => (element) => { 51531 function onInput(event) { 51532 if (event.inputType !== "insertReplacementText") { 51533 return; 51534 } 51535 const { registry } = props.current; 51536 registry.dispatch(store).__unstableMarkLastChangeAsPersistent(); 51537 } 51538 element.addEventListener("beforeinput", onInput); 51539 return () => { 51540 element.removeEventListener("beforeinput", onInput); 51541 }; 51542 }; 51543 51544 // packages/block-editor/build-module/components/rich-text/event-listeners/remove-browser-shortcuts.js 51545 var import_keycodes19 = __toESM(require_keycodes()); 51546 var remove_browser_shortcuts_default = () => (node) => { 51547 function onKeydown(event) { 51548 if (import_keycodes19.isKeyboardEvent.primary(event, "z") || import_keycodes19.isKeyboardEvent.primary(event, "y") || import_keycodes19.isKeyboardEvent.primaryShift(event, "z")) { 51549 event.preventDefault(); 51550 } 51551 } 51552 node.addEventListener("keydown", onKeydown); 51553 return () => { 51554 node.removeEventListener("keydown", onKeydown); 51555 }; 51556 }; 51557 51558 // packages/block-editor/build-module/components/rich-text/event-listeners/shortcuts.js 51559 var shortcuts_default = (props) => (element) => { 51560 const { keyboardShortcuts } = props.current; 51561 function onKeyDown(event) { 51562 for (const keyboardShortcut of keyboardShortcuts.current) { 51563 keyboardShortcut(event); 51564 } 51565 } 51566 element.addEventListener("keydown", onKeyDown); 51567 return () => { 51568 element.removeEventListener("keydown", onKeyDown); 51569 }; 51570 }; 51571 51572 // packages/block-editor/build-module/components/rich-text/event-listeners/input-events.js 51573 var input_events_default = (props) => (element) => { 51574 const { inputEvents } = props.current; 51575 function onInput(event) { 51576 for (const keyboardShortcut of inputEvents.current) { 51577 keyboardShortcut(event); 51578 } 51579 } 51580 element.addEventListener("input", onInput); 51581 return () => { 51582 element.removeEventListener("input", onInput); 51583 }; 51584 }; 51585 51586 // packages/block-editor/build-module/components/rich-text/event-listeners/undo-automatic-change.js 51587 var import_keycodes20 = __toESM(require_keycodes()); 51588 var undo_automatic_change_default = (props) => (element) => { 51589 function onKeyDown(event) { 51590 const { keyCode } = event; 51591 if (event.defaultPrevented) { 51592 return; 51593 } 51594 if (keyCode !== import_keycodes20.BACKSPACE && keyCode !== import_keycodes20.ESCAPE) { 51595 return; 51596 } 51597 const { registry } = props.current; 51598 const { didAutomaticChange: didAutomaticChange2, getSettings: getSettings8 } = registry.select(store); 51599 const { __experimentalUndo } = getSettings8(); 51600 if (!__experimentalUndo) { 51601 return; 51602 } 51603 if (!didAutomaticChange2()) { 51604 return; 51605 } 51606 event.preventDefault(); 51607 __experimentalUndo(); 51608 } 51609 element.addEventListener("keydown", onKeyDown); 51610 return () => { 51611 element.removeEventListener("keydown", onKeyDown); 51612 }; 51613 }; 51614 51615 // packages/block-editor/build-module/components/rich-text/event-listeners/paste-handler.js 51616 var import_blocks83 = __toESM(require_blocks()); 51617 var import_rich_text9 = __toESM(require_rich_text()); 51618 var import_url10 = __toESM(require_url()); 51619 51620 // packages/block-editor/build-module/components/rich-text/utils.js 51621 var import_element176 = __toESM(require_element()); 51622 var import_blocks82 = __toESM(require_blocks()); 51623 var import_jsx_runtime330 = __toESM(require_jsx_runtime()); 51624 function addActiveFormats(value, activeFormats) { 51625 if (activeFormats?.length) { 51626 let index = value.formats.length; 51627 while (index--) { 51628 value.formats[index] = [ 51629 ...activeFormats, 51630 ...value.formats[index] || [] 51631 ]; 51632 } 51633 } 51634 } 51635 function getMultilineTag(multiline) { 51636 if (multiline !== true && multiline !== "p" && multiline !== "li") { 51637 return; 51638 } 51639 return multiline === true ? "p" : multiline; 51640 } 51641 function getAllowedFormats({ allowedFormats, disableFormats }) { 51642 if (disableFormats) { 51643 return getAllowedFormats.EMPTY_ARRAY; 51644 } 51645 return allowedFormats; 51646 } 51647 getAllowedFormats.EMPTY_ARRAY = []; 51648 51649 // packages/block-editor/build-module/components/rich-text/event-listeners/paste-handler.js 51650 var paste_handler_default = (props) => (element) => { 51651 function _onPaste(event) { 51652 const { 51653 disableFormats, 51654 onChange, 51655 value, 51656 formatTypes, 51657 tagName, 51658 onReplace, 51659 __unstableEmbedURLOnPaste, 51660 preserveWhiteSpace, 51661 pastePlainText 51662 } = props.current; 51663 if (!element.contains(event.target)) { 51664 return; 51665 } 51666 if (event.defaultPrevented) { 51667 return; 51668 } 51669 const { plainText, html } = getPasteEventData(event); 51670 event.preventDefault(); 51671 window.console.log("Received HTML:\n\n", html); 51672 window.console.log("Received plain text:\n\n", plainText); 51673 if (disableFormats) { 51674 onChange((0, import_rich_text9.insert)(value, plainText)); 51675 return; 51676 } 51677 const isInternal = event.clipboardData.getData("rich-text") === "true"; 51678 function pasteInline(content2) { 51679 const transformed = formatTypes.reduce( 51680 (accumulator, { __unstablePasteRule }) => { 51681 if (__unstablePasteRule && accumulator === value) { 51682 accumulator = __unstablePasteRule(value, { 51683 html, 51684 plainText 51685 }); 51686 } 51687 return accumulator; 51688 }, 51689 value 51690 ); 51691 if (transformed !== value) { 51692 onChange(transformed); 51693 } else { 51694 const valueToInsert = (0, import_rich_text9.create)({ html: content2 }); 51695 addActiveFormats(valueToInsert, value.activeFormats); 51696 onChange((0, import_rich_text9.insert)(value, valueToInsert)); 51697 } 51698 } 51699 if (isInternal) { 51700 pasteInline(html); 51701 return; 51702 } 51703 if (pastePlainText) { 51704 onChange((0, import_rich_text9.insert)(value, (0, import_rich_text9.create)({ text: plainText }))); 51705 return; 51706 } 51707 let mode2 = "INLINE"; 51708 const trimmedPlainText = plainText.trim(); 51709 if (__unstableEmbedURLOnPaste && (0, import_rich_text9.isEmpty)(value) && (0, import_url10.isURL)(trimmedPlainText) && // For the link pasting feature, allow only http(s) protocols. 51710 /^https?:/.test(trimmedPlainText)) { 51711 mode2 = "BLOCKS"; 51712 } 51713 const content = (0, import_blocks83.pasteHandler)({ 51714 HTML: html, 51715 plainText, 51716 mode: mode2, 51717 tagName, 51718 preserveWhiteSpace 51719 }); 51720 if (typeof content === "string") { 51721 pasteInline(content); 51722 } else if (content.length > 0) { 51723 if (onReplace && (0, import_rich_text9.isEmpty)(value)) { 51724 onReplace(content, content.length - 1, -1); 51725 } 51726 } 51727 } 51728 const { defaultView } = element.ownerDocument; 51729 defaultView.addEventListener("paste", _onPaste); 51730 return () => { 51731 defaultView.removeEventListener("paste", _onPaste); 51732 }; 51733 }; 51734 51735 // packages/block-editor/build-module/components/rich-text/event-listeners/delete.js 51736 var import_keycodes21 = __toESM(require_keycodes()); 51737 var import_rich_text10 = __toESM(require_rich_text()); 51738 var delete_default = (props) => (element) => { 51739 function onKeyDown(event) { 51740 const { keyCode } = event; 51741 if (event.defaultPrevented) { 51742 return; 51743 } 51744 const { value, onMerge, onRemove } = props.current; 51745 if (keyCode === import_keycodes21.DELETE || keyCode === import_keycodes21.BACKSPACE) { 51746 const { start: start2, end, text } = value; 51747 const isReverse = keyCode === import_keycodes21.BACKSPACE; 51748 const hasActiveFormats = value.activeFormats && !!value.activeFormats.length; 51749 if (!(0, import_rich_text10.isCollapsed)(value) || hasActiveFormats || isReverse && start2 !== 0 || !isReverse && end !== text.length) { 51750 return; 51751 } 51752 if (onMerge) { 51753 onMerge(!isReverse); 51754 } else if (onRemove && (0, import_rich_text10.isEmpty)(value) && isReverse) { 51755 onRemove(!isReverse); 51756 } 51757 event.preventDefault(); 51758 } 51759 } 51760 element.addEventListener("keydown", onKeyDown); 51761 return () => { 51762 element.removeEventListener("keydown", onKeyDown); 51763 }; 51764 }; 51765 51766 // packages/block-editor/build-module/components/rich-text/event-listeners/enter.js 51767 var import_keycodes22 = __toESM(require_keycodes()); 51768 var import_rich_text11 = __toESM(require_rich_text()); 51769 var enter_default = (props) => (element) => { 51770 function onKeyDownDeprecated(event) { 51771 if (event.keyCode !== import_keycodes22.ENTER) { 51772 return; 51773 } 51774 const { onReplace, onSplit } = props.current; 51775 if (onReplace && onSplit) { 51776 event.__deprecatedOnSplit = true; 51777 } 51778 } 51779 function onKeyDown(event) { 51780 if (event.defaultPrevented) { 51781 return; 51782 } 51783 if (event.target !== element) { 51784 return; 51785 } 51786 if (event.keyCode !== import_keycodes22.ENTER) { 51787 return; 51788 } 51789 const { 51790 value, 51791 onChange, 51792 disableLineBreaks, 51793 onSplitAtEnd, 51794 onSplitAtDoubleLineEnd, 51795 registry 51796 } = props.current; 51797 event.preventDefault(); 51798 const { text, start: start2, end } = value; 51799 if (event.shiftKey) { 51800 if (!disableLineBreaks) { 51801 onChange((0, import_rich_text11.insert)(value, "\n")); 51802 } 51803 } else if (onSplitAtEnd && start2 === end && end === text.length) { 51804 onSplitAtEnd(); 51805 } else if ( 51806 // For some blocks it's desirable to split at the end of the 51807 // block when there are two line breaks at the end of the 51808 // block, so triple Enter exits the block. 51809 onSplitAtDoubleLineEnd && start2 === end && end === text.length && text.slice(-2) === "\n\n" 51810 ) { 51811 registry.batch(() => { 51812 const _value = { ...value }; 51813 _value.start = _value.end - 2; 51814 onChange((0, import_rich_text11.remove)(_value)); 51815 onSplitAtDoubleLineEnd(); 51816 }); 51817 } else if (!disableLineBreaks) { 51818 onChange((0, import_rich_text11.insert)(value, "\n")); 51819 } 51820 } 51821 const { defaultView } = element.ownerDocument; 51822 defaultView.addEventListener("keydown", onKeyDown); 51823 element.addEventListener("keydown", onKeyDownDeprecated); 51824 return () => { 51825 defaultView.removeEventListener("keydown", onKeyDown); 51826 element.removeEventListener("keydown", onKeyDownDeprecated); 51827 }; 51828 }; 51829 51830 // packages/block-editor/build-module/components/rich-text/event-listeners/firefox-compat.js 51831 var firefox_compat_default = (props) => (element) => { 51832 function onFocus() { 51833 const { registry } = props.current; 51834 if (!registry.select(store).isMultiSelecting()) { 51835 return; 51836 } 51837 const parentEditable = element.parentElement.closest( 51838 '[contenteditable="true"]' 51839 ); 51840 if (parentEditable) { 51841 parentEditable.focus(); 51842 } 51843 } 51844 element.addEventListener("focus", onFocus); 51845 return () => { 51846 element.removeEventListener("focus", onFocus); 51847 }; 51848 }; 51849 51850 // packages/block-editor/build-module/components/rich-text/event-listeners/index.js 51851 var allEventListeners = [ 51852 before_input_rules_default, 51853 input_rules_default, 51854 insert_replacement_text_default, 51855 remove_browser_shortcuts_default, 51856 shortcuts_default, 51857 input_events_default, 51858 undo_automatic_change_default, 51859 paste_handler_default, 51860 delete_default, 51861 enter_default, 51862 firefox_compat_default 51863 ]; 51864 function useEventListeners(props) { 51865 const propsRef = (0, import_element177.useRef)(props); 51866 (0, import_element177.useInsertionEffect)(() => { 51867 propsRef.current = props; 51868 }); 51869 const refEffects = (0, import_element177.useMemo)( 51870 () => allEventListeners.map((refEffect) => refEffect(propsRef)), 51871 [propsRef] 51872 ); 51873 return (0, import_compose86.useRefEffect)( 51874 (element) => { 51875 if (!props.isSelected) { 51876 return; 51877 } 51878 const cleanups = refEffects.map((effect) => effect(element)); 51879 return () => { 51880 cleanups.forEach((cleanup) => cleanup()); 51881 }; 51882 }, 51883 [refEffects, props.isSelected] 51884 ); 51885 } 51886 51887 // packages/block-editor/build-module/components/rich-text/format-edit.js 51888 var import_rich_text12 = __toESM(require_rich_text()); 51889 var import_element178 = __toESM(require_element()); 51890 var import_jsx_runtime331 = __toESM(require_jsx_runtime()); 51891 var import_react5 = __toESM(require_react()); 51892 var DEFAULT_BLOCK_CONTEXT2 = {}; 51893 var usesContextKey = Symbol("usesContext"); 51894 function Edit3({ 51895 onChange, 51896 onFocus, 51897 value, 51898 forwardedRef, 51899 settings: settings2, 51900 isVisible 51901 }) { 51902 const { 51903 name, 51904 edit: EditFunction, 51905 [usesContextKey]: usesContext 51906 } = settings2; 51907 const blockContext = (0, import_element178.useContext)(block_context_default); 51908 const context = (0, import_element178.useMemo)(() => { 51909 return usesContext ? Object.fromEntries( 51910 Object.entries(blockContext).filter( 51911 ([key]) => usesContext.includes(key) 51912 ) 51913 ) : DEFAULT_BLOCK_CONTEXT2; 51914 }, [usesContext, blockContext]); 51915 if (!EditFunction) { 51916 return null; 51917 } 51918 const activeFormat = (0, import_rich_text12.getActiveFormat)(value, name); 51919 const isActive = activeFormat !== void 0; 51920 const activeObject = (0, import_rich_text12.getActiveObject)(value); 51921 const isObjectActive = activeObject !== void 0 && activeObject.type === name; 51922 return /* @__PURE__ */ (0, import_jsx_runtime331.jsx)( 51923 EditFunction, 51924 { 51925 isActive, 51926 isVisible, 51927 activeAttributes: isActive ? activeFormat.attributes || {} : {}, 51928 isObjectActive, 51929 activeObjectAttributes: isObjectActive ? activeObject.attributes || {} : {}, 51930 value, 51931 onChange, 51932 onFocus, 51933 contentRef: forwardedRef, 51934 context 51935 }, 51936 name 51937 ); 51938 } 51939 function FormatEdit({ formatTypes, ...props }) { 51940 return formatTypes.map((settings2) => /* @__PURE__ */ (0, import_react5.createElement)(Edit3, { settings: settings2, ...props, key: settings2.name })); 51941 } 51942 51943 // packages/block-editor/build-module/components/rich-text/content.js 51944 var import_element179 = __toESM(require_element()); 51945 var import_blocks84 = __toESM(require_blocks()); 51946 var import_deprecated27 = __toESM(require_deprecated()); 51947 var import_jsx_runtime332 = __toESM(require_jsx_runtime()); 51948 function valueToHTMLString(value, multiline) { 51949 if (rich_text_default.isEmpty(value)) { 51950 const multilineTag = getMultilineTag(multiline); 51951 return multilineTag ? `<$multilineTag}></$multilineTag}>` : ""; 51952 } 51953 if (Array.isArray(value)) { 51954 (0, import_deprecated27.default)("wp.blockEditor.RichText value prop as children type", { 51955 since: "6.1", 51956 version: "6.3", 51957 alternative: "value prop as string", 51958 link: "https://developer.wordpress.org/block-editor/how-to-guides/block-tutorial/introducing-attributes-and-editable-fields/" 51959 }); 51960 return import_blocks84.children.toHTML(value); 51961 } 51962 if (typeof value === "string") { 51963 return value; 51964 } 51965 return value.toHTMLString(); 51966 } 51967 function Content({ 51968 value, 51969 tagName: Tag, 51970 multiline, 51971 format: format6, 51972 ...props 51973 }) { 51974 value = /* @__PURE__ */ (0, import_jsx_runtime332.jsx)(import_element179.RawHTML, { children: valueToHTMLString(value, multiline) }); 51975 return Tag ? /* @__PURE__ */ (0, import_jsx_runtime332.jsx)(Tag, { ...props, children: value }) : value; 51976 } 51977 51978 // packages/block-editor/build-module/components/rich-text/with-deprecations.js 51979 var import_element181 = __toESM(require_element()); 51980 var import_blocks85 = __toESM(require_blocks()); 51981 var import_rich_text14 = __toESM(require_rich_text()); 51982 var import_deprecated29 = __toESM(require_deprecated()); 51983 51984 // packages/block-editor/build-module/components/rich-text/multiline.js 51985 var import_element180 = __toESM(require_element()); 51986 var import_deprecated28 = __toESM(require_deprecated()); 51987 var import_data150 = __toESM(require_data()); 51988 var import_keycodes23 = __toESM(require_keycodes()); 51989 var import_rich_text13 = __toESM(require_rich_text()); 51990 var import_jsx_runtime333 = __toESM(require_jsx_runtime()); 51991 function RichTextMultiline({ 51992 children, 51993 identifier, 51994 tagName: TagName = "div", 51995 value = "", 51996 onChange, 51997 multiline, 51998 ...props 51999 }, forwardedRef) { 52000 (0, import_deprecated28.default)("wp.blockEditor.RichText multiline prop", { 52001 since: "6.1", 52002 version: "6.3", 52003 alternative: "nested blocks (InnerBlocks)", 52004 link: "https://developer.wordpress.org/block-editor/how-to-guides/block-tutorial/nested-blocks-inner-blocks/" 52005 }); 52006 const { clientId } = useBlockEditContext(); 52007 const { getSelectionStart: getSelectionStart2, getSelectionEnd: getSelectionEnd2 } = (0, import_data150.useSelect)(store); 52008 const { selectionChange: selectionChange2 } = (0, import_data150.useDispatch)(store); 52009 const multilineTagName = getMultilineTag(multiline); 52010 value = value || `<$multilineTagName}></$multilineTagName}>`; 52011 const padded = `</$multilineTagName}>$value}<$multilineTagName}>`; 52012 const values = padded.split( 52013 `</$multilineTagName}><$multilineTagName}>` 52014 ); 52015 values.shift(); 52016 values.pop(); 52017 function _onChange(newValues) { 52018 onChange( 52019 `<$multilineTagName}>$newValues.join( 52020 `</$multilineTagName}><$multilineTagName}>` 52021 )}</$multilineTagName}>` 52022 ); 52023 } 52024 return /* @__PURE__ */ (0, import_jsx_runtime333.jsx)(TagName, { ref: forwardedRef, children: values.map((_value, index) => { 52025 return /* @__PURE__ */ (0, import_jsx_runtime333.jsx)( 52026 RichTextWrapper, 52027 { 52028 identifier: `$identifier}-$index}`, 52029 tagName: multilineTagName, 52030 value: _value, 52031 onChange: (newValue) => { 52032 const newValues = values.slice(); 52033 newValues[index] = newValue; 52034 _onChange(newValues); 52035 }, 52036 isSelected: void 0, 52037 onKeyDown: (event) => { 52038 if (event.keyCode !== import_keycodes23.ENTER) { 52039 return; 52040 } 52041 event.preventDefault(); 52042 const { offset: start2 } = getSelectionStart2(); 52043 const { offset: end } = getSelectionEnd2(); 52044 if (typeof start2 !== "number" || typeof end !== "number") { 52045 return; 52046 } 52047 const richTextValue = (0, import_rich_text13.create)({ html: _value }); 52048 richTextValue.start = start2; 52049 richTextValue.end = end; 52050 const array = (0, import_rich_text13.split)(richTextValue).map( 52051 (v2) => (0, import_rich_text13.toHTMLString)({ value: v2 }) 52052 ); 52053 const newValues = values.slice(); 52054 newValues.splice(index, 1, ...array); 52055 _onChange(newValues); 52056 selectionChange2( 52057 clientId, 52058 `$identifier}-$index + 1}`, 52059 0, 52060 0 52061 ); 52062 }, 52063 onMerge: (forward) => { 52064 const newValues = values.slice(); 52065 let offset = 0; 52066 if (forward) { 52067 if (!newValues[index + 1]) { 52068 return; 52069 } 52070 newValues.splice( 52071 index, 52072 2, 52073 newValues[index] + newValues[index + 1] 52074 ); 52075 offset = newValues[index].length - 1; 52076 } else { 52077 if (!newValues[index - 1]) { 52078 return; 52079 } 52080 newValues.splice( 52081 index - 1, 52082 2, 52083 newValues[index - 1] + newValues[index] 52084 ); 52085 offset = newValues[index - 1].length - 1; 52086 } 52087 _onChange(newValues); 52088 selectionChange2( 52089 clientId, 52090 `$identifier}-$index - (forward ? 0 : 1)}`, 52091 offset, 52092 offset 52093 ); 52094 }, 52095 ...props 52096 }, 52097 index 52098 ); 52099 }) }); 52100 } 52101 var multiline_default = (0, import_element180.forwardRef)(RichTextMultiline); 52102 52103 // packages/block-editor/build-module/components/rich-text/with-deprecations.js 52104 var import_jsx_runtime334 = __toESM(require_jsx_runtime()); 52105 function withDeprecations(Component7) { 52106 return (0, import_element181.forwardRef)((props, ref) => { 52107 let value = props.value; 52108 let onChange = props.onChange; 52109 if (Array.isArray(value)) { 52110 (0, import_deprecated29.default)("wp.blockEditor.RichText value prop as children type", { 52111 since: "6.1", 52112 version: "6.3", 52113 alternative: "value prop as string", 52114 link: "https://developer.wordpress.org/block-editor/how-to-guides/block-tutorial/introducing-attributes-and-editable-fields/" 52115 }); 52116 value = import_blocks85.children.toHTML(props.value); 52117 onChange = (newValue) => props.onChange( 52118 import_blocks85.children.fromDOM( 52119 (0, import_rich_text14.__unstableCreateElement)(document, newValue).childNodes 52120 ) 52121 ); 52122 } 52123 const NewComponent = props.multiline ? multiline_default : Component7; 52124 return /* @__PURE__ */ (0, import_jsx_runtime334.jsx)( 52125 NewComponent, 52126 { 52127 ...props, 52128 value, 52129 onChange, 52130 ref 52131 } 52132 ); 52133 }); 52134 } 52135 52136 // packages/block-editor/build-module/components/rich-text/shortcut.js 52137 var import_keycodes24 = __toESM(require_keycodes()); 52138 var import_element182 = __toESM(require_element()); 52139 function RichTextShortcut({ character, type, onUse }) { 52140 const keyboardShortcuts = (0, import_element182.useContext)(keyboardShortcutContext); 52141 const onUseRef = (0, import_element182.useRef)(); 52142 onUseRef.current = onUse; 52143 (0, import_element182.useEffect)(() => { 52144 function callback(event) { 52145 if (import_keycodes24.isKeyboardEvent[type](event, character)) { 52146 onUseRef.current(); 52147 event.preventDefault(); 52148 } 52149 } 52150 keyboardShortcuts.current.add(callback); 52151 return () => { 52152 keyboardShortcuts.current.delete(callback); 52153 }; 52154 }, [character, type]); 52155 return null; 52156 } 52157 52158 // packages/block-editor/build-module/components/rich-text/toolbar-button.js 52159 var import_components177 = __toESM(require_components()); 52160 var import_keycodes25 = __toESM(require_keycodes()); 52161 var import_jsx_runtime335 = __toESM(require_jsx_runtime()); 52162 function RichTextToolbarButton({ 52163 name, 52164 shortcutType, 52165 shortcutCharacter, 52166 ...props 52167 }) { 52168 let shortcut; 52169 let fillName = "RichText.ToolbarControls"; 52170 if (name) { 52171 fillName += `.$name}`; 52172 } 52173 if (shortcutType && shortcutCharacter) { 52174 shortcut = import_keycodes25.displayShortcut[shortcutType](shortcutCharacter); 52175 } 52176 return /* @__PURE__ */ (0, import_jsx_runtime335.jsx)(import_components177.Fill, { name: fillName, children: /* @__PURE__ */ (0, import_jsx_runtime335.jsx)(import_components177.ToolbarButton, { ...props, shortcut }) }); 52177 } 52178 52179 // packages/block-editor/build-module/components/rich-text/input-event.js 52180 var import_element183 = __toESM(require_element()); 52181 function __unstableRichTextInputEvent({ inputType, onInput }) { 52182 const callbacks = (0, import_element183.useContext)(inputEventContext); 52183 const onInputRef = (0, import_element183.useRef)(); 52184 onInputRef.current = onInput; 52185 (0, import_element183.useEffect)(() => { 52186 function callback(event) { 52187 if (event.inputType === inputType) { 52188 onInputRef.current(); 52189 event.preventDefault(); 52190 } 52191 } 52192 callbacks.current.add(callback); 52193 return () => { 52194 callbacks.current.delete(callback); 52195 }; 52196 }, [inputType]); 52197 return null; 52198 } 52199 52200 // packages/block-editor/build-module/components/rich-text/index.js 52201 var import_jsx_runtime336 = __toESM(require_jsx_runtime()); 52202 var keyboardShortcutContext = (0, import_element184.createContext)(); 52203 keyboardShortcutContext.displayName = "keyboardShortcutContext"; 52204 var inputEventContext = (0, import_element184.createContext)(); 52205 inputEventContext.displayName = "inputEventContext"; 52206 var instanceIdKey = Symbol("instanceId"); 52207 function removeNativeProps(props) { 52208 const { 52209 __unstableMobileNoFocusOnMount, 52210 deleteEnter, 52211 placeholderTextColor, 52212 textAlign, 52213 selectionColor, 52214 tagsToEliminate, 52215 disableEditingMenu, 52216 fontSize, 52217 fontFamily, 52218 fontWeight, 52219 fontStyle, 52220 minWidth, 52221 maxWidth, 52222 disableSuggestions, 52223 disableAutocorrection, 52224 ...restProps 52225 } = props; 52226 return restProps; 52227 } 52228 function RichTextWrapper({ 52229 children, 52230 tagName = "div", 52231 value: adjustedValue = "", 52232 onChange: adjustedOnChange, 52233 isSelected: originalIsSelected, 52234 multiline, 52235 inlineToolbar, 52236 wrapperClassName, 52237 autocompleters, 52238 onReplace, 52239 placeholder, 52240 allowedFormats, 52241 withoutInteractiveFormatting, 52242 onRemove, 52243 onMerge, 52244 onSplit, 52245 __unstableOnSplitAtEnd: onSplitAtEnd, 52246 __unstableOnSplitAtDoubleLineEnd: onSplitAtDoubleLineEnd, 52247 identifier, 52248 preserveWhiteSpace, 52249 __unstablePastePlainText: pastePlainText, 52250 __unstableEmbedURLOnPaste, 52251 __unstableDisableFormats: disableFormats, 52252 disableLineBreaks, 52253 __unstableAllowPrefixTransformations, 52254 readOnly, 52255 ...props 52256 }, forwardedRef) { 52257 props = removeNativeProps(props); 52258 if (onSplit) { 52259 (0, import_deprecated30.default)("wp.blockEditor.RichText onSplit prop", { 52260 since: "6.4", 52261 alternative: 'block.json support key: "splitting"' 52262 }); 52263 } 52264 const instanceId = (0, import_compose87.useInstanceId)(RichTextWrapper); 52265 const anchorRef = (0, import_element184.useRef)(); 52266 const [anchorElement, setAnchorElement] = (0, import_element184.useState)(null); 52267 const context = useBlockEditContext(); 52268 const { clientId, isSelected: isBlockSelected2, name: blockName } = context; 52269 const blockBindings = context[blockBindingsKey]; 52270 const blockContext = (0, import_element184.useContext)(block_context_default); 52271 const registry = (0, import_data151.useRegistry)(); 52272 const selector3 = (select3) => { 52273 if (!isBlockSelected2) { 52274 return { isSelected: false }; 52275 } 52276 const { getSelectionStart: getSelectionStart22, getSelectionEnd: getSelectionEnd22, getBlockEditingMode: getBlockEditingMode2 } = select3(store); 52277 const selectionStart2 = getSelectionStart22(); 52278 const selectionEnd2 = getSelectionEnd22(); 52279 let isSelected2; 52280 if (originalIsSelected === void 0) { 52281 isSelected2 = selectionStart2.clientId === clientId && selectionEnd2.clientId === clientId && (identifier ? selectionStart2.attributeKey === identifier : selectionStart2[instanceIdKey] === instanceId); 52282 } else if (originalIsSelected) { 52283 isSelected2 = selectionStart2.clientId === clientId; 52284 } 52285 return { 52286 selectionStart: isSelected2 ? selectionStart2.offset : void 0, 52287 selectionEnd: isSelected2 ? selectionEnd2.offset : void 0, 52288 isSelected: isSelected2, 52289 isContentOnly: getBlockEditingMode2(clientId) === "contentOnly" 52290 }; 52291 }; 52292 const { selectionStart, selectionEnd, isSelected, isContentOnly } = (0, import_data151.useSelect)(selector3, [ 52293 clientId, 52294 identifier, 52295 instanceId, 52296 originalIsSelected, 52297 isBlockSelected2 52298 ]); 52299 const { disableBoundBlock, bindingsPlaceholder, bindingsLabel } = (0, import_data151.useSelect)( 52300 (select3) => { 52301 if (!blockBindings?.[identifier]) { 52302 return {}; 52303 } 52304 const { __experimentalBlockBindingsSupportedAttributes } = select3(store).getSettings(); 52305 const bindableAttributes = __experimentalBlockBindingsSupportedAttributes?.[blockName]; 52306 if (!bindableAttributes) { 52307 return {}; 52308 } 52309 const relatedBinding = blockBindings[identifier]; 52310 const blockBindingsSource = (0, import_blocks86.getBlockBindingsSource)( 52311 relatedBinding.source 52312 ); 52313 const blockBindingsContext = {}; 52314 if (blockBindingsSource?.usesContext?.length) { 52315 for (const key of blockBindingsSource.usesContext) { 52316 blockBindingsContext[key] = blockContext[key]; 52317 } 52318 } 52319 const _disableBoundBlock = !blockBindingsSource?.canUserEditValue?.({ 52320 select: select3, 52321 context: blockBindingsContext, 52322 args: relatedBinding.args 52323 }); 52324 if (adjustedValue.length > 0) { 52325 return { 52326 disableBoundBlock: _disableBoundBlock, 52327 // Null values will make them fall back to the default behavior. 52328 bindingsPlaceholder: null, 52329 bindingsLabel: null 52330 }; 52331 } 52332 const { getBlockAttributes: getBlockAttributes3 } = select3(store); 52333 const blockAttributes = getBlockAttributes3(clientId); 52334 let clientSideFieldLabel = null; 52335 if (blockBindingsSource?.getFieldsList) { 52336 const fieldsItems = blockBindingsSource.getFieldsList({ 52337 select: select3, 52338 context: blockBindingsContext 52339 }); 52340 clientSideFieldLabel = fieldsItems?.find( 52341 (item) => (0, import_es65.default)(item.args, relatedBinding?.args) 52342 )?.label; 52343 } 52344 const bindingKey = clientSideFieldLabel ?? blockBindingsSource?.label; 52345 const _bindingsPlaceholder = _disableBoundBlock ? bindingKey : (0, import_i18n166.sprintf)( 52346 /* translators: %s: connected field label or source label */ 52347 (0, import_i18n166.__)("Add %s"), 52348 bindingKey 52349 ); 52350 const _bindingsLabel = _disableBoundBlock ? relatedBinding?.args?.key || blockBindingsSource?.label : (0, import_i18n166.sprintf)( 52351 /* translators: %s: source label or key */ 52352 (0, import_i18n166.__)("Empty %s; start writing to edit its value"), 52353 relatedBinding?.args?.key || blockBindingsSource?.label 52354 ); 52355 return { 52356 disableBoundBlock: _disableBoundBlock, 52357 bindingsPlaceholder: blockAttributes?.placeholder || _bindingsPlaceholder, 52358 bindingsLabel: _bindingsLabel 52359 }; 52360 }, 52361 [ 52362 blockBindings, 52363 identifier, 52364 blockName, 52365 adjustedValue, 52366 clientId, 52367 blockContext 52368 ] 52369 ); 52370 const isInsidePatternOverrides = !!blockContext?.["pattern/overrides"]; 52371 const hasOverrideEnabled = blockBindings?.__default?.source === "core/pattern-overrides"; 52372 const shouldDisableForPattern = isInsidePatternOverrides && !hasOverrideEnabled; 52373 const shouldDisableEditing = readOnly || disableBoundBlock || shouldDisableForPattern; 52374 const { getSelectionStart: getSelectionStart2, getSelectionEnd: getSelectionEnd2, getBlockRootClientId: getBlockRootClientId2 } = (0, import_data151.useSelect)(store); 52375 const { selectionChange: selectionChange2 } = (0, import_data151.useDispatch)(store); 52376 const adjustedAllowedFormats = getAllowedFormats({ 52377 allowedFormats, 52378 disableFormats 52379 }); 52380 const hasFormats = !adjustedAllowedFormats || adjustedAllowedFormats.length > 0; 52381 const onSelectionChange = (0, import_element184.useCallback)( 52382 (start2, end) => { 52383 const selection2 = {}; 52384 const unset = start2 === void 0 && end === void 0; 52385 const baseSelection = { 52386 clientId, 52387 [identifier ? "attributeKey" : instanceIdKey]: identifier ? identifier : instanceId 52388 }; 52389 if (typeof start2 === "number" || unset) { 52390 if (end === void 0 && getBlockRootClientId2(clientId) !== getBlockRootClientId2(getSelectionEnd2().clientId)) { 52391 return; 52392 } 52393 selection2.start = { 52394 ...baseSelection, 52395 offset: start2 52396 }; 52397 } 52398 if (typeof end === "number" || unset) { 52399 if (start2 === void 0 && getBlockRootClientId2(clientId) !== getBlockRootClientId2(getSelectionStart2().clientId)) { 52400 return; 52401 } 52402 selection2.end = { 52403 ...baseSelection, 52404 offset: end 52405 }; 52406 } 52407 selectionChange2(selection2); 52408 }, 52409 [ 52410 clientId, 52411 getBlockRootClientId2, 52412 getSelectionEnd2, 52413 getSelectionStart2, 52414 identifier, 52415 instanceId, 52416 selectionChange2 52417 ] 52418 ); 52419 const { 52420 formatTypes, 52421 prepareHandlers, 52422 valueHandlers, 52423 changeHandlers, 52424 dependencies 52425 } = useFormatTypes({ 52426 clientId, 52427 identifier, 52428 allowedFormats: adjustedAllowedFormats, 52429 withoutInteractiveFormatting, 52430 disableNoneEssentialFormatting: isContentOnly 52431 }); 52432 function addEditorOnlyFormats(value2) { 52433 return valueHandlers.reduce( 52434 (accumulator, fn) => fn(accumulator, value2.text), 52435 value2.formats 52436 ); 52437 } 52438 function removeEditorOnlyFormats(value2) { 52439 formatTypes.forEach((formatType) => { 52440 if (formatType.__experimentalCreatePrepareEditableTree) { 52441 value2 = (0, import_rich_text15.removeFormat)( 52442 value2, 52443 formatType.name, 52444 0, 52445 value2.text.length 52446 ); 52447 } 52448 }); 52449 return value2.formats; 52450 } 52451 function addInvisibleFormats(value2) { 52452 return prepareHandlers.reduce( 52453 (accumulator, fn) => fn(accumulator, value2.text), 52454 value2.formats 52455 ); 52456 } 52457 const { 52458 value, 52459 getValue, 52460 onChange, 52461 ref: richTextRef 52462 } = (0, import_rich_text15.__unstableUseRichText)({ 52463 value: adjustedValue, 52464 onChange(html, { __unstableFormats, __unstableText }) { 52465 adjustedOnChange(html); 52466 Object.values(changeHandlers).forEach((changeHandler) => { 52467 changeHandler(__unstableFormats, __unstableText); 52468 }); 52469 }, 52470 selectionStart, 52471 selectionEnd, 52472 onSelectionChange, 52473 placeholder: bindingsPlaceholder || placeholder, 52474 __unstableIsSelected: isSelected, 52475 __unstableDisableFormats: disableFormats, 52476 preserveWhiteSpace, 52477 __unstableDependencies: [...dependencies, tagName], 52478 __unstableAfterParse: addEditorOnlyFormats, 52479 __unstableBeforeSerialize: removeEditorOnlyFormats, 52480 __unstableAddInvisibleFormats: addInvisibleFormats 52481 }); 52482 const autocompleteProps = useBlockEditorAutocompleteProps({ 52483 onReplace, 52484 completers: autocompleters, 52485 record: value, 52486 onChange 52487 }); 52488 useMarkPersistent({ html: adjustedValue, value }); 52489 const keyboardShortcuts = (0, import_element184.useRef)(/* @__PURE__ */ new Set()); 52490 const inputEvents = (0, import_element184.useRef)(/* @__PURE__ */ new Set()); 52491 function onFocus() { 52492 anchorRef.current?.focus(); 52493 } 52494 const TagName = tagName; 52495 return /* @__PURE__ */ (0, import_jsx_runtime336.jsxs)(import_jsx_runtime336.Fragment, { children: [ 52496 isSelected && /* @__PURE__ */ (0, import_jsx_runtime336.jsx)(keyboardShortcutContext.Provider, { value: keyboardShortcuts, children: /* @__PURE__ */ (0, import_jsx_runtime336.jsx)(inputEventContext.Provider, { value: inputEvents, children: /* @__PURE__ */ (0, import_jsx_runtime336.jsxs)(import_components178.Popover.__unstableSlotNameProvider, { value: "__unstable-block-tools-after", children: [ 52497 children && children({ value, onChange, onFocus }), 52498 /* @__PURE__ */ (0, import_jsx_runtime336.jsx)( 52499 FormatEdit, 52500 { 52501 value, 52502 onChange, 52503 onFocus, 52504 formatTypes, 52505 forwardedRef: anchorRef 52506 } 52507 ) 52508 ] }) }) }), 52509 isSelected && hasFormats && /* @__PURE__ */ (0, import_jsx_runtime336.jsx)( 52510 format_toolbar_container_default, 52511 { 52512 inline: inlineToolbar, 52513 editableContentElement: anchorElement 52514 } 52515 ), 52516 /* @__PURE__ */ (0, import_jsx_runtime336.jsx)( 52517 TagName, 52518 { 52519 role: "textbox", 52520 "aria-multiline": !disableLineBreaks, 52521 "aria-readonly": shouldDisableEditing, 52522 ...props, 52523 draggable: void 0, 52524 "aria-label": bindingsLabel || props["aria-label"] || placeholder, 52525 ...autocompleteProps, 52526 ref: (0, import_compose87.useMergeRefs)([ 52527 // Rich text ref must be first because its focus listener 52528 // must be set up before any other ref calls .focus() on 52529 // mount. 52530 richTextRef, 52531 forwardedRef, 52532 autocompleteProps.ref, 52533 props.ref, 52534 useEventListeners({ 52535 registry, 52536 getValue, 52537 onChange, 52538 __unstableAllowPrefixTransformations, 52539 formatTypes, 52540 onReplace, 52541 selectionChange: selectionChange2, 52542 isSelected, 52543 disableFormats, 52544 value, 52545 tagName, 52546 onSplit, 52547 __unstableEmbedURLOnPaste, 52548 pastePlainText, 52549 onMerge, 52550 onRemove, 52551 removeEditorOnlyFormats, 52552 disableLineBreaks, 52553 onSplitAtEnd, 52554 onSplitAtDoubleLineEnd, 52555 keyboardShortcuts, 52556 inputEvents 52557 }), 52558 anchorRef, 52559 setAnchorElement 52560 ]), 52561 contentEditable: !shouldDisableEditing, 52562 suppressContentEditableWarning: true, 52563 className: clsx_default( 52564 "block-editor-rich-text__editable", 52565 props.className, 52566 "rich-text" 52567 ), 52568 tabIndex: props.tabIndex === 0 && !shouldDisableEditing ? null : props.tabIndex, 52569 "data-wp-block-attribute-key": identifier 52570 } 52571 ) 52572 ] }); 52573 } 52574 var PrivateRichText = withDeprecations( 52575 (0, import_element184.forwardRef)(RichTextWrapper) 52576 ); 52577 PrivateRichText.Content = Content; 52578 PrivateRichText.isEmpty = (value) => { 52579 return !value || value.length === 0; 52580 }; 52581 var PublicForwardedRichTextContainer = (0, import_element184.forwardRef)((props, ref) => { 52582 const context = useBlockEditContext(); 52583 const isPreviewMode = context[isPreviewModeKey]; 52584 if (isPreviewMode) { 52585 const { 52586 children, 52587 tagName: Tag = "div", 52588 value, 52589 onChange, 52590 isSelected, 52591 multiline, 52592 inlineToolbar, 52593 wrapperClassName, 52594 autocompleters, 52595 onReplace, 52596 placeholder, 52597 allowedFormats, 52598 withoutInteractiveFormatting, 52599 onRemove, 52600 onMerge, 52601 onSplit, 52602 __unstableOnSplitAtEnd, 52603 __unstableOnSplitAtDoubleLineEnd, 52604 identifier, 52605 preserveWhiteSpace, 52606 __unstablePastePlainText, 52607 __unstableEmbedURLOnPaste, 52608 __unstableDisableFormats, 52609 disableLineBreaks, 52610 __unstableAllowPrefixTransformations, 52611 readOnly, 52612 ...contentProps 52613 } = removeNativeProps(props); 52614 return /* @__PURE__ */ (0, import_jsx_runtime336.jsx)( 52615 Tag, 52616 { 52617 ref, 52618 ...contentProps, 52619 dangerouslySetInnerHTML: { 52620 __html: valueToHTMLString(value, multiline) 52621 } 52622 } 52623 ); 52624 } 52625 return /* @__PURE__ */ (0, import_jsx_runtime336.jsx)(PrivateRichText, { ref, ...props, readOnly: false }); 52626 }); 52627 PublicForwardedRichTextContainer.Content = Content; 52628 PublicForwardedRichTextContainer.isEmpty = (value) => { 52629 return !value || value.length === 0; 52630 }; 52631 var rich_text_default = PublicForwardedRichTextContainer; 52632 52633 // packages/block-editor/build-module/components/editable-text/index.js 52634 var import_jsx_runtime337 = __toESM(require_jsx_runtime()); 52635 var EditableText = (0, import_element185.forwardRef)((props, ref) => { 52636 return /* @__PURE__ */ (0, import_jsx_runtime337.jsx)(rich_text_default, { ref, ...props, __unstableDisableFormats: true }); 52637 }); 52638 EditableText.Content = ({ value = "", tagName: Tag = "div", ...props }) => { 52639 return /* @__PURE__ */ (0, import_jsx_runtime337.jsx)(Tag, { ...props, children: value }); 52640 }; 52641 var editable_text_default = EditableText; 52642 52643 // packages/block-editor/build-module/components/plain-text/index.js 52644 var import_jsx_runtime338 = __toESM(require_jsx_runtime()); 52645 var PlainText = (0, import_element186.forwardRef)(({ __experimentalVersion, ...props }, ref) => { 52646 if (__experimentalVersion === 2) { 52647 return /* @__PURE__ */ (0, import_jsx_runtime338.jsx)(editable_text_default, { ref, ...props }); 52648 } 52649 const { className, onChange, ...remainingProps } = props; 52650 return /* @__PURE__ */ (0, import_jsx_runtime338.jsx)( 52651 import_react_autosize_textarea2.default, 52652 { 52653 ref, 52654 className: clsx_default("block-editor-plain-text", className), 52655 onChange: (event) => onChange(event.target.value), 52656 ...remainingProps 52657 } 52658 ); 52659 }); 52660 var plain_text_default = PlainText; 52661 52662 // packages/block-editor/build-module/components/responsive-block-control/index.js 52663 var import_i18n168 = __toESM(require_i18n()); 52664 var import_element187 = __toESM(require_element()); 52665 var import_components180 = __toESM(require_components()); 52666 52667 // packages/block-editor/build-module/components/responsive-block-control/label.js 52668 var import_compose88 = __toESM(require_compose()); 52669 var import_components179 = __toESM(require_components()); 52670 var import_i18n167 = __toESM(require_i18n()); 52671 var import_jsx_runtime339 = __toESM(require_jsx_runtime()); 52672 function ResponsiveBlockControlLabel({ 52673 property, 52674 viewport, 52675 desc 52676 }) { 52677 const instanceId = (0, import_compose88.useInstanceId)(ResponsiveBlockControlLabel); 52678 const accessibleLabel = desc || (0, import_i18n167.sprintf)( 52679 /* translators: 1: property name. 2: viewport name. */ 52680 (0, import_i18n167._x)( 52681 "Controls the %1$s property for %2$s viewports.", 52682 "Text labelling a interface as controlling a given layout property (eg: margin) for a given screen size." 52683 ), 52684 property, 52685 viewport.label 52686 ); 52687 return /* @__PURE__ */ (0, import_jsx_runtime339.jsxs)(import_jsx_runtime339.Fragment, { children: [ 52688 /* @__PURE__ */ (0, import_jsx_runtime339.jsx)("span", { "aria-describedby": `rbc-desc-$instanceId}`, children: viewport.label }), 52689 /* @__PURE__ */ (0, import_jsx_runtime339.jsx)(import_components179.VisuallyHidden, { as: "span", id: `rbc-desc-$instanceId}`, children: accessibleLabel }) 52690 ] }); 52691 } 52692 52693 // packages/block-editor/build-module/components/responsive-block-control/index.js 52694 var import_jsx_runtime340 = __toESM(require_jsx_runtime()); 52695 function ResponsiveBlockControl(props) { 52696 const { 52697 title, 52698 property, 52699 toggleLabel, 52700 onIsResponsiveChange, 52701 renderDefaultControl, 52702 renderResponsiveControls, 52703 isResponsive = false, 52704 defaultLabel = { 52705 id: "all", 52706 label: (0, import_i18n168._x)("All", "screen sizes") 52707 }, 52708 viewports = [ 52709 { 52710 id: "small", 52711 label: (0, import_i18n168.__)("Small screens") 52712 }, 52713 { 52714 id: "medium", 52715 label: (0, import_i18n168.__)("Medium screens") 52716 }, 52717 { 52718 id: "large", 52719 label: (0, import_i18n168.__)("Large screens") 52720 } 52721 ] 52722 } = props; 52723 if (!title || !property || !renderDefaultControl) { 52724 return null; 52725 } 52726 const toggleControlLabel = toggleLabel || (0, import_i18n168.sprintf)( 52727 /* translators: %s: Property value for the control (eg: margin, padding, etc.). */ 52728 (0, import_i18n168.__)("Use the same %s on all screen sizes."), 52729 property 52730 ); 52731 const toggleHelpText = (0, import_i18n168.__)( 52732 "Choose whether to use the same value for all screen sizes or a unique value for each screen size." 52733 ); 52734 const defaultControl = renderDefaultControl( 52735 /* @__PURE__ */ (0, import_jsx_runtime340.jsx)( 52736 ResponsiveBlockControlLabel, 52737 { 52738 property, 52739 viewport: defaultLabel 52740 } 52741 ), 52742 defaultLabel 52743 ); 52744 const defaultResponsiveControls = () => { 52745 return viewports.map((viewport) => /* @__PURE__ */ (0, import_jsx_runtime340.jsx)(import_element187.Fragment, { children: renderDefaultControl( 52746 /* @__PURE__ */ (0, import_jsx_runtime340.jsx)( 52747 ResponsiveBlockControlLabel, 52748 { 52749 property, 52750 viewport 52751 } 52752 ), 52753 viewport 52754 ) }, viewport.id)); 52755 }; 52756 return /* @__PURE__ */ (0, import_jsx_runtime340.jsxs)("fieldset", { className: "block-editor-responsive-block-control", children: [ 52757 /* @__PURE__ */ (0, import_jsx_runtime340.jsx)("legend", { className: "block-editor-responsive-block-control__title", children: title }), 52758 /* @__PURE__ */ (0, import_jsx_runtime340.jsxs)("div", { className: "block-editor-responsive-block-control__inner", children: [ 52759 /* @__PURE__ */ (0, import_jsx_runtime340.jsx)( 52760 import_components180.ToggleControl, 52761 { 52762 className: "block-editor-responsive-block-control__toggle", 52763 label: toggleControlLabel, 52764 checked: !isResponsive, 52765 onChange: onIsResponsiveChange, 52766 help: toggleHelpText 52767 } 52768 ), 52769 /* @__PURE__ */ (0, import_jsx_runtime340.jsxs)( 52770 "div", 52771 { 52772 className: clsx_default( 52773 "block-editor-responsive-block-control__group", 52774 { 52775 "is-responsive": isResponsive 52776 } 52777 ), 52778 children: [ 52779 !isResponsive && defaultControl, 52780 isResponsive && (renderResponsiveControls ? renderResponsiveControls(viewports) : defaultResponsiveControls()) 52781 ] 52782 } 52783 ) 52784 ] }) 52785 ] }); 52786 } 52787 var responsive_block_control_default = ResponsiveBlockControl; 52788 52789 // packages/block-editor/build-module/components/unit-control/index.js 52790 var import_components181 = __toESM(require_components()); 52791 var import_jsx_runtime341 = __toESM(require_jsx_runtime()); 52792 function UnitControl6({ units: unitsProp, ...props }) { 52793 const [availableUnits] = useSettings("spacing.units"); 52794 const units2 = (0, import_components181.__experimentalUseCustomUnits)({ 52795 availableUnits: availableUnits || ["%", "px", "em", "rem", "vw"], 52796 units: unitsProp 52797 }); 52798 return /* @__PURE__ */ (0, import_jsx_runtime341.jsx)(import_components181.__experimentalUnitControl, { units: units2, ...props }); 52799 } 52800 52801 // packages/block-editor/build-module/components/url-input/button.js 52802 var import_i18n169 = __toESM(require_i18n()); 52803 var import_element188 = __toESM(require_element()); 52804 var import_components182 = __toESM(require_components()); 52805 var import_jsx_runtime342 = __toESM(require_jsx_runtime()); 52806 function URLInputButton({ url, onChange }) { 52807 const [expanded2, toggleExpanded] = (0, import_element188.useReducer)( 52808 (isExpanded) => !isExpanded, 52809 false 52810 ); 52811 const submitLink = (event) => { 52812 event.preventDefault(); 52813 toggleExpanded(); 52814 }; 52815 return /* @__PURE__ */ (0, import_jsx_runtime342.jsxs)("div", { className: "block-editor-url-input__button", children: [ 52816 /* @__PURE__ */ (0, import_jsx_runtime342.jsx)( 52817 import_components182.Button, 52818 { 52819 size: "compact", 52820 icon: link_default, 52821 label: url ? (0, import_i18n169.__)("Edit link") : (0, import_i18n169.__)("Insert link"), 52822 onClick: toggleExpanded, 52823 className: "components-toolbar__control", 52824 isPressed: !!url 52825 } 52826 ), 52827 expanded2 && /* @__PURE__ */ (0, import_jsx_runtime342.jsx)( 52828 "form", 52829 { 52830 className: "block-editor-url-input__button-modal", 52831 onSubmit: submitLink, 52832 children: /* @__PURE__ */ (0, import_jsx_runtime342.jsxs)("div", { className: "block-editor-url-input__button-modal-line", children: [ 52833 /* @__PURE__ */ (0, import_jsx_runtime342.jsx)( 52834 import_components182.Button, 52835 { 52836 __next40pxDefaultSize: true, 52837 className: "block-editor-url-input__back", 52838 icon: arrow_left_default, 52839 label: (0, import_i18n169.__)("Close"), 52840 onClick: toggleExpanded 52841 } 52842 ), 52843 /* @__PURE__ */ (0, import_jsx_runtime342.jsx)( 52844 url_input_default, 52845 { 52846 value: url || "", 52847 onChange, 52848 suffix: /* @__PURE__ */ (0, import_jsx_runtime342.jsx)(import_components182.__experimentalInputControlSuffixWrapper, { variant: "control", children: /* @__PURE__ */ (0, import_jsx_runtime342.jsx)( 52849 import_components182.Button, 52850 { 52851 size: "small", 52852 icon: keyboard_return_default, 52853 label: (0, import_i18n169.__)("Submit"), 52854 type: "submit" 52855 } 52856 ) }) 52857 } 52858 ) 52859 ] }) 52860 } 52861 ) 52862 ] }); 52863 } 52864 var button_default = URLInputButton; 52865 52866 // packages/block-editor/build-module/components/url-popover/image-url-input-ui.js 52867 var import_i18n170 = __toESM(require_i18n()); 52868 var import_element189 = __toESM(require_element()); 52869 var import_dom37 = __toESM(require_dom()); 52870 var import_components183 = __toESM(require_components()); 52871 var import_url11 = __toESM(require_url()); 52872 var import_jsx_runtime343 = __toESM(require_jsx_runtime()); 52873 var LINK_DESTINATION_NONE = "none"; 52874 var LINK_DESTINATION_CUSTOM = "custom"; 52875 var LINK_DESTINATION_MEDIA = "media"; 52876 var LINK_DESTINATION_ATTACHMENT = "attachment"; 52877 var NEW_TAB_REL = ["noreferrer", "noopener"]; 52878 var ImageURLInputUI = ({ 52879 linkDestination, 52880 onChangeUrl, 52881 url, 52882 mediaType = "image", 52883 mediaUrl, 52884 mediaLink, 52885 linkTarget, 52886 linkClass, 52887 rel, 52888 showLightboxSetting, 52889 lightboxEnabled, 52890 onSetLightbox, 52891 resetLightbox 52892 }) => { 52893 const [isOpen, setIsOpen] = (0, import_element189.useState)(false); 52894 const [popoverAnchor, setPopoverAnchor] = (0, import_element189.useState)(null); 52895 const openLinkUI = () => { 52896 setIsOpen(true); 52897 }; 52898 const [isEditingLink, setIsEditingLink] = (0, import_element189.useState)(false); 52899 const [urlInput, setUrlInput] = (0, import_element189.useState)(null); 52900 const autocompleteRef = (0, import_element189.useRef)(null); 52901 const wrapperRef = (0, import_element189.useRef)(); 52902 (0, import_element189.useEffect)(() => { 52903 if (!wrapperRef.current) { 52904 return; 52905 } 52906 const nextFocusTarget = import_dom37.focus.focusable.find(wrapperRef.current)[0] || wrapperRef.current; 52907 nextFocusTarget.focus(); 52908 }, [isEditingLink, url, lightboxEnabled]); 52909 const startEditLink = () => { 52910 if (linkDestination === LINK_DESTINATION_MEDIA || linkDestination === LINK_DESTINATION_ATTACHMENT) { 52911 setUrlInput(""); 52912 } 52913 setIsEditingLink(true); 52914 }; 52915 const stopEditLink = () => { 52916 setIsEditingLink(false); 52917 }; 52918 const closeLinkUI = () => { 52919 setUrlInput(null); 52920 stopEditLink(); 52921 setIsOpen(false); 52922 }; 52923 const getUpdatedLinkTargetSettings = (value) => { 52924 const newLinkTarget = value ? "_blank" : void 0; 52925 let updatedRel; 52926 if (newLinkTarget) { 52927 const rels = (rel ?? "").split(" "); 52928 NEW_TAB_REL.forEach((relVal) => { 52929 if (!rels.includes(relVal)) { 52930 rels.push(relVal); 52931 } 52932 }); 52933 updatedRel = rels.join(" "); 52934 } else { 52935 const rels = (rel ?? "").split(" ").filter( 52936 (relVal) => NEW_TAB_REL.includes(relVal) === false 52937 ); 52938 updatedRel = rels.length ? rels.join(" ") : void 0; 52939 } 52940 return { 52941 linkTarget: newLinkTarget, 52942 rel: updatedRel 52943 }; 52944 }; 52945 const onFocusOutside = () => { 52946 return (event) => { 52947 const autocompleteElement = autocompleteRef.current; 52948 if (autocompleteElement && autocompleteElement.contains(event.target)) { 52949 return; 52950 } 52951 setIsOpen(false); 52952 setUrlInput(null); 52953 stopEditLink(); 52954 }; 52955 }; 52956 const onSubmitLinkChange = () => { 52957 return (event) => { 52958 if (urlInput) { 52959 const selectedDestination = getLinkDestinations().find( 52960 (destination) => destination.url === urlInput 52961 )?.linkDestination || LINK_DESTINATION_CUSTOM; 52962 onChangeUrl({ 52963 href: (0, import_url11.prependHTTP)(urlInput), 52964 linkDestination: selectedDestination, 52965 lightbox: { enabled: false } 52966 }); 52967 } 52968 stopEditLink(); 52969 setUrlInput(null); 52970 event.preventDefault(); 52971 }; 52972 }; 52973 const onLinkRemove = () => { 52974 onChangeUrl({ 52975 linkDestination: LINK_DESTINATION_NONE, 52976 href: "" 52977 }); 52978 }; 52979 const getLinkDestinations = () => { 52980 const linkDestinations = [ 52981 { 52982 linkDestination: LINK_DESTINATION_MEDIA, 52983 title: (0, import_i18n170.__)("Link to image file"), 52984 url: mediaType === "image" ? mediaUrl : void 0, 52985 icon: image_default 52986 } 52987 ]; 52988 if (mediaType === "image" && mediaLink) { 52989 linkDestinations.push({ 52990 linkDestination: LINK_DESTINATION_ATTACHMENT, 52991 title: (0, import_i18n170.__)("Link to attachment page"), 52992 url: mediaType === "image" ? mediaLink : void 0, 52993 icon: page_default 52994 }); 52995 } 52996 return linkDestinations; 52997 }; 52998 const onSetHref = (value) => { 52999 const linkDestinations = getLinkDestinations(); 53000 let linkDestinationInput; 53001 if (!value) { 53002 linkDestinationInput = LINK_DESTINATION_NONE; 53003 } else { 53004 linkDestinationInput = (linkDestinations.find((destination) => { 53005 return destination.url === value; 53006 }) || { linkDestination: LINK_DESTINATION_CUSTOM }).linkDestination; 53007 } 53008 onChangeUrl({ 53009 linkDestination: linkDestinationInput, 53010 href: value 53011 }); 53012 }; 53013 const onSetNewTab = (value) => { 53014 const updatedLinkTarget = getUpdatedLinkTargetSettings(value); 53015 onChangeUrl(updatedLinkTarget); 53016 }; 53017 const onSetLinkRel = (value) => { 53018 onChangeUrl({ rel: value }); 53019 }; 53020 const onSetLinkClass = (value) => { 53021 onChangeUrl({ linkClass: value }); 53022 }; 53023 const advancedOptions = /* @__PURE__ */ (0, import_jsx_runtime343.jsxs)(import_components183.__experimentalVStack, { spacing: "3", children: [ 53024 /* @__PURE__ */ (0, import_jsx_runtime343.jsx)( 53025 import_components183.ToggleControl, 53026 { 53027 label: (0, import_i18n170.__)("Open in new tab"), 53028 onChange: onSetNewTab, 53029 checked: linkTarget === "_blank" 53030 } 53031 ), 53032 /* @__PURE__ */ (0, import_jsx_runtime343.jsx)( 53033 import_components183.TextControl, 53034 { 53035 __next40pxDefaultSize: true, 53036 label: (0, import_i18n170.__)("Link relation"), 53037 value: rel ?? "", 53038 onChange: onSetLinkRel, 53039 help: (0, import_element189.createInterpolateElement)( 53040 (0, import_i18n170.__)( 53041 "The <a>Link Relation</a> attribute defines the relationship between a linked resource and the current document." 53042 ), 53043 { 53044 a: /* @__PURE__ */ (0, import_jsx_runtime343.jsx)(import_components183.ExternalLink, { href: "https://developer.mozilla.org/docs/Web/HTML/Attributes/rel" }) 53045 } 53046 ) 53047 } 53048 ), 53049 /* @__PURE__ */ (0, import_jsx_runtime343.jsx)( 53050 import_components183.TextControl, 53051 { 53052 __next40pxDefaultSize: true, 53053 label: (0, import_i18n170.__)("Link CSS class"), 53054 value: linkClass || "", 53055 onChange: onSetLinkClass 53056 } 53057 ) 53058 ] }); 53059 const linkEditorValue = urlInput !== null ? urlInput : url; 53060 const hideLightboxPanel = !lightboxEnabled || lightboxEnabled && !showLightboxSetting; 53061 const showLinkEditor = !linkEditorValue && hideLightboxPanel; 53062 const urlLabel = (getLinkDestinations().find( 53063 (destination) => destination.linkDestination === linkDestination 53064 ) || {}).title; 53065 const PopoverChildren = () => { 53066 if (lightboxEnabled && showLightboxSetting && !url && !isEditingLink) { 53067 return /* @__PURE__ */ (0, import_jsx_runtime343.jsxs)("div", { className: "block-editor-url-popover__expand-on-click", children: [ 53068 /* @__PURE__ */ (0, import_jsx_runtime343.jsx)(icon_default, { icon: fullscreen_default }), 53069 /* @__PURE__ */ (0, import_jsx_runtime343.jsxs)("div", { className: "text", children: [ 53070 /* @__PURE__ */ (0, import_jsx_runtime343.jsx)("p", { children: (0, import_i18n170.__)("Enlarge on click") }), 53071 /* @__PURE__ */ (0, import_jsx_runtime343.jsx)("p", { className: "description", children: (0, import_i18n170.__)("Scales the image with a lightbox effect") }) 53072 ] }), 53073 /* @__PURE__ */ (0, import_jsx_runtime343.jsx)( 53074 import_components183.Button, 53075 { 53076 icon: link_off_default, 53077 label: (0, import_i18n170.__)("Disable enlarge on click"), 53078 onClick: () => { 53079 onSetLightbox?.(false); 53080 }, 53081 size: "compact" 53082 } 53083 ) 53084 ] }); 53085 } else if (!url || isEditingLink) { 53086 return /* @__PURE__ */ (0, import_jsx_runtime343.jsx)( 53087 url_popover_default.LinkEditor, 53088 { 53089 className: "block-editor-format-toolbar__link-container-content", 53090 value: linkEditorValue, 53091 onChangeInputValue: setUrlInput, 53092 onSubmit: onSubmitLinkChange(), 53093 autocompleteRef 53094 } 53095 ); 53096 } else if (url && !isEditingLink) { 53097 return /* @__PURE__ */ (0, import_jsx_runtime343.jsxs)(import_jsx_runtime343.Fragment, { children: [ 53098 /* @__PURE__ */ (0, import_jsx_runtime343.jsx)( 53099 url_popover_default.LinkViewer, 53100 { 53101 className: "block-editor-format-toolbar__link-container-content", 53102 url, 53103 onEditLinkClick: startEditLink, 53104 urlLabel 53105 } 53106 ), 53107 /* @__PURE__ */ (0, import_jsx_runtime343.jsx)( 53108 import_components183.Button, 53109 { 53110 icon: link_off_default, 53111 label: (0, import_i18n170.__)("Remove link"), 53112 onClick: () => { 53113 onLinkRemove(); 53114 resetLightbox?.(); 53115 }, 53116 size: "compact" 53117 } 53118 ) 53119 ] }); 53120 } 53121 }; 53122 return /* @__PURE__ */ (0, import_jsx_runtime343.jsxs)(import_jsx_runtime343.Fragment, { children: [ 53123 /* @__PURE__ */ (0, import_jsx_runtime343.jsx)( 53124 import_components183.ToolbarButton, 53125 { 53126 icon: link_default, 53127 className: "components-toolbar__control", 53128 label: (0, import_i18n170.__)("Link"), 53129 "aria-expanded": isOpen, 53130 onClick: openLinkUI, 53131 ref: setPopoverAnchor, 53132 isActive: !!url || lightboxEnabled && showLightboxSetting 53133 } 53134 ), 53135 isOpen && /* @__PURE__ */ (0, import_jsx_runtime343.jsx)( 53136 url_popover_default, 53137 { 53138 ref: wrapperRef, 53139 anchor: popoverAnchor, 53140 onFocusOutside: onFocusOutside(), 53141 onClose: closeLinkUI, 53142 renderSettings: hideLightboxPanel ? () => advancedOptions : null, 53143 additionalControls: showLinkEditor && /* @__PURE__ */ (0, import_jsx_runtime343.jsxs)(import_components183.NavigableMenu, { children: [ 53144 getLinkDestinations().map((link) => /* @__PURE__ */ (0, import_jsx_runtime343.jsx)( 53145 import_components183.MenuItem, 53146 { 53147 icon: link.icon, 53148 iconPosition: "left", 53149 onClick: () => { 53150 setUrlInput(null); 53151 onSetHref(link.url); 53152 stopEditLink(); 53153 }, 53154 children: link.title 53155 }, 53156 link.linkDestination 53157 )), 53158 showLightboxSetting && /* @__PURE__ */ (0, import_jsx_runtime343.jsx)( 53159 import_components183.MenuItem, 53160 { 53161 className: "block-editor-url-popover__expand-on-click", 53162 icon: fullscreen_default, 53163 info: (0, import_i18n170.__)( 53164 "Scale the image with a lightbox effect." 53165 ), 53166 iconPosition: "left", 53167 onClick: () => { 53168 setUrlInput(null); 53169 onChangeUrl({ 53170 linkDestination: LINK_DESTINATION_NONE, 53171 href: "" 53172 }); 53173 onSetLightbox?.(true); 53174 stopEditLink(); 53175 }, 53176 children: (0, import_i18n170.__)("Enlarge on click") 53177 }, 53178 "expand-on-click" 53179 ) 53180 ] }), 53181 offset: 13, 53182 children: PopoverChildren() 53183 } 53184 ) 53185 ] }); 53186 }; 53187 53188 // packages/block-editor/build-module/components/spacing-sizes-control/index.js 53189 var import_components186 = __toESM(require_components()); 53190 var import_element192 = __toESM(require_element()); 53191 var import_i18n174 = __toESM(require_i18n()); 53192 53193 // packages/block-editor/build-module/components/spacing-sizes-control/hooks/use-spacing-sizes.js 53194 var import_element190 = __toESM(require_element()); 53195 var import_i18n171 = __toESM(require_i18n()); 53196 var EMPTY_ARRAY11 = []; 53197 var compare = new Intl.Collator("und", { numeric: true }).compare; 53198 function useSpacingSizes() { 53199 const [ 53200 customSpacingSizes, 53201 themeSpacingSizes, 53202 defaultSpacingSizes, 53203 defaultSpacingSizesEnabled 53204 ] = useSettings( 53205 "spacing.spacingSizes.custom", 53206 "spacing.spacingSizes.theme", 53207 "spacing.spacingSizes.default", 53208 "spacing.defaultSpacingSizes" 53209 ); 53210 const customSizes = customSpacingSizes ?? EMPTY_ARRAY11; 53211 const themeSizes = themeSpacingSizes ?? EMPTY_ARRAY11; 53212 const defaultSizes = defaultSpacingSizes && defaultSpacingSizesEnabled !== false ? defaultSpacingSizes : EMPTY_ARRAY11; 53213 return (0, import_element190.useMemo)(() => { 53214 const sizes = [ 53215 { name: (0, import_i18n171.__)("None"), slug: "0", size: 0 }, 53216 ...customSizes, 53217 ...themeSizes, 53218 ...defaultSizes 53219 ]; 53220 if (sizes.every(({ slug }) => /^[0-9]/.test(slug))) { 53221 sizes.sort((a2, b2) => compare(a2.slug, b2.slug)); 53222 } 53223 return sizes.length > RANGE_CONTROL_MAX_SIZE ? [ 53224 { 53225 name: (0, import_i18n171.__)("Default"), 53226 slug: "default", 53227 size: void 0 53228 }, 53229 ...sizes 53230 ] : sizes; 53231 }, [customSizes, themeSizes, defaultSizes]); 53232 } 53233 53234 // packages/block-editor/build-module/components/spacing-sizes-control/input-controls/spacing-input-control.js 53235 var import_element191 = __toESM(require_element()); 53236 var import_data152 = __toESM(require_data()); 53237 var import_i18n172 = __toESM(require_i18n()); 53238 var import_components184 = __toESM(require_components()); 53239 var import_jsx_runtime344 = __toESM(require_jsx_runtime()); 53240 var CUSTOM_VALUE_SETTINGS2 = { 53241 px: { max: 300, steps: 1 }, 53242 "%": { max: 100, steps: 1 }, 53243 vw: { max: 100, steps: 1 }, 53244 vh: { max: 100, steps: 1 }, 53245 em: { max: 10, steps: 0.1 }, 53246 rm: { max: 10, steps: 0.1 }, 53247 svw: { max: 100, steps: 1 }, 53248 lvw: { max: 100, steps: 1 }, 53249 dvw: { max: 100, steps: 1 }, 53250 svh: { max: 100, steps: 1 }, 53251 lvh: { max: 100, steps: 1 }, 53252 dvh: { max: 100, steps: 1 }, 53253 vi: { max: 100, steps: 1 }, 53254 svi: { max: 100, steps: 1 }, 53255 lvi: { max: 100, steps: 1 }, 53256 dvi: { max: 100, steps: 1 }, 53257 vb: { max: 100, steps: 1 }, 53258 svb: { max: 100, steps: 1 }, 53259 lvb: { max: 100, steps: 1 }, 53260 dvb: { max: 100, steps: 1 }, 53261 vmin: { max: 100, steps: 1 }, 53262 svmin: { max: 100, steps: 1 }, 53263 lvmin: { max: 100, steps: 1 }, 53264 dvmin: { max: 100, steps: 1 }, 53265 vmax: { max: 100, steps: 1 }, 53266 svmax: { max: 100, steps: 1 }, 53267 lvmax: { max: 100, steps: 1 }, 53268 dvmax: { max: 100, steps: 1 } 53269 }; 53270 function SpacingInputControl({ 53271 icon, 53272 isMixed = false, 53273 minimumCustomValue, 53274 onChange, 53275 onMouseOut, 53276 onMouseOver, 53277 showSideInLabel = true, 53278 side, 53279 spacingSizes, 53280 type, 53281 value, 53282 ...restProps 53283 }) { 53284 const disableCustomSpacingSizes = (0, import_data152.useSelect)((select3) => { 53285 const editorSettings = select3(store).getSettings(); 53286 return editorSettings?.disableCustomSpacingSizes; 53287 }); 53288 const [availableUnits] = useSettings("spacing.units"); 53289 const units2 = (0, import_components184.__experimentalUseCustomUnits)({ 53290 availableUnits: availableUnits || ["px", "em", "rem"] 53291 }); 53292 const presets = (0, import_element191.useMemo)(() => { 53293 return spacingSizes?.map((preset) => ({ 53294 name: preset.name, 53295 slug: preset.slug, 53296 size: preset.size 53297 })) || []; 53298 }, [spacingSizes]); 53299 const sideLabel = (ALL_SIDES.includes(side) || ["vertical", "horizontal"].includes(side)) && showSideInLabel ? LABELS[side] : ""; 53300 const typeLabel = showSideInLabel ? type?.toLowerCase() : type; 53301 const ariaLabel = (0, import_i18n172.sprintf)( 53302 // translators: 1: The side of the block being modified (top, bottom, left etc.). 2. Type of spacing being modified (padding, margin, etc). 53303 (0, import_i18n172._x)("%1$s %2$s", "spacing"), 53304 sideLabel, 53305 typeLabel 53306 ).trim(); 53307 const selectedUnit = units2[0]?.value || "px"; 53308 return /* @__PURE__ */ (0, import_jsx_runtime344.jsx)( 53309 PresetInputControl, 53310 { 53311 allowNegativeOnDrag: minimumCustomValue < 0, 53312 ariaLabel, 53313 className: "spacing-sizes-control", 53314 customValueSettings: CUSTOM_VALUE_SETTINGS2, 53315 disableCustomValues: disableCustomSpacingSizes, 53316 icon, 53317 isMixed, 53318 minimumCustomValue, 53319 onChange, 53320 onMouseOut, 53321 onMouseOver, 53322 presets, 53323 presetType: "spacing", 53324 selectedUnit, 53325 units: units2, 53326 value, 53327 ...restProps 53328 } 53329 ); 53330 } 53331 53332 // packages/block-editor/build-module/components/spacing-sizes-control/input-controls/axial.js 53333 var import_jsx_runtime345 = __toESM(require_jsx_runtime()); 53334 var groupedSides = ["vertical", "horizontal"]; 53335 function AxialInputControls({ 53336 minimumCustomValue, 53337 onChange, 53338 onMouseOut, 53339 onMouseOver, 53340 sides, 53341 spacingSizes, 53342 type, 53343 values 53344 }) { 53345 const createHandleOnChange = (side) => (next) => { 53346 if (!onChange) { 53347 return; 53348 } 53349 const nextValues = { 53350 ...Object.keys(values).reduce((acc, key) => { 53351 acc[key] = getPresetValueFromCustomValue( 53352 values[key], 53353 spacingSizes 53354 ); 53355 return acc; 53356 }, {}) 53357 }; 53358 if (side === "vertical") { 53359 nextValues.top = next; 53360 nextValues.bottom = next; 53361 } 53362 if (side === "horizontal") { 53363 nextValues.left = next; 53364 nextValues.right = next; 53365 } 53366 onChange(nextValues); 53367 }; 53368 const filteredSides = sides?.length ? groupedSides.filter((side) => hasAxisSupport(sides, side)) : groupedSides; 53369 return /* @__PURE__ */ (0, import_jsx_runtime345.jsx)(import_jsx_runtime345.Fragment, { children: filteredSides.map((side) => { 53370 const axisValue = side === "vertical" ? values.top : values.left; 53371 return /* @__PURE__ */ (0, import_jsx_runtime345.jsx)( 53372 SpacingInputControl, 53373 { 53374 icon: ICONS[side], 53375 label: LABELS[side], 53376 minimumCustomValue, 53377 onChange: createHandleOnChange(side), 53378 onMouseOut, 53379 onMouseOver, 53380 side, 53381 spacingSizes, 53382 type, 53383 value: axisValue, 53384 withInputField: false 53385 }, 53386 `spacing-sizes-control-$side}` 53387 ); 53388 }) }); 53389 } 53390 53391 // packages/block-editor/build-module/components/spacing-sizes-control/input-controls/separated.js 53392 var import_jsx_runtime346 = __toESM(require_jsx_runtime()); 53393 function SeparatedInputControls({ 53394 minimumCustomValue, 53395 onChange, 53396 onMouseOut, 53397 onMouseOver, 53398 sides, 53399 spacingSizes, 53400 type, 53401 values 53402 }) { 53403 const filteredSides = sides?.length ? ALL_SIDES.filter((side) => sides.includes(side)) : ALL_SIDES; 53404 const createHandleOnChange = (side) => (next) => { 53405 const nextValues = { 53406 ...Object.keys(values).reduce((acc, key) => { 53407 acc[key] = getPresetValueFromCustomValue( 53408 values[key], 53409 spacingSizes 53410 ); 53411 return acc; 53412 }, {}) 53413 }; 53414 nextValues[side] = next; 53415 onChange(nextValues); 53416 }; 53417 return /* @__PURE__ */ (0, import_jsx_runtime346.jsx)(import_jsx_runtime346.Fragment, { children: filteredSides.map((side) => { 53418 return /* @__PURE__ */ (0, import_jsx_runtime346.jsx)( 53419 SpacingInputControl, 53420 { 53421 icon: ICONS[side], 53422 label: LABELS[side], 53423 minimumCustomValue, 53424 onChange: createHandleOnChange(side), 53425 onMouseOut, 53426 onMouseOver, 53427 side, 53428 spacingSizes, 53429 type, 53430 value: values[side], 53431 withInputField: false 53432 }, 53433 `spacing-sizes-control-$side}` 53434 ); 53435 }) }); 53436 } 53437 53438 // packages/block-editor/build-module/components/spacing-sizes-control/input-controls/single.js 53439 var import_jsx_runtime347 = __toESM(require_jsx_runtime()); 53440 function SingleInputControl({ 53441 minimumCustomValue, 53442 onChange, 53443 onMouseOut, 53444 onMouseOver, 53445 showSideInLabel, 53446 side, 53447 spacingSizes, 53448 type, 53449 values 53450 }) { 53451 const createHandleOnChange = (currentSide) => (next) => { 53452 const nextValues = { 53453 ...Object.keys(values).reduce((acc, key) => { 53454 acc[key] = getPresetValueFromCustomValue( 53455 values[key], 53456 spacingSizes 53457 ); 53458 return acc; 53459 }, {}) 53460 }; 53461 nextValues[currentSide] = next; 53462 onChange(nextValues); 53463 }; 53464 return /* @__PURE__ */ (0, import_jsx_runtime347.jsx)( 53465 SpacingInputControl, 53466 { 53467 label: LABELS[side], 53468 minimumCustomValue, 53469 onChange: createHandleOnChange(side), 53470 onMouseOut, 53471 onMouseOver, 53472 showSideInLabel, 53473 side, 53474 spacingSizes, 53475 type, 53476 value: values[side], 53477 withInputField: false 53478 } 53479 ); 53480 } 53481 53482 // packages/block-editor/build-module/components/spacing-sizes-control/linked-button.js 53483 var import_components185 = __toESM(require_components()); 53484 var import_i18n173 = __toESM(require_i18n()); 53485 var import_jsx_runtime348 = __toESM(require_jsx_runtime()); 53486 function LinkedButton2({ isLinked, ...props }) { 53487 const label = isLinked ? (0, import_i18n173.__)("Unlink sides") : (0, import_i18n173.__)("Link sides"); 53488 return /* @__PURE__ */ (0, import_jsx_runtime348.jsx)( 53489 import_components185.Button, 53490 { 53491 ...props, 53492 size: "small", 53493 icon: isLinked ? link_default : link_off_default, 53494 iconSize: 24, 53495 label 53496 } 53497 ); 53498 } 53499 53500 // packages/block-editor/build-module/components/spacing-sizes-control/index.js 53501 var import_jsx_runtime349 = __toESM(require_jsx_runtime()); 53502 function SpacingSizesControl({ 53503 inputProps, 53504 label: labelProp, 53505 minimumCustomValue = 0, 53506 onChange, 53507 onMouseOut, 53508 onMouseOver, 53509 showSideInLabel = true, 53510 sides = ALL_SIDES, 53511 useSelect: useSelect167, 53512 values 53513 }) { 53514 const spacingSizes = useSpacingSizes(); 53515 const inputValues = values || DEFAULT_VALUES; 53516 const hasOneSide = sides?.length === 1; 53517 const hasOnlyAxialSides = sides?.includes("horizontal") && sides?.includes("vertical") && sides?.length === 2; 53518 const [view, setView] = (0, import_element192.useState)(getInitialView(inputValues, sides)); 53519 const toggleLinked = () => { 53520 setView(view === VIEWS.axial ? VIEWS.custom : VIEWS.axial); 53521 }; 53522 const handleOnChange = (nextValue) => { 53523 const newValues = { ...values, ...nextValue }; 53524 onChange(newValues); 53525 }; 53526 const inputControlProps = { 53527 ...inputProps, 53528 minimumCustomValue, 53529 onChange: handleOnChange, 53530 onMouseOut, 53531 onMouseOver, 53532 sides, 53533 spacingSizes, 53534 type: labelProp, 53535 useSelect: useSelect167, 53536 values: inputValues 53537 }; 53538 const renderControls = () => { 53539 if (view === VIEWS.axial) { 53540 return /* @__PURE__ */ (0, import_jsx_runtime349.jsx)(AxialInputControls, { ...inputControlProps }); 53541 } 53542 if (view === VIEWS.custom) { 53543 return /* @__PURE__ */ (0, import_jsx_runtime349.jsx)(SeparatedInputControls, { ...inputControlProps }); 53544 } 53545 return /* @__PURE__ */ (0, import_jsx_runtime349.jsx)( 53546 SingleInputControl, 53547 { 53548 side: view, 53549 ...inputControlProps, 53550 showSideInLabel 53551 } 53552 ); 53553 }; 53554 const sideLabel = ALL_SIDES.includes(view) && showSideInLabel ? LABELS[view] : ""; 53555 const label = (0, import_i18n174.sprintf)( 53556 // translators: 1: The side of the block being modified (top, bottom, left etc.). 2. Type of spacing being modified (padding, margin, etc). 53557 (0, import_i18n174._x)("%1$s %2$s", "spacing"), 53558 labelProp, 53559 sideLabel 53560 ).trim(); 53561 return /* @__PURE__ */ (0, import_jsx_runtime349.jsxs)("fieldset", { className: "spacing-sizes-control", children: [ 53562 /* @__PURE__ */ (0, import_jsx_runtime349.jsxs)(import_components186.__experimentalHStack, { className: "spacing-sizes-control__header", children: [ 53563 /* @__PURE__ */ (0, import_jsx_runtime349.jsx)( 53564 import_components186.BaseControl.VisualLabel, 53565 { 53566 as: "legend", 53567 className: "spacing-sizes-control__label", 53568 children: label 53569 } 53570 ), 53571 !hasOneSide && !hasOnlyAxialSides && /* @__PURE__ */ (0, import_jsx_runtime349.jsx)( 53572 LinkedButton2, 53573 { 53574 label: labelProp, 53575 onClick: toggleLinked, 53576 isLinked: view === VIEWS.axial 53577 } 53578 ) 53579 ] }), 53580 /* @__PURE__ */ (0, import_jsx_runtime349.jsx)(import_components186.__experimentalVStack, { spacing: 0.5, children: renderControls() }) 53581 ] }); 53582 } 53583 53584 // packages/block-editor/build-module/components/preview-options/index.js 53585 var import_deprecated31 = __toESM(require_deprecated()); 53586 function PreviewOptions() { 53587 (0, import_deprecated31.default)("wp.blockEditor.PreviewOptions", { 53588 version: "6.5" 53589 }); 53590 return null; 53591 } 53592 53593 // packages/block-editor/build-module/components/use-resize-canvas/index.js 53594 var import_element193 = __toESM(require_element()); 53595 function useResizeCanvas(deviceType) { 53596 const [actualWidth, updateActualWidth] = (0, import_element193.useState)(window.innerWidth); 53597 (0, import_element193.useEffect)(() => { 53598 if (deviceType === "Desktop") { 53599 return; 53600 } 53601 const resizeListener = () => updateActualWidth(window.innerWidth); 53602 window.addEventListener("resize", resizeListener); 53603 return () => { 53604 window.removeEventListener("resize", resizeListener); 53605 }; 53606 }, [deviceType]); 53607 const getCanvasWidth = (device) => { 53608 let deviceWidth; 53609 switch (device) { 53610 case "Tablet": 53611 deviceWidth = 780; 53612 break; 53613 case "Mobile": 53614 deviceWidth = 360; 53615 break; 53616 default: 53617 return null; 53618 } 53619 return deviceWidth < actualWidth ? deviceWidth : actualWidth; 53620 }; 53621 const contentInlineStyles = (device) => { 53622 const height = device === "Mobile" ? "768px" : "1024px"; 53623 const marginVertical = "40px"; 53624 const marginHorizontal = "auto"; 53625 switch (device) { 53626 case "Tablet": 53627 case "Mobile": 53628 return { 53629 width: getCanvasWidth(device), 53630 // Keeping margin styles separate to avoid warnings 53631 // when those props get overridden in the iframe component 53632 marginTop: marginVertical, 53633 marginBottom: marginVertical, 53634 marginLeft: marginHorizontal, 53635 marginRight: marginHorizontal, 53636 height, 53637 overflowY: "auto" 53638 }; 53639 default: 53640 return { 53641 marginLeft: marginHorizontal, 53642 marginRight: marginHorizontal 53643 }; 53644 } 53645 }; 53646 return contentInlineStyles(deviceType); 53647 } 53648 53649 // packages/block-editor/build-module/components/block-inspector/index.js 53650 var import_i18n220 = __toESM(require_i18n()); 53651 var import_blocks93 = __toESM(require_blocks()); 53652 var import_components242 = __toESM(require_components()); 53653 var import_data172 = __toESM(require_data()); 53654 53655 // packages/block-editor/build-module/components/block-inspector/edit-contents.js 53656 var import_components187 = __toESM(require_components()); 53657 var import_i18n175 = __toESM(require_i18n()); 53658 var import_data153 = __toESM(require_data()); 53659 var import_blocks87 = __toESM(require_blocks()); 53660 var import_jsx_runtime350 = __toESM(require_jsx_runtime()); 53661 function IsolatedEditButton({ 53662 block, 53663 onNavigateToEntityRecord, 53664 isSyncedPattern, 53665 isTemplatePartBlock 53666 }) { 53667 const blockAttributes = block?.attributes || {}; 53668 const handleClick = () => { 53669 if (isSyncedPattern) { 53670 onNavigateToEntityRecord({ 53671 postId: blockAttributes.ref, 53672 postType: "wp_block" 53673 }); 53674 } else if (isTemplatePartBlock) { 53675 const { theme, slug } = blockAttributes; 53676 const templatePartId = theme && slug ? `$theme}//${slug}` : null; 53677 if (templatePartId) { 53678 onNavigateToEntityRecord({ 53679 postId: templatePartId, 53680 postType: "wp_template_part" 53681 }); 53682 } 53683 } 53684 }; 53685 return /* @__PURE__ */ (0, import_jsx_runtime350.jsx)(import_components187.__experimentalVStack, { className: "block-editor-block-inspector-edit-contents", expanded: true, children: /* @__PURE__ */ (0, import_jsx_runtime350.jsx)( 53686 import_components187.Button, 53687 { 53688 className: "block-editor-block-inspector-edit-contents__button", 53689 __next40pxDefaultSize: true, 53690 variant: "secondary", 53691 onClick: handleClick, 53692 children: (0, import_i18n175.__)("Edit section") 53693 } 53694 ) }); 53695 } 53696 function InlineEditButton({ 53697 clientId, 53698 editedContentOnlySection: editedContentOnlySection2, 53699 editContentOnlySection: editContentOnlySection2, 53700 stopEditingContentOnlySection: stopEditingContentOnlySection2 53701 }) { 53702 const handleClick = () => { 53703 if (!editedContentOnlySection2) { 53704 editContentOnlySection2(clientId); 53705 } else { 53706 stopEditingContentOnlySection2(); 53707 } 53708 }; 53709 return /* @__PURE__ */ (0, import_jsx_runtime350.jsx)(import_components187.__experimentalVStack, { className: "block-editor-block-inspector-edit-contents", expanded: true, children: /* @__PURE__ */ (0, import_jsx_runtime350.jsx)( 53710 import_components187.Button, 53711 { 53712 className: "block-editor-block-inspector-edit-contents__button", 53713 __next40pxDefaultSize: true, 53714 variant: "secondary", 53715 onClick: handleClick, 53716 children: editedContentOnlySection2 ? (0, import_i18n175.__)("Exit section") : (0, import_i18n175.__)("Edit section") 53717 } 53718 ) }); 53719 } 53720 function EditContents({ clientId }) { 53721 const { 53722 isWithinSection, 53723 isWithinEditedSection, 53724 editedContentOnlySection: editedContentOnlySection2, 53725 editContentOnlySection: editContentOnlySection2, 53726 stopEditingContentOnlySection: stopEditingContentOnlySection2 53727 } = useContentOnlySectionEdit(clientId); 53728 const { block, onNavigateToEntityRecord } = (0, import_data153.useSelect)( 53729 (select3) => { 53730 const { getBlock: getBlock2, getSettings: getSettings8 } = select3(store); 53731 return { 53732 block: getBlock2(clientId), 53733 onNavigateToEntityRecord: getSettings8().onNavigateToEntityRecord 53734 }; 53735 }, 53736 [clientId] 53737 ); 53738 if (!isWithinSection && !isWithinEditedSection) { 53739 return null; 53740 } 53741 const isSyncedPattern = (0, import_blocks87.isReusableBlock)(block); 53742 const isTemplatePartBlock = (0, import_blocks87.isTemplatePart)(block); 53743 const shouldUseIsolatedEditor = (isSyncedPattern || isTemplatePartBlock) && onNavigateToEntityRecord; 53744 if (shouldUseIsolatedEditor) { 53745 return /* @__PURE__ */ (0, import_jsx_runtime350.jsx)( 53746 IsolatedEditButton, 53747 { 53748 block, 53749 onNavigateToEntityRecord, 53750 isSyncedPattern, 53751 isTemplatePartBlock 53752 } 53753 ); 53754 } 53755 return /* @__PURE__ */ (0, import_jsx_runtime350.jsx)( 53756 InlineEditButton, 53757 { 53758 clientId, 53759 editedContentOnlySection: editedContentOnlySection2, 53760 editContentOnlySection: editContentOnlySection2, 53761 stopEditingContentOnlySection: stopEditingContentOnlySection2 53762 } 53763 ); 53764 } 53765 53766 // packages/block-editor/build-module/components/skip-to-selected-block/index.js 53767 var import_data154 = __toESM(require_data()); 53768 var import_i18n176 = __toESM(require_i18n()); 53769 var import_components188 = __toESM(require_components()); 53770 var import_element194 = __toESM(require_element()); 53771 var import_jsx_runtime351 = __toESM(require_jsx_runtime()); 53772 function SkipToSelectedBlock() { 53773 const selectedBlockClientId = (0, import_data154.useSelect)( 53774 (select3) => select3(store).getBlockSelectionStart(), 53775 [] 53776 ); 53777 const ref = (0, import_element194.useRef)(); 53778 useBlockElementRef(selectedBlockClientId, ref); 53779 const onClick = () => { 53780 ref.current?.focus(); 53781 }; 53782 return selectedBlockClientId ? /* @__PURE__ */ (0, import_jsx_runtime351.jsx)( 53783 import_components188.Button, 53784 { 53785 __next40pxDefaultSize: true, 53786 variant: "secondary", 53787 className: "block-editor-skip-to-selected-block", 53788 onClick, 53789 children: (0, import_i18n176.__)("Skip to the selected block") 53790 } 53791 ) : null; 53792 } 53793 53794 // packages/block-editor/build-module/components/multi-selection-inspector/index.js 53795 var import_i18n177 = __toESM(require_i18n()); 53796 var import_data155 = __toESM(require_data()); 53797 var import_components189 = __toESM(require_components()); 53798 var import_jsx_runtime352 = __toESM(require_jsx_runtime()); 53799 function MultiSelectionInspector() { 53800 const selectedBlockCount = (0, import_data155.useSelect)( 53801 (select3) => select3(store).getSelectedBlockCount(), 53802 [] 53803 ); 53804 return /* @__PURE__ */ (0, import_jsx_runtime352.jsxs)( 53805 import_components189.__experimentalHStack, 53806 { 53807 justify: "flex-start", 53808 spacing: 2, 53809 className: "block-editor-multi-selection-inspector__card", 53810 children: [ 53811 /* @__PURE__ */ (0, import_jsx_runtime352.jsx)(block_icon_default, { icon: copy_default, showColors: true }), 53812 /* @__PURE__ */ (0, import_jsx_runtime352.jsx)("div", { className: "block-editor-multi-selection-inspector__card-title", children: (0, import_i18n177.sprintf)( 53813 /* translators: %d: number of blocks */ 53814 (0, import_i18n177._n)("%d Block", "%d Blocks", selectedBlockCount), 53815 selectedBlockCount 53816 ) }) 53817 ] 53818 } 53819 ); 53820 } 53821 53822 // packages/block-editor/build-module/components/inspector-controls-tabs/index.js 53823 var import_components240 = __toESM(require_components()); 53824 var import_element241 = __toESM(require_element()); 53825 var import_preferences5 = __toESM(require_preferences()); 53826 var import_data169 = __toESM(require_data()); 53827 53828 // packages/block-editor/build-module/components/inspector-controls-tabs/utils.js 53829 var import_i18n178 = __toESM(require_i18n()); 53830 var TAB_SETTINGS = { 53831 name: "settings", 53832 title: (0, import_i18n178.__)("Settings"), 53833 value: "settings", 53834 icon: cog_default 53835 }; 53836 var TAB_STYLES = { 53837 name: "styles", 53838 title: (0, import_i18n178.__)("Styles"), 53839 value: "styles", 53840 icon: styles_default 53841 }; 53842 var TAB_CONTENT = { 53843 name: "content", 53844 title: (0, import_i18n178.__)("Content"), 53845 value: "content", 53846 icon: page_default 53847 }; 53848 var TAB_LIST_VIEW = { 53849 name: "list", 53850 title: (0, import_i18n178.__)("List View"), 53851 value: "list-view", 53852 icon: list_view_default 53853 }; 53854 53855 // packages/block-editor/build-module/components/inspector-controls-tabs/advanced-controls-panel.js 53856 var import_components190 = __toESM(require_components()); 53857 var import_i18n179 = __toESM(require_i18n()); 53858 var import_jsx_runtime353 = __toESM(require_jsx_runtime()); 53859 var AdvancedControls = () => { 53860 const fills = (0, import_components190.__experimentalUseSlotFills)(InspectorAdvancedControls.slotName); 53861 const privateFills = (0, import_components190.__experimentalUseSlotFills)( 53862 PrivateInspectorControlsAllowedBlocks.name 53863 ); 53864 const hasFills = Boolean(fills && fills.length); 53865 const hasPrivateFills = Boolean(privateFills && privateFills.length); 53866 if (!hasFills && !hasPrivateFills) { 53867 return null; 53868 } 53869 return /* @__PURE__ */ (0, import_jsx_runtime353.jsxs)( 53870 import_components190.PanelBody, 53871 { 53872 className: "block-editor-block-inspector__advanced", 53873 title: (0, import_i18n179.__)("Advanced"), 53874 initialOpen: false, 53875 children: [ 53876 /* @__PURE__ */ (0, import_jsx_runtime353.jsx)(inspector_controls_default.Slot, { group: "advanced" }), 53877 /* @__PURE__ */ (0, import_jsx_runtime353.jsx)(PrivateInspectorControlsAllowedBlocks.Slot, {}) 53878 ] 53879 } 53880 ); 53881 }; 53882 var advanced_controls_panel_default = AdvancedControls; 53883 53884 // packages/block-editor/build-module/components/inspector-controls-tabs/position-controls-panel.js 53885 var import_components191 = __toESM(require_components()); 53886 var import_data156 = __toESM(require_data()); 53887 var import_i18n180 = __toESM(require_i18n()); 53888 var import_jsx_runtime354 = __toESM(require_jsx_runtime()); 53889 var PositionControlsPanel = () => { 53890 const { selectedClientIds, selectedBlocks, hasPositionAttribute } = (0, import_data156.useSelect)((select3) => { 53891 const { getBlocksByClientId: getBlocksByClientId2, getSelectedBlockClientIds: getSelectedBlockClientIds2 } = select3(store); 53892 const selectedBlockClientIds = getSelectedBlockClientIds2(); 53893 const _selectedBlocks = getBlocksByClientId2( 53894 selectedBlockClientIds 53895 ); 53896 return { 53897 selectedClientIds: selectedBlockClientIds, 53898 selectedBlocks: _selectedBlocks, 53899 hasPositionAttribute: _selectedBlocks?.some( 53900 ({ attributes }) => !!attributes?.style?.position?.type 53901 ) 53902 }; 53903 }, []); 53904 const { updateBlockAttributes: updateBlockAttributes2 } = (0, import_data156.useDispatch)(store); 53905 const dropdownMenuProps = useToolsPanelDropdownMenuProps(); 53906 function resetPosition() { 53907 if (!selectedClientIds?.length || !selectedBlocks?.length) { 53908 return; 53909 } 53910 const attributesByClientId = Object.fromEntries( 53911 selectedBlocks?.map(({ clientId, attributes }) => [ 53912 clientId, 53913 { 53914 style: cleanEmptyObject({ 53915 ...attributes?.style, 53916 position: { 53917 ...attributes?.style?.position, 53918 type: void 0, 53919 top: void 0, 53920 right: void 0, 53921 bottom: void 0, 53922 left: void 0 53923 } 53924 }) 53925 } 53926 ]) 53927 ); 53928 updateBlockAttributes2(selectedClientIds, attributesByClientId, true); 53929 } 53930 return /* @__PURE__ */ (0, import_jsx_runtime354.jsx)( 53931 import_components191.__experimentalToolsPanel, 53932 { 53933 className: "block-editor-block-inspector__position", 53934 label: (0, import_i18n180.__)("Position"), 53935 resetAll: resetPosition, 53936 dropdownMenuProps, 53937 children: /* @__PURE__ */ (0, import_jsx_runtime354.jsx)( 53938 import_components191.__experimentalToolsPanelItem, 53939 { 53940 isShownByDefault: hasPositionAttribute, 53941 label: (0, import_i18n180.__)("Position"), 53942 hasValue: () => hasPositionAttribute, 53943 onDeselect: resetPosition, 53944 children: /* @__PURE__ */ (0, import_jsx_runtime354.jsx)(inspector_controls_default.Slot, { group: "position" }) 53945 } 53946 ) 53947 } 53948 ); 53949 }; 53950 var PositionControls = () => { 53951 const fills = (0, import_components191.__experimentalUseSlotFills)(groups_default.position.name); 53952 const hasFills = Boolean(fills && fills.length); 53953 if (!hasFills) { 53954 return null; 53955 } 53956 return /* @__PURE__ */ (0, import_jsx_runtime354.jsx)(PositionControlsPanel, {}); 53957 }; 53958 var position_controls_panel_default = PositionControls; 53959 53960 // packages/block-editor/build-module/components/inspector-controls-tabs/settings-tab.js 53961 var import_jsx_runtime355 = __toESM(require_jsx_runtime()); 53962 var SettingsTab = ({ showAdvancedControls = false }) => /* @__PURE__ */ (0, import_jsx_runtime355.jsxs)(import_jsx_runtime355.Fragment, { children: [ 53963 /* @__PURE__ */ (0, import_jsx_runtime355.jsx)(inspector_controls_default.Slot, {}), 53964 /* @__PURE__ */ (0, import_jsx_runtime355.jsx)(position_controls_panel_default, {}), 53965 /* @__PURE__ */ (0, import_jsx_runtime355.jsx)(inspector_controls_default.Slot, { group: "bindings" }), 53966 showAdvancedControls && /* @__PURE__ */ (0, import_jsx_runtime355.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime355.jsx)(advanced_controls_panel_default, {}) }) 53967 ] }); 53968 var settings_tab_default = SettingsTab; 53969 53970 // packages/block-editor/build-module/components/inspector-controls-tabs/styles-tab.js 53971 var import_components206 = __toESM(require_components()); 53972 var import_i18n196 = __toESM(require_i18n()); 53973 var import_data164 = __toESM(require_data()); 53974 53975 // packages/block-editor/build-module/hooks/border.js 53976 var import_blocks89 = __toESM(require_blocks()); 53977 var import_components205 = __toESM(require_components()); 53978 var import_element207 = __toESM(require_element()); 53979 var import_hooks11 = __toESM(require_hooks()); 53980 var import_data161 = __toESM(require_data()); 53981 53982 // packages/block-editor/build-module/components/global-styles/index.js 53983 var global_styles_exports = {}; 53984 __export(global_styles_exports, { 53985 AdvancedPanel: () => AdvancedPanel, 53986 BackgroundPanel: () => BackgroundImagePanel2, 53987 BorderPanel: () => BorderPanel, 53988 ColorPanel: () => ColorPanel, 53989 DimensionsPanel: () => DimensionsPanel, 53990 FiltersPanel: () => FiltersPanel, 53991 ImageSettingsPanel: () => ImageSettingsPanel, 53992 TypographyPanel: () => TypographyPanel, 53993 useHasBackgroundPanel: () => useHasBackgroundPanel, 53994 useHasBorderPanel: () => useHasBorderPanel, 53995 useHasBorderPanelControls: () => useHasBorderPanelControls, 53996 useHasColorPanel: () => useHasColorPanel, 53997 useHasDimensionsPanel: () => useHasDimensionsPanel, 53998 useHasFiltersPanel: () => useHasFiltersPanel, 53999 useHasImageSettingsPanel: () => useHasImageSettingsPanel, 54000 useHasTypographyPanel: () => useHasTypographyPanel, 54001 useSettingsForBlockElement: () => useSettingsForBlockElement 54002 }); 54003 54004 // packages/block-editor/build-module/components/global-styles/hooks.js 54005 var import_element195 = __toESM(require_element()); 54006 var import_data157 = __toESM(require_data()); 54007 var import_blocks88 = __toESM(require_blocks()); 54008 var import_i18n181 = __toESM(require_i18n()); 54009 function useSettingsForBlockElement(parentSettings, blockName, element) { 54010 const { supportedStyles, supports } = (0, import_data157.useSelect)( 54011 (select3) => { 54012 return { 54013 supportedStyles: unlock( 54014 select3(import_blocks88.store) 54015 ).getSupportedStyles(blockName, element), 54016 supports: select3(import_blocks88.store).getBlockType(blockName)?.supports 54017 }; 54018 }, 54019 [blockName, element] 54020 ); 54021 return (0, import_element195.useMemo)(() => { 54022 const updatedSettings = { ...parentSettings }; 54023 if (!supportedStyles.includes("fontSize")) { 54024 updatedSettings.typography = { 54025 ...updatedSettings.typography, 54026 fontSizes: {}, 54027 customFontSize: false, 54028 defaultFontSizes: false 54029 }; 54030 } 54031 if (!supportedStyles.includes("fontFamily")) { 54032 updatedSettings.typography = { 54033 ...updatedSettings.typography, 54034 fontFamilies: {} 54035 }; 54036 } 54037 updatedSettings.color = { 54038 ...updatedSettings.color, 54039 text: updatedSettings.color?.text && supportedStyles.includes("color"), 54040 background: updatedSettings.color?.background && (supportedStyles.includes("background") || supportedStyles.includes("backgroundColor")), 54041 button: updatedSettings.color?.button && supportedStyles.includes("buttonColor"), 54042 heading: updatedSettings.color?.heading && supportedStyles.includes("headingColor"), 54043 link: updatedSettings.color?.link && supportedStyles.includes("linkColor"), 54044 caption: updatedSettings.color?.caption && supportedStyles.includes("captionColor") 54045 }; 54046 if (!supportedStyles.includes("background")) { 54047 updatedSettings.color.gradients = []; 54048 updatedSettings.color.customGradient = false; 54049 } 54050 if (!supportedStyles.includes("filter")) { 54051 updatedSettings.color.defaultDuotone = false; 54052 updatedSettings.color.customDuotone = false; 54053 } 54054 [ 54055 "lineHeight", 54056 "fontStyle", 54057 "fontWeight", 54058 "letterSpacing", 54059 "textAlign", 54060 "textTransform", 54061 "textDecoration", 54062 "writingMode" 54063 ].forEach((key) => { 54064 if (!supportedStyles.includes(key)) { 54065 updatedSettings.typography = { 54066 ...updatedSettings.typography, 54067 [key]: false 54068 }; 54069 } 54070 }); 54071 if (!supportedStyles.includes("columnCount")) { 54072 updatedSettings.typography = { 54073 ...updatedSettings.typography, 54074 textColumns: false 54075 }; 54076 } 54077 ["contentSize", "wideSize"].forEach((key) => { 54078 if (!supportedStyles.includes(key)) { 54079 updatedSettings.layout = { 54080 ...updatedSettings.layout, 54081 [key]: false 54082 }; 54083 } 54084 }); 54085 ["padding", "margin", "blockGap"].forEach((key) => { 54086 if (!supportedStyles.includes(key)) { 54087 updatedSettings.spacing = { 54088 ...updatedSettings.spacing, 54089 [key]: false 54090 }; 54091 } 54092 const sides = Array.isArray(supports?.spacing?.[key]) ? supports?.spacing?.[key] : supports?.spacing?.[key]?.sides; 54093 if (sides?.length && updatedSettings.spacing?.[key]) { 54094 updatedSettings.spacing = { 54095 ...updatedSettings.spacing, 54096 [key]: { 54097 ...updatedSettings.spacing?.[key], 54098 sides 54099 } 54100 }; 54101 } 54102 }); 54103 ["aspectRatio", "height", "minHeight", "width"].forEach((key) => { 54104 if (!supportedStyles.includes(key)) { 54105 updatedSettings.dimensions = { 54106 ...updatedSettings.dimensions, 54107 [key]: false 54108 }; 54109 } 54110 }); 54111 ["radius", "color", "style", "width"].forEach((key) => { 54112 if (!supportedStyles.includes( 54113 "border" + key.charAt(0).toUpperCase() + key.slice(1) 54114 )) { 54115 updatedSettings.border = { 54116 ...updatedSettings.border, 54117 [key]: false 54118 }; 54119 } 54120 }); 54121 ["backgroundImage", "backgroundSize"].forEach((key) => { 54122 if (!supportedStyles.includes(key)) { 54123 updatedSettings.background = { 54124 ...updatedSettings.background, 54125 [key]: false 54126 }; 54127 } 54128 }); 54129 updatedSettings.shadow = supportedStyles.includes("shadow") ? updatedSettings.shadow : false; 54130 return updatedSettings; 54131 }, [parentSettings, supportedStyles, supports]); 54132 } 54133 function useColorsPerOrigin(settings2) { 54134 const customColors = settings2?.color?.palette?.custom; 54135 const themeColors = settings2?.color?.palette?.theme; 54136 const defaultColors = settings2?.color?.palette?.default; 54137 const shouldDisplayDefaultColors = settings2?.color?.defaultPalette; 54138 return (0, import_element195.useMemo)(() => { 54139 const result = []; 54140 if (themeColors && themeColors.length) { 54141 result.push({ 54142 name: (0, import_i18n181._x)( 54143 "Theme", 54144 "Indicates this palette comes from the theme." 54145 ), 54146 colors: themeColors 54147 }); 54148 } 54149 if (shouldDisplayDefaultColors && defaultColors && defaultColors.length) { 54150 result.push({ 54151 name: (0, import_i18n181._x)( 54152 "Default", 54153 "Indicates this palette comes from WordPress." 54154 ), 54155 colors: defaultColors 54156 }); 54157 } 54158 if (customColors && customColors.length) { 54159 result.push({ 54160 name: (0, import_i18n181._x)( 54161 "Custom", 54162 "Indicates this palette is created by the user." 54163 ), 54164 colors: customColors 54165 }); 54166 } 54167 return result; 54168 }, [ 54169 customColors, 54170 themeColors, 54171 defaultColors, 54172 shouldDisplayDefaultColors 54173 ]); 54174 } 54175 function useGradientsPerOrigin(settings2) { 54176 const customGradients = settings2?.color?.gradients?.custom; 54177 const themeGradients = settings2?.color?.gradients?.theme; 54178 const defaultGradients = settings2?.color?.gradients?.default; 54179 const shouldDisplayDefaultGradients = settings2?.color?.defaultGradients; 54180 return (0, import_element195.useMemo)(() => { 54181 const result = []; 54182 if (themeGradients && themeGradients.length) { 54183 result.push({ 54184 name: (0, import_i18n181._x)( 54185 "Theme", 54186 "Indicates this palette comes from the theme." 54187 ), 54188 gradients: themeGradients 54189 }); 54190 } 54191 if (shouldDisplayDefaultGradients && defaultGradients && defaultGradients.length) { 54192 result.push({ 54193 name: (0, import_i18n181._x)( 54194 "Default", 54195 "Indicates this palette comes from WordPress." 54196 ), 54197 gradients: defaultGradients 54198 }); 54199 } 54200 if (customGradients && customGradients.length) { 54201 result.push({ 54202 name: (0, import_i18n181._x)( 54203 "Custom", 54204 "Indicates this palette is created by the user." 54205 ), 54206 gradients: customGradients 54207 }); 54208 } 54209 return result; 54210 }, [ 54211 customGradients, 54212 themeGradients, 54213 defaultGradients, 54214 shouldDisplayDefaultGradients 54215 ]); 54216 } 54217 54218 // packages/block-editor/build-module/components/global-styles/typography-panel.js 54219 var import_components193 = __toESM(require_components()); 54220 var import_i18n183 = __toESM(require_i18n()); 54221 var import_element197 = __toESM(require_element()); 54222 54223 // packages/block-editor/build-module/components/text-alignment-control/index.js 54224 var import_i18n182 = __toESM(require_i18n()); 54225 var import_element196 = __toESM(require_element()); 54226 var import_components192 = __toESM(require_components()); 54227 var import_jsx_runtime356 = __toESM(require_jsx_runtime()); 54228 var TEXT_ALIGNMENT_OPTIONS = [ 54229 { 54230 label: (0, import_i18n182.__)("Align text left"), 54231 value: "left", 54232 icon: align_left_default 54233 }, 54234 { 54235 label: (0, import_i18n182.__)("Align text center"), 54236 value: "center", 54237 icon: align_center_default 54238 }, 54239 { 54240 label: (0, import_i18n182.__)("Align text right"), 54241 value: "right", 54242 icon: align_right_default 54243 }, 54244 { 54245 label: (0, import_i18n182.__)("Justify text"), 54246 value: "justify", 54247 icon: align_justify_default 54248 } 54249 ]; 54250 var DEFAULT_OPTIONS = ["left", "center", "right"]; 54251 function TextAlignmentControl({ 54252 className, 54253 value, 54254 onChange, 54255 options = DEFAULT_OPTIONS 54256 }) { 54257 const validOptions = (0, import_element196.useMemo)( 54258 () => TEXT_ALIGNMENT_OPTIONS.filter( 54259 (option) => options.includes(option.value) 54260 ), 54261 [options] 54262 ); 54263 if (!validOptions.length) { 54264 return null; 54265 } 54266 return /* @__PURE__ */ (0, import_jsx_runtime356.jsx)( 54267 import_components192.__experimentalToggleGroupControl, 54268 { 54269 isDeselectable: true, 54270 __next40pxDefaultSize: true, 54271 label: (0, import_i18n182.__)("Text alignment"), 54272 className: clsx_default( 54273 "block-editor-text-alignment-control", 54274 className 54275 ), 54276 value, 54277 onChange: (newValue) => { 54278 onChange(newValue === value ? void 0 : newValue); 54279 }, 54280 children: validOptions.map((option) => { 54281 return /* @__PURE__ */ (0, import_jsx_runtime356.jsx)( 54282 import_components192.__experimentalToggleGroupControlOptionIcon, 54283 { 54284 value: option.value, 54285 icon: option.icon, 54286 label: option.label 54287 }, 54288 option.value 54289 ); 54290 }) 54291 } 54292 ); 54293 } 54294 54295 // packages/block-editor/build-module/components/global-styles/typography-utils.js 54296 function getMergedFontFamiliesAndFontFamilyFaces(settings2, selectedFontFamily) { 54297 const fontFamiliesFromSettings = settings2?.typography?.fontFamilies; 54298 const fontFamilies = ["default", "theme", "custom"].flatMap( 54299 (key) => fontFamiliesFromSettings?.[key] ?? [] 54300 ); 54301 const fontFamilyFaces = fontFamilies.find( 54302 (family) => family.fontFamily === selectedFontFamily 54303 )?.fontFace ?? []; 54304 return { fontFamilies, fontFamilyFaces }; 54305 } 54306 function findNearestFontWeight(availableFontWeights, newFontWeightValue) { 54307 newFontWeightValue = "number" === typeof newFontWeightValue ? newFontWeightValue.toString() : newFontWeightValue; 54308 if (!newFontWeightValue || typeof newFontWeightValue !== "string") { 54309 return ""; 54310 } 54311 if (!availableFontWeights || availableFontWeights.length === 0) { 54312 return newFontWeightValue; 54313 } 54314 const nearestFontWeight = availableFontWeights?.reduce( 54315 (nearest, { value: fw }) => { 54316 const currentDiff = Math.abs( 54317 parseInt(fw) - parseInt(newFontWeightValue) 54318 ); 54319 const nearestDiff = Math.abs( 54320 parseInt(nearest) - parseInt(newFontWeightValue) 54321 ); 54322 return currentDiff < nearestDiff ? fw : nearest; 54323 }, 54324 availableFontWeights[0]?.value 54325 ); 54326 return nearestFontWeight; 54327 } 54328 function findNearestFontStyle(availableFontStyles, newFontStyleValue) { 54329 if (typeof newFontStyleValue !== "string" || !newFontStyleValue) { 54330 return ""; 54331 } 54332 const validStyles = ["normal", "italic", "oblique"]; 54333 if (!validStyles.includes(newFontStyleValue)) { 54334 return ""; 54335 } 54336 if (!availableFontStyles || availableFontStyles.length === 0 || availableFontStyles.find( 54337 (style) => style.value === newFontStyleValue 54338 )) { 54339 return newFontStyleValue; 54340 } 54341 if (newFontStyleValue === "oblique" && !availableFontStyles.find((style) => style.value === "oblique")) { 54342 return "italic"; 54343 } 54344 return ""; 54345 } 54346 function findNearestStyleAndWeight(fontFamilyFaces, fontStyle, fontWeight) { 54347 let nearestFontStyle = fontStyle; 54348 let nearestFontWeight = fontWeight; 54349 const { fontStyles, fontWeights, combinedStyleAndWeightOptions } = getFontStylesAndWeights(fontFamilyFaces); 54350 const hasFontStyle = fontStyles?.some( 54351 ({ value: fs }) => fs === fontStyle 54352 ); 54353 const hasFontWeight = fontWeights?.some( 54354 ({ value: fw }) => fw?.toString() === fontWeight?.toString() 54355 ); 54356 if (!hasFontStyle) { 54357 nearestFontStyle = fontStyle ? findNearestFontStyle(fontStyles, fontStyle) : combinedStyleAndWeightOptions?.find( 54358 (option) => option.style.fontWeight === findNearestFontWeight(fontWeights, fontWeight) 54359 )?.style?.fontStyle; 54360 } 54361 if (!hasFontWeight) { 54362 nearestFontWeight = fontWeight ? findNearestFontWeight(fontWeights, fontWeight) : combinedStyleAndWeightOptions?.find( 54363 (option) => option.style.fontStyle === (nearestFontStyle || fontStyle) 54364 )?.style?.fontWeight; 54365 } 54366 return { nearestFontStyle, nearestFontWeight }; 54367 } 54368 54369 // packages/block-editor/build-module/components/global-styles/typography-panel.js 54370 var import_jsx_runtime357 = __toESM(require_jsx_runtime()); 54371 var MIN_TEXT_COLUMNS = 1; 54372 var MAX_TEXT_COLUMNS = 6; 54373 function useHasTypographyPanel(settings2) { 54374 const hasFontFamily = useHasFontFamilyControl(settings2); 54375 const hasLineHeight = useHasLineHeightControl(settings2); 54376 const hasFontAppearance = useHasAppearanceControl(settings2); 54377 const hasLetterSpacing = useHasLetterSpacingControl(settings2); 54378 const hasTextAlign = useHasTextAlignmentControl(settings2); 54379 const hasTextTransform = useHasTextTransformControl(settings2); 54380 const hasTextDecoration = useHasTextDecorationControl(settings2); 54381 const hasWritingMode = useHasWritingModeControl(settings2); 54382 const hasTextColumns = useHasTextColumnsControl(settings2); 54383 const hasFontSize = useHasFontSizeControl(settings2); 54384 return hasFontFamily || hasLineHeight || hasFontAppearance || hasLetterSpacing || hasTextAlign || hasTextTransform || hasFontSize || hasTextDecoration || hasWritingMode || hasTextColumns; 54385 } 54386 function useHasFontSizeControl(settings2) { 54387 return settings2?.typography?.defaultFontSizes !== false && settings2?.typography?.fontSizes?.default?.length || settings2?.typography?.fontSizes?.theme?.length || settings2?.typography?.fontSizes?.custom?.length || settings2?.typography?.customFontSize; 54388 } 54389 function useHasFontFamilyControl(settings2) { 54390 return ["default", "theme", "custom"].some( 54391 (key) => settings2?.typography?.fontFamilies?.[key]?.length 54392 ); 54393 } 54394 function useHasLineHeightControl(settings2) { 54395 return settings2?.typography?.lineHeight; 54396 } 54397 function useHasAppearanceControl(settings2) { 54398 return settings2?.typography?.fontStyle || settings2?.typography?.fontWeight; 54399 } 54400 function useAppearanceControlLabel(settings2) { 54401 if (!settings2?.typography?.fontStyle) { 54402 return (0, import_i18n183.__)("Font weight"); 54403 } 54404 if (!settings2?.typography?.fontWeight) { 54405 return (0, import_i18n183.__)("Font style"); 54406 } 54407 return (0, import_i18n183.__)("Appearance"); 54408 } 54409 function useHasLetterSpacingControl(settings2) { 54410 return settings2?.typography?.letterSpacing; 54411 } 54412 function useHasTextTransformControl(settings2) { 54413 return settings2?.typography?.textTransform; 54414 } 54415 function useHasTextAlignmentControl(settings2) { 54416 return settings2?.typography?.textAlign; 54417 } 54418 function useHasTextDecorationControl(settings2) { 54419 return settings2?.typography?.textDecoration; 54420 } 54421 function useHasWritingModeControl(settings2) { 54422 return settings2?.typography?.writingMode; 54423 } 54424 function useHasTextColumnsControl(settings2) { 54425 return settings2?.typography?.textColumns; 54426 } 54427 function getMergedFontSizes(settings2) { 54428 const fontSizes = settings2?.typography?.fontSizes; 54429 const defaultFontSizesEnabled = !!settings2?.typography?.defaultFontSizes; 54430 return [ 54431 ...fontSizes?.custom ?? [], 54432 ...fontSizes?.theme ?? [], 54433 ...defaultFontSizesEnabled ? fontSizes?.default ?? [] : [] 54434 ]; 54435 } 54436 function TypographyToolsPanel({ 54437 resetAllFilter, 54438 onChange, 54439 value, 54440 panelId, 54441 children 54442 }) { 54443 const dropdownMenuProps = useToolsPanelDropdownMenuProps(); 54444 const resetAll = () => { 54445 const updatedValue = resetAllFilter(value); 54446 onChange(updatedValue); 54447 }; 54448 return /* @__PURE__ */ (0, import_jsx_runtime357.jsx)( 54449 import_components193.__experimentalToolsPanel, 54450 { 54451 label: (0, import_i18n183.__)("Typography"), 54452 resetAll, 54453 panelId, 54454 dropdownMenuProps, 54455 children 54456 } 54457 ); 54458 } 54459 var DEFAULT_CONTROLS3 = { 54460 fontFamily: true, 54461 fontSize: true, 54462 fontAppearance: true, 54463 lineHeight: true, 54464 letterSpacing: true, 54465 textAlign: true, 54466 textTransform: true, 54467 textDecoration: true, 54468 writingMode: true, 54469 textColumns: true 54470 }; 54471 function TypographyPanel({ 54472 as: Wrapper = TypographyToolsPanel, 54473 value, 54474 onChange, 54475 inheritedValue = value, 54476 settings: settings2, 54477 panelId, 54478 defaultControls = DEFAULT_CONTROLS3 54479 }) { 54480 const decodeValue = (rawValue) => getValueFromVariable({ settings: settings2 }, "", rawValue); 54481 const hasFontFamilyEnabled = useHasFontFamilyControl(settings2); 54482 const fontFamily = decodeValue(inheritedValue?.typography?.fontFamily); 54483 const { fontFamilies, fontFamilyFaces } = (0, import_element197.useMemo)(() => { 54484 return getMergedFontFamiliesAndFontFamilyFaces(settings2, fontFamily); 54485 }, [settings2, fontFamily]); 54486 const setFontFamily = (newValue) => { 54487 const slug = fontFamilies?.find( 54488 ({ fontFamily: f2 }) => f2 === newValue 54489 )?.slug; 54490 let updatedValue = setImmutably( 54491 value, 54492 ["typography", "fontFamily"], 54493 slug ? `var:preset|font-family|$slug}` : newValue || void 0 54494 ); 54495 const newFontFamilyFaces = fontFamilies?.find(({ fontFamily: f2 }) => f2 === newValue)?.fontFace ?? []; 54496 const { fontStyles, fontWeights } = getFontStylesAndWeights(newFontFamilyFaces); 54497 const hasFontStyle = fontStyles?.some( 54498 ({ value: fs }) => fs === fontStyle 54499 ); 54500 const hasFontWeight = fontWeights?.some( 54501 ({ value: fw }) => fw?.toString() === fontWeight?.toString() 54502 ); 54503 if (!hasFontStyle || !hasFontWeight) { 54504 const { nearestFontStyle, nearestFontWeight } = findNearestStyleAndWeight( 54505 newFontFamilyFaces, 54506 fontStyle, 54507 fontWeight 54508 ); 54509 if (nearestFontStyle || nearestFontWeight) { 54510 updatedValue = { 54511 ...updatedValue, 54512 typography: { 54513 ...updatedValue?.typography, 54514 fontStyle: nearestFontStyle || void 0, 54515 fontWeight: nearestFontWeight || void 0 54516 } 54517 }; 54518 } else if (fontStyle || fontWeight) { 54519 updatedValue = { 54520 ...updatedValue, 54521 typography: { 54522 ...updatedValue?.typography, 54523 fontStyle: void 0, 54524 fontWeight: void 0 54525 } 54526 }; 54527 } 54528 } 54529 onChange(updatedValue); 54530 }; 54531 const hasFontFamily = () => !!value?.typography?.fontFamily; 54532 const resetFontFamily = () => setFontFamily(void 0); 54533 const hasFontSizeEnabled = useHasFontSizeControl(settings2); 54534 const disableCustomFontSizes = !settings2?.typography?.customFontSize; 54535 const mergedFontSizes = getMergedFontSizes(settings2); 54536 const fontSize = decodeValue(inheritedValue?.typography?.fontSize); 54537 const currentFontSizeSlug = (() => { 54538 const rawValue = inheritedValue?.typography?.fontSize; 54539 if (!rawValue || typeof rawValue !== "string") { 54540 return void 0; 54541 } 54542 if (rawValue.startsWith("var:preset|font-size|")) { 54543 return rawValue.replace("var:preset|font-size|", ""); 54544 } 54545 const cssVarMatch = rawValue.match( 54546 /^var\(--wp--preset--font-size--([^)]+)\)$/ 54547 ); 54548 if (cssVarMatch) { 54549 return cssVarMatch[1]; 54550 } 54551 return void 0; 54552 })(); 54553 const setFontSize = (newValue, metadata) => { 54554 const actualValue = !!metadata?.slug ? `var:preset|font-size|$metadata?.slug}` : newValue; 54555 onChange( 54556 setImmutably( 54557 value, 54558 ["typography", "fontSize"], 54559 actualValue || void 0 54560 ) 54561 ); 54562 }; 54563 const hasFontSize = () => !!value?.typography?.fontSize; 54564 const resetFontSize = () => setFontSize(void 0); 54565 const hasAppearanceControl = useHasAppearanceControl(settings2); 54566 const appearanceControlLabel = useAppearanceControlLabel(settings2); 54567 const hasFontStyles = settings2?.typography?.fontStyle; 54568 const hasFontWeights = settings2?.typography?.fontWeight; 54569 const fontStyle = decodeValue(inheritedValue?.typography?.fontStyle); 54570 const fontWeight = decodeValue(inheritedValue?.typography?.fontWeight); 54571 const setFontAppearance = (0, import_element197.useCallback)( 54572 ({ fontStyle: newFontStyle, fontWeight: newFontWeight }) => { 54573 if (newFontStyle !== fontStyle || newFontWeight !== fontWeight) { 54574 onChange({ 54575 ...value, 54576 typography: { 54577 ...value?.typography, 54578 fontStyle: newFontStyle || void 0, 54579 fontWeight: newFontWeight || void 0 54580 } 54581 }); 54582 } 54583 }, 54584 [fontStyle, fontWeight, onChange, value] 54585 ); 54586 const hasFontAppearance = () => !!value?.typography?.fontStyle || !!value?.typography?.fontWeight; 54587 const resetFontAppearance = (0, import_element197.useCallback)(() => { 54588 setFontAppearance({}); 54589 }, [setFontAppearance]); 54590 const hasLineHeightEnabled = useHasLineHeightControl(settings2); 54591 const lineHeight = decodeValue(inheritedValue?.typography?.lineHeight); 54592 const setLineHeight = (newValue) => { 54593 onChange( 54594 setImmutably( 54595 value, 54596 ["typography", "lineHeight"], 54597 newValue || void 0 54598 ) 54599 ); 54600 }; 54601 const hasLineHeight = () => value?.typography?.lineHeight !== void 0; 54602 const resetLineHeight = () => setLineHeight(void 0); 54603 const hasLetterSpacingControl = useHasLetterSpacingControl(settings2); 54604 const letterSpacing = decodeValue( 54605 inheritedValue?.typography?.letterSpacing 54606 ); 54607 const setLetterSpacing = (newValue) => { 54608 onChange( 54609 setImmutably( 54610 value, 54611 ["typography", "letterSpacing"], 54612 newValue || void 0 54613 ) 54614 ); 54615 }; 54616 const hasLetterSpacing = () => !!value?.typography?.letterSpacing; 54617 const resetLetterSpacing = () => setLetterSpacing(void 0); 54618 const hasTextColumnsControl = useHasTextColumnsControl(settings2); 54619 const textColumns = decodeValue(inheritedValue?.typography?.textColumns); 54620 const setTextColumns = (newValue) => { 54621 onChange( 54622 setImmutably( 54623 value, 54624 ["typography", "textColumns"], 54625 newValue || void 0 54626 ) 54627 ); 54628 }; 54629 const hasTextColumns = () => !!value?.typography?.textColumns; 54630 const resetTextColumns = () => setTextColumns(void 0); 54631 const hasTextTransformControl = useHasTextTransformControl(settings2); 54632 const textTransform = decodeValue( 54633 inheritedValue?.typography?.textTransform 54634 ); 54635 const setTextTransform = (newValue) => { 54636 onChange( 54637 setImmutably( 54638 value, 54639 ["typography", "textTransform"], 54640 newValue || void 0 54641 ) 54642 ); 54643 }; 54644 const hasTextTransform = () => !!value?.typography?.textTransform; 54645 const resetTextTransform = () => setTextTransform(void 0); 54646 const hasTextDecorationControl = useHasTextDecorationControl(settings2); 54647 const textDecoration = decodeValue( 54648 inheritedValue?.typography?.textDecoration 54649 ); 54650 const setTextDecoration = (newValue) => { 54651 onChange( 54652 setImmutably( 54653 value, 54654 ["typography", "textDecoration"], 54655 newValue || void 0 54656 ) 54657 ); 54658 }; 54659 const hasTextDecoration = () => !!value?.typography?.textDecoration; 54660 const resetTextDecoration = () => setTextDecoration(void 0); 54661 const hasWritingModeControl = useHasWritingModeControl(settings2); 54662 const writingMode = decodeValue(inheritedValue?.typography?.writingMode); 54663 const setWritingMode = (newValue) => { 54664 onChange( 54665 setImmutably( 54666 value, 54667 ["typography", "writingMode"], 54668 newValue || void 0 54669 ) 54670 ); 54671 }; 54672 const hasWritingMode = () => !!value?.typography?.writingMode; 54673 const resetWritingMode = () => setWritingMode(void 0); 54674 const hasTextAlignmentControl = useHasTextAlignmentControl(settings2); 54675 const textAlign = decodeValue(inheritedValue?.typography?.textAlign); 54676 const setTextAlign = (newValue) => { 54677 onChange( 54678 setImmutably( 54679 value, 54680 ["typography", "textAlign"], 54681 newValue || void 0 54682 ) 54683 ); 54684 }; 54685 const hasTextAlign = () => !!value?.typography?.textAlign; 54686 const resetTextAlign = () => setTextAlign(void 0); 54687 const resetAllFilter = (0, import_element197.useCallback)((previousValue) => { 54688 return { 54689 ...previousValue, 54690 typography: {} 54691 }; 54692 }, []); 54693 return /* @__PURE__ */ (0, import_jsx_runtime357.jsxs)( 54694 Wrapper, 54695 { 54696 resetAllFilter, 54697 value, 54698 onChange, 54699 panelId, 54700 children: [ 54701 hasFontFamilyEnabled && /* @__PURE__ */ (0, import_jsx_runtime357.jsx)( 54702 import_components193.__experimentalToolsPanelItem, 54703 { 54704 label: (0, import_i18n183.__)("Font"), 54705 hasValue: hasFontFamily, 54706 onDeselect: resetFontFamily, 54707 isShownByDefault: defaultControls.fontFamily, 54708 panelId, 54709 children: /* @__PURE__ */ (0, import_jsx_runtime357.jsx)( 54710 FontFamilyControl, 54711 { 54712 fontFamilies, 54713 value: fontFamily, 54714 onChange: setFontFamily, 54715 size: "__unstable-large" 54716 } 54717 ) 54718 } 54719 ), 54720 hasFontSizeEnabled && /* @__PURE__ */ (0, import_jsx_runtime357.jsx)( 54721 import_components193.__experimentalToolsPanelItem, 54722 { 54723 label: (0, import_i18n183.__)("Size"), 54724 hasValue: hasFontSize, 54725 onDeselect: resetFontSize, 54726 isShownByDefault: defaultControls.fontSize, 54727 panelId, 54728 children: /* @__PURE__ */ (0, import_jsx_runtime357.jsx)( 54729 import_components193.FontSizePicker, 54730 { 54731 value: currentFontSizeSlug || fontSize, 54732 valueMode: currentFontSizeSlug ? "slug" : "literal", 54733 onChange: setFontSize, 54734 fontSizes: mergedFontSizes, 54735 disableCustomFontSizes, 54736 withReset: false, 54737 withSlider: true, 54738 size: "__unstable-large" 54739 } 54740 ) 54741 } 54742 ), 54743 hasAppearanceControl && /* @__PURE__ */ (0, import_jsx_runtime357.jsx)( 54744 import_components193.__experimentalToolsPanelItem, 54745 { 54746 className: "single-column", 54747 label: appearanceControlLabel, 54748 hasValue: hasFontAppearance, 54749 onDeselect: resetFontAppearance, 54750 isShownByDefault: defaultControls.fontAppearance, 54751 panelId, 54752 children: /* @__PURE__ */ (0, import_jsx_runtime357.jsx)( 54753 FontAppearanceControl, 54754 { 54755 value: { 54756 fontStyle, 54757 fontWeight 54758 }, 54759 onChange: setFontAppearance, 54760 hasFontStyles, 54761 hasFontWeights, 54762 fontFamilyFaces, 54763 size: "__unstable-large" 54764 } 54765 ) 54766 } 54767 ), 54768 hasLineHeightEnabled && /* @__PURE__ */ (0, import_jsx_runtime357.jsx)( 54769 import_components193.__experimentalToolsPanelItem, 54770 { 54771 className: "single-column", 54772 label: (0, import_i18n183.__)("Line height"), 54773 hasValue: hasLineHeight, 54774 onDeselect: resetLineHeight, 54775 isShownByDefault: defaultControls.lineHeight, 54776 panelId, 54777 children: /* @__PURE__ */ (0, import_jsx_runtime357.jsx)( 54778 line_height_control_default, 54779 { 54780 __unstableInputWidth: "auto", 54781 value: lineHeight, 54782 onChange: setLineHeight, 54783 size: "__unstable-large" 54784 } 54785 ) 54786 } 54787 ), 54788 hasLetterSpacingControl && /* @__PURE__ */ (0, import_jsx_runtime357.jsx)( 54789 import_components193.__experimentalToolsPanelItem, 54790 { 54791 className: "single-column", 54792 label: (0, import_i18n183.__)("Letter spacing"), 54793 hasValue: hasLetterSpacing, 54794 onDeselect: resetLetterSpacing, 54795 isShownByDefault: defaultControls.letterSpacing, 54796 panelId, 54797 children: /* @__PURE__ */ (0, import_jsx_runtime357.jsx)( 54798 LetterSpacingControl, 54799 { 54800 value: letterSpacing, 54801 onChange: setLetterSpacing, 54802 size: "__unstable-large", 54803 __unstableInputWidth: "auto" 54804 } 54805 ) 54806 } 54807 ), 54808 hasTextColumnsControl && /* @__PURE__ */ (0, import_jsx_runtime357.jsx)( 54809 import_components193.__experimentalToolsPanelItem, 54810 { 54811 className: "single-column", 54812 label: (0, import_i18n183.__)("Columns"), 54813 hasValue: hasTextColumns, 54814 onDeselect: resetTextColumns, 54815 isShownByDefault: defaultControls.textColumns, 54816 panelId, 54817 children: /* @__PURE__ */ (0, import_jsx_runtime357.jsx)( 54818 import_components193.__experimentalNumberControl, 54819 { 54820 label: (0, import_i18n183.__)("Columns"), 54821 max: MAX_TEXT_COLUMNS, 54822 min: MIN_TEXT_COLUMNS, 54823 onChange: setTextColumns, 54824 size: "__unstable-large", 54825 spinControls: "custom", 54826 value: textColumns, 54827 initialPosition: 1 54828 } 54829 ) 54830 } 54831 ), 54832 hasTextDecorationControl && /* @__PURE__ */ (0, import_jsx_runtime357.jsx)( 54833 import_components193.__experimentalToolsPanelItem, 54834 { 54835 className: "single-column", 54836 label: (0, import_i18n183.__)("Decoration"), 54837 hasValue: hasTextDecoration, 54838 onDeselect: resetTextDecoration, 54839 isShownByDefault: defaultControls.textDecoration, 54840 panelId, 54841 children: /* @__PURE__ */ (0, import_jsx_runtime357.jsx)( 54842 TextDecorationControl, 54843 { 54844 value: textDecoration, 54845 onChange: setTextDecoration, 54846 size: "__unstable-large", 54847 __unstableInputWidth: "auto" 54848 } 54849 ) 54850 } 54851 ), 54852 hasWritingModeControl && /* @__PURE__ */ (0, import_jsx_runtime357.jsx)( 54853 import_components193.__experimentalToolsPanelItem, 54854 { 54855 className: "single-column", 54856 label: (0, import_i18n183.__)("Orientation"), 54857 hasValue: hasWritingMode, 54858 onDeselect: resetWritingMode, 54859 isShownByDefault: defaultControls.writingMode, 54860 panelId, 54861 children: /* @__PURE__ */ (0, import_jsx_runtime357.jsx)( 54862 WritingModeControl, 54863 { 54864 value: writingMode, 54865 onChange: setWritingMode, 54866 size: "__unstable-large" 54867 } 54868 ) 54869 } 54870 ), 54871 hasTextTransformControl && /* @__PURE__ */ (0, import_jsx_runtime357.jsx)( 54872 import_components193.__experimentalToolsPanelItem, 54873 { 54874 label: (0, import_i18n183.__)("Letter case"), 54875 hasValue: hasTextTransform, 54876 onDeselect: resetTextTransform, 54877 isShownByDefault: defaultControls.textTransform, 54878 panelId, 54879 children: /* @__PURE__ */ (0, import_jsx_runtime357.jsx)( 54880 TextTransformControl, 54881 { 54882 value: textTransform, 54883 onChange: setTextTransform, 54884 showNone: true, 54885 isBlock: true, 54886 size: "__unstable-large" 54887 } 54888 ) 54889 } 54890 ), 54891 hasTextAlignmentControl && /* @__PURE__ */ (0, import_jsx_runtime357.jsxs)( 54892 import_components193.__experimentalToolsPanelItem, 54893 { 54894 label: (0, import_i18n183.__)("Text alignment"), 54895 hasValue: hasTextAlign, 54896 onDeselect: resetTextAlign, 54897 isShownByDefault: defaultControls.textAlign, 54898 panelId, 54899 children: [ 54900 /* @__PURE__ */ (0, import_jsx_runtime357.jsx)( 54901 TextAlignmentControl, 54902 { 54903 value: textAlign, 54904 onChange: setTextAlign, 54905 options: ["left", "center", "right", "justify"], 54906 size: "__unstable-large" 54907 } 54908 ), 54909 textAlign === "justify" && /* @__PURE__ */ (0, import_jsx_runtime357.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime357.jsx)(import_components193.Notice, { status: "warning", isDismissible: false, children: (0, import_i18n183.__)( 54910 "Justified text can reduce readability. For better accessibility, use left-aligned text instead." 54911 ) }) }) 54912 ] 54913 } 54914 ) 54915 ] 54916 } 54917 ); 54918 } 54919 54920 // packages/block-editor/build-module/components/global-styles/dimensions-panel.js 54921 var import_i18n186 = __toESM(require_i18n()); 54922 var import_components196 = __toESM(require_components()); 54923 var import_element199 = __toESM(require_element()); 54924 54925 // packages/block-editor/build-module/components/child-layout-control/index.js 54926 var import_components194 = __toESM(require_components()); 54927 var import_i18n184 = __toESM(require_i18n()); 54928 var import_element198 = __toESM(require_element()); 54929 var import_data159 = __toESM(require_data()); 54930 54931 // packages/block-editor/build-module/components/grid/use-get-number-of-blocks-before-cell.js 54932 var import_data158 = __toESM(require_data()); 54933 function useGetNumberOfBlocksBeforeCell(gridClientId, numColumns) { 54934 const { getBlockOrder: getBlockOrder2, getBlockAttributes: getBlockAttributes3 } = (0, import_data158.useSelect)(store); 54935 const getNumberOfBlocksBeforeCell = (column, row) => { 54936 const targetIndex = (row - 1) * numColumns + column - 1; 54937 let count = 0; 54938 for (const clientId of getBlockOrder2(gridClientId)) { 54939 const { columnStart, rowStart } = getBlockAttributes3(clientId).style?.layout ?? {}; 54940 const cellIndex = (rowStart - 1) * numColumns + columnStart - 1; 54941 if (cellIndex < targetIndex) { 54942 count++; 54943 } 54944 } 54945 return count; 54946 }; 54947 return getNumberOfBlocksBeforeCell; 54948 } 54949 54950 // packages/block-editor/build-module/components/child-layout-control/index.js 54951 var import_jsx_runtime358 = __toESM(require_jsx_runtime()); 54952 function helpText(selfStretch, parentLayout) { 54953 const { orientation = "horizontal" } = parentLayout; 54954 if (selfStretch === "fill") { 54955 return (0, import_i18n184.__)("Stretch to fill available space."); 54956 } 54957 if (selfStretch === "fixed" && orientation === "horizontal") { 54958 return (0, import_i18n184.__)("Specify a fixed width."); 54959 } else if (selfStretch === "fixed") { 54960 return (0, import_i18n184.__)("Specify a fixed height."); 54961 } 54962 return (0, import_i18n184.__)("Fit contents."); 54963 } 54964 function ChildLayoutControl({ 54965 value: childLayout = {}, 54966 onChange, 54967 parentLayout, 54968 isShownByDefault, 54969 panelId 54970 }) { 54971 const { 54972 type: parentType, 54973 default: { type: defaultParentType = "default" } = {} 54974 } = parentLayout ?? {}; 54975 const parentLayoutType = parentType || defaultParentType; 54976 if (parentLayoutType === "flex") { 54977 return /* @__PURE__ */ (0, import_jsx_runtime358.jsx)( 54978 FlexControls, 54979 { 54980 childLayout, 54981 onChange, 54982 parentLayout, 54983 isShownByDefault, 54984 panelId 54985 } 54986 ); 54987 } else if (parentLayoutType === "grid") { 54988 return /* @__PURE__ */ (0, import_jsx_runtime358.jsx)( 54989 GridControls, 54990 { 54991 childLayout, 54992 onChange, 54993 parentLayout, 54994 isShownByDefault, 54995 panelId 54996 } 54997 ); 54998 } 54999 return null; 55000 } 55001 function FlexControls({ 55002 childLayout, 55003 onChange, 55004 parentLayout, 55005 isShownByDefault, 55006 panelId 55007 }) { 55008 const { selfStretch, flexSize } = childLayout; 55009 const { orientation = "horizontal" } = parentLayout ?? {}; 55010 const hasFlexValue = () => !!selfStretch; 55011 const flexResetLabel = orientation === "horizontal" ? (0, import_i18n184.__)("Width") : (0, import_i18n184.__)("Height"); 55012 const [availableUnits] = useSettings("spacing.units"); 55013 const units2 = (0, import_components194.__experimentalUseCustomUnits)({ 55014 availableUnits: availableUnits || [ 55015 "%", 55016 "px", 55017 "em", 55018 "rem", 55019 "vh", 55020 "vw" 55021 ] 55022 }); 55023 const resetFlex = () => { 55024 onChange({ 55025 selfStretch: void 0, 55026 flexSize: void 0 55027 }); 55028 }; 55029 (0, import_element198.useEffect)(() => { 55030 if (selfStretch === "fixed" && !flexSize) { 55031 onChange({ 55032 ...childLayout, 55033 selfStretch: "fit" 55034 }); 55035 } 55036 }, []); 55037 return /* @__PURE__ */ (0, import_jsx_runtime358.jsxs)( 55038 import_components194.__experimentalVStack, 55039 { 55040 as: import_components194.__experimentalToolsPanelItem, 55041 spacing: 2, 55042 hasValue: hasFlexValue, 55043 label: flexResetLabel, 55044 onDeselect: resetFlex, 55045 isShownByDefault, 55046 panelId, 55047 children: [ 55048 /* @__PURE__ */ (0, import_jsx_runtime358.jsxs)( 55049 import_components194.__experimentalToggleGroupControl, 55050 { 55051 size: "__unstable-large", 55052 label: childLayoutOrientation(parentLayout), 55053 value: selfStretch || "fit", 55054 help: helpText(selfStretch, parentLayout), 55055 onChange: (value) => { 55056 const newFlexSize = value !== "fixed" ? null : flexSize; 55057 onChange({ 55058 selfStretch: value, 55059 flexSize: newFlexSize 55060 }); 55061 }, 55062 isBlock: true, 55063 children: [ 55064 /* @__PURE__ */ (0, import_jsx_runtime358.jsx)( 55065 import_components194.__experimentalToggleGroupControlOption, 55066 { 55067 value: "fit", 55068 label: (0, import_i18n184._x)( 55069 "Fit", 55070 "Intrinsic block width in flex layout" 55071 ) 55072 }, 55073 "fit" 55074 ), 55075 /* @__PURE__ */ (0, import_jsx_runtime358.jsx)( 55076 import_components194.__experimentalToggleGroupControlOption, 55077 { 55078 value: "fill", 55079 label: (0, import_i18n184._x)( 55080 "Grow", 55081 "Block with expanding width in flex layout" 55082 ) 55083 }, 55084 "fill" 55085 ), 55086 /* @__PURE__ */ (0, import_jsx_runtime358.jsx)( 55087 import_components194.__experimentalToggleGroupControlOption, 55088 { 55089 value: "fixed", 55090 label: (0, import_i18n184._x)( 55091 "Fixed", 55092 "Block with fixed width in flex layout" 55093 ) 55094 }, 55095 "fixed" 55096 ) 55097 ] 55098 } 55099 ), 55100 selfStretch === "fixed" && /* @__PURE__ */ (0, import_jsx_runtime358.jsx)( 55101 import_components194.__experimentalUnitControl, 55102 { 55103 size: "__unstable-large", 55104 units: units2, 55105 onChange: (value) => { 55106 onChange({ 55107 selfStretch, 55108 flexSize: value 55109 }); 55110 }, 55111 value: flexSize, 55112 min: 0, 55113 label: flexResetLabel, 55114 hideLabelFromVision: true 55115 } 55116 ) 55117 ] 55118 } 55119 ); 55120 } 55121 function childLayoutOrientation(parentLayout) { 55122 const { orientation = "horizontal" } = parentLayout; 55123 return orientation === "horizontal" ? (0, import_i18n184.__)("Width") : (0, import_i18n184.__)("Height"); 55124 } 55125 function GridControls({ 55126 childLayout, 55127 onChange, 55128 parentLayout, 55129 isShownByDefault, 55130 panelId 55131 }) { 55132 const { columnStart, rowStart, columnSpan, rowSpan } = childLayout; 55133 const { columnCount, rowCount } = parentLayout ?? {}; 55134 const rootClientId = (0, import_data159.useSelect)( 55135 (select3) => select3(store).getBlockRootClientId(panelId) 55136 ); 55137 const { moveBlocksToPosition: moveBlocksToPosition2, __unstableMarkNextChangeAsNotPersistent: __unstableMarkNextChangeAsNotPersistent2 } = (0, import_data159.useDispatch)(store); 55138 const getNumberOfBlocksBeforeCell = useGetNumberOfBlocksBeforeCell( 55139 rootClientId, 55140 columnCount || 3 55141 ); 55142 const hasStartValue = () => !!columnStart || !!rowStart; 55143 const hasSpanValue = () => !!columnSpan || !!rowSpan; 55144 const resetGridStarts = () => { 55145 onChange({ 55146 columnStart: void 0, 55147 rowStart: void 0 55148 }); 55149 }; 55150 const resetGridSpans = () => { 55151 onChange({ 55152 columnSpan: void 0, 55153 rowSpan: void 0 55154 }); 55155 }; 55156 const maxColumnSpan = columnCount ? columnCount - (columnStart ?? 1) + 1 : void 0; 55157 const maxRowSpan = window.__experimentalEnableGridInteractivity && rowCount ? rowCount - (rowStart ?? 1) + 1 : void 0; 55158 return /* @__PURE__ */ (0, import_jsx_runtime358.jsxs)(import_jsx_runtime358.Fragment, { children: [ 55159 /* @__PURE__ */ (0, import_jsx_runtime358.jsxs)( 55160 import_components194.Flex, 55161 { 55162 as: import_components194.__experimentalToolsPanelItem, 55163 hasValue: hasSpanValue, 55164 label: (0, import_i18n184.__)("Grid span"), 55165 onDeselect: resetGridSpans, 55166 isShownByDefault, 55167 panelId, 55168 children: [ 55169 /* @__PURE__ */ (0, import_jsx_runtime358.jsx)(import_components194.FlexItem, { style: { width: "50%" }, children: /* @__PURE__ */ (0, import_jsx_runtime358.jsx)( 55170 import_components194.__experimentalInputControl, 55171 { 55172 size: "__unstable-large", 55173 label: (0, import_i18n184.__)("Column span"), 55174 type: "number", 55175 onChange: (value) => { 55176 const newColumnSpan = value === "" ? 1 : parseInt(value, 10); 55177 const constrainedValue = maxColumnSpan ? Math.min(newColumnSpan, maxColumnSpan) : newColumnSpan; 55178 onChange({ 55179 columnStart, 55180 rowStart, 55181 rowSpan, 55182 columnSpan: constrainedValue 55183 }); 55184 }, 55185 value: columnSpan ?? 1, 55186 min: 1, 55187 max: maxColumnSpan 55188 } 55189 ) }), 55190 /* @__PURE__ */ (0, import_jsx_runtime358.jsx)(import_components194.FlexItem, { style: { width: "50%" }, children: /* @__PURE__ */ (0, import_jsx_runtime358.jsx)( 55191 import_components194.__experimentalInputControl, 55192 { 55193 size: "__unstable-large", 55194 label: (0, import_i18n184.__)("Row span"), 55195 type: "number", 55196 onChange: (value) => { 55197 const newRowSpan = value === "" ? 1 : parseInt(value, 10); 55198 const constrainedValue = maxRowSpan ? Math.min(newRowSpan, maxRowSpan) : newRowSpan; 55199 onChange({ 55200 columnStart, 55201 rowStart, 55202 columnSpan, 55203 rowSpan: constrainedValue 55204 }); 55205 }, 55206 value: rowSpan ?? 1, 55207 min: 1, 55208 max: maxRowSpan 55209 } 55210 ) }) 55211 ] 55212 } 55213 ), 55214 window.__experimentalEnableGridInteractivity && // Use Flex with an explicit width on the FlexItem instead of HStack to 55215 // work around an issue in webkit where inputs with a max attribute are 55216 // sized incorrectly. 55217 /* @__PURE__ */ (0, import_jsx_runtime358.jsxs)( 55218 import_components194.Flex, 55219 { 55220 as: import_components194.__experimentalToolsPanelItem, 55221 hasValue: hasStartValue, 55222 label: (0, import_i18n184.__)("Grid placement"), 55223 onDeselect: resetGridStarts, 55224 isShownByDefault: false, 55225 panelId, 55226 children: [ 55227 /* @__PURE__ */ (0, import_jsx_runtime358.jsx)(import_components194.FlexItem, { style: { width: "50%" }, children: /* @__PURE__ */ (0, import_jsx_runtime358.jsx)( 55228 import_components194.__experimentalInputControl, 55229 { 55230 size: "__unstable-large", 55231 label: (0, import_i18n184.__)("Column"), 55232 type: "number", 55233 onChange: (value) => { 55234 const newColumnStart = value === "" ? 1 : parseInt(value, 10); 55235 onChange({ 55236 columnStart: newColumnStart, 55237 rowStart, 55238 columnSpan, 55239 rowSpan 55240 }); 55241 __unstableMarkNextChangeAsNotPersistent2(); 55242 moveBlocksToPosition2( 55243 [panelId], 55244 rootClientId, 55245 rootClientId, 55246 getNumberOfBlocksBeforeCell( 55247 newColumnStart, 55248 rowStart 55249 ) 55250 ); 55251 }, 55252 value: columnStart ?? 1, 55253 min: 1, 55254 max: columnCount ? columnCount - (columnSpan ?? 1) + 1 : void 0 55255 } 55256 ) }), 55257 /* @__PURE__ */ (0, import_jsx_runtime358.jsx)(import_components194.FlexItem, { style: { width: "50%" }, children: /* @__PURE__ */ (0, import_jsx_runtime358.jsx)( 55258 import_components194.__experimentalInputControl, 55259 { 55260 size: "__unstable-large", 55261 label: (0, import_i18n184.__)("Row"), 55262 type: "number", 55263 onChange: (value) => { 55264 const newRowStart = value === "" ? 1 : parseInt(value, 10); 55265 onChange({ 55266 columnStart, 55267 rowStart: newRowStart, 55268 columnSpan, 55269 rowSpan 55270 }); 55271 __unstableMarkNextChangeAsNotPersistent2(); 55272 moveBlocksToPosition2( 55273 [panelId], 55274 rootClientId, 55275 rootClientId, 55276 getNumberOfBlocksBeforeCell( 55277 columnStart, 55278 newRowStart 55279 ) 55280 ); 55281 }, 55282 value: rowStart ?? 1, 55283 min: 1, 55284 max: rowCount ? rowCount - (rowSpan ?? 1) + 1 : void 0 55285 } 55286 ) }) 55287 ] 55288 } 55289 ) 55290 ] }); 55291 } 55292 55293 // packages/block-editor/build-module/components/dimensions-tool/aspect-ratio-tool.js 55294 var import_components195 = __toESM(require_components()); 55295 var import_i18n185 = __toESM(require_i18n()); 55296 var import_jsx_runtime359 = __toESM(require_jsx_runtime()); 55297 function AspectRatioTool({ 55298 panelId, 55299 value, 55300 onChange = () => { 55301 }, 55302 options, 55303 defaultValue = "auto", 55304 hasValue, 55305 isShownByDefault = true 55306 }) { 55307 const displayValue = value ?? "auto"; 55308 const [defaultRatios, themeRatios, showDefaultRatios] = useSettings( 55309 "dimensions.aspectRatios.default", 55310 "dimensions.aspectRatios.theme", 55311 "dimensions.defaultAspectRatios" 55312 ); 55313 const themeOptions = themeRatios?.map(({ name, ratio }) => ({ 55314 label: name, 55315 value: ratio 55316 })); 55317 const defaultOptions2 = defaultRatios?.map(({ name, ratio }) => ({ 55318 label: name, 55319 value: ratio 55320 })); 55321 const aspectRatioOptions = [ 55322 { 55323 label: (0, import_i18n185._x)( 55324 "Original", 55325 "Aspect ratio option for dimensions control" 55326 ), 55327 value: "auto" 55328 }, 55329 ...showDefaultRatios ? defaultOptions2 : [], 55330 ...themeOptions ? themeOptions : [], 55331 { 55332 label: (0, import_i18n185._x)("Custom", "Aspect ratio option for dimensions control"), 55333 value: "custom", 55334 disabled: true, 55335 hidden: true 55336 } 55337 ]; 55338 return /* @__PURE__ */ (0, import_jsx_runtime359.jsx)( 55339 import_components195.__experimentalToolsPanelItem, 55340 { 55341 hasValue: hasValue ? hasValue : () => displayValue !== defaultValue, 55342 label: (0, import_i18n185.__)("Aspect ratio"), 55343 onDeselect: () => onChange(void 0), 55344 isShownByDefault, 55345 panelId, 55346 children: /* @__PURE__ */ (0, import_jsx_runtime359.jsx)( 55347 import_components195.SelectControl, 55348 { 55349 label: (0, import_i18n185.__)("Aspect ratio"), 55350 value: displayValue, 55351 options: options ?? aspectRatioOptions, 55352 onChange, 55353 size: "__unstable-large" 55354 } 55355 ) 55356 } 55357 ); 55358 } 55359 55360 // packages/block-editor/build-module/components/global-styles/dimensions-panel.js 55361 var import_jsx_runtime360 = __toESM(require_jsx_runtime()); 55362 var AXIAL_SIDES = ["horizontal", "vertical"]; 55363 function useHasDimensionsPanel(settings2) { 55364 const hasContentSize = useHasContentSize(settings2); 55365 const hasWideSize = useHasWideSize(settings2); 55366 const hasPadding = useHasPadding(settings2); 55367 const hasMargin = useHasMargin(settings2); 55368 const hasGap = useHasGap(settings2); 55369 const hasHeight = useHasHeight(settings2); 55370 const hasMinHeight = useHasMinHeight(settings2); 55371 const hasWidth = useHasWidth(settings2); 55372 const hasAspectRatio = useHasAspectRatio(settings2); 55373 const hasChildLayout = useHasChildLayout(settings2); 55374 return import_element199.Platform.OS === "web" && (hasContentSize || hasWideSize || hasPadding || hasMargin || hasGap || hasHeight || hasMinHeight || hasWidth || hasAspectRatio || hasChildLayout); 55375 } 55376 function useHasContentSize(settings2) { 55377 return settings2?.layout?.contentSize; 55378 } 55379 function useHasWideSize(settings2) { 55380 return settings2?.layout?.wideSize; 55381 } 55382 function useHasPadding(settings2) { 55383 return settings2?.spacing?.padding; 55384 } 55385 function useHasMargin(settings2) { 55386 return settings2?.spacing?.margin; 55387 } 55388 function useHasGap(settings2) { 55389 return settings2?.spacing?.blockGap; 55390 } 55391 function useHasHeight(settings2) { 55392 return settings2?.dimensions?.height; 55393 } 55394 function useHasMinHeight(settings2) { 55395 return settings2?.dimensions?.minHeight; 55396 } 55397 function useHasWidth(settings2) { 55398 return settings2?.dimensions?.width; 55399 } 55400 function useHasAspectRatio(settings2) { 55401 return settings2?.dimensions?.aspectRatio; 55402 } 55403 function useHasChildLayout(settings2) { 55404 const { 55405 type: parentLayoutType = "default", 55406 default: { type: defaultParentLayoutType = "default" } = {}, 55407 allowSizingOnChildren = false 55408 } = settings2?.parentLayout ?? {}; 55409 const support = (defaultParentLayoutType === "flex" || parentLayoutType === "flex" || defaultParentLayoutType === "grid" || parentLayoutType === "grid") && allowSizingOnChildren; 55410 return !!settings2?.layout && support; 55411 } 55412 function useHasSpacingPresets(settings2) { 55413 const { defaultSpacingSizes, spacingSizes } = settings2?.spacing || {}; 55414 return defaultSpacingSizes !== false && spacingSizes?.default?.length > 0 || spacingSizes?.theme?.length > 0 || spacingSizes?.custom?.length > 0; 55415 } 55416 function filterValuesBySides(values, sides) { 55417 if (!sides || !values) { 55418 return values; 55419 } 55420 const filteredValues = {}; 55421 sides.forEach((side) => { 55422 if (side === "vertical") { 55423 filteredValues.top = values.top; 55424 filteredValues.bottom = values.bottom; 55425 } 55426 if (side === "horizontal") { 55427 filteredValues.left = values.left; 55428 filteredValues.right = values.right; 55429 } 55430 filteredValues[side] = values?.[side]; 55431 }); 55432 return filteredValues; 55433 } 55434 function splitStyleValue(value) { 55435 if (value && typeof value === "string") { 55436 return { 55437 top: value, 55438 right: value, 55439 bottom: value, 55440 left: value 55441 }; 55442 } 55443 return value; 55444 } 55445 function splitGapValue(value, isAxialGap) { 55446 if (!value) { 55447 return value; 55448 } 55449 if (typeof value === "string") { 55450 return isAxialGap ? { top: value, right: value, bottom: value, left: value } : { top: value }; 55451 } 55452 return { 55453 ...value, 55454 right: value?.left, 55455 bottom: value?.top 55456 }; 55457 } 55458 function DimensionsToolsPanel({ 55459 resetAllFilter, 55460 onChange, 55461 value, 55462 panelId, 55463 children 55464 }) { 55465 const dropdownMenuProps = useToolsPanelDropdownMenuProps(); 55466 const resetAll = () => { 55467 const updatedValue = resetAllFilter(value); 55468 onChange(updatedValue); 55469 }; 55470 return /* @__PURE__ */ (0, import_jsx_runtime360.jsx)( 55471 import_components196.__experimentalToolsPanel, 55472 { 55473 label: (0, import_i18n186.__)("Dimensions"), 55474 resetAll, 55475 panelId, 55476 dropdownMenuProps, 55477 children 55478 } 55479 ); 55480 } 55481 var DEFAULT_CONTROLS4 = { 55482 contentSize: true, 55483 wideSize: true, 55484 padding: true, 55485 margin: true, 55486 blockGap: true, 55487 height: true, 55488 minHeight: true, 55489 width: true, 55490 aspectRatio: true, 55491 childLayout: true 55492 }; 55493 function DimensionsPanel({ 55494 as: Wrapper = DimensionsToolsPanel, 55495 value, 55496 onChange, 55497 inheritedValue = value, 55498 settings: settings2, 55499 panelId, 55500 defaultControls = DEFAULT_CONTROLS4, 55501 onVisualize = () => { 55502 }, 55503 // Special case because the layout controls are not part of the dimensions panel 55504 // in global styles but not in block inspector. 55505 includeLayoutControls = false 55506 }) { 55507 const { dimensions, spacing } = settings2; 55508 const decodeValue = (rawValue) => { 55509 if (rawValue && typeof rawValue === "object") { 55510 return Object.keys(rawValue).reduce((acc, key) => { 55511 acc[key] = getValueFromVariable( 55512 { settings: { dimensions, spacing } }, 55513 "", 55514 rawValue[key] 55515 ); 55516 return acc; 55517 }, {}); 55518 } 55519 return getValueFromVariable( 55520 { settings: { dimensions, spacing } }, 55521 "", 55522 rawValue 55523 ); 55524 }; 55525 const showSpacingPresetsControl = useHasSpacingPresets(settings2); 55526 const units2 = (0, import_components196.__experimentalUseCustomUnits)({ 55527 availableUnits: settings2?.spacing?.units || [ 55528 "%", 55529 "px", 55530 "em", 55531 "rem", 55532 "vw" 55533 ] 55534 }); 55535 const minimumMargin = -Infinity; 55536 const [minMarginValue, setMinMarginValue] = (0, import_element199.useState)(minimumMargin); 55537 const showContentSizeControl = useHasContentSize(settings2) && includeLayoutControls; 55538 const contentSizeValue = decodeValue(inheritedValue?.layout?.contentSize); 55539 const setContentSizeValue = (newValue) => { 55540 onChange( 55541 setImmutably( 55542 value, 55543 ["layout", "contentSize"], 55544 newValue || void 0 55545 ) 55546 ); 55547 }; 55548 const hasUserSetContentSizeValue = () => !!value?.layout?.contentSize; 55549 const resetContentSizeValue = () => setContentSizeValue(void 0); 55550 const showWideSizeControl = useHasWideSize(settings2) && includeLayoutControls; 55551 const wideSizeValue = decodeValue(inheritedValue?.layout?.wideSize); 55552 const setWideSizeValue = (newValue) => { 55553 onChange( 55554 setImmutably( 55555 value, 55556 ["layout", "wideSize"], 55557 newValue || void 0 55558 ) 55559 ); 55560 }; 55561 const hasUserSetWideSizeValue = () => !!value?.layout?.wideSize; 55562 const resetWideSizeValue = () => setWideSizeValue(void 0); 55563 const showPaddingControl = useHasPadding(settings2); 55564 const rawPadding = decodeValue(inheritedValue?.spacing?.padding); 55565 const paddingValues = splitStyleValue(rawPadding); 55566 const paddingSides = Array.isArray(settings2?.spacing?.padding) ? settings2?.spacing?.padding : settings2?.spacing?.padding?.sides; 55567 const isAxialPadding = paddingSides && paddingSides.some((side) => AXIAL_SIDES.includes(side)); 55568 const setPaddingValues = (newPaddingValues) => { 55569 const padding = filterValuesBySides(newPaddingValues, paddingSides); 55570 onChange(setImmutably(value, ["spacing", "padding"], padding)); 55571 }; 55572 const hasPaddingValue = () => !!value?.spacing?.padding && Object.keys(value?.spacing?.padding).length; 55573 const resetPaddingValue = () => setPaddingValues(void 0); 55574 const onMouseOverPadding = () => onVisualize("padding"); 55575 const showMarginControl = useHasMargin(settings2); 55576 const rawMargin = decodeValue(inheritedValue?.spacing?.margin); 55577 const marginValues = splitStyleValue(rawMargin); 55578 const marginSides = Array.isArray(settings2?.spacing?.margin) ? settings2?.spacing?.margin : settings2?.spacing?.margin?.sides; 55579 const isAxialMargin = marginSides && marginSides.some((side) => AXIAL_SIDES.includes(side)); 55580 const setMarginValues = (newMarginValues) => { 55581 const margin = filterValuesBySides(newMarginValues, marginSides); 55582 onChange(setImmutably(value, ["spacing", "margin"], margin)); 55583 }; 55584 const hasMarginValue = () => !!value?.spacing?.margin && Object.keys(value?.spacing?.margin).length; 55585 const resetMarginValue = () => setMarginValues(void 0); 55586 const onMouseOverMargin = () => onVisualize("margin"); 55587 const showGapControl = useHasGap(settings2); 55588 const gapSides = Array.isArray(settings2?.spacing?.blockGap) ? settings2?.spacing?.blockGap : settings2?.spacing?.blockGap?.sides; 55589 const isAxialGap = gapSides && gapSides.some((side) => AXIAL_SIDES.includes(side)); 55590 const gapValue = decodeValue(inheritedValue?.spacing?.blockGap); 55591 const gapValues = splitGapValue(gapValue, isAxialGap); 55592 const setGapValue = (newGapValue) => { 55593 onChange( 55594 setImmutably(value, ["spacing", "blockGap"], newGapValue) 55595 ); 55596 }; 55597 const setGapValues = (nextBoxGapValue) => { 55598 if (!nextBoxGapValue) { 55599 setGapValue(null); 55600 } 55601 if (!isAxialGap && nextBoxGapValue?.hasOwnProperty("top")) { 55602 setGapValue(nextBoxGapValue.top); 55603 } else { 55604 setGapValue({ 55605 top: nextBoxGapValue?.top, 55606 left: nextBoxGapValue?.left 55607 }); 55608 } 55609 }; 55610 const resetGapValue = () => setGapValue(void 0); 55611 const hasGapValue = () => !!value?.spacing?.blockGap; 55612 const showMinHeightControl = useHasMinHeight(settings2); 55613 const minHeightValue = decodeValue(inheritedValue?.dimensions?.minHeight); 55614 const setMinHeightValue = (newValue) => { 55615 const tempValue = setImmutably( 55616 value, 55617 ["dimensions", "minHeight"], 55618 newValue 55619 ); 55620 onChange( 55621 setImmutably( 55622 tempValue, 55623 ["dimensions", "aspectRatio"], 55624 void 0 55625 ) 55626 ); 55627 }; 55628 const resetMinHeightValue = () => { 55629 setMinHeightValue(void 0); 55630 }; 55631 const hasMinHeightValue = () => !!value?.dimensions?.minHeight; 55632 const showHeightControl = useHasHeight(settings2); 55633 const heightValue = decodeValue(inheritedValue?.dimensions?.height); 55634 const setHeightValue = (newValue) => { 55635 const tempValue = setImmutably( 55636 value, 55637 ["dimensions", "height"], 55638 newValue 55639 ); 55640 onChange( 55641 setImmutably( 55642 tempValue, 55643 ["dimensions", "aspectRatio"], 55644 void 0 55645 ) 55646 ); 55647 }; 55648 const resetHeightValue = () => { 55649 setHeightValue(void 0); 55650 }; 55651 const hasHeightValue = () => !!value?.dimensions?.height; 55652 const showWidthControl = useHasWidth(settings2); 55653 const widthValue = decodeValue(inheritedValue?.dimensions?.width); 55654 const setWidthValue = (newValue) => { 55655 onChange(setImmutably(value, ["dimensions", "width"], newValue)); 55656 }; 55657 const resetWidthValue = () => { 55658 setWidthValue(void 0); 55659 }; 55660 const hasWidthValue = () => !!value?.dimensions?.width; 55661 const showAspectRatioControl = useHasAspectRatio(settings2); 55662 const aspectRatioValue = decodeValue( 55663 inheritedValue?.dimensions?.aspectRatio 55664 ); 55665 const setAspectRatioValue = (newValue) => { 55666 const tempValue = setImmutably( 55667 value, 55668 ["dimensions", "aspectRatio"], 55669 newValue 55670 ); 55671 onChange( 55672 setImmutably(tempValue, ["dimensions", "minHeight"], void 0) 55673 ); 55674 }; 55675 const hasAspectRatioValue = () => !!value?.dimensions?.aspectRatio; 55676 const showChildLayoutControl = useHasChildLayout(settings2); 55677 const childLayout = inheritedValue?.layout; 55678 const setChildLayout = (newChildLayout) => { 55679 onChange({ 55680 ...value, 55681 layout: { 55682 ...newChildLayout 55683 } 55684 }); 55685 }; 55686 const resetAllFilter = (0, import_element199.useCallback)((previousValue) => { 55687 return { 55688 ...previousValue, 55689 layout: cleanEmptyObject({ 55690 ...previousValue?.layout, 55691 contentSize: void 0, 55692 wideSize: void 0, 55693 selfStretch: void 0, 55694 flexSize: void 0, 55695 columnStart: void 0, 55696 rowStart: void 0, 55697 columnSpan: void 0, 55698 rowSpan: void 0 55699 }), 55700 spacing: { 55701 ...previousValue?.spacing, 55702 padding: void 0, 55703 margin: void 0, 55704 blockGap: void 0 55705 }, 55706 dimensions: { 55707 ...previousValue?.dimensions, 55708 height: void 0, 55709 minHeight: void 0, 55710 aspectRatio: void 0, 55711 width: void 0 55712 } 55713 }; 55714 }, []); 55715 const onMouseLeaveControls = () => onVisualize(false); 55716 return /* @__PURE__ */ (0, import_jsx_runtime360.jsxs)( 55717 Wrapper, 55718 { 55719 resetAllFilter, 55720 value, 55721 onChange, 55722 panelId, 55723 children: [ 55724 (showContentSizeControl || showWideSizeControl) && /* @__PURE__ */ (0, import_jsx_runtime360.jsx)("span", { className: "span-columns", children: (0, import_i18n186.__)("Set the width of the main content area.") }), 55725 showContentSizeControl && /* @__PURE__ */ (0, import_jsx_runtime360.jsx)( 55726 import_components196.__experimentalToolsPanelItem, 55727 { 55728 label: (0, import_i18n186.__)("Content width"), 55729 hasValue: hasUserSetContentSizeValue, 55730 onDeselect: resetContentSizeValue, 55731 isShownByDefault: defaultControls.contentSize ?? DEFAULT_CONTROLS4.contentSize, 55732 panelId, 55733 children: /* @__PURE__ */ (0, import_jsx_runtime360.jsx)( 55734 import_components196.__experimentalUnitControl, 55735 { 55736 __next40pxDefaultSize: true, 55737 label: (0, import_i18n186.__)("Content width"), 55738 labelPosition: "top", 55739 value: contentSizeValue || "", 55740 onChange: (nextContentSize) => { 55741 setContentSizeValue(nextContentSize); 55742 }, 55743 units: units2, 55744 prefix: /* @__PURE__ */ (0, import_jsx_runtime360.jsx)(import_components196.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime360.jsx)(icon_default, { icon: align_none_default }) }) 55745 } 55746 ) 55747 } 55748 ), 55749 showWideSizeControl && /* @__PURE__ */ (0, import_jsx_runtime360.jsx)( 55750 import_components196.__experimentalToolsPanelItem, 55751 { 55752 label: (0, import_i18n186.__)("Wide width"), 55753 hasValue: hasUserSetWideSizeValue, 55754 onDeselect: resetWideSizeValue, 55755 isShownByDefault: defaultControls.wideSize ?? DEFAULT_CONTROLS4.wideSize, 55756 panelId, 55757 children: /* @__PURE__ */ (0, import_jsx_runtime360.jsx)( 55758 import_components196.__experimentalUnitControl, 55759 { 55760 __next40pxDefaultSize: true, 55761 label: (0, import_i18n186.__)("Wide width"), 55762 labelPosition: "top", 55763 value: wideSizeValue || "", 55764 onChange: (nextWideSize) => { 55765 setWideSizeValue(nextWideSize); 55766 }, 55767 units: units2, 55768 prefix: /* @__PURE__ */ (0, import_jsx_runtime360.jsx)(import_components196.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime360.jsx)(icon_default, { icon: stretch_wide_default }) }) 55769 } 55770 ) 55771 } 55772 ), 55773 showPaddingControl && /* @__PURE__ */ (0, import_jsx_runtime360.jsxs)( 55774 import_components196.__experimentalToolsPanelItem, 55775 { 55776 hasValue: hasPaddingValue, 55777 label: (0, import_i18n186.__)("Padding"), 55778 onDeselect: resetPaddingValue, 55779 isShownByDefault: defaultControls.padding ?? DEFAULT_CONTROLS4.padding, 55780 className: clsx_default({ 55781 "tools-panel-item-spacing": showSpacingPresetsControl 55782 }), 55783 panelId, 55784 children: [ 55785 !showSpacingPresetsControl && /* @__PURE__ */ (0, import_jsx_runtime360.jsx)( 55786 import_components196.BoxControl, 55787 { 55788 __next40pxDefaultSize: true, 55789 values: paddingValues, 55790 onChange: setPaddingValues, 55791 label: (0, import_i18n186.__)("Padding"), 55792 sides: paddingSides, 55793 units: units2, 55794 allowReset: false, 55795 splitOnAxis: isAxialPadding, 55796 inputProps: { 55797 onMouseOver: onMouseOverPadding, 55798 onMouseOut: onMouseLeaveControls 55799 } 55800 } 55801 ), 55802 showSpacingPresetsControl && /* @__PURE__ */ (0, import_jsx_runtime360.jsx)( 55803 SpacingSizesControl, 55804 { 55805 values: paddingValues, 55806 onChange: setPaddingValues, 55807 label: (0, import_i18n186.__)("Padding"), 55808 sides: paddingSides, 55809 units: units2, 55810 allowReset: false, 55811 onMouseOver: onMouseOverPadding, 55812 onMouseOut: onMouseLeaveControls 55813 } 55814 ) 55815 ] 55816 } 55817 ), 55818 showMarginControl && /* @__PURE__ */ (0, import_jsx_runtime360.jsxs)( 55819 import_components196.__experimentalToolsPanelItem, 55820 { 55821 hasValue: hasMarginValue, 55822 label: (0, import_i18n186.__)("Margin"), 55823 onDeselect: resetMarginValue, 55824 isShownByDefault: defaultControls.margin ?? DEFAULT_CONTROLS4.margin, 55825 className: clsx_default({ 55826 "tools-panel-item-spacing": showSpacingPresetsControl 55827 }), 55828 panelId, 55829 children: [ 55830 !showSpacingPresetsControl && /* @__PURE__ */ (0, import_jsx_runtime360.jsx)( 55831 import_components196.BoxControl, 55832 { 55833 __next40pxDefaultSize: true, 55834 values: marginValues, 55835 onChange: setMarginValues, 55836 inputProps: { 55837 min: minMarginValue, 55838 onDragStart: () => { 55839 setMinMarginValue(0); 55840 }, 55841 onDragEnd: () => { 55842 setMinMarginValue(minimumMargin); 55843 }, 55844 onMouseOver: onMouseOverMargin, 55845 onMouseOut: onMouseLeaveControls 55846 }, 55847 label: (0, import_i18n186.__)("Margin"), 55848 sides: marginSides, 55849 units: units2, 55850 allowReset: false, 55851 splitOnAxis: isAxialMargin 55852 } 55853 ), 55854 showSpacingPresetsControl && /* @__PURE__ */ (0, import_jsx_runtime360.jsx)( 55855 SpacingSizesControl, 55856 { 55857 values: marginValues, 55858 onChange: setMarginValues, 55859 minimumCustomValue: -Infinity, 55860 label: (0, import_i18n186.__)("Margin"), 55861 sides: marginSides, 55862 units: units2, 55863 allowReset: false, 55864 onMouseOver: onMouseOverMargin, 55865 onMouseOut: onMouseLeaveControls 55866 } 55867 ) 55868 ] 55869 } 55870 ), 55871 showGapControl && /* @__PURE__ */ (0, import_jsx_runtime360.jsxs)( 55872 import_components196.__experimentalToolsPanelItem, 55873 { 55874 hasValue: hasGapValue, 55875 label: (0, import_i18n186.__)("Block spacing"), 55876 onDeselect: resetGapValue, 55877 isShownByDefault: defaultControls.blockGap ?? DEFAULT_CONTROLS4.blockGap, 55878 className: clsx_default({ 55879 "tools-panel-item-spacing": showSpacingPresetsControl, 55880 "single-column": ( 55881 // If UnitControl is used, should be single-column. 55882 !showSpacingPresetsControl && !isAxialGap 55883 ) 55884 }), 55885 panelId, 55886 children: [ 55887 !showSpacingPresetsControl && (isAxialGap ? /* @__PURE__ */ (0, import_jsx_runtime360.jsx)( 55888 import_components196.BoxControl, 55889 { 55890 __next40pxDefaultSize: true, 55891 label: (0, import_i18n186.__)("Block spacing"), 55892 min: 0, 55893 onChange: setGapValues, 55894 units: units2, 55895 sides: gapSides, 55896 values: gapValues, 55897 allowReset: false, 55898 splitOnAxis: isAxialGap 55899 } 55900 ) : /* @__PURE__ */ (0, import_jsx_runtime360.jsx)( 55901 import_components196.__experimentalUnitControl, 55902 { 55903 __next40pxDefaultSize: true, 55904 label: (0, import_i18n186.__)("Block spacing"), 55905 min: 0, 55906 onChange: setGapValue, 55907 units: units2, 55908 value: gapValue 55909 } 55910 )), 55911 showSpacingPresetsControl && /* @__PURE__ */ (0, import_jsx_runtime360.jsx)( 55912 SpacingSizesControl, 55913 { 55914 label: (0, import_i18n186.__)("Block spacing"), 55915 min: 0, 55916 onChange: setGapValues, 55917 showSideInLabel: false, 55918 sides: isAxialGap ? gapSides : ["top"], 55919 values: gapValues, 55920 allowReset: false 55921 } 55922 ) 55923 ] 55924 } 55925 ), 55926 showChildLayoutControl && /* @__PURE__ */ (0, import_jsx_runtime360.jsx)( 55927 ChildLayoutControl, 55928 { 55929 value: childLayout, 55930 onChange: setChildLayout, 55931 parentLayout: settings2?.parentLayout, 55932 panelId, 55933 isShownByDefault: defaultControls.childLayout ?? DEFAULT_CONTROLS4.childLayout 55934 } 55935 ), 55936 showMinHeightControl && /* @__PURE__ */ (0, import_jsx_runtime360.jsx)( 55937 import_components196.__experimentalToolsPanelItem, 55938 { 55939 hasValue: hasMinHeightValue, 55940 label: (0, import_i18n186.__)("Minimum height"), 55941 onDeselect: resetMinHeightValue, 55942 isShownByDefault: defaultControls.minHeight ?? DEFAULT_CONTROLS4.minHeight, 55943 panelId, 55944 children: /* @__PURE__ */ (0, import_jsx_runtime360.jsx)( 55945 DimensionControl, 55946 { 55947 label: (0, import_i18n186.__)("Minimum height"), 55948 value: minHeightValue, 55949 onChange: setMinHeightValue 55950 } 55951 ) 55952 } 55953 ), 55954 showHeightControl && /* @__PURE__ */ (0, import_jsx_runtime360.jsx)( 55955 import_components196.__experimentalToolsPanelItem, 55956 { 55957 hasValue: hasHeightValue, 55958 label: (0, import_i18n186.__)("Height"), 55959 onDeselect: resetHeightValue, 55960 isShownByDefault: defaultControls.height ?? DEFAULT_CONTROLS4.height, 55961 panelId, 55962 children: /* @__PURE__ */ (0, import_jsx_runtime360.jsx)( 55963 DimensionControl, 55964 { 55965 label: (0, import_i18n186.__)("Height"), 55966 value: heightValue, 55967 onChange: setHeightValue 55968 } 55969 ) 55970 } 55971 ), 55972 showWidthControl && /* @__PURE__ */ (0, import_jsx_runtime360.jsx)( 55973 import_components196.__experimentalToolsPanelItem, 55974 { 55975 hasValue: hasWidthValue, 55976 label: (0, import_i18n186.__)("Width"), 55977 onDeselect: resetWidthValue, 55978 isShownByDefault: defaultControls.width ?? DEFAULT_CONTROLS4.width, 55979 panelId, 55980 children: /* @__PURE__ */ (0, import_jsx_runtime360.jsx)( 55981 DimensionControl, 55982 { 55983 label: (0, import_i18n186.__)("Width"), 55984 value: widthValue, 55985 onChange: setWidthValue 55986 } 55987 ) 55988 } 55989 ), 55990 showAspectRatioControl && /* @__PURE__ */ (0, import_jsx_runtime360.jsx)( 55991 AspectRatioTool, 55992 { 55993 hasValue: hasAspectRatioValue, 55994 value: aspectRatioValue, 55995 onChange: setAspectRatioValue, 55996 panelId, 55997 isShownByDefault: defaultControls.aspectRatio ?? DEFAULT_CONTROLS4.aspectRatio 55998 } 55999 ) 56000 ] 56001 } 56002 ); 56003 } 56004 56005 // packages/block-editor/build-module/components/global-styles/border-panel.js 56006 var import_components198 = __toESM(require_components()); 56007 var import_element201 = __toESM(require_element()); 56008 var import_i18n188 = __toESM(require_i18n()); 56009 56010 // packages/block-editor/build-module/components/global-styles/shadow-panel-components.js 56011 var import_i18n187 = __toESM(require_i18n()); 56012 var import_components197 = __toESM(require_components()); 56013 var import_element200 = __toESM(require_element()); 56014 var import_jsx_runtime361 = __toESM(require_jsx_runtime()); 56015 var EMPTY_ARRAY12 = []; 56016 function ShadowPopoverContainer({ shadow, onShadowChange, settings: settings2 }) { 56017 const shadows = useShadowPresets(settings2); 56018 return /* @__PURE__ */ (0, import_jsx_runtime361.jsx)("div", { className: "block-editor-global-styles__shadow-popover-container", children: /* @__PURE__ */ (0, import_jsx_runtime361.jsxs)(import_components197.__experimentalVStack, { spacing: 4, children: [ 56019 /* @__PURE__ */ (0, import_jsx_runtime361.jsx)(import_components197.__experimentalHeading, { level: 5, children: (0, import_i18n187.__)("Drop shadow") }), 56020 /* @__PURE__ */ (0, import_jsx_runtime361.jsx)( 56021 ShadowPresets, 56022 { 56023 presets: shadows, 56024 activeShadow: shadow, 56025 onSelect: onShadowChange 56026 } 56027 ), 56028 /* @__PURE__ */ (0, import_jsx_runtime361.jsx)("div", { className: "block-editor-global-styles__clear-shadow", children: /* @__PURE__ */ (0, import_jsx_runtime361.jsx)( 56029 import_components197.Button, 56030 { 56031 __next40pxDefaultSize: true, 56032 variant: "tertiary", 56033 onClick: () => onShadowChange(void 0), 56034 disabled: !shadow, 56035 accessibleWhenDisabled: true, 56036 children: (0, import_i18n187.__)("Clear") 56037 } 56038 ) }) 56039 ] }) }); 56040 } 56041 function ShadowPresets({ presets, activeShadow, onSelect }) { 56042 return !presets ? null : /* @__PURE__ */ (0, import_jsx_runtime361.jsx)( 56043 import_components197.Composite, 56044 { 56045 role: "listbox", 56046 className: "block-editor-global-styles__shadow__list", 56047 "aria-label": (0, import_i18n187.__)("Drop shadows"), 56048 children: presets.map(({ name, slug, shadow }) => /* @__PURE__ */ (0, import_jsx_runtime361.jsx)( 56049 ShadowIndicator, 56050 { 56051 label: name, 56052 isActive: shadow === activeShadow, 56053 type: slug === "unset" ? "unset" : "preset", 56054 onSelect: () => onSelect(shadow === activeShadow ? void 0 : shadow), 56055 shadow 56056 }, 56057 slug 56058 )) 56059 } 56060 ); 56061 } 56062 function ShadowIndicator({ type, label, isActive, onSelect, shadow }) { 56063 return /* @__PURE__ */ (0, import_jsx_runtime361.jsx)(import_components197.Tooltip, { text: label, children: /* @__PURE__ */ (0, import_jsx_runtime361.jsx)( 56064 import_components197.Composite.Item, 56065 { 56066 role: "option", 56067 "aria-label": label, 56068 "aria-selected": isActive, 56069 className: clsx_default("block-editor-global-styles__shadow__item", { 56070 "is-active": isActive 56071 }), 56072 render: /* @__PURE__ */ (0, import_jsx_runtime361.jsx)( 56073 "button", 56074 { 56075 className: clsx_default( 56076 "block-editor-global-styles__shadow-indicator", 56077 { 56078 unset: type === "unset" 56079 } 56080 ), 56081 onClick: onSelect, 56082 style: { boxShadow: shadow }, 56083 "aria-label": label, 56084 children: isActive && /* @__PURE__ */ (0, import_jsx_runtime361.jsx)(icon_default, { icon: check_default }) 56085 } 56086 ) 56087 } 56088 ) }); 56089 } 56090 function ShadowPopover({ shadow, onShadowChange, settings: settings2 }) { 56091 const popoverProps3 = { 56092 placement: "left-start", 56093 offset: 36, 56094 shift: true 56095 }; 56096 return /* @__PURE__ */ (0, import_jsx_runtime361.jsx)( 56097 import_components197.Dropdown, 56098 { 56099 popoverProps: popoverProps3, 56100 className: "block-editor-global-styles__shadow-dropdown", 56101 renderToggle: renderShadowToggle(shadow, onShadowChange), 56102 renderContent: () => /* @__PURE__ */ (0, import_jsx_runtime361.jsx)(import_components197.__experimentalDropdownContentWrapper, { paddingSize: "medium", children: /* @__PURE__ */ (0, import_jsx_runtime361.jsx)( 56103 ShadowPopoverContainer, 56104 { 56105 shadow, 56106 onShadowChange, 56107 settings: settings2 56108 } 56109 ) }) 56110 } 56111 ); 56112 } 56113 function renderShadowToggle(shadow, onShadowChange) { 56114 return ({ onToggle, isOpen }) => { 56115 const shadowButtonRef = (0, import_element200.useRef)(void 0); 56116 const toggleProps = { 56117 onClick: onToggle, 56118 className: clsx_default( 56119 "block-editor-global-styles__shadow-dropdown-toggle", 56120 { "is-open": isOpen } 56121 ), 56122 "aria-expanded": isOpen, 56123 ref: shadowButtonRef 56124 }; 56125 const removeButtonProps = { 56126 onClick: () => { 56127 if (isOpen) { 56128 onToggle(); 56129 } 56130 onShadowChange(void 0); 56131 shadowButtonRef.current?.focus(); 56132 }, 56133 className: clsx_default( 56134 "block-editor-global-styles__shadow-editor__remove-button", 56135 { "is-open": isOpen } 56136 ), 56137 label: (0, import_i18n187.__)("Remove") 56138 }; 56139 return /* @__PURE__ */ (0, import_jsx_runtime361.jsxs)(import_jsx_runtime361.Fragment, { children: [ 56140 /* @__PURE__ */ (0, import_jsx_runtime361.jsx)(import_components197.Button, { __next40pxDefaultSize: true, ...toggleProps, children: /* @__PURE__ */ (0, import_jsx_runtime361.jsxs)(import_components197.__experimentalHStack, { justify: "flex-start", children: [ 56141 /* @__PURE__ */ (0, import_jsx_runtime361.jsx)( 56142 icon_default, 56143 { 56144 className: "block-editor-global-styles__toggle-icon", 56145 icon: shadow_default, 56146 size: 24 56147 } 56148 ), 56149 /* @__PURE__ */ (0, import_jsx_runtime361.jsx)(import_components197.FlexItem, { children: (0, import_i18n187.__)("Drop shadow") }) 56150 ] }) }), 56151 !!shadow && /* @__PURE__ */ (0, import_jsx_runtime361.jsx)( 56152 import_components197.Button, 56153 { 56154 __next40pxDefaultSize: true, 56155 size: "small", 56156 icon: reset_default, 56157 ...removeButtonProps 56158 } 56159 ) 56160 ] }); 56161 }; 56162 } 56163 function useShadowPresets(settings2) { 56164 return (0, import_element200.useMemo)(() => { 56165 if (!settings2?.shadow) { 56166 return EMPTY_ARRAY12; 56167 } 56168 const defaultPresetsEnabled = settings2?.shadow?.defaultPresets; 56169 const { 56170 default: defaultShadows, 56171 theme: themeShadows, 56172 custom: customShadows 56173 } = settings2?.shadow?.presets ?? {}; 56174 const unsetShadow = { 56175 name: (0, import_i18n187.__)("Unset"), 56176 slug: "unset", 56177 shadow: "none" 56178 }; 56179 const shadowPresets = [ 56180 ...defaultPresetsEnabled && defaultShadows || EMPTY_ARRAY12, 56181 ...themeShadows || EMPTY_ARRAY12, 56182 ...customShadows || EMPTY_ARRAY12 56183 ]; 56184 if (shadowPresets.length) { 56185 shadowPresets.unshift(unsetShadow); 56186 } 56187 return shadowPresets; 56188 }, [settings2]); 56189 } 56190 56191 // packages/block-editor/build-module/components/global-styles/border-panel.js 56192 var import_jsx_runtime362 = __toESM(require_jsx_runtime()); 56193 function useHasBorderPanel(settings2) { 56194 const controls = Object.values(useHasBorderPanelControls(settings2)); 56195 return controls.some(Boolean); 56196 } 56197 function useHasBorderPanelControls(settings2) { 56198 const controls = { 56199 hasBorderColor: useHasBorderColorControl(settings2), 56200 hasBorderRadius: useHasBorderRadiusControl(settings2), 56201 hasBorderStyle: useHasBorderStyleControl(settings2), 56202 hasBorderWidth: useHasBorderWidthControl(settings2), 56203 hasShadow: useHasShadowControl(settings2) 56204 }; 56205 return controls; 56206 } 56207 function useHasBorderColorControl(settings2) { 56208 return settings2?.border?.color; 56209 } 56210 function useHasBorderRadiusControl(settings2) { 56211 return settings2?.border?.radius; 56212 } 56213 function useHasBorderStyleControl(settings2) { 56214 return settings2?.border?.style; 56215 } 56216 function useHasBorderWidthControl(settings2) { 56217 return settings2?.border?.width; 56218 } 56219 function useHasShadowControl(settings2) { 56220 const shadows = useShadowPresets(settings2); 56221 return !!settings2?.shadow && shadows.length > 0; 56222 } 56223 function BorderToolsPanel({ 56224 resetAllFilter, 56225 onChange, 56226 value, 56227 panelId, 56228 children, 56229 label 56230 }) { 56231 const dropdownMenuProps = useToolsPanelDropdownMenuProps(); 56232 const resetAll = () => { 56233 const updatedValue = resetAllFilter(value); 56234 onChange(updatedValue); 56235 }; 56236 return /* @__PURE__ */ (0, import_jsx_runtime362.jsx)( 56237 import_components198.__experimentalToolsPanel, 56238 { 56239 label, 56240 resetAll, 56241 panelId, 56242 dropdownMenuProps, 56243 children 56244 } 56245 ); 56246 } 56247 var DEFAULT_CONTROLS5 = { 56248 radius: true, 56249 color: true, 56250 width: true, 56251 shadow: true 56252 }; 56253 function BorderPanel({ 56254 as: Wrapper = BorderToolsPanel, 56255 value, 56256 onChange, 56257 inheritedValue = value, 56258 settings: settings2, 56259 panelId, 56260 name, 56261 defaultControls = DEFAULT_CONTROLS5 56262 }) { 56263 const colors2 = useColorsPerOrigin(settings2); 56264 const decodeValue = (0, import_element201.useCallback)( 56265 (rawValue) => getValueFromVariable({ settings: settings2 }, "", rawValue), 56266 [settings2] 56267 ); 56268 const encodeColorValue = (colorValue) => { 56269 const allColors = colors2.flatMap( 56270 ({ colors: originColors }) => originColors 56271 ); 56272 const colorObject = allColors.find( 56273 ({ color }) => color === colorValue 56274 ); 56275 return colorObject ? "var:preset|color|" + colorObject.slug : colorValue; 56276 }; 56277 const border = (0, import_element201.useMemo)(() => { 56278 if ((0, import_components198.__experimentalHasSplitBorders)(inheritedValue?.border)) { 56279 const borderValue = { ...inheritedValue?.border }; 56280 ["top", "right", "bottom", "left"].forEach((side) => { 56281 borderValue[side] = { 56282 ...borderValue[side], 56283 color: decodeValue(borderValue[side]?.color) 56284 }; 56285 }); 56286 return borderValue; 56287 } 56288 return { 56289 ...inheritedValue?.border, 56290 color: inheritedValue?.border?.color ? decodeValue(inheritedValue?.border?.color) : void 0 56291 }; 56292 }, [inheritedValue?.border, decodeValue]); 56293 const setBorder = (newBorder) => onChange({ ...value, border: newBorder }); 56294 const showBorderColor = useHasBorderColorControl(settings2); 56295 const showBorderStyle = useHasBorderStyleControl(settings2); 56296 const showBorderWidth = useHasBorderWidthControl(settings2); 56297 const showBorderRadius = useHasBorderRadiusControl(settings2); 56298 const borderRadiusValues = (0, import_element201.useMemo)(() => { 56299 if (typeof inheritedValue?.border?.radius !== "object") { 56300 return decodeValue(inheritedValue?.border?.radius); 56301 } 56302 return { 56303 topLeft: decodeValue(inheritedValue?.border?.radius?.topLeft), 56304 topRight: decodeValue(inheritedValue?.border?.radius?.topRight), 56305 bottomLeft: decodeValue( 56306 inheritedValue?.border?.radius?.bottomLeft 56307 ), 56308 bottomRight: decodeValue( 56309 inheritedValue?.border?.radius?.bottomRight 56310 ) 56311 }; 56312 }, [inheritedValue?.border?.radius, decodeValue]); 56313 const setBorderRadius = (newBorderRadius) => setBorder({ ...border, radius: newBorderRadius }); 56314 const hasBorderRadius = () => { 56315 const borderValues = value?.border?.radius; 56316 if (typeof borderValues === "object") { 56317 return Object.entries(borderValues).some(Boolean); 56318 } 56319 return !!borderValues; 56320 }; 56321 const hasShadowControl = useHasShadowControl(settings2); 56322 const shadow = decodeValue(inheritedValue?.shadow); 56323 const shadowPresets = settings2?.shadow?.presets ?? {}; 56324 const mergedShadowPresets = shadowPresets.custom ?? shadowPresets.theme ?? shadowPresets.default ?? []; 56325 const setShadow = (newValue) => { 56326 const slug = mergedShadowPresets?.find( 56327 ({ shadow: shadowName }) => shadowName === newValue 56328 )?.slug; 56329 onChange( 56330 setImmutably( 56331 value, 56332 ["shadow"], 56333 slug ? `var:preset|shadow|$slug}` : newValue || void 0 56334 ) 56335 ); 56336 }; 56337 const hasShadow = () => !!value?.shadow; 56338 const resetShadow = () => setShadow(void 0); 56339 const resetBorder = () => { 56340 if (hasBorderRadius()) { 56341 return setBorder({ radius: value?.border?.radius }); 56342 } 56343 setBorder(void 0); 56344 }; 56345 const onBorderChange = (newBorder) => { 56346 const updatedBorder = { ...newBorder }; 56347 if ((0, import_components198.__experimentalHasSplitBorders)(updatedBorder)) { 56348 ["top", "right", "bottom", "left"].forEach((side) => { 56349 if (updatedBorder[side]) { 56350 updatedBorder[side] = { 56351 ...updatedBorder[side], 56352 color: encodeColorValue(updatedBorder[side]?.color) 56353 }; 56354 } 56355 }); 56356 } else if (updatedBorder) { 56357 updatedBorder.color = encodeColorValue(updatedBorder.color); 56358 } 56359 setBorder({ radius: border?.radius, ...updatedBorder }); 56360 }; 56361 const resetAllFilter = (0, import_element201.useCallback)((previousValue) => { 56362 return { 56363 ...previousValue, 56364 border: void 0, 56365 shadow: void 0 56366 }; 56367 }, []); 56368 const showBorderByDefault = defaultControls?.color || defaultControls?.width; 56369 const hasBorderControl = showBorderColor || showBorderStyle || showBorderWidth || showBorderRadius; 56370 const label = useBorderPanelLabel({ 56371 blockName: name, 56372 hasShadowControl, 56373 hasBorderControl 56374 }); 56375 return /* @__PURE__ */ (0, import_jsx_runtime362.jsxs)( 56376 Wrapper, 56377 { 56378 resetAllFilter, 56379 value, 56380 onChange, 56381 panelId, 56382 label, 56383 children: [ 56384 (showBorderWidth || showBorderColor) && /* @__PURE__ */ (0, import_jsx_runtime362.jsx)( 56385 import_components198.__experimentalToolsPanelItem, 56386 { 56387 hasValue: () => (0, import_components198.__experimentalIsDefinedBorder)(value?.border), 56388 label: (0, import_i18n188.__)("Border"), 56389 onDeselect: () => resetBorder(), 56390 isShownByDefault: showBorderByDefault, 56391 panelId, 56392 children: /* @__PURE__ */ (0, import_jsx_runtime362.jsx)( 56393 import_components198.BorderBoxControl, 56394 { 56395 colors: colors2, 56396 enableAlpha: true, 56397 enableStyle: showBorderStyle, 56398 onChange: onBorderChange, 56399 popoverOffset: 40, 56400 popoverPlacement: "left-start", 56401 value: border, 56402 __experimentalIsRenderedInSidebar: true, 56403 size: "__unstable-large", 56404 hideLabelFromVision: !hasShadowControl, 56405 label: (0, import_i18n188.__)("Border") 56406 } 56407 ) 56408 } 56409 ), 56410 showBorderRadius && /* @__PURE__ */ (0, import_jsx_runtime362.jsx)( 56411 import_components198.__experimentalToolsPanelItem, 56412 { 56413 hasValue: hasBorderRadius, 56414 label: (0, import_i18n188.__)("Radius"), 56415 onDeselect: () => setBorderRadius(void 0), 56416 isShownByDefault: defaultControls.radius, 56417 panelId, 56418 children: /* @__PURE__ */ (0, import_jsx_runtime362.jsx)( 56419 BorderRadiusControl, 56420 { 56421 presets: settings2?.border?.radiusSizes, 56422 values: borderRadiusValues, 56423 onChange: (newValue) => { 56424 setBorderRadius(newValue || void 0); 56425 } 56426 } 56427 ) 56428 } 56429 ), 56430 hasShadowControl && /* @__PURE__ */ (0, import_jsx_runtime362.jsxs)( 56431 import_components198.__experimentalToolsPanelItem, 56432 { 56433 label: (0, import_i18n188.__)("Shadow"), 56434 hasValue: hasShadow, 56435 onDeselect: resetShadow, 56436 isShownByDefault: defaultControls.shadow, 56437 panelId, 56438 children: [ 56439 hasBorderControl ? /* @__PURE__ */ (0, import_jsx_runtime362.jsx)(import_components198.BaseControl.VisualLabel, { as: "legend", children: (0, import_i18n188.__)("Shadow") }) : null, 56440 /* @__PURE__ */ (0, import_jsx_runtime362.jsx)( 56441 ShadowPopover, 56442 { 56443 shadow, 56444 onShadowChange: setShadow, 56445 settings: settings2 56446 } 56447 ) 56448 ] 56449 } 56450 ) 56451 ] 56452 } 56453 ); 56454 } 56455 56456 // packages/block-editor/build-module/components/global-styles/color-panel.js 56457 var import_components199 = __toESM(require_components()); 56458 var import_element202 = __toESM(require_element()); 56459 var import_i18n189 = __toESM(require_i18n()); 56460 var import_jsx_runtime363 = __toESM(require_jsx_runtime()); 56461 function useHasColorPanel(settings2) { 56462 const hasTextPanel = useHasTextPanel(settings2); 56463 const hasBackgroundPanel = useHasBackgroundColorPanel(settings2); 56464 const hasLinkPanel = useHasLinkPanel(settings2); 56465 const hasHeadingPanel = useHasHeadingPanel(settings2); 56466 const hasButtonPanel = useHasButtonPanel(settings2); 56467 const hasCaptionPanel = useHasCaptionPanel(settings2); 56468 return hasTextPanel || hasBackgroundPanel || hasLinkPanel || hasHeadingPanel || hasButtonPanel || hasCaptionPanel; 56469 } 56470 function useHasTextPanel(settings2) { 56471 const colors2 = useColorsPerOrigin(settings2); 56472 return settings2?.color?.text && (colors2?.length > 0 || settings2?.color?.custom); 56473 } 56474 function useHasLinkPanel(settings2) { 56475 const colors2 = useColorsPerOrigin(settings2); 56476 return settings2?.color?.link && (colors2?.length > 0 || settings2?.color?.custom); 56477 } 56478 function useHasCaptionPanel(settings2) { 56479 const colors2 = useColorsPerOrigin(settings2); 56480 return settings2?.color?.caption && (colors2?.length > 0 || settings2?.color?.custom); 56481 } 56482 function useHasHeadingPanel(settings2) { 56483 const colors2 = useColorsPerOrigin(settings2); 56484 const gradients = useGradientsPerOrigin(settings2); 56485 return settings2?.color?.heading && (colors2?.length > 0 || settings2?.color?.custom || gradients?.length > 0 || settings2?.color?.customGradient); 56486 } 56487 function useHasButtonPanel(settings2) { 56488 const colors2 = useColorsPerOrigin(settings2); 56489 const gradients = useGradientsPerOrigin(settings2); 56490 return settings2?.color?.button && (colors2?.length > 0 || settings2?.color?.custom || gradients?.length > 0 || settings2?.color?.customGradient); 56491 } 56492 function useHasBackgroundColorPanel(settings2) { 56493 const colors2 = useColorsPerOrigin(settings2); 56494 const gradients = useGradientsPerOrigin(settings2); 56495 return settings2?.color?.background && (colors2?.length > 0 || settings2?.color?.custom || gradients?.length > 0 || settings2?.color?.customGradient); 56496 } 56497 function ColorToolsPanel({ 56498 resetAllFilter, 56499 onChange, 56500 value, 56501 panelId, 56502 children, 56503 label 56504 }) { 56505 const dropdownMenuProps = useToolsPanelDropdownMenuProps(); 56506 const resetAll = () => { 56507 const updatedValue = resetAllFilter(value); 56508 onChange(updatedValue); 56509 }; 56510 return /* @__PURE__ */ (0, import_jsx_runtime363.jsx)( 56511 import_components199.__experimentalToolsPanel, 56512 { 56513 label: label || (0, import_i18n189.__)("Elements"), 56514 resetAll, 56515 panelId, 56516 hasInnerWrapper: true, 56517 headingLevel: 3, 56518 className: "color-block-support-panel", 56519 __experimentalFirstVisibleItemClass: "first", 56520 __experimentalLastVisibleItemClass: "last", 56521 dropdownMenuProps, 56522 children: /* @__PURE__ */ (0, import_jsx_runtime363.jsx)("div", { className: "color-block-support-panel__inner-wrapper", children }) 56523 } 56524 ); 56525 } 56526 var DEFAULT_CONTROLS6 = { 56527 text: true, 56528 background: true, 56529 link: true, 56530 heading: true, 56531 button: true, 56532 caption: true 56533 }; 56534 var popoverProps = { 56535 placement: "left-start", 56536 offset: 36, 56537 shift: true 56538 }; 56539 var { Tabs: Tabs4 } = unlock(import_components199.privateApis); 56540 var LabeledColorIndicators = ({ indicators, label }) => /* @__PURE__ */ (0, import_jsx_runtime363.jsxs)(import_components199.__experimentalHStack, { justify: "flex-start", children: [ 56541 /* @__PURE__ */ (0, import_jsx_runtime363.jsx)(import_components199.__experimentalZStack, { isLayered: false, offset: -8, children: indicators.map((indicator, index) => /* @__PURE__ */ (0, import_jsx_runtime363.jsx)(import_components199.Flex, { expanded: false, children: /* @__PURE__ */ (0, import_jsx_runtime363.jsx)(import_components199.ColorIndicator, { colorValue: indicator }) }, index)) }), 56542 /* @__PURE__ */ (0, import_jsx_runtime363.jsx)(import_components199.FlexItem, { className: "block-editor-panel-color-gradient-settings__color-name", children: label }) 56543 ] }); 56544 function ColorPanelTab({ 56545 isGradient, 56546 inheritedValue, 56547 userValue, 56548 setValue, 56549 colorGradientControlSettings 56550 }) { 56551 return /* @__PURE__ */ (0, import_jsx_runtime363.jsx)( 56552 control_default, 56553 { 56554 ...colorGradientControlSettings, 56555 showTitle: false, 56556 enableAlpha: true, 56557 __experimentalIsRenderedInSidebar: true, 56558 colorValue: isGradient ? void 0 : inheritedValue, 56559 gradientValue: isGradient ? inheritedValue : void 0, 56560 onColorChange: isGradient ? void 0 : setValue, 56561 onGradientChange: isGradient ? setValue : void 0, 56562 clearable: inheritedValue === userValue, 56563 headingLevel: 3 56564 } 56565 ); 56566 } 56567 function ColorPanelDropdown({ 56568 label, 56569 hasValue, 56570 resetValue, 56571 isShownByDefault, 56572 indicators, 56573 tabs, 56574 colorGradientControlSettings, 56575 panelId 56576 }) { 56577 const currentTab = tabs.find((tab) => tab.userValue !== void 0); 56578 const { key: firstTabKey, ...firstTab } = tabs[0] ?? {}; 56579 const colorGradientDropdownButtonRef = (0, import_element202.useRef)(void 0); 56580 return /* @__PURE__ */ (0, import_jsx_runtime363.jsx)( 56581 import_components199.__experimentalToolsPanelItem, 56582 { 56583 className: "block-editor-tools-panel-color-gradient-settings__item", 56584 hasValue, 56585 label, 56586 onDeselect: resetValue, 56587 isShownByDefault, 56588 panelId, 56589 children: /* @__PURE__ */ (0, import_jsx_runtime363.jsx)( 56590 import_components199.Dropdown, 56591 { 56592 popoverProps, 56593 className: "block-editor-tools-panel-color-gradient-settings__dropdown", 56594 renderToggle: ({ onToggle, isOpen }) => { 56595 const toggleProps = { 56596 onClick: onToggle, 56597 className: clsx_default( 56598 "block-editor-panel-color-gradient-settings__dropdown", 56599 { "is-open": isOpen } 56600 ), 56601 "aria-expanded": isOpen, 56602 ref: colorGradientDropdownButtonRef 56603 }; 56604 return /* @__PURE__ */ (0, import_jsx_runtime363.jsxs)(import_jsx_runtime363.Fragment, { children: [ 56605 /* @__PURE__ */ (0, import_jsx_runtime363.jsx)(import_components199.Button, { ...toggleProps, __next40pxDefaultSize: true, children: /* @__PURE__ */ (0, import_jsx_runtime363.jsx)( 56606 LabeledColorIndicators, 56607 { 56608 indicators, 56609 label 56610 } 56611 ) }), 56612 hasValue() && /* @__PURE__ */ (0, import_jsx_runtime363.jsx)( 56613 import_components199.Button, 56614 { 56615 __next40pxDefaultSize: true, 56616 label: (0, import_i18n189.__)("Reset"), 56617 className: "block-editor-panel-color-gradient-settings__reset", 56618 size: "small", 56619 icon: reset_default, 56620 onClick: () => { 56621 resetValue(); 56622 if (isOpen) { 56623 onToggle(); 56624 } 56625 colorGradientDropdownButtonRef.current?.focus(); 56626 } 56627 } 56628 ) 56629 ] }); 56630 }, 56631 renderContent: () => /* @__PURE__ */ (0, import_jsx_runtime363.jsx)(import_components199.__experimentalDropdownContentWrapper, { paddingSize: "none", children: /* @__PURE__ */ (0, import_jsx_runtime363.jsxs)("div", { className: "block-editor-panel-color-gradient-settings__dropdown-content", children: [ 56632 tabs.length === 1 && /* @__PURE__ */ (0, import_jsx_runtime363.jsx)( 56633 ColorPanelTab, 56634 { 56635 ...firstTab, 56636 colorGradientControlSettings 56637 }, 56638 firstTabKey 56639 ), 56640 tabs.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime363.jsxs)(Tabs4, { defaultTabId: currentTab?.key, children: [ 56641 /* @__PURE__ */ (0, import_jsx_runtime363.jsx)(Tabs4.TabList, { children: tabs.map((tab) => /* @__PURE__ */ (0, import_jsx_runtime363.jsx)( 56642 Tabs4.Tab, 56643 { 56644 tabId: tab.key, 56645 children: tab.label 56646 }, 56647 tab.key 56648 )) }), 56649 tabs.map((tab) => { 56650 const { key: tabKey, ...restTabProps } = tab; 56651 return /* @__PURE__ */ (0, import_jsx_runtime363.jsx)( 56652 Tabs4.TabPanel, 56653 { 56654 tabId: tabKey, 56655 focusable: false, 56656 children: /* @__PURE__ */ (0, import_jsx_runtime363.jsx)( 56657 ColorPanelTab, 56658 { 56659 ...restTabProps, 56660 colorGradientControlSettings 56661 }, 56662 tabKey 56663 ) 56664 }, 56665 tabKey 56666 ); 56667 }) 56668 ] }) 56669 ] }) }) 56670 } 56671 ) 56672 } 56673 ); 56674 } 56675 function ColorPanel({ 56676 as: Wrapper = ColorToolsPanel, 56677 value, 56678 onChange, 56679 inheritedValue = value, 56680 settings: settings2, 56681 panelId, 56682 defaultControls = DEFAULT_CONTROLS6, 56683 label, 56684 children 56685 }) { 56686 const colors2 = useColorsPerOrigin(settings2); 56687 const gradients = useGradientsPerOrigin(settings2); 56688 const areCustomSolidsEnabled = settings2?.color?.custom; 56689 const areCustomGradientsEnabled = settings2?.color?.customGradient; 56690 const hasSolidColors = colors2.length > 0 || areCustomSolidsEnabled; 56691 const hasGradientColors = gradients.length > 0 || areCustomGradientsEnabled; 56692 const decodeValue = (rawValue) => getValueFromVariable({ settings: settings2 }, "", rawValue); 56693 const encodeColorValue = (colorValue) => { 56694 const allColors = colors2.flatMap( 56695 ({ colors: originColors }) => originColors 56696 ); 56697 const colorObject = allColors.find( 56698 ({ color }) => color === colorValue 56699 ); 56700 return colorObject ? "var:preset|color|" + colorObject.slug : colorValue; 56701 }; 56702 const encodeGradientValue = (gradientValue) => { 56703 const allGradients = gradients.flatMap( 56704 ({ gradients: originGradients }) => originGradients 56705 ); 56706 const gradientObject = allGradients.find( 56707 ({ gradient: gradient2 }) => gradient2 === gradientValue 56708 ); 56709 return gradientObject ? "var:preset|gradient|" + gradientObject.slug : gradientValue; 56710 }; 56711 const showBackgroundPanel = useHasBackgroundColorPanel(settings2); 56712 const backgroundColor = decodeValue(inheritedValue?.color?.background); 56713 const userBackgroundColor = decodeValue(value?.color?.background); 56714 const gradient = decodeValue(inheritedValue?.color?.gradient); 56715 const userGradient = decodeValue(value?.color?.gradient); 56716 const hasBackground = () => !!userBackgroundColor || !!userGradient; 56717 const setBackgroundColor = (newColor) => { 56718 const newValue = setImmutably( 56719 value, 56720 ["color", "background"], 56721 encodeColorValue(newColor) 56722 ); 56723 newValue.color.gradient = void 0; 56724 onChange(newValue); 56725 }; 56726 const setGradient = (newGradient) => { 56727 const newValue = setImmutably( 56728 value, 56729 ["color", "gradient"], 56730 encodeGradientValue(newGradient) 56731 ); 56732 newValue.color.background = void 0; 56733 onChange(newValue); 56734 }; 56735 const resetBackground = () => { 56736 const newValue = setImmutably( 56737 value, 56738 ["color", "background"], 56739 void 0 56740 ); 56741 newValue.color.gradient = void 0; 56742 onChange(newValue); 56743 }; 56744 const showLinkPanel = useHasLinkPanel(settings2); 56745 const linkColor = decodeValue( 56746 inheritedValue?.elements?.link?.color?.text 56747 ); 56748 const userLinkColor = decodeValue(value?.elements?.link?.color?.text); 56749 const setLinkColor = (newColor) => { 56750 onChange( 56751 setImmutably( 56752 value, 56753 ["elements", "link", "color", "text"], 56754 encodeColorValue(newColor) 56755 ) 56756 ); 56757 }; 56758 const hoverLinkColor = decodeValue( 56759 inheritedValue?.elements?.link?.[":hover"]?.color?.text 56760 ); 56761 const userHoverLinkColor = decodeValue( 56762 value?.elements?.link?.[":hover"]?.color?.text 56763 ); 56764 const setHoverLinkColor = (newColor) => { 56765 onChange( 56766 setImmutably( 56767 value, 56768 ["elements", "link", ":hover", "color", "text"], 56769 encodeColorValue(newColor) 56770 ) 56771 ); 56772 }; 56773 const hasLink = () => !!userLinkColor || !!userHoverLinkColor; 56774 const resetLink = () => { 56775 let newValue = setImmutably( 56776 value, 56777 ["elements", "link", ":hover", "color", "text"], 56778 void 0 56779 ); 56780 newValue = setImmutably( 56781 newValue, 56782 ["elements", "link", "color", "text"], 56783 void 0 56784 ); 56785 onChange(newValue); 56786 }; 56787 const showTextPanel = useHasTextPanel(settings2); 56788 const textColor = decodeValue(inheritedValue?.color?.text); 56789 const userTextColor = decodeValue(value?.color?.text); 56790 const hasTextColor = () => !!userTextColor; 56791 const setTextColor = (newColor) => { 56792 let changedObject = setImmutably( 56793 value, 56794 ["color", "text"], 56795 encodeColorValue(newColor) 56796 ); 56797 if (textColor === linkColor) { 56798 changedObject = setImmutably( 56799 changedObject, 56800 ["elements", "link", "color", "text"], 56801 encodeColorValue(newColor) 56802 ); 56803 } 56804 onChange(changedObject); 56805 }; 56806 const resetTextColor = () => setTextColor(void 0); 56807 const elements = [ 56808 { 56809 name: "caption", 56810 label: (0, import_i18n189.__)("Captions"), 56811 showPanel: useHasCaptionPanel(settings2) 56812 }, 56813 { 56814 name: "button", 56815 label: (0, import_i18n189.__)("Button"), 56816 showPanel: useHasButtonPanel(settings2) 56817 }, 56818 { 56819 name: "heading", 56820 label: (0, import_i18n189.__)("Heading"), 56821 showPanel: useHasHeadingPanel(settings2) 56822 }, 56823 { 56824 name: "h1", 56825 label: (0, import_i18n189.__)("H1"), 56826 showPanel: useHasHeadingPanel(settings2) 56827 }, 56828 { 56829 name: "h2", 56830 label: (0, import_i18n189.__)("H2"), 56831 showPanel: useHasHeadingPanel(settings2) 56832 }, 56833 { 56834 name: "h3", 56835 label: (0, import_i18n189.__)("H3"), 56836 showPanel: useHasHeadingPanel(settings2) 56837 }, 56838 { 56839 name: "h4", 56840 label: (0, import_i18n189.__)("H4"), 56841 showPanel: useHasHeadingPanel(settings2) 56842 }, 56843 { 56844 name: "h5", 56845 label: (0, import_i18n189.__)("H5"), 56846 showPanel: useHasHeadingPanel(settings2) 56847 }, 56848 { 56849 name: "h6", 56850 label: (0, import_i18n189.__)("H6"), 56851 showPanel: useHasHeadingPanel(settings2) 56852 } 56853 ]; 56854 const resetAllFilter = (0, import_element202.useCallback)( 56855 (previousValue) => { 56856 return { 56857 ...previousValue, 56858 color: void 0, 56859 elements: { 56860 ...previousValue?.elements, 56861 link: { 56862 ...previousValue?.elements?.link, 56863 color: void 0, 56864 ":hover": { 56865 color: void 0 56866 } 56867 }, 56868 ...elements.reduce((acc, element) => { 56869 return { 56870 ...acc, 56871 [element.name]: { 56872 ...previousValue?.elements?.[element.name], 56873 color: void 0 56874 } 56875 }; 56876 }, {}) 56877 } 56878 }; 56879 }, 56880 [elements] 56881 ); 56882 const items = [ 56883 showTextPanel && { 56884 key: "text", 56885 label: (0, import_i18n189.__)("Text"), 56886 hasValue: hasTextColor, 56887 resetValue: resetTextColor, 56888 isShownByDefault: defaultControls.text, 56889 indicators: [textColor], 56890 tabs: [ 56891 { 56892 key: "text", 56893 label: (0, import_i18n189.__)("Text"), 56894 inheritedValue: textColor, 56895 setValue: setTextColor, 56896 userValue: userTextColor 56897 } 56898 ] 56899 }, 56900 showBackgroundPanel && { 56901 key: "background", 56902 label: (0, import_i18n189.__)("Background"), 56903 hasValue: hasBackground, 56904 resetValue: resetBackground, 56905 isShownByDefault: defaultControls.background, 56906 indicators: [gradient ?? backgroundColor], 56907 tabs: [ 56908 hasSolidColors && { 56909 key: "background", 56910 label: (0, import_i18n189.__)("Color"), 56911 inheritedValue: backgroundColor, 56912 setValue: setBackgroundColor, 56913 userValue: userBackgroundColor 56914 }, 56915 hasGradientColors && { 56916 key: "gradient", 56917 label: (0, import_i18n189.__)("Gradient"), 56918 inheritedValue: gradient, 56919 setValue: setGradient, 56920 userValue: userGradient, 56921 isGradient: true 56922 } 56923 ].filter(Boolean) 56924 }, 56925 showLinkPanel && { 56926 key: "link", 56927 label: (0, import_i18n189.__)("Link"), 56928 hasValue: hasLink, 56929 resetValue: resetLink, 56930 isShownByDefault: defaultControls.link, 56931 indicators: [linkColor, hoverLinkColor], 56932 tabs: [ 56933 { 56934 key: "link", 56935 label: (0, import_i18n189.__)("Default"), 56936 inheritedValue: linkColor, 56937 setValue: setLinkColor, 56938 userValue: userLinkColor 56939 }, 56940 { 56941 key: "hover", 56942 label: (0, import_i18n189.__)("Hover"), 56943 inheritedValue: hoverLinkColor, 56944 setValue: setHoverLinkColor, 56945 userValue: userHoverLinkColor 56946 } 56947 ] 56948 } 56949 ].filter(Boolean); 56950 elements.forEach(({ name, label: elementLabel, showPanel }) => { 56951 if (!showPanel) { 56952 return; 56953 } 56954 const elementBackgroundColor = decodeValue( 56955 inheritedValue?.elements?.[name]?.color?.background 56956 ); 56957 const elementGradient = decodeValue( 56958 inheritedValue?.elements?.[name]?.color?.gradient 56959 ); 56960 const elementTextColor = decodeValue( 56961 inheritedValue?.elements?.[name]?.color?.text 56962 ); 56963 const elementBackgroundUserColor = decodeValue( 56964 value?.elements?.[name]?.color?.background 56965 ); 56966 const elementGradientUserColor = decodeValue( 56967 value?.elements?.[name]?.color?.gradient 56968 ); 56969 const elementTextUserColor = decodeValue( 56970 value?.elements?.[name]?.color?.text 56971 ); 56972 const hasElement = () => !!(elementTextUserColor || elementBackgroundUserColor || elementGradientUserColor); 56973 const resetElement = () => { 56974 const newValue = setImmutably( 56975 value, 56976 ["elements", name, "color", "background"], 56977 void 0 56978 ); 56979 newValue.elements[name].color.gradient = void 0; 56980 newValue.elements[name].color.text = void 0; 56981 onChange(newValue); 56982 }; 56983 const setElementTextColor = (newTextColor) => { 56984 onChange( 56985 setImmutably( 56986 value, 56987 ["elements", name, "color", "text"], 56988 encodeColorValue(newTextColor) 56989 ) 56990 ); 56991 }; 56992 const setElementBackgroundColor = (newBackgroundColor) => { 56993 const newValue = setImmutably( 56994 value, 56995 ["elements", name, "color", "background"], 56996 encodeColorValue(newBackgroundColor) 56997 ); 56998 newValue.elements[name].color.gradient = void 0; 56999 onChange(newValue); 57000 }; 57001 const setElementGradient = (newGradient) => { 57002 const newValue = setImmutably( 57003 value, 57004 ["elements", name, "color", "gradient"], 57005 encodeGradientValue(newGradient) 57006 ); 57007 newValue.elements[name].color.background = void 0; 57008 onChange(newValue); 57009 }; 57010 const supportsTextColor = true; 57011 const supportsBackground = name !== "caption"; 57012 items.push({ 57013 key: name, 57014 label: elementLabel, 57015 hasValue: hasElement, 57016 resetValue: resetElement, 57017 isShownByDefault: defaultControls[name], 57018 indicators: supportsTextColor && supportsBackground ? [ 57019 elementTextColor, 57020 elementGradient ?? elementBackgroundColor 57021 ] : [ 57022 supportsTextColor ? elementTextColor : elementGradient ?? elementBackgroundColor 57023 ], 57024 tabs: [ 57025 hasSolidColors && supportsTextColor && { 57026 key: "text", 57027 label: (0, import_i18n189.__)("Text"), 57028 inheritedValue: elementTextColor, 57029 setValue: setElementTextColor, 57030 userValue: elementTextUserColor 57031 }, 57032 hasSolidColors && supportsBackground && { 57033 key: "background", 57034 label: (0, import_i18n189.__)("Background"), 57035 inheritedValue: elementBackgroundColor, 57036 setValue: setElementBackgroundColor, 57037 userValue: elementBackgroundUserColor 57038 }, 57039 hasGradientColors && supportsBackground && { 57040 key: "gradient", 57041 label: (0, import_i18n189.__)("Gradient"), 57042 inheritedValue: elementGradient, 57043 setValue: setElementGradient, 57044 userValue: elementGradientUserColor, 57045 isGradient: true 57046 } 57047 ].filter(Boolean) 57048 }); 57049 }); 57050 return /* @__PURE__ */ (0, import_jsx_runtime363.jsxs)( 57051 Wrapper, 57052 { 57053 resetAllFilter, 57054 value, 57055 onChange, 57056 panelId, 57057 label, 57058 children: [ 57059 items.map((item) => { 57060 const { key, ...restItem } = item; 57061 return /* @__PURE__ */ (0, import_jsx_runtime363.jsx)( 57062 ColorPanelDropdown, 57063 { 57064 ...restItem, 57065 colorGradientControlSettings: { 57066 colors: colors2, 57067 disableCustomColors: !areCustomSolidsEnabled, 57068 gradients, 57069 disableCustomGradients: !areCustomGradientsEnabled 57070 }, 57071 panelId 57072 }, 57073 key 57074 ); 57075 }), 57076 children 57077 ] 57078 } 57079 ); 57080 } 57081 57082 // packages/block-editor/build-module/components/global-styles/filters-panel.js 57083 var import_components200 = __toESM(require_components()); 57084 var import_i18n190 = __toESM(require_i18n()); 57085 var import_element203 = __toESM(require_element()); 57086 var import_jsx_runtime364 = __toESM(require_jsx_runtime()); 57087 var EMPTY_ARRAY13 = []; 57088 function useMultiOriginColorPresets(settings2, { presetSetting, defaultSetting }) { 57089 const disableDefault = !settings2?.color?.[defaultSetting]; 57090 const userPresets = settings2?.color?.[presetSetting]?.custom || EMPTY_ARRAY13; 57091 const themePresets = settings2?.color?.[presetSetting]?.theme || EMPTY_ARRAY13; 57092 const defaultPresets = settings2?.color?.[presetSetting]?.default || EMPTY_ARRAY13; 57093 return (0, import_element203.useMemo)( 57094 () => [ 57095 ...userPresets, 57096 ...themePresets, 57097 ...disableDefault ? EMPTY_ARRAY13 : defaultPresets 57098 ], 57099 [disableDefault, userPresets, themePresets, defaultPresets] 57100 ); 57101 } 57102 function useHasFiltersPanel(settings2) { 57103 return useHasDuotoneControl(settings2); 57104 } 57105 function useHasDuotoneControl(settings2) { 57106 return settings2.color.customDuotone || settings2.color.defaultDuotone || settings2.color.duotone.length > 0; 57107 } 57108 function FiltersToolsPanel({ 57109 resetAllFilter, 57110 onChange, 57111 value, 57112 panelId, 57113 children 57114 }) { 57115 const dropdownMenuProps = useToolsPanelDropdownMenuProps(); 57116 const resetAll = () => { 57117 const updatedValue = resetAllFilter(value); 57118 onChange(updatedValue); 57119 }; 57120 return /* @__PURE__ */ (0, import_jsx_runtime364.jsx)( 57121 import_components200.__experimentalToolsPanel, 57122 { 57123 label: (0, import_i18n190._x)("Filters", "Name for applying graphical effects"), 57124 resetAll, 57125 panelId, 57126 dropdownMenuProps, 57127 children 57128 } 57129 ); 57130 } 57131 var DEFAULT_CONTROLS7 = { 57132 duotone: true 57133 }; 57134 var popoverProps2 = { 57135 placement: "left-start", 57136 offset: 36, 57137 shift: true, 57138 className: "block-editor-duotone-control__popover", 57139 headerTitle: (0, import_i18n190.__)("Duotone") 57140 }; 57141 var LabeledColorIndicator2 = ({ indicator, label }) => /* @__PURE__ */ (0, import_jsx_runtime364.jsxs)(import_components200.__experimentalHStack, { justify: "flex-start", children: [ 57142 /* @__PURE__ */ (0, import_jsx_runtime364.jsx)(import_components200.__experimentalZStack, { isLayered: false, offset: -8, children: /* @__PURE__ */ (0, import_jsx_runtime364.jsx)(import_components200.Flex, { expanded: false, children: indicator === "unset" || !indicator ? /* @__PURE__ */ (0, import_jsx_runtime364.jsx)(import_components200.ColorIndicator, { className: "block-editor-duotone-control__unset-indicator" }) : /* @__PURE__ */ (0, import_jsx_runtime364.jsx)(import_components200.DuotoneSwatch, { values: indicator }) }) }), 57143 /* @__PURE__ */ (0, import_jsx_runtime364.jsx)(import_components200.FlexItem, { title: label, children: label }) 57144 ] }); 57145 var renderToggle2 = (duotone, resetDuotone) => ({ onToggle, isOpen }) => { 57146 const duotoneButtonRef = (0, import_element203.useRef)(void 0); 57147 const toggleProps = { 57148 onClick: onToggle, 57149 className: clsx_default( 57150 "block-editor-global-styles-filters-panel__dropdown-toggle", 57151 { "is-open": isOpen } 57152 ), 57153 "aria-expanded": isOpen, 57154 ref: duotoneButtonRef 57155 }; 57156 const removeButtonProps = { 57157 onClick: () => { 57158 if (isOpen) { 57159 onToggle(); 57160 } 57161 resetDuotone(); 57162 duotoneButtonRef.current?.focus(); 57163 }, 57164 className: "block-editor-panel-duotone-settings__reset", 57165 label: (0, import_i18n190.__)("Reset") 57166 }; 57167 return /* @__PURE__ */ (0, import_jsx_runtime364.jsxs)(import_jsx_runtime364.Fragment, { children: [ 57168 /* @__PURE__ */ (0, import_jsx_runtime364.jsx)(import_components200.Button, { __next40pxDefaultSize: true, ...toggleProps, children: /* @__PURE__ */ (0, import_jsx_runtime364.jsx)( 57169 LabeledColorIndicator2, 57170 { 57171 indicator: duotone, 57172 label: (0, import_i18n190.__)("Duotone") 57173 } 57174 ) }), 57175 duotone && /* @__PURE__ */ (0, import_jsx_runtime364.jsx)( 57176 import_components200.Button, 57177 { 57178 size: "small", 57179 icon: reset_default, 57180 ...removeButtonProps 57181 } 57182 ) 57183 ] }); 57184 }; 57185 function FiltersPanel({ 57186 as: Wrapper = FiltersToolsPanel, 57187 value, 57188 onChange, 57189 inheritedValue = value, 57190 settings: settings2, 57191 panelId, 57192 defaultControls = DEFAULT_CONTROLS7 57193 }) { 57194 const decodeValue = (rawValue) => getValueFromVariable({ settings: settings2 }, "", rawValue); 57195 const hasDuotoneEnabled = useHasDuotoneControl(settings2); 57196 const duotonePalette = useMultiOriginColorPresets(settings2, { 57197 presetSetting: "duotone", 57198 defaultSetting: "defaultDuotone" 57199 }); 57200 const colorPalette = useMultiOriginColorPresets(settings2, { 57201 presetSetting: "palette", 57202 defaultSetting: "defaultPalette" 57203 }); 57204 const duotone = decodeValue(inheritedValue?.filter?.duotone); 57205 const setDuotone = (newValue) => { 57206 const duotonePreset = duotonePalette.find(({ colors: colors2 }) => { 57207 return colors2 === newValue; 57208 }); 57209 const duotoneValue = duotonePreset ? `var:preset|duotone|$duotonePreset.slug}` : newValue; 57210 onChange( 57211 setImmutably(value, ["filter", "duotone"], duotoneValue) 57212 ); 57213 }; 57214 const hasDuotone = () => !!value?.filter?.duotone; 57215 const resetDuotone = () => setDuotone(void 0); 57216 const resetAllFilter = (0, import_element203.useCallback)((previousValue) => { 57217 return { 57218 ...previousValue, 57219 filter: { 57220 ...previousValue.filter, 57221 duotone: void 0 57222 } 57223 }; 57224 }, []); 57225 return /* @__PURE__ */ (0, import_jsx_runtime364.jsx)( 57226 Wrapper, 57227 { 57228 resetAllFilter, 57229 value, 57230 onChange, 57231 panelId, 57232 children: hasDuotoneEnabled && /* @__PURE__ */ (0, import_jsx_runtime364.jsx)( 57233 import_components200.__experimentalToolsPanelItem, 57234 { 57235 label: (0, import_i18n190.__)("Duotone"), 57236 hasValue: hasDuotone, 57237 onDeselect: resetDuotone, 57238 isShownByDefault: defaultControls.duotone, 57239 panelId, 57240 children: /* @__PURE__ */ (0, import_jsx_runtime364.jsx)( 57241 import_components200.Dropdown, 57242 { 57243 popoverProps: popoverProps2, 57244 className: "block-editor-global-styles-filters-panel__dropdown", 57245 renderToggle: renderToggle2(duotone, resetDuotone), 57246 renderContent: () => /* @__PURE__ */ (0, import_jsx_runtime364.jsx)(import_components200.__experimentalDropdownContentWrapper, { paddingSize: "small", children: /* @__PURE__ */ (0, import_jsx_runtime364.jsxs)(import_components200.MenuGroup, { label: (0, import_i18n190.__)("Duotone"), children: [ 57247 /* @__PURE__ */ (0, import_jsx_runtime364.jsx)("p", { children: (0, import_i18n190.__)( 57248 "Create a two-tone color effect without losing your original image." 57249 ) }), 57250 /* @__PURE__ */ (0, import_jsx_runtime364.jsx)( 57251 import_components200.DuotonePicker, 57252 { 57253 colorPalette, 57254 duotonePalette, 57255 disableCustomColors: true, 57256 disableCustomDuotone: true, 57257 value: duotone, 57258 onChange: setDuotone 57259 } 57260 ) 57261 ] }) }) 57262 } 57263 ) 57264 } 57265 ) 57266 } 57267 ); 57268 } 57269 57270 // packages/block-editor/build-module/components/global-styles/image-settings-panel.js 57271 var import_components201 = __toESM(require_components()); 57272 var import_i18n191 = __toESM(require_i18n()); 57273 var import_jsx_runtime365 = __toESM(require_jsx_runtime()); 57274 function useHasImageSettingsPanel(name, value, inheritedValue) { 57275 return name === "core/image" && inheritedValue?.lightbox?.allowEditing || !!value?.lightbox; 57276 } 57277 function ImageSettingsPanel({ 57278 onChange, 57279 value, 57280 inheritedValue, 57281 panelId 57282 }) { 57283 const dropdownMenuProps = useToolsPanelDropdownMenuProps(); 57284 const resetLightbox = () => { 57285 onChange(void 0); 57286 }; 57287 const onChangeLightbox = (newSetting) => { 57288 onChange({ 57289 enabled: newSetting 57290 }); 57291 }; 57292 let lightboxChecked = false; 57293 if (inheritedValue?.lightbox?.enabled) { 57294 lightboxChecked = inheritedValue.lightbox.enabled; 57295 } 57296 return /* @__PURE__ */ (0, import_jsx_runtime365.jsx)(import_jsx_runtime365.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime365.jsx)( 57297 import_components201.__experimentalToolsPanel, 57298 { 57299 label: (0, import_i18n191._x)("Settings", "Image settings"), 57300 resetAll: resetLightbox, 57301 panelId, 57302 dropdownMenuProps, 57303 children: /* @__PURE__ */ (0, import_jsx_runtime365.jsx)( 57304 import_components201.__experimentalToolsPanelItem, 57305 { 57306 hasValue: () => !!value?.lightbox, 57307 label: (0, import_i18n191.__)("Enlarge on click"), 57308 onDeselect: resetLightbox, 57309 isShownByDefault: true, 57310 panelId, 57311 children: /* @__PURE__ */ (0, import_jsx_runtime365.jsx)( 57312 import_components201.ToggleControl, 57313 { 57314 label: (0, import_i18n191.__)("Enlarge on click"), 57315 checked: lightboxChecked, 57316 onChange: onChangeLightbox 57317 } 57318 ) 57319 } 57320 ) 57321 } 57322 ) }); 57323 } 57324 57325 // packages/block-editor/build-module/components/global-styles/advanced-panel.js 57326 var import_components202 = __toESM(require_components()); 57327 var import_element204 = __toESM(require_element()); 57328 var import_i18n192 = __toESM(require_i18n()); 57329 var import_jsx_runtime366 = __toESM(require_jsx_runtime()); 57330 function AdvancedPanel({ 57331 value, 57332 onChange, 57333 inheritedValue = value 57334 }) { 57335 const [cssError, setCSSError] = (0, import_element204.useState)(null); 57336 const customCSS = inheritedValue?.css; 57337 function handleOnChange(newValue) { 57338 onChange({ 57339 ...value, 57340 css: newValue 57341 }); 57342 if (cssError) { 57343 const [transformed] = transform_styles_default( 57344 [{ css: newValue }], 57345 ".for-validation-only" 57346 ); 57347 if (transformed) { 57348 setCSSError(null); 57349 } 57350 } 57351 } 57352 function handleOnBlur(event) { 57353 if (!event?.target?.value) { 57354 setCSSError(null); 57355 return; 57356 } 57357 const [transformed] = transform_styles_default( 57358 [{ css: event.target.value }], 57359 ".for-validation-only" 57360 ); 57361 setCSSError( 57362 transformed === null ? (0, import_i18n192.__)("There is an error with your CSS structure.") : null 57363 ); 57364 } 57365 return /* @__PURE__ */ (0, import_jsx_runtime366.jsxs)(import_components202.__experimentalVStack, { spacing: 3, children: [ 57366 cssError && /* @__PURE__ */ (0, import_jsx_runtime366.jsx)(import_components202.Notice, { status: "error", onRemove: () => setCSSError(null), children: cssError }), 57367 /* @__PURE__ */ (0, import_jsx_runtime366.jsx)( 57368 import_components202.TextareaControl, 57369 { 57370 label: (0, import_i18n192.__)("Additional CSS"), 57371 value: customCSS, 57372 onChange: (newValue) => handleOnChange(newValue), 57373 onBlur: handleOnBlur, 57374 className: "block-editor-global-styles-advanced-panel__custom-css-input", 57375 spellCheck: false 57376 } 57377 ) 57378 ] }); 57379 } 57380 57381 // packages/block-editor/build-module/components/global-styles/background-panel.js 57382 var import_components204 = __toESM(require_components()); 57383 var import_element206 = __toESM(require_element()); 57384 57385 // packages/block-editor/build-module/components/background-image-control/index.js 57386 var import_components203 = __toESM(require_components()); 57387 var import_i18n193 = __toESM(require_i18n()); 57388 var import_notices11 = __toESM(require_notices()); 57389 var import_url12 = __toESM(require_url()); 57390 var import_element205 = __toESM(require_element()); 57391 var import_data160 = __toESM(require_data()); 57392 var import_dom38 = __toESM(require_dom()); 57393 var import_blob3 = __toESM(require_blob()); 57394 var import_jsx_runtime367 = __toESM(require_jsx_runtime()); 57395 var IMAGE_BACKGROUND_TYPE = "image"; 57396 var BACKGROUND_POPOVER_PROPS = { 57397 placement: "left-start", 57398 offset: 36, 57399 shift: true, 57400 className: "block-editor-global-styles-background-panel__popover" 57401 }; 57402 var noop18 = () => { 57403 }; 57404 var focusToggleButton = (containerRef) => { 57405 window.requestAnimationFrame(() => { 57406 const [toggleButton] = import_dom38.focus.tabbable.find(containerRef?.current); 57407 if (!toggleButton) { 57408 return; 57409 } 57410 toggleButton.focus(); 57411 }); 57412 }; 57413 function backgroundSizeHelpText(value) { 57414 if (value === "cover" || value === void 0) { 57415 return (0, import_i18n193.__)("Image covers the space evenly."); 57416 } 57417 if (value === "contain") { 57418 return (0, import_i18n193.__)("Image is contained without distortion."); 57419 } 57420 return (0, import_i18n193.__)("Image has a fixed width."); 57421 } 57422 var coordsToBackgroundPosition = (value) => { 57423 if (!value || isNaN(value.x) && isNaN(value.y)) { 57424 return void 0; 57425 } 57426 const x2 = isNaN(value.x) ? 0.5 : value.x; 57427 const y2 = isNaN(value.y) ? 0.5 : value.y; 57428 return `$x2 * 100}% $y2 * 100}%`; 57429 }; 57430 var backgroundPositionToCoords = (value) => { 57431 if (!value) { 57432 return { x: void 0, y: void 0 }; 57433 } 57434 let [x2, y2] = value.split(" ").map((v2) => parseFloat(v2) / 100); 57435 x2 = isNaN(x2) ? void 0 : x2; 57436 y2 = isNaN(y2) ? x2 : y2; 57437 return { x: x2, y: y2 }; 57438 }; 57439 function InspectorImagePreviewItem({ 57440 as = "span", 57441 imgUrl, 57442 toggleProps = {}, 57443 filename, 57444 label, 57445 onToggleCallback = noop18 57446 }) { 57447 const { isOpen, ...restToggleProps } = toggleProps; 57448 (0, import_element205.useEffect)(() => { 57449 if (typeof isOpen !== "undefined") { 57450 onToggleCallback(isOpen); 57451 } 57452 }, [isOpen, onToggleCallback]); 57453 const renderPreviewContent = () => { 57454 return /* @__PURE__ */ (0, import_jsx_runtime367.jsxs)( 57455 import_components203.__experimentalHStack, 57456 { 57457 justify: "flex-start", 57458 as: "span", 57459 className: "block-editor-global-styles-background-panel__inspector-preview-inner", 57460 children: [ 57461 imgUrl && /* @__PURE__ */ (0, import_jsx_runtime367.jsx)( 57462 "span", 57463 { 57464 className: "block-editor-global-styles-background-panel__inspector-image-indicator-wrapper", 57465 "aria-hidden": true, 57466 children: /* @__PURE__ */ (0, import_jsx_runtime367.jsx)( 57467 "span", 57468 { 57469 className: "block-editor-global-styles-background-panel__inspector-image-indicator", 57470 style: { 57471 backgroundImage: `url($imgUrl})` 57472 } 57473 } 57474 ) 57475 } 57476 ), 57477 /* @__PURE__ */ (0, import_jsx_runtime367.jsxs)(import_components203.FlexItem, { as: "span", style: imgUrl ? {} : { flexGrow: 1 }, children: [ 57478 /* @__PURE__ */ (0, import_jsx_runtime367.jsx)( 57479 import_components203.__experimentalTruncate, 57480 { 57481 numberOfLines: 1, 57482 className: "block-editor-global-styles-background-panel__inspector-media-replace-title", 57483 children: label 57484 } 57485 ), 57486 /* @__PURE__ */ (0, import_jsx_runtime367.jsx)(import_components203.VisuallyHidden, { as: "span", children: imgUrl ? (0, import_i18n193.sprintf)( 57487 /* translators: %s: file name */ 57488 (0, import_i18n193.__)("Background image: %s"), 57489 filename || label 57490 ) : (0, import_i18n193.__)("No background image selected") }) 57491 ] }) 57492 ] 57493 } 57494 ); 57495 }; 57496 return as === "button" ? /* @__PURE__ */ (0, import_jsx_runtime367.jsx)(import_components203.Button, { __next40pxDefaultSize: true, ...restToggleProps, children: renderPreviewContent() }) : renderPreviewContent(); 57497 } 57498 function BackgroundControlsPanel({ 57499 label, 57500 filename, 57501 url: imgUrl, 57502 children, 57503 onToggle: onToggleCallback = noop18, 57504 hasImageValue, 57505 onReset, 57506 containerRef 57507 }) { 57508 if (!hasImageValue) { 57509 return; 57510 } 57511 const imgLabel = label || (0, import_url12.getFilename)(imgUrl) || (0, import_i18n193.__)("Add background image"); 57512 return /* @__PURE__ */ (0, import_jsx_runtime367.jsx)( 57513 import_components203.Dropdown, 57514 { 57515 popoverProps: BACKGROUND_POPOVER_PROPS, 57516 renderToggle: ({ onToggle, isOpen }) => { 57517 const toggleProps = { 57518 onClick: onToggle, 57519 className: "block-editor-global-styles-background-panel__dropdown-toggle", 57520 "aria-expanded": isOpen, 57521 "aria-label": (0, import_i18n193.__)( 57522 "Background size, position and repeat options." 57523 ), 57524 isOpen 57525 }; 57526 return /* @__PURE__ */ (0, import_jsx_runtime367.jsxs)(import_jsx_runtime367.Fragment, { children: [ 57527 /* @__PURE__ */ (0, import_jsx_runtime367.jsx)( 57528 InspectorImagePreviewItem, 57529 { 57530 imgUrl, 57531 filename, 57532 label: imgLabel, 57533 toggleProps, 57534 as: "button", 57535 onToggleCallback 57536 } 57537 ), 57538 onReset && /* @__PURE__ */ (0, import_jsx_runtime367.jsx)( 57539 import_components203.Button, 57540 { 57541 __next40pxDefaultSize: true, 57542 label: (0, import_i18n193.__)("Reset"), 57543 className: "block-editor-global-styles-background-panel__reset", 57544 size: "small", 57545 icon: reset_default, 57546 onClick: () => { 57547 onReset(); 57548 if (isOpen) { 57549 onToggle(); 57550 } 57551 focusToggleButton(containerRef); 57552 } 57553 } 57554 ) 57555 ] }); 57556 }, 57557 renderContent: () => /* @__PURE__ */ (0, import_jsx_runtime367.jsx)( 57558 import_components203.__experimentalDropdownContentWrapper, 57559 { 57560 className: "block-editor-global-styles-background-panel__dropdown-content-wrapper", 57561 paddingSize: "medium", 57562 children 57563 } 57564 ) 57565 } 57566 ); 57567 } 57568 function LoadingSpinner() { 57569 return /* @__PURE__ */ (0, import_jsx_runtime367.jsx)(import_components203.Placeholder, { className: "block-editor-global-styles-background-panel__loading", children: /* @__PURE__ */ (0, import_jsx_runtime367.jsx)(import_components203.Spinner, {}) }); 57570 } 57571 function BackgroundImageControls({ 57572 onChange, 57573 style, 57574 inheritedValue, 57575 onRemoveImage = noop18, 57576 onResetImage = noop18, 57577 displayInPanel, 57578 defaultValues, 57579 containerRef 57580 }) { 57581 const [isUploading2, setIsUploading] = (0, import_element205.useState)(false); 57582 const { getSettings: getSettings8 } = (0, import_data160.useSelect)(store); 57583 const { id, title, url } = style?.background?.backgroundImage || { 57584 ...inheritedValue?.background?.backgroundImage 57585 }; 57586 const { createErrorNotice } = (0, import_data160.useDispatch)(import_notices11.store); 57587 const onUploadError = (message2) => { 57588 createErrorNotice(message2, { type: "snackbar" }); 57589 setIsUploading(false); 57590 }; 57591 const resetBackgroundImage = () => onChange( 57592 setImmutably( 57593 style, 57594 ["background", "backgroundImage"], 57595 void 0 57596 ) 57597 ); 57598 const onSelectMedia = (media) => { 57599 if (!media || !media.url) { 57600 resetBackgroundImage(); 57601 setIsUploading(false); 57602 return; 57603 } 57604 if ((0, import_blob3.isBlobURL)(media.url)) { 57605 setIsUploading(true); 57606 return; 57607 } 57608 if (media.media_type && media.media_type !== IMAGE_BACKGROUND_TYPE || !media.media_type && media.type && media.type !== IMAGE_BACKGROUND_TYPE) { 57609 onUploadError( 57610 (0, import_i18n193.__)("Only images can be used as a background image.") 57611 ); 57612 return; 57613 } 57614 const sizeValue = style?.background?.backgroundSize || defaultValues?.backgroundSize; 57615 const positionValue = style?.background?.backgroundPosition; 57616 onChange( 57617 setImmutably(style, ["background"], { 57618 ...style?.background, 57619 backgroundImage: { 57620 url: media.url, 57621 id: media.id, 57622 source: "file", 57623 title: media.title || void 0 57624 }, 57625 backgroundPosition: ( 57626 /* 57627 * A background image uploaded and set in the editor receives a default background position of '50% 0', 57628 * when the background image size is the equivalent of "Tile". 57629 * This is to increase the chance that the image's focus point is visible. 57630 * This is in-editor only to assist with the user experience. 57631 */ 57632 !positionValue && ("auto" === sizeValue || !sizeValue) ? "50% 0" : positionValue 57633 ), 57634 backgroundSize: sizeValue 57635 }) 57636 ); 57637 setIsUploading(false); 57638 focusToggleButton(containerRef); 57639 }; 57640 const onFilesDrop2 = (filesList) => { 57641 getSettings8().mediaUpload({ 57642 allowedTypes: [IMAGE_BACKGROUND_TYPE], 57643 filesList, 57644 onFileChange([image]) { 57645 onSelectMedia(image); 57646 }, 57647 onError: onUploadError, 57648 multiple: false 57649 }); 57650 }; 57651 const hasValue = hasBackgroundImageValue(style); 57652 const onRemove = () => onChange( 57653 setImmutably(style, ["background"], { 57654 backgroundImage: "none" 57655 }) 57656 ); 57657 const canRemove = !hasValue && hasBackgroundImageValue(inheritedValue); 57658 const imgLabel = title || (0, import_url12.getFilename)(url) || (0, import_i18n193.__)("Add background image"); 57659 return /* @__PURE__ */ (0, import_jsx_runtime367.jsxs)("div", { className: "block-editor-global-styles-background-panel__image-tools-panel-item", children: [ 57660 isUploading2 && /* @__PURE__ */ (0, import_jsx_runtime367.jsx)(LoadingSpinner, {}), 57661 /* @__PURE__ */ (0, import_jsx_runtime367.jsx)( 57662 media_replace_flow_default, 57663 { 57664 mediaId: id, 57665 mediaURL: url, 57666 allowedTypes: [IMAGE_BACKGROUND_TYPE], 57667 accept: "image/*", 57668 onSelect: onSelectMedia, 57669 popoverProps: { 57670 className: clsx_default({ 57671 "block-editor-global-styles-background-panel__media-replace-popover": displayInPanel 57672 }) 57673 }, 57674 name: /* @__PURE__ */ (0, import_jsx_runtime367.jsx)( 57675 InspectorImagePreviewItem, 57676 { 57677 imgUrl: url, 57678 filename: title, 57679 label: imgLabel 57680 } 57681 ), 57682 renderToggle: (props) => /* @__PURE__ */ (0, import_jsx_runtime367.jsx)(import_components203.Button, { ...props, __next40pxDefaultSize: true }), 57683 onError: onUploadError, 57684 onReset: () => { 57685 focusToggleButton(containerRef); 57686 onResetImage(); 57687 }, 57688 children: canRemove && /* @__PURE__ */ (0, import_jsx_runtime367.jsx)( 57689 import_components203.MenuItem, 57690 { 57691 onClick: () => { 57692 focusToggleButton(containerRef); 57693 onRemove(); 57694 onRemoveImage(); 57695 }, 57696 children: (0, import_i18n193.__)("Remove") 57697 } 57698 ) 57699 } 57700 ), 57701 /* @__PURE__ */ (0, import_jsx_runtime367.jsx)( 57702 import_components203.DropZone, 57703 { 57704 onFilesDrop: onFilesDrop2, 57705 label: (0, import_i18n193.__)("Drop to upload") 57706 } 57707 ) 57708 ] }); 57709 } 57710 function BackgroundSizeControls({ 57711 onChange, 57712 style, 57713 inheritedValue, 57714 defaultValues 57715 }) { 57716 const sizeValue = style?.background?.backgroundSize || inheritedValue?.background?.backgroundSize; 57717 const repeatValue = style?.background?.backgroundRepeat || inheritedValue?.background?.backgroundRepeat; 57718 const imageValue = style?.background?.backgroundImage?.url || inheritedValue?.background?.backgroundImage?.url; 57719 const isUploadedImage = style?.background?.backgroundImage?.id; 57720 const positionValue = style?.background?.backgroundPosition || inheritedValue?.background?.backgroundPosition; 57721 const attachmentValue = style?.background?.backgroundAttachment || inheritedValue?.background?.backgroundAttachment; 57722 let currentValueForToggle = !sizeValue && isUploadedImage ? defaultValues?.backgroundSize : sizeValue || "auto"; 57723 currentValueForToggle = !["cover", "contain", "auto"].includes( 57724 currentValueForToggle 57725 ) ? "auto" : currentValueForToggle; 57726 const repeatCheckedValue = !(repeatValue === "no-repeat" || currentValueForToggle === "cover" && repeatValue === void 0); 57727 const updateBackgroundSize = (next) => { 57728 let nextRepeat = repeatValue; 57729 let nextPosition = positionValue; 57730 if (next === "contain") { 57731 nextRepeat = "no-repeat"; 57732 nextPosition = void 0; 57733 } 57734 if (next === "cover") { 57735 nextRepeat = void 0; 57736 nextPosition = void 0; 57737 } 57738 if ((currentValueForToggle === "cover" || currentValueForToggle === "contain") && next === "auto") { 57739 nextRepeat = void 0; 57740 if (!!style?.background?.backgroundImage?.id) { 57741 nextPosition = "50% 0"; 57742 } 57743 } 57744 if (!next && currentValueForToggle === "auto") { 57745 next = "auto"; 57746 } 57747 onChange( 57748 setImmutably(style, ["background"], { 57749 ...style?.background, 57750 backgroundPosition: nextPosition, 57751 backgroundRepeat: nextRepeat, 57752 backgroundSize: next 57753 }) 57754 ); 57755 }; 57756 const updateBackgroundPosition = (next) => { 57757 onChange( 57758 setImmutably( 57759 style, 57760 ["background", "backgroundPosition"], 57761 coordsToBackgroundPosition(next) 57762 ) 57763 ); 57764 }; 57765 const toggleIsRepeated = () => onChange( 57766 setImmutably( 57767 style, 57768 ["background", "backgroundRepeat"], 57769 repeatCheckedValue === true ? "no-repeat" : "repeat" 57770 ) 57771 ); 57772 const toggleScrollWithPage = () => onChange( 57773 setImmutably( 57774 style, 57775 ["background", "backgroundAttachment"], 57776 attachmentValue === "fixed" ? "scroll" : "fixed" 57777 ) 57778 ); 57779 const backgroundPositionValue = !positionValue && isUploadedImage && "contain" === sizeValue ? defaultValues?.backgroundPosition : positionValue; 57780 return /* @__PURE__ */ (0, import_jsx_runtime367.jsxs)(import_components203.__experimentalVStack, { spacing: 3, className: "single-column", children: [ 57781 /* @__PURE__ */ (0, import_jsx_runtime367.jsx)( 57782 import_components203.FocalPointPicker, 57783 { 57784 label: (0, import_i18n193.__)("Focal point"), 57785 url: imageValue, 57786 value: backgroundPositionToCoords(backgroundPositionValue), 57787 onChange: updateBackgroundPosition 57788 } 57789 ), 57790 /* @__PURE__ */ (0, import_jsx_runtime367.jsx)( 57791 import_components203.ToggleControl, 57792 { 57793 label: (0, import_i18n193.__)("Fixed background"), 57794 checked: attachmentValue === "fixed", 57795 onChange: toggleScrollWithPage 57796 } 57797 ), 57798 /* @__PURE__ */ (0, import_jsx_runtime367.jsxs)( 57799 import_components203.__experimentalToggleGroupControl, 57800 { 57801 size: "__unstable-large", 57802 label: (0, import_i18n193.__)("Size"), 57803 value: currentValueForToggle, 57804 onChange: updateBackgroundSize, 57805 isBlock: true, 57806 help: backgroundSizeHelpText( 57807 sizeValue || defaultValues?.backgroundSize 57808 ), 57809 children: [ 57810 /* @__PURE__ */ (0, import_jsx_runtime367.jsx)( 57811 import_components203.__experimentalToggleGroupControlOption, 57812 { 57813 value: "cover", 57814 label: (0, import_i18n193._x)( 57815 "Cover", 57816 "Size option for background image control" 57817 ) 57818 }, 57819 "cover" 57820 ), 57821 /* @__PURE__ */ (0, import_jsx_runtime367.jsx)( 57822 import_components203.__experimentalToggleGroupControlOption, 57823 { 57824 value: "contain", 57825 label: (0, import_i18n193._x)( 57826 "Contain", 57827 "Size option for background image control" 57828 ) 57829 }, 57830 "contain" 57831 ), 57832 /* @__PURE__ */ (0, import_jsx_runtime367.jsx)( 57833 import_components203.__experimentalToggleGroupControlOption, 57834 { 57835 value: "auto", 57836 label: (0, import_i18n193._x)( 57837 "Tile", 57838 "Size option for background image control" 57839 ) 57840 }, 57841 "tile" 57842 ) 57843 ] 57844 } 57845 ), 57846 /* @__PURE__ */ (0, import_jsx_runtime367.jsxs)(import_components203.__experimentalHStack, { justify: "flex-start", spacing: 2, as: "span", children: [ 57847 /* @__PURE__ */ (0, import_jsx_runtime367.jsx)( 57848 import_components203.__experimentalUnitControl, 57849 { 57850 "aria-label": (0, import_i18n193.__)("Background image width"), 57851 onChange: updateBackgroundSize, 57852 value: sizeValue, 57853 size: "__unstable-large", 57854 __unstableInputWidth: "100px", 57855 min: 0, 57856 placeholder: (0, import_i18n193.__)("Auto"), 57857 disabled: currentValueForToggle !== "auto" || currentValueForToggle === void 0 57858 } 57859 ), 57860 /* @__PURE__ */ (0, import_jsx_runtime367.jsx)( 57861 import_components203.ToggleControl, 57862 { 57863 label: (0, import_i18n193.__)("Repeat"), 57864 checked: repeatCheckedValue, 57865 onChange: toggleIsRepeated, 57866 disabled: currentValueForToggle === "cover" 57867 } 57868 ) 57869 ] }) 57870 ] }); 57871 } 57872 function BackgroundImagePanel({ 57873 value, 57874 onChange, 57875 inheritedValue = value, 57876 settings: settings2, 57877 defaultValues = {} 57878 }) { 57879 const { globalStyles, _links } = (0, import_data160.useSelect)((select3) => { 57880 const { getSettings: getSettings8 } = select3(store); 57881 const _settings = getSettings8(); 57882 return { 57883 globalStyles: _settings[globalStylesDataKey], 57884 _links: _settings[globalStylesLinksDataKey] 57885 }; 57886 }, []); 57887 const resolvedInheritedValue = (0, import_element205.useMemo)(() => { 57888 const resolvedValues = { 57889 background: {} 57890 }; 57891 if (!inheritedValue?.background) { 57892 return inheritedValue; 57893 } 57894 Object.entries(inheritedValue?.background).forEach( 57895 ([key, backgroundValue]) => { 57896 resolvedValues.background[key] = getResolvedValue( 57897 backgroundValue, 57898 { 57899 styles: globalStyles, 57900 _links 57901 } 57902 ); 57903 } 57904 ); 57905 return resolvedValues; 57906 }, [globalStyles, _links, inheritedValue]); 57907 const resetBackground = () => onChange(setImmutably(value, ["background"], {})); 57908 const { title, url } = value?.background?.backgroundImage || { 57909 ...resolvedInheritedValue?.background?.backgroundImage 57910 }; 57911 const hasImageValue = hasBackgroundImageValue(value) || hasBackgroundImageValue(resolvedInheritedValue); 57912 const imageValue = value?.background?.backgroundImage || inheritedValue?.background?.backgroundImage; 57913 const shouldShowBackgroundImageControls = hasImageValue && "none" !== imageValue && (settings2?.background?.backgroundSize || settings2?.background?.backgroundPosition || settings2?.background?.backgroundRepeat); 57914 const [isDropDownOpen, setIsDropDownOpen] = (0, import_element205.useState)(false); 57915 const containerRef = (0, import_element205.useRef)(); 57916 return /* @__PURE__ */ (0, import_jsx_runtime367.jsx)( 57917 "div", 57918 { 57919 ref: containerRef, 57920 className: clsx_default( 57921 "block-editor-global-styles-background-panel__inspector-media-replace-container", 57922 { 57923 "is-open": isDropDownOpen 57924 } 57925 ), 57926 children: shouldShowBackgroundImageControls ? /* @__PURE__ */ (0, import_jsx_runtime367.jsx)( 57927 BackgroundControlsPanel, 57928 { 57929 label: title, 57930 filename: title, 57931 url, 57932 onToggle: setIsDropDownOpen, 57933 hasImageValue, 57934 onReset: resetBackground, 57935 containerRef, 57936 children: /* @__PURE__ */ (0, import_jsx_runtime367.jsxs)(import_components203.__experimentalVStack, { spacing: 3, className: "single-column", children: [ 57937 /* @__PURE__ */ (0, import_jsx_runtime367.jsx)( 57938 BackgroundImageControls, 57939 { 57940 onChange, 57941 style: value, 57942 inheritedValue: resolvedInheritedValue, 57943 displayInPanel: true, 57944 onResetImage: () => { 57945 setIsDropDownOpen(false); 57946 resetBackground(); 57947 }, 57948 onRemoveImage: () => setIsDropDownOpen(false), 57949 defaultValues, 57950 containerRef 57951 } 57952 ), 57953 /* @__PURE__ */ (0, import_jsx_runtime367.jsx)( 57954 BackgroundSizeControls, 57955 { 57956 onChange, 57957 style: value, 57958 defaultValues, 57959 inheritedValue: resolvedInheritedValue 57960 } 57961 ) 57962 ] }) 57963 } 57964 ) : /* @__PURE__ */ (0, import_jsx_runtime367.jsx)( 57965 BackgroundImageControls, 57966 { 57967 onChange, 57968 style: value, 57969 inheritedValue: resolvedInheritedValue, 57970 defaultValues, 57971 onResetImage: () => { 57972 setIsDropDownOpen(false); 57973 resetBackground(); 57974 }, 57975 onRemoveImage: () => setIsDropDownOpen(false), 57976 containerRef 57977 } 57978 ) 57979 } 57980 ); 57981 } 57982 57983 // packages/block-editor/build-module/components/global-styles/background-panel.js 57984 var import_i18n194 = __toESM(require_i18n()); 57985 var import_jsx_runtime368 = __toESM(require_jsx_runtime()); 57986 var DEFAULT_CONTROLS8 = { 57987 backgroundImage: true 57988 }; 57989 function useHasBackgroundPanel(settings2) { 57990 return import_element206.Platform.OS === "web" && settings2?.background?.backgroundImage; 57991 } 57992 function hasBackgroundImageValue(style) { 57993 return !!style?.background?.backgroundImage?.id || // Supports url() string values in theme.json. 57994 "string" === typeof style?.background?.backgroundImage || !!style?.background?.backgroundImage?.url; 57995 } 57996 function BackgroundToolsPanel({ 57997 resetAllFilter, 57998 onChange, 57999 value, 58000 panelId, 58001 children, 58002 headerLabel 58003 }) { 58004 const dropdownMenuProps = useToolsPanelDropdownMenuProps(); 58005 const resetAll = () => { 58006 const updatedValue = resetAllFilter(value); 58007 onChange(updatedValue); 58008 }; 58009 return /* @__PURE__ */ (0, import_jsx_runtime368.jsx)( 58010 import_components204.__experimentalToolsPanel, 58011 { 58012 label: headerLabel, 58013 resetAll, 58014 panelId, 58015 dropdownMenuProps, 58016 children 58017 } 58018 ); 58019 } 58020 function BackgroundImagePanel2({ 58021 as: Wrapper = BackgroundToolsPanel, 58022 value, 58023 onChange, 58024 inheritedValue, 58025 settings: settings2, 58026 panelId, 58027 defaultControls = DEFAULT_CONTROLS8, 58028 defaultValues = {}, 58029 headerLabel = (0, import_i18n194.__)("Background image") 58030 }) { 58031 const showBackgroundImageControl = useHasBackgroundPanel(settings2); 58032 const resetBackground = () => onChange(setImmutably(value, ["background"], {})); 58033 const resetAllFilter = (0, import_element206.useCallback)((previousValue) => { 58034 return { 58035 ...previousValue, 58036 background: {} 58037 }; 58038 }, []); 58039 return /* @__PURE__ */ (0, import_jsx_runtime368.jsx)( 58040 Wrapper, 58041 { 58042 resetAllFilter, 58043 value, 58044 onChange, 58045 panelId, 58046 headerLabel, 58047 children: showBackgroundImageControl && /* @__PURE__ */ (0, import_jsx_runtime368.jsx)( 58048 import_components204.__experimentalToolsPanelItem, 58049 { 58050 hasValue: () => !!value?.background, 58051 label: (0, import_i18n194.__)("Image"), 58052 onDeselect: resetBackground, 58053 isShownByDefault: defaultControls.backgroundImage, 58054 panelId, 58055 children: /* @__PURE__ */ (0, import_jsx_runtime368.jsx)( 58056 BackgroundImagePanel, 58057 { 58058 value, 58059 onChange, 58060 settings: settings2, 58061 inheritedValue, 58062 defaultControls, 58063 defaultValues 58064 } 58065 ) 58066 } 58067 ) 58068 } 58069 ); 58070 } 58071 58072 // packages/block-editor/build-module/hooks/border.js 58073 var import_i18n195 = __toESM(require_i18n()); 58074 var import_jsx_runtime369 = __toESM(require_jsx_runtime()); 58075 var BORDER_SUPPORT_KEY2 = "__experimentalBorder"; 58076 var SHADOW_SUPPORT_KEY = "shadow"; 58077 var getColorByProperty = (colors2, property, value) => { 58078 let matchedColor; 58079 colors2.some( 58080 (origin) => origin.colors.some((color) => { 58081 if (color[property] === value) { 58082 matchedColor = color; 58083 return true; 58084 } 58085 return false; 58086 }) 58087 ); 58088 return matchedColor; 58089 }; 58090 var getMultiOriginColor = ({ colors: colors2, namedColor, customColor }) => { 58091 if (namedColor) { 58092 const colorObject2 = getColorByProperty(colors2, "slug", namedColor); 58093 if (colorObject2) { 58094 return colorObject2; 58095 } 58096 } 58097 if (!customColor) { 58098 return { color: void 0 }; 58099 } 58100 const colorObject = getColorByProperty(colors2, "color", customColor); 58101 return colorObject ? colorObject : { color: customColor }; 58102 }; 58103 function getColorSlugFromVariable(value) { 58104 const namedColor = /var:preset\|color\|(.+)/.exec(value); 58105 if (namedColor && namedColor[1]) { 58106 return namedColor[1]; 58107 } 58108 return null; 58109 } 58110 function styleToAttributes(style) { 58111 if ((0, import_components205.__experimentalHasSplitBorders)(style?.border)) { 58112 return { 58113 style, 58114 borderColor: void 0 58115 }; 58116 } 58117 const borderColorValue = style?.border?.color; 58118 const borderColorSlug = borderColorValue?.startsWith("var:preset|color|") ? borderColorValue.substring("var:preset|color|".length) : void 0; 58119 const updatedStyle = { ...style }; 58120 updatedStyle.border = { 58121 ...updatedStyle.border, 58122 color: borderColorSlug ? void 0 : borderColorValue 58123 }; 58124 return { 58125 style: cleanEmptyObject(updatedStyle), 58126 borderColor: borderColorSlug 58127 }; 58128 } 58129 function attributesToStyle(attributes) { 58130 if ((0, import_components205.__experimentalHasSplitBorders)(attributes.style?.border)) { 58131 return attributes.style; 58132 } 58133 return { 58134 ...attributes.style, 58135 border: { 58136 ...attributes.style?.border, 58137 color: attributes.borderColor ? "var:preset|color|" + attributes.borderColor : attributes.style?.border?.color 58138 } 58139 }; 58140 } 58141 function BordersInspectorControl({ label, children, resetAllFilter }) { 58142 const attributesResetAllFilter = (0, import_element207.useCallback)( 58143 (attributes) => { 58144 const existingStyle = attributesToStyle(attributes); 58145 const updatedStyle = resetAllFilter(existingStyle); 58146 return { 58147 ...attributes, 58148 ...styleToAttributes(updatedStyle) 58149 }; 58150 }, 58151 [resetAllFilter] 58152 ); 58153 return /* @__PURE__ */ (0, import_jsx_runtime369.jsx)( 58154 inspector_controls_default, 58155 { 58156 group: "border", 58157 resetAllFilter: attributesResetAllFilter, 58158 label, 58159 children 58160 } 58161 ); 58162 } 58163 function BorderPanel2({ clientId, name, setAttributes, settings: settings2 }) { 58164 const isEnabled = useHasBorderPanel(settings2); 58165 const { style, borderColor } = (0, import_data161.useSelect)( 58166 (select3) => { 58167 if (!isEnabled) { 58168 return {}; 58169 } 58170 const { style: _style, borderColor: _borderColor } = select3(store).getBlockAttributes(clientId) || {}; 58171 return { style: _style, borderColor: _borderColor }; 58172 }, 58173 [clientId, isEnabled] 58174 ); 58175 const value = (0, import_element207.useMemo)(() => { 58176 return attributesToStyle({ style, borderColor }); 58177 }, [style, borderColor]); 58178 const onChange = (newStyle) => { 58179 setAttributes(styleToAttributes(newStyle)); 58180 }; 58181 if (!isEnabled) { 58182 return null; 58183 } 58184 const defaultControls = { 58185 ...(0, import_blocks89.getBlockSupport)(name, [ 58186 BORDER_SUPPORT_KEY2, 58187 "__experimentalDefaultControls" 58188 ]), 58189 ...(0, import_blocks89.getBlockSupport)(name, [ 58190 SHADOW_SUPPORT_KEY, 58191 "__experimentalDefaultControls" 58192 ]) 58193 }; 58194 return /* @__PURE__ */ (0, import_jsx_runtime369.jsx)( 58195 BorderPanel, 58196 { 58197 as: BordersInspectorControl, 58198 panelId: clientId, 58199 settings: settings2, 58200 value, 58201 onChange, 58202 defaultControls 58203 } 58204 ); 58205 } 58206 function hasBorderSupport2(blockName, feature = "any") { 58207 if (import_element207.Platform.OS !== "web") { 58208 return false; 58209 } 58210 const support = (0, import_blocks89.getBlockSupport)(blockName, BORDER_SUPPORT_KEY2); 58211 if (support === true) { 58212 return true; 58213 } 58214 if (feature === "any") { 58215 return !!(support?.color || support?.radius || support?.width || support?.style); 58216 } 58217 return !!support?.[feature]; 58218 } 58219 function useBorderPanelLabel({ 58220 blockName, 58221 hasBorderControl, 58222 hasShadowControl 58223 } = {}) { 58224 const settings2 = useBlockSettings(blockName); 58225 const controls = useHasBorderPanelControls(settings2); 58226 if (!hasBorderControl && !hasShadowControl && blockName) { 58227 hasBorderControl = controls?.hasBorderColor || controls?.hasBorderStyle || controls?.hasBorderWidth || controls?.hasBorderRadius; 58228 hasShadowControl = controls?.hasShadow; 58229 } 58230 if (hasBorderControl && hasShadowControl) { 58231 return (0, import_i18n195.__)("Border & Shadow"); 58232 } 58233 if (hasShadowControl) { 58234 return (0, import_i18n195.__)("Shadow"); 58235 } 58236 return (0, import_i18n195.__)("Border"); 58237 } 58238 function addAttributes(settings2) { 58239 if (!hasBorderSupport2(settings2, "color")) { 58240 return settings2; 58241 } 58242 if (settings2.attributes.borderColor) { 58243 return settings2; 58244 } 58245 return { 58246 ...settings2, 58247 attributes: { 58248 ...settings2.attributes, 58249 borderColor: { 58250 type: "string" 58251 } 58252 } 58253 }; 58254 } 58255 function addSaveProps(props, blockNameOrType, attributes) { 58256 if (!hasBorderSupport2(blockNameOrType, "color") || shouldSkipSerialization(blockNameOrType, BORDER_SUPPORT_KEY2, "color")) { 58257 return props; 58258 } 58259 const borderClasses = getBorderClasses(attributes); 58260 const newClassName = clsx_default(props.className, borderClasses); 58261 props.className = newClassName ? newClassName : void 0; 58262 return props; 58263 } 58264 function getBorderClasses(attributes) { 58265 const { borderColor, style } = attributes; 58266 const borderColorClass = getColorClassName("border-color", borderColor); 58267 return clsx_default({ 58268 "has-border-color": borderColor || style?.border?.color, 58269 [borderColorClass]: !!borderColorClass 58270 }); 58271 } 58272 function useBlockProps4({ name, borderColor, style }) { 58273 const { colors: colors2 } = useMultipleOriginColorsAndGradients(); 58274 if (!hasBorderSupport2(name, "color") || shouldSkipSerialization(name, BORDER_SUPPORT_KEY2, "color")) { 58275 return {}; 58276 } 58277 const { color: borderColorValue } = getMultiOriginColor({ 58278 colors: colors2, 58279 namedColor: borderColor 58280 }); 58281 const { color: borderTopColor } = getMultiOriginColor({ 58282 colors: colors2, 58283 namedColor: getColorSlugFromVariable(style?.border?.top?.color) 58284 }); 58285 const { color: borderRightColor } = getMultiOriginColor({ 58286 colors: colors2, 58287 namedColor: getColorSlugFromVariable(style?.border?.right?.color) 58288 }); 58289 const { color: borderBottomColor } = getMultiOriginColor({ 58290 colors: colors2, 58291 namedColor: getColorSlugFromVariable(style?.border?.bottom?.color) 58292 }); 58293 const { color: borderLeftColor } = getMultiOriginColor({ 58294 colors: colors2, 58295 namedColor: getColorSlugFromVariable(style?.border?.left?.color) 58296 }); 58297 const extraStyles = { 58298 borderTopColor: borderTopColor || borderColorValue, 58299 borderRightColor: borderRightColor || borderColorValue, 58300 borderBottomColor: borderBottomColor || borderColorValue, 58301 borderLeftColor: borderLeftColor || borderColorValue 58302 }; 58303 return addSaveProps( 58304 { style: cleanEmptyObject(extraStyles) || {} }, 58305 name, 58306 { borderColor, style } 58307 ); 58308 } 58309 var border_default = { 58310 useBlockProps: useBlockProps4, 58311 addSaveProps, 58312 attributeKeys: ["borderColor", "style"], 58313 hasSupport(name) { 58314 return hasBorderSupport2(name, "color"); 58315 } 58316 }; 58317 (0, import_hooks11.addFilter)( 58318 "blocks.registerBlockType", 58319 "core/border/addAttributes", 58320 addAttributes 58321 ); 58322 58323 // packages/block-editor/build-module/hooks/color.js 58324 var import_hooks12 = __toESM(require_hooks()); 58325 var import_blocks91 = __toESM(require_blocks()); 58326 var import_element210 = __toESM(require_element()); 58327 var import_data163 = __toESM(require_data()); 58328 58329 // packages/block-editor/build-module/hooks/background.js 58330 var import_blocks90 = __toESM(require_blocks()); 58331 var import_data162 = __toESM(require_data()); 58332 var import_element208 = __toESM(require_element()); 58333 var import_jsx_runtime370 = __toESM(require_jsx_runtime()); 58334 var BACKGROUND_SUPPORT_KEY = "background"; 58335 var BACKGROUND_BLOCK_DEFAULT_VALUES2 = { 58336 backgroundSize: "cover", 58337 backgroundPosition: "50% 50%" 58338 // used only when backgroundSize is 'contain'. 58339 }; 58340 function hasBackgroundSupport(blockName, feature = "any") { 58341 const support = (0, import_blocks90.getBlockSupport)(blockName, BACKGROUND_SUPPORT_KEY); 58342 if (support === true) { 58343 return true; 58344 } 58345 if (feature === "any") { 58346 return !!support?.backgroundImage || !!support?.backgroundSize || !!support?.backgroundRepeat; 58347 } 58348 return !!support?.[feature]; 58349 } 58350 function setBackgroundStyleDefaults2(backgroundStyle) { 58351 if (!backgroundStyle || !backgroundStyle?.backgroundImage?.url) { 58352 return; 58353 } 58354 let backgroundStylesWithDefaults; 58355 if (!backgroundStyle?.backgroundSize) { 58356 backgroundStylesWithDefaults = { 58357 backgroundSize: BACKGROUND_BLOCK_DEFAULT_VALUES2.backgroundSize 58358 }; 58359 } 58360 if ("contain" === backgroundStyle?.backgroundSize && !backgroundStyle?.backgroundPosition) { 58361 backgroundStylesWithDefaults = { 58362 backgroundPosition: BACKGROUND_BLOCK_DEFAULT_VALUES2.backgroundPosition 58363 }; 58364 } 58365 return backgroundStylesWithDefaults; 58366 } 58367 function useBlockProps5({ name, style }) { 58368 if (!hasBackgroundSupport(name) || !style?.background?.backgroundImage) { 58369 return; 58370 } 58371 const backgroundStyles = setBackgroundStyleDefaults2(style?.background); 58372 if (!backgroundStyles) { 58373 return; 58374 } 58375 return { 58376 style: { 58377 ...backgroundStyles 58378 } 58379 }; 58380 } 58381 function getBackgroundImageClasses(style) { 58382 return hasBackgroundImageValue(style) ? "has-background" : ""; 58383 } 58384 function BackgroundInspectorControl({ children }) { 58385 const resetAllFilter = (0, import_element208.useCallback)((attributes) => { 58386 return { 58387 ...attributes, 58388 style: { 58389 ...attributes.style, 58390 background: void 0 58391 } 58392 }; 58393 }, []); 58394 return /* @__PURE__ */ (0, import_jsx_runtime370.jsx)(inspector_controls_default, { group: "background", resetAllFilter, children }); 58395 } 58396 function BackgroundImagePanel3({ 58397 clientId, 58398 name, 58399 setAttributes, 58400 settings: settings2 58401 }) { 58402 const { style, inheritedValue } = (0, import_data162.useSelect)( 58403 (select3) => { 58404 const { getBlockAttributes: getBlockAttributes3, getSettings: getSettings8 } = select3(store); 58405 const _settings = getSettings8(); 58406 return { 58407 style: getBlockAttributes3(clientId)?.style, 58408 /* 58409 * To ensure we pass down the right inherited values: 58410 * @TODO 1. Pass inherited value down to all block style controls, 58411 * See: packages/block-editor/src/hooks/style.js 58412 * @TODO 2. Add support for block style variations, 58413 * See implementation: packages/block-editor/src/hooks/block-style-variation.js 58414 */ 58415 inheritedValue: _settings[globalStylesDataKey]?.blocks?.[name] 58416 }; 58417 }, 58418 [clientId, name] 58419 ); 58420 if (!useHasBackgroundPanel(settings2) || !hasBackgroundSupport(name, "backgroundImage")) { 58421 return null; 58422 } 58423 const onChange = (newStyle) => { 58424 setAttributes({ 58425 style: cleanEmptyObject(newStyle) 58426 }); 58427 }; 58428 const updatedSettings = { 58429 ...settings2, 58430 background: { 58431 ...settings2.background, 58432 backgroundSize: settings2?.background?.backgroundSize && hasBackgroundSupport(name, "backgroundSize") 58433 } 58434 }; 58435 const defaultControls = (0, import_blocks90.getBlockSupport)(name, [ 58436 BACKGROUND_SUPPORT_KEY, 58437 "defaultControls" 58438 ]); 58439 return /* @__PURE__ */ (0, import_jsx_runtime370.jsx)( 58440 BackgroundImagePanel2, 58441 { 58442 inheritedValue, 58443 as: BackgroundInspectorControl, 58444 panelId: clientId, 58445 defaultValues: BACKGROUND_BLOCK_DEFAULT_VALUES2, 58446 settings: updatedSettings, 58447 onChange, 58448 defaultControls, 58449 value: style 58450 } 58451 ); 58452 } 58453 var background_default = { 58454 useBlockProps: useBlockProps5, 58455 attributeKeys: ["style"], 58456 hasSupport: hasBackgroundSupport 58457 }; 58458 58459 // packages/block-editor/build-module/hooks/contrast-checker.js 58460 var import_element209 = __toESM(require_element()); 58461 var import_jsx_runtime371 = __toESM(require_jsx_runtime()); 58462 function getComputedValue(node, property) { 58463 return node.ownerDocument.defaultView.getComputedStyle(node).getPropertyValue(property); 58464 } 58465 function getBlockElementColors(blockEl) { 58466 if (!blockEl) { 58467 return {}; 58468 } 58469 const firstLinkElement = blockEl.querySelector("a"); 58470 const linkColor = !!firstLinkElement?.innerText ? getComputedValue(firstLinkElement, "color") : void 0; 58471 const textColor = getComputedValue(blockEl, "color"); 58472 let backgroundColorNode = blockEl; 58473 let backgroundColor = getComputedValue( 58474 backgroundColorNode, 58475 "background-color" 58476 ); 58477 while (backgroundColor === "rgba(0, 0, 0, 0)" && backgroundColorNode.parentNode && backgroundColorNode.parentNode.nodeType === backgroundColorNode.parentNode.ELEMENT_NODE) { 58478 backgroundColorNode = backgroundColorNode.parentNode; 58479 backgroundColor = getComputedValue( 58480 backgroundColorNode, 58481 "background-color" 58482 ); 58483 } 58484 return { 58485 textColor, 58486 backgroundColor, 58487 linkColor 58488 }; 58489 } 58490 function reducer3(prevColors, newColors) { 58491 const hasChanged = Object.keys(newColors).some( 58492 (key) => prevColors[key] !== newColors[key] 58493 ); 58494 return hasChanged ? newColors : prevColors; 58495 } 58496 function BlockColorContrastChecker({ clientId }) { 58497 const blockEl = useBlockElement(clientId); 58498 const [colors2, setColors] = (0, import_element209.useReducer)(reducer3, {}); 58499 (0, import_element209.useLayoutEffect)(() => { 58500 if (!blockEl) { 58501 return; 58502 } 58503 function updateColors() { 58504 setColors(getBlockElementColors(blockEl)); 58505 } 58506 window.requestAnimationFrame( 58507 () => window.requestAnimationFrame(updateColors) 58508 ); 58509 }); 58510 return /* @__PURE__ */ (0, import_jsx_runtime371.jsx)( 58511 contrast_checker_default, 58512 { 58513 backgroundColor: colors2.backgroundColor, 58514 textColor: colors2.textColor, 58515 linkColor: colors2.linkColor, 58516 enableAlphaChecker: true 58517 } 58518 ); 58519 } 58520 58521 // packages/block-editor/build-module/hooks/color.js 58522 var import_jsx_runtime372 = __toESM(require_jsx_runtime()); 58523 var COLOR_SUPPORT_KEY2 = "color"; 58524 var hasColorSupport = (blockNameOrType) => { 58525 const colorSupport = (0, import_blocks91.getBlockSupport)(blockNameOrType, COLOR_SUPPORT_KEY2); 58526 return colorSupport && (colorSupport.link === true || colorSupport.gradient === true || colorSupport.background !== false || colorSupport.text !== false); 58527 }; 58528 var hasLinkColorSupport = (blockType) => { 58529 if (import_element210.Platform.OS !== "web") { 58530 return false; 58531 } 58532 const colorSupport = (0, import_blocks91.getBlockSupport)(blockType, COLOR_SUPPORT_KEY2); 58533 return colorSupport !== null && typeof colorSupport === "object" && !!colorSupport.link; 58534 }; 58535 var hasGradientSupport2 = (blockNameOrType) => { 58536 const colorSupport = (0, import_blocks91.getBlockSupport)(blockNameOrType, COLOR_SUPPORT_KEY2); 58537 return colorSupport !== null && typeof colorSupport === "object" && !!colorSupport.gradients; 58538 }; 58539 var hasBackgroundColorSupport2 = (blockType) => { 58540 const colorSupport = (0, import_blocks91.getBlockSupport)(blockType, COLOR_SUPPORT_KEY2); 58541 return colorSupport && colorSupport.background !== false; 58542 }; 58543 var hasTextColorSupport2 = (blockType) => { 58544 const colorSupport = (0, import_blocks91.getBlockSupport)(blockType, COLOR_SUPPORT_KEY2); 58545 return colorSupport && colorSupport.text !== false; 58546 }; 58547 function addAttributes2(settings2) { 58548 if (!hasColorSupport(settings2)) { 58549 return settings2; 58550 } 58551 if (!settings2.attributes.backgroundColor) { 58552 Object.assign(settings2.attributes, { 58553 backgroundColor: { 58554 type: "string" 58555 } 58556 }); 58557 } 58558 if (!settings2.attributes.textColor) { 58559 Object.assign(settings2.attributes, { 58560 textColor: { 58561 type: "string" 58562 } 58563 }); 58564 } 58565 if (hasGradientSupport2(settings2) && !settings2.attributes.gradient) { 58566 Object.assign(settings2.attributes, { 58567 gradient: { 58568 type: "string" 58569 } 58570 }); 58571 } 58572 return settings2; 58573 } 58574 function addSaveProps2(props, blockNameOrType, attributes) { 58575 if (!hasColorSupport(blockNameOrType) || shouldSkipSerialization(blockNameOrType, COLOR_SUPPORT_KEY2)) { 58576 return props; 58577 } 58578 const hasGradient = hasGradientSupport2(blockNameOrType); 58579 const { backgroundColor, textColor, gradient, style } = attributes; 58580 const shouldSerialize = (feature) => !shouldSkipSerialization( 58581 blockNameOrType, 58582 COLOR_SUPPORT_KEY2, 58583 feature 58584 ); 58585 const textClass = shouldSerialize("text") ? getColorClassName("color", textColor) : void 0; 58586 const gradientClass = shouldSerialize("gradients") ? __experimentalGetGradientClass(gradient) : void 0; 58587 const backgroundClass = shouldSerialize("background") ? getColorClassName("background-color", backgroundColor) : void 0; 58588 const serializeHasBackground = shouldSerialize("background") || shouldSerialize("gradients"); 58589 const hasBackground = backgroundColor || style?.color?.background || hasGradient && (gradient || style?.color?.gradient); 58590 const newClassName = clsx_default(props.className, textClass, gradientClass, { 58591 // Don't apply the background class if there's a custom gradient. 58592 [backgroundClass]: (!hasGradient || !style?.color?.gradient) && !!backgroundClass, 58593 "has-text-color": shouldSerialize("text") && (textColor || style?.color?.text), 58594 "has-background": serializeHasBackground && hasBackground, 58595 "has-link-color": shouldSerialize("link") && style?.elements?.link?.color 58596 }); 58597 props.className = newClassName ? newClassName : void 0; 58598 return props; 58599 } 58600 function styleToAttributes2(style) { 58601 const textColorValue = style?.color?.text; 58602 const textColorSlug = textColorValue?.startsWith("var:preset|color|") ? textColorValue.substring("var:preset|color|".length) : void 0; 58603 const backgroundColorValue = style?.color?.background; 58604 const backgroundColorSlug = backgroundColorValue?.startsWith( 58605 "var:preset|color|" 58606 ) ? backgroundColorValue.substring("var:preset|color|".length) : void 0; 58607 const gradientValue = style?.color?.gradient; 58608 const gradientSlug = gradientValue?.startsWith("var:preset|gradient|") ? gradientValue.substring("var:preset|gradient|".length) : void 0; 58609 const updatedStyle = { ...style }; 58610 updatedStyle.color = { 58611 ...updatedStyle.color, 58612 text: textColorSlug ? void 0 : textColorValue, 58613 background: backgroundColorSlug ? void 0 : backgroundColorValue, 58614 gradient: gradientSlug ? void 0 : gradientValue 58615 }; 58616 return { 58617 style: cleanEmptyObject(updatedStyle), 58618 textColor: textColorSlug, 58619 backgroundColor: backgroundColorSlug, 58620 gradient: gradientSlug 58621 }; 58622 } 58623 function attributesToStyle2(attributes) { 58624 return { 58625 ...attributes.style, 58626 color: { 58627 ...attributes.style?.color, 58628 text: attributes.textColor ? "var:preset|color|" + attributes.textColor : attributes.style?.color?.text, 58629 background: attributes.backgroundColor ? "var:preset|color|" + attributes.backgroundColor : attributes.style?.color?.background, 58630 gradient: attributes.gradient ? "var:preset|gradient|" + attributes.gradient : attributes.style?.color?.gradient 58631 } 58632 }; 58633 } 58634 function ColorInspectorControl({ children, resetAllFilter }) { 58635 const attributesResetAllFilter = (0, import_element210.useCallback)( 58636 (attributes) => { 58637 const existingStyle = attributesToStyle2(attributes); 58638 const updatedStyle = resetAllFilter(existingStyle); 58639 return { 58640 ...attributes, 58641 ...styleToAttributes2(updatedStyle) 58642 }; 58643 }, 58644 [resetAllFilter] 58645 ); 58646 return /* @__PURE__ */ (0, import_jsx_runtime372.jsx)( 58647 inspector_controls_default, 58648 { 58649 group: "color", 58650 resetAllFilter: attributesResetAllFilter, 58651 children 58652 } 58653 ); 58654 } 58655 function ColorEdit({ 58656 clientId, 58657 name, 58658 setAttributes, 58659 settings: settings2, 58660 asWrapper, 58661 label, 58662 defaultControls 58663 }) { 58664 const isEnabled = useHasColorPanel(settings2); 58665 const { style, textColor, backgroundColor, gradient } = (0, import_data163.useSelect)( 58666 (select3) => { 58667 if (!isEnabled) { 58668 return {}; 58669 } 58670 const { 58671 style: _style, 58672 textColor: _textColor, 58673 backgroundColor: _backgroundColor, 58674 gradient: _gradient 58675 } = select3(store).getBlockAttributes(clientId) || {}; 58676 return { 58677 style: _style, 58678 textColor: _textColor, 58679 backgroundColor: _backgroundColor, 58680 gradient: _gradient 58681 }; 58682 }, 58683 [clientId, isEnabled] 58684 ); 58685 const value = (0, import_element210.useMemo)(() => { 58686 return attributesToStyle2({ 58687 style, 58688 textColor, 58689 backgroundColor, 58690 gradient 58691 }); 58692 }, [style, textColor, backgroundColor, gradient]); 58693 const onChange = (newStyle) => { 58694 setAttributes(styleToAttributes2(newStyle)); 58695 }; 58696 if (!isEnabled) { 58697 return null; 58698 } 58699 defaultControls = defaultControls ? defaultControls : (0, import_blocks91.getBlockSupport)(name, [ 58700 COLOR_SUPPORT_KEY2, 58701 "__experimentalDefaultControls" 58702 ]); 58703 const enableContrastChecking = import_element210.Platform.OS === "web" && !value?.color?.gradient && (settings2?.color?.text || settings2?.color?.link) && // Contrast checking is enabled by default. 58704 // Deactivating it requires `enableContrastChecker` to have 58705 // an explicit value of `false`. 58706 false !== (0, import_blocks91.getBlockSupport)(name, [ 58707 COLOR_SUPPORT_KEY2, 58708 "enableContrastChecker" 58709 ]); 58710 const Wrapper = asWrapper || ColorInspectorControl; 58711 return /* @__PURE__ */ (0, import_jsx_runtime372.jsx)( 58712 ColorPanel, 58713 { 58714 as: Wrapper, 58715 panelId: clientId, 58716 settings: settings2, 58717 value, 58718 onChange, 58719 defaultControls, 58720 label, 58721 enableContrastChecker: false !== (0, import_blocks91.getBlockSupport)(name, [ 58722 COLOR_SUPPORT_KEY2, 58723 "enableContrastChecker" 58724 ]), 58725 children: enableContrastChecking && /* @__PURE__ */ (0, import_jsx_runtime372.jsx)(BlockColorContrastChecker, { clientId }) 58726 } 58727 ); 58728 } 58729 function useBlockProps6({ 58730 name, 58731 backgroundColor, 58732 textColor, 58733 gradient, 58734 style 58735 }) { 58736 const [userPalette, themePalette, defaultPalette] = useSettings( 58737 "color.palette.custom", 58738 "color.palette.theme", 58739 "color.palette.default" 58740 ); 58741 const colors2 = (0, import_element210.useMemo)( 58742 () => [ 58743 ...userPalette || [], 58744 ...themePalette || [], 58745 ...defaultPalette || [] 58746 ], 58747 [userPalette, themePalette, defaultPalette] 58748 ); 58749 if (!hasColorSupport(name) || shouldSkipSerialization(name, COLOR_SUPPORT_KEY2)) { 58750 return {}; 58751 } 58752 const extraStyles = {}; 58753 if (textColor && !shouldSkipSerialization(name, COLOR_SUPPORT_KEY2, "text")) { 58754 extraStyles.color = getColorObjectByAttributeValues( 58755 colors2, 58756 textColor 58757 )?.color; 58758 } 58759 if (backgroundColor && !shouldSkipSerialization(name, COLOR_SUPPORT_KEY2, "background")) { 58760 extraStyles.backgroundColor = getColorObjectByAttributeValues( 58761 colors2, 58762 backgroundColor 58763 )?.color; 58764 } 58765 const saveProps = addSaveProps2({ style: extraStyles }, name, { 58766 textColor, 58767 backgroundColor, 58768 gradient, 58769 style 58770 }); 58771 const hasBackgroundValue = backgroundColor || style?.color?.background || gradient || style?.color?.gradient; 58772 return { 58773 ...saveProps, 58774 className: clsx_default( 58775 saveProps.className, 58776 // Add background image classes in the editor, if not already handled by background color values. 58777 !hasBackgroundValue && getBackgroundImageClasses(style) 58778 ) 58779 }; 58780 } 58781 var color_default = { 58782 useBlockProps: useBlockProps6, 58783 addSaveProps: addSaveProps2, 58784 attributeKeys: ["backgroundColor", "textColor", "gradient", "style"], 58785 hasSupport: hasColorSupport 58786 }; 58787 var MIGRATION_PATHS = { 58788 linkColor: [["style", "elements", "link", "color", "text"]], 58789 textColor: [["textColor"], ["style", "color", "text"]], 58790 backgroundColor: [ 58791 ["backgroundColor"], 58792 ["style", "color", "background"] 58793 ], 58794 gradient: [["gradient"], ["style", "color", "gradient"]] 58795 }; 58796 function addTransforms(result, source, index, results) { 58797 const destinationBlockType = result.name; 58798 const activeSupports = { 58799 linkColor: hasLinkColorSupport(destinationBlockType), 58800 textColor: hasTextColorSupport2(destinationBlockType), 58801 backgroundColor: hasBackgroundColorSupport2(destinationBlockType), 58802 gradient: hasGradientSupport2(destinationBlockType) 58803 }; 58804 return transformStyles2( 58805 activeSupports, 58806 MIGRATION_PATHS, 58807 result, 58808 source, 58809 index, 58810 results 58811 ); 58812 } 58813 (0, import_hooks12.addFilter)( 58814 "blocks.registerBlockType", 58815 "core/color/addAttribute", 58816 addAttributes2 58817 ); 58818 (0, import_hooks12.addFilter)( 58819 "blocks.switchToBlockType.transformedBlock", 58820 "core/color/addTransforms", 58821 addTransforms 58822 ); 58823 58824 // packages/block-editor/build-module/components/inspector-controls-tabs/styles-tab.js 58825 var import_jsx_runtime373 = __toESM(require_jsx_runtime()); 58826 function SectionBlockColorControls({ 58827 blockName, 58828 clientId, 58829 contentClientIds 58830 }) { 58831 const settings2 = useBlockSettings(blockName); 58832 const { updateBlockAttributes: updateBlockAttributes2 } = (0, import_data164.useDispatch)(store); 58833 const { hasButton, hasHeading } = (0, import_data164.useSelect)( 58834 (select3) => { 58835 const blockNames = select3(store).getBlockNamesByClientId( 58836 contentClientIds 58837 ); 58838 return { 58839 hasButton: blockNames.includes("core/button"), 58840 hasHeading: blockNames.includes("core/heading") 58841 }; 58842 }, 58843 [contentClientIds] 58844 ); 58845 const setAttributes = (newAttributes) => { 58846 updateBlockAttributes2(clientId, newAttributes); 58847 }; 58848 return /* @__PURE__ */ (0, import_jsx_runtime373.jsx)( 58849 ColorEdit, 58850 { 58851 clientId, 58852 name: blockName, 58853 settings: settings2, 58854 setAttributes, 58855 asWrapper: ColorToolsPanel, 58856 label: (0, import_i18n196.__)("Color"), 58857 defaultControls: { 58858 text: true, 58859 background: true, 58860 button: hasButton, 58861 heading: hasHeading 58862 } 58863 } 58864 ); 58865 } 58866 var StylesTab = ({ 58867 blockName, 58868 clientId, 58869 hasBlockStyles, 58870 isSectionBlock: isSectionBlock2, 58871 contentClientIds 58872 }) => { 58873 const borderPanelLabel = useBorderPanelLabel({ blockName }); 58874 return /* @__PURE__ */ (0, import_jsx_runtime373.jsxs)(import_jsx_runtime373.Fragment, { children: [ 58875 hasBlockStyles && /* @__PURE__ */ (0, import_jsx_runtime373.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime373.jsx)(import_components206.PanelBody, { title: (0, import_i18n196.__)("Styles"), children: /* @__PURE__ */ (0, import_jsx_runtime373.jsx)(block_styles_default, { clientId }) }) }), 58876 isSectionBlock2 && window?.__experimentalContentOnlyPatternInsertion && /* @__PURE__ */ (0, import_jsx_runtime373.jsx)( 58877 SectionBlockColorControls, 58878 { 58879 blockName, 58880 clientId, 58881 contentClientIds 58882 } 58883 ), 58884 !isSectionBlock2 && /* @__PURE__ */ (0, import_jsx_runtime373.jsxs)(import_jsx_runtime373.Fragment, { children: [ 58885 /* @__PURE__ */ (0, import_jsx_runtime373.jsx)( 58886 inspector_controls_default.Slot, 58887 { 58888 group: "color", 58889 label: (0, import_i18n196.__)("Color"), 58890 className: "color-block-support-panel__inner-wrapper" 58891 } 58892 ), 58893 /* @__PURE__ */ (0, import_jsx_runtime373.jsx)( 58894 inspector_controls_default.Slot, 58895 { 58896 group: "background", 58897 label: (0, import_i18n196.__)("Background image") 58898 } 58899 ), 58900 /* @__PURE__ */ (0, import_jsx_runtime373.jsx)(inspector_controls_default.Slot, { group: "filter" }), 58901 /* @__PURE__ */ (0, import_jsx_runtime373.jsx)( 58902 inspector_controls_default.Slot, 58903 { 58904 group: "typography", 58905 label: (0, import_i18n196.__)("Typography") 58906 } 58907 ), 58908 /* @__PURE__ */ (0, import_jsx_runtime373.jsx)( 58909 inspector_controls_default.Slot, 58910 { 58911 group: "dimensions", 58912 label: (0, import_i18n196.__)("Dimensions") 58913 } 58914 ), 58915 /* @__PURE__ */ (0, import_jsx_runtime373.jsx)( 58916 inspector_controls_default.Slot, 58917 { 58918 group: "border", 58919 label: borderPanelLabel 58920 } 58921 ), 58922 /* @__PURE__ */ (0, import_jsx_runtime373.jsx)(inspector_controls_default.Slot, { group: "styles" }) 58923 ] }) 58924 ] }); 58925 }; 58926 var styles_tab_default = StylesTab; 58927 58928 // packages/block-editor/build-module/components/inspector-controls-tabs/content-tab.js 58929 var import_components239 = __toESM(require_components()); 58930 var import_i18n219 = __toESM(require_i18n()); 58931 58932 // packages/block-editor/build-module/components/block-quick-navigation/index.js 58933 var import_data165 = __toESM(require_data()); 58934 var import_components207 = __toESM(require_components()); 58935 var import_jsx_runtime374 = __toESM(require_jsx_runtime()); 58936 function BlockQuickNavigation({ clientIds, onSelect }) { 58937 if (!clientIds.length) { 58938 return null; 58939 } 58940 return /* @__PURE__ */ (0, import_jsx_runtime374.jsx)(import_components207.__experimentalVStack, { spacing: 1, children: clientIds.map((clientId) => /* @__PURE__ */ (0, import_jsx_runtime374.jsx)( 58941 BlockQuickNavigationItem, 58942 { 58943 onSelect, 58944 clientId 58945 }, 58946 clientId 58947 )) }); 58948 } 58949 function BlockQuickNavigationItem({ clientId, onSelect }) { 58950 const blockInformation = useBlockDisplayInformation(clientId); 58951 const blockTitle = useBlockDisplayTitle({ 58952 clientId, 58953 context: "list-view" 58954 }); 58955 const { isSelected } = (0, import_data165.useSelect)( 58956 (select3) => { 58957 const { isBlockSelected: isBlockSelected2, hasSelectedInnerBlock: hasSelectedInnerBlock2 } = select3(store); 58958 return { 58959 isSelected: isBlockSelected2(clientId) || hasSelectedInnerBlock2( 58960 clientId, 58961 /* deep: */ 58962 true 58963 ) 58964 }; 58965 }, 58966 [clientId] 58967 ); 58968 const { selectBlock: selectBlock2 } = (0, import_data165.useDispatch)(store); 58969 return /* @__PURE__ */ (0, import_jsx_runtime374.jsx)( 58970 import_components207.Button, 58971 { 58972 __next40pxDefaultSize: true, 58973 className: "block-editor-block-quick-navigation__item", 58974 isPressed: isSelected, 58975 onClick: async () => { 58976 await selectBlock2(clientId); 58977 if (onSelect) { 58978 onSelect(clientId); 58979 } 58980 }, 58981 children: /* @__PURE__ */ (0, import_jsx_runtime374.jsxs)(import_components207.Flex, { children: [ 58982 /* @__PURE__ */ (0, import_jsx_runtime374.jsx)(import_components207.FlexItem, { children: /* @__PURE__ */ (0, import_jsx_runtime374.jsx)(block_icon_default, { icon: blockInformation?.icon }) }), 58983 /* @__PURE__ */ (0, import_jsx_runtime374.jsx)(import_components207.FlexBlock, { style: { textAlign: "left" }, children: /* @__PURE__ */ (0, import_jsx_runtime374.jsx)(import_components207.__experimentalTruncate, { children: blockTitle }) }) 58984 ] }) 58985 } 58986 ); 58987 } 58988 58989 // packages/block-editor/build-module/components/content-only-controls/index.js 58990 var import_blocks92 = __toESM(require_blocks()); 58991 var import_components238 = __toESM(require_components()); 58992 var import_data168 = __toESM(require_data()); 58993 var import_i18n218 = __toESM(require_i18n()); 58994 58995 // packages/dataviews/build-module/constants.js 58996 var import_i18n197 = __toESM(require_i18n()); 58997 var OPERATOR_IS_ANY = "isAny"; 58998 var OPERATOR_IS_NONE = "isNone"; 58999 var OPERATOR_IS_ALL = "isAll"; 59000 var OPERATOR_IS_NOT_ALL = "isNotAll"; 59001 var OPERATOR_BETWEEN = "between"; 59002 var OPERATOR_IN_THE_PAST = "inThePast"; 59003 var OPERATOR_OVER = "over"; 59004 var OPERATOR_IS = "is"; 59005 var OPERATOR_IS_NOT = "isNot"; 59006 var OPERATOR_LESS_THAN = "lessThan"; 59007 var OPERATOR_GREATER_THAN = "greaterThan"; 59008 var OPERATOR_LESS_THAN_OR_EQUAL = "lessThanOrEqual"; 59009 var OPERATOR_GREATER_THAN_OR_EQUAL = "greaterThanOrEqual"; 59010 var OPERATOR_BEFORE = "before"; 59011 var OPERATOR_AFTER = "after"; 59012 var OPERATOR_BEFORE_INC = "beforeInc"; 59013 var OPERATOR_AFTER_INC = "afterInc"; 59014 var OPERATOR_CONTAINS = "contains"; 59015 var OPERATOR_NOT_CONTAINS = "notContains"; 59016 var OPERATOR_STARTS_WITH = "startsWith"; 59017 var OPERATOR_ON = "on"; 59018 var OPERATOR_NOT_ON = "notOn"; 59019 var sortLabels = { 59020 asc: (0, import_i18n197.__)("Sort ascending"), 59021 desc: (0, import_i18n197.__)("Sort descending") 59022 }; 59023 59024 // packages/dataviews/build-module/lock-unlock.js 59025 var import_private_apis3 = __toESM(require_private_apis()); 59026 var { lock: lock3, unlock: unlock3 } = (0, import_private_apis3.__dangerousOptInToUnstableAPIsOnlyForCoreModules)( 59027 "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.", 59028 "@wordpress/dataviews" 59029 ); 59030 59031 // packages/dataviews/build-module/hooks/use-elements.js 59032 var import_element211 = __toESM(require_element()); 59033 var EMPTY_ARRAY14 = []; 59034 function useElements({ 59035 elements, 59036 getElements 59037 }) { 59038 const staticElements = Array.isArray(elements) && elements.length > 0 ? elements : EMPTY_ARRAY14; 59039 const [records, setRecords] = (0, import_element211.useState)(staticElements); 59040 const [isLoading, setIsLoading] = (0, import_element211.useState)(false); 59041 (0, import_element211.useEffect)(() => { 59042 if (!getElements) { 59043 setRecords(staticElements); 59044 return; 59045 } 59046 let cancelled = false; 59047 setIsLoading(true); 59048 getElements().then((fetchedElements) => { 59049 if (!cancelled) { 59050 const dynamicElements = Array.isArray(fetchedElements) && fetchedElements.length > 0 ? fetchedElements : staticElements; 59051 setRecords(dynamicElements); 59052 } 59053 }).catch(() => { 59054 if (!cancelled) { 59055 setRecords(staticElements); 59056 } 59057 }).finally(() => { 59058 if (!cancelled) { 59059 setIsLoading(false); 59060 } 59061 }); 59062 return () => { 59063 cancelled = true; 59064 }; 59065 }, [getElements, staticElements]); 59066 return { 59067 elements: records, 59068 isLoading 59069 }; 59070 } 59071 59072 // packages/dataviews/build-module/utils/operators.js 59073 var import_i18n198 = __toESM(require_i18n()); 59074 var import_element212 = __toESM(require_element()); 59075 var import_jsx_runtime375 = __toESM(require_jsx_runtime()); 59076 var filterTextWrappers = { 59077 Name: /* @__PURE__ */ (0, import_jsx_runtime375.jsx)("span", { className: "dataviews-filters__summary-filter-text-name" }), 59078 Value: /* @__PURE__ */ (0, import_jsx_runtime375.jsx)("span", { className: "dataviews-filters__summary-filter-text-value" }) 59079 }; 59080 var OPERATORS = [ 59081 { 59082 name: OPERATOR_IS_ANY, 59083 /* translators: DataViews operator name */ 59084 label: (0, import_i18n198.__)("Includes"), 59085 filterText: (filter, activeElements) => (0, import_element212.createInterpolateElement)( 59086 (0, import_i18n198.sprintf)( 59087 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is any: Admin, Editor". */ 59088 (0, import_i18n198.__)("<Name>%1$s includes: </Name><Value>%2$s</Value>"), 59089 filter.name, 59090 activeElements.map((element) => element.label).join(", ") 59091 ), 59092 filterTextWrappers 59093 ), 59094 selection: "multi" 59095 }, 59096 { 59097 name: OPERATOR_IS_NONE, 59098 /* translators: DataViews operator name */ 59099 label: (0, import_i18n198.__)("Is none of"), 59100 filterText: (filter, activeElements) => (0, import_element212.createInterpolateElement)( 59101 (0, import_i18n198.sprintf)( 59102 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is none of: Admin, Editor". */ 59103 (0, import_i18n198.__)("<Name>%1$s is none of: </Name><Value>%2$s</Value>"), 59104 filter.name, 59105 activeElements.map((element) => element.label).join(", ") 59106 ), 59107 filterTextWrappers 59108 ), 59109 selection: "multi" 59110 }, 59111 { 59112 name: OPERATOR_IS_ALL, 59113 /* translators: DataViews operator name */ 59114 label: (0, import_i18n198.__)("Includes all"), 59115 filterText: (filter, activeElements) => (0, import_element212.createInterpolateElement)( 59116 (0, import_i18n198.sprintf)( 59117 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author includes all: Admin, Editor". */ 59118 (0, import_i18n198.__)("<Name>%1$s includes all: </Name><Value>%2$s</Value>"), 59119 filter.name, 59120 activeElements.map((element) => element.label).join(", ") 59121 ), 59122 filterTextWrappers 59123 ), 59124 selection: "multi" 59125 }, 59126 { 59127 name: OPERATOR_IS_NOT_ALL, 59128 /* translators: DataViews operator name */ 59129 label: (0, import_i18n198.__)("Is none of"), 59130 filterText: (filter, activeElements) => (0, import_element212.createInterpolateElement)( 59131 (0, import_i18n198.sprintf)( 59132 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is none of: Admin, Editor". */ 59133 (0, import_i18n198.__)("<Name>%1$s is none of: </Name><Value>%2$s</Value>"), 59134 filter.name, 59135 activeElements.map((element) => element.label).join(", ") 59136 ), 59137 filterTextWrappers 59138 ), 59139 selection: "multi" 59140 }, 59141 { 59142 name: OPERATOR_BETWEEN, 59143 /* translators: DataViews operator name */ 59144 label: (0, import_i18n198.__)("Between (inc)"), 59145 filterText: (filter, activeElements) => (0, import_element212.createInterpolateElement)( 59146 (0, import_i18n198.sprintf)( 59147 /* 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". */ 59148 (0, import_i18n198.__)( 59149 "<Name>%1$s between (inc): </Name><Value>%2$s and %3$s</Value>" 59150 ), 59151 filter.name, 59152 activeElements[0].label[0], 59153 activeElements[0].label[1] 59154 ), 59155 filterTextWrappers 59156 ), 59157 selection: "custom" 59158 }, 59159 { 59160 name: OPERATOR_IN_THE_PAST, 59161 /* translators: DataViews operator name */ 59162 label: (0, import_i18n198.__)("In the past"), 59163 filterText: (filter, activeElements) => (0, import_element212.createInterpolateElement)( 59164 (0, import_i18n198.sprintf)( 59165 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "7 days"): "Date is in the past: 7 days". */ 59166 (0, import_i18n198.__)( 59167 "<Name>%1$s is in the past: </Name><Value>%2$s</Value>" 59168 ), 59169 filter.name, 59170 `$activeElements[0].value.value} $activeElements[0].value.unit}` 59171 ), 59172 filterTextWrappers 59173 ), 59174 selection: "custom" 59175 }, 59176 { 59177 name: OPERATOR_OVER, 59178 /* translators: DataViews operator name */ 59179 label: (0, import_i18n198.__)("Over"), 59180 filterText: (filter, activeElements) => (0, import_element212.createInterpolateElement)( 59181 (0, import_i18n198.sprintf)( 59182 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "7 days"): "Date is over: 7 days". */ 59183 (0, import_i18n198.__)("<Name>%1$s is over: </Name><Value>%2$s</Value>"), 59184 filter.name, 59185 `$activeElements[0].value.value} $activeElements[0].value.unit}` 59186 ), 59187 filterTextWrappers 59188 ), 59189 selection: "custom" 59190 }, 59191 { 59192 name: OPERATOR_IS, 59193 /* translators: DataViews operator name */ 59194 label: (0, import_i18n198.__)("Is"), 59195 filterText: (filter, activeElements) => (0, import_element212.createInterpolateElement)( 59196 (0, import_i18n198.sprintf)( 59197 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is: Admin". */ 59198 (0, import_i18n198.__)("<Name>%1$s is: </Name><Value>%2$s</Value>"), 59199 filter.name, 59200 activeElements[0].label 59201 ), 59202 filterTextWrappers 59203 ), 59204 selection: "single" 59205 }, 59206 { 59207 name: OPERATOR_IS_NOT, 59208 /* translators: DataViews operator name */ 59209 label: (0, import_i18n198.__)("Is not"), 59210 filterText: (filter, activeElements) => (0, import_element212.createInterpolateElement)( 59211 (0, import_i18n198.sprintf)( 59212 /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is not: Admin". */ 59213 (0, import_i18n198.__)("<Name>%1$s is not: </Name><Value>%2$s</Value>"), 59214 filter.name, 59215 activeElements[0].label 59216 ), 59217 filterTextWrappers 59218 ), 59219 selection: "single" 59220 }, 59221 { 59222 name: OPERATOR_LESS_THAN, 59223 /* translators: DataViews operator name */ 59224 label: (0, import_i18n198.__)("Less than"), 59225 filterText: (filter, activeElements) => (0, import_element212.createInterpolateElement)( 59226 (0, import_i18n198.sprintf)( 59227 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is less than: 10". */ 59228 (0, import_i18n198.__)("<Name>%1$s is less than: </Name><Value>%2$s</Value>"), 59229 filter.name, 59230 activeElements[0].label 59231 ), 59232 filterTextWrappers 59233 ), 59234 selection: "single" 59235 }, 59236 { 59237 name: OPERATOR_GREATER_THAN, 59238 /* translators: DataViews operator name */ 59239 label: (0, import_i18n198.__)("Greater than"), 59240 filterText: (filter, activeElements) => (0, import_element212.createInterpolateElement)( 59241 (0, import_i18n198.sprintf)( 59242 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is greater than: 10". */ 59243 (0, import_i18n198.__)( 59244 "<Name>%1$s is greater than: </Name><Value>%2$s</Value>" 59245 ), 59246 filter.name, 59247 activeElements[0].label 59248 ), 59249 filterTextWrappers 59250 ), 59251 selection: "single" 59252 }, 59253 { 59254 name: OPERATOR_LESS_THAN_OR_EQUAL, 59255 /* translators: DataViews operator name */ 59256 label: (0, import_i18n198.__)("Less than or equal"), 59257 filterText: (filter, activeElements) => (0, import_element212.createInterpolateElement)( 59258 (0, import_i18n198.sprintf)( 59259 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is less than or equal to: 10". */ 59260 (0, import_i18n198.__)( 59261 "<Name>%1$s is less than or equal to: </Name><Value>%2$s</Value>" 59262 ), 59263 filter.name, 59264 activeElements[0].label 59265 ), 59266 filterTextWrappers 59267 ), 59268 selection: "single" 59269 }, 59270 { 59271 name: OPERATOR_GREATER_THAN_OR_EQUAL, 59272 /* translators: DataViews operator name */ 59273 label: (0, import_i18n198.__)("Greater than or equal"), 59274 filterText: (filter, activeElements) => (0, import_element212.createInterpolateElement)( 59275 (0, import_i18n198.sprintf)( 59276 /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is greater than or equal to: 10". */ 59277 (0, import_i18n198.__)( 59278 "<Name>%1$s is greater than or equal to: </Name><Value>%2$s</Value>" 59279 ), 59280 filter.name, 59281 activeElements[0].label 59282 ), 59283 filterTextWrappers 59284 ), 59285 selection: "single" 59286 }, 59287 { 59288 name: OPERATOR_BEFORE, 59289 /* translators: DataViews operator name */ 59290 label: (0, import_i18n198.__)("Before"), 59291 filterText: (filter, activeElements) => (0, import_element212.createInterpolateElement)( 59292 (0, import_i18n198.sprintf)( 59293 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is before: 2024-01-01". */ 59294 (0, import_i18n198.__)("<Name>%1$s is before: </Name><Value>%2$s</Value>"), 59295 filter.name, 59296 activeElements[0].label 59297 ), 59298 filterTextWrappers 59299 ), 59300 selection: "single" 59301 }, 59302 { 59303 name: OPERATOR_AFTER, 59304 /* translators: DataViews operator name */ 59305 label: (0, import_i18n198.__)("After"), 59306 filterText: (filter, activeElements) => (0, import_element212.createInterpolateElement)( 59307 (0, import_i18n198.sprintf)( 59308 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is after: 2024-01-01". */ 59309 (0, import_i18n198.__)("<Name>%1$s is after: </Name><Value>%2$s</Value>"), 59310 filter.name, 59311 activeElements[0].label 59312 ), 59313 filterTextWrappers 59314 ), 59315 selection: "single" 59316 }, 59317 { 59318 name: OPERATOR_BEFORE_INC, 59319 /* translators: DataViews operator name */ 59320 label: (0, import_i18n198.__)("Before (inc)"), 59321 filterText: (filter, activeElements) => (0, import_element212.createInterpolateElement)( 59322 (0, import_i18n198.sprintf)( 59323 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is on or before: 2024-01-01". */ 59324 (0, import_i18n198.__)( 59325 "<Name>%1$s is on or before: </Name><Value>%2$s</Value>" 59326 ), 59327 filter.name, 59328 activeElements[0].label 59329 ), 59330 filterTextWrappers 59331 ), 59332 selection: "single" 59333 }, 59334 { 59335 name: OPERATOR_AFTER_INC, 59336 /* translators: DataViews operator name */ 59337 label: (0, import_i18n198.__)("After (inc)"), 59338 filterText: (filter, activeElements) => (0, import_element212.createInterpolateElement)( 59339 (0, import_i18n198.sprintf)( 59340 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is on or after: 2024-01-01". */ 59341 (0, import_i18n198.__)( 59342 "<Name>%1$s is on or after: </Name><Value>%2$s</Value>" 59343 ), 59344 filter.name, 59345 activeElements[0].label 59346 ), 59347 filterTextWrappers 59348 ), 59349 selection: "single" 59350 }, 59351 { 59352 name: OPERATOR_CONTAINS, 59353 /* translators: DataViews operator name */ 59354 label: (0, import_i18n198.__)("Contains"), 59355 filterText: (filter, activeElements) => (0, import_element212.createInterpolateElement)( 59356 (0, import_i18n198.sprintf)( 59357 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title contains: Hello". */ 59358 (0, import_i18n198.__)("<Name>%1$s contains: </Name><Value>%2$s</Value>"), 59359 filter.name, 59360 activeElements[0].label 59361 ), 59362 filterTextWrappers 59363 ), 59364 selection: "single" 59365 }, 59366 { 59367 name: OPERATOR_NOT_CONTAINS, 59368 /* translators: DataViews operator name */ 59369 label: (0, import_i18n198.__)("Doesn't contain"), 59370 filterText: (filter, activeElements) => (0, import_element212.createInterpolateElement)( 59371 (0, import_i18n198.sprintf)( 59372 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title doesn't contain: Hello". */ 59373 (0, import_i18n198.__)( 59374 "<Name>%1$s doesn't contain: </Name><Value>%2$s</Value>" 59375 ), 59376 filter.name, 59377 activeElements[0].label 59378 ), 59379 filterTextWrappers 59380 ), 59381 selection: "single" 59382 }, 59383 { 59384 name: OPERATOR_STARTS_WITH, 59385 /* translators: DataViews operator name */ 59386 label: (0, import_i18n198.__)("Starts with"), 59387 filterText: (filter, activeElements) => (0, import_element212.createInterpolateElement)( 59388 (0, import_i18n198.sprintf)( 59389 /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title starts with: Hello". */ 59390 (0, import_i18n198.__)("<Name>%1$s starts with: </Name><Value>%2$s</Value>"), 59391 filter.name, 59392 activeElements[0].label 59393 ), 59394 filterTextWrappers 59395 ), 59396 selection: "single" 59397 }, 59398 { 59399 name: OPERATOR_ON, 59400 /* translators: DataViews operator name */ 59401 label: (0, import_i18n198.__)("On"), 59402 filterText: (filter, activeElements) => (0, import_element212.createInterpolateElement)( 59403 (0, import_i18n198.sprintf)( 59404 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is: 2024-01-01". */ 59405 (0, import_i18n198.__)("<Name>%1$s is: </Name><Value>%2$s</Value>"), 59406 filter.name, 59407 activeElements[0].label 59408 ), 59409 filterTextWrappers 59410 ), 59411 selection: "single" 59412 }, 59413 { 59414 name: OPERATOR_NOT_ON, 59415 /* translators: DataViews operator name */ 59416 label: (0, import_i18n198.__)("Not on"), 59417 filterText: (filter, activeElements) => (0, import_element212.createInterpolateElement)( 59418 (0, import_i18n198.sprintf)( 59419 /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is not: 2024-01-01". */ 59420 (0, import_i18n198.__)("<Name>%1$s is not: </Name><Value>%2$s</Value>"), 59421 filter.name, 59422 activeElements[0].label 59423 ), 59424 filterTextWrappers 59425 ), 59426 selection: "single" 59427 } 59428 ]; 59429 var getAllOperatorNames = () => OPERATORS.map((op) => op.name); 59430 59431 // packages/dataviews/build-module/dataform-controls/checkbox.js 59432 var import_components208 = __toESM(require_components()); 59433 var import_element213 = __toESM(require_element()); 59434 59435 // packages/dataviews/build-module/dataform-controls/utils/get-custom-validity.js 59436 function getCustomValidity(isValid2, validity) { 59437 let customValidity; 59438 if (isValid2?.required && validity?.required) { 59439 customValidity = validity?.required?.message ? validity.required : void 0; 59440 } else if (isValid2?.pattern && validity?.pattern) { 59441 customValidity = validity.pattern; 59442 } else if (isValid2?.min && validity?.min) { 59443 customValidity = validity.min; 59444 } else if (isValid2?.max && validity?.max) { 59445 customValidity = validity.max; 59446 } else if (isValid2?.minLength && validity?.minLength) { 59447 customValidity = validity.minLength; 59448 } else if (isValid2?.maxLength && validity?.maxLength) { 59449 customValidity = validity.maxLength; 59450 } else if (isValid2?.elements && validity?.elements) { 59451 customValidity = validity.elements; 59452 } else if (validity?.custom) { 59453 customValidity = validity.custom; 59454 } 59455 return customValidity; 59456 } 59457 59458 // packages/dataviews/build-module/dataform-controls/checkbox.js 59459 var import_jsx_runtime376 = __toESM(require_jsx_runtime()); 59460 var { ValidatedCheckboxControl } = unlock3(import_components208.privateApis); 59461 function Checkbox({ 59462 field, 59463 onChange, 59464 data, 59465 hideLabelFromVision, 59466 validity 59467 }) { 59468 const { getValue, setValue, label, description, isValid: isValid2 } = field; 59469 const onChangeControl = (0, import_element213.useCallback)(() => { 59470 onChange( 59471 setValue({ item: data, value: !getValue({ item: data }) }) 59472 ); 59473 }, [data, getValue, onChange, setValue]); 59474 return /* @__PURE__ */ (0, import_jsx_runtime376.jsx)( 59475 ValidatedCheckboxControl, 59476 { 59477 required: !!field.isValid?.required, 59478 customValidity: getCustomValidity(isValid2, validity), 59479 hidden: hideLabelFromVision, 59480 label, 59481 help: description, 59482 checked: getValue({ item: data }), 59483 onChange: onChangeControl 59484 } 59485 ); 59486 } 59487 59488 // packages/dataviews/node_modules/date-fns/constants.js 59489 var daysInYear = 365.2425; 59490 var maxTime = Math.pow(10, 8) * 24 * 60 * 60 * 1e3; 59491 var minTime = -maxTime; 59492 var millisecondsInWeek = 6048e5; 59493 var millisecondsInDay = 864e5; 59494 var secondsInHour = 3600; 59495 var secondsInDay = secondsInHour * 24; 59496 var secondsInWeek = secondsInDay * 7; 59497 var secondsInYear = secondsInDay * daysInYear; 59498 var secondsInMonth = secondsInYear / 12; 59499 var secondsInQuarter = secondsInMonth * 3; 59500 var constructFromSymbol = Symbol.for("constructDateFrom"); 59501 59502 // packages/dataviews/node_modules/date-fns/constructFrom.js 59503 function constructFrom(date, value) { 59504 if (typeof date === "function") return date(value); 59505 if (date && typeof date === "object" && constructFromSymbol in date) 59506 return date[constructFromSymbol](value); 59507 if (date instanceof Date) return new date.constructor(value); 59508 return new Date(value); 59509 } 59510 59511 // packages/dataviews/node_modules/date-fns/toDate.js 59512 function toDate(argument, context) { 59513 return constructFrom(context || argument, argument); 59514 } 59515 59516 // packages/dataviews/node_modules/date-fns/addDays.js 59517 function addDays(date, amount, options) { 59518 const _date = toDate(date, options?.in); 59519 if (isNaN(amount)) return constructFrom(options?.in || date, NaN); 59520 if (!amount) return _date; 59521 _date.setDate(_date.getDate() + amount); 59522 return _date; 59523 } 59524 59525 // packages/dataviews/node_modules/date-fns/addMonths.js 59526 function addMonths(date, amount, options) { 59527 const _date = toDate(date, options?.in); 59528 if (isNaN(amount)) return constructFrom(options?.in || date, NaN); 59529 if (!amount) { 59530 return _date; 59531 } 59532 const dayOfMonth = _date.getDate(); 59533 const endOfDesiredMonth = constructFrom(options?.in || date, _date.getTime()); 59534 endOfDesiredMonth.setMonth(_date.getMonth() + amount + 1, 0); 59535 const daysInMonth = endOfDesiredMonth.getDate(); 59536 if (dayOfMonth >= daysInMonth) { 59537 return endOfDesiredMonth; 59538 } else { 59539 _date.setFullYear( 59540 endOfDesiredMonth.getFullYear(), 59541 endOfDesiredMonth.getMonth(), 59542 dayOfMonth 59543 ); 59544 return _date; 59545 } 59546 } 59547 59548 // packages/dataviews/node_modules/date-fns/_lib/defaultOptions.js 59549 var defaultOptions = {}; 59550 function getDefaultOptions() { 59551 return defaultOptions; 59552 } 59553 59554 // packages/dataviews/node_modules/date-fns/startOfWeek.js 59555 function startOfWeek(date, options) { 59556 const defaultOptions2 = getDefaultOptions(); 59557 const weekStartsOn = options?.weekStartsOn ?? options?.locale?.options?.weekStartsOn ?? defaultOptions2.weekStartsOn ?? defaultOptions2.locale?.options?.weekStartsOn ?? 0; 59558 const _date = toDate(date, options?.in); 59559 const day = _date.getDay(); 59560 const diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn; 59561 _date.setDate(_date.getDate() - diff); 59562 _date.setHours(0, 0, 0, 0); 59563 return _date; 59564 } 59565 59566 // packages/dataviews/node_modules/date-fns/startOfISOWeek.js 59567 function startOfISOWeek(date, options) { 59568 return startOfWeek(date, { ...options, weekStartsOn: 1 }); 59569 } 59570 59571 // packages/dataviews/node_modules/date-fns/getISOWeekYear.js 59572 function getISOWeekYear(date, options) { 59573 const _date = toDate(date, options?.in); 59574 const year = _date.getFullYear(); 59575 const fourthOfJanuaryOfNextYear = constructFrom(_date, 0); 59576 fourthOfJanuaryOfNextYear.setFullYear(year + 1, 0, 4); 59577 fourthOfJanuaryOfNextYear.setHours(0, 0, 0, 0); 59578 const startOfNextYear = startOfISOWeek(fourthOfJanuaryOfNextYear); 59579 const fourthOfJanuaryOfThisYear = constructFrom(_date, 0); 59580 fourthOfJanuaryOfThisYear.setFullYear(year, 0, 4); 59581 fourthOfJanuaryOfThisYear.setHours(0, 0, 0, 0); 59582 const startOfThisYear = startOfISOWeek(fourthOfJanuaryOfThisYear); 59583 if (_date.getTime() >= startOfNextYear.getTime()) { 59584 return year + 1; 59585 } else if (_date.getTime() >= startOfThisYear.getTime()) { 59586 return year; 59587 } else { 59588 return year - 1; 59589 } 59590 } 59591 59592 // packages/dataviews/node_modules/date-fns/_lib/getTimezoneOffsetInMilliseconds.js 59593 function getTimezoneOffsetInMilliseconds(date) { 59594 const _date = toDate(date); 59595 const utcDate = new Date( 59596 Date.UTC( 59597 _date.getFullYear(), 59598 _date.getMonth(), 59599 _date.getDate(), 59600 _date.getHours(), 59601 _date.getMinutes(), 59602 _date.getSeconds(), 59603 _date.getMilliseconds() 59604 ) 59605 ); 59606 utcDate.setUTCFullYear(_date.getFullYear()); 59607 return +date - +utcDate; 59608 } 59609 59610 // packages/dataviews/node_modules/date-fns/_lib/normalizeDates.js 59611 function normalizeDates(context, ...dates) { 59612 const normalize = constructFrom.bind( 59613 null, 59614 context || dates.find((date) => typeof date === "object") 59615 ); 59616 return dates.map(normalize); 59617 } 59618 59619 // packages/dataviews/node_modules/date-fns/startOfDay.js 59620 function startOfDay(date, options) { 59621 const _date = toDate(date, options?.in); 59622 _date.setHours(0, 0, 0, 0); 59623 return _date; 59624 } 59625 59626 // packages/dataviews/node_modules/date-fns/differenceInCalendarDays.js 59627 function differenceInCalendarDays(laterDate, earlierDate, options) { 59628 const [laterDate_, earlierDate_] = normalizeDates( 59629 options?.in, 59630 laterDate, 59631 earlierDate 59632 ); 59633 const laterStartOfDay = startOfDay(laterDate_); 59634 const earlierStartOfDay = startOfDay(earlierDate_); 59635 const laterTimestamp = +laterStartOfDay - getTimezoneOffsetInMilliseconds(laterStartOfDay); 59636 const earlierTimestamp = +earlierStartOfDay - getTimezoneOffsetInMilliseconds(earlierStartOfDay); 59637 return Math.round((laterTimestamp - earlierTimestamp) / millisecondsInDay); 59638 } 59639 59640 // packages/dataviews/node_modules/date-fns/startOfISOWeekYear.js 59641 function startOfISOWeekYear(date, options) { 59642 const year = getISOWeekYear(date, options); 59643 const fourthOfJanuary = constructFrom(options?.in || date, 0); 59644 fourthOfJanuary.setFullYear(year, 0, 4); 59645 fourthOfJanuary.setHours(0, 0, 0, 0); 59646 return startOfISOWeek(fourthOfJanuary); 59647 } 59648 59649 // packages/dataviews/node_modules/date-fns/addYears.js 59650 function addYears(date, amount, options) { 59651 return addMonths(date, amount * 12, options); 59652 } 59653 59654 // packages/dataviews/node_modules/date-fns/isDate.js 59655 function isDate(value) { 59656 return value instanceof Date || typeof value === "object" && Object.prototype.toString.call(value) === "[object Date]"; 59657 } 59658 59659 // packages/dataviews/node_modules/date-fns/isValid.js 59660 function isValid(date) { 59661 return !(!isDate(date) && typeof date !== "number" || isNaN(+toDate(date))); 59662 } 59663 59664 // packages/dataviews/node_modules/date-fns/startOfMonth.js 59665 function startOfMonth(date, options) { 59666 const _date = toDate(date, options?.in); 59667 _date.setDate(1); 59668 _date.setHours(0, 0, 0, 0); 59669 return _date; 59670 } 59671 59672 // packages/dataviews/node_modules/date-fns/startOfYear.js 59673 function startOfYear(date, options) { 59674 const date_ = toDate(date, options?.in); 59675 date_.setFullYear(date_.getFullYear(), 0, 1); 59676 date_.setHours(0, 0, 0, 0); 59677 return date_; 59678 } 59679 59680 // packages/dataviews/node_modules/date-fns/locale/en-US/_lib/formatDistance.js 59681 var formatDistanceLocale = { 59682 lessThanXSeconds: { 59683 one: "less than a second", 59684 other: "less than {{count}} seconds" 59685 }, 59686 xSeconds: { 59687 one: "1 second", 59688 other: "{{count}} seconds" 59689 }, 59690 halfAMinute: "half a minute", 59691 lessThanXMinutes: { 59692 one: "less than a minute", 59693 other: "less than {{count}} minutes" 59694 }, 59695 xMinutes: { 59696 one: "1 minute", 59697 other: "{{count}} minutes" 59698 }, 59699 aboutXHours: { 59700 one: "about 1 hour", 59701 other: "about {{count}} hours" 59702 }, 59703 xHours: { 59704 one: "1 hour", 59705 other: "{{count}} hours" 59706 }, 59707 xDays: { 59708 one: "1 day", 59709 other: "{{count}} days" 59710 }, 59711 aboutXWeeks: { 59712 one: "about 1 week", 59713 other: "about {{count}} weeks" 59714 }, 59715 xWeeks: { 59716 one: "1 week", 59717 other: "{{count}} weeks" 59718 }, 59719 aboutXMonths: { 59720 one: "about 1 month", 59721 other: "about {{count}} months" 59722 }, 59723 xMonths: { 59724 one: "1 month", 59725 other: "{{count}} months" 59726 }, 59727 aboutXYears: { 59728 one: "about 1 year", 59729 other: "about {{count}} years" 59730 }, 59731 xYears: { 59732 one: "1 year", 59733 other: "{{count}} years" 59734 }, 59735 overXYears: { 59736 one: "over 1 year", 59737 other: "over {{count}} years" 59738 }, 59739 almostXYears: { 59740 one: "almost 1 year", 59741 other: "almost {{count}} years" 59742 } 59743 }; 59744 var formatDistance = (token, count, options) => { 59745 let result; 59746 const tokenValue = formatDistanceLocale[token]; 59747 if (typeof tokenValue === "string") { 59748 result = tokenValue; 59749 } else if (count === 1) { 59750 result = tokenValue.one; 59751 } else { 59752 result = tokenValue.other.replace("{{count}}", count.toString()); 59753 } 59754 if (options?.addSuffix) { 59755 if (options.comparison && options.comparison > 0) { 59756 return "in " + result; 59757 } else { 59758 return result + " ago"; 59759 } 59760 } 59761 return result; 59762 }; 59763 59764 // packages/dataviews/node_modules/date-fns/locale/_lib/buildFormatLongFn.js 59765 function buildFormatLongFn(args) { 59766 return (options = {}) => { 59767 const width = options.width ? String(options.width) : args.defaultWidth; 59768 const format6 = args.formats[width] || args.formats[args.defaultWidth]; 59769 return format6; 59770 }; 59771 } 59772 59773 // packages/dataviews/node_modules/date-fns/locale/en-US/_lib/formatLong.js 59774 var dateFormats = { 59775 full: "EEEE, MMMM do, y", 59776 long: "MMMM do, y", 59777 medium: "MMM d, y", 59778 short: "MM/dd/yyyy" 59779 }; 59780 var timeFormats = { 59781 full: "h:mm:ss a zzzz", 59782 long: "h:mm:ss a z", 59783 medium: "h:mm:ss a", 59784 short: "h:mm a" 59785 }; 59786 var dateTimeFormats = { 59787 full: "{{date}} 'at' {{time}}", 59788 long: "{{date}} 'at' {{time}}", 59789 medium: "{{date}}, {{time}}", 59790 short: "{{date}}, {{time}}" 59791 }; 59792 var formatLong = { 59793 date: buildFormatLongFn({ 59794 formats: dateFormats, 59795 defaultWidth: "full" 59796 }), 59797 time: buildFormatLongFn({ 59798 formats: timeFormats, 59799 defaultWidth: "full" 59800 }), 59801 dateTime: buildFormatLongFn({ 59802 formats: dateTimeFormats, 59803 defaultWidth: "full" 59804 }) 59805 }; 59806 59807 // packages/dataviews/node_modules/date-fns/locale/en-US/_lib/formatRelative.js 59808 var formatRelativeLocale = { 59809 lastWeek: "'last' eeee 'at' p", 59810 yesterday: "'yesterday at' p", 59811 today: "'today at' p", 59812 tomorrow: "'tomorrow at' p", 59813 nextWeek: "eeee 'at' p", 59814 other: "P" 59815 }; 59816 var formatRelative = (token, _date, _baseDate, _options) => formatRelativeLocale[token]; 59817 59818 // packages/dataviews/node_modules/date-fns/locale/_lib/buildLocalizeFn.js 59819 function buildLocalizeFn(args) { 59820 return (value, options) => { 59821 const context = options?.context ? String(options.context) : "standalone"; 59822 let valuesArray; 59823 if (context === "formatting" && args.formattingValues) { 59824 const defaultWidth = args.defaultFormattingWidth || args.defaultWidth; 59825 const width = options?.width ? String(options.width) : defaultWidth; 59826 valuesArray = args.formattingValues[width] || args.formattingValues[defaultWidth]; 59827 } else { 59828 const defaultWidth = args.defaultWidth; 59829 const width = options?.width ? String(options.width) : args.defaultWidth; 59830 valuesArray = args.values[width] || args.values[defaultWidth]; 59831 } 59832 const index = args.argumentCallback ? args.argumentCallback(value) : value; 59833 return valuesArray[index]; 59834 }; 59835 } 59836 59837 // packages/dataviews/node_modules/date-fns/locale/en-US/_lib/localize.js 59838 var eraValues = { 59839 narrow: ["B", "A"], 59840 abbreviated: ["BC", "AD"], 59841 wide: ["Before Christ", "Anno Domini"] 59842 }; 59843 var quarterValues = { 59844 narrow: ["1", "2", "3", "4"], 59845 abbreviated: ["Q1", "Q2", "Q3", "Q4"], 59846 wide: ["1st quarter", "2nd quarter", "3rd quarter", "4th quarter"] 59847 }; 59848 var monthValues = { 59849 narrow: ["J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"], 59850 abbreviated: [ 59851 "Jan", 59852 "Feb", 59853 "Mar", 59854 "Apr", 59855 "May", 59856 "Jun", 59857 "Jul", 59858 "Aug", 59859 "Sep", 59860 "Oct", 59861 "Nov", 59862 "Dec" 59863 ], 59864 wide: [ 59865 "January", 59866 "February", 59867 "March", 59868 "April", 59869 "May", 59870 "June", 59871 "July", 59872 "August", 59873 "September", 59874 "October", 59875 "November", 59876 "December" 59877 ] 59878 }; 59879 var dayValues = { 59880 narrow: ["S", "M", "T", "W", "T", "F", "S"], 59881 short: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"], 59882 abbreviated: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], 59883 wide: [ 59884 "Sunday", 59885 "Monday", 59886 "Tuesday", 59887 "Wednesday", 59888 "Thursday", 59889 "Friday", 59890 "Saturday" 59891 ] 59892 }; 59893 var dayPeriodValues = { 59894 narrow: { 59895 am: "a", 59896 pm: "p", 59897 midnight: "mi", 59898 noon: "n", 59899 morning: "morning", 59900 afternoon: "afternoon", 59901 evening: "evening", 59902 night: "night" 59903 }, 59904 abbreviated: { 59905 am: "AM", 59906 pm: "PM", 59907 midnight: "midnight", 59908 noon: "noon", 59909 morning: "morning", 59910 afternoon: "afternoon", 59911 evening: "evening", 59912 night: "night" 59913 }, 59914 wide: { 59915 am: "a.m.", 59916 pm: "p.m.", 59917 midnight: "midnight", 59918 noon: "noon", 59919 morning: "morning", 59920 afternoon: "afternoon", 59921 evening: "evening", 59922 night: "night" 59923 } 59924 }; 59925 var formattingDayPeriodValues = { 59926 narrow: { 59927 am: "a", 59928 pm: "p", 59929 midnight: "mi", 59930 noon: "n", 59931 morning: "in the morning", 59932 afternoon: "in the afternoon", 59933 evening: "in the evening", 59934 night: "at night" 59935 }, 59936 abbreviated: { 59937 am: "AM", 59938 pm: "PM", 59939 midnight: "midnight", 59940 noon: "noon", 59941 morning: "in the morning", 59942 afternoon: "in the afternoon", 59943 evening: "in the evening", 59944 night: "at night" 59945 }, 59946 wide: { 59947 am: "a.m.", 59948 pm: "p.m.", 59949 midnight: "midnight", 59950 noon: "noon", 59951 morning: "in the morning", 59952 afternoon: "in the afternoon", 59953 evening: "in the evening", 59954 night: "at night" 59955 } 59956 }; 59957 var ordinalNumber = (dirtyNumber, _options) => { 59958 const number = Number(dirtyNumber); 59959 const rem100 = number % 100; 59960 if (rem100 > 20 || rem100 < 10) { 59961 switch (rem100 % 10) { 59962 case 1: 59963 return number + "st"; 59964 case 2: 59965 return number + "nd"; 59966 case 3: 59967 return number + "rd"; 59968 } 59969 } 59970 return number + "th"; 59971 }; 59972 var localize = { 59973 ordinalNumber, 59974 era: buildLocalizeFn({ 59975 values: eraValues, 59976 defaultWidth: "wide" 59977 }), 59978 quarter: buildLocalizeFn({ 59979 values: quarterValues, 59980 defaultWidth: "wide", 59981 argumentCallback: (quarter) => quarter - 1 59982 }), 59983 month: buildLocalizeFn({ 59984 values: monthValues, 59985 defaultWidth: "wide" 59986 }), 59987 day: buildLocalizeFn({ 59988 values: dayValues, 59989 defaultWidth: "wide" 59990 }), 59991 dayPeriod: buildLocalizeFn({ 59992 values: dayPeriodValues, 59993 defaultWidth: "wide", 59994 formattingValues: formattingDayPeriodValues, 59995 defaultFormattingWidth: "wide" 59996 }) 59997 }; 59998 59999 // packages/dataviews/node_modules/date-fns/locale/_lib/buildMatchFn.js 60000 function buildMatchFn(args) { 60001 return (string, options = {}) => { 60002 const width = options.width; 60003 const matchPattern = width && args.matchPatterns[width] || args.matchPatterns[args.defaultMatchWidth]; 60004 const matchResult = string.match(matchPattern); 60005 if (!matchResult) { 60006 return null; 60007 } 60008 const matchedString = matchResult[0]; 60009 const parsePatterns = width && args.parsePatterns[width] || args.parsePatterns[args.defaultParseWidth]; 60010 const key = Array.isArray(parsePatterns) ? findIndex2(parsePatterns, (pattern) => pattern.test(matchedString)) : ( 60011 // [TODO] -- I challenge you to fix the type 60012 findKey(parsePatterns, (pattern) => pattern.test(matchedString)) 60013 ); 60014 let value; 60015 value = args.valueCallback ? args.valueCallback(key) : key; 60016 value = options.valueCallback ? ( 60017 // [TODO] -- I challenge you to fix the type 60018 options.valueCallback(value) 60019 ) : value; 60020 const rest = string.slice(matchedString.length); 60021 return { value, rest }; 60022 }; 60023 } 60024 function findKey(object, predicate) { 60025 for (const key in object) { 60026 if (Object.prototype.hasOwnProperty.call(object, key) && predicate(object[key])) { 60027 return key; 60028 } 60029 } 60030 return void 0; 60031 } 60032 function findIndex2(array, predicate) { 60033 for (let key = 0; key < array.length; key++) { 60034 if (predicate(array[key])) { 60035 return key; 60036 } 60037 } 60038 return void 0; 60039 } 60040 60041 // packages/dataviews/node_modules/date-fns/locale/_lib/buildMatchPatternFn.js 60042 function buildMatchPatternFn(args) { 60043 return (string, options = {}) => { 60044 const matchResult = string.match(args.matchPattern); 60045 if (!matchResult) return null; 60046 const matchedString = matchResult[0]; 60047 const parseResult = string.match(args.parsePattern); 60048 if (!parseResult) return null; 60049 let value = args.valueCallback ? args.valueCallback(parseResult[0]) : parseResult[0]; 60050 value = options.valueCallback ? options.valueCallback(value) : value; 60051 const rest = string.slice(matchedString.length); 60052 return { value, rest }; 60053 }; 60054 } 60055 60056 // packages/dataviews/node_modules/date-fns/locale/en-US/_lib/match.js 60057 var matchOrdinalNumberPattern = /^(\d+)(th|st|nd|rd)?/i; 60058 var parseOrdinalNumberPattern = /\d+/i; 60059 var matchEraPatterns = { 60060 narrow: /^(b|a)/i, 60061 abbreviated: /^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i, 60062 wide: /^(before christ|before common era|anno domini|common era)/i 60063 }; 60064 var parseEraPatterns = { 60065 any: [/^b/i, /^(a|c)/i] 60066 }; 60067 var matchQuarterPatterns = { 60068 narrow: /^[1234]/i, 60069 abbreviated: /^q[1234]/i, 60070 wide: /^[1234](th|st|nd|rd)? quarter/i 60071 }; 60072 var parseQuarterPatterns = { 60073 any: [/1/i, /2/i, /3/i, /4/i] 60074 }; 60075 var matchMonthPatterns = { 60076 narrow: /^[jfmasond]/i, 60077 abbreviated: /^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i, 60078 wide: /^(january|february|march|april|may|june|july|august|september|october|november|december)/i 60079 }; 60080 var parseMonthPatterns = { 60081 narrow: [ 60082 /^j/i, 60083 /^f/i, 60084 /^m/i, 60085 /^a/i, 60086 /^m/i, 60087 /^j/i, 60088 /^j/i, 60089 /^a/i, 60090 /^s/i, 60091 /^o/i, 60092 /^n/i, 60093 /^d/i 60094 ], 60095 any: [ 60096 /^ja/i, 60097 /^f/i, 60098 /^mar/i, 60099 /^ap/i, 60100 /^may/i, 60101 /^jun/i, 60102 /^jul/i, 60103 /^au/i, 60104 /^s/i, 60105 /^o/i, 60106 /^n/i, 60107 /^d/i 60108 ] 60109 }; 60110 var matchDayPatterns = { 60111 narrow: /^[smtwf]/i, 60112 short: /^(su|mo|tu|we|th|fr|sa)/i, 60113 abbreviated: /^(sun|mon|tue|wed|thu|fri|sat)/i, 60114 wide: /^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i 60115 }; 60116 var parseDayPatterns = { 60117 narrow: [/^s/i, /^m/i, /^t/i, /^w/i, /^t/i, /^f/i, /^s/i], 60118 any: [/^su/i, /^m/i, /^tu/i, /^w/i, /^th/i, /^f/i, /^sa/i] 60119 }; 60120 var matchDayPeriodPatterns = { 60121 narrow: /^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i, 60122 any: /^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i 60123 }; 60124 var parseDayPeriodPatterns = { 60125 any: { 60126 am: /^a/i, 60127 pm: /^p/i, 60128 midnight: /^mi/i, 60129 noon: /^no/i, 60130 morning: /morning/i, 60131 afternoon: /afternoon/i, 60132 evening: /evening/i, 60133 night: /night/i 60134 } 60135 }; 60136 var match = { 60137 ordinalNumber: buildMatchPatternFn({ 60138 matchPattern: matchOrdinalNumberPattern, 60139 parsePattern: parseOrdinalNumberPattern, 60140 valueCallback: (value) => parseInt(value, 10) 60141 }), 60142 era: buildMatchFn({ 60143 matchPatterns: matchEraPatterns, 60144 defaultMatchWidth: "wide", 60145 parsePatterns: parseEraPatterns, 60146 defaultParseWidth: "any" 60147 }), 60148 quarter: buildMatchFn({ 60149 matchPatterns: matchQuarterPatterns, 60150 defaultMatchWidth: "wide", 60151 parsePatterns: parseQuarterPatterns, 60152 defaultParseWidth: "any", 60153 valueCallback: (index) => index + 1 60154 }), 60155 month: buildMatchFn({ 60156 matchPatterns: matchMonthPatterns, 60157 defaultMatchWidth: "wide", 60158 parsePatterns: parseMonthPatterns, 60159 defaultParseWidth: "any" 60160 }), 60161 day: buildMatchFn({ 60162 matchPatterns: matchDayPatterns, 60163 defaultMatchWidth: "wide", 60164 parsePatterns: parseDayPatterns, 60165 defaultParseWidth: "any" 60166 }), 60167 dayPeriod: buildMatchFn({ 60168 matchPatterns: matchDayPeriodPatterns, 60169 defaultMatchWidth: "any", 60170 parsePatterns: parseDayPeriodPatterns, 60171 defaultParseWidth: "any" 60172 }) 60173 }; 60174 60175 // packages/dataviews/node_modules/date-fns/locale/en-US.js 60176 var enUS = { 60177 code: "en-US", 60178 formatDistance, 60179 formatLong, 60180 formatRelative, 60181 localize, 60182 match, 60183 options: { 60184 weekStartsOn: 0, 60185 firstWeekContainsDate: 1 60186 } 60187 }; 60188 60189 // packages/dataviews/node_modules/date-fns/getDayOfYear.js 60190 function getDayOfYear(date, options) { 60191 const _date = toDate(date, options?.in); 60192 const diff = differenceInCalendarDays(_date, startOfYear(_date)); 60193 const dayOfYear = diff + 1; 60194 return dayOfYear; 60195 } 60196 60197 // packages/dataviews/node_modules/date-fns/getISOWeek.js 60198 function getISOWeek(date, options) { 60199 const _date = toDate(date, options?.in); 60200 const diff = +startOfISOWeek(_date) - +startOfISOWeekYear(_date); 60201 return Math.round(diff / millisecondsInWeek) + 1; 60202 } 60203 60204 // packages/dataviews/node_modules/date-fns/getWeekYear.js 60205 function getWeekYear(date, options) { 60206 const _date = toDate(date, options?.in); 60207 const year = _date.getFullYear(); 60208 const defaultOptions2 = getDefaultOptions(); 60209 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1; 60210 const firstWeekOfNextYear = constructFrom(options?.in || date, 0); 60211 firstWeekOfNextYear.setFullYear(year + 1, 0, firstWeekContainsDate); 60212 firstWeekOfNextYear.setHours(0, 0, 0, 0); 60213 const startOfNextYear = startOfWeek(firstWeekOfNextYear, options); 60214 const firstWeekOfThisYear = constructFrom(options?.in || date, 0); 60215 firstWeekOfThisYear.setFullYear(year, 0, firstWeekContainsDate); 60216 firstWeekOfThisYear.setHours(0, 0, 0, 0); 60217 const startOfThisYear = startOfWeek(firstWeekOfThisYear, options); 60218 if (+_date >= +startOfNextYear) { 60219 return year + 1; 60220 } else if (+_date >= +startOfThisYear) { 60221 return year; 60222 } else { 60223 return year - 1; 60224 } 60225 } 60226 60227 // packages/dataviews/node_modules/date-fns/startOfWeekYear.js 60228 function startOfWeekYear(date, options) { 60229 const defaultOptions2 = getDefaultOptions(); 60230 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1; 60231 const year = getWeekYear(date, options); 60232 const firstWeek = constructFrom(options?.in || date, 0); 60233 firstWeek.setFullYear(year, 0, firstWeekContainsDate); 60234 firstWeek.setHours(0, 0, 0, 0); 60235 const _date = startOfWeek(firstWeek, options); 60236 return _date; 60237 } 60238 60239 // packages/dataviews/node_modules/date-fns/getWeek.js 60240 function getWeek(date, options) { 60241 const _date = toDate(date, options?.in); 60242 const diff = +startOfWeek(_date, options) - +startOfWeekYear(_date, options); 60243 return Math.round(diff / millisecondsInWeek) + 1; 60244 } 60245 60246 // packages/dataviews/node_modules/date-fns/_lib/addLeadingZeros.js 60247 function addLeadingZeros(number, targetLength) { 60248 const sign = number < 0 ? "-" : ""; 60249 const output = Math.abs(number).toString().padStart(targetLength, "0"); 60250 return sign + output; 60251 } 60252 60253 // packages/dataviews/node_modules/date-fns/_lib/format/lightFormatters.js 60254 var lightFormatters = { 60255 // Year 60256 y(date, token) { 60257 const signedYear = date.getFullYear(); 60258 const year = signedYear > 0 ? signedYear : 1 - signedYear; 60259 return addLeadingZeros(token === "yy" ? year % 100 : year, token.length); 60260 }, 60261 // Month 60262 M(date, token) { 60263 const month = date.getMonth(); 60264 return token === "M" ? String(month + 1) : addLeadingZeros(month + 1, 2); 60265 }, 60266 // Day of the month 60267 d(date, token) { 60268 return addLeadingZeros(date.getDate(), token.length); 60269 }, 60270 // AM or PM 60271 a(date, token) { 60272 const dayPeriodEnumValue = date.getHours() / 12 >= 1 ? "pm" : "am"; 60273 switch (token) { 60274 case "a": 60275 case "aa": 60276 return dayPeriodEnumValue.toUpperCase(); 60277 case "aaa": 60278 return dayPeriodEnumValue; 60279 case "aaaaa": 60280 return dayPeriodEnumValue[0]; 60281 case "aaaa": 60282 default: 60283 return dayPeriodEnumValue === "am" ? "a.m." : "p.m."; 60284 } 60285 }, 60286 // Hour [1-12] 60287 h(date, token) { 60288 return addLeadingZeros(date.getHours() % 12 || 12, token.length); 60289 }, 60290 // Hour [0-23] 60291 H(date, token) { 60292 return addLeadingZeros(date.getHours(), token.length); 60293 }, 60294 // Minute 60295 m(date, token) { 60296 return addLeadingZeros(date.getMinutes(), token.length); 60297 }, 60298 // Second 60299 s(date, token) { 60300 return addLeadingZeros(date.getSeconds(), token.length); 60301 }, 60302 // Fraction of second 60303 S(date, token) { 60304 const numberOfDigits = token.length; 60305 const milliseconds = date.getMilliseconds(); 60306 const fractionalSeconds = Math.trunc( 60307 milliseconds * Math.pow(10, numberOfDigits - 3) 60308 ); 60309 return addLeadingZeros(fractionalSeconds, token.length); 60310 } 60311 }; 60312 60313 // packages/dataviews/node_modules/date-fns/_lib/format/formatters.js 60314 var dayPeriodEnum = { 60315 am: "am", 60316 pm: "pm", 60317 midnight: "midnight", 60318 noon: "noon", 60319 morning: "morning", 60320 afternoon: "afternoon", 60321 evening: "evening", 60322 night: "night" 60323 }; 60324 var formatters = { 60325 // Era 60326 G: function(date, token, localize2) { 60327 const era = date.getFullYear() > 0 ? 1 : 0; 60328 switch (token) { 60329 // AD, BC 60330 case "G": 60331 case "GG": 60332 case "GGG": 60333 return localize2.era(era, { width: "abbreviated" }); 60334 // A, B 60335 case "GGGGG": 60336 return localize2.era(era, { width: "narrow" }); 60337 // Anno Domini, Before Christ 60338 case "GGGG": 60339 default: 60340 return localize2.era(era, { width: "wide" }); 60341 } 60342 }, 60343 // Year 60344 y: function(date, token, localize2) { 60345 if (token === "yo") { 60346 const signedYear = date.getFullYear(); 60347 const year = signedYear > 0 ? signedYear : 1 - signedYear; 60348 return localize2.ordinalNumber(year, { unit: "year" }); 60349 } 60350 return lightFormatters.y(date, token); 60351 }, 60352 // Local week-numbering year 60353 Y: function(date, token, localize2, options) { 60354 const signedWeekYear = getWeekYear(date, options); 60355 const weekYear = signedWeekYear > 0 ? signedWeekYear : 1 - signedWeekYear; 60356 if (token === "YY") { 60357 const twoDigitYear = weekYear % 100; 60358 return addLeadingZeros(twoDigitYear, 2); 60359 } 60360 if (token === "Yo") { 60361 return localize2.ordinalNumber(weekYear, { unit: "year" }); 60362 } 60363 return addLeadingZeros(weekYear, token.length); 60364 }, 60365 // ISO week-numbering year 60366 R: function(date, token) { 60367 const isoWeekYear = getISOWeekYear(date); 60368 return addLeadingZeros(isoWeekYear, token.length); 60369 }, 60370 // Extended year. This is a single number designating the year of this calendar system. 60371 // The main difference between `y` and `u` localizers are B.C. years: 60372 // | Year | `y` | `u` | 60373 // |------|-----|-----| 60374 // | AC 1 | 1 | 1 | 60375 // | BC 1 | 1 | 0 | 60376 // | BC 2 | 2 | -1 | 60377 // Also `yy` always returns the last two digits of a year, 60378 // while `uu` pads single digit years to 2 characters and returns other years unchanged. 60379 u: function(date, token) { 60380 const year = date.getFullYear(); 60381 return addLeadingZeros(year, token.length); 60382 }, 60383 // Quarter 60384 Q: function(date, token, localize2) { 60385 const quarter = Math.ceil((date.getMonth() + 1) / 3); 60386 switch (token) { 60387 // 1, 2, 3, 4 60388 case "Q": 60389 return String(quarter); 60390 // 01, 02, 03, 04 60391 case "QQ": 60392 return addLeadingZeros(quarter, 2); 60393 // 1st, 2nd, 3rd, 4th 60394 case "Qo": 60395 return localize2.ordinalNumber(quarter, { unit: "quarter" }); 60396 // Q1, Q2, Q3, Q4 60397 case "QQQ": 60398 return localize2.quarter(quarter, { 60399 width: "abbreviated", 60400 context: "formatting" 60401 }); 60402 // 1, 2, 3, 4 (narrow quarter; could be not numerical) 60403 case "QQQQQ": 60404 return localize2.quarter(quarter, { 60405 width: "narrow", 60406 context: "formatting" 60407 }); 60408 // 1st quarter, 2nd quarter, ... 60409 case "QQQQ": 60410 default: 60411 return localize2.quarter(quarter, { 60412 width: "wide", 60413 context: "formatting" 60414 }); 60415 } 60416 }, 60417 // Stand-alone quarter 60418 q: function(date, token, localize2) { 60419 const quarter = Math.ceil((date.getMonth() + 1) / 3); 60420 switch (token) { 60421 // 1, 2, 3, 4 60422 case "q": 60423 return String(quarter); 60424 // 01, 02, 03, 04 60425 case "qq": 60426 return addLeadingZeros(quarter, 2); 60427 // 1st, 2nd, 3rd, 4th 60428 case "qo": 60429 return localize2.ordinalNumber(quarter, { unit: "quarter" }); 60430 // Q1, Q2, Q3, Q4 60431 case "qqq": 60432 return localize2.quarter(quarter, { 60433 width: "abbreviated", 60434 context: "standalone" 60435 }); 60436 // 1, 2, 3, 4 (narrow quarter; could be not numerical) 60437 case "qqqqq": 60438 return localize2.quarter(quarter, { 60439 width: "narrow", 60440 context: "standalone" 60441 }); 60442 // 1st quarter, 2nd quarter, ... 60443 case "qqqq": 60444 default: 60445 return localize2.quarter(quarter, { 60446 width: "wide", 60447 context: "standalone" 60448 }); 60449 } 60450 }, 60451 // Month 60452 M: function(date, token, localize2) { 60453 const month = date.getMonth(); 60454 switch (token) { 60455 case "M": 60456 case "MM": 60457 return lightFormatters.M(date, token); 60458 // 1st, 2nd, ..., 12th 60459 case "Mo": 60460 return localize2.ordinalNumber(month + 1, { unit: "month" }); 60461 // Jan, Feb, ..., Dec 60462 case "MMM": 60463 return localize2.month(month, { 60464 width: "abbreviated", 60465 context: "formatting" 60466 }); 60467 // J, F, ..., D 60468 case "MMMMM": 60469 return localize2.month(month, { 60470 width: "narrow", 60471 context: "formatting" 60472 }); 60473 // January, February, ..., December 60474 case "MMMM": 60475 default: 60476 return localize2.month(month, { width: "wide", context: "formatting" }); 60477 } 60478 }, 60479 // Stand-alone month 60480 L: function(date, token, localize2) { 60481 const month = date.getMonth(); 60482 switch (token) { 60483 // 1, 2, ..., 12 60484 case "L": 60485 return String(month + 1); 60486 // 01, 02, ..., 12 60487 case "LL": 60488 return addLeadingZeros(month + 1, 2); 60489 // 1st, 2nd, ..., 12th 60490 case "Lo": 60491 return localize2.ordinalNumber(month + 1, { unit: "month" }); 60492 // Jan, Feb, ..., Dec 60493 case "LLL": 60494 return localize2.month(month, { 60495 width: "abbreviated", 60496 context: "standalone" 60497 }); 60498 // J, F, ..., D 60499 case "LLLLL": 60500 return localize2.month(month, { 60501 width: "narrow", 60502 context: "standalone" 60503 }); 60504 // January, February, ..., December 60505 case "LLLL": 60506 default: 60507 return localize2.month(month, { width: "wide", context: "standalone" }); 60508 } 60509 }, 60510 // Local week of year 60511 w: function(date, token, localize2, options) { 60512 const week = getWeek(date, options); 60513 if (token === "wo") { 60514 return localize2.ordinalNumber(week, { unit: "week" }); 60515 } 60516 return addLeadingZeros(week, token.length); 60517 }, 60518 // ISO week of year 60519 I: function(date, token, localize2) { 60520 const isoWeek = getISOWeek(date); 60521 if (token === "Io") { 60522 return localize2.ordinalNumber(isoWeek, { unit: "week" }); 60523 } 60524 return addLeadingZeros(isoWeek, token.length); 60525 }, 60526 // Day of the month 60527 d: function(date, token, localize2) { 60528 if (token === "do") { 60529 return localize2.ordinalNumber(date.getDate(), { unit: "date" }); 60530 } 60531 return lightFormatters.d(date, token); 60532 }, 60533 // Day of year 60534 D: function(date, token, localize2) { 60535 const dayOfYear = getDayOfYear(date); 60536 if (token === "Do") { 60537 return localize2.ordinalNumber(dayOfYear, { unit: "dayOfYear" }); 60538 } 60539 return addLeadingZeros(dayOfYear, token.length); 60540 }, 60541 // Day of week 60542 E: function(date, token, localize2) { 60543 const dayOfWeek = date.getDay(); 60544 switch (token) { 60545 // Tue 60546 case "E": 60547 case "EE": 60548 case "EEE": 60549 return localize2.day(dayOfWeek, { 60550 width: "abbreviated", 60551 context: "formatting" 60552 }); 60553 // T 60554 case "EEEEE": 60555 return localize2.day(dayOfWeek, { 60556 width: "narrow", 60557 context: "formatting" 60558 }); 60559 // Tu 60560 case "EEEEEE": 60561 return localize2.day(dayOfWeek, { 60562 width: "short", 60563 context: "formatting" 60564 }); 60565 // Tuesday 60566 case "EEEE": 60567 default: 60568 return localize2.day(dayOfWeek, { 60569 width: "wide", 60570 context: "formatting" 60571 }); 60572 } 60573 }, 60574 // Local day of week 60575 e: function(date, token, localize2, options) { 60576 const dayOfWeek = date.getDay(); 60577 const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7; 60578 switch (token) { 60579 // Numerical value (Nth day of week with current locale or weekStartsOn) 60580 case "e": 60581 return String(localDayOfWeek); 60582 // Padded numerical value 60583 case "ee": 60584 return addLeadingZeros(localDayOfWeek, 2); 60585 // 1st, 2nd, ..., 7th 60586 case "eo": 60587 return localize2.ordinalNumber(localDayOfWeek, { unit: "day" }); 60588 case "eee": 60589 return localize2.day(dayOfWeek, { 60590 width: "abbreviated", 60591 context: "formatting" 60592 }); 60593 // T 60594 case "eeeee": 60595 return localize2.day(dayOfWeek, { 60596 width: "narrow", 60597 context: "formatting" 60598 }); 60599 // Tu 60600 case "eeeeee": 60601 return localize2.day(dayOfWeek, { 60602 width: "short", 60603 context: "formatting" 60604 }); 60605 // Tuesday 60606 case "eeee": 60607 default: 60608 return localize2.day(dayOfWeek, { 60609 width: "wide", 60610 context: "formatting" 60611 }); 60612 } 60613 }, 60614 // Stand-alone local day of week 60615 c: function(date, token, localize2, options) { 60616 const dayOfWeek = date.getDay(); 60617 const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7; 60618 switch (token) { 60619 // Numerical value (same as in `e`) 60620 case "c": 60621 return String(localDayOfWeek); 60622 // Padded numerical value 60623 case "cc": 60624 return addLeadingZeros(localDayOfWeek, token.length); 60625 // 1st, 2nd, ..., 7th 60626 case "co": 60627 return localize2.ordinalNumber(localDayOfWeek, { unit: "day" }); 60628 case "ccc": 60629 return localize2.day(dayOfWeek, { 60630 width: "abbreviated", 60631 context: "standalone" 60632 }); 60633 // T 60634 case "ccccc": 60635 return localize2.day(dayOfWeek, { 60636 width: "narrow", 60637 context: "standalone" 60638 }); 60639 // Tu 60640 case "cccccc": 60641 return localize2.day(dayOfWeek, { 60642 width: "short", 60643 context: "standalone" 60644 }); 60645 // Tuesday 60646 case "cccc": 60647 default: 60648 return localize2.day(dayOfWeek, { 60649 width: "wide", 60650 context: "standalone" 60651 }); 60652 } 60653 }, 60654 // ISO day of week 60655 i: function(date, token, localize2) { 60656 const dayOfWeek = date.getDay(); 60657 const isoDayOfWeek = dayOfWeek === 0 ? 7 : dayOfWeek; 60658 switch (token) { 60659 // 2 60660 case "i": 60661 return String(isoDayOfWeek); 60662 // 02 60663 case "ii": 60664 return addLeadingZeros(isoDayOfWeek, token.length); 60665 // 2nd 60666 case "io": 60667 return localize2.ordinalNumber(isoDayOfWeek, { unit: "day" }); 60668 // Tue 60669 case "iii": 60670 return localize2.day(dayOfWeek, { 60671 width: "abbreviated", 60672 context: "formatting" 60673 }); 60674 // T 60675 case "iiiii": 60676 return localize2.day(dayOfWeek, { 60677 width: "narrow", 60678 context: "formatting" 60679 }); 60680 // Tu 60681 case "iiiiii": 60682 return localize2.day(dayOfWeek, { 60683 width: "short", 60684 context: "formatting" 60685 }); 60686 // Tuesday 60687 case "iiii": 60688 default: 60689 return localize2.day(dayOfWeek, { 60690 width: "wide", 60691 context: "formatting" 60692 }); 60693 } 60694 }, 60695 // AM or PM 60696 a: function(date, token, localize2) { 60697 const hours = date.getHours(); 60698 const dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am"; 60699 switch (token) { 60700 case "a": 60701 case "aa": 60702 return localize2.dayPeriod(dayPeriodEnumValue, { 60703 width: "abbreviated", 60704 context: "formatting" 60705 }); 60706 case "aaa": 60707 return localize2.dayPeriod(dayPeriodEnumValue, { 60708 width: "abbreviated", 60709 context: "formatting" 60710 }).toLowerCase(); 60711 case "aaaaa": 60712 return localize2.dayPeriod(dayPeriodEnumValue, { 60713 width: "narrow", 60714 context: "formatting" 60715 }); 60716 case "aaaa": 60717 default: 60718 return localize2.dayPeriod(dayPeriodEnumValue, { 60719 width: "wide", 60720 context: "formatting" 60721 }); 60722 } 60723 }, 60724 // AM, PM, midnight, noon 60725 b: function(date, token, localize2) { 60726 const hours = date.getHours(); 60727 let dayPeriodEnumValue; 60728 if (hours === 12) { 60729 dayPeriodEnumValue = dayPeriodEnum.noon; 60730 } else if (hours === 0) { 60731 dayPeriodEnumValue = dayPeriodEnum.midnight; 60732 } else { 60733 dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am"; 60734 } 60735 switch (token) { 60736 case "b": 60737 case "bb": 60738 return localize2.dayPeriod(dayPeriodEnumValue, { 60739 width: "abbreviated", 60740 context: "formatting" 60741 }); 60742 case "bbb": 60743 return localize2.dayPeriod(dayPeriodEnumValue, { 60744 width: "abbreviated", 60745 context: "formatting" 60746 }).toLowerCase(); 60747 case "bbbbb": 60748 return localize2.dayPeriod(dayPeriodEnumValue, { 60749 width: "narrow", 60750 context: "formatting" 60751 }); 60752 case "bbbb": 60753 default: 60754 return localize2.dayPeriod(dayPeriodEnumValue, { 60755 width: "wide", 60756 context: "formatting" 60757 }); 60758 } 60759 }, 60760 // in the morning, in the afternoon, in the evening, at night 60761 B: function(date, token, localize2) { 60762 const hours = date.getHours(); 60763 let dayPeriodEnumValue; 60764 if (hours >= 17) { 60765 dayPeriodEnumValue = dayPeriodEnum.evening; 60766 } else if (hours >= 12) { 60767 dayPeriodEnumValue = dayPeriodEnum.afternoon; 60768 } else if (hours >= 4) { 60769 dayPeriodEnumValue = dayPeriodEnum.morning; 60770 } else { 60771 dayPeriodEnumValue = dayPeriodEnum.night; 60772 } 60773 switch (token) { 60774 case "B": 60775 case "BB": 60776 case "BBB": 60777 return localize2.dayPeriod(dayPeriodEnumValue, { 60778 width: "abbreviated", 60779 context: "formatting" 60780 }); 60781 case "BBBBB": 60782 return localize2.dayPeriod(dayPeriodEnumValue, { 60783 width: "narrow", 60784 context: "formatting" 60785 }); 60786 case "BBBB": 60787 default: 60788 return localize2.dayPeriod(dayPeriodEnumValue, { 60789 width: "wide", 60790 context: "formatting" 60791 }); 60792 } 60793 }, 60794 // Hour [1-12] 60795 h: function(date, token, localize2) { 60796 if (token === "ho") { 60797 let hours = date.getHours() % 12; 60798 if (hours === 0) hours = 12; 60799 return localize2.ordinalNumber(hours, { unit: "hour" }); 60800 } 60801 return lightFormatters.h(date, token); 60802 }, 60803 // Hour [0-23] 60804 H: function(date, token, localize2) { 60805 if (token === "Ho") { 60806 return localize2.ordinalNumber(date.getHours(), { unit: "hour" }); 60807 } 60808 return lightFormatters.H(date, token); 60809 }, 60810 // Hour [0-11] 60811 K: function(date, token, localize2) { 60812 const hours = date.getHours() % 12; 60813 if (token === "Ko") { 60814 return localize2.ordinalNumber(hours, { unit: "hour" }); 60815 } 60816 return addLeadingZeros(hours, token.length); 60817 }, 60818 // Hour [1-24] 60819 k: function(date, token, localize2) { 60820 let hours = date.getHours(); 60821 if (hours === 0) hours = 24; 60822 if (token === "ko") { 60823 return localize2.ordinalNumber(hours, { unit: "hour" }); 60824 } 60825 return addLeadingZeros(hours, token.length); 60826 }, 60827 // Minute 60828 m: function(date, token, localize2) { 60829 if (token === "mo") { 60830 return localize2.ordinalNumber(date.getMinutes(), { unit: "minute" }); 60831 } 60832 return lightFormatters.m(date, token); 60833 }, 60834 // Second 60835 s: function(date, token, localize2) { 60836 if (token === "so") { 60837 return localize2.ordinalNumber(date.getSeconds(), { unit: "second" }); 60838 } 60839 return lightFormatters.s(date, token); 60840 }, 60841 // Fraction of second 60842 S: function(date, token) { 60843 return lightFormatters.S(date, token); 60844 }, 60845 // Timezone (ISO-8601. If offset is 0, output is always `'Z'`) 60846 X: function(date, token, _localize) { 60847 const timezoneOffset = date.getTimezoneOffset(); 60848 if (timezoneOffset === 0) { 60849 return "Z"; 60850 } 60851 switch (token) { 60852 // Hours and optional minutes 60853 case "X": 60854 return formatTimezoneWithOptionalMinutes(timezoneOffset); 60855 // Hours, minutes and optional seconds without `:` delimiter 60856 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets 60857 // so this token always has the same output as `XX` 60858 case "XXXX": 60859 case "XX": 60860 return formatTimezone(timezoneOffset); 60861 // Hours, minutes and optional seconds with `:` delimiter 60862 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets 60863 // so this token always has the same output as `XXX` 60864 case "XXXXX": 60865 case "XXX": 60866 // Hours and minutes with `:` delimiter 60867 default: 60868 return formatTimezone(timezoneOffset, ":"); 60869 } 60870 }, 60871 // Timezone (ISO-8601. If offset is 0, output is `'+00:00'` or equivalent) 60872 x: function(date, token, _localize) { 60873 const timezoneOffset = date.getTimezoneOffset(); 60874 switch (token) { 60875 // Hours and optional minutes 60876 case "x": 60877 return formatTimezoneWithOptionalMinutes(timezoneOffset); 60878 // Hours, minutes and optional seconds without `:` delimiter 60879 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets 60880 // so this token always has the same output as `xx` 60881 case "xxxx": 60882 case "xx": 60883 return formatTimezone(timezoneOffset); 60884 // Hours, minutes and optional seconds with `:` delimiter 60885 // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets 60886 // so this token always has the same output as `xxx` 60887 case "xxxxx": 60888 case "xxx": 60889 // Hours and minutes with `:` delimiter 60890 default: 60891 return formatTimezone(timezoneOffset, ":"); 60892 } 60893 }, 60894 // Timezone (GMT) 60895 O: function(date, token, _localize) { 60896 const timezoneOffset = date.getTimezoneOffset(); 60897 switch (token) { 60898 // Short 60899 case "O": 60900 case "OO": 60901 case "OOO": 60902 return "GMT" + formatTimezoneShort(timezoneOffset, ":"); 60903 // Long 60904 case "OOOO": 60905 default: 60906 return "GMT" + formatTimezone(timezoneOffset, ":"); 60907 } 60908 }, 60909 // Timezone (specific non-location) 60910 z: function(date, token, _localize) { 60911 const timezoneOffset = date.getTimezoneOffset(); 60912 switch (token) { 60913 // Short 60914 case "z": 60915 case "zz": 60916 case "zzz": 60917 return "GMT" + formatTimezoneShort(timezoneOffset, ":"); 60918 // Long 60919 case "zzzz": 60920 default: 60921 return "GMT" + formatTimezone(timezoneOffset, ":"); 60922 } 60923 }, 60924 // Seconds timestamp 60925 t: function(date, token, _localize) { 60926 const timestamp = Math.trunc(+date / 1e3); 60927 return addLeadingZeros(timestamp, token.length); 60928 }, 60929 // Milliseconds timestamp 60930 T: function(date, token, _localize) { 60931 return addLeadingZeros(+date, token.length); 60932 } 60933 }; 60934 function formatTimezoneShort(offset, delimiter = "") { 60935 const sign = offset > 0 ? "-" : "+"; 60936 const absOffset = Math.abs(offset); 60937 const hours = Math.trunc(absOffset / 60); 60938 const minutes = absOffset % 60; 60939 if (minutes === 0) { 60940 return sign + String(hours); 60941 } 60942 return sign + String(hours) + delimiter + addLeadingZeros(minutes, 2); 60943 } 60944 function formatTimezoneWithOptionalMinutes(offset, delimiter) { 60945 if (offset % 60 === 0) { 60946 const sign = offset > 0 ? "-" : "+"; 60947 return sign + addLeadingZeros(Math.abs(offset) / 60, 2); 60948 } 60949 return formatTimezone(offset, delimiter); 60950 } 60951 function formatTimezone(offset, delimiter = "") { 60952 const sign = offset > 0 ? "-" : "+"; 60953 const absOffset = Math.abs(offset); 60954 const hours = addLeadingZeros(Math.trunc(absOffset / 60), 2); 60955 const minutes = addLeadingZeros(absOffset % 60, 2); 60956 return sign + hours + delimiter + minutes; 60957 } 60958 60959 // packages/dataviews/node_modules/date-fns/_lib/format/longFormatters.js 60960 var dateLongFormatter = (pattern, formatLong2) => { 60961 switch (pattern) { 60962 case "P": 60963 return formatLong2.date({ width: "short" }); 60964 case "PP": 60965 return formatLong2.date({ width: "medium" }); 60966 case "PPP": 60967 return formatLong2.date({ width: "long" }); 60968 case "PPPP": 60969 default: 60970 return formatLong2.date({ width: "full" }); 60971 } 60972 }; 60973 var timeLongFormatter = (pattern, formatLong2) => { 60974 switch (pattern) { 60975 case "p": 60976 return formatLong2.time({ width: "short" }); 60977 case "pp": 60978 return formatLong2.time({ width: "medium" }); 60979 case "ppp": 60980 return formatLong2.time({ width: "long" }); 60981 case "pppp": 60982 default: 60983 return formatLong2.time({ width: "full" }); 60984 } 60985 }; 60986 var dateTimeLongFormatter = (pattern, formatLong2) => { 60987 const matchResult = pattern.match(/(P+)(p+)?/) || []; 60988 const datePattern = matchResult[1]; 60989 const timePattern = matchResult[2]; 60990 if (!timePattern) { 60991 return dateLongFormatter(pattern, formatLong2); 60992 } 60993 let dateTimeFormat; 60994 switch (datePattern) { 60995 case "P": 60996 dateTimeFormat = formatLong2.dateTime({ width: "short" }); 60997 break; 60998 case "PP": 60999 dateTimeFormat = formatLong2.dateTime({ width: "medium" }); 61000 break; 61001 case "PPP": 61002 dateTimeFormat = formatLong2.dateTime({ width: "long" }); 61003 break; 61004 case "PPPP": 61005 default: 61006 dateTimeFormat = formatLong2.dateTime({ width: "full" }); 61007 break; 61008 } 61009 return dateTimeFormat.replace("{{date}}", dateLongFormatter(datePattern, formatLong2)).replace("{{time}}", timeLongFormatter(timePattern, formatLong2)); 61010 }; 61011 var longFormatters = { 61012 p: timeLongFormatter, 61013 P: dateTimeLongFormatter 61014 }; 61015 61016 // packages/dataviews/node_modules/date-fns/_lib/protectedTokens.js 61017 var dayOfYearTokenRE = /^D+$/; 61018 var weekYearTokenRE = /^Y+$/; 61019 var throwTokens = ["D", "DD", "YY", "YYYY"]; 61020 function isProtectedDayOfYearToken(token) { 61021 return dayOfYearTokenRE.test(token); 61022 } 61023 function isProtectedWeekYearToken(token) { 61024 return weekYearTokenRE.test(token); 61025 } 61026 function warnOrThrowProtectedError(token, format6, input) { 61027 const _message = message(token, format6, input); 61028 console.warn(_message); 61029 if (throwTokens.includes(token)) throw new RangeError(_message); 61030 } 61031 function message(token, format6, input) { 61032 const subject = token[0] === "Y" ? "years" : "days of the month"; 61033 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`; 61034 } 61035 61036 // packages/dataviews/node_modules/date-fns/format.js 61037 var formattingTokensRegExp = /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g; 61038 var longFormattingTokensRegExp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g; 61039 var escapedStringRegExp = /^'([^]*?)'?$/; 61040 var doubleQuoteRegExp = /''/g; 61041 var unescapedLatinCharacterRegExp = /[a-zA-Z]/; 61042 function format(date, formatStr, options) { 61043 const defaultOptions2 = getDefaultOptions(); 61044 const locale = options?.locale ?? defaultOptions2.locale ?? enUS; 61045 const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1; 61046 const weekStartsOn = options?.weekStartsOn ?? options?.locale?.options?.weekStartsOn ?? defaultOptions2.weekStartsOn ?? defaultOptions2.locale?.options?.weekStartsOn ?? 0; 61047 const originalDate = toDate(date, options?.in); 61048 if (!isValid(originalDate)) { 61049 throw new RangeError("Invalid time value"); 61050 } 61051 let parts = formatStr.match(longFormattingTokensRegExp).map((substring) => { 61052 const firstCharacter = substring[0]; 61053 if (firstCharacter === "p" || firstCharacter === "P") { 61054 const longFormatter = longFormatters[firstCharacter]; 61055 return longFormatter(substring, locale.formatLong); 61056 } 61057 return substring; 61058 }).join("").match(formattingTokensRegExp).map((substring) => { 61059 if (substring === "''") { 61060 return { isToken: false, value: "'" }; 61061 } 61062 const firstCharacter = substring[0]; 61063 if (firstCharacter === "'") { 61064 return { isToken: false, value: cleanEscapedString(substring) }; 61065 } 61066 if (formatters[firstCharacter]) { 61067 return { isToken: true, value: substring }; 61068 } 61069 if (firstCharacter.match(unescapedLatinCharacterRegExp)) { 61070 throw new RangeError( 61071 "Format string contains an unescaped latin alphabet character `" + firstCharacter + "`" 61072 ); 61073 } 61074 return { isToken: false, value: substring }; 61075 }); 61076 if (locale.localize.preprocessor) { 61077 parts = locale.localize.preprocessor(originalDate, parts); 61078 } 61079 const formatterOptions = { 61080 firstWeekContainsDate, 61081 weekStartsOn, 61082 locale 61083 }; 61084 return parts.map((part) => { 61085 if (!part.isToken) return part.value; 61086 const token = part.value; 61087 if (!options?.useAdditionalWeekYearTokens && isProtectedWeekYearToken(token) || !options?.useAdditionalDayOfYearTokens && isProtectedDayOfYearToken(token)) { 61088 warnOrThrowProtectedError(token, formatStr, String(date)); 61089 } 61090 const formatter = formatters[token[0]]; 61091 return formatter(originalDate, token, locale.localize, formatterOptions); 61092 }).join(""); 61093 } 61094 function cleanEscapedString(input) { 61095 const matched = input.match(escapedStringRegExp); 61096 if (!matched) { 61097 return input; 61098 } 61099 return matched[1].replace(doubleQuoteRegExp, "'"); 61100 } 61101 61102 // packages/dataviews/node_modules/date-fns/subDays.js 61103 function subDays(date, amount, options) { 61104 return addDays(date, -amount, options); 61105 } 61106 61107 // packages/dataviews/node_modules/date-fns/subMonths.js 61108 function subMonths(date, amount, options) { 61109 return addMonths(date, -amount, options); 61110 } 61111 61112 // packages/dataviews/node_modules/date-fns/subYears.js 61113 function subYears(date, amount, options) { 61114 return addYears(date, -amount, options); 61115 } 61116 61117 // packages/dataviews/build-module/dataform-controls/datetime.js 61118 var import_components210 = __toESM(require_components()); 61119 var import_element215 = __toESM(require_element()); 61120 var import_i18n200 = __toESM(require_i18n()); 61121 var import_date3 = __toESM(require_date()); 61122 61123 // packages/dataviews/build-module/dataform-controls/utils/relative-date-control.js 61124 var import_components209 = __toESM(require_components()); 61125 var import_element214 = __toESM(require_element()); 61126 var import_i18n199 = __toESM(require_i18n()); 61127 var import_jsx_runtime377 = __toESM(require_jsx_runtime()); 61128 var TIME_UNITS_OPTIONS = { 61129 [OPERATOR_IN_THE_PAST]: [ 61130 { value: "days", label: (0, import_i18n199.__)("Days") }, 61131 { value: "weeks", label: (0, import_i18n199.__)("Weeks") }, 61132 { value: "months", label: (0, import_i18n199.__)("Months") }, 61133 { value: "years", label: (0, import_i18n199.__)("Years") } 61134 ], 61135 [OPERATOR_OVER]: [ 61136 { value: "days", label: (0, import_i18n199.__)("Days ago") }, 61137 { value: "weeks", label: (0, import_i18n199.__)("Weeks ago") }, 61138 { value: "months", label: (0, import_i18n199.__)("Months ago") }, 61139 { value: "years", label: (0, import_i18n199.__)("Years ago") } 61140 ] 61141 }; 61142 function RelativeDateControl({ 61143 className, 61144 data, 61145 field, 61146 onChange, 61147 hideLabelFromVision, 61148 operator 61149 }) { 61150 const options = TIME_UNITS_OPTIONS[operator === OPERATOR_IN_THE_PAST ? "inThePast" : "over"]; 61151 const { id, label, getValue, setValue } = field; 61152 const fieldValue = getValue({ item: data }); 61153 const { value: relValue = "", unit = options[0].value } = fieldValue && typeof fieldValue === "object" ? fieldValue : {}; 61154 const onChangeValue = (0, import_element214.useCallback)( 61155 (newValue) => onChange( 61156 setValue({ 61157 item: data, 61158 value: { value: Number(newValue), unit } 61159 }) 61160 ), 61161 [onChange, setValue, data, unit] 61162 ); 61163 const onChangeUnit = (0, import_element214.useCallback)( 61164 (newUnit) => onChange( 61165 setValue({ 61166 item: data, 61167 value: { value: relValue, unit: newUnit } 61168 }) 61169 ), 61170 [onChange, setValue, data, relValue] 61171 ); 61172 return /* @__PURE__ */ (0, import_jsx_runtime377.jsx)( 61173 import_components209.BaseControl, 61174 { 61175 id, 61176 className: clsx_default(className, "dataviews-controls__relative-date"), 61177 label, 61178 hideLabelFromVision, 61179 children: /* @__PURE__ */ (0, import_jsx_runtime377.jsxs)(import_components209.__experimentalHStack, { spacing: 2.5, children: [ 61180 /* @__PURE__ */ (0, import_jsx_runtime377.jsx)( 61181 import_components209.__experimentalNumberControl, 61182 { 61183 __next40pxDefaultSize: true, 61184 className: "dataviews-controls__relative-date-number", 61185 spinControls: "none", 61186 min: 1, 61187 step: 1, 61188 value: relValue, 61189 onChange: onChangeValue 61190 } 61191 ), 61192 /* @__PURE__ */ (0, import_jsx_runtime377.jsx)( 61193 import_components209.SelectControl, 61194 { 61195 className: "dataviews-controls__relative-date-unit", 61196 __next40pxDefaultSize: true, 61197 label: (0, import_i18n199.__)("Unit"), 61198 value: unit, 61199 options, 61200 onChange: onChangeUnit, 61201 hideLabelFromVision: true 61202 } 61203 ) 61204 ] }) 61205 } 61206 ); 61207 } 61208 61209 // packages/dataviews/build-module/field-types/utils/parse-date-time.js 61210 var import_date2 = __toESM(require_date()); 61211 function parseDateTime(dateTimeString) { 61212 if (!dateTimeString) { 61213 return null; 61214 } 61215 const parsed = (0, import_date2.getDate)(dateTimeString); 61216 return parsed && isValid(parsed) ? parsed : null; 61217 } 61218 61219 // packages/dataviews/build-module/dataform-controls/datetime.js 61220 var import_jsx_runtime378 = __toESM(require_jsx_runtime()); 61221 var { DateCalendar, ValidatedInputControl } = unlock3(import_components210.privateApis); 61222 var formatDateTime = (date) => { 61223 if (!date) { 61224 return ""; 61225 } 61226 if (typeof date === "string") { 61227 return date; 61228 } 61229 return format(date, "yyyy-MM-dd'T'HH:mm"); 61230 }; 61231 function CalendarDateTimeControl({ 61232 data, 61233 field, 61234 onChange, 61235 hideLabelFromVision, 61236 validity 61237 }) { 61238 const { id, label, description, setValue, getValue, isValid: isValid2 } = field; 61239 const fieldValue = getValue({ item: data }); 61240 const value = typeof fieldValue === "string" ? fieldValue : void 0; 61241 const [calendarMonth, setCalendarMonth] = (0, import_element215.useState)(() => { 61242 const parsedDate = parseDateTime(value); 61243 return parsedDate || /* @__PURE__ */ new Date(); 61244 }); 61245 const inputControlRef = (0, import_element215.useRef)(null); 61246 const validationTimeoutRef = (0, import_element215.useRef)(); 61247 const previousFocusRef = (0, import_element215.useRef)(null); 61248 const onChangeCallback = (0, import_element215.useCallback)( 61249 (newValue) => onChange(setValue({ item: data, value: newValue })), 61250 [data, onChange, setValue] 61251 ); 61252 (0, import_element215.useEffect)(() => { 61253 return () => { 61254 if (validationTimeoutRef.current) { 61255 clearTimeout(validationTimeoutRef.current); 61256 } 61257 }; 61258 }, []); 61259 const onSelectDate = (0, import_element215.useCallback)( 61260 (newDate) => { 61261 let dateTimeValue; 61262 if (newDate) { 61263 let finalDateTime = newDate; 61264 if (value) { 61265 const currentDateTime = parseDateTime(value); 61266 if (currentDateTime) { 61267 finalDateTime = new Date(newDate); 61268 finalDateTime.setHours(currentDateTime.getHours()); 61269 finalDateTime.setMinutes( 61270 currentDateTime.getMinutes() 61271 ); 61272 } 61273 } 61274 dateTimeValue = finalDateTime.toISOString(); 61275 onChangeCallback(dateTimeValue); 61276 if (validationTimeoutRef.current) { 61277 clearTimeout(validationTimeoutRef.current); 61278 } 61279 } else { 61280 onChangeCallback(void 0); 61281 } 61282 previousFocusRef.current = inputControlRef.current && inputControlRef.current.ownerDocument.activeElement; 61283 validationTimeoutRef.current = setTimeout(() => { 61284 if (inputControlRef.current) { 61285 inputControlRef.current.focus(); 61286 inputControlRef.current.blur(); 61287 onChangeCallback(dateTimeValue); 61288 if (previousFocusRef.current && previousFocusRef.current instanceof HTMLElement) { 61289 previousFocusRef.current.focus(); 61290 } 61291 } 61292 }, 0); 61293 }, 61294 [onChangeCallback, value] 61295 ); 61296 const handleManualDateTimeChange = (0, import_element215.useCallback)( 61297 (newValue) => { 61298 if (newValue) { 61299 const dateTime = new Date(newValue); 61300 onChangeCallback(dateTime.toISOString()); 61301 const parsedDate = parseDateTime(dateTime.toISOString()); 61302 if (parsedDate) { 61303 setCalendarMonth(parsedDate); 61304 } 61305 } else { 61306 onChangeCallback(void 0); 61307 } 61308 }, 61309 [onChangeCallback] 61310 ); 61311 const { format: fieldFormat } = field; 61312 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date3.getSettings)().l10n.startOfWeek; 61313 const { 61314 timezone: { string: timezoneString } 61315 } = (0, import_date3.getSettings)(); 61316 const displayLabel = isValid2?.required && !hideLabelFromVision ? `$label} (${(0, import_i18n200.__)("Required")})` : label; 61317 return /* @__PURE__ */ (0, import_jsx_runtime378.jsx)( 61318 import_components210.BaseControl, 61319 { 61320 id, 61321 label: displayLabel, 61322 help: description, 61323 hideLabelFromVision, 61324 children: /* @__PURE__ */ (0, import_jsx_runtime378.jsxs)(import_components210.__experimentalVStack, { spacing: 4, children: [ 61325 /* @__PURE__ */ (0, import_jsx_runtime378.jsx)( 61326 DateCalendar, 61327 { 61328 style: { width: "100%" }, 61329 selected: value ? parseDateTime(value) || void 0 : void 0, 61330 onSelect: onSelectDate, 61331 month: calendarMonth, 61332 onMonthChange: setCalendarMonth, 61333 timeZone: timezoneString || void 0, 61334 weekStartsOn 61335 } 61336 ), 61337 /* @__PURE__ */ (0, import_jsx_runtime378.jsx)( 61338 ValidatedInputControl, 61339 { 61340 ref: inputControlRef, 61341 __next40pxDefaultSize: true, 61342 required: !!isValid2?.required, 61343 customValidity: getCustomValidity(isValid2, validity), 61344 type: "datetime-local", 61345 label: (0, import_i18n200.__)("Date time"), 61346 hideLabelFromVision: true, 61347 value: value ? formatDateTime( 61348 parseDateTime(value) || void 0 61349 ) : "", 61350 onChange: handleManualDateTimeChange 61351 } 61352 ) 61353 ] }) 61354 } 61355 ); 61356 } 61357 function DateTime({ 61358 data, 61359 field, 61360 onChange, 61361 hideLabelFromVision, 61362 operator, 61363 validity 61364 }) { 61365 if (operator === OPERATOR_IN_THE_PAST || operator === OPERATOR_OVER) { 61366 return /* @__PURE__ */ (0, import_jsx_runtime378.jsx)( 61367 RelativeDateControl, 61368 { 61369 className: "dataviews-controls__datetime", 61370 data, 61371 field, 61372 onChange, 61373 hideLabelFromVision, 61374 operator 61375 } 61376 ); 61377 } 61378 return /* @__PURE__ */ (0, import_jsx_runtime378.jsx)( 61379 CalendarDateTimeControl, 61380 { 61381 data, 61382 field, 61383 onChange, 61384 hideLabelFromVision, 61385 validity 61386 } 61387 ); 61388 } 61389 61390 // packages/dataviews/build-module/dataform-controls/date.js 61391 var import_components211 = __toESM(require_components()); 61392 var import_element216 = __toESM(require_element()); 61393 var import_i18n201 = __toESM(require_i18n()); 61394 var import_date4 = __toESM(require_date()); 61395 var import_jsx_runtime379 = __toESM(require_jsx_runtime()); 61396 var { DateCalendar: DateCalendar2, DateRangeCalendar } = unlock3(import_components211.privateApis); 61397 var DATE_PRESETS = [ 61398 { 61399 id: "today", 61400 label: (0, import_i18n201.__)("Today"), 61401 getValue: () => (0, import_date4.getDate)(null) 61402 }, 61403 { 61404 id: "yesterday", 61405 label: (0, import_i18n201.__)("Yesterday"), 61406 getValue: () => { 61407 const today = (0, import_date4.getDate)(null); 61408 return subDays(today, 1); 61409 } 61410 }, 61411 { 61412 id: "past-week", 61413 label: (0, import_i18n201.__)("Past week"), 61414 getValue: () => { 61415 const today = (0, import_date4.getDate)(null); 61416 return subDays(today, 7); 61417 } 61418 }, 61419 { 61420 id: "past-month", 61421 label: (0, import_i18n201.__)("Past month"), 61422 getValue: () => { 61423 const today = (0, import_date4.getDate)(null); 61424 return subMonths(today, 1); 61425 } 61426 } 61427 ]; 61428 var DATE_RANGE_PRESETS = [ 61429 { 61430 id: "last-7-days", 61431 label: (0, import_i18n201.__)("Last 7 days"), 61432 getValue: () => { 61433 const today = (0, import_date4.getDate)(null); 61434 return [subDays(today, 7), today]; 61435 } 61436 }, 61437 { 61438 id: "last-30-days", 61439 label: (0, import_i18n201.__)("Last 30 days"), 61440 getValue: () => { 61441 const today = (0, import_date4.getDate)(null); 61442 return [subDays(today, 30), today]; 61443 } 61444 }, 61445 { 61446 id: "month-to-date", 61447 label: (0, import_i18n201.__)("Month to date"), 61448 getValue: () => { 61449 const today = (0, import_date4.getDate)(null); 61450 return [startOfMonth(today), today]; 61451 } 61452 }, 61453 { 61454 id: "last-year", 61455 label: (0, import_i18n201.__)("Last year"), 61456 getValue: () => { 61457 const today = (0, import_date4.getDate)(null); 61458 return [subYears(today, 1), today]; 61459 } 61460 }, 61461 { 61462 id: "year-to-date", 61463 label: (0, import_i18n201.__)("Year to date"), 61464 getValue: () => { 61465 const today = (0, import_date4.getDate)(null); 61466 return [startOfYear(today), today]; 61467 } 61468 } 61469 ]; 61470 var parseDate = (dateString) => { 61471 if (!dateString) { 61472 return null; 61473 } 61474 const parsed = (0, import_date4.getDate)(dateString); 61475 return parsed && isValid(parsed) ? parsed : null; 61476 }; 61477 var formatDate = (date) => { 61478 if (!date) { 61479 return ""; 61480 } 61481 return typeof date === "string" ? date : format(date, "yyyy-MM-dd"); 61482 }; 61483 function ValidatedDateControl({ 61484 field, 61485 validity, 61486 inputRefs, 61487 isTouched, 61488 setIsTouched, 61489 children 61490 }) { 61491 const { isValid: isValid2 } = field; 61492 const [customValidity, setCustomValidity] = (0, import_element216.useState)(void 0); 61493 const validateRefs = (0, import_element216.useCallback)(() => { 61494 const refs = Array.isArray(inputRefs) ? inputRefs : [inputRefs]; 61495 for (const ref of refs) { 61496 const input = ref.current; 61497 if (input && !input.validity.valid) { 61498 setCustomValidity({ 61499 type: "invalid", 61500 message: input.validationMessage 61501 }); 61502 return; 61503 } 61504 } 61505 setCustomValidity(void 0); 61506 }, [inputRefs]); 61507 (0, import_element216.useEffect)(() => { 61508 if (isTouched) { 61509 const timeoutId = setTimeout(() => { 61510 if (validity) { 61511 setCustomValidity(getCustomValidity(isValid2, validity)); 61512 } else { 61513 validateRefs(); 61514 } 61515 }, 0); 61516 return () => clearTimeout(timeoutId); 61517 } 61518 return void 0; 61519 }, [isTouched, isValid2, validity, validateRefs]); 61520 const onBlur = (event) => { 61521 if (isTouched) { 61522 return; 61523 } 61524 if (!event.relatedTarget || !event.currentTarget.contains(event.relatedTarget)) { 61525 setIsTouched(true); 61526 } 61527 }; 61528 return /* @__PURE__ */ (0, import_jsx_runtime379.jsxs)("div", { onBlur, children: [ 61529 children, 61530 /* @__PURE__ */ (0, import_jsx_runtime379.jsx)("div", { "aria-live": "polite", children: customValidity && /* @__PURE__ */ (0, import_jsx_runtime379.jsxs)( 61531 "p", 61532 { 61533 className: clsx_default( 61534 "components-validated-control__indicator", 61535 customValidity.type === "invalid" ? "is-invalid" : void 0, 61536 customValidity.type === "valid" ? "is-valid" : void 0 61537 ), 61538 children: [ 61539 /* @__PURE__ */ (0, import_jsx_runtime379.jsx)( 61540 import_components211.Icon, 61541 { 61542 className: "components-validated-control__indicator-icon", 61543 icon: error_default, 61544 size: 16, 61545 fill: "currentColor" 61546 } 61547 ), 61548 customValidity.message 61549 ] 61550 } 61551 ) }) 61552 ] }); 61553 } 61554 function CalendarDateControl({ 61555 data, 61556 field, 61557 onChange, 61558 hideLabelFromVision, 61559 validity 61560 }) { 61561 const { 61562 id, 61563 label, 61564 setValue, 61565 getValue, 61566 isValid: isValid2, 61567 format: fieldFormat 61568 } = field; 61569 const [selectedPresetId, setSelectedPresetId] = (0, import_element216.useState)( 61570 null 61571 ); 61572 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date4.getSettings)().l10n.startOfWeek; 61573 const fieldValue = getValue({ item: data }); 61574 const value = typeof fieldValue === "string" ? fieldValue : void 0; 61575 const [calendarMonth, setCalendarMonth] = (0, import_element216.useState)(() => { 61576 const parsedDate = parseDate(value); 61577 return parsedDate || /* @__PURE__ */ new Date(); 61578 }); 61579 const [isTouched, setIsTouched] = (0, import_element216.useState)(false); 61580 const validityTargetRef = (0, import_element216.useRef)(null); 61581 const onChangeCallback = (0, import_element216.useCallback)( 61582 (newValue) => onChange(setValue({ item: data, value: newValue })), 61583 [data, onChange, setValue] 61584 ); 61585 const onSelectDate = (0, import_element216.useCallback)( 61586 (newDate) => { 61587 const dateValue = newDate ? format(newDate, "yyyy-MM-dd") : void 0; 61588 onChangeCallback(dateValue); 61589 setSelectedPresetId(null); 61590 setIsTouched(true); 61591 }, 61592 [onChangeCallback] 61593 ); 61594 const handlePresetClick = (0, import_element216.useCallback)( 61595 (preset) => { 61596 const presetDate = preset.getValue(); 61597 const dateValue = formatDate(presetDate); 61598 setCalendarMonth(presetDate); 61599 onChangeCallback(dateValue); 61600 setSelectedPresetId(preset.id); 61601 setIsTouched(true); 61602 }, 61603 [onChangeCallback] 61604 ); 61605 const handleManualDateChange = (0, import_element216.useCallback)( 61606 (newValue) => { 61607 onChangeCallback(newValue); 61608 if (newValue) { 61609 const parsedDate = parseDate(newValue); 61610 if (parsedDate) { 61611 setCalendarMonth(parsedDate); 61612 } 61613 } 61614 setSelectedPresetId(null); 61615 setIsTouched(true); 61616 }, 61617 [onChangeCallback] 61618 ); 61619 const { 61620 timezone: { string: timezoneString } 61621 } = (0, import_date4.getSettings)(); 61622 const displayLabel = isValid2?.required ? `$label} (${(0, import_i18n201.__)("Required")})` : label; 61623 return /* @__PURE__ */ (0, import_jsx_runtime379.jsx)( 61624 ValidatedDateControl, 61625 { 61626 field, 61627 validity, 61628 inputRefs: validityTargetRef, 61629 isTouched, 61630 setIsTouched, 61631 children: /* @__PURE__ */ (0, import_jsx_runtime379.jsx)( 61632 import_components211.BaseControl, 61633 { 61634 id, 61635 className: "dataviews-controls__date", 61636 label: displayLabel, 61637 hideLabelFromVision, 61638 children: /* @__PURE__ */ (0, import_jsx_runtime379.jsxs)(import_components211.__experimentalVStack, { spacing: 4, children: [ 61639 /* @__PURE__ */ (0, import_jsx_runtime379.jsxs)(import_components211.__experimentalHStack, { spacing: 2, wrap: true, justify: "flex-start", children: [ 61640 DATE_PRESETS.map((preset) => { 61641 const isSelected = selectedPresetId === preset.id; 61642 return /* @__PURE__ */ (0, import_jsx_runtime379.jsx)( 61643 import_components211.Button, 61644 { 61645 className: "dataviews-controls__date-preset", 61646 variant: "tertiary", 61647 isPressed: isSelected, 61648 size: "small", 61649 onClick: () => handlePresetClick(preset), 61650 children: preset.label 61651 }, 61652 preset.id 61653 ); 61654 }), 61655 /* @__PURE__ */ (0, import_jsx_runtime379.jsx)( 61656 import_components211.Button, 61657 { 61658 className: "dataviews-controls__date-preset", 61659 variant: "tertiary", 61660 isPressed: !selectedPresetId, 61661 size: "small", 61662 disabled: !!selectedPresetId, 61663 accessibleWhenDisabled: false, 61664 children: (0, import_i18n201.__)("Custom") 61665 } 61666 ) 61667 ] }), 61668 /* @__PURE__ */ (0, import_jsx_runtime379.jsx)( 61669 import_components211.__experimentalInputControl, 61670 { 61671 __next40pxDefaultSize: true, 61672 ref: validityTargetRef, 61673 type: "date", 61674 label: (0, import_i18n201.__)("Date"), 61675 hideLabelFromVision: true, 61676 value, 61677 onChange: handleManualDateChange, 61678 required: !!field.isValid?.required 61679 } 61680 ), 61681 /* @__PURE__ */ (0, import_jsx_runtime379.jsx)( 61682 DateCalendar2, 61683 { 61684 style: { width: "100%" }, 61685 selected: value ? parseDate(value) || void 0 : void 0, 61686 onSelect: onSelectDate, 61687 month: calendarMonth, 61688 onMonthChange: setCalendarMonth, 61689 timeZone: timezoneString || void 0, 61690 weekStartsOn 61691 } 61692 ) 61693 ] }) 61694 } 61695 ) 61696 } 61697 ); 61698 } 61699 function CalendarDateRangeControl({ 61700 data, 61701 field, 61702 onChange, 61703 hideLabelFromVision, 61704 validity 61705 }) { 61706 const { id, label, getValue, setValue, format: fieldFormat } = field; 61707 let value; 61708 const fieldValue = getValue({ item: data }); 61709 if (Array.isArray(fieldValue) && fieldValue.length === 2 && fieldValue.every((date) => typeof date === "string")) { 61710 value = fieldValue; 61711 } 61712 const weekStartsOn = fieldFormat.weekStartsOn ?? (0, import_date4.getSettings)().l10n.startOfWeek; 61713 const onChangeCallback = (0, import_element216.useCallback)( 61714 (newValue) => { 61715 onChange( 61716 setValue({ 61717 item: data, 61718 value: newValue 61719 }) 61720 ); 61721 }, 61722 [data, onChange, setValue] 61723 ); 61724 const [selectedPresetId, setSelectedPresetId] = (0, import_element216.useState)( 61725 null 61726 ); 61727 const selectedRange = (0, import_element216.useMemo)(() => { 61728 if (!value) { 61729 return { from: void 0, to: void 0 }; 61730 } 61731 const [from, to2] = value; 61732 return { 61733 from: parseDate(from) || void 0, 61734 to: parseDate(to2) || void 0 61735 }; 61736 }, [value]); 61737 const [calendarMonth, setCalendarMonth] = (0, import_element216.useState)(() => { 61738 return selectedRange.from || /* @__PURE__ */ new Date(); 61739 }); 61740 const [isTouched, setIsTouched] = (0, import_element216.useState)(false); 61741 const fromInputRef = (0, import_element216.useRef)(null); 61742 const toInputRef = (0, import_element216.useRef)(null); 61743 const updateDateRange = (0, import_element216.useCallback)( 61744 (fromDate, toDate2) => { 61745 if (fromDate && toDate2) { 61746 onChangeCallback([ 61747 formatDate(fromDate), 61748 formatDate(toDate2) 61749 ]); 61750 } else if (!fromDate && !toDate2) { 61751 onChangeCallback(void 0); 61752 } 61753 }, 61754 [onChangeCallback] 61755 ); 61756 const onSelectCalendarRange = (0, import_element216.useCallback)( 61757 (newRange) => { 61758 updateDateRange(newRange?.from, newRange?.to); 61759 setSelectedPresetId(null); 61760 setIsTouched(true); 61761 }, 61762 [updateDateRange] 61763 ); 61764 const handlePresetClick = (0, import_element216.useCallback)( 61765 (preset) => { 61766 const [startDate, endDate] = preset.getValue(); 61767 setCalendarMonth(startDate); 61768 updateDateRange(startDate, endDate); 61769 setSelectedPresetId(preset.id); 61770 setIsTouched(true); 61771 }, 61772 [updateDateRange] 61773 ); 61774 const handleManualDateChange = (0, import_element216.useCallback)( 61775 (fromOrTo, newValue) => { 61776 const [currentFrom, currentTo] = value || [ 61777 void 0, 61778 void 0 61779 ]; 61780 const updatedFrom = fromOrTo === "from" ? newValue : currentFrom; 61781 const updatedTo = fromOrTo === "to" ? newValue : currentTo; 61782 updateDateRange(updatedFrom, updatedTo); 61783 if (newValue) { 61784 const parsedDate = parseDate(newValue); 61785 if (parsedDate) { 61786 setCalendarMonth(parsedDate); 61787 } 61788 } 61789 setSelectedPresetId(null); 61790 setIsTouched(true); 61791 }, 61792 [value, updateDateRange] 61793 ); 61794 const { timezone } = (0, import_date4.getSettings)(); 61795 const displayLabel = field.isValid?.required ? `$label} (${(0, import_i18n201.__)("Required")})` : label; 61796 return /* @__PURE__ */ (0, import_jsx_runtime379.jsx)( 61797 ValidatedDateControl, 61798 { 61799 field, 61800 validity, 61801 inputRefs: [fromInputRef, toInputRef], 61802 isTouched, 61803 setIsTouched, 61804 children: /* @__PURE__ */ (0, import_jsx_runtime379.jsx)( 61805 import_components211.BaseControl, 61806 { 61807 id, 61808 className: "dataviews-controls__date", 61809 label: displayLabel, 61810 hideLabelFromVision, 61811 children: /* @__PURE__ */ (0, import_jsx_runtime379.jsxs)(import_components211.__experimentalVStack, { spacing: 4, children: [ 61812 /* @__PURE__ */ (0, import_jsx_runtime379.jsxs)(import_components211.__experimentalHStack, { spacing: 2, wrap: true, justify: "flex-start", children: [ 61813 DATE_RANGE_PRESETS.map((preset) => { 61814 const isSelected = selectedPresetId === preset.id; 61815 return /* @__PURE__ */ (0, import_jsx_runtime379.jsx)( 61816 import_components211.Button, 61817 { 61818 className: "dataviews-controls__date-preset", 61819 variant: "tertiary", 61820 isPressed: isSelected, 61821 size: "small", 61822 onClick: () => handlePresetClick(preset), 61823 children: preset.label 61824 }, 61825 preset.id 61826 ); 61827 }), 61828 /* @__PURE__ */ (0, import_jsx_runtime379.jsx)( 61829 import_components211.Button, 61830 { 61831 className: "dataviews-controls__date-preset", 61832 variant: "tertiary", 61833 isPressed: !selectedPresetId, 61834 size: "small", 61835 accessibleWhenDisabled: false, 61836 disabled: !!selectedPresetId, 61837 children: (0, import_i18n201.__)("Custom") 61838 } 61839 ) 61840 ] }), 61841 /* @__PURE__ */ (0, import_jsx_runtime379.jsxs)(import_components211.__experimentalHStack, { spacing: 2, children: [ 61842 /* @__PURE__ */ (0, import_jsx_runtime379.jsx)( 61843 import_components211.__experimentalInputControl, 61844 { 61845 __next40pxDefaultSize: true, 61846 ref: fromInputRef, 61847 type: "date", 61848 label: (0, import_i18n201.__)("From"), 61849 hideLabelFromVision: true, 61850 value: value?.[0], 61851 onChange: (newValue) => handleManualDateChange("from", newValue), 61852 required: !!field.isValid?.required 61853 } 61854 ), 61855 /* @__PURE__ */ (0, import_jsx_runtime379.jsx)( 61856 import_components211.__experimentalInputControl, 61857 { 61858 __next40pxDefaultSize: true, 61859 ref: toInputRef, 61860 type: "date", 61861 label: (0, import_i18n201.__)("To"), 61862 hideLabelFromVision: true, 61863 value: value?.[1], 61864 onChange: (newValue) => handleManualDateChange("to", newValue), 61865 required: !!field.isValid?.required 61866 } 61867 ) 61868 ] }), 61869 /* @__PURE__ */ (0, import_jsx_runtime379.jsx)( 61870 DateRangeCalendar, 61871 { 61872 style: { width: "100%" }, 61873 selected: selectedRange, 61874 onSelect: onSelectCalendarRange, 61875 month: calendarMonth, 61876 onMonthChange: setCalendarMonth, 61877 timeZone: timezone.string || void 0, 61878 weekStartsOn 61879 } 61880 ) 61881 ] }) 61882 } 61883 ) 61884 } 61885 ); 61886 } 61887 function DateControl({ 61888 data, 61889 field, 61890 onChange, 61891 hideLabelFromVision, 61892 operator, 61893 validity 61894 }) { 61895 if (operator === OPERATOR_IN_THE_PAST || operator === OPERATOR_OVER) { 61896 return /* @__PURE__ */ (0, import_jsx_runtime379.jsx)( 61897 RelativeDateControl, 61898 { 61899 className: "dataviews-controls__date", 61900 data, 61901 field, 61902 onChange, 61903 hideLabelFromVision, 61904 operator 61905 } 61906 ); 61907 } 61908 if (operator === OPERATOR_BETWEEN) { 61909 return /* @__PURE__ */ (0, import_jsx_runtime379.jsx)( 61910 CalendarDateRangeControl, 61911 { 61912 data, 61913 field, 61914 onChange, 61915 hideLabelFromVision, 61916 validity 61917 } 61918 ); 61919 } 61920 return /* @__PURE__ */ (0, import_jsx_runtime379.jsx)( 61921 CalendarDateControl, 61922 { 61923 data, 61924 field, 61925 onChange, 61926 hideLabelFromVision, 61927 validity 61928 } 61929 ); 61930 } 61931 61932 // packages/dataviews/build-module/dataform-controls/email.js 61933 var import_components213 = __toESM(require_components()); 61934 61935 // packages/dataviews/build-module/dataform-controls/utils/validated-input.js 61936 var import_components212 = __toESM(require_components()); 61937 var import_element217 = __toESM(require_element()); 61938 var import_jsx_runtime380 = __toESM(require_jsx_runtime()); 61939 var { ValidatedInputControl: ValidatedInputControl2 } = unlock3(import_components212.privateApis); 61940 function ValidatedText({ 61941 data, 61942 field, 61943 onChange, 61944 hideLabelFromVision, 61945 type, 61946 prefix: prefix2, 61947 suffix, 61948 validity 61949 }) { 61950 const { label, placeholder, description, getValue, setValue, isValid: isValid2 } = field; 61951 const value = getValue({ item: data }); 61952 const onChangeControl = (0, import_element217.useCallback)( 61953 (newValue) => onChange( 61954 setValue({ 61955 item: data, 61956 value: newValue 61957 }) 61958 ), 61959 [data, setValue, onChange] 61960 ); 61961 return /* @__PURE__ */ (0, import_jsx_runtime380.jsx)( 61962 ValidatedInputControl2, 61963 { 61964 required: !!isValid2.required, 61965 customValidity: getCustomValidity(isValid2, validity), 61966 label, 61967 placeholder, 61968 value: value ?? "", 61969 help: description, 61970 onChange: onChangeControl, 61971 hideLabelFromVision, 61972 type, 61973 prefix: prefix2, 61974 suffix, 61975 pattern: isValid2.pattern ? isValid2.pattern.constraint : void 0, 61976 minLength: isValid2.minLength ? isValid2.minLength.constraint : void 0, 61977 maxLength: isValid2.maxLength ? isValid2.maxLength.constraint : void 0, 61978 __next40pxDefaultSize: true 61979 } 61980 ); 61981 } 61982 61983 // packages/dataviews/build-module/dataform-controls/email.js 61984 var import_jsx_runtime381 = __toESM(require_jsx_runtime()); 61985 function Email({ 61986 data, 61987 field, 61988 onChange, 61989 hideLabelFromVision, 61990 validity 61991 }) { 61992 return /* @__PURE__ */ (0, import_jsx_runtime381.jsx)( 61993 ValidatedText, 61994 { 61995 ...{ 61996 data, 61997 field, 61998 onChange, 61999 hideLabelFromVision, 62000 validity, 62001 type: "email", 62002 prefix: /* @__PURE__ */ (0, import_jsx_runtime381.jsx)(import_components213.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime381.jsx)(import_components213.Icon, { icon: envelope_default }) }) 62003 } 62004 } 62005 ); 62006 } 62007 62008 // packages/dataviews/build-module/dataform-controls/telephone.js 62009 var import_components214 = __toESM(require_components()); 62010 var import_jsx_runtime382 = __toESM(require_jsx_runtime()); 62011 function Telephone({ 62012 data, 62013 field, 62014 onChange, 62015 hideLabelFromVision, 62016 validity 62017 }) { 62018 return /* @__PURE__ */ (0, import_jsx_runtime382.jsx)( 62019 ValidatedText, 62020 { 62021 ...{ 62022 data, 62023 field, 62024 onChange, 62025 hideLabelFromVision, 62026 validity, 62027 type: "tel", 62028 prefix: /* @__PURE__ */ (0, import_jsx_runtime382.jsx)(import_components214.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime382.jsx)(import_components214.Icon, { icon: mobile_default }) }) 62029 } 62030 } 62031 ); 62032 } 62033 62034 // packages/dataviews/build-module/dataform-controls/url.js 62035 var import_components215 = __toESM(require_components()); 62036 var import_jsx_runtime383 = __toESM(require_jsx_runtime()); 62037 function Url({ 62038 data, 62039 field, 62040 onChange, 62041 hideLabelFromVision, 62042 validity 62043 }) { 62044 return /* @__PURE__ */ (0, import_jsx_runtime383.jsx)( 62045 ValidatedText, 62046 { 62047 ...{ 62048 data, 62049 field, 62050 onChange, 62051 hideLabelFromVision, 62052 validity, 62053 type: "url", 62054 prefix: /* @__PURE__ */ (0, import_jsx_runtime383.jsx)(import_components215.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime383.jsx)(import_components215.Icon, { icon: link_default }) }) 62055 } 62056 } 62057 ); 62058 } 62059 62060 // packages/dataviews/build-module/dataform-controls/utils/validated-number.js 62061 var import_components216 = __toESM(require_components()); 62062 var import_element218 = __toESM(require_element()); 62063 var import_i18n202 = __toESM(require_i18n()); 62064 var import_jsx_runtime384 = __toESM(require_jsx_runtime()); 62065 var { ValidatedNumberControl } = unlock3(import_components216.privateApis); 62066 function toNumberOrEmpty(value) { 62067 if (value === "" || value === void 0) { 62068 return ""; 62069 } 62070 const number = Number(value); 62071 return Number.isFinite(number) ? number : ""; 62072 } 62073 function BetweenControls({ 62074 value, 62075 onChange, 62076 hideLabelFromVision, 62077 step 62078 }) { 62079 const [min = "", max = ""] = value; 62080 const onChangeMin = (0, import_element218.useCallback)( 62081 (newValue) => onChange([toNumberOrEmpty(newValue), max]), 62082 [onChange, max] 62083 ); 62084 const onChangeMax = (0, import_element218.useCallback)( 62085 (newValue) => onChange([min, toNumberOrEmpty(newValue)]), 62086 [onChange, min] 62087 ); 62088 return /* @__PURE__ */ (0, import_jsx_runtime384.jsx)( 62089 import_components216.BaseControl, 62090 { 62091 help: (0, import_i18n202.__)("The max. value must be greater than the min. value."), 62092 children: /* @__PURE__ */ (0, import_jsx_runtime384.jsxs)(import_components216.Flex, { direction: "row", gap: 4, children: [ 62093 /* @__PURE__ */ (0, import_jsx_runtime384.jsx)( 62094 import_components216.__experimentalNumberControl, 62095 { 62096 label: (0, import_i18n202.__)("Min."), 62097 value: min, 62098 max: max ? Number(max) - step : void 0, 62099 onChange: onChangeMin, 62100 __next40pxDefaultSize: true, 62101 hideLabelFromVision, 62102 step 62103 } 62104 ), 62105 /* @__PURE__ */ (0, import_jsx_runtime384.jsx)( 62106 import_components216.__experimentalNumberControl, 62107 { 62108 label: (0, import_i18n202.__)("Max."), 62109 value: max, 62110 min: min ? Number(min) + step : void 0, 62111 onChange: onChangeMax, 62112 __next40pxDefaultSize: true, 62113 hideLabelFromVision, 62114 step 62115 } 62116 ) 62117 ] }) 62118 } 62119 ); 62120 } 62121 function ValidatedNumber({ 62122 data, 62123 field, 62124 onChange, 62125 hideLabelFromVision, 62126 operator, 62127 validity 62128 }) { 62129 const decimals = field.format?.decimals ?? 0; 62130 const step = Math.pow(10, Math.abs(decimals) * -1); 62131 const { label, description, getValue, setValue, isValid: isValid2 } = field; 62132 const value = getValue({ item: data }) ?? ""; 62133 const onChangeControl = (0, import_element218.useCallback)( 62134 (newValue) => { 62135 onChange( 62136 setValue({ 62137 item: data, 62138 // Do not convert an empty string or undefined to a number, 62139 // otherwise there's a mismatch between the UI control (empty) 62140 // and the data relied by onChange (0). 62141 value: ["", void 0].includes(newValue) ? void 0 : Number(newValue) 62142 }) 62143 ); 62144 }, 62145 [data, onChange, setValue] 62146 ); 62147 const onChangeBetweenControls = (0, import_element218.useCallback)( 62148 (newValue) => { 62149 onChange( 62150 setValue({ 62151 item: data, 62152 value: newValue 62153 }) 62154 ); 62155 }, 62156 [data, onChange, setValue] 62157 ); 62158 if (operator === OPERATOR_BETWEEN) { 62159 let valueBetween = ["", ""]; 62160 if (Array.isArray(value) && value.length === 2 && value.every( 62161 (element) => typeof element === "number" || element === "" 62162 )) { 62163 valueBetween = value; 62164 } 62165 return /* @__PURE__ */ (0, import_jsx_runtime384.jsx)( 62166 BetweenControls, 62167 { 62168 value: valueBetween, 62169 onChange: onChangeBetweenControls, 62170 hideLabelFromVision, 62171 step 62172 } 62173 ); 62174 } 62175 return /* @__PURE__ */ (0, import_jsx_runtime384.jsx)( 62176 ValidatedNumberControl, 62177 { 62178 required: !!isValid2.required, 62179 customValidity: getCustomValidity(isValid2, validity), 62180 label, 62181 help: description, 62182 value, 62183 onChange: onChangeControl, 62184 __next40pxDefaultSize: true, 62185 hideLabelFromVision, 62186 step, 62187 min: isValid2.min ? isValid2.min.constraint : void 0, 62188 max: isValid2.max ? isValid2.max.constraint : void 0 62189 } 62190 ); 62191 } 62192 62193 // packages/dataviews/build-module/dataform-controls/integer.js 62194 var import_jsx_runtime385 = __toESM(require_jsx_runtime()); 62195 function Integer(props) { 62196 return /* @__PURE__ */ (0, import_jsx_runtime385.jsx)(ValidatedNumber, { ...props }); 62197 } 62198 62199 // packages/dataviews/build-module/dataform-controls/number.js 62200 var import_jsx_runtime386 = __toESM(require_jsx_runtime()); 62201 function Number2(props) { 62202 return /* @__PURE__ */ (0, import_jsx_runtime386.jsx)(ValidatedNumber, { ...props }); 62203 } 62204 62205 // packages/dataviews/build-module/dataform-controls/radio.js 62206 var import_components217 = __toESM(require_components()); 62207 var import_element219 = __toESM(require_element()); 62208 var import_jsx_runtime387 = __toESM(require_jsx_runtime()); 62209 var { ValidatedRadioControl } = unlock3(import_components217.privateApis); 62210 function Radio({ 62211 data, 62212 field, 62213 onChange, 62214 hideLabelFromVision, 62215 validity 62216 }) { 62217 const { label, description, getValue, setValue, isValid: isValid2 } = field; 62218 const { elements, isLoading } = useElements({ 62219 elements: field.elements, 62220 getElements: field.getElements 62221 }); 62222 const value = getValue({ item: data }); 62223 const onChangeControl = (0, import_element219.useCallback)( 62224 (newValue) => onChange(setValue({ item: data, value: newValue })), 62225 [data, onChange, setValue] 62226 ); 62227 if (isLoading) { 62228 return /* @__PURE__ */ (0, import_jsx_runtime387.jsx)(import_components217.Spinner, {}); 62229 } 62230 return /* @__PURE__ */ (0, import_jsx_runtime387.jsx)( 62231 ValidatedRadioControl, 62232 { 62233 required: !!field.isValid?.required, 62234 customValidity: getCustomValidity(isValid2, validity), 62235 label, 62236 help: description, 62237 onChange: onChangeControl, 62238 options: elements, 62239 selected: value, 62240 hideLabelFromVision 62241 } 62242 ); 62243 } 62244 62245 // packages/dataviews/build-module/dataform-controls/select.js 62246 var import_components218 = __toESM(require_components()); 62247 var import_element220 = __toESM(require_element()); 62248 var import_jsx_runtime388 = __toESM(require_jsx_runtime()); 62249 var { ValidatedSelectControl } = unlock3(import_components218.privateApis); 62250 function Select({ 62251 data, 62252 field, 62253 onChange, 62254 hideLabelFromVision, 62255 validity 62256 }) { 62257 const { type, label, description, getValue, setValue, isValid: isValid2 } = field; 62258 const isMultiple = type === "array"; 62259 const value = getValue({ item: data }) ?? (isMultiple ? [] : ""); 62260 const onChangeControl = (0, import_element220.useCallback)( 62261 (newValue) => onChange(setValue({ item: data, value: newValue })), 62262 [data, onChange, setValue] 62263 ); 62264 const { elements, isLoading } = useElements({ 62265 elements: field.elements, 62266 getElements: field.getElements 62267 }); 62268 if (isLoading) { 62269 return /* @__PURE__ */ (0, import_jsx_runtime388.jsx)(import_components218.Spinner, {}); 62270 } 62271 return /* @__PURE__ */ (0, import_jsx_runtime388.jsx)( 62272 ValidatedSelectControl, 62273 { 62274 required: !!field.isValid?.required, 62275 customValidity: getCustomValidity(isValid2, validity), 62276 label, 62277 value, 62278 help: description, 62279 options: elements, 62280 onChange: onChangeControl, 62281 __next40pxDefaultSize: true, 62282 hideLabelFromVision, 62283 multiple: isMultiple 62284 } 62285 ); 62286 } 62287 62288 // packages/dataviews/build-module/dataform-controls/text.js 62289 var import_element221 = __toESM(require_element()); 62290 var import_jsx_runtime389 = __toESM(require_jsx_runtime()); 62291 function Text8({ 62292 data, 62293 field, 62294 onChange, 62295 hideLabelFromVision, 62296 config: config2, 62297 validity 62298 }) { 62299 const { prefix: prefix2, suffix } = config2 || {}; 62300 return /* @__PURE__ */ (0, import_jsx_runtime389.jsx)( 62301 ValidatedText, 62302 { 62303 ...{ 62304 data, 62305 field, 62306 onChange, 62307 hideLabelFromVision, 62308 validity, 62309 prefix: prefix2 ? (0, import_element221.createElement)(prefix2) : void 0, 62310 suffix: suffix ? (0, import_element221.createElement)(suffix) : void 0 62311 } 62312 } 62313 ); 62314 } 62315 62316 // packages/dataviews/build-module/dataform-controls/toggle.js 62317 var import_components219 = __toESM(require_components()); 62318 var import_element222 = __toESM(require_element()); 62319 var import_jsx_runtime390 = __toESM(require_jsx_runtime()); 62320 var { ValidatedToggleControl } = unlock3(import_components219.privateApis); 62321 function Toggle({ 62322 field, 62323 onChange, 62324 data, 62325 hideLabelFromVision, 62326 validity 62327 }) { 62328 const { label, description, getValue, setValue, isValid: isValid2 } = field; 62329 const onChangeControl = (0, import_element222.useCallback)(() => { 62330 onChange( 62331 setValue({ item: data, value: !getValue({ item: data }) }) 62332 ); 62333 }, [onChange, setValue, data, getValue]); 62334 return /* @__PURE__ */ (0, import_jsx_runtime390.jsx)( 62335 ValidatedToggleControl, 62336 { 62337 required: !!isValid2.required, 62338 customValidity: getCustomValidity(isValid2, validity), 62339 hidden: hideLabelFromVision, 62340 label, 62341 help: description, 62342 checked: getValue({ item: data }), 62343 onChange: onChangeControl 62344 } 62345 ); 62346 } 62347 62348 // packages/dataviews/build-module/dataform-controls/textarea.js 62349 var import_components220 = __toESM(require_components()); 62350 var import_element223 = __toESM(require_element()); 62351 var import_jsx_runtime391 = __toESM(require_jsx_runtime()); 62352 var { ValidatedTextareaControl } = unlock3(import_components220.privateApis); 62353 function Textarea({ 62354 data, 62355 field, 62356 onChange, 62357 hideLabelFromVision, 62358 config: config2, 62359 validity 62360 }) { 62361 const { rows = 4 } = config2 || {}; 62362 const { label, placeholder, description, setValue, isValid: isValid2 } = field; 62363 const value = field.getValue({ item: data }); 62364 const onChangeControl = (0, import_element223.useCallback)( 62365 (newValue) => onChange(setValue({ item: data, value: newValue })), 62366 [data, onChange, setValue] 62367 ); 62368 return /* @__PURE__ */ (0, import_jsx_runtime391.jsx)( 62369 ValidatedTextareaControl, 62370 { 62371 required: !!isValid2.required, 62372 customValidity: getCustomValidity(isValid2, validity), 62373 label, 62374 placeholder, 62375 value: value ?? "", 62376 help: description, 62377 onChange: onChangeControl, 62378 rows, 62379 minLength: isValid2.minLength ? isValid2.minLength.constraint : void 0, 62380 maxLength: isValid2.maxLength ? isValid2.maxLength.constraint : void 0, 62381 __next40pxDefaultSize: true, 62382 hideLabelFromVision 62383 } 62384 ); 62385 } 62386 62387 // packages/dataviews/build-module/dataform-controls/toggle-group.js 62388 var import_components221 = __toESM(require_components()); 62389 var import_element224 = __toESM(require_element()); 62390 var import_jsx_runtime392 = __toESM(require_jsx_runtime()); 62391 var { ValidatedToggleGroupControl } = unlock3(import_components221.privateApis); 62392 function ToggleGroup({ 62393 data, 62394 field, 62395 onChange, 62396 hideLabelFromVision, 62397 validity 62398 }) { 62399 const { getValue, setValue, isValid: isValid2 } = field; 62400 const value = getValue({ item: data }); 62401 const onChangeControl = (0, import_element224.useCallback)( 62402 (newValue) => onChange(setValue({ item: data, value: newValue })), 62403 [data, onChange, setValue] 62404 ); 62405 const { elements, isLoading } = useElements({ 62406 elements: field.elements, 62407 getElements: field.getElements 62408 }); 62409 if (isLoading) { 62410 return /* @__PURE__ */ (0, import_jsx_runtime392.jsx)(import_components221.Spinner, {}); 62411 } 62412 if (elements.length === 0) { 62413 return null; 62414 } 62415 const selectedOption = elements.find((el) => el.value === value); 62416 return /* @__PURE__ */ (0, import_jsx_runtime392.jsx)( 62417 ValidatedToggleGroupControl, 62418 { 62419 required: !!field.isValid?.required, 62420 customValidity: getCustomValidity(isValid2, validity), 62421 __next40pxDefaultSize: true, 62422 isBlock: true, 62423 label: field.label, 62424 help: selectedOption?.description || field.description, 62425 onChange: onChangeControl, 62426 value, 62427 hideLabelFromVision, 62428 children: elements.map((el) => /* @__PURE__ */ (0, import_jsx_runtime392.jsx)( 62429 import_components221.__experimentalToggleGroupControlOption, 62430 { 62431 label: el.label, 62432 value: el.value 62433 }, 62434 el.value 62435 )) 62436 } 62437 ); 62438 } 62439 62440 // packages/dataviews/build-module/dataform-controls/array.js 62441 var import_components222 = __toESM(require_components()); 62442 var import_element225 = __toESM(require_element()); 62443 var import_jsx_runtime393 = __toESM(require_jsx_runtime()); 62444 var { ValidatedFormTokenField } = unlock3(import_components222.privateApis); 62445 function ArrayControl({ 62446 data, 62447 field, 62448 onChange, 62449 hideLabelFromVision, 62450 validity 62451 }) { 62452 const { label, placeholder, getValue, setValue, isValid: isValid2 } = field; 62453 const value = getValue({ item: data }); 62454 const { elements, isLoading } = useElements({ 62455 elements: field.elements, 62456 getElements: field.getElements 62457 }); 62458 const arrayValueAsElements = (0, import_element225.useMemo)( 62459 () => Array.isArray(value) ? value.map((token) => { 62460 const element = elements?.find( 62461 (suggestion) => suggestion.value === token 62462 ); 62463 return element || { value: token, label: token }; 62464 }) : [], 62465 [value, elements] 62466 ); 62467 const onChangeControl = (0, import_element225.useCallback)( 62468 (tokens) => { 62469 const valueTokens = tokens.map((token) => { 62470 if (typeof token === "object" && "value" in token) { 62471 return token.value; 62472 } 62473 return token; 62474 }); 62475 onChange(setValue({ item: data, value: valueTokens })); 62476 }, 62477 [onChange, setValue, data] 62478 ); 62479 if (isLoading) { 62480 return /* @__PURE__ */ (0, import_jsx_runtime393.jsx)(import_components222.Spinner, {}); 62481 } 62482 return /* @__PURE__ */ (0, import_jsx_runtime393.jsx)( 62483 ValidatedFormTokenField, 62484 { 62485 required: !!isValid2?.required, 62486 customValidity: getCustomValidity(isValid2, validity), 62487 label: hideLabelFromVision ? void 0 : label, 62488 value: arrayValueAsElements, 62489 onChange: onChangeControl, 62490 placeholder, 62491 suggestions: elements?.map((element) => element.value), 62492 __experimentalValidateInput: (token) => { 62493 if (field.isValid?.elements && elements) { 62494 return elements.some( 62495 (element) => element.value === token || element.label === token 62496 ); 62497 } 62498 return true; 62499 }, 62500 __experimentalExpandOnFocus: elements && elements.length > 0, 62501 __experimentalShowHowTo: !field.isValid?.elements, 62502 displayTransform: (token) => { 62503 if (typeof token === "object" && "label" in token) { 62504 return token.label; 62505 } 62506 if (typeof token === "string" && elements) { 62507 const element = elements.find( 62508 (el) => el.value === token 62509 ); 62510 return element?.label || token; 62511 } 62512 return token; 62513 }, 62514 __experimentalRenderItem: ({ item }) => { 62515 if (typeof item === "string" && elements) { 62516 const element = elements.find( 62517 (el) => el.value === item 62518 ); 62519 return /* @__PURE__ */ (0, import_jsx_runtime393.jsx)("span", { children: element?.label || item }); 62520 } 62521 return /* @__PURE__ */ (0, import_jsx_runtime393.jsx)("span", { children: item }); 62522 } 62523 } 62524 ); 62525 } 62526 62527 // packages/dataviews/build-module/dataform-controls/color.js 62528 var import_components223 = __toESM(require_components()); 62529 var import_element226 = __toESM(require_element()); 62530 var import_jsx_runtime394 = __toESM(require_jsx_runtime()); 62531 var { ValidatedInputControl: ValidatedInputControl3, Picker } = unlock3(import_components223.privateApis); 62532 var ColorPicker = ({ 62533 color, 62534 onColorChange 62535 }) => { 62536 const validColor = color && w(color).isValid() ? color : "#ffffff"; 62537 return /* @__PURE__ */ (0, import_jsx_runtime394.jsx)( 62538 import_components223.Dropdown, 62539 { 62540 renderToggle: ({ onToggle, isOpen }) => /* @__PURE__ */ (0, import_jsx_runtime394.jsx)(import_components223.__experimentalInputControlPrefixWrapper, { variant: "icon", children: /* @__PURE__ */ (0, import_jsx_runtime394.jsx)( 62541 "button", 62542 { 62543 type: "button", 62544 onClick: onToggle, 62545 style: { 62546 width: "24px", 62547 height: "24px", 62548 borderRadius: "50%", 62549 backgroundColor: validColor, 62550 border: "1px solid #ddd", 62551 cursor: "pointer", 62552 outline: isOpen ? "2px solid #007cba" : "none", 62553 outlineOffset: "2px", 62554 display: "flex", 62555 alignItems: "center", 62556 justifyContent: "center", 62557 padding: 0, 62558 margin: 0 62559 }, 62560 "aria-label": "Open color picker" 62561 } 62562 ) }), 62563 renderContent: () => /* @__PURE__ */ (0, import_jsx_runtime394.jsx)("div", { style: { padding: "16px" }, children: /* @__PURE__ */ (0, import_jsx_runtime394.jsx)( 62564 Picker, 62565 { 62566 color: w(validColor), 62567 onChange: onColorChange, 62568 enableAlpha: true 62569 } 62570 ) }) 62571 } 62572 ); 62573 }; 62574 function Color({ 62575 data, 62576 field, 62577 onChange, 62578 hideLabelFromVision, 62579 validity 62580 }) { 62581 const { label, placeholder, description, setValue, isValid: isValid2 } = field; 62582 const value = field.getValue({ item: data }) || ""; 62583 const handleColorChange = (0, import_element226.useCallback)( 62584 (colorObject) => { 62585 onChange(setValue({ item: data, value: colorObject.toHex() })); 62586 }, 62587 [data, onChange, setValue] 62588 ); 62589 const handleInputChange = (0, import_element226.useCallback)( 62590 (newValue) => { 62591 onChange(setValue({ item: data, value: newValue || "" })); 62592 }, 62593 [data, onChange, setValue] 62594 ); 62595 return /* @__PURE__ */ (0, import_jsx_runtime394.jsx)( 62596 ValidatedInputControl3, 62597 { 62598 required: !!field.isValid?.required, 62599 customValidity: getCustomValidity(isValid2, validity), 62600 label, 62601 placeholder, 62602 value, 62603 help: description, 62604 onChange: handleInputChange, 62605 hideLabelFromVision, 62606 type: "text", 62607 prefix: /* @__PURE__ */ (0, import_jsx_runtime394.jsx)( 62608 ColorPicker, 62609 { 62610 color: value, 62611 onColorChange: handleColorChange 62612 } 62613 ) 62614 } 62615 ); 62616 } 62617 62618 // packages/dataviews/build-module/dataform-controls/password.js 62619 var import_components224 = __toESM(require_components()); 62620 var import_element227 = __toESM(require_element()); 62621 var import_i18n203 = __toESM(require_i18n()); 62622 var import_jsx_runtime395 = __toESM(require_jsx_runtime()); 62623 function Password({ 62624 data, 62625 field, 62626 onChange, 62627 hideLabelFromVision, 62628 validity 62629 }) { 62630 const [isVisible, setIsVisible] = (0, import_element227.useState)(false); 62631 const toggleVisibility = (0, import_element227.useCallback)(() => { 62632 setIsVisible((prev) => !prev); 62633 }, []); 62634 return /* @__PURE__ */ (0, import_jsx_runtime395.jsx)( 62635 ValidatedText, 62636 { 62637 ...{ 62638 data, 62639 field, 62640 onChange, 62641 hideLabelFromVision, 62642 validity, 62643 type: isVisible ? "text" : "password", 62644 suffix: /* @__PURE__ */ (0, import_jsx_runtime395.jsx)(import_components224.__experimentalInputControlSuffixWrapper, { variant: "control", children: /* @__PURE__ */ (0, import_jsx_runtime395.jsx)( 62645 import_components224.Button, 62646 { 62647 icon: isVisible ? unseen_default : seen_default, 62648 onClick: toggleVisibility, 62649 size: "small", 62650 label: isVisible ? (0, import_i18n203.__)("Hide password") : (0, import_i18n203.__)("Show password") 62651 } 62652 ) }) 62653 } 62654 } 62655 ); 62656 } 62657 62658 // packages/dataviews/build-module/field-types/utils/has-elements.js 62659 function hasElements(field) { 62660 return Array.isArray(field.elements) && field.elements.length > 0 || typeof field.getElements === "function"; 62661 } 62662 62663 // packages/dataviews/build-module/dataform-controls/index.js 62664 var import_jsx_runtime396 = __toESM(require_jsx_runtime()); 62665 var FORM_CONTROLS = { 62666 array: ArrayControl, 62667 checkbox: Checkbox, 62668 color: Color, 62669 datetime: DateTime, 62670 date: DateControl, 62671 email: Email, 62672 telephone: Telephone, 62673 url: Url, 62674 integer: Integer, 62675 number: Number2, 62676 password: Password, 62677 radio: Radio, 62678 select: Select, 62679 text: Text8, 62680 toggle: Toggle, 62681 textarea: Textarea, 62682 toggleGroup: ToggleGroup 62683 }; 62684 function isEditConfig(value) { 62685 return value && typeof value === "object" && typeof value.control === "string"; 62686 } 62687 function createConfiguredControl(config2) { 62688 const { control, ...controlConfig } = config2; 62689 const BaseControlType = getControlByType(control); 62690 if (BaseControlType === null) { 62691 return null; 62692 } 62693 return function ConfiguredControl(props) { 62694 return /* @__PURE__ */ (0, import_jsx_runtime396.jsx)(BaseControlType, { ...props, config: controlConfig }); 62695 }; 62696 } 62697 function getControl(field, fallback) { 62698 if (typeof field.Edit === "function") { 62699 return field.Edit; 62700 } 62701 if (typeof field.Edit === "string") { 62702 return getControlByType(field.Edit); 62703 } 62704 if (isEditConfig(field.Edit)) { 62705 return createConfiguredControl(field.Edit); 62706 } 62707 if (hasElements(field) && field.type !== "array") { 62708 return getControlByType("select"); 62709 } 62710 if (fallback === null) { 62711 return null; 62712 } 62713 return getControlByType(fallback); 62714 } 62715 function getControlByType(type) { 62716 if (Object.keys(FORM_CONTROLS).includes(type)) { 62717 return FORM_CONTROLS[type]; 62718 } 62719 return null; 62720 } 62721 62722 // packages/dataviews/build-module/field-types/utils/get-filter-by.js 62723 function getFilterBy(field, defaultOperators, validOperators) { 62724 if (field.filterBy === false) { 62725 return false; 62726 } 62727 const operators = field.filterBy?.operators?.filter( 62728 (op) => validOperators.includes(op) 62729 ) ?? defaultOperators; 62730 if (operators.length === 0) { 62731 return false; 62732 } 62733 return { 62734 isPrimary: !!field.filterBy?.isPrimary, 62735 operators 62736 }; 62737 } 62738 var get_filter_by_default = getFilterBy; 62739 62740 // packages/dataviews/build-module/field-types/utils/get-value-from-id.js 62741 var getValueFromId = (id) => ({ item }) => { 62742 const path = id.split("."); 62743 let value = item; 62744 for (const segment of path) { 62745 if (value.hasOwnProperty(segment)) { 62746 value = value[segment]; 62747 } else { 62748 value = void 0; 62749 } 62750 } 62751 return value; 62752 }; 62753 var get_value_from_id_default = getValueFromId; 62754 62755 // packages/dataviews/build-module/field-types/utils/set-value-from-id.js 62756 var setValueFromId = (id) => ({ value }) => { 62757 const path = id.split("."); 62758 const result = {}; 62759 let current = result; 62760 for (const segment of path.slice(0, -1)) { 62761 current[segment] = {}; 62762 current = current[segment]; 62763 } 62764 current[path.at(-1)] = value; 62765 return result; 62766 }; 62767 var set_value_from_id_default = setValueFromId; 62768 62769 // packages/dataviews/build-module/field-types/email.js 62770 var import_i18n204 = __toESM(require_i18n()); 62771 62772 // packages/dataviews/build-module/field-types/utils/render-from-elements.js 62773 function RenderFromElements({ 62774 item, 62775 field 62776 }) { 62777 const { elements, isLoading } = useElements({ 62778 elements: field.elements, 62779 getElements: field.getElements 62780 }); 62781 const value = field.getValue({ item }); 62782 if (isLoading) { 62783 return value; 62784 } 62785 if (elements.length === 0) { 62786 return value; 62787 } 62788 return elements?.find((element) => element.value === value)?.label || field.getValue({ item }); 62789 } 62790 62791 // packages/dataviews/build-module/field-types/utils/render-default.js 62792 var import_jsx_runtime397 = __toESM(require_jsx_runtime()); 62793 function render({ 62794 item, 62795 field 62796 }) { 62797 if (field.hasElements) { 62798 return /* @__PURE__ */ (0, import_jsx_runtime397.jsx)(RenderFromElements, { item, field }); 62799 } 62800 return field.getValueFormatted({ item, field }); 62801 } 62802 62803 // packages/dataviews/build-module/field-types/utils/sort-text.js 62804 var sort_text_default = (a2, b2, direction) => { 62805 return direction === "asc" ? a2.localeCompare(b2) : b2.localeCompare(a2); 62806 }; 62807 62808 // packages/dataviews/build-module/field-types/utils/is-valid-required.js 62809 function isValidRequired(item, field) { 62810 const value = field.getValue({ item }); 62811 return ![void 0, "", null].includes(value); 62812 } 62813 62814 // packages/dataviews/build-module/field-types/utils/is-valid-min-length.js 62815 function isValidMinLength(item, field) { 62816 if (typeof field.isValid.minLength?.constraint !== "number") { 62817 return false; 62818 } 62819 const value = field.getValue({ item }); 62820 if ([void 0, "", null].includes(value)) { 62821 return true; 62822 } 62823 return String(value).length >= field.isValid.minLength.constraint; 62824 } 62825 62826 // packages/dataviews/build-module/field-types/utils/is-valid-max-length.js 62827 function isValidMaxLength(item, field) { 62828 if (typeof field.isValid.maxLength?.constraint !== "number") { 62829 return false; 62830 } 62831 const value = field.getValue({ item }); 62832 if ([void 0, "", null].includes(value)) { 62833 return true; 62834 } 62835 return String(value).length <= field.isValid.maxLength.constraint; 62836 } 62837 62838 // packages/dataviews/build-module/field-types/utils/is-valid-pattern.js 62839 function isValidPattern(item, field) { 62840 if (field.isValid.pattern?.constraint === void 0) { 62841 return true; 62842 } 62843 try { 62844 const regexp = new RegExp(field.isValid.pattern.constraint); 62845 const value = field.getValue({ item }); 62846 if ([void 0, "", null].includes(value)) { 62847 return true; 62848 } 62849 return regexp.test(String(value)); 62850 } catch { 62851 return false; 62852 } 62853 } 62854 62855 // packages/dataviews/build-module/field-types/utils/is-valid-elements.js 62856 function isValidElements(item, field) { 62857 const elements = field.elements ?? []; 62858 const validValues = elements.map((el) => el.value); 62859 if (validValues.length === 0) { 62860 return true; 62861 } 62862 const value = field.getValue({ item }); 62863 return [].concat(value).every((v2) => validValues.includes(v2)); 62864 } 62865 62866 // packages/dataviews/build-module/field-types/utils/get-value-formatted-default.js 62867 function getValueFormatted({ 62868 item, 62869 field 62870 }) { 62871 return field.getValue({ item }); 62872 } 62873 var get_value_formatted_default_default = getValueFormatted; 62874 62875 // packages/dataviews/build-module/field-types/email.js 62876 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])?)*$/; 62877 function isValidCustom(item, field) { 62878 const value = field.getValue({ item }); 62879 if (![void 0, "", null].includes(value) && !emailRegex.test(value)) { 62880 return (0, import_i18n204.__)("Value must be a valid email address."); 62881 } 62882 return null; 62883 } 62884 var email_default = { 62885 type: "email", 62886 render, 62887 Edit: "email", 62888 sort: sort_text_default, 62889 enableSorting: true, 62890 enableGlobalSearch: false, 62891 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE], 62892 validOperators: [ 62893 OPERATOR_IS, 62894 OPERATOR_IS_NOT, 62895 OPERATOR_CONTAINS, 62896 OPERATOR_NOT_CONTAINS, 62897 OPERATOR_STARTS_WITH, 62898 // Multiple selection 62899 OPERATOR_IS_ANY, 62900 OPERATOR_IS_NONE, 62901 OPERATOR_IS_ALL, 62902 OPERATOR_IS_NOT_ALL 62903 ], 62904 format: {}, 62905 getValueFormatted: get_value_formatted_default_default, 62906 validate: { 62907 required: isValidRequired, 62908 pattern: isValidPattern, 62909 minLength: isValidMinLength, 62910 maxLength: isValidMaxLength, 62911 elements: isValidElements, 62912 custom: isValidCustom 62913 } 62914 }; 62915 62916 // packages/dataviews/build-module/field-types/integer.js 62917 var import_i18n205 = __toESM(require_i18n()); 62918 62919 // packages/dataviews/build-module/field-types/utils/sort-number.js 62920 var sort_number_default = (a2, b2, direction) => { 62921 return direction === "asc" ? a2 - b2 : b2 - a2; 62922 }; 62923 62924 // packages/dataviews/build-module/field-types/utils/is-valid-min.js 62925 function isValidMin(item, field) { 62926 if (typeof field.isValid.min?.constraint !== "number") { 62927 return false; 62928 } 62929 const value = field.getValue({ item }); 62930 if ([void 0, "", null].includes(value)) { 62931 return true; 62932 } 62933 return Number(value) >= field.isValid.min.constraint; 62934 } 62935 62936 // packages/dataviews/build-module/field-types/utils/is-valid-max.js 62937 function isValidMax(item, field) { 62938 if (typeof field.isValid.max?.constraint !== "number") { 62939 return false; 62940 } 62941 const value = field.getValue({ item }); 62942 if ([void 0, "", null].includes(value)) { 62943 return true; 62944 } 62945 return Number(value) <= field.isValid.max.constraint; 62946 } 62947 62948 // packages/dataviews/build-module/field-types/integer.js 62949 var format2 = { 62950 separatorThousand: "," 62951 }; 62952 function getValueFormatted2({ 62953 item, 62954 field 62955 }) { 62956 let value = field.getValue({ item }); 62957 if (value === null || value === void 0) { 62958 return ""; 62959 } 62960 value = Number(value); 62961 if (!Number.isFinite(value)) { 62962 return String(value); 62963 } 62964 let formatInteger; 62965 if (field.type !== "integer") { 62966 formatInteger = format2; 62967 } else { 62968 formatInteger = field.format; 62969 } 62970 const { separatorThousand } = formatInteger; 62971 const integerValue = Math.trunc(value); 62972 if (!separatorThousand) { 62973 return String(integerValue); 62974 } 62975 return String(integerValue).replace( 62976 /\B(?=(\d{3})+(?!\d))/g, 62977 separatorThousand 62978 ); 62979 } 62980 function isValidCustom2(item, field) { 62981 const value = field.getValue({ item }); 62982 if (![void 0, "", null].includes(value) && !Number.isInteger(value)) { 62983 return (0, import_i18n205.__)("Value must be an integer."); 62984 } 62985 return null; 62986 } 62987 var integer_default = { 62988 type: "integer", 62989 render, 62990 Edit: "integer", 62991 sort: sort_number_default, 62992 enableSorting: true, 62993 enableGlobalSearch: false, 62994 defaultOperators: [ 62995 OPERATOR_IS, 62996 OPERATOR_IS_NOT, 62997 OPERATOR_LESS_THAN, 62998 OPERATOR_GREATER_THAN, 62999 OPERATOR_LESS_THAN_OR_EQUAL, 63000 OPERATOR_GREATER_THAN_OR_EQUAL, 63001 OPERATOR_BETWEEN 63002 ], 63003 validOperators: [ 63004 // Single-selection 63005 OPERATOR_IS, 63006 OPERATOR_IS_NOT, 63007 OPERATOR_LESS_THAN, 63008 OPERATOR_GREATER_THAN, 63009 OPERATOR_LESS_THAN_OR_EQUAL, 63010 OPERATOR_GREATER_THAN_OR_EQUAL, 63011 OPERATOR_BETWEEN, 63012 // Multiple-selection 63013 OPERATOR_IS_ANY, 63014 OPERATOR_IS_NONE, 63015 OPERATOR_IS_ALL, 63016 OPERATOR_IS_NOT_ALL 63017 ], 63018 format: format2, 63019 getValueFormatted: getValueFormatted2, 63020 validate: { 63021 required: isValidRequired, 63022 min: isValidMin, 63023 max: isValidMax, 63024 elements: isValidElements, 63025 custom: isValidCustom2 63026 } 63027 }; 63028 63029 // packages/dataviews/build-module/field-types/number.js 63030 var import_i18n206 = __toESM(require_i18n()); 63031 var format3 = { 63032 separatorThousand: ",", 63033 separatorDecimal: ".", 63034 decimals: 2 63035 }; 63036 function getValueFormatted3({ 63037 item, 63038 field 63039 }) { 63040 let value = field.getValue({ item }); 63041 if (value === null || value === void 0) { 63042 return ""; 63043 } 63044 value = Number(value); 63045 if (!Number.isFinite(value)) { 63046 return String(value); 63047 } 63048 let formatNumber; 63049 if (field.type !== "number") { 63050 formatNumber = format3; 63051 } else { 63052 formatNumber = field.format; 63053 } 63054 const { separatorThousand, separatorDecimal, decimals } = formatNumber; 63055 const fixedValue = value.toFixed(decimals); 63056 const [integerPart, decimalPart] = fixedValue.split("."); 63057 const formattedInteger = separatorThousand ? integerPart.replace(/\B(?=(\d{3})+(?!\d))/g, separatorThousand) : integerPart; 63058 return decimals === 0 ? formattedInteger : formattedInteger + separatorDecimal + decimalPart; 63059 } 63060 function isEmpty3(value) { 63061 return value === "" || value === void 0 || value === null; 63062 } 63063 function isValidCustom3(item, field) { 63064 const value = field.getValue({ item }); 63065 if (!isEmpty3(value) && !Number.isFinite(value)) { 63066 return (0, import_i18n206.__)("Value must be a number."); 63067 } 63068 return null; 63069 } 63070 var number_default = { 63071 type: "number", 63072 render, 63073 Edit: "number", 63074 sort: sort_number_default, 63075 enableSorting: true, 63076 enableGlobalSearch: false, 63077 defaultOperators: [ 63078 OPERATOR_IS, 63079 OPERATOR_IS_NOT, 63080 OPERATOR_LESS_THAN, 63081 OPERATOR_GREATER_THAN, 63082 OPERATOR_LESS_THAN_OR_EQUAL, 63083 OPERATOR_GREATER_THAN_OR_EQUAL, 63084 OPERATOR_BETWEEN 63085 ], 63086 validOperators: [ 63087 // Single-selection 63088 OPERATOR_IS, 63089 OPERATOR_IS_NOT, 63090 OPERATOR_LESS_THAN, 63091 OPERATOR_GREATER_THAN, 63092 OPERATOR_LESS_THAN_OR_EQUAL, 63093 OPERATOR_GREATER_THAN_OR_EQUAL, 63094 OPERATOR_BETWEEN, 63095 // Multiple-selection 63096 OPERATOR_IS_ANY, 63097 OPERATOR_IS_NONE, 63098 OPERATOR_IS_ALL, 63099 OPERATOR_IS_NOT_ALL 63100 ], 63101 format: format3, 63102 getValueFormatted: getValueFormatted3, 63103 validate: { 63104 required: isValidRequired, 63105 min: isValidMin, 63106 max: isValidMax, 63107 elements: isValidElements, 63108 custom: isValidCustom3 63109 } 63110 }; 63111 63112 // packages/dataviews/build-module/field-types/text.js 63113 var text_default = { 63114 type: "text", 63115 render, 63116 Edit: "text", 63117 sort: sort_text_default, 63118 enableSorting: true, 63119 enableGlobalSearch: false, 63120 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE], 63121 validOperators: [ 63122 // Single selection 63123 OPERATOR_IS, 63124 OPERATOR_IS_NOT, 63125 OPERATOR_CONTAINS, 63126 OPERATOR_NOT_CONTAINS, 63127 OPERATOR_STARTS_WITH, 63128 // Multiple selection 63129 OPERATOR_IS_ANY, 63130 OPERATOR_IS_NONE, 63131 OPERATOR_IS_ALL, 63132 OPERATOR_IS_NOT_ALL 63133 ], 63134 format: {}, 63135 getValueFormatted: get_value_formatted_default_default, 63136 validate: { 63137 required: isValidRequired, 63138 pattern: isValidPattern, 63139 minLength: isValidMinLength, 63140 maxLength: isValidMaxLength, 63141 elements: isValidElements 63142 } 63143 }; 63144 63145 // packages/dataviews/build-module/field-types/datetime.js 63146 var import_date6 = __toESM(require_date()); 63147 var format4 = { 63148 datetime: (0, import_date6.getSettings)().formats.datetime, 63149 weekStartsOn: (0, import_date6.getSettings)().l10n.startOfWeek 63150 }; 63151 function getValueFormatted4({ 63152 item, 63153 field 63154 }) { 63155 const value = field.getValue({ item }); 63156 if (["", void 0, null].includes(value)) { 63157 return ""; 63158 } 63159 let formatDatetime; 63160 if (field.type !== "datetime") { 63161 formatDatetime = format4; 63162 } else { 63163 formatDatetime = field.format; 63164 } 63165 return (0, import_date6.dateI18n)(formatDatetime.datetime, (0, import_date6.getDate)(value)); 63166 } 63167 var sort = (a2, b2, direction) => { 63168 const timeA = new Date(a2).getTime(); 63169 const timeB = new Date(b2).getTime(); 63170 return direction === "asc" ? timeA - timeB : timeB - timeA; 63171 }; 63172 var datetime_default = { 63173 type: "datetime", 63174 render, 63175 Edit: "datetime", 63176 sort, 63177 enableSorting: true, 63178 enableGlobalSearch: false, 63179 defaultOperators: [ 63180 OPERATOR_ON, 63181 OPERATOR_NOT_ON, 63182 OPERATOR_BEFORE, 63183 OPERATOR_AFTER, 63184 OPERATOR_BEFORE_INC, 63185 OPERATOR_AFTER_INC, 63186 OPERATOR_IN_THE_PAST, 63187 OPERATOR_OVER 63188 ], 63189 validOperators: [ 63190 OPERATOR_ON, 63191 OPERATOR_NOT_ON, 63192 OPERATOR_BEFORE, 63193 OPERATOR_AFTER, 63194 OPERATOR_BEFORE_INC, 63195 OPERATOR_AFTER_INC, 63196 OPERATOR_IN_THE_PAST, 63197 OPERATOR_OVER 63198 ], 63199 format: format4, 63200 getValueFormatted: getValueFormatted4, 63201 validate: { 63202 required: isValidRequired, 63203 elements: isValidElements 63204 } 63205 }; 63206 63207 // packages/dataviews/build-module/field-types/date.js 63208 var import_date7 = __toESM(require_date()); 63209 var format5 = { 63210 date: (0, import_date7.getSettings)().formats.date, 63211 weekStartsOn: (0, import_date7.getSettings)().l10n.startOfWeek 63212 }; 63213 function getValueFormatted5({ 63214 item, 63215 field 63216 }) { 63217 const value = field.getValue({ item }); 63218 if (["", void 0, null].includes(value)) { 63219 return ""; 63220 } 63221 let formatDate2; 63222 if (field.type !== "date") { 63223 formatDate2 = format5; 63224 } else { 63225 formatDate2 = field.format; 63226 } 63227 return (0, import_date7.dateI18n)(formatDate2.date, (0, import_date7.getDate)(value)); 63228 } 63229 var sort2 = (a2, b2, direction) => { 63230 const timeA = new Date(a2).getTime(); 63231 const timeB = new Date(b2).getTime(); 63232 return direction === "asc" ? timeA - timeB : timeB - timeA; 63233 }; 63234 var date_default = { 63235 type: "date", 63236 render, 63237 Edit: "date", 63238 sort: sort2, 63239 enableSorting: true, 63240 enableGlobalSearch: false, 63241 defaultOperators: [ 63242 OPERATOR_ON, 63243 OPERATOR_NOT_ON, 63244 OPERATOR_BEFORE, 63245 OPERATOR_AFTER, 63246 OPERATOR_BEFORE_INC, 63247 OPERATOR_AFTER_INC, 63248 OPERATOR_IN_THE_PAST, 63249 OPERATOR_OVER, 63250 OPERATOR_BETWEEN 63251 ], 63252 validOperators: [ 63253 OPERATOR_ON, 63254 OPERATOR_NOT_ON, 63255 OPERATOR_BEFORE, 63256 OPERATOR_AFTER, 63257 OPERATOR_BEFORE_INC, 63258 OPERATOR_AFTER_INC, 63259 OPERATOR_IN_THE_PAST, 63260 OPERATOR_OVER, 63261 OPERATOR_BETWEEN 63262 ], 63263 format: format5, 63264 getValueFormatted: getValueFormatted5, 63265 validate: { 63266 required: isValidRequired, 63267 elements: isValidElements 63268 } 63269 }; 63270 63271 // packages/dataviews/build-module/field-types/boolean.js 63272 var import_i18n207 = __toESM(require_i18n()); 63273 63274 // packages/dataviews/build-module/field-types/utils/is-valid-required-for-bool.js 63275 function isValidRequiredForBool(item, field) { 63276 const value = field.getValue({ item }); 63277 return value === true; 63278 } 63279 63280 // packages/dataviews/build-module/field-types/boolean.js 63281 function getValueFormatted6({ 63282 item, 63283 field 63284 }) { 63285 const value = field.getValue({ item }); 63286 if (value === true) { 63287 return (0, import_i18n207.__)("True"); 63288 } 63289 if (value === false) { 63290 return (0, import_i18n207.__)("False"); 63291 } 63292 return ""; 63293 } 63294 function isValidCustom4(item, field) { 63295 const value = field.getValue({ item }); 63296 if (![void 0, "", null].includes(value) && ![true, false].includes(value)) { 63297 return (0, import_i18n207.__)("Value must be true, false, or undefined"); 63298 } 63299 return null; 63300 } 63301 var sort3 = (a2, b2, direction) => { 63302 const boolA = Boolean(a2); 63303 const boolB = Boolean(b2); 63304 if (boolA === boolB) { 63305 return 0; 63306 } 63307 if (direction === "asc") { 63308 return boolA ? 1 : -1; 63309 } 63310 return boolA ? -1 : 1; 63311 }; 63312 var boolean_default = { 63313 type: "boolean", 63314 render, 63315 Edit: "checkbox", 63316 sort: sort3, 63317 validate: { 63318 required: isValidRequiredForBool, 63319 elements: isValidElements, 63320 custom: isValidCustom4 63321 }, 63322 enableSorting: true, 63323 enableGlobalSearch: false, 63324 defaultOperators: [OPERATOR_IS, OPERATOR_IS_NOT], 63325 validOperators: [OPERATOR_IS, OPERATOR_IS_NOT], 63326 format: {}, 63327 getValueFormatted: getValueFormatted6 63328 }; 63329 63330 // packages/dataviews/build-module/field-types/media.js 63331 var media_default2 = { 63332 type: "media", 63333 render: () => null, 63334 Edit: null, 63335 sort: () => 0, 63336 enableSorting: false, 63337 enableGlobalSearch: false, 63338 defaultOperators: [], 63339 validOperators: [], 63340 format: {}, 63341 getValueFormatted: get_value_formatted_default_default, 63342 // cannot validate any constraint, so 63343 // the only available validation for the field author 63344 // would be providing a custom validator. 63345 validate: {} 63346 }; 63347 63348 // packages/dataviews/build-module/field-types/array.js 63349 var import_i18n208 = __toESM(require_i18n()); 63350 63351 // packages/dataviews/build-module/field-types/utils/is-valid-required-for-array.js 63352 function isValidRequiredForArray(item, field) { 63353 const value = field.getValue({ item }); 63354 return Array.isArray(value) && value.length > 0 && value.every( 63355 (element) => ![void 0, "", null].includes(element) 63356 ); 63357 } 63358 63359 // packages/dataviews/build-module/field-types/array.js 63360 function getValueFormatted7({ 63361 item, 63362 field 63363 }) { 63364 const value = field.getValue({ item }); 63365 const arr = Array.isArray(value) ? value : []; 63366 return arr.join(", "); 63367 } 63368 function render2({ item, field }) { 63369 return getValueFormatted7({ item, field }); 63370 } 63371 function isValidCustom5(item, field) { 63372 const value = field.getValue({ item }); 63373 if (![void 0, "", null].includes(value) && !Array.isArray(value)) { 63374 return (0, import_i18n208.__)("Value must be an array."); 63375 } 63376 if (!value.every((v2) => typeof v2 === "string")) { 63377 return (0, import_i18n208.__)("Every value must be a string."); 63378 } 63379 return null; 63380 } 63381 var sort4 = (a2, b2, direction) => { 63382 const arrA = Array.isArray(a2) ? a2 : []; 63383 const arrB = Array.isArray(b2) ? b2 : []; 63384 if (arrA.length !== arrB.length) { 63385 return direction === "asc" ? arrA.length - arrB.length : arrB.length - arrA.length; 63386 } 63387 const joinedA = arrA.join(","); 63388 const joinedB = arrB.join(","); 63389 return direction === "asc" ? joinedA.localeCompare(joinedB) : joinedB.localeCompare(joinedA); 63390 }; 63391 var array_default = { 63392 type: "array", 63393 render: render2, 63394 Edit: "array", 63395 sort: sort4, 63396 enableSorting: true, 63397 enableGlobalSearch: false, 63398 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE], 63399 validOperators: [ 63400 OPERATOR_IS_ANY, 63401 OPERATOR_IS_NONE, 63402 OPERATOR_IS_ALL, 63403 OPERATOR_IS_NOT_ALL 63404 ], 63405 format: {}, 63406 getValueFormatted: getValueFormatted7, 63407 validate: { 63408 required: isValidRequiredForArray, 63409 elements: isValidElements, 63410 custom: isValidCustom5 63411 } 63412 }; 63413 63414 // packages/dataviews/build-module/field-types/password.js 63415 function getValueFormatted8({ 63416 item, 63417 field 63418 }) { 63419 return field.getValue({ item }) ? "\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022" : ""; 63420 } 63421 var password_default = { 63422 type: "password", 63423 render, 63424 Edit: "password", 63425 sort: () => 0, 63426 // Passwords should not be sortable for security reasons 63427 enableSorting: false, 63428 enableGlobalSearch: false, 63429 defaultOperators: [], 63430 validOperators: [], 63431 format: {}, 63432 getValueFormatted: getValueFormatted8, 63433 validate: { 63434 required: isValidRequired, 63435 pattern: isValidPattern, 63436 minLength: isValidMinLength, 63437 maxLength: isValidMaxLength, 63438 elements: isValidElements 63439 } 63440 }; 63441 63442 // packages/dataviews/build-module/field-types/telephone.js 63443 var telephone_default = { 63444 type: "telephone", 63445 render, 63446 Edit: "telephone", 63447 sort: sort_text_default, 63448 enableSorting: true, 63449 enableGlobalSearch: false, 63450 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE], 63451 validOperators: [ 63452 OPERATOR_IS, 63453 OPERATOR_IS_NOT, 63454 OPERATOR_CONTAINS, 63455 OPERATOR_NOT_CONTAINS, 63456 OPERATOR_STARTS_WITH, 63457 // Multiple selection 63458 OPERATOR_IS_ANY, 63459 OPERATOR_IS_NONE, 63460 OPERATOR_IS_ALL, 63461 OPERATOR_IS_NOT_ALL 63462 ], 63463 format: {}, 63464 getValueFormatted: get_value_formatted_default_default, 63465 validate: { 63466 required: isValidRequired, 63467 pattern: isValidPattern, 63468 minLength: isValidMinLength, 63469 maxLength: isValidMaxLength, 63470 elements: isValidElements 63471 } 63472 }; 63473 63474 // packages/dataviews/build-module/field-types/color.js 63475 var import_i18n209 = __toESM(require_i18n()); 63476 var import_jsx_runtime398 = __toESM(require_jsx_runtime()); 63477 function render3({ item, field }) { 63478 if (field.hasElements) { 63479 return /* @__PURE__ */ (0, import_jsx_runtime398.jsx)(RenderFromElements, { item, field }); 63480 } 63481 const value = get_value_formatted_default_default({ item, field }); 63482 if (!value || !w(value).isValid()) { 63483 return value; 63484 } 63485 return /* @__PURE__ */ (0, import_jsx_runtime398.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "8px" }, children: [ 63486 /* @__PURE__ */ (0, import_jsx_runtime398.jsx)( 63487 "div", 63488 { 63489 style: { 63490 width: "16px", 63491 height: "16px", 63492 borderRadius: "50%", 63493 backgroundColor: value, 63494 border: "1px solid #ddd", 63495 flexShrink: 0 63496 } 63497 } 63498 ), 63499 /* @__PURE__ */ (0, import_jsx_runtime398.jsx)("span", { children: value }) 63500 ] }); 63501 } 63502 function isValidCustom6(item, field) { 63503 const value = field.getValue({ item }); 63504 if (![void 0, "", null].includes(value) && !w(value).isValid()) { 63505 return (0, import_i18n209.__)("Value must be a valid color."); 63506 } 63507 return null; 63508 } 63509 var sort5 = (a2, b2, direction) => { 63510 const colorA = w(a2); 63511 const colorB = w(b2); 63512 if (!colorA.isValid() && !colorB.isValid()) { 63513 return 0; 63514 } 63515 if (!colorA.isValid()) { 63516 return direction === "asc" ? 1 : -1; 63517 } 63518 if (!colorB.isValid()) { 63519 return direction === "asc" ? -1 : 1; 63520 } 63521 const hslA = colorA.toHsl(); 63522 const hslB = colorB.toHsl(); 63523 if (hslA.h !== hslB.h) { 63524 return direction === "asc" ? hslA.h - hslB.h : hslB.h - hslA.h; 63525 } 63526 if (hslA.s !== hslB.s) { 63527 return direction === "asc" ? hslA.s - hslB.s : hslB.s - hslA.s; 63528 } 63529 return direction === "asc" ? hslA.l - hslB.l : hslB.l - hslA.l; 63530 }; 63531 var color_default2 = { 63532 type: "color", 63533 render: render3, 63534 Edit: "color", 63535 sort: sort5, 63536 enableSorting: true, 63537 enableGlobalSearch: false, 63538 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE], 63539 validOperators: [ 63540 OPERATOR_IS, 63541 OPERATOR_IS_NOT, 63542 OPERATOR_IS_ANY, 63543 OPERATOR_IS_NONE 63544 ], 63545 format: {}, 63546 getValueFormatted: get_value_formatted_default_default, 63547 validate: { 63548 required: isValidRequired, 63549 elements: isValidElements, 63550 custom: isValidCustom6 63551 } 63552 }; 63553 63554 // packages/dataviews/build-module/field-types/url.js 63555 var url_default = { 63556 type: "url", 63557 render, 63558 Edit: "url", 63559 sort: sort_text_default, 63560 enableSorting: true, 63561 enableGlobalSearch: false, 63562 defaultOperators: [OPERATOR_IS_ANY, OPERATOR_IS_NONE], 63563 validOperators: [ 63564 OPERATOR_IS, 63565 OPERATOR_IS_NOT, 63566 OPERATOR_CONTAINS, 63567 OPERATOR_NOT_CONTAINS, 63568 OPERATOR_STARTS_WITH, 63569 // Multiple selection 63570 OPERATOR_IS_ANY, 63571 OPERATOR_IS_NONE, 63572 OPERATOR_IS_ALL, 63573 OPERATOR_IS_NOT_ALL 63574 ], 63575 format: {}, 63576 getValueFormatted: get_value_formatted_default_default, 63577 validate: { 63578 required: isValidRequired, 63579 pattern: isValidPattern, 63580 minLength: isValidMinLength, 63581 maxLength: isValidMaxLength, 63582 elements: isValidElements 63583 } 63584 }; 63585 63586 // packages/dataviews/build-module/field-types/no-type.js 63587 var sort6 = (a2, b2, direction) => { 63588 if (typeof a2 === "number" && typeof b2 === "number") { 63589 return sort_number_default(a2, b2, direction); 63590 } 63591 return sort_text_default(a2, b2, direction); 63592 }; 63593 var no_type_default = { 63594 // type: no type for this one 63595 render, 63596 Edit: null, 63597 sort: sort6, 63598 enableSorting: true, 63599 enableGlobalSearch: false, 63600 defaultOperators: [OPERATOR_IS, OPERATOR_IS_NOT], 63601 validOperators: getAllOperatorNames(), 63602 format: {}, 63603 getValueFormatted: get_value_formatted_default_default, 63604 validate: { 63605 required: isValidRequired, 63606 elements: isValidElements 63607 } 63608 }; 63609 63610 // packages/dataviews/build-module/field-types/utils/get-is-valid.js 63611 function getIsValid(field, fieldType) { 63612 let required; 63613 if (field.isValid?.required === true && fieldType.validate.required !== void 0) { 63614 required = { 63615 constraint: true, 63616 validate: fieldType.validate.required 63617 }; 63618 } 63619 let elements; 63620 if ((field.isValid?.elements === true || // elements is enabled unless the field opts-out 63621 field.isValid?.elements === void 0 && (!!field.elements || !!field.getElements)) && fieldType.validate.elements !== void 0) { 63622 elements = { 63623 constraint: true, 63624 validate: fieldType.validate.elements 63625 }; 63626 } 63627 let min; 63628 if (typeof field.isValid?.min === "number" && fieldType.validate.min !== void 0) { 63629 min = { 63630 constraint: field.isValid.min, 63631 validate: fieldType.validate.min 63632 }; 63633 } 63634 let max; 63635 if (typeof field.isValid?.max === "number" && fieldType.validate.max !== void 0) { 63636 max = { 63637 constraint: field.isValid.max, 63638 validate: fieldType.validate.max 63639 }; 63640 } 63641 let minLength; 63642 if (typeof field.isValid?.minLength === "number" && fieldType.validate.minLength !== void 0) { 63643 minLength = { 63644 constraint: field.isValid.minLength, 63645 validate: fieldType.validate.minLength 63646 }; 63647 } 63648 let maxLength; 63649 if (typeof field.isValid?.maxLength === "number" && fieldType.validate.maxLength !== void 0) { 63650 maxLength = { 63651 constraint: field.isValid.maxLength, 63652 validate: fieldType.validate.maxLength 63653 }; 63654 } 63655 let pattern; 63656 if (field.isValid?.pattern !== void 0 && fieldType.validate.pattern !== void 0) { 63657 pattern = { 63658 constraint: field.isValid?.pattern, 63659 validate: fieldType.validate.pattern 63660 }; 63661 } 63662 const custom = field.isValid?.custom ?? fieldType.validate.custom; 63663 return { 63664 required, 63665 elements, 63666 min, 63667 max, 63668 minLength, 63669 maxLength, 63670 pattern, 63671 custom 63672 }; 63673 } 63674 63675 // packages/dataviews/build-module/field-types/utils/get-format.js 63676 function getFormat(field, fieldType) { 63677 return { 63678 ...fieldType.format, 63679 ...field.format 63680 }; 63681 } 63682 var get_format_default = getFormat; 63683 63684 // packages/dataviews/build-module/field-types/index.js 63685 function getFieldTypeByName(type) { 63686 const found = [ 63687 email_default, 63688 integer_default, 63689 number_default, 63690 text_default, 63691 datetime_default, 63692 date_default, 63693 boolean_default, 63694 media_default2, 63695 array_default, 63696 password_default, 63697 telephone_default, 63698 color_default2, 63699 url_default 63700 ].find((fieldType) => fieldType?.type === type); 63701 if (!!found) { 63702 return found; 63703 } 63704 return no_type_default; 63705 } 63706 function normalizeFields(fields) { 63707 return fields.map((field) => { 63708 const fieldType = getFieldTypeByName(field.type); 63709 const getValue = field.getValue || get_value_from_id_default(field.id); 63710 const sort7 = function(a2, b2, direction) { 63711 const aValue = getValue({ item: a2 }); 63712 const bValue = getValue({ item: b2 }); 63713 return field.sort ? field.sort(aValue, bValue, direction) : fieldType.sort(aValue, bValue, direction); 63714 }; 63715 return { 63716 id: field.id, 63717 label: field.label || field.id, 63718 header: field.header || field.label || field.id, 63719 description: field.description, 63720 placeholder: field.placeholder, 63721 getValue, 63722 setValue: field.setValue || set_value_from_id_default(field.id), 63723 elements: field.elements, 63724 getElements: field.getElements, 63725 hasElements: hasElements(field), 63726 isVisible: field.isVisible, 63727 enableHiding: field.enableHiding ?? true, 63728 readOnly: field.readOnly ?? false, 63729 // The type provides defaults for the following props 63730 type: fieldType.type, 63731 render: field.render ?? fieldType.render, 63732 Edit: getControl(field, fieldType.Edit), 63733 sort: sort7, 63734 enableSorting: field.enableSorting ?? fieldType.enableSorting, 63735 enableGlobalSearch: field.enableGlobalSearch ?? fieldType.enableGlobalSearch, 63736 isValid: getIsValid(field, fieldType), 63737 filterBy: get_filter_by_default( 63738 field, 63739 fieldType.defaultOperators, 63740 fieldType.validOperators 63741 ), 63742 format: get_format_default(field, fieldType), 63743 getValueFormatted: field.getValueFormatted ?? fieldType.getValueFormatted 63744 }; 63745 }); 63746 } 63747 63748 // packages/dataviews/build-module/components/dataform/index.js 63749 var import_element237 = __toESM(require_element()); 63750 63751 // packages/dataviews/build-module/components/dataform-context/index.js 63752 var import_element228 = __toESM(require_element()); 63753 var import_jsx_runtime399 = __toESM(require_jsx_runtime()); 63754 var DataFormContext = (0, import_element228.createContext)({ 63755 fields: [] 63756 }); 63757 DataFormContext.displayName = "DataFormContext"; 63758 function DataFormProvider({ 63759 fields, 63760 children 63761 }) { 63762 return /* @__PURE__ */ (0, import_jsx_runtime399.jsx)(DataFormContext.Provider, { value: { fields }, children }); 63763 } 63764 var dataform_context_default = DataFormContext; 63765 63766 // packages/dataviews/build-module/dataform-layouts/data-form-layout.js 63767 var import_components233 = __toESM(require_components()); 63768 var import_element236 = __toESM(require_element()); 63769 63770 // packages/dataviews/build-module/dataform-layouts/index.js 63771 var import_components232 = __toESM(require_components()); 63772 63773 // packages/dataviews/build-module/dataform-layouts/regular/index.js 63774 var import_element229 = __toESM(require_element()); 63775 var import_components225 = __toESM(require_components()); 63776 63777 // packages/dataviews/build-module/dataform-layouts/normalize-form.js 63778 var DEFAULT_LAYOUT = { 63779 type: "regular", 63780 labelPosition: "top" 63781 }; 63782 var normalizeCardSummaryField = (sum) => { 63783 if (typeof sum === "string") { 63784 return [{ id: sum, visibility: "when-collapsed" }]; 63785 } 63786 return sum.map((item) => { 63787 if (typeof item === "string") { 63788 return { id: item, visibility: "when-collapsed" }; 63789 } 63790 return { id: item.id, visibility: item.visibility }; 63791 }); 63792 }; 63793 function normalizeLayout(layout) { 63794 let normalizedLayout = DEFAULT_LAYOUT; 63795 if (layout?.type === "regular") { 63796 normalizedLayout = { 63797 type: "regular", 63798 labelPosition: layout?.labelPosition ?? "top" 63799 }; 63800 } else if (layout?.type === "panel") { 63801 const summary = layout.summary ?? []; 63802 const normalizedSummary = Array.isArray(summary) ? summary : [summary]; 63803 normalizedLayout = { 63804 type: "panel", 63805 labelPosition: layout?.labelPosition ?? "side", 63806 openAs: layout?.openAs ?? "dropdown", 63807 summary: normalizedSummary 63808 }; 63809 } else if (layout?.type === "card") { 63810 if (layout.withHeader === false) { 63811 normalizedLayout = { 63812 type: "card", 63813 withHeader: false, 63814 isOpened: true, 63815 summary: [], 63816 isCollapsible: false 63817 }; 63818 } else { 63819 const summary = layout.summary ?? []; 63820 normalizedLayout = { 63821 type: "card", 63822 withHeader: true, 63823 isOpened: typeof layout.isOpened === "boolean" ? layout.isOpened : true, 63824 summary: normalizeCardSummaryField(summary), 63825 isCollapsible: layout.isCollapsible === void 0 ? true : layout.isCollapsible 63826 }; 63827 } 63828 } else if (layout?.type === "row") { 63829 normalizedLayout = { 63830 type: "row", 63831 alignment: layout?.alignment ?? "center", 63832 styles: layout?.styles ?? {} 63833 }; 63834 } else if (layout?.type === "details") { 63835 normalizedLayout = { 63836 type: "details", 63837 summary: layout?.summary ?? "" 63838 }; 63839 } 63840 return normalizedLayout; 63841 } 63842 function normalizeForm(form) { 63843 const normalizedFormLayout = normalizeLayout(form?.layout); 63844 const normalizedFields = (form.fields ?? []).map( 63845 (field) => { 63846 if (typeof field === "string") { 63847 return { 63848 id: field, 63849 layout: normalizedFormLayout 63850 }; 63851 } 63852 const fieldLayout = field.layout ? normalizeLayout(field.layout) : normalizedFormLayout; 63853 return { 63854 id: field.id, 63855 layout: fieldLayout, 63856 ...!!field.label && { label: field.label }, 63857 ...!!field.description && { 63858 description: field.description 63859 }, 63860 ..."children" in field && Array.isArray(field.children) && { 63861 children: normalizeForm({ 63862 fields: field.children, 63863 layout: DEFAULT_LAYOUT 63864 }).fields 63865 } 63866 }; 63867 } 63868 ); 63869 return { 63870 layout: normalizedFormLayout, 63871 fields: normalizedFields 63872 }; 63873 } 63874 var normalize_form_default = normalizeForm; 63875 63876 // packages/dataviews/build-module/dataform-layouts/regular/index.js 63877 var import_jsx_runtime400 = __toESM(require_jsx_runtime()); 63878 function Header({ title }) { 63879 return /* @__PURE__ */ (0, import_jsx_runtime400.jsx)(import_components225.__experimentalVStack, { className: "dataforms-layouts-regular__header", spacing: 4, children: /* @__PURE__ */ (0, import_jsx_runtime400.jsxs)(import_components225.__experimentalHStack, { alignment: "center", children: [ 63880 /* @__PURE__ */ (0, import_jsx_runtime400.jsx)(import_components225.__experimentalHeading, { level: 2, size: 13, children: title }), 63881 /* @__PURE__ */ (0, import_jsx_runtime400.jsx)(import_components225.__experimentalSpacer, {}) 63882 ] }) }); 63883 } 63884 function FormRegularField({ 63885 data, 63886 field, 63887 onChange, 63888 hideLabelFromVision, 63889 validity 63890 }) { 63891 const { fields } = (0, import_element229.useContext)(dataform_context_default); 63892 const layout = field.layout; 63893 const form = (0, import_element229.useMemo)( 63894 () => ({ 63895 layout: DEFAULT_LAYOUT, 63896 fields: !!field.children ? field.children : [] 63897 }), 63898 [field] 63899 ); 63900 if (!!field.children) { 63901 return /* @__PURE__ */ (0, import_jsx_runtime400.jsxs)(import_jsx_runtime400.Fragment, { children: [ 63902 !hideLabelFromVision && field.label && /* @__PURE__ */ (0, import_jsx_runtime400.jsx)(Header, { title: field.label }), 63903 /* @__PURE__ */ (0, import_jsx_runtime400.jsx)( 63904 DataFormLayout, 63905 { 63906 data, 63907 form, 63908 onChange, 63909 validity: validity?.children 63910 } 63911 ) 63912 ] }); 63913 } 63914 const labelPosition = layout.labelPosition; 63915 const fieldDefinition = fields.find( 63916 (fieldDef) => fieldDef.id === field.id 63917 ); 63918 if (!fieldDefinition || !fieldDefinition.Edit) { 63919 return null; 63920 } 63921 if (labelPosition === "side") { 63922 return /* @__PURE__ */ (0, import_jsx_runtime400.jsxs)(import_components225.__experimentalHStack, { className: "dataforms-layouts-regular__field", children: [ 63923 /* @__PURE__ */ (0, import_jsx_runtime400.jsx)( 63924 "div", 63925 { 63926 className: clsx_default( 63927 "dataforms-layouts-regular__field-label", 63928 `dataforms-layouts-regular__field-label--label-position-$labelPosition}` 63929 ), 63930 children: fieldDefinition.label 63931 } 63932 ), 63933 /* @__PURE__ */ (0, import_jsx_runtime400.jsx)("div", { className: "dataforms-layouts-regular__field-control", children: fieldDefinition.readOnly === true ? /* @__PURE__ */ (0, import_jsx_runtime400.jsx)( 63934 fieldDefinition.render, 63935 { 63936 item: data, 63937 field: fieldDefinition 63938 } 63939 ) : /* @__PURE__ */ (0, import_jsx_runtime400.jsx)( 63940 fieldDefinition.Edit, 63941 { 63942 data, 63943 field: fieldDefinition, 63944 onChange, 63945 hideLabelFromVision: true, 63946 validity 63947 }, 63948 fieldDefinition.id 63949 ) }) 63950 ] }); 63951 } 63952 return /* @__PURE__ */ (0, import_jsx_runtime400.jsx)("div", { className: "dataforms-layouts-regular__field", children: fieldDefinition.readOnly === true ? /* @__PURE__ */ (0, import_jsx_runtime400.jsx)(import_jsx_runtime400.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime400.jsxs)(import_jsx_runtime400.Fragment, { children: [ 63953 !hideLabelFromVision && labelPosition !== "none" && /* @__PURE__ */ (0, import_jsx_runtime400.jsx)(import_components225.BaseControl.VisualLabel, { children: fieldDefinition.label }), 63954 /* @__PURE__ */ (0, import_jsx_runtime400.jsx)( 63955 fieldDefinition.render, 63956 { 63957 item: data, 63958 field: fieldDefinition 63959 } 63960 ) 63961 ] }) }) : /* @__PURE__ */ (0, import_jsx_runtime400.jsx)( 63962 fieldDefinition.Edit, 63963 { 63964 data, 63965 field: fieldDefinition, 63966 onChange, 63967 hideLabelFromVision: labelPosition === "none" ? true : hideLabelFromVision, 63968 validity 63969 } 63970 ) }); 63971 } 63972 63973 // packages/dataviews/build-module/dataform-layouts/panel/index.js 63974 var import_components229 = __toESM(require_components()); 63975 var import_element233 = __toESM(require_element()); 63976 63977 // packages/dataviews/build-module/dataform-layouts/panel/dropdown.js 63978 var import_components227 = __toESM(require_components()); 63979 var import_i18n211 = __toESM(require_i18n()); 63980 var import_element230 = __toESM(require_element()); 63981 var import_compose89 = __toESM(require_compose()); 63982 63983 // packages/dataviews/build-module/dataform-layouts/panel/summary-button.js 63984 var import_components226 = __toESM(require_components()); 63985 var import_i18n210 = __toESM(require_i18n()); 63986 var import_jsx_runtime401 = __toESM(require_jsx_runtime()); 63987 function SummaryButton({ 63988 summaryFields, 63989 data, 63990 labelPosition, 63991 fieldLabel, 63992 disabled, 63993 onClick, 63994 "aria-expanded": ariaExpanded 63995 }) { 63996 return /* @__PURE__ */ (0, import_jsx_runtime401.jsx)( 63997 import_components226.Button, 63998 { 63999 className: "dataforms-layouts-panel__summary-button", 64000 size: "compact", 64001 variant: ["none", "top"].includes(labelPosition) ? "link" : "tertiary", 64002 "aria-expanded": ariaExpanded, 64003 "aria-label": (0, import_i18n210.sprintf)( 64004 // translators: %s: Field name. 64005 (0, import_i18n210._x)("Edit %s", "field"), 64006 fieldLabel || "" 64007 ), 64008 onClick, 64009 disabled, 64010 accessibleWhenDisabled: true, 64011 style: summaryFields.length > 1 ? { 64012 minHeight: "auto", 64013 height: "auto", 64014 alignItems: "flex-start" 64015 } : void 0, 64016 children: summaryFields.length > 1 ? /* @__PURE__ */ (0, import_jsx_runtime401.jsx)( 64017 "div", 64018 { 64019 style: { 64020 display: "flex", 64021 flexDirection: "column", 64022 alignItems: "flex-start", 64023 width: "100%", 64024 gap: "2px" 64025 }, 64026 children: summaryFields.map((summaryField) => /* @__PURE__ */ (0, import_jsx_runtime401.jsx)( 64027 "div", 64028 { 64029 style: { width: "100%" }, 64030 children: /* @__PURE__ */ (0, import_jsx_runtime401.jsx)( 64031 summaryField.render, 64032 { 64033 item: data, 64034 field: summaryField 64035 } 64036 ) 64037 }, 64038 summaryField.id 64039 )) 64040 } 64041 ) : summaryFields.map((summaryField) => /* @__PURE__ */ (0, import_jsx_runtime401.jsx)( 64042 summaryField.render, 64043 { 64044 item: data, 64045 field: summaryField 64046 }, 64047 summaryField.id 64048 )) 64049 } 64050 ); 64051 } 64052 var summary_button_default = SummaryButton; 64053 64054 // packages/dataviews/build-module/dataform-layouts/panel/dropdown.js 64055 var import_jsx_runtime402 = __toESM(require_jsx_runtime()); 64056 function DropdownHeader({ 64057 title, 64058 onClose 64059 }) { 64060 return /* @__PURE__ */ (0, import_jsx_runtime402.jsx)( 64061 import_components227.__experimentalVStack, 64062 { 64063 className: "dataforms-layouts-panel__dropdown-header", 64064 spacing: 4, 64065 children: /* @__PURE__ */ (0, import_jsx_runtime402.jsxs)(import_components227.__experimentalHStack, { alignment: "center", children: [ 64066 title && /* @__PURE__ */ (0, import_jsx_runtime402.jsx)(import_components227.__experimentalHeading, { level: 2, size: 13, children: title }), 64067 /* @__PURE__ */ (0, import_jsx_runtime402.jsx)(import_components227.__experimentalSpacer, {}), 64068 onClose && /* @__PURE__ */ (0, import_jsx_runtime402.jsx)( 64069 import_components227.Button, 64070 { 64071 label: (0, import_i18n211.__)("Close"), 64072 icon: close_small_default, 64073 onClick: onClose, 64074 size: "small" 64075 } 64076 ) 64077 ] }) 64078 } 64079 ); 64080 } 64081 function PanelDropdown({ 64082 data, 64083 field, 64084 onChange, 64085 validity, 64086 labelPosition = "side", 64087 summaryFields, 64088 fieldDefinition, 64089 popoverAnchor, 64090 onOpen 64091 }) { 64092 const fieldLabel = !!field.children ? field.label : fieldDefinition?.label; 64093 const form = (0, import_element230.useMemo)( 64094 () => ({ 64095 layout: DEFAULT_LAYOUT, 64096 fields: !!field.children ? field.children : ( 64097 // If not explicit children return the field id itself. 64098 [{ id: field.id, layout: DEFAULT_LAYOUT }] 64099 ) 64100 }), 64101 [field] 64102 ); 64103 const formValidity = (0, import_element230.useMemo)(() => { 64104 if (validity === void 0) { 64105 return void 0; 64106 } 64107 if (!!field.children) { 64108 return validity?.children; 64109 } 64110 return { [field.id]: validity }; 64111 }, [validity, field]); 64112 const popoverProps3 = (0, import_element230.useMemo)( 64113 () => ({ 64114 // Anchor the popover to the middle of the entire row so that it doesn't 64115 // move around when the label changes. 64116 anchor: popoverAnchor, 64117 placement: "left-start", 64118 offset: 36, 64119 shift: true 64120 }), 64121 [popoverAnchor] 64122 ); 64123 const focusOnMountRef = (0, import_compose89.useFocusOnMount)("firstInputElement"); 64124 return /* @__PURE__ */ (0, import_jsx_runtime402.jsx)( 64125 import_components227.Dropdown, 64126 { 64127 contentClassName: "dataforms-layouts-panel__field-dropdown", 64128 popoverProps: popoverProps3, 64129 focusOnMount: false, 64130 toggleProps: { 64131 size: "compact", 64132 variant: "tertiary", 64133 tooltipPosition: "middle left" 64134 }, 64135 renderToggle: ({ isOpen, onToggle }) => /* @__PURE__ */ (0, import_jsx_runtime402.jsx)( 64136 summary_button_default, 64137 { 64138 summaryFields, 64139 data, 64140 labelPosition, 64141 fieldLabel, 64142 disabled: fieldDefinition.readOnly === true, 64143 onClick: () => { 64144 if (!isOpen && onOpen) { 64145 onOpen(); 64146 } 64147 onToggle(); 64148 }, 64149 "aria-expanded": isOpen 64150 } 64151 ), 64152 renderContent: ({ onClose }) => /* @__PURE__ */ (0, import_jsx_runtime402.jsxs)(import_jsx_runtime402.Fragment, { children: [ 64153 /* @__PURE__ */ (0, import_jsx_runtime402.jsx)(DropdownHeader, { title: fieldLabel, onClose }), 64154 /* @__PURE__ */ (0, import_jsx_runtime402.jsx)("div", { ref: focusOnMountRef, children: /* @__PURE__ */ (0, import_jsx_runtime402.jsx)( 64155 DataFormLayout, 64156 { 64157 data, 64158 form, 64159 onChange, 64160 validity: formValidity, 64161 children: (FieldLayout, childField, childFieldValidity) => /* @__PURE__ */ (0, import_jsx_runtime402.jsx)( 64162 FieldLayout, 64163 { 64164 data, 64165 field: childField, 64166 onChange, 64167 hideLabelFromVision: (form?.fields ?? []).length < 2, 64168 validity: childFieldValidity 64169 }, 64170 childField.id 64171 ) 64172 } 64173 ) }) 64174 ] }) 64175 } 64176 ); 64177 } 64178 var dropdown_default2 = PanelDropdown; 64179 64180 // packages/dataviews/build-module/dataform-layouts/panel/modal.js 64181 var import_deepmerge2 = __toESM(require_cjs()); 64182 var import_components228 = __toESM(require_components()); 64183 var import_i18n213 = __toESM(require_i18n()); 64184 var import_element232 = __toESM(require_element()); 64185 var import_compose90 = __toESM(require_compose()); 64186 64187 // packages/dataviews/build-module/hooks/use-form-validity.js 64188 var import_deepmerge = __toESM(require_cjs()); 64189 var import_es66 = __toESM(require_es6()); 64190 var import_element231 = __toESM(require_element()); 64191 var import_i18n212 = __toESM(require_i18n()); 64192 function isFormValid(formValidity) { 64193 if (!formValidity) { 64194 return true; 64195 } 64196 return Object.values(formValidity).every((fieldValidation) => { 64197 return Object.entries(fieldValidation).every( 64198 ([key, validation]) => { 64199 if (key === "children" && validation && typeof validation === "object") { 64200 return isFormValid(validation); 64201 } 64202 return validation.type === "valid"; 64203 } 64204 ); 64205 }); 64206 } 64207 function getFormFieldsToValidate(form, fields) { 64208 const normalizedForm = normalize_form_default(form); 64209 if (normalizedForm.fields.length === 0) { 64210 return []; 64211 } 64212 const fieldsMap = /* @__PURE__ */ new Map(); 64213 fields.forEach((field) => { 64214 fieldsMap.set(field.id, field); 64215 }); 64216 function processFormField(formField) { 64217 if ("children" in formField && Array.isArray(formField.children)) { 64218 const processedChildren = formField.children.map(processFormField).filter((child) => child !== null); 64219 if (processedChildren.length === 0) { 64220 return null; 64221 } 64222 const fieldDef2 = fieldsMap.get(formField.id); 64223 if (fieldDef2) { 64224 const [normalizedField2] = normalizeFields([ 64225 fieldDef2 64226 ]); 64227 return { 64228 id: formField.id, 64229 children: processedChildren, 64230 field: normalizedField2 64231 }; 64232 } 64233 return { 64234 id: formField.id, 64235 children: processedChildren 64236 }; 64237 } 64238 const fieldDef = fieldsMap.get(formField.id); 64239 if (!fieldDef) { 64240 return null; 64241 } 64242 const [normalizedField] = normalizeFields([fieldDef]); 64243 return { 64244 id: formField.id, 64245 children: [], 64246 field: normalizedField 64247 }; 64248 } 64249 const toValidate = normalizedForm.fields.map(processFormField).filter((field) => field !== null); 64250 return toValidate; 64251 } 64252 function setValidityAtPath(formValidity, fieldValidity, path) { 64253 if (!formValidity) { 64254 formValidity = {}; 64255 } 64256 if (path.length === 0) { 64257 return formValidity; 64258 } 64259 const result = { ...formValidity }; 64260 let current = result; 64261 for (let i2 = 0; i2 < path.length - 1; i2++) { 64262 const segment = path[i2]; 64263 if (!current[segment]) { 64264 current[segment] = {}; 64265 } 64266 current = current[segment]; 64267 } 64268 const finalKey = path[path.length - 1]; 64269 current[finalKey] = { 64270 ...current[finalKey] || {}, 64271 ...fieldValidity 64272 }; 64273 return result; 64274 } 64275 function handleElementsValidationAsync(promise, formField, promiseHandler) { 64276 const { elementsCounterRef, setFormValidity, path, item } = promiseHandler; 64277 const currentToken = (elementsCounterRef.current[formField.id] || 0) + 1; 64278 elementsCounterRef.current[formField.id] = currentToken; 64279 promise.then((result) => { 64280 if (currentToken !== elementsCounterRef.current[formField.id]) { 64281 return; 64282 } 64283 if (!Array.isArray(result)) { 64284 setFormValidity((prev) => { 64285 const newFormValidity = setValidityAtPath( 64286 prev, 64287 { 64288 elements: { 64289 type: "invalid", 64290 message: (0, import_i18n212.__)("Could not validate elements.") 64291 } 64292 }, 64293 [...path, formField.id] 64294 ); 64295 return newFormValidity; 64296 }); 64297 return; 64298 } 64299 if (formField.field?.isValid.elements && !formField.field.isValid.elements.validate(item, { 64300 ...formField.field, 64301 elements: result 64302 })) { 64303 setFormValidity((prev) => { 64304 const newFormValidity = setValidityAtPath( 64305 prev, 64306 { 64307 elements: { 64308 type: "invalid", 64309 message: (0, import_i18n212.__)( 64310 "Value must be one of the elements." 64311 ) 64312 } 64313 }, 64314 [...path, formField.id] 64315 ); 64316 return newFormValidity; 64317 }); 64318 } 64319 }).catch((error) => { 64320 if (currentToken !== elementsCounterRef.current[formField.id]) { 64321 return; 64322 } 64323 let errorMessage; 64324 if (error instanceof Error) { 64325 errorMessage = error.message; 64326 } else { 64327 errorMessage = String(error) || (0, import_i18n212.__)( 64328 "Unknown error when running elements validation asynchronously." 64329 ); 64330 } 64331 setFormValidity((prev) => { 64332 const newFormValidity = setValidityAtPath( 64333 prev, 64334 { 64335 elements: { 64336 type: "invalid", 64337 message: errorMessage 64338 } 64339 }, 64340 [...path, formField.id] 64341 ); 64342 return newFormValidity; 64343 }); 64344 }); 64345 } 64346 function handleCustomValidationAsync(promise, formField, promiseHandler) { 64347 const { customCounterRef, setFormValidity, path } = promiseHandler; 64348 const currentToken = (customCounterRef.current[formField.id] || 0) + 1; 64349 customCounterRef.current[formField.id] = currentToken; 64350 promise.then((result) => { 64351 if (currentToken !== customCounterRef.current[formField.id]) { 64352 return; 64353 } 64354 if (result === null) { 64355 setFormValidity((prev) => { 64356 const newFormValidity = setValidityAtPath( 64357 prev, 64358 { 64359 custom: { 64360 type: "valid", 64361 message: (0, import_i18n212.__)("Valid") 64362 } 64363 }, 64364 [...path, formField.id] 64365 ); 64366 return newFormValidity; 64367 }); 64368 return; 64369 } 64370 if (typeof result === "string") { 64371 setFormValidity((prev) => { 64372 const newFormValidity = setValidityAtPath( 64373 prev, 64374 { 64375 custom: { 64376 type: "invalid", 64377 message: result 64378 } 64379 }, 64380 [...path, formField.id] 64381 ); 64382 return newFormValidity; 64383 }); 64384 return; 64385 } 64386 setFormValidity((prev) => { 64387 const newFormValidity = setValidityAtPath( 64388 prev, 64389 { 64390 custom: { 64391 type: "invalid", 64392 message: (0, import_i18n212.__)("Validation could not be processed.") 64393 } 64394 }, 64395 [...path, formField.id] 64396 ); 64397 return newFormValidity; 64398 }); 64399 }).catch((error) => { 64400 if (currentToken !== customCounterRef.current[formField.id]) { 64401 return; 64402 } 64403 let errorMessage; 64404 if (error instanceof Error) { 64405 errorMessage = error.message; 64406 } else { 64407 errorMessage = String(error) || (0, import_i18n212.__)( 64408 "Unknown error when running custom validation asynchronously." 64409 ); 64410 } 64411 setFormValidity((prev) => { 64412 const newFormValidity = setValidityAtPath( 64413 prev, 64414 { 64415 custom: { 64416 type: "invalid", 64417 message: errorMessage 64418 } 64419 }, 64420 [...path, formField.id] 64421 ); 64422 return newFormValidity; 64423 }); 64424 }); 64425 } 64426 function validateFormField(item, formField, promiseHandler) { 64427 if (formField.field?.isValid.required && !formField.field.isValid.required.validate(item, formField.field)) { 64428 return { 64429 required: { type: "invalid" } 64430 }; 64431 } 64432 if (formField.field?.isValid.pattern && !formField.field.isValid.pattern.validate(item, formField.field)) { 64433 return { 64434 pattern: { 64435 type: "invalid", 64436 message: (0, import_i18n212.__)("Value does not match the required pattern.") 64437 } 64438 }; 64439 } 64440 if (formField.field?.isValid.min && !formField.field.isValid.min.validate(item, formField.field)) { 64441 return { 64442 min: { 64443 type: "invalid", 64444 message: (0, import_i18n212.__)("Value is below the minimum.") 64445 } 64446 }; 64447 } 64448 if (formField.field?.isValid.max && !formField.field.isValid.max.validate(item, formField.field)) { 64449 return { 64450 max: { 64451 type: "invalid", 64452 message: (0, import_i18n212.__)("Value is above the maximum.") 64453 } 64454 }; 64455 } 64456 if (formField.field?.isValid.minLength && !formField.field.isValid.minLength.validate(item, formField.field)) { 64457 return { 64458 minLength: { 64459 type: "invalid", 64460 message: (0, import_i18n212.__)("Value is too short.") 64461 } 64462 }; 64463 } 64464 if (formField.field?.isValid.maxLength && !formField.field.isValid.maxLength.validate(item, formField.field)) { 64465 return { 64466 maxLength: { 64467 type: "invalid", 64468 message: (0, import_i18n212.__)("Value is too long.") 64469 } 64470 }; 64471 } 64472 if (formField.field?.isValid.elements && formField.field.hasElements && !formField.field.getElements && Array.isArray(formField.field.elements) && !formField.field.isValid.elements.validate(item, formField.field)) { 64473 return { 64474 elements: { 64475 type: "invalid", 64476 message: (0, import_i18n212.__)("Value must be one of the elements.") 64477 } 64478 }; 64479 } 64480 if (!!formField.field && formField.field.isValid.elements && formField.field.hasElements && typeof formField.field.getElements === "function") { 64481 handleElementsValidationAsync( 64482 formField.field.getElements(), 64483 formField, 64484 promiseHandler 64485 ); 64486 return { 64487 elements: { 64488 type: "validating", 64489 message: (0, import_i18n212.__)("Validating\u2026") 64490 } 64491 }; 64492 } 64493 let customError; 64494 if (!!formField.field && formField.field.isValid.custom) { 64495 try { 64496 const value = formField.field.getValue({ item }); 64497 customError = formField.field.isValid.custom( 64498 (0, import_deepmerge.default)( 64499 item, 64500 formField.field.setValue({ 64501 item, 64502 value 64503 }) 64504 ), 64505 formField.field 64506 ); 64507 } catch (error) { 64508 let errorMessage; 64509 if (error instanceof Error) { 64510 errorMessage = error.message; 64511 } else { 64512 errorMessage = String(error) || (0, import_i18n212.__)("Unknown error when running custom validation."); 64513 } 64514 return { 64515 custom: { 64516 type: "invalid", 64517 message: errorMessage 64518 } 64519 }; 64520 } 64521 } 64522 if (typeof customError === "string") { 64523 return { 64524 custom: { 64525 type: "invalid", 64526 message: customError 64527 } 64528 }; 64529 } 64530 if (customError instanceof Promise) { 64531 handleCustomValidationAsync(customError, formField, promiseHandler); 64532 return { 64533 custom: { 64534 type: "validating", 64535 message: (0, import_i18n212.__)("Validating\u2026") 64536 } 64537 }; 64538 } 64539 if (formField.children.length > 0) { 64540 const result = {}; 64541 formField.children.forEach((child) => { 64542 result[child.id] = validateFormField(item, child, { 64543 ...promiseHandler, 64544 path: [...promiseHandler.path, formField.id, "children"] 64545 }); 64546 }); 64547 const filteredResult = {}; 64548 Object.entries(result).forEach(([key, value]) => { 64549 if (value !== void 0) { 64550 filteredResult[key] = value; 64551 } 64552 }); 64553 if (Object.keys(filteredResult).length === 0) { 64554 return void 0; 64555 } 64556 return { 64557 children: filteredResult 64558 }; 64559 } 64560 return void 0; 64561 } 64562 function getFormFieldValue(formField, item) { 64563 const fieldValue = formField?.field?.getValue({ item }); 64564 if (formField.children.length === 0) { 64565 return fieldValue; 64566 } 64567 const childrenValues = formField.children.map( 64568 (child) => getFormFieldValue(child, item) 64569 ); 64570 if (!childrenValues) { 64571 return fieldValue; 64572 } 64573 return { 64574 value: fieldValue, 64575 children: childrenValues 64576 }; 64577 } 64578 function useFormValidity(item, fields, form) { 64579 const [formValidity, setFormValidity] = (0, import_element231.useState)(); 64580 const customCounterRef = (0, import_element231.useRef)({}); 64581 const elementsCounterRef = (0, import_element231.useRef)({}); 64582 const previousValuesRef = (0, import_element231.useRef)({}); 64583 const validate = (0, import_element231.useCallback)(() => { 64584 const promiseHandler = { 64585 customCounterRef, 64586 elementsCounterRef, 64587 setFormValidity, 64588 path: [], 64589 item 64590 }; 64591 const formFieldsToValidate = getFormFieldsToValidate(form, fields); 64592 if (formFieldsToValidate.length === 0) { 64593 setFormValidity(void 0); 64594 return; 64595 } 64596 const newFormValidity = {}; 64597 const untouchedFields = []; 64598 formFieldsToValidate.forEach((formField) => { 64599 const value = getFormFieldValue(formField, item); 64600 if (previousValuesRef.current.hasOwnProperty(formField.id) && (0, import_es66.default)( 64601 previousValuesRef.current[formField.id], 64602 value 64603 )) { 64604 untouchedFields.push(formField.id); 64605 return; 64606 } 64607 previousValuesRef.current[formField.id] = value; 64608 const fieldValidity = validateFormField( 64609 item, 64610 formField, 64611 promiseHandler 64612 ); 64613 if (fieldValidity !== void 0) { 64614 newFormValidity[formField.id] = fieldValidity; 64615 } 64616 }); 64617 setFormValidity((existingFormValidity) => { 64618 let validity = { 64619 ...existingFormValidity, 64620 ...newFormValidity 64621 }; 64622 const fieldsToKeep = [ 64623 ...untouchedFields, 64624 ...Object.keys(newFormValidity) 64625 ]; 64626 Object.keys(validity).forEach((key) => { 64627 if (validity && !fieldsToKeep.includes(key)) { 64628 delete validity[key]; 64629 } 64630 }); 64631 if (Object.keys(validity).length === 0) { 64632 validity = void 0; 64633 } 64634 const areEqual = (0, import_es66.default)(existingFormValidity, validity); 64635 if (areEqual) { 64636 return existingFormValidity; 64637 } 64638 return validity; 64639 }); 64640 }, [item, fields, form]); 64641 (0, import_element231.useEffect)(() => { 64642 validate(); 64643 }, [validate]); 64644 return { 64645 validity: formValidity, 64646 isValid: isFormValid(formValidity) 64647 }; 64648 } 64649 var use_form_validity_default = useFormValidity; 64650 64651 // packages/dataviews/build-module/dataform-layouts/panel/modal.js 64652 var import_jsx_runtime403 = __toESM(require_jsx_runtime()); 64653 function ModalContent({ 64654 data, 64655 field, 64656 onChange, 64657 fieldLabel, 64658 onClose 64659 }) { 64660 const { fields } = (0, import_element232.useContext)(dataform_context_default); 64661 const [changes, setChanges] = (0, import_element232.useState)({}); 64662 const modalData = (0, import_element232.useMemo)(() => { 64663 return (0, import_deepmerge2.default)(data, changes, { 64664 arrayMerge: (target, source) => source 64665 }); 64666 }, [data, changes]); 64667 const form = (0, import_element232.useMemo)( 64668 () => ({ 64669 layout: DEFAULT_LAYOUT, 64670 fields: !!field.children ? field.children : ( 64671 // If not explicit children return the field id itself. 64672 [{ id: field.id, layout: DEFAULT_LAYOUT }] 64673 ) 64674 }), 64675 [field] 64676 ); 64677 const fieldsAsFieldType = fields.map((f2) => ({ 64678 ...f2, 64679 Edit: f2.Edit === null ? void 0 : f2.Edit, 64680 isValid: { 64681 required: f2.isValid.required?.constraint, 64682 elements: f2.isValid.elements?.constraint, 64683 min: f2.isValid.min?.constraint, 64684 max: f2.isValid.max?.constraint, 64685 pattern: f2.isValid.pattern?.constraint, 64686 minLength: f2.isValid.minLength?.constraint, 64687 maxLength: f2.isValid.maxLength?.constraint 64688 } 64689 })); 64690 const { validity } = use_form_validity_default(modalData, fieldsAsFieldType, form); 64691 const onApply = () => { 64692 onChange(changes); 64693 onClose(); 64694 }; 64695 const handleOnChange = (newValue) => { 64696 setChanges( 64697 (prev) => (0, import_deepmerge2.default)(prev, newValue, { 64698 arrayMerge: (target, source) => source 64699 }) 64700 ); 64701 }; 64702 const focusOnMountRef = (0, import_compose90.useFocusOnMount)("firstInputElement"); 64703 return /* @__PURE__ */ (0, import_jsx_runtime403.jsxs)( 64704 import_components228.Modal, 64705 { 64706 className: "dataforms-layouts-panel__modal", 64707 onRequestClose: onClose, 64708 isFullScreen: false, 64709 title: fieldLabel, 64710 size: "medium", 64711 children: [ 64712 /* @__PURE__ */ (0, import_jsx_runtime403.jsx)("div", { ref: focusOnMountRef, children: /* @__PURE__ */ (0, import_jsx_runtime403.jsx)( 64713 DataFormLayout, 64714 { 64715 data: modalData, 64716 form, 64717 onChange: handleOnChange, 64718 validity, 64719 children: (FieldLayout, childField, childFieldValidity) => /* @__PURE__ */ (0, import_jsx_runtime403.jsx)( 64720 FieldLayout, 64721 { 64722 data: modalData, 64723 field: childField, 64724 onChange: handleOnChange, 64725 hideLabelFromVision: form.fields.length < 2, 64726 validity: childFieldValidity 64727 }, 64728 childField.id 64729 ) 64730 } 64731 ) }), 64732 /* @__PURE__ */ (0, import_jsx_runtime403.jsxs)( 64733 import_components228.__experimentalHStack, 64734 { 64735 className: "dataforms-layouts-panel__modal-footer", 64736 spacing: 3, 64737 children: [ 64738 /* @__PURE__ */ (0, import_jsx_runtime403.jsx)(import_components228.__experimentalSpacer, {}), 64739 /* @__PURE__ */ (0, import_jsx_runtime403.jsx)( 64740 import_components228.Button, 64741 { 64742 variant: "tertiary", 64743 onClick: onClose, 64744 __next40pxDefaultSize: true, 64745 children: (0, import_i18n213.__)("Cancel") 64746 } 64747 ), 64748 /* @__PURE__ */ (0, import_jsx_runtime403.jsx)( 64749 import_components228.Button, 64750 { 64751 variant: "primary", 64752 onClick: onApply, 64753 __next40pxDefaultSize: true, 64754 children: (0, import_i18n213.__)("Apply") 64755 } 64756 ) 64757 ] 64758 } 64759 ) 64760 ] 64761 } 64762 ); 64763 } 64764 function PanelModal({ 64765 data, 64766 field, 64767 onChange, 64768 labelPosition, 64769 summaryFields, 64770 fieldDefinition, 64771 onOpen 64772 }) { 64773 const [isOpen, setIsOpen] = (0, import_element232.useState)(false); 64774 const fieldLabel = !!field.children ? field.label : fieldDefinition?.label; 64775 return /* @__PURE__ */ (0, import_jsx_runtime403.jsxs)(import_jsx_runtime403.Fragment, { children: [ 64776 /* @__PURE__ */ (0, import_jsx_runtime403.jsx)( 64777 summary_button_default, 64778 { 64779 summaryFields, 64780 data, 64781 labelPosition, 64782 fieldLabel, 64783 disabled: fieldDefinition.readOnly === true, 64784 onClick: () => { 64785 if (onOpen) { 64786 onOpen(); 64787 } 64788 setIsOpen(true); 64789 }, 64790 "aria-expanded": isOpen 64791 } 64792 ), 64793 isOpen && /* @__PURE__ */ (0, import_jsx_runtime403.jsx)( 64794 ModalContent, 64795 { 64796 data, 64797 field, 64798 onChange, 64799 fieldLabel: fieldLabel ?? "", 64800 onClose: () => setIsOpen(false) 64801 } 64802 ) 64803 ] }); 64804 } 64805 var modal_default = PanelModal; 64806 64807 // packages/dataviews/build-module/dataform-layouts/get-summary-fields.js 64808 function extractSummaryIds(summary) { 64809 if (Array.isArray(summary)) { 64810 return summary.map( 64811 (item) => typeof item === "string" ? item : item.id 64812 ); 64813 } 64814 return []; 64815 } 64816 var getSummaryFields = (summaryField, fields) => { 64817 if (Array.isArray(summaryField) && summaryField.length > 0) { 64818 const summaryIds = extractSummaryIds(summaryField); 64819 return summaryIds.map( 64820 (summaryId) => fields.find((_field) => _field.id === summaryId) 64821 ).filter((_field) => _field !== void 0); 64822 } 64823 return []; 64824 }; 64825 64826 // packages/dataviews/build-module/dataform-layouts/panel/index.js 64827 var import_jsx_runtime404 = __toESM(require_jsx_runtime()); 64828 function getFirstValidationError(validity) { 64829 if (!validity) { 64830 return void 0; 64831 } 64832 const validityRules = Object.keys(validity).filter( 64833 (key) => key !== "children" 64834 ); 64835 for (const key of validityRules) { 64836 const rule = validity[key]; 64837 if (rule === void 0) { 64838 continue; 64839 } 64840 if (rule.type === "invalid") { 64841 if (rule.message) { 64842 return rule.message; 64843 } 64844 if (key === "required") { 64845 return "A required field is empty"; 64846 } 64847 return "Unidentified validation error"; 64848 } 64849 } 64850 if (validity.children) { 64851 for (const childValidity of Object.values(validity.children)) { 64852 const childError = getFirstValidationError(childValidity); 64853 if (childError) { 64854 return childError; 64855 } 64856 } 64857 } 64858 return void 0; 64859 } 64860 var getFieldDefinition = (field, fields) => { 64861 const fieldDefinition = fields.find((_field) => _field.id === field.id); 64862 if (!fieldDefinition) { 64863 return fields.find((_field) => { 64864 if (!!field.children) { 64865 const simpleChildren = field.children.filter( 64866 (child) => !child.children 64867 ); 64868 if (simpleChildren.length === 0) { 64869 return false; 64870 } 64871 return _field.id === simpleChildren[0].id; 64872 } 64873 return _field.id === field.id; 64874 }); 64875 } 64876 return fieldDefinition; 64877 }; 64878 var getFieldDefinitionAndSummaryFields = (layout, field, fields) => { 64879 const summaryFields = getSummaryFields(layout.summary, fields); 64880 const fieldDefinition = getFieldDefinition(field, fields); 64881 if (summaryFields.length === 0) { 64882 return { 64883 summaryFields: fieldDefinition ? [fieldDefinition] : [], 64884 fieldDefinition 64885 }; 64886 } 64887 return { 64888 summaryFields, 64889 fieldDefinition 64890 }; 64891 }; 64892 function FormPanelField({ 64893 data, 64894 field, 64895 onChange, 64896 validity 64897 }) { 64898 const { fields } = (0, import_element233.useContext)(dataform_context_default); 64899 const layout = field.layout; 64900 const [popoverAnchor, setPopoverAnchor] = (0, import_element233.useState)( 64901 null 64902 ); 64903 const [touched, setTouched] = (0, import_element233.useState)(false); 64904 const handleOpen = () => setTouched(true); 64905 const { fieldDefinition, summaryFields } = getFieldDefinitionAndSummaryFields(layout, field, fields); 64906 if (!fieldDefinition) { 64907 return null; 64908 } 64909 const labelPosition = layout.labelPosition; 64910 const errorMessage = getFirstValidationError(validity); 64911 const showError = touched && !!errorMessage; 64912 const labelClassName = clsx_default( 64913 "dataforms-layouts-panel__field-label", 64914 `dataforms-layouts-panel__field-label--label-position-$labelPosition}`, 64915 { "has-error": showError } 64916 ); 64917 const fieldLabel = !!field.children ? field.label : fieldDefinition?.label; 64918 const labelContent = showError ? /* @__PURE__ */ (0, import_jsx_runtime404.jsx)(import_components229.Tooltip, { text: errorMessage, placement: "top", children: /* @__PURE__ */ (0, import_jsx_runtime404.jsxs)( 64919 import_components229.__experimentalHStack, 64920 { 64921 className: "dataforms-layouts-panel__field-label-error-content", 64922 justify: "flex-start", 64923 children: [ 64924 /* @__PURE__ */ (0, import_jsx_runtime404.jsx)(import_components229.Icon, { icon: error_default, size: 16 }), 64925 /* @__PURE__ */ (0, import_jsx_runtime404.jsx)(import_jsx_runtime404.Fragment, { children: fieldLabel }) 64926 ] 64927 } 64928 ) }) : fieldLabel; 64929 const renderedControl = layout.openAs === "modal" ? /* @__PURE__ */ (0, import_jsx_runtime404.jsx)( 64930 modal_default, 64931 { 64932 data, 64933 field, 64934 onChange, 64935 labelPosition, 64936 summaryFields, 64937 fieldDefinition, 64938 onOpen: handleOpen 64939 } 64940 ) : /* @__PURE__ */ (0, import_jsx_runtime404.jsx)( 64941 dropdown_default2, 64942 { 64943 data, 64944 field, 64945 onChange, 64946 validity, 64947 labelPosition, 64948 summaryFields, 64949 fieldDefinition, 64950 popoverAnchor, 64951 onOpen: handleOpen 64952 } 64953 ); 64954 if (labelPosition === "top") { 64955 return /* @__PURE__ */ (0, import_jsx_runtime404.jsxs)(import_components229.__experimentalVStack, { className: "dataforms-layouts-panel__field", spacing: 0, children: [ 64956 /* @__PURE__ */ (0, import_jsx_runtime404.jsx)( 64957 "div", 64958 { 64959 className: labelClassName, 64960 style: { paddingBottom: 0 }, 64961 children: labelContent 64962 } 64963 ), 64964 /* @__PURE__ */ (0, import_jsx_runtime404.jsx)("div", { className: "dataforms-layouts-panel__field-control", children: renderedControl }) 64965 ] }); 64966 } 64967 if (labelPosition === "none") { 64968 return /* @__PURE__ */ (0, import_jsx_runtime404.jsxs)(import_components229.__experimentalHStack, { className: "dataforms-layouts-panel__field dataforms-layouts-panel__field--label-position-none", children: [ 64969 showError && /* @__PURE__ */ (0, import_jsx_runtime404.jsx)(import_components229.Tooltip, { text: errorMessage, placement: "top", children: /* @__PURE__ */ (0, import_jsx_runtime404.jsx)( 64970 import_components229.Icon, 64971 { 64972 className: "dataforms-layouts-panel__field-label-error-content", 64973 icon: error_default, 64974 size: 16 64975 } 64976 ) }), 64977 /* @__PURE__ */ (0, import_jsx_runtime404.jsx)("div", { className: "dataforms-layouts-panel__field-control", children: renderedControl }) 64978 ] }); 64979 } 64980 return /* @__PURE__ */ (0, import_jsx_runtime404.jsxs)( 64981 import_components229.__experimentalHStack, 64982 { 64983 ref: setPopoverAnchor, 64984 className: "dataforms-layouts-panel__field", 64985 children: [ 64986 /* @__PURE__ */ (0, import_jsx_runtime404.jsx)("div", { className: labelClassName, children: labelContent }), 64987 /* @__PURE__ */ (0, import_jsx_runtime404.jsx)("div", { className: "dataforms-layouts-panel__field-control", children: renderedControl }) 64988 ] 64989 } 64990 ); 64991 } 64992 64993 // packages/dataviews/build-module/dataform-layouts/card/index.js 64994 var import_components230 = __toESM(require_components()); 64995 var import_element234 = __toESM(require_element()); 64996 var import_jsx_runtime405 = __toESM(require_jsx_runtime()); 64997 var NonCollapsibleCardHeader = ({ 64998 children, 64999 ...props 65000 }) => /* @__PURE__ */ (0, import_jsx_runtime405.jsx)(import_components230.CardHeader, { isBorderless: true, ...props, children: /* @__PURE__ */ (0, import_jsx_runtime405.jsx)( 65001 "div", 65002 { 65003 style: { 65004 height: "40px", 65005 // This is to match the chevron's __next40pxDefaultSize 65006 width: "100%", 65007 display: "flex", 65008 justifyContent: "space-between", 65009 alignItems: "center" 65010 }, 65011 children 65012 } 65013 ) }); 65014 function useCardHeader(layout) { 65015 const { isOpened, isCollapsible } = layout; 65016 const [isOpen, setIsOpen] = (0, import_element234.useState)(isOpened); 65017 const toggle = (0, import_element234.useCallback)(() => { 65018 setIsOpen((prev) => !prev); 65019 }, []); 65020 const CollapsibleCardHeader = (0, import_element234.useCallback)( 65021 ({ 65022 children, 65023 ...props 65024 }) => /* @__PURE__ */ (0, import_jsx_runtime405.jsxs)( 65025 import_components230.CardHeader, 65026 { 65027 ...props, 65028 onClick: toggle, 65029 style: { 65030 cursor: "pointer", 65031 ...props.style 65032 }, 65033 isBorderless: true, 65034 children: [ 65035 /* @__PURE__ */ (0, import_jsx_runtime405.jsx)( 65036 "div", 65037 { 65038 style: { 65039 width: "100%", 65040 display: "flex", 65041 justifyContent: "space-between", 65042 alignItems: "center" 65043 }, 65044 children 65045 } 65046 ), 65047 /* @__PURE__ */ (0, import_jsx_runtime405.jsx)( 65048 import_components230.Button, 65049 { 65050 __next40pxDefaultSize: true, 65051 variant: "tertiary", 65052 icon: isOpen ? chevron_up_default : chevron_down_default, 65053 "aria-expanded": isOpen, 65054 "aria-label": isOpen ? "Collapse" : "Expand" 65055 } 65056 ) 65057 ] 65058 } 65059 ), 65060 [toggle, isOpen] 65061 ); 65062 const effectiveIsOpen = isCollapsible ? isOpen : true; 65063 const CardHeaderComponent = isCollapsible ? CollapsibleCardHeader : NonCollapsibleCardHeader; 65064 return { isOpen: effectiveIsOpen, CardHeader: CardHeaderComponent }; 65065 } 65066 function isSummaryFieldVisible(summaryField, summaryConfig, isOpen) { 65067 if (!summaryConfig || Array.isArray(summaryConfig) && summaryConfig.length === 0) { 65068 return false; 65069 } 65070 const summaryConfigArray = Array.isArray(summaryConfig) ? summaryConfig : [summaryConfig]; 65071 const fieldConfig = summaryConfigArray.find((config2) => { 65072 if (typeof config2 === "string") { 65073 return config2 === summaryField.id; 65074 } 65075 if (typeof config2 === "object" && "id" in config2) { 65076 return config2.id === summaryField.id; 65077 } 65078 return false; 65079 }); 65080 if (!fieldConfig) { 65081 return false; 65082 } 65083 if (typeof fieldConfig === "string") { 65084 return true; 65085 } 65086 if (typeof fieldConfig === "object" && "visibility" in fieldConfig) { 65087 return fieldConfig.visibility === "always" || fieldConfig.visibility === "when-collapsed" && !isOpen; 65088 } 65089 return true; 65090 } 65091 function FormCardField({ 65092 data, 65093 field, 65094 onChange, 65095 hideLabelFromVision, 65096 validity 65097 }) { 65098 const { fields } = (0, import_element234.useContext)(dataform_context_default); 65099 const layout = field.layout; 65100 const form = (0, import_element234.useMemo)( 65101 () => ({ 65102 layout: DEFAULT_LAYOUT, 65103 fields: field.children ?? [] 65104 }), 65105 [field] 65106 ); 65107 const { isOpen, CardHeader } = useCardHeader(layout); 65108 const summaryFields = getSummaryFields(layout.summary, fields); 65109 const visibleSummaryFields = summaryFields.filter( 65110 (summaryField) => isSummaryFieldVisible(summaryField, layout.summary, isOpen) 65111 ); 65112 const sizeCard = { 65113 blockStart: "medium", 65114 blockEnd: "medium", 65115 inlineStart: "medium", 65116 inlineEnd: "medium" 65117 }; 65118 if (!!field.children) { 65119 const withHeader2 = !!field.label && layout.withHeader; 65120 const sizeCardBody2 = { 65121 blockStart: withHeader2 ? "none" : "medium", 65122 blockEnd: "medium", 65123 inlineStart: "medium", 65124 inlineEnd: "medium" 65125 }; 65126 return /* @__PURE__ */ (0, import_jsx_runtime405.jsxs)(import_components230.Card, { className: "dataforms-layouts-card__field", size: sizeCard, children: [ 65127 withHeader2 && /* @__PURE__ */ (0, import_jsx_runtime405.jsxs)(CardHeader, { className: "dataforms-layouts-card__field-header", children: [ 65128 /* @__PURE__ */ (0, import_jsx_runtime405.jsx)("span", { className: "dataforms-layouts-card__field-header-label", children: field.label }), 65129 visibleSummaryFields.length > 0 && layout.withHeader && /* @__PURE__ */ (0, import_jsx_runtime405.jsx)("div", { className: "dataforms-layouts-card__field-summary", children: visibleSummaryFields.map( 65130 (summaryField) => /* @__PURE__ */ (0, import_jsx_runtime405.jsx)( 65131 summaryField.render, 65132 { 65133 item: data, 65134 field: summaryField 65135 }, 65136 summaryField.id 65137 ) 65138 ) }) 65139 ] }), 65140 (isOpen || !withHeader2) && // If it doesn't have a header, keep it open. 65141 // Otherwise, the card will not be visible. 65142 /* @__PURE__ */ (0, import_jsx_runtime405.jsxs)( 65143 import_components230.CardBody, 65144 { 65145 size: sizeCardBody2, 65146 className: "dataforms-layouts-card__field-control", 65147 children: [ 65148 field.description && /* @__PURE__ */ (0, import_jsx_runtime405.jsx)("div", { className: "dataforms-layouts-card__field-description", children: field.description }), 65149 /* @__PURE__ */ (0, import_jsx_runtime405.jsx)( 65150 DataFormLayout, 65151 { 65152 data, 65153 form, 65154 onChange, 65155 validity: validity?.children 65156 } 65157 ) 65158 ] 65159 } 65160 ) 65161 ] }); 65162 } 65163 const fieldDefinition = fields.find( 65164 (fieldDef) => fieldDef.id === field.id 65165 ); 65166 if (!fieldDefinition || !fieldDefinition.Edit) { 65167 return null; 65168 } 65169 const RegularLayout = getFormFieldLayout("regular")?.component; 65170 if (!RegularLayout) { 65171 return null; 65172 } 65173 const withHeader = !!fieldDefinition.label && layout.withHeader; 65174 const sizeCardBody = { 65175 blockStart: withHeader ? "none" : "medium", 65176 blockEnd: "medium", 65177 inlineStart: "medium", 65178 inlineEnd: "medium" 65179 }; 65180 return /* @__PURE__ */ (0, import_jsx_runtime405.jsxs)(import_components230.Card, { className: "dataforms-layouts-card__field", size: sizeCard, children: [ 65181 withHeader && /* @__PURE__ */ (0, import_jsx_runtime405.jsxs)(CardHeader, { className: "dataforms-layouts-card__field-header", children: [ 65182 /* @__PURE__ */ (0, import_jsx_runtime405.jsx)("span", { className: "dataforms-layouts-card__field-header-label", children: fieldDefinition.label }), 65183 visibleSummaryFields.length > 0 && layout.withHeader && /* @__PURE__ */ (0, import_jsx_runtime405.jsx)("div", { className: "dataforms-layouts-card__field-summary", children: visibleSummaryFields.map((summaryField) => /* @__PURE__ */ (0, import_jsx_runtime405.jsx)( 65184 summaryField.render, 65185 { 65186 item: data, 65187 field: summaryField 65188 }, 65189 summaryField.id 65190 )) }) 65191 ] }), 65192 (isOpen || !withHeader) && // If it doesn't have a header, keep it open. 65193 // Otherwise, the card will not be visible. 65194 /* @__PURE__ */ (0, import_jsx_runtime405.jsx)( 65195 import_components230.CardBody, 65196 { 65197 size: sizeCardBody, 65198 className: "dataforms-layouts-card__field-control", 65199 children: /* @__PURE__ */ (0, import_jsx_runtime405.jsx)( 65200 RegularLayout, 65201 { 65202 data, 65203 field, 65204 onChange, 65205 hideLabelFromVision: hideLabelFromVision || withHeader, 65206 validity 65207 } 65208 ) 65209 } 65210 ) 65211 ] }); 65212 } 65213 65214 // packages/dataviews/build-module/dataform-layouts/row/index.js 65215 var import_components231 = __toESM(require_components()); 65216 var import_jsx_runtime406 = __toESM(require_jsx_runtime()); 65217 function Header2({ title }) { 65218 return /* @__PURE__ */ (0, import_jsx_runtime406.jsx)(import_components231.__experimentalVStack, { className: "dataforms-layouts-row__header", spacing: 4, children: /* @__PURE__ */ (0, import_jsx_runtime406.jsxs)(import_components231.__experimentalHStack, { alignment: "center", children: [ 65219 /* @__PURE__ */ (0, import_jsx_runtime406.jsx)(import_components231.__experimentalHeading, { level: 2, size: 13, children: title }), 65220 /* @__PURE__ */ (0, import_jsx_runtime406.jsx)(import_components231.__experimentalSpacer, {}) 65221 ] }) }); 65222 } 65223 var EMPTY_WRAPPER = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime406.jsx)(import_jsx_runtime406.Fragment, { children }); 65224 function FormRowField({ 65225 data, 65226 field, 65227 onChange, 65228 hideLabelFromVision, 65229 validity 65230 }) { 65231 const layout = field.layout; 65232 if (!!field.children) { 65233 const form = { 65234 layout: DEFAULT_LAYOUT, 65235 fields: field.children 65236 }; 65237 return /* @__PURE__ */ (0, import_jsx_runtime406.jsxs)("div", { className: "dataforms-layouts-row__field", children: [ 65238 !hideLabelFromVision && field.label && /* @__PURE__ */ (0, import_jsx_runtime406.jsx)(Header2, { title: field.label }), 65239 /* @__PURE__ */ (0, import_jsx_runtime406.jsx)(import_components231.__experimentalHStack, { alignment: layout.alignment, spacing: 4, children: /* @__PURE__ */ (0, import_jsx_runtime406.jsx)( 65240 DataFormLayout, 65241 { 65242 data, 65243 form, 65244 onChange, 65245 validity: validity?.children, 65246 as: EMPTY_WRAPPER, 65247 children: (FieldLayout, childField, childFieldValidity) => /* @__PURE__ */ (0, import_jsx_runtime406.jsx)( 65248 "div", 65249 { 65250 className: "dataforms-layouts-row__field-control", 65251 style: layout.styles[childField.id], 65252 children: /* @__PURE__ */ (0, import_jsx_runtime406.jsx)( 65253 FieldLayout, 65254 { 65255 data, 65256 field: childField, 65257 onChange, 65258 hideLabelFromVision, 65259 validity: childFieldValidity 65260 } 65261 ) 65262 }, 65263 childField.id 65264 ) 65265 } 65266 ) }) 65267 ] }); 65268 } 65269 const RegularLayout = getFormFieldLayout("regular")?.component; 65270 if (!RegularLayout) { 65271 return null; 65272 } 65273 return /* @__PURE__ */ (0, import_jsx_runtime406.jsx)(import_jsx_runtime406.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime406.jsx)("div", { className: "dataforms-layouts-row__field-control", children: /* @__PURE__ */ (0, import_jsx_runtime406.jsx)( 65274 RegularLayout, 65275 { 65276 data, 65277 field, 65278 onChange, 65279 validity 65280 } 65281 ) }) }); 65282 } 65283 65284 // packages/dataviews/build-module/dataform-layouts/details/index.js 65285 var import_element235 = __toESM(require_element()); 65286 var import_i18n214 = __toESM(require_i18n()); 65287 var import_jsx_runtime407 = __toESM(require_jsx_runtime()); 65288 function FormDetailsField({ 65289 data, 65290 field, 65291 onChange 65292 }) { 65293 const { fields } = (0, import_element235.useContext)(dataform_context_default); 65294 const form = (0, import_element235.useMemo)( 65295 () => ({ 65296 layout: DEFAULT_LAYOUT, 65297 fields: field.children ?? [] 65298 }), 65299 [field] 65300 ); 65301 if (!field.children) { 65302 return null; 65303 } 65304 const summaryFieldId = field.layout.summary ?? ""; 65305 const summaryField = summaryFieldId ? fields.find((fieldDef) => fieldDef.id === summaryFieldId) : void 0; 65306 let summaryContent; 65307 if (summaryField && summaryField.render) { 65308 summaryContent = /* @__PURE__ */ (0, import_jsx_runtime407.jsx)(summaryField.render, { item: data, field: summaryField }); 65309 } else { 65310 summaryContent = field.label || (0, import_i18n214.__)("More details"); 65311 } 65312 return /* @__PURE__ */ (0, import_jsx_runtime407.jsxs)("details", { className: "dataforms-layouts-details__details", children: [ 65313 /* @__PURE__ */ (0, import_jsx_runtime407.jsx)("summary", { className: "dataforms-layouts-details__summary", children: summaryContent }), 65314 /* @__PURE__ */ (0, import_jsx_runtime407.jsx)("div", { className: "dataforms-layouts-details__content", children: /* @__PURE__ */ (0, import_jsx_runtime407.jsx)( 65315 DataFormLayout, 65316 { 65317 data, 65318 form, 65319 onChange 65320 } 65321 ) }) 65322 ] }); 65323 } 65324 65325 // packages/dataviews/build-module/dataform-layouts/index.js 65326 var import_jsx_runtime408 = __toESM(require_jsx_runtime()); 65327 var FORM_FIELD_LAYOUTS = [ 65328 { 65329 type: "regular", 65330 component: FormRegularField, 65331 wrapper: ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime408.jsx)(import_components232.__experimentalVStack, { className: "dataforms-layouts__wrapper", spacing: 4, children }) 65332 }, 65333 { 65334 type: "panel", 65335 component: FormPanelField, 65336 wrapper: ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime408.jsx)(import_components232.__experimentalVStack, { className: "dataforms-layouts__wrapper", spacing: 2, children }) 65337 }, 65338 { 65339 type: "card", 65340 component: FormCardField, 65341 wrapper: ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime408.jsx)(import_components232.__experimentalVStack, { className: "dataforms-layouts__wrapper", spacing: 6, children }) 65342 }, 65343 { 65344 type: "row", 65345 component: FormRowField, 65346 wrapper: ({ 65347 children, 65348 layout 65349 }) => /* @__PURE__ */ (0, import_jsx_runtime408.jsx)(import_components232.__experimentalVStack, { className: "dataforms-layouts__wrapper", spacing: 4, children: /* @__PURE__ */ (0, import_jsx_runtime408.jsx)("div", { className: "dataforms-layouts-row__field", children: /* @__PURE__ */ (0, import_jsx_runtime408.jsx)( 65350 import_components232.__experimentalHStack, 65351 { 65352 spacing: 4, 65353 alignment: layout.alignment, 65354 children 65355 } 65356 ) }) }) 65357 }, 65358 { 65359 type: "details", 65360 component: FormDetailsField 65361 } 65362 ]; 65363 function getFormFieldLayout(type) { 65364 return FORM_FIELD_LAYOUTS.find((layout) => layout.type === type); 65365 } 65366 65367 // packages/dataviews/build-module/dataform-layouts/data-form-layout.js 65368 var import_jsx_runtime409 = __toESM(require_jsx_runtime()); 65369 var DEFAULT_WRAPPER = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime409.jsx)(import_components233.__experimentalVStack, { className: "dataforms-layouts__wrapper", spacing: 4, children }); 65370 function DataFormLayout({ 65371 data, 65372 form, 65373 onChange, 65374 validity, 65375 children, 65376 as 65377 }) { 65378 const { fields: fieldDefinitions } = (0, import_element236.useContext)(dataform_context_default); 65379 function getFieldDefinition2(field) { 65380 return fieldDefinitions.find( 65381 (fieldDefinition) => fieldDefinition.id === field.id 65382 ); 65383 } 65384 const Wrapper = as ?? getFormFieldLayout(form.layout.type)?.wrapper ?? DEFAULT_WRAPPER; 65385 return /* @__PURE__ */ (0, import_jsx_runtime409.jsx)(Wrapper, { layout: form.layout, children: form.fields.map((formField) => { 65386 const FieldLayout = getFormFieldLayout(formField.layout.type)?.component; 65387 if (!FieldLayout) { 65388 return null; 65389 } 65390 const fieldDefinition = !formField.children ? getFieldDefinition2(formField) : void 0; 65391 if (fieldDefinition && fieldDefinition.isVisible && !fieldDefinition.isVisible(data)) { 65392 return null; 65393 } 65394 if (children) { 65395 return children( 65396 FieldLayout, 65397 formField, 65398 validity?.[formField.id] 65399 ); 65400 } 65401 return /* @__PURE__ */ (0, import_jsx_runtime409.jsx)( 65402 FieldLayout, 65403 { 65404 data, 65405 field: formField, 65406 onChange, 65407 validity: validity?.[formField.id] 65408 }, 65409 formField.id 65410 ); 65411 }) }); 65412 } 65413 65414 // packages/dataviews/build-module/components/dataform/index.js 65415 var import_jsx_runtime410 = __toESM(require_jsx_runtime()); 65416 function DataForm({ 65417 data, 65418 form, 65419 fields, 65420 onChange, 65421 validity 65422 }) { 65423 const normalizedForm = (0, import_element237.useMemo)(() => normalize_form_default(form), [form]); 65424 const normalizedFields = (0, import_element237.useMemo)( 65425 () => normalizeFields(fields), 65426 [fields] 65427 ); 65428 if (!form.fields) { 65429 return null; 65430 } 65431 return /* @__PURE__ */ (0, import_jsx_runtime410.jsx)(DataFormProvider, { fields: normalizedFields, children: /* @__PURE__ */ (0, import_jsx_runtime410.jsx)( 65432 DataFormLayout, 65433 { 65434 data, 65435 form: normalizedForm, 65436 onChange, 65437 validity 65438 } 65439 ) }); 65440 } 65441 65442 // packages/block-editor/build-module/components/content-only-controls/index.js 65443 var import_element240 = __toESM(require_element()); 65444 65445 // packages/block-editor/build-module/components/content-only-controls/fields-dropdown-menu.js 65446 var import_components234 = __toESM(require_components()); 65447 var import_i18n215 = __toESM(require_i18n()); 65448 65449 // packages/block-editor/build-module/components/content-only-controls/use-inspector-popover-placement.js 65450 var import_compose91 = __toESM(require_compose()); 65451 function useInspectorPopoverPlacement({ isControl } = { isControl: false }) { 65452 const isMobile = (0, import_compose91.useViewportMatch)("medium", "<"); 65453 return !isMobile ? { 65454 popoverProps: { 65455 placement: "left-start", 65456 // For non-mobile, inner sidebar width (248px) - button width (24px) - border (1px) + padding (16px) + spacing (20px) 65457 offset: isControl ? 35 : 259 65458 } 65459 } : {}; 65460 } 65461 65462 // packages/block-editor/build-module/components/content-only-controls/fields-dropdown-menu.js 65463 var import_jsx_runtime411 = __toESM(require_jsx_runtime()); 65464 function FieldsDropdownMenu({ 65465 fields, 65466 visibleFields, 65467 onToggleField 65468 }) { 65469 const { popoverProps: popoverProps3 } = useInspectorPopoverPlacement(); 65470 if (!fields || fields.length === 0) { 65471 return null; 65472 } 65473 return /* @__PURE__ */ (0, import_jsx_runtime411.jsx)( 65474 import_components234.DropdownMenu, 65475 { 65476 icon: more_vertical_default, 65477 label: (0, import_i18n215.__)("Options"), 65478 popoverProps: popoverProps3, 65479 children: ({ onClose }) => /* @__PURE__ */ (0, import_jsx_runtime411.jsx)(import_components234.MenuGroup, { label: (0, import_i18n215.__)("Show / Hide"), children: fields.map((field) => { 65480 const isVisible = visibleFields.includes(field.id); 65481 return /* @__PURE__ */ (0, import_jsx_runtime411.jsx)( 65482 import_components234.MenuItem, 65483 { 65484 isSelected: isVisible, 65485 onClick: () => { 65486 onToggleField(field.id); 65487 onClose(); 65488 }, 65489 role: "menuitemcheckbox", 65490 icon: isVisible ? check_default : null, 65491 children: field.label 65492 }, 65493 field.id 65494 ); 65495 }) }) 65496 } 65497 ); 65498 } 65499 65500 // packages/block-editor/build-module/components/content-only-controls/rich-text/index.js 65501 var import_components235 = __toESM(require_components()); 65502 var import_compose92 = __toESM(require_compose()); 65503 var import_data166 = __toESM(require_data()); 65504 var import_element238 = __toESM(require_element()); 65505 var import_rich_text17 = __toESM(require_rich_text()); 65506 var import_jsx_runtime412 = __toESM(require_jsx_runtime()); 65507 function RichTextControl({ 65508 data, 65509 field, 65510 hideLabelFromVision, 65511 onChange, 65512 config: config2 = {} 65513 }) { 65514 const registry = (0, import_data166.useRegistry)(); 65515 const attrValue = field.getValue({ item: data }); 65516 const fieldConfig = field.config || {}; 65517 const { clientId } = config2; 65518 const updateAttributes = (html) => { 65519 const mappedChanges = field.setValue({ item: data, value: html }); 65520 onChange(mappedChanges); 65521 }; 65522 const [selection2, setSelection] = (0, import_element238.useState)({ 65523 start: void 0, 65524 end: void 0 65525 }); 65526 const [isSelected, setIsSelected] = (0, import_element238.useState)(false); 65527 const anchorRef = (0, import_element238.useRef)(); 65528 const inputEvents = (0, import_element238.useRef)(/* @__PURE__ */ new Set()); 65529 const keyboardShortcuts = (0, import_element238.useRef)(/* @__PURE__ */ new Set()); 65530 const adjustedAllowedFormats = getAllowedFormats({ 65531 allowedFormats: fieldConfig?.allowedFormats, 65532 disableFormats: fieldConfig?.disableFormats 65533 }); 65534 const { 65535 formatTypes, 65536 prepareHandlers, 65537 valueHandlers, 65538 changeHandlers, 65539 dependencies 65540 } = useFormatTypes({ 65541 clientId, 65542 identifier: field.id, 65543 allowedFormats: adjustedAllowedFormats, 65544 withoutInteractiveFormatting: fieldConfig?.withoutInteractiveFormatting, 65545 disableNoneEssentialFormatting: true 65546 }); 65547 function addEditorOnlyFormats(value2) { 65548 return valueHandlers.reduce( 65549 (accumulator, fn) => fn(accumulator, value2.text), 65550 value2.formats 65551 ); 65552 } 65553 function removeEditorOnlyFormats(value2) { 65554 formatTypes.forEach((formatType) => { 65555 if (formatType.__experimentalCreatePrepareEditableTree) { 65556 value2 = (0, import_rich_text17.removeFormat)( 65557 value2, 65558 formatType.name, 65559 0, 65560 value2.text.length 65561 ); 65562 } 65563 }); 65564 return value2.formats; 65565 } 65566 function addInvisibleFormats(value2) { 65567 return prepareHandlers.reduce( 65568 (accumulator, fn) => fn(accumulator, value2.text), 65569 value2.formats 65570 ); 65571 } 65572 function onFocus() { 65573 anchorRef.current?.focus(); 65574 } 65575 const { 65576 value, 65577 getValue, 65578 onChange: onRichTextChange, 65579 ref: richTextRef 65580 } = (0, import_rich_text17.__unstableUseRichText)({ 65581 value: attrValue, 65582 onChange(html, { __unstableFormats, __unstableText }) { 65583 updateAttributes(html); 65584 Object.values(changeHandlers).forEach((changeHandler) => { 65585 changeHandler(__unstableFormats, __unstableText); 65586 }); 65587 }, 65588 selectionStart: selection2.start, 65589 selectionEnd: selection2.end, 65590 onSelectionChange: (start2, end) => setSelection({ start: start2, end }), 65591 __unstableIsSelected: isSelected, 65592 preserveWhiteSpace: !!fieldConfig?.preserveWhiteSpace, 65593 placeholder: fieldConfig?.placeholder, 65594 __unstableDisableFormats: fieldConfig?.disableFormats, 65595 __unstableDependencies: dependencies, 65596 __unstableAfterParse: addEditorOnlyFormats, 65597 __unstableBeforeSerialize: removeEditorOnlyFormats, 65598 __unstableAddInvisibleFormats: addInvisibleFormats 65599 }); 65600 const { baseControlProps, controlProps } = (0, import_components235.useBaseControlProps)({ 65601 hideLabelFromVision: hideLabelFromVision ?? field.hideLabelFromVision, 65602 label: field.label 65603 }); 65604 return /* @__PURE__ */ (0, import_jsx_runtime412.jsxs)(import_jsx_runtime412.Fragment, { children: [ 65605 isSelected && /* @__PURE__ */ (0, import_jsx_runtime412.jsx)(keyboardShortcutContext.Provider, { value: keyboardShortcuts, children: /* @__PURE__ */ (0, import_jsx_runtime412.jsx)(inputEventContext.Provider, { value: inputEvents, children: /* @__PURE__ */ (0, import_jsx_runtime412.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime412.jsx)( 65606 FormatEdit, 65607 { 65608 value, 65609 onChange: onRichTextChange, 65610 onFocus, 65611 formatTypes, 65612 forwardedRef: anchorRef, 65613 isVisible: false 65614 } 65615 ) }) }) }), 65616 /* @__PURE__ */ (0, import_jsx_runtime412.jsx)(import_components235.BaseControl, { ...baseControlProps, children: /* @__PURE__ */ (0, import_jsx_runtime412.jsx)( 65617 "div", 65618 { 65619 className: "block-editor-content-only-controls__rich-text", 65620 role: "textbox", 65621 "aria-multiline": !fieldConfig?.disableLineBreaks, 65622 ref: (0, import_compose92.useMergeRefs)([ 65623 richTextRef, 65624 useEventListeners({ 65625 registry, 65626 getValue, 65627 onChange: onRichTextChange, 65628 formatTypes, 65629 selectionChange: setSelection, 65630 isSelected, 65631 disableFormats: fieldConfig?.disableFormats, 65632 value, 65633 tagName: "div", 65634 removeEditorOnlyFormats, 65635 disableLineBreaks: fieldConfig?.disableLineBreaks, 65636 keyboardShortcuts, 65637 inputEvents 65638 }), 65639 anchorRef 65640 ]), 65641 onFocus: () => setIsSelected(true), 65642 onBlur: () => setIsSelected(false), 65643 contentEditable: true, 65644 ...controlProps 65645 } 65646 ) }) 65647 ] }); 65648 } 65649 65650 // packages/block-editor/build-module/components/content-only-controls/media/index.js 65651 var import_components236 = __toESM(require_components()); 65652 var import_data167 = __toESM(require_data()); 65653 var import_i18n216 = __toESM(require_i18n()); 65654 var import_jsx_runtime413 = __toESM(require_jsx_runtime()); 65655 function MediaThumbnail({ data, field, attachment }) { 65656 const config2 = field.config || {}; 65657 const { allowedTypes = [], multiple = false } = config2; 65658 if (multiple) { 65659 return "todo multiple"; 65660 } 65661 if (attachment?.media_type === "image" || attachment?.poster) { 65662 return /* @__PURE__ */ (0, import_jsx_runtime413.jsx)( 65663 "img", 65664 { 65665 className: "block-editor-content-only-controls__media-thumbnail", 65666 alt: "", 65667 width: 24, 65668 height: 24, 65669 src: attachment.media_type === "image" ? attachment.source_url : attachment.poster 65670 } 65671 ); 65672 } 65673 if (allowedTypes.length === 1) { 65674 const value = field.getValue({ item: data }); 65675 const url = value?.url; 65676 if (url) { 65677 return /* @__PURE__ */ (0, import_jsx_runtime413.jsx)( 65678 "img", 65679 { 65680 className: "block-editor-content-only-controls__media-thumbnail", 65681 alt: "", 65682 width: 24, 65683 height: 24, 65684 src: url 65685 } 65686 ); 65687 } 65688 let icon; 65689 if (allowedTypes[0] === "image") { 65690 icon = image_default; 65691 } else if (allowedTypes[0] === "video") { 65692 icon = video_default; 65693 } else if (allowedTypes[0] === "audio") { 65694 icon = audio_default; 65695 } else { 65696 icon = media_default; 65697 } 65698 if (icon) { 65699 return /* @__PURE__ */ (0, import_jsx_runtime413.jsx)(import_components236.Icon, { icon, size: 24 }); 65700 } 65701 } 65702 return /* @__PURE__ */ (0, import_jsx_runtime413.jsx)(import_components236.Icon, { icon: media_default, size: 24 }); 65703 } 65704 function Media({ data, field, onChange, config: config2 = {} }) { 65705 const { popoverProps: popoverProps3 } = useInspectorPopoverPlacement({ 65706 isControl: true 65707 }); 65708 const value = field.getValue({ item: data }); 65709 const { allowedTypes = [], multiple = false } = field.config || {}; 65710 const { fieldDef } = config2; 65711 const updateAttributes = (newFieldValue) => { 65712 const mappedChanges = field.setValue({ 65713 item: data, 65714 value: newFieldValue 65715 }); 65716 onChange(mappedChanges); 65717 }; 65718 const hasFeaturedImageSupport = fieldDef?.mapping && "featuredImage" in fieldDef.mapping; 65719 const id = value?.id; 65720 const url = value?.url; 65721 const attachment = (0, import_data167.useSelect)( 65722 (select3) => { 65723 if (!id) { 65724 return; 65725 } 65726 const settings2 = select3(store).getSettings(); 65727 const getMedia = settings2[getMediaSelectKey]; 65728 if (!getMedia) { 65729 return; 65730 } 65731 return getMedia(select3, id); 65732 }, 65733 [id] 65734 ); 65735 let chooseItemLabel; 65736 if (allowedTypes.length === 1) { 65737 const allowedType = allowedTypes[0]; 65738 if (allowedType === "image") { 65739 chooseItemLabel = (0, import_i18n216.__)("Choose an image\u2026"); 65740 } else if (allowedType === "video") { 65741 chooseItemLabel = (0, import_i18n216.__)("Choose a video\u2026"); 65742 } else if (allowedType === "application") { 65743 chooseItemLabel = (0, import_i18n216.__)("Choose a file\u2026"); 65744 } else { 65745 chooseItemLabel = (0, import_i18n216.__)("Choose a media item\u2026"); 65746 } 65747 } else { 65748 chooseItemLabel = (0, import_i18n216.__)("Choose a media item\u2026"); 65749 } 65750 return /* @__PURE__ */ (0, import_jsx_runtime413.jsx)(check_default2, { children: /* @__PURE__ */ (0, import_jsx_runtime413.jsx)( 65751 media_replace_flow_default, 65752 { 65753 className: "block-editor-content-only-controls__media-replace-flow", 65754 allowedTypes, 65755 mediaId: id, 65756 mediaURL: url, 65757 multiple, 65758 popoverProps: popoverProps3, 65759 onReset: () => { 65760 const resetValue = {}; 65761 if (fieldDef?.mapping) { 65762 Object.keys(fieldDef.mapping).forEach((key) => { 65763 if (key === "id" || key === "src" || key === "url") { 65764 resetValue[key] = void 0; 65765 } else if (key === "caption" || key === "alt") { 65766 resetValue[key] = ""; 65767 } 65768 }); 65769 } 65770 if (hasFeaturedImageSupport) { 65771 resetValue.featuredImage = false; 65772 } 65773 updateAttributes({ ...value, ...resetValue }); 65774 }, 65775 ...hasFeaturedImageSupport && { 65776 useFeaturedImage: !!value?.featuredImage, 65777 onToggleFeaturedImage: () => { 65778 updateAttributes({ 65779 ...value, 65780 featuredImage: !value?.featuredImage 65781 }); 65782 } 65783 }, 65784 onSelect: (selectedMedia) => { 65785 if (selectedMedia.id && selectedMedia.url) { 65786 let mediaType = "image"; 65787 if (selectedMedia.mime_type) { 65788 if (selectedMedia.mime_type.startsWith("video/")) { 65789 mediaType = "video"; 65790 } else if (selectedMedia.mime_type.startsWith("audio/")) { 65791 mediaType = "audio"; 65792 } 65793 } 65794 const newValue = {}; 65795 if (fieldDef?.mapping) { 65796 Object.keys(fieldDef.mapping).forEach( 65797 (key) => { 65798 if (key === "id") { 65799 newValue[key] = selectedMedia.id; 65800 } else if (key === "src" || key === "url") { 65801 newValue[key] = selectedMedia.url; 65802 } else if (key === "type") { 65803 newValue[key] = mediaType; 65804 } else if (key === "link" && selectedMedia.link) { 65805 newValue[key] = selectedMedia.link; 65806 } else if (key === "caption" && !value?.caption && selectedMedia.caption) { 65807 newValue[key] = selectedMedia.caption; 65808 } else if (key === "alt" && !value?.alt && selectedMedia.alt) { 65809 newValue[key] = selectedMedia.alt; 65810 } else if (key === "poster" && selectedMedia.poster) { 65811 newValue[key] = selectedMedia.poster; 65812 } 65813 } 65814 ); 65815 } 65816 if (hasFeaturedImageSupport) { 65817 newValue.featuredImage = false; 65818 } 65819 const finalValue = { ...value, ...newValue }; 65820 updateAttributes(finalValue); 65821 } 65822 }, 65823 renderToggle: (buttonProps) => /* @__PURE__ */ (0, import_jsx_runtime413.jsx)( 65824 import_components236.Button, 65825 { 65826 __next40pxDefaultSize: true, 65827 className: "block-editor-content-only-controls__media", 65828 ...buttonProps, 65829 children: /* @__PURE__ */ (0, import_jsx_runtime413.jsxs)( 65830 import_components236.__experimentalGrid, 65831 { 65832 rowGap: 0, 65833 columnGap: 8, 65834 templateColumns: "24px 1fr", 65835 className: "block-editor-content-only-controls__media-row", 65836 children: [ 65837 url && /* @__PURE__ */ (0, import_jsx_runtime413.jsxs)(import_jsx_runtime413.Fragment, { children: [ 65838 /* @__PURE__ */ (0, import_jsx_runtime413.jsx)( 65839 MediaThumbnail, 65840 { 65841 attachment, 65842 field, 65843 data 65844 } 65845 ), 65846 /* @__PURE__ */ (0, import_jsx_runtime413.jsx)("span", { 65847 className: "block-editor-content-only-controls__media-title", 65848 // TODO - truncate long titles or url smartly (e.g. show filename). 65849 children: attachment?.title?.raw && attachment?.title?.raw !== "" ? attachment?.title?.raw : url 65850 }) 65851 ] }), 65852 !url && /* @__PURE__ */ (0, import_jsx_runtime413.jsxs)(import_jsx_runtime413.Fragment, { children: [ 65853 /* @__PURE__ */ (0, import_jsx_runtime413.jsx)( 65854 "span", 65855 { 65856 className: "block-editor-content-only-controls__media-placeholder", 65857 style: { 65858 width: "24px", 65859 height: "24px" 65860 } 65861 } 65862 ), 65863 /* @__PURE__ */ (0, import_jsx_runtime413.jsx)("span", { className: "block-editor-content-only-controls__media-title", children: chooseItemLabel }) 65864 ] }) 65865 ] 65866 } 65867 ) 65868 } 65869 ) 65870 } 65871 ) }); 65872 } 65873 65874 // packages/block-editor/build-module/components/content-only-controls/link/index.js 65875 var import_components237 = __toESM(require_components()); 65876 var import_element239 = __toESM(require_element()); 65877 var import_i18n217 = __toESM(require_i18n()); 65878 var import_url15 = __toESM(require_url()); 65879 var import_jsx_runtime414 = __toESM(require_jsx_runtime()); 65880 var NEW_TAB_REL2 = "noreferrer noopener"; 65881 var NEW_TAB_TARGET = "_blank"; 65882 var NOFOLLOW_REL = "nofollow"; 65883 function getUpdatedLinkAttributes({ 65884 rel = "", 65885 url = "", 65886 opensInNewTab, 65887 nofollow 65888 }) { 65889 let newLinkTarget; 65890 let updatedRel = rel; 65891 if (opensInNewTab) { 65892 newLinkTarget = NEW_TAB_TARGET; 65893 updatedRel = updatedRel?.includes(NEW_TAB_REL2) ? updatedRel : updatedRel + ` $NEW_TAB_REL2}`; 65894 } else { 65895 const relRegex = new RegExp(`\\b$NEW_TAB_REL2}\\s*`, "g"); 65896 updatedRel = updatedRel?.replace(relRegex, "").trim(); 65897 } 65898 if (nofollow) { 65899 updatedRel = updatedRel?.includes(NOFOLLOW_REL) ? updatedRel : (updatedRel + ` $NOFOLLOW_REL}`).trim(); 65900 } else { 65901 const relRegex = new RegExp(`\\b$NOFOLLOW_REL}\\s*`, "g"); 65902 updatedRel = updatedRel?.replace(relRegex, "").trim(); 65903 } 65904 return { 65905 url: (0, import_url15.prependHTTP)(url), 65906 linkTarget: newLinkTarget, 65907 rel: updatedRel || void 0 65908 }; 65909 } 65910 function Link({ data, field, onChange, config: config2 = {} }) { 65911 const [isLinkControlOpen, setIsLinkControlOpen] = (0, import_element239.useState)(false); 65912 const { popoverProps: popoverProps3 } = useInspectorPopoverPlacement({ 65913 isControl: true 65914 }); 65915 const { fieldDef } = config2; 65916 const updateAttributes = (newValue) => { 65917 const mappedChanges = field.setValue({ item: data, value: newValue }); 65918 onChange(mappedChanges); 65919 }; 65920 const value = field.getValue({ item: data }); 65921 const url = value?.url; 65922 const rel = value?.rel || ""; 65923 const target = value?.linkTarget; 65924 const opensInNewTab = target === NEW_TAB_TARGET; 65925 const nofollow = rel === NOFOLLOW_REL; 65926 const linkValue = (0, import_element239.useMemo)( 65927 () => ({ url, opensInNewTab, nofollow }), 65928 [url, opensInNewTab, nofollow] 65929 ); 65930 return /* @__PURE__ */ (0, import_jsx_runtime414.jsxs)(import_jsx_runtime414.Fragment, { children: [ 65931 /* @__PURE__ */ (0, import_jsx_runtime414.jsx)( 65932 import_components237.Button, 65933 { 65934 __next40pxDefaultSize: true, 65935 className: "block-editor-content-only-controls__link", 65936 onClick: () => { 65937 setIsLinkControlOpen(true); 65938 }, 65939 children: /* @__PURE__ */ (0, import_jsx_runtime414.jsxs)( 65940 import_components237.__experimentalGrid, 65941 { 65942 rowGap: 0, 65943 columnGap: 8, 65944 templateColumns: "24px 1fr", 65945 className: "block-editor-content-only-controls__link-row", 65946 children: [ 65947 url && /* @__PURE__ */ (0, import_jsx_runtime414.jsxs)(import_jsx_runtime414.Fragment, { children: [ 65948 /* @__PURE__ */ (0, import_jsx_runtime414.jsx)(import_components237.Icon, { icon: link_default, size: 24 }), 65949 /* @__PURE__ */ (0, import_jsx_runtime414.jsx)("span", { className: "block-editor-content-only-controls__link-title", children: url }) 65950 ] }), 65951 !url && /* @__PURE__ */ (0, import_jsx_runtime414.jsxs)(import_jsx_runtime414.Fragment, { children: [ 65952 /* @__PURE__ */ (0, import_jsx_runtime414.jsx)( 65953 import_components237.Icon, 65954 { 65955 icon: link_default, 65956 size: 24, 65957 style: { opacity: 0.3 } 65958 } 65959 ), 65960 /* @__PURE__ */ (0, import_jsx_runtime414.jsx)("span", { className: "block-editor-content-only-controls__link-title", children: (0, import_i18n217.__)("Link") }) 65961 ] }) 65962 ] 65963 } 65964 ) 65965 } 65966 ), 65967 isLinkControlOpen && /* @__PURE__ */ (0, import_jsx_runtime414.jsx)( 65968 import_components237.Popover, 65969 { 65970 onClose: () => { 65971 setIsLinkControlOpen(false); 65972 }, 65973 ...popoverProps3 ?? {}, 65974 children: /* @__PURE__ */ (0, import_jsx_runtime414.jsx)( 65975 link_control_default, 65976 { 65977 value: linkValue, 65978 onChange: (newValues) => { 65979 const updatedAttrs = getUpdatedLinkAttributes({ 65980 rel, 65981 ...newValues 65982 }); 65983 const updateValue = { ...value }; 65984 if (fieldDef?.mapping) { 65985 Object.keys(fieldDef.mapping).forEach( 65986 (key) => { 65987 if (key === "href" || key === "url") { 65988 updateValue[key] = updatedAttrs.url; 65989 } else if (key === "rel") { 65990 updateValue[key] = updatedAttrs.rel; 65991 } else if (key === "target" || key === "linkTarget") { 65992 updateValue[key] = updatedAttrs.linkTarget; 65993 } 65994 } 65995 ); 65996 } 65997 updateAttributes(updateValue); 65998 }, 65999 onRemove: () => { 66000 const removeValue = {}; 66001 if (fieldDef?.mapping) { 66002 Object.keys(fieldDef.mapping).forEach( 66003 (key) => { 66004 if (key === "href" || key === "url" || key === "rel" || key === "target" || key === "linkTarget") { 66005 removeValue[key] = void 0; 66006 } 66007 } 66008 ); 66009 } 66010 updateAttributes(removeValue); 66011 } 66012 } 66013 ) 66014 } 66015 ) 66016 ] }); 66017 } 66018 66019 // packages/block-editor/build-module/components/content-only-controls/index.js 66020 var import_jsx_runtime415 = __toESM(require_jsx_runtime()); 66021 var { fieldsKey, formKey } = unlock(import_blocks92.privateApis); 66022 var CONTROLS = { 66023 richtext: RichTextControl, 66024 media: Media, 66025 link: Link 66026 }; 66027 function createConfiguredControl2(config2) { 66028 const { control, ...controlConfig } = config2; 66029 const ControlComponent = CONTROLS[control]; 66030 if (!ControlComponent) { 66031 throw new Error(`Control type "$control}" not found`); 66032 } 66033 return function ConfiguredControl(props) { 66034 return /* @__PURE__ */ (0, import_jsx_runtime415.jsx)(ControlComponent, { ...props, config: controlConfig }); 66035 }; 66036 } 66037 function normalizeMediaValue(value, fieldDef) { 66038 const defaults2 = { 66039 id: null, 66040 url: "", 66041 caption: "", 66042 alt: "", 66043 type: "image", 66044 poster: "", 66045 featuredImage: false, 66046 link: "" 66047 }; 66048 const result = {}; 66049 if (fieldDef?.mapping) { 66050 Object.keys(fieldDef.mapping).forEach((key) => { 66051 result[key] = value?.[key] ?? defaults2[key] ?? ""; 66052 }); 66053 return result; 66054 } 66055 Object.keys(defaults2).forEach((key) => { 66056 result[key] = value?.[key] ?? defaults2[key]; 66057 }); 66058 return result; 66059 } 66060 function denormalizeMediaValue(value, fieldDef) { 66061 if (!fieldDef.mapping) { 66062 return value; 66063 } 66064 const result = {}; 66065 Object.entries(fieldDef.mapping).forEach(([key]) => { 66066 if (key in value) { 66067 result[key] = value[key]; 66068 } 66069 }); 66070 return result; 66071 } 66072 function normalizeLinkValue(value, fieldDef) { 66073 const defaults2 = { 66074 url: "", 66075 rel: "", 66076 linkTarget: "", 66077 destination: "" 66078 }; 66079 const result = {}; 66080 if (fieldDef?.mapping) { 66081 Object.keys(fieldDef.mapping).forEach((key) => { 66082 result[key] = value?.[key] ?? defaults2[key] ?? ""; 66083 }); 66084 return result; 66085 } 66086 Object.keys(defaults2).forEach((key) => { 66087 result[key] = value?.[key] ?? defaults2[key]; 66088 }); 66089 return result; 66090 } 66091 function denormalizeLinkValue(value, fieldDef) { 66092 if (!fieldDef.mapping) { 66093 return value; 66094 } 66095 const result = {}; 66096 Object.entries(fieldDef.mapping).forEach(([key]) => { 66097 if (key in value) { 66098 result[key] = value[key]; 66099 } 66100 }); 66101 return result; 66102 } 66103 function BlockFields({ clientId }) { 66104 const { attributes, blockType } = (0, import_data168.useSelect)( 66105 (select3) => { 66106 const { getBlockAttributes: getBlockAttributes3, getBlockName: getBlockName2 } = select3(store); 66107 const { getBlockType: getBlockType21 } = select3(import_blocks92.store); 66108 const blockName = getBlockName2(clientId); 66109 return { 66110 attributes: getBlockAttributes3(clientId), 66111 blockType: getBlockType21(blockName) 66112 }; 66113 }, 66114 [clientId] 66115 ); 66116 const { updateBlockAttributes: updateBlockAttributes2 } = (0, import_data168.useDispatch)(store); 66117 const blockTitle = useBlockDisplayTitle({ 66118 clientId, 66119 context: "list-view" 66120 }); 66121 const blockInformation = useBlockDisplayInformation(clientId); 66122 const blockTypeFields = blockType?.[fieldsKey]; 66123 const [form, setForm] = (0, import_element240.useState)(() => { 66124 return blockType?.[formKey]; 66125 }); 66126 const dataFormFields = (0, import_element240.useMemo)(() => { 66127 if (!blockTypeFields?.length) { 66128 return []; 66129 } 66130 return blockTypeFields.map((fieldDef) => { 66131 const ControlComponent = CONTROLS[fieldDef.type]; 66132 const defaultValues = {}; 66133 if (fieldDef.mapping && blockType?.attributes) { 66134 Object.entries(fieldDef.mapping).forEach( 66135 ([key, attrKey]) => { 66136 defaultValues[key] = blockType.attributes[attrKey]?.defaultValue ?? void 0; 66137 } 66138 ); 66139 } 66140 const field = { 66141 id: fieldDef.id, 66142 label: fieldDef.label, 66143 type: fieldDef.type, 66144 // Use the field's type; DataForm will use built-in or custom Edit 66145 config: { ...fieldDef.args, defaultValues }, 66146 hideLabelFromVision: fieldDef.id === "content", 66147 // getValue and setValue handle the mapping to block attributes 66148 getValue: ({ item }) => { 66149 if (fieldDef.mapping) { 66150 const mappedValue = {}; 66151 Object.entries(fieldDef.mapping).forEach( 66152 ([key, attrKey]) => { 66153 mappedValue[key] = item[attrKey]; 66154 } 66155 ); 66156 if (fieldDef.type === "media") { 66157 return normalizeMediaValue(mappedValue, fieldDef); 66158 } 66159 if (fieldDef.type === "link") { 66160 return normalizeLinkValue(mappedValue, fieldDef); 66161 } 66162 return mappedValue; 66163 } 66164 return item[fieldDef.id]; 66165 }, 66166 setValue: ({ item, value }) => { 66167 if (fieldDef.mapping) { 66168 let denormalizedValue = value; 66169 if (fieldDef.type === "media") { 66170 denormalizedValue = denormalizeMediaValue( 66171 value, 66172 fieldDef 66173 ); 66174 } else if (fieldDef.type === "link") { 66175 denormalizedValue = denormalizeLinkValue( 66176 value, 66177 fieldDef 66178 ); 66179 } 66180 const updates = {}; 66181 Object.entries(fieldDef.mapping).forEach( 66182 ([key, attrKey]) => { 66183 if (key in denormalizedValue) { 66184 updates[attrKey] = denormalizedValue[key]; 66185 } else { 66186 updates[attrKey] = item[attrKey]; 66187 } 66188 } 66189 ); 66190 return updates; 66191 } 66192 return { [fieldDef.id]: value }; 66193 } 66194 }; 66195 if (ControlComponent) { 66196 field.Edit = createConfiguredControl2({ 66197 control: fieldDef.type, 66198 clientId, 66199 fieldDef 66200 }); 66201 } 66202 return field; 66203 }); 66204 }, [blockTypeFields, blockType?.attributes, clientId]); 66205 const handleToggleField = (fieldId) => { 66206 setForm((prev) => { 66207 if (prev.fields?.includes(fieldId)) { 66208 return { 66209 ...prev, 66210 fields: prev.fields.filter((id) => id !== fieldId) 66211 }; 66212 } 66213 return { 66214 ...prev, 66215 fields: [...prev.fields || [], fieldId] 66216 }; 66217 }); 66218 }; 66219 if (!blockTypeFields?.length) { 66220 return null; 66221 } 66222 return /* @__PURE__ */ (0, import_jsx_runtime415.jsxs)("div", { className: "block-editor-content-only-controls__fields-container", children: [ 66223 /* @__PURE__ */ (0, import_jsx_runtime415.jsx)("div", { className: "block-editor-content-only-controls__fields-header", children: /* @__PURE__ */ (0, import_jsx_runtime415.jsxs)(import_components238.__experimentalHStack, { spacing: 1, justify: "space-between", expanded: true, children: [ 66224 /* @__PURE__ */ (0, import_jsx_runtime415.jsxs)(import_components238.__experimentalHStack, { spacing: 1, justify: "flex-start", children: [ 66225 /* @__PURE__ */ (0, import_jsx_runtime415.jsx)(block_icon_default, { icon: blockInformation?.icon }), 66226 /* @__PURE__ */ (0, import_jsx_runtime415.jsx)("div", { children: blockTitle }) 66227 ] }), 66228 /* @__PURE__ */ (0, import_jsx_runtime415.jsx)( 66229 FieldsDropdownMenu, 66230 { 66231 fields: dataFormFields, 66232 visibleFields: form.fields, 66233 onToggleField: handleToggleField 66234 } 66235 ) 66236 ] }) }), 66237 /* @__PURE__ */ (0, import_jsx_runtime415.jsx)( 66238 DataForm, 66239 { 66240 data: attributes, 66241 fields: dataFormFields, 66242 form, 66243 onChange: (changes) => { 66244 updateBlockAttributes2(clientId, changes); 66245 } 66246 } 66247 ) 66248 ] }); 66249 } 66250 function DrillDownButton({ clientId }) { 66251 const blockTitle = useBlockDisplayTitle({ 66252 clientId, 66253 context: "list-view" 66254 }); 66255 const blockInformation = useBlockDisplayInformation(clientId); 66256 return /* @__PURE__ */ (0, import_jsx_runtime415.jsx)("div", { className: "block-editor-content-only-controls__button-panel", children: /* @__PURE__ */ (0, import_jsx_runtime415.jsx)( 66257 import_components238.Navigator.Button, 66258 { 66259 path: `/$clientId}`, 66260 className: "block-editor-content-only-controls__drill-down-button", 66261 children: /* @__PURE__ */ (0, import_jsx_runtime415.jsxs)(import_components238.__experimentalHStack, { expanded: true, justify: "space-between", children: [ 66262 /* @__PURE__ */ (0, import_jsx_runtime415.jsxs)(import_components238.__experimentalHStack, { justify: "flex-start", spacing: 1, children: [ 66263 /* @__PURE__ */ (0, import_jsx_runtime415.jsx)(block_icon_default, { icon: blockInformation?.icon }), 66264 /* @__PURE__ */ (0, import_jsx_runtime415.jsx)("div", { children: blockTitle }) 66265 ] }), 66266 /* @__PURE__ */ (0, import_jsx_runtime415.jsx)(import_components238.Icon, { icon: arrow_right_default }) 66267 ] }) 66268 } 66269 ) }); 66270 } 66271 function ContentOnlyControlsScreen({ 66272 rootClientId, 66273 contentClientIds, 66274 parentClientIds, 66275 isNested 66276 }) { 66277 const isRootContentBlock = (0, import_data168.useSelect)( 66278 (select3) => { 66279 const { getBlockName: getBlockName2 } = select3(store); 66280 const blockName = getBlockName2(rootClientId); 66281 const { hasContentRoleAttribute } = unlock(select3(import_blocks92.store)); 66282 return hasContentRoleAttribute(blockName); 66283 }, 66284 [rootClientId] 66285 ); 66286 if (!isRootContentBlock && !contentClientIds.length) { 66287 return null; 66288 } 66289 return /* @__PURE__ */ (0, import_jsx_runtime415.jsxs)(import_jsx_runtime415.Fragment, { children: [ 66290 isNested && /* @__PURE__ */ (0, import_jsx_runtime415.jsx)("div", { className: "block-editor-content-only-controls__button-panel", children: /* @__PURE__ */ (0, import_jsx_runtime415.jsx)(import_components238.Navigator.BackButton, { className: "block-editor-content-only-controls__back-button", children: /* @__PURE__ */ (0, import_jsx_runtime415.jsxs)(import_components238.__experimentalHStack, { expanded: true, spacing: 1, justify: "flex-start", children: [ 66291 /* @__PURE__ */ (0, import_jsx_runtime415.jsx)(import_components238.Icon, { icon: arrow_left_default }), 66292 /* @__PURE__ */ (0, import_jsx_runtime415.jsx)("div", { children: (0, import_i18n218.__)("Back") }) 66293 ] }) }) }), 66294 isRootContentBlock && /* @__PURE__ */ (0, import_jsx_runtime415.jsx)(BlockFields, { clientId: rootClientId }), 66295 contentClientIds.map((clientId) => { 66296 if (parentClientIds?.[clientId]) { 66297 return /* @__PURE__ */ (0, import_jsx_runtime415.jsx)( 66298 DrillDownButton, 66299 { 66300 clientId 66301 }, 66302 clientId 66303 ); 66304 } 66305 return /* @__PURE__ */ (0, import_jsx_runtime415.jsx)(BlockFields, { clientId }, clientId); 66306 }) 66307 ] }); 66308 } 66309 function ContentOnlyControls({ rootClientId }) { 66310 const { updatedRootClientId, nestedContentClientIds, contentClientIds } = (0, import_data168.useSelect)( 66311 (select3) => { 66312 const { getClientIdsOfDescendants: getClientIdsOfDescendants2, getBlockEditingMode: getBlockEditingMode2 } = select3(store); 66313 const _nestedContentClientIds = {}; 66314 const _contentClientIds = []; 66315 let allNestedClientIds = []; 66316 const allContentClientIds = getClientIdsOfDescendants2( 66317 rootClientId 66318 ).filter( 66319 (clientId) => getBlockEditingMode2(clientId) === "contentOnly" 66320 ); 66321 for (const clientId of allContentClientIds) { 66322 const childClientIds = getClientIdsOfDescendants2( 66323 clientId 66324 ).filter( 66325 (childClientId) => getBlockEditingMode2(childClientId) === "contentOnly" 66326 ); 66327 if (childClientIds.length > 1 && !allNestedClientIds.includes(clientId)) { 66328 _nestedContentClientIds[clientId] = childClientIds; 66329 allNestedClientIds = [ 66330 allNestedClientIds, 66331 ...childClientIds 66332 ]; 66333 } 66334 if (!allNestedClientIds.includes(clientId)) { 66335 _contentClientIds.push(clientId); 66336 } 66337 } 66338 if (_contentClientIds.length === 1 && Object.keys(_nestedContentClientIds).length === 1) { 66339 const onlyParentClientId = Object.keys( 66340 _nestedContentClientIds 66341 )[0]; 66342 return { 66343 updatedRootClientId: onlyParentClientId, 66344 contentClientIds: _nestedContentClientIds[onlyParentClientId], 66345 nestedContentClientIds: {} 66346 }; 66347 } 66348 return { 66349 nestedContentClientIds: _nestedContentClientIds, 66350 contentClientIds: _contentClientIds 66351 }; 66352 }, 66353 [rootClientId] 66354 ); 66355 return /* @__PURE__ */ (0, import_jsx_runtime415.jsxs)(import_components238.Navigator, { initialPath: "/", children: [ 66356 /* @__PURE__ */ (0, import_jsx_runtime415.jsx)( 66357 import_components238.Navigator.Screen, 66358 { 66359 path: "/", 66360 className: "block-editor-content-only-controls__screen", 66361 children: /* @__PURE__ */ (0, import_jsx_runtime415.jsx)( 66362 ContentOnlyControlsScreen, 66363 { 66364 rootClientId: updatedRootClientId ?? rootClientId, 66365 contentClientIds, 66366 parentClientIds: nestedContentClientIds 66367 } 66368 ) 66369 } 66370 ), 66371 Object.keys(nestedContentClientIds).map((clientId) => /* @__PURE__ */ (0, import_jsx_runtime415.jsx)( 66372 import_components238.Navigator.Screen, 66373 { 66374 path: `/$clientId}`, 66375 className: "block-editor-content-only-controls__screen", 66376 children: /* @__PURE__ */ (0, import_jsx_runtime415.jsx)( 66377 ContentOnlyControlsScreen, 66378 { 66379 isNested: true, 66380 rootClientId: clientId, 66381 contentClientIds: nestedContentClientIds[clientId] 66382 } 66383 ) 66384 }, 66385 clientId 66386 )) 66387 ] }); 66388 } 66389 66390 // packages/block-editor/build-module/components/inspector-controls-tabs/content-tab.js 66391 var import_jsx_runtime416 = __toESM(require_jsx_runtime()); 66392 var ContentTab = ({ rootClientId, contentClientIds }) => { 66393 if (!contentClientIds || contentClientIds.length === 0) { 66394 return null; 66395 } 66396 const shouldShowContentOnlyControls = window?.__experimentalContentOnlyPatternInsertion && window?.__experimentalContentOnlyInspectorFields; 66397 return /* @__PURE__ */ (0, import_jsx_runtime416.jsxs)(import_jsx_runtime416.Fragment, { children: [ 66398 !shouldShowContentOnlyControls && /* @__PURE__ */ (0, import_jsx_runtime416.jsx)(import_components239.PanelBody, { title: (0, import_i18n219.__)("Content"), children: /* @__PURE__ */ (0, import_jsx_runtime416.jsx)(BlockQuickNavigation, { clientIds: contentClientIds }) }), 66399 shouldShowContentOnlyControls && /* @__PURE__ */ (0, import_jsx_runtime416.jsx)(ContentOnlyControls, { rootClientId }) 66400 ] }); 66401 }; 66402 var content_tab_default = ContentTab; 66403 66404 // packages/block-editor/build-module/components/inspector-controls-tabs/use-is-list-view-tab-disabled.js 66405 var allowlist = ["core/navigation"]; 66406 var useIsListViewTabDisabled = (blockName) => { 66407 return !allowlist.includes(blockName); 66408 }; 66409 var use_is_list_view_tab_disabled_default = useIsListViewTabDisabled; 66410 66411 // packages/block-editor/build-module/components/inspector-controls-tabs/index.js 66412 var import_jsx_runtime417 = __toESM(require_jsx_runtime()); 66413 var { Tabs: Tabs5 } = unlock(import_components240.privateApis); 66414 function InspectorControlsTabs({ 66415 blockName, 66416 clientId, 66417 hasBlockStyles, 66418 tabs, 66419 isSectionBlock: isSectionBlock2, 66420 contentClientIds 66421 }) { 66422 const showIconLabels = (0, import_data169.useSelect)((select3) => { 66423 return select3(import_preferences5.store).get("core", "showIconLabels"); 66424 }, []); 66425 const initialTabName = !use_is_list_view_tab_disabled_default(blockName) ? TAB_LIST_VIEW.name : void 0; 66426 const [selectedTabId, setSelectedTabId] = (0, import_element241.useState)( 66427 initialTabName ?? tabs[0]?.name 66428 ); 66429 (0, import_element241.useEffect)(() => { 66430 if (initialTabName) { 66431 return; 66432 } 66433 if (tabs?.length && selectedTabId) { 66434 const activeTab = tabs.find( 66435 (tab) => tab.name === selectedTabId 66436 ); 66437 if (!activeTab) { 66438 setSelectedTabId(tabs[0].name); 66439 } 66440 } 66441 }, [tabs, selectedTabId, initialTabName]); 66442 return /* @__PURE__ */ (0, import_jsx_runtime417.jsx)("div", { className: "block-editor-block-inspector__tabs", children: /* @__PURE__ */ (0, import_jsx_runtime417.jsxs)( 66443 Tabs5, 66444 { 66445 defaultTabId: initialTabName, 66446 selectedTabId, 66447 onSelect: setSelectedTabId, 66448 children: [ 66449 /* @__PURE__ */ (0, import_jsx_runtime417.jsx)(Tabs5.TabList, { children: tabs.map( 66450 (tab) => showIconLabels ? /* @__PURE__ */ (0, import_jsx_runtime417.jsx)(Tabs5.Tab, { tabId: tab.name, children: tab.title }, tab.name) : /* @__PURE__ */ (0, import_jsx_runtime417.jsx)(import_components240.Tooltip, { text: tab.title, children: /* @__PURE__ */ (0, import_jsx_runtime417.jsx)( 66451 Tabs5.Tab, 66452 { 66453 tabId: tab.name, 66454 "aria-label": tab.title, 66455 children: /* @__PURE__ */ (0, import_jsx_runtime417.jsx)(import_components240.Icon, { icon: tab.icon }) 66456 } 66457 ) }, tab.name) 66458 ) }), 66459 /* @__PURE__ */ (0, import_jsx_runtime417.jsx)(Tabs5.TabPanel, { tabId: TAB_SETTINGS.name, focusable: false, children: /* @__PURE__ */ (0, import_jsx_runtime417.jsx)(settings_tab_default, { showAdvancedControls: !!blockName }) }), 66460 /* @__PURE__ */ (0, import_jsx_runtime417.jsx)(Tabs5.TabPanel, { tabId: TAB_STYLES.name, focusable: false, children: /* @__PURE__ */ (0, import_jsx_runtime417.jsx)( 66461 styles_tab_default, 66462 { 66463 blockName, 66464 clientId, 66465 hasBlockStyles, 66466 isSectionBlock: isSectionBlock2, 66467 contentClientIds 66468 } 66469 ) }), 66470 /* @__PURE__ */ (0, import_jsx_runtime417.jsx)(Tabs5.TabPanel, { tabId: TAB_CONTENT.name, focusable: false, children: /* @__PURE__ */ (0, import_jsx_runtime417.jsx)( 66471 content_tab_default, 66472 { 66473 rootClientId: clientId, 66474 contentClientIds 66475 } 66476 ) }), 66477 /* @__PURE__ */ (0, import_jsx_runtime417.jsx)(Tabs5.TabPanel, { tabId: TAB_LIST_VIEW.name, focusable: false, children: /* @__PURE__ */ (0, import_jsx_runtime417.jsx)(inspector_controls_default.Slot, { group: "list" }) }) 66478 ] 66479 }, 66480 clientId 66481 ) }); 66482 } 66483 66484 // packages/block-editor/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js 66485 var import_components241 = __toESM(require_components()); 66486 var import_data170 = __toESM(require_data()); 66487 var EMPTY_ARRAY15 = []; 66488 function getShowTabs(blockName, tabSettings = {}) { 66489 if (tabSettings[blockName] !== void 0) { 66490 return tabSettings[blockName]; 66491 } 66492 if (tabSettings.default !== void 0) { 66493 return tabSettings.default; 66494 } 66495 return true; 66496 } 66497 function useInspectorControlsTabs(blockName, contentClientIds, isSectionBlock2, hasBlockStyles) { 66498 const tabs = []; 66499 const { 66500 bindings: bindingsGroup, 66501 border: borderGroup, 66502 color: colorGroup, 66503 default: defaultGroup, 66504 dimensions: dimensionsGroup, 66505 list: listGroup, 66506 position: positionGroup, 66507 styles: stylesGroup, 66508 typography: typographyGroup, 66509 effects: effectsGroup 66510 } = groups_default; 66511 const listViewDisabled = use_is_list_view_tab_disabled_default(blockName); 66512 const listFills = (0, import_components241.__experimentalUseSlotFills)(listGroup.name); 66513 const hasListFills = !listViewDisabled && !!listFills && listFills.length; 66514 const styleFills = [ 66515 ...(0, import_components241.__experimentalUseSlotFills)(borderGroup.name) || [], 66516 ...(0, import_components241.__experimentalUseSlotFills)(colorGroup.name) || [], 66517 ...(0, import_components241.__experimentalUseSlotFills)(dimensionsGroup.name) || [], 66518 ...(0, import_components241.__experimentalUseSlotFills)(stylesGroup.name) || [], 66519 ...(0, import_components241.__experimentalUseSlotFills)(typographyGroup.name) || [], 66520 ...(0, import_components241.__experimentalUseSlotFills)(effectsGroup.name) || [] 66521 ]; 66522 const hasStyleFills = styleFills.length; 66523 const advancedFills = [ 66524 ...(0, import_components241.__experimentalUseSlotFills)(InspectorAdvancedControls.slotName) || [], 66525 ...(0, import_components241.__experimentalUseSlotFills)(bindingsGroup.name) || [] 66526 ]; 66527 const settingsFills = [ 66528 ...(0, import_components241.__experimentalUseSlotFills)(defaultGroup.name) || [], 66529 ...(0, import_components241.__experimentalUseSlotFills)(positionGroup.name) || [], 66530 ...hasListFills && hasStyleFills > 1 ? advancedFills : [] 66531 ]; 66532 const hasContentTab = !!(contentClientIds && contentClientIds.length > 0); 66533 if (hasListFills && !isSectionBlock2) { 66534 tabs.push(TAB_LIST_VIEW); 66535 } 66536 if (hasContentTab) { 66537 tabs.push(TAB_CONTENT); 66538 } 66539 if (settingsFills.length && !isSectionBlock2) { 66540 tabs.push(TAB_SETTINGS); 66541 } 66542 if (hasBlockStyles || hasStyleFills) { 66543 tabs.push(TAB_STYLES); 66544 } 66545 const tabSettings = (0, import_data170.useSelect)((select3) => { 66546 return select3(store).getSettings().blockInspectorTabs; 66547 }, []); 66548 const showTabs = getShowTabs(blockName, tabSettings); 66549 return showTabs ? tabs : EMPTY_ARRAY15; 66550 } 66551 66552 // packages/block-editor/build-module/components/block-inspector/useBlockInspectorAnimationSettings.js 66553 var import_data171 = __toESM(require_data()); 66554 function useBlockInspectorAnimationSettings(blockType) { 66555 return (0, import_data171.useSelect)( 66556 (select3) => { 66557 if (blockType) { 66558 const globalBlockInspectorAnimationSettings = select3(store).getSettings().blockInspectorAnimation; 66559 const animationParent = globalBlockInspectorAnimationSettings?.animationParent; 66560 const { getSelectedBlockClientId: getSelectedBlockClientId2, getBlockParentsByBlockName: getBlockParentsByBlockName2 } = select3(store); 66561 const _selectedBlockClientId = getSelectedBlockClientId2(); 66562 const animationParentBlockClientId = getBlockParentsByBlockName2( 66563 _selectedBlockClientId, 66564 animationParent, 66565 true 66566 )[0]; 66567 if (!animationParentBlockClientId && blockType.name !== animationParent) { 66568 return null; 66569 } 66570 return globalBlockInspectorAnimationSettings?.[blockType.name]; 66571 } 66572 return null; 66573 }, 66574 [blockType] 66575 ); 66576 } 66577 66578 // packages/block-editor/build-module/components/block-inspector/index.js 66579 var import_jsx_runtime418 = __toESM(require_jsx_runtime()); 66580 function BlockStylesPanel({ clientId }) { 66581 return /* @__PURE__ */ (0, import_jsx_runtime418.jsx)(import_components242.PanelBody, { title: (0, import_i18n220.__)("Styles"), children: /* @__PURE__ */ (0, import_jsx_runtime418.jsx)(block_styles_default, { clientId }) }); 66582 } 66583 function StyleInspectorSlots({ 66584 blockName, 66585 showAdvancedControls = true, 66586 showPositionControls = true, 66587 showListControls = false, 66588 showBindingsControls = true 66589 }) { 66590 const borderPanelLabel = useBorderPanelLabel({ blockName }); 66591 return /* @__PURE__ */ (0, import_jsx_runtime418.jsxs)(import_jsx_runtime418.Fragment, { children: [ 66592 /* @__PURE__ */ (0, import_jsx_runtime418.jsx)(inspector_controls_default.Slot, {}), 66593 showListControls && /* @__PURE__ */ (0, import_jsx_runtime418.jsx)(inspector_controls_default.Slot, { group: "list" }), 66594 /* @__PURE__ */ (0, import_jsx_runtime418.jsx)( 66595 inspector_controls_default.Slot, 66596 { 66597 group: "color", 66598 label: (0, import_i18n220.__)("Color"), 66599 className: "color-block-support-panel__inner-wrapper" 66600 } 66601 ), 66602 /* @__PURE__ */ (0, import_jsx_runtime418.jsx)( 66603 inspector_controls_default.Slot, 66604 { 66605 group: "background", 66606 label: (0, import_i18n220.__)("Background image") 66607 } 66608 ), 66609 /* @__PURE__ */ (0, import_jsx_runtime418.jsx)( 66610 inspector_controls_default.Slot, 66611 { 66612 group: "typography", 66613 label: (0, import_i18n220.__)("Typography") 66614 } 66615 ), 66616 /* @__PURE__ */ (0, import_jsx_runtime418.jsx)( 66617 inspector_controls_default.Slot, 66618 { 66619 group: "dimensions", 66620 label: (0, import_i18n220.__)("Dimensions") 66621 } 66622 ), 66623 /* @__PURE__ */ (0, import_jsx_runtime418.jsx)(inspector_controls_default.Slot, { group: "border", label: borderPanelLabel }), 66624 /* @__PURE__ */ (0, import_jsx_runtime418.jsx)(inspector_controls_default.Slot, { group: "styles" }), 66625 showPositionControls && /* @__PURE__ */ (0, import_jsx_runtime418.jsx)(position_controls_panel_default, {}), 66626 showBindingsControls && /* @__PURE__ */ (0, import_jsx_runtime418.jsx)(inspector_controls_default.Slot, { group: "bindings" }), 66627 showAdvancedControls && /* @__PURE__ */ (0, import_jsx_runtime418.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime418.jsx)(advanced_controls_panel_default, {}) }) 66628 ] }); 66629 } 66630 function BlockInspector() { 66631 const { 66632 selectedBlockCount, 66633 selectedBlockClientId, 66634 renderedBlockName, 66635 renderedBlockClientId, 66636 blockType, 66637 isSectionBlock: isSectionBlock2, 66638 isSectionBlockInSelection, 66639 hasBlockStyles, 66640 editedContentOnlySection: editedContentOnlySection2 66641 } = (0, import_data172.useSelect)((select3) => { 66642 const { 66643 getSelectedBlockClientId: getSelectedBlockClientId2, 66644 getSelectedBlockClientIds: getSelectedBlockClientIds2, 66645 getSelectedBlockCount: getSelectedBlockCount2, 66646 getBlockName: getBlockName2, 66647 getParentSectionBlock: getParentSectionBlock2, 66648 isSectionBlock: _isSectionBlock, 66649 getEditedContentOnlySection: getEditedContentOnlySection2, 66650 isWithinEditedContentOnlySection: isWithinEditedContentOnlySection2 66651 } = unlock(select3(store)); 66652 const { getBlockStyles: getBlockStyles2 } = select3(import_blocks93.store); 66653 const _selectedBlockClientId = getSelectedBlockClientId2(); 66654 const isWithinEditedSection = isWithinEditedContentOnlySection2( 66655 _selectedBlockClientId 66656 ); 66657 const _renderedBlockClientId = isWithinEditedSection ? _selectedBlockClientId : getParentSectionBlock2(_selectedBlockClientId) || _selectedBlockClientId; 66658 const _renderedBlockName = _renderedBlockClientId && getBlockName2(_renderedBlockClientId); 66659 const _blockType = _renderedBlockName && (0, import_blocks93.getBlockType)(_renderedBlockName); 66660 const selectedBlockClientIds = getSelectedBlockClientIds2(); 66661 const _isSectionBlockInSelection = selectedBlockClientIds.some( 66662 (id) => _isSectionBlock(id) 66663 ); 66664 const blockStyles = _renderedBlockName && getBlockStyles2(_renderedBlockName); 66665 const _hasBlockStyles = blockStyles && blockStyles.length > 0; 66666 return { 66667 selectedBlockCount: getSelectedBlockCount2(), 66668 selectedBlockClientId: _selectedBlockClientId, 66669 renderedBlockClientId: _renderedBlockClientId, 66670 renderedBlockName: _renderedBlockName, 66671 blockType: _blockType, 66672 isSectionBlockInSelection: _isSectionBlockInSelection, 66673 isSectionBlock: _isSectionBlock(_renderedBlockClientId), 66674 hasBlockStyles: _hasBlockStyles, 66675 editedContentOnlySection: getEditedContentOnlySection2() 66676 }; 66677 }, []); 66678 const contentClientIds = (0, import_data172.useSelect)( 66679 (select3) => { 66680 if (!isSectionBlock2 || !renderedBlockClientId) { 66681 return []; 66682 } 66683 const { 66684 getClientIdsOfDescendants: getClientIdsOfDescendants2, 66685 getBlockName: getBlockName2, 66686 getBlockEditingMode: getBlockEditingMode2 66687 } = unlock(select3(store)); 66688 const descendants = getClientIdsOfDescendants2( 66689 renderedBlockClientId 66690 ); 66691 const navigationDescendants = /* @__PURE__ */ new Set(); 66692 descendants.forEach((clientId) => { 66693 if (getBlockName2(clientId) === "core/navigation") { 66694 const navChildren = getClientIdsOfDescendants2(clientId); 66695 navChildren.forEach( 66696 (childId) => navigationDescendants.add(childId) 66697 ); 66698 } 66699 }); 66700 return descendants.filter((current) => { 66701 if (navigationDescendants.has(current)) { 66702 return false; 66703 } 66704 return getBlockName2(current) !== "core/list-item" && getBlockEditingMode2(current) === "contentOnly"; 66705 }); 66706 }, 66707 [isSectionBlock2, renderedBlockClientId] 66708 ); 66709 const availableTabs = useInspectorControlsTabs( 66710 blockType?.name, 66711 contentClientIds, 66712 isSectionBlock2, 66713 hasBlockStyles 66714 ); 66715 const hasMultipleTabs = availableTabs?.length > 1; 66716 const blockInspectorAnimationSettings = useBlockInspectorAnimationSettings(blockType); 66717 const hasSelectedBlocks = selectedBlockCount > 1; 66718 if (hasSelectedBlocks && !isSectionBlockInSelection) { 66719 return /* @__PURE__ */ (0, import_jsx_runtime418.jsxs)("div", { className: "block-editor-block-inspector", children: [ 66720 /* @__PURE__ */ (0, import_jsx_runtime418.jsx)(MultiSelectionInspector, {}), 66721 hasMultipleTabs ? /* @__PURE__ */ (0, import_jsx_runtime418.jsx)(InspectorControlsTabs, { tabs: availableTabs }) : /* @__PURE__ */ (0, import_jsx_runtime418.jsx)( 66722 StyleInspectorSlots, 66723 { 66724 blockName: renderedBlockName, 66725 showAdvancedControls: false, 66726 showPositionControls: false, 66727 showBindingsControls: false 66728 } 66729 ) 66730 ] }); 66731 } 66732 if (hasSelectedBlocks && isSectionBlockInSelection) { 66733 return /* @__PURE__ */ (0, import_jsx_runtime418.jsx)("div", { className: "block-editor-block-inspector", children: /* @__PURE__ */ (0, import_jsx_runtime418.jsx)(MultiSelectionInspector, {}) }); 66734 } 66735 const isRenderedBlockUnregistered = renderedBlockName === (0, import_blocks93.getUnregisteredTypeHandlerName)(); 66736 const shouldShowWarning = !blockType || !renderedBlockClientId || isRenderedBlockUnregistered; 66737 if (shouldShowWarning) { 66738 return /* @__PURE__ */ (0, import_jsx_runtime418.jsx)("span", { className: "block-editor-block-inspector__no-blocks", children: (0, import_i18n220.__)("No block selected.") }); 66739 } 66740 return /* @__PURE__ */ (0, import_jsx_runtime418.jsx)( 66741 BlockInspectorSingleBlockWrapper, 66742 { 66743 animate: blockInspectorAnimationSettings, 66744 wrapper: (children) => /* @__PURE__ */ (0, import_jsx_runtime418.jsx)( 66745 AnimatedContainer, 66746 { 66747 blockInspectorAnimationSettings, 66748 renderedBlockClientId, 66749 children 66750 } 66751 ), 66752 children: /* @__PURE__ */ (0, import_jsx_runtime418.jsx)( 66753 BlockInspectorSingleBlock, 66754 { 66755 renderedBlockClientId, 66756 selectedBlockClientId, 66757 blockName: blockType.name, 66758 isSectionBlock: isSectionBlock2, 66759 availableTabs, 66760 contentClientIds, 66761 hasBlockStyles, 66762 editedContentOnlySection: editedContentOnlySection2 66763 } 66764 ) 66765 } 66766 ); 66767 } 66768 var BlockInspectorSingleBlockWrapper = ({ animate, wrapper, children }) => { 66769 return animate ? wrapper(children) : children; 66770 }; 66771 var AnimatedContainer = ({ 66772 blockInspectorAnimationSettings, 66773 renderedBlockClientId, 66774 children 66775 }) => { 66776 const animationOrigin = blockInspectorAnimationSettings && blockInspectorAnimationSettings.enterDirection === "leftToRight" ? -50 : 50; 66777 return /* @__PURE__ */ (0, import_jsx_runtime418.jsx)( 66778 import_components242.__unstableMotion.div, 66779 { 66780 animate: { 66781 x: 0, 66782 opacity: 1, 66783 transition: { 66784 ease: "easeInOut", 66785 duration: 0.14 66786 } 66787 }, 66788 initial: { 66789 x: animationOrigin, 66790 opacity: 0 66791 }, 66792 children 66793 }, 66794 renderedBlockClientId 66795 ); 66796 }; 66797 var BlockInspectorSingleBlock = ({ 66798 // The block that is displayed in the inspector. This is the block whose 66799 // controls and information are shown to the user. 66800 renderedBlockClientId, 66801 // The actual block that is selected in the editor. This may or may not 66802 // be the same as the rendered block (e.g., when a child block is selected 66803 // but its parent section block is the main one rendered in the inspector). 66804 selectedBlockClientId, 66805 blockName, 66806 isSectionBlock: isSectionBlock2, 66807 availableTabs, 66808 contentClientIds, 66809 hasBlockStyles, 66810 editedContentOnlySection: editedContentOnlySection2 66811 }) => { 66812 const hasMultipleTabs = availableTabs?.length > 1; 66813 const hasParentChildBlockCards = window?.__experimentalContentOnlyPatternInsertion && editedContentOnlySection2 && editedContentOnlySection2 !== renderedBlockClientId; 66814 const parentBlockInformation = useBlockDisplayInformation( 66815 editedContentOnlySection2 66816 ); 66817 const blockInformation = useBlockDisplayInformation( 66818 renderedBlockClientId 66819 ); 66820 const isBlockSynced = blockInformation.isSynced; 66821 const shouldShowTabs = !isBlockSynced && hasMultipleTabs; 66822 const isSectionBlockSelected = window?.__experimentalContentOnlyPatternInsertion && selectedBlockClientId === renderedBlockClientId; 66823 return /* @__PURE__ */ (0, import_jsx_runtime418.jsxs)("div", { className: "block-editor-block-inspector", children: [ 66824 hasParentChildBlockCards && /* @__PURE__ */ (0, import_jsx_runtime418.jsx)( 66825 block_card_default, 66826 { 66827 ...parentBlockInformation, 66828 className: parentBlockInformation.isSynced && "is-synced", 66829 parentClientId: editedContentOnlySection2 66830 } 66831 ), 66832 /* @__PURE__ */ (0, import_jsx_runtime418.jsx)( 66833 block_card_default, 66834 { 66835 ...blockInformation, 66836 allowParentNavigation: true, 66837 className: isBlockSynced && "is-synced", 66838 isChild: hasParentChildBlockCards, 66839 clientId: renderedBlockClientId 66840 } 66841 ), 66842 window?.__experimentalContentOnlyPatternInsertion && /* @__PURE__ */ (0, import_jsx_runtime418.jsx)(EditContents, { clientId: renderedBlockClientId }), 66843 /* @__PURE__ */ (0, import_jsx_runtime418.jsx)(block_variation_transforms_default, { blockClientId: renderedBlockClientId }), 66844 shouldShowTabs && /* @__PURE__ */ (0, import_jsx_runtime418.jsx)( 66845 InspectorControlsTabs, 66846 { 66847 hasBlockStyles, 66848 clientId: renderedBlockClientId, 66849 blockName, 66850 tabs: availableTabs, 66851 isSectionBlock: isSectionBlock2, 66852 contentClientIds 66853 } 66854 ), 66855 !shouldShowTabs && /* @__PURE__ */ (0, import_jsx_runtime418.jsxs)(import_jsx_runtime418.Fragment, { children: [ 66856 hasBlockStyles && /* @__PURE__ */ (0, import_jsx_runtime418.jsx)(BlockStylesPanel, { clientId: renderedBlockClientId }), 66857 /* @__PURE__ */ (0, import_jsx_runtime418.jsx)( 66858 content_tab_default, 66859 { 66860 rootClientId: renderedBlockClientId, 66861 contentClientIds 66862 } 66863 ), 66864 !isSectionBlock2 && /* @__PURE__ */ (0, import_jsx_runtime418.jsx)( 66865 StyleInspectorSlots, 66866 { 66867 blockName, 66868 showListControls: true 66869 } 66870 ), 66871 isSectionBlock2 && isBlockSynced && isSectionBlockSelected && /* @__PURE__ */ (0, import_jsx_runtime418.jsxs)(import_jsx_runtime418.Fragment, { children: [ 66872 /* @__PURE__ */ (0, import_jsx_runtime418.jsx)(inspector_controls_default.Slot, {}), 66873 /* @__PURE__ */ (0, import_jsx_runtime418.jsx)(advanced_controls_panel_default, {}) 66874 ] }) 66875 ] }), 66876 /* @__PURE__ */ (0, import_jsx_runtime418.jsx)(SkipToSelectedBlock, {}, "back") 66877 ] }); 66878 }; 66879 var block_inspector_default = BlockInspector; 66880 66881 // packages/block-editor/build-module/components/copy-handler/index.js 66882 var import_deprecated32 = __toESM(require_deprecated()); 66883 var import_jsx_runtime419 = __toESM(require_jsx_runtime()); 66884 var __unstableUseClipboardHandler = () => { 66885 (0, import_deprecated32.default)("__unstableUseClipboardHandler", { 66886 alternative: "BlockCanvas or WritingFlow", 66887 since: "6.4", 66888 version: "6.7" 66889 }); 66890 return useClipboardHandler(); 66891 }; 66892 function CopyHandler(props) { 66893 (0, import_deprecated32.default)("CopyHandler", { 66894 alternative: "BlockCanvas or WritingFlow", 66895 since: "6.4", 66896 version: "6.7" 66897 }); 66898 return /* @__PURE__ */ (0, import_jsx_runtime419.jsx)("div", { ...props, ref: useClipboardHandler() }); 66899 } 66900 66901 // packages/block-editor/build-module/components/inserter/library.js 66902 var import_data173 = __toESM(require_data()); 66903 var import_element242 = __toESM(require_element()); 66904 var import_jsx_runtime420 = __toESM(require_jsx_runtime()); 66905 var noop19 = () => { 66906 }; 66907 function InserterLibrary({ 66908 rootClientId, 66909 clientId, 66910 isAppender, 66911 showInserterHelpPanel, 66912 showMostUsedBlocks = false, 66913 __experimentalInsertionIndex, 66914 __experimentalInitialTab, 66915 __experimentalInitialCategory, 66916 __experimentalFilterValue, 66917 onPatternCategorySelection, 66918 onSelect = noop19, 66919 shouldFocusBlock = false, 66920 onClose 66921 }, ref) { 66922 const { destinationRootClientId } = (0, import_data173.useSelect)( 66923 (select3) => { 66924 const { getBlockRootClientId: getBlockRootClientId2 } = select3(store); 66925 const _rootClientId = rootClientId || getBlockRootClientId2(clientId) || void 0; 66926 return { 66927 destinationRootClientId: _rootClientId 66928 }; 66929 }, 66930 [clientId, rootClientId] 66931 ); 66932 return /* @__PURE__ */ (0, import_jsx_runtime420.jsx)( 66933 PrivateInserterMenu, 66934 { 66935 onSelect, 66936 rootClientId: destinationRootClientId, 66937 clientId, 66938 isAppender, 66939 showInserterHelpPanel, 66940 showMostUsedBlocks, 66941 __experimentalInsertionIndex, 66942 __experimentalFilterValue, 66943 onPatternCategorySelection, 66944 __experimentalInitialTab, 66945 __experimentalInitialCategory, 66946 shouldFocusBlock, 66947 ref, 66948 onClose 66949 } 66950 ); 66951 } 66952 var PrivateInserterLibrary = (0, import_element242.forwardRef)(InserterLibrary); 66953 function PublicInserterLibrary(props, ref) { 66954 return /* @__PURE__ */ (0, import_jsx_runtime420.jsx)( 66955 PrivateInserterLibrary, 66956 { 66957 ...props, 66958 onPatternCategorySelection: void 0, 66959 ref 66960 } 66961 ); 66962 } 66963 var library_default = (0, import_element242.forwardRef)(PublicInserterLibrary); 66964 66965 // packages/block-editor/build-module/components/selection-scroll-into-view/index.js 66966 var import_deprecated33 = __toESM(require_deprecated()); 66967 function MultiSelectScrollIntoView() { 66968 (0, import_deprecated33.default)("wp.blockEditor.MultiSelectScrollIntoView", { 66969 hint: "This behaviour is now built-in.", 66970 since: "5.8" 66971 }); 66972 return null; 66973 } 66974 66975 // packages/block-editor/build-module/components/typewriter/index.js 66976 var import_compose93 = __toESM(require_compose()); 66977 var import_dom39 = __toESM(require_dom()); 66978 var import_data174 = __toESM(require_data()); 66979 var import_keycodes26 = __toESM(require_keycodes()); 66980 var import_jsx_runtime421 = __toESM(require_jsx_runtime()); 66981 var isIE = window.navigator.userAgent.indexOf("Trident") !== -1; 66982 var arrowKeyCodes = /* @__PURE__ */ new Set([import_keycodes26.UP, import_keycodes26.DOWN, import_keycodes26.LEFT, import_keycodes26.RIGHT]); 66983 var initialTriggerPercentage = 0.75; 66984 function useTypewriter() { 66985 const hasSelectedBlock2 = (0, import_data174.useSelect)( 66986 (select3) => select3(store).hasSelectedBlock(), 66987 [] 66988 ); 66989 return (0, import_compose93.useRefEffect)( 66990 (node) => { 66991 if (!hasSelectedBlock2) { 66992 return; 66993 } 66994 const { ownerDocument } = node; 66995 const { defaultView } = ownerDocument; 66996 let scrollResizeRafId; 66997 let onKeyDownRafId; 66998 let caretRect; 66999 function onScrollResize() { 67000 if (scrollResizeRafId) { 67001 return; 67002 } 67003 scrollResizeRafId = defaultView.requestAnimationFrame(() => { 67004 computeCaretRectangle(); 67005 scrollResizeRafId = null; 67006 }); 67007 } 67008 function onKeyDown(event) { 67009 if (onKeyDownRafId) { 67010 defaultView.cancelAnimationFrame(onKeyDownRafId); 67011 } 67012 onKeyDownRafId = defaultView.requestAnimationFrame(() => { 67013 maintainCaretPosition(event); 67014 onKeyDownRafId = null; 67015 }); 67016 } 67017 function maintainCaretPosition({ keyCode }) { 67018 if (!isSelectionEligibleForScroll()) { 67019 return; 67020 } 67021 const currentCaretRect = (0, import_dom39.computeCaretRect)(defaultView); 67022 if (!currentCaretRect) { 67023 return; 67024 } 67025 if (!caretRect) { 67026 caretRect = currentCaretRect; 67027 return; 67028 } 67029 if (arrowKeyCodes.has(keyCode)) { 67030 caretRect = currentCaretRect; 67031 return; 67032 } 67033 const diff = currentCaretRect.top - caretRect.top; 67034 if (diff === 0) { 67035 return; 67036 } 67037 const scrollContainer = (0, import_dom39.getScrollContainer)(node); 67038 if (!scrollContainer) { 67039 return; 67040 } 67041 const windowScroll = scrollContainer === ownerDocument.body || scrollContainer === ownerDocument.documentElement; 67042 const scrollY = windowScroll ? defaultView.scrollY : scrollContainer.scrollTop; 67043 const scrollContainerY = windowScroll ? 0 : scrollContainer.getBoundingClientRect().top; 67044 const relativeScrollPosition = windowScroll ? caretRect.top / defaultView.innerHeight : (caretRect.top - scrollContainerY) / (defaultView.innerHeight - scrollContainerY); 67045 if (scrollY === 0 && relativeScrollPosition < initialTriggerPercentage && isLastEditableNode()) { 67046 caretRect = currentCaretRect; 67047 return; 67048 } 67049 const scrollContainerHeight = windowScroll ? defaultView.innerHeight : scrollContainer.clientHeight; 67050 if ( 67051 // The caret is under the lower fold. 67052 caretRect.top + caretRect.height > scrollContainerY + scrollContainerHeight || // The caret is above the upper fold. 67053 caretRect.top < scrollContainerY 67054 ) { 67055 caretRect = currentCaretRect; 67056 return; 67057 } 67058 if (windowScroll) { 67059 defaultView.scrollBy(0, diff); 67060 } else { 67061 scrollContainer.scrollTop += diff; 67062 } 67063 } 67064 function addSelectionChangeListener() { 67065 ownerDocument.addEventListener( 67066 "selectionchange", 67067 computeCaretRectOnSelectionChange 67068 ); 67069 } 67070 function computeCaretRectOnSelectionChange() { 67071 ownerDocument.removeEventListener( 67072 "selectionchange", 67073 computeCaretRectOnSelectionChange 67074 ); 67075 computeCaretRectangle(); 67076 } 67077 function computeCaretRectangle() { 67078 if (isSelectionEligibleForScroll()) { 67079 caretRect = (0, import_dom39.computeCaretRect)(defaultView); 67080 } 67081 } 67082 function isSelectionEligibleForScroll() { 67083 return node.contains(ownerDocument.activeElement) && ownerDocument.activeElement.isContentEditable; 67084 } 67085 function isLastEditableNode() { 67086 const editableNodes = node.querySelectorAll( 67087 '[contenteditable="true"]' 67088 ); 67089 const lastEditableNode = editableNodes[editableNodes.length - 1]; 67090 return lastEditableNode === ownerDocument.activeElement; 67091 } 67092 defaultView.addEventListener("scroll", onScrollResize, true); 67093 defaultView.addEventListener("resize", onScrollResize, true); 67094 node.addEventListener("keydown", onKeyDown); 67095 node.addEventListener("keyup", maintainCaretPosition); 67096 node.addEventListener("mousedown", addSelectionChangeListener); 67097 node.addEventListener("touchstart", addSelectionChangeListener); 67098 return () => { 67099 defaultView.removeEventListener( 67100 "scroll", 67101 onScrollResize, 67102 true 67103 ); 67104 defaultView.removeEventListener( 67105 "resize", 67106 onScrollResize, 67107 true 67108 ); 67109 node.removeEventListener("keydown", onKeyDown); 67110 node.removeEventListener("keyup", maintainCaretPosition); 67111 node.removeEventListener( 67112 "mousedown", 67113 addSelectionChangeListener 67114 ); 67115 node.removeEventListener( 67116 "touchstart", 67117 addSelectionChangeListener 67118 ); 67119 ownerDocument.removeEventListener( 67120 "selectionchange", 67121 computeCaretRectOnSelectionChange 67122 ); 67123 defaultView.cancelAnimationFrame(scrollResizeRafId); 67124 defaultView.cancelAnimationFrame(onKeyDownRafId); 67125 }; 67126 }, 67127 [hasSelectedBlock2] 67128 ); 67129 } 67130 function Typewriter({ children }) { 67131 return /* @__PURE__ */ (0, import_jsx_runtime421.jsx)("div", { ref: useTypewriter(), className: "block-editor__typewriter", children }); 67132 } 67133 var TypewriterOrIEBypass = isIE ? (props) => props.children : Typewriter; 67134 var typewriter_default = TypewriterOrIEBypass; 67135 67136 // packages/block-editor/build-module/components/recursion-provider/index.js 67137 var import_element243 = __toESM(require_element()); 67138 var import_deprecated34 = __toESM(require_deprecated()); 67139 var import_jsx_runtime422 = __toESM(require_jsx_runtime()); 67140 var RenderedRefsContext = (0, import_element243.createContext)({}); 67141 RenderedRefsContext.displayName = "RenderedRefsContext"; 67142 function addToBlockType(renderedBlocks, blockName, uniqueId2) { 67143 const result = { 67144 ...renderedBlocks, 67145 [blockName]: renderedBlocks[blockName] ? new Set(renderedBlocks[blockName]) : /* @__PURE__ */ new Set() 67146 }; 67147 result[blockName].add(uniqueId2); 67148 return result; 67149 } 67150 function RecursionProvider({ children, uniqueId: uniqueId2, blockName = "" }) { 67151 const previouslyRenderedBlocks = (0, import_element243.useContext)(RenderedRefsContext); 67152 const { name } = useBlockEditContext(); 67153 blockName = blockName || name; 67154 const newRenderedBlocks = (0, import_element243.useMemo)( 67155 () => addToBlockType(previouslyRenderedBlocks, blockName, uniqueId2), 67156 [previouslyRenderedBlocks, blockName, uniqueId2] 67157 ); 67158 return /* @__PURE__ */ (0, import_jsx_runtime422.jsx)(RenderedRefsContext.Provider, { value: newRenderedBlocks, children }); 67159 } 67160 function useHasRecursion(uniqueId2, blockName = "") { 67161 const previouslyRenderedBlocks = (0, import_element243.useContext)(RenderedRefsContext); 67162 const { name } = useBlockEditContext(); 67163 blockName = blockName || name; 67164 return Boolean(previouslyRenderedBlocks[blockName]?.has(uniqueId2)); 67165 } 67166 var DeprecatedExperimentalRecursionProvider = (props) => { 67167 (0, import_deprecated34.default)("wp.blockEditor.__experimentalRecursionProvider", { 67168 since: "6.5", 67169 alternative: "wp.blockEditor.RecursionProvider" 67170 }); 67171 return /* @__PURE__ */ (0, import_jsx_runtime422.jsx)(RecursionProvider, { ...props }); 67172 }; 67173 var DeprecatedExperimentalUseHasRecursion = (...args) => { 67174 (0, import_deprecated34.default)("wp.blockEditor.__experimentalUseHasRecursion", { 67175 since: "6.5", 67176 alternative: "wp.blockEditor.useHasRecursion" 67177 }); 67178 return useHasRecursion(...args); 67179 }; 67180 67181 // packages/block-editor/build-module/components/publish-date-time-picker/index.js 67182 var import_components244 = __toESM(require_components()); 67183 var import_i18n222 = __toESM(require_i18n()); 67184 var import_element244 = __toESM(require_element()); 67185 var import_date9 = __toESM(require_date()); 67186 67187 // packages/block-editor/build-module/components/inspector-popover-header/index.js 67188 var import_components243 = __toESM(require_components()); 67189 var import_i18n221 = __toESM(require_i18n()); 67190 var import_jsx_runtime423 = __toESM(require_jsx_runtime()); 67191 function InspectorPopoverHeader({ 67192 title, 67193 help, 67194 actions = [], 67195 onClose 67196 }) { 67197 return /* @__PURE__ */ (0, import_jsx_runtime423.jsxs)(import_components243.__experimentalVStack, { className: "block-editor-inspector-popover-header", spacing: 4, children: [ 67198 /* @__PURE__ */ (0, import_jsx_runtime423.jsxs)(import_components243.__experimentalHStack, { alignment: "center", children: [ 67199 /* @__PURE__ */ (0, import_jsx_runtime423.jsx)( 67200 import_components243.__experimentalHeading, 67201 { 67202 className: "block-editor-inspector-popover-header__heading", 67203 level: 2, 67204 size: 13, 67205 children: title 67206 } 67207 ), 67208 /* @__PURE__ */ (0, import_jsx_runtime423.jsx)(import_components243.__experimentalSpacer, {}), 67209 actions.map(({ label, icon, onClick }) => /* @__PURE__ */ (0, import_jsx_runtime423.jsx)( 67210 import_components243.Button, 67211 { 67212 size: "small", 67213 className: "block-editor-inspector-popover-header__action", 67214 label, 67215 icon, 67216 variant: !icon && "tertiary", 67217 onClick, 67218 children: !icon && label 67219 }, 67220 label 67221 )), 67222 onClose && /* @__PURE__ */ (0, import_jsx_runtime423.jsx)( 67223 import_components243.Button, 67224 { 67225 size: "small", 67226 className: "block-editor-inspector-popover-header__action", 67227 label: (0, import_i18n221.__)("Close"), 67228 icon: close_small_default, 67229 onClick: onClose 67230 } 67231 ) 67232 ] }), 67233 help && /* @__PURE__ */ (0, import_jsx_runtime423.jsx)(import_components243.__experimentalText, { children: help }) 67234 ] }); 67235 } 67236 67237 // packages/block-editor/build-module/components/publish-date-time-picker/index.js 67238 var import_jsx_runtime424 = __toESM(require_jsx_runtime()); 67239 function PublishDateTimePicker({ 67240 onClose, 67241 onChange, 67242 showPopoverHeaderActions, 67243 isCompact, 67244 currentDate, 67245 title, 67246 ...additionalProps 67247 }, ref) { 67248 const datePickerProps = { 67249 startOfWeek: (0, import_date9.getSettings)().l10n.startOfWeek, 67250 onChange, 67251 currentDate: isCompact ? void 0 : currentDate, 67252 currentTime: isCompact ? currentDate : void 0, 67253 ...additionalProps 67254 }; 67255 const DatePickerComponent = isCompact ? import_components244.TimePicker : import_components244.DateTimePicker; 67256 return /* @__PURE__ */ (0, import_jsx_runtime424.jsxs)("div", { ref, className: "block-editor-publish-date-time-picker", children: [ 67257 /* @__PURE__ */ (0, import_jsx_runtime424.jsx)( 67258 InspectorPopoverHeader, 67259 { 67260 title: title || (0, import_i18n222.__)("Publish"), 67261 actions: showPopoverHeaderActions ? [ 67262 { 67263 label: (0, import_i18n222.__)("Now"), 67264 onClick: () => onChange?.(null) 67265 } 67266 ] : void 0, 67267 onClose 67268 } 67269 ), 67270 /* @__PURE__ */ (0, import_jsx_runtime424.jsx)(DatePickerComponent, { ...datePickerProps }) 67271 ] }); 67272 } 67273 var PrivatePublishDateTimePicker = (0, import_element244.forwardRef)(PublishDateTimePicker); 67274 function PublicPublishDateTimePicker(props, ref) { 67275 return /* @__PURE__ */ (0, import_jsx_runtime424.jsx)( 67276 PrivatePublishDateTimePicker, 67277 { 67278 ...props, 67279 showPopoverHeaderActions: true, 67280 isCompact: false, 67281 ref 67282 } 67283 ); 67284 } 67285 var publish_date_time_picker_default = (0, import_element244.forwardRef)(PublicPublishDateTimePicker); 67286 67287 // packages/block-editor/build-module/components/block-editing-mode/index.js 67288 var import_data175 = __toESM(require_data()); 67289 var import_element245 = __toESM(require_element()); 67290 function useBlockEditingMode(mode2) { 67291 const context = useBlockEditContext(); 67292 const { clientId = "" } = context; 67293 const { setBlockEditingMode: setBlockEditingMode2, unsetBlockEditingMode: unsetBlockEditingMode2 } = (0, import_data175.useDispatch)(store); 67294 const globalBlockEditingMode = (0, import_data175.useSelect)( 67295 (select3) => ( 67296 // Avoid adding the subscription if not needed! 67297 clientId ? null : select3(store).getBlockEditingMode() 67298 ), 67299 [clientId] 67300 ); 67301 (0, import_element245.useEffect)(() => { 67302 if (mode2) { 67303 setBlockEditingMode2(clientId, mode2); 67304 } 67305 return () => { 67306 if (mode2) { 67307 unsetBlockEditingMode2(clientId); 67308 } 67309 }; 67310 }, [clientId, mode2, setBlockEditingMode2, unsetBlockEditingMode2]); 67311 return clientId ? context[blockEditingModeKey] : globalBlockEditingMode; 67312 } 67313 67314 // packages/block-editor/build-module/components/tool-selector/index.js 67315 var import_deprecated35 = __toESM(require_deprecated()); 67316 var import_element246 = __toESM(require_element()); 67317 function ToolSelector() { 67318 (0, import_deprecated35.default)("wp.blockEditor.ToolSelector", { 67319 since: "6.9", 67320 hint: "The ToolSelector component no longer renders anything." 67321 }); 67322 return null; 67323 } 67324 var tool_selector_default = (0, import_element246.forwardRef)(ToolSelector); 67325 67326 // packages/block-editor/build-module/hooks/utils.js 67327 var import_jsx_runtime425 = __toESM(require_jsx_runtime()); 67328 var cleanEmptyObject = (object) => { 67329 if (object === null || typeof object !== "object" || Array.isArray(object)) { 67330 return object; 67331 } 67332 const cleanedNestedObjects = Object.entries(object).map(([key, value]) => [key, cleanEmptyObject(value)]).filter(([, value]) => value !== void 0); 67333 return !cleanedNestedObjects.length ? void 0 : Object.fromEntries(cleanedNestedObjects); 67334 }; 67335 function transformStyles2(activeSupports, migrationPaths, result, source, index, results) { 67336 if (Object.values(activeSupports ?? {}).every( 67337 (isActive) => !isActive 67338 )) { 67339 return result; 67340 } 67341 if (results.length === 1 && result.innerBlocks.length === source.length) { 67342 return result; 67343 } 67344 let referenceBlockAttributes = source[0]?.attributes; 67345 if (results.length > 1 && source.length > 1) { 67346 if (source[index]) { 67347 referenceBlockAttributes = source[index]?.attributes; 67348 } else { 67349 return result; 67350 } 67351 } 67352 let returnBlock = result; 67353 Object.entries(activeSupports).forEach(([support, isActive]) => { 67354 if (isActive) { 67355 migrationPaths[support].forEach((path) => { 67356 const styleValue = getValueFromObjectPath( 67357 referenceBlockAttributes, 67358 path 67359 ); 67360 if (styleValue) { 67361 returnBlock = { 67362 ...returnBlock, 67363 attributes: setImmutably( 67364 returnBlock.attributes, 67365 path, 67366 styleValue 67367 ) 67368 }; 67369 } 67370 }); 67371 } 67372 }); 67373 return returnBlock; 67374 } 67375 function shouldSkipSerialization(blockNameOrType, featureSet, feature) { 67376 const support = (0, import_blocks94.getBlockSupport)(blockNameOrType, featureSet); 67377 const skipSerialization = support?.__experimentalSkipSerialization; 67378 if (Array.isArray(skipSerialization)) { 67379 return skipSerialization.includes(feature); 67380 } 67381 return skipSerialization; 67382 } 67383 var pendingStyleOverrides = /* @__PURE__ */ new WeakMap(); 67384 function useStyleOverride({ id, css }) { 67385 return usePrivateStyleOverride({ id, css }); 67386 } 67387 function usePrivateStyleOverride({ 67388 id, 67389 css, 67390 assets, 67391 __unstableType, 67392 variation, 67393 clientId 67394 } = {}) { 67395 const { setStyleOverride: setStyleOverride2, deleteStyleOverride: deleteStyleOverride2 } = unlock( 67396 (0, import_data176.useDispatch)(store) 67397 ); 67398 const registry = (0, import_data176.useRegistry)(); 67399 const fallbackId = (0, import_element247.useId)(); 67400 (0, import_element247.useEffect)(() => { 67401 if (!css && !assets) { 67402 return; 67403 } 67404 const _id = id || fallbackId; 67405 const override = { 67406 id, 67407 css, 67408 assets, 67409 __unstableType, 67410 variation, 67411 clientId 67412 }; 67413 if (!pendingStyleOverrides.get(registry)) { 67414 pendingStyleOverrides.set(registry, []); 67415 } 67416 pendingStyleOverrides.get(registry).push([_id, override]); 67417 window.queueMicrotask(() => { 67418 if (pendingStyleOverrides.get(registry)?.length) { 67419 registry.batch(() => { 67420 pendingStyleOverrides.get(registry).forEach((args) => { 67421 setStyleOverride2(...args); 67422 }); 67423 pendingStyleOverrides.set(registry, []); 67424 }); 67425 } 67426 }); 67427 return () => { 67428 const isPending = pendingStyleOverrides.get(registry)?.find(([currentId]) => currentId === _id); 67429 if (isPending) { 67430 pendingStyleOverrides.set( 67431 registry, 67432 pendingStyleOverrides.get(registry).filter(([currentId]) => currentId !== _id) 67433 ); 67434 } else { 67435 deleteStyleOverride2(_id); 67436 } 67437 }; 67438 }, [ 67439 id, 67440 css, 67441 clientId, 67442 assets, 67443 __unstableType, 67444 fallbackId, 67445 setStyleOverride2, 67446 deleteStyleOverride2, 67447 registry, 67448 variation 67449 ]); 67450 } 67451 function useBlockSettings(name, parentLayout) { 67452 const [ 67453 backgroundImage, 67454 backgroundSize, 67455 customFontFamilies, 67456 defaultFontFamilies, 67457 themeFontFamilies, 67458 defaultFontSizesEnabled, 67459 customFontSizes, 67460 defaultFontSizes, 67461 themeFontSizes, 67462 customFontSize, 67463 fontStyle, 67464 fontWeight, 67465 lineHeight, 67466 textAlign, 67467 textColumns, 67468 textDecoration, 67469 writingMode, 67470 textTransform, 67471 letterSpacing, 67472 padding, 67473 margin, 67474 blockGap, 67475 defaultSpacingSizesEnabled, 67476 customSpacingSize, 67477 userSpacingSizes, 67478 defaultSpacingSizes, 67479 themeSpacingSizes, 67480 units2, 67481 aspectRatio, 67482 height, 67483 minHeight, 67484 width, 67485 dimensionSizes, 67486 layout, 67487 borderColor, 67488 borderRadius, 67489 borderStyle, 67490 borderWidth, 67491 borderRadiusSizes, 67492 customColorsEnabled, 67493 customColors, 67494 customDuotone, 67495 themeColors, 67496 defaultColors, 67497 defaultPalette, 67498 defaultDuotone, 67499 userDuotonePalette, 67500 themeDuotonePalette, 67501 defaultDuotonePalette, 67502 userGradientPalette, 67503 themeGradientPalette, 67504 defaultGradientPalette, 67505 defaultGradients, 67506 areCustomGradientsEnabled, 67507 isBackgroundEnabled, 67508 isLinkEnabled, 67509 isTextEnabled, 67510 isHeadingEnabled, 67511 isButtonEnabled, 67512 shadow 67513 ] = useSettings( 67514 "background.backgroundImage", 67515 "background.backgroundSize", 67516 "typography.fontFamilies.custom", 67517 "typography.fontFamilies.default", 67518 "typography.fontFamilies.theme", 67519 "typography.defaultFontSizes", 67520 "typography.fontSizes.custom", 67521 "typography.fontSizes.default", 67522 "typography.fontSizes.theme", 67523 "typography.customFontSize", 67524 "typography.fontStyle", 67525 "typography.fontWeight", 67526 "typography.lineHeight", 67527 "typography.textAlign", 67528 "typography.textColumns", 67529 "typography.textDecoration", 67530 "typography.writingMode", 67531 "typography.textTransform", 67532 "typography.letterSpacing", 67533 "spacing.padding", 67534 "spacing.margin", 67535 "spacing.blockGap", 67536 "spacing.defaultSpacingSizes", 67537 "spacing.customSpacingSize", 67538 "spacing.spacingSizes.custom", 67539 "spacing.spacingSizes.default", 67540 "spacing.spacingSizes.theme", 67541 "spacing.units", 67542 "dimensions.aspectRatio", 67543 "dimensions.height", 67544 "dimensions.minHeight", 67545 "dimensions.width", 67546 "dimensions.dimensionSizes", 67547 "layout", 67548 "border.color", 67549 "border.radius", 67550 "border.style", 67551 "border.width", 67552 "border.radiusSizes", 67553 "color.custom", 67554 "color.palette.custom", 67555 "color.customDuotone", 67556 "color.palette.theme", 67557 "color.palette.default", 67558 "color.defaultPalette", 67559 "color.defaultDuotone", 67560 "color.duotone.custom", 67561 "color.duotone.theme", 67562 "color.duotone.default", 67563 "color.gradients.custom", 67564 "color.gradients.theme", 67565 "color.gradients.default", 67566 "color.defaultGradients", 67567 "color.customGradient", 67568 "color.background", 67569 "color.link", 67570 "color.text", 67571 "color.heading", 67572 "color.button", 67573 "shadow" 67574 ); 67575 const rawSettings = (0, import_element247.useMemo)(() => { 67576 return { 67577 background: { 67578 backgroundImage, 67579 backgroundSize 67580 }, 67581 color: { 67582 palette: { 67583 custom: customColors, 67584 theme: themeColors, 67585 default: defaultColors 67586 }, 67587 gradients: { 67588 custom: userGradientPalette, 67589 theme: themeGradientPalette, 67590 default: defaultGradientPalette 67591 }, 67592 duotone: { 67593 custom: userDuotonePalette, 67594 theme: themeDuotonePalette, 67595 default: defaultDuotonePalette 67596 }, 67597 defaultGradients, 67598 defaultPalette, 67599 defaultDuotone, 67600 custom: customColorsEnabled, 67601 customGradient: areCustomGradientsEnabled, 67602 customDuotone, 67603 background: isBackgroundEnabled, 67604 link: isLinkEnabled, 67605 heading: isHeadingEnabled, 67606 button: isButtonEnabled, 67607 text: isTextEnabled 67608 }, 67609 typography: { 67610 fontFamilies: { 67611 custom: customFontFamilies, 67612 default: defaultFontFamilies, 67613 theme: themeFontFamilies 67614 }, 67615 fontSizes: { 67616 custom: customFontSizes, 67617 default: defaultFontSizes, 67618 theme: themeFontSizes 67619 }, 67620 customFontSize, 67621 defaultFontSizes: defaultFontSizesEnabled, 67622 fontStyle, 67623 fontWeight, 67624 lineHeight, 67625 textAlign, 67626 textColumns, 67627 textDecoration, 67628 textTransform, 67629 letterSpacing, 67630 writingMode 67631 }, 67632 spacing: { 67633 spacingSizes: { 67634 custom: userSpacingSizes, 67635 default: defaultSpacingSizes, 67636 theme: themeSpacingSizes 67637 }, 67638 customSpacingSize, 67639 defaultSpacingSizes: defaultSpacingSizesEnabled, 67640 padding, 67641 margin, 67642 blockGap, 67643 units: units2 67644 }, 67645 border: { 67646 color: borderColor, 67647 radius: borderRadius, 67648 style: borderStyle, 67649 width: borderWidth, 67650 radiusSizes: borderRadiusSizes 67651 }, 67652 dimensions: { 67653 aspectRatio, 67654 height, 67655 minHeight, 67656 width, 67657 dimensionSizes 67658 }, 67659 layout, 67660 parentLayout, 67661 shadow 67662 }; 67663 }, [ 67664 backgroundImage, 67665 backgroundSize, 67666 customFontFamilies, 67667 defaultFontFamilies, 67668 themeFontFamilies, 67669 defaultFontSizesEnabled, 67670 customFontSizes, 67671 defaultFontSizes, 67672 themeFontSizes, 67673 customFontSize, 67674 fontStyle, 67675 fontWeight, 67676 lineHeight, 67677 textAlign, 67678 textColumns, 67679 textDecoration, 67680 textTransform, 67681 letterSpacing, 67682 writingMode, 67683 padding, 67684 margin, 67685 blockGap, 67686 defaultSpacingSizesEnabled, 67687 customSpacingSize, 67688 userSpacingSizes, 67689 defaultSpacingSizes, 67690 themeSpacingSizes, 67691 units2, 67692 aspectRatio, 67693 height, 67694 minHeight, 67695 width, 67696 dimensionSizes, 67697 layout, 67698 parentLayout, 67699 borderColor, 67700 borderRadius, 67701 borderStyle, 67702 borderWidth, 67703 borderRadiusSizes, 67704 customColorsEnabled, 67705 customColors, 67706 customDuotone, 67707 themeColors, 67708 defaultColors, 67709 defaultPalette, 67710 defaultDuotone, 67711 userDuotonePalette, 67712 themeDuotonePalette, 67713 defaultDuotonePalette, 67714 userGradientPalette, 67715 themeGradientPalette, 67716 defaultGradientPalette, 67717 defaultGradients, 67718 areCustomGradientsEnabled, 67719 isBackgroundEnabled, 67720 isLinkEnabled, 67721 isTextEnabled, 67722 isHeadingEnabled, 67723 isButtonEnabled, 67724 shadow 67725 ]); 67726 return useSettingsForBlockElement(rawSettings, name); 67727 } 67728 function createBlockEditFilter(features) { 67729 features = features.map((settings2) => { 67730 return { ...settings2, Edit: (0, import_element247.memo)(settings2.edit) }; 67731 }); 67732 const withBlockEditHooks = (0, import_compose94.createHigherOrderComponent)( 67733 (OriginalBlockEdit) => (props) => { 67734 const context = useBlockEditContext(); 67735 return [ 67736 ...features.map((feature, i2) => { 67737 const { 67738 Edit: Edit4, 67739 hasSupport, 67740 attributeKeys = [], 67741 shareWithChildBlocks 67742 } = feature; 67743 const shouldDisplayControls = context[mayDisplayControlsKey] || context[mayDisplayParentControlsKey] && shareWithChildBlocks; 67744 if (!shouldDisplayControls || !hasSupport(props.name)) { 67745 return null; 67746 } 67747 const neededProps = {}; 67748 for (const key of attributeKeys) { 67749 if (props.attributes[key]) { 67750 neededProps[key] = props.attributes[key]; 67751 } 67752 } 67753 return /* @__PURE__ */ (0, import_jsx_runtime425.jsx)( 67754 Edit4, 67755 { 67756 name: props.name, 67757 isSelected: props.isSelected, 67758 clientId: props.clientId, 67759 setAttributes: props.setAttributes, 67760 __unstableParentLayout: props.__unstableParentLayout, 67761 ...neededProps 67762 }, 67763 i2 67764 ); 67765 }), 67766 /* @__PURE__ */ (0, import_jsx_runtime425.jsx)(OriginalBlockEdit, { ...props }, "edit") 67767 ]; 67768 }, 67769 "withBlockEditHooks" 67770 ); 67771 (0, import_hooks13.addFilter)("editor.BlockEdit", "core/editor/hooks", withBlockEditHooks); 67772 } 67773 function BlockProps({ 67774 index, 67775 useBlockProps: hook, 67776 setAllWrapperProps, 67777 ...props 67778 }) { 67779 const wrapperProps = hook(props); 67780 const setWrapperProps = (next) => setAllWrapperProps((prev) => { 67781 const nextAll = [...prev]; 67782 nextAll[index] = next; 67783 return nextAll; 67784 }); 67785 (0, import_element247.useEffect)(() => { 67786 setWrapperProps(wrapperProps); 67787 return () => { 67788 setWrapperProps(void 0); 67789 }; 67790 }); 67791 return null; 67792 } 67793 var BlockPropsPure = (0, import_element247.memo)(BlockProps); 67794 function createBlockListBlockFilter(features) { 67795 const withBlockListBlockHooks = (0, import_compose94.createHigherOrderComponent)( 67796 (BlockListBlock2) => (props) => { 67797 const [allWrapperProps, setAllWrapperProps] = (0, import_element247.useState)( 67798 Array(features.length).fill(void 0) 67799 ); 67800 return [ 67801 ...features.map((feature, i2) => { 67802 const { 67803 hasSupport, 67804 attributeKeys = [], 67805 useBlockProps: useBlockProps15, 67806 isMatch 67807 } = feature; 67808 const neededProps = {}; 67809 for (const key of attributeKeys) { 67810 if (props.attributes[key]) { 67811 neededProps[key] = props.attributes[key]; 67812 } 67813 } 67814 if ( 67815 // Skip rendering if none of the needed attributes are 67816 // set. 67817 !Object.keys(neededProps).length || !hasSupport(props.name) || isMatch && !isMatch(neededProps) 67818 ) { 67819 return null; 67820 } 67821 return /* @__PURE__ */ (0, import_jsx_runtime425.jsx)( 67822 BlockPropsPure, 67823 { 67824 index: i2, 67825 useBlockProps: useBlockProps15, 67826 setAllWrapperProps, 67827 name: props.name, 67828 clientId: props.clientId, 67829 ...neededProps 67830 }, 67831 i2 67832 ); 67833 }), 67834 /* @__PURE__ */ (0, import_jsx_runtime425.jsx)( 67835 BlockListBlock2, 67836 { 67837 ...props, 67838 wrapperProps: allWrapperProps.filter(Boolean).reduce((acc, wrapperProps) => { 67839 return { 67840 ...acc, 67841 ...wrapperProps, 67842 className: clsx_default( 67843 acc.className, 67844 wrapperProps.className 67845 ), 67846 style: { 67847 ...acc.style, 67848 ...wrapperProps.style 67849 } 67850 }; 67851 }, props.wrapperProps || {}) 67852 }, 67853 "edit" 67854 ) 67855 ]; 67856 }, 67857 "withBlockListBlockHooks" 67858 ); 67859 (0, import_hooks13.addFilter)( 67860 "editor.BlockListBlock", 67861 "core/editor/hooks", 67862 withBlockListBlockHooks 67863 ); 67864 } 67865 function createBlockSaveFilter(features) { 67866 function extraPropsFromHooks(props, name, attributes) { 67867 return features.reduce((accu, feature) => { 67868 const { hasSupport, attributeKeys = [], addSaveProps: addSaveProps10 } = feature; 67869 const neededAttributes = {}; 67870 for (const key of attributeKeys) { 67871 if (attributes[key]) { 67872 neededAttributes[key] = attributes[key]; 67873 } 67874 } 67875 if ( 67876 // Skip rendering if none of the needed attributes are 67877 // set. 67878 !Object.keys(neededAttributes).length || !hasSupport(name) 67879 ) { 67880 return accu; 67881 } 67882 return addSaveProps10(accu, name, neededAttributes); 67883 }, props); 67884 } 67885 (0, import_hooks13.addFilter)( 67886 "blocks.getSaveContent.extraProps", 67887 "core/editor/hooks", 67888 extraPropsFromHooks, 67889 0 67890 ); 67891 (0, import_hooks13.addFilter)( 67892 "blocks.getSaveContent.extraProps", 67893 "core/editor/hooks", 67894 (props) => { 67895 if (props.hasOwnProperty("className") && !props.className) { 67896 delete props.className; 67897 } 67898 return props; 67899 } 67900 ); 67901 } 67902 67903 // packages/block-editor/build-module/hooks/compat.js 67904 var import_blocks95 = __toESM(require_blocks()); 67905 var import_hooks15 = __toESM(require_hooks()); 67906 function migrateLightBlockWrapper(settings2) { 67907 const { apiVersion = 1 } = settings2; 67908 if (apiVersion < 2 && (0, import_blocks95.hasBlockSupport)(settings2, "lightBlockWrapper", false)) { 67909 settings2.apiVersion = 2; 67910 } 67911 return settings2; 67912 } 67913 (0, import_hooks15.addFilter)( 67914 "blocks.registerBlockType", 67915 "core/compat/migrateLightBlockWrapper", 67916 migrateLightBlockWrapper 67917 ); 67918 67919 // packages/block-editor/build-module/hooks/align.js 67920 var import_hooks16 = __toESM(require_hooks()); 67921 var import_blocks96 = __toESM(require_blocks()); 67922 var import_jsx_runtime426 = __toESM(require_jsx_runtime()); 67923 var ALL_ALIGNMENTS = ["left", "center", "right", "wide", "full"]; 67924 var WIDE_ALIGNMENTS = ["wide", "full"]; 67925 function getValidAlignments(blockAlign, hasWideBlockSupport = true, hasWideEnabled = true) { 67926 let validAlignments; 67927 if (Array.isArray(blockAlign)) { 67928 validAlignments = ALL_ALIGNMENTS.filter( 67929 (value) => blockAlign.includes(value) 67930 ); 67931 } else if (blockAlign === true) { 67932 validAlignments = [...ALL_ALIGNMENTS]; 67933 } else { 67934 validAlignments = []; 67935 } 67936 if (!hasWideEnabled || blockAlign === true && !hasWideBlockSupport) { 67937 return validAlignments.filter( 67938 (alignment) => !WIDE_ALIGNMENTS.includes(alignment) 67939 ); 67940 } 67941 return validAlignments; 67942 } 67943 function addAttribute(settings2) { 67944 if ("type" in (settings2.attributes?.align ?? {})) { 67945 return settings2; 67946 } 67947 if ((0, import_blocks96.hasBlockSupport)(settings2, "align")) { 67948 settings2.attributes = { 67949 ...settings2.attributes, 67950 align: { 67951 type: "string", 67952 // Allow for '' since it is used by the `updateAlignment` function 67953 // in toolbar controls for special cases with defined default values. 67954 enum: [...ALL_ALIGNMENTS, ""] 67955 } 67956 }; 67957 } 67958 return settings2; 67959 } 67960 function BlockEditAlignmentToolbarControlsPure({ 67961 name: blockName, 67962 align, 67963 setAttributes 67964 }) { 67965 const blockAllowedAlignments = getValidAlignments( 67966 (0, import_blocks96.getBlockSupport)(blockName, "align"), 67967 (0, import_blocks96.hasBlockSupport)(blockName, "alignWide", true) 67968 ); 67969 const validAlignments = useAvailableAlignments( 67970 blockAllowedAlignments 67971 ).map(({ name }) => name); 67972 const blockEditingMode = useBlockEditingMode(); 67973 if (!validAlignments.length || blockEditingMode !== "default") { 67974 return null; 67975 } 67976 const updateAlignment = (nextAlign) => { 67977 if (!nextAlign) { 67978 const blockType = (0, import_blocks96.getBlockType)(blockName); 67979 const blockDefaultAlign = blockType?.attributes?.align?.default; 67980 if (blockDefaultAlign) { 67981 nextAlign = ""; 67982 } 67983 } 67984 setAttributes({ align: nextAlign }); 67985 }; 67986 return /* @__PURE__ */ (0, import_jsx_runtime426.jsx)(block_controls_default, { group: "block", __experimentalShareWithChildBlocks: true, children: /* @__PURE__ */ (0, import_jsx_runtime426.jsx)( 67987 BlockAlignmentControl, 67988 { 67989 value: align, 67990 onChange: updateAlignment, 67991 controls: validAlignments 67992 } 67993 ) }); 67994 } 67995 var align_default = { 67996 shareWithChildBlocks: true, 67997 edit: BlockEditAlignmentToolbarControlsPure, 67998 useBlockProps: useBlockProps7, 67999 addSaveProps: addAssignedAlign, 68000 attributeKeys: ["align"], 68001 hasSupport(name) { 68002 return (0, import_blocks96.hasBlockSupport)(name, "align", false); 68003 } 68004 }; 68005 function useBlockProps7({ name, align }) { 68006 const blockAllowedAlignments = getValidAlignments( 68007 (0, import_blocks96.getBlockSupport)(name, "align"), 68008 (0, import_blocks96.hasBlockSupport)(name, "alignWide", true) 68009 ); 68010 const validAlignments = useAvailableAlignments(blockAllowedAlignments); 68011 if (validAlignments.some((alignment) => alignment.name === align)) { 68012 return { "data-align": align }; 68013 } 68014 return {}; 68015 } 68016 function addAssignedAlign(props, blockType, attributes) { 68017 const { align } = attributes; 68018 const blockAlign = (0, import_blocks96.getBlockSupport)(blockType, "align"); 68019 const hasWideBlockSupport = (0, import_blocks96.hasBlockSupport)(blockType, "alignWide", true); 68020 const isAlignValid = getValidAlignments( 68021 blockAlign, 68022 hasWideBlockSupport 68023 ).includes(align); 68024 if (isAlignValid) { 68025 props.className = clsx_default(`align$align}`, props.className); 68026 } 68027 return props; 68028 } 68029 (0, import_hooks16.addFilter)( 68030 "blocks.registerBlockType", 68031 "core/editor/align/addAttribute", 68032 addAttribute 68033 ); 68034 68035 // packages/block-editor/build-module/hooks/lock.js 68036 var import_hooks17 = __toESM(require_hooks()); 68037 function addAttribute2(settings2) { 68038 if ("type" in (settings2.attributes?.lock ?? {})) { 68039 return settings2; 68040 } 68041 settings2.attributes = { 68042 ...settings2.attributes, 68043 lock: { 68044 type: "object" 68045 } 68046 }; 68047 return settings2; 68048 } 68049 (0, import_hooks17.addFilter)("blocks.registerBlockType", "core/lock/addAttribute", addAttribute2); 68050 68051 // packages/block-editor/build-module/hooks/allowed-blocks.js 68052 var import_hooks18 = __toESM(require_hooks()); 68053 var import_blocks99 = __toESM(require_blocks()); 68054 68055 // packages/block-editor/build-module/components/block-allowed-blocks/allowed-blocks-control.js 68056 var import_components251 = __toESM(require_components()); 68057 var import_i18n225 = __toESM(require_i18n()); 68058 var import_element251 = __toESM(require_element()); 68059 var import_data179 = __toESM(require_data()); 68060 var import_blocks98 = __toESM(require_blocks()); 68061 68062 // packages/block-editor/build-module/components/block-allowed-blocks/modal.js 68063 var import_components250 = __toESM(require_components()); 68064 var import_element250 = __toESM(require_element()); 68065 var import_i18n224 = __toESM(require_i18n()); 68066 var import_data178 = __toESM(require_data()); 68067 68068 // packages/block-editor/build-module/components/block-manager/index.js 68069 var import_blocks97 = __toESM(require_blocks()); 68070 var import_data177 = __toESM(require_data()); 68071 var import_components249 = __toESM(require_components()); 68072 var import_i18n223 = __toESM(require_i18n()); 68073 var import_element249 = __toESM(require_element()); 68074 var import_compose96 = __toESM(require_compose()); 68075 var import_a11y19 = __toESM(require_a11y()); 68076 68077 // packages/block-editor/build-module/components/block-manager/category.js 68078 var import_element248 = __toESM(require_element()); 68079 var import_compose95 = __toESM(require_compose()); 68080 var import_components248 = __toESM(require_components()); 68081 68082 // packages/block-editor/build-module/components/block-manager/checklist.js 68083 var import_components247 = __toESM(require_components()); 68084 var import_jsx_runtime427 = __toESM(require_jsx_runtime()); 68085 function BlockTypesChecklist({ blockTypes, value, onItemChange }) { 68086 return /* @__PURE__ */ (0, import_jsx_runtime427.jsx)("ul", { className: "block-editor-block-manager__checklist", children: blockTypes.map((blockType) => /* @__PURE__ */ (0, import_jsx_runtime427.jsxs)( 68087 "li", 68088 { 68089 className: "block-editor-block-manager__checklist-item", 68090 children: [ 68091 /* @__PURE__ */ (0, import_jsx_runtime427.jsx)( 68092 import_components247.CheckboxControl, 68093 { 68094 label: blockType.title, 68095 checked: value.includes(blockType.name), 68096 onChange: (...args) => onItemChange(blockType, ...args) 68097 } 68098 ), 68099 /* @__PURE__ */ (0, import_jsx_runtime427.jsx)(block_icon_default, { icon: blockType.icon }) 68100 ] 68101 }, 68102 blockType.name 68103 )) }); 68104 } 68105 var checklist_default = BlockTypesChecklist; 68106 68107 // packages/block-editor/build-module/components/block-manager/category.js 68108 var import_jsx_runtime428 = __toESM(require_jsx_runtime()); 68109 function BlockManagerCategory({ 68110 title, 68111 blockTypes, 68112 selectedBlockTypes, 68113 onChange 68114 }) { 68115 const instanceId = (0, import_compose95.useInstanceId)(BlockManagerCategory); 68116 const toggleVisible = (0, import_element248.useCallback)( 68117 (blockType, nextIsChecked) => { 68118 if (nextIsChecked) { 68119 onChange([...selectedBlockTypes, blockType]); 68120 } else { 68121 onChange( 68122 selectedBlockTypes.filter( 68123 ({ name }) => name !== blockType.name 68124 ) 68125 ); 68126 } 68127 }, 68128 [selectedBlockTypes, onChange] 68129 ); 68130 const toggleAllVisible = (0, import_element248.useCallback)( 68131 (nextIsChecked) => { 68132 if (nextIsChecked) { 68133 onChange([ 68134 ...selectedBlockTypes, 68135 ...blockTypes.filter( 68136 (blockType) => !selectedBlockTypes.find( 68137 ({ name }) => name === blockType.name 68138 ) 68139 ) 68140 ]); 68141 } else { 68142 onChange( 68143 selectedBlockTypes.filter( 68144 (selectedBlockType) => !blockTypes.find( 68145 ({ name }) => name === selectedBlockType.name 68146 ) 68147 ) 68148 ); 68149 } 68150 }, 68151 [blockTypes, selectedBlockTypes, onChange] 68152 ); 68153 if (!blockTypes.length) { 68154 return null; 68155 } 68156 const checkedBlockNames = blockTypes.map(({ name }) => name).filter( 68157 (type) => (selectedBlockTypes ?? []).some( 68158 (selectedBlockType) => selectedBlockType.name === type 68159 ) 68160 ); 68161 const titleId = "block-editor-block-manager__category-title-" + instanceId; 68162 const isAllChecked = checkedBlockNames.length === blockTypes.length; 68163 const isIndeterminate = !isAllChecked && checkedBlockNames.length > 0; 68164 return /* @__PURE__ */ (0, import_jsx_runtime428.jsxs)( 68165 "div", 68166 { 68167 role: "group", 68168 "aria-labelledby": titleId, 68169 className: "block-editor-block-manager__category", 68170 children: [ 68171 /* @__PURE__ */ (0, import_jsx_runtime428.jsx)( 68172 import_components248.CheckboxControl, 68173 { 68174 checked: isAllChecked, 68175 onChange: toggleAllVisible, 68176 className: "block-editor-block-manager__category-title", 68177 indeterminate: isIndeterminate, 68178 label: /* @__PURE__ */ (0, import_jsx_runtime428.jsx)("span", { id: titleId, children: title }) 68179 } 68180 ), 68181 /* @__PURE__ */ (0, import_jsx_runtime428.jsx)( 68182 checklist_default, 68183 { 68184 blockTypes, 68185 value: checkedBlockNames, 68186 onItemChange: toggleVisible 68187 } 68188 ) 68189 ] 68190 } 68191 ); 68192 } 68193 var category_default2 = BlockManagerCategory; 68194 68195 // packages/block-editor/build-module/components/block-manager/index.js 68196 var import_jsx_runtime429 = __toESM(require_jsx_runtime()); 68197 function BlockManager({ 68198 blockTypes, 68199 selectedBlockTypes, 68200 onChange, 68201 showSelectAll = true 68202 }) { 68203 const debouncedSpeak = (0, import_compose96.useDebounce)(import_a11y19.speak, 500); 68204 const [search, setSearch] = (0, import_element249.useState)(""); 68205 const { categories, isMatchingSearchTerm } = (0, import_data177.useSelect)((select3) => { 68206 return { 68207 categories: select3(import_blocks97.store).getCategories(), 68208 isMatchingSearchTerm: select3(import_blocks97.store).isMatchingSearchTerm 68209 }; 68210 }, []); 68211 const filteredBlockTypes = blockTypes.filter((blockType) => { 68212 return !search || isMatchingSearchTerm(blockType, search); 68213 }); 68214 const isIndeterminate = selectedBlockTypes.length > 0 && selectedBlockTypes.length !== blockTypes.length; 68215 const isAllChecked = blockTypes.length > 0 && selectedBlockTypes.length === blockTypes.length; 68216 (0, import_element249.useEffect)(() => { 68217 if (!search) { 68218 return; 68219 } 68220 const count = filteredBlockTypes.length; 68221 const resultsFoundMessage = (0, import_i18n223.sprintf)( 68222 /* translators: %d: number of results. */ 68223 (0, import_i18n223._n)("%d result found.", "%d results found.", count), 68224 count 68225 ); 68226 debouncedSpeak(resultsFoundMessage); 68227 }, [filteredBlockTypes?.length, search, debouncedSpeak]); 68228 return /* @__PURE__ */ (0, import_jsx_runtime429.jsxs)(import_components249.__experimentalVStack, { className: "block-editor-block-manager__content", spacing: 4, children: [ 68229 /* @__PURE__ */ (0, import_jsx_runtime429.jsx)( 68230 import_components249.SearchControl, 68231 { 68232 label: (0, import_i18n223.__)("Search for a block"), 68233 placeholder: (0, import_i18n223.__)("Search for a block"), 68234 value: search, 68235 onChange: (nextSearch) => setSearch(nextSearch), 68236 className: "block-editor-block-manager__search" 68237 } 68238 ), 68239 showSelectAll && /* @__PURE__ */ (0, import_jsx_runtime429.jsx)( 68240 import_components249.CheckboxControl, 68241 { 68242 className: "block-editor-block-manager__select-all", 68243 label: (0, import_i18n223.__)("Select all"), 68244 checked: isAllChecked, 68245 onChange: () => { 68246 if (isAllChecked) { 68247 onChange([]); 68248 } else { 68249 onChange(blockTypes); 68250 } 68251 }, 68252 indeterminate: isIndeterminate 68253 } 68254 ), 68255 /* @__PURE__ */ (0, import_jsx_runtime429.jsxs)( 68256 "div", 68257 { 68258 tabIndex: "0", 68259 role: "region", 68260 "aria-label": (0, import_i18n223.__)("Available block types"), 68261 className: "block-editor-block-manager__results", 68262 children: [ 68263 filteredBlockTypes.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime429.jsx)("p", { className: "block-editor-block-manager__no-results", children: (0, import_i18n223.__)("No blocks found.") }), 68264 categories.map((category) => /* @__PURE__ */ (0, import_jsx_runtime429.jsx)( 68265 category_default2, 68266 { 68267 title: category.title, 68268 blockTypes: filteredBlockTypes.filter( 68269 (blockType) => blockType.category === category.slug 68270 ), 68271 selectedBlockTypes, 68272 onChange 68273 }, 68274 category.slug 68275 )), 68276 /* @__PURE__ */ (0, import_jsx_runtime429.jsx)( 68277 category_default2, 68278 { 68279 title: (0, import_i18n223.__)("Uncategorized"), 68280 blockTypes: filteredBlockTypes.filter( 68281 ({ category }) => !category 68282 ), 68283 selectedBlockTypes, 68284 onChange 68285 } 68286 ) 68287 ] 68288 } 68289 ) 68290 ] }); 68291 } 68292 68293 // packages/block-editor/build-module/components/block-allowed-blocks/modal.js 68294 var import_jsx_runtime430 = __toESM(require_jsx_runtime()); 68295 function BlockAllowedBlocksModal({ 68296 clientId, 68297 blockTypes, 68298 selectedBlockTypes, 68299 onClose 68300 }) { 68301 const [currentSelectedBlockTypes, setCurrentSelectedBlockTypes] = (0, import_element250.useState)(selectedBlockTypes); 68302 const { updateBlockAttributes: updateBlockAttributes2 } = (0, import_data178.useDispatch)(store); 68303 const handleSubmit = () => { 68304 const isFullySelected = currentSelectedBlockTypes.length === blockTypes.length; 68305 const newBlockNames = currentSelectedBlockTypes.map( 68306 ({ name }) => name 68307 ); 68308 updateBlockAttributes2(clientId, { 68309 allowedBlocks: isFullySelected ? void 0 : newBlockNames 68310 }); 68311 onClose(); 68312 }; 68313 return /* @__PURE__ */ (0, import_jsx_runtime430.jsx)( 68314 import_components250.Modal, 68315 { 68316 title: (0, import_i18n224.__)("Manage allowed blocks"), 68317 onRequestClose: onClose, 68318 overlayClassName: "block-editor-block-allowed-blocks-modal", 68319 focusOnMount: "firstContentElement", 68320 size: "medium", 68321 children: /* @__PURE__ */ (0, import_jsx_runtime430.jsxs)( 68322 import_components250.__experimentalVStack, 68323 { 68324 as: "form", 68325 onSubmit: (e2) => { 68326 e2.preventDefault(); 68327 handleSubmit(); 68328 }, 68329 spacing: "4", 68330 children: [ 68331 /* @__PURE__ */ (0, import_jsx_runtime430.jsx)(import_components250.__experimentalText, { children: (0, import_i18n224.__)( 68332 "Select which blocks can be added inside this container." 68333 ) }), 68334 /* @__PURE__ */ (0, import_jsx_runtime430.jsx)( 68335 BlockManager, 68336 { 68337 blockTypes, 68338 selectedBlockTypes: currentSelectedBlockTypes, 68339 onChange: (newSelectedBlockTypes) => { 68340 setCurrentSelectedBlockTypes(newSelectedBlockTypes); 68341 } 68342 } 68343 ), 68344 /* @__PURE__ */ (0, import_jsx_runtime430.jsxs)( 68345 import_components250.Flex, 68346 { 68347 className: "block-editor-block-allowed-blocks-modal__actions", 68348 justify: "flex-end", 68349 expanded: false, 68350 children: [ 68351 /* @__PURE__ */ (0, import_jsx_runtime430.jsx)(import_components250.FlexItem, { children: /* @__PURE__ */ (0, import_jsx_runtime430.jsx)( 68352 import_components250.Button, 68353 { 68354 variant: "tertiary", 68355 onClick: onClose, 68356 __next40pxDefaultSize: true, 68357 children: (0, import_i18n224.__)("Cancel") 68358 } 68359 ) }), 68360 /* @__PURE__ */ (0, import_jsx_runtime430.jsx)(import_components250.FlexItem, { children: /* @__PURE__ */ (0, import_jsx_runtime430.jsx)( 68361 import_components250.Button, 68362 { 68363 variant: "primary", 68364 type: "submit", 68365 __next40pxDefaultSize: true, 68366 children: (0, import_i18n224.__)("Apply") 68367 } 68368 ) }) 68369 ] 68370 } 68371 ) 68372 ] 68373 } 68374 ) 68375 } 68376 ); 68377 } 68378 68379 // packages/block-editor/build-module/components/block-allowed-blocks/allowed-blocks-control.js 68380 var import_jsx_runtime431 = __toESM(require_jsx_runtime()); 68381 function BlockAllowedBlocksControl({ clientId }) { 68382 const [isBlockControlOpened, setIsBlockControlOpened] = (0, import_element251.useState)(false); 68383 const { blockTypes, selectedBlockNames } = (0, import_data179.useSelect)( 68384 (select3) => { 68385 const { getBlockAttributes: getBlockAttributes3 } = select3(store); 68386 return { 68387 blockTypes: select3(import_blocks98.store).getBlockTypes(), 68388 selectedBlockNames: getBlockAttributes3(clientId)?.allowedBlocks 68389 }; 68390 }, 68391 [clientId] 68392 ); 68393 const filteredBlockTypes = blockTypes.filter( 68394 (blockType) => (0, import_blocks98.hasBlockSupport)(blockType, "inserter", true) && (!blockType.parent || blockType.parent.includes("core/post-content")) 68395 ); 68396 if (!filteredBlockTypes) { 68397 return null; 68398 } 68399 const selectedBlockTypes = selectedBlockNames === void 0 ? filteredBlockTypes : filteredBlockTypes.filter( 68400 (blockType) => selectedBlockNames.includes(blockType.name) 68401 ); 68402 return /* @__PURE__ */ (0, import_jsx_runtime431.jsxs)("div", { className: "block-editor-block-allowed-blocks-control", children: [ 68403 /* @__PURE__ */ (0, import_jsx_runtime431.jsxs)( 68404 import_components251.BaseControl, 68405 { 68406 help: (0, import_i18n225.__)( 68407 "Specify which blocks are allowed inside this container." 68408 ), 68409 children: [ 68410 /* @__PURE__ */ (0, import_jsx_runtime431.jsx)(import_components251.BaseControl.VisualLabel, { children: (0, import_i18n225.__)("Allowed Blocks") }), 68411 /* @__PURE__ */ (0, import_jsx_runtime431.jsx)( 68412 import_components251.Button, 68413 { 68414 __next40pxDefaultSize: true, 68415 variant: "secondary", 68416 onClick: () => { 68417 setIsBlockControlOpened(true); 68418 }, 68419 className: "block-editor-block-allowed-blocks-control__button", 68420 children: (0, import_i18n225.__)("Manage allowed blocks") 68421 } 68422 ) 68423 ] 68424 } 68425 ), 68426 isBlockControlOpened && /* @__PURE__ */ (0, import_jsx_runtime431.jsx)( 68427 BlockAllowedBlocksModal, 68428 { 68429 clientId, 68430 blockTypes: filteredBlockTypes, 68431 selectedBlockTypes, 68432 onClose: () => setIsBlockControlOpened(false) 68433 } 68434 ) 68435 ] }); 68436 } 68437 68438 // packages/block-editor/build-module/hooks/allowed-blocks.js 68439 var import_jsx_runtime432 = __toESM(require_jsx_runtime()); 68440 function BlockEditAllowedBlocksControlPure({ clientId }) { 68441 const blockEditingMode = useBlockEditingMode(); 68442 const isContentOnly = blockEditingMode === "contentOnly"; 68443 if (isContentOnly) { 68444 return null; 68445 } 68446 return /* @__PURE__ */ (0, import_jsx_runtime432.jsx)(PrivateInspectorControlsAllowedBlocks.Fill, { children: /* @__PURE__ */ (0, import_jsx_runtime432.jsx)(BlockAllowedBlocksControl, { clientId }) }); 68447 } 68448 var allowed_blocks_default = { 68449 edit: BlockEditAllowedBlocksControlPure, 68450 attributeKeys: ["allowedBlocks"], 68451 hasSupport(name) { 68452 return (0, import_blocks99.hasBlockSupport)(name, "allowedBlocks"); 68453 } 68454 }; 68455 function addAttribute3(settings2) { 68456 if (settings2?.attributes?.allowedBlocks?.type) { 68457 return settings2; 68458 } 68459 if ((0, import_blocks99.hasBlockSupport)(settings2, "allowedBlocks")) { 68460 settings2.attributes = { 68461 ...settings2.attributes, 68462 allowedBlocks: { 68463 type: "array" 68464 } 68465 }; 68466 } 68467 return settings2; 68468 } 68469 (0, import_hooks18.addFilter)( 68470 "blocks.registerBlockType", 68471 "core/allowedBlocks/attribute", 68472 addAttribute3 68473 ); 68474 function addTransforms2(result, source, index, results) { 68475 if (!(0, import_blocks99.hasBlockSupport)(result.name, "allowedBlocks")) { 68476 return result; 68477 } 68478 if (source.length !== 1 && results.length === 1 && result.innerBlocks.length === source.length) { 68479 return result; 68480 } 68481 if (results.length === 1 && source.length > 1 || results.length > 1 && source.length === 1) { 68482 return result; 68483 } 68484 if (results.length > 1 && source.length > 1 && results.length !== source.length) { 68485 return result; 68486 } 68487 if (result.attributes.allowedBlocks) { 68488 return result; 68489 } 68490 const sourceAllowedBlocks = source[index]?.attributes?.allowedBlocks; 68491 if (!sourceAllowedBlocks) { 68492 return result; 68493 } 68494 const blockType = (0, import_blocks99.getBlockType)(result.name); 68495 const destinationAllowedBlocks = blockType?.allowedBlocks || []; 68496 if (!destinationAllowedBlocks.length) { 68497 return { 68498 ...result, 68499 attributes: { 68500 ...result.attributes, 68501 allowedBlocks: sourceAllowedBlocks 68502 } 68503 }; 68504 } 68505 const filteredSourceAllowedBlocks = sourceAllowedBlocks.filter( 68506 (block) => destinationAllowedBlocks.includes(block) 68507 ); 68508 return { 68509 ...result, 68510 attributes: { 68511 ...result.attributes, 68512 allowedBlocks: filteredSourceAllowedBlocks 68513 } 68514 }; 68515 } 68516 (0, import_hooks18.addFilter)( 68517 "blocks.switchToBlockType.transformedBlock", 68518 "core/allowedBlocks/addTransforms", 68519 addTransforms2 68520 ); 68521 68522 // packages/block-editor/build-module/hooks/anchor.js 68523 var import_hooks19 = __toESM(require_hooks()); 68524 var import_components252 = __toESM(require_components()); 68525 var import_i18n226 = __toESM(require_i18n()); 68526 var import_blocks100 = __toESM(require_blocks()); 68527 var import_element252 = __toESM(require_element()); 68528 var import_jsx_runtime433 = __toESM(require_jsx_runtime()); 68529 var ANCHOR_REGEX = /[\s#]/g; 68530 function addAttribute4(settings2) { 68531 if ("type" in (settings2.attributes?.anchor ?? {})) { 68532 return settings2; 68533 } 68534 if ((0, import_blocks100.hasBlockSupport)(settings2, "anchor")) { 68535 settings2.attributes = { 68536 ...settings2.attributes, 68537 anchor: { 68538 type: "string" 68539 } 68540 }; 68541 } 68542 return settings2; 68543 } 68544 function BlockEditAnchorControlPure({ anchor, setAttributes }) { 68545 const blockEditingMode = useBlockEditingMode(); 68546 if (blockEditingMode !== "default") { 68547 return null; 68548 } 68549 const isWeb = import_element252.Platform.OS === "web"; 68550 return /* @__PURE__ */ (0, import_jsx_runtime433.jsx)(inspector_controls_default, { group: "advanced", children: /* @__PURE__ */ (0, import_jsx_runtime433.jsx)( 68551 import_components252.TextControl, 68552 { 68553 __next40pxDefaultSize: true, 68554 className: "html-anchor-control", 68555 label: (0, import_i18n226.__)("HTML anchor"), 68556 help: /* @__PURE__ */ (0, import_jsx_runtime433.jsxs)(import_jsx_runtime433.Fragment, { children: [ 68557 (0, import_i18n226.__)( 68558 "Enter a word or two \u2014 without spaces \u2014 to make a unique web address just for this block, called an \u201Canchor\u201D. Then, you\u2019ll be able to link directly to this section of your page." 68559 ), 68560 isWeb && /* @__PURE__ */ (0, import_jsx_runtime433.jsxs)(import_jsx_runtime433.Fragment, { children: [ 68561 " ", 68562 /* @__PURE__ */ (0, import_jsx_runtime433.jsx)( 68563 import_components252.ExternalLink, 68564 { 68565 href: (0, import_i18n226.__)( 68566 "https://wordpress.org/documentation/article/page-jumps/" 68567 ), 68568 children: (0, import_i18n226.__)("Learn more about anchors") 68569 } 68570 ) 68571 ] }) 68572 ] }), 68573 value: anchor || "", 68574 placeholder: !isWeb ? (0, import_i18n226.__)("Add an anchor") : null, 68575 onChange: (nextValue) => { 68576 nextValue = nextValue.replace(ANCHOR_REGEX, "-"); 68577 setAttributes({ 68578 anchor: nextValue !== "" ? nextValue : void 0 68579 }); 68580 }, 68581 autoCapitalize: "none", 68582 autoComplete: "off" 68583 } 68584 ) }); 68585 } 68586 var anchor_default = { 68587 addSaveProps: addSaveProps3, 68588 edit: BlockEditAnchorControlPure, 68589 attributeKeys: ["anchor"], 68590 hasSupport(name) { 68591 return (0, import_blocks100.hasBlockSupport)(name, "anchor"); 68592 } 68593 }; 68594 function addSaveProps3(extraProps, blockType, attributes) { 68595 if ((0, import_blocks100.hasBlockSupport)(blockType, "anchor")) { 68596 extraProps.id = attributes.anchor === "" ? null : attributes.anchor; 68597 } 68598 return extraProps; 68599 } 68600 (0, import_hooks19.addFilter)("blocks.registerBlockType", "core/anchor/attribute", addAttribute4); 68601 68602 // packages/block-editor/build-module/hooks/aria-label.js 68603 var import_hooks20 = __toESM(require_hooks()); 68604 var import_blocks101 = __toESM(require_blocks()); 68605 function addAttribute5(settings2) { 68606 if (settings2?.attributes?.ariaLabel?.type) { 68607 return settings2; 68608 } 68609 if ((0, import_blocks101.hasBlockSupport)(settings2, "ariaLabel")) { 68610 settings2.attributes = { 68611 ...settings2.attributes, 68612 ariaLabel: { 68613 type: "string" 68614 } 68615 }; 68616 } 68617 return settings2; 68618 } 68619 function addSaveProps4(extraProps, blockType, attributes) { 68620 if ((0, import_blocks101.hasBlockSupport)(blockType, "ariaLabel")) { 68621 extraProps["aria-label"] = attributes.ariaLabel === "" ? null : attributes.ariaLabel; 68622 } 68623 return extraProps; 68624 } 68625 var aria_label_default = { 68626 addSaveProps: addSaveProps4, 68627 attributeKeys: ["ariaLabel"], 68628 hasSupport(name) { 68629 return (0, import_blocks101.hasBlockSupport)(name, "ariaLabel"); 68630 } 68631 }; 68632 (0, import_hooks20.addFilter)( 68633 "blocks.registerBlockType", 68634 "core/ariaLabel/attribute", 68635 addAttribute5 68636 ); 68637 68638 // packages/block-editor/build-module/hooks/custom-class-name.js 68639 var import_hooks21 = __toESM(require_hooks()); 68640 var import_components254 = __toESM(require_components()); 68641 var import_i18n227 = __toESM(require_i18n()); 68642 var import_blocks102 = __toESM(require_blocks()); 68643 var import_jsx_runtime434 = __toESM(require_jsx_runtime()); 68644 function addAttribute6(settings2) { 68645 if ((0, import_blocks102.hasBlockSupport)(settings2, "customClassName", true)) { 68646 settings2.attributes = { 68647 ...settings2.attributes, 68648 className: { 68649 type: "string" 68650 } 68651 }; 68652 } 68653 return settings2; 68654 } 68655 function CustomClassNameControlsPure({ className, setAttributes }) { 68656 const blockEditingMode = useBlockEditingMode(); 68657 if (blockEditingMode !== "default") { 68658 return null; 68659 } 68660 return /* @__PURE__ */ (0, import_jsx_runtime434.jsx)(inspector_controls_default, { group: "advanced", children: /* @__PURE__ */ (0, import_jsx_runtime434.jsx)( 68661 import_components254.TextControl, 68662 { 68663 __next40pxDefaultSize: true, 68664 autoComplete: "off", 68665 label: (0, import_i18n227.__)("Additional CSS class(es)"), 68666 value: className || "", 68667 onChange: (nextValue) => { 68668 setAttributes({ 68669 className: nextValue !== "" ? nextValue : void 0 68670 }); 68671 }, 68672 help: (0, import_i18n227.__)("Separate multiple classes with spaces.") 68673 } 68674 ) }); 68675 } 68676 var custom_class_name_default = { 68677 edit: CustomClassNameControlsPure, 68678 addSaveProps: addSaveProps5, 68679 attributeKeys: ["className"], 68680 hasSupport(name) { 68681 return (0, import_blocks102.hasBlockSupport)(name, "customClassName", true); 68682 } 68683 }; 68684 function addSaveProps5(extraProps, blockType, attributes) { 68685 if ((0, import_blocks102.hasBlockSupport)(blockType, "customClassName", true) && attributes.className) { 68686 extraProps.className = clsx_default( 68687 extraProps.className, 68688 attributes.className 68689 ); 68690 } 68691 return extraProps; 68692 } 68693 function addTransforms3(result, source, index, results) { 68694 if (!(0, import_blocks102.hasBlockSupport)(result.name, "customClassName", true)) { 68695 return result; 68696 } 68697 if (results.length === 1 && result.innerBlocks.length === source.length) { 68698 return result; 68699 } 68700 if (results.length === 1 && source.length > 1 || results.length > 1 && source.length === 1) { 68701 return result; 68702 } 68703 if (source[index]) { 68704 const originClassName = source[index]?.attributes.className; 68705 if (originClassName && result.attributes.className === void 0) { 68706 return { 68707 ...result, 68708 attributes: { 68709 ...result.attributes, 68710 className: originClassName 68711 } 68712 }; 68713 } 68714 } 68715 return result; 68716 } 68717 (0, import_hooks21.addFilter)( 68718 "blocks.registerBlockType", 68719 "core/editor/custom-class-name/attribute", 68720 addAttribute6 68721 ); 68722 (0, import_hooks21.addFilter)( 68723 "blocks.switchToBlockType.transformedBlock", 68724 "core/customClassName/addTransforms", 68725 addTransforms3 68726 ); 68727 68728 // packages/block-editor/build-module/hooks/generated-class-name.js 68729 var import_hooks22 = __toESM(require_hooks()); 68730 var import_blocks103 = __toESM(require_blocks()); 68731 function addGeneratedClassName(extraProps, blockType) { 68732 if ((0, import_blocks103.hasBlockSupport)(blockType, "className", true)) { 68733 if (typeof extraProps.className === "string") { 68734 extraProps.className = [ 68735 .../* @__PURE__ */ new Set([ 68736 (0, import_blocks103.getBlockDefaultClassName)(blockType.name), 68737 ...extraProps.className.split(" ") 68738 ]) 68739 ].join(" ").trim(); 68740 } else { 68741 extraProps.className = (0, import_blocks103.getBlockDefaultClassName)(blockType.name); 68742 } 68743 } 68744 return extraProps; 68745 } 68746 (0, import_hooks22.addFilter)( 68747 "blocks.getSaveContent.extraProps", 68748 "core/generated-class-name/save-props", 68749 addGeneratedClassName 68750 ); 68751 68752 // packages/block-editor/build-module/hooks/style.js 68753 var import_element258 = __toESM(require_element()); 68754 var import_hooks26 = __toESM(require_hooks()); 68755 var import_blocks111 = __toESM(require_blocks()); 68756 var import_compose98 = __toESM(require_compose()); 68757 var import_style_engine4 = __toESM(require_style_engine()); 68758 68759 // packages/block-editor/build-module/hooks/typography.js 68760 var import_blocks109 = __toESM(require_blocks()); 68761 var import_element255 = __toESM(require_element()); 68762 var import_data181 = __toESM(require_data()); 68763 68764 // packages/block-editor/build-module/hooks/line-height.js 68765 var import_blocks104 = __toESM(require_blocks()); 68766 var import_jsx_runtime435 = __toESM(require_jsx_runtime()); 68767 var LINE_HEIGHT_SUPPORT_KEY2 = "typography.lineHeight"; 68768 68769 // packages/block-editor/build-module/hooks/font-family.js 68770 var import_hooks23 = __toESM(require_hooks()); 68771 var import_blocks105 = __toESM(require_blocks()); 68772 var import_token_list2 = __toESM(require_token_list()); 68773 var import_components256 = __toESM(require_components()); 68774 var FONT_FAMILY_SUPPORT_KEY2 = "typography.__experimentalFontFamily"; 68775 var { kebabCase: kebabCase5 } = unlock(import_components256.privateApis); 68776 function addAttributes3(settings2) { 68777 if (!(0, import_blocks105.hasBlockSupport)(settings2, FONT_FAMILY_SUPPORT_KEY2)) { 68778 return settings2; 68779 } 68780 if (!settings2.attributes.fontFamily) { 68781 Object.assign(settings2.attributes, { 68782 fontFamily: { 68783 type: "string" 68784 } 68785 }); 68786 } 68787 return settings2; 68788 } 68789 function addSaveProps6(props, blockType, attributes) { 68790 if (!(0, import_blocks105.hasBlockSupport)(blockType, FONT_FAMILY_SUPPORT_KEY2)) { 68791 return props; 68792 } 68793 if (shouldSkipSerialization( 68794 blockType, 68795 TYPOGRAPHY_SUPPORT_KEY, 68796 "fontFamily" 68797 )) { 68798 return props; 68799 } 68800 if (!attributes?.fontFamily) { 68801 return props; 68802 } 68803 const classes = new import_token_list2.default(props.className); 68804 classes.add(`has-$kebabCase5(attributes?.fontFamily)}-font-family`); 68805 const newClassName = classes.value; 68806 props.className = newClassName ? newClassName : void 0; 68807 return props; 68808 } 68809 function useBlockProps8({ name, fontFamily }) { 68810 return addSaveProps6({}, name, { fontFamily }); 68811 } 68812 var font_family_default = { 68813 useBlockProps: useBlockProps8, 68814 addSaveProps: addSaveProps6, 68815 attributeKeys: ["fontFamily"], 68816 hasSupport(name) { 68817 return (0, import_blocks105.hasBlockSupport)(name, FONT_FAMILY_SUPPORT_KEY2); 68818 } 68819 }; 68820 (0, import_hooks23.addFilter)( 68821 "blocks.registerBlockType", 68822 "core/fontFamily/addAttribute", 68823 addAttributes3 68824 ); 68825 68826 // packages/block-editor/build-module/hooks/font-size.js 68827 var import_hooks24 = __toESM(require_hooks()); 68828 var import_blocks106 = __toESM(require_blocks()); 68829 var import_token_list3 = __toESM(require_token_list()); 68830 var import_jsx_runtime436 = __toESM(require_jsx_runtime()); 68831 var FONT_SIZE_SUPPORT_KEY2 = "typography.fontSize"; 68832 function addAttributes4(settings2) { 68833 if (!(0, import_blocks106.hasBlockSupport)(settings2, FONT_SIZE_SUPPORT_KEY2)) { 68834 return settings2; 68835 } 68836 if (!settings2.attributes.fontSize) { 68837 Object.assign(settings2.attributes, { 68838 fontSize: { 68839 type: "string" 68840 } 68841 }); 68842 } 68843 return settings2; 68844 } 68845 function addSaveProps7(props, blockNameOrType, attributes) { 68846 if (!(0, import_blocks106.hasBlockSupport)(blockNameOrType, FONT_SIZE_SUPPORT_KEY2)) { 68847 return props; 68848 } 68849 if (shouldSkipSerialization( 68850 blockNameOrType, 68851 TYPOGRAPHY_SUPPORT_KEY, 68852 "fontSize" 68853 )) { 68854 return props; 68855 } 68856 const classes = new import_token_list3.default(props.className); 68857 classes.add(getFontSizeClass(attributes.fontSize)); 68858 const newClassName = classes.value; 68859 props.className = newClassName ? newClassName : void 0; 68860 return props; 68861 } 68862 function useBlockProps9({ name, fontSize, style }) { 68863 const [fontSizes, fluidTypographySettings, layoutSettings] = useSettings( 68864 "typography.fontSizes", 68865 "typography.fluid", 68866 "layout" 68867 ); 68868 if (!(0, import_blocks106.hasBlockSupport)(name, FONT_SIZE_SUPPORT_KEY2) || shouldSkipSerialization(name, TYPOGRAPHY_SUPPORT_KEY, "fontSize") || !fontSize && !style?.typography?.fontSize) { 68869 return; 68870 } 68871 let props; 68872 if (style?.typography?.fontSize) { 68873 props = { 68874 style: { 68875 fontSize: getTypographyFontSizeValue( 68876 { size: style.typography.fontSize }, 68877 { 68878 typography: { 68879 fluid: fluidTypographySettings 68880 }, 68881 layout: layoutSettings 68882 } 68883 ) 68884 } 68885 }; 68886 } 68887 if (fontSize) { 68888 props = { 68889 style: { 68890 fontSize: getFontSize( 68891 fontSizes, 68892 fontSize, 68893 style?.typography?.fontSize 68894 ).size 68895 } 68896 }; 68897 } 68898 if (!props) { 68899 return; 68900 } 68901 return addSaveProps7(props, name, { fontSize }); 68902 } 68903 var font_size_default = { 68904 useBlockProps: useBlockProps9, 68905 addSaveProps: addSaveProps7, 68906 attributeKeys: ["fontSize", "style"], 68907 hasSupport(name) { 68908 return (0, import_blocks106.hasBlockSupport)(name, FONT_SIZE_SUPPORT_KEY2); 68909 } 68910 }; 68911 var MIGRATION_PATHS2 = { 68912 fontSize: [["fontSize"], ["style", "typography", "fontSize"]] 68913 }; 68914 function addTransforms4(result, source, index, results) { 68915 const destinationBlockType = result.name; 68916 const activeSupports = { 68917 fontSize: (0, import_blocks106.hasBlockSupport)( 68918 destinationBlockType, 68919 FONT_SIZE_SUPPORT_KEY2 68920 ) 68921 }; 68922 return transformStyles2( 68923 activeSupports, 68924 MIGRATION_PATHS2, 68925 result, 68926 source, 68927 index, 68928 results 68929 ); 68930 } 68931 (0, import_hooks24.addFilter)( 68932 "blocks.registerBlockType", 68933 "core/font/addAttribute", 68934 addAttributes4 68935 ); 68936 (0, import_hooks24.addFilter)( 68937 "blocks.switchToBlockType.transformedBlock", 68938 "core/font-size/addTransforms", 68939 addTransforms4 68940 ); 68941 68942 // packages/block-editor/build-module/hooks/text-align.js 68943 var import_i18n228 = __toESM(require_i18n()); 68944 var import_blocks107 = __toESM(require_blocks()); 68945 var import_jsx_runtime437 = __toESM(require_jsx_runtime()); 68946 var TEXT_ALIGN_SUPPORT_KEY2 = "typography.textAlign"; 68947 var TEXT_ALIGNMENT_OPTIONS2 = [ 68948 { 68949 icon: align_left_default, 68950 title: (0, import_i18n228.__)("Align text left"), 68951 align: "left" 68952 }, 68953 { 68954 icon: align_center_default, 68955 title: (0, import_i18n228.__)("Align text center"), 68956 align: "center" 68957 }, 68958 { 68959 icon: align_right_default, 68960 title: (0, import_i18n228.__)("Align text right"), 68961 align: "right" 68962 } 68963 ]; 68964 var VALID_TEXT_ALIGNMENTS = ["left", "center", "right"]; 68965 var NO_TEXT_ALIGNMENTS = []; 68966 function getValidTextAlignments(blockTextAlign) { 68967 if (Array.isArray(blockTextAlign)) { 68968 return VALID_TEXT_ALIGNMENTS.filter( 68969 (textAlign) => blockTextAlign.includes(textAlign) 68970 ); 68971 } 68972 return blockTextAlign === true ? VALID_TEXT_ALIGNMENTS : NO_TEXT_ALIGNMENTS; 68973 } 68974 function BlockEditTextAlignmentToolbarControlsPure({ 68975 style, 68976 name: blockName, 68977 setAttributes 68978 }) { 68979 const settings2 = useBlockSettings(blockName); 68980 const hasTextAlignControl = settings2?.typography?.textAlign; 68981 const blockEditingMode = useBlockEditingMode(); 68982 if (!hasTextAlignControl || blockEditingMode !== "default") { 68983 return null; 68984 } 68985 const validTextAlignments = getValidTextAlignments( 68986 (0, import_blocks107.getBlockSupport)(blockName, TEXT_ALIGN_SUPPORT_KEY2) 68987 ); 68988 if (!validTextAlignments.length) { 68989 return null; 68990 } 68991 const textAlignmentControls = TEXT_ALIGNMENT_OPTIONS2.filter( 68992 (control) => validTextAlignments.includes(control.align) 68993 ); 68994 const onChange = (newTextAlignValue) => { 68995 const newStyle = { 68996 ...style, 68997 typography: { 68998 ...style?.typography, 68999 textAlign: newTextAlignValue 69000 } 69001 }; 69002 setAttributes({ style: cleanEmptyObject(newStyle) }); 69003 }; 69004 return /* @__PURE__ */ (0, import_jsx_runtime437.jsx)(block_controls_default, { group: "block", children: /* @__PURE__ */ (0, import_jsx_runtime437.jsx)( 69005 AlignmentControl, 69006 { 69007 value: style?.typography?.textAlign, 69008 onChange, 69009 alignmentControls: textAlignmentControls 69010 } 69011 ) }); 69012 } 69013 var text_align_default = { 69014 edit: BlockEditTextAlignmentToolbarControlsPure, 69015 useBlockProps: useBlockProps10, 69016 addSaveProps: addAssignedTextAlign, 69017 attributeKeys: ["style"], 69018 hasSupport(name) { 69019 return (0, import_blocks107.hasBlockSupport)(name, TEXT_ALIGN_SUPPORT_KEY2, false); 69020 } 69021 }; 69022 function useBlockProps10({ name, style }) { 69023 if (!style?.typography?.textAlign) { 69024 return null; 69025 } 69026 const validTextAlignments = getValidTextAlignments( 69027 (0, import_blocks107.getBlockSupport)(name, TEXT_ALIGN_SUPPORT_KEY2) 69028 ); 69029 if (!validTextAlignments.length) { 69030 return null; 69031 } 69032 if (shouldSkipSerialization(name, TYPOGRAPHY_SUPPORT_KEY, "textAlign")) { 69033 return null; 69034 } 69035 const textAlign = style.typography.textAlign; 69036 const className = clsx_default({ 69037 [`has-text-align-$textAlign}`]: textAlign 69038 }); 69039 return { className }; 69040 } 69041 function addAssignedTextAlign(props, blockType, attributes) { 69042 if (!attributes?.style?.typography?.textAlign) { 69043 return props; 69044 } 69045 const { textAlign } = attributes.style.typography; 69046 const blockTextAlign = (0, import_blocks107.getBlockSupport)(blockType, TEXT_ALIGN_SUPPORT_KEY2); 69047 const isTextAlignValid = getValidTextAlignments(blockTextAlign).includes(textAlign); 69048 if (isTextAlignValid && !shouldSkipSerialization( 69049 blockType, 69050 TYPOGRAPHY_SUPPORT_KEY, 69051 "textAlign" 69052 )) { 69053 props.className = clsx_default( 69054 `has-text-align-$textAlign}`, 69055 props.className 69056 ); 69057 } 69058 return props; 69059 } 69060 69061 // packages/block-editor/build-module/hooks/fit-text.js 69062 var import_hooks25 = __toESM(require_hooks()); 69063 var import_blocks108 = __toESM(require_blocks()); 69064 var import_element254 = __toESM(require_element()); 69065 var import_data180 = __toESM(require_data()); 69066 var import_i18n230 = __toESM(require_i18n()); 69067 var import_components259 = __toESM(require_components()); 69068 var import_compose97 = __toESM(require_compose()); 69069 69070 // packages/block-editor/build-module/utils/fit-text-utils.js 69071 function findOptimalFontSize(textElement, applyFontSize) { 69072 const alreadyHasScrollableHeight = textElement.scrollHeight > textElement.clientHeight; 69073 let minSize = 0; 69074 let maxSize = 2400; 69075 let bestSize = minSize; 69076 const computedStyle = window.getComputedStyle(textElement); 69077 const paddingLeft = parseFloat(computedStyle.paddingLeft) || 0; 69078 const paddingRight = parseFloat(computedStyle.paddingRight) || 0; 69079 const range2 = document.createRange(); 69080 range2.selectNodeContents(textElement); 69081 while (minSize <= maxSize) { 69082 const midSize = Math.floor((minSize + maxSize) / 2); 69083 applyFontSize(midSize); 69084 const rect = range2.getBoundingClientRect(); 69085 const textWidth = rect.width; 69086 const fitsWidth = textElement.scrollWidth <= textElement.clientWidth && textWidth <= textElement.clientWidth - paddingLeft - paddingRight; 69087 const fitsHeight = alreadyHasScrollableHeight || textElement.scrollHeight <= textElement.clientHeight; 69088 if (fitsWidth && fitsHeight) { 69089 bestSize = midSize; 69090 minSize = midSize + 1; 69091 } else { 69092 maxSize = midSize - 1; 69093 } 69094 } 69095 range2.detach(); 69096 return bestSize; 69097 } 69098 function optimizeFitText(textElement, applyFontSize) { 69099 if (!textElement) { 69100 return; 69101 } 69102 applyFontSize(0); 69103 const optimalSize = findOptimalFontSize(textElement, applyFontSize); 69104 applyFontSize(optimalSize); 69105 return optimalSize; 69106 } 69107 69108 // packages/block-editor/build-module/components/fit-text-size-warning/index.js 69109 var import_element253 = __toESM(require_element()); 69110 var import_i18n229 = __toESM(require_i18n()); 69111 var import_components258 = __toESM(require_components()); 69112 var import_a11y20 = __toESM(require_a11y()); 69113 var import_jsx_runtime438 = __toESM(require_jsx_runtime()); 69114 function FitTextSizeWarning() { 69115 const message2 = (0, import_i18n229.__)( 69116 "The text may be too small to read. Consider using a larger container or less text." 69117 ); 69118 (0, import_element253.useEffect)(() => { 69119 (0, import_a11y20.speak)(message2); 69120 }, [message2]); 69121 return /* @__PURE__ */ (0, import_jsx_runtime438.jsx)("div", { className: "block-editor-fit-text-size-warning", children: /* @__PURE__ */ (0, import_jsx_runtime438.jsx)( 69122 import_components258.Notice, 69123 { 69124 spokenMessage: null, 69125 status: "warning", 69126 isDismissible: false, 69127 children: message2 69128 } 69129 ) }); 69130 } 69131 69132 // packages/block-editor/build-module/hooks/fit-text.js 69133 var import_jsx_runtime439 = __toESM(require_jsx_runtime()); 69134 var EMPTY_OBJECT3 = {}; 69135 var MIN_FONT_SIZE_FOR_WARNING = 6; 69136 var FIT_TEXT_SUPPORT_KEY = "typography.fitText"; 69137 function addAttributes5(settings2) { 69138 if (!(0, import_blocks108.hasBlockSupport)(settings2, FIT_TEXT_SUPPORT_KEY)) { 69139 return settings2; 69140 } 69141 if (settings2.attributes?.fitText) { 69142 return settings2; 69143 } 69144 return { 69145 ...settings2, 69146 attributes: { 69147 ...settings2.attributes, 69148 fitText: { 69149 type: "boolean" 69150 } 69151 } 69152 }; 69153 } 69154 function useFitText({ fitText, name, clientId }) { 69155 const [fontSize, setFontSize] = (0, import_element254.useState)(null); 69156 const hasFitTextSupport2 = (0, import_blocks108.hasBlockSupport)(name, FIT_TEXT_SUPPORT_KEY); 69157 const blockElement = useBlockElement(clientId); 69158 const { blockAttributes, parentId } = (0, import_data180.useSelect)( 69159 (select3) => { 69160 if (!clientId || !hasFitTextSupport2 || !fitText) { 69161 return EMPTY_OBJECT3; 69162 } 69163 return { 69164 blockAttributes: select3(store).getBlockAttributes(clientId), 69165 parentId: select3(store).getBlockRootClientId(clientId) 69166 }; 69167 }, 69168 [clientId, hasFitTextSupport2, fitText] 69169 ); 69170 const applyFitText = (0, import_element254.useCallback)(() => { 69171 if (!blockElement || !hasFitTextSupport2 || !fitText) { 69172 return; 69173 } 69174 const styleId = `fit-text-$clientId}`; 69175 let styleElement = blockElement.ownerDocument.getElementById(styleId); 69176 if (!styleElement) { 69177 styleElement = blockElement.ownerDocument.createElement("style"); 69178 styleElement.id = styleId; 69179 blockElement.ownerDocument.head.appendChild(styleElement); 69180 } 69181 const blockSelector = `#block-$clientId}`; 69182 const applyFontSizeStyle = (size) => { 69183 if (size === 0) { 69184 styleElement.textContent = ""; 69185 } else { 69186 styleElement.textContent = `$blockSelector} { font-size: $size}px !important; }`; 69187 } 69188 }; 69189 const optimalSize = optimizeFitText(blockElement, applyFontSizeStyle); 69190 setFontSize(optimalSize); 69191 }, [blockElement, clientId, hasFitTextSupport2, fitText]); 69192 (0, import_element254.useEffect)(() => { 69193 if (!fitText || !blockElement || !clientId || !hasFitTextSupport2) { 69194 return; 69195 } 69196 const currentElement = blockElement; 69197 const previousVisibility = currentElement.style.visibility; 69198 let hideFrameId = null; 69199 let calculateFrameId = null; 69200 let showTimeoutId = null; 69201 hideFrameId = window.requestAnimationFrame(() => { 69202 currentElement.style.visibility = "hidden"; 69203 calculateFrameId = window.requestAnimationFrame(() => { 69204 applyFitText(); 69205 showTimeoutId = setTimeout(() => { 69206 currentElement.style.visibility = previousVisibility; 69207 }, 10); 69208 }); 69209 }); 69210 let resizeObserver; 69211 if (window.ResizeObserver && currentElement.parentElement) { 69212 resizeObserver = new window.ResizeObserver(applyFitText); 69213 resizeObserver.observe(currentElement.parentElement); 69214 resizeObserver.observe(currentElement); 69215 } 69216 return () => { 69217 if (hideFrameId !== null) { 69218 window.cancelAnimationFrame(hideFrameId); 69219 } 69220 if (calculateFrameId !== null) { 69221 window.cancelAnimationFrame(calculateFrameId); 69222 } 69223 if (showTimeoutId !== null) { 69224 clearTimeout(showTimeoutId); 69225 } 69226 if (resizeObserver) { 69227 resizeObserver.disconnect(); 69228 } 69229 const styleId = `fit-text-$clientId}`; 69230 const styleElement = currentElement.ownerDocument.getElementById(styleId); 69231 if (styleElement) { 69232 styleElement.remove(); 69233 } 69234 }; 69235 }, [ 69236 fitText, 69237 clientId, 69238 parentId, 69239 applyFitText, 69240 blockElement, 69241 hasFitTextSupport2 69242 ]); 69243 (0, import_element254.useEffect)(() => { 69244 if (fitText && blockElement && hasFitTextSupport2) { 69245 const frameId = window.requestAnimationFrame(() => { 69246 if (blockElement) { 69247 applyFitText(); 69248 } 69249 }); 69250 return () => window.cancelAnimationFrame(frameId); 69251 } 69252 }, [ 69253 blockAttributes, 69254 fitText, 69255 applyFitText, 69256 blockElement, 69257 hasFitTextSupport2 69258 ]); 69259 return { fontSize }; 69260 } 69261 function FitTextControl({ 69262 clientId, 69263 fitText = false, 69264 setAttributes, 69265 name, 69266 fontSize, 69267 style, 69268 warning: warning6 69269 }) { 69270 if (!(0, import_blocks108.hasBlockSupport)(name, FIT_TEXT_SUPPORT_KEY)) { 69271 return null; 69272 } 69273 return /* @__PURE__ */ (0, import_jsx_runtime439.jsx)(inspector_controls_default, { group: "typography", children: /* @__PURE__ */ (0, import_jsx_runtime439.jsxs)( 69274 import_components259.__experimentalToolsPanelItem, 69275 { 69276 hasValue: () => fitText, 69277 label: (0, import_i18n230.__)("Fit text"), 69278 onDeselect: () => setAttributes({ fitText: void 0 }), 69279 resetAllFilter: () => ({ fitText: void 0 }), 69280 panelId: clientId, 69281 children: [ 69282 /* @__PURE__ */ (0, import_jsx_runtime439.jsx)( 69283 import_components259.ToggleControl, 69284 { 69285 label: (0, import_i18n230.__)("Fit text"), 69286 checked: fitText, 69287 onChange: () => { 69288 const newFitText = !fitText || void 0; 69289 const updates = { fitText: newFitText }; 69290 if (newFitText) { 69291 if (fontSize) { 69292 updates.fontSize = void 0; 69293 } 69294 if (style?.typography?.fontSize) { 69295 updates.style = { 69296 ...style, 69297 typography: { 69298 ...style?.typography, 69299 fontSize: void 0 69300 } 69301 }; 69302 } 69303 } 69304 setAttributes(updates); 69305 }, 69306 help: fitText ? (0, import_i18n230.__)("Text will resize to fit its container.") : (0, import_i18n230.__)( 69307 "The text will resize to fit its container, resetting other font size settings." 69308 ) 69309 } 69310 ), 69311 warning6 69312 ] 69313 } 69314 ) }); 69315 } 69316 function addSaveProps8(props, blockType, attributes) { 69317 if (!(0, import_blocks108.hasBlockSupport)(blockType, FIT_TEXT_SUPPORT_KEY)) { 69318 return props; 69319 } 69320 const { fitText } = attributes; 69321 if (!fitText) { 69322 return props; 69323 } 69324 const className = props.className ? `$props.className} has-fit-text` : "has-fit-text"; 69325 return { 69326 ...props, 69327 className 69328 }; 69329 } 69330 function useBlockProps11({ name, fitText }) { 69331 if (fitText && (0, import_blocks108.hasBlockSupport)(name, FIT_TEXT_SUPPORT_KEY)) { 69332 return { 69333 className: "has-fit-text" 69334 }; 69335 } 69336 return {}; 69337 } 69338 (0, import_hooks25.addFilter)( 69339 "blocks.registerBlockType", 69340 "core/fit-text/addAttribute", 69341 addAttributes5 69342 ); 69343 var hasFitTextSupport = (blockNameOrType) => { 69344 return (0, import_blocks108.hasBlockSupport)(blockNameOrType, FIT_TEXT_SUPPORT_KEY); 69345 }; 69346 function FitTextEdit(props) { 69347 const { name, attributes, clientId, isSelected, setAttributes } = props; 69348 const { fitText } = attributes; 69349 const { fontSize } = useFitText({ fitText, name, clientId }); 69350 return isSelected && /* @__PURE__ */ (0, import_jsx_runtime439.jsx)( 69351 FitTextControl, 69352 { 69353 clientId, 69354 fitText, 69355 setAttributes, 69356 name, 69357 fontSize: attributes.fontSize, 69358 style: attributes.style, 69359 warning: fontSize < MIN_FONT_SIZE_FOR_WARNING && /* @__PURE__ */ (0, import_jsx_runtime439.jsx)(FitTextSizeWarning, {}) 69360 } 69361 ); 69362 } 69363 var withFitTextEdit = (0, import_compose97.createHigherOrderComponent)((BlockEdit2) => { 69364 return (props) => { 69365 const { name, attributes, clientId, isSelected, setAttributes } = props; 69366 const { fitText } = attributes; 69367 const supportsFitText = (0, import_blocks108.hasBlockSupport)(name, FIT_TEXT_SUPPORT_KEY); 69368 if (!supportsFitText) { 69369 return /* @__PURE__ */ (0, import_jsx_runtime439.jsx)(BlockEdit2, { ...props }); 69370 } 69371 return /* @__PURE__ */ (0, import_jsx_runtime439.jsxs)(import_jsx_runtime439.Fragment, { children: [ 69372 /* @__PURE__ */ (0, import_jsx_runtime439.jsx)(BlockEdit2, { ...props }), 69373 fitText && /* @__PURE__ */ (0, import_jsx_runtime439.jsx)( 69374 FitTextEdit, 69375 { 69376 clientId, 69377 fitText, 69378 setAttributes: props.setAttributes, 69379 name, 69380 attributes, 69381 isSelected 69382 } 69383 ), 69384 !fitText && isSelected && /* @__PURE__ */ (0, import_jsx_runtime439.jsx)( 69385 FitTextControl, 69386 { 69387 clientId, 69388 fitText, 69389 setAttributes, 69390 name, 69391 fontSize: attributes.fontSize, 69392 style: attributes.style 69393 } 69394 ) 69395 ] }); 69396 }; 69397 }, "withFitTextEdit"); 69398 (0, import_hooks25.addFilter)( 69399 "editor.BlockEdit", 69400 "core/fit-text/with-fit-text-edit", 69401 withFitTextEdit 69402 ); 69403 var fit_text_default = { 69404 useBlockProps: useBlockProps11, 69405 addSaveProps: addSaveProps8, 69406 attributeKeys: ["fitText", "fontSize", "style"], 69407 hasSupport: hasFitTextSupport, 69408 edit: () => null 69409 }; 69410 69411 // packages/block-editor/build-module/hooks/typography.js 69412 var import_jsx_runtime440 = __toESM(require_jsx_runtime()); 69413 function omit(object, keys) { 69414 return Object.fromEntries( 69415 Object.entries(object).filter(([key]) => !keys.includes(key)) 69416 ); 69417 } 69418 var LETTER_SPACING_SUPPORT_KEY2 = "typography.__experimentalLetterSpacing"; 69419 var TEXT_TRANSFORM_SUPPORT_KEY2 = "typography.__experimentalTextTransform"; 69420 var TEXT_DECORATION_SUPPORT_KEY2 = "typography.__experimentalTextDecoration"; 69421 var TEXT_COLUMNS_SUPPORT_KEY2 = "typography.textColumns"; 69422 var FONT_STYLE_SUPPORT_KEY2 = "typography.__experimentalFontStyle"; 69423 var FONT_WEIGHT_SUPPORT_KEY2 = "typography.__experimentalFontWeight"; 69424 var WRITING_MODE_SUPPORT_KEY2 = "typography.__experimentalWritingMode"; 69425 var TYPOGRAPHY_SUPPORT_KEY = "typography"; 69426 var TYPOGRAPHY_SUPPORT_KEYS2 = [ 69427 LINE_HEIGHT_SUPPORT_KEY2, 69428 FONT_SIZE_SUPPORT_KEY2, 69429 FONT_STYLE_SUPPORT_KEY2, 69430 FONT_WEIGHT_SUPPORT_KEY2, 69431 FONT_FAMILY_SUPPORT_KEY2, 69432 TEXT_ALIGN_SUPPORT_KEY2, 69433 TEXT_COLUMNS_SUPPORT_KEY2, 69434 TEXT_DECORATION_SUPPORT_KEY2, 69435 WRITING_MODE_SUPPORT_KEY2, 69436 TEXT_TRANSFORM_SUPPORT_KEY2, 69437 LETTER_SPACING_SUPPORT_KEY2, 69438 FIT_TEXT_SUPPORT_KEY 69439 ]; 69440 function styleToAttributes3(style) { 69441 const updatedStyle = { ...omit(style, ["fontFamily"]) }; 69442 const fontSizeValue = style?.typography?.fontSize; 69443 const fontFamilyValue = style?.typography?.fontFamily; 69444 const fontSizeSlug = typeof fontSizeValue === "string" && fontSizeValue?.startsWith("var:preset|font-size|") ? fontSizeValue.substring("var:preset|font-size|".length) : void 0; 69445 const fontFamilySlug = fontFamilyValue?.startsWith( 69446 "var:preset|font-family|" 69447 ) ? fontFamilyValue.substring("var:preset|font-family|".length) : void 0; 69448 updatedStyle.typography = { 69449 ...omit(updatedStyle.typography, ["fontFamily"]), 69450 fontSize: fontSizeSlug ? void 0 : fontSizeValue 69451 }; 69452 return { 69453 style: cleanEmptyObject(updatedStyle), 69454 fontFamily: fontFamilySlug, 69455 fontSize: fontSizeSlug 69456 }; 69457 } 69458 function attributesToStyle3(attributes) { 69459 return { 69460 ...attributes.style, 69461 typography: { 69462 ...attributes.style?.typography, 69463 fontFamily: attributes.fontFamily ? "var:preset|font-family|" + attributes.fontFamily : void 0, 69464 fontSize: attributes.fontSize ? "var:preset|font-size|" + attributes.fontSize : attributes.style?.typography?.fontSize 69465 } 69466 }; 69467 } 69468 function TypographyInspectorControl({ children, resetAllFilter }) { 69469 const attributesResetAllFilter = (0, import_element255.useCallback)( 69470 (attributes) => { 69471 const existingStyle = attributesToStyle3(attributes); 69472 const updatedStyle = resetAllFilter(existingStyle); 69473 return { 69474 ...attributes, 69475 ...styleToAttributes3(updatedStyle) 69476 }; 69477 }, 69478 [resetAllFilter] 69479 ); 69480 return /* @__PURE__ */ (0, import_jsx_runtime440.jsx)( 69481 inspector_controls_default, 69482 { 69483 group: "typography", 69484 resetAllFilter: attributesResetAllFilter, 69485 children 69486 } 69487 ); 69488 } 69489 function TypographyPanel2({ clientId, name, setAttributes, settings: settings2 }) { 69490 const isEnabled = useHasTypographyPanel(settings2); 69491 const { style, fontFamily, fontSize, fitText } = (0, import_data181.useSelect)( 69492 (select3) => { 69493 if (!isEnabled) { 69494 return {}; 69495 } 69496 const { 69497 style: _style, 69498 fontFamily: _fontFamily, 69499 fontSize: _fontSize, 69500 fitText: _fitText 69501 } = select3(store).getBlockAttributes(clientId) || {}; 69502 return { 69503 style: _style, 69504 fontFamily: _fontFamily, 69505 fontSize: _fontSize, 69506 fitText: _fitText 69507 }; 69508 }, 69509 [clientId, isEnabled] 69510 ); 69511 const value = (0, import_element255.useMemo)( 69512 () => attributesToStyle3({ style, fontFamily, fontSize }), 69513 [style, fontSize, fontFamily] 69514 ); 69515 const onChange = (newStyle) => { 69516 const newAttributes = styleToAttributes3(newStyle); 69517 const hasFontSize = newAttributes.fontSize || newAttributes.style?.typography?.fontSize; 69518 if (hasFontSize && fitText) { 69519 newAttributes.fitText = void 0; 69520 } 69521 setAttributes(newAttributes); 69522 }; 69523 if (!isEnabled) { 69524 return null; 69525 } 69526 const defaultControls = (0, import_blocks109.getBlockSupport)(name, [ 69527 TYPOGRAPHY_SUPPORT_KEY, 69528 "__experimentalDefaultControls" 69529 ]); 69530 return /* @__PURE__ */ (0, import_jsx_runtime440.jsx)( 69531 TypographyPanel, 69532 { 69533 as: TypographyInspectorControl, 69534 panelId: clientId, 69535 settings: settings2, 69536 value, 69537 onChange, 69538 defaultControls 69539 } 69540 ); 69541 } 69542 69543 // packages/block-editor/build-module/hooks/dimensions.js 69544 var import_element257 = __toESM(require_element()); 69545 var import_data182 = __toESM(require_data()); 69546 var import_blocks110 = __toESM(require_blocks()); 69547 var import_deprecated36 = __toESM(require_deprecated()); 69548 69549 // packages/block-editor/build-module/hooks/spacing-visualizer.js 69550 var import_element256 = __toESM(require_element()); 69551 var import_is_shallow_equal4 = __toESM(require_is_shallow_equal()); 69552 var import_jsx_runtime441 = __toESM(require_jsx_runtime()); 69553 function SpacingVisualizer({ clientId, value, computeStyle, forceShow }) { 69554 const blockElement = useBlockElement(clientId); 69555 const [style, updateStyle] = (0, import_element256.useReducer)( 69556 () => computeStyle(blockElement) 69557 ); 69558 (0, import_element256.useEffect)(() => { 69559 if (blockElement && forceShow) { 69560 updateStyle(); 69561 } 69562 }, [blockElement, forceShow]); 69563 (0, import_element256.useEffect)(() => { 69564 if (!blockElement) { 69565 return; 69566 } 69567 const observer = new window.MutationObserver(updateStyle); 69568 observer.observe(blockElement, { 69569 attributes: true, 69570 attributeFilter: ["style", "class"] 69571 }); 69572 return () => { 69573 observer.disconnect(); 69574 }; 69575 }, [blockElement]); 69576 const previousValueRef = (0, import_element256.useRef)(value); 69577 const [isActive, setIsActive] = (0, import_element256.useState)(false); 69578 (0, import_element256.useEffect)(() => { 69579 if ((0, import_is_shallow_equal4.default)(value, previousValueRef.current) || forceShow) { 69580 return; 69581 } 69582 setIsActive(true); 69583 previousValueRef.current = value; 69584 const timeout = setTimeout(() => { 69585 setIsActive(false); 69586 }, 400); 69587 return () => { 69588 setIsActive(false); 69589 clearTimeout(timeout); 69590 }; 69591 }, [value, forceShow]); 69592 if (!isActive && !forceShow) { 69593 return null; 69594 } 69595 return /* @__PURE__ */ (0, import_jsx_runtime441.jsx)( 69596 cover_default, 69597 { 69598 clientId, 69599 __unstablePopoverSlot: "block-toolbar", 69600 children: /* @__PURE__ */ (0, import_jsx_runtime441.jsx)("div", { className: "block-editor__spacing-visualizer", style }) 69601 } 69602 ); 69603 } 69604 function getComputedCSS(element, property) { 69605 return element.ownerDocument.defaultView.getComputedStyle(element).getPropertyValue(property); 69606 } 69607 function MarginVisualizer({ clientId, value, forceShow }) { 69608 return /* @__PURE__ */ (0, import_jsx_runtime441.jsx)( 69609 SpacingVisualizer, 69610 { 69611 clientId, 69612 value: value?.spacing?.margin, 69613 computeStyle: (blockElement) => { 69614 const top = getComputedCSS(blockElement, "margin-top"); 69615 const right = getComputedCSS(blockElement, "margin-right"); 69616 const bottom = getComputedCSS(blockElement, "margin-bottom"); 69617 const left = getComputedCSS(blockElement, "margin-left"); 69618 return { 69619 borderTopWidth: top, 69620 borderRightWidth: right, 69621 borderBottomWidth: bottom, 69622 borderLeftWidth: left, 69623 top: top ? `-$top}` : 0, 69624 right: right ? `-$right}` : 0, 69625 bottom: bottom ? `-$bottom}` : 0, 69626 left: left ? `-$left}` : 0 69627 }; 69628 }, 69629 forceShow 69630 } 69631 ); 69632 } 69633 function PaddingVisualizer({ clientId, value, forceShow }) { 69634 return /* @__PURE__ */ (0, import_jsx_runtime441.jsx)( 69635 SpacingVisualizer, 69636 { 69637 clientId, 69638 value: value?.spacing?.padding, 69639 computeStyle: (blockElement) => ({ 69640 borderTopWidth: getComputedCSS(blockElement, "padding-top"), 69641 borderRightWidth: getComputedCSS( 69642 blockElement, 69643 "padding-right" 69644 ), 69645 borderBottomWidth: getComputedCSS( 69646 blockElement, 69647 "padding-bottom" 69648 ), 69649 borderLeftWidth: getComputedCSS(blockElement, "padding-left") 69650 }), 69651 forceShow 69652 } 69653 ); 69654 } 69655 69656 // packages/block-editor/build-module/hooks/dimensions.js 69657 var import_jsx_runtime442 = __toESM(require_jsx_runtime()); 69658 var DIMENSIONS_SUPPORT_KEY = "dimensions"; 69659 var SPACING_SUPPORT_KEY2 = "spacing"; 69660 function useVisualizer() { 69661 const [property, setProperty] = (0, import_element257.useState)(false); 69662 const { hideBlockInterface: hideBlockInterface2, showBlockInterface: showBlockInterface2 } = unlock( 69663 (0, import_data182.useDispatch)(store) 69664 ); 69665 (0, import_element257.useEffect)(() => { 69666 if (!property) { 69667 showBlockInterface2(); 69668 } else { 69669 hideBlockInterface2(); 69670 } 69671 }, [property, showBlockInterface2, hideBlockInterface2]); 69672 return [property, setProperty]; 69673 } 69674 function DimensionsInspectorControl({ children, resetAllFilter }) { 69675 const attributesResetAllFilter = (0, import_element257.useCallback)( 69676 (attributes) => { 69677 const existingStyle = attributes.style; 69678 const updatedStyle = resetAllFilter(existingStyle); 69679 return { 69680 ...attributes, 69681 style: updatedStyle 69682 }; 69683 }, 69684 [resetAllFilter] 69685 ); 69686 return /* @__PURE__ */ (0, import_jsx_runtime442.jsx)( 69687 inspector_controls_default, 69688 { 69689 group: "dimensions", 69690 resetAllFilter: attributesResetAllFilter, 69691 children 69692 } 69693 ); 69694 } 69695 function DimensionsPanel2({ clientId, name, setAttributes, settings: settings2 }) { 69696 const isEnabled = useHasDimensionsPanel(settings2); 69697 const value = (0, import_data182.useSelect)( 69698 (select3) => { 69699 if (!isEnabled) { 69700 return void 0; 69701 } 69702 return select3(store).getBlockAttributes(clientId)?.style; 69703 }, 69704 [clientId, isEnabled] 69705 ); 69706 const [visualizedProperty, setVisualizedProperty] = useVisualizer(); 69707 const onChange = (newStyle) => { 69708 setAttributes({ 69709 style: cleanEmptyObject(newStyle) 69710 }); 69711 }; 69712 if (!isEnabled) { 69713 return null; 69714 } 69715 const defaultDimensionsControls = (0, import_blocks110.getBlockSupport)(name, [ 69716 DIMENSIONS_SUPPORT_KEY, 69717 "__experimentalDefaultControls" 69718 ]); 69719 const defaultSpacingControls = (0, import_blocks110.getBlockSupport)(name, [ 69720 SPACING_SUPPORT_KEY2, 69721 "__experimentalDefaultControls" 69722 ]); 69723 const defaultControls = { 69724 ...defaultDimensionsControls, 69725 ...defaultSpacingControls 69726 }; 69727 return /* @__PURE__ */ (0, import_jsx_runtime442.jsxs)(import_jsx_runtime442.Fragment, { children: [ 69728 /* @__PURE__ */ (0, import_jsx_runtime442.jsx)( 69729 DimensionsPanel, 69730 { 69731 as: DimensionsInspectorControl, 69732 panelId: clientId, 69733 settings: settings2, 69734 value, 69735 onChange, 69736 defaultControls, 69737 onVisualize: setVisualizedProperty 69738 } 69739 ), 69740 !!settings2?.spacing?.padding && visualizedProperty === "padding" && /* @__PURE__ */ (0, import_jsx_runtime442.jsx)( 69741 PaddingVisualizer, 69742 { 69743 forceShow: visualizedProperty === "padding", 69744 clientId, 69745 value 69746 } 69747 ), 69748 !!settings2?.spacing?.margin && visualizedProperty === "margin" && /* @__PURE__ */ (0, import_jsx_runtime442.jsx)( 69749 MarginVisualizer, 69750 { 69751 forceShow: visualizedProperty === "margin", 69752 clientId, 69753 value 69754 } 69755 ) 69756 ] }); 69757 } 69758 function hasDimensionsSupport(blockName, feature = "any") { 69759 if (import_element257.Platform.OS !== "web") { 69760 return false; 69761 } 69762 const support = (0, import_blocks110.getBlockSupport)(blockName, DIMENSIONS_SUPPORT_KEY); 69763 if (support === true) { 69764 return true; 69765 } 69766 if (feature === "any") { 69767 return !!(support?.aspectRatio || !!support?.height || !!support?.minHeight || !!support?.width); 69768 } 69769 return !!support?.[feature]; 69770 } 69771 var dimensions_default = { 69772 useBlockProps: useBlockProps12, 69773 attributeKeys: ["height", "minHeight", "width", "style"], 69774 hasSupport(name) { 69775 return hasDimensionsSupport(name); 69776 } 69777 }; 69778 function useBlockProps12({ name, height, minHeight, style }) { 69779 if (!hasDimensionsSupport(name, "aspectRatio") || shouldSkipSerialization(name, DIMENSIONS_SUPPORT_KEY, "aspectRatio")) { 69780 return {}; 69781 } 69782 const className = clsx_default({ 69783 "has-aspect-ratio": !!style?.dimensions?.aspectRatio 69784 }); 69785 const inlineStyleOverrides = {}; 69786 if (style?.dimensions?.aspectRatio) { 69787 inlineStyleOverrides.minHeight = "unset"; 69788 inlineStyleOverrides.height = "unset"; 69789 } else if (minHeight || style?.dimensions?.minHeight || height || style?.dimensions?.height) { 69790 inlineStyleOverrides.aspectRatio = "unset"; 69791 } 69792 return { className, style: inlineStyleOverrides }; 69793 } 69794 function useCustomSides() { 69795 (0, import_deprecated36.default)("wp.blockEditor.__experimentalUseCustomSides", { 69796 since: "6.3", 69797 version: "6.4" 69798 }); 69799 } 69800 69801 // packages/block-editor/build-module/hooks/style.js 69802 var import_jsx_runtime443 = __toESM(require_jsx_runtime()); 69803 var styleSupportKeys2 = [ 69804 ...TYPOGRAPHY_SUPPORT_KEYS2, 69805 BORDER_SUPPORT_KEY2, 69806 COLOR_SUPPORT_KEY2, 69807 DIMENSIONS_SUPPORT_KEY, 69808 BACKGROUND_SUPPORT_KEY, 69809 SPACING_SUPPORT_KEY2, 69810 SHADOW_SUPPORT_KEY 69811 ]; 69812 var hasStyleSupport2 = (nameOrType) => styleSupportKeys2.some((key) => (0, import_blocks111.hasBlockSupport)(nameOrType, key)); 69813 function getInlineStyles(styles = {}) { 69814 const output = {}; 69815 (0, import_style_engine4.getCSSRules)(styles).forEach((rule) => { 69816 output[rule.key] = rule.value; 69817 }); 69818 return output; 69819 } 69820 function addAttribute7(settings2) { 69821 if (!hasStyleSupport2(settings2)) { 69822 return settings2; 69823 } 69824 if (!settings2.attributes.style) { 69825 Object.assign(settings2.attributes, { 69826 style: { 69827 type: "object" 69828 } 69829 }); 69830 } 69831 return settings2; 69832 } 69833 var skipSerializationPathsEdit = { 69834 [`$BORDER_SUPPORT_KEY2}.__experimentalSkipSerialization`]: ["border"], 69835 [`$COLOR_SUPPORT_KEY2}.__experimentalSkipSerialization`]: [ 69836 COLOR_SUPPORT_KEY2 69837 ], 69838 [`$TYPOGRAPHY_SUPPORT_KEY}.__experimentalSkipSerialization`]: [ 69839 TYPOGRAPHY_SUPPORT_KEY 69840 ], 69841 [`$DIMENSIONS_SUPPORT_KEY}.__experimentalSkipSerialization`]: [ 69842 DIMENSIONS_SUPPORT_KEY 69843 ], 69844 [`$SPACING_SUPPORT_KEY2}.__experimentalSkipSerialization`]: [ 69845 SPACING_SUPPORT_KEY2 69846 ], 69847 [`$SHADOW_SUPPORT_KEY}.__experimentalSkipSerialization`]: [ 69848 SHADOW_SUPPORT_KEY 69849 ] 69850 }; 69851 var skipSerializationPathsSave = { 69852 ...skipSerializationPathsEdit, 69853 [`$DIMENSIONS_SUPPORT_KEY}.aspectRatio`]: [ 69854 `$DIMENSIONS_SUPPORT_KEY}.aspectRatio` 69855 ], 69856 // Skip serialization of aspect ratio in save mode. 69857 [`$BACKGROUND_SUPPORT_KEY}`]: [BACKGROUND_SUPPORT_KEY] 69858 // Skip serialization of background support in save mode. 69859 }; 69860 var skipSerializationPathsSaveChecks = { 69861 [`$DIMENSIONS_SUPPORT_KEY}.aspectRatio`]: true, 69862 [`$BACKGROUND_SUPPORT_KEY}`]: true 69863 }; 69864 var renamedFeatures = { gradients: "gradient" }; 69865 function omitStyle(style, paths, preserveReference = false) { 69866 if (!style) { 69867 return style; 69868 } 69869 let newStyle = style; 69870 if (!preserveReference) { 69871 newStyle = JSON.parse(JSON.stringify(style)); 69872 } 69873 if (!Array.isArray(paths)) { 69874 paths = [paths]; 69875 } 69876 paths.forEach((path) => { 69877 if (!Array.isArray(path)) { 69878 path = path.split("."); 69879 } 69880 if (path.length > 1) { 69881 const [firstSubpath, ...restPath] = path; 69882 omitStyle(newStyle[firstSubpath], [restPath], true); 69883 } else if (path.length === 1) { 69884 delete newStyle[path[0]]; 69885 } 69886 }); 69887 return newStyle; 69888 } 69889 function addSaveProps9(props, blockNameOrType, attributes, skipPaths = skipSerializationPathsSave) { 69890 if (!hasStyleSupport2(blockNameOrType)) { 69891 return props; 69892 } 69893 let { style } = attributes; 69894 Object.entries(skipPaths).forEach(([indicator, path]) => { 69895 const skipSerialization = skipSerializationPathsSaveChecks[indicator] || (0, import_blocks111.getBlockSupport)(blockNameOrType, indicator); 69896 if (skipSerialization === true) { 69897 style = omitStyle(style, path); 69898 } 69899 if (Array.isArray(skipSerialization)) { 69900 skipSerialization.forEach((featureName) => { 69901 const feature = renamedFeatures[featureName] || featureName; 69902 style = omitStyle(style, [[...path, feature]]); 69903 }); 69904 } 69905 }); 69906 props.style = { 69907 ...getInlineStyles(style), 69908 ...props.style 69909 }; 69910 return props; 69911 } 69912 function BlockStyleControls({ 69913 clientId, 69914 name, 69915 setAttributes, 69916 __unstableParentLayout 69917 }) { 69918 const settings2 = useBlockSettings(name, __unstableParentLayout); 69919 const blockEditingMode = useBlockEditingMode(); 69920 const passedProps = { 69921 clientId, 69922 name, 69923 setAttributes, 69924 settings: { 69925 ...settings2, 69926 typography: { 69927 ...settings2.typography, 69928 // The text alignment UI for individual blocks is rendered in 69929 // the block toolbar, so disable it here. 69930 textAlign: false 69931 } 69932 } 69933 }; 69934 if (blockEditingMode !== "default") { 69935 return null; 69936 } 69937 return /* @__PURE__ */ (0, import_jsx_runtime443.jsxs)(import_jsx_runtime443.Fragment, { children: [ 69938 /* @__PURE__ */ (0, import_jsx_runtime443.jsx)(ColorEdit, { ...passedProps }), 69939 /* @__PURE__ */ (0, import_jsx_runtime443.jsx)(BackgroundImagePanel3, { ...passedProps }), 69940 /* @__PURE__ */ (0, import_jsx_runtime443.jsx)(TypographyPanel2, { ...passedProps }), 69941 /* @__PURE__ */ (0, import_jsx_runtime443.jsx)(BorderPanel2, { ...passedProps }), 69942 /* @__PURE__ */ (0, import_jsx_runtime443.jsx)(DimensionsPanel2, { ...passedProps }) 69943 ] }); 69944 } 69945 var style_default = { 69946 edit: BlockStyleControls, 69947 hasSupport: hasStyleSupport2, 69948 addSaveProps: addSaveProps9, 69949 attributeKeys: ["style"], 69950 useBlockProps: useBlockProps13 69951 }; 69952 var elementTypes = [ 69953 { elementType: "button" }, 69954 { elementType: "link", pseudo: [":hover"] }, 69955 { 69956 elementType: "heading", 69957 elements: ["h1", "h2", "h3", "h4", "h5", "h6"] 69958 } 69959 ]; 69960 var STYLE_BLOCK_PROPS_REFERENCE = {}; 69961 function useBlockProps13({ name, style }) { 69962 const blockElementsContainerIdentifier = (0, import_compose98.useInstanceId)( 69963 STYLE_BLOCK_PROPS_REFERENCE, 69964 "wp-elements" 69965 ); 69966 const baseElementSelector = `.$blockElementsContainerIdentifier}`; 69967 const blockElementStyles = style?.elements; 69968 const styles = (0, import_element258.useMemo)(() => { 69969 if (!blockElementStyles) { 69970 return; 69971 } 69972 const elementCSSRules = []; 69973 elementTypes.forEach(({ elementType, pseudo, elements }) => { 69974 const skipSerialization = shouldSkipSerialization( 69975 name, 69976 COLOR_SUPPORT_KEY2, 69977 elementType 69978 ); 69979 if (skipSerialization) { 69980 return; 69981 } 69982 const elementStyles = blockElementStyles?.[elementType]; 69983 if (elementStyles) { 69984 const selector3 = scopeSelector( 69985 baseElementSelector, 69986 import_blocks111.__EXPERIMENTAL_ELEMENTS[elementType] 69987 ); 69988 elementCSSRules.push( 69989 (0, import_style_engine4.compileCSS)(elementStyles, { selector: selector3 }) 69990 ); 69991 if (pseudo) { 69992 pseudo.forEach((pseudoSelector) => { 69993 if (elementStyles[pseudoSelector]) { 69994 elementCSSRules.push( 69995 (0, import_style_engine4.compileCSS)(elementStyles[pseudoSelector], { 69996 selector: scopeSelector( 69997 baseElementSelector, 69998 `$import_blocks111.__EXPERIMENTAL_ELEMENTS[elementType]}$pseudoSelector}` 69999 ) 70000 }) 70001 ); 70002 } 70003 }); 70004 } 70005 } 70006 if (elements) { 70007 elements.forEach((element) => { 70008 if (blockElementStyles[element]) { 70009 elementCSSRules.push( 70010 (0, import_style_engine4.compileCSS)(blockElementStyles[element], { 70011 selector: scopeSelector( 70012 baseElementSelector, 70013 import_blocks111.__EXPERIMENTAL_ELEMENTS[element] 70014 ) 70015 }) 70016 ); 70017 } 70018 }); 70019 } 70020 }); 70021 return elementCSSRules.length > 0 ? elementCSSRules.join("") : void 0; 70022 }, [baseElementSelector, blockElementStyles, name]); 70023 useStyleOverride({ css: styles }); 70024 return addSaveProps9( 70025 { className: blockElementsContainerIdentifier }, 70026 name, 70027 { style }, 70028 skipSerializationPathsEdit 70029 ); 70030 } 70031 (0, import_hooks26.addFilter)( 70032 "blocks.registerBlockType", 70033 "core/style/addAttribute", 70034 addAttribute7 70035 ); 70036 70037 // packages/block-editor/build-module/hooks/settings.js 70038 var import_hooks27 = __toESM(require_hooks()); 70039 var import_blocks112 = __toESM(require_blocks()); 70040 var hasSettingsSupport = (blockType) => (0, import_blocks112.hasBlockSupport)(blockType, "__experimentalSettings", false); 70041 function addAttribute8(settings2) { 70042 if (!hasSettingsSupport(settings2)) { 70043 return settings2; 70044 } 70045 if (!settings2?.attributes?.settings) { 70046 settings2.attributes = { 70047 ...settings2.attributes, 70048 settings: { 70049 type: "object" 70050 } 70051 }; 70052 } 70053 return settings2; 70054 } 70055 (0, import_hooks27.addFilter)( 70056 "blocks.registerBlockType", 70057 "core/settings/addAttribute", 70058 addAttribute8 70059 ); 70060 70061 // packages/block-editor/build-module/hooks/duotone.js 70062 var import_blocks113 = __toESM(require_blocks()); 70063 var import_compose99 = __toESM(require_compose()); 70064 var import_hooks28 = __toESM(require_hooks()); 70065 var import_element259 = __toESM(require_element()); 70066 70067 // packages/block-editor/build-module/components/duotone/utils.js 70068 function getValuesFromColors(colors2 = []) { 70069 const values = { r: [], g: [], b: [], a: [] }; 70070 colors2.forEach((color) => { 70071 const rgbColor = w(color).toRgb(); 70072 values.r.push(rgbColor.r / 255); 70073 values.g.push(rgbColor.g / 255); 70074 values.b.push(rgbColor.b / 255); 70075 values.a.push(rgbColor.a); 70076 }); 70077 return values; 70078 } 70079 function getDuotoneUnsetStylesheet(selector3) { 70080 return `$selector3}{filter:none}`; 70081 } 70082 function getDuotoneStylesheet(selector3, id) { 70083 return `$selector3}{filter:url(#$id})}`; 70084 } 70085 function getDuotoneFilter(id, colors2) { 70086 const values = getValuesFromColors(colors2); 70087 return ` 70088 <svg 70089 xmlns:xlink="http://www.w3.org/1999/xlink" 70090 viewBox="0 0 0 0" 70091 width="0" 70092 height="0" 70093 focusable="false" 70094 role="none" 70095 aria-hidden="true" 70096 style="visibility: hidden; position: absolute; left: -9999px; overflow: hidden;" 70097 > 70098 <defs> 70099 <filter id="$id}"> 70100 <!-- 70101 Use sRGB instead of linearRGB so transparency looks correct. 70102 Use perceptual brightness to convert to grayscale. 70103 --> 70104 <feColorMatrix color-interpolation-filters="sRGB" type="matrix" values=" .299 .587 .114 0 0 .299 .587 .114 0 0 .299 .587 .114 0 0 .299 .587 .114 0 0 "></feColorMatrix> 70105 <!-- Use sRGB instead of linearRGB to be consistent with how CSS gradients work. --> 70106 <feComponentTransfer color-interpolation-filters="sRGB"> 70107 <feFuncR type="table" tableValues="$values.r.join(" ")}"></feFuncR> 70108 <feFuncG type="table" tableValues="$values.g.join(" ")}"></feFuncG> 70109 <feFuncB type="table" tableValues="$values.b.join(" ")}"></feFuncB> 70110 <feFuncA type="table" tableValues="$values.a.join(" ")}"></feFuncA> 70111 </feComponentTransfer> 70112 <!-- Re-mask the image with the original transparency since the feColorMatrix above loses that information. --> 70113 <feComposite in2="SourceGraphic" operator="in"></feComposite> 70114 </filter> 70115 </defs> 70116 </svg>`; 70117 } 70118 70119 // packages/block-editor/build-module/hooks/duotone.js 70120 var import_jsx_runtime444 = __toESM(require_jsx_runtime()); 70121 var EMPTY_ARRAY16 = []; 70122 var isSafari = window?.navigator.userAgent && window.navigator.userAgent.includes("Safari") && !window.navigator.userAgent.includes("Chrome") && !window.navigator.userAgent.includes("Chromium"); 70123 k([names_default]); 70124 function useMultiOriginPresets({ presetSetting, defaultSetting }) { 70125 const [enableDefault, userPresets, themePresets, defaultPresets] = useSettings( 70126 defaultSetting, 70127 `$presetSetting}.custom`, 70128 `$presetSetting}.theme`, 70129 `$presetSetting}.default` 70130 ); 70131 return (0, import_element259.useMemo)( 70132 () => [ 70133 ...userPresets || EMPTY_ARRAY16, 70134 ...themePresets || EMPTY_ARRAY16, 70135 ...enableDefault && defaultPresets || EMPTY_ARRAY16 70136 ], 70137 [enableDefault, userPresets, themePresets, defaultPresets] 70138 ); 70139 } 70140 function getColorsFromDuotonePreset(duotone, duotonePalette) { 70141 if (!duotone) { 70142 return; 70143 } 70144 const preset = duotonePalette?.find(({ slug }) => { 70145 return duotone === `var:preset|duotone|$slug}`; 70146 }); 70147 return preset ? preset.colors : void 0; 70148 } 70149 function getDuotonePresetFromColors(colors2, duotonePalette) { 70150 if (!colors2 || !Array.isArray(colors2)) { 70151 return; 70152 } 70153 const preset = duotonePalette?.find((duotonePreset) => { 70154 return duotonePreset?.colors?.every( 70155 (val, index) => val === colors2[index] 70156 ); 70157 }); 70158 return preset ? `var:preset|duotone|$preset.slug}` : void 0; 70159 } 70160 function DuotonePanelPure({ style, setAttributes, name }) { 70161 const duotoneStyle = style?.color?.duotone; 70162 const settings2 = useBlockSettings(name); 70163 const blockEditingMode = useBlockEditingMode(); 70164 const duotonePalette = useMultiOriginPresets({ 70165 presetSetting: "color.duotone", 70166 defaultSetting: "color.defaultDuotone" 70167 }); 70168 const colorPalette = useMultiOriginPresets({ 70169 presetSetting: "color.palette", 70170 defaultSetting: "color.defaultPalette" 70171 }); 70172 const [enableCustomColors, enableCustomDuotone] = useSettings( 70173 "color.custom", 70174 "color.customDuotone" 70175 ); 70176 const disableCustomColors = !enableCustomColors; 70177 const disableCustomDuotone = !enableCustomDuotone || colorPalette?.length === 0 && disableCustomColors; 70178 if (duotonePalette?.length === 0 && disableCustomDuotone) { 70179 return null; 70180 } 70181 if (blockEditingMode !== "default") { 70182 return null; 70183 } 70184 const duotonePresetOrColors = duotoneStyle === "unset" || Array.isArray(duotoneStyle) ? duotoneStyle : getColorsFromDuotonePreset(duotoneStyle, duotonePalette); 70185 return /* @__PURE__ */ (0, import_jsx_runtime444.jsxs)(import_jsx_runtime444.Fragment, { children: [ 70186 /* @__PURE__ */ (0, import_jsx_runtime444.jsx)(inspector_controls_default, { group: "filter", children: /* @__PURE__ */ (0, import_jsx_runtime444.jsx)( 70187 FiltersPanel, 70188 { 70189 value: { filter: { duotone: duotonePresetOrColors } }, 70190 onChange: (newDuotone) => { 70191 const newStyle = { 70192 ...style, 70193 color: { 70194 ...newDuotone?.filter 70195 } 70196 }; 70197 setAttributes({ 70198 style: cleanEmptyObject(newStyle) 70199 }); 70200 }, 70201 settings: settings2 70202 } 70203 ) }), 70204 /* @__PURE__ */ (0, import_jsx_runtime444.jsx)(block_controls_default, { group: "block", __experimentalShareWithChildBlocks: true, children: /* @__PURE__ */ (0, import_jsx_runtime444.jsx)( 70205 duotone_control_default, 70206 { 70207 duotonePalette, 70208 colorPalette, 70209 disableCustomDuotone, 70210 disableCustomColors, 70211 value: duotonePresetOrColors, 70212 onChange: (newDuotone) => { 70213 const maybePreset = getDuotonePresetFromColors( 70214 newDuotone, 70215 duotonePalette 70216 ); 70217 const newStyle = { 70218 ...style, 70219 color: { 70220 ...style?.color, 70221 duotone: maybePreset ?? newDuotone 70222 // use preset or fallback to custom colors. 70223 } 70224 }; 70225 setAttributes({ 70226 style: cleanEmptyObject(newStyle) 70227 }); 70228 }, 70229 settings: settings2 70230 } 70231 ) }) 70232 ] }); 70233 } 70234 var duotone_default = { 70235 shareWithChildBlocks: true, 70236 edit: DuotonePanelPure, 70237 useBlockProps: useBlockProps14, 70238 attributeKeys: ["style"], 70239 hasSupport(name) { 70240 return (0, import_blocks113.hasBlockSupport)(name, "filter.duotone"); 70241 } 70242 }; 70243 function addDuotoneAttributes(settings2) { 70244 if (!(0, import_blocks113.hasBlockSupport)(settings2, "filter.duotone")) { 70245 return settings2; 70246 } 70247 if (!settings2.attributes.style) { 70248 Object.assign(settings2.attributes, { 70249 style: { 70250 type: "object" 70251 } 70252 }); 70253 } 70254 return settings2; 70255 } 70256 function useDuotoneStyles({ 70257 clientId, 70258 id: filterId, 70259 selector: duotoneSelector, 70260 attribute: duotoneAttr 70261 }) { 70262 const duotonePalette = useMultiOriginPresets({ 70263 presetSetting: "color.duotone", 70264 defaultSetting: "color.defaultDuotone" 70265 }); 70266 const isCustom = Array.isArray(duotoneAttr); 70267 const duotonePreset = isCustom ? void 0 : getColorsFromDuotonePreset(duotoneAttr, duotonePalette); 70268 const isPreset = typeof duotoneAttr === "string" && duotonePreset; 70269 const isCSS = typeof duotoneAttr === "string" && !isPreset; 70270 let colors2 = null; 70271 if (isPreset) { 70272 colors2 = duotonePreset; 70273 } else if (isCSS) { 70274 colors2 = duotoneAttr; 70275 } else if (isCustom) { 70276 colors2 = duotoneAttr; 70277 } 70278 const selectors = duotoneSelector.split(","); 70279 const selectorsScoped = selectors.map((selectorPart) => { 70280 return `.$filterId}$selectorPart.trim()}`; 70281 }); 70282 const selector3 = selectorsScoped.join(", "); 70283 const isValidFilter = Array.isArray(colors2) || colors2 === "unset"; 70284 usePrivateStyleOverride( 70285 isValidFilter ? { 70286 css: colors2 !== "unset" ? getDuotoneStylesheet(selector3, filterId) : getDuotoneUnsetStylesheet(selector3), 70287 __unstableType: "presets" 70288 } : void 0 70289 ); 70290 usePrivateStyleOverride( 70291 isValidFilter ? { 70292 assets: colors2 !== "unset" ? getDuotoneFilter(filterId, colors2) : "", 70293 __unstableType: "svgs" 70294 } : void 0 70295 ); 70296 const blockElement = useBlockElement(clientId); 70297 (0, import_element259.useEffect)(() => { 70298 if (!isValidFilter) { 70299 return; 70300 } 70301 if (blockElement && isSafari) { 70302 const display = blockElement.style.display; 70303 blockElement.style.setProperty("display", "inline-block"); 70304 blockElement.offsetHeight; 70305 blockElement.style.setProperty("display", display); 70306 } 70307 }, [isValidFilter, blockElement, colors2]); 70308 } 70309 var DUOTONE_BLOCK_PROPS_REFERENCE = {}; 70310 function useBlockProps14({ clientId, name, style }) { 70311 const id = (0, import_compose99.useInstanceId)(DUOTONE_BLOCK_PROPS_REFERENCE); 70312 const selector3 = (0, import_element259.useMemo)(() => { 70313 const blockType = (0, import_blocks113.getBlockType)(name); 70314 if (blockType) { 70315 const duotoneSupport = (0, import_blocks113.getBlockSupport)( 70316 blockType, 70317 "filter.duotone", 70318 false 70319 ); 70320 if (!duotoneSupport) { 70321 return null; 70322 } 70323 const experimentalDuotone = (0, import_blocks113.getBlockSupport)( 70324 blockType, 70325 "color.__experimentalDuotone", 70326 false 70327 ); 70328 if (experimentalDuotone) { 70329 const rootSelector = getBlockSelector(blockType); 70330 return typeof experimentalDuotone === "string" ? scopeSelector(rootSelector, experimentalDuotone) : rootSelector; 70331 } 70332 return getBlockSelector(blockType, "filter.duotone", { 70333 fallback: true 70334 }); 70335 } 70336 }, [name]); 70337 const attribute = style?.color?.duotone; 70338 const filterClass = `wp-duotone-$id}`; 70339 const shouldRender = selector3 && attribute; 70340 useDuotoneStyles({ 70341 clientId, 70342 id: filterClass, 70343 selector: selector3, 70344 attribute 70345 }); 70346 return { 70347 className: shouldRender ? filterClass : "" 70348 }; 70349 } 70350 (0, import_hooks28.addFilter)( 70351 "blocks.registerBlockType", 70352 "core/editor/duotone/add-attributes", 70353 addDuotoneAttributes 70354 ); 70355 70356 // packages/block-editor/build-module/hooks/layout.js 70357 var import_compose100 = __toESM(require_compose()); 70358 var import_hooks29 = __toESM(require_hooks()); 70359 var import_blocks114 = __toESM(require_blocks()); 70360 var import_data183 = __toESM(require_data()); 70361 var import_components261 = __toESM(require_components()); 70362 var import_i18n231 = __toESM(require_i18n()); 70363 var import_jsx_runtime445 = __toESM(require_jsx_runtime()); 70364 var layoutBlockSupportKey = "layout"; 70365 var { kebabCase: kebabCase6 } = unlock(import_components261.privateApis); 70366 function hasLayoutBlockSupport(blockName) { 70367 return (0, import_blocks114.hasBlockSupport)(blockName, "layout") || (0, import_blocks114.hasBlockSupport)(blockName, "__experimentalLayout"); 70368 } 70369 function useLayoutClasses(blockAttributes = {}, blockName = "") { 70370 const { layout } = blockAttributes; 70371 const { default: defaultBlockLayout } = (0, import_blocks114.getBlockSupport)(blockName, layoutBlockSupportKey) || {}; 70372 const usedLayout = layout?.inherit || layout?.contentSize || layout?.wideSize ? { ...layout, type: "constrained" } : layout || defaultBlockLayout || {}; 70373 const layoutClassnames = []; 70374 if (LAYOUT_DEFINITIONS[usedLayout?.type || "default"]?.className) { 70375 const baseClassName = LAYOUT_DEFINITIONS[usedLayout?.type || "default"]?.className; 70376 const splitBlockName = blockName.split("/"); 70377 const fullBlockName = splitBlockName[0] === "core" ? splitBlockName.pop() : splitBlockName.join("-"); 70378 const compoundClassName = `wp-block-$fullBlockName}-$baseClassName}`; 70379 layoutClassnames.push(baseClassName, compoundClassName); 70380 } 70381 const hasGlobalPadding = (0, import_data183.useSelect)( 70382 (select3) => { 70383 if (!usedLayout?.inherit && !usedLayout?.contentSize && usedLayout?.type !== "constrained") { 70384 return false; 70385 } 70386 return select3(store).getSettings().__experimentalFeatures?.useRootPaddingAwareAlignments; 70387 }, 70388 [usedLayout?.contentSize, usedLayout?.inherit, usedLayout?.type] 70389 ); 70390 if (hasGlobalPadding) { 70391 layoutClassnames.push("has-global-padding"); 70392 } 70393 if (usedLayout?.orientation) { 70394 layoutClassnames.push(`is-$kebabCase6(usedLayout.orientation)}`); 70395 } 70396 if (usedLayout?.justifyContent) { 70397 layoutClassnames.push( 70398 `is-content-justification-$kebabCase6( 70399 usedLayout.justifyContent 70400 )}` 70401 ); 70402 } 70403 if (usedLayout?.flexWrap && usedLayout.flexWrap === "nowrap") { 70404 layoutClassnames.push("is-nowrap"); 70405 } 70406 return layoutClassnames; 70407 } 70408 function useLayoutStyles(blockAttributes = {}, blockName, selector3) { 70409 const { layout = {}, style = {} } = blockAttributes; 70410 const usedLayout = layout?.inherit || layout?.contentSize || layout?.wideSize ? { ...layout, type: "constrained" } : layout || {}; 70411 const fullLayoutType = getLayoutType(usedLayout?.type || "default"); 70412 const [blockGapSupport] = useSettings("spacing.blockGap"); 70413 const hasBlockGapSupport = blockGapSupport !== null; 70414 return fullLayoutType?.getLayoutStyle?.({ 70415 blockName, 70416 selector: selector3, 70417 layout, 70418 style, 70419 hasBlockGapSupport 70420 }); 70421 } 70422 function LayoutPanelPure({ 70423 layout, 70424 setAttributes, 70425 name: blockName, 70426 clientId 70427 }) { 70428 const settings2 = useBlockSettings(blockName); 70429 const { layout: layoutSettings } = settings2; 70430 const { themeSupportsLayout } = (0, import_data183.useSelect)((select3) => { 70431 const { getSettings: getSettings8 } = select3(store); 70432 return { 70433 themeSupportsLayout: getSettings8().supportsLayout 70434 }; 70435 }, []); 70436 const blockEditingMode = useBlockEditingMode(); 70437 if (blockEditingMode !== "default") { 70438 return null; 70439 } 70440 const layoutBlockSupport = (0, import_blocks114.getBlockSupport)( 70441 blockName, 70442 layoutBlockSupportKey, 70443 {} 70444 ); 70445 const blockSupportAndThemeSettings = { 70446 ...layoutSettings, 70447 ...layoutBlockSupport 70448 }; 70449 const { 70450 allowSwitching, 70451 allowEditing = true, 70452 allowInheriting = true, 70453 default: defaultBlockLayout 70454 } = blockSupportAndThemeSettings; 70455 if (!allowEditing) { 70456 return null; 70457 } 70458 const blockSupportAndLayout = { 70459 ...layoutBlockSupport, 70460 ...layout 70461 }; 70462 const { type, default: { type: defaultType = "default" } = {} } = blockSupportAndLayout; 70463 const blockLayoutType = type || defaultType; 70464 const showInheritToggle = !!(allowInheriting && (!blockLayoutType || blockLayoutType === "default" || blockLayoutType === "constrained" || blockSupportAndLayout.inherit)); 70465 const usedLayout = layout || defaultBlockLayout || {}; 70466 const { inherit = false, contentSize = null } = usedLayout; 70467 if ((blockLayoutType === "default" || blockLayoutType === "constrained") && !themeSupportsLayout) { 70468 return null; 70469 } 70470 const layoutType = getLayoutType(blockLayoutType); 70471 const constrainedType = getLayoutType("constrained"); 70472 const displayControlsForLegacyLayouts = !usedLayout.type && (contentSize || inherit); 70473 const hasContentSizeOrLegacySettings = !!inherit || !!contentSize; 70474 const onChangeType = (newType) => setAttributes({ layout: { type: newType } }); 70475 const onChangeLayout = (newLayout) => setAttributes({ layout: newLayout }); 70476 return /* @__PURE__ */ (0, import_jsx_runtime445.jsxs)(import_jsx_runtime445.Fragment, { children: [ 70477 /* @__PURE__ */ (0, import_jsx_runtime445.jsx)(inspector_controls_default, { children: /* @__PURE__ */ (0, import_jsx_runtime445.jsxs)(import_components261.PanelBody, { title: (0, import_i18n231.__)("Layout"), children: [ 70478 showInheritToggle && /* @__PURE__ */ (0, import_jsx_runtime445.jsx)(import_jsx_runtime445.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime445.jsx)( 70479 import_components261.ToggleControl, 70480 { 70481 label: (0, import_i18n231.__)("Inner blocks use content width"), 70482 checked: layoutType?.name === "constrained" || hasContentSizeOrLegacySettings, 70483 onChange: () => setAttributes({ 70484 layout: { 70485 type: layoutType?.name === "constrained" || hasContentSizeOrLegacySettings ? "default" : "constrained" 70486 } 70487 }), 70488 help: layoutType?.name === "constrained" || hasContentSizeOrLegacySettings ? (0, import_i18n231.__)( 70489 "Nested blocks use content width with options for full and wide widths." 70490 ) : (0, import_i18n231.__)( 70491 "Nested blocks will fill the width of this container." 70492 ) 70493 } 70494 ) }), 70495 !inherit && allowSwitching && /* @__PURE__ */ (0, import_jsx_runtime445.jsx)( 70496 LayoutTypeSwitcher, 70497 { 70498 type: blockLayoutType, 70499 onChange: onChangeType 70500 } 70501 ), 70502 layoutType && layoutType.name !== "default" && /* @__PURE__ */ (0, import_jsx_runtime445.jsx)( 70503 layoutType.inspectorControls, 70504 { 70505 layout: usedLayout, 70506 onChange: onChangeLayout, 70507 layoutBlockSupport: blockSupportAndThemeSettings, 70508 name: blockName, 70509 clientId 70510 } 70511 ), 70512 constrainedType && displayControlsForLegacyLayouts && /* @__PURE__ */ (0, import_jsx_runtime445.jsx)( 70513 constrainedType.inspectorControls, 70514 { 70515 layout: usedLayout, 70516 onChange: onChangeLayout, 70517 layoutBlockSupport: blockSupportAndThemeSettings, 70518 name: blockName, 70519 clientId 70520 } 70521 ) 70522 ] }) }), 70523 !inherit && layoutType && /* @__PURE__ */ (0, import_jsx_runtime445.jsx)( 70524 layoutType.toolBarControls, 70525 { 70526 layout: usedLayout, 70527 onChange: onChangeLayout, 70528 layoutBlockSupport, 70529 name: blockName, 70530 clientId 70531 } 70532 ) 70533 ] }); 70534 } 70535 var layout_default2 = { 70536 shareWithChildBlocks: true, 70537 edit: LayoutPanelPure, 70538 attributeKeys: ["layout"], 70539 hasSupport(name) { 70540 return hasLayoutBlockSupport(name); 70541 } 70542 }; 70543 function LayoutTypeSwitcher({ type, onChange }) { 70544 return /* @__PURE__ */ (0, import_jsx_runtime445.jsx)( 70545 import_components261.__experimentalToggleGroupControl, 70546 { 70547 __next40pxDefaultSize: true, 70548 isBlock: true, 70549 label: (0, import_i18n231.__)("Layout type"), 70550 hideLabelFromVision: true, 70551 isAdaptiveWidth: true, 70552 value: type, 70553 onChange, 70554 children: getLayoutTypes().map(({ name, label }) => { 70555 return /* @__PURE__ */ (0, import_jsx_runtime445.jsx)( 70556 import_components261.__experimentalToggleGroupControlOption, 70557 { 70558 value: name, 70559 label 70560 }, 70561 name 70562 ); 70563 }) 70564 } 70565 ); 70566 } 70567 function addAttribute9(settings2) { 70568 if ("type" in (settings2.attributes?.layout ?? {})) { 70569 return settings2; 70570 } 70571 if (hasLayoutBlockSupport(settings2)) { 70572 settings2.attributes = { 70573 ...settings2.attributes, 70574 layout: { 70575 type: "object" 70576 } 70577 }; 70578 } 70579 return settings2; 70580 } 70581 function BlockWithLayoutStyles({ 70582 block: BlockListBlock2, 70583 props, 70584 blockGapSupport, 70585 layoutClasses 70586 }) { 70587 const { name, attributes } = props; 70588 const id = (0, import_compose100.useInstanceId)(BlockListBlock2); 70589 const { layout } = attributes; 70590 const { default: defaultBlockLayout } = (0, import_blocks114.getBlockSupport)(name, layoutBlockSupportKey) || {}; 70591 const usedLayout = layout?.inherit || layout?.contentSize || layout?.wideSize ? { ...layout, type: "constrained" } : layout || defaultBlockLayout || {}; 70592 const selectorPrefix = `wp-container-$kebabCase6(name)}-is-layout-`; 70593 const selector3 = `.$selectorPrefix}$id}`; 70594 const hasBlockGapSupport = blockGapSupport !== null; 70595 const fullLayoutType = getLayoutType(usedLayout?.type || "default"); 70596 const css = fullLayoutType?.getLayoutStyle?.({ 70597 blockName: name, 70598 selector: selector3, 70599 layout: usedLayout, 70600 style: attributes?.style, 70601 hasBlockGapSupport 70602 }); 70603 const layoutClassNames = clsx_default( 70604 { 70605 [`$selectorPrefix}$id}`]: !!css 70606 // Only attach a container class if there is generated CSS to be attached. 70607 }, 70608 layoutClasses 70609 ); 70610 useStyleOverride({ css }); 70611 return /* @__PURE__ */ (0, import_jsx_runtime445.jsx)( 70612 BlockListBlock2, 70613 { 70614 ...props, 70615 __unstableLayoutClassNames: layoutClassNames 70616 } 70617 ); 70618 } 70619 var withLayoutStyles = (0, import_compose100.createHigherOrderComponent)( 70620 (BlockListBlock2) => (props) => { 70621 const { clientId, name, attributes } = props; 70622 const blockSupportsLayout = hasLayoutBlockSupport(name); 70623 const layoutClasses = useLayoutClasses(attributes, name); 70624 const extraProps = (0, import_data183.useSelect)( 70625 (select3) => { 70626 if (!blockSupportsLayout) { 70627 return; 70628 } 70629 const { getSettings: getSettings8, getBlockSettings: getBlockSettings2 } = unlock( 70630 select3(store) 70631 ); 70632 const { disableLayoutStyles } = getSettings8(); 70633 if (disableLayoutStyles) { 70634 return; 70635 } 70636 const [blockGapSupport] = getBlockSettings2( 70637 clientId, 70638 "spacing.blockGap" 70639 ); 70640 return { blockGapSupport }; 70641 }, 70642 [blockSupportsLayout, clientId] 70643 ); 70644 if (!extraProps) { 70645 return /* @__PURE__ */ (0, import_jsx_runtime445.jsx)( 70646 BlockListBlock2, 70647 { 70648 ...props, 70649 __unstableLayoutClassNames: blockSupportsLayout ? layoutClasses : void 0 70650 } 70651 ); 70652 } 70653 return /* @__PURE__ */ (0, import_jsx_runtime445.jsx)( 70654 BlockWithLayoutStyles, 70655 { 70656 block: BlockListBlock2, 70657 props, 70658 layoutClasses, 70659 ...extraProps 70660 } 70661 ); 70662 }, 70663 "withLayoutStyles" 70664 ); 70665 (0, import_hooks29.addFilter)( 70666 "blocks.registerBlockType", 70667 "core/layout/addAttribute", 70668 addAttribute9 70669 ); 70670 (0, import_hooks29.addFilter)( 70671 "editor.BlockListBlock", 70672 "core/editor/layout/with-layout-styles", 70673 withLayoutStyles 70674 ); 70675 70676 // packages/block-editor/build-module/hooks/layout-child.js 70677 var import_compose104 = __toESM(require_compose()); 70678 var import_data187 = __toESM(require_data()); 70679 var import_element263 = __toESM(require_element()); 70680 70681 // packages/block-editor/build-module/components/grid/grid-visualizer.js 70682 var import_element260 = __toESM(require_element()); 70683 var import_data184 = __toESM(require_data()); 70684 var import_compose101 = __toESM(require_compose()); 70685 70686 // packages/block-editor/build-module/components/grid/utils.js 70687 function range(start2, length) { 70688 return Array.from({ length }, (_, i2) => start2 + i2); 70689 } 70690 var GridRect = class { 70691 constructor({ 70692 columnStart, 70693 rowStart, 70694 columnEnd, 70695 rowEnd, 70696 columnSpan, 70697 rowSpan 70698 } = {}) { 70699 this.columnStart = columnStart ?? 1; 70700 this.rowStart = rowStart ?? 1; 70701 if (columnSpan !== void 0) { 70702 this.columnEnd = this.columnStart + columnSpan - 1; 70703 } else { 70704 this.columnEnd = columnEnd ?? this.columnStart; 70705 } 70706 if (rowSpan !== void 0) { 70707 this.rowEnd = this.rowStart + rowSpan - 1; 70708 } else { 70709 this.rowEnd = rowEnd ?? this.rowStart; 70710 } 70711 } 70712 get columnSpan() { 70713 return this.columnEnd - this.columnStart + 1; 70714 } 70715 get rowSpan() { 70716 return this.rowEnd - this.rowStart + 1; 70717 } 70718 contains(column, row) { 70719 return column >= this.columnStart && column <= this.columnEnd && row >= this.rowStart && row <= this.rowEnd; 70720 } 70721 containsRect(rect) { 70722 return this.contains(rect.columnStart, rect.rowStart) && this.contains(rect.columnEnd, rect.rowEnd); 70723 } 70724 intersectsRect(rect) { 70725 return this.columnStart <= rect.columnEnd && this.columnEnd >= rect.columnStart && this.rowStart <= rect.rowEnd && this.rowEnd >= rect.rowStart; 70726 } 70727 }; 70728 function getComputedCSS2(element, property) { 70729 return element.ownerDocument.defaultView.getComputedStyle(element).getPropertyValue(property); 70730 } 70731 function getGridTracks(template2, gap) { 70732 const tracks = []; 70733 for (const size of template2.split(" ")) { 70734 const previousTrack = tracks[tracks.length - 1]; 70735 const start2 = previousTrack ? previousTrack.end + gap : 0; 70736 const end = start2 + parseFloat(size); 70737 tracks.push({ start: start2, end }); 70738 } 70739 return tracks; 70740 } 70741 function getClosestTrack(tracks, position, edge = "start") { 70742 return tracks.reduce( 70743 (closest, track, index) => Math.abs(track[edge] - position) < Math.abs(tracks[closest][edge] - position) ? index : closest, 70744 0 70745 ); 70746 } 70747 function getGridInfo(gridElement) { 70748 const gridTemplateColumns = getComputedCSS2( 70749 gridElement, 70750 "grid-template-columns" 70751 ); 70752 const gridTemplateRows = getComputedCSS2( 70753 gridElement, 70754 "grid-template-rows" 70755 ); 70756 const borderTopWidth = getComputedCSS2(gridElement, "border-top-width"); 70757 const borderRightWidth = getComputedCSS2( 70758 gridElement, 70759 "border-right-width" 70760 ); 70761 const borderBottomWidth = getComputedCSS2( 70762 gridElement, 70763 "border-bottom-width" 70764 ); 70765 const borderLeftWidth = getComputedCSS2(gridElement, "border-left-width"); 70766 const paddingTop = getComputedCSS2(gridElement, "padding-top"); 70767 const paddingRight = getComputedCSS2(gridElement, "padding-right"); 70768 const paddingBottom = getComputedCSS2(gridElement, "padding-bottom"); 70769 const paddingLeft = getComputedCSS2(gridElement, "padding-left"); 70770 const numColumns = gridTemplateColumns.split(" ").length; 70771 const numRows = gridTemplateRows.split(" ").length; 70772 const numItems = numColumns * numRows; 70773 return { 70774 numColumns, 70775 numRows, 70776 numItems, 70777 currentColor: getComputedCSS2(gridElement, "color"), 70778 style: { 70779 gridTemplateColumns, 70780 gridTemplateRows, 70781 gap: getComputedCSS2(gridElement, "gap"), 70782 inset: ` 70783 calc($paddingTop} + $borderTopWidth}) 70784 calc($paddingRight} + $borderRightWidth}) 70785 calc($paddingBottom} + $borderBottomWidth}) 70786 calc($paddingLeft} + $borderLeftWidth}) 70787 ` 70788 } 70789 }; 70790 } 70791 70792 // packages/block-editor/build-module/components/grid/grid-visualizer.js 70793 var import_jsx_runtime446 = __toESM(require_jsx_runtime()); 70794 function GridVisualizer({ clientId, contentRef, parentLayout }) { 70795 const isDistractionFree = (0, import_data184.useSelect)( 70796 (select3) => select3(store).getSettings().isDistractionFree, 70797 [] 70798 ); 70799 const gridElement = useBlockElement(clientId); 70800 if (isDistractionFree || !gridElement) { 70801 return null; 70802 } 70803 const isManualGrid = parentLayout?.isManualPlacement && window.__experimentalEnableGridInteractivity; 70804 return /* @__PURE__ */ (0, import_jsx_runtime446.jsx)( 70805 GridVisualizerGrid, 70806 { 70807 gridClientId: clientId, 70808 gridElement, 70809 isManualGrid, 70810 ref: contentRef 70811 } 70812 ); 70813 } 70814 var GridVisualizerGrid = (0, import_element260.forwardRef)( 70815 ({ gridClientId, gridElement, isManualGrid }, ref) => { 70816 const [gridInfo, setGridInfo] = (0, import_element260.useState)( 70817 () => getGridInfo(gridElement) 70818 ); 70819 const [isDroppingAllowed, setIsDroppingAllowed] = (0, import_element260.useState)(false); 70820 (0, import_element260.useEffect)(() => { 70821 const resizeCallback = () => setGridInfo(getGridInfo(gridElement)); 70822 const borderBoxSpy = new window.ResizeObserver(resizeCallback); 70823 borderBoxSpy.observe(gridElement, { box: "border-box" }); 70824 const contentBoxSpy = new window.ResizeObserver(resizeCallback); 70825 contentBoxSpy.observe(gridElement); 70826 return () => { 70827 borderBoxSpy.disconnect(); 70828 contentBoxSpy.disconnect(); 70829 }; 70830 }, [gridElement]); 70831 (0, import_element260.useEffect)(() => { 70832 function onGlobalDrag() { 70833 setIsDroppingAllowed(true); 70834 } 70835 function onGlobalDragEnd() { 70836 setIsDroppingAllowed(false); 70837 } 70838 document.addEventListener("drag", onGlobalDrag); 70839 document.addEventListener("dragend", onGlobalDragEnd); 70840 return () => { 70841 document.removeEventListener("drag", onGlobalDrag); 70842 document.removeEventListener("dragend", onGlobalDragEnd); 70843 }; 70844 }, []); 70845 return /* @__PURE__ */ (0, import_jsx_runtime446.jsx)( 70846 cover_default, 70847 { 70848 className: clsx_default("block-editor-grid-visualizer", { 70849 "is-dropping-allowed": isDroppingAllowed 70850 }), 70851 clientId: gridClientId, 70852 __unstablePopoverSlot: "__unstable-block-tools-after", 70853 children: /* @__PURE__ */ (0, import_jsx_runtime446.jsx)( 70854 "div", 70855 { 70856 ref, 70857 className: "block-editor-grid-visualizer__grid", 70858 style: gridInfo.style, 70859 children: isManualGrid ? /* @__PURE__ */ (0, import_jsx_runtime446.jsx)( 70860 ManualGridVisualizer, 70861 { 70862 gridClientId, 70863 gridInfo 70864 } 70865 ) : Array.from({ length: gridInfo.numItems }, (_, i2) => /* @__PURE__ */ (0, import_jsx_runtime446.jsx)( 70866 GridVisualizerCell, 70867 { 70868 color: gridInfo.currentColor 70869 }, 70870 i2 70871 )) 70872 } 70873 ) 70874 } 70875 ); 70876 } 70877 ); 70878 function ManualGridVisualizer({ gridClientId, gridInfo }) { 70879 const [highlightedRect, setHighlightedRect] = (0, import_element260.useState)(null); 70880 const gridItemStyles = (0, import_data184.useSelect)( 70881 (select3) => { 70882 const { getBlockOrder: getBlockOrder2, getBlockStyles: getBlockStyles2 } = unlock( 70883 select3(store) 70884 ); 70885 const blockOrder = getBlockOrder2(gridClientId); 70886 return getBlockStyles2(blockOrder); 70887 }, 70888 [gridClientId] 70889 ); 70890 const occupiedRects = (0, import_element260.useMemo)(() => { 70891 const rects = []; 70892 for (const style of Object.values(gridItemStyles)) { 70893 const { 70894 columnStart, 70895 rowStart, 70896 columnSpan = 1, 70897 rowSpan = 1 70898 } = style?.layout ?? {}; 70899 if (!columnStart || !rowStart) { 70900 continue; 70901 } 70902 rects.push( 70903 new GridRect({ 70904 columnStart, 70905 rowStart, 70906 columnSpan, 70907 rowSpan 70908 }) 70909 ); 70910 } 70911 return rects; 70912 }, [gridItemStyles]); 70913 return range(1, gridInfo.numRows).map( 70914 (row) => range(1, gridInfo.numColumns).map((column) => { 70915 const isCellOccupied = occupiedRects.some( 70916 (rect) => rect.contains(column, row) 70917 ); 70918 const isHighlighted = highlightedRect?.contains(column, row) ?? false; 70919 return /* @__PURE__ */ (0, import_jsx_runtime446.jsx)( 70920 GridVisualizerCell, 70921 { 70922 color: gridInfo.currentColor, 70923 className: isHighlighted && "is-highlighted", 70924 children: isCellOccupied ? /* @__PURE__ */ (0, import_jsx_runtime446.jsx)( 70925 GridVisualizerDropZone, 70926 { 70927 column, 70928 row, 70929 gridClientId, 70930 gridInfo, 70931 setHighlightedRect 70932 } 70933 ) : /* @__PURE__ */ (0, import_jsx_runtime446.jsx)( 70934 GridVisualizerAppender, 70935 { 70936 column, 70937 row, 70938 gridClientId, 70939 gridInfo, 70940 setHighlightedRect 70941 } 70942 ) 70943 }, 70944 `$row}-$column}` 70945 ); 70946 }) 70947 ); 70948 } 70949 function GridVisualizerCell({ color, children, className }) { 70950 return /* @__PURE__ */ (0, import_jsx_runtime446.jsx)( 70951 "div", 70952 { 70953 className: clsx_default( 70954 "block-editor-grid-visualizer__cell", 70955 className 70956 ), 70957 style: { 70958 boxShadow: `inset 0 0 0 1px color-mix(in srgb, $color} 20%, #0000)`, 70959 color 70960 }, 70961 children 70962 } 70963 ); 70964 } 70965 function useGridVisualizerDropZone(column, row, gridClientId, gridInfo, setHighlightedRect) { 70966 const { 70967 getBlockAttributes: getBlockAttributes3, 70968 getBlockRootClientId: getBlockRootClientId2, 70969 canInsertBlockType: canInsertBlockType2, 70970 getBlockName: getBlockName2 70971 } = (0, import_data184.useSelect)(store); 70972 const { 70973 updateBlockAttributes: updateBlockAttributes2, 70974 moveBlocksToPosition: moveBlocksToPosition2, 70975 __unstableMarkNextChangeAsNotPersistent: __unstableMarkNextChangeAsNotPersistent2 70976 } = (0, import_data184.useDispatch)(store); 70977 const getNumberOfBlocksBeforeCell = useGetNumberOfBlocksBeforeCell( 70978 gridClientId, 70979 gridInfo.numColumns 70980 ); 70981 return useDropZoneWithValidation({ 70982 validateDrag(srcClientId) { 70983 const blockName = getBlockName2(srcClientId); 70984 if (!canInsertBlockType2(blockName, gridClientId)) { 70985 return false; 70986 } 70987 const attributes = getBlockAttributes3(srcClientId); 70988 const rect = new GridRect({ 70989 columnStart: column, 70990 rowStart: row, 70991 columnSpan: attributes.style?.layout?.columnSpan, 70992 rowSpan: attributes.style?.layout?.rowSpan 70993 }); 70994 const isInBounds = new GridRect({ 70995 columnSpan: gridInfo.numColumns, 70996 rowSpan: gridInfo.numRows 70997 }).containsRect(rect); 70998 return isInBounds; 70999 }, 71000 onDragEnter(srcClientId) { 71001 const attributes = getBlockAttributes3(srcClientId); 71002 setHighlightedRect( 71003 new GridRect({ 71004 columnStart: column, 71005 rowStart: row, 71006 columnSpan: attributes.style?.layout?.columnSpan, 71007 rowSpan: attributes.style?.layout?.rowSpan 71008 }) 71009 ); 71010 }, 71011 onDragLeave() { 71012 setHighlightedRect( 71013 (prevHighlightedRect) => prevHighlightedRect?.columnStart === column && prevHighlightedRect?.rowStart === row ? null : prevHighlightedRect 71014 ); 71015 }, 71016 onDrop(srcClientId) { 71017 setHighlightedRect(null); 71018 const attributes = getBlockAttributes3(srcClientId); 71019 updateBlockAttributes2(srcClientId, { 71020 style: { 71021 ...attributes.style, 71022 layout: { 71023 ...attributes.style?.layout, 71024 columnStart: column, 71025 rowStart: row 71026 } 71027 } 71028 }); 71029 __unstableMarkNextChangeAsNotPersistent2(); 71030 moveBlocksToPosition2( 71031 [srcClientId], 71032 getBlockRootClientId2(srcClientId), 71033 gridClientId, 71034 getNumberOfBlocksBeforeCell(column, row) 71035 ); 71036 } 71037 }); 71038 } 71039 function GridVisualizerDropZone({ 71040 column, 71041 row, 71042 gridClientId, 71043 gridInfo, 71044 setHighlightedRect 71045 }) { 71046 return /* @__PURE__ */ (0, import_jsx_runtime446.jsx)( 71047 "div", 71048 { 71049 className: "block-editor-grid-visualizer__drop-zone", 71050 ref: useGridVisualizerDropZone( 71051 column, 71052 row, 71053 gridClientId, 71054 gridInfo, 71055 setHighlightedRect 71056 ) 71057 } 71058 ); 71059 } 71060 function GridVisualizerAppender({ 71061 column, 71062 row, 71063 gridClientId, 71064 gridInfo, 71065 setHighlightedRect 71066 }) { 71067 const { 71068 updateBlockAttributes: updateBlockAttributes2, 71069 moveBlocksToPosition: moveBlocksToPosition2, 71070 __unstableMarkNextChangeAsNotPersistent: __unstableMarkNextChangeAsNotPersistent2 71071 } = (0, import_data184.useDispatch)(store); 71072 const getNumberOfBlocksBeforeCell = useGetNumberOfBlocksBeforeCell( 71073 gridClientId, 71074 gridInfo.numColumns 71075 ); 71076 return /* @__PURE__ */ (0, import_jsx_runtime446.jsx)( 71077 button_block_appender_default, 71078 { 71079 rootClientId: gridClientId, 71080 className: "block-editor-grid-visualizer__appender", 71081 ref: useGridVisualizerDropZone( 71082 column, 71083 row, 71084 gridClientId, 71085 gridInfo, 71086 setHighlightedRect 71087 ), 71088 style: { 71089 color: gridInfo.currentColor 71090 }, 71091 onSelect: (block) => { 71092 if (!block) { 71093 return; 71094 } 71095 updateBlockAttributes2(block.clientId, { 71096 style: { 71097 layout: { 71098 columnStart: column, 71099 rowStart: row 71100 } 71101 } 71102 }); 71103 __unstableMarkNextChangeAsNotPersistent2(); 71104 moveBlocksToPosition2( 71105 [block.clientId], 71106 gridClientId, 71107 gridClientId, 71108 getNumberOfBlocksBeforeCell(column, row) 71109 ); 71110 } 71111 } 71112 ); 71113 } 71114 function useDropZoneWithValidation({ 71115 validateDrag, 71116 onDragEnter, 71117 onDragLeave, 71118 onDrop 71119 }) { 71120 const { getDraggedBlockClientIds: getDraggedBlockClientIds2 } = (0, import_data184.useSelect)(store); 71121 return (0, import_compose101.__experimentalUseDropZone)({ 71122 onDragEnter() { 71123 const [srcClientId] = getDraggedBlockClientIds2(); 71124 if (srcClientId && validateDrag(srcClientId)) { 71125 onDragEnter(srcClientId); 71126 } 71127 }, 71128 onDragLeave() { 71129 onDragLeave(); 71130 }, 71131 onDrop() { 71132 const [srcClientId] = getDraggedBlockClientIds2(); 71133 if (srcClientId && validateDrag(srcClientId)) { 71134 onDrop(srcClientId); 71135 } 71136 } 71137 }); 71138 } 71139 71140 // packages/block-editor/build-module/components/grid/grid-item-resizer.js 71141 var import_components263 = __toESM(require_components()); 71142 var import_element261 = __toESM(require_element()); 71143 var import_jsx_runtime447 = __toESM(require_jsx_runtime()); 71144 function GridItemResizer({ 71145 clientId, 71146 bounds, 71147 onChange, 71148 parentLayout 71149 }) { 71150 const blockElement = useBlockElement(clientId); 71151 const rootBlockElement = blockElement?.parentElement; 71152 const { isManualPlacement } = parentLayout; 71153 if (!blockElement || !rootBlockElement) { 71154 return null; 71155 } 71156 return /* @__PURE__ */ (0, import_jsx_runtime447.jsx)( 71157 GridItemResizerInner, 71158 { 71159 clientId, 71160 bounds, 71161 blockElement, 71162 rootBlockElement, 71163 onChange, 71164 isManualGrid: isManualPlacement && window.__experimentalEnableGridInteractivity 71165 } 71166 ); 71167 } 71168 function GridItemResizerInner({ 71169 clientId, 71170 bounds, 71171 blockElement, 71172 rootBlockElement, 71173 onChange, 71174 isManualGrid 71175 }) { 71176 const [resizeDirection, setResizeDirection] = (0, import_element261.useState)(null); 71177 const [enableSide, setEnableSide] = (0, import_element261.useState)({ 71178 top: false, 71179 bottom: false, 71180 left: false, 71181 right: false 71182 }); 71183 (0, import_element261.useEffect)(() => { 71184 const observer = new window.ResizeObserver(() => { 71185 const blockClientRect = blockElement.getBoundingClientRect(); 71186 const rootBlockClientRect = rootBlockElement.getBoundingClientRect(); 71187 const topAvailable = blockClientRect.top > rootBlockClientRect.top; 71188 const bottomAvailable = blockClientRect.bottom < rootBlockClientRect.bottom; 71189 const leftAvailable = blockClientRect.left > rootBlockClientRect.left; 71190 const rightAvailable = blockClientRect.right < rootBlockClientRect.right; 71191 setEnableSide({ 71192 top: !!isManualGrid ? topAvailable : !bottomAvailable && topAvailable, 71193 bottom: bottomAvailable, 71194 left: !!isManualGrid ? leftAvailable : !rightAvailable && leftAvailable, 71195 right: rightAvailable 71196 }); 71197 }); 71198 observer.observe(blockElement); 71199 return () => observer.disconnect(); 71200 }, [blockElement, rootBlockElement, isManualGrid]); 71201 const justification = { 71202 right: "left", 71203 left: "right" 71204 }; 71205 const alignment = { 71206 top: "flex-end", 71207 bottom: "flex-start" 71208 }; 71209 const styles = { 71210 display: "flex", 71211 justifyContent: "center", 71212 alignItems: "center", 71213 ...justification[resizeDirection] && { 71214 justifyContent: justification[resizeDirection] 71215 }, 71216 ...alignment[resizeDirection] && { 71217 alignItems: alignment[resizeDirection] 71218 } 71219 }; 71220 return /* @__PURE__ */ (0, import_jsx_runtime447.jsx)( 71221 cover_default, 71222 { 71223 className: "block-editor-grid-item-resizer", 71224 clientId, 71225 __unstablePopoverSlot: "__unstable-block-tools-after", 71226 additionalStyles: styles, 71227 children: /* @__PURE__ */ (0, import_jsx_runtime447.jsx)( 71228 import_components263.ResizableBox, 71229 { 71230 className: "block-editor-grid-item-resizer__box", 71231 size: { 71232 width: "100%", 71233 height: "100%" 71234 }, 71235 enable: { 71236 bottom: enableSide.bottom, 71237 bottomLeft: false, 71238 bottomRight: false, 71239 left: enableSide.left, 71240 right: enableSide.right, 71241 top: enableSide.top, 71242 topLeft: false, 71243 topRight: false 71244 }, 71245 bounds, 71246 boundsByDirection: true, 71247 onPointerDown: ({ target, pointerId }) => { 71248 target.setPointerCapture(pointerId); 71249 }, 71250 onResizeStart: (event, direction) => { 71251 setResizeDirection(direction); 71252 }, 71253 onResizeStop: (event, direction, boxElement) => { 71254 const columnGap = parseFloat( 71255 getComputedCSS2(rootBlockElement, "column-gap") 71256 ); 71257 const rowGap = parseFloat( 71258 getComputedCSS2(rootBlockElement, "row-gap") 71259 ); 71260 const gridColumnTracks = getGridTracks( 71261 getComputedCSS2( 71262 rootBlockElement, 71263 "grid-template-columns" 71264 ), 71265 columnGap 71266 ); 71267 const gridRowTracks = getGridTracks( 71268 getComputedCSS2( 71269 rootBlockElement, 71270 "grid-template-rows" 71271 ), 71272 rowGap 71273 ); 71274 const rect = new window.DOMRect( 71275 blockElement.offsetLeft + boxElement.offsetLeft, 71276 blockElement.offsetTop + boxElement.offsetTop, 71277 boxElement.offsetWidth, 71278 boxElement.offsetHeight 71279 ); 71280 const columnStart = getClosestTrack(gridColumnTracks, rect.left) + 1; 71281 const rowStart = getClosestTrack(gridRowTracks, rect.top) + 1; 71282 const columnEnd = getClosestTrack(gridColumnTracks, rect.right, "end") + 1; 71283 const rowEnd = getClosestTrack(gridRowTracks, rect.bottom, "end") + 1; 71284 onChange({ 71285 columnSpan: columnEnd - columnStart + 1, 71286 rowSpan: rowEnd - rowStart + 1, 71287 columnStart: isManualGrid ? columnStart : void 0, 71288 rowStart: isManualGrid ? rowStart : void 0 71289 }); 71290 } 71291 } 71292 ) 71293 } 71294 ); 71295 } 71296 71297 // packages/block-editor/build-module/components/grid/grid-item-movers.js 71298 var import_i18n232 = __toESM(require_i18n()); 71299 var import_components264 = __toESM(require_components()); 71300 var import_data185 = __toESM(require_data()); 71301 var import_compose102 = __toESM(require_compose()); 71302 var import_jsx_runtime448 = __toESM(require_jsx_runtime()); 71303 function GridItemMovers({ 71304 layout, 71305 parentLayout, 71306 onChange, 71307 gridClientId, 71308 blockClientId 71309 }) { 71310 const { moveBlocksToPosition: moveBlocksToPosition2, __unstableMarkNextChangeAsNotPersistent: __unstableMarkNextChangeAsNotPersistent2 } = (0, import_data185.useDispatch)(store); 71311 const columnStart = layout?.columnStart ?? 1; 71312 const rowStart = layout?.rowStart ?? 1; 71313 const columnSpan = layout?.columnSpan ?? 1; 71314 const rowSpan = layout?.rowSpan ?? 1; 71315 const columnEnd = columnStart + columnSpan - 1; 71316 const rowEnd = rowStart + rowSpan - 1; 71317 const columnCount = parentLayout?.columnCount; 71318 const rowCount = parentLayout?.rowCount; 71319 const getNumberOfBlocksBeforeCell = useGetNumberOfBlocksBeforeCell( 71320 gridClientId, 71321 columnCount 71322 ); 71323 return /* @__PURE__ */ (0, import_jsx_runtime448.jsx)(block_controls_default, { group: "parent", children: /* @__PURE__ */ (0, import_jsx_runtime448.jsxs)(import_components264.ToolbarGroup, { className: "block-editor-grid-item-mover__move-button-container", children: [ 71324 /* @__PURE__ */ (0, import_jsx_runtime448.jsx)("div", { className: "block-editor-grid-item-mover__move-horizontal-button-container is-left", children: /* @__PURE__ */ (0, import_jsx_runtime448.jsx)( 71325 GridItemMover, 71326 { 71327 icon: (0, import_i18n232.isRTL)() ? chevron_right_default : chevron_left_default, 71328 label: (0, import_i18n232.__)("Move left"), 71329 description: (0, import_i18n232.__)("Move left"), 71330 isDisabled: columnStart <= 1, 71331 onClick: () => { 71332 onChange({ 71333 columnStart: columnStart - 1 71334 }); 71335 __unstableMarkNextChangeAsNotPersistent2(); 71336 moveBlocksToPosition2( 71337 [blockClientId], 71338 gridClientId, 71339 gridClientId, 71340 getNumberOfBlocksBeforeCell( 71341 columnStart - 1, 71342 rowStart 71343 ) 71344 ); 71345 } 71346 } 71347 ) }), 71348 /* @__PURE__ */ (0, import_jsx_runtime448.jsxs)("div", { className: "block-editor-grid-item-mover__move-vertical-button-container", children: [ 71349 /* @__PURE__ */ (0, import_jsx_runtime448.jsx)( 71350 GridItemMover, 71351 { 71352 className: "is-up-button", 71353 icon: chevron_up_default, 71354 label: (0, import_i18n232.__)("Move up"), 71355 description: (0, import_i18n232.__)("Move up"), 71356 isDisabled: rowStart <= 1, 71357 onClick: () => { 71358 onChange({ 71359 rowStart: rowStart - 1 71360 }); 71361 __unstableMarkNextChangeAsNotPersistent2(); 71362 moveBlocksToPosition2( 71363 [blockClientId], 71364 gridClientId, 71365 gridClientId, 71366 getNumberOfBlocksBeforeCell( 71367 columnStart, 71368 rowStart - 1 71369 ) 71370 ); 71371 } 71372 } 71373 ), 71374 /* @__PURE__ */ (0, import_jsx_runtime448.jsx)( 71375 GridItemMover, 71376 { 71377 className: "is-down-button", 71378 icon: chevron_down_default, 71379 label: (0, import_i18n232.__)("Move down"), 71380 description: (0, import_i18n232.__)("Move down"), 71381 isDisabled: rowCount && rowEnd >= rowCount, 71382 onClick: () => { 71383 onChange({ 71384 rowStart: rowStart + 1 71385 }); 71386 __unstableMarkNextChangeAsNotPersistent2(); 71387 moveBlocksToPosition2( 71388 [blockClientId], 71389 gridClientId, 71390 gridClientId, 71391 getNumberOfBlocksBeforeCell( 71392 columnStart, 71393 rowStart + 1 71394 ) 71395 ); 71396 } 71397 } 71398 ) 71399 ] }), 71400 /* @__PURE__ */ (0, import_jsx_runtime448.jsx)("div", { className: "block-editor-grid-item-mover__move-horizontal-button-container is-right", children: /* @__PURE__ */ (0, import_jsx_runtime448.jsx)( 71401 GridItemMover, 71402 { 71403 icon: (0, import_i18n232.isRTL)() ? chevron_left_default : chevron_right_default, 71404 label: (0, import_i18n232.__)("Move right"), 71405 description: (0, import_i18n232.__)("Move right"), 71406 isDisabled: columnCount && columnEnd >= columnCount, 71407 onClick: () => { 71408 onChange({ 71409 columnStart: columnStart + 1 71410 }); 71411 __unstableMarkNextChangeAsNotPersistent2(); 71412 moveBlocksToPosition2( 71413 [blockClientId], 71414 gridClientId, 71415 gridClientId, 71416 getNumberOfBlocksBeforeCell( 71417 columnStart + 1, 71418 rowStart 71419 ) 71420 ); 71421 } 71422 } 71423 ) }) 71424 ] }) }); 71425 } 71426 function GridItemMover({ 71427 className, 71428 icon, 71429 label, 71430 isDisabled, 71431 onClick, 71432 description 71433 }) { 71434 const instanceId = (0, import_compose102.useInstanceId)(GridItemMover); 71435 const descriptionId = `block-editor-grid-item-mover-button__description-$instanceId}`; 71436 return /* @__PURE__ */ (0, import_jsx_runtime448.jsxs)(import_jsx_runtime448.Fragment, { children: [ 71437 /* @__PURE__ */ (0, import_jsx_runtime448.jsx)( 71438 import_components264.ToolbarButton, 71439 { 71440 className: clsx_default( 71441 "block-editor-grid-item-mover-button", 71442 className 71443 ), 71444 icon, 71445 label, 71446 "aria-describedby": descriptionId, 71447 onClick: isDisabled ? null : onClick, 71448 disabled: isDisabled, 71449 accessibleWhenDisabled: true 71450 } 71451 ), 71452 /* @__PURE__ */ (0, import_jsx_runtime448.jsx)(import_components264.VisuallyHidden, { id: descriptionId, children: description }) 71453 ] }); 71454 } 71455 71456 // packages/block-editor/build-module/components/grid/use-grid-layout-sync.js 71457 var import_data186 = __toESM(require_data()); 71458 var import_element262 = __toESM(require_element()); 71459 var import_compose103 = __toESM(require_compose()); 71460 function useGridLayoutSync({ clientId: gridClientId }) { 71461 const { gridLayout, blockOrder, selectedBlockLayout } = (0, import_data186.useSelect)( 71462 (select3) => { 71463 const { getBlockAttributes: getBlockAttributes22, getBlockOrder: getBlockOrder2 } = select3(store); 71464 const selectedBlock = select3(store).getSelectedBlock(); 71465 return { 71466 gridLayout: getBlockAttributes22(gridClientId).layout ?? {}, 71467 blockOrder: getBlockOrder2(gridClientId), 71468 selectedBlockLayout: selectedBlock?.attributes.style?.layout 71469 }; 71470 }, 71471 [gridClientId] 71472 ); 71473 const { getBlockAttributes: getBlockAttributes3, getBlockRootClientId: getBlockRootClientId2 } = (0, import_data186.useSelect)(store); 71474 const { updateBlockAttributes: updateBlockAttributes2, __unstableMarkNextChangeAsNotPersistent: __unstableMarkNextChangeAsNotPersistent2 } = (0, import_data186.useDispatch)(store); 71475 const selectedBlockRect = (0, import_element262.useMemo)( 71476 () => selectedBlockLayout ? new GridRect(selectedBlockLayout) : null, 71477 [selectedBlockLayout] 71478 ); 71479 const previouslySelectedBlockRect = (0, import_compose103.usePrevious)(selectedBlockRect); 71480 const previousIsManualPlacement = (0, import_compose103.usePrevious)( 71481 gridLayout.isManualPlacement 71482 ); 71483 const previousBlockOrder = (0, import_compose103.usePrevious)(blockOrder); 71484 (0, import_element262.useEffect)(() => { 71485 const updates = {}; 71486 if (gridLayout.isManualPlacement) { 71487 const occupiedRects = []; 71488 for (const clientId of blockOrder) { 71489 const { 71490 columnStart, 71491 rowStart, 71492 columnSpan = 1, 71493 rowSpan = 1 71494 } = getBlockAttributes3(clientId).style?.layout ?? {}; 71495 if (!columnStart || !rowStart) { 71496 continue; 71497 } 71498 occupiedRects.push( 71499 new GridRect({ 71500 columnStart, 71501 rowStart, 71502 columnSpan, 71503 rowSpan 71504 }) 71505 ); 71506 } 71507 for (const clientId of blockOrder) { 71508 const attributes = getBlockAttributes3(clientId); 71509 const { 71510 columnStart, 71511 rowStart, 71512 columnSpan = 1, 71513 rowSpan = 1 71514 } = attributes.style?.layout ?? {}; 71515 if (columnStart && rowStart) { 71516 continue; 71517 } 71518 const [newColumnStart, newRowStart] = placeBlock( 71519 occupiedRects, 71520 gridLayout.columnCount, 71521 columnSpan, 71522 rowSpan, 71523 previouslySelectedBlockRect?.columnEnd, 71524 previouslySelectedBlockRect?.rowEnd 71525 ); 71526 occupiedRects.push( 71527 new GridRect({ 71528 columnStart: newColumnStart, 71529 rowStart: newRowStart, 71530 columnSpan, 71531 rowSpan 71532 }) 71533 ); 71534 updates[clientId] = { 71535 style: { 71536 ...attributes.style, 71537 layout: { 71538 ...attributes.style?.layout, 71539 columnStart: newColumnStart, 71540 rowStart: newRowStart 71541 } 71542 } 71543 }; 71544 } 71545 const bottomMostRow = Math.max( 71546 ...occupiedRects.map((r3) => r3.rowEnd) 71547 ); 71548 if (!gridLayout.rowCount || gridLayout.rowCount < bottomMostRow) { 71549 updates[gridClientId] = { 71550 layout: { 71551 ...gridLayout, 71552 rowCount: bottomMostRow 71553 } 71554 }; 71555 } 71556 for (const clientId of previousBlockOrder ?? []) { 71557 if (!blockOrder.includes(clientId)) { 71558 const rootClientId = getBlockRootClientId2(clientId); 71559 if (rootClientId === null) { 71560 continue; 71561 } 71562 const rootAttributes = getBlockAttributes3(rootClientId); 71563 if (rootAttributes?.layout?.type === "grid") { 71564 continue; 71565 } 71566 const attributes = getBlockAttributes3(clientId); 71567 const { 71568 columnStart, 71569 rowStart, 71570 columnSpan, 71571 rowSpan, 71572 ...layout 71573 } = attributes.style?.layout ?? {}; 71574 if (columnStart || rowStart || columnSpan || rowSpan) { 71575 const hasEmptyLayoutAttribute = Object.keys(layout).length === 0; 71576 updates[clientId] = setImmutably( 71577 attributes, 71578 ["style", "layout"], 71579 hasEmptyLayoutAttribute ? void 0 : layout 71580 ); 71581 } 71582 } 71583 } 71584 } else { 71585 if (previousIsManualPlacement === true) { 71586 for (const clientId of blockOrder) { 71587 const attributes = getBlockAttributes3(clientId); 71588 const { columnStart, rowStart, ...layout } = attributes.style?.layout ?? {}; 71589 if (columnStart || rowStart) { 71590 const hasEmptyLayoutAttribute = Object.keys(layout).length === 0; 71591 updates[clientId] = setImmutably( 71592 attributes, 71593 ["style", "layout"], 71594 hasEmptyLayoutAttribute ? void 0 : layout 71595 ); 71596 } 71597 } 71598 } 71599 if (gridLayout.rowCount) { 71600 updates[gridClientId] = { 71601 layout: { 71602 ...gridLayout, 71603 rowCount: void 0 71604 } 71605 }; 71606 } 71607 } 71608 if (Object.keys(updates).length) { 71609 __unstableMarkNextChangeAsNotPersistent2(); 71610 updateBlockAttributes2( 71611 Object.keys(updates), 71612 updates, 71613 /* uniqueByBlock: */ 71614 true 71615 ); 71616 } 71617 }, [ 71618 // Actual deps to sync: 71619 gridClientId, 71620 gridLayout, 71621 previousBlockOrder, 71622 blockOrder, 71623 previouslySelectedBlockRect, 71624 previousIsManualPlacement, 71625 // These won't change, but the linter thinks they might: 71626 __unstableMarkNextChangeAsNotPersistent2, 71627 getBlockAttributes3, 71628 getBlockRootClientId2, 71629 updateBlockAttributes2 71630 ]); 71631 } 71632 function placeBlock(occupiedRects, gridColumnCount, blockColumnSpan, blockRowSpan, startColumn = 1, startRow = 1) { 71633 for (let row = startRow; ; row++) { 71634 for (let column = row === startRow ? startColumn : 1; column <= gridColumnCount; column++) { 71635 const candidateRect = new GridRect({ 71636 columnStart: column, 71637 rowStart: row, 71638 columnSpan: blockColumnSpan, 71639 rowSpan: blockRowSpan 71640 }); 71641 if (!occupiedRects.some( 71642 (r3) => r3.intersectsRect(candidateRect) 71643 )) { 71644 return [column, row]; 71645 } 71646 } 71647 } 71648 } 71649 71650 // packages/block-editor/build-module/hooks/layout-child.js 71651 var import_jsx_runtime449 = __toESM(require_jsx_runtime()); 71652 var LAYOUT_CHILD_BLOCK_PROPS_REFERENCE = {}; 71653 function useBlockPropsChildLayoutStyles({ style }) { 71654 const shouldRenderChildLayoutStyles = (0, import_data187.useSelect)((select3) => { 71655 return !select3(store).getSettings().disableLayoutStyles; 71656 }); 71657 const layout = style?.layout ?? {}; 71658 const { 71659 selfStretch, 71660 flexSize, 71661 columnStart, 71662 rowStart, 71663 columnSpan, 71664 rowSpan 71665 } = layout; 71666 const parentLayout = useLayout() || {}; 71667 const { columnCount, minimumColumnWidth } = parentLayout; 71668 const id = (0, import_compose104.useInstanceId)(LAYOUT_CHILD_BLOCK_PROPS_REFERENCE); 71669 const selector3 = `.wp-container-content-$id}`; 71670 if (true) { 71671 if (columnStart && typeof columnStart !== "number") { 71672 throw new Error("columnStart must be a number"); 71673 } 71674 if (rowStart && typeof rowStart !== "number") { 71675 throw new Error("rowStart must be a number"); 71676 } 71677 if (columnSpan && typeof columnSpan !== "number") { 71678 throw new Error("columnSpan must be a number"); 71679 } 71680 if (rowSpan && typeof rowSpan !== "number") { 71681 throw new Error("rowSpan must be a number"); 71682 } 71683 } 71684 let css = ""; 71685 if (shouldRenderChildLayoutStyles) { 71686 if (selfStretch === "fixed" && flexSize) { 71687 css = `$selector3} { 71688 flex-basis: $flexSize}; 71689 box-sizing: border-box; 71690 }`; 71691 } else if (selfStretch === "fill") { 71692 css = `$selector3} { 71693 flex-grow: 1; 71694 }`; 71695 } else if (columnStart && columnSpan) { 71696 css = `$selector3} { 71697 grid-column: $columnStart} / span $columnSpan}; 71698 }`; 71699 } else if (columnStart) { 71700 css = `$selector3} { 71701 grid-column: $columnStart}; 71702 }`; 71703 } else if (columnSpan) { 71704 css = `$selector3} { 71705 grid-column: span $columnSpan}; 71706 }`; 71707 } 71708 if (rowStart && rowSpan) { 71709 css += `$selector3} { 71710 grid-row: $rowStart} / span $rowSpan}; 71711 }`; 71712 } else if (rowStart) { 71713 css += `$selector3} { 71714 grid-row: $rowStart}; 71715 }`; 71716 } else if (rowSpan) { 71717 css += `$selector3} { 71718 grid-row: span $rowSpan}; 71719 }`; 71720 } 71721 if ((columnSpan || columnStart) && (minimumColumnWidth || !columnCount)) { 71722 let parentColumnValue = parseFloat(minimumColumnWidth); 71723 if (isNaN(parentColumnValue)) { 71724 parentColumnValue = 12; 71725 } 71726 let parentColumnUnit = minimumColumnWidth?.replace( 71727 parentColumnValue, 71728 "" 71729 ); 71730 if (!["px", "rem", "em"].includes(parentColumnUnit)) { 71731 parentColumnUnit = "rem"; 71732 } 71733 let numColsToBreakAt = 2; 71734 if (columnSpan && columnStart) { 71735 numColsToBreakAt = columnSpan + columnStart - 1; 71736 } else if (columnSpan) { 71737 numColsToBreakAt = columnSpan; 71738 } else { 71739 numColsToBreakAt = columnStart; 71740 } 71741 const defaultGapValue = parentColumnUnit === "px" ? 24 : 1.5; 71742 const containerQueryValue = numColsToBreakAt * parentColumnValue + (numColsToBreakAt - 1) * defaultGapValue; 71743 const minimumContainerQueryValue = parentColumnValue * 2 + defaultGapValue - 1; 71744 const gridColumnValue = columnSpan && columnSpan > 1 ? "1/-1" : "auto"; 71745 css += `@container (max-width: $Math.max( 71746 containerQueryValue, 71747 minimumContainerQueryValue 71748 )}$parentColumnUnit}) { 71749 $selector3} { 71750 grid-column: $gridColumnValue}; 71751 grid-row: auto; 71752 } 71753 }`; 71754 } 71755 } 71756 useStyleOverride({ css }); 71757 if (!css) { 71758 return; 71759 } 71760 return { className: `wp-container-content-$id}` }; 71761 } 71762 function ChildLayoutControlsPure({ clientId, style, setAttributes }) { 71763 const parentLayout = useLayout() || {}; 71764 const { 71765 type: parentLayoutType = "default", 71766 allowSizingOnChildren = false, 71767 isManualPlacement 71768 } = parentLayout; 71769 if (parentLayoutType !== "grid") { 71770 return null; 71771 } 71772 return /* @__PURE__ */ (0, import_jsx_runtime449.jsx)( 71773 GridTools, 71774 { 71775 clientId, 71776 style, 71777 setAttributes, 71778 allowSizingOnChildren, 71779 isManualPlacement, 71780 parentLayout 71781 } 71782 ); 71783 } 71784 function GridTools({ 71785 clientId, 71786 style, 71787 setAttributes, 71788 allowSizingOnChildren, 71789 isManualPlacement, 71790 parentLayout 71791 }) { 71792 const { rootClientId, isVisible } = (0, import_data187.useSelect)( 71793 (select3) => { 71794 const { 71795 getBlockRootClientId: getBlockRootClientId2, 71796 getBlockEditingMode: getBlockEditingMode2, 71797 getTemplateLock: getTemplateLock2 71798 } = select3(store); 71799 const _rootClientId = getBlockRootClientId2(clientId); 71800 if (getTemplateLock2(_rootClientId) || getBlockEditingMode2(_rootClientId) !== "default") { 71801 return { 71802 rootClientId: _rootClientId, 71803 isVisible: false 71804 }; 71805 } 71806 return { 71807 rootClientId: _rootClientId, 71808 isVisible: true 71809 }; 71810 }, 71811 [clientId] 71812 ); 71813 const [resizerBounds, setResizerBounds] = (0, import_element263.useState)(); 71814 if (!isVisible) { 71815 return null; 71816 } 71817 function updateLayout(layout) { 71818 setAttributes({ 71819 style: { 71820 ...style, 71821 layout: { 71822 ...style?.layout, 71823 ...layout 71824 } 71825 } 71826 }); 71827 } 71828 return /* @__PURE__ */ (0, import_jsx_runtime449.jsxs)(import_jsx_runtime449.Fragment, { children: [ 71829 /* @__PURE__ */ (0, import_jsx_runtime449.jsx)( 71830 GridVisualizer, 71831 { 71832 clientId: rootClientId, 71833 contentRef: setResizerBounds, 71834 parentLayout 71835 } 71836 ), 71837 allowSizingOnChildren && /* @__PURE__ */ (0, import_jsx_runtime449.jsx)( 71838 GridItemResizer, 71839 { 71840 clientId, 71841 bounds: resizerBounds, 71842 onChange: updateLayout, 71843 parentLayout 71844 } 71845 ), 71846 isManualPlacement && window.__experimentalEnableGridInteractivity && /* @__PURE__ */ (0, import_jsx_runtime449.jsx)( 71847 GridItemMovers, 71848 { 71849 layout: style?.layout, 71850 parentLayout, 71851 onChange: updateLayout, 71852 gridClientId: rootClientId, 71853 blockClientId: clientId 71854 } 71855 ) 71856 ] }); 71857 } 71858 var layout_child_default = { 71859 useBlockProps: useBlockPropsChildLayoutStyles, 71860 edit: ChildLayoutControlsPure, 71861 attributeKeys: ["style"], 71862 hasSupport() { 71863 return true; 71864 } 71865 }; 71866 71867 // packages/block-editor/build-module/hooks/content-lock-ui.js 71868 var import_components265 = __toESM(require_components()); 71869 var import_data188 = __toESM(require_data()); 71870 var import_i18n233 = __toESM(require_i18n()); 71871 var import_element264 = __toESM(require_element()); 71872 var import_jsx_runtime450 = __toESM(require_jsx_runtime()); 71873 function ContentLockControlsPure({ clientId }) { 71874 const { templateLock, isLockedByParent, isEditingContentOnlySection } = (0, import_data188.useSelect)( 71875 (select3) => { 71876 const { 71877 getContentLockingParent: getContentLockingParent2, 71878 getTemplateLock: getTemplateLock2, 71879 getEditedContentOnlySection: getEditedContentOnlySection2 71880 } = unlock(select3(store)); 71881 return { 71882 templateLock: getTemplateLock2(clientId), 71883 isLockedByParent: !!getContentLockingParent2(clientId), 71884 isEditingContentOnlySection: getEditedContentOnlySection2() === clientId 71885 }; 71886 }, 71887 [clientId] 71888 ); 71889 const { stopEditingContentOnlySection: stopEditingContentOnlySection2 } = unlock( 71890 (0, import_data188.useDispatch)(store) 71891 ); 71892 const isContentLocked = !isLockedByParent && templateLock === "contentOnly"; 71893 const stopEditingAsBlockCallback = (0, import_element264.useCallback)(() => { 71894 stopEditingContentOnlySection2(); 71895 }, [stopEditingContentOnlySection2]); 71896 if (window?.__experimentalContentOnlyPatternInsertion || !isContentLocked && !isEditingContentOnlySection) { 71897 return null; 71898 } 71899 return isEditingContentOnlySection && /* @__PURE__ */ (0, import_jsx_runtime450.jsx)(block_controls_default, { group: "other", children: /* @__PURE__ */ (0, import_jsx_runtime450.jsx)(import_components265.ToolbarButton, { onClick: stopEditingAsBlockCallback, children: (0, import_i18n233.__)("Done") }) }); 71900 } 71901 var content_lock_ui_default = { 71902 edit: ContentLockControlsPure, 71903 hasSupport() { 71904 return true; 71905 } 71906 }; 71907 71908 // packages/block-editor/build-module/hooks/metadata.js 71909 var import_hooks30 = __toESM(require_hooks()); 71910 var import_blocks115 = __toESM(require_blocks()); 71911 var META_ATTRIBUTE_NAME = "metadata"; 71912 function addMetaAttribute(blockTypeSettings) { 71913 if (blockTypeSettings?.attributes?.[META_ATTRIBUTE_NAME]?.type) { 71914 return blockTypeSettings; 71915 } 71916 blockTypeSettings.attributes = { 71917 ...blockTypeSettings.attributes, 71918 [META_ATTRIBUTE_NAME]: { 71919 type: "object" 71920 } 71921 }; 71922 return blockTypeSettings; 71923 } 71924 function addTransforms5(result, source, index, results) { 71925 if (results.length === 1 && result.innerBlocks.length === source.length) { 71926 return result; 71927 } 71928 if (results.length === 1 && source.length > 1 || results.length > 1 && source.length === 1) { 71929 return result; 71930 } 71931 if (results.length > 1 && source.length > 1 && results.length !== source.length) { 71932 return result; 71933 } 71934 const sourceMetadata = source[index]?.attributes?.metadata; 71935 if (!sourceMetadata) { 71936 return result; 71937 } 71938 const preservedMetadata = {}; 71939 if (sourceMetadata.noteId && !result.attributes?.metadata?.noteId) { 71940 preservedMetadata.noteId = sourceMetadata.noteId; 71941 } 71942 if (sourceMetadata.name && !result.attributes?.metadata?.name && (0, import_blocks115.hasBlockSupport)(result.name, "renaming", true)) { 71943 preservedMetadata.name = sourceMetadata.name; 71944 } 71945 if (sourceMetadata.blockVisibility !== void 0 && !result.attributes?.metadata?.blockVisibility && (0, import_blocks115.hasBlockSupport)(result.name, "visibility", true)) { 71946 preservedMetadata.blockVisibility = sourceMetadata.blockVisibility; 71947 } 71948 if (Object.keys(preservedMetadata).length > 0) { 71949 return { 71950 ...result, 71951 attributes: { 71952 ...result.attributes, 71953 metadata: { 71954 ...result.attributes.metadata, 71955 ...preservedMetadata 71956 } 71957 } 71958 }; 71959 } 71960 return result; 71961 } 71962 (0, import_hooks30.addFilter)( 71963 "blocks.registerBlockType", 71964 "core/metadata/addMetaAttribute", 71965 addMetaAttribute 71966 ); 71967 (0, import_hooks30.addFilter)( 71968 "blocks.switchToBlockType.transformedBlock", 71969 "core/metadata/addTransforms", 71970 addTransforms5 71971 ); 71972 71973 // packages/block-editor/build-module/hooks/block-hooks.js 71974 var import_i18n234 = __toESM(require_i18n()); 71975 var import_element265 = __toESM(require_element()); 71976 var import_components267 = __toESM(require_components()); 71977 var import_blocks116 = __toESM(require_blocks()); 71978 var import_data189 = __toESM(require_data()); 71979 var import_jsx_runtime451 = __toESM(require_jsx_runtime()); 71980 var EMPTY_OBJECT4 = {}; 71981 function BlockHooksControlPure({ 71982 name, 71983 clientId, 71984 metadata: { ignoredHookedBlocks = [] } = {} 71985 }) { 71986 const blockTypes = (0, import_data189.useSelect)( 71987 (select3) => select3(import_blocks116.store).getBlockTypes(), 71988 [] 71989 ); 71990 const hookedBlocksForCurrentBlock = (0, import_element265.useMemo)( 71991 () => blockTypes?.filter( 71992 ({ name: blockName, blockHooks }) => blockHooks && name in blockHooks || ignoredHookedBlocks.includes(blockName) 71993 ), 71994 [blockTypes, name, ignoredHookedBlocks] 71995 ); 71996 const hookedBlockClientIds = (0, import_data189.useSelect)( 71997 (select3) => { 71998 const { getBlocks: getBlocks2, getBlockRootClientId: getBlockRootClientId22, getGlobalBlockCount: getGlobalBlockCount2 } = select3(store); 71999 const rootClientId = getBlockRootClientId22(clientId); 72000 const _hookedBlockClientIds = hookedBlocksForCurrentBlock.reduce( 72001 (clientIds, block) => { 72002 if (getGlobalBlockCount2(block.name) === 0) { 72003 return clientIds; 72004 } 72005 const relativePosition = block?.blockHooks?.[name]; 72006 let candidates; 72007 switch (relativePosition) { 72008 case "before": 72009 case "after": 72010 candidates = getBlocks2(rootClientId); 72011 break; 72012 case "first_child": 72013 case "last_child": 72014 candidates = getBlocks2(clientId); 72015 break; 72016 case void 0: 72017 candidates = [ 72018 ...getBlocks2(rootClientId), 72019 ...getBlocks2(clientId) 72020 ]; 72021 break; 72022 } 72023 const hookedBlock = candidates?.find( 72024 (candidate) => candidate.name === block.name 72025 ); 72026 if (hookedBlock) { 72027 return { 72028 ...clientIds, 72029 [block.name]: hookedBlock.clientId 72030 }; 72031 } 72032 return clientIds; 72033 }, 72034 {} 72035 ); 72036 if (Object.values(_hookedBlockClientIds).length > 0) { 72037 return _hookedBlockClientIds; 72038 } 72039 return EMPTY_OBJECT4; 72040 }, 72041 [hookedBlocksForCurrentBlock, name, clientId] 72042 ); 72043 const { getBlockIndex: getBlockIndex2, getBlockCount: getBlockCount2, getBlockRootClientId: getBlockRootClientId2 } = (0, import_data189.useSelect)(store); 72044 const { insertBlock: insertBlock2, removeBlock: removeBlock2 } = (0, import_data189.useDispatch)(store); 72045 if (!hookedBlocksForCurrentBlock.length) { 72046 return null; 72047 } 72048 const groupedHookedBlocks = hookedBlocksForCurrentBlock.reduce( 72049 (groups3, block) => { 72050 const [namespace] = block.name.split("/"); 72051 if (!groups3[namespace]) { 72052 groups3[namespace] = []; 72053 } 72054 groups3[namespace].push(block); 72055 return groups3; 72056 }, 72057 {} 72058 ); 72059 const insertBlockIntoDesignatedLocation = (block, relativePosition) => { 72060 const blockIndex = getBlockIndex2(clientId); 72061 const innerBlocksLength = getBlockCount2(clientId); 72062 const rootClientId = getBlockRootClientId2(clientId); 72063 switch (relativePosition) { 72064 case "before": 72065 case "after": 72066 insertBlock2( 72067 block, 72068 relativePosition === "after" ? blockIndex + 1 : blockIndex, 72069 rootClientId, 72070 // Insert as a child of the current block's parent 72071 false 72072 ); 72073 break; 72074 case "first_child": 72075 case "last_child": 72076 insertBlock2( 72077 block, 72078 // TODO: It'd be great if insertBlock() would accept negative indices for insertion. 72079 relativePosition === "first_child" ? 0 : innerBlocksLength, 72080 clientId, 72081 // Insert as a child of the current block. 72082 false 72083 ); 72084 break; 72085 case void 0: 72086 insertBlock2( 72087 block, 72088 blockIndex + 1, 72089 rootClientId, 72090 // Insert as a child of the current block's parent 72091 false 72092 ); 72093 break; 72094 } 72095 }; 72096 return /* @__PURE__ */ (0, import_jsx_runtime451.jsx)(inspector_controls_default, { children: /* @__PURE__ */ (0, import_jsx_runtime451.jsxs)( 72097 import_components267.PanelBody, 72098 { 72099 className: "block-editor-hooks__block-hooks", 72100 title: (0, import_i18n234.__)("Plugins"), 72101 initialOpen: true, 72102 children: [ 72103 /* @__PURE__ */ (0, import_jsx_runtime451.jsx)("p", { className: "block-editor-hooks__block-hooks-helptext", children: (0, import_i18n234.__)( 72104 "Manage the inclusion of blocks added automatically by plugins." 72105 ) }), 72106 Object.keys(groupedHookedBlocks).map((vendor) => { 72107 return /* @__PURE__ */ (0, import_jsx_runtime451.jsxs)(import_element265.Fragment, { children: [ 72108 /* @__PURE__ */ (0, import_jsx_runtime451.jsx)("h3", { children: vendor }), 72109 groupedHookedBlocks[vendor].map((block) => { 72110 const checked = block.name in hookedBlockClientIds; 72111 return /* @__PURE__ */ (0, import_jsx_runtime451.jsx)( 72112 import_components267.ToggleControl, 72113 { 72114 checked, 72115 label: block.title, 72116 onChange: () => { 72117 if (!checked) { 72118 const relativePosition = block.blockHooks[name]; 72119 insertBlockIntoDesignatedLocation( 72120 (0, import_blocks116.createBlock)(block.name), 72121 relativePosition 72122 ); 72123 return; 72124 } 72125 removeBlock2( 72126 hookedBlockClientIds[block.name], 72127 false 72128 ); 72129 } 72130 }, 72131 block.title 72132 ); 72133 }) 72134 ] }, vendor); 72135 }) 72136 ] 72137 } 72138 ) }); 72139 } 72140 var block_hooks_default = { 72141 edit: BlockHooksControlPure, 72142 attributeKeys: ["metadata"], 72143 hasSupport() { 72144 return true; 72145 } 72146 }; 72147 72148 // packages/block-editor/build-module/hooks/block-bindings.js 72149 var import_i18n235 = __toESM(require_i18n()); 72150 var import_blocks117 = __toESM(require_blocks()); 72151 var import_components269 = __toESM(require_components()); 72152 var import_data190 = __toESM(require_data()); 72153 var import_element266 = __toESM(require_element()); 72154 var import_compose105 = __toESM(require_compose()); 72155 var import_jsx_runtime452 = __toESM(require_jsx_runtime()); 72156 var useToolsPanelDropdownMenuProps2 = () => { 72157 const isMobile = (0, import_compose105.useViewportMatch)("medium", "<"); 72158 return !isMobile ? { 72159 popoverProps: { 72160 placement: "left-start", 72161 // For non-mobile, inner sidebar width (248px) - button width (24px) - border (1px) + padding (16px) + spacing (20px) 72162 offset: 259 72163 } 72164 } : {}; 72165 }; 72166 var BlockBindingsPanel = ({ name: blockName, metadata }) => { 72167 const blockContext = (0, import_element266.useContext)(block_context_default); 72168 const { removeAllBlockBindings } = useBlockBindingsUtils(); 72169 const dropdownMenuProps = useToolsPanelDropdownMenuProps2(); 72170 const { bindableAttributes, hasCompatibleFields } = (0, import_data190.useSelect)( 72171 (select3) => { 72172 const { __experimentalBlockBindingsSupportedAttributes } = select3(store).getSettings(); 72173 const { 72174 getAllBlockBindingsSources, 72175 getBlockBindingsSourceFieldsList 72176 } = unlock(select3(import_blocks117.store)); 72177 return { 72178 bindableAttributes: __experimentalBlockBindingsSupportedAttributes?.[blockName], 72179 hasCompatibleFields: Object.values( 72180 getAllBlockBindingsSources() 72181 ).some( 72182 (source) => getBlockBindingsSourceFieldsList(source, blockContext)?.length > 0 72183 ) 72184 }; 72185 }, 72186 [blockName, blockContext] 72187 ); 72188 if (!bindableAttributes || bindableAttributes.length === 0) { 72189 return null; 72190 } 72191 const { bindings } = metadata || {}; 72192 if (bindings === void 0 && !hasCompatibleFields) { 72193 return null; 72194 } 72195 return /* @__PURE__ */ (0, import_jsx_runtime452.jsx)(inspector_controls_default, { group: "bindings", children: /* @__PURE__ */ (0, import_jsx_runtime452.jsxs)( 72196 import_components269.__experimentalToolsPanel, 72197 { 72198 label: (0, import_i18n235.__)("Attributes"), 72199 resetAll: () => { 72200 removeAllBlockBindings(); 72201 }, 72202 dropdownMenuProps, 72203 className: "block-editor-bindings__panel", 72204 children: [ 72205 /* @__PURE__ */ (0, import_jsx_runtime452.jsx)(import_components269.__experimentalItemGroup, { isBordered: true, isSeparated: true, children: bindableAttributes.map((attribute) => /* @__PURE__ */ (0, import_jsx_runtime452.jsx)( 72206 BlockBindingsAttributeControl, 72207 { 72208 attribute, 72209 blockName, 72210 binding: bindings?.[attribute] 72211 }, 72212 attribute 72213 )) }), 72214 /* @__PURE__ */ (0, import_jsx_runtime452.jsx)(import_components269.__experimentalText, { as: "div", variant: "muted", children: /* @__PURE__ */ (0, import_jsx_runtime452.jsx)("p", { children: (0, import_i18n235.__)( 72215 "Attributes connected to custom fields or other dynamic data." 72216 ) }) }) 72217 ] 72218 } 72219 ) }); 72220 }; 72221 var block_bindings_default = { 72222 edit: BlockBindingsPanel, 72223 attributeKeys: ["metadata"], 72224 hasSupport(name) { 72225 return ![ 72226 "core/post-date", 72227 "core/navigation-link", 72228 "core/navigation-submenu" 72229 ].includes(name); 72230 } 72231 }; 72232 72233 // packages/block-editor/build-module/hooks/block-renaming.js 72234 var import_hooks31 = __toESM(require_hooks()); 72235 var import_blocks118 = __toESM(require_blocks()); 72236 function addLabelCallback(settings2) { 72237 if (settings2.__experimentalLabel) { 72238 return settings2; 72239 } 72240 const supportsBlockNaming = (0, import_blocks118.hasBlockSupport)( 72241 settings2, 72242 "renaming", 72243 true 72244 // default value 72245 ); 72246 if (supportsBlockNaming) { 72247 settings2.__experimentalLabel = (attributes, { context }) => { 72248 const { metadata } = attributes; 72249 if (context === "list-view" && metadata?.name) { 72250 return metadata.name; 72251 } 72252 }; 72253 } 72254 return settings2; 72255 } 72256 (0, import_hooks31.addFilter)( 72257 "blocks.registerBlockType", 72258 "core/metadata/addLabelCallback", 72259 addLabelCallback 72260 ); 72261 72262 // packages/block-editor/build-module/hooks/grid-visualizer.js 72263 var import_compose106 = __toESM(require_compose()); 72264 var import_hooks32 = __toESM(require_hooks()); 72265 var import_data191 = __toESM(require_data()); 72266 var import_jsx_runtime453 = __toESM(require_jsx_runtime()); 72267 function GridLayoutSync(props) { 72268 useGridLayoutSync(props); 72269 } 72270 function GridTools2({ clientId, layout }) { 72271 const isVisible = (0, import_data191.useSelect)( 72272 (select3) => { 72273 const { 72274 isBlockSelected: isBlockSelected2, 72275 isDraggingBlocks: isDraggingBlocks2, 72276 getTemplateLock: getTemplateLock2, 72277 getBlockEditingMode: getBlockEditingMode2 72278 } = select3(store); 72279 if (!isDraggingBlocks2() && !isBlockSelected2(clientId) || getTemplateLock2(clientId) || getBlockEditingMode2(clientId) !== "default") { 72280 return false; 72281 } 72282 return true; 72283 }, 72284 [clientId] 72285 ); 72286 return /* @__PURE__ */ (0, import_jsx_runtime453.jsxs)(import_jsx_runtime453.Fragment, { children: [ 72287 /* @__PURE__ */ (0, import_jsx_runtime453.jsx)(GridLayoutSync, { clientId }), 72288 isVisible && /* @__PURE__ */ (0, import_jsx_runtime453.jsx)(GridVisualizer, { clientId, parentLayout: layout }) 72289 ] }); 72290 } 72291 var addGridVisualizerToBlockEdit = (0, import_compose106.createHigherOrderComponent)( 72292 (BlockEdit2) => (props) => { 72293 if (props.attributes.layout?.type !== "grid") { 72294 return /* @__PURE__ */ (0, import_jsx_runtime453.jsx)(BlockEdit2, { ...props }, "edit"); 72295 } 72296 return /* @__PURE__ */ (0, import_jsx_runtime453.jsxs)(import_jsx_runtime453.Fragment, { children: [ 72297 /* @__PURE__ */ (0, import_jsx_runtime453.jsx)( 72298 GridTools2, 72299 { 72300 clientId: props.clientId, 72301 layout: props.attributes.layout 72302 } 72303 ), 72304 /* @__PURE__ */ (0, import_jsx_runtime453.jsx)(BlockEdit2, { ...props }, "edit") 72305 ] }); 72306 }, 72307 "addGridVisualizerToBlockEdit" 72308 ); 72309 (0, import_hooks32.addFilter)( 72310 "editor.BlockEdit", 72311 "core/editor/grid-visualizer", 72312 addGridVisualizerToBlockEdit 72313 ); 72314 72315 // packages/block-editor/build-module/hooks/use-border-props.js 72316 function getBorderClassesAndStyles(attributes) { 72317 const border = attributes.style?.border || {}; 72318 const className = getBorderClasses(attributes); 72319 return { 72320 className: className || void 0, 72321 style: getInlineStyles({ border }) 72322 }; 72323 } 72324 function useBorderProps(attributes) { 72325 const { colors: colors2 } = useMultipleOriginColorsAndGradients(); 72326 const borderProps = getBorderClassesAndStyles(attributes); 72327 const { borderColor } = attributes; 72328 if (borderColor) { 72329 const borderColorObject = getMultiOriginColor({ 72330 colors: colors2, 72331 namedColor: borderColor 72332 }); 72333 borderProps.style.borderColor = borderColorObject.color; 72334 } 72335 return borderProps; 72336 } 72337 72338 // packages/block-editor/build-module/hooks/use-shadow-props.js 72339 function getShadowClassesAndStyles(attributes) { 72340 const shadow = attributes.style?.shadow || ""; 72341 return { 72342 style: getInlineStyles({ shadow }) 72343 }; 72344 } 72345 72346 // packages/block-editor/build-module/hooks/use-color-props.js 72347 var import_element267 = __toESM(require_element()); 72348 function getColorClassesAndStyles(attributes) { 72349 const { backgroundColor, textColor, gradient, style } = attributes; 72350 const backgroundClass = getColorClassName( 72351 "background-color", 72352 backgroundColor 72353 ); 72354 const textClass = getColorClassName("color", textColor); 72355 const gradientClass = __experimentalGetGradientClass(gradient); 72356 const hasGradient = gradientClass || style?.color?.gradient; 72357 const className = clsx_default(textClass, gradientClass, { 72358 // Don't apply the background class if there's a gradient. 72359 [backgroundClass]: !hasGradient && !!backgroundClass, 72360 "has-text-color": textColor || style?.color?.text, 72361 "has-background": backgroundColor || style?.color?.background || gradient || style?.color?.gradient, 72362 "has-link-color": style?.elements?.link?.color 72363 }); 72364 const colorStyles = style?.color || {}; 72365 const styleProp = getInlineStyles({ color: colorStyles }); 72366 return { 72367 className: className || void 0, 72368 style: styleProp 72369 }; 72370 } 72371 function useColorProps(attributes) { 72372 const { backgroundColor, textColor, gradient } = attributes; 72373 const [ 72374 userPalette, 72375 themePalette, 72376 defaultPalette, 72377 userGradients, 72378 themeGradients, 72379 defaultGradients 72380 ] = useSettings( 72381 "color.palette.custom", 72382 "color.palette.theme", 72383 "color.palette.default", 72384 "color.gradients.custom", 72385 "color.gradients.theme", 72386 "color.gradients.default" 72387 ); 72388 const colors2 = (0, import_element267.useMemo)( 72389 () => [ 72390 ...userPalette || [], 72391 ...themePalette || [], 72392 ...defaultPalette || [] 72393 ], 72394 [userPalette, themePalette, defaultPalette] 72395 ); 72396 const gradients = (0, import_element267.useMemo)( 72397 () => [ 72398 ...userGradients || [], 72399 ...themeGradients || [], 72400 ...defaultGradients || [] 72401 ], 72402 [userGradients, themeGradients, defaultGradients] 72403 ); 72404 const colorProps = getColorClassesAndStyles(attributes); 72405 if (backgroundColor) { 72406 const backgroundColorObject = getColorObjectByAttributeValues( 72407 colors2, 72408 backgroundColor 72409 ); 72410 colorProps.style.backgroundColor = backgroundColorObject.color; 72411 } 72412 if (gradient) { 72413 colorProps.style.background = getGradientValueBySlug( 72414 gradients, 72415 gradient 72416 ); 72417 } 72418 if (textColor) { 72419 const textColorObject = getColorObjectByAttributeValues( 72420 colors2, 72421 textColor 72422 ); 72423 colorProps.style.color = textColorObject.color; 72424 } 72425 return colorProps; 72426 } 72427 72428 // packages/block-editor/build-module/hooks/use-spacing-props.js 72429 function getSpacingClassesAndStyles(attributes) { 72430 const { style } = attributes; 72431 const spacingStyles = style?.spacing || {}; 72432 const styleProp = getInlineStyles({ spacing: spacingStyles }); 72433 return { 72434 style: styleProp 72435 }; 72436 } 72437 72438 // packages/block-editor/build-module/hooks/use-typography-props.js 72439 var import_components270 = __toESM(require_components()); 72440 var { kebabCase: kebabCase7 } = unlock(import_components270.privateApis); 72441 function getTypographyClassesAndStyles(attributes, settings2) { 72442 let typographyStyles = attributes?.style?.typography || {}; 72443 typographyStyles = { 72444 ...typographyStyles, 72445 fontSize: getTypographyFontSizeValue( 72446 { size: attributes?.style?.typography?.fontSize }, 72447 settings2 72448 ) 72449 }; 72450 const style = getInlineStyles({ typography: typographyStyles }); 72451 const fontFamilyClassName = !!attributes?.fontFamily ? `has-$kebabCase7(attributes.fontFamily)}-font-family` : ""; 72452 const textAlignClassName = !!attributes?.style?.typography?.textAlign ? `has-text-align-$attributes?.style?.typography?.textAlign}` : ""; 72453 const className = clsx_default( 72454 fontFamilyClassName, 72455 textAlignClassName, 72456 getFontSizeClass(attributes?.fontSize) 72457 ); 72458 return { 72459 className, 72460 style 72461 }; 72462 } 72463 72464 // packages/block-editor/build-module/hooks/use-cached-truthy.js 72465 var import_element268 = __toESM(require_element()); 72466 function useCachedTruthy(value) { 72467 const [cachedValue, setCachedValue] = (0, import_element268.useState)(value); 72468 (0, import_element268.useEffect)(() => { 72469 if (value) { 72470 setCachedValue(value); 72471 } 72472 }, [value]); 72473 return cachedValue; 72474 } 72475 72476 // packages/block-editor/build-module/hooks/index.js 72477 createBlockEditFilter( 72478 [ 72479 align_default, 72480 text_align_default, 72481 anchor_default, 72482 custom_class_name_default, 72483 style_default, 72484 duotone_default, 72485 fit_text_default, 72486 position_default, 72487 layout_default2, 72488 content_lock_ui_default, 72489 block_hooks_default, 72490 block_bindings_default, 72491 layout_child_default, 72492 allowed_blocks_default 72493 ].filter(Boolean) 72494 ); 72495 createBlockListBlockFilter([ 72496 align_default, 72497 text_align_default, 72498 background_default, 72499 style_default, 72500 color_default, 72501 dimensions_default, 72502 duotone_default, 72503 font_family_default, 72504 font_size_default, 72505 fit_text_default, 72506 border_default, 72507 position_default, 72508 block_style_variation_default, 72509 layout_child_default 72510 ]); 72511 createBlockSaveFilter([ 72512 align_default, 72513 text_align_default, 72514 anchor_default, 72515 aria_label_default, 72516 custom_class_name_default, 72517 border_default, 72518 fit_text_default, 72519 color_default, 72520 style_default, 72521 font_family_default, 72522 font_size_default 72523 ]); 72524 72525 // packages/block-editor/build-module/elements/index.js 72526 var ELEMENT_CLASS_NAMES2 = { 72527 button: "wp-element-button", 72528 caption: "wp-element-caption" 72529 }; 72530 var __experimentalGetElementClassName = (element) => { 72531 return ELEMENT_CLASS_NAMES2[element] ? ELEMENT_CLASS_NAMES2[element] : ""; 72532 }; 72533 72534 // packages/block-editor/build-module/utils/get-px-from-css-unit.js 72535 var get_px_from_css_unit_default = () => ""; 72536 72537 // packages/block-editor/build-module/components/rich-text/get-rich-text-values.js 72538 var import_element269 = __toESM(require_element()); 72539 var import_blocks119 = __toESM(require_blocks()); 72540 var import_rich_text21 = __toESM(require_rich_text()); 72541 var import_jsx_runtime454 = __toESM(require_jsx_runtime()); 72542 function addValuesForElement(element, values, innerBlocks) { 72543 if (null === element || void 0 === element || false === element) { 72544 return; 72545 } 72546 if (Array.isArray(element)) { 72547 return addValuesForElements(element, values, innerBlocks); 72548 } 72549 switch (typeof element) { 72550 case "string": 72551 case "number": 72552 return; 72553 } 72554 const { type, props } = element; 72555 switch (type) { 72556 case import_element269.StrictMode: 72557 case import_element269.Fragment: 72558 return addValuesForElements(props.children, values, innerBlocks); 72559 case import_element269.RawHTML: 72560 return; 72561 case inner_blocks_default.Content: 72562 return addValuesForBlocks(values, innerBlocks); 72563 case Content: 72564 values.push(props.value); 72565 return; 72566 } 72567 switch (typeof type) { 72568 case "string": 72569 if (typeof props.children !== "undefined") { 72570 return addValuesForElements( 72571 props.children, 72572 values, 72573 innerBlocks 72574 ); 72575 } 72576 return; 72577 case "function": 72578 const el = type.prototype && typeof type.prototype.render === "function" ? new type(props).render() : type(props); 72579 return addValuesForElement(el, values, innerBlocks); 72580 } 72581 } 72582 function addValuesForElements(children, ...args) { 72583 children = Array.isArray(children) ? children : [children]; 72584 for (let i2 = 0; i2 < children.length; i2++) { 72585 addValuesForElement(children[i2], ...args); 72586 } 72587 } 72588 function addValuesForBlocks(values, blocks2) { 72589 for (let i2 = 0; i2 < blocks2.length; i2++) { 72590 const { name, attributes, innerBlocks } = blocks2[i2]; 72591 const saveElement = (0, import_blocks119.getSaveElement)( 72592 name, 72593 attributes, 72594 // Instead of letting save elements use `useInnerBlocksProps.save`, 72595 // force them to use InnerBlocks.Content instead so we can intercept 72596 // a single component. 72597 /* @__PURE__ */ (0, import_jsx_runtime454.jsx)(inner_blocks_default.Content, {}) 72598 ); 72599 addValuesForElement(saveElement, values, innerBlocks); 72600 } 72601 } 72602 function getRichTextValues(blocks2 = []) { 72603 import_blocks119.__unstableGetBlockProps.skipFilters = true; 72604 const values = []; 72605 addValuesForBlocks(values, blocks2); 72606 import_blocks119.__unstableGetBlockProps.skipFilters = false; 72607 return values.map( 72608 (value) => value instanceof import_rich_text21.RichTextData ? value : import_rich_text21.RichTextData.fromHTMLString(value) 72609 ); 72610 } 72611 72612 // packages/block-editor/build-module/components/resizable-box-popover/index.js 72613 var import_components271 = __toESM(require_components()); 72614 var import_jsx_runtime455 = __toESM(require_jsx_runtime()); 72615 function ResizableBoxPopover({ 72616 clientId, 72617 resizableBoxProps, 72618 ...props 72619 }) { 72620 return /* @__PURE__ */ (0, import_jsx_runtime455.jsx)( 72621 cover_default, 72622 { 72623 clientId, 72624 __unstablePopoverSlot: "block-toolbar", 72625 ...props, 72626 children: /* @__PURE__ */ (0, import_jsx_runtime455.jsx)(import_components271.ResizableBox, { ...resizableBoxProps }) 72627 } 72628 ); 72629 } 72630 72631 // packages/block-editor/build-module/components/block-removal-warning-modal/index.js 72632 var import_element270 = __toESM(require_element()); 72633 var import_data192 = __toESM(require_data()); 72634 var import_components272 = __toESM(require_components()); 72635 var import_i18n236 = __toESM(require_i18n()); 72636 var import_jsx_runtime456 = __toESM(require_jsx_runtime()); 72637 function BlockRemovalWarningModal({ rules }) { 72638 const { clientIds, selectPrevious, message: message2 } = (0, import_data192.useSelect)( 72639 (select3) => unlock(select3(store)).getRemovalPromptData() 72640 ); 72641 const { 72642 clearBlockRemovalPrompt: clearBlockRemovalPrompt2, 72643 setBlockRemovalRules: setBlockRemovalRules2, 72644 privateRemoveBlocks: privateRemoveBlocks2 72645 } = unlock((0, import_data192.useDispatch)(store)); 72646 (0, import_element270.useEffect)(() => { 72647 setBlockRemovalRules2(rules); 72648 return () => { 72649 setBlockRemovalRules2(); 72650 }; 72651 }, [rules, setBlockRemovalRules2]); 72652 if (!message2) { 72653 return; 72654 } 72655 const onConfirmRemoval = () => { 72656 privateRemoveBlocks2( 72657 clientIds, 72658 selectPrevious, 72659 /* force */ 72660 true 72661 ); 72662 clearBlockRemovalPrompt2(); 72663 }; 72664 return /* @__PURE__ */ (0, import_jsx_runtime456.jsxs)( 72665 import_components272.Modal, 72666 { 72667 title: (0, import_i18n236.__)("Be careful!"), 72668 onRequestClose: clearBlockRemovalPrompt2, 72669 size: "medium", 72670 children: [ 72671 /* @__PURE__ */ (0, import_jsx_runtime456.jsx)("p", { children: message2 }), 72672 /* @__PURE__ */ (0, import_jsx_runtime456.jsxs)(import_components272.__experimentalHStack, { justify: "right", children: [ 72673 /* @__PURE__ */ (0, import_jsx_runtime456.jsx)( 72674 import_components272.Button, 72675 { 72676 variant: "tertiary", 72677 onClick: clearBlockRemovalPrompt2, 72678 __next40pxDefaultSize: true, 72679 children: (0, import_i18n236.__)("Cancel") 72680 } 72681 ), 72682 /* @__PURE__ */ (0, import_jsx_runtime456.jsx)( 72683 import_components272.Button, 72684 { 72685 variant: "primary", 72686 onClick: onConfirmRemoval, 72687 __next40pxDefaultSize: true, 72688 children: (0, import_i18n236.__)("Delete") 72689 } 72690 ) 72691 ] }) 72692 ] 72693 } 72694 ); 72695 } 72696 72697 // packages/block-editor/build-module/components/dimensions-tool/index.js 72698 var import_element272 = __toESM(require_element()); 72699 72700 // packages/block-editor/build-module/components/dimensions-tool/scale-tool.js 72701 var import_components273 = __toESM(require_components()); 72702 var import_element271 = __toESM(require_element()); 72703 var import_i18n237 = __toESM(require_i18n()); 72704 var import_jsx_runtime457 = __toESM(require_jsx_runtime()); 72705 var DEFAULT_SCALE_OPTIONS = [ 72706 { 72707 value: "fill", 72708 label: (0, import_i18n237._x)("Fill", "Scale option for dimensions control"), 72709 help: (0, import_i18n237.__)("Fill the space by stretching the content.") 72710 }, 72711 { 72712 value: "contain", 72713 label: (0, import_i18n237._x)("Contain", "Scale option for dimensions control"), 72714 help: (0, import_i18n237.__)("Fit the content to the space without clipping.") 72715 }, 72716 { 72717 value: "cover", 72718 label: (0, import_i18n237._x)("Cover", "Scale option for dimensions control"), 72719 help: (0, import_i18n237.__)("Fill the space by clipping what doesn't fit.") 72720 }, 72721 { 72722 value: "none", 72723 label: (0, import_i18n237._x)("None", "Scale option for dimensions control"), 72724 help: (0, import_i18n237.__)( 72725 "Do not adjust the sizing of the content. Content that is too large will be clipped, and content that is too small will have additional padding." 72726 ) 72727 }, 72728 { 72729 value: "scale-down", 72730 label: (0, import_i18n237._x)("Scale down", "Scale option for dimensions control"), 72731 help: (0, import_i18n237.__)( 72732 "Scale down the content to fit the space if it is too big. Content that is too small will have additional padding." 72733 ) 72734 } 72735 ]; 72736 function ScaleTool({ 72737 panelId, 72738 value, 72739 onChange, 72740 options = DEFAULT_SCALE_OPTIONS, 72741 defaultValue = DEFAULT_SCALE_OPTIONS[0].value, 72742 isShownByDefault = true 72743 }) { 72744 const displayValue = value ?? "fill"; 72745 const scaleHelp = (0, import_element271.useMemo)(() => { 72746 return options.reduce((acc, option) => { 72747 acc[option.value] = option.help; 72748 return acc; 72749 }, {}); 72750 }, [options]); 72751 return /* @__PURE__ */ (0, import_jsx_runtime457.jsx)( 72752 import_components273.__experimentalToolsPanelItem, 72753 { 72754 label: (0, import_i18n237.__)("Scale"), 72755 isShownByDefault, 72756 hasValue: () => displayValue !== defaultValue, 72757 onDeselect: () => onChange(defaultValue), 72758 panelId, 72759 children: /* @__PURE__ */ (0, import_jsx_runtime457.jsx)( 72760 import_components273.__experimentalToggleGroupControl, 72761 { 72762 label: (0, import_i18n237.__)("Scale"), 72763 isBlock: true, 72764 help: scaleHelp[displayValue], 72765 value: displayValue, 72766 onChange, 72767 size: "__unstable-large", 72768 children: options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime457.jsx)( 72769 import_components273.__experimentalToggleGroupControlOption, 72770 { 72771 ...option 72772 }, 72773 option.value 72774 )) 72775 } 72776 ) 72777 } 72778 ); 72779 } 72780 72781 // packages/block-editor/build-module/components/dimensions-tool/width-height-tool.js 72782 var import_components274 = __toESM(require_components()); 72783 var import_i18n238 = __toESM(require_i18n()); 72784 var import_jsx_runtime458 = __toESM(require_jsx_runtime()); 72785 function WidthHeightTool({ 72786 panelId, 72787 value = {}, 72788 onChange = () => { 72789 }, 72790 units: units2, 72791 isShownByDefault = true 72792 }) { 72793 const width = value.width === "auto" ? "" : value.width ?? ""; 72794 const height = value.height === "auto" ? "" : value.height ?? ""; 72795 const onDimensionChange = (dimension) => (nextDimension) => { 72796 const nextValue = { ...value }; 72797 if (!nextDimension) { 72798 delete nextValue[dimension]; 72799 } else { 72800 nextValue[dimension] = nextDimension; 72801 } 72802 onChange(nextValue); 72803 }; 72804 return /* @__PURE__ */ (0, import_jsx_runtime458.jsxs)(import_jsx_runtime458.Fragment, { children: [ 72805 /* @__PURE__ */ (0, import_jsx_runtime458.jsx)( 72806 import_components274.__experimentalToolsPanelItem, 72807 { 72808 style: { gridColumn: "span 1" }, 72809 label: (0, import_i18n238.__)("Width"), 72810 isShownByDefault, 72811 hasValue: () => width !== "", 72812 onDeselect: onDimensionChange("width"), 72813 panelId, 72814 children: /* @__PURE__ */ (0, import_jsx_runtime458.jsx)( 72815 import_components274.__experimentalUnitControl, 72816 { 72817 label: (0, import_i18n238.__)("Width"), 72818 placeholder: (0, import_i18n238.__)("Auto"), 72819 labelPosition: "top", 72820 units: units2, 72821 min: 0, 72822 value: width, 72823 onChange: onDimensionChange("width"), 72824 size: "__unstable-large" 72825 } 72826 ) 72827 } 72828 ), 72829 /* @__PURE__ */ (0, import_jsx_runtime458.jsx)( 72830 import_components274.__experimentalToolsPanelItem, 72831 { 72832 style: { gridColumn: "span 1" }, 72833 label: (0, import_i18n238.__)("Height"), 72834 isShownByDefault, 72835 hasValue: () => height !== "", 72836 onDeselect: onDimensionChange("height"), 72837 panelId, 72838 children: /* @__PURE__ */ (0, import_jsx_runtime458.jsx)( 72839 import_components274.__experimentalUnitControl, 72840 { 72841 label: (0, import_i18n238.__)("Height"), 72842 placeholder: (0, import_i18n238.__)("Auto"), 72843 labelPosition: "top", 72844 units: units2, 72845 min: 0, 72846 value: height, 72847 onChange: onDimensionChange("height"), 72848 size: "__unstable-large" 72849 } 72850 ) 72851 } 72852 ) 72853 ] }); 72854 } 72855 72856 // packages/block-editor/build-module/components/dimensions-tool/index.js 72857 var import_jsx_runtime459 = __toESM(require_jsx_runtime()); 72858 function DimensionsTool({ 72859 panelId, 72860 value = {}, 72861 onChange = () => { 72862 }, 72863 aspectRatioOptions, 72864 // Default options handled by AspectRatioTool. 72865 defaultAspectRatio = "auto", 72866 // Match CSS default value for aspect-ratio. 72867 scaleOptions, 72868 // Default options handled by ScaleTool. 72869 defaultScale = "fill", 72870 // Match CSS default value for object-fit. 72871 unitsOptions, 72872 // Default options handled by UnitControl. 72873 tools = ["aspectRatio", "widthHeight", "scale"] 72874 }) { 72875 const width = value.width === void 0 || value.width === "auto" ? null : value.width; 72876 const height = value.height === void 0 || value.height === "auto" ? null : value.height; 72877 const aspectRatio = value.aspectRatio === void 0 || value.aspectRatio === "auto" ? null : value.aspectRatio; 72878 const scale = value.scale === void 0 || value.scale === "fill" ? null : value.scale; 72879 const [lastScale, setLastScale] = (0, import_element272.useState)(scale); 72880 const [lastAspectRatio, setLastAspectRatio] = (0, import_element272.useState)(aspectRatio); 72881 const aspectRatioValue = width && height ? "custom" : lastAspectRatio; 72882 const showScaleControl = aspectRatio || width && height; 72883 return /* @__PURE__ */ (0, import_jsx_runtime459.jsxs)(import_jsx_runtime459.Fragment, { children: [ 72884 tools.includes("aspectRatio") && /* @__PURE__ */ (0, import_jsx_runtime459.jsx)( 72885 AspectRatioTool, 72886 { 72887 panelId, 72888 options: aspectRatioOptions, 72889 defaultValue: defaultAspectRatio, 72890 value: aspectRatioValue, 72891 onChange: (nextAspectRatio) => { 72892 const nextValue = { ...value }; 72893 nextAspectRatio = nextAspectRatio === "auto" ? null : nextAspectRatio; 72894 setLastAspectRatio(nextAspectRatio); 72895 if (!nextAspectRatio) { 72896 delete nextValue.aspectRatio; 72897 } else { 72898 nextValue.aspectRatio = nextAspectRatio; 72899 } 72900 if (!nextAspectRatio) { 72901 delete nextValue.scale; 72902 } else if (lastScale) { 72903 nextValue.scale = lastScale; 72904 } else { 72905 nextValue.scale = defaultScale; 72906 setLastScale(defaultScale); 72907 } 72908 if ("custom" !== nextAspectRatio && width && height) { 72909 delete nextValue.height; 72910 } 72911 onChange(nextValue); 72912 } 72913 } 72914 ), 72915 tools.includes("widthHeight") && /* @__PURE__ */ (0, import_jsx_runtime459.jsx)( 72916 WidthHeightTool, 72917 { 72918 panelId, 72919 units: unitsOptions, 72920 value: { width, height }, 72921 onChange: ({ width: nextWidth, height: nextHeight }) => { 72922 const nextValue = { ...value }; 72923 nextWidth = nextWidth === "auto" ? null : nextWidth; 72924 nextHeight = nextHeight === "auto" ? null : nextHeight; 72925 if (!nextWidth) { 72926 delete nextValue.width; 72927 } else { 72928 nextValue.width = nextWidth; 72929 } 72930 if (!nextHeight) { 72931 delete nextValue.height; 72932 } else { 72933 nextValue.height = nextHeight; 72934 } 72935 if (nextWidth && nextHeight) { 72936 delete nextValue.aspectRatio; 72937 } else if (lastAspectRatio) { 72938 nextValue.aspectRatio = lastAspectRatio; 72939 } else { 72940 } 72941 if (!lastAspectRatio && !!nextWidth !== !!nextHeight) { 72942 delete nextValue.scale; 72943 } else if (lastScale) { 72944 nextValue.scale = lastScale; 72945 } else { 72946 nextValue.scale = defaultScale; 72947 setLastScale(defaultScale); 72948 } 72949 onChange(nextValue); 72950 } 72951 } 72952 ), 72953 tools.includes("scale") && showScaleControl && /* @__PURE__ */ (0, import_jsx_runtime459.jsx)( 72954 ScaleTool, 72955 { 72956 panelId, 72957 options: scaleOptions, 72958 defaultValue: defaultScale, 72959 value: lastScale, 72960 onChange: (nextScale) => { 72961 const nextValue = { ...value }; 72962 nextScale = nextScale === "fill" ? null : nextScale; 72963 setLastScale(nextScale); 72964 if (!nextScale) { 72965 delete nextValue.scale; 72966 } else { 72967 nextValue.scale = nextScale; 72968 } 72969 onChange(nextValue); 72970 } 72971 } 72972 ) 72973 ] }); 72974 } 72975 var dimensions_tool_default = DimensionsTool; 72976 72977 // packages/block-editor/build-module/components/resolution-tool/index.js 72978 var import_components275 = __toESM(require_components()); 72979 var import_i18n239 = __toESM(require_i18n()); 72980 var import_jsx_runtime460 = __toESM(require_jsx_runtime()); 72981 var DEFAULT_SIZE_OPTIONS = [ 72982 { 72983 label: (0, import_i18n239._x)("Thumbnail", "Image size option for resolution control"), 72984 value: "thumbnail" 72985 }, 72986 { 72987 label: (0, import_i18n239._x)("Medium", "Image size option for resolution control"), 72988 value: "medium" 72989 }, 72990 { 72991 label: (0, import_i18n239._x)("Large", "Image size option for resolution control"), 72992 value: "large" 72993 }, 72994 { 72995 label: (0, import_i18n239._x)("Full Size", "Image size option for resolution control"), 72996 value: "full" 72997 } 72998 ]; 72999 function ResolutionTool({ 73000 panelId, 73001 value, 73002 onChange, 73003 options = DEFAULT_SIZE_OPTIONS, 73004 defaultValue = DEFAULT_SIZE_OPTIONS[0].value, 73005 isShownByDefault = true, 73006 resetAllFilter 73007 }) { 73008 const displayValue = value ?? defaultValue; 73009 return /* @__PURE__ */ (0, import_jsx_runtime460.jsx)( 73010 import_components275.__experimentalToolsPanelItem, 73011 { 73012 hasValue: () => displayValue !== defaultValue, 73013 label: (0, import_i18n239.__)("Resolution"), 73014 onDeselect: () => onChange(defaultValue), 73015 isShownByDefault, 73016 panelId, 73017 resetAllFilter, 73018 children: /* @__PURE__ */ (0, import_jsx_runtime460.jsx)( 73019 import_components275.SelectControl, 73020 { 73021 label: (0, import_i18n239.__)("Resolution"), 73022 value: displayValue, 73023 options, 73024 onChange, 73025 help: (0, import_i18n239.__)("Select the size of the source image."), 73026 size: "__unstable-large" 73027 } 73028 ) 73029 } 73030 ); 73031 } 73032 73033 // packages/block-editor/build-module/components/html-element-control/index.js 73034 var import_i18n241 = __toESM(require_i18n()); 73035 var import_components276 = __toESM(require_components()); 73036 var import_data193 = __toESM(require_data()); 73037 73038 // packages/block-editor/build-module/components/html-element-control/messages.js 73039 var import_i18n240 = __toESM(require_i18n()); 73040 var htmlElementMessages = { 73041 a: (0, import_i18n240.__)( 73042 "The <a> element should be used for links that navigate to a different page or to a different section within the same page." 73043 ), 73044 article: (0, import_i18n240.__)( 73045 "The <article> element should represent a self-contained, syndicatable portion of the document." 73046 ), 73047 aside: (0, import_i18n240.__)( 73048 "The <aside> element should represent a portion of a document whose content is only indirectly related to the document's main content." 73049 ), 73050 button: (0, import_i18n240.__)( 73051 "The <button> element should be used for interactive controls that perform an action on the current page, such as opening a modal or toggling content visibility." 73052 ), 73053 div: (0, import_i18n240.__)( 73054 "The <div> element should only be used if the block is a design element with no semantic meaning." 73055 ), 73056 footer: (0, import_i18n240.__)( 73057 "The <footer> element should represent a footer for its nearest sectioning element (e.g.: <section>, <article>, <main> etc.)." 73058 ), 73059 header: (0, import_i18n240.__)( 73060 "The <header> element should represent introductory content, typically a group of introductory or navigational aids." 73061 ), 73062 main: (0, import_i18n240.__)( 73063 "The <main> element should be used for the primary content of your document only." 73064 ), 73065 nav: (0, import_i18n240.__)( 73066 "The <nav> element should be used to identify groups of links that are intended to be used for website or page content navigation." 73067 ), 73068 section: (0, import_i18n240.__)( 73069 "The <section> element should represent a standalone portion of the document that can't be better represented by another element." 73070 ) 73071 }; 73072 73073 // packages/block-editor/build-module/components/html-element-control/index.js 73074 var import_jsx_runtime461 = __toESM(require_jsx_runtime()); 73075 function HTMLElementControl({ 73076 tagName, 73077 onChange, 73078 clientId, 73079 options = [ 73080 { label: (0, import_i18n241.__)("Default (<div>)"), value: "div" }, 73081 { label: "<header>", value: "header" }, 73082 { label: "<main>", value: "main" }, 73083 { label: "<section>", value: "section" }, 73084 { label: "<article>", value: "article" }, 73085 { label: "<aside>", value: "aside" }, 73086 { label: "<footer>", value: "footer" } 73087 ] 73088 }) { 73089 const checkForMainTag = !!clientId && options.some((option) => option.value === "main"); 73090 const hasMainElementElsewhere = (0, import_data193.useSelect)( 73091 (select3) => { 73092 if (!checkForMainTag) { 73093 return false; 73094 } 73095 const { getClientIdsWithDescendants: getClientIdsWithDescendants2, getBlockAttributes: getBlockAttributes3 } = select3(store); 73096 return getClientIdsWithDescendants2().some((id) => { 73097 if (id === clientId) { 73098 return false; 73099 } 73100 return getBlockAttributes3(id)?.tagName === "main"; 73101 }); 73102 }, 73103 [clientId, checkForMainTag] 73104 ); 73105 const modifiedOptions = options.map((option) => { 73106 if (option.value === "main" && hasMainElementElsewhere && tagName !== "main") { 73107 return { 73108 ...option, 73109 disabled: true, 73110 label: (0, import_i18n241.sprintf)( 73111 /* translators: %s: HTML element name */ 73112 (0, import_i18n241.__)("%s (Already in use)"), 73113 option.label 73114 ) 73115 }; 73116 } 73117 return option; 73118 }); 73119 return /* @__PURE__ */ (0, import_jsx_runtime461.jsxs)(import_components276.__experimentalVStack, { spacing: 2, className: "block-editor-html-element-control", children: [ 73120 /* @__PURE__ */ (0, import_jsx_runtime461.jsx)( 73121 import_components276.SelectControl, 73122 { 73123 __next40pxDefaultSize: true, 73124 label: (0, import_i18n241.__)("HTML element"), 73125 options: modifiedOptions, 73126 value: tagName, 73127 onChange, 73128 help: htmlElementMessages[tagName] 73129 } 73130 ), 73131 tagName === "main" && hasMainElementElsewhere && /* @__PURE__ */ (0, import_jsx_runtime461.jsx)(import_components276.Notice, { status: "warning", isDismissible: false, children: (0, import_i18n241.__)( 73132 "Multiple <main> elements detected. The duplicate may be in your content or template. This is not valid HTML and may cause accessibility issues. Please change this HTML element." 73133 ) }) 73134 ] }); 73135 } 73136 73137 // packages/block-editor/build-module/components/link-picker/link-picker.js 73138 var import_components278 = __toESM(require_components()); 73139 var import_element273 = __toESM(require_element()); 73140 var import_i18n242 = __toESM(require_i18n()); 73141 73142 // packages/block-editor/build-module/components/link-picker/link-preview.js 73143 var import_components277 = __toESM(require_components()); 73144 var import_jsx_runtime462 = __toESM(require_jsx_runtime()); 73145 var { Badge: Badge3 } = unlock(import_components277.privateApis); 73146 function LinkPreview2({ title, url, image, badges }) { 73147 return /* @__PURE__ */ (0, import_jsx_runtime462.jsxs)(import_components277.__experimentalHStack, { justify: "space-between", alignment: "top", children: [ 73148 /* @__PURE__ */ (0, import_jsx_runtime462.jsx)(import_components277.FlexItem, { className: "link-preview-button__content", children: /* @__PURE__ */ (0, import_jsx_runtime462.jsxs)(import_components277.__experimentalHStack, { alignment: "top", children: [ 73149 image && /* @__PURE__ */ (0, import_jsx_runtime462.jsx)(import_components277.FlexItem, { className: "link-preview-button__image-container", children: /* @__PURE__ */ (0, import_jsx_runtime462.jsx)( 73150 "img", 73151 { 73152 className: "link-preview-button__image", 73153 src: image, 73154 alt: "" 73155 } 73156 ) }), 73157 /* @__PURE__ */ (0, import_jsx_runtime462.jsxs)( 73158 import_components277.__experimentalVStack, 73159 { 73160 className: "link-preview-button__details", 73161 alignment: "topLeft", 73162 children: [ 73163 /* @__PURE__ */ (0, import_jsx_runtime462.jsx)( 73164 import_components277.__experimentalTruncate, 73165 { 73166 numberOfLines: 1, 73167 className: "link-preview-button__title", 73168 children: title 73169 } 73170 ), 73171 url && /* @__PURE__ */ (0, import_jsx_runtime462.jsx)( 73172 import_components277.__experimentalTruncate, 73173 { 73174 numberOfLines: 1, 73175 className: "link-preview-button__hint", 73176 children: url 73177 } 73178 ), 73179 badges && badges.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime462.jsx)( 73180 import_components277.__experimentalHStack, 73181 { 73182 className: "link-preview-button__badges", 73183 alignment: "left", 73184 children: badges.map((badge) => /* @__PURE__ */ (0, import_jsx_runtime462.jsx)( 73185 Badge3, 73186 { 73187 intent: badge.intent, 73188 children: badge.label 73189 }, 73190 `$badge.label}|$badge.intent}` 73191 )) 73192 } 73193 ) 73194 ] 73195 } 73196 ) 73197 ] }) }), 73198 /* @__PURE__ */ (0, import_jsx_runtime462.jsx)(icon_default, { icon: chevron_down_default, className: "link-preview-button__icon" }) 73199 ] }); 73200 } 73201 73202 // packages/block-editor/build-module/components/link-picker/link-picker.js 73203 var import_jsx_runtime463 = __toESM(require_jsx_runtime()); 73204 function LinkPicker({ 73205 preview, 73206 onSelect, 73207 suggestionsQuery, 73208 label, 73209 help 73210 }) { 73211 const [isOpen, setIsOpen] = (0, import_element273.useState)(false); 73212 const instanceId = (0, import_element273.useId)(); 73213 const dialogTitleId = `link-picker-title-$instanceId}`; 73214 const dialogDescriptionId = `link-picker-description-$instanceId}`; 73215 const anchorRef = (0, import_element273.useRef)(null); 73216 const { baseControlProps, controlProps } = (0, import_components278.useBaseControlProps)({ 73217 help 73218 }); 73219 const handleChange = (newValue) => { 73220 setIsOpen(false); 73221 if (newValue) { 73222 const suggestion = { 73223 url: newValue.url, 73224 kind: newValue.kind, 73225 type: newValue.type, 73226 id: newValue.id, 73227 title: newValue.title 73228 }; 73229 onSelect(suggestion); 73230 } 73231 }; 73232 return /* @__PURE__ */ (0, import_jsx_runtime463.jsxs)(import_components278.BaseControl, { ...baseControlProps, children: [ 73233 /* @__PURE__ */ (0, import_jsx_runtime463.jsx)(import_components278.BaseControl.VisualLabel, { children: label }), 73234 /* @__PURE__ */ (0, import_jsx_runtime463.jsxs)( 73235 import_components278.Button, 73236 { 73237 ref: anchorRef, 73238 onClick: () => setIsOpen(!isOpen), 73239 "aria-haspopup": "dialog", 73240 "aria-expanded": isOpen, 73241 "aria-describedby": controlProps["aria-describedby"], 73242 variant: "secondary", 73243 __next40pxDefaultSize: true, 73244 className: "link-preview-button", 73245 children: [ 73246 label && /* @__PURE__ */ (0, import_jsx_runtime463.jsxs)(import_components278.VisuallyHidden, { children: [ 73247 label, 73248 ":" 73249 ] }), 73250 /* @__PURE__ */ (0, import_jsx_runtime463.jsx)( 73251 LinkPreview2, 73252 { 73253 title: preview.title || (0, import_i18n242.__)("Add link"), 73254 url: preview.url, 73255 image: preview.image, 73256 badges: preview.badges 73257 } 73258 ) 73259 ] 73260 } 73261 ), 73262 isOpen && /* @__PURE__ */ (0, import_jsx_runtime463.jsx)( 73263 import_components278.Popover, 73264 { 73265 anchor: anchorRef.current, 73266 onClose: () => setIsOpen(false), 73267 placement: "left-start", 73268 offset: 36, 73269 shift: true, 73270 children: /* @__PURE__ */ (0, import_jsx_runtime463.jsxs)( 73271 "div", 73272 { 73273 role: "dialog", 73274 "aria-labelledby": dialogTitleId, 73275 "aria-describedby": dialogDescriptionId, 73276 children: [ 73277 /* @__PURE__ */ (0, import_jsx_runtime463.jsxs)(import_components278.VisuallyHidden, { children: [ 73278 /* @__PURE__ */ (0, import_jsx_runtime463.jsx)("h2", { id: dialogTitleId, children: (0, import_i18n242.__)("Select a link") }), 73279 /* @__PURE__ */ (0, import_jsx_runtime463.jsx)("p", { id: dialogDescriptionId, children: (0, import_i18n242.__)( 73280 "Search for and add a link to the navigation item." 73281 ) }) 73282 ] }), 73283 /* @__PURE__ */ (0, import_jsx_runtime463.jsx)( 73284 link_control_default, 73285 { 73286 value: null, 73287 onChange: handleChange, 73288 suggestionsQuery, 73289 showInitialSuggestions: true, 73290 forceIsEditingLink: true, 73291 settings: [] 73292 } 73293 ) 73294 ] 73295 } 73296 ) 73297 } 73298 ) 73299 ] }); 73300 } 73301 73302 // packages/block-editor/build-module/private-apis.js 73303 var privateApis12 = {}; 73304 lock(privateApis12, { 73305 ...global_styles_exports, 73306 ExperimentalBlockCanvas, 73307 ExperimentalBlockEditorProvider, 73308 getDuotoneFilter, 73309 getRichTextValues, 73310 PrivateQuickInserter: QuickInserter, 73311 extractWords, 73312 getNormalizedSearchTerms, 73313 normalizeString, 73314 PrivateListView, 73315 ResizableBoxPopover, 73316 useHasBlockToolbar, 73317 cleanEmptyObject, 73318 BlockQuickNavigation, 73319 LayoutStyle, 73320 BlockManager, 73321 BlockRemovalWarningModal, 73322 useLayoutClasses, 73323 useLayoutStyles, 73324 DimensionsTool: dimensions_tool_default, 73325 ResolutionTool, 73326 TabbedSidebar: tabbed_sidebar_default, 73327 TextAlignmentControl, 73328 usesContextKey, 73329 useFlashEditableBlocks, 73330 HTMLElementControl, 73331 useZoomOut, 73332 globalStylesDataKey, 73333 globalStylesLinksDataKey, 73334 selectBlockPatternsKey, 73335 requiresWrapperOnCopy, 73336 PrivateRichText, 73337 PrivateInserterLibrary, 73338 reusableBlocksSelectKey, 73339 PrivateBlockPopover, 73340 PrivatePublishDateTimePicker, 73341 useSpacingSizes, 73342 useBlockDisplayTitle, 73343 __unstableBlockStyleVariationOverridesWithConfig, 73344 setBackgroundStyleDefaults: setBackgroundStyleDefaults2, 73345 sectionRootClientIdKey, 73346 CommentIconSlotFill: block_comment_icon_slot_default, 73347 CommentIconToolbarSlotFill: block_comment_icon_toolbar_slot_default, 73348 mediaEditKey, 73349 getMediaSelectKey, 73350 essentialFormatKey, 73351 isIsolatedEditorKey, 73352 useBlockElement, 73353 useBlockElementRef, 73354 LinkPicker, 73355 useRemoteUrlData: use_rich_url_data_default 73356 }); 73357 return __toCommonJS(index_exports); 73358 })(); 73359 /*! Bundled license information: 73360 73361 react-is/cjs/react-is.development.js: 73362 (** @license React v16.13.1 73363 * react-is.development.js 73364 * 73365 * Copyright (c) Facebook, Inc. and its affiliates. 73366 * 73367 * This source code is licensed under the MIT license found in the 73368 * LICENSE file in the root directory of this source tree. 73369 *) 73370 73371 object-assign/index.js: 73372 (* 73373 object-assign 73374 (c) Sindre Sorhus 73375 @license MIT 73376 *) 73377 73378 autosize/dist/autosize.js: 73379 (*! 73380 autosize 4.0.2 73381 license: MIT 73382 http://www.jacklmoore.com/autosize 73383 *) 73384 73385 normalize-wheel/src/isEventSupported.js: 73386 (** 73387 * Checks if an event is supported in the current execution environment. 73388 * 73389 * NOTE: This will not work correctly for non-generic events such as `change`, 73390 * `reset`, `load`, `error`, and `select`. 73391 * 73392 * Borrows from Modernizr. 73393 * 73394 * @param {string} eventNameSuffix Event name, e.g. "click". 73395 * @param {?boolean} capture Check if the capture phase is supported. 73396 * @return {boolean} True if the event is supported. 73397 * @internal 73398 * @license Modernizr 3.0.0pre (Custom Build) | MIT 73399 *) 73400 */
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated : Mon May 11 08:20:02 2026 | Cross-referenced by PHPXref |