[ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Summary view] [Print] [Text view]
1 /******/ (() => { // webpackBootstrap 2 /******/ var __webpack_modules__ = ({ 3 4 /***/ 4660: 5 /***/ ((module) => { 6 7 /* eslint eslint-comments/no-unlimited-disable: 0 */ 8 /* eslint-disable */ 9 /* pako 1.0.10 nodeca/pako */ ( function ( f ) { 10 if ( true ) { 11 module.exports = f(); 12 } else { var g; } 13 } )( function () { 14 var define, module, exports; 15 return ( function () { 16 function r( e, n, t ) { 17 function o( i, f ) { 18 if ( ! n[ i ] ) { 19 if ( ! e[ i ] ) { 20 var c = undefined; 21 if ( ! f && c ) return require( i, ! 0 ); 22 if ( u ) return u( i, ! 0 ); 23 var a = new Error( "Cannot find module '" + i + "'" ); 24 throw ( ( a.code = 'MODULE_NOT_FOUND' ), a ); 25 } 26 var p = ( n[ i ] = { exports: {} } ); 27 e[ i ][ 0 ].call( 28 p.exports, 29 function ( r ) { 30 var n = e[ i ][ 1 ][ r ]; 31 return o( n || r ); 32 }, 33 p, 34 p.exports, 35 r, 36 e, 37 n, 38 t 39 ); 40 } 41 return n[ i ].exports; 42 } 43 for ( 44 var u = undefined, i = 0; 45 i < t.length; 46 i++ 47 ) 48 o( t[ i ] ); 49 return o; 50 } 51 return r; 52 } )()( 53 { 54 1: [ 55 function ( require, module, exports ) { 56 'use strict'; 57 58 var TYPED_OK = 59 typeof Uint8Array !== 'undefined' && 60 typeof Uint16Array !== 'undefined' && 61 typeof Int32Array !== 'undefined'; 62 63 function _has( obj, key ) { 64 return Object.prototype.hasOwnProperty.call( obj, key ); 65 } 66 67 exports.assign = function ( 68 obj /*from1, from2, from3, ...*/ 69 ) { 70 var sources = Array.prototype.slice.call( 71 arguments, 72 1 73 ); 74 while ( sources.length ) { 75 var source = sources.shift(); 76 if ( ! source ) { 77 continue; 78 } 79 80 if ( typeof source !== 'object' ) { 81 throw new TypeError( 82 source + 'must be non-object' 83 ); 84 } 85 86 for ( var p in source ) { 87 if ( _has( source, p ) ) { 88 obj[ p ] = source[ p ]; 89 } 90 } 91 } 92 93 return obj; 94 }; 95 96 // reduce buffer size, avoiding mem copy 97 exports.shrinkBuf = function ( buf, size ) { 98 if ( buf.length === size ) { 99 return buf; 100 } 101 if ( buf.subarray ) { 102 return buf.subarray( 0, size ); 103 } 104 buf.length = size; 105 return buf; 106 }; 107 108 var fnTyped = { 109 arraySet: function ( 110 dest, 111 src, 112 src_offs, 113 len, 114 dest_offs 115 ) { 116 if ( src.subarray && dest.subarray ) { 117 dest.set( 118 src.subarray( src_offs, src_offs + len ), 119 dest_offs 120 ); 121 return; 122 } 123 // Fallback to ordinary array 124 for ( var i = 0; i < len; i++ ) { 125 dest[ dest_offs + i ] = src[ src_offs + i ]; 126 } 127 }, 128 // Join array of chunks to single array. 129 flattenChunks: function ( chunks ) { 130 var i, l, len, pos, chunk, result; 131 132 // calculate data length 133 len = 0; 134 for ( i = 0, l = chunks.length; i < l; i++ ) { 135 len += chunks[ i ].length; 136 } 137 138 // join chunks 139 result = new Uint8Array( len ); 140 pos = 0; 141 for ( i = 0, l = chunks.length; i < l; i++ ) { 142 chunk = chunks[ i ]; 143 result.set( chunk, pos ); 144 pos += chunk.length; 145 } 146 147 return result; 148 }, 149 }; 150 151 var fnUntyped = { 152 arraySet: function ( 153 dest, 154 src, 155 src_offs, 156 len, 157 dest_offs 158 ) { 159 for ( var i = 0; i < len; i++ ) { 160 dest[ dest_offs + i ] = src[ src_offs + i ]; 161 } 162 }, 163 // Join array of chunks to single array. 164 flattenChunks: function ( chunks ) { 165 return [].concat.apply( [], chunks ); 166 }, 167 }; 168 169 // Enable/Disable typed arrays use, for testing 170 // 171 exports.setTyped = function ( on ) { 172 if ( on ) { 173 exports.Buf8 = Uint8Array; 174 exports.Buf16 = Uint16Array; 175 exports.Buf32 = Int32Array; 176 exports.assign( exports, fnTyped ); 177 } else { 178 exports.Buf8 = Array; 179 exports.Buf16 = Array; 180 exports.Buf32 = Array; 181 exports.assign( exports, fnUntyped ); 182 } 183 }; 184 185 exports.setTyped( TYPED_OK ); 186 }, 187 {}, 188 ], 189 2: [ 190 function ( require, module, exports ) { 191 // String encode/decode helpers 192 'use strict'; 193 194 var utils = require( './common' ); 195 196 // Quick check if we can use fast array to bin string conversion 197 // 198 // - apply(Array) can fail on Android 2.2 199 // - apply(Uint8Array) can fail on iOS 5.1 Safari 200 // 201 var STR_APPLY_OK = true; 202 var STR_APPLY_UIA_OK = true; 203 204 try { 205 String.fromCharCode.apply( null, [ 0 ] ); 206 } catch ( __ ) { 207 STR_APPLY_OK = false; 208 } 209 try { 210 String.fromCharCode.apply( null, new Uint8Array( 1 ) ); 211 } catch ( __ ) { 212 STR_APPLY_UIA_OK = false; 213 } 214 215 // Table with utf8 lengths (calculated by first byte of sequence) 216 // Note, that 5 & 6-byte values and some 4-byte values can not be represented in JS, 217 // because max possible codepoint is 0x10ffff 218 var _utf8len = new utils.Buf8( 256 ); 219 for ( var q = 0; q < 256; q++ ) { 220 _utf8len[ q ] = 221 q >= 252 222 ? 6 223 : q >= 248 224 ? 5 225 : q >= 240 226 ? 4 227 : q >= 224 228 ? 3 229 : q >= 192 230 ? 2 231 : 1; 232 } 233 _utf8len[ 254 ] = _utf8len[ 254 ] = 1; // Invalid sequence start 234 235 // convert string to array (typed, when possible) 236 exports.string2buf = function ( str ) { 237 var buf, 238 c, 239 c2, 240 m_pos, 241 i, 242 str_len = str.length, 243 buf_len = 0; 244 245 // count binary size 246 for ( m_pos = 0; m_pos < str_len; m_pos++ ) { 247 c = str.charCodeAt( m_pos ); 248 if ( 249 ( c & 0xfc00 ) === 0xd800 && 250 m_pos + 1 < str_len 251 ) { 252 c2 = str.charCodeAt( m_pos + 1 ); 253 if ( ( c2 & 0xfc00 ) === 0xdc00 ) { 254 c = 255 0x10000 + 256 ( ( c - 0xd800 ) << 10 ) + 257 ( c2 - 0xdc00 ); 258 m_pos++; 259 } 260 } 261 buf_len += 262 c < 0x80 263 ? 1 264 : c < 0x800 265 ? 2 266 : c < 0x10000 267 ? 3 268 : 4; 269 } 270 271 // allocate buffer 272 buf = new utils.Buf8( buf_len ); 273 274 // convert 275 for ( i = 0, m_pos = 0; i < buf_len; m_pos++ ) { 276 c = str.charCodeAt( m_pos ); 277 if ( 278 ( c & 0xfc00 ) === 0xd800 && 279 m_pos + 1 < str_len 280 ) { 281 c2 = str.charCodeAt( m_pos + 1 ); 282 if ( ( c2 & 0xfc00 ) === 0xdc00 ) { 283 c = 284 0x10000 + 285 ( ( c - 0xd800 ) << 10 ) + 286 ( c2 - 0xdc00 ); 287 m_pos++; 288 } 289 } 290 if ( c < 0x80 ) { 291 /* one byte */ 292 buf[ i++ ] = c; 293 } else if ( c < 0x800 ) { 294 /* two bytes */ 295 buf[ i++ ] = 0xc0 | ( c >>> 6 ); 296 buf[ i++ ] = 0x80 | ( c & 0x3f ); 297 } else if ( c < 0x10000 ) { 298 /* three bytes */ 299 buf[ i++ ] = 0xe0 | ( c >>> 12 ); 300 buf[ i++ ] = 0x80 | ( ( c >>> 6 ) & 0x3f ); 301 buf[ i++ ] = 0x80 | ( c & 0x3f ); 302 } else { 303 /* four bytes */ 304 buf[ i++ ] = 0xf0 | ( c >>> 18 ); 305 buf[ i++ ] = 0x80 | ( ( c >>> 12 ) & 0x3f ); 306 buf[ i++ ] = 0x80 | ( ( c >>> 6 ) & 0x3f ); 307 buf[ i++ ] = 0x80 | ( c & 0x3f ); 308 } 309 } 310 311 return buf; 312 }; 313 314 // Helper (used in 2 places) 315 function buf2binstring( buf, len ) { 316 // On Chrome, the arguments in a function call that are allowed is `65534`. 317 // If the length of the buffer is smaller than that, we can use this optimization, 318 // otherwise we will take a slower path. 319 if ( len < 65534 ) { 320 if ( 321 ( buf.subarray && STR_APPLY_UIA_OK ) || 322 ( ! buf.subarray && STR_APPLY_OK ) 323 ) { 324 return String.fromCharCode.apply( 325 null, 326 utils.shrinkBuf( buf, len ) 327 ); 328 } 329 } 330 331 var result = ''; 332 for ( var i = 0; i < len; i++ ) { 333 result += String.fromCharCode( buf[ i ] ); 334 } 335 return result; 336 } 337 338 // Convert byte array to binary string 339 exports.buf2binstring = function ( buf ) { 340 return buf2binstring( buf, buf.length ); 341 }; 342 343 // Convert binary string (typed, when possible) 344 exports.binstring2buf = function ( str ) { 345 var buf = new utils.Buf8( str.length ); 346 for ( var i = 0, len = buf.length; i < len; i++ ) { 347 buf[ i ] = str.charCodeAt( i ); 348 } 349 return buf; 350 }; 351 352 // convert array to string 353 exports.buf2string = function ( buf, max ) { 354 var i, out, c, c_len; 355 var len = max || buf.length; 356 357 // Reserve max possible length (2 words per char) 358 // NB: by unknown reasons, Array is significantly faster for 359 // String.fromCharCode.apply than Uint16Array. 360 var utf16buf = new Array( len * 2 ); 361 362 for ( out = 0, i = 0; i < len; ) { 363 c = buf[ i++ ]; 364 // quick process ascii 365 if ( c < 0x80 ) { 366 utf16buf[ out++ ] = c; 367 continue; 368 } 369 370 c_len = _utf8len[ c ]; 371 // skip 5 & 6 byte codes 372 if ( c_len > 4 ) { 373 utf16buf[ out++ ] = 0xfffd; 374 i += c_len - 1; 375 continue; 376 } 377 378 // apply mask on first byte 379 c &= c_len === 2 ? 0x1f : c_len === 3 ? 0x0f : 0x07; 380 // join the rest 381 while ( c_len > 1 && i < len ) { 382 c = ( c << 6 ) | ( buf[ i++ ] & 0x3f ); 383 c_len--; 384 } 385 386 // terminated by end of string? 387 if ( c_len > 1 ) { 388 utf16buf[ out++ ] = 0xfffd; 389 continue; 390 } 391 392 if ( c < 0x10000 ) { 393 utf16buf[ out++ ] = c; 394 } else { 395 c -= 0x10000; 396 utf16buf[ out++ ] = 397 0xd800 | ( ( c >> 10 ) & 0x3ff ); 398 utf16buf[ out++ ] = 0xdc00 | ( c & 0x3ff ); 399 } 400 } 401 402 return buf2binstring( utf16buf, out ); 403 }; 404 405 // Calculate max possible position in utf8 buffer, 406 // that will not break sequence. If that's not possible 407 // - (very small limits) return max size as is. 408 // 409 // buf[] - utf8 bytes array 410 // max - length limit (mandatory); 411 exports.utf8border = function ( buf, max ) { 412 var pos; 413 414 max = max || buf.length; 415 if ( max > buf.length ) { 416 max = buf.length; 417 } 418 419 // go back from last position, until start of sequence found 420 pos = max - 1; 421 while ( pos >= 0 && ( buf[ pos ] & 0xc0 ) === 0x80 ) { 422 pos--; 423 } 424 425 // Very small and broken sequence, 426 // return max, because we should return something anyway. 427 if ( pos < 0 ) { 428 return max; 429 } 430 431 // If we came to start of buffer - that means buffer is too small, 432 // return max too. 433 if ( pos === 0 ) { 434 return max; 435 } 436 437 return pos + _utf8len[ buf[ pos ] ] > max ? pos : max; 438 }; 439 }, 440 { './common': 1 }, 441 ], 442 3: [ 443 function ( require, module, exports ) { 444 'use strict'; 445 446 // Note: adler32 takes 12% for level 0 and 2% for level 6. 447 // It isn't worth it to make additional optimizations as in original. 448 // Small size is preferable. 449 450 // (C) 1995-2013 Jean-loup Gailly and Mark Adler 451 // (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin 452 // 453 // This software is provided 'as-is', without any express or implied 454 // warranty. In no event will the authors be held liable for any damages 455 // arising from the use of this software. 456 // 457 // Permission is granted to anyone to use this software for any purpose, 458 // including commercial applications, and to alter it and redistribute it 459 // freely, subject to the following restrictions: 460 // 461 // 1. The origin of this software must not be misrepresented; you must not 462 // claim that you wrote the original software. If you use this software 463 // in a product, an acknowledgment in the product documentation would be 464 // appreciated but is not required. 465 // 2. Altered source versions must be plainly marked as such, and must not be 466 // misrepresented as being the original software. 467 // 3. This notice may not be removed or altered from any source distribution. 468 469 function adler32( adler, buf, len, pos ) { 470 var s1 = ( adler & 0xffff ) | 0, 471 s2 = ( ( adler >>> 16 ) & 0xffff ) | 0, 472 n = 0; 473 474 while ( len !== 0 ) { 475 // Set limit ~ twice less than 5552, to keep 476 // s2 in 31-bits, because we force signed ints. 477 // in other case %= will fail. 478 n = len > 2000 ? 2000 : len; 479 len -= n; 480 481 do { 482 s1 = ( s1 + buf[ pos++ ] ) | 0; 483 s2 = ( s2 + s1 ) | 0; 484 } while ( --n ); 485 486 s1 %= 65521; 487 s2 %= 65521; 488 } 489 490 return s1 | ( s2 << 16 ) | 0; 491 } 492 493 module.exports = adler32; 494 }, 495 {}, 496 ], 497 4: [ 498 function ( require, module, exports ) { 499 'use strict'; 500 501 // (C) 1995-2013 Jean-loup Gailly and Mark Adler 502 // (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin 503 // 504 // This software is provided 'as-is', without any express or implied 505 // warranty. In no event will the authors be held liable for any damages 506 // arising from the use of this software. 507 // 508 // Permission is granted to anyone to use this software for any purpose, 509 // including commercial applications, and to alter it and redistribute it 510 // freely, subject to the following restrictions: 511 // 512 // 1. The origin of this software must not be misrepresented; you must not 513 // claim that you wrote the original software. If you use this software 514 // in a product, an acknowledgment in the product documentation would be 515 // appreciated but is not required. 516 // 2. Altered source versions must be plainly marked as such, and must not be 517 // misrepresented as being the original software. 518 // 3. This notice may not be removed or altered from any source distribution. 519 520 module.exports = { 521 /* Allowed flush values; see deflate() and inflate() below for details */ 522 Z_NO_FLUSH: 0, 523 Z_PARTIAL_FLUSH: 1, 524 Z_SYNC_FLUSH: 2, 525 Z_FULL_FLUSH: 3, 526 Z_FINISH: 4, 527 Z_BLOCK: 5, 528 Z_TREES: 6, 529 530 /* Return codes for the compression/decompression functions. Negative values 531 * are errors, positive values are used for special but normal events. 532 */ 533 Z_OK: 0, 534 Z_STREAM_END: 1, 535 Z_NEED_DICT: 2, 536 Z_ERRNO: -1, 537 Z_STREAM_ERROR: -2, 538 Z_DATA_ERROR: -3, 539 //Z_MEM_ERROR: -4, 540 Z_BUF_ERROR: -5, 541 //Z_VERSION_ERROR: -6, 542 543 /* compression levels */ 544 Z_NO_COMPRESSION: 0, 545 Z_BEST_SPEED: 1, 546 Z_BEST_COMPRESSION: 9, 547 Z_DEFAULT_COMPRESSION: -1, 548 549 Z_FILTERED: 1, 550 Z_HUFFMAN_ONLY: 2, 551 Z_RLE: 3, 552 Z_FIXED: 4, 553 Z_DEFAULT_STRATEGY: 0, 554 555 /* Possible values of the data_type field (though see inflate()) */ 556 Z_BINARY: 0, 557 Z_TEXT: 1, 558 //Z_ASCII: 1, // = Z_TEXT (deprecated) 559 Z_UNKNOWN: 2, 560 561 /* The deflate compression method */ 562 Z_DEFLATED: 8, 563 //Z_NULL: null // Use -1 or null inline, depending on var type 564 }; 565 }, 566 {}, 567 ], 568 5: [ 569 function ( require, module, exports ) { 570 'use strict'; 571 572 // Note: we can't get significant speed boost here. 573 // So write code to minimize size - no pregenerated tables 574 // and array tools dependencies. 575 576 // (C) 1995-2013 Jean-loup Gailly and Mark Adler 577 // (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin 578 // 579 // This software is provided 'as-is', without any express or implied 580 // warranty. In no event will the authors be held liable for any damages 581 // arising from the use of this software. 582 // 583 // Permission is granted to anyone to use this software for any purpose, 584 // including commercial applications, and to alter it and redistribute it 585 // freely, subject to the following restrictions: 586 // 587 // 1. The origin of this software must not be misrepresented; you must not 588 // claim that you wrote the original software. If you use this software 589 // in a product, an acknowledgment in the product documentation would be 590 // appreciated but is not required. 591 // 2. Altered source versions must be plainly marked as such, and must not be 592 // misrepresented as being the original software. 593 // 3. This notice may not be removed or altered from any source distribution. 594 595 // Use ordinary array, since untyped makes no boost here 596 function makeTable() { 597 var c, 598 table = []; 599 600 for ( var n = 0; n < 256; n++ ) { 601 c = n; 602 for ( var k = 0; k < 8; k++ ) { 603 c = c & 1 ? 0xedb88320 ^ ( c >>> 1 ) : c >>> 1; 604 } 605 table[ n ] = c; 606 } 607 608 return table; 609 } 610 611 // Create table on load. Just 255 signed longs. Not a problem. 612 var crcTable = makeTable(); 613 614 function crc32( crc, buf, len, pos ) { 615 var t = crcTable, 616 end = pos + len; 617 618 crc ^= -1; 619 620 for ( var i = pos; i < end; i++ ) { 621 crc = 622 ( crc >>> 8 ) ^ t[ ( crc ^ buf[ i ] ) & 0xff ]; 623 } 624 625 return crc ^ -1; // >>> 0; 626 } 627 628 module.exports = crc32; 629 }, 630 {}, 631 ], 632 6: [ 633 function ( require, module, exports ) { 634 'use strict'; 635 636 // (C) 1995-2013 Jean-loup Gailly and Mark Adler 637 // (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin 638 // 639 // This software is provided 'as-is', without any express or implied 640 // warranty. In no event will the authors be held liable for any damages 641 // arising from the use of this software. 642 // 643 // Permission is granted to anyone to use this software for any purpose, 644 // including commercial applications, and to alter it and redistribute it 645 // freely, subject to the following restrictions: 646 // 647 // 1. The origin of this software must not be misrepresented; you must not 648 // claim that you wrote the original software. If you use this software 649 // in a product, an acknowledgment in the product documentation would be 650 // appreciated but is not required. 651 // 2. Altered source versions must be plainly marked as such, and must not be 652 // misrepresented as being the original software. 653 // 3. This notice may not be removed or altered from any source distribution. 654 655 function GZheader() { 656 /* true if compressed data believed to be text */ 657 this.text = 0; 658 /* modification time */ 659 this.time = 0; 660 /* extra flags (not used when writing a gzip file) */ 661 this.xflags = 0; 662 /* operating system */ 663 this.os = 0; 664 /* pointer to extra field or Z_NULL if none */ 665 this.extra = null; 666 /* extra field length (valid if extra != Z_NULL) */ 667 this.extra_len = 0; // Actually, we don't need it in JS, 668 // but leave for few code modifications 669 670 // 671 // Setup limits is not necessary because in js we should not preallocate memory 672 // for inflate use constant limit in 65536 bytes 673 // 674 675 /* space at extra (only when reading header) */ 676 // this.extra_max = 0; 677 /* pointer to zero-terminated file name or Z_NULL */ 678 this.name = ''; 679 /* space at name (only when reading header) */ 680 // this.name_max = 0; 681 /* pointer to zero-terminated comment or Z_NULL */ 682 this.comment = ''; 683 /* space at comment (only when reading header) */ 684 // this.comm_max = 0; 685 /* true if there was or will be a header crc */ 686 this.hcrc = 0; 687 /* true when done reading gzip header (not used when writing a gzip file) */ 688 this.done = false; 689 } 690 691 module.exports = GZheader; 692 }, 693 {}, 694 ], 695 7: [ 696 function ( require, module, exports ) { 697 'use strict'; 698 699 // (C) 1995-2013 Jean-loup Gailly and Mark Adler 700 // (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin 701 // 702 // This software is provided 'as-is', without any express or implied 703 // warranty. In no event will the authors be held liable for any damages 704 // arising from the use of this software. 705 // 706 // Permission is granted to anyone to use this software for any purpose, 707 // including commercial applications, and to alter it and redistribute it 708 // freely, subject to the following restrictions: 709 // 710 // 1. The origin of this software must not be misrepresented; you must not 711 // claim that you wrote the original software. If you use this software 712 // in a product, an acknowledgment in the product documentation would be 713 // appreciated but is not required. 714 // 2. Altered source versions must be plainly marked as such, and must not be 715 // misrepresented as being the original software. 716 // 3. This notice may not be removed or altered from any source distribution. 717 718 // See state defs from inflate.js 719 var BAD = 30; /* got a data error -- remain here until reset */ 720 var TYPE = 12; /* i: waiting for type bits, including last-flag bit */ 721 722 /* 723 Decode literal, length, and distance codes and write out the resulting 724 literal and match bytes until either not enough input or output is 725 available, an end-of-block is encountered, or a data error is encountered. 726 When large enough input and output buffers are supplied to inflate(), for 727 example, a 16K input buffer and a 64K output buffer, more than 95% of the 728 inflate execution time is spent in this routine. 729 730 Entry assumptions: 731 732 state.mode === LEN 733 strm.avail_in >= 6 734 strm.avail_out >= 258 735 start >= strm.avail_out 736 state.bits < 8 737 738 On return, state.mode is one of: 739 740 LEN -- ran out of enough output space or enough available input 741 TYPE -- reached end of block code, inflate() to interpret next block 742 BAD -- error in block data 743 744 Notes: 745 746 - The maximum input bits used by a length/distance pair is 15 bits for the 747 length code, 5 bits for the length extra, 15 bits for the distance code, 748 and 13 bits for the distance extra. This totals 48 bits, or six bytes. 749 Therefore if strm.avail_in >= 6, then there is enough input to avoid 750 checking for available input while decoding. 751 752 - The maximum bytes that a single length/distance pair can output is 258 753 bytes, which is the maximum length that can be coded. inflate_fast() 754 requires strm.avail_out >= 258 for each loop to avoid checking for 755 output space. 756 */ 757 module.exports = function inflate_fast( strm, start ) { 758 var state; 759 var _in; /* local strm.input */ 760 var last; /* have enough input while in < last */ 761 var _out; /* local strm.output */ 762 var beg; /* inflate()'s initial strm.output */ 763 var end; /* while out < end, enough space available */ 764 //#ifdef INFLATE_STRICT 765 var dmax; /* maximum distance from zlib header */ 766 //#endif 767 var wsize; /* window size or zero if not using window */ 768 var whave; /* valid bytes in the window */ 769 var wnext; /* window write index */ 770 // Use `s_window` instead `window`, avoid conflict with instrumentation tools 771 var s_window; /* allocated sliding window, if wsize != 0 */ 772 var hold; /* local strm.hold */ 773 var bits; /* local strm.bits */ 774 var lcode; /* local strm.lencode */ 775 var dcode; /* local strm.distcode */ 776 var lmask; /* mask for first level of length codes */ 777 var dmask; /* mask for first level of distance codes */ 778 var here; /* retrieved table entry */ 779 var op; /* code bits, operation, extra bits, or */ 780 /* window position, window bytes to copy */ 781 var len; /* match length, unused bytes */ 782 var dist; /* match distance */ 783 var from; /* where to copy match from */ 784 var from_source; 785 786 var input, output; // JS specific, because we have no pointers 787 788 /* copy state to local variables */ 789 state = strm.state; 790 //here = state.here; 791 _in = strm.next_in; 792 input = strm.input; 793 last = _in + ( strm.avail_in - 5 ); 794 _out = strm.next_out; 795 output = strm.output; 796 beg = _out - ( start - strm.avail_out ); 797 end = _out + ( strm.avail_out - 257 ); 798 //#ifdef INFLATE_STRICT 799 dmax = state.dmax; 800 //#endif 801 wsize = state.wsize; 802 whave = state.whave; 803 wnext = state.wnext; 804 s_window = state.window; 805 hold = state.hold; 806 bits = state.bits; 807 lcode = state.lencode; 808 dcode = state.distcode; 809 lmask = ( 1 << state.lenbits ) - 1; 810 dmask = ( 1 << state.distbits ) - 1; 811 812 /* decode literals and length/distances until end-of-block or not enough 813 input data or output space */ 814 815 top: do { 816 if ( bits < 15 ) { 817 hold += input[ _in++ ] << bits; 818 bits += 8; 819 hold += input[ _in++ ] << bits; 820 bits += 8; 821 } 822 823 here = lcode[ hold & lmask ]; 824 825 dolen: for (;;) { 826 // Goto emulation 827 op = here >>> 24 /*here.bits*/; 828 hold >>>= op; 829 bits -= op; 830 op = ( here >>> 16 ) & 0xff /*here.op*/; 831 if ( op === 0 ) { 832 /* literal */ 833 //Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ? 834 // "inflate: literal '%c'\n" : 835 // "inflate: literal 0x%02x\n", here.val)); 836 output[ _out++ ] = 837 here & 0xffff /*here.val*/; 838 } else if ( op & 16 ) { 839 /* length base */ 840 len = here & 0xffff /*here.val*/; 841 op &= 15; /* number of extra bits */ 842 if ( op ) { 843 if ( bits < op ) { 844 hold += input[ _in++ ] << bits; 845 bits += 8; 846 } 847 len += hold & ( ( 1 << op ) - 1 ); 848 hold >>>= op; 849 bits -= op; 850 } 851 //Tracevv((stderr, "inflate: length %u\n", len)); 852 if ( bits < 15 ) { 853 hold += input[ _in++ ] << bits; 854 bits += 8; 855 hold += input[ _in++ ] << bits; 856 bits += 8; 857 } 858 here = dcode[ hold & dmask ]; 859 860 dodist: for (;;) { 861 // goto emulation 862 op = here >>> 24 /*here.bits*/; 863 hold >>>= op; 864 bits -= op; 865 op = ( here >>> 16 ) & 0xff /*here.op*/; 866 867 if ( op & 16 ) { 868 /* distance base */ 869 dist = here & 0xffff /*here.val*/; 870 op &= 15; /* number of extra bits */ 871 if ( bits < op ) { 872 hold += input[ _in++ ] << bits; 873 bits += 8; 874 if ( bits < op ) { 875 hold += 876 input[ _in++ ] << bits; 877 bits += 8; 878 } 879 } 880 dist += hold & ( ( 1 << op ) - 1 ); 881 //#ifdef INFLATE_STRICT 882 if ( dist > dmax ) { 883 strm.msg = 884 'invalid distance too far back'; 885 state.mode = BAD; 886 break top; 887 } 888 //#endif 889 hold >>>= op; 890 bits -= op; 891 //Tracevv((stderr, "inflate: distance %u\n", dist)); 892 op = 893 _out - 894 beg; /* max distance in output */ 895 if ( dist > op ) { 896 /* see if copy from window */ 897 op = 898 dist - 899 op; /* distance back in window */ 900 if ( op > whave ) { 901 if ( state.sane ) { 902 strm.msg = 903 'invalid distance too far back'; 904 state.mode = BAD; 905 break top; 906 } 907 908 // (!) This block is disabled in zlib defaults, 909 // don't enable it for binary compatibility 910 //#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR 911 // if (len <= op - whave) { 912 // do { 913 // output[_out++] = 0; 914 // } while (--len); 915 // continue top; 916 // } 917 // len -= op - whave; 918 // do { 919 // output[_out++] = 0; 920 // } while (--op > whave); 921 // if (op === 0) { 922 // from = _out - dist; 923 // do { 924 // output[_out++] = output[from++]; 925 // } while (--len); 926 // continue top; 927 // } 928 //#endif 929 } 930 from = 0; // window index 931 from_source = s_window; 932 if ( wnext === 0 ) { 933 /* very common case */ 934 from += wsize - op; 935 if ( op < len ) { 936 /* some from window */ 937 len -= op; 938 do { 939 output[ _out++ ] = 940 s_window[ 941 from++ 942 ]; 943 } while ( --op ); 944 from = 945 _out - 946 dist; /* rest from output */ 947 from_source = output; 948 } 949 } else if ( wnext < op ) { 950 /* wrap around window */ 951 from += wsize + wnext - op; 952 op -= wnext; 953 if ( op < len ) { 954 /* some from end of window */ 955 len -= op; 956 do { 957 output[ _out++ ] = 958 s_window[ 959 from++ 960 ]; 961 } while ( --op ); 962 from = 0; 963 if ( wnext < len ) { 964 /* some from start of window */ 965 op = wnext; 966 len -= op; 967 do { 968 output[ 969 _out++ 970 ] = 971 s_window[ 972 from++ 973 ]; 974 } while ( --op ); 975 from = 976 _out - 977 dist; /* rest from output */ 978 from_source = 979 output; 980 } 981 } 982 } else { 983 /* contiguous in window */ 984 from += wnext - op; 985 if ( op < len ) { 986 /* some from window */ 987 len -= op; 988 do { 989 output[ _out++ ] = 990 s_window[ 991 from++ 992 ]; 993 } while ( --op ); 994 from = 995 _out - 996 dist; /* rest from output */ 997 from_source = output; 998 } 999 } 1000 while ( len > 2 ) { 1001 output[ _out++ ] = 1002 from_source[ from++ ]; 1003 output[ _out++ ] = 1004 from_source[ from++ ]; 1005 output[ _out++ ] = 1006 from_source[ from++ ]; 1007 len -= 3; 1008 } 1009 if ( len ) { 1010 output[ _out++ ] = 1011 from_source[ from++ ]; 1012 if ( len > 1 ) { 1013 output[ _out++ ] = 1014 from_source[ 1015 from++ 1016 ]; 1017 } 1018 } 1019 } else { 1020 from = 1021 _out - 1022 dist; /* copy direct from output */ 1023 do { 1024 /* minimum length is three */ 1025 output[ _out++ ] = 1026 output[ from++ ]; 1027 output[ _out++ ] = 1028 output[ from++ ]; 1029 output[ _out++ ] = 1030 output[ from++ ]; 1031 len -= 3; 1032 } while ( len > 2 ); 1033 if ( len ) { 1034 output[ _out++ ] = 1035 output[ from++ ]; 1036 if ( len > 1 ) { 1037 output[ _out++ ] = 1038 output[ from++ ]; 1039 } 1040 } 1041 } 1042 } else if ( ( op & 64 ) === 0 ) { 1043 /* 2nd level distance code */ 1044 here = 1045 dcode[ 1046 ( here & 1047 0xffff ) /*here.val*/ + 1048 ( hold & 1049 ( ( 1 << op ) - 1050 1 ) ) 1051 ]; 1052 continue dodist; 1053 } else { 1054 strm.msg = 'invalid distance code'; 1055 state.mode = BAD; 1056 break top; 1057 } 1058 1059 break; // need to emulate goto via "continue" 1060 } 1061 } else if ( ( op & 64 ) === 0 ) { 1062 /* 2nd level length code */ 1063 here = 1064 lcode[ 1065 ( here & 0xffff ) /*here.val*/ + 1066 ( hold & ( ( 1 << op ) - 1 ) ) 1067 ]; 1068 continue dolen; 1069 } else if ( op & 32 ) { 1070 /* end-of-block */ 1071 //Tracevv((stderr, "inflate: end of block\n")); 1072 state.mode = TYPE; 1073 break top; 1074 } else { 1075 strm.msg = 'invalid literal/length code'; 1076 state.mode = BAD; 1077 break top; 1078 } 1079 1080 break; // need to emulate goto via "continue" 1081 } 1082 } while ( _in < last && _out < end ); 1083 1084 /* return unused bytes (on entry, bits < 8, so in won't go too far back) */ 1085 len = bits >> 3; 1086 _in -= len; 1087 bits -= len << 3; 1088 hold &= ( 1 << bits ) - 1; 1089 1090 /* update state and return */ 1091 strm.next_in = _in; 1092 strm.next_out = _out; 1093 strm.avail_in = 1094 _in < last 1095 ? 5 + ( last - _in ) 1096 : 5 - ( _in - last ); 1097 strm.avail_out = 1098 _out < end 1099 ? 257 + ( end - _out ) 1100 : 257 - ( _out - end ); 1101 state.hold = hold; 1102 state.bits = bits; 1103 return; 1104 }; 1105 }, 1106 {}, 1107 ], 1108 8: [ 1109 function ( require, module, exports ) { 1110 'use strict'; 1111 1112 // (C) 1995-2013 Jean-loup Gailly and Mark Adler 1113 // (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin 1114 // 1115 // This software is provided 'as-is', without any express or implied 1116 // warranty. In no event will the authors be held liable for any damages 1117 // arising from the use of this software. 1118 // 1119 // Permission is granted to anyone to use this software for any purpose, 1120 // including commercial applications, and to alter it and redistribute it 1121 // freely, subject to the following restrictions: 1122 // 1123 // 1. The origin of this software must not be misrepresented; you must not 1124 // claim that you wrote the original software. If you use this software 1125 // in a product, an acknowledgment in the product documentation would be 1126 // appreciated but is not required. 1127 // 2. Altered source versions must be plainly marked as such, and must not be 1128 // misrepresented as being the original software. 1129 // 3. This notice may not be removed or altered from any source distribution. 1130 1131 var utils = require( '../utils/common' ); 1132 var adler32 = require( './adler32' ); 1133 var crc32 = require( './crc32' ); 1134 var inflate_fast = require( './inffast' ); 1135 var inflate_table = require( './inftrees' ); 1136 1137 var CODES = 0; 1138 var LENS = 1; 1139 var DISTS = 2; 1140 1141 /* Public constants ==========================================================*/ 1142 /* ===========================================================================*/ 1143 1144 /* Allowed flush values; see deflate() and inflate() below for details */ 1145 //var Z_NO_FLUSH = 0; 1146 //var Z_PARTIAL_FLUSH = 1; 1147 //var Z_SYNC_FLUSH = 2; 1148 //var Z_FULL_FLUSH = 3; 1149 var Z_FINISH = 4; 1150 var Z_BLOCK = 5; 1151 var Z_TREES = 6; 1152 1153 /* Return codes for the compression/decompression functions. Negative values 1154 * are errors, positive values are used for special but normal events. 1155 */ 1156 var Z_OK = 0; 1157 var Z_STREAM_END = 1; 1158 var Z_NEED_DICT = 2; 1159 //var Z_ERRNO = -1; 1160 var Z_STREAM_ERROR = -2; 1161 var Z_DATA_ERROR = -3; 1162 var Z_MEM_ERROR = -4; 1163 var Z_BUF_ERROR = -5; 1164 //var Z_VERSION_ERROR = -6; 1165 1166 /* The deflate compression method */ 1167 var Z_DEFLATED = 8; 1168 1169 /* STATES ====================================================================*/ 1170 /* ===========================================================================*/ 1171 1172 var HEAD = 1; /* i: waiting for magic header */ 1173 var FLAGS = 2; /* i: waiting for method and flags (gzip) */ 1174 var TIME = 3; /* i: waiting for modification time (gzip) */ 1175 var OS = 4; /* i: waiting for extra flags and operating system (gzip) */ 1176 var EXLEN = 5; /* i: waiting for extra length (gzip) */ 1177 var EXTRA = 6; /* i: waiting for extra bytes (gzip) */ 1178 var NAME = 7; /* i: waiting for end of file name (gzip) */ 1179 var COMMENT = 8; /* i: waiting for end of comment (gzip) */ 1180 var HCRC = 9; /* i: waiting for header crc (gzip) */ 1181 var DICTID = 10; /* i: waiting for dictionary check value */ 1182 var DICT = 11; /* waiting for inflateSetDictionary() call */ 1183 var TYPE = 12; /* i: waiting for type bits, including last-flag bit */ 1184 var TYPEDO = 13; /* i: same, but skip check to exit inflate on new block */ 1185 var STORED = 14; /* i: waiting for stored size (length and complement) */ 1186 var COPY_ = 15; /* i/o: same as COPY below, but only first time in */ 1187 var COPY = 16; /* i/o: waiting for input or output to copy stored block */ 1188 var TABLE = 17; /* i: waiting for dynamic block table lengths */ 1189 var LENLENS = 18; /* i: waiting for code length code lengths */ 1190 var CODELENS = 19; /* i: waiting for length/lit and distance code lengths */ 1191 var LEN_ = 20; /* i: same as LEN below, but only first time in */ 1192 var LEN = 21; /* i: waiting for length/lit/eob code */ 1193 var LENEXT = 22; /* i: waiting for length extra bits */ 1194 var DIST = 23; /* i: waiting for distance code */ 1195 var DISTEXT = 24; /* i: waiting for distance extra bits */ 1196 var MATCH = 25; /* o: waiting for output space to copy string */ 1197 var LIT = 26; /* o: waiting for output space to write literal */ 1198 var CHECK = 27; /* i: waiting for 32-bit check value */ 1199 var LENGTH = 28; /* i: waiting for 32-bit length (gzip) */ 1200 var DONE = 29; /* finished check, done -- remain here until reset */ 1201 var BAD = 30; /* got a data error -- remain here until reset */ 1202 var MEM = 31; /* got an inflate() memory error -- remain here until reset */ 1203 var SYNC = 32; /* looking for synchronization bytes to restart inflate() */ 1204 1205 /* ===========================================================================*/ 1206 1207 var ENOUGH_LENS = 852; 1208 var ENOUGH_DISTS = 592; 1209 //var ENOUGH = (ENOUGH_LENS+ENOUGH_DISTS); 1210 1211 var MAX_WBITS = 15; 1212 /* 32K LZ77 window */ 1213 var DEF_WBITS = MAX_WBITS; 1214 1215 function zswap32( q ) { 1216 return ( 1217 ( ( q >>> 24 ) & 0xff ) + 1218 ( ( q >>> 8 ) & 0xff00 ) + 1219 ( ( q & 0xff00 ) << 8 ) + 1220 ( ( q & 0xff ) << 24 ) 1221 ); 1222 } 1223 1224 function InflateState() { 1225 this.mode = 0; /* current inflate mode */ 1226 this.last = false; /* true if processing last block */ 1227 this.wrap = 0; /* bit 0 true for zlib, bit 1 true for gzip */ 1228 this.havedict = false; /* true if dictionary provided */ 1229 this.flags = 0; /* gzip header method and flags (0 if zlib) */ 1230 this.dmax = 0; /* zlib header max distance (INFLATE_STRICT) */ 1231 this.check = 0; /* protected copy of check value */ 1232 this.total = 0; /* protected copy of output count */ 1233 // TODO: may be {} 1234 this.head = 1235 null; /* where to save gzip header information */ 1236 1237 /* sliding window */ 1238 this.wbits = 0; /* log base 2 of requested window size */ 1239 this.wsize = 0; /* window size or zero if not using window */ 1240 this.whave = 0; /* valid bytes in the window */ 1241 this.wnext = 0; /* window write index */ 1242 this.window = 1243 null; /* allocated sliding window, if needed */ 1244 1245 /* bit accumulator */ 1246 this.hold = 0; /* input bit accumulator */ 1247 this.bits = 0; /* number of bits in "in" */ 1248 1249 /* for string and stored block copying */ 1250 this.length = 0; /* literal or length of data to copy */ 1251 this.offset = 0; /* distance back to copy string from */ 1252 1253 /* for table and code decoding */ 1254 this.extra = 0; /* extra bits needed */ 1255 1256 /* fixed and dynamic code tables */ 1257 this.lencode = 1258 null; /* starting table for length/literal codes */ 1259 this.distcode = 1260 null; /* starting table for distance codes */ 1261 this.lenbits = 0; /* index bits for lencode */ 1262 this.distbits = 0; /* index bits for distcode */ 1263 1264 /* dynamic table building */ 1265 this.ncode = 0; /* number of code length code lengths */ 1266 this.nlen = 0; /* number of length code lengths */ 1267 this.ndist = 0; /* number of distance code lengths */ 1268 this.have = 0; /* number of code lengths in lens[] */ 1269 this.next = null; /* next available space in codes[] */ 1270 1271 this.lens = new utils.Buf16( 1272 320 1273 ); /* temporary storage for code lengths */ 1274 this.work = new utils.Buf16( 1275 288 1276 ); /* work area for code table building */ 1277 1278 /* 1279 because we don't have pointers in js, we use lencode and distcode directly 1280 as buffers so we don't need codes 1281 */ 1282 //this.codes = new utils.Buf32(ENOUGH); /* space for code tables */ 1283 this.lendyn = 1284 null; /* dynamic table for length/literal codes (JS specific) */ 1285 this.distdyn = 1286 null; /* dynamic table for distance codes (JS specific) */ 1287 this.sane = 0; /* if false, allow invalid distance too far */ 1288 this.back = 0; /* bits back of last unprocessed length/lit */ 1289 this.was = 0; /* initial length of match */ 1290 } 1291 1292 function inflateResetKeep( strm ) { 1293 var state; 1294 1295 if ( ! strm || ! strm.state ) { 1296 return Z_STREAM_ERROR; 1297 } 1298 state = strm.state; 1299 strm.total_in = strm.total_out = state.total = 0; 1300 strm.msg = ''; /*Z_NULL*/ 1301 if ( state.wrap ) { 1302 /* to support ill-conceived Java test suite */ 1303 strm.adler = state.wrap & 1; 1304 } 1305 state.mode = HEAD; 1306 state.last = 0; 1307 state.havedict = 0; 1308 state.dmax = 32768; 1309 state.head = null /*Z_NULL*/; 1310 state.hold = 0; 1311 state.bits = 0; 1312 //state.lencode = state.distcode = state.next = state.codes; 1313 state.lencode = state.lendyn = new utils.Buf32( 1314 ENOUGH_LENS 1315 ); 1316 state.distcode = state.distdyn = new utils.Buf32( 1317 ENOUGH_DISTS 1318 ); 1319 1320 state.sane = 1; 1321 state.back = -1; 1322 //Tracev((stderr, "inflate: reset\n")); 1323 return Z_OK; 1324 } 1325 1326 function inflateReset( strm ) { 1327 var state; 1328 1329 if ( ! strm || ! strm.state ) { 1330 return Z_STREAM_ERROR; 1331 } 1332 state = strm.state; 1333 state.wsize = 0; 1334 state.whave = 0; 1335 state.wnext = 0; 1336 return inflateResetKeep( strm ); 1337 } 1338 1339 function inflateReset2( strm, windowBits ) { 1340 var wrap; 1341 var state; 1342 1343 /* get the state */ 1344 if ( ! strm || ! strm.state ) { 1345 return Z_STREAM_ERROR; 1346 } 1347 state = strm.state; 1348 1349 /* extract wrap request from windowBits parameter */ 1350 if ( windowBits < 0 ) { 1351 wrap = 0; 1352 windowBits = -windowBits; 1353 } else { 1354 wrap = ( windowBits >> 4 ) + 1; 1355 if ( windowBits < 48 ) { 1356 windowBits &= 15; 1357 } 1358 } 1359 1360 /* set number of window bits, free window if different */ 1361 if ( 1362 windowBits && 1363 ( windowBits < 8 || windowBits > 15 ) 1364 ) { 1365 return Z_STREAM_ERROR; 1366 } 1367 if ( 1368 state.window !== null && 1369 state.wbits !== windowBits 1370 ) { 1371 state.window = null; 1372 } 1373 1374 /* update state and reset the rest of it */ 1375 state.wrap = wrap; 1376 state.wbits = windowBits; 1377 return inflateReset( strm ); 1378 } 1379 1380 function inflateInit2( strm, windowBits ) { 1381 var ret; 1382 var state; 1383 1384 if ( ! strm ) { 1385 return Z_STREAM_ERROR; 1386 } 1387 //strm.msg = Z_NULL; /* in case we return an error */ 1388 1389 state = new InflateState(); 1390 1391 //if (state === Z_NULL) return Z_MEM_ERROR; 1392 //Tracev((stderr, "inflate: allocated\n")); 1393 strm.state = state; 1394 state.window = null /*Z_NULL*/; 1395 ret = inflateReset2( strm, windowBits ); 1396 if ( ret !== Z_OK ) { 1397 strm.state = null /*Z_NULL*/; 1398 } 1399 return ret; 1400 } 1401 1402 function inflateInit( strm ) { 1403 return inflateInit2( strm, DEF_WBITS ); 1404 } 1405 1406 /* 1407 Return state with length and distance decoding tables and index sizes set to 1408 fixed code decoding. Normally this returns fixed tables from inffixed.h. 1409 If BUILDFIXED is defined, then instead this routine builds the tables the 1410 first time it's called, and returns those tables the first time and 1411 thereafter. This reduces the size of the code by about 2K bytes, in 1412 exchange for a little execution time. However, BUILDFIXED should not be 1413 used for threaded applications, since the rewriting of the tables and virgin 1414 may not be thread-safe. 1415 */ 1416 var virgin = true; 1417 1418 var lenfix, distfix; // We have no pointers in JS, so keep tables separate 1419 1420 function fixedtables( state ) { 1421 /* build fixed huffman tables if first call (may not be thread safe) */ 1422 if ( virgin ) { 1423 var sym; 1424 1425 lenfix = new utils.Buf32( 512 ); 1426 distfix = new utils.Buf32( 32 ); 1427 1428 /* literal/length table */ 1429 sym = 0; 1430 while ( sym < 144 ) { 1431 state.lens[ sym++ ] = 8; 1432 } 1433 while ( sym < 256 ) { 1434 state.lens[ sym++ ] = 9; 1435 } 1436 while ( sym < 280 ) { 1437 state.lens[ sym++ ] = 7; 1438 } 1439 while ( sym < 288 ) { 1440 state.lens[ sym++ ] = 8; 1441 } 1442 1443 inflate_table( 1444 LENS, 1445 state.lens, 1446 0, 1447 288, 1448 lenfix, 1449 0, 1450 state.work, 1451 { bits: 9 } 1452 ); 1453 1454 /* distance table */ 1455 sym = 0; 1456 while ( sym < 32 ) { 1457 state.lens[ sym++ ] = 5; 1458 } 1459 1460 inflate_table( 1461 DISTS, 1462 state.lens, 1463 0, 1464 32, 1465 distfix, 1466 0, 1467 state.work, 1468 { bits: 5 } 1469 ); 1470 1471 /* do this just once */ 1472 virgin = false; 1473 } 1474 1475 state.lencode = lenfix; 1476 state.lenbits = 9; 1477 state.distcode = distfix; 1478 state.distbits = 5; 1479 } 1480 1481 /* 1482 Update the window with the last wsize (normally 32K) bytes written before 1483 returning. If window does not exist yet, create it. This is only called 1484 when a window is already in use, or when output has been written during this 1485 inflate call, but the end of the deflate stream has not been reached yet. 1486 It is also called to create a window for dictionary data when a dictionary 1487 is loaded. 1488 1489 Providing output buffers larger than 32K to inflate() should provide a speed 1490 advantage, since only the last 32K of output is copied to the sliding window 1491 upon return from inflate(), and since all distances after the first 32K of 1492 output will fall in the output data, making match copies simpler and faster. 1493 The advantage may be dependent on the size of the processor's data caches. 1494 */ 1495 function updatewindow( strm, src, end, copy ) { 1496 var dist; 1497 var state = strm.state; 1498 1499 /* if it hasn't been done already, allocate space for the window */ 1500 if ( state.window === null ) { 1501 state.wsize = 1 << state.wbits; 1502 state.wnext = 0; 1503 state.whave = 0; 1504 1505 state.window = new utils.Buf8( state.wsize ); 1506 } 1507 1508 /* copy state->wsize or less output bytes into the circular window */ 1509 if ( copy >= state.wsize ) { 1510 utils.arraySet( 1511 state.window, 1512 src, 1513 end - state.wsize, 1514 state.wsize, 1515 0 1516 ); 1517 state.wnext = 0; 1518 state.whave = state.wsize; 1519 } else { 1520 dist = state.wsize - state.wnext; 1521 if ( dist > copy ) { 1522 dist = copy; 1523 } 1524 //zmemcpy(state->window + state->wnext, end - copy, dist); 1525 utils.arraySet( 1526 state.window, 1527 src, 1528 end - copy, 1529 dist, 1530 state.wnext 1531 ); 1532 copy -= dist; 1533 if ( copy ) { 1534 //zmemcpy(state->window, end - copy, copy); 1535 utils.arraySet( 1536 state.window, 1537 src, 1538 end - copy, 1539 copy, 1540 0 1541 ); 1542 state.wnext = copy; 1543 state.whave = state.wsize; 1544 } else { 1545 state.wnext += dist; 1546 if ( state.wnext === state.wsize ) { 1547 state.wnext = 0; 1548 } 1549 if ( state.whave < state.wsize ) { 1550 state.whave += dist; 1551 } 1552 } 1553 } 1554 return 0; 1555 } 1556 1557 function inflate( strm, flush ) { 1558 var state; 1559 var input, output; // input/output buffers 1560 var next; /* next input INDEX */ 1561 var put; /* next output INDEX */ 1562 var have, left; /* available input and output */ 1563 var hold; /* bit buffer */ 1564 var bits; /* bits in bit buffer */ 1565 var _in, 1566 _out; /* save starting available input and output */ 1567 var copy; /* number of stored or match bytes to copy */ 1568 var from; /* where to copy match bytes from */ 1569 var from_source; 1570 var here = 0; /* current decoding table entry */ 1571 var here_bits, here_op, here_val; // paked "here" denormalized (JS specific) 1572 //var last; /* parent table entry */ 1573 var last_bits, last_op, last_val; // paked "last" denormalized (JS specific) 1574 var len; /* length to copy for repeats, bits to drop */ 1575 var ret; /* return code */ 1576 var hbuf = new utils.Buf8( 1577 4 1578 ); /* buffer for gzip header crc calculation */ 1579 var opts; 1580 1581 var n; // temporary var for NEED_BITS 1582 1583 var order = 1584 /* permutation of code lengths */ 1585 [ 1586 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 1587 13, 2, 14, 1, 15, 1588 ]; 1589 1590 if ( 1591 ! strm || 1592 ! strm.state || 1593 ! strm.output || 1594 ( ! strm.input && strm.avail_in !== 0 ) 1595 ) { 1596 return Z_STREAM_ERROR; 1597 } 1598 1599 state = strm.state; 1600 if ( state.mode === TYPE ) { 1601 state.mode = TYPEDO; 1602 } /* skip check */ 1603 1604 //--- LOAD() --- 1605 put = strm.next_out; 1606 output = strm.output; 1607 left = strm.avail_out; 1608 next = strm.next_in; 1609 input = strm.input; 1610 have = strm.avail_in; 1611 hold = state.hold; 1612 bits = state.bits; 1613 //--- 1614 1615 _in = have; 1616 _out = left; 1617 ret = Z_OK; 1618 1619 // goto emulation 1620 inf_leave: for (;;) { 1621 switch ( state.mode ) { 1622 case HEAD: 1623 if ( state.wrap === 0 ) { 1624 state.mode = TYPEDO; 1625 break; 1626 } 1627 //=== NEEDBITS(16); 1628 while ( bits < 16 ) { 1629 if ( have === 0 ) { 1630 break inf_leave; 1631 } 1632 have--; 1633 hold += input[ next++ ] << bits; 1634 bits += 8; 1635 } 1636 //===// 1637 if ( state.wrap & 2 && hold === 0x8b1f ) { 1638 /* gzip header */ 1639 state.check = 0 /*crc32(0L, Z_NULL, 0)*/; 1640 //=== CRC2(state.check, hold); 1641 hbuf[ 0 ] = hold & 0xff; 1642 hbuf[ 1 ] = ( hold >>> 8 ) & 0xff; 1643 state.check = crc32( 1644 state.check, 1645 hbuf, 1646 2, 1647 0 1648 ); 1649 //===// 1650 1651 //=== INITBITS(); 1652 hold = 0; 1653 bits = 0; 1654 //===// 1655 state.mode = FLAGS; 1656 break; 1657 } 1658 state.flags = 0; /* expect zlib header */ 1659 if ( state.head ) { 1660 state.head.done = false; 1661 } 1662 if ( 1663 ! ( 1664 state.wrap & 1 1665 ) /* check if zlib header allowed */ || 1666 ( ( ( hold & 0xff ) /*BITS(8)*/ << 8 ) + 1667 ( hold >> 8 ) ) % 1668 31 1669 ) { 1670 strm.msg = 'incorrect header check'; 1671 state.mode = BAD; 1672 break; 1673 } 1674 if ( 1675 ( hold & 0x0f ) /*BITS(4)*/ !== 1676 Z_DEFLATED 1677 ) { 1678 strm.msg = 'unknown compression method'; 1679 state.mode = BAD; 1680 break; 1681 } 1682 //--- DROPBITS(4) ---// 1683 hold >>>= 4; 1684 bits -= 4; 1685 //---// 1686 len = ( hold & 0x0f ) /*BITS(4)*/ + 8; 1687 if ( state.wbits === 0 ) { 1688 state.wbits = len; 1689 } else if ( len > state.wbits ) { 1690 strm.msg = 'invalid window size'; 1691 state.mode = BAD; 1692 break; 1693 } 1694 state.dmax = 1 << len; 1695 //Tracev((stderr, "inflate: zlib header ok\n")); 1696 strm.adler = 1697 state.check = 1 /*adler32(0L, Z_NULL, 0)*/; 1698 state.mode = hold & 0x200 ? DICTID : TYPE; 1699 //=== INITBITS(); 1700 hold = 0; 1701 bits = 0; 1702 //===// 1703 break; 1704 case FLAGS: 1705 //=== NEEDBITS(16); */ 1706 while ( bits < 16 ) { 1707 if ( have === 0 ) { 1708 break inf_leave; 1709 } 1710 have--; 1711 hold += input[ next++ ] << bits; 1712 bits += 8; 1713 } 1714 //===// 1715 state.flags = hold; 1716 if ( 1717 ( state.flags & 0xff ) !== 1718 Z_DEFLATED 1719 ) { 1720 strm.msg = 'unknown compression method'; 1721 state.mode = BAD; 1722 break; 1723 } 1724 if ( state.flags & 0xe000 ) { 1725 strm.msg = 'unknown header flags set'; 1726 state.mode = BAD; 1727 break; 1728 } 1729 if ( state.head ) { 1730 state.head.text = ( hold >> 8 ) & 1; 1731 } 1732 if ( state.flags & 0x0200 ) { 1733 //=== CRC2(state.check, hold); 1734 hbuf[ 0 ] = hold & 0xff; 1735 hbuf[ 1 ] = ( hold >>> 8 ) & 0xff; 1736 state.check = crc32( 1737 state.check, 1738 hbuf, 1739 2, 1740 0 1741 ); 1742 //===// 1743 } 1744 //=== INITBITS(); 1745 hold = 0; 1746 bits = 0; 1747 //===// 1748 state.mode = TIME; 1749 /* falls through */ 1750 case TIME: 1751 //=== NEEDBITS(32); */ 1752 while ( bits < 32 ) { 1753 if ( have === 0 ) { 1754 break inf_leave; 1755 } 1756 have--; 1757 hold += input[ next++ ] << bits; 1758 bits += 8; 1759 } 1760 //===// 1761 if ( state.head ) { 1762 state.head.time = hold; 1763 } 1764 if ( state.flags & 0x0200 ) { 1765 //=== CRC4(state.check, hold) 1766 hbuf[ 0 ] = hold & 0xff; 1767 hbuf[ 1 ] = ( hold >>> 8 ) & 0xff; 1768 hbuf[ 2 ] = ( hold >>> 16 ) & 0xff; 1769 hbuf[ 3 ] = ( hold >>> 24 ) & 0xff; 1770 state.check = crc32( 1771 state.check, 1772 hbuf, 1773 4, 1774 0 1775 ); 1776 //=== 1777 } 1778 //=== INITBITS(); 1779 hold = 0; 1780 bits = 0; 1781 //===// 1782 state.mode = OS; 1783 /* falls through */ 1784 case OS: 1785 //=== NEEDBITS(16); */ 1786 while ( bits < 16 ) { 1787 if ( have === 0 ) { 1788 break inf_leave; 1789 } 1790 have--; 1791 hold += input[ next++ ] << bits; 1792 bits += 8; 1793 } 1794 //===// 1795 if ( state.head ) { 1796 state.head.xflags = hold & 0xff; 1797 state.head.os = hold >> 8; 1798 } 1799 if ( state.flags & 0x0200 ) { 1800 //=== CRC2(state.check, hold); 1801 hbuf[ 0 ] = hold & 0xff; 1802 hbuf[ 1 ] = ( hold >>> 8 ) & 0xff; 1803 state.check = crc32( 1804 state.check, 1805 hbuf, 1806 2, 1807 0 1808 ); 1809 //===// 1810 } 1811 //=== INITBITS(); 1812 hold = 0; 1813 bits = 0; 1814 //===// 1815 state.mode = EXLEN; 1816 /* falls through */ 1817 case EXLEN: 1818 if ( state.flags & 0x0400 ) { 1819 //=== NEEDBITS(16); */ 1820 while ( bits < 16 ) { 1821 if ( have === 0 ) { 1822 break inf_leave; 1823 } 1824 have--; 1825 hold += input[ next++ ] << bits; 1826 bits += 8; 1827 } 1828 //===// 1829 state.length = hold; 1830 if ( state.head ) { 1831 state.head.extra_len = hold; 1832 } 1833 if ( state.flags & 0x0200 ) { 1834 //=== CRC2(state.check, hold); 1835 hbuf[ 0 ] = hold & 0xff; 1836 hbuf[ 1 ] = ( hold >>> 8 ) & 0xff; 1837 state.check = crc32( 1838 state.check, 1839 hbuf, 1840 2, 1841 0 1842 ); 1843 //===// 1844 } 1845 //=== INITBITS(); 1846 hold = 0; 1847 bits = 0; 1848 //===// 1849 } else if ( state.head ) { 1850 state.head.extra = null /*Z_NULL*/; 1851 } 1852 state.mode = EXTRA; 1853 /* falls through */ 1854 case EXTRA: 1855 if ( state.flags & 0x0400 ) { 1856 copy = state.length; 1857 if ( copy > have ) { 1858 copy = have; 1859 } 1860 if ( copy ) { 1861 if ( state.head ) { 1862 len = 1863 state.head.extra_len - 1864 state.length; 1865 if ( ! state.head.extra ) { 1866 // Use untyped array for more convenient processing later 1867 state.head.extra = 1868 new Array( 1869 state.head.extra_len 1870 ); 1871 } 1872 utils.arraySet( 1873 state.head.extra, 1874 input, 1875 next, 1876 // extra field is limited to 65536 bytes 1877 // - no need for additional size check 1878 copy, 1879 /*len + copy > state.head.extra_max - len ? state.head.extra_max : copy,*/ 1880 len 1881 ); 1882 //zmemcpy(state.head.extra + len, next, 1883 // len + copy > state.head.extra_max ? 1884 // state.head.extra_max - len : copy); 1885 } 1886 if ( state.flags & 0x0200 ) { 1887 state.check = crc32( 1888 state.check, 1889 input, 1890 copy, 1891 next 1892 ); 1893 } 1894 have -= copy; 1895 next += copy; 1896 state.length -= copy; 1897 } 1898 if ( state.length ) { 1899 break inf_leave; 1900 } 1901 } 1902 state.length = 0; 1903 state.mode = NAME; 1904 /* falls through */ 1905 case NAME: 1906 if ( state.flags & 0x0800 ) { 1907 if ( have === 0 ) { 1908 break inf_leave; 1909 } 1910 copy = 0; 1911 do { 1912 // TODO: 2 or 1 bytes? 1913 len = input[ next + copy++ ]; 1914 /* use constant limit because in js we should not preallocate memory */ 1915 if ( 1916 state.head && 1917 len && 1918 state.length < 1919 65536 /*state.head.name_max*/ 1920 ) { 1921 state.head.name += 1922 String.fromCharCode( len ); 1923 } 1924 } while ( len && copy < have ); 1925 1926 if ( state.flags & 0x0200 ) { 1927 state.check = crc32( 1928 state.check, 1929 input, 1930 copy, 1931 next 1932 ); 1933 } 1934 have -= copy; 1935 next += copy; 1936 if ( len ) { 1937 break inf_leave; 1938 } 1939 } else if ( state.head ) { 1940 state.head.name = null; 1941 } 1942 state.length = 0; 1943 state.mode = COMMENT; 1944 /* falls through */ 1945 case COMMENT: 1946 if ( state.flags & 0x1000 ) { 1947 if ( have === 0 ) { 1948 break inf_leave; 1949 } 1950 copy = 0; 1951 do { 1952 len = input[ next + copy++ ]; 1953 /* use constant limit because in js we should not preallocate memory */ 1954 if ( 1955 state.head && 1956 len && 1957 state.length < 1958 65536 /*state.head.comm_max*/ 1959 ) { 1960 state.head.comment += 1961 String.fromCharCode( len ); 1962 } 1963 } while ( len && copy < have ); 1964 if ( state.flags & 0x0200 ) { 1965 state.check = crc32( 1966 state.check, 1967 input, 1968 copy, 1969 next 1970 ); 1971 } 1972 have -= copy; 1973 next += copy; 1974 if ( len ) { 1975 break inf_leave; 1976 } 1977 } else if ( state.head ) { 1978 state.head.comment = null; 1979 } 1980 state.mode = HCRC; 1981 /* falls through */ 1982 case HCRC: 1983 if ( state.flags & 0x0200 ) { 1984 //=== NEEDBITS(16); */ 1985 while ( bits < 16 ) { 1986 if ( have === 0 ) { 1987 break inf_leave; 1988 } 1989 have--; 1990 hold += input[ next++ ] << bits; 1991 bits += 8; 1992 } 1993 //===// 1994 if ( 1995 hold !== 1996 ( state.check & 0xffff ) 1997 ) { 1998 strm.msg = 'header crc mismatch'; 1999 state.mode = BAD; 2000 break; 2001 } 2002 //=== INITBITS(); 2003 hold = 0; 2004 bits = 0; 2005 //===// 2006 } 2007 if ( state.head ) { 2008 state.head.hcrc = 2009 ( state.flags >> 9 ) & 1; 2010 state.head.done = true; 2011 } 2012 strm.adler = state.check = 0; 2013 state.mode = TYPE; 2014 break; 2015 case DICTID: 2016 //=== NEEDBITS(32); */ 2017 while ( bits < 32 ) { 2018 if ( have === 0 ) { 2019 break inf_leave; 2020 } 2021 have--; 2022 hold += input[ next++ ] << bits; 2023 bits += 8; 2024 } 2025 //===// 2026 strm.adler = state.check = zswap32( hold ); 2027 //=== INITBITS(); 2028 hold = 0; 2029 bits = 0; 2030 //===// 2031 state.mode = DICT; 2032 /* falls through */ 2033 case DICT: 2034 if ( state.havedict === 0 ) { 2035 //--- RESTORE() --- 2036 strm.next_out = put; 2037 strm.avail_out = left; 2038 strm.next_in = next; 2039 strm.avail_in = have; 2040 state.hold = hold; 2041 state.bits = bits; 2042 //--- 2043 return Z_NEED_DICT; 2044 } 2045 strm.adler = 2046 state.check = 1 /*adler32(0L, Z_NULL, 0)*/; 2047 state.mode = TYPE; 2048 /* falls through */ 2049 case TYPE: 2050 if ( 2051 flush === Z_BLOCK || 2052 flush === Z_TREES 2053 ) { 2054 break inf_leave; 2055 } 2056 /* falls through */ 2057 case TYPEDO: 2058 if ( state.last ) { 2059 //--- BYTEBITS() ---// 2060 hold >>>= bits & 7; 2061 bits -= bits & 7; 2062 //---// 2063 state.mode = CHECK; 2064 break; 2065 } 2066 //=== NEEDBITS(3); */ 2067 while ( bits < 3 ) { 2068 if ( have === 0 ) { 2069 break inf_leave; 2070 } 2071 have--; 2072 hold += input[ next++ ] << bits; 2073 bits += 8; 2074 } 2075 //===// 2076 state.last = hold & 0x01 /*BITS(1)*/; 2077 //--- DROPBITS(1) ---// 2078 hold >>>= 1; 2079 bits -= 1; 2080 //---// 2081 2082 switch ( hold & 0x03 /*BITS(2)*/ ) { 2083 case 0 /* stored block */: 2084 //Tracev((stderr, "inflate: stored block%s\n", 2085 // state.last ? " (last)" : "")); 2086 state.mode = STORED; 2087 break; 2088 case 1 /* fixed block */: 2089 fixedtables( state ); 2090 //Tracev((stderr, "inflate: fixed codes block%s\n", 2091 // state.last ? " (last)" : "")); 2092 state.mode = 2093 LEN_; /* decode codes */ 2094 if ( flush === Z_TREES ) { 2095 //--- DROPBITS(2) ---// 2096 hold >>>= 2; 2097 bits -= 2; 2098 //---// 2099 break inf_leave; 2100 } 2101 break; 2102 case 2 /* dynamic block */: 2103 //Tracev((stderr, "inflate: dynamic codes block%s\n", 2104 // state.last ? " (last)" : "")); 2105 state.mode = TABLE; 2106 break; 2107 case 3: 2108 strm.msg = 'invalid block type'; 2109 state.mode = BAD; 2110 } 2111 //--- DROPBITS(2) ---// 2112 hold >>>= 2; 2113 bits -= 2; 2114 //---// 2115 break; 2116 case STORED: 2117 //--- BYTEBITS() ---// /* go to byte boundary */ 2118 hold >>>= bits & 7; 2119 bits -= bits & 7; 2120 //---// 2121 //=== NEEDBITS(32); */ 2122 while ( bits < 32 ) { 2123 if ( have === 0 ) { 2124 break inf_leave; 2125 } 2126 have--; 2127 hold += input[ next++ ] << bits; 2128 bits += 8; 2129 } 2130 //===// 2131 if ( 2132 ( hold & 0xffff ) !== 2133 ( ( hold >>> 16 ) ^ 0xffff ) 2134 ) { 2135 strm.msg = 2136 'invalid stored block lengths'; 2137 state.mode = BAD; 2138 break; 2139 } 2140 state.length = hold & 0xffff; 2141 //Tracev((stderr, "inflate: stored length %u\n", 2142 // state.length)); 2143 //=== INITBITS(); 2144 hold = 0; 2145 bits = 0; 2146 //===// 2147 state.mode = COPY_; 2148 if ( flush === Z_TREES ) { 2149 break inf_leave; 2150 } 2151 /* falls through */ 2152 case COPY_: 2153 state.mode = COPY; 2154 /* falls through */ 2155 case COPY: 2156 copy = state.length; 2157 if ( copy ) { 2158 if ( copy > have ) { 2159 copy = have; 2160 } 2161 if ( copy > left ) { 2162 copy = left; 2163 } 2164 if ( copy === 0 ) { 2165 break inf_leave; 2166 } 2167 //--- zmemcpy(put, next, copy); --- 2168 utils.arraySet( 2169 output, 2170 input, 2171 next, 2172 copy, 2173 put 2174 ); 2175 //---// 2176 have -= copy; 2177 next += copy; 2178 left -= copy; 2179 put += copy; 2180 state.length -= copy; 2181 break; 2182 } 2183 //Tracev((stderr, "inflate: stored end\n")); 2184 state.mode = TYPE; 2185 break; 2186 case TABLE: 2187 //=== NEEDBITS(14); */ 2188 while ( bits < 14 ) { 2189 if ( have === 0 ) { 2190 break inf_leave; 2191 } 2192 have--; 2193 hold += input[ next++ ] << bits; 2194 bits += 8; 2195 } 2196 //===// 2197 state.nlen = 2198 ( hold & 0x1f ) /*BITS(5)*/ + 257; 2199 //--- DROPBITS(5) ---// 2200 hold >>>= 5; 2201 bits -= 5; 2202 //---// 2203 state.ndist = 2204 ( hold & 0x1f ) /*BITS(5)*/ + 1; 2205 //--- DROPBITS(5) ---// 2206 hold >>>= 5; 2207 bits -= 5; 2208 //---// 2209 state.ncode = 2210 ( hold & 0x0f ) /*BITS(4)*/ + 4; 2211 //--- DROPBITS(4) ---// 2212 hold >>>= 4; 2213 bits -= 4; 2214 //---// 2215 //#ifndef PKZIP_BUG_WORKAROUND 2216 if ( 2217 state.nlen > 286 || 2218 state.ndist > 30 2219 ) { 2220 strm.msg = 2221 'too many length or distance symbols'; 2222 state.mode = BAD; 2223 break; 2224 } 2225 //#endif 2226 //Tracev((stderr, "inflate: table sizes ok\n")); 2227 state.have = 0; 2228 state.mode = LENLENS; 2229 /* falls through */ 2230 case LENLENS: 2231 while ( state.have < state.ncode ) { 2232 //=== NEEDBITS(3); 2233 while ( bits < 3 ) { 2234 if ( have === 0 ) { 2235 break inf_leave; 2236 } 2237 have--; 2238 hold += input[ next++ ] << bits; 2239 bits += 8; 2240 } 2241 //===// 2242 state.lens[ order[ state.have++ ] ] = 2243 hold & 0x07; //BITS(3); 2244 //--- DROPBITS(3) ---// 2245 hold >>>= 3; 2246 bits -= 3; 2247 //---// 2248 } 2249 while ( state.have < 19 ) { 2250 state.lens[ order[ state.have++ ] ] = 0; 2251 } 2252 // We have separate tables & no pointers. 2 commented lines below not needed. 2253 //state.next = state.codes; 2254 //state.lencode = state.next; 2255 // Switch to use dynamic table 2256 state.lencode = state.lendyn; 2257 state.lenbits = 7; 2258 2259 opts = { bits: state.lenbits }; 2260 ret = inflate_table( 2261 CODES, 2262 state.lens, 2263 0, 2264 19, 2265 state.lencode, 2266 0, 2267 state.work, 2268 opts 2269 ); 2270 state.lenbits = opts.bits; 2271 2272 if ( ret ) { 2273 strm.msg = 'invalid code lengths set'; 2274 state.mode = BAD; 2275 break; 2276 } 2277 //Tracev((stderr, "inflate: code lengths ok\n")); 2278 state.have = 0; 2279 state.mode = CODELENS; 2280 /* falls through */ 2281 case CODELENS: 2282 while ( 2283 state.have < 2284 state.nlen + state.ndist 2285 ) { 2286 for (;;) { 2287 here = 2288 state.lencode[ 2289 hold & 2290 ( ( 1 << 2291 state.lenbits ) - 2292 1 ) 2293 ]; /*BITS(state.lenbits)*/ 2294 here_bits = here >>> 24; 2295 here_op = ( here >>> 16 ) & 0xff; 2296 here_val = here & 0xffff; 2297 2298 if ( here_bits <= bits ) { 2299 break; 2300 } 2301 //--- PULLBYTE() ---// 2302 if ( have === 0 ) { 2303 break inf_leave; 2304 } 2305 have--; 2306 hold += input[ next++ ] << bits; 2307 bits += 8; 2308 //---// 2309 } 2310 if ( here_val < 16 ) { 2311 //--- DROPBITS(here.bits) ---// 2312 hold >>>= here_bits; 2313 bits -= here_bits; 2314 //---// 2315 state.lens[ state.have++ ] = 2316 here_val; 2317 } else { 2318 if ( here_val === 16 ) { 2319 //=== NEEDBITS(here.bits + 2); 2320 n = here_bits + 2; 2321 while ( bits < n ) { 2322 if ( have === 0 ) { 2323 break inf_leave; 2324 } 2325 have--; 2326 hold += 2327 input[ next++ ] << bits; 2328 bits += 8; 2329 } 2330 //===// 2331 //--- DROPBITS(here.bits) ---// 2332 hold >>>= here_bits; 2333 bits -= here_bits; 2334 //---// 2335 if ( state.have === 0 ) { 2336 strm.msg = 2337 'invalid bit length repeat'; 2338 state.mode = BAD; 2339 break; 2340 } 2341 len = 2342 state.lens[ 2343 state.have - 1 2344 ]; 2345 copy = 3 + ( hold & 0x03 ); //BITS(2); 2346 //--- DROPBITS(2) ---// 2347 hold >>>= 2; 2348 bits -= 2; 2349 //---// 2350 } else if ( here_val === 17 ) { 2351 //=== NEEDBITS(here.bits + 3); 2352 n = here_bits + 3; 2353 while ( bits < n ) { 2354 if ( have === 0 ) { 2355 break inf_leave; 2356 } 2357 have--; 2358 hold += 2359 input[ next++ ] << bits; 2360 bits += 8; 2361 } 2362 //===// 2363 //--- DROPBITS(here.bits) ---// 2364 hold >>>= here_bits; 2365 bits -= here_bits; 2366 //---// 2367 len = 0; 2368 copy = 3 + ( hold & 0x07 ); //BITS(3); 2369 //--- DROPBITS(3) ---// 2370 hold >>>= 3; 2371 bits -= 3; 2372 //---// 2373 } else { 2374 //=== NEEDBITS(here.bits + 7); 2375 n = here_bits + 7; 2376 while ( bits < n ) { 2377 if ( have === 0 ) { 2378 break inf_leave; 2379 } 2380 have--; 2381 hold += 2382 input[ next++ ] << bits; 2383 bits += 8; 2384 } 2385 //===// 2386 //--- DROPBITS(here.bits) ---// 2387 hold >>>= here_bits; 2388 bits -= here_bits; 2389 //---// 2390 len = 0; 2391 copy = 11 + ( hold & 0x7f ); //BITS(7); 2392 //--- DROPBITS(7) ---// 2393 hold >>>= 7; 2394 bits -= 7; 2395 //---// 2396 } 2397 if ( 2398 state.have + copy > 2399 state.nlen + state.ndist 2400 ) { 2401 strm.msg = 2402 'invalid bit length repeat'; 2403 state.mode = BAD; 2404 break; 2405 } 2406 while ( copy-- ) { 2407 state.lens[ state.have++ ] = 2408 len; 2409 } 2410 } 2411 } 2412 2413 /* handle error breaks in while */ 2414 if ( state.mode === BAD ) { 2415 break; 2416 } 2417 2418 /* check for end-of-block code (better have one) */ 2419 if ( state.lens[ 256 ] === 0 ) { 2420 strm.msg = 2421 'invalid code -- missing end-of-block'; 2422 state.mode = BAD; 2423 break; 2424 } 2425 2426 /* build code tables -- note: do not change the lenbits or distbits 2427 values here (9 and 6) without reading the comments in inftrees.h 2428 concerning the ENOUGH constants, which depend on those values */ 2429 state.lenbits = 9; 2430 2431 opts = { bits: state.lenbits }; 2432 ret = inflate_table( 2433 LENS, 2434 state.lens, 2435 0, 2436 state.nlen, 2437 state.lencode, 2438 0, 2439 state.work, 2440 opts 2441 ); 2442 // We have separate tables & no pointers. 2 commented lines below not needed. 2443 // state.next_index = opts.table_index; 2444 state.lenbits = opts.bits; 2445 // state.lencode = state.next; 2446 2447 if ( ret ) { 2448 strm.msg = 2449 'invalid literal/lengths set'; 2450 state.mode = BAD; 2451 break; 2452 } 2453 2454 state.distbits = 6; 2455 //state.distcode.copy(state.codes); 2456 // Switch to use dynamic table 2457 state.distcode = state.distdyn; 2458 opts = { bits: state.distbits }; 2459 ret = inflate_table( 2460 DISTS, 2461 state.lens, 2462 state.nlen, 2463 state.ndist, 2464 state.distcode, 2465 0, 2466 state.work, 2467 opts 2468 ); 2469 // We have separate tables & no pointers. 2 commented lines below not needed. 2470 // state.next_index = opts.table_index; 2471 state.distbits = opts.bits; 2472 // state.distcode = state.next; 2473 2474 if ( ret ) { 2475 strm.msg = 'invalid distances set'; 2476 state.mode = BAD; 2477 break; 2478 } 2479 //Tracev((stderr, 'inflate: codes ok\n')); 2480 state.mode = LEN_; 2481 if ( flush === Z_TREES ) { 2482 break inf_leave; 2483 } 2484 /* falls through */ 2485 case LEN_: 2486 state.mode = LEN; 2487 /* falls through */ 2488 case LEN: 2489 if ( have >= 6 && left >= 258 ) { 2490 //--- RESTORE() --- 2491 strm.next_out = put; 2492 strm.avail_out = left; 2493 strm.next_in = next; 2494 strm.avail_in = have; 2495 state.hold = hold; 2496 state.bits = bits; 2497 //--- 2498 inflate_fast( strm, _out ); 2499 //--- LOAD() --- 2500 put = strm.next_out; 2501 output = strm.output; 2502 left = strm.avail_out; 2503 next = strm.next_in; 2504 input = strm.input; 2505 have = strm.avail_in; 2506 hold = state.hold; 2507 bits = state.bits; 2508 //--- 2509 2510 if ( state.mode === TYPE ) { 2511 state.back = -1; 2512 } 2513 break; 2514 } 2515 state.back = 0; 2516 for (;;) { 2517 here = 2518 state.lencode[ 2519 hold & 2520 ( ( 1 << state.lenbits ) - 2521 1 ) 2522 ]; /*BITS(state.lenbits)*/ 2523 here_bits = here >>> 24; 2524 here_op = ( here >>> 16 ) & 0xff; 2525 here_val = here & 0xffff; 2526 2527 if ( here_bits <= bits ) { 2528 break; 2529 } 2530 //--- PULLBYTE() ---// 2531 if ( have === 0 ) { 2532 break inf_leave; 2533 } 2534 have--; 2535 hold += input[ next++ ] << bits; 2536 bits += 8; 2537 //---// 2538 } 2539 if ( here_op && ( here_op & 0xf0 ) === 0 ) { 2540 last_bits = here_bits; 2541 last_op = here_op; 2542 last_val = here_val; 2543 for (;;) { 2544 here = 2545 state.lencode[ 2546 last_val + 2547 ( ( hold & 2548 ( ( 1 << 2549 ( last_bits + 2550 last_op ) ) - 2551 1 ) ) /*BITS(last.bits + last.op)*/ >> 2552 last_bits ) 2553 ]; 2554 here_bits = here >>> 24; 2555 here_op = ( here >>> 16 ) & 0xff; 2556 here_val = here & 0xffff; 2557 2558 if ( 2559 last_bits + here_bits <= 2560 bits 2561 ) { 2562 break; 2563 } 2564 //--- PULLBYTE() ---// 2565 if ( have === 0 ) { 2566 break inf_leave; 2567 } 2568 have--; 2569 hold += input[ next++ ] << bits; 2570 bits += 8; 2571 //---// 2572 } 2573 //--- DROPBITS(last.bits) ---// 2574 hold >>>= last_bits; 2575 bits -= last_bits; 2576 //---// 2577 state.back += last_bits; 2578 } 2579 //--- DROPBITS(here.bits) ---// 2580 hold >>>= here_bits; 2581 bits -= here_bits; 2582 //---// 2583 state.back += here_bits; 2584 state.length = here_val; 2585 if ( here_op === 0 ) { 2586 //Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ? 2587 // "inflate: literal '%c'\n" : 2588 // "inflate: literal 0x%02x\n", here.val)); 2589 state.mode = LIT; 2590 break; 2591 } 2592 if ( here_op & 32 ) { 2593 //Tracevv((stderr, "inflate: end of block\n")); 2594 state.back = -1; 2595 state.mode = TYPE; 2596 break; 2597 } 2598 if ( here_op & 64 ) { 2599 strm.msg = 2600 'invalid literal/length code'; 2601 state.mode = BAD; 2602 break; 2603 } 2604 state.extra = here_op & 15; 2605 state.mode = LENEXT; 2606 /* falls through */ 2607 case LENEXT: 2608 if ( state.extra ) { 2609 //=== NEEDBITS(state.extra); 2610 n = state.extra; 2611 while ( bits < n ) { 2612 if ( have === 0 ) { 2613 break inf_leave; 2614 } 2615 have--; 2616 hold += input[ next++ ] << bits; 2617 bits += 8; 2618 } 2619 //===// 2620 state.length += 2621 hold & 2622 ( ( 1 << state.extra ) - 2623 1 ) /*BITS(state.extra)*/; 2624 //--- DROPBITS(state.extra) ---// 2625 hold >>>= state.extra; 2626 bits -= state.extra; 2627 //---// 2628 state.back += state.extra; 2629 } 2630 //Tracevv((stderr, "inflate: length %u\n", state.length)); 2631 state.was = state.length; 2632 state.mode = DIST; 2633 /* falls through */ 2634 case DIST: 2635 for (;;) { 2636 here = 2637 state.distcode[ 2638 hold & 2639 ( ( 1 << state.distbits ) - 2640 1 ) 2641 ]; /*BITS(state.distbits)*/ 2642 here_bits = here >>> 24; 2643 here_op = ( here >>> 16 ) & 0xff; 2644 here_val = here & 0xffff; 2645 2646 if ( here_bits <= bits ) { 2647 break; 2648 } 2649 //--- PULLBYTE() ---// 2650 if ( have === 0 ) { 2651 break inf_leave; 2652 } 2653 have--; 2654 hold += input[ next++ ] << bits; 2655 bits += 8; 2656 //---// 2657 } 2658 if ( ( here_op & 0xf0 ) === 0 ) { 2659 last_bits = here_bits; 2660 last_op = here_op; 2661 last_val = here_val; 2662 for (;;) { 2663 here = 2664 state.distcode[ 2665 last_val + 2666 ( ( hold & 2667 ( ( 1 << 2668 ( last_bits + 2669 last_op ) ) - 2670 1 ) ) /*BITS(last.bits + last.op)*/ >> 2671 last_bits ) 2672 ]; 2673 here_bits = here >>> 24; 2674 here_op = ( here >>> 16 ) & 0xff; 2675 here_val = here & 0xffff; 2676 2677 if ( 2678 last_bits + here_bits <= 2679 bits 2680 ) { 2681 break; 2682 } 2683 //--- PULLBYTE() ---// 2684 if ( have === 0 ) { 2685 break inf_leave; 2686 } 2687 have--; 2688 hold += input[ next++ ] << bits; 2689 bits += 8; 2690 //---// 2691 } 2692 //--- DROPBITS(last.bits) ---// 2693 hold >>>= last_bits; 2694 bits -= last_bits; 2695 //---// 2696 state.back += last_bits; 2697 } 2698 //--- DROPBITS(here.bits) ---// 2699 hold >>>= here_bits; 2700 bits -= here_bits; 2701 //---// 2702 state.back += here_bits; 2703 if ( here_op & 64 ) { 2704 strm.msg = 'invalid distance code'; 2705 state.mode = BAD; 2706 break; 2707 } 2708 state.offset = here_val; 2709 state.extra = here_op & 15; 2710 state.mode = DISTEXT; 2711 /* falls through */ 2712 case DISTEXT: 2713 if ( state.extra ) { 2714 //=== NEEDBITS(state.extra); 2715 n = state.extra; 2716 while ( bits < n ) { 2717 if ( have === 0 ) { 2718 break inf_leave; 2719 } 2720 have--; 2721 hold += input[ next++ ] << bits; 2722 bits += 8; 2723 } 2724 //===// 2725 state.offset += 2726 hold & 2727 ( ( 1 << state.extra ) - 2728 1 ) /*BITS(state.extra)*/; 2729 //--- DROPBITS(state.extra) ---// 2730 hold >>>= state.extra; 2731 bits -= state.extra; 2732 //---// 2733 state.back += state.extra; 2734 } 2735 //#ifdef INFLATE_STRICT 2736 if ( state.offset > state.dmax ) { 2737 strm.msg = 2738 'invalid distance too far back'; 2739 state.mode = BAD; 2740 break; 2741 } 2742 //#endif 2743 //Tracevv((stderr, "inflate: distance %u\n", state.offset)); 2744 state.mode = MATCH; 2745 /* falls through */ 2746 case MATCH: 2747 if ( left === 0 ) { 2748 break inf_leave; 2749 } 2750 copy = _out - left; 2751 if ( state.offset > copy ) { 2752 /* copy from window */ 2753 copy = state.offset - copy; 2754 if ( copy > state.whave ) { 2755 if ( state.sane ) { 2756 strm.msg = 2757 'invalid distance too far back'; 2758 state.mode = BAD; 2759 break; 2760 } 2761 // (!) This block is disabled in zlib defaults, 2762 // don't enable it for binary compatibility 2763 //#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR 2764 // Trace((stderr, "inflate.c too far\n")); 2765 // copy -= state.whave; 2766 // if (copy > state.length) { copy = state.length; } 2767 // if (copy > left) { copy = left; } 2768 // left -= copy; 2769 // state.length -= copy; 2770 // do { 2771 // output[put++] = 0; 2772 // } while (--copy); 2773 // if (state.length === 0) { state.mode = LEN; } 2774 // break; 2775 //#endif 2776 } 2777 if ( copy > state.wnext ) { 2778 copy -= state.wnext; 2779 from = state.wsize - copy; 2780 } else { 2781 from = state.wnext - copy; 2782 } 2783 if ( copy > state.length ) { 2784 copy = state.length; 2785 } 2786 from_source = state.window; 2787 } else { 2788 /* copy from output */ 2789 from_source = output; 2790 from = put - state.offset; 2791 copy = state.length; 2792 } 2793 if ( copy > left ) { 2794 copy = left; 2795 } 2796 left -= copy; 2797 state.length -= copy; 2798 do { 2799 output[ put++ ] = from_source[ from++ ]; 2800 } while ( --copy ); 2801 if ( state.length === 0 ) { 2802 state.mode = LEN; 2803 } 2804 break; 2805 case LIT: 2806 if ( left === 0 ) { 2807 break inf_leave; 2808 } 2809 output[ put++ ] = state.length; 2810 left--; 2811 state.mode = LEN; 2812 break; 2813 case CHECK: 2814 if ( state.wrap ) { 2815 //=== NEEDBITS(32); 2816 while ( bits < 32 ) { 2817 if ( have === 0 ) { 2818 break inf_leave; 2819 } 2820 have--; 2821 // Use '|' instead of '+' to make sure that result is signed 2822 hold |= input[ next++ ] << bits; 2823 bits += 8; 2824 } 2825 //===// 2826 _out -= left; 2827 strm.total_out += _out; 2828 state.total += _out; 2829 if ( _out ) { 2830 strm.adler = state.check = 2831 /*UPDATE(state.check, put - _out, _out);*/ 2832 state.flags 2833 ? crc32( 2834 state.check, 2835 output, 2836 _out, 2837 put - _out 2838 ) 2839 : adler32( 2840 state.check, 2841 output, 2842 _out, 2843 put - _out 2844 ); 2845 } 2846 _out = left; 2847 // NB: crc32 stored as signed 32-bit int, zswap32 returns signed too 2848 if ( 2849 ( state.flags 2850 ? hold 2851 : zswap32( hold ) ) !== 2852 state.check 2853 ) { 2854 strm.msg = 'incorrect data check'; 2855 state.mode = BAD; 2856 break; 2857 } 2858 //=== INITBITS(); 2859 hold = 0; 2860 bits = 0; 2861 //===// 2862 //Tracev((stderr, "inflate: check matches trailer\n")); 2863 } 2864 state.mode = LENGTH; 2865 /* falls through */ 2866 case LENGTH: 2867 if ( state.wrap && state.flags ) { 2868 //=== NEEDBITS(32); 2869 while ( bits < 32 ) { 2870 if ( have === 0 ) { 2871 break inf_leave; 2872 } 2873 have--; 2874 hold += input[ next++ ] << bits; 2875 bits += 8; 2876 } 2877 //===// 2878 if ( 2879 hold !== 2880 ( state.total & 0xffffffff ) 2881 ) { 2882 strm.msg = 'incorrect length check'; 2883 state.mode = BAD; 2884 break; 2885 } 2886 //=== INITBITS(); 2887 hold = 0; 2888 bits = 0; 2889 //===// 2890 //Tracev((stderr, "inflate: length matches trailer\n")); 2891 } 2892 state.mode = DONE; 2893 /* falls through */ 2894 case DONE: 2895 ret = Z_STREAM_END; 2896 break inf_leave; 2897 case BAD: 2898 ret = Z_DATA_ERROR; 2899 break inf_leave; 2900 case MEM: 2901 return Z_MEM_ERROR; 2902 case SYNC: 2903 /* falls through */ 2904 default: 2905 return Z_STREAM_ERROR; 2906 } 2907 } 2908 2909 // inf_leave <- here is real place for "goto inf_leave", emulated via "break inf_leave" 2910 2911 /* 2912 Return from inflate(), updating the total counts and the check value. 2913 If there was no progress during the inflate() call, return a buffer 2914 error. Call updatewindow() to create and/or update the window state. 2915 Note: a memory error from inflate() is non-recoverable. 2916 */ 2917 2918 //--- RESTORE() --- 2919 strm.next_out = put; 2920 strm.avail_out = left; 2921 strm.next_in = next; 2922 strm.avail_in = have; 2923 state.hold = hold; 2924 state.bits = bits; 2925 //--- 2926 2927 if ( 2928 state.wsize || 2929 ( _out !== strm.avail_out && 2930 state.mode < BAD && 2931 ( state.mode < CHECK || flush !== Z_FINISH ) ) 2932 ) { 2933 if ( 2934 updatewindow( 2935 strm, 2936 strm.output, 2937 strm.next_out, 2938 _out - strm.avail_out 2939 ) 2940 ) { 2941 state.mode = MEM; 2942 return Z_MEM_ERROR; 2943 } 2944 } 2945 _in -= strm.avail_in; 2946 _out -= strm.avail_out; 2947 strm.total_in += _in; 2948 strm.total_out += _out; 2949 state.total += _out; 2950 if ( state.wrap && _out ) { 2951 strm.adler = state.check = 2952 /*UPDATE(state.check, strm.next_out - _out, _out);*/ 2953 state.flags 2954 ? crc32( 2955 state.check, 2956 output, 2957 _out, 2958 strm.next_out - _out 2959 ) 2960 : adler32( 2961 state.check, 2962 output, 2963 _out, 2964 strm.next_out - _out 2965 ); 2966 } 2967 strm.data_type = 2968 state.bits + 2969 ( state.last ? 64 : 0 ) + 2970 ( state.mode === TYPE ? 128 : 0 ) + 2971 ( state.mode === LEN_ || state.mode === COPY_ 2972 ? 256 2973 : 0 ); 2974 if ( 2975 ( ( _in === 0 && _out === 0 ) || 2976 flush === Z_FINISH ) && 2977 ret === Z_OK 2978 ) { 2979 ret = Z_BUF_ERROR; 2980 } 2981 return ret; 2982 } 2983 2984 function inflateEnd( strm ) { 2985 if ( 2986 ! strm || 2987 ! strm.state /*|| strm->zfree == (free_func)0*/ 2988 ) { 2989 return Z_STREAM_ERROR; 2990 } 2991 2992 var state = strm.state; 2993 if ( state.window ) { 2994 state.window = null; 2995 } 2996 strm.state = null; 2997 return Z_OK; 2998 } 2999 3000 function inflateGetHeader( strm, head ) { 3001 var state; 3002 3003 /* check state */ 3004 if ( ! strm || ! strm.state ) { 3005 return Z_STREAM_ERROR; 3006 } 3007 state = strm.state; 3008 if ( ( state.wrap & 2 ) === 0 ) { 3009 return Z_STREAM_ERROR; 3010 } 3011 3012 /* save header structure */ 3013 state.head = head; 3014 head.done = false; 3015 return Z_OK; 3016 } 3017 3018 function inflateSetDictionary( strm, dictionary ) { 3019 var dictLength = dictionary.length; 3020 3021 var state; 3022 var dictid; 3023 var ret; 3024 3025 /* check state */ 3026 if ( 3027 ! strm /* == Z_NULL */ || 3028 ! strm.state /* == Z_NULL */ 3029 ) { 3030 return Z_STREAM_ERROR; 3031 } 3032 state = strm.state; 3033 3034 if ( state.wrap !== 0 && state.mode !== DICT ) { 3035 return Z_STREAM_ERROR; 3036 } 3037 3038 /* check for correct dictionary identifier */ 3039 if ( state.mode === DICT ) { 3040 dictid = 1; /* adler32(0, null, 0)*/ 3041 /* dictid = adler32(dictid, dictionary, dictLength); */ 3042 dictid = adler32( 3043 dictid, 3044 dictionary, 3045 dictLength, 3046 0 3047 ); 3048 if ( dictid !== state.check ) { 3049 return Z_DATA_ERROR; 3050 } 3051 } 3052 /* copy dictionary to window using updatewindow(), which will amend the 3053 existing dictionary if appropriate */ 3054 ret = updatewindow( 3055 strm, 3056 dictionary, 3057 dictLength, 3058 dictLength 3059 ); 3060 if ( ret ) { 3061 state.mode = MEM; 3062 return Z_MEM_ERROR; 3063 } 3064 state.havedict = 1; 3065 // Tracev((stderr, "inflate: dictionary set\n")); 3066 return Z_OK; 3067 } 3068 3069 exports.inflateReset = inflateReset; 3070 exports.inflateReset2 = inflateReset2; 3071 exports.inflateResetKeep = inflateResetKeep; 3072 exports.inflateInit = inflateInit; 3073 exports.inflateInit2 = inflateInit2; 3074 exports.inflate = inflate; 3075 exports.inflateEnd = inflateEnd; 3076 exports.inflateGetHeader = inflateGetHeader; 3077 exports.inflateSetDictionary = inflateSetDictionary; 3078 exports.inflateInfo = 'pako inflate (from Nodeca project)'; 3079 3080 /* Not implemented 3081 exports.inflateCopy = inflateCopy; 3082 exports.inflateGetDictionary = inflateGetDictionary; 3083 exports.inflateMark = inflateMark; 3084 exports.inflatePrime = inflatePrime; 3085 exports.inflateSync = inflateSync; 3086 exports.inflateSyncPoint = inflateSyncPoint; 3087 exports.inflateUndermine = inflateUndermine; 3088 */ 3089 }, 3090 { 3091 '../utils/common': 1, 3092 './adler32': 3, 3093 './crc32': 5, 3094 './inffast': 7, 3095 './inftrees': 9, 3096 }, 3097 ], 3098 9: [ 3099 function ( require, module, exports ) { 3100 'use strict'; 3101 3102 // (C) 1995-2013 Jean-loup Gailly and Mark Adler 3103 // (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin 3104 // 3105 // This software is provided 'as-is', without any express or implied 3106 // warranty. In no event will the authors be held liable for any damages 3107 // arising from the use of this software. 3108 // 3109 // Permission is granted to anyone to use this software for any purpose, 3110 // including commercial applications, and to alter it and redistribute it 3111 // freely, subject to the following restrictions: 3112 // 3113 // 1. The origin of this software must not be misrepresented; you must not 3114 // claim that you wrote the original software. If you use this software 3115 // in a product, an acknowledgment in the product documentation would be 3116 // appreciated but is not required. 3117 // 2. Altered source versions must be plainly marked as such, and must not be 3118 // misrepresented as being the original software. 3119 // 3. This notice may not be removed or altered from any source distribution. 3120 3121 var utils = require( '../utils/common' ); 3122 3123 var MAXBITS = 15; 3124 var ENOUGH_LENS = 852; 3125 var ENOUGH_DISTS = 592; 3126 //var ENOUGH = (ENOUGH_LENS+ENOUGH_DISTS); 3127 3128 var CODES = 0; 3129 var LENS = 1; 3130 var DISTS = 2; 3131 3132 var lbase = [ 3133 /* Length codes 257..285 base */ 3, 4, 5, 6, 7, 8, 9, 3134 10, 11, 13, 15, 17, 19, 23, 27, 31, 35, 43, 51, 59, 67, 3135 83, 99, 115, 131, 163, 195, 227, 258, 0, 0, 3136 ]; 3137 3138 var lext = [ 3139 /* Length codes 257..285 extra */ 16, 16, 16, 16, 16, 3140 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18, 19, 19, 19, 3141 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 72, 78, 3142 ]; 3143 3144 var dbase = [ 3145 /* Distance codes 0..29 base */ 1, 2, 3, 4, 5, 7, 9, 13, 3146 17, 25, 33, 49, 65, 97, 129, 193, 257, 385, 513, 769, 3147 1025, 1537, 2049, 3073, 4097, 6145, 8193, 12289, 16385, 3148 24577, 0, 0, 3149 ]; 3150 3151 var dext = [ 3152 /* Distance codes 0..29 extra */ 16, 16, 16, 16, 17, 17, 3153 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 3154 25, 25, 26, 26, 27, 27, 28, 28, 29, 29, 64, 64, 3155 ]; 3156 3157 module.exports = function inflate_table( 3158 type, 3159 lens, 3160 lens_index, 3161 codes, 3162 table, 3163 table_index, 3164 work, 3165 opts 3166 ) { 3167 var bits = opts.bits; 3168 //here = opts.here; /* table entry for duplication */ 3169 3170 var len = 0; /* a code's length in bits */ 3171 var sym = 0; /* index of code symbols */ 3172 var min = 0, 3173 max = 0; /* minimum and maximum code lengths */ 3174 var root = 0; /* number of index bits for root table */ 3175 var curr = 0; /* number of index bits for current table */ 3176 var drop = 0; /* code bits to drop for sub-table */ 3177 var left = 0; /* number of prefix codes available */ 3178 var used = 0; /* code entries in table used */ 3179 var huff = 0; /* Huffman code */ 3180 var incr; /* for incrementing code, index */ 3181 var fill; /* index for replicating entries */ 3182 var low; /* low bits for current root entry */ 3183 var mask; /* mask for low root bits */ 3184 var next; /* next available space in table */ 3185 var base = null; /* base value table to use */ 3186 var base_index = 0; 3187 // var shoextra; /* extra bits table to use */ 3188 var end; /* use base and extra for symbol > end */ 3189 var count = new utils.Buf16( MAXBITS + 1 ); //[MAXBITS+1]; /* number of codes of each length */ 3190 var offs = new utils.Buf16( MAXBITS + 1 ); //[MAXBITS+1]; /* offsets in table for each length */ 3191 var extra = null; 3192 var extra_index = 0; 3193 3194 var here_bits, here_op, here_val; 3195 3196 /* 3197 Process a set of code lengths to create a canonical Huffman code. The 3198 code lengths are lens[0..codes-1]. Each length corresponds to the 3199 symbols 0..codes-1. The Huffman code is generated by first sorting the 3200 symbols by length from short to long, and retaining the symbol order 3201 for codes with equal lengths. Then the code starts with all zero bits 3202 for the first code of the shortest length, and the codes are integer 3203 increments for the same length, and zeros are appended as the length 3204 increases. For the deflate format, these bits are stored backwards 3205 from their more natural integer increment ordering, and so when the 3206 decoding tables are built in the large loop below, the integer codes 3207 are incremented backwards. 3208 3209 This routine assumes, but does not check, that all of the entries in 3210 lens[] are in the range 0..MAXBITS. The caller must assure this. 3211 1..MAXBITS is interpreted as that code length. zero means that that 3212 symbol does not occur in this code. 3213 3214 The codes are sorted by computing a count of codes for each length, 3215 creating from that a table of starting indices for each length in the 3216 sorted table, and then entering the symbols in order in the sorted 3217 table. The sorted table is work[], with that space being provided by 3218 the caller. 3219 3220 The length counts are used for other purposes as well, i.e. finding 3221 the minimum and maximum length codes, determining if there are any 3222 codes at all, checking for a valid set of lengths, and looking ahead 3223 at length counts to determine sub-table sizes when building the 3224 decoding tables. 3225 */ 3226 3227 /* accumulate lengths for codes (assumes lens[] all in 0..MAXBITS) */ 3228 for ( len = 0; len <= MAXBITS; len++ ) { 3229 count[ len ] = 0; 3230 } 3231 for ( sym = 0; sym < codes; sym++ ) { 3232 count[ lens[ lens_index + sym ] ]++; 3233 } 3234 3235 /* bound code lengths, force root to be within code lengths */ 3236 root = bits; 3237 for ( max = MAXBITS; max >= 1; max-- ) { 3238 if ( count[ max ] !== 0 ) { 3239 break; 3240 } 3241 } 3242 if ( root > max ) { 3243 root = max; 3244 } 3245 if ( max === 0 ) { 3246 /* no symbols to code at all */ 3247 //table.op[opts.table_index] = 64; //here.op = (var char)64; /* invalid code marker */ 3248 //table.bits[opts.table_index] = 1; //here.bits = (var char)1; 3249 //table.val[opts.table_index++] = 0; //here.val = (var short)0; 3250 table[ table_index++ ] = 3251 ( 1 << 24 ) | ( 64 << 16 ) | 0; 3252 3253 //table.op[opts.table_index] = 64; 3254 //table.bits[opts.table_index] = 1; 3255 //table.val[opts.table_index++] = 0; 3256 table[ table_index++ ] = 3257 ( 1 << 24 ) | ( 64 << 16 ) | 0; 3258 3259 opts.bits = 1; 3260 return 0; /* no symbols, but wait for decoding to report error */ 3261 } 3262 for ( min = 1; min < max; min++ ) { 3263 if ( count[ min ] !== 0 ) { 3264 break; 3265 } 3266 } 3267 if ( root < min ) { 3268 root = min; 3269 } 3270 3271 /* check for an over-subscribed or incomplete set of lengths */ 3272 left = 1; 3273 for ( len = 1; len <= MAXBITS; len++ ) { 3274 left <<= 1; 3275 left -= count[ len ]; 3276 if ( left < 0 ) { 3277 return -1; 3278 } /* over-subscribed */ 3279 } 3280 if ( left > 0 && ( type === CODES || max !== 1 ) ) { 3281 return -1; /* incomplete set */ 3282 } 3283 3284 /* generate offsets into symbol table for each length for sorting */ 3285 offs[ 1 ] = 0; 3286 for ( len = 1; len < MAXBITS; len++ ) { 3287 offs[ len + 1 ] = offs[ len ] + count[ len ]; 3288 } 3289 3290 /* sort symbols by length, by symbol order within each length */ 3291 for ( sym = 0; sym < codes; sym++ ) { 3292 if ( lens[ lens_index + sym ] !== 0 ) { 3293 work[ offs[ lens[ lens_index + sym ] ]++ ] = 3294 sym; 3295 } 3296 } 3297 3298 /* 3299 Create and fill in decoding tables. In this loop, the table being 3300 filled is at next and has curr index bits. The code being used is huff 3301 with length len. That code is converted to an index by dropping drop 3302 bits off of the bottom. For codes where len is less than drop + curr, 3303 those top drop + curr - len bits are incremented through all values to 3304 fill the table with replicated entries. 3305 3306 root is the number of index bits for the root table. When len exceeds 3307 root, sub-tables are created pointed to by the root entry with an index 3308 of the low root bits of huff. This is saved in low to check for when a 3309 new sub-table should be started. drop is zero when the root table is 3310 being filled, and drop is root when sub-tables are being filled. 3311 3312 When a new sub-table is needed, it is necessary to look ahead in the 3313 code lengths to determine what size sub-table is needed. The length 3314 counts are used for this, and so count[] is decremented as codes are 3315 entered in the tables. 3316 3317 used keeps track of how many table entries have been allocated from the 3318 provided *table space. It is checked for LENS and DIST tables against 3319 the constants ENOUGH_LENS and ENOUGH_DISTS to guard against changes in 3320 the initial root table size constants. See the comments in inftrees.h 3321 for more information. 3322 3323 sym increments through all symbols, and the loop terminates when 3324 all codes of length max, i.e. all codes, have been processed. This 3325 routine permits incomplete codes, so another loop after this one fills 3326 in the rest of the decoding tables with invalid code markers. 3327 */ 3328 3329 /* set up for code type */ 3330 // poor man optimization - use if-else instead of switch, 3331 // to avoid deopts in old v8 3332 if ( type === CODES ) { 3333 base = extra = work; /* dummy value--not used */ 3334 end = 19; 3335 } else if ( type === LENS ) { 3336 base = lbase; 3337 base_index -= 257; 3338 extra = lext; 3339 extra_index -= 257; 3340 end = 256; 3341 } else { 3342 /* DISTS */ 3343 base = dbase; 3344 extra = dext; 3345 end = -1; 3346 } 3347 3348 /* initialize opts for loop */ 3349 huff = 0; /* starting code */ 3350 sym = 0; /* starting code symbol */ 3351 len = min; /* starting code length */ 3352 next = table_index; /* current table to fill in */ 3353 curr = root; /* current table index bits */ 3354 drop = 0; /* current bits to drop from code for index */ 3355 low = -1; /* trigger new sub-table when len > root */ 3356 used = 1 << root; /* use root table entries */ 3357 mask = used - 1; /* mask for comparing low */ 3358 3359 /* check available table space */ 3360 if ( 3361 ( type === LENS && used > ENOUGH_LENS ) || 3362 ( type === DISTS && used > ENOUGH_DISTS ) 3363 ) { 3364 return 1; 3365 } 3366 3367 /* process all codes and make table entries */ 3368 for (;;) { 3369 /* create table entry */ 3370 here_bits = len - drop; 3371 if ( work[ sym ] < end ) { 3372 here_op = 0; 3373 here_val = work[ sym ]; 3374 } else if ( work[ sym ] > end ) { 3375 here_op = extra[ extra_index + work[ sym ] ]; 3376 here_val = base[ base_index + work[ sym ] ]; 3377 } else { 3378 here_op = 32 + 64; /* end of block */ 3379 here_val = 0; 3380 } 3381 3382 /* replicate for those indices with low len bits equal to huff */ 3383 incr = 1 << ( len - drop ); 3384 fill = 1 << curr; 3385 min = fill; /* save offset to next table */ 3386 do { 3387 fill -= incr; 3388 table[ next + ( huff >> drop ) + fill ] = 3389 ( here_bits << 24 ) | 3390 ( here_op << 16 ) | 3391 here_val | 3392 0; 3393 } while ( fill !== 0 ); 3394 3395 /* backwards increment the len-bit code huff */ 3396 incr = 1 << ( len - 1 ); 3397 while ( huff & incr ) { 3398 incr >>= 1; 3399 } 3400 if ( incr !== 0 ) { 3401 huff &= incr - 1; 3402 huff += incr; 3403 } else { 3404 huff = 0; 3405 } 3406 3407 /* go to next symbol, update count, len */ 3408 sym++; 3409 if ( --count[ len ] === 0 ) { 3410 if ( len === max ) { 3411 break; 3412 } 3413 len = lens[ lens_index + work[ sym ] ]; 3414 } 3415 3416 /* create new sub-table if needed */ 3417 if ( len > root && ( huff & mask ) !== low ) { 3418 /* if first time, transition to sub-tables */ 3419 if ( drop === 0 ) { 3420 drop = root; 3421 } 3422 3423 /* increment past last table */ 3424 next += min; /* here min is 1 << curr */ 3425 3426 /* determine length of next table */ 3427 curr = len - drop; 3428 left = 1 << curr; 3429 while ( curr + drop < max ) { 3430 left -= count[ curr + drop ]; 3431 if ( left <= 0 ) { 3432 break; 3433 } 3434 curr++; 3435 left <<= 1; 3436 } 3437 3438 /* check for enough space */ 3439 used += 1 << curr; 3440 if ( 3441 ( type === LENS && used > ENOUGH_LENS ) || 3442 ( type === DISTS && used > ENOUGH_DISTS ) 3443 ) { 3444 return 1; 3445 } 3446 3447 /* point entry in root table to sub-table */ 3448 low = huff & mask; 3449 /*table.op[low] = curr; 3450 table.bits[low] = root; 3451 table.val[low] = next - opts.table_index;*/ 3452 table[ low ] = 3453 ( root << 24 ) | 3454 ( curr << 16 ) | 3455 ( next - table_index ) | 3456 0; 3457 } 3458 } 3459 3460 /* fill in remaining table entry if code is incomplete (guaranteed to have 3461 at most one remaining entry, since if the code is incomplete, the 3462 maximum code length that was allowed to get this far is one bit) */ 3463 if ( huff !== 0 ) { 3464 //table.op[next + huff] = 64; /* invalid code marker */ 3465 //table.bits[next + huff] = len - drop; 3466 //table.val[next + huff] = 0; 3467 table[ next + huff ] = 3468 ( ( len - drop ) << 24 ) | ( 64 << 16 ) | 0; 3469 } 3470 3471 /* set return parameters */ 3472 //opts.table_index += used; 3473 opts.bits = root; 3474 return 0; 3475 }; 3476 }, 3477 { '../utils/common': 1 }, 3478 ], 3479 10: [ 3480 function ( require, module, exports ) { 3481 'use strict'; 3482 3483 // (C) 1995-2013 Jean-loup Gailly and Mark Adler 3484 // (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin 3485 // 3486 // This software is provided 'as-is', without any express or implied 3487 // warranty. In no event will the authors be held liable for any damages 3488 // arising from the use of this software. 3489 // 3490 // Permission is granted to anyone to use this software for any purpose, 3491 // including commercial applications, and to alter it and redistribute it 3492 // freely, subject to the following restrictions: 3493 // 3494 // 1. The origin of this software must not be misrepresented; you must not 3495 // claim that you wrote the original software. If you use this software 3496 // in a product, an acknowledgment in the product documentation would be 3497 // appreciated but is not required. 3498 // 2. Altered source versions must be plainly marked as such, and must not be 3499 // misrepresented as being the original software. 3500 // 3. This notice may not be removed or altered from any source distribution. 3501 3502 module.exports = { 3503 2: 'need dictionary' /* Z_NEED_DICT 2 */, 3504 1: 'stream end' /* Z_STREAM_END 1 */, 3505 0: '' /* Z_OK 0 */, 3506 '-1': 'file error' /* Z_ERRNO (-1) */, 3507 '-2': 'stream error' /* Z_STREAM_ERROR (-2) */, 3508 '-3': 'data error' /* Z_DATA_ERROR (-3) */, 3509 '-4': 'insufficient memory' /* Z_MEM_ERROR (-4) */, 3510 '-5': 'buffer error' /* Z_BUF_ERROR (-5) */, 3511 '-6': 'incompatible version' /* Z_VERSION_ERROR (-6) */, 3512 }; 3513 }, 3514 {}, 3515 ], 3516 11: [ 3517 function ( require, module, exports ) { 3518 'use strict'; 3519 3520 // (C) 1995-2013 Jean-loup Gailly and Mark Adler 3521 // (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin 3522 // 3523 // This software is provided 'as-is', without any express or implied 3524 // warranty. In no event will the authors be held liable for any damages 3525 // arising from the use of this software. 3526 // 3527 // Permission is granted to anyone to use this software for any purpose, 3528 // including commercial applications, and to alter it and redistribute it 3529 // freely, subject to the following restrictions: 3530 // 3531 // 1. The origin of this software must not be misrepresented; you must not 3532 // claim that you wrote the original software. If you use this software 3533 // in a product, an acknowledgment in the product documentation would be 3534 // appreciated but is not required. 3535 // 2. Altered source versions must be plainly marked as such, and must not be 3536 // misrepresented as being the original software. 3537 // 3. This notice may not be removed or altered from any source distribution. 3538 3539 function ZStream() { 3540 /* next input byte */ 3541 this.input = null; // JS specific, because we have no pointers 3542 this.next_in = 0; 3543 /* number of bytes available at input */ 3544 this.avail_in = 0; 3545 /* total number of input bytes read so far */ 3546 this.total_in = 0; 3547 /* next output byte should be put there */ 3548 this.output = null; // JS specific, because we have no pointers 3549 this.next_out = 0; 3550 /* remaining free space at output */ 3551 this.avail_out = 0; 3552 /* total number of bytes output so far */ 3553 this.total_out = 0; 3554 /* last error message, NULL if no error */ 3555 this.msg = '' /*Z_NULL*/; 3556 /* not visible by applications */ 3557 this.state = null; 3558 /* best guess about the data type: binary or text */ 3559 this.data_type = 2 /*Z_UNKNOWN*/; 3560 /* adler32 value of the uncompressed data */ 3561 this.adler = 0; 3562 } 3563 3564 module.exports = ZStream; 3565 }, 3566 {}, 3567 ], 3568 '/lib/inflate.js': [ 3569 function ( require, module, exports ) { 3570 'use strict'; 3571 3572 var zlib_inflate = require( './zlib/inflate' ); 3573 var utils = require( './utils/common' ); 3574 var strings = require( './utils/strings' ); 3575 var c = require( './zlib/constants' ); 3576 var msg = require( './zlib/messages' ); 3577 var ZStream = require( './zlib/zstream' ); 3578 var GZheader = require( './zlib/gzheader' ); 3579 3580 var toString = Object.prototype.toString; 3581 3582 /** 3583 * class Inflate 3584 * 3585 * Generic JS-style wrapper for zlib calls. If you don't need 3586 * streaming behaviour - use more simple functions: [[inflate]] 3587 * and [[inflateRaw]]. 3588 **/ 3589 3590 /* internal 3591 * inflate.chunks -> Array 3592 * 3593 * Chunks of output data, if [[Inflate#onData]] not overridden. 3594 **/ 3595 3596 /** 3597 * Inflate.result -> Uint8Array|Array|String 3598 * 3599 * Uncompressed result, generated by default [[Inflate#onData]] 3600 * and [[Inflate#onEnd]] handlers. Filled after you push last chunk 3601 * (call [[Inflate#push]] with `Z_FINISH` / `true` param) or if you 3602 * push a chunk with explicit flush (call [[Inflate#push]] with 3603 * `Z_SYNC_FLUSH` param). 3604 **/ 3605 3606 /** 3607 * Inflate.err -> Number 3608 * 3609 * Error code after inflate finished. 0 (Z_OK) on success. 3610 * Should be checked if broken data possible. 3611 **/ 3612 3613 /** 3614 * Inflate.msg -> String 3615 * 3616 * Error message, if [[Inflate.err]] != 0 3617 **/ 3618 3619 /** 3620 * new Inflate(options) 3621 * - options (Object): zlib inflate options. 3622 * 3623 * Creates new inflator instance with specified params. Throws exception 3624 * on bad params. Supported options: 3625 * 3626 * - `windowBits` 3627 * - `dictionary` 3628 * 3629 * [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced) 3630 * for more information on these. 3631 * 3632 * Additional options, for internal needs: 3633 * 3634 * - `chunkSize` - size of generated data chunks (16K by default) 3635 * - `raw` (Boolean) - do raw inflate 3636 * - `to` (String) - if equal to 'string', then result will be converted 3637 * from utf8 to utf16 (javascript) string. When string output requested, 3638 * chunk length can differ from `chunkSize`, depending on content. 3639 * 3640 * By default, when no options set, autodetect deflate/gzip data format via 3641 * wrapper header. 3642 * 3643 * ##### Example: 3644 * 3645 * ```javascript 3646 * var pako = require('pako') 3647 * , chunk1 = Uint8Array([1,2,3,4,5,6,7,8,9]) 3648 * , chunk2 = Uint8Array([10,11,12,13,14,15,16,17,18,19]); 3649 * 3650 * var inflate = new pako.Inflate({ level: 3}); 3651 * 3652 * inflate.push(chunk1, false); 3653 * inflate.push(chunk2, true); // true -> last chunk 3654 * 3655 * if (inflate.err) { throw new Error(inflate.err); } 3656 * 3657 * console.log(inflate.result); 3658 * ``` 3659 **/ 3660 function Inflate( options ) { 3661 if ( ! ( this instanceof Inflate ) ) 3662 return new Inflate( options ); 3663 3664 this.options = utils.assign( 3665 { 3666 chunkSize: 16384, 3667 windowBits: 0, 3668 to: '', 3669 }, 3670 options || {} 3671 ); 3672 3673 var opt = this.options; 3674 3675 // Force window size for `raw` data, if not set directly, 3676 // because we have no header for autodetect. 3677 if ( 3678 opt.raw && 3679 opt.windowBits >= 0 && 3680 opt.windowBits < 16 3681 ) { 3682 opt.windowBits = -opt.windowBits; 3683 if ( opt.windowBits === 0 ) { 3684 opt.windowBits = -15; 3685 } 3686 } 3687 3688 // If `windowBits` not defined (and mode not raw) - set autodetect flag for gzip/deflate 3689 if ( 3690 opt.windowBits >= 0 && 3691 opt.windowBits < 16 && 3692 ! ( options && options.windowBits ) 3693 ) { 3694 opt.windowBits += 32; 3695 } 3696 3697 // Gzip header has no info about windows size, we can do autodetect only 3698 // for deflate. So, if window size not set, force it to max when gzip possible 3699 if ( opt.windowBits > 15 && opt.windowBits < 48 ) { 3700 // bit 3 (16) -> gzipped data 3701 // bit 4 (32) -> autodetect gzip/deflate 3702 if ( ( opt.windowBits & 15 ) === 0 ) { 3703 opt.windowBits |= 15; 3704 } 3705 } 3706 3707 this.err = 0; // error code, if happens (0 = Z_OK) 3708 this.msg = ''; // error message 3709 this.ended = false; // used to avoid multiple onEnd() calls 3710 this.chunks = []; // chunks of compressed data 3711 3712 this.strm = new ZStream(); 3713 this.strm.avail_out = 0; 3714 3715 var status = zlib_inflate.inflateInit2( 3716 this.strm, 3717 opt.windowBits 3718 ); 3719 3720 if ( status !== c.Z_OK ) { 3721 throw new Error( msg[ status ] ); 3722 } 3723 3724 this.header = new GZheader(); 3725 3726 zlib_inflate.inflateGetHeader( this.strm, this.header ); 3727 3728 // Setup dictionary 3729 if ( opt.dictionary ) { 3730 // Convert data if needed 3731 if ( typeof opt.dictionary === 'string' ) { 3732 opt.dictionary = strings.string2buf( 3733 opt.dictionary 3734 ); 3735 } else if ( 3736 toString.call( opt.dictionary ) === 3737 '[object ArrayBuffer]' 3738 ) { 3739 opt.dictionary = new Uint8Array( 3740 opt.dictionary 3741 ); 3742 } 3743 if ( opt.raw ) { 3744 //In raw mode we need to set the dictionary early 3745 status = zlib_inflate.inflateSetDictionary( 3746 this.strm, 3747 opt.dictionary 3748 ); 3749 if ( status !== c.Z_OK ) { 3750 throw new Error( msg[ status ] ); 3751 } 3752 } 3753 } 3754 } 3755 3756 /** 3757 * Inflate#push(data[, mode]) -> Boolean 3758 * - data (Uint8Array|Array|ArrayBuffer|String): input data 3759 * - mode (Number|Boolean): 0..6 for corresponding Z_NO_FLUSH..Z_TREE modes. 3760 * See constants. Skipped or `false` means Z_NO_FLUSH, `true` means Z_FINISH. 3761 * 3762 * Sends input data to inflate pipe, generating [[Inflate#onData]] calls with 3763 * new output chunks. Returns `true` on success. The last data block must have 3764 * mode Z_FINISH (or `true`). That will flush internal pending buffers and call 3765 * [[Inflate#onEnd]]. For interim explicit flushes (without ending the stream) you 3766 * can use mode Z_SYNC_FLUSH, keeping the decompression context. 3767 * 3768 * On fail call [[Inflate#onEnd]] with error code and return false. 3769 * 3770 * We strongly recommend to use `Uint8Array` on input for best speed (output 3771 * format is detected automatically). Also, don't skip last param and always 3772 * use the same type in your code (boolean or number). That will improve JS speed. 3773 * 3774 * For regular `Array`-s make sure all elements are [0..255]. 3775 * 3776 * ##### Example 3777 * 3778 * ```javascript 3779 * push(chunk, false); // push one of data chunks 3780 * ... 3781 * push(chunk, true); // push last chunk 3782 * ``` 3783 **/ 3784 Inflate.prototype.push = function ( data, mode ) { 3785 var strm = this.strm; 3786 var chunkSize = this.options.chunkSize; 3787 var dictionary = this.options.dictionary; 3788 var status, _mode; 3789 var next_out_utf8, tail, utf8str; 3790 3791 // Flag to properly process Z_BUF_ERROR on testing inflate call 3792 // when we check that all output data was flushed. 3793 var allowBufError = false; 3794 3795 if ( this.ended ) { 3796 return false; 3797 } 3798 _mode = 3799 mode === ~~mode 3800 ? mode 3801 : mode === true 3802 ? c.Z_FINISH 3803 : c.Z_NO_FLUSH; 3804 3805 // Convert data if needed 3806 if ( typeof data === 'string' ) { 3807 // Only binary strings can be decompressed on practice 3808 strm.input = strings.binstring2buf( data ); 3809 } else if ( 3810 toString.call( data ) === '[object ArrayBuffer]' 3811 ) { 3812 strm.input = new Uint8Array( data ); 3813 } else { 3814 strm.input = data; 3815 } 3816 3817 strm.next_in = 0; 3818 strm.avail_in = strm.input.length; 3819 3820 do { 3821 if ( strm.avail_out === 0 ) { 3822 strm.output = new utils.Buf8( chunkSize ); 3823 strm.next_out = 0; 3824 strm.avail_out = chunkSize; 3825 } 3826 3827 status = zlib_inflate.inflate( 3828 strm, 3829 c.Z_NO_FLUSH 3830 ); /* no bad return value */ 3831 3832 if ( status === c.Z_NEED_DICT && dictionary ) { 3833 status = zlib_inflate.inflateSetDictionary( 3834 this.strm, 3835 dictionary 3836 ); 3837 } 3838 3839 if ( 3840 status === c.Z_BUF_ERROR && 3841 allowBufError === true 3842 ) { 3843 status = c.Z_OK; 3844 allowBufError = false; 3845 } 3846 3847 if ( 3848 status !== c.Z_STREAM_END && 3849 status !== c.Z_OK 3850 ) { 3851 this.onEnd( status ); 3852 this.ended = true; 3853 return false; 3854 } 3855 3856 if ( strm.next_out ) { 3857 if ( 3858 strm.avail_out === 0 || 3859 status === c.Z_STREAM_END || 3860 ( strm.avail_in === 0 && 3861 ( _mode === c.Z_FINISH || 3862 _mode === c.Z_SYNC_FLUSH ) ) 3863 ) { 3864 if ( this.options.to === 'string' ) { 3865 next_out_utf8 = strings.utf8border( 3866 strm.output, 3867 strm.next_out 3868 ); 3869 3870 tail = strm.next_out - next_out_utf8; 3871 utf8str = strings.buf2string( 3872 strm.output, 3873 next_out_utf8 3874 ); 3875 3876 // move tail 3877 strm.next_out = tail; 3878 strm.avail_out = chunkSize - tail; 3879 if ( tail ) { 3880 utils.arraySet( 3881 strm.output, 3882 strm.output, 3883 next_out_utf8, 3884 tail, 3885 0 3886 ); 3887 } 3888 3889 this.onData( utf8str ); 3890 } else { 3891 this.onData( 3892 utils.shrinkBuf( 3893 strm.output, 3894 strm.next_out 3895 ) 3896 ); 3897 } 3898 } 3899 } 3900 3901 // When no more input data, we should check that internal inflate buffers 3902 // are flushed. The only way to do it when avail_out = 0 - run one more 3903 // inflate pass. But if output data not exists, inflate return Z_BUF_ERROR. 3904 // Here we set flag to process this error properly. 3905 // 3906 // NOTE. Deflate does not return error in this case and does not needs such 3907 // logic. 3908 if ( strm.avail_in === 0 && strm.avail_out === 0 ) { 3909 allowBufError = true; 3910 } 3911 } while ( 3912 ( strm.avail_in > 0 || strm.avail_out === 0 ) && 3913 status !== c.Z_STREAM_END 3914 ); 3915 3916 if ( status === c.Z_STREAM_END ) { 3917 _mode = c.Z_FINISH; 3918 } 3919 3920 // Finalize on the last chunk. 3921 if ( _mode === c.Z_FINISH ) { 3922 status = zlib_inflate.inflateEnd( this.strm ); 3923 this.onEnd( status ); 3924 this.ended = true; 3925 return status === c.Z_OK; 3926 } 3927 3928 // callback interim results if Z_SYNC_FLUSH. 3929 if ( _mode === c.Z_SYNC_FLUSH ) { 3930 this.onEnd( c.Z_OK ); 3931 strm.avail_out = 0; 3932 return true; 3933 } 3934 3935 return true; 3936 }; 3937 3938 /** 3939 * Inflate#onData(chunk) -> Void 3940 * - chunk (Uint8Array|Array|String): output data. Type of array depends 3941 * on js engine support. When string output requested, each chunk 3942 * will be string. 3943 * 3944 * By default, stores data blocks in `chunks[]` property and glue 3945 * those in `onEnd`. Override this handler, if you need another behaviour. 3946 **/ 3947 Inflate.prototype.onData = function ( chunk ) { 3948 this.chunks.push( chunk ); 3949 }; 3950 3951 /** 3952 * Inflate#onEnd(status) -> Void 3953 * - status (Number): inflate status. 0 (Z_OK) on success, 3954 * other if not. 3955 * 3956 * Called either after you tell inflate that the input stream is 3957 * complete (Z_FINISH) or should be flushed (Z_SYNC_FLUSH) 3958 * or if an error happened. By default - join collected chunks, 3959 * free memory and fill `results` / `err` properties. 3960 **/ 3961 Inflate.prototype.onEnd = function ( status ) { 3962 // On success - join 3963 if ( status === c.Z_OK ) { 3964 if ( this.options.to === 'string' ) { 3965 // Glue & convert here, until we teach pako to send 3966 // utf8 aligned strings to onData 3967 this.result = this.chunks.join( '' ); 3968 } else { 3969 this.result = utils.flattenChunks( 3970 this.chunks 3971 ); 3972 } 3973 } 3974 this.chunks = []; 3975 this.err = status; 3976 this.msg = this.strm.msg; 3977 }; 3978 3979 /** 3980 * inflate(data[, options]) -> Uint8Array|Array|String 3981 * - data (Uint8Array|Array|String): input data to decompress. 3982 * - options (Object): zlib inflate options. 3983 * 3984 * Decompress `data` with inflate/ungzip and `options`. Autodetect 3985 * format via wrapper header by default. That's why we don't provide 3986 * separate `ungzip` method. 3987 * 3988 * Supported options are: 3989 * 3990 * - windowBits 3991 * 3992 * [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced) 3993 * for more information. 3994 * 3995 * Sugar (options): 3996 * 3997 * - `raw` (Boolean) - say that we work with raw stream, if you don't wish to specify 3998 * negative windowBits implicitly. 3999 * - `to` (String) - if equal to 'string', then result will be converted 4000 * from utf8 to utf16 (javascript) string. When string output requested, 4001 * chunk length can differ from `chunkSize`, depending on content. 4002 * 4003 * 4004 * ##### Example: 4005 * 4006 * ```javascript 4007 * var pako = require('pako') 4008 * , input = pako.deflate([1,2,3,4,5,6,7,8,9]) 4009 * , output; 4010 * 4011 * try { 4012 * output = pako.inflate(input); 4013 * } catch (err) 4014 * console.log(err); 4015 * } 4016 * ``` 4017 **/ 4018 function inflate( input, options ) { 4019 var inflator = new Inflate( options ); 4020 4021 inflator.push( input, true ); 4022 4023 // That will never happens, if you don't cheat with options :) 4024 if ( inflator.err ) { 4025 throw inflator.msg || msg[ inflator.err ]; 4026 } 4027 4028 return inflator.result; 4029 } 4030 4031 /** 4032 * inflateRaw(data[, options]) -> Uint8Array|Array|String 4033 * - data (Uint8Array|Array|String): input data to decompress. 4034 * - options (Object): zlib inflate options. 4035 * 4036 * The same as [[inflate]], but creates raw data, without wrapper 4037 * (header and adler32 crc). 4038 **/ 4039 function inflateRaw( input, options ) { 4040 options = options || {}; 4041 options.raw = true; 4042 return inflate( input, options ); 4043 } 4044 4045 /** 4046 * ungzip(data[, options]) -> Uint8Array|Array|String 4047 * - data (Uint8Array|Array|String): input data to decompress. 4048 * - options (Object): zlib inflate options. 4049 * 4050 * Just shortcut to [[inflate]], because it autodetects format 4051 * by header.content. Done for convenience. 4052 **/ 4053 4054 exports.Inflate = Inflate; 4055 exports.inflate = inflate; 4056 exports.inflateRaw = inflateRaw; 4057 exports.ungzip = inflate; 4058 }, 4059 { 4060 './utils/common': 1, 4061 './utils/strings': 2, 4062 './zlib/constants': 4, 4063 './zlib/gzheader': 6, 4064 './zlib/inflate': 8, 4065 './zlib/messages': 10, 4066 './zlib/zstream': 11, 4067 }, 4068 ], 4069 }, 4070 {}, 4071 [] 4072 )( '/lib/inflate.js' ); 4073 } ); 4074 /* eslint-enable */ 4075 4076 4077 /***/ }), 4078 4079 /***/ 8572: 4080 /***/ ((module) => { 4081 4082 /* eslint eslint-comments/no-unlimited-disable: 0 */ 4083 /* eslint-disable */ 4084 ( function ( f ) { 4085 if ( true ) { 4086 module.exports = f(); 4087 } else { var g; } 4088 } )( function () { 4089 var define, module, exports; 4090 return ( function () { 4091 function r( e, n, t ) { 4092 function o( i, f ) { 4093 if ( ! n[ i ] ) { 4094 if ( ! e[ i ] ) { 4095 var c = undefined; 4096 if ( ! f && c ) return require( i, ! 0 ); 4097 if ( u ) return u( i, ! 0 ); 4098 var a = new Error( "Cannot find module '" + i + "'" ); 4099 throw ( ( a.code = 'MODULE_NOT_FOUND' ), a ); 4100 } 4101 var p = ( n[ i ] = { exports: {} } ); 4102 e[ i ][ 0 ].call( 4103 p.exports, 4104 function ( r ) { 4105 var n = e[ i ][ 1 ][ r ]; 4106 return o( n || r ); 4107 }, 4108 p, 4109 p.exports, 4110 r, 4111 e, 4112 n, 4113 t 4114 ); 4115 } 4116 return n[ i ].exports; 4117 } 4118 for ( 4119 var u = undefined, i = 0; 4120 i < t.length; 4121 i++ 4122 ) 4123 o( t[ i ] ); 4124 return o; 4125 } 4126 return r; 4127 } )()( 4128 { 4129 1: [ 4130 function ( require, module, exports ) { 4131 /* Copyright 2013 Google Inc. All Rights Reserved. 4132 4133 Licensed under the Apache License, Version 2.0 (the "License"); 4134 you may not use this file except in compliance with the License. 4135 You may obtain a copy of the License at 4136 4137 http://www.apache.org/licenses/LICENSE-2.0 4138 4139 Unless required by applicable law or agreed to in writing, software 4140 distributed under the License is distributed on an "AS IS" BASIS, 4141 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4142 See the License for the specific language governing permissions and 4143 limitations under the License. 4144 4145 Bit reading helpers 4146 */ 4147 4148 var BROTLI_READ_SIZE = 4096; 4149 var BROTLI_IBUF_SIZE = 2 * BROTLI_READ_SIZE + 32; 4150 var BROTLI_IBUF_MASK = 2 * BROTLI_READ_SIZE - 1; 4151 4152 var kBitMask = new Uint32Array( [ 4153 0, 1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 4154 8191, 16383, 32767, 65535, 131071, 262143, 524287, 4155 1048575, 2097151, 4194303, 8388607, 16777215, 4156 ] ); 4157 4158 /* Input byte buffer, consist of a ringbuffer and a "slack" region where */ 4159 /* bytes from the start of the ringbuffer are copied. */ 4160 function BrotliBitReader( input ) { 4161 this.buf_ = new Uint8Array( BROTLI_IBUF_SIZE ); 4162 this.input_ = input; /* input callback */ 4163 4164 this.reset(); 4165 } 4166 4167 BrotliBitReader.READ_SIZE = BROTLI_READ_SIZE; 4168 BrotliBitReader.IBUF_MASK = BROTLI_IBUF_MASK; 4169 4170 BrotliBitReader.prototype.reset = function () { 4171 this.buf_ptr_ = 0; /* next input will write here */ 4172 this.val_ = 0; /* pre-fetched bits */ 4173 this.pos_ = 0; /* byte position in stream */ 4174 this.bit_pos_ = 0; /* current bit-reading position in val_ */ 4175 this.bit_end_pos_ = 0; /* bit-reading end position from LSB of val_ */ 4176 this.eos_ = 0; /* input stream is finished */ 4177 4178 this.readMoreInput(); 4179 for ( var i = 0; i < 4; i++ ) { 4180 this.val_ |= this.buf_[ this.pos_ ] << ( 8 * i ); 4181 ++this.pos_; 4182 } 4183 4184 return this.bit_end_pos_ > 0; 4185 }; 4186 4187 /* Fills up the input ringbuffer by calling the input callback. 4188 4189 Does nothing if there are at least 32 bytes present after current position. 4190 4191 Returns 0 if either: 4192 - the input callback returned an error, or 4193 - there is no more input and the position is past the end of the stream. 4194 4195 After encountering the end of the input stream, 32 additional zero bytes are 4196 copied to the ringbuffer, therefore it is safe to call this function after 4197 every 32 bytes of input is read. 4198 */ 4199 BrotliBitReader.prototype.readMoreInput = function () { 4200 if ( this.bit_end_pos_ > 256 ) { 4201 return; 4202 } else if ( this.eos_ ) { 4203 if ( this.bit_pos_ > this.bit_end_pos_ ) 4204 throw new Error( 4205 'Unexpected end of input ' + 4206 this.bit_pos_ + 4207 ' ' + 4208 this.bit_end_pos_ 4209 ); 4210 } else { 4211 var dst = this.buf_ptr_; 4212 var bytes_read = this.input_.read( 4213 this.buf_, 4214 dst, 4215 BROTLI_READ_SIZE 4216 ); 4217 if ( bytes_read < 0 ) { 4218 throw new Error( 'Unexpected end of input' ); 4219 } 4220 4221 if ( bytes_read < BROTLI_READ_SIZE ) { 4222 this.eos_ = 1; 4223 /* Store 32 bytes of zero after the stream end. */ 4224 for ( var p = 0; p < 32; p++ ) 4225 this.buf_[ dst + bytes_read + p ] = 0; 4226 } 4227 4228 if ( dst === 0 ) { 4229 /* Copy the head of the ringbuffer to the slack region. */ 4230 for ( var p = 0; p < 32; p++ ) 4231 this.buf_[ ( BROTLI_READ_SIZE << 1 ) + p ] = 4232 this.buf_[ p ]; 4233 4234 this.buf_ptr_ = BROTLI_READ_SIZE; 4235 } else { 4236 this.buf_ptr_ = 0; 4237 } 4238 4239 this.bit_end_pos_ += bytes_read << 3; 4240 } 4241 }; 4242 4243 /* Guarantees that there are at least 24 bits in the buffer. */ 4244 BrotliBitReader.prototype.fillBitWindow = function () { 4245 while ( this.bit_pos_ >= 8 ) { 4246 this.val_ >>>= 8; 4247 this.val_ |= 4248 this.buf_[ this.pos_ & BROTLI_IBUF_MASK ] << 24; 4249 ++this.pos_; 4250 this.bit_pos_ = ( this.bit_pos_ - 8 ) >>> 0; 4251 this.bit_end_pos_ = ( this.bit_end_pos_ - 8 ) >>> 0; 4252 } 4253 }; 4254 4255 /* Reads the specified number of bits from Read Buffer. */ 4256 BrotliBitReader.prototype.readBits = function ( n_bits ) { 4257 if ( 32 - this.bit_pos_ < n_bits ) { 4258 this.fillBitWindow(); 4259 } 4260 4261 var val = 4262 ( this.val_ >>> this.bit_pos_ ) & 4263 kBitMask[ n_bits ]; 4264 this.bit_pos_ += n_bits; 4265 return val; 4266 }; 4267 4268 module.exports = BrotliBitReader; 4269 }, 4270 {}, 4271 ], 4272 2: [ 4273 function ( require, module, exports ) { 4274 /* Copyright 2013 Google Inc. All Rights Reserved. 4275 4276 Licensed under the Apache License, Version 2.0 (the "License"); 4277 you may not use this file except in compliance with the License. 4278 You may obtain a copy of the License at 4279 4280 http://www.apache.org/licenses/LICENSE-2.0 4281 4282 Unless required by applicable law or agreed to in writing, software 4283 distributed under the License is distributed on an "AS IS" BASIS, 4284 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4285 See the License for the specific language governing permissions and 4286 limitations under the License. 4287 4288 Lookup table to map the previous two bytes to a context id. 4289 4290 There are four different context modeling modes defined here: 4291 CONTEXT_LSB6: context id is the least significant 6 bits of the last byte, 4292 CONTEXT_MSB6: context id is the most significant 6 bits of the last byte, 4293 CONTEXT_UTF8: second-order context model tuned for UTF8-encoded text, 4294 CONTEXT_SIGNED: second-order context model tuned for signed integers. 4295 4296 The context id for the UTF8 context model is calculated as follows. If p1 4297 and p2 are the previous two bytes, we calcualte the context as 4298 4299 context = kContextLookup[p1] | kContextLookup[p2 + 256]. 4300 4301 If the previous two bytes are ASCII characters (i.e. < 128), this will be 4302 equivalent to 4303 4304 context = 4 * context1(p1) + context2(p2), 4305 4306 where context1 is based on the previous byte in the following way: 4307 4308 0 : non-ASCII control 4309 1 : \t, \n, \r 4310 2 : space 4311 3 : other punctuation 4312 4 : " ' 4313 5 : % 4314 6 : ( < [ { 4315 7 : ) > ] } 4316 8 : , ; : 4317 9 : . 4318 10 : = 4319 11 : number 4320 12 : upper-case vowel 4321 13 : upper-case consonant 4322 14 : lower-case vowel 4323 15 : lower-case consonant 4324 4325 and context2 is based on the second last byte: 4326 4327 0 : control, space 4328 1 : punctuation 4329 2 : upper-case letter, number 4330 3 : lower-case letter 4331 4332 If the last byte is ASCII, and the second last byte is not (in a valid UTF8 4333 stream it will be a continuation byte, value between 128 and 191), the 4334 context is the same as if the second last byte was an ASCII control or space. 4335 4336 If the last byte is a UTF8 lead byte (value >= 192), then the next byte will 4337 be a continuation byte and the context id is 2 or 3 depending on the LSB of 4338 the last byte and to a lesser extent on the second last byte if it is ASCII. 4339 4340 If the last byte is a UTF8 continuation byte, the second last byte can be: 4341 - continuation byte: the next byte is probably ASCII or lead byte (assuming 4342 4-byte UTF8 characters are rare) and the context id is 0 or 1. 4343 - lead byte (192 - 207): next byte is ASCII or lead byte, context is 0 or 1 4344 - lead byte (208 - 255): next byte is continuation byte, context is 2 or 3 4345 4346 The possible value combinations of the previous two bytes, the range of 4347 context ids and the type of the next byte is summarized in the table below: 4348 4349 |--------\-----------------------------------------------------------------| 4350 | \ Last byte | 4351 | Second \---------------------------------------------------------------| 4352 | last byte \ ASCII | cont. byte | lead byte | 4353 | \ (0-127) | (128-191) | (192-) | 4354 |=============|===================|=====================|==================| 4355 | ASCII | next: ASCII/lead | not valid | next: cont. | 4356 | (0-127) | context: 4 - 63 | | context: 2 - 3 | 4357 |-------------|-------------------|---------------------|------------------| 4358 | cont. byte | next: ASCII/lead | next: ASCII/lead | next: cont. | 4359 | (128-191) | context: 4 - 63 | context: 0 - 1 | context: 2 - 3 | 4360 |-------------|-------------------|---------------------|------------------| 4361 | lead byte | not valid | next: ASCII/lead | not valid | 4362 | (192-207) | | context: 0 - 1 | | 4363 |-------------|-------------------|---------------------|------------------| 4364 | lead byte | not valid | next: cont. | not valid | 4365 | (208-) | | context: 2 - 3 | | 4366 |-------------|-------------------|---------------------|------------------| 4367 4368 The context id for the signed context mode is calculated as: 4369 4370 context = (kContextLookup[512 + p1] << 3) | kContextLookup[512 + p2]. 4371 4372 For any context modeling modes, the context ids can be calculated by |-ing 4373 together two lookups from one table using context model dependent offsets: 4374 4375 context = kContextLookup[offset1 + p1] | kContextLookup[offset2 + p2]. 4376 4377 where offset1 and offset2 are dependent on the context mode. 4378 */ 4379 4380 var CONTEXT_LSB6 = 0; 4381 var CONTEXT_MSB6 = 1; 4382 var CONTEXT_UTF8 = 2; 4383 var CONTEXT_SIGNED = 3; 4384 4385 /* Common context lookup table for all context modes. */ 4386 exports.lookup = new Uint8Array( [ 4387 /* CONTEXT_UTF8, last byte. */ 4388 /* ASCII range. */ 4389 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 0, 0, 4, 0, 0, 0, 0, 0, 4390 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 12, 16, 12, 4391 12, 20, 12, 16, 24, 28, 12, 12, 32, 12, 36, 12, 44, 44, 4392 44, 44, 44, 44, 44, 44, 44, 44, 32, 32, 24, 40, 28, 12, 4393 12, 48, 52, 52, 52, 48, 52, 52, 52, 48, 52, 52, 52, 52, 4394 52, 48, 52, 52, 52, 52, 52, 48, 52, 52, 52, 52, 52, 24, 4395 12, 28, 12, 12, 12, 56, 60, 60, 60, 56, 60, 60, 60, 56, 4396 60, 60, 60, 60, 60, 56, 60, 60, 60, 60, 60, 56, 60, 60, 4397 60, 60, 60, 24, 12, 28, 12, 0, 4398 /* UTF8 continuation byte range. */ 4399 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 4400 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 4401 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 4402 1, 0, 1, 0, 1, 0, 1, /* UTF8 lead byte range. */ 4403 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 4404 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 4405 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 4406 3, 2, 3, 2, 3, 2, 3, 4407 /* CONTEXT_UTF8 second last byte. */ 4408 /* ASCII range. */ 4409 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4410 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 4411 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4412 2, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4413 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 4414 1, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4415 3, 3, 3, 3, 3, 3, 3, 3, 3, 1, 1, 1, 1, 0, 4416 /* UTF8 continuation byte range. */ 4417 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4418 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4419 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4420 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4421 0, 0, 0, 0, /* UTF8 lead byte range. */ 4422 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 4423 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4424 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4425 /* CONTEXT_SIGNED, second last byte. */ 4426 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 4427 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4428 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4429 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4430 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4431 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4432 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4433 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4434 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4435 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4436 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 4437 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 4438 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 4439 6, 6, 6, 6, 6, 6, 6, 6, 7, 4440 /* CONTEXT_SIGNED, last byte, same as the above values shifted by 3 bits. */ 4441 0, 4442 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 16, 16, 16, 4443 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 4444 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 4445 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 4446 16, 16, 16, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 4447 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 4448 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 4449 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 4450 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 32, 32, 32, 4451 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 4452 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 4453 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 4454 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 4455 32, 32, 32, 32, 32, 40, 40, 40, 40, 40, 40, 40, 40, 40, 4456 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 4457 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 4458 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 48, 48, 48, 4459 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 56, 4460 /* CONTEXT_LSB6, last byte. */ 4461 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 4462 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 4463 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 4464 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 4465 58, 59, 60, 61, 62, 63, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 4466 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 4467 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 4468 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 4469 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 0, 1, 2, 4470 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 4471 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 4472 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 4473 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 4474 61, 62, 63, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 4475 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 4476 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 4477 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 4478 55, 56, 57, 58, 59, 60, 61, 62, 63, 4479 /* CONTEXT_MSB6, last byte. */ 4480 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4481 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 4482 9, 9, 10, 10, 10, 10, 11, 11, 11, 11, 12, 12, 12, 12, 4483 13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, 16, 16, 4484 16, 16, 17, 17, 17, 17, 18, 18, 18, 18, 19, 19, 19, 19, 4485 20, 20, 20, 20, 21, 21, 21, 21, 22, 22, 22, 22, 23, 23, 4486 23, 23, 24, 24, 24, 24, 25, 25, 25, 25, 26, 26, 26, 26, 4487 27, 27, 27, 27, 28, 28, 28, 28, 29, 29, 29, 29, 30, 30, 4488 30, 30, 31, 31, 31, 31, 32, 32, 32, 32, 33, 33, 33, 33, 4489 34, 34, 34, 34, 35, 35, 35, 35, 36, 36, 36, 36, 37, 37, 4490 37, 37, 38, 38, 38, 38, 39, 39, 39, 39, 40, 40, 40, 40, 4491 41, 41, 41, 41, 42, 42, 42, 42, 43, 43, 43, 43, 44, 44, 4492 44, 44, 45, 45, 45, 45, 46, 46, 46, 46, 47, 47, 47, 47, 4493 48, 48, 48, 48, 49, 49, 49, 49, 50, 50, 50, 50, 51, 51, 4494 51, 51, 52, 52, 52, 52, 53, 53, 53, 53, 54, 54, 54, 54, 4495 55, 55, 55, 55, 56, 56, 56, 56, 57, 57, 57, 57, 58, 58, 4496 58, 58, 59, 59, 59, 59, 60, 60, 60, 60, 61, 61, 61, 61, 4497 62, 62, 62, 62, 63, 63, 63, 63, 4498 /* CONTEXT_{M,L}SB6, second last byte, */ 4499 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4500 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4501 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4502 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4503 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4504 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4505 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4506 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4507 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4508 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4509 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4510 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4511 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4512 0, 0, 0, 0, 0, 0, 0, 0, 0, 4513 ] ); 4514 4515 exports.lookupOffsets = new Uint16Array( [ 4516 /* CONTEXT_LSB6 */ 4517 1024, 1536, /* CONTEXT_MSB6 */ 4518 1280, 1536, /* CONTEXT_UTF8 */ 4519 0, 256, /* CONTEXT_SIGNED */ 4520 768, 512, 4521 ] ); 4522 }, 4523 {}, 4524 ], 4525 3: [ 4526 function ( require, module, exports ) { 4527 /* Copyright 2013 Google Inc. All Rights Reserved. 4528 4529 Licensed under the Apache License, Version 2.0 (the "License"); 4530 you may not use this file except in compliance with the License. 4531 You may obtain a copy of the License at 4532 4533 http://www.apache.org/licenses/LICENSE-2.0 4534 4535 Unless required by applicable law or agreed to in writing, software 4536 distributed under the License is distributed on an "AS IS" BASIS, 4537 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 4538 See the License for the specific language governing permissions and 4539 limitations under the License. 4540 */ 4541 4542 var BrotliInput = require( './streams' ).BrotliInput; 4543 var BrotliOutput = require( './streams' ).BrotliOutput; 4544 var BrotliBitReader = require( './bit_reader' ); 4545 var BrotliDictionary = require( './dictionary' ); 4546 var HuffmanCode = require( './huffman' ).HuffmanCode; 4547 var BrotliBuildHuffmanTable = 4548 require( './huffman' ).BrotliBuildHuffmanTable; 4549 var Context = require( './context' ); 4550 var Prefix = require( './prefix' ); 4551 var Transform = require( './transform' ); 4552 4553 var kDefaultCodeLength = 8; 4554 var kCodeLengthRepeatCode = 16; 4555 var kNumLiteralCodes = 256; 4556 var kNumInsertAndCopyCodes = 704; 4557 var kNumBlockLengthCodes = 26; 4558 var kLiteralContextBits = 6; 4559 var kDistanceContextBits = 2; 4560 4561 var HUFFMAN_TABLE_BITS = 8; 4562 var HUFFMAN_TABLE_MASK = 0xff; 4563 /* Maximum possible Huffman table size for an alphabet size of 704, max code 4564 * length 15 and root table bits 8. */ 4565 var HUFFMAN_MAX_TABLE_SIZE = 1080; 4566 4567 var CODE_LENGTH_CODES = 18; 4568 var kCodeLengthCodeOrder = new Uint8Array( [ 4569 1, 2, 3, 4, 0, 5, 17, 6, 16, 7, 8, 9, 10, 11, 12, 13, 4570 14, 15, 4571 ] ); 4572 4573 var NUM_DISTANCE_SHORT_CODES = 16; 4574 var kDistanceShortCodeIndexOffset = new Uint8Array( [ 4575 3, 2, 1, 0, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 4576 ] ); 4577 4578 var kDistanceShortCodeValueOffset = new Int8Array( [ 4579 0, 0, 0, 0, -1, 1, -2, 2, -3, 3, -1, 1, -2, 2, -3, 3, 4580 ] ); 4581 4582 var kMaxHuffmanTableSize = new Uint16Array( [ 4583 256, 402, 436, 468, 500, 534, 566, 598, 630, 662, 694, 4584 726, 758, 790, 822, 854, 886, 920, 952, 984, 1016, 1048, 4585 1080, 4586 ] ); 4587 4588 function DecodeWindowBits( br ) { 4589 var n; 4590 if ( br.readBits( 1 ) === 0 ) { 4591 return 16; 4592 } 4593 4594 n = br.readBits( 3 ); 4595 if ( n > 0 ) { 4596 return 17 + n; 4597 } 4598 4599 n = br.readBits( 3 ); 4600 if ( n > 0 ) { 4601 return 8 + n; 4602 } 4603 4604 return 17; 4605 } 4606 4607 /* Decodes a number in the range [0..255], by reading 1 - 11 bits. */ 4608 function DecodeVarLenUint8( br ) { 4609 if ( br.readBits( 1 ) ) { 4610 var nbits = br.readBits( 3 ); 4611 if ( nbits === 0 ) { 4612 return 1; 4613 } else { 4614 return br.readBits( nbits ) + ( 1 << nbits ); 4615 } 4616 } 4617 return 0; 4618 } 4619 4620 function MetaBlockLength() { 4621 this.meta_block_length = 0; 4622 this.input_end = 0; 4623 this.is_uncompressed = 0; 4624 this.is_metadata = false; 4625 } 4626 4627 function DecodeMetaBlockLength( br ) { 4628 var out = new MetaBlockLength(); 4629 var size_nibbles; 4630 var size_bytes; 4631 var i; 4632 4633 out.input_end = br.readBits( 1 ); 4634 if ( out.input_end && br.readBits( 1 ) ) { 4635 return out; 4636 } 4637 4638 size_nibbles = br.readBits( 2 ) + 4; 4639 if ( size_nibbles === 7 ) { 4640 out.is_metadata = true; 4641 4642 if ( br.readBits( 1 ) !== 0 ) 4643 throw new Error( 'Invalid reserved bit' ); 4644 4645 size_bytes = br.readBits( 2 ); 4646 if ( size_bytes === 0 ) return out; 4647 4648 for ( i = 0; i < size_bytes; i++ ) { 4649 var next_byte = br.readBits( 8 ); 4650 if ( 4651 i + 1 === size_bytes && 4652 size_bytes > 1 && 4653 next_byte === 0 4654 ) 4655 throw new Error( 'Invalid size byte' ); 4656 4657 out.meta_block_length |= next_byte << ( i * 8 ); 4658 } 4659 } else { 4660 for ( i = 0; i < size_nibbles; ++i ) { 4661 var next_nibble = br.readBits( 4 ); 4662 if ( 4663 i + 1 === size_nibbles && 4664 size_nibbles > 4 && 4665 next_nibble === 0 4666 ) 4667 throw new Error( 'Invalid size nibble' ); 4668 4669 out.meta_block_length |= 4670 next_nibble << ( i * 4 ); 4671 } 4672 } 4673 4674 ++out.meta_block_length; 4675 4676 if ( ! out.input_end && ! out.is_metadata ) { 4677 out.is_uncompressed = br.readBits( 1 ); 4678 } 4679 4680 return out; 4681 } 4682 4683 /* Decodes the next Huffman code from bit-stream. */ 4684 function ReadSymbol( table, index, br ) { 4685 var start_index = index; 4686 4687 var nbits; 4688 br.fillBitWindow(); 4689 index += 4690 ( br.val_ >>> br.bit_pos_ ) & HUFFMAN_TABLE_MASK; 4691 nbits = table[ index ].bits - HUFFMAN_TABLE_BITS; 4692 if ( nbits > 0 ) { 4693 br.bit_pos_ += HUFFMAN_TABLE_BITS; 4694 index += table[ index ].value; 4695 index += 4696 ( br.val_ >>> br.bit_pos_ ) & 4697 ( ( 1 << nbits ) - 1 ); 4698 } 4699 br.bit_pos_ += table[ index ].bits; 4700 return table[ index ].value; 4701 } 4702 4703 function ReadHuffmanCodeLengths( 4704 code_length_code_lengths, 4705 num_symbols, 4706 code_lengths, 4707 br 4708 ) { 4709 var symbol = 0; 4710 var prev_code_len = kDefaultCodeLength; 4711 var repeat = 0; 4712 var repeat_code_len = 0; 4713 var space = 32768; 4714 4715 var table = []; 4716 for ( var i = 0; i < 32; i++ ) 4717 table.push( new HuffmanCode( 0, 0 ) ); 4718 4719 BrotliBuildHuffmanTable( 4720 table, 4721 0, 4722 5, 4723 code_length_code_lengths, 4724 CODE_LENGTH_CODES 4725 ); 4726 4727 while ( symbol < num_symbols && space > 0 ) { 4728 var p = 0; 4729 var code_len; 4730 4731 br.readMoreInput(); 4732 br.fillBitWindow(); 4733 p += ( br.val_ >>> br.bit_pos_ ) & 31; 4734 br.bit_pos_ += table[ p ].bits; 4735 code_len = table[ p ].value & 0xff; 4736 if ( code_len < kCodeLengthRepeatCode ) { 4737 repeat = 0; 4738 code_lengths[ symbol++ ] = code_len; 4739 if ( code_len !== 0 ) { 4740 prev_code_len = code_len; 4741 space -= 32768 >> code_len; 4742 } 4743 } else { 4744 var extra_bits = code_len - 14; 4745 var old_repeat; 4746 var repeat_delta; 4747 var new_len = 0; 4748 if ( code_len === kCodeLengthRepeatCode ) { 4749 new_len = prev_code_len; 4750 } 4751 if ( repeat_code_len !== new_len ) { 4752 repeat = 0; 4753 repeat_code_len = new_len; 4754 } 4755 old_repeat = repeat; 4756 if ( repeat > 0 ) { 4757 repeat -= 2; 4758 repeat <<= extra_bits; 4759 } 4760 repeat += br.readBits( extra_bits ) + 3; 4761 repeat_delta = repeat - old_repeat; 4762 if ( symbol + repeat_delta > num_symbols ) { 4763 throw new Error( 4764 '[ReadHuffmanCodeLengths] symbol + repeat_delta > num_symbols' 4765 ); 4766 } 4767 4768 for ( var x = 0; x < repeat_delta; x++ ) 4769 code_lengths[ symbol + x ] = 4770 repeat_code_len; 4771 4772 symbol += repeat_delta; 4773 4774 if ( repeat_code_len !== 0 ) { 4775 space -= 4776 repeat_delta << 4777 ( 15 - repeat_code_len ); 4778 } 4779 } 4780 } 4781 if ( space !== 0 ) { 4782 throw new Error( 4783 '[ReadHuffmanCodeLengths] space = ' + space 4784 ); 4785 } 4786 4787 for ( ; symbol < num_symbols; symbol++ ) 4788 code_lengths[ symbol ] = 0; 4789 } 4790 4791 function ReadHuffmanCode( 4792 alphabet_size, 4793 tables, 4794 table, 4795 br 4796 ) { 4797 var table_size = 0; 4798 var simple_code_or_skip; 4799 var code_lengths = new Uint8Array( alphabet_size ); 4800 4801 br.readMoreInput(); 4802 4803 /* simple_code_or_skip is used as follows: 4804 1 for simple code; 4805 0 for no skipping, 2 skips 2 code lengths, 3 skips 3 code lengths */ 4806 simple_code_or_skip = br.readBits( 2 ); 4807 if ( simple_code_or_skip === 1 ) { 4808 /* Read symbols, codes & code lengths directly. */ 4809 var i; 4810 var max_bits_counter = alphabet_size - 1; 4811 var max_bits = 0; 4812 var symbols = new Int32Array( 4 ); 4813 var num_symbols = br.readBits( 2 ) + 1; 4814 while ( max_bits_counter ) { 4815 max_bits_counter >>= 1; 4816 ++max_bits; 4817 } 4818 4819 for ( i = 0; i < num_symbols; ++i ) { 4820 symbols[ i ] = 4821 br.readBits( max_bits ) % alphabet_size; 4822 code_lengths[ symbols[ i ] ] = 2; 4823 } 4824 code_lengths[ symbols[ 0 ] ] = 1; 4825 switch ( num_symbols ) { 4826 case 1: 4827 break; 4828 case 3: 4829 if ( 4830 symbols[ 0 ] === symbols[ 1 ] || 4831 symbols[ 0 ] === symbols[ 2 ] || 4832 symbols[ 1 ] === symbols[ 2 ] 4833 ) { 4834 throw new Error( 4835 '[ReadHuffmanCode] invalid symbols' 4836 ); 4837 } 4838 break; 4839 case 2: 4840 if ( symbols[ 0 ] === symbols[ 1 ] ) { 4841 throw new Error( 4842 '[ReadHuffmanCode] invalid symbols' 4843 ); 4844 } 4845 4846 code_lengths[ symbols[ 1 ] ] = 1; 4847 break; 4848 case 4: 4849 if ( 4850 symbols[ 0 ] === symbols[ 1 ] || 4851 symbols[ 0 ] === symbols[ 2 ] || 4852 symbols[ 0 ] === symbols[ 3 ] || 4853 symbols[ 1 ] === symbols[ 2 ] || 4854 symbols[ 1 ] === symbols[ 3 ] || 4855 symbols[ 2 ] === symbols[ 3 ] 4856 ) { 4857 throw new Error( 4858 '[ReadHuffmanCode] invalid symbols' 4859 ); 4860 } 4861 4862 if ( br.readBits( 1 ) ) { 4863 code_lengths[ symbols[ 2 ] ] = 3; 4864 code_lengths[ symbols[ 3 ] ] = 3; 4865 } else { 4866 code_lengths[ symbols[ 0 ] ] = 2; 4867 } 4868 break; 4869 } 4870 } else { 4871 /* Decode Huffman-coded code lengths. */ 4872 var i; 4873 var code_length_code_lengths = new Uint8Array( 4874 CODE_LENGTH_CODES 4875 ); 4876 var space = 32; 4877 var num_codes = 0; 4878 /* Static Huffman code for the code length code lengths */ 4879 var huff = [ 4880 new HuffmanCode( 2, 0 ), 4881 new HuffmanCode( 2, 4 ), 4882 new HuffmanCode( 2, 3 ), 4883 new HuffmanCode( 3, 2 ), 4884 new HuffmanCode( 2, 0 ), 4885 new HuffmanCode( 2, 4 ), 4886 new HuffmanCode( 2, 3 ), 4887 new HuffmanCode( 4, 1 ), 4888 new HuffmanCode( 2, 0 ), 4889 new HuffmanCode( 2, 4 ), 4890 new HuffmanCode( 2, 3 ), 4891 new HuffmanCode( 3, 2 ), 4892 new HuffmanCode( 2, 0 ), 4893 new HuffmanCode( 2, 4 ), 4894 new HuffmanCode( 2, 3 ), 4895 new HuffmanCode( 4, 5 ), 4896 ]; 4897 for ( 4898 i = simple_code_or_skip; 4899 i < CODE_LENGTH_CODES && space > 0; 4900 ++i 4901 ) { 4902 var code_len_idx = kCodeLengthCodeOrder[ i ]; 4903 var p = 0; 4904 var v; 4905 br.fillBitWindow(); 4906 p += ( br.val_ >>> br.bit_pos_ ) & 15; 4907 br.bit_pos_ += huff[ p ].bits; 4908 v = huff[ p ].value; 4909 code_length_code_lengths[ code_len_idx ] = v; 4910 if ( v !== 0 ) { 4911 space -= 32 >> v; 4912 ++num_codes; 4913 } 4914 } 4915 4916 if ( ! ( num_codes === 1 || space === 0 ) ) 4917 throw new Error( 4918 '[ReadHuffmanCode] invalid num_codes or space' 4919 ); 4920 4921 ReadHuffmanCodeLengths( 4922 code_length_code_lengths, 4923 alphabet_size, 4924 code_lengths, 4925 br 4926 ); 4927 } 4928 4929 table_size = BrotliBuildHuffmanTable( 4930 tables, 4931 table, 4932 HUFFMAN_TABLE_BITS, 4933 code_lengths, 4934 alphabet_size 4935 ); 4936 4937 if ( table_size === 0 ) { 4938 throw new Error( 4939 '[ReadHuffmanCode] BuildHuffmanTable failed: ' 4940 ); 4941 } 4942 4943 return table_size; 4944 } 4945 4946 function ReadBlockLength( table, index, br ) { 4947 var code; 4948 var nbits; 4949 code = ReadSymbol( table, index, br ); 4950 nbits = Prefix.kBlockLengthPrefixCode[ code ].nbits; 4951 return ( 4952 Prefix.kBlockLengthPrefixCode[ code ].offset + 4953 br.readBits( nbits ) 4954 ); 4955 } 4956 4957 function TranslateShortCodes( code, ringbuffer, index ) { 4958 var val; 4959 if ( code < NUM_DISTANCE_SHORT_CODES ) { 4960 index += kDistanceShortCodeIndexOffset[ code ]; 4961 index &= 3; 4962 val = 4963 ringbuffer[ index ] + 4964 kDistanceShortCodeValueOffset[ code ]; 4965 } else { 4966 val = code - NUM_DISTANCE_SHORT_CODES + 1; 4967 } 4968 return val; 4969 } 4970 4971 function MoveToFront( v, index ) { 4972 var value = v[ index ]; 4973 var i = index; 4974 for ( ; i; --i ) v[ i ] = v[ i - 1 ]; 4975 v[ 0 ] = value; 4976 } 4977 4978 function InverseMoveToFrontTransform( v, v_len ) { 4979 var mtf = new Uint8Array( 256 ); 4980 var i; 4981 for ( i = 0; i < 256; ++i ) { 4982 mtf[ i ] = i; 4983 } 4984 for ( i = 0; i < v_len; ++i ) { 4985 var index = v[ i ]; 4986 v[ i ] = mtf[ index ]; 4987 if ( index ) MoveToFront( mtf, index ); 4988 } 4989 } 4990 4991 /* Contains a collection of huffman trees with the same alphabet size. */ 4992 function HuffmanTreeGroup( alphabet_size, num_htrees ) { 4993 this.alphabet_size = alphabet_size; 4994 this.num_htrees = num_htrees; 4995 this.codes = new Array( 4996 num_htrees + 4997 num_htrees * 4998 kMaxHuffmanTableSize[ 4999 ( alphabet_size + 31 ) >>> 5 5000 ] 5001 ); 5002 this.htrees = new Uint32Array( num_htrees ); 5003 } 5004 5005 HuffmanTreeGroup.prototype.decode = function ( br ) { 5006 var i; 5007 var table_size; 5008 var next = 0; 5009 for ( i = 0; i < this.num_htrees; ++i ) { 5010 this.htrees[ i ] = next; 5011 table_size = ReadHuffmanCode( 5012 this.alphabet_size, 5013 this.codes, 5014 next, 5015 br 5016 ); 5017 next += table_size; 5018 } 5019 }; 5020 5021 function DecodeContextMap( context_map_size, br ) { 5022 var out = { num_htrees: null, context_map: null }; 5023 var use_rle_for_zeros; 5024 var max_run_length_prefix = 0; 5025 var table; 5026 var i; 5027 5028 br.readMoreInput(); 5029 var num_htrees = ( out.num_htrees = 5030 DecodeVarLenUint8( br ) + 1 ); 5031 5032 var context_map = ( out.context_map = new Uint8Array( 5033 context_map_size 5034 ) ); 5035 if ( num_htrees <= 1 ) { 5036 return out; 5037 } 5038 5039 use_rle_for_zeros = br.readBits( 1 ); 5040 if ( use_rle_for_zeros ) { 5041 max_run_length_prefix = br.readBits( 4 ) + 1; 5042 } 5043 5044 table = []; 5045 for ( i = 0; i < HUFFMAN_MAX_TABLE_SIZE; i++ ) { 5046 table[ i ] = new HuffmanCode( 0, 0 ); 5047 } 5048 5049 ReadHuffmanCode( 5050 num_htrees + max_run_length_prefix, 5051 table, 5052 0, 5053 br 5054 ); 5055 5056 for ( i = 0; i < context_map_size; ) { 5057 var code; 5058 5059 br.readMoreInput(); 5060 code = ReadSymbol( table, 0, br ); 5061 if ( code === 0 ) { 5062 context_map[ i ] = 0; 5063 ++i; 5064 } else if ( code <= max_run_length_prefix ) { 5065 var reps = 5066 1 + ( 1 << code ) + br.readBits( code ); 5067 while ( --reps ) { 5068 if ( i >= context_map_size ) { 5069 throw new Error( 5070 '[DecodeContextMap] i >= context_map_size' 5071 ); 5072 } 5073 context_map[ i ] = 0; 5074 ++i; 5075 } 5076 } else { 5077 context_map[ i ] = code - max_run_length_prefix; 5078 ++i; 5079 } 5080 } 5081 if ( br.readBits( 1 ) ) { 5082 InverseMoveToFrontTransform( 5083 context_map, 5084 context_map_size 5085 ); 5086 } 5087 5088 return out; 5089 } 5090 5091 function DecodeBlockType( 5092 max_block_type, 5093 trees, 5094 tree_type, 5095 block_types, 5096 ringbuffers, 5097 indexes, 5098 br 5099 ) { 5100 var ringbuffer = tree_type * 2; 5101 var index = tree_type; 5102 var type_code = ReadSymbol( 5103 trees, 5104 tree_type * HUFFMAN_MAX_TABLE_SIZE, 5105 br 5106 ); 5107 var block_type; 5108 if ( type_code === 0 ) { 5109 block_type = 5110 ringbuffers[ 5111 ringbuffer + ( indexes[ index ] & 1 ) 5112 ]; 5113 } else if ( type_code === 1 ) { 5114 block_type = 5115 ringbuffers[ 5116 ringbuffer + 5117 ( ( indexes[ index ] - 1 ) & 1 ) 5118 ] + 1; 5119 } else { 5120 block_type = type_code - 2; 5121 } 5122 if ( block_type >= max_block_type ) { 5123 block_type -= max_block_type; 5124 } 5125 block_types[ tree_type ] = block_type; 5126 ringbuffers[ ringbuffer + ( indexes[ index ] & 1 ) ] = 5127 block_type; 5128 ++indexes[ index ]; 5129 } 5130 5131 function CopyUncompressedBlockToOutput( 5132 output, 5133 len, 5134 pos, 5135 ringbuffer, 5136 ringbuffer_mask, 5137 br 5138 ) { 5139 var rb_size = ringbuffer_mask + 1; 5140 var rb_pos = pos & ringbuffer_mask; 5141 var br_pos = br.pos_ & BrotliBitReader.IBUF_MASK; 5142 var nbytes; 5143 5144 /* For short lengths copy byte-by-byte */ 5145 if ( 5146 len < 8 || 5147 br.bit_pos_ + ( len << 3 ) < br.bit_end_pos_ 5148 ) { 5149 while ( len-- > 0 ) { 5150 br.readMoreInput(); 5151 ringbuffer[ rb_pos++ ] = br.readBits( 8 ); 5152 if ( rb_pos === rb_size ) { 5153 output.write( ringbuffer, rb_size ); 5154 rb_pos = 0; 5155 } 5156 } 5157 return; 5158 } 5159 5160 if ( br.bit_end_pos_ < 32 ) { 5161 throw new Error( 5162 '[CopyUncompressedBlockToOutput] br.bit_end_pos_ < 32' 5163 ); 5164 } 5165 5166 /* Copy remaining 0-4 bytes from br.val_ to ringbuffer. */ 5167 while ( br.bit_pos_ < 32 ) { 5168 ringbuffer[ rb_pos ] = br.val_ >>> br.bit_pos_; 5169 br.bit_pos_ += 8; 5170 ++rb_pos; 5171 --len; 5172 } 5173 5174 /* Copy remaining bytes from br.buf_ to ringbuffer. */ 5175 nbytes = ( br.bit_end_pos_ - br.bit_pos_ ) >> 3; 5176 if ( br_pos + nbytes > BrotliBitReader.IBUF_MASK ) { 5177 var tail = BrotliBitReader.IBUF_MASK + 1 - br_pos; 5178 for ( var x = 0; x < tail; x++ ) 5179 ringbuffer[ rb_pos + x ] = 5180 br.buf_[ br_pos + x ]; 5181 5182 nbytes -= tail; 5183 rb_pos += tail; 5184 len -= tail; 5185 br_pos = 0; 5186 } 5187 5188 for ( var x = 0; x < nbytes; x++ ) 5189 ringbuffer[ rb_pos + x ] = br.buf_[ br_pos + x ]; 5190 5191 rb_pos += nbytes; 5192 len -= nbytes; 5193 5194 /* If we wrote past the logical end of the ringbuffer, copy the tail of the 5195 ringbuffer to its beginning and flush the ringbuffer to the output. */ 5196 if ( rb_pos >= rb_size ) { 5197 output.write( ringbuffer, rb_size ); 5198 rb_pos -= rb_size; 5199 for ( var x = 0; x < rb_pos; x++ ) 5200 ringbuffer[ x ] = ringbuffer[ rb_size + x ]; 5201 } 5202 5203 /* If we have more to copy than the remaining size of the ringbuffer, then we 5204 first fill the ringbuffer from the input and then flush the ringbuffer to 5205 the output */ 5206 while ( rb_pos + len >= rb_size ) { 5207 nbytes = rb_size - rb_pos; 5208 if ( 5209 br.input_.read( ringbuffer, rb_pos, nbytes ) < 5210 nbytes 5211 ) { 5212 throw new Error( 5213 '[CopyUncompressedBlockToOutput] not enough bytes' 5214 ); 5215 } 5216 output.write( ringbuffer, rb_size ); 5217 len -= nbytes; 5218 rb_pos = 0; 5219 } 5220 5221 /* Copy straight from the input onto the ringbuffer. The ringbuffer will be 5222 flushed to the output at a later time. */ 5223 if ( br.input_.read( ringbuffer, rb_pos, len ) < len ) { 5224 throw new Error( 5225 '[CopyUncompressedBlockToOutput] not enough bytes' 5226 ); 5227 } 5228 5229 /* Restore the state of the bit reader. */ 5230 br.reset(); 5231 } 5232 5233 /* Advances the bit reader position to the next byte boundary and verifies 5234 that any skipped bits are set to zero. */ 5235 function JumpToByteBoundary( br ) { 5236 var new_bit_pos = ( br.bit_pos_ + 7 ) & ~7; 5237 var pad_bits = br.readBits( new_bit_pos - br.bit_pos_ ); 5238 return pad_bits == 0; 5239 } 5240 5241 function BrotliDecompressedSize( buffer ) { 5242 var input = new BrotliInput( buffer ); 5243 var br = new BrotliBitReader( input ); 5244 DecodeWindowBits( br ); 5245 var out = DecodeMetaBlockLength( br ); 5246 return out.meta_block_length; 5247 } 5248 5249 exports.BrotliDecompressedSize = BrotliDecompressedSize; 5250 5251 function BrotliDecompressBuffer( buffer, output_size ) { 5252 var input = new BrotliInput( buffer ); 5253 5254 if ( output_size == null ) { 5255 output_size = BrotliDecompressedSize( buffer ); 5256 } 5257 5258 var output_buffer = new Uint8Array( output_size ); 5259 var output = new BrotliOutput( output_buffer ); 5260 5261 BrotliDecompress( input, output ); 5262 5263 if ( output.pos < output.buffer.length ) { 5264 output.buffer = output.buffer.subarray( 5265 0, 5266 output.pos 5267 ); 5268 } 5269 5270 return output.buffer; 5271 } 5272 5273 exports.BrotliDecompressBuffer = BrotliDecompressBuffer; 5274 5275 function BrotliDecompress( input, output ) { 5276 var i; 5277 var pos = 0; 5278 var input_end = 0; 5279 var window_bits = 0; 5280 var max_backward_distance; 5281 var max_distance = 0; 5282 var ringbuffer_size; 5283 var ringbuffer_mask; 5284 var ringbuffer; 5285 var ringbuffer_end; 5286 /* This ring buffer holds a few past copy distances that will be used by */ 5287 /* some special distance codes. */ 5288 var dist_rb = [ 16, 15, 11, 4 ]; 5289 var dist_rb_idx = 0; 5290 /* The previous 2 bytes used for context. */ 5291 var prev_byte1 = 0; 5292 var prev_byte2 = 0; 5293 var hgroup = [ 5294 new HuffmanTreeGroup( 0, 0 ), 5295 new HuffmanTreeGroup( 0, 0 ), 5296 new HuffmanTreeGroup( 0, 0 ), 5297 ]; 5298 var block_type_trees; 5299 var block_len_trees; 5300 var br; 5301 5302 /* We need the slack region for the following reasons: 5303 - always doing two 8-byte copies for fast backward copying 5304 - transforms 5305 - flushing the input ringbuffer when decoding uncompressed blocks */ 5306 var kRingBufferWriteAheadSlack = 5307 128 + BrotliBitReader.READ_SIZE; 5308 5309 br = new BrotliBitReader( input ); 5310 5311 /* Decode window size. */ 5312 window_bits = DecodeWindowBits( br ); 5313 max_backward_distance = ( 1 << window_bits ) - 16; 5314 5315 ringbuffer_size = 1 << window_bits; 5316 ringbuffer_mask = ringbuffer_size - 1; 5317 ringbuffer = new Uint8Array( 5318 ringbuffer_size + 5319 kRingBufferWriteAheadSlack + 5320 BrotliDictionary.maxDictionaryWordLength 5321 ); 5322 ringbuffer_end = ringbuffer_size; 5323 5324 block_type_trees = []; 5325 block_len_trees = []; 5326 for ( var x = 0; x < 3 * HUFFMAN_MAX_TABLE_SIZE; x++ ) { 5327 block_type_trees[ x ] = new HuffmanCode( 0, 0 ); 5328 block_len_trees[ x ] = new HuffmanCode( 0, 0 ); 5329 } 5330 5331 while ( ! input_end ) { 5332 var meta_block_remaining_len = 0; 5333 var is_uncompressed; 5334 var block_length = [ 1 << 28, 1 << 28, 1 << 28 ]; 5335 var block_type = [ 0 ]; 5336 var num_block_types = [ 1, 1, 1 ]; 5337 var block_type_rb = [ 0, 1, 0, 1, 0, 1 ]; 5338 var block_type_rb_index = [ 0 ]; 5339 var distance_postfix_bits; 5340 var num_direct_distance_codes; 5341 var distance_postfix_mask; 5342 var num_distance_codes; 5343 var context_map = null; 5344 var context_modes = null; 5345 var num_literal_htrees; 5346 var dist_context_map = null; 5347 var num_dist_htrees; 5348 var context_offset = 0; 5349 var context_map_slice = null; 5350 var literal_htree_index = 0; 5351 var dist_context_offset = 0; 5352 var dist_context_map_slice = null; 5353 var dist_htree_index = 0; 5354 var context_lookup_offset1 = 0; 5355 var context_lookup_offset2 = 0; 5356 var context_mode; 5357 var htree_command; 5358 5359 for ( i = 0; i < 3; ++i ) { 5360 hgroup[ i ].codes = null; 5361 hgroup[ i ].htrees = null; 5362 } 5363 5364 br.readMoreInput(); 5365 5366 var _out = DecodeMetaBlockLength( br ); 5367 meta_block_remaining_len = _out.meta_block_length; 5368 if ( 5369 pos + meta_block_remaining_len > 5370 output.buffer.length 5371 ) { 5372 /* We need to grow the output buffer to fit the additional data. */ 5373 var tmp = new Uint8Array( 5374 pos + meta_block_remaining_len 5375 ); 5376 tmp.set( output.buffer ); 5377 output.buffer = tmp; 5378 } 5379 input_end = _out.input_end; 5380 is_uncompressed = _out.is_uncompressed; 5381 5382 if ( _out.is_metadata ) { 5383 JumpToByteBoundary( br ); 5384 5385 for ( 5386 ; 5387 meta_block_remaining_len > 0; 5388 --meta_block_remaining_len 5389 ) { 5390 br.readMoreInput(); 5391 /* Read one byte and ignore it. */ 5392 br.readBits( 8 ); 5393 } 5394 5395 continue; 5396 } 5397 5398 if ( meta_block_remaining_len === 0 ) { 5399 continue; 5400 } 5401 5402 if ( is_uncompressed ) { 5403 br.bit_pos_ = ( br.bit_pos_ + 7 ) & ~7; 5404 CopyUncompressedBlockToOutput( 5405 output, 5406 meta_block_remaining_len, 5407 pos, 5408 ringbuffer, 5409 ringbuffer_mask, 5410 br 5411 ); 5412 pos += meta_block_remaining_len; 5413 continue; 5414 } 5415 5416 for ( i = 0; i < 3; ++i ) { 5417 num_block_types[ i ] = 5418 DecodeVarLenUint8( br ) + 1; 5419 if ( num_block_types[ i ] >= 2 ) { 5420 ReadHuffmanCode( 5421 num_block_types[ i ] + 2, 5422 block_type_trees, 5423 i * HUFFMAN_MAX_TABLE_SIZE, 5424 br 5425 ); 5426 ReadHuffmanCode( 5427 kNumBlockLengthCodes, 5428 block_len_trees, 5429 i * HUFFMAN_MAX_TABLE_SIZE, 5430 br 5431 ); 5432 block_length[ i ] = ReadBlockLength( 5433 block_len_trees, 5434 i * HUFFMAN_MAX_TABLE_SIZE, 5435 br 5436 ); 5437 block_type_rb_index[ i ] = 1; 5438 } 5439 } 5440 5441 br.readMoreInput(); 5442 5443 distance_postfix_bits = br.readBits( 2 ); 5444 num_direct_distance_codes = 5445 NUM_DISTANCE_SHORT_CODES + 5446 ( br.readBits( 4 ) << distance_postfix_bits ); 5447 distance_postfix_mask = 5448 ( 1 << distance_postfix_bits ) - 1; 5449 num_distance_codes = 5450 num_direct_distance_codes + 5451 ( 48 << distance_postfix_bits ); 5452 context_modes = new Uint8Array( 5453 num_block_types[ 0 ] 5454 ); 5455 5456 for ( i = 0; i < num_block_types[ 0 ]; ++i ) { 5457 br.readMoreInput(); 5458 context_modes[ i ] = br.readBits( 2 ) << 1; 5459 } 5460 5461 var _o1 = DecodeContextMap( 5462 num_block_types[ 0 ] << kLiteralContextBits, 5463 br 5464 ); 5465 num_literal_htrees = _o1.num_htrees; 5466 context_map = _o1.context_map; 5467 5468 var _o2 = DecodeContextMap( 5469 num_block_types[ 2 ] << kDistanceContextBits, 5470 br 5471 ); 5472 num_dist_htrees = _o2.num_htrees; 5473 dist_context_map = _o2.context_map; 5474 5475 hgroup[ 0 ] = new HuffmanTreeGroup( 5476 kNumLiteralCodes, 5477 num_literal_htrees 5478 ); 5479 hgroup[ 1 ] = new HuffmanTreeGroup( 5480 kNumInsertAndCopyCodes, 5481 num_block_types[ 1 ] 5482 ); 5483 hgroup[ 2 ] = new HuffmanTreeGroup( 5484 num_distance_codes, 5485 num_dist_htrees 5486 ); 5487 5488 for ( i = 0; i < 3; ++i ) { 5489 hgroup[ i ].decode( br ); 5490 } 5491 5492 context_map_slice = 0; 5493 dist_context_map_slice = 0; 5494 context_mode = context_modes[ block_type[ 0 ] ]; 5495 context_lookup_offset1 = 5496 Context.lookupOffsets[ context_mode ]; 5497 context_lookup_offset2 = 5498 Context.lookupOffsets[ context_mode + 1 ]; 5499 htree_command = hgroup[ 1 ].htrees[ 0 ]; 5500 5501 while ( meta_block_remaining_len > 0 ) { 5502 var cmd_code; 5503 var range_idx; 5504 var insert_code; 5505 var copy_code; 5506 var insert_length; 5507 var copy_length; 5508 var distance_code; 5509 var distance; 5510 var context; 5511 var j; 5512 var copy_dst; 5513 5514 br.readMoreInput(); 5515 5516 if ( block_length[ 1 ] === 0 ) { 5517 DecodeBlockType( 5518 num_block_types[ 1 ], 5519 block_type_trees, 5520 1, 5521 block_type, 5522 block_type_rb, 5523 block_type_rb_index, 5524 br 5525 ); 5526 block_length[ 1 ] = ReadBlockLength( 5527 block_len_trees, 5528 HUFFMAN_MAX_TABLE_SIZE, 5529 br 5530 ); 5531 htree_command = 5532 hgroup[ 1 ].htrees[ block_type[ 1 ] ]; 5533 } 5534 --block_length[ 1 ]; 5535 cmd_code = ReadSymbol( 5536 hgroup[ 1 ].codes, 5537 htree_command, 5538 br 5539 ); 5540 range_idx = cmd_code >> 6; 5541 if ( range_idx >= 2 ) { 5542 range_idx -= 2; 5543 distance_code = -1; 5544 } else { 5545 distance_code = 0; 5546 } 5547 insert_code = 5548 Prefix.kInsertRangeLut[ range_idx ] + 5549 ( ( cmd_code >> 3 ) & 7 ); 5550 copy_code = 5551 Prefix.kCopyRangeLut[ range_idx ] + 5552 ( cmd_code & 7 ); 5553 insert_length = 5554 Prefix.kInsertLengthPrefixCode[ 5555 insert_code 5556 ].offset + 5557 br.readBits( 5558 Prefix.kInsertLengthPrefixCode[ 5559 insert_code 5560 ].nbits 5561 ); 5562 copy_length = 5563 Prefix.kCopyLengthPrefixCode[ copy_code ] 5564 .offset + 5565 br.readBits( 5566 Prefix.kCopyLengthPrefixCode[ 5567 copy_code 5568 ].nbits 5569 ); 5570 prev_byte1 = 5571 ringbuffer[ ( pos - 1 ) & ringbuffer_mask ]; 5572 prev_byte2 = 5573 ringbuffer[ ( pos - 2 ) & ringbuffer_mask ]; 5574 for ( j = 0; j < insert_length; ++j ) { 5575 br.readMoreInput(); 5576 5577 if ( block_length[ 0 ] === 0 ) { 5578 DecodeBlockType( 5579 num_block_types[ 0 ], 5580 block_type_trees, 5581 0, 5582 block_type, 5583 block_type_rb, 5584 block_type_rb_index, 5585 br 5586 ); 5587 block_length[ 0 ] = ReadBlockLength( 5588 block_len_trees, 5589 0, 5590 br 5591 ); 5592 context_offset = 5593 block_type[ 0 ] << 5594 kLiteralContextBits; 5595 context_map_slice = context_offset; 5596 context_mode = 5597 context_modes[ block_type[ 0 ] ]; 5598 context_lookup_offset1 = 5599 Context.lookupOffsets[ 5600 context_mode 5601 ]; 5602 context_lookup_offset2 = 5603 Context.lookupOffsets[ 5604 context_mode + 1 5605 ]; 5606 } 5607 context = 5608 Context.lookup[ 5609 context_lookup_offset1 + prev_byte1 5610 ] | 5611 Context.lookup[ 5612 context_lookup_offset2 + prev_byte2 5613 ]; 5614 literal_htree_index = 5615 context_map[ 5616 context_map_slice + context 5617 ]; 5618 --block_length[ 0 ]; 5619 prev_byte2 = prev_byte1; 5620 prev_byte1 = ReadSymbol( 5621 hgroup[ 0 ].codes, 5622 hgroup[ 0 ].htrees[ 5623 literal_htree_index 5624 ], 5625 br 5626 ); 5627 ringbuffer[ pos & ringbuffer_mask ] = 5628 prev_byte1; 5629 if ( 5630 ( pos & ringbuffer_mask ) === 5631 ringbuffer_mask 5632 ) { 5633 output.write( 5634 ringbuffer, 5635 ringbuffer_size 5636 ); 5637 } 5638 ++pos; 5639 } 5640 meta_block_remaining_len -= insert_length; 5641 if ( meta_block_remaining_len <= 0 ) break; 5642 5643 if ( distance_code < 0 ) { 5644 var context; 5645 5646 br.readMoreInput(); 5647 if ( block_length[ 2 ] === 0 ) { 5648 DecodeBlockType( 5649 num_block_types[ 2 ], 5650 block_type_trees, 5651 2, 5652 block_type, 5653 block_type_rb, 5654 block_type_rb_index, 5655 br 5656 ); 5657 block_length[ 2 ] = ReadBlockLength( 5658 block_len_trees, 5659 2 * HUFFMAN_MAX_TABLE_SIZE, 5660 br 5661 ); 5662 dist_context_offset = 5663 block_type[ 2 ] << 5664 kDistanceContextBits; 5665 dist_context_map_slice = 5666 dist_context_offset; 5667 } 5668 --block_length[ 2 ]; 5669 context = 5670 ( copy_length > 4 5671 ? 3 5672 : copy_length - 2 ) & 0xff; 5673 dist_htree_index = 5674 dist_context_map[ 5675 dist_context_map_slice + context 5676 ]; 5677 distance_code = ReadSymbol( 5678 hgroup[ 2 ].codes, 5679 hgroup[ 2 ].htrees[ dist_htree_index ], 5680 br 5681 ); 5682 if ( 5683 distance_code >= 5684 num_direct_distance_codes 5685 ) { 5686 var nbits; 5687 var postfix; 5688 var offset; 5689 distance_code -= 5690 num_direct_distance_codes; 5691 postfix = 5692 distance_code & 5693 distance_postfix_mask; 5694 distance_code >>= distance_postfix_bits; 5695 nbits = ( distance_code >> 1 ) + 1; 5696 offset = 5697 ( ( 2 + ( distance_code & 1 ) ) << 5698 nbits ) - 5699 4; 5700 distance_code = 5701 num_direct_distance_codes + 5702 ( ( offset + 5703 br.readBits( nbits ) ) << 5704 distance_postfix_bits ) + 5705 postfix; 5706 } 5707 } 5708 5709 /* Convert the distance code to the actual distance by possibly looking */ 5710 /* up past distnaces from the ringbuffer. */ 5711 distance = TranslateShortCodes( 5712 distance_code, 5713 dist_rb, 5714 dist_rb_idx 5715 ); 5716 if ( distance < 0 ) { 5717 throw new Error( 5718 '[BrotliDecompress] invalid distance' 5719 ); 5720 } 5721 5722 if ( 5723 pos < max_backward_distance && 5724 max_distance !== max_backward_distance 5725 ) { 5726 max_distance = pos; 5727 } else { 5728 max_distance = max_backward_distance; 5729 } 5730 5731 copy_dst = pos & ringbuffer_mask; 5732 5733 if ( distance > max_distance ) { 5734 if ( 5735 copy_length >= 5736 BrotliDictionary.minDictionaryWordLength && 5737 copy_length <= 5738 BrotliDictionary.maxDictionaryWordLength 5739 ) { 5740 var offset = 5741 BrotliDictionary.offsetsByLength[ 5742 copy_length 5743 ]; 5744 var word_id = 5745 distance - max_distance - 1; 5746 var shift = 5747 BrotliDictionary.sizeBitsByLength[ 5748 copy_length 5749 ]; 5750 var mask = ( 1 << shift ) - 1; 5751 var word_idx = word_id & mask; 5752 var transform_idx = word_id >> shift; 5753 offset += word_idx * copy_length; 5754 if ( 5755 transform_idx < 5756 Transform.kNumTransforms 5757 ) { 5758 var len = 5759 Transform.transformDictionaryWord( 5760 ringbuffer, 5761 copy_dst, 5762 offset, 5763 copy_length, 5764 transform_idx 5765 ); 5766 copy_dst += len; 5767 pos += len; 5768 meta_block_remaining_len -= len; 5769 if ( copy_dst >= ringbuffer_end ) { 5770 output.write( 5771 ringbuffer, 5772 ringbuffer_size 5773 ); 5774 5775 for ( 5776 var _x = 0; 5777 _x < 5778 copy_dst - ringbuffer_end; 5779 _x++ 5780 ) 5781 ringbuffer[ _x ] = 5782 ringbuffer[ 5783 ringbuffer_end + _x 5784 ]; 5785 } 5786 } else { 5787 throw new Error( 5788 'Invalid backward reference. pos: ' + 5789 pos + 5790 ' distance: ' + 5791 distance + 5792 ' len: ' + 5793 copy_length + 5794 ' bytes left: ' + 5795 meta_block_remaining_len 5796 ); 5797 } 5798 } else { 5799 throw new Error( 5800 'Invalid backward reference. pos: ' + 5801 pos + 5802 ' distance: ' + 5803 distance + 5804 ' len: ' + 5805 copy_length + 5806 ' bytes left: ' + 5807 meta_block_remaining_len 5808 ); 5809 } 5810 } else { 5811 if ( distance_code > 0 ) { 5812 dist_rb[ dist_rb_idx & 3 ] = distance; 5813 ++dist_rb_idx; 5814 } 5815 5816 if ( 5817 copy_length > meta_block_remaining_len 5818 ) { 5819 throw new Error( 5820 'Invalid backward reference. pos: ' + 5821 pos + 5822 ' distance: ' + 5823 distance + 5824 ' len: ' + 5825 copy_length + 5826 ' bytes left: ' + 5827 meta_block_remaining_len 5828 ); 5829 } 5830 5831 for ( j = 0; j < copy_length; ++j ) { 5832 ringbuffer[ pos & ringbuffer_mask ] = 5833 ringbuffer[ 5834 ( pos - distance ) & 5835 ringbuffer_mask 5836 ]; 5837 if ( 5838 ( pos & ringbuffer_mask ) === 5839 ringbuffer_mask 5840 ) { 5841 output.write( 5842 ringbuffer, 5843 ringbuffer_size 5844 ); 5845 } 5846 ++pos; 5847 --meta_block_remaining_len; 5848 } 5849 } 5850 5851 /* When we get here, we must have inserted at least one literal and */ 5852 /* made a copy of at least length two, therefore accessing the last 2 */ 5853 /* bytes is valid. */ 5854 prev_byte1 = 5855 ringbuffer[ ( pos - 1 ) & ringbuffer_mask ]; 5856 prev_byte2 = 5857 ringbuffer[ ( pos - 2 ) & ringbuffer_mask ]; 5858 } 5859 5860 /* Protect pos from overflow, wrap it around at every GB of input data */ 5861 pos &= 0x3fffffff; 5862 } 5863 5864 output.write( ringbuffer, pos & ringbuffer_mask ); 5865 } 5866 5867 exports.BrotliDecompress = BrotliDecompress; 5868 5869 BrotliDictionary.init(); 5870 }, 5871 { 5872 './bit_reader': 1, 5873 './context': 2, 5874 './dictionary': 6, 5875 './huffman': 7, 5876 './prefix': 9, 5877 './streams': 10, 5878 './transform': 11, 5879 }, 5880 ], 5881 4: [ 5882 function ( require, module, exports ) { 5883 var base64 = require( 'base64-js' ); 5884 //var fs = require('fs'); 5885 5886 /** 5887 * The normal dictionary-data.js is quite large, which makes it 5888 * unsuitable for browser usage. In order to make it smaller, 5889 * we read dictionary.bin, which is a compressed version of 5890 * the dictionary, and on initial load, Brotli decompresses 5891 * it's own dictionary. 😜 5892 */ 5893 exports.init = function () { 5894 var BrotliDecompressBuffer = 5895 require( './decode' ).BrotliDecompressBuffer; 5896 var compressed = base64.toByteArray( 5897 require( './dictionary.bin.js' ) 5898 ); 5899 return BrotliDecompressBuffer( compressed ); 5900 }; 5901 }, 5902 { './decode': 3, './dictionary.bin.js': 5, 'base64-js': 8 }, 5903 ], 5904 5: [ 5905 function ( require, module, exports ) { 5906 module.exports = 5907 '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'; 5908 }, 5909 {}, 5910 ], 5911 6: [ 5912 function ( require, module, exports ) { 5913 /* Copyright 2013 Google Inc. All Rights Reserved. 5914 5915 Licensed under the Apache License, Version 2.0 (the "License"); 5916 you may not use this file except in compliance with the License. 5917 You may obtain a copy of the License at 5918 5919 http://www.apache.org/licenses/LICENSE-2.0 5920 5921 Unless required by applicable law or agreed to in writing, software 5922 distributed under the License is distributed on an "AS IS" BASIS, 5923 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 5924 See the License for the specific language governing permissions and 5925 limitations under the License. 5926 5927 Collection of static dictionary words. 5928 */ 5929 5930 var data = require( './dictionary-browser' ); 5931 exports.init = function () { 5932 exports.dictionary = data.init(); 5933 }; 5934 5935 exports.offsetsByLength = new Uint32Array( [ 5936 0, 0, 0, 0, 0, 4096, 9216, 21504, 35840, 44032, 53248, 5937 63488, 74752, 87040, 93696, 100864, 104704, 106752, 5938 108928, 113536, 115968, 118528, 119872, 121280, 122016, 5939 ] ); 5940 5941 exports.sizeBitsByLength = new Uint8Array( [ 5942 0, 0, 0, 0, 10, 10, 11, 11, 10, 10, 10, 10, 10, 9, 9, 8, 5943 7, 7, 8, 7, 7, 6, 6, 5, 5, 5944 ] ); 5945 5946 exports.minDictionaryWordLength = 4; 5947 exports.maxDictionaryWordLength = 24; 5948 }, 5949 { './dictionary-browser': 4 }, 5950 ], 5951 7: [ 5952 function ( require, module, exports ) { 5953 function HuffmanCode( bits, value ) { 5954 this.bits = 5955 bits; /* number of bits used for this symbol */ 5956 this.value = value; /* symbol value or table offset */ 5957 } 5958 5959 exports.HuffmanCode = HuffmanCode; 5960 5961 var MAX_LENGTH = 15; 5962 5963 /* Returns reverse(reverse(key, len) + 1, len), where reverse(key, len) is the 5964 bit-wise reversal of the len least significant bits of key. */ 5965 function GetNextKey( key, len ) { 5966 var step = 1 << ( len - 1 ); 5967 while ( key & step ) { 5968 step >>= 1; 5969 } 5970 return ( key & ( step - 1 ) ) + step; 5971 } 5972 5973 /* Stores code in table[0], table[step], table[2*step], ..., table[end] */ 5974 /* Assumes that end is an integer multiple of step */ 5975 function ReplicateValue( table, i, step, end, code ) { 5976 do { 5977 end -= step; 5978 table[ i + end ] = new HuffmanCode( 5979 code.bits, 5980 code.value 5981 ); 5982 } while ( end > 0 ); 5983 } 5984 5985 /* Returns the table width of the next 2nd level table. count is the histogram 5986 of bit lengths for the remaining symbols, len is the code length of the next 5987 processed symbol */ 5988 function NextTableBitSize( count, len, root_bits ) { 5989 var left = 1 << ( len - root_bits ); 5990 while ( len < MAX_LENGTH ) { 5991 left -= count[ len ]; 5992 if ( left <= 0 ) break; 5993 ++len; 5994 left <<= 1; 5995 } 5996 return len - root_bits; 5997 } 5998 5999 exports.BrotliBuildHuffmanTable = function ( 6000 root_table, 6001 table, 6002 root_bits, 6003 code_lengths, 6004 code_lengths_size 6005 ) { 6006 var start_table = table; 6007 var code; /* current table entry */ 6008 var len; /* current code length */ 6009 var symbol; /* symbol index in original or sorted table */ 6010 var key; /* reversed prefix code */ 6011 var step; /* step size to replicate values in current table */ 6012 var low; /* low bits for current root entry */ 6013 var mask; /* mask for low bits */ 6014 var table_bits; /* key length of current table */ 6015 var table_size; /* size of current table */ 6016 var total_size; /* sum of root table size and 2nd level table sizes */ 6017 var sorted; /* symbols sorted by code length */ 6018 var count = new Int32Array( 6019 MAX_LENGTH + 1 6020 ); /* number of codes of each length */ 6021 var offset = new Int32Array( 6022 MAX_LENGTH + 1 6023 ); /* offsets in sorted table for each length */ 6024 6025 sorted = new Int32Array( code_lengths_size ); 6026 6027 /* build histogram of code lengths */ 6028 for ( 6029 symbol = 0; 6030 symbol < code_lengths_size; 6031 symbol++ 6032 ) { 6033 count[ code_lengths[ symbol ] ]++; 6034 } 6035 6036 /* generate offsets into sorted symbol table by code length */ 6037 offset[ 1 ] = 0; 6038 for ( len = 1; len < MAX_LENGTH; len++ ) { 6039 offset[ len + 1 ] = offset[ len ] + count[ len ]; 6040 } 6041 6042 /* sort symbols by length, by symbol order within each length */ 6043 for ( 6044 symbol = 0; 6045 symbol < code_lengths_size; 6046 symbol++ 6047 ) { 6048 if ( code_lengths[ symbol ] !== 0 ) { 6049 sorted[ offset[ code_lengths[ symbol ] ]++ ] = 6050 symbol; 6051 } 6052 } 6053 6054 table_bits = root_bits; 6055 table_size = 1 << table_bits; 6056 total_size = table_size; 6057 6058 /* special case code with only one value */ 6059 if ( offset[ MAX_LENGTH ] === 1 ) { 6060 for ( key = 0; key < total_size; ++key ) { 6061 root_table[ table + key ] = new HuffmanCode( 6062 0, 6063 sorted[ 0 ] & 0xffff 6064 ); 6065 } 6066 6067 return total_size; 6068 } 6069 6070 /* fill in root table */ 6071 key = 0; 6072 symbol = 0; 6073 for ( 6074 len = 1, step = 2; 6075 len <= root_bits; 6076 ++len, step <<= 1 6077 ) { 6078 for ( ; count[ len ] > 0; --count[ len ] ) { 6079 code = new HuffmanCode( 6080 len & 0xff, 6081 sorted[ symbol++ ] & 0xffff 6082 ); 6083 ReplicateValue( 6084 root_table, 6085 table + key, 6086 step, 6087 table_size, 6088 code 6089 ); 6090 key = GetNextKey( key, len ); 6091 } 6092 } 6093 6094 /* fill in 2nd level tables and add pointers to root table */ 6095 mask = total_size - 1; 6096 low = -1; 6097 for ( 6098 len = root_bits + 1, step = 2; 6099 len <= MAX_LENGTH; 6100 ++len, step <<= 1 6101 ) { 6102 for ( ; count[ len ] > 0; --count[ len ] ) { 6103 if ( ( key & mask ) !== low ) { 6104 table += table_size; 6105 table_bits = NextTableBitSize( 6106 count, 6107 len, 6108 root_bits 6109 ); 6110 table_size = 1 << table_bits; 6111 total_size += table_size; 6112 low = key & mask; 6113 root_table[ start_table + low ] = 6114 new HuffmanCode( 6115 ( table_bits + root_bits ) & 0xff, 6116 ( table - start_table - low ) & 6117 0xffff 6118 ); 6119 } 6120 code = new HuffmanCode( 6121 ( len - root_bits ) & 0xff, 6122 sorted[ symbol++ ] & 0xffff 6123 ); 6124 ReplicateValue( 6125 root_table, 6126 table + ( key >> root_bits ), 6127 step, 6128 table_size, 6129 code 6130 ); 6131 key = GetNextKey( key, len ); 6132 } 6133 } 6134 6135 return total_size; 6136 }; 6137 }, 6138 {}, 6139 ], 6140 8: [ 6141 function ( require, module, exports ) { 6142 'use strict'; 6143 6144 exports.byteLength = byteLength; 6145 exports.toByteArray = toByteArray; 6146 exports.fromByteArray = fromByteArray; 6147 6148 var lookup = []; 6149 var revLookup = []; 6150 var Arr = 6151 typeof Uint8Array !== 'undefined' ? Uint8Array : Array; 6152 6153 var code = 6154 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; 6155 for ( var i = 0, len = code.length; i < len; ++i ) { 6156 lookup[ i ] = code[ i ]; 6157 revLookup[ code.charCodeAt( i ) ] = i; 6158 } 6159 6160 // Support decoding URL-safe base64 strings, as Node.js does. 6161 // See: https://en.wikipedia.org/wiki/Base64#URL_applications 6162 revLookup[ '-'.charCodeAt( 0 ) ] = 62; 6163 revLookup[ '_'.charCodeAt( 0 ) ] = 63; 6164 6165 function getLens( b64 ) { 6166 var len = b64.length; 6167 6168 if ( len % 4 > 0 ) { 6169 throw new Error( 6170 'Invalid string. Length must be a multiple of 4' 6171 ); 6172 } 6173 6174 // Trim off extra bytes after placeholder bytes are found 6175 // See: https://github.com/beatgammit/base64-js/issues/42 6176 var validLen = b64.indexOf( '=' ); 6177 if ( validLen === -1 ) validLen = len; 6178 6179 var placeHoldersLen = 6180 validLen === len ? 0 : 4 - ( validLen % 4 ); 6181 6182 return [ validLen, placeHoldersLen ]; 6183 } 6184 6185 // base64 is 4/3 + up to two characters of the original data 6186 function byteLength( b64 ) { 6187 var lens = getLens( b64 ); 6188 var validLen = lens[ 0 ]; 6189 var placeHoldersLen = lens[ 1 ]; 6190 return ( 6191 ( ( validLen + placeHoldersLen ) * 3 ) / 4 - 6192 placeHoldersLen 6193 ); 6194 } 6195 6196 function _byteLength( b64, validLen, placeHoldersLen ) { 6197 return ( 6198 ( ( validLen + placeHoldersLen ) * 3 ) / 4 - 6199 placeHoldersLen 6200 ); 6201 } 6202 6203 function toByteArray( b64 ) { 6204 var tmp; 6205 var lens = getLens( b64 ); 6206 var validLen = lens[ 0 ]; 6207 var placeHoldersLen = lens[ 1 ]; 6208 6209 var arr = new Arr( 6210 _byteLength( b64, validLen, placeHoldersLen ) 6211 ); 6212 6213 var curByte = 0; 6214 6215 // if there are placeholders, only get up to the last complete 4 chars 6216 var len = placeHoldersLen > 0 ? validLen - 4 : validLen; 6217 6218 for ( var i = 0; i < len; i += 4 ) { 6219 tmp = 6220 ( revLookup[ b64.charCodeAt( i ) ] << 18 ) | 6221 ( revLookup[ b64.charCodeAt( i + 1 ) ] << 12 ) | 6222 ( revLookup[ b64.charCodeAt( i + 2 ) ] << 6 ) | 6223 revLookup[ b64.charCodeAt( i + 3 ) ]; 6224 arr[ curByte++ ] = ( tmp >> 16 ) & 0xff; 6225 arr[ curByte++ ] = ( tmp >> 8 ) & 0xff; 6226 arr[ curByte++ ] = tmp & 0xff; 6227 } 6228 6229 if ( placeHoldersLen === 2 ) { 6230 tmp = 6231 ( revLookup[ b64.charCodeAt( i ) ] << 2 ) | 6232 ( revLookup[ b64.charCodeAt( i + 1 ) ] >> 4 ); 6233 arr[ curByte++ ] = tmp & 0xff; 6234 } 6235 6236 if ( placeHoldersLen === 1 ) { 6237 tmp = 6238 ( revLookup[ b64.charCodeAt( i ) ] << 10 ) | 6239 ( revLookup[ b64.charCodeAt( i + 1 ) ] << 4 ) | 6240 ( revLookup[ b64.charCodeAt( i + 2 ) ] >> 2 ); 6241 arr[ curByte++ ] = ( tmp >> 8 ) & 0xff; 6242 arr[ curByte++ ] = tmp & 0xff; 6243 } 6244 6245 return arr; 6246 } 6247 6248 function tripletToBase64( num ) { 6249 return ( 6250 lookup[ ( num >> 18 ) & 0x3f ] + 6251 lookup[ ( num >> 12 ) & 0x3f ] + 6252 lookup[ ( num >> 6 ) & 0x3f ] + 6253 lookup[ num & 0x3f ] 6254 ); 6255 } 6256 6257 function encodeChunk( uint8, start, end ) { 6258 var tmp; 6259 var output = []; 6260 for ( var i = start; i < end; i += 3 ) { 6261 tmp = 6262 ( ( uint8[ i ] << 16 ) & 0xff0000 ) + 6263 ( ( uint8[ i + 1 ] << 8 ) & 0xff00 ) + 6264 ( uint8[ i + 2 ] & 0xff ); 6265 output.push( tripletToBase64( tmp ) ); 6266 } 6267 return output.join( '' ); 6268 } 6269 6270 function fromByteArray( uint8 ) { 6271 var tmp; 6272 var len = uint8.length; 6273 var extraBytes = len % 3; // if we have 1 byte left, pad 2 bytes 6274 var parts = []; 6275 var maxChunkLength = 16383; // must be multiple of 3 6276 6277 // go through the array every three bytes, we'll deal with trailing stuff later 6278 for ( 6279 var i = 0, len2 = len - extraBytes; 6280 i < len2; 6281 i += maxChunkLength 6282 ) { 6283 parts.push( 6284 encodeChunk( 6285 uint8, 6286 i, 6287 i + maxChunkLength > len2 6288 ? len2 6289 : i + maxChunkLength 6290 ) 6291 ); 6292 } 6293 6294 // pad the end with zeros, but make sure to not forget the extra bytes 6295 if ( extraBytes === 1 ) { 6296 tmp = uint8[ len - 1 ]; 6297 parts.push( 6298 lookup[ tmp >> 2 ] + 6299 lookup[ ( tmp << 4 ) & 0x3f ] + 6300 '==' 6301 ); 6302 } else if ( extraBytes === 2 ) { 6303 tmp = ( uint8[ len - 2 ] << 8 ) + uint8[ len - 1 ]; 6304 parts.push( 6305 lookup[ tmp >> 10 ] + 6306 lookup[ ( tmp >> 4 ) & 0x3f ] + 6307 lookup[ ( tmp << 2 ) & 0x3f ] + 6308 '=' 6309 ); 6310 } 6311 6312 return parts.join( '' ); 6313 } 6314 }, 6315 {}, 6316 ], 6317 9: [ 6318 function ( require, module, exports ) { 6319 /* Copyright 2013 Google Inc. All Rights Reserved. 6320 6321 Licensed under the Apache License, Version 2.0 (the "License"); 6322 you may not use this file except in compliance with the License. 6323 You may obtain a copy of the License at 6324 6325 http://www.apache.org/licenses/LICENSE-2.0 6326 6327 Unless required by applicable law or agreed to in writing, software 6328 distributed under the License is distributed on an "AS IS" BASIS, 6329 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6330 See the License for the specific language governing permissions and 6331 limitations under the License. 6332 6333 Lookup tables to map prefix codes to value ranges. This is used during 6334 decoding of the block lengths, literal insertion lengths and copy lengths. 6335 */ 6336 6337 /* Represents the range of values belonging to a prefix code: */ 6338 /* [offset, offset + 2^nbits) */ 6339 function PrefixCodeRange( offset, nbits ) { 6340 this.offset = offset; 6341 this.nbits = nbits; 6342 } 6343 6344 exports.kBlockLengthPrefixCode = [ 6345 new PrefixCodeRange( 1, 2 ), 6346 new PrefixCodeRange( 5, 2 ), 6347 new PrefixCodeRange( 9, 2 ), 6348 new PrefixCodeRange( 13, 2 ), 6349 new PrefixCodeRange( 17, 3 ), 6350 new PrefixCodeRange( 25, 3 ), 6351 new PrefixCodeRange( 33, 3 ), 6352 new PrefixCodeRange( 41, 3 ), 6353 new PrefixCodeRange( 49, 4 ), 6354 new PrefixCodeRange( 65, 4 ), 6355 new PrefixCodeRange( 81, 4 ), 6356 new PrefixCodeRange( 97, 4 ), 6357 new PrefixCodeRange( 113, 5 ), 6358 new PrefixCodeRange( 145, 5 ), 6359 new PrefixCodeRange( 177, 5 ), 6360 new PrefixCodeRange( 209, 5 ), 6361 new PrefixCodeRange( 241, 6 ), 6362 new PrefixCodeRange( 305, 6 ), 6363 new PrefixCodeRange( 369, 7 ), 6364 new PrefixCodeRange( 497, 8 ), 6365 new PrefixCodeRange( 753, 9 ), 6366 new PrefixCodeRange( 1265, 10 ), 6367 new PrefixCodeRange( 2289, 11 ), 6368 new PrefixCodeRange( 4337, 12 ), 6369 new PrefixCodeRange( 8433, 13 ), 6370 new PrefixCodeRange( 16625, 24 ), 6371 ]; 6372 6373 exports.kInsertLengthPrefixCode = [ 6374 new PrefixCodeRange( 0, 0 ), 6375 new PrefixCodeRange( 1, 0 ), 6376 new PrefixCodeRange( 2, 0 ), 6377 new PrefixCodeRange( 3, 0 ), 6378 new PrefixCodeRange( 4, 0 ), 6379 new PrefixCodeRange( 5, 0 ), 6380 new PrefixCodeRange( 6, 1 ), 6381 new PrefixCodeRange( 8, 1 ), 6382 new PrefixCodeRange( 10, 2 ), 6383 new PrefixCodeRange( 14, 2 ), 6384 new PrefixCodeRange( 18, 3 ), 6385 new PrefixCodeRange( 26, 3 ), 6386 new PrefixCodeRange( 34, 4 ), 6387 new PrefixCodeRange( 50, 4 ), 6388 new PrefixCodeRange( 66, 5 ), 6389 new PrefixCodeRange( 98, 5 ), 6390 new PrefixCodeRange( 130, 6 ), 6391 new PrefixCodeRange( 194, 7 ), 6392 new PrefixCodeRange( 322, 8 ), 6393 new PrefixCodeRange( 578, 9 ), 6394 new PrefixCodeRange( 1090, 10 ), 6395 new PrefixCodeRange( 2114, 12 ), 6396 new PrefixCodeRange( 6210, 14 ), 6397 new PrefixCodeRange( 22594, 24 ), 6398 ]; 6399 6400 exports.kCopyLengthPrefixCode = [ 6401 new PrefixCodeRange( 2, 0 ), 6402 new PrefixCodeRange( 3, 0 ), 6403 new PrefixCodeRange( 4, 0 ), 6404 new PrefixCodeRange( 5, 0 ), 6405 new PrefixCodeRange( 6, 0 ), 6406 new PrefixCodeRange( 7, 0 ), 6407 new PrefixCodeRange( 8, 0 ), 6408 new PrefixCodeRange( 9, 0 ), 6409 new PrefixCodeRange( 10, 1 ), 6410 new PrefixCodeRange( 12, 1 ), 6411 new PrefixCodeRange( 14, 2 ), 6412 new PrefixCodeRange( 18, 2 ), 6413 new PrefixCodeRange( 22, 3 ), 6414 new PrefixCodeRange( 30, 3 ), 6415 new PrefixCodeRange( 38, 4 ), 6416 new PrefixCodeRange( 54, 4 ), 6417 new PrefixCodeRange( 70, 5 ), 6418 new PrefixCodeRange( 102, 5 ), 6419 new PrefixCodeRange( 134, 6 ), 6420 new PrefixCodeRange( 198, 7 ), 6421 new PrefixCodeRange( 326, 8 ), 6422 new PrefixCodeRange( 582, 9 ), 6423 new PrefixCodeRange( 1094, 10 ), 6424 new PrefixCodeRange( 2118, 24 ), 6425 ]; 6426 6427 exports.kInsertRangeLut = [ 0, 0, 8, 8, 0, 16, 8, 16, 16 ]; 6428 6429 exports.kCopyRangeLut = [ 0, 8, 0, 8, 16, 0, 16, 8, 16 ]; 6430 }, 6431 {}, 6432 ], 6433 10: [ 6434 function ( require, module, exports ) { 6435 function BrotliInput( buffer ) { 6436 this.buffer = buffer; 6437 this.pos = 0; 6438 } 6439 6440 BrotliInput.prototype.read = function ( buf, i, count ) { 6441 if ( this.pos + count > this.buffer.length ) { 6442 count = this.buffer.length - this.pos; 6443 } 6444 6445 for ( var p = 0; p < count; p++ ) 6446 buf[ i + p ] = this.buffer[ this.pos + p ]; 6447 6448 this.pos += count; 6449 return count; 6450 }; 6451 6452 exports.BrotliInput = BrotliInput; 6453 6454 function BrotliOutput( buf ) { 6455 this.buffer = buf; 6456 this.pos = 0; 6457 } 6458 6459 BrotliOutput.prototype.write = function ( buf, count ) { 6460 if ( this.pos + count > this.buffer.length ) 6461 throw new Error( 6462 'Output buffer is not large enough' 6463 ); 6464 6465 this.buffer.set( buf.subarray( 0, count ), this.pos ); 6466 this.pos += count; 6467 return count; 6468 }; 6469 6470 exports.BrotliOutput = BrotliOutput; 6471 }, 6472 {}, 6473 ], 6474 11: [ 6475 function ( require, module, exports ) { 6476 /* Copyright 2013 Google Inc. All Rights Reserved. 6477 6478 Licensed under the Apache License, Version 2.0 (the "License"); 6479 you may not use this file except in compliance with the License. 6480 You may obtain a copy of the License at 6481 6482 http://www.apache.org/licenses/LICENSE-2.0 6483 6484 Unless required by applicable law or agreed to in writing, software 6485 distributed under the License is distributed on an "AS IS" BASIS, 6486 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 6487 See the License for the specific language governing permissions and 6488 limitations under the License. 6489 6490 Transformations on dictionary words. 6491 */ 6492 6493 var BrotliDictionary = require( './dictionary' ); 6494 6495 var kIdentity = 0; 6496 var kOmitLast1 = 1; 6497 var kOmitLast2 = 2; 6498 var kOmitLast3 = 3; 6499 var kOmitLast4 = 4; 6500 var kOmitLast5 = 5; 6501 var kOmitLast6 = 6; 6502 var kOmitLast7 = 7; 6503 var kOmitLast8 = 8; 6504 var kOmitLast9 = 9; 6505 var kUppercaseFirst = 10; 6506 var kUppercaseAll = 11; 6507 var kOmitFirst1 = 12; 6508 var kOmitFirst2 = 13; 6509 var kOmitFirst3 = 14; 6510 var kOmitFirst4 = 15; 6511 var kOmitFirst5 = 16; 6512 var kOmitFirst6 = 17; 6513 var kOmitFirst7 = 18; 6514 var kOmitFirst8 = 19; 6515 var kOmitFirst9 = 20; 6516 6517 function Transform( prefix, transform, suffix ) { 6518 this.prefix = new Uint8Array( prefix.length ); 6519 this.transform = transform; 6520 this.suffix = new Uint8Array( suffix.length ); 6521 6522 for ( var i = 0; i < prefix.length; i++ ) 6523 this.prefix[ i ] = prefix.charCodeAt( i ); 6524 6525 for ( var i = 0; i < suffix.length; i++ ) 6526 this.suffix[ i ] = suffix.charCodeAt( i ); 6527 } 6528 6529 var kTransforms = [ 6530 new Transform( '', kIdentity, '' ), 6531 new Transform( '', kIdentity, ' ' ), 6532 new Transform( ' ', kIdentity, ' ' ), 6533 new Transform( '', kOmitFirst1, '' ), 6534 new Transform( '', kUppercaseFirst, ' ' ), 6535 new Transform( '', kIdentity, ' the ' ), 6536 new Transform( ' ', kIdentity, '' ), 6537 new Transform( 's ', kIdentity, ' ' ), 6538 new Transform( '', kIdentity, ' of ' ), 6539 new Transform( '', kUppercaseFirst, '' ), 6540 new Transform( '', kIdentity, ' and ' ), 6541 new Transform( '', kOmitFirst2, '' ), 6542 new Transform( '', kOmitLast1, '' ), 6543 new Transform( ', ', kIdentity, ' ' ), 6544 new Transform( '', kIdentity, ', ' ), 6545 new Transform( ' ', kUppercaseFirst, ' ' ), 6546 new Transform( '', kIdentity, ' in ' ), 6547 new Transform( '', kIdentity, ' to ' ), 6548 new Transform( 'e ', kIdentity, ' ' ), 6549 new Transform( '', kIdentity, '"' ), 6550 new Transform( '', kIdentity, '.' ), 6551 new Transform( '', kIdentity, '">' ), 6552 new Transform( '', kIdentity, '\n' ), 6553 new Transform( '', kOmitLast3, '' ), 6554 new Transform( '', kIdentity, ']' ), 6555 new Transform( '', kIdentity, ' for ' ), 6556 new Transform( '', kOmitFirst3, '' ), 6557 new Transform( '', kOmitLast2, '' ), 6558 new Transform( '', kIdentity, ' a ' ), 6559 new Transform( '', kIdentity, ' that ' ), 6560 new Transform( ' ', kUppercaseFirst, '' ), 6561 new Transform( '', kIdentity, '. ' ), 6562 new Transform( '.', kIdentity, '' ), 6563 new Transform( ' ', kIdentity, ', ' ), 6564 new Transform( '', kOmitFirst4, '' ), 6565 new Transform( '', kIdentity, ' with ' ), 6566 new Transform( '', kIdentity, "'" ), 6567 new Transform( '', kIdentity, ' from ' ), 6568 new Transform( '', kIdentity, ' by ' ), 6569 new Transform( '', kOmitFirst5, '' ), 6570 new Transform( '', kOmitFirst6, '' ), 6571 new Transform( ' the ', kIdentity, '' ), 6572 new Transform( '', kOmitLast4, '' ), 6573 new Transform( '', kIdentity, '. The ' ), 6574 new Transform( '', kUppercaseAll, '' ), 6575 new Transform( '', kIdentity, ' on ' ), 6576 new Transform( '', kIdentity, ' as ' ), 6577 new Transform( '', kIdentity, ' is ' ), 6578 new Transform( '', kOmitLast7, '' ), 6579 new Transform( '', kOmitLast1, 'ing ' ), 6580 new Transform( '', kIdentity, '\n\t' ), 6581 new Transform( '', kIdentity, ':' ), 6582 new Transform( ' ', kIdentity, '. ' ), 6583 new Transform( '', kIdentity, 'ed ' ), 6584 new Transform( '', kOmitFirst9, '' ), 6585 new Transform( '', kOmitFirst7, '' ), 6586 new Transform( '', kOmitLast6, '' ), 6587 new Transform( '', kIdentity, '(' ), 6588 new Transform( '', kUppercaseFirst, ', ' ), 6589 new Transform( '', kOmitLast8, '' ), 6590 new Transform( '', kIdentity, ' at ' ), 6591 new Transform( '', kIdentity, 'ly ' ), 6592 new Transform( ' the ', kIdentity, ' of ' ), 6593 new Transform( '', kOmitLast5, '' ), 6594 new Transform( '', kOmitLast9, '' ), 6595 new Transform( ' ', kUppercaseFirst, ', ' ), 6596 new Transform( '', kUppercaseFirst, '"' ), 6597 new Transform( '.', kIdentity, '(' ), 6598 new Transform( '', kUppercaseAll, ' ' ), 6599 new Transform( '', kUppercaseFirst, '">' ), 6600 new Transform( '', kIdentity, '="' ), 6601 new Transform( ' ', kIdentity, '.' ), 6602 new Transform( '.com/', kIdentity, '' ), 6603 new Transform( ' the ', kIdentity, ' of the ' ), 6604 new Transform( '', kUppercaseFirst, "'" ), 6605 new Transform( '', kIdentity, '. This ' ), 6606 new Transform( '', kIdentity, ',' ), 6607 new Transform( '.', kIdentity, ' ' ), 6608 new Transform( '', kUppercaseFirst, '(' ), 6609 new Transform( '', kUppercaseFirst, '.' ), 6610 new Transform( '', kIdentity, ' not ' ), 6611 new Transform( ' ', kIdentity, '="' ), 6612 new Transform( '', kIdentity, 'er ' ), 6613 new Transform( ' ', kUppercaseAll, ' ' ), 6614 new Transform( '', kIdentity, 'al ' ), 6615 new Transform( ' ', kUppercaseAll, '' ), 6616 new Transform( '', kIdentity, "='" ), 6617 new Transform( '', kUppercaseAll, '"' ), 6618 new Transform( '', kUppercaseFirst, '. ' ), 6619 new Transform( ' ', kIdentity, '(' ), 6620 new Transform( '', kIdentity, 'ful ' ), 6621 new Transform( ' ', kUppercaseFirst, '. ' ), 6622 new Transform( '', kIdentity, 'ive ' ), 6623 new Transform( '', kIdentity, 'less ' ), 6624 new Transform( '', kUppercaseAll, "'" ), 6625 new Transform( '', kIdentity, 'est ' ), 6626 new Transform( ' ', kUppercaseFirst, '.' ), 6627 new Transform( '', kUppercaseAll, '">' ), 6628 new Transform( ' ', kIdentity, "='" ), 6629 new Transform( '', kUppercaseFirst, ',' ), 6630 new Transform( '', kIdentity, 'ize ' ), 6631 new Transform( '', kUppercaseAll, '.' ), 6632 new Transform( '\xc2\xa0', kIdentity, '' ), 6633 new Transform( ' ', kIdentity, ',' ), 6634 new Transform( '', kUppercaseFirst, '="' ), 6635 new Transform( '', kUppercaseAll, '="' ), 6636 new Transform( '', kIdentity, 'ous ' ), 6637 new Transform( '', kUppercaseAll, ', ' ), 6638 new Transform( '', kUppercaseFirst, "='" ), 6639 new Transform( ' ', kUppercaseFirst, ',' ), 6640 new Transform( ' ', kUppercaseAll, '="' ), 6641 new Transform( ' ', kUppercaseAll, ', ' ), 6642 new Transform( '', kUppercaseAll, ',' ), 6643 new Transform( '', kUppercaseAll, '(' ), 6644 new Transform( '', kUppercaseAll, '. ' ), 6645 new Transform( ' ', kUppercaseAll, '.' ), 6646 new Transform( '', kUppercaseAll, "='" ), 6647 new Transform( ' ', kUppercaseAll, '. ' ), 6648 new Transform( ' ', kUppercaseFirst, '="' ), 6649 new Transform( ' ', kUppercaseAll, "='" ), 6650 new Transform( ' ', kUppercaseFirst, "='" ), 6651 ]; 6652 6653 exports.kTransforms = kTransforms; 6654 exports.kNumTransforms = kTransforms.length; 6655 6656 function ToUpperCase( p, i ) { 6657 if ( p[ i ] < 0xc0 ) { 6658 if ( p[ i ] >= 97 && p[ i ] <= 122 ) { 6659 p[ i ] ^= 32; 6660 } 6661 return 1; 6662 } 6663 6664 /* An overly simplified uppercasing model for utf-8. */ 6665 if ( p[ i ] < 0xe0 ) { 6666 p[ i + 1 ] ^= 32; 6667 return 2; 6668 } 6669 6670 /* An arbitrary transform for three byte characters. */ 6671 p[ i + 2 ] ^= 5; 6672 return 3; 6673 } 6674 6675 exports.transformDictionaryWord = function ( 6676 dst, 6677 idx, 6678 word, 6679 len, 6680 transform 6681 ) { 6682 var prefix = kTransforms[ transform ].prefix; 6683 var suffix = kTransforms[ transform ].suffix; 6684 var t = kTransforms[ transform ].transform; 6685 var skip = 6686 t < kOmitFirst1 ? 0 : t - ( kOmitFirst1 - 1 ); 6687 var i = 0; 6688 var start_idx = idx; 6689 var uppercase; 6690 6691 if ( skip > len ) { 6692 skip = len; 6693 } 6694 6695 var prefix_pos = 0; 6696 while ( prefix_pos < prefix.length ) { 6697 dst[ idx++ ] = prefix[ prefix_pos++ ]; 6698 } 6699 6700 word += skip; 6701 len -= skip; 6702 6703 if ( t <= kOmitLast9 ) { 6704 len -= t; 6705 } 6706 6707 for ( i = 0; i < len; i++ ) { 6708 dst[ idx++ ] = 6709 BrotliDictionary.dictionary[ word + i ]; 6710 } 6711 6712 uppercase = idx - len; 6713 6714 if ( t === kUppercaseFirst ) { 6715 ToUpperCase( dst, uppercase ); 6716 } else if ( t === kUppercaseAll ) { 6717 while ( len > 0 ) { 6718 var step = ToUpperCase( dst, uppercase ); 6719 uppercase += step; 6720 len -= step; 6721 } 6722 } 6723 6724 var suffix_pos = 0; 6725 while ( suffix_pos < suffix.length ) { 6726 dst[ idx++ ] = suffix[ suffix_pos++ ]; 6727 } 6728 6729 return idx - start_idx; 6730 }; 6731 }, 6732 { './dictionary': 6 }, 6733 ], 6734 12: [ 6735 function ( require, module, exports ) { 6736 module.exports = 6737 require( './dec/decode' ).BrotliDecompressBuffer; 6738 }, 6739 { './dec/decode': 3 }, 6740 ], 6741 }, 6742 {}, 6743 [ 12 ] 6744 )( 12 ); 6745 } ); 6746 /* eslint-enable */ 6747 6748 6749 /***/ }), 6750 6751 /***/ 4306: 6752 /***/ (function(module, exports) { 6753 6754 var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*! 6755 autosize 4.0.4 6756 license: MIT 6757 http://www.jacklmoore.com/autosize 6758 */ 6759 (function (global, factory) { 6760 if (true) { 6761 !(__WEBPACK_AMD_DEFINE_ARRAY__ = [module, exports], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory), 6762 __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? 6763 (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__), 6764 __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); 6765 } else { var mod; } 6766 })(this, function (module, exports) { 6767 'use strict'; 6768 6769 var map = typeof Map === "function" ? new Map() : function () { 6770 var keys = []; 6771 var values = []; 6772 6773 return { 6774 has: function has(key) { 6775 return keys.indexOf(key) > -1; 6776 }, 6777 get: function get(key) { 6778 return values[keys.indexOf(key)]; 6779 }, 6780 set: function set(key, value) { 6781 if (keys.indexOf(key) === -1) { 6782 keys.push(key); 6783 values.push(value); 6784 } 6785 }, 6786 delete: function _delete(key) { 6787 var index = keys.indexOf(key); 6788 if (index > -1) { 6789 keys.splice(index, 1); 6790 values.splice(index, 1); 6791 } 6792 } 6793 }; 6794 }(); 6795 6796 var createEvent = function createEvent(name) { 6797 return new Event(name, { bubbles: true }); 6798 }; 6799 try { 6800 new Event('test'); 6801 } catch (e) { 6802 // IE does not support `new Event()` 6803 createEvent = function createEvent(name) { 6804 var evt = document.createEvent('Event'); 6805 evt.initEvent(name, true, false); 6806 return evt; 6807 }; 6808 } 6809 6810 function assign(ta) { 6811 if (!ta || !ta.nodeName || ta.nodeName !== 'TEXTAREA' || map.has(ta)) return; 6812 6813 var heightOffset = null; 6814 var clientWidth = null; 6815 var cachedHeight = null; 6816 6817 function init() { 6818 var style = window.getComputedStyle(ta, null); 6819 6820 if (style.resize === 'vertical') { 6821 ta.style.resize = 'none'; 6822 } else if (style.resize === 'both') { 6823 ta.style.resize = 'horizontal'; 6824 } 6825 6826 if (style.boxSizing === 'content-box') { 6827 heightOffset = -(parseFloat(style.paddingTop) + parseFloat(style.paddingBottom)); 6828 } else { 6829 heightOffset = parseFloat(style.borderTopWidth) + parseFloat(style.borderBottomWidth); 6830 } 6831 // Fix when a textarea is not on document body and heightOffset is Not a Number 6832 if (isNaN(heightOffset)) { 6833 heightOffset = 0; 6834 } 6835 6836 update(); 6837 } 6838 6839 function changeOverflow(value) { 6840 { 6841 // Chrome/Safari-specific fix: 6842 // When the textarea y-overflow is hidden, Chrome/Safari do not reflow the text to account for the space 6843 // made available by removing the scrollbar. The following forces the necessary text reflow. 6844 var width = ta.style.width; 6845 ta.style.width = '0px'; 6846 // Force reflow: 6847 /* jshint ignore:start */ 6848 ta.offsetWidth; 6849 /* jshint ignore:end */ 6850 ta.style.width = width; 6851 } 6852 6853 ta.style.overflowY = value; 6854 } 6855 6856 function getParentOverflows(el) { 6857 var arr = []; 6858 6859 while (el && el.parentNode && el.parentNode instanceof Element) { 6860 if (el.parentNode.scrollTop) { 6861 arr.push({ 6862 node: el.parentNode, 6863 scrollTop: el.parentNode.scrollTop 6864 }); 6865 } 6866 el = el.parentNode; 6867 } 6868 6869 return arr; 6870 } 6871 6872 function resize() { 6873 if (ta.scrollHeight === 0) { 6874 // If the scrollHeight is 0, then the element probably has display:none or is detached from the DOM. 6875 return; 6876 } 6877 6878 var overflows = getParentOverflows(ta); 6879 var docTop = document.documentElement && document.documentElement.scrollTop; // Needed for Mobile IE (ticket #240) 6880 6881 ta.style.height = ''; 6882 ta.style.height = ta.scrollHeight + heightOffset + 'px'; 6883 6884 // used to check if an update is actually necessary on window.resize 6885 clientWidth = ta.clientWidth; 6886 6887 // prevents scroll-position jumping 6888 overflows.forEach(function (el) { 6889 el.node.scrollTop = el.scrollTop; 6890 }); 6891 6892 if (docTop) { 6893 document.documentElement.scrollTop = docTop; 6894 } 6895 } 6896 6897 function update() { 6898 resize(); 6899 6900 var styleHeight = Math.round(parseFloat(ta.style.height)); 6901 var computed = window.getComputedStyle(ta, null); 6902 6903 // Using offsetHeight as a replacement for computed.height in IE, because IE does not account use of border-box 6904 var actualHeight = computed.boxSizing === 'content-box' ? Math.round(parseFloat(computed.height)) : ta.offsetHeight; 6905 6906 // The actual height not matching the style height (set via the resize method) indicates that 6907 // the max-height has been exceeded, in which case the overflow should be allowed. 6908 if (actualHeight < styleHeight) { 6909 if (computed.overflowY === 'hidden') { 6910 changeOverflow('scroll'); 6911 resize(); 6912 actualHeight = computed.boxSizing === 'content-box' ? Math.round(parseFloat(window.getComputedStyle(ta, null).height)) : ta.offsetHeight; 6913 } 6914 } else { 6915 // Normally keep overflow set to hidden, to avoid flash of scrollbar as the textarea expands. 6916 if (computed.overflowY !== 'hidden') { 6917 changeOverflow('hidden'); 6918 resize(); 6919 actualHeight = computed.boxSizing === 'content-box' ? Math.round(parseFloat(window.getComputedStyle(ta, null).height)) : ta.offsetHeight; 6920 } 6921 } 6922 6923 if (cachedHeight !== actualHeight) { 6924 cachedHeight = actualHeight; 6925 var evt = createEvent('autosize:resized'); 6926 try { 6927 ta.dispatchEvent(evt); 6928 } catch (err) { 6929 // Firefox will throw an error on dispatchEvent for a detached element 6930 // https://bugzilla.mozilla.org/show_bug.cgi?id=889376 6931 } 6932 } 6933 } 6934 6935 var pageResize = function pageResize() { 6936 if (ta.clientWidth !== clientWidth) { 6937 update(); 6938 } 6939 }; 6940 6941 var destroy = function (style) { 6942 window.removeEventListener('resize', pageResize, false); 6943 ta.removeEventListener('input', update, false); 6944 ta.removeEventListener('keyup', update, false); 6945 ta.removeEventListener('autosize:destroy', destroy, false); 6946 ta.removeEventListener('autosize:update', update, false); 6947 6948 Object.keys(style).forEach(function (key) { 6949 ta.style[key] = style[key]; 6950 }); 6951 6952 map.delete(ta); 6953 }.bind(ta, { 6954 height: ta.style.height, 6955 resize: ta.style.resize, 6956 overflowY: ta.style.overflowY, 6957 overflowX: ta.style.overflowX, 6958 wordWrap: ta.style.wordWrap 6959 }); 6960 6961 ta.addEventListener('autosize:destroy', destroy, false); 6962 6963 // IE9 does not fire onpropertychange or oninput for deletions, 6964 // so binding to onkeyup to catch most of those events. 6965 // There is no way that I know of to detect something like 'cut' in IE9. 6966 if ('onpropertychange' in ta && 'oninput' in ta) { 6967 ta.addEventListener('keyup', update, false); 6968 } 6969 6970 window.addEventListener('resize', pageResize, false); 6971 ta.addEventListener('input', update, false); 6972 ta.addEventListener('autosize:update', update, false); 6973 ta.style.overflowX = 'hidden'; 6974 ta.style.wordWrap = 'break-word'; 6975 6976 map.set(ta, { 6977 destroy: destroy, 6978 update: update 6979 }); 6980 6981 init(); 6982 } 6983 6984 function destroy(ta) { 6985 var methods = map.get(ta); 6986 if (methods) { 6987 methods.destroy(); 6988 } 6989 } 6990 6991 function update(ta) { 6992 var methods = map.get(ta); 6993 if (methods) { 6994 methods.update(); 6995 } 6996 } 6997 6998 var autosize = null; 6999 7000 // Do nothing in Node.js environment and IE8 (or lower) 7001 if (typeof window === 'undefined' || typeof window.getComputedStyle !== 'function') { 7002 autosize = function autosize(el) { 7003 return el; 7004 }; 7005 autosize.destroy = function (el) { 7006 return el; 7007 }; 7008 autosize.update = function (el) { 7009 return el; 7010 }; 7011 } else { 7012 autosize = function autosize(el, options) { 7013 if (el) { 7014 Array.prototype.forEach.call(el.length ? el : [el], function (x) { 7015 return assign(x, options); 7016 }); 7017 } 7018 return el; 7019 }; 7020 autosize.destroy = function (el) { 7021 if (el) { 7022 Array.prototype.forEach.call(el.length ? el : [el], destroy); 7023 } 7024 return el; 7025 }; 7026 autosize.update = function (el) { 7027 if (el) { 7028 Array.prototype.forEach.call(el.length ? el : [el], update); 7029 } 7030 return el; 7031 }; 7032 } 7033 7034 exports.default = autosize; 7035 module.exports = exports['default']; 7036 }); 7037 7038 /***/ }), 7039 7040 /***/ 5755: 7041 /***/ ((module, exports) => { 7042 7043 var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*! 7044 Copyright (c) 2018 Jed Watson. 7045 Licensed under the MIT License (MIT), see 7046 http://jedwatson.github.io/classnames 7047 */ 7048 /* global define */ 7049 7050 (function () { 7051 'use strict'; 7052 7053 var hasOwn = {}.hasOwnProperty; 7054 var nativeCodeString = '[native code]'; 7055 7056 function classNames() { 7057 var classes = []; 7058 7059 for (var i = 0; i < arguments.length; i++) { 7060 var arg = arguments[i]; 7061 if (!arg) continue; 7062 7063 var argType = typeof arg; 7064 7065 if (argType === 'string' || argType === 'number') { 7066 classes.push(arg); 7067 } else if (Array.isArray(arg)) { 7068 if (arg.length) { 7069 var inner = classNames.apply(null, arg); 7070 if (inner) { 7071 classes.push(inner); 7072 } 7073 } 7074 } else if (argType === 'object') { 7075 if (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes('[native code]')) { 7076 classes.push(arg.toString()); 7077 continue; 7078 } 7079 7080 for (var key in arg) { 7081 if (hasOwn.call(arg, key) && arg[key]) { 7082 classes.push(key); 7083 } 7084 } 7085 } 7086 } 7087 7088 return classes.join(' '); 7089 } 7090 7091 if ( true && module.exports) { 7092 classNames.default = classNames; 7093 module.exports = classNames; 7094 } else if (true) { 7095 // register as 'classnames', consistent with npm package name 7096 !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = (function () { 7097 return classNames; 7098 }).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__), 7099 __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); 7100 } else {} 7101 }()); 7102 7103 7104 /***/ }), 7105 7106 /***/ 6109: 7107 /***/ ((module) => { 7108 7109 // This code has been refactored for 140 bytes 7110 // You can see the original here: https://github.com/twolfson/computedStyle/blob/04cd1da2e30fa45844f95f5cb1ac898e9b9ef050/lib/computedStyle.js 7111 var computedStyle = function (el, prop, getComputedStyle) { 7112 getComputedStyle = window.getComputedStyle; 7113 7114 // In one fell swoop 7115 return ( 7116 // If we have getComputedStyle 7117 getComputedStyle ? 7118 // Query it 7119 // TODO: From CSS-Query notes, we might need (node, null) for FF 7120 getComputedStyle(el) : 7121 7122 // Otherwise, we are in IE and use currentStyle 7123 el.currentStyle 7124 )[ 7125 // Switch to camelCase for CSSOM 7126 // DEV: Grabbed from jQuery 7127 // https://github.com/jquery/jquery/blob/1.9-stable/src/css.js#L191-L194 7128 // https://github.com/jquery/jquery/blob/1.9-stable/src/core.js#L593-L597 7129 prop.replace(/-(\w)/gi, function (word, letter) { 7130 return letter.toUpperCase(); 7131 }) 7132 ]; 7133 }; 7134 7135 module.exports = computedStyle; 7136 7137 7138 /***/ }), 7139 7140 /***/ 66: 7141 /***/ ((module) => { 7142 7143 "use strict"; 7144 7145 7146 var isMergeableObject = function isMergeableObject(value) { 7147 return isNonNullObject(value) 7148 && !isSpecial(value) 7149 }; 7150 7151 function isNonNullObject(value) { 7152 return !!value && typeof value === 'object' 7153 } 7154 7155 function isSpecial(value) { 7156 var stringValue = Object.prototype.toString.call(value); 7157 7158 return stringValue === '[object RegExp]' 7159 || stringValue === '[object Date]' 7160 || isReactElement(value) 7161 } 7162 7163 // see https://github.com/facebook/react/blob/b5ac963fb791d1298e7f396236383bc955f916c1/src/isomorphic/classic/element/ReactElement.js#L21-L25 7164 var canUseSymbol = typeof Symbol === 'function' && Symbol.for; 7165 var REACT_ELEMENT_TYPE = canUseSymbol ? Symbol.for('react.element') : 0xeac7; 7166 7167 function isReactElement(value) { 7168 return value.$$typeof === REACT_ELEMENT_TYPE 7169 } 7170 7171 function emptyTarget(val) { 7172 return Array.isArray(val) ? [] : {} 7173 } 7174 7175 function cloneUnlessOtherwiseSpecified(value, options) { 7176 return (options.clone !== false && options.isMergeableObject(value)) 7177 ? deepmerge(emptyTarget(value), value, options) 7178 : value 7179 } 7180 7181 function defaultArrayMerge(target, source, options) { 7182 return target.concat(source).map(function(element) { 7183 return cloneUnlessOtherwiseSpecified(element, options) 7184 }) 7185 } 7186 7187 function getMergeFunction(key, options) { 7188 if (!options.customMerge) { 7189 return deepmerge 7190 } 7191 var customMerge = options.customMerge(key); 7192 return typeof customMerge === 'function' ? customMerge : deepmerge 7193 } 7194 7195 function getEnumerableOwnPropertySymbols(target) { 7196 return Object.getOwnPropertySymbols 7197 ? Object.getOwnPropertySymbols(target).filter(function(symbol) { 7198 return Object.propertyIsEnumerable.call(target, symbol) 7199 }) 7200 : [] 7201 } 7202 7203 function getKeys(target) { 7204 return Object.keys(target).concat(getEnumerableOwnPropertySymbols(target)) 7205 } 7206 7207 function propertyIsOnObject(object, property) { 7208 try { 7209 return property in object 7210 } catch(_) { 7211 return false 7212 } 7213 } 7214 7215 // Protects from prototype poisoning and unexpected merging up the prototype chain. 7216 function propertyIsUnsafe(target, key) { 7217 return propertyIsOnObject(target, key) // Properties are safe to merge if they don't exist in the target yet, 7218 && !(Object.hasOwnProperty.call(target, key) // unsafe if they exist up the prototype chain, 7219 && Object.propertyIsEnumerable.call(target, key)) // and also unsafe if they're nonenumerable. 7220 } 7221 7222 function mergeObject(target, source, options) { 7223 var destination = {}; 7224 if (options.isMergeableObject(target)) { 7225 getKeys(target).forEach(function(key) { 7226 destination[key] = cloneUnlessOtherwiseSpecified(target[key], options); 7227 }); 7228 } 7229 getKeys(source).forEach(function(key) { 7230 if (propertyIsUnsafe(target, key)) { 7231 return 7232 } 7233 7234 if (propertyIsOnObject(target, key) && options.isMergeableObject(source[key])) { 7235 destination[key] = getMergeFunction(key, options)(target[key], source[key], options); 7236 } else { 7237 destination[key] = cloneUnlessOtherwiseSpecified(source[key], options); 7238 } 7239 }); 7240 return destination 7241 } 7242 7243 function deepmerge(target, source, options) { 7244 options = options || {}; 7245 options.arrayMerge = options.arrayMerge || defaultArrayMerge; 7246 options.isMergeableObject = options.isMergeableObject || isMergeableObject; 7247 // cloneUnlessOtherwiseSpecified is added to `options` so that custom arrayMerge() 7248 // implementations can use it. The caller may not replace it. 7249 options.cloneUnlessOtherwiseSpecified = cloneUnlessOtherwiseSpecified; 7250 7251 var sourceIsArray = Array.isArray(source); 7252 var targetIsArray = Array.isArray(target); 7253 var sourceAndTargetTypesMatch = sourceIsArray === targetIsArray; 7254 7255 if (!sourceAndTargetTypesMatch) { 7256 return cloneUnlessOtherwiseSpecified(source, options) 7257 } else if (sourceIsArray) { 7258 return options.arrayMerge(target, source, options) 7259 } else { 7260 return mergeObject(target, source, options) 7261 } 7262 } 7263 7264 deepmerge.all = function deepmergeAll(array, options) { 7265 if (!Array.isArray(array)) { 7266 throw new Error('first argument should be an array') 7267 } 7268 7269 return array.reduce(function(prev, next) { 7270 return deepmerge(prev, next, options) 7271 }, {}) 7272 }; 7273 7274 var deepmerge_1 = deepmerge; 7275 7276 module.exports = deepmerge_1; 7277 7278 7279 /***/ }), 7280 7281 /***/ 461: 7282 /***/ ((module, __unused_webpack_exports, __webpack_require__) => { 7283 7284 // Load in dependencies 7285 var computedStyle = __webpack_require__(6109); 7286 7287 /** 7288 * Calculate the `line-height` of a given node 7289 * @param {HTMLElement} node Element to calculate line height of. Must be in the DOM. 7290 * @returns {Number} `line-height` of the element in pixels 7291 */ 7292 function lineHeight(node) { 7293 // Grab the line-height via style 7294 var lnHeightStr = computedStyle(node, 'line-height'); 7295 var lnHeight = parseFloat(lnHeightStr, 10); 7296 7297 // If the lineHeight did not contain a unit (i.e. it was numeric), convert it to ems (e.g. '2.3' === '2.3em') 7298 if (lnHeightStr === lnHeight + '') { 7299 // Save the old lineHeight style and update the em unit to the element 7300 var _lnHeightStyle = node.style.lineHeight; 7301 node.style.lineHeight = lnHeightStr + 'em'; 7302 7303 // Calculate the em based height 7304 lnHeightStr = computedStyle(node, 'line-height'); 7305 lnHeight = parseFloat(lnHeightStr, 10); 7306 7307 // Revert the lineHeight style 7308 if (_lnHeightStyle) { 7309 node.style.lineHeight = _lnHeightStyle; 7310 } else { 7311 delete node.style.lineHeight; 7312 } 7313 } 7314 7315 // If the lineHeight is in `pt`, convert it to pixels (4px for 3pt) 7316 // DEV: `em` units are converted to `pt` in IE6 7317 // Conversion ratio from https://developer.mozilla.org/en-US/docs/Web/CSS/length 7318 if (lnHeightStr.indexOf('pt') !== -1) { 7319 lnHeight *= 4; 7320 lnHeight /= 3; 7321 // Otherwise, if the lineHeight is in `mm`, convert it to pixels (96px for 25.4mm) 7322 } else if (lnHeightStr.indexOf('mm') !== -1) { 7323 lnHeight *= 96; 7324 lnHeight /= 25.4; 7325 // Otherwise, if the lineHeight is in `cm`, convert it to pixels (96px for 2.54cm) 7326 } else if (lnHeightStr.indexOf('cm') !== -1) { 7327 lnHeight *= 96; 7328 lnHeight /= 2.54; 7329 // Otherwise, if the lineHeight is in `in`, convert it to pixels (96px for 1in) 7330 } else if (lnHeightStr.indexOf('in') !== -1) { 7331 lnHeight *= 96; 7332 // Otherwise, if the lineHeight is in `pc`, convert it to pixels (12pt for 1pc) 7333 } else if (lnHeightStr.indexOf('pc') !== -1) { 7334 lnHeight *= 16; 7335 } 7336 7337 // Continue our computation 7338 lnHeight = Math.round(lnHeight); 7339 7340 // If the line-height is "normal", calculate by font-size 7341 if (lnHeightStr === 'normal') { 7342 // Create a temporary node 7343 var nodeName = node.nodeName; 7344 var _node = document.createElement(nodeName); 7345 _node.innerHTML = ' '; 7346 7347 // If we have a text area, reset it to only 1 row 7348 // https://github.com/twolfson/line-height/issues/4 7349 if (nodeName.toUpperCase() === 'TEXTAREA') { 7350 _node.setAttribute('rows', '1'); 7351 } 7352 7353 // Set the font-size of the element 7354 var fontSizeStr = computedStyle(node, 'font-size'); 7355 _node.style.fontSize = fontSizeStr; 7356 7357 // Remove default padding/border which can affect offset height 7358 // https://github.com/twolfson/line-height/issues/4 7359 // https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/offsetHeight 7360 _node.style.padding = '0px'; 7361 _node.style.border = '0px'; 7362 7363 // Append it to the body 7364 var body = document.body; 7365 body.appendChild(_node); 7366 7367 // Assume the line height of the element is the height 7368 var height = _node.offsetHeight; 7369 lnHeight = height; 7370 7371 // Remove our child from the DOM 7372 body.removeChild(_node); 7373 } 7374 7375 // Return the calculated height 7376 return lnHeight; 7377 } 7378 7379 // Export lineHeight 7380 module.exports = lineHeight; 7381 7382 7383 /***/ }), 7384 7385 /***/ 628: 7386 /***/ ((module, __unused_webpack_exports, __webpack_require__) => { 7387 7388 "use strict"; 7389 /** 7390 * Copyright (c) 2013-present, Facebook, Inc. 7391 * 7392 * This source code is licensed under the MIT license found in the 7393 * LICENSE file in the root directory of this source tree. 7394 */ 7395 7396 7397 7398 var ReactPropTypesSecret = __webpack_require__(4067); 7399 7400 function emptyFunction() {} 7401 function emptyFunctionWithReset() {} 7402 emptyFunctionWithReset.resetWarningCache = emptyFunction; 7403 7404 module.exports = function() { 7405 function shim(props, propName, componentName, location, propFullName, secret) { 7406 if (secret === ReactPropTypesSecret) { 7407 // It is still safe when called from React. 7408 return; 7409 } 7410 var err = new Error( 7411 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' + 7412 'Use PropTypes.checkPropTypes() to call them. ' + 7413 'Read more at http://fb.me/use-check-prop-types' 7414 ); 7415 err.name = 'Invariant Violation'; 7416 throw err; 7417 }; 7418 shim.isRequired = shim; 7419 function getShim() { 7420 return shim; 7421 }; 7422 // Important! 7423 // Keep this list in sync with production version in `./factoryWithTypeCheckers.js`. 7424 var ReactPropTypes = { 7425 array: shim, 7426 bigint: shim, 7427 bool: shim, 7428 func: shim, 7429 number: shim, 7430 object: shim, 7431 string: shim, 7432 symbol: shim, 7433 7434 any: shim, 7435 arrayOf: getShim, 7436 element: shim, 7437 elementType: shim, 7438 instanceOf: getShim, 7439 node: shim, 7440 objectOf: getShim, 7441 oneOf: getShim, 7442 oneOfType: getShim, 7443 shape: getShim, 7444 exact: getShim, 7445 7446 checkPropTypes: emptyFunctionWithReset, 7447 resetWarningCache: emptyFunction 7448 }; 7449 7450 ReactPropTypes.PropTypes = ReactPropTypes; 7451 7452 return ReactPropTypes; 7453 }; 7454 7455 7456 /***/ }), 7457 7458 /***/ 5826: 7459 /***/ ((module, __unused_webpack_exports, __webpack_require__) => { 7460 7461 /** 7462 * Copyright (c) 2013-present, Facebook, Inc. 7463 * 7464 * This source code is licensed under the MIT license found in the 7465 * LICENSE file in the root directory of this source tree. 7466 */ 7467 7468 if (false) { var throwOnDirectAccess, ReactIs; } else { 7469 // By explicitly using `prop-types` you are opting into new production behavior. 7470 // http://fb.me/prop-types-in-prod 7471 module.exports = __webpack_require__(628)(); 7472 } 7473 7474 7475 /***/ }), 7476 7477 /***/ 4067: 7478 /***/ ((module) => { 7479 7480 "use strict"; 7481 /** 7482 * Copyright (c) 2013-present, Facebook, Inc. 7483 * 7484 * This source code is licensed under the MIT license found in the 7485 * LICENSE file in the root directory of this source tree. 7486 */ 7487 7488 7489 7490 var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED'; 7491 7492 module.exports = ReactPropTypesSecret; 7493 7494 7495 /***/ }), 7496 7497 /***/ 4462: 7498 /***/ (function(__unused_webpack_module, exports, __webpack_require__) { 7499 7500 "use strict"; 7501 7502 var __extends = (this && this.__extends) || (function () { 7503 var extendStatics = Object.setPrototypeOf || 7504 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || 7505 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; 7506 return function (d, b) { 7507 extendStatics(d, b); 7508 function __() { this.constructor = d; } 7509 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); 7510 }; 7511 })(); 7512 var __assign = (this && this.__assign) || Object.assign || function(t) { 7513 for (var s, i = 1, n = arguments.length; i < n; i++) { 7514 s = arguments[i]; 7515 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) 7516 t[p] = s[p]; 7517 } 7518 return t; 7519 }; 7520 var __rest = (this && this.__rest) || function (s, e) { 7521 var t = {}; 7522 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) 7523 t[p] = s[p]; 7524 if (s != null && typeof Object.getOwnPropertySymbols === "function") 7525 for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0) 7526 t[p[i]] = s[p[i]]; 7527 return t; 7528 }; 7529 exports.__esModule = true; 7530 var React = __webpack_require__(1609); 7531 var PropTypes = __webpack_require__(5826); 7532 var autosize = __webpack_require__(4306); 7533 var _getLineHeight = __webpack_require__(461); 7534 var getLineHeight = _getLineHeight; 7535 var RESIZED = "autosize:resized"; 7536 /** 7537 * A light replacement for built-in textarea component 7538 * which automaticaly adjusts its height to match the content 7539 */ 7540 var TextareaAutosizeClass = /** @class */ (function (_super) { 7541 __extends(TextareaAutosizeClass, _super); 7542 function TextareaAutosizeClass() { 7543 var _this = _super !== null && _super.apply(this, arguments) || this; 7544 _this.state = { 7545 lineHeight: null 7546 }; 7547 _this.textarea = null; 7548 _this.onResize = function (e) { 7549 if (_this.props.onResize) { 7550 _this.props.onResize(e); 7551 } 7552 }; 7553 _this.updateLineHeight = function () { 7554 if (_this.textarea) { 7555 _this.setState({ 7556 lineHeight: getLineHeight(_this.textarea) 7557 }); 7558 } 7559 }; 7560 _this.onChange = function (e) { 7561 var onChange = _this.props.onChange; 7562 _this.currentValue = e.currentTarget.value; 7563 onChange && onChange(e); 7564 }; 7565 return _this; 7566 } 7567 TextareaAutosizeClass.prototype.componentDidMount = function () { 7568 var _this = this; 7569 var _a = this.props, maxRows = _a.maxRows, async = _a.async; 7570 if (typeof maxRows === "number") { 7571 this.updateLineHeight(); 7572 } 7573 if (typeof maxRows === "number" || async) { 7574 /* 7575 the defer is needed to: 7576 - force "autosize" to activate the scrollbar when this.props.maxRows is passed 7577 - support StyledComponents (see #71) 7578 */ 7579 setTimeout(function () { return _this.textarea && autosize(_this.textarea); }); 7580 } 7581 else { 7582 this.textarea && autosize(this.textarea); 7583 } 7584 if (this.textarea) { 7585 this.textarea.addEventListener(RESIZED, this.onResize); 7586 } 7587 }; 7588 TextareaAutosizeClass.prototype.componentWillUnmount = function () { 7589 if (this.textarea) { 7590 this.textarea.removeEventListener(RESIZED, this.onResize); 7591 autosize.destroy(this.textarea); 7592 } 7593 }; 7594 TextareaAutosizeClass.prototype.render = function () { 7595 var _this = this; 7596 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; 7597 var maxHeight = maxRows && lineHeight ? lineHeight * maxRows : null; 7598 return (React.createElement("textarea", __assign({}, props, { onChange: this.onChange, style: maxHeight ? __assign({}, style, { maxHeight: maxHeight }) : style, ref: function (element) { 7599 _this.textarea = element; 7600 if (typeof _this.props.innerRef === 'function') { 7601 _this.props.innerRef(element); 7602 } 7603 else if (_this.props.innerRef) { 7604 _this.props.innerRef.current = element; 7605 } 7606 } }), children)); 7607 }; 7608 TextareaAutosizeClass.prototype.componentDidUpdate = function () { 7609 this.textarea && autosize.update(this.textarea); 7610 }; 7611 TextareaAutosizeClass.defaultProps = { 7612 rows: 1, 7613 async: false 7614 }; 7615 TextareaAutosizeClass.propTypes = { 7616 rows: PropTypes.number, 7617 maxRows: PropTypes.number, 7618 onResize: PropTypes.func, 7619 innerRef: PropTypes.any, 7620 async: PropTypes.bool 7621 }; 7622 return TextareaAutosizeClass; 7623 }(React.Component)); 7624 exports.TextareaAutosize = React.forwardRef(function (props, ref) { 7625 return React.createElement(TextareaAutosizeClass, __assign({}, props, { innerRef: ref })); 7626 }); 7627 7628 7629 /***/ }), 7630 7631 /***/ 4132: 7632 /***/ ((__unused_webpack_module, exports, __webpack_require__) => { 7633 7634 "use strict"; 7635 var __webpack_unused_export__; 7636 7637 __webpack_unused_export__ = true; 7638 var TextareaAutosize_1 = __webpack_require__(4462); 7639 exports.A = TextareaAutosize_1.TextareaAutosize; 7640 7641 7642 /***/ }), 7643 7644 /***/ 3394: 7645 /***/ ((__unused_webpack_module, exports, __webpack_require__) => { 7646 7647 "use strict"; 7648 var __webpack_unused_export__; 7649 /** 7650 * @license React 7651 * react-jsx-runtime.production.min.js 7652 * 7653 * Copyright (c) Facebook, Inc. and its affiliates. 7654 * 7655 * This source code is licensed under the MIT license found in the 7656 * LICENSE file in the root directory of this source tree. 7657 */ 7658 var f=__webpack_require__(1609),k=Symbol.for("react.element"),l=Symbol.for("react.fragment"),m=Object.prototype.hasOwnProperty,n=f.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,p={key:!0,ref:!0,__self:!0,__source:!0}; 7659 function q(c,a,g){var b,d={},e=null,h=null;void 0!==g&&(e=""+g);void 0!==a.key&&(e=""+a.key);void 0!==a.ref&&(h=a.ref);for(b in a)m.call(a,b)&&!p.hasOwnProperty(b)&&(d[b]=a[b]);if(c&&c.defaultProps)for(b in a=c.defaultProps,a)void 0===d[b]&&(d[b]=a[b]);return{$$typeof:k,type:c,key:e,ref:h,props:d,_owner:n.current}}__webpack_unused_export__=l;exports.jsx=q;__webpack_unused_export__=q; 7660 7661 7662 /***/ }), 7663 7664 /***/ 4922: 7665 /***/ ((module, __unused_webpack_exports, __webpack_require__) => { 7666 7667 "use strict"; 7668 7669 7670 if (true) { 7671 module.exports = __webpack_require__(3394); 7672 } else {} 7673 7674 7675 /***/ }), 7676 7677 /***/ 9681: 7678 /***/ ((module) => { 7679 7680 var characterMap = { 7681 "À": "A", 7682 "Á": "A", 7683 "Â": "A", 7684 "Ã": "A", 7685 "Ä": "A", 7686 "Å": "A", 7687 "Ấ": "A", 7688 "Ắ": "A", 7689 "Ẳ": "A", 7690 "Ẵ": "A", 7691 "Ặ": "A", 7692 "Æ": "AE", 7693 "Ầ": "A", 7694 "Ằ": "A", 7695 "Ȃ": "A", 7696 "Ả": "A", 7697 "Ạ": "A", 7698 "Ẩ": "A", 7699 "Ẫ": "A", 7700 "Ậ": "A", 7701 "Ç": "C", 7702 "Ḉ": "C", 7703 "È": "E", 7704 "É": "E", 7705 "Ê": "E", 7706 "Ë": "E", 7707 "Ế": "E", 7708 "Ḗ": "E", 7709 "Ề": "E", 7710 "Ḕ": "E", 7711 "Ḝ": "E", 7712 "Ȇ": "E", 7713 "Ẻ": "E", 7714 "Ẽ": "E", 7715 "Ẹ": "E", 7716 "Ể": "E", 7717 "Ễ": "E", 7718 "Ệ": "E", 7719 "Ì": "I", 7720 "Í": "I", 7721 "Î": "I", 7722 "Ï": "I", 7723 "Ḯ": "I", 7724 "Ȋ": "I", 7725 "Ỉ": "I", 7726 "Ị": "I", 7727 "Ð": "D", 7728 "Ñ": "N", 7729 "Ò": "O", 7730 "Ó": "O", 7731 "Ô": "O", 7732 "Õ": "O", 7733 "Ö": "O", 7734 "Ø": "O", 7735 "Ố": "O", 7736 "Ṍ": "O", 7737 "Ṓ": "O", 7738 "Ȏ": "O", 7739 "Ỏ": "O", 7740 "Ọ": "O", 7741 "Ổ": "O", 7742 "Ỗ": "O", 7743 "Ộ": "O", 7744 "Ờ": "O", 7745 "Ở": "O", 7746 "Ỡ": "O", 7747 "Ớ": "O", 7748 "Ợ": "O", 7749 "Ù": "U", 7750 "Ú": "U", 7751 "Û": "U", 7752 "Ü": "U", 7753 "Ủ": "U", 7754 "Ụ": "U", 7755 "Ử": "U", 7756 "Ữ": "U", 7757 "Ự": "U", 7758 "Ý": "Y", 7759 "à": "a", 7760 "á": "a", 7761 "â": "a", 7762 "ã": "a", 7763 "ä": "a", 7764 "å": "a", 7765 "ấ": "a", 7766 "ắ": "a", 7767 "ẳ": "a", 7768 "ẵ": "a", 7769 "ặ": "a", 7770 "æ": "ae", 7771 "ầ": "a", 7772 "ằ": "a", 7773 "ȃ": "a", 7774 "ả": "a", 7775 "ạ": "a", 7776 "ẩ": "a", 7777 "ẫ": "a", 7778 "ậ": "a", 7779 "ç": "c", 7780 "ḉ": "c", 7781 "è": "e", 7782 "é": "e", 7783 "ê": "e", 7784 "ë": "e", 7785 "ế": "e", 7786 "ḗ": "e", 7787 "ề": "e", 7788 "ḕ": "e", 7789 "ḝ": "e", 7790 "ȇ": "e", 7791 "ẻ": "e", 7792 "ẽ": "e", 7793 "ẹ": "e", 7794 "ể": "e", 7795 "ễ": "e", 7796 "ệ": "e", 7797 "ì": "i", 7798 "í": "i", 7799 "î": "i", 7800 "ï": "i", 7801 "ḯ": "i", 7802 "ȋ": "i", 7803 "ỉ": "i", 7804 "ị": "i", 7805 "ð": "d", 7806 "ñ": "n", 7807 "ò": "o", 7808 "ó": "o", 7809 "ô": "o", 7810 "õ": "o", 7811 "ö": "o", 7812 "ø": "o", 7813 "ố": "o", 7814 "ṍ": "o", 7815 "ṓ": "o", 7816 "ȏ": "o", 7817 "ỏ": "o", 7818 "ọ": "o", 7819 "ổ": "o", 7820 "ỗ": "o", 7821 "ộ": "o", 7822 "ờ": "o", 7823 "ở": "o", 7824 "ỡ": "o", 7825 "ớ": "o", 7826 "ợ": "o", 7827 "ù": "u", 7828 "ú": "u", 7829 "û": "u", 7830 "ü": "u", 7831 "ủ": "u", 7832 "ụ": "u", 7833 "ử": "u", 7834 "ữ": "u", 7835 "ự": "u", 7836 "ý": "y", 7837 "ÿ": "y", 7838 "Ā": "A", 7839 "ā": "a", 7840 "Ă": "A", 7841 "ă": "a", 7842 "Ą": "A", 7843 "ą": "a", 7844 "Ć": "C", 7845 "ć": "c", 7846 "Ĉ": "C", 7847 "ĉ": "c", 7848 "Ċ": "C", 7849 "ċ": "c", 7850 "Č": "C", 7851 "č": "c", 7852 "C̆": "C", 7853 "c̆": "c", 7854 "Ď": "D", 7855 "ď": "d", 7856 "Đ": "D", 7857 "đ": "d", 7858 "Ē": "E", 7859 "ē": "e", 7860 "Ĕ": "E", 7861 "ĕ": "e", 7862 "Ė": "E", 7863 "ė": "e", 7864 "Ę": "E", 7865 "ę": "e", 7866 "Ě": "E", 7867 "ě": "e", 7868 "Ĝ": "G", 7869 "Ǵ": "G", 7870 "ĝ": "g", 7871 "ǵ": "g", 7872 "Ğ": "G", 7873 "ğ": "g", 7874 "Ġ": "G", 7875 "ġ": "g", 7876 "Ģ": "G", 7877 "ģ": "g", 7878 "Ĥ": "H", 7879 "ĥ": "h", 7880 "Ħ": "H", 7881 "ħ": "h", 7882 "Ḫ": "H", 7883 "ḫ": "h", 7884 "Ĩ": "I", 7885 "ĩ": "i", 7886 "Ī": "I", 7887 "ī": "i", 7888 "Ĭ": "I", 7889 "ĭ": "i", 7890 "Į": "I", 7891 "į": "i", 7892 "İ": "I", 7893 "ı": "i", 7894 "IJ": "IJ", 7895 "ij": "ij", 7896 "Ĵ": "J", 7897 "ĵ": "j", 7898 "Ķ": "K", 7899 "ķ": "k", 7900 "Ḱ": "K", 7901 "ḱ": "k", 7902 "K̆": "K", 7903 "k̆": "k", 7904 "Ĺ": "L", 7905 "ĺ": "l", 7906 "Ļ": "L", 7907 "ļ": "l", 7908 "Ľ": "L", 7909 "ľ": "l", 7910 "Ŀ": "L", 7911 "ŀ": "l", 7912 "Ł": "l", 7913 "ł": "l", 7914 "Ḿ": "M", 7915 "ḿ": "m", 7916 "M̆": "M", 7917 "m̆": "m", 7918 "Ń": "N", 7919 "ń": "n", 7920 "Ņ": "N", 7921 "ņ": "n", 7922 "Ň": "N", 7923 "ň": "n", 7924 "ʼn": "n", 7925 "N̆": "N", 7926 "n̆": "n", 7927 "Ō": "O", 7928 "ō": "o", 7929 "Ŏ": "O", 7930 "ŏ": "o", 7931 "Ő": "O", 7932 "ő": "o", 7933 "Œ": "OE", 7934 "œ": "oe", 7935 "P̆": "P", 7936 "p̆": "p", 7937 "Ŕ": "R", 7938 "ŕ": "r", 7939 "Ŗ": "R", 7940 "ŗ": "r", 7941 "Ř": "R", 7942 "ř": "r", 7943 "R̆": "R", 7944 "r̆": "r", 7945 "Ȓ": "R", 7946 "ȓ": "r", 7947 "Ś": "S", 7948 "ś": "s", 7949 "Ŝ": "S", 7950 "ŝ": "s", 7951 "Ş": "S", 7952 "Ș": "S", 7953 "ș": "s", 7954 "ş": "s", 7955 "Š": "S", 7956 "š": "s", 7957 "Ţ": "T", 7958 "ţ": "t", 7959 "ț": "t", 7960 "Ț": "T", 7961 "Ť": "T", 7962 "ť": "t", 7963 "Ŧ": "T", 7964 "ŧ": "t", 7965 "T̆": "T", 7966 "t̆": "t", 7967 "Ũ": "U", 7968 "ũ": "u", 7969 "Ū": "U", 7970 "ū": "u", 7971 "Ŭ": "U", 7972 "ŭ": "u", 7973 "Ů": "U", 7974 "ů": "u", 7975 "Ű": "U", 7976 "ű": "u", 7977 "Ų": "U", 7978 "ų": "u", 7979 "Ȗ": "U", 7980 "ȗ": "u", 7981 "V̆": "V", 7982 "v̆": "v", 7983 "Ŵ": "W", 7984 "ŵ": "w", 7985 "Ẃ": "W", 7986 "ẃ": "w", 7987 "X̆": "X", 7988 "x̆": "x", 7989 "Ŷ": "Y", 7990 "ŷ": "y", 7991 "Ÿ": "Y", 7992 "Y̆": "Y", 7993 "y̆": "y", 7994 "Ź": "Z", 7995 "ź": "z", 7996 "Ż": "Z", 7997 "ż": "z", 7998 "Ž": "Z", 7999 "ž": "z", 8000 "ſ": "s", 8001 "ƒ": "f", 8002 "Ơ": "O", 8003 "ơ": "o", 8004 "Ư": "U", 8005 "ư": "u", 8006 "Ǎ": "A", 8007 "ǎ": "a", 8008 "Ǐ": "I", 8009 "ǐ": "i", 8010 "Ǒ": "O", 8011 "ǒ": "o", 8012 "Ǔ": "U", 8013 "ǔ": "u", 8014 "Ǖ": "U", 8015 "ǖ": "u", 8016 "Ǘ": "U", 8017 "ǘ": "u", 8018 "Ǚ": "U", 8019 "ǚ": "u", 8020 "Ǜ": "U", 8021 "ǜ": "u", 8022 "Ứ": "U", 8023 "ứ": "u", 8024 "Ṹ": "U", 8025 "ṹ": "u", 8026 "Ǻ": "A", 8027 "ǻ": "a", 8028 "Ǽ": "AE", 8029 "ǽ": "ae", 8030 "Ǿ": "O", 8031 "ǿ": "o", 8032 "Þ": "TH", 8033 "þ": "th", 8034 "Ṕ": "P", 8035 "ṕ": "p", 8036 "Ṥ": "S", 8037 "ṥ": "s", 8038 "X́": "X", 8039 "x́": "x", 8040 "Ѓ": "Г", 8041 "ѓ": "г", 8042 "Ќ": "К", 8043 "ќ": "к", 8044 "A̋": "A", 8045 "a̋": "a", 8046 "E̋": "E", 8047 "e̋": "e", 8048 "I̋": "I", 8049 "i̋": "i", 8050 "Ǹ": "N", 8051 "ǹ": "n", 8052 "Ồ": "O", 8053 "ồ": "o", 8054 "Ṑ": "O", 8055 "ṑ": "o", 8056 "Ừ": "U", 8057 "ừ": "u", 8058 "Ẁ": "W", 8059 "ẁ": "w", 8060 "Ỳ": "Y", 8061 "ỳ": "y", 8062 "Ȁ": "A", 8063 "ȁ": "a", 8064 "Ȅ": "E", 8065 "ȅ": "e", 8066 "Ȉ": "I", 8067 "ȉ": "i", 8068 "Ȍ": "O", 8069 "ȍ": "o", 8070 "Ȑ": "R", 8071 "ȑ": "r", 8072 "Ȕ": "U", 8073 "ȕ": "u", 8074 "B̌": "B", 8075 "b̌": "b", 8076 "Č̣": "C", 8077 "č̣": "c", 8078 "Ê̌": "E", 8079 "ê̌": "e", 8080 "F̌": "F", 8081 "f̌": "f", 8082 "Ǧ": "G", 8083 "ǧ": "g", 8084 "Ȟ": "H", 8085 "ȟ": "h", 8086 "J̌": "J", 8087 "ǰ": "j", 8088 "Ǩ": "K", 8089 "ǩ": "k", 8090 "M̌": "M", 8091 "m̌": "m", 8092 "P̌": "P", 8093 "p̌": "p", 8094 "Q̌": "Q", 8095 "q̌": "q", 8096 "Ř̩": "R", 8097 "ř̩": "r", 8098 "Ṧ": "S", 8099 "ṧ": "s", 8100 "V̌": "V", 8101 "v̌": "v", 8102 "W̌": "W", 8103 "w̌": "w", 8104 "X̌": "X", 8105 "x̌": "x", 8106 "Y̌": "Y", 8107 "y̌": "y", 8108 "A̧": "A", 8109 "a̧": "a", 8110 "B̧": "B", 8111 "b̧": "b", 8112 "Ḑ": "D", 8113 "ḑ": "d", 8114 "Ȩ": "E", 8115 "ȩ": "e", 8116 "Ɛ̧": "E", 8117 "ɛ̧": "e", 8118 "Ḩ": "H", 8119 "ḩ": "h", 8120 "I̧": "I", 8121 "i̧": "i", 8122 "Ɨ̧": "I", 8123 "ɨ̧": "i", 8124 "M̧": "M", 8125 "m̧": "m", 8126 "O̧": "O", 8127 "o̧": "o", 8128 "Q̧": "Q", 8129 "q̧": "q", 8130 "U̧": "U", 8131 "u̧": "u", 8132 "X̧": "X", 8133 "x̧": "x", 8134 "Z̧": "Z", 8135 "z̧": "z", 8136 "й":"и", 8137 "Й":"И", 8138 "ё":"е", 8139 "Ё":"Е", 8140 }; 8141 8142 var chars = Object.keys(characterMap).join('|'); 8143 var allAccents = new RegExp(chars, 'g'); 8144 var firstAccent = new RegExp(chars, ''); 8145 8146 function matcher(match) { 8147 return characterMap[match]; 8148 } 8149 8150 var removeAccents = function(string) { 8151 return string.replace(allAccents, matcher); 8152 }; 8153 8154 var hasAccents = function(string) { 8155 return !!string.match(firstAccent); 8156 }; 8157 8158 module.exports = removeAccents; 8159 module.exports.has = hasAccents; 8160 module.exports.remove = removeAccents; 8161 8162 8163 /***/ }), 8164 8165 /***/ 8477: 8166 /***/ ((__unused_webpack_module, exports, __webpack_require__) => { 8167 8168 "use strict"; 8169 /** 8170 * @license React 8171 * use-sync-external-store-shim.production.min.js 8172 * 8173 * Copyright (c) Facebook, Inc. and its affiliates. 8174 * 8175 * This source code is licensed under the MIT license found in the 8176 * LICENSE file in the root directory of this source tree. 8177 */ 8178 var e=__webpack_require__(1609);function h(a,b){return a===b&&(0!==a||1/a===1/b)||a!==a&&b!==b}var k="function"===typeof Object.is?Object.is:h,l=e.useState,m=e.useEffect,n=e.useLayoutEffect,p=e.useDebugValue;function q(a,b){var d=b(),f=l({inst:{value:d,getSnapshot:b}}),c=f[0].inst,g=f[1];n(function(){c.value=d;c.getSnapshot=b;r(c)&&g({inst:c})},[a,d,b]);m(function(){r(c)&&g({inst:c});return a(function(){r(c)&&g({inst:c})})},[a]);p(d);return d} 8179 function r(a){var b=a.getSnapshot;a=a.value;try{var d=b();return!k(a,d)}catch(f){return!0}}function t(a,b){return b()}var u="undefined"===typeof window||"undefined"===typeof window.document||"undefined"===typeof window.document.createElement?t:q;exports.useSyncExternalStore=void 0!==e.useSyncExternalStore?e.useSyncExternalStore:u; 8180 8181 8182 /***/ }), 8183 8184 /***/ 422: 8185 /***/ ((module, __unused_webpack_exports, __webpack_require__) => { 8186 8187 "use strict"; 8188 8189 8190 if (true) { 8191 module.exports = __webpack_require__(8477); 8192 } else {} 8193 8194 8195 /***/ }), 8196 8197 /***/ 1609: 8198 /***/ ((module) => { 8199 8200 "use strict"; 8201 module.exports = window["React"]; 8202 8203 /***/ }) 8204 8205 /******/ }); 8206 /************************************************************************/ 8207 /******/ // The module cache 8208 /******/ var __webpack_module_cache__ = {}; 8209 /******/ 8210 /******/ // The require function 8211 /******/ function __webpack_require__(moduleId) { 8212 /******/ // Check if module is in cache 8213 /******/ var cachedModule = __webpack_module_cache__[moduleId]; 8214 /******/ if (cachedModule !== undefined) { 8215 /******/ return cachedModule.exports; 8216 /******/ } 8217 /******/ // Create a new module (and put it into the cache) 8218 /******/ var module = __webpack_module_cache__[moduleId] = { 8219 /******/ // no module.id needed 8220 /******/ // no module.loaded needed 8221 /******/ exports: {} 8222 /******/ }; 8223 /******/ 8224 /******/ // Execute the module function 8225 /******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__); 8226 /******/ 8227 /******/ // Return the exports of the module 8228 /******/ return module.exports; 8229 /******/ } 8230 /******/ 8231 /************************************************************************/ 8232 /******/ /* webpack/runtime/compat get default export */ 8233 /******/ (() => { 8234 /******/ // getDefaultExport function for compatibility with non-harmony modules 8235 /******/ __webpack_require__.n = (module) => { 8236 /******/ var getter = module && module.__esModule ? 8237 /******/ () => (module['default']) : 8238 /******/ () => (module); 8239 /******/ __webpack_require__.d(getter, { a: getter }); 8240 /******/ return getter; 8241 /******/ }; 8242 /******/ })(); 8243 /******/ 8244 /******/ /* webpack/runtime/create fake namespace object */ 8245 /******/ (() => { 8246 /******/ var getProto = Object.getPrototypeOf ? (obj) => (Object.getPrototypeOf(obj)) : (obj) => (obj.__proto__); 8247 /******/ var leafPrototypes; 8248 /******/ // create a fake namespace object 8249 /******/ // mode & 1: value is a module id, require it 8250 /******/ // mode & 2: merge all properties of value into the ns 8251 /******/ // mode & 4: return value when already ns object 8252 /******/ // mode & 16: return value when it's Promise-like 8253 /******/ // mode & 8|1: behave like require 8254 /******/ __webpack_require__.t = function(value, mode) { 8255 /******/ if(mode & 1) value = this(value); 8256 /******/ if(mode & 8) return value; 8257 /******/ if(typeof value === 'object' && value) { 8258 /******/ if((mode & 4) && value.__esModule) return value; 8259 /******/ if((mode & 16) && typeof value.then === 'function') return value; 8260 /******/ } 8261 /******/ var ns = Object.create(null); 8262 /******/ __webpack_require__.r(ns); 8263 /******/ var def = {}; 8264 /******/ leafPrototypes = leafPrototypes || [null, getProto({}), getProto([]), getProto(getProto)]; 8265 /******/ for(var current = mode & 2 && value; typeof current == 'object' && !~leafPrototypes.indexOf(current); current = getProto(current)) { 8266 /******/ Object.getOwnPropertyNames(current).forEach((key) => (def[key] = () => (value[key]))); 8267 /******/ } 8268 /******/ def['default'] = () => (value); 8269 /******/ __webpack_require__.d(ns, def); 8270 /******/ return ns; 8271 /******/ }; 8272 /******/ })(); 8273 /******/ 8274 /******/ /* webpack/runtime/define property getters */ 8275 /******/ (() => { 8276 /******/ // define getter functions for harmony exports 8277 /******/ __webpack_require__.d = (exports, definition) => { 8278 /******/ for(var key in definition) { 8279 /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { 8280 /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); 8281 /******/ } 8282 /******/ } 8283 /******/ }; 8284 /******/ })(); 8285 /******/ 8286 /******/ /* webpack/runtime/hasOwnProperty shorthand */ 8287 /******/ (() => { 8288 /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) 8289 /******/ })(); 8290 /******/ 8291 /******/ /* webpack/runtime/make namespace object */ 8292 /******/ (() => { 8293 /******/ // define __esModule on exports 8294 /******/ __webpack_require__.r = (exports) => { 8295 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { 8296 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); 8297 /******/ } 8298 /******/ Object.defineProperty(exports, '__esModule', { value: true }); 8299 /******/ }; 8300 /******/ })(); 8301 /******/ 8302 /************************************************************************/ 8303 var __webpack_exports__ = {}; 8304 // This entry need to be wrapped in an IIFE because it need to be in strict mode. 8305 (() => { 8306 "use strict"; 8307 // ESM COMPAT FLAG 8308 __webpack_require__.r(__webpack_exports__); 8309 8310 // EXPORTS 8311 __webpack_require__.d(__webpack_exports__, { 8312 PluginMoreMenuItem: () => (/* reexport */ plugin_more_menu_item), 8313 PluginSidebar: () => (/* reexport */ PluginSidebarEditSite), 8314 PluginSidebarMoreMenuItem: () => (/* reexport */ PluginSidebarMoreMenuItem), 8315 PluginTemplateSettingPanel: () => (/* reexport */ plugin_template_setting_panel), 8316 initializeEditor: () => (/* binding */ initializeEditor), 8317 reinitializeEditor: () => (/* binding */ reinitializeEditor), 8318 store: () => (/* reexport */ store_store) 8319 }); 8320 8321 // NAMESPACE OBJECT: ./node_modules/@wordpress/interface/build-module/store/actions.js 8322 var actions_namespaceObject = {}; 8323 __webpack_require__.r(actions_namespaceObject); 8324 __webpack_require__.d(actions_namespaceObject, { 8325 closeModal: () => (closeModal), 8326 disableComplementaryArea: () => (disableComplementaryArea), 8327 enableComplementaryArea: () => (enableComplementaryArea), 8328 openModal: () => (openModal), 8329 pinItem: () => (pinItem), 8330 setDefaultComplementaryArea: () => (setDefaultComplementaryArea), 8331 setFeatureDefaults: () => (setFeatureDefaults), 8332 setFeatureValue: () => (setFeatureValue), 8333 toggleFeature: () => (toggleFeature), 8334 unpinItem: () => (unpinItem) 8335 }); 8336 8337 // NAMESPACE OBJECT: ./node_modules/@wordpress/interface/build-module/store/selectors.js 8338 var selectors_namespaceObject = {}; 8339 __webpack_require__.r(selectors_namespaceObject); 8340 __webpack_require__.d(selectors_namespaceObject, { 8341 getActiveComplementaryArea: () => (getActiveComplementaryArea), 8342 isComplementaryAreaLoading: () => (isComplementaryAreaLoading), 8343 isFeatureActive: () => (isFeatureActive), 8344 isItemPinned: () => (isItemPinned), 8345 isModalActive: () => (isModalActive) 8346 }); 8347 8348 // NAMESPACE OBJECT: ./node_modules/@wordpress/edit-site/build-module/store/private-actions.js 8349 var private_actions_namespaceObject = {}; 8350 __webpack_require__.r(private_actions_namespaceObject); 8351 __webpack_require__.d(private_actions_namespaceObject, { 8352 removeTemplates: () => (removeTemplates), 8353 setCanvasMode: () => (setCanvasMode), 8354 setEditorCanvasContainerView: () => (setEditorCanvasContainerView) 8355 }); 8356 8357 // NAMESPACE OBJECT: ./node_modules/@wordpress/edit-site/build-module/store/actions.js 8358 var store_actions_namespaceObject = {}; 8359 __webpack_require__.r(store_actions_namespaceObject); 8360 __webpack_require__.d(store_actions_namespaceObject, { 8361 __experimentalSetPreviewDeviceType: () => (__experimentalSetPreviewDeviceType), 8362 addTemplate: () => (addTemplate), 8363 closeGeneralSidebar: () => (closeGeneralSidebar), 8364 openGeneralSidebar: () => (openGeneralSidebar), 8365 openNavigationPanelToMenu: () => (openNavigationPanelToMenu), 8366 removeTemplate: () => (removeTemplate), 8367 revertTemplate: () => (revertTemplate), 8368 setEditedEntity: () => (setEditedEntity), 8369 setEditedPostContext: () => (setEditedPostContext), 8370 setHasPageContentFocus: () => (setHasPageContentFocus), 8371 setHomeTemplateId: () => (setHomeTemplateId), 8372 setIsInserterOpened: () => (setIsInserterOpened), 8373 setIsListViewOpened: () => (setIsListViewOpened), 8374 setIsNavigationPanelOpened: () => (setIsNavigationPanelOpened), 8375 setIsSaveViewOpened: () => (setIsSaveViewOpened), 8376 setNavigationMenu: () => (setNavigationMenu), 8377 setNavigationPanelActiveMenu: () => (setNavigationPanelActiveMenu), 8378 setPage: () => (setPage), 8379 setTemplate: () => (setTemplate), 8380 setTemplatePart: () => (setTemplatePart), 8381 switchEditorMode: () => (switchEditorMode), 8382 toggleDistractionFree: () => (toggleDistractionFree), 8383 toggleFeature: () => (actions_toggleFeature), 8384 updateSettings: () => (updateSettings) 8385 }); 8386 8387 // NAMESPACE OBJECT: ./node_modules/@wordpress/edit-site/build-module/store/selectors.js 8388 var store_selectors_namespaceObject = {}; 8389 __webpack_require__.r(store_selectors_namespaceObject); 8390 __webpack_require__.d(store_selectors_namespaceObject, { 8391 __experimentalGetInsertionPoint: () => (__experimentalGetInsertionPoint), 8392 __experimentalGetPreviewDeviceType: () => (__experimentalGetPreviewDeviceType), 8393 getCanUserCreateMedia: () => (getCanUserCreateMedia), 8394 getCurrentTemplateNavigationPanelSubMenu: () => (getCurrentTemplateNavigationPanelSubMenu), 8395 getCurrentTemplateTemplateParts: () => (getCurrentTemplateTemplateParts), 8396 getEditedPostContext: () => (getEditedPostContext), 8397 getEditedPostId: () => (getEditedPostId), 8398 getEditedPostType: () => (getEditedPostType), 8399 getEditorMode: () => (getEditorMode), 8400 getHomeTemplateId: () => (getHomeTemplateId), 8401 getNavigationPanelActiveMenu: () => (getNavigationPanelActiveMenu), 8402 getPage: () => (getPage), 8403 getReusableBlocks: () => (getReusableBlocks), 8404 getSettings: () => (getSettings), 8405 hasPageContentFocus: () => (hasPageContentFocus), 8406 isFeatureActive: () => (selectors_isFeatureActive), 8407 isInserterOpened: () => (isInserterOpened), 8408 isListViewOpened: () => (isListViewOpened), 8409 isNavigationOpened: () => (isNavigationOpened), 8410 isPage: () => (isPage), 8411 isSaveViewOpened: () => (isSaveViewOpened) 8412 }); 8413 8414 // NAMESPACE OBJECT: ./node_modules/@wordpress/edit-site/build-module/store/private-selectors.js 8415 var private_selectors_namespaceObject = {}; 8416 __webpack_require__.r(private_selectors_namespaceObject); 8417 __webpack_require__.d(private_selectors_namespaceObject, { 8418 getCanvasMode: () => (getCanvasMode), 8419 getEditorCanvasContainerView: () => (getEditorCanvasContainerView) 8420 }); 8421 8422 // EXTERNAL MODULE: external "React" 8423 var external_React_ = __webpack_require__(1609); 8424 var external_React_namespaceObject = /*#__PURE__*/__webpack_require__.t(external_React_, 2); 8425 ;// CONCATENATED MODULE: external ["wp","blocks"] 8426 const external_wp_blocks_namespaceObject = window["wp"]["blocks"]; 8427 ;// CONCATENATED MODULE: external ["wp","blockLibrary"] 8428 const external_wp_blockLibrary_namespaceObject = window["wp"]["blockLibrary"]; 8429 ;// CONCATENATED MODULE: external ["wp","data"] 8430 const external_wp_data_namespaceObject = window["wp"]["data"]; 8431 ;// CONCATENATED MODULE: external ["wp","deprecated"] 8432 const external_wp_deprecated_namespaceObject = window["wp"]["deprecated"]; 8433 var external_wp_deprecated_default = /*#__PURE__*/__webpack_require__.n(external_wp_deprecated_namespaceObject); 8434 ;// CONCATENATED MODULE: external ["wp","element"] 8435 const external_wp_element_namespaceObject = window["wp"]["element"]; 8436 ;// CONCATENATED MODULE: external ["wp","editor"] 8437 const external_wp_editor_namespaceObject = window["wp"]["editor"]; 8438 // EXTERNAL MODULE: ./node_modules/classnames/index.js 8439 var classnames = __webpack_require__(5755); 8440 var classnames_default = /*#__PURE__*/__webpack_require__.n(classnames); 8441 ;// CONCATENATED MODULE: external ["wp","components"] 8442 const external_wp_components_namespaceObject = window["wp"]["components"]; 8443 ;// CONCATENATED MODULE: external ["wp","i18n"] 8444 const external_wp_i18n_namespaceObject = window["wp"]["i18n"]; 8445 ;// CONCATENATED MODULE: external ["wp","primitives"] 8446 const external_wp_primitives_namespaceObject = window["wp"]["primitives"]; 8447 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/check.js 8448 8449 /** 8450 * WordPress dependencies 8451 */ 8452 8453 const check = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { 8454 xmlns: "http://www.w3.org/2000/svg", 8455 viewBox: "0 0 24 24" 8456 }, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 8457 d: "M16.7 7.1l-6.3 8.5-3.3-2.5-.9 1.2 4.5 3.4L17.9 8z" 8458 })); 8459 /* harmony default export */ const library_check = (check); 8460 8461 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/star-filled.js 8462 8463 /** 8464 * WordPress dependencies 8465 */ 8466 8467 const starFilled = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { 8468 xmlns: "http://www.w3.org/2000/svg", 8469 viewBox: "0 0 24 24" 8470 }, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 8471 d: "M11.776 4.454a.25.25 0 01.448 0l2.069 4.192a.25.25 0 00.188.137l4.626.672a.25.25 0 01.139.426l-3.348 3.263a.25.25 0 00-.072.222l.79 4.607a.25.25 0 01-.362.263l-4.138-2.175a.25.25 0 00-.232 0l-4.138 2.175a.25.25 0 01-.363-.263l.79-4.607a.25.25 0 00-.071-.222L4.754 9.881a.25.25 0 01.139-.426l4.626-.672a.25.25 0 00.188-.137l2.069-4.192z" 8472 })); 8473 /* harmony default export */ const star_filled = (starFilled); 8474 8475 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/star-empty.js 8476 8477 /** 8478 * WordPress dependencies 8479 */ 8480 8481 const starEmpty = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { 8482 xmlns: "http://www.w3.org/2000/svg", 8483 viewBox: "0 0 24 24" 8484 }, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 8485 fillRule: "evenodd", 8486 d: "M9.706 8.646a.25.25 0 01-.188.137l-4.626.672a.25.25 0 00-.139.427l3.348 3.262a.25.25 0 01.072.222l-.79 4.607a.25.25 0 00.362.264l4.138-2.176a.25.25 0 01.233 0l4.137 2.175a.25.25 0 00.363-.263l-.79-4.607a.25.25 0 01.072-.222l3.347-3.262a.25.25 0 00-.139-.427l-4.626-.672a.25.25 0 01-.188-.137l-2.069-4.192a.25.25 0 00-.448 0L9.706 8.646zM12 7.39l-.948 1.921a1.75 1.75 0 01-1.317.957l-2.12.308 1.534 1.495c.412.402.6.982.503 1.55l-.362 2.11 1.896-.997a1.75 1.75 0 011.629 0l1.895.997-.362-2.11a1.75 1.75 0 01.504-1.55l1.533-1.495-2.12-.308a1.75 1.75 0 01-1.317-.957L12 7.39z", 8487 clipRule: "evenodd" 8488 })); 8489 /* harmony default export */ const star_empty = (starEmpty); 8490 8491 ;// CONCATENATED MODULE: external ["wp","viewport"] 8492 const external_wp_viewport_namespaceObject = window["wp"]["viewport"]; 8493 ;// CONCATENATED MODULE: external ["wp","preferences"] 8494 const external_wp_preferences_namespaceObject = window["wp"]["preferences"]; 8495 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/close-small.js 8496 8497 /** 8498 * WordPress dependencies 8499 */ 8500 8501 const closeSmall = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { 8502 xmlns: "http://www.w3.org/2000/svg", 8503 viewBox: "0 0 24 24" 8504 }, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 8505 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" 8506 })); 8507 /* harmony default export */ const close_small = (closeSmall); 8508 8509 ;// CONCATENATED MODULE: ./node_modules/@wordpress/interface/build-module/store/actions.js 8510 /** 8511 * WordPress dependencies 8512 */ 8513 8514 8515 8516 /** 8517 * Set a default complementary area. 8518 * 8519 * @param {string} scope Complementary area scope. 8520 * @param {string} area Area identifier. 8521 * 8522 * @return {Object} Action object. 8523 */ 8524 const setDefaultComplementaryArea = (scope, area) => ({ 8525 type: 'SET_DEFAULT_COMPLEMENTARY_AREA', 8526 scope, 8527 area 8528 }); 8529 8530 /** 8531 * Enable the complementary area. 8532 * 8533 * @param {string} scope Complementary area scope. 8534 * @param {string} area Area identifier. 8535 */ 8536 const enableComplementaryArea = (scope, area) => ({ 8537 registry, 8538 dispatch 8539 }) => { 8540 // Return early if there's no area. 8541 if (!area) { 8542 return; 8543 } 8544 const isComplementaryAreaVisible = registry.select(external_wp_preferences_namespaceObject.store).get(scope, 'isComplementaryAreaVisible'); 8545 if (!isComplementaryAreaVisible) { 8546 registry.dispatch(external_wp_preferences_namespaceObject.store).set(scope, 'isComplementaryAreaVisible', true); 8547 } 8548 dispatch({ 8549 type: 'ENABLE_COMPLEMENTARY_AREA', 8550 scope, 8551 area 8552 }); 8553 }; 8554 8555 /** 8556 * Disable the complementary area. 8557 * 8558 * @param {string} scope Complementary area scope. 8559 */ 8560 const disableComplementaryArea = scope => ({ 8561 registry 8562 }) => { 8563 const isComplementaryAreaVisible = registry.select(external_wp_preferences_namespaceObject.store).get(scope, 'isComplementaryAreaVisible'); 8564 if (isComplementaryAreaVisible) { 8565 registry.dispatch(external_wp_preferences_namespaceObject.store).set(scope, 'isComplementaryAreaVisible', false); 8566 } 8567 }; 8568 8569 /** 8570 * Pins an item. 8571 * 8572 * @param {string} scope Item scope. 8573 * @param {string} item Item identifier. 8574 * 8575 * @return {Object} Action object. 8576 */ 8577 const pinItem = (scope, item) => ({ 8578 registry 8579 }) => { 8580 // Return early if there's no item. 8581 if (!item) { 8582 return; 8583 } 8584 const pinnedItems = registry.select(external_wp_preferences_namespaceObject.store).get(scope, 'pinnedItems'); 8585 8586 // The item is already pinned, there's nothing to do. 8587 if (pinnedItems?.[item] === true) { 8588 return; 8589 } 8590 registry.dispatch(external_wp_preferences_namespaceObject.store).set(scope, 'pinnedItems', { 8591 ...pinnedItems, 8592 [item]: true 8593 }); 8594 }; 8595 8596 /** 8597 * Unpins an item. 8598 * 8599 * @param {string} scope Item scope. 8600 * @param {string} item Item identifier. 8601 */ 8602 const unpinItem = (scope, item) => ({ 8603 registry 8604 }) => { 8605 // Return early if there's no item. 8606 if (!item) { 8607 return; 8608 } 8609 const pinnedItems = registry.select(external_wp_preferences_namespaceObject.store).get(scope, 'pinnedItems'); 8610 registry.dispatch(external_wp_preferences_namespaceObject.store).set(scope, 'pinnedItems', { 8611 ...pinnedItems, 8612 [item]: false 8613 }); 8614 }; 8615 8616 /** 8617 * Returns an action object used in signalling that a feature should be toggled. 8618 * 8619 * @param {string} scope The feature scope (e.g. core/edit-post). 8620 * @param {string} featureName The feature name. 8621 */ 8622 function toggleFeature(scope, featureName) { 8623 return function ({ 8624 registry 8625 }) { 8626 external_wp_deprecated_default()(`dispatch( 'core/interface' ).toggleFeature`, { 8627 since: '6.0', 8628 alternative: `dispatch( 'core/preferences' ).toggle` 8629 }); 8630 registry.dispatch(external_wp_preferences_namespaceObject.store).toggle(scope, featureName); 8631 }; 8632 } 8633 8634 /** 8635 * Returns an action object used in signalling that a feature should be set to 8636 * a true or false value 8637 * 8638 * @param {string} scope The feature scope (e.g. core/edit-post). 8639 * @param {string} featureName The feature name. 8640 * @param {boolean} value The value to set. 8641 * 8642 * @return {Object} Action object. 8643 */ 8644 function setFeatureValue(scope, featureName, value) { 8645 return function ({ 8646 registry 8647 }) { 8648 external_wp_deprecated_default()(`dispatch( 'core/interface' ).setFeatureValue`, { 8649 since: '6.0', 8650 alternative: `dispatch( 'core/preferences' ).set` 8651 }); 8652 registry.dispatch(external_wp_preferences_namespaceObject.store).set(scope, featureName, !!value); 8653 }; 8654 } 8655 8656 /** 8657 * Returns an action object used in signalling that defaults should be set for features. 8658 * 8659 * @param {string} scope The feature scope (e.g. core/edit-post). 8660 * @param {Object<string, boolean>} defaults A key/value map of feature names to values. 8661 * 8662 * @return {Object} Action object. 8663 */ 8664 function setFeatureDefaults(scope, defaults) { 8665 return function ({ 8666 registry 8667 }) { 8668 external_wp_deprecated_default()(`dispatch( 'core/interface' ).setFeatureDefaults`, { 8669 since: '6.0', 8670 alternative: `dispatch( 'core/preferences' ).setDefaults` 8671 }); 8672 registry.dispatch(external_wp_preferences_namespaceObject.store).setDefaults(scope, defaults); 8673 }; 8674 } 8675 8676 /** 8677 * Returns an action object used in signalling that the user opened a modal. 8678 * 8679 * @param {string} name A string that uniquely identifies the modal. 8680 * 8681 * @return {Object} Action object. 8682 */ 8683 function openModal(name) { 8684 return { 8685 type: 'OPEN_MODAL', 8686 name 8687 }; 8688 } 8689 8690 /** 8691 * Returns an action object signalling that the user closed a modal. 8692 * 8693 * @return {Object} Action object. 8694 */ 8695 function closeModal() { 8696 return { 8697 type: 'CLOSE_MODAL' 8698 }; 8699 } 8700 8701 ;// CONCATENATED MODULE: ./node_modules/@wordpress/interface/build-module/store/selectors.js 8702 /** 8703 * WordPress dependencies 8704 */ 8705 8706 8707 8708 8709 /** 8710 * Returns the complementary area that is active in a given scope. 8711 * 8712 * @param {Object} state Global application state. 8713 * @param {string} scope Item scope. 8714 * 8715 * @return {string | null | undefined} The complementary area that is active in the given scope. 8716 */ 8717 const getActiveComplementaryArea = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, scope) => { 8718 const isComplementaryAreaVisible = select(external_wp_preferences_namespaceObject.store).get(scope, 'isComplementaryAreaVisible'); 8719 8720 // Return `undefined` to indicate that the user has never toggled 8721 // visibility, this is the vanilla default. Other code relies on this 8722 // nuance in the return value. 8723 if (isComplementaryAreaVisible === undefined) { 8724 return undefined; 8725 } 8726 8727 // Return `null` to indicate the user hid the complementary area. 8728 if (isComplementaryAreaVisible === false) { 8729 return null; 8730 } 8731 return state?.complementaryAreas?.[scope]; 8732 }); 8733 const isComplementaryAreaLoading = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, scope) => { 8734 const isVisible = select(external_wp_preferences_namespaceObject.store).get(scope, 'isComplementaryAreaVisible'); 8735 const identifier = state?.complementaryAreas?.[scope]; 8736 return isVisible && identifier === undefined; 8737 }); 8738 8739 /** 8740 * Returns a boolean indicating if an item is pinned or not. 8741 * 8742 * @param {Object} state Global application state. 8743 * @param {string} scope Scope. 8744 * @param {string} item Item to check. 8745 * 8746 * @return {boolean} True if the item is pinned and false otherwise. 8747 */ 8748 const isItemPinned = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, scope, item) => { 8749 var _pinnedItems$item; 8750 const pinnedItems = select(external_wp_preferences_namespaceObject.store).get(scope, 'pinnedItems'); 8751 return (_pinnedItems$item = pinnedItems?.[item]) !== null && _pinnedItems$item !== void 0 ? _pinnedItems$item : true; 8752 }); 8753 8754 /** 8755 * Returns a boolean indicating whether a feature is active for a particular 8756 * scope. 8757 * 8758 * @param {Object} state The store state. 8759 * @param {string} scope The scope of the feature (e.g. core/edit-post). 8760 * @param {string} featureName The name of the feature. 8761 * 8762 * @return {boolean} Is the feature enabled? 8763 */ 8764 const isFeatureActive = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, scope, featureName) => { 8765 external_wp_deprecated_default()(`select( 'core/interface' ).isFeatureActive( scope, featureName )`, { 8766 since: '6.0', 8767 alternative: `select( 'core/preferences' ).get( scope, featureName )` 8768 }); 8769 return !!select(external_wp_preferences_namespaceObject.store).get(scope, featureName); 8770 }); 8771 8772 /** 8773 * Returns true if a modal is active, or false otherwise. 8774 * 8775 * @param {Object} state Global application state. 8776 * @param {string} modalName A string that uniquely identifies the modal. 8777 * 8778 * @return {boolean} Whether the modal is active. 8779 */ 8780 function isModalActive(state, modalName) { 8781 return state.activeModal === modalName; 8782 } 8783 8784 ;// CONCATENATED MODULE: ./node_modules/@wordpress/interface/build-module/store/reducer.js 8785 /** 8786 * WordPress dependencies 8787 */ 8788 8789 function complementaryAreas(state = {}, action) { 8790 switch (action.type) { 8791 case 'SET_DEFAULT_COMPLEMENTARY_AREA': 8792 { 8793 const { 8794 scope, 8795 area 8796 } = action; 8797 8798 // If there's already an area, don't overwrite it. 8799 if (state[scope]) { 8800 return state; 8801 } 8802 return { 8803 ...state, 8804 [scope]: area 8805 }; 8806 } 8807 case 'ENABLE_COMPLEMENTARY_AREA': 8808 { 8809 const { 8810 scope, 8811 area 8812 } = action; 8813 return { 8814 ...state, 8815 [scope]: area 8816 }; 8817 } 8818 } 8819 return state; 8820 } 8821 8822 /** 8823 * Reducer for storing the name of the open modal, or null if no modal is open. 8824 * 8825 * @param {Object} state Previous state. 8826 * @param {Object} action Action object containing the `name` of the modal 8827 * 8828 * @return {Object} Updated state 8829 */ 8830 function activeModal(state = null, action) { 8831 switch (action.type) { 8832 case 'OPEN_MODAL': 8833 return action.name; 8834 case 'CLOSE_MODAL': 8835 return null; 8836 } 8837 return state; 8838 } 8839 /* harmony default export */ const reducer = ((0,external_wp_data_namespaceObject.combineReducers)({ 8840 complementaryAreas, 8841 activeModal 8842 })); 8843 8844 ;// CONCATENATED MODULE: ./node_modules/@wordpress/interface/build-module/store/constants.js 8845 /** 8846 * The identifier for the data store. 8847 * 8848 * @type {string} 8849 */ 8850 const STORE_NAME = 'core/interface'; 8851 8852 ;// CONCATENATED MODULE: ./node_modules/@wordpress/interface/build-module/store/index.js 8853 /** 8854 * WordPress dependencies 8855 */ 8856 8857 8858 /** 8859 * Internal dependencies 8860 */ 8861 8862 8863 8864 8865 8866 /** 8867 * Store definition for the interface namespace. 8868 * 8869 * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore 8870 * 8871 * @type {Object} 8872 */ 8873 const store = (0,external_wp_data_namespaceObject.createReduxStore)(STORE_NAME, { 8874 reducer: reducer, 8875 actions: actions_namespaceObject, 8876 selectors: selectors_namespaceObject 8877 }); 8878 8879 // Once we build a more generic persistence plugin that works across types of stores 8880 // we'd be able to replace this with a register call. 8881 (0,external_wp_data_namespaceObject.register)(store); 8882 8883 ;// CONCATENATED MODULE: external ["wp","plugins"] 8884 const external_wp_plugins_namespaceObject = window["wp"]["plugins"]; 8885 ;// CONCATENATED MODULE: ./node_modules/@wordpress/interface/build-module/components/complementary-area-context/index.js 8886 /** 8887 * WordPress dependencies 8888 */ 8889 8890 /* harmony default export */ const complementary_area_context = ((0,external_wp_plugins_namespaceObject.withPluginContext)((context, ownProps) => { 8891 return { 8892 icon: ownProps.icon || context.icon, 8893 identifier: ownProps.identifier || `$context.name}/$ownProps.name}` 8894 }; 8895 })); 8896 8897 ;// CONCATENATED MODULE: ./node_modules/@wordpress/interface/build-module/components/complementary-area-toggle/index.js 8898 8899 /** 8900 * WordPress dependencies 8901 */ 8902 8903 8904 8905 /** 8906 * Internal dependencies 8907 */ 8908 8909 8910 function ComplementaryAreaToggle({ 8911 as = external_wp_components_namespaceObject.Button, 8912 scope, 8913 identifier, 8914 icon, 8915 selectedIcon, 8916 name, 8917 ...props 8918 }) { 8919 const ComponentToUse = as; 8920 const isSelected = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).getActiveComplementaryArea(scope) === identifier, [identifier, scope]); 8921 const { 8922 enableComplementaryArea, 8923 disableComplementaryArea 8924 } = (0,external_wp_data_namespaceObject.useDispatch)(store); 8925 return (0,external_React_.createElement)(ComponentToUse, { 8926 icon: selectedIcon && isSelected ? selectedIcon : icon, 8927 "aria-controls": identifier.replace('/', ':'), 8928 onClick: () => { 8929 if (isSelected) { 8930 disableComplementaryArea(scope); 8931 } else { 8932 enableComplementaryArea(scope, identifier); 8933 } 8934 }, 8935 ...props 8936 }); 8937 } 8938 /* harmony default export */ const complementary_area_toggle = (complementary_area_context(ComplementaryAreaToggle)); 8939 8940 ;// CONCATENATED MODULE: ./node_modules/@wordpress/interface/build-module/components/complementary-area-header/index.js 8941 8942 /** 8943 * External dependencies 8944 */ 8945 8946 8947 /** 8948 * WordPress dependencies 8949 */ 8950 8951 8952 /** 8953 * Internal dependencies 8954 */ 8955 8956 const ComplementaryAreaHeader = ({ 8957 smallScreenTitle, 8958 children, 8959 className, 8960 toggleButtonProps 8961 }) => { 8962 const toggleButton = (0,external_React_.createElement)(complementary_area_toggle, { 8963 icon: close_small, 8964 ...toggleButtonProps 8965 }); 8966 return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)("div", { 8967 className: "components-panel__header interface-complementary-area-header__small" 8968 }, smallScreenTitle && (0,external_React_.createElement)("span", { 8969 className: "interface-complementary-area-header__small-title" 8970 }, smallScreenTitle), toggleButton), (0,external_React_.createElement)("div", { 8971 className: classnames_default()('components-panel__header', 'interface-complementary-area-header', className), 8972 tabIndex: -1 8973 }, children, toggleButton)); 8974 }; 8975 /* harmony default export */ const complementary_area_header = (ComplementaryAreaHeader); 8976 8977 ;// CONCATENATED MODULE: ./node_modules/@wordpress/interface/build-module/components/action-item/index.js 8978 8979 /** 8980 * WordPress dependencies 8981 */ 8982 8983 8984 const noop = () => {}; 8985 function ActionItemSlot({ 8986 name, 8987 as: Component = external_wp_components_namespaceObject.ButtonGroup, 8988 fillProps = {}, 8989 bubblesVirtually, 8990 ...props 8991 }) { 8992 return (0,external_React_.createElement)(external_wp_components_namespaceObject.Slot, { 8993 name: name, 8994 bubblesVirtually: bubblesVirtually, 8995 fillProps: fillProps 8996 }, fills => { 8997 if (!external_wp_element_namespaceObject.Children.toArray(fills).length) { 8998 return null; 8999 } 9000 9001 // Special handling exists for backward compatibility. 9002 // It ensures that menu items created by plugin authors aren't 9003 // duplicated with automatically injected menu items coming 9004 // from pinnable plugin sidebars. 9005 // @see https://github.com/WordPress/gutenberg/issues/14457 9006 const initializedByPlugins = []; 9007 external_wp_element_namespaceObject.Children.forEach(fills, ({ 9008 props: { 9009 __unstableExplicitMenuItem, 9010 __unstableTarget 9011 } 9012 }) => { 9013 if (__unstableTarget && __unstableExplicitMenuItem) { 9014 initializedByPlugins.push(__unstableTarget); 9015 } 9016 }); 9017 const children = external_wp_element_namespaceObject.Children.map(fills, child => { 9018 if (!child.props.__unstableExplicitMenuItem && initializedByPlugins.includes(child.props.__unstableTarget)) { 9019 return null; 9020 } 9021 return child; 9022 }); 9023 return (0,external_React_.createElement)(Component, { 9024 ...props 9025 }, children); 9026 }); 9027 } 9028 function ActionItem({ 9029 name, 9030 as: Component = external_wp_components_namespaceObject.Button, 9031 onClick, 9032 ...props 9033 }) { 9034 return (0,external_React_.createElement)(external_wp_components_namespaceObject.Fill, { 9035 name: name 9036 }, ({ 9037 onClick: fpOnClick 9038 }) => { 9039 return (0,external_React_.createElement)(Component, { 9040 onClick: onClick || fpOnClick ? (...args) => { 9041 (onClick || noop)(...args); 9042 (fpOnClick || noop)(...args); 9043 } : undefined, 9044 ...props 9045 }); 9046 }); 9047 } 9048 ActionItem.Slot = ActionItemSlot; 9049 /* harmony default export */ const action_item = (ActionItem); 9050 9051 ;// CONCATENATED MODULE: ./node_modules/@wordpress/interface/build-module/components/complementary-area-more-menu-item/index.js 9052 9053 /** 9054 * WordPress dependencies 9055 */ 9056 9057 9058 9059 /** 9060 * Internal dependencies 9061 */ 9062 9063 9064 const PluginsMenuItem = ({ 9065 // Menu item is marked with unstable prop for backward compatibility. 9066 // They are removed so they don't leak to DOM elements. 9067 // @see https://github.com/WordPress/gutenberg/issues/14457 9068 __unstableExplicitMenuItem, 9069 __unstableTarget, 9070 ...restProps 9071 }) => (0,external_React_.createElement)(external_wp_components_namespaceObject.MenuItem, { 9072 ...restProps 9073 }); 9074 function ComplementaryAreaMoreMenuItem({ 9075 scope, 9076 target, 9077 __unstableExplicitMenuItem, 9078 ...props 9079 }) { 9080 return (0,external_React_.createElement)(complementary_area_toggle, { 9081 as: toggleProps => { 9082 return (0,external_React_.createElement)(action_item, { 9083 __unstableExplicitMenuItem: __unstableExplicitMenuItem, 9084 __unstableTarget: `$scope}/$target}`, 9085 as: PluginsMenuItem, 9086 name: `$scope}/plugin-more-menu`, 9087 ...toggleProps 9088 }); 9089 }, 9090 role: "menuitemcheckbox", 9091 selectedIcon: library_check, 9092 name: target, 9093 scope: scope, 9094 ...props 9095 }); 9096 } 9097 9098 ;// CONCATENATED MODULE: ./node_modules/@wordpress/interface/build-module/components/pinned-items/index.js 9099 9100 /** 9101 * External dependencies 9102 */ 9103 9104 9105 /** 9106 * WordPress dependencies 9107 */ 9108 9109 function PinnedItems({ 9110 scope, 9111 ...props 9112 }) { 9113 return (0,external_React_.createElement)(external_wp_components_namespaceObject.Fill, { 9114 name: `PinnedItems/$scope}`, 9115 ...props 9116 }); 9117 } 9118 function PinnedItemsSlot({ 9119 scope, 9120 className, 9121 ...props 9122 }) { 9123 return (0,external_React_.createElement)(external_wp_components_namespaceObject.Slot, { 9124 name: `PinnedItems/$scope}`, 9125 ...props 9126 }, fills => fills?.length > 0 && (0,external_React_.createElement)("div", { 9127 className: classnames_default()(className, 'interface-pinned-items') 9128 }, fills)); 9129 } 9130 PinnedItems.Slot = PinnedItemsSlot; 9131 /* harmony default export */ const pinned_items = (PinnedItems); 9132 9133 ;// CONCATENATED MODULE: ./node_modules/@wordpress/interface/build-module/components/complementary-area/index.js 9134 9135 /** 9136 * External dependencies 9137 */ 9138 9139 9140 /** 9141 * WordPress dependencies 9142 */ 9143 9144 9145 9146 9147 9148 9149 9150 9151 /** 9152 * Internal dependencies 9153 */ 9154 9155 9156 9157 9158 9159 9160 function ComplementaryAreaSlot({ 9161 scope, 9162 ...props 9163 }) { 9164 return (0,external_React_.createElement)(external_wp_components_namespaceObject.Slot, { 9165 name: `ComplementaryArea/$scope}`, 9166 ...props 9167 }); 9168 } 9169 function ComplementaryAreaFill({ 9170 scope, 9171 children, 9172 className, 9173 id 9174 }) { 9175 return (0,external_React_.createElement)(external_wp_components_namespaceObject.Fill, { 9176 name: `ComplementaryArea/$scope}` 9177 }, (0,external_React_.createElement)("div", { 9178 id: id, 9179 className: className 9180 }, children)); 9181 } 9182 function useAdjustComplementaryListener(scope, identifier, activeArea, isActive, isSmall) { 9183 const previousIsSmall = (0,external_wp_element_namespaceObject.useRef)(false); 9184 const shouldOpenWhenNotSmall = (0,external_wp_element_namespaceObject.useRef)(false); 9185 const { 9186 enableComplementaryArea, 9187 disableComplementaryArea 9188 } = (0,external_wp_data_namespaceObject.useDispatch)(store); 9189 (0,external_wp_element_namespaceObject.useEffect)(() => { 9190 // If the complementary area is active and the editor is switching from 9191 // a big to a small window size. 9192 if (isActive && isSmall && !previousIsSmall.current) { 9193 disableComplementaryArea(scope); 9194 // Flag the complementary area to be reopened when the window size 9195 // goes from small to big. 9196 shouldOpenWhenNotSmall.current = true; 9197 } else if ( 9198 // If there is a flag indicating the complementary area should be 9199 // enabled when we go from small to big window size and we are going 9200 // from a small to big window size. 9201 shouldOpenWhenNotSmall.current && !isSmall && previousIsSmall.current) { 9202 // Remove the flag indicating the complementary area should be 9203 // enabled. 9204 shouldOpenWhenNotSmall.current = false; 9205 enableComplementaryArea(scope, identifier); 9206 } else if ( 9207 // If the flag is indicating the current complementary should be 9208 // reopened but another complementary area becomes active, remove 9209 // the flag. 9210 shouldOpenWhenNotSmall.current && activeArea && activeArea !== identifier) { 9211 shouldOpenWhenNotSmall.current = false; 9212 } 9213 if (isSmall !== previousIsSmall.current) { 9214 previousIsSmall.current = isSmall; 9215 } 9216 }, [isActive, isSmall, scope, identifier, activeArea, disableComplementaryArea, enableComplementaryArea]); 9217 } 9218 function ComplementaryArea({ 9219 children, 9220 className, 9221 closeLabel = (0,external_wp_i18n_namespaceObject.__)('Close plugin'), 9222 identifier, 9223 header, 9224 headerClassName, 9225 icon, 9226 isPinnable = true, 9227 panelClassName, 9228 scope, 9229 name, 9230 smallScreenTitle, 9231 title, 9232 toggleShortcut, 9233 isActiveByDefault 9234 }) { 9235 const { 9236 isLoading, 9237 isActive, 9238 isPinned, 9239 activeArea, 9240 isSmall, 9241 isLarge, 9242 showIconLabels 9243 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 9244 const { 9245 getActiveComplementaryArea, 9246 isComplementaryAreaLoading, 9247 isItemPinned 9248 } = select(store); 9249 const { 9250 get 9251 } = select(external_wp_preferences_namespaceObject.store); 9252 const _activeArea = getActiveComplementaryArea(scope); 9253 return { 9254 isLoading: isComplementaryAreaLoading(scope), 9255 isActive: _activeArea === identifier, 9256 isPinned: isItemPinned(scope, identifier), 9257 activeArea: _activeArea, 9258 isSmall: select(external_wp_viewport_namespaceObject.store).isViewportMatch('< medium'), 9259 isLarge: select(external_wp_viewport_namespaceObject.store).isViewportMatch('large'), 9260 showIconLabels: get('core', 'showIconLabels') 9261 }; 9262 }, [identifier, scope]); 9263 useAdjustComplementaryListener(scope, identifier, activeArea, isActive, isSmall); 9264 const { 9265 enableComplementaryArea, 9266 disableComplementaryArea, 9267 pinItem, 9268 unpinItem 9269 } = (0,external_wp_data_namespaceObject.useDispatch)(store); 9270 (0,external_wp_element_namespaceObject.useEffect)(() => { 9271 // Set initial visibility: For large screens, enable if it's active by 9272 // default. For small screens, always initially disable. 9273 if (isActiveByDefault && activeArea === undefined && !isSmall) { 9274 enableComplementaryArea(scope, identifier); 9275 } else if (activeArea === undefined && isSmall) { 9276 disableComplementaryArea(scope, identifier); 9277 } 9278 }, [activeArea, isActiveByDefault, scope, identifier, isSmall, enableComplementaryArea, disableComplementaryArea]); 9279 return (0,external_React_.createElement)(external_React_.Fragment, null, isPinnable && (0,external_React_.createElement)(pinned_items, { 9280 scope: scope 9281 }, isPinned && (0,external_React_.createElement)(complementary_area_toggle, { 9282 scope: scope, 9283 identifier: identifier, 9284 isPressed: isActive && (!showIconLabels || isLarge), 9285 "aria-expanded": isActive, 9286 "aria-disabled": isLoading, 9287 label: title, 9288 icon: showIconLabels ? library_check : icon, 9289 showTooltip: !showIconLabels, 9290 variant: showIconLabels ? 'tertiary' : undefined, 9291 size: "compact" 9292 })), name && isPinnable && (0,external_React_.createElement)(ComplementaryAreaMoreMenuItem, { 9293 target: name, 9294 scope: scope, 9295 icon: icon 9296 }, title), isActive && (0,external_React_.createElement)(ComplementaryAreaFill, { 9297 className: classnames_default()('interface-complementary-area', className), 9298 scope: scope, 9299 id: identifier.replace('/', ':') 9300 }, (0,external_React_.createElement)(complementary_area_header, { 9301 className: headerClassName, 9302 closeLabel: closeLabel, 9303 onClose: () => disableComplementaryArea(scope), 9304 smallScreenTitle: smallScreenTitle, 9305 toggleButtonProps: { 9306 label: closeLabel, 9307 shortcut: toggleShortcut, 9308 scope, 9309 identifier 9310 } 9311 }, header || (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)("strong", null, title), isPinnable && (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 9312 className: "interface-complementary-area__pin-unpin-item", 9313 icon: isPinned ? star_filled : star_empty, 9314 label: isPinned ? (0,external_wp_i18n_namespaceObject.__)('Unpin from toolbar') : (0,external_wp_i18n_namespaceObject.__)('Pin to toolbar'), 9315 onClick: () => (isPinned ? unpinItem : pinItem)(scope, identifier), 9316 isPressed: isPinned, 9317 "aria-expanded": isPinned 9318 }))), (0,external_React_.createElement)(external_wp_components_namespaceObject.Panel, { 9319 className: panelClassName 9320 }, children))); 9321 } 9322 const ComplementaryAreaWrapped = complementary_area_context(ComplementaryArea); 9323 ComplementaryAreaWrapped.Slot = ComplementaryAreaSlot; 9324 /* harmony default export */ const complementary_area = (ComplementaryAreaWrapped); 9325 9326 ;// CONCATENATED MODULE: external ["wp","compose"] 9327 const external_wp_compose_namespaceObject = window["wp"]["compose"]; 9328 ;// CONCATENATED MODULE: ./node_modules/@wordpress/interface/build-module/components/navigable-region/index.js 9329 9330 /** 9331 * External dependencies 9332 */ 9333 9334 function NavigableRegion({ 9335 children, 9336 className, 9337 ariaLabel, 9338 as: Tag = 'div', 9339 ...props 9340 }) { 9341 return (0,external_React_.createElement)(Tag, { 9342 className: classnames_default()('interface-navigable-region', className), 9343 "aria-label": ariaLabel, 9344 role: "region", 9345 tabIndex: "-1", 9346 ...props 9347 }, children); 9348 } 9349 9350 ;// CONCATENATED MODULE: ./node_modules/@wordpress/interface/build-module/components/interface-skeleton/index.js 9351 9352 /** 9353 * External dependencies 9354 */ 9355 9356 9357 /** 9358 * WordPress dependencies 9359 */ 9360 9361 9362 9363 9364 9365 /** 9366 * Internal dependencies 9367 */ 9368 9369 function useHTMLClass(className) { 9370 (0,external_wp_element_namespaceObject.useEffect)(() => { 9371 const element = document && document.querySelector(`html:not(.$className})`); 9372 if (!element) { 9373 return; 9374 } 9375 element.classList.toggle(className); 9376 return () => { 9377 element.classList.toggle(className); 9378 }; 9379 }, [className]); 9380 } 9381 const headerVariants = { 9382 hidden: { 9383 opacity: 0 9384 }, 9385 hover: { 9386 opacity: 1, 9387 transition: { 9388 type: 'tween', 9389 delay: 0.2, 9390 delayChildren: 0.2 9391 } 9392 }, 9393 distractionFreeInactive: { 9394 opacity: 1, 9395 transition: { 9396 delay: 0 9397 } 9398 } 9399 }; 9400 function InterfaceSkeleton({ 9401 isDistractionFree, 9402 footer, 9403 header, 9404 editorNotices, 9405 sidebar, 9406 secondarySidebar, 9407 notices, 9408 content, 9409 actions, 9410 labels, 9411 className, 9412 enableRegionNavigation = true, 9413 // Todo: does this need to be a prop. 9414 // Can we use a dependency to keyboard-shortcuts directly? 9415 shortcuts 9416 }, ref) { 9417 const navigateRegionsProps = (0,external_wp_components_namespaceObject.__unstableUseNavigateRegions)(shortcuts); 9418 useHTMLClass('interface-interface-skeleton__html-container'); 9419 const defaultLabels = { 9420 /* translators: accessibility text for the top bar landmark region. */ 9421 header: (0,external_wp_i18n_namespaceObject._x)('Header', 'header landmark area'), 9422 /* translators: accessibility text for the content landmark region. */ 9423 body: (0,external_wp_i18n_namespaceObject.__)('Content'), 9424 /* translators: accessibility text for the secondary sidebar landmark region. */ 9425 secondarySidebar: (0,external_wp_i18n_namespaceObject.__)('Block Library'), 9426 /* translators: accessibility text for the settings landmark region. */ 9427 sidebar: (0,external_wp_i18n_namespaceObject.__)('Settings'), 9428 /* translators: accessibility text for the publish landmark region. */ 9429 actions: (0,external_wp_i18n_namespaceObject.__)('Publish'), 9430 /* translators: accessibility text for the footer landmark region. */ 9431 footer: (0,external_wp_i18n_namespaceObject.__)('Footer') 9432 }; 9433 const mergedLabels = { 9434 ...defaultLabels, 9435 ...labels 9436 }; 9437 return (0,external_React_.createElement)("div", { 9438 ...(enableRegionNavigation ? navigateRegionsProps : {}), 9439 ref: (0,external_wp_compose_namespaceObject.useMergeRefs)([ref, enableRegionNavigation ? navigateRegionsProps.ref : undefined]), 9440 className: classnames_default()(className, 'interface-interface-skeleton', navigateRegionsProps.className, !!footer && 'has-footer') 9441 }, (0,external_React_.createElement)("div", { 9442 className: "interface-interface-skeleton__editor" 9443 }, !!header && (0,external_React_.createElement)(NavigableRegion, { 9444 as: external_wp_components_namespaceObject.__unstableMotion.div, 9445 className: "interface-interface-skeleton__header", 9446 "aria-label": mergedLabels.header, 9447 initial: isDistractionFree ? 'hidden' : 'distractionFreeInactive', 9448 whileHover: isDistractionFree ? 'hover' : 'distractionFreeInactive', 9449 animate: isDistractionFree ? 'hidden' : 'distractionFreeInactive', 9450 variants: headerVariants, 9451 transition: isDistractionFree ? { 9452 type: 'tween', 9453 delay: 0.8 9454 } : undefined 9455 }, header), isDistractionFree && (0,external_React_.createElement)("div", { 9456 className: "interface-interface-skeleton__header" 9457 }, editorNotices), (0,external_React_.createElement)("div", { 9458 className: "interface-interface-skeleton__body" 9459 }, !!secondarySidebar && (0,external_React_.createElement)(NavigableRegion, { 9460 className: "interface-interface-skeleton__secondary-sidebar", 9461 ariaLabel: mergedLabels.secondarySidebar 9462 }, secondarySidebar), !!notices && (0,external_React_.createElement)("div", { 9463 className: "interface-interface-skeleton__notices" 9464 }, notices), (0,external_React_.createElement)(NavigableRegion, { 9465 className: "interface-interface-skeleton__content", 9466 ariaLabel: mergedLabels.body 9467 }, content), !!sidebar && (0,external_React_.createElement)(NavigableRegion, { 9468 className: "interface-interface-skeleton__sidebar", 9469 ariaLabel: mergedLabels.sidebar 9470 }, sidebar), !!actions && (0,external_React_.createElement)(NavigableRegion, { 9471 className: "interface-interface-skeleton__actions", 9472 ariaLabel: mergedLabels.actions 9473 }, actions))), !!footer && (0,external_React_.createElement)(NavigableRegion, { 9474 className: "interface-interface-skeleton__footer", 9475 ariaLabel: mergedLabels.footer 9476 }, footer)); 9477 } 9478 /* harmony default export */ const interface_skeleton = ((0,external_wp_element_namespaceObject.forwardRef)(InterfaceSkeleton)); 9479 9480 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/more-vertical.js 9481 9482 /** 9483 * WordPress dependencies 9484 */ 9485 9486 const moreVertical = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { 9487 xmlns: "http://www.w3.org/2000/svg", 9488 viewBox: "0 0 24 24" 9489 }, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 9490 d: "M13 19h-2v-2h2v2zm0-6h-2v-2h2v2zm0-6h-2V5h2v2z" 9491 })); 9492 /* harmony default export */ const more_vertical = (moreVertical); 9493 9494 ;// CONCATENATED MODULE: ./node_modules/@wordpress/interface/build-module/components/more-menu-dropdown/index.js 9495 9496 /** 9497 * External dependencies 9498 */ 9499 9500 9501 /** 9502 * WordPress dependencies 9503 */ 9504 9505 9506 9507 function MoreMenuDropdown({ 9508 as: DropdownComponent = external_wp_components_namespaceObject.DropdownMenu, 9509 className, 9510 /* translators: button label text should, if possible, be under 16 characters. */ 9511 label = (0,external_wp_i18n_namespaceObject.__)('Options'), 9512 popoverProps, 9513 toggleProps, 9514 children 9515 }) { 9516 return (0,external_React_.createElement)(DropdownComponent, { 9517 className: classnames_default()('interface-more-menu-dropdown', className), 9518 icon: more_vertical, 9519 label: label, 9520 popoverProps: { 9521 placement: 'bottom-end', 9522 ...popoverProps, 9523 className: classnames_default()('interface-more-menu-dropdown__content', popoverProps?.className) 9524 }, 9525 toggleProps: { 9526 tooltipPosition: 'bottom', 9527 ...toggleProps, 9528 size: 'compact' 9529 } 9530 }, onClose => children(onClose)); 9531 } 9532 9533 ;// CONCATENATED MODULE: ./node_modules/@wordpress/interface/build-module/components/index.js 9534 9535 9536 9537 9538 9539 9540 9541 9542 9543 9544 ;// CONCATENATED MODULE: ./node_modules/@wordpress/interface/build-module/index.js 9545 9546 9547 9548 ;// CONCATENATED MODULE: external ["wp","widgets"] 9549 const external_wp_widgets_namespaceObject = window["wp"]["widgets"]; 9550 ;// CONCATENATED MODULE: external ["wp","hooks"] 9551 const external_wp_hooks_namespaceObject = window["wp"]["hooks"]; 9552 ;// CONCATENATED MODULE: external ["wp","mediaUtils"] 9553 const external_wp_mediaUtils_namespaceObject = window["wp"]["mediaUtils"]; 9554 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/hooks/components.js 9555 /** 9556 * WordPress dependencies 9557 */ 9558 9559 9560 (0,external_wp_hooks_namespaceObject.addFilter)('editor.MediaUpload', 'core/edit-site/components/media-upload', () => external_wp_mediaUtils_namespaceObject.MediaUpload); 9561 9562 ;// CONCATENATED MODULE: external ["wp","blockEditor"] 9563 const external_wp_blockEditor_namespaceObject = window["wp"]["blockEditor"]; 9564 ;// CONCATENATED MODULE: external ["wp","notices"] 9565 const external_wp_notices_namespaceObject = window["wp"]["notices"]; 9566 ;// CONCATENATED MODULE: external ["wp","coreData"] 9567 const external_wp_coreData_namespaceObject = window["wp"]["coreData"]; 9568 ;// CONCATENATED MODULE: ./node_modules/colord/index.mjs 9569 var r={grad:.9,turn:360,rad:360/(2*Math.PI)},t=function(r){return"string"==typeof r?r.length>0:"number"==typeof r},n=function(r,t,n){return void 0===t&&(t=0),void 0===n&&(n=Math.pow(10,t)),Math.round(n*r)/n+0},e=function(r,t,n){return void 0===t&&(t=0),void 0===n&&(n=1),r>n?n:r>t?r:t},u=function(r){return(r=isFinite(r)?r%360:0)>0?r:r+360},a=function(r){return{r:e(r.r,0,255),g:e(r.g,0,255),b:e(r.b,0,255),a:e(r.a)}},o=function(r){return{r:n(r.r),g:n(r.g),b:n(r.b),a:n(r.a,3)}},i=/^#([0-9a-f]{3,8})$/i,s=function(r){var t=r.toString(16);return t.length<2?"0"+t:t},h=function(r){var t=r.r,n=r.g,e=r.b,u=r.a,a=Math.max(t,n,e),o=a-Math.min(t,n,e),i=o?a===t?(n-e)/o:a===n?2+(e-t)/o:4+(t-n)/o:0;return{h:60*(i<0?i+6:i),s:a?o/a*100:0,v:a/255*100,a:u}},b=function(r){var t=r.h,n=r.s,e=r.v,u=r.a;t=t/360*6,n/=100,e/=100;var a=Math.floor(t),o=e*(1-n),i=e*(1-(t-a)*n),s=e*(1-(1-t+a)*n),h=a%6;return{r:255*[e,i,o,o,s,e][h],g:255*[s,e,e,i,o,o][h],b:255*[o,o,s,e,e,i][h],a:u}},g=function(r){return{h:u(r.h),s:e(r.s,0,100),l:e(r.l,0,100),a:e(r.a)}},d=function(r){return{h:n(r.h),s:n(r.s),l:n(r.l),a:n(r.a,3)}},f=function(r){return b((n=(t=r).s,{h:t.h,s:(n*=((e=t.l)<50?e:100-e)/100)>0?2*n/(e+n)*100:0,v:e+n,a:t.a}));var t,n,e},c=function(r){return{h:(t=h(r)).h,s:(u=(200-(n=t.s))*(e=t.v)/100)>0&&u<200?n*e/100/(u<=100?u:200-u)*100:0,l:u/2,a:t.a};var t,n,e,u},l=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,colord_p=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,v=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,m=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,y={string:[[function(r){var t=i.exec(r);return t?(r=t[1]).length<=4?{r:parseInt(r[0]+r[0],16),g:parseInt(r[1]+r[1],16),b:parseInt(r[2]+r[2],16),a:4===r.length?n(parseInt(r[3]+r[3],16)/255,2):1}:6===r.length||8===r.length?{r:parseInt(r.substr(0,2),16),g:parseInt(r.substr(2,2),16),b:parseInt(r.substr(4,2),16),a:8===r.length?n(parseInt(r.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(r){var t=v.exec(r)||m.exec(r);return t?t[2]!==t[4]||t[4]!==t[6]?null:a({r:Number(t[1])/(t[2]?100/255:1),g:Number(t[3])/(t[4]?100/255:1),b:Number(t[5])/(t[6]?100/255:1),a:void 0===t[7]?1:Number(t[7])/(t[8]?100:1)}):null},"rgb"],[function(t){var n=l.exec(t)||colord_p.exec(t);if(!n)return null;var e,u,a=g({h:(e=n[1],u=n[2],void 0===u&&(u="deg"),Number(e)*(r[u]||1)),s:Number(n[3]),l:Number(n[4]),a:void 0===n[5]?1:Number(n[5])/(n[6]?100:1)});return f(a)},"hsl"]],object:[[function(r){var n=r.r,e=r.g,u=r.b,o=r.a,i=void 0===o?1:o;return t(n)&&t(e)&&t(u)?a({r:Number(n),g:Number(e),b:Number(u),a:Number(i)}):null},"rgb"],[function(r){var n=r.h,e=r.s,u=r.l,a=r.a,o=void 0===a?1:a;if(!t(n)||!t(e)||!t(u))return null;var i=g({h:Number(n),s:Number(e),l:Number(u),a:Number(o)});return f(i)},"hsl"],[function(r){var n=r.h,a=r.s,o=r.v,i=r.a,s=void 0===i?1:i;if(!t(n)||!t(a)||!t(o))return null;var h=function(r){return{h:u(r.h),s:e(r.s,0,100),v:e(r.v,0,100),a:e(r.a)}}({h:Number(n),s:Number(a),v:Number(o),a:Number(s)});return b(h)},"hsv"]]},N=function(r,t){for(var n=0;n<t.length;n++){var e=t[n][0](r);if(e)return[e,t[n][1]]}return[null,void 0]},x=function(r){return"string"==typeof r?N(r.trim(),y.string):"object"==typeof r&&null!==r?N(r,y.object):[null,void 0]},I=function(r){return x(r)[1]},M=function(r,t){var n=c(r);return{h:n.h,s:e(n.s+100*t,0,100),l:n.l,a:n.a}},H=function(r){return(299*r.r+587*r.g+114*r.b)/1e3/255},$=function(r,t){var n=c(r);return{h:n.h,s:n.s,l:e(n.l+100*t,0,100),a:n.a}},j=function(){function r(r){this.parsed=x(r)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return r.prototype.isValid=function(){return null!==this.parsed},r.prototype.brightness=function(){return n(H(this.rgba),2)},r.prototype.isDark=function(){return H(this.rgba)<.5},r.prototype.isLight=function(){return H(this.rgba)>=.5},r.prototype.toHex=function(){return r=o(this.rgba),t=r.r,e=r.g,u=r.b,i=(a=r.a)<1?s(n(255*a)):"","#"+s(t)+s(e)+s(u)+i;var r,t,e,u,a,i},r.prototype.toRgb=function(){return o(this.rgba)},r.prototype.toRgbString=function(){return r=o(this.rgba),t=r.r,n=r.g,e=r.b,(u=r.a)<1?"rgba("+t+", "+n+", "+e+", "+u+")":"rgb("+t+", "+n+", "+e+")";var r,t,n,e,u},r.prototype.toHsl=function(){return d(c(this.rgba))},r.prototype.toHslString=function(){return r=d(c(this.rgba)),t=r.h,n=r.s,e=r.l,(u=r.a)<1?"hsla("+t+", "+n+"%, "+e+"%, "+u+")":"hsl("+t+", "+n+"%, "+e+"%)";var r,t,n,e,u},r.prototype.toHsv=function(){return r=h(this.rgba),{h:n(r.h),s:n(r.s),v:n(r.v),a:n(r.a,3)};var r},r.prototype.invert=function(){return w({r:255-(r=this.rgba).r,g:255-r.g,b:255-r.b,a:r.a});var r},r.prototype.saturate=function(r){return void 0===r&&(r=.1),w(M(this.rgba,r))},r.prototype.desaturate=function(r){return void 0===r&&(r=.1),w(M(this.rgba,-r))},r.prototype.grayscale=function(){return w(M(this.rgba,-1))},r.prototype.lighten=function(r){return void 0===r&&(r=.1),w($(this.rgba,r))},r.prototype.darken=function(r){return void 0===r&&(r=.1),w($(this.rgba,-r))},r.prototype.rotate=function(r){return void 0===r&&(r=15),this.hue(this.hue()+r)},r.prototype.alpha=function(r){return"number"==typeof r?w({r:(t=this.rgba).r,g:t.g,b:t.b,a:r}):n(this.rgba.a,3);var t},r.prototype.hue=function(r){var t=c(this.rgba);return"number"==typeof r?w({h:r,s:t.s,l:t.l,a:t.a}):n(t.h)},r.prototype.isEqual=function(r){return this.toHex()===w(r).toHex()},r}(),w=function(r){return r instanceof j?r:new j(r)},S=[],k=function(r){r.forEach(function(r){S.indexOf(r)<0&&(r(j,y),S.push(r))})},E=function(){return new j({r:255*Math.random(),g:255*Math.random(),b:255*Math.random()})}; 9570 9571 ;// CONCATENATED MODULE: ./node_modules/colord/plugins/a11y.mjs 9572 var a11y_o=function(o){var t=o/255;return t<.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)},a11y_t=function(t){return.2126*a11y_o(t.r)+.7152*a11y_o(t.g)+.0722*a11y_o(t.b)};/* harmony default export */ function a11y(o){o.prototype.luminance=function(){return o=a11y_t(this.rgba),void 0===(r=2)&&(r=0),void 0===n&&(n=Math.pow(10,r)),Math.round(n*o)/n+0;var o,r,n},o.prototype.contrast=function(r){void 0===r&&(r="#FFF");var n,a,i,e,v,u,d,c=r instanceof o?r:new o(r);return e=this.rgba,v=c.toRgb(),u=a11y_t(e),d=a11y_t(v),n=u>d?(u+.05)/(d+.05):(d+.05)/(u+.05),void 0===(a=2)&&(a=0),void 0===i&&(i=Math.pow(10,a)),Math.floor(i*n)/i+0},o.prototype.isReadable=function(o,t){return void 0===o&&(o="#FFF"),void 0===t&&(t={}),this.contrast(o)>=(e=void 0===(i=(r=t).size)?"normal":i,"AAA"===(a=void 0===(n=r.level)?"AA":n)&&"normal"===e?7:"AA"===a&&"large"===e?3:4.5);var r,n,a,i,e}} 9573 9574 ;// CONCATENATED MODULE: external ["wp","privateApis"] 9575 const external_wp_privateApis_namespaceObject = window["wp"]["privateApis"]; 9576 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/lock-unlock.js 9577 /** 9578 * WordPress dependencies 9579 */ 9580 9581 const { 9582 lock, 9583 unlock 9584 } = (0,external_wp_privateApis_namespaceObject.__dangerousOptInToUnstableAPIsOnlyForCoreModules)('I know using unstable features means my theme or plugin will inevitably break in the next version of WordPress.', '@wordpress/edit-site'); 9585 9586 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/global-styles/hooks.js 9587 /** 9588 * External dependencies 9589 */ 9590 9591 9592 9593 /** 9594 * WordPress dependencies 9595 */ 9596 9597 9598 9599 /** 9600 * Internal dependencies 9601 */ 9602 9603 9604 const { 9605 useGlobalSetting, 9606 useGlobalStyle 9607 } = unlock(external_wp_blockEditor_namespaceObject.privateApis); 9608 9609 // Enable colord's a11y plugin. 9610 k([a11y]); 9611 function useColorRandomizer(name) { 9612 const [themeColors, setThemeColors] = useGlobalSetting('color.palette.theme', name); 9613 function randomizeColors() { 9614 /* eslint-disable no-restricted-syntax */ 9615 const randomRotationValue = Math.floor(Math.random() * 225); 9616 /* eslint-enable no-restricted-syntax */ 9617 9618 const newColors = themeColors.map(colorObject => { 9619 const { 9620 color 9621 } = colorObject; 9622 const newColor = w(color).rotate(randomRotationValue).toHex(); 9623 return { 9624 ...colorObject, 9625 color: newColor 9626 }; 9627 }); 9628 setThemeColors(newColors); 9629 } 9630 return window.__experimentalEnableColorRandomizer ? [randomizeColors] : []; 9631 } 9632 function useStylesPreviewColors() { 9633 const [textColor = 'black'] = useGlobalStyle('color.text'); 9634 const [backgroundColor = 'white'] = useGlobalStyle('color.background'); 9635 const [headingColor = textColor] = useGlobalStyle('elements.h1.color.text'); 9636 const [coreColors] = useGlobalSetting('color.palette.core'); 9637 const [themeColors] = useGlobalSetting('color.palette.theme'); 9638 const [customColors] = useGlobalSetting('color.palette.custom'); 9639 const paletteColors = (themeColors !== null && themeColors !== void 0 ? themeColors : []).concat(customColors !== null && customColors !== void 0 ? customColors : []).concat(coreColors !== null && coreColors !== void 0 ? coreColors : []); 9640 const highlightedColors = paletteColors.filter( 9641 // we exclude these two colors because they are already visible in the preview. 9642 ({ 9643 color 9644 }) => color !== backgroundColor && color !== headingColor).slice(0, 2); 9645 return { 9646 paletteColors, 9647 highlightedColors 9648 }; 9649 } 9650 function useSupportedStyles(name, element) { 9651 const { 9652 supportedPanels 9653 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 9654 return { 9655 supportedPanels: unlock(select(external_wp_blocks_namespaceObject.store)).getSupportedStyles(name, element) 9656 }; 9657 }, [name, element]); 9658 return supportedPanels; 9659 } 9660 9661 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/utils/set-nested-value.js 9662 /** 9663 * Sets the value at path of object. 9664 * If a portion of path doesn’t exist, it’s created. 9665 * Arrays are created for missing index properties while objects are created 9666 * for all other missing properties. 9667 * 9668 * This function intentionally mutates the input object. 9669 * 9670 * Inspired by _.set(). 9671 * 9672 * @see https://lodash.com/docs/4.17.15#set 9673 * 9674 * @todo Needs to be deduplicated with its copy in `@wordpress/core-data`. 9675 * 9676 * @param {Object} object Object to modify 9677 * @param {Array} path Path of the property to set. 9678 * @param {*} value Value to set. 9679 */ 9680 function setNestedValue(object, path, value) { 9681 if (!object || typeof object !== 'object') { 9682 return object; 9683 } 9684 path.reduce((acc, key, idx) => { 9685 if (acc[key] === undefined) { 9686 if (Number.isInteger(path[idx + 1])) { 9687 acc[key] = []; 9688 } else { 9689 acc[key] = {}; 9690 } 9691 } 9692 if (idx === path.length - 1) { 9693 acc[key] = value; 9694 } 9695 return acc[key]; 9696 }, object); 9697 return object; 9698 } 9699 9700 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/hooks/push-changes-to-global-styles/index.js 9701 9702 /** 9703 * WordPress dependencies 9704 */ 9705 9706 9707 9708 9709 9710 9711 9712 9713 9714 9715 9716 /** 9717 * Internal dependencies 9718 */ 9719 9720 9721 9722 const { 9723 cleanEmptyObject, 9724 GlobalStylesContext 9725 } = unlock(external_wp_blockEditor_namespaceObject.privateApis); 9726 9727 // Block Gap is a special case and isn't defined within the blocks 9728 // style properties config. We'll add it here to allow it to be pushed 9729 // to global styles as well. 9730 const STYLE_PROPERTY = { 9731 ...external_wp_blocks_namespaceObject.__EXPERIMENTAL_STYLE_PROPERTY, 9732 blockGap: { 9733 value: ['spacing', 'blockGap'] 9734 } 9735 }; 9736 9737 // TODO: Temporary duplication of constant in @wordpress/block-editor. Can be 9738 // removed by moving PushChangesToGlobalStylesControl to 9739 // @wordpress/block-editor. 9740 const STYLE_PATH_TO_CSS_VAR_INFIX = { 9741 'border.color': 'color', 9742 'color.background': 'color', 9743 'color.text': 'color', 9744 'elements.link.color.text': 'color', 9745 'elements.link.:hover.color.text': 'color', 9746 'elements.link.typography.fontFamily': 'font-family', 9747 'elements.link.typography.fontSize': 'font-size', 9748 'elements.button.color.text': 'color', 9749 'elements.button.color.background': 'color', 9750 'elements.button.typography.fontFamily': 'font-family', 9751 'elements.button.typography.fontSize': 'font-size', 9752 'elements.caption.color.text': 'color', 9753 'elements.heading.color': 'color', 9754 'elements.heading.color.background': 'color', 9755 'elements.heading.typography.fontFamily': 'font-family', 9756 'elements.heading.gradient': 'gradient', 9757 'elements.heading.color.gradient': 'gradient', 9758 'elements.h1.color': 'color', 9759 'elements.h1.color.background': 'color', 9760 'elements.h1.typography.fontFamily': 'font-family', 9761 'elements.h1.color.gradient': 'gradient', 9762 'elements.h2.color': 'color', 9763 'elements.h2.color.background': 'color', 9764 'elements.h2.typography.fontFamily': 'font-family', 9765 'elements.h2.color.gradient': 'gradient', 9766 'elements.h3.color': 'color', 9767 'elements.h3.color.background': 'color', 9768 'elements.h3.typography.fontFamily': 'font-family', 9769 'elements.h3.color.gradient': 'gradient', 9770 'elements.h4.color': 'color', 9771 'elements.h4.color.background': 'color', 9772 'elements.h4.typography.fontFamily': 'font-family', 9773 'elements.h4.color.gradient': 'gradient', 9774 'elements.h5.color': 'color', 9775 'elements.h5.color.background': 'color', 9776 'elements.h5.typography.fontFamily': 'font-family', 9777 'elements.h5.color.gradient': 'gradient', 9778 'elements.h6.color': 'color', 9779 'elements.h6.color.background': 'color', 9780 'elements.h6.typography.fontFamily': 'font-family', 9781 'elements.h6.color.gradient': 'gradient', 9782 'color.gradient': 'gradient', 9783 blockGap: 'spacing', 9784 'typography.fontSize': 'font-size', 9785 'typography.fontFamily': 'font-family' 9786 }; 9787 9788 // TODO: Temporary duplication of constant in @wordpress/block-editor. Can be 9789 // removed by moving PushChangesToGlobalStylesControl to 9790 // @wordpress/block-editor. 9791 const STYLE_PATH_TO_PRESET_BLOCK_ATTRIBUTE = { 9792 'border.color': 'borderColor', 9793 'color.background': 'backgroundColor', 9794 'color.text': 'textColor', 9795 'color.gradient': 'gradient', 9796 'typography.fontSize': 'fontSize', 9797 'typography.fontFamily': 'fontFamily' 9798 }; 9799 const SUPPORTED_STYLES = ['border', 'color', 'spacing', 'typography']; 9800 const getValueFromObjectPath = (object, path) => { 9801 let value = object; 9802 path.forEach(fieldName => { 9803 value = value?.[fieldName]; 9804 }); 9805 return value; 9806 }; 9807 const flatBorderProperties = ['borderColor', 'borderWidth', 'borderStyle']; 9808 const sides = ['top', 'right', 'bottom', 'left']; 9809 function getBorderStyleChanges(border, presetColor, userStyle) { 9810 if (!border && !presetColor) { 9811 return []; 9812 } 9813 const changes = [...getFallbackBorderStyleChange('top', border, userStyle), ...getFallbackBorderStyleChange('right', border, userStyle), ...getFallbackBorderStyleChange('bottom', border, userStyle), ...getFallbackBorderStyleChange('left', border, userStyle)]; 9814 9815 // Handle a flat border i.e. all sides the same, CSS shorthand. 9816 const { 9817 color: customColor, 9818 style, 9819 width 9820 } = border || {}; 9821 const hasColorOrWidth = presetColor || customColor || width; 9822 if (hasColorOrWidth && !style) { 9823 // Global Styles need individual side configurations to overcome 9824 // theme.json configurations which are per side as well. 9825 sides.forEach(side => { 9826 // Only add fallback border-style if global styles don't already 9827 // have something set. 9828 if (!userStyle?.[side]?.style) { 9829 changes.push({ 9830 path: ['border', side, 'style'], 9831 value: 'solid' 9832 }); 9833 } 9834 }); 9835 } 9836 return changes; 9837 } 9838 function getFallbackBorderStyleChange(side, border, globalBorderStyle) { 9839 if (!border?.[side] || globalBorderStyle?.[side]?.style) { 9840 return []; 9841 } 9842 const { 9843 color, 9844 style, 9845 width 9846 } = border[side]; 9847 const hasColorOrWidth = color || width; 9848 if (!hasColorOrWidth || style) { 9849 return []; 9850 } 9851 return [{ 9852 path: ['border', side, 'style'], 9853 value: 'solid' 9854 }]; 9855 } 9856 function useChangesToPush(name, attributes, userConfig) { 9857 const supports = useSupportedStyles(name); 9858 const blockUserConfig = userConfig?.styles?.blocks?.[name]; 9859 return (0,external_wp_element_namespaceObject.useMemo)(() => { 9860 const changes = supports.flatMap(key => { 9861 if (!STYLE_PROPERTY[key]) { 9862 return []; 9863 } 9864 const { 9865 value: path 9866 } = STYLE_PROPERTY[key]; 9867 const presetAttributeKey = path.join('.'); 9868 const presetAttributeValue = attributes[STYLE_PATH_TO_PRESET_BLOCK_ATTRIBUTE[presetAttributeKey]]; 9869 const value = presetAttributeValue ? `var:preset|$STYLE_PATH_TO_CSS_VAR_INFIX[presetAttributeKey]}|$presetAttributeValue}` : getValueFromObjectPath(attributes.style, path); 9870 9871 // Links only have a single support entry but have two element 9872 // style properties, color and hover color. The following check 9873 // will add the hover color to the changes if required. 9874 if (key === 'linkColor') { 9875 const linkChanges = value ? [{ 9876 path, 9877 value 9878 }] : []; 9879 const hoverPath = ['elements', 'link', ':hover', 'color', 'text']; 9880 const hoverValue = getValueFromObjectPath(attributes.style, hoverPath); 9881 if (hoverValue) { 9882 linkChanges.push({ 9883 path: hoverPath, 9884 value: hoverValue 9885 }); 9886 } 9887 return linkChanges; 9888 } 9889 9890 // The shorthand border styles can't be mapped directly as global 9891 // styles requires longhand config. 9892 if (flatBorderProperties.includes(key) && value) { 9893 // The shorthand config path is included to clear the block attribute. 9894 const borderChanges = [{ 9895 path, 9896 value 9897 }]; 9898 sides.forEach(side => { 9899 const currentPath = [...path]; 9900 currentPath.splice(-1, 0, side); 9901 borderChanges.push({ 9902 path: currentPath, 9903 value 9904 }); 9905 }); 9906 return borderChanges; 9907 } 9908 return value ? [{ 9909 path, 9910 value 9911 }] : []; 9912 }); 9913 9914 // To ensure display of a visible border, global styles require a 9915 // default border style if a border color or width is present. 9916 getBorderStyleChanges(attributes.style?.border, attributes.borderColor, blockUserConfig?.border).forEach(change => changes.push(change)); 9917 return changes; 9918 }, [supports, attributes, blockUserConfig]); 9919 } 9920 function cloneDeep(object) { 9921 return !object ? {} : JSON.parse(JSON.stringify(object)); 9922 } 9923 function PushChangesToGlobalStylesControl({ 9924 name, 9925 attributes, 9926 setAttributes 9927 }) { 9928 const { 9929 user: userConfig, 9930 setUserConfig 9931 } = (0,external_wp_element_namespaceObject.useContext)(GlobalStylesContext); 9932 const changes = useChangesToPush(name, attributes, userConfig); 9933 const { 9934 __unstableMarkNextChangeAsNotPersistent 9935 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store); 9936 const { 9937 createSuccessNotice 9938 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store); 9939 const pushChanges = (0,external_wp_element_namespaceObject.useCallback)(() => { 9940 if (changes.length === 0) { 9941 return; 9942 } 9943 if (changes.length > 0) { 9944 const { 9945 style: blockStyles 9946 } = attributes; 9947 const newBlockStyles = cloneDeep(blockStyles); 9948 const newUserConfig = cloneDeep(userConfig); 9949 for (const { 9950 path, 9951 value 9952 } of changes) { 9953 setNestedValue(newBlockStyles, path, undefined); 9954 setNestedValue(newUserConfig, ['styles', 'blocks', name, ...path], value); 9955 } 9956 const newBlockAttributes = { 9957 borderColor: undefined, 9958 backgroundColor: undefined, 9959 textColor: undefined, 9960 gradient: undefined, 9961 fontSize: undefined, 9962 fontFamily: undefined, 9963 style: cleanEmptyObject(newBlockStyles) 9964 }; 9965 9966 // @wordpress/core-data doesn't support editing multiple entity types in 9967 // a single undo level. So for now, we disable @wordpress/core-data undo 9968 // tracking and implement our own Undo button in the snackbar 9969 // notification. 9970 __unstableMarkNextChangeAsNotPersistent(); 9971 setAttributes(newBlockAttributes); 9972 setUserConfig(() => newUserConfig, { 9973 undoIgnore: true 9974 }); 9975 createSuccessNotice((0,external_wp_i18n_namespaceObject.sprintf)( 9976 // translators: %s: Title of the block e.g. 'Heading'. 9977 (0,external_wp_i18n_namespaceObject.__)('%s styles applied.'), (0,external_wp_blocks_namespaceObject.getBlockType)(name).title), { 9978 type: 'snackbar', 9979 actions: [{ 9980 label: (0,external_wp_i18n_namespaceObject.__)('Undo'), 9981 onClick() { 9982 __unstableMarkNextChangeAsNotPersistent(); 9983 setAttributes(attributes); 9984 setUserConfig(() => userConfig, { 9985 undoIgnore: true 9986 }); 9987 } 9988 }] 9989 }); 9990 } 9991 }, [__unstableMarkNextChangeAsNotPersistent, attributes, changes, createSuccessNotice, name, setAttributes, setUserConfig, userConfig]); 9992 return (0,external_React_.createElement)(external_wp_components_namespaceObject.BaseControl, { 9993 className: "edit-site-push-changes-to-global-styles-control", 9994 help: (0,external_wp_i18n_namespaceObject.sprintf)( 9995 // translators: %s: Title of the block e.g. 'Heading'. 9996 (0,external_wp_i18n_namespaceObject.__)('Apply this block’s typography, spacing, dimensions, and color styles to all %s blocks.'), (0,external_wp_blocks_namespaceObject.getBlockType)(name).title) 9997 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.BaseControl.VisualLabel, null, (0,external_wp_i18n_namespaceObject.__)('Styles')), (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 9998 variant: "primary", 9999 disabled: changes.length === 0, 10000 onClick: pushChanges 10001 }, (0,external_wp_i18n_namespaceObject.__)('Apply globally'))); 10002 } 10003 function PushChangesToGlobalStyles(props) { 10004 const blockEditingMode = (0,external_wp_blockEditor_namespaceObject.useBlockEditingMode)(); 10005 const isBlockBasedTheme = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).getCurrentTheme()?.is_block_theme, []); 10006 const supportsStyles = SUPPORTED_STYLES.some(feature => (0,external_wp_blocks_namespaceObject.hasBlockSupport)(props.name, feature)); 10007 const isDisplayed = blockEditingMode === 'default' && supportsStyles && isBlockBasedTheme; 10008 if (!isDisplayed) { 10009 return null; 10010 } 10011 return (0,external_React_.createElement)(external_wp_blockEditor_namespaceObject.InspectorAdvancedControls, null, (0,external_React_.createElement)(PushChangesToGlobalStylesControl, { 10012 ...props 10013 })); 10014 } 10015 const withPushChangesToGlobalStyles = (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(BlockEdit => props => (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(BlockEdit, { 10016 ...props 10017 }), props.isSelected && (0,external_React_.createElement)(PushChangesToGlobalStyles, { 10018 ...props 10019 }))); 10020 (0,external_wp_hooks_namespaceObject.addFilter)('editor.BlockEdit', 'core/edit-site/push-changes-to-global-styles', withPushChangesToGlobalStyles); 10021 10022 ;// CONCATENATED MODULE: external ["wp","router"] 10023 const external_wp_router_namespaceObject = window["wp"]["router"]; 10024 ;// CONCATENATED MODULE: external ["wp","url"] 10025 const external_wp_url_namespaceObject = window["wp"]["url"]; 10026 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/utils/is-previewing-theme.js 10027 /** 10028 * WordPress dependencies 10029 */ 10030 10031 function isPreviewingTheme() { 10032 return (0,external_wp_url_namespaceObject.getQueryArg)(window.location.href, 'wp_theme_preview') !== undefined; 10033 } 10034 function currentlyPreviewingTheme() { 10035 if (isPreviewingTheme()) { 10036 return (0,external_wp_url_namespaceObject.getQueryArg)(window.location.href, 'wp_theme_preview'); 10037 } 10038 return null; 10039 } 10040 10041 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/routes/link.js 10042 10043 /** 10044 * WordPress dependencies 10045 */ 10046 10047 10048 10049 /** 10050 * Internal dependencies 10051 */ 10052 10053 10054 const { 10055 useHistory 10056 } = unlock(external_wp_router_namespaceObject.privateApis); 10057 function useLink(params, state, shouldReplace = false) { 10058 const history = useHistory(); 10059 function onClick(event) { 10060 event?.preventDefault(); 10061 if (shouldReplace) { 10062 history.replace(params, state); 10063 } else { 10064 history.push(params, state); 10065 } 10066 } 10067 const currentArgs = (0,external_wp_url_namespaceObject.getQueryArgs)(window.location.href); 10068 const currentUrlWithoutArgs = (0,external_wp_url_namespaceObject.removeQueryArgs)(window.location.href, ...Object.keys(currentArgs)); 10069 if (isPreviewingTheme()) { 10070 params = { 10071 ...params, 10072 wp_theme_preview: currentlyPreviewingTheme() 10073 }; 10074 } 10075 const newUrl = (0,external_wp_url_namespaceObject.addQueryArgs)(currentUrlWithoutArgs, params); 10076 return { 10077 href: newUrl, 10078 onClick 10079 }; 10080 } 10081 function Link({ 10082 params = {}, 10083 state, 10084 replace: shouldReplace = false, 10085 children, 10086 ...props 10087 }) { 10088 const { 10089 href, 10090 onClick 10091 } = useLink(params, state, shouldReplace); 10092 return (0,external_React_.createElement)("a", { 10093 href: href, 10094 onClick: onClick, 10095 ...props 10096 }, children); 10097 } 10098 10099 ;// CONCATENATED MODULE: external ["wp","patterns"] 10100 const external_wp_patterns_namespaceObject = window["wp"]["patterns"]; 10101 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/utils/constants.js 10102 /** 10103 * WordPress dependencies 10104 */ 10105 10106 10107 10108 /** 10109 * Internal dependencies 10110 */ 10111 10112 10113 // Navigation 10114 const NAVIGATION_POST_TYPE = 'wp_navigation'; 10115 10116 // Templates. 10117 const constants_TEMPLATE_POST_TYPE = 'wp_template'; 10118 const TEMPLATE_PART_POST_TYPE = 'wp_template_part'; 10119 const TEMPLATE_ORIGINS = { 10120 custom: 'custom', 10121 theme: 'theme', 10122 plugin: 'plugin' 10123 }; 10124 const TEMPLATE_PART_AREA_DEFAULT_CATEGORY = 'uncategorized'; 10125 10126 // Patterns. 10127 const { 10128 PATTERN_TYPES, 10129 PATTERN_DEFAULT_CATEGORY, 10130 PATTERN_USER_CATEGORY, 10131 EXCLUDED_PATTERN_SOURCES, 10132 PATTERN_SYNC_TYPES 10133 } = unlock(external_wp_patterns_namespaceObject.privateApis); 10134 10135 // Entities that are editable in focus mode. 10136 const FOCUSABLE_ENTITIES = [TEMPLATE_PART_POST_TYPE, NAVIGATION_POST_TYPE, PATTERN_TYPES.user]; 10137 const POST_TYPE_LABELS = { 10138 [constants_TEMPLATE_POST_TYPE]: (0,external_wp_i18n_namespaceObject.__)('Template'), 10139 [TEMPLATE_PART_POST_TYPE]: (0,external_wp_i18n_namespaceObject.__)('Template part'), 10140 [PATTERN_TYPES.user]: (0,external_wp_i18n_namespaceObject.__)('Pattern'), 10141 [NAVIGATION_POST_TYPE]: (0,external_wp_i18n_namespaceObject.__)('Navigation') 10142 }; 10143 10144 // DataViews constants 10145 const LAYOUT_GRID = 'grid'; 10146 const LAYOUT_TABLE = 'table'; 10147 const LAYOUT_LIST = 'list'; 10148 const ENUMERATION_TYPE = 'enumeration'; 10149 const OPERATOR_IN = 'in'; 10150 const OPERATOR_NOT_IN = 'notIn'; 10151 10152 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/hooks/template-part-edit.js 10153 10154 /** 10155 * WordPress dependencies 10156 */ 10157 10158 10159 10160 10161 10162 10163 10164 10165 10166 /** 10167 * Internal dependencies 10168 */ 10169 10170 10171 10172 const { 10173 useLocation 10174 } = unlock(external_wp_router_namespaceObject.privateApis); 10175 function EditTemplatePartMenuItem({ 10176 attributes 10177 }) { 10178 const { 10179 theme, 10180 slug 10181 } = attributes; 10182 const { 10183 params 10184 } = useLocation(); 10185 const templatePart = (0,external_wp_data_namespaceObject.useSelect)(select => { 10186 const { 10187 getCurrentTheme, 10188 getEntityRecord 10189 } = select(external_wp_coreData_namespaceObject.store); 10190 return getEntityRecord('postType', TEMPLATE_PART_POST_TYPE, 10191 // Ideally this should be an official public API. 10192 `$theme || getCurrentTheme()?.stylesheet}//${slug}`); 10193 }, [theme, slug]); 10194 const linkProps = useLink({ 10195 postId: templatePart?.id, 10196 postType: templatePart?.type, 10197 canvas: 'edit' 10198 }, { 10199 fromTemplateId: params.postId || templatePart?.id 10200 }); 10201 if (!templatePart) { 10202 return null; 10203 } 10204 return (0,external_React_.createElement)(external_wp_components_namespaceObject.ToolbarButton, { 10205 ...linkProps, 10206 onClick: event => { 10207 linkProps.onClick(event); 10208 } 10209 }, (0,external_wp_i18n_namespaceObject.__)('Edit')); 10210 } 10211 const withEditBlockControls = (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(BlockEdit => props => { 10212 const { 10213 attributes, 10214 name 10215 } = props; 10216 const isDisplayed = name === 'core/template-part' && attributes.slug; 10217 return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(BlockEdit, { 10218 key: "edit", 10219 ...props 10220 }), isDisplayed && (0,external_React_.createElement)(external_wp_blockEditor_namespaceObject.BlockControls, { 10221 group: "other" 10222 }, (0,external_React_.createElement)(EditTemplatePartMenuItem, { 10223 attributes: attributes 10224 }))); 10225 }, 'withEditBlockControls'); 10226 (0,external_wp_hooks_namespaceObject.addFilter)('editor.BlockEdit', 'core/edit-site/template-part-edit-button', withEditBlockControls); 10227 10228 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/hooks/navigation-menu-edit.js 10229 10230 /** 10231 * WordPress dependencies 10232 */ 10233 10234 10235 10236 10237 10238 10239 10240 10241 10242 /** 10243 * Internal dependencies 10244 */ 10245 10246 10247 10248 const { 10249 useLocation: navigation_menu_edit_useLocation 10250 } = unlock(external_wp_router_namespaceObject.privateApis); 10251 function NavigationMenuEdit({ 10252 attributes 10253 }) { 10254 const { 10255 ref 10256 } = attributes; 10257 const { 10258 params 10259 } = navigation_menu_edit_useLocation(); 10260 const blockEditingMode = (0,external_wp_blockEditor_namespaceObject.useBlockEditingMode)(); 10261 const navigationMenu = (0,external_wp_data_namespaceObject.useSelect)(select => { 10262 return select(external_wp_coreData_namespaceObject.store).getEntityRecord('postType', NAVIGATION_POST_TYPE, 10263 // Ideally this should be an official public API. 10264 ref); 10265 }, [ref]); 10266 const linkProps = useLink({ 10267 postId: navigationMenu?.id, 10268 postType: navigationMenu?.type, 10269 canvas: 'edit' 10270 }, { 10271 // this applies to Navigation Menus as well. 10272 fromTemplateId: params.postId || navigationMenu?.id 10273 }); 10274 10275 // A non-default setting for block editing mode indicates that the 10276 // editor should restrict "editing" actions. Therefore the `Edit` button 10277 // should not be displayed. 10278 if (!navigationMenu || blockEditingMode !== 'default') { 10279 return null; 10280 } 10281 return (0,external_React_.createElement)(external_wp_blockEditor_namespaceObject.BlockControls, { 10282 group: "other" 10283 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.ToolbarButton, { 10284 ...linkProps, 10285 onClick: event => { 10286 linkProps.onClick(event); 10287 } 10288 }, (0,external_wp_i18n_namespaceObject.__)('Edit'))); 10289 } 10290 const navigation_menu_edit_withEditBlockControls = (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(BlockEdit => props => { 10291 const { 10292 attributes, 10293 name 10294 } = props; 10295 const isDisplayed = name === 'core/navigation' && attributes.ref; 10296 return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(BlockEdit, { 10297 ...props 10298 }), isDisplayed && (0,external_React_.createElement)(NavigationMenuEdit, { 10299 attributes: attributes 10300 })); 10301 }, 'withEditBlockControls'); 10302 (0,external_wp_hooks_namespaceObject.addFilter)('editor.BlockEdit', 'core/edit-site/navigation-edit-button', navigation_menu_edit_withEditBlockControls); 10303 10304 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/hooks/index.js 10305 /** 10306 * Internal dependencies 10307 */ 10308 10309 10310 10311 10312 10313 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/store/reducer.js 10314 /** 10315 * WordPress dependencies 10316 */ 10317 10318 10319 /** 10320 * Reducer returning the settings. 10321 * 10322 * @param {Object} state Current state. 10323 * @param {Object} action Dispatched action. 10324 * 10325 * @return {Object} Updated state. 10326 */ 10327 function settings(state = {}, action) { 10328 switch (action.type) { 10329 case 'UPDATE_SETTINGS': 10330 return { 10331 ...state, 10332 ...action.settings 10333 }; 10334 } 10335 return state; 10336 } 10337 10338 /** 10339 * Reducer keeping track of the currently edited Post Type, 10340 * Post Id and the context provided to fill the content of the block editor. 10341 * 10342 * @param {Object} state Current edited post. 10343 * @param {Object} action Dispatched action. 10344 * 10345 * @return {Object} Updated state. 10346 */ 10347 function editedPost(state = {}, action) { 10348 switch (action.type) { 10349 case 'SET_EDITED_POST': 10350 return { 10351 postType: action.postType, 10352 id: action.id, 10353 context: action.context 10354 }; 10355 case 'SET_EDITED_POST_CONTEXT': 10356 return { 10357 ...state, 10358 context: action.context 10359 }; 10360 } 10361 return state; 10362 } 10363 10364 /** 10365 * Reducer to set the save view panel open or closed. 10366 * 10367 * @param {Object} state Current state. 10368 * @param {Object} action Dispatched action. 10369 */ 10370 function saveViewPanel(state = false, action) { 10371 switch (action.type) { 10372 case 'SET_IS_SAVE_VIEW_OPENED': 10373 return action.isOpen; 10374 case 'SET_CANVAS_MODE': 10375 return false; 10376 } 10377 return state; 10378 } 10379 10380 /** 10381 * Reducer used to track the site editor canvas mode (edit or view). 10382 * 10383 * @param {Object} state Current state. 10384 * @param {Object} action Dispatched action. 10385 */ 10386 function canvasMode(state = 'init', action) { 10387 switch (action.type) { 10388 case 'SET_CANVAS_MODE': 10389 return action.mode; 10390 } 10391 return state; 10392 } 10393 10394 /** 10395 * Reducer used to track the site editor canvas container view. 10396 * Default is `undefined`, denoting the default, visual block editor. 10397 * This could be, for example, `'style-book'` (the style book). 10398 * 10399 * @param {string|undefined} state Current state. 10400 * @param {Object} action Dispatched action. 10401 */ 10402 function editorCanvasContainerView(state = undefined, action) { 10403 switch (action.type) { 10404 case 'SET_EDITOR_CANVAS_CONTAINER_VIEW': 10405 return action.view; 10406 } 10407 return state; 10408 } 10409 /* harmony default export */ const store_reducer = ((0,external_wp_data_namespaceObject.combineReducers)({ 10410 settings, 10411 editedPost, 10412 saveViewPanel, 10413 canvasMode, 10414 editorCanvasContainerView 10415 })); 10416 10417 ;// CONCATENATED MODULE: external ["wp","apiFetch"] 10418 const external_wp_apiFetch_namespaceObject = window["wp"]["apiFetch"]; 10419 var external_wp_apiFetch_default = /*#__PURE__*/__webpack_require__.n(external_wp_apiFetch_namespaceObject); 10420 ;// CONCATENATED MODULE: external ["wp","a11y"] 10421 const external_wp_a11y_namespaceObject = window["wp"]["a11y"]; 10422 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/store/constants.js 10423 /** 10424 * The identifier for the data store. 10425 * 10426 * @type {string} 10427 */ 10428 const constants_STORE_NAME = 'core/edit-site'; 10429 10430 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/utils/is-template-revertable.js 10431 /** 10432 * Internal dependencies 10433 */ 10434 10435 10436 /** 10437 * Check if a template is revertable to its original theme-provided template file. 10438 * 10439 * @param {Object} template The template entity to check. 10440 * @return {boolean} Whether the template is revertable. 10441 */ 10442 function isTemplateRevertable(template) { 10443 if (!template) { 10444 return false; 10445 } 10446 /* eslint-disable camelcase */ 10447 return template?.source === TEMPLATE_ORIGINS.custom && template?.has_theme_file; 10448 /* eslint-enable camelcase */ 10449 } 10450 10451 ;// CONCATENATED MODULE: external ["wp","htmlEntities"] 10452 const external_wp_htmlEntities_namespaceObject = window["wp"]["htmlEntities"]; 10453 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/store/private-actions.js 10454 /** 10455 * WordPress dependencies 10456 */ 10457 10458 10459 10460 10461 10462 10463 10464 10465 /** 10466 * Internal dependencies 10467 */ 10468 10469 10470 /** 10471 * Action that switches the canvas mode. 10472 * 10473 * @param {?string} mode Canvas mode. 10474 */ 10475 const setCanvasMode = mode => ({ 10476 registry, 10477 dispatch 10478 }) => { 10479 const isMediumOrBigger = window.matchMedia('(min-width: 782px)').matches; 10480 registry.dispatch(external_wp_blockEditor_namespaceObject.store).__unstableSetEditorMode('edit'); 10481 dispatch({ 10482 type: 'SET_CANVAS_MODE', 10483 mode 10484 }); 10485 // Check if the block list view should be open by default. 10486 // If `distractionFree` mode is enabled, the block list view should not be open. 10487 // This behavior is disabled for small viewports. 10488 if (isMediumOrBigger && mode === 'edit' && registry.select(external_wp_preferences_namespaceObject.store).get('core', 'showListViewByDefault') && !registry.select(external_wp_preferences_namespaceObject.store).get('core', 'distractionFree')) { 10489 registry.dispatch(external_wp_editor_namespaceObject.store).setIsListViewOpened(true); 10490 } else { 10491 registry.dispatch(external_wp_editor_namespaceObject.store).setIsListViewOpened(false); 10492 } 10493 registry.dispatch(external_wp_editor_namespaceObject.store).setIsInserterOpened(false); 10494 }; 10495 10496 /** 10497 * Action that switches the editor canvas container view. 10498 * 10499 * @param {?string} view Editor canvas container view. 10500 */ 10501 const setEditorCanvasContainerView = view => ({ 10502 dispatch 10503 }) => { 10504 dispatch({ 10505 type: 'SET_EDITOR_CANVAS_CONTAINER_VIEW', 10506 view 10507 }); 10508 }; 10509 10510 /** 10511 * Action that removes an array of templates. 10512 * 10513 * @param {Array} items An array of template or template part objects to remove. 10514 */ 10515 const removeTemplates = items => async ({ 10516 registry 10517 }) => { 10518 const isTemplate = items[0].type === constants_TEMPLATE_POST_TYPE; 10519 const promiseResult = await Promise.allSettled(items.map(item => { 10520 return registry.dispatch(external_wp_coreData_namespaceObject.store).deleteEntityRecord('postType', item.type, item.id, { 10521 force: true 10522 }, { 10523 throwOnError: true 10524 }); 10525 })); 10526 10527 // If all the promises were fulfilled with sucess. 10528 if (promiseResult.every(({ 10529 status 10530 }) => status === 'fulfilled')) { 10531 let successMessage; 10532 if (items.length === 1) { 10533 // Depending on how the entity was retrieved its title might be 10534 // an object or simple string. 10535 const title = typeof items[0].title === 'string' ? items[0].title : items[0].title?.rendered; 10536 successMessage = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: The template/part's name. */ 10537 (0,external_wp_i18n_namespaceObject.__)('"%s" deleted.'), (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(title)); 10538 } else { 10539 successMessage = isTemplate ? (0,external_wp_i18n_namespaceObject.__)('Templates deleted.') : (0,external_wp_i18n_namespaceObject.__)('Template parts deleted.'); 10540 } 10541 registry.dispatch(external_wp_notices_namespaceObject.store).createSuccessNotice(successMessage, { 10542 type: 'snackbar', 10543 id: 'site-editor-template-deleted-success' 10544 }); 10545 } else { 10546 // If there was at lease one failure. 10547 let errorMessage; 10548 // If we were trying to delete a single template. 10549 if (promiseResult.length === 1) { 10550 if (promiseResult[0].reason?.message) { 10551 errorMessage = promiseResult[0].reason.message; 10552 } else { 10553 errorMessage = isTemplate ? (0,external_wp_i18n_namespaceObject.__)('An error occurred while deleting the template.') : (0,external_wp_i18n_namespaceObject.__)('An error occurred while deleting the template part.'); 10554 } 10555 // If we were trying to delete a multiple templates 10556 } else { 10557 const errorMessages = new Set(); 10558 const failedPromises = promiseResult.filter(({ 10559 status 10560 }) => status === 'rejected'); 10561 for (const failedPromise of failedPromises) { 10562 if (failedPromise.reason?.message) { 10563 errorMessages.add(failedPromise.reason.message); 10564 } 10565 } 10566 if (errorMessages.size === 0) { 10567 errorMessage = isTemplate ? (0,external_wp_i18n_namespaceObject.__)('An error occurred while deleting the templates.') : (0,external_wp_i18n_namespaceObject.__)('An error occurred while deleting the template parts.'); 10568 } else if (errorMessages.size === 1) { 10569 errorMessage = isTemplate ? (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: an error message */ 10570 (0,external_wp_i18n_namespaceObject.__)('An error occurred while deleting the templates: %s'), [...errorMessages][0]) : (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: an error message */ 10571 (0,external_wp_i18n_namespaceObject.__)('An error occurred while deleting the template parts: %s'), [...errorMessages][0]); 10572 } else { 10573 errorMessage = isTemplate ? (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: a list of comma separated error messages */ 10574 (0,external_wp_i18n_namespaceObject.__)('Some errors occurred while deleting the templates: %s'), [...errorMessages].join(',')) : (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: a list of comma separated error messages */ 10575 (0,external_wp_i18n_namespaceObject.__)('Some errors occurred while deleting the template parts: %s'), [...errorMessages].join(',')); 10576 } 10577 } 10578 registry.dispatch(external_wp_notices_namespaceObject.store).createErrorNotice(errorMessage, { 10579 type: 'snackbar' 10580 }); 10581 } 10582 }; 10583 10584 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/store/actions.js 10585 /** 10586 * WordPress dependencies 10587 */ 10588 10589 10590 10591 10592 10593 10594 10595 10596 10597 10598 10599 10600 10601 /** 10602 * Internal dependencies 10603 */ 10604 10605 10606 10607 10608 10609 /** 10610 * Dispatches an action that toggles a feature flag. 10611 * 10612 * @param {string} featureName Feature name. 10613 */ 10614 function actions_toggleFeature(featureName) { 10615 return function ({ 10616 registry 10617 }) { 10618 external_wp_deprecated_default()("dispatch( 'core/edit-site' ).toggleFeature( featureName )", { 10619 since: '6.0', 10620 alternative: "dispatch( 'core/preferences').toggle( 'core/edit-site', featureName )" 10621 }); 10622 registry.dispatch(external_wp_preferences_namespaceObject.store).toggle('core/edit-site', featureName); 10623 }; 10624 } 10625 10626 /** 10627 * Action that changes the width of the editing canvas. 10628 * 10629 * @deprecated 10630 * 10631 * @param {string} deviceType 10632 * 10633 * @return {Object} Action object. 10634 */ 10635 const __experimentalSetPreviewDeviceType = deviceType => ({ 10636 registry 10637 }) => { 10638 external_wp_deprecated_default()("dispatch( 'core/edit-site' ).__experimentalSetPreviewDeviceType", { 10639 since: '6.5', 10640 version: '6.7', 10641 hint: 'registry.dispatch( editorStore ).setDeviceType' 10642 }); 10643 registry.dispatch(external_wp_editor_namespaceObject.store).setDeviceType(deviceType); 10644 }; 10645 10646 /** 10647 * Action that sets a template, optionally fetching it from REST API. 10648 * 10649 * @return {Object} Action object. 10650 */ 10651 function setTemplate() { 10652 external_wp_deprecated_default()("dispatch( 'core/edit-site' ).setTemplate", { 10653 since: '6.5', 10654 version: '6.8', 10655 hint: 'The setTemplate is not needed anymore, the correct entity is resolved from the URL automatically.' 10656 }); 10657 return { 10658 type: 'NOTHING' 10659 }; 10660 } 10661 10662 /** 10663 * Action that adds a new template and sets it as the current template. 10664 * 10665 * @param {Object} template The template. 10666 * 10667 * @deprecated 10668 * 10669 * @return {Object} Action object used to set the current template. 10670 */ 10671 const addTemplate = template => async ({ 10672 dispatch, 10673 registry 10674 }) => { 10675 external_wp_deprecated_default()("dispatch( 'core/edit-site' ).addTemplate", { 10676 since: '6.5', 10677 version: '6.8', 10678 hint: 'use saveEntityRecord directly' 10679 }); 10680 const newTemplate = await registry.dispatch(external_wp_coreData_namespaceObject.store).saveEntityRecord('postType', constants_TEMPLATE_POST_TYPE, template); 10681 if (template.content) { 10682 registry.dispatch(external_wp_coreData_namespaceObject.store).editEntityRecord('postType', constants_TEMPLATE_POST_TYPE, newTemplate.id, { 10683 blocks: (0,external_wp_blocks_namespaceObject.parse)(template.content) 10684 }, { 10685 undoIgnore: true 10686 }); 10687 } 10688 dispatch({ 10689 type: 'SET_EDITED_POST', 10690 postType: constants_TEMPLATE_POST_TYPE, 10691 id: newTemplate.id 10692 }); 10693 }; 10694 10695 /** 10696 * Action that removes a template. 10697 * 10698 * @param {Object} template The template object. 10699 */ 10700 const removeTemplate = template => { 10701 return removeTemplates([template]); 10702 }; 10703 10704 /** 10705 * Action that sets a template part. 10706 * 10707 * @param {string} templatePartId The template part ID. 10708 * 10709 * @return {Object} Action object. 10710 */ 10711 function setTemplatePart(templatePartId) { 10712 return { 10713 type: 'SET_EDITED_POST', 10714 postType: TEMPLATE_PART_POST_TYPE, 10715 id: templatePartId 10716 }; 10717 } 10718 10719 /** 10720 * Action that sets a navigation menu. 10721 * 10722 * @param {string} navigationMenuId The Navigation Menu Post ID. 10723 * 10724 * @return {Object} Action object. 10725 */ 10726 function setNavigationMenu(navigationMenuId) { 10727 return { 10728 type: 'SET_EDITED_POST', 10729 postType: NAVIGATION_POST_TYPE, 10730 id: navigationMenuId 10731 }; 10732 } 10733 10734 /** 10735 * Action that sets an edited entity. 10736 * 10737 * @param {string} postType The entity's post type. 10738 * @param {string} postId The entity's ID. 10739 * @param {Object} context The entity's context. 10740 * 10741 * @return {Object} Action object. 10742 */ 10743 function setEditedEntity(postType, postId, context) { 10744 return { 10745 type: 'SET_EDITED_POST', 10746 postType, 10747 id: postId, 10748 context 10749 }; 10750 } 10751 10752 /** 10753 * @deprecated 10754 */ 10755 function setHomeTemplateId() { 10756 external_wp_deprecated_default()("dispatch( 'core/edit-site' ).setHomeTemplateId", { 10757 since: '6.2', 10758 version: '6.4' 10759 }); 10760 return { 10761 type: 'NOTHING' 10762 }; 10763 } 10764 10765 /** 10766 * Set's the current block editor context. 10767 * 10768 * @param {Object} context The context object. 10769 * 10770 * @return {Object} Action object. 10771 */ 10772 function setEditedPostContext(context) { 10773 return { 10774 type: 'SET_EDITED_POST_CONTEXT', 10775 context 10776 }; 10777 } 10778 10779 /** 10780 * Resolves the template for a page and displays both. If no path is given, attempts 10781 * to use the postId to generate a path like `?p=${ postId }`. 10782 * 10783 * @deprecated 10784 * 10785 * @return {number} The resolved template ID for the page route. 10786 */ 10787 function setPage() { 10788 external_wp_deprecated_default()("dispatch( 'core/edit-site' ).setPage", { 10789 since: '6.5', 10790 version: '6.8', 10791 hint: 'The setPage is not needed anymore, the correct entity is resolved from the URL automatically.' 10792 }); 10793 return { 10794 type: 'NOTHING' 10795 }; 10796 } 10797 10798 /** 10799 * Action that sets the active navigation panel menu. 10800 * 10801 * @deprecated 10802 * 10803 * @return {Object} Action object. 10804 */ 10805 function setNavigationPanelActiveMenu() { 10806 external_wp_deprecated_default()("dispatch( 'core/edit-site' ).setNavigationPanelActiveMenu", { 10807 since: '6.2', 10808 version: '6.4' 10809 }); 10810 return { 10811 type: 'NOTHING' 10812 }; 10813 } 10814 10815 /** 10816 * Opens the navigation panel and sets its active menu at the same time. 10817 * 10818 * @deprecated 10819 */ 10820 function openNavigationPanelToMenu() { 10821 external_wp_deprecated_default()("dispatch( 'core/edit-site' ).openNavigationPanelToMenu", { 10822 since: '6.2', 10823 version: '6.4' 10824 }); 10825 return { 10826 type: 'NOTHING' 10827 }; 10828 } 10829 10830 /** 10831 * Sets whether the navigation panel should be open. 10832 * 10833 * @deprecated 10834 */ 10835 function setIsNavigationPanelOpened() { 10836 external_wp_deprecated_default()("dispatch( 'core/edit-site' ).setIsNavigationPanelOpened", { 10837 since: '6.2', 10838 version: '6.4' 10839 }); 10840 return { 10841 type: 'NOTHING' 10842 }; 10843 } 10844 10845 /** 10846 * Returns an action object used to open/close the inserter. 10847 * 10848 * @deprecated 10849 * 10850 * @param {boolean|Object} value Whether the inserter should be opened (true) or closed (false). 10851 */ 10852 const setIsInserterOpened = value => ({ 10853 registry 10854 }) => { 10855 external_wp_deprecated_default()("dispatch( 'core/edit-site' ).setIsInserterOpened", { 10856 since: '6.5', 10857 alternative: "dispatch( 'core/editor').setIsInserterOpened" 10858 }); 10859 registry.dispatch(external_wp_editor_namespaceObject.store).setIsInserterOpened(value); 10860 }; 10861 10862 /** 10863 * Returns an action object used to open/close the list view. 10864 * 10865 * @deprecated 10866 * 10867 * @param {boolean} isOpen A boolean representing whether the list view should be opened or closed. 10868 */ 10869 const setIsListViewOpened = isOpen => ({ 10870 registry 10871 }) => { 10872 external_wp_deprecated_default()("dispatch( 'core/edit-site' ).setIsListViewOpened", { 10873 since: '6.5', 10874 alternative: "dispatch( 'core/editor').setIsListViewOpened" 10875 }); 10876 registry.dispatch(external_wp_editor_namespaceObject.store).setIsListViewOpened(isOpen); 10877 }; 10878 10879 /** 10880 * Returns an action object used to update the settings. 10881 * 10882 * @param {Object} settings New settings. 10883 * 10884 * @return {Object} Action object. 10885 */ 10886 function updateSettings(settings) { 10887 return { 10888 type: 'UPDATE_SETTINGS', 10889 settings 10890 }; 10891 } 10892 10893 /** 10894 * Sets whether the save view panel should be open. 10895 * 10896 * @param {boolean} isOpen If true, opens the save view. If false, closes it. 10897 * It does not toggle the state, but sets it directly. 10898 */ 10899 function setIsSaveViewOpened(isOpen) { 10900 return { 10901 type: 'SET_IS_SAVE_VIEW_OPENED', 10902 isOpen 10903 }; 10904 } 10905 10906 /** 10907 * Reverts a template to its original theme-provided file. 10908 * 10909 * @param {Object} template The template to revert. 10910 * @param {Object} [options] 10911 * @param {boolean} [options.allowUndo] Whether to allow the user to undo 10912 * reverting the template. Default true. 10913 */ 10914 const revertTemplate = (template, { 10915 allowUndo = true 10916 } = {}) => async ({ 10917 registry 10918 }) => { 10919 const noticeId = 'edit-site-template-reverted'; 10920 registry.dispatch(external_wp_notices_namespaceObject.store).removeNotice(noticeId); 10921 if (!isTemplateRevertable(template)) { 10922 registry.dispatch(external_wp_notices_namespaceObject.store).createErrorNotice((0,external_wp_i18n_namespaceObject.__)('This template is not revertable.'), { 10923 type: 'snackbar' 10924 }); 10925 return; 10926 } 10927 try { 10928 const templateEntityConfig = registry.select(external_wp_coreData_namespaceObject.store).getEntityConfig('postType', template.type); 10929 if (!templateEntityConfig) { 10930 registry.dispatch(external_wp_notices_namespaceObject.store).createErrorNotice((0,external_wp_i18n_namespaceObject.__)('The editor has encountered an unexpected error. Please reload.'), { 10931 type: 'snackbar' 10932 }); 10933 return; 10934 } 10935 const fileTemplatePath = (0,external_wp_url_namespaceObject.addQueryArgs)(`$templateEntityConfig.baseURL}/$template.id}`, { 10936 context: 'edit', 10937 source: 'theme' 10938 }); 10939 const fileTemplate = await external_wp_apiFetch_default()({ 10940 path: fileTemplatePath 10941 }); 10942 if (!fileTemplate) { 10943 registry.dispatch(external_wp_notices_namespaceObject.store).createErrorNotice((0,external_wp_i18n_namespaceObject.__)('The editor has encountered an unexpected error. Please reload.'), { 10944 type: 'snackbar' 10945 }); 10946 return; 10947 } 10948 const serializeBlocks = ({ 10949 blocks: blocksForSerialization = [] 10950 }) => (0,external_wp_blocks_namespaceObject.__unstableSerializeAndClean)(blocksForSerialization); 10951 const edited = registry.select(external_wp_coreData_namespaceObject.store).getEditedEntityRecord('postType', template.type, template.id); 10952 10953 // We are fixing up the undo level here to make sure we can undo 10954 // the revert in the header toolbar correctly. 10955 registry.dispatch(external_wp_coreData_namespaceObject.store).editEntityRecord('postType', template.type, template.id, { 10956 content: serializeBlocks, 10957 // Required to make the `undo` behave correctly. 10958 blocks: edited.blocks, 10959 // Required to revert the blocks in the editor. 10960 source: 'custom' // required to avoid turning the editor into a dirty state 10961 }, { 10962 undoIgnore: true // Required to merge this edit with the last undo level. 10963 }); 10964 const blocks = (0,external_wp_blocks_namespaceObject.parse)(fileTemplate?.content?.raw); 10965 registry.dispatch(external_wp_coreData_namespaceObject.store).editEntityRecord('postType', template.type, fileTemplate.id, { 10966 content: serializeBlocks, 10967 blocks, 10968 source: 'theme' 10969 }); 10970 if (allowUndo) { 10971 const undoRevert = () => { 10972 registry.dispatch(external_wp_coreData_namespaceObject.store).editEntityRecord('postType', template.type, edited.id, { 10973 content: serializeBlocks, 10974 blocks: edited.blocks, 10975 source: 'custom' 10976 }); 10977 }; 10978 registry.dispatch(external_wp_notices_namespaceObject.store).createSuccessNotice((0,external_wp_i18n_namespaceObject.__)('Template reverted.'), { 10979 type: 'snackbar', 10980 id: noticeId, 10981 actions: [{ 10982 label: (0,external_wp_i18n_namespaceObject.__)('Undo'), 10983 onClick: undoRevert 10984 }] 10985 }); 10986 } 10987 } catch (error) { 10988 const errorMessage = error.message && error.code !== 'unknown_error' ? error.message : (0,external_wp_i18n_namespaceObject.__)('Template revert failed. Please reload.'); 10989 registry.dispatch(external_wp_notices_namespaceObject.store).createErrorNotice(errorMessage, { 10990 type: 'snackbar' 10991 }); 10992 } 10993 }; 10994 /** 10995 * Action that opens an editor sidebar. 10996 * 10997 * @param {?string} name Sidebar name to be opened. 10998 */ 10999 const openGeneralSidebar = name => ({ 11000 dispatch, 11001 registry 11002 }) => { 11003 const isDistractionFree = registry.select(external_wp_preferences_namespaceObject.store).get('core', 'distractionFree'); 11004 if (isDistractionFree) { 11005 dispatch.toggleDistractionFree(); 11006 } 11007 registry.dispatch(store).enableComplementaryArea(constants_STORE_NAME, name); 11008 }; 11009 11010 /** 11011 * Action that closes the sidebar. 11012 */ 11013 const closeGeneralSidebar = () => ({ 11014 registry 11015 }) => { 11016 registry.dispatch(store).disableComplementaryArea(constants_STORE_NAME); 11017 }; 11018 const switchEditorMode = mode => ({ 11019 dispatch, 11020 registry 11021 }) => { 11022 registry.dispatch('core/preferences').set('core', 'editorMode', mode); 11023 11024 // Unselect blocks when we switch to a non visual mode. 11025 if (mode !== 'visual') { 11026 registry.dispatch(external_wp_blockEditor_namespaceObject.store).clearSelectedBlock(); 11027 } 11028 if (mode === 'visual') { 11029 (0,external_wp_a11y_namespaceObject.speak)((0,external_wp_i18n_namespaceObject.__)('Visual editor selected'), 'assertive'); 11030 } else if (mode === 'text') { 11031 const isDistractionFree = registry.select(external_wp_preferences_namespaceObject.store).get('core', 'distractionFree'); 11032 if (isDistractionFree) { 11033 dispatch.toggleDistractionFree(); 11034 } 11035 (0,external_wp_a11y_namespaceObject.speak)((0,external_wp_i18n_namespaceObject.__)('Code editor selected'), 'assertive'); 11036 } 11037 }; 11038 11039 /** 11040 * Sets whether or not the editor allows only page content to be edited. 11041 * 11042 * @param {boolean} hasPageContentFocus True to allow only page content to be 11043 * edited, false to allow template to be 11044 * edited. 11045 */ 11046 const setHasPageContentFocus = hasPageContentFocus => ({ 11047 dispatch, 11048 registry 11049 }) => { 11050 external_wp_deprecated_default()(`dispatch( 'core/edit-site' ).setHasPageContentFocus`, { 11051 since: '6.5' 11052 }); 11053 if (hasPageContentFocus) { 11054 registry.dispatch(external_wp_blockEditor_namespaceObject.store).clearSelectedBlock(); 11055 } 11056 dispatch({ 11057 type: 'SET_HAS_PAGE_CONTENT_FOCUS', 11058 hasPageContentFocus 11059 }); 11060 }; 11061 11062 /** 11063 * Action that toggles Distraction free mode. 11064 * Distraction free mode expects there are no sidebars, as due to the 11065 * z-index values set, you can't close sidebars. 11066 */ 11067 const toggleDistractionFree = () => ({ 11068 dispatch, 11069 registry 11070 }) => { 11071 const isDistractionFree = registry.select(external_wp_preferences_namespaceObject.store).get('core', 'distractionFree'); 11072 if (isDistractionFree) { 11073 registry.dispatch(external_wp_preferences_namespaceObject.store).set('core', 'fixedToolbar', false); 11074 } 11075 if (!isDistractionFree) { 11076 registry.batch(() => { 11077 registry.dispatch(external_wp_preferences_namespaceObject.store).set('core', 'fixedToolbar', true); 11078 registry.dispatch(external_wp_editor_namespaceObject.store).setIsInserterOpened(false); 11079 registry.dispatch(external_wp_editor_namespaceObject.store).setIsListViewOpened(false); 11080 dispatch.closeGeneralSidebar(); 11081 }); 11082 } 11083 registry.batch(() => { 11084 registry.dispatch(external_wp_preferences_namespaceObject.store).set('core', 'distractionFree', !isDistractionFree); 11085 registry.dispatch(external_wp_notices_namespaceObject.store).createInfoNotice(isDistractionFree ? (0,external_wp_i18n_namespaceObject.__)('Distraction free off.') : (0,external_wp_i18n_namespaceObject.__)('Distraction free on.'), { 11086 id: 'core/edit-site/distraction-free-mode/notice', 11087 type: 'snackbar', 11088 actions: [{ 11089 label: (0,external_wp_i18n_namespaceObject.__)('Undo'), 11090 onClick: () => { 11091 registry.batch(() => { 11092 registry.dispatch(external_wp_preferences_namespaceObject.store).set('core', 'fixedToolbar', isDistractionFree ? true : false); 11093 registry.dispatch(external_wp_preferences_namespaceObject.store).toggle('core', 'distractionFree'); 11094 }); 11095 } 11096 }] 11097 }); 11098 }); 11099 }; 11100 11101 ;// CONCATENATED MODULE: ./node_modules/memize/dist/index.js 11102 /** 11103 * Memize options object. 11104 * 11105 * @typedef MemizeOptions 11106 * 11107 * @property {number} [maxSize] Maximum size of the cache. 11108 */ 11109 11110 /** 11111 * Internal cache entry. 11112 * 11113 * @typedef MemizeCacheNode 11114 * 11115 * @property {?MemizeCacheNode|undefined} [prev] Previous node. 11116 * @property {?MemizeCacheNode|undefined} [next] Next node. 11117 * @property {Array<*>} args Function arguments for cache 11118 * entry. 11119 * @property {*} val Function result. 11120 */ 11121 11122 /** 11123 * Properties of the enhanced function for controlling cache. 11124 * 11125 * @typedef MemizeMemoizedFunction 11126 * 11127 * @property {()=>void} clear Clear the cache. 11128 */ 11129 11130 /** 11131 * Accepts a function to be memoized, and returns a new memoized function, with 11132 * optional options. 11133 * 11134 * @template {(...args: any[]) => any} F 11135 * 11136 * @param {F} fn Function to memoize. 11137 * @param {MemizeOptions} [options] Options object. 11138 * 11139 * @return {((...args: Parameters<F>) => ReturnType<F>) & MemizeMemoizedFunction} Memoized function. 11140 */ 11141 function memize(fn, options) { 11142 var size = 0; 11143 11144 /** @type {?MemizeCacheNode|undefined} */ 11145 var head; 11146 11147 /** @type {?MemizeCacheNode|undefined} */ 11148 var tail; 11149 11150 options = options || {}; 11151 11152 function memoized(/* ...args */) { 11153 var node = head, 11154 len = arguments.length, 11155 args, 11156 i; 11157 11158 searchCache: while (node) { 11159 // Perform a shallow equality test to confirm that whether the node 11160 // under test is a candidate for the arguments passed. Two arrays 11161 // are shallowly equal if their length matches and each entry is 11162 // strictly equal between the two sets. Avoid abstracting to a 11163 // function which could incur an arguments leaking deoptimization. 11164 11165 // Check whether node arguments match arguments length 11166 if (node.args.length !== arguments.length) { 11167 node = node.next; 11168 continue; 11169 } 11170 11171 // Check whether node arguments match arguments values 11172 for (i = 0; i < len; i++) { 11173 if (node.args[i] !== arguments[i]) { 11174 node = node.next; 11175 continue searchCache; 11176 } 11177 } 11178 11179 // At this point we can assume we've found a match 11180 11181 // Surface matched node to head if not already 11182 if (node !== head) { 11183 // As tail, shift to previous. Must only shift if not also 11184 // head, since if both head and tail, there is no previous. 11185 if (node === tail) { 11186 tail = node.prev; 11187 } 11188 11189 // Adjust siblings to point to each other. If node was tail, 11190 // this also handles new tail's empty `next` assignment. 11191 /** @type {MemizeCacheNode} */ (node.prev).next = node.next; 11192 if (node.next) { 11193 node.next.prev = node.prev; 11194 } 11195 11196 node.next = head; 11197 node.prev = null; 11198 /** @type {MemizeCacheNode} */ (head).prev = node; 11199 head = node; 11200 } 11201 11202 // Return immediately 11203 return node.val; 11204 } 11205 11206 // No cached value found. Continue to insertion phase: 11207 11208 // Create a copy of arguments (avoid leaking deoptimization) 11209 args = new Array(len); 11210 for (i = 0; i < len; i++) { 11211 args[i] = arguments[i]; 11212 } 11213 11214 node = { 11215 args: args, 11216 11217 // Generate the result from original function 11218 val: fn.apply(null, args), 11219 }; 11220 11221 // Don't need to check whether node is already head, since it would 11222 // have been returned above already if it was 11223 11224 // Shift existing head down list 11225 if (head) { 11226 head.prev = node; 11227 node.next = head; 11228 } else { 11229 // If no head, follows that there's no tail (at initial or reset) 11230 tail = node; 11231 } 11232 11233 // Trim tail if we're reached max size and are pending cache insertion 11234 if (size === /** @type {MemizeOptions} */ (options).maxSize) { 11235 tail = /** @type {MemizeCacheNode} */ (tail).prev; 11236 /** @type {MemizeCacheNode} */ (tail).next = null; 11237 } else { 11238 size++; 11239 } 11240 11241 head = node; 11242 11243 return node.val; 11244 } 11245 11246 memoized.clear = function () { 11247 head = null; 11248 tail = null; 11249 size = 0; 11250 }; 11251 11252 // Ignore reason: There's not a clear solution to create an intersection of 11253 // the function with additional properties, where the goal is to retain the 11254 // function signature of the incoming argument and add control properties 11255 // on the return value. 11256 11257 // @ts-ignore 11258 return memoized; 11259 } 11260 11261 11262 11263 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/store/utils.js 11264 /** 11265 * External dependencies 11266 */ 11267 11268 11269 /** 11270 * WordPress dependencies 11271 */ 11272 11273 const EMPTY_ARRAY = []; 11274 11275 /** 11276 * Get a flattened and filtered list of template parts and the matching block for that template part. 11277 * 11278 * Takes a list of blocks defined within a template, and a list of template parts, and returns a 11279 * flattened list of template parts and the matching block for that template part. 11280 * 11281 * @param {Array} blocks Blocks to flatten. 11282 * @param {?Array} templateParts Available template parts. 11283 * @return {Array} An array of template parts and their blocks. 11284 */ 11285 function getFilteredTemplatePartBlocks(blocks = EMPTY_ARRAY, templateParts) { 11286 const templatePartsById = templateParts ? 11287 // Key template parts by their ID. 11288 templateParts.reduce((newTemplateParts, part) => ({ 11289 ...newTemplateParts, 11290 [part.id]: part 11291 }), {}) : {}; 11292 const result = []; 11293 11294 // Iterate over all blocks, recursing into inner blocks. 11295 // Output will be based on a depth-first traversal. 11296 const stack = [...blocks]; 11297 while (stack.length) { 11298 const { 11299 innerBlocks, 11300 ...block 11301 } = stack.shift(); 11302 // Place inner blocks at the beginning of the stack to preserve order. 11303 stack.unshift(...innerBlocks); 11304 if ((0,external_wp_blocks_namespaceObject.isTemplatePart)(block)) { 11305 const { 11306 attributes: { 11307 theme, 11308 slug 11309 } 11310 } = block; 11311 const templatePartId = `$theme}//${slug}`; 11312 const templatePart = templatePartsById[templatePartId]; 11313 11314 // Only add to output if the found template part block is in the list of available template parts. 11315 if (templatePart) { 11316 result.push({ 11317 templatePart, 11318 block 11319 }); 11320 } 11321 } 11322 } 11323 return result; 11324 } 11325 const memoizedGetFilteredTemplatePartBlocks = memize(getFilteredTemplatePartBlocks); 11326 11327 11328 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/store/selectors.js 11329 /** 11330 * WordPress dependencies 11331 */ 11332 11333 11334 11335 11336 11337 11338 11339 11340 /** 11341 * Internal dependencies 11342 */ 11343 11344 11345 11346 11347 /** 11348 * @typedef {'template'|'template_type'} TemplateType Template type. 11349 */ 11350 11351 /** 11352 * Returns whether the given feature is enabled or not. 11353 * 11354 * @deprecated 11355 * @param {Object} state Global application state. 11356 * @param {string} featureName Feature slug. 11357 * 11358 * @return {boolean} Is active. 11359 */ 11360 const selectors_isFeatureActive = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (_, featureName) => { 11361 external_wp_deprecated_default()(`select( 'core/edit-site' ).isFeatureActive`, { 11362 since: '6.0', 11363 alternative: `select( 'core/preferences' ).get` 11364 }); 11365 return !!select(external_wp_preferences_namespaceObject.store).get('core/edit-site', featureName); 11366 }); 11367 11368 /** 11369 * Returns the current editing canvas device type. 11370 * 11371 * @deprecated 11372 * 11373 * @param {Object} state Global application state. 11374 * 11375 * @return {string} Device type. 11376 */ 11377 const __experimentalGetPreviewDeviceType = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => () => { 11378 external_wp_deprecated_default()(`select( 'core/edit-site' ).__experimentalGetPreviewDeviceType`, { 11379 since: '6.5', 11380 version: '6.7', 11381 alternative: `select( 'core/editor' ).getDeviceType` 11382 }); 11383 return select(external_wp_editor_namespaceObject.store).getDeviceType(); 11384 }); 11385 11386 /** 11387 * Returns whether the current user can create media or not. 11388 * 11389 * @param {Object} state Global application state. 11390 * 11391 * @return {Object} Whether the current user can create media or not. 11392 */ 11393 const getCanUserCreateMedia = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => () => select(external_wp_coreData_namespaceObject.store).canUser('create', 'media')); 11394 11395 /** 11396 * Returns any available Reusable blocks. 11397 * 11398 * @param {Object} state Global application state. 11399 * 11400 * @return {Array} The available reusable blocks. 11401 */ 11402 const getReusableBlocks = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => () => { 11403 external_wp_deprecated_default()("select( 'core/core' ).getEntityRecords( 'postType', 'wp_block' )", { 11404 since: '6.5', 11405 version: '6.8' 11406 }); 11407 const isWeb = external_wp_element_namespaceObject.Platform.OS === 'web'; 11408 return isWeb ? select(external_wp_coreData_namespaceObject.store).getEntityRecords('postType', 'wp_block', { 11409 per_page: -1 11410 }) : []; 11411 }); 11412 11413 /** 11414 * Returns the site editor settings. 11415 * 11416 * @param {Object} state Global application state. 11417 * 11418 * @return {Object} Settings. 11419 */ 11420 function getSettings(state) { 11421 // It is important that we don't inject anything into these settings locally. 11422 // The reason for this is that we have an effect in place that calls setSettings based on the previous value of getSettings. 11423 // If we add computed settings here, we'll be adding these computed settings to the state which is very unexpected. 11424 return state.settings; 11425 } 11426 11427 /** 11428 * @deprecated 11429 */ 11430 function getHomeTemplateId() { 11431 external_wp_deprecated_default()("select( 'core/edit-site' ).getHomeTemplateId", { 11432 since: '6.2', 11433 version: '6.4' 11434 }); 11435 } 11436 11437 /** 11438 * Returns the current edited post type (wp_template or wp_template_part). 11439 * 11440 * @param {Object} state Global application state. 11441 * 11442 * @return {TemplateType?} Template type. 11443 */ 11444 function getEditedPostType(state) { 11445 return state.editedPost.postType; 11446 } 11447 11448 /** 11449 * Returns the ID of the currently edited template or template part. 11450 * 11451 * @param {Object} state Global application state. 11452 * 11453 * @return {string?} Post ID. 11454 */ 11455 function getEditedPostId(state) { 11456 return state.editedPost.id; 11457 } 11458 11459 /** 11460 * Returns the edited post's context object. 11461 * 11462 * @deprecated 11463 * @param {Object} state Global application state. 11464 * 11465 * @return {Object} Page. 11466 */ 11467 function getEditedPostContext(state) { 11468 return state.editedPost.context; 11469 } 11470 11471 /** 11472 * Returns the current page object. 11473 * 11474 * @deprecated 11475 * @param {Object} state Global application state. 11476 * 11477 * @return {Object} Page. 11478 */ 11479 function getPage(state) { 11480 return { 11481 context: state.editedPost.context 11482 }; 11483 } 11484 11485 /** 11486 * Returns true if the inserter is opened. 11487 * 11488 * @deprecated 11489 * 11490 * @param {Object} state Global application state. 11491 * 11492 * @return {boolean} Whether the inserter is opened. 11493 */ 11494 const isInserterOpened = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => () => { 11495 external_wp_deprecated_default()(`select( 'core/edit-site' ).isInserterOpened`, { 11496 since: '6.5', 11497 alternative: `select( 'core/editor' ).isInserterOpened` 11498 }); 11499 return select(external_wp_editor_namespaceObject.store).isInserterOpened(); 11500 }); 11501 11502 /** 11503 * Get the insertion point for the inserter. 11504 * 11505 * @deprecated 11506 * 11507 * @param {Object} state Global application state. 11508 * 11509 * @return {Object} The root client ID, index to insert at and starting filter value. 11510 */ 11511 const __experimentalGetInsertionPoint = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => () => { 11512 external_wp_deprecated_default()(`select( 'core/edit-site' ).__experimentalGetInsertionPoint`, { 11513 since: '6.5', 11514 version: '6.7' 11515 }); 11516 return unlock(select(external_wp_editor_namespaceObject.store)).getInsertionPoint(); 11517 }); 11518 11519 /** 11520 * Returns true if the list view is opened. 11521 * 11522 * @param {Object} state Global application state. 11523 * 11524 * @return {boolean} Whether the list view is opened. 11525 */ 11526 const isListViewOpened = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => () => { 11527 external_wp_deprecated_default()(`select( 'core/edit-site' ).isListViewOpened`, { 11528 since: '6.5', 11529 alternative: `select( 'core/editor' ).isListViewOpened` 11530 }); 11531 return select(external_wp_editor_namespaceObject.store).isListViewOpened(); 11532 }); 11533 11534 /** 11535 * Returns the current opened/closed state of the save panel. 11536 * 11537 * @param {Object} state Global application state. 11538 * 11539 * @return {boolean} True if the save panel should be open; false if closed. 11540 */ 11541 function isSaveViewOpened(state) { 11542 return state.saveViewPanel; 11543 } 11544 11545 /** 11546 * Returns the template parts and their blocks for the current edited template. 11547 * 11548 * @param {Object} state Global application state. 11549 * @return {Array} Template parts and their blocks in an array. 11550 */ 11551 const getCurrentTemplateTemplateParts = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => () => { 11552 const templateParts = select(external_wp_coreData_namespaceObject.store).getEntityRecords('postType', TEMPLATE_PART_POST_TYPE, { 11553 per_page: -1 11554 }); 11555 const clientIds = select(external_wp_blockEditor_namespaceObject.store).getBlocksByName('core/template-part'); 11556 const blocks = select(external_wp_blockEditor_namespaceObject.store).getBlocksByClientId(clientIds); 11557 return memoizedGetFilteredTemplatePartBlocks(blocks, templateParts); 11558 }); 11559 11560 /** 11561 * Returns the current editing mode. 11562 * 11563 * @param {Object} state Global application state. 11564 * 11565 * @return {string} Editing mode. 11566 */ 11567 const getEditorMode = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => () => { 11568 return select(external_wp_preferences_namespaceObject.store).get('core', 'editorMode'); 11569 }); 11570 11571 /** 11572 * @deprecated 11573 */ 11574 function getCurrentTemplateNavigationPanelSubMenu() { 11575 external_wp_deprecated_default()("dispatch( 'core/edit-site' ).getCurrentTemplateNavigationPanelSubMenu", { 11576 since: '6.2', 11577 version: '6.4' 11578 }); 11579 } 11580 11581 /** 11582 * @deprecated 11583 */ 11584 function getNavigationPanelActiveMenu() { 11585 external_wp_deprecated_default()("dispatch( 'core/edit-site' ).getNavigationPanelActiveMenu", { 11586 since: '6.2', 11587 version: '6.4' 11588 }); 11589 } 11590 11591 /** 11592 * @deprecated 11593 */ 11594 function isNavigationOpened() { 11595 external_wp_deprecated_default()("dispatch( 'core/edit-site' ).isNavigationOpened", { 11596 since: '6.2', 11597 version: '6.4' 11598 }); 11599 } 11600 11601 /** 11602 * Whether or not the editor has a page loaded into it. 11603 * 11604 * @see setPage 11605 * 11606 * @param {Object} state Global application state. 11607 * 11608 * @return {boolean} Whether or not the editor has a page loaded into it. 11609 */ 11610 function isPage(state) { 11611 return !!state.editedPost.context?.postId; 11612 } 11613 11614 /** 11615 * Whether or not the editor allows only page content to be edited. 11616 * 11617 * @deprecated 11618 * 11619 * @return {boolean} Whether or not focus is on editing page content. 11620 */ 11621 function hasPageContentFocus() { 11622 external_wp_deprecated_default()(`select( 'core/edit-site' ).hasPageContentFocus`, { 11623 since: '6.5' 11624 }); 11625 return false; 11626 } 11627 11628 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/store/private-selectors.js 11629 /** 11630 * Returns the current canvas mode. 11631 * 11632 * @param {Object} state Global application state. 11633 * 11634 * @return {string} Canvas mode. 11635 */ 11636 function getCanvasMode(state) { 11637 return state.canvasMode; 11638 } 11639 11640 /** 11641 * Returns the editor canvas container view. 11642 * 11643 * @param {Object} state Global application state. 11644 * 11645 * @return {string} Editor canvas container view. 11646 */ 11647 function getEditorCanvasContainerView(state) { 11648 return state.editorCanvasContainerView; 11649 } 11650 11651 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/store/index.js 11652 /** 11653 * WordPress dependencies 11654 */ 11655 11656 11657 /** 11658 * Internal dependencies 11659 */ 11660 11661 11662 11663 11664 11665 11666 11667 const storeConfig = { 11668 reducer: store_reducer, 11669 actions: store_actions_namespaceObject, 11670 selectors: store_selectors_namespaceObject 11671 }; 11672 const store_store = (0,external_wp_data_namespaceObject.createReduxStore)(constants_STORE_NAME, storeConfig); 11673 (0,external_wp_data_namespaceObject.register)(store_store); 11674 unlock(store_store).registerPrivateSelectors(private_selectors_namespaceObject); 11675 unlock(store_store).registerPrivateActions(private_actions_namespaceObject); 11676 11677 ;// CONCATENATED MODULE: external ["wp","keyboardShortcuts"] 11678 const external_wp_keyboardShortcuts_namespaceObject = window["wp"]["keyboardShortcuts"]; 11679 ;// CONCATENATED MODULE: external ["wp","commands"] 11680 const external_wp_commands_namespaceObject = window["wp"]["commands"]; 11681 ;// CONCATENATED MODULE: external ["wp","coreCommands"] 11682 const external_wp_coreCommands_namespaceObject = window["wp"]["coreCommands"]; 11683 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/navigation.js 11684 11685 /** 11686 * WordPress dependencies 11687 */ 11688 11689 const navigation = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { 11690 viewBox: "0 0 24 24", 11691 xmlns: "http://www.w3.org/2000/svg" 11692 }, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 11693 d: "M12 4c-4.4 0-8 3.6-8 8s3.6 8 8 8 8-3.6 8-8-3.6-8-8-8zm0 14.5c-3.6 0-6.5-2.9-6.5-6.5S8.4 5.5 12 5.5s6.5 2.9 6.5 6.5-2.9 6.5-6.5 6.5zM9 16l4.5-3L15 8.4l-4.5 3L9 16z" 11694 })); 11695 /* harmony default export */ const library_navigation = (navigation); 11696 11697 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/styles.js 11698 11699 /** 11700 * WordPress dependencies 11701 */ 11702 11703 const styles = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { 11704 viewBox: "0 0 24 24", 11705 xmlns: "http://www.w3.org/2000/svg" 11706 }, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 11707 d: "M12 4c-4.4 0-8 3.6-8 8v.1c0 4.1 3.2 7.5 7.2 7.9h.8c4.4 0 8-3.6 8-8s-3.6-8-8-8zm0 15V5c3.9 0 7 3.1 7 7s-3.1 7-7 7z" 11708 })); 11709 /* harmony default export */ const library_styles = (styles); 11710 11711 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/page.js 11712 11713 /** 11714 * WordPress dependencies 11715 */ 11716 11717 const page = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { 11718 xmlns: "http://www.w3.org/2000/svg", 11719 viewBox: "0 0 24 24" 11720 }, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 11721 d: "M15.5 7.5h-7V9h7V7.5Zm-7 3.5h7v1.5h-7V11Zm7 3.5h-7V16h7v-1.5Z" 11722 }), (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 11723 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" 11724 })); 11725 /* harmony default export */ const library_page = (page); 11726 11727 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/layout.js 11728 11729 /** 11730 * WordPress dependencies 11731 */ 11732 11733 const layout = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { 11734 xmlns: "http://www.w3.org/2000/svg", 11735 viewBox: "0 0 24 24" 11736 }, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 11737 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" 11738 })); 11739 /* harmony default export */ const library_layout = (layout); 11740 11741 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/symbol.js 11742 11743 /** 11744 * WordPress dependencies 11745 */ 11746 11747 const symbol = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { 11748 xmlns: "http://www.w3.org/2000/svg", 11749 viewBox: "0 0 24 24" 11750 }, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 11751 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" 11752 })); 11753 /* harmony default export */ const library_symbol = (symbol); 11754 11755 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/chevron-right.js 11756 11757 /** 11758 * WordPress dependencies 11759 */ 11760 11761 const chevronRight = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { 11762 xmlns: "http://www.w3.org/2000/svg", 11763 viewBox: "0 0 24 24" 11764 }, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 11765 d: "M10.6 6L9.4 7l4.6 5-4.6 5 1.2 1 5.4-6z" 11766 })); 11767 /* harmony default export */ const chevron_right = (chevronRight); 11768 11769 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/chevron-left.js 11770 11771 /** 11772 * WordPress dependencies 11773 */ 11774 11775 const chevronLeft = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { 11776 xmlns: "http://www.w3.org/2000/svg", 11777 viewBox: "0 0 24 24" 11778 }, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 11779 d: "M14.6 7l-1.2-1L8 12l5.4 6 1.2-1-4.6-5z" 11780 })); 11781 /* harmony default export */ const chevron_left = (chevronLeft); 11782 11783 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sidebar-button/index.js 11784 11785 /** 11786 * External dependencies 11787 */ 11788 11789 11790 /** 11791 * WordPress dependencies 11792 */ 11793 11794 function SidebarButton(props) { 11795 return (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 11796 ...props, 11797 className: classnames_default()('edit-site-sidebar-button', props.className) 11798 }); 11799 } 11800 11801 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sidebar-navigation-screen/index.js 11802 11803 /** 11804 * External dependencies 11805 */ 11806 11807 11808 /** 11809 * WordPress dependencies 11810 */ 11811 11812 11813 11814 11815 11816 11817 11818 /** 11819 * Internal dependencies 11820 */ 11821 11822 11823 11824 11825 const { 11826 useLocation: sidebar_navigation_screen_useLocation 11827 } = unlock(external_wp_router_namespaceObject.privateApis); 11828 function SidebarNavigationScreen({ 11829 isRoot, 11830 title, 11831 actions, 11832 meta, 11833 content, 11834 footer, 11835 description, 11836 backPath: backPathProp 11837 }) { 11838 const { 11839 dashboardLink, 11840 dashboardLinkText, 11841 previewingThemeName 11842 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 11843 const { 11844 getSettings 11845 } = unlock(select(store_store)); 11846 const currentlyPreviewingThemeId = currentlyPreviewingTheme(); 11847 return { 11848 dashboardLink: getSettings().__experimentalDashboardLink, 11849 dashboardLinkText: getSettings().__experimentalDashboardLinkText, 11850 // Do not call `getTheme` with null, it will cause a request to 11851 // the server. 11852 previewingThemeName: currentlyPreviewingThemeId ? select(external_wp_coreData_namespaceObject.store).getTheme(currentlyPreviewingThemeId)?.name?.rendered : undefined 11853 }; 11854 }, []); 11855 const location = sidebar_navigation_screen_useLocation(); 11856 const navigator = (0,external_wp_components_namespaceObject.__experimentalUseNavigator)(); 11857 const icon = (0,external_wp_i18n_namespaceObject.isRTL)() ? chevron_right : chevron_left; 11858 return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { 11859 className: classnames_default()('edit-site-sidebar-navigation-screen__main', { 11860 'has-footer': !!footer 11861 }), 11862 spacing: 0, 11863 justify: "flex-start" 11864 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { 11865 spacing: 4, 11866 alignment: "flex-start", 11867 className: "edit-site-sidebar-navigation-screen__title-icon" 11868 }, !isRoot && (0,external_React_.createElement)(SidebarButton, { 11869 onClick: () => { 11870 const backPath = backPathProp !== null && backPathProp !== void 0 ? backPathProp : location.state?.backPath; 11871 if (backPath) { 11872 navigator.goTo(backPath, { 11873 isBack: true 11874 }); 11875 } else { 11876 navigator.goToParent(); 11877 } 11878 }, 11879 icon: icon, 11880 label: (0,external_wp_i18n_namespaceObject.__)('Back'), 11881 showTooltip: false 11882 }), isRoot && (0,external_React_.createElement)(SidebarButton, { 11883 icon: icon, 11884 label: dashboardLinkText || (0,external_wp_i18n_namespaceObject.__)('Go to the Dashboard'), 11885 href: dashboardLink || 'index.php' 11886 }), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHeading, { 11887 className: "edit-site-sidebar-navigation-screen__title", 11888 color: '#e0e0e0' /* $gray-200 */, 11889 level: 1, 11890 size: 20 11891 }, !isPreviewingTheme() ? title : (0,external_wp_i18n_namespaceObject.sprintf)('Previewing %1$s: %2$s', previewingThemeName, title)), actions && (0,external_React_.createElement)("div", { 11892 className: "edit-site-sidebar-navigation-screen__actions" 11893 }, actions)), meta && (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)("div", { 11894 className: "edit-site-sidebar-navigation-screen__meta" 11895 }, meta)), (0,external_React_.createElement)("div", { 11896 className: "edit-site-sidebar-navigation-screen__content" 11897 }, description && (0,external_React_.createElement)("p", { 11898 className: "edit-site-sidebar-navigation-screen__description" 11899 }, description), content)), footer && (0,external_React_.createElement)("footer", { 11900 className: "edit-site-sidebar-navigation-screen__footer" 11901 }, footer)); 11902 } 11903 11904 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/icon/index.js 11905 /** 11906 * WordPress dependencies 11907 */ 11908 11909 11910 /** @typedef {{icon: JSX.Element, size?: number} & import('@wordpress/primitives').SVGProps} IconProps */ 11911 11912 /** 11913 * Return an SVG icon. 11914 * 11915 * @param {IconProps} props icon is the SVG component to render 11916 * size is a number specifiying the icon size in pixels 11917 * Other props will be passed to wrapped SVG component 11918 * @param {import('react').ForwardedRef<HTMLElement>} ref The forwarded ref to the SVG element. 11919 * 11920 * @return {JSX.Element} Icon component 11921 */ 11922 function icon_Icon({ 11923 icon, 11924 size = 24, 11925 ...props 11926 }, ref) { 11927 return (0,external_wp_element_namespaceObject.cloneElement)(icon, { 11928 width: size, 11929 height: size, 11930 ...props, 11931 ref 11932 }); 11933 } 11934 /* harmony default export */ const build_module_icon = ((0,external_wp_element_namespaceObject.forwardRef)(icon_Icon)); 11935 11936 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/chevron-left-small.js 11937 11938 /** 11939 * WordPress dependencies 11940 */ 11941 11942 const chevronLeftSmall = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { 11943 xmlns: "http://www.w3.org/2000/svg", 11944 viewBox: "0 0 24 24" 11945 }, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 11946 d: "m13.1 16-3.4-4 3.4-4 1.1 1-2.6 3 2.6 3-1.1 1z" 11947 })); 11948 /* harmony default export */ const chevron_left_small = (chevronLeftSmall); 11949 11950 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/chevron-right-small.js 11951 11952 /** 11953 * WordPress dependencies 11954 */ 11955 11956 const chevronRightSmall = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { 11957 xmlns: "http://www.w3.org/2000/svg", 11958 viewBox: "0 0 24 24" 11959 }, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 11960 d: "M10.8622 8.04053L14.2805 12.0286L10.8622 16.0167L9.72327 15.0405L12.3049 12.0286L9.72327 9.01672L10.8622 8.04053Z" 11961 })); 11962 /* harmony default export */ const chevron_right_small = (chevronRightSmall); 11963 11964 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sidebar-navigation-item/index.js 11965 11966 /** 11967 * External dependencies 11968 */ 11969 11970 11971 /** 11972 * WordPress dependencies 11973 */ 11974 11975 11976 11977 function SidebarNavigationItem({ 11978 className, 11979 icon, 11980 withChevron = false, 11981 suffix, 11982 children, 11983 ...props 11984 }) { 11985 return (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalItem, { 11986 className: classnames_default()('edit-site-sidebar-navigation-item', { 11987 'with-suffix': !withChevron && suffix 11988 }, className), 11989 ...props 11990 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { 11991 justify: "flex-start" 11992 }, icon && (0,external_React_.createElement)(build_module_icon, { 11993 style: { 11994 fill: 'currentcolor' 11995 }, 11996 icon: icon, 11997 size: 24 11998 }), (0,external_React_.createElement)(external_wp_components_namespaceObject.FlexBlock, null, children), withChevron && (0,external_React_.createElement)(build_module_icon, { 11999 icon: (0,external_wp_i18n_namespaceObject.isRTL)() ? chevron_left_small : chevron_right_small, 12000 className: "edit-site-sidebar-navigation-item__drilldown-indicator", 12001 size: 24 12002 }), !withChevron && suffix)); 12003 } 12004 12005 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/seen.js 12006 12007 /** 12008 * WordPress dependencies 12009 */ 12010 12011 const seen = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { 12012 viewBox: "0 0 24 24", 12013 xmlns: "http://www.w3.org/2000/svg" 12014 }, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 12015 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" 12016 })); 12017 /* harmony default export */ const library_seen = (seen); 12018 12019 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/pencil.js 12020 12021 /** 12022 * WordPress dependencies 12023 */ 12024 12025 const pencil = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { 12026 xmlns: "http://www.w3.org/2000/svg", 12027 viewBox: "0 0 24 24" 12028 }, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 12029 d: "m19 7-3-3-8.5 8.5-1 4 4-1L19 7Zm-7 11.5H5V20h7v-1.5Z" 12030 })); 12031 /* harmony default export */ const library_pencil = (pencil); 12032 12033 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/edit.js 12034 /** 12035 * Internal dependencies 12036 */ 12037 12038 12039 /* harmony default export */ const edit = (library_pencil); 12040 12041 ;// CONCATENATED MODULE: external ["wp","keycodes"] 12042 const external_wp_keycodes_namespaceObject = window["wp"]["keycodes"]; 12043 // EXTERNAL MODULE: ./node_modules/deepmerge/dist/cjs.js 12044 var cjs = __webpack_require__(66); 12045 var cjs_default = /*#__PURE__*/__webpack_require__.n(cjs); 12046 ;// CONCATENATED MODULE: ./node_modules/is-plain-object/dist/is-plain-object.mjs 12047 /*! 12048 * is-plain-object <https://github.com/jonschlinkert/is-plain-object> 12049 * 12050 * Copyright (c) 2014-2017, Jon Schlinkert. 12051 * Released under the MIT License. 12052 */ 12053 12054 function isObject(o) { 12055 return Object.prototype.toString.call(o) === '[object Object]'; 12056 } 12057 12058 function isPlainObject(o) { 12059 var ctor,prot; 12060 12061 if (isObject(o) === false) return false; 12062 12063 // If has modified constructor 12064 ctor = o.constructor; 12065 if (ctor === undefined) return true; 12066 12067 // If has modified prototype 12068 prot = ctor.prototype; 12069 if (isObject(prot) === false) return false; 12070 12071 // If constructor does not have an Object-specific method 12072 if (prot.hasOwnProperty('isPrototypeOf') === false) { 12073 return false; 12074 } 12075 12076 // Most likely a plain Object 12077 return true; 12078 } 12079 12080 12081 12082 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/global-styles/global-styles-provider.js 12083 12084 /** 12085 * External dependencies 12086 */ 12087 12088 12089 12090 /** 12091 * WordPress dependencies 12092 */ 12093 12094 12095 12096 12097 12098 /** 12099 * Internal dependencies 12100 */ 12101 12102 const { 12103 GlobalStylesContext: global_styles_provider_GlobalStylesContext, 12104 cleanEmptyObject: global_styles_provider_cleanEmptyObject 12105 } = unlock(external_wp_blockEditor_namespaceObject.privateApis); 12106 function mergeBaseAndUserConfigs(base, user) { 12107 return cjs_default()(base, user, { 12108 // We only pass as arrays the presets, 12109 // in which case we want the new array of values 12110 // to override the old array (no merging). 12111 isMergeableObject: isPlainObject 12112 }); 12113 } 12114 function useGlobalStylesUserConfig() { 12115 const { 12116 globalStylesId, 12117 isReady, 12118 settings, 12119 styles 12120 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 12121 const { 12122 getEditedEntityRecord, 12123 hasFinishedResolution 12124 } = select(external_wp_coreData_namespaceObject.store); 12125 const _globalStylesId = select(external_wp_coreData_namespaceObject.store).__experimentalGetCurrentGlobalStylesId(); 12126 const record = _globalStylesId ? getEditedEntityRecord('root', 'globalStyles', _globalStylesId) : undefined; 12127 let hasResolved = false; 12128 if (hasFinishedResolution('__experimentalGetCurrentGlobalStylesId')) { 12129 hasResolved = _globalStylesId ? hasFinishedResolution('getEditedEntityRecord', ['root', 'globalStyles', _globalStylesId]) : true; 12130 } 12131 return { 12132 globalStylesId: _globalStylesId, 12133 isReady: hasResolved, 12134 settings: record?.settings, 12135 styles: record?.styles 12136 }; 12137 }, []); 12138 const { 12139 getEditedEntityRecord 12140 } = (0,external_wp_data_namespaceObject.useSelect)(external_wp_coreData_namespaceObject.store); 12141 const { 12142 editEntityRecord 12143 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store); 12144 const config = (0,external_wp_element_namespaceObject.useMemo)(() => { 12145 return { 12146 settings: settings !== null && settings !== void 0 ? settings : {}, 12147 styles: styles !== null && styles !== void 0 ? styles : {} 12148 }; 12149 }, [settings, styles]); 12150 const setConfig = (0,external_wp_element_namespaceObject.useCallback)((callback, options = {}) => { 12151 var _record$styles, _record$settings; 12152 const record = getEditedEntityRecord('root', 'globalStyles', globalStylesId); 12153 const currentConfig = { 12154 styles: (_record$styles = record?.styles) !== null && _record$styles !== void 0 ? _record$styles : {}, 12155 settings: (_record$settings = record?.settings) !== null && _record$settings !== void 0 ? _record$settings : {} 12156 }; 12157 const updatedConfig = callback(currentConfig); 12158 editEntityRecord('root', 'globalStyles', globalStylesId, { 12159 styles: global_styles_provider_cleanEmptyObject(updatedConfig.styles) || {}, 12160 settings: global_styles_provider_cleanEmptyObject(updatedConfig.settings) || {} 12161 }, options); 12162 }, [globalStylesId]); 12163 return [isReady, config, setConfig]; 12164 } 12165 function useGlobalStylesBaseConfig() { 12166 const baseConfig = (0,external_wp_data_namespaceObject.useSelect)(select => { 12167 return select(external_wp_coreData_namespaceObject.store).__experimentalGetCurrentThemeBaseGlobalStyles(); 12168 }, []); 12169 return [!!baseConfig, baseConfig]; 12170 } 12171 function useGlobalStylesContext() { 12172 const [isUserConfigReady, userConfig, setUserConfig] = useGlobalStylesUserConfig(); 12173 const [isBaseConfigReady, baseConfig] = useGlobalStylesBaseConfig(); 12174 const mergedConfig = (0,external_wp_element_namespaceObject.useMemo)(() => { 12175 if (!baseConfig || !userConfig) { 12176 return {}; 12177 } 12178 return mergeBaseAndUserConfigs(baseConfig, userConfig); 12179 }, [userConfig, baseConfig]); 12180 const context = (0,external_wp_element_namespaceObject.useMemo)(() => { 12181 return { 12182 isReady: isUserConfigReady && isBaseConfigReady, 12183 user: userConfig, 12184 base: baseConfig, 12185 merged: mergedConfig, 12186 setUserConfig 12187 }; 12188 }, [mergedConfig, userConfig, baseConfig, setUserConfig, isUserConfigReady, isBaseConfigReady]); 12189 return context; 12190 } 12191 function GlobalStylesProvider({ 12192 children 12193 }) { 12194 const context = useGlobalStylesContext(); 12195 if (!context.isReady) { 12196 return null; 12197 } 12198 return (0,external_React_.createElement)(global_styles_provider_GlobalStylesContext.Provider, { 12199 value: context 12200 }, children); 12201 } 12202 12203 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/global-styles/preview.js 12204 12205 /** 12206 * WordPress dependencies 12207 */ 12208 12209 12210 12211 12212 12213 /** 12214 * Internal dependencies 12215 */ 12216 12217 12218 const { 12219 useGlobalStyle: preview_useGlobalStyle, 12220 useGlobalStylesOutput 12221 } = unlock(external_wp_blockEditor_namespaceObject.privateApis); 12222 const firstFrame = { 12223 start: { 12224 scale: 1, 12225 opacity: 1 12226 }, 12227 hover: { 12228 scale: 0, 12229 opacity: 0 12230 } 12231 }; 12232 const midFrame = { 12233 hover: { 12234 opacity: 1 12235 }, 12236 start: { 12237 opacity: 0.5 12238 } 12239 }; 12240 const secondFrame = { 12241 hover: { 12242 scale: 1, 12243 opacity: 1 12244 }, 12245 start: { 12246 scale: 0, 12247 opacity: 0 12248 } 12249 }; 12250 const normalizedWidth = 248; 12251 const normalizedHeight = 152; 12252 const normalizedColorSwatchSize = 32; 12253 12254 // Throttle options for useThrottle. Must be defined outside of the component, 12255 // so that the object reference is the same on each render. 12256 const THROTTLE_OPTIONS = { 12257 leading: true, 12258 trailing: true 12259 }; 12260 const StylesPreview = ({ 12261 label, 12262 isFocused, 12263 withHoverView 12264 }) => { 12265 const [fontWeight] = preview_useGlobalStyle('typography.fontWeight'); 12266 const [fontFamily = 'serif'] = preview_useGlobalStyle('typography.fontFamily'); 12267 const [headingFontFamily = fontFamily] = preview_useGlobalStyle('elements.h1.typography.fontFamily'); 12268 const [headingFontWeight = fontWeight] = preview_useGlobalStyle('elements.h1.typography.fontWeight'); 12269 const [textColor = 'black'] = preview_useGlobalStyle('color.text'); 12270 const [headingColor = textColor] = preview_useGlobalStyle('elements.h1.color.text'); 12271 const [backgroundColor = 'white'] = preview_useGlobalStyle('color.background'); 12272 const [gradientValue] = preview_useGlobalStyle('color.gradient'); 12273 const [styles] = useGlobalStylesOutput(); 12274 const disableMotion = (0,external_wp_compose_namespaceObject.useReducedMotion)(); 12275 const [isHovered, setIsHovered] = (0,external_wp_element_namespaceObject.useState)(false); 12276 const [containerResizeListener, { 12277 width 12278 }] = (0,external_wp_compose_namespaceObject.useResizeObserver)(); 12279 const [throttledWidth, setThrottledWidthState] = (0,external_wp_element_namespaceObject.useState)(width); 12280 const [ratioState, setRatioState] = (0,external_wp_element_namespaceObject.useState)(); 12281 const setThrottledWidth = (0,external_wp_compose_namespaceObject.useThrottle)(setThrottledWidthState, 250, THROTTLE_OPTIONS); 12282 12283 // Must use useLayoutEffect to avoid a flash of the iframe at the wrong 12284 // size before the width is set. 12285 (0,external_wp_element_namespaceObject.useLayoutEffect)(() => { 12286 if (width) { 12287 setThrottledWidth(width); 12288 } 12289 }, [width, setThrottledWidth]); 12290 12291 // Must use useLayoutEffect to avoid a flash of the iframe at the wrong 12292 // size before the width is set. 12293 (0,external_wp_element_namespaceObject.useLayoutEffect)(() => { 12294 const newRatio = throttledWidth ? throttledWidth / normalizedWidth : 1; 12295 const ratioDiff = newRatio - (ratioState || 0); 12296 12297 // Only update the ratio state if the difference is big enough 12298 // or if the ratio state is not yet set. This is to avoid an 12299 // endless loop of updates at particular viewport heights when the 12300 // presence of a scrollbar causes the width to change slightly. 12301 const isRatioDiffBigEnough = Math.abs(ratioDiff) > 0.1; 12302 if (isRatioDiffBigEnough || !ratioState) { 12303 setRatioState(newRatio); 12304 } 12305 }, [throttledWidth, ratioState]); 12306 12307 // Set a fallbackRatio to use before the throttled ratio has been set. 12308 const fallbackRatio = width ? width / normalizedWidth : 1; 12309 // Use the throttled ratio if it has been calculated, otherwise 12310 // use the fallback ratio. The throttled ratio is used to avoid 12311 // an endless loop of updates at particular viewport heights. 12312 // See: https://github.com/WordPress/gutenberg/issues/55112 12313 const ratio = ratioState ? ratioState : fallbackRatio; 12314 const { 12315 paletteColors, 12316 highlightedColors 12317 } = useStylesPreviewColors(); 12318 12319 // Reset leaked styles from WP common.css and remove main content layout padding and border. 12320 const editorStyles = (0,external_wp_element_namespaceObject.useMemo)(() => { 12321 if (styles) { 12322 return [...styles, { 12323 css: 'html{overflow:hidden}body{min-width: 0;padding: 0;border: none;}', 12324 isGlobalStyles: true 12325 }]; 12326 } 12327 return styles; 12328 }, [styles]); 12329 const isReady = !!width; 12330 return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)("div", { 12331 style: { 12332 position: 'relative' 12333 } 12334 }, containerResizeListener), isReady && (0,external_React_.createElement)(external_wp_blockEditor_namespaceObject.__unstableIframe, { 12335 className: "edit-site-global-styles-preview__iframe", 12336 style: { 12337 width: '100%', 12338 height: normalizedHeight * ratio 12339 }, 12340 onMouseEnter: () => setIsHovered(true), 12341 onMouseLeave: () => setIsHovered(false), 12342 tabIndex: -1 12343 }, (0,external_React_.createElement)(external_wp_blockEditor_namespaceObject.__unstableEditorStyles, { 12344 styles: editorStyles 12345 }), (0,external_React_.createElement)(external_wp_components_namespaceObject.__unstableMotion.div, { 12346 style: { 12347 height: normalizedHeight * ratio, 12348 width: '100%', 12349 background: gradientValue !== null && gradientValue !== void 0 ? gradientValue : backgroundColor, 12350 cursor: withHoverView ? 'pointer' : undefined 12351 }, 12352 initial: "start", 12353 animate: (isHovered || isFocused) && !disableMotion && label ? 'hover' : 'start' 12354 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__unstableMotion.div, { 12355 variants: firstFrame, 12356 style: { 12357 height: '100%', 12358 overflow: 'hidden' 12359 } 12360 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { 12361 spacing: 10 * ratio, 12362 justify: "center", 12363 style: { 12364 height: '100%', 12365 overflow: 'hidden' 12366 } 12367 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__unstableMotion.div, { 12368 style: { 12369 fontFamily: headingFontFamily, 12370 fontSize: 65 * ratio, 12371 color: headingColor, 12372 fontWeight: headingFontWeight 12373 }, 12374 animate: { 12375 scale: 1, 12376 opacity: 1 12377 }, 12378 initial: { 12379 scale: 0.1, 12380 opacity: 0 12381 }, 12382 transition: { 12383 delay: 0.3, 12384 type: 'tween' 12385 } 12386 }, "Aa"), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { 12387 spacing: 4 * ratio 12388 }, highlightedColors.map(({ 12389 slug, 12390 color 12391 }, index) => (0,external_React_.createElement)(external_wp_components_namespaceObject.__unstableMotion.div, { 12392 key: slug, 12393 style: { 12394 height: normalizedColorSwatchSize * ratio, 12395 width: normalizedColorSwatchSize * ratio, 12396 background: color, 12397 borderRadius: normalizedColorSwatchSize * ratio / 2 12398 }, 12399 animate: { 12400 scale: 1, 12401 opacity: 1 12402 }, 12403 initial: { 12404 scale: 0.1, 12405 opacity: 0 12406 }, 12407 transition: { 12408 delay: index === 1 ? 0.2 : 0.1 12409 } 12410 }))))), (0,external_React_.createElement)(external_wp_components_namespaceObject.__unstableMotion.div, { 12411 variants: withHoverView && midFrame, 12412 style: { 12413 height: '100%', 12414 width: '100%', 12415 position: 'absolute', 12416 top: 0, 12417 overflow: 'hidden', 12418 filter: 'blur(60px)', 12419 opacity: 0.1 12420 } 12421 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { 12422 spacing: 0, 12423 justify: "flex-start", 12424 style: { 12425 height: '100%', 12426 overflow: 'hidden' 12427 } 12428 }, paletteColors.slice(0, 4).map(({ 12429 color 12430 }, index) => (0,external_React_.createElement)("div", { 12431 key: index, 12432 style: { 12433 height: '100%', 12434 background: color, 12435 flexGrow: 1 12436 } 12437 })))), (0,external_React_.createElement)(external_wp_components_namespaceObject.__unstableMotion.div, { 12438 variants: secondFrame, 12439 style: { 12440 height: '100%', 12441 width: '100%', 12442 overflow: 'hidden', 12443 position: 'absolute', 12444 top: 0 12445 } 12446 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { 12447 spacing: 3 * ratio, 12448 justify: "center", 12449 style: { 12450 height: '100%', 12451 overflow: 'hidden', 12452 padding: 10 * ratio, 12453 boxSizing: 'border-box' 12454 } 12455 }, label && (0,external_React_.createElement)("div", { 12456 style: { 12457 fontSize: 40 * ratio, 12458 fontFamily: headingFontFamily, 12459 color: headingColor, 12460 fontWeight: headingFontWeight, 12461 lineHeight: '1em', 12462 textAlign: 'center' 12463 } 12464 }, label)))))); 12465 }; 12466 /* harmony default export */ const preview = (StylesPreview); 12467 12468 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/global-styles/style-variations-container.js 12469 12470 /** 12471 * External dependencies 12472 */ 12473 12474 12475 /** 12476 * WordPress dependencies 12477 */ 12478 12479 12480 12481 12482 12483 12484 12485 12486 /** 12487 * Internal dependencies 12488 */ 12489 12490 12491 12492 const { 12493 GlobalStylesContext: style_variations_container_GlobalStylesContext, 12494 areGlobalStyleConfigsEqual 12495 } = unlock(external_wp_blockEditor_namespaceObject.privateApis); 12496 function Variation({ 12497 variation 12498 }) { 12499 const [isFocused, setIsFocused] = (0,external_wp_element_namespaceObject.useState)(false); 12500 const { 12501 base, 12502 user, 12503 setUserConfig 12504 } = (0,external_wp_element_namespaceObject.useContext)(style_variations_container_GlobalStylesContext); 12505 const context = (0,external_wp_element_namespaceObject.useMemo)(() => { 12506 var _variation$settings, _variation$styles; 12507 return { 12508 user: { 12509 settings: (_variation$settings = variation.settings) !== null && _variation$settings !== void 0 ? _variation$settings : {}, 12510 styles: (_variation$styles = variation.styles) !== null && _variation$styles !== void 0 ? _variation$styles : {} 12511 }, 12512 base, 12513 merged: mergeBaseAndUserConfigs(base, variation), 12514 setUserConfig: () => {} 12515 }; 12516 }, [variation, base]); 12517 const selectVariation = () => { 12518 setUserConfig(() => { 12519 return { 12520 settings: variation.settings, 12521 styles: variation.styles 12522 }; 12523 }); 12524 }; 12525 const selectOnEnter = event => { 12526 if (event.keyCode === external_wp_keycodes_namespaceObject.ENTER) { 12527 event.preventDefault(); 12528 selectVariation(); 12529 } 12530 }; 12531 const isActive = (0,external_wp_element_namespaceObject.useMemo)(() => { 12532 return areGlobalStyleConfigsEqual(user, variation); 12533 }, [user, variation]); 12534 let label = variation?.title; 12535 if (variation?.description) { 12536 label = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %1$s: variation title. %2$s variation description. */ 12537 (0,external_wp_i18n_namespaceObject.__)('%1$s (%2$s)'), variation?.title, variation?.description); 12538 } 12539 return (0,external_React_.createElement)(style_variations_container_GlobalStylesContext.Provider, { 12540 value: context 12541 }, (0,external_React_.createElement)("div", { 12542 className: classnames_default()('edit-site-global-styles-variations_item', { 12543 'is-active': isActive 12544 }), 12545 role: "button", 12546 onClick: selectVariation, 12547 onKeyDown: selectOnEnter, 12548 tabIndex: "0", 12549 "aria-label": label, 12550 "aria-current": isActive, 12551 onFocus: () => setIsFocused(true), 12552 onBlur: () => setIsFocused(false) 12553 }, (0,external_React_.createElement)("div", { 12554 className: "edit-site-global-styles-variations_item-preview" 12555 }, (0,external_React_.createElement)(preview, { 12556 label: variation?.title, 12557 isFocused: isFocused, 12558 withHoverView: true 12559 })))); 12560 } 12561 function StyleVariationsContainer() { 12562 const variations = (0,external_wp_data_namespaceObject.useSelect)(select => { 12563 return select(external_wp_coreData_namespaceObject.store).__experimentalGetCurrentThemeGlobalStylesVariations(); 12564 }, []); 12565 const withEmptyVariation = (0,external_wp_element_namespaceObject.useMemo)(() => { 12566 return [{ 12567 title: (0,external_wp_i18n_namespaceObject.__)('Default'), 12568 settings: {}, 12569 styles: {} 12570 }, ...(variations !== null && variations !== void 0 ? variations : []).map(variation => { 12571 var _variation$settings2, _variation$styles2; 12572 return { 12573 ...variation, 12574 settings: (_variation$settings2 = variation.settings) !== null && _variation$settings2 !== void 0 ? _variation$settings2 : {}, 12575 styles: (_variation$styles2 = variation.styles) !== null && _variation$styles2 !== void 0 ? _variation$styles2 : {} 12576 }; 12577 })]; 12578 }, [variations]); 12579 return (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalGrid, { 12580 columns: 2, 12581 className: "edit-site-global-styles-style-variations-container" 12582 }, withEmptyVariation.map((variation, index) => (0,external_React_.createElement)(Variation, { 12583 key: index, 12584 variation: variation 12585 }))); 12586 } 12587 12588 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/block-editor/resize-handle.js 12589 12590 /** 12591 * WordPress dependencies 12592 */ 12593 12594 12595 12596 const DELTA_DISTANCE = 20; // The distance to resize per keydown in pixels. 12597 12598 function ResizeHandle({ 12599 variation = 'default', 12600 direction, 12601 resizeWidthBy 12602 }) { 12603 function handleKeyDown(event) { 12604 const { 12605 keyCode 12606 } = event; 12607 if (direction === 'left' && keyCode === external_wp_keycodes_namespaceObject.LEFT || direction === 'right' && keyCode === external_wp_keycodes_namespaceObject.RIGHT) { 12608 resizeWidthBy(DELTA_DISTANCE); 12609 } else if (direction === 'left' && keyCode === external_wp_keycodes_namespaceObject.RIGHT || direction === 'right' && keyCode === external_wp_keycodes_namespaceObject.LEFT) { 12610 resizeWidthBy(-DELTA_DISTANCE); 12611 } 12612 } 12613 return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)("button", { 12614 className: `resizable-editor__drag-handle is-$direction} is-variation-$variation}`, 12615 "aria-label": (0,external_wp_i18n_namespaceObject.__)('Drag to resize'), 12616 "aria-describedby": `resizable-editor__resize-help-$direction}`, 12617 onKeyDown: handleKeyDown, 12618 type: "button" 12619 }), (0,external_React_.createElement)(external_wp_components_namespaceObject.VisuallyHidden, { 12620 id: `resizable-editor__resize-help-$direction}` 12621 }, (0,external_wp_i18n_namespaceObject.__)('Use left and right arrow keys to resize the canvas.'))); 12622 } 12623 12624 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/block-editor/resizable-editor.js 12625 12626 /** 12627 * WordPress dependencies 12628 */ 12629 12630 12631 12632 /** 12633 * Internal dependencies 12634 */ 12635 12636 12637 // Removes the inline styles in the drag handles. 12638 const HANDLE_STYLES_OVERRIDE = { 12639 position: undefined, 12640 userSelect: undefined, 12641 cursor: undefined, 12642 width: undefined, 12643 height: undefined, 12644 top: undefined, 12645 right: undefined, 12646 bottom: undefined, 12647 left: undefined 12648 }; 12649 function ResizableEditor({ 12650 enableResizing, 12651 height, 12652 children 12653 }) { 12654 const [width, setWidth] = (0,external_wp_element_namespaceObject.useState)('100%'); 12655 const resizableRef = (0,external_wp_element_namespaceObject.useRef)(); 12656 const resizeWidthBy = (0,external_wp_element_namespaceObject.useCallback)(deltaPixels => { 12657 if (resizableRef.current) { 12658 setWidth(resizableRef.current.offsetWidth + deltaPixels); 12659 } 12660 }, []); 12661 return (0,external_React_.createElement)(external_wp_components_namespaceObject.ResizableBox, { 12662 ref: api => { 12663 resizableRef.current = api?.resizable; 12664 }, 12665 size: { 12666 width: enableResizing ? width : '100%', 12667 height: enableResizing && height ? height : '100%' 12668 }, 12669 onResizeStop: (event, direction, element) => { 12670 setWidth(element.style.width); 12671 }, 12672 minWidth: 300, 12673 maxWidth: "100%", 12674 maxHeight: "100%", 12675 enable: { 12676 left: enableResizing, 12677 right: enableResizing 12678 }, 12679 showHandle: enableResizing 12680 // The editor is centered horizontally, resizing it only 12681 // moves half the distance. Hence double the ratio to correctly 12682 // align the cursor to the resizer handle. 12683 , 12684 resizeRatio: 2, 12685 handleComponent: { 12686 left: (0,external_React_.createElement)(ResizeHandle, { 12687 direction: "left", 12688 resizeWidthBy: resizeWidthBy 12689 }), 12690 right: (0,external_React_.createElement)(ResizeHandle, { 12691 direction: "right", 12692 resizeWidthBy: resizeWidthBy 12693 }) 12694 }, 12695 handleClasses: undefined, 12696 handleStyles: { 12697 left: HANDLE_STYLES_OVERRIDE, 12698 right: HANDLE_STYLES_OVERRIDE 12699 } 12700 }, children); 12701 } 12702 /* harmony default export */ const resizable_editor = (ResizableEditor); 12703 12704 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/editor-canvas-container/index.js 12705 12706 /** 12707 * WordPress dependencies 12708 */ 12709 12710 12711 12712 12713 12714 12715 12716 12717 12718 12719 /** 12720 * Internal dependencies 12721 */ 12722 12723 12724 12725 12726 /** 12727 * Returns a translated string for the title of the editor canvas container. 12728 * 12729 * @param {string} view Editor canvas container view. 12730 * 12731 * @return {string} Translated string corresponding to value of view. Default is ''. 12732 */ 12733 function getEditorCanvasContainerTitle(view) { 12734 switch (view) { 12735 case 'style-book': 12736 return (0,external_wp_i18n_namespaceObject.__)('Style Book'); 12737 case 'global-styles-revisions': 12738 case 'global-styles-revisions:style-book': 12739 return (0,external_wp_i18n_namespaceObject.__)('Style Revisions'); 12740 default: 12741 return ''; 12742 } 12743 } 12744 12745 // Creates a private slot fill. 12746 const { 12747 createPrivateSlotFill 12748 } = unlock(external_wp_components_namespaceObject.privateApis); 12749 const SLOT_FILL_NAME = 'EditSiteEditorCanvasContainerSlot'; 12750 const { 12751 privateKey, 12752 Slot: EditorCanvasContainerSlot, 12753 Fill: EditorCanvasContainerFill 12754 } = createPrivateSlotFill(SLOT_FILL_NAME); 12755 function EditorCanvasContainer({ 12756 children, 12757 closeButtonLabel, 12758 onClose, 12759 enableResizing = false 12760 }) { 12761 const { 12762 editorCanvasContainerView, 12763 showListViewByDefault 12764 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 12765 const _editorCanvasContainerView = unlock(select(store_store)).getEditorCanvasContainerView(); 12766 const _showListViewByDefault = select(external_wp_preferences_namespaceObject.store).get('core', 'showListViewByDefault'); 12767 return { 12768 editorCanvasContainerView: _editorCanvasContainerView, 12769 showListViewByDefault: _showListViewByDefault 12770 }; 12771 }, []); 12772 const [isClosed, setIsClosed] = (0,external_wp_element_namespaceObject.useState)(false); 12773 const { 12774 setEditorCanvasContainerView 12775 } = unlock((0,external_wp_data_namespaceObject.useDispatch)(store_store)); 12776 const { 12777 setIsListViewOpened 12778 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_editor_namespaceObject.store); 12779 const focusOnMountRef = (0,external_wp_compose_namespaceObject.useFocusOnMount)('firstElement'); 12780 const sectionFocusReturnRef = (0,external_wp_compose_namespaceObject.useFocusReturn)(); 12781 const title = (0,external_wp_element_namespaceObject.useMemo)(() => getEditorCanvasContainerTitle(editorCanvasContainerView), [editorCanvasContainerView]); 12782 function onCloseContainer() { 12783 setIsListViewOpened(showListViewByDefault); 12784 setEditorCanvasContainerView(undefined); 12785 setIsClosed(true); 12786 if (typeof onClose === 'function') { 12787 onClose(); 12788 } 12789 } 12790 function closeOnEscape(event) { 12791 if (event.keyCode === external_wp_keycodes_namespaceObject.ESCAPE && !event.defaultPrevented) { 12792 event.preventDefault(); 12793 onCloseContainer(); 12794 } 12795 } 12796 const childrenWithProps = Array.isArray(children) ? external_wp_element_namespaceObject.Children.map(children, (child, index) => index === 0 ? (0,external_wp_element_namespaceObject.cloneElement)(child, { 12797 ref: sectionFocusReturnRef 12798 }) : child) : (0,external_wp_element_namespaceObject.cloneElement)(children, { 12799 ref: sectionFocusReturnRef 12800 }); 12801 if (isClosed) { 12802 return null; 12803 } 12804 const shouldShowCloseButton = onClose || closeButtonLabel; 12805 return (0,external_React_.createElement)(EditorCanvasContainerFill, null, (0,external_React_.createElement)(resizable_editor, { 12806 enableResizing: enableResizing 12807 }, (0,external_React_.createElement)("section", { 12808 className: "edit-site-editor-canvas-container", 12809 ref: shouldShowCloseButton ? focusOnMountRef : null, 12810 onKeyDown: closeOnEscape, 12811 "aria-label": title 12812 }, shouldShowCloseButton && (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 12813 className: "edit-site-editor-canvas-container__close-button", 12814 icon: close_small, 12815 label: closeButtonLabel || (0,external_wp_i18n_namespaceObject.__)('Close'), 12816 onClick: onCloseContainer, 12817 showTooltip: false 12818 }), childrenWithProps))); 12819 } 12820 function useHasEditorCanvasContainer() { 12821 const fills = (0,external_wp_components_namespaceObject.__experimentalUseSlotFills)(privateKey); 12822 return !!fills?.length; 12823 } 12824 EditorCanvasContainer.Slot = EditorCanvasContainerSlot; 12825 /* harmony default export */ const editor_canvas_container = (EditorCanvasContainer); 12826 12827 12828 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/style-book/index.js 12829 12830 /** 12831 * External dependencies 12832 */ 12833 12834 12835 /** 12836 * WordPress dependencies 12837 */ 12838 12839 12840 12841 12842 12843 12844 12845 12846 12847 /** 12848 * Internal dependencies 12849 */ 12850 12851 12852 12853 const { 12854 ExperimentalBlockEditorProvider, 12855 useGlobalStyle: style_book_useGlobalStyle, 12856 GlobalStylesContext: style_book_GlobalStylesContext, 12857 useGlobalStylesOutputWithConfig 12858 } = unlock(external_wp_blockEditor_namespaceObject.privateApis); 12859 const { 12860 CompositeV2: Composite, 12861 CompositeItemV2: CompositeItem, 12862 useCompositeStoreV2: useCompositeStore, 12863 Tabs 12864 } = unlock(external_wp_components_namespaceObject.privateApis); 12865 12866 // The content area of the Style Book is rendered within an iframe so that global styles 12867 // are applied to elements within the entire content area. To support elements that are 12868 // not part of the block previews, such as headings and layout for the block previews, 12869 // additional CSS rules need to be passed into the iframe. These are hard-coded below. 12870 // Note that button styles are unset, and then focus rules from the `Button` component are 12871 // applied to the `button` element, targeted via `.edit-site-style-book__example`. 12872 // This is to ensure that browser default styles for buttons are not applied to the previews. 12873 const STYLE_BOOK_IFRAME_STYLES = ` 12874 .edit-site-style-book__examples { 12875 max-width: 900px; 12876 margin: 0 auto; 12877 } 12878 12879 .edit-site-style-book__example { 12880 border-radius: 2px; 12881 cursor: pointer; 12882 display: flex; 12883 flex-direction: column; 12884 gap: 40px; 12885 margin-bottom: 40px; 12886 padding: 16px; 12887 width: 100%; 12888 box-sizing: border-box; 12889 scroll-margin-top: 32px; 12890 scroll-margin-bottom: 32px; 12891 } 12892 12893 .edit-site-style-book__example.is-selected { 12894 box-shadow: 0 0 0 1px var(--wp-components-color-accent, var(--wp-admin-theme-color, #007cba)); 12895 } 12896 12897 .edit-site-style-book__example:focus:not(:disabled) { 12898 box-shadow: 0 0 0 var(--wp-admin-border-width-focus) var(--wp-components-color-accent, var(--wp-admin-theme-color, #007cba)); 12899 outline: 3px solid transparent; 12900 } 12901 12902 .edit-site-style-book__examples.is-wide .edit-site-style-book__example { 12903 flex-direction: row; 12904 } 12905 12906 .edit-site-style-book__example-title { 12907 font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif; 12908 font-size: 11px; 12909 font-weight: 500; 12910 line-height: normal; 12911 margin: 0; 12912 text-align: left; 12913 text-transform: uppercase; 12914 } 12915 12916 .edit-site-style-book__examples.is-wide .edit-site-style-book__example-title { 12917 text-align: right; 12918 width: 120px; 12919 } 12920 12921 .edit-site-style-book__example-preview { 12922 width: 100%; 12923 } 12924 12925 .edit-site-style-book__example-preview .block-editor-block-list__insertion-point, 12926 .edit-site-style-book__example-preview .block-list-appender { 12927 display: none; 12928 } 12929 12930 .edit-site-style-book__example-preview .is-root-container > .wp-block:first-child { 12931 margin-top: 0; 12932 } 12933 .edit-site-style-book__example-preview .is-root-container > .wp-block:last-child { 12934 margin-bottom: 0; 12935 } 12936 `; 12937 function isObjectEmpty(object) { 12938 return !object || Object.keys(object).length === 0; 12939 } 12940 function getExamples() { 12941 // Use our own example for the Heading block so that we can show multiple 12942 // heading levels. 12943 const headingsExample = { 12944 name: 'core/heading', 12945 title: (0,external_wp_i18n_namespaceObject.__)('Headings'), 12946 category: 'text', 12947 blocks: [(0,external_wp_blocks_namespaceObject.createBlock)('core/heading', { 12948 content: (0,external_wp_i18n_namespaceObject.__)('Code Is Poetry'), 12949 level: 1 12950 }), (0,external_wp_blocks_namespaceObject.createBlock)('core/heading', { 12951 content: (0,external_wp_i18n_namespaceObject.__)('Code Is Poetry'), 12952 level: 2 12953 }), (0,external_wp_blocks_namespaceObject.createBlock)('core/heading', { 12954 content: (0,external_wp_i18n_namespaceObject.__)('Code Is Poetry'), 12955 level: 3 12956 }), (0,external_wp_blocks_namespaceObject.createBlock)('core/heading', { 12957 content: (0,external_wp_i18n_namespaceObject.__)('Code Is Poetry'), 12958 level: 4 12959 }), (0,external_wp_blocks_namespaceObject.createBlock)('core/heading', { 12960 content: (0,external_wp_i18n_namespaceObject.__)('Code Is Poetry'), 12961 level: 5 12962 })] 12963 }; 12964 const otherExamples = (0,external_wp_blocks_namespaceObject.getBlockTypes)().filter(blockType => { 12965 const { 12966 name, 12967 example, 12968 supports 12969 } = blockType; 12970 return name !== 'core/heading' && !!example && supports.inserter !== false; 12971 }).map(blockType => ({ 12972 name: blockType.name, 12973 title: blockType.title, 12974 category: blockType.category, 12975 blocks: (0,external_wp_blocks_namespaceObject.getBlockFromExample)(blockType.name, blockType.example) 12976 })); 12977 return [headingsExample, ...otherExamples]; 12978 } 12979 function StyleBook({ 12980 enableResizing = true, 12981 isSelected, 12982 onClick, 12983 onSelect, 12984 showCloseButton = true, 12985 onClose, 12986 showTabs = true, 12987 userConfig = {} 12988 }) { 12989 const [resizeObserver, sizes] = (0,external_wp_compose_namespaceObject.useResizeObserver)(); 12990 const [textColor] = style_book_useGlobalStyle('color.text'); 12991 const [backgroundColor] = style_book_useGlobalStyle('color.background'); 12992 const examples = (0,external_wp_element_namespaceObject.useMemo)(getExamples, []); 12993 const tabs = (0,external_wp_element_namespaceObject.useMemo)(() => (0,external_wp_blocks_namespaceObject.getCategories)().filter(category => examples.some(example => example.category === category.slug)).map(category => ({ 12994 name: category.slug, 12995 title: category.title, 12996 icon: category.icon 12997 })), [examples]); 12998 const { 12999 base: baseConfig 13000 } = (0,external_wp_element_namespaceObject.useContext)(style_book_GlobalStylesContext); 13001 const mergedConfig = (0,external_wp_element_namespaceObject.useMemo)(() => { 13002 if (!isObjectEmpty(userConfig) && !isObjectEmpty(baseConfig)) { 13003 return mergeBaseAndUserConfigs(baseConfig, userConfig); 13004 } 13005 return {}; 13006 }, [baseConfig, userConfig]); 13007 13008 // Copied from packages/edit-site/src/components/revisions/index.js 13009 // could we create a shared hook? 13010 const originalSettings = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_blockEditor_namespaceObject.store).getSettings(), []); 13011 const settings = (0,external_wp_element_namespaceObject.useMemo)(() => ({ 13012 ...originalSettings, 13013 __unstableIsPreviewMode: true 13014 }), [originalSettings]); 13015 const [globalStyles] = useGlobalStylesOutputWithConfig(mergedConfig); 13016 settings.styles = !isObjectEmpty(globalStyles) && !isObjectEmpty(userConfig) ? globalStyles : settings.styles; 13017 return (0,external_React_.createElement)(editor_canvas_container, { 13018 onClose: onClose, 13019 enableResizing: enableResizing, 13020 closeButtonLabel: showCloseButton ? (0,external_wp_i18n_namespaceObject.__)('Close Style Book') : null 13021 }, (0,external_React_.createElement)("div", { 13022 className: classnames_default()('edit-site-style-book', { 13023 'is-wide': sizes.width > 600, 13024 'is-button': !!onClick 13025 }), 13026 style: { 13027 color: textColor, 13028 background: backgroundColor 13029 } 13030 }, resizeObserver, showTabs ? (0,external_React_.createElement)("div", { 13031 className: "edit-site-style-book__tabs" 13032 }, (0,external_React_.createElement)(Tabs, null, (0,external_React_.createElement)(Tabs.TabList, null, tabs.map(tab => (0,external_React_.createElement)(Tabs.Tab, { 13033 tabId: tab.name, 13034 key: tab.name 13035 }, tab.title))), tabs.map(tab => (0,external_React_.createElement)(Tabs.TabPanel, { 13036 key: tab.name, 13037 tabId: tab.name, 13038 focusable: false 13039 }, (0,external_React_.createElement)(StyleBookBody, { 13040 category: tab.name, 13041 examples: examples, 13042 isSelected: isSelected, 13043 onSelect: onSelect, 13044 settings: settings, 13045 sizes: sizes, 13046 title: tab.title 13047 }))))) : (0,external_React_.createElement)(StyleBookBody, { 13048 examples: examples, 13049 isSelected: isSelected, 13050 onClick: onClick, 13051 onSelect: onSelect, 13052 settings: settings, 13053 sizes: sizes 13054 }))); 13055 } 13056 const StyleBookBody = ({ 13057 category, 13058 examples, 13059 isSelected, 13060 onClick, 13061 onSelect, 13062 settings, 13063 sizes, 13064 title 13065 }) => { 13066 const [isFocused, setIsFocused] = (0,external_wp_element_namespaceObject.useState)(false); 13067 13068 // The presence of an `onClick` prop indicates that the Style Book is being used as a button. 13069 // In this case, add additional props to the iframe to make it behave like a button. 13070 const buttonModeProps = { 13071 role: 'button', 13072 onFocus: () => setIsFocused(true), 13073 onBlur: () => setIsFocused(false), 13074 onKeyDown: event => { 13075 if (event.defaultPrevented) { 13076 return; 13077 } 13078 const { 13079 keyCode 13080 } = event; 13081 if (onClick && (keyCode === external_wp_keycodes_namespaceObject.ENTER || keyCode === external_wp_keycodes_namespaceObject.SPACE)) { 13082 event.preventDefault(); 13083 onClick(event); 13084 } 13085 }, 13086 onClick: event => { 13087 if (event.defaultPrevented) { 13088 return; 13089 } 13090 if (onClick) { 13091 event.preventDefault(); 13092 onClick(event); 13093 } 13094 }, 13095 readonly: true 13096 }; 13097 const buttonModeStyles = onClick ? 'body { cursor: pointer; } body * { pointer-events: none; }' : ''; 13098 return (0,external_React_.createElement)(external_wp_blockEditor_namespaceObject.__unstableIframe, { 13099 className: classnames_default()('edit-site-style-book__iframe', { 13100 'is-focused': isFocused && !!onClick, 13101 'is-button': !!onClick 13102 }), 13103 name: "style-book-canvas", 13104 tabIndex: 0, 13105 ...(onClick ? buttonModeProps : {}) 13106 }, (0,external_React_.createElement)(external_wp_blockEditor_namespaceObject.__unstableEditorStyles, { 13107 styles: settings.styles 13108 }), (0,external_React_.createElement)("style", null, 13109 // Forming a "block formatting context" to prevent margin collapsing. 13110 // @see https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Block_formatting_context 13111 `.is-root-container { display: flow-root; } 13112 body { position: relative; padding: 32px !important; }` + STYLE_BOOK_IFRAME_STYLES + buttonModeStyles), (0,external_React_.createElement)(Examples, { 13113 className: classnames_default()('edit-site-style-book__examples', { 13114 'is-wide': sizes.width > 600 13115 }), 13116 examples: examples, 13117 category: category, 13118 label: title ? (0,external_wp_i18n_namespaceObject.sprintf)( 13119 // translators: %s: Category of blocks, e.g. Text. 13120 (0,external_wp_i18n_namespaceObject.__)('Examples of blocks in the %s category'), title) : (0,external_wp_i18n_namespaceObject.__)('Examples of blocks'), 13121 isSelected: isSelected, 13122 onSelect: onSelect, 13123 key: category 13124 })); 13125 }; 13126 const Examples = (0,external_wp_element_namespaceObject.memo)(({ 13127 className, 13128 examples, 13129 category, 13130 label, 13131 isSelected, 13132 onSelect 13133 }) => { 13134 const compositeStore = useCompositeStore({ 13135 orientation: 'vertical' 13136 }); 13137 return (0,external_React_.createElement)(Composite, { 13138 store: compositeStore, 13139 className: className, 13140 "aria-label": label, 13141 role: "grid" 13142 }, examples.filter(example => category ? example.category === category : true).map(example => (0,external_React_.createElement)(Example, { 13143 key: example.name, 13144 id: `example-$example.name}`, 13145 title: example.title, 13146 blocks: example.blocks, 13147 isSelected: isSelected(example.name), 13148 onClick: () => { 13149 onSelect?.(example.name); 13150 } 13151 }))); 13152 }); 13153 const Example = ({ 13154 id, 13155 title, 13156 blocks, 13157 isSelected, 13158 onClick 13159 }) => { 13160 const originalSettings = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_blockEditor_namespaceObject.store).getSettings(), []); 13161 const settings = (0,external_wp_element_namespaceObject.useMemo)(() => ({ 13162 ...originalSettings, 13163 focusMode: false, 13164 // Disable "Spotlight mode". 13165 __unstableIsPreviewMode: true 13166 }), [originalSettings]); 13167 13168 // Cache the list of blocks to avoid additional processing when the component is re-rendered. 13169 const renderedBlocks = (0,external_wp_element_namespaceObject.useMemo)(() => Array.isArray(blocks) ? blocks : [blocks], [blocks]); 13170 return (0,external_React_.createElement)("div", { 13171 role: "row" 13172 }, (0,external_React_.createElement)("div", { 13173 role: "gridcell" 13174 }, (0,external_React_.createElement)(CompositeItem, { 13175 className: classnames_default()('edit-site-style-book__example', { 13176 'is-selected': isSelected 13177 }), 13178 id: id, 13179 "aria-label": (0,external_wp_i18n_namespaceObject.sprintf)( 13180 // translators: %s: Title of a block, e.g. Heading. 13181 (0,external_wp_i18n_namespaceObject.__)('Open %s styles in Styles panel'), title), 13182 render: (0,external_React_.createElement)("div", null), 13183 role: "button", 13184 onClick: onClick 13185 }, (0,external_React_.createElement)("span", { 13186 className: "edit-site-style-book__example-title" 13187 }, title), (0,external_React_.createElement)("div", { 13188 className: "edit-site-style-book__example-preview", 13189 "aria-hidden": true 13190 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.Disabled, { 13191 className: "edit-site-style-book__example-preview__content" 13192 }, (0,external_React_.createElement)(ExperimentalBlockEditorProvider, { 13193 value: renderedBlocks, 13194 settings: settings 13195 }, (0,external_React_.createElement)(external_wp_blockEditor_namespaceObject.BlockList, { 13196 renderAppender: false 13197 }))))))); 13198 }; 13199 /* harmony default export */ const style_book = (StyleBook); 13200 13201 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/global-styles/screen-revisions/use-global-styles-revisions.js 13202 /** 13203 * WordPress dependencies 13204 */ 13205 13206 13207 13208 13209 13210 /** 13211 * Internal dependencies 13212 */ 13213 13214 const SITE_EDITOR_AUTHORS_QUERY = { 13215 per_page: -1, 13216 _fields: 'id,name,avatar_urls', 13217 context: 'view', 13218 capabilities: ['edit_theme_options'] 13219 }; 13220 const DEFAULT_QUERY = { 13221 per_page: 100, 13222 page: 1 13223 }; 13224 const use_global_styles_revisions_EMPTY_ARRAY = []; 13225 const { 13226 GlobalStylesContext: use_global_styles_revisions_GlobalStylesContext 13227 } = unlock(external_wp_blockEditor_namespaceObject.privateApis); 13228 function useGlobalStylesRevisions({ 13229 query 13230 } = {}) { 13231 const { 13232 user: userConfig 13233 } = (0,external_wp_element_namespaceObject.useContext)(use_global_styles_revisions_GlobalStylesContext); 13234 const _query = { 13235 ...DEFAULT_QUERY, 13236 ...query 13237 }; 13238 const { 13239 authors, 13240 currentUser, 13241 isDirty, 13242 revisions, 13243 isLoadingGlobalStylesRevisions, 13244 revisionsCount 13245 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 13246 var _globalStyles$_links$; 13247 const { 13248 __experimentalGetDirtyEntityRecords, 13249 getCurrentUser, 13250 getUsers, 13251 getRevisions, 13252 __experimentalGetCurrentGlobalStylesId, 13253 getEntityRecord, 13254 isResolving 13255 } = select(external_wp_coreData_namespaceObject.store); 13256 const dirtyEntityRecords = __experimentalGetDirtyEntityRecords(); 13257 const _currentUser = getCurrentUser(); 13258 const _isDirty = dirtyEntityRecords.length > 0; 13259 const globalStylesId = __experimentalGetCurrentGlobalStylesId(); 13260 const globalStyles = globalStylesId ? getEntityRecord('root', 'globalStyles', globalStylesId) : undefined; 13261 const _revisionsCount = (_globalStyles$_links$ = globalStyles?._links?.['version-history']?.[0]?.count) !== null && _globalStyles$_links$ !== void 0 ? _globalStyles$_links$ : 0; 13262 const globalStylesRevisions = getRevisions('root', 'globalStyles', globalStylesId, _query) || use_global_styles_revisions_EMPTY_ARRAY; 13263 const _authors = getUsers(SITE_EDITOR_AUTHORS_QUERY) || use_global_styles_revisions_EMPTY_ARRAY; 13264 const _isResolving = isResolving('getRevisions', ['root', 'globalStyles', globalStylesId, _query]); 13265 return { 13266 authors: _authors, 13267 currentUser: _currentUser, 13268 isDirty: _isDirty, 13269 revisions: globalStylesRevisions, 13270 isLoadingGlobalStylesRevisions: _isResolving, 13271 revisionsCount: _revisionsCount 13272 }; 13273 }, [query]); 13274 return (0,external_wp_element_namespaceObject.useMemo)(() => { 13275 if (!authors.length || isLoadingGlobalStylesRevisions) { 13276 return { 13277 revisions: use_global_styles_revisions_EMPTY_ARRAY, 13278 hasUnsavedChanges: isDirty, 13279 isLoading: true, 13280 revisionsCount 13281 }; 13282 } 13283 13284 // Adds author details to each revision. 13285 const _modifiedRevisions = revisions.map(revision => { 13286 return { 13287 ...revision, 13288 author: authors.find(author => author.id === revision.author) 13289 }; 13290 }); 13291 const fetchedRevisionsCount = revisions.length; 13292 if (fetchedRevisionsCount) { 13293 // Flags the most current saved revision. 13294 if (_modifiedRevisions[0].id !== 'unsaved' && _query.page === 1) { 13295 _modifiedRevisions[0].isLatest = true; 13296 } 13297 13298 // Adds an item for unsaved changes. 13299 if (isDirty && userConfig && Object.keys(userConfig).length > 0 && currentUser && _query.page === 1) { 13300 const unsavedRevision = { 13301 id: 'unsaved', 13302 styles: userConfig?.styles, 13303 settings: userConfig?.settings, 13304 author: { 13305 name: currentUser?.name, 13306 avatar_urls: currentUser?.avatar_urls 13307 }, 13308 modified: new Date() 13309 }; 13310 _modifiedRevisions.unshift(unsavedRevision); 13311 } 13312 if (_query.page === Math.ceil(revisionsCount / _query.per_page)) { 13313 // Adds an item for the default theme styles. 13314 _modifiedRevisions.push({ 13315 id: 'parent', 13316 styles: {}, 13317 settings: {} 13318 }); 13319 } 13320 } 13321 return { 13322 revisions: _modifiedRevisions, 13323 hasUnsavedChanges: isDirty, 13324 isLoading: false, 13325 revisionsCount 13326 }; 13327 }, [isDirty, revisions, currentUser, authors, userConfig, isLoadingGlobalStylesRevisions]); 13328 } 13329 13330 ;// CONCATENATED MODULE: external ["wp","date"] 13331 const external_wp_date_namespaceObject = window["wp"]["date"]; 13332 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/backup.js 13333 13334 /** 13335 * WordPress dependencies 13336 */ 13337 13338 const backup = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { 13339 xmlns: "http://www.w3.org/2000/svg", 13340 viewBox: "0 0 24 24" 13341 }, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 13342 d: "M5.5 12h1.75l-2.5 3-2.5-3H4a8 8 0 113.134 6.35l.907-1.194A6.5 6.5 0 105.5 12zm9.53 1.97l-2.28-2.28V8.5a.75.75 0 00-1.5 0V12a.747.747 0 00.218.529l1.282-.84-1.28.842 2.5 2.5a.75.75 0 101.06-1.061z" 13343 })); 13344 /* harmony default export */ const library_backup = (backup); 13345 13346 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sidebar-navigation-screen-details-panel/sidebar-navigation-screen-details-panel-label.js 13347 13348 /** 13349 * WordPress dependencies 13350 */ 13351 13352 function SidebarNavigationScreenDetailsPanelLabel({ 13353 children 13354 }) { 13355 return (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalText, { 13356 className: "edit-site-sidebar-navigation-details-screen-panel__label" 13357 }, children); 13358 } 13359 13360 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sidebar-navigation-screen-details-panel/sidebar-navigation-screen-details-panel-row.js 13361 13362 /** 13363 * External dependencies 13364 */ 13365 13366 13367 /** 13368 * WordPress dependencies 13369 */ 13370 13371 function SidebarNavigationScreenDetailsPanelRow({ 13372 label, 13373 children, 13374 className, 13375 ...extraProps 13376 }) { 13377 return (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { 13378 key: label, 13379 spacing: 5, 13380 alignment: "left", 13381 className: classnames_default()('edit-site-sidebar-navigation-details-screen-panel__row', className), 13382 ...extraProps 13383 }, children); 13384 } 13385 13386 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sidebar-navigation-screen-details-panel/sidebar-navigation-screen-details-panel-value.js 13387 13388 /** 13389 * WordPress dependencies 13390 */ 13391 13392 function SidebarNavigationScreenDetailsPanelValue({ 13393 children 13394 }) { 13395 return (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalText, { 13396 className: "edit-site-sidebar-navigation-details-screen-panel__value" 13397 }, children); 13398 } 13399 13400 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sidebar-navigation-screen-details-panel/index.js 13401 13402 /** 13403 * WordPress dependencies 13404 */ 13405 13406 13407 /** 13408 * Internal dependencies 13409 */ 13410 13411 13412 13413 function SidebarNavigationScreenDetailsPanel({ 13414 title, 13415 children, 13416 spacing 13417 }) { 13418 return (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { 13419 className: "edit-site-sidebar-navigation-details-screen-panel", 13420 spacing: spacing 13421 }, title && (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHeading, { 13422 className: "edit-site-sidebar-navigation-details-screen-panel__heading", 13423 level: 2 13424 }, title), children); 13425 } 13426 13427 13428 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sidebar-navigation-screen-details-footer/index.js 13429 13430 /** 13431 * WordPress dependencies 13432 */ 13433 13434 13435 13436 13437 13438 13439 13440 /** 13441 * Internal dependencies 13442 */ 13443 13444 13445 function SidebarNavigationScreenDetailsFooter({ 13446 record, 13447 ...otherProps 13448 }) { 13449 /* 13450 * There might be other items in the future, 13451 * but for now it's just modified date. 13452 * Later we might render a list of items and isolate 13453 * the following logic. 13454 */ 13455 const hrefProps = {}; 13456 if (record?._links?.['predecessor-version']?.[0]?.id) { 13457 hrefProps.href = (0,external_wp_url_namespaceObject.addQueryArgs)('revision.php', { 13458 revision: record?._links['predecessor-version'][0].id 13459 }); 13460 hrefProps.as = 'a'; 13461 } 13462 return (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalItemGroup, { 13463 className: "edit-site-sidebar-navigation-screen-details-footer" 13464 }, (0,external_React_.createElement)(SidebarNavigationItem, { 13465 "aria-label": (0,external_wp_i18n_namespaceObject.__)('Revisions'), 13466 ...hrefProps, 13467 ...otherProps 13468 }, (0,external_React_.createElement)(SidebarNavigationScreenDetailsPanelRow, { 13469 justify: "space-between" 13470 }, (0,external_React_.createElement)(SidebarNavigationScreenDetailsPanelLabel, null, (0,external_wp_i18n_namespaceObject.__)('Last modified')), (0,external_React_.createElement)(SidebarNavigationScreenDetailsPanelValue, null, (0,external_wp_element_namespaceObject.createInterpolateElement)((0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: is the relative time when the post was last modified. */ 13471 (0,external_wp_i18n_namespaceObject.__)('<time>%s</time>'), (0,external_wp_date_namespaceObject.humanTimeDiff)(record.modified)), { 13472 time: (0,external_React_.createElement)("time", { 13473 dateTime: record.modified 13474 }) 13475 })), (0,external_React_.createElement)(external_wp_components_namespaceObject.Icon, { 13476 className: "edit-site-sidebar-navigation-screen-details-footer__icon", 13477 icon: library_backup 13478 })))); 13479 } 13480 13481 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sidebar-navigation-screen-global-styles/index.js 13482 13483 /** 13484 * WordPress dependencies 13485 */ 13486 13487 13488 13489 13490 13491 13492 13493 13494 13495 13496 /** 13497 * Internal dependencies 13498 */ 13499 13500 13501 13502 13503 13504 13505 13506 13507 13508 const sidebar_navigation_screen_global_styles_noop = () => {}; 13509 function SidebarNavigationItemGlobalStyles(props) { 13510 const { 13511 openGeneralSidebar 13512 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store); 13513 const { 13514 setCanvasMode 13515 } = unlock((0,external_wp_data_namespaceObject.useDispatch)(store_store)); 13516 const hasGlobalStyleVariations = (0,external_wp_data_namespaceObject.useSelect)(select => !!select(external_wp_coreData_namespaceObject.store).__experimentalGetCurrentThemeGlobalStylesVariations()?.length, []); 13517 if (hasGlobalStyleVariations) { 13518 return (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalNavigatorButton, { 13519 ...props, 13520 as: SidebarNavigationItem, 13521 path: "/wp_global_styles" 13522 }); 13523 } 13524 return (0,external_React_.createElement)(SidebarNavigationItem, { 13525 ...props, 13526 onClick: () => { 13527 // Switch to edit mode. 13528 setCanvasMode('edit'); 13529 // Open global styles sidebar. 13530 openGeneralSidebar('edit-site/global-styles'); 13531 } 13532 }); 13533 } 13534 function SidebarNavigationScreenGlobalStylesContent() { 13535 const { 13536 storedSettings 13537 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 13538 const { 13539 getSettings 13540 } = unlock(select(store_store)); 13541 return { 13542 storedSettings: getSettings() 13543 }; 13544 }, []); 13545 13546 // Wrap in a BlockEditorProvider to ensure that the Iframe's dependencies are 13547 // loaded. This is necessary because the Iframe component waits until 13548 // the block editor store's `__internalIsInitialized` is true before 13549 // rendering the iframe. Without this, the iframe previews will not render 13550 // in mobile viewport sizes, where the editor canvas is hidden. 13551 return (0,external_React_.createElement)(external_wp_blockEditor_namespaceObject.BlockEditorProvider, { 13552 settings: storedSettings, 13553 onChange: sidebar_navigation_screen_global_styles_noop, 13554 onInput: sidebar_navigation_screen_global_styles_noop 13555 }, (0,external_React_.createElement)(StyleVariationsContainer, null)); 13556 } 13557 function SidebarNavigationScreenGlobalStyles() { 13558 const { 13559 revisions, 13560 isLoading: isLoadingRevisions 13561 } = useGlobalStylesRevisions(); 13562 const { 13563 openGeneralSidebar 13564 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store); 13565 const { 13566 setIsListViewOpened 13567 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_editor_namespaceObject.store); 13568 const isMobileViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium', '<'); 13569 const { 13570 setCanvasMode, 13571 setEditorCanvasContainerView 13572 } = unlock((0,external_wp_data_namespaceObject.useDispatch)(store_store)); 13573 const { 13574 isViewMode, 13575 isStyleBookOpened, 13576 revisionsCount 13577 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 13578 var _globalStyles$_links$; 13579 const { 13580 getCanvasMode, 13581 getEditorCanvasContainerView 13582 } = unlock(select(store_store)); 13583 const { 13584 getEntityRecord, 13585 __experimentalGetCurrentGlobalStylesId 13586 } = select(external_wp_coreData_namespaceObject.store); 13587 const globalStylesId = __experimentalGetCurrentGlobalStylesId(); 13588 const globalStyles = globalStylesId ? getEntityRecord('root', 'globalStyles', globalStylesId) : undefined; 13589 return { 13590 isViewMode: 'view' === getCanvasMode(), 13591 isStyleBookOpened: 'style-book' === getEditorCanvasContainerView(), 13592 revisionsCount: (_globalStyles$_links$ = globalStyles?._links?.['version-history']?.[0]?.count) !== null && _globalStyles$_links$ !== void 0 ? _globalStyles$_links$ : 0 13593 }; 13594 }, []); 13595 const openGlobalStyles = (0,external_wp_element_namespaceObject.useCallback)(async () => { 13596 return Promise.all([setCanvasMode('edit'), openGeneralSidebar('edit-site/global-styles')]); 13597 }, [setCanvasMode, openGeneralSidebar]); 13598 const openStyleBook = (0,external_wp_element_namespaceObject.useCallback)(async () => { 13599 await openGlobalStyles(); 13600 // Open the Style Book once the canvas mode is set to edit, 13601 // and the global styles sidebar is open. This ensures that 13602 // the Style Book is not prematurely closed. 13603 setEditorCanvasContainerView('style-book'); 13604 setIsListViewOpened(false); 13605 }, [openGlobalStyles, setEditorCanvasContainerView, setIsListViewOpened]); 13606 const openRevisions = (0,external_wp_element_namespaceObject.useCallback)(async () => { 13607 await openGlobalStyles(); 13608 // Open the global styles revisions once the canvas mode is set to edit, 13609 // and the global styles sidebar is open. The global styles UI is responsible 13610 // for redirecting to the revisions screen once the editor canvas container 13611 // has been set to 'global-styles-revisions'. 13612 setEditorCanvasContainerView('global-styles-revisions'); 13613 }, [openGlobalStyles, setEditorCanvasContainerView]); 13614 13615 // If there are no revisions, do not render a footer. 13616 const hasRevisions = revisionsCount > 0; 13617 const modifiedDateTime = revisions?.[0]?.modified; 13618 const shouldShowGlobalStylesFooter = hasRevisions && !isLoadingRevisions && modifiedDateTime; 13619 return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(SidebarNavigationScreen, { 13620 title: (0,external_wp_i18n_namespaceObject.__)('Styles'), 13621 description: (0,external_wp_i18n_namespaceObject.__)('Choose a different style combination for the theme styles.'), 13622 content: (0,external_React_.createElement)(SidebarNavigationScreenGlobalStylesContent, null), 13623 footer: shouldShowGlobalStylesFooter && (0,external_React_.createElement)(SidebarNavigationScreenDetailsFooter, { 13624 record: revisions?.[0], 13625 onClick: openRevisions 13626 }), 13627 actions: (0,external_React_.createElement)(external_React_.Fragment, null, !isMobileViewport && (0,external_React_.createElement)(SidebarButton, { 13628 icon: library_seen, 13629 label: (0,external_wp_i18n_namespaceObject.__)('Style Book'), 13630 onClick: () => setEditorCanvasContainerView(!isStyleBookOpened ? 'style-book' : undefined), 13631 isPressed: isStyleBookOpened 13632 }), (0,external_React_.createElement)(SidebarButton, { 13633 icon: edit, 13634 label: (0,external_wp_i18n_namespaceObject.__)('Edit styles'), 13635 onClick: async () => await openGlobalStyles() 13636 })) 13637 }), isStyleBookOpened && !isMobileViewport && isViewMode && (0,external_React_.createElement)(style_book, { 13638 enableResizing: false, 13639 isSelected: () => false, 13640 onClick: openStyleBook, 13641 onSelect: openStyleBook, 13642 showCloseButton: false, 13643 showTabs: false 13644 })); 13645 } 13646 13647 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sidebar-navigation-screen-main/template-part-hint.js 13648 13649 /** 13650 * WordPress dependencies 13651 */ 13652 13653 13654 13655 13656 const PREFERENCE_NAME = 'isTemplatePartMoveHintVisible'; 13657 function TemplatePartHint() { 13658 const showTemplatePartHint = (0,external_wp_data_namespaceObject.useSelect)(select => { 13659 var _select$get; 13660 return (_select$get = select(external_wp_preferences_namespaceObject.store).get('core', PREFERENCE_NAME)) !== null && _select$get !== void 0 ? _select$get : true; 13661 }, []); 13662 const { 13663 set: setPreference 13664 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_preferences_namespaceObject.store); 13665 if (!showTemplatePartHint) { 13666 return null; 13667 } 13668 return (0,external_React_.createElement)(external_wp_components_namespaceObject.Notice, { 13669 politeness: "polite", 13670 className: "edit-site-sidebar__notice", 13671 onRemove: () => { 13672 setPreference('core', PREFERENCE_NAME, false); 13673 } 13674 }, (0,external_wp_i18n_namespaceObject.__)('Looking for template parts? Find them in "Patterns".')); 13675 } 13676 13677 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sidebar-navigation-screen-main/index.js 13678 13679 /** 13680 * WordPress dependencies 13681 */ 13682 13683 13684 13685 13686 13687 13688 /** 13689 * Internal dependencies 13690 */ 13691 13692 13693 13694 13695 13696 13697 function SidebarNavigationScreenMain() { 13698 const { 13699 location 13700 } = (0,external_wp_components_namespaceObject.__experimentalUseNavigator)(); 13701 const { 13702 setEditorCanvasContainerView 13703 } = unlock((0,external_wp_data_namespaceObject.useDispatch)(store_store)); 13704 13705 // Clear the editor canvas container view when accessing the main navigation screen. 13706 (0,external_wp_element_namespaceObject.useEffect)(() => { 13707 if (location?.path === '/') { 13708 setEditorCanvasContainerView(undefined); 13709 } 13710 }, [setEditorCanvasContainerView, location?.path]); 13711 return (0,external_React_.createElement)(SidebarNavigationScreen, { 13712 isRoot: true, 13713 title: (0,external_wp_i18n_namespaceObject.__)('Design'), 13714 description: (0,external_wp_i18n_namespaceObject.__)('Customize the appearance of your website using the block editor.'), 13715 content: (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalItemGroup, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalNavigatorButton, { 13716 as: SidebarNavigationItem, 13717 path: "/navigation", 13718 withChevron: true, 13719 icon: library_navigation 13720 }, (0,external_wp_i18n_namespaceObject.__)('Navigation')), (0,external_React_.createElement)(SidebarNavigationItemGlobalStyles, { 13721 withChevron: true, 13722 icon: library_styles 13723 }, (0,external_wp_i18n_namespaceObject.__)('Styles')), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalNavigatorButton, { 13724 as: SidebarNavigationItem, 13725 path: "/page", 13726 withChevron: true, 13727 icon: library_page 13728 }, (0,external_wp_i18n_namespaceObject.__)('Pages')), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalNavigatorButton, { 13729 as: SidebarNavigationItem, 13730 path: "/wp_template", 13731 withChevron: true, 13732 icon: library_layout 13733 }, (0,external_wp_i18n_namespaceObject.__)('Templates')), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalNavigatorButton, { 13734 as: SidebarNavigationItem, 13735 path: "/patterns", 13736 withChevron: true, 13737 icon: library_symbol 13738 }, (0,external_wp_i18n_namespaceObject.__)('Patterns'))), (0,external_React_.createElement)(TemplatePartHint, null)) 13739 }); 13740 } 13741 13742 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/home.js 13743 13744 /** 13745 * WordPress dependencies 13746 */ 13747 13748 const home = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { 13749 xmlns: "http://www.w3.org/2000/svg", 13750 viewBox: "0 0 24 24" 13751 }, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 13752 d: "M12 4L4 7.9V20h16V7.9L12 4zm6.5 14.5H14V13h-4v5.5H5.5V8.8L12 5.7l6.5 3.1v9.7z" 13753 })); 13754 /* harmony default export */ const library_home = (home); 13755 13756 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/verse.js 13757 13758 /** 13759 * WordPress dependencies 13760 */ 13761 13762 const verse = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { 13763 viewBox: "0 0 24 24", 13764 xmlns: "http://www.w3.org/2000/svg" 13765 }, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 13766 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" 13767 })); 13768 /* harmony default export */ const library_verse = (verse); 13769 13770 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/pin.js 13771 13772 /** 13773 * WordPress dependencies 13774 */ 13775 13776 const pin = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { 13777 xmlns: "http://www.w3.org/2000/svg", 13778 viewBox: "0 0 24 24" 13779 }, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 13780 d: "m21.5 9.1-6.6-6.6-4.2 5.6c-1.2-.1-2.4.1-3.6.7-.1 0-.1.1-.2.1-.5.3-.9.6-1.2.9l3.7 3.7-5.7 5.7v1.1h1.1l5.7-5.7 3.7 3.7c.4-.4.7-.8.9-1.2.1-.1.1-.2.2-.3.6-1.1.8-2.4.6-3.6l5.6-4.1zm-7.3 3.5.1.9c.1.9 0 1.8-.4 2.6l-6-6c.8-.4 1.7-.5 2.6-.4l.9.1L15 4.9 19.1 9l-4.9 3.6z" 13781 })); 13782 /* harmony default export */ const library_pin = (pin); 13783 13784 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/archive.js 13785 13786 /** 13787 * WordPress dependencies 13788 */ 13789 13790 const archive = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { 13791 viewBox: "0 0 24 24", 13792 xmlns: "http://www.w3.org/2000/svg" 13793 }, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 13794 fillRule: "evenodd", 13795 clipRule: "evenodd", 13796 d: "M11.934 7.406a1 1 0 0 0 .914.594H19a.5.5 0 0 1 .5.5v9a.5.5 0 0 1-.5.5H5a.5.5 0 0 1-.5-.5V6a.5.5 0 0 1 .5-.5h5.764a.5.5 0 0 1 .447.276l.723 1.63Zm1.064-1.216a.5.5 0 0 0 .462.31H19a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h5.764a2 2 0 0 1 1.789 1.106l.445 1.084ZM8.5 10.5h7V12h-7v-1.5Zm7 3.5h-7v1.5h7V14Z" 13797 })); 13798 /* harmony default export */ const library_archive = (archive); 13799 13800 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/search.js 13801 13802 /** 13803 * WordPress dependencies 13804 */ 13805 13806 const search = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { 13807 xmlns: "http://www.w3.org/2000/svg", 13808 viewBox: "0 0 24 24" 13809 }, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 13810 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" 13811 })); 13812 /* harmony default export */ const library_search = (search); 13813 13814 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/not-found.js 13815 13816 /** 13817 * WordPress dependencies 13818 */ 13819 13820 const notFound = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { 13821 xmlns: "http://www.w3.org/2000/svg", 13822 viewBox: "0 0 24 24" 13823 }, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 13824 d: "M19 5H5c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm.5 12c0 .3-.2.5-.5.5H5c-.3 0-.5-.2-.5-.5V7c0-.3.2-.5.5-.5h14c.3 0 .5.2.5.5v10zm-11-7.6h-.7l-3.1 4.3h2.8V15h1v-1.3h.7v-.8h-.7V9.4zm-.9 3.5H6.3l1.2-1.7v1.7zm5.6-3.2c-.4-.2-.8-.4-1.2-.4-.5 0-.9.1-1.2.4-.4.2-.6.6-.8 1-.2.4-.3.9-.3 1.5s.1 1.1.3 1.6c.2.4.5.8.8 1 .4.2.8.4 1.2.4.5 0 .9-.1 1.2-.4.4-.2.6-.6.8-1 .2-.4.3-1 .3-1.6 0-.6-.1-1.1-.3-1.5-.1-.5-.4-.8-.8-1zm0 3.6c-.1.3-.3.5-.5.7-.2.1-.4.2-.7.2-.3 0-.5-.1-.7-.2-.2-.1-.4-.4-.5-.7-.1-.3-.2-.7-.2-1.2 0-.7.1-1.2.4-1.5.3-.3.6-.5 1-.5s.7.2 1 .5c.3.3.4.8.4 1.5-.1.5-.1.9-.2 1.2zm5-3.9h-.7l-3.1 4.3h2.8V15h1v-1.3h.7v-.8h-.7V9.4zm-1 3.5H16l1.2-1.7v1.7z" 13825 })); 13826 /* harmony default export */ const not_found = (notFound); 13827 13828 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/list.js 13829 13830 /** 13831 * WordPress dependencies 13832 */ 13833 13834 const list = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { 13835 viewBox: "0 0 24 24", 13836 xmlns: "http://www.w3.org/2000/svg" 13837 }, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 13838 d: "M4 4v1.5h16V4H4zm8 8.5h8V11h-8v1.5zM4 20h16v-1.5H4V20zm4-8c0-1.1-.9-2-2-2s-2 .9-2 2 .9 2 2 2 2-.9 2-2z" 13839 })); 13840 /* harmony default export */ const library_list = (list); 13841 13842 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/category.js 13843 13844 /** 13845 * WordPress dependencies 13846 */ 13847 13848 const category = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { 13849 viewBox: "0 0 24 24", 13850 xmlns: "http://www.w3.org/2000/svg" 13851 }, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 13852 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", 13853 fillRule: "evenodd", 13854 clipRule: "evenodd" 13855 })); 13856 /* harmony default export */ const library_category = (category); 13857 13858 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/comment-author-avatar.js 13859 13860 /** 13861 * WordPress dependencies 13862 */ 13863 13864 const commentAuthorAvatar = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { 13865 xmlns: "http://www.w3.org/2000/svg", 13866 viewBox: "0 0 24 24" 13867 }, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 13868 fillRule: "evenodd", 13869 d: "M7.25 16.437a6.5 6.5 0 1 1 9.5 0V16A2.75 2.75 0 0 0 14 13.25h-4A2.75 2.75 0 0 0 7.25 16v.437Zm1.5 1.193a6.47 6.47 0 0 0 3.25.87 6.47 6.47 0 0 0 3.25-.87V16c0-.69-.56-1.25-1.25-1.25h-4c-.69 0-1.25.56-1.25 1.25v1.63ZM4 12a8 8 0 1 1 16 0 8 8 0 0 1-16 0Zm10-2a2 2 0 1 1-4 0 2 2 0 0 1 4 0Z", 13870 clipRule: "evenodd" 13871 })); 13872 /* harmony default export */ const comment_author_avatar = (commentAuthorAvatar); 13873 13874 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/block-meta.js 13875 13876 /** 13877 * WordPress dependencies 13878 */ 13879 13880 const blockMeta = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { 13881 xmlns: "http://www.w3.org/2000/svg", 13882 viewBox: "0 0 24 24" 13883 }, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 13884 fillRule: "evenodd", 13885 d: "M8.95 11.25H4v1.5h4.95v4.5H13V18c0 1.1.9 2 2 2h3c1.1 0 2-.9 2-2v-3c0-1.1-.9-2-2-2h-3c-1.1 0-2 .9-2 2v.75h-2.55v-7.5H13V9c0 1.1.9 2 2 2h3c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2h-3c-1.1 0-2 .9-2 2v.75H8.95v4.5ZM14.5 15v3c0 .3.2.5.5.5h3c.3 0 .5-.2.5-.5v-3c0-.3-.2-.5-.5-.5h-3c-.3 0-.5.2-.5.5Zm0-6V6c0-.3.2-.5.5-.5h3c.3 0 .5.2.5.5v3c0 .3-.2.5-.5.5h-3c-.3 0-.5-.2-.5-.5Z", 13886 clipRule: "evenodd" 13887 })); 13888 /* harmony default export */ const block_meta = (blockMeta); 13889 13890 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/calendar.js 13891 13892 /** 13893 * WordPress dependencies 13894 */ 13895 13896 const calendar = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { 13897 viewBox: "0 0 24 24", 13898 xmlns: "http://www.w3.org/2000/svg" 13899 }, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 13900 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-2zm.5 16c0 .3-.2.5-.5.5H5c-.3 0-.5-.2-.5-.5V7h15v12zM9 10H7v2h2v-2zm0 4H7v2h2v-2zm4-4h-2v2h2v-2zm4 0h-2v2h2v-2zm-4 4h-2v2h2v-2zm4 0h-2v2h2v-2z" 13901 })); 13902 /* harmony default export */ const library_calendar = (calendar); 13903 13904 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/tag.js 13905 13906 /** 13907 * WordPress dependencies 13908 */ 13909 13910 const tag = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { 13911 xmlns: "http://www.w3.org/2000/svg", 13912 viewBox: "0 0 24 24" 13913 }, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 13914 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" 13915 })); 13916 /* harmony default export */ const library_tag = (tag); 13917 13918 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/media.js 13919 13920 /** 13921 * WordPress dependencies 13922 */ 13923 13924 const media = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { 13925 xmlns: "http://www.w3.org/2000/svg", 13926 viewBox: "0 0 24 24" 13927 }, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 13928 d: "m7 6.5 4 2.5-4 2.5z" 13929 }), (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 13930 fillRule: "evenodd", 13931 clipRule: "evenodd", 13932 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" 13933 })); 13934 /* harmony default export */ const library_media = (media); 13935 13936 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/plus.js 13937 13938 /** 13939 * WordPress dependencies 13940 */ 13941 13942 const plus = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { 13943 xmlns: "http://www.w3.org/2000/svg", 13944 viewBox: "0 0 24 24" 13945 }, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 13946 d: "M11 12.5V17.5H12.5V12.5H17.5V11H12.5V6H11V11H6V12.5H11Z" 13947 })); 13948 /* harmony default export */ const library_plus = (plus); 13949 13950 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/post.js 13951 13952 /** 13953 * WordPress dependencies 13954 */ 13955 13956 const post = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { 13957 xmlns: "http://www.w3.org/2000/svg", 13958 viewBox: "0 0 24 24" 13959 }, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 13960 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" 13961 })); 13962 /* harmony default export */ const library_post = (post); 13963 13964 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/add-new-template/utils.js 13965 /** 13966 * WordPress dependencies 13967 */ 13968 13969 13970 13971 13972 13973 13974 13975 13976 /** 13977 * Internal dependencies 13978 */ 13979 13980 13981 /** 13982 * @typedef IHasNameAndId 13983 * @property {string|number} id The entity's id. 13984 * @property {string} name The entity's name. 13985 */ 13986 13987 const utils_getValueFromObjectPath = (object, path) => { 13988 let value = object; 13989 path.split('.').forEach(fieldName => { 13990 value = value?.[fieldName]; 13991 }); 13992 return value; 13993 }; 13994 13995 /** 13996 * Helper util to map records to add a `name` prop from a 13997 * provided path, in order to handle all entities in the same 13998 * fashion(implementing`IHasNameAndId` interface). 13999 * 14000 * @param {Object[]} entities The array of entities. 14001 * @param {string} path The path to map a `name` property from the entity. 14002 * @return {IHasNameAndId[]} An array of enitities that now implement the `IHasNameAndId` interface. 14003 */ 14004 const mapToIHasNameAndId = (entities, path) => { 14005 return (entities || []).map(entity => ({ 14006 ...entity, 14007 name: (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(utils_getValueFromObjectPath(entity, path)) 14008 })); 14009 }; 14010 14011 /** 14012 * @typedef {Object} EntitiesInfo 14013 * @property {boolean} hasEntities If an entity has available records(posts, terms, etc..). 14014 * @property {number[]} existingEntitiesIds An array of the existing entities ids. 14015 */ 14016 14017 const useExistingTemplates = () => { 14018 return (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).getEntityRecords('postType', constants_TEMPLATE_POST_TYPE, { 14019 per_page: -1 14020 }), []); 14021 }; 14022 const useDefaultTemplateTypes = () => { 14023 return (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_editor_namespaceObject.store).__experimentalGetDefaultTemplateTypes(), []); 14024 }; 14025 const usePublicPostTypes = () => { 14026 const postTypes = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).getPostTypes({ 14027 per_page: -1 14028 }), []); 14029 return (0,external_wp_element_namespaceObject.useMemo)(() => { 14030 const excludedPostTypes = ['attachment']; 14031 return postTypes?.filter(({ 14032 viewable, 14033 slug 14034 }) => viewable && !excludedPostTypes.includes(slug)); 14035 }, [postTypes]); 14036 }; 14037 const usePublicTaxonomies = () => { 14038 const taxonomies = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).getTaxonomies({ 14039 per_page: -1 14040 }), []); 14041 return (0,external_wp_element_namespaceObject.useMemo)(() => { 14042 return taxonomies?.filter(({ 14043 visibility 14044 }) => visibility?.publicly_queryable); 14045 }, [taxonomies]); 14046 }; 14047 function usePostTypeNeedsUniqueIdentifier(publicPostTypes) { 14048 const postTypeLabels = (0,external_wp_element_namespaceObject.useMemo)(() => publicPostTypes?.reduce((accumulator, { 14049 labels 14050 }) => { 14051 const singularName = labels.singular_name.toLowerCase(); 14052 accumulator[singularName] = (accumulator[singularName] || 0) + 1; 14053 return accumulator; 14054 }, {})); 14055 return (0,external_wp_element_namespaceObject.useCallback)(({ 14056 labels, 14057 slug 14058 }) => { 14059 const singularName = labels.singular_name.toLowerCase(); 14060 return postTypeLabels[singularName] > 1 && singularName !== slug; 14061 }, [postTypeLabels]); 14062 } 14063 function usePostTypeArchiveMenuItems() { 14064 const publicPostTypes = usePublicPostTypes(); 14065 const postTypesWithArchives = (0,external_wp_element_namespaceObject.useMemo)(() => publicPostTypes?.filter(postType => postType.has_archive), [publicPostTypes]); 14066 const existingTemplates = useExistingTemplates(); 14067 const needsUniqueIdentifier = usePostTypeNeedsUniqueIdentifier(postTypesWithArchives); 14068 return (0,external_wp_element_namespaceObject.useMemo)(() => postTypesWithArchives?.filter(postType => !(existingTemplates || []).some(existingTemplate => existingTemplate.slug === 'archive-' + postType.slug)).map(postType => { 14069 let title; 14070 if (needsUniqueIdentifier(postType)) { 14071 title = (0,external_wp_i18n_namespaceObject.sprintf)( 14072 // translators: %1s: Name of the post type e.g: "Post"; %2s: Slug of the post type e.g: "book". 14073 (0,external_wp_i18n_namespaceObject.__)('Archive: %1$s (%2$s)'), postType.labels.singular_name, postType.slug); 14074 } else { 14075 title = (0,external_wp_i18n_namespaceObject.sprintf)( 14076 // translators: %s: Name of the post type e.g: "Post". 14077 (0,external_wp_i18n_namespaceObject.__)('Archive: %s'), postType.labels.singular_name); 14078 } 14079 return { 14080 slug: 'archive-' + postType.slug, 14081 description: (0,external_wp_i18n_namespaceObject.sprintf)( 14082 // translators: %s: Name of the post type e.g: "Post". 14083 (0,external_wp_i18n_namespaceObject.__)('Displays an archive with the latest posts of type: %s.'), postType.labels.singular_name), 14084 title, 14085 // `icon` is the `menu_icon` property of a post type. We 14086 // only handle `dashicons` for now, even if the `menu_icon` 14087 // also supports urls and svg as values. 14088 icon: postType.icon?.startsWith('dashicons-') ? postType.icon.slice(10) : library_archive, 14089 templatePrefix: 'archive' 14090 }; 14091 }) || [], [postTypesWithArchives, existingTemplates, needsUniqueIdentifier]); 14092 } 14093 const usePostTypeMenuItems = onClickMenuItem => { 14094 const publicPostTypes = usePublicPostTypes(); 14095 const existingTemplates = useExistingTemplates(); 14096 const defaultTemplateTypes = useDefaultTemplateTypes(); 14097 const needsUniqueIdentifier = usePostTypeNeedsUniqueIdentifier(publicPostTypes); 14098 // `page`is a special case in template hierarchy. 14099 const templatePrefixes = (0,external_wp_element_namespaceObject.useMemo)(() => publicPostTypes?.reduce((accumulator, { 14100 slug 14101 }) => { 14102 let suffix = slug; 14103 if (slug !== 'page') { 14104 suffix = `single-$suffix}`; 14105 } 14106 accumulator[slug] = suffix; 14107 return accumulator; 14108 }, {}), [publicPostTypes]); 14109 const postTypesInfo = useEntitiesInfo('postType', templatePrefixes); 14110 const existingTemplateSlugs = (existingTemplates || []).map(({ 14111 slug 14112 }) => slug); 14113 const menuItems = (publicPostTypes || []).reduce((accumulator, postType) => { 14114 const { 14115 slug, 14116 labels, 14117 icon 14118 } = postType; 14119 // We need to check if the general template is part of the 14120 // defaultTemplateTypes. If it is, just use that info and 14121 // augment it with the specific template functionality. 14122 const generalTemplateSlug = templatePrefixes[slug]; 14123 const defaultTemplateType = defaultTemplateTypes?.find(({ 14124 slug: _slug 14125 }) => _slug === generalTemplateSlug); 14126 const hasGeneralTemplate = existingTemplateSlugs?.includes(generalTemplateSlug); 14127 const _needsUniqueIdentifier = needsUniqueIdentifier(postType); 14128 let menuItemTitle = (0,external_wp_i18n_namespaceObject.sprintf)( 14129 // translators: %s: Name of the post type e.g: "Post". 14130 (0,external_wp_i18n_namespaceObject.__)('Single item: %s'), labels.singular_name); 14131 if (_needsUniqueIdentifier) { 14132 menuItemTitle = (0,external_wp_i18n_namespaceObject.sprintf)( 14133 // translators: %1s: Name of the post type e.g: "Post"; %2s: Slug of the post type e.g: "book". 14134 (0,external_wp_i18n_namespaceObject.__)('Single item: %1$s (%2$s)'), labels.singular_name, slug); 14135 } 14136 const menuItem = defaultTemplateType ? { 14137 ...defaultTemplateType, 14138 templatePrefix: templatePrefixes[slug] 14139 } : { 14140 slug: generalTemplateSlug, 14141 title: menuItemTitle, 14142 description: (0,external_wp_i18n_namespaceObject.sprintf)( 14143 // translators: %s: Name of the post type e.g: "Post". 14144 (0,external_wp_i18n_namespaceObject.__)('Displays a single item: %s.'), labels.singular_name), 14145 // `icon` is the `menu_icon` property of a post type. We 14146 // only handle `dashicons` for now, even if the `menu_icon` 14147 // also supports urls and svg as values. 14148 icon: icon?.startsWith('dashicons-') ? icon.slice(10) : library_post, 14149 templatePrefix: templatePrefixes[slug] 14150 }; 14151 const hasEntities = postTypesInfo?.[slug]?.hasEntities; 14152 // We have a different template creation flow only if they have entities. 14153 if (hasEntities) { 14154 menuItem.onClick = template => { 14155 onClickMenuItem({ 14156 type: 'postType', 14157 slug, 14158 config: { 14159 recordNamePath: 'title.rendered', 14160 queryArgs: ({ 14161 search 14162 }) => { 14163 return { 14164 _fields: 'id,title,slug,link', 14165 orderBy: search ? 'relevance' : 'modified', 14166 exclude: postTypesInfo[slug].existingEntitiesIds 14167 }; 14168 }, 14169 getSpecificTemplate: suggestion => { 14170 const templateSlug = `$templatePrefixes[slug]}-$suggestion.slug}`; 14171 return { 14172 title: templateSlug, 14173 slug: templateSlug, 14174 templatePrefix: templatePrefixes[slug] 14175 }; 14176 } 14177 }, 14178 labels, 14179 hasGeneralTemplate, 14180 template 14181 }); 14182 }; 14183 } 14184 // We don't need to add the menu item if there are no 14185 // entities and the general template exists. 14186 if (!hasGeneralTemplate || hasEntities) { 14187 accumulator.push(menuItem); 14188 } 14189 return accumulator; 14190 }, []); 14191 // Split menu items into two groups: one for the default post types 14192 // and one for the rest. 14193 const postTypesMenuItems = (0,external_wp_element_namespaceObject.useMemo)(() => menuItems.reduce((accumulator, postType) => { 14194 const { 14195 slug 14196 } = postType; 14197 let key = 'postTypesMenuItems'; 14198 if (slug === 'page') { 14199 key = 'defaultPostTypesMenuItems'; 14200 } 14201 accumulator[key].push(postType); 14202 return accumulator; 14203 }, { 14204 defaultPostTypesMenuItems: [], 14205 postTypesMenuItems: [] 14206 }), [menuItems]); 14207 return postTypesMenuItems; 14208 }; 14209 const useTaxonomiesMenuItems = onClickMenuItem => { 14210 const publicTaxonomies = usePublicTaxonomies(); 14211 const existingTemplates = useExistingTemplates(); 14212 const defaultTemplateTypes = useDefaultTemplateTypes(); 14213 // `category` and `post_tag` are special cases in template hierarchy. 14214 const templatePrefixes = (0,external_wp_element_namespaceObject.useMemo)(() => publicTaxonomies?.reduce((accumulator, { 14215 slug 14216 }) => { 14217 let suffix = slug; 14218 if (!['category', 'post_tag'].includes(slug)) { 14219 suffix = `taxonomy-$suffix}`; 14220 } 14221 if (slug === 'post_tag') { 14222 suffix = `tag`; 14223 } 14224 accumulator[slug] = suffix; 14225 return accumulator; 14226 }, {}), [publicTaxonomies]); 14227 // We need to keep track of naming conflicts. If a conflict 14228 // occurs, we need to add slug. 14229 const taxonomyLabels = publicTaxonomies?.reduce((accumulator, { 14230 labels 14231 }) => { 14232 const singularName = labels.singular_name.toLowerCase(); 14233 accumulator[singularName] = (accumulator[singularName] || 0) + 1; 14234 return accumulator; 14235 }, {}); 14236 const needsUniqueIdentifier = (labels, slug) => { 14237 if (['category', 'post_tag'].includes(slug)) { 14238 return false; 14239 } 14240 const singularName = labels.singular_name.toLowerCase(); 14241 return taxonomyLabels[singularName] > 1 && singularName !== slug; 14242 }; 14243 const taxonomiesInfo = useEntitiesInfo('taxonomy', templatePrefixes); 14244 const existingTemplateSlugs = (existingTemplates || []).map(({ 14245 slug 14246 }) => slug); 14247 const menuItems = (publicTaxonomies || []).reduce((accumulator, taxonomy) => { 14248 const { 14249 slug, 14250 labels 14251 } = taxonomy; 14252 // We need to check if the general template is part of the 14253 // defaultTemplateTypes. If it is, just use that info and 14254 // augment it with the specific template functionality. 14255 const generalTemplateSlug = templatePrefixes[slug]; 14256 const defaultTemplateType = defaultTemplateTypes?.find(({ 14257 slug: _slug 14258 }) => _slug === generalTemplateSlug); 14259 const hasGeneralTemplate = existingTemplateSlugs?.includes(generalTemplateSlug); 14260 const _needsUniqueIdentifier = needsUniqueIdentifier(labels, slug); 14261 let menuItemTitle = labels.singular_name; 14262 if (_needsUniqueIdentifier) { 14263 menuItemTitle = (0,external_wp_i18n_namespaceObject.sprintf)( 14264 // translators: %1s: Name of the taxonomy e.g: "Category"; %2s: Slug of the taxonomy e.g: "product_cat". 14265 (0,external_wp_i18n_namespaceObject.__)('%1$s (%2$s)'), labels.singular_name, slug); 14266 } 14267 const menuItem = defaultTemplateType ? { 14268 ...defaultTemplateType, 14269 templatePrefix: templatePrefixes[slug] 14270 } : { 14271 slug: generalTemplateSlug, 14272 title: menuItemTitle, 14273 description: (0,external_wp_i18n_namespaceObject.sprintf)( 14274 // translators: %s: Name of the taxonomy e.g: "Product Categories". 14275 (0,external_wp_i18n_namespaceObject.__)('Displays taxonomy: %s.'), labels.singular_name), 14276 icon: block_meta, 14277 templatePrefix: templatePrefixes[slug] 14278 }; 14279 const hasEntities = taxonomiesInfo?.[slug]?.hasEntities; 14280 // We have a different template creation flow only if they have entities. 14281 if (hasEntities) { 14282 menuItem.onClick = template => { 14283 onClickMenuItem({ 14284 type: 'taxonomy', 14285 slug, 14286 config: { 14287 queryArgs: ({ 14288 search 14289 }) => { 14290 return { 14291 _fields: 'id,name,slug,link', 14292 orderBy: search ? 'name' : 'count', 14293 exclude: taxonomiesInfo[slug].existingEntitiesIds 14294 }; 14295 }, 14296 getSpecificTemplate: suggestion => { 14297 const templateSlug = `$templatePrefixes[slug]}-$suggestion.slug}`; 14298 return { 14299 title: templateSlug, 14300 slug: templateSlug, 14301 templatePrefix: templatePrefixes[slug] 14302 }; 14303 } 14304 }, 14305 labels, 14306 hasGeneralTemplate, 14307 template 14308 }); 14309 }; 14310 } 14311 // We don't need to add the menu item if there are no 14312 // entities and the general template exists. 14313 if (!hasGeneralTemplate || hasEntities) { 14314 accumulator.push(menuItem); 14315 } 14316 return accumulator; 14317 }, []); 14318 // Split menu items into two groups: one for the default taxonomies 14319 // and one for the rest. 14320 const taxonomiesMenuItems = (0,external_wp_element_namespaceObject.useMemo)(() => menuItems.reduce((accumulator, taxonomy) => { 14321 const { 14322 slug 14323 } = taxonomy; 14324 let key = 'taxonomiesMenuItems'; 14325 if (['category', 'tag'].includes(slug)) { 14326 key = 'defaultTaxonomiesMenuItems'; 14327 } 14328 accumulator[key].push(taxonomy); 14329 return accumulator; 14330 }, { 14331 defaultTaxonomiesMenuItems: [], 14332 taxonomiesMenuItems: [] 14333 }), [menuItems]); 14334 return taxonomiesMenuItems; 14335 }; 14336 const USE_AUTHOR_MENU_ITEM_TEMPLATE_PREFIX = { 14337 user: 'author' 14338 }; 14339 const USE_AUTHOR_MENU_ITEM_QUERY_PARAMETERS = { 14340 user: { 14341 who: 'authors' 14342 } 14343 }; 14344 function useAuthorMenuItem(onClickMenuItem) { 14345 const existingTemplates = useExistingTemplates(); 14346 const defaultTemplateTypes = useDefaultTemplateTypes(); 14347 const authorInfo = useEntitiesInfo('root', USE_AUTHOR_MENU_ITEM_TEMPLATE_PREFIX, USE_AUTHOR_MENU_ITEM_QUERY_PARAMETERS); 14348 let authorMenuItem = defaultTemplateTypes?.find(({ 14349 slug 14350 }) => slug === 'author'); 14351 if (!authorMenuItem) { 14352 authorMenuItem = { 14353 description: (0,external_wp_i18n_namespaceObject.__)('Displays latest posts written by a single author.'), 14354 slug: 'author', 14355 title: 'Author' 14356 }; 14357 } 14358 const hasGeneralTemplate = !!existingTemplates?.find(({ 14359 slug 14360 }) => slug === 'author'); 14361 if (authorInfo.user?.hasEntities) { 14362 authorMenuItem = { 14363 ...authorMenuItem, 14364 templatePrefix: 'author' 14365 }; 14366 authorMenuItem.onClick = template => { 14367 onClickMenuItem({ 14368 type: 'root', 14369 slug: 'user', 14370 config: { 14371 queryArgs: ({ 14372 search 14373 }) => { 14374 return { 14375 _fields: 'id,name,slug,link', 14376 orderBy: search ? 'name' : 'registered_date', 14377 exclude: authorInfo.user.existingEntitiesIds, 14378 who: 'authors' 14379 }; 14380 }, 14381 getSpecificTemplate: suggestion => { 14382 const templateSlug = `author-$suggestion.slug}`; 14383 return { 14384 title: templateSlug, 14385 slug: templateSlug, 14386 templatePrefix: 'author' 14387 }; 14388 } 14389 }, 14390 labels: { 14391 singular_name: (0,external_wp_i18n_namespaceObject.__)('Author'), 14392 search_items: (0,external_wp_i18n_namespaceObject.__)('Search Authors'), 14393 not_found: (0,external_wp_i18n_namespaceObject.__)('No authors found.'), 14394 all_items: (0,external_wp_i18n_namespaceObject.__)('All Authors') 14395 }, 14396 hasGeneralTemplate, 14397 template 14398 }); 14399 }; 14400 } 14401 if (!hasGeneralTemplate || authorInfo.user?.hasEntities) { 14402 return authorMenuItem; 14403 } 14404 } 14405 14406 /** 14407 * Helper hook that filters all the existing templates by the given 14408 * object with the entity's slug as key and the template prefix as value. 14409 * 14410 * Example: 14411 * `existingTemplates` is: [ { slug: 'tag-apple' }, { slug: 'page-about' }, { slug: 'tag' } ] 14412 * `templatePrefixes` is: { post_tag: 'tag' } 14413 * It will return: { post_tag: ['apple'] } 14414 * 14415 * Note: We append the `-` to the given template prefix in this function for our checks. 14416 * 14417 * @param {Record<string,string>} templatePrefixes An object with the entity's slug as key and the template prefix as value. 14418 * @return {Record<string,string[]>} An object with the entity's slug as key and an array with the existing template slugs as value. 14419 */ 14420 const useExistingTemplateSlugs = templatePrefixes => { 14421 const existingTemplates = useExistingTemplates(); 14422 const existingSlugs = (0,external_wp_element_namespaceObject.useMemo)(() => { 14423 return Object.entries(templatePrefixes || {}).reduce((accumulator, [slug, prefix]) => { 14424 const slugsWithTemplates = (existingTemplates || []).reduce((_accumulator, existingTemplate) => { 14425 const _prefix = `$prefix}-`; 14426 if (existingTemplate.slug.startsWith(_prefix)) { 14427 _accumulator.push(existingTemplate.slug.substring(_prefix.length)); 14428 } 14429 return _accumulator; 14430 }, []); 14431 if (slugsWithTemplates.length) { 14432 accumulator[slug] = slugsWithTemplates; 14433 } 14434 return accumulator; 14435 }, {}); 14436 }, [templatePrefixes, existingTemplates]); 14437 return existingSlugs; 14438 }; 14439 14440 /** 14441 * Helper hook that finds the existing records with an associated template, 14442 * as they need to be excluded from the template suggestions. 14443 * 14444 * @param {string} entityName The entity's name. 14445 * @param {Record<string,string>} templatePrefixes An object with the entity's slug as key and the template prefix as value. 14446 * @param {Record<string,Object>} additionalQueryParameters An object with the entity's slug as key and additional query parameters as value. 14447 * @return {Record<string,EntitiesInfo>} An object with the entity's slug as key and the existing records as value. 14448 */ 14449 const useTemplatesToExclude = (entityName, templatePrefixes, additionalQueryParameters = {}) => { 14450 const slugsToExcludePerEntity = useExistingTemplateSlugs(templatePrefixes); 14451 const recordsToExcludePerEntity = (0,external_wp_data_namespaceObject.useSelect)(select => { 14452 return Object.entries(slugsToExcludePerEntity || {}).reduce((accumulator, [slug, slugsWithTemplates]) => { 14453 const entitiesWithTemplates = select(external_wp_coreData_namespaceObject.store).getEntityRecords(entityName, slug, { 14454 _fields: 'id', 14455 context: 'view', 14456 slug: slugsWithTemplates, 14457 ...additionalQueryParameters[slug] 14458 }); 14459 if (entitiesWithTemplates?.length) { 14460 accumulator[slug] = entitiesWithTemplates; 14461 } 14462 return accumulator; 14463 }, {}); 14464 }, [slugsToExcludePerEntity]); 14465 return recordsToExcludePerEntity; 14466 }; 14467 14468 /** 14469 * Helper hook that returns information about an entity having 14470 * records that we can create a specific template for. 14471 * 14472 * For example we can search for `terms` in `taxonomy` entity or 14473 * `posts` in `postType` entity. 14474 * 14475 * First we need to find the existing records with an associated template, 14476 * to query afterwards for any remaining record, by excluding them. 14477 * 14478 * @param {string} entityName The entity's name. 14479 * @param {Record<string,string>} templatePrefixes An object with the entity's slug as key and the template prefix as value. 14480 * @param {Record<string,Object>} additionalQueryParameters An object with the entity's slug as key and additional query parameters as value. 14481 * @return {Record<string,EntitiesInfo>} An object with the entity's slug as key and the EntitiesInfo as value. 14482 */ 14483 const useEntitiesInfo = (entityName, templatePrefixes, additionalQueryParameters = {}) => { 14484 const recordsToExcludePerEntity = useTemplatesToExclude(entityName, templatePrefixes, additionalQueryParameters); 14485 const entitiesInfo = (0,external_wp_data_namespaceObject.useSelect)(select => { 14486 return Object.keys(templatePrefixes || {}).reduce((accumulator, slug) => { 14487 const existingEntitiesIds = recordsToExcludePerEntity?.[slug]?.map(({ 14488 id 14489 }) => id) || []; 14490 accumulator[slug] = { 14491 hasEntities: !!select(external_wp_coreData_namespaceObject.store).getEntityRecords(entityName, slug, { 14492 per_page: 1, 14493 _fields: 'id', 14494 context: 'view', 14495 exclude: existingEntitiesIds, 14496 ...additionalQueryParameters[slug] 14497 })?.length, 14498 existingEntitiesIds 14499 }; 14500 return accumulator; 14501 }, {}); 14502 }, [templatePrefixes, recordsToExcludePerEntity]); 14503 return entitiesInfo; 14504 }; 14505 14506 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/add-new-template/add-custom-template-modal-content.js 14507 14508 /** 14509 * WordPress dependencies 14510 */ 14511 14512 14513 14514 14515 14516 14517 14518 /** 14519 * Internal dependencies 14520 */ 14521 14522 14523 const { 14524 CompositeV2: add_custom_template_modal_content_Composite, 14525 CompositeItemV2: add_custom_template_modal_content_CompositeItem, 14526 useCompositeStoreV2: add_custom_template_modal_content_useCompositeStore 14527 } = unlock(external_wp_components_namespaceObject.privateApis); 14528 const add_custom_template_modal_content_EMPTY_ARRAY = []; 14529 function SuggestionListItem({ 14530 suggestion, 14531 search, 14532 onSelect, 14533 entityForSuggestions 14534 }) { 14535 const baseCssClass = 'edit-site-custom-template-modal__suggestions_list__list-item'; 14536 return (0,external_React_.createElement)(add_custom_template_modal_content_CompositeItem, { 14537 render: (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 14538 role: "option", 14539 className: baseCssClass, 14540 onClick: () => onSelect(entityForSuggestions.config.getSpecificTemplate(suggestion)) 14541 }) 14542 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalText, { 14543 size: "body", 14544 lineHeight: 1.53846153846 // 20px 14545 , 14546 weight: 500, 14547 className: `$baseCssClass}__title` 14548 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.TextHighlight, { 14549 text: (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(suggestion.name), 14550 highlight: search 14551 })), suggestion.link && (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalText, { 14552 size: "body", 14553 lineHeight: 1.53846153846 // 20px 14554 , 14555 className: `$baseCssClass}__info` 14556 }, suggestion.link)); 14557 } 14558 function useSearchSuggestions(entityForSuggestions, search) { 14559 const { 14560 config 14561 } = entityForSuggestions; 14562 const query = (0,external_wp_element_namespaceObject.useMemo)(() => ({ 14563 order: 'asc', 14564 context: 'view', 14565 search, 14566 per_page: search ? 20 : 10, 14567 ...config.queryArgs(search) 14568 }), [search, config]); 14569 const { 14570 records: searchResults, 14571 hasResolved: searchHasResolved 14572 } = (0,external_wp_coreData_namespaceObject.useEntityRecords)(entityForSuggestions.type, entityForSuggestions.slug, query); 14573 const [suggestions, setSuggestions] = (0,external_wp_element_namespaceObject.useState)(add_custom_template_modal_content_EMPTY_ARRAY); 14574 (0,external_wp_element_namespaceObject.useEffect)(() => { 14575 if (!searchHasResolved) return; 14576 let newSuggestions = add_custom_template_modal_content_EMPTY_ARRAY; 14577 if (searchResults?.length) { 14578 newSuggestions = searchResults; 14579 if (config.recordNamePath) { 14580 newSuggestions = mapToIHasNameAndId(newSuggestions, config.recordNamePath); 14581 } 14582 } 14583 // Update suggestions only when the query has resolved, so as to keep 14584 // the previous results in the UI. 14585 setSuggestions(newSuggestions); 14586 }, [searchResults, searchHasResolved]); 14587 return suggestions; 14588 } 14589 function SuggestionList({ 14590 entityForSuggestions, 14591 onSelect 14592 }) { 14593 const composite = add_custom_template_modal_content_useCompositeStore({ 14594 orientation: 'vertical' 14595 }); 14596 const [search, setSearch, debouncedSearch] = (0,external_wp_compose_namespaceObject.useDebouncedInput)(); 14597 const suggestions = useSearchSuggestions(entityForSuggestions, debouncedSearch); 14598 const { 14599 labels 14600 } = entityForSuggestions; 14601 const [showSearchControl, setShowSearchControl] = (0,external_wp_element_namespaceObject.useState)(false); 14602 if (!showSearchControl && suggestions?.length > 9) { 14603 setShowSearchControl(true); 14604 } 14605 return (0,external_React_.createElement)(external_React_.Fragment, null, showSearchControl && (0,external_React_.createElement)(external_wp_components_namespaceObject.SearchControl, { 14606 __nextHasNoMarginBottom: true, 14607 onChange: setSearch, 14608 value: search, 14609 label: labels.search_items, 14610 placeholder: labels.search_items 14611 }), !!suggestions?.length && (0,external_React_.createElement)(add_custom_template_modal_content_Composite, { 14612 store: composite, 14613 role: "listbox", 14614 className: "edit-site-custom-template-modal__suggestions_list", 14615 "aria-label": (0,external_wp_i18n_namespaceObject.__)('Suggestions list') 14616 }, suggestions.map(suggestion => (0,external_React_.createElement)(SuggestionListItem, { 14617 key: suggestion.slug, 14618 suggestion: suggestion, 14619 search: debouncedSearch, 14620 onSelect: onSelect, 14621 entityForSuggestions: entityForSuggestions 14622 }))), debouncedSearch && !suggestions?.length && (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalText, { 14623 as: "p", 14624 className: "edit-site-custom-template-modal__no-results" 14625 }, labels.not_found)); 14626 } 14627 function AddCustomTemplateModalContent({ 14628 onSelect, 14629 entityForSuggestions 14630 }) { 14631 const [showSearchEntities, setShowSearchEntities] = (0,external_wp_element_namespaceObject.useState)(entityForSuggestions.hasGeneralTemplate); 14632 return (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { 14633 spacing: 4, 14634 className: "edit-site-custom-template-modal__contents-wrapper", 14635 alignment: "left" 14636 }, !showSearchEntities && (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalText, { 14637 as: "p" 14638 }, (0,external_wp_i18n_namespaceObject.__)('Select whether to create a single template for all items or a specific one.')), (0,external_React_.createElement)(external_wp_components_namespaceObject.Flex, { 14639 className: "edit-site-custom-template-modal__contents", 14640 gap: "4", 14641 align: "initial" 14642 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.FlexItem, { 14643 isBlock: true, 14644 as: external_wp_components_namespaceObject.Button, 14645 onClick: () => { 14646 const { 14647 slug, 14648 title, 14649 description, 14650 templatePrefix 14651 } = entityForSuggestions.template; 14652 onSelect({ 14653 slug, 14654 title, 14655 description, 14656 templatePrefix 14657 }); 14658 } 14659 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalText, { 14660 as: "span", 14661 weight: 500, 14662 lineHeight: 1.53846153846 // 20px 14663 }, entityForSuggestions.labels.all_items), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalText, { 14664 as: "span", 14665 lineHeight: 1.53846153846 // 20px 14666 }, 14667 // translators: The user is given the choice to set up a template for all items of a post type or taxonomy, or just a specific one. 14668 (0,external_wp_i18n_namespaceObject.__)('For all items'))), (0,external_React_.createElement)(external_wp_components_namespaceObject.FlexItem, { 14669 isBlock: true, 14670 as: external_wp_components_namespaceObject.Button, 14671 onClick: () => { 14672 setShowSearchEntities(true); 14673 } 14674 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalText, { 14675 as: "span", 14676 weight: 500, 14677 lineHeight: 1.53846153846 // 20px 14678 }, entityForSuggestions.labels.singular_name), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalText, { 14679 as: "span", 14680 lineHeight: 1.53846153846 // 20px 14681 }, 14682 // translators: The user is given the choice to set up a template for all items of a post type or taxonomy, or just a specific one. 14683 (0,external_wp_i18n_namespaceObject.__)('For a specific item'))))), showSearchEntities && (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalText, { 14684 as: "p" 14685 }, (0,external_wp_i18n_namespaceObject.__)('This template will be used only for the specific item chosen.')), (0,external_React_.createElement)(SuggestionList, { 14686 entityForSuggestions: entityForSuggestions, 14687 onSelect: onSelect 14688 }))); 14689 } 14690 /* harmony default export */ const add_custom_template_modal_content = (AddCustomTemplateModalContent); 14691 14692 ;// CONCATENATED MODULE: ./node_modules/tslib/tslib.es6.mjs 14693 /****************************************************************************** 14694 Copyright (c) Microsoft Corporation. 14695 14696 Permission to use, copy, modify, and/or distribute this software for any 14697 purpose with or without fee is hereby granted. 14698 14699 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH 14700 REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 14701 AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, 14702 INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 14703 LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR 14704 OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 14705 PERFORMANCE OF THIS SOFTWARE. 14706 ***************************************************************************** */ 14707 /* global Reflect, Promise, SuppressedError, Symbol */ 14708 14709 var extendStatics = function(d, b) { 14710 extendStatics = Object.setPrototypeOf || 14711 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || 14712 function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; 14713 return extendStatics(d, b); 14714 }; 14715 14716 function __extends(d, b) { 14717 if (typeof b !== "function" && b !== null) 14718 throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); 14719 extendStatics(d, b); 14720 function __() { this.constructor = d; } 14721 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); 14722 } 14723 14724 var __assign = function() { 14725 __assign = Object.assign || function __assign(t) { 14726 for (var s, i = 1, n = arguments.length; i < n; i++) { 14727 s = arguments[i]; 14728 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; 14729 } 14730 return t; 14731 } 14732 return __assign.apply(this, arguments); 14733 } 14734 14735 function __rest(s, e) { 14736 var t = {}; 14737 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) 14738 t[p] = s[p]; 14739 if (s != null && typeof Object.getOwnPropertySymbols === "function") 14740 for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { 14741 if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) 14742 t[p[i]] = s[p[i]]; 14743 } 14744 return t; 14745 } 14746 14747 function __decorate(decorators, target, key, desc) { 14748 var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; 14749 if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); 14750 else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; 14751 return c > 3 && r && Object.defineProperty(target, key, r), r; 14752 } 14753 14754 function __param(paramIndex, decorator) { 14755 return function (target, key) { decorator(target, key, paramIndex); } 14756 } 14757 14758 function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) { 14759 function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; } 14760 var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value"; 14761 var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null; 14762 var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {}); 14763 var _, done = false; 14764 for (var i = decorators.length - 1; i >= 0; i--) { 14765 var context = {}; 14766 for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p]; 14767 for (var p in contextIn.access) context.access[p] = contextIn.access[p]; 14768 context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); }; 14769 var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context); 14770 if (kind === "accessor") { 14771 if (result === void 0) continue; 14772 if (result === null || typeof result !== "object") throw new TypeError("Object expected"); 14773 if (_ = accept(result.get)) descriptor.get = _; 14774 if (_ = accept(result.set)) descriptor.set = _; 14775 if (_ = accept(result.init)) initializers.unshift(_); 14776 } 14777 else if (_ = accept(result)) { 14778 if (kind === "field") initializers.unshift(_); 14779 else descriptor[key] = _; 14780 } 14781 } 14782 if (target) Object.defineProperty(target, contextIn.name, descriptor); 14783 done = true; 14784 }; 14785 14786 function __runInitializers(thisArg, initializers, value) { 14787 var useValue = arguments.length > 2; 14788 for (var i = 0; i < initializers.length; i++) { 14789 value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg); 14790 } 14791 return useValue ? value : void 0; 14792 }; 14793 14794 function __propKey(x) { 14795 return typeof x === "symbol" ? x : "".concat(x); 14796 }; 14797 14798 function __setFunctionName(f, name, prefix) { 14799 if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : ""; 14800 return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name }); 14801 }; 14802 14803 function __metadata(metadataKey, metadataValue) { 14804 if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue); 14805 } 14806 14807 function __awaiter(thisArg, _arguments, P, generator) { 14808 function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } 14809 return new (P || (P = Promise))(function (resolve, reject) { 14810 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } 14811 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } 14812 function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } 14813 step((generator = generator.apply(thisArg, _arguments || [])).next()); 14814 }); 14815 } 14816 14817 function __generator(thisArg, body) { 14818 var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; 14819 return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; 14820 function verb(n) { return function (v) { return step([n, v]); }; } 14821 function step(op) { 14822 if (f) throw new TypeError("Generator is already executing."); 14823 while (g && (g = 0, op[0] && (_ = 0)), _) try { 14824 if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; 14825 if (y = 0, t) op = [op[0] & 2, t.value]; 14826 switch (op[0]) { 14827 case 0: case 1: t = op; break; 14828 case 4: _.label++; return { value: op[1], done: false }; 14829 case 5: _.label++; y = op[1]; op = [0]; continue; 14830 case 7: op = _.ops.pop(); _.trys.pop(); continue; 14831 default: 14832 if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } 14833 if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } 14834 if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } 14835 if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } 14836 if (t[2]) _.ops.pop(); 14837 _.trys.pop(); continue; 14838 } 14839 op = body.call(thisArg, _); 14840 } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } 14841 if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; 14842 } 14843 } 14844 14845 var __createBinding = Object.create ? (function(o, m, k, k2) { 14846 if (k2 === undefined) k2 = k; 14847 var desc = Object.getOwnPropertyDescriptor(m, k); 14848 if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { 14849 desc = { enumerable: true, get: function() { return m[k]; } }; 14850 } 14851 Object.defineProperty(o, k2, desc); 14852 }) : (function(o, m, k, k2) { 14853 if (k2 === undefined) k2 = k; 14854 o[k2] = m[k]; 14855 }); 14856 14857 function __exportStar(m, o) { 14858 for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p); 14859 } 14860 14861 function __values(o) { 14862 var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; 14863 if (m) return m.call(o); 14864 if (o && typeof o.length === "number") return { 14865 next: function () { 14866 if (o && i >= o.length) o = void 0; 14867 return { value: o && o[i++], done: !o }; 14868 } 14869 }; 14870 throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); 14871 } 14872 14873 function __read(o, n) { 14874 var m = typeof Symbol === "function" && o[Symbol.iterator]; 14875 if (!m) return o; 14876 var i = m.call(o), r, ar = [], e; 14877 try { 14878 while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); 14879 } 14880 catch (error) { e = { error: error }; } 14881 finally { 14882 try { 14883 if (r && !r.done && (m = i["return"])) m.call(i); 14884 } 14885 finally { if (e) throw e.error; } 14886 } 14887 return ar; 14888 } 14889 14890 /** @deprecated */ 14891 function __spread() { 14892 for (var ar = [], i = 0; i < arguments.length; i++) 14893 ar = ar.concat(__read(arguments[i])); 14894 return ar; 14895 } 14896 14897 /** @deprecated */ 14898 function __spreadArrays() { 14899 for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; 14900 for (var r = Array(s), k = 0, i = 0; i < il; i++) 14901 for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) 14902 r[k] = a[j]; 14903 return r; 14904 } 14905 14906 function __spreadArray(to, from, pack) { 14907 if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { 14908 if (ar || !(i in from)) { 14909 if (!ar) ar = Array.prototype.slice.call(from, 0, i); 14910 ar[i] = from[i]; 14911 } 14912 } 14913 return to.concat(ar || Array.prototype.slice.call(from)); 14914 } 14915 14916 function __await(v) { 14917 return this instanceof __await ? (this.v = v, this) : new __await(v); 14918 } 14919 14920 function __asyncGenerator(thisArg, _arguments, generator) { 14921 if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); 14922 var g = generator.apply(thisArg, _arguments || []), i, q = []; 14923 return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; 14924 function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } 14925 function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } 14926 function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } 14927 function fulfill(value) { resume("next", value); } 14928 function reject(value) { resume("throw", value); } 14929 function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } 14930 } 14931 14932 function __asyncDelegator(o) { 14933 var i, p; 14934 return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i; 14935 function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; } 14936 } 14937 14938 function __asyncValues(o) { 14939 if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); 14940 var m = o[Symbol.asyncIterator], i; 14941 return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); 14942 function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } 14943 function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } 14944 } 14945 14946 function __makeTemplateObject(cooked, raw) { 14947 if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } 14948 return cooked; 14949 }; 14950 14951 var __setModuleDefault = Object.create ? (function(o, v) { 14952 Object.defineProperty(o, "default", { enumerable: true, value: v }); 14953 }) : function(o, v) { 14954 o["default"] = v; 14955 }; 14956 14957 function __importStar(mod) { 14958 if (mod && mod.__esModule) return mod; 14959 var result = {}; 14960 if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); 14961 __setModuleDefault(result, mod); 14962 return result; 14963 } 14964 14965 function __importDefault(mod) { 14966 return (mod && mod.__esModule) ? mod : { default: mod }; 14967 } 14968 14969 function __classPrivateFieldGet(receiver, state, kind, f) { 14970 if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); 14971 if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it"); 14972 return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); 14973 } 14974 14975 function __classPrivateFieldSet(receiver, state, value, kind, f) { 14976 if (kind === "m") throw new TypeError("Private method is not writable"); 14977 if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter"); 14978 if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it"); 14979 return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value; 14980 } 14981 14982 function __classPrivateFieldIn(state, receiver) { 14983 if (receiver === null || (typeof receiver !== "object" && typeof receiver !== "function")) throw new TypeError("Cannot use 'in' operator on non-object"); 14984 return typeof state === "function" ? receiver === state : state.has(receiver); 14985 } 14986 14987 function __addDisposableResource(env, value, async) { 14988 if (value !== null && value !== void 0) { 14989 if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected."); 14990 var dispose; 14991 if (async) { 14992 if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined."); 14993 dispose = value[Symbol.asyncDispose]; 14994 } 14995 if (dispose === void 0) { 14996 if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined."); 14997 dispose = value[Symbol.dispose]; 14998 } 14999 if (typeof dispose !== "function") throw new TypeError("Object not disposable."); 15000 env.stack.push({ value: value, dispose: dispose, async: async }); 15001 } 15002 else if (async) { 15003 env.stack.push({ async: true }); 15004 } 15005 return value; 15006 } 15007 15008 var _SuppressedError = typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) { 15009 var e = new Error(message); 15010 return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e; 15011 }; 15012 15013 function __disposeResources(env) { 15014 function fail(e) { 15015 env.error = env.hasError ? new _SuppressedError(e, env.error, "An error was suppressed during disposal.") : e; 15016 env.hasError = true; 15017 } 15018 function next() { 15019 while (env.stack.length) { 15020 var rec = env.stack.pop(); 15021 try { 15022 var result = rec.dispose && rec.dispose.call(rec.value); 15023 if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); }); 15024 } 15025 catch (e) { 15026 fail(e); 15027 } 15028 } 15029 if (env.hasError) throw env.error; 15030 } 15031 return next(); 15032 } 15033 15034 /* harmony default export */ const tslib_es6 = ({ 15035 __extends, 15036 __assign, 15037 __rest, 15038 __decorate, 15039 __param, 15040 __metadata, 15041 __awaiter, 15042 __generator, 15043 __createBinding, 15044 __exportStar, 15045 __values, 15046 __read, 15047 __spread, 15048 __spreadArrays, 15049 __spreadArray, 15050 __await, 15051 __asyncGenerator, 15052 __asyncDelegator, 15053 __asyncValues, 15054 __makeTemplateObject, 15055 __importStar, 15056 __importDefault, 15057 __classPrivateFieldGet, 15058 __classPrivateFieldSet, 15059 __classPrivateFieldIn, 15060 __addDisposableResource, 15061 __disposeResources, 15062 }); 15063 15064 ;// CONCATENATED MODULE: ./node_modules/lower-case/dist.es2015/index.js 15065 /** 15066 * Source: ftp://ftp.unicode.org/Public/UCD/latest/ucd/SpecialCasing.txt 15067 */ 15068 var SUPPORTED_LOCALE = { 15069 tr: { 15070 regexp: /\u0130|\u0049|\u0049\u0307/g, 15071 map: { 15072 İ: "\u0069", 15073 I: "\u0131", 15074 İ: "\u0069", 15075 }, 15076 }, 15077 az: { 15078 regexp: /\u0130/g, 15079 map: { 15080 İ: "\u0069", 15081 I: "\u0131", 15082 İ: "\u0069", 15083 }, 15084 }, 15085 lt: { 15086 regexp: /\u0049|\u004A|\u012E|\u00CC|\u00CD|\u0128/g, 15087 map: { 15088 I: "\u0069\u0307", 15089 J: "\u006A\u0307", 15090 Į: "\u012F\u0307", 15091 Ì: "\u0069\u0307\u0300", 15092 Í: "\u0069\u0307\u0301", 15093 Ĩ: "\u0069\u0307\u0303", 15094 }, 15095 }, 15096 }; 15097 /** 15098 * Localized lower case. 15099 */ 15100 function localeLowerCase(str, locale) { 15101 var lang = SUPPORTED_LOCALE[locale.toLowerCase()]; 15102 if (lang) 15103 return lowerCase(str.replace(lang.regexp, function (m) { return lang.map[m]; })); 15104 return lowerCase(str); 15105 } 15106 /** 15107 * Lower case as a function. 15108 */ 15109 function lowerCase(str) { 15110 return str.toLowerCase(); 15111 } 15112 15113 ;// CONCATENATED MODULE: ./node_modules/no-case/dist.es2015/index.js 15114 15115 // Support camel case ("camelCase" -> "camel Case" and "CAMELCase" -> "CAMEL Case"). 15116 var DEFAULT_SPLIT_REGEXP = [/([a-z0-9])([A-Z])/g, /([A-Z])([A-Z][a-z])/g]; 15117 // Remove all non-word characters. 15118 var DEFAULT_STRIP_REGEXP = /[^A-Z0-9]+/gi; 15119 /** 15120 * Normalize the string into something other libraries can manipulate easier. 15121 */ 15122 function noCase(input, options) { 15123 if (options === void 0) { options = {}; } 15124 var _a = options.splitRegexp, splitRegexp = _a === void 0 ? DEFAULT_SPLIT_REGEXP : _a, _b = options.stripRegexp, stripRegexp = _b === void 0 ? DEFAULT_STRIP_REGEXP : _b, _c = options.transform, transform = _c === void 0 ? lowerCase : _c, _d = options.delimiter, delimiter = _d === void 0 ? " " : _d; 15125 var result = replace(replace(input, splitRegexp, "$1\0$2"), stripRegexp, "\0"); 15126 var start = 0; 15127 var end = result.length; 15128 // Trim the delimiter from around the output string. 15129 while (result.charAt(start) === "\0") 15130 start++; 15131 while (result.charAt(end - 1) === "\0") 15132 end--; 15133 // Transform each token independently. 15134 return result.slice(start, end).split("\0").map(transform).join(delimiter); 15135 } 15136 /** 15137 * Replace `re` in the input string with the replacement value. 15138 */ 15139 function replace(input, re, value) { 15140 if (re instanceof RegExp) 15141 return input.replace(re, value); 15142 return re.reduce(function (input, re) { return input.replace(re, value); }, input); 15143 } 15144 15145 ;// CONCATENATED MODULE: ./node_modules/dot-case/dist.es2015/index.js 15146 15147 15148 function dotCase(input, options) { 15149 if (options === void 0) { options = {}; } 15150 return noCase(input, __assign({ delimiter: "." }, options)); 15151 } 15152 15153 ;// CONCATENATED MODULE: ./node_modules/param-case/dist.es2015/index.js 15154 15155 15156 function paramCase(input, options) { 15157 if (options === void 0) { options = {}; } 15158 return dotCase(input, __assign({ delimiter: "-" }, options)); 15159 } 15160 15161 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/add-new-template/add-custom-generic-template-modal-content.js 15162 15163 /** 15164 * External dependencies 15165 */ 15166 15167 15168 /** 15169 * WordPress dependencies 15170 */ 15171 15172 15173 15174 function AddCustomGenericTemplateModalContent({ 15175 onClose, 15176 createTemplate 15177 }) { 15178 const [title, setTitle] = (0,external_wp_element_namespaceObject.useState)(''); 15179 const defaultTitle = (0,external_wp_i18n_namespaceObject.__)('Custom Template'); 15180 const [isBusy, setIsBusy] = (0,external_wp_element_namespaceObject.useState)(false); 15181 async function onCreateTemplate(event) { 15182 event.preventDefault(); 15183 if (isBusy) { 15184 return; 15185 } 15186 setIsBusy(true); 15187 try { 15188 await createTemplate({ 15189 slug: 'wp-custom-template-' + paramCase(title || defaultTitle), 15190 title: title || defaultTitle 15191 }, false); 15192 } finally { 15193 setIsBusy(false); 15194 } 15195 } 15196 return (0,external_React_.createElement)("form", { 15197 onSubmit: onCreateTemplate 15198 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { 15199 spacing: 6 15200 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.TextControl, { 15201 __nextHasNoMarginBottom: true, 15202 label: (0,external_wp_i18n_namespaceObject.__)('Name'), 15203 value: title, 15204 onChange: setTitle, 15205 placeholder: defaultTitle, 15206 disabled: isBusy, 15207 help: (0,external_wp_i18n_namespaceObject.__)('Describe the template, e.g. "Post with sidebar". A custom template can be manually applied to any post or page.') 15208 }), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { 15209 className: "edit-site-custom-generic-template__modal-actions", 15210 justify: "right" 15211 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 15212 variant: "tertiary", 15213 onClick: () => { 15214 onClose(); 15215 } 15216 }, (0,external_wp_i18n_namespaceObject.__)('Cancel')), (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 15217 variant: "primary", 15218 type: "submit", 15219 isBusy: isBusy, 15220 "aria-disabled": isBusy 15221 }, (0,external_wp_i18n_namespaceObject.__)('Create'))))); 15222 } 15223 /* harmony default export */ const add_custom_generic_template_modal_content = (AddCustomGenericTemplateModalContent); 15224 15225 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/add-new-template/template-actions-loading-screen.js 15226 15227 /** 15228 * WordPress dependencies 15229 */ 15230 15231 function TemplateActionsLoadingScreen() { 15232 const baseCssClass = 'edit-site-template-actions-loading-screen-modal'; 15233 return (0,external_React_.createElement)(external_wp_components_namespaceObject.Modal, { 15234 isFullScreen: true, 15235 isDismissible: false, 15236 shouldCloseOnClickOutside: false, 15237 shouldCloseOnEsc: false, 15238 onRequestClose: () => {}, 15239 __experimentalHideHeader: true, 15240 className: baseCssClass 15241 }, (0,external_React_.createElement)("div", { 15242 className: `$baseCssClass}__content` 15243 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.Spinner, null))); 15244 } 15245 15246 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/add-new-template/new-template.js 15247 15248 /** 15249 * External dependencies 15250 */ 15251 15252 15253 /** 15254 * WordPress dependencies 15255 */ 15256 15257 15258 15259 15260 15261 15262 15263 15264 15265 15266 /** 15267 * Internal dependencies 15268 */ 15269 15270 15271 /** 15272 * Internal dependencies 15273 */ 15274 15275 15276 15277 15278 15279 const { 15280 useHistory: new_template_useHistory 15281 } = unlock(external_wp_router_namespaceObject.privateApis); 15282 const DEFAULT_TEMPLATE_SLUGS = ['front-page', 'home', 'single', 'page', 'index', 'archive', 'author', 'category', 'date', 'tag', 'search', '404']; 15283 const TEMPLATE_ICONS = { 15284 'front-page': library_home, 15285 home: library_verse, 15286 single: library_pin, 15287 page: library_page, 15288 archive: library_archive, 15289 search: library_search, 15290 404: not_found, 15291 index: library_list, 15292 category: library_category, 15293 author: comment_author_avatar, 15294 taxonomy: block_meta, 15295 date: library_calendar, 15296 tag: library_tag, 15297 attachment: library_media 15298 }; 15299 function TemplateListItem({ 15300 title, 15301 direction, 15302 className, 15303 description, 15304 icon, 15305 onClick, 15306 children 15307 }) { 15308 return (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 15309 className: className, 15310 onClick: onClick, 15311 label: description, 15312 showTooltip: !!description 15313 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.Flex, { 15314 as: "span", 15315 spacing: 2, 15316 align: "center", 15317 justify: "center", 15318 style: { 15319 width: '100%' 15320 }, 15321 direction: direction 15322 }, (0,external_React_.createElement)("div", { 15323 className: "edit-site-add-new-template__template-icon" 15324 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.Icon, { 15325 icon: icon 15326 })), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { 15327 className: "edit-site-add-new-template__template-name", 15328 alignment: "center", 15329 spacing: 0 15330 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalText, { 15331 weight: 500, 15332 lineHeight: 1.53846153846 // 20px 15333 }, title), children))); 15334 } 15335 const modalContentMap = { 15336 templatesList: 1, 15337 customTemplate: 2, 15338 customGenericTemplate: 3 15339 }; 15340 function NewTemplate({ 15341 postType, 15342 toggleProps, 15343 showIcon = true 15344 }) { 15345 const [showModal, setShowModal] = (0,external_wp_element_namespaceObject.useState)(false); 15346 const [modalContent, setModalContent] = (0,external_wp_element_namespaceObject.useState)(modalContentMap.templatesList); 15347 const [entityForSuggestions, setEntityForSuggestions] = (0,external_wp_element_namespaceObject.useState)({}); 15348 const [isCreatingTemplate, setIsCreatingTemplate] = (0,external_wp_element_namespaceObject.useState)(false); 15349 const history = new_template_useHistory(); 15350 const { 15351 saveEntityRecord 15352 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store); 15353 const { 15354 createErrorNotice, 15355 createSuccessNotice 15356 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store); 15357 const { 15358 homeUrl 15359 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 15360 const { 15361 getUnstableBase // Site index. 15362 } = select(external_wp_coreData_namespaceObject.store); 15363 return { 15364 homeUrl: getUnstableBase()?.home 15365 }; 15366 }, []); 15367 const TEMPLATE_SHORT_DESCRIPTIONS = { 15368 'front-page': homeUrl, 15369 date: (0,external_wp_i18n_namespaceObject.sprintf)( 15370 // translators: %s: The homepage url. 15371 (0,external_wp_i18n_namespaceObject.__)('E.g. %s'), homeUrl + '/' + new Date().getFullYear()) 15372 }; 15373 async function createTemplate(template, isWPSuggestion = true) { 15374 if (isCreatingTemplate) { 15375 return; 15376 } 15377 setIsCreatingTemplate(true); 15378 try { 15379 const { 15380 title, 15381 description, 15382 slug 15383 } = template; 15384 const newTemplate = await saveEntityRecord('postType', constants_TEMPLATE_POST_TYPE, { 15385 description, 15386 // Slugs need to be strings, so this is for template `404` 15387 slug: slug.toString(), 15388 status: 'publish', 15389 title, 15390 // This adds a post meta field in template that is part of `is_custom` value calculation. 15391 is_wp_suggestion: isWPSuggestion 15392 }, { 15393 throwOnError: true 15394 }); 15395 15396 // Navigate to the created template editor. 15397 history.push({ 15398 postId: newTemplate.id, 15399 postType: newTemplate.type, 15400 canvas: 'edit' 15401 }); 15402 createSuccessNotice((0,external_wp_i18n_namespaceObject.sprintf)( 15403 // translators: %s: Title of the created template e.g: "Category". 15404 (0,external_wp_i18n_namespaceObject.__)('"%s" successfully created.'), (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(newTemplate.title?.rendered || title)), { 15405 type: 'snackbar' 15406 }); 15407 } catch (error) { 15408 const errorMessage = error.message && error.code !== 'unknown_error' ? error.message : (0,external_wp_i18n_namespaceObject.__)('An error occurred while creating the template.'); 15409 createErrorNotice(errorMessage, { 15410 type: 'snackbar' 15411 }); 15412 } finally { 15413 setIsCreatingTemplate(false); 15414 } 15415 } 15416 const onModalClose = () => { 15417 setShowModal(false); 15418 setModalContent(modalContentMap.templatesList); 15419 }; 15420 const missingTemplates = useMissingTemplates(setEntityForSuggestions, () => setModalContent(modalContentMap.customTemplate)); 15421 if (!missingTemplates.length) { 15422 return null; 15423 } 15424 const { 15425 as: Toggle = external_wp_components_namespaceObject.Button, 15426 ...restToggleProps 15427 } = toggleProps !== null && toggleProps !== void 0 ? toggleProps : {}; 15428 let modalTitle = (0,external_wp_i18n_namespaceObject.__)('Add template'); 15429 if (modalContent === modalContentMap.customTemplate) { 15430 modalTitle = (0,external_wp_i18n_namespaceObject.sprintf)( 15431 // translators: %s: Name of the post type e.g: "Post". 15432 (0,external_wp_i18n_namespaceObject.__)('Add template: %s'), entityForSuggestions.labels.singular_name); 15433 } else if (modalContent === modalContentMap.customGenericTemplate) { 15434 modalTitle = (0,external_wp_i18n_namespaceObject.__)('Create custom template'); 15435 } 15436 return (0,external_React_.createElement)(external_React_.Fragment, null, isCreatingTemplate && (0,external_React_.createElement)(TemplateActionsLoadingScreen, null), (0,external_React_.createElement)(Toggle, { 15437 ...restToggleProps, 15438 onClick: () => setShowModal(true), 15439 icon: showIcon ? library_plus : null, 15440 label: postType.labels.add_new_item 15441 }, showIcon ? null : postType.labels.add_new_item), showModal && (0,external_React_.createElement)(external_wp_components_namespaceObject.Modal, { 15442 title: modalTitle, 15443 className: classnames_default()('edit-site-add-new-template__modal', { 15444 'edit-site-add-new-template__modal_template_list': modalContent === modalContentMap.templatesList, 15445 'edit-site-custom-template-modal': modalContent === modalContentMap.customTemplate 15446 }), 15447 onRequestClose: onModalClose, 15448 overlayClassName: modalContent === modalContentMap.customGenericTemplate ? 'edit-site-custom-generic-template__modal' : undefined 15449 }, modalContent === modalContentMap.templatesList && (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalGrid, { 15450 columns: 3, 15451 gap: 4, 15452 align: "flex-start", 15453 justify: "center", 15454 className: "edit-site-add-new-template__template-list__contents" 15455 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.Flex, { 15456 className: "edit-site-add-new-template__template-list__prompt" 15457 }, (0,external_wp_i18n_namespaceObject.__)('Select what the new template should apply to:')), missingTemplates.map(template => { 15458 const { 15459 title, 15460 slug, 15461 onClick 15462 } = template; 15463 return (0,external_React_.createElement)(TemplateListItem, { 15464 key: slug, 15465 title: title, 15466 direction: "column", 15467 className: "edit-site-add-new-template__template-button", 15468 description: TEMPLATE_SHORT_DESCRIPTIONS[slug], 15469 icon: TEMPLATE_ICONS[slug] || library_layout, 15470 onClick: () => onClick ? onClick(template) : createTemplate(template) 15471 }); 15472 }), (0,external_React_.createElement)(TemplateListItem, { 15473 title: (0,external_wp_i18n_namespaceObject.__)('Custom template'), 15474 direction: "row", 15475 className: "edit-site-add-new-template__custom-template-button", 15476 icon: edit, 15477 onClick: () => setModalContent(modalContentMap.customGenericTemplate) 15478 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalText, { 15479 lineHeight: 1.53846153846 // 20px 15480 }, (0,external_wp_i18n_namespaceObject.__)('A custom template can be manually applied to any post or page.')))), modalContent === modalContentMap.customTemplate && (0,external_React_.createElement)(add_custom_template_modal_content, { 15481 onSelect: createTemplate, 15482 entityForSuggestions: entityForSuggestions 15483 }), modalContent === modalContentMap.customGenericTemplate && (0,external_React_.createElement)(add_custom_generic_template_modal_content, { 15484 onClose: onModalClose, 15485 createTemplate: createTemplate 15486 }))); 15487 } 15488 function useMissingTemplates(setEntityForSuggestions, onClick) { 15489 const existingTemplates = useExistingTemplates(); 15490 const defaultTemplateTypes = useDefaultTemplateTypes(); 15491 const existingTemplateSlugs = (existingTemplates || []).map(({ 15492 slug 15493 }) => slug); 15494 const missingDefaultTemplates = (defaultTemplateTypes || []).filter(template => DEFAULT_TEMPLATE_SLUGS.includes(template.slug) && !existingTemplateSlugs.includes(template.slug)); 15495 const onClickMenuItem = _entityForSuggestions => { 15496 onClick?.(); 15497 setEntityForSuggestions(_entityForSuggestions); 15498 }; 15499 // We need to replace existing default template types with 15500 // the create specific template functionality. The original 15501 // info (title, description, etc.) is preserved in the 15502 // used hooks. 15503 const enhancedMissingDefaultTemplateTypes = [...missingDefaultTemplates]; 15504 const { 15505 defaultTaxonomiesMenuItems, 15506 taxonomiesMenuItems 15507 } = useTaxonomiesMenuItems(onClickMenuItem); 15508 const { 15509 defaultPostTypesMenuItems, 15510 postTypesMenuItems 15511 } = usePostTypeMenuItems(onClickMenuItem); 15512 const authorMenuItem = useAuthorMenuItem(onClickMenuItem); 15513 [...defaultTaxonomiesMenuItems, ...defaultPostTypesMenuItems, authorMenuItem].forEach(menuItem => { 15514 if (!menuItem) { 15515 return; 15516 } 15517 const matchIndex = enhancedMissingDefaultTemplateTypes.findIndex(template => template.slug === menuItem.slug); 15518 // Some default template types might have been filtered above from 15519 // `missingDefaultTemplates` because they only check for the general 15520 // template. So here we either replace or append the item, augmented 15521 // with the check if it has available specific item to create a 15522 // template for. 15523 if (matchIndex > -1) { 15524 enhancedMissingDefaultTemplateTypes[matchIndex] = menuItem; 15525 } else { 15526 enhancedMissingDefaultTemplateTypes.push(menuItem); 15527 } 15528 }); 15529 // Update the sort order to match the DEFAULT_TEMPLATE_SLUGS order. 15530 enhancedMissingDefaultTemplateTypes?.sort((template1, template2) => { 15531 return DEFAULT_TEMPLATE_SLUGS.indexOf(template1.slug) - DEFAULT_TEMPLATE_SLUGS.indexOf(template2.slug); 15532 }); 15533 const missingTemplates = [...enhancedMissingDefaultTemplateTypes, ...usePostTypeArchiveMenuItems(), ...postTypesMenuItems, ...taxonomiesMenuItems]; 15534 return missingTemplates; 15535 } 15536 15537 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/add-new-template/index.js 15538 15539 /** 15540 * WordPress dependencies 15541 */ 15542 15543 15544 15545 /** 15546 * Internal dependencies 15547 */ 15548 15549 15550 function AddNewTemplate({ 15551 templateType = constants_TEMPLATE_POST_TYPE, 15552 ...props 15553 }) { 15554 const postType = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).getPostType(templateType), [templateType]); 15555 if (!postType) { 15556 return null; 15557 } 15558 if (templateType === constants_TEMPLATE_POST_TYPE) { 15559 return (0,external_React_.createElement)(NewTemplate, { 15560 ...props, 15561 postType: postType 15562 }); 15563 } 15564 return null; 15565 } 15566 15567 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sidebar-navigation-screen-templates/index.js 15568 15569 /** 15570 * WordPress dependencies 15571 */ 15572 15573 15574 15575 15576 15577 15578 /** 15579 * Internal dependencies 15580 */ 15581 15582 15583 15584 15585 15586 15587 const TemplateItem = ({ 15588 postType, 15589 postId, 15590 ...props 15591 }) => { 15592 const linkInfo = useLink({ 15593 postType, 15594 postId 15595 }); 15596 return (0,external_React_.createElement)(SidebarNavigationItem, { 15597 ...linkInfo, 15598 ...props 15599 }); 15600 }; 15601 function SidebarNavigationScreenTemplates() { 15602 const isMobileViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium', '<'); 15603 const { 15604 records: templates, 15605 isResolving: isLoading 15606 } = (0,external_wp_coreData_namespaceObject.useEntityRecords)('postType', constants_TEMPLATE_POST_TYPE, { 15607 per_page: -1 15608 }); 15609 const browseAllLink = useLink({ 15610 path: '/wp_template/all' 15611 }); 15612 const canCreate = !isMobileViewport; 15613 return (0,external_React_.createElement)(SidebarNavigationScreen, { 15614 title: (0,external_wp_i18n_namespaceObject.__)('Templates'), 15615 description: (0,external_wp_i18n_namespaceObject.__)('Express the layout of your site with templates.'), 15616 actions: canCreate && (0,external_React_.createElement)(AddNewTemplate, { 15617 templateType: constants_TEMPLATE_POST_TYPE, 15618 toggleProps: { 15619 as: SidebarButton 15620 } 15621 }), 15622 content: (0,external_React_.createElement)(external_React_.Fragment, null, isLoading && (0,external_wp_i18n_namespaceObject.__)('Loading templates…'), !isLoading && (0,external_React_.createElement)(SidebarTemplatesList, { 15623 templates: templates 15624 })), 15625 footer: !isMobileViewport && (0,external_React_.createElement)(SidebarNavigationItem, { 15626 withChevron: true, 15627 ...browseAllLink 15628 }, (0,external_wp_i18n_namespaceObject.__)('Manage all templates')) 15629 }); 15630 } 15631 function TemplatesGroup({ 15632 title, 15633 templates 15634 }) { 15635 return (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalItemGroup, null, !!title && (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalItem, { 15636 className: "edit-site-sidebar-navigation-screen-templates__templates-group-title" 15637 }, title), templates.map(template => (0,external_React_.createElement)(TemplateItem, { 15638 postType: constants_TEMPLATE_POST_TYPE, 15639 postId: template.id, 15640 key: template.id, 15641 withChevron: true 15642 }, (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(template.title?.rendered || template.slug)))); 15643 } 15644 function SidebarTemplatesList({ 15645 templates 15646 }) { 15647 if (!templates?.length) { 15648 return (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalItemGroup, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalItem, null, (0,external_wp_i18n_namespaceObject.__)('No templates found'))); 15649 } 15650 const sortedTemplates = templates ? [...templates] : []; 15651 sortedTemplates.sort((a, b) => a.title.rendered.localeCompare(b.title.rendered)); 15652 const { 15653 hierarchyTemplates, 15654 customTemplates, 15655 ...plugins 15656 } = sortedTemplates.reduce((accumulator, template) => { 15657 const { 15658 original_source: originalSource, 15659 author_text: authorText 15660 } = template; 15661 if (originalSource === 'plugin') { 15662 if (!accumulator[authorText]) { 15663 accumulator[authorText] = []; 15664 } 15665 accumulator[authorText].push(template); 15666 } else if (template.is_custom) { 15667 accumulator.customTemplates.push(template); 15668 } else { 15669 accumulator.hierarchyTemplates.push(template); 15670 } 15671 return accumulator; 15672 }, { 15673 hierarchyTemplates: [], 15674 customTemplates: [] 15675 }); 15676 return (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { 15677 spacing: 3 15678 }, !!hierarchyTemplates.length && (0,external_React_.createElement)(TemplatesGroup, { 15679 templates: hierarchyTemplates 15680 }), !!customTemplates.length && (0,external_React_.createElement)(TemplatesGroup, { 15681 title: (0,external_wp_i18n_namespaceObject.__)('Custom'), 15682 templates: customTemplates 15683 }), Object.entries(plugins).map(([plugin, pluginTemplates]) => { 15684 return (0,external_React_.createElement)(TemplatesGroup, { 15685 key: plugin, 15686 title: plugin, 15687 templates: pluginTemplates 15688 }); 15689 })); 15690 } 15691 15692 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sidebar-navigation-screen-template/template-areas.js 15693 15694 /** 15695 * WordPress dependencies 15696 */ 15697 15698 15699 15700 15701 15702 15703 15704 /** 15705 * Internal dependencies 15706 */ 15707 15708 15709 15710 15711 15712 15713 function TemplateAreaButton({ 15714 postId, 15715 area, 15716 title 15717 }) { 15718 const templatePartArea = (0,external_wp_data_namespaceObject.useSelect)(select => { 15719 const defaultAreas = select(external_wp_editor_namespaceObject.store).__experimentalGetDefaultTemplatePartAreas(); 15720 return defaultAreas.find(defaultArea => defaultArea.area === area); 15721 }, [area]); 15722 const linkInfo = useLink({ 15723 postType: TEMPLATE_PART_POST_TYPE, 15724 postId 15725 }); 15726 return (0,external_React_.createElement)(SidebarNavigationItem, { 15727 className: "edit-site-sidebar-navigation-screen-template__template-area-button", 15728 ...linkInfo, 15729 icon: templatePartArea?.icon, 15730 withChevron: true 15731 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalTruncate, { 15732 limit: 20, 15733 ellipsizeMode: "tail", 15734 numberOfLines: 1, 15735 className: "edit-site-sidebar-navigation-screen-template__template-area-label-text" 15736 }, (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(title))); 15737 } 15738 function TemplateAreas() { 15739 const { 15740 templatePartAreas, 15741 currentTemplateParts 15742 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 15743 const { 15744 getSettings, 15745 getCurrentTemplateTemplateParts 15746 } = unlock(select(store_store)); 15747 return { 15748 templatePartAreas: getSettings()?.defaultTemplatePartAreas, 15749 currentTemplateParts: getCurrentTemplateTemplateParts() 15750 }; 15751 }, []); 15752 15753 /* 15754 * Merge data in currentTemplateParts with templatePartAreas, 15755 * which contains the template icon and fallback labels 15756 */ 15757 const templateAreas = (0,external_wp_element_namespaceObject.useMemo)(() => { 15758 // Keep track of template part IDs that have already been added to the array. 15759 const templatePartIds = new Set(); 15760 const filterOutDuplicateTemplateParts = currentTemplatePart => { 15761 // If the template part has already been added to the array, skip it. 15762 if (templatePartIds.has(currentTemplatePart.templatePart.id)) { 15763 return; 15764 } 15765 // Add to the array of template part IDs. 15766 templatePartIds.add(currentTemplatePart.templatePart.id); 15767 return currentTemplatePart; 15768 }; 15769 return currentTemplateParts.length && templatePartAreas ? currentTemplateParts.filter(filterOutDuplicateTemplateParts).map(({ 15770 templatePart, 15771 block 15772 }) => ({ 15773 ...templatePartAreas?.find(({ 15774 area 15775 }) => area === templatePart?.area), 15776 ...templatePart, 15777 clientId: block.clientId 15778 })) : []; 15779 }, [currentTemplateParts, templatePartAreas]); 15780 if (!templateAreas.length) { 15781 return null; 15782 } 15783 return (0,external_React_.createElement)(SidebarNavigationScreenDetailsPanel, { 15784 title: (0,external_wp_i18n_namespaceObject.__)('Areas'), 15785 spacing: 3 15786 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalItemGroup, null, templateAreas.map(({ 15787 clientId, 15788 label, 15789 area, 15790 theme, 15791 slug, 15792 title 15793 }) => (0,external_React_.createElement)(SidebarNavigationScreenDetailsPanelRow, { 15794 key: clientId 15795 }, (0,external_React_.createElement)(TemplateAreaButton, { 15796 postId: `$theme}//${slug}`, 15797 title: title?.rendered || label, 15798 area: area 15799 }))))); 15800 } 15801 15802 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/use-edited-entity-record/index.js 15803 /** 15804 * WordPress dependencies 15805 */ 15806 15807 15808 15809 15810 15811 /** 15812 * Internal dependencies 15813 */ 15814 15815 function useEditedEntityRecord(postType, postId) { 15816 const { 15817 record, 15818 title, 15819 description, 15820 isLoaded, 15821 icon 15822 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 15823 const { 15824 getEditedPostType, 15825 getEditedPostId 15826 } = select(store_store); 15827 const { 15828 getEditedEntityRecord, 15829 hasFinishedResolution 15830 } = select(external_wp_coreData_namespaceObject.store); 15831 const { 15832 __experimentalGetTemplateInfo: getTemplateInfo 15833 } = select(external_wp_editor_namespaceObject.store); 15834 const usedPostType = postType !== null && postType !== void 0 ? postType : getEditedPostType(); 15835 const usedPostId = postId !== null && postId !== void 0 ? postId : getEditedPostId(); 15836 const _record = getEditedEntityRecord('postType', usedPostType, usedPostId); 15837 const _isLoaded = usedPostId && hasFinishedResolution('getEditedEntityRecord', ['postType', usedPostType, usedPostId]); 15838 const templateInfo = getTemplateInfo(_record); 15839 return { 15840 record: _record, 15841 title: templateInfo.title, 15842 description: templateInfo.description, 15843 isLoaded: _isLoaded, 15844 icon: templateInfo.icon 15845 }; 15846 }, [postType, postId]); 15847 return { 15848 isLoaded, 15849 icon, 15850 record, 15851 getTitle: () => title ? (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(title) : null, 15852 getDescription: () => description ? (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(description) : null 15853 }; 15854 } 15855 15856 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/plugins.js 15857 15858 /** 15859 * WordPress dependencies 15860 */ 15861 15862 const plugins = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { 15863 xmlns: "http://www.w3.org/2000/svg", 15864 viewBox: "0 0 24 24" 15865 }, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 15866 d: "M10.5 4v4h3V4H15v4h1.5a1 1 0 011 1v4l-3 4v2a1 1 0 01-1 1h-3a1 1 0 01-1-1v-2l-3-4V9a1 1 0 011-1H9V4h1.5zm.5 12.5v2h2v-2l3-4v-3H8v3l3 4z" 15867 })); 15868 /* harmony default export */ const library_plugins = (plugins); 15869 15870 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/globe.js 15871 15872 /** 15873 * WordPress dependencies 15874 */ 15875 15876 const globe = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { 15877 xmlns: "http://www.w3.org/2000/svg", 15878 viewBox: "0 0 24 24" 15879 }, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 15880 d: "M12 3.3c-4.8 0-8.8 3.9-8.8 8.8 0 4.8 3.9 8.8 8.8 8.8 4.8 0 8.8-3.9 8.8-8.8s-4-8.8-8.8-8.8zm6.5 5.5h-2.6C15.4 7.3 14.8 6 14 5c2 .6 3.6 2 4.5 3.8zm.7 3.2c0 .6-.1 1.2-.2 1.8h-2.9c.1-.6.1-1.2.1-1.8s-.1-1.2-.1-1.8H19c.2.6.2 1.2.2 1.8zM12 18.7c-1-.7-1.8-1.9-2.3-3.5h4.6c-.5 1.6-1.3 2.9-2.3 3.5zm-2.6-4.9c-.1-.6-.1-1.1-.1-1.8 0-.6.1-1.2.1-1.8h5.2c.1.6.1 1.1.1 1.8s-.1 1.2-.1 1.8H9.4zM4.8 12c0-.6.1-1.2.2-1.8h2.9c-.1.6-.1 1.2-.1 1.8 0 .6.1 1.2.1 1.8H5c-.2-.6-.2-1.2-.2-1.8zM12 5.3c1 .7 1.8 1.9 2.3 3.5H9.7c.5-1.6 1.3-2.9 2.3-3.5zM10 5c-.8 1-1.4 2.3-1.8 3.8H5.5C6.4 7 8 5.6 10 5zM5.5 15.3h2.6c.4 1.5 1 2.8 1.8 3.7-1.8-.6-3.5-2-4.4-3.7zM14 19c.8-1 1.4-2.2 1.8-3.7h2.6C17.6 17 16 18.4 14 19z" 15881 })); 15882 /* harmony default export */ const library_globe = (globe); 15883 15884 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/list/added-by.js 15885 15886 // @ts-check 15887 /** 15888 * External dependencies 15889 */ 15890 15891 15892 /** 15893 * WordPress dependencies 15894 */ 15895 15896 15897 15898 15899 15900 15901 15902 /** 15903 * Internal dependencies 15904 */ 15905 15906 15907 /** @typedef {'wp_template'|'wp_template_part'} TemplateType */ 15908 15909 /** 15910 * @typedef {'theme'|'plugin'|'site'|'user'} AddedByType 15911 * 15912 * @typedef AddedByData 15913 * @type {Object} 15914 * @property {AddedByType} type The type of the data. 15915 * @property {JSX.Element} icon The icon to display. 15916 * @property {string} [imageUrl] The optional image URL to display. 15917 * @property {string} [text] The text to display. 15918 * @property {boolean} isCustomized Whether the template has been customized. 15919 * 15920 * @param {TemplateType} postType The template post type. 15921 * @param {number} postId The template post id. 15922 * @return {AddedByData} The added by object or null. 15923 */ 15924 function useAddedBy(postType, postId) { 15925 return (0,external_wp_data_namespaceObject.useSelect)(select => { 15926 const { 15927 getEntityRecord, 15928 getMedia, 15929 getUser, 15930 getEditedEntityRecord 15931 } = select(external_wp_coreData_namespaceObject.store); 15932 const template = getEditedEntityRecord('postType', postType, postId); 15933 const originalSource = template?.original_source; 15934 const authorText = template?.author_text; 15935 switch (originalSource) { 15936 case 'theme': 15937 { 15938 return { 15939 type: originalSource, 15940 icon: library_layout, 15941 text: authorText, 15942 isCustomized: template.source === TEMPLATE_ORIGINS.custom 15943 }; 15944 } 15945 case 'plugin': 15946 { 15947 return { 15948 type: originalSource, 15949 icon: library_plugins, 15950 text: authorText, 15951 isCustomized: template.source === TEMPLATE_ORIGINS.custom 15952 }; 15953 } 15954 case 'site': 15955 { 15956 const siteData = getEntityRecord('root', '__unstableBase'); 15957 return { 15958 type: originalSource, 15959 icon: library_globe, 15960 imageUrl: siteData?.site_logo ? getMedia(siteData.site_logo)?.source_url : undefined, 15961 text: authorText, 15962 isCustomized: false 15963 }; 15964 } 15965 default: 15966 { 15967 const user = getUser(template.author); 15968 return { 15969 type: 'user', 15970 icon: comment_author_avatar, 15971 imageUrl: user?.avatar_urls?.[48], 15972 text: authorText, 15973 isCustomized: false 15974 }; 15975 } 15976 } 15977 }, [postType, postId]); 15978 } 15979 15980 /** 15981 * @param {Object} props 15982 * @param {string} props.imageUrl 15983 */ 15984 function AvatarImage({ 15985 imageUrl 15986 }) { 15987 const [isImageLoaded, setIsImageLoaded] = (0,external_wp_element_namespaceObject.useState)(false); 15988 return (0,external_React_.createElement)("div", { 15989 className: classnames_default()('edit-site-list-added-by__avatar', { 15990 'is-loaded': isImageLoaded 15991 }) 15992 }, (0,external_React_.createElement)("img", { 15993 onLoad: () => setIsImageLoaded(true), 15994 alt: "", 15995 src: imageUrl 15996 })); 15997 } 15998 15999 /** 16000 * @param {Object} props 16001 * @param {TemplateType} props.postType The template post type. 16002 * @param {number} props.postId The template post id. 16003 */ 16004 function AddedBy({ 16005 postType, 16006 postId 16007 }) { 16008 const { 16009 text, 16010 icon, 16011 imageUrl, 16012 isCustomized 16013 } = useAddedBy(postType, postId); 16014 return createElement(HStack, { 16015 alignment: "left" 16016 }, imageUrl ? createElement(AvatarImage, { 16017 imageUrl: imageUrl 16018 }) : createElement("div", { 16019 className: "edit-site-list-added-by__icon" 16020 }, createElement(Icon, { 16021 icon: icon 16022 })), createElement("span", null, text, isCustomized && createElement("span", { 16023 className: "edit-site-list-added-by__customized-info" 16024 }, postType === TEMPLATE_POST_TYPE ? _x('Customized', 'template') : _x('Customized', 'template part')))); 16025 } 16026 16027 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/utils/is-template-removable.js 16028 /** 16029 * Internal dependencies 16030 */ 16031 16032 16033 /** 16034 * Check if a template is removable. 16035 * 16036 * @param {Object} template The template entity to check. 16037 * @return {boolean} Whether the template is revertable. 16038 */ 16039 function isTemplateRemovable(template) { 16040 if (!template) { 16041 return false; 16042 } 16043 return template.source === TEMPLATE_ORIGINS.custom && !template.has_theme_file; 16044 } 16045 16046 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/template-actions/rename-menu-item.js 16047 16048 /** 16049 * WordPress dependencies 16050 */ 16051 16052 16053 16054 16055 16056 16057 16058 16059 /** 16060 * Internal dependencies 16061 */ 16062 16063 function RenameMenuItem({ 16064 template, 16065 onClose 16066 }) { 16067 const title = (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(template.title.rendered); 16068 const [editedTitle, setEditedTitle] = (0,external_wp_element_namespaceObject.useState)(title); 16069 const [isModalOpen, setIsModalOpen] = (0,external_wp_element_namespaceObject.useState)(false); 16070 const { 16071 editEntityRecord, 16072 __experimentalSaveSpecifiedEntityEdits: saveSpecifiedEntityEdits 16073 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store); 16074 const { 16075 createSuccessNotice, 16076 createErrorNotice 16077 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store); 16078 if (template.type === constants_TEMPLATE_POST_TYPE && !template.is_custom) { 16079 return null; 16080 } 16081 async function onTemplateRename(event) { 16082 event.preventDefault(); 16083 try { 16084 await editEntityRecord('postType', template.type, template.id, { 16085 title: editedTitle 16086 }); 16087 16088 // Update state before saving rerenders the list. 16089 setEditedTitle(''); 16090 setIsModalOpen(false); 16091 onClose(); 16092 16093 // Persist edited entity. 16094 await saveSpecifiedEntityEdits('postType', template.type, template.id, ['title'], 16095 // Only save title to avoid persisting other edits. 16096 { 16097 throwOnError: true 16098 }); 16099 createSuccessNotice(template.type === constants_TEMPLATE_POST_TYPE ? (0,external_wp_i18n_namespaceObject.__)('Template renamed.') : (0,external_wp_i18n_namespaceObject.__)('Template part renamed.'), { 16100 type: 'snackbar' 16101 }); 16102 } catch (error) { 16103 const fallbackErrorMessage = template.type === constants_TEMPLATE_POST_TYPE ? (0,external_wp_i18n_namespaceObject.__)('An error occurred while renaming the template.') : (0,external_wp_i18n_namespaceObject.__)('An error occurred while renaming the template part.'); 16104 const errorMessage = error.message && error.code !== 'unknown_error' ? error.message : fallbackErrorMessage; 16105 createErrorNotice(errorMessage, { 16106 type: 'snackbar' 16107 }); 16108 } 16109 } 16110 return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.MenuItem, { 16111 onClick: () => { 16112 setIsModalOpen(true); 16113 setEditedTitle(title); 16114 } 16115 }, (0,external_wp_i18n_namespaceObject.__)('Rename')), isModalOpen && (0,external_React_.createElement)(external_wp_components_namespaceObject.Modal, { 16116 title: (0,external_wp_i18n_namespaceObject.__)('Rename'), 16117 onRequestClose: () => { 16118 setIsModalOpen(false); 16119 }, 16120 overlayClassName: "edit-site-list__rename-modal" 16121 }, (0,external_React_.createElement)("form", { 16122 onSubmit: onTemplateRename 16123 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { 16124 spacing: "5" 16125 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.TextControl, { 16126 __nextHasNoMarginBottom: true, 16127 __next40pxDefaultSize: true, 16128 label: (0,external_wp_i18n_namespaceObject.__)('Name'), 16129 value: editedTitle, 16130 onChange: setEditedTitle, 16131 required: true 16132 }), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { 16133 justify: "right" 16134 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 16135 __next40pxDefaultSize: true, 16136 variant: "tertiary", 16137 onClick: () => { 16138 setIsModalOpen(false); 16139 } 16140 }, (0,external_wp_i18n_namespaceObject.__)('Cancel')), (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 16141 __next40pxDefaultSize: true, 16142 variant: "primary", 16143 type: "submit" 16144 }, (0,external_wp_i18n_namespaceObject.__)('Save'))))))); 16145 } 16146 16147 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/template-actions/index.js 16148 16149 /** 16150 * WordPress dependencies 16151 */ 16152 16153 16154 16155 16156 16157 16158 16159 16160 16161 /** 16162 * Internal dependencies 16163 */ 16164 16165 16166 16167 16168 16169 function TemplateActions({ 16170 postType, 16171 postId, 16172 className, 16173 toggleProps, 16174 onRemove 16175 }) { 16176 const template = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).getEntityRecord('postType', postType, postId), [postType, postId]); 16177 const { 16178 removeTemplate, 16179 revertTemplate 16180 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store); 16181 const { 16182 saveEditedEntityRecord 16183 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store); 16184 const { 16185 createSuccessNotice, 16186 createErrorNotice 16187 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store); 16188 const isRemovable = isTemplateRemovable(template); 16189 const isRevertable = isTemplateRevertable(template); 16190 if (!isRemovable && !isRevertable) { 16191 return null; 16192 } 16193 async function revertAndSaveTemplate() { 16194 try { 16195 await revertTemplate(template, { 16196 allowUndo: false 16197 }); 16198 await saveEditedEntityRecord('postType', template.type, template.id); 16199 createSuccessNotice((0,external_wp_i18n_namespaceObject.sprintf)( /* translators: The template/part's name. */ 16200 (0,external_wp_i18n_namespaceObject.__)('"%s" reverted.'), (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(template.title.rendered)), { 16201 type: 'snackbar', 16202 id: 'edit-site-template-reverted' 16203 }); 16204 } catch (error) { 16205 const fallbackErrorMessage = template.type === constants_TEMPLATE_POST_TYPE ? (0,external_wp_i18n_namespaceObject.__)('An error occurred while reverting the template.') : (0,external_wp_i18n_namespaceObject.__)('An error occurred while reverting the template part.'); 16206 const errorMessage = error.message && error.code !== 'unknown_error' ? error.message : fallbackErrorMessage; 16207 createErrorNotice(errorMessage, { 16208 type: 'snackbar' 16209 }); 16210 } 16211 } 16212 return (0,external_React_.createElement)(external_wp_components_namespaceObject.DropdownMenu, { 16213 icon: more_vertical, 16214 label: (0,external_wp_i18n_namespaceObject.__)('Actions'), 16215 className: className, 16216 toggleProps: toggleProps 16217 }, ({ 16218 onClose 16219 }) => (0,external_React_.createElement)(external_wp_components_namespaceObject.MenuGroup, null, isRemovable && (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(RenameMenuItem, { 16220 template: template, 16221 onClose: onClose 16222 }), (0,external_React_.createElement)(DeleteMenuItem, { 16223 onRemove: () => { 16224 removeTemplate(template); 16225 onRemove?.(); 16226 onClose(); 16227 }, 16228 title: template.title.rendered 16229 })), isRevertable && (0,external_React_.createElement)(external_wp_components_namespaceObject.MenuItem, { 16230 info: (0,external_wp_i18n_namespaceObject.__)('Use the template as supplied by the theme.'), 16231 onClick: () => { 16232 revertAndSaveTemplate(); 16233 onClose(); 16234 } 16235 }, (0,external_wp_i18n_namespaceObject.__)('Clear customizations')))); 16236 } 16237 function DeleteMenuItem({ 16238 onRemove, 16239 title 16240 }) { 16241 const [isModalOpen, setIsModalOpen] = (0,external_wp_element_namespaceObject.useState)(false); 16242 return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.MenuItem, { 16243 isDestructive: true, 16244 onClick: () => setIsModalOpen(true) 16245 }, (0,external_wp_i18n_namespaceObject.__)('Delete')), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalConfirmDialog, { 16246 isOpen: isModalOpen, 16247 onConfirm: onRemove, 16248 onCancel: () => setIsModalOpen(false), 16249 confirmButtonText: (0,external_wp_i18n_namespaceObject.__)('Delete') 16250 }, (0,external_wp_i18n_namespaceObject.sprintf)( 16251 // translators: %s: The template or template part's title. 16252 (0,external_wp_i18n_namespaceObject.__)('Are you sure you want to delete "%s"?'), (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(title)))); 16253 } 16254 16255 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sidebar-navigation-screen-template/home-template-details.js 16256 16257 /** 16258 * WordPress dependencies 16259 */ 16260 16261 16262 16263 16264 16265 16266 16267 /** 16268 * Internal dependencies 16269 */ 16270 16271 const EMPTY_OBJECT = {}; 16272 function HomeTemplateDetails() { 16273 const { 16274 editEntityRecord 16275 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store); 16276 const { 16277 allowCommentsOnNewPosts, 16278 postsPerPage, 16279 postsPageTitle, 16280 postsPageId 16281 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 16282 const { 16283 getEntityRecord 16284 } = select(external_wp_coreData_namespaceObject.store); 16285 const siteSettings = getEntityRecord('root', 'site'); 16286 const _postsPageRecord = siteSettings?.page_for_posts ? getEntityRecord('postType', 'page', siteSettings?.page_for_posts) : EMPTY_OBJECT; 16287 return { 16288 allowCommentsOnNewPosts: siteSettings?.default_comment_status === 'open', 16289 postsPageTitle: _postsPageRecord?.title?.rendered, 16290 postsPageId: _postsPageRecord?.id, 16291 postsPerPage: siteSettings?.posts_per_page 16292 }; 16293 }, []); 16294 const [commentsOnNewPostsValue, setCommentsOnNewPostsValue] = (0,external_wp_element_namespaceObject.useState)(''); 16295 const [postsCountValue, setPostsCountValue] = (0,external_wp_element_namespaceObject.useState)(1); 16296 const [postsPageTitleValue, setPostsPageTitleValue] = (0,external_wp_element_namespaceObject.useState)(''); 16297 16298 /* 16299 * This hook serves to set the server-retrieved values, 16300 * postsPageTitle, allowCommentsOnNewPosts, postsPerPage, 16301 * to local state. 16302 */ 16303 (0,external_wp_element_namespaceObject.useEffect)(() => { 16304 setCommentsOnNewPostsValue(allowCommentsOnNewPosts); 16305 setPostsPageTitleValue(postsPageTitle); 16306 setPostsCountValue(postsPerPage); 16307 }, [postsPageTitle, allowCommentsOnNewPosts, postsPerPage]); 16308 const setAllowCommentsOnNewPosts = newValue => { 16309 setCommentsOnNewPostsValue(newValue); 16310 editEntityRecord('root', 'site', undefined, { 16311 default_comment_status: newValue ? 'open' : null 16312 }); 16313 }; 16314 const setPostsPageTitle = newValue => { 16315 setPostsPageTitleValue(newValue); 16316 editEntityRecord('postType', 'page', postsPageId, { 16317 title: newValue 16318 }); 16319 }; 16320 const setPostsPerPage = newValue => { 16321 setPostsCountValue(newValue); 16322 editEntityRecord('root', 'site', undefined, { 16323 posts_per_page: newValue 16324 }); 16325 }; 16326 return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(SidebarNavigationScreenDetailsPanel, { 16327 spacing: 6 16328 }, postsPageId && (0,external_React_.createElement)(SidebarNavigationScreenDetailsPanelRow, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalInputControl, { 16329 className: "edit-site-sidebar-navigation-screen__input-control", 16330 placeholder: (0,external_wp_i18n_namespaceObject.__)('No Title'), 16331 size: '__unstable-large', 16332 value: postsPageTitleValue, 16333 onChange: (0,external_wp_compose_namespaceObject.debounce)(setPostsPageTitle, 300), 16334 label: (0,external_wp_i18n_namespaceObject.__)('Blog title'), 16335 help: (0,external_wp_i18n_namespaceObject.__)('Set the Posts Page title. Appears in search results, and when the page is shared on social media.') 16336 })), (0,external_React_.createElement)(SidebarNavigationScreenDetailsPanelRow, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalNumberControl, { 16337 className: "edit-site-sidebar-navigation-screen__input-control", 16338 placeholder: 0, 16339 value: postsCountValue, 16340 size: '__unstable-large', 16341 spinControls: "custom", 16342 step: "1", 16343 min: "1", 16344 onChange: setPostsPerPage, 16345 label: (0,external_wp_i18n_namespaceObject.__)('Posts per page'), 16346 help: (0,external_wp_i18n_namespaceObject.__)('Set the default number of posts to display on blog pages, including categories and tags. Some templates may override this setting.') 16347 }))), (0,external_React_.createElement)(SidebarNavigationScreenDetailsPanel, { 16348 title: (0,external_wp_i18n_namespaceObject.__)('Discussion'), 16349 spacing: 3 16350 }, (0,external_React_.createElement)(SidebarNavigationScreenDetailsPanelRow, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.CheckboxControl, { 16351 className: "edit-site-sidebar-navigation-screen__input-control", 16352 label: (0,external_wp_i18n_namespaceObject.__)('Allow comments on new posts'), 16353 help: (0,external_wp_i18n_namespaceObject.__)('Changes will apply to new posts only. Individual posts may override these settings.'), 16354 checked: commentsOnNewPostsValue, 16355 onChange: setAllowCommentsOnNewPosts 16356 })))); 16357 } 16358 16359 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sidebar-navigation-screen-template/index.js 16360 16361 /** 16362 * WordPress dependencies 16363 */ 16364 16365 16366 16367 16368 16369 /** 16370 * Internal dependencies 16371 */ 16372 16373 16374 16375 16376 16377 16378 16379 16380 16381 16382 function useTemplateDetails(postType, postId) { 16383 const { 16384 getDescription, 16385 getTitle, 16386 record 16387 } = useEditedEntityRecord(postType, postId); 16388 const currentTheme = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).getCurrentTheme(), []); 16389 const addedBy = useAddedBy(postType, postId); 16390 const isAddedByActiveTheme = addedBy.type === 'theme' && record.theme === currentTheme?.stylesheet; 16391 const title = getTitle(); 16392 let descriptionText = getDescription(); 16393 if (!descriptionText && addedBy.text) { 16394 descriptionText = (0,external_wp_i18n_namespaceObject.__)('This is a custom template that can be applied manually to any Post or Page.'); 16395 } 16396 const content = record?.slug === 'home' || record?.slug === 'index' ? (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(HomeTemplateDetails, null), (0,external_React_.createElement)(TemplateAreas, null)) : (0,external_React_.createElement)(TemplateAreas, null); 16397 const footer = record?.modified ? (0,external_React_.createElement)(SidebarNavigationScreenDetailsFooter, { 16398 record: record 16399 }) : null; 16400 const description = (0,external_React_.createElement)(external_React_.Fragment, null, descriptionText, addedBy.text && !isAddedByActiveTheme && (0,external_React_.createElement)("span", { 16401 className: "edit-site-sidebar-navigation-screen-template__added-by-description" 16402 }, (0,external_React_.createElement)("span", { 16403 className: "edit-site-sidebar-navigation-screen-template__added-by-description-author" 16404 }, (0,external_React_.createElement)("span", { 16405 className: "edit-site-sidebar-navigation-screen-template__added-by-description-author-icon" 16406 }, addedBy.imageUrl ? (0,external_React_.createElement)("img", { 16407 src: addedBy.imageUrl, 16408 alt: "", 16409 width: "24", 16410 height: "24" 16411 }) : (0,external_React_.createElement)(external_wp_components_namespaceObject.Icon, { 16412 icon: addedBy.icon 16413 })), addedBy.text), addedBy.isCustomized && (0,external_React_.createElement)("span", { 16414 className: "edit-site-sidebar-navigation-screen-template__added-by-description-customized" 16415 }, (0,external_wp_i18n_namespaceObject._x)('(Customized)', 'template')))); 16416 return { 16417 title, 16418 description, 16419 content, 16420 footer 16421 }; 16422 } 16423 function SidebarNavigationScreenTemplate() { 16424 const navigator = (0,external_wp_components_namespaceObject.__experimentalUseNavigator)(); 16425 const { 16426 params: { 16427 postType, 16428 postId 16429 } 16430 } = navigator; 16431 const { 16432 setCanvasMode 16433 } = unlock((0,external_wp_data_namespaceObject.useDispatch)(store_store)); 16434 const { 16435 title, 16436 content, 16437 description, 16438 footer 16439 } = useTemplateDetails(postType, postId); 16440 return (0,external_React_.createElement)(SidebarNavigationScreen, { 16441 title: title, 16442 actions: (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(TemplateActions, { 16443 postType: postType, 16444 postId: postId, 16445 toggleProps: { 16446 as: SidebarButton 16447 }, 16448 onRemove: () => { 16449 navigator.goTo(`/$postType}/all`); 16450 } 16451 }), (0,external_React_.createElement)(SidebarButton, { 16452 onClick: () => setCanvasMode('edit'), 16453 label: (0,external_wp_i18n_namespaceObject.__)('Edit'), 16454 icon: library_pencil 16455 })), 16456 description: description, 16457 content: content, 16458 footer: footer 16459 }); 16460 } 16461 16462 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/file.js 16463 16464 /** 16465 * WordPress dependencies 16466 */ 16467 16468 const file = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { 16469 viewBox: "0 0 24 24", 16470 xmlns: "http://www.w3.org/2000/svg" 16471 }, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 16472 fillRule: "evenodd", 16473 clipRule: "evenodd", 16474 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" 16475 })); 16476 /* harmony default export */ const library_file = (file); 16477 16478 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/symbol-filled.js 16479 16480 /** 16481 * WordPress dependencies 16482 */ 16483 16484 const symbolFilled = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { 16485 xmlns: "http://www.w3.org/2000/svg", 16486 viewBox: "0 0 24 24" 16487 }, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 16488 d: "M21.3 10.8l-5.6-5.6c-.7-.7-1.8-.7-2.5 0l-5.6 5.6c-.7.7-.7 1.8 0 2.5l5.6 5.6c.3.3.8.5 1.2.5s.9-.2 1.2-.5l5.6-5.6c.8-.7.8-1.9.1-2.5zm-17.6 1L10 5.5l-1-1-6.3 6.3c-.7.7-.7 1.8 0 2.5L9 19.5l1.1-1.1-6.3-6.3c-.2 0-.2-.2-.1-.3z" 16489 })); 16490 /* harmony default export */ const symbol_filled = (symbolFilled); 16491 16492 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/upload.js 16493 16494 /** 16495 * WordPress dependencies 16496 */ 16497 16498 const upload = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { 16499 xmlns: "http://www.w3.org/2000/svg", 16500 viewBox: "0 0 24 24" 16501 }, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 16502 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" 16503 })); 16504 /* harmony default export */ const library_upload = (upload); 16505 16506 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/utils/template-part-create.js 16507 /** 16508 * External dependencies 16509 */ 16510 16511 16512 /** 16513 * WordPress dependencies 16514 */ 16515 16516 16517 16518 /** 16519 * Internal dependencies 16520 */ 16521 16522 const useExistingTemplateParts = () => { 16523 return (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).getEntityRecords('postType', TEMPLATE_PART_POST_TYPE, { 16524 per_page: -1 16525 }), []); 16526 }; 16527 16528 /** 16529 * Return a unique template part title based on 16530 * the given title and existing template parts. 16531 * 16532 * @param {string} title The original template part title. 16533 * @param {Object} templateParts The array of template part entities. 16534 * @return {string} A unique template part title. 16535 */ 16536 const getUniqueTemplatePartTitle = (title, templateParts) => { 16537 const lowercaseTitle = title.toLowerCase(); 16538 const existingTitles = templateParts.map(templatePart => templatePart.title.rendered.toLowerCase()); 16539 if (!existingTitles.includes(lowercaseTitle)) { 16540 return title; 16541 } 16542 let suffix = 2; 16543 while (existingTitles.includes(`$lowercaseTitle} $suffix}`)) { 16544 suffix++; 16545 } 16546 return `$title} $suffix}`; 16547 }; 16548 16549 /** 16550 * Get a valid slug for a template part. 16551 * Currently template parts only allow latin chars. 16552 * The fallback slug will receive suffix by default. 16553 * 16554 * @param {string} title The template part title. 16555 * @return {string} A valid template part slug. 16556 */ 16557 const getCleanTemplatePartSlug = title => { 16558 return paramCase(title).replace(/[^\w-]+/g, '') || 'wp-custom-part'; 16559 }; 16560 16561 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/create-template-part-modal/index.js 16562 16563 /** 16564 * WordPress dependencies 16565 */ 16566 16567 16568 16569 16570 16571 16572 16573 16574 16575 16576 16577 /** 16578 * Internal dependencies 16579 */ 16580 16581 16582 function CreateTemplatePartModal({ 16583 modalTitle = (0,external_wp_i18n_namespaceObject.__)('Create template part'), 16584 ...restProps 16585 }) { 16586 return (0,external_React_.createElement)(external_wp_components_namespaceObject.Modal, { 16587 title: modalTitle, 16588 onRequestClose: restProps.closeModal, 16589 overlayClassName: "edit-site-create-template-part-modal" 16590 }, (0,external_React_.createElement)(CreateTemplatePartModalContents, { 16591 ...restProps 16592 })); 16593 } 16594 function CreateTemplatePartModalContents({ 16595 defaultArea = TEMPLATE_PART_AREA_DEFAULT_CATEGORY, 16596 blocks = [], 16597 confirmLabel = (0,external_wp_i18n_namespaceObject.__)('Create'), 16598 closeModal, 16599 onCreate, 16600 onError, 16601 defaultTitle = '' 16602 }) { 16603 const { 16604 createErrorNotice 16605 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store); 16606 const { 16607 saveEntityRecord 16608 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store); 16609 const existingTemplateParts = useExistingTemplateParts(); 16610 const [title, setTitle] = (0,external_wp_element_namespaceObject.useState)(defaultTitle); 16611 const [area, setArea] = (0,external_wp_element_namespaceObject.useState)(defaultArea); 16612 const [isSubmitting, setIsSubmitting] = (0,external_wp_element_namespaceObject.useState)(false); 16613 const instanceId = (0,external_wp_compose_namespaceObject.useInstanceId)(CreateTemplatePartModal); 16614 const templatePartAreas = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_editor_namespaceObject.store).__experimentalGetDefaultTemplatePartAreas(), []); 16615 async function createTemplatePart() { 16616 if (!title || isSubmitting) { 16617 return; 16618 } 16619 try { 16620 setIsSubmitting(true); 16621 const uniqueTitle = getUniqueTemplatePartTitle(title, existingTemplateParts); 16622 const cleanSlug = getCleanTemplatePartSlug(uniqueTitle); 16623 const templatePart = await saveEntityRecord('postType', TEMPLATE_PART_POST_TYPE, { 16624 slug: cleanSlug, 16625 title: uniqueTitle, 16626 content: (0,external_wp_blocks_namespaceObject.serialize)(blocks), 16627 area 16628 }, { 16629 throwOnError: true 16630 }); 16631 await onCreate(templatePart); 16632 16633 // TODO: Add a success notice? 16634 } catch (error) { 16635 const errorMessage = error.message && error.code !== 'unknown_error' ? error.message : (0,external_wp_i18n_namespaceObject.__)('An error occurred while creating the template part.'); 16636 createErrorNotice(errorMessage, { 16637 type: 'snackbar' 16638 }); 16639 onError?.(); 16640 } finally { 16641 setIsSubmitting(false); 16642 } 16643 } 16644 return (0,external_React_.createElement)("form", { 16645 onSubmit: async event => { 16646 event.preventDefault(); 16647 await createTemplatePart(); 16648 } 16649 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { 16650 spacing: "4" 16651 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.TextControl, { 16652 __nextHasNoMarginBottom: true, 16653 label: (0,external_wp_i18n_namespaceObject.__)('Name'), 16654 value: title, 16655 onChange: setTitle, 16656 required: true 16657 }), (0,external_React_.createElement)(external_wp_components_namespaceObject.BaseControl, { 16658 label: (0,external_wp_i18n_namespaceObject.__)('Area'), 16659 id: `edit-site-create-template-part-modal__area-selection-$instanceId}`, 16660 className: "edit-site-create-template-part-modal__area-base-control" 16661 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalRadioGroup, { 16662 label: (0,external_wp_i18n_namespaceObject.__)('Area'), 16663 className: "edit-site-create-template-part-modal__area-radio-group", 16664 id: `edit-site-create-template-part-modal__area-selection-$instanceId}`, 16665 onChange: setArea, 16666 checked: area 16667 }, templatePartAreas.map(({ 16668 icon, 16669 label, 16670 area: value, 16671 description 16672 }) => (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalRadio, { 16673 key: label, 16674 value: value, 16675 className: "edit-site-create-template-part-modal__area-radio" 16676 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.Flex, { 16677 align: "start", 16678 justify: "start" 16679 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.FlexItem, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.Icon, { 16680 icon: icon 16681 })), (0,external_React_.createElement)(external_wp_components_namespaceObject.FlexBlock, { 16682 className: "edit-site-create-template-part-modal__option-label" 16683 }, label, (0,external_React_.createElement)("div", null, description)), (0,external_React_.createElement)(external_wp_components_namespaceObject.FlexItem, { 16684 className: "edit-site-create-template-part-modal__checkbox" 16685 }, area === value && (0,external_React_.createElement)(external_wp_components_namespaceObject.Icon, { 16686 icon: library_check 16687 }))))))), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { 16688 justify: "right" 16689 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 16690 variant: "tertiary", 16691 onClick: () => { 16692 closeModal(); 16693 } 16694 }, (0,external_wp_i18n_namespaceObject.__)('Cancel')), (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 16695 variant: "primary", 16696 type: "submit", 16697 "aria-disabled": !title || isSubmitting, 16698 isBusy: isSubmitting 16699 }, confirmLabel)))); 16700 } 16701 16702 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/add-new-pattern/index.js 16703 16704 /** 16705 * WordPress dependencies 16706 */ 16707 16708 16709 16710 16711 16712 16713 16714 16715 16716 16717 /** 16718 * Internal dependencies 16719 */ 16720 16721 16722 16723 16724 const { 16725 useHistory: add_new_pattern_useHistory, 16726 useLocation: add_new_pattern_useLocation 16727 } = unlock(external_wp_router_namespaceObject.privateApis); 16728 const { 16729 CreatePatternModal, 16730 useAddPatternCategory 16731 } = unlock(external_wp_patterns_namespaceObject.privateApis); 16732 function AddNewPattern() { 16733 const history = add_new_pattern_useHistory(); 16734 const { 16735 params 16736 } = add_new_pattern_useLocation(); 16737 const [showPatternModal, setShowPatternModal] = (0,external_wp_element_namespaceObject.useState)(false); 16738 const [showTemplatePartModal, setShowTemplatePartModal] = (0,external_wp_element_namespaceObject.useState)(false); 16739 const isBlockBasedTheme = (0,external_wp_data_namespaceObject.useSelect)(select => { 16740 return select(external_wp_coreData_namespaceObject.store).getCurrentTheme()?.is_block_theme; 16741 }, []); 16742 const { 16743 createPatternFromFile 16744 } = unlock((0,external_wp_data_namespaceObject.useDispatch)(external_wp_patterns_namespaceObject.store)); 16745 const { 16746 createSuccessNotice, 16747 createErrorNotice 16748 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store); 16749 const patternUploadInputRef = (0,external_wp_element_namespaceObject.useRef)(); 16750 function handleCreatePattern({ 16751 pattern, 16752 categoryId 16753 }) { 16754 setShowPatternModal(false); 16755 history.push({ 16756 postId: pattern.id, 16757 postType: PATTERN_TYPES.user, 16758 categoryType: PATTERN_TYPES.theme, 16759 categoryId, 16760 canvas: 'edit' 16761 }); 16762 } 16763 function handleCreateTemplatePart(templatePart) { 16764 setShowTemplatePartModal(false); 16765 16766 // Navigate to the created template part editor. 16767 history.push({ 16768 postId: templatePart.id, 16769 postType: TEMPLATE_PART_POST_TYPE, 16770 canvas: 'edit' 16771 }); 16772 } 16773 function handleError() { 16774 setShowPatternModal(false); 16775 setShowTemplatePartModal(false); 16776 } 16777 const controls = [{ 16778 icon: library_symbol, 16779 onClick: () => setShowPatternModal(true), 16780 title: (0,external_wp_i18n_namespaceObject.__)('Create pattern') 16781 }]; 16782 if (isBlockBasedTheme) { 16783 controls.push({ 16784 icon: symbol_filled, 16785 onClick: () => setShowTemplatePartModal(true), 16786 title: (0,external_wp_i18n_namespaceObject.__)('Create template part') 16787 }); 16788 } 16789 controls.push({ 16790 icon: library_upload, 16791 onClick: () => { 16792 patternUploadInputRef.current.click(); 16793 }, 16794 title: (0,external_wp_i18n_namespaceObject.__)('Import pattern from JSON') 16795 }); 16796 const { 16797 categoryMap, 16798 findOrCreateTerm 16799 } = useAddPatternCategory(); 16800 return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.DropdownMenu, { 16801 controls: controls, 16802 toggleProps: { 16803 as: SidebarButton 16804 }, 16805 icon: library_plus, 16806 label: (0,external_wp_i18n_namespaceObject.__)('Create pattern') 16807 }), showPatternModal && (0,external_React_.createElement)(CreatePatternModal, { 16808 onClose: () => setShowPatternModal(false), 16809 onSuccess: handleCreatePattern, 16810 onError: handleError 16811 }), showTemplatePartModal && (0,external_React_.createElement)(CreateTemplatePartModal, { 16812 closeModal: () => setShowTemplatePartModal(false), 16813 blocks: [], 16814 onCreate: handleCreateTemplatePart, 16815 onError: handleError 16816 }), (0,external_React_.createElement)("input", { 16817 type: "file", 16818 accept: ".json", 16819 hidden: true, 16820 ref: patternUploadInputRef, 16821 onChange: async event => { 16822 const file = event.target.files?.[0]; 16823 if (!file) return; 16824 try { 16825 let currentCategoryId; 16826 // When we're not handling template parts, we should 16827 // add or create the proper pattern category. 16828 if (params.categoryType !== TEMPLATE_PART_POST_TYPE) { 16829 const currentCategory = categoryMap.values().find(term => term.name === params.categoryId); 16830 if (!!currentCategory) { 16831 currentCategoryId = currentCategory.id || (await findOrCreateTerm(currentCategory.label)); 16832 } 16833 } 16834 const pattern = await createPatternFromFile(file, currentCategoryId ? [currentCategoryId] : undefined); 16835 16836 // Navigate to the All patterns category for the newly created pattern 16837 // if we're not on that page already and if we're not in the `my-patterns` 16838 // category. 16839 if (!currentCategoryId && params.categoryId !== 'my-patterns') { 16840 history.push({ 16841 path: `/patterns`, 16842 categoryType: PATTERN_TYPES.theme, 16843 categoryId: PATTERN_DEFAULT_CATEGORY 16844 }); 16845 } 16846 createSuccessNotice((0,external_wp_i18n_namespaceObject.sprintf)( 16847 // translators: %s: The imported pattern's title. 16848 (0,external_wp_i18n_namespaceObject.__)('Imported "%s" from JSON.'), pattern.title.raw), { 16849 type: 'snackbar', 16850 id: 'import-pattern-success' 16851 }); 16852 } catch (err) { 16853 createErrorNotice(err.message, { 16854 type: 'snackbar', 16855 id: 'import-pattern-error' 16856 }); 16857 } finally { 16858 event.target.value = ''; 16859 } 16860 } 16861 })); 16862 } 16863 16864 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sidebar-navigation-screen-patterns/category-item.js 16865 16866 /** 16867 * Internal dependencies 16868 */ 16869 16870 16871 function CategoryItem({ 16872 count, 16873 icon, 16874 id, 16875 isActive, 16876 label, 16877 type 16878 }) { 16879 const linkInfo = useLink({ 16880 path: '/patterns', 16881 categoryType: type, 16882 categoryId: id 16883 }); 16884 if (!count) { 16885 return; 16886 } 16887 return (0,external_React_.createElement)(SidebarNavigationItem, { 16888 ...linkInfo, 16889 icon: icon, 16890 suffix: (0,external_React_.createElement)("span", null, count), 16891 "aria-current": isActive ? 'true' : undefined 16892 }, label); 16893 } 16894 16895 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sidebar-navigation-screen-patterns/use-default-pattern-categories.js 16896 /** 16897 * WordPress dependencies 16898 */ 16899 16900 16901 16902 /** 16903 * Internal dependencies 16904 */ 16905 16906 16907 function useDefaultPatternCategories() { 16908 const blockPatternCategories = (0,external_wp_data_namespaceObject.useSelect)(select => { 16909 var _settings$__experimen; 16910 const { 16911 getSettings 16912 } = unlock(select(store_store)); 16913 const settings = getSettings(); 16914 return (_settings$__experimen = settings.__experimentalAdditionalBlockPatternCategories) !== null && _settings$__experimen !== void 0 ? _settings$__experimen : settings.__experimentalBlockPatternCategories; 16915 }); 16916 const restBlockPatternCategories = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).getBlockPatternCategories()); 16917 return [...(blockPatternCategories || []), ...(restBlockPatternCategories || [])]; 16918 } 16919 16920 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/page-patterns/utils.js 16921 const filterOutDuplicatesByName = (currentItem, index, items) => index === items.findIndex(item => currentItem.name === item.name); 16922 16923 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sidebar-navigation-screen-patterns/use-theme-patterns.js 16924 /** 16925 * WordPress dependencies 16926 */ 16927 16928 16929 16930 16931 /** 16932 * Internal dependencies 16933 */ 16934 16935 16936 16937 16938 function useThemePatterns() { 16939 const blockPatterns = (0,external_wp_data_namespaceObject.useSelect)(select => { 16940 var _getSettings$__experi; 16941 const { 16942 getSettings 16943 } = unlock(select(store_store)); 16944 return (_getSettings$__experi = getSettings().__experimentalAdditionalBlockPatterns) !== null && _getSettings$__experi !== void 0 ? _getSettings$__experi : getSettings().__experimentalBlockPatterns; 16945 }); 16946 const restBlockPatterns = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).getBlockPatterns()); 16947 const patterns = (0,external_wp_element_namespaceObject.useMemo)(() => [...(blockPatterns || []), ...(restBlockPatterns || [])].filter(pattern => !EXCLUDED_PATTERN_SOURCES.includes(pattern.source)).filter(filterOutDuplicatesByName).filter(pattern => pattern.inserter !== false), [blockPatterns, restBlockPatterns]); 16948 return patterns; 16949 } 16950 16951 ;// CONCATENATED MODULE: ./node_modules/rememo/rememo.js 16952 16953 16954 /** @typedef {(...args: any[]) => *[]} GetDependants */ 16955 16956 /** @typedef {() => void} Clear */ 16957 16958 /** 16959 * @typedef {{ 16960 * getDependants: GetDependants, 16961 * clear: Clear 16962 * }} EnhancedSelector 16963 */ 16964 16965 /** 16966 * Internal cache entry. 16967 * 16968 * @typedef CacheNode 16969 * 16970 * @property {?CacheNode|undefined} [prev] Previous node. 16971 * @property {?CacheNode|undefined} [next] Next node. 16972 * @property {*[]} args Function arguments for cache entry. 16973 * @property {*} val Function result. 16974 */ 16975 16976 /** 16977 * @typedef Cache 16978 * 16979 * @property {Clear} clear Function to clear cache. 16980 * @property {boolean} [isUniqueByDependants] Whether dependants are valid in 16981 * considering cache uniqueness. A cache is unique if dependents are all arrays 16982 * or objects. 16983 * @property {CacheNode?} [head] Cache head. 16984 * @property {*[]} [lastDependants] Dependants from previous invocation. 16985 */ 16986 16987 /** 16988 * Arbitrary value used as key for referencing cache object in WeakMap tree. 16989 * 16990 * @type {{}} 16991 */ 16992 var LEAF_KEY = {}; 16993 16994 /** 16995 * Returns the first argument as the sole entry in an array. 16996 * 16997 * @template T 16998 * 16999 * @param {T} value Value to return. 17000 * 17001 * @return {[T]} Value returned as entry in array. 17002 */ 17003 function arrayOf(value) { 17004 return [value]; 17005 } 17006 17007 /** 17008 * Returns true if the value passed is object-like, or false otherwise. A value 17009 * is object-like if it can support property assignment, e.g. object or array. 17010 * 17011 * @param {*} value Value to test. 17012 * 17013 * @return {boolean} Whether value is object-like. 17014 */ 17015 function isObjectLike(value) { 17016 return !!value && 'object' === typeof value; 17017 } 17018 17019 /** 17020 * Creates and returns a new cache object. 17021 * 17022 * @return {Cache} Cache object. 17023 */ 17024 function createCache() { 17025 /** @type {Cache} */ 17026 var cache = { 17027 clear: function () { 17028 cache.head = null; 17029 }, 17030 }; 17031 17032 return cache; 17033 } 17034 17035 /** 17036 * Returns true if entries within the two arrays are strictly equal by 17037 * reference from a starting index. 17038 * 17039 * @param {*[]} a First array. 17040 * @param {*[]} b Second array. 17041 * @param {number} fromIndex Index from which to start comparison. 17042 * 17043 * @return {boolean} Whether arrays are shallowly equal. 17044 */ 17045 function isShallowEqual(a, b, fromIndex) { 17046 var i; 17047 17048 if (a.length !== b.length) { 17049 return false; 17050 } 17051 17052 for (i = fromIndex; i < a.length; i++) { 17053 if (a[i] !== b[i]) { 17054 return false; 17055 } 17056 } 17057 17058 return true; 17059 } 17060 17061 /** 17062 * Returns a memoized selector function. The getDependants function argument is 17063 * called before the memoized selector and is expected to return an immutable 17064 * reference or array of references on which the selector depends for computing 17065 * its own return value. The memoize cache is preserved only as long as those 17066 * dependant references remain the same. If getDependants returns a different 17067 * reference(s), the cache is cleared and the selector value regenerated. 17068 * 17069 * @template {(...args: *[]) => *} S 17070 * 17071 * @param {S} selector Selector function. 17072 * @param {GetDependants=} getDependants Dependant getter returning an array of 17073 * references used in cache bust consideration. 17074 */ 17075 /* harmony default export */ function rememo(selector, getDependants) { 17076 /** @type {WeakMap<*,*>} */ 17077 var rootCache; 17078 17079 /** @type {GetDependants} */ 17080 var normalizedGetDependants = getDependants ? getDependants : arrayOf; 17081 17082 /** 17083 * Returns the cache for a given dependants array. When possible, a WeakMap 17084 * will be used to create a unique cache for each set of dependants. This 17085 * is feasible due to the nature of WeakMap in allowing garbage collection 17086 * to occur on entries where the key object is no longer referenced. Since 17087 * WeakMap requires the key to be an object, this is only possible when the 17088 * dependant is object-like. The root cache is created as a hierarchy where 17089 * each top-level key is the first entry in a dependants set, the value a 17090 * WeakMap where each key is the next dependant, and so on. This continues 17091 * so long as the dependants are object-like. If no dependants are object- 17092 * like, then the cache is shared across all invocations. 17093 * 17094 * @see isObjectLike 17095 * 17096 * @param {*[]} dependants Selector dependants. 17097 * 17098 * @return {Cache} Cache object. 17099 */ 17100 function getCache(dependants) { 17101 var caches = rootCache, 17102 isUniqueByDependants = true, 17103 i, 17104 dependant, 17105 map, 17106 cache; 17107 17108 for (i = 0; i < dependants.length; i++) { 17109 dependant = dependants[i]; 17110 17111 // Can only compose WeakMap from object-like key. 17112 if (!isObjectLike(dependant)) { 17113 isUniqueByDependants = false; 17114 break; 17115 } 17116 17117 // Does current segment of cache already have a WeakMap? 17118 if (caches.has(dependant)) { 17119 // Traverse into nested WeakMap. 17120 caches = caches.get(dependant); 17121 } else { 17122 // Create, set, and traverse into a new one. 17123 map = new WeakMap(); 17124 caches.set(dependant, map); 17125 caches = map; 17126 } 17127 } 17128 17129 // We use an arbitrary (but consistent) object as key for the last item 17130 // in the WeakMap to serve as our running cache. 17131 if (!caches.has(LEAF_KEY)) { 17132 cache = createCache(); 17133 cache.isUniqueByDependants = isUniqueByDependants; 17134 caches.set(LEAF_KEY, cache); 17135 } 17136 17137 return caches.get(LEAF_KEY); 17138 } 17139 17140 /** 17141 * Resets root memoization cache. 17142 */ 17143 function clear() { 17144 rootCache = new WeakMap(); 17145 } 17146 17147 /* eslint-disable jsdoc/check-param-names */ 17148 /** 17149 * The augmented selector call, considering first whether dependants have 17150 * changed before passing it to underlying memoize function. 17151 * 17152 * @param {*} source Source object for derivation. 17153 * @param {...*} extraArgs Additional arguments to pass to selector. 17154 * 17155 * @return {*} Selector result. 17156 */ 17157 /* eslint-enable jsdoc/check-param-names */ 17158 function callSelector(/* source, ...extraArgs */) { 17159 var len = arguments.length, 17160 cache, 17161 node, 17162 i, 17163 args, 17164 dependants; 17165 17166 // Create copy of arguments (avoid leaking deoptimization). 17167 args = new Array(len); 17168 for (i = 0; i < len; i++) { 17169 args[i] = arguments[i]; 17170 } 17171 17172 dependants = normalizedGetDependants.apply(null, args); 17173 cache = getCache(dependants); 17174 17175 // If not guaranteed uniqueness by dependants (primitive type), shallow 17176 // compare against last dependants and, if references have changed, 17177 // destroy cache to recalculate result. 17178 if (!cache.isUniqueByDependants) { 17179 if ( 17180 cache.lastDependants && 17181 !isShallowEqual(dependants, cache.lastDependants, 0) 17182 ) { 17183 cache.clear(); 17184 } 17185 17186 cache.lastDependants = dependants; 17187 } 17188 17189 node = cache.head; 17190 while (node) { 17191 // Check whether node arguments match arguments 17192 if (!isShallowEqual(node.args, args, 1)) { 17193 node = node.next; 17194 continue; 17195 } 17196 17197 // At this point we can assume we've found a match 17198 17199 // Surface matched node to head if not already 17200 if (node !== cache.head) { 17201 // Adjust siblings to point to each other. 17202 /** @type {CacheNode} */ (node.prev).next = node.next; 17203 if (node.next) { 17204 node.next.prev = node.prev; 17205 } 17206 17207 node.next = cache.head; 17208 node.prev = null; 17209 /** @type {CacheNode} */ (cache.head).prev = node; 17210 cache.head = node; 17211 } 17212 17213 // Return immediately 17214 return node.val; 17215 } 17216 17217 // No cached value found. Continue to insertion phase: 17218 17219 node = /** @type {CacheNode} */ ({ 17220 // Generate the result from original function 17221 val: selector.apply(null, args), 17222 }); 17223 17224 // Avoid including the source object in the cache. 17225 args[0] = null; 17226 node.args = args; 17227 17228 // Don't need to check whether node is already head, since it would 17229 // have been returned above already if it was 17230 17231 // Shift existing head down list 17232 if (cache.head) { 17233 cache.head.prev = node; 17234 node.next = cache.head; 17235 } 17236 17237 cache.head = node; 17238 17239 return node.val; 17240 } 17241 17242 callSelector.getDependants = normalizedGetDependants; 17243 callSelector.clear = clear; 17244 clear(); 17245 17246 return /** @type {S & EnhancedSelector} */ (callSelector); 17247 } 17248 17249 // EXTERNAL MODULE: ./node_modules/remove-accents/index.js 17250 var remove_accents = __webpack_require__(9681); 17251 var remove_accents_default = /*#__PURE__*/__webpack_require__.n(remove_accents); 17252 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/page-patterns/search-items.js 17253 /** 17254 * External dependencies 17255 */ 17256 17257 17258 17259 /** 17260 * Internal dependencies 17261 */ 17262 17263 17264 // Default search helpers. 17265 const defaultGetName = item => item.name || ''; 17266 const defaultGetTitle = item => item.title; 17267 const defaultGetDescription = item => item.description || ''; 17268 const defaultGetKeywords = item => item.keywords || []; 17269 const defaultHasCategory = () => false; 17270 17271 /** 17272 * Extracts words from an input string. 17273 * 17274 * @param {string} input The input string. 17275 * 17276 * @return {Array} Words, extracted from the input string. 17277 */ 17278 function extractWords(input = '') { 17279 return noCase(input, { 17280 splitRegexp: [/([\p{Ll}\p{Lo}\p{N}])([\p{Lu}\p{Lt}])/gu, 17281 // One lowercase or digit, followed by one uppercase. 17282 /([\p{Lu}\p{Lt}])([\p{Lu}\p{Lt}][\p{Ll}\p{Lo}])/gu // One uppercase followed by one uppercase and one lowercase. 17283 ], 17284 stripRegexp: /(\p{C}|\p{P}|\p{S})+/giu // Anything that's not a punctuation, symbol or control/format character. 17285 }).split(' ').filter(Boolean); 17286 } 17287 17288 /** 17289 * Sanitizes the search input string. 17290 * 17291 * @param {string} input The search input to normalize. 17292 * 17293 * @return {string} The normalized search input. 17294 */ 17295 function normalizeSearchInput(input = '') { 17296 // Disregard diacritics. 17297 // Input: "média" 17298 input = remove_accents_default()(input); 17299 17300 // Accommodate leading slash, matching autocomplete expectations. 17301 // Input: "/media" 17302 input = input.replace(/^\//, ''); 17303 17304 // Lowercase. 17305 // Input: "MEDIA" 17306 input = input.toLowerCase(); 17307 return input; 17308 } 17309 17310 /** 17311 * Converts the search term into a list of normalized terms. 17312 * 17313 * @param {string} input The search term to normalize. 17314 * 17315 * @return {string[]} The normalized list of search terms. 17316 */ 17317 const getNormalizedSearchTerms = (input = '') => { 17318 return extractWords(normalizeSearchInput(input)); 17319 }; 17320 const removeMatchingTerms = (unmatchedTerms, unprocessedTerms) => { 17321 return unmatchedTerms.filter(term => !getNormalizedSearchTerms(unprocessedTerms).some(unprocessedTerm => unprocessedTerm.includes(term))); 17322 }; 17323 17324 /** 17325 * Filters an item list given a search term. 17326 * 17327 * @param {Array} items Item list 17328 * @param {string} searchInput Search input. 17329 * @param {Object} config Search Config. 17330 * 17331 * @return {Array} Filtered item list. 17332 */ 17333 const searchItems = (items = [], searchInput = '', config = {}) => { 17334 const normalizedSearchTerms = getNormalizedSearchTerms(searchInput); 17335 // Filter patterns by category: the default category indicates that all patterns will be shown. 17336 const onlyFilterByCategory = config.categoryId !== PATTERN_DEFAULT_CATEGORY && !normalizedSearchTerms.length; 17337 const searchRankConfig = { 17338 ...config, 17339 onlyFilterByCategory 17340 }; 17341 17342 // If we aren't filtering on search terms, matching on category is satisfactory. 17343 // If we are, then we need more than a category match. 17344 const threshold = onlyFilterByCategory ? 0 : 1; 17345 const rankedItems = items.map(item => { 17346 return [item, getItemSearchRank(item, searchInput, searchRankConfig)]; 17347 }).filter(([, rank]) => rank > threshold); 17348 17349 // If we didn't have terms to search on, there's no point sorting. 17350 if (normalizedSearchTerms.length === 0) { 17351 return rankedItems.map(([item]) => item); 17352 } 17353 rankedItems.sort(([, rank1], [, rank2]) => rank2 - rank1); 17354 return rankedItems.map(([item]) => item); 17355 }; 17356 17357 /** 17358 * Get the search rank for a given item and a specific search term. 17359 * The better the match, the higher the rank. 17360 * If the rank equals 0, it should be excluded from the results. 17361 * 17362 * @param {Object} item Item to filter. 17363 * @param {string} searchTerm Search term. 17364 * @param {Object} config Search Config. 17365 * 17366 * @return {number} Search Rank. 17367 */ 17368 function getItemSearchRank(item, searchTerm, config) { 17369 const { 17370 categoryId, 17371 getName = defaultGetName, 17372 getTitle = defaultGetTitle, 17373 getDescription = defaultGetDescription, 17374 getKeywords = defaultGetKeywords, 17375 hasCategory = defaultHasCategory, 17376 onlyFilterByCategory 17377 } = config; 17378 let rank = categoryId === PATTERN_DEFAULT_CATEGORY || categoryId === PATTERN_USER_CATEGORY && item.type === PATTERN_TYPES.user || hasCategory(item, categoryId) ? 1 : 0; 17379 17380 // If an item doesn't belong to the current category or we don't have 17381 // search terms to filter by, return the initial rank value. 17382 if (!rank || onlyFilterByCategory) { 17383 return rank; 17384 } 17385 const name = getName(item); 17386 const title = getTitle(item); 17387 const description = getDescription(item); 17388 const keywords = getKeywords(item); 17389 const normalizedSearchInput = normalizeSearchInput(searchTerm); 17390 const normalizedTitle = normalizeSearchInput(title); 17391 17392 // Prefers exact matches 17393 // Then prefers if the beginning of the title matches the search term 17394 // name, keywords, description matches come later. 17395 if (normalizedSearchInput === normalizedTitle) { 17396 rank += 30; 17397 } else if (normalizedTitle.startsWith(normalizedSearchInput)) { 17398 rank += 20; 17399 } else { 17400 const terms = [name, title, description, ...keywords].join(' '); 17401 const normalizedSearchTerms = extractWords(normalizedSearchInput); 17402 const unmatchedTerms = removeMatchingTerms(normalizedSearchTerms, terms); 17403 if (unmatchedTerms.length === 0) { 17404 rank += 10; 17405 } 17406 } 17407 return rank; 17408 } 17409 17410 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/page-patterns/use-patterns.js 17411 /** 17412 * External dependencies 17413 */ 17414 17415 17416 /** 17417 * WordPress dependencies 17418 */ 17419 17420 17421 17422 17423 17424 17425 /** 17426 * Internal dependencies 17427 */ 17428 17429 17430 17431 17432 17433 const EMPTY_PATTERN_LIST = []; 17434 const createTemplatePartId = (theme, slug) => theme && slug ? theme + '//' + slug : null; 17435 const templatePartToPattern = templatePart => ({ 17436 blocks: (0,external_wp_blocks_namespaceObject.parse)(templatePart.content.raw, { 17437 __unstableSkipMigrationLogs: true 17438 }), 17439 categories: [templatePart.area], 17440 description: templatePart.description || '', 17441 isCustom: templatePart.source === TEMPLATE_ORIGINS.custom, 17442 keywords: templatePart.keywords || [], 17443 id: createTemplatePartId(templatePart.theme, templatePart.slug), 17444 name: createTemplatePartId(templatePart.theme, templatePart.slug), 17445 title: (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(templatePart.title.rendered), 17446 type: templatePart.type, 17447 templatePart 17448 }); 17449 const selectTemplatePartsAsPatterns = rememo((select, categoryId, search = '') => { 17450 var _getEntityRecords; 17451 const { 17452 getEntityRecords, 17453 getIsResolving 17454 } = select(external_wp_coreData_namespaceObject.store); 17455 const { 17456 __experimentalGetDefaultTemplatePartAreas 17457 } = select(external_wp_editor_namespaceObject.store); 17458 const query = { 17459 per_page: -1 17460 }; 17461 const rawTemplateParts = (_getEntityRecords = getEntityRecords('postType', TEMPLATE_PART_POST_TYPE, query)) !== null && _getEntityRecords !== void 0 ? _getEntityRecords : EMPTY_PATTERN_LIST; 17462 const templateParts = rawTemplateParts.map(templatePart => templatePartToPattern(templatePart)); 17463 17464 // In the case where a custom template part area has been removed we need 17465 // the current list of areas to cross check against so orphaned template 17466 // parts can be treated as uncategorized. 17467 const knownAreas = __experimentalGetDefaultTemplatePartAreas() || []; 17468 const templatePartAreas = knownAreas.map(area => area.area); 17469 const templatePartHasCategory = (item, category) => { 17470 if (category !== TEMPLATE_PART_AREA_DEFAULT_CATEGORY) { 17471 return item.templatePart.area === category; 17472 } 17473 return item.templatePart.area === category || !templatePartAreas.includes(item.templatePart.area); 17474 }; 17475 const isResolving = getIsResolving('getEntityRecords', ['postType', TEMPLATE_PART_POST_TYPE, query]); 17476 const patterns = searchItems(templateParts, search, { 17477 categoryId, 17478 hasCategory: templatePartHasCategory 17479 }); 17480 return { 17481 patterns, 17482 isResolving 17483 }; 17484 }, select => [select(external_wp_coreData_namespaceObject.store).getEntityRecords('postType', TEMPLATE_PART_POST_TYPE, { 17485 per_page: -1 17486 }), select(external_wp_coreData_namespaceObject.store).getIsResolving('getEntityRecords', ['postType', TEMPLATE_PART_POST_TYPE, { 17487 per_page: -1 17488 }]), select(external_wp_editor_namespaceObject.store).__experimentalGetDefaultTemplatePartAreas()]); 17489 const selectThemePatterns = rememo(select => { 17490 var _settings$__experimen; 17491 const { 17492 getSettings 17493 } = unlock(select(store_store)); 17494 const { 17495 getIsResolving 17496 } = select(external_wp_coreData_namespaceObject.store); 17497 const settings = getSettings(); 17498 const blockPatterns = (_settings$__experimen = settings.__experimentalAdditionalBlockPatterns) !== null && _settings$__experimen !== void 0 ? _settings$__experimen : settings.__experimentalBlockPatterns; 17499 const restBlockPatterns = select(external_wp_coreData_namespaceObject.store).getBlockPatterns(); 17500 const patterns = [...(blockPatterns || []), ...(restBlockPatterns || [])].filter(pattern => !EXCLUDED_PATTERN_SOURCES.includes(pattern.source)).filter(filterOutDuplicatesByName).filter(pattern => pattern.inserter !== false).map(pattern => ({ 17501 ...pattern, 17502 keywords: pattern.keywords || [], 17503 type: PATTERN_TYPES.theme, 17504 blocks: (0,external_wp_blocks_namespaceObject.parse)(pattern.content, { 17505 __unstableSkipMigrationLogs: true 17506 }) 17507 })); 17508 return { 17509 patterns, 17510 isResolving: getIsResolving('getBlockPatterns') 17511 }; 17512 }, select => [select(external_wp_coreData_namespaceObject.store).getBlockPatterns(), select(external_wp_coreData_namespaceObject.store).getIsResolving('getBlockPatterns'), unlock(select(store_store)).getSettings()]); 17513 const selectPatterns = rememo((select, categoryId, syncStatus, search = '') => { 17514 const { 17515 patterns: themePatterns, 17516 isResolving: isResolvingThemePatterns 17517 } = selectThemePatterns(select); 17518 const { 17519 patterns: userPatterns, 17520 isResolving: isResolvingUserPatterns 17521 } = selectUserPatterns(select); 17522 let patterns = [...(themePatterns || []), ...(userPatterns || [])]; 17523 if (syncStatus) { 17524 // User patterns can have their sync statuses checked directly 17525 // Non-user patterns are all unsynced for the time being. 17526 patterns = patterns.filter(pattern => { 17527 return pattern.type === PATTERN_TYPES.user ? pattern.syncStatus === syncStatus : syncStatus === PATTERN_SYNC_TYPES.unsynced; 17528 }); 17529 } 17530 if (categoryId) { 17531 patterns = searchItems(patterns, search, { 17532 categoryId, 17533 hasCategory: (item, currentCategory) => item.categories?.includes(currentCategory) 17534 }); 17535 } else { 17536 patterns = searchItems(patterns, search, { 17537 hasCategory: item => !item.hasOwnProperty('categories') 17538 }); 17539 } 17540 return { 17541 patterns, 17542 isResolving: isResolvingThemePatterns || isResolvingUserPatterns 17543 }; 17544 }, select => [selectThemePatterns(select), selectUserPatterns(select)]); 17545 17546 /** 17547 * Converts a post of type `wp_block` to a 'pattern item' that more closely 17548 * matches the structure of theme provided patterns. 17549 * 17550 * @param {Object} patternPost The `wp_block` record being normalized. 17551 * @param {Map} categories A Map of user created categories. 17552 * 17553 * @return {Object} The normalized item. 17554 */ 17555 const convertPatternPostToItem = (patternPost, categories) => ({ 17556 blocks: (0,external_wp_blocks_namespaceObject.parse)(patternPost.content.raw, { 17557 __unstableSkipMigrationLogs: true 17558 }), 17559 ...(patternPost.wp_pattern_category.length > 0 && { 17560 categories: patternPost.wp_pattern_category.map(patternCategoryId => categories && categories.get(patternCategoryId) ? categories.get(patternCategoryId).slug : patternCategoryId) 17561 }), 17562 termLabels: patternPost.wp_pattern_category.map(patternCategoryId => categories?.get(patternCategoryId) ? categories.get(patternCategoryId).label : patternCategoryId), 17563 id: patternPost.id, 17564 name: patternPost.slug, 17565 syncStatus: patternPost.wp_pattern_sync_status || PATTERN_SYNC_TYPES.full, 17566 title: patternPost.title.raw, 17567 type: patternPost.type, 17568 patternPost 17569 }); 17570 const selectUserPatterns = rememo((select, syncStatus, search = '') => { 17571 const { 17572 getEntityRecords, 17573 getIsResolving, 17574 getUserPatternCategories 17575 } = select(external_wp_coreData_namespaceObject.store); 17576 const query = { 17577 per_page: -1 17578 }; 17579 const patternPosts = getEntityRecords('postType', PATTERN_TYPES.user, query); 17580 const userPatternCategories = getUserPatternCategories(); 17581 const categories = new Map(); 17582 userPatternCategories.forEach(userCategory => categories.set(userCategory.id, userCategory)); 17583 let patterns = patternPosts ? patternPosts.map(record => convertPatternPostToItem(record, categories)) : EMPTY_PATTERN_LIST; 17584 const isResolving = getIsResolving('getEntityRecords', ['postType', PATTERN_TYPES.user, query]); 17585 if (syncStatus) { 17586 patterns = patterns.filter(pattern => pattern.syncStatus === syncStatus); 17587 } 17588 patterns = searchItems(patterns, search, { 17589 // We exit user pattern retrieval early if we aren't in the 17590 // catch-all category for user created patterns, so it has 17591 // to be in the category. 17592 hasCategory: () => true 17593 }); 17594 return { 17595 patterns, 17596 isResolving, 17597 categories: userPatternCategories 17598 }; 17599 }, select => [select(external_wp_coreData_namespaceObject.store).getEntityRecords('postType', PATTERN_TYPES.user, { 17600 per_page: -1 17601 }), select(external_wp_coreData_namespaceObject.store).getIsResolving('getEntityRecords', ['postType', PATTERN_TYPES.user, { 17602 per_page: -1 17603 }]), select(external_wp_coreData_namespaceObject.store).getUserPatternCategories()]); 17604 const usePatterns = (categoryType, categoryId, { 17605 search = '', 17606 syncStatus 17607 } = {}) => { 17608 return (0,external_wp_data_namespaceObject.useSelect)(select => { 17609 if (categoryType === TEMPLATE_PART_POST_TYPE) { 17610 return selectTemplatePartsAsPatterns(select, categoryId, search); 17611 } else if (categoryType === PATTERN_TYPES.theme) { 17612 return selectPatterns(select, categoryId, syncStatus, search); 17613 } else if (categoryType === PATTERN_TYPES.user) { 17614 return selectUserPatterns(select, syncStatus, search); 17615 } 17616 return { 17617 patterns: EMPTY_PATTERN_LIST, 17618 isResolving: false 17619 }; 17620 }, [categoryId, categoryType, search, syncStatus]); 17621 }; 17622 /* harmony default export */ const use_patterns = (usePatterns); 17623 17624 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sidebar-navigation-screen-patterns/use-pattern-categories.js 17625 /** 17626 * WordPress dependencies 17627 */ 17628 17629 17630 17631 /** 17632 * Internal dependencies 17633 */ 17634 17635 17636 17637 17638 function usePatternCategories() { 17639 const defaultCategories = useDefaultPatternCategories(); 17640 defaultCategories.push({ 17641 name: TEMPLATE_PART_AREA_DEFAULT_CATEGORY, 17642 label: (0,external_wp_i18n_namespaceObject.__)('Uncategorized') 17643 }); 17644 const themePatterns = useThemePatterns(); 17645 const { 17646 patterns: userPatterns, 17647 categories: userPatternCategories 17648 } = use_patterns(PATTERN_TYPES.user); 17649 const patternCategories = (0,external_wp_element_namespaceObject.useMemo)(() => { 17650 const categoryMap = {}; 17651 const categoriesWithCounts = []; 17652 17653 // Create a map for easier counting of patterns in categories. 17654 defaultCategories.forEach(category => { 17655 if (!categoryMap[category.name]) { 17656 categoryMap[category.name] = { 17657 ...category, 17658 count: 0 17659 }; 17660 } 17661 }); 17662 userPatternCategories.forEach(category => { 17663 if (!categoryMap[category.name]) { 17664 categoryMap[category.name] = { 17665 ...category, 17666 count: 0 17667 }; 17668 } 17669 }); 17670 17671 // Update the category counts to reflect theme registered patterns. 17672 themePatterns.forEach(pattern => { 17673 pattern.categories?.forEach(category => { 17674 if (categoryMap[category]) { 17675 categoryMap[category].count += 1; 17676 } 17677 }); 17678 // If the pattern has no categories, add it to uncategorized. 17679 if (!pattern.categories?.length) { 17680 categoryMap.uncategorized.count += 1; 17681 } 17682 }); 17683 17684 // Update the category counts to reflect user registered patterns. 17685 userPatterns.forEach(pattern => { 17686 pattern.categories?.forEach(category => { 17687 if (categoryMap[category]) { 17688 categoryMap[category].count += 1; 17689 } 17690 }); 17691 // If the pattern has no categories, add it to uncategorized. 17692 if (!pattern.categories?.length) { 17693 categoryMap.uncategorized.count += 1; 17694 } 17695 }); 17696 17697 // Filter categories so we only have those containing patterns. 17698 [...defaultCategories, ...userPatternCategories].forEach(category => { 17699 if (categoryMap[category.name].count && !categoriesWithCounts.find(cat => cat.name === category.name)) { 17700 categoriesWithCounts.push(categoryMap[category.name]); 17701 } 17702 }); 17703 const sortedCategories = categoriesWithCounts.sort((a, b) => a.label.localeCompare(b.label)); 17704 sortedCategories.unshift({ 17705 name: PATTERN_USER_CATEGORY, 17706 label: (0,external_wp_i18n_namespaceObject.__)('My patterns'), 17707 count: userPatterns.length 17708 }); 17709 sortedCategories.unshift({ 17710 name: PATTERN_DEFAULT_CATEGORY, 17711 label: (0,external_wp_i18n_namespaceObject.__)('All patterns'), 17712 description: (0,external_wp_i18n_namespaceObject.__)('A list of all patterns from all sources.'), 17713 count: themePatterns.length + userPatterns.length 17714 }); 17715 return sortedCategories; 17716 }, [defaultCategories, themePatterns, userPatternCategories, userPatterns]); 17717 return { 17718 patternCategories, 17719 hasPatterns: !!patternCategories.length 17720 }; 17721 } 17722 17723 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sidebar-navigation-screen-patterns/use-template-part-areas.js 17724 /** 17725 * WordPress dependencies 17726 */ 17727 17728 17729 17730 17731 /** 17732 * Internal dependencies 17733 */ 17734 17735 const useTemplatePartsGroupedByArea = items => { 17736 const allItems = items || []; 17737 const templatePartAreas = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_editor_namespaceObject.store).__experimentalGetDefaultTemplatePartAreas(), []); 17738 17739 // Create map of template areas ensuring that default areas are displayed before 17740 // any custom registered template part areas. 17741 const knownAreas = { 17742 header: {}, 17743 footer: {}, 17744 sidebar: {}, 17745 uncategorized: {} 17746 }; 17747 templatePartAreas.forEach(templatePartArea => knownAreas[templatePartArea.area] = { 17748 ...templatePartArea, 17749 templateParts: [] 17750 }); 17751 const groupedByArea = allItems.reduce((accumulator, item) => { 17752 const key = accumulator[item.area] ? item.area : TEMPLATE_PART_AREA_DEFAULT_CATEGORY; 17753 accumulator[key].templateParts.push(item); 17754 return accumulator; 17755 }, knownAreas); 17756 return groupedByArea; 17757 }; 17758 function useTemplatePartAreas() { 17759 const { 17760 records: templateParts, 17761 isResolving: isLoading 17762 } = (0,external_wp_coreData_namespaceObject.useEntityRecords)('postType', TEMPLATE_PART_POST_TYPE, { 17763 per_page: -1 17764 }); 17765 return { 17766 hasTemplateParts: templateParts ? !!templateParts.length : false, 17767 isLoading, 17768 templatePartAreas: useTemplatePartsGroupedByArea(templateParts) 17769 }; 17770 } 17771 17772 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sidebar-navigation-screen-patterns/index.js 17773 17774 /** 17775 * WordPress dependencies 17776 */ 17777 17778 17779 17780 17781 17782 17783 17784 17785 17786 /** 17787 * Internal dependencies 17788 */ 17789 17790 17791 17792 17793 17794 17795 17796 17797 17798 function TemplatePartGroup({ 17799 areas, 17800 currentArea, 17801 currentType 17802 }) { 17803 return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)("div", { 17804 className: "edit-site-sidebar-navigation-screen-patterns__group-header" 17805 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHeading, { 17806 level: 2 17807 }, (0,external_wp_i18n_namespaceObject.__)('Template parts'))), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalItemGroup, { 17808 className: "edit-site-sidebar-navigation-screen-patterns__group" 17809 }, Object.entries(areas).map(([area, { 17810 label, 17811 templateParts 17812 }]) => (0,external_React_.createElement)(CategoryItem, { 17813 key: area, 17814 count: templateParts?.length, 17815 icon: (0,external_wp_editor_namespaceObject.getTemplatePartIcon)(area), 17816 label: label, 17817 id: area, 17818 type: TEMPLATE_PART_POST_TYPE, 17819 isActive: currentArea === area && currentType === TEMPLATE_PART_POST_TYPE 17820 })))); 17821 } 17822 function PatternCategoriesGroup({ 17823 categories, 17824 currentCategory, 17825 currentType 17826 }) { 17827 return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalItemGroup, { 17828 className: "edit-site-sidebar-navigation-screen-patterns__group" 17829 }, categories.map(category => (0,external_React_.createElement)(CategoryItem, { 17830 key: category.name, 17831 count: category.count, 17832 label: category.label, 17833 icon: library_file, 17834 id: category.name, 17835 type: "pattern", 17836 isActive: currentCategory === `$category.name}` && (currentType === PATTERN_TYPES.theme || currentType === PATTERN_TYPES.user) 17837 })))); 17838 } 17839 function SidebarNavigationScreenPatterns() { 17840 const isMobileViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium', '<'); 17841 const { 17842 categoryType, 17843 categoryId 17844 } = (0,external_wp_url_namespaceObject.getQueryArgs)(window.location.href); 17845 const currentCategory = categoryId || PATTERN_DEFAULT_CATEGORY; 17846 const currentType = categoryType || PATTERN_TYPES.theme; 17847 const { 17848 templatePartAreas, 17849 hasTemplateParts, 17850 isLoading 17851 } = useTemplatePartAreas(); 17852 const { 17853 patternCategories, 17854 hasPatterns 17855 } = usePatternCategories(); 17856 const isBlockBasedTheme = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).getCurrentTheme()?.is_block_theme, []); 17857 const isTemplatePartsMode = (0,external_wp_data_namespaceObject.useSelect)(select => { 17858 const settings = select(store_store).getSettings(); 17859 return !!settings.supportsTemplatePartsMode; 17860 }, []); 17861 const templatePartsLink = useLink({ 17862 path: '/wp_template_part/all', 17863 // If a classic theme that supports template parts accessed 17864 // the Patterns page directly, preserve that state in the URL. 17865 didAccessPatternsPage: !isBlockBasedTheme && isTemplatePartsMode ? 1 : undefined 17866 }); 17867 const footer = !isMobileViewport ? (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalItemGroup, null, (0,external_React_.createElement)(SidebarNavigationItem, { 17868 as: "a", 17869 href: "edit.php?post_type=wp_block", 17870 withChevron: true 17871 }, (0,external_wp_i18n_namespaceObject.__)('Manage all of my patterns')), (isBlockBasedTheme || isTemplatePartsMode) && (0,external_React_.createElement)(SidebarNavigationItem, { 17872 withChevron: true, 17873 ...templatePartsLink 17874 }, (0,external_wp_i18n_namespaceObject.__)('Manage all template parts'))) : undefined; 17875 return (0,external_React_.createElement)(SidebarNavigationScreen, { 17876 isRoot: !isBlockBasedTheme, 17877 title: (0,external_wp_i18n_namespaceObject.__)('Patterns'), 17878 description: (0,external_wp_i18n_namespaceObject.__)('Manage what patterns are available when editing the site.'), 17879 actions: (0,external_React_.createElement)(AddNewPattern, null), 17880 footer: footer, 17881 content: (0,external_React_.createElement)(external_React_.Fragment, null, isLoading && (0,external_wp_i18n_namespaceObject.__)('Loading patterns…'), !isLoading && (0,external_React_.createElement)(external_React_.Fragment, null, !hasTemplateParts && !hasPatterns && (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalItemGroup, { 17882 className: "edit-site-sidebar-navigation-screen-patterns__group" 17883 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalItem, null, (0,external_wp_i18n_namespaceObject.__)('No template parts or patterns found'))), hasPatterns && (0,external_React_.createElement)(PatternCategoriesGroup, { 17884 categories: patternCategories, 17885 currentCategory: currentCategory, 17886 currentType: currentType 17887 }), hasTemplateParts && (0,external_React_.createElement)(TemplatePartGroup, { 17888 areas: templatePartAreas, 17889 currentArea: currentCategory, 17890 currentType: currentType 17891 }))) 17892 }); 17893 } 17894 17895 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js 17896 /** 17897 * WordPress dependencies 17898 */ 17899 17900 17901 17902 17903 17904 /** 17905 * Internal dependencies 17906 */ 17907 17908 17909 17910 const { 17911 useLocation: use_init_edited_entity_from_url_useLocation 17912 } = unlock(external_wp_router_namespaceObject.privateApis); 17913 const postTypesWithoutParentTemplate = [constants_TEMPLATE_POST_TYPE, TEMPLATE_PART_POST_TYPE, NAVIGATION_POST_TYPE, PATTERN_TYPES.user]; 17914 function useResolveEditedEntityAndContext({ 17915 path, 17916 postId, 17917 postType 17918 }) { 17919 const { 17920 hasLoadedAllDependencies, 17921 homepageId, 17922 url, 17923 frontPageTemplateId 17924 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 17925 const { 17926 getSite, 17927 getUnstableBase, 17928 getEntityRecords 17929 } = select(external_wp_coreData_namespaceObject.store); 17930 const siteData = getSite(); 17931 const base = getUnstableBase(); 17932 const templates = getEntityRecords('postType', constants_TEMPLATE_POST_TYPE, { 17933 per_page: -1 17934 }); 17935 let _frontPateTemplateId; 17936 if (templates) { 17937 const frontPageTemplate = templates.find(t => t.slug === 'front-page'); 17938 _frontPateTemplateId = frontPageTemplate ? frontPageTemplate.id : false; 17939 } 17940 return { 17941 hasLoadedAllDependencies: !!base && !!siteData, 17942 homepageId: siteData?.show_on_front === 'page' && ['number', 'string'].includes(typeof siteData.page_on_front) ? siteData.page_on_front.toString() : null, 17943 url: base?.home, 17944 frontPageTemplateId: _frontPateTemplateId 17945 }; 17946 }, []); 17947 17948 /** 17949 * This is a hook that recreates the logic to resolve a template for a given WordPress postID postTypeId 17950 * in order to match the frontend as closely as possible in the site editor. 17951 * 17952 * It is not possible to rely on the server logic because there maybe unsaved changes that impact the template resolution. 17953 */ 17954 const resolvedTemplateId = (0,external_wp_data_namespaceObject.useSelect)(select => { 17955 // If we're rendering a post type that doesn't have a template 17956 // no need to resolve its template. 17957 if (postTypesWithoutParentTemplate.includes(postType)) { 17958 return undefined; 17959 } 17960 const { 17961 getEditedEntityRecord, 17962 getEntityRecords, 17963 getDefaultTemplateId, 17964 __experimentalGetTemplateForLink 17965 } = select(external_wp_coreData_namespaceObject.store); 17966 function resolveTemplateForPostTypeAndId(postTypeToResolve, postIdToResolve) { 17967 // For the front page, we always use the front page template if existing. 17968 if (postTypeToResolve === 'page' && homepageId === postIdToResolve) { 17969 // We're still checking whether the front page template exists. 17970 // Don't resolve the template yet. 17971 if (frontPageTemplateId === undefined) { 17972 return undefined; 17973 } 17974 if (!!frontPageTemplateId) { 17975 return frontPageTemplateId; 17976 } 17977 } 17978 const editedEntity = getEditedEntityRecord('postType', postTypeToResolve, postIdToResolve); 17979 if (!editedEntity) { 17980 return undefined; 17981 } 17982 // First see if the post/page has an assigned template and fetch it. 17983 const currentTemplateSlug = editedEntity.template; 17984 if (currentTemplateSlug) { 17985 const currentTemplate = getEntityRecords('postType', constants_TEMPLATE_POST_TYPE, { 17986 per_page: -1 17987 })?.find(({ 17988 slug 17989 }) => slug === currentTemplateSlug); 17990 if (currentTemplate) { 17991 return currentTemplate.id; 17992 } 17993 } 17994 // If no template is assigned, use the default template. 17995 let slugToCheck; 17996 // In `draft` status we might not have a slug available, so we use the `single` 17997 // post type templates slug(ex page, single-post, single-product etc..). 17998 // Pages do not need the `single` prefix in the slug to be prioritized 17999 // through template hierarchy. 18000 if (editedEntity.slug) { 18001 slugToCheck = postTypeToResolve === 'page' ? `$postTypeToResolve}-$editedEntity.slug}` : `single-$postTypeToResolve}-$editedEntity.slug}`; 18002 } else { 18003 slugToCheck = postTypeToResolve === 'page' ? 'page' : `single-$postTypeToResolve}`; 18004 } 18005 return getDefaultTemplateId({ 18006 slug: slugToCheck 18007 }); 18008 } 18009 if (!hasLoadedAllDependencies) { 18010 return undefined; 18011 } 18012 18013 // If we're rendering a specific page, post... we need to resolve its template. 18014 if (postType && postId) { 18015 return resolveTemplateForPostTypeAndId(postType, postId); 18016 } 18017 18018 // Some URLs in list views are different 18019 if (path === '/pages' && postId) { 18020 return resolveTemplateForPostTypeAndId('page', postId); 18021 } 18022 18023 // If we're rendering the home page, and we have a static home page, resolve its template. 18024 if (homepageId) { 18025 return resolveTemplateForPostTypeAndId('page', homepageId); 18026 } 18027 18028 // If we're not rendering a specific page, use the front page template. 18029 if (url) { 18030 const template = __experimentalGetTemplateForLink(url); 18031 return template?.id; 18032 } 18033 }, [homepageId, hasLoadedAllDependencies, url, postId, postType, path, frontPageTemplateId]); 18034 const context = (0,external_wp_element_namespaceObject.useMemo)(() => { 18035 if (postTypesWithoutParentTemplate.includes(postType)) { 18036 return {}; 18037 } 18038 if (postType && postId) { 18039 return { 18040 postType, 18041 postId 18042 }; 18043 } 18044 18045 // Some URLs in list views are different 18046 if (path === '/pages' && postId) { 18047 return { 18048 postType: 'page', 18049 postId 18050 }; 18051 } 18052 if (homepageId) { 18053 return { 18054 postType: 'page', 18055 postId: homepageId 18056 }; 18057 } 18058 return {}; 18059 }, [homepageId, postType, postId, path]); 18060 if (path === '/wp_template/all' && postId) { 18061 return { 18062 isReady: true, 18063 postType: 'wp_template', 18064 postId, 18065 context 18066 }; 18067 } 18068 if (path === '/wp_template_part/all' && postId) { 18069 return { 18070 isReady: true, 18071 postType: 'wp_template_part', 18072 postId, 18073 context 18074 }; 18075 } 18076 if (postTypesWithoutParentTemplate.includes(postType)) { 18077 return { 18078 isReady: true, 18079 postType, 18080 postId, 18081 context 18082 }; 18083 } 18084 if (hasLoadedAllDependencies) { 18085 return { 18086 isReady: resolvedTemplateId !== undefined, 18087 postType: constants_TEMPLATE_POST_TYPE, 18088 postId: resolvedTemplateId, 18089 context 18090 }; 18091 } 18092 return { 18093 isReady: false 18094 }; 18095 } 18096 function useInitEditedEntityFromURL() { 18097 const { 18098 params = {} 18099 } = use_init_edited_entity_from_url_useLocation(); 18100 const { 18101 postType, 18102 postId, 18103 context, 18104 isReady 18105 } = useResolveEditedEntityAndContext(params); 18106 const { 18107 setEditedEntity 18108 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store); 18109 (0,external_wp_element_namespaceObject.useEffect)(() => { 18110 if (isReady) { 18111 setEditedEntity(postType, postId, context); 18112 } 18113 }, [isReady, postType, postId, context, setEditedEntity]); 18114 } 18115 18116 ;// CONCATENATED MODULE: ./node_modules/upper-case-first/dist.es2015/index.js 18117 /** 18118 * Upper case the first character of an input string. 18119 */ 18120 function upperCaseFirst(input) { 18121 return input.charAt(0).toUpperCase() + input.substr(1); 18122 } 18123 18124 ;// CONCATENATED MODULE: ./node_modules/sentence-case/dist.es2015/index.js 18125 18126 18127 18128 function sentenceCaseTransform(input, index) { 18129 var result = input.toLowerCase(); 18130 if (index === 0) 18131 return upperCaseFirst(result); 18132 return result; 18133 } 18134 function sentenceCase(input, options) { 18135 if (options === void 0) { options = {}; } 18136 return noCase(input, __assign({ delimiter: " ", transform: sentenceCaseTransform }, options)); 18137 } 18138 18139 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/chevron-up.js 18140 18141 /** 18142 * WordPress dependencies 18143 */ 18144 18145 const chevronUp = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { 18146 viewBox: "0 0 24 24", 18147 xmlns: "http://www.w3.org/2000/svg" 18148 }, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 18149 d: "M6.5 12.4L12 8l5.5 4.4-.9 1.2L12 10l-4.5 3.6-1-1.2z" 18150 })); 18151 /* harmony default export */ const chevron_up = (chevronUp); 18152 18153 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/chevron-down.js 18154 18155 /** 18156 * WordPress dependencies 18157 */ 18158 18159 const chevronDown = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { 18160 viewBox: "0 0 24 24", 18161 xmlns: "http://www.w3.org/2000/svg" 18162 }, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 18163 d: "M17.5 11.6L12 16l-5.5-4.4.9-1.2L12 14l4.5-3.6 1 1.2z" 18164 })); 18165 /* harmony default export */ const chevron_down = (chevronDown); 18166 18167 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sync-state-with-url/use-sync-path-with-url.js 18168 /** 18169 * WordPress dependencies 18170 */ 18171 18172 18173 18174 18175 /** 18176 * Internal dependencies 18177 */ 18178 18179 18180 const { 18181 useLocation: use_sync_path_with_url_useLocation, 18182 useHistory: use_sync_path_with_url_useHistory 18183 } = unlock(external_wp_router_namespaceObject.privateApis); 18184 function getPathFromURL(urlParams) { 18185 var _urlParams$path; 18186 let path = (_urlParams$path = urlParams?.path) !== null && _urlParams$path !== void 0 ? _urlParams$path : '/'; 18187 18188 // Compute the navigator path based on the URL params. 18189 if (urlParams?.postType && urlParams?.postId) { 18190 switch (urlParams.postType) { 18191 case PATTERN_TYPES.user: 18192 case constants_TEMPLATE_POST_TYPE: 18193 case TEMPLATE_PART_POST_TYPE: 18194 case 'page': 18195 path = `/$encodeURIComponent(urlParams.postType)}/$encodeURIComponent(urlParams.postId)}`; 18196 break; 18197 default: 18198 path = `/navigation/$encodeURIComponent(urlParams.postType)}/$encodeURIComponent(urlParams.postId)}`; 18199 } 18200 } 18201 return path; 18202 } 18203 function isSubset(subset, superset) { 18204 return Object.entries(subset).every(([key, value]) => { 18205 return superset[key] === value; 18206 }); 18207 } 18208 function useSyncPathWithURL() { 18209 const history = use_sync_path_with_url_useHistory(); 18210 const { 18211 params: urlParams 18212 } = use_sync_path_with_url_useLocation(); 18213 const { 18214 location: navigatorLocation, 18215 params: navigatorParams, 18216 goTo 18217 } = (0,external_wp_components_namespaceObject.__experimentalUseNavigator)(); 18218 const isMounting = (0,external_wp_element_namespaceObject.useRef)(true); 18219 (0,external_wp_element_namespaceObject.useEffect)(() => { 18220 // The navigatorParams are only initially filled properly when the 18221 // navigator screens mount. so we ignore the first synchronisation. 18222 if (isMounting.current) { 18223 isMounting.current = false; 18224 return; 18225 } 18226 function updateUrlParams(newUrlParams) { 18227 if (isSubset(newUrlParams, urlParams)) { 18228 return; 18229 } 18230 const updatedParams = { 18231 ...urlParams, 18232 ...newUrlParams 18233 }; 18234 history.push(updatedParams); 18235 } 18236 if (navigatorParams?.postType && navigatorParams?.postId) { 18237 updateUrlParams({ 18238 postType: navigatorParams?.postType, 18239 postId: navigatorParams?.postId, 18240 path: undefined, 18241 layout: undefined 18242 }); 18243 } else if (navigatorLocation.path.startsWith('/page/') && navigatorParams?.postId) { 18244 updateUrlParams({ 18245 postType: 'page', 18246 postId: navigatorParams?.postId, 18247 path: undefined, 18248 layout: undefined 18249 }); 18250 } else if (navigatorLocation.path === '/patterns') { 18251 updateUrlParams({ 18252 postType: undefined, 18253 postId: undefined, 18254 canvas: undefined, 18255 path: navigatorLocation.path 18256 }); 18257 } else if (navigatorLocation.path === '/wp_template/all' && !window?.__experimentalAdminViews) { 18258 // When the experiment is disabled, we only support table layout. 18259 // Clear it out from the URL, so layouts other than table cannot be accessed. 18260 updateUrlParams({ 18261 postType: undefined, 18262 categoryType: undefined, 18263 categoryId: undefined, 18264 path: navigatorLocation.path, 18265 layout: undefined 18266 }); 18267 } else if ( 18268 // These sidebar paths are special in the sense that the url in these pages may or may not have a postId and we need to retain it if it has. 18269 // The "type" property should be kept as well. 18270 navigatorLocation.path === '/pages' && window?.__experimentalAdminViews || navigatorLocation.path === '/wp_template/all' && window?.__experimentalAdminViews || navigatorLocation.path === '/wp_template_part/all' && window?.__experimentalAdminViews) { 18271 updateUrlParams({ 18272 postType: undefined, 18273 categoryType: undefined, 18274 categoryId: undefined, 18275 path: navigatorLocation.path 18276 }); 18277 } else { 18278 updateUrlParams({ 18279 postType: undefined, 18280 postId: undefined, 18281 categoryType: undefined, 18282 categoryId: undefined, 18283 layout: undefined, 18284 path: navigatorLocation.path === '/' ? undefined : navigatorLocation.path 18285 }); 18286 } 18287 }, 18288 // Trigger only when navigator changes to prevent infinite loops. 18289 // eslint-disable-next-line react-hooks/exhaustive-deps 18290 [navigatorLocation?.path, navigatorParams]); 18291 (0,external_wp_element_namespaceObject.useEffect)(() => { 18292 const path = getPathFromURL(urlParams); 18293 if (navigatorLocation.path !== path) { 18294 goTo(path); 18295 } 18296 }, 18297 // Trigger only when URL changes to prevent infinite loops. 18298 // eslint-disable-next-line react-hooks/exhaustive-deps 18299 [urlParams]); 18300 } 18301 18302 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sidebar-navigation-screen-navigation-menus/leaf-more-menu.js 18303 18304 /** 18305 * WordPress dependencies 18306 */ 18307 18308 18309 18310 18311 18312 18313 18314 18315 const POPOVER_PROPS = { 18316 className: 'block-editor-block-settings-menu__popover', 18317 placement: 'bottom-start' 18318 }; 18319 18320 /** 18321 * Internal dependencies 18322 */ 18323 18324 18325 18326 const { 18327 useLocation: leaf_more_menu_useLocation, 18328 useHistory: leaf_more_menu_useHistory 18329 } = unlock(external_wp_router_namespaceObject.privateApis); 18330 function LeafMoreMenu(props) { 18331 const location = leaf_more_menu_useLocation(); 18332 const history = leaf_more_menu_useHistory(); 18333 const { 18334 block 18335 } = props; 18336 const { 18337 clientId 18338 } = block; 18339 const { 18340 moveBlocksDown, 18341 moveBlocksUp, 18342 removeBlocks 18343 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store); 18344 const removeLabel = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: block name */ 18345 (0,external_wp_i18n_namespaceObject.__)('Remove %s'), (0,external_wp_blockEditor_namespaceObject.BlockTitle)({ 18346 clientId, 18347 maximumLength: 25 18348 })); 18349 const goToLabel = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: block name */ 18350 (0,external_wp_i18n_namespaceObject.__)('Go to %s'), (0,external_wp_blockEditor_namespaceObject.BlockTitle)({ 18351 clientId, 18352 maximumLength: 25 18353 })); 18354 const rootClientId = (0,external_wp_data_namespaceObject.useSelect)(select => { 18355 const { 18356 getBlockRootClientId 18357 } = select(external_wp_blockEditor_namespaceObject.store); 18358 return getBlockRootClientId(clientId); 18359 }, [clientId]); 18360 const onGoToPage = (0,external_wp_element_namespaceObject.useCallback)(selectedBlock => { 18361 const { 18362 attributes, 18363 name 18364 } = selectedBlock; 18365 if (attributes.kind === 'post-type' && attributes.id && attributes.type && history) { 18366 history.push({ 18367 postType: attributes.type, 18368 postId: attributes.id, 18369 ...(isPreviewingTheme() && { 18370 wp_theme_preview: currentlyPreviewingTheme() 18371 }) 18372 }, { 18373 backPath: getPathFromURL(location.params) 18374 }); 18375 } 18376 if (name === 'core/page-list-item' && attributes.id && history) { 18377 history.push({ 18378 postType: 'page', 18379 postId: attributes.id, 18380 ...(isPreviewingTheme() && { 18381 wp_theme_preview: currentlyPreviewingTheme() 18382 }) 18383 }, { 18384 backPath: getPathFromURL(location.params) 18385 }); 18386 } 18387 }, [history]); 18388 return (0,external_React_.createElement)(external_wp_components_namespaceObject.DropdownMenu, { 18389 icon: more_vertical, 18390 label: (0,external_wp_i18n_namespaceObject.__)('Options'), 18391 className: "block-editor-block-settings-menu", 18392 popoverProps: POPOVER_PROPS, 18393 noIcons: true, 18394 ...props 18395 }, ({ 18396 onClose 18397 }) => (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.MenuGroup, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.MenuItem, { 18398 icon: chevron_up, 18399 onClick: () => { 18400 moveBlocksUp([clientId], rootClientId); 18401 onClose(); 18402 } 18403 }, (0,external_wp_i18n_namespaceObject.__)('Move up')), (0,external_React_.createElement)(external_wp_components_namespaceObject.MenuItem, { 18404 icon: chevron_down, 18405 onClick: () => { 18406 moveBlocksDown([clientId], rootClientId); 18407 onClose(); 18408 } 18409 }, (0,external_wp_i18n_namespaceObject.__)('Move down')), block.attributes?.type === 'page' && block.attributes?.id && (0,external_React_.createElement)(external_wp_components_namespaceObject.MenuItem, { 18410 onClick: () => { 18411 onGoToPage(block); 18412 onClose(); 18413 } 18414 }, goToLabel)), (0,external_React_.createElement)(external_wp_components_namespaceObject.MenuGroup, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.MenuItem, { 18415 onClick: () => { 18416 removeBlocks([clientId], false); 18417 onClose(); 18418 } 18419 }, removeLabel)))); 18420 } 18421 18422 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sidebar-navigation-screen-navigation-menus/navigation-menu-content.js 18423 18424 /** 18425 * WordPress dependencies 18426 */ 18427 18428 18429 18430 18431 18432 18433 /** 18434 * Internal dependencies 18435 */ 18436 18437 18438 const { 18439 PrivateListView 18440 } = unlock(external_wp_blockEditor_namespaceObject.privateApis); 18441 18442 // Needs to be kept in sync with the query used at packages/block-library/src/page-list/edit.js. 18443 const MAX_PAGE_COUNT = 100; 18444 const PAGES_QUERY = ['postType', 'page', { 18445 per_page: MAX_PAGE_COUNT, 18446 _fields: ['id', 'link', 'menu_order', 'parent', 'title', 'type'], 18447 // TODO: When https://core.trac.wordpress.org/ticket/39037 REST API support for multiple orderby 18448 // values is resolved, update 'orderby' to [ 'menu_order', 'post_title' ] to provide a consistent 18449 // sort. 18450 orderby: 'menu_order', 18451 order: 'asc' 18452 }]; 18453 function NavigationMenuContent({ 18454 rootClientId 18455 }) { 18456 const { 18457 listViewRootClientId, 18458 isLoading 18459 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 18460 const { 18461 areInnerBlocksControlled, 18462 getBlockName, 18463 getBlockCount, 18464 getBlockOrder 18465 } = select(external_wp_blockEditor_namespaceObject.store); 18466 const { 18467 isResolving 18468 } = select(external_wp_coreData_namespaceObject.store); 18469 const blockClientIds = getBlockOrder(rootClientId); 18470 const hasOnlyPageListBlock = blockClientIds.length === 1 && getBlockName(blockClientIds[0]) === 'core/page-list'; 18471 const pageListHasBlocks = hasOnlyPageListBlock && getBlockCount(blockClientIds[0]) > 0; 18472 const isLoadingPages = isResolving('getEntityRecords', PAGES_QUERY); 18473 return { 18474 listViewRootClientId: pageListHasBlocks ? blockClientIds[0] : rootClientId, 18475 // This is a small hack to wait for the navigation block 18476 // to actually load its inner blocks. 18477 isLoading: !areInnerBlocksControlled(rootClientId) || isLoadingPages 18478 }; 18479 }, [rootClientId]); 18480 const { 18481 replaceBlock, 18482 __unstableMarkNextChangeAsNotPersistent 18483 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store); 18484 const offCanvasOnselect = (0,external_wp_element_namespaceObject.useCallback)(block => { 18485 if (block.name === 'core/navigation-link' && !block.attributes.url) { 18486 __unstableMarkNextChangeAsNotPersistent(); 18487 replaceBlock(block.clientId, (0,external_wp_blocks_namespaceObject.createBlock)('core/navigation-link', block.attributes)); 18488 } 18489 }, [__unstableMarkNextChangeAsNotPersistent, replaceBlock]); 18490 18491 // The hidden block is needed because it makes block edit side effects trigger. 18492 // For example a navigation page list load its items has an effect on edit to load its items. 18493 return (0,external_React_.createElement)(external_React_.Fragment, null, !isLoading && (0,external_React_.createElement)(PrivateListView, { 18494 rootClientId: listViewRootClientId, 18495 onSelect: offCanvasOnselect, 18496 blockSettingsMenu: LeafMoreMenu, 18497 showAppender: false 18498 }), (0,external_React_.createElement)("div", { 18499 className: "edit-site-sidebar-navigation-screen-navigation-menus__helper-block-editor" 18500 }, (0,external_React_.createElement)(external_wp_blockEditor_namespaceObject.BlockList, null))); 18501 } 18502 18503 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sidebar-navigation-screen-navigation-menu/navigation-menu-editor.js 18504 18505 /** 18506 * WordPress dependencies 18507 */ 18508 18509 18510 18511 18512 18513 /** 18514 * Internal dependencies 18515 */ 18516 18517 18518 18519 const navigation_menu_editor_noop = () => {}; 18520 function NavigationMenuEditor({ 18521 navigationMenuId 18522 }) { 18523 const { 18524 storedSettings 18525 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 18526 const { 18527 getSettings 18528 } = unlock(select(store_store)); 18529 return { 18530 storedSettings: getSettings() 18531 }; 18532 }, []); 18533 const blocks = (0,external_wp_element_namespaceObject.useMemo)(() => { 18534 if (!navigationMenuId) { 18535 return []; 18536 } 18537 return [(0,external_wp_blocks_namespaceObject.createBlock)('core/navigation', { 18538 ref: navigationMenuId 18539 })]; 18540 }, [navigationMenuId]); 18541 if (!navigationMenuId || !blocks?.length) { 18542 return null; 18543 } 18544 return (0,external_React_.createElement)(external_wp_blockEditor_namespaceObject.BlockEditorProvider, { 18545 settings: storedSettings, 18546 value: blocks, 18547 onChange: navigation_menu_editor_noop, 18548 onInput: navigation_menu_editor_noop 18549 }, (0,external_React_.createElement)("div", { 18550 className: "edit-site-sidebar-navigation-screen-navigation-menus__content" 18551 }, (0,external_React_.createElement)(NavigationMenuContent, { 18552 rootClientId: blocks[0].clientId 18553 }))); 18554 } 18555 18556 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sidebar-navigation-screen-pattern/use-navigation-menu-title.js 18557 /** 18558 * WordPress dependencies 18559 */ 18560 18561 18562 18563 /** 18564 * Internal dependencies 18565 */ 18566 18567 function useNavigationMenuTitle(id) { 18568 return (0,external_wp_data_namespaceObject.useSelect)(select => { 18569 if (!id) { 18570 return undefined; 18571 } 18572 const editedRecord = select(external_wp_coreData_namespaceObject.store).getEditedEntityRecord('postType', NAVIGATION_POST_TYPE, id); 18573 18574 // Do not display a 'trashed' navigation menu. 18575 return editedRecord.status === 'trash' ? undefined : editedRecord.title; 18576 }, [id]); 18577 } 18578 18579 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sidebar-navigation-screen-pattern/template-part-navigation-menu.js 18580 18581 /** 18582 * WordPress dependencies 18583 */ 18584 18585 18586 18587 /** 18588 * Internal dependencies 18589 */ 18590 18591 18592 function TemplatePartNavigationMenu({ 18593 id 18594 }) { 18595 const title = useNavigationMenuTitle(id); 18596 if (!id || title === undefined) { 18597 return null; 18598 } 18599 return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHeading, { 18600 className: "edit-site-sidebar-navigation-screen-template-part-navigation-menu__title", 18601 size: "11", 18602 upperCase: true, 18603 weight: 500 18604 }, title || (0,external_wp_i18n_namespaceObject.__)('Navigation')), (0,external_React_.createElement)(NavigationMenuEditor, { 18605 navigationMenuId: id 18606 })); 18607 } 18608 18609 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sidebar-navigation-screen-pattern/template-part-navigation-menu-list-item.js 18610 18611 /** 18612 * WordPress dependencies 18613 */ 18614 18615 18616 /** 18617 * Internal dependencies 18618 */ 18619 18620 18621 18622 18623 function TemplatePartNavigationMenuListItem({ 18624 id 18625 }) { 18626 const title = useNavigationMenuTitle(id); 18627 const linkInfo = useLink({ 18628 postId: id, 18629 postType: NAVIGATION_POST_TYPE 18630 }); 18631 if (!id || title === undefined) { 18632 return null; 18633 } 18634 return (0,external_React_.createElement)(SidebarNavigationItem, { 18635 withChevron: true, 18636 ...linkInfo 18637 }, title || (0,external_wp_i18n_namespaceObject.__)('(no title)')); 18638 } 18639 18640 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sidebar-navigation-screen-pattern/template-part-navigation-menu-list.js 18641 18642 /** 18643 * WordPress dependencies 18644 */ 18645 18646 /** 18647 * Internal dependencies 18648 */ 18649 18650 function TemplatePartNavigationMenuList({ 18651 menus 18652 }) { 18653 return (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalItemGroup, { 18654 className: "edit-site-sidebar-navigation-screen-template-part-navigation-menu-list" 18655 }, menus.map(menuId => (0,external_React_.createElement)(TemplatePartNavigationMenuListItem, { 18656 key: menuId, 18657 id: menuId 18658 }))); 18659 } 18660 18661 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sidebar-navigation-screen-pattern/template-part-navigation-menus.js 18662 18663 /** 18664 * WordPress dependencies 18665 */ 18666 18667 18668 /** 18669 * Internal dependencies 18670 */ 18671 18672 18673 function TemplatePartNavigationMenus({ 18674 menus 18675 }) { 18676 if (!menus.length) return null; 18677 18678 // if there is a single menu then render TemplatePartNavigationMenu 18679 if (menus.length === 1) { 18680 return (0,external_React_.createElement)(TemplatePartNavigationMenu, { 18681 id: menus[0] 18682 }); 18683 } 18684 18685 // if there are multiple menus then render TemplatePartNavigationMenuList 18686 return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHeading, { 18687 className: "edit-site-sidebar-navigation-screen-template-part-navigation-menu__title", 18688 size: "11", 18689 upperCase: true, 18690 weight: 500 18691 }, (0,external_wp_i18n_namespaceObject.__)('Navigation')), (0,external_React_.createElement)(TemplatePartNavigationMenuList, { 18692 menus: menus 18693 })); 18694 } 18695 18696 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sidebar-navigation-screen-pattern/use-navigation-menu-content.js 18697 18698 /** 18699 * WordPress dependencies 18700 */ 18701 18702 18703 /** 18704 * Internal dependencies 18705 */ 18706 18707 18708 18709 function getBlocksFromRecord(record) { 18710 if (record?.blocks) { 18711 return record?.blocks; 18712 } 18713 return record?.content && typeof record.content !== 'function' ? (0,external_wp_blocks_namespaceObject.parse)(record.content) : []; 18714 } 18715 18716 /** 18717 * Retrieves a list of specific blocks from a given tree of blocks. 18718 * 18719 * @param {string} targetBlockType The name of the block type to find. 18720 * @param {Array} blocks A list of blocks from a template part entity. 18721 * 18722 * @return {Array} A list of any navigation blocks found in the blocks. 18723 */ 18724 function getBlocksOfTypeFromBlocks(targetBlockType, blocks) { 18725 if (!targetBlockType || !blocks?.length) { 18726 return []; 18727 } 18728 const findInBlocks = _blocks => { 18729 if (!_blocks) { 18730 return []; 18731 } 18732 const navigationBlocks = []; 18733 for (const block of _blocks) { 18734 if (block.name === targetBlockType) { 18735 navigationBlocks.push(block); 18736 } 18737 if (block?.innerBlocks) { 18738 const innerNavigationBlocks = findInBlocks(block.innerBlocks); 18739 if (innerNavigationBlocks.length) { 18740 navigationBlocks.push(...innerNavigationBlocks); 18741 } 18742 } 18743 } 18744 return navigationBlocks; 18745 }; 18746 return findInBlocks(blocks); 18747 } 18748 function useNavigationMenuContent(postType, postId) { 18749 const { 18750 record 18751 } = useEditedEntityRecord(postType, postId); 18752 18753 // Only managing navigation menus in template parts is supported 18754 // to match previous behaviour. This could potentially be expanded 18755 // to patterns as well. 18756 if (postType !== TEMPLATE_PART_POST_TYPE) { 18757 return; 18758 } 18759 const blocks = getBlocksFromRecord(record); 18760 const navigationBlocks = getBlocksOfTypeFromBlocks('core/navigation', blocks); 18761 if (!navigationBlocks.length) { 18762 return; 18763 } 18764 const navigationMenuIds = navigationBlocks?.map(block => block.attributes.ref); 18765 18766 // Dedupe the Navigation blocks, as you can have multiple navigation blocks in the template. 18767 // Also, filter out undefined values, as blocks don't have an id when initially added. 18768 const uniqueNavigationMenuIds = [...new Set(navigationMenuIds)].filter(menuId => menuId); 18769 if (!uniqueNavigationMenuIds?.length) { 18770 return; 18771 } 18772 return (0,external_React_.createElement)(TemplatePartNavigationMenus, { 18773 menus: uniqueNavigationMenuIds 18774 }); 18775 } 18776 18777 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sidebar-navigation-screen-pattern/use-pattern-details.js 18778 18779 /** 18780 * External dependencies 18781 */ 18782 18783 18784 /** 18785 * WordPress dependencies 18786 */ 18787 18788 18789 18790 18791 18792 /** 18793 * Internal dependencies 18794 */ 18795 18796 18797 18798 18799 18800 18801 function usePatternDetails(postType, postId) { 18802 const { 18803 getDescription, 18804 getTitle, 18805 record 18806 } = useEditedEntityRecord(postType, postId); 18807 const templatePartAreas = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_editor_namespaceObject.store).__experimentalGetDefaultTemplatePartAreas(), []); 18808 const { 18809 currentTheme, 18810 userPatternCategories 18811 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 18812 const { 18813 getCurrentTheme, 18814 getUserPatternCategories 18815 } = select(external_wp_coreData_namespaceObject.store); 18816 return { 18817 currentTheme: getCurrentTheme(), 18818 userPatternCategories: getUserPatternCategories() 18819 }; 18820 }, []); 18821 const addedBy = useAddedBy(postType, postId); 18822 const isAddedByActiveTheme = addedBy.type === 'theme' && record.theme === currentTheme?.stylesheet; 18823 const title = getTitle(); 18824 let description = getDescription(); 18825 if (!description && addedBy.text) { 18826 description = postType === PATTERN_TYPES.user ? (0,external_wp_i18n_namespaceObject.sprintf)( 18827 // translators: %s: pattern title e.g: "Header". 18828 (0,external_wp_i18n_namespaceObject.__)('This is the %s pattern.'), getTitle()) : (0,external_wp_i18n_namespaceObject.sprintf)( 18829 // translators: %s: template part title e.g: "Header". 18830 (0,external_wp_i18n_namespaceObject.__)('This is the %s template part.'), getTitle()); 18831 } 18832 if (!description && postType === PATTERN_TYPES.user && record?.title) { 18833 description = (0,external_wp_i18n_namespaceObject.sprintf)( 18834 // translators: %s: user created pattern title e.g. "Footer". 18835 (0,external_wp_i18n_namespaceObject.__)('This is the %s pattern.'), record.title); 18836 } 18837 const footer = record?.modified ? (0,external_React_.createElement)(SidebarNavigationScreenDetailsFooter, { 18838 record: record 18839 }) : null; 18840 const details = []; 18841 if (postType === PATTERN_TYPES.user || postType === TEMPLATE_PART_POST_TYPE) { 18842 details.push({ 18843 label: (0,external_wp_i18n_namespaceObject.__)('Syncing'), 18844 value: record.wp_pattern_sync_status === PATTERN_SYNC_TYPES.unsynced ? (0,external_wp_i18n_namespaceObject._x)('Not synced', 'Text that indicates that the pattern is not synchronized') : (0,external_wp_i18n_namespaceObject._x)('Synced', 'Text that indicates that the pattern is synchronized') 18845 }); 18846 if (record.wp_pattern_category?.length === 0) { 18847 details.push({ 18848 label: (0,external_wp_i18n_namespaceObject.__)('Categories'), 18849 value: (0,external_wp_i18n_namespaceObject.__)('Uncategorized') 18850 }); 18851 } 18852 if (record.wp_pattern_category?.length > 0) { 18853 const patternCategories = new Map(); 18854 userPatternCategories.forEach(userCategory => patternCategories.set(userCategory.id, userCategory)); 18855 const categories = record.wp_pattern_category.filter(category => patternCategories.get(category)).map(category => patternCategories.get(category).label); 18856 details.push({ 18857 label: (0,external_wp_i18n_namespaceObject.__)('Categories'), 18858 value: categories.length > 0 ? categories.join(', ') : '' 18859 }); 18860 } 18861 } 18862 if (postType === TEMPLATE_PART_POST_TYPE) { 18863 const templatePartArea = templatePartAreas.find(area => area.area === record.area); 18864 let areaDetailValue = templatePartArea?.label; 18865 if (!areaDetailValue) { 18866 areaDetailValue = record.area ? (0,external_wp_i18n_namespaceObject.sprintf)( 18867 // translators: %s: Sentenced cased template part area e.g: "My custom area". 18868 (0,external_wp_i18n_namespaceObject.__)('%s (removed)'), sentenceCase(record.area)) : (0,external_wp_i18n_namespaceObject.__)('None'); 18869 } 18870 details.push({ 18871 label: (0,external_wp_i18n_namespaceObject.__)('Area'), 18872 value: areaDetailValue 18873 }); 18874 } 18875 if (postType === TEMPLATE_PART_POST_TYPE && addedBy.text && !isAddedByActiveTheme) { 18876 details.push({ 18877 label: (0,external_wp_i18n_namespaceObject.__)('Added by'), 18878 value: (0,external_React_.createElement)("span", { 18879 className: "edit-site-sidebar-navigation-screen-pattern__added-by-description-author" 18880 }, addedBy.text) 18881 }); 18882 } 18883 if (postType === TEMPLATE_PART_POST_TYPE && addedBy.text && (record.origin === TEMPLATE_ORIGINS.plugin || record.has_theme_file === true)) { 18884 details.push({ 18885 label: (0,external_wp_i18n_namespaceObject.__)('Customized'), 18886 value: (0,external_React_.createElement)("span", { 18887 className: "edit-site-sidebar-navigation-screen-pattern__added-by-description-customized" 18888 }, addedBy.isCustomized ? (0,external_wp_i18n_namespaceObject.__)('Yes') : (0,external_wp_i18n_namespaceObject.__)('No')) 18889 }); 18890 } 18891 const content = (0,external_React_.createElement)(external_React_.Fragment, null, useNavigationMenuContent(postType, postId), !!details.length && (0,external_React_.createElement)(SidebarNavigationScreenDetailsPanel, { 18892 spacing: 5, 18893 title: (0,external_wp_i18n_namespaceObject.__)('Details') 18894 }, details.map(({ 18895 label, 18896 value 18897 }) => (0,external_React_.createElement)(SidebarNavigationScreenDetailsPanelRow, { 18898 key: label 18899 }, (0,external_React_.createElement)(SidebarNavigationScreenDetailsPanelLabel, null, label), (0,external_React_.createElement)(SidebarNavigationScreenDetailsPanelValue, null, value))))); 18900 return { 18901 title, 18902 description, 18903 content, 18904 footer 18905 }; 18906 } 18907 18908 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sidebar-navigation-screen-pattern/index.js 18909 18910 /** 18911 * WordPress dependencies 18912 */ 18913 18914 18915 18916 18917 18918 18919 /** 18920 * Internal dependencies 18921 */ 18922 18923 18924 18925 18926 18927 18928 18929 18930 function SidebarNavigationScreenPattern() { 18931 const navigator = (0,external_wp_components_namespaceObject.__experimentalUseNavigator)(); 18932 const { 18933 params: { 18934 postType, 18935 postId 18936 } 18937 } = navigator; 18938 const { 18939 categoryType 18940 } = (0,external_wp_url_namespaceObject.getQueryArgs)(window.location.href); 18941 const { 18942 setCanvasMode 18943 } = unlock((0,external_wp_data_namespaceObject.useDispatch)(store_store)); 18944 useInitEditedEntityFromURL(); 18945 const patternDetails = usePatternDetails(postType, postId); 18946 18947 // The absence of a category type in the query params for template parts 18948 // indicates the user has arrived at the template part via the "manage all" 18949 // page and the back button should return them to that list page. 18950 const backPath = !categoryType && postType === TEMPLATE_PART_POST_TYPE ? '/wp_template_part/all' : '/patterns'; 18951 return (0,external_React_.createElement)(SidebarNavigationScreen, { 18952 actions: (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(TemplateActions, { 18953 postType: postType, 18954 postId: postId, 18955 toggleProps: { 18956 as: SidebarButton 18957 }, 18958 onRemove: () => { 18959 navigator.goTo(backPath); 18960 } 18961 }), (0,external_React_.createElement)(SidebarButton, { 18962 onClick: () => setCanvasMode('edit'), 18963 label: (0,external_wp_i18n_namespaceObject.__)('Edit'), 18964 icon: library_pencil 18965 })), 18966 backPath: backPath, 18967 ...patternDetails 18968 }); 18969 } 18970 18971 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sidebar-navigation-screen-navigation-menus/constants.js 18972 // This requested is preloaded in `gutenberg_preload_navigation_posts`. 18973 // As unbounded queries are limited to 100 by `fetchAllMiddleware` 18974 // on apiFetch this query is limited to 100. 18975 // These parameters must be kept aligned with those in 18976 // lib/compat/wordpress-6.3/navigation-block-preloading.php 18977 // and 18978 // block-library/src/navigation/constants.js 18979 const PRELOADED_NAVIGATION_MENUS_QUERY = { 18980 per_page: 100, 18981 status: ['publish', 'draft'], 18982 order: 'desc', 18983 orderby: 'date' 18984 }; 18985 18986 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sidebar-navigation-screen-navigation-menu/rename-modal.js 18987 18988 /** 18989 * WordPress dependencies 18990 */ 18991 18992 18993 18994 const notEmptyString = testString => testString?.trim()?.length > 0; 18995 function RenameModal({ 18996 menuTitle, 18997 onClose, 18998 onSave 18999 }) { 19000 const [editedMenuTitle, setEditedMenuTitle] = (0,external_wp_element_namespaceObject.useState)(menuTitle); 19001 const titleHasChanged = editedMenuTitle !== menuTitle; 19002 const isEditedMenuTitleValid = titleHasChanged && notEmptyString(editedMenuTitle); 19003 return (0,external_React_.createElement)(external_wp_components_namespaceObject.Modal, { 19004 title: (0,external_wp_i18n_namespaceObject.__)('Rename'), 19005 onRequestClose: onClose 19006 }, (0,external_React_.createElement)("form", { 19007 className: "sidebar-navigation__rename-modal-form" 19008 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { 19009 spacing: "3" 19010 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.TextControl, { 19011 __nextHasNoMarginBottom: true, 19012 __next40pxDefaultSize: true, 19013 value: editedMenuTitle, 19014 placeholder: (0,external_wp_i18n_namespaceObject.__)('Navigation title'), 19015 onChange: setEditedMenuTitle 19016 }), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { 19017 justify: "right" 19018 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 19019 __next40pxDefaultSize: true, 19020 variant: "tertiary", 19021 onClick: onClose 19022 }, (0,external_wp_i18n_namespaceObject.__)('Cancel')), (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 19023 __next40pxDefaultSize: true, 19024 disabled: !isEditedMenuTitleValid, 19025 variant: "primary", 19026 type: "submit", 19027 onClick: e => { 19028 e.preventDefault(); 19029 if (!isEditedMenuTitleValid) { 19030 return; 19031 } 19032 onSave({ 19033 title: editedMenuTitle 19034 }); 19035 19036 // Immediate close avoids ability to hit save multiple times. 19037 onClose(); 19038 } 19039 }, (0,external_wp_i18n_namespaceObject.__)('Save')))))); 19040 } 19041 19042 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sidebar-navigation-screen-navigation-menu/delete-modal.js 19043 19044 /** 19045 * WordPress dependencies 19046 */ 19047 19048 19049 function delete_modal_RenameModal({ 19050 onClose, 19051 onConfirm 19052 }) { 19053 return (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalConfirmDialog, { 19054 isOpen: true, 19055 onConfirm: e => { 19056 e.preventDefault(); 19057 onConfirm(); 19058 19059 // Immediate close avoids ability to hit delete multiple times. 19060 onClose(); 19061 }, 19062 onCancel: onClose, 19063 confirmButtonText: (0,external_wp_i18n_namespaceObject.__)('Delete') 19064 }, (0,external_wp_i18n_namespaceObject.__)('Are you sure you want to delete this Navigation menu?')); 19065 } 19066 19067 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sidebar-navigation-screen-navigation-menu/more-menu.js 19068 19069 /** 19070 * WordPress dependencies 19071 */ 19072 19073 19074 19075 19076 19077 /** 19078 * Internal dependencies 19079 */ 19080 19081 19082 const more_menu_POPOVER_PROPS = { 19083 position: 'bottom right' 19084 }; 19085 function ScreenNavigationMoreMenu(props) { 19086 const { 19087 onDelete, 19088 onSave, 19089 onDuplicate, 19090 menuTitle 19091 } = props; 19092 const [renameModalOpen, setRenameModalOpen] = (0,external_wp_element_namespaceObject.useState)(false); 19093 const [deleteModalOpen, setDeleteModalOpen] = (0,external_wp_element_namespaceObject.useState)(false); 19094 const closeModals = () => { 19095 setRenameModalOpen(false); 19096 setDeleteModalOpen(false); 19097 }; 19098 const openRenameModal = () => setRenameModalOpen(true); 19099 const openDeleteModal = () => setDeleteModalOpen(true); 19100 return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.DropdownMenu, { 19101 className: "sidebar-navigation__more-menu", 19102 label: (0,external_wp_i18n_namespaceObject.__)('Actions'), 19103 icon: more_vertical, 19104 popoverProps: more_menu_POPOVER_PROPS 19105 }, ({ 19106 onClose 19107 }) => (0,external_React_.createElement)("div", null, (0,external_React_.createElement)(external_wp_components_namespaceObject.MenuGroup, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.MenuItem, { 19108 onClick: () => { 19109 openRenameModal(); 19110 // Close the dropdown after opening the modal. 19111 onClose(); 19112 } 19113 }, (0,external_wp_i18n_namespaceObject.__)('Rename')), (0,external_React_.createElement)(external_wp_components_namespaceObject.MenuItem, { 19114 onClick: () => { 19115 onDuplicate(); 19116 onClose(); 19117 } 19118 }, (0,external_wp_i18n_namespaceObject.__)('Duplicate')), (0,external_React_.createElement)(external_wp_components_namespaceObject.MenuItem, { 19119 isDestructive: true, 19120 onClick: () => { 19121 openDeleteModal(); 19122 19123 // Close the dropdown after opening the modal. 19124 onClose(); 19125 } 19126 }, (0,external_wp_i18n_namespaceObject.__)('Delete'))))), deleteModalOpen && (0,external_React_.createElement)(delete_modal_RenameModal, { 19127 onClose: closeModals, 19128 onConfirm: onDelete 19129 }), renameModalOpen && (0,external_React_.createElement)(RenameModal, { 19130 onClose: closeModals, 19131 menuTitle: menuTitle, 19132 onSave: onSave 19133 })); 19134 } 19135 19136 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sidebar-navigation-screen-navigation-menus/build-navigation-label.js 19137 /** 19138 * WordPress dependencies 19139 */ 19140 19141 19142 19143 // Copied from packages/block-library/src/navigation/edit/navigation-menu-selector.js. 19144 function buildNavigationLabel(title, id, status) { 19145 if (!title?.rendered) { 19146 /* translators: %s is the index of the menu in the list of menus. */ 19147 return (0,external_wp_i18n_namespaceObject.sprintf)((0,external_wp_i18n_namespaceObject.__)('(no title %s)'), id); 19148 } 19149 if (status === 'publish') { 19150 return (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(title?.rendered); 19151 } 19152 return (0,external_wp_i18n_namespaceObject.sprintf)( 19153 // translators: %1s: title of the menu; %2s: status of the menu (draft, pending, etc.). 19154 (0,external_wp_i18n_namespaceObject.__)('%1$s (%2$s)'), (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(title?.rendered), status); 19155 } 19156 19157 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sidebar-navigation-screen-navigation-menu/edit-button.js 19158 19159 /** 19160 * WordPress dependencies 19161 */ 19162 19163 19164 /** 19165 * Internal dependencies 19166 */ 19167 19168 19169 19170 function EditButton({ 19171 postId 19172 }) { 19173 const linkInfo = useLink({ 19174 postId, 19175 postType: NAVIGATION_POST_TYPE, 19176 canvas: 'edit' 19177 }); 19178 return (0,external_React_.createElement)(SidebarButton, { 19179 ...linkInfo, 19180 label: (0,external_wp_i18n_namespaceObject.__)('Edit'), 19181 icon: library_pencil 19182 }); 19183 } 19184 19185 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sidebar-navigation-screen-navigation-menu/single-navigation-menu.js 19186 19187 /** 19188 * WordPress dependencies 19189 */ 19190 19191 19192 /** 19193 * Internal dependencies 19194 */ 19195 19196 19197 19198 19199 19200 function SingleNavigationMenu({ 19201 navigationMenu, 19202 handleDelete, 19203 handleDuplicate, 19204 handleSave 19205 }) { 19206 const menuTitle = navigationMenu?.title?.rendered; 19207 return (0,external_React_.createElement)(SidebarNavigationScreenWrapper, { 19208 actions: (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(ScreenNavigationMoreMenu, { 19209 menuTitle: (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(menuTitle), 19210 onDelete: handleDelete, 19211 onSave: handleSave, 19212 onDuplicate: handleDuplicate 19213 }), (0,external_React_.createElement)(EditButton, { 19214 postId: navigationMenu?.id 19215 })), 19216 title: buildNavigationLabel(navigationMenu?.title, navigationMenu?.id, navigationMenu?.status), 19217 description: (0,external_wp_i18n_namespaceObject.__)('Navigation menus are a curated collection of blocks that allow visitors to get around your site.') 19218 }, (0,external_React_.createElement)(NavigationMenuEditor, { 19219 navigationMenuId: navigationMenu?.id 19220 })); 19221 } 19222 19223 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sidebar-navigation-screen-navigation-menu/index.js 19224 19225 /** 19226 * WordPress dependencies 19227 */ 19228 19229 19230 19231 19232 19233 19234 /** 19235 * Internal dependencies 19236 */ 19237 19238 19239 19240 19241 19242 const postType = `wp_navigation`; 19243 function SidebarNavigationScreenNavigationMenu() { 19244 const { 19245 params: { 19246 postId 19247 } 19248 } = (0,external_wp_components_namespaceObject.__experimentalUseNavigator)(); 19249 const { 19250 record: navigationMenu, 19251 isResolving 19252 } = (0,external_wp_coreData_namespaceObject.useEntityRecord)('postType', postType, postId); 19253 const { 19254 isSaving, 19255 isDeleting 19256 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 19257 const { 19258 isSavingEntityRecord, 19259 isDeletingEntityRecord 19260 } = select(external_wp_coreData_namespaceObject.store); 19261 return { 19262 isSaving: isSavingEntityRecord('postType', postType, postId), 19263 isDeleting: isDeletingEntityRecord('postType', postType, postId) 19264 }; 19265 }, [postId]); 19266 const isLoading = isResolving || isSaving || isDeleting; 19267 const menuTitle = navigationMenu?.title?.rendered || navigationMenu?.slug; 19268 const { 19269 handleSave, 19270 handleDelete, 19271 handleDuplicate 19272 } = useNavigationMenuHandlers(); 19273 const _handleDelete = () => handleDelete(navigationMenu); 19274 const _handleSave = edits => handleSave(navigationMenu, edits); 19275 const _handleDuplicate = () => handleDuplicate(navigationMenu); 19276 if (isLoading) { 19277 return (0,external_React_.createElement)(SidebarNavigationScreenWrapper, { 19278 description: (0,external_wp_i18n_namespaceObject.__)('Navigation menus are a curated collection of blocks that allow visitors to get around your site.') 19279 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.Spinner, { 19280 className: "edit-site-sidebar-navigation-screen-navigation-menus__loading" 19281 })); 19282 } 19283 if (!isLoading && !navigationMenu) { 19284 return (0,external_React_.createElement)(SidebarNavigationScreenWrapper, { 19285 description: (0,external_wp_i18n_namespaceObject.__)('Navigation Menu missing.') 19286 }); 19287 } 19288 if (!navigationMenu?.content?.raw) { 19289 return (0,external_React_.createElement)(SidebarNavigationScreenWrapper, { 19290 actions: (0,external_React_.createElement)(ScreenNavigationMoreMenu, { 19291 menuTitle: (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(menuTitle), 19292 onDelete: _handleDelete, 19293 onSave: _handleSave, 19294 onDuplicate: _handleDuplicate 19295 }), 19296 title: buildNavigationLabel(navigationMenu?.title, navigationMenu?.id, navigationMenu?.status), 19297 description: (0,external_wp_i18n_namespaceObject.__)('This Navigation Menu is empty.') 19298 }); 19299 } 19300 return (0,external_React_.createElement)(SingleNavigationMenu, { 19301 navigationMenu: navigationMenu, 19302 handleDelete: _handleDelete, 19303 handleSave: _handleSave, 19304 handleDuplicate: _handleDuplicate 19305 }); 19306 } 19307 19308 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sidebar-navigation-screen-navigation-menu/use-navigation-menu-handlers.js 19309 /** 19310 * WordPress dependencies 19311 */ 19312 19313 19314 19315 19316 19317 19318 /** 19319 * Internal dependencies 19320 */ 19321 19322 19323 function useDeleteNavigationMenu() { 19324 const { 19325 goTo 19326 } = (0,external_wp_components_namespaceObject.__experimentalUseNavigator)(); 19327 const { 19328 deleteEntityRecord 19329 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store); 19330 const { 19331 createSuccessNotice, 19332 createErrorNotice 19333 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store); 19334 const handleDelete = async navigationMenu => { 19335 const postId = navigationMenu?.id; 19336 try { 19337 await deleteEntityRecord('postType', postType, postId, { 19338 force: true 19339 }, { 19340 throwOnError: true 19341 }); 19342 createSuccessNotice((0,external_wp_i18n_namespaceObject.__)('Deleted Navigation menu'), { 19343 type: 'snackbar' 19344 }); 19345 goTo('/navigation'); 19346 } catch (error) { 19347 createErrorNotice((0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: error message describing why the navigation menu could not be deleted. */ 19348 (0,external_wp_i18n_namespaceObject.__)(`Unable to delete Navigation menu (%s).`), error?.message), { 19349 type: 'snackbar' 19350 }); 19351 } 19352 }; 19353 return handleDelete; 19354 } 19355 function useSaveNavigationMenu() { 19356 const { 19357 getEditedEntityRecord 19358 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 19359 const { 19360 getEditedEntityRecord: getEditedEntityRecordSelector 19361 } = select(external_wp_coreData_namespaceObject.store); 19362 return { 19363 getEditedEntityRecord: getEditedEntityRecordSelector 19364 }; 19365 }, []); 19366 const { 19367 editEntityRecord, 19368 __experimentalSaveSpecifiedEntityEdits: saveSpecifiedEntityEdits 19369 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store); 19370 const { 19371 createSuccessNotice, 19372 createErrorNotice 19373 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store); 19374 const handleSave = async (navigationMenu, edits) => { 19375 if (!edits) { 19376 return; 19377 } 19378 const postId = navigationMenu?.id; 19379 // Prepare for revert in case of error. 19380 const originalRecord = getEditedEntityRecord('postType', NAVIGATION_POST_TYPE, postId); 19381 19382 // Apply the edits. 19383 editEntityRecord('postType', postType, postId, edits); 19384 const recordPropertiesToSave = Object.keys(edits); 19385 19386 // Attempt to persist. 19387 try { 19388 await saveSpecifiedEntityEdits('postType', postType, postId, recordPropertiesToSave, { 19389 throwOnError: true 19390 }); 19391 createSuccessNotice((0,external_wp_i18n_namespaceObject.__)('Renamed Navigation menu'), { 19392 type: 'snackbar' 19393 }); 19394 } catch (error) { 19395 // Revert to original in case of error. 19396 editEntityRecord('postType', postType, postId, originalRecord); 19397 createErrorNotice((0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: error message describing why the navigation menu could not be renamed. */ 19398 (0,external_wp_i18n_namespaceObject.__)(`Unable to rename Navigation menu (%s).`), error?.message), { 19399 type: 'snackbar' 19400 }); 19401 } 19402 }; 19403 return handleSave; 19404 } 19405 function useDuplicateNavigationMenu() { 19406 const { 19407 goTo 19408 } = (0,external_wp_components_namespaceObject.__experimentalUseNavigator)(); 19409 const { 19410 saveEntityRecord 19411 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store); 19412 const { 19413 createSuccessNotice, 19414 createErrorNotice 19415 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store); 19416 const handleDuplicate = async navigationMenu => { 19417 const menuTitle = navigationMenu?.title?.rendered || navigationMenu?.slug; 19418 try { 19419 const savedRecord = await saveEntityRecord('postType', postType, { 19420 title: (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: Navigation menu title */ 19421 (0,external_wp_i18n_namespaceObject.__)('%s (Copy)'), menuTitle), 19422 content: navigationMenu?.content?.raw, 19423 status: 'publish' 19424 }, { 19425 throwOnError: true 19426 }); 19427 if (savedRecord) { 19428 createSuccessNotice((0,external_wp_i18n_namespaceObject.__)('Duplicated Navigation menu'), { 19429 type: 'snackbar' 19430 }); 19431 goTo(`/navigation/$postType}/$savedRecord.id}`); 19432 } 19433 } catch (error) { 19434 createErrorNotice((0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: error message describing why the navigation menu could not be deleted. */ 19435 (0,external_wp_i18n_namespaceObject.__)(`Unable to duplicate Navigation menu (%s).`), error?.message), { 19436 type: 'snackbar' 19437 }); 19438 } 19439 }; 19440 return handleDuplicate; 19441 } 19442 function useNavigationMenuHandlers() { 19443 return { 19444 handleDelete: useDeleteNavigationMenu(), 19445 handleSave: useSaveNavigationMenu(), 19446 handleDuplicate: useDuplicateNavigationMenu() 19447 }; 19448 } 19449 19450 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sidebar-navigation-screen-navigation-menus/index.js 19451 19452 /** 19453 * WordPress dependencies 19454 */ 19455 19456 19457 19458 19459 19460 19461 19462 /** 19463 * Internal dependencies 19464 */ 19465 19466 19467 19468 19469 19470 19471 19472 19473 19474 // Copied from packages/block-library/src/navigation/edit/navigation-menu-selector.js. 19475 function buildMenuLabel(title, id, status) { 19476 if (!title) { 19477 /* translators: %s is the index of the menu in the list of menus. */ 19478 return (0,external_wp_i18n_namespaceObject.sprintf)((0,external_wp_i18n_namespaceObject.__)('(no title %s)'), id); 19479 } 19480 if (status === 'publish') { 19481 return (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(title); 19482 } 19483 return (0,external_wp_i18n_namespaceObject.sprintf)( 19484 // translators: %1s: title of the menu; %2s: status of the menu (draft, pending, etc.). 19485 (0,external_wp_i18n_namespaceObject.__)('%1$s (%2$s)'), (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(title), status); 19486 } 19487 19488 // Save a boolean to prevent us creating a fallback more than once per session. 19489 let hasCreatedFallback = false; 19490 function SidebarNavigationScreenNavigationMenus() { 19491 const { 19492 records: navigationMenus, 19493 isResolving: isResolvingNavigationMenus, 19494 hasResolved: hasResolvedNavigationMenus 19495 } = (0,external_wp_coreData_namespaceObject.useEntityRecords)('postType', NAVIGATION_POST_TYPE, PRELOADED_NAVIGATION_MENUS_QUERY); 19496 const isLoading = isResolvingNavigationMenus && !hasResolvedNavigationMenus; 19497 const { 19498 getNavigationFallbackId 19499 } = unlock((0,external_wp_data_namespaceObject.useSelect)(external_wp_coreData_namespaceObject.store)); 19500 const firstNavigationMenu = navigationMenus?.[0]; 19501 19502 // Save a boolean to prevent us creating a fallback more than once per session. 19503 if (firstNavigationMenu) { 19504 hasCreatedFallback = true; 19505 } 19506 19507 // If there is no navigation menu found 19508 // then trigger fallback algorithm to create one. 19509 if (!firstNavigationMenu && !isResolvingNavigationMenus && hasResolvedNavigationMenus && !hasCreatedFallback) { 19510 getNavigationFallbackId(); 19511 } 19512 const { 19513 handleSave, 19514 handleDelete, 19515 handleDuplicate 19516 } = useNavigationMenuHandlers(); 19517 const hasNavigationMenus = !!navigationMenus?.length; 19518 if (isLoading) { 19519 return (0,external_React_.createElement)(SidebarNavigationScreenWrapper, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.Spinner, { 19520 className: "edit-site-sidebar-navigation-screen-navigation-menus__loading" 19521 })); 19522 } 19523 if (!isLoading && !hasNavigationMenus) { 19524 return (0,external_React_.createElement)(SidebarNavigationScreenWrapper, { 19525 description: (0,external_wp_i18n_namespaceObject.__)('No Navigation Menus found.') 19526 }); 19527 } 19528 19529 // if single menu then render it 19530 if (navigationMenus?.length === 1) { 19531 return (0,external_React_.createElement)(SingleNavigationMenu, { 19532 navigationMenu: firstNavigationMenu, 19533 handleDelete: () => handleDelete(firstNavigationMenu), 19534 handleDuplicate: () => handleDuplicate(firstNavigationMenu), 19535 handleSave: edits => handleSave(firstNavigationMenu, edits) 19536 }); 19537 } 19538 return (0,external_React_.createElement)(SidebarNavigationScreenWrapper, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalItemGroup, null, navigationMenus?.map(({ 19539 id, 19540 title, 19541 status 19542 }, index) => (0,external_React_.createElement)(NavMenuItem, { 19543 postId: id, 19544 key: id, 19545 withChevron: true, 19546 icon: library_navigation 19547 }, buildMenuLabel(title?.rendered, index + 1, status))))); 19548 } 19549 function SidebarNavigationScreenWrapper({ 19550 children, 19551 actions, 19552 title, 19553 description 19554 }) { 19555 return (0,external_React_.createElement)(SidebarNavigationScreen, { 19556 title: title || (0,external_wp_i18n_namespaceObject.__)('Navigation'), 19557 actions: actions, 19558 description: description || (0,external_wp_i18n_namespaceObject.__)('Manage your Navigation menus.'), 19559 content: children 19560 }); 19561 } 19562 const NavMenuItem = ({ 19563 postId, 19564 ...props 19565 }) => { 19566 const linkInfo = useLink({ 19567 postId, 19568 postType: NAVIGATION_POST_TYPE 19569 }); 19570 return (0,external_React_.createElement)(SidebarNavigationItem, { 19571 ...linkInfo, 19572 ...props 19573 }); 19574 }; 19575 19576 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/block-table.js 19577 19578 /** 19579 * WordPress dependencies 19580 */ 19581 19582 const blockTable = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { 19583 viewBox: "0 0 24 24", 19584 xmlns: "http://www.w3.org/2000/svg" 19585 }, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 19586 d: "M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zM5 4.5h14c.3 0 .5.2.5.5v3.5h-15V5c0-.3.2-.5.5-.5zm8 5.5h6.5v3.5H13V10zm-1.5 3.5h-7V10h7v3.5zm-7 5.5v-4h7v4.5H5c-.3 0-.5-.2-.5-.5zm14.5.5h-6V15h6.5v4c0 .3-.2.5-.5.5z" 19587 })); 19588 /* harmony default export */ const block_table = (blockTable); 19589 19590 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/format-list-bullets-rtl.js 19591 19592 /** 19593 * WordPress dependencies 19594 */ 19595 19596 const formatListBulletsRTL = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { 19597 xmlns: "http://www.w3.org/2000/svg", 19598 viewBox: "0 0 24 24" 19599 }, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 19600 d: "M4 8.8h8.9V7.2H4v1.6zm0 7h8.9v-1.5H4v1.5zM18 13c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0-3c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2z" 19601 })); 19602 /* harmony default export */ const format_list_bullets_rtl = (formatListBulletsRTL); 19603 19604 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/format-list-bullets.js 19605 19606 /** 19607 * WordPress dependencies 19608 */ 19609 19610 const formatListBullets = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { 19611 xmlns: "http://www.w3.org/2000/svg", 19612 viewBox: "0 0 24 24" 19613 }, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 19614 d: "M11.1 15.8H20v-1.5h-8.9v1.5zm0-8.6v1.5H20V7.2h-8.9zM6 13c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0-7c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z" 19615 })); 19616 /* harmony default export */ const format_list_bullets = (formatListBullets); 19617 19618 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/funnel.js 19619 19620 /** 19621 * WordPress dependencies 19622 */ 19623 19624 const funnel = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { 19625 viewBox: "0 0 24 24", 19626 xmlns: "http://www.w3.org/2000/svg" 19627 }, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 19628 d: "M10 17.5H14V16H10V17.5ZM6 6V7.5H18V6H6ZM8 12.5H16V11H8V12.5Z" 19629 })); 19630 /* harmony default export */ const library_funnel = (funnel); 19631 19632 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/unseen.js 19633 19634 /** 19635 * WordPress dependencies 19636 */ 19637 19638 const unseen = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { 19639 viewBox: "0 0 24 24", 19640 xmlns: "http://www.w3.org/2000/svg" 19641 }, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 19642 d: "M4.67 10.664s-2.09 1.11-2.917 1.582l.494.87 1.608-.914.002.002c.343.502.86 1.17 1.563 1.84.348.33.742.663 1.185.976L5.57 16.744l.858.515 1.02-1.701a9.1 9.1 0 0 0 4.051 1.18V19h1v-2.263a9.1 9.1 0 0 0 4.05-1.18l1.021 1.7.858-.514-1.034-1.723c.442-.313.837-.646 1.184-.977.703-.669 1.22-1.337 1.563-1.839l.002-.003 1.61.914.493-.87c-1.75-.994-2.918-1.58-2.918-1.58l-.003.005a8.29 8.29 0 0 1-.422.689 10.097 10.097 0 0 1-1.36 1.598c-1.218 1.16-3.042 2.293-5.544 2.293-2.503 0-4.327-1.132-5.546-2.293a10.099 10.099 0 0 1-1.359-1.599 8.267 8.267 0 0 1-.422-.689l-.003-.005Z" 19643 })); 19644 /* harmony default export */ const library_unseen = (unseen); 19645 19646 ;// CONCATENATED MODULE: ./node_modules/@wordpress/dataviews/build-module/single-selection-checkbox.js 19647 19648 /** 19649 * WordPress dependencies 19650 */ 19651 19652 19653 function SingleSelectionCheckbox({ 19654 selection, 19655 onSelectionChange, 19656 item, 19657 data, 19658 getItemId, 19659 primaryField, 19660 disabled 19661 }) { 19662 const id = getItemId(item); 19663 const isSelected = selection.includes(id); 19664 let selectionLabel; 19665 if (primaryField?.getValue && item) { 19666 // eslint-disable-next-line @wordpress/valid-sprintf 19667 selectionLabel = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: item title. */ 19668 isSelected ? (0,external_wp_i18n_namespaceObject.__)('Deselect item: %s') : (0,external_wp_i18n_namespaceObject.__)('Select item: %s'), primaryField.getValue({ 19669 item 19670 })); 19671 } else { 19672 selectionLabel = isSelected ? (0,external_wp_i18n_namespaceObject.__)('Select a new item') : (0,external_wp_i18n_namespaceObject.__)('Deselect item'); 19673 } 19674 return (0,external_React_.createElement)(external_wp_components_namespaceObject.CheckboxControl, { 19675 className: "dataviews-view-table-selection-checkbox", 19676 __nextHasNoMarginBottom: true, 19677 label: selectionLabel, 19678 "aria-disabled": disabled, 19679 checked: isSelected, 19680 onChange: () => { 19681 if (disabled) { 19682 return; 19683 } 19684 if (!isSelected) { 19685 onSelectionChange(data.filter(_item => { 19686 const itemId = getItemId?.(_item); 19687 return itemId === id || selection.includes(itemId); 19688 })); 19689 } else { 19690 onSelectionChange(data.filter(_item => { 19691 const itemId = getItemId?.(_item); 19692 return itemId !== id && selection.includes(itemId); 19693 })); 19694 } 19695 } 19696 }); 19697 } 19698 19699 ;// CONCATENATED MODULE: ./node_modules/@wordpress/dataviews/build-module/lock-unlock.js 19700 /** 19701 * WordPress dependencies 19702 */ 19703 19704 const { 19705 lock: lock_unlock_lock, 19706 unlock: lock_unlock_unlock 19707 } = (0,external_wp_privateApis_namespaceObject.__dangerousOptInToUnstableAPIsOnlyForCoreModules)('I know using unstable features means my theme or plugin will inevitably break in the next version of WordPress.', '@wordpress/dataviews'); 19708 19709 ;// CONCATENATED MODULE: ./node_modules/@wordpress/dataviews/build-module/item-actions.js 19710 19711 /** 19712 * WordPress dependencies 19713 */ 19714 19715 19716 19717 19718 19719 /** 19720 * Internal dependencies 19721 */ 19722 19723 const { 19724 DropdownMenuV2: DropdownMenu, 19725 DropdownMenuGroupV2: DropdownMenuGroup, 19726 DropdownMenuItemV2: DropdownMenuItem, 19727 DropdownMenuItemLabelV2: DropdownMenuItemLabel, 19728 kebabCase 19729 } = lock_unlock_unlock(external_wp_components_namespaceObject.privateApis); 19730 function ButtonTrigger({ 19731 action, 19732 onClick 19733 }) { 19734 return (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 19735 label: action.label, 19736 icon: action.icon, 19737 isDestructive: action.isDestructive, 19738 size: "compact", 19739 onClick: onClick 19740 }); 19741 } 19742 function DropdownMenuItemTrigger({ 19743 action, 19744 onClick 19745 }) { 19746 return (0,external_React_.createElement)(DropdownMenuItem, { 19747 onClick: onClick, 19748 hideOnClick: !action.RenderModal 19749 }, (0,external_React_.createElement)(DropdownMenuItemLabel, null, action.label)); 19750 } 19751 function ActionWithModal({ 19752 action, 19753 item, 19754 ActionTrigger 19755 }) { 19756 const [isModalOpen, setIsModalOpen] = (0,external_wp_element_namespaceObject.useState)(false); 19757 const actionTriggerProps = { 19758 action, 19759 onClick: () => setIsModalOpen(true) 19760 }; 19761 const { 19762 RenderModal, 19763 hideModalHeader 19764 } = action; 19765 return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(ActionTrigger, { 19766 ...actionTriggerProps 19767 }), isModalOpen && (0,external_React_.createElement)(external_wp_components_namespaceObject.Modal, { 19768 title: action.modalHeader || action.label, 19769 __experimentalHideHeader: !!hideModalHeader, 19770 onRequestClose: () => { 19771 setIsModalOpen(false); 19772 }, 19773 overlayClassName: `dataviews-action-modal dataviews-action-modal__$kebabCase(action.id)}` 19774 }, (0,external_React_.createElement)(RenderModal, { 19775 items: [item], 19776 closeModal: () => setIsModalOpen(false) 19777 }))); 19778 } 19779 function ActionsDropdownMenuGroup({ 19780 actions, 19781 item 19782 }) { 19783 return (0,external_React_.createElement)(DropdownMenuGroup, null, actions.map(action => { 19784 if (!!action.RenderModal) { 19785 return (0,external_React_.createElement)(ActionWithModal, { 19786 key: action.id, 19787 action: action, 19788 item: item, 19789 ActionTrigger: DropdownMenuItemTrigger 19790 }); 19791 } 19792 return (0,external_React_.createElement)(DropdownMenuItemTrigger, { 19793 key: action.id, 19794 action: action, 19795 onClick: () => action.callback([item]) 19796 }); 19797 })); 19798 } 19799 function ItemActions({ 19800 item, 19801 actions, 19802 isCompact 19803 }) { 19804 const { 19805 primaryActions, 19806 secondaryActions 19807 } = (0,external_wp_element_namespaceObject.useMemo)(() => { 19808 return actions.reduce((accumulator, action) => { 19809 // If an action is eligible for all items, doesn't need 19810 // to provide the `isEligible` function. 19811 if (action.isEligible && !action.isEligible(item)) { 19812 return accumulator; 19813 } 19814 if (action.isPrimary && !!action.icon) { 19815 accumulator.primaryActions.push(action); 19816 } else { 19817 accumulator.secondaryActions.push(action); 19818 } 19819 return accumulator; 19820 }, { 19821 primaryActions: [], 19822 secondaryActions: [] 19823 }); 19824 }, [actions, item]); 19825 if (isCompact) { 19826 return (0,external_React_.createElement)(CompactItemActions, { 19827 item: item, 19828 primaryActions: primaryActions, 19829 secondaryActions: secondaryActions 19830 }); 19831 } 19832 return (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { 19833 spacing: 1, 19834 justify: "flex-end", 19835 style: { 19836 flexShrink: '0', 19837 width: 'auto' 19838 } 19839 }, !!primaryActions.length && primaryActions.map(action => { 19840 if (!!action.RenderModal) { 19841 return (0,external_React_.createElement)(ActionWithModal, { 19842 key: action.id, 19843 action: action, 19844 item: item, 19845 ActionTrigger: ButtonTrigger 19846 }); 19847 } 19848 return (0,external_React_.createElement)(ButtonTrigger, { 19849 key: action.id, 19850 action: action, 19851 onClick: () => action.callback([item]) 19852 }); 19853 }), (0,external_React_.createElement)(DropdownMenu, { 19854 trigger: (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 19855 size: "compact", 19856 icon: more_vertical, 19857 label: (0,external_wp_i18n_namespaceObject.__)('Actions'), 19858 disabled: !secondaryActions.length 19859 }), 19860 placement: "bottom-end" 19861 }, (0,external_React_.createElement)(ActionsDropdownMenuGroup, { 19862 actions: secondaryActions, 19863 item: item 19864 }))); 19865 } 19866 function CompactItemActions({ 19867 item, 19868 primaryActions, 19869 secondaryActions 19870 }) { 19871 return (0,external_React_.createElement)(DropdownMenu, { 19872 trigger: (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 19873 size: "compact", 19874 icon: more_vertical, 19875 label: (0,external_wp_i18n_namespaceObject.__)('Actions'), 19876 disabled: !primaryActions.length && !secondaryActions.length 19877 }), 19878 placement: "bottom-end" 19879 }, !!primaryActions.length && (0,external_React_.createElement)(ActionsDropdownMenuGroup, { 19880 actions: primaryActions, 19881 item: item 19882 }), !!secondaryActions.length && (0,external_React_.createElement)(ActionsDropdownMenuGroup, { 19883 actions: secondaryActions, 19884 item: item 19885 })); 19886 } 19887 19888 ;// CONCATENATED MODULE: ./node_modules/@wordpress/dataviews/build-module/utils.js 19889 /** 19890 * Internal dependencies 19891 */ 19892 19893 19894 /** 19895 * Helper util to sort data by text fields, when sorting is done client side. 19896 * 19897 * @param {Object} params Function params. 19898 * @param {Object[]} params.data Data to sort. 19899 * @param {Object} params.view Current view object. 19900 * @param {Object[]} params.fields Array of available fields. 19901 * @param {string[]} params.textFields Array of the field ids to sort. 19902 * 19903 * @return {Object[]} Sorted data. 19904 */ 19905 const sortByTextFields = ({ 19906 data, 19907 view, 19908 fields, 19909 textFields 19910 }) => { 19911 const sortedData = [...data]; 19912 const fieldId = view.sort.field; 19913 if (textFields.includes(fieldId)) { 19914 const fieldToSort = fields.find(field => { 19915 return field.id === fieldId; 19916 }); 19917 sortedData.sort((a, b) => { 19918 var _fieldToSort$getValue, _fieldToSort$getValue2; 19919 const valueA = (_fieldToSort$getValue = fieldToSort.getValue({ 19920 item: a 19921 })) !== null && _fieldToSort$getValue !== void 0 ? _fieldToSort$getValue : ''; 19922 const valueB = (_fieldToSort$getValue2 = fieldToSort.getValue({ 19923 item: b 19924 })) !== null && _fieldToSort$getValue2 !== void 0 ? _fieldToSort$getValue2 : ''; 19925 return view.sort.direction === 'asc' ? valueA.localeCompare(valueB) : valueB.localeCompare(valueA); 19926 }); 19927 } 19928 return sortedData; 19929 }; 19930 19931 /** 19932 * Helper util to get the paginated data and the paginateInfo needed, 19933 * when pagination is done client side. 19934 * 19935 * @param {Object} params Function params. 19936 * @param {Object[]} params.data Available data. 19937 * @param {Object} params.view Current view object. 19938 * 19939 * @return {Object} Paginated data and paginationInfo. 19940 */ 19941 function getPaginationResults({ 19942 data, 19943 view 19944 }) { 19945 const start = (view.page - 1) * view.perPage; 19946 const totalItems = data?.length || 0; 19947 data = data?.slice(start, start + view.perPage); 19948 return { 19949 data, 19950 paginationInfo: { 19951 totalItems, 19952 totalPages: Math.ceil(totalItems / view.perPage) 19953 } 19954 }; 19955 } 19956 const sanitizeOperators = field => { 19957 let operators = field.filterBy?.operators; 19958 if (!operators || !Array.isArray(operators)) { 19959 operators = Object.keys(OPERATORS); 19960 } 19961 return operators.filter(operator => Object.keys(OPERATORS).includes(operator)); 19962 }; 19963 19964 ;// CONCATENATED MODULE: ./node_modules/@wordpress/dataviews/build-module/bulk-actions.js 19965 19966 /** 19967 * WordPress dependencies 19968 */ 19969 19970 19971 19972 19973 /** 19974 * Internal dependencies 19975 */ 19976 19977 const { 19978 DropdownMenuV2: bulk_actions_DropdownMenu, 19979 DropdownMenuGroupV2: bulk_actions_DropdownMenuGroup, 19980 DropdownMenuItemV2: bulk_actions_DropdownMenuItem, 19981 DropdownMenuSeparatorV2: DropdownMenuSeparator 19982 } = lock_unlock_unlock(external_wp_components_namespaceObject.privateApis); 19983 function useHasAPossibleBulkAction(actions, item) { 19984 return (0,external_wp_element_namespaceObject.useMemo)(() => { 19985 return actions.some(action => { 19986 return action.supportsBulk && action.isEligible(item); 19987 }); 19988 }, [actions, item]); 19989 } 19990 function useSomeItemHasAPossibleBulkAction(actions, data) { 19991 return (0,external_wp_element_namespaceObject.useMemo)(() => { 19992 return data.some(item => { 19993 return actions.some(action => { 19994 return action.supportsBulk && action.isEligible(item); 19995 }); 19996 }); 19997 }, [actions, data]); 19998 } 19999 function bulk_actions_ActionWithModal({ 20000 action, 20001 selectedItems, 20002 setActionWithModal, 20003 onMenuOpenChange 20004 }) { 20005 const eligibleItems = (0,external_wp_element_namespaceObject.useMemo)(() => { 20006 return selectedItems.filter(item => action.isEligible(item)); 20007 }, [action, selectedItems]); 20008 const { 20009 RenderModal, 20010 hideModalHeader 20011 } = action; 20012 const onCloseModal = (0,external_wp_element_namespaceObject.useCallback)(() => { 20013 setActionWithModal(undefined); 20014 }, [setActionWithModal]); 20015 return (0,external_React_.createElement)(external_wp_components_namespaceObject.Modal, { 20016 title: !hideModalHeader && action.label, 20017 __experimentalHideHeader: !!hideModalHeader, 20018 onRequestClose: onCloseModal, 20019 overlayClassName: "dataviews-action-modal" 20020 }, (0,external_React_.createElement)(RenderModal, { 20021 items: eligibleItems, 20022 closeModal: onCloseModal, 20023 onPerform: () => onMenuOpenChange(false) 20024 })); 20025 } 20026 function BulkActionItem({ 20027 action, 20028 selectedItems, 20029 setActionWithModal 20030 }) { 20031 const eligibleItems = (0,external_wp_element_namespaceObject.useMemo)(() => { 20032 return selectedItems.filter(item => action.isEligible(item)); 20033 }, [action, selectedItems]); 20034 const shouldShowModal = !!action.RenderModal; 20035 return (0,external_React_.createElement)(bulk_actions_DropdownMenuItem, { 20036 key: action.id, 20037 disabled: eligibleItems.length === 0, 20038 hideOnClick: !shouldShowModal, 20039 onClick: async () => { 20040 if (shouldShowModal) { 20041 setActionWithModal(action); 20042 } else { 20043 await action.callback(eligibleItems); 20044 } 20045 }, 20046 suffix: eligibleItems.length > 0 ? eligibleItems.length : undefined 20047 }, action.label); 20048 } 20049 function ActionsMenuGroup({ 20050 actions, 20051 selectedItems, 20052 setActionWithModal 20053 }) { 20054 return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(bulk_actions_DropdownMenuGroup, null, actions.map(action => (0,external_React_.createElement)(BulkActionItem, { 20055 key: action.id, 20056 action: action, 20057 selectedItems: selectedItems, 20058 setActionWithModal: setActionWithModal 20059 }))), (0,external_React_.createElement)(DropdownMenuSeparator, null)); 20060 } 20061 function BulkActions({ 20062 data, 20063 actions, 20064 selection, 20065 onSelectionChange, 20066 getItemId 20067 }) { 20068 const bulkActions = (0,external_wp_element_namespaceObject.useMemo)(() => actions.filter(action => action.supportsBulk), [actions]); 20069 const [isMenuOpen, onMenuOpenChange] = (0,external_wp_element_namespaceObject.useState)(false); 20070 const [actionWithModal, setActionWithModal] = (0,external_wp_element_namespaceObject.useState)(); 20071 const selectableItems = (0,external_wp_element_namespaceObject.useMemo)(() => { 20072 return data.filter(item => { 20073 return bulkActions.some(action => action.isEligible(item)); 20074 }); 20075 }, [data, bulkActions]); 20076 const numberSelectableItems = selectableItems.length; 20077 const areAllSelected = selection && selection.length === numberSelectableItems; 20078 const selectedItems = (0,external_wp_element_namespaceObject.useMemo)(() => { 20079 return data.filter(item => selection.includes(getItemId(item))); 20080 }, [selection, data, getItemId]); 20081 const hasNonSelectableItemSelected = (0,external_wp_element_namespaceObject.useMemo)(() => { 20082 return selectedItems.some(item => { 20083 return !selectableItems.includes(item); 20084 }); 20085 }, [selectedItems, selectableItems]); 20086 (0,external_wp_element_namespaceObject.useEffect)(() => { 20087 if (hasNonSelectableItemSelected) { 20088 onSelectionChange(selectedItems.filter(selectedItem => { 20089 return selectableItems.some(item => { 20090 return getItemId(selectedItem) === getItemId(item); 20091 }); 20092 })); 20093 } 20094 }, [hasNonSelectableItemSelected, selectedItems, selectableItems, getItemId, onSelectionChange]); 20095 if (bulkActions.length === 0) { 20096 return null; 20097 } 20098 return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(bulk_actions_DropdownMenu, { 20099 open: isMenuOpen, 20100 onOpenChange: onMenuOpenChange, 20101 label: (0,external_wp_i18n_namespaceObject.__)('Bulk actions'), 20102 style: { 20103 minWidth: '240px' 20104 }, 20105 trigger: (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 20106 className: "dataviews-bulk-edit-button", 20107 __next40pxDefaultSize: true, 20108 variant: "tertiary", 20109 size: "compact" 20110 }, selection.length ? (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %d: Number of items. */ 20111 (0,external_wp_i18n_namespaceObject._n)('Edit %d item', 'Edit %d items', selection.length), selection.length) : (0,external_wp_i18n_namespaceObject.__)('Bulk edit')) 20112 }, (0,external_React_.createElement)(ActionsMenuGroup, { 20113 actions: bulkActions, 20114 setActionWithModal: setActionWithModal, 20115 selectedItems: selectedItems 20116 }), (0,external_React_.createElement)(bulk_actions_DropdownMenuGroup, null, (0,external_React_.createElement)(bulk_actions_DropdownMenuItem, { 20117 disabled: areAllSelected, 20118 hideOnClick: false, 20119 onClick: () => { 20120 onSelectionChange(selectableItems); 20121 }, 20122 suffix: numberSelectableItems 20123 }, (0,external_wp_i18n_namespaceObject.__)('Select all')), (0,external_React_.createElement)(bulk_actions_DropdownMenuItem, { 20124 disabled: selection.length === 0, 20125 hideOnClick: false, 20126 onClick: () => { 20127 onSelectionChange([]); 20128 } 20129 }, (0,external_wp_i18n_namespaceObject.__)('Deselect')))), actionWithModal && (0,external_React_.createElement)(bulk_actions_ActionWithModal, { 20130 action: actionWithModal, 20131 selectedItems: selectedItems, 20132 setActionWithModal: setActionWithModal, 20133 onMenuOpenChange: onMenuOpenChange 20134 })); 20135 } 20136 20137 ;// CONCATENATED MODULE: ./node_modules/@wordpress/dataviews/build-module/view-table.js 20138 20139 /** 20140 * External dependencies 20141 */ 20142 20143 20144 /** 20145 * WordPress dependencies 20146 */ 20147 20148 20149 20150 20151 20152 20153 /** 20154 * Internal dependencies 20155 */ 20156 20157 20158 20159 20160 20161 20162 const { 20163 DropdownMenuV2: view_table_DropdownMenu, 20164 DropdownMenuGroupV2: view_table_DropdownMenuGroup, 20165 DropdownMenuItemV2: view_table_DropdownMenuItem, 20166 DropdownMenuRadioItemV2: DropdownMenuRadioItem, 20167 DropdownMenuItemLabelV2: view_table_DropdownMenuItemLabel, 20168 DropdownMenuSeparatorV2: view_table_DropdownMenuSeparator 20169 } = lock_unlock_unlock(external_wp_components_namespaceObject.privateApis); 20170 function WithSeparators({ 20171 children 20172 }) { 20173 return external_wp_element_namespaceObject.Children.toArray(children).filter(Boolean).map((child, i) => (0,external_React_.createElement)(external_wp_element_namespaceObject.Fragment, { 20174 key: i 20175 }, i > 0 && (0,external_React_.createElement)(view_table_DropdownMenuSeparator, null), child)); 20176 } 20177 const sortArrows = { 20178 asc: '↑', 20179 desc: '↓' 20180 }; 20181 const HeaderMenu = (0,external_wp_element_namespaceObject.forwardRef)(function HeaderMenu({ 20182 field, 20183 view, 20184 onChangeView, 20185 onHide, 20186 setOpenedFilter 20187 }, ref) { 20188 const isHidable = field.enableHiding !== false; 20189 const isSortable = field.enableSorting !== false; 20190 const isSorted = view.sort?.field === field.id; 20191 const operators = sanitizeOperators(field); 20192 // Filter can be added: 20193 // 1. If the field is not already part of a view's filters. 20194 // 2. If the field meets the type and operator requirements. 20195 // 3. If it's not primary. If it is, it should be already visible. 20196 const canAddFilter = !view.filters?.some(_filter => field.id === _filter.field) && field.type === constants_ENUMERATION_TYPE && !!operators.length && !field.filterBy?.isPrimary; 20197 if (!isSortable && !isHidable && !canAddFilter) { 20198 return field.header; 20199 } 20200 return (0,external_React_.createElement)(view_table_DropdownMenu, { 20201 align: "start", 20202 trigger: (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 20203 size: "compact", 20204 className: "dataviews-view-table-header-button", 20205 ref: ref, 20206 variant: "tertiary" 20207 }, field.header, isSorted && (0,external_React_.createElement)("span", { 20208 "aria-hidden": "true" 20209 }, isSorted && sortArrows[view.sort.direction])), 20210 style: { 20211 minWidth: '240px' 20212 } 20213 }, (0,external_React_.createElement)(WithSeparators, null, isSortable && (0,external_React_.createElement)(view_table_DropdownMenuGroup, null, Object.entries(SORTING_DIRECTIONS).map(([direction, info]) => { 20214 const isChecked = isSorted && view.sort.direction === direction; 20215 const value = `$field.id}-$direction}`; 20216 return (0,external_React_.createElement)(DropdownMenuRadioItem, { 20217 key: value 20218 // All sorting radio items share the same name, so that 20219 // selecting a sorting option automatically deselects the 20220 // previously selected one, even if it is displayed in 20221 // another submenu. The field and direction are passed via 20222 // the `value` prop. 20223 , 20224 name: "view-table-sorting", 20225 value: value, 20226 checked: isChecked, 20227 onChange: () => { 20228 onChangeView({ 20229 ...view, 20230 sort: { 20231 field: field.id, 20232 direction 20233 } 20234 }); 20235 } 20236 }, (0,external_React_.createElement)(view_table_DropdownMenuItemLabel, null, info.label)); 20237 })), canAddFilter && (0,external_React_.createElement)(view_table_DropdownMenuGroup, null, (0,external_React_.createElement)(view_table_DropdownMenuItem, { 20238 prefix: (0,external_React_.createElement)(external_wp_components_namespaceObject.Icon, { 20239 icon: library_funnel 20240 }), 20241 onClick: () => { 20242 setOpenedFilter(field.id); 20243 onChangeView({ 20244 ...view, 20245 page: 1, 20246 filters: [...(view.filters || []), { 20247 field: field.id, 20248 value: undefined, 20249 operator: operators[0] 20250 }] 20251 }); 20252 } 20253 }, (0,external_React_.createElement)(view_table_DropdownMenuItemLabel, null, (0,external_wp_i18n_namespaceObject.__)('Add filter')))), isHidable && (0,external_React_.createElement)(view_table_DropdownMenuItem, { 20254 prefix: (0,external_React_.createElement)(external_wp_components_namespaceObject.Icon, { 20255 icon: library_unseen 20256 }), 20257 onClick: () => { 20258 onHide(field); 20259 onChangeView({ 20260 ...view, 20261 hiddenFields: view.hiddenFields.concat(field.id) 20262 }); 20263 } 20264 }, (0,external_React_.createElement)(view_table_DropdownMenuItemLabel, null, (0,external_wp_i18n_namespaceObject.__)('Hide'))))); 20265 }); 20266 function BulkSelectionCheckbox({ 20267 selection, 20268 onSelectionChange, 20269 data, 20270 actions 20271 }) { 20272 const selectableItems = (0,external_wp_element_namespaceObject.useMemo)(() => { 20273 return data.filter(item => { 20274 return actions.some(action => action.supportsBulk && action.isEligible(item)); 20275 }); 20276 }, [data, actions]); 20277 const areAllSelected = selection.length === selectableItems.length; 20278 return (0,external_React_.createElement)(external_wp_components_namespaceObject.CheckboxControl, { 20279 className: "dataviews-view-table-selection-checkbox", 20280 __nextHasNoMarginBottom: true, 20281 checked: areAllSelected, 20282 indeterminate: !areAllSelected && selection.length, 20283 onChange: () => { 20284 if (areAllSelected) { 20285 onSelectionChange([]); 20286 } else { 20287 onSelectionChange(selectableItems); 20288 } 20289 }, 20290 label: areAllSelected ? (0,external_wp_i18n_namespaceObject.__)('Deselect all') : (0,external_wp_i18n_namespaceObject.__)('Select all') 20291 }); 20292 } 20293 function TableRow({ 20294 hasBulkActions, 20295 item, 20296 actions, 20297 id, 20298 visibleFields, 20299 primaryField, 20300 selection, 20301 getItemId, 20302 onSelectionChange, 20303 data 20304 }) { 20305 const hasPossibleBulkAction = useHasAPossibleBulkAction(actions, item); 20306 return (0,external_React_.createElement)("tr", { 20307 className: classnames_default()('dataviews-view-table__row', { 20308 'is-selected': hasPossibleBulkAction && selection.includes(id) 20309 }) 20310 }, hasBulkActions && (0,external_React_.createElement)("td", { 20311 className: "dataviews-view-table__checkbox-column", 20312 style: { 20313 width: 20, 20314 minWidth: 20 20315 } 20316 }, (0,external_React_.createElement)("div", { 20317 className: "dataviews-view-table__cell-content-wrapper" 20318 }, (0,external_React_.createElement)(SingleSelectionCheckbox, { 20319 id: id, 20320 item: item, 20321 selection: selection, 20322 onSelectionChange: onSelectionChange, 20323 getItemId: getItemId, 20324 data: data, 20325 primaryField: primaryField, 20326 disabled: !hasPossibleBulkAction 20327 }))), visibleFields.map(field => (0,external_React_.createElement)("td", { 20328 key: field.id, 20329 style: { 20330 width: field.width || undefined, 20331 minWidth: field.minWidth || undefined, 20332 maxWidth: field.maxWidth || undefined 20333 } 20334 }, (0,external_React_.createElement)("div", { 20335 className: classnames_default()('dataviews-view-table__cell-content-wrapper', { 20336 'dataviews-view-table__primary-field': primaryField?.id === field.id 20337 }) 20338 }, field.render({ 20339 item 20340 })))), !!actions?.length && (0,external_React_.createElement)("td", { 20341 className: "dataviews-view-table__actions-column" 20342 }, (0,external_React_.createElement)(ItemActions, { 20343 item: item, 20344 actions: actions 20345 }))); 20346 } 20347 function ViewTable({ 20348 view, 20349 onChangeView, 20350 fields, 20351 actions, 20352 data, 20353 getItemId, 20354 isLoading = false, 20355 deferredRendering, 20356 selection, 20357 onSelectionChange, 20358 setOpenedFilter 20359 }) { 20360 const headerMenuRefs = (0,external_wp_element_namespaceObject.useRef)(new Map()); 20361 const headerMenuToFocusRef = (0,external_wp_element_namespaceObject.useRef)(); 20362 const [nextHeaderMenuToFocus, setNextHeaderMenuToFocus] = (0,external_wp_element_namespaceObject.useState)(); 20363 const hasBulkActions = useSomeItemHasAPossibleBulkAction(actions, data); 20364 (0,external_wp_element_namespaceObject.useEffect)(() => { 20365 if (headerMenuToFocusRef.current) { 20366 headerMenuToFocusRef.current.focus(); 20367 headerMenuToFocusRef.current = undefined; 20368 } 20369 }); 20370 const asyncData = (0,external_wp_compose_namespaceObject.useAsyncList)(data); 20371 const tableNoticeId = (0,external_wp_element_namespaceObject.useId)(); 20372 if (nextHeaderMenuToFocus) { 20373 // If we need to force focus, we short-circuit rendering here 20374 // to prevent any additional work while we handle that. 20375 // Clearing out the focus directive is necessary to make sure 20376 // future renders don't cause unexpected focus jumps. 20377 headerMenuToFocusRef.current = nextHeaderMenuToFocus; 20378 setNextHeaderMenuToFocus(); 20379 return; 20380 } 20381 const onHide = field => { 20382 const hidden = headerMenuRefs.current.get(field.id); 20383 const fallback = headerMenuRefs.current.get(hidden.fallback); 20384 setNextHeaderMenuToFocus(fallback?.node); 20385 }; 20386 const visibleFields = fields.filter(field => !view.hiddenFields.includes(field.id) && ![view.layout.mediaField].includes(field.id)); 20387 const usedData = deferredRendering ? asyncData : data; 20388 const hasData = !!usedData?.length; 20389 const sortValues = { 20390 asc: 'ascending', 20391 desc: 'descending' 20392 }; 20393 const primaryField = fields.find(field => field.id === view.layout.primaryField); 20394 return (0,external_React_.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_React_.createElement)("table", { 20395 className: "dataviews-view-table", 20396 "aria-busy": isLoading, 20397 "aria-describedby": tableNoticeId 20398 }, (0,external_React_.createElement)("thead", null, (0,external_React_.createElement)("tr", { 20399 className: "dataviews-view-table__row" 20400 }, hasBulkActions && (0,external_React_.createElement)("th", { 20401 className: "dataviews-view-table__checkbox-column", 20402 style: { 20403 width: 20, 20404 minWidth: 20 20405 }, 20406 "data-field-id": "selection", 20407 scope: "col" 20408 }, (0,external_React_.createElement)(BulkSelectionCheckbox, { 20409 selection: selection, 20410 onSelectionChange: onSelectionChange, 20411 data: data, 20412 actions: actions 20413 })), visibleFields.map((field, index) => (0,external_React_.createElement)("th", { 20414 key: field.id, 20415 style: { 20416 width: field.width || undefined, 20417 minWidth: field.minWidth || undefined, 20418 maxWidth: field.maxWidth || undefined 20419 }, 20420 "data-field-id": field.id, 20421 "aria-sort": view.sort?.field === field.id && sortValues[view.sort.direction], 20422 scope: "col" 20423 }, (0,external_React_.createElement)(HeaderMenu, { 20424 ref: node => { 20425 if (node) { 20426 headerMenuRefs.current.set(field.id, { 20427 node, 20428 fallback: visibleFields[index > 0 ? index - 1 : 1]?.id 20429 }); 20430 } else { 20431 headerMenuRefs.current.delete(field.id); 20432 } 20433 }, 20434 field: field, 20435 view: view, 20436 onChangeView: onChangeView, 20437 onHide: onHide, 20438 setOpenedFilter: setOpenedFilter 20439 }))), !!actions?.length && (0,external_React_.createElement)("th", { 20440 "data-field-id": "actions", 20441 className: "dataviews-view-table__actions-column" 20442 }, (0,external_React_.createElement)("span", { 20443 className: "dataviews-view-table-header" 20444 }, (0,external_wp_i18n_namespaceObject.__)('Actions'))))), (0,external_React_.createElement)("tbody", null, hasData && usedData.map((item, index) => (0,external_React_.createElement)(TableRow, { 20445 key: getItemId(item), 20446 item: item, 20447 hasBulkActions: hasBulkActions, 20448 actions: actions, 20449 id: getItemId(item) || index, 20450 visibleFields: visibleFields, 20451 primaryField: primaryField, 20452 selection: selection, 20453 getItemId: getItemId, 20454 onSelectionChange: onSelectionChange, 20455 data: data 20456 })))), (0,external_React_.createElement)("div", { 20457 className: classnames_default()({ 20458 'dataviews-loading': isLoading, 20459 'dataviews-no-results': !hasData && !isLoading 20460 }), 20461 id: tableNoticeId 20462 }, !hasData && (0,external_React_.createElement)("p", null, isLoading ? (0,external_wp_i18n_namespaceObject.__)('Loading…') : (0,external_wp_i18n_namespaceObject.__)('No results')))); 20463 } 20464 /* harmony default export */ const view_table = (ViewTable); 20465 20466 ;// CONCATENATED MODULE: ./node_modules/@wordpress/dataviews/build-module/view-grid.js 20467 20468 /** 20469 * External dependencies 20470 */ 20471 20472 20473 /** 20474 * WordPress dependencies 20475 */ 20476 20477 20478 20479 20480 20481 /** 20482 * Internal dependencies 20483 */ 20484 20485 20486 20487 function GridItem({ 20488 selection, 20489 data, 20490 onSelectionChange, 20491 getItemId, 20492 item, 20493 actions, 20494 mediaField, 20495 primaryField, 20496 visibleFields 20497 }) { 20498 const [hasNoPointerEvents, setHasNoPointerEvents] = (0,external_wp_element_namespaceObject.useState)(false); 20499 const hasBulkAction = useHasAPossibleBulkAction(actions, item); 20500 const id = getItemId(item); 20501 const isSelected = selection.includes(id); 20502 return (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { 20503 spacing: 0, 20504 key: id, 20505 className: classnames_default()('dataviews-view-grid__card', { 20506 'is-selected': hasBulkAction && isSelected, 20507 'has-no-pointer-events': hasNoPointerEvents 20508 }), 20509 onMouseDown: event => { 20510 if (hasBulkAction && (event.ctrlKey || event.metaKey)) { 20511 setHasNoPointerEvents(true); 20512 if (!isSelected) { 20513 onSelectionChange(data.filter(_item => { 20514 const itemId = getItemId?.(_item); 20515 return itemId === id || selection.includes(itemId); 20516 })); 20517 } else { 20518 onSelectionChange(data.filter(_item => { 20519 const itemId = getItemId?.(_item); 20520 return itemId !== id && selection.includes(itemId); 20521 })); 20522 } 20523 } 20524 }, 20525 onClick: () => { 20526 if (hasNoPointerEvents) { 20527 setHasNoPointerEvents(false); 20528 } 20529 } 20530 }, (0,external_React_.createElement)("div", { 20531 className: "dataviews-view-grid__media" 20532 }, mediaField?.render({ 20533 item 20534 })), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { 20535 justify: "space-between", 20536 className: "dataviews-view-grid__title-actions" 20537 }, (0,external_React_.createElement)(SingleSelectionCheckbox, { 20538 id: id, 20539 item: item, 20540 selection: selection, 20541 onSelectionChange: onSelectionChange, 20542 getItemId: getItemId, 20543 data: data, 20544 primaryField: primaryField, 20545 disabled: !hasBulkAction 20546 }), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { 20547 className: "dataviews-view-grid__primary-field" 20548 }, primaryField?.render({ 20549 item 20550 })), (0,external_React_.createElement)(ItemActions, { 20551 item: item, 20552 actions: actions, 20553 isCompact: true 20554 })), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { 20555 className: "dataviews-view-grid__fields", 20556 spacing: 3 20557 }, visibleFields.map(field => { 20558 const renderedValue = field.render({ 20559 item 20560 }); 20561 if (!renderedValue) { 20562 return null; 20563 } 20564 return (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { 20565 className: "dataviews-view-grid__field", 20566 key: field.id, 20567 spacing: 1 20568 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.Tooltip, { 20569 text: field.header, 20570 placement: "left" 20571 }, (0,external_React_.createElement)("div", { 20572 className: "dataviews-view-grid__field-value" 20573 }, renderedValue))); 20574 }))); 20575 } 20576 function ViewGrid({ 20577 data, 20578 fields, 20579 view, 20580 actions, 20581 isLoading, 20582 getItemId, 20583 deferredRendering, 20584 selection, 20585 onSelectionChange 20586 }) { 20587 const mediaField = fields.find(field => field.id === view.layout.mediaField); 20588 const primaryField = fields.find(field => field.id === view.layout.primaryField); 20589 const visibleFields = fields.filter(field => !view.hiddenFields.includes(field.id) && ![view.layout.mediaField, view.layout.primaryField].includes(field.id)); 20590 const shownData = (0,external_wp_compose_namespaceObject.useAsyncList)(data, { 20591 step: 3 20592 }); 20593 const usedData = deferredRendering ? shownData : data; 20594 const hasData = !!usedData?.length; 20595 return (0,external_React_.createElement)(external_React_.Fragment, null, hasData && (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalGrid, { 20596 gap: 6, 20597 columns: 2, 20598 alignment: "top", 20599 className: "dataviews-view-grid", 20600 "aria-busy": isLoading 20601 }, usedData.map(item => { 20602 return (0,external_React_.createElement)(GridItem, { 20603 key: getItemId(item), 20604 selection: selection, 20605 data: data, 20606 onSelectionChange: onSelectionChange, 20607 getItemId: getItemId, 20608 item: item, 20609 actions: actions, 20610 mediaField: mediaField, 20611 primaryField: primaryField, 20612 visibleFields: visibleFields 20613 }); 20614 })), !hasData && (0,external_React_.createElement)("div", { 20615 className: classnames_default()({ 20616 'dataviews-loading': isLoading, 20617 'dataviews-no-results': !isLoading 20618 }) 20619 }, (0,external_React_.createElement)("p", null, isLoading ? (0,external_wp_i18n_namespaceObject.__)('Loading…') : (0,external_wp_i18n_namespaceObject.__)('No results')))); 20620 } 20621 20622 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/info.js 20623 20624 /** 20625 * WordPress dependencies 20626 */ 20627 20628 const info = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { 20629 xmlns: "http://www.w3.org/2000/svg", 20630 viewBox: "0 0 24 24" 20631 }, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 20632 d: "M12 3.2c-4.8 0-8.8 3.9-8.8 8.8 0 4.8 3.9 8.8 8.8 8.8 4.8 0 8.8-3.9 8.8-8.8 0-4.8-4-8.8-8.8-8.8zm0 16c-4 0-7.2-3.3-7.2-7.2C4.8 8 8 4.8 12 4.8s7.2 3.3 7.2 7.2c0 4-3.2 7.2-7.2 7.2zM11 17h2v-6h-2v6zm0-8h2V7h-2v2z" 20633 })); 20634 /* harmony default export */ const library_info = (info); 20635 20636 ;// CONCATENATED MODULE: ./node_modules/@wordpress/dataviews/build-module/view-list.js 20637 20638 /** 20639 * External dependencies 20640 */ 20641 20642 20643 /** 20644 * WordPress dependencies 20645 */ 20646 20647 20648 20649 20650 20651 function ViewList({ 20652 view, 20653 fields, 20654 data, 20655 isLoading, 20656 getItemId, 20657 onSelectionChange, 20658 onDetailsChange, 20659 selection, 20660 deferredRendering 20661 }) { 20662 const shownData = (0,external_wp_compose_namespaceObject.useAsyncList)(data, { 20663 step: 3 20664 }); 20665 const usedData = deferredRendering ? shownData : data; 20666 const mediaField = fields.find(field => field.id === view.layout.mediaField); 20667 const primaryField = fields.find(field => field.id === view.layout.primaryField); 20668 const visibleFields = fields.filter(field => !view.hiddenFields.includes(field.id) && ![view.layout.primaryField, view.layout.mediaField].includes(field.id)); 20669 const onEnter = item => event => { 20670 const { 20671 keyCode 20672 } = event; 20673 if ([external_wp_keycodes_namespaceObject.ENTER, external_wp_keycodes_namespaceObject.SPACE].includes(keyCode)) { 20674 onSelectionChange([item]); 20675 } 20676 }; 20677 const hasData = usedData?.length; 20678 if (!hasData) { 20679 return (0,external_React_.createElement)("div", { 20680 className: classnames_default()({ 20681 'dataviews-loading': isLoading, 20682 'dataviews-no-results': !hasData && !isLoading 20683 }) 20684 }, !hasData && (0,external_React_.createElement)("p", null, isLoading ? (0,external_wp_i18n_namespaceObject.__)('Loading…') : (0,external_wp_i18n_namespaceObject.__)('No results'))); 20685 } 20686 return (0,external_React_.createElement)("ul", { 20687 className: "dataviews-view-list" 20688 }, usedData.map(item => { 20689 return (0,external_React_.createElement)("li", { 20690 key: getItemId(item), 20691 className: classnames_default()({ 20692 'is-selected': selection.includes(item.id) 20693 }) 20694 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { 20695 className: "dataviews-view-list__item-wrapper" 20696 }, (0,external_React_.createElement)("div", { 20697 role: "button", 20698 tabIndex: 0, 20699 "aria-pressed": selection.includes(item.id), 20700 onKeyDown: onEnter(item), 20701 className: "dataviews-view-list__item", 20702 onClick: () => onSelectionChange([item]) 20703 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { 20704 spacing: 3, 20705 justify: "start", 20706 alignment: "flex-start" 20707 }, (0,external_React_.createElement)("div", { 20708 className: "dataviews-view-list__media-wrapper" 20709 }, mediaField?.render({ 20710 item 20711 }) || (0,external_React_.createElement)("div", { 20712 className: "dataviews-view-list__media-placeholder" 20713 })), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { 20714 spacing: 1 20715 }, (0,external_React_.createElement)("span", { 20716 className: "dataviews-view-list__primary-field" 20717 }, primaryField?.render({ 20718 item 20719 })), (0,external_React_.createElement)("div", { 20720 className: "dataviews-view-list__fields" 20721 }, visibleFields.map(field => { 20722 return (0,external_React_.createElement)("span", { 20723 key: field.id, 20724 className: "dataviews-view-list__field" 20725 }, field.render({ 20726 item 20727 })); 20728 }))))), onDetailsChange && (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 20729 className: "dataviews-view-list__details-button", 20730 onClick: () => onDetailsChange([item]), 20731 icon: library_info, 20732 label: (0,external_wp_i18n_namespaceObject.__)('View details'), 20733 size: "compact" 20734 }))); 20735 })); 20736 } 20737 20738 ;// CONCATENATED MODULE: ./node_modules/@wordpress/dataviews/build-module/constants.js 20739 /** 20740 * WordPress dependencies 20741 */ 20742 20743 20744 20745 /** 20746 * Internal dependencies 20747 */ 20748 20749 20750 20751 20752 // Field types. 20753 const constants_ENUMERATION_TYPE = 'enumeration'; 20754 20755 // Filter operators. 20756 const constants_OPERATOR_IN = 'in'; 20757 const constants_OPERATOR_NOT_IN = 'notIn'; 20758 const OPERATORS = { 20759 [constants_OPERATOR_IN]: { 20760 key: 'in-filter', 20761 label: (0,external_wp_i18n_namespaceObject.__)('Is') 20762 }, 20763 [constants_OPERATOR_NOT_IN]: { 20764 key: 'not-in-filter', 20765 label: (0,external_wp_i18n_namespaceObject.__)('Is not') 20766 } 20767 }; 20768 20769 // Sorting 20770 const SORTING_DIRECTIONS = { 20771 asc: { 20772 label: (0,external_wp_i18n_namespaceObject.__)('Sort ascending') 20773 }, 20774 desc: { 20775 label: (0,external_wp_i18n_namespaceObject.__)('Sort descending') 20776 } 20777 }; 20778 20779 // View layouts. 20780 const constants_LAYOUT_TABLE = 'table'; 20781 const constants_LAYOUT_GRID = 'grid'; 20782 const constants_LAYOUT_LIST = 'list'; 20783 const VIEW_LAYOUTS = [{ 20784 type: constants_LAYOUT_TABLE, 20785 label: (0,external_wp_i18n_namespaceObject.__)('Table'), 20786 component: view_table, 20787 icon: block_table 20788 }, { 20789 type: constants_LAYOUT_GRID, 20790 label: (0,external_wp_i18n_namespaceObject.__)('Grid'), 20791 component: ViewGrid, 20792 icon: library_category 20793 }, { 20794 type: constants_LAYOUT_LIST, 20795 label: (0,external_wp_i18n_namespaceObject.__)('List'), 20796 component: ViewList, 20797 icon: (0,external_wp_i18n_namespaceObject.isRTL)() ? format_list_bullets_rtl : format_list_bullets 20798 }]; 20799 20800 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sidebar-dataviews/dataview-item.js 20801 20802 /** 20803 * External dependencies 20804 */ 20805 20806 20807 /** 20808 * WordPress dependencies 20809 */ 20810 20811 20812 20813 20814 /** 20815 * Internal dependencies 20816 */ 20817 20818 20819 20820 const { 20821 useLocation: dataview_item_useLocation 20822 } = unlock(external_wp_router_namespaceObject.privateApis); 20823 function DataViewItem({ 20824 title, 20825 slug, 20826 customViewId, 20827 type, 20828 icon, 20829 isActive, 20830 isCustom, 20831 suffix 20832 }) { 20833 const { 20834 params: { 20835 path, 20836 layout 20837 } 20838 } = dataview_item_useLocation(); 20839 const iconToUse = icon || VIEW_LAYOUTS.find(v => v.type === type).icon; 20840 const linkInfo = useLink({ 20841 path, 20842 layout, 20843 activeView: isCustom === 'true' ? customViewId : slug, 20844 isCustom 20845 }); 20846 return (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { 20847 justify: "flex-start", 20848 className: classnames_default()('edit-site-sidebar-dataviews-dataview-item', { 20849 'is-selected': isActive 20850 }) 20851 }, (0,external_React_.createElement)(SidebarNavigationItem, { 20852 icon: iconToUse, 20853 ...linkInfo, 20854 "aria-current": isActive ? 'true' : undefined 20855 }, title), suffix); 20856 } 20857 20858 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sidebar-navigation-screen-templates-browse/content.js 20859 20860 /** 20861 * WordPress dependencies 20862 */ 20863 20864 20865 20866 20867 /** 20868 * Internal dependencies 20869 */ 20870 20871 20872 20873 const content_EMPTY_ARRAY = []; 20874 function TemplateDataviewItem({ 20875 template, 20876 isActive 20877 }) { 20878 const { 20879 text, 20880 icon 20881 } = useAddedBy(template.type, template.id); 20882 return (0,external_React_.createElement)(DataViewItem, { 20883 key: text, 20884 slug: text, 20885 title: text, 20886 icon: icon, 20887 isActive: isActive, 20888 isCustom: "false" 20889 }); 20890 } 20891 function DataviewsTemplatesSidebarContent({ 20892 activeView, 20893 postType, 20894 title 20895 }) { 20896 const { 20897 records 20898 } = (0,external_wp_coreData_namespaceObject.useEntityRecords)('postType', postType, { 20899 per_page: -1 20900 }); 20901 const firstItemPerAuthorText = (0,external_wp_element_namespaceObject.useMemo)(() => { 20902 var _ref; 20903 const firstItemPerAuthor = records?.reduce((acc, template) => { 20904 const author = template.author_text; 20905 if (author && !acc[author]) { 20906 acc[author] = template; 20907 } 20908 return acc; 20909 }, {}); 20910 return (_ref = firstItemPerAuthor && Object.values(firstItemPerAuthor)) !== null && _ref !== void 0 ? _ref : content_EMPTY_ARRAY; 20911 }, [records]); 20912 return (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalItemGroup, null, (0,external_React_.createElement)(DataViewItem, { 20913 slug: 'all', 20914 title: title, 20915 icon: library_layout, 20916 isActive: activeView === 'all', 20917 isCustom: "false" 20918 }), firstItemPerAuthorText.map(template => { 20919 return (0,external_React_.createElement)(TemplateDataviewItem, { 20920 key: template.author_text, 20921 template: template, 20922 isActive: activeView === template.author_text 20923 }); 20924 })); 20925 } 20926 20927 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sidebar-navigation-screen-templates-browse/index.js 20928 20929 /** 20930 * WordPress dependencies 20931 */ 20932 20933 20934 20935 20936 20937 /** 20938 * Internal dependencies 20939 */ 20940 20941 20942 20943 20944 20945 const config = { 20946 [constants_TEMPLATE_POST_TYPE]: { 20947 title: (0,external_wp_i18n_namespaceObject.__)('Manage templates'), 20948 description: (0,external_wp_i18n_namespaceObject.__)('Create new templates, or reset any customizations made to the templates supplied by your theme.'), 20949 contentTitle: (0,external_wp_i18n_namespaceObject.__)('All templates') 20950 }, 20951 [TEMPLATE_PART_POST_TYPE]: { 20952 title: (0,external_wp_i18n_namespaceObject.__)('Manage template parts'), 20953 description: (0,external_wp_i18n_namespaceObject.__)('Create new template parts, or reset any customizations made to the template parts supplied by your theme.'), 20954 backPath: '/patterns', 20955 contentTitle: (0,external_wp_i18n_namespaceObject.__)('All template parts') 20956 } 20957 }; 20958 const { 20959 useLocation: sidebar_navigation_screen_templates_browse_useLocation 20960 } = unlock(external_wp_router_namespaceObject.privateApis); 20961 function SidebarNavigationScreenTemplatesBrowse() { 20962 const { 20963 params: { 20964 postType 20965 } 20966 } = (0,external_wp_components_namespaceObject.__experimentalUseNavigator)(); 20967 const { 20968 params: { 20969 didAccessPatternsPage, 20970 activeView = 'all' 20971 } 20972 } = sidebar_navigation_screen_templates_browse_useLocation(); 20973 const isTemplatePartsMode = (0,external_wp_data_namespaceObject.useSelect)(select => { 20974 return !!select(store_store).getSettings().supportsTemplatePartsMode; 20975 }, []); 20976 return (0,external_React_.createElement)(SidebarNavigationScreen 20977 // If a classic theme that supports template parts has never 20978 // accessed the Patterns page, return to the dashboard. 20979 , { 20980 isRoot: isTemplatePartsMode && !didAccessPatternsPage, 20981 title: config[postType].title, 20982 description: config[postType].description, 20983 backPath: config[postType].backPath, 20984 content: (0,external_React_.createElement)(DataviewsTemplatesSidebarContent, { 20985 activeView: activeView, 20986 postType: postType, 20987 title: config[postType].contentTitle 20988 }) 20989 }); 20990 } 20991 20992 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/save-button/index.js 20993 20994 /** 20995 * WordPress dependencies 20996 */ 20997 20998 20999 21000 21001 21002 21003 /** 21004 * Internal dependencies 21005 */ 21006 21007 21008 function SaveButton({ 21009 className = 'edit-site-save-button__button', 21010 variant = 'primary', 21011 showTooltip = true, 21012 defaultLabel, 21013 icon, 21014 __next40pxDefaultSize = false 21015 }) { 21016 const { 21017 isDirty, 21018 isSaving, 21019 isSaveViewOpen, 21020 previewingThemeName 21021 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 21022 const { 21023 __experimentalGetDirtyEntityRecords, 21024 isSavingEntityRecord, 21025 isResolving 21026 } = select(external_wp_coreData_namespaceObject.store); 21027 const dirtyEntityRecords = __experimentalGetDirtyEntityRecords(); 21028 const { 21029 isSaveViewOpened 21030 } = select(store_store); 21031 const isActivatingTheme = isResolving('activateTheme'); 21032 const currentlyPreviewingThemeId = currentlyPreviewingTheme(); 21033 return { 21034 isDirty: dirtyEntityRecords.length > 0, 21035 isSaving: dirtyEntityRecords.some(record => isSavingEntityRecord(record.kind, record.name, record.key)) || isActivatingTheme, 21036 isSaveViewOpen: isSaveViewOpened(), 21037 // Do not call `getTheme` with null, it will cause a request to 21038 // the server. 21039 previewingThemeName: currentlyPreviewingThemeId ? select(external_wp_coreData_namespaceObject.store).getTheme(currentlyPreviewingThemeId)?.name?.rendered : undefined 21040 }; 21041 }, []); 21042 const { 21043 setIsSaveViewOpened 21044 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store); 21045 const activateSaveEnabled = isPreviewingTheme() || isDirty; 21046 const disabled = isSaving || !activateSaveEnabled; 21047 const getLabel = () => { 21048 if (isPreviewingTheme()) { 21049 if (isSaving) { 21050 return (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: The name of theme to be activated. */ 21051 (0,external_wp_i18n_namespaceObject.__)('Activating %s'), previewingThemeName); 21052 } else if (disabled) { 21053 return (0,external_wp_i18n_namespaceObject.__)('Saved'); 21054 } else if (isDirty) { 21055 return (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: The name of theme to be activated. */ 21056 (0,external_wp_i18n_namespaceObject.__)('Activate %s & Save'), previewingThemeName); 21057 } 21058 return (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: The name of theme to be activated. */ 21059 (0,external_wp_i18n_namespaceObject.__)('Activate %s'), previewingThemeName); 21060 } 21061 if (isSaving) { 21062 return (0,external_wp_i18n_namespaceObject.__)('Saving'); 21063 } else if (disabled) { 21064 return (0,external_wp_i18n_namespaceObject.__)('Saved'); 21065 } else if (defaultLabel) { 21066 return defaultLabel; 21067 } 21068 return (0,external_wp_i18n_namespaceObject.__)('Save'); 21069 }; 21070 const label = getLabel(); 21071 return (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 21072 variant: variant, 21073 className: className, 21074 "aria-disabled": disabled, 21075 "aria-expanded": isSaveViewOpen, 21076 isBusy: isSaving, 21077 onClick: disabled ? undefined : () => setIsSaveViewOpened(true), 21078 label: label 21079 /* 21080 * We want the tooltip to show the keyboard shortcut only when the 21081 * button does something, i.e. when it's not disabled. 21082 */, 21083 shortcut: disabled ? undefined : external_wp_keycodes_namespaceObject.displayShortcut.primary('s') 21084 /* 21085 * Displaying the keyboard shortcut conditionally makes the tooltip 21086 * itself show conditionally. This would trigger a full-rerendering 21087 * of the button that we want to avoid. By setting `showTooltip`, 21088 * the tooltip is always rendered even when there's no keyboard shortcut. 21089 */, 21090 showTooltip: showTooltip, 21091 icon: icon, 21092 __next40pxDefaultSize: __next40pxDefaultSize, 21093 size: "compact" 21094 }, label); 21095 } 21096 21097 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/save-hub/index.js 21098 21099 /** 21100 * WordPress dependencies 21101 */ 21102 21103 21104 21105 21106 21107 21108 21109 21110 21111 /** 21112 * Internal dependencies 21113 */ 21114 21115 21116 21117 21118 const { 21119 useLocation: save_hub_useLocation 21120 } = unlock(external_wp_router_namespaceObject.privateApis); 21121 const PUBLISH_ON_SAVE_ENTITIES = [{ 21122 kind: 'postType', 21123 name: NAVIGATION_POST_TYPE 21124 }]; 21125 function SaveHub() { 21126 const saveNoticeId = 'site-edit-save-notice'; 21127 const { 21128 params 21129 } = save_hub_useLocation(); 21130 const { 21131 __unstableMarkLastChangeAsPersistent 21132 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store); 21133 const { 21134 createSuccessNotice, 21135 createErrorNotice, 21136 removeNotice 21137 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store); 21138 const { 21139 dirtyCurrentEntity, 21140 countUnsavedChanges, 21141 isDirty, 21142 isSaving 21143 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 21144 const { 21145 __experimentalGetDirtyEntityRecords, 21146 isSavingEntityRecord 21147 } = select(external_wp_coreData_namespaceObject.store); 21148 const dirtyEntityRecords = __experimentalGetDirtyEntityRecords(); 21149 let calcDirtyCurrentEntity = null; 21150 if (dirtyEntityRecords.length === 1) { 21151 // if we are on global styles 21152 if (params.path?.includes('wp_global_styles')) { 21153 calcDirtyCurrentEntity = dirtyEntityRecords.find(record => record.name === 'globalStyles'); 21154 } 21155 // if we are on pages 21156 else if (params.postId) { 21157 calcDirtyCurrentEntity = dirtyEntityRecords.find(record => record.name === params.postType && String(record.key) === params.postId); 21158 } 21159 } 21160 return { 21161 dirtyCurrentEntity: calcDirtyCurrentEntity, 21162 isDirty: dirtyEntityRecords.length > 0, 21163 isSaving: dirtyEntityRecords.some(record => isSavingEntityRecord(record.kind, record.name, record.key)), 21164 countUnsavedChanges: dirtyEntityRecords.length 21165 }; 21166 }, [params.path, params.postType, params.postId]); 21167 const { 21168 editEntityRecord, 21169 saveEditedEntityRecord, 21170 __experimentalSaveSpecifiedEntityEdits: saveSpecifiedEntityEdits 21171 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store); 21172 const disabled = isSaving || !isDirty && !isPreviewingTheme(); 21173 21174 // if we have only one unsaved change and it matches current context, we can show a more specific label 21175 let label = dirtyCurrentEntity ? (0,external_wp_i18n_namespaceObject.__)('Save') : (0,external_wp_i18n_namespaceObject.sprintf)( 21176 // translators: %d: number of unsaved changes (number). 21177 (0,external_wp_i18n_namespaceObject._n)('Review %d change…', 'Review %d changes…', countUnsavedChanges), countUnsavedChanges); 21178 if (isSaving) { 21179 label = (0,external_wp_i18n_namespaceObject.__)('Saving'); 21180 } 21181 const { 21182 homeUrl 21183 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 21184 const { 21185 getUnstableBase // Site index. 21186 } = select(external_wp_coreData_namespaceObject.store); 21187 return { 21188 homeUrl: getUnstableBase()?.home 21189 }; 21190 }, []); 21191 const saveCurrentEntity = async () => { 21192 if (!dirtyCurrentEntity) return; 21193 removeNotice(saveNoticeId); 21194 const { 21195 kind, 21196 name, 21197 key, 21198 property 21199 } = dirtyCurrentEntity; 21200 try { 21201 if ('root' === dirtyCurrentEntity.kind && 'site' === name) { 21202 await saveSpecifiedEntityEdits('root', 'site', undefined, [property]); 21203 } else { 21204 if (PUBLISH_ON_SAVE_ENTITIES.some(typeToPublish => typeToPublish.kind === kind && typeToPublish.name === name)) { 21205 editEntityRecord(kind, name, key, { 21206 status: 'publish' 21207 }); 21208 } 21209 await saveEditedEntityRecord(kind, name, key); 21210 } 21211 __unstableMarkLastChangeAsPersistent(); 21212 createSuccessNotice((0,external_wp_i18n_namespaceObject.__)('Site updated.'), { 21213 type: 'snackbar', 21214 actions: [{ 21215 label: (0,external_wp_i18n_namespaceObject.__)('View site'), 21216 url: homeUrl 21217 }], 21218 id: saveNoticeId 21219 }); 21220 } catch (error) { 21221 createErrorNotice(`${(0,external_wp_i18n_namespaceObject.__)('Saving failed.')} $error}`); 21222 } 21223 }; 21224 return (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { 21225 className: "edit-site-save-hub", 21226 alignment: "right", 21227 spacing: 4 21228 }, dirtyCurrentEntity ? (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 21229 variant: "primary", 21230 onClick: saveCurrentEntity, 21231 isBusy: isSaving, 21232 disabled: isSaving, 21233 "aria-disabled": isSaving, 21234 className: "edit-site-save-hub__button", 21235 __next40pxDefaultSize: true 21236 }, label) : (0,external_React_.createElement)(SaveButton, { 21237 className: "edit-site-save-hub__button", 21238 variant: disabled ? null : 'primary', 21239 showTooltip: false, 21240 icon: disabled && !isSaving ? library_check : null, 21241 defaultLabel: label, 21242 __next40pxDefaultSize: true 21243 })); 21244 } 21245 21246 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/add-new-page/index.js 21247 21248 /** 21249 * WordPress dependencies 21250 */ 21251 21252 21253 21254 21255 21256 21257 function AddNewPageModal({ 21258 onSave, 21259 onClose 21260 }) { 21261 const [isCreatingPage, setIsCreatingPage] = (0,external_wp_element_namespaceObject.useState)(false); 21262 const [title, setTitle] = (0,external_wp_element_namespaceObject.useState)(''); 21263 const { 21264 saveEntityRecord 21265 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store); 21266 const { 21267 createErrorNotice, 21268 createSuccessNotice 21269 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store); 21270 async function createPage(event) { 21271 event.preventDefault(); 21272 if (isCreatingPage) { 21273 return; 21274 } 21275 setIsCreatingPage(true); 21276 try { 21277 const newPage = await saveEntityRecord('postType', 'page', { 21278 status: 'draft', 21279 title, 21280 slug: title || (0,external_wp_i18n_namespaceObject.__)('No title') 21281 }, { 21282 throwOnError: true 21283 }); 21284 onSave(newPage); 21285 createSuccessNotice((0,external_wp_i18n_namespaceObject.sprintf)( 21286 // translators: %s: Title of the created template e.g: "Category". 21287 (0,external_wp_i18n_namespaceObject.__)('"%s" successfully created.'), newPage.title?.rendered || title), { 21288 type: 'snackbar' 21289 }); 21290 } catch (error) { 21291 const errorMessage = error.message && error.code !== 'unknown_error' ? error.message : (0,external_wp_i18n_namespaceObject.__)('An error occurred while creating the page.'); 21292 createErrorNotice(errorMessage, { 21293 type: 'snackbar' 21294 }); 21295 } finally { 21296 setIsCreatingPage(false); 21297 } 21298 } 21299 return (0,external_React_.createElement)(external_wp_components_namespaceObject.Modal, { 21300 title: (0,external_wp_i18n_namespaceObject.__)('Draft a new page'), 21301 onRequestClose: onClose 21302 }, (0,external_React_.createElement)("form", { 21303 onSubmit: createPage 21304 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { 21305 spacing: 3 21306 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.TextControl, { 21307 label: (0,external_wp_i18n_namespaceObject.__)('Page title'), 21308 onChange: setTitle, 21309 placeholder: (0,external_wp_i18n_namespaceObject.__)('No title'), 21310 value: title 21311 }), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { 21312 spacing: 2, 21313 justify: "end" 21314 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 21315 variant: "tertiary", 21316 onClick: onClose 21317 }, (0,external_wp_i18n_namespaceObject.__)('Cancel')), (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 21318 variant: "primary", 21319 type: "submit", 21320 isBusy: isCreatingPage, 21321 "aria-disabled": isCreatingPage 21322 }, (0,external_wp_i18n_namespaceObject.__)('Create draft')))))); 21323 } 21324 21325 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sidebar-navigation-screen-pages/index.js 21326 21327 /** 21328 * WordPress dependencies 21329 */ 21330 21331 21332 21333 21334 21335 21336 21337 21338 21339 21340 /** 21341 * Internal dependencies 21342 */ 21343 21344 21345 21346 21347 21348 21349 21350 const { 21351 useHistory: sidebar_navigation_screen_pages_useHistory 21352 } = unlock(external_wp_router_namespaceObject.privateApis); 21353 const PageItem = ({ 21354 postType = 'page', 21355 postId, 21356 ...props 21357 }) => { 21358 const linkInfo = useLink({ 21359 postType, 21360 postId 21361 }, { 21362 backPath: '/page' 21363 }); 21364 return (0,external_React_.createElement)(SidebarNavigationItem, { 21365 ...linkInfo, 21366 ...props 21367 }); 21368 }; 21369 function SidebarNavigationScreenPages() { 21370 const isMobileViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium', '<'); 21371 const { 21372 records: pages, 21373 isResolving: isLoadingPages 21374 } = (0,external_wp_coreData_namespaceObject.useEntityRecords)('postType', 'page', { 21375 status: 'any', 21376 per_page: -1 21377 }); 21378 const { 21379 records: templates, 21380 isResolving: isLoadingTemplates 21381 } = (0,external_wp_coreData_namespaceObject.useEntityRecords)('postType', constants_TEMPLATE_POST_TYPE, { 21382 per_page: -1 21383 }); 21384 const dynamicPageTemplates = templates?.filter(({ 21385 slug 21386 }) => ['404', 'search'].includes(slug)); 21387 const homeTemplate = templates?.find(template => template.slug === 'front-page') || templates?.find(template => template.slug === 'home') || templates?.find(template => template.slug === 'index'); 21388 const getPostsPageTemplate = () => templates?.find(template => template.slug === 'home') || templates?.find(template => template.slug === 'index'); 21389 const pagesAndTemplates = pages?.concat(dynamicPageTemplates, [homeTemplate]); 21390 const { 21391 frontPage, 21392 postsPage 21393 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 21394 const { 21395 getEntityRecord 21396 } = select(external_wp_coreData_namespaceObject.store); 21397 const siteSettings = getEntityRecord('root', 'site'); 21398 return { 21399 frontPage: siteSettings?.page_on_front, 21400 postsPage: siteSettings?.page_for_posts 21401 }; 21402 }, []); 21403 const isHomePageBlog = frontPage === postsPage; 21404 const reorderedPages = pages && [...pages]; 21405 if (!isHomePageBlog && reorderedPages?.length) { 21406 const homePageIndex = reorderedPages.findIndex(item => item.id === frontPage); 21407 const homePage = reorderedPages.splice(homePageIndex, 1); 21408 reorderedPages?.splice(0, 0, ...homePage); 21409 const postsPageIndex = reorderedPages.findIndex(item => item.id === postsPage); 21410 const blogPage = reorderedPages.splice(postsPageIndex, 1); 21411 reorderedPages.splice(1, 0, ...blogPage); 21412 } 21413 const [showAddPage, setShowAddPage] = (0,external_wp_element_namespaceObject.useState)(false); 21414 const history = sidebar_navigation_screen_pages_useHistory(); 21415 const handleNewPage = ({ 21416 type, 21417 id 21418 }) => { 21419 // Navigate to the created template editor. 21420 history.push({ 21421 postId: id, 21422 postType: type, 21423 canvas: 'edit' 21424 }); 21425 setShowAddPage(false); 21426 }; 21427 const getPageProps = id => { 21428 let itemIcon = library_page; 21429 const postsPageTemplateId = postsPage && postsPage === id ? getPostsPageTemplate()?.id : null; 21430 switch (id) { 21431 case frontPage: 21432 itemIcon = library_home; 21433 break; 21434 case postsPage: 21435 itemIcon = library_verse; 21436 break; 21437 } 21438 return { 21439 icon: itemIcon, 21440 postType: postsPageTemplateId ? constants_TEMPLATE_POST_TYPE : 'page', 21441 postId: postsPageTemplateId || id 21442 }; 21443 }; 21444 const pagesLink = useLink({ 21445 path: '/pages' 21446 }); 21447 return (0,external_React_.createElement)(external_React_.Fragment, null, showAddPage && (0,external_React_.createElement)(AddNewPageModal, { 21448 onSave: handleNewPage, 21449 onClose: () => setShowAddPage(false) 21450 }), (0,external_React_.createElement)(SidebarNavigationScreen, { 21451 title: (0,external_wp_i18n_namespaceObject.__)('Pages'), 21452 description: (0,external_wp_i18n_namespaceObject.__)('Browse and manage pages.'), 21453 actions: (0,external_React_.createElement)(SidebarButton, { 21454 icon: library_plus, 21455 label: (0,external_wp_i18n_namespaceObject.__)('Draft a new page'), 21456 onClick: () => setShowAddPage(true) 21457 }), 21458 content: (0,external_React_.createElement)(external_React_.Fragment, null, (isLoadingPages || isLoadingTemplates) && (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalItemGroup, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalItem, null, (0,external_wp_i18n_namespaceObject.__)('Loading pages…'))), !(isLoadingPages || isLoadingTemplates) && (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalItemGroup, null, !pagesAndTemplates?.length && (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalItem, null, (0,external_wp_i18n_namespaceObject.__)('No page found')), isHomePageBlog && homeTemplate && (0,external_React_.createElement)(PageItem, { 21459 postType: constants_TEMPLATE_POST_TYPE, 21460 postId: homeTemplate.id, 21461 key: homeTemplate.id, 21462 icon: library_home, 21463 withChevron: true 21464 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalTruncate, { 21465 numberOfLines: 1 21466 }, (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(homeTemplate.title?.rendered || (0,external_wp_i18n_namespaceObject.__)('(no title)')))), reorderedPages?.map(({ 21467 id, 21468 title 21469 }) => (0,external_React_.createElement)(PageItem, { 21470 ...getPageProps(id), 21471 key: id, 21472 withChevron: true 21473 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalTruncate, { 21474 numberOfLines: 1 21475 }, (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(title?.rendered || (0,external_wp_i18n_namespaceObject.__)('(no title)'))))))), 21476 footer: (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { 21477 spacing: 0 21478 }, dynamicPageTemplates?.map(item => (0,external_React_.createElement)(PageItem, { 21479 postType: constants_TEMPLATE_POST_TYPE, 21480 postId: item.id, 21481 key: item.id, 21482 icon: library_layout, 21483 withChevron: true 21484 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalTruncate, { 21485 numberOfLines: 1 21486 }, (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(item.title?.rendered || (0,external_wp_i18n_namespaceObject.__)('(no title)'))))), !isMobileViewport && (0,external_React_.createElement)(SidebarNavigationItem, { 21487 className: "edit-site-sidebar-navigation-screen-pages__see-all", 21488 ...pagesLink 21489 }, (0,external_wp_i18n_namespaceObject.__)('Manage all pages'))) 21490 })); 21491 } 21492 21493 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/pages.js 21494 21495 /** 21496 * WordPress dependencies 21497 */ 21498 21499 const pages = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { 21500 xmlns: "http://www.w3.org/2000/svg", 21501 viewBox: "0 0 24 24" 21502 }, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 21503 d: "M14.5 5.5h-7V7h7V5.5ZM7.5 9h7v1.5h-7V9Zm7 3.5h-7V14h7v-1.5Z" 21504 }), (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 21505 d: "M16 2H6a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2ZM6 3.5h10a.5.5 0 0 1 .5.5v12a.5.5 0 0 1-.5.5H6a.5.5 0 0 1-.5-.5V4a.5.5 0 0 1 .5-.5Z" 21506 }), (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 21507 d: "M20 8v11c0 .69-.31 1-.999 1H6v1.5h13.001c1.52 0 2.499-.982 2.499-2.5V8H20Z" 21508 })); 21509 /* harmony default export */ const library_pages = (pages); 21510 21511 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/drafts.js 21512 21513 /** 21514 * WordPress dependencies 21515 */ 21516 21517 const drafts = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { 21518 xmlns: "http://www.w3.org/2000/svg", 21519 viewBox: "0 0 24 24" 21520 }, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 21521 fillRule: "evenodd", 21522 clipRule: "evenodd", 21523 d: "M8 2H6a2 2 0 0 0-2 2v2.4h1.5V4a.5.5 0 0 1 .5-.5h2V2ZM4 13.6V16a2 2 0 0 0 2 2h2v-1.5H6a.5.5 0 0 1-.5-.5v-2.4H4Zm0-1.2h1.5V7.6H4v4.8ZM9 2v1.5h4V2H9Zm5 0v1.5h2a.5.5 0 0 1 .5.5v2.4H18V4a2 2 0 0 0-2-2h-2Zm4 5.6h-1.5v4.8H18V7.6Zm0 6h-1.5V16a.5.5 0 0 1-.5.5h-2V18h2a2 2 0 0 0 2-2v-2.4ZM13 18v-1.5H9V18h4ZM7 7.25h8v-1.5H7v1.5Zm0 3.25h6V9H7v1.5ZM21.75 19V6h-1.5v13c0 .69-.56 1.25-1.25 1.25H8v1.5h11A2.75 2.75 0 0 0 21.75 19Z" 21524 })); 21525 /* harmony default export */ const library_drafts = (drafts); 21526 21527 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/trash.js 21528 21529 /** 21530 * WordPress dependencies 21531 */ 21532 21533 const trash = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { 21534 xmlns: "http://www.w3.org/2000/svg", 21535 viewBox: "0 0 24 24" 21536 }, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 21537 fillRule: "evenodd", 21538 clipRule: "evenodd", 21539 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" 21540 })); 21541 /* harmony default export */ const library_trash = (trash); 21542 21543 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sidebar-dataviews/default-views.js 21544 /** 21545 * WordPress dependencies 21546 */ 21547 21548 21549 21550 /** 21551 * Internal dependencies 21552 */ 21553 21554 const DEFAULT_CONFIG_PER_VIEW_TYPE = { 21555 [LAYOUT_TABLE]: { 21556 primaryField: 'title' 21557 }, 21558 [LAYOUT_GRID]: { 21559 mediaField: 'featured-image', 21560 primaryField: 'title' 21561 }, 21562 [LAYOUT_LIST]: { 21563 primaryField: 'title', 21564 mediaField: 'featured-image' 21565 } 21566 }; 21567 const DEFAULT_PAGE_BASE = { 21568 type: LAYOUT_TABLE, 21569 search: '', 21570 filters: [], 21571 page: 1, 21572 perPage: 20, 21573 sort: { 21574 field: 'date', 21575 direction: 'desc' 21576 }, 21577 // All fields are visible by default, so it's 21578 // better to keep track of the hidden ones. 21579 hiddenFields: ['date', 'featured-image'], 21580 layout: { 21581 ...DEFAULT_CONFIG_PER_VIEW_TYPE[LAYOUT_TABLE] 21582 } 21583 }; 21584 const DEFAULT_VIEWS = { 21585 page: [{ 21586 title: (0,external_wp_i18n_namespaceObject.__)('All pages'), 21587 slug: 'all', 21588 icon: library_pages, 21589 view: DEFAULT_PAGE_BASE 21590 }, { 21591 title: (0,external_wp_i18n_namespaceObject.__)('Drafts'), 21592 slug: 'drafts', 21593 icon: library_drafts, 21594 view: { 21595 ...DEFAULT_PAGE_BASE, 21596 filters: [{ 21597 field: 'status', 21598 operator: OPERATOR_IN, 21599 value: 'draft' 21600 }] 21601 } 21602 }, { 21603 title: (0,external_wp_i18n_namespaceObject.__)('Trash'), 21604 slug: 'trash', 21605 icon: library_trash, 21606 view: { 21607 ...DEFAULT_PAGE_BASE, 21608 filters: [{ 21609 field: 'status', 21610 operator: OPERATOR_IN, 21611 value: 'trash' 21612 }] 21613 } 21614 }] 21615 }; 21616 21617 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sidebar-dataviews/add-new-view.js 21618 21619 /** 21620 * WordPress dependencies 21621 */ 21622 21623 21624 21625 21626 21627 21628 21629 21630 /** 21631 * Internal dependencies 21632 */ 21633 21634 21635 21636 const { 21637 useHistory: add_new_view_useHistory, 21638 useLocation: add_new_view_useLocation 21639 } = unlock(external_wp_router_namespaceObject.privateApis); 21640 function AddNewItemModalContent({ 21641 type, 21642 setIsAdding 21643 }) { 21644 const { 21645 params: { 21646 path 21647 } 21648 } = add_new_view_useLocation(); 21649 const history = add_new_view_useHistory(); 21650 const { 21651 saveEntityRecord 21652 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store); 21653 const [title, setTitle] = (0,external_wp_element_namespaceObject.useState)(''); 21654 const [isSaving, setIsSaving] = (0,external_wp_element_namespaceObject.useState)(false); 21655 return (0,external_React_.createElement)("form", { 21656 onSubmit: async event => { 21657 event.preventDefault(); 21658 setIsSaving(true); 21659 const { 21660 getEntityRecords 21661 } = (0,external_wp_data_namespaceObject.resolveSelect)(external_wp_coreData_namespaceObject.store); 21662 let dataViewTaxonomyId; 21663 const dataViewTypeRecords = await getEntityRecords('taxonomy', 'wp_dataviews_type', { 21664 slug: type 21665 }); 21666 if (dataViewTypeRecords && dataViewTypeRecords.length > 0) { 21667 dataViewTaxonomyId = dataViewTypeRecords[0].id; 21668 } else { 21669 const record = await saveEntityRecord('taxonomy', 'wp_dataviews_type', { 21670 name: type 21671 }); 21672 if (record && record.id) { 21673 dataViewTaxonomyId = record.id; 21674 } 21675 } 21676 const savedRecord = await saveEntityRecord('postType', 'wp_dataviews', { 21677 title, 21678 status: 'publish', 21679 wp_dataviews_type: dataViewTaxonomyId, 21680 content: JSON.stringify(DEFAULT_VIEWS[type][0].view) 21681 }); 21682 history.push({ 21683 path, 21684 activeView: savedRecord.id, 21685 isCustom: 'true' 21686 }); 21687 setIsSaving(false); 21688 setIsAdding(false); 21689 } 21690 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { 21691 spacing: "5" 21692 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.TextControl, { 21693 __nextHasNoMarginBottom: true, 21694 label: (0,external_wp_i18n_namespaceObject.__)('Name'), 21695 value: title, 21696 onChange: setTitle, 21697 placeholder: (0,external_wp_i18n_namespaceObject.__)('My view'), 21698 className: "patterns-create-modal__name-input" 21699 }), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { 21700 justify: "right" 21701 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 21702 variant: "tertiary", 21703 onClick: () => { 21704 setIsAdding(false); 21705 } 21706 }, (0,external_wp_i18n_namespaceObject.__)('Cancel')), (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 21707 variant: "primary", 21708 type: "submit", 21709 "aria-disabled": !title || isSaving, 21710 isBusy: isSaving 21711 }, (0,external_wp_i18n_namespaceObject.__)('Create'))))); 21712 } 21713 function AddNewItem({ 21714 type 21715 }) { 21716 const [isAdding, setIsAdding] = (0,external_wp_element_namespaceObject.useState)(false); 21717 return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(SidebarNavigationItem, { 21718 icon: library_plus, 21719 onClick: () => { 21720 setIsAdding(true); 21721 }, 21722 className: "dataviews__siderbar-content-add-new-item" 21723 }, (0,external_wp_i18n_namespaceObject.__)('New view')), isAdding && (0,external_React_.createElement)(external_wp_components_namespaceObject.Modal, { 21724 title: (0,external_wp_i18n_namespaceObject.__)('Add new view'), 21725 onRequestClose: () => { 21726 setIsAdding(false); 21727 } 21728 }, (0,external_React_.createElement)(AddNewItemModalContent, { 21729 type: type, 21730 setIsAdding: setIsAdding 21731 }))); 21732 } 21733 21734 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sidebar-dataviews/custom-dataviews-list.js 21735 21736 /** 21737 * WordPress dependencies 21738 */ 21739 21740 21741 21742 21743 21744 21745 21746 21747 /** 21748 * Internal dependencies 21749 */ 21750 21751 21752 21753 const { 21754 useHistory: custom_dataviews_list_useHistory, 21755 useLocation: custom_dataviews_list_useLocation 21756 } = unlock(external_wp_router_namespaceObject.privateApis); 21757 const custom_dataviews_list_EMPTY_ARRAY = []; 21758 function RenameItemModalContent({ 21759 dataviewId, 21760 currentTitle, 21761 setIsRenaming 21762 }) { 21763 const { 21764 editEntityRecord 21765 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store); 21766 const [title, setTitle] = (0,external_wp_element_namespaceObject.useState)(currentTitle); 21767 return (0,external_React_.createElement)("form", { 21768 onSubmit: async event => { 21769 event.preventDefault(); 21770 await editEntityRecord('postType', 'wp_dataviews', dataviewId, { 21771 title 21772 }); 21773 setIsRenaming(false); 21774 } 21775 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { 21776 spacing: "5" 21777 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.TextControl, { 21778 __nextHasNoMarginBottom: true, 21779 label: (0,external_wp_i18n_namespaceObject.__)('Name'), 21780 value: title, 21781 onChange: setTitle, 21782 placeholder: (0,external_wp_i18n_namespaceObject.__)('My view'), 21783 className: "patterns-create-modal__name-input" 21784 }), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { 21785 justify: "right" 21786 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 21787 variant: "tertiary", 21788 onClick: () => { 21789 setIsRenaming(false); 21790 } 21791 }, (0,external_wp_i18n_namespaceObject.__)('Cancel')), (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 21792 variant: "primary", 21793 type: "submit", 21794 "aria-disabled": !title 21795 }, (0,external_wp_i18n_namespaceObject.__)('Rename'))))); 21796 } 21797 function CustomDataViewItem({ 21798 dataviewId, 21799 isActive 21800 }) { 21801 const { 21802 params: { 21803 path 21804 } 21805 } = custom_dataviews_list_useLocation(); 21806 const history = custom_dataviews_list_useHistory(); 21807 const { 21808 dataview 21809 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 21810 const { 21811 getEditedEntityRecord 21812 } = select(external_wp_coreData_namespaceObject.store); 21813 return { 21814 dataview: getEditedEntityRecord('postType', 'wp_dataviews', dataviewId) 21815 }; 21816 }, [dataviewId]); 21817 const { 21818 deleteEntityRecord 21819 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store); 21820 const type = (0,external_wp_element_namespaceObject.useMemo)(() => { 21821 const viewContent = JSON.parse(dataview.content); 21822 return viewContent.type; 21823 }, [dataview.content]); 21824 const [isRenaming, setIsRenaming] = (0,external_wp_element_namespaceObject.useState)(false); 21825 return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(DataViewItem, { 21826 title: dataview.title, 21827 type: type, 21828 isActive: isActive, 21829 isCustom: "true", 21830 customViewId: dataviewId, 21831 suffix: (0,external_React_.createElement)(external_wp_components_namespaceObject.DropdownMenu, { 21832 icon: more_vertical, 21833 label: (0,external_wp_i18n_namespaceObject.__)('Actions'), 21834 className: "edit-site-sidebar-dataviews-dataview-item__dropdown-menu", 21835 toggleProps: { 21836 style: { 21837 color: 'inherit' 21838 }, 21839 size: 'small' 21840 } 21841 }, ({ 21842 onClose 21843 }) => (0,external_React_.createElement)(external_wp_components_namespaceObject.MenuGroup, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.MenuItem, { 21844 onClick: () => { 21845 setIsRenaming(true); 21846 onClose(); 21847 } 21848 }, (0,external_wp_i18n_namespaceObject.__)('Rename')), (0,external_React_.createElement)(external_wp_components_namespaceObject.MenuItem, { 21849 onClick: async () => { 21850 await deleteEntityRecord('postType', 'wp_dataviews', dataview.id, { 21851 force: true 21852 }); 21853 if (isActive) { 21854 history.replace({ 21855 path 21856 }); 21857 } 21858 onClose(); 21859 }, 21860 isDestructive: true 21861 }, (0,external_wp_i18n_namespaceObject.__)('Delete')))) 21862 }), isRenaming && (0,external_React_.createElement)(external_wp_components_namespaceObject.Modal, { 21863 title: (0,external_wp_i18n_namespaceObject.__)('Rename view'), 21864 onRequestClose: () => { 21865 setIsRenaming(false); 21866 } 21867 }, (0,external_React_.createElement)(RenameItemModalContent, { 21868 dataviewId: dataviewId, 21869 setIsRenaming: setIsRenaming, 21870 currentTitle: dataview.title 21871 }))); 21872 } 21873 function useCustomDataViews(type) { 21874 const customDataViews = (0,external_wp_data_namespaceObject.useSelect)(select => { 21875 const { 21876 getEntityRecords 21877 } = select(external_wp_coreData_namespaceObject.store); 21878 const dataViewTypeRecords = getEntityRecords('taxonomy', 'wp_dataviews_type', { 21879 slug: type 21880 }); 21881 if (!dataViewTypeRecords || dataViewTypeRecords.length === 0) { 21882 return custom_dataviews_list_EMPTY_ARRAY; 21883 } 21884 const dataViews = getEntityRecords('postType', 'wp_dataviews', { 21885 wp_dataviews_type: dataViewTypeRecords[0].id, 21886 orderby: 'date', 21887 order: 'asc' 21888 }); 21889 if (!dataViews) { 21890 return custom_dataviews_list_EMPTY_ARRAY; 21891 } 21892 return dataViews; 21893 }); 21894 return customDataViews; 21895 } 21896 function CustomDataViewsList({ 21897 type, 21898 activeView, 21899 isCustom 21900 }) { 21901 const customDataViews = useCustomDataViews(type); 21902 return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)("div", { 21903 className: "edit-site-sidebar-navigation-screen-dataviews__group-header" 21904 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHeading, { 21905 level: 2 21906 }, (0,external_wp_i18n_namespaceObject.__)('Custom Views'))), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalItemGroup, null, customDataViews.map(customViewRecord => { 21907 return (0,external_React_.createElement)(CustomDataViewItem, { 21908 key: customViewRecord.id, 21909 dataviewId: customViewRecord.id, 21910 isActive: isCustom === 'true' && Number(activeView) === customViewRecord.id 21911 }); 21912 }), (0,external_React_.createElement)(AddNewItem, { 21913 type: type 21914 }))); 21915 } 21916 21917 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sidebar-dataviews/index.js 21918 21919 /** 21920 * WordPress dependencies 21921 */ 21922 21923 21924 /** 21925 * Internal dependencies 21926 */ 21927 21928 21929 21930 const { 21931 useLocation: sidebar_dataviews_useLocation 21932 } = unlock(external_wp_router_namespaceObject.privateApis); 21933 21934 21935 const PATH_TO_TYPE = { 21936 '/pages': 'page' 21937 }; 21938 function DataViewsSidebarContent() { 21939 const { 21940 params: { 21941 path, 21942 activeView = 'all', 21943 isCustom = 'false' 21944 } 21945 } = sidebar_dataviews_useLocation(); 21946 if (!path || !PATH_TO_TYPE[path]) { 21947 return null; 21948 } 21949 const type = PATH_TO_TYPE[path]; 21950 return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalItemGroup, null, DEFAULT_VIEWS[type].map(dataview => { 21951 return (0,external_React_.createElement)(DataViewItem, { 21952 key: dataview.slug, 21953 slug: dataview.slug, 21954 title: dataview.title, 21955 icon: dataview.icon, 21956 type: dataview.view.type, 21957 isActive: isCustom === 'false' && dataview.slug === activeView, 21958 isCustom: "false" 21959 }); 21960 })), window?.__experimentalAdminViews && (0,external_React_.createElement)(CustomDataViewsList, { 21961 activeView: activeView, 21962 type: type, 21963 isCustom: "true" 21964 })); 21965 } 21966 21967 ;// CONCATENATED MODULE: external ["wp","dom"] 21968 const external_wp_dom_namespaceObject = window["wp"]["dom"]; 21969 ;// CONCATENATED MODULE: external ["wp","escapeHtml"] 21970 const external_wp_escapeHtml_namespaceObject = window["wp"]["escapeHtml"]; 21971 ;// CONCATENATED MODULE: external ["wp","wordcount"] 21972 const external_wp_wordcount_namespaceObject = window["wp"]["wordcount"]; 21973 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sidebar-navigation-screen-page/status-label.js 21974 21975 /** 21976 * External dependencies 21977 */ 21978 21979 21980 /** 21981 * WordPress dependencies 21982 */ 21983 21984 21985 21986 function StatusLabel({ 21987 status, 21988 date, 21989 short 21990 }) { 21991 const relateToNow = (0,external_wp_date_namespaceObject.humanTimeDiff)(date); 21992 let statusLabel = status; 21993 switch (status) { 21994 case 'publish': 21995 statusLabel = date ? (0,external_wp_element_namespaceObject.createInterpolateElement)((0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: is the relative time when the post was published. */ 21996 (0,external_wp_i18n_namespaceObject.__)('Published <time>%s</time>'), relateToNow), { 21997 time: (0,external_React_.createElement)("time", { 21998 dateTime: date 21999 }) 22000 }) : (0,external_wp_i18n_namespaceObject.__)('Published'); 22001 break; 22002 case 'future': 22003 const formattedDate = (0,external_wp_date_namespaceObject.dateI18n)(short ? 'M j' : 'F j', (0,external_wp_date_namespaceObject.getDate)(date)); 22004 statusLabel = date ? (0,external_wp_element_namespaceObject.createInterpolateElement)((0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: is the formatted date and time on which the post is scheduled to be published. */ 22005 (0,external_wp_i18n_namespaceObject.__)('Scheduled: <time>%s</time>'), formattedDate), { 22006 time: (0,external_React_.createElement)("time", { 22007 dateTime: date 22008 }) 22009 }) : (0,external_wp_i18n_namespaceObject.__)('Scheduled'); 22010 break; 22011 case 'draft': 22012 statusLabel = (0,external_wp_i18n_namespaceObject.__)('Draft'); 22013 break; 22014 case 'pending': 22015 statusLabel = (0,external_wp_i18n_namespaceObject.__)('Pending'); 22016 break; 22017 case 'private': 22018 statusLabel = (0,external_wp_i18n_namespaceObject.__)('Private'); 22019 break; 22020 case 'protected': 22021 statusLabel = (0,external_wp_i18n_namespaceObject.__)('Password protected'); 22022 break; 22023 } 22024 return (0,external_React_.createElement)("div", { 22025 className: classnames_default()('edit-site-sidebar-navigation-screen-page__status', { 22026 [`has-status has-$status}-status`]: !!status 22027 }) 22028 }, statusLabel); 22029 } 22030 22031 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sidebar-navigation-screen-page/page-details.js 22032 22033 /** 22034 * WordPress dependencies 22035 */ 22036 22037 22038 22039 22040 22041 22042 22043 22044 /** 22045 * Internal dependencies 22046 */ 22047 22048 22049 22050 22051 22052 22053 // Taken from packages/editor/src/components/time-to-read/index.js. 22054 const AVERAGE_READING_RATE = 189; 22055 function getPageDetails(page) { 22056 if (!page) { 22057 return []; 22058 } 22059 const details = [{ 22060 label: (0,external_wp_i18n_namespaceObject.__)('Status'), 22061 value: (0,external_React_.createElement)(StatusLabel, { 22062 status: page?.password ? 'protected' : page.status, 22063 date: page?.date, 22064 short: true 22065 }) 22066 }, { 22067 label: (0,external_wp_i18n_namespaceObject.__)('Slug'), 22068 value: (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalTruncate, { 22069 numberOfLines: 1 22070 }, (0,external_wp_url_namespaceObject.safeDecodeURIComponent)(page.slug || page.generated_slug)) 22071 }]; 22072 if (page?.templateTitle) { 22073 details.push({ 22074 label: (0,external_wp_i18n_namespaceObject.__)('Template'), 22075 value: (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(page.templateTitle) 22076 }); 22077 } 22078 if (page?.parentTitle) { 22079 details.push({ 22080 label: (0,external_wp_i18n_namespaceObject.__)('Parent'), 22081 value: (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(page.parentTitle || (0,external_wp_i18n_namespaceObject.__)('(no title)')) 22082 }); 22083 } 22084 22085 /* 22086 * translators: If your word count is based on single characters (e.g. East Asian characters), 22087 * enter 'characters_excluding_spaces' or 'characters_including_spaces'. Otherwise, enter 'words'. 22088 * Do not translate into your own language. 22089 */ 22090 const wordCountType = (0,external_wp_i18n_namespaceObject._x)('words', 'Word count type. Do not translate!'); 22091 const wordsCounted = page?.content?.rendered ? (0,external_wp_wordcount_namespaceObject.count)(page.content.rendered, wordCountType) : 0; 22092 const readingTime = Math.round(wordsCounted / AVERAGE_READING_RATE); 22093 if (wordsCounted && !page?.isPostsPage) { 22094 details.push({ 22095 label: (0,external_wp_i18n_namespaceObject.__)('Words'), 22096 value: wordsCounted.toLocaleString() || (0,external_wp_i18n_namespaceObject.__)('Unknown') 22097 }, { 22098 label: (0,external_wp_i18n_namespaceObject.__)('Time to read'), 22099 value: readingTime > 1 ? (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: is the number of minutes. */ 22100 (0,external_wp_i18n_namespaceObject.__)('%s mins'), readingTime.toLocaleString()) : (0,external_wp_i18n_namespaceObject.__)('< 1 min') 22101 }); 22102 } 22103 return details; 22104 } 22105 function PageDetails({ 22106 id 22107 }) { 22108 const { 22109 record 22110 } = (0,external_wp_coreData_namespaceObject.useEntityRecord)('postType', 'page', id); 22111 const { 22112 parentTitle, 22113 templateTitle, 22114 isPostsPage 22115 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 22116 const { 22117 getEditedPostId 22118 } = unlock(select(store_store)); 22119 const template = select(external_wp_coreData_namespaceObject.store).getEntityRecord('postType', constants_TEMPLATE_POST_TYPE, getEditedPostId()); 22120 const _templateTitle = template?.title?.rendered; 22121 22122 // Parent page title. 22123 const _parentTitle = record?.parent ? select(external_wp_coreData_namespaceObject.store).getEntityRecord('postType', 'page', record.parent, { 22124 _fields: ['title'] 22125 })?.title?.rendered : null; 22126 const { 22127 getEntityRecord 22128 } = select(external_wp_coreData_namespaceObject.store); 22129 const siteSettings = getEntityRecord('root', 'site'); 22130 return { 22131 parentTitle: _parentTitle, 22132 templateTitle: _templateTitle, 22133 isPostsPage: record?.id === siteSettings?.page_for_posts 22134 }; 22135 }, [record?.parent, record?.id]); 22136 return (0,external_React_.createElement)(SidebarNavigationScreenDetailsPanel, { 22137 spacing: 5, 22138 title: (0,external_wp_i18n_namespaceObject.__)('Details') 22139 }, getPageDetails({ 22140 parentTitle, 22141 templateTitle, 22142 isPostsPage, 22143 ...record 22144 }).map(({ 22145 label, 22146 value 22147 }) => (0,external_React_.createElement)(SidebarNavigationScreenDetailsPanelRow, { 22148 key: label 22149 }, (0,external_React_.createElement)(SidebarNavigationScreenDetailsPanelLabel, null, label), (0,external_React_.createElement)(SidebarNavigationScreenDetailsPanelValue, null, value)))); 22150 } 22151 22152 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/page-actions/trash-page-menu-item.js 22153 22154 /** 22155 * WordPress dependencies 22156 */ 22157 22158 22159 22160 22161 22162 22163 function TrashPageMenuItem({ 22164 postId, 22165 onRemove 22166 }) { 22167 const { 22168 createSuccessNotice, 22169 createErrorNotice 22170 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store); 22171 const { 22172 deleteEntityRecord 22173 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store); 22174 const page = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).getEntityRecord('postType', 'page', postId), [postId]); 22175 async function removePage() { 22176 try { 22177 await deleteEntityRecord('postType', 'page', postId, {}, { 22178 throwOnError: true 22179 }); 22180 createSuccessNotice((0,external_wp_i18n_namespaceObject.sprintf)( /* translators: The page's title. */ 22181 (0,external_wp_i18n_namespaceObject.__)('"%s" moved to the Trash.'), (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(page.title.rendered)), { 22182 type: 'snackbar', 22183 id: 'edit-site-page-trashed' 22184 }); 22185 onRemove?.(); 22186 } catch (error) { 22187 const errorMessage = error.message && error.code !== 'unknown_error' ? error.message : (0,external_wp_i18n_namespaceObject.__)('An error occurred while moving the page to the trash.'); 22188 createErrorNotice(errorMessage, { 22189 type: 'snackbar' 22190 }); 22191 } 22192 } 22193 return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.MenuItem, { 22194 onClick: () => removePage(), 22195 isDestructive: true, 22196 variant: "secondary" 22197 }, (0,external_wp_i18n_namespaceObject.__)('Move to Trash'))); 22198 } 22199 22200 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/page-actions/index.js 22201 22202 /** 22203 * WordPress dependencies 22204 */ 22205 22206 22207 22208 22209 /** 22210 * Internal dependencies 22211 */ 22212 22213 function PageActions({ 22214 postId, 22215 toggleProps, 22216 onRemove 22217 }) { 22218 return (0,external_React_.createElement)(external_wp_components_namespaceObject.DropdownMenu, { 22219 icon: more_vertical, 22220 label: (0,external_wp_i18n_namespaceObject.__)('Actions'), 22221 toggleProps: toggleProps 22222 }, () => (0,external_React_.createElement)(external_wp_components_namespaceObject.MenuGroup, null, (0,external_React_.createElement)(TrashPageMenuItem, { 22223 postId: postId, 22224 onRemove: onRemove 22225 }))); 22226 } 22227 22228 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sidebar-navigation-screen-page/index.js 22229 22230 /** 22231 * WordPress dependencies 22232 */ 22233 22234 22235 22236 22237 22238 22239 22240 22241 22242 22243 22244 22245 /** 22246 * Internal dependencies 22247 */ 22248 22249 22250 22251 22252 22253 22254 22255 const { 22256 useHistory: sidebar_navigation_screen_page_useHistory 22257 } = unlock(external_wp_router_namespaceObject.privateApis); 22258 function SidebarNavigationScreenPage({ 22259 backPath 22260 }) { 22261 const { 22262 setCanvasMode 22263 } = unlock((0,external_wp_data_namespaceObject.useDispatch)(store_store)); 22264 const history = sidebar_navigation_screen_page_useHistory(); 22265 const { 22266 params: { 22267 postId 22268 }, 22269 goTo 22270 } = (0,external_wp_components_namespaceObject.__experimentalUseNavigator)(); 22271 const { 22272 record, 22273 hasResolved 22274 } = (0,external_wp_coreData_namespaceObject.useEntityRecord)('postType', 'page', postId); 22275 const { 22276 featuredMediaAltText, 22277 featuredMediaSourceUrl 22278 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 22279 const { 22280 getEntityRecord 22281 } = select(external_wp_coreData_namespaceObject.store); 22282 // Featured image. 22283 const attachedMedia = record?.featured_media ? getEntityRecord('postType', 'attachment', record?.featured_media) : null; 22284 return { 22285 featuredMediaSourceUrl: attachedMedia?.media_details.sizes?.medium?.source_url || attachedMedia?.source_url, 22286 featuredMediaAltText: (0,external_wp_escapeHtml_namespaceObject.escapeAttribute)(attachedMedia?.alt_text || attachedMedia?.description?.raw || '') 22287 }; 22288 }, [record]); 22289 22290 // Redirect to the main pages navigation screen if the page is not found or has been deleted. 22291 (0,external_wp_element_namespaceObject.useEffect)(() => { 22292 if (hasResolved && !record) { 22293 history.push({ 22294 path: '/page', 22295 postId: undefined, 22296 postType: undefined, 22297 canvas: 'view' 22298 }); 22299 } 22300 }, [hasResolved, history]); 22301 const featureImageAltText = featuredMediaAltText ? (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(featuredMediaAltText) : (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(record?.title?.rendered || (0,external_wp_i18n_namespaceObject.__)('Featured image')); 22302 return record ? (0,external_React_.createElement)(SidebarNavigationScreen, { 22303 backPath: backPath, 22304 title: (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(record?.title?.rendered || (0,external_wp_i18n_namespaceObject.__)('(no title)')), 22305 actions: (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(PageActions, { 22306 postId: postId, 22307 toggleProps: { 22308 as: SidebarButton 22309 }, 22310 onRemove: () => { 22311 goTo('/page'); 22312 } 22313 }), (0,external_React_.createElement)(SidebarButton, { 22314 onClick: () => setCanvasMode('edit'), 22315 label: (0,external_wp_i18n_namespaceObject.__)('Edit'), 22316 icon: library_pencil 22317 })), 22318 meta: (0,external_React_.createElement)(external_wp_components_namespaceObject.ExternalLink, { 22319 className: "edit-site-sidebar-navigation-screen__page-link", 22320 href: record.link 22321 }, (0,external_wp_url_namespaceObject.filterURLForDisplay)((0,external_wp_url_namespaceObject.safeDecodeURIComponent)(record.link))), 22322 content: (0,external_React_.createElement)(external_React_.Fragment, null, !!featuredMediaSourceUrl && (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { 22323 className: "edit-site-sidebar-navigation-screen-page__featured-image-wrapper", 22324 alignment: "left", 22325 spacing: 2 22326 }, (0,external_React_.createElement)("div", { 22327 className: "edit-site-sidebar-navigation-screen-page__featured-image has-image" 22328 }, (0,external_React_.createElement)("img", { 22329 alt: featureImageAltText, 22330 src: featuredMediaSourceUrl 22331 }))), !!record?.excerpt?.rendered && (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalTruncate, { 22332 className: "edit-site-sidebar-navigation-screen-page__excerpt", 22333 numberOfLines: 3 22334 }, (0,external_wp_dom_namespaceObject.__unstableStripHTML)(record.excerpt.rendered)), (0,external_React_.createElement)(PageDetails, { 22335 id: postId 22336 })), 22337 footer: record?.modified ? (0,external_React_.createElement)(SidebarNavigationScreenDetailsFooter, { 22338 record: record 22339 }) : null 22340 }) : null; 22341 } 22342 22343 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sidebar/index.js 22344 22345 /** 22346 * External dependencies 22347 */ 22348 22349 22350 /** 22351 * WordPress dependencies 22352 */ 22353 22354 22355 22356 22357 22358 22359 /** 22360 * Internal dependencies 22361 */ 22362 22363 22364 22365 22366 22367 22368 22369 22370 22371 22372 22373 22374 22375 22376 22377 22378 const { 22379 useLocation: sidebar_useLocation 22380 } = unlock(external_wp_router_namespaceObject.privateApis); 22381 function SidebarScreenWrapper({ 22382 className, 22383 ...props 22384 }) { 22385 return (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalNavigatorScreen, { 22386 className: classnames_default()('edit-site-sidebar__screen-wrapper', className), 22387 ...props 22388 }); 22389 } 22390 function SidebarScreens() { 22391 useSyncPathWithURL(); 22392 const isMobileViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium', '<'); 22393 return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(SidebarScreenWrapper, { 22394 path: "/" 22395 }, (0,external_React_.createElement)(SidebarNavigationScreenMain, null)), (0,external_React_.createElement)(SidebarScreenWrapper, { 22396 path: "/navigation" 22397 }, (0,external_React_.createElement)(SidebarNavigationScreenNavigationMenus, null)), (0,external_React_.createElement)(SidebarScreenWrapper, { 22398 path: "/navigation/:postType/:postId" 22399 }, (0,external_React_.createElement)(SidebarNavigationScreenNavigationMenu, null)), (0,external_React_.createElement)(SidebarScreenWrapper, { 22400 path: "/wp_global_styles" 22401 }, (0,external_React_.createElement)(SidebarNavigationScreenGlobalStyles, null)), (0,external_React_.createElement)(SidebarScreenWrapper, { 22402 path: "/page" 22403 }, (0,external_React_.createElement)(SidebarNavigationScreenPages, null)), (0,external_React_.createElement)(SidebarScreenWrapper, { 22404 path: "/pages" 22405 }, (0,external_React_.createElement)(SidebarNavigationScreen, { 22406 title: (0,external_wp_i18n_namespaceObject.__)('Manage pages'), 22407 content: (0,external_React_.createElement)(DataViewsSidebarContent, null), 22408 backPath: "/page" 22409 })), (0,external_React_.createElement)(SidebarScreenWrapper, { 22410 path: "/page/:postId" 22411 }, (0,external_React_.createElement)(SidebarNavigationScreenPage, null)), (0,external_React_.createElement)(SidebarScreenWrapper, { 22412 path: "/:postType(wp_template)" 22413 }, (0,external_React_.createElement)(SidebarNavigationScreenTemplates, null)), !isMobileViewport && (0,external_React_.createElement)(SidebarScreenWrapper, { 22414 path: "/patterns" 22415 }, (0,external_React_.createElement)(SidebarNavigationScreenPatterns, null)), (0,external_React_.createElement)(SidebarScreenWrapper, { 22416 path: "/:postType(wp_template|wp_template_part)/all" 22417 }, (0,external_React_.createElement)(SidebarNavigationScreenTemplatesBrowse, null)), (0,external_React_.createElement)(SidebarScreenWrapper, { 22418 path: "/:postType(wp_template_part|wp_block)/:postId" 22419 }, (0,external_React_.createElement)(SidebarNavigationScreenPattern, null)), (0,external_React_.createElement)(SidebarScreenWrapper, { 22420 path: "/:postType(wp_template)/:postId" 22421 }, (0,external_React_.createElement)(SidebarNavigationScreenTemplate, null))); 22422 } 22423 function Sidebar() { 22424 const { 22425 params: urlParams 22426 } = sidebar_useLocation(); 22427 const initialPath = (0,external_wp_element_namespaceObject.useRef)(getPathFromURL(urlParams)); 22428 return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalNavigatorProvider, { 22429 className: "edit-site-sidebar__content", 22430 initialPath: initialPath.current 22431 }, (0,external_React_.createElement)(SidebarScreens, null)), (0,external_React_.createElement)(SaveHub, null)); 22432 } 22433 /* harmony default export */ const sidebar = ((0,external_wp_element_namespaceObject.memo)(Sidebar)); 22434 22435 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/error-boundary/warning.js 22436 22437 /** 22438 * WordPress dependencies 22439 */ 22440 22441 22442 22443 22444 function CopyButton({ 22445 text, 22446 children 22447 }) { 22448 const ref = (0,external_wp_compose_namespaceObject.useCopyToClipboard)(text); 22449 return (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 22450 variant: "secondary", 22451 ref: ref 22452 }, children); 22453 } 22454 function ErrorBoundaryWarning({ 22455 message, 22456 error 22457 }) { 22458 const actions = [(0,external_React_.createElement)(CopyButton, { 22459 key: "copy-error", 22460 text: error.stack 22461 }, (0,external_wp_i18n_namespaceObject.__)('Copy Error'))]; 22462 return (0,external_React_.createElement)(external_wp_blockEditor_namespaceObject.Warning, { 22463 className: "editor-error-boundary", 22464 actions: actions 22465 }, message); 22466 } 22467 22468 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/error-boundary/index.js 22469 22470 /** 22471 * WordPress dependencies 22472 */ 22473 22474 22475 22476 22477 /** 22478 * Internal dependencies 22479 */ 22480 22481 class ErrorBoundary extends external_wp_element_namespaceObject.Component { 22482 constructor() { 22483 super(...arguments); 22484 this.state = { 22485 error: null 22486 }; 22487 } 22488 componentDidCatch(error) { 22489 (0,external_wp_hooks_namespaceObject.doAction)('editor.ErrorBoundary.errorLogged', error); 22490 } 22491 static getDerivedStateFromError(error) { 22492 return { 22493 error 22494 }; 22495 } 22496 render() { 22497 if (!this.state.error) { 22498 return this.props.children; 22499 } 22500 return (0,external_React_.createElement)(ErrorBoundaryWarning, { 22501 message: (0,external_wp_i18n_namespaceObject.__)('The editor has encountered an unexpected error.'), 22502 error: this.state.error 22503 }); 22504 } 22505 } 22506 22507 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/next.js 22508 22509 /** 22510 * WordPress dependencies 22511 */ 22512 22513 const next = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { 22514 xmlns: "http://www.w3.org/2000/svg", 22515 viewBox: "0 0 24 24" 22516 }, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 22517 d: "M6.6 6L5.4 7l4.5 5-4.5 5 1.1 1 5.5-6-5.4-6zm6 0l-1.1 1 4.5 5-4.5 5 1.1 1 5.5-6-5.5-6z" 22518 })); 22519 /* harmony default export */ const library_next = (next); 22520 22521 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/previous.js 22522 22523 /** 22524 * WordPress dependencies 22525 */ 22526 22527 const previous = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { 22528 xmlns: "http://www.w3.org/2000/svg", 22529 viewBox: "0 0 24 24" 22530 }, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 22531 d: "M11.6 7l-1.1-1L5 12l5.5 6 1.1-1L7 12l4.6-5zm6 0l-1.1-1-5.5 6 5.5 6 1.1-1-4.6-5 4.6-5z" 22532 })); 22533 /* harmony default export */ const library_previous = (previous); 22534 22535 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/external.js 22536 22537 /** 22538 * WordPress dependencies 22539 */ 22540 22541 const external = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { 22542 xmlns: "http://www.w3.org/2000/svg", 22543 viewBox: "0 0 24 24" 22544 }, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 22545 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" 22546 })); 22547 /* harmony default export */ const library_external = (external); 22548 22549 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/keyboard-shortcut-help-modal/config.js 22550 /** 22551 * WordPress dependencies 22552 */ 22553 22554 const textFormattingShortcuts = [{ 22555 keyCombination: { 22556 modifier: 'primary', 22557 character: 'b' 22558 }, 22559 description: (0,external_wp_i18n_namespaceObject.__)('Make the selected text bold.') 22560 }, { 22561 keyCombination: { 22562 modifier: 'primary', 22563 character: 'i' 22564 }, 22565 description: (0,external_wp_i18n_namespaceObject.__)('Make the selected text italic.') 22566 }, { 22567 keyCombination: { 22568 modifier: 'primary', 22569 character: 'k' 22570 }, 22571 description: (0,external_wp_i18n_namespaceObject.__)('Convert the selected text into a link.') 22572 }, { 22573 keyCombination: { 22574 modifier: 'primaryShift', 22575 character: 'k' 22576 }, 22577 description: (0,external_wp_i18n_namespaceObject.__)('Remove a link.') 22578 }, { 22579 keyCombination: { 22580 character: '[[' 22581 }, 22582 description: (0,external_wp_i18n_namespaceObject.__)('Insert a link to a post or page.') 22583 }, { 22584 keyCombination: { 22585 modifier: 'primary', 22586 character: 'u' 22587 }, 22588 description: (0,external_wp_i18n_namespaceObject.__)('Underline the selected text.') 22589 }, { 22590 keyCombination: { 22591 modifier: 'access', 22592 character: 'd' 22593 }, 22594 description: (0,external_wp_i18n_namespaceObject.__)('Strikethrough the selected text.') 22595 }, { 22596 keyCombination: { 22597 modifier: 'access', 22598 character: 'x' 22599 }, 22600 description: (0,external_wp_i18n_namespaceObject.__)('Make the selected text inline code.') 22601 }, { 22602 keyCombination: { 22603 modifier: 'access', 22604 character: '0' 22605 }, 22606 description: (0,external_wp_i18n_namespaceObject.__)('Convert the current heading to a paragraph.') 22607 }, { 22608 keyCombination: { 22609 modifier: 'access', 22610 character: '1-6' 22611 }, 22612 description: (0,external_wp_i18n_namespaceObject.__)('Convert the current paragraph or heading to a heading of level 1 to 6.') 22613 }]; 22614 22615 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/keyboard-shortcut-help-modal/shortcut.js 22616 22617 /** 22618 * WordPress dependencies 22619 */ 22620 22621 22622 function KeyCombination({ 22623 keyCombination, 22624 forceAriaLabel 22625 }) { 22626 const shortcut = keyCombination.modifier ? external_wp_keycodes_namespaceObject.displayShortcutList[keyCombination.modifier](keyCombination.character) : keyCombination.character; 22627 const ariaLabel = keyCombination.modifier ? external_wp_keycodes_namespaceObject.shortcutAriaLabel[keyCombination.modifier](keyCombination.character) : keyCombination.character; 22628 return (0,external_React_.createElement)("kbd", { 22629 className: "edit-site-keyboard-shortcut-help-modal__shortcut-key-combination", 22630 "aria-label": forceAriaLabel || ariaLabel 22631 }, (Array.isArray(shortcut) ? shortcut : [shortcut]).map((character, index) => { 22632 if (character === '+') { 22633 return (0,external_React_.createElement)(external_wp_element_namespaceObject.Fragment, { 22634 key: index 22635 }, character); 22636 } 22637 return (0,external_React_.createElement)("kbd", { 22638 key: index, 22639 className: "edit-site-keyboard-shortcut-help-modal__shortcut-key" 22640 }, character); 22641 })); 22642 } 22643 function Shortcut({ 22644 description, 22645 keyCombination, 22646 aliases = [], 22647 ariaLabel 22648 }) { 22649 return (0,external_React_.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_React_.createElement)("div", { 22650 className: "edit-site-keyboard-shortcut-help-modal__shortcut-description" 22651 }, description), (0,external_React_.createElement)("div", { 22652 className: "edit-site-keyboard-shortcut-help-modal__shortcut-term" 22653 }, (0,external_React_.createElement)(KeyCombination, { 22654 keyCombination: keyCombination, 22655 forceAriaLabel: ariaLabel 22656 }), aliases.map((alias, index) => (0,external_React_.createElement)(KeyCombination, { 22657 keyCombination: alias, 22658 forceAriaLabel: ariaLabel, 22659 key: index 22660 })))); 22661 } 22662 22663 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/keyboard-shortcut-help-modal/dynamic-shortcut.js 22664 22665 /** 22666 * WordPress dependencies 22667 */ 22668 22669 22670 22671 /** 22672 * Internal dependencies 22673 */ 22674 22675 function DynamicShortcut({ 22676 name 22677 }) { 22678 const { 22679 keyCombination, 22680 description, 22681 aliases 22682 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 22683 const { 22684 getShortcutKeyCombination, 22685 getShortcutDescription, 22686 getShortcutAliases 22687 } = select(external_wp_keyboardShortcuts_namespaceObject.store); 22688 return { 22689 keyCombination: getShortcutKeyCombination(name), 22690 aliases: getShortcutAliases(name), 22691 description: getShortcutDescription(name) 22692 }; 22693 }, [name]); 22694 if (!keyCombination) { 22695 return null; 22696 } 22697 return (0,external_React_.createElement)(Shortcut, { 22698 keyCombination: keyCombination, 22699 description: description, 22700 aliases: aliases 22701 }); 22702 } 22703 22704 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/keyboard-shortcut-help-modal/index.js 22705 22706 /** 22707 * External dependencies 22708 */ 22709 22710 22711 /** 22712 * WordPress dependencies 22713 */ 22714 22715 22716 22717 22718 22719 22720 /** 22721 * Internal dependencies 22722 */ 22723 22724 22725 22726 const KEYBOARD_SHORTCUT_HELP_MODAL_NAME = 'edit-site/keyboard-shortcut-help'; 22727 const ShortcutList = ({ 22728 shortcuts 22729 }) => 22730 /* 22731 * Disable reason: The `list` ARIA role is redundant but 22732 * Safari+VoiceOver won't announce the list otherwise. 22733 */ 22734 /* eslint-disable jsx-a11y/no-redundant-roles */ 22735 (0,external_React_.createElement)("ul", { 22736 className: "edit-site-keyboard-shortcut-help-modal__shortcut-list", 22737 role: "list" 22738 }, shortcuts.map((shortcut, index) => (0,external_React_.createElement)("li", { 22739 className: "edit-site-keyboard-shortcut-help-modal__shortcut", 22740 key: index 22741 }, typeof shortcut === 'string' ? (0,external_React_.createElement)(DynamicShortcut, { 22742 name: shortcut 22743 }) : (0,external_React_.createElement)(Shortcut, { 22744 ...shortcut 22745 })))) 22746 /* eslint-enable jsx-a11y/no-redundant-roles */; 22747 const ShortcutSection = ({ 22748 title, 22749 shortcuts, 22750 className 22751 }) => (0,external_React_.createElement)("section", { 22752 className: classnames_default()('edit-site-keyboard-shortcut-help-modal__section', className) 22753 }, !!title && (0,external_React_.createElement)("h2", { 22754 className: "edit-site-keyboard-shortcut-help-modal__section-title" 22755 }, title), (0,external_React_.createElement)(ShortcutList, { 22756 shortcuts: shortcuts 22757 })); 22758 const ShortcutCategorySection = ({ 22759 title, 22760 categoryName, 22761 additionalShortcuts = [] 22762 }) => { 22763 const categoryShortcuts = (0,external_wp_data_namespaceObject.useSelect)(select => { 22764 return select(external_wp_keyboardShortcuts_namespaceObject.store).getCategoryShortcuts(categoryName); 22765 }, [categoryName]); 22766 return (0,external_React_.createElement)(ShortcutSection, { 22767 title: title, 22768 shortcuts: categoryShortcuts.concat(additionalShortcuts) 22769 }); 22770 }; 22771 function KeyboardShortcutHelpModal() { 22772 const isModalActive = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).isModalActive(KEYBOARD_SHORTCUT_HELP_MODAL_NAME)); 22773 const { 22774 closeModal, 22775 openModal 22776 } = (0,external_wp_data_namespaceObject.useDispatch)(store); 22777 const toggleModal = () => isModalActive ? closeModal() : openModal(KEYBOARD_SHORTCUT_HELP_MODAL_NAME); 22778 (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/edit-site/keyboard-shortcuts', toggleModal); 22779 if (!isModalActive) { 22780 return null; 22781 } 22782 return (0,external_React_.createElement)(external_wp_components_namespaceObject.Modal, { 22783 className: "edit-site-keyboard-shortcut-help-modal", 22784 title: (0,external_wp_i18n_namespaceObject.__)('Keyboard shortcuts'), 22785 onRequestClose: toggleModal 22786 }, (0,external_React_.createElement)(ShortcutSection, { 22787 className: "edit-site-keyboard-shortcut-help-modal__main-shortcuts", 22788 shortcuts: ['core/edit-site/keyboard-shortcuts'] 22789 }), (0,external_React_.createElement)(ShortcutCategorySection, { 22790 title: (0,external_wp_i18n_namespaceObject.__)('Global shortcuts'), 22791 categoryName: "global" 22792 }), (0,external_React_.createElement)(ShortcutCategorySection, { 22793 title: (0,external_wp_i18n_namespaceObject.__)('Selection shortcuts'), 22794 categoryName: "selection" 22795 }), (0,external_React_.createElement)(ShortcutCategorySection, { 22796 title: (0,external_wp_i18n_namespaceObject.__)('Block shortcuts'), 22797 categoryName: "block", 22798 additionalShortcuts: [{ 22799 keyCombination: { 22800 character: '/' 22801 }, 22802 description: (0,external_wp_i18n_namespaceObject.__)('Change the block type after adding a new paragraph.'), 22803 /* translators: The forward-slash character. e.g. '/'. */ 22804 ariaLabel: (0,external_wp_i18n_namespaceObject.__)('Forward-slash') 22805 }] 22806 }), (0,external_React_.createElement)(ShortcutSection, { 22807 title: (0,external_wp_i18n_namespaceObject.__)('Text formatting'), 22808 shortcuts: textFormattingShortcuts 22809 })); 22810 } 22811 22812 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/preferences-modal/index.js 22813 22814 /** 22815 * WordPress dependencies 22816 */ 22817 22818 22819 22820 22821 /** 22822 * Internal dependencies 22823 */ 22824 22825 const { 22826 PreferencesModal 22827 } = unlock(external_wp_editor_namespaceObject.privateApis); 22828 const PREFERENCES_MODAL_NAME = 'edit-site/preferences'; 22829 function EditSitePreferencesModal() { 22830 const isModalActive = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).isModalActive(PREFERENCES_MODAL_NAME)); 22831 const { 22832 closeModal 22833 } = (0,external_wp_data_namespaceObject.useDispatch)(store); 22834 if (!isModalActive) { 22835 return null; 22836 } 22837 return (0,external_React_.createElement)(PreferencesModal, { 22838 isActive: isModalActive, 22839 onClose: closeModal 22840 }); 22841 } 22842 22843 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/header-edit-mode/tools-more-menu-group/index.js 22844 22845 /** 22846 * WordPress dependencies 22847 */ 22848 22849 const { 22850 Fill: ToolsMoreMenuGroup, 22851 Slot 22852 } = (0,external_wp_components_namespaceObject.createSlotFill)('EditSiteToolsMoreMenuGroup'); 22853 ToolsMoreMenuGroup.Slot = ({ 22854 fillProps 22855 }) => (0,external_React_.createElement)(Slot, { 22856 fillProps: fillProps 22857 }, fills => fills && fills.length > 0); 22858 /* harmony default export */ const tools_more_menu_group = (ToolsMoreMenuGroup); 22859 22860 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/download.js 22861 22862 /** 22863 * WordPress dependencies 22864 */ 22865 22866 const download = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { 22867 xmlns: "http://www.w3.org/2000/svg", 22868 viewBox: "0 0 24 24" 22869 }, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 22870 d: "M18 11.3l-1-1.1-4 4V3h-1.5v11.3L7 10.2l-1 1.1 6.2 5.8 5.8-5.8zm.5 3.7v3.5h-13V15H4v5h16v-5h-1.5z" 22871 })); 22872 /* harmony default export */ const library_download = (download); 22873 22874 ;// CONCATENATED MODULE: external ["wp","blob"] 22875 const external_wp_blob_namespaceObject = window["wp"]["blob"]; 22876 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/header-edit-mode/more-menu/site-export.js 22877 22878 /** 22879 * WordPress dependencies 22880 */ 22881 22882 22883 22884 22885 22886 22887 22888 function SiteExport() { 22889 const { 22890 createErrorNotice 22891 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store); 22892 async function handleExport() { 22893 try { 22894 const response = await external_wp_apiFetch_default()({ 22895 path: '/wp-block-editor/v1/export', 22896 parse: false, 22897 headers: { 22898 Accept: 'application/zip' 22899 } 22900 }); 22901 const blob = await response.blob(); 22902 const contentDisposition = response.headers.get('content-disposition'); 22903 const contentDispositionMatches = contentDisposition.match(/=(.+)\.zip/); 22904 const fileName = contentDispositionMatches[1] ? contentDispositionMatches[1] : 'edit-site-export'; 22905 (0,external_wp_blob_namespaceObject.downloadBlob)(fileName + '.zip', blob, 'application/zip'); 22906 } catch (errorResponse) { 22907 let error = {}; 22908 try { 22909 error = await errorResponse.json(); 22910 } catch (e) {} 22911 const errorMessage = error.message && error.code !== 'unknown_error' ? error.message : (0,external_wp_i18n_namespaceObject.__)('An error occurred while creating the site export.'); 22912 createErrorNotice(errorMessage, { 22913 type: 'snackbar' 22914 }); 22915 } 22916 } 22917 return (0,external_React_.createElement)(external_wp_components_namespaceObject.MenuItem, { 22918 role: "menuitem", 22919 icon: library_download, 22920 onClick: handleExport, 22921 info: (0,external_wp_i18n_namespaceObject.__)('Download your theme with updated templates and styles.') 22922 }, (0,external_wp_i18n_namespaceObject._x)('Export', 'site exporter menu item')); 22923 } 22924 22925 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/header-edit-mode/more-menu/welcome-guide-menu-item.js 22926 22927 /** 22928 * WordPress dependencies 22929 */ 22930 22931 22932 22933 22934 function WelcomeGuideMenuItem() { 22935 const { 22936 toggle 22937 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_preferences_namespaceObject.store); 22938 return (0,external_React_.createElement)(external_wp_components_namespaceObject.MenuItem, { 22939 onClick: () => toggle('core/edit-site', 'welcomeGuide') 22940 }, (0,external_wp_i18n_namespaceObject.__)('Welcome Guide')); 22941 } 22942 22943 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/header-edit-mode/more-menu/copy-content-menu-item.js 22944 22945 /** 22946 * WordPress dependencies 22947 */ 22948 22949 22950 22951 22952 22953 22954 22955 22956 /** 22957 * Internal dependencies 22958 */ 22959 22960 function CopyContentMenuItem() { 22961 const { 22962 createNotice 22963 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store); 22964 const { 22965 getEditedPostId, 22966 getEditedPostType 22967 } = (0,external_wp_data_namespaceObject.useSelect)(store_store); 22968 const { 22969 getEditedEntityRecord 22970 } = (0,external_wp_data_namespaceObject.useSelect)(external_wp_coreData_namespaceObject.store); 22971 function getText() { 22972 const record = getEditedEntityRecord('postType', getEditedPostType(), getEditedPostId()); 22973 if (!record) { 22974 return ''; 22975 } 22976 if (typeof record.content === 'function') { 22977 return record.content(record); 22978 } else if (record.blocks) { 22979 return (0,external_wp_blocks_namespaceObject.__unstableSerializeAndClean)(record.blocks); 22980 } else if (record.content) { 22981 return record.content; 22982 } 22983 } 22984 function onSuccess() { 22985 createNotice('info', (0,external_wp_i18n_namespaceObject.__)('All content copied.'), { 22986 isDismissible: true, 22987 type: 'snackbar' 22988 }); 22989 } 22990 const ref = (0,external_wp_compose_namespaceObject.useCopyToClipboard)(getText, onSuccess); 22991 return (0,external_React_.createElement)(external_wp_components_namespaceObject.MenuItem, { 22992 ref: ref 22993 }, (0,external_wp_i18n_namespaceObject.__)('Copy all blocks')); 22994 } 22995 22996 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/header-edit-mode/mode-switcher/index.js 22997 22998 /** 22999 * WordPress dependencies 23000 */ 23001 23002 23003 23004 23005 23006 /** 23007 * Internal dependencies 23008 */ 23009 23010 23011 /** 23012 * Set of available mode options. 23013 * 23014 * @type {Array} 23015 */ 23016 const MODES = [{ 23017 value: 'visual', 23018 label: (0,external_wp_i18n_namespaceObject.__)('Visual editor') 23019 }, { 23020 value: 'text', 23021 label: (0,external_wp_i18n_namespaceObject.__)('Code editor') 23022 }]; 23023 function ModeSwitcher() { 23024 const { 23025 shortcut, 23026 mode 23027 } = (0,external_wp_data_namespaceObject.useSelect)(select => ({ 23028 shortcut: select(external_wp_keyboardShortcuts_namespaceObject.store).getShortcutRepresentation('core/edit-site/toggle-mode'), 23029 mode: select(store_store).getEditorMode() 23030 }), []); 23031 const { 23032 switchEditorMode 23033 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store); 23034 const choices = MODES.map(choice => { 23035 if (choice.value !== mode) { 23036 return { 23037 ...choice, 23038 shortcut 23039 }; 23040 } 23041 return choice; 23042 }); 23043 return (0,external_React_.createElement)(external_wp_components_namespaceObject.MenuGroup, { 23044 label: (0,external_wp_i18n_namespaceObject.__)('Editor') 23045 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.MenuItemsChoice, { 23046 choices: choices, 23047 value: mode, 23048 onSelect: switchEditorMode 23049 })); 23050 } 23051 /* harmony default export */ const mode_switcher = (ModeSwitcher); 23052 23053 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/header-edit-mode/more-menu/index.js 23054 23055 /** 23056 * WordPress dependencies 23057 */ 23058 23059 23060 23061 23062 23063 23064 23065 23066 23067 /** 23068 * Internal dependencies 23069 */ 23070 23071 23072 23073 23074 23075 23076 23077 23078 function MoreMenu({ 23079 showIconLabels 23080 }) { 23081 const { 23082 openModal 23083 } = (0,external_wp_data_namespaceObject.useDispatch)(store); 23084 const { 23085 set: setPreference 23086 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_preferences_namespaceObject.store); 23087 const isBlockBasedTheme = (0,external_wp_data_namespaceObject.useSelect)(select => { 23088 return select(external_wp_coreData_namespaceObject.store).getCurrentTheme().is_block_theme; 23089 }, []); 23090 const { 23091 toggleDistractionFree 23092 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store); 23093 const turnOffDistractionFree = () => { 23094 setPreference('core', 'distractionFree', false); 23095 }; 23096 return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(MoreMenuDropdown, { 23097 toggleProps: { 23098 showTooltip: !showIconLabels, 23099 ...(showIconLabels && { 23100 variant: 'tertiary' 23101 }) 23102 } 23103 }, ({ 23104 onClose 23105 }) => (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.MenuGroup, { 23106 label: (0,external_wp_i18n_namespaceObject._x)('View', 'noun') 23107 }, (0,external_React_.createElement)(external_wp_preferences_namespaceObject.PreferenceToggleMenuItem, { 23108 scope: "core", 23109 name: "fixedToolbar", 23110 onToggle: turnOffDistractionFree, 23111 label: (0,external_wp_i18n_namespaceObject.__)('Top toolbar'), 23112 info: (0,external_wp_i18n_namespaceObject.__)('Access all block and document tools in a single place'), 23113 messageActivated: (0,external_wp_i18n_namespaceObject.__)('Top toolbar activated'), 23114 messageDeactivated: (0,external_wp_i18n_namespaceObject.__)('Top toolbar deactivated') 23115 }), (0,external_React_.createElement)(external_wp_preferences_namespaceObject.PreferenceToggleMenuItem, { 23116 scope: "core", 23117 name: "distractionFree", 23118 label: (0,external_wp_i18n_namespaceObject.__)('Distraction free'), 23119 info: (0,external_wp_i18n_namespaceObject.__)('Write with calmness'), 23120 handleToggling: false, 23121 onToggle: toggleDistractionFree, 23122 messageActivated: (0,external_wp_i18n_namespaceObject.__)('Distraction free mode activated'), 23123 messageDeactivated: (0,external_wp_i18n_namespaceObject.__)('Distraction free mode deactivated'), 23124 shortcut: external_wp_keycodes_namespaceObject.displayShortcut.primaryShift('\\') 23125 }), (0,external_React_.createElement)(external_wp_preferences_namespaceObject.PreferenceToggleMenuItem, { 23126 scope: "core", 23127 name: "focusMode", 23128 label: (0,external_wp_i18n_namespaceObject.__)('Spotlight mode'), 23129 info: (0,external_wp_i18n_namespaceObject.__)('Focus on one block at a time'), 23130 messageActivated: (0,external_wp_i18n_namespaceObject.__)('Spotlight mode activated'), 23131 messageDeactivated: (0,external_wp_i18n_namespaceObject.__)('Spotlight mode deactivated') 23132 })), (0,external_React_.createElement)(mode_switcher, null), (0,external_React_.createElement)(action_item.Slot, { 23133 name: "core/edit-site/plugin-more-menu", 23134 label: (0,external_wp_i18n_namespaceObject.__)('Plugins'), 23135 as: external_wp_components_namespaceObject.MenuGroup, 23136 fillProps: { 23137 onClick: onClose 23138 } 23139 }), (0,external_React_.createElement)(external_wp_components_namespaceObject.MenuGroup, { 23140 label: (0,external_wp_i18n_namespaceObject.__)('Tools') 23141 }, isBlockBasedTheme && (0,external_React_.createElement)(SiteExport, null), (0,external_React_.createElement)(external_wp_components_namespaceObject.MenuItem, { 23142 onClick: () => openModal(KEYBOARD_SHORTCUT_HELP_MODAL_NAME), 23143 shortcut: external_wp_keycodes_namespaceObject.displayShortcut.access('h') 23144 }, (0,external_wp_i18n_namespaceObject.__)('Keyboard shortcuts')), (0,external_React_.createElement)(WelcomeGuideMenuItem, null), (0,external_React_.createElement)(CopyContentMenuItem, null), (0,external_React_.createElement)(external_wp_components_namespaceObject.MenuItem, { 23145 icon: library_external, 23146 role: "menuitem", 23147 href: (0,external_wp_i18n_namespaceObject.__)('https://wordpress.org/documentation/article/site-editor/'), 23148 target: "_blank", 23149 rel: "noopener noreferrer" 23150 }, (0,external_wp_i18n_namespaceObject.__)('Help'), (0,external_React_.createElement)(external_wp_components_namespaceObject.VisuallyHidden, { 23151 as: "span" 23152 }, /* translators: accessibility text */ 23153 (0,external_wp_i18n_namespaceObject.__)('(opens in a new tab)'))), (0,external_React_.createElement)(tools_more_menu_group.Slot, { 23154 fillProps: { 23155 onClose 23156 } 23157 })), (0,external_React_.createElement)(external_wp_components_namespaceObject.MenuGroup, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.MenuItem, { 23158 onClick: () => openModal(PREFERENCES_MODAL_NAME) 23159 }, (0,external_wp_i18n_namespaceObject.__)('Preferences'))))), (0,external_React_.createElement)(KeyboardShortcutHelpModal, null), (0,external_React_.createElement)(EditSitePreferencesModal, null)); 23160 } 23161 23162 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/chevron-up-down.js 23163 23164 /** 23165 * WordPress dependencies 23166 */ 23167 23168 const chevronUpDown = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { 23169 xmlns: "http://www.w3.org/2000/svg", 23170 viewBox: "0 0 24 24" 23171 }, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 23172 d: "m12 20-4.5-3.6-.9 1.2L12 22l5.5-4.4-.9-1.2L12 20zm0-16 4.5 3.6.9-1.2L12 2 6.5 6.4l.9 1.2L12 4z" 23173 })); 23174 /* harmony default export */ const chevron_up_down = (chevronUpDown); 23175 23176 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/header-edit-mode/document-tools/index.js 23177 23178 /** 23179 * WordPress dependencies 23180 */ 23181 23182 23183 23184 23185 23186 23187 23188 23189 /** 23190 * Internal dependencies 23191 */ 23192 23193 23194 const { 23195 DocumentTools: EditorDocumentTools 23196 } = unlock(external_wp_editor_namespaceObject.privateApis); 23197 function DocumentTools({ 23198 blockEditorMode, 23199 hasFixedToolbar, 23200 isDistractionFree 23201 }) { 23202 const { 23203 isVisualMode 23204 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 23205 const { 23206 getEditorMode 23207 } = select(store_store); 23208 return { 23209 isVisualMode: getEditorMode() === 'visual' 23210 }; 23211 }, []); 23212 const { 23213 __unstableSetEditorMode 23214 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store); 23215 const { 23216 setDeviceType 23217 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_editor_namespaceObject.store); 23218 const isLargeViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium'); 23219 const isZoomedOutViewExperimentEnabled = window?.__experimentalEnableZoomedOutView && isVisualMode; 23220 const isZoomedOutView = blockEditorMode === 'zoom-out'; 23221 return (0,external_React_.createElement)(EditorDocumentTools, { 23222 disableBlockTools: !isVisualMode, 23223 listViewLabel: (0,external_wp_i18n_namespaceObject.__)('List View') 23224 }, isZoomedOutViewExperimentEnabled && isLargeViewport && !isDistractionFree && !hasFixedToolbar && (0,external_React_.createElement)(external_wp_components_namespaceObject.ToolbarItem, { 23225 as: external_wp_components_namespaceObject.Button, 23226 className: "edit-site-header-edit-mode__zoom-out-view-toggle", 23227 icon: chevron_up_down, 23228 isPressed: isZoomedOutView 23229 /* translators: button label text should, if possible, be under 16 characters. */, 23230 label: (0,external_wp_i18n_namespaceObject.__)('Zoom-out View'), 23231 onClick: () => { 23232 setDeviceType('Desktop'); 23233 __unstableSetEditorMode(isZoomedOutView ? 'edit' : 'zoom-out'); 23234 }, 23235 size: "compact" 23236 })); 23237 } 23238 23239 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/header-edit-mode/index.js 23240 23241 /** 23242 * External dependencies 23243 */ 23244 23245 23246 /** 23247 * WordPress dependencies 23248 */ 23249 23250 23251 23252 23253 23254 23255 23256 23257 23258 23259 23260 /** 23261 * Internal dependencies 23262 */ 23263 23264 23265 23266 23267 23268 23269 23270 const { 23271 PostViewLink, 23272 PreviewDropdown 23273 } = unlock(external_wp_editor_namespaceObject.privateApis); 23274 function HeaderEditMode() { 23275 const { 23276 templateType, 23277 isDistractionFree, 23278 blockEditorMode, 23279 blockSelectionStart, 23280 showIconLabels, 23281 editorCanvasView, 23282 hasFixedToolbar, 23283 isZoomOutMode 23284 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 23285 const { 23286 getEditedPostType 23287 } = select(store_store); 23288 const { 23289 getBlockSelectionStart, 23290 __unstableGetEditorMode 23291 } = select(external_wp_blockEditor_namespaceObject.store); 23292 const { 23293 get: getPreference 23294 } = select(external_wp_preferences_namespaceObject.store); 23295 const { 23296 getDeviceType 23297 } = select(external_wp_editor_namespaceObject.store); 23298 return { 23299 deviceType: getDeviceType(), 23300 templateType: getEditedPostType(), 23301 blockEditorMode: __unstableGetEditorMode(), 23302 blockSelectionStart: getBlockSelectionStart(), 23303 showIconLabels: getPreference('core', 'showIconLabels'), 23304 editorCanvasView: unlock(select(store_store)).getEditorCanvasContainerView(), 23305 hasFixedToolbar: getPreference('core', 'fixedToolbar'), 23306 isDistractionFree: getPreference('core', 'distractionFree'), 23307 isZoomOutMode: __unstableGetEditorMode() === 'zoom-out' 23308 }; 23309 }, []); 23310 const isLargeViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium'); 23311 const isTopToolbar = !isZoomOutMode && hasFixedToolbar && isLargeViewport; 23312 const blockToolbarRef = (0,external_wp_element_namespaceObject.useRef)(); 23313 const disableMotion = (0,external_wp_compose_namespaceObject.useReducedMotion)(); 23314 const hasDefaultEditorCanvasView = !useHasEditorCanvasContainer(); 23315 const isFocusMode = FOCUSABLE_ENTITIES.includes(templateType); 23316 const isZoomedOutView = blockEditorMode === 'zoom-out'; 23317 const [isBlockToolsCollapsed, setIsBlockToolsCollapsed] = (0,external_wp_element_namespaceObject.useState)(true); 23318 const hasBlockSelected = !!blockSelectionStart; 23319 (0,external_wp_element_namespaceObject.useEffect)(() => { 23320 // If we have a new block selection, show the block tools 23321 if (blockSelectionStart) { 23322 setIsBlockToolsCollapsed(false); 23323 } 23324 }, [blockSelectionStart]); 23325 const toolbarVariants = { 23326 isDistractionFree: { 23327 y: '-50px' 23328 }, 23329 isDistractionFreeHovering: { 23330 y: 0 23331 }, 23332 view: { 23333 y: 0 23334 }, 23335 edit: { 23336 y: 0 23337 } 23338 }; 23339 const toolbarTransition = { 23340 type: 'tween', 23341 duration: disableMotion ? 0 : 0.2, 23342 ease: 'easeOut' 23343 }; 23344 return (0,external_React_.createElement)("div", { 23345 className: classnames_default()('edit-site-header-edit-mode', { 23346 'show-icon-labels': showIconLabels 23347 }) 23348 }, hasDefaultEditorCanvasView && (0,external_React_.createElement)(external_wp_components_namespaceObject.__unstableMotion.div, { 23349 className: "edit-site-header-edit-mode__start", 23350 variants: toolbarVariants, 23351 transition: toolbarTransition 23352 }, (0,external_React_.createElement)(DocumentTools, { 23353 blockEditorMode: blockEditorMode, 23354 isDistractionFree: isDistractionFree 23355 }), isTopToolbar && (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)("div", { 23356 className: classnames_default()('selected-block-tools-wrapper', { 23357 'is-collapsed': isBlockToolsCollapsed || !hasBlockSelected 23358 }) 23359 }, (0,external_React_.createElement)(external_wp_blockEditor_namespaceObject.BlockToolbar, { 23360 hideDragHandle: true 23361 })), (0,external_React_.createElement)(external_wp_components_namespaceObject.Popover.Slot, { 23362 ref: blockToolbarRef, 23363 name: "block-toolbar" 23364 }), hasBlockSelected && (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 23365 className: "edit-site-header-edit-mode__block-tools-toggle", 23366 icon: isBlockToolsCollapsed ? library_next : library_previous, 23367 onClick: () => { 23368 setIsBlockToolsCollapsed(collapsed => !collapsed); 23369 }, 23370 label: isBlockToolsCollapsed ? (0,external_wp_i18n_namespaceObject.__)('Show block tools') : (0,external_wp_i18n_namespaceObject.__)('Hide block tools') 23371 }))), !isDistractionFree && (0,external_React_.createElement)("div", { 23372 className: classnames_default()('edit-site-header-edit-mode__center', { 23373 'is-collapsed': !isBlockToolsCollapsed && isLargeViewport 23374 }) 23375 }, !hasDefaultEditorCanvasView ? getEditorCanvasContainerTitle(editorCanvasView) : (0,external_React_.createElement)(external_wp_editor_namespaceObject.DocumentBar, null)), (0,external_React_.createElement)("div", { 23376 className: "edit-site-header-edit-mode__end" 23377 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__unstableMotion.div, { 23378 className: "edit-site-header-edit-mode__actions", 23379 variants: toolbarVariants, 23380 transition: toolbarTransition 23381 }, isLargeViewport && (0,external_React_.createElement)("div", { 23382 className: classnames_default()('edit-site-header-edit-mode__preview-options', { 23383 'is-zoomed-out': isZoomedOutView 23384 }) 23385 }, (0,external_React_.createElement)(PreviewDropdown, { 23386 disabled: isFocusMode || !hasDefaultEditorCanvasView 23387 })), (0,external_React_.createElement)(PostViewLink, null), (0,external_React_.createElement)(SaveButton, null), !isDistractionFree && (0,external_React_.createElement)(pinned_items.Slot, { 23388 scope: "core/edit-site" 23389 }), (0,external_React_.createElement)(MoreMenu, { 23390 showIconLabels: showIconLabels 23391 })))); 23392 } 23393 23394 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/wordpress.js 23395 23396 /** 23397 * WordPress dependencies 23398 */ 23399 23400 const wordpress = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { 23401 xmlns: "http://www.w3.org/2000/svg", 23402 viewBox: "-2 -2 24 24" 23403 }, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 23404 d: "M20 10c0-5.51-4.49-10-10-10C4.48 0 0 4.49 0 10c0 5.52 4.48 10 10 10 5.51 0 10-4.48 10-10zM7.78 15.37L4.37 6.22c.55-.02 1.17-.08 1.17-.08.5-.06.44-1.13-.06-1.11 0 0-1.45.11-2.37.11-.18 0-.37 0-.58-.01C4.12 2.69 6.87 1.11 10 1.11c2.33 0 4.45.87 6.05 2.34-.68-.11-1.65.39-1.65 1.58 0 .74.45 1.36.9 2.1.35.61.55 1.36.55 2.46 0 1.49-1.4 5-1.4 5l-3.03-8.37c.54-.02.82-.17.82-.17.5-.05.44-1.25-.06-1.22 0 0-1.44.12-2.38.12-.87 0-2.33-.12-2.33-.12-.5-.03-.56 1.2-.06 1.22l.92.08 1.26 3.41zM17.41 10c.24-.64.74-1.87.43-4.25.7 1.29 1.05 2.71 1.05 4.25 0 3.29-1.73 6.24-4.4 7.78.97-2.59 1.94-5.2 2.92-7.78zM6.1 18.09C3.12 16.65 1.11 13.53 1.11 10c0-1.3.23-2.48.72-3.59C3.25 10.3 4.67 14.2 6.1 18.09zm4.03-6.63l2.58 6.98c-.86.29-1.76.45-2.71.45-.79 0-1.57-.11-2.29-.33.81-2.38 1.62-4.74 2.42-7.1z" 23405 })); 23406 /* harmony default export */ const library_wordpress = (wordpress); 23407 23408 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/site-icon/index.js 23409 23410 /** 23411 * External dependencies 23412 */ 23413 23414 23415 /** 23416 * WordPress dependencies 23417 */ 23418 23419 23420 23421 23422 23423 function SiteIcon({ 23424 className 23425 }) { 23426 const { 23427 isRequestingSite, 23428 siteIconUrl 23429 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 23430 const { 23431 getEntityRecord 23432 } = select(external_wp_coreData_namespaceObject.store); 23433 const siteData = getEntityRecord('root', '__unstableBase', undefined); 23434 return { 23435 isRequestingSite: !siteData, 23436 siteIconUrl: siteData?.site_icon_url 23437 }; 23438 }, []); 23439 if (isRequestingSite && !siteIconUrl) { 23440 return (0,external_React_.createElement)("div", { 23441 className: "edit-site-site-icon__image" 23442 }); 23443 } 23444 const icon = siteIconUrl ? (0,external_React_.createElement)("img", { 23445 className: "edit-site-site-icon__image", 23446 alt: (0,external_wp_i18n_namespaceObject.__)('Site Icon'), 23447 src: siteIconUrl 23448 }) : (0,external_React_.createElement)(external_wp_components_namespaceObject.Icon, { 23449 className: "edit-site-site-icon__icon", 23450 icon: library_wordpress, 23451 size: 48 23452 }); 23453 return (0,external_React_.createElement)("div", { 23454 className: classnames_default()(className, 'edit-site-site-icon') 23455 }, icon); 23456 } 23457 /* harmony default export */ const site_icon = (SiteIcon); 23458 23459 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/site-hub/index.js 23460 23461 /** 23462 * External dependencies 23463 */ 23464 23465 23466 /** 23467 * WordPress dependencies 23468 */ 23469 23470 23471 23472 23473 23474 23475 23476 23477 23478 23479 23480 23481 23482 /** 23483 * Internal dependencies 23484 */ 23485 23486 23487 23488 const HUB_ANIMATION_DURATION = 0.3; 23489 const SiteHub = (0,external_wp_element_namespaceObject.memo)(({ 23490 isTransparent, 23491 className 23492 }) => { 23493 const { 23494 canvasMode, 23495 dashboardLink, 23496 homeUrl, 23497 siteTitle 23498 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 23499 const { 23500 getCanvasMode, 23501 getSettings 23502 } = unlock(select(store_store)); 23503 const { 23504 getSite, 23505 getUnstableBase // Site index. 23506 } = select(external_wp_coreData_namespaceObject.store); 23507 return { 23508 canvasMode: getCanvasMode(), 23509 dashboardLink: getSettings().__experimentalDashboardLink || 'index.php', 23510 homeUrl: getUnstableBase()?.home, 23511 siteTitle: getSite()?.title 23512 }; 23513 }, []); 23514 const { 23515 open: openCommandCenter 23516 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_commands_namespaceObject.store); 23517 const disableMotion = (0,external_wp_compose_namespaceObject.useReducedMotion)(); 23518 const { 23519 setCanvasMode 23520 } = unlock((0,external_wp_data_namespaceObject.useDispatch)(store_store)); 23521 const { 23522 clearSelectedBlock 23523 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store); 23524 const { 23525 setDeviceType 23526 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_editor_namespaceObject.store); 23527 const isBackToDashboardButton = canvasMode === 'view'; 23528 const siteIconButtonProps = isBackToDashboardButton ? { 23529 href: dashboardLink, 23530 label: (0,external_wp_i18n_namespaceObject.__)('Go to the Dashboard') 23531 } : { 23532 href: dashboardLink, 23533 // We need to keep the `href` here so the component doesn't remount as a `<button>` and break the animation. 23534 role: 'button', 23535 label: (0,external_wp_i18n_namespaceObject.__)('Open Navigation'), 23536 onClick: event => { 23537 event.preventDefault(); 23538 if (canvasMode === 'edit') { 23539 clearSelectedBlock(); 23540 setDeviceType('Desktop'); 23541 setCanvasMode('view'); 23542 } 23543 } 23544 }; 23545 return (0,external_React_.createElement)(external_wp_components_namespaceObject.__unstableMotion.div, { 23546 className: classnames_default()('edit-site-site-hub', className), 23547 variants: { 23548 isDistractionFree: { 23549 x: '-100%' 23550 }, 23551 isDistractionFreeHovering: { 23552 x: 0 23553 }, 23554 view: { 23555 x: 0 23556 }, 23557 edit: { 23558 x: 0 23559 } 23560 }, 23561 initial: false, 23562 transition: { 23563 type: 'tween', 23564 duration: disableMotion ? 0 : HUB_ANIMATION_DURATION, 23565 ease: 'easeOut' 23566 } 23567 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { 23568 justify: "space-between", 23569 alignment: "center", 23570 className: "edit-site-site-hub__container" 23571 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { 23572 justify: "flex-start", 23573 className: "edit-site-site-hub__text-content", 23574 spacing: "0" 23575 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__unstableMotion.div, { 23576 className: classnames_default()('edit-site-site-hub__view-mode-toggle-container', { 23577 'has-transparent-background': isTransparent 23578 }), 23579 layout: true, 23580 transition: { 23581 type: 'tween', 23582 duration: disableMotion ? 0 : HUB_ANIMATION_DURATION, 23583 ease: 'easeOut' 23584 } 23585 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 23586 ...siteIconButtonProps, 23587 className: "edit-site-layout__view-mode-toggle" 23588 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__unstableMotion.div, { 23589 initial: false, 23590 animate: { 23591 scale: canvasMode === 'view' ? 0.5 : 1 23592 }, 23593 whileHover: { 23594 scale: canvasMode === 'view' ? 0.5 : 0.96 23595 }, 23596 transition: { 23597 type: 'tween', 23598 duration: disableMotion ? 0 : HUB_ANIMATION_DURATION, 23599 ease: 'easeOut' 23600 } 23601 }, (0,external_React_.createElement)(site_icon, { 23602 className: "edit-site-layout__view-mode-toggle-icon" 23603 })))), (0,external_React_.createElement)(external_wp_components_namespaceObject.__unstableAnimatePresence, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.__unstableMotion.div, { 23604 layout: canvasMode === 'edit', 23605 animate: { 23606 opacity: canvasMode === 'view' ? 1 : 0 23607 }, 23608 exit: { 23609 opacity: 0 23610 }, 23611 className: classnames_default()('edit-site-site-hub__site-title', { 23612 'is-transparent': isTransparent 23613 }), 23614 transition: { 23615 type: 'tween', 23616 duration: disableMotion ? 0 : 0.2, 23617 ease: 'easeOut', 23618 delay: canvasMode === 'view' ? 0.1 : 0 23619 } 23620 }, (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(siteTitle))), canvasMode === 'view' && (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 23621 href: homeUrl, 23622 target: "_blank", 23623 label: (0,external_wp_i18n_namespaceObject.__)('View site (opens in a new tab)'), 23624 "aria-label": (0,external_wp_i18n_namespaceObject.__)('View site (opens in a new tab)'), 23625 icon: library_external, 23626 className: classnames_default()('edit-site-site-hub__site-view-link', { 23627 'is-transparent': isTransparent 23628 }) 23629 })), canvasMode === 'view' && (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 23630 className: classnames_default()('edit-site-site-hub_toggle-command-center', { 23631 'is-transparent': isTransparent 23632 }), 23633 icon: library_search, 23634 onClick: () => openCommandCenter(), 23635 label: (0,external_wp_i18n_namespaceObject.__)('Open command palette'), 23636 shortcut: external_wp_keycodes_namespaceObject.displayShortcut.primary('k') 23637 }))); 23638 }); 23639 /* harmony default export */ const site_hub = (SiteHub); 23640 23641 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/resizable-frame/index.js 23642 23643 /** 23644 * External dependencies 23645 */ 23646 23647 23648 /** 23649 * WordPress dependencies 23650 */ 23651 23652 23653 23654 23655 23656 23657 /** 23658 * Internal dependencies 23659 */ 23660 23661 23662 23663 // Removes the inline styles in the drag handles. 23664 const resizable_frame_HANDLE_STYLES_OVERRIDE = { 23665 position: undefined, 23666 userSelect: undefined, 23667 cursor: undefined, 23668 width: undefined, 23669 height: undefined, 23670 top: undefined, 23671 right: undefined, 23672 bottom: undefined, 23673 left: undefined 23674 }; 23675 23676 // The minimum width of the frame (in px) while resizing. 23677 const FRAME_MIN_WIDTH = 320; 23678 // The reference width of the frame (in px) used to calculate the aspect ratio. 23679 const FRAME_REFERENCE_WIDTH = 1300; 23680 // 9 : 19.5 is the target aspect ratio enforced (when possible) while resizing. 23681 const FRAME_TARGET_ASPECT_RATIO = 9 / 19.5; 23682 // The minimum distance (in px) between the frame resize handle and the 23683 // viewport's edge. If the frame is resized to be closer to the viewport's edge 23684 // than this distance, then "canvas mode" will be enabled. 23685 const SNAP_TO_EDIT_CANVAS_MODE_THRESHOLD = 200; 23686 // Default size for the `frameSize` state. 23687 const INITIAL_FRAME_SIZE = { 23688 width: '100%', 23689 height: '100%' 23690 }; 23691 function calculateNewHeight(width, initialAspectRatio) { 23692 const lerp = (a, b, amount) => { 23693 return a + (b - a) * amount; 23694 }; 23695 23696 // Calculate the intermediate aspect ratio based on the current width. 23697 const lerpFactor = 1 - Math.max(0, Math.min(1, (width - FRAME_MIN_WIDTH) / (FRAME_REFERENCE_WIDTH - FRAME_MIN_WIDTH))); 23698 23699 // Calculate the height based on the intermediate aspect ratio 23700 // ensuring the frame arrives at the target aspect ratio. 23701 const intermediateAspectRatio = lerp(initialAspectRatio, FRAME_TARGET_ASPECT_RATIO, lerpFactor); 23702 return width / intermediateAspectRatio; 23703 } 23704 function ResizableFrame({ 23705 isFullWidth, 23706 isOversized, 23707 setIsOversized, 23708 isReady, 23709 children, 23710 /** The default (unresized) width/height of the frame, based on the space availalbe in the viewport. */ 23711 defaultSize, 23712 innerContentStyle 23713 }) { 23714 const [frameSize, setFrameSize] = (0,external_wp_element_namespaceObject.useState)(INITIAL_FRAME_SIZE); 23715 // The width of the resizable frame when a new resize gesture starts. 23716 const [startingWidth, setStartingWidth] = (0,external_wp_element_namespaceObject.useState)(); 23717 const [isResizing, setIsResizing] = (0,external_wp_element_namespaceObject.useState)(false); 23718 const [shouldShowHandle, setShouldShowHandle] = (0,external_wp_element_namespaceObject.useState)(false); 23719 const [resizeRatio, setResizeRatio] = (0,external_wp_element_namespaceObject.useState)(1); 23720 const canvasMode = (0,external_wp_data_namespaceObject.useSelect)(select => unlock(select(store_store)).getCanvasMode(), []); 23721 const { 23722 setCanvasMode 23723 } = unlock((0,external_wp_data_namespaceObject.useDispatch)(store_store)); 23724 const FRAME_TRANSITION = { 23725 type: 'tween', 23726 duration: isResizing ? 0 : 0.5 23727 }; 23728 const frameRef = (0,external_wp_element_namespaceObject.useRef)(null); 23729 const resizableHandleHelpId = (0,external_wp_compose_namespaceObject.useInstanceId)(ResizableFrame, 'edit-site-resizable-frame-handle-help'); 23730 const defaultAspectRatio = defaultSize.width / defaultSize.height; 23731 const handleResizeStart = (_event, _direction, ref) => { 23732 // Remember the starting width so we don't have to get `ref.offsetWidth` on 23733 // every resize event thereafter, which will cause layout thrashing. 23734 setStartingWidth(ref.offsetWidth); 23735 setIsResizing(true); 23736 }; 23737 23738 // Calculate the frame size based on the window width as its resized. 23739 const handleResize = (_event, _direction, _ref, delta) => { 23740 const normalizedDelta = delta.width / resizeRatio; 23741 const deltaAbs = Math.abs(normalizedDelta); 23742 const maxDoubledDelta = delta.width < 0 // is shrinking 23743 ? deltaAbs : (defaultSize.width - startingWidth) / 2; 23744 const deltaToDouble = Math.min(deltaAbs, maxDoubledDelta); 23745 const doubleSegment = deltaAbs === 0 ? 0 : deltaToDouble / deltaAbs; 23746 const singleSegment = 1 - doubleSegment; 23747 setResizeRatio(singleSegment + doubleSegment * 2); 23748 const updatedWidth = startingWidth + delta.width; 23749 setIsOversized(updatedWidth > defaultSize.width); 23750 23751 // Width will be controlled by the library (via `resizeRatio`), 23752 // so we only need to update the height. 23753 setFrameSize({ 23754 height: isOversized ? '100%' : calculateNewHeight(updatedWidth, defaultAspectRatio) 23755 }); 23756 }; 23757 const handleResizeStop = (_event, _direction, ref) => { 23758 setIsResizing(false); 23759 if (!isOversized) { 23760 return; 23761 } 23762 setIsOversized(false); 23763 const remainingWidth = ref.ownerDocument.documentElement.offsetWidth - ref.offsetWidth; 23764 if (remainingWidth > SNAP_TO_EDIT_CANVAS_MODE_THRESHOLD) { 23765 // Reset the initial aspect ratio if the frame is resized slightly 23766 // above the sidebar but not far enough to trigger full screen. 23767 setFrameSize(INITIAL_FRAME_SIZE); 23768 } else { 23769 // Trigger full screen if the frame is resized far enough to the left. 23770 setCanvasMode('edit'); 23771 } 23772 }; 23773 23774 // Handle resize by arrow keys 23775 const handleResizableHandleKeyDown = event => { 23776 if (!['ArrowLeft', 'ArrowRight'].includes(event.key)) { 23777 return; 23778 } 23779 event.preventDefault(); 23780 const step = 20 * (event.shiftKey ? 5 : 1); 23781 const delta = step * (event.key === 'ArrowLeft' ? 1 : -1); 23782 const newWidth = Math.min(Math.max(FRAME_MIN_WIDTH, frameRef.current.resizable.offsetWidth + delta), defaultSize.width); 23783 setFrameSize({ 23784 width: newWidth, 23785 height: calculateNewHeight(newWidth, defaultAspectRatio) 23786 }); 23787 }; 23788 const frameAnimationVariants = { 23789 default: { 23790 flexGrow: 0, 23791 height: frameSize.height 23792 }, 23793 fullWidth: { 23794 flexGrow: 1, 23795 height: frameSize.height 23796 } 23797 }; 23798 const resizeHandleVariants = { 23799 hidden: { 23800 opacity: 0, 23801 left: 0 23802 }, 23803 visible: { 23804 opacity: 1, 23805 left: -16 23806 }, 23807 active: { 23808 opacity: 1, 23809 left: -16, 23810 scaleY: 1.3 23811 } 23812 }; 23813 const currentResizeHandleVariant = (() => { 23814 if (isResizing) { 23815 return 'active'; 23816 } 23817 return shouldShowHandle ? 'visible' : 'hidden'; 23818 })(); 23819 return (0,external_React_.createElement)(external_wp_components_namespaceObject.ResizableBox, { 23820 as: external_wp_components_namespaceObject.__unstableMotion.div, 23821 ref: frameRef, 23822 initial: false, 23823 variants: frameAnimationVariants, 23824 animate: isFullWidth ? 'fullWidth' : 'default', 23825 onAnimationComplete: definition => { 23826 if (definition === 'fullWidth') setFrameSize({ 23827 width: '100%', 23828 height: '100%' 23829 }); 23830 }, 23831 transition: FRAME_TRANSITION, 23832 size: frameSize, 23833 enable: { 23834 top: false, 23835 right: false, 23836 bottom: false, 23837 // Resizing will be disabled until the editor content is loaded. 23838 left: isReady, 23839 topRight: false, 23840 bottomRight: false, 23841 bottomLeft: false, 23842 topLeft: false 23843 }, 23844 resizeRatio: resizeRatio, 23845 handleClasses: undefined, 23846 handleStyles: { 23847 left: resizable_frame_HANDLE_STYLES_OVERRIDE, 23848 right: resizable_frame_HANDLE_STYLES_OVERRIDE 23849 }, 23850 minWidth: FRAME_MIN_WIDTH, 23851 maxWidth: isFullWidth ? '100%' : '150%', 23852 maxHeight: '100%', 23853 onFocus: () => setShouldShowHandle(true), 23854 onBlur: () => setShouldShowHandle(false), 23855 onMouseOver: () => setShouldShowHandle(true), 23856 onMouseOut: () => setShouldShowHandle(false), 23857 handleComponent: { 23858 left: canvasMode === 'view' && (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.Tooltip, { 23859 text: (0,external_wp_i18n_namespaceObject.__)('Drag to resize') 23860 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__unstableMotion.button, { 23861 key: "handle", 23862 role: "separator", 23863 "aria-orientation": "vertical", 23864 className: classnames_default()('edit-site-resizable-frame__handle', { 23865 'is-resizing': isResizing 23866 }), 23867 variants: resizeHandleVariants, 23868 animate: currentResizeHandleVariant, 23869 "aria-label": (0,external_wp_i18n_namespaceObject.__)('Drag to resize'), 23870 "aria-describedby": resizableHandleHelpId, 23871 "aria-valuenow": frameRef.current?.resizable?.offsetWidth || undefined, 23872 "aria-valuemin": FRAME_MIN_WIDTH, 23873 "aria-valuemax": defaultSize.width, 23874 onKeyDown: handleResizableHandleKeyDown, 23875 initial: "hidden", 23876 exit: "hidden", 23877 whileFocus: "active", 23878 whileHover: "active" 23879 })), (0,external_React_.createElement)("div", { 23880 hidden: true, 23881 id: resizableHandleHelpId 23882 }, (0,external_wp_i18n_namespaceObject.__)('Use left and right arrow keys to resize the canvas. Hold shift to resize in larger increments.'))) 23883 }, 23884 onResizeStart: handleResizeStart, 23885 onResize: handleResize, 23886 onResizeStop: handleResizeStop, 23887 className: classnames_default()('edit-site-resizable-frame__inner', { 23888 'is-resizing': isResizing 23889 }), 23890 showHandle: false // Do not show the default handle, as we're using a custom one. 23891 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__unstableMotion.div, { 23892 className: "edit-site-resizable-frame__inner-content", 23893 animate: { 23894 borderRadius: isFullWidth ? 0 : 8 23895 }, 23896 transition: FRAME_TRANSITION, 23897 style: innerContentStyle 23898 }, children)); 23899 } 23900 /* harmony default export */ const resizable_frame = (ResizableFrame); 23901 23902 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sync-state-with-url/use-sync-canvas-mode-with-url.js 23903 /** 23904 * WordPress dependencies 23905 */ 23906 23907 23908 23909 23910 /** 23911 * Internal dependencies 23912 */ 23913 23914 23915 const { 23916 useLocation: use_sync_canvas_mode_with_url_useLocation, 23917 useHistory: use_sync_canvas_mode_with_url_useHistory 23918 } = unlock(external_wp_router_namespaceObject.privateApis); 23919 function useSyncCanvasModeWithURL() { 23920 const history = use_sync_canvas_mode_with_url_useHistory(); 23921 const { 23922 params 23923 } = use_sync_canvas_mode_with_url_useLocation(); 23924 const canvasMode = (0,external_wp_data_namespaceObject.useSelect)(select => unlock(select(store_store)).getCanvasMode(), []); 23925 const { 23926 setCanvasMode 23927 } = unlock((0,external_wp_data_namespaceObject.useDispatch)(store_store)); 23928 const currentCanvasMode = (0,external_wp_element_namespaceObject.useRef)(canvasMode); 23929 const { 23930 canvas: canvasInUrl 23931 } = params; 23932 const currentCanvasInUrl = (0,external_wp_element_namespaceObject.useRef)(canvasInUrl); 23933 const currentUrlParams = (0,external_wp_element_namespaceObject.useRef)(params); 23934 (0,external_wp_element_namespaceObject.useEffect)(() => { 23935 currentUrlParams.current = params; 23936 }, [params]); 23937 (0,external_wp_element_namespaceObject.useEffect)(() => { 23938 currentCanvasMode.current = canvasMode; 23939 if (canvasMode === 'init') { 23940 return; 23941 } 23942 if (canvasMode === 'edit' && currentCanvasInUrl.current !== canvasMode) { 23943 history.push({ 23944 ...currentUrlParams.current, 23945 canvas: 'edit' 23946 }); 23947 } 23948 if (canvasMode === 'view' && currentCanvasInUrl.current !== undefined) { 23949 history.push({ 23950 ...currentUrlParams.current, 23951 canvas: undefined 23952 }); 23953 } 23954 }, [canvasMode, history]); 23955 (0,external_wp_element_namespaceObject.useEffect)(() => { 23956 currentCanvasInUrl.current = canvasInUrl; 23957 if (canvasInUrl !== 'edit' && currentCanvasMode.current !== 'view') { 23958 setCanvasMode('view'); 23959 } else if (canvasInUrl === 'edit' && currentCanvasMode.current !== 'edit') { 23960 setCanvasMode('edit'); 23961 } 23962 }, [canvasInUrl, setCanvasMode]); 23963 } 23964 23965 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/utils/use-activate-theme.js 23966 /** 23967 * WordPress dependencies 23968 */ 23969 23970 23971 23972 23973 /** 23974 * Internal dependencies 23975 */ 23976 23977 23978 const { 23979 useHistory: use_activate_theme_useHistory, 23980 useLocation: use_activate_theme_useLocation 23981 } = unlock(external_wp_router_namespaceObject.privateApis); 23982 23983 /** 23984 * This should be refactored to use the REST API, once the REST API can activate themes. 23985 * 23986 * @return {Function} A function that activates the theme. 23987 */ 23988 function useActivateTheme() { 23989 const history = use_activate_theme_useHistory(); 23990 const location = use_activate_theme_useLocation(); 23991 const { 23992 startResolution, 23993 finishResolution 23994 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store); 23995 return async () => { 23996 if (isPreviewingTheme()) { 23997 const activationURL = 'themes.php?action=activate&stylesheet=' + currentlyPreviewingTheme() + '&_wpnonce=' + window.WP_BLOCK_THEME_ACTIVATE_NONCE; 23998 startResolution('activateTheme'); 23999 await window.fetch(activationURL); 24000 finishResolution('activateTheme'); 24001 const { 24002 wp_theme_preview: themePreview, 24003 ...params 24004 } = location.params; 24005 history.replace(params); 24006 } 24007 }; 24008 } 24009 24010 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/utils/use-actual-current-theme.js 24011 /** 24012 * WordPress dependencies 24013 */ 24014 24015 24016 24017 const ACTIVE_THEMES_URL = '/wp/v2/themes?status=active'; 24018 function useActualCurrentTheme() { 24019 const [currentTheme, setCurrentTheme] = (0,external_wp_element_namespaceObject.useState)(); 24020 (0,external_wp_element_namespaceObject.useEffect)(() => { 24021 // Set the `wp_theme_preview` to empty string to bypass the createThemePreviewMiddleware. 24022 const path = (0,external_wp_url_namespaceObject.addQueryArgs)(ACTIVE_THEMES_URL, { 24023 context: 'edit', 24024 wp_theme_preview: '' 24025 }); 24026 external_wp_apiFetch_default()({ 24027 path 24028 }).then(activeThemes => setCurrentTheme(activeThemes[0])) 24029 // Do nothing 24030 .catch(() => {}); 24031 }, []); 24032 return currentTheme; 24033 } 24034 24035 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/save-panel/index.js 24036 24037 /** 24038 * External dependencies 24039 */ 24040 24041 24042 /** 24043 * WordPress dependencies 24044 */ 24045 24046 24047 24048 24049 24050 24051 24052 /** 24053 * Internal dependencies 24054 */ 24055 24056 24057 24058 24059 24060 const { 24061 EntitiesSavedStatesExtensible 24062 } = unlock(external_wp_editor_namespaceObject.privateApis); 24063 const EntitiesSavedStatesForPreview = ({ 24064 onClose 24065 }) => { 24066 var _currentTheme$name$re, _previewingTheme$name; 24067 const isDirtyProps = (0,external_wp_editor_namespaceObject.useEntitiesSavedStatesIsDirty)(); 24068 let activateSaveLabel; 24069 if (isDirtyProps.isDirty) { 24070 activateSaveLabel = (0,external_wp_i18n_namespaceObject.__)('Activate & Save'); 24071 } else { 24072 activateSaveLabel = (0,external_wp_i18n_namespaceObject.__)('Activate'); 24073 } 24074 const currentTheme = useActualCurrentTheme(); 24075 const previewingTheme = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).getCurrentTheme(), []); 24076 const additionalPrompt = (0,external_React_.createElement)("p", null, (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %1$s: The name of active theme, %2$s: The name of theme to be activated. */ 24077 (0,external_wp_i18n_namespaceObject.__)('Saving your changes will change your active theme from %1$s to %2$s.'), (_currentTheme$name$re = currentTheme?.name?.rendered) !== null && _currentTheme$name$re !== void 0 ? _currentTheme$name$re : '...', (_previewingTheme$name = previewingTheme?.name?.rendered) !== null && _previewingTheme$name !== void 0 ? _previewingTheme$name : '...')); 24078 const activateTheme = useActivateTheme(); 24079 const onSave = async values => { 24080 await activateTheme(); 24081 return values; 24082 }; 24083 return (0,external_React_.createElement)(EntitiesSavedStatesExtensible, { 24084 ...isDirtyProps, 24085 additionalPrompt, 24086 close: onClose, 24087 onSave, 24088 saveEnabled: true, 24089 saveLabel: activateSaveLabel 24090 }); 24091 }; 24092 const _EntitiesSavedStates = ({ 24093 onClose 24094 }) => { 24095 if (isPreviewingTheme()) { 24096 return (0,external_React_.createElement)(EntitiesSavedStatesForPreview, { 24097 onClose: onClose 24098 }); 24099 } 24100 return (0,external_React_.createElement)(external_wp_editor_namespaceObject.EntitiesSavedStates, { 24101 close: onClose 24102 }); 24103 }; 24104 function SavePanel() { 24105 const { 24106 isSaveViewOpen, 24107 canvasMode 24108 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 24109 const { 24110 isSaveViewOpened, 24111 getCanvasMode 24112 } = unlock(select(store_store)); 24113 24114 // The currently selected entity to display. 24115 // Typically template or template part in the site editor. 24116 return { 24117 isSaveViewOpen: isSaveViewOpened(), 24118 canvasMode: getCanvasMode() 24119 }; 24120 }, []); 24121 const { 24122 setIsSaveViewOpened 24123 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store); 24124 const onClose = () => setIsSaveViewOpened(false); 24125 if (canvasMode === 'view') { 24126 return isSaveViewOpen ? (0,external_React_.createElement)(external_wp_components_namespaceObject.Modal, { 24127 className: "edit-site-save-panel__modal", 24128 onRequestClose: onClose, 24129 __experimentalHideHeader: true, 24130 contentLabel: (0,external_wp_i18n_namespaceObject.__)('Save site, content, and template changes') 24131 }, (0,external_React_.createElement)(_EntitiesSavedStates, { 24132 onClose: onClose 24133 })) : null; 24134 } 24135 return (0,external_React_.createElement)(NavigableRegion, { 24136 className: classnames_default()('edit-site-layout__actions', { 24137 'is-entity-save-view-open': isSaveViewOpen 24138 }), 24139 ariaLabel: (0,external_wp_i18n_namespaceObject.__)('Save panel') 24140 }, isSaveViewOpen ? (0,external_React_.createElement)(_EntitiesSavedStates, { 24141 onClose: onClose 24142 }) : (0,external_React_.createElement)("div", { 24143 className: "edit-site-editor__toggle-save-panel" 24144 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 24145 variant: "secondary", 24146 className: "edit-site-editor__toggle-save-panel-button", 24147 onClick: () => setIsSaveViewOpened(true), 24148 "aria-expanded": false 24149 }, (0,external_wp_i18n_namespaceObject.__)('Open save panel')))); 24150 } 24151 24152 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/keyboard-shortcuts/register.js 24153 /** 24154 * WordPress dependencies 24155 */ 24156 24157 24158 24159 24160 function KeyboardShortcutsRegister() { 24161 // Registering the shortcuts. 24162 const { 24163 registerShortcut 24164 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_keyboardShortcuts_namespaceObject.store); 24165 (0,external_wp_element_namespaceObject.useEffect)(() => { 24166 registerShortcut({ 24167 name: 'core/edit-site/save', 24168 category: 'global', 24169 description: (0,external_wp_i18n_namespaceObject.__)('Save your changes.'), 24170 keyCombination: { 24171 modifier: 'primary', 24172 character: 's' 24173 } 24174 }); 24175 registerShortcut({ 24176 name: 'core/edit-site/toggle-block-settings-sidebar', 24177 category: 'global', 24178 description: (0,external_wp_i18n_namespaceObject.__)('Show or hide the Settings sidebar.'), 24179 keyCombination: { 24180 modifier: 'primaryShift', 24181 character: ',' 24182 } 24183 }); 24184 registerShortcut({ 24185 name: 'core/edit-site/keyboard-shortcuts', 24186 category: 'main', 24187 description: (0,external_wp_i18n_namespaceObject.__)('Display these keyboard shortcuts.'), 24188 keyCombination: { 24189 modifier: 'access', 24190 character: 'h' 24191 } 24192 }); 24193 registerShortcut({ 24194 name: 'core/edit-site/next-region', 24195 category: 'global', 24196 description: (0,external_wp_i18n_namespaceObject.__)('Navigate to the next part of the editor.'), 24197 keyCombination: { 24198 modifier: 'ctrl', 24199 character: '`' 24200 }, 24201 aliases: [{ 24202 modifier: 'access', 24203 character: 'n' 24204 }] 24205 }); 24206 registerShortcut({ 24207 name: 'core/edit-site/previous-region', 24208 category: 'global', 24209 description: (0,external_wp_i18n_namespaceObject.__)('Navigate to the previous part of the editor.'), 24210 keyCombination: { 24211 modifier: 'ctrlShift', 24212 character: '`' 24213 }, 24214 aliases: [{ 24215 modifier: 'access', 24216 character: 'p' 24217 }, { 24218 modifier: 'ctrlShift', 24219 character: '~' 24220 }] 24221 }); 24222 registerShortcut({ 24223 name: 'core/edit-site/toggle-mode', 24224 category: 'global', 24225 description: (0,external_wp_i18n_namespaceObject.__)('Switch between visual editor and code editor.'), 24226 keyCombination: { 24227 modifier: 'secondary', 24228 character: 'm' 24229 } 24230 }); 24231 registerShortcut({ 24232 name: 'core/edit-site/transform-heading-to-paragraph', 24233 category: 'block-library', 24234 description: (0,external_wp_i18n_namespaceObject.__)('Transform heading to paragraph.'), 24235 keyCombination: { 24236 modifier: 'access', 24237 character: `0` 24238 } 24239 }); 24240 [1, 2, 3, 4, 5, 6].forEach(level => { 24241 registerShortcut({ 24242 name: `core/edit-site/transform-paragraph-to-heading-$level}`, 24243 category: 'block-library', 24244 description: (0,external_wp_i18n_namespaceObject.__)('Transform paragraph to heading.'), 24245 keyCombination: { 24246 modifier: 'access', 24247 character: `$level}` 24248 } 24249 }); 24250 }); 24251 registerShortcut({ 24252 name: 'core/edit-site/toggle-distraction-free', 24253 category: 'global', 24254 description: (0,external_wp_i18n_namespaceObject.__)('Toggle distraction free mode.'), 24255 keyCombination: { 24256 modifier: 'primaryShift', 24257 character: '\\' 24258 } 24259 }); 24260 }, [registerShortcut]); 24261 return null; 24262 } 24263 /* harmony default export */ const register = (KeyboardShortcutsRegister); 24264 24265 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/keyboard-shortcuts/global.js 24266 /** 24267 * WordPress dependencies 24268 */ 24269 24270 24271 24272 24273 24274 /** 24275 * Internal dependencies 24276 */ 24277 24278 24279 function KeyboardShortcutsGlobal() { 24280 const { 24281 __experimentalGetDirtyEntityRecords, 24282 isSavingEntityRecord 24283 } = (0,external_wp_data_namespaceObject.useSelect)(external_wp_coreData_namespaceObject.store); 24284 const { 24285 hasNonPostEntityChanges 24286 } = (0,external_wp_data_namespaceObject.useSelect)(external_wp_editor_namespaceObject.store); 24287 const { 24288 getCanvasMode 24289 } = unlock((0,external_wp_data_namespaceObject.useSelect)(store_store)); 24290 const { 24291 setIsSaveViewOpened 24292 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store); 24293 (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/edit-site/save', event => { 24294 event.preventDefault(); 24295 const dirtyEntityRecords = __experimentalGetDirtyEntityRecords(); 24296 const hasDirtyEntities = !!dirtyEntityRecords.length; 24297 const isSaving = dirtyEntityRecords.some(record => isSavingEntityRecord(record.kind, record.name, record.key)); 24298 const _hasNonPostEntityChanges = hasNonPostEntityChanges(); 24299 const isViewMode = getCanvasMode() === 'view'; 24300 if ((!hasDirtyEntities || !_hasNonPostEntityChanges || isSaving) && !isViewMode) { 24301 return; 24302 } 24303 // At this point, we know that there are dirty entities, other than 24304 // the edited post, and we're not in the process of saving, so open 24305 // save view. 24306 setIsSaveViewOpened(true); 24307 }); 24308 return null; 24309 } 24310 /* harmony default export */ const global = (KeyboardShortcutsGlobal); 24311 24312 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/help.js 24313 24314 /** 24315 * WordPress dependencies 24316 */ 24317 24318 const help = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { 24319 xmlns: "http://www.w3.org/2000/svg", 24320 viewBox: "0 0 24 24" 24321 }, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 24322 d: "M12 4.75a7.25 7.25 0 100 14.5 7.25 7.25 0 000-14.5zM3.25 12a8.75 8.75 0 1117.5 0 8.75 8.75 0 01-17.5 0zM12 8.75a1.5 1.5 0 01.167 2.99c-.465.052-.917.44-.917 1.01V14h1.5v-.845A3 3 0 109 10.25h1.5a1.5 1.5 0 011.5-1.5zM11.25 15v1.5h1.5V15h-1.5z" 24323 })); 24324 /* harmony default export */ const library_help = (help); 24325 24326 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/rotate-right.js 24327 24328 /** 24329 * WordPress dependencies 24330 */ 24331 24332 const rotateRight = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { 24333 xmlns: "http://www.w3.org/2000/svg", 24334 viewBox: "0 0 24 24" 24335 }, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 24336 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" 24337 })); 24338 /* harmony default export */ const rotate_right = (rotateRight); 24339 24340 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/rotate-left.js 24341 24342 /** 24343 * WordPress dependencies 24344 */ 24345 24346 const rotateLeft = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { 24347 xmlns: "http://www.w3.org/2000/svg", 24348 viewBox: "0 0 24 24" 24349 }, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 24350 d: "M12 4V2.2L9 4.8l3 2.5V5.5c3.6 0 6.5 2.9 6.5 6.5 0 2.9-1.9 5.3-4.5 6.2v.2l-.1-.2c-.4.1-.7.2-1.1.2l.2 1.5c.3 0 .6-.1 1-.2 3.5-.9 6-4 6-7.7 0-4.4-3.6-8-8-8zm-7.9 7l1.5.2c.1-1.2.5-2.3 1.2-3.2l-1.1-.9C4.8 8.2 4.3 9.6 4.1 11zm1.5 1.8l-1.5.2c.1.7.3 1.4.5 2 .3.7.6 1.3 1 1.8l1.2-.8c-.3-.5-.6-1-.8-1.5s-.4-1.1-.4-1.7zm1.5 5.5c1.1.9 2.4 1.4 3.8 1.6l.2-1.5c-1.1-.1-2.2-.5-3.1-1.2l-.9 1.1z" 24351 })); 24352 /* harmony default export */ const rotate_left = (rotateLeft); 24353 24354 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/brush.js 24355 24356 /** 24357 * WordPress dependencies 24358 */ 24359 24360 const brush = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { 24361 xmlns: "http://www.w3.org/2000/svg", 24362 viewBox: "0 0 24 24" 24363 }, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 24364 d: "M4 20h8v-1.5H4V20zM18.9 3.5c-.6-.6-1.5-.6-2.1 0l-7.2 7.2c-.4-.1-.7 0-1.1.1-.5.2-1.5.7-1.9 2.2-.4 1.7-.8 2.2-1.1 2.7-.1.1-.2.3-.3.4l-.6 1.1H6c2 0 3.4-.4 4.7-1.4.8-.6 1.2-1.4 1.3-2.3 0-.3 0-.5-.1-.7L19 5.7c.5-.6.5-1.6-.1-2.2zM9.7 14.7c-.7.5-1.5.8-2.4 1 .2-.5.5-1.2.8-2.3.2-.6.4-1 .8-1.1.5-.1 1 .1 1.3.3.2.2.3.5.2.8 0 .3-.1.9-.7 1.3z" 24365 })); 24366 /* harmony default export */ const library_brush = (brush); 24367 24368 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/utils/get-is-list-page.js 24369 /** 24370 * Returns if the params match the list page route. 24371 * 24372 * @param {Object} params The url params. 24373 * @param {string} params.path The current path. 24374 * @param {string} [params.categoryType] The current category type. 24375 * @param {string} [params.categoryId] The current category id. 24376 * @param {boolean} isMobileViewport Is mobile viewport. 24377 * 24378 * @return {boolean} Is list page or not. 24379 */ 24380 function getIsListPage({ 24381 path, 24382 categoryType, 24383 categoryId 24384 }, isMobileViewport) { 24385 return ['/wp_template/all', '/wp_template_part/all', '/pages'].includes(path) || path === '/patterns' && ( 24386 // Don't treat "/patterns" without categoryType and categoryId as a 24387 // list page in mobile because the sidebar covers the whole page. 24388 !isMobileViewport || !!categoryType && !!categoryId); 24389 } 24390 24391 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/hooks/commands/use-common-commands.js 24392 /** 24393 * WordPress dependencies 24394 */ 24395 24396 24397 24398 24399 24400 24401 24402 24403 24404 24405 24406 /** 24407 * Internal dependencies 24408 */ 24409 24410 24411 24412 const { 24413 useGlobalStylesReset 24414 } = unlock(external_wp_blockEditor_namespaceObject.privateApis); 24415 const { 24416 useHistory: use_common_commands_useHistory, 24417 useLocation: use_common_commands_useLocation 24418 } = unlock(external_wp_router_namespaceObject.privateApis); 24419 function useGlobalStylesOpenStylesCommands() { 24420 const { 24421 openGeneralSidebar, 24422 setCanvasMode 24423 } = unlock((0,external_wp_data_namespaceObject.useDispatch)(store_store)); 24424 const { 24425 params 24426 } = use_common_commands_useLocation(); 24427 const isMobileViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium', '<'); 24428 const isEditorPage = !getIsListPage(params, isMobileViewport); 24429 const { 24430 getCanvasMode 24431 } = unlock((0,external_wp_data_namespaceObject.useSelect)(store_store)); 24432 const history = use_common_commands_useHistory(); 24433 const isBlockBasedTheme = (0,external_wp_data_namespaceObject.useSelect)(select => { 24434 return select(external_wp_coreData_namespaceObject.store).getCurrentTheme().is_block_theme; 24435 }, []); 24436 const commands = (0,external_wp_element_namespaceObject.useMemo)(() => { 24437 if (!isBlockBasedTheme) { 24438 return []; 24439 } 24440 return [{ 24441 name: 'core/edit-site/open-styles', 24442 label: (0,external_wp_i18n_namespaceObject.__)('Open styles'), 24443 callback: ({ 24444 close 24445 }) => { 24446 close(); 24447 if (!isEditorPage) { 24448 history.push({ 24449 path: '/wp_global_styles', 24450 canvas: 'edit' 24451 }); 24452 } 24453 if (isEditorPage && getCanvasMode() !== 'edit') { 24454 setCanvasMode('edit'); 24455 } 24456 openGeneralSidebar('edit-site/global-styles'); 24457 }, 24458 icon: library_styles 24459 }]; 24460 }, [history, openGeneralSidebar, setCanvasMode, isEditorPage, getCanvasMode, isBlockBasedTheme]); 24461 return { 24462 isLoading: false, 24463 commands 24464 }; 24465 } 24466 function useGlobalStylesToggleWelcomeGuideCommands() { 24467 const { 24468 openGeneralSidebar, 24469 setCanvasMode 24470 } = unlock((0,external_wp_data_namespaceObject.useDispatch)(store_store)); 24471 const { 24472 params 24473 } = use_common_commands_useLocation(); 24474 const isMobileViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium', '<'); 24475 const isEditorPage = !getIsListPage(params, isMobileViewport); 24476 const { 24477 getCanvasMode 24478 } = unlock((0,external_wp_data_namespaceObject.useSelect)(store_store)); 24479 const { 24480 set 24481 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_preferences_namespaceObject.store); 24482 const history = use_common_commands_useHistory(); 24483 const isBlockBasedTheme = (0,external_wp_data_namespaceObject.useSelect)(select => { 24484 return select(external_wp_coreData_namespaceObject.store).getCurrentTheme().is_block_theme; 24485 }, []); 24486 const commands = (0,external_wp_element_namespaceObject.useMemo)(() => { 24487 if (!isBlockBasedTheme) { 24488 return []; 24489 } 24490 return [{ 24491 name: 'core/edit-site/toggle-styles-welcome-guide', 24492 label: (0,external_wp_i18n_namespaceObject.__)('Learn about styles'), 24493 callback: ({ 24494 close 24495 }) => { 24496 close(); 24497 if (!isEditorPage) { 24498 history.push({ 24499 path: '/wp_global_styles', 24500 canvas: 'edit' 24501 }); 24502 } 24503 if (isEditorPage && getCanvasMode() !== 'edit') { 24504 setCanvasMode('edit'); 24505 } 24506 openGeneralSidebar('edit-site/global-styles'); 24507 set('core/edit-site', 'welcomeGuideStyles', true); 24508 // sometimes there's a focus loss that happens after some time 24509 // that closes the modal, we need to force reopening it. 24510 setTimeout(() => { 24511 set('core/edit-site', 'welcomeGuideStyles', true); 24512 }, 500); 24513 }, 24514 icon: library_help 24515 }]; 24516 }, [history, openGeneralSidebar, setCanvasMode, isEditorPage, getCanvasMode, isBlockBasedTheme, set]); 24517 return { 24518 isLoading: false, 24519 commands 24520 }; 24521 } 24522 function useGlobalStylesResetCommands() { 24523 const [canReset, onReset] = useGlobalStylesReset(); 24524 const commands = (0,external_wp_element_namespaceObject.useMemo)(() => { 24525 if (!canReset) { 24526 return []; 24527 } 24528 return [{ 24529 name: 'core/edit-site/reset-global-styles', 24530 label: (0,external_wp_i18n_namespaceObject.__)('Reset styles'), 24531 icon: (0,external_wp_i18n_namespaceObject.isRTL)() ? rotate_right : rotate_left, 24532 callback: ({ 24533 close 24534 }) => { 24535 close(); 24536 onReset(); 24537 } 24538 }]; 24539 }, [canReset, onReset]); 24540 return { 24541 isLoading: false, 24542 commands 24543 }; 24544 } 24545 function useGlobalStylesOpenCssCommands() { 24546 const { 24547 openGeneralSidebar, 24548 setEditorCanvasContainerView, 24549 setCanvasMode 24550 } = unlock((0,external_wp_data_namespaceObject.useDispatch)(store_store)); 24551 const { 24552 params 24553 } = use_common_commands_useLocation(); 24554 const isMobileViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium', '<'); 24555 const isListPage = getIsListPage(params, isMobileViewport); 24556 const isEditorPage = !isListPage; 24557 const history = use_common_commands_useHistory(); 24558 const { 24559 canEditCSS 24560 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 24561 const { 24562 getEntityRecord, 24563 __experimentalGetCurrentGlobalStylesId 24564 } = select(external_wp_coreData_namespaceObject.store); 24565 const globalStylesId = __experimentalGetCurrentGlobalStylesId(); 24566 const globalStyles = globalStylesId ? getEntityRecord('root', 'globalStyles', globalStylesId) : undefined; 24567 return { 24568 canEditCSS: !!globalStyles?._links?.['wp:action-edit-css'] 24569 }; 24570 }, []); 24571 const { 24572 getCanvasMode 24573 } = unlock((0,external_wp_data_namespaceObject.useSelect)(store_store)); 24574 const commands = (0,external_wp_element_namespaceObject.useMemo)(() => { 24575 if (!canEditCSS) { 24576 return []; 24577 } 24578 return [{ 24579 name: 'core/edit-site/open-styles-css', 24580 label: (0,external_wp_i18n_namespaceObject.__)('Customize CSS'), 24581 icon: library_brush, 24582 callback: ({ 24583 close 24584 }) => { 24585 close(); 24586 if (!isEditorPage) { 24587 history.push({ 24588 path: '/wp_global_styles', 24589 canvas: 'edit' 24590 }); 24591 } 24592 if (isEditorPage && getCanvasMode() !== 'edit') { 24593 setCanvasMode('edit'); 24594 } 24595 openGeneralSidebar('edit-site/global-styles'); 24596 setEditorCanvasContainerView('global-styles-css'); 24597 } 24598 }]; 24599 }, [history, openGeneralSidebar, setEditorCanvasContainerView, canEditCSS, isEditorPage, getCanvasMode, setCanvasMode]); 24600 return { 24601 isLoading: false, 24602 commands 24603 }; 24604 } 24605 function useGlobalStylesOpenRevisionsCommands() { 24606 const { 24607 openGeneralSidebar, 24608 setEditorCanvasContainerView, 24609 setCanvasMode 24610 } = unlock((0,external_wp_data_namespaceObject.useDispatch)(store_store)); 24611 const { 24612 getCanvasMode 24613 } = unlock((0,external_wp_data_namespaceObject.useSelect)(store_store)); 24614 const { 24615 params 24616 } = use_common_commands_useLocation(); 24617 const isMobileViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium', '<'); 24618 const isEditorPage = !getIsListPage(params, isMobileViewport); 24619 const history = use_common_commands_useHistory(); 24620 const hasRevisions = (0,external_wp_data_namespaceObject.useSelect)(select => { 24621 const { 24622 getEntityRecord, 24623 __experimentalGetCurrentGlobalStylesId 24624 } = select(external_wp_coreData_namespaceObject.store); 24625 const globalStylesId = __experimentalGetCurrentGlobalStylesId(); 24626 const globalStyles = globalStylesId ? getEntityRecord('root', 'globalStyles', globalStylesId) : undefined; 24627 return !!globalStyles?._links?.['version-history']?.[0]?.count; 24628 }, []); 24629 const commands = (0,external_wp_element_namespaceObject.useMemo)(() => { 24630 if (!hasRevisions) { 24631 return []; 24632 } 24633 return [{ 24634 name: 'core/edit-site/open-global-styles-revisions', 24635 label: (0,external_wp_i18n_namespaceObject.__)('Style revisions'), 24636 icon: library_backup, 24637 callback: ({ 24638 close 24639 }) => { 24640 close(); 24641 if (!isEditorPage) { 24642 history.push({ 24643 path: '/wp_global_styles', 24644 canvas: 'edit' 24645 }); 24646 } 24647 if (isEditorPage && getCanvasMode() !== 'edit') { 24648 setCanvasMode('edit'); 24649 } 24650 openGeneralSidebar('edit-site/global-styles'); 24651 setEditorCanvasContainerView('global-styles-revisions'); 24652 } 24653 }]; 24654 }, [hasRevisions, history, openGeneralSidebar, setEditorCanvasContainerView, isEditorPage, getCanvasMode, setCanvasMode]); 24655 return { 24656 isLoading: false, 24657 commands 24658 }; 24659 } 24660 function useCommonCommands() { 24661 const homeUrl = (0,external_wp_data_namespaceObject.useSelect)(select => { 24662 const { 24663 getUnstableBase // Site index. 24664 } = select(external_wp_coreData_namespaceObject.store); 24665 return getUnstableBase()?.home; 24666 }, []); 24667 (0,external_wp_commands_namespaceObject.useCommand)({ 24668 name: 'core/edit-site/view-site', 24669 label: (0,external_wp_i18n_namespaceObject.__)('View site'), 24670 callback: ({ 24671 close 24672 }) => { 24673 close(); 24674 window.open(homeUrl, '_blank'); 24675 }, 24676 icon: library_external 24677 }); 24678 (0,external_wp_commands_namespaceObject.useCommandLoader)({ 24679 name: 'core/edit-site/open-styles', 24680 hook: useGlobalStylesOpenStylesCommands 24681 }); 24682 (0,external_wp_commands_namespaceObject.useCommandLoader)({ 24683 name: 'core/edit-site/toggle-styles-welcome-guide', 24684 hook: useGlobalStylesToggleWelcomeGuideCommands 24685 }); 24686 (0,external_wp_commands_namespaceObject.useCommandLoader)({ 24687 name: 'core/edit-site/reset-global-styles', 24688 hook: useGlobalStylesResetCommands 24689 }); 24690 (0,external_wp_commands_namespaceObject.useCommandLoader)({ 24691 name: 'core/edit-site/open-styles-css', 24692 hook: useGlobalStylesOpenCssCommands 24693 }); 24694 (0,external_wp_commands_namespaceObject.useCommandLoader)({ 24695 name: 'core/edit-site/open-styles-revisions', 24696 hook: useGlobalStylesOpenRevisionsCommands 24697 }); 24698 } 24699 24700 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/code.js 24701 24702 /** 24703 * WordPress dependencies 24704 */ 24705 24706 const code = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { 24707 viewBox: "0 0 24 24", 24708 xmlns: "http://www.w3.org/2000/svg" 24709 }, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 24710 d: "M20.8 10.7l-4.3-4.3-1.1 1.1 4.3 4.3c.1.1.1.3 0 .4l-4.3 4.3 1.1 1.1 4.3-4.3c.7-.8.7-1.9 0-2.6zM4.2 11.8l4.3-4.3-1-1-4.3 4.3c-.7.7-.7 1.8 0 2.5l4.3 4.3 1.1-1.1-4.3-4.3c-.2-.1-.2-.3-.1-.4z" 24711 })); 24712 /* harmony default export */ const library_code = (code); 24713 24714 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/drawer-left.js 24715 24716 /** 24717 * WordPress dependencies 24718 */ 24719 24720 const drawerLeft = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { 24721 width: "24", 24722 height: "24", 24723 xmlns: "http://www.w3.org/2000/svg", 24724 viewBox: "0 0 24 24" 24725 }, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 24726 fillRule: "evenodd", 24727 clipRule: "evenodd", 24728 d: "M18 4H6c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zM8.5 18.5H6c-.3 0-.5-.2-.5-.5V6c0-.3.2-.5.5-.5h2.5v13zm10-.5c0 .3-.2.5-.5.5h-8v-13h8c.3 0 .5.2.5.5v12z" 24729 })); 24730 /* harmony default export */ const drawer_left = (drawerLeft); 24731 24732 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/drawer-right.js 24733 24734 /** 24735 * WordPress dependencies 24736 */ 24737 24738 const drawerRight = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { 24739 width: "24", 24740 height: "24", 24741 xmlns: "http://www.w3.org/2000/svg", 24742 viewBox: "0 0 24 24" 24743 }, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 24744 fillRule: "evenodd", 24745 clipRule: "evenodd", 24746 d: "M18 4H6c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm-4 14.5H6c-.3 0-.5-.2-.5-.5V6c0-.3.2-.5.5-.5h8v13zm4.5-.5c0 .3-.2.5-.5.5h-2.5v-13H18c.3 0 .5.2.5.5v12z" 24747 })); 24748 /* harmony default export */ const drawer_right = (drawerRight); 24749 24750 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/block-default.js 24751 24752 /** 24753 * WordPress dependencies 24754 */ 24755 24756 const blockDefault = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { 24757 xmlns: "http://www.w3.org/2000/svg", 24758 viewBox: "0 0 24 24" 24759 }, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 24760 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" 24761 })); 24762 /* harmony default export */ const block_default = (blockDefault); 24763 24764 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/keyboard.js 24765 24766 /** 24767 * WordPress dependencies 24768 */ 24769 24770 const keyboard = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { 24771 xmlns: "http://www.w3.org/2000/svg", 24772 viewBox: "0 0 24 24" 24773 }, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 24774 d: "m16 15.5h-8v-1.5h8zm-7.5-2.5h-2v-2h2zm3 0h-2v-2h2zm3 0h-2v-2h2zm3 0h-2v-2h2zm-9-3h-2v-2h2zm3 0h-2v-2h2zm3 0h-2v-2h2zm3 0h-2v-2h2z" 24775 }), (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 24776 d: "m18.5 6.5h-13a.5.5 0 0 0 -.5.5v9.5a.5.5 0 0 0 .5.5h13a.5.5 0 0 0 .5-.5v-9.5a.5.5 0 0 0 -.5-.5zm-13-1.5h13a2 2 0 0 1 2 2v9.5a2 2 0 0 1 -2 2h-13a2 2 0 0 1 -2-2v-9.5a2 2 0 0 1 2-2z" 24777 })); 24778 /* harmony default export */ const library_keyboard = (keyboard); 24779 24780 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/list-view.js 24781 24782 /** 24783 * WordPress dependencies 24784 */ 24785 24786 const listView = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { 24787 viewBox: "0 0 24 24", 24788 xmlns: "http://www.w3.org/2000/svg" 24789 }, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 24790 d: "M3 6h11v1.5H3V6Zm3.5 5.5h11V13h-11v-1.5ZM21 17H10v1.5h11V17Z" 24791 })); 24792 /* harmony default export */ const list_view = (listView); 24793 24794 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/pattern-modal/rename.js 24795 24796 /** 24797 * WordPress dependencies 24798 */ 24799 24800 24801 24802 24803 /** 24804 * Internal dependencies 24805 */ 24806 24807 24808 24809 const { 24810 RenamePatternModal 24811 } = unlock(external_wp_patterns_namespaceObject.privateApis); 24812 function PatternRenameModal() { 24813 const { 24814 record: pattern 24815 } = useEditedEntityRecord(); 24816 const { 24817 closeModal 24818 } = (0,external_wp_data_namespaceObject.useDispatch)(store); 24819 const isActive = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).isModalActive(PATTERN_MODALS.rename)); 24820 if (!isActive) { 24821 return null; 24822 } 24823 return (0,external_React_.createElement)(RenamePatternModal, { 24824 onClose: closeModal, 24825 pattern: pattern 24826 }); 24827 } 24828 24829 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/pattern-modal/duplicate.js 24830 24831 /** 24832 * WordPress dependencies 24833 */ 24834 24835 24836 24837 24838 24839 24840 /** 24841 * Internal dependencies 24842 */ 24843 24844 24845 24846 24847 const { 24848 DuplicatePatternModal 24849 } = unlock(external_wp_patterns_namespaceObject.privateApis); 24850 const { 24851 useHistory: duplicate_useHistory 24852 } = unlock(external_wp_router_namespaceObject.privateApis); 24853 function PatternDuplicateModal() { 24854 const { 24855 record 24856 } = useEditedEntityRecord(); 24857 const { 24858 categoryType, 24859 categoryId 24860 } = (0,external_wp_url_namespaceObject.getQueryArgs)(window.location.href); 24861 const { 24862 closeModal 24863 } = (0,external_wp_data_namespaceObject.useDispatch)(store); 24864 const history = duplicate_useHistory(); 24865 const isActive = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).isModalActive(PATTERN_MODALS.duplicate)); 24866 if (!isActive) { 24867 return null; 24868 } 24869 function onSuccess({ 24870 pattern: newPattern 24871 }) { 24872 history.push({ 24873 categoryType, 24874 categoryId, 24875 postType: PATTERN_TYPES.user, 24876 postId: newPattern.id 24877 }); 24878 closeModal(); 24879 } 24880 return (0,external_React_.createElement)(DuplicatePatternModal, { 24881 onClose: closeModal, 24882 onSuccess: onSuccess, 24883 pattern: record 24884 }); 24885 } 24886 24887 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/pattern-modal/index.js 24888 24889 /** 24890 * Internal dependencies 24891 */ 24892 24893 24894 const PATTERN_MODALS = { 24895 rename: 'edit-site/pattern-rename', 24896 duplicate: 'edit-site/pattern-duplicate' 24897 }; 24898 function PatternModal() { 24899 return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(PatternDuplicateModal, null), (0,external_React_.createElement)(PatternRenameModal, null)); 24900 } 24901 24902 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/hooks/commands/use-edit-mode-commands.js 24903 /** 24904 * WordPress dependencies 24905 */ 24906 24907 24908 24909 24910 24911 24912 24913 24914 24915 24916 24917 /** 24918 * Internal dependencies 24919 */ 24920 24921 24922 24923 24924 24925 24926 24927 24928 24929 24930 const { 24931 useHistory: use_edit_mode_commands_useHistory 24932 } = unlock(external_wp_router_namespaceObject.privateApis); 24933 function usePageContentFocusCommands() { 24934 const { 24935 record: template 24936 } = useEditedEntityRecord(); 24937 const { 24938 isPage, 24939 canvasMode, 24940 templateId, 24941 currentPostType 24942 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 24943 const { 24944 isPage: _isPage, 24945 getCanvasMode 24946 } = unlock(select(store_store)); 24947 const { 24948 getCurrentPostType, 24949 getCurrentTemplateId 24950 } = select(external_wp_editor_namespaceObject.store); 24951 return { 24952 isPage: _isPage(), 24953 canvasMode: getCanvasMode(), 24954 templateId: getCurrentTemplateId(), 24955 currentPostType: getCurrentPostType() 24956 }; 24957 }, []); 24958 const { 24959 onClick: editTemplate 24960 } = useLink({ 24961 postType: 'wp_template', 24962 postId: templateId 24963 }); 24964 const { 24965 setRenderingMode 24966 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_editor_namespaceObject.store); 24967 if (!isPage || canvasMode !== 'edit') { 24968 return { 24969 isLoading: false, 24970 commands: [] 24971 }; 24972 } 24973 const commands = []; 24974 if (currentPostType !== 'wp_template') { 24975 commands.push({ 24976 name: 'core/switch-to-template-focus', 24977 label: (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: template title */ 24978 (0,external_wp_i18n_namespaceObject.__)('Edit template: %s'), (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(template.title)), 24979 icon: library_layout, 24980 callback: ({ 24981 close 24982 }) => { 24983 editTemplate(); 24984 close(); 24985 } 24986 }); 24987 } else { 24988 commands.push({ 24989 name: 'core/switch-to-page-focus', 24990 label: (0,external_wp_i18n_namespaceObject.__)('Back to page'), 24991 icon: library_page, 24992 callback: ({ 24993 close 24994 }) => { 24995 setRenderingMode('template-locked'); 24996 close(); 24997 } 24998 }); 24999 } 25000 return { 25001 isLoading: false, 25002 commands 25003 }; 25004 } 25005 function useEditorModeCommands() { 25006 const { 25007 switchEditorMode 25008 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store); 25009 const { 25010 canvasMode, 25011 editorMode 25012 } = (0,external_wp_data_namespaceObject.useSelect)(select => ({ 25013 canvasMode: unlock(select(store_store)).getCanvasMode(), 25014 editorMode: select(store_store).getEditorMode() 25015 }), []); 25016 if (canvasMode !== 'edit' || editorMode !== 'text') { 25017 return { 25018 isLoading: false, 25019 commands: [] 25020 }; 25021 } 25022 const commands = []; 25023 if (editorMode === 'text') { 25024 commands.push({ 25025 name: 'core/exit-code-editor', 25026 label: (0,external_wp_i18n_namespaceObject.__)('Exit code editor'), 25027 icon: library_code, 25028 callback: ({ 25029 close 25030 }) => { 25031 switchEditorMode('visual'); 25032 close(); 25033 } 25034 }); 25035 } 25036 return { 25037 isLoading: false, 25038 commands 25039 }; 25040 } 25041 function useManipulateDocumentCommands() { 25042 const { 25043 isLoaded, 25044 record: template 25045 } = useEditedEntityRecord(); 25046 const { 25047 removeTemplate, 25048 revertTemplate 25049 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store); 25050 const history = use_edit_mode_commands_useHistory(); 25051 const isEditingPage = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).isPage() && select(external_wp_editor_namespaceObject.store).getCurrentPostType() !== 'wp_template', []); 25052 if (!isLoaded) { 25053 return { 25054 isLoading: true, 25055 commands: [] 25056 }; 25057 } 25058 const commands = []; 25059 if (isTemplateRevertable(template) && !isEditingPage) { 25060 const label = template.type === constants_TEMPLATE_POST_TYPE ? (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: template title */ 25061 (0,external_wp_i18n_namespaceObject.__)('Reset template: %s'), (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(template.title)) : (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: template part title */ 25062 (0,external_wp_i18n_namespaceObject.__)('Reset template part: %s'), (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(template.title)); 25063 commands.push({ 25064 name: 'core/reset-template', 25065 label, 25066 icon: (0,external_wp_i18n_namespaceObject.isRTL)() ? rotate_right : rotate_left, 25067 callback: ({ 25068 close 25069 }) => { 25070 revertTemplate(template); 25071 close(); 25072 } 25073 }); 25074 } 25075 if (isTemplateRemovable(template) && !isEditingPage) { 25076 const label = template.type === constants_TEMPLATE_POST_TYPE ? (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: template title */ 25077 (0,external_wp_i18n_namespaceObject.__)('Delete template: %s'), (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(template.title)) : (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: template part title */ 25078 (0,external_wp_i18n_namespaceObject.__)('Delete template part: %s'), (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(template.title)); 25079 const path = template.type === constants_TEMPLATE_POST_TYPE ? '/wp_template' : '/wp_template_part/all'; 25080 commands.push({ 25081 name: 'core/remove-template', 25082 label, 25083 icon: library_trash, 25084 callback: ({ 25085 close 25086 }) => { 25087 removeTemplate(template); 25088 // Navigate to the template list 25089 history.push({ 25090 path 25091 }); 25092 close(); 25093 } 25094 }); 25095 } 25096 return { 25097 isLoading: !isLoaded, 25098 commands 25099 }; 25100 } 25101 function useEditUICommands() { 25102 const { 25103 openGeneralSidebar, 25104 closeGeneralSidebar, 25105 toggleDistractionFree, 25106 setIsListViewOpened, 25107 switchEditorMode 25108 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store); 25109 const { 25110 canvasMode, 25111 editorMode, 25112 activeSidebar, 25113 showBlockBreadcrumbs, 25114 isListViewOpen, 25115 isDistractionFree, 25116 isTopToolbar, 25117 isFocusMode 25118 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 25119 const { 25120 get 25121 } = select(external_wp_preferences_namespaceObject.store); 25122 const { 25123 getEditorMode 25124 } = select(store_store); 25125 const { 25126 isListViewOpened 25127 } = select(external_wp_editor_namespaceObject.store); 25128 return { 25129 canvasMode: unlock(select(store_store)).getCanvasMode(), 25130 editorMode: getEditorMode(), 25131 activeSidebar: select(store).getActiveComplementaryArea(store_store.name), 25132 showBlockBreadcrumbs: get('core', 'showBlockBreadcrumbs'), 25133 isListViewOpen: isListViewOpened(), 25134 isDistractionFree: get('core', 'distractionFree'), 25135 isFocusMode: get('core', 'focusMode'), 25136 isTopToolbar: get('core', 'fixedToolbar') 25137 }; 25138 }, []); 25139 const { 25140 openModal 25141 } = (0,external_wp_data_namespaceObject.useDispatch)(store); 25142 const { 25143 toggle 25144 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_preferences_namespaceObject.store); 25145 const { 25146 createInfoNotice 25147 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store); 25148 if (canvasMode !== 'edit') { 25149 return { 25150 isLoading: false, 25151 commands: [] 25152 }; 25153 } 25154 const commands = []; 25155 commands.push({ 25156 name: 'core/open-settings-sidebar', 25157 label: (0,external_wp_i18n_namespaceObject.__)('Toggle settings sidebar'), 25158 icon: (0,external_wp_i18n_namespaceObject.isRTL)() ? drawer_left : drawer_right, 25159 callback: ({ 25160 close 25161 }) => { 25162 close(); 25163 if (activeSidebar === 'edit-site/template') { 25164 closeGeneralSidebar(); 25165 } else { 25166 openGeneralSidebar('edit-site/template'); 25167 } 25168 } 25169 }); 25170 commands.push({ 25171 name: 'core/open-block-inspector', 25172 label: (0,external_wp_i18n_namespaceObject.__)('Toggle block inspector'), 25173 icon: block_default, 25174 callback: ({ 25175 close 25176 }) => { 25177 close(); 25178 if (activeSidebar === 'edit-site/block-inspector') { 25179 closeGeneralSidebar(); 25180 } else { 25181 openGeneralSidebar('edit-site/block-inspector'); 25182 } 25183 } 25184 }); 25185 commands.push({ 25186 name: 'core/toggle-spotlight-mode', 25187 label: (0,external_wp_i18n_namespaceObject.__)('Toggle spotlight'), 25188 callback: ({ 25189 close 25190 }) => { 25191 toggle('core', 'focusMode'); 25192 close(); 25193 createInfoNotice(isFocusMode ? (0,external_wp_i18n_namespaceObject.__)('Spotlight off.') : (0,external_wp_i18n_namespaceObject.__)('Spotlight on.'), { 25194 id: 'core/edit-site/toggle-spotlight-mode/notice', 25195 type: 'snackbar', 25196 actions: [{ 25197 label: (0,external_wp_i18n_namespaceObject.__)('Undo'), 25198 onClick: () => { 25199 toggle('core', 'focusMode'); 25200 } 25201 }] 25202 }); 25203 } 25204 }); 25205 commands.push({ 25206 name: 'core/toggle-distraction-free', 25207 label: isDistractionFree ? (0,external_wp_i18n_namespaceObject.__)('Exit Distraction Free') : (0,external_wp_i18n_namespaceObject.__)('Enter Distraction Free '), 25208 callback: ({ 25209 close 25210 }) => { 25211 toggleDistractionFree(); 25212 close(); 25213 } 25214 }); 25215 commands.push({ 25216 name: 'core/toggle-top-toolbar', 25217 label: (0,external_wp_i18n_namespaceObject.__)('Toggle top toolbar'), 25218 callback: ({ 25219 close 25220 }) => { 25221 toggle('core', 'fixedToolbar'); 25222 if (isDistractionFree) { 25223 toggleDistractionFree(); 25224 } 25225 close(); 25226 createInfoNotice(isTopToolbar ? (0,external_wp_i18n_namespaceObject.__)('Top toolbar off.') : (0,external_wp_i18n_namespaceObject.__)('Top toolbar on.'), { 25227 id: 'core/edit-site/toggle-top-toolbar/notice', 25228 type: 'snackbar', 25229 actions: [{ 25230 label: (0,external_wp_i18n_namespaceObject.__)('Undo'), 25231 onClick: () => { 25232 toggle('core', 'fixedToolbar'); 25233 } 25234 }] 25235 }); 25236 } 25237 }); 25238 if (editorMode === 'visual') { 25239 commands.push({ 25240 name: 'core/toggle-code-editor', 25241 label: (0,external_wp_i18n_namespaceObject.__)('Open code editor'), 25242 icon: library_code, 25243 callback: ({ 25244 close 25245 }) => { 25246 switchEditorMode('text'); 25247 close(); 25248 } 25249 }); 25250 } 25251 commands.push({ 25252 name: 'core/open-preferences', 25253 label: (0,external_wp_i18n_namespaceObject.__)('Editor preferences'), 25254 callback: () => { 25255 openModal(PREFERENCES_MODAL_NAME); 25256 } 25257 }); 25258 commands.push({ 25259 name: 'core/open-shortcut-help', 25260 label: (0,external_wp_i18n_namespaceObject.__)('Keyboard shortcuts'), 25261 icon: library_keyboard, 25262 callback: () => { 25263 openModal(KEYBOARD_SHORTCUT_HELP_MODAL_NAME); 25264 } 25265 }); 25266 commands.push({ 25267 name: 'core/toggle-breadcrumbs', 25268 label: showBlockBreadcrumbs ? (0,external_wp_i18n_namespaceObject.__)('Hide block breadcrumbs') : (0,external_wp_i18n_namespaceObject.__)('Show block breadcrumbs'), 25269 callback: ({ 25270 close 25271 }) => { 25272 toggle('core', 'showBlockBreadcrumbs'); 25273 close(); 25274 createInfoNotice(showBlockBreadcrumbs ? (0,external_wp_i18n_namespaceObject.__)('Breadcrumbs hidden.') : (0,external_wp_i18n_namespaceObject.__)('Breadcrumbs visible.'), { 25275 id: 'core/edit-site/toggle-breadcrumbs/notice', 25276 type: 'snackbar' 25277 }); 25278 } 25279 }); 25280 commands.push({ 25281 name: 'core/toggle-list-view', 25282 label: isListViewOpen ? (0,external_wp_i18n_namespaceObject.__)('Close List View') : (0,external_wp_i18n_namespaceObject.__)('Open List View'), 25283 icon: list_view, 25284 callback: ({ 25285 close 25286 }) => { 25287 setIsListViewOpened(!isListViewOpen); 25288 close(); 25289 createInfoNotice(isListViewOpen ? (0,external_wp_i18n_namespaceObject.__)('List View off.') : (0,external_wp_i18n_namespaceObject.__)('List View on.'), { 25290 id: 'core/edit-site/toggle-list-view/notice', 25291 type: 'snackbar' 25292 }); 25293 } 25294 }); 25295 return { 25296 isLoading: false, 25297 commands 25298 }; 25299 } 25300 function usePatternCommands() { 25301 const { 25302 isLoaded, 25303 record: pattern 25304 } = useEditedEntityRecord(); 25305 const { 25306 openModal 25307 } = (0,external_wp_data_namespaceObject.useDispatch)(store); 25308 if (!isLoaded) { 25309 return { 25310 isLoading: true, 25311 commands: [] 25312 }; 25313 } 25314 const commands = []; 25315 if (pattern?.type === 'wp_block') { 25316 commands.push({ 25317 name: 'core/rename-pattern', 25318 label: (0,external_wp_i18n_namespaceObject.__)('Rename pattern'), 25319 icon: edit, 25320 callback: ({ 25321 close 25322 }) => { 25323 openModal(PATTERN_MODALS.rename); 25324 close(); 25325 } 25326 }); 25327 commands.push({ 25328 name: 'core/duplicate-pattern', 25329 label: (0,external_wp_i18n_namespaceObject.__)('Duplicate pattern'), 25330 icon: library_symbol, 25331 callback: ({ 25332 close 25333 }) => { 25334 openModal(PATTERN_MODALS.duplicate); 25335 close(); 25336 } 25337 }); 25338 } 25339 return { 25340 isLoading: false, 25341 commands 25342 }; 25343 } 25344 function useEditModeCommands() { 25345 (0,external_wp_commands_namespaceObject.useCommandLoader)({ 25346 name: 'core/exit-code-editor', 25347 hook: useEditorModeCommands, 25348 context: 'site-editor-edit' 25349 }); 25350 (0,external_wp_commands_namespaceObject.useCommandLoader)({ 25351 name: 'core/edit-site/page-content-focus', 25352 hook: usePageContentFocusCommands, 25353 context: 'site-editor-edit' 25354 }); 25355 (0,external_wp_commands_namespaceObject.useCommandLoader)({ 25356 name: 'core/edit-site/manipulate-document', 25357 hook: useManipulateDocumentCommands 25358 }); 25359 (0,external_wp_commands_namespaceObject.useCommandLoader)({ 25360 name: 'core/edit-site/patterns', 25361 hook: usePatternCommands, 25362 context: 'site-editor-edit' 25363 }); 25364 (0,external_wp_commands_namespaceObject.useCommandLoader)({ 25365 name: 'core/edit-site/edit-ui', 25366 hook: useEditUICommands 25367 }); 25368 } 25369 25370 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/layout/hooks.js 25371 /** 25372 * WordPress dependencies 25373 */ 25374 25375 25376 25377 25378 /** 25379 * Internal dependencies 25380 */ 25381 25382 const MAX_LOADING_TIME = 10000; // 10 seconds 25383 25384 function useIsSiteEditorLoading() { 25385 const { 25386 isLoaded: hasLoadedPost 25387 } = useEditedEntityRecord(); 25388 const [loaded, setLoaded] = (0,external_wp_element_namespaceObject.useState)(false); 25389 const inLoadingPause = (0,external_wp_data_namespaceObject.useSelect)(select => { 25390 const hasResolvingSelectors = select(external_wp_coreData_namespaceObject.store).hasResolvingSelectors(); 25391 return !loaded && !hasResolvingSelectors; 25392 }, [loaded]); 25393 25394 /* 25395 * If the maximum expected loading time has passed, we're marking the 25396 * editor as loaded, in order to prevent any failed requests from blocking 25397 * the editor canvas from appearing. 25398 */ 25399 (0,external_wp_element_namespaceObject.useEffect)(() => { 25400 let timeout; 25401 if (!loaded) { 25402 timeout = setTimeout(() => { 25403 setLoaded(true); 25404 }, MAX_LOADING_TIME); 25405 } 25406 return () => { 25407 clearTimeout(timeout); 25408 }; 25409 }, [loaded]); 25410 (0,external_wp_element_namespaceObject.useEffect)(() => { 25411 if (inLoadingPause) { 25412 /* 25413 * We're using an arbitrary 100ms timeout here to catch brief 25414 * moments without any resolving selectors that would result in 25415 * displaying brief flickers of loading state and loaded state. 25416 * 25417 * It's worth experimenting with different values, since this also 25418 * adds 100ms of artificial delay after loading has finished. 25419 */ 25420 const ARTIFICIAL_DELAY = 100; 25421 const timeout = setTimeout(() => { 25422 setLoaded(true); 25423 }, ARTIFICIAL_DELAY); 25424 return () => { 25425 clearTimeout(timeout); 25426 }; 25427 } 25428 }, [inLoadingPause]); 25429 return !loaded || !hasLoadedPost; 25430 } 25431 25432 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sidebar-edit-mode/default-sidebar.js 25433 25434 /** 25435 * WordPress dependencies 25436 */ 25437 25438 function DefaultSidebar({ 25439 className, 25440 identifier, 25441 title, 25442 icon, 25443 children, 25444 closeLabel, 25445 header, 25446 headerClassName, 25447 panelClassName 25448 }) { 25449 return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(complementary_area, { 25450 className: className, 25451 scope: "core/edit-site", 25452 identifier: identifier, 25453 title: title, 25454 smallScreenTitle: title, 25455 icon: icon, 25456 closeLabel: closeLabel, 25457 header: header, 25458 headerClassName: headerClassName, 25459 panelClassName: panelClassName 25460 }, children), (0,external_React_.createElement)(ComplementaryAreaMoreMenuItem, { 25461 scope: "core/edit-site", 25462 identifier: identifier, 25463 icon: icon 25464 }, title)); 25465 } 25466 25467 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/global-styles/icon-with-current-color.js 25468 25469 /** 25470 * External dependencies 25471 */ 25472 25473 25474 /** 25475 * WordPress dependencies 25476 */ 25477 25478 function IconWithCurrentColor({ 25479 className, 25480 ...props 25481 }) { 25482 return (0,external_React_.createElement)(external_wp_components_namespaceObject.Icon, { 25483 className: classnames_default()(className, 'edit-site-global-styles-icon-with-current-color'), 25484 ...props 25485 }); 25486 } 25487 25488 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/global-styles/navigation-button.js 25489 25490 /** 25491 * WordPress dependencies 25492 */ 25493 25494 25495 /** 25496 * Internal dependencies 25497 */ 25498 25499 function GenericNavigationButton({ 25500 icon, 25501 children, 25502 ...props 25503 }) { 25504 return (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalItem, { 25505 ...props 25506 }, icon && (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { 25507 justify: "flex-start" 25508 }, (0,external_React_.createElement)(IconWithCurrentColor, { 25509 icon: icon, 25510 size: 24 25511 }), (0,external_React_.createElement)(external_wp_components_namespaceObject.FlexItem, null, children)), !icon && children); 25512 } 25513 function NavigationButtonAsItem(props) { 25514 return (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalNavigatorButton, { 25515 as: GenericNavigationButton, 25516 ...props 25517 }); 25518 } 25519 function NavigationBackButtonAsItem(props) { 25520 return createElement(NavigatorToParentButton, { 25521 as: GenericNavigationButton, 25522 ...props 25523 }); 25524 } 25525 25526 25527 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/typography.js 25528 25529 /** 25530 * WordPress dependencies 25531 */ 25532 25533 const typography = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { 25534 xmlns: "http://www.w3.org/2000/svg", 25535 viewBox: "0 0 24 24" 25536 }, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 25537 d: "M6.9 7L3 17.8h1.7l1-2.8h4.1l1 2.8h1.7L8.6 7H6.9zm-.7 6.6l1.5-4.3 1.5 4.3h-3zM21.6 17c-.1.1-.2.2-.3.2-.1.1-.2.1-.4.1s-.3-.1-.4-.2c-.1-.1-.1-.3-.1-.6V12c0-.5 0-1-.1-1.4-.1-.4-.3-.7-.5-1-.2-.2-.5-.4-.9-.5-.4 0-.8-.1-1.3-.1s-1 .1-1.4.2c-.4.1-.7.3-1 .4-.2.2-.4.3-.6.5-.1.2-.2.4-.2.7 0 .3.1.5.2.8.2.2.4.3.8.3.3 0 .6-.1.8-.3.2-.2.3-.4.3-.7 0-.3-.1-.5-.2-.7-.2-.2-.4-.3-.6-.4.2-.2.4-.3.7-.4.3-.1.6-.1.8-.1.3 0 .6 0 .8.1.2.1.4.3.5.5.1.2.2.5.2.9v1.1c0 .3-.1.5-.3.6-.2.2-.5.3-.9.4-.3.1-.7.3-1.1.4-.4.1-.8.3-1.1.5-.3.2-.6.4-.8.7-.2.3-.3.7-.3 1.2 0 .6.2 1.1.5 1.4.3.4.9.5 1.6.5.5 0 1-.1 1.4-.3.4-.2.8-.6 1.1-1.1 0 .4.1.7.3 1 .2.3.6.4 1.2.4.4 0 .7-.1.9-.2.2-.1.5-.3.7-.4h-.3zm-3-.9c-.2.4-.5.7-.8.8-.3.2-.6.2-.8.2-.4 0-.6-.1-.9-.3-.2-.2-.3-.6-.3-1.1 0-.5.1-.9.3-1.2s.5-.5.8-.7c.3-.2.7-.3 1-.5.3-.1.6-.3.7-.6v3.4z" 25538 })); 25539 /* harmony default export */ const library_typography = (typography); 25540 25541 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/color.js 25542 25543 /** 25544 * WordPress dependencies 25545 */ 25546 25547 const color = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { 25548 viewBox: "0 0 24 24", 25549 xmlns: "http://www.w3.org/2000/svg" 25550 }, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 25551 d: "M17.2 10.9c-.5-1-1.2-2.1-2.1-3.2-.6-.9-1.3-1.7-2.1-2.6L12 4l-1 1.1c-.6.9-1.3 1.7-2 2.6-.8 1.2-1.5 2.3-2 3.2-.6 1.2-1 2.2-1 3 0 3.4 2.7 6.1 6.1 6.1s6.1-2.7 6.1-6.1c0-.8-.3-1.8-1-3zm-5.1 7.6c-2.5 0-4.6-2.1-4.6-4.6 0-.3.1-1 .8-2.3.5-.9 1.1-1.9 2-3.1.7-.9 1.3-1.7 1.8-2.3.7.8 1.3 1.6 1.8 2.3.8 1.1 1.5 2.2 2 3.1.7 1.3.8 2 .8 2.3 0 2.5-2.1 4.6-4.6 4.6z" 25552 })); 25553 /* harmony default export */ const library_color = (color); 25554 25555 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/global-styles/root-menu.js 25556 25557 /** 25558 * WordPress dependencies 25559 */ 25560 25561 25562 25563 25564 25565 /** 25566 * Internal dependencies 25567 */ 25568 25569 25570 const { 25571 useHasDimensionsPanel, 25572 useHasTypographyPanel, 25573 useHasColorPanel, 25574 useGlobalSetting: root_menu_useGlobalSetting, 25575 useSettingsForBlockElement 25576 } = unlock(external_wp_blockEditor_namespaceObject.privateApis); 25577 function RootMenu() { 25578 const [rawSettings] = root_menu_useGlobalSetting(''); 25579 const settings = useSettingsForBlockElement(rawSettings); 25580 const hasTypographyPanel = useHasTypographyPanel(settings); 25581 const hasColorPanel = useHasColorPanel(settings); 25582 const hasDimensionsPanel = useHasDimensionsPanel(settings); 25583 const hasLayoutPanel = hasDimensionsPanel; 25584 return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalItemGroup, null, hasTypographyPanel && (0,external_React_.createElement)(NavigationButtonAsItem, { 25585 icon: library_typography, 25586 path: "/typography", 25587 "aria-label": (0,external_wp_i18n_namespaceObject.__)('Typography styles') 25588 }, (0,external_wp_i18n_namespaceObject.__)('Typography')), hasColorPanel && (0,external_React_.createElement)(NavigationButtonAsItem, { 25589 icon: library_color, 25590 path: "/colors", 25591 "aria-label": (0,external_wp_i18n_namespaceObject.__)('Colors styles') 25592 }, (0,external_wp_i18n_namespaceObject.__)('Colors')), hasLayoutPanel && (0,external_React_.createElement)(NavigationButtonAsItem, { 25593 icon: library_layout, 25594 path: "/layout", 25595 "aria-label": (0,external_wp_i18n_namespaceObject.__)('Layout styles') 25596 }, (0,external_wp_i18n_namespaceObject.__)('Layout')))); 25597 } 25598 /* harmony default export */ const root_menu = (RootMenu); 25599 25600 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/global-styles/screen-root.js 25601 25602 /** 25603 * WordPress dependencies 25604 */ 25605 25606 25607 25608 25609 25610 25611 25612 /** 25613 * Internal dependencies 25614 */ 25615 25616 25617 25618 25619 25620 const { 25621 useGlobalStyle: screen_root_useGlobalStyle 25622 } = unlock(external_wp_blockEditor_namespaceObject.privateApis); 25623 function ScreenRoot() { 25624 const [customCSS] = screen_root_useGlobalStyle('css'); 25625 const { 25626 hasVariations, 25627 canEditCSS 25628 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 25629 const { 25630 getEntityRecord, 25631 __experimentalGetCurrentGlobalStylesId, 25632 __experimentalGetCurrentThemeGlobalStylesVariations 25633 } = select(external_wp_coreData_namespaceObject.store); 25634 const globalStylesId = __experimentalGetCurrentGlobalStylesId(); 25635 const globalStyles = globalStylesId ? getEntityRecord('root', 'globalStyles', globalStylesId) : undefined; 25636 return { 25637 hasVariations: !!__experimentalGetCurrentThemeGlobalStylesVariations()?.length, 25638 canEditCSS: !!globalStyles?._links?.['wp:action-edit-css'] 25639 }; 25640 }, []); 25641 return (0,external_React_.createElement)(external_wp_components_namespaceObject.Card, { 25642 size: "small", 25643 className: "edit-site-global-styles-screen-root" 25644 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.CardBody, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { 25645 spacing: 4 25646 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.Card, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.CardMedia, null, (0,external_React_.createElement)(preview, null))), hasVariations && (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalItemGroup, null, (0,external_React_.createElement)(NavigationButtonAsItem, { 25647 path: "/variations", 25648 "aria-label": (0,external_wp_i18n_namespaceObject.__)('Browse styles') 25649 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { 25650 justify: "space-between" 25651 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.FlexItem, null, (0,external_wp_i18n_namespaceObject.__)('Browse styles')), (0,external_React_.createElement)(IconWithCurrentColor, { 25652 icon: (0,external_wp_i18n_namespaceObject.isRTL)() ? chevron_left : chevron_right 25653 })))), (0,external_React_.createElement)(root_menu, null))), (0,external_React_.createElement)(external_wp_components_namespaceObject.CardDivider, null), (0,external_React_.createElement)(external_wp_components_namespaceObject.CardBody, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalSpacer, { 25654 as: "p", 25655 paddingTop: 2 25656 /* 25657 * 13px matches the text inset of the NavigationButton (12px padding, plus the width of the button's border). 25658 * This is an ad hoc override for this instance and the Addtional CSS option below. Other options for matching the 25659 * the nav button inset should be looked at before reusing further. 25660 */, 25661 paddingX: "13px", 25662 marginBottom: 4 25663 }, (0,external_wp_i18n_namespaceObject.__)('Customize the appearance of specific blocks for the whole site.')), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalItemGroup, null, (0,external_React_.createElement)(NavigationButtonAsItem, { 25664 path: "/blocks", 25665 "aria-label": (0,external_wp_i18n_namespaceObject.__)('Blocks styles') 25666 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { 25667 justify: "space-between" 25668 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.FlexItem, null, (0,external_wp_i18n_namespaceObject.__)('Blocks')), (0,external_React_.createElement)(IconWithCurrentColor, { 25669 icon: (0,external_wp_i18n_namespaceObject.isRTL)() ? chevron_left : chevron_right 25670 }))))), canEditCSS && !!customCSS && (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.CardDivider, null), (0,external_React_.createElement)(external_wp_components_namespaceObject.CardBody, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalSpacer, { 25671 as: "p", 25672 paddingTop: 2, 25673 paddingX: "13px", 25674 marginBottom: 4 25675 }, (0,external_wp_i18n_namespaceObject.__)('Add your own CSS to customize the appearance and layout of your site.')), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalItemGroup, null, (0,external_React_.createElement)(NavigationButtonAsItem, { 25676 path: "/css", 25677 "aria-label": (0,external_wp_i18n_namespaceObject.__)('Additional CSS') 25678 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { 25679 justify: "space-between" 25680 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.FlexItem, null, (0,external_wp_i18n_namespaceObject.__)('Additional CSS')), (0,external_React_.createElement)(IconWithCurrentColor, { 25681 icon: (0,external_wp_i18n_namespaceObject.isRTL)() ? chevron_left : chevron_right 25682 }))))))); 25683 } 25684 /* harmony default export */ const screen_root = (ScreenRoot); 25685 25686 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/global-styles/variations-panel.js 25687 25688 /** 25689 * WordPress dependencies 25690 */ 25691 25692 25693 25694 /** 25695 * Internal dependencies 25696 */ 25697 25698 25699 function getCoreBlockStyles(blockStyles) { 25700 return blockStyles?.filter(style => style.source === 'block'); 25701 } 25702 function useBlockVariations(name) { 25703 const blockStyles = (0,external_wp_data_namespaceObject.useSelect)(select => { 25704 const { 25705 getBlockStyles 25706 } = select(external_wp_blocks_namespaceObject.store); 25707 return getBlockStyles(name); 25708 }, [name]); 25709 const coreBlockStyles = getCoreBlockStyles(blockStyles); 25710 return coreBlockStyles; 25711 } 25712 function VariationsPanel({ 25713 name 25714 }) { 25715 const coreBlockStyles = useBlockVariations(name); 25716 return (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalItemGroup, { 25717 isBordered: true, 25718 isSeparated: true 25719 }, coreBlockStyles.map((style, index) => { 25720 if (style?.isDefault) { 25721 return null; 25722 } 25723 return (0,external_React_.createElement)(NavigationButtonAsItem, { 25724 key: index, 25725 path: '/blocks/' + encodeURIComponent(name) + '/variations/' + encodeURIComponent(style.name), 25726 "aria-label": style.label 25727 }, style.label); 25728 })); 25729 } 25730 25731 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/global-styles/header.js 25732 25733 /** 25734 * WordPress dependencies 25735 */ 25736 25737 25738 25739 function ScreenHeader({ 25740 title, 25741 description, 25742 onBack 25743 }) { 25744 return (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { 25745 spacing: 0 25746 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalView, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalSpacer, { 25747 marginBottom: 0, 25748 paddingX: 4, 25749 paddingY: 3 25750 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { 25751 spacing: 2 25752 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalNavigatorToParentButton, { 25753 style: 25754 // TODO: This style override is also used in ToolsPanelHeader. 25755 // It should be supported out-of-the-box by Button. 25756 { 25757 minWidth: 24, 25758 padding: 0 25759 }, 25760 icon: (0,external_wp_i18n_namespaceObject.isRTL)() ? chevron_right : chevron_left, 25761 isSmall: true, 25762 "aria-label": (0,external_wp_i18n_namespaceObject.__)('Navigate to the previous view'), 25763 onClick: onBack 25764 }), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalSpacer, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHeading, { 25765 className: "edit-site-global-styles-header", 25766 level: 2, 25767 size: 13 25768 }, title))))), description && (0,external_React_.createElement)("p", { 25769 className: "edit-site-global-styles-header__description" 25770 }, description)); 25771 } 25772 /* harmony default export */ const header = (ScreenHeader); 25773 25774 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/global-styles/screen-block-list.js 25775 25776 /** 25777 * WordPress dependencies 25778 */ 25779 25780 25781 25782 25783 25784 25785 25786 25787 25788 /** 25789 * Internal dependencies 25790 */ 25791 25792 25793 25794 25795 const { 25796 useHasDimensionsPanel: screen_block_list_useHasDimensionsPanel, 25797 useHasTypographyPanel: screen_block_list_useHasTypographyPanel, 25798 useHasBorderPanel, 25799 useGlobalSetting: screen_block_list_useGlobalSetting, 25800 useSettingsForBlockElement: screen_block_list_useSettingsForBlockElement, 25801 useHasColorPanel: screen_block_list_useHasColorPanel 25802 } = unlock(external_wp_blockEditor_namespaceObject.privateApis); 25803 function useSortedBlockTypes() { 25804 const blockItems = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_blocks_namespaceObject.store).getBlockTypes(), []); 25805 // Ensure core blocks are prioritized in the returned results, 25806 // because third party blocks can be registered earlier than 25807 // the core blocks (usually by using the `init` action), 25808 // thus affecting the display order. 25809 // We don't sort reusable blocks as they are handled differently. 25810 const groupByType = (blocks, block) => { 25811 const { 25812 core, 25813 noncore 25814 } = blocks; 25815 const type = block.name.startsWith('core/') ? core : noncore; 25816 type.push(block); 25817 return blocks; 25818 }; 25819 const { 25820 core: coreItems, 25821 noncore: nonCoreItems 25822 } = blockItems.reduce(groupByType, { 25823 core: [], 25824 noncore: [] 25825 }); 25826 return [...coreItems, ...nonCoreItems]; 25827 } 25828 function useBlockHasGlobalStyles(blockName) { 25829 const [rawSettings] = screen_block_list_useGlobalSetting('', blockName); 25830 const settings = screen_block_list_useSettingsForBlockElement(rawSettings, blockName); 25831 const hasTypographyPanel = screen_block_list_useHasTypographyPanel(settings); 25832 const hasColorPanel = screen_block_list_useHasColorPanel(settings); 25833 const hasBorderPanel = useHasBorderPanel(settings); 25834 const hasDimensionsPanel = screen_block_list_useHasDimensionsPanel(settings); 25835 const hasLayoutPanel = hasBorderPanel || hasDimensionsPanel; 25836 const hasVariationsPanel = !!useBlockVariations(blockName)?.length; 25837 const hasGlobalStyles = hasTypographyPanel || hasColorPanel || hasLayoutPanel || hasVariationsPanel; 25838 return hasGlobalStyles; 25839 } 25840 function BlockMenuItem({ 25841 block 25842 }) { 25843 const hasBlockMenuItem = useBlockHasGlobalStyles(block.name); 25844 if (!hasBlockMenuItem) { 25845 return null; 25846 } 25847 const navigationButtonLabel = (0,external_wp_i18n_namespaceObject.sprintf)( 25848 // translators: %s: is the name of a block e.g., 'Image' or 'Table'. 25849 (0,external_wp_i18n_namespaceObject.__)('%s block styles'), block.title); 25850 return (0,external_React_.createElement)(NavigationButtonAsItem, { 25851 path: '/blocks/' + encodeURIComponent(block.name), 25852 "aria-label": navigationButtonLabel 25853 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { 25854 justify: "flex-start" 25855 }, (0,external_React_.createElement)(external_wp_blockEditor_namespaceObject.BlockIcon, { 25856 icon: block.icon 25857 }), (0,external_React_.createElement)(external_wp_components_namespaceObject.FlexItem, null, block.title))); 25858 } 25859 function BlockList({ 25860 filterValue 25861 }) { 25862 const sortedBlockTypes = useSortedBlockTypes(); 25863 const debouncedSpeak = (0,external_wp_compose_namespaceObject.useDebounce)(external_wp_a11y_namespaceObject.speak, 500); 25864 const { 25865 isMatchingSearchTerm 25866 } = (0,external_wp_data_namespaceObject.useSelect)(external_wp_blocks_namespaceObject.store); 25867 const filteredBlockTypes = !filterValue ? sortedBlockTypes : sortedBlockTypes.filter(blockType => isMatchingSearchTerm(blockType, filterValue)); 25868 const blockTypesListRef = (0,external_wp_element_namespaceObject.useRef)(); 25869 25870 // Announce search results on change 25871 (0,external_wp_element_namespaceObject.useEffect)(() => { 25872 if (!filterValue) { 25873 return; 25874 } 25875 // We extract the results from the wrapper div's `ref` because 25876 // filtered items can contain items that will eventually not 25877 // render and there is no reliable way to detect when a child 25878 // will return `null`. 25879 // TODO: We should find a better way of handling this as it's 25880 // fragile and depends on the number of rendered elements of `BlockMenuItem`, 25881 // which is now one. 25882 // @see https://github.com/WordPress/gutenberg/pull/39117#discussion_r816022116 25883 const count = blockTypesListRef.current.childElementCount; 25884 const resultsFoundMessage = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %d: number of results. */ 25885 (0,external_wp_i18n_namespaceObject._n)('%d result found.', '%d results found.', count), count); 25886 debouncedSpeak(resultsFoundMessage, count); 25887 }, [filterValue, debouncedSpeak]); 25888 return (0,external_React_.createElement)("div", { 25889 ref: blockTypesListRef, 25890 className: "edit-site-block-types-item-list" 25891 }, filteredBlockTypes.map(block => (0,external_React_.createElement)(BlockMenuItem, { 25892 block: block, 25893 key: 'menu-itemblock-' + block.name 25894 }))); 25895 } 25896 const MemoizedBlockList = (0,external_wp_element_namespaceObject.memo)(BlockList); 25897 function ScreenBlockList() { 25898 const [filterValue, setFilterValue] = (0,external_wp_element_namespaceObject.useState)(''); 25899 const deferredFilterValue = (0,external_wp_element_namespaceObject.useDeferredValue)(filterValue); 25900 return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(header, { 25901 title: (0,external_wp_i18n_namespaceObject.__)('Blocks'), 25902 description: (0,external_wp_i18n_namespaceObject.__)('Customize the appearance of specific blocks and for the whole site.') 25903 }), (0,external_React_.createElement)(external_wp_components_namespaceObject.SearchControl, { 25904 __nextHasNoMarginBottom: true, 25905 className: "edit-site-block-types-search", 25906 onChange: setFilterValue, 25907 value: filterValue, 25908 label: (0,external_wp_i18n_namespaceObject.__)('Search for blocks'), 25909 placeholder: (0,external_wp_i18n_namespaceObject.__)('Search') 25910 }), (0,external_React_.createElement)(MemoizedBlockList, { 25911 filterValue: deferredFilterValue 25912 })); 25913 } 25914 /* harmony default export */ const screen_block_list = (ScreenBlockList); 25915 25916 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/global-styles/block-preview-panel.js 25917 25918 /** 25919 * WordPress dependencies 25920 */ 25921 25922 25923 25924 25925 const BlockPreviewPanel = ({ 25926 name, 25927 variation = '' 25928 }) => { 25929 var _blockExample$viewpor; 25930 const blockExample = (0,external_wp_blocks_namespaceObject.getBlockType)(name)?.example; 25931 const blocks = (0,external_wp_element_namespaceObject.useMemo)(() => { 25932 if (!blockExample) { 25933 return null; 25934 } 25935 let example = blockExample; 25936 if (variation) { 25937 example = { 25938 ...example, 25939 attributes: { 25940 ...example.attributes, 25941 className: 'is-style-' + variation 25942 } 25943 }; 25944 } 25945 return (0,external_wp_blocks_namespaceObject.getBlockFromExample)(name, example); 25946 }, [name, blockExample, variation]); 25947 const viewportWidth = (_blockExample$viewpor = blockExample?.viewportWidth) !== null && _blockExample$viewpor !== void 0 ? _blockExample$viewpor : null; 25948 const previewHeight = 150; 25949 if (!blockExample) { 25950 return null; 25951 } 25952 return (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalSpacer, { 25953 marginX: 4, 25954 marginBottom: 4 25955 }, (0,external_React_.createElement)("div", { 25956 className: "edit-site-global-styles__block-preview-panel", 25957 style: { 25958 maxHeight: previewHeight, 25959 boxSizing: 'initial' 25960 } 25961 }, (0,external_React_.createElement)(external_wp_blockEditor_namespaceObject.BlockPreview, { 25962 blocks: blocks, 25963 viewportWidth: viewportWidth, 25964 minHeight: previewHeight, 25965 additionalStyles: [{ 25966 css: ` 25967 body{ 25968 min-height:$previewHeight}px; 25969 display:flex;align-items:center;justify-content:center; 25970 } 25971 ` 25972 }] 25973 }))); 25974 }; 25975 /* harmony default export */ const block_preview_panel = (BlockPreviewPanel); 25976 25977 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/global-styles/subtitle.js 25978 25979 /** 25980 * WordPress dependencies 25981 */ 25982 25983 function Subtitle({ 25984 children, 25985 level 25986 }) { 25987 return (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHeading, { 25988 className: "edit-site-global-styles-subtitle", 25989 level: level !== null && level !== void 0 ? level : 2 25990 }, children); 25991 } 25992 /* harmony default export */ const subtitle = (Subtitle); 25993 25994 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/global-styles/screen-block.js 25995 25996 /** 25997 * WordPress dependencies 25998 */ 25999 26000 26001 26002 26003 26004 26005 26006 26007 /** 26008 * Internal dependencies 26009 */ 26010 26011 26012 26013 26014 26015 function applyFallbackStyle(border) { 26016 if (!border) { 26017 return border; 26018 } 26019 const hasColorOrWidth = border.color || border.width; 26020 if (!border.style && hasColorOrWidth) { 26021 return { 26022 ...border, 26023 style: 'solid' 26024 }; 26025 } 26026 if (border.style && !hasColorOrWidth) { 26027 return undefined; 26028 } 26029 return border; 26030 } 26031 function applyAllFallbackStyles(border) { 26032 if (!border) { 26033 return border; 26034 } 26035 if ((0,external_wp_components_namespaceObject.__experimentalHasSplitBorders)(border)) { 26036 return { 26037 top: applyFallbackStyle(border.top), 26038 right: applyFallbackStyle(border.right), 26039 bottom: applyFallbackStyle(border.bottom), 26040 left: applyFallbackStyle(border.left) 26041 }; 26042 } 26043 return applyFallbackStyle(border); 26044 } 26045 const { 26046 useHasDimensionsPanel: screen_block_useHasDimensionsPanel, 26047 useHasTypographyPanel: screen_block_useHasTypographyPanel, 26048 useHasBorderPanel: screen_block_useHasBorderPanel, 26049 useGlobalSetting: screen_block_useGlobalSetting, 26050 useSettingsForBlockElement: screen_block_useSettingsForBlockElement, 26051 useHasColorPanel: screen_block_useHasColorPanel, 26052 useHasFiltersPanel, 26053 useHasImageSettingsPanel, 26054 useGlobalStyle: screen_block_useGlobalStyle, 26055 BorderPanel: StylesBorderPanel, 26056 ColorPanel: StylesColorPanel, 26057 TypographyPanel: StylesTypographyPanel, 26058 DimensionsPanel: StylesDimensionsPanel, 26059 FiltersPanel: StylesFiltersPanel, 26060 ImageSettingsPanel, 26061 AdvancedPanel: StylesAdvancedPanel 26062 } = unlock(external_wp_blockEditor_namespaceObject.privateApis); 26063 function ScreenBlock({ 26064 name, 26065 variation 26066 }) { 26067 let prefixParts = []; 26068 if (variation) { 26069 prefixParts = ['variations', variation].concat(prefixParts); 26070 } 26071 const prefix = prefixParts.join('.'); 26072 const [style] = screen_block_useGlobalStyle(prefix, name, 'user', { 26073 shouldDecodeEncode: false 26074 }); 26075 const [inheritedStyle, setStyle] = screen_block_useGlobalStyle(prefix, name, 'all', { 26076 shouldDecodeEncode: false 26077 }); 26078 const [userSettings] = screen_block_useGlobalSetting('', name, 'user'); 26079 const [rawSettings, setSettings] = screen_block_useGlobalSetting('', name); 26080 const settings = screen_block_useSettingsForBlockElement(rawSettings, name); 26081 const blockType = (0,external_wp_blocks_namespaceObject.getBlockType)(name); 26082 26083 // Only allow `blockGap` support if serialization has not been skipped, to be sure global spacing can be applied. 26084 if (settings?.spacing?.blockGap && blockType?.supports?.spacing?.blockGap && (blockType?.supports?.spacing?.__experimentalSkipSerialization === true || blockType?.supports?.spacing?.__experimentalSkipSerialization?.some?.(spacingType => spacingType === 'blockGap'))) { 26085 settings.spacing.blockGap = false; 26086 } 26087 26088 // Only allow `aspectRatio` support if the block is not the grouping block. 26089 // The grouping block allows the user to use Group, Row and Stack variations, 26090 // and it is highly likely that the user will not want to set an aspect ratio 26091 // for all three at once. Until there is the ability to set a different aspect 26092 // ratio for each variation, we disable the aspect ratio controls for the 26093 // grouping block in global styles. 26094 if (settings?.dimensions?.aspectRatio && name === 'core/group') { 26095 settings.dimensions.aspectRatio = false; 26096 } 26097 const blockVariations = useBlockVariations(name); 26098 const hasTypographyPanel = screen_block_useHasTypographyPanel(settings); 26099 const hasColorPanel = screen_block_useHasColorPanel(settings); 26100 const hasBorderPanel = screen_block_useHasBorderPanel(settings); 26101 const hasDimensionsPanel = screen_block_useHasDimensionsPanel(settings); 26102 const hasFiltersPanel = useHasFiltersPanel(settings); 26103 const hasImageSettingsPanel = useHasImageSettingsPanel(name, userSettings, settings); 26104 const hasVariationsPanel = !!blockVariations?.length && !variation; 26105 const { 26106 canEditCSS 26107 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 26108 const { 26109 getEntityRecord, 26110 __experimentalGetCurrentGlobalStylesId 26111 } = select(external_wp_coreData_namespaceObject.store); 26112 const globalStylesId = __experimentalGetCurrentGlobalStylesId(); 26113 const globalStyles = globalStylesId ? getEntityRecord('root', 'globalStyles', globalStylesId) : undefined; 26114 return { 26115 canEditCSS: !!globalStyles?._links?.['wp:action-edit-css'] 26116 }; 26117 }, []); 26118 const currentBlockStyle = variation ? blockVariations.find(s => s.name === variation) : null; 26119 26120 // These intermediary objects are needed because the "layout" property is stored 26121 // in settings rather than styles. 26122 const inheritedStyleWithLayout = (0,external_wp_element_namespaceObject.useMemo)(() => { 26123 return { 26124 ...inheritedStyle, 26125 layout: settings.layout 26126 }; 26127 }, [inheritedStyle, settings.layout]); 26128 const styleWithLayout = (0,external_wp_element_namespaceObject.useMemo)(() => { 26129 return { 26130 ...style, 26131 layout: userSettings.layout 26132 }; 26133 }, [style, userSettings.layout]); 26134 const onChangeDimensions = newStyle => { 26135 const updatedStyle = { 26136 ...newStyle 26137 }; 26138 delete updatedStyle.layout; 26139 setStyle(updatedStyle); 26140 if (newStyle.layout !== userSettings.layout) { 26141 setSettings({ 26142 ...userSettings, 26143 layout: newStyle.layout 26144 }); 26145 } 26146 }; 26147 const onChangeLightbox = newSetting => { 26148 // If the newSetting is undefined, this means that the user has deselected 26149 // (reset) the lightbox setting. 26150 if (newSetting === undefined) { 26151 setSettings({ 26152 ...rawSettings, 26153 lightbox: undefined 26154 }); 26155 26156 // Otherwise, we simply set the lightbox setting to the new value but 26157 // taking care of not overriding the other lightbox settings. 26158 } else { 26159 setSettings({ 26160 ...rawSettings, 26161 lightbox: { 26162 ...rawSettings.lightbox, 26163 ...newSetting 26164 } 26165 }); 26166 } 26167 }; 26168 const onChangeBorders = newStyle => { 26169 if (!newStyle?.border) { 26170 setStyle(newStyle); 26171 return; 26172 } 26173 26174 // As Global Styles can't conditionally generate styles based on if 26175 // other style properties have been set, we need to force split 26176 // border definitions for user set global border styles. Border 26177 // radius is derived from the same property i.e. `border.radius` if 26178 // it is a string that is used. The longhand border radii styles are 26179 // only generated if that property is an object. 26180 // 26181 // For borders (color, style, and width) those are all properties on 26182 // the `border` style property. This means if the theme.json defined 26183 // split borders and the user condenses them into a flat border or 26184 // vice-versa we'd get both sets of styles which would conflict. 26185 const { 26186 radius, 26187 ...newBorder 26188 } = newStyle.border; 26189 const border = applyAllFallbackStyles(newBorder); 26190 const updatedBorder = !(0,external_wp_components_namespaceObject.__experimentalHasSplitBorders)(border) ? { 26191 top: border, 26192 right: border, 26193 bottom: border, 26194 left: border 26195 } : { 26196 color: null, 26197 style: null, 26198 width: null, 26199 ...border 26200 }; 26201 setStyle({ 26202 ...newStyle, 26203 border: { 26204 ...updatedBorder, 26205 radius 26206 } 26207 }); 26208 }; 26209 return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(header, { 26210 title: variation ? currentBlockStyle.label : blockType.title 26211 }), (0,external_React_.createElement)(block_preview_panel, { 26212 name: name, 26213 variation: variation 26214 }), hasVariationsPanel && (0,external_React_.createElement)("div", { 26215 className: "edit-site-global-styles-screen-variations" 26216 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { 26217 spacing: 3 26218 }, (0,external_React_.createElement)(subtitle, null, (0,external_wp_i18n_namespaceObject.__)('Style Variations')), (0,external_React_.createElement)(VariationsPanel, { 26219 name: name 26220 }))), hasColorPanel && (0,external_React_.createElement)(StylesColorPanel, { 26221 inheritedValue: inheritedStyle, 26222 value: style, 26223 onChange: setStyle, 26224 settings: settings 26225 }), hasTypographyPanel && (0,external_React_.createElement)(StylesTypographyPanel, { 26226 inheritedValue: inheritedStyle, 26227 value: style, 26228 onChange: setStyle, 26229 settings: settings 26230 }), hasDimensionsPanel && (0,external_React_.createElement)(StylesDimensionsPanel, { 26231 inheritedValue: inheritedStyleWithLayout, 26232 value: styleWithLayout, 26233 onChange: onChangeDimensions, 26234 settings: settings, 26235 includeLayoutControls: true 26236 }), hasBorderPanel && (0,external_React_.createElement)(StylesBorderPanel, { 26237 inheritedValue: inheritedStyle, 26238 value: style, 26239 onChange: onChangeBorders, 26240 settings: settings 26241 }), hasFiltersPanel && (0,external_React_.createElement)(StylesFiltersPanel, { 26242 inheritedValue: inheritedStyleWithLayout, 26243 value: styleWithLayout, 26244 onChange: setStyle, 26245 settings: settings, 26246 includeLayoutControls: true 26247 }), hasImageSettingsPanel && (0,external_React_.createElement)(ImageSettingsPanel, { 26248 onChange: onChangeLightbox, 26249 value: userSettings, 26250 inheritedValue: settings 26251 }), canEditCSS && (0,external_React_.createElement)(external_wp_components_namespaceObject.PanelBody, { 26252 title: (0,external_wp_i18n_namespaceObject.__)('Advanced'), 26253 initialOpen: false 26254 }, (0,external_React_.createElement)("p", null, (0,external_wp_i18n_namespaceObject.sprintf)( 26255 // translators: %s: is the name of a block e.g., 'Image' or 'Table'. 26256 (0,external_wp_i18n_namespaceObject.__)('Add your own CSS to customize the appearance of the %s block. You do not need to include a CSS selector, just add the property and value.'), blockType?.title)), (0,external_React_.createElement)(StylesAdvancedPanel, { 26257 value: style, 26258 onChange: setStyle, 26259 inheritedValue: inheritedStyle 26260 }))); 26261 } 26262 /* harmony default export */ const screen_block = (ScreenBlock); 26263 26264 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/global-styles/typogrphy-elements.js 26265 26266 /** 26267 * WordPress dependencies 26268 */ 26269 26270 26271 26272 26273 /** 26274 * Internal dependencies 26275 */ 26276 26277 26278 26279 const { 26280 useGlobalStyle: typogrphy_elements_useGlobalStyle 26281 } = unlock(external_wp_blockEditor_namespaceObject.privateApis); 26282 function ElementItem({ 26283 parentMenu, 26284 element, 26285 label 26286 }) { 26287 const prefix = element === 'text' || !element ? '' : `elements.$element}.`; 26288 const extraStyles = element === 'link' ? { 26289 textDecoration: 'underline' 26290 } : {}; 26291 const [fontFamily] = typogrphy_elements_useGlobalStyle(prefix + 'typography.fontFamily'); 26292 const [fontStyle] = typogrphy_elements_useGlobalStyle(prefix + 'typography.fontStyle'); 26293 const [fontWeight] = typogrphy_elements_useGlobalStyle(prefix + 'typography.fontWeight'); 26294 const [letterSpacing] = typogrphy_elements_useGlobalStyle(prefix + 'typography.letterSpacing'); 26295 const [backgroundColor] = typogrphy_elements_useGlobalStyle(prefix + 'color.background'); 26296 const [gradientValue] = typogrphy_elements_useGlobalStyle(prefix + 'color.gradient'); 26297 const [color] = typogrphy_elements_useGlobalStyle(prefix + 'color.text'); 26298 const navigationButtonLabel = (0,external_wp_i18n_namespaceObject.sprintf)( 26299 // translators: %s: is a subset of Typography, e.g., 'text' or 'links'. 26300 (0,external_wp_i18n_namespaceObject.__)('Typography %s styles'), label); 26301 return (0,external_React_.createElement)(NavigationButtonAsItem, { 26302 path: parentMenu + '/typography/' + element, 26303 "aria-label": navigationButtonLabel 26304 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { 26305 justify: "flex-start" 26306 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.FlexItem, { 26307 className: "edit-site-global-styles-screen-typography__indicator", 26308 style: { 26309 fontFamily: fontFamily !== null && fontFamily !== void 0 ? fontFamily : 'serif', 26310 background: gradientValue !== null && gradientValue !== void 0 ? gradientValue : backgroundColor, 26311 color, 26312 fontStyle, 26313 fontWeight, 26314 letterSpacing, 26315 ...extraStyles 26316 } 26317 }, (0,external_wp_i18n_namespaceObject.__)('Aa')), (0,external_React_.createElement)(external_wp_components_namespaceObject.FlexItem, null, label))); 26318 } 26319 function TypographyElements() { 26320 const parentMenu = ''; 26321 return (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { 26322 spacing: 3 26323 }, (0,external_React_.createElement)(subtitle, { 26324 level: 3 26325 }, (0,external_wp_i18n_namespaceObject.__)('Elements')), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalItemGroup, { 26326 isBordered: true, 26327 isSeparated: true 26328 }, (0,external_React_.createElement)(ElementItem, { 26329 parentMenu: parentMenu, 26330 element: "text", 26331 label: (0,external_wp_i18n_namespaceObject.__)('Text') 26332 }), (0,external_React_.createElement)(ElementItem, { 26333 parentMenu: parentMenu, 26334 element: "link", 26335 label: (0,external_wp_i18n_namespaceObject.__)('Links') 26336 }), (0,external_React_.createElement)(ElementItem, { 26337 parentMenu: parentMenu, 26338 element: "heading", 26339 label: (0,external_wp_i18n_namespaceObject.__)('Headings') 26340 }), (0,external_React_.createElement)(ElementItem, { 26341 parentMenu: parentMenu, 26342 element: "caption", 26343 label: (0,external_wp_i18n_namespaceObject.__)('Captions') 26344 }), (0,external_React_.createElement)(ElementItem, { 26345 parentMenu: parentMenu, 26346 element: "button", 26347 label: (0,external_wp_i18n_namespaceObject.__)('Buttons') 26348 }))); 26349 } 26350 /* harmony default export */ const typogrphy_elements = (TypographyElements); 26351 26352 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/settings.js 26353 26354 /** 26355 * WordPress dependencies 26356 */ 26357 26358 const settings_settings = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { 26359 xmlns: "http://www.w3.org/2000/svg", 26360 viewBox: "0 0 24 24" 26361 }, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 26362 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" 26363 }), (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 26364 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" 26365 })); 26366 /* harmony default export */ const library_settings = (settings_settings); 26367 26368 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/global-styles/font-library-modal/resolvers.js 26369 /** 26370 * WordPress dependencies 26371 */ 26372 26373 const FONT_FAMILIES_URL = '/wp/v2/font-families'; 26374 const FONT_COLLECTIONS_URL = '/wp/v2/font-collections'; 26375 async function fetchInstallFontFamily(data) { 26376 const config = { 26377 path: FONT_FAMILIES_URL, 26378 method: 'POST', 26379 body: data 26380 }; 26381 const response = await external_wp_apiFetch_default()(config); 26382 return { 26383 id: response.id, 26384 ...response.font_family_settings, 26385 fontFace: [] 26386 }; 26387 } 26388 async function fetchInstallFontFace(fontFamilyId, data) { 26389 const config = { 26390 path: `$FONT_FAMILIES_URL}/$fontFamilyId}/font-faces`, 26391 method: 'POST', 26392 body: data 26393 }; 26394 const response = await external_wp_apiFetch_default()(config); 26395 return { 26396 id: response.id, 26397 ...response.font_face_settings 26398 }; 26399 } 26400 async function fetchGetFontFamilyBySlug(slug) { 26401 const config = { 26402 path: `$FONT_FAMILIES_URL}?slug=$slug}&_embed=true`, 26403 method: 'GET' 26404 }; 26405 const response = await external_wp_apiFetch_default()(config); 26406 if (!response || response.length === 0) { 26407 return null; 26408 } 26409 const fontFamilyPost = response[0]; 26410 return { 26411 id: fontFamilyPost.id, 26412 ...fontFamilyPost.font_family_settings, 26413 fontFace: fontFamilyPost?._embedded?.font_faces.map(face => face.font_face_settings) || [] 26414 }; 26415 } 26416 async function fetchUninstallFontFamily(fontFamilyId) { 26417 const config = { 26418 path: `$FONT_FAMILIES_URL}/$fontFamilyId}?force=true`, 26419 method: 'DELETE' 26420 }; 26421 return await external_wp_apiFetch_default()(config); 26422 } 26423 async function fetchFontCollections() { 26424 const config = { 26425 path: `$FONT_COLLECTIONS_URL}?_fields=slug,name,description`, 26426 method: 'GET' 26427 }; 26428 return await external_wp_apiFetch_default()(config); 26429 } 26430 async function fetchFontCollection(id) { 26431 const config = { 26432 path: `$FONT_COLLECTIONS_URL}/$id}`, 26433 method: 'GET' 26434 }; 26435 return await external_wp_apiFetch_default()(config); 26436 } 26437 26438 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/global-styles/font-library-modal/utils/constants.js 26439 /** 26440 * WordPress dependencies 26441 */ 26442 26443 const ALLOWED_FILE_EXTENSIONS = ['otf', 'ttf', 'woff', 'woff2']; 26444 const FONT_WEIGHTS = { 26445 100: (0,external_wp_i18n_namespaceObject._x)('Thin', 'font weight'), 26446 200: (0,external_wp_i18n_namespaceObject._x)('Extra-light', 'font weight'), 26447 300: (0,external_wp_i18n_namespaceObject._x)('Light', 'font weight'), 26448 400: (0,external_wp_i18n_namespaceObject._x)('Normal', 'font weight'), 26449 500: (0,external_wp_i18n_namespaceObject._x)('Medium', 'font weight'), 26450 600: (0,external_wp_i18n_namespaceObject._x)('Semi-bold', 'font weight'), 26451 700: (0,external_wp_i18n_namespaceObject._x)('Bold', 'font weight'), 26452 800: (0,external_wp_i18n_namespaceObject._x)('Extra-bold', 'font weight'), 26453 900: (0,external_wp_i18n_namespaceObject._x)('Black', 'font weight') 26454 }; 26455 const FONT_STYLES = { 26456 normal: (0,external_wp_i18n_namespaceObject._x)('Normal', 'font style'), 26457 italic: (0,external_wp_i18n_namespaceObject._x)('Italic', 'font style') 26458 }; 26459 26460 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/global-styles/font-library-modal/utils/preview-styles.js 26461 function findNearest(input, numbers) { 26462 // If the numbers array is empty, return null 26463 if (numbers.length === 0) { 26464 return null; 26465 } 26466 // Sort the array based on the absolute difference with the input 26467 numbers.sort((a, b) => Math.abs(input - a) - Math.abs(input - b)); 26468 // Return the first element (which will be the nearest) from the sorted array 26469 return numbers[0]; 26470 } 26471 function extractFontWeights(fontFaces) { 26472 const result = []; 26473 fontFaces.forEach(face => { 26474 const weights = String(face.fontWeight).split(' '); 26475 if (weights.length === 2) { 26476 const start = parseInt(weights[0]); 26477 const end = parseInt(weights[1]); 26478 for (let i = start; i <= end; i += 100) { 26479 result.push(i); 26480 } 26481 } else if (weights.length === 1) { 26482 result.push(parseInt(weights[0])); 26483 } 26484 }); 26485 return result; 26486 } 26487 26488 /* 26489 * Format the font family to use in the CSS font-family property of a CSS rule. 26490 * 26491 * The input can be a string with the font family name or a string with multiple font family names separated by commas. 26492 * It follows the recommendations from the CSS Fonts Module Level 4. 26493 * https://www.w3.org/TR/css-fonts-4/#font-family-prop 26494 * 26495 * @param {string} input - The font family. 26496 * @return {string} The formatted font family. 26497 * 26498 * Example: 26499 * formatFontFamily( "Open Sans, Font+Name, sans-serif" ) => '"Open Sans", "Font+Name", sans-serif' 26500 * formatFontFamily( "'Open Sans', generic(kai), sans-serif" ) => '"Open Sans", sans-serif' 26501 * formatFontFamily( "DotGothic16, Slabo 27px, serif" ) => '"DotGothic16","Slabo 27px",serif' 26502 * formatFontFamily( "Mine's, Moe's Typography" ) => `"mine's","Moe's Typography"` 26503 */ 26504 function formatFontFamily(input) { 26505 // Matches strings that are not exclusively alphabetic characters or hyphens, and do not exactly follow the pattern generic(alphabetic characters or hyphens). 26506 const regex = /^(?!generic\([ a-zA-Z\-]+\)$)(?!^[a-zA-Z\-]+$).+/; 26507 const output = input.trim(); 26508 const formatItem = item => { 26509 item = item.trim(); 26510 if (item.match(regex)) { 26511 // removes leading and trailing quotes. 26512 item = item.replace(/^["']|["']$/g, ''); 26513 return `"$item}"`; 26514 } 26515 return item; 26516 }; 26517 if (output.includes(',')) { 26518 return output.split(',').map(formatItem).filter(item => item !== '').join(', '); 26519 } 26520 return formatItem(output); 26521 } 26522 26523 /* 26524 * Format the font face name to use in the font-family property of a font face. 26525 * 26526 * The input can be a string with the font face name or a string with multiple font face names separated by commas. 26527 * It removes the leading and trailing quotes from the font face name. 26528 * 26529 * @param {string} input - The font face name. 26530 * @return {string} The formatted font face name. 26531 * 26532 * Example: 26533 * formatFontFaceName("Open Sans") => "Open Sans" 26534 * formatFontFaceName("'Open Sans', sans-serif") => "Open Sans" 26535 * formatFontFaceName(", 'Open Sans', 'Helvetica Neue', sans-serif") => "Open Sans" 26536 */ 26537 function formatFontFaceName(input) { 26538 if (!input) { 26539 return ''; 26540 } 26541 let output = input.trim(); 26542 if (output.includes(',')) { 26543 output = output.split(',') 26544 // finds the first item that is not an empty string. 26545 .find(item => item.trim() !== '').trim(); 26546 } 26547 // removes leading and trailing quotes. 26548 output = output.replace(/^["']|["']$/g, ''); 26549 26550 // Firefox needs the font name to be wrapped in double quotes meanwhile other browsers don't. 26551 if (window.navigator.userAgent.toLowerCase().includes('firefox')) { 26552 output = `"$output}"`; 26553 } 26554 return output; 26555 } 26556 function getFamilyPreviewStyle(family) { 26557 const style = { 26558 fontFamily: formatFontFamily(family.fontFamily) 26559 }; 26560 if (!Array.isArray(family.fontFace)) { 26561 style.fontWeight = '400'; 26562 style.fontStyle = 'normal'; 26563 return style; 26564 } 26565 if (family.fontFace) { 26566 //get all the font faces with normal style 26567 const normalFaces = family.fontFace.filter(face => face.fontStyle.toLowerCase() === 'normal'); 26568 if (normalFaces.length > 0) { 26569 style.fontStyle = 'normal'; 26570 const normalWeights = extractFontWeights(normalFaces); 26571 const nearestWeight = findNearest(400, normalWeights); 26572 style.fontWeight = String(nearestWeight) || '400'; 26573 } else { 26574 style.fontStyle = family.fontFace.length && family.fontFace[0].fontStyle || 'normal'; 26575 style.fontWeight = family.fontFace.length && String(family.fontFace[0].fontWeight) || '400'; 26576 } 26577 } 26578 return style; 26579 } 26580 function getFacePreviewStyle(face) { 26581 return { 26582 fontFamily: formatFontFamily(face.fontFamily), 26583 fontStyle: face.fontStyle || 'normal', 26584 fontWeight: face.fontWeight || '400' 26585 }; 26586 } 26587 26588 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/global-styles/font-library-modal/utils/index.js 26589 /** 26590 * WordPress dependencies 26591 */ 26592 26593 26594 /** 26595 * Internal dependencies 26596 */ 26597 26598 26599 26600 26601 26602 /** 26603 * Browser dependencies 26604 */ 26605 const { 26606 File 26607 } = window; 26608 function setUIValuesNeeded(font, extraValues = {}) { 26609 if (!font.name && (font.fontFamily || font.slug)) { 26610 font.name = font.fontFamily || font.slug; 26611 } 26612 return { 26613 ...font, 26614 ...extraValues 26615 }; 26616 } 26617 function isUrlEncoded(url) { 26618 if (typeof url !== 'string') { 26619 return false; 26620 } 26621 return url !== decodeURIComponent(url); 26622 } 26623 function getFontFaceVariantName(face) { 26624 const weightName = FONT_WEIGHTS[face.fontWeight] || face.fontWeight; 26625 const styleName = face.fontStyle === 'normal' ? '' : FONT_STYLES[face.fontStyle] || face.fontStyle; 26626 return `$weightName} $styleName}`; 26627 } 26628 function mergeFontFaces(existing = [], incoming = []) { 26629 const map = new Map(); 26630 for (const face of existing) { 26631 map.set(`$face.fontWeight}$face.fontStyle}`, face); 26632 } 26633 for (const face of incoming) { 26634 // This will overwrite if the src already exists, keeping it unique. 26635 map.set(`$face.fontWeight}$face.fontStyle}`, face); 26636 } 26637 return Array.from(map.values()); 26638 } 26639 function mergeFontFamilies(existing = [], incoming = []) { 26640 const map = new Map(); 26641 // Add the existing array to the map. 26642 for (const font of existing) { 26643 map.set(font.slug, { 26644 ...font 26645 }); 26646 } 26647 // Add the incoming array to the map, overwriting existing values excepting fontFace that need to be merged. 26648 for (const font of incoming) { 26649 if (map.has(font.slug)) { 26650 const { 26651 fontFace: incomingFontFaces, 26652 ...restIncoming 26653 } = font; 26654 const existingFont = map.get(font.slug); 26655 // Merge the fontFaces existing with the incoming fontFaces. 26656 const mergedFontFaces = mergeFontFaces(existingFont.fontFace, incomingFontFaces); 26657 // Except for the fontFace key all the other keys are overwritten with the incoming values. 26658 map.set(font.slug, { 26659 ...restIncoming, 26660 fontFace: mergedFontFaces 26661 }); 26662 } else { 26663 map.set(font.slug, { 26664 ...font 26665 }); 26666 } 26667 } 26668 return Array.from(map.values()); 26669 } 26670 26671 /* 26672 * Loads the font face from a URL and adds it to the browser. 26673 * It also adds it to the iframe document. 26674 */ 26675 async function loadFontFaceInBrowser(fontFace, source, addTo = 'all') { 26676 let dataSource; 26677 if (typeof source === 'string') { 26678 dataSource = `url($source})`; 26679 // eslint-disable-next-line no-undef 26680 } else if (source instanceof File) { 26681 dataSource = await source.arrayBuffer(); 26682 } else { 26683 return; 26684 } 26685 const newFont = new window.FontFace(formatFontFaceName(fontFace.fontFamily), dataSource, { 26686 style: fontFace.fontStyle, 26687 weight: fontFace.fontWeight 26688 }); 26689 const loadedFace = await newFont.load(); 26690 if (addTo === 'document' || addTo === 'all') { 26691 document.fonts.add(loadedFace); 26692 } 26693 if (addTo === 'iframe' || addTo === 'all') { 26694 const iframeDocument = document.querySelector('iframe[name="editor-canvas"]').contentDocument; 26695 iframeDocument.fonts.add(loadedFace); 26696 } 26697 } 26698 26699 /* 26700 * Unloads the font face and remove it from the browser. 26701 * It also removes it from the iframe document. 26702 * 26703 * Note that Font faces that were added to the set using the CSS @font-face rule 26704 * remain connected to the corresponding CSS, and cannot be deleted. 26705 * 26706 * @see https://developer.mozilla.org/en-US/docs/Web/API/FontFaceSet/delete. 26707 */ 26708 function unloadFontFaceInBrowser(fontFace, removeFrom = 'all') { 26709 const unloadFontFace = fonts => { 26710 fonts.forEach(f => { 26711 if (f.family === formatFontFaceName(fontFace?.fontFamily) && f.weight === fontFace?.fontWeight && f.style === fontFace?.fontStyle) { 26712 fonts.delete(f); 26713 } 26714 }); 26715 }; 26716 if (removeFrom === 'document' || removeFrom === 'all') { 26717 unloadFontFace(document.fonts); 26718 } 26719 if (removeFrom === 'iframe' || removeFrom === 'all') { 26720 const iframeDocument = document.querySelector('iframe[name="editor-canvas"]').contentDocument; 26721 unloadFontFace(iframeDocument.fonts); 26722 } 26723 } 26724 26725 /** 26726 * Retrieves the display source from a font face src. 26727 * 26728 * @param {string|string[]} input - The font face src. 26729 * @return {string|undefined} The display source or undefined if the input is invalid. 26730 */ 26731 function getDisplaySrcFromFontFace(input) { 26732 if (!input) { 26733 return; 26734 } 26735 let src; 26736 if (Array.isArray(input)) { 26737 src = input[0]; 26738 } else { 26739 src = input; 26740 } 26741 // It's expected theme fonts will already be loaded in the browser. 26742 if (src.startsWith('file:.')) { 26743 return; 26744 } 26745 if (!isUrlEncoded(src)) { 26746 src = encodeURI(src); 26747 } 26748 return src; 26749 } 26750 function makeFontFamilyFormData(fontFamily) { 26751 const formData = new FormData(); 26752 const { 26753 kebabCase 26754 } = unlock(external_wp_components_namespaceObject.privateApis); 26755 const { 26756 fontFace, 26757 category, 26758 ...familyWithValidParameters 26759 } = fontFamily; 26760 const fontFamilySettings = { 26761 ...familyWithValidParameters, 26762 slug: kebabCase(fontFamily.slug) 26763 }; 26764 formData.append('font_family_settings', JSON.stringify(fontFamilySettings)); 26765 return formData; 26766 } 26767 function makeFontFacesFormData(font) { 26768 if (font?.fontFace) { 26769 const fontFacesFormData = font.fontFace.map((item, faceIndex) => { 26770 const face = { 26771 ...item 26772 }; 26773 const formData = new FormData(); 26774 if (face.file) { 26775 // Normalize to an array, since face.file may be a single file or an array of files. 26776 const files = Array.isArray(face.file) ? face.file : [face.file]; 26777 const src = []; 26778 files.forEach((file, key) => { 26779 // Slugified file name because the it might contain spaces or characters treated differently on the server. 26780 const fileId = `file-$faceIndex}-$key}`; 26781 // Add the files to the formData 26782 formData.append(fileId, file, file.name); 26783 src.push(fileId); 26784 }); 26785 face.src = src.length === 1 ? src[0] : src; 26786 delete face.file; 26787 formData.append('font_face_settings', JSON.stringify(face)); 26788 } else { 26789 formData.append('font_face_settings', JSON.stringify(face)); 26790 } 26791 return formData; 26792 }); 26793 return fontFacesFormData; 26794 } 26795 } 26796 async function batchInstallFontFaces(fontFamilyId, fontFacesData) { 26797 const responses = []; 26798 26799 /* 26800 * Uses the same response format as Promise.allSettled, but executes requests in sequence to work 26801 * around a race condition that can cause an error when the fonts directory doesn't exist yet. 26802 */ 26803 for (const faceData of fontFacesData) { 26804 try { 26805 const response = await fetchInstallFontFace(fontFamilyId, faceData); 26806 responses.push({ 26807 status: 'fulfilled', 26808 value: response 26809 }); 26810 } catch (error) { 26811 responses.push({ 26812 status: 'rejected', 26813 reason: error 26814 }); 26815 } 26816 } 26817 const results = { 26818 errors: [], 26819 successes: [] 26820 }; 26821 responses.forEach((result, index) => { 26822 if (result.status === 'fulfilled') { 26823 const response = result.value; 26824 if (response.id) { 26825 results.successes.push(response); 26826 } else { 26827 results.errors.push({ 26828 data: fontFacesData[index], 26829 message: `Error: $response.message}` 26830 }); 26831 } 26832 } else { 26833 // Handle network errors or other fetch-related errors 26834 results.errors.push({ 26835 data: fontFacesData[index], 26836 message: result.reason.message 26837 }); 26838 } 26839 }); 26840 return results; 26841 } 26842 26843 /* 26844 * Downloads a font face asset from a URL to the client and returns a File object. 26845 */ 26846 async function downloadFontFaceAssets(src) { 26847 // Normalize to an array, since `src` could be a string or array. 26848 src = Array.isArray(src) ? src : [src]; 26849 const files = await Promise.all(src.map(async url => { 26850 return fetch(new Request(url)).then(response => { 26851 if (!response.ok) { 26852 throw new Error(`Error downloading font face asset from $url}. Server responded with status: $response.status}`); 26853 } 26854 return response.blob(); 26855 }).then(blob => { 26856 const filename = url.split('/').pop(); 26857 const file = new File([blob], filename, { 26858 type: blob.type 26859 }); 26860 return file; 26861 }); 26862 })); 26863 26864 // If we only have one file return it (not the array). Otherwise return all of them in the array. 26865 return files.length === 1 ? files[0] : files; 26866 } 26867 26868 /* 26869 * Determine if a given Font Face is present in a given collection. 26870 * We determine that a font face has been installed by comparing the fontWeight and fontStyle 26871 * 26872 * @param {Object} fontFace The Font Face to seek 26873 * @param {Array} collection The Collection to seek in 26874 * @returns True if the font face is found in the collection. Otherwise False. 26875 */ 26876 function checkFontFaceInstalled(fontFace, collection) { 26877 return -1 !== collection.findIndex(collectionFontFace => { 26878 return collectionFontFace.fontWeight === fontFace.fontWeight && collectionFontFace.fontStyle === fontFace.fontStyle; 26879 }); 26880 } 26881 26882 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/global-styles/font-library-modal/utils/toggleFont.js 26883 /** 26884 * Toggles the activation of a given font or font variant within a list of custom fonts. 26885 * 26886 * - If only the font is provided (without face), the entire font family's activation is toggled. 26887 * - If both font and face are provided, the activation of the specific font variant is toggled. 26888 * 26889 * @param {Object} font - The font to be toggled. 26890 * @param {string} font.slug - The unique identifier for the font. 26891 * @param {Array} [font.fontFace] - The list of font variants (faces) associated with the font. 26892 * 26893 * @param {Object} [face] - The specific font variant to be toggled. 26894 * @param {string} face.fontWeight - The weight of the font variant. 26895 * @param {string} face.fontStyle - The style of the font variant. 26896 * 26897 * @param {Array} initialfonts - The initial list of custom fonts. 26898 * 26899 * @return {Array} - The updated list of custom fonts with the font/font variant toggled. 26900 * 26901 * @example 26902 * const customFonts = [ 26903 * { slug: 'roboto', fontFace: [{ fontWeight: '400', fontStyle: 'normal' }] } 26904 * ]; 26905 * 26906 * toggleFont({ slug: 'roboto' }, null, customFonts); 26907 * // This will remove 'roboto' from customFonts 26908 * 26909 * toggleFont({ slug: 'roboto' }, { fontWeight: '400', fontStyle: 'normal' }, customFonts); 26910 * // This will remove the specified face from 'roboto' in customFonts 26911 * 26912 * toggleFont({ slug: 'roboto' }, { fontWeight: '500', fontStyle: 'normal' }, customFonts); 26913 * // This will add the specified face to 'roboto' in customFonts 26914 */ 26915 function toggleFont(font, face, initialfonts) { 26916 // Helper to check if a font is activated based on its slug 26917 const isFontActivated = f => f.slug === font.slug; 26918 26919 // Helper to get the activated font from a list of fonts 26920 const getActivatedFont = fonts => fonts.find(isFontActivated); 26921 26922 // Toggle the activation status of an entire font family 26923 const toggleEntireFontFamily = activatedFont => { 26924 if (!activatedFont) { 26925 // If the font is not active, activate the entire font family 26926 return [...initialfonts, font]; 26927 } 26928 // If the font is already active, deactivate the entire font family 26929 return initialfonts.filter(f => !isFontActivated(f)); 26930 }; 26931 26932 // Toggle the activation status of a specific font variant 26933 const toggleFontVariant = activatedFont => { 26934 const isFaceActivated = f => f.fontWeight === face.fontWeight && f.fontStyle === face.fontStyle; 26935 if (!activatedFont) { 26936 // If the font family is not active, activate the font family with the font variant 26937 return [...initialfonts, { 26938 ...font, 26939 fontFace: [face] 26940 }]; 26941 } 26942 let newFontFaces = activatedFont.fontFace || []; 26943 if (newFontFaces.find(isFaceActivated)) { 26944 // If the font variant is active, deactivate it 26945 newFontFaces = newFontFaces.filter(f => !isFaceActivated(f)); 26946 } else { 26947 // If the font variant is not active, activate it 26948 newFontFaces = [...newFontFaces, face]; 26949 } 26950 26951 // If there are no more font faces, deactivate the font family 26952 if (newFontFaces.length === 0) { 26953 return initialfonts.filter(f => !isFontActivated(f)); 26954 } 26955 26956 // Return updated fonts list with toggled font variant 26957 return initialfonts.map(f => isFontActivated(f) ? { 26958 ...f, 26959 fontFace: newFontFaces 26960 } : f); 26961 }; 26962 const activatedFont = getActivatedFont(initialfonts); 26963 if (!face) { 26964 return toggleEntireFontFamily(activatedFont); 26965 } 26966 return toggleFontVariant(activatedFont); 26967 } 26968 26969 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/global-styles/font-library-modal/context.js 26970 26971 /** 26972 * WordPress dependencies 26973 */ 26974 26975 26976 26977 26978 26979 26980 /** 26981 * Internal dependencies 26982 */ 26983 26984 26985 const { 26986 useGlobalSetting: context_useGlobalSetting 26987 } = unlock(external_wp_blockEditor_namespaceObject.privateApis); 26988 26989 26990 26991 const FontLibraryContext = (0,external_wp_element_namespaceObject.createContext)({}); 26992 function FontLibraryProvider({ 26993 children 26994 }) { 26995 const { 26996 saveEntityRecord 26997 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store); 26998 const { 26999 globalStylesId 27000 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 27001 const { 27002 __experimentalGetCurrentGlobalStylesId 27003 } = select(external_wp_coreData_namespaceObject.store); 27004 return { 27005 globalStylesId: __experimentalGetCurrentGlobalStylesId() 27006 }; 27007 }); 27008 const globalStyles = (0,external_wp_coreData_namespaceObject.useEntityRecord)('root', 'globalStyles', globalStylesId); 27009 const fontFamiliesHasChanges = !!globalStyles?.edits?.settings?.typography?.fontFamilies; 27010 const [isInstalling, setIsInstalling] = (0,external_wp_element_namespaceObject.useState)(false); 27011 const [refreshKey, setRefreshKey] = (0,external_wp_element_namespaceObject.useState)(0); 27012 const [notice, setNotice] = (0,external_wp_element_namespaceObject.useState)(null); 27013 const refreshLibrary = () => { 27014 setRefreshKey(Date.now()); 27015 }; 27016 const { 27017 records: libraryPosts = [], 27018 isResolving: isResolvingLibrary, 27019 hasResolved: hasResolvedLibrary 27020 } = (0,external_wp_coreData_namespaceObject.useEntityRecords)('postType', 'wp_font_family', { 27021 refreshKey, 27022 _embed: true 27023 }); 27024 const libraryFonts = (libraryPosts || []).map(fontFamilyPost => { 27025 return { 27026 id: fontFamilyPost.id, 27027 ...fontFamilyPost.font_family_settings, 27028 fontFace: fontFamilyPost?._embedded?.font_faces.map(face => face.font_face_settings) || [] 27029 }; 27030 }) || []; 27031 27032 // Global Styles (settings) font families 27033 const [fontFamilies, setFontFamilies] = context_useGlobalSetting('typography.fontFamilies'); 27034 // theme.json file font families 27035 const [baseFontFamilies] = context_useGlobalSetting('typography.fontFamilies', undefined, 'base'); 27036 27037 /* 27038 * Save the font families to the database. 27039 * This function is called when the user activates or deactivates a font family. 27040 * It only updates the global styles post content in the database for new font families. 27041 * This avoids saving other styles/settings changed by the user using other parts of the editor. 27042 * 27043 * It uses the font families from the param to avoid using the font families from an outdated state. 27044 * 27045 * @param {Array} fonts - The font families that will be saved to the database. 27046 */ 27047 const saveFontFamilies = async fonts => { 27048 // Gets the global styles database post content. 27049 const updatedGlobalStyles = globalStyles.record; 27050 27051 // Updates the database version of global styles with the edited font families in the client. 27052 setNestedValue(updatedGlobalStyles, ['settings', 'typography', 'fontFamilies'], fonts); 27053 27054 // Saves a new version of the global styles in the database. 27055 await saveEntityRecord('root', 'globalStyles', updatedGlobalStyles); 27056 }; 27057 27058 // Library Fonts 27059 const [modalTabOpen, setModalTabOpen] = (0,external_wp_element_namespaceObject.useState)(false); 27060 const [libraryFontSelected, setLibraryFontSelected] = (0,external_wp_element_namespaceObject.useState)(null); 27061 27062 // Themes Fonts are the fonts defined in the global styles (database persisted theme.json data). 27063 const themeFonts = fontFamilies?.theme ? fontFamilies.theme.map(f => setUIValuesNeeded(f, { 27064 source: 'theme' 27065 })).sort((a, b) => a.name.localeCompare(b.name)) : []; 27066 const themeFontsSlugs = new Set(themeFonts.map(f => f.slug)); 27067 27068 /* 27069 * Base Theme Fonts are the fonts defined in the theme.json *file*. 27070 * 27071 * Uses the fonts from global styles + the ones from the theme.json file that hasn't repeated slugs. 27072 * Avoids incosistencies with the fonts listed in the font library modal as base (unactivated). 27073 * These inconsistencies can happen when the active theme fonts in global styles aren't defined in theme.json file as when a theme style variation is applied. 27074 */ 27075 const baseThemeFonts = baseFontFamilies?.theme ? themeFonts.concat(baseFontFamilies.theme.filter(f => !themeFontsSlugs.has(f.slug)).map(f => setUIValuesNeeded(f, { 27076 source: 'theme' 27077 })).sort((a, b) => a.name.localeCompare(b.name))) : []; 27078 const customFonts = fontFamilies?.custom ? fontFamilies.custom.map(f => setUIValuesNeeded(f, { 27079 source: 'custom' 27080 })).sort((a, b) => a.name.localeCompare(b.name)) : []; 27081 const baseCustomFonts = libraryFonts ? libraryFonts.map(f => setUIValuesNeeded(f, { 27082 source: 'custom' 27083 })).sort((a, b) => a.name.localeCompare(b.name)) : []; 27084 (0,external_wp_element_namespaceObject.useEffect)(() => { 27085 if (!modalTabOpen) { 27086 setLibraryFontSelected(null); 27087 } 27088 }, [modalTabOpen]); 27089 const handleSetLibraryFontSelected = font => { 27090 setNotice(null); 27091 27092 // If font is null, reset the selected font 27093 if (!font) { 27094 setLibraryFontSelected(null); 27095 return; 27096 } 27097 const fonts = font.source === 'theme' ? themeFonts : baseCustomFonts; 27098 27099 // Tries to find the font in the installed fonts 27100 const fontSelected = fonts.find(f => f.slug === font.slug); 27101 // If the font is not found (it is only defined in custom styles), use the font from custom styles 27102 setLibraryFontSelected({ 27103 ...(fontSelected || font), 27104 source: font.source 27105 }); 27106 }; 27107 const toggleModal = tabName => { 27108 setModalTabOpen(tabName || null); 27109 }; 27110 27111 // Demo 27112 const [loadedFontUrls] = (0,external_wp_element_namespaceObject.useState)(new Set()); 27113 const getAvailableFontsOutline = availableFontFamilies => { 27114 const outline = availableFontFamilies.reduce((acc, font) => { 27115 const availableFontFaces = font?.fontFace && font.fontFace?.length > 0 ? font?.fontFace.map(face => `$face.fontStyle + face.fontWeight}`) : ['normal400']; // If the font doesn't have fontFace, we assume it is a system font and we add the defaults: normal 400 27116 27117 acc[font.slug] = availableFontFaces; 27118 return acc; 27119 }, {}); 27120 return outline; 27121 }; 27122 const getActivatedFontsOutline = source => { 27123 switch (source) { 27124 case 'theme': 27125 return getAvailableFontsOutline(themeFonts); 27126 case 'custom': 27127 default: 27128 return getAvailableFontsOutline(customFonts); 27129 } 27130 }; 27131 const isFontActivated = (slug, style, weight, source) => { 27132 if (!style && !weight) { 27133 return !!getActivatedFontsOutline(source)[slug]; 27134 } 27135 return !!getActivatedFontsOutline(source)[slug]?.includes(style + weight); 27136 }; 27137 const getFontFacesActivated = (slug, source) => { 27138 return getActivatedFontsOutline(source)[slug] || []; 27139 }; 27140 async function installFonts(fontFamiliesToInstall) { 27141 setIsInstalling(true); 27142 try { 27143 const fontFamiliesToActivate = []; 27144 let installationErrors = []; 27145 for (const fontFamilyToInstall of fontFamiliesToInstall) { 27146 let isANewFontFamily = false; 27147 27148 // Get the font family if it already exists. 27149 let installedFontFamily = await fetchGetFontFamilyBySlug(fontFamilyToInstall.slug); 27150 27151 // Otherwise create it. 27152 if (!installedFontFamily) { 27153 isANewFontFamily = true; 27154 // Prepare font family form data to install. 27155 installedFontFamily = await fetchInstallFontFamily(makeFontFamilyFormData(fontFamilyToInstall)); 27156 } 27157 27158 // Collect font faces that have already been installed (to be activated later) 27159 const alreadyInstalledFontFaces = installedFontFamily.fontFace && fontFamilyToInstall.fontFace ? installedFontFamily.fontFace.filter(fontFaceToInstall => checkFontFaceInstalled(fontFaceToInstall, fontFamilyToInstall.fontFace)) : []; 27160 27161 // Filter out Font Faces that have already been installed (so that they are not re-installed) 27162 if (installedFontFamily.fontFace && fontFamilyToInstall.fontFace) { 27163 fontFamilyToInstall.fontFace = fontFamilyToInstall.fontFace.filter(fontFaceToInstall => !checkFontFaceInstalled(fontFaceToInstall, installedFontFamily.fontFace)); 27164 } 27165 27166 // Install the fonts (upload the font files to the server and create the post in the database). 27167 let sucessfullyInstalledFontFaces = []; 27168 let unsucessfullyInstalledFontFaces = []; 27169 if (fontFamilyToInstall?.fontFace?.length > 0) { 27170 const response = await batchInstallFontFaces(installedFontFamily.id, makeFontFacesFormData(fontFamilyToInstall)); 27171 sucessfullyInstalledFontFaces = response?.successes; 27172 unsucessfullyInstalledFontFaces = response?.errors; 27173 } 27174 27175 // Use the sucessfully installed font faces 27176 // As well as any font faces that were already installed (those will be activated) 27177 if (sucessfullyInstalledFontFaces?.length > 0 || alreadyInstalledFontFaces?.length > 0) { 27178 // Use font data from REST API not from client to ensure 27179 // correct font information is used. 27180 installedFontFamily.fontFace = [...sucessfullyInstalledFontFaces]; 27181 fontFamiliesToActivate.push(installedFontFamily); 27182 } 27183 27184 // If it's a system font but was installed successfully, activate it. 27185 if (installedFontFamily && !fontFamilyToInstall?.fontFace?.length) { 27186 fontFamiliesToActivate.push(installedFontFamily); 27187 } 27188 27189 // If the font family is new and is not a system font, delete it to avoid having font families without font faces. 27190 if (isANewFontFamily && fontFamilyToInstall?.fontFace?.length > 0 && sucessfullyInstalledFontFaces?.length === 0) { 27191 await fetchUninstallFontFamily(installedFontFamily.id); 27192 } 27193 installationErrors = installationErrors.concat(unsucessfullyInstalledFontFaces); 27194 } 27195 installationErrors = installationErrors.reduce((unique, item) => unique.includes(item.message) ? unique : [...unique, item.message], []); 27196 if (fontFamiliesToActivate.length > 0) { 27197 // Activate the font family (add the font family to the global styles). 27198 const activeFonts = activateCustomFontFamilies(fontFamiliesToActivate); 27199 // Save the global styles to the database. 27200 await saveFontFamilies(activeFonts); 27201 refreshLibrary(); 27202 } 27203 if (installationErrors.length > 0) { 27204 const installError = new Error((0,external_wp_i18n_namespaceObject.__)('There was an error installing fonts.')); 27205 installError.installationErrors = installationErrors; 27206 throw installError; 27207 } 27208 } finally { 27209 setIsInstalling(false); 27210 } 27211 } 27212 async function uninstallFontFamily(fontFamilyToUninstall) { 27213 try { 27214 // Uninstall the font family. 27215 // (Removes the font files from the server and the posts from the database). 27216 const uninstalledFontFamily = await fetchUninstallFontFamily(fontFamilyToUninstall.id); 27217 27218 // Deactivate the font family if delete request is successful 27219 // (Removes the font family from the global styles). 27220 if (uninstalledFontFamily.deleted) { 27221 const activeFonts = deactivateFontFamily(fontFamilyToUninstall); 27222 // Save the global styles to the database. 27223 await saveFontFamilies(activeFonts); 27224 } 27225 27226 // Refresh the library (the library font families from database). 27227 refreshLibrary(); 27228 return uninstalledFontFamily; 27229 } catch (error) { 27230 // eslint-disable-next-line no-console 27231 console.error(`There was an error uninstalling the font family:`, error); 27232 throw error; 27233 } 27234 } 27235 const deactivateFontFamily = font => { 27236 var _fontFamilies$font$so; 27237 // If the user doesn't have custom fonts defined, include as custom fonts all the theme fonts 27238 // We want to save as active all the theme fonts at the beginning 27239 const initialCustomFonts = (_fontFamilies$font$so = fontFamilies?.[font.source]) !== null && _fontFamilies$font$so !== void 0 ? _fontFamilies$font$so : []; 27240 const newCustomFonts = initialCustomFonts.filter(f => f.slug !== font.slug); 27241 const activeFonts = { 27242 ...fontFamilies, 27243 [font.source]: newCustomFonts 27244 }; 27245 setFontFamilies(activeFonts); 27246 if (font.fontFace) { 27247 font.fontFace.forEach(face => { 27248 unloadFontFaceInBrowser(face, 'all'); 27249 }); 27250 } 27251 return activeFonts; 27252 }; 27253 const activateCustomFontFamilies = fontsToAdd => { 27254 const fontsToActivate = cleanFontsForSave(fontsToAdd); 27255 const activeFonts = { 27256 ...fontFamilies, 27257 // Merge the existing custom fonts with the new fonts. 27258 custom: mergeFontFamilies(fontFamilies?.custom, fontsToActivate) 27259 }; 27260 27261 // Activate the fonts by set the new custom fonts array. 27262 setFontFamilies(activeFonts); 27263 loadFontsInBrowser(fontsToActivate); 27264 return activeFonts; 27265 }; 27266 27267 // Removes the id from the families and faces to avoid saving that to global styles post content. 27268 const cleanFontsForSave = fonts => { 27269 return fonts.map(({ 27270 id: _familyDbId, 27271 fontFace, 27272 ...font 27273 }) => ({ 27274 ...font, 27275 ...(fontFace && fontFace.length > 0 ? { 27276 fontFace: fontFace.map(({ 27277 id: _faceDbId, 27278 ...face 27279 }) => face) 27280 } : {}) 27281 })); 27282 }; 27283 const loadFontsInBrowser = fonts => { 27284 // Add custom fonts to the browser. 27285 fonts.forEach(font => { 27286 if (font.fontFace) { 27287 font.fontFace.forEach(face => { 27288 // Load font faces just in the iframe because they already are in the document. 27289 loadFontFaceInBrowser(face, getDisplaySrcFromFontFace(face.src), 'all'); 27290 }); 27291 } 27292 }); 27293 }; 27294 const toggleActivateFont = (font, face) => { 27295 var _fontFamilies$font$so2; 27296 // If the user doesn't have custom fonts defined, include as custom fonts all the theme fonts 27297 // We want to save as active all the theme fonts at the beginning 27298 const initialFonts = (_fontFamilies$font$so2 = fontFamilies?.[font.source]) !== null && _fontFamilies$font$so2 !== void 0 ? _fontFamilies$font$so2 : []; 27299 // Toggles the received font family or font face 27300 const newFonts = toggleFont(font, face, initialFonts); 27301 // Updates the font families activated in global settings: 27302 setFontFamilies({ 27303 ...fontFamilies, 27304 [font.source]: newFonts 27305 }); 27306 const isFaceActivated = isFontActivated(font.slug, face?.fontStyle, face?.fontWeight, font.source); 27307 if (isFaceActivated) { 27308 loadFontFaceInBrowser(face, getDisplaySrcFromFontFace(face?.src), 'all'); 27309 } else { 27310 unloadFontFaceInBrowser(face, 'all'); 27311 } 27312 }; 27313 const loadFontFaceAsset = async fontFace => { 27314 // If the font doesn't have a src, don't load it. 27315 if (!fontFace.src) return; 27316 // Get the src of the font. 27317 const src = getDisplaySrcFromFontFace(fontFace.src); 27318 // If the font is already loaded, don't load it again. 27319 if (!src || loadedFontUrls.has(src)) return; 27320 // Load the font in the browser. 27321 loadFontFaceInBrowser(fontFace, src, 'document'); 27322 // Add the font to the loaded fonts list. 27323 loadedFontUrls.add(src); 27324 }; 27325 27326 // Font Collections 27327 const [collections, setFontCollections] = (0,external_wp_element_namespaceObject.useState)([]); 27328 const getFontCollections = async () => { 27329 const response = await fetchFontCollections(); 27330 setFontCollections(response); 27331 }; 27332 const getFontCollection = async slug => { 27333 try { 27334 const hasData = !!collections.find(collection => collection.slug === slug)?.font_families; 27335 if (hasData) return; 27336 const response = await fetchFontCollection(slug); 27337 const updatedCollections = collections.map(collection => collection.slug === slug ? { 27338 ...collection, 27339 ...response 27340 } : collection); 27341 setFontCollections(updatedCollections); 27342 } catch (e) { 27343 // eslint-disable-next-line no-console 27344 console.error(e); 27345 throw e; 27346 } 27347 }; 27348 (0,external_wp_element_namespaceObject.useEffect)(() => { 27349 getFontCollections(); 27350 }, []); 27351 return (0,external_React_.createElement)(FontLibraryContext.Provider, { 27352 value: { 27353 libraryFontSelected, 27354 handleSetLibraryFontSelected, 27355 fontFamilies, 27356 themeFonts, 27357 baseThemeFonts, 27358 customFonts, 27359 baseCustomFonts, 27360 isFontActivated, 27361 getFontFacesActivated, 27362 loadFontFaceAsset, 27363 installFonts, 27364 uninstallFontFamily, 27365 toggleActivateFont, 27366 getAvailableFontsOutline, 27367 modalTabOpen, 27368 toggleModal, 27369 refreshLibrary, 27370 notice, 27371 setNotice, 27372 saveFontFamilies, 27373 fontFamiliesHasChanges, 27374 isResolvingLibrary, 27375 hasResolvedLibrary, 27376 isInstalling, 27377 collections, 27378 getFontCollection 27379 } 27380 }, children); 27381 } 27382 /* harmony default export */ const context = (FontLibraryProvider); 27383 27384 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/global-styles/font-library-modal/font-demo.js 27385 27386 /** 27387 * WordPress dependencies 27388 */ 27389 27390 27391 27392 /** 27393 * Internal dependencies 27394 */ 27395 27396 27397 function getPreviewUrl(fontFace) { 27398 if (fontFace.preview) { 27399 return fontFace.preview; 27400 } 27401 if (fontFace.src) { 27402 return Array.isArray(fontFace.src) ? fontFace.src[0] : fontFace.src; 27403 } 27404 } 27405 function getDisplayFontFace(font) { 27406 // if this IS a font face return it 27407 if (font.fontStyle || font.fontWeight) { 27408 return font; 27409 } 27410 // if this is a font family with a collection of font faces 27411 // return the first one that is normal and 400 OR just the first one 27412 if (font.fontFace && font.fontFace.length) { 27413 return font.fontFace.find(face => face.fontStyle === 'normal' && face.fontWeight === '400') || font.fontFace[0]; 27414 } 27415 // This must be a font family with no font faces 27416 // return a fake font face 27417 return { 27418 fontStyle: 'normal', 27419 fontWeight: '400', 27420 fontFamily: font.fontFamily, 27421 fake: true 27422 }; 27423 } 27424 function FontDemo({ 27425 font, 27426 text 27427 }) { 27428 const ref = (0,external_wp_element_namespaceObject.useRef)(null); 27429 const fontFace = getDisplayFontFace(font); 27430 const style = getFamilyPreviewStyle(font); 27431 text = text || font.name; 27432 const customPreviewUrl = font.preview; 27433 const [isIntersecting, setIsIntersecting] = (0,external_wp_element_namespaceObject.useState)(false); 27434 const [isAssetLoaded, setIsAssetLoaded] = (0,external_wp_element_namespaceObject.useState)(false); 27435 const { 27436 loadFontFaceAsset 27437 } = (0,external_wp_element_namespaceObject.useContext)(FontLibraryContext); 27438 const previewUrl = customPreviewUrl !== null && customPreviewUrl !== void 0 ? customPreviewUrl : getPreviewUrl(fontFace); 27439 const isPreviewImage = previewUrl && previewUrl.match(/\.(png|jpg|jpeg|gif|svg)$/i); 27440 const faceStyles = getFacePreviewStyle(fontFace); 27441 const textDemoStyle = { 27442 fontSize: '18px', 27443 lineHeight: 1, 27444 opacity: isAssetLoaded ? '1' : '0', 27445 ...style, 27446 ...faceStyles 27447 }; 27448 (0,external_wp_element_namespaceObject.useEffect)(() => { 27449 const observer = new window.IntersectionObserver(([entry]) => { 27450 setIsIntersecting(entry.isIntersecting); 27451 }, {}); 27452 observer.observe(ref.current); 27453 return () => observer.disconnect(); 27454 }, [ref]); 27455 (0,external_wp_element_namespaceObject.useEffect)(() => { 27456 const loadAsset = async () => { 27457 if (isIntersecting) { 27458 if (!isPreviewImage && fontFace.src) { 27459 await loadFontFaceAsset(fontFace); 27460 } 27461 setIsAssetLoaded(true); 27462 } 27463 }; 27464 loadAsset(); 27465 }, [fontFace, isIntersecting, loadFontFaceAsset, isPreviewImage]); 27466 return (0,external_React_.createElement)("div", { 27467 ref: ref 27468 }, isPreviewImage ? (0,external_React_.createElement)("img", { 27469 src: previewUrl, 27470 loading: "lazy", 27471 alt: text, 27472 className: "font-library-modal__font-variant_demo-image" 27473 }) : (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalText, { 27474 style: textDemoStyle, 27475 className: "font-library-modal__font-variant_demo-text" 27476 }, text)); 27477 } 27478 /* harmony default export */ const font_demo = (FontDemo); 27479 27480 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/global-styles/font-library-modal/font-card.js 27481 27482 /** 27483 * WordPress dependencies 27484 */ 27485 27486 27487 27488 /** 27489 * Internal dependencies 27490 */ 27491 27492 27493 function FontCard({ 27494 font, 27495 onClick, 27496 variantsText, 27497 navigatorPath 27498 }) { 27499 const variantsCount = font.fontFace?.length || 1; 27500 const style = { 27501 cursor: !!onClick ? 'pointer' : 'default' 27502 }; 27503 const navigator = (0,external_wp_components_namespaceObject.__experimentalUseNavigator)(); 27504 return (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 27505 onClick: () => { 27506 onClick(); 27507 if (navigatorPath) { 27508 navigator.goTo(navigatorPath); 27509 } 27510 }, 27511 style: style, 27512 className: "font-library-modal__font-card" 27513 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.Flex, { 27514 justify: "space-between", 27515 wrap: false 27516 }, (0,external_React_.createElement)(font_demo, { 27517 font: font 27518 }), (0,external_React_.createElement)(external_wp_components_namespaceObject.Flex, { 27519 justify: "flex-end" 27520 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.FlexItem, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalText, { 27521 className: "font-library-modal__font-card__count" 27522 }, variantsText || (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %d: Number of font variants. */ 27523 (0,external_wp_i18n_namespaceObject._n)('%d variant', '%d variants', variantsCount), variantsCount))), (0,external_React_.createElement)(external_wp_components_namespaceObject.FlexItem, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.Icon, { 27524 icon: chevron_right 27525 }))))); 27526 } 27527 /* harmony default export */ const font_card = (FontCard); 27528 27529 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/global-styles/font-library-modal/library-font-variant.js 27530 27531 /** 27532 * WordPress dependencies 27533 */ 27534 27535 27536 27537 /** 27538 * Internal dependencies 27539 */ 27540 27541 27542 27543 27544 function LibraryFontVariant({ 27545 face, 27546 font 27547 }) { 27548 const { 27549 isFontActivated, 27550 toggleActivateFont 27551 } = (0,external_wp_element_namespaceObject.useContext)(FontLibraryContext); 27552 const isInstalled = font?.fontFace?.length > 0 ? isFontActivated(font.slug, face.fontStyle, face.fontWeight, font.source) : isFontActivated(font.slug, null, null, font.source); 27553 const handleToggleActivation = () => { 27554 if (font?.fontFace?.length > 0) { 27555 toggleActivateFont(font, face); 27556 return; 27557 } 27558 toggleActivateFont(font); 27559 }; 27560 const displayName = font.name + ' ' + getFontFaceVariantName(face); 27561 const { 27562 kebabCase 27563 } = unlock(external_wp_components_namespaceObject.privateApis); 27564 const checkboxId = kebabCase(`$font.slug}-$getFontFaceVariantName(face)}`); 27565 return (0,external_React_.createElement)("div", { 27566 className: "font-library-modal__font-card" 27567 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.Flex, { 27568 justify: "flex-start", 27569 align: "center", 27570 gap: "1rem" 27571 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.CheckboxControl, { 27572 checked: isInstalled, 27573 onChange: handleToggleActivation, 27574 __nextHasNoMarginBottom: true, 27575 id: checkboxId 27576 }), (0,external_React_.createElement)("label", { 27577 htmlFor: checkboxId 27578 }, (0,external_React_.createElement)(font_demo, { 27579 font: face, 27580 text: displayName, 27581 onClick: handleToggleActivation 27582 })))); 27583 } 27584 /* harmony default export */ const library_font_variant = (LibraryFontVariant); 27585 27586 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/global-styles/font-library-modal/utils/sort-font-faces.js 27587 function getNumericFontWeight(value) { 27588 switch (value) { 27589 case 'normal': 27590 return 400; 27591 case 'bold': 27592 return 700; 27593 case 'bolder': 27594 return 500; 27595 case 'lighter': 27596 return 300; 27597 default: 27598 return parseInt(value, 10); 27599 } 27600 } 27601 function sortFontFaces(faces) { 27602 return faces.sort((a, b) => { 27603 // Ensure 'normal' fontStyle is always first 27604 if (a.fontStyle === 'normal' && b.fontStyle !== 'normal') return -1; 27605 if (b.fontStyle === 'normal' && a.fontStyle !== 'normal') return 1; 27606 27607 // If both fontStyles are the same, sort by fontWeight 27608 if (a.fontStyle === b.fontStyle) { 27609 return getNumericFontWeight(a.fontWeight) - getNumericFontWeight(b.fontWeight); 27610 } 27611 27612 // Sort other fontStyles alphabetically 27613 return a.fontStyle.localeCompare(b.fontStyle); 27614 }); 27615 } 27616 27617 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/global-styles/font-library-modal/installed-fonts.js 27618 27619 /** 27620 * WordPress dependencies 27621 */ 27622 27623 27624 27625 27626 27627 27628 27629 /** 27630 * Internal dependencies 27631 */ 27632 27633 27634 27635 27636 27637 const { 27638 ProgressBar 27639 } = unlock(external_wp_components_namespaceObject.privateApis); 27640 function InstalledFonts() { 27641 const { 27642 baseCustomFonts, 27643 libraryFontSelected, 27644 baseThemeFonts, 27645 handleSetLibraryFontSelected, 27646 refreshLibrary, 27647 uninstallFontFamily, 27648 isResolvingLibrary, 27649 isInstalling, 27650 saveFontFamilies, 27651 getFontFacesActivated, 27652 fontFamiliesHasChanges, 27653 notice, 27654 setNotice, 27655 fontFamilies 27656 } = (0,external_wp_element_namespaceObject.useContext)(FontLibraryContext); 27657 const [isConfirmDeleteOpen, setIsConfirmDeleteOpen] = (0,external_wp_element_namespaceObject.useState)(false); 27658 const customFontFamilyId = libraryFontSelected?.source === 'custom' && libraryFontSelected?.id; 27659 const canUserDelete = (0,external_wp_data_namespaceObject.useSelect)(select => { 27660 const { 27661 canUser 27662 } = select(external_wp_coreData_namespaceObject.store); 27663 return customFontFamilyId && canUser('delete', 'font-families', customFontFamilyId); 27664 }, [customFontFamilyId]); 27665 const shouldDisplayDeleteButton = !!libraryFontSelected && libraryFontSelected?.source !== 'theme' && canUserDelete; 27666 const handleUninstallClick = () => { 27667 setIsConfirmDeleteOpen(true); 27668 }; 27669 const getFontFacesToDisplay = font => { 27670 if (!font) { 27671 return []; 27672 } 27673 if (!font.fontFace || !font.fontFace.length) { 27674 return [{ 27675 fontFamily: font.fontFamily, 27676 fontStyle: 'normal', 27677 fontWeight: '400' 27678 }]; 27679 } 27680 return sortFontFaces(font.fontFace); 27681 }; 27682 const getFontCardVariantsText = font => { 27683 const variantsInstalled = font?.fontFace?.length > 0 ? font.fontFace.length : 1; 27684 const variantsActive = getFontFacesActivated(font.slug, font.source).length; 27685 return (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: 1: Active font variants, 2: Total font variants. */ 27686 (0,external_wp_i18n_namespaceObject.__)('%1$s/%2$s variants active'), variantsActive, variantsInstalled); 27687 }; 27688 (0,external_wp_element_namespaceObject.useEffect)(() => { 27689 handleSetLibraryFontSelected(libraryFontSelected); 27690 refreshLibrary(); 27691 }, []); 27692 return (0,external_React_.createElement)("div", { 27693 className: "font-library-modal__tabpanel-layout" 27694 }, isResolvingLibrary && (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { 27695 align: "center" 27696 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalSpacer, null), (0,external_React_.createElement)(external_wp_components_namespaceObject.Spinner, null), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalSpacer, null)), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalNavigatorProvider, { 27697 initialPath: libraryFontSelected ? '/fontFamily' : '/' 27698 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalNavigatorScreen, { 27699 path: "/" 27700 }, notice && (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalSpacer, { 27701 margin: 1 27702 }), (0,external_React_.createElement)(external_wp_components_namespaceObject.Notice, { 27703 status: notice.type, 27704 onRemove: () => setNotice(null) 27705 }, notice.message), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalSpacer, { 27706 margin: 1 27707 })), baseCustomFonts.length > 0 && (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalText, { 27708 className: "font-library-modal__subtitle" 27709 }, (0,external_wp_i18n_namespaceObject.__)('Installed Fonts')), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalSpacer, { 27710 margin: 2 27711 }), baseCustomFonts.map(font => (0,external_React_.createElement)(font_card, { 27712 font: font, 27713 key: font.slug, 27714 navigatorPath: '/fontFamily', 27715 variantsText: getFontCardVariantsText(font), 27716 onClick: () => { 27717 handleSetLibraryFontSelected(font); 27718 } 27719 })), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalSpacer, { 27720 margin: 8 27721 })), baseThemeFonts.length > 0 && (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalText, { 27722 className: "font-library-modal__subtitle" 27723 }, (0,external_wp_i18n_namespaceObject.__)('Theme Fonts')), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalSpacer, { 27724 margin: 2 27725 }), baseThemeFonts.map(font => (0,external_React_.createElement)(font_card, { 27726 font: font, 27727 key: font.slug, 27728 navigatorPath: '/fontFamily', 27729 variantsText: getFontCardVariantsText(font), 27730 onClick: () => { 27731 handleSetLibraryFontSelected(font); 27732 } 27733 }))), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalSpacer, { 27734 margin: 16 27735 })), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalNavigatorScreen, { 27736 path: "/fontFamily" 27737 }, (0,external_React_.createElement)(ConfirmDeleteDialog, { 27738 font: libraryFontSelected, 27739 isOpen: isConfirmDeleteOpen, 27740 setIsOpen: setIsConfirmDeleteOpen, 27741 setNotice: setNotice, 27742 uninstallFontFamily: uninstallFontFamily, 27743 handleSetLibraryFontSelected: handleSetLibraryFontSelected 27744 }), (0,external_React_.createElement)(external_wp_components_namespaceObject.Flex, { 27745 justify: "flex-start" 27746 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalNavigatorToParentButton, { 27747 icon: chevron_left, 27748 isSmall: true, 27749 onClick: () => { 27750 handleSetLibraryFontSelected(null); 27751 }, 27752 "aria-label": (0,external_wp_i18n_namespaceObject.__)('Navigate to the previous view') 27753 }), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHeading, { 27754 level: 2, 27755 size: 13, 27756 className: "edit-site-global-styles-header" 27757 }, libraryFontSelected?.name)), notice && (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalSpacer, { 27758 margin: 1 27759 }), (0,external_React_.createElement)(external_wp_components_namespaceObject.Notice, { 27760 status: notice.type, 27761 onRemove: () => setNotice(null) 27762 }, notice.message), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalSpacer, { 27763 margin: 1 27764 })), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalSpacer, { 27765 margin: 4 27766 }), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalText, null, (0,external_wp_i18n_namespaceObject.__)('Choose font variants. Keep in mind that too many variants could make your site slower.')), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalSpacer, { 27767 margin: 4 27768 }), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { 27769 spacing: 0 27770 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalSpacer, { 27771 margin: 8 27772 }), getFontFacesToDisplay(libraryFontSelected).map((face, i) => (0,external_React_.createElement)(library_font_variant, { 27773 font: libraryFontSelected, 27774 face: face, 27775 key: `face$i}` 27776 }))))), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { 27777 justify: "flex-end", 27778 className: "font-library-modal__tabpanel-layout__footer" 27779 }, isInstalling && (0,external_React_.createElement)(ProgressBar, null), shouldDisplayDeleteButton && (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 27780 isDestructive: true, 27781 variant: "tertiary", 27782 onClick: handleUninstallClick 27783 }, (0,external_wp_i18n_namespaceObject.__)('Delete')), (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 27784 variant: "primary", 27785 onClick: () => { 27786 saveFontFamilies(fontFamilies); 27787 }, 27788 disabled: !fontFamiliesHasChanges, 27789 __experimentalIsFocusable: true 27790 }, (0,external_wp_i18n_namespaceObject.__)('Update')))); 27791 } 27792 function ConfirmDeleteDialog({ 27793 font, 27794 isOpen, 27795 setIsOpen, 27796 setNotice, 27797 uninstallFontFamily, 27798 handleSetLibraryFontSelected 27799 }) { 27800 const navigator = (0,external_wp_components_namespaceObject.__experimentalUseNavigator)(); 27801 const handleConfirmUninstall = async () => { 27802 setNotice(null); 27803 setIsOpen(false); 27804 try { 27805 await uninstallFontFamily(font); 27806 navigator.goBack(); 27807 handleSetLibraryFontSelected(null); 27808 setNotice({ 27809 type: 'success', 27810 message: (0,external_wp_i18n_namespaceObject.__)('Font family uninstalled successfully.') 27811 }); 27812 } catch (error) { 27813 setNotice({ 27814 type: 'error', 27815 message: (0,external_wp_i18n_namespaceObject.__)('There was an error uninstalling the font family. ') + error.message 27816 }); 27817 } 27818 }; 27819 const handleCancelUninstall = () => { 27820 setIsOpen(false); 27821 }; 27822 return (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalConfirmDialog, { 27823 isOpen: isOpen, 27824 cancelButtonText: (0,external_wp_i18n_namespaceObject.__)('Cancel'), 27825 confirmButtonText: (0,external_wp_i18n_namespaceObject.__)('Delete'), 27826 onCancel: handleCancelUninstall, 27827 onConfirm: handleConfirmUninstall 27828 }, font && (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: Name of the font. */ 27829 (0,external_wp_i18n_namespaceObject.__)('Are you sure you want to delete "%s" font and all its variants and assets?'), font.name)); 27830 } 27831 /* harmony default export */ const installed_fonts = (InstalledFonts); 27832 27833 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/global-styles/font-library-modal/utils/filter-fonts.js 27834 /** 27835 * Filters a list of fonts based on the specified filters. 27836 * 27837 * This function filters a given array of fonts based on the criteria provided in the filters object. 27838 * It supports filtering by category and a search term. If the category is provided and not equal to 'all', 27839 * the function filters the fonts array to include only those fonts that belong to the specified category. 27840 * Additionally, if a search term is provided, it filters the fonts array to include only those fonts 27841 * whose name includes the search term, case-insensitively. 27842 * 27843 * @param {Array} fonts Array of font objects in font-collection schema fashion to be filtered. Each font object should have a 'categories' property and a 'font_family_settings' property with a 'name' key. 27844 * @param {Object} filters Object containing the filter criteria. It should have a 'category' key and/or a 'search' key. 27845 * The 'category' key is a string representing the category to filter by. 27846 * The 'search' key is a string representing the search term to filter by. 27847 * @return {Array} Array of filtered font objects based on the provided criteria. 27848 */ 27849 function filterFonts(fonts, filters) { 27850 const { 27851 category, 27852 search 27853 } = filters; 27854 let filteredFonts = fonts || []; 27855 if (category && category !== 'all') { 27856 filteredFonts = filteredFonts.filter(font => font.categories.indexOf(category) !== -1); 27857 } 27858 if (search) { 27859 filteredFonts = filteredFonts.filter(font => font.font_family_settings.name.toLowerCase().includes(search.toLowerCase())); 27860 } 27861 return filteredFonts; 27862 } 27863 27864 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/global-styles/font-library-modal/utils/fonts-outline.js 27865 function getFontsOutline(fonts) { 27866 return fonts.reduce((acc, font) => ({ 27867 ...acc, 27868 [font.slug]: (font?.fontFace || []).reduce((faces, face) => ({ 27869 ...faces, 27870 [`$face.fontStyle}-$face.fontWeight}`]: true 27871 }), {}) 27872 }), {}); 27873 } 27874 function isFontFontFaceInOutline(slug, face, outline) { 27875 if (!face) { 27876 return !!outline[slug]; 27877 } 27878 return !!outline[slug]?.[`$face.fontStyle}-$face.fontWeight}`]; 27879 } 27880 27881 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/global-styles/font-library-modal/google-fonts-confirm-dialog.js 27882 27883 /** 27884 * WordPress dependencies 27885 */ 27886 27887 27888 function GoogleFontsConfirmDialog() { 27889 const handleConfirm = () => { 27890 // eslint-disable-next-line no-undef 27891 window.localStorage.setItem('wp-font-library-google-fonts-permission', 'true'); 27892 window.dispatchEvent(new Event('storage')); 27893 }; 27894 return (0,external_React_.createElement)("div", { 27895 className: "font-library__google-fonts-confirm" 27896 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.Card, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.CardBody, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalText, { 27897 as: "h3" 27898 }, (0,external_wp_i18n_namespaceObject.__)('Connect to Google Fonts')), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalSpacer, { 27899 margin: 6 27900 }), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalText, { 27901 as: "p" 27902 }, (0,external_wp_i18n_namespaceObject.__)('To install fonts from Google you must give permission to connect directly to Google servers. The fonts you install will be downloaded from Google and stored on your site. Your site will then use these locally-hosted fonts.')), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalSpacer, { 27903 margin: 3 27904 }), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalText, { 27905 as: "p" 27906 }, (0,external_wp_i18n_namespaceObject.__)('You can alternatively upload files directly on the Upload tab.')), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalSpacer, { 27907 margin: 6 27908 }), (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 27909 variant: "primary", 27910 onClick: handleConfirm 27911 }, (0,external_wp_i18n_namespaceObject.__)('Allow access to Google Fonts'))))); 27912 } 27913 /* harmony default export */ const google_fonts_confirm_dialog = (GoogleFontsConfirmDialog); 27914 27915 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/global-styles/font-library-modal/collection-font-variant.js 27916 27917 /** 27918 * WordPress dependencies 27919 */ 27920 27921 27922 /** 27923 * Internal dependencies 27924 */ 27925 27926 27927 27928 function CollectionFontVariant({ 27929 face, 27930 font, 27931 handleToggleVariant, 27932 selected 27933 }) { 27934 const handleToggleActivation = () => { 27935 if (font?.fontFace) { 27936 handleToggleVariant(font, face); 27937 return; 27938 } 27939 handleToggleVariant(font); 27940 }; 27941 const displayName = font.name + ' ' + getFontFaceVariantName(face); 27942 const { 27943 kebabCase 27944 } = unlock(external_wp_components_namespaceObject.privateApis); 27945 const checkboxId = kebabCase(`$font.slug}-$getFontFaceVariantName(face)}`); 27946 return (0,external_React_.createElement)("div", { 27947 className: "font-library-modal__font-card" 27948 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.Flex, { 27949 justify: "flex-start", 27950 align: "center", 27951 gap: "1rem" 27952 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.CheckboxControl, { 27953 checked: selected, 27954 onChange: handleToggleActivation, 27955 __nextHasNoMarginBottom: true, 27956 id: checkboxId 27957 }), (0,external_React_.createElement)("label", { 27958 htmlFor: checkboxId 27959 }, (0,external_React_.createElement)(font_demo, { 27960 font: face, 27961 text: displayName, 27962 onClick: handleToggleActivation 27963 })))); 27964 } 27965 /* harmony default export */ const collection_font_variant = (CollectionFontVariant); 27966 27967 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/global-styles/font-library-modal/font-collection.js 27968 27969 /** 27970 * WordPress dependencies 27971 */ 27972 27973 27974 27975 27976 27977 27978 /** 27979 * Internal dependencies 27980 */ 27981 27982 27983 27984 27985 27986 27987 27988 27989 27990 const DEFAULT_CATEGORY = { 27991 slug: 'all', 27992 name: (0,external_wp_i18n_namespaceObject._x)('All', 'font categories') 27993 }; 27994 const LOCAL_STORAGE_ITEM = 'wp-font-library-google-fonts-permission'; 27995 const MIN_WINDOW_HEIGHT = 500; 27996 function FontCollection({ 27997 slug 27998 }) { 27999 var _selectedCollection$c; 28000 const requiresPermission = slug === 'google-fonts'; 28001 const getGoogleFontsPermissionFromStorage = () => { 28002 return window.localStorage.getItem(LOCAL_STORAGE_ITEM) === 'true'; 28003 }; 28004 const [selectedFont, setSelectedFont] = (0,external_wp_element_namespaceObject.useState)(null); 28005 const [fontsToInstall, setFontsToInstall] = (0,external_wp_element_namespaceObject.useState)([]); 28006 const [page, setPage] = (0,external_wp_element_namespaceObject.useState)(1); 28007 const [filters, setFilters] = (0,external_wp_element_namespaceObject.useState)({}); 28008 const [renderConfirmDialog, setRenderConfirmDialog] = (0,external_wp_element_namespaceObject.useState)(requiresPermission && !getGoogleFontsPermissionFromStorage()); 28009 const { 28010 collections, 28011 getFontCollection, 28012 installFonts, 28013 isInstalling, 28014 notice, 28015 setNotice 28016 } = (0,external_wp_element_namespaceObject.useContext)(FontLibraryContext); 28017 const selectedCollection = collections.find(collection => collection.slug === slug); 28018 (0,external_wp_element_namespaceObject.useEffect)(() => { 28019 const handleStorage = () => { 28020 setRenderConfirmDialog(requiresPermission && !getGoogleFontsPermissionFromStorage()); 28021 }; 28022 handleStorage(); 28023 window.addEventListener('storage', handleStorage); 28024 return () => window.removeEventListener('storage', handleStorage); 28025 }, [slug, requiresPermission]); 28026 const revokeAccess = () => { 28027 window.localStorage.setItem(LOCAL_STORAGE_ITEM, 'false'); 28028 window.dispatchEvent(new Event('storage')); 28029 }; 28030 (0,external_wp_element_namespaceObject.useEffect)(() => { 28031 const fetchFontCollection = async () => { 28032 try { 28033 await getFontCollection(slug); 28034 resetFilters(); 28035 } catch (e) { 28036 if (!notice) { 28037 setNotice({ 28038 type: 'error', 28039 message: e?.message 28040 }); 28041 } 28042 } 28043 }; 28044 fetchFontCollection(); 28045 }, [slug, getFontCollection, setNotice, notice]); 28046 (0,external_wp_element_namespaceObject.useEffect)(() => { 28047 setSelectedFont(null); 28048 setNotice(null); 28049 }, [slug, setNotice]); 28050 (0,external_wp_element_namespaceObject.useEffect)(() => { 28051 // If the selected fonts change, reset the selected fonts to install 28052 setFontsToInstall([]); 28053 }, [selectedFont]); 28054 const collectionFonts = (0,external_wp_element_namespaceObject.useMemo)(() => { 28055 var _selectedCollection$f; 28056 return (_selectedCollection$f = selectedCollection?.font_families) !== null && _selectedCollection$f !== void 0 ? _selectedCollection$f : []; 28057 }, [selectedCollection]); 28058 const collectionCategories = (_selectedCollection$c = selectedCollection?.categories) !== null && _selectedCollection$c !== void 0 ? _selectedCollection$c : []; 28059 const categories = [DEFAULT_CATEGORY, ...collectionCategories]; 28060 const fonts = (0,external_wp_element_namespaceObject.useMemo)(() => filterFonts(collectionFonts, filters), [collectionFonts, filters]); 28061 28062 // NOTE: The height of the font library modal unavailable to use for rendering font family items is roughly 417px 28063 // The height of each font family item is 61px. 28064 const windowHeight = Math.max(window.innerHeight, MIN_WINDOW_HEIGHT); 28065 const pageSize = Math.floor((windowHeight - 417) / 61); 28066 const totalPages = Math.ceil(fonts.length / pageSize); 28067 const itemsStart = (page - 1) * pageSize; 28068 const itemsLimit = page * pageSize; 28069 const items = fonts.slice(itemsStart, itemsLimit); 28070 const handleCategoryFilter = category => { 28071 setFilters({ 28072 ...filters, 28073 category 28074 }); 28075 setPage(1); 28076 }; 28077 const handleUpdateSearchInput = value => { 28078 setFilters({ 28079 ...filters, 28080 search: value 28081 }); 28082 setPage(1); 28083 }; 28084 const debouncedUpdateSearchInput = (0,external_wp_compose_namespaceObject.debounce)(handleUpdateSearchInput, 300); 28085 const resetFilters = () => { 28086 setFilters({}); 28087 setPage(1); 28088 }; 28089 const resetSearch = () => { 28090 setFilters({ 28091 ...filters, 28092 search: '' 28093 }); 28094 setPage(1); 28095 }; 28096 const handleToggleVariant = (font, face) => { 28097 const newFontsToInstall = toggleFont(font, face, fontsToInstall); 28098 setFontsToInstall(newFontsToInstall); 28099 }; 28100 const fontToInstallOutline = getFontsOutline(fontsToInstall); 28101 const resetFontsToInstall = () => { 28102 setFontsToInstall([]); 28103 }; 28104 const handleInstall = async () => { 28105 setNotice(null); 28106 const fontFamily = fontsToInstall[0]; 28107 try { 28108 if (fontFamily?.fontFace) { 28109 await Promise.all(fontFamily.fontFace.map(async fontFace => { 28110 if (fontFace.src) { 28111 fontFace.file = await downloadFontFaceAssets(fontFace.src); 28112 } 28113 })); 28114 } 28115 } catch (error) { 28116 // If any of the fonts fail to download, 28117 // show an error notice and stop the request from being sent. 28118 setNotice({ 28119 type: 'error', 28120 message: (0,external_wp_i18n_namespaceObject.__)('Error installing the fonts, could not be downloaded.') 28121 }); 28122 return; 28123 } 28124 try { 28125 await installFonts([fontFamily]); 28126 setNotice({ 28127 type: 'success', 28128 message: (0,external_wp_i18n_namespaceObject.__)('Fonts were installed successfully.') 28129 }); 28130 } catch (error) { 28131 setNotice({ 28132 type: 'error', 28133 message: error.message 28134 }); 28135 } 28136 resetFontsToInstall(); 28137 }; 28138 const getSortedFontFaces = fontFamily => { 28139 if (!fontFamily) { 28140 return []; 28141 } 28142 if (!fontFamily.fontFace || !fontFamily.fontFace.length) { 28143 return [{ 28144 fontFamily: fontFamily.fontFamily, 28145 fontStyle: 'normal', 28146 fontWeight: '400' 28147 }]; 28148 } 28149 return sortFontFaces(fontFamily.fontFace); 28150 }; 28151 if (renderConfirmDialog) { 28152 return (0,external_React_.createElement)(google_fonts_confirm_dialog, null); 28153 } 28154 const ActionsComponent = () => { 28155 if (slug !== 'google-fonts' || renderConfirmDialog || selectedFont) { 28156 return null; 28157 } 28158 return (0,external_React_.createElement)(external_wp_components_namespaceObject.DropdownMenu, { 28159 icon: more_vertical, 28160 label: (0,external_wp_i18n_namespaceObject.__)('Actions'), 28161 popoverProps: { 28162 position: 'bottom left' 28163 }, 28164 controls: [{ 28165 title: (0,external_wp_i18n_namespaceObject.__)('Revoke access to Google Fonts'), 28166 onClick: revokeAccess 28167 }] 28168 }); 28169 }; 28170 return (0,external_React_.createElement)("div", { 28171 className: "font-library-modal__tabpanel-layout" 28172 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalNavigatorProvider, { 28173 initialPath: "/", 28174 className: "font-library-modal__tabpanel-layout" 28175 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalNavigatorScreen, { 28176 path: "/" 28177 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { 28178 justify: "space-between" 28179 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalVStack, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHeading, { 28180 level: 2, 28181 size: 13 28182 }, selectedCollection.name), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalText, null, selectedCollection.description)), (0,external_React_.createElement)(ActionsComponent, null)), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalSpacer, { 28183 margin: 4 28184 }), (0,external_React_.createElement)(external_wp_components_namespaceObject.Flex, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.FlexItem, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalInputControl, { 28185 value: filters.search, 28186 placeholder: (0,external_wp_i18n_namespaceObject.__)('Font name…'), 28187 label: (0,external_wp_i18n_namespaceObject.__)('Search'), 28188 onChange: debouncedUpdateSearchInput, 28189 prefix: (0,external_React_.createElement)(external_wp_components_namespaceObject.Icon, { 28190 icon: library_search 28191 }), 28192 suffix: filters?.search ? (0,external_React_.createElement)(external_wp_components_namespaceObject.Icon, { 28193 icon: close_small, 28194 onClick: resetSearch 28195 }) : null 28196 })), (0,external_React_.createElement)(external_wp_components_namespaceObject.FlexItem, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.SelectControl, { 28197 label: (0,external_wp_i18n_namespaceObject.__)('Category'), 28198 value: filters.category, 28199 onChange: handleCategoryFilter 28200 }, categories && categories.map(category => (0,external_React_.createElement)("option", { 28201 value: category.slug, 28202 key: category.slug 28203 }, category.name))))), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalSpacer, { 28204 margin: 4 28205 }), !selectedCollection?.font_families && !notice && (0,external_React_.createElement)(external_wp_components_namespaceObject.Spinner, null), !!selectedCollection?.font_families?.length && !fonts.length && (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalText, null, (0,external_wp_i18n_namespaceObject.__)('No fonts found. Try with a different search term')), (0,external_React_.createElement)("div", { 28206 className: "font-library-modal__fonts-grid__main" 28207 }, items.map(font => (0,external_React_.createElement)(font_card, { 28208 key: font.font_family_settings.slug, 28209 font: font.font_family_settings, 28210 navigatorPath: '/fontFamily', 28211 onClick: () => { 28212 setSelectedFont(font.font_family_settings); 28213 } 28214 })))), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalNavigatorScreen, { 28215 path: "/fontFamily" 28216 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.Flex, { 28217 justify: "flex-start" 28218 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalNavigatorToParentButton, { 28219 icon: chevron_left, 28220 isSmall: true, 28221 onClick: () => { 28222 setSelectedFont(null); 28223 setNotice(null); 28224 }, 28225 "aria-label": (0,external_wp_i18n_namespaceObject.__)('Navigate to the previous view') 28226 }), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHeading, { 28227 level: 2, 28228 size: 13, 28229 className: "edit-site-global-styles-header" 28230 }, selectedFont?.name)), notice && (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalSpacer, { 28231 margin: 1 28232 }), (0,external_React_.createElement)(external_wp_components_namespaceObject.Notice, { 28233 status: notice.type, 28234 onRemove: () => setNotice(null) 28235 }, notice.message), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalSpacer, { 28236 margin: 1 28237 })), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalSpacer, { 28238 margin: 4 28239 }), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalText, null, " ", (0,external_wp_i18n_namespaceObject.__)('Select font variants to install.'), " "), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalSpacer, { 28240 margin: 4 28241 }), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { 28242 spacing: 0 28243 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalSpacer, { 28244 margin: 8 28245 }), getSortedFontFaces(selectedFont).map((face, i) => (0,external_React_.createElement)(collection_font_variant, { 28246 font: selectedFont, 28247 face: face, 28248 key: `face$i}`, 28249 handleToggleVariant: handleToggleVariant, 28250 selected: isFontFontFaceInOutline(selectedFont.slug, selectedFont.fontFace ? face : null, 28251 // If the font has no fontFace, we want to check if the font is in the outline 28252 fontToInstallOutline) 28253 }))), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalSpacer, { 28254 margin: 16 28255 }))), selectedFont && (0,external_React_.createElement)(external_wp_components_namespaceObject.Flex, { 28256 justify: "flex-end", 28257 className: "font-library-modal__tabpanel-layout__footer" 28258 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 28259 variant: "primary", 28260 onClick: handleInstall, 28261 isBusy: isInstalling, 28262 disabled: fontsToInstall.length === 0 || isInstalling, 28263 __experimentalIsFocusable: true 28264 }, (0,external_wp_i18n_namespaceObject.__)('Install'))), !selectedFont && (0,external_React_.createElement)(external_wp_components_namespaceObject.Flex, { 28265 justify: "center", 28266 className: "font-library-modal__tabpanel-layout__footer" 28267 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 28268 label: (0,external_wp_i18n_namespaceObject.__)('First page'), 28269 size: "compact", 28270 onClick: () => setPage(1), 28271 disabled: page === 1, 28272 __experimentalIsFocusable: true 28273 }, (0,external_React_.createElement)("span", null, "\xAB")), (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 28274 label: (0,external_wp_i18n_namespaceObject.__)('Previous page'), 28275 size: "compact", 28276 onClick: () => setPage(page - 1), 28277 disabled: page === 1, 28278 __experimentalIsFocusable: true 28279 }, (0,external_React_.createElement)("span", null, "\u2039")), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { 28280 justify: "flex-start", 28281 expanded: false, 28282 spacing: 2 28283 }, (0,external_wp_element_namespaceObject.createInterpolateElement)((0,external_wp_i18n_namespaceObject.sprintf)( 28284 // translators: %s: Total number of pages. 28285 (0,external_wp_i18n_namespaceObject._x)('Page <CurrentPageControl /> of %s', 'paging'), totalPages), { 28286 CurrentPageControl: (0,external_React_.createElement)(external_wp_components_namespaceObject.SelectControl, { 28287 "aria-label": (0,external_wp_i18n_namespaceObject.__)('Current page'), 28288 value: page, 28289 options: [...Array(totalPages)].map((e, i) => { 28290 return { 28291 label: i + 1, 28292 value: i + 1 28293 }; 28294 }), 28295 onChange: newPage => setPage(parseInt(newPage)), 28296 size: 'compact', 28297 __nextHasNoMarginBottom: true 28298 }) 28299 })), (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 28300 label: (0,external_wp_i18n_namespaceObject.__)('Next page'), 28301 size: "compact", 28302 onClick: () => setPage(page + 1), 28303 disabled: page === totalPages, 28304 __experimentalIsFocusable: true 28305 }, (0,external_React_.createElement)("span", null, "\u203A")), (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 28306 label: (0,external_wp_i18n_namespaceObject.__)('Last page'), 28307 size: "compact", 28308 onClick: () => setPage(totalPages), 28309 disabled: page === totalPages, 28310 __experimentalIsFocusable: true 28311 }, (0,external_React_.createElement)("span", null, "\xBB")))); 28312 } 28313 /* harmony default export */ const font_collection = (FontCollection); 28314 28315 // EXTERNAL MODULE: ./node_modules/@wordpress/edit-site/lib/unbrotli.js 28316 var unbrotli = __webpack_require__(8572); 28317 var unbrotli_default = /*#__PURE__*/__webpack_require__.n(unbrotli); 28318 // EXTERNAL MODULE: ./node_modules/@wordpress/edit-site/lib/inflate.js 28319 var inflate = __webpack_require__(4660); 28320 var inflate_default = /*#__PURE__*/__webpack_require__.n(inflate); 28321 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/lib/lib-font.browser.js 28322 /* eslint eslint-comments/no-unlimited-disable: 0 */ 28323 /* eslint-disable */ 28324 // import pako from 'pako'; 28325 28326 28327 28328 let fetchFunction = globalThis.fetch; 28329 // if ( ! fetchFunction ) { 28330 // let backlog = []; 28331 // fetchFunction = globalThis.fetch = ( ...args ) => 28332 // new Promise( ( resolve, reject ) => { 28333 // backlog.push( { args: args, resolve: resolve, reject: reject } ); 28334 // } ); 28335 // import( 'fs' ) 28336 // .then( ( fs ) => { 28337 // fetchFunction = globalThis.fetch = async function ( path ) { 28338 // return new Promise( ( resolve, reject ) => { 28339 // fs.readFile( path, ( err, data ) => { 28340 // if ( err ) return reject( err ); 28341 // resolve( { ok: true, arrayBuffer: () => data.buffer } ); 28342 // } ); 28343 // } ); 28344 // }; 28345 // while ( backlog.length ) { 28346 // let instruction = backlog.shift(); 28347 // fetchFunction( ...instruction.args ) 28348 // .then( ( data ) => instruction.resolve( data ) ) 28349 // .catch( ( err ) => instruction.reject( err ) ); 28350 // } 28351 // } ) 28352 // .catch( ( err ) => { 28353 // console.error( err ); 28354 // throw new Error( 28355 // `lib-font cannot run unless either the Fetch API or Node's filesystem module is available.` 28356 // ); 28357 // } ); 28358 // } 28359 class lib_font_browser_Event { 28360 constructor( type, detail = {}, msg ) { 28361 this.type = type; 28362 this.detail = detail; 28363 this.msg = msg; 28364 Object.defineProperty( this, `__mayPropagate`, { 28365 enumerable: false, 28366 writable: true, 28367 } ); 28368 this.__mayPropagate = true; 28369 } 28370 preventDefault() {} 28371 stopPropagation() { 28372 this.__mayPropagate = false; 28373 } 28374 valueOf() { 28375 return this; 28376 } 28377 toString() { 28378 return this.msg 28379 ? `[${ this.type } event]: ${ this.msg }` 28380 : `[${ this.type } event]`; 28381 } 28382 } 28383 class EventManager { 28384 constructor() { 28385 this.listeners = {}; 28386 } 28387 addEventListener( type, listener, useCapture ) { 28388 let bin = this.listeners[ type ] || []; 28389 if ( useCapture ) bin.unshift( listener ); 28390 else bin.push( listener ); 28391 this.listeners[ type ] = bin; 28392 } 28393 removeEventListener( type, listener ) { 28394 let bin = this.listeners[ type ] || []; 28395 let pos = bin.findIndex( ( e ) => e === listener ); 28396 if ( pos > -1 ) { 28397 bin.splice( pos, 1 ); 28398 this.listeners[ type ] = bin; 28399 } 28400 } 28401 dispatch( event ) { 28402 let bin = this.listeners[ event.type ]; 28403 if ( bin ) { 28404 for ( let l = 0, e = bin.length; l < e; l++ ) { 28405 if ( ! event.__mayPropagate ) break; 28406 bin[ l ]( event ); 28407 } 28408 } 28409 } 28410 } 28411 const startDate = new Date( `1904-01-01T00:00:00+0000` ).getTime(); 28412 function asText( data ) { 28413 return Array.from( data ) 28414 .map( ( v ) => String.fromCharCode( v ) ) 28415 .join( `` ); 28416 } 28417 class Parser { 28418 constructor( dict, dataview, name ) { 28419 this.name = ( name || dict.tag || `` ).trim(); 28420 this.length = dict.length; 28421 this.start = dict.offset; 28422 this.offset = 0; 28423 this.data = dataview; 28424 [ 28425 `getInt8`, 28426 `getUint8`, 28427 `getInt16`, 28428 `getUint16`, 28429 `getInt32`, 28430 `getUint32`, 28431 `getBigInt64`, 28432 `getBigUint64`, 28433 ].forEach( ( name ) => { 28434 let fn = name.replace( /get(Big)?/, '' ).toLowerCase(); 28435 let increment = parseInt( name.replace( /[^\d]/g, '' ) ) / 8; 28436 Object.defineProperty( this, fn, { 28437 get: () => this.getValue( name, increment ), 28438 } ); 28439 } ); 28440 } 28441 get currentPosition() { 28442 return this.start + this.offset; 28443 } 28444 set currentPosition( position ) { 28445 this.start = position; 28446 this.offset = 0; 28447 } 28448 skip( n = 0, bits = 8 ) { 28449 this.offset += ( n * bits ) / 8; 28450 } 28451 getValue( type, increment ) { 28452 let pos = this.start + this.offset; 28453 this.offset += increment; 28454 try { 28455 return this.data[ type ]( pos ); 28456 } catch ( e ) { 28457 console.error( `parser`, type, increment, this ); 28458 console.error( `parser`, this.start, this.offset ); 28459 throw e; 28460 } 28461 } 28462 flags( n ) { 28463 if ( n === 8 || n === 16 || n === 32 || n === 64 ) { 28464 return this[ `uint${ n }` ] 28465 .toString( 2 ) 28466 .padStart( n, 0 ) 28467 .split( `` ) 28468 .map( ( v ) => v === '1' ); 28469 } 28470 console.error( 28471 `Error parsing flags: flag types can only be 1, 2, 4, or 8 bytes long` 28472 ); 28473 console.trace(); 28474 } 28475 get tag() { 28476 const t = this.uint32; 28477 return asText( [ 28478 ( t >> 24 ) & 255, 28479 ( t >> 16 ) & 255, 28480 ( t >> 8 ) & 255, 28481 t & 255, 28482 ] ); 28483 } 28484 get fixed() { 28485 let major = this.int16; 28486 let minor = Math.round( ( 1e3 * this.uint16 ) / 65356 ); 28487 return major + minor / 1e3; 28488 } 28489 get legacyFixed() { 28490 let major = this.uint16; 28491 let minor = this.uint16.toString( 16 ).padStart( 4, 0 ); 28492 return parseFloat( `${ major }.${ minor }` ); 28493 } 28494 get uint24() { 28495 return ( this.uint8 << 16 ) + ( this.uint8 << 8 ) + this.uint8; 28496 } 28497 get uint128() { 28498 let value = 0; 28499 for ( let i = 0; i < 5; i++ ) { 28500 let byte = this.uint8; 28501 value = value * 128 + ( byte & 127 ); 28502 if ( byte < 128 ) break; 28503 } 28504 return value; 28505 } 28506 get longdatetime() { 28507 return new Date( startDate + 1e3 * parseInt( this.int64.toString() ) ); 28508 } 28509 get fword() { 28510 return this.int16; 28511 } 28512 get ufword() { 28513 return this.uint16; 28514 } 28515 get Offset16() { 28516 return this.uint16; 28517 } 28518 get Offset32() { 28519 return this.uint32; 28520 } 28521 get F2DOT14() { 28522 const bits = p.uint16; 28523 const integer = [ 0, 1, -2, -1 ][ bits >> 14 ]; 28524 const fraction = bits & 16383; 28525 return integer + fraction / 16384; 28526 } 28527 verifyLength() { 28528 if ( this.offset != this.length ) { 28529 console.error( 28530 `unexpected parsed table size (${ this.offset }) for "${ this.name }" (expected ${ this.length })` 28531 ); 28532 } 28533 } 28534 readBytes( n = 0, position = 0, bits = 8, signed = false ) { 28535 n = n || this.length; 28536 if ( n === 0 ) return []; 28537 if ( position ) this.currentPosition = position; 28538 const fn = `${ signed ? `` : `u` }int${ bits }`, 28539 slice = []; 28540 while ( n-- ) slice.push( this[ fn ] ); 28541 return slice; 28542 } 28543 } 28544 class ParsedData { 28545 constructor( parser ) { 28546 const pGetter = { enumerable: false, get: () => parser }; 28547 Object.defineProperty( this, `parser`, pGetter ); 28548 const start = parser.currentPosition; 28549 const startGetter = { enumerable: false, get: () => start }; 28550 Object.defineProperty( this, `start`, startGetter ); 28551 } 28552 load( struct ) { 28553 Object.keys( struct ).forEach( ( p ) => { 28554 let props = Object.getOwnPropertyDescriptor( struct, p ); 28555 if ( props.get ) { 28556 this[ p ] = props.get.bind( this ); 28557 } else if ( props.value !== undefined ) { 28558 this[ p ] = props.value; 28559 } 28560 } ); 28561 if ( this.parser.length ) { 28562 this.parser.verifyLength(); 28563 } 28564 } 28565 } 28566 class SimpleTable extends ParsedData { 28567 constructor( dict, dataview, name ) { 28568 const { parser: parser, start: start } = super( 28569 new Parser( dict, dataview, name ) 28570 ); 28571 const pGetter = { enumerable: false, get: () => parser }; 28572 Object.defineProperty( this, `p`, pGetter ); 28573 const startGetter = { enumerable: false, get: () => start }; 28574 Object.defineProperty( this, `tableStart`, startGetter ); 28575 } 28576 } 28577 function lazy$1( object, property, getter ) { 28578 let val; 28579 Object.defineProperty( object, property, { 28580 get: () => { 28581 if ( val ) return val; 28582 val = getter(); 28583 return val; 28584 }, 28585 enumerable: true, 28586 } ); 28587 } 28588 class SFNT extends SimpleTable { 28589 constructor( font, dataview, createTable ) { 28590 const { p: p } = super( { offset: 0, length: 12 }, dataview, `sfnt` ); 28591 this.version = p.uint32; 28592 this.numTables = p.uint16; 28593 this.searchRange = p.uint16; 28594 this.entrySelector = p.uint16; 28595 this.rangeShift = p.uint16; 28596 p.verifyLength(); 28597 this.directory = [ ...new Array( this.numTables ) ].map( 28598 ( _ ) => new TableRecord( p ) 28599 ); 28600 this.tables = {}; 28601 this.directory.forEach( ( entry ) => { 28602 const getter = () => 28603 createTable( 28604 this.tables, 28605 { 28606 tag: entry.tag, 28607 offset: entry.offset, 28608 length: entry.length, 28609 }, 28610 dataview 28611 ); 28612 lazy$1( this.tables, entry.tag.trim(), getter ); 28613 } ); 28614 } 28615 } 28616 class TableRecord { 28617 constructor( p ) { 28618 this.tag = p.tag; 28619 this.checksum = p.uint32; 28620 this.offset = p.uint32; 28621 this.length = p.uint32; 28622 } 28623 } 28624 const gzipDecode = (inflate_default()).inflate || undefined; 28625 let nativeGzipDecode = undefined; 28626 // if ( ! gzipDecode ) { 28627 // import( 'zlib' ).then( ( zlib ) => { 28628 // nativeGzipDecode = ( buffer ) => zlib.unzipSync( buffer ); 28629 // } ); 28630 // } 28631 class WOFF$1 extends SimpleTable { 28632 constructor( font, dataview, createTable ) { 28633 const { p: p } = super( { offset: 0, length: 44 }, dataview, `woff` ); 28634 this.signature = p.tag; 28635 this.flavor = p.uint32; 28636 this.length = p.uint32; 28637 this.numTables = p.uint16; 28638 p.uint16; 28639 this.totalSfntSize = p.uint32; 28640 this.majorVersion = p.uint16; 28641 this.minorVersion = p.uint16; 28642 this.metaOffset = p.uint32; 28643 this.metaLength = p.uint32; 28644 this.metaOrigLength = p.uint32; 28645 this.privOffset = p.uint32; 28646 this.privLength = p.uint32; 28647 p.verifyLength(); 28648 this.directory = [ ...new Array( this.numTables ) ].map( 28649 ( _ ) => new WoffTableDirectoryEntry( p ) 28650 ); 28651 buildWoffLazyLookups( this, dataview, createTable ); 28652 } 28653 } 28654 class WoffTableDirectoryEntry { 28655 constructor( p ) { 28656 this.tag = p.tag; 28657 this.offset = p.uint32; 28658 this.compLength = p.uint32; 28659 this.origLength = p.uint32; 28660 this.origChecksum = p.uint32; 28661 } 28662 } 28663 function buildWoffLazyLookups( woff, dataview, createTable ) { 28664 woff.tables = {}; 28665 woff.directory.forEach( ( entry ) => { 28666 lazy$1( woff.tables, entry.tag.trim(), () => { 28667 let offset = 0; 28668 let view = dataview; 28669 if ( entry.compLength !== entry.origLength ) { 28670 const data = dataview.buffer.slice( 28671 entry.offset, 28672 entry.offset + entry.compLength 28673 ); 28674 let unpacked; 28675 if ( gzipDecode ) { 28676 unpacked = gzipDecode( new Uint8Array( data ) ); 28677 } else if ( nativeGzipDecode ) { 28678 unpacked = nativeGzipDecode( new Uint8Array( data ) ); 28679 } else { 28680 const msg = `no brotli decoder available to decode WOFF2 font`; 28681 if ( font.onerror ) font.onerror( msg ); 28682 throw new Error( msg ); 28683 } 28684 view = new DataView( unpacked.buffer ); 28685 } else { 28686 offset = entry.offset; 28687 } 28688 return createTable( 28689 woff.tables, 28690 { tag: entry.tag, offset: offset, length: entry.origLength }, 28691 view 28692 ); 28693 } ); 28694 } ); 28695 } 28696 const brotliDecode = (unbrotli_default()); 28697 let nativeBrotliDecode = undefined; 28698 // if ( ! brotliDecode ) { 28699 // import( 'zlib' ).then( ( zlib ) => { 28700 // nativeBrotliDecode = ( buffer ) => zlib.brotliDecompressSync( buffer ); 28701 // } ); 28702 // } 28703 class WOFF2$1 extends SimpleTable { 28704 constructor( font, dataview, createTable ) { 28705 const { p: p } = super( { offset: 0, length: 48 }, dataview, `woff2` ); 28706 this.signature = p.tag; 28707 this.flavor = p.uint32; 28708 this.length = p.uint32; 28709 this.numTables = p.uint16; 28710 p.uint16; 28711 this.totalSfntSize = p.uint32; 28712 this.totalCompressedSize = p.uint32; 28713 this.majorVersion = p.uint16; 28714 this.minorVersion = p.uint16; 28715 this.metaOffset = p.uint32; 28716 this.metaLength = p.uint32; 28717 this.metaOrigLength = p.uint32; 28718 this.privOffset = p.uint32; 28719 this.privLength = p.uint32; 28720 p.verifyLength(); 28721 this.directory = [ ...new Array( this.numTables ) ].map( 28722 ( _ ) => new Woff2TableDirectoryEntry( p ) 28723 ); 28724 let dictOffset = p.currentPosition; 28725 this.directory[ 0 ].offset = 0; 28726 this.directory.forEach( ( e, i ) => { 28727 let next = this.directory[ i + 1 ]; 28728 if ( next ) { 28729 next.offset = 28730 e.offset + 28731 ( e.transformLength !== undefined 28732 ? e.transformLength 28733 : e.origLength ); 28734 } 28735 } ); 28736 let decoded; 28737 let buffer = dataview.buffer.slice( dictOffset ); 28738 if ( brotliDecode ) { 28739 decoded = brotliDecode( new Uint8Array( buffer ) ); 28740 } else if ( nativeBrotliDecode ) { 28741 decoded = new Uint8Array( nativeBrotliDecode( buffer ) ); 28742 } else { 28743 const msg = `no brotli decoder available to decode WOFF2 font`; 28744 if ( font.onerror ) font.onerror( msg ); 28745 throw new Error( msg ); 28746 } 28747 buildWoff2LazyLookups( this, decoded, createTable ); 28748 } 28749 } 28750 class Woff2TableDirectoryEntry { 28751 constructor( p ) { 28752 this.flags = p.uint8; 28753 const tagNumber = ( this.tagNumber = this.flags & 63 ); 28754 if ( tagNumber === 63 ) { 28755 this.tag = p.tag; 28756 } else { 28757 this.tag = getWOFF2Tag( tagNumber ); 28758 } 28759 const transformVersion = ( this.transformVersion = 28760 ( this.flags & 192 ) >> 6 ); 28761 let hasTransforms = transformVersion !== 0; 28762 if ( this.tag === `glyf` || this.tag === `loca` ) { 28763 hasTransforms = this.transformVersion !== 3; 28764 } 28765 this.origLength = p.uint128; 28766 if ( hasTransforms ) { 28767 this.transformLength = p.uint128; 28768 } 28769 } 28770 } 28771 function buildWoff2LazyLookups( woff2, decoded, createTable ) { 28772 woff2.tables = {}; 28773 woff2.directory.forEach( ( entry ) => { 28774 lazy$1( woff2.tables, entry.tag.trim(), () => { 28775 const start = entry.offset; 28776 const end = 28777 start + 28778 ( entry.transformLength 28779 ? entry.transformLength 28780 : entry.origLength ); 28781 const data = new DataView( decoded.slice( start, end ).buffer ); 28782 try { 28783 return createTable( 28784 woff2.tables, 28785 { tag: entry.tag, offset: 0, length: entry.origLength }, 28786 data 28787 ); 28788 } catch ( e ) { 28789 console.error( e ); 28790 } 28791 } ); 28792 } ); 28793 } 28794 function getWOFF2Tag( flag ) { 28795 return [ 28796 `cmap`, 28797 `head`, 28798 `hhea`, 28799 `hmtx`, 28800 `maxp`, 28801 `name`, 28802 `OS/2`, 28803 `post`, 28804 `cvt `, 28805 `fpgm`, 28806 `glyf`, 28807 `loca`, 28808 `prep`, 28809 `CFF `, 28810 `VORG`, 28811 `EBDT`, 28812 `EBLC`, 28813 `gasp`, 28814 `hdmx`, 28815 `kern`, 28816 `LTSH`, 28817 `PCLT`, 28818 `VDMX`, 28819 `vhea`, 28820 `vmtx`, 28821 `BASE`, 28822 `GDEF`, 28823 `GPOS`, 28824 `GSUB`, 28825 `EBSC`, 28826 `JSTF`, 28827 `MATH`, 28828 `CBDT`, 28829 `CBLC`, 28830 `COLR`, 28831 `CPAL`, 28832 `SVG `, 28833 `sbix`, 28834 `acnt`, 28835 `avar`, 28836 `bdat`, 28837 `bloc`, 28838 `bsln`, 28839 `cvar`, 28840 `fdsc`, 28841 `feat`, 28842 `fmtx`, 28843 `fvar`, 28844 `gvar`, 28845 `hsty`, 28846 `just`, 28847 `lcar`, 28848 `mort`, 28849 `morx`, 28850 `opbd`, 28851 `prop`, 28852 `trak`, 28853 `Zapf`, 28854 `Silf`, 28855 `Glat`, 28856 `Gloc`, 28857 `Feat`, 28858 `Sill`, 28859 ][ flag & 63 ]; 28860 } 28861 const tableClasses = {}; 28862 let tableClassesLoaded = false; 28863 Promise.all( [ 28864 Promise.resolve().then( function () { 28865 return cmap$1; 28866 } ), 28867 Promise.resolve().then( function () { 28868 return head$1; 28869 } ), 28870 Promise.resolve().then( function () { 28871 return hhea$1; 28872 } ), 28873 Promise.resolve().then( function () { 28874 return hmtx$1; 28875 } ), 28876 Promise.resolve().then( function () { 28877 return maxp$1; 28878 } ), 28879 Promise.resolve().then( function () { 28880 return name$1; 28881 } ), 28882 Promise.resolve().then( function () { 28883 return OS2$1; 28884 } ), 28885 Promise.resolve().then( function () { 28886 return post$1; 28887 } ), 28888 Promise.resolve().then( function () { 28889 return BASE$1; 28890 } ), 28891 Promise.resolve().then( function () { 28892 return GDEF$1; 28893 } ), 28894 Promise.resolve().then( function () { 28895 return GSUB$1; 28896 } ), 28897 Promise.resolve().then( function () { 28898 return GPOS$1; 28899 } ), 28900 Promise.resolve().then( function () { 28901 return SVG$1; 28902 } ), 28903 Promise.resolve().then( function () { 28904 return fvar$1; 28905 } ), 28906 Promise.resolve().then( function () { 28907 return cvt$1; 28908 } ), 28909 Promise.resolve().then( function () { 28910 return fpgm$1; 28911 } ), 28912 Promise.resolve().then( function () { 28913 return gasp$1; 28914 } ), 28915 Promise.resolve().then( function () { 28916 return glyf$1; 28917 } ), 28918 Promise.resolve().then( function () { 28919 return loca$1; 28920 } ), 28921 Promise.resolve().then( function () { 28922 return prep$1; 28923 } ), 28924 Promise.resolve().then( function () { 28925 return CFF$1; 28926 } ), 28927 Promise.resolve().then( function () { 28928 return CFF2$1; 28929 } ), 28930 Promise.resolve().then( function () { 28931 return VORG$1; 28932 } ), 28933 Promise.resolve().then( function () { 28934 return EBLC$1; 28935 } ), 28936 Promise.resolve().then( function () { 28937 return EBDT$1; 28938 } ), 28939 Promise.resolve().then( function () { 28940 return EBSC$1; 28941 } ), 28942 Promise.resolve().then( function () { 28943 return CBLC$1; 28944 } ), 28945 Promise.resolve().then( function () { 28946 return CBDT$1; 28947 } ), 28948 Promise.resolve().then( function () { 28949 return sbix$1; 28950 } ), 28951 Promise.resolve().then( function () { 28952 return COLR$1; 28953 } ), 28954 Promise.resolve().then( function () { 28955 return CPAL$1; 28956 } ), 28957 Promise.resolve().then( function () { 28958 return DSIG$1; 28959 } ), 28960 Promise.resolve().then( function () { 28961 return hdmx$1; 28962 } ), 28963 Promise.resolve().then( function () { 28964 return kern$1; 28965 } ), 28966 Promise.resolve().then( function () { 28967 return LTSH$1; 28968 } ), 28969 Promise.resolve().then( function () { 28970 return MERG$1; 28971 } ), 28972 Promise.resolve().then( function () { 28973 return meta$1; 28974 } ), 28975 Promise.resolve().then( function () { 28976 return PCLT$1; 28977 } ), 28978 Promise.resolve().then( function () { 28979 return VDMX$1; 28980 } ), 28981 Promise.resolve().then( function () { 28982 return vhea$1; 28983 } ), 28984 Promise.resolve().then( function () { 28985 return vmtx$1; 28986 } ), 28987 ] ).then( ( data ) => { 28988 data.forEach( ( e ) => { 28989 let name = Object.keys( e )[ 0 ]; 28990 tableClasses[ name ] = e[ name ]; 28991 } ); 28992 tableClassesLoaded = true; 28993 } ); 28994 function createTable( tables, dict, dataview ) { 28995 let name = dict.tag.replace( /[^\w\d]/g, `` ); 28996 let Type = tableClasses[ name ]; 28997 if ( Type ) return new Type( dict, dataview, tables ); 28998 console.warn( 28999 `lib-font has no definition for ${ name }. The table was skipped.` 29000 ); 29001 return {}; 29002 } 29003 function loadTableClasses() { 29004 let count = 0; 29005 function checkLoaded( resolve, reject ) { 29006 if ( ! tableClassesLoaded ) { 29007 if ( count > 10 ) { 29008 return reject( new Error( `loading took too long` ) ); 29009 } 29010 count++; 29011 return setTimeout( () => checkLoaded( resolve ), 250 ); 29012 } 29013 resolve( createTable ); 29014 } 29015 return new Promise( ( resolve, reject ) => checkLoaded( resolve ) ); 29016 } 29017 function getFontCSSFormat( path, errorOnStyle ) { 29018 let pos = path.lastIndexOf( `.` ); 29019 let ext = ( path.substring( pos + 1 ) || `` ).toLowerCase(); 29020 let format = { 29021 ttf: `truetype`, 29022 otf: `opentype`, 29023 woff: `woff`, 29024 woff2: `woff2`, 29025 }[ ext ]; 29026 if ( format ) return format; 29027 let msg = { 29028 eot: `The .eot format is not supported: it died in January 12, 2016, when Microsoft retired all versions of IE that didn't already support WOFF.`, 29029 svg: `The .svg format is not supported: SVG fonts (not to be confused with OpenType with embedded SVG) were so bad we took the entire fonts chapter out of the SVG specification again.`, 29030 fon: `The .fon format is not supported: this is an ancient Windows bitmap font format.`, 29031 ttc: `Based on the current CSS specification, font collections are not (yet?) supported.`, 29032 }[ ext ]; 29033 if ( ! msg ) msg = `${ path } is not a known webfont format.`; 29034 if ( errorOnStyle ) { 29035 throw new Error( msg ); 29036 } else { 29037 console.warn( `Could not load font: ${ msg }` ); 29038 } 29039 } 29040 async function setupFontFace( name, url, options = {} ) { 29041 if ( ! globalThis.document ) return; 29042 let format = getFontCSSFormat( url, options.errorOnStyle ); 29043 if ( ! format ) return; 29044 let style = document.createElement( `style` ); 29045 style.className = `injected-by-Font-js`; 29046 let rules = []; 29047 if ( options.styleRules ) { 29048 rules = Object.entries( options.styleRules ).map( 29049 ( [ key, value ] ) => `${ key }: ${ value };` 29050 ); 29051 } 29052 style.textContent = `\n@font-face {\n font-family: "${ name }";\n ${ rules.join( 29053 `\n\t` 29054 ) }\n src: url("${ url }") format("${ format }");\n}`; 29055 globalThis.document.head.appendChild( style ); 29056 return style; 29057 } 29058 const TTF = [ 0, 1, 0, 0 ]; 29059 const OTF = [ 79, 84, 84, 79 ]; 29060 const WOFF = [ 119, 79, 70, 70 ]; 29061 const WOFF2 = [ 119, 79, 70, 50 ]; 29062 function match( ar1, ar2 ) { 29063 if ( ar1.length !== ar2.length ) return; 29064 for ( let i = 0; i < ar1.length; i++ ) { 29065 if ( ar1[ i ] !== ar2[ i ] ) return; 29066 } 29067 return true; 29068 } 29069 function validFontFormat( dataview ) { 29070 const LEAD_BYTES = [ 29071 dataview.getUint8( 0 ), 29072 dataview.getUint8( 1 ), 29073 dataview.getUint8( 2 ), 29074 dataview.getUint8( 3 ), 29075 ]; 29076 if ( match( LEAD_BYTES, TTF ) || match( LEAD_BYTES, OTF ) ) return `SFNT`; 29077 if ( match( LEAD_BYTES, WOFF ) ) return `WOFF`; 29078 if ( match( LEAD_BYTES, WOFF2 ) ) return `WOFF2`; 29079 } 29080 function checkFetchResponseStatus( response ) { 29081 if ( ! response.ok ) { 29082 throw new Error( 29083 `HTTP ${ response.status } - ${ response.statusText }` 29084 ); 29085 } 29086 return response; 29087 } 29088 class Font extends EventManager { 29089 constructor( name, options = {} ) { 29090 super(); 29091 this.name = name; 29092 this.options = options; 29093 this.metrics = false; 29094 } 29095 get src() { 29096 return this.__src; 29097 } 29098 set src( src ) { 29099 this.__src = src; 29100 ( async () => { 29101 if ( globalThis.document && ! this.options.skipStyleSheet ) { 29102 await setupFontFace( this.name, src, this.options ); 29103 } 29104 this.loadFont( src ); 29105 } )(); 29106 } 29107 async loadFont( url, filename ) { 29108 fetch( url ) 29109 .then( 29110 ( response ) => 29111 checkFetchResponseStatus( response ) && 29112 response.arrayBuffer() 29113 ) 29114 .then( ( buffer ) => 29115 this.fromDataBuffer( buffer, filename || url ) 29116 ) 29117 .catch( ( err ) => { 29118 const evt = new lib_font_browser_Event( 29119 `error`, 29120 err, 29121 `Failed to load font at ${ filename || url }` 29122 ); 29123 this.dispatch( evt ); 29124 if ( this.onerror ) this.onerror( evt ); 29125 } ); 29126 } 29127 async fromDataBuffer( buffer, filenameOrUrL ) { 29128 this.fontData = new DataView( buffer ); 29129 let type = validFontFormat( this.fontData ); 29130 if ( ! type ) { 29131 throw new Error( 29132 `${ filenameOrUrL } is either an unsupported font format, or not a font at all.` 29133 ); 29134 } 29135 await this.parseBasicData( type ); 29136 const evt = new lib_font_browser_Event( 'load', { font: this } ); 29137 this.dispatch( evt ); 29138 if ( this.onload ) this.onload( evt ); 29139 } 29140 async parseBasicData( type ) { 29141 return loadTableClasses().then( ( createTable ) => { 29142 if ( type === `SFNT` ) { 29143 this.opentype = new SFNT( this, this.fontData, createTable ); 29144 } 29145 if ( type === `WOFF` ) { 29146 this.opentype = new WOFF$1( this, this.fontData, createTable ); 29147 } 29148 if ( type === `WOFF2` ) { 29149 this.opentype = new WOFF2$1( this, this.fontData, createTable ); 29150 } 29151 return this.opentype; 29152 } ); 29153 } 29154 getGlyphId( char ) { 29155 return this.opentype.tables.cmap.getGlyphId( char ); 29156 } 29157 reverse( glyphid ) { 29158 return this.opentype.tables.cmap.reverse( glyphid ); 29159 } 29160 supports( char ) { 29161 return this.getGlyphId( char ) !== 0; 29162 } 29163 supportsVariation( variation ) { 29164 return ( 29165 this.opentype.tables.cmap.supportsVariation( variation ) !== false 29166 ); 29167 } 29168 measureText( text, size = 16 ) { 29169 if ( this.__unloaded ) 29170 throw new Error( 29171 'Cannot measure text: font was unloaded. Please reload before calling measureText()' 29172 ); 29173 let d = document.createElement( 'div' ); 29174 d.textContent = text; 29175 d.style.fontFamily = this.name; 29176 d.style.fontSize = `${ size }px`; 29177 d.style.color = `transparent`; 29178 d.style.background = `transparent`; 29179 d.style.top = `0`; 29180 d.style.left = `0`; 29181 d.style.position = `absolute`; 29182 document.body.appendChild( d ); 29183 let bbox = d.getBoundingClientRect(); 29184 document.body.removeChild( d ); 29185 const OS2 = this.opentype.tables[ 'OS/2' ]; 29186 bbox.fontSize = size; 29187 bbox.ascender = OS2.sTypoAscender; 29188 bbox.descender = OS2.sTypoDescender; 29189 return bbox; 29190 } 29191 unload() { 29192 if ( this.styleElement.parentNode ) { 29193 this.styleElement.parentNode.removeElement( this.styleElement ); 29194 const evt = new lib_font_browser_Event( 'unload', { font: this } ); 29195 this.dispatch( evt ); 29196 if ( this.onunload ) this.onunload( evt ); 29197 } 29198 this._unloaded = true; 29199 } 29200 load() { 29201 if ( this.__unloaded ) { 29202 delete this.__unloaded; 29203 document.head.appendChild( this.styleElement ); 29204 const evt = new lib_font_browser_Event( 'load', { font: this } ); 29205 this.dispatch( evt ); 29206 if ( this.onload ) this.onload( evt ); 29207 } 29208 } 29209 } 29210 globalThis.Font = Font; 29211 class Subtable extends ParsedData { 29212 constructor( p, plaformID, encodingID ) { 29213 super( p ); 29214 this.plaformID = plaformID; 29215 this.encodingID = encodingID; 29216 } 29217 } 29218 class Format0 extends Subtable { 29219 constructor( p, platformID, encodingID ) { 29220 super( p, platformID, encodingID ); 29221 this.format = 0; 29222 this.length = p.uint16; 29223 this.language = p.uint16; 29224 this.glyphIdArray = [ ...new Array( 256 ) ].map( ( _ ) => p.uint8 ); 29225 } 29226 supports( charCode ) { 29227 if ( charCode.charCodeAt ) { 29228 charCode = -1; 29229 console.warn( 29230 `supports(character) not implemented for cmap subtable format 0. only supports(id) is implemented.` 29231 ); 29232 } 29233 return 0 <= charCode && charCode <= 255; 29234 } 29235 reverse( glyphID ) { 29236 console.warn( `reverse not implemented for cmap subtable format 0` ); 29237 return {}; 29238 } 29239 getSupportedCharCodes() { 29240 return [ { start: 1, end: 256 } ]; 29241 } 29242 } 29243 class Format2 extends Subtable { 29244 constructor( p, platformID, encodingID ) { 29245 super( p, platformID, encodingID ); 29246 this.format = 2; 29247 this.length = p.uint16; 29248 this.language = p.uint16; 29249 this.subHeaderKeys = [ ...new Array( 256 ) ].map( ( _ ) => p.uint16 ); 29250 const subHeaderCount = Math.max( ...this.subHeaderKeys ); 29251 const subHeaderOffset = p.currentPosition; 29252 lazy$1( this, `subHeaders`, () => { 29253 p.currentPosition = subHeaderOffset; 29254 return [ ...new Array( subHeaderCount ) ].map( 29255 ( _ ) => new SubHeader( p ) 29256 ); 29257 } ); 29258 const glyphIndexOffset = subHeaderOffset + subHeaderCount * 8; 29259 lazy$1( this, `glyphIndexArray`, () => { 29260 p.currentPosition = glyphIndexOffset; 29261 return [ ...new Array( subHeaderCount ) ].map( ( _ ) => p.uint16 ); 29262 } ); 29263 } 29264 supports( charCode ) { 29265 if ( charCode.charCodeAt ) { 29266 charCode = -1; 29267 console.warn( 29268 `supports(character) not implemented for cmap subtable format 2. only supports(id) is implemented.` 29269 ); 29270 } 29271 const low = charCode && 255; 29272 const high = charCode && 65280; 29273 const subHeaderKey = this.subHeaders[ high ]; 29274 const subheader = this.subHeaders[ subHeaderKey ]; 29275 const first = subheader.firstCode; 29276 const last = first + subheader.entryCount; 29277 return first <= low && low <= last; 29278 } 29279 reverse( glyphID ) { 29280 console.warn( `reverse not implemented for cmap subtable format 2` ); 29281 return {}; 29282 } 29283 getSupportedCharCodes( preservePropNames = false ) { 29284 if ( preservePropNames ) { 29285 return this.subHeaders.map( ( h ) => ( { 29286 firstCode: h.firstCode, 29287 lastCode: h.lastCode, 29288 } ) ); 29289 } 29290 return this.subHeaders.map( ( h ) => ( { 29291 start: h.firstCode, 29292 end: h.lastCode, 29293 } ) ); 29294 } 29295 } 29296 class SubHeader { 29297 constructor( p ) { 29298 this.firstCode = p.uint16; 29299 this.entryCount = p.uint16; 29300 this.lastCode = this.first + this.entryCount; 29301 this.idDelta = p.int16; 29302 this.idRangeOffset = p.uint16; 29303 } 29304 } 29305 class Format4 extends Subtable { 29306 constructor( p, platformID, encodingID ) { 29307 super( p, platformID, encodingID ); 29308 this.format = 4; 29309 this.length = p.uint16; 29310 this.language = p.uint16; 29311 this.segCountX2 = p.uint16; 29312 this.segCount = this.segCountX2 / 2; 29313 this.searchRange = p.uint16; 29314 this.entrySelector = p.uint16; 29315 this.rangeShift = p.uint16; 29316 const endCodePosition = p.currentPosition; 29317 lazy$1( this, `endCode`, () => 29318 p.readBytes( this.segCount, endCodePosition, 16 ) 29319 ); 29320 const startCodePosition = endCodePosition + 2 + this.segCountX2; 29321 lazy$1( this, `startCode`, () => 29322 p.readBytes( this.segCount, startCodePosition, 16 ) 29323 ); 29324 const idDeltaPosition = startCodePosition + this.segCountX2; 29325 lazy$1( this, `idDelta`, () => 29326 p.readBytes( this.segCount, idDeltaPosition, 16, true ) 29327 ); 29328 const idRangePosition = idDeltaPosition + this.segCountX2; 29329 lazy$1( this, `idRangeOffset`, () => 29330 p.readBytes( this.segCount, idRangePosition, 16 ) 29331 ); 29332 const glyphIdArrayPosition = idRangePosition + this.segCountX2; 29333 const glyphIdArrayLength = 29334 this.length - ( glyphIdArrayPosition - this.tableStart ); 29335 lazy$1( this, `glyphIdArray`, () => 29336 p.readBytes( glyphIdArrayLength, glyphIdArrayPosition, 16 ) 29337 ); 29338 lazy$1( this, `segments`, () => 29339 this.buildSegments( idRangePosition, glyphIdArrayPosition, p ) 29340 ); 29341 } 29342 buildSegments( idRangePosition, glyphIdArrayPosition, p ) { 29343 const build = ( _, i ) => { 29344 let startCode = this.startCode[ i ], 29345 endCode = this.endCode[ i ], 29346 idDelta = this.idDelta[ i ], 29347 idRangeOffset = this.idRangeOffset[ i ], 29348 idRangeOffsetPointer = idRangePosition + 2 * i, 29349 glyphIDs = []; 29350 if ( idRangeOffset === 0 ) { 29351 for ( 29352 let i = startCode + idDelta, e = endCode + idDelta; 29353 i <= e; 29354 i++ 29355 ) { 29356 glyphIDs.push( i ); 29357 } 29358 } else { 29359 for ( let i = 0, e = endCode - startCode; i <= e; i++ ) { 29360 p.currentPosition = 29361 idRangeOffsetPointer + idRangeOffset + i * 2; 29362 glyphIDs.push( p.uint16 ); 29363 } 29364 } 29365 return { 29366 startCode: startCode, 29367 endCode: endCode, 29368 idDelta: idDelta, 29369 idRangeOffset: idRangeOffset, 29370 glyphIDs: glyphIDs, 29371 }; 29372 }; 29373 return [ ...new Array( this.segCount ) ].map( build ); 29374 } 29375 reverse( glyphID ) { 29376 let s = this.segments.find( ( v ) => v.glyphIDs.includes( glyphID ) ); 29377 if ( ! s ) return {}; 29378 const code = s.startCode + s.glyphIDs.indexOf( glyphID ); 29379 return { code: code, unicode: String.fromCodePoint( code ) }; 29380 } 29381 getGlyphId( charCode ) { 29382 if ( charCode.charCodeAt ) charCode = charCode.charCodeAt( 0 ); 29383 if ( 55296 <= charCode && charCode <= 57343 ) return 0; 29384 if ( ( charCode & 65534 ) === 65534 || ( charCode & 65535 ) === 65535 ) 29385 return 0; 29386 let segment = this.segments.find( 29387 ( s ) => s.startCode <= charCode && charCode <= s.endCode 29388 ); 29389 if ( ! segment ) return 0; 29390 return segment.glyphIDs[ charCode - segment.startCode ]; 29391 } 29392 supports( charCode ) { 29393 return this.getGlyphId( charCode ) !== 0; 29394 } 29395 getSupportedCharCodes( preservePropNames = false ) { 29396 if ( preservePropNames ) return this.segments; 29397 return this.segments.map( ( v ) => ( { 29398 start: v.startCode, 29399 end: v.endCode, 29400 } ) ); 29401 } 29402 } 29403 class Format6 extends Subtable { 29404 constructor( p, platformID, encodingID ) { 29405 super( p, platformID, encodingID ); 29406 this.format = 6; 29407 this.length = p.uint16; 29408 this.language = p.uint16; 29409 this.firstCode = p.uint16; 29410 this.entryCount = p.uint16; 29411 this.lastCode = this.firstCode + this.entryCount - 1; 29412 const getter = () => 29413 [ ...new Array( this.entryCount ) ].map( ( _ ) => p.uint16 ); 29414 lazy$1( this, `glyphIdArray`, getter ); 29415 } 29416 supports( charCode ) { 29417 if ( charCode.charCodeAt ) { 29418 charCode = -1; 29419 console.warn( 29420 `supports(character) not implemented for cmap subtable format 6. only supports(id) is implemented.` 29421 ); 29422 } 29423 if ( charCode < this.firstCode ) return {}; 29424 if ( charCode > this.firstCode + this.entryCount ) return {}; 29425 const code = charCode - this.firstCode; 29426 return { code: code, unicode: String.fromCodePoint( code ) }; 29427 } 29428 reverse( glyphID ) { 29429 let pos = this.glyphIdArray.indexOf( glyphID ); 29430 if ( pos > -1 ) return this.firstCode + pos; 29431 } 29432 getSupportedCharCodes( preservePropNames = false ) { 29433 if ( preservePropNames ) { 29434 return [ { firstCode: this.firstCode, lastCode: this.lastCode } ]; 29435 } 29436 return [ { start: this.firstCode, end: this.lastCode } ]; 29437 } 29438 } 29439 class Format8 extends Subtable { 29440 constructor( p, platformID, encodingID ) { 29441 super( p, platformID, encodingID ); 29442 this.format = 8; 29443 p.uint16; 29444 this.length = p.uint32; 29445 this.language = p.uint32; 29446 this.is32 = [ ...new Array( 8192 ) ].map( ( _ ) => p.uint8 ); 29447 this.numGroups = p.uint32; 29448 const getter = () => 29449 [ ...new Array( this.numGroups ) ].map( 29450 ( _ ) => new SequentialMapGroup$1( p ) 29451 ); 29452 lazy$1( this, `groups`, getter ); 29453 } 29454 supports( charCode ) { 29455 if ( charCode.charCodeAt ) { 29456 charCode = -1; 29457 console.warn( 29458 `supports(character) not implemented for cmap subtable format 8. only supports(id) is implemented.` 29459 ); 29460 } 29461 return ( 29462 this.groups.findIndex( 29463 ( s ) => 29464 s.startcharCode <= charCode && charCode <= s.endcharCode 29465 ) !== -1 29466 ); 29467 } 29468 reverse( glyphID ) { 29469 console.warn( `reverse not implemented for cmap subtable format 8` ); 29470 return {}; 29471 } 29472 getSupportedCharCodes( preservePropNames = false ) { 29473 if ( preservePropNames ) return this.groups; 29474 return this.groups.map( ( v ) => ( { 29475 start: v.startcharCode, 29476 end: v.endcharCode, 29477 } ) ); 29478 } 29479 } 29480 class SequentialMapGroup$1 { 29481 constructor( p ) { 29482 this.startcharCode = p.uint32; 29483 this.endcharCode = p.uint32; 29484 this.startGlyphID = p.uint32; 29485 } 29486 } 29487 class Format10 extends Subtable { 29488 constructor( p, platformID, encodingID ) { 29489 super( p, platformID, encodingID ); 29490 this.format = 10; 29491 p.uint16; 29492 this.length = p.uint32; 29493 this.language = p.uint32; 29494 this.startCharCode = p.uint32; 29495 this.numChars = p.uint32; 29496 this.endCharCode = this.startCharCode + this.numChars; 29497 const getter = () => 29498 [ ...new Array( this.numChars ) ].map( ( _ ) => p.uint16 ); 29499 lazy$1( this, `glyphs`, getter ); 29500 } 29501 supports( charCode ) { 29502 if ( charCode.charCodeAt ) { 29503 charCode = -1; 29504 console.warn( 29505 `supports(character) not implemented for cmap subtable format 10. only supports(id) is implemented.` 29506 ); 29507 } 29508 if ( charCode < this.startCharCode ) return false; 29509 if ( charCode > this.startCharCode + this.numChars ) return false; 29510 return charCode - this.startCharCode; 29511 } 29512 reverse( glyphID ) { 29513 console.warn( `reverse not implemented for cmap subtable format 10` ); 29514 return {}; 29515 } 29516 getSupportedCharCodes( preservePropNames = false ) { 29517 if ( preservePropNames ) { 29518 return [ 29519 { 29520 startCharCode: this.startCharCode, 29521 endCharCode: this.endCharCode, 29522 }, 29523 ]; 29524 } 29525 return [ { start: this.startCharCode, end: this.endCharCode } ]; 29526 } 29527 } 29528 class Format12 extends Subtable { 29529 constructor( p, platformID, encodingID ) { 29530 super( p, platformID, encodingID ); 29531 this.format = 12; 29532 p.uint16; 29533 this.length = p.uint32; 29534 this.language = p.uint32; 29535 this.numGroups = p.uint32; 29536 const getter = () => 29537 [ ...new Array( this.numGroups ) ].map( 29538 ( _ ) => new SequentialMapGroup( p ) 29539 ); 29540 lazy$1( this, `groups`, getter ); 29541 } 29542 supports( charCode ) { 29543 if ( charCode.charCodeAt ) charCode = charCode.charCodeAt( 0 ); 29544 if ( 55296 <= charCode && charCode <= 57343 ) return 0; 29545 if ( ( charCode & 65534 ) === 65534 || ( charCode & 65535 ) === 65535 ) 29546 return 0; 29547 return ( 29548 this.groups.findIndex( 29549 ( s ) => 29550 s.startCharCode <= charCode && charCode <= s.endCharCode 29551 ) !== -1 29552 ); 29553 } 29554 reverse( glyphID ) { 29555 for ( let group of this.groups ) { 29556 let start = group.startGlyphID; 29557 if ( start > glyphID ) continue; 29558 if ( start === glyphID ) return group.startCharCode; 29559 let end = start + ( group.endCharCode - group.startCharCode ); 29560 if ( end < glyphID ) continue; 29561 const code = group.startCharCode + ( glyphID - start ); 29562 return { code: code, unicode: String.fromCodePoint( code ) }; 29563 } 29564 return {}; 29565 } 29566 getSupportedCharCodes( preservePropNames = false ) { 29567 if ( preservePropNames ) return this.groups; 29568 return this.groups.map( ( v ) => ( { 29569 start: v.startCharCode, 29570 end: v.endCharCode, 29571 } ) ); 29572 } 29573 } 29574 class SequentialMapGroup { 29575 constructor( p ) { 29576 this.startCharCode = p.uint32; 29577 this.endCharCode = p.uint32; 29578 this.startGlyphID = p.uint32; 29579 } 29580 } 29581 class Format13 extends Subtable { 29582 constructor( p, platformID, encodingID ) { 29583 super( p, platformID, encodingID ); 29584 this.format = 13; 29585 p.uint16; 29586 this.length = p.uint32; 29587 this.language = p.uint32; 29588 this.numGroups = p.uint32; 29589 const getter = [ ...new Array( this.numGroups ) ].map( 29590 ( _ ) => new ConstantMapGroup( p ) 29591 ); 29592 lazy$1( this, `groups`, getter ); 29593 } 29594 supports( charCode ) { 29595 if ( charCode.charCodeAt ) charCode = charCode.charCodeAt( 0 ); 29596 return ( 29597 this.groups.findIndex( 29598 ( s ) => 29599 s.startCharCode <= charCode && charCode <= s.endCharCode 29600 ) !== -1 29601 ); 29602 } 29603 reverse( glyphID ) { 29604 console.warn( `reverse not implemented for cmap subtable format 13` ); 29605 return {}; 29606 } 29607 getSupportedCharCodes( preservePropNames = false ) { 29608 if ( preservePropNames ) return this.groups; 29609 return this.groups.map( ( v ) => ( { 29610 start: v.startCharCode, 29611 end: v.endCharCode, 29612 } ) ); 29613 } 29614 } 29615 class ConstantMapGroup { 29616 constructor( p ) { 29617 this.startCharCode = p.uint32; 29618 this.endCharCode = p.uint32; 29619 this.glyphID = p.uint32; 29620 } 29621 } 29622 class Format14 extends Subtable { 29623 constructor( p, platformID, encodingID ) { 29624 super( p, platformID, encodingID ); 29625 this.subTableStart = p.currentPosition; 29626 this.format = 14; 29627 this.length = p.uint32; 29628 this.numVarSelectorRecords = p.uint32; 29629 lazy$1( this, `varSelectors`, () => 29630 [ ...new Array( this.numVarSelectorRecords ) ].map( 29631 ( _ ) => new VariationSelector( p ) 29632 ) 29633 ); 29634 } 29635 supports() { 29636 console.warn( `supports not implemented for cmap subtable format 14` ); 29637 return 0; 29638 } 29639 getSupportedCharCodes() { 29640 console.warn( 29641 `getSupportedCharCodes not implemented for cmap subtable format 14` 29642 ); 29643 return []; 29644 } 29645 reverse( glyphID ) { 29646 console.warn( `reverse not implemented for cmap subtable format 14` ); 29647 return {}; 29648 } 29649 supportsVariation( variation ) { 29650 let v = this.varSelector.find( 29651 ( uvs ) => uvs.varSelector === variation 29652 ); 29653 return v ? v : false; 29654 } 29655 getSupportedVariations() { 29656 return this.varSelectors.map( ( v ) => v.varSelector ); 29657 } 29658 } 29659 class VariationSelector { 29660 constructor( p ) { 29661 this.varSelector = p.uint24; 29662 this.defaultUVSOffset = p.Offset32; 29663 this.nonDefaultUVSOffset = p.Offset32; 29664 } 29665 } 29666 function createSubTable( parser, platformID, encodingID ) { 29667 const format = parser.uint16; 29668 if ( format === 0 ) return new Format0( parser, platformID, encodingID ); 29669 if ( format === 2 ) return new Format2( parser, platformID, encodingID ); 29670 if ( format === 4 ) return new Format4( parser, platformID, encodingID ); 29671 if ( format === 6 ) return new Format6( parser, platformID, encodingID ); 29672 if ( format === 8 ) return new Format8( parser, platformID, encodingID ); 29673 if ( format === 10 ) return new Format10( parser, platformID, encodingID ); 29674 if ( format === 12 ) return new Format12( parser, platformID, encodingID ); 29675 if ( format === 13 ) return new Format13( parser, platformID, encodingID ); 29676 if ( format === 14 ) return new Format14( parser, platformID, encodingID ); 29677 return {}; 29678 } 29679 class cmap extends SimpleTable { 29680 constructor( dict, dataview ) { 29681 const { p: p } = super( dict, dataview ); 29682 this.version = p.uint16; 29683 this.numTables = p.uint16; 29684 this.encodingRecords = [ ...new Array( this.numTables ) ].map( 29685 ( _ ) => new EncodingRecord( p, this.tableStart ) 29686 ); 29687 } 29688 getSubTable( tableID ) { 29689 return this.encodingRecords[ tableID ].table; 29690 } 29691 getSupportedEncodings() { 29692 return this.encodingRecords.map( ( r ) => ( { 29693 platformID: r.platformID, 29694 encodingId: r.encodingID, 29695 } ) ); 29696 } 29697 getSupportedCharCodes( platformID, encodingID ) { 29698 const recordID = this.encodingRecords.findIndex( 29699 ( r ) => r.platformID === platformID && r.encodingID === encodingID 29700 ); 29701 if ( recordID === -1 ) return false; 29702 const subtable = this.getSubTable( recordID ); 29703 return subtable.getSupportedCharCodes(); 29704 } 29705 reverse( glyphid ) { 29706 for ( let i = 0; i < this.numTables; i++ ) { 29707 let code = this.getSubTable( i ).reverse( glyphid ); 29708 if ( code ) return code; 29709 } 29710 } 29711 getGlyphId( char ) { 29712 let last = 0; 29713 this.encodingRecords.some( ( _, tableID ) => { 29714 let t = this.getSubTable( tableID ); 29715 if ( ! t.getGlyphId ) return false; 29716 last = t.getGlyphId( char ); 29717 return last !== 0; 29718 } ); 29719 return last; 29720 } 29721 supports( char ) { 29722 return this.encodingRecords.some( ( _, tableID ) => { 29723 const t = this.getSubTable( tableID ); 29724 return t.supports && t.supports( char ) !== false; 29725 } ); 29726 } 29727 supportsVariation( variation ) { 29728 return this.encodingRecords.some( ( _, tableID ) => { 29729 const t = this.getSubTable( tableID ); 29730 return ( 29731 t.supportsVariation && 29732 t.supportsVariation( variation ) !== false 29733 ); 29734 } ); 29735 } 29736 } 29737 class EncodingRecord { 29738 constructor( p, tableStart ) { 29739 const platformID = ( this.platformID = p.uint16 ); 29740 const encodingID = ( this.encodingID = p.uint16 ); 29741 const offset = ( this.offset = p.Offset32 ); 29742 lazy$1( this, `table`, () => { 29743 p.currentPosition = tableStart + offset; 29744 return createSubTable( p, platformID, encodingID ); 29745 } ); 29746 } 29747 } 29748 var cmap$1 = Object.freeze( { __proto__: null, cmap: cmap } ); 29749 class head extends SimpleTable { 29750 constructor( dict, dataview ) { 29751 const { p: p } = super( dict, dataview ); 29752 this.load( { 29753 majorVersion: p.uint16, 29754 minorVersion: p.uint16, 29755 fontRevision: p.fixed, 29756 checkSumAdjustment: p.uint32, 29757 magicNumber: p.uint32, 29758 flags: p.flags( 16 ), 29759 unitsPerEm: p.uint16, 29760 created: p.longdatetime, 29761 modified: p.longdatetime, 29762 xMin: p.int16, 29763 yMin: p.int16, 29764 xMax: p.int16, 29765 yMax: p.int16, 29766 macStyle: p.flags( 16 ), 29767 lowestRecPPEM: p.uint16, 29768 fontDirectionHint: p.uint16, 29769 indexToLocFormat: p.uint16, 29770 glyphDataFormat: p.uint16, 29771 } ); 29772 } 29773 } 29774 var head$1 = Object.freeze( { __proto__: null, head: head } ); 29775 class hhea extends SimpleTable { 29776 constructor( dict, dataview ) { 29777 const { p: p } = super( dict, dataview ); 29778 this.majorVersion = p.uint16; 29779 this.minorVersion = p.uint16; 29780 this.ascender = p.fword; 29781 this.descender = p.fword; 29782 this.lineGap = p.fword; 29783 this.advanceWidthMax = p.ufword; 29784 this.minLeftSideBearing = p.fword; 29785 this.minRightSideBearing = p.fword; 29786 this.xMaxExtent = p.fword; 29787 this.caretSlopeRise = p.int16; 29788 this.caretSlopeRun = p.int16; 29789 this.caretOffset = p.int16; 29790 p.int16; 29791 p.int16; 29792 p.int16; 29793 p.int16; 29794 this.metricDataFormat = p.int16; 29795 this.numberOfHMetrics = p.uint16; 29796 p.verifyLength(); 29797 } 29798 } 29799 var hhea$1 = Object.freeze( { __proto__: null, hhea: hhea } ); 29800 class hmtx extends SimpleTable { 29801 constructor( dict, dataview, tables ) { 29802 const { p: p } = super( dict, dataview ); 29803 const numberOfHMetrics = tables.hhea.numberOfHMetrics; 29804 const numGlyphs = tables.maxp.numGlyphs; 29805 const metricsStart = p.currentPosition; 29806 lazy$1( this, `hMetrics`, () => { 29807 p.currentPosition = metricsStart; 29808 return [ ...new Array( numberOfHMetrics ) ].map( 29809 ( _ ) => new LongHorMetric( p.uint16, p.int16 ) 29810 ); 29811 } ); 29812 if ( numberOfHMetrics < numGlyphs ) { 29813 const lsbStart = metricsStart + numberOfHMetrics * 4; 29814 lazy$1( this, `leftSideBearings`, () => { 29815 p.currentPosition = lsbStart; 29816 return [ ...new Array( numGlyphs - numberOfHMetrics ) ].map( 29817 ( _ ) => p.int16 29818 ); 29819 } ); 29820 } 29821 } 29822 } 29823 class LongHorMetric { 29824 constructor( w, b ) { 29825 this.advanceWidth = w; 29826 this.lsb = b; 29827 } 29828 } 29829 var hmtx$1 = Object.freeze( { __proto__: null, hmtx: hmtx } ); 29830 class maxp extends SimpleTable { 29831 constructor( dict, dataview ) { 29832 const { p: p } = super( dict, dataview ); 29833 this.version = p.legacyFixed; 29834 this.numGlyphs = p.uint16; 29835 if ( this.version === 1 ) { 29836 this.maxPoints = p.uint16; 29837 this.maxContours = p.uint16; 29838 this.maxCompositePoints = p.uint16; 29839 this.maxCompositeContours = p.uint16; 29840 this.maxZones = p.uint16; 29841 this.maxTwilightPoints = p.uint16; 29842 this.maxStorage = p.uint16; 29843 this.maxFunctionDefs = p.uint16; 29844 this.maxInstructionDefs = p.uint16; 29845 this.maxStackElements = p.uint16; 29846 this.maxSizeOfInstructions = p.uint16; 29847 this.maxComponentElements = p.uint16; 29848 this.maxComponentDepth = p.uint16; 29849 } 29850 p.verifyLength(); 29851 } 29852 } 29853 var maxp$1 = Object.freeze( { __proto__: null, maxp: maxp } ); 29854 class lib_font_browser_name extends SimpleTable { 29855 constructor( dict, dataview ) { 29856 const { p: p } = super( dict, dataview ); 29857 this.format = p.uint16; 29858 this.count = p.uint16; 29859 this.stringOffset = p.Offset16; 29860 this.nameRecords = [ ...new Array( this.count ) ].map( 29861 ( _ ) => new NameRecord( p, this ) 29862 ); 29863 if ( this.format === 1 ) { 29864 this.langTagCount = p.uint16; 29865 this.langTagRecords = [ ...new Array( this.langTagCount ) ].map( 29866 ( _ ) => new LangTagRecord( p.uint16, p.Offset16 ) 29867 ); 29868 } 29869 this.stringStart = this.tableStart + this.stringOffset; 29870 } 29871 get( nameID ) { 29872 let record = this.nameRecords.find( 29873 ( record ) => record.nameID === nameID 29874 ); 29875 if ( record ) return record.string; 29876 } 29877 } 29878 class LangTagRecord { 29879 constructor( length, offset ) { 29880 this.length = length; 29881 this.offset = offset; 29882 } 29883 } 29884 class NameRecord { 29885 constructor( p, nameTable ) { 29886 this.platformID = p.uint16; 29887 this.encodingID = p.uint16; 29888 this.languageID = p.uint16; 29889 this.nameID = p.uint16; 29890 this.length = p.uint16; 29891 this.offset = p.Offset16; 29892 lazy$1( this, `string`, () => { 29893 p.currentPosition = nameTable.stringStart + this.offset; 29894 return decodeString( p, this ); 29895 } ); 29896 } 29897 } 29898 function decodeString( p, record ) { 29899 const { platformID: platformID, length: length } = record; 29900 if ( length === 0 ) return ``; 29901 if ( platformID === 0 || platformID === 3 ) { 29902 const str = []; 29903 for ( let i = 0, e = length / 2; i < e; i++ ) 29904 str[ i ] = String.fromCharCode( p.uint16 ); 29905 return str.join( `` ); 29906 } 29907 const bytes = p.readBytes( length ); 29908 const str = []; 29909 bytes.forEach( function ( b, i ) { 29910 str[ i ] = String.fromCharCode( b ); 29911 } ); 29912 return str.join( `` ); 29913 } 29914 var name$1 = Object.freeze( { __proto__: null, name: lib_font_browser_name } ); 29915 class OS2 extends SimpleTable { 29916 constructor( dict, dataview ) { 29917 const { p: p } = super( dict, dataview ); 29918 this.version = p.uint16; 29919 this.xAvgCharWidth = p.int16; 29920 this.usWeightClass = p.uint16; 29921 this.usWidthClass = p.uint16; 29922 this.fsType = p.uint16; 29923 this.ySubscriptXSize = p.int16; 29924 this.ySubscriptYSize = p.int16; 29925 this.ySubscriptXOffset = p.int16; 29926 this.ySubscriptYOffset = p.int16; 29927 this.ySuperscriptXSize = p.int16; 29928 this.ySuperscriptYSize = p.int16; 29929 this.ySuperscriptXOffset = p.int16; 29930 this.ySuperscriptYOffset = p.int16; 29931 this.yStrikeoutSize = p.int16; 29932 this.yStrikeoutPosition = p.int16; 29933 this.sFamilyClass = p.int16; 29934 this.panose = [ ...new Array( 10 ) ].map( ( _ ) => p.uint8 ); 29935 this.ulUnicodeRange1 = p.flags( 32 ); 29936 this.ulUnicodeRange2 = p.flags( 32 ); 29937 this.ulUnicodeRange3 = p.flags( 32 ); 29938 this.ulUnicodeRange4 = p.flags( 32 ); 29939 this.achVendID = p.tag; 29940 this.fsSelection = p.uint16; 29941 this.usFirstCharIndex = p.uint16; 29942 this.usLastCharIndex = p.uint16; 29943 this.sTypoAscender = p.int16; 29944 this.sTypoDescender = p.int16; 29945 this.sTypoLineGap = p.int16; 29946 this.usWinAscent = p.uint16; 29947 this.usWinDescent = p.uint16; 29948 if ( this.version === 0 ) return p.verifyLength(); 29949 this.ulCodePageRange1 = p.flags( 32 ); 29950 this.ulCodePageRange2 = p.flags( 32 ); 29951 if ( this.version === 1 ) return p.verifyLength(); 29952 this.sxHeight = p.int16; 29953 this.sCapHeight = p.int16; 29954 this.usDefaultChar = p.uint16; 29955 this.usBreakChar = p.uint16; 29956 this.usMaxContext = p.uint16; 29957 if ( this.version <= 4 ) return p.verifyLength(); 29958 this.usLowerOpticalPointSize = p.uint16; 29959 this.usUpperOpticalPointSize = p.uint16; 29960 if ( this.version === 5 ) return p.verifyLength(); 29961 } 29962 } 29963 var OS2$1 = Object.freeze( { __proto__: null, OS2: OS2 } ); 29964 class lib_font_browser_post extends SimpleTable { 29965 constructor( dict, dataview ) { 29966 const { p: p } = super( dict, dataview ); 29967 this.version = p.legacyFixed; 29968 this.italicAngle = p.fixed; 29969 this.underlinePosition = p.fword; 29970 this.underlineThickness = p.fword; 29971 this.isFixedPitch = p.uint32; 29972 this.minMemType42 = p.uint32; 29973 this.maxMemType42 = p.uint32; 29974 this.minMemType1 = p.uint32; 29975 this.maxMemType1 = p.uint32; 29976 if ( this.version === 1 || this.version === 3 ) return p.verifyLength(); 29977 this.numGlyphs = p.uint16; 29978 if ( this.version === 2 ) { 29979 this.glyphNameIndex = [ ...new Array( this.numGlyphs ) ].map( 29980 ( _ ) => p.uint16 29981 ); 29982 this.namesOffset = p.currentPosition; 29983 this.glyphNameOffsets = [ 1 ]; 29984 for ( let i = 0; i < this.numGlyphs; i++ ) { 29985 let index = this.glyphNameIndex[ i ]; 29986 if ( index < macStrings.length ) { 29987 this.glyphNameOffsets.push( this.glyphNameOffsets[ i ] ); 29988 continue; 29989 } 29990 let bytelength = p.int8; 29991 p.skip( bytelength ); 29992 this.glyphNameOffsets.push( 29993 this.glyphNameOffsets[ i ] + bytelength + 1 29994 ); 29995 } 29996 } 29997 if ( this.version === 2.5 ) { 29998 this.offset = [ ...new Array( this.numGlyphs ) ].map( 29999 ( _ ) => p.int8 30000 ); 30001 } 30002 } 30003 getGlyphName( glyphid ) { 30004 if ( this.version !== 2 ) { 30005 console.warn( 30006 `post table version ${ this.version } does not support glyph name lookups` 30007 ); 30008 return ``; 30009 } 30010 let index = this.glyphNameIndex[ glyphid ]; 30011 if ( index < 258 ) return macStrings[ index ]; 30012 let offset = this.glyphNameOffsets[ glyphid ]; 30013 let next = this.glyphNameOffsets[ glyphid + 1 ]; 30014 let len = next - offset - 1; 30015 if ( len === 0 ) return `.notdef.`; 30016 this.parser.currentPosition = this.namesOffset + offset; 30017 const data = this.parser.readBytes( 30018 len, 30019 this.namesOffset + offset, 30020 8, 30021 true 30022 ); 30023 return data.map( ( b ) => String.fromCharCode( b ) ).join( `` ); 30024 } 30025 } 30026 const macStrings = [ 30027 `.notdef`, 30028 `.null`, 30029 `nonmarkingreturn`, 30030 `space`, 30031 `exclam`, 30032 `quotedbl`, 30033 `numbersign`, 30034 `dollar`, 30035 `percent`, 30036 `ampersand`, 30037 `quotesingle`, 30038 `parenleft`, 30039 `parenright`, 30040 `asterisk`, 30041 `plus`, 30042 `comma`, 30043 `hyphen`, 30044 `period`, 30045 `slash`, 30046 `zero`, 30047 `one`, 30048 `two`, 30049 `three`, 30050 `four`, 30051 `five`, 30052 `six`, 30053 `seven`, 30054 `eight`, 30055 `nine`, 30056 `colon`, 30057 `semicolon`, 30058 `less`, 30059 `equal`, 30060 `greater`, 30061 `question`, 30062 `at`, 30063 `A`, 30064 `B`, 30065 `C`, 30066 `D`, 30067 `E`, 30068 `F`, 30069 `G`, 30070 `H`, 30071 `I`, 30072 `J`, 30073 `K`, 30074 `L`, 30075 `M`, 30076 `N`, 30077 `O`, 30078 `P`, 30079 `Q`, 30080 `R`, 30081 `S`, 30082 `T`, 30083 `U`, 30084 `V`, 30085 `W`, 30086 `X`, 30087 `Y`, 30088 `Z`, 30089 `bracketleft`, 30090 `backslash`, 30091 `bracketright`, 30092 `asciicircum`, 30093 `underscore`, 30094 `grave`, 30095 `a`, 30096 `b`, 30097 `c`, 30098 `d`, 30099 `e`, 30100 `f`, 30101 `g`, 30102 `h`, 30103 `i`, 30104 `j`, 30105 `k`, 30106 `l`, 30107 `m`, 30108 `n`, 30109 `o`, 30110 `p`, 30111 `q`, 30112 `r`, 30113 `s`, 30114 `t`, 30115 `u`, 30116 `v`, 30117 `w`, 30118 `x`, 30119 `y`, 30120 `z`, 30121 `braceleft`, 30122 `bar`, 30123 `braceright`, 30124 `asciitilde`, 30125 `Adieresis`, 30126 `Aring`, 30127 `Ccedilla`, 30128 `Eacute`, 30129 `Ntilde`, 30130 `Odieresis`, 30131 `Udieresis`, 30132 `aacute`, 30133 `agrave`, 30134 `acircumflex`, 30135 `adieresis`, 30136 `atilde`, 30137 `aring`, 30138 `ccedilla`, 30139 `eacute`, 30140 `egrave`, 30141 `ecircumflex`, 30142 `edieresis`, 30143 `iacute`, 30144 `igrave`, 30145 `icircumflex`, 30146 `idieresis`, 30147 `ntilde`, 30148 `oacute`, 30149 `ograve`, 30150 `ocircumflex`, 30151 `odieresis`, 30152 `otilde`, 30153 `uacute`, 30154 `ugrave`, 30155 `ucircumflex`, 30156 `udieresis`, 30157 `dagger`, 30158 `degree`, 30159 `cent`, 30160 `sterling`, 30161 `section`, 30162 `bullet`, 30163 `paragraph`, 30164 `germandbls`, 30165 `registered`, 30166 `copyright`, 30167 `trademark`, 30168 `acute`, 30169 `dieresis`, 30170 `notequal`, 30171 `AE`, 30172 `Oslash`, 30173 `infinity`, 30174 `plusminus`, 30175 `lessequal`, 30176 `greaterequal`, 30177 `yen`, 30178 `mu`, 30179 `partialdiff`, 30180 `summation`, 30181 `product`, 30182 `pi`, 30183 `integral`, 30184 `ordfeminine`, 30185 `ordmasculine`, 30186 `Omega`, 30187 `ae`, 30188 `oslash`, 30189 `questiondown`, 30190 `exclamdown`, 30191 `logicalnot`, 30192 `radical`, 30193 `florin`, 30194 `approxequal`, 30195 `Delta`, 30196 `guillemotleft`, 30197 `guillemotright`, 30198 `ellipsis`, 30199 `nonbreakingspace`, 30200 `Agrave`, 30201 `Atilde`, 30202 `Otilde`, 30203 `OE`, 30204 `oe`, 30205 `endash`, 30206 `emdash`, 30207 `quotedblleft`, 30208 `quotedblright`, 30209 `quoteleft`, 30210 `quoteright`, 30211 `divide`, 30212 `lozenge`, 30213 `ydieresis`, 30214 `Ydieresis`, 30215 `fraction`, 30216 `currency`, 30217 `guilsinglleft`, 30218 `guilsinglright`, 30219 `fi`, 30220 `fl`, 30221 `daggerdbl`, 30222 `periodcentered`, 30223 `quotesinglbase`, 30224 `quotedblbase`, 30225 `perthousand`, 30226 `Acircumflex`, 30227 `Ecircumflex`, 30228 `Aacute`, 30229 `Edieresis`, 30230 `Egrave`, 30231 `Iacute`, 30232 `Icircumflex`, 30233 `Idieresis`, 30234 `Igrave`, 30235 `Oacute`, 30236 `Ocircumflex`, 30237 `apple`, 30238 `Ograve`, 30239 `Uacute`, 30240 `Ucircumflex`, 30241 `Ugrave`, 30242 `dotlessi`, 30243 `circumflex`, 30244 `tilde`, 30245 `macron`, 30246 `breve`, 30247 `dotaccent`, 30248 `ring`, 30249 `cedilla`, 30250 `hungarumlaut`, 30251 `ogonek`, 30252 `caron`, 30253 `Lslash`, 30254 `lslash`, 30255 `Scaron`, 30256 `scaron`, 30257 `Zcaron`, 30258 `zcaron`, 30259 `brokenbar`, 30260 `Eth`, 30261 `eth`, 30262 `Yacute`, 30263 `yacute`, 30264 `Thorn`, 30265 `thorn`, 30266 `minus`, 30267 `multiply`, 30268 `onesuperior`, 30269 `twosuperior`, 30270 `threesuperior`, 30271 `onehalf`, 30272 `onequarter`, 30273 `threequarters`, 30274 `franc`, 30275 `Gbreve`, 30276 `gbreve`, 30277 `Idotaccent`, 30278 `Scedilla`, 30279 `scedilla`, 30280 `Cacute`, 30281 `cacute`, 30282 `Ccaron`, 30283 `ccaron`, 30284 `dcroat`, 30285 ]; 30286 var post$1 = Object.freeze( { __proto__: null, post: lib_font_browser_post } ); 30287 class BASE extends SimpleTable { 30288 constructor( dict, dataview ) { 30289 const { p: p } = super( dict, dataview ); 30290 this.majorVersion = p.uint16; 30291 this.minorVersion = p.uint16; 30292 this.horizAxisOffset = p.Offset16; 30293 this.vertAxisOffset = p.Offset16; 30294 lazy$1( 30295 this, 30296 `horizAxis`, 30297 () => 30298 new AxisTable( 30299 { offset: dict.offset + this.horizAxisOffset }, 30300 dataview 30301 ) 30302 ); 30303 lazy$1( 30304 this, 30305 `vertAxis`, 30306 () => 30307 new AxisTable( 30308 { offset: dict.offset + this.vertAxisOffset }, 30309 dataview 30310 ) 30311 ); 30312 if ( this.majorVersion === 1 && this.minorVersion === 1 ) { 30313 this.itemVarStoreOffset = p.Offset32; 30314 lazy$1( 30315 this, 30316 `itemVarStore`, 30317 () => 30318 new AxisTable( 30319 { offset: dict.offset + this.itemVarStoreOffset }, 30320 dataview 30321 ) 30322 ); 30323 } 30324 } 30325 } 30326 class AxisTable extends SimpleTable { 30327 constructor( dict, dataview ) { 30328 const { p: p } = super( dict, dataview, `AxisTable` ); 30329 this.baseTagListOffset = p.Offset16; 30330 this.baseScriptListOffset = p.Offset16; 30331 lazy$1( 30332 this, 30333 `baseTagList`, 30334 () => 30335 new BaseTagListTable( 30336 { offset: dict.offset + this.baseTagListOffset }, 30337 dataview 30338 ) 30339 ); 30340 lazy$1( 30341 this, 30342 `baseScriptList`, 30343 () => 30344 new BaseScriptListTable( 30345 { offset: dict.offset + this.baseScriptListOffset }, 30346 dataview 30347 ) 30348 ); 30349 } 30350 } 30351 class BaseTagListTable extends SimpleTable { 30352 constructor( dict, dataview ) { 30353 const { p: p } = super( dict, dataview, `BaseTagListTable` ); 30354 this.baseTagCount = p.uint16; 30355 this.baselineTags = [ ...new Array( this.baseTagCount ) ].map( 30356 ( _ ) => p.tag 30357 ); 30358 } 30359 } 30360 class BaseScriptListTable extends SimpleTable { 30361 constructor( dict, dataview ) { 30362 const { p: p } = super( dict, dataview, `BaseScriptListTable` ); 30363 this.baseScriptCount = p.uint16; 30364 const recordStart = p.currentPosition; 30365 lazy$1( this, `baseScriptRecords`, () => { 30366 p.currentPosition = recordStart; 30367 return [ ...new Array( this.baseScriptCount ) ].map( 30368 ( _ ) => new BaseScriptRecord( this.start, p ) 30369 ); 30370 } ); 30371 } 30372 } 30373 class BaseScriptRecord { 30374 constructor( baseScriptListTableStart, p ) { 30375 this.baseScriptTag = p.tag; 30376 this.baseScriptOffset = p.Offset16; 30377 lazy$1( this, `baseScriptTable`, () => { 30378 p.currentPosition = 30379 baseScriptListTableStart + this.baseScriptOffset; 30380 return new BaseScriptTable( p ); 30381 } ); 30382 } 30383 } 30384 class BaseScriptTable { 30385 constructor( p ) { 30386 this.start = p.currentPosition; 30387 this.baseValuesOffset = p.Offset16; 30388 this.defaultMinMaxOffset = p.Offset16; 30389 this.baseLangSysCount = p.uint16; 30390 this.baseLangSysRecords = [ ...new Array( this.baseLangSysCount ) ].map( 30391 ( _ ) => new BaseLangSysRecord( this.start, p ) 30392 ); 30393 lazy$1( this, `baseValues`, () => { 30394 p.currentPosition = this.start + this.baseValuesOffset; 30395 return new BaseValuesTable( p ); 30396 } ); 30397 lazy$1( this, `defaultMinMax`, () => { 30398 p.currentPosition = this.start + this.defaultMinMaxOffset; 30399 return new MinMaxTable( p ); 30400 } ); 30401 } 30402 } 30403 class BaseLangSysRecord { 30404 constructor( baseScriptTableStart, p ) { 30405 this.baseLangSysTag = p.tag; 30406 this.minMaxOffset = p.Offset16; 30407 lazy$1( this, `minMax`, () => { 30408 p.currentPosition = baseScriptTableStart + this.minMaxOffset; 30409 return new MinMaxTable( p ); 30410 } ); 30411 } 30412 } 30413 class BaseValuesTable { 30414 constructor( p ) { 30415 this.parser = p; 30416 this.start = p.currentPosition; 30417 this.defaultBaselineIndex = p.uint16; 30418 this.baseCoordCount = p.uint16; 30419 this.baseCoords = [ ...new Array( this.baseCoordCount ) ].map( 30420 ( _ ) => p.Offset16 30421 ); 30422 } 30423 getTable( id ) { 30424 this.parser.currentPosition = this.start + this.baseCoords[ id ]; 30425 return new BaseCoordTable( this.parser ); 30426 } 30427 } 30428 class MinMaxTable { 30429 constructor( p ) { 30430 this.minCoord = p.Offset16; 30431 this.maxCoord = p.Offset16; 30432 this.featMinMaxCount = p.uint16; 30433 const recordStart = p.currentPosition; 30434 lazy$1( this, `featMinMaxRecords`, () => { 30435 p.currentPosition = recordStart; 30436 return [ ...new Array( this.featMinMaxCount ) ].map( 30437 ( _ ) => new FeatMinMaxRecord( p ) 30438 ); 30439 } ); 30440 } 30441 } 30442 class FeatMinMaxRecord { 30443 constructor( p ) { 30444 this.featureTableTag = p.tag; 30445 this.minCoord = p.Offset16; 30446 this.maxCoord = p.Offset16; 30447 } 30448 } 30449 class BaseCoordTable { 30450 constructor( p ) { 30451 this.baseCoordFormat = p.uint16; 30452 this.coordinate = p.int16; 30453 if ( this.baseCoordFormat === 2 ) { 30454 this.referenceGlyph = p.uint16; 30455 this.baseCoordPoint = p.uint16; 30456 } 30457 if ( this.baseCoordFormat === 3 ) { 30458 this.deviceTable = p.Offset16; 30459 } 30460 } 30461 } 30462 var BASE$1 = Object.freeze( { __proto__: null, BASE: BASE } ); 30463 class ClassDefinition { 30464 constructor( p ) { 30465 this.classFormat = p.uint16; 30466 if ( this.classFormat === 1 ) { 30467 this.startGlyphID = p.uint16; 30468 this.glyphCount = p.uint16; 30469 this.classValueArray = [ ...new Array( this.glyphCount ) ].map( 30470 ( _ ) => p.uint16 30471 ); 30472 } 30473 if ( this.classFormat === 2 ) { 30474 this.classRangeCount = p.uint16; 30475 this.classRangeRecords = [ 30476 ...new Array( this.classRangeCount ), 30477 ].map( ( _ ) => new ClassRangeRecord( p ) ); 30478 } 30479 } 30480 } 30481 class ClassRangeRecord { 30482 constructor( p ) { 30483 this.startGlyphID = p.uint16; 30484 this.endGlyphID = p.uint16; 30485 this.class = p.uint16; 30486 } 30487 } 30488 class CoverageTable extends ParsedData { 30489 constructor( p ) { 30490 super( p ); 30491 this.coverageFormat = p.uint16; 30492 if ( this.coverageFormat === 1 ) { 30493 this.glyphCount = p.uint16; 30494 this.glyphArray = [ ...new Array( this.glyphCount ) ].map( 30495 ( _ ) => p.uint16 30496 ); 30497 } 30498 if ( this.coverageFormat === 2 ) { 30499 this.rangeCount = p.uint16; 30500 this.rangeRecords = [ ...new Array( this.rangeCount ) ].map( 30501 ( _ ) => new CoverageRangeRecord( p ) 30502 ); 30503 } 30504 } 30505 } 30506 class CoverageRangeRecord { 30507 constructor( p ) { 30508 this.startGlyphID = p.uint16; 30509 this.endGlyphID = p.uint16; 30510 this.startCoverageIndex = p.uint16; 30511 } 30512 } 30513 class ItemVariationStoreTable { 30514 constructor( table, p ) { 30515 this.table = table; 30516 this.parser = p; 30517 this.start = p.currentPosition; 30518 this.format = p.uint16; 30519 this.variationRegionListOffset = p.Offset32; 30520 this.itemVariationDataCount = p.uint16; 30521 this.itemVariationDataOffsets = [ 30522 ...new Array( this.itemVariationDataCount ), 30523 ].map( ( _ ) => p.Offset32 ); 30524 } 30525 } 30526 class GDEF extends SimpleTable { 30527 constructor( dict, dataview ) { 30528 const { p: p } = super( dict, dataview ); 30529 this.majorVersion = p.uint16; 30530 this.minorVersion = p.uint16; 30531 this.glyphClassDefOffset = p.Offset16; 30532 lazy$1( this, `glyphClassDefs`, () => { 30533 if ( this.glyphClassDefOffset === 0 ) return undefined; 30534 p.currentPosition = this.tableStart + this.glyphClassDefOffset; 30535 return new ClassDefinition( p ); 30536 } ); 30537 this.attachListOffset = p.Offset16; 30538 lazy$1( this, `attachList`, () => { 30539 if ( this.attachListOffset === 0 ) return undefined; 30540 p.currentPosition = this.tableStart + this.attachListOffset; 30541 return new AttachList( p ); 30542 } ); 30543 this.ligCaretListOffset = p.Offset16; 30544 lazy$1( this, `ligCaretList`, () => { 30545 if ( this.ligCaretListOffset === 0 ) return undefined; 30546 p.currentPosition = this.tableStart + this.ligCaretListOffset; 30547 return new LigCaretList( p ); 30548 } ); 30549 this.markAttachClassDefOffset = p.Offset16; 30550 lazy$1( this, `markAttachClassDef`, () => { 30551 if ( this.markAttachClassDefOffset === 0 ) return undefined; 30552 p.currentPosition = this.tableStart + this.markAttachClassDefOffset; 30553 return new ClassDefinition( p ); 30554 } ); 30555 if ( this.minorVersion >= 2 ) { 30556 this.markGlyphSetsDefOffset = p.Offset16; 30557 lazy$1( this, `markGlyphSetsDef`, () => { 30558 if ( this.markGlyphSetsDefOffset === 0 ) return undefined; 30559 p.currentPosition = 30560 this.tableStart + this.markGlyphSetsDefOffset; 30561 return new MarkGlyphSetsTable( p ); 30562 } ); 30563 } 30564 if ( this.minorVersion === 3 ) { 30565 this.itemVarStoreOffset = p.Offset32; 30566 lazy$1( this, `itemVarStore`, () => { 30567 if ( this.itemVarStoreOffset === 0 ) return undefined; 30568 p.currentPosition = this.tableStart + this.itemVarStoreOffset; 30569 return new ItemVariationStoreTable( p ); 30570 } ); 30571 } 30572 } 30573 } 30574 class AttachList extends ParsedData { 30575 constructor( p ) { 30576 super( p ); 30577 this.coverageOffset = p.Offset16; 30578 this.glyphCount = p.uint16; 30579 this.attachPointOffsets = [ ...new Array( this.glyphCount ) ].map( 30580 ( _ ) => p.Offset16 30581 ); 30582 } 30583 getPoint( pointID ) { 30584 this.parser.currentPosition = 30585 this.start + this.attachPointOffsets[ pointID ]; 30586 return new AttachPoint( this.parser ); 30587 } 30588 } 30589 class AttachPoint { 30590 constructor( p ) { 30591 this.pointCount = p.uint16; 30592 this.pointIndices = [ ...new Array( this.pointCount ) ].map( 30593 ( _ ) => p.uint16 30594 ); 30595 } 30596 } 30597 class LigCaretList extends ParsedData { 30598 constructor( p ) { 30599 super( p ); 30600 this.coverageOffset = p.Offset16; 30601 lazy$1( this, `coverage`, () => { 30602 p.currentPosition = this.start + this.coverageOffset; 30603 return new CoverageTable( p ); 30604 } ); 30605 this.ligGlyphCount = p.uint16; 30606 this.ligGlyphOffsets = [ ...new Array( this.ligGlyphCount ) ].map( 30607 ( _ ) => p.Offset16 30608 ); 30609 } 30610 getLigGlyph( ligGlyphID ) { 30611 this.parser.currentPosition = 30612 this.start + this.ligGlyphOffsets[ ligGlyphID ]; 30613 return new LigGlyph( this.parser ); 30614 } 30615 } 30616 class LigGlyph extends ParsedData { 30617 constructor( p ) { 30618 super( p ); 30619 this.caretCount = p.uint16; 30620 this.caretValueOffsets = [ ...new Array( this.caretCount ) ].map( 30621 ( _ ) => p.Offset16 30622 ); 30623 } 30624 getCaretValue( caretID ) { 30625 this.parser.currentPosition = 30626 this.start + this.caretValueOffsets[ caretID ]; 30627 return new CaretValue( this.parser ); 30628 } 30629 } 30630 class CaretValue { 30631 constructor( p ) { 30632 this.caretValueFormat = p.uint16; 30633 if ( this.caretValueFormat === 1 ) { 30634 this.coordinate = p.int16; 30635 } 30636 if ( this.caretValueFormat === 2 ) { 30637 this.caretValuePointIndex = p.uint16; 30638 } 30639 if ( this.caretValueFormat === 3 ) { 30640 this.coordinate = p.int16; 30641 this.deviceOffset = p.Offset16; 30642 } 30643 } 30644 } 30645 class MarkGlyphSetsTable extends ParsedData { 30646 constructor( p ) { 30647 super( p ); 30648 this.markGlyphSetTableFormat = p.uint16; 30649 this.markGlyphSetCount = p.uint16; 30650 this.coverageOffsets = [ ...new Array( this.markGlyphSetCount ) ].map( 30651 ( _ ) => p.Offset32 30652 ); 30653 } 30654 getMarkGlyphSet( markGlyphSetID ) { 30655 this.parser.currentPosition = 30656 this.start + this.coverageOffsets[ markGlyphSetID ]; 30657 return new CoverageTable( this.parser ); 30658 } 30659 } 30660 var GDEF$1 = Object.freeze( { __proto__: null, GDEF: GDEF } ); 30661 class ScriptList extends ParsedData { 30662 static EMPTY = { scriptCount: 0, scriptRecords: [] }; 30663 constructor( p ) { 30664 super( p ); 30665 this.scriptCount = p.uint16; 30666 this.scriptRecords = [ ...new Array( this.scriptCount ) ].map( 30667 ( _ ) => new ScriptRecord( p ) 30668 ); 30669 } 30670 } 30671 class ScriptRecord { 30672 constructor( p ) { 30673 this.scriptTag = p.tag; 30674 this.scriptOffset = p.Offset16; 30675 } 30676 } 30677 class ScriptTable extends ParsedData { 30678 constructor( p ) { 30679 super( p ); 30680 this.defaultLangSys = p.Offset16; 30681 this.langSysCount = p.uint16; 30682 this.langSysRecords = [ ...new Array( this.langSysCount ) ].map( 30683 ( _ ) => new LangSysRecord( p ) 30684 ); 30685 } 30686 } 30687 class LangSysRecord { 30688 constructor( p ) { 30689 this.langSysTag = p.tag; 30690 this.langSysOffset = p.Offset16; 30691 } 30692 } 30693 class LangSysTable { 30694 constructor( p ) { 30695 this.lookupOrder = p.Offset16; 30696 this.requiredFeatureIndex = p.uint16; 30697 this.featureIndexCount = p.uint16; 30698 this.featureIndices = [ ...new Array( this.featureIndexCount ) ].map( 30699 ( _ ) => p.uint16 30700 ); 30701 } 30702 } 30703 class FeatureList extends ParsedData { 30704 static EMPTY = { featureCount: 0, featureRecords: [] }; 30705 constructor( p ) { 30706 super( p ); 30707 this.featureCount = p.uint16; 30708 this.featureRecords = [ ...new Array( this.featureCount ) ].map( 30709 ( _ ) => new FeatureRecord( p ) 30710 ); 30711 } 30712 } 30713 class FeatureRecord { 30714 constructor( p ) { 30715 this.featureTag = p.tag; 30716 this.featureOffset = p.Offset16; 30717 } 30718 } 30719 class FeatureTable extends ParsedData { 30720 constructor( p ) { 30721 super( p ); 30722 this.featureParams = p.Offset16; 30723 this.lookupIndexCount = p.uint16; 30724 this.lookupListIndices = [ ...new Array( this.lookupIndexCount ) ].map( 30725 ( _ ) => p.uint16 30726 ); 30727 } 30728 getFeatureParams() { 30729 if ( this.featureParams > 0 ) { 30730 const p = this.parser; 30731 p.currentPosition = this.start + this.featureParams; 30732 const tag = this.featureTag; 30733 if ( tag === `size` ) return new Size( p ); 30734 if ( tag.startsWith( `cc` ) ) return new CharacterVariant( p ); 30735 if ( tag.startsWith( `ss` ) ) return new StylisticSet( p ); 30736 } 30737 } 30738 } 30739 class CharacterVariant { 30740 constructor( p ) { 30741 this.format = p.uint16; 30742 this.featUiLabelNameId = p.uint16; 30743 this.featUiTooltipTextNameId = p.uint16; 30744 this.sampleTextNameId = p.uint16; 30745 this.numNamedParameters = p.uint16; 30746 this.firstParamUiLabelNameId = p.uint16; 30747 this.charCount = p.uint16; 30748 this.character = [ ...new Array( this.charCount ) ].map( 30749 ( _ ) => p.uint24 30750 ); 30751 } 30752 } 30753 class Size { 30754 constructor( p ) { 30755 this.designSize = p.uint16; 30756 this.subfamilyIdentifier = p.uint16; 30757 this.subfamilyNameID = p.uint16; 30758 this.smallEnd = p.uint16; 30759 this.largeEnd = p.uint16; 30760 } 30761 } 30762 class StylisticSet { 30763 constructor( p ) { 30764 this.version = p.uint16; 30765 this.UINameID = p.uint16; 30766 } 30767 } 30768 function undoCoverageOffsetParsing( instance ) { 30769 instance.parser.currentPosition -= 2; 30770 delete instance.coverageOffset; 30771 delete instance.getCoverageTable; 30772 } 30773 class LookupType$1 extends ParsedData { 30774 constructor( p ) { 30775 super( p ); 30776 this.substFormat = p.uint16; 30777 this.coverageOffset = p.Offset16; 30778 } 30779 getCoverageTable() { 30780 let p = this.parser; 30781 p.currentPosition = this.start + this.coverageOffset; 30782 return new CoverageTable( p ); 30783 } 30784 } 30785 class SubstLookupRecord { 30786 constructor( p ) { 30787 this.glyphSequenceIndex = p.uint16; 30788 this.lookupListIndex = p.uint16; 30789 } 30790 } 30791 class LookupType1$1 extends LookupType$1 { 30792 constructor( p ) { 30793 super( p ); 30794 this.deltaGlyphID = p.int16; 30795 } 30796 } 30797 class LookupType2$1 extends LookupType$1 { 30798 constructor( p ) { 30799 super( p ); 30800 this.sequenceCount = p.uint16; 30801 this.sequenceOffsets = [ ...new Array( this.sequenceCount ) ].map( 30802 ( _ ) => p.Offset16 30803 ); 30804 } 30805 getSequence( index ) { 30806 let p = this.parser; 30807 p.currentPosition = this.start + this.sequenceOffsets[ index ]; 30808 return new SequenceTable( p ); 30809 } 30810 } 30811 class SequenceTable { 30812 constructor( p ) { 30813 this.glyphCount = p.uint16; 30814 this.substituteGlyphIDs = [ ...new Array( this.glyphCount ) ].map( 30815 ( _ ) => p.uint16 30816 ); 30817 } 30818 } 30819 class LookupType3$1 extends LookupType$1 { 30820 constructor( p ) { 30821 super( p ); 30822 this.alternateSetCount = p.uint16; 30823 this.alternateSetOffsets = [ 30824 ...new Array( this.alternateSetCount ), 30825 ].map( ( _ ) => p.Offset16 ); 30826 } 30827 getAlternateSet( index ) { 30828 let p = this.parser; 30829 p.currentPosition = this.start + this.alternateSetOffsets[ index ]; 30830 return new AlternateSetTable( p ); 30831 } 30832 } 30833 class AlternateSetTable { 30834 constructor( p ) { 30835 this.glyphCount = p.uint16; 30836 this.alternateGlyphIDs = [ ...new Array( this.glyphCount ) ].map( 30837 ( _ ) => p.uint16 30838 ); 30839 } 30840 } 30841 class LookupType4$1 extends LookupType$1 { 30842 constructor( p ) { 30843 super( p ); 30844 this.ligatureSetCount = p.uint16; 30845 this.ligatureSetOffsets = [ ...new Array( this.ligatureSetCount ) ].map( 30846 ( _ ) => p.Offset16 30847 ); 30848 } 30849 getLigatureSet( index ) { 30850 let p = this.parser; 30851 p.currentPosition = this.start + this.ligatureSetOffsets[ index ]; 30852 return new LigatureSetTable( p ); 30853 } 30854 } 30855 class LigatureSetTable extends ParsedData { 30856 constructor( p ) { 30857 super( p ); 30858 this.ligatureCount = p.uint16; 30859 this.ligatureOffsets = [ ...new Array( this.ligatureCount ) ].map( 30860 ( _ ) => p.Offset16 30861 ); 30862 } 30863 getLigature( index ) { 30864 let p = this.parser; 30865 p.currentPosition = this.start + this.ligatureOffsets[ index ]; 30866 return new LigatureTable( p ); 30867 } 30868 } 30869 class LigatureTable { 30870 constructor( p ) { 30871 this.ligatureGlyph = p.uint16; 30872 this.componentCount = p.uint16; 30873 this.componentGlyphIDs = [ 30874 ...new Array( this.componentCount - 1 ), 30875 ].map( ( _ ) => p.uint16 ); 30876 } 30877 } 30878 class LookupType5$1 extends LookupType$1 { 30879 constructor( p ) { 30880 super( p ); 30881 if ( this.substFormat === 1 ) { 30882 this.subRuleSetCount = p.uint16; 30883 this.subRuleSetOffsets = [ 30884 ...new Array( this.subRuleSetCount ), 30885 ].map( ( _ ) => p.Offset16 ); 30886 } 30887 if ( this.substFormat === 2 ) { 30888 this.classDefOffset = p.Offset16; 30889 this.subClassSetCount = p.uint16; 30890 this.subClassSetOffsets = [ 30891 ...new Array( this.subClassSetCount ), 30892 ].map( ( _ ) => p.Offset16 ); 30893 } 30894 if ( this.substFormat === 3 ) { 30895 undoCoverageOffsetParsing( this ); 30896 this.glyphCount = p.uint16; 30897 this.substitutionCount = p.uint16; 30898 this.coverageOffsets = [ ...new Array( this.glyphCount ) ].map( 30899 ( _ ) => p.Offset16 30900 ); 30901 this.substLookupRecords = [ 30902 ...new Array( this.substitutionCount ), 30903 ].map( ( _ ) => new SubstLookupRecord( p ) ); 30904 } 30905 } 30906 getSubRuleSet( index ) { 30907 if ( this.substFormat !== 1 ) 30908 throw new Error( 30909 `lookup type 5.${ this.substFormat } has no subrule sets.` 30910 ); 30911 let p = this.parser; 30912 p.currentPosition = this.start + this.subRuleSetOffsets[ index ]; 30913 return new SubRuleSetTable( p ); 30914 } 30915 getSubClassSet( index ) { 30916 if ( this.substFormat !== 2 ) 30917 throw new Error( 30918 `lookup type 5.${ this.substFormat } has no subclass sets.` 30919 ); 30920 let p = this.parser; 30921 p.currentPosition = this.start + this.subClassSetOffsets[ index ]; 30922 return new SubClassSetTable( p ); 30923 } 30924 getCoverageTable( index ) { 30925 if ( this.substFormat !== 3 && ! index ) 30926 return super.getCoverageTable(); 30927 if ( ! index ) 30928 throw new Error( 30929 `lookup type 5.${ this.substFormat } requires an coverage table index.` 30930 ); 30931 let p = this.parser; 30932 p.currentPosition = this.start + this.coverageOffsets[ index ]; 30933 return new CoverageTable( p ); 30934 } 30935 } 30936 class SubRuleSetTable extends ParsedData { 30937 constructor( p ) { 30938 super( p ); 30939 this.subRuleCount = p.uint16; 30940 this.subRuleOffsets = [ ...new Array( this.subRuleCount ) ].map( 30941 ( _ ) => p.Offset16 30942 ); 30943 } 30944 getSubRule( index ) { 30945 let p = this.parser; 30946 p.currentPosition = this.start + this.subRuleOffsets[ index ]; 30947 return new SubRuleTable( p ); 30948 } 30949 } 30950 class SubRuleTable { 30951 constructor( p ) { 30952 this.glyphCount = p.uint16; 30953 this.substitutionCount = p.uint16; 30954 this.inputSequence = [ ...new Array( this.glyphCount - 1 ) ].map( 30955 ( _ ) => p.uint16 30956 ); 30957 this.substLookupRecords = [ 30958 ...new Array( this.substitutionCount ), 30959 ].map( ( _ ) => new SubstLookupRecord( p ) ); 30960 } 30961 } 30962 class SubClassSetTable extends ParsedData { 30963 constructor( p ) { 30964 super( p ); 30965 this.subClassRuleCount = p.uint16; 30966 this.subClassRuleOffsets = [ 30967 ...new Array( this.subClassRuleCount ), 30968 ].map( ( _ ) => p.Offset16 ); 30969 } 30970 getSubClass( index ) { 30971 let p = this.parser; 30972 p.currentPosition = this.start + this.subClassRuleOffsets[ index ]; 30973 return new SubClassRuleTable( p ); 30974 } 30975 } 30976 class SubClassRuleTable extends SubRuleTable { 30977 constructor( p ) { 30978 super( p ); 30979 } 30980 } 30981 class LookupType6$1 extends LookupType$1 { 30982 constructor( p ) { 30983 super( p ); 30984 if ( this.substFormat === 1 ) { 30985 this.chainSubRuleSetCount = p.uint16; 30986 this.chainSubRuleSetOffsets = [ 30987 ...new Array( this.chainSubRuleSetCount ), 30988 ].map( ( _ ) => p.Offset16 ); 30989 } 30990 if ( this.substFormat === 2 ) { 30991 this.backtrackClassDefOffset = p.Offset16; 30992 this.inputClassDefOffset = p.Offset16; 30993 this.lookaheadClassDefOffset = p.Offset16; 30994 this.chainSubClassSetCount = p.uint16; 30995 this.chainSubClassSetOffsets = [ 30996 ...new Array( this.chainSubClassSetCount ), 30997 ].map( ( _ ) => p.Offset16 ); 30998 } 30999 if ( this.substFormat === 3 ) { 31000 undoCoverageOffsetParsing( this ); 31001 this.backtrackGlyphCount = p.uint16; 31002 this.backtrackCoverageOffsets = [ 31003 ...new Array( this.backtrackGlyphCount ), 31004 ].map( ( _ ) => p.Offset16 ); 31005 this.inputGlyphCount = p.uint16; 31006 this.inputCoverageOffsets = [ 31007 ...new Array( this.inputGlyphCount ), 31008 ].map( ( _ ) => p.Offset16 ); 31009 this.lookaheadGlyphCount = p.uint16; 31010 this.lookaheadCoverageOffsets = [ 31011 ...new Array( this.lookaheadGlyphCount ), 31012 ].map( ( _ ) => p.Offset16 ); 31013 this.seqLookupCount = p.uint16; 31014 this.seqLookupRecords = [ 31015 ...new Array( this.substitutionCount ), 31016 ].map( ( _ ) => new SequenceLookupRecord( p ) ); 31017 } 31018 } 31019 getChainSubRuleSet( index ) { 31020 if ( this.substFormat !== 1 ) 31021 throw new Error( 31022 `lookup type 6.${ this.substFormat } has no chainsubrule sets.` 31023 ); 31024 let p = this.parser; 31025 p.currentPosition = this.start + this.chainSubRuleSetOffsets[ index ]; 31026 return new ChainSubRuleSetTable( p ); 31027 } 31028 getChainSubClassSet( index ) { 31029 if ( this.substFormat !== 2 ) 31030 throw new Error( 31031 `lookup type 6.${ this.substFormat } has no chainsubclass sets.` 31032 ); 31033 let p = this.parser; 31034 p.currentPosition = this.start + this.chainSubClassSetOffsets[ index ]; 31035 return new ChainSubClassSetTable( p ); 31036 } 31037 getCoverageFromOffset( offset ) { 31038 if ( this.substFormat !== 3 ) 31039 throw new Error( 31040 `lookup type 6.${ this.substFormat } does not use contextual coverage offsets.` 31041 ); 31042 let p = this.parser; 31043 p.currentPosition = this.start + offset; 31044 return new CoverageTable( p ); 31045 } 31046 } 31047 class ChainSubRuleSetTable extends ParsedData { 31048 constructor( p ) { 31049 super( p ); 31050 this.chainSubRuleCount = p.uint16; 31051 this.chainSubRuleOffsets = [ 31052 ...new Array( this.chainSubRuleCount ), 31053 ].map( ( _ ) => p.Offset16 ); 31054 } 31055 getSubRule( index ) { 31056 let p = this.parser; 31057 p.currentPosition = this.start + this.chainSubRuleOffsets[ index ]; 31058 return new ChainSubRuleTable( p ); 31059 } 31060 } 31061 class ChainSubRuleTable { 31062 constructor( p ) { 31063 this.backtrackGlyphCount = p.uint16; 31064 this.backtrackSequence = [ 31065 ...new Array( this.backtrackGlyphCount ), 31066 ].map( ( _ ) => p.uint16 ); 31067 this.inputGlyphCount = p.uint16; 31068 this.inputSequence = [ ...new Array( this.inputGlyphCount - 1 ) ].map( 31069 ( _ ) => p.uint16 31070 ); 31071 this.lookaheadGlyphCount = p.uint16; 31072 this.lookAheadSequence = [ 31073 ...new Array( this.lookAheadGlyphCount ), 31074 ].map( ( _ ) => p.uint16 ); 31075 this.substitutionCount = p.uint16; 31076 this.substLookupRecords = [ ...new Array( this.SubstCount ) ].map( 31077 ( _ ) => new SubstLookupRecord( p ) 31078 ); 31079 } 31080 } 31081 class ChainSubClassSetTable extends ParsedData { 31082 constructor( p ) { 31083 super( p ); 31084 this.chainSubClassRuleCount = p.uint16; 31085 this.chainSubClassRuleOffsets = [ 31086 ...new Array( this.chainSubClassRuleCount ), 31087 ].map( ( _ ) => p.Offset16 ); 31088 } 31089 getSubClass( index ) { 31090 let p = this.parser; 31091 p.currentPosition = this.start + this.chainSubRuleOffsets[ index ]; 31092 return new ChainSubClassRuleTable( p ); 31093 } 31094 } 31095 class ChainSubClassRuleTable { 31096 constructor( p ) { 31097 this.backtrackGlyphCount = p.uint16; 31098 this.backtrackSequence = [ 31099 ...new Array( this.backtrackGlyphCount ), 31100 ].map( ( _ ) => p.uint16 ); 31101 this.inputGlyphCount = p.uint16; 31102 this.inputSequence = [ ...new Array( this.inputGlyphCount - 1 ) ].map( 31103 ( _ ) => p.uint16 31104 ); 31105 this.lookaheadGlyphCount = p.uint16; 31106 this.lookAheadSequence = [ 31107 ...new Array( this.lookAheadGlyphCount ), 31108 ].map( ( _ ) => p.uint16 ); 31109 this.substitutionCount = p.uint16; 31110 this.substLookupRecords = [ 31111 ...new Array( this.substitutionCount ), 31112 ].map( ( _ ) => new SequenceLookupRecord( p ) ); 31113 } 31114 } 31115 class SequenceLookupRecord extends ParsedData { 31116 constructor( p ) { 31117 super( p ); 31118 this.sequenceIndex = p.uint16; 31119 this.lookupListIndex = p.uint16; 31120 } 31121 } 31122 class LookupType7$1 extends ParsedData { 31123 constructor( p ) { 31124 super( p ); 31125 this.substFormat = p.uint16; 31126 this.extensionLookupType = p.uint16; 31127 this.extensionOffset = p.Offset32; 31128 } 31129 } 31130 class LookupType8$1 extends LookupType$1 { 31131 constructor( p ) { 31132 super( p ); 31133 this.backtrackGlyphCount = p.uint16; 31134 this.backtrackCoverageOffsets = [ 31135 ...new Array( this.backtrackGlyphCount ), 31136 ].map( ( _ ) => p.Offset16 ); 31137 this.lookaheadGlyphCount = p.uint16; 31138 this.lookaheadCoverageOffsets = [ 31139 new Array( this.lookaheadGlyphCount ), 31140 ].map( ( _ ) => p.Offset16 ); 31141 this.glyphCount = p.uint16; 31142 this.substituteGlyphIDs = [ ...new Array( this.glyphCount ) ].map( 31143 ( _ ) => p.uint16 31144 ); 31145 } 31146 } 31147 var GSUBtables = { 31148 buildSubtable: function ( type, p ) { 31149 const subtable = new [ 31150 undefined, 31151 LookupType1$1, 31152 LookupType2$1, 31153 LookupType3$1, 31154 LookupType4$1, 31155 LookupType5$1, 31156 LookupType6$1, 31157 LookupType7$1, 31158 LookupType8$1, 31159 ][ type ]( p ); 31160 subtable.type = type; 31161 return subtable; 31162 }, 31163 }; 31164 class LookupType extends ParsedData { 31165 constructor( p ) { 31166 super( p ); 31167 } 31168 } 31169 class LookupType1 extends LookupType { 31170 constructor( p ) { 31171 super( p ); 31172 console.log( `lookup type 1` ); 31173 } 31174 } 31175 class LookupType2 extends LookupType { 31176 constructor( p ) { 31177 super( p ); 31178 console.log( `lookup type 2` ); 31179 } 31180 } 31181 class LookupType3 extends LookupType { 31182 constructor( p ) { 31183 super( p ); 31184 console.log( `lookup type 3` ); 31185 } 31186 } 31187 class LookupType4 extends LookupType { 31188 constructor( p ) { 31189 super( p ); 31190 console.log( `lookup type 4` ); 31191 } 31192 } 31193 class LookupType5 extends LookupType { 31194 constructor( p ) { 31195 super( p ); 31196 console.log( `lookup type 5` ); 31197 } 31198 } 31199 class LookupType6 extends LookupType { 31200 constructor( p ) { 31201 super( p ); 31202 console.log( `lookup type 6` ); 31203 } 31204 } 31205 class LookupType7 extends LookupType { 31206 constructor( p ) { 31207 super( p ); 31208 console.log( `lookup type 7` ); 31209 } 31210 } 31211 class LookupType8 extends LookupType { 31212 constructor( p ) { 31213 super( p ); 31214 console.log( `lookup type 8` ); 31215 } 31216 } 31217 class LookupType9 extends LookupType { 31218 constructor( p ) { 31219 super( p ); 31220 console.log( `lookup type 9` ); 31221 } 31222 } 31223 var GPOStables = { 31224 buildSubtable: function ( type, p ) { 31225 const subtable = new [ 31226 undefined, 31227 LookupType1, 31228 LookupType2, 31229 LookupType3, 31230 LookupType4, 31231 LookupType5, 31232 LookupType6, 31233 LookupType7, 31234 LookupType8, 31235 LookupType9, 31236 ][ type ]( p ); 31237 subtable.type = type; 31238 return subtable; 31239 }, 31240 }; 31241 class LookupList extends ParsedData { 31242 static EMPTY = { lookupCount: 0, lookups: [] }; 31243 constructor( p ) { 31244 super( p ); 31245 this.lookupCount = p.uint16; 31246 this.lookups = [ ...new Array( this.lookupCount ) ].map( 31247 ( _ ) => p.Offset16 31248 ); 31249 } 31250 } 31251 class LookupTable extends ParsedData { 31252 constructor( p, type ) { 31253 super( p ); 31254 this.ctType = type; 31255 this.lookupType = p.uint16; 31256 this.lookupFlag = p.uint16; 31257 this.subTableCount = p.uint16; 31258 this.subtableOffsets = [ ...new Array( this.subTableCount ) ].map( 31259 ( _ ) => p.Offset16 31260 ); 31261 this.markFilteringSet = p.uint16; 31262 } 31263 get rightToLeft() { 31264 return this.lookupFlag & ( 1 === 1 ); 31265 } 31266 get ignoreBaseGlyphs() { 31267 return this.lookupFlag & ( 2 === 2 ); 31268 } 31269 get ignoreLigatures() { 31270 return this.lookupFlag & ( 4 === 4 ); 31271 } 31272 get ignoreMarks() { 31273 return this.lookupFlag & ( 8 === 8 ); 31274 } 31275 get useMarkFilteringSet() { 31276 return this.lookupFlag & ( 16 === 16 ); 31277 } 31278 get markAttachmentType() { 31279 return this.lookupFlag & ( 65280 === 65280 ); 31280 } 31281 getSubTable( index ) { 31282 const builder = this.ctType === `GSUB` ? GSUBtables : GPOStables; 31283 this.parser.currentPosition = 31284 this.start + this.subtableOffsets[ index ]; 31285 return builder.buildSubtable( this.lookupType, this.parser ); 31286 } 31287 } 31288 class CommonLayoutTable extends SimpleTable { 31289 constructor( dict, dataview, name ) { 31290 const { p: p, tableStart: tableStart } = super( dict, dataview, name ); 31291 this.majorVersion = p.uint16; 31292 this.minorVersion = p.uint16; 31293 this.scriptListOffset = p.Offset16; 31294 this.featureListOffset = p.Offset16; 31295 this.lookupListOffset = p.Offset16; 31296 if ( this.majorVersion === 1 && this.minorVersion === 1 ) { 31297 this.featureVariationsOffset = p.Offset32; 31298 } 31299 const no_content = ! ( 31300 this.scriptListOffset || 31301 this.featureListOffset || 31302 this.lookupListOffset 31303 ); 31304 lazy$1( this, `scriptList`, () => { 31305 if ( no_content ) return ScriptList.EMPTY; 31306 p.currentPosition = tableStart + this.scriptListOffset; 31307 return new ScriptList( p ); 31308 } ); 31309 lazy$1( this, `featureList`, () => { 31310 if ( no_content ) return FeatureList.EMPTY; 31311 p.currentPosition = tableStart + this.featureListOffset; 31312 return new FeatureList( p ); 31313 } ); 31314 lazy$1( this, `lookupList`, () => { 31315 if ( no_content ) return LookupList.EMPTY; 31316 p.currentPosition = tableStart + this.lookupListOffset; 31317 return new LookupList( p ); 31318 } ); 31319 if ( this.featureVariationsOffset ) { 31320 lazy$1( this, `featureVariations`, () => { 31321 if ( no_content ) return FeatureVariations.EMPTY; 31322 p.currentPosition = tableStart + this.featureVariationsOffset; 31323 return new FeatureVariations( p ); 31324 } ); 31325 } 31326 } 31327 getSupportedScripts() { 31328 return this.scriptList.scriptRecords.map( ( r ) => r.scriptTag ); 31329 } 31330 getScriptTable( scriptTag ) { 31331 let record = this.scriptList.scriptRecords.find( 31332 ( r ) => r.scriptTag === scriptTag 31333 ); 31334 this.parser.currentPosition = 31335 this.scriptList.start + record.scriptOffset; 31336 let table = new ScriptTable( this.parser ); 31337 table.scriptTag = scriptTag; 31338 return table; 31339 } 31340 ensureScriptTable( arg ) { 31341 if ( typeof arg === 'string' ) { 31342 return this.getScriptTable( arg ); 31343 } 31344 return arg; 31345 } 31346 getSupportedLangSys( scriptTable ) { 31347 scriptTable = this.ensureScriptTable( scriptTable ); 31348 const hasDefault = scriptTable.defaultLangSys !== 0; 31349 const supported = scriptTable.langSysRecords.map( 31350 ( l ) => l.langSysTag 31351 ); 31352 if ( hasDefault ) supported.unshift( `dflt` ); 31353 return supported; 31354 } 31355 getDefaultLangSysTable( scriptTable ) { 31356 scriptTable = this.ensureScriptTable( scriptTable ); 31357 let offset = scriptTable.defaultLangSys; 31358 if ( offset !== 0 ) { 31359 this.parser.currentPosition = scriptTable.start + offset; 31360 let table = new LangSysTable( this.parser ); 31361 table.langSysTag = ``; 31362 table.defaultForScript = scriptTable.scriptTag; 31363 return table; 31364 } 31365 } 31366 getLangSysTable( scriptTable, langSysTag = `dflt` ) { 31367 if ( langSysTag === `dflt` ) 31368 return this.getDefaultLangSysTable( scriptTable ); 31369 scriptTable = this.ensureScriptTable( scriptTable ); 31370 let record = scriptTable.langSysRecords.find( 31371 ( l ) => l.langSysTag === langSysTag 31372 ); 31373 this.parser.currentPosition = scriptTable.start + record.langSysOffset; 31374 let table = new LangSysTable( this.parser ); 31375 table.langSysTag = langSysTag; 31376 return table; 31377 } 31378 getFeatures( langSysTable ) { 31379 return langSysTable.featureIndices.map( ( index ) => 31380 this.getFeature( index ) 31381 ); 31382 } 31383 getFeature( indexOrTag ) { 31384 let record; 31385 if ( parseInt( indexOrTag ) == indexOrTag ) { 31386 record = this.featureList.featureRecords[ indexOrTag ]; 31387 } else { 31388 record = this.featureList.featureRecords.find( 31389 ( f ) => f.featureTag === indexOrTag 31390 ); 31391 } 31392 if ( ! record ) return; 31393 this.parser.currentPosition = 31394 this.featureList.start + record.featureOffset; 31395 let table = new FeatureTable( this.parser ); 31396 table.featureTag = record.featureTag; 31397 return table; 31398 } 31399 getLookups( featureTable ) { 31400 return featureTable.lookupListIndices.map( ( index ) => 31401 this.getLookup( index ) 31402 ); 31403 } 31404 getLookup( lookupIndex, type ) { 31405 let lookupOffset = this.lookupList.lookups[ lookupIndex ]; 31406 this.parser.currentPosition = this.lookupList.start + lookupOffset; 31407 return new LookupTable( this.parser, type ); 31408 } 31409 } 31410 class GSUB extends CommonLayoutTable { 31411 constructor( dict, dataview ) { 31412 super( dict, dataview, `GSUB` ); 31413 } 31414 getLookup( lookupIndex ) { 31415 return super.getLookup( lookupIndex, `GSUB` ); 31416 } 31417 } 31418 var GSUB$1 = Object.freeze( { __proto__: null, GSUB: GSUB } ); 31419 class GPOS extends CommonLayoutTable { 31420 constructor( dict, dataview ) { 31421 super( dict, dataview, `GPOS` ); 31422 } 31423 getLookup( lookupIndex ) { 31424 return super.getLookup( lookupIndex, `GPOS` ); 31425 } 31426 } 31427 var GPOS$1 = Object.freeze( { __proto__: null, GPOS: GPOS } ); 31428 class SVG extends SimpleTable { 31429 constructor( dict, dataview ) { 31430 const { p: p } = super( dict, dataview ); 31431 this.version = p.uint16; 31432 this.offsetToSVGDocumentList = p.Offset32; 31433 p.currentPosition = this.tableStart + this.offsetToSVGDocumentList; 31434 this.documentList = new SVGDocumentList( p ); 31435 } 31436 } 31437 class SVGDocumentList extends ParsedData { 31438 constructor( p ) { 31439 super( p ); 31440 this.numEntries = p.uint16; 31441 this.documentRecords = [ ...new Array( this.numEntries ) ].map( 31442 ( _ ) => new SVGDocumentRecord( p ) 31443 ); 31444 } 31445 getDocument( documentID ) { 31446 let record = this.documentRecords[ documentID ]; 31447 if ( ! record ) return ''; 31448 let offset = this.start + record.svgDocOffset; 31449 this.parser.currentPosition = offset; 31450 return this.parser.readBytes( record.svgDocLength ); 31451 } 31452 getDocumentForGlyph( glyphID ) { 31453 let id = this.documentRecords.findIndex( 31454 ( d ) => d.startGlyphID <= glyphID && glyphID <= d.endGlyphID 31455 ); 31456 if ( id === -1 ) return ''; 31457 return this.getDocument( id ); 31458 } 31459 } 31460 class SVGDocumentRecord { 31461 constructor( p ) { 31462 this.startGlyphID = p.uint16; 31463 this.endGlyphID = p.uint16; 31464 this.svgDocOffset = p.Offset32; 31465 this.svgDocLength = p.uint32; 31466 } 31467 } 31468 var SVG$1 = Object.freeze( { __proto__: null, SVG: SVG } ); 31469 class fvar extends SimpleTable { 31470 constructor( dict, dataview ) { 31471 const { p: p } = super( dict, dataview ); 31472 this.majorVersion = p.uint16; 31473 this.minorVersion = p.uint16; 31474 this.axesArrayOffset = p.Offset16; 31475 p.uint16; 31476 this.axisCount = p.uint16; 31477 this.axisSize = p.uint16; 31478 this.instanceCount = p.uint16; 31479 this.instanceSize = p.uint16; 31480 const axisStart = this.tableStart + this.axesArrayOffset; 31481 lazy$1( this, `axes`, () => { 31482 p.currentPosition = axisStart; 31483 return [ ...new Array( this.axisCount ) ].map( 31484 ( _ ) => new VariationAxisRecord( p ) 31485 ); 31486 } ); 31487 const instanceStart = axisStart + this.axisCount * this.axisSize; 31488 lazy$1( this, `instances`, () => { 31489 let instances = []; 31490 for ( let i = 0; i < this.instanceCount; i++ ) { 31491 p.currentPosition = instanceStart + i * this.instanceSize; 31492 instances.push( 31493 new InstanceRecord( p, this.axisCount, this.instanceSize ) 31494 ); 31495 } 31496 return instances; 31497 } ); 31498 } 31499 getSupportedAxes() { 31500 return this.axes.map( ( a ) => a.tag ); 31501 } 31502 getAxis( name ) { 31503 return this.axes.find( ( a ) => a.tag === name ); 31504 } 31505 } 31506 class VariationAxisRecord { 31507 constructor( p ) { 31508 this.tag = p.tag; 31509 this.minValue = p.fixed; 31510 this.defaultValue = p.fixed; 31511 this.maxValue = p.fixed; 31512 this.flags = p.flags( 16 ); 31513 this.axisNameID = p.uint16; 31514 } 31515 } 31516 class InstanceRecord { 31517 constructor( p, axisCount, size ) { 31518 let start = p.currentPosition; 31519 this.subfamilyNameID = p.uint16; 31520 p.uint16; 31521 this.coordinates = [ ...new Array( axisCount ) ].map( 31522 ( _ ) => p.fixed 31523 ); 31524 if ( p.currentPosition - start < size ) { 31525 this.postScriptNameID = p.uint16; 31526 } 31527 } 31528 } 31529 var fvar$1 = Object.freeze( { __proto__: null, fvar: fvar } ); 31530 class cvt extends SimpleTable { 31531 constructor( dict, dataview ) { 31532 const { p: p } = super( dict, dataview ); 31533 const n = dict.length / 2; 31534 lazy$1( this, `items`, () => 31535 [ ...new Array( n ) ].map( ( _ ) => p.fword ) 31536 ); 31537 } 31538 } 31539 var cvt$1 = Object.freeze( { __proto__: null, cvt: cvt } ); 31540 class fpgm extends SimpleTable { 31541 constructor( dict, dataview ) { 31542 const { p: p } = super( dict, dataview ); 31543 lazy$1( this, `instructions`, () => 31544 [ ...new Array( dict.length ) ].map( ( _ ) => p.uint8 ) 31545 ); 31546 } 31547 } 31548 var fpgm$1 = Object.freeze( { __proto__: null, fpgm: fpgm } ); 31549 class gasp extends SimpleTable { 31550 constructor( dict, dataview ) { 31551 const { p: p } = super( dict, dataview ); 31552 this.version = p.uint16; 31553 this.numRanges = p.uint16; 31554 const getter = () => 31555 [ ...new Array( this.numRanges ) ].map( 31556 ( _ ) => new GASPRange( p ) 31557 ); 31558 lazy$1( this, `gaspRanges`, getter ); 31559 } 31560 } 31561 class GASPRange { 31562 constructor( p ) { 31563 this.rangeMaxPPEM = p.uint16; 31564 this.rangeGaspBehavior = p.uint16; 31565 } 31566 } 31567 var gasp$1 = Object.freeze( { __proto__: null, gasp: gasp } ); 31568 class glyf extends SimpleTable { 31569 constructor( dict, dataview ) { 31570 super( dict, dataview ); 31571 } 31572 getGlyphData( offset, length ) { 31573 this.parser.currentPosition = this.tableStart + offset; 31574 return this.parser.readBytes( length ); 31575 } 31576 } 31577 var glyf$1 = Object.freeze( { __proto__: null, glyf: glyf } ); 31578 class loca extends SimpleTable { 31579 constructor( dict, dataview, tables ) { 31580 const { p: p } = super( dict, dataview ); 31581 const n = tables.maxp.numGlyphs + 1; 31582 if ( tables.head.indexToLocFormat === 0 ) { 31583 this.x2 = true; 31584 lazy$1( this, `offsets`, () => 31585 [ ...new Array( n ) ].map( ( _ ) => p.Offset16 ) 31586 ); 31587 } else { 31588 lazy$1( this, `offsets`, () => 31589 [ ...new Array( n ) ].map( ( _ ) => p.Offset32 ) 31590 ); 31591 } 31592 } 31593 getGlyphDataOffsetAndLength( glyphID ) { 31594 let offset = this.offsets[ glyphID ] * this.x2 ? 2 : 1; 31595 let nextOffset = this.offsets[ glyphID + 1 ] * this.x2 ? 2 : 1; 31596 return { offset: offset, length: nextOffset - offset }; 31597 } 31598 } 31599 var loca$1 = Object.freeze( { __proto__: null, loca: loca } ); 31600 class prep extends SimpleTable { 31601 constructor( dict, dataview ) { 31602 const { p: p } = super( dict, dataview ); 31603 lazy$1( this, `instructions`, () => 31604 [ ...new Array( dict.length ) ].map( ( _ ) => p.uint8 ) 31605 ); 31606 } 31607 } 31608 var prep$1 = Object.freeze( { __proto__: null, prep: prep } ); 31609 class CFF extends SimpleTable { 31610 constructor( dict, dataview ) { 31611 const { p: p } = super( dict, dataview ); 31612 lazy$1( this, `data`, () => p.readBytes() ); 31613 } 31614 } 31615 var CFF$1 = Object.freeze( { __proto__: null, CFF: CFF } ); 31616 class CFF2 extends SimpleTable { 31617 constructor( dict, dataview ) { 31618 const { p: p } = super( dict, dataview ); 31619 lazy$1( this, `data`, () => p.readBytes() ); 31620 } 31621 } 31622 var CFF2$1 = Object.freeze( { __proto__: null, CFF2: CFF2 } ); 31623 class VORG extends SimpleTable { 31624 constructor( dict, dataview ) { 31625 const { p: p } = super( dict, dataview ); 31626 this.majorVersion = p.uint16; 31627 this.minorVersion = p.uint16; 31628 this.defaultVertOriginY = p.int16; 31629 this.numVertOriginYMetrics = p.uint16; 31630 lazy$1( this, `vertORiginYMetrics`, () => 31631 [ ...new Array( this.numVertOriginYMetrics ) ].map( 31632 ( _ ) => new VertOriginYMetric( p ) 31633 ) 31634 ); 31635 } 31636 } 31637 class VertOriginYMetric { 31638 constructor( p ) { 31639 this.glyphIndex = p.uint16; 31640 this.vertOriginY = p.int16; 31641 } 31642 } 31643 var VORG$1 = Object.freeze( { __proto__: null, VORG: VORG } ); 31644 class BitmapSize { 31645 constructor( p ) { 31646 this.indexSubTableArrayOffset = p.Offset32; 31647 this.indexTablesSize = p.uint32; 31648 this.numberofIndexSubTables = p.uint32; 31649 this.colorRef = p.uint32; 31650 this.hori = new SbitLineMetrics( p ); 31651 this.vert = new SbitLineMetrics( p ); 31652 this.startGlyphIndex = p.uint16; 31653 this.endGlyphIndex = p.uint16; 31654 this.ppemX = p.uint8; 31655 this.ppemY = p.uint8; 31656 this.bitDepth = p.uint8; 31657 this.flags = p.int8; 31658 } 31659 } 31660 class BitmapScale { 31661 constructor( p ) { 31662 this.hori = new SbitLineMetrics( p ); 31663 this.vert = new SbitLineMetrics( p ); 31664 this.ppemX = p.uint8; 31665 this.ppemY = p.uint8; 31666 this.substitutePpemX = p.uint8; 31667 this.substitutePpemY = p.uint8; 31668 } 31669 } 31670 class SbitLineMetrics { 31671 constructor( p ) { 31672 this.ascender = p.int8; 31673 this.descender = p.int8; 31674 this.widthMax = p.uint8; 31675 this.caretSlopeNumerator = p.int8; 31676 this.caretSlopeDenominator = p.int8; 31677 this.caretOffset = p.int8; 31678 this.minOriginSB = p.int8; 31679 this.minAdvanceSB = p.int8; 31680 this.maxBeforeBL = p.int8; 31681 this.minAfterBL = p.int8; 31682 this.pad1 = p.int8; 31683 this.pad2 = p.int8; 31684 } 31685 } 31686 class EBLC extends SimpleTable { 31687 constructor( dict, dataview, name ) { 31688 const { p: p } = super( dict, dataview, name ); 31689 this.majorVersion = p.uint16; 31690 this.minorVersion = p.uint16; 31691 this.numSizes = p.uint32; 31692 lazy$1( this, `bitMapSizes`, () => 31693 [ ...new Array( this.numSizes ) ].map( 31694 ( _ ) => new BitmapSize( p ) 31695 ) 31696 ); 31697 } 31698 } 31699 var EBLC$1 = Object.freeze( { __proto__: null, EBLC: EBLC } ); 31700 class EBDT extends SimpleTable { 31701 constructor( dict, dataview, name ) { 31702 const { p: p } = super( dict, dataview, name ); 31703 this.majorVersion = p.uint16; 31704 this.minorVersion = p.uint16; 31705 } 31706 } 31707 var EBDT$1 = Object.freeze( { __proto__: null, EBDT: EBDT } ); 31708 class EBSC extends SimpleTable { 31709 constructor( dict, dataview ) { 31710 const { p: p } = super( dict, dataview ); 31711 this.majorVersion = p.uint16; 31712 this.minorVersion = p.uint16; 31713 this.numSizes = p.uint32; 31714 lazy$1( this, `bitmapScales`, () => 31715 [ ...new Array( this.numSizes ) ].map( 31716 ( _ ) => new BitmapScale( p ) 31717 ) 31718 ); 31719 } 31720 } 31721 var EBSC$1 = Object.freeze( { __proto__: null, EBSC: EBSC } ); 31722 class CBLC extends EBLC { 31723 constructor( dict, dataview ) { 31724 super( dict, dataview, `CBLC` ); 31725 } 31726 } 31727 var CBLC$1 = Object.freeze( { __proto__: null, CBLC: CBLC } ); 31728 class CBDT extends EBDT { 31729 constructor( dict, dataview ) { 31730 super( dict, dataview, `CBDT` ); 31731 } 31732 } 31733 var CBDT$1 = Object.freeze( { __proto__: null, CBDT: CBDT } ); 31734 class sbix extends SimpleTable { 31735 constructor( dict, dataview ) { 31736 const { p: p } = super( dict, dataview ); 31737 this.version = p.uint16; 31738 this.flags = p.flags( 16 ); 31739 this.numStrikes = p.uint32; 31740 lazy$1( this, `strikeOffsets`, () => 31741 [ ...new Array( this.numStrikes ) ].map( ( _ ) => p.Offset32 ) 31742 ); 31743 } 31744 } 31745 var sbix$1 = Object.freeze( { __proto__: null, sbix: sbix } ); 31746 class COLR extends SimpleTable { 31747 constructor( dict, dataview ) { 31748 const { p: p } = super( dict, dataview ); 31749 this.version = p.uint16; 31750 this.numBaseGlyphRecords = p.uint16; 31751 this.baseGlyphRecordsOffset = p.Offset32; 31752 this.layerRecordsOffset = p.Offset32; 31753 this.numLayerRecords = p.uint16; 31754 } 31755 getBaseGlyphRecord( glyphID ) { 31756 let start = this.tableStart + this.baseGlyphRecordsOffset; 31757 this.parser.currentPosition = start; 31758 let first = new BaseGlyphRecord( this.parser ); 31759 let firstID = first.gID; 31760 let end = this.tableStart + this.layerRecordsOffset - 6; 31761 this.parser.currentPosition = end; 31762 let last = new BaseGlyphRecord( this.parser ); 31763 let lastID = last.gID; 31764 if ( firstID === glyphID ) return first; 31765 if ( lastID === glyphID ) return last; 31766 while ( true ) { 31767 if ( start === end ) break; 31768 let mid = start + ( end - start ) / 12; 31769 this.parser.currentPosition = mid; 31770 let middle = new BaseGlyphRecord( this.parser ); 31771 let midID = middle.gID; 31772 if ( midID === glyphID ) return middle; 31773 else if ( midID > glyphID ) { 31774 end = mid; 31775 } else if ( midID < glyphID ) { 31776 start = mid; 31777 } 31778 } 31779 return false; 31780 } 31781 getLayers( glyphID ) { 31782 let record = this.getBaseGlyphRecord( glyphID ); 31783 this.parser.currentPosition = 31784 this.tableStart + 31785 this.layerRecordsOffset + 31786 4 * record.firstLayerIndex; 31787 return [ ...new Array( record.numLayers ) ].map( 31788 ( _ ) => new LayerRecord( p ) 31789 ); 31790 } 31791 } 31792 class BaseGlyphRecord { 31793 constructor( p ) { 31794 this.gID = p.uint16; 31795 this.firstLayerIndex = p.uint16; 31796 this.numLayers = p.uint16; 31797 } 31798 } 31799 class LayerRecord { 31800 constructor( p ) { 31801 this.gID = p.uint16; 31802 this.paletteIndex = p.uint16; 31803 } 31804 } 31805 var COLR$1 = Object.freeze( { __proto__: null, COLR: COLR } ); 31806 class CPAL extends SimpleTable { 31807 constructor( dict, dataview ) { 31808 const { p: p } = super( dict, dataview ); 31809 this.version = p.uint16; 31810 this.numPaletteEntries = p.uint16; 31811 const numPalettes = ( this.numPalettes = p.uint16 ); 31812 this.numColorRecords = p.uint16; 31813 this.offsetFirstColorRecord = p.Offset32; 31814 this.colorRecordIndices = [ ...new Array( this.numPalettes ) ].map( 31815 ( _ ) => p.uint16 31816 ); 31817 lazy$1( this, `colorRecords`, () => { 31818 p.currentPosition = this.tableStart + this.offsetFirstColorRecord; 31819 return [ ...new Array( this.numColorRecords ) ].map( 31820 ( _ ) => new ColorRecord( p ) 31821 ); 31822 } ); 31823 if ( this.version === 1 ) { 31824 this.offsetPaletteTypeArray = p.Offset32; 31825 this.offsetPaletteLabelArray = p.Offset32; 31826 this.offsetPaletteEntryLabelArray = p.Offset32; 31827 lazy$1( this, `paletteTypeArray`, () => { 31828 p.currentPosition = 31829 this.tableStart + this.offsetPaletteTypeArray; 31830 return new PaletteTypeArray( p, numPalettes ); 31831 } ); 31832 lazy$1( this, `paletteLabelArray`, () => { 31833 p.currentPosition = 31834 this.tableStart + this.offsetPaletteLabelArray; 31835 return new PaletteLabelsArray( p, numPalettes ); 31836 } ); 31837 lazy$1( this, `paletteEntryLabelArray`, () => { 31838 p.currentPosition = 31839 this.tableStart + this.offsetPaletteEntryLabelArray; 31840 return new PaletteEntryLabelArray( p, numPalettes ); 31841 } ); 31842 } 31843 } 31844 } 31845 class ColorRecord { 31846 constructor( p ) { 31847 this.blue = p.uint8; 31848 this.green = p.uint8; 31849 this.red = p.uint8; 31850 this.alpha = p.uint8; 31851 } 31852 } 31853 class PaletteTypeArray { 31854 constructor( p, numPalettes ) { 31855 this.paletteTypes = [ ...new Array( numPalettes ) ].map( 31856 ( _ ) => p.uint32 31857 ); 31858 } 31859 } 31860 class PaletteLabelsArray { 31861 constructor( p, numPalettes ) { 31862 this.paletteLabels = [ ...new Array( numPalettes ) ].map( 31863 ( _ ) => p.uint16 31864 ); 31865 } 31866 } 31867 class PaletteEntryLabelArray { 31868 constructor( p, numPalettes ) { 31869 this.paletteEntryLabels = [ ...new Array( numPalettes ) ].map( 31870 ( _ ) => p.uint16 31871 ); 31872 } 31873 } 31874 var CPAL$1 = Object.freeze( { __proto__: null, CPAL: CPAL } ); 31875 class DSIG extends SimpleTable { 31876 constructor( dict, dataview ) { 31877 const { p: p } = super( dict, dataview ); 31878 this.version = p.uint32; 31879 this.numSignatures = p.uint16; 31880 this.flags = p.uint16; 31881 this.signatureRecords = [ ...new Array( this.numSignatures ) ].map( 31882 ( _ ) => new SignatureRecord( p ) 31883 ); 31884 } 31885 getData( signatureID ) { 31886 const record = this.signatureRecords[ signatureID ]; 31887 this.parser.currentPosition = this.tableStart + record.offset; 31888 return new SignatureBlockFormat1( this.parser ); 31889 } 31890 } 31891 class SignatureRecord { 31892 constructor( p ) { 31893 this.format = p.uint32; 31894 this.length = p.uint32; 31895 this.offset = p.Offset32; 31896 } 31897 } 31898 class SignatureBlockFormat1 { 31899 constructor( p ) { 31900 p.uint16; 31901 p.uint16; 31902 this.signatureLength = p.uint32; 31903 this.signature = p.readBytes( this.signatureLength ); 31904 } 31905 } 31906 var DSIG$1 = Object.freeze( { __proto__: null, DSIG: DSIG } ); 31907 class hdmx extends SimpleTable { 31908 constructor( dict, dataview, tables ) { 31909 const { p: p } = super( dict, dataview ); 31910 const numGlyphs = tables.hmtx.numGlyphs; 31911 this.version = p.uint16; 31912 this.numRecords = p.int16; 31913 this.sizeDeviceRecord = p.int32; 31914 this.records = [ ...new Array( numRecords ) ].map( 31915 ( _ ) => new DeviceRecord( p, numGlyphs ) 31916 ); 31917 } 31918 } 31919 class DeviceRecord { 31920 constructor( p, numGlyphs ) { 31921 this.pixelSize = p.uint8; 31922 this.maxWidth = p.uint8; 31923 this.widths = p.readBytes( numGlyphs ); 31924 } 31925 } 31926 var hdmx$1 = Object.freeze( { __proto__: null, hdmx: hdmx } ); 31927 class kern extends SimpleTable { 31928 constructor( dict, dataview ) { 31929 const { p: p } = super( dict, dataview ); 31930 this.version = p.uint16; 31931 this.nTables = p.uint16; 31932 lazy$1( this, `tables`, () => { 31933 let offset = this.tableStart + 4; 31934 const tables = []; 31935 for ( let i = 0; i < this.nTables; i++ ) { 31936 p.currentPosition = offset; 31937 let subtable = new KernSubTable( p ); 31938 tables.push( subtable ); 31939 offset += subtable; 31940 } 31941 return tables; 31942 } ); 31943 } 31944 } 31945 class KernSubTable { 31946 constructor( p ) { 31947 this.version = p.uint16; 31948 this.length = p.uint16; 31949 this.coverage = p.flags( 8 ); 31950 this.format = p.uint8; 31951 if ( this.format === 0 ) { 31952 this.nPairs = p.uint16; 31953 this.searchRange = p.uint16; 31954 this.entrySelector = p.uint16; 31955 this.rangeShift = p.uint16; 31956 lazy$1( this, `pairs`, () => 31957 [ ...new Array( this.nPairs ) ].map( ( _ ) => new Pair( p ) ) 31958 ); 31959 } 31960 if ( this.format === 2 ) { 31961 console.warn( 31962 `Kern subtable format 2 is not supported: this parser currently only parses universal table data.` 31963 ); 31964 } 31965 } 31966 get horizontal() { 31967 return this.coverage[ 0 ]; 31968 } 31969 get minimum() { 31970 return this.coverage[ 1 ]; 31971 } 31972 get crossstream() { 31973 return this.coverage[ 2 ]; 31974 } 31975 get override() { 31976 return this.coverage[ 3 ]; 31977 } 31978 } 31979 class Pair { 31980 constructor( p ) { 31981 this.left = p.uint16; 31982 this.right = p.uint16; 31983 this.value = p.fword; 31984 } 31985 } 31986 var kern$1 = Object.freeze( { __proto__: null, kern: kern } ); 31987 class LTSH extends SimpleTable { 31988 constructor( dict, dataview ) { 31989 const { p: p } = super( dict, dataview ); 31990 this.version = p.uint16; 31991 this.numGlyphs = p.uint16; 31992 this.yPels = p.readBytes( this.numGlyphs ); 31993 } 31994 } 31995 var LTSH$1 = Object.freeze( { __proto__: null, LTSH: LTSH } ); 31996 class MERG extends SimpleTable { 31997 constructor( dict, dataview ) { 31998 const { p: p } = super( dict, dataview ); 31999 this.version = p.uint16; 32000 this.mergeClassCount = p.uint16; 32001 this.mergeDataOffset = p.Offset16; 32002 this.classDefCount = p.uint16; 32003 this.offsetToClassDefOffsets = p.Offset16; 32004 lazy$1( this, `mergeEntryMatrix`, () => 32005 [ ...new Array( this.mergeClassCount ) ].map( ( _ ) => 32006 p.readBytes( this.mergeClassCount ) 32007 ) 32008 ); 32009 console.warn( `Full MERG parsing is currently not supported.` ); 32010 console.warn( 32011 `If you need this table parsed, please file an issue, or better yet, a PR.` 32012 ); 32013 } 32014 } 32015 var MERG$1 = Object.freeze( { __proto__: null, MERG: MERG } ); 32016 class meta extends SimpleTable { 32017 constructor( dict, dataview ) { 32018 const { p: p } = super( dict, dataview ); 32019 this.version = p.uint32; 32020 this.flags = p.uint32; 32021 p.uint32; 32022 this.dataMapsCount = p.uint32; 32023 this.dataMaps = [ ...new Array( this.dataMapsCount ) ].map( 32024 ( _ ) => new DataMap( this.tableStart, p ) 32025 ); 32026 } 32027 } 32028 class DataMap { 32029 constructor( tableStart, p ) { 32030 this.tableStart = tableStart; 32031 this.parser = p; 32032 this.tag = p.tag; 32033 this.dataOffset = p.Offset32; 32034 this.dataLength = p.uint32; 32035 } 32036 getData() { 32037 this.parser.currentField = this.tableStart + this.dataOffset; 32038 return this.parser.readBytes( this.dataLength ); 32039 } 32040 } 32041 var meta$1 = Object.freeze( { __proto__: null, meta: meta } ); 32042 class PCLT extends SimpleTable { 32043 constructor( dict, dataview ) { 32044 super( dict, dataview ); 32045 console.warn( 32046 `This font uses a PCLT table, which is currently not supported by this parser.` 32047 ); 32048 console.warn( 32049 `If you need this table parsed, please file an issue, or better yet, a PR.` 32050 ); 32051 } 32052 } 32053 var PCLT$1 = Object.freeze( { __proto__: null, PCLT: PCLT } ); 32054 class VDMX extends SimpleTable { 32055 constructor( dict, dataview ) { 32056 const { p: p } = super( dict, dataview ); 32057 this.version = p.uint16; 32058 this.numRecs = p.uint16; 32059 this.numRatios = p.uint16; 32060 this.ratRanges = [ ...new Array( this.numRatios ) ].map( 32061 ( _ ) => new RatioRange( p ) 32062 ); 32063 this.offsets = [ ...new Array( this.numRatios ) ].map( 32064 ( _ ) => p.Offset16 32065 ); 32066 this.VDMXGroups = [ ...new Array( this.numRecs ) ].map( 32067 ( _ ) => new VDMXGroup( p ) 32068 ); 32069 } 32070 } 32071 class RatioRange { 32072 constructor( p ) { 32073 this.bCharSet = p.uint8; 32074 this.xRatio = p.uint8; 32075 this.yStartRatio = p.uint8; 32076 this.yEndRatio = p.uint8; 32077 } 32078 } 32079 class VDMXGroup { 32080 constructor( p ) { 32081 this.recs = p.uint16; 32082 this.startsz = p.uint8; 32083 this.endsz = p.uint8; 32084 this.records = [ ...new Array( this.recs ) ].map( 32085 ( _ ) => new vTable( p ) 32086 ); 32087 } 32088 } 32089 class vTable { 32090 constructor( p ) { 32091 this.yPelHeight = p.uint16; 32092 this.yMax = p.int16; 32093 this.yMin = p.int16; 32094 } 32095 } 32096 var VDMX$1 = Object.freeze( { __proto__: null, VDMX: VDMX } ); 32097 class vhea extends SimpleTable { 32098 constructor( dict, dataview ) { 32099 const { p: p } = super( dict, dataview ); 32100 this.version = p.fixed; 32101 this.ascent = this.vertTypoAscender = p.int16; 32102 this.descent = this.vertTypoDescender = p.int16; 32103 this.lineGap = this.vertTypoLineGap = p.int16; 32104 this.advanceHeightMax = p.int16; 32105 this.minTopSideBearing = p.int16; 32106 this.minBottomSideBearing = p.int16; 32107 this.yMaxExtent = p.int16; 32108 this.caretSlopeRise = p.int16; 32109 this.caretSlopeRun = p.int16; 32110 this.caretOffset = p.int16; 32111 this.reserved = p.int16; 32112 this.reserved = p.int16; 32113 this.reserved = p.int16; 32114 this.reserved = p.int16; 32115 this.metricDataFormat = p.int16; 32116 this.numOfLongVerMetrics = p.uint16; 32117 p.verifyLength(); 32118 } 32119 } 32120 var vhea$1 = Object.freeze( { __proto__: null, vhea: vhea } ); 32121 class vmtx extends SimpleTable { 32122 constructor( dict, dataview, tables ) { 32123 super( dict, dataview ); 32124 const numOfLongVerMetrics = tables.vhea.numOfLongVerMetrics; 32125 const numGlyphs = tables.maxp.numGlyphs; 32126 const metricsStart = p.currentPosition; 32127 lazy( this, `vMetrics`, () => { 32128 p.currentPosition = metricsStart; 32129 return [ ...new Array( numOfLongVerMetrics ) ].map( 32130 ( _ ) => new LongVertMetric( p.uint16, p.int16 ) 32131 ); 32132 } ); 32133 if ( numOfLongVerMetrics < numGlyphs ) { 32134 const tsbStart = metricsStart + numOfLongVerMetrics * 4; 32135 lazy( this, `topSideBearings`, () => { 32136 p.currentPosition = tsbStart; 32137 return [ ...new Array( numGlyphs - numOfLongVerMetrics ) ].map( 32138 ( _ ) => p.int16 32139 ); 32140 } ); 32141 } 32142 } 32143 } 32144 class LongVertMetric { 32145 constructor( h, b ) { 32146 this.advanceHeight = h; 32147 this.topSideBearing = b; 32148 } 32149 } 32150 var vmtx$1 = Object.freeze( { __proto__: null, vmtx: vmtx } ); 32151 32152 /* eslint-enable */ 32153 32154 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/global-styles/font-library-modal/utils/make-families-from-faces.js 32155 /** 32156 * WordPress dependencies 32157 */ 32158 32159 32160 /** 32161 * Internal dependencies 32162 */ 32163 32164 const { 32165 kebabCase: make_families_from_faces_kebabCase 32166 } = unlock(external_wp_components_namespaceObject.privateApis); 32167 function makeFamiliesFromFaces(fontFaces) { 32168 const fontFamiliesObject = fontFaces.reduce((acc, item) => { 32169 if (!acc[item.fontFamily]) { 32170 acc[item.fontFamily] = { 32171 name: item.fontFamily, 32172 fontFamily: item.fontFamily, 32173 slug: make_families_from_faces_kebabCase(item.fontFamily.toLowerCase()), 32174 fontFace: [] 32175 }; 32176 } 32177 acc[item.fontFamily].fontFace.push(item); 32178 return acc; 32179 }, {}); 32180 return Object.values(fontFamiliesObject); 32181 } 32182 32183 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/global-styles/font-library-modal/upload-fonts.js 32184 32185 /** 32186 * WordPress dependencies 32187 */ 32188 32189 32190 32191 32192 /** 32193 * Internal dependencies 32194 */ 32195 32196 32197 32198 32199 32200 32201 const { 32202 ProgressBar: upload_fonts_ProgressBar 32203 } = unlock(external_wp_components_namespaceObject.privateApis); 32204 function UploadFonts() { 32205 const { 32206 installFonts, 32207 notice, 32208 setNotice 32209 } = (0,external_wp_element_namespaceObject.useContext)(FontLibraryContext); 32210 const [isUploading, setIsUploading] = (0,external_wp_element_namespaceObject.useState)(false); 32211 const handleDropZone = files => { 32212 handleFilesUpload(files); 32213 }; 32214 const onFilesUpload = event => { 32215 handleFilesUpload(event.target.files); 32216 }; 32217 32218 /** 32219 * Filters the selected files to only allow the ones with the allowed extensions 32220 * 32221 * @param {Array} files The files to be filtered 32222 * @return {void} 32223 */ 32224 const handleFilesUpload = async files => { 32225 setNotice(null); 32226 setIsUploading(true); 32227 const uniqueFilenames = new Set(); 32228 const selectedFiles = [...files]; 32229 let hasInvalidFiles = false; 32230 32231 // Use map to create a promise for each file check, then filter with Promise.all. 32232 const checkFilesPromises = selectedFiles.map(async file => { 32233 const isFont = await isFontFile(file); 32234 if (!isFont) { 32235 hasInvalidFiles = true; 32236 return null; // Return null for invalid files. 32237 } 32238 // Check for duplicates 32239 if (uniqueFilenames.has(file.name)) { 32240 return null; // Return null for duplicates. 32241 } 32242 // Check if the file extension is allowed. 32243 const fileExtension = file.name.split('.').pop().toLowerCase(); 32244 if (ALLOWED_FILE_EXTENSIONS.includes(fileExtension)) { 32245 uniqueFilenames.add(file.name); 32246 return file; // Return the file if it passes all checks. 32247 } 32248 return null; // Return null for disallowed file extensions. 32249 }); 32250 32251 // Filter out the nulls after all promises have resolved. 32252 const allowedFiles = (await Promise.all(checkFilesPromises)).filter(file => null !== file); 32253 if (allowedFiles.length > 0) { 32254 loadFiles(allowedFiles); 32255 } else { 32256 const message = hasInvalidFiles ? (0,external_wp_i18n_namespaceObject.__)('Sorry, you are not allowed to upload this file type.') : (0,external_wp_i18n_namespaceObject.__)('No fonts found to install.'); 32257 setNotice({ 32258 type: 'error', 32259 message 32260 }); 32261 setIsUploading(false); 32262 } 32263 }; 32264 32265 /** 32266 * Loads the selected files and reads the font metadata 32267 * 32268 * @param {Array} files The files to be loaded 32269 * @return {void} 32270 */ 32271 const loadFiles = async files => { 32272 const fontFacesLoaded = await Promise.all(files.map(async fontFile => { 32273 const fontFaceData = await getFontFaceMetadata(fontFile); 32274 await loadFontFaceInBrowser(fontFaceData, fontFaceData.file, 'all'); 32275 return fontFaceData; 32276 })); 32277 handleInstall(fontFacesLoaded); 32278 }; 32279 32280 /** 32281 * Checks if a file is a valid Font file. 32282 * 32283 * @param {File} file The file to be checked. 32284 * @return {boolean} Whether the file is a valid font file. 32285 */ 32286 async function isFontFile(file) { 32287 const font = new Font('Uploaded Font'); 32288 try { 32289 const buffer = await readFileAsArrayBuffer(file); 32290 await font.fromDataBuffer(buffer, 'font'); 32291 return true; 32292 } catch (error) { 32293 return false; 32294 } 32295 } 32296 32297 // Create a function to read the file as array buffer 32298 async function readFileAsArrayBuffer(file) { 32299 return new Promise((resolve, reject) => { 32300 const reader = new window.FileReader(); 32301 reader.readAsArrayBuffer(file); 32302 reader.onload = () => resolve(reader.result); 32303 reader.onerror = reject; 32304 }); 32305 } 32306 const getFontFaceMetadata = async fontFile => { 32307 const buffer = await readFileAsArrayBuffer(fontFile); 32308 const fontObj = new Font('Uploaded Font'); 32309 fontObj.fromDataBuffer(buffer, fontFile.name); 32310 // Assuming that fromDataBuffer triggers onload event and returning a Promise 32311 const onloadEvent = await new Promise(resolve => fontObj.onload = resolve); 32312 const font = onloadEvent.detail.font; 32313 const { 32314 name 32315 } = font.opentype.tables; 32316 const fontName = name.get(16) || name.get(1); 32317 const isItalic = name.get(2).toLowerCase().includes('italic'); 32318 const fontWeight = font.opentype.tables['OS/2'].usWeightClass || 'normal'; 32319 const isVariable = !!font.opentype.tables.fvar; 32320 const weightAxis = isVariable && font.opentype.tables.fvar.axes.find(({ 32321 tag 32322 }) => tag === 'wght'); 32323 const weightRange = weightAxis ? `$weightAxis.minValue} $weightAxis.maxValue}` : null; 32324 return { 32325 file: fontFile, 32326 fontFamily: fontName, 32327 fontStyle: isItalic ? 'italic' : 'normal', 32328 fontWeight: weightRange || fontWeight 32329 }; 32330 }; 32331 32332 /** 32333 * Creates the font family definition and sends it to the server 32334 * 32335 * @param {Array} fontFaces The font faces to be installed 32336 * @return {void} 32337 */ 32338 const handleInstall = async fontFaces => { 32339 const fontFamilies = makeFamiliesFromFaces(fontFaces); 32340 try { 32341 await installFonts(fontFamilies); 32342 setNotice({ 32343 type: 'success', 32344 message: (0,external_wp_i18n_namespaceObject.__)('Fonts were installed successfully.') 32345 }); 32346 } catch (error) { 32347 setNotice({ 32348 type: 'error', 32349 message: error.message, 32350 errors: error?.installationErrors 32351 }); 32352 } 32353 setIsUploading(false); 32354 }; 32355 return (0,external_React_.createElement)("div", { 32356 className: "font-library-modal__tabpanel-layout" 32357 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.DropZone, { 32358 onFilesDrop: handleDropZone 32359 }), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { 32360 className: "font-library-modal__local-fonts" 32361 }, notice && (0,external_React_.createElement)(external_wp_components_namespaceObject.Notice, { 32362 status: notice.type, 32363 __unstableHTML: true, 32364 onRemove: () => setNotice(null) 32365 }, notice.message, notice.errors && (0,external_React_.createElement)("ul", null, notice.errors.map((error, index) => (0,external_React_.createElement)("li", { 32366 key: index 32367 }, error)))), isUploading && (0,external_React_.createElement)(external_wp_components_namespaceObject.FlexItem, null, (0,external_React_.createElement)("div", { 32368 className: "font-library-modal__upload-area" 32369 }, (0,external_React_.createElement)(upload_fonts_ProgressBar, null))), !isUploading && (0,external_React_.createElement)(external_wp_components_namespaceObject.FormFileUpload, { 32370 accept: ALLOWED_FILE_EXTENSIONS.map(ext => `.$ext}`).join(','), 32371 multiple: true, 32372 onChange: onFilesUpload, 32373 render: ({ 32374 openFileDialog 32375 }) => (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 32376 className: "font-library-modal__upload-area", 32377 onClick: openFileDialog 32378 }, (0,external_wp_i18n_namespaceObject.__)('Upload font')) 32379 }), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalSpacer, { 32380 margin: 2 32381 }), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalText, { 32382 className: "font-library-modal__upload-area__text" 32383 }, (0,external_wp_i18n_namespaceObject.__)('Uploaded fonts appear in your library and can be used in your theme. Supported formats: .ttf, .otf, .woff, and .woff2.')))); 32384 } 32385 /* harmony default export */ const upload_fonts = (UploadFonts); 32386 32387 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/global-styles/font-library-modal/index.js 32388 32389 /** 32390 * WordPress dependencies 32391 */ 32392 32393 32394 32395 32396 32397 32398 /** 32399 * Internal dependencies 32400 */ 32401 32402 32403 32404 32405 32406 const { 32407 Tabs: font_library_modal_Tabs 32408 } = unlock(external_wp_components_namespaceObject.privateApis); 32409 const DEFAULT_TAB = { 32410 id: 'installed-fonts', 32411 title: (0,external_wp_i18n_namespaceObject._x)('Library', 'Font library') 32412 }; 32413 const UPLOAD_TAB = { 32414 id: 'upload-fonts', 32415 title: (0,external_wp_i18n_namespaceObject.__)('Upload') 32416 }; 32417 const tabsFromCollections = collections => collections.map(({ 32418 slug, 32419 name 32420 }) => ({ 32421 id: slug, 32422 title: collections.length === 1 && slug === 'google-fonts' ? (0,external_wp_i18n_namespaceObject.__)('Install Fonts') : name 32423 })); 32424 function FontLibraryModal({ 32425 onRequestClose, 32426 initialTabId = 'installed-fonts' 32427 }) { 32428 const { 32429 collections, 32430 setNotice 32431 } = (0,external_wp_element_namespaceObject.useContext)(FontLibraryContext); 32432 const canUserCreate = (0,external_wp_data_namespaceObject.useSelect)(select => { 32433 const { 32434 canUser 32435 } = select(external_wp_coreData_namespaceObject.store); 32436 return canUser('create', 'font-families'); 32437 }, []); 32438 const tabs = [DEFAULT_TAB]; 32439 if (canUserCreate) { 32440 tabs.push(UPLOAD_TAB); 32441 tabs.push(...tabsFromCollections(collections || [])); 32442 } 32443 32444 // Reset notice when new tab is selected. 32445 const onSelect = () => { 32446 setNotice(null); 32447 }; 32448 return (0,external_React_.createElement)(external_wp_components_namespaceObject.Modal, { 32449 title: (0,external_wp_i18n_namespaceObject.__)('Fonts'), 32450 onRequestClose: onRequestClose, 32451 isFullScreen: true, 32452 className: "font-library-modal" 32453 }, (0,external_React_.createElement)("div", { 32454 className: "font-library-modal__tabs" 32455 }, (0,external_React_.createElement)(font_library_modal_Tabs, { 32456 initialTabId: initialTabId, 32457 onSelect: onSelect 32458 }, (0,external_React_.createElement)(font_library_modal_Tabs.TabList, null, tabs.map(({ 32459 id, 32460 title 32461 }) => (0,external_React_.createElement)(font_library_modal_Tabs.Tab, { 32462 key: id, 32463 tabId: id 32464 }, title))), tabs.map(({ 32465 id 32466 }) => { 32467 let contents; 32468 switch (id) { 32469 case 'upload-fonts': 32470 contents = (0,external_React_.createElement)(upload_fonts, null); 32471 break; 32472 case 'installed-fonts': 32473 contents = (0,external_React_.createElement)(installed_fonts, null); 32474 break; 32475 default: 32476 contents = (0,external_React_.createElement)(font_collection, { 32477 slug: id 32478 }); 32479 } 32480 return (0,external_React_.createElement)(font_library_modal_Tabs.TabPanel, { 32481 key: id, 32482 tabId: id, 32483 focusable: false 32484 }, contents); 32485 })))); 32486 } 32487 /* harmony default export */ const font_library_modal = (FontLibraryModal); 32488 32489 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/global-styles/font-family-item.js 32490 32491 /** 32492 * WordPress dependencies 32493 */ 32494 32495 32496 32497 32498 /** 32499 * Internal dependencies 32500 */ 32501 32502 32503 function FontFamilyItem({ 32504 font 32505 }) { 32506 const { 32507 handleSetLibraryFontSelected, 32508 toggleModal 32509 } = (0,external_wp_element_namespaceObject.useContext)(FontLibraryContext); 32510 const variantsCount = font?.fontFace?.length || 1; 32511 const handleClick = () => { 32512 handleSetLibraryFontSelected(font); 32513 toggleModal('installed-fonts'); 32514 }; 32515 const previewStyle = getFamilyPreviewStyle(font); 32516 return (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalItem, { 32517 onClick: handleClick 32518 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { 32519 justify: "space-between" 32520 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.FlexItem, { 32521 style: previewStyle 32522 }, font.name), (0,external_React_.createElement)(external_wp_components_namespaceObject.FlexItem, { 32523 className: "edit-site-global-styles-screen-typography__font-variants-count" 32524 }, (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %d: Number of font variants. */ 32525 (0,external_wp_i18n_namespaceObject._n)('%d variant', '%d variants', variantsCount), variantsCount)))); 32526 } 32527 /* harmony default export */ const font_family_item = (FontFamilyItem); 32528 32529 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/global-styles/font-families.js 32530 32531 /** 32532 * WordPress dependencies 32533 */ 32534 32535 32536 32537 32538 32539 /** 32540 * Internal dependencies 32541 */ 32542 32543 32544 32545 32546 function FontFamilies() { 32547 const { 32548 modalTabOpen, 32549 toggleModal, 32550 themeFonts, 32551 customFonts 32552 } = (0,external_wp_element_namespaceObject.useContext)(FontLibraryContext); 32553 const hasFonts = 0 < customFonts.length || 0 < themeFonts.length; 32554 return (0,external_React_.createElement)(external_React_.Fragment, null, !!modalTabOpen && (0,external_React_.createElement)(font_library_modal, { 32555 onRequestClose: () => toggleModal(), 32556 initialTabId: modalTabOpen 32557 }), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { 32558 spacing: 3 32559 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { 32560 justify: "space-between" 32561 }, (0,external_React_.createElement)(subtitle, { 32562 level: 3 32563 }, (0,external_wp_i18n_namespaceObject.__)('Fonts')), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { 32564 justify: "flex-end" 32565 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.Tooltip, { 32566 text: (0,external_wp_i18n_namespaceObject.__)('Manage fonts') 32567 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 32568 onClick: () => toggleModal('installed-fonts'), 32569 "aria-label": (0,external_wp_i18n_namespaceObject.__)('Manage fonts'), 32570 icon: library_settings, 32571 size: 'small' 32572 })))), hasFonts ? (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalItemGroup, { 32573 isBordered: true, 32574 isSeparated: true 32575 }, customFonts.map(font => (0,external_React_.createElement)(font_family_item, { 32576 key: font.slug, 32577 font: font 32578 })), themeFonts.map(font => (0,external_React_.createElement)(font_family_item, { 32579 key: font.slug, 32580 font: font 32581 }))) : (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_wp_i18n_namespaceObject.__)('No fonts installed.'), (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 32582 className: "edit-site-global-styles-font-families__add-fonts", 32583 variant: "secondary", 32584 onClick: () => toggleModal('upload-fonts') 32585 }, (0,external_wp_i18n_namespaceObject.__)('Add fonts'))))); 32586 } 32587 /* harmony default export */ const font_families = (({ 32588 ...props 32589 }) => (0,external_React_.createElement)(context, null, (0,external_React_.createElement)(FontFamilies, { 32590 ...props 32591 }))); 32592 32593 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/global-styles/screen-typography.js 32594 32595 /** 32596 * WordPress dependencies 32597 */ 32598 32599 32600 32601 32602 32603 /** 32604 * Internal dependencies 32605 */ 32606 32607 32608 32609 function ScreenTypography() { 32610 const fontLibraryEnabled = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_editor_namespaceObject.store).getEditorSettings().fontLibraryEnabled, []); 32611 return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(header, { 32612 title: (0,external_wp_i18n_namespaceObject.__)('Typography'), 32613 description: (0,external_wp_i18n_namespaceObject.__)('Manage the typography settings for different elements.') 32614 }), (0,external_React_.createElement)("div", { 32615 className: "edit-site-global-styles-screen-typography" 32616 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { 32617 spacing: 6 32618 }, fontLibraryEnabled && (0,external_React_.createElement)(font_families, null), (0,external_React_.createElement)(typogrphy_elements, null)))); 32619 } 32620 /* harmony default export */ const screen_typography = (ScreenTypography); 32621 32622 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/global-styles/typography-panel.js 32623 32624 /** 32625 * WordPress dependencies 32626 */ 32627 32628 32629 /** 32630 * Internal dependencies 32631 */ 32632 32633 const { 32634 useGlobalStyle: typography_panel_useGlobalStyle, 32635 useGlobalSetting: typography_panel_useGlobalSetting, 32636 useSettingsForBlockElement: typography_panel_useSettingsForBlockElement, 32637 TypographyPanel: typography_panel_StylesTypographyPanel 32638 } = unlock(external_wp_blockEditor_namespaceObject.privateApis); 32639 function TypographyPanel({ 32640 element, 32641 headingLevel 32642 }) { 32643 let prefixParts = []; 32644 if (element === 'heading') { 32645 prefixParts = prefixParts.concat(['elements', headingLevel]); 32646 } else if (element && element !== 'text') { 32647 prefixParts = prefixParts.concat(['elements', element]); 32648 } 32649 const prefix = prefixParts.join('.'); 32650 const [style] = typography_panel_useGlobalStyle(prefix, undefined, 'user', { 32651 shouldDecodeEncode: false 32652 }); 32653 const [inheritedStyle, setStyle] = typography_panel_useGlobalStyle(prefix, undefined, 'all', { 32654 shouldDecodeEncode: false 32655 }); 32656 const [rawSettings] = typography_panel_useGlobalSetting(''); 32657 const usedElement = element === 'heading' ? headingLevel : element; 32658 const settings = typography_panel_useSettingsForBlockElement(rawSettings, undefined, usedElement); 32659 return (0,external_React_.createElement)(typography_panel_StylesTypographyPanel, { 32660 inheritedValue: inheritedStyle, 32661 value: style, 32662 onChange: setStyle, 32663 settings: settings 32664 }); 32665 } 32666 32667 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/global-styles/typography-preview.js 32668 32669 /** 32670 * WordPress dependencies 32671 */ 32672 32673 32674 /** 32675 * Internal dependencies 32676 */ 32677 32678 const { 32679 useGlobalStyle: typography_preview_useGlobalStyle 32680 } = unlock(external_wp_blockEditor_namespaceObject.privateApis); 32681 function TypographyPreview({ 32682 name, 32683 element, 32684 headingLevel 32685 }) { 32686 let prefix = ''; 32687 if (element === 'heading') { 32688 prefix = `elements.$headingLevel}.`; 32689 } else if (element && element !== 'text') { 32690 prefix = `elements.$element}.`; 32691 } 32692 const [fontFamily] = typography_preview_useGlobalStyle(prefix + 'typography.fontFamily', name); 32693 const [gradientValue] = typography_preview_useGlobalStyle(prefix + 'color.gradient', name); 32694 const [backgroundColor] = typography_preview_useGlobalStyle(prefix + 'color.background', name); 32695 const [color] = typography_preview_useGlobalStyle(prefix + 'color.text', name); 32696 const [fontSize] = typography_preview_useGlobalStyle(prefix + 'typography.fontSize', name); 32697 const [fontStyle] = typography_preview_useGlobalStyle(prefix + 'typography.fontStyle', name); 32698 const [fontWeight] = typography_preview_useGlobalStyle(prefix + 'typography.fontWeight', name); 32699 const [letterSpacing] = typography_preview_useGlobalStyle(prefix + 'typography.letterSpacing', name); 32700 const extraStyles = element === 'link' ? { 32701 textDecoration: 'underline' 32702 } : {}; 32703 return (0,external_React_.createElement)("div", { 32704 className: "edit-site-typography-preview", 32705 style: { 32706 fontFamily: fontFamily !== null && fontFamily !== void 0 ? fontFamily : 'serif', 32707 background: gradientValue !== null && gradientValue !== void 0 ? gradientValue : backgroundColor, 32708 color, 32709 fontSize, 32710 fontStyle, 32711 fontWeight, 32712 letterSpacing, 32713 ...extraStyles 32714 } 32715 }, "Aa"); 32716 } 32717 32718 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/global-styles/screen-typography-element.js 32719 32720 /** 32721 * WordPress dependencies 32722 */ 32723 32724 32725 32726 32727 /** 32728 * Internal dependencies 32729 */ 32730 32731 32732 32733 const screen_typography_element_elements = { 32734 text: { 32735 description: (0,external_wp_i18n_namespaceObject.__)('Manage the fonts used on the site.'), 32736 title: (0,external_wp_i18n_namespaceObject.__)('Text') 32737 }, 32738 link: { 32739 description: (0,external_wp_i18n_namespaceObject.__)('Manage the fonts and typography used on the links.'), 32740 title: (0,external_wp_i18n_namespaceObject.__)('Links') 32741 }, 32742 heading: { 32743 description: (0,external_wp_i18n_namespaceObject.__)('Manage the fonts and typography used on headings.'), 32744 title: (0,external_wp_i18n_namespaceObject.__)('Headings') 32745 }, 32746 caption: { 32747 description: (0,external_wp_i18n_namespaceObject.__)('Manage the fonts and typography used on captions.'), 32748 title: (0,external_wp_i18n_namespaceObject.__)('Captions') 32749 }, 32750 button: { 32751 description: (0,external_wp_i18n_namespaceObject.__)('Manage the fonts and typography used on buttons.'), 32752 title: (0,external_wp_i18n_namespaceObject.__)('Buttons') 32753 } 32754 }; 32755 function ScreenTypographyElement({ 32756 element 32757 }) { 32758 const [headingLevel, setHeadingLevel] = (0,external_wp_element_namespaceObject.useState)('heading'); 32759 return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(header, { 32760 title: screen_typography_element_elements[element].title, 32761 description: screen_typography_element_elements[element].description 32762 }), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalSpacer, { 32763 marginX: 4 32764 }, (0,external_React_.createElement)(TypographyPreview, { 32765 element: element, 32766 headingLevel: headingLevel 32767 })), element === 'heading' && (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalSpacer, { 32768 marginX: 4, 32769 marginBottom: "1em" 32770 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalToggleGroupControl, { 32771 label: (0,external_wp_i18n_namespaceObject.__)('Select heading level'), 32772 hideLabelFromVision: true, 32773 value: headingLevel, 32774 onChange: setHeadingLevel, 32775 isBlock: true, 32776 size: "__unstable-large", 32777 __nextHasNoMarginBottom: true 32778 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalToggleGroupControlOption, { 32779 value: "heading", 32780 label: (0,external_wp_i18n_namespaceObject._x)('All', 'heading levels') 32781 }), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalToggleGroupControlOption, { 32782 value: "h1", 32783 label: (0,external_wp_i18n_namespaceObject.__)('H1') 32784 }), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalToggleGroupControlOption, { 32785 value: "h2", 32786 label: (0,external_wp_i18n_namespaceObject.__)('H2') 32787 }), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalToggleGroupControlOption, { 32788 value: "h3", 32789 label: (0,external_wp_i18n_namespaceObject.__)('H3') 32790 }), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalToggleGroupControlOption, { 32791 value: "h4", 32792 label: (0,external_wp_i18n_namespaceObject.__)('H4') 32793 }), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalToggleGroupControlOption, { 32794 value: "h5", 32795 label: (0,external_wp_i18n_namespaceObject.__)('H5') 32796 }), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalToggleGroupControlOption, { 32797 value: "h6", 32798 label: (0,external_wp_i18n_namespaceObject.__)('H6') 32799 }))), (0,external_React_.createElement)(TypographyPanel, { 32800 element: element, 32801 headingLevel: headingLevel 32802 })); 32803 } 32804 /* harmony default export */ const screen_typography_element = (ScreenTypographyElement); 32805 32806 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/shuffle.js 32807 32808 /** 32809 * WordPress dependencies 32810 */ 32811 32812 const shuffle = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { 32813 viewBox: "0 0 24 24", 32814 xmlns: "http://www.w3.org/2000/SVG" 32815 }, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 32816 d: "M17.192 6.75L15.47 5.03l1.06-1.06 3.537 3.53-3.537 3.53-1.06-1.06 1.723-1.72h-3.19c-.602 0-.993.202-1.28.498-.309.319-.538.792-.695 1.383-.13.488-.222 1.023-.296 1.508-.034.664-.116 1.413-.303 2.117-.193.721-.513 1.467-1.068 2.04-.575.594-1.359.954-2.357.954H4v-1.5h4.003c.601 0 .993-.202 1.28-.498.308-.319.538-.792.695-1.383.149-.557.216-1.093.288-1.662l.039-.31a9.653 9.653 0 0 1 .272-1.653c.193-.722.513-1.467 1.067-2.04.576-.594 1.36-.954 2.358-.954h3.19zM8.004 6.75c.8 0 1.46.23 1.988.628a6.24 6.24 0 0 0-.684 1.396 1.725 1.725 0 0 0-.024-.026c-.287-.296-.679-.498-1.28-.498H4v-1.5h4.003zM12.699 14.726c-.161.459-.38.94-.684 1.396.527.397 1.188.628 1.988.628h3.19l-1.722 1.72 1.06 1.06L20.067 16l-3.537-3.53-1.06 1.06 1.723 1.72h-3.19c-.602 0-.993-.202-1.28-.498a1.96 1.96 0 0 1-.024-.026z" 32817 })); 32818 /* harmony default export */ const library_shuffle = (shuffle); 32819 32820 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/global-styles/color-indicator-wrapper.js 32821 32822 /** 32823 * External dependencies 32824 */ 32825 32826 32827 /** 32828 * WordPress dependencies 32829 */ 32830 32831 function ColorIndicatorWrapper({ 32832 className, 32833 ...props 32834 }) { 32835 return (0,external_React_.createElement)(external_wp_components_namespaceObject.Flex, { 32836 className: classnames_default()('edit-site-global-styles__color-indicator-wrapper', className), 32837 ...props 32838 }); 32839 } 32840 /* harmony default export */ const color_indicator_wrapper = (ColorIndicatorWrapper); 32841 32842 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/global-styles/palette.js 32843 32844 /** 32845 * WordPress dependencies 32846 */ 32847 32848 32849 32850 32851 32852 32853 /** 32854 * Internal dependencies 32855 */ 32856 32857 32858 32859 32860 32861 const { 32862 useGlobalSetting: palette_useGlobalSetting 32863 } = unlock(external_wp_blockEditor_namespaceObject.privateApis); 32864 const EMPTY_COLORS = []; 32865 function Palette({ 32866 name 32867 }) { 32868 const [customColors] = palette_useGlobalSetting('color.palette.custom'); 32869 const [themeColors] = palette_useGlobalSetting('color.palette.theme'); 32870 const [defaultColors] = palette_useGlobalSetting('color.palette.default'); 32871 const [defaultPaletteEnabled] = palette_useGlobalSetting('color.defaultPalette', name); 32872 const [randomizeThemeColors] = useColorRandomizer(); 32873 const colors = (0,external_wp_element_namespaceObject.useMemo)(() => [...(customColors || EMPTY_COLORS), ...(themeColors || EMPTY_COLORS), ...(defaultColors && defaultPaletteEnabled ? defaultColors : EMPTY_COLORS)], [customColors, themeColors, defaultColors, defaultPaletteEnabled]); 32874 const screenPath = !name ? '/colors/palette' : '/blocks/' + encodeURIComponent(name) + '/colors/palette'; 32875 const paletteButtonText = colors.length > 0 ? (0,external_wp_i18n_namespaceObject.sprintf)( 32876 // Translators: %d: Number of palette colors. 32877 (0,external_wp_i18n_namespaceObject._n)('%d color', '%d colors', colors.length), colors.length) : (0,external_wp_i18n_namespaceObject.__)('Add custom colors'); 32878 return (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { 32879 spacing: 3 32880 }, (0,external_React_.createElement)(subtitle, { 32881 level: 3 32882 }, (0,external_wp_i18n_namespaceObject.__)('Palette')), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalItemGroup, { 32883 isBordered: true, 32884 isSeparated: true 32885 }, (0,external_React_.createElement)(NavigationButtonAsItem, { 32886 path: screenPath, 32887 "aria-label": (0,external_wp_i18n_namespaceObject.__)('Color palettes') 32888 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { 32889 direction: colors.length === 0 ? 'row-reverse' : 'row' 32890 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalZStack, { 32891 isLayered: false, 32892 offset: -8 32893 }, colors.slice(0, 5).map(({ 32894 color 32895 }, index) => (0,external_React_.createElement)(color_indicator_wrapper, { 32896 key: `$color}-$index}` 32897 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.ColorIndicator, { 32898 colorValue: color 32899 })))), (0,external_React_.createElement)(external_wp_components_namespaceObject.FlexItem, null, paletteButtonText)))), window.__experimentalEnableColorRandomizer && themeColors?.length > 0 && (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 32900 variant: "secondary", 32901 icon: library_shuffle, 32902 onClick: randomizeThemeColors 32903 }, (0,external_wp_i18n_namespaceObject.__)('Randomize colors'))); 32904 } 32905 /* harmony default export */ const palette = (Palette); 32906 32907 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/global-styles/screen-colors.js 32908 32909 /** 32910 * WordPress dependencies 32911 */ 32912 32913 32914 32915 32916 /** 32917 * Internal dependencies 32918 */ 32919 32920 32921 32922 const { 32923 useGlobalStyle: screen_colors_useGlobalStyle, 32924 useGlobalSetting: screen_colors_useGlobalSetting, 32925 useSettingsForBlockElement: screen_colors_useSettingsForBlockElement, 32926 ColorPanel: screen_colors_StylesColorPanel 32927 } = unlock(external_wp_blockEditor_namespaceObject.privateApis); 32928 function ScreenColors() { 32929 const [style] = screen_colors_useGlobalStyle('', undefined, 'user', { 32930 shouldDecodeEncode: false 32931 }); 32932 const [inheritedStyle, setStyle] = screen_colors_useGlobalStyle('', undefined, 'all', { 32933 shouldDecodeEncode: false 32934 }); 32935 const [rawSettings] = screen_colors_useGlobalSetting(''); 32936 const settings = screen_colors_useSettingsForBlockElement(rawSettings); 32937 return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(header, { 32938 title: (0,external_wp_i18n_namespaceObject.__)('Colors'), 32939 description: (0,external_wp_i18n_namespaceObject.__)('Manage palettes and the default color of different global elements on the site.') 32940 }), (0,external_React_.createElement)("div", { 32941 className: "edit-site-global-styles-screen-colors" 32942 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { 32943 spacing: 10 32944 }, (0,external_React_.createElement)(palette, null), (0,external_React_.createElement)(screen_colors_StylesColorPanel, { 32945 inheritedValue: inheritedStyle, 32946 value: style, 32947 onChange: setStyle, 32948 settings: settings 32949 })))); 32950 } 32951 /* harmony default export */ const screen_colors = (ScreenColors); 32952 32953 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/global-styles/color-palette-panel.js 32954 32955 /** 32956 * WordPress dependencies 32957 */ 32958 32959 32960 32961 32962 32963 /** 32964 * Internal dependencies 32965 */ 32966 32967 const { 32968 useGlobalSetting: color_palette_panel_useGlobalSetting 32969 } = unlock(external_wp_blockEditor_namespaceObject.privateApis); 32970 const mobilePopoverProps = { 32971 placement: 'bottom-start', 32972 offset: 8 32973 }; 32974 function ColorPalettePanel({ 32975 name 32976 }) { 32977 const [themeColors, setThemeColors] = color_palette_panel_useGlobalSetting('color.palette.theme', name); 32978 const [baseThemeColors] = color_palette_panel_useGlobalSetting('color.palette.theme', name, 'base'); 32979 const [defaultColors, setDefaultColors] = color_palette_panel_useGlobalSetting('color.palette.default', name); 32980 const [baseDefaultColors] = color_palette_panel_useGlobalSetting('color.palette.default', name, 'base'); 32981 const [customColors, setCustomColors] = color_palette_panel_useGlobalSetting('color.palette.custom', name); 32982 const [defaultPaletteEnabled] = color_palette_panel_useGlobalSetting('color.defaultPalette', name); 32983 const isMobileViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('small', '<'); 32984 const popoverProps = isMobileViewport ? mobilePopoverProps : undefined; 32985 return (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { 32986 className: "edit-site-global-styles-color-palette-panel", 32987 spacing: 10 32988 }, !!themeColors && !!themeColors.length && (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalPaletteEdit, { 32989 canReset: themeColors !== baseThemeColors, 32990 canOnlyChangeValues: true, 32991 colors: themeColors, 32992 onChange: setThemeColors, 32993 paletteLabel: (0,external_wp_i18n_namespaceObject.__)('Theme'), 32994 paletteLabelHeadingLevel: 3, 32995 popoverProps: popoverProps 32996 }), !!defaultColors && !!defaultColors.length && !!defaultPaletteEnabled && (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalPaletteEdit, { 32997 canReset: defaultColors !== baseDefaultColors, 32998 canOnlyChangeValues: true, 32999 colors: defaultColors, 33000 onChange: setDefaultColors, 33001 paletteLabel: (0,external_wp_i18n_namespaceObject.__)('Default'), 33002 paletteLabelHeadingLevel: 3, 33003 popoverProps: popoverProps 33004 }), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalPaletteEdit, { 33005 colors: customColors, 33006 onChange: setCustomColors, 33007 paletteLabel: (0,external_wp_i18n_namespaceObject.__)('Custom'), 33008 paletteLabelHeadingLevel: 3, 33009 emptyMessage: (0,external_wp_i18n_namespaceObject.__)('Custom colors are empty! Add some colors to create your own color palette.'), 33010 slugPrefix: "custom-", 33011 popoverProps: popoverProps 33012 })); 33013 } 33014 33015 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/global-styles/gradients-palette-panel.js 33016 33017 /** 33018 * WordPress dependencies 33019 */ 33020 33021 33022 33023 33024 33025 /** 33026 * Internal dependencies 33027 */ 33028 33029 33030 const { 33031 useGlobalSetting: gradients_palette_panel_useGlobalSetting 33032 } = unlock(external_wp_blockEditor_namespaceObject.privateApis); 33033 const gradients_palette_panel_mobilePopoverProps = { 33034 placement: 'bottom-start', 33035 offset: 8 33036 }; 33037 const gradients_palette_panel_noop = () => {}; 33038 function GradientPalettePanel({ 33039 name 33040 }) { 33041 const [themeGradients, setThemeGradients] = gradients_palette_panel_useGlobalSetting('color.gradients.theme', name); 33042 const [baseThemeGradients] = gradients_palette_panel_useGlobalSetting('color.gradients.theme', name, 'base'); 33043 const [defaultGradients, setDefaultGradients] = gradients_palette_panel_useGlobalSetting('color.gradients.default', name); 33044 const [baseDefaultGradients] = gradients_palette_panel_useGlobalSetting('color.gradients.default', name, 'base'); 33045 const [customGradients, setCustomGradients] = gradients_palette_panel_useGlobalSetting('color.gradients.custom', name); 33046 const [defaultPaletteEnabled] = gradients_palette_panel_useGlobalSetting('color.defaultGradients', name); 33047 const [customDuotone] = gradients_palette_panel_useGlobalSetting('color.duotone.custom') || []; 33048 const [defaultDuotone] = gradients_palette_panel_useGlobalSetting('color.duotone.default') || []; 33049 const [themeDuotone] = gradients_palette_panel_useGlobalSetting('color.duotone.theme') || []; 33050 const [defaultDuotoneEnabled] = gradients_palette_panel_useGlobalSetting('color.defaultDuotone'); 33051 const duotonePalette = [...(customDuotone || []), ...(themeDuotone || []), ...(defaultDuotone && defaultDuotoneEnabled ? defaultDuotone : [])]; 33052 const isMobileViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('small', '<'); 33053 const popoverProps = isMobileViewport ? gradients_palette_panel_mobilePopoverProps : undefined; 33054 return (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { 33055 className: "edit-site-global-styles-gradient-palette-panel", 33056 spacing: 10 33057 }, !!themeGradients && !!themeGradients.length && (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalPaletteEdit, { 33058 canReset: themeGradients !== baseThemeGradients, 33059 canOnlyChangeValues: true, 33060 gradients: themeGradients, 33061 onChange: setThemeGradients, 33062 paletteLabel: (0,external_wp_i18n_namespaceObject.__)('Theme'), 33063 paletteLabelHeadingLevel: 3, 33064 popoverProps: popoverProps 33065 }), !!defaultGradients && !!defaultGradients.length && !!defaultPaletteEnabled && (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalPaletteEdit, { 33066 canReset: defaultGradients !== baseDefaultGradients, 33067 canOnlyChangeValues: true, 33068 gradients: defaultGradients, 33069 onChange: setDefaultGradients, 33070 paletteLabel: (0,external_wp_i18n_namespaceObject.__)('Default'), 33071 paletteLabelLevel: 3, 33072 popoverProps: popoverProps 33073 }), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalPaletteEdit, { 33074 gradients: customGradients, 33075 onChange: setCustomGradients, 33076 paletteLabel: (0,external_wp_i18n_namespaceObject.__)('Custom'), 33077 paletteLabelLevel: 3, 33078 emptyMessage: (0,external_wp_i18n_namespaceObject.__)('Custom gradients are empty! Add some gradients to create your own palette.'), 33079 slugPrefix: "custom-", 33080 popoverProps: popoverProps 33081 }), !!duotonePalette && !!duotonePalette.length && (0,external_React_.createElement)("div", null, (0,external_React_.createElement)(subtitle, { 33082 level: 3 33083 }, (0,external_wp_i18n_namespaceObject.__)('Duotone')), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalSpacer, { 33084 margin: 3 33085 }), (0,external_React_.createElement)(external_wp_components_namespaceObject.DuotonePicker, { 33086 duotonePalette: duotonePalette, 33087 disableCustomDuotone: true, 33088 disableCustomColors: true, 33089 clearable: false, 33090 onChange: gradients_palette_panel_noop 33091 }))); 33092 } 33093 33094 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/global-styles/screen-color-palette.js 33095 33096 /** 33097 * WordPress dependencies 33098 */ 33099 33100 33101 33102 /** 33103 * Internal dependencies 33104 */ 33105 33106 33107 33108 33109 const { 33110 Tabs: screen_color_palette_Tabs 33111 } = unlock(external_wp_components_namespaceObject.privateApis); 33112 function ScreenColorPalette({ 33113 name 33114 }) { 33115 return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(header, { 33116 title: (0,external_wp_i18n_namespaceObject.__)('Palette'), 33117 description: (0,external_wp_i18n_namespaceObject.__)('Palettes are used to provide default color options for blocks and various design tools. Here you can edit the colors with their labels.') 33118 }), (0,external_React_.createElement)(screen_color_palette_Tabs, null, (0,external_React_.createElement)(screen_color_palette_Tabs.TabList, null, (0,external_React_.createElement)(screen_color_palette_Tabs.Tab, { 33119 tabId: "solid" 33120 }, "Solid"), (0,external_React_.createElement)(screen_color_palette_Tabs.Tab, { 33121 tabId: "gradient" 33122 }, "Gradient")), (0,external_React_.createElement)(screen_color_palette_Tabs.TabPanel, { 33123 tabId: "solid", 33124 focusable: false 33125 }, (0,external_React_.createElement)(ColorPalettePanel, { 33126 name: name 33127 })), (0,external_React_.createElement)(screen_color_palette_Tabs.TabPanel, { 33128 tabId: "gradient", 33129 focusable: false 33130 }, (0,external_React_.createElement)(GradientPalettePanel, { 33131 name: name 33132 })))); 33133 } 33134 /* harmony default export */ const screen_color_palette = (ScreenColorPalette); 33135 33136 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/global-styles/dimensions-panel.js 33137 33138 /** 33139 * WordPress dependencies 33140 */ 33141 33142 33143 33144 /** 33145 * Internal dependencies 33146 */ 33147 33148 const { 33149 useGlobalStyle: dimensions_panel_useGlobalStyle, 33150 useGlobalSetting: dimensions_panel_useGlobalSetting, 33151 useSettingsForBlockElement: dimensions_panel_useSettingsForBlockElement, 33152 DimensionsPanel: dimensions_panel_StylesDimensionsPanel 33153 } = unlock(external_wp_blockEditor_namespaceObject.privateApis); 33154 const DEFAULT_CONTROLS = { 33155 contentSize: true, 33156 wideSize: true, 33157 padding: true, 33158 margin: true, 33159 blockGap: true, 33160 minHeight: true, 33161 childLayout: false 33162 }; 33163 function DimensionsPanel() { 33164 const [style] = dimensions_panel_useGlobalStyle('', undefined, 'user', { 33165 shouldDecodeEncode: false 33166 }); 33167 const [inheritedStyle, setStyle] = dimensions_panel_useGlobalStyle('', undefined, 'all', { 33168 shouldDecodeEncode: false 33169 }); 33170 const [userSettings] = dimensions_panel_useGlobalSetting('', undefined, 'user'); 33171 const [rawSettings, setSettings] = dimensions_panel_useGlobalSetting(''); 33172 const settings = dimensions_panel_useSettingsForBlockElement(rawSettings); 33173 33174 // These intermediary objects are needed because the "layout" property is stored 33175 // in settings rather than styles. 33176 const inheritedStyleWithLayout = (0,external_wp_element_namespaceObject.useMemo)(() => { 33177 return { 33178 ...inheritedStyle, 33179 layout: settings.layout 33180 }; 33181 }, [inheritedStyle, settings.layout]); 33182 const styleWithLayout = (0,external_wp_element_namespaceObject.useMemo)(() => { 33183 return { 33184 ...style, 33185 layout: userSettings.layout 33186 }; 33187 }, [style, userSettings.layout]); 33188 const onChange = newStyle => { 33189 const updatedStyle = { 33190 ...newStyle 33191 }; 33192 delete updatedStyle.layout; 33193 setStyle(updatedStyle); 33194 if (newStyle.layout !== userSettings.layout) { 33195 const updatedSettings = { 33196 ...userSettings, 33197 layout: newStyle.layout 33198 }; 33199 33200 // Ensure any changes to layout definitions are not persisted. 33201 if (updatedSettings.layout?.definitions) { 33202 delete updatedSettings.layout.definitions; 33203 } 33204 setSettings(updatedSettings); 33205 } 33206 }; 33207 return (0,external_React_.createElement)(dimensions_panel_StylesDimensionsPanel, { 33208 inheritedValue: inheritedStyleWithLayout, 33209 value: styleWithLayout, 33210 onChange: onChange, 33211 settings: settings, 33212 includeLayoutControls: true, 33213 defaultControls: DEFAULT_CONTROLS 33214 }); 33215 } 33216 33217 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/global-styles/screen-layout.js 33218 33219 /** 33220 * WordPress dependencies 33221 */ 33222 33223 33224 33225 /** 33226 * Internal dependencies 33227 */ 33228 33229 33230 33231 const { 33232 useHasDimensionsPanel: screen_layout_useHasDimensionsPanel, 33233 useGlobalSetting: screen_layout_useGlobalSetting, 33234 useSettingsForBlockElement: screen_layout_useSettingsForBlockElement 33235 } = unlock(external_wp_blockEditor_namespaceObject.privateApis); 33236 function ScreenLayout() { 33237 const [rawSettings] = screen_layout_useGlobalSetting(''); 33238 const settings = screen_layout_useSettingsForBlockElement(rawSettings); 33239 const hasDimensionsPanel = screen_layout_useHasDimensionsPanel(settings); 33240 return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(header, { 33241 title: (0,external_wp_i18n_namespaceObject.__)('Layout') 33242 }), hasDimensionsPanel && (0,external_React_.createElement)(DimensionsPanel, null)); 33243 } 33244 /* harmony default export */ const screen_layout = (ScreenLayout); 33245 33246 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/global-styles/screen-style-variations.js 33247 33248 /** 33249 * WordPress dependencies 33250 */ 33251 33252 33253 33254 33255 33256 33257 /** 33258 * Internal dependencies 33259 */ 33260 33261 33262 function ScreenStyleVariations() { 33263 const { 33264 mode 33265 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 33266 return { 33267 mode: select(external_wp_blockEditor_namespaceObject.store).__unstableGetEditorMode() 33268 }; 33269 }, []); 33270 const shouldRevertInitialMode = (0,external_wp_element_namespaceObject.useRef)(null); 33271 (0,external_wp_element_namespaceObject.useEffect)(() => { 33272 // ignore changes to zoom-out mode as we explictily change to it on mount. 33273 if (mode !== 'zoom-out') { 33274 shouldRevertInitialMode.current = false; 33275 } 33276 }, [mode]); 33277 33278 // Intentionality left without any dependency. 33279 // This effect should only run the first time the component is rendered. 33280 // The effect opens the zoom-out view if it is not open before when applying a style variation. 33281 (0,external_wp_element_namespaceObject.useEffect)(() => { 33282 if (mode !== 'zoom-out') { 33283 __unstableSetEditorMode('zoom-out'); 33284 shouldRevertInitialMode.current = true; 33285 return () => { 33286 // if there were not mode changes revert to the initial mode when unmounting. 33287 if (shouldRevertInitialMode.current) { 33288 __unstableSetEditorMode(mode); 33289 } 33290 }; 33291 } 33292 // eslint-disable-next-line react-hooks/exhaustive-deps 33293 }, []); 33294 const { 33295 __unstableSetEditorMode 33296 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store); 33297 return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(header, { 33298 back: "/", 33299 title: (0,external_wp_i18n_namespaceObject.__)('Browse styles'), 33300 description: (0,external_wp_i18n_namespaceObject.__)('Choose a variation to change the look of the site.') 33301 }), (0,external_React_.createElement)(external_wp_components_namespaceObject.Card, { 33302 size: "small", 33303 isBorderless: true, 33304 className: "edit-site-global-styles-screen-style-variations" 33305 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.CardBody, null, (0,external_React_.createElement)(StyleVariationsContainer, null)))); 33306 } 33307 /* harmony default export */ const screen_style_variations = (ScreenStyleVariations); 33308 33309 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/global-styles/screen-css.js 33310 33311 /** 33312 * WordPress dependencies 33313 */ 33314 33315 33316 33317 33318 /** 33319 * Internal dependencies 33320 */ 33321 33322 33323 const { 33324 useGlobalStyle: screen_css_useGlobalStyle, 33325 AdvancedPanel: screen_css_StylesAdvancedPanel 33326 } = unlock(external_wp_blockEditor_namespaceObject.privateApis); 33327 function ScreenCSS() { 33328 const description = (0,external_wp_i18n_namespaceObject.__)('Add your own CSS to customize the appearance and layout of your site.'); 33329 const [style] = screen_css_useGlobalStyle('', undefined, 'user', { 33330 shouldDecodeEncode: false 33331 }); 33332 const [inheritedStyle, setStyle] = screen_css_useGlobalStyle('', undefined, 'all', { 33333 shouldDecodeEncode: false 33334 }); 33335 return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(header, { 33336 title: (0,external_wp_i18n_namespaceObject.__)('CSS'), 33337 description: (0,external_React_.createElement)(external_React_.Fragment, null, description, (0,external_React_.createElement)(external_wp_components_namespaceObject.ExternalLink, { 33338 href: "https://wordpress.org/documentation/article/css/", 33339 className: "edit-site-global-styles-screen-css-help-link" 33340 }, (0,external_wp_i18n_namespaceObject.__)('Learn more about CSS'))) 33341 }), (0,external_React_.createElement)("div", { 33342 className: "edit-site-global-styles-screen-css" 33343 }, (0,external_React_.createElement)(screen_css_StylesAdvancedPanel, { 33344 value: style, 33345 onChange: setStyle, 33346 inheritedValue: inheritedStyle 33347 }))); 33348 } 33349 /* harmony default export */ const screen_css = (ScreenCSS); 33350 33351 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/revisions/index.js 33352 33353 /** 33354 * WordPress dependencies 33355 */ 33356 33357 33358 33359 33360 33361 33362 /** 33363 * Internal dependencies 33364 */ 33365 33366 33367 33368 33369 const { 33370 ExperimentalBlockEditorProvider: revisions_ExperimentalBlockEditorProvider, 33371 GlobalStylesContext: revisions_GlobalStylesContext, 33372 useGlobalStylesOutputWithConfig: revisions_useGlobalStylesOutputWithConfig 33373 } = unlock(external_wp_blockEditor_namespaceObject.privateApis); 33374 function revisions_isObjectEmpty(object) { 33375 return !object || Object.keys(object).length === 0; 33376 } 33377 function Revisions({ 33378 userConfig, 33379 blocks 33380 }) { 33381 const { 33382 base: baseConfig 33383 } = (0,external_wp_element_namespaceObject.useContext)(revisions_GlobalStylesContext); 33384 const mergedConfig = (0,external_wp_element_namespaceObject.useMemo)(() => { 33385 if (!revisions_isObjectEmpty(userConfig) && !revisions_isObjectEmpty(baseConfig)) { 33386 return mergeBaseAndUserConfigs(baseConfig, userConfig); 33387 } 33388 return {}; 33389 }, [baseConfig, userConfig]); 33390 const renderedBlocksArray = (0,external_wp_element_namespaceObject.useMemo)(() => Array.isArray(blocks) ? blocks : [blocks], [blocks]); 33391 const originalSettings = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_blockEditor_namespaceObject.store).getSettings(), []); 33392 const settings = (0,external_wp_element_namespaceObject.useMemo)(() => ({ 33393 ...originalSettings, 33394 __unstableIsPreviewMode: true 33395 }), [originalSettings]); 33396 const [globalStyles] = revisions_useGlobalStylesOutputWithConfig(mergedConfig); 33397 const editorStyles = !revisions_isObjectEmpty(globalStyles) && !revisions_isObjectEmpty(userConfig) ? globalStyles : settings.styles; 33398 return (0,external_React_.createElement)(editor_canvas_container, { 33399 title: (0,external_wp_i18n_namespaceObject.__)('Revisions'), 33400 closeButtonLabel: (0,external_wp_i18n_namespaceObject.__)('Close revisions'), 33401 enableResizing: true 33402 }, (0,external_React_.createElement)(external_wp_blockEditor_namespaceObject.__unstableIframe, { 33403 className: "edit-site-revisions__iframe", 33404 name: "revisions", 33405 tabIndex: 0 33406 }, (0,external_React_.createElement)(external_wp_blockEditor_namespaceObject.__unstableEditorStyles, { 33407 styles: editorStyles 33408 }), (0,external_React_.createElement)("style", null, 33409 // Forming a "block formatting context" to prevent margin collapsing. 33410 // @see https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Block_formatting_context 33411 `.is-root-container { display: flow-root; }`), (0,external_React_.createElement)(external_wp_components_namespaceObject.Disabled, { 33412 className: "edit-site-revisions__example-preview__content" 33413 }, (0,external_React_.createElement)(revisions_ExperimentalBlockEditorProvider, { 33414 value: renderedBlocksArray, 33415 settings: settings 33416 }, (0,external_React_.createElement)(external_wp_blockEditor_namespaceObject.BlockList, { 33417 renderAppender: false 33418 }))))); 33419 } 33420 /* harmony default export */ const components_revisions = (Revisions); 33421 33422 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/global-styles/screen-revisions/revisions-buttons.js 33423 33424 /** 33425 * External dependencies 33426 */ 33427 33428 33429 /** 33430 * WordPress dependencies 33431 */ 33432 33433 33434 33435 33436 33437 33438 33439 /** 33440 * Internal dependencies 33441 */ 33442 33443 const DAY_IN_MILLISECONDS = 60 * 60 * 1000 * 24; 33444 const { 33445 getGlobalStylesChanges 33446 } = unlock(external_wp_blockEditor_namespaceObject.privateApis); 33447 function ChangesSummary({ 33448 revision, 33449 previousRevision 33450 }) { 33451 const changes = getGlobalStylesChanges(revision, previousRevision, { 33452 maxResults: 7 33453 }); 33454 if (!changes.length) { 33455 return null; 33456 } 33457 return (0,external_React_.createElement)("ul", { 33458 "data-testid": "global-styles-revision-changes", 33459 className: "edit-site-global-styles-screen-revisions__changes" 33460 }, changes.map(change => (0,external_React_.createElement)("li", { 33461 key: change 33462 }, change))); 33463 } 33464 33465 /** 33466 * Returns a button label for the revision. 33467 * 33468 * @param {string|number} id A revision object. 33469 * @param {string} authorDisplayName Author name. 33470 * @param {string} formattedModifiedDate Revision modified date formatted. 33471 * @param {boolean} areStylesEqual Whether the revision matches the current editor styles. 33472 * @return {string} Translated label. 33473 */ 33474 function getRevisionLabel(id, authorDisplayName, formattedModifiedDate, areStylesEqual) { 33475 if ('parent' === id) { 33476 return (0,external_wp_i18n_namespaceObject.__)('Reset the styles to the theme defaults'); 33477 } 33478 if ('unsaved' === id) { 33479 return (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: author display name */ 33480 (0,external_wp_i18n_namespaceObject.__)('Unsaved changes by %s'), authorDisplayName); 33481 } 33482 return areStylesEqual ? (0,external_wp_i18n_namespaceObject.sprintf)( 33483 // translators: %1$s: author display name, %2$s: revision creation date. 33484 (0,external_wp_i18n_namespaceObject.__)('Changes saved by %1$s on %2$s. This revision matches current editor styles.'), authorDisplayName, formattedModifiedDate) : (0,external_wp_i18n_namespaceObject.sprintf)( 33485 // translators: %1$s: author display name, %2$s: revision creation date. 33486 (0,external_wp_i18n_namespaceObject.__)('Changes saved by %1$s on %2$s'), authorDisplayName, formattedModifiedDate); 33487 } 33488 33489 /** 33490 * Returns a rendered list of revisions buttons. 33491 * 33492 * @typedef {Object} props 33493 * @property {Array<Object>} userRevisions A collection of user revisions. 33494 * @property {number} selectedRevisionId The id of the currently-selected revision. 33495 * @property {Function} onChange Callback fired when a revision is selected. 33496 * 33497 * @param {props} Component props. 33498 * @return {JSX.Element} The modal component. 33499 */ 33500 function RevisionsButtons({ 33501 userRevisions, 33502 selectedRevisionId, 33503 onChange, 33504 canApplyRevision, 33505 onApplyRevision 33506 }) { 33507 const { 33508 currentThemeName, 33509 currentUser 33510 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 33511 const { 33512 getCurrentTheme, 33513 getCurrentUser 33514 } = select(external_wp_coreData_namespaceObject.store); 33515 const currentTheme = getCurrentTheme(); 33516 return { 33517 currentThemeName: currentTheme?.name?.rendered || currentTheme?.stylesheet, 33518 currentUser: getCurrentUser() 33519 }; 33520 }, []); 33521 const dateNowInMs = (0,external_wp_date_namespaceObject.getDate)().getTime(); 33522 const { 33523 datetimeAbbreviated 33524 } = (0,external_wp_date_namespaceObject.getSettings)().formats; 33525 return (0,external_React_.createElement)("ol", { 33526 className: "edit-site-global-styles-screen-revisions__revisions-list", 33527 "aria-label": (0,external_wp_i18n_namespaceObject.__)('Global styles revisions list'), 33528 role: "group" 33529 }, userRevisions.map((revision, index) => { 33530 const { 33531 id, 33532 author, 33533 modified 33534 } = revision; 33535 const isUnsaved = 'unsaved' === id; 33536 // Unsaved changes are created by the current user. 33537 const revisionAuthor = isUnsaved ? currentUser : author; 33538 const authorDisplayName = revisionAuthor?.name || (0,external_wp_i18n_namespaceObject.__)('User'); 33539 const authorAvatar = revisionAuthor?.avatar_urls?.['48']; 33540 const isFirstItem = index === 0; 33541 const isSelected = selectedRevisionId ? selectedRevisionId === id : isFirstItem; 33542 const areStylesEqual = !canApplyRevision && isSelected; 33543 const isReset = 'parent' === id; 33544 const modifiedDate = (0,external_wp_date_namespaceObject.getDate)(modified); 33545 const displayDate = modified && dateNowInMs - modifiedDate.getTime() > DAY_IN_MILLISECONDS ? (0,external_wp_date_namespaceObject.dateI18n)(datetimeAbbreviated, modifiedDate) : (0,external_wp_date_namespaceObject.humanTimeDiff)(modified); 33546 const revisionLabel = getRevisionLabel(id, authorDisplayName, (0,external_wp_date_namespaceObject.dateI18n)(datetimeAbbreviated, modifiedDate), areStylesEqual); 33547 return (0,external_React_.createElement)("li", { 33548 className: classnames_default()('edit-site-global-styles-screen-revisions__revision-item', { 33549 'is-selected': isSelected, 33550 'is-active': areStylesEqual, 33551 'is-reset': isReset 33552 }), 33553 key: id, 33554 "aria-current": isSelected 33555 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 33556 className: "edit-site-global-styles-screen-revisions__revision-button", 33557 disabled: isSelected, 33558 onClick: () => { 33559 onChange(revision); 33560 }, 33561 "aria-label": revisionLabel 33562 }, isReset ? (0,external_React_.createElement)("span", { 33563 className: "edit-site-global-styles-screen-revisions__description" 33564 }, (0,external_wp_i18n_namespaceObject.__)('Default styles'), (0,external_React_.createElement)("span", { 33565 className: "edit-site-global-styles-screen-revisions__meta" 33566 }, currentThemeName)) : (0,external_React_.createElement)("span", { 33567 className: "edit-site-global-styles-screen-revisions__description" 33568 }, isUnsaved ? (0,external_React_.createElement)("span", { 33569 className: "edit-site-global-styles-screen-revisions__date" 33570 }, (0,external_wp_i18n_namespaceObject.__)('(Unsaved)')) : (0,external_React_.createElement)("time", { 33571 className: "edit-site-global-styles-screen-revisions__date", 33572 dateTime: modified 33573 }, displayDate), (0,external_React_.createElement)("span", { 33574 className: "edit-site-global-styles-screen-revisions__meta" 33575 }, (0,external_React_.createElement)("img", { 33576 alt: authorDisplayName, 33577 src: authorAvatar 33578 }), authorDisplayName), isSelected && (0,external_React_.createElement)(ChangesSummary, { 33579 revision: revision, 33580 previousRevision: index < userRevisions.length ? userRevisions[index + 1] : {} 33581 }))), isSelected && (areStylesEqual ? (0,external_React_.createElement)("p", { 33582 className: "edit-site-global-styles-screen-revisions__applied-text" 33583 }, (0,external_wp_i18n_namespaceObject.__)('These styles are already applied to your site.')) : (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 33584 disabled: areStylesEqual, 33585 size: "compact", 33586 variant: "primary", 33587 className: "edit-site-global-styles-screen-revisions__apply-button", 33588 onClick: onApplyRevision 33589 }, isReset ? (0,external_wp_i18n_namespaceObject.__)('Reset to defaults') : (0,external_wp_i18n_namespaceObject.__)('Apply')))); 33590 })); 33591 } 33592 /* harmony default export */ const revisions_buttons = (RevisionsButtons); 33593 33594 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/pagination/index.js 33595 33596 /** 33597 * External dependencies 33598 */ 33599 33600 33601 /** 33602 * WordPress dependencies 33603 */ 33604 33605 33606 function Pagination({ 33607 currentPage, 33608 numPages, 33609 changePage, 33610 totalItems, 33611 className, 33612 disabled = false, 33613 buttonVariant = 'tertiary', 33614 label = (0,external_wp_i18n_namespaceObject.__)('Pagination Navigation') 33615 }) { 33616 return (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { 33617 expanded: false, 33618 as: "nav", 33619 "aria-label": label, 33620 spacing: 3, 33621 justify: "flex-start", 33622 className: classnames_default()('edit-site-pagination', className) 33623 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalText, { 33624 variant: "muted", 33625 className: "edit-site-pagination__total" 33626 }, 33627 // translators: %s: Total number of patterns. 33628 (0,external_wp_i18n_namespaceObject.sprintf)( 33629 // translators: %s: Total number of patterns. 33630 (0,external_wp_i18n_namespaceObject._n)('%s item', '%s items', totalItems), totalItems)), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { 33631 expanded: false, 33632 spacing: 1 33633 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 33634 variant: buttonVariant, 33635 onClick: () => changePage(1), 33636 disabled: disabled || currentPage === 1, 33637 "aria-label": (0,external_wp_i18n_namespaceObject.__)('First page') 33638 }, "\xAB"), (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 33639 variant: buttonVariant, 33640 onClick: () => changePage(currentPage - 1), 33641 disabled: disabled || currentPage === 1, 33642 "aria-label": (0,external_wp_i18n_namespaceObject.__)('Previous page') 33643 }, "\u2039")), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalText, { 33644 variant: "muted" 33645 }, (0,external_wp_i18n_namespaceObject.sprintf)( 33646 // translators: %1$s: Current page number, %2$s: Total number of pages. 33647 (0,external_wp_i18n_namespaceObject._x)('%1$s of %2$s', 'paging'), currentPage, numPages)), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { 33648 expanded: false, 33649 spacing: 1 33650 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 33651 variant: buttonVariant, 33652 onClick: () => changePage(currentPage + 1), 33653 disabled: disabled || currentPage === numPages, 33654 "aria-label": (0,external_wp_i18n_namespaceObject.__)('Next page') 33655 }, "\u203A"), (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 33656 variant: buttonVariant, 33657 onClick: () => changePage(numPages), 33658 disabled: disabled || currentPage === numPages, 33659 "aria-label": (0,external_wp_i18n_namespaceObject.__)('Last page') 33660 }, "\xBB"))); 33661 } 33662 33663 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/global-styles/screen-revisions/index.js 33664 33665 /** 33666 * WordPress dependencies 33667 */ 33668 33669 33670 33671 33672 33673 33674 /** 33675 * Internal dependencies 33676 */ 33677 33678 33679 33680 33681 33682 33683 33684 33685 const { 33686 GlobalStylesContext: screen_revisions_GlobalStylesContext, 33687 areGlobalStyleConfigsEqual: screen_revisions_areGlobalStyleConfigsEqual 33688 } = unlock(external_wp_blockEditor_namespaceObject.privateApis); 33689 const PAGE_SIZE = 10; 33690 function ScreenRevisions() { 33691 const { 33692 goTo 33693 } = (0,external_wp_components_namespaceObject.__experimentalUseNavigator)(); 33694 const { 33695 user: currentEditorGlobalStyles, 33696 setUserConfig 33697 } = (0,external_wp_element_namespaceObject.useContext)(screen_revisions_GlobalStylesContext); 33698 const { 33699 blocks, 33700 editorCanvasContainerView 33701 } = (0,external_wp_data_namespaceObject.useSelect)(select => ({ 33702 editorCanvasContainerView: unlock(select(store_store)).getEditorCanvasContainerView(), 33703 blocks: select(external_wp_blockEditor_namespaceObject.store).getBlocks() 33704 }), []); 33705 const [currentPage, setCurrentPage] = (0,external_wp_element_namespaceObject.useState)(1); 33706 const [currentRevisions, setCurrentRevisions] = (0,external_wp_element_namespaceObject.useState)([]); 33707 const { 33708 revisions, 33709 isLoading, 33710 hasUnsavedChanges, 33711 revisionsCount 33712 } = useGlobalStylesRevisions({ 33713 query: { 33714 per_page: PAGE_SIZE, 33715 page: currentPage 33716 } 33717 }); 33718 const numPages = Math.ceil(revisionsCount / PAGE_SIZE); 33719 const [currentlySelectedRevision, setCurrentlySelectedRevision] = (0,external_wp_element_namespaceObject.useState)(currentEditorGlobalStyles); 33720 const [isLoadingRevisionWithUnsavedChanges, setIsLoadingRevisionWithUnsavedChanges] = (0,external_wp_element_namespaceObject.useState)(false); 33721 const { 33722 setEditorCanvasContainerView 33723 } = unlock((0,external_wp_data_namespaceObject.useDispatch)(store_store)); 33724 const selectedRevisionMatchesEditorStyles = screen_revisions_areGlobalStyleConfigsEqual(currentlySelectedRevision, currentEditorGlobalStyles); 33725 const onCloseRevisions = () => { 33726 goTo('/'); // Return to global styles main panel. 33727 const canvasContainerView = editorCanvasContainerView === 'global-styles-revisions:style-book' ? 'style-book' : undefined; 33728 setEditorCanvasContainerView(canvasContainerView); 33729 }; 33730 const restoreRevision = revision => { 33731 setUserConfig(() => ({ 33732 styles: revision?.styles, 33733 settings: revision?.settings 33734 })); 33735 setIsLoadingRevisionWithUnsavedChanges(false); 33736 onCloseRevisions(); 33737 }; 33738 const selectRevision = revision => { 33739 setCurrentlySelectedRevision({ 33740 styles: revision?.styles || {}, 33741 settings: revision?.settings || {}, 33742 id: revision?.id 33743 }); 33744 }; 33745 (0,external_wp_element_namespaceObject.useEffect)(() => { 33746 if (!editorCanvasContainerView || !editorCanvasContainerView.startsWith('global-styles-revisions')) { 33747 goTo('/'); // Return to global styles main panel. 33748 } 33749 }, [editorCanvasContainerView]); 33750 (0,external_wp_element_namespaceObject.useEffect)(() => { 33751 if (!isLoading && revisions.length) { 33752 setCurrentRevisions(revisions); 33753 } 33754 }, [revisions, isLoading]); 33755 const firstRevision = revisions[0]; 33756 const currentlySelectedRevisionId = currentlySelectedRevision?.id; 33757 const shouldSelectFirstItem = !!firstRevision?.id && !selectedRevisionMatchesEditorStyles && !currentlySelectedRevisionId; 33758 (0,external_wp_element_namespaceObject.useEffect)(() => { 33759 /* 33760 * Ensure that the first item is selected and loaded into the preview pane 33761 * when no revision is selected and the selected styles don't match the current editor styles. 33762 * This is required in case editor styles are changed outside the revisions panel, 33763 * e.g., via the reset styles function of useGlobalStylesReset(). 33764 * See: https://github.com/WordPress/gutenberg/issues/55866 33765 */ 33766 if (shouldSelectFirstItem) { 33767 setCurrentlySelectedRevision({ 33768 styles: firstRevision?.styles || {}, 33769 settings: firstRevision?.settings || {}, 33770 id: firstRevision?.id 33771 }); 33772 } 33773 }, [shouldSelectFirstItem, firstRevision]); 33774 33775 // Only display load button if there is a revision to load, 33776 // and it is different from the current editor styles. 33777 const isLoadButtonEnabled = !!currentlySelectedRevisionId && currentlySelectedRevisionId !== 'unsaved' && !selectedRevisionMatchesEditorStyles; 33778 const hasRevisions = !!currentRevisions.length; 33779 return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(header, { 33780 title: revisionsCount && 33781 // translators: %s: number of revisions. 33782 (0,external_wp_i18n_namespaceObject.sprintf)((0,external_wp_i18n_namespaceObject.__)('Revisions (%s)'), revisionsCount), 33783 description: (0,external_wp_i18n_namespaceObject.__)('Click on previously saved styles to preview them. To restore a selected version to the editor, hit "Apply." When you\'re ready, use the Save button to save your changes.'), 33784 onBack: onCloseRevisions 33785 }), !hasRevisions && (0,external_React_.createElement)(external_wp_components_namespaceObject.Spinner, { 33786 className: "edit-site-global-styles-screen-revisions__loading" 33787 }), hasRevisions && (editorCanvasContainerView === 'global-styles-revisions:style-book' ? (0,external_React_.createElement)(style_book, { 33788 userConfig: currentlySelectedRevision, 33789 isSelected: () => {}, 33790 onClose: () => { 33791 setEditorCanvasContainerView('global-styles-revisions'); 33792 } 33793 }) : (0,external_React_.createElement)(components_revisions, { 33794 blocks: blocks, 33795 userConfig: currentlySelectedRevision, 33796 closeButtonLabel: (0,external_wp_i18n_namespaceObject.__)('Close revisions') 33797 })), (0,external_React_.createElement)(revisions_buttons, { 33798 onChange: selectRevision, 33799 selectedRevisionId: currentlySelectedRevisionId, 33800 userRevisions: currentRevisions, 33801 canApplyRevision: isLoadButtonEnabled, 33802 onApplyRevision: () => hasUnsavedChanges ? setIsLoadingRevisionWithUnsavedChanges(true) : restoreRevision(currentlySelectedRevision) 33803 }), numPages > 1 && (0,external_React_.createElement)("div", { 33804 className: "edit-site-global-styles-screen-revisions__footer" 33805 }, (0,external_React_.createElement)(Pagination, { 33806 className: "edit-site-global-styles-screen-revisions__pagination", 33807 currentPage: currentPage, 33808 numPages: numPages, 33809 changePage: setCurrentPage, 33810 totalItems: revisionsCount, 33811 disabled: isLoading, 33812 label: (0,external_wp_i18n_namespaceObject.__)('Global Styles pagination navigation') 33813 })), isLoadingRevisionWithUnsavedChanges && (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalConfirmDialog, { 33814 isOpen: isLoadingRevisionWithUnsavedChanges, 33815 confirmButtonText: (0,external_wp_i18n_namespaceObject.__)('Apply'), 33816 onConfirm: () => restoreRevision(currentlySelectedRevision), 33817 onCancel: () => setIsLoadingRevisionWithUnsavedChanges(false) 33818 }, (0,external_wp_i18n_namespaceObject.__)('Any unsaved changes will be lost when you apply this revision.'))); 33819 } 33820 /* harmony default export */ const screen_revisions = (ScreenRevisions); 33821 33822 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/global-styles/ui.js 33823 33824 /** 33825 * WordPress dependencies 33826 */ 33827 33828 33829 33830 33831 33832 33833 33834 33835 33836 33837 /** 33838 * Internal dependencies 33839 */ 33840 33841 33842 33843 33844 33845 33846 33847 33848 33849 33850 33851 33852 33853 33854 const ui_SLOT_FILL_NAME = 'GlobalStylesMenu'; 33855 const { 33856 useGlobalStylesReset: ui_useGlobalStylesReset 33857 } = unlock(external_wp_blockEditor_namespaceObject.privateApis); 33858 const { 33859 Slot: GlobalStylesMenuSlot, 33860 Fill: GlobalStylesMenuFill 33861 } = (0,external_wp_components_namespaceObject.createSlotFill)(ui_SLOT_FILL_NAME); 33862 function GlobalStylesActionMenu() { 33863 const [canReset, onReset] = ui_useGlobalStylesReset(); 33864 const { 33865 toggle 33866 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_preferences_namespaceObject.store); 33867 const { 33868 canEditCSS 33869 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 33870 const { 33871 getEntityRecord, 33872 __experimentalGetCurrentGlobalStylesId 33873 } = select(external_wp_coreData_namespaceObject.store); 33874 const globalStylesId = __experimentalGetCurrentGlobalStylesId(); 33875 const globalStyles = globalStylesId ? getEntityRecord('root', 'globalStyles', globalStylesId) : undefined; 33876 return { 33877 canEditCSS: !!globalStyles?._links?.['wp:action-edit-css'] 33878 }; 33879 }, []); 33880 const { 33881 setEditorCanvasContainerView 33882 } = unlock((0,external_wp_data_namespaceObject.useDispatch)(store_store)); 33883 const { 33884 goTo 33885 } = (0,external_wp_components_namespaceObject.__experimentalUseNavigator)(); 33886 const loadCustomCSS = () => { 33887 setEditorCanvasContainerView('global-styles-css'); 33888 goTo('/css'); 33889 }; 33890 return (0,external_React_.createElement)(GlobalStylesMenuFill, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.DropdownMenu, { 33891 icon: more_vertical, 33892 label: (0,external_wp_i18n_namespaceObject.__)('More') 33893 }, ({ 33894 onClose 33895 }) => (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.MenuGroup, null, canEditCSS && (0,external_React_.createElement)(external_wp_components_namespaceObject.MenuItem, { 33896 onClick: loadCustomCSS 33897 }, (0,external_wp_i18n_namespaceObject.__)('Additional CSS')), (0,external_React_.createElement)(external_wp_components_namespaceObject.MenuItem, { 33898 onClick: () => { 33899 toggle('core/edit-site', 'welcomeGuideStyles'); 33900 onClose(); 33901 } 33902 }, (0,external_wp_i18n_namespaceObject.__)('Welcome Guide'))), (0,external_React_.createElement)(external_wp_components_namespaceObject.MenuGroup, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.MenuItem, { 33903 onClick: () => { 33904 onReset(); 33905 onClose(); 33906 }, 33907 disabled: !canReset 33908 }, (0,external_wp_i18n_namespaceObject.__)('Reset styles')))))); 33909 } 33910 function GlobalStylesNavigationScreen({ 33911 className, 33912 ...props 33913 }) { 33914 return (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalNavigatorScreen, { 33915 className: ['edit-site-global-styles-sidebar__navigator-screen', className].filter(Boolean).join(' '), 33916 ...props 33917 }); 33918 } 33919 function BlockStylesNavigationScreens({ 33920 parentMenu, 33921 blockStyles, 33922 blockName 33923 }) { 33924 return blockStyles.map((style, index) => (0,external_React_.createElement)(GlobalStylesNavigationScreen, { 33925 key: index, 33926 path: parentMenu + '/variations/' + style.name 33927 }, (0,external_React_.createElement)(screen_block, { 33928 name: blockName, 33929 variation: style.name 33930 }))); 33931 } 33932 function ContextScreens({ 33933 name, 33934 parentMenu = '' 33935 }) { 33936 const blockStyleVariations = (0,external_wp_data_namespaceObject.useSelect)(select => { 33937 const { 33938 getBlockStyles 33939 } = select(external_wp_blocks_namespaceObject.store); 33940 return getBlockStyles(name); 33941 }, [name]); 33942 return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(GlobalStylesNavigationScreen, { 33943 path: parentMenu + '/colors/palette' 33944 }, (0,external_React_.createElement)(screen_color_palette, { 33945 name: name 33946 })), !!blockStyleVariations?.length && (0,external_React_.createElement)(BlockStylesNavigationScreens, { 33947 parentMenu: parentMenu, 33948 blockStyles: blockStyleVariations, 33949 blockName: name 33950 })); 33951 } 33952 function GlobalStylesStyleBook() { 33953 const navigator = (0,external_wp_components_namespaceObject.__experimentalUseNavigator)(); 33954 const { 33955 path 33956 } = navigator.location; 33957 return (0,external_React_.createElement)(style_book, { 33958 isSelected: blockName => 33959 // Match '/blocks/core%2Fbutton' and 33960 // '/blocks/core%2Fbutton/typography', but not 33961 // '/blocks/core%2Fbuttons'. 33962 path === `/blocks/$encodeURIComponent(blockName)}` || path.startsWith(`/blocks/$encodeURIComponent(blockName)}/`), 33963 onSelect: blockName => { 33964 // Now go to the selected block. 33965 navigator.goTo('/blocks/' + encodeURIComponent(blockName)); 33966 } 33967 }); 33968 } 33969 function GlobalStylesBlockLink() { 33970 const navigator = (0,external_wp_components_namespaceObject.__experimentalUseNavigator)(); 33971 const { 33972 selectedBlockName, 33973 selectedBlockClientId 33974 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 33975 const { 33976 getSelectedBlockClientId, 33977 getBlockName 33978 } = select(external_wp_blockEditor_namespaceObject.store); 33979 const clientId = getSelectedBlockClientId(); 33980 return { 33981 selectedBlockName: getBlockName(clientId), 33982 selectedBlockClientId: clientId 33983 }; 33984 }, []); 33985 const blockHasGlobalStyles = useBlockHasGlobalStyles(selectedBlockName); 33986 // When we're in the `Blocks` screen enable deep linking to the selected block. 33987 (0,external_wp_element_namespaceObject.useEffect)(() => { 33988 if (!selectedBlockClientId || !blockHasGlobalStyles) { 33989 return; 33990 } 33991 const currentPath = navigator.location.path; 33992 if (currentPath !== '/blocks' && !currentPath.startsWith('/blocks/')) { 33993 return; 33994 } 33995 const newPath = '/blocks/' + encodeURIComponent(selectedBlockName); 33996 // Avoid navigating to the same path. This can happen when selecting 33997 // a new block of the same type. 33998 if (newPath !== currentPath) { 33999 navigator.goTo(newPath, { 34000 skipFocus: true 34001 }); 34002 } 34003 }, [selectedBlockClientId, selectedBlockName, blockHasGlobalStyles]); 34004 } 34005 function GlobalStylesEditorCanvasContainerLink() { 34006 const { 34007 goTo, 34008 location 34009 } = (0,external_wp_components_namespaceObject.__experimentalUseNavigator)(); 34010 const editorCanvasContainerView = (0,external_wp_data_namespaceObject.useSelect)(select => unlock(select(store_store)).getEditorCanvasContainerView(), []); 34011 const path = location?.path; 34012 const isRevisionsOpen = path === '/revisions'; 34013 34014 // If the user switches the editor canvas container view, redirect 34015 // to the appropriate screen. This effectively allows deep linking to the 34016 // desired screens from outside the global styles navigation provider. 34017 (0,external_wp_element_namespaceObject.useEffect)(() => { 34018 switch (editorCanvasContainerView) { 34019 case 'global-styles-revisions': 34020 case 'global-styles-revisions:style-book': 34021 goTo('/revisions'); 34022 break; 34023 case 'global-styles-css': 34024 goTo('/css'); 34025 break; 34026 case 'style-book': 34027 /* 34028 * The stand-alone style book is open 34029 * and the revisions panel is open, 34030 * close the revisions panel. 34031 * Otherwise keep the style book open while 34032 * browsing global styles panel. 34033 */ 34034 if (isRevisionsOpen) { 34035 goTo('/'); 34036 } 34037 break; 34038 default: 34039 /* 34040 * Example: the user has navigated to "Browse styles" or elsewhere 34041 * and changes the editorCanvasContainerView, e.g., closes the style book. 34042 * The panel should not be affected. 34043 * Exclude revisions panel from this behavior, 34044 * as it should close when the editorCanvasContainerView doesn't correspond. 34045 */ 34046 if (path !== '/' && !isRevisionsOpen) { 34047 return; 34048 } 34049 goTo('/'); 34050 break; 34051 } 34052 }, [editorCanvasContainerView, isRevisionsOpen, goTo]); 34053 } 34054 function GlobalStylesUI() { 34055 const blocks = (0,external_wp_blocks_namespaceObject.getBlockTypes)(); 34056 const editorCanvasContainerView = (0,external_wp_data_namespaceObject.useSelect)(select => unlock(select(store_store)).getEditorCanvasContainerView(), []); 34057 return (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalNavigatorProvider, { 34058 className: "edit-site-global-styles-sidebar__navigator-provider", 34059 initialPath: "/" 34060 }, (0,external_React_.createElement)(GlobalStylesNavigationScreen, { 34061 path: "/" 34062 }, (0,external_React_.createElement)(screen_root, null)), (0,external_React_.createElement)(GlobalStylesNavigationScreen, { 34063 path: "/variations" 34064 }, (0,external_React_.createElement)(screen_style_variations, null)), (0,external_React_.createElement)(GlobalStylesNavigationScreen, { 34065 path: "/blocks" 34066 }, (0,external_React_.createElement)(screen_block_list, null)), (0,external_React_.createElement)(GlobalStylesNavigationScreen, { 34067 path: "/typography" 34068 }, (0,external_React_.createElement)(screen_typography, null)), (0,external_React_.createElement)(GlobalStylesNavigationScreen, { 34069 path: "/typography/text" 34070 }, (0,external_React_.createElement)(screen_typography_element, { 34071 element: "text" 34072 })), (0,external_React_.createElement)(GlobalStylesNavigationScreen, { 34073 path: "/typography/link" 34074 }, (0,external_React_.createElement)(screen_typography_element, { 34075 element: "link" 34076 })), (0,external_React_.createElement)(GlobalStylesNavigationScreen, { 34077 path: "/typography/heading" 34078 }, (0,external_React_.createElement)(screen_typography_element, { 34079 element: "heading" 34080 })), (0,external_React_.createElement)(GlobalStylesNavigationScreen, { 34081 path: "/typography/caption" 34082 }, (0,external_React_.createElement)(screen_typography_element, { 34083 element: "caption" 34084 })), (0,external_React_.createElement)(GlobalStylesNavigationScreen, { 34085 path: "/typography/button" 34086 }, (0,external_React_.createElement)(screen_typography_element, { 34087 element: "button" 34088 })), (0,external_React_.createElement)(GlobalStylesNavigationScreen, { 34089 path: "/colors" 34090 }, (0,external_React_.createElement)(screen_colors, null)), (0,external_React_.createElement)(GlobalStylesNavigationScreen, { 34091 path: "/layout" 34092 }, (0,external_React_.createElement)(screen_layout, null)), (0,external_React_.createElement)(GlobalStylesNavigationScreen, { 34093 path: "/css" 34094 }, (0,external_React_.createElement)(screen_css, null)), (0,external_React_.createElement)(GlobalStylesNavigationScreen, { 34095 path: '/revisions' 34096 }, (0,external_React_.createElement)(screen_revisions, null)), blocks.map(block => (0,external_React_.createElement)(GlobalStylesNavigationScreen, { 34097 key: 'menu-block-' + block.name, 34098 path: '/blocks/' + encodeURIComponent(block.name) 34099 }, (0,external_React_.createElement)(screen_block, { 34100 name: block.name 34101 }))), (0,external_React_.createElement)(ContextScreens, null), blocks.map(block => (0,external_React_.createElement)(ContextScreens, { 34102 key: 'screens-block-' + block.name, 34103 name: block.name, 34104 parentMenu: '/blocks/' + encodeURIComponent(block.name) 34105 })), 'style-book' === editorCanvasContainerView && (0,external_React_.createElement)(GlobalStylesStyleBook, null), (0,external_React_.createElement)(GlobalStylesActionMenu, null), (0,external_React_.createElement)(GlobalStylesBlockLink, null), (0,external_React_.createElement)(GlobalStylesEditorCanvasContainerLink, null)); 34106 } 34107 34108 /* harmony default export */ const ui = (GlobalStylesUI); 34109 34110 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/global-styles/index.js 34111 34112 34113 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sidebar-edit-mode/global-styles-sidebar.js 34114 34115 /** 34116 * WordPress dependencies 34117 */ 34118 34119 34120 34121 34122 34123 34124 34125 34126 34127 /** 34128 * Internal dependencies 34129 */ 34130 34131 34132 34133 34134 34135 34136 function GlobalStylesSidebar() { 34137 const { 34138 shouldClearCanvasContainerView, 34139 isStyleBookOpened, 34140 showListViewByDefault, 34141 hasRevisions, 34142 isRevisionsOpened, 34143 isRevisionsStyleBookOpened 34144 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 34145 const { 34146 getActiveComplementaryArea 34147 } = select(store); 34148 const { 34149 getEditorCanvasContainerView, 34150 getCanvasMode 34151 } = unlock(select(store_store)); 34152 const canvasContainerView = getEditorCanvasContainerView(); 34153 const _isVisualEditorMode = 'visual' === select(store_store).getEditorMode(); 34154 const _isEditCanvasMode = 'edit' === getCanvasMode(); 34155 const _showListViewByDefault = select(external_wp_preferences_namespaceObject.store).get('core', 'showListViewByDefault'); 34156 const { 34157 getEntityRecord, 34158 __experimentalGetCurrentGlobalStylesId 34159 } = select(external_wp_coreData_namespaceObject.store); 34160 const globalStylesId = __experimentalGetCurrentGlobalStylesId(); 34161 const globalStyles = globalStylesId ? getEntityRecord('root', 'globalStyles', globalStylesId) : undefined; 34162 return { 34163 isStyleBookOpened: 'style-book' === canvasContainerView, 34164 shouldClearCanvasContainerView: 'edit-site/global-styles' !== getActiveComplementaryArea('core/edit-site') || !_isVisualEditorMode || !_isEditCanvasMode, 34165 showListViewByDefault: _showListViewByDefault, 34166 hasRevisions: !!globalStyles?._links?.['version-history']?.[0]?.count, 34167 isRevisionsStyleBookOpened: 'global-styles-revisions:style-book' === canvasContainerView, 34168 isRevisionsOpened: 'global-styles-revisions' === canvasContainerView 34169 }; 34170 }, []); 34171 const { 34172 setEditorCanvasContainerView 34173 } = unlock((0,external_wp_data_namespaceObject.useDispatch)(store_store)); 34174 (0,external_wp_element_namespaceObject.useEffect)(() => { 34175 if (shouldClearCanvasContainerView) { 34176 setEditorCanvasContainerView(undefined); 34177 } 34178 }, [shouldClearCanvasContainerView]); 34179 const { 34180 setIsListViewOpened 34181 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_editor_namespaceObject.store); 34182 const { 34183 goTo 34184 } = (0,external_wp_components_namespaceObject.__experimentalUseNavigator)(); 34185 const toggleRevisions = () => { 34186 setIsListViewOpened(false); 34187 if (isRevisionsStyleBookOpened) { 34188 goTo('/'); 34189 setEditorCanvasContainerView('style-book'); 34190 return; 34191 } 34192 if (isRevisionsOpened) { 34193 goTo('/'); 34194 setEditorCanvasContainerView(undefined); 34195 return; 34196 } 34197 goTo('/revisions'); 34198 if (isStyleBookOpened) { 34199 setEditorCanvasContainerView('global-styles-revisions:style-book'); 34200 } else { 34201 setEditorCanvasContainerView('global-styles-revisions'); 34202 } 34203 }; 34204 const toggleStyleBook = () => { 34205 if (isRevisionsOpened) { 34206 setEditorCanvasContainerView('global-styles-revisions:style-book'); 34207 return; 34208 } 34209 if (isRevisionsStyleBookOpened) { 34210 setEditorCanvasContainerView('global-styles-revisions'); 34211 return; 34212 } 34213 setIsListViewOpened(isStyleBookOpened && showListViewByDefault); 34214 setEditorCanvasContainerView(isStyleBookOpened ? undefined : 'style-book'); 34215 }; 34216 return (0,external_React_.createElement)(DefaultSidebar, { 34217 className: "edit-site-global-styles-sidebar", 34218 identifier: "edit-site/global-styles", 34219 title: (0,external_wp_i18n_namespaceObject.__)('Styles'), 34220 icon: library_styles, 34221 closeLabel: (0,external_wp_i18n_namespaceObject.__)('Close Styles'), 34222 panelClassName: "edit-site-global-styles-sidebar__panel", 34223 header: (0,external_React_.createElement)(external_wp_components_namespaceObject.Flex, { 34224 className: "edit-site-global-styles-sidebar__header", 34225 role: "menubar", 34226 "aria-label": (0,external_wp_i18n_namespaceObject.__)('Styles actions') 34227 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.FlexBlock, { 34228 style: { 34229 minWidth: 'min-content' 34230 } 34231 }, (0,external_React_.createElement)("strong", null, (0,external_wp_i18n_namespaceObject.__)('Styles'))), (0,external_React_.createElement)(external_wp_components_namespaceObject.FlexItem, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 34232 icon: library_seen, 34233 label: (0,external_wp_i18n_namespaceObject.__)('Style Book'), 34234 isPressed: isStyleBookOpened || isRevisionsStyleBookOpened, 34235 disabled: shouldClearCanvasContainerView, 34236 onClick: toggleStyleBook 34237 })), (0,external_React_.createElement)(external_wp_components_namespaceObject.FlexItem, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 34238 label: (0,external_wp_i18n_namespaceObject.__)('Revisions'), 34239 icon: library_backup, 34240 onClick: toggleRevisions, 34241 disabled: !hasRevisions, 34242 isPressed: isRevisionsOpened || isRevisionsStyleBookOpened 34243 })), (0,external_React_.createElement)(GlobalStylesMenuSlot, null)) 34244 }, (0,external_React_.createElement)(ui, null)); 34245 } 34246 34247 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sidebar-edit-mode/constants.js 34248 const SIDEBAR_TEMPLATE = 'edit-site/template'; 34249 const SIDEBAR_BLOCK = 'edit-site/block-inspector'; 34250 34251 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sidebar-edit-mode/settings-header/index.js 34252 34253 /** 34254 * WordPress dependencies 34255 */ 34256 34257 34258 34259 34260 34261 34262 /** 34263 * Internal dependencies 34264 */ 34265 34266 34267 const { 34268 Tabs: settings_header_Tabs 34269 } = unlock(external_wp_components_namespaceObject.privateApis); 34270 const SettingsHeader = (_, ref) => { 34271 const postTypeLabel = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_editor_namespaceObject.store).getPostTypeLabel(), []); 34272 return (0,external_React_.createElement)(settings_header_Tabs.TabList, { 34273 ref: ref 34274 }, (0,external_React_.createElement)(settings_header_Tabs.Tab, { 34275 tabId: SIDEBAR_TEMPLATE 34276 // Used for focus management in the SettingsSidebar component. 34277 , 34278 "data-tab-id": SIDEBAR_TEMPLATE 34279 }, postTypeLabel), (0,external_React_.createElement)(settings_header_Tabs.Tab, { 34280 tabId: SIDEBAR_BLOCK 34281 // Used for focus management in the SettingsSidebar component. 34282 , 34283 "data-tab-id": SIDEBAR_BLOCK 34284 }, (0,external_wp_i18n_namespaceObject.__)('Block'))); 34285 }; 34286 /* harmony default export */ const settings_header = ((0,external_wp_element_namespaceObject.forwardRef)(SettingsHeader)); 34287 34288 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sidebar-edit-mode/sidebar-card/index.js 34289 34290 /** 34291 * External dependencies 34292 */ 34293 34294 34295 /** 34296 * WordPress dependencies 34297 */ 34298 34299 function SidebarCard({ 34300 className, 34301 title, 34302 icon, 34303 description, 34304 actions, 34305 children 34306 }) { 34307 return (0,external_React_.createElement)("div", { 34308 className: classnames_default()('edit-site-sidebar-card', className) 34309 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.Icon, { 34310 className: "edit-site-sidebar-card__icon", 34311 icon: icon 34312 }), (0,external_React_.createElement)("div", { 34313 className: "edit-site-sidebar-card__content" 34314 }, (0,external_React_.createElement)("div", { 34315 className: "edit-site-sidebar-card__header" 34316 }, (0,external_React_.createElement)("h2", { 34317 className: "edit-site-sidebar-card__title" 34318 }, title), actions), (0,external_React_.createElement)("div", { 34319 className: "edit-site-sidebar-card__description" 34320 }, description), children)); 34321 } 34322 34323 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sidebar-edit-mode/page-panels/page-content.js 34324 34325 /** 34326 * WordPress dependencies 34327 */ 34328 34329 34330 34331 34332 /** 34333 * Internal dependencies 34334 */ 34335 34336 const { 34337 BlockQuickNavigation 34338 } = unlock(external_wp_blockEditor_namespaceObject.privateApis); 34339 function PageContent() { 34340 const clientIdsTree = (0,external_wp_data_namespaceObject.useSelect)(select => unlock(select(external_wp_blockEditor_namespaceObject.store)).getEnabledClientIdsTree(), []); 34341 const clientIds = (0,external_wp_element_namespaceObject.useMemo)(() => clientIdsTree.map(({ 34342 clientId 34343 }) => clientId), [clientIdsTree]); 34344 return (0,external_React_.createElement)(BlockQuickNavigation, { 34345 clientIds: clientIds 34346 }); 34347 } 34348 34349 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sidebar-edit-mode/page-panels/page-status.js 34350 34351 /** 34352 * WordPress dependencies 34353 */ 34354 34355 34356 34357 34358 34359 34360 34361 34362 34363 34364 /** 34365 * Internal dependencies 34366 */ 34367 34368 34369 const { 34370 PostPanelRow 34371 } = unlock(external_wp_editor_namespaceObject.privateApis); 34372 const STATUS_OPTIONS = [{ 34373 label: (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_wp_i18n_namespaceObject.__)('Draft'), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalText, { 34374 variant: "muted" 34375 }, (0,external_wp_i18n_namespaceObject.__)('Not ready to publish.'))), 34376 value: 'draft' 34377 }, { 34378 label: (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_wp_i18n_namespaceObject.__)('Pending'), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalText, { 34379 variant: "muted" 34380 }, (0,external_wp_i18n_namespaceObject.__)('Waiting for review before publishing.'))), 34381 value: 'pending' 34382 }, { 34383 label: (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_wp_i18n_namespaceObject.__)('Private'), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalText, { 34384 variant: "muted" 34385 }, (0,external_wp_i18n_namespaceObject.__)('Only visible to site admins and editors.'))), 34386 value: 'private' 34387 }, { 34388 label: (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_wp_i18n_namespaceObject.__)('Scheduled'), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalText, { 34389 variant: "muted" 34390 }, (0,external_wp_i18n_namespaceObject.__)('Publish automatically on a chosen date.'))), 34391 value: 'future' 34392 }, { 34393 label: (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_wp_i18n_namespaceObject.__)('Published'), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalText, { 34394 variant: "muted" 34395 }, (0,external_wp_i18n_namespaceObject.__)('Visible to everyone.'))), 34396 value: 'publish' 34397 }]; 34398 function PageStatus({ 34399 postType, 34400 postId, 34401 status, 34402 password, 34403 date 34404 }) { 34405 const [showPassword, setShowPassword] = (0,external_wp_element_namespaceObject.useState)(!!password); 34406 const instanceId = (0,external_wp_compose_namespaceObject.useInstanceId)(PageStatus); 34407 const { 34408 editEntityRecord 34409 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store); 34410 const { 34411 createErrorNotice 34412 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store); 34413 const [popoverAnchor, setPopoverAnchor] = (0,external_wp_element_namespaceObject.useState)(null); 34414 // Memoize popoverProps to avoid returning a new object every time. 34415 const popoverProps = (0,external_wp_element_namespaceObject.useMemo)(() => ({ 34416 // Anchor the popover to the middle of the entire row so that it doesn't 34417 // move around when the label changes. 34418 anchor: popoverAnchor, 34419 'aria-label': (0,external_wp_i18n_namespaceObject.__)('Change status'), 34420 placement: 'bottom-end' 34421 }), [popoverAnchor]); 34422 const saveStatus = async ({ 34423 status: newStatus = status, 34424 password: newPassword = password, 34425 date: newDate = date 34426 }) => { 34427 try { 34428 await editEntityRecord('postType', postType, postId, { 34429 status: newStatus, 34430 date: newDate, 34431 password: newPassword 34432 }); 34433 } catch (error) { 34434 const errorMessage = error.message && error.code !== 'unknown_error' ? error.message : (0,external_wp_i18n_namespaceObject.__)('An error occurred while updating the status'); 34435 createErrorNotice(errorMessage, { 34436 type: 'snackbar' 34437 }); 34438 } 34439 }; 34440 const handleTogglePassword = value => { 34441 setShowPassword(value); 34442 if (!value) { 34443 saveStatus({ 34444 password: '' 34445 }); 34446 } 34447 }; 34448 const handleStatus = value => { 34449 let newDate = date; 34450 let newPassword = password; 34451 if (value === 'publish') { 34452 if (new Date(date) > new Date()) { 34453 newDate = null; 34454 } 34455 } else if (value === 'future') { 34456 if (!date || new Date(date) < new Date()) { 34457 newDate = new Date(); 34458 newDate.setDate(newDate.getDate() + 7); 34459 } 34460 } else if (value === 'private' && password) { 34461 setShowPassword(false); 34462 newPassword = ''; 34463 } 34464 saveStatus({ 34465 status: value, 34466 date: newDate, 34467 password: newPassword 34468 }); 34469 }; 34470 return (0,external_React_.createElement)(PostPanelRow, { 34471 label: (0,external_wp_i18n_namespaceObject.__)('Status') 34472 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.Dropdown, { 34473 contentClassName: "edit-site-change-status__content", 34474 popoverProps: popoverProps, 34475 focusOnMount: true, 34476 ref: setPopoverAnchor, 34477 renderToggle: ({ 34478 onToggle 34479 }) => (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 34480 className: "edit-site-summary-field__trigger", 34481 variant: "tertiary", 34482 onClick: onToggle 34483 }, (0,external_React_.createElement)(StatusLabel, { 34484 status: password ? 'protected' : status 34485 })), 34486 renderContent: ({ 34487 onClose 34488 }) => (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(external_wp_blockEditor_namespaceObject.__experimentalInspectorPopoverHeader, { 34489 title: (0,external_wp_i18n_namespaceObject.__)('Status'), 34490 onClose: onClose 34491 }), (0,external_React_.createElement)("form", null, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { 34492 spacing: 5 34493 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.RadioControl, { 34494 className: "edit-site-change-status__options", 34495 hideLabelFromVision: true, 34496 label: (0,external_wp_i18n_namespaceObject.__)('Status'), 34497 options: STATUS_OPTIONS, 34498 onChange: handleStatus, 34499 selected: status 34500 }), status !== 'private' && (0,external_React_.createElement)("fieldset", { 34501 className: "edit-site-change-status__password-fieldset" 34502 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalText, { 34503 as: "legend", 34504 className: "edit-site-change-status__password-legend", 34505 size: "11", 34506 lineHeight: 1.4, 34507 weight: 500, 34508 upperCase: true 34509 }, (0,external_wp_i18n_namespaceObject.__)('Password')), (0,external_React_.createElement)(external_wp_components_namespaceObject.ToggleControl, { 34510 label: (0,external_wp_i18n_namespaceObject.__)('Hide this page behind a password'), 34511 checked: showPassword, 34512 onChange: handleTogglePassword 34513 }), showPassword && (0,external_React_.createElement)("div", { 34514 className: "edit-site-change-status__password-input" 34515 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.VisuallyHidden, { 34516 as: "label", 34517 htmlFor: `edit-site-change-status__password-input-$instanceId}` 34518 }, (0,external_wp_i18n_namespaceObject.__)('Create password')), (0,external_React_.createElement)(external_wp_components_namespaceObject.TextControl, { 34519 onChange: value => saveStatus({ 34520 password: value 34521 }), 34522 value: password, 34523 placeholder: (0,external_wp_i18n_namespaceObject.__)('Use a secure password'), 34524 type: "text", 34525 id: `edit-site-change-status__password-input-$instanceId}` 34526 })))))) 34527 })); 34528 } 34529 34530 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sidebar-edit-mode/page-panels/page-summary.js 34531 34532 /** 34533 * WordPress dependencies 34534 */ 34535 34536 34537 34538 /** 34539 * Internal dependencies 34540 */ 34541 34542 function PageSummary({ 34543 status, 34544 date, 34545 password, 34546 postId, 34547 postType 34548 }) { 34549 return (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { 34550 spacing: 0 34551 }, (0,external_React_.createElement)(PageStatus, { 34552 status: status, 34553 date: date, 34554 password: password, 34555 postId: postId, 34556 postType: postType 34557 }), (0,external_React_.createElement)(external_wp_editor_namespaceObject.PostSchedulePanel, null), (0,external_React_.createElement)(external_wp_editor_namespaceObject.PostTemplatePanel, null), (0,external_React_.createElement)(external_wp_editor_namespaceObject.PostURLPanel, null), (0,external_React_.createElement)(external_wp_editor_namespaceObject.PostAuthorPanel, null)); 34558 } 34559 34560 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sidebar-edit-mode/page-panels/index.js 34561 34562 /** 34563 * WordPress dependencies 34564 */ 34565 34566 34567 34568 34569 34570 34571 34572 34573 34574 /** 34575 * Internal dependencies 34576 */ 34577 34578 34579 34580 34581 function PagePanels() { 34582 const { 34583 id, 34584 type, 34585 hasResolved, 34586 status, 34587 date, 34588 password, 34589 title, 34590 modified, 34591 renderingMode 34592 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 34593 const { 34594 getEditedPostContext 34595 } = select(store_store); 34596 const { 34597 getEditedEntityRecord, 34598 hasFinishedResolution 34599 } = select(external_wp_coreData_namespaceObject.store); 34600 const { 34601 getRenderingMode 34602 } = select(external_wp_editor_namespaceObject.store); 34603 const context = getEditedPostContext(); 34604 const queryArgs = ['postType', context.postType, context.postId]; 34605 const page = getEditedEntityRecord(...queryArgs); 34606 return { 34607 hasResolved: hasFinishedResolution('getEditedEntityRecord', queryArgs), 34608 title: page?.title, 34609 id: page?.id, 34610 type: page?.type, 34611 status: page?.status, 34612 date: page?.date, 34613 password: page?.password, 34614 modified: page?.modified, 34615 renderingMode: getRenderingMode() 34616 }; 34617 }, []); 34618 if (!hasResolved) { 34619 return null; 34620 } 34621 return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.PanelBody, null, (0,external_React_.createElement)(SidebarCard, { 34622 title: (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(title), 34623 icon: library_page, 34624 description: (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalVStack, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalText, null, (0,external_wp_i18n_namespaceObject.sprintf)( 34625 // translators: %s: Human-readable time difference, e.g. "2 days ago". 34626 (0,external_wp_i18n_namespaceObject.__)('Last edited %s'), (0,external_wp_date_namespaceObject.humanTimeDiff)(modified)))) 34627 })), (0,external_React_.createElement)(external_wp_components_namespaceObject.PanelBody, { 34628 title: (0,external_wp_i18n_namespaceObject.__)('Summary') 34629 }, (0,external_React_.createElement)(PageSummary, { 34630 status: status, 34631 date: date, 34632 password: password, 34633 postId: id, 34634 postType: type 34635 })), renderingMode !== 'post-only' && (0,external_React_.createElement)(external_wp_components_namespaceObject.PanelBody, { 34636 title: (0,external_wp_i18n_namespaceObject.__)('Content') 34637 }, (0,external_React_.createElement)(PageContent, null)), (0,external_React_.createElement)(external_wp_editor_namespaceObject.PostLastRevisionPanel, null), (0,external_React_.createElement)(external_wp_editor_namespaceObject.PostTaxonomiesPanel, null), (0,external_React_.createElement)(external_wp_editor_namespaceObject.PostFeaturedImagePanel, null), (0,external_React_.createElement)(external_wp_editor_namespaceObject.PostExcerptPanel, null), (0,external_React_.createElement)(external_wp_editor_namespaceObject.PostDiscussionPanel, null), (0,external_React_.createElement)(external_wp_editor_namespaceObject.PageAttributesPanel, null)); 34638 } 34639 34640 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sidebar-edit-mode/template-panel/replace-template-button.js 34641 34642 /** 34643 * WordPress dependencies 34644 */ 34645 34646 34647 34648 34649 34650 34651 34652 34653 34654 /** 34655 * Internal dependencies 34656 */ 34657 34658 function ReplaceTemplateButton({ 34659 onClick, 34660 availableTemplates 34661 }) { 34662 const { 34663 editEntityRecord 34664 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store); 34665 const [showModal, setShowModal] = (0,external_wp_element_namespaceObject.useState)(false); 34666 const onClose = () => { 34667 setShowModal(false); 34668 }; 34669 const { 34670 postId, 34671 postType 34672 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 34673 return { 34674 postId: select(store_store).getEditedPostId(), 34675 postType: select(store_store).getEditedPostType() 34676 }; 34677 }, []); 34678 const onTemplateSelect = async selectedTemplate => { 34679 onClose(); // Close the template suggestions modal first. 34680 onClick(); 34681 await editEntityRecord('postType', postType, postId, { 34682 blocks: selectedTemplate.blocks, 34683 content: (0,external_wp_blocks_namespaceObject.serialize)(selectedTemplate.blocks) 34684 }); 34685 }; 34686 if (!availableTemplates.length || availableTemplates.length < 1) { 34687 return null; 34688 } 34689 return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.MenuItem, { 34690 info: (0,external_wp_i18n_namespaceObject.__)('Replace the contents of this template with another.'), 34691 onClick: () => setShowModal(true) 34692 }, (0,external_wp_i18n_namespaceObject.__)('Replace template')), showModal && (0,external_React_.createElement)(external_wp_components_namespaceObject.Modal, { 34693 title: (0,external_wp_i18n_namespaceObject.__)('Choose a template'), 34694 onRequestClose: onClose, 34695 overlayClassName: "edit-site-template-panel__replace-template-modal", 34696 isFullScreen: true 34697 }, (0,external_React_.createElement)("div", { 34698 className: "edit-site-template-panel__replace-template-modal__content" 34699 }, (0,external_React_.createElement)(TemplatesList, { 34700 availableTemplates: availableTemplates, 34701 onSelect: onTemplateSelect 34702 })))); 34703 } 34704 function TemplatesList({ 34705 availableTemplates, 34706 onSelect 34707 }) { 34708 const shownTemplates = (0,external_wp_compose_namespaceObject.useAsyncList)(availableTemplates); 34709 return (0,external_React_.createElement)(external_wp_blockEditor_namespaceObject.__experimentalBlockPatternsList, { 34710 label: (0,external_wp_i18n_namespaceObject.__)('Templates'), 34711 blockPatterns: availableTemplates, 34712 shownPatterns: shownTemplates, 34713 onClickPattern: onSelect 34714 }); 34715 } 34716 34717 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sidebar-edit-mode/template-panel/hooks.js 34718 /** 34719 * WordPress dependencies 34720 */ 34721 34722 34723 34724 34725 34726 /** 34727 * Internal dependencies 34728 */ 34729 34730 34731 34732 function injectThemeAttributeInBlockTemplateContent(block, currentThemeStylesheet) { 34733 block.innerBlocks = block.innerBlocks.map(innerBlock => { 34734 return injectThemeAttributeInBlockTemplateContent(innerBlock, currentThemeStylesheet); 34735 }); 34736 if (block.name === 'core/template-part' && block.attributes.theme === undefined) { 34737 block.attributes.theme = currentThemeStylesheet; 34738 } 34739 return block; 34740 } 34741 function preparePatterns(patterns, template, currentThemeStylesheet) { 34742 // Filter out duplicates. 34743 const filterOutDuplicatesByName = (currentItem, index, items) => index === items.findIndex(item => currentItem.name === item.name); 34744 34745 // Filter out core/directory patterns not included in theme.json. 34746 const filterOutExcludedPatternSources = pattern => !EXCLUDED_PATTERN_SOURCES.includes(pattern.source); 34747 34748 // Filter only the patterns that are compatible with the current template. 34749 const filterCompatiblePatterns = pattern => pattern.templateTypes?.includes(template.slug); 34750 return patterns.filter((pattern, index, items) => filterOutExcludedPatternSources(pattern) && filterOutDuplicatesByName(pattern, index, items) && filterCompatiblePatterns(pattern)).map(pattern => ({ 34751 ...pattern, 34752 keywords: pattern.keywords || [], 34753 type: PATTERN_TYPES.theme, 34754 blocks: (0,external_wp_blocks_namespaceObject.parse)(pattern.content, { 34755 __unstableSkipMigrationLogs: true 34756 }).map(block => injectThemeAttributeInBlockTemplateContent(block, currentThemeStylesheet)) 34757 })); 34758 } 34759 function useAvailablePatterns(template) { 34760 const { 34761 blockPatterns, 34762 restBlockPatterns, 34763 currentThemeStylesheet 34764 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 34765 var _settings$__experimen; 34766 const { 34767 getSettings 34768 } = unlock(select(store_store)); 34769 const settings = getSettings(); 34770 return { 34771 blockPatterns: (_settings$__experimen = settings.__experimentalAdditionalBlockPatterns) !== null && _settings$__experimen !== void 0 ? _settings$__experimen : settings.__experimentalBlockPatterns, 34772 restBlockPatterns: select(external_wp_coreData_namespaceObject.store).getBlockPatterns(), 34773 currentThemeStylesheet: select(external_wp_coreData_namespaceObject.store).getCurrentTheme().stylesheet 34774 }; 34775 }, []); 34776 return (0,external_wp_element_namespaceObject.useMemo)(() => { 34777 const mergedPatterns = [...(blockPatterns || []), ...(restBlockPatterns || [])]; 34778 return preparePatterns(mergedPatterns, template, currentThemeStylesheet); 34779 }, [blockPatterns, restBlockPatterns, template, currentThemeStylesheet]); 34780 } 34781 34782 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sidebar-edit-mode/template-panel/template-actions.js 34783 34784 /** 34785 * WordPress dependencies 34786 */ 34787 34788 34789 34790 34791 34792 /** 34793 * Internal dependencies 34794 */ 34795 34796 34797 34798 34799 function Actions({ 34800 template 34801 }) { 34802 const availablePatterns = useAvailablePatterns(template); 34803 const { 34804 revertTemplate 34805 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store); 34806 const isRevertable = isTemplateRevertable(template); 34807 if (!isRevertable && (!availablePatterns.length || availablePatterns.length < 1)) { 34808 return null; 34809 } 34810 return (0,external_React_.createElement)(external_wp_components_namespaceObject.DropdownMenu, { 34811 icon: more_vertical, 34812 label: (0,external_wp_i18n_namespaceObject.__)('Actions'), 34813 className: "edit-site-template-card__actions", 34814 toggleProps: { 34815 isSmall: true 34816 } 34817 }, ({ 34818 onClose 34819 }) => (0,external_React_.createElement)(external_wp_components_namespaceObject.MenuGroup, null, isRevertable && (0,external_React_.createElement)(external_wp_components_namespaceObject.MenuItem, { 34820 info: (0,external_wp_i18n_namespaceObject.__)('Use the template as supplied by the theme.'), 34821 onClick: () => { 34822 revertTemplate(template); 34823 onClose(); 34824 } 34825 }, (0,external_wp_i18n_namespaceObject.__)('Clear customizations')), (0,external_React_.createElement)(ReplaceTemplateButton, { 34826 availableTemplates: availablePatterns, 34827 template: template, 34828 onClick: onClose 34829 }))); 34830 } 34831 34832 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sidebar-edit-mode/template-panel/template-areas.js 34833 34834 /** 34835 * WordPress dependencies 34836 */ 34837 34838 34839 34840 34841 34842 34843 /** 34844 * Internal dependencies 34845 */ 34846 34847 function TemplateAreaItem({ 34848 area, 34849 clientId 34850 }) { 34851 const { 34852 selectBlock, 34853 toggleBlockHighlight 34854 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store); 34855 const templatePartArea = (0,external_wp_data_namespaceObject.useSelect)(select => { 34856 const defaultAreas = select(external_wp_editor_namespaceObject.store).__experimentalGetDefaultTemplatePartAreas(); 34857 return defaultAreas.find(defaultArea => defaultArea.area === area); 34858 }, [area]); 34859 const highlightBlock = () => toggleBlockHighlight(clientId, true); 34860 const cancelHighlightBlock = () => toggleBlockHighlight(clientId, false); 34861 return (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 34862 className: "edit-site-template-card__template-areas-item", 34863 icon: templatePartArea?.icon, 34864 onMouseOver: highlightBlock, 34865 onMouseLeave: cancelHighlightBlock, 34866 onFocus: highlightBlock, 34867 onBlur: cancelHighlightBlock, 34868 onClick: () => { 34869 selectBlock(clientId); 34870 } 34871 }, templatePartArea?.label); 34872 } 34873 function template_areas_TemplateAreas() { 34874 const templateParts = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getCurrentTemplateTemplateParts(), []); 34875 if (!templateParts.length) { 34876 return null; 34877 } 34878 return (0,external_React_.createElement)("section", { 34879 className: "edit-site-template-card__template-areas" 34880 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHeading, { 34881 level: 3, 34882 className: "edit-site-template-card__template-areas-title" 34883 }, (0,external_wp_i18n_namespaceObject.__)('Areas')), (0,external_React_.createElement)("ul", { 34884 className: "edit-site-template-card__template-areas-list" 34885 }, templateParts.map(({ 34886 templatePart, 34887 block 34888 }) => (0,external_React_.createElement)("li", { 34889 key: block.clientId 34890 }, (0,external_React_.createElement)(TemplateAreaItem, { 34891 area: templatePart.area, 34892 clientId: block.clientId 34893 }))))); 34894 } 34895 34896 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sidebar-edit-mode/template-panel/index.js 34897 34898 /** 34899 * WordPress dependencies 34900 */ 34901 34902 34903 34904 34905 34906 34907 34908 /** 34909 * Internal dependencies 34910 */ 34911 34912 34913 34914 34915 const CARD_ICONS = { 34916 wp_block: library_symbol, 34917 wp_navigation: library_navigation 34918 }; 34919 function TemplatePanel() { 34920 var _CARD_ICONS$record$ty; 34921 const { 34922 title, 34923 description, 34924 icon, 34925 record 34926 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 34927 const { 34928 getEditedPostType, 34929 getEditedPostId 34930 } = select(store_store); 34931 const { 34932 getEditedEntityRecord 34933 } = select(external_wp_coreData_namespaceObject.store); 34934 const { 34935 __experimentalGetTemplateInfo: getTemplateInfo 34936 } = select(external_wp_editor_namespaceObject.store); 34937 const type = getEditedPostType(); 34938 const postId = getEditedPostId(); 34939 const _record = getEditedEntityRecord('postType', type, postId); 34940 const info = getTemplateInfo(_record); 34941 return { 34942 title: info.title, 34943 description: info.description, 34944 icon: info.icon, 34945 record: _record 34946 }; 34947 }, []); 34948 if (!title && !description) { 34949 return null; 34950 } 34951 return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.PanelBody, null, (0,external_React_.createElement)(SidebarCard, { 34952 className: "edit-site-template-card", 34953 title: (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(title), 34954 icon: (_CARD_ICONS$record$ty = CARD_ICONS[record?.type]) !== null && _CARD_ICONS$record$ty !== void 0 ? _CARD_ICONS$record$ty : icon, 34955 description: (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(description), 34956 actions: (0,external_React_.createElement)(Actions, { 34957 template: record 34958 }) 34959 }, (0,external_React_.createElement)(template_areas_TemplateAreas, null))), (0,external_React_.createElement)(external_wp_editor_namespaceObject.PostLastRevisionPanel, null), (0,external_React_.createElement)(external_wp_editor_namespaceObject.PostTaxonomiesPanel, null), (0,external_React_.createElement)(external_wp_editor_namespaceObject.PostFeaturedImagePanel, null), (0,external_React_.createElement)(external_wp_editor_namespaceObject.PostExcerptPanel, null), (0,external_React_.createElement)(external_wp_editor_namespaceObject.PostDiscussionPanel, null), (0,external_React_.createElement)(external_wp_editor_namespaceObject.PageAttributesPanel, null)); 34960 } 34961 34962 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/plugin-template-setting-panel/index.js 34963 /** 34964 * Defines an extensibility slot for the Template sidebar. 34965 */ 34966 34967 /** 34968 * WordPress dependencies 34969 */ 34970 34971 const { 34972 Fill, 34973 Slot: plugin_template_setting_panel_Slot 34974 } = (0,external_wp_components_namespaceObject.createSlotFill)('PluginTemplateSettingPanel'); 34975 const PluginTemplateSettingPanel = Fill; 34976 PluginTemplateSettingPanel.Slot = plugin_template_setting_panel_Slot; 34977 34978 /** 34979 * Renders items in the Template Sidebar below the main information 34980 * like the Template Card. 34981 * 34982 * @example 34983 * ```jsx 34984 * // Using ESNext syntax 34985 * import { PluginTemplateSettingPanel } from '@wordpress/edit-site'; 34986 * 34987 * const MyTemplateSettingTest = () => ( 34988 * <PluginTemplateSettingPanel> 34989 * <p>Hello, World!</p> 34990 * </PluginTemplateSettingPanel> 34991 * ); 34992 * ``` 34993 * 34994 * @return {Component} The component to be rendered. 34995 */ 34996 /* harmony default export */ const plugin_template_setting_panel = (PluginTemplateSettingPanel); 34997 34998 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sidebar-edit-mode/index.js 34999 35000 /** 35001 * WordPress dependencies 35002 */ 35003 35004 35005 35006 35007 35008 35009 35010 35011 35012 /** 35013 * Internal dependencies 35014 */ 35015 35016 35017 35018 35019 35020 35021 35022 35023 35024 35025 const { 35026 Tabs: sidebar_edit_mode_Tabs 35027 } = unlock(external_wp_components_namespaceObject.privateApis); 35028 const { 35029 Slot: InspectorSlot, 35030 Fill: InspectorFill 35031 } = (0,external_wp_components_namespaceObject.createSlotFill)('EditSiteSidebarInspector'); 35032 const SidebarInspectorFill = InspectorFill; 35033 const FillContents = ({ 35034 sidebarName, 35035 isEditingPage, 35036 supportsGlobalStyles 35037 }) => { 35038 const tabListRef = (0,external_wp_element_namespaceObject.useRef)(null); 35039 // Because `DefaultSidebar` renders a `ComplementaryArea`, we 35040 // need to forward the `Tabs` context so it can be passed through the 35041 // underlying slot/fill. 35042 const tabsContextValue = (0,external_wp_element_namespaceObject.useContext)(sidebar_edit_mode_Tabs.Context); 35043 35044 // This effect addresses a race condition caused by tabbing from the last 35045 // block in the editor into the settings sidebar. Without this effect, the 35046 // selected tab and browser focus can become separated in an unexpected way. 35047 // (e.g the "block" tab is focused, but the "post" tab is selected). 35048 (0,external_wp_element_namespaceObject.useEffect)(() => { 35049 const tabsElements = Array.from(tabListRef.current?.querySelectorAll('[role="tab"]') || []); 35050 const selectedTabElement = tabsElements.find( 35051 // We are purposefully using a custom `data-tab-id` attribute here 35052 // because we don't want rely on any assumptions about `Tabs` 35053 // component internals. 35054 element => element.getAttribute('data-tab-id') === sidebarName); 35055 const activeElement = selectedTabElement?.ownerDocument.activeElement; 35056 const tabsHasFocus = tabsElements.some(element => { 35057 return activeElement && activeElement.id === element.id; 35058 }); 35059 if (tabsHasFocus && selectedTabElement && selectedTabElement.id !== activeElement?.id) { 35060 selectedTabElement?.focus(); 35061 } 35062 }, [sidebarName]); 35063 return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(DefaultSidebar, { 35064 identifier: sidebarName, 35065 title: (0,external_wp_i18n_namespaceObject.__)('Settings'), 35066 icon: (0,external_wp_i18n_namespaceObject.isRTL)() ? drawer_left : drawer_right, 35067 closeLabel: (0,external_wp_i18n_namespaceObject.__)('Close Settings'), 35068 header: (0,external_React_.createElement)(sidebar_edit_mode_Tabs.Context.Provider, { 35069 value: tabsContextValue 35070 }, (0,external_React_.createElement)(settings_header, { 35071 ref: tabListRef 35072 })), 35073 headerClassName: "edit-site-sidebar-edit-mode__panel-tabs" 35074 // This classname is added so we can apply a corrective negative 35075 // margin to the panel. 35076 // see https://github.com/WordPress/gutenberg/pull/55360#pullrequestreview-1737671049 35077 , 35078 className: "edit-site-sidebar__panel" 35079 }, (0,external_React_.createElement)(sidebar_edit_mode_Tabs.Context.Provider, { 35080 value: tabsContextValue 35081 }, (0,external_React_.createElement)(sidebar_edit_mode_Tabs.TabPanel, { 35082 tabId: SIDEBAR_TEMPLATE, 35083 focusable: false 35084 }, isEditingPage ? (0,external_React_.createElement)(PagePanels, null) : (0,external_React_.createElement)(TemplatePanel, null), (0,external_React_.createElement)(plugin_template_setting_panel.Slot, null)), (0,external_React_.createElement)(sidebar_edit_mode_Tabs.TabPanel, { 35085 tabId: SIDEBAR_BLOCK, 35086 focusable: false 35087 }, (0,external_React_.createElement)(InspectorSlot, { 35088 bubblesVirtually: true 35089 })))), supportsGlobalStyles && (0,external_React_.createElement)(GlobalStylesSidebar, null)); 35090 }; 35091 function SidebarComplementaryAreaFills() { 35092 const { 35093 sidebar, 35094 isEditorSidebarOpened, 35095 hasBlockSelection, 35096 supportsGlobalStyles, 35097 isEditingPage, 35098 isEditorOpen 35099 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 35100 const _sidebar = select(store).getActiveComplementaryArea(constants_STORE_NAME); 35101 const _isEditorSidebarOpened = [SIDEBAR_BLOCK, SIDEBAR_TEMPLATE].includes(_sidebar); 35102 const { 35103 getCanvasMode 35104 } = unlock(select(store_store)); 35105 return { 35106 sidebar: _sidebar, 35107 isEditorSidebarOpened: _isEditorSidebarOpened, 35108 hasBlockSelection: !!select(external_wp_blockEditor_namespaceObject.store).getBlockSelectionStart(), 35109 supportsGlobalStyles: select(external_wp_coreData_namespaceObject.store).getCurrentTheme()?.is_block_theme, 35110 isEditingPage: select(store_store).isPage(), 35111 isEditorOpen: getCanvasMode() === 'edit' 35112 }; 35113 }, []); 35114 const { 35115 enableComplementaryArea 35116 } = (0,external_wp_data_namespaceObject.useDispatch)(store); 35117 (0,external_wp_element_namespaceObject.useEffect)(() => { 35118 // Don't automatically switch tab when the sidebar is closed or when we 35119 // are focused on page content. 35120 if (!isEditorSidebarOpened) { 35121 return; 35122 } 35123 if (hasBlockSelection) { 35124 if (!isEditingPage) { 35125 enableComplementaryArea(constants_STORE_NAME, SIDEBAR_BLOCK); 35126 } 35127 } else { 35128 enableComplementaryArea(constants_STORE_NAME, SIDEBAR_TEMPLATE); 35129 } 35130 }, [hasBlockSelection, isEditorSidebarOpened, isEditingPage, enableComplementaryArea]); 35131 let sidebarName = sidebar; 35132 if (!isEditorSidebarOpened) { 35133 sidebarName = hasBlockSelection ? SIDEBAR_BLOCK : SIDEBAR_TEMPLATE; 35134 } 35135 35136 // `newSelectedTabId` could technically be falsey if no tab is selected (i.e. 35137 // the initial render) or when we don't want a tab displayed (i.e. the 35138 // sidebar is closed). These cases should both be covered by the `!!` check 35139 // below, so we shouldn't need any additional falsey handling. 35140 const onTabSelect = (0,external_wp_element_namespaceObject.useCallback)(newSelectedTabId => { 35141 if (!!newSelectedTabId) { 35142 enableComplementaryArea(constants_STORE_NAME, newSelectedTabId); 35143 } 35144 }, [enableComplementaryArea]); 35145 return (0,external_React_.createElement)(sidebar_edit_mode_Tabs 35146 // Due to how this component is controlled (via a value from the 35147 // edit-site store), when the sidebar closes the currently selected 35148 // tab can't be found. This causes the component to continuously reset 35149 // the selection to `null` in an infinite loop. Proactively setting 35150 // the selected tab to `null` avoids that. 35151 , { 35152 selectedTabId: isEditorOpen && isEditorSidebarOpened ? sidebarName : null, 35153 onSelect: onTabSelect, 35154 selectOnMove: false 35155 }, (0,external_React_.createElement)(FillContents, { 35156 sidebarName: sidebarName, 35157 isEditingPage: isEditingPage, 35158 supportsGlobalStyles: supportsGlobalStyles 35159 })); 35160 } 35161 35162 // EXTERNAL MODULE: ./node_modules/react-autosize-textarea/lib/index.js 35163 var lib = __webpack_require__(4132); 35164 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/code-editor/index.js 35165 35166 /** 35167 * External dependencies 35168 */ 35169 35170 35171 /** 35172 * WordPress dependencies 35173 */ 35174 35175 35176 35177 35178 35179 35180 35181 35182 35183 /** 35184 * Internal dependencies 35185 */ 35186 35187 function CodeEditor() { 35188 const instanceId = (0,external_wp_compose_namespaceObject.useInstanceId)(CodeEditor); 35189 const { 35190 shortcut, 35191 content, 35192 blocks, 35193 type, 35194 id 35195 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 35196 const { 35197 getEditedEntityRecord 35198 } = select(external_wp_coreData_namespaceObject.store); 35199 const { 35200 getEditedPostType, 35201 getEditedPostId 35202 } = select(store_store); 35203 const { 35204 getShortcutRepresentation 35205 } = select(external_wp_keyboardShortcuts_namespaceObject.store); 35206 const _type = getEditedPostType(); 35207 const _id = getEditedPostId(); 35208 const editedRecord = getEditedEntityRecord('postType', _type, _id); 35209 return { 35210 shortcut: getShortcutRepresentation('core/edit-site/toggle-mode'), 35211 content: editedRecord?.content, 35212 blocks: editedRecord?.blocks, 35213 type: _type, 35214 id: _id 35215 }; 35216 }, []); 35217 const { 35218 editEntityRecord 35219 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store); 35220 // Replicates the logic found in getEditedPostContent(). 35221 const realContent = (0,external_wp_element_namespaceObject.useMemo)(() => { 35222 if (content instanceof Function) { 35223 return content({ 35224 blocks 35225 }); 35226 } else if (blocks) { 35227 // If we have parsed blocks already, they should be our source of truth. 35228 // Parsing applies block deprecations and legacy block conversions that 35229 // unparsed content will not have. 35230 return (0,external_wp_blocks_namespaceObject.__unstableSerializeAndClean)(blocks); 35231 } 35232 return content; 35233 }, [content, blocks]); 35234 const { 35235 switchEditorMode 35236 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store); 35237 return (0,external_React_.createElement)("div", { 35238 className: "edit-site-code-editor" 35239 }, (0,external_React_.createElement)("div", { 35240 className: "edit-site-code-editor__toolbar" 35241 }, (0,external_React_.createElement)("h2", null, (0,external_wp_i18n_namespaceObject.__)('Editing code')), (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 35242 variant: "tertiary", 35243 onClick: () => switchEditorMode('visual'), 35244 shortcut: shortcut 35245 }, (0,external_wp_i18n_namespaceObject.__)('Exit code editor'))), (0,external_React_.createElement)("div", { 35246 className: "edit-site-code-editor__body" 35247 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.VisuallyHidden, { 35248 as: "label", 35249 htmlFor: `code-editor-text-area-$instanceId}` 35250 }, (0,external_wp_i18n_namespaceObject.__)('Type text or HTML')), (0,external_React_.createElement)(lib/* default */.A, { 35251 autoComplete: "off", 35252 dir: "auto", 35253 value: realContent, 35254 onChange: event => { 35255 editEntityRecord('postType', type, id, { 35256 content: event.target.value, 35257 blocks: undefined, 35258 selection: undefined 35259 }); 35260 }, 35261 className: "edit-site-code-editor-text-area", 35262 id: `code-editor-text-area-$instanceId}`, 35263 placeholder: (0,external_wp_i18n_namespaceObject.__)('Start writing with text or HTML') 35264 }))); 35265 } 35266 35267 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/keyboard-shortcuts/edit-mode.js 35268 /** 35269 * WordPress dependencies 35270 */ 35271 35272 35273 35274 35275 35276 35277 /** 35278 * Internal dependencies 35279 */ 35280 35281 35282 35283 function KeyboardShortcutsEditMode() { 35284 const { 35285 getEditorMode 35286 } = (0,external_wp_data_namespaceObject.useSelect)(store_store); 35287 const isBlockInspectorOpen = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).getActiveComplementaryArea(store_store.name) === SIDEBAR_BLOCK, []); 35288 const { 35289 switchEditorMode, 35290 toggleDistractionFree 35291 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store); 35292 const { 35293 enableComplementaryArea, 35294 disableComplementaryArea 35295 } = (0,external_wp_data_namespaceObject.useDispatch)(store); 35296 const { 35297 replaceBlocks 35298 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store); 35299 const { 35300 getBlockName, 35301 getSelectedBlockClientId, 35302 getBlockAttributes 35303 } = (0,external_wp_data_namespaceObject.useSelect)(external_wp_blockEditor_namespaceObject.store); 35304 const handleTextLevelShortcut = (event, level) => { 35305 event.preventDefault(); 35306 const destinationBlockName = level === 0 ? 'core/paragraph' : 'core/heading'; 35307 const currentClientId = getSelectedBlockClientId(); 35308 if (currentClientId === null) { 35309 return; 35310 } 35311 const blockName = getBlockName(currentClientId); 35312 if (blockName !== 'core/paragraph' && blockName !== 'core/heading') { 35313 return; 35314 } 35315 const attributes = getBlockAttributes(currentClientId); 35316 const textAlign = blockName === 'core/paragraph' ? 'align' : 'textAlign'; 35317 const destinationTextAlign = destinationBlockName === 'core/paragraph' ? 'align' : 'textAlign'; 35318 replaceBlocks(currentClientId, (0,external_wp_blocks_namespaceObject.createBlock)(destinationBlockName, { 35319 level, 35320 content: attributes.content, 35321 ...{ 35322 [destinationTextAlign]: attributes[textAlign] 35323 } 35324 })); 35325 }; 35326 (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/edit-site/toggle-block-settings-sidebar', event => { 35327 // This shortcut has no known clashes, but use preventDefault to prevent any 35328 // obscure shortcuts from triggering. 35329 event.preventDefault(); 35330 if (isBlockInspectorOpen) { 35331 disableComplementaryArea(constants_STORE_NAME); 35332 } else { 35333 enableComplementaryArea(constants_STORE_NAME, SIDEBAR_BLOCK); 35334 } 35335 }); 35336 (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/edit-site/toggle-mode', () => { 35337 switchEditorMode(getEditorMode() === 'visual' ? 'text' : 'visual'); 35338 }); 35339 (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/edit-site/transform-heading-to-paragraph', event => handleTextLevelShortcut(event, 0)); 35340 [1, 2, 3, 4, 5, 6].forEach(level => { 35341 //the loop is based off on a constant therefore 35342 //the hook will execute the same way every time 35343 //eslint-disable-next-line react-hooks/rules-of-hooks 35344 (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)(`core/edit-site/transform-paragraph-to-heading-$level}`, event => handleTextLevelShortcut(event, level)); 35345 }); 35346 (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/edit-site/toggle-distraction-free', () => { 35347 toggleDistractionFree(); 35348 }); 35349 return null; 35350 } 35351 /* harmony default export */ const edit_mode = (KeyboardShortcutsEditMode); 35352 35353 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/welcome-guide/image.js 35354 35355 function WelcomeGuideImage({ 35356 nonAnimatedSrc, 35357 animatedSrc 35358 }) { 35359 return (0,external_React_.createElement)("picture", { 35360 className: "edit-site-welcome-guide__image" 35361 }, (0,external_React_.createElement)("source", { 35362 srcSet: nonAnimatedSrc, 35363 media: "(prefers-reduced-motion: reduce)" 35364 }), (0,external_React_.createElement)("img", { 35365 src: animatedSrc, 35366 width: "312", 35367 height: "240", 35368 alt: "" 35369 })); 35370 } 35371 35372 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/welcome-guide/editor.js 35373 35374 /** 35375 * WordPress dependencies 35376 */ 35377 35378 35379 35380 35381 35382 35383 /** 35384 * Internal dependencies 35385 */ 35386 35387 function WelcomeGuideEditor() { 35388 const { 35389 toggle 35390 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_preferences_namespaceObject.store); 35391 const isActive = (0,external_wp_data_namespaceObject.useSelect)(select => !!select(external_wp_preferences_namespaceObject.store).get('core/edit-site', 'welcomeGuide'), []); 35392 if (!isActive) { 35393 return null; 35394 } 35395 return (0,external_React_.createElement)(external_wp_components_namespaceObject.Guide, { 35396 className: "edit-site-welcome-guide guide-editor", 35397 contentLabel: (0,external_wp_i18n_namespaceObject.__)('Welcome to the site editor'), 35398 finishButtonText: (0,external_wp_i18n_namespaceObject.__)('Get started'), 35399 onFinish: () => toggle('core/edit-site', 'welcomeGuide'), 35400 pages: [{ 35401 image: (0,external_React_.createElement)(WelcomeGuideImage, { 35402 nonAnimatedSrc: "https://s.w.org/images/block-editor/edit-your-site.svg?1", 35403 animatedSrc: "https://s.w.org/images/block-editor/edit-your-site.gif?1" 35404 }), 35405 content: (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)("h1", { 35406 className: "edit-site-welcome-guide__heading" 35407 }, (0,external_wp_i18n_namespaceObject.__)('Edit your site')), (0,external_React_.createElement)("p", { 35408 className: "edit-site-welcome-guide__text" 35409 }, (0,external_wp_i18n_namespaceObject.__)('Design everything on your site — from the header right down to the footer — using blocks.')), (0,external_React_.createElement)("p", { 35410 className: "edit-site-welcome-guide__text" 35411 }, (0,external_wp_element_namespaceObject.createInterpolateElement)((0,external_wp_i18n_namespaceObject.__)('Click <StylesIconImage /> to start designing your blocks, and choose your typography, layout, and colors.'), { 35412 StylesIconImage: (0,external_React_.createElement)("img", { 35413 alt: (0,external_wp_i18n_namespaceObject.__)('styles'), 35414 src: "data:image/svg+xml,%3Csvg width='18' height='18' viewBox='0 0 24 24' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M12 4c-4.4 0-8 3.6-8 8v.1c0 4.1 3.2 7.5 7.2 7.9h.8c4.4 0 8-3.6 8-8s-3.6-8-8-8zm0 15V5c3.9 0 7 3.1 7 7s-3.1 7-7 7z' fill='%231E1E1E'/%3E%3C/svg%3E%0A" 35415 }) 35416 }))) 35417 }] 35418 }); 35419 } 35420 35421 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/welcome-guide/styles.js 35422 35423 /** 35424 * WordPress dependencies 35425 */ 35426 35427 35428 35429 35430 35431 35432 /** 35433 * Internal dependencies 35434 */ 35435 35436 35437 function WelcomeGuideStyles() { 35438 const { 35439 toggle 35440 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_preferences_namespaceObject.store); 35441 const { 35442 isActive, 35443 isStylesOpen 35444 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 35445 const sidebar = select(store).getActiveComplementaryArea(store_store.name); 35446 return { 35447 isActive: !!select(external_wp_preferences_namespaceObject.store).get('core/edit-site', 'welcomeGuideStyles'), 35448 isStylesOpen: sidebar === 'edit-site/global-styles' 35449 }; 35450 }, []); 35451 if (!isActive || !isStylesOpen) { 35452 return null; 35453 } 35454 const welcomeLabel = (0,external_wp_i18n_namespaceObject.__)('Welcome to Styles'); 35455 return (0,external_React_.createElement)(external_wp_components_namespaceObject.Guide, { 35456 className: "edit-site-welcome-guide guide-styles", 35457 contentLabel: welcomeLabel, 35458 finishButtonText: (0,external_wp_i18n_namespaceObject.__)('Get started'), 35459 onFinish: () => toggle('core/edit-site', 'welcomeGuideStyles'), 35460 pages: [{ 35461 image: (0,external_React_.createElement)(WelcomeGuideImage, { 35462 nonAnimatedSrc: "https://s.w.org/images/block-editor/welcome-to-styles.svg?1", 35463 animatedSrc: "https://s.w.org/images/block-editor/welcome-to-styles.gif?1" 35464 }), 35465 content: (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)("h1", { 35466 className: "edit-site-welcome-guide__heading" 35467 }, welcomeLabel), (0,external_React_.createElement)("p", { 35468 className: "edit-site-welcome-guide__text" 35469 }, (0,external_wp_i18n_namespaceObject.__)('Tweak your site, or give it a whole new look! Get creative — how about a new color palette for your buttons, or choosing a new font? Take a look at what you can do here.'))) 35470 }, { 35471 image: (0,external_React_.createElement)(WelcomeGuideImage, { 35472 nonAnimatedSrc: "https://s.w.org/images/block-editor/set-the-design.svg?1", 35473 animatedSrc: "https://s.w.org/images/block-editor/set-the-design.gif?1" 35474 }), 35475 content: (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)("h1", { 35476 className: "edit-site-welcome-guide__heading" 35477 }, (0,external_wp_i18n_namespaceObject.__)('Set the design')), (0,external_React_.createElement)("p", { 35478 className: "edit-site-welcome-guide__text" 35479 }, (0,external_wp_i18n_namespaceObject.__)('You can customize your site as much as you like with different colors, typography, and layouts. Or if you prefer, just leave it up to your theme to handle!'))) 35480 }, { 35481 image: (0,external_React_.createElement)(WelcomeGuideImage, { 35482 nonAnimatedSrc: "https://s.w.org/images/block-editor/personalize-blocks.svg?1", 35483 animatedSrc: "https://s.w.org/images/block-editor/personalize-blocks.gif?1" 35484 }), 35485 content: (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)("h1", { 35486 className: "edit-site-welcome-guide__heading" 35487 }, (0,external_wp_i18n_namespaceObject.__)('Personalize blocks')), (0,external_React_.createElement)("p", { 35488 className: "edit-site-welcome-guide__text" 35489 }, (0,external_wp_i18n_namespaceObject.__)('You can adjust your blocks to ensure a cohesive experience across your site — add your unique colors to a branded Button block, or adjust the Heading block to your preferred size.'))) 35490 }, { 35491 image: (0,external_React_.createElement)(WelcomeGuideImage, { 35492 nonAnimatedSrc: "https://s.w.org/images/block-editor/welcome-documentation.svg", 35493 animatedSrc: "https://s.w.org/images/block-editor/welcome-documentation.gif" 35494 }), 35495 content: (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)("h1", { 35496 className: "edit-site-welcome-guide__heading" 35497 }, (0,external_wp_i18n_namespaceObject.__)('Learn more')), (0,external_React_.createElement)("p", { 35498 className: "edit-site-welcome-guide__text" 35499 }, (0,external_wp_i18n_namespaceObject.__)('New to block themes and styling your site?'), ' ', (0,external_React_.createElement)(external_wp_components_namespaceObject.ExternalLink, { 35500 href: (0,external_wp_i18n_namespaceObject.__)('https://wordpress.org/documentation/article/styles-overview/') 35501 }, (0,external_wp_i18n_namespaceObject.__)('Here’s a detailed guide to learn how to make the most of it.')))) 35502 }] 35503 }); 35504 } 35505 35506 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/welcome-guide/page.js 35507 35508 /** 35509 * WordPress dependencies 35510 */ 35511 35512 35513 35514 35515 35516 /** 35517 * Internal dependencies 35518 */ 35519 35520 function WelcomeGuidePage() { 35521 const { 35522 toggle 35523 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_preferences_namespaceObject.store); 35524 const isVisible = (0,external_wp_data_namespaceObject.useSelect)(select => { 35525 const isPageActive = !!select(external_wp_preferences_namespaceObject.store).get('core/edit-site', 'welcomeGuidePage'); 35526 const isEditorActive = !!select(external_wp_preferences_namespaceObject.store).get('core/edit-site', 'welcomeGuide'); 35527 const { 35528 isPage 35529 } = select(store_store); 35530 return isPageActive && !isEditorActive && isPage(); 35531 }, []); 35532 if (!isVisible) { 35533 return null; 35534 } 35535 const heading = (0,external_wp_i18n_namespaceObject.__)('Editing a page'); 35536 return (0,external_React_.createElement)(external_wp_components_namespaceObject.Guide, { 35537 className: "edit-site-welcome-guide guide-page", 35538 contentLabel: heading, 35539 finishButtonText: (0,external_wp_i18n_namespaceObject.__)('Continue'), 35540 onFinish: () => toggle('core/edit-site', 'welcomeGuidePage'), 35541 pages: [{ 35542 image: (0,external_React_.createElement)("video", { 35543 className: "edit-site-welcome-guide__video", 35544 autoPlay: true, 35545 loop: true, 35546 muted: true, 35547 width: "312", 35548 height: "240" 35549 }, (0,external_React_.createElement)("source", { 35550 src: "https://s.w.org/images/block-editor/editing-your-page.mp4", 35551 type: "video/mp4" 35552 })), 35553 content: (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)("h1", { 35554 className: "edit-site-welcome-guide__heading" 35555 }, heading), (0,external_React_.createElement)("p", { 35556 className: "edit-site-welcome-guide__text" 35557 }, (0,external_wp_i18n_namespaceObject.__)('It’s now possible to edit page content in the site editor. To customise other parts of the page like the header and footer switch to editing the template using the settings sidebar.'))) 35558 }] 35559 }); 35560 } 35561 35562 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/welcome-guide/template.js 35563 35564 /** 35565 * WordPress dependencies 35566 */ 35567 35568 35569 35570 35571 35572 35573 /** 35574 * Internal dependencies 35575 */ 35576 35577 function WelcomeGuideTemplate() { 35578 const { 35579 toggle 35580 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_preferences_namespaceObject.store); 35581 const isVisible = (0,external_wp_data_namespaceObject.useSelect)(select => { 35582 const isTemplateActive = !!select(external_wp_preferences_namespaceObject.store).get('core/edit-site', 'welcomeGuideTemplate'); 35583 const isEditorActive = !!select(external_wp_preferences_namespaceObject.store).get('core/edit-site', 'welcomeGuide'); 35584 const { 35585 isPage 35586 } = select(store_store); 35587 const { 35588 getCurrentPostType 35589 } = select(external_wp_editor_namespaceObject.store); 35590 return isTemplateActive && !isEditorActive && isPage() && getCurrentPostType() === 'wp_template'; 35591 }, []); 35592 if (!isVisible) { 35593 return null; 35594 } 35595 const heading = (0,external_wp_i18n_namespaceObject.__)('Editing a template'); 35596 return (0,external_React_.createElement)(external_wp_components_namespaceObject.Guide, { 35597 className: "edit-site-welcome-guide guide-template", 35598 contentLabel: heading, 35599 finishButtonText: (0,external_wp_i18n_namespaceObject.__)('Continue'), 35600 onFinish: () => toggle('core/edit-site', 'welcomeGuideTemplate'), 35601 pages: [{ 35602 image: (0,external_React_.createElement)("video", { 35603 className: "edit-site-welcome-guide__video", 35604 autoPlay: true, 35605 loop: true, 35606 muted: true, 35607 width: "312", 35608 height: "240" 35609 }, (0,external_React_.createElement)("source", { 35610 src: "https://s.w.org/images/block-editor/editing-your-template.mp4", 35611 type: "video/mp4" 35612 })), 35613 content: (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)("h1", { 35614 className: "edit-site-welcome-guide__heading" 35615 }, heading), (0,external_React_.createElement)("p", { 35616 className: "edit-site-welcome-guide__text" 35617 }, (0,external_wp_i18n_namespaceObject.__)('Note that the same template can be used by multiple pages, so any changes made here may affect other pages on the site. To switch back to editing the page content click the ‘Back’ button in the toolbar.'))) 35618 }] 35619 }); 35620 } 35621 35622 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/welcome-guide/index.js 35623 35624 /** 35625 * Internal dependencies 35626 */ 35627 35628 35629 35630 35631 function WelcomeGuide() { 35632 return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(WelcomeGuideEditor, null), (0,external_React_.createElement)(WelcomeGuideStyles, null), (0,external_React_.createElement)(WelcomeGuidePage, null), (0,external_React_.createElement)(WelcomeGuideTemplate, null)); 35633 } 35634 35635 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/start-template-options/index.js 35636 35637 /** 35638 * WordPress dependencies 35639 */ 35640 35641 35642 35643 35644 35645 35646 35647 35648 35649 35650 /** 35651 * Internal dependencies 35652 */ 35653 35654 35655 function useFallbackTemplateContent(slug, isCustom = false) { 35656 return (0,external_wp_data_namespaceObject.useSelect)(select => { 35657 const { 35658 getEntityRecord, 35659 getDefaultTemplateId 35660 } = select(external_wp_coreData_namespaceObject.store); 35661 const templateId = getDefaultTemplateId({ 35662 slug, 35663 is_custom: isCustom, 35664 ignore_empty: true 35665 }); 35666 return templateId ? getEntityRecord('postType', constants_TEMPLATE_POST_TYPE, templateId)?.content?.raw : undefined; 35667 }, [slug, isCustom]); 35668 } 35669 function useStartPatterns(fallbackContent) { 35670 const { 35671 slug, 35672 patterns 35673 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 35674 const { 35675 getEditedPostType, 35676 getEditedPostId 35677 } = select(store_store); 35678 const { 35679 getEntityRecord, 35680 getBlockPatterns 35681 } = select(external_wp_coreData_namespaceObject.store); 35682 const postId = getEditedPostId(); 35683 const postType = getEditedPostType(); 35684 const record = getEntityRecord('postType', postType, postId); 35685 return { 35686 slug: record.slug, 35687 patterns: getBlockPatterns() 35688 }; 35689 }, []); 35690 const currentThemeStylesheet = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).getCurrentTheme().stylesheet); 35691 35692 // Duplicated from packages/block-library/src/pattern/edit.js. 35693 function injectThemeAttributeInBlockTemplateContent(block) { 35694 if (block.innerBlocks.find(innerBlock => innerBlock.name === 'core/template-part')) { 35695 block.innerBlocks = block.innerBlocks.map(innerBlock => { 35696 if (innerBlock.name === 'core/template-part' && innerBlock.attributes.theme === undefined) { 35697 innerBlock.attributes.theme = currentThemeStylesheet; 35698 } 35699 return innerBlock; 35700 }); 35701 } 35702 if (block.name === 'core/template-part' && block.attributes.theme === undefined) { 35703 block.attributes.theme = currentThemeStylesheet; 35704 } 35705 return block; 35706 } 35707 return (0,external_wp_element_namespaceObject.useMemo)(() => { 35708 // filter patterns that are supposed to be used in the current template being edited. 35709 return [{ 35710 name: 'fallback', 35711 blocks: (0,external_wp_blocks_namespaceObject.parse)(fallbackContent), 35712 title: (0,external_wp_i18n_namespaceObject.__)('Fallback content') 35713 }, ...patterns.filter(pattern => { 35714 return Array.isArray(pattern.templateTypes) && pattern.templateTypes.some(templateType => slug.startsWith(templateType)); 35715 }).map(pattern => { 35716 return { 35717 ...pattern, 35718 blocks: (0,external_wp_blocks_namespaceObject.parse)(pattern.content).map(block => injectThemeAttributeInBlockTemplateContent(block)) 35719 }; 35720 })]; 35721 }, [fallbackContent, slug, patterns]); 35722 } 35723 function PatternSelection({ 35724 fallbackContent, 35725 onChoosePattern, 35726 postType 35727 }) { 35728 const [,, onChange] = (0,external_wp_coreData_namespaceObject.useEntityBlockEditor)('postType', postType); 35729 const blockPatterns = useStartPatterns(fallbackContent); 35730 const shownBlockPatterns = (0,external_wp_compose_namespaceObject.useAsyncList)(blockPatterns); 35731 return (0,external_React_.createElement)(external_wp_blockEditor_namespaceObject.__experimentalBlockPatternsList, { 35732 blockPatterns: blockPatterns, 35733 shownPatterns: shownBlockPatterns, 35734 onClickPattern: (pattern, blocks) => { 35735 onChange(blocks, { 35736 selection: undefined 35737 }); 35738 onChoosePattern(); 35739 } 35740 }); 35741 } 35742 function StartModal({ 35743 slug, 35744 isCustom, 35745 onClose, 35746 postType 35747 }) { 35748 const fallbackContent = useFallbackTemplateContent(slug, isCustom); 35749 if (!fallbackContent) { 35750 return null; 35751 } 35752 return (0,external_React_.createElement)(external_wp_components_namespaceObject.Modal, { 35753 className: "edit-site-start-template-options__modal", 35754 title: (0,external_wp_i18n_namespaceObject.__)('Choose a pattern'), 35755 closeLabel: (0,external_wp_i18n_namespaceObject.__)('Cancel'), 35756 focusOnMount: "firstElement", 35757 onRequestClose: onClose, 35758 isFullScreen: true 35759 }, (0,external_React_.createElement)("div", { 35760 className: "edit-site-start-template-options__modal-content" 35761 }, (0,external_React_.createElement)(PatternSelection, { 35762 fallbackContent: fallbackContent, 35763 slug: slug, 35764 isCustom: isCustom, 35765 postType: postType, 35766 onChoosePattern: () => { 35767 onClose(); 35768 } 35769 })), (0,external_React_.createElement)(external_wp_components_namespaceObject.Flex, { 35770 className: "edit-site-start-template-options__modal__actions", 35771 justify: "flex-end", 35772 expanded: false 35773 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.FlexItem, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 35774 variant: "tertiary", 35775 onClick: onClose 35776 }, (0,external_wp_i18n_namespaceObject.__)('Skip'))))); 35777 } 35778 const START_TEMPLATE_MODAL_STATES = { 35779 INITIAL: 'INITIAL', 35780 CLOSED: 'CLOSED' 35781 }; 35782 function StartTemplateOptions() { 35783 const [modalState, setModalState] = (0,external_wp_element_namespaceObject.useState)(START_TEMPLATE_MODAL_STATES.INITIAL); 35784 const { 35785 shouldOpenModal, 35786 slug, 35787 isCustom, 35788 postType 35789 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 35790 const { 35791 getEditedPostType, 35792 getEditedPostId 35793 } = select(store_store); 35794 const _postType = getEditedPostType(); 35795 const postId = getEditedPostId(); 35796 const { 35797 getEditedEntityRecord, 35798 hasEditsForEntityRecord 35799 } = select(external_wp_coreData_namespaceObject.store); 35800 const templateRecord = getEditedEntityRecord('postType', _postType, postId); 35801 const hasEdits = hasEditsForEntityRecord('postType', _postType, postId); 35802 return { 35803 shouldOpenModal: !hasEdits && '' === templateRecord.content && constants_TEMPLATE_POST_TYPE === _postType && !select(external_wp_preferences_namespaceObject.store).get('core/edit-site', 'welcomeGuide'), 35804 slug: templateRecord.slug, 35805 isCustom: templateRecord.is_custom, 35806 postType: _postType 35807 }; 35808 }, []); 35809 if (modalState === START_TEMPLATE_MODAL_STATES.INITIAL && !shouldOpenModal || modalState === START_TEMPLATE_MODAL_STATES.CLOSED) { 35810 return null; 35811 } 35812 return (0,external_React_.createElement)(StartModal, { 35813 slug: slug, 35814 isCustom: isCustom, 35815 postType: postType, 35816 onClose: () => setModalState(START_TEMPLATE_MODAL_STATES.CLOSED) 35817 }); 35818 } 35819 35820 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/global-styles-renderer/index.js 35821 /** 35822 * WordPress dependencies 35823 */ 35824 35825 35826 35827 35828 /** 35829 * Internal dependencies 35830 */ 35831 35832 35833 const { 35834 useGlobalStylesOutput: global_styles_renderer_useGlobalStylesOutput 35835 } = unlock(external_wp_blockEditor_namespaceObject.privateApis); 35836 function useGlobalStylesRenderer() { 35837 const [styles, settings] = global_styles_renderer_useGlobalStylesOutput(); 35838 const { 35839 getSettings 35840 } = (0,external_wp_data_namespaceObject.useSelect)(store_store); 35841 const { 35842 updateSettings 35843 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store); 35844 (0,external_wp_element_namespaceObject.useEffect)(() => { 35845 var _currentStoreSettings; 35846 if (!styles || !settings) { 35847 return; 35848 } 35849 const currentStoreSettings = getSettings(); 35850 const nonGlobalStyles = Object.values((_currentStoreSettings = currentStoreSettings.styles) !== null && _currentStoreSettings !== void 0 ? _currentStoreSettings : []).filter(style => !style.isGlobalStyles); 35851 updateSettings({ 35852 ...currentStoreSettings, 35853 styles: [...nonGlobalStyles, ...styles], 35854 __experimentalFeatures: settings 35855 }); 35856 }, [styles, settings, updateSettings, getSettings]); 35857 } 35858 function GlobalStylesRenderer() { 35859 useGlobalStylesRenderer(); 35860 return null; 35861 } 35862 35863 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/routes/use-title.js 35864 /** 35865 * WordPress dependencies 35866 */ 35867 35868 35869 35870 35871 35872 35873 35874 35875 /** 35876 * Internal dependencies 35877 */ 35878 35879 const { 35880 useLocation: use_title_useLocation 35881 } = unlock(external_wp_router_namespaceObject.privateApis); 35882 function useTitle(title) { 35883 const location = use_title_useLocation(); 35884 const siteTitle = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).getEntityRecord('root', 'site')?.title, []); 35885 const isInitialLocationRef = (0,external_wp_element_namespaceObject.useRef)(true); 35886 (0,external_wp_element_namespaceObject.useEffect)(() => { 35887 isInitialLocationRef.current = false; 35888 }, [location]); 35889 (0,external_wp_element_namespaceObject.useEffect)(() => { 35890 // Don't update or announce the title for initial page load. 35891 if (isInitialLocationRef.current) { 35892 return; 35893 } 35894 if (title && siteTitle) { 35895 // @see https://github.com/WordPress/wordpress-develop/blob/94849898192d271d533e09756007e176feb80697/src/wp-admin/admin-header.php#L67-L68 35896 const formattedTitle = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: Admin document title. 1: Admin screen name, 2: Network or site name. */ 35897 (0,external_wp_i18n_namespaceObject.__)('%1$s ‹ %2$s ‹ Editor — WordPress'), (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(title), (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(siteTitle)); 35898 document.title = formattedTitle; 35899 35900 // Announce title on route change for screen readers. 35901 (0,external_wp_a11y_namespaceObject.speak)(title, 'assertive'); 35902 } 35903 }, [title, siteTitle, location]); 35904 } 35905 35906 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/canvas-loader/index.js 35907 35908 /** 35909 * WordPress dependencies 35910 */ 35911 35912 35913 35914 35915 35916 /** 35917 * Internal dependencies 35918 */ 35919 35920 35921 const { 35922 ProgressBar: canvas_loader_ProgressBar, 35923 Theme 35924 } = unlock(external_wp_components_namespaceObject.privateApis); 35925 const { 35926 useGlobalStyle: canvas_loader_useGlobalStyle 35927 } = unlock(external_wp_blockEditor_namespaceObject.privateApis); 35928 function CanvasLoader({ 35929 id 35930 }) { 35931 var _highlightedColors$0$; 35932 const [fallbackIndicatorColor] = canvas_loader_useGlobalStyle('color.text'); 35933 const [backgroundColor] = canvas_loader_useGlobalStyle('color.background'); 35934 const { 35935 highlightedColors 35936 } = useStylesPreviewColors(); 35937 const indicatorColor = (_highlightedColors$0$ = highlightedColors[0]?.color) !== null && _highlightedColors$0$ !== void 0 ? _highlightedColors$0$ : fallbackIndicatorColor; 35938 const { 35939 elapsed, 35940 total 35941 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 35942 var _selectorsByStatus$re, _selectorsByStatus$fi; 35943 const selectorsByStatus = select(external_wp_coreData_namespaceObject.store).countSelectorsByStatus(); 35944 const resolving = (_selectorsByStatus$re = selectorsByStatus.resolving) !== null && _selectorsByStatus$re !== void 0 ? _selectorsByStatus$re : 0; 35945 const finished = (_selectorsByStatus$fi = selectorsByStatus.finished) !== null && _selectorsByStatus$fi !== void 0 ? _selectorsByStatus$fi : 0; 35946 return { 35947 elapsed: finished, 35948 total: finished + resolving 35949 }; 35950 }, []); 35951 return (0,external_React_.createElement)("div", { 35952 className: "edit-site-canvas-loader" 35953 }, (0,external_React_.createElement)(Theme, { 35954 accent: indicatorColor, 35955 background: backgroundColor 35956 }, (0,external_React_.createElement)(canvas_loader_ProgressBar, { 35957 id: id, 35958 max: total, 35959 value: elapsed 35960 }))); 35961 } 35962 35963 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/block-editor/editor-canvas.js 35964 35965 /** 35966 * External dependencies 35967 */ 35968 35969 35970 /** 35971 * WordPress dependencies 35972 */ 35973 35974 35975 35976 35977 35978 35979 35980 /** 35981 * Internal dependencies 35982 */ 35983 35984 35985 35986 const { 35987 EditorCanvas: EditorCanvasRoot 35988 } = unlock(external_wp_editor_namespaceObject.privateApis); 35989 function EditorCanvas({ 35990 enableResizing, 35991 settings, 35992 children, 35993 ...props 35994 }) { 35995 const { 35996 hasBlocks, 35997 isFocusMode, 35998 templateType, 35999 canvasMode, 36000 isZoomOutMode 36001 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 36002 const { 36003 getBlockCount, 36004 __unstableGetEditorMode 36005 } = select(external_wp_blockEditor_namespaceObject.store); 36006 const { 36007 getEditedPostType, 36008 getCanvasMode 36009 } = unlock(select(store_store)); 36010 const _templateType = getEditedPostType(); 36011 return { 36012 templateType: _templateType, 36013 isFocusMode: FOCUSABLE_ENTITIES.includes(_templateType), 36014 isZoomOutMode: __unstableGetEditorMode() === 'zoom-out', 36015 canvasMode: getCanvasMode(), 36016 hasBlocks: !!getBlockCount() 36017 }; 36018 }, []); 36019 const { 36020 setCanvasMode 36021 } = unlock((0,external_wp_data_namespaceObject.useDispatch)(store_store)); 36022 const [isFocused, setIsFocused] = (0,external_wp_element_namespaceObject.useState)(false); 36023 (0,external_wp_element_namespaceObject.useEffect)(() => { 36024 if (canvasMode === 'edit') { 36025 setIsFocused(false); 36026 } 36027 }, [canvasMode]); 36028 const viewModeProps = { 36029 'aria-label': (0,external_wp_i18n_namespaceObject.__)('Editor Canvas'), 36030 role: 'button', 36031 tabIndex: 0, 36032 onFocus: () => setIsFocused(true), 36033 onBlur: () => setIsFocused(false), 36034 onKeyDown: event => { 36035 const { 36036 keyCode 36037 } = event; 36038 if (keyCode === external_wp_keycodes_namespaceObject.ENTER || keyCode === external_wp_keycodes_namespaceObject.SPACE) { 36039 event.preventDefault(); 36040 setCanvasMode('edit'); 36041 } 36042 }, 36043 onClick: () => setCanvasMode('edit'), 36044 readonly: true 36045 }; 36046 const isTemplateTypeNavigation = templateType === NAVIGATION_POST_TYPE; 36047 const isNavigationFocusMode = isTemplateTypeNavigation && isFocusMode; 36048 // Hide the appender when: 36049 // - In navigation focus mode (should only allow the root Nav block). 36050 // - In view mode (i.e. not editing). 36051 const showBlockAppender = isNavigationFocusMode && hasBlocks || canvasMode === 'view' ? false : undefined; 36052 const styles = (0,external_wp_element_namespaceObject.useMemo)(() => [...settings.styles, { 36053 // Forming a "block formatting context" to prevent margin collapsing. 36054 // @see https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Block_formatting_context 36055 36056 css: `.is-root-container{display:flow-root;${ 36057 // Some themes will have `min-height: 100vh` for the root container, 36058 // which isn't a requirement in auto resize mode. 36059 enableResizing ? 'min-height:0!important;' : ''}}body{position:relative; $canvasMode === 'view' ? 'cursor: pointer; min-height: 100vh;' : ''}}}` 36060 }], [settings.styles, enableResizing, canvasMode]); 36061 return (0,external_React_.createElement)(EditorCanvasRoot, { 36062 className: classnames_default()('edit-site-editor-canvas__block-list', { 36063 'is-navigation-block': isTemplateTypeNavigation 36064 }), 36065 renderAppender: showBlockAppender, 36066 styles: styles, 36067 iframeProps: { 36068 expand: isZoomOutMode, 36069 scale: isZoomOutMode ? 0.45 : undefined, 36070 frameSize: isZoomOutMode ? 100 : undefined, 36071 className: classnames_default()('edit-site-visual-editor__editor-canvas', { 36072 'is-focused': isFocused && canvasMode === 'view' 36073 }), 36074 ...props, 36075 ...(canvasMode === 'view' ? viewModeProps : {}) 36076 } 36077 }, children); 36078 } 36079 /* harmony default export */ const editor_canvas = (EditorCanvas); 36080 36081 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/block-editor/use-navigate-to-entity-record.js 36082 /** 36083 * WordPress dependencies 36084 */ 36085 36086 36087 36088 /** 36089 * Internal dependencies 36090 */ 36091 36092 const { 36093 useHistory: use_navigate_to_entity_record_useHistory 36094 } = unlock(external_wp_router_namespaceObject.privateApis); 36095 function useNavigateToEntityRecord() { 36096 const history = use_navigate_to_entity_record_useHistory(); 36097 const onNavigateToEntityRecord = (0,external_wp_element_namespaceObject.useCallback)(params => { 36098 history.push({ 36099 ...params, 36100 focusMode: true, 36101 canvas: 'edit' 36102 }); 36103 }, [history]); 36104 return onNavigateToEntityRecord; 36105 } 36106 36107 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/block-editor/use-site-editor-settings.js 36108 /** 36109 * WordPress dependencies 36110 */ 36111 36112 36113 36114 36115 36116 36117 36118 /** 36119 * Internal dependencies 36120 */ 36121 36122 36123 36124 36125 const { 36126 useBlockEditorSettings 36127 } = unlock(external_wp_editor_namespaceObject.privateApis); 36128 const { 36129 useLocation: use_site_editor_settings_useLocation, 36130 useHistory: use_site_editor_settings_useHistory 36131 } = unlock(external_wp_router_namespaceObject.privateApis); 36132 function useArchiveLabel(templateSlug) { 36133 const taxonomyMatches = templateSlug?.match(/^(category|tag|taxonomy-([^-]+))$|^(((category|tag)|taxonomy-([^-]+))-(.+))$/); 36134 let taxonomy; 36135 let term; 36136 let isAuthor = false; 36137 let authorSlug; 36138 if (taxonomyMatches) { 36139 // If is for a all taxonomies of a type 36140 if (taxonomyMatches[1]) { 36141 taxonomy = taxonomyMatches[2] ? taxonomyMatches[2] : taxonomyMatches[1]; 36142 } 36143 // If is for a all taxonomies of a type 36144 else if (taxonomyMatches[3]) { 36145 taxonomy = taxonomyMatches[6] ? taxonomyMatches[6] : taxonomyMatches[4]; 36146 term = taxonomyMatches[7]; 36147 } 36148 taxonomy = taxonomy === 'tag' ? 'post_tag' : taxonomy; 36149 36150 //getTaxonomy( 'category' ); 36151 //wp.data.select('core').getEntityRecords( 'taxonomy', 'category', {slug: 'newcat'} ); 36152 } else { 36153 const authorMatches = templateSlug?.match(/^(author)$|^author-(.+)$/); 36154 if (authorMatches) { 36155 isAuthor = true; 36156 if (authorMatches[2]) { 36157 authorSlug = authorMatches[2]; 36158 } 36159 } 36160 } 36161 return (0,external_wp_data_namespaceObject.useSelect)(select => { 36162 const { 36163 getEntityRecords, 36164 getTaxonomy, 36165 getAuthors 36166 } = select(external_wp_coreData_namespaceObject.store); 36167 let archiveTypeLabel; 36168 let archiveNameLabel; 36169 if (taxonomy) { 36170 archiveTypeLabel = getTaxonomy(taxonomy)?.labels?.singular_name; 36171 } 36172 if (term) { 36173 const records = getEntityRecords('taxonomy', taxonomy, { 36174 slug: term, 36175 per_page: 1 36176 }); 36177 if (records && records[0]) { 36178 archiveNameLabel = records[0].name; 36179 } 36180 } 36181 if (isAuthor) { 36182 archiveTypeLabel = 'Author'; 36183 if (authorSlug) { 36184 const authorRecords = getAuthors({ 36185 slug: authorSlug 36186 }); 36187 if (authorRecords && authorRecords[0]) { 36188 archiveNameLabel = authorRecords[0].name; 36189 } 36190 } 36191 } 36192 return { 36193 archiveTypeLabel, 36194 archiveNameLabel 36195 }; 36196 }, [authorSlug, isAuthor, taxonomy, term]); 36197 } 36198 function useNavigateToPreviousEntityRecord() { 36199 const location = use_site_editor_settings_useLocation(); 36200 const previousLocation = (0,external_wp_compose_namespaceObject.usePrevious)(location); 36201 const history = use_site_editor_settings_useHistory(); 36202 const goBack = (0,external_wp_element_namespaceObject.useMemo)(() => { 36203 const isFocusMode = location.params.focusMode || location.params.postId && FOCUSABLE_ENTITIES.includes(location.params.postType); 36204 const didComeFromEditorCanvas = previousLocation?.params.canvas === 'edit'; 36205 const showBackButton = isFocusMode && didComeFromEditorCanvas; 36206 return showBackButton ? () => history.back() : undefined; 36207 // Disable reason: previousLocation changes when the component updates for any reason, not 36208 // just when location changes. Until this is fixed we can't add it to deps. See 36209 // https://github.com/WordPress/gutenberg/pull/58710#discussion_r1479219465. 36210 // eslint-disable-next-line react-hooks/exhaustive-deps 36211 }, [location, history]); 36212 return goBack; 36213 } 36214 function useSpecificEditorSettings() { 36215 const onNavigateToEntityRecord = useNavigateToEntityRecord(); 36216 const { 36217 templateSlug, 36218 canvasMode, 36219 settings, 36220 postWithTemplate 36221 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 36222 const { 36223 getEditedPostType, 36224 getEditedPostId, 36225 getEditedPostContext, 36226 getCanvasMode, 36227 getSettings 36228 } = unlock(select(store_store)); 36229 const { 36230 getEditedEntityRecord 36231 } = select(external_wp_coreData_namespaceObject.store); 36232 const usedPostType = getEditedPostType(); 36233 const usedPostId = getEditedPostId(); 36234 const _record = getEditedEntityRecord('postType', usedPostType, usedPostId); 36235 const _context = getEditedPostContext(); 36236 return { 36237 templateSlug: _record.slug, 36238 canvasMode: getCanvasMode(), 36239 settings: getSettings(), 36240 postWithTemplate: _context?.postId 36241 }; 36242 }, []); 36243 const archiveLabels = useArchiveLabel(templateSlug); 36244 const defaultRenderingMode = postWithTemplate ? 'template-locked' : 'post-only'; 36245 const onNavigateToPreviousEntityRecord = useNavigateToPreviousEntityRecord(); 36246 const defaultEditorSettings = (0,external_wp_element_namespaceObject.useMemo)(() => { 36247 return { 36248 ...settings, 36249 richEditingEnabled: true, 36250 supportsTemplateMode: true, 36251 focusMode: canvasMode !== 'view', 36252 defaultRenderingMode, 36253 onNavigateToEntityRecord, 36254 onNavigateToPreviousEntityRecord, 36255 // I wonder if they should be set in the post editor too 36256 __experimentalArchiveTitleTypeLabel: archiveLabels.archiveTypeLabel, 36257 __experimentalArchiveTitleNameLabel: archiveLabels.archiveNameLabel 36258 }; 36259 }, [settings, canvasMode, defaultRenderingMode, onNavigateToEntityRecord, onNavigateToPreviousEntityRecord, archiveLabels.archiveTypeLabel, archiveLabels.archiveNameLabel]); 36260 return defaultEditorSettings; 36261 } 36262 function useSiteEditorSettings() { 36263 const defaultEditorSettings = useSpecificEditorSettings(); 36264 const { 36265 postType, 36266 postId 36267 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 36268 const { 36269 getEditedPostType, 36270 getEditedPostId 36271 } = unlock(select(store_store)); 36272 const usedPostType = getEditedPostType(); 36273 const usedPostId = getEditedPostId(); 36274 return { 36275 postType: usedPostType, 36276 postId: usedPostId 36277 }; 36278 }, []); 36279 return useBlockEditorSettings(defaultEditorSettings, postType, postId); 36280 } 36281 36282 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/block-editor/site-editor-canvas.js 36283 36284 /** 36285 * External dependencies 36286 */ 36287 36288 /** 36289 * WordPress dependencies 36290 */ 36291 36292 36293 36294 /** 36295 * Internal dependencies 36296 */ 36297 36298 36299 36300 36301 36302 36303 36304 36305 const { 36306 useLocation: site_editor_canvas_useLocation 36307 } = unlock(external_wp_router_namespaceObject.privateApis); 36308 function SiteEditorCanvas() { 36309 const location = site_editor_canvas_useLocation(); 36310 const { 36311 templateType, 36312 isFocusableEntity, 36313 isViewMode 36314 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 36315 const { 36316 getEditedPostType, 36317 getCanvasMode 36318 } = unlock(select(store_store)); 36319 const _templateType = getEditedPostType(); 36320 return { 36321 templateType: _templateType, 36322 isFocusableEntity: FOCUSABLE_ENTITIES.includes(_templateType), 36323 isViewMode: getCanvasMode() === 'view' 36324 }; 36325 }, []); 36326 const isFocusMode = location.params.focusMode || isFocusableEntity; 36327 const [resizeObserver, sizes] = (0,external_wp_compose_namespaceObject.useResizeObserver)(); 36328 const settings = useSiteEditorSettings(); 36329 const isMobileViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('small', '<'); 36330 const enableResizing = isFocusMode && !isViewMode && 36331 // Disable resizing in mobile viewport. 36332 !isMobileViewport && 36333 // Disable resizing when editing a template in focus mode. 36334 templateType !== constants_TEMPLATE_POST_TYPE; 36335 const isTemplateTypeNavigation = templateType === NAVIGATION_POST_TYPE; 36336 const isNavigationFocusMode = isTemplateTypeNavigation && isFocusMode; 36337 const forceFullHeight = isNavigationFocusMode; 36338 return (0,external_React_.createElement)(editor_canvas_container.Slot, null, ([editorCanvasView]) => editorCanvasView ? (0,external_React_.createElement)("div", { 36339 className: "edit-site-visual-editor is-focus-mode" 36340 }, editorCanvasView) : (0,external_React_.createElement)("div", { 36341 className: classnames_default()('edit-site-visual-editor', { 36342 'is-focus-mode': isFocusMode || !!editorCanvasView, 36343 'is-view-mode': isViewMode 36344 }) 36345 }, (0,external_React_.createElement)(resizable_editor, { 36346 enableResizing: enableResizing, 36347 height: sizes.height && !forceFullHeight ? sizes.height : '100%' 36348 }, (0,external_React_.createElement)(editor_canvas, { 36349 enableResizing: enableResizing, 36350 settings: settings 36351 }, resizeObserver)))); 36352 } 36353 36354 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/template-part-converter/convert-to-regular.js 36355 36356 /** 36357 * WordPress dependencies 36358 */ 36359 36360 36361 36362 36363 function ConvertToRegularBlocks({ 36364 clientId, 36365 onClose 36366 }) { 36367 const { 36368 getBlocks 36369 } = (0,external_wp_data_namespaceObject.useSelect)(external_wp_blockEditor_namespaceObject.store); 36370 const { 36371 replaceBlocks 36372 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store); 36373 const canRemove = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_blockEditor_namespaceObject.store).canRemoveBlock(clientId), [clientId]); 36374 if (!canRemove) { 36375 return null; 36376 } 36377 return (0,external_React_.createElement)(external_wp_components_namespaceObject.MenuItem, { 36378 onClick: () => { 36379 replaceBlocks(clientId, getBlocks(clientId)); 36380 onClose(); 36381 } 36382 }, (0,external_wp_i18n_namespaceObject.__)('Detach')); 36383 } 36384 36385 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/template-part-converter/convert-to-template-part.js 36386 36387 /** 36388 * WordPress dependencies 36389 */ 36390 36391 36392 36393 36394 36395 36396 36397 36398 36399 /** 36400 * Internal dependencies 36401 */ 36402 36403 36404 function ConvertToTemplatePart({ 36405 clientIds, 36406 blocks 36407 }) { 36408 const [isModalOpen, setIsModalOpen] = (0,external_wp_element_namespaceObject.useState)(false); 36409 const { 36410 replaceBlocks 36411 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store); 36412 const { 36413 createSuccessNotice 36414 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store); 36415 const { 36416 canCreate 36417 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 36418 const { 36419 supportsTemplatePartsMode 36420 } = select(store_store).getSettings(); 36421 return { 36422 canCreate: !supportsTemplatePartsMode 36423 }; 36424 }, []); 36425 if (!canCreate) { 36426 return null; 36427 } 36428 const onConvert = async templatePart => { 36429 replaceBlocks(clientIds, (0,external_wp_blocks_namespaceObject.createBlock)('core/template-part', { 36430 slug: templatePart.slug, 36431 theme: templatePart.theme 36432 })); 36433 createSuccessNotice((0,external_wp_i18n_namespaceObject.__)('Template part created.'), { 36434 type: 'snackbar' 36435 }); 36436 36437 // The modal and this component will be unmounted because of `replaceBlocks` above, 36438 // so no need to call `closeModal` or `onClose`. 36439 }; 36440 return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.MenuItem, { 36441 icon: symbol_filled, 36442 onClick: () => { 36443 setIsModalOpen(true); 36444 }, 36445 "aria-expanded": isModalOpen, 36446 "aria-haspopup": "dialog" 36447 }, (0,external_wp_i18n_namespaceObject.__)('Create template part')), isModalOpen && (0,external_React_.createElement)(CreateTemplatePartModal, { 36448 closeModal: () => { 36449 setIsModalOpen(false); 36450 }, 36451 blocks: blocks, 36452 onCreate: onConvert 36453 })); 36454 } 36455 36456 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/template-part-converter/index.js 36457 36458 /** 36459 * WordPress dependencies 36460 */ 36461 36462 36463 36464 /** 36465 * Internal dependencies 36466 */ 36467 36468 36469 function TemplatePartConverter() { 36470 return (0,external_React_.createElement)(external_wp_blockEditor_namespaceObject.BlockSettingsMenuControls, null, ({ 36471 selectedClientIds, 36472 onClose 36473 }) => (0,external_React_.createElement)(TemplatePartConverterMenuItem, { 36474 clientIds: selectedClientIds, 36475 onClose: onClose 36476 })); 36477 } 36478 function TemplatePartConverterMenuItem({ 36479 clientIds, 36480 onClose 36481 }) { 36482 const blocks = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_blockEditor_namespaceObject.store).getBlocksByClientId(clientIds), [clientIds]); 36483 36484 // Allow converting a single template part to standard blocks. 36485 if (blocks.length === 1 && blocks[0]?.name === 'core/template-part') { 36486 return (0,external_React_.createElement)(ConvertToRegularBlocks, { 36487 clientId: clientIds[0], 36488 onClose: onClose 36489 }); 36490 } 36491 return (0,external_React_.createElement)(ConvertToTemplatePart, { 36492 clientIds: clientIds, 36493 blocks: blocks 36494 }); 36495 } 36496 36497 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/editor/index.js 36498 36499 /** 36500 * External dependencies 36501 */ 36502 36503 36504 /** 36505 * WordPress dependencies 36506 */ 36507 36508 36509 36510 36511 36512 36513 36514 36515 36516 36517 /** 36518 * Internal dependencies 36519 */ 36520 36521 36522 36523 36524 36525 36526 36527 36528 36529 36530 36531 36532 36533 36534 36535 36536 const { 36537 BlockRemovalWarningModal 36538 } = unlock(external_wp_blockEditor_namespaceObject.privateApis); 36539 const { 36540 ExperimentalEditorProvider: EditorProvider, 36541 InserterSidebar, 36542 ListViewSidebar 36543 } = unlock(external_wp_editor_namespaceObject.privateApis); 36544 const interfaceLabels = { 36545 /* translators: accessibility text for the editor content landmark region. */ 36546 body: (0,external_wp_i18n_namespaceObject.__)('Editor content'), 36547 /* translators: accessibility text for the editor settings landmark region. */ 36548 sidebar: (0,external_wp_i18n_namespaceObject.__)('Editor settings'), 36549 /* translators: accessibility text for the editor publish landmark region. */ 36550 actions: (0,external_wp_i18n_namespaceObject.__)('Editor publish'), 36551 /* translators: accessibility text for the editor footer landmark region. */ 36552 footer: (0,external_wp_i18n_namespaceObject.__)('Editor footer') 36553 }; 36554 36555 // Prevent accidental removal of certain blocks, asking the user for 36556 // confirmation. 36557 const blockRemovalRules = { 36558 'core/query': (0,external_wp_i18n_namespaceObject.__)('Query Loop displays a list of posts or pages.'), 36559 'core/post-content': (0,external_wp_i18n_namespaceObject.__)('Post Content displays the content of a post or page.'), 36560 'core/post-template': (0,external_wp_i18n_namespaceObject.__)('Post Template displays each post or page in a Query Loop.'), 36561 'bindings/core/pattern-overrides': (0,external_wp_i18n_namespaceObject.__)('Blocks from synced patterns that can have overriden content.') 36562 }; 36563 function Editor({ 36564 isLoading 36565 }) { 36566 const { 36567 record: editedPost, 36568 getTitle, 36569 isLoaded: hasLoadedPost 36570 } = useEditedEntityRecord(); 36571 const { 36572 type: editedPostType 36573 } = editedPost; 36574 const isLargeViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium'); 36575 const { 36576 context, 36577 contextPost, 36578 editorMode, 36579 canvasMode, 36580 blockEditorMode, 36581 isRightSidebarOpen, 36582 isInserterOpen, 36583 isListViewOpen, 36584 isDistractionFree, 36585 showIconLabels, 36586 showBlockBreadcrumbs, 36587 postTypeLabel 36588 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 36589 const { 36590 get 36591 } = select(external_wp_preferences_namespaceObject.store); 36592 const { 36593 getEditedPostContext, 36594 getEditorMode, 36595 getCanvasMode 36596 } = unlock(select(store_store)); 36597 const { 36598 __unstableGetEditorMode 36599 } = select(external_wp_blockEditor_namespaceObject.store); 36600 const { 36601 getActiveComplementaryArea 36602 } = select(store); 36603 const { 36604 getEntityRecord 36605 } = select(external_wp_coreData_namespaceObject.store); 36606 const { 36607 isInserterOpened, 36608 isListViewOpened, 36609 getPostTypeLabel 36610 } = select(external_wp_editor_namespaceObject.store); 36611 const _context = getEditedPostContext(); 36612 36613 // The currently selected entity to display. 36614 // Typically template or template part in the site editor. 36615 return { 36616 context: _context, 36617 contextPost: _context?.postId ? getEntityRecord('postType', _context.postType, _context.postId) : undefined, 36618 editorMode: getEditorMode(), 36619 canvasMode: getCanvasMode(), 36620 blockEditorMode: __unstableGetEditorMode(), 36621 isInserterOpen: isInserterOpened(), 36622 isListViewOpen: isListViewOpened(), 36623 isRightSidebarOpen: getActiveComplementaryArea(store_store.name), 36624 isDistractionFree: get('core', 'distractionFree'), 36625 showBlockBreadcrumbs: get('core', 'showBlockBreadcrumbs'), 36626 showIconLabels: get('core', 'showIconLabels'), 36627 postTypeLabel: getPostTypeLabel() 36628 }; 36629 }, []); 36630 const isViewMode = canvasMode === 'view'; 36631 const isEditMode = canvasMode === 'edit'; 36632 const showVisualEditor = isViewMode || editorMode === 'visual'; 36633 const shouldShowBlockBreadcrumbs = !isDistractionFree && showBlockBreadcrumbs && isEditMode && showVisualEditor && blockEditorMode !== 'zoom-out'; 36634 const shouldShowInserter = isEditMode && showVisualEditor && isInserterOpen; 36635 const shouldShowListView = isEditMode && showVisualEditor && isListViewOpen; 36636 const secondarySidebarLabel = isListViewOpen ? (0,external_wp_i18n_namespaceObject.__)('List View') : (0,external_wp_i18n_namespaceObject.__)('Block Library'); 36637 const postWithTemplate = !!context?.postId; 36638 let title; 36639 if (hasLoadedPost) { 36640 var _POST_TYPE_LABELS$edi; 36641 title = (0,external_wp_i18n_namespaceObject.sprintf)( 36642 // translators: A breadcrumb trail for the Admin document title. %1$s: title of template being edited, %2$s: type of template (Template or Template Part). 36643 (0,external_wp_i18n_namespaceObject.__)('%1$s ‹ %2$s'), getTitle(), (_POST_TYPE_LABELS$edi = POST_TYPE_LABELS[editedPostType]) !== null && _POST_TYPE_LABELS$edi !== void 0 ? _POST_TYPE_LABELS$edi : POST_TYPE_LABELS[constants_TEMPLATE_POST_TYPE]); 36644 } 36645 36646 // Only announce the title once the editor is ready to prevent "Replace" 36647 // action in <URLQueryController> from double-announcing. 36648 useTitle(hasLoadedPost && title); 36649 const loadingProgressId = (0,external_wp_compose_namespaceObject.useInstanceId)(CanvasLoader, 'edit-site-editor__loading-progress'); 36650 const settings = useSpecificEditorSettings(); 36651 const isReady = !isLoading && (postWithTemplate && !!contextPost && !!editedPost || !postWithTemplate && !!editedPost); 36652 return (0,external_React_.createElement)(external_React_.Fragment, null, !isReady ? (0,external_React_.createElement)(CanvasLoader, { 36653 id: loadingProgressId 36654 }) : null, isEditMode && (0,external_React_.createElement)(WelcomeGuide, null), hasLoadedPost && !editedPost && (0,external_React_.createElement)(external_wp_components_namespaceObject.Notice, { 36655 status: "warning", 36656 isDismissible: false 36657 }, (0,external_wp_i18n_namespaceObject.__)("You attempted to edit an item that doesn't exist. Perhaps it was deleted?")), isReady && (0,external_React_.createElement)(EditorProvider, { 36658 post: postWithTemplate ? contextPost : editedPost, 36659 __unstableTemplate: postWithTemplate ? editedPost : undefined, 36660 settings: settings, 36661 useSubRegistry: false 36662 }, (0,external_React_.createElement)(SidebarComplementaryAreaFills, null), isEditMode && (0,external_React_.createElement)(StartTemplateOptions, null), (0,external_React_.createElement)(interface_skeleton, { 36663 isDistractionFree: isDistractionFree, 36664 enableRegionNavigation: false, 36665 className: classnames_default()('edit-site-editor__interface-skeleton', { 36666 'show-icon-labels': showIconLabels 36667 }), 36668 notices: (0,external_React_.createElement)(external_wp_editor_namespaceObject.EditorSnackbars, null), 36669 content: (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(GlobalStylesRenderer, null), isEditMode && (0,external_React_.createElement)(external_wp_editor_namespaceObject.EditorNotices, null), showVisualEditor && (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(TemplatePartConverter, null), (0,external_React_.createElement)(SidebarInspectorFill, null, (0,external_React_.createElement)(external_wp_blockEditor_namespaceObject.BlockInspector, null)), !isLargeViewport && (0,external_React_.createElement)(external_wp_blockEditor_namespaceObject.BlockToolbar, { 36670 hideDragHandle: true 36671 }), (0,external_React_.createElement)(SiteEditorCanvas, null), (0,external_React_.createElement)(BlockRemovalWarningModal, { 36672 rules: blockRemovalRules 36673 }), (0,external_React_.createElement)(PatternModal, null)), editorMode === 'text' && isEditMode && (0,external_React_.createElement)(CodeEditor, null), isEditMode && (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(edit_mode, null), (0,external_React_.createElement)(external_wp_editor_namespaceObject.EditorKeyboardShortcutsRegister, null), (0,external_React_.createElement)(external_wp_editor_namespaceObject.EditorKeyboardShortcuts, null))), 36674 secondarySidebar: isEditMode && (shouldShowInserter && (0,external_React_.createElement)(InserterSidebar, null) || shouldShowListView && (0,external_React_.createElement)(ListViewSidebar, null)), 36675 sidebar: !isDistractionFree && isEditMode && isRightSidebarOpen && (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(complementary_area.Slot, { 36676 scope: "core/edit-site" 36677 })), 36678 footer: shouldShowBlockBreadcrumbs && (0,external_React_.createElement)(external_wp_blockEditor_namespaceObject.BlockBreadcrumb, { 36679 rootLabelText: postTypeLabel 36680 }), 36681 labels: { 36682 ...interfaceLabels, 36683 secondarySidebar: secondarySidebarLabel 36684 } 36685 }))); 36686 } 36687 36688 ;// CONCATENATED MODULE: ./node_modules/@wordpress/dataviews/build-module/pagination.js 36689 36690 /** 36691 * WordPress dependencies 36692 */ 36693 36694 36695 36696 36697 const pagination_Pagination = (0,external_wp_element_namespaceObject.memo)(function Pagination({ 36698 view, 36699 onChangeView, 36700 paginationInfo: { 36701 totalItems = 0, 36702 totalPages 36703 } 36704 }) { 36705 if (!totalItems || !totalPages) { 36706 return null; 36707 } 36708 return !!totalItems && totalPages !== 1 && (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { 36709 expanded: false, 36710 spacing: 6, 36711 justify: "end", 36712 className: "dataviews-pagination" 36713 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { 36714 justify: "flex-start", 36715 expanded: false, 36716 spacing: 2, 36717 className: "dataviews-pagination__page-selection" 36718 }, (0,external_wp_element_namespaceObject.createInterpolateElement)((0,external_wp_i18n_namespaceObject.sprintf)( 36719 // translators: %s: Total number of pages. 36720 (0,external_wp_i18n_namespaceObject._x)('Page <CurrentPageControl /> of %s', 'paging'), totalPages), { 36721 CurrentPageControl: (0,external_React_.createElement)(external_wp_components_namespaceObject.SelectControl, { 36722 "aria-label": (0,external_wp_i18n_namespaceObject.__)('Current page'), 36723 value: view.page, 36724 options: Array.from(Array(totalPages)).map((_, i) => { 36725 const page = i + 1; 36726 return { 36727 value: page, 36728 label: page 36729 }; 36730 }), 36731 onChange: newValue => { 36732 onChangeView({ 36733 ...view, 36734 page: +newValue 36735 }); 36736 }, 36737 size: 'compact', 36738 __nextHasNoMarginBottom: true 36739 }) 36740 })), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { 36741 expanded: false, 36742 spacing: 1 36743 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 36744 onClick: () => onChangeView({ 36745 ...view, 36746 page: view.page - 1 36747 }), 36748 disabled: view.page === 1, 36749 __experimentalIsFocusable: true, 36750 label: (0,external_wp_i18n_namespaceObject.__)('Previous page'), 36751 icon: chevron_left, 36752 showTooltip: true, 36753 size: "compact", 36754 tooltipPosition: "top" 36755 }), (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 36756 onClick: () => onChangeView({ 36757 ...view, 36758 page: view.page + 1 36759 }), 36760 disabled: view.page >= totalPages, 36761 __experimentalIsFocusable: true, 36762 label: (0,external_wp_i18n_namespaceObject.__)('Next page'), 36763 icon: chevron_right, 36764 showTooltip: true, 36765 size: "compact", 36766 tooltipPosition: "top" 36767 }))); 36768 }); 36769 /* harmony default export */ const pagination = (pagination_Pagination); 36770 36771 ;// CONCATENATED MODULE: ./node_modules/@wordpress/dataviews/build-module/view-actions.js 36772 36773 /** 36774 * WordPress dependencies 36775 */ 36776 36777 36778 36779 36780 36781 /** 36782 * Internal dependencies 36783 */ 36784 36785 36786 const { 36787 DropdownMenuV2: view_actions_DropdownMenu, 36788 DropdownMenuGroupV2: view_actions_DropdownMenuGroup, 36789 DropdownMenuItemV2: view_actions_DropdownMenuItem, 36790 DropdownMenuRadioItemV2: view_actions_DropdownMenuRadioItem, 36791 DropdownMenuCheckboxItemV2: DropdownMenuCheckboxItem, 36792 DropdownMenuItemLabelV2: view_actions_DropdownMenuItemLabel 36793 } = lock_unlock_unlock(external_wp_components_namespaceObject.privateApis); 36794 function ViewTypeMenu({ 36795 view, 36796 onChangeView, 36797 supportedLayouts 36798 }) { 36799 let _availableViews = VIEW_LAYOUTS; 36800 if (supportedLayouts) { 36801 _availableViews = _availableViews.filter(_view => supportedLayouts.includes(_view.type)); 36802 } 36803 if (_availableViews.length === 1) { 36804 return null; 36805 } 36806 const activeView = _availableViews.find(v => view.type === v.type); 36807 return (0,external_React_.createElement)(view_actions_DropdownMenu, { 36808 trigger: (0,external_React_.createElement)(view_actions_DropdownMenuItem, { 36809 suffix: (0,external_React_.createElement)("span", { 36810 "aria-hidden": "true" 36811 }, activeView.label) 36812 }, (0,external_React_.createElement)(view_actions_DropdownMenuItemLabel, null, (0,external_wp_i18n_namespaceObject.__)('Layout'))) 36813 }, _availableViews.map(availableView => { 36814 return (0,external_React_.createElement)(view_actions_DropdownMenuRadioItem, { 36815 key: availableView.type, 36816 value: availableView.type, 36817 name: "view-actions-available-view", 36818 checked: availableView.type === view.type, 36819 hideOnClick: true, 36820 onChange: e => { 36821 onChangeView({ 36822 ...view, 36823 type: e.target.value 36824 }); 36825 } 36826 }, (0,external_React_.createElement)(view_actions_DropdownMenuItemLabel, null, availableView.label)); 36827 })); 36828 } 36829 const PAGE_SIZE_VALUES = [10, 20, 50, 100]; 36830 function PageSizeMenu({ 36831 view, 36832 onChangeView 36833 }) { 36834 return (0,external_React_.createElement)(view_actions_DropdownMenu, { 36835 trigger: (0,external_React_.createElement)(view_actions_DropdownMenuItem, { 36836 suffix: (0,external_React_.createElement)("span", { 36837 "aria-hidden": "true" 36838 }, view.perPage) 36839 }, (0,external_React_.createElement)(view_actions_DropdownMenuItemLabel, null, (0,external_wp_i18n_namespaceObject.__)('Items per page'))) 36840 }, PAGE_SIZE_VALUES.map(size => { 36841 return (0,external_React_.createElement)(view_actions_DropdownMenuRadioItem, { 36842 key: size, 36843 value: size, 36844 name: "view-actions-page-size", 36845 checked: view.perPage === size, 36846 onChange: () => { 36847 onChangeView({ 36848 ...view, 36849 // `e.target.value` holds the same value as `size` but as a string, 36850 // so we use `size` directly to avoid parsing to int. 36851 perPage: size, 36852 page: 1 36853 }); 36854 } 36855 }, (0,external_React_.createElement)(view_actions_DropdownMenuItemLabel, null, size)); 36856 })); 36857 } 36858 function FieldsVisibilityMenu({ 36859 view, 36860 onChangeView, 36861 fields 36862 }) { 36863 const hidableFields = fields.filter(field => field.enableHiding !== false && field.id !== view.layout.mediaField); 36864 if (!hidableFields?.length) { 36865 return null; 36866 } 36867 return (0,external_React_.createElement)(view_actions_DropdownMenu, { 36868 trigger: (0,external_React_.createElement)(view_actions_DropdownMenuItem, null, (0,external_React_.createElement)(view_actions_DropdownMenuItemLabel, null, (0,external_wp_i18n_namespaceObject.__)('Fields'))) 36869 }, hidableFields?.map(field => { 36870 return (0,external_React_.createElement)(DropdownMenuCheckboxItem, { 36871 key: field.id, 36872 value: field.id, 36873 checked: !view.hiddenFields?.includes(field.id), 36874 onChange: () => { 36875 onChangeView({ 36876 ...view, 36877 hiddenFields: view.hiddenFields?.includes(field.id) ? view.hiddenFields.filter(id => id !== field.id) : [...(view.hiddenFields || []), field.id] 36878 }); 36879 } 36880 }, (0,external_React_.createElement)(view_actions_DropdownMenuItemLabel, null, field.header)); 36881 })); 36882 } 36883 function SortMenu({ 36884 fields, 36885 view, 36886 onChangeView 36887 }) { 36888 const sortableFields = fields.filter(field => field.enableSorting !== false); 36889 if (!sortableFields?.length) { 36890 return null; 36891 } 36892 const currentSortedField = fields.find(field => field.id === view.sort?.field); 36893 return (0,external_React_.createElement)(view_actions_DropdownMenu, { 36894 trigger: (0,external_React_.createElement)(view_actions_DropdownMenuItem, { 36895 suffix: (0,external_React_.createElement)("span", { 36896 "aria-hidden": "true" 36897 }, currentSortedField?.header) 36898 }, (0,external_React_.createElement)(view_actions_DropdownMenuItemLabel, null, (0,external_wp_i18n_namespaceObject.__)('Sort by'))) 36899 }, sortableFields?.map(field => { 36900 const sortedDirection = view.sort?.direction; 36901 return (0,external_React_.createElement)(view_actions_DropdownMenu, { 36902 key: field.id, 36903 trigger: (0,external_React_.createElement)(view_actions_DropdownMenuItem, null, (0,external_React_.createElement)(view_actions_DropdownMenuItemLabel, null, field.header)), 36904 style: { 36905 minWidth: '220px' 36906 } 36907 }, Object.entries(SORTING_DIRECTIONS).map(([direction, info]) => { 36908 const isChecked = currentSortedField !== undefined && sortedDirection === direction && field.id === currentSortedField.id; 36909 const value = `$field.id}-$direction}`; 36910 return (0,external_React_.createElement)(view_actions_DropdownMenuRadioItem, { 36911 key: value 36912 // All sorting radio items share the same name, so that 36913 // selecting a sorting option automatically deselects the 36914 // previously selected one, even if it is displayed in 36915 // another submenu. The field and direction are passed via 36916 // the `value` prop. 36917 , 36918 name: "view-actions-sorting", 36919 value: value, 36920 checked: isChecked, 36921 onChange: () => { 36922 onChangeView({ 36923 ...view, 36924 sort: { 36925 field: field.id, 36926 direction 36927 } 36928 }); 36929 } 36930 }, (0,external_React_.createElement)(view_actions_DropdownMenuItemLabel, null, info.label)); 36931 })); 36932 })); 36933 } 36934 const ViewActions = (0,external_wp_element_namespaceObject.memo)(function ViewActions({ 36935 fields, 36936 view, 36937 onChangeView, 36938 supportedLayouts 36939 }) { 36940 return (0,external_React_.createElement)(view_actions_DropdownMenu, { 36941 trigger: (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 36942 size: "compact", 36943 icon: library_settings, 36944 label: (0,external_wp_i18n_namespaceObject.__)('View options') 36945 }) 36946 }, (0,external_React_.createElement)(view_actions_DropdownMenuGroup, null, (0,external_React_.createElement)(ViewTypeMenu, { 36947 view: view, 36948 onChangeView: onChangeView, 36949 supportedLayouts: supportedLayouts 36950 }), (0,external_React_.createElement)(SortMenu, { 36951 fields: fields, 36952 view: view, 36953 onChangeView: onChangeView 36954 }), (0,external_React_.createElement)(FieldsVisibilityMenu, { 36955 fields: fields, 36956 view: view, 36957 onChangeView: onChangeView 36958 }), (0,external_React_.createElement)(PageSizeMenu, { 36959 view: view, 36960 onChangeView: onChangeView 36961 }))); 36962 }); 36963 /* harmony default export */ const view_actions = (ViewActions); 36964 36965 ;// CONCATENATED MODULE: ./node_modules/@ariakit/react-core/esm/__chunks/4R3V3JGP.js 36966 "use client"; 36967 var __defProp = Object.defineProperty; 36968 var __defProps = Object.defineProperties; 36969 var __getOwnPropDescs = Object.getOwnPropertyDescriptors; 36970 var __getOwnPropSymbols = Object.getOwnPropertySymbols; 36971 var __hasOwnProp = Object.prototype.hasOwnProperty; 36972 var __propIsEnum = Object.prototype.propertyIsEnumerable; 36973 var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; 36974 var _4R3V3JGP_spreadValues = (a, b) => { 36975 for (var prop in b || (b = {})) 36976 if (__hasOwnProp.call(b, prop)) 36977 __defNormalProp(a, prop, b[prop]); 36978 if (__getOwnPropSymbols) 36979 for (var prop of __getOwnPropSymbols(b)) { 36980 if (__propIsEnum.call(b, prop)) 36981 __defNormalProp(a, prop, b[prop]); 36982 } 36983 return a; 36984 }; 36985 var _4R3V3JGP_spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b)); 36986 var __objRest = (source, exclude) => { 36987 var target = {}; 36988 for (var prop in source) 36989 if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0) 36990 target[prop] = source[prop]; 36991 if (source != null && __getOwnPropSymbols) 36992 for (var prop of __getOwnPropSymbols(source)) { 36993 if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop)) 36994 target[prop] = source[prop]; 36995 } 36996 return target; 36997 }; 36998 36999 37000 37001 ;// CONCATENATED MODULE: ./node_modules/@ariakit/core/esm/__chunks/4R3V3JGP.js 37002 "use client"; 37003 var _4R3V3JGP_defProp = Object.defineProperty; 37004 var _4R3V3JGP_defProps = Object.defineProperties; 37005 var _4R3V3JGP_getOwnPropDescs = Object.getOwnPropertyDescriptors; 37006 var _4R3V3JGP_getOwnPropSymbols = Object.getOwnPropertySymbols; 37007 var _4R3V3JGP_hasOwnProp = Object.prototype.hasOwnProperty; 37008 var _4R3V3JGP_propIsEnum = Object.prototype.propertyIsEnumerable; 37009 var _4R3V3JGP_defNormalProp = (obj, key, value) => key in obj ? _4R3V3JGP_defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; 37010 var _chunks_4R3V3JGP_spreadValues = (a, b) => { 37011 for (var prop in b || (b = {})) 37012 if (_4R3V3JGP_hasOwnProp.call(b, prop)) 37013 _4R3V3JGP_defNormalProp(a, prop, b[prop]); 37014 if (_4R3V3JGP_getOwnPropSymbols) 37015 for (var prop of _4R3V3JGP_getOwnPropSymbols(b)) { 37016 if (_4R3V3JGP_propIsEnum.call(b, prop)) 37017 _4R3V3JGP_defNormalProp(a, prop, b[prop]); 37018 } 37019 return a; 37020 }; 37021 var _chunks_4R3V3JGP_spreadProps = (a, b) => _4R3V3JGP_defProps(a, _4R3V3JGP_getOwnPropDescs(b)); 37022 var _4R3V3JGP_objRest = (source, exclude) => { 37023 var target = {}; 37024 for (var prop in source) 37025 if (_4R3V3JGP_hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0) 37026 target[prop] = source[prop]; 37027 if (source != null && _4R3V3JGP_getOwnPropSymbols) 37028 for (var prop of _4R3V3JGP_getOwnPropSymbols(source)) { 37029 if (exclude.indexOf(prop) < 0 && _4R3V3JGP_propIsEnum.call(source, prop)) 37030 target[prop] = source[prop]; 37031 } 37032 return target; 37033 }; 37034 37035 37036 37037 ;// CONCATENATED MODULE: ./node_modules/@ariakit/core/esm/__chunks/Y3OOHFCN.js 37038 "use client"; 37039 37040 37041 // src/utils/misc.ts 37042 function Y3OOHFCN_noop(..._) { 37043 } 37044 function shallowEqual(a, b) { 37045 if (a === b) 37046 return true; 37047 if (!a) 37048 return false; 37049 if (!b) 37050 return false; 37051 if (typeof a !== "object") 37052 return false; 37053 if (typeof b !== "object") 37054 return false; 37055 const aKeys = Object.keys(a); 37056 const bKeys = Object.keys(b); 37057 const { length } = aKeys; 37058 if (bKeys.length !== length) 37059 return false; 37060 for (const key of aKeys) { 37061 if (a[key] !== b[key]) { 37062 return false; 37063 } 37064 } 37065 return true; 37066 } 37067 function Y3OOHFCN_applyState(argument, currentValue) { 37068 if (isUpdater(argument)) { 37069 const value = isLazyValue(currentValue) ? currentValue() : currentValue; 37070 return argument(value); 37071 } 37072 return argument; 37073 } 37074 function isUpdater(argument) { 37075 return typeof argument === "function"; 37076 } 37077 function isLazyValue(value) { 37078 return typeof value === "function"; 37079 } 37080 function Y3OOHFCN_isObject(arg) { 37081 return typeof arg === "object" && arg != null; 37082 } 37083 function isEmpty(arg) { 37084 if (Array.isArray(arg)) 37085 return !arg.length; 37086 if (Y3OOHFCN_isObject(arg)) 37087 return !Object.keys(arg).length; 37088 if (arg == null) 37089 return true; 37090 if (arg === "") 37091 return true; 37092 return false; 37093 } 37094 function isInteger(arg) { 37095 if (typeof arg === "number") { 37096 return Math.floor(arg) === arg; 37097 } 37098 return String(Math.floor(Number(arg))) === arg; 37099 } 37100 function Y3OOHFCN_hasOwnProperty(object, prop) { 37101 if (typeof Object.hasOwn === "function") { 37102 return Object.hasOwn(object, prop); 37103 } 37104 return Object.prototype.hasOwnProperty.call(object, prop); 37105 } 37106 function chain(...fns) { 37107 return (...args) => { 37108 for (const fn of fns) { 37109 if (typeof fn === "function") { 37110 fn(...args); 37111 } 37112 } 37113 }; 37114 } 37115 function cx(...args) { 37116 return args.filter(Boolean).join(" ") || void 0; 37117 } 37118 function normalizeString(str) { 37119 return str.normalize("NFD").replace(/[\u0300-\u036f]/g, ""); 37120 } 37121 function omit(object, keys) { 37122 const result = _chunks_4R3V3JGP_spreadValues({}, object); 37123 for (const key of keys) { 37124 if (Y3OOHFCN_hasOwnProperty(result, key)) { 37125 delete result[key]; 37126 } 37127 } 37128 return result; 37129 } 37130 function pick(object, paths) { 37131 const result = {}; 37132 for (const key of paths) { 37133 if (Y3OOHFCN_hasOwnProperty(object, key)) { 37134 result[key] = object[key]; 37135 } 37136 } 37137 return result; 37138 } 37139 function identity(value) { 37140 return value; 37141 } 37142 function beforePaint(cb = Y3OOHFCN_noop) { 37143 const raf = requestAnimationFrame(cb); 37144 return () => cancelAnimationFrame(raf); 37145 } 37146 function afterPaint(cb = Y3OOHFCN_noop) { 37147 let raf = requestAnimationFrame(() => { 37148 raf = requestAnimationFrame(cb); 37149 }); 37150 return () => cancelAnimationFrame(raf); 37151 } 37152 function invariant(condition, message) { 37153 if (condition) 37154 return; 37155 if (typeof message !== "string") 37156 throw new Error("Invariant failed"); 37157 throw new Error(message); 37158 } 37159 function getKeys(obj) { 37160 return Object.keys(obj); 37161 } 37162 function isFalsyBooleanCallback(booleanOrCallback, ...args) { 37163 const result = typeof booleanOrCallback === "function" ? booleanOrCallback(...args) : booleanOrCallback; 37164 if (result == null) 37165 return false; 37166 return !result; 37167 } 37168 function disabledFromProps(props) { 37169 return props.disabled || props["aria-disabled"] === true || props["aria-disabled"] === "true"; 37170 } 37171 function defaultValue(...values) { 37172 for (const value of values) { 37173 if (value !== void 0) 37174 return value; 37175 } 37176 return void 0; 37177 } 37178 37179 37180 37181 ;// CONCATENATED MODULE: ./node_modules/@ariakit/react-core/esm/__chunks/XM66DUTO.js 37182 "use client"; 37183 37184 37185 // src/utils/misc.ts 37186 37187 37188 function setRef(ref, value) { 37189 if (typeof ref === "function") { 37190 ref(value); 37191 } else if (ref) { 37192 ref.current = value; 37193 } 37194 } 37195 function isValidElementWithRef(element) { 37196 if (!element) 37197 return false; 37198 if (!(0,external_React_.isValidElement)(element)) 37199 return false; 37200 if (!("ref" in element)) 37201 return false; 37202 return true; 37203 } 37204 function getRefProperty(element) { 37205 if (!isValidElementWithRef(element)) 37206 return null; 37207 return element.ref; 37208 } 37209 function mergeProps(base, overrides) { 37210 const props = _4R3V3JGP_spreadValues({}, base); 37211 for (const key in overrides) { 37212 if (!Y3OOHFCN_hasOwnProperty(overrides, key)) 37213 continue; 37214 if (key === "className") { 37215 const prop = "className"; 37216 props[prop] = base[prop] ? `$base[prop]} $overrides[prop]}` : overrides[prop]; 37217 continue; 37218 } 37219 if (key === "style") { 37220 const prop = "style"; 37221 props[prop] = base[prop] ? _4R3V3JGP_spreadValues(_4R3V3JGP_spreadValues({}, base[prop]), overrides[prop]) : overrides[prop]; 37222 continue; 37223 } 37224 const overrideValue = overrides[key]; 37225 if (typeof overrideValue === "function" && key.startsWith("on")) { 37226 const baseValue = base[key]; 37227 if (typeof baseValue === "function") { 37228 props[key] = (...args) => { 37229 overrideValue(...args); 37230 baseValue(...args); 37231 }; 37232 continue; 37233 } 37234 } 37235 props[key] = overrideValue; 37236 } 37237 return props; 37238 } 37239 37240 37241 37242 ;// CONCATENATED MODULE: ./node_modules/@ariakit/core/esm/__chunks/DLOEKDPY.js 37243 "use client"; 37244 37245 // src/utils/dom.ts 37246 var DLOEKDPY_canUseDOM = checkIsBrowser(); 37247 function checkIsBrowser() { 37248 var _a; 37249 return typeof window !== "undefined" && !!((_a = window.document) == null ? void 0 : _a.createElement); 37250 } 37251 function DLOEKDPY_getDocument(node) { 37252 return node ? node.ownerDocument || node : document; 37253 } 37254 function getWindow(node) { 37255 return DLOEKDPY_getDocument(node).defaultView || window; 37256 } 37257 function DLOEKDPY_getActiveElement(node, activeDescendant = false) { 37258 const { activeElement } = DLOEKDPY_getDocument(node); 37259 if (!(activeElement == null ? void 0 : activeElement.nodeName)) { 37260 return null; 37261 } 37262 if (DLOEKDPY_isFrame(activeElement) && activeElement.contentDocument) { 37263 return DLOEKDPY_getActiveElement( 37264 activeElement.contentDocument.body, 37265 activeDescendant 37266 ); 37267 } 37268 if (activeDescendant) { 37269 const id = activeElement.getAttribute("aria-activedescendant"); 37270 if (id) { 37271 const element = DLOEKDPY_getDocument(activeElement).getElementById(id); 37272 if (element) { 37273 return element; 37274 } 37275 } 37276 } 37277 return activeElement; 37278 } 37279 function contains(parent, child) { 37280 return parent === child || parent.contains(child); 37281 } 37282 function DLOEKDPY_isFrame(element) { 37283 return element.tagName === "IFRAME"; 37284 } 37285 function isButton(element) { 37286 const tagName = element.tagName.toLowerCase(); 37287 if (tagName === "button") 37288 return true; 37289 if (tagName === "input" && element.type) { 37290 return buttonInputTypes.indexOf(element.type) !== -1; 37291 } 37292 return false; 37293 } 37294 var buttonInputTypes = [ 37295 "button", 37296 "color", 37297 "file", 37298 "image", 37299 "reset", 37300 "submit" 37301 ]; 37302 function matches(element, selectors) { 37303 if ("matches" in element) { 37304 return element.matches(selectors); 37305 } 37306 if ("msMatchesSelector" in element) { 37307 return element.msMatchesSelector(selectors); 37308 } 37309 return element.webkitMatchesSelector(selectors); 37310 } 37311 function isVisible(element) { 37312 const htmlElement = element; 37313 return htmlElement.offsetWidth > 0 || htmlElement.offsetHeight > 0 || element.getClientRects().length > 0; 37314 } 37315 function DLOEKDPY_closest(element, selectors) { 37316 if ("closest" in element) 37317 return element.closest(selectors); 37318 do { 37319 if (matches(element, selectors)) 37320 return element; 37321 element = element.parentElement || element.parentNode; 37322 } while (element !== null && element.nodeType === 1); 37323 return null; 37324 } 37325 function DLOEKDPY_isTextField(element) { 37326 try { 37327 const isTextInput = element instanceof HTMLInputElement && element.selectionStart !== null; 37328 const isTextArea = element.tagName === "TEXTAREA"; 37329 return isTextInput || isTextArea || false; 37330 } catch (error) { 37331 return false; 37332 } 37333 } 37334 function getPopupRole(element, fallback) { 37335 const allowedPopupRoles = ["dialog", "menu", "listbox", "tree", "grid"]; 37336 const role = element == null ? void 0 : element.getAttribute("role"); 37337 if (role && allowedPopupRoles.indexOf(role) !== -1) { 37338 return role; 37339 } 37340 return fallback; 37341 } 37342 function getPopupItemRole(element, fallback) { 37343 var _a; 37344 const itemRoleByPopupRole = { 37345 menu: "menuitem", 37346 listbox: "option", 37347 tree: "treeitem", 37348 grid: "gridcell" 37349 }; 37350 const popupRole = getPopupRole(element); 37351 if (!popupRole) 37352 return fallback; 37353 const key = popupRole; 37354 return (_a = itemRoleByPopupRole[key]) != null ? _a : fallback; 37355 } 37356 function getTextboxSelection(element) { 37357 let start = 0; 37358 let end = 0; 37359 if (DLOEKDPY_isTextField(element)) { 37360 start = element.selectionStart || 0; 37361 end = element.selectionEnd || 0; 37362 } else if (element.isContentEditable) { 37363 const selection = DLOEKDPY_getDocument(element).getSelection(); 37364 if ((selection == null ? void 0 : selection.rangeCount) && selection.anchorNode && contains(element, selection.anchorNode) && selection.focusNode && contains(element, selection.focusNode)) { 37365 const range = selection.getRangeAt(0); 37366 const nextRange = range.cloneRange(); 37367 nextRange.selectNodeContents(element); 37368 nextRange.setEnd(range.startContainer, range.startOffset); 37369 start = nextRange.toString().length; 37370 nextRange.setEnd(range.endContainer, range.endOffset); 37371 end = nextRange.toString().length; 37372 } 37373 } 37374 return { start, end }; 37375 } 37376 function scrollIntoViewIfNeeded(element, arg) { 37377 if (isPartiallyHidden(element) && "scrollIntoView" in element) { 37378 element.scrollIntoView(arg); 37379 } 37380 } 37381 function getScrollingElement(element) { 37382 if (!element) 37383 return null; 37384 if (element.clientHeight && element.scrollHeight > element.clientHeight) { 37385 const { overflowY } = getComputedStyle(element); 37386 const isScrollable = overflowY !== "visible" && overflowY !== "hidden"; 37387 if (isScrollable) 37388 return element; 37389 } else if (element.clientWidth && element.scrollWidth > element.clientWidth) { 37390 const { overflowX } = getComputedStyle(element); 37391 const isScrollable = overflowX !== "visible" && overflowX !== "hidden"; 37392 if (isScrollable) 37393 return element; 37394 } 37395 return getScrollingElement(element.parentElement) || document.scrollingElement || document.body; 37396 } 37397 function isPartiallyHidden(element) { 37398 const elementRect = element.getBoundingClientRect(); 37399 const scroller = getScrollingElement(element); 37400 if (!scroller) 37401 return false; 37402 const scrollerRect = scroller.getBoundingClientRect(); 37403 const isHTML = scroller.tagName === "HTML"; 37404 const scrollerTop = isHTML ? scrollerRect.top + scroller.scrollTop : scrollerRect.top; 37405 const scrollerBottom = isHTML ? scroller.clientHeight : scrollerRect.bottom; 37406 const scrollerLeft = isHTML ? scrollerRect.left + scroller.scrollLeft : scrollerRect.left; 37407 const scrollerRight = isHTML ? scroller.clientWidth : scrollerRect.right; 37408 const top = elementRect.top < scrollerTop; 37409 const left = elementRect.left < scrollerLeft; 37410 const bottom = elementRect.bottom > scrollerBottom; 37411 const right = elementRect.right > scrollerRight; 37412 return top || left || bottom || right; 37413 } 37414 function setSelectionRange(element, ...args) { 37415 if (/text|search|password|tel|url/i.test(element.type)) { 37416 element.setSelectionRange(...args); 37417 } 37418 } 37419 37420 37421 37422 ;// CONCATENATED MODULE: ./node_modules/@ariakit/core/esm/__chunks/MHPO2BXA.js 37423 "use client"; 37424 37425 37426 // src/utils/platform.ts 37427 function isTouchDevice() { 37428 return DLOEKDPY_canUseDOM && !!navigator.maxTouchPoints; 37429 } 37430 function isApple() { 37431 if (!DLOEKDPY_canUseDOM) 37432 return false; 37433 return /mac|iphone|ipad|ipod/i.test(navigator.platform); 37434 } 37435 function isSafari() { 37436 return DLOEKDPY_canUseDOM && isApple() && /apple/i.test(navigator.vendor); 37437 } 37438 function isFirefox() { 37439 return DLOEKDPY_canUseDOM && /firefox\//i.test(navigator.userAgent); 37440 } 37441 function isMac() { 37442 return canUseDOM && navigator.platform.startsWith("Mac") && !isTouchDevice(); 37443 } 37444 37445 37446 37447 ;// CONCATENATED MODULE: ./node_modules/@ariakit/core/esm/utils/events.js 37448 "use client"; 37449 37450 37451 37452 37453 // src/utils/events.ts 37454 function isPortalEvent(event) { 37455 return Boolean( 37456 event.currentTarget && !contains(event.currentTarget, event.target) 37457 ); 37458 } 37459 function isSelfTarget(event) { 37460 return event.target === event.currentTarget; 37461 } 37462 function isOpeningInNewTab(event) { 37463 const element = event.currentTarget; 37464 if (!element) 37465 return false; 37466 const isAppleDevice = isApple(); 37467 if (isAppleDevice && !event.metaKey) 37468 return false; 37469 if (!isAppleDevice && !event.ctrlKey) 37470 return false; 37471 const tagName = element.tagName.toLowerCase(); 37472 if (tagName === "a") 37473 return true; 37474 if (tagName === "button" && element.type === "submit") 37475 return true; 37476 if (tagName === "input" && element.type === "submit") 37477 return true; 37478 return false; 37479 } 37480 function isDownloading(event) { 37481 const element = event.currentTarget; 37482 if (!element) 37483 return false; 37484 const tagName = element.tagName.toLowerCase(); 37485 if (!event.altKey) 37486 return false; 37487 if (tagName === "a") 37488 return true; 37489 if (tagName === "button" && element.type === "submit") 37490 return true; 37491 if (tagName === "input" && element.type === "submit") 37492 return true; 37493 return false; 37494 } 37495 function fireEvent(element, type, eventInit) { 37496 const event = new Event(type, eventInit); 37497 return element.dispatchEvent(event); 37498 } 37499 function fireBlurEvent(element, eventInit) { 37500 const event = new FocusEvent("blur", eventInit); 37501 const defaultAllowed = element.dispatchEvent(event); 37502 const bubbleInit = _chunks_4R3V3JGP_spreadProps(_chunks_4R3V3JGP_spreadValues({}, eventInit), { bubbles: true }); 37503 element.dispatchEvent(new FocusEvent("focusout", bubbleInit)); 37504 return defaultAllowed; 37505 } 37506 function fireFocusEvent(element, eventInit) { 37507 const event = new FocusEvent("focus", eventInit); 37508 const defaultAllowed = element.dispatchEvent(event); 37509 const bubbleInit = __spreadProps(__spreadValues({}, eventInit), { bubbles: true }); 37510 element.dispatchEvent(new FocusEvent("focusin", bubbleInit)); 37511 return defaultAllowed; 37512 } 37513 function fireKeyboardEvent(element, type, eventInit) { 37514 const event = new KeyboardEvent(type, eventInit); 37515 return element.dispatchEvent(event); 37516 } 37517 function fireClickEvent(element, eventInit) { 37518 const event = new MouseEvent("click", eventInit); 37519 return element.dispatchEvent(event); 37520 } 37521 function isFocusEventOutside(event, container) { 37522 const containerElement = container || event.currentTarget; 37523 const relatedTarget = event.relatedTarget; 37524 return !relatedTarget || !contains(containerElement, relatedTarget); 37525 } 37526 function queueBeforeEvent(element, type, callback) { 37527 const raf = requestAnimationFrame(() => { 37528 element.removeEventListener(type, callImmediately, true); 37529 callback(); 37530 }); 37531 const callImmediately = () => { 37532 cancelAnimationFrame(raf); 37533 callback(); 37534 }; 37535 element.addEventListener(type, callImmediately, { 37536 once: true, 37537 capture: true 37538 }); 37539 return raf; 37540 } 37541 function addGlobalEventListener(type, listener, options, scope = window) { 37542 const children = []; 37543 try { 37544 scope.document.addEventListener(type, listener, options); 37545 for (const frame of Array.from(scope.frames)) { 37546 children.push(addGlobalEventListener(type, listener, options, frame)); 37547 } 37548 } catch (e) { 37549 } 37550 const removeEventListener = () => { 37551 try { 37552 scope.document.removeEventListener(type, listener, options); 37553 } catch (e) { 37554 } 37555 children.forEach((remove) => remove()); 37556 }; 37557 return removeEventListener; 37558 } 37559 37560 37561 ;// CONCATENATED MODULE: ./node_modules/@ariakit/react-core/esm/__chunks/6O5OEQGF.js 37562 "use client"; 37563 37564 37565 37566 // src/utils/hooks.ts 37567 37568 37569 37570 37571 37572 var _React = _4R3V3JGP_spreadValues({}, external_React_namespaceObject); 37573 var useReactId = _React.useId; 37574 var useReactDeferredValue = _React.useDeferredValue; 37575 var useReactInsertionEffect = _React.useInsertionEffect; 37576 var useSafeLayoutEffect = DLOEKDPY_canUseDOM ? external_React_.useLayoutEffect : external_React_.useEffect; 37577 function useInitialValue(value) { 37578 const [initialValue] = useState(value); 37579 return initialValue; 37580 } 37581 function useLazyValue(init) { 37582 const ref = useRef(); 37583 if (ref.current === void 0) { 37584 ref.current = init(); 37585 } 37586 return ref.current; 37587 } 37588 function useLiveRef(value) { 37589 const ref = (0,external_React_.useRef)(value); 37590 useSafeLayoutEffect(() => { 37591 ref.current = value; 37592 }); 37593 return ref; 37594 } 37595 function usePreviousValue(value) { 37596 const [previousValue, setPreviousValue] = useState(value); 37597 if (value !== previousValue) { 37598 setPreviousValue(value); 37599 } 37600 return previousValue; 37601 } 37602 function useEvent(callback) { 37603 const ref = (0,external_React_.useRef)(() => { 37604 throw new Error("Cannot call an event handler while rendering."); 37605 }); 37606 if (useReactInsertionEffect) { 37607 useReactInsertionEffect(() => { 37608 ref.current = callback; 37609 }); 37610 } else { 37611 ref.current = callback; 37612 } 37613 return (0,external_React_.useCallback)((...args) => { 37614 var _a; 37615 return (_a = ref.current) == null ? void 0 : _a.call(ref, ...args); 37616 }, []); 37617 } 37618 function useMergeRefs(...refs) { 37619 return (0,external_React_.useMemo)(() => { 37620 if (!refs.some(Boolean)) 37621 return; 37622 return (value) => { 37623 refs.forEach((ref) => setRef(ref, value)); 37624 }; 37625 }, refs); 37626 } 37627 function useRefId(ref, deps) { 37628 const [id, setId] = useState(void 0); 37629 useSafeLayoutEffect(() => { 37630 var _a; 37631 setId((_a = ref == null ? void 0 : ref.current) == null ? void 0 : _a.id); 37632 }, deps); 37633 return id; 37634 } 37635 function useId(defaultId) { 37636 if (useReactId) { 37637 const reactId = useReactId(); 37638 if (defaultId) 37639 return defaultId; 37640 return reactId; 37641 } 37642 const [id, setId] = (0,external_React_.useState)(defaultId); 37643 useSafeLayoutEffect(() => { 37644 if (defaultId || id) 37645 return; 37646 const random = Math.random().toString(36).substr(2, 6); 37647 setId(`id-$random}`); 37648 }, [defaultId, id]); 37649 return defaultId || id; 37650 } 37651 function useDeferredValue(value) { 37652 if (useReactDeferredValue) { 37653 return useReactDeferredValue(value); 37654 } 37655 const [deferredValue, setDeferredValue] = useState(value); 37656 useEffect(() => { 37657 const raf = requestAnimationFrame(() => setDeferredValue(value)); 37658 return () => cancelAnimationFrame(raf); 37659 }, [value]); 37660 return deferredValue; 37661 } 37662 function useTagName(refOrElement, type) { 37663 const stringOrUndefined = (type2) => { 37664 if (typeof type2 !== "string") 37665 return; 37666 return type2; 37667 }; 37668 const [tagName, setTagName] = (0,external_React_.useState)(() => stringOrUndefined(type)); 37669 useSafeLayoutEffect(() => { 37670 const element = refOrElement && "current" in refOrElement ? refOrElement.current : refOrElement; 37671 setTagName((element == null ? void 0 : element.tagName.toLowerCase()) || stringOrUndefined(type)); 37672 }, [refOrElement, type]); 37673 return tagName; 37674 } 37675 function useAttribute(refOrElement, attributeName, defaultValue) { 37676 const [attribute, setAttribute] = (0,external_React_.useState)(defaultValue); 37677 useSafeLayoutEffect(() => { 37678 const element = refOrElement && "current" in refOrElement ? refOrElement.current : refOrElement; 37679 const value = element == null ? void 0 : element.getAttribute(attributeName); 37680 if (value == null) 37681 return; 37682 setAttribute(value); 37683 }, [refOrElement, attributeName]); 37684 return attribute; 37685 } 37686 function useUpdateEffect(effect, deps) { 37687 const mounted = (0,external_React_.useRef)(false); 37688 (0,external_React_.useEffect)(() => { 37689 if (mounted.current) { 37690 return effect(); 37691 } 37692 mounted.current = true; 37693 }, deps); 37694 (0,external_React_.useEffect)( 37695 () => () => { 37696 mounted.current = false; 37697 }, 37698 [] 37699 ); 37700 } 37701 function useUpdateLayoutEffect(effect, deps) { 37702 const mounted = (0,external_React_.useRef)(false); 37703 useSafeLayoutEffect(() => { 37704 if (mounted.current) { 37705 return effect(); 37706 } 37707 mounted.current = true; 37708 }, deps); 37709 useSafeLayoutEffect( 37710 () => () => { 37711 mounted.current = false; 37712 }, 37713 [] 37714 ); 37715 } 37716 function useControlledState(defaultState, state, setState) { 37717 const [localState, setLocalState] = useState(defaultState); 37718 const nextState = state !== void 0 ? state : localState; 37719 const stateRef = useLiveRef(state); 37720 const setStateRef = useLiveRef(setState); 37721 const nextStateRef = useLiveRef(nextState); 37722 const setNextState = useCallback((prevValue) => { 37723 const setStateProp = setStateRef.current; 37724 if (setStateProp) { 37725 if (isSetNextState(setStateProp)) { 37726 setStateProp(prevValue); 37727 } else { 37728 const nextValue = applyState(prevValue, nextStateRef.current); 37729 nextStateRef.current = nextValue; 37730 setStateProp(nextValue); 37731 } 37732 } 37733 if (stateRef.current === void 0) { 37734 setLocalState(prevValue); 37735 } 37736 }, []); 37737 defineSetNextState(setNextState); 37738 return [nextState, setNextState]; 37739 } 37740 var SET_NEXT_STATE = Symbol("setNextState"); 37741 function isSetNextState(arg) { 37742 return arg[SET_NEXT_STATE] === true; 37743 } 37744 function defineSetNextState(arg) { 37745 if (!isSetNextState(arg)) { 37746 Object.defineProperty(arg, SET_NEXT_STATE, { value: true }); 37747 } 37748 } 37749 function useForceUpdate() { 37750 return (0,external_React_.useReducer)(() => [], []); 37751 } 37752 function useBooleanEvent(booleanOrCallback) { 37753 return useEvent( 37754 typeof booleanOrCallback === "function" ? booleanOrCallback : () => booleanOrCallback 37755 ); 37756 } 37757 function useWrapElement(props, callback, deps = []) { 37758 const wrapElement = (0,external_React_.useCallback)( 37759 (element) => { 37760 if (props.wrapElement) { 37761 element = props.wrapElement(element); 37762 } 37763 return callback(element); 37764 }, 37765 [...deps, props.wrapElement] 37766 ); 37767 return _4R3V3JGP_spreadProps(_4R3V3JGP_spreadValues({}, props), { wrapElement }); 37768 } 37769 function usePortalRef(portalProp = false, portalRefProp) { 37770 const [portalNode, setPortalNode] = useState(null); 37771 const portalRef = useMergeRefs(setPortalNode, portalRefProp); 37772 const domReady = !portalProp || portalNode; 37773 return { portalRef, portalNode, domReady }; 37774 } 37775 function useMetadataProps(props, key, value) { 37776 const parent = props.onLoadedMetadataCapture; 37777 const onLoadedMetadataCapture = (0,external_React_.useMemo)(() => { 37778 return Object.assign(() => { 37779 }, _4R3V3JGP_spreadProps(_4R3V3JGP_spreadValues({}, parent), { [key]: value })); 37780 }, [parent, key, value]); 37781 return [parent == null ? void 0 : parent[key], { onLoadedMetadataCapture }]; 37782 } 37783 function useIsMouseMoving() { 37784 (0,external_React_.useEffect)(() => { 37785 addGlobalEventListener("mousemove", setMouseMoving, true); 37786 addGlobalEventListener("mousedown", resetMouseMoving, true); 37787 addGlobalEventListener("mouseup", resetMouseMoving, true); 37788 addGlobalEventListener("keydown", resetMouseMoving, true); 37789 addGlobalEventListener("scroll", resetMouseMoving, true); 37790 }, []); 37791 const isMouseMoving = useEvent(() => mouseMoving); 37792 return isMouseMoving; 37793 } 37794 var mouseMoving = false; 37795 var previousScreenX = 0; 37796 var previousScreenY = 0; 37797 function hasMouseMovement(event) { 37798 const movementX = event.movementX || event.screenX - previousScreenX; 37799 const movementY = event.movementY || event.screenY - previousScreenY; 37800 previousScreenX = event.screenX; 37801 previousScreenY = event.screenY; 37802 return movementX || movementY || "production" === "test"; 37803 } 37804 function setMouseMoving(event) { 37805 if (!hasMouseMovement(event)) 37806 return; 37807 mouseMoving = true; 37808 } 37809 function resetMouseMoving() { 37810 mouseMoving = false; 37811 } 37812 37813 37814 37815 ;// CONCATENATED MODULE: ./node_modules/@ariakit/core/esm/__chunks/EAHJFCU4.js 37816 "use client"; 37817 37818 37819 37820 // src/utils/store.ts 37821 function getInternal(store, key) { 37822 const internals = store.__unstableInternals; 37823 invariant(internals, "Invalid store"); 37824 return internals[key]; 37825 } 37826 function createStore(initialState, ...stores) { 37827 let state = initialState; 37828 let prevStateBatch = state; 37829 let lastUpdate = Symbol(); 37830 let destroy = Y3OOHFCN_noop; 37831 const instances = /* @__PURE__ */ new Set(); 37832 const updatedKeys = /* @__PURE__ */ new Set(); 37833 const setups = /* @__PURE__ */ new Set(); 37834 const listeners = /* @__PURE__ */ new Set(); 37835 const batchListeners = /* @__PURE__ */ new Set(); 37836 const disposables = /* @__PURE__ */ new WeakMap(); 37837 const listenerKeys = /* @__PURE__ */ new WeakMap(); 37838 const storeSetup = (callback) => { 37839 setups.add(callback); 37840 return () => setups.delete(callback); 37841 }; 37842 const storeInit = () => { 37843 const initialized = instances.size; 37844 const instance = Symbol(); 37845 instances.add(instance); 37846 const maybeDestroy = () => { 37847 instances.delete(instance); 37848 if (instances.size) 37849 return; 37850 destroy(); 37851 }; 37852 if (initialized) 37853 return maybeDestroy; 37854 const desyncs = getKeys(state).map( 37855 (key) => chain( 37856 ...stores.map((store) => { 37857 var _a; 37858 const storeState = (_a = store == null ? void 0 : store.getState) == null ? void 0 : _a.call(store); 37859 if (!storeState) 37860 return; 37861 if (!Y3OOHFCN_hasOwnProperty(storeState, key)) 37862 return; 37863 return sync(store, [key], (state2) => { 37864 setState( 37865 key, 37866 state2[key], 37867 // @ts-expect-error - Not public API. This is just to prevent 37868 // infinite loops. 37869 true 37870 ); 37871 }); 37872 }) 37873 ) 37874 ); 37875 const teardowns = []; 37876 setups.forEach((setup2) => teardowns.push(setup2())); 37877 const cleanups = stores.map(init); 37878 destroy = chain(...desyncs, ...teardowns, ...cleanups); 37879 return maybeDestroy; 37880 }; 37881 const sub = (keys, listener, set = listeners) => { 37882 set.add(listener); 37883 listenerKeys.set(listener, keys); 37884 return () => { 37885 var _a; 37886 (_a = disposables.get(listener)) == null ? void 0 : _a(); 37887 disposables.delete(listener); 37888 listenerKeys.delete(listener); 37889 set.delete(listener); 37890 }; 37891 }; 37892 const storeSubscribe = (keys, listener) => sub(keys, listener); 37893 const storeSync = (keys, listener) => { 37894 disposables.set(listener, listener(state, state)); 37895 return sub(keys, listener); 37896 }; 37897 const storeBatch = (keys, listener) => { 37898 disposables.set(listener, listener(state, prevStateBatch)); 37899 return sub(keys, listener, batchListeners); 37900 }; 37901 const storePick = (keys) => createStore(pick(state, keys), finalStore); 37902 const storeOmit = (keys) => createStore(omit(state, keys), finalStore); 37903 const getState = () => state; 37904 const setState = (key, value, fromStores = false) => { 37905 if (!Y3OOHFCN_hasOwnProperty(state, key)) 37906 return; 37907 const nextValue = Y3OOHFCN_applyState(value, state[key]); 37908 if (nextValue === state[key]) 37909 return; 37910 if (!fromStores) { 37911 stores.forEach((store) => { 37912 var _a; 37913 (_a = store == null ? void 0 : store.setState) == null ? void 0 : _a.call(store, key, nextValue); 37914 }); 37915 } 37916 const prevState = state; 37917 state = _chunks_4R3V3JGP_spreadProps(_chunks_4R3V3JGP_spreadValues({}, state), { [key]: nextValue }); 37918 const thisUpdate = Symbol(); 37919 lastUpdate = thisUpdate; 37920 updatedKeys.add(key); 37921 const run = (listener, prev, uKeys) => { 37922 var _a; 37923 const keys = listenerKeys.get(listener); 37924 const updated = (k) => uKeys ? uKeys.has(k) : k === key; 37925 if (!keys || keys.some(updated)) { 37926 (_a = disposables.get(listener)) == null ? void 0 : _a(); 37927 disposables.set(listener, listener(state, prev)); 37928 } 37929 }; 37930 listeners.forEach((listener) => { 37931 run(listener, prevState); 37932 }); 37933 queueMicrotask(() => { 37934 if (lastUpdate !== thisUpdate) 37935 return; 37936 const snapshot = state; 37937 batchListeners.forEach((listener) => { 37938 run(listener, prevStateBatch, updatedKeys); 37939 }); 37940 prevStateBatch = snapshot; 37941 updatedKeys.clear(); 37942 }); 37943 }; 37944 const finalStore = { 37945 getState, 37946 setState, 37947 __unstableInternals: { 37948 setup: storeSetup, 37949 init: storeInit, 37950 subscribe: storeSubscribe, 37951 sync: storeSync, 37952 batch: storeBatch, 37953 pick: storePick, 37954 omit: storeOmit 37955 } 37956 }; 37957 return finalStore; 37958 } 37959 function setup(store, ...args) { 37960 if (!store) 37961 return; 37962 return getInternal(store, "setup")(...args); 37963 } 37964 function init(store, ...args) { 37965 if (!store) 37966 return; 37967 return getInternal(store, "init")(...args); 37968 } 37969 function subscribe(store, ...args) { 37970 if (!store) 37971 return; 37972 return getInternal(store, "subscribe")(...args); 37973 } 37974 function sync(store, ...args) { 37975 if (!store) 37976 return; 37977 return getInternal(store, "sync")(...args); 37978 } 37979 function batch(store, ...args) { 37980 if (!store) 37981 return; 37982 return getInternal(store, "batch")(...args); 37983 } 37984 function omit2(store, ...args) { 37985 if (!store) 37986 return; 37987 return getInternal(store, "omit")(...args); 37988 } 37989 function pick2(store, ...args) { 37990 if (!store) 37991 return; 37992 return getInternal(store, "pick")(...args); 37993 } 37994 function mergeStore(...stores) { 37995 const initialState = stores.reduce((state, store2) => { 37996 var _a; 37997 const nextState = (_a = store2 == null ? void 0 : store2.getState) == null ? void 0 : _a.call(store2); 37998 if (!nextState) 37999 return state; 38000 return _chunks_4R3V3JGP_spreadValues(_chunks_4R3V3JGP_spreadValues({}, state), nextState); 38001 }, {}); 38002 const store = createStore(initialState, ...stores); 38003 return store; 38004 } 38005 function throwOnConflictingProps(props, store) { 38006 if (true) 38007 return; 38008 if (!store) 38009 return; 38010 const defaultKeys = Object.entries(props).filter(([key, value]) => key.startsWith("default") && value !== void 0).map(([key]) => { 38011 var _a; 38012 const stateKey = key.replace("default", ""); 38013 return `${((_a = stateKey[0]) == null ? void 0 : _a.toLowerCase()) || ""}$stateKey.slice(1)}`; 38014 }); 38015 if (!defaultKeys.length) 38016 return; 38017 const storeState = store.getState(); 38018 const conflictingProps = defaultKeys.filter( 38019 (key) => Y3OOHFCN_hasOwnProperty(storeState, key) 38020 ); 38021 if (!conflictingProps.length) 38022 return; 38023 throw new Error( 38024 `Passing a store prop in conjunction with a default state is not supported. 38025 38026 const store = useSelectStore(); 38027 <SelectProvider store={store} defaultValue="Apple" /> 38028 ^ ^ 38029 38030 Instead, pass the default state to the topmost store: 38031 38032 const store = useSelectStore({ defaultValue: "Apple" }); 38033 <SelectProvider store={store} /> 38034 38035 See https://github.com/ariakit/ariakit/pull/2745 for more details. 38036 38037 If there's a particular need for this, please submit a feature request at https://github.com/ariakit/ariakit 38038 ` 38039 ); 38040 } 38041 38042 38043 38044 // EXTERNAL MODULE: ./node_modules/use-sync-external-store/shim/index.js 38045 var shim = __webpack_require__(422); 38046 ;// CONCATENATED MODULE: ./node_modules/@ariakit/react-core/esm/__chunks/EKQEJRUF.js 38047 "use client"; 38048 38049 38050 38051 // src/utils/store.tsx 38052 38053 38054 38055 38056 var { useSyncExternalStore } = shim; 38057 var noopSubscribe = () => () => { 38058 }; 38059 function useStoreState(store, keyOrSelector = identity) { 38060 const storeSubscribe = external_React_.useCallback( 38061 (callback) => { 38062 if (!store) 38063 return noopSubscribe(); 38064 return subscribe(store, null, callback); 38065 }, 38066 [store] 38067 ); 38068 const getSnapshot = () => { 38069 const key = typeof keyOrSelector === "string" ? keyOrSelector : null; 38070 const selector = typeof keyOrSelector === "function" ? keyOrSelector : null; 38071 const state = store == null ? void 0 : store.getState(); 38072 if (selector) 38073 return selector(state); 38074 if (!state) 38075 return; 38076 if (!key) 38077 return; 38078 if (!Y3OOHFCN_hasOwnProperty(state, key)) 38079 return; 38080 return state[key]; 38081 }; 38082 return useSyncExternalStore(storeSubscribe, getSnapshot, getSnapshot); 38083 } 38084 function useStoreProps(store, props, key, setKey) { 38085 const value = Y3OOHFCN_hasOwnProperty(props, key) ? props[key] : void 0; 38086 const setValue = setKey ? props[setKey] : void 0; 38087 const propsRef = useLiveRef({ value, setValue }); 38088 useSafeLayoutEffect(() => { 38089 return sync(store, [key], (state, prev) => { 38090 const { value: value2, setValue: setValue2 } = propsRef.current; 38091 if (!setValue2) 38092 return; 38093 if (state[key] === prev[key]) 38094 return; 38095 if (state[key] === value2) 38096 return; 38097 setValue2(state[key]); 38098 }); 38099 }, [store, key]); 38100 useSafeLayoutEffect(() => { 38101 if (value === void 0) 38102 return; 38103 store.setState(key, value); 38104 return batch(store, [key], () => { 38105 if (value === void 0) 38106 return; 38107 store.setState(key, value); 38108 }); 38109 }); 38110 } 38111 function EKQEJRUF_useStore(createStore, props) { 38112 const [store, setStore] = external_React_.useState(() => createStore(props)); 38113 useSafeLayoutEffect(() => init(store), [store]); 38114 const useState2 = external_React_.useCallback( 38115 (keyOrSelector) => useStoreState(store, keyOrSelector), 38116 [store] 38117 ); 38118 const memoizedStore = external_React_.useMemo( 38119 () => _4R3V3JGP_spreadProps(_4R3V3JGP_spreadValues({}, store), { useState: useState2 }), 38120 [store, useState2] 38121 ); 38122 const updateStore = useEvent(() => { 38123 setStore((store2) => createStore(_4R3V3JGP_spreadValues(_4R3V3JGP_spreadValues({}, props), store2.getState()))); 38124 }); 38125 return [memoizedStore, updateStore]; 38126 } 38127 38128 38129 38130 ;// CONCATENATED MODULE: ./node_modules/@ariakit/react-core/esm/__chunks/Y6GYTNQ2.js 38131 "use client"; 38132 38133 38134 38135 // src/collection/collection-store.ts 38136 38137 function useCollectionStoreProps(store, update, props) { 38138 useUpdateEffect(update, [props.store]); 38139 useStoreProps(store, props, "items", "setItems"); 38140 return store; 38141 } 38142 function useCollectionStore(props = {}) { 38143 const [store, update] = useStore(Core.createCollectionStore, props); 38144 return useCollectionStoreProps(store, update, props); 38145 } 38146 38147 38148 38149 ;// CONCATENATED MODULE: ./node_modules/@ariakit/react-core/esm/__chunks/7GBW5FLS.js 38150 "use client"; 38151 38152 38153 38154 // src/composite/composite-store.ts 38155 38156 function useCompositeStoreProps(store, update, props) { 38157 store = useCollectionStoreProps(store, update, props); 38158 useStoreProps(store, props, "activeId", "setActiveId"); 38159 useStoreProps(store, props, "includesBaseElement"); 38160 useStoreProps(store, props, "virtualFocus"); 38161 useStoreProps(store, props, "orientation"); 38162 useStoreProps(store, props, "rtl"); 38163 useStoreProps(store, props, "focusLoop"); 38164 useStoreProps(store, props, "focusWrap"); 38165 useStoreProps(store, props, "focusShift"); 38166 return store; 38167 } 38168 function _7GBW5FLS_useCompositeStore(props = {}) { 38169 const [store, update] = useStore(Core.createCompositeStore, props); 38170 return useCompositeStoreProps(store, update, props); 38171 } 38172 38173 38174 38175 ;// CONCATENATED MODULE: ./node_modules/@ariakit/react-core/esm/__chunks/SFCBA2JZ.js 38176 "use client"; 38177 38178 38179 38180 // src/disclosure/disclosure-store.ts 38181 38182 function useDisclosureStoreProps(store, update, props) { 38183 useUpdateEffect(update, [props.store, props.disclosure]); 38184 useStoreProps(store, props, "open", "setOpen"); 38185 useStoreProps(store, props, "mounted", "setMounted"); 38186 useStoreProps(store, props, "animated"); 38187 return store; 38188 } 38189 function useDisclosureStore(props = {}) { 38190 const [store, update] = useStore(Core.createDisclosureStore, props); 38191 return useDisclosureStoreProps(store, update, props); 38192 } 38193 38194 38195 38196 ;// CONCATENATED MODULE: ./node_modules/@ariakit/react-core/esm/__chunks/ZSELSBRM.js 38197 "use client"; 38198 38199 38200 38201 // src/dialog/dialog-store.ts 38202 38203 function useDialogStoreProps(store, update, props) { 38204 return useDisclosureStoreProps(store, update, props); 38205 } 38206 function useDialogStore(props = {}) { 38207 const [store, update] = useStore(Core.createDialogStore, props); 38208 return useDialogStoreProps(store, update, props); 38209 } 38210 38211 38212 38213 ;// CONCATENATED MODULE: ./node_modules/@ariakit/react-core/esm/__chunks/MG4P3223.js 38214 "use client"; 38215 38216 38217 38218 38219 // src/popover/popover-store.ts 38220 38221 function usePopoverStoreProps(store, update, props) { 38222 useUpdateEffect(update, [props.popover]); 38223 store = useDialogStoreProps(store, update, props); 38224 useStoreProps(store, props, "placement"); 38225 return store; 38226 } 38227 function usePopoverStore(props = {}) { 38228 const [store, update] = useStore(Core.createPopoverStore, props); 38229 return usePopoverStoreProps(store, update, props); 38230 } 38231 38232 38233 38234 ;// CONCATENATED MODULE: ./node_modules/@ariakit/core/esm/__chunks/Z5IGYIPT.js 38235 "use client"; 38236 38237 38238 38239 38240 // src/disclosure/disclosure-store.ts 38241 function createDisclosureStore(props = {}) { 38242 const store = mergeStore( 38243 props.store, 38244 omit2(props.disclosure, ["contentElement", "disclosureElement"]) 38245 ); 38246 throwOnConflictingProps(props, store); 38247 const syncState = store == null ? void 0 : store.getState(); 38248 const open = defaultValue( 38249 props.open, 38250 syncState == null ? void 0 : syncState.open, 38251 props.defaultOpen, 38252 false 38253 ); 38254 const animated = defaultValue(props.animated, syncState == null ? void 0 : syncState.animated, false); 38255 const initialState = { 38256 open, 38257 animated, 38258 animating: !!animated && open, 38259 mounted: open, 38260 contentElement: defaultValue(syncState == null ? void 0 : syncState.contentElement, null), 38261 disclosureElement: defaultValue(syncState == null ? void 0 : syncState.disclosureElement, null) 38262 }; 38263 const disclosure = createStore(initialState, store); 38264 setup( 38265 disclosure, 38266 () => sync(disclosure, ["animated", "animating"], (state) => { 38267 if (state.animated) 38268 return; 38269 disclosure.setState("animating", false); 38270 }) 38271 ); 38272 setup( 38273 disclosure, 38274 () => subscribe(disclosure, ["open"], () => { 38275 if (!disclosure.getState().animated) 38276 return; 38277 disclosure.setState("animating", true); 38278 }) 38279 ); 38280 setup( 38281 disclosure, 38282 () => sync(disclosure, ["open", "animating"], (state) => { 38283 disclosure.setState("mounted", state.open || state.animating); 38284 }) 38285 ); 38286 return _chunks_4R3V3JGP_spreadProps(_chunks_4R3V3JGP_spreadValues({}, disclosure), { 38287 setOpen: (value) => disclosure.setState("open", value), 38288 show: () => disclosure.setState("open", true), 38289 hide: () => disclosure.setState("open", false), 38290 toggle: () => disclosure.setState("open", (open2) => !open2), 38291 stopAnimation: () => disclosure.setState("animating", false), 38292 setContentElement: (value) => disclosure.setState("contentElement", value), 38293 setDisclosureElement: (value) => disclosure.setState("disclosureElement", value) 38294 }); 38295 } 38296 38297 38298 38299 ;// CONCATENATED MODULE: ./node_modules/@ariakit/core/esm/__chunks/SX2XFD6A.js 38300 "use client"; 38301 38302 38303 // src/dialog/dialog-store.ts 38304 function createDialogStore(props = {}) { 38305 return createDisclosureStore(props); 38306 } 38307 38308 38309 38310 ;// CONCATENATED MODULE: ./node_modules/@ariakit/core/esm/__chunks/AF6IUUFN.js 38311 "use client"; 38312 38313 38314 38315 38316 38317 // src/popover/popover-store.ts 38318 function createPopoverStore(_a = {}) { 38319 var _b = _a, { 38320 popover: otherPopover 38321 } = _b, props = _4R3V3JGP_objRest(_b, [ 38322 "popover" 38323 ]); 38324 const store = mergeStore( 38325 props.store, 38326 omit2(otherPopover, [ 38327 "arrowElement", 38328 "anchorElement", 38329 "contentElement", 38330 "popoverElement", 38331 "disclosureElement" 38332 ]) 38333 ); 38334 throwOnConflictingProps(props, store); 38335 const syncState = store == null ? void 0 : store.getState(); 38336 const dialog = createDialogStore(_chunks_4R3V3JGP_spreadProps(_chunks_4R3V3JGP_spreadValues({}, props), { store })); 38337 const placement = defaultValue( 38338 props.placement, 38339 syncState == null ? void 0 : syncState.placement, 38340 "bottom" 38341 ); 38342 const initialState = _chunks_4R3V3JGP_spreadProps(_chunks_4R3V3JGP_spreadValues({}, dialog.getState()), { 38343 placement, 38344 currentPlacement: placement, 38345 anchorElement: defaultValue(syncState == null ? void 0 : syncState.anchorElement, null), 38346 popoverElement: defaultValue(syncState == null ? void 0 : syncState.popoverElement, null), 38347 arrowElement: defaultValue(syncState == null ? void 0 : syncState.arrowElement, null), 38348 rendered: Symbol("rendered") 38349 }); 38350 const popover = createStore(initialState, dialog, store); 38351 return _chunks_4R3V3JGP_spreadProps(_chunks_4R3V3JGP_spreadValues(_chunks_4R3V3JGP_spreadValues({}, dialog), popover), { 38352 setAnchorElement: (element) => popover.setState("anchorElement", element), 38353 setPopoverElement: (element) => popover.setState("popoverElement", element), 38354 setArrowElement: (element) => popover.setState("arrowElement", element), 38355 render: () => popover.setState("rendered", Symbol("rendered")) 38356 }); 38357 } 38358 38359 38360 38361 ;// CONCATENATED MODULE: ./node_modules/@ariakit/core/esm/__chunks/22K762VQ.js 38362 "use client"; 38363 38364 38365 38366 38367 38368 // src/collection/collection-store.ts 38369 function isElementPreceding(a, b) { 38370 return Boolean( 38371 b.compareDocumentPosition(a) & Node.DOCUMENT_POSITION_PRECEDING 38372 ); 38373 } 38374 function sortBasedOnDOMPosition(items) { 38375 const pairs = items.map((item, index) => [index, item]); 38376 let isOrderDifferent = false; 38377 pairs.sort(([indexA, a], [indexB, b]) => { 38378 const elementA = a.element; 38379 const elementB = b.element; 38380 if (elementA === elementB) 38381 return 0; 38382 if (!elementA || !elementB) 38383 return 0; 38384 if (isElementPreceding(elementA, elementB)) { 38385 if (indexA > indexB) { 38386 isOrderDifferent = true; 38387 } 38388 return -1; 38389 } 38390 if (indexA < indexB) { 38391 isOrderDifferent = true; 38392 } 38393 return 1; 38394 }); 38395 if (isOrderDifferent) { 38396 return pairs.map(([_, item]) => item); 38397 } 38398 return items; 38399 } 38400 function getCommonParent(items) { 38401 var _a; 38402 const firstItem = items.find((item) => !!item.element); 38403 const lastItem = [...items].reverse().find((item) => !!item.element); 38404 let parentElement = (_a = firstItem == null ? void 0 : firstItem.element) == null ? void 0 : _a.parentElement; 38405 while (parentElement && (lastItem == null ? void 0 : lastItem.element)) { 38406 const parent = parentElement; 38407 if (lastItem && parent.contains(lastItem.element)) { 38408 return parentElement; 38409 } 38410 parentElement = parentElement.parentElement; 38411 } 38412 return DLOEKDPY_getDocument(parentElement).body; 38413 } 38414 function getPrivateStore(store) { 38415 return store == null ? void 0 : store.__unstablePrivateStore; 38416 } 38417 function createCollectionStore(props = {}) { 38418 var _a; 38419 throwOnConflictingProps(props, props.store); 38420 const syncState = (_a = props.store) == null ? void 0 : _a.getState(); 38421 const items = defaultValue( 38422 props.items, 38423 syncState == null ? void 0 : syncState.items, 38424 props.defaultItems, 38425 [] 38426 ); 38427 const itemsMap = new Map(items.map((item) => [item.id, item])); 38428 const initialState = { 38429 items, 38430 renderedItems: defaultValue(syncState == null ? void 0 : syncState.renderedItems, []) 38431 }; 38432 const syncPrivateStore = getPrivateStore(props.store); 38433 const privateStore = createStore( 38434 { items, renderedItems: initialState.renderedItems }, 38435 syncPrivateStore 38436 ); 38437 const collection = createStore(initialState, props.store); 38438 const sortItems = (renderedItems) => { 38439 const sortedItems = sortBasedOnDOMPosition(renderedItems); 38440 privateStore.setState("renderedItems", sortedItems); 38441 collection.setState("renderedItems", sortedItems); 38442 }; 38443 setup(collection, () => init(privateStore)); 38444 setup(privateStore, () => { 38445 return batch(privateStore, ["items"], (state) => { 38446 collection.setState("items", state.items); 38447 }); 38448 }); 38449 setup(privateStore, () => { 38450 return batch(privateStore, ["renderedItems"], (state) => { 38451 let firstRun = true; 38452 let raf = requestAnimationFrame(() => { 38453 const { renderedItems } = collection.getState(); 38454 if (state.renderedItems === renderedItems) 38455 return; 38456 sortItems(state.renderedItems); 38457 }); 38458 if (typeof IntersectionObserver !== "function") { 38459 return () => cancelAnimationFrame(raf); 38460 } 38461 const ioCallback = () => { 38462 if (firstRun) { 38463 firstRun = false; 38464 return; 38465 } 38466 cancelAnimationFrame(raf); 38467 raf = requestAnimationFrame(() => sortItems(state.renderedItems)); 38468 }; 38469 const root = getCommonParent(state.renderedItems); 38470 const observer = new IntersectionObserver(ioCallback, { root }); 38471 for (const item of state.renderedItems) { 38472 if (!item.element) 38473 continue; 38474 observer.observe(item.element); 38475 } 38476 return () => { 38477 cancelAnimationFrame(raf); 38478 observer.disconnect(); 38479 }; 38480 }); 38481 }); 38482 const mergeItem = (item, setItems, canDeleteFromMap = false) => { 38483 let prevItem; 38484 setItems((items2) => { 38485 const index = items2.findIndex(({ id }) => id === item.id); 38486 const nextItems = items2.slice(); 38487 if (index !== -1) { 38488 prevItem = items2[index]; 38489 const nextItem = _chunks_4R3V3JGP_spreadValues(_chunks_4R3V3JGP_spreadValues({}, prevItem), item); 38490 nextItems[index] = nextItem; 38491 itemsMap.set(item.id, nextItem); 38492 } else { 38493 nextItems.push(item); 38494 itemsMap.set(item.id, item); 38495 } 38496 return nextItems; 38497 }); 38498 const unmergeItem = () => { 38499 setItems((items2) => { 38500 if (!prevItem) { 38501 if (canDeleteFromMap) { 38502 itemsMap.delete(item.id); 38503 } 38504 return items2.filter(({ id }) => id !== item.id); 38505 } 38506 const index = items2.findIndex(({ id }) => id === item.id); 38507 if (index === -1) 38508 return items2; 38509 const nextItems = items2.slice(); 38510 nextItems[index] = prevItem; 38511 itemsMap.set(item.id, prevItem); 38512 return nextItems; 38513 }); 38514 }; 38515 return unmergeItem; 38516 }; 38517 const registerItem = (item) => mergeItem( 38518 item, 38519 (getItems) => privateStore.setState("items", getItems), 38520 true 38521 ); 38522 return _chunks_4R3V3JGP_spreadProps(_chunks_4R3V3JGP_spreadValues({}, collection), { 38523 registerItem, 38524 renderItem: (item) => chain( 38525 registerItem(item), 38526 mergeItem( 38527 item, 38528 (getItems) => privateStore.setState("renderedItems", getItems) 38529 ) 38530 ), 38531 item: (id) => { 38532 if (!id) 38533 return null; 38534 let item = itemsMap.get(id); 38535 if (!item) { 38536 const { items: items2 } = collection.getState(); 38537 item = items2.find((item2) => item2.id === id); 38538 if (item) { 38539 itemsMap.set(id, item); 38540 } 38541 } 38542 return item || null; 38543 }, 38544 // @ts-expect-error Internal 38545 __unstablePrivateStore: privateStore 38546 }); 38547 } 38548 38549 38550 38551 ;// CONCATENATED MODULE: ./node_modules/@ariakit/core/esm/__chunks/7PRQYBBV.js 38552 "use client"; 38553 38554 // src/utils/array.ts 38555 function toArray(arg) { 38556 if (Array.isArray(arg)) { 38557 return arg; 38558 } 38559 return typeof arg !== "undefined" ? [arg] : []; 38560 } 38561 function addItemToArray(array, item, index = -1) { 38562 if (!(index in array)) { 38563 return [...array, item]; 38564 } 38565 return [...array.slice(0, index), item, ...array.slice(index)]; 38566 } 38567 function flatten2DArray(array) { 38568 const flattened = []; 38569 for (const row of array) { 38570 flattened.push(...row); 38571 } 38572 return flattened; 38573 } 38574 function reverseArray(array) { 38575 return array.slice().reverse(); 38576 } 38577 38578 38579 38580 ;// CONCATENATED MODULE: ./node_modules/@ariakit/core/esm/__chunks/IERTEJ3A.js 38581 "use client"; 38582 38583 38584 38585 38586 38587 38588 // src/composite/composite-store.ts 38589 var NULL_ITEM = { id: null }; 38590 function findFirstEnabledItem(items, excludeId) { 38591 return items.find((item) => { 38592 if (excludeId) { 38593 return !item.disabled && item.id !== excludeId; 38594 } 38595 return !item.disabled; 38596 }); 38597 } 38598 function getEnabledItems(items, excludeId) { 38599 return items.filter((item) => { 38600 if (excludeId) { 38601 return !item.disabled && item.id !== excludeId; 38602 } 38603 return !item.disabled; 38604 }); 38605 } 38606 function getOppositeOrientation(orientation) { 38607 if (orientation === "vertical") 38608 return "horizontal"; 38609 if (orientation === "horizontal") 38610 return "vertical"; 38611 return; 38612 } 38613 function getItemsInRow(items, rowId) { 38614 return items.filter((item) => item.rowId === rowId); 38615 } 38616 function flipItems(items, activeId, shouldInsertNullItem = false) { 38617 const index = items.findIndex((item) => item.id === activeId); 38618 return [ 38619 ...items.slice(index + 1), 38620 ...shouldInsertNullItem ? [NULL_ITEM] : [], 38621 ...items.slice(0, index) 38622 ]; 38623 } 38624 function groupItemsByRows(items) { 38625 const rows = []; 38626 for (const item of items) { 38627 const row = rows.find((currentRow) => { 38628 var _a; 38629 return ((_a = currentRow[0]) == null ? void 0 : _a.rowId) === item.rowId; 38630 }); 38631 if (row) { 38632 row.push(item); 38633 } else { 38634 rows.push([item]); 38635 } 38636 } 38637 return rows; 38638 } 38639 function getMaxRowLength(array) { 38640 let maxLength = 0; 38641 for (const { length } of array) { 38642 if (length > maxLength) { 38643 maxLength = length; 38644 } 38645 } 38646 return maxLength; 38647 } 38648 function createEmptyItem(rowId) { 38649 return { 38650 id: "__EMPTY_ITEM__", 38651 disabled: true, 38652 rowId 38653 }; 38654 } 38655 function normalizeRows(rows, activeId, focusShift) { 38656 const maxLength = getMaxRowLength(rows); 38657 for (const row of rows) { 38658 for (let i = 0; i < maxLength; i += 1) { 38659 const item = row[i]; 38660 if (!item || focusShift && item.disabled) { 38661 const isFirst = i === 0; 38662 const previousItem = isFirst && focusShift ? findFirstEnabledItem(row) : row[i - 1]; 38663 row[i] = previousItem && activeId !== previousItem.id && focusShift ? previousItem : createEmptyItem(previousItem == null ? void 0 : previousItem.rowId); 38664 } 38665 } 38666 } 38667 return rows; 38668 } 38669 function verticalizeItems(items) { 38670 const rows = groupItemsByRows(items); 38671 const maxLength = getMaxRowLength(rows); 38672 const verticalized = []; 38673 for (let i = 0; i < maxLength; i += 1) { 38674 for (const row of rows) { 38675 const item = row[i]; 38676 if (item) { 38677 verticalized.push(_chunks_4R3V3JGP_spreadProps(_chunks_4R3V3JGP_spreadValues({}, item), { 38678 // If there's no rowId, it means that it's not a grid composite, but 38679 // a single row instead. So, instead of verticalizing it, that is, 38680 // assigning a different rowId based on the column index, we keep it 38681 // undefined so they will be part of the same row. This is useful 38682 // when using up/down on one-dimensional composites. 38683 rowId: item.rowId ? `$i}` : void 0 38684 })); 38685 } 38686 } 38687 } 38688 return verticalized; 38689 } 38690 function createCompositeStore(props = {}) { 38691 var _a; 38692 const syncState = (_a = props.store) == null ? void 0 : _a.getState(); 38693 const collection = createCollectionStore(props); 38694 const activeId = defaultValue( 38695 props.activeId, 38696 syncState == null ? void 0 : syncState.activeId, 38697 props.defaultActiveId 38698 ); 38699 const initialState = _chunks_4R3V3JGP_spreadProps(_chunks_4R3V3JGP_spreadValues({}, collection.getState()), { 38700 activeId, 38701 baseElement: defaultValue(syncState == null ? void 0 : syncState.baseElement, null), 38702 includesBaseElement: defaultValue( 38703 props.includesBaseElement, 38704 syncState == null ? void 0 : syncState.includesBaseElement, 38705 activeId === null 38706 ), 38707 moves: defaultValue(syncState == null ? void 0 : syncState.moves, 0), 38708 orientation: defaultValue( 38709 props.orientation, 38710 syncState == null ? void 0 : syncState.orientation, 38711 "both" 38712 ), 38713 rtl: defaultValue(props.rtl, syncState == null ? void 0 : syncState.rtl, false), 38714 virtualFocus: defaultValue( 38715 props.virtualFocus, 38716 syncState == null ? void 0 : syncState.virtualFocus, 38717 false 38718 ), 38719 focusLoop: defaultValue(props.focusLoop, syncState == null ? void 0 : syncState.focusLoop, false), 38720 focusWrap: defaultValue(props.focusWrap, syncState == null ? void 0 : syncState.focusWrap, false), 38721 focusShift: defaultValue(props.focusShift, syncState == null ? void 0 : syncState.focusShift, false) 38722 }); 38723 const composite = createStore(initialState, collection, props.store); 38724 setup( 38725 composite, 38726 () => sync(composite, ["renderedItems", "activeId"], (state) => { 38727 composite.setState("activeId", (activeId2) => { 38728 var _a2; 38729 if (activeId2 !== void 0) 38730 return activeId2; 38731 return (_a2 = findFirstEnabledItem(state.renderedItems)) == null ? void 0 : _a2.id; 38732 }); 38733 }) 38734 ); 38735 const getNextId = (items, orientation, hasNullItem, skip) => { 38736 var _a2, _b; 38737 const { activeId: activeId2, rtl, focusLoop, focusWrap, includesBaseElement } = composite.getState(); 38738 const isHorizontal = orientation !== "vertical"; 38739 const isRTL = rtl && isHorizontal; 38740 const allItems = isRTL ? reverseArray(items) : items; 38741 if (activeId2 == null) { 38742 return (_a2 = findFirstEnabledItem(allItems)) == null ? void 0 : _a2.id; 38743 } 38744 const activeItem = allItems.find((item) => item.id === activeId2); 38745 if (!activeItem) { 38746 return (_b = findFirstEnabledItem(allItems)) == null ? void 0 : _b.id; 38747 } 38748 const isGrid = !!activeItem.rowId; 38749 const activeIndex = allItems.indexOf(activeItem); 38750 const nextItems = allItems.slice(activeIndex + 1); 38751 const nextItemsInRow = getItemsInRow(nextItems, activeItem.rowId); 38752 if (skip !== void 0) { 38753 const nextEnabledItemsInRow = getEnabledItems(nextItemsInRow, activeId2); 38754 const nextItem2 = nextEnabledItemsInRow.slice(skip)[0] || // If we can't find an item, just return the last one. 38755 nextEnabledItemsInRow[nextEnabledItemsInRow.length - 1]; 38756 return nextItem2 == null ? void 0 : nextItem2.id; 38757 } 38758 const oppositeOrientation = getOppositeOrientation( 38759 // If it's a grid and orientation is not set, it's a next/previous call, 38760 // which is inherently horizontal. up/down will call next with orientation 38761 // set to vertical by default (see below on up/down methods). 38762 isGrid ? orientation || "horizontal" : orientation 38763 ); 38764 const canLoop = focusLoop && focusLoop !== oppositeOrientation; 38765 const canWrap = isGrid && focusWrap && focusWrap !== oppositeOrientation; 38766 hasNullItem = hasNullItem || !isGrid && canLoop && includesBaseElement; 38767 if (canLoop) { 38768 const loopItems = canWrap && !hasNullItem ? allItems : getItemsInRow(allItems, activeItem.rowId); 38769 const sortedItems = flipItems(loopItems, activeId2, hasNullItem); 38770 const nextItem2 = findFirstEnabledItem(sortedItems, activeId2); 38771 return nextItem2 == null ? void 0 : nextItem2.id; 38772 } 38773 if (canWrap) { 38774 const nextItem2 = findFirstEnabledItem( 38775 // We can use nextItems, which contains all the next items, including 38776 // items from other rows, to wrap between rows. However, if there is a 38777 // null item (the composite container), we'll only use the next items in 38778 // the row. So moving next from the last item will focus on the 38779 // composite container. On grid composites, horizontal navigation never 38780 // focuses on the composite container, only vertical. 38781 hasNullItem ? nextItemsInRow : nextItems, 38782 activeId2 38783 ); 38784 const nextId = hasNullItem ? (nextItem2 == null ? void 0 : nextItem2.id) || null : nextItem2 == null ? void 0 : nextItem2.id; 38785 return nextId; 38786 } 38787 const nextItem = findFirstEnabledItem(nextItemsInRow, activeId2); 38788 if (!nextItem && hasNullItem) { 38789 return null; 38790 } 38791 return nextItem == null ? void 0 : nextItem.id; 38792 }; 38793 return _chunks_4R3V3JGP_spreadProps(_chunks_4R3V3JGP_spreadValues(_chunks_4R3V3JGP_spreadValues({}, collection), composite), { 38794 setBaseElement: (element) => composite.setState("baseElement", element), 38795 setActiveId: (id) => composite.setState("activeId", id), 38796 move: (id) => { 38797 if (id === void 0) 38798 return; 38799 composite.setState("activeId", id); 38800 composite.setState("moves", (moves) => moves + 1); 38801 }, 38802 first: () => { 38803 var _a2; 38804 return (_a2 = findFirstEnabledItem(composite.getState().renderedItems)) == null ? void 0 : _a2.id; 38805 }, 38806 last: () => { 38807 var _a2; 38808 return (_a2 = findFirstEnabledItem(reverseArray(composite.getState().renderedItems))) == null ? void 0 : _a2.id; 38809 }, 38810 next: (skip) => { 38811 const { renderedItems, orientation } = composite.getState(); 38812 return getNextId(renderedItems, orientation, false, skip); 38813 }, 38814 previous: (skip) => { 38815 var _a2; 38816 const { renderedItems, orientation, includesBaseElement } = composite.getState(); 38817 const isGrid = !!((_a2 = findFirstEnabledItem(renderedItems)) == null ? void 0 : _a2.rowId); 38818 const hasNullItem = !isGrid && includesBaseElement; 38819 return getNextId( 38820 reverseArray(renderedItems), 38821 orientation, 38822 hasNullItem, 38823 skip 38824 ); 38825 }, 38826 down: (skip) => { 38827 const { 38828 activeId: activeId2, 38829 renderedItems, 38830 focusShift, 38831 focusLoop, 38832 includesBaseElement 38833 } = composite.getState(); 38834 const shouldShift = focusShift && !skip; 38835 const verticalItems = verticalizeItems( 38836 flatten2DArray( 38837 normalizeRows(groupItemsByRows(renderedItems), activeId2, shouldShift) 38838 ) 38839 ); 38840 const canLoop = focusLoop && focusLoop !== "horizontal"; 38841 const hasNullItem = canLoop && includesBaseElement; 38842 return getNextId(verticalItems, "vertical", hasNullItem, skip); 38843 }, 38844 up: (skip) => { 38845 const { activeId: activeId2, renderedItems, focusShift, includesBaseElement } = composite.getState(); 38846 const shouldShift = focusShift && !skip; 38847 const verticalItems = verticalizeItems( 38848 reverseArray( 38849 flatten2DArray( 38850 normalizeRows( 38851 groupItemsByRows(renderedItems), 38852 activeId2, 38853 shouldShift 38854 ) 38855 ) 38856 ) 38857 ); 38858 const hasNullItem = includesBaseElement; 38859 return getNextId(verticalItems, "vertical", hasNullItem, skip); 38860 } 38861 }); 38862 } 38863 38864 38865 38866 ;// CONCATENATED MODULE: ./node_modules/@ariakit/core/esm/combobox/combobox-store.js 38867 "use client"; 38868 38869 38870 38871 38872 38873 38874 38875 38876 38877 38878 38879 38880 // src/combobox/combobox-store.ts 38881 var isSafariOnMobile = isSafari() && isTouchDevice(); 38882 function createComboboxStore(props = {}) { 38883 var _a; 38884 throwOnConflictingProps(props, props.store); 38885 const syncState = (_a = props.store) == null ? void 0 : _a.getState(); 38886 const activeId = defaultValue( 38887 props.activeId, 38888 syncState == null ? void 0 : syncState.activeId, 38889 props.defaultActiveId, 38890 null 38891 ); 38892 const composite = createCompositeStore(_chunks_4R3V3JGP_spreadProps(_chunks_4R3V3JGP_spreadValues({}, props), { 38893 activeId, 38894 includesBaseElement: defaultValue( 38895 props.includesBaseElement, 38896 syncState == null ? void 0 : syncState.includesBaseElement, 38897 true 38898 ), 38899 orientation: defaultValue( 38900 props.orientation, 38901 syncState == null ? void 0 : syncState.orientation, 38902 "vertical" 38903 ), 38904 focusLoop: defaultValue(props.focusLoop, syncState == null ? void 0 : syncState.focusLoop, true), 38905 focusWrap: defaultValue(props.focusWrap, syncState == null ? void 0 : syncState.focusWrap, true), 38906 virtualFocus: defaultValue( 38907 props.virtualFocus, 38908 syncState == null ? void 0 : syncState.virtualFocus, 38909 !isSafariOnMobile 38910 ) 38911 })); 38912 const popover = createPopoverStore(_chunks_4R3V3JGP_spreadProps(_chunks_4R3V3JGP_spreadValues({}, props), { 38913 placement: defaultValue( 38914 props.placement, 38915 syncState == null ? void 0 : syncState.placement, 38916 "bottom-start" 38917 ) 38918 })); 38919 const value = defaultValue( 38920 props.value, 38921 syncState == null ? void 0 : syncState.value, 38922 props.defaultValue, 38923 "" 38924 ); 38925 const selectedValue = defaultValue( 38926 props.selectedValue, 38927 syncState == null ? void 0 : syncState.selectedValue, 38928 props.defaultSelectedValue, 38929 "" 38930 ); 38931 const multiSelectable = Array.isArray(selectedValue); 38932 const initialState = _chunks_4R3V3JGP_spreadProps(_chunks_4R3V3JGP_spreadValues(_chunks_4R3V3JGP_spreadValues({}, composite.getState()), popover.getState()), { 38933 value, 38934 selectedValue, 38935 resetValueOnSelect: defaultValue( 38936 props.resetValueOnSelect, 38937 syncState == null ? void 0 : syncState.resetValueOnSelect, 38938 multiSelectable 38939 ), 38940 resetValueOnHide: defaultValue( 38941 props.resetValueOnHide, 38942 syncState == null ? void 0 : syncState.resetValueOnHide, 38943 multiSelectable 38944 ), 38945 activeValue: syncState == null ? void 0 : syncState.activeValue 38946 }); 38947 const combobox = createStore(initialState, composite, popover, props.store); 38948 setup( 38949 combobox, 38950 () => sync(combobox, ["resetValueOnHide", "mounted"], (state) => { 38951 if (!state.resetValueOnHide) 38952 return; 38953 if (state.mounted) 38954 return; 38955 combobox.setState("value", value); 38956 }) 38957 ); 38958 setup( 38959 combobox, 38960 () => sync(combobox, ["resetValueOnSelect", "selectedValue"], (state) => { 38961 if (!state.resetValueOnSelect) 38962 return; 38963 combobox.setState("value", value); 38964 }) 38965 ); 38966 setup( 38967 combobox, 38968 () => batch(combobox, ["mounted"], (state) => { 38969 if (state.mounted) 38970 return; 38971 combobox.setState("activeId", activeId); 38972 combobox.setState("moves", 0); 38973 }) 38974 ); 38975 setup( 38976 combobox, 38977 () => sync(combobox, ["moves", "activeId"], (state, prevState) => { 38978 if (state.moves === prevState.moves) { 38979 combobox.setState("activeValue", void 0); 38980 } 38981 }) 38982 ); 38983 setup( 38984 combobox, 38985 () => batch(combobox, ["moves", "renderedItems"], (state, prev) => { 38986 if (state.moves === prev.moves) 38987 return; 38988 const { activeId: activeId2 } = combobox.getState(); 38989 const activeItem = composite.item(activeId2); 38990 combobox.setState("activeValue", activeItem == null ? void 0 : activeItem.value); 38991 }) 38992 ); 38993 return _chunks_4R3V3JGP_spreadProps(_chunks_4R3V3JGP_spreadValues(_chunks_4R3V3JGP_spreadValues(_chunks_4R3V3JGP_spreadValues({}, popover), composite), combobox), { 38994 setValue: (value2) => combobox.setState("value", value2), 38995 setSelectedValue: (selectedValue2) => combobox.setState("selectedValue", selectedValue2) 38996 }); 38997 } 38998 38999 39000 ;// CONCATENATED MODULE: ./node_modules/@ariakit/react-core/esm/__chunks/ZKJ2WLF7.js 39001 "use client"; 39002 39003 39004 39005 39006 // src/combobox/combobox-store.ts 39007 39008 function useComboboxStoreProps(store, update, props) { 39009 store = usePopoverStoreProps(store, update, props); 39010 store = useCompositeStoreProps(store, update, props); 39011 useStoreProps(store, props, "value", "setValue"); 39012 useStoreProps(store, props, "selectedValue", "setSelectedValue"); 39013 useStoreProps(store, props, "resetValueOnHide"); 39014 useStoreProps(store, props, "resetValueOnSelect"); 39015 return store; 39016 } 39017 function useComboboxStore(props = {}) { 39018 const [store, update] = EKQEJRUF_useStore(createComboboxStore, props); 39019 return useComboboxStoreProps(store, update, props); 39020 } 39021 39022 39023 39024 // EXTERNAL MODULE: ./node_modules/react/jsx-runtime.js 39025 var jsx_runtime = __webpack_require__(4922); 39026 ;// CONCATENATED MODULE: ./node_modules/@ariakit/react-core/esm/__chunks/3ORBWXWF.js 39027 "use client"; 39028 39029 39030 39031 39032 // src/utils/system.tsx 39033 39034 39035 39036 function isRenderProp(children) { 39037 return typeof children === "function"; 39038 } 39039 function forwardRef2(render) { 39040 const Role = React.forwardRef((props, ref) => render(__spreadProps(__spreadValues({}, props), { ref }))); 39041 Role.displayName = render.displayName || render.name; 39042 return Role; 39043 } 39044 function memo2(Component, propsAreEqual) { 39045 const Role = React.memo(Component, propsAreEqual); 39046 Role.displayName = Component.displayName || Component.name; 39047 return Role; 39048 } 39049 function createComponent(render) { 39050 const Role = (props, ref) => render(_4R3V3JGP_spreadValues({ ref }, props)); 39051 return external_React_.forwardRef(Role); 39052 } 39053 function createMemoComponent(render) { 39054 const Role = createComponent(render); 39055 return external_React_.memo(Role); 39056 } 39057 function _3ORBWXWF_createElement(Type, props) { 39058 const _a = props, { as: As, wrapElement, render } = _a, rest = __objRest(_a, ["as", "wrapElement", "render"]); 39059 let element; 39060 const mergedRef = useMergeRefs(props.ref, getRefProperty(render)); 39061 if (false) {} 39062 if (As && typeof As !== "string") { 39063 element = /* @__PURE__ */ (0,jsx_runtime.jsx)(As, _4R3V3JGP_spreadProps(_4R3V3JGP_spreadValues({}, rest), { render })); 39064 } else if (external_React_.isValidElement(render)) { 39065 const renderProps = _4R3V3JGP_spreadProps(_4R3V3JGP_spreadValues({}, render.props), { ref: mergedRef }); 39066 element = external_React_.cloneElement(render, mergeProps(rest, renderProps)); 39067 } else if (render) { 39068 element = render(rest); 39069 } else if (isRenderProp(props.children)) { 39070 if (false) {} 39071 const _b = rest, { children } = _b, otherProps = __objRest(_b, ["children"]); 39072 element = props.children(otherProps); 39073 } else if (As) { 39074 element = /* @__PURE__ */ (0,jsx_runtime.jsx)(As, _4R3V3JGP_spreadValues({}, rest)); 39075 } else { 39076 element = /* @__PURE__ */ (0,jsx_runtime.jsx)(Type, _4R3V3JGP_spreadValues({}, rest)); 39077 } 39078 if (wrapElement) { 39079 return wrapElement(element); 39080 } 39081 return element; 39082 } 39083 function createHook(useProps) { 39084 const useRole = (props = {}) => { 39085 const htmlProps = useProps(props); 39086 const copy = {}; 39087 for (const prop in htmlProps) { 39088 if (Y3OOHFCN_hasOwnProperty(htmlProps, prop) && htmlProps[prop] !== void 0) { 39089 copy[prop] = htmlProps[prop]; 39090 } 39091 } 39092 return copy; 39093 }; 39094 return useRole; 39095 } 39096 function createStoreContext(providers = [], scopedProviders = []) { 39097 const context = external_React_.createContext(void 0); 39098 const scopedContext = external_React_.createContext(void 0); 39099 const useContext2 = () => external_React_.useContext(context); 39100 const useScopedContext = (onlyScoped = false) => { 39101 const scoped = external_React_.useContext(scopedContext); 39102 const store = useContext2(); 39103 if (onlyScoped) 39104 return scoped; 39105 return scoped || store; 39106 }; 39107 const useProviderContext = () => { 39108 const scoped = external_React_.useContext(scopedContext); 39109 const store = useContext2(); 39110 if (scoped && scoped === store) 39111 return; 39112 return store; 39113 }; 39114 const ContextProvider = (props) => { 39115 return providers.reduceRight( 39116 (children, Provider) => /* @__PURE__ */ (0,jsx_runtime.jsx)(Provider, _4R3V3JGP_spreadProps(_4R3V3JGP_spreadValues({}, props), { children })), 39117 /* @__PURE__ */ (0,jsx_runtime.jsx)(context.Provider, _4R3V3JGP_spreadValues({}, props)) 39118 ); 39119 }; 39120 const ScopedContextProvider = (props) => { 39121 return /* @__PURE__ */ (0,jsx_runtime.jsx)(ContextProvider, _4R3V3JGP_spreadProps(_4R3V3JGP_spreadValues({}, props), { children: scopedProviders.reduceRight( 39122 (children, Provider) => /* @__PURE__ */ (0,jsx_runtime.jsx)(Provider, _4R3V3JGP_spreadProps(_4R3V3JGP_spreadValues({}, props), { children })), 39123 /* @__PURE__ */ (0,jsx_runtime.jsx)(scopedContext.Provider, _4R3V3JGP_spreadValues({}, props)) 39124 ) })); 39125 }; 39126 return { 39127 context, 39128 scopedContext, 39129 useContext: useContext2, 39130 useScopedContext, 39131 useProviderContext, 39132 ContextProvider, 39133 ScopedContextProvider 39134 }; 39135 } 39136 39137 39138 39139 ;// CONCATENATED MODULE: ./node_modules/@ariakit/react-core/esm/__chunks/4UUKJZ4V.js 39140 "use client"; 39141 39142 39143 // src/collection/collection-context.tsx 39144 var ctx = createStoreContext(); 39145 var useCollectionContext = ctx.useContext; 39146 var useCollectionScopedContext = ctx.useScopedContext; 39147 var useCollectionProviderContext = ctx.useProviderContext; 39148 var CollectionContextProvider = ctx.ContextProvider; 39149 var CollectionScopedContextProvider = ctx.ScopedContextProvider; 39150 39151 39152 39153 ;// CONCATENATED MODULE: ./node_modules/@ariakit/react-core/esm/__chunks/IB7YUKH5.js 39154 "use client"; 39155 39156 39157 39158 // src/composite/composite-context.tsx 39159 39160 var IB7YUKH5_ctx = createStoreContext( 39161 [CollectionContextProvider], 39162 [CollectionScopedContextProvider] 39163 ); 39164 var useCompositeContext = IB7YUKH5_ctx.useContext; 39165 var useCompositeScopedContext = IB7YUKH5_ctx.useScopedContext; 39166 var useCompositeProviderContext = IB7YUKH5_ctx.useProviderContext; 39167 var CompositeContextProvider = IB7YUKH5_ctx.ContextProvider; 39168 var CompositeScopedContextProvider = IB7YUKH5_ctx.ScopedContextProvider; 39169 var CompositeItemContext = (0,external_React_.createContext)( 39170 void 0 39171 ); 39172 var CompositeRowContext = (0,external_React_.createContext)( 39173 void 0 39174 ); 39175 39176 39177 39178 ;// CONCATENATED MODULE: ./node_modules/@ariakit/react-core/esm/__chunks/OAYFXAQ2.js 39179 "use client"; 39180 39181 39182 // src/disclosure/disclosure-context.tsx 39183 var OAYFXAQ2_ctx = createStoreContext(); 39184 var useDisclosureContext = OAYFXAQ2_ctx.useContext; 39185 var useDisclosureScopedContext = OAYFXAQ2_ctx.useScopedContext; 39186 var useDisclosureProviderContext = OAYFXAQ2_ctx.useProviderContext; 39187 var DisclosureContextProvider = OAYFXAQ2_ctx.ContextProvider; 39188 var DisclosureScopedContextProvider = OAYFXAQ2_ctx.ScopedContextProvider; 39189 39190 39191 39192 ;// CONCATENATED MODULE: ./node_modules/@ariakit/react-core/esm/__chunks/G6BJYYBK.js 39193 "use client"; 39194 39195 39196 39197 // src/dialog/dialog-context.tsx 39198 39199 var G6BJYYBK_ctx = createStoreContext( 39200 [DisclosureContextProvider], 39201 [DisclosureScopedContextProvider] 39202 ); 39203 var useDialogContext = G6BJYYBK_ctx.useContext; 39204 var useDialogScopedContext = G6BJYYBK_ctx.useScopedContext; 39205 var useDialogProviderContext = G6BJYYBK_ctx.useProviderContext; 39206 var DialogContextProvider = G6BJYYBK_ctx.ContextProvider; 39207 var DialogScopedContextProvider = G6BJYYBK_ctx.ScopedContextProvider; 39208 var DialogHeadingContext = (0,external_React_.createContext)(void 0); 39209 var DialogDescriptionContext = (0,external_React_.createContext)(void 0); 39210 39211 39212 39213 ;// CONCATENATED MODULE: ./node_modules/@ariakit/react-core/esm/__chunks/7H5KSHHF.js 39214 "use client"; 39215 39216 39217 39218 // src/popover/popover-context.tsx 39219 var _7H5KSHHF_ctx = createStoreContext( 39220 [DialogContextProvider], 39221 [DialogScopedContextProvider] 39222 ); 39223 var usePopoverContext = _7H5KSHHF_ctx.useContext; 39224 var usePopoverScopedContext = _7H5KSHHF_ctx.useScopedContext; 39225 var usePopoverProviderContext = _7H5KSHHF_ctx.useProviderContext; 39226 var PopoverContextProvider = _7H5KSHHF_ctx.ContextProvider; 39227 var PopoverScopedContextProvider = _7H5KSHHF_ctx.ScopedContextProvider; 39228 39229 39230 39231 ;// CONCATENATED MODULE: ./node_modules/@ariakit/react-core/esm/__chunks/W76OTZCC.js 39232 "use client"; 39233 39234 39235 39236 39237 // src/combobox/combobox-context.tsx 39238 39239 var W76OTZCC_ctx = createStoreContext( 39240 [PopoverContextProvider, CompositeContextProvider], 39241 [PopoverScopedContextProvider, CompositeScopedContextProvider] 39242 ); 39243 var useComboboxContext = W76OTZCC_ctx.useContext; 39244 var useComboboxScopedContext = W76OTZCC_ctx.useScopedContext; 39245 var useComboboxProviderContext = W76OTZCC_ctx.useProviderContext; 39246 var ComboboxContextProvider = W76OTZCC_ctx.ContextProvider; 39247 var ComboboxScopedContextProvider = W76OTZCC_ctx.ScopedContextProvider; 39248 var ComboboxItemValueContext = (0,external_React_.createContext)( 39249 void 0 39250 ); 39251 var ComboboxItemCheckedContext = (0,external_React_.createContext)(false); 39252 39253 39254 39255 ;// CONCATENATED MODULE: ./node_modules/@ariakit/react-core/esm/combobox/combobox-provider.js 39256 "use client"; 39257 39258 39259 39260 39261 39262 39263 39264 39265 39266 39267 39268 39269 39270 39271 39272 39273 39274 39275 // src/combobox/combobox-provider.tsx 39276 39277 function ComboboxProvider(props = {}) { 39278 const store = useComboboxStore(props); 39279 return /* @__PURE__ */ (0,jsx_runtime.jsx)(ComboboxContextProvider, { value: store, children: props.children }); 39280 } 39281 39282 39283 ;// CONCATENATED MODULE: ./node_modules/@ariakit/react-core/esm/combobox/combobox-label.js 39284 "use client"; 39285 39286 39287 39288 39289 39290 39291 39292 39293 39294 39295 39296 // src/combobox/combobox-label.ts 39297 39298 var useComboboxLabel = createHook( 39299 (_a) => { 39300 var _b = _a, { store } = _b, props = __objRest(_b, ["store"]); 39301 const context = useComboboxProviderContext(); 39302 store = store || context; 39303 invariant( 39304 store, 39305 false && 0 39306 ); 39307 const comboboxId = store.useState((state) => { 39308 var _a2; 39309 return (_a2 = state.baseElement) == null ? void 0 : _a2.id; 39310 }); 39311 props = _4R3V3JGP_spreadValues({ 39312 htmlFor: comboboxId 39313 }, props); 39314 return props; 39315 } 39316 ); 39317 var ComboboxLabel = createMemoComponent( 39318 (props) => { 39319 const htmlProps = useComboboxLabel(props); 39320 return _3ORBWXWF_createElement("label", htmlProps); 39321 } 39322 ); 39323 if (false) {} 39324 39325 39326 ;// CONCATENATED MODULE: ./node_modules/@ariakit/react-core/esm/__chunks/JCH6MLL2.js 39327 "use client"; 39328 39329 39330 39331 39332 39333 // src/popover/popover-anchor.ts 39334 var usePopoverAnchor = createHook( 39335 (_a) => { 39336 var _b = _a, { store } = _b, props = __objRest(_b, ["store"]); 39337 const context = usePopoverProviderContext(); 39338 store = store || context; 39339 props = _4R3V3JGP_spreadProps(_4R3V3JGP_spreadValues({}, props), { 39340 ref: useMergeRefs(store == null ? void 0 : store.setAnchorElement, props.ref) 39341 }); 39342 return props; 39343 } 39344 ); 39345 var PopoverAnchor = createComponent((props) => { 39346 const htmlProps = usePopoverAnchor(props); 39347 return _3ORBWXWF_createElement("div", htmlProps); 39348 }); 39349 if (false) {} 39350 39351 39352 39353 ;// CONCATENATED MODULE: ./node_modules/@ariakit/react-core/esm/__chunks/3IEDWLST.js 39354 "use client"; 39355 39356 // src/composite/utils.ts 39357 39358 var _3IEDWLST_NULL_ITEM = { id: null }; 39359 function _3IEDWLST_flipItems(items, activeId, shouldInsertNullItem = false) { 39360 const index = items.findIndex((item) => item.id === activeId); 39361 return [ 39362 ...items.slice(index + 1), 39363 ...shouldInsertNullItem ? [_3IEDWLST_NULL_ITEM] : [], 39364 ...items.slice(0, index) 39365 ]; 39366 } 39367 function _3IEDWLST_findFirstEnabledItem(items, excludeId) { 39368 return items.find((item) => { 39369 if (excludeId) { 39370 return !item.disabled && item.id !== excludeId; 39371 } 39372 return !item.disabled; 39373 }); 39374 } 39375 function getEnabledItem(store, id) { 39376 if (!id) 39377 return null; 39378 return store.item(id) || null; 39379 } 39380 function _3IEDWLST_groupItemsByRows(items) { 39381 const rows = []; 39382 for (const item of items) { 39383 const row = rows.find((currentRow) => { 39384 var _a; 39385 return ((_a = currentRow[0]) == null ? void 0 : _a.rowId) === item.rowId; 39386 }); 39387 if (row) { 39388 row.push(item); 39389 } else { 39390 rows.push([item]); 39391 } 39392 } 39393 return rows; 39394 } 39395 function selectTextField(element, collapseToEnd = false) { 39396 if (isTextField(element)) { 39397 element.setSelectionRange( 39398 collapseToEnd ? element.value.length : 0, 39399 element.value.length 39400 ); 39401 } else if (element.isContentEditable) { 39402 const selection = getDocument(element).getSelection(); 39403 selection == null ? void 0 : selection.selectAllChildren(element); 39404 if (collapseToEnd) { 39405 selection == null ? void 0 : selection.collapseToEnd(); 39406 } 39407 } 39408 } 39409 var FOCUS_SILENTLY = Symbol("FOCUS_SILENTLY"); 39410 function focusSilently(element) { 39411 element[FOCUS_SILENTLY] = true; 39412 element.focus({ preventScroll: true }); 39413 } 39414 function silentlyFocused(element) { 39415 const isSilentlyFocused = element[FOCUS_SILENTLY]; 39416 delete element[FOCUS_SILENTLY]; 39417 return isSilentlyFocused; 39418 } 39419 function isItem(store, element, exclude) { 39420 if (!element) 39421 return false; 39422 if (element === exclude) 39423 return false; 39424 const item = store.item(element.id); 39425 if (!item) 39426 return false; 39427 if (exclude && item.element === exclude) 39428 return false; 39429 return true; 39430 } 39431 39432 39433 39434 ;// CONCATENATED MODULE: ./node_modules/@ariakit/react-core/esm/__chunks/SHA3WOPI.js 39435 "use client"; 39436 39437 // src/focusable/focusable-context.ts 39438 39439 var FocusableContext = (0,external_React_.createContext)(true); 39440 39441 39442 39443 ;// CONCATENATED MODULE: ./node_modules/@ariakit/core/esm/utils/focus.js 39444 "use client"; 39445 39446 39447 39448 // src/utils/focus.ts 39449 var selector = "input:not([type='hidden']):not([disabled]), select:not([disabled]), textarea:not([disabled]), a[href], button:not([disabled]), [tabindex], iframe, object, embed, area[href], audio[controls], video[controls], [contenteditable]:not([contenteditable='false'])"; 39450 function hasNegativeTabIndex(element) { 39451 const tabIndex = parseInt(element.getAttribute("tabindex") || "0", 10); 39452 return tabIndex < 0; 39453 } 39454 function isFocusable(element) { 39455 if (!matches(element, selector)) 39456 return false; 39457 if (!isVisible(element)) 39458 return false; 39459 if (DLOEKDPY_closest(element, "[inert]")) 39460 return false; 39461 return true; 39462 } 39463 function isTabbable(element) { 39464 if (!isFocusable(element)) 39465 return false; 39466 if (hasNegativeTabIndex(element)) 39467 return false; 39468 if (!("form" in element)) 39469 return true; 39470 if (!element.form) 39471 return true; 39472 if (element.checked) 39473 return true; 39474 if (element.type !== "radio") 39475 return true; 39476 const radioGroup = element.form.elements.namedItem(element.name); 39477 if (!radioGroup) 39478 return true; 39479 if (!("length" in radioGroup)) 39480 return true; 39481 const activeElement = getActiveElement(element); 39482 if (!activeElement) 39483 return true; 39484 if (activeElement === element) 39485 return true; 39486 if (!("form" in activeElement)) 39487 return true; 39488 if (activeElement.form !== element.form) 39489 return true; 39490 if (activeElement.name !== element.name) 39491 return true; 39492 return false; 39493 } 39494 function getAllFocusableIn(container, includeContainer) { 39495 const elements = Array.from( 39496 container.querySelectorAll(selector) 39497 ); 39498 if (includeContainer) { 39499 elements.unshift(container); 39500 } 39501 const focusableElements = elements.filter(isFocusable); 39502 focusableElements.forEach((element, i) => { 39503 if (isFrame(element) && element.contentDocument) { 39504 const frameBody = element.contentDocument.body; 39505 focusableElements.splice(i, 1, ...getAllFocusableIn(frameBody)); 39506 } 39507 }); 39508 return focusableElements; 39509 } 39510 function getAllFocusable(includeBody) { 39511 return getAllFocusableIn(document.body, includeBody); 39512 } 39513 function getFirstFocusableIn(container, includeContainer) { 39514 const [first] = getAllFocusableIn(container, includeContainer); 39515 return first || null; 39516 } 39517 function getFirstFocusable(includeBody) { 39518 return getFirstFocusableIn(document.body, includeBody); 39519 } 39520 function getAllTabbableIn(container, includeContainer, fallbackToFocusable) { 39521 const elements = Array.from( 39522 container.querySelectorAll(selector) 39523 ); 39524 const tabbableElements = elements.filter(isTabbable); 39525 if (includeContainer && isTabbable(container)) { 39526 tabbableElements.unshift(container); 39527 } 39528 tabbableElements.forEach((element, i) => { 39529 if (isFrame(element) && element.contentDocument) { 39530 const frameBody = element.contentDocument.body; 39531 const allFrameTabbable = getAllTabbableIn( 39532 frameBody, 39533 false, 39534 fallbackToFocusable 39535 ); 39536 tabbableElements.splice(i, 1, ...allFrameTabbable); 39537 } 39538 }); 39539 if (!tabbableElements.length && fallbackToFocusable) { 39540 return elements; 39541 } 39542 return tabbableElements; 39543 } 39544 function getAllTabbable(fallbackToFocusable) { 39545 return getAllTabbableIn(document.body, false, fallbackToFocusable); 39546 } 39547 function getFirstTabbableIn(container, includeContainer, fallbackToFocusable) { 39548 const [first] = getAllTabbableIn( 39549 container, 39550 includeContainer, 39551 fallbackToFocusable 39552 ); 39553 return first || null; 39554 } 39555 function getFirstTabbable(fallbackToFocusable) { 39556 return getFirstTabbableIn(document.body, false, fallbackToFocusable); 39557 } 39558 function getLastTabbableIn(container, includeContainer, fallbackToFocusable) { 39559 const allTabbable = getAllTabbableIn( 39560 container, 39561 includeContainer, 39562 fallbackToFocusable 39563 ); 39564 return allTabbable[allTabbable.length - 1] || null; 39565 } 39566 function getLastTabbable(fallbackToFocusable) { 39567 return getLastTabbableIn(document.body, false, fallbackToFocusable); 39568 } 39569 function getNextTabbableIn(container, includeContainer, fallbackToFirst, fallbackToFocusable) { 39570 const activeElement = getActiveElement(container); 39571 const allFocusable = getAllFocusableIn(container, includeContainer); 39572 const activeIndex = allFocusable.indexOf(activeElement); 39573 const nextFocusableElements = allFocusable.slice(activeIndex + 1); 39574 return nextFocusableElements.find(isTabbable) || (fallbackToFirst ? allFocusable.find(isTabbable) : null) || (fallbackToFocusable ? nextFocusableElements[0] : null) || null; 39575 } 39576 function getNextTabbable(fallbackToFirst, fallbackToFocusable) { 39577 return getNextTabbableIn( 39578 document.body, 39579 false, 39580 fallbackToFirst, 39581 fallbackToFocusable 39582 ); 39583 } 39584 function getPreviousTabbableIn(container, includeContainer, fallbackToLast, fallbackToFocusable) { 39585 const activeElement = getActiveElement(container); 39586 const allFocusable = getAllFocusableIn(container, includeContainer).reverse(); 39587 const activeIndex = allFocusable.indexOf(activeElement); 39588 const previousFocusableElements = allFocusable.slice(activeIndex + 1); 39589 return previousFocusableElements.find(isTabbable) || (fallbackToLast ? allFocusable.find(isTabbable) : null) || (fallbackToFocusable ? previousFocusableElements[0] : null) || null; 39590 } 39591 function getPreviousTabbable(fallbackToFirst, fallbackToFocusable) { 39592 return getPreviousTabbableIn( 39593 document.body, 39594 false, 39595 fallbackToFirst, 39596 fallbackToFocusable 39597 ); 39598 } 39599 function getClosestFocusable(element) { 39600 while (element && !isFocusable(element)) { 39601 element = closest(element, selector); 39602 } 39603 return element || null; 39604 } 39605 function hasFocus(element) { 39606 const activeElement = DLOEKDPY_getActiveElement(element); 39607 if (!activeElement) 39608 return false; 39609 if (activeElement === element) 39610 return true; 39611 const activeDescendant = activeElement.getAttribute("aria-activedescendant"); 39612 if (!activeDescendant) 39613 return false; 39614 return activeDescendant === element.id; 39615 } 39616 function hasFocusWithin(element) { 39617 const activeElement = DLOEKDPY_getActiveElement(element); 39618 if (!activeElement) 39619 return false; 39620 if (contains(element, activeElement)) 39621 return true; 39622 const activeDescendant = activeElement.getAttribute("aria-activedescendant"); 39623 if (!activeDescendant) 39624 return false; 39625 if (!("id" in element)) 39626 return false; 39627 if (activeDescendant === element.id) 39628 return true; 39629 return !!element.querySelector(`#$CSS.escape(activeDescendant)}`); 39630 } 39631 function focusIfNeeded(element) { 39632 if (!hasFocusWithin(element) && isFocusable(element)) { 39633 element.focus(); 39634 } 39635 } 39636 function disableFocus(element) { 39637 var _a; 39638 const currentTabindex = (_a = element.getAttribute("tabindex")) != null ? _a : ""; 39639 element.setAttribute("data-tabindex", currentTabindex); 39640 element.setAttribute("tabindex", "-1"); 39641 } 39642 function disableFocusIn(container, includeContainer) { 39643 const tabbableElements = getAllTabbableIn(container, includeContainer); 39644 tabbableElements.forEach(disableFocus); 39645 } 39646 function restoreFocusIn(container) { 39647 const elements = container.querySelectorAll("[data-tabindex]"); 39648 const restoreTabIndex = (element) => { 39649 const tabindex = element.getAttribute("data-tabindex"); 39650 element.removeAttribute("data-tabindex"); 39651 if (tabindex) { 39652 element.setAttribute("tabindex", tabindex); 39653 } else { 39654 element.removeAttribute("tabindex"); 39655 } 39656 }; 39657 if (container.hasAttribute("data-tabindex")) { 39658 restoreTabIndex(container); 39659 } 39660 elements.forEach(restoreTabIndex); 39661 } 39662 function focusIntoView(element, options) { 39663 if (!("scrollIntoView" in element)) { 39664 element.focus(); 39665 } else { 39666 element.focus({ preventScroll: true }); 39667 element.scrollIntoView(_chunks_4R3V3JGP_spreadValues({ block: "nearest", inline: "nearest" }, options)); 39668 } 39669 } 39670 39671 39672 ;// CONCATENATED MODULE: ./node_modules/@ariakit/react-core/esm/__chunks/KK7H3W2B.js 39673 "use client"; 39674 39675 39676 39677 39678 39679 // src/focusable/focusable.ts 39680 39681 39682 39683 39684 39685 39686 var isSafariBrowser = isSafari(); 39687 var alwaysFocusVisibleInputTypes = [ 39688 "text", 39689 "search", 39690 "url", 39691 "tel", 39692 "email", 39693 "password", 39694 "number", 39695 "date", 39696 "month", 39697 "week", 39698 "time", 39699 "datetime", 39700 "datetime-local" 39701 ]; 39702 function isAlwaysFocusVisible(element) { 39703 const { tagName, readOnly, type } = element; 39704 if (tagName === "TEXTAREA" && !readOnly) 39705 return true; 39706 if (tagName === "SELECT" && !readOnly) 39707 return true; 39708 if (tagName === "INPUT" && !readOnly) { 39709 return alwaysFocusVisibleInputTypes.includes(type); 39710 } 39711 if (element.isContentEditable) 39712 return true; 39713 return false; 39714 } 39715 function isAlwaysFocusVisibleDelayed(element) { 39716 const role = element.getAttribute("role"); 39717 if (role !== "combobox") 39718 return false; 39719 return !!element.dataset.name; 39720 } 39721 function getLabels(element) { 39722 if ("labels" in element) { 39723 return element.labels; 39724 } 39725 return null; 39726 } 39727 function isNativeCheckboxOrRadio(element) { 39728 const tagName = element.tagName.toLowerCase(); 39729 if (tagName === "input" && element.type) { 39730 return element.type === "radio" || element.type === "checkbox"; 39731 } 39732 return false; 39733 } 39734 function isNativeTabbable(tagName) { 39735 if (!tagName) 39736 return true; 39737 return tagName === "button" || tagName === "input" || tagName === "select" || tagName === "textarea" || tagName === "a"; 39738 } 39739 function supportsDisabledAttribute(tagName) { 39740 if (!tagName) 39741 return true; 39742 return tagName === "button" || tagName === "input" || tagName === "select" || tagName === "textarea"; 39743 } 39744 function getTabIndex(focusable, trulyDisabled, nativeTabbable, supportsDisabled, tabIndexProp) { 39745 if (!focusable) { 39746 return tabIndexProp; 39747 } 39748 if (trulyDisabled) { 39749 if (nativeTabbable && !supportsDisabled) { 39750 return -1; 39751 } 39752 return; 39753 } 39754 if (nativeTabbable) { 39755 return tabIndexProp; 39756 } 39757 return tabIndexProp || 0; 39758 } 39759 function useDisableEvent(onEvent, disabled) { 39760 return useEvent((event) => { 39761 onEvent == null ? void 0 : onEvent(event); 39762 if (event.defaultPrevented) 39763 return; 39764 if (disabled) { 39765 event.stopPropagation(); 39766 event.preventDefault(); 39767 } 39768 }); 39769 } 39770 var isKeyboardModality = true; 39771 function onGlobalMouseDown(event) { 39772 const target = event.target; 39773 if (target && "hasAttribute" in target) { 39774 if (!target.hasAttribute("data-focus-visible")) { 39775 isKeyboardModality = false; 39776 } 39777 } 39778 } 39779 function onGlobalKeyDown(event) { 39780 if (event.metaKey) 39781 return; 39782 if (event.ctrlKey) 39783 return; 39784 if (event.altKey) 39785 return; 39786 isKeyboardModality = true; 39787 } 39788 var useFocusable = createHook( 39789 (_a) => { 39790 var _b = _a, { 39791 focusable = true, 39792 accessibleWhenDisabled, 39793 autoFocus, 39794 onFocusVisible 39795 } = _b, props = __objRest(_b, [ 39796 "focusable", 39797 "accessibleWhenDisabled", 39798 "autoFocus", 39799 "onFocusVisible" 39800 ]); 39801 const ref = (0,external_React_.useRef)(null); 39802 (0,external_React_.useEffect)(() => { 39803 if (!focusable) 39804 return; 39805 addGlobalEventListener("mousedown", onGlobalMouseDown, true); 39806 addGlobalEventListener("keydown", onGlobalKeyDown, true); 39807 }, [focusable]); 39808 if (isSafariBrowser) { 39809 (0,external_React_.useEffect)(() => { 39810 if (!focusable) 39811 return; 39812 const element = ref.current; 39813 if (!element) 39814 return; 39815 if (!isNativeCheckboxOrRadio(element)) 39816 return; 39817 const labels = getLabels(element); 39818 if (!labels) 39819 return; 39820 const onMouseUp = () => queueMicrotask(() => element.focus()); 39821 labels.forEach((label) => label.addEventListener("mouseup", onMouseUp)); 39822 return () => { 39823 labels.forEach( 39824 (label) => label.removeEventListener("mouseup", onMouseUp) 39825 ); 39826 }; 39827 }, [focusable]); 39828 } 39829 const disabled = focusable && disabledFromProps(props); 39830 const trulyDisabled = !!disabled && !accessibleWhenDisabled; 39831 const [focusVisible, setFocusVisible] = (0,external_React_.useState)(false); 39832 (0,external_React_.useEffect)(() => { 39833 if (!focusable) 39834 return; 39835 if (trulyDisabled && focusVisible) { 39836 setFocusVisible(false); 39837 } 39838 }, [focusable, trulyDisabled, focusVisible]); 39839 (0,external_React_.useEffect)(() => { 39840 if (!focusable) 39841 return; 39842 if (!focusVisible) 39843 return; 39844 const element = ref.current; 39845 if (!element) 39846 return; 39847 if (typeof IntersectionObserver === "undefined") 39848 return; 39849 const observer = new IntersectionObserver(() => { 39850 if (!isFocusable(element)) { 39851 setFocusVisible(false); 39852 } 39853 }); 39854 observer.observe(element); 39855 return () => observer.disconnect(); 39856 }, [focusable, focusVisible]); 39857 const onKeyPressCapture = useDisableEvent( 39858 props.onKeyPressCapture, 39859 disabled 39860 ); 39861 const onMouseDownCapture = useDisableEvent( 39862 props.onMouseDownCapture, 39863 disabled 39864 ); 39865 const onClickCapture = useDisableEvent(props.onClickCapture, disabled); 39866 const onMouseDownProp = props.onMouseDown; 39867 const onMouseDown = useEvent((event) => { 39868 onMouseDownProp == null ? void 0 : onMouseDownProp(event); 39869 if (event.defaultPrevented) 39870 return; 39871 if (!focusable) 39872 return; 39873 const element = event.currentTarget; 39874 if (!isSafariBrowser) 39875 return; 39876 if (isPortalEvent(event)) 39877 return; 39878 if (!isButton(element) && !isNativeCheckboxOrRadio(element)) 39879 return; 39880 let receivedFocus = false; 39881 const onFocus = () => { 39882 receivedFocus = true; 39883 }; 39884 const options = { capture: true, once: true }; 39885 element.addEventListener("focusin", onFocus, options); 39886 queueBeforeEvent(element, "mouseup", () => { 39887 element.removeEventListener("focusin", onFocus, true); 39888 if (receivedFocus) 39889 return; 39890 focusIfNeeded(element); 39891 }); 39892 }); 39893 const handleFocusVisible = (event, currentTarget) => { 39894 if (currentTarget) { 39895 event.currentTarget = currentTarget; 39896 } 39897 if (!focusable) 39898 return; 39899 const element = event.currentTarget; 39900 if (!element) 39901 return; 39902 if (!hasFocus(element)) 39903 return; 39904 onFocusVisible == null ? void 0 : onFocusVisible(event); 39905 if (event.defaultPrevented) 39906 return; 39907 setFocusVisible(true); 39908 }; 39909 const onKeyDownCaptureProp = props.onKeyDownCapture; 39910 const onKeyDownCapture = useEvent( 39911 (event) => { 39912 onKeyDownCaptureProp == null ? void 0 : onKeyDownCaptureProp(event); 39913 if (event.defaultPrevented) 39914 return; 39915 if (!focusable) 39916 return; 39917 if (focusVisible) 39918 return; 39919 if (event.metaKey) 39920 return; 39921 if (event.altKey) 39922 return; 39923 if (event.ctrlKey) 39924 return; 39925 if (!isSelfTarget(event)) 39926 return; 39927 const element = event.currentTarget; 39928 queueMicrotask(() => handleFocusVisible(event, element)); 39929 } 39930 ); 39931 const onFocusCaptureProp = props.onFocusCapture; 39932 const onFocusCapture = useEvent((event) => { 39933 onFocusCaptureProp == null ? void 0 : onFocusCaptureProp(event); 39934 if (event.defaultPrevented) 39935 return; 39936 if (!focusable) 39937 return; 39938 if (!isSelfTarget(event)) { 39939 setFocusVisible(false); 39940 return; 39941 } 39942 const element = event.currentTarget; 39943 const applyFocusVisible = () => handleFocusVisible(event, element); 39944 if (isKeyboardModality || isAlwaysFocusVisible(event.target)) { 39945 queueMicrotask(applyFocusVisible); 39946 } else if (isAlwaysFocusVisibleDelayed(event.target)) { 39947 queueBeforeEvent(event.target, "focusout", applyFocusVisible); 39948 } else { 39949 setFocusVisible(false); 39950 } 39951 }); 39952 const onBlurProp = props.onBlur; 39953 const onBlur = useEvent((event) => { 39954 onBlurProp == null ? void 0 : onBlurProp(event); 39955 if (!focusable) 39956 return; 39957 if (!isFocusEventOutside(event)) 39958 return; 39959 setFocusVisible(false); 39960 }); 39961 const autoFocusOnShow = (0,external_React_.useContext)(FocusableContext); 39962 const autoFocusRef = useEvent((element) => { 39963 if (!focusable) 39964 return; 39965 if (!autoFocus) 39966 return; 39967 if (!element) 39968 return; 39969 if (!autoFocusOnShow) 39970 return; 39971 queueMicrotask(() => { 39972 if (hasFocus(element)) 39973 return; 39974 if (!isFocusable(element)) 39975 return; 39976 element.focus(); 39977 }); 39978 }); 39979 const tagName = useTagName(ref, props.as); 39980 const nativeTabbable = focusable && isNativeTabbable(tagName); 39981 const supportsDisabled = focusable && supportsDisabledAttribute(tagName); 39982 const style = trulyDisabled ? _4R3V3JGP_spreadValues({ pointerEvents: "none" }, props.style) : props.style; 39983 props = _4R3V3JGP_spreadProps(_4R3V3JGP_spreadValues({ 39984 "data-focus-visible": focusable && focusVisible ? "" : void 0, 39985 "data-autofocus": autoFocus ? true : void 0, 39986 "aria-disabled": disabled ? true : void 0 39987 }, props), { 39988 ref: useMergeRefs(ref, autoFocusRef, props.ref), 39989 style, 39990 tabIndex: getTabIndex( 39991 focusable, 39992 trulyDisabled, 39993 nativeTabbable, 39994 supportsDisabled, 39995 props.tabIndex 39996 ), 39997 disabled: supportsDisabled && trulyDisabled ? true : void 0, 39998 // TODO: Test Focusable contentEditable. 39999 contentEditable: disabled ? void 0 : props.contentEditable, 40000 onKeyPressCapture, 40001 onClickCapture, 40002 onMouseDownCapture, 40003 onMouseDown, 40004 onKeyDownCapture, 40005 onFocusCapture, 40006 onBlur 40007 }); 40008 return props; 40009 } 40010 ); 40011 var Focusable = createComponent((props) => { 40012 props = useFocusable(props); 40013 return _3ORBWXWF_createElement("div", props); 40014 }); 40015 if (false) {} 40016 40017 40018 40019 ;// CONCATENATED MODULE: ./node_modules/@ariakit/react-core/esm/__chunks/7QTPYGNZ.js 40020 "use client"; 40021 40022 40023 40024 40025 40026 40027 40028 // src/composite/composite.tsx 40029 40030 40031 40032 40033 40034 40035 40036 function isGrid(items) { 40037 return items.some((item) => !!item.rowId); 40038 } 40039 function isPrintableKey(event) { 40040 const target = event.target; 40041 if (target && !DLOEKDPY_isTextField(target)) 40042 return false; 40043 return event.key.length === 1 && !event.ctrlKey && !event.metaKey; 40044 } 40045 function isModifierKey(event) { 40046 return event.key === "Shift" || event.key === "Control" || event.key === "Alt" || event.key === "Meta"; 40047 } 40048 function useKeyboardEventProxy(store, onKeyboardEvent, previousElementRef) { 40049 return useEvent((event) => { 40050 var _a; 40051 onKeyboardEvent == null ? void 0 : onKeyboardEvent(event); 40052 if (event.defaultPrevented) 40053 return; 40054 if (event.isPropagationStopped()) 40055 return; 40056 if (!isSelfTarget(event)) 40057 return; 40058 if (isModifierKey(event)) 40059 return; 40060 if (isPrintableKey(event)) 40061 return; 40062 const state = store.getState(); 40063 const activeElement = (_a = getEnabledItem(store, state.activeId)) == null ? void 0 : _a.element; 40064 if (!activeElement) 40065 return; 40066 const _b = event, { view } = _b, eventInit = __objRest(_b, ["view"]); 40067 const previousElement = previousElementRef == null ? void 0 : previousElementRef.current; 40068 if (activeElement !== previousElement) { 40069 activeElement.focus(); 40070 } 40071 if (!fireKeyboardEvent(activeElement, event.type, eventInit)) { 40072 event.preventDefault(); 40073 } 40074 if (event.currentTarget.contains(activeElement)) { 40075 event.stopPropagation(); 40076 } 40077 }); 40078 } 40079 function findFirstEnabledItemInTheLastRow(items) { 40080 return _3IEDWLST_findFirstEnabledItem( 40081 flatten2DArray(reverseArray(_3IEDWLST_groupItemsByRows(items))) 40082 ); 40083 } 40084 function useScheduleFocus(store) { 40085 const [scheduled, setScheduled] = (0,external_React_.useState)(false); 40086 const schedule = (0,external_React_.useCallback)(() => setScheduled(true), []); 40087 const activeItem = store.useState( 40088 (state) => getEnabledItem(store, state.activeId) 40089 ); 40090 (0,external_React_.useEffect)(() => { 40091 const activeElement = activeItem == null ? void 0 : activeItem.element; 40092 if (!scheduled) 40093 return; 40094 if (!activeElement) 40095 return; 40096 setScheduled(false); 40097 activeElement.focus({ preventScroll: true }); 40098 }, [activeItem, scheduled]); 40099 return schedule; 40100 } 40101 var useComposite = createHook( 40102 (_a) => { 40103 var _b = _a, { 40104 store, 40105 composite = true, 40106 focusOnMove = composite, 40107 moveOnKeyPress = true 40108 } = _b, props = __objRest(_b, [ 40109 "store", 40110 "composite", 40111 "focusOnMove", 40112 "moveOnKeyPress" 40113 ]); 40114 const context = useCompositeProviderContext(); 40115 store = store || context; 40116 invariant( 40117 store, 40118 false && 0 40119 ); 40120 const previousElementRef = (0,external_React_.useRef)(null); 40121 const scheduleFocus = useScheduleFocus(store); 40122 const moves = store.useState("moves"); 40123 (0,external_React_.useEffect)(() => { 40124 var _a2; 40125 if (!store) 40126 return; 40127 if (!moves) 40128 return; 40129 if (!composite) 40130 return; 40131 if (!focusOnMove) 40132 return; 40133 const { activeId: activeId2 } = store.getState(); 40134 const itemElement = (_a2 = getEnabledItem(store, activeId2)) == null ? void 0 : _a2.element; 40135 if (!itemElement) 40136 return; 40137 focusIntoView(itemElement); 40138 }, [store, moves, composite, focusOnMove]); 40139 useSafeLayoutEffect(() => { 40140 if (!store) 40141 return; 40142 if (!moves) 40143 return; 40144 if (!composite) 40145 return; 40146 const { baseElement, activeId: activeId2 } = store.getState(); 40147 const isSelfAcive = activeId2 === null; 40148 if (!isSelfAcive) 40149 return; 40150 if (!baseElement) 40151 return; 40152 const previousElement = previousElementRef.current; 40153 previousElementRef.current = null; 40154 if (previousElement) { 40155 fireBlurEvent(previousElement, { relatedTarget: baseElement }); 40156 } 40157 if (!hasFocus(baseElement)) { 40158 baseElement.focus(); 40159 } 40160 }, [store, moves, composite]); 40161 const activeId = store.useState("activeId"); 40162 const virtualFocus = store.useState("virtualFocus"); 40163 useSafeLayoutEffect(() => { 40164 var _a2; 40165 if (!store) 40166 return; 40167 if (!composite) 40168 return; 40169 if (!virtualFocus) 40170 return; 40171 const previousElement = previousElementRef.current; 40172 previousElementRef.current = null; 40173 if (!previousElement) 40174 return; 40175 const activeElement = (_a2 = getEnabledItem(store, activeId)) == null ? void 0 : _a2.element; 40176 const relatedTarget = activeElement || DLOEKDPY_getActiveElement(previousElement); 40177 if (relatedTarget === previousElement) 40178 return; 40179 fireBlurEvent(previousElement, { relatedTarget }); 40180 }, [store, activeId, virtualFocus, composite]); 40181 const onKeyDownCapture = useKeyboardEventProxy( 40182 store, 40183 props.onKeyDownCapture, 40184 previousElementRef 40185 ); 40186 const onKeyUpCapture = useKeyboardEventProxy( 40187 store, 40188 props.onKeyUpCapture, 40189 previousElementRef 40190 ); 40191 const onFocusCaptureProp = props.onFocusCapture; 40192 const onFocusCapture = useEvent((event) => { 40193 onFocusCaptureProp == null ? void 0 : onFocusCaptureProp(event); 40194 if (event.defaultPrevented) 40195 return; 40196 if (!store) 40197 return; 40198 const { virtualFocus: virtualFocus2 } = store.getState(); 40199 if (!virtualFocus2) 40200 return; 40201 const previousActiveElement = event.relatedTarget; 40202 const isSilentlyFocused = silentlyFocused(event.currentTarget); 40203 if (isSelfTarget(event) && isSilentlyFocused) { 40204 event.stopPropagation(); 40205 previousElementRef.current = previousActiveElement; 40206 } 40207 }); 40208 const onFocusProp = props.onFocus; 40209 const onFocus = useEvent((event) => { 40210 onFocusProp == null ? void 0 : onFocusProp(event); 40211 if (event.defaultPrevented) 40212 return; 40213 if (!composite) 40214 return; 40215 if (!store) 40216 return; 40217 const { relatedTarget } = event; 40218 const { virtualFocus: virtualFocus2 } = store.getState(); 40219 if (virtualFocus2) { 40220 if (isSelfTarget(event) && !isItem(store, relatedTarget)) { 40221 queueMicrotask(scheduleFocus); 40222 } 40223 } else if (isSelfTarget(event)) { 40224 store.setActiveId(null); 40225 } 40226 }); 40227 const onBlurCaptureProp = props.onBlurCapture; 40228 const onBlurCapture = useEvent((event) => { 40229 var _a2; 40230 onBlurCaptureProp == null ? void 0 : onBlurCaptureProp(event); 40231 if (event.defaultPrevented) 40232 return; 40233 if (!store) 40234 return; 40235 const { virtualFocus: virtualFocus2, activeId: activeId2 } = store.getState(); 40236 if (!virtualFocus2) 40237 return; 40238 const activeElement = (_a2 = getEnabledItem(store, activeId2)) == null ? void 0 : _a2.element; 40239 const nextActiveElement = event.relatedTarget; 40240 const nextActiveElementIsItem = isItem(store, nextActiveElement); 40241 const previousElement = previousElementRef.current; 40242 previousElementRef.current = null; 40243 if (isSelfTarget(event) && nextActiveElementIsItem) { 40244 if (nextActiveElement === activeElement) { 40245 if (previousElement && previousElement !== nextActiveElement) { 40246 fireBlurEvent(previousElement, event); 40247 } 40248 } else if (activeElement) { 40249 fireBlurEvent(activeElement, event); 40250 } else if (previousElement) { 40251 fireBlurEvent(previousElement, event); 40252 } 40253 event.stopPropagation(); 40254 } else { 40255 const targetIsItem = isItem(store, event.target); 40256 if (!targetIsItem && activeElement) { 40257 fireBlurEvent(activeElement, event); 40258 } 40259 } 40260 }); 40261 const onKeyDownProp = props.onKeyDown; 40262 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress); 40263 const onKeyDown = useEvent((event) => { 40264 var _a2; 40265 onKeyDownProp == null ? void 0 : onKeyDownProp(event); 40266 if (event.defaultPrevented) 40267 return; 40268 if (!store) 40269 return; 40270 if (!isSelfTarget(event)) 40271 return; 40272 const { orientation, items, renderedItems, activeId: activeId2 } = store.getState(); 40273 const activeItem = getEnabledItem(store, activeId2); 40274 if ((_a2 = activeItem == null ? void 0 : activeItem.element) == null ? void 0 : _a2.isConnected) 40275 return; 40276 const isVertical = orientation !== "horizontal"; 40277 const isHorizontal = orientation !== "vertical"; 40278 const grid = isGrid(renderedItems); 40279 const isHorizontalKey = event.key === "ArrowLeft" || event.key === "ArrowRight" || event.key === "Home" || event.key === "End"; 40280 if (isHorizontalKey && DLOEKDPY_isTextField(event.currentTarget)) 40281 return; 40282 const up = () => { 40283 if (grid) { 40284 const item = items && findFirstEnabledItemInTheLastRow(items); 40285 return item == null ? void 0 : item.id; 40286 } 40287 return store == null ? void 0 : store.last(); 40288 }; 40289 const keyMap = { 40290 ArrowUp: (grid || isVertical) && up, 40291 ArrowRight: (grid || isHorizontal) && store.first, 40292 ArrowDown: (grid || isVertical) && store.first, 40293 ArrowLeft: (grid || isHorizontal) && store.last, 40294 Home: store.first, 40295 End: store.last, 40296 PageUp: store.first, 40297 PageDown: store.last 40298 }; 40299 const action = keyMap[event.key]; 40300 if (action) { 40301 const id = action(); 40302 if (id !== void 0) { 40303 if (!moveOnKeyPressProp(event)) 40304 return; 40305 event.preventDefault(); 40306 store.move(id); 40307 } 40308 } 40309 }); 40310 props = useWrapElement( 40311 props, 40312 (element) => /* @__PURE__ */ (0,jsx_runtime.jsx)(CompositeContextProvider, { value: store, children: element }), 40313 [store] 40314 ); 40315 const activeDescendant = store.useState((state) => { 40316 var _a2; 40317 if (!store) 40318 return; 40319 if (!composite) 40320 return; 40321 if (!state.virtualFocus) 40322 return; 40323 return (_a2 = getEnabledItem(store, state.activeId)) == null ? void 0 : _a2.id; 40324 }); 40325 props = _4R3V3JGP_spreadProps(_4R3V3JGP_spreadValues({ 40326 "aria-activedescendant": activeDescendant 40327 }, props), { 40328 ref: useMergeRefs(composite ? store.setBaseElement : null, props.ref), 40329 onKeyDownCapture, 40330 onKeyUpCapture, 40331 onFocusCapture, 40332 onFocus, 40333 onBlurCapture, 40334 onKeyDown 40335 }); 40336 const focusable = store.useState( 40337 (state) => composite && (state.virtualFocus || state.activeId === null) 40338 ); 40339 props = useFocusable(_4R3V3JGP_spreadValues({ focusable }, props)); 40340 return props; 40341 } 40342 ); 40343 var _7QTPYGNZ_Composite = createComponent((props) => { 40344 const htmlProps = useComposite(props); 40345 return _3ORBWXWF_createElement("div", htmlProps); 40346 }); 40347 if (false) {} 40348 40349 40350 40351 ;// CONCATENATED MODULE: external "ReactDOM" 40352 const external_ReactDOM_namespaceObject = window["ReactDOM"]; 40353 ;// CONCATENATED MODULE: ./node_modules/@ariakit/react-core/esm/combobox/combobox.js 40354 "use client"; 40355 40356 40357 40358 40359 40360 40361 40362 40363 40364 40365 40366 40367 40368 40369 40370 40371 // src/combobox/combobox.ts 40372 40373 40374 40375 40376 40377 40378 function isFirstItemAutoSelected(items, activeValue, autoSelect) { 40379 if (!autoSelect) 40380 return false; 40381 const firstItem = items.find((item) => !item.disabled && item.value); 40382 return (firstItem == null ? void 0 : firstItem.value) === activeValue; 40383 } 40384 function hasCompletionString(value, activeValue) { 40385 if (!activeValue) 40386 return false; 40387 if (value == null) 40388 return false; 40389 value = normalizeString(value); 40390 return activeValue.length > value.length && activeValue.toLowerCase().indexOf(value.toLowerCase()) === 0; 40391 } 40392 function isInputEvent(event) { 40393 return event.type === "input"; 40394 } 40395 function isAriaAutoCompleteValue(value) { 40396 return value === "inline" || value === "list" || value === "both" || value === "none"; 40397 } 40398 var useCombobox = createHook( 40399 (_a) => { 40400 var _b = _a, { 40401 store, 40402 focusable = true, 40403 autoSelect: autoSelectProp = false, 40404 getAutoSelectId, 40405 showOnChange = true, 40406 setValueOnChange = true, 40407 showOnMouseDown = true, 40408 setValueOnClick = true, 40409 showOnKeyDown = true, 40410 moveOnKeyPress = true, 40411 autoComplete = "list" 40412 } = _b, props = __objRest(_b, [ 40413 "store", 40414 "focusable", 40415 "autoSelect", 40416 "getAutoSelectId", 40417 "showOnChange", 40418 "setValueOnChange", 40419 "showOnMouseDown", 40420 "setValueOnClick", 40421 "showOnKeyDown", 40422 "moveOnKeyPress", 40423 "autoComplete" 40424 ]); 40425 const context = useComboboxProviderContext(); 40426 store = store || context; 40427 invariant( 40428 store, 40429 false && 0 40430 ); 40431 const ref = (0,external_React_.useRef)(null); 40432 const [valueUpdated, forceValueUpdate] = useForceUpdate(); 40433 const canAutoSelectRef = (0,external_React_.useRef)(false); 40434 const composingRef = (0,external_React_.useRef)(false); 40435 const autoSelect = store.useState( 40436 (state) => !!autoSelectProp && state.virtualFocus 40437 ); 40438 const inline = autoComplete === "inline" || autoComplete === "both"; 40439 const [canInline, setCanInline] = (0,external_React_.useState)(inline); 40440 useUpdateLayoutEffect(() => { 40441 if (!inline) 40442 return; 40443 setCanInline(true); 40444 }, [inline]); 40445 const storeValue = store.useState("value"); 40446 const activeValue = store.useState( 40447 (state) => inline && canInline ? state.activeValue : void 0 40448 ); 40449 const items = store.useState("renderedItems"); 40450 const open = store.useState("open"); 40451 const contentElement = store.useState("contentElement"); 40452 const value = (0,external_React_.useMemo)(() => { 40453 if (!inline) 40454 return storeValue; 40455 if (!canInline) 40456 return storeValue; 40457 const firstItemAutoSelected = isFirstItemAutoSelected( 40458 items, 40459 activeValue, 40460 autoSelect 40461 ); 40462 if (firstItemAutoSelected) { 40463 if (hasCompletionString(storeValue, activeValue)) { 40464 const slice = (activeValue == null ? void 0 : activeValue.slice(storeValue.length)) || ""; 40465 return storeValue + slice; 40466 } 40467 return storeValue; 40468 } 40469 return activeValue || storeValue; 40470 }, [inline, canInline, items, activeValue, autoSelect, storeValue]); 40471 (0,external_React_.useEffect)(() => { 40472 const element = ref.current; 40473 if (!element) 40474 return; 40475 const onCompositeItemMove = () => setCanInline(true); 40476 element.addEventListener("combobox-item-move", onCompositeItemMove); 40477 return () => { 40478 element.removeEventListener("combobox-item-move", onCompositeItemMove); 40479 }; 40480 }, []); 40481 (0,external_React_.useEffect)(() => { 40482 if (!inline) 40483 return; 40484 if (!canInline) 40485 return; 40486 if (!activeValue) 40487 return; 40488 const firstItemAutoSelected = isFirstItemAutoSelected( 40489 items, 40490 activeValue, 40491 autoSelect 40492 ); 40493 if (!firstItemAutoSelected) 40494 return; 40495 if (!hasCompletionString(storeValue, activeValue)) 40496 return; 40497 queueMicrotask(() => { 40498 const element = ref.current; 40499 if (!element) 40500 return; 40501 setSelectionRange(element, storeValue.length, activeValue.length); 40502 }); 40503 }, [ 40504 valueUpdated, 40505 inline, 40506 canInline, 40507 activeValue, 40508 items, 40509 autoSelect, 40510 storeValue 40511 ]); 40512 const scrollingElementRef = (0,external_React_.useRef)(null); 40513 const getAutoSelectIdProp = useEvent(getAutoSelectId); 40514 const autoSelectIdRef = (0,external_React_.useRef)(null); 40515 (0,external_React_.useEffect)(() => { 40516 if (!open) 40517 return; 40518 if (!contentElement) 40519 return; 40520 const scrollingElement = getScrollingElement(contentElement); 40521 if (!scrollingElement) 40522 return; 40523 scrollingElementRef.current = scrollingElement; 40524 const onWheel = () => { 40525 canAutoSelectRef.current = false; 40526 }; 40527 const onScroll = () => { 40528 if (!store) 40529 return; 40530 if (!canAutoSelectRef.current) 40531 return; 40532 const { activeId } = store.getState(); 40533 if (activeId === null) 40534 return; 40535 if (activeId === autoSelectIdRef.current) 40536 return; 40537 canAutoSelectRef.current = false; 40538 }; 40539 const options = { passive: true, capture: true }; 40540 scrollingElement.addEventListener("wheel", onWheel, options); 40541 scrollingElement.addEventListener("scroll", onScroll, options); 40542 return () => { 40543 scrollingElement.removeEventListener("wheel", onWheel, true); 40544 scrollingElement.removeEventListener("scroll", onScroll, true); 40545 }; 40546 }, [open, contentElement, store]); 40547 useSafeLayoutEffect(() => { 40548 if (!storeValue) 40549 return; 40550 if (composingRef.current) 40551 return; 40552 canAutoSelectRef.current = true; 40553 }, [storeValue]); 40554 useSafeLayoutEffect(() => { 40555 if (open) 40556 return; 40557 canAutoSelectRef.current = false; 40558 }, [open]); 40559 const resetValueOnSelect = store.useState("resetValueOnSelect"); 40560 useUpdateEffect(() => { 40561 var _a2; 40562 const canAutoSelect = canAutoSelectRef.current; 40563 if (!store) 40564 return; 40565 if ((!autoSelect || !canAutoSelect) && !resetValueOnSelect) 40566 return; 40567 const { baseElement, contentElement: contentElement2, activeId } = store.getState(); 40568 if (baseElement && !hasFocus(baseElement)) 40569 return; 40570 if (contentElement2 == null ? void 0 : contentElement2.hasAttribute("data-placing")) { 40571 const observer = new MutationObserver(forceValueUpdate); 40572 observer.observe(contentElement2, { attributeFilter: ["data-placing"] }); 40573 return () => observer.disconnect(); 40574 } 40575 if (autoSelect && canAutoSelect) { 40576 const userAutoSelectId = getAutoSelectIdProp(items); 40577 const autoSelectId = userAutoSelectId !== void 0 ? userAutoSelectId : store.first(); 40578 autoSelectIdRef.current = autoSelectId; 40579 store.move(autoSelectId != null ? autoSelectId : null); 40580 } else { 40581 const element = (_a2 = store.item(activeId)) == null ? void 0 : _a2.element; 40582 if (element && "scrollIntoView" in element) { 40583 element.scrollIntoView({ block: "nearest", inline: "nearest" }); 40584 } 40585 } 40586 return; 40587 }, [ 40588 store, 40589 valueUpdated, 40590 storeValue, 40591 autoSelect, 40592 resetValueOnSelect, 40593 getAutoSelectIdProp, 40594 items 40595 ]); 40596 (0,external_React_.useEffect)(() => { 40597 if (!inline) 40598 return; 40599 const combobox = ref.current; 40600 if (!combobox) 40601 return; 40602 const elements = [combobox, contentElement].filter( 40603 (value2) => !!value2 40604 ); 40605 const onBlur2 = (event) => { 40606 if (elements.every((el) => isFocusEventOutside(event, el))) { 40607 store == null ? void 0 : store.setValue(value); 40608 } 40609 }; 40610 elements.forEach((el) => el.addEventListener("focusout", onBlur2)); 40611 return () => { 40612 elements.forEach((el) => el.removeEventListener("focusout", onBlur2)); 40613 }; 40614 }, [inline, contentElement, store, value]); 40615 const onChangeProp = props.onChange; 40616 const showOnChangeProp = useBooleanEvent(showOnChange); 40617 const setValueOnChangeProp = useBooleanEvent(setValueOnChange); 40618 const onChange = useEvent((event) => { 40619 onChangeProp == null ? void 0 : onChangeProp(event); 40620 if (event.defaultPrevented) 40621 return; 40622 if (!store) 40623 return; 40624 const { value: value2, selectionStart, selectionEnd } = event.target; 40625 const nativeEvent = event.nativeEvent; 40626 canAutoSelectRef.current = true; 40627 if (isInputEvent(nativeEvent)) { 40628 if (nativeEvent.isComposing) { 40629 canAutoSelectRef.current = false; 40630 composingRef.current = true; 40631 } 40632 if (inline) { 40633 const textInserted = nativeEvent.inputType === "insertText" || nativeEvent.inputType === "insertCompositionText"; 40634 const caretAtEnd = selectionStart === value2.length; 40635 setCanInline(textInserted && caretAtEnd); 40636 } 40637 } 40638 if (setValueOnChangeProp(event)) { 40639 const isSameValue = value2 === store.getState().value; 40640 (0,external_ReactDOM_namespaceObject.flushSync)(() => store == null ? void 0 : store.setValue(value2)); 40641 setSelectionRange(event.currentTarget, selectionStart, selectionEnd); 40642 if (inline && autoSelect && isSameValue) { 40643 forceValueUpdate(); 40644 } 40645 } 40646 if (showOnChangeProp(event)) { 40647 store.show(); 40648 } 40649 if (!autoSelect || !canAutoSelectRef.current) { 40650 store.setActiveId(null); 40651 } 40652 }); 40653 const onCompositionEndProp = props.onCompositionEnd; 40654 const onCompositionEnd = useEvent( 40655 (event) => { 40656 canAutoSelectRef.current = true; 40657 composingRef.current = false; 40658 onCompositionEndProp == null ? void 0 : onCompositionEndProp(event); 40659 if (event.defaultPrevented) 40660 return; 40661 if (!autoSelect) 40662 return; 40663 forceValueUpdate(); 40664 } 40665 ); 40666 const onMouseDownProp = props.onMouseDown; 40667 const setValueOnClickProp = useBooleanEvent(setValueOnClick); 40668 const showOnMouseDownProp = useBooleanEvent(showOnMouseDown); 40669 const onMouseDown = useEvent((event) => { 40670 onMouseDownProp == null ? void 0 : onMouseDownProp(event); 40671 if (event.defaultPrevented) 40672 return; 40673 if (event.button) 40674 return; 40675 if (event.ctrlKey) 40676 return; 40677 if (!store) 40678 return; 40679 store.setActiveId(null); 40680 if (setValueOnClickProp(event)) { 40681 store.setValue(value); 40682 } 40683 if (showOnMouseDownProp(event)) { 40684 queueBeforeEvent(event.currentTarget, "mouseup", store.show); 40685 } 40686 }); 40687 const onKeyDownProp = props.onKeyDown; 40688 const showOnKeyDownProp = useBooleanEvent(showOnKeyDown); 40689 const onKeyDown = useEvent( 40690 (event) => { 40691 onKeyDownProp == null ? void 0 : onKeyDownProp(event); 40692 if (!event.repeat) { 40693 canAutoSelectRef.current = false; 40694 } 40695 if (event.defaultPrevented) 40696 return; 40697 if (event.ctrlKey) 40698 return; 40699 if (event.altKey) 40700 return; 40701 if (event.shiftKey) 40702 return; 40703 if (event.metaKey) 40704 return; 40705 if (!store) 40706 return; 40707 const { open: open2, activeId } = store.getState(); 40708 if (open2) 40709 return; 40710 if (activeId !== null) 40711 return; 40712 if (event.key === "ArrowUp" || event.key === "ArrowDown") { 40713 if (showOnKeyDownProp(event)) { 40714 event.preventDefault(); 40715 store.show(); 40716 } 40717 } 40718 } 40719 ); 40720 const onBlurProp = props.onBlur; 40721 const onBlur = useEvent((event) => { 40722 canAutoSelectRef.current = false; 40723 onBlurProp == null ? void 0 : onBlurProp(event); 40724 if (event.defaultPrevented) 40725 return; 40726 }); 40727 const id = useId(props.id); 40728 const ariaAutoComplete = isAriaAutoCompleteValue(autoComplete) ? autoComplete : void 0; 40729 const isActiveItem = store.useState((state) => state.activeId === null); 40730 props = _4R3V3JGP_spreadProps(_4R3V3JGP_spreadValues({ 40731 id, 40732 role: "combobox", 40733 "aria-autocomplete": ariaAutoComplete, 40734 "aria-haspopup": getPopupRole(contentElement, "listbox"), 40735 "aria-expanded": open, 40736 "aria-controls": contentElement == null ? void 0 : contentElement.id, 40737 "data-active-item": isActiveItem || void 0, 40738 value 40739 }, props), { 40740 ref: useMergeRefs(ref, props.ref), 40741 onChange, 40742 onCompositionEnd, 40743 onMouseDown, 40744 onKeyDown, 40745 onBlur 40746 }); 40747 props = useComposite(_4R3V3JGP_spreadProps(_4R3V3JGP_spreadValues({ 40748 store, 40749 focusable 40750 }, props), { 40751 // Enable inline autocomplete when the user moves from the combobox input 40752 // to an item. 40753 moveOnKeyPress: (event) => { 40754 if (isFalsyBooleanCallback(moveOnKeyPress, event)) 40755 return false; 40756 if (inline) 40757 setCanInline(true); 40758 return true; 40759 } 40760 })); 40761 props = usePopoverAnchor(_4R3V3JGP_spreadValues({ store }, props)); 40762 return _4R3V3JGP_spreadValues({ autoComplete: "off" }, props); 40763 } 40764 ); 40765 var Combobox = createComponent((props) => { 40766 const htmlProps = useCombobox(props); 40767 return _3ORBWXWF_createElement("input", htmlProps); 40768 }); 40769 if (false) {} 40770 40771 40772 ;// CONCATENATED MODULE: ./node_modules/@ariakit/react-core/esm/__chunks/CLE7NTOY.js 40773 "use client"; 40774 40775 40776 40777 40778 40779 40780 40781 // src/disclosure/disclosure-content.tsx 40782 40783 40784 40785 function afterTimeout(timeoutMs, cb) { 40786 const timeoutId = setTimeout(cb, timeoutMs); 40787 return () => clearTimeout(timeoutId); 40788 } 40789 function CLE7NTOY_afterPaint(cb) { 40790 let raf = requestAnimationFrame(() => { 40791 raf = requestAnimationFrame(cb); 40792 }); 40793 return () => cancelAnimationFrame(raf); 40794 } 40795 function parseCSSTime(...times) { 40796 return times.join(", ").split(", ").reduce((longestTime, currentTimeString) => { 40797 const currentTime = parseFloat(currentTimeString || "0s") * 1e3; 40798 if (currentTime > longestTime) 40799 return currentTime; 40800 return longestTime; 40801 }, 0); 40802 } 40803 function isHidden(mounted, hidden, alwaysVisible) { 40804 return !alwaysVisible && hidden !== false && (!mounted || !!hidden); 40805 } 40806 var useDisclosureContent = createHook( 40807 (_a) => { 40808 var _b = _a, { store, alwaysVisible } = _b, props = __objRest(_b, ["store", "alwaysVisible"]); 40809 const context = useDisclosureProviderContext(); 40810 store = store || context; 40811 invariant( 40812 store, 40813 false && 0 40814 ); 40815 const id = useId(props.id); 40816 const [transition, setTransition] = (0,external_React_.useState)(null); 40817 const open = store.useState("open"); 40818 const mounted = store.useState("mounted"); 40819 const animated = store.useState("animated"); 40820 const contentElement = store.useState("contentElement"); 40821 useSafeLayoutEffect(() => { 40822 if (!animated) 40823 return; 40824 if (!(contentElement == null ? void 0 : contentElement.isConnected)) { 40825 setTransition(null); 40826 return; 40827 } 40828 return CLE7NTOY_afterPaint(() => { 40829 setTransition(open ? "enter" : "leave"); 40830 }); 40831 }, [animated, contentElement, open]); 40832 useSafeLayoutEffect(() => { 40833 if (!store) 40834 return; 40835 if (!animated) 40836 return; 40837 if (!contentElement) 40838 return; 40839 if (!transition) 40840 return; 40841 if (transition === "enter" && !open) 40842 return; 40843 if (transition === "leave" && open) 40844 return; 40845 if (typeof animated === "number") { 40846 const timeoutMs2 = animated; 40847 return afterTimeout(timeoutMs2, store.stopAnimation); 40848 } 40849 const { 40850 transitionDuration, 40851 animationDuration, 40852 transitionDelay, 40853 animationDelay 40854 } = getComputedStyle(contentElement); 40855 const delay = parseCSSTime(transitionDelay, animationDelay); 40856 const duration = parseCSSTime(transitionDuration, animationDuration); 40857 const timeoutMs = delay + duration; 40858 if (!timeoutMs) 40859 return; 40860 return afterTimeout(timeoutMs, store.stopAnimation); 40861 }, [store, animated, contentElement, open, transition]); 40862 props = useWrapElement( 40863 props, 40864 (element) => /* @__PURE__ */ (0,jsx_runtime.jsx)(DialogScopedContextProvider, { value: store, children: element }), 40865 [store] 40866 ); 40867 const hidden = isHidden(mounted, props.hidden, alwaysVisible); 40868 const style = hidden ? _4R3V3JGP_spreadProps(_4R3V3JGP_spreadValues({}, props.style), { display: "none" }) : props.style; 40869 props = _4R3V3JGP_spreadProps(_4R3V3JGP_spreadValues({ 40870 id, 40871 "data-enter": transition === "enter" ? "" : void 0, 40872 "data-leave": transition === "leave" ? "" : void 0, 40873 hidden 40874 }, props), { 40875 ref: useMergeRefs(id ? store.setContentElement : null, props.ref), 40876 style 40877 }); 40878 return props; 40879 } 40880 ); 40881 var DisclosureContentImpl = createComponent( 40882 (props) => { 40883 const htmlProps = useDisclosureContent(props); 40884 return _3ORBWXWF_createElement("div", htmlProps); 40885 } 40886 ); 40887 var DisclosureContent = createComponent( 40888 (_a) => { 40889 var _b = _a, { unmountOnHide } = _b, props = __objRest(_b, ["unmountOnHide"]); 40890 const context = useDisclosureProviderContext(); 40891 const store = props.store || context; 40892 const mounted = useStoreState( 40893 store, 40894 (state) => !unmountOnHide || (state == null ? void 0 : state.mounted) 40895 ); 40896 if (mounted === false) 40897 return null; 40898 return /* @__PURE__ */ (0,jsx_runtime.jsx)(DisclosureContentImpl, _4R3V3JGP_spreadValues({}, props)); 40899 } 40900 ); 40901 if (false) {} 40902 40903 40904 40905 ;// CONCATENATED MODULE: ./node_modules/@ariakit/react-core/esm/__chunks/ZEXNX5JH.js 40906 "use client"; 40907 40908 40909 40910 40911 40912 40913 40914 // src/combobox/combobox-list.tsx 40915 40916 40917 40918 40919 var useComboboxList = createHook( 40920 (_a) => { 40921 var _b = _a, { store, focusable = true, alwaysVisible } = _b, props = __objRest(_b, ["store", "focusable", "alwaysVisible"]); 40922 const context = useComboboxProviderContext(); 40923 store = store || context; 40924 invariant( 40925 store, 40926 false && 0 40927 ); 40928 const ref = (0,external_React_.useRef)(null); 40929 const id = useId(props.id); 40930 const onKeyDownProp = props.onKeyDown; 40931 const onKeyDown = useEvent((event) => { 40932 onKeyDownProp == null ? void 0 : onKeyDownProp(event); 40933 if (event.defaultPrevented) 40934 return; 40935 if (event.key === "Escape") { 40936 store == null ? void 0 : store.move(null); 40937 } 40938 }); 40939 const restoreVirtualFocus = (0,external_React_.useRef)(false); 40940 const onFocusVisibleProp = props.onFocusVisible; 40941 const onFocusVisible = useEvent((event) => { 40942 onFocusVisibleProp == null ? void 0 : onFocusVisibleProp(event); 40943 if (event.defaultPrevented) 40944 return; 40945 if (event.type !== "focus") 40946 return; 40947 if (!store) 40948 return; 40949 const { virtualFocus } = store.getState(); 40950 if (!virtualFocus) 40951 return; 40952 const { relatedTarget, currentTarget } = event; 40953 if (relatedTarget && currentTarget.contains(relatedTarget)) 40954 return; 40955 restoreVirtualFocus.current = true; 40956 store.setState("virtualFocus", false); 40957 }); 40958 const onBlurProp = props.onBlur; 40959 const onBlur = useEvent((event) => { 40960 onBlurProp == null ? void 0 : onBlurProp(event); 40961 if (event.defaultPrevented) 40962 return; 40963 if (!restoreVirtualFocus.current) 40964 return; 40965 if (!isFocusEventOutside(event)) 40966 return; 40967 restoreVirtualFocus.current = false; 40968 store == null ? void 0 : store.setState("virtualFocus", true); 40969 }); 40970 props = useWrapElement( 40971 props, 40972 (element) => /* @__PURE__ */ (0,jsx_runtime.jsx)(ComboboxScopedContextProvider, { value: store, children: element }), 40973 [store] 40974 ); 40975 const mounted = store.useState("mounted"); 40976 const hidden = isHidden(mounted, props.hidden, alwaysVisible); 40977 const style = hidden ? _4R3V3JGP_spreadProps(_4R3V3JGP_spreadValues({}, props.style), { display: "none" }) : props.style; 40978 const multiSelectable = store.useState( 40979 (state) => Array.isArray(state.selectedValue) 40980 ); 40981 const role = useAttribute(ref, "role", props.role); 40982 const isCompositeRole = role === "listbox" || role === "tree" || role === "grid"; 40983 const ariaMultiSelectable = isCompositeRole ? multiSelectable || void 0 : void 0; 40984 props = _4R3V3JGP_spreadProps(_4R3V3JGP_spreadValues({ 40985 id, 40986 hidden, 40987 role: "listbox", 40988 tabIndex: focusable ? -1 : void 0, 40989 "aria-multiselectable": ariaMultiSelectable 40990 }, props), { 40991 ref: useMergeRefs(id ? store.setContentElement : null, ref, props.ref), 40992 style, 40993 onKeyDown, 40994 onFocusVisible, 40995 onBlur 40996 }); 40997 props = useFocusable(_4R3V3JGP_spreadValues({ focusable }, props)); 40998 return props; 40999 } 41000 ); 41001 var ComboboxList = createComponent((props) => { 41002 const htmlProps = useComboboxList(props); 41003 return _3ORBWXWF_createElement("div", htmlProps); 41004 }); 41005 if (false) {} 41006 41007 41008 41009 ;// CONCATENATED MODULE: ./node_modules/@ariakit/react-core/esm/__chunks/G6ONQ5EH.js 41010 "use client"; 41011 41012 41013 41014 41015 41016 // src/composite/composite-hover.ts 41017 41018 41019 41020 41021 function getMouseDestination(event) { 41022 const relatedTarget = event.relatedTarget; 41023 if ((relatedTarget == null ? void 0 : relatedTarget.nodeType) === Node.ELEMENT_NODE) { 41024 return relatedTarget; 41025 } 41026 return null; 41027 } 41028 function hoveringInside(event) { 41029 const nextElement = getMouseDestination(event); 41030 if (!nextElement) 41031 return false; 41032 return contains(event.currentTarget, nextElement); 41033 } 41034 var G6ONQ5EH_symbol = Symbol("composite-hover"); 41035 function movingToAnotherItem(event) { 41036 let dest = getMouseDestination(event); 41037 if (!dest) 41038 return false; 41039 do { 41040 if (Y3OOHFCN_hasOwnProperty(dest, G6ONQ5EH_symbol) && dest[G6ONQ5EH_symbol]) 41041 return true; 41042 dest = dest.parentElement; 41043 } while (dest); 41044 return false; 41045 } 41046 var useCompositeHover = createHook( 41047 (_a) => { 41048 var _b = _a, { 41049 store, 41050 focusOnHover = true, 41051 blurOnHoverEnd = !!focusOnHover 41052 } = _b, props = __objRest(_b, [ 41053 "store", 41054 "focusOnHover", 41055 "blurOnHoverEnd" 41056 ]); 41057 const context = useCompositeContext(); 41058 store = store || context; 41059 invariant( 41060 store, 41061 false && 0 41062 ); 41063 const isMouseMoving = useIsMouseMoving(); 41064 const onMouseMoveProp = props.onMouseMove; 41065 const focusOnHoverProp = useBooleanEvent(focusOnHover); 41066 const onMouseMove = useEvent((event) => { 41067 onMouseMoveProp == null ? void 0 : onMouseMoveProp(event); 41068 if (event.defaultPrevented) 41069 return; 41070 if (!isMouseMoving()) 41071 return; 41072 if (!focusOnHoverProp(event)) 41073 return; 41074 if (!hasFocusWithin(event.currentTarget)) { 41075 const baseElement = store == null ? void 0 : store.getState().baseElement; 41076 if (baseElement && !hasFocus(baseElement)) { 41077 baseElement.focus(); 41078 } 41079 } 41080 store == null ? void 0 : store.setActiveId(event.currentTarget.id); 41081 }); 41082 const onMouseLeaveProp = props.onMouseLeave; 41083 const blurOnHoverEndProp = useBooleanEvent(blurOnHoverEnd); 41084 const onMouseLeave = useEvent((event) => { 41085 var _a2; 41086 onMouseLeaveProp == null ? void 0 : onMouseLeaveProp(event); 41087 if (event.defaultPrevented) 41088 return; 41089 if (!isMouseMoving()) 41090 return; 41091 if (hoveringInside(event)) 41092 return; 41093 if (movingToAnotherItem(event)) 41094 return; 41095 if (!focusOnHoverProp(event)) 41096 return; 41097 if (!blurOnHoverEndProp(event)) 41098 return; 41099 store == null ? void 0 : store.setActiveId(null); 41100 (_a2 = store == null ? void 0 : store.getState().baseElement) == null ? void 0 : _a2.focus(); 41101 }); 41102 const ref = (0,external_React_.useCallback)((element) => { 41103 if (!element) 41104 return; 41105 element[G6ONQ5EH_symbol] = true; 41106 }, []); 41107 props = _4R3V3JGP_spreadProps(_4R3V3JGP_spreadValues({}, props), { 41108 ref: useMergeRefs(ref, props.ref), 41109 onMouseMove, 41110 onMouseLeave 41111 }); 41112 return props; 41113 } 41114 ); 41115 var CompositeHover = createMemoComponent( 41116 (props) => { 41117 const htmlProps = useCompositeHover(props); 41118 return _3ORBWXWF_createElement("div", htmlProps); 41119 } 41120 ); 41121 if (false) {} 41122 41123 41124 41125 ;// CONCATENATED MODULE: ./node_modules/@ariakit/react-core/esm/__chunks/NWCBQ4CV.js 41126 "use client"; 41127 41128 41129 41130 41131 41132 // src/command/command.ts 41133 41134 41135 41136 41137 41138 function isNativeClick(event) { 41139 if (!event.isTrusted) 41140 return false; 41141 const element = event.currentTarget; 41142 if (event.key === "Enter") { 41143 return isButton(element) || element.tagName === "SUMMARY" || element.tagName === "A"; 41144 } 41145 if (event.key === " ") { 41146 return isButton(element) || element.tagName === "SUMMARY" || element.tagName === "INPUT" || element.tagName === "SELECT"; 41147 } 41148 return false; 41149 } 41150 var NWCBQ4CV_symbol = Symbol("command"); 41151 var useCommand = createHook( 41152 (_a) => { 41153 var _b = _a, { clickOnEnter = true, clickOnSpace = true } = _b, props = __objRest(_b, ["clickOnEnter", "clickOnSpace"]); 41154 const ref = (0,external_React_.useRef)(null); 41155 const tagName = useTagName(ref, props.as); 41156 const type = props.type; 41157 const [isNativeButton, setIsNativeButton] = (0,external_React_.useState)( 41158 () => !!tagName && isButton({ tagName, type }) 41159 ); 41160 (0,external_React_.useEffect)(() => { 41161 if (!ref.current) 41162 return; 41163 setIsNativeButton(isButton(ref.current)); 41164 }, []); 41165 const [active, setActive] = (0,external_React_.useState)(false); 41166 const activeRef = (0,external_React_.useRef)(false); 41167 const disabled = disabledFromProps(props); 41168 const [isDuplicate, metadataProps] = useMetadataProps(props, NWCBQ4CV_symbol, true); 41169 const onKeyDownProp = props.onKeyDown; 41170 const onKeyDown = useEvent((event) => { 41171 onKeyDownProp == null ? void 0 : onKeyDownProp(event); 41172 const element = event.currentTarget; 41173 if (event.defaultPrevented) 41174 return; 41175 if (isDuplicate) 41176 return; 41177 if (disabled) 41178 return; 41179 if (!isSelfTarget(event)) 41180 return; 41181 if (DLOEKDPY_isTextField(element)) 41182 return; 41183 if (element.isContentEditable) 41184 return; 41185 const isEnter = clickOnEnter && event.key === "Enter"; 41186 const isSpace = clickOnSpace && event.key === " "; 41187 const shouldPreventEnter = event.key === "Enter" && !clickOnEnter; 41188 const shouldPreventSpace = event.key === " " && !clickOnSpace; 41189 if (shouldPreventEnter || shouldPreventSpace) { 41190 event.preventDefault(); 41191 return; 41192 } 41193 if (isEnter || isSpace) { 41194 const nativeClick = isNativeClick(event); 41195 if (isEnter) { 41196 if (!nativeClick) { 41197 event.preventDefault(); 41198 const _a2 = event, { view } = _a2, eventInit = __objRest(_a2, ["view"]); 41199 const click = () => fireClickEvent(element, eventInit); 41200 if (isFirefox()) { 41201 queueBeforeEvent(element, "keyup", click); 41202 } else { 41203 queueMicrotask(click); 41204 } 41205 } 41206 } else if (isSpace) { 41207 activeRef.current = true; 41208 if (!nativeClick) { 41209 event.preventDefault(); 41210 setActive(true); 41211 } 41212 } 41213 } 41214 }); 41215 const onKeyUpProp = props.onKeyUp; 41216 const onKeyUp = useEvent((event) => { 41217 onKeyUpProp == null ? void 0 : onKeyUpProp(event); 41218 if (event.defaultPrevented) 41219 return; 41220 if (isDuplicate) 41221 return; 41222 if (disabled) 41223 return; 41224 if (event.metaKey) 41225 return; 41226 const isSpace = clickOnSpace && event.key === " "; 41227 if (activeRef.current && isSpace) { 41228 activeRef.current = false; 41229 if (!isNativeClick(event)) { 41230 event.preventDefault(); 41231 setActive(false); 41232 const element = event.currentTarget; 41233 const _a2 = event, { view } = _a2, eventInit = __objRest(_a2, ["view"]); 41234 queueMicrotask(() => fireClickEvent(element, eventInit)); 41235 } 41236 } 41237 }); 41238 props = _4R3V3JGP_spreadProps(_4R3V3JGP_spreadValues(_4R3V3JGP_spreadValues({ 41239 "data-active": active ? "" : void 0, 41240 type: isNativeButton ? "button" : void 0 41241 }, metadataProps), props), { 41242 ref: useMergeRefs(ref, props.ref), 41243 onKeyDown, 41244 onKeyUp 41245 }); 41246 props = useFocusable(props); 41247 return props; 41248 } 41249 ); 41250 var Command = createComponent((props) => { 41251 props = useCommand(props); 41252 return _3ORBWXWF_createElement("button", props); 41253 }); 41254 if (false) {} 41255 41256 41257 41258 ;// CONCATENATED MODULE: ./node_modules/@ariakit/react-core/esm/__chunks/UH3I23HL.js 41259 "use client"; 41260 41261 41262 41263 41264 41265 // src/collection/collection-item.ts 41266 41267 41268 var useCollectionItem = createHook( 41269 (_a) => { 41270 var _b = _a, { 41271 store, 41272 shouldRegisterItem = true, 41273 getItem = identity, 41274 element: element 41275 } = _b, props = __objRest(_b, [ 41276 "store", 41277 "shouldRegisterItem", 41278 "getItem", 41279 // @ts-expect-error This prop may come from a collection renderer. 41280 "element" 41281 ]); 41282 const context = useCollectionContext(); 41283 store = store || context; 41284 const id = useId(props.id); 41285 const ref = (0,external_React_.useRef)(element); 41286 (0,external_React_.useEffect)(() => { 41287 const element2 = ref.current; 41288 if (!id) 41289 return; 41290 if (!element2) 41291 return; 41292 if (!shouldRegisterItem) 41293 return; 41294 const item = getItem({ id, element: element2 }); 41295 return store == null ? void 0 : store.renderItem(item); 41296 }, [id, shouldRegisterItem, getItem, store]); 41297 props = _4R3V3JGP_spreadProps(_4R3V3JGP_spreadValues({}, props), { 41298 ref: useMergeRefs(ref, props.ref) 41299 }); 41300 return props; 41301 } 41302 ); 41303 var CollectionItem = createComponent( 41304 (props) => { 41305 const htmlProps = useCollectionItem(props); 41306 return _3ORBWXWF_createElement("div", htmlProps); 41307 } 41308 ); 41309 if (false) {} 41310 41311 41312 41313 ;// CONCATENATED MODULE: ./node_modules/@ariakit/react-core/esm/__chunks/QZLXIDNP.js 41314 "use client"; 41315 41316 41317 41318 41319 41320 41321 41322 41323 41324 // src/composite/composite-item.tsx 41325 41326 41327 41328 41329 41330 function isEditableElement(element) { 41331 if (element.isContentEditable) 41332 return true; 41333 if (DLOEKDPY_isTextField(element)) 41334 return true; 41335 return element.tagName === "INPUT" && !isButton(element); 41336 } 41337 function getNextPageOffset(scrollingElement, pageUp = false) { 41338 const height = scrollingElement.clientHeight; 41339 const { top } = scrollingElement.getBoundingClientRect(); 41340 const pageSize = Math.max(height * 0.875, height - 40) * 1.5; 41341 const pageOffset = pageUp ? height - pageSize + top : pageSize + top; 41342 if (scrollingElement.tagName === "HTML") { 41343 return pageOffset + scrollingElement.scrollTop; 41344 } 41345 return pageOffset; 41346 } 41347 function getItemOffset(itemElement, pageUp = false) { 41348 const { top } = itemElement.getBoundingClientRect(); 41349 if (pageUp) { 41350 return top + itemElement.clientHeight; 41351 } 41352 return top; 41353 } 41354 function findNextPageItemId(element, store, next, pageUp = false) { 41355 var _a; 41356 if (!store) 41357 return; 41358 if (!next) 41359 return; 41360 const { renderedItems } = store.getState(); 41361 const scrollingElement = getScrollingElement(element); 41362 if (!scrollingElement) 41363 return; 41364 const nextPageOffset = getNextPageOffset(scrollingElement, pageUp); 41365 let id; 41366 let prevDifference; 41367 for (let i = 0; i < renderedItems.length; i += 1) { 41368 const previousId = id; 41369 id = next(i); 41370 if (!id) 41371 break; 41372 if (id === previousId) 41373 continue; 41374 const itemElement = (_a = getEnabledItem(store, id)) == null ? void 0 : _a.element; 41375 if (!itemElement) 41376 continue; 41377 const itemOffset = getItemOffset(itemElement, pageUp); 41378 const difference = itemOffset - nextPageOffset; 41379 const absDifference = Math.abs(difference); 41380 if (pageUp && difference <= 0 || !pageUp && difference >= 0) { 41381 if (prevDifference !== void 0 && prevDifference < absDifference) { 41382 id = previousId; 41383 } 41384 break; 41385 } 41386 prevDifference = absDifference; 41387 } 41388 return id; 41389 } 41390 function targetIsAnotherItem(event, store) { 41391 if (isSelfTarget(event)) 41392 return false; 41393 return isItem(store, event.target); 41394 } 41395 function useRole(ref, props) { 41396 const roleProp = props.role; 41397 const [role, setRole] = (0,external_React_.useState)(roleProp); 41398 useSafeLayoutEffect(() => { 41399 const element = ref.current; 41400 if (!element) 41401 return; 41402 setRole(element.getAttribute("role") || roleProp); 41403 }, [roleProp]); 41404 return role; 41405 } 41406 function requiresAriaSelected(role) { 41407 return role === "option" || role === "treeitem"; 41408 } 41409 function supportsAriaSelected(role) { 41410 if (role === "option") 41411 return true; 41412 if (role === "tab") 41413 return true; 41414 if (role === "treeitem") 41415 return true; 41416 if (role === "gridcell") 41417 return true; 41418 if (role === "row") 41419 return true; 41420 if (role === "columnheader") 41421 return true; 41422 if (role === "rowheader") 41423 return true; 41424 return false; 41425 } 41426 var useCompositeItem = createHook( 41427 (_a) => { 41428 var _b = _a, { 41429 store, 41430 rowId: rowIdProp, 41431 preventScrollOnKeyDown = false, 41432 moveOnKeyPress = true, 41433 tabbable = false, 41434 getItem: getItemProp, 41435 "aria-setsize": ariaSetSizeProp, 41436 "aria-posinset": ariaPosInSetProp 41437 } = _b, props = __objRest(_b, [ 41438 "store", 41439 "rowId", 41440 "preventScrollOnKeyDown", 41441 "moveOnKeyPress", 41442 "tabbable", 41443 "getItem", 41444 "aria-setsize", 41445 "aria-posinset" 41446 ]); 41447 const context = useCompositeContext(); 41448 store = store || context; 41449 const id = useId(props.id); 41450 const ref = (0,external_React_.useRef)(null); 41451 const row = (0,external_React_.useContext)(CompositeRowContext); 41452 const rowId = useStoreState(store, (state) => { 41453 if (rowIdProp) 41454 return rowIdProp; 41455 if (!state) 41456 return; 41457 if (!(row == null ? void 0 : row.baseElement)) 41458 return; 41459 if (row.baseElement !== state.baseElement) 41460 return; 41461 return row.id; 41462 }); 41463 const disabled = disabledFromProps(props); 41464 const trulyDisabled = disabled && !props.accessibleWhenDisabled; 41465 const getItem = (0,external_React_.useCallback)( 41466 (item) => { 41467 const nextItem = _4R3V3JGP_spreadProps(_4R3V3JGP_spreadValues({}, item), { 41468 id: id || item.id, 41469 rowId, 41470 disabled: !!trulyDisabled 41471 }); 41472 if (getItemProp) { 41473 return getItemProp(nextItem); 41474 } 41475 return nextItem; 41476 }, 41477 [id, rowId, trulyDisabled, getItemProp] 41478 ); 41479 const onFocusProp = props.onFocus; 41480 const hasFocusedComposite = (0,external_React_.useRef)(false); 41481 const onFocus = useEvent((event) => { 41482 onFocusProp == null ? void 0 : onFocusProp(event); 41483 if (event.defaultPrevented) 41484 return; 41485 if (isPortalEvent(event)) 41486 return; 41487 if (!id) 41488 return; 41489 if (!store) 41490 return; 41491 const { activeId, virtualFocus: virtualFocus2, baseElement: baseElement2 } = store.getState(); 41492 if (targetIsAnotherItem(event, store)) 41493 return; 41494 if (activeId !== id) { 41495 store.setActiveId(id); 41496 } 41497 if (!virtualFocus2) 41498 return; 41499 if (!isSelfTarget(event)) 41500 return; 41501 if (isEditableElement(event.currentTarget)) 41502 return; 41503 if (!(baseElement2 == null ? void 0 : baseElement2.isConnected)) 41504 return; 41505 hasFocusedComposite.current = true; 41506 const fromComposite = event.relatedTarget === baseElement2 || isItem(store, event.relatedTarget); 41507 if (fromComposite) { 41508 focusSilently(baseElement2); 41509 } else { 41510 baseElement2.focus(); 41511 } 41512 }); 41513 const onBlurCaptureProp = props.onBlurCapture; 41514 const onBlurCapture = useEvent((event) => { 41515 onBlurCaptureProp == null ? void 0 : onBlurCaptureProp(event); 41516 if (event.defaultPrevented) 41517 return; 41518 const state = store == null ? void 0 : store.getState(); 41519 if ((state == null ? void 0 : state.virtualFocus) && hasFocusedComposite.current) { 41520 hasFocusedComposite.current = false; 41521 event.preventDefault(); 41522 event.stopPropagation(); 41523 } 41524 }); 41525 const onKeyDownProp = props.onKeyDown; 41526 const preventScrollOnKeyDownProp = useBooleanEvent(preventScrollOnKeyDown); 41527 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress); 41528 const onKeyDown = useEvent((event) => { 41529 onKeyDownProp == null ? void 0 : onKeyDownProp(event); 41530 if (event.defaultPrevented) 41531 return; 41532 if (!isSelfTarget(event)) 41533 return; 41534 if (!store) 41535 return; 41536 const { currentTarget } = event; 41537 const state = store.getState(); 41538 const item = store.item(id); 41539 const isGrid = !!(item == null ? void 0 : item.rowId); 41540 const isVertical = state.orientation !== "horizontal"; 41541 const isHorizontal = state.orientation !== "vertical"; 41542 const canHomeEnd = () => { 41543 if (isGrid) 41544 return true; 41545 if (isHorizontal) 41546 return true; 41547 if (!state.baseElement) 41548 return true; 41549 if (!DLOEKDPY_isTextField(state.baseElement)) 41550 return true; 41551 return false; 41552 }; 41553 const keyMap = { 41554 ArrowUp: (isGrid || isVertical) && store.up, 41555 ArrowRight: (isGrid || isHorizontal) && store.next, 41556 ArrowDown: (isGrid || isVertical) && store.down, 41557 ArrowLeft: (isGrid || isHorizontal) && store.previous, 41558 Home: () => { 41559 if (!canHomeEnd()) 41560 return; 41561 if (!isGrid || event.ctrlKey) { 41562 return store == null ? void 0 : store.first(); 41563 } 41564 return store == null ? void 0 : store.previous(-1); 41565 }, 41566 End: () => { 41567 if (!canHomeEnd()) 41568 return; 41569 if (!isGrid || event.ctrlKey) { 41570 return store == null ? void 0 : store.last(); 41571 } 41572 return store == null ? void 0 : store.next(-1); 41573 }, 41574 PageUp: () => { 41575 return findNextPageItemId(currentTarget, store, store == null ? void 0 : store.up, true); 41576 }, 41577 PageDown: () => { 41578 return findNextPageItemId(currentTarget, store, store == null ? void 0 : store.down); 41579 } 41580 }; 41581 const action = keyMap[event.key]; 41582 if (action) { 41583 const nextId = action(); 41584 if (preventScrollOnKeyDownProp(event) || nextId !== void 0) { 41585 if (!moveOnKeyPressProp(event)) 41586 return; 41587 event.preventDefault(); 41588 store.move(nextId); 41589 } 41590 } 41591 }); 41592 const baseElement = useStoreState( 41593 store, 41594 (state) => (state == null ? void 0 : state.baseElement) || void 0 41595 ); 41596 const providerValue = (0,external_React_.useMemo)( 41597 () => ({ id, baseElement }), 41598 [id, baseElement] 41599 ); 41600 props = useWrapElement( 41601 props, 41602 (element) => /* @__PURE__ */ (0,jsx_runtime.jsx)(CompositeItemContext.Provider, { value: providerValue, children: element }), 41603 [providerValue] 41604 ); 41605 const isActiveItem = useStoreState( 41606 store, 41607 (state) => !!state && state.activeId === id 41608 ); 41609 const virtualFocus = useStoreState(store, "virtualFocus"); 41610 const role = useRole(ref, props); 41611 let ariaSelected; 41612 if (isActiveItem) { 41613 if (requiresAriaSelected(role)) { 41614 ariaSelected = true; 41615 } else if (virtualFocus && supportsAriaSelected(role)) { 41616 ariaSelected = true; 41617 } 41618 } 41619 const ariaSetSize = useStoreState(store, (state) => { 41620 if (ariaSetSizeProp != null) 41621 return ariaSetSizeProp; 41622 if (!state) 41623 return; 41624 if (!(row == null ? void 0 : row.ariaSetSize)) 41625 return; 41626 if (row.baseElement !== state.baseElement) 41627 return; 41628 return row.ariaSetSize; 41629 }); 41630 const ariaPosInSet = useStoreState(store, (state) => { 41631 if (ariaPosInSetProp != null) 41632 return ariaPosInSetProp; 41633 if (!state) 41634 return; 41635 if (!(row == null ? void 0 : row.ariaPosInSet)) 41636 return; 41637 if (row.baseElement !== state.baseElement) 41638 return; 41639 const itemsInRow = state.renderedItems.filter( 41640 (item) => item.rowId === rowId 41641 ); 41642 return row.ariaPosInSet + itemsInRow.findIndex((item) => item.id === id); 41643 }); 41644 const isTabbable = useStoreState(store, (state) => { 41645 if (!(state == null ? void 0 : state.renderedItems.length)) 41646 return true; 41647 if (state.virtualFocus) 41648 return false; 41649 if (tabbable) 41650 return true; 41651 return state.activeId === id; 41652 }); 41653 props = _4R3V3JGP_spreadProps(_4R3V3JGP_spreadValues({ 41654 id, 41655 "aria-selected": ariaSelected, 41656 "data-active-item": isActiveItem ? "" : void 0 41657 }, props), { 41658 ref: useMergeRefs(ref, props.ref), 41659 tabIndex: isTabbable ? props.tabIndex : -1, 41660 onFocus, 41661 onBlurCapture, 41662 onKeyDown 41663 }); 41664 props = useCommand(props); 41665 props = useCollectionItem(_4R3V3JGP_spreadProps(_4R3V3JGP_spreadValues({ 41666 store 41667 }, props), { 41668 getItem, 41669 shouldRegisterItem: !!id ? props.shouldRegisterItem : false 41670 })); 41671 return _4R3V3JGP_spreadProps(_4R3V3JGP_spreadValues({}, props), { 41672 "aria-setsize": ariaSetSize, 41673 "aria-posinset": ariaPosInSet 41674 }); 41675 } 41676 ); 41677 var QZLXIDNP_CompositeItem = createMemoComponent( 41678 (props) => { 41679 const htmlProps = useCompositeItem(props); 41680 return _3ORBWXWF_createElement("button", htmlProps); 41681 } 41682 ); 41683 if (false) {} 41684 41685 41686 41687 ;// CONCATENATED MODULE: ./node_modules/@ariakit/react-core/esm/combobox/combobox-item.js 41688 "use client"; 41689 41690 41691 41692 41693 41694 41695 41696 41697 41698 41699 41700 41701 41702 41703 41704 41705 41706 41707 41708 // src/combobox/combobox-item.tsx 41709 41710 41711 41712 41713 41714 41715 function isSelected(storeValue, itemValue) { 41716 if (itemValue == null) 41717 return; 41718 if (storeValue == null) 41719 return false; 41720 if (Array.isArray(storeValue)) { 41721 return storeValue.includes(itemValue); 41722 } 41723 return storeValue === itemValue; 41724 } 41725 var useComboboxItem = createHook( 41726 (_a) => { 41727 var _b = _a, { 41728 store, 41729 value, 41730 hideOnClick, 41731 selectValueOnClick = true, 41732 setValueOnClick, 41733 focusOnHover = false, 41734 moveOnKeyPress = true, 41735 getItem: getItemProp 41736 } = _b, props = __objRest(_b, [ 41737 "store", 41738 "value", 41739 "hideOnClick", 41740 "selectValueOnClick", 41741 "setValueOnClick", 41742 "focusOnHover", 41743 "moveOnKeyPress", 41744 "getItem" 41745 ]); 41746 const context = useComboboxScopedContext(); 41747 store = store || context; 41748 invariant( 41749 store, 41750 false && 0 41751 ); 41752 const getItem = (0,external_React_.useCallback)( 41753 (item) => { 41754 const nextItem = _4R3V3JGP_spreadProps(_4R3V3JGP_spreadValues({}, item), { value }); 41755 if (getItemProp) { 41756 return getItemProp(nextItem); 41757 } 41758 return nextItem; 41759 }, 41760 [value, getItemProp] 41761 ); 41762 const multiSelectable = store.useState( 41763 (state) => Array.isArray(state.selectedValue) 41764 ); 41765 setValueOnClick = setValueOnClick != null ? setValueOnClick : !multiSelectable; 41766 hideOnClick = hideOnClick != null ? hideOnClick : value != null && !multiSelectable; 41767 const onClickProp = props.onClick; 41768 const setValueOnClickProp = useBooleanEvent(setValueOnClick); 41769 const selectValueOnClickProp = useBooleanEvent(selectValueOnClick); 41770 const hideOnClickProp = useBooleanEvent(hideOnClick); 41771 const onClick = useEvent((event) => { 41772 onClickProp == null ? void 0 : onClickProp(event); 41773 if (event.defaultPrevented) 41774 return; 41775 if (isDownloading(event)) 41776 return; 41777 if (isOpeningInNewTab(event)) 41778 return; 41779 if (value != null) { 41780 if (selectValueOnClickProp(event)) { 41781 store == null ? void 0 : store.setSelectedValue((prevValue) => { 41782 if (!Array.isArray(prevValue)) 41783 return value; 41784 if (prevValue.includes(value)) { 41785 return prevValue.filter((v) => v !== value); 41786 } 41787 return [...prevValue, value]; 41788 }); 41789 } 41790 if (setValueOnClickProp(event)) { 41791 store == null ? void 0 : store.setValue(value); 41792 } 41793 } 41794 if (hideOnClickProp(event)) { 41795 store == null ? void 0 : store.move(null); 41796 store == null ? void 0 : store.hide(); 41797 } 41798 }); 41799 const onKeyDownProp = props.onKeyDown; 41800 const onKeyDown = useEvent((event) => { 41801 onKeyDownProp == null ? void 0 : onKeyDownProp(event); 41802 if (event.defaultPrevented) 41803 return; 41804 const baseElement = store == null ? void 0 : store.getState().baseElement; 41805 if (!baseElement) 41806 return; 41807 if (hasFocus(baseElement)) 41808 return; 41809 const printable = event.key.length === 1; 41810 if (printable || event.key === "Backspace" || event.key === "Delete") { 41811 queueMicrotask(() => baseElement.focus()); 41812 if (DLOEKDPY_isTextField(baseElement)) { 41813 store == null ? void 0 : store.setValue(baseElement.value); 41814 } 41815 } 41816 }); 41817 const selected = store.useState( 41818 (state) => isSelected(state.selectedValue, value) 41819 ); 41820 if (multiSelectable && selected != null) { 41821 props = _4R3V3JGP_spreadValues({ 41822 "aria-selected": selected 41823 }, props); 41824 } 41825 props = useWrapElement( 41826 props, 41827 (element) => /* @__PURE__ */ (0,jsx_runtime.jsx)(ComboboxItemValueContext.Provider, { value, children: /* @__PURE__ */ (0,jsx_runtime.jsx)(ComboboxItemCheckedContext.Provider, { value: selected != null ? selected : false, children: element }) }), 41828 [value, selected] 41829 ); 41830 const contentElement = store.useState("contentElement"); 41831 props = _4R3V3JGP_spreadProps(_4R3V3JGP_spreadValues({ 41832 role: getPopupItemRole(contentElement), 41833 children: value 41834 }, props), { 41835 onClick, 41836 onKeyDown 41837 }); 41838 const moveOnKeyPressProp = useBooleanEvent(moveOnKeyPress); 41839 props = useCompositeItem(_4R3V3JGP_spreadProps(_4R3V3JGP_spreadValues({ 41840 store 41841 }, props), { 41842 getItem, 41843 // Dispatch a custom event on the combobox input when moving to an item 41844 // with the keyboard so the Combobox component can enable inline 41845 // autocompletion. 41846 moveOnKeyPress: (event) => { 41847 if (!moveOnKeyPressProp(event)) 41848 return false; 41849 const moveEvent = new Event("combobox-item-move"); 41850 const baseElement = store == null ? void 0 : store.getState().baseElement; 41851 baseElement == null ? void 0 : baseElement.dispatchEvent(moveEvent); 41852 return true; 41853 } 41854 })); 41855 props = useCompositeHover(_4R3V3JGP_spreadValues({ store, focusOnHover }, props)); 41856 return props; 41857 } 41858 ); 41859 var ComboboxItem = createMemoComponent( 41860 (props) => { 41861 const htmlProps = useComboboxItem(props); 41862 return _3ORBWXWF_createElement("div", htmlProps); 41863 } 41864 ); 41865 if (false) {} 41866 41867 41868 ;// CONCATENATED MODULE: ./node_modules/@ariakit/react-core/esm/combobox/combobox-item-value.js 41869 "use client"; 41870 41871 41872 41873 41874 41875 41876 41877 41878 41879 41880 41881 // src/combobox/combobox-item-value.tsx 41882 41883 41884 41885 function normalizeValue(value) { 41886 return normalizeString(value).toLowerCase(); 41887 } 41888 function splitValue(itemValue, userValue) { 41889 userValue = normalizeValue(userValue); 41890 let index = normalizeValue(itemValue).indexOf(userValue); 41891 const parts = []; 41892 while (index !== -1) { 41893 if (index !== 0) { 41894 parts.push( 41895 /* @__PURE__ */ (0,jsx_runtime.jsx)("span", { "data-autocomplete-value": "", children: itemValue.substr(0, index) }, parts.length) 41896 ); 41897 } 41898 parts.push( 41899 /* @__PURE__ */ (0,jsx_runtime.jsx)("span", { "data-user-value": "", children: itemValue.substr(index, userValue.length) }, parts.length) 41900 ); 41901 itemValue = itemValue.substr(index + userValue.length); 41902 index = normalizeValue(itemValue).indexOf(userValue); 41903 } 41904 if (itemValue) { 41905 parts.push( 41906 /* @__PURE__ */ (0,jsx_runtime.jsx)("span", { "data-autocomplete-value": "", children: itemValue }, parts.length) 41907 ); 41908 } 41909 return parts; 41910 } 41911 var useComboboxItemValue = createHook( 41912 (_a) => { 41913 var _b = _a, { store, value } = _b, props = __objRest(_b, ["store", "value"]); 41914 const context = useComboboxScopedContext(); 41915 store = store || context; 41916 const itemContext = (0,external_React_.useContext)(ComboboxItemValueContext); 41917 const itemValue = value != null ? value : itemContext; 41918 invariant( 41919 store, 41920 false && 0 41921 ); 41922 const stateValue = store.useState( 41923 (state) => itemValue && state.value ? state.value : void 0 41924 ); 41925 const children = (0,external_React_.useMemo)( 41926 () => itemValue && stateValue ? splitValue(itemValue, stateValue) : itemValue, 41927 [itemValue, stateValue] 41928 ); 41929 props = _4R3V3JGP_spreadValues({ 41930 children 41931 }, props); 41932 return props; 41933 } 41934 ); 41935 var ComboboxItemValue = createComponent( 41936 (props) => { 41937 const htmlProps = useComboboxItemValue(props); 41938 return _3ORBWXWF_createElement("span", htmlProps); 41939 } 41940 ); 41941 if (false) {} 41942 41943 41944 ;// CONCATENATED MODULE: ./node_modules/@wordpress/dataviews/build-module/search-widget.js 41945 41946 /** 41947 * External dependencies 41948 */ 41949 // eslint-disable-next-line no-restricted-imports 41950 41951 41952 41953 /** 41954 * WordPress dependencies 41955 */ 41956 41957 41958 41959 41960 41961 const radioCheck = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { 41962 xmlns: "http://www.w3.org/2000/svg", 41963 viewBox: "0 0 24 24" 41964 }, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Circle, { 41965 cx: 12, 41966 cy: 12, 41967 r: 3 41968 })); 41969 function search_widget_normalizeSearchInput(input = '') { 41970 return remove_accents_default()(input.trim().toLowerCase()); 41971 } 41972 function SearchWidget({ 41973 filter, 41974 view, 41975 onChangeView 41976 }) { 41977 const [searchValue, setSearchValue] = (0,external_wp_element_namespaceObject.useState)(''); 41978 const deferredSearchValue = (0,external_wp_element_namespaceObject.useDeferredValue)(searchValue); 41979 const selectedFilter = view.filters.find(_filter => _filter.field === filter.field); 41980 const selectedValues = selectedFilter?.value; 41981 const matches = (0,external_wp_element_namespaceObject.useMemo)(() => { 41982 const normalizedSearch = search_widget_normalizeSearchInput(deferredSearchValue); 41983 return filter.elements.filter(item => search_widget_normalizeSearchInput(item.label).includes(normalizedSearch)); 41984 }, [filter.elements, deferredSearchValue]); 41985 return (0,external_React_.createElement)(ComboboxProvider, { 41986 value: searchValue, 41987 setSelectedValue: value => { 41988 const currentFilter = view.filters.find(_filter => _filter.field === filter.field); 41989 const newFilters = currentFilter ? [...view.filters.map(_filter => { 41990 if (_filter.field === filter.field) { 41991 return { 41992 ..._filter, 41993 operator: currentFilter.operator || filter.operators[0], 41994 value 41995 }; 41996 } 41997 return _filter; 41998 })] : [...view.filters, { 41999 field: filter.field, 42000 operator: filter.operators[0], 42001 value 42002 }]; 42003 onChangeView({ 42004 ...view, 42005 page: 1, 42006 filters: newFilters 42007 }); 42008 }, 42009 setValue: setSearchValue 42010 }, (0,external_React_.createElement)("div", { 42011 className: "dataviews-search-widget-filter-combobox__wrapper" 42012 }, (0,external_React_.createElement)(ComboboxLabel, { 42013 render: (0,external_React_.createElement)(external_wp_components_namespaceObject.VisuallyHidden, null) 42014 }, (0,external_wp_i18n_namespaceObject.__)('Search items')), (0,external_React_.createElement)(Combobox, { 42015 autoSelect: "always", 42016 placeholder: (0,external_wp_i18n_namespaceObject.__)('Search'), 42017 className: "dataviews-search-widget-filter-combobox__input" 42018 }), (0,external_React_.createElement)("div", { 42019 className: "dataviews-search-widget-filter-combobox__icon" 42020 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.Icon, { 42021 icon: library_search 42022 }))), (0,external_React_.createElement)(ComboboxList, { 42023 className: "dataviews-search-widget-filter-combobox-list", 42024 alwaysVisible: true 42025 }, matches.map(element => { 42026 return (0,external_React_.createElement)(ComboboxItem, { 42027 key: element.value, 42028 value: element.value, 42029 className: "dataviews-search-widget-filter-combobox-item", 42030 hideOnClick: false, 42031 setValueOnClick: false, 42032 focusOnHover: true 42033 }, (0,external_React_.createElement)("span", { 42034 className: "dataviews-search-widget-filter-combobox-item-check" 42035 }, selectedValues === element.value && (0,external_React_.createElement)(external_wp_components_namespaceObject.Icon, { 42036 icon: radioCheck 42037 })), (0,external_React_.createElement)("span", null, (0,external_React_.createElement)(ComboboxItemValue, { 42038 className: "dataviews-search-widget-filter-combobox-item-value", 42039 value: element.label 42040 }), !!element.description && (0,external_React_.createElement)("span", { 42041 className: "dataviews-search-widget-filter-combobox-item-description" 42042 }, element.description))); 42043 }), !matches.length && (0,external_React_.createElement)("p", null, (0,external_wp_i18n_namespaceObject.__)('No results found')))); 42044 } 42045 42046 ;// CONCATENATED MODULE: ./node_modules/@wordpress/dataviews/build-module/filter-summary.js 42047 42048 /** 42049 * External dependencies 42050 */ 42051 42052 42053 /** 42054 * WordPress dependencies 42055 */ 42056 42057 42058 42059 42060 42061 42062 /** 42063 * Internal dependencies 42064 */ 42065 42066 42067 const FilterText = ({ 42068 activeElement, 42069 filterInView, 42070 filter 42071 }) => { 42072 if (activeElement === undefined) { 42073 return filter.name; 42074 } 42075 const filterTextWrappers = { 42076 Span1: (0,external_React_.createElement)("span", { 42077 className: "dataviews-filter-summary__filter-text-name" 42078 }), 42079 Span2: (0,external_React_.createElement)("span", { 42080 className: "dataviews-filter-summary__filter-text-value" 42081 }) 42082 }; 42083 if (activeElement !== undefined && filterInView?.operator === constants_OPERATOR_IN) { 42084 return (0,external_wp_element_namespaceObject.createInterpolateElement)((0,external_wp_i18n_namespaceObject.sprintf)( /* translators: 1: Filter name. 2: Filter value. e.g.: "Author is Admin". */ 42085 (0,external_wp_i18n_namespaceObject.__)('<Span1>%1$s </Span1><Span2>is %2$s</Span2>'), filter.name, activeElement.label), filterTextWrappers); 42086 } 42087 if (activeElement !== undefined && filterInView?.operator === constants_OPERATOR_NOT_IN) { 42088 return (0,external_wp_element_namespaceObject.createInterpolateElement)((0,external_wp_i18n_namespaceObject.sprintf)( /* translators: 1: Filter name. 2: Filter value. e.g.: "Author is not Admin". */ 42089 (0,external_wp_i18n_namespaceObject.__)('<Span1>%1$s </Span1><Span2>is not %2$s</Span2>'), filter.name, activeElement.label), filterTextWrappers); 42090 } 42091 return (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: 1: Filter name e.g.: "Unknown status for Author". */ 42092 (0,external_wp_i18n_namespaceObject.__)('Unknown status for %1$s'), filter.name); 42093 }; 42094 function OperatorSelector({ 42095 filter, 42096 view, 42097 onChangeView 42098 }) { 42099 const operatorOptions = filter.operators?.map(operator => ({ 42100 value: operator, 42101 label: OPERATORS[operator]?.label 42102 })); 42103 const currentFilter = view.filters.find(_filter => _filter.field === filter.field); 42104 const value = currentFilter?.operator || filter.operators[0]; 42105 return operatorOptions.length > 1 && (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { 42106 spacing: 2, 42107 justify: "flex-start", 42108 className: "dataviews-filter-summary__operators-container" 42109 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.FlexItem, { 42110 className: "dataviews-filter-summary__operators-filter-name" 42111 }, filter.name), (0,external_React_.createElement)(external_wp_components_namespaceObject.SelectControl, { 42112 label: (0,external_wp_i18n_namespaceObject.__)('Conditions'), 42113 value: value, 42114 options: operatorOptions, 42115 onChange: newValue => { 42116 const newFilters = currentFilter ? [...view.filters.map(_filter => { 42117 if (_filter.field === filter.field) { 42118 return { 42119 ..._filter, 42120 operator: newValue 42121 }; 42122 } 42123 return _filter; 42124 })] : [...view.filters, { 42125 field: filter.field, 42126 operator: newValue 42127 }]; 42128 onChangeView({ 42129 ...view, 42130 page: 1, 42131 filters: newFilters 42132 }); 42133 }, 42134 size: "small", 42135 __nextHasNoMarginBottom: true, 42136 hideLabelFromVision: true 42137 })); 42138 } 42139 function FilterSummary({ 42140 addFilterRef, 42141 openedFilter, 42142 ...commonProps 42143 }) { 42144 const toggleRef = (0,external_wp_element_namespaceObject.useRef)(); 42145 const { 42146 filter, 42147 view, 42148 onChangeView 42149 } = commonProps; 42150 const filterInView = view.filters.find(f => f.field === filter.field); 42151 const activeElement = filter.elements.find(element => element.value === filterInView?.value); 42152 const isPrimary = filter.isPrimary; 42153 const hasValues = filterInView?.value !== undefined; 42154 const canResetOrRemove = !isPrimary || hasValues; 42155 return (0,external_React_.createElement)(external_wp_components_namespaceObject.Dropdown, { 42156 defaultOpen: openedFilter === filter.field, 42157 contentClassName: "dataviews-filter-summary__popover", 42158 popoverProps: { 42159 placement: 'bottom-start', 42160 role: 'dialog' 42161 }, 42162 onClose: () => { 42163 toggleRef.current?.focus(); 42164 }, 42165 renderToggle: ({ 42166 isOpen, 42167 onToggle 42168 }) => (0,external_React_.createElement)("div", { 42169 className: "dataviews-filter-summary__chip-container" 42170 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.Tooltip, { 42171 text: (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: 1: Filter name. */ 42172 (0,external_wp_i18n_namespaceObject.__)('Filter by: %1$s'), filter.name.toLowerCase()), 42173 placement: "top" 42174 }, (0,external_React_.createElement)("div", { 42175 className: classnames_default()('dataviews-filter-summary__chip', { 42176 'has-reset': canResetOrRemove, 42177 'has-values': hasValues 42178 }), 42179 role: "button", 42180 tabIndex: 0, 42181 onClick: onToggle, 42182 onKeyDown: event => { 42183 if ([external_wp_keycodes_namespaceObject.ENTER, external_wp_keycodes_namespaceObject.SPACE].includes(event.keyCode)) { 42184 onToggle(); 42185 event.preventDefault(); 42186 } 42187 }, 42188 "aria-pressed": isOpen, 42189 "aria-expanded": isOpen, 42190 ref: toggleRef 42191 }, (0,external_React_.createElement)(FilterText, { 42192 activeElement: activeElement, 42193 filterInView: filterInView, 42194 filter: filter 42195 }))), canResetOrRemove && (0,external_React_.createElement)(external_wp_components_namespaceObject.Tooltip, { 42196 text: isPrimary ? (0,external_wp_i18n_namespaceObject.__)('Reset') : (0,external_wp_i18n_namespaceObject.__)('Remove'), 42197 placement: "top" 42198 }, (0,external_React_.createElement)("button", { 42199 className: classnames_default()('dataviews-filter-summary__chip-remove', { 42200 'has-values': hasValues 42201 }), 42202 onClick: () => { 42203 onChangeView({ 42204 ...view, 42205 page: 1, 42206 filters: view.filters.filter(_filter => _filter.field !== filter.field) 42207 }); 42208 // If the filter is not primary and can be removed, it will be added 42209 // back to the available filters from `Add filter` component. 42210 if (!isPrimary) { 42211 addFilterRef.current?.focus(); 42212 } else { 42213 // If is primary, focus the toggle button. 42214 toggleRef.current?.focus(); 42215 } 42216 } 42217 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.Icon, { 42218 icon: close_small 42219 })))), 42220 renderContent: () => { 42221 return (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { 42222 spacing: 0, 42223 justify: "flex-start" 42224 }, (0,external_React_.createElement)(OperatorSelector, { 42225 ...commonProps 42226 }), (0,external_React_.createElement)(SearchWidget, { 42227 ...commonProps 42228 })); 42229 } 42230 }); 42231 } 42232 42233 ;// CONCATENATED MODULE: ./node_modules/@wordpress/dataviews/build-module/add-filter.js 42234 42235 /** 42236 * WordPress dependencies 42237 */ 42238 42239 42240 42241 42242 42243 /** 42244 * Internal dependencies 42245 */ 42246 42247 const { 42248 DropdownMenuV2: add_filter_DropdownMenu, 42249 DropdownMenuItemV2: add_filter_DropdownMenuItem, 42250 DropdownMenuItemLabelV2: add_filter_DropdownMenuItemLabel 42251 } = lock_unlock_unlock(external_wp_components_namespaceObject.privateApis); 42252 function AddFilter({ 42253 filters, 42254 view, 42255 onChangeView, 42256 setOpenedFilter 42257 }, ref) { 42258 if (!filters.length || filters.every(({ 42259 isPrimary 42260 }) => isPrimary)) { 42261 return null; 42262 } 42263 const inactiveFilters = filters.filter(filter => !filter.isVisible); 42264 return (0,external_React_.createElement)(add_filter_DropdownMenu, { 42265 trigger: (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 42266 __experimentalIsFocusable: true, 42267 size: "compact", 42268 icon: library_plus, 42269 className: "dataviews-filters-button", 42270 variant: "tertiary", 42271 disabled: !inactiveFilters.length, 42272 ref: ref 42273 }, (0,external_wp_i18n_namespaceObject.__)('Add filter')) 42274 }, inactiveFilters.map(filter => { 42275 return (0,external_React_.createElement)(add_filter_DropdownMenuItem, { 42276 key: filter.field, 42277 onClick: () => { 42278 setOpenedFilter(filter.field); 42279 onChangeView({ 42280 ...view, 42281 page: 1, 42282 filters: [...(view.filters || []), { 42283 field: filter.field, 42284 value: undefined, 42285 operator: filter.operators[0] 42286 }] 42287 }); 42288 } 42289 }, (0,external_React_.createElement)(add_filter_DropdownMenuItemLabel, null, filter.name)); 42290 })); 42291 } 42292 /* harmony default export */ const add_filter = ((0,external_wp_element_namespaceObject.forwardRef)(AddFilter)); 42293 42294 ;// CONCATENATED MODULE: ./node_modules/@wordpress/dataviews/build-module/reset-filters.js 42295 42296 /** 42297 * WordPress dependencies 42298 */ 42299 42300 42301 function ResetFilter({ 42302 filters, 42303 view, 42304 onChangeView 42305 }) { 42306 const isPrimary = field => filters.some(_filter => _filter.field === field && _filter.isPrimary); 42307 const isDisabled = !view.search && !view.filters?.some(_filter => _filter.value !== undefined || !isPrimary(_filter.field)); 42308 return (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 42309 disabled: isDisabled, 42310 __experimentalIsFocusable: true, 42311 size: "compact", 42312 variant: "tertiary", 42313 onClick: () => { 42314 onChangeView({ 42315 ...view, 42316 page: 1, 42317 search: '', 42318 filters: [] 42319 }); 42320 } 42321 }, (0,external_wp_i18n_namespaceObject.__)('Reset filters')); 42322 } 42323 42324 ;// CONCATENATED MODULE: ./node_modules/@wordpress/dataviews/build-module/filters.js 42325 42326 /** 42327 * WordPress dependencies 42328 */ 42329 42330 42331 /** 42332 * Internal dependencies 42333 */ 42334 42335 42336 42337 42338 42339 42340 const Filters = (0,external_wp_element_namespaceObject.memo)(function Filters({ 42341 fields, 42342 view, 42343 onChangeView, 42344 openedFilter, 42345 setOpenedFilter 42346 }) { 42347 const addFilterRef = (0,external_wp_element_namespaceObject.useRef)(); 42348 const filters = []; 42349 fields.forEach(field => { 42350 if (!field.type) { 42351 return; 42352 } 42353 const operators = sanitizeOperators(field); 42354 if (operators.length === 0) { 42355 return; 42356 } 42357 switch (field.type) { 42358 case constants_ENUMERATION_TYPE: 42359 if (!field.elements?.length) { 42360 return; 42361 } 42362 const isPrimary = !!field.filterBy?.isPrimary; 42363 filters.push({ 42364 field: field.id, 42365 name: field.header, 42366 elements: field.elements, 42367 operators, 42368 isVisible: isPrimary || view.filters.some(f => f.field === field.id && [constants_OPERATOR_IN, constants_OPERATOR_NOT_IN].includes(f.operator)), 42369 isPrimary 42370 }); 42371 } 42372 }); 42373 // Sort filters by primary property. We need the primary filters to be first. 42374 // Then we sort by name. 42375 filters.sort((a, b) => { 42376 if (a.isPrimary && !b.isPrimary) { 42377 return -1; 42378 } 42379 if (!a.isPrimary && b.isPrimary) { 42380 return 1; 42381 } 42382 return a.name.localeCompare(b.name); 42383 }); 42384 const addFilter = (0,external_React_.createElement)(add_filter, { 42385 key: "add-filter", 42386 filters: filters, 42387 view: view, 42388 onChangeView: onChangeView, 42389 ref: addFilterRef, 42390 setOpenedFilter: setOpenedFilter 42391 }); 42392 const filterComponents = [...filters.map(filter => { 42393 if (!filter.isVisible) { 42394 return null; 42395 } 42396 return (0,external_React_.createElement)(FilterSummary, { 42397 key: filter.field, 42398 filter: filter, 42399 view: view, 42400 onChangeView: onChangeView, 42401 addFilterRef: addFilterRef, 42402 openedFilter: openedFilter 42403 }); 42404 }), addFilter]; 42405 if (filterComponents.length > 1) { 42406 filterComponents.push((0,external_React_.createElement)(ResetFilter, { 42407 key: "reset-filters", 42408 filters: filters, 42409 view: view, 42410 onChangeView: onChangeView 42411 })); 42412 } 42413 return (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { 42414 justify: "flex-start", 42415 style: { 42416 width: 'fit-content' 42417 }, 42418 wrap: true 42419 }, filterComponents); 42420 }); 42421 /* harmony default export */ const filters = (Filters); 42422 42423 ;// CONCATENATED MODULE: ./node_modules/@wordpress/dataviews/build-module/search.js 42424 42425 /** 42426 * WordPress dependencies 42427 */ 42428 42429 42430 42431 42432 const Search = (0,external_wp_element_namespaceObject.memo)(function Search({ 42433 label, 42434 view, 42435 onChangeView 42436 }) { 42437 const [search, setSearch, debouncedSearch] = (0,external_wp_compose_namespaceObject.useDebouncedInput)(view.search); 42438 (0,external_wp_element_namespaceObject.useEffect)(() => { 42439 setSearch(view.search); 42440 }, [view]); 42441 const onChangeViewRef = (0,external_wp_element_namespaceObject.useRef)(onChangeView); 42442 (0,external_wp_element_namespaceObject.useEffect)(() => { 42443 onChangeViewRef.current = onChangeView; 42444 }, [onChangeView]); 42445 (0,external_wp_element_namespaceObject.useEffect)(() => { 42446 onChangeViewRef.current({ 42447 ...view, 42448 page: 1, 42449 search: debouncedSearch 42450 }); 42451 }, [debouncedSearch]); 42452 const searchLabel = label || (0,external_wp_i18n_namespaceObject.__)('Search'); 42453 return (0,external_React_.createElement)(external_wp_components_namespaceObject.SearchControl, { 42454 __nextHasNoMarginBottom: true, 42455 onChange: setSearch, 42456 value: search, 42457 label: searchLabel, 42458 placeholder: searchLabel, 42459 size: "compact" 42460 }); 42461 }); 42462 /* harmony default export */ const build_module_search = (Search); 42463 42464 ;// CONCATENATED MODULE: ./node_modules/@wordpress/dataviews/build-module/dataviews.js 42465 42466 /** 42467 * WordPress dependencies 42468 */ 42469 42470 42471 42472 /** 42473 * Internal dependencies 42474 */ 42475 42476 42477 42478 42479 42480 42481 const defaultGetItemId = item => item.id; 42482 const defaultOnSelectionChange = () => {}; 42483 function dataviews_useSomeItemHasAPossibleBulkAction(actions, data) { 42484 return (0,external_wp_element_namespaceObject.useMemo)(() => { 42485 return data.some(item => { 42486 return actions.some(action => { 42487 return action.supportsBulk && action.isEligible(item); 42488 }); 42489 }); 42490 }, [actions, data]); 42491 } 42492 function DataViews({ 42493 view, 42494 onChangeView, 42495 fields, 42496 search = true, 42497 searchLabel = undefined, 42498 actions, 42499 data, 42500 getItemId = defaultGetItemId, 42501 isLoading = false, 42502 paginationInfo, 42503 supportedLayouts, 42504 onSelectionChange = defaultOnSelectionChange, 42505 onDetailsChange = null, 42506 deferredRendering = false 42507 }) { 42508 const [selection, setSelection] = (0,external_wp_element_namespaceObject.useState)([]); 42509 const [openedFilter, setOpenedFilter] = (0,external_wp_element_namespaceObject.useState)(null); 42510 (0,external_wp_element_namespaceObject.useEffect)(() => { 42511 if (selection.length > 0 && selection.some(id => !data.some(item => getItemId(item) === id))) { 42512 const newSelection = selection.filter(id => data.some(item => getItemId(item) === id)); 42513 setSelection(newSelection); 42514 onSelectionChange(data.filter(item => newSelection.includes(getItemId(item)))); 42515 } 42516 }, [selection, data, getItemId, onSelectionChange]); 42517 const onSetSelection = (0,external_wp_element_namespaceObject.useCallback)(items => { 42518 setSelection(items.map(item => getItemId(item))); 42519 onSelectionChange(items); 42520 }, [setSelection, getItemId, onSelectionChange]); 42521 const ViewComponent = VIEW_LAYOUTS.find(v => v.type === view.type).component; 42522 const _fields = (0,external_wp_element_namespaceObject.useMemo)(() => { 42523 return fields.map(field => ({ 42524 ...field, 42525 render: field.render || field.getValue 42526 })); 42527 }, [fields]); 42528 const hasPossibleBulkAction = dataviews_useSomeItemHasAPossibleBulkAction(actions, data); 42529 return (0,external_React_.createElement)("div", { 42530 className: "dataviews-wrapper" 42531 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { 42532 alignment: "top", 42533 justify: "start", 42534 className: "dataviews-filters__view-actions" 42535 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { 42536 justify: "start", 42537 className: "dataviews-filters__container", 42538 wrap: true 42539 }, search && (0,external_React_.createElement)(build_module_search, { 42540 label: searchLabel, 42541 view: view, 42542 onChangeView: onChangeView 42543 }), (0,external_React_.createElement)(filters, { 42544 fields: _fields, 42545 view: view, 42546 onChangeView: onChangeView, 42547 openedFilter: openedFilter, 42548 setOpenedFilter: setOpenedFilter 42549 })), [constants_LAYOUT_TABLE, constants_LAYOUT_GRID].includes(view.type) && hasPossibleBulkAction && (0,external_React_.createElement)(BulkActions, { 42550 actions: actions, 42551 data: data, 42552 onSelectionChange: onSetSelection, 42553 selection: selection, 42554 getItemId: getItemId 42555 }), (0,external_React_.createElement)(view_actions, { 42556 fields: _fields, 42557 view: view, 42558 onChangeView: onChangeView, 42559 supportedLayouts: supportedLayouts 42560 })), (0,external_React_.createElement)(ViewComponent, { 42561 fields: _fields, 42562 view: view, 42563 onChangeView: onChangeView, 42564 actions: actions, 42565 data: data, 42566 getItemId: getItemId, 42567 isLoading: isLoading, 42568 onSelectionChange: onSetSelection, 42569 onDetailsChange: onDetailsChange, 42570 selection: selection, 42571 deferredRendering: deferredRendering, 42572 setOpenedFilter: setOpenedFilter 42573 }), (0,external_React_.createElement)(pagination, { 42574 view: view, 42575 onChangeView: onChangeView, 42576 paginationInfo: paginationInfo 42577 })); 42578 } 42579 42580 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/page/header.js 42581 42582 /** 42583 * WordPress dependencies 42584 */ 42585 42586 42587 /** 42588 * Internal dependencies 42589 */ 42590 42591 function Header({ 42592 title, 42593 subTitle, 42594 actions 42595 }) { 42596 return (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { 42597 as: "header", 42598 alignment: "left", 42599 className: "edit-site-page-header" 42600 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.FlexBlock, { 42601 className: "edit-site-page-header__page-title" 42602 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHeading, { 42603 as: "h2", 42604 level: 3, 42605 weight: 500, 42606 className: "edit-site-page-header__title" 42607 }, title), subTitle && (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalText, { 42608 as: "p", 42609 className: "edit-site-page-header__sub-title" 42610 }, subTitle)), (0,external_React_.createElement)(external_wp_components_namespaceObject.FlexItem, { 42611 className: "edit-site-page-header__actions" 42612 }, actions)); 42613 } 42614 42615 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/page/index.js 42616 42617 /** 42618 * External dependencies 42619 */ 42620 42621 42622 /** 42623 * WordPress dependencies 42624 */ 42625 42626 42627 42628 /** 42629 * Internal dependencies 42630 */ 42631 42632 function Page({ 42633 title, 42634 subTitle, 42635 actions, 42636 children, 42637 className, 42638 hideTitleFromUI = false 42639 }) { 42640 const classes = classnames_default()('edit-site-page', className); 42641 return (0,external_React_.createElement)(NavigableRegion, { 42642 className: classes, 42643 ariaLabel: title 42644 }, (0,external_React_.createElement)("div", { 42645 className: "edit-site-page-content" 42646 }, !hideTitleFromUI && title && (0,external_React_.createElement)(Header, { 42647 title: title, 42648 subTitle: subTitle, 42649 actions: actions 42650 }), children), (0,external_React_.createElement)(external_wp_editor_namespaceObject.EditorSnackbars, null)); 42651 } 42652 42653 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/actions/index.js 42654 42655 /** 42656 * WordPress dependencies 42657 */ 42658 42659 42660 42661 42662 42663 42664 42665 42666 42667 42668 42669 /** 42670 * Internal dependencies 42671 */ 42672 42673 const { 42674 useHistory: actions_useHistory 42675 } = unlock(external_wp_router_namespaceObject.privateApis); 42676 const trashPostAction = { 42677 id: 'move-to-trash', 42678 label: (0,external_wp_i18n_namespaceObject.__)('Move to Trash'), 42679 isPrimary: true, 42680 icon: library_trash, 42681 isEligible({ 42682 status 42683 }) { 42684 return status !== 'trash'; 42685 }, 42686 supportsBulk: true, 42687 hideModalHeader: true, 42688 RenderModal: ({ 42689 items: posts, 42690 closeModal, 42691 onPerform 42692 }) => { 42693 const { 42694 createSuccessNotice, 42695 createErrorNotice 42696 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store); 42697 const { 42698 deleteEntityRecord 42699 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store); 42700 return (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { 42701 spacing: "5" 42702 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalText, null, posts.length === 1 ? (0,external_wp_i18n_namespaceObject.sprintf)( 42703 // translators: %s: The page's title. 42704 (0,external_wp_i18n_namespaceObject.__)('Are you sure you want to delete "%s"?'), (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(posts[0].title.rendered)) : (0,external_wp_i18n_namespaceObject.sprintf)( 42705 // translators: %d: The number of pages (2 or more). 42706 (0,external_wp_i18n_namespaceObject.__)('Are you sure you want to delete %d pages?'), posts.length)), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { 42707 justify: "right" 42708 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 42709 variant: "tertiary", 42710 onClick: closeModal 42711 }, (0,external_wp_i18n_namespaceObject.__)('Cancel')), (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 42712 variant: "primary", 42713 onClick: async () => { 42714 const promiseResult = await Promise.allSettled(posts.map(post => { 42715 return deleteEntityRecord('postType', post.type, post.id, {}, { 42716 throwOnError: true 42717 }); 42718 })); 42719 // If all the promises were fulfilled with success. 42720 if (promiseResult.every(({ 42721 status 42722 }) => status === 'fulfilled')) { 42723 let successMessage; 42724 if (promiseResult.length === 1) { 42725 successMessage = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: The posts's title. */ 42726 (0,external_wp_i18n_namespaceObject.__)('"%s" moved to the Trash.'), (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(posts[0].title.rendered)); 42727 } else { 42728 successMessage = (0,external_wp_i18n_namespaceObject.__)('Pages moved to the Trash.'); 42729 } 42730 createSuccessNotice(successMessage, { 42731 type: 'snackbar', 42732 id: 'edit-site-page-trashed' 42733 }); 42734 } else { 42735 // If there was at lease one failure. 42736 let errorMessage; 42737 // If we were trying to move a single post to the trash. 42738 if (promiseResult.length === 1) { 42739 if (promiseResult[0].reason?.message) { 42740 errorMessage = promiseResult[0].reason.message; 42741 } else { 42742 errorMessage = (0,external_wp_i18n_namespaceObject.__)('An error occurred while moving the post to the trash.'); 42743 } 42744 // If we were trying to move multiple posts to the trash 42745 } else { 42746 const errorMessages = new Set(); 42747 const failedPromises = promiseResult.filter(({ 42748 status 42749 }) => status === 'rejected'); 42750 for (const failedPromise of failedPromises) { 42751 if (failedPromise.reason?.message) { 42752 errorMessages.add(failedPromise.reason.message); 42753 } 42754 } 42755 if (errorMessages.size === 0) { 42756 errorMessage = (0,external_wp_i18n_namespaceObject.__)('An error occurred while moving the posts to the trash.'); 42757 } else if (errorMessages.size === 1) { 42758 errorMessage = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: an error message */ 42759 (0,external_wp_i18n_namespaceObject.__)('An error occurred while moving the posts to the trash: %s'), [...errorMessages][0]); 42760 } else { 42761 errorMessage = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: a list of comma separated error messages */ 42762 (0,external_wp_i18n_namespaceObject.__)('Some errors occurred while moving the pages to the trash: %s'), [...errorMessages].join(',')); 42763 } 42764 createErrorNotice(errorMessage, { 42765 type: 'snackbar' 42766 }); 42767 } 42768 } 42769 if (onPerform) { 42770 onPerform(); 42771 } 42772 closeModal(); 42773 } 42774 }, (0,external_wp_i18n_namespaceObject.__)('Delete')))); 42775 } 42776 }; 42777 function usePermanentlyDeletePostAction() { 42778 const { 42779 createSuccessNotice, 42780 createErrorNotice 42781 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store); 42782 const { 42783 deleteEntityRecord 42784 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store); 42785 return (0,external_wp_element_namespaceObject.useMemo)(() => ({ 42786 id: 'permanently-delete', 42787 label: (0,external_wp_i18n_namespaceObject.__)('Permanently delete'), 42788 isPrimary: true, 42789 icon: library_trash, 42790 supportsBulk: true, 42791 isEligible({ 42792 status 42793 }) { 42794 return status === 'trash'; 42795 }, 42796 async callback(posts) { 42797 const promiseResult = await Promise.allSettled(posts.map(post => { 42798 return deleteEntityRecord('postType', post.type, post.id, { 42799 force: true 42800 }, { 42801 throwOnError: true 42802 }); 42803 })); 42804 // If all the promises were fulfilled with success. 42805 if (promiseResult.every(({ 42806 status 42807 }) => status === 'fulfilled')) { 42808 let successMessage; 42809 if (promiseResult.length === 1) { 42810 successMessage = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: The posts's title. */ 42811 (0,external_wp_i18n_namespaceObject.__)('"%s" permanently deleted.'), (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(posts[0].title.rendered)); 42812 } else { 42813 successMessage = (0,external_wp_i18n_namespaceObject.__)('The posts were permanently deleted.'); 42814 } 42815 createSuccessNotice(successMessage, { 42816 type: 'snackbar', 42817 id: 'edit-site-post-permanently-deleted' 42818 }); 42819 } else { 42820 // If there was at lease one failure. 42821 let errorMessage; 42822 // If we were trying to permanently delete a single post. 42823 if (promiseResult.length === 1) { 42824 if (promiseResult[0].reason?.message) { 42825 errorMessage = promiseResult[0].reason.message; 42826 } else { 42827 errorMessage = (0,external_wp_i18n_namespaceObject.__)('An error occurred while permanently deleting the post.'); 42828 } 42829 // If we were trying to permanently delete multiple posts 42830 } else { 42831 const errorMessages = new Set(); 42832 const failedPromises = promiseResult.filter(({ 42833 status 42834 }) => status === 'rejected'); 42835 for (const failedPromise of failedPromises) { 42836 if (failedPromise.reason?.message) { 42837 errorMessages.add(failedPromise.reason.message); 42838 } 42839 } 42840 if (errorMessages.size === 0) { 42841 errorMessage = (0,external_wp_i18n_namespaceObject.__)('An error occurred while permanently deleting the posts.'); 42842 } else if (errorMessages.size === 1) { 42843 errorMessage = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: an error message */ 42844 (0,external_wp_i18n_namespaceObject.__)('An error occurred while permanently deleting the posts: %s'), [...errorMessages][0]); 42845 } else { 42846 errorMessage = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: a list of comma separated error messages */ 42847 (0,external_wp_i18n_namespaceObject.__)('Some errors occurred while permanently deleting the posts: %s'), [...errorMessages].join(',')); 42848 } 42849 createErrorNotice(errorMessage, { 42850 type: 'snackbar' 42851 }); 42852 } 42853 } 42854 } 42855 }), [createSuccessNotice, createErrorNotice, deleteEntityRecord]); 42856 } 42857 function useRestorePostAction() { 42858 const { 42859 createSuccessNotice, 42860 createErrorNotice 42861 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store); 42862 const { 42863 editEntityRecord, 42864 saveEditedEntityRecord 42865 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store); 42866 return (0,external_wp_element_namespaceObject.useMemo)(() => ({ 42867 id: 'restore', 42868 label: (0,external_wp_i18n_namespaceObject.__)('Restore'), 42869 isPrimary: true, 42870 icon: library_backup, 42871 supportsBulk: true, 42872 isEligible({ 42873 status 42874 }) { 42875 return status === 'trash'; 42876 }, 42877 async callback(posts) { 42878 try { 42879 for (const post of posts) { 42880 await editEntityRecord('postType', post.type, post.id, { 42881 status: 'draft' 42882 }); 42883 await saveEditedEntityRecord('postType', post.type, post.id, { 42884 throwOnError: true 42885 }); 42886 } 42887 createSuccessNotice(posts.length > 1 ? (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: The number of posts. */ 42888 (0,external_wp_i18n_namespaceObject.__)('%d posts have been restored.'), posts.length) : (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: The number of posts. */ 42889 (0,external_wp_i18n_namespaceObject.__)('"%s" has been restored.'), (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(posts[0].title.rendered)), { 42890 type: 'snackbar', 42891 id: 'edit-site-post-restored' 42892 }); 42893 } catch (error) { 42894 let errorMessage; 42895 if (error.message && error.code !== 'unknown_error' && error.message) { 42896 errorMessage = error.message; 42897 } else if (posts.length > 1) { 42898 errorMessage = (0,external_wp_i18n_namespaceObject.__)('An error occurred while restoring the posts.'); 42899 } else { 42900 errorMessage = (0,external_wp_i18n_namespaceObject.__)('An error occurred while restoring the post.'); 42901 } 42902 createErrorNotice(errorMessage, { 42903 type: 'snackbar' 42904 }); 42905 } 42906 } 42907 }), [createSuccessNotice, createErrorNotice, editEntityRecord, saveEditedEntityRecord]); 42908 } 42909 const viewPostAction = { 42910 id: 'view-post', 42911 label: (0,external_wp_i18n_namespaceObject.__)('View'), 42912 isPrimary: true, 42913 icon: library_external, 42914 isEligible(post) { 42915 return post.status !== 'trash'; 42916 }, 42917 callback(posts) { 42918 const post = posts[0]; 42919 document.location.href = post.link; 42920 } 42921 }; 42922 function useEditPostAction() { 42923 const history = actions_useHistory(); 42924 return (0,external_wp_element_namespaceObject.useMemo)(() => ({ 42925 id: 'edit-post', 42926 label: (0,external_wp_i18n_namespaceObject.__)('Edit'), 42927 isEligible({ 42928 status 42929 }) { 42930 return status !== 'trash'; 42931 }, 42932 callback(posts) { 42933 const post = posts[0]; 42934 history.push({ 42935 postId: post.id, 42936 postType: post.type, 42937 canvas: 'edit' 42938 }); 42939 } 42940 }), [history]); 42941 } 42942 const postRevisionsAction = { 42943 id: 'view-post-revisions', 42944 label: (0,external_wp_i18n_namespaceObject.__)('View revisions'), 42945 isPrimary: false, 42946 isEligible: post => { 42947 var _post$_links$predeces, _post$_links$version; 42948 if (post.status === 'trash') { 42949 return false; 42950 } 42951 const lastRevisionId = (_post$_links$predeces = post?._links?.['predecessor-version']?.[0]?.id) !== null && _post$_links$predeces !== void 0 ? _post$_links$predeces : null; 42952 const revisionsCount = (_post$_links$version = post?._links?.['version-history']?.[0]?.count) !== null && _post$_links$version !== void 0 ? _post$_links$version : 0; 42953 return lastRevisionId && revisionsCount > 1; 42954 }, 42955 callback(posts) { 42956 const post = posts[0]; 42957 const href = (0,external_wp_url_namespaceObject.addQueryArgs)('revision.php', { 42958 revision: post?._links?.['predecessor-version']?.[0]?.id 42959 }); 42960 document.location.href = href; 42961 } 42962 }; 42963 42964 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/media/index.js 42965 42966 /** 42967 * WordPress dependencies 42968 */ 42969 42970 function Media({ 42971 id, 42972 size = ['large', 'medium', 'thumbnail'], 42973 ...props 42974 }) { 42975 const { 42976 record: media 42977 } = (0,external_wp_coreData_namespaceObject.useEntityRecord)('root', 'media', id); 42978 const currentSize = size.find(s => !!media?.media_details?.sizes[s]); 42979 const mediaUrl = media?.media_details?.sizes[currentSize]?.source_url || media?.source_url; 42980 if (!mediaUrl) { 42981 return null; 42982 } 42983 return (0,external_React_.createElement)("img", { 42984 ...props, 42985 src: mediaUrl, 42986 alt: media.alt_text 42987 }); 42988 } 42989 /* harmony default export */ const components_media = (Media); 42990 42991 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/page-pages/index.js 42992 42993 /** 42994 * External dependencies 42995 */ 42996 42997 42998 /** 42999 * WordPress dependencies 43000 */ 43001 43002 43003 43004 43005 43006 43007 43008 43009 43010 43011 /** 43012 * Internal dependencies 43013 */ 43014 43015 43016 43017 43018 43019 43020 43021 43022 const { 43023 useLocation: page_pages_useLocation, 43024 useHistory: page_pages_useHistory 43025 } = unlock(external_wp_router_namespaceObject.privateApis); 43026 const page_pages_EMPTY_ARRAY = []; 43027 const SUPPORTED_LAYOUTS = window?.__experimentalAdminViews ? [LAYOUT_GRID, LAYOUT_TABLE, LAYOUT_LIST] : [LAYOUT_GRID, LAYOUT_TABLE]; 43028 function useView(postType) { 43029 const { 43030 params 43031 } = page_pages_useLocation(); 43032 const { 43033 activeView = 'all', 43034 isCustom = 'false', 43035 layout 43036 } = params; 43037 const history = page_pages_useHistory(); 43038 const selectedDefaultView = (0,external_wp_element_namespaceObject.useMemo)(() => { 43039 const defaultView = isCustom === 'false' && DEFAULT_VIEWS[postType].find(({ 43040 slug 43041 }) => slug === activeView)?.view; 43042 if (isCustom === 'false' && layout) { 43043 return { 43044 ...defaultView, 43045 type: layout, 43046 layout: { 43047 ...(DEFAULT_CONFIG_PER_VIEW_TYPE[layout] || {}) 43048 } 43049 }; 43050 } 43051 return defaultView; 43052 }, [isCustom, activeView, layout, postType]); 43053 const [view, setView] = (0,external_wp_element_namespaceObject.useState)(selectedDefaultView); 43054 (0,external_wp_element_namespaceObject.useEffect)(() => { 43055 if (selectedDefaultView) { 43056 setView(selectedDefaultView); 43057 } 43058 }, [selectedDefaultView]); 43059 const editedViewRecord = (0,external_wp_data_namespaceObject.useSelect)(select => { 43060 if (isCustom !== 'true') { 43061 return; 43062 } 43063 const { 43064 getEditedEntityRecord 43065 } = select(external_wp_coreData_namespaceObject.store); 43066 const dataviewRecord = getEditedEntityRecord('postType', 'wp_dataviews', Number(activeView)); 43067 return dataviewRecord; 43068 }, [activeView, isCustom]); 43069 const { 43070 editEntityRecord 43071 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store); 43072 const customView = (0,external_wp_element_namespaceObject.useMemo)(() => { 43073 const storedView = editedViewRecord?.content && JSON.parse(editedViewRecord?.content); 43074 if (!storedView) { 43075 return storedView; 43076 } 43077 return { 43078 ...storedView, 43079 layout: { 43080 ...(DEFAULT_CONFIG_PER_VIEW_TYPE[storedView?.type] || {}) 43081 } 43082 }; 43083 }, [editedViewRecord?.content]); 43084 const setCustomView = (0,external_wp_element_namespaceObject.useCallback)(viewToSet => { 43085 editEntityRecord('postType', 'wp_dataviews', editedViewRecord?.id, { 43086 content: JSON.stringify(viewToSet) 43087 }); 43088 }, [editEntityRecord, editedViewRecord?.id]); 43089 const setDefaultViewAndUpdateUrl = (0,external_wp_element_namespaceObject.useCallback)(viewToSet => { 43090 if (viewToSet.type !== view?.type) { 43091 history.push({ 43092 ...params, 43093 layout: viewToSet.type 43094 }); 43095 } 43096 setView(viewToSet); 43097 }, [params, view?.type, history]); 43098 if (isCustom === 'false') { 43099 return [view, setDefaultViewAndUpdateUrl]; 43100 } else if (isCustom === 'true' && customView) { 43101 return [customView, setCustomView]; 43102 } 43103 // Loading state where no the view was not found on custom views or default views. 43104 return [DEFAULT_VIEWS[postType][0].view, setDefaultViewAndUpdateUrl]; 43105 } 43106 43107 // See https://github.com/WordPress/gutenberg/issues/55886 43108 // We do not support custom statutes at the moment. 43109 const STATUSES = [{ 43110 value: 'draft', 43111 label: (0,external_wp_i18n_namespaceObject.__)('Draft') 43112 }, { 43113 value: 'future', 43114 label: (0,external_wp_i18n_namespaceObject.__)('Scheduled') 43115 }, { 43116 value: 'pending', 43117 label: (0,external_wp_i18n_namespaceObject.__)('Pending Review') 43118 }, { 43119 value: 'private', 43120 label: (0,external_wp_i18n_namespaceObject.__)('Private') 43121 }, { 43122 value: 'publish', 43123 label: (0,external_wp_i18n_namespaceObject.__)('Published') 43124 }, { 43125 value: 'trash', 43126 label: (0,external_wp_i18n_namespaceObject.__)('Trash') 43127 }]; 43128 const DEFAULT_STATUSES = 'draft,future,pending,private,publish'; // All but 'trash'. 43129 43130 function FeaturedImage({ 43131 item, 43132 viewType 43133 }) { 43134 const { 43135 onClick 43136 } = useLink({ 43137 postId: item.id, 43138 postType: item.type, 43139 canvas: 'edit' 43140 }); 43141 const hasMedia = !!item.featured_media; 43142 const size = viewType === LAYOUT_GRID ? ['large', 'full', 'medium', 'thumbnail'] : ['thumbnail', 'medium', 'large', 'full']; 43143 const media = hasMedia ? (0,external_React_.createElement)(components_media, { 43144 className: "edit-site-page-pages__featured-image", 43145 id: item.featured_media, 43146 size: size 43147 }) : null; 43148 if (viewType === LAYOUT_LIST) { 43149 return media; 43150 } 43151 return (0,external_React_.createElement)("button", { 43152 className: classnames_default()('page-pages-preview-field__button', { 43153 'edit-site-page-pages__media-wrapper': viewType === LAYOUT_TABLE 43154 }), 43155 type: "button", 43156 onClick: onClick, 43157 "aria-label": item.title?.rendered || (0,external_wp_i18n_namespaceObject.__)('(no title)') 43158 }, media); 43159 } 43160 function PagePages() { 43161 const postType = 'page'; 43162 const [view, setView] = useView(postType); 43163 const history = page_pages_useHistory(); 43164 const { 43165 params 43166 } = page_pages_useLocation(); 43167 const { 43168 isCustom = 'false' 43169 } = params; 43170 const onSelectionChange = (0,external_wp_element_namespaceObject.useCallback)(items => { 43171 if (isCustom === 'false' && view?.type === LAYOUT_LIST) { 43172 history.push({ 43173 ...params, 43174 postId: items.length === 1 ? items[0].id : undefined 43175 }); 43176 } 43177 }, [history, params, view?.type, isCustom]); 43178 const queryArgs = (0,external_wp_element_namespaceObject.useMemo)(() => { 43179 const filters = {}; 43180 view.filters.forEach(filter => { 43181 if (filter.field === 'status' && filter.operator === OPERATOR_IN) { 43182 filters.status = filter.value; 43183 } 43184 if (filter.field === 'author' && filter.operator === OPERATOR_IN) { 43185 filters.author = filter.value; 43186 } else if (filter.field === 'author' && filter.operator === OPERATOR_NOT_IN) { 43187 filters.author_exclude = filter.value; 43188 } 43189 }); 43190 // We want to provide a different default item for the status filter 43191 // than the REST API provides. 43192 if (!filters.status || filters.status === '') { 43193 filters.status = DEFAULT_STATUSES; 43194 } 43195 return { 43196 per_page: view.perPage, 43197 page: view.page, 43198 _embed: 'author', 43199 order: view.sort?.direction, 43200 orderby: view.sort?.field, 43201 search: view.search, 43202 ...filters 43203 }; 43204 }, [view]); 43205 const { 43206 records: pages, 43207 isResolving: isLoadingPages, 43208 totalItems, 43209 totalPages 43210 } = (0,external_wp_coreData_namespaceObject.useEntityRecords)('postType', postType, queryArgs); 43211 const { 43212 records: authors, 43213 isResolving: isLoadingAuthors 43214 } = (0,external_wp_coreData_namespaceObject.useEntityRecords)('root', 'user'); 43215 const paginationInfo = (0,external_wp_element_namespaceObject.useMemo)(() => ({ 43216 totalItems, 43217 totalPages 43218 }), [totalItems, totalPages]); 43219 const fields = (0,external_wp_element_namespaceObject.useMemo)(() => [{ 43220 id: 'featured-image', 43221 header: (0,external_wp_i18n_namespaceObject.__)('Featured Image'), 43222 getValue: ({ 43223 item 43224 }) => item.featured_media, 43225 render: ({ 43226 item 43227 }) => (0,external_React_.createElement)(FeaturedImage, { 43228 item: item, 43229 viewType: view.type 43230 }), 43231 enableSorting: false, 43232 width: '1%' 43233 }, { 43234 header: (0,external_wp_i18n_namespaceObject.__)('Title'), 43235 id: 'title', 43236 getValue: ({ 43237 item 43238 }) => item.title?.rendered, 43239 render: ({ 43240 item 43241 }) => { 43242 return [LAYOUT_TABLE, LAYOUT_GRID].includes(view.type) ? (0,external_React_.createElement)(Link, { 43243 params: { 43244 postId: item.id, 43245 postType: item.type, 43246 canvas: 'edit' 43247 } 43248 }, (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(item.title?.rendered) || (0,external_wp_i18n_namespaceObject.__)('(no title)')) : (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(item.title?.rendered) || (0,external_wp_i18n_namespaceObject.__)('(no title)'); 43249 }, 43250 maxWidth: 300, 43251 enableHiding: false 43252 }, { 43253 header: (0,external_wp_i18n_namespaceObject.__)('Author'), 43254 id: 'author', 43255 getValue: ({ 43256 item 43257 }) => item._embedded?.author[0]?.name, 43258 type: ENUMERATION_TYPE, 43259 elements: authors?.map(({ 43260 id, 43261 name 43262 }) => ({ 43263 value: id, 43264 label: name 43265 })) || [] 43266 }, { 43267 header: (0,external_wp_i18n_namespaceObject.__)('Status'), 43268 id: 'status', 43269 getValue: ({ 43270 item 43271 }) => { 43272 var _STATUSES$find$label; 43273 return (_STATUSES$find$label = STATUSES.find(({ 43274 value 43275 }) => value === item.status)?.label) !== null && _STATUSES$find$label !== void 0 ? _STATUSES$find$label : item.status; 43276 }, 43277 type: ENUMERATION_TYPE, 43278 elements: STATUSES, 43279 enableSorting: false, 43280 filterBy: { 43281 operators: [OPERATOR_IN] 43282 } 43283 }, { 43284 header: (0,external_wp_i18n_namespaceObject.__)('Date'), 43285 id: 'date', 43286 getValue: ({ 43287 item 43288 }) => item.date, 43289 render: ({ 43290 item 43291 }) => { 43292 const formattedDate = (0,external_wp_date_namespaceObject.dateI18n)((0,external_wp_date_namespaceObject.getSettings)().formats.datetimeAbbreviated, (0,external_wp_date_namespaceObject.getDate)(item.date)); 43293 return (0,external_React_.createElement)("time", null, formattedDate); 43294 } 43295 }], [authors, view.type]); 43296 const permanentlyDeletePostAction = usePermanentlyDeletePostAction(); 43297 const restorePostAction = useRestorePostAction(); 43298 const editPostAction = useEditPostAction(); 43299 const actions = (0,external_wp_element_namespaceObject.useMemo)(() => [viewPostAction, trashPostAction, restorePostAction, permanentlyDeletePostAction, editPostAction, postRevisionsAction], [permanentlyDeletePostAction, restorePostAction, editPostAction]); 43300 const onChangeView = (0,external_wp_element_namespaceObject.useCallback)(newView => { 43301 if (newView.type !== view.type) { 43302 newView = { 43303 ...newView, 43304 layout: { 43305 ...DEFAULT_CONFIG_PER_VIEW_TYPE[newView.type] 43306 } 43307 }; 43308 } 43309 setView(newView); 43310 }, [view.type, setView]); 43311 const [showAddPageModal, setShowAddPageModal] = (0,external_wp_element_namespaceObject.useState)(false); 43312 const openModal = (0,external_wp_element_namespaceObject.useCallback)(() => { 43313 if (!showAddPageModal) { 43314 setShowAddPageModal(true); 43315 } 43316 }, [showAddPageModal]); 43317 const closeModal = (0,external_wp_element_namespaceObject.useCallback)(() => { 43318 if (showAddPageModal) { 43319 setShowAddPageModal(false); 43320 } 43321 }, [showAddPageModal]); 43322 const handleNewPage = (0,external_wp_element_namespaceObject.useCallback)(({ 43323 type, 43324 id 43325 }) => { 43326 history.push({ 43327 postId: id, 43328 postType: type, 43329 canvas: 'edit' 43330 }); 43331 closeModal(); 43332 }, [history]); 43333 43334 // TODO: we need to handle properly `data={ data || EMPTY_ARRAY }` for when `isLoading`. 43335 return (0,external_React_.createElement)(Page, { 43336 title: (0,external_wp_i18n_namespaceObject.__)('Pages'), 43337 actions: (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 43338 variant: "primary", 43339 onClick: openModal 43340 }, (0,external_wp_i18n_namespaceObject.__)('Add new page')), showAddPageModal && (0,external_React_.createElement)(AddNewPageModal, { 43341 onSave: handleNewPage, 43342 onClose: closeModal 43343 })) 43344 }, (0,external_React_.createElement)(DataViews, { 43345 paginationInfo: paginationInfo, 43346 fields: fields, 43347 actions: actions, 43348 data: pages || page_pages_EMPTY_ARRAY, 43349 isLoading: isLoadingPages || isLoadingAuthors, 43350 view: view, 43351 onChangeView: onChangeView, 43352 onSelectionChange: onSelectionChange, 43353 supportedLayouts: SUPPORTED_LAYOUTS 43354 })); 43355 } 43356 43357 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/header.js 43358 43359 /** 43360 * WordPress dependencies 43361 */ 43362 43363 const header_header = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { 43364 xmlns: "http://www.w3.org/2000/svg", 43365 viewBox: "0 0 24 24" 43366 }, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 43367 d: "M18.5 10.5H10v8h8a.5.5 0 00.5-.5v-7.5zm-10 0h-3V18a.5.5 0 00.5.5h2.5v-8zM6 4h12a2 2 0 012 2v12a2 2 0 01-2 2H6a2 2 0 01-2-2V6a2 2 0 012-2z" 43368 })); 43369 /* harmony default export */ const library_header = (header_header); 43370 43371 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/footer.js 43372 43373 /** 43374 * WordPress dependencies 43375 */ 43376 43377 const footer = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { 43378 xmlns: "http://www.w3.org/2000/svg", 43379 viewBox: "0 0 24 24" 43380 }, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 43381 fillRule: "evenodd", 43382 d: "M18 5.5h-8v8h8.5V6a.5.5 0 00-.5-.5zm-9.5 8h-3V6a.5.5 0 01.5-.5h2.5v8zM6 4h12a2 2 0 012 2v12a2 2 0 01-2 2H6a2 2 0 01-2-2V6a2 2 0 012-2z" 43383 })); 43384 /* harmony default export */ const library_footer = (footer); 43385 43386 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/lock-small.js 43387 43388 /** 43389 * WordPress dependencies 43390 */ 43391 43392 const lockSmall = (0,external_React_.createElement)(external_wp_primitives_namespaceObject.SVG, { 43393 viewBox: "0 0 24 24", 43394 xmlns: "http://www.w3.org/2000/svg" 43395 }, (0,external_React_.createElement)(external_wp_primitives_namespaceObject.Path, { 43396 fillRule: "evenodd", 43397 clipRule: "evenodd", 43398 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" 43399 })); 43400 /* harmony default export */ const lock_small = (lockSmall); 43401 43402 ;// CONCATENATED MODULE: external ["wp","reusableBlocks"] 43403 const external_wp_reusableBlocks_namespaceObject = window["wp"]["reusableBlocks"]; 43404 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/page-patterns/dataviews-pattern-actions.js 43405 43406 /** 43407 * External dependencies 43408 */ 43409 43410 43411 /** 43412 * WordPress dependencies 43413 */ 43414 43415 43416 43417 43418 43419 43420 43421 43422 43423 43424 43425 43426 43427 /** 43428 * Internal dependencies 43429 */ 43430 43431 43432 43433 43434 const { 43435 useHistory: dataviews_pattern_actions_useHistory 43436 } = unlock(external_wp_router_namespaceObject.privateApis); 43437 const { 43438 CreatePatternModalContents, 43439 useDuplicatePatternProps 43440 } = unlock(external_wp_patterns_namespaceObject.privateApis); 43441 const exportJSONaction = { 43442 id: 'export-pattern', 43443 label: (0,external_wp_i18n_namespaceObject.__)('Export as JSON'), 43444 isEligible: item => item.type === PATTERN_TYPES.user, 43445 callback: ([item]) => { 43446 const json = { 43447 __file: item.type, 43448 title: item.title || item.name, 43449 content: item.patternPost.content.raw, 43450 syncStatus: item.patternPost.wp_pattern_sync_status 43451 }; 43452 return (0,external_wp_blob_namespaceObject.downloadBlob)(`$paramCase(item.title || item.name)}.json`, JSON.stringify(json, null, 2), 'application/json'); 43453 } 43454 }; 43455 const renameAction = { 43456 id: 'rename-pattern', 43457 label: (0,external_wp_i18n_namespaceObject.__)('Rename'), 43458 isEligible: item => { 43459 const isTemplatePart = item.type === TEMPLATE_PART_POST_TYPE; 43460 const isUserPattern = item.type === PATTERN_TYPES.user; 43461 const isCustomPattern = isUserPattern || isTemplatePart && item.isCustom; 43462 const hasThemeFile = isTemplatePart && item.templatePart.has_theme_file; 43463 return isCustomPattern && !hasThemeFile; 43464 }, 43465 RenderModal: ({ 43466 items, 43467 closeModal 43468 }) => { 43469 const [item] = items; 43470 const [title, setTitle] = (0,external_wp_element_namespaceObject.useState)(() => item.title); 43471 const { 43472 editEntityRecord, 43473 saveEditedEntityRecord 43474 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store); 43475 const { 43476 createSuccessNotice, 43477 createErrorNotice 43478 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store); 43479 async function onRename(event) { 43480 event.preventDefault(); 43481 try { 43482 await editEntityRecord('postType', item.type, item.id, { 43483 title 43484 }); 43485 // Update state before saving rerenders the list. 43486 setTitle(''); 43487 closeModal(); 43488 // Persist edited entity. 43489 await saveEditedEntityRecord('postType', item.type, item.id, { 43490 throwOnError: true 43491 }); 43492 createSuccessNotice(item.type === TEMPLATE_PART_POST_TYPE ? (0,external_wp_i18n_namespaceObject.__)('Template part renamed.') : (0,external_wp_i18n_namespaceObject.__)('Pattern renamed.'), { 43493 type: 'snackbar' 43494 }); 43495 } catch (error) { 43496 const fallbackErrorMessage = item.type === TEMPLATE_PART_POST_TYPE ? (0,external_wp_i18n_namespaceObject.__)('An error occurred while renaming the template part.') : (0,external_wp_i18n_namespaceObject.__)('An error occurred while renaming the pattern.'); 43497 const errorMessage = error.message && error.code !== 'unknown_error' ? error.message : fallbackErrorMessage; 43498 createErrorNotice(errorMessage, { 43499 type: 'snackbar' 43500 }); 43501 } 43502 } 43503 return (0,external_React_.createElement)("form", { 43504 onSubmit: onRename 43505 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { 43506 spacing: "5" 43507 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.TextControl, { 43508 __nextHasNoMarginBottom: true, 43509 __next40pxDefaultSize: true, 43510 label: (0,external_wp_i18n_namespaceObject.__)('Name'), 43511 value: title, 43512 onChange: setTitle, 43513 required: true 43514 }), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { 43515 justify: "right" 43516 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 43517 __next40pxDefaultSize: true, 43518 variant: "tertiary", 43519 onClick: () => { 43520 closeModal(); 43521 } 43522 }, (0,external_wp_i18n_namespaceObject.__)('Cancel')), (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 43523 __next40pxDefaultSize: true, 43524 variant: "primary", 43525 type: "submit" 43526 }, (0,external_wp_i18n_namespaceObject.__)('Save'))))); 43527 } 43528 }; 43529 const canDeleteOrReset = item => { 43530 const isTemplatePart = item.type === TEMPLATE_PART_POST_TYPE; 43531 const isUserPattern = item.type === PATTERN_TYPES.user; 43532 return isUserPattern || isTemplatePart && item.isCustom; 43533 }; 43534 const deleteAction = { 43535 id: 'delete-pattern', 43536 label: (0,external_wp_i18n_namespaceObject.__)('Delete'), 43537 isEligible: item => { 43538 const isTemplatePart = item.type === TEMPLATE_PART_POST_TYPE; 43539 const hasThemeFile = isTemplatePart && item.templatePart.has_theme_file; 43540 return canDeleteOrReset(item) && !hasThemeFile; 43541 }, 43542 hideModalHeader: true, 43543 supportsBulk: true, 43544 RenderModal: ({ 43545 items, 43546 closeModal, 43547 onPerform 43548 }) => { 43549 const { 43550 __experimentalDeleteReusableBlock 43551 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_reusableBlocks_namespaceObject.store); 43552 const { 43553 createErrorNotice, 43554 createSuccessNotice 43555 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store); 43556 const { 43557 removeTemplates 43558 } = unlock((0,external_wp_data_namespaceObject.useDispatch)(store_store)); 43559 const deletePattern = async () => { 43560 const promiseResult = await Promise.allSettled(items.map(item => { 43561 return __experimentalDeleteReusableBlock(item.id); 43562 })); 43563 // If all the promises were fulfilled with success. 43564 if (promiseResult.every(({ 43565 status 43566 }) => status === 'fulfilled')) { 43567 let successMessage; 43568 if (promiseResult.length === 1) { 43569 successMessage = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: The posts's title. */ 43570 (0,external_wp_i18n_namespaceObject.__)('"%s" deleted.'), items[0].title); 43571 } else { 43572 successMessage = (0,external_wp_i18n_namespaceObject.__)('The patterns were deleted.'); 43573 } 43574 createSuccessNotice(successMessage, { 43575 type: 'snackbar', 43576 id: 'edit-site-page-trashed' 43577 }); 43578 } else { 43579 // If there was at lease one failure. 43580 let errorMessage; 43581 // If we were trying to delete a single pattern. 43582 if (promiseResult.length === 1) { 43583 if (promiseResult[0].reason?.message) { 43584 errorMessage = promiseResult[0].reason.message; 43585 } else { 43586 errorMessage = (0,external_wp_i18n_namespaceObject.__)('An error occurred while deleting the pattern.'); 43587 } 43588 // If we were trying to delete multiple patterns. 43589 } else { 43590 const errorMessages = new Set(); 43591 const failedPromises = promiseResult.filter(({ 43592 status 43593 }) => status === 'rejected'); 43594 for (const failedPromise of failedPromises) { 43595 if (failedPromise.reason?.message) { 43596 errorMessages.add(failedPromise.reason.message); 43597 } 43598 } 43599 if (errorMessages.size === 0) { 43600 errorMessage = (0,external_wp_i18n_namespaceObject.__)('An error occurred while deleting the patterns.'); 43601 } else if (errorMessages.size === 1) { 43602 errorMessage = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: an error message */ 43603 (0,external_wp_i18n_namespaceObject.__)('An error occurred while deleting the patterns: %s'), [...errorMessages][0]); 43604 } else { 43605 errorMessage = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: a list of comma separated error messages */ 43606 (0,external_wp_i18n_namespaceObject.__)('Some errors occurred while deleting the patterns: %s'), [...errorMessages].join(',')); 43607 } 43608 createErrorNotice(errorMessage, { 43609 type: 'snackbar' 43610 }); 43611 } 43612 } 43613 }; 43614 const deleteItem = () => { 43615 if (items[0].type === TEMPLATE_PART_POST_TYPE) { 43616 removeTemplates(items); 43617 } else { 43618 deletePattern(); 43619 } 43620 if (onPerform) { 43621 onPerform(); 43622 } 43623 closeModal(); 43624 }; 43625 let questionMessage; 43626 if (items.length === 1) { 43627 questionMessage = (0,external_wp_i18n_namespaceObject.sprintf)( 43628 // translators: %s: The page's title. 43629 (0,external_wp_i18n_namespaceObject.__)('Are you sure you want to delete "%s"?'), (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(items[0].title || items[0].name)); 43630 } else if (items.length > 1 && items[0].type === TEMPLATE_PART_POST_TYPE) { 43631 questionMessage = (0,external_wp_i18n_namespaceObject.sprintf)( 43632 // translators: %d: The number of template parts (2 or more). 43633 (0,external_wp_i18n_namespaceObject.__)('Are you sure you want to delete %d template parts?'), items.length); 43634 } else { 43635 questionMessage = (0,external_wp_i18n_namespaceObject.sprintf)( 43636 // translators: %d: The number of patterns (2 or more). 43637 (0,external_wp_i18n_namespaceObject.__)('Are you sure you want to delete %d patterns?'), items.length); 43638 } 43639 return (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { 43640 spacing: "5" 43641 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalText, null, questionMessage), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { 43642 justify: "right" 43643 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 43644 variant: "tertiary", 43645 onClick: closeModal 43646 }, (0,external_wp_i18n_namespaceObject.__)('Cancel')), (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 43647 variant: "primary", 43648 onClick: deleteItem 43649 }, (0,external_wp_i18n_namespaceObject.__)('Delete')))); 43650 } 43651 }; 43652 const resetAction = { 43653 id: 'reset-action', 43654 label: (0,external_wp_i18n_namespaceObject.__)('Clear customizations'), 43655 isEligible: item => { 43656 const isTemplatePart = item.type === TEMPLATE_PART_POST_TYPE; 43657 const hasThemeFile = isTemplatePart && item.templatePart.has_theme_file; 43658 return canDeleteOrReset(item) && hasThemeFile; 43659 }, 43660 hideModalHeader: true, 43661 RenderModal: ({ 43662 items, 43663 closeModal 43664 }) => { 43665 const [item] = items; 43666 const { 43667 removeTemplate 43668 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store); 43669 return (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { 43670 spacing: "5" 43671 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalText, null, (0,external_wp_i18n_namespaceObject.__)('Are you sure you want to clear these customizations?')), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { 43672 justify: "right" 43673 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 43674 variant: "tertiary", 43675 onClick: closeModal 43676 }, (0,external_wp_i18n_namespaceObject.__)('Cancel')), (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 43677 variant: "primary", 43678 onClick: () => removeTemplate(item) 43679 }, (0,external_wp_i18n_namespaceObject.__)('Clear')))); 43680 } 43681 }; 43682 const duplicatePatternAction = { 43683 id: 'duplicate-pattern', 43684 label: (0,external_wp_i18n_namespaceObject._x)('Duplicate', 'action label'), 43685 isEligible: item => item.type !== TEMPLATE_PART_POST_TYPE, 43686 modalHeader: (0,external_wp_i18n_namespaceObject._x)('Duplicate pattern', 'action label'), 43687 RenderModal: ({ 43688 items, 43689 closeModal 43690 }) => { 43691 const [item] = items; 43692 const { 43693 categoryId = PATTERN_DEFAULT_CATEGORY 43694 } = (0,external_wp_url_namespaceObject.getQueryArgs)(window.location.href); 43695 const isThemePattern = item.type === PATTERN_TYPES.theme; 43696 const history = dataviews_pattern_actions_useHistory(); 43697 function onPatternSuccess({ 43698 pattern 43699 }) { 43700 history.push({ 43701 categoryType: PATTERN_TYPES.theme, 43702 categoryId, 43703 postType: PATTERN_TYPES.user, 43704 postId: pattern.id 43705 }); 43706 closeModal(); 43707 } 43708 const duplicatedProps = useDuplicatePatternProps({ 43709 pattern: isThemePattern ? item : item.patternPost, 43710 onSuccess: onPatternSuccess 43711 }); 43712 return (0,external_React_.createElement)(CreatePatternModalContents, { 43713 onClose: closeModal, 43714 confirmLabel: (0,external_wp_i18n_namespaceObject._x)('Duplicate', 'action label'), 43715 ...duplicatedProps 43716 }); 43717 } 43718 }; 43719 const duplicateTemplatePartAction = { 43720 id: 'duplicate-template-part', 43721 label: (0,external_wp_i18n_namespaceObject._x)('Duplicate', 'action label'), 43722 isEligible: item => item.type === TEMPLATE_PART_POST_TYPE, 43723 modalHeader: (0,external_wp_i18n_namespaceObject._x)('Duplicate template part', 'action label'), 43724 RenderModal: ({ 43725 items, 43726 closeModal 43727 }) => { 43728 const [item] = items; 43729 const { 43730 createSuccessNotice 43731 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store); 43732 const { 43733 categoryId = PATTERN_DEFAULT_CATEGORY 43734 } = (0,external_wp_url_namespaceObject.getQueryArgs)(window.location.href); 43735 const history = dataviews_pattern_actions_useHistory(); 43736 async function onTemplatePartSuccess(templatePart) { 43737 createSuccessNotice((0,external_wp_i18n_namespaceObject.sprintf)( 43738 // translators: %s: The new template part's title e.g. 'Call to action (copy)'. 43739 (0,external_wp_i18n_namespaceObject.__)('"%s" duplicated.'), item.title), { 43740 type: 'snackbar', 43741 id: 'edit-site-patterns-success' 43742 }); 43743 history.push({ 43744 postType: TEMPLATE_PART_POST_TYPE, 43745 postId: templatePart?.id, 43746 categoryType: TEMPLATE_PART_POST_TYPE, 43747 categoryId 43748 }); 43749 closeModal(); 43750 } 43751 return (0,external_React_.createElement)(CreateTemplatePartModalContents, { 43752 blocks: item.blocks, 43753 defaultArea: item.templatePart.area, 43754 defaultTitle: (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: Existing template part title */ 43755 (0,external_wp_i18n_namespaceObject.__)('%s (Copy)'), item.title), 43756 onCreate: onTemplatePartSuccess, 43757 onError: closeModal, 43758 confirmLabel: (0,external_wp_i18n_namespaceObject._x)('Duplicate', 'action label') 43759 }); 43760 } 43761 }; 43762 43763 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/page-patterns/use-pattern-settings.js 43764 /** 43765 * WordPress dependencies 43766 */ 43767 43768 43769 43770 43771 /** 43772 * Internal dependencies 43773 */ 43774 43775 43776 43777 function usePatternSettings() { 43778 var _storedSettings$__exp; 43779 const storedSettings = (0,external_wp_data_namespaceObject.useSelect)(select => { 43780 const { 43781 getSettings 43782 } = unlock(select(store_store)); 43783 return getSettings(); 43784 }, []); 43785 const settingsBlockPatterns = (_storedSettings$__exp = storedSettings.__experimentalAdditionalBlockPatterns) !== null && _storedSettings$__exp !== void 0 ? _storedSettings$__exp : 43786 // WP 6.0 43787 storedSettings.__experimentalBlockPatterns; // WP 5.9 43788 43789 const restBlockPatterns = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).getBlockPatterns(), []); 43790 const blockPatterns = (0,external_wp_element_namespaceObject.useMemo)(() => [...(settingsBlockPatterns || []), ...(restBlockPatterns || [])].filter(filterOutDuplicatesByName), [settingsBlockPatterns, restBlockPatterns]); 43791 const settings = (0,external_wp_element_namespaceObject.useMemo)(() => { 43792 const { 43793 __experimentalAdditionalBlockPatterns, 43794 ...restStoredSettings 43795 } = storedSettings; 43796 return { 43797 ...restStoredSettings, 43798 __experimentalBlockPatterns: blockPatterns, 43799 __unstableIsPreviewMode: true 43800 }; 43801 }, [storedSettings, blockPatterns]); 43802 return settings; 43803 } 43804 43805 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/page-patterns/rename-category-menu-item.js 43806 43807 /** 43808 * WordPress dependencies 43809 */ 43810 43811 43812 43813 43814 /** 43815 * Internal dependencies 43816 */ 43817 43818 43819 /** 43820 * Internal dependencies 43821 */ 43822 43823 const { 43824 RenamePatternCategoryModal 43825 } = unlock(external_wp_patterns_namespaceObject.privateApis); 43826 function RenameCategoryMenuItem({ 43827 category, 43828 onClose 43829 }) { 43830 const [isModalOpen, setIsModalOpen] = (0,external_wp_element_namespaceObject.useState)(false); 43831 return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.MenuItem, { 43832 onClick: () => setIsModalOpen(true) 43833 }, (0,external_wp_i18n_namespaceObject.__)('Rename')), isModalOpen && (0,external_React_.createElement)(rename_category_menu_item_RenameModal, { 43834 category: category, 43835 onClose: () => { 43836 setIsModalOpen(false); 43837 onClose(); 43838 } 43839 })); 43840 } 43841 function rename_category_menu_item_RenameModal({ 43842 category, 43843 onClose 43844 }) { 43845 // User created pattern categories have their properties updated when 43846 // retrieved via `getUserPatternCategories`. The rename modal expects an 43847 // object that will match the pattern category entity. 43848 const normalizedCategory = { 43849 id: category.id, 43850 slug: category.slug, 43851 name: category.label 43852 }; 43853 43854 // Optimization - only use pattern categories when the modal is open. 43855 const existingCategories = usePatternCategories(); 43856 return (0,external_React_.createElement)(RenamePatternCategoryModal, { 43857 category: normalizedCategory, 43858 existingCategories: existingCategories, 43859 onClose: onClose, 43860 overlayClassName: "edit-site-list__rename-modal" 43861 }); 43862 } 43863 43864 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/page-patterns/delete-category-menu-item.js 43865 43866 /** 43867 * WordPress dependencies 43868 */ 43869 43870 43871 43872 43873 43874 43875 43876 43877 43878 /** 43879 * Internal dependencies 43880 */ 43881 43882 43883 const { 43884 useHistory: delete_category_menu_item_useHistory 43885 } = unlock(external_wp_router_namespaceObject.privateApis); 43886 function DeleteCategoryMenuItem({ 43887 category, 43888 onClose 43889 }) { 43890 const [isModalOpen, setIsModalOpen] = (0,external_wp_element_namespaceObject.useState)(false); 43891 const history = delete_category_menu_item_useHistory(); 43892 const { 43893 createSuccessNotice, 43894 createErrorNotice 43895 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store); 43896 const { 43897 deleteEntityRecord, 43898 invalidateResolution 43899 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store); 43900 const onDelete = async () => { 43901 try { 43902 await deleteEntityRecord('taxonomy', 'wp_pattern_category', category.id, { 43903 force: true 43904 }, { 43905 throwOnError: true 43906 }); 43907 43908 // Prevent the need to refresh the page to get up-to-date categories 43909 // and pattern categorization. 43910 invalidateResolution('getUserPatternCategories'); 43911 invalidateResolution('getEntityRecords', ['postType', PATTERN_TYPES.user, { 43912 per_page: -1 43913 }]); 43914 createSuccessNotice((0,external_wp_i18n_namespaceObject.sprintf)( /* translators: The pattern category's name */ 43915 (0,external_wp_i18n_namespaceObject.__)('"%s" deleted.'), category.label), { 43916 type: 'snackbar', 43917 id: 'pattern-category-delete' 43918 }); 43919 onClose?.(); 43920 history.push({ 43921 path: `/patterns`, 43922 categoryType: PATTERN_TYPES.theme, 43923 categoryId: PATTERN_DEFAULT_CATEGORY 43924 }); 43925 } catch (error) { 43926 const errorMessage = error.message && error.code !== 'unknown_error' ? error.message : (0,external_wp_i18n_namespaceObject.__)('An error occurred while deleting the pattern category.'); 43927 createErrorNotice(errorMessage, { 43928 type: 'snackbar', 43929 id: 'pattern-category-delete' 43930 }); 43931 } 43932 }; 43933 return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.MenuItem, { 43934 isDestructive: true, 43935 onClick: () => setIsModalOpen(true) 43936 }, (0,external_wp_i18n_namespaceObject.__)('Delete')), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalConfirmDialog, { 43937 isOpen: isModalOpen, 43938 onConfirm: onDelete, 43939 onCancel: () => setIsModalOpen(false), 43940 confirmButtonText: (0,external_wp_i18n_namespaceObject.__)('Delete'), 43941 className: "edit-site-patterns__delete-modal" 43942 }, (0,external_wp_i18n_namespaceObject.sprintf)( 43943 // translators: %s: The pattern category's name. 43944 (0,external_wp_i18n_namespaceObject.__)('Are you sure you want to delete the category "%s"? The patterns will not be deleted.'), (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(category.label)))); 43945 } 43946 43947 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/page-patterns/header.js 43948 43949 /** 43950 * WordPress dependencies 43951 */ 43952 43953 43954 43955 43956 43957 43958 /** 43959 * Internal dependencies 43960 */ 43961 43962 43963 43964 43965 function PatternsHeader({ 43966 categoryId, 43967 type, 43968 titleId, 43969 descriptionId 43970 }) { 43971 const { 43972 patternCategories 43973 } = usePatternCategories(); 43974 const templatePartAreas = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_editor_namespaceObject.store).__experimentalGetDefaultTemplatePartAreas(), []); 43975 let title, description, patternCategory; 43976 if (type === TEMPLATE_PART_POST_TYPE) { 43977 const templatePartArea = templatePartAreas.find(area => area.area === categoryId); 43978 title = templatePartArea?.label; 43979 description = templatePartArea?.description; 43980 } else if (type === PATTERN_TYPES.theme) { 43981 patternCategory = patternCategories.find(category => category.name === categoryId); 43982 title = patternCategory?.label; 43983 description = patternCategory?.description; 43984 } 43985 if (!title) return null; 43986 return (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { 43987 className: "edit-site-patterns__section-header" 43988 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { 43989 justify: "space-between" 43990 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHeading, { 43991 as: "h2", 43992 level: 4, 43993 id: titleId 43994 }, title), !!patternCategory?.id && (0,external_React_.createElement)(external_wp_components_namespaceObject.DropdownMenu, { 43995 icon: more_vertical, 43996 label: (0,external_wp_i18n_namespaceObject.__)('Actions'), 43997 toggleProps: { 43998 className: 'edit-site-patterns__button', 43999 describedBy: (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: pattern category name */ 44000 (0,external_wp_i18n_namespaceObject.__)('Action menu for %s pattern category'), title) 44001 } 44002 }, ({ 44003 onClose 44004 }) => (0,external_React_.createElement)(external_wp_components_namespaceObject.MenuGroup, null, (0,external_React_.createElement)(RenameCategoryMenuItem, { 44005 category: patternCategory, 44006 onClose: onClose 44007 }), (0,external_React_.createElement)(DeleteCategoryMenuItem, { 44008 category: patternCategory, 44009 onClose: onClose 44010 })))), description ? (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalText, { 44011 variant: "muted", 44012 as: "p", 44013 id: descriptionId 44014 }, description) : null); 44015 } 44016 44017 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/page-patterns/index.js 44018 44019 /** 44020 * WordPress dependencies 44021 */ 44022 44023 44024 44025 44026 44027 44028 44029 44030 44031 /** 44032 * Internal dependencies 44033 */ 44034 44035 44036 44037 44038 44039 44040 44041 44042 const { 44043 ExperimentalBlockEditorProvider: page_patterns_ExperimentalBlockEditorProvider, 44044 useGlobalStyle: page_patterns_useGlobalStyle 44045 } = unlock(external_wp_blockEditor_namespaceObject.privateApis); 44046 const templatePartIcons = { 44047 header: library_header, 44048 footer: library_footer, 44049 uncategorized: symbol_filled 44050 }; 44051 const page_patterns_EMPTY_ARRAY = []; 44052 const defaultConfigPerViewType = { 44053 [LAYOUT_GRID]: { 44054 mediaField: 'preview', 44055 primaryField: 'title' 44056 } 44057 }; 44058 const DEFAULT_VIEW = { 44059 type: LAYOUT_GRID, 44060 search: '', 44061 page: 1, 44062 perPage: 20, 44063 hiddenFields: ['sync-status'], 44064 layout: { 44065 ...defaultConfigPerViewType[LAYOUT_GRID] 44066 }, 44067 filters: [] 44068 }; 44069 const SYNC_FILTERS = [{ 44070 value: PATTERN_SYNC_TYPES.full, 44071 label: (0,external_wp_i18n_namespaceObject._x)('Synced', 'Option that shows all synchronized patterns'), 44072 description: (0,external_wp_i18n_namespaceObject.__)('Patterns that are kept in sync across the site.') 44073 }, { 44074 value: PATTERN_SYNC_TYPES.unsynced, 44075 label: (0,external_wp_i18n_namespaceObject._x)('Not synced', 'Option that shows all patterns that are not synchronized'), 44076 description: (0,external_wp_i18n_namespaceObject.__)('Patterns that can be changed freely without affecting the site.') 44077 }]; 44078 function PreviewWrapper({ 44079 item, 44080 onClick, 44081 ariaDescribedBy, 44082 children 44083 }) { 44084 if (item.type === PATTERN_TYPES.theme) { 44085 return children; 44086 } 44087 return (0,external_React_.createElement)("button", { 44088 className: "page-patterns-preview-field__button", 44089 type: "button", 44090 onClick: onClick, 44091 "aria-label": item.title, 44092 "aria-describedby": ariaDescribedBy 44093 }, children); 44094 } 44095 function Preview({ 44096 item, 44097 categoryId, 44098 viewType 44099 }) { 44100 const descriptionId = (0,external_wp_element_namespaceObject.useId)(); 44101 const isUserPattern = item.type === PATTERN_TYPES.user; 44102 const isNonUserPattern = item.type === PATTERN_TYPES.theme; 44103 const isTemplatePart = item.type === TEMPLATE_PART_POST_TYPE; 44104 const isEmpty = !item.blocks?.length; 44105 // Only custom patterns or custom template parts can be renamed or deleted. 44106 const isCustomPattern = isUserPattern || isTemplatePart && item.isCustom; 44107 const ariaDescriptions = []; 44108 if (isCustomPattern) { 44109 // User patterns don't have descriptions, but can be edited and deleted, so include some help text. 44110 ariaDescriptions.push((0,external_wp_i18n_namespaceObject.__)('Press Enter to edit, or Delete to delete the pattern.')); 44111 } else if (item.description) { 44112 ariaDescriptions.push(item.description); 44113 } 44114 if (isNonUserPattern) { 44115 ariaDescriptions.push((0,external_wp_i18n_namespaceObject.__)('Theme & plugin patterns cannot be edited.')); 44116 } 44117 const [backgroundColor] = page_patterns_useGlobalStyle('color.background'); 44118 const { 44119 onClick 44120 } = useLink({ 44121 postType: item.type, 44122 postId: isUserPattern ? item.id : item.name, 44123 categoryId, 44124 categoryType: isTemplatePart ? item.type : PATTERN_TYPES.theme 44125 }); 44126 return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)("div", { 44127 className: `page-patterns-preview-field is-viewtype-$viewType}`, 44128 style: { 44129 backgroundColor 44130 } 44131 }, (0,external_React_.createElement)(PreviewWrapper, { 44132 item: item, 44133 onClick: onClick, 44134 ariaDescribedBy: ariaDescriptions.length ? ariaDescriptions.map((_, index) => `$descriptionId}-$index}`).join(' ') : undefined 44135 }, isEmpty && isTemplatePart && (0,external_wp_i18n_namespaceObject.__)('Empty template part'), isEmpty && !isTemplatePart && (0,external_wp_i18n_namespaceObject.__)('Empty pattern'), !isEmpty && (0,external_React_.createElement)(external_wp_blockEditor_namespaceObject.BlockPreview, { 44136 blocks: item.blocks 44137 }))), ariaDescriptions.map((ariaDescription, index) => (0,external_React_.createElement)("div", { 44138 key: index, 44139 hidden: true, 44140 id: `$descriptionId}-$index}` 44141 }, ariaDescription))); 44142 } 44143 function Title({ 44144 item, 44145 categoryId 44146 }) { 44147 const isUserPattern = item.type === PATTERN_TYPES.user; 44148 const isNonUserPattern = item.type === PATTERN_TYPES.theme; 44149 const isTemplatePart = item.type === TEMPLATE_PART_POST_TYPE; 44150 let itemIcon; 44151 const { 44152 onClick 44153 } = useLink({ 44154 postType: item.type, 44155 postId: isUserPattern ? item.id : item.name, 44156 categoryId, 44157 categoryType: isTemplatePart ? item.type : PATTERN_TYPES.theme 44158 }); 44159 if (!isUserPattern && templatePartIcons[categoryId]) { 44160 itemIcon = templatePartIcons[categoryId]; 44161 } else { 44162 itemIcon = item.syncStatus === PATTERN_SYNC_TYPES.full ? library_symbol : undefined; 44163 } 44164 return (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { 44165 alignment: "center", 44166 justify: "flex-start", 44167 spacing: 2 44168 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.Flex, { 44169 as: "div", 44170 gap: 0, 44171 justify: "left", 44172 className: "edit-site-patterns__pattern-title" 44173 }, item.type === PATTERN_TYPES.theme ? item.title : (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 44174 variant: "link", 44175 onClick: onClick 44176 // Required for the grid's roving tab index system. 44177 // See https://github.com/WordPress/gutenberg/pull/51898#discussion_r1243399243. 44178 , 44179 tabIndex: "-1" 44180 }, item.title || item.name)), itemIcon && !isNonUserPattern && (0,external_React_.createElement)(external_wp_components_namespaceObject.Tooltip, { 44181 placement: "top", 44182 text: (0,external_wp_i18n_namespaceObject.__)('Editing this pattern will also update anywhere it is used') 44183 }, (0,external_React_.createElement)(build_module_icon, { 44184 className: "edit-site-patterns__pattern-icon", 44185 icon: itemIcon 44186 })), item.type === PATTERN_TYPES.theme && (0,external_React_.createElement)(external_wp_components_namespaceObject.Tooltip, { 44187 placement: "top", 44188 text: (0,external_wp_i18n_namespaceObject.__)('This pattern cannot be edited.') 44189 }, (0,external_React_.createElement)(build_module_icon, { 44190 className: "edit-site-patterns__pattern-lock-icon", 44191 icon: lock_small, 44192 size: 24 44193 }))); 44194 } 44195 function DataviewsPatterns() { 44196 const { 44197 categoryType, 44198 categoryId = PATTERN_DEFAULT_CATEGORY 44199 } = (0,external_wp_url_namespaceObject.getQueryArgs)(window.location.href); 44200 const type = categoryType || PATTERN_TYPES.theme; 44201 const [view, setView] = (0,external_wp_element_namespaceObject.useState)(DEFAULT_VIEW); 44202 const isUncategorizedThemePatterns = type === PATTERN_TYPES.theme && categoryId === 'uncategorized'; 44203 const previousCategoryId = (0,external_wp_compose_namespaceObject.usePrevious)(categoryId); 44204 const viewSyncStatus = view.filters?.find(({ 44205 field 44206 }) => field === 'sync-status')?.value; 44207 const { 44208 patterns, 44209 isResolving 44210 } = use_patterns(type, isUncategorizedThemePatterns ? '' : categoryId, { 44211 search: view.search, 44212 syncStatus: viewSyncStatus 44213 }); 44214 const fields = (0,external_wp_element_namespaceObject.useMemo)(() => { 44215 const _fields = [{ 44216 header: (0,external_wp_i18n_namespaceObject.__)('Preview'), 44217 id: 'preview', 44218 render: ({ 44219 item 44220 }) => (0,external_React_.createElement)(Preview, { 44221 item: item, 44222 categoryId: categoryId, 44223 viewType: view.type 44224 }), 44225 enableSorting: false, 44226 enableHiding: false 44227 }, { 44228 header: (0,external_wp_i18n_namespaceObject.__)('Title'), 44229 id: 'title', 44230 getValue: ({ 44231 item 44232 }) => item.title, 44233 render: ({ 44234 item 44235 }) => (0,external_React_.createElement)(Title, { 44236 item: item, 44237 categoryId: categoryId 44238 }), 44239 enableHiding: false 44240 }]; 44241 if (type === PATTERN_TYPES.theme) { 44242 _fields.push({ 44243 header: (0,external_wp_i18n_namespaceObject.__)('Sync Status'), 44244 id: 'sync-status', 44245 render: ({ 44246 item 44247 }) => { 44248 // User patterns can have their sync statuses checked directly. 44249 // Non-user patterns are all unsynced for the time being. 44250 return SYNC_FILTERS.find(({ 44251 value 44252 }) => value === item.syncStatus)?.label || SYNC_FILTERS.find(({ 44253 value 44254 }) => value === PATTERN_SYNC_TYPES.unsynced).label; 44255 }, 44256 type: ENUMERATION_TYPE, 44257 elements: SYNC_FILTERS, 44258 filterBy: { 44259 operators: [OPERATOR_IN], 44260 isPrimary: true 44261 }, 44262 enableSorting: false 44263 }); 44264 } 44265 return _fields; 44266 }, [view.type, categoryId, type]); 44267 // Reset the page number when the category changes. 44268 (0,external_wp_element_namespaceObject.useEffect)(() => { 44269 if (previousCategoryId !== categoryId) { 44270 setView(DEFAULT_VIEW); 44271 } 44272 }, [categoryId, previousCategoryId]); 44273 const { 44274 data, 44275 paginationInfo 44276 } = (0,external_wp_element_namespaceObject.useMemo)(() => { 44277 if (!patterns) { 44278 return { 44279 data: page_patterns_EMPTY_ARRAY, 44280 paginationInfo: { 44281 totalItems: 0, 44282 totalPages: 0 44283 } 44284 }; 44285 } 44286 let filteredData = [...patterns]; 44287 // Handle sorting. 44288 if (view.sort) { 44289 filteredData = sortByTextFields({ 44290 data: filteredData, 44291 view, 44292 fields, 44293 textFields: ['title', 'author'] 44294 }); 44295 } 44296 // Handle pagination. 44297 return getPaginationResults({ 44298 data: filteredData, 44299 view 44300 }); 44301 }, [patterns, view, fields]); 44302 const actions = (0,external_wp_element_namespaceObject.useMemo)(() => [renameAction, duplicatePatternAction, duplicateTemplatePartAction, exportJSONaction, resetAction, deleteAction], []); 44303 const onChangeView = (0,external_wp_element_namespaceObject.useCallback)(newView => { 44304 if (newView.type !== view.type) { 44305 newView = { 44306 ...newView, 44307 layout: { 44308 ...defaultConfigPerViewType[newView.type] 44309 } 44310 }; 44311 } 44312 setView(newView); 44313 }, [view.type, setView]); 44314 const id = (0,external_wp_element_namespaceObject.useId)(); 44315 const settings = usePatternSettings(); 44316 // Wrap everything in a block editor provider. 44317 // This ensures 'styles' that are needed for the previews are synced 44318 // from the site editor store to the block editor store. 44319 // TODO: check if I add the provider in every preview like in templates... 44320 return (0,external_React_.createElement)(page_patterns_ExperimentalBlockEditorProvider, { 44321 settings: settings 44322 }, (0,external_React_.createElement)(Page, { 44323 title: (0,external_wp_i18n_namespaceObject.__)('Patterns content'), 44324 className: "edit-site-page-patterns-dataviews", 44325 hideTitleFromUI: true 44326 }, (0,external_React_.createElement)(PatternsHeader, { 44327 categoryId: categoryId, 44328 type: type, 44329 titleId: `$id}-title`, 44330 descriptionId: `$id}-description` 44331 }), (0,external_React_.createElement)(DataViews, { 44332 paginationInfo: paginationInfo, 44333 fields: fields, 44334 actions: actions, 44335 data: data || page_patterns_EMPTY_ARRAY, 44336 getItemId: item => item.name, 44337 isLoading: isResolving, 44338 view: view, 44339 onChangeView: onChangeView, 44340 deferredRendering: true, 44341 supportedLayouts: [LAYOUT_GRID] 44342 }))); 44343 } 44344 44345 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/page-templates-template-parts/actions.js 44346 44347 /** 44348 * WordPress dependencies 44349 */ 44350 44351 44352 44353 44354 44355 44356 44357 44358 44359 /** 44360 * Internal dependencies 44361 */ 44362 44363 44364 44365 44366 44367 function useResetTemplateAction() { 44368 const { 44369 revertTemplate 44370 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store); 44371 const { 44372 saveEditedEntityRecord 44373 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store); 44374 const { 44375 createSuccessNotice, 44376 createErrorNotice 44377 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store); 44378 return (0,external_wp_element_namespaceObject.useMemo)(() => ({ 44379 id: 'reset-template', 44380 label: (0,external_wp_i18n_namespaceObject.__)('Reset'), 44381 isPrimary: true, 44382 icon: library_backup, 44383 isEligible: isTemplateRevertable, 44384 supportsBulk: true, 44385 async callback(templates) { 44386 try { 44387 for (const template of templates) { 44388 await revertTemplate(template, { 44389 allowUndo: false 44390 }); 44391 await saveEditedEntityRecord('postType', template.type, template.id); 44392 } 44393 createSuccessNotice(templates.length > 1 ? (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: The number of items. */ 44394 (0,external_wp_i18n_namespaceObject.__)('%s items reverted.'), templates.length) : (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: The template/part's name. */ 44395 (0,external_wp_i18n_namespaceObject.__)('"%s" reverted.'), (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(templates[0].title.rendered)), { 44396 type: 'snackbar', 44397 id: 'edit-site-template-reverted' 44398 }); 44399 } catch (error) { 44400 let fallbackErrorMessage; 44401 if (templates[0].type === constants_TEMPLATE_POST_TYPE) { 44402 fallbackErrorMessage = templates.length === 1 ? (0,external_wp_i18n_namespaceObject.__)('An error occurred while reverting the template.') : (0,external_wp_i18n_namespaceObject.__)('An error occurred while reverting the templates.'); 44403 } else { 44404 fallbackErrorMessage = templates.length === 1 ? (0,external_wp_i18n_namespaceObject.__)('An error occurred while reverting the template part.') : (0,external_wp_i18n_namespaceObject.__)('An error occurred while reverting the template parts.'); 44405 } 44406 const errorMessage = error.message && error.code !== 'unknown_error' ? error.message : fallbackErrorMessage; 44407 createErrorNotice(errorMessage, { 44408 type: 'snackbar' 44409 }); 44410 } 44411 } 44412 }), [createErrorNotice, createSuccessNotice, revertTemplate, saveEditedEntityRecord]); 44413 } 44414 const deleteTemplateAction = { 44415 id: 'delete-template', 44416 label: (0,external_wp_i18n_namespaceObject.__)('Delete'), 44417 isPrimary: true, 44418 icon: library_trash, 44419 isEligible: isTemplateRemovable, 44420 supportsBulk: true, 44421 hideModalHeader: true, 44422 RenderModal: ({ 44423 items: templates, 44424 closeModal, 44425 onPerform 44426 }) => { 44427 const { 44428 removeTemplates 44429 } = unlock((0,external_wp_data_namespaceObject.useDispatch)(store_store)); 44430 return (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { 44431 spacing: "5" 44432 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalText, null, templates.length > 1 ? (0,external_wp_i18n_namespaceObject.sprintf)( 44433 // translators: %d: number of items to delete. 44434 (0,external_wp_i18n_namespaceObject._n)('Delete %d item?', 'Delete %d items?', templates.length), templates.length) : (0,external_wp_i18n_namespaceObject.sprintf)( 44435 // translators: %s: The template or template part's titles 44436 (0,external_wp_i18n_namespaceObject.__)('Delete "%s"?'), (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(templates?.[0]?.title?.rendered))), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { 44437 justify: "right" 44438 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 44439 variant: "tertiary", 44440 onClick: closeModal 44441 }, (0,external_wp_i18n_namespaceObject.__)('Cancel')), (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 44442 variant: "primary", 44443 onClick: async () => { 44444 await removeTemplates(templates, { 44445 allowUndo: false 44446 }); 44447 if (onPerform) { 44448 onPerform(); 44449 } 44450 closeModal(); 44451 } 44452 }, (0,external_wp_i18n_namespaceObject.__)('Delete')))); 44453 } 44454 }; 44455 const renameTemplateAction = { 44456 id: 'rename-template', 44457 label: (0,external_wp_i18n_namespaceObject.__)('Rename'), 44458 isEligible: template => { 44459 // We can only remove templates or template parts that can be removed. 44460 // Additionally in the case of templates, we can only remove custom templates. 44461 if (!isTemplateRemovable(template) || template.type === constants_TEMPLATE_POST_TYPE && !template.is_custom) { 44462 return false; 44463 } 44464 return true; 44465 }, 44466 RenderModal: ({ 44467 items: templates, 44468 closeModal 44469 }) => { 44470 const template = templates[0]; 44471 const title = (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(template.title.rendered); 44472 const [editedTitle, setEditedTitle] = (0,external_wp_element_namespaceObject.useState)(title); 44473 const { 44474 editEntityRecord, 44475 __experimentalSaveSpecifiedEntityEdits: saveSpecifiedEntityEdits 44476 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store); 44477 const { 44478 createSuccessNotice, 44479 createErrorNotice 44480 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store); 44481 async function onTemplateRename(event) { 44482 event.preventDefault(); 44483 try { 44484 await editEntityRecord('postType', template.type, template.id, { 44485 title: editedTitle 44486 }); 44487 // Update state before saving rerenders the list. 44488 setEditedTitle(''); 44489 closeModal(); 44490 // Persist edited entity. 44491 await saveSpecifiedEntityEdits('postType', template.type, template.id, ['title'], 44492 // Only save title to avoid persisting other edits. 44493 { 44494 throwOnError: true 44495 }); 44496 // TODO: this action will be reused in template parts list, so 44497 // let's keep this for a bit, even it's always a `template` now. 44498 createSuccessNotice(template.type === constants_TEMPLATE_POST_TYPE ? (0,external_wp_i18n_namespaceObject.__)('Template renamed.') : (0,external_wp_i18n_namespaceObject.__)('Template part renamed.'), { 44499 type: 'snackbar' 44500 }); 44501 } catch (error) { 44502 const fallbackErrorMessage = template.type === constants_TEMPLATE_POST_TYPE ? (0,external_wp_i18n_namespaceObject.__)('An error occurred while renaming the template.') : (0,external_wp_i18n_namespaceObject.__)('An error occurred while renaming the template part.'); 44503 const errorMessage = error.message && error.code !== 'unknown_error' ? error.message : fallbackErrorMessage; 44504 createErrorNotice(errorMessage, { 44505 type: 'snackbar' 44506 }); 44507 } 44508 } 44509 return (0,external_React_.createElement)("form", { 44510 onSubmit: onTemplateRename 44511 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalVStack, { 44512 spacing: "5" 44513 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.TextControl, { 44514 __nextHasNoMarginBottom: true, 44515 label: (0,external_wp_i18n_namespaceObject.__)('Name'), 44516 value: editedTitle, 44517 onChange: setEditedTitle, 44518 required: true 44519 }), (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { 44520 justify: "right" 44521 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 44522 variant: "tertiary", 44523 onClick: closeModal 44524 }, (0,external_wp_i18n_namespaceObject.__)('Cancel')), (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 44525 variant: "primary", 44526 type: "submit" 44527 }, (0,external_wp_i18n_namespaceObject.__)('Save'))))); 44528 } 44529 }; 44530 44531 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/page-templates-template-parts/add-new-template-part.js 44532 44533 /** 44534 * WordPress dependencies 44535 */ 44536 44537 44538 44539 44540 44541 44542 /** 44543 * Internal dependencies 44544 */ 44545 44546 44547 44548 44549 const { 44550 useHistory: add_new_template_part_useHistory 44551 } = unlock(external_wp_router_namespaceObject.privateApis); 44552 function AddNewTemplatePart() { 44553 const { 44554 canCreate, 44555 postType 44556 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 44557 const { 44558 supportsTemplatePartsMode 44559 } = select(store_store).getSettings(); 44560 return { 44561 canCreate: !supportsTemplatePartsMode, 44562 postType: select(external_wp_coreData_namespaceObject.store).getPostType(TEMPLATE_PART_POST_TYPE) 44563 }; 44564 }, []); 44565 const [isModalOpen, setIsModalOpen] = (0,external_wp_element_namespaceObject.useState)(false); 44566 const history = add_new_template_part_useHistory(); 44567 if (!canCreate || !postType) { 44568 return null; 44569 } 44570 return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.Button, { 44571 variant: "primary", 44572 onClick: () => setIsModalOpen(true) 44573 }, postType.labels.add_new_item), isModalOpen && (0,external_React_.createElement)(CreateTemplatePartModal, { 44574 closeModal: () => setIsModalOpen(false), 44575 blocks: [], 44576 onCreate: templatePart => { 44577 setIsModalOpen(false); 44578 history.push({ 44579 postId: templatePart.id, 44580 postType: TEMPLATE_PART_POST_TYPE, 44581 canvas: 'edit' 44582 }); 44583 }, 44584 onError: () => setIsModalOpen(false) 44585 })); 44586 } 44587 44588 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/page-templates-template-parts/index.js 44589 44590 /** 44591 * External dependencies 44592 */ 44593 44594 44595 /** 44596 * WordPress dependencies 44597 */ 44598 44599 44600 44601 44602 44603 44604 44605 44606 44607 44608 /** 44609 * Internal dependencies 44610 */ 44611 44612 44613 44614 44615 44616 44617 44618 44619 44620 44621 const { 44622 ExperimentalBlockEditorProvider: page_templates_template_parts_ExperimentalBlockEditorProvider, 44623 useGlobalStyle: page_templates_template_parts_useGlobalStyle 44624 } = unlock(external_wp_blockEditor_namespaceObject.privateApis); 44625 const { 44626 useHistory: page_templates_template_parts_useHistory, 44627 useLocation: page_templates_template_parts_useLocation 44628 } = unlock(external_wp_router_namespaceObject.privateApis); 44629 const page_templates_template_parts_EMPTY_ARRAY = []; 44630 const page_templates_template_parts_SUPPORTED_LAYOUTS = window?.__experimentalAdminViews ? [LAYOUT_TABLE, LAYOUT_GRID, LAYOUT_LIST] : [LAYOUT_TABLE, LAYOUT_GRID]; 44631 const page_templates_template_parts_defaultConfigPerViewType = { 44632 [LAYOUT_TABLE]: { 44633 primaryField: 'title' 44634 }, 44635 [LAYOUT_GRID]: { 44636 mediaField: 'preview', 44637 primaryField: 'title' 44638 }, 44639 [LAYOUT_LIST]: { 44640 primaryField: 'title', 44641 mediaField: 'preview' 44642 } 44643 }; 44644 const page_templates_template_parts_DEFAULT_VIEW = { 44645 type: LAYOUT_TABLE, 44646 search: '', 44647 page: 1, 44648 perPage: 20, 44649 sort: { 44650 field: 'title', 44651 direction: 'asc' 44652 }, 44653 // All fields are visible by default, so it's 44654 // better to keep track of the hidden ones. 44655 hiddenFields: ['preview'], 44656 layout: page_templates_template_parts_defaultConfigPerViewType[LAYOUT_TABLE], 44657 filters: [] 44658 }; 44659 function page_templates_template_parts_normalizeSearchInput(input = '') { 44660 return remove_accents_default()(input.trim().toLowerCase()); 44661 } 44662 function page_templates_template_parts_Title({ 44663 item, 44664 viewType 44665 }) { 44666 if (viewType === LAYOUT_LIST) { 44667 return (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(item.title?.rendered) || (0,external_wp_i18n_namespaceObject.__)('(no title)'); 44668 } 44669 const linkProps = { 44670 params: { 44671 postId: item.id, 44672 postType: item.type, 44673 canvas: 'edit' 44674 } 44675 }; 44676 if (item.type === TEMPLATE_PART_POST_TYPE) { 44677 linkProps.state = { 44678 backPath: '/wp_template_part/all' 44679 }; 44680 } 44681 return (0,external_React_.createElement)(Link, { 44682 ...linkProps 44683 }, (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(item.title?.rendered) || (0,external_wp_i18n_namespaceObject.__)('(no title)')); 44684 } 44685 function AuthorField({ 44686 item, 44687 viewType 44688 }) { 44689 const { 44690 text, 44691 icon, 44692 imageUrl 44693 } = useAddedBy(item.type, item.id); 44694 const withIcon = viewType !== LAYOUT_LIST; 44695 return (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalHStack, { 44696 alignment: "left", 44697 spacing: 1 44698 }, withIcon && imageUrl && (0,external_React_.createElement)(AvatarImage, { 44699 imageUrl: imageUrl 44700 }), withIcon && !imageUrl && (0,external_React_.createElement)("div", { 44701 className: "edit-site-list-added-by__icon" 44702 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.Icon, { 44703 icon: icon 44704 })), (0,external_React_.createElement)("span", null, text)); 44705 } 44706 function page_templates_template_parts_Preview({ 44707 item, 44708 viewType 44709 }) { 44710 const settings = usePatternSettings(); 44711 const [backgroundColor = 'white'] = page_templates_template_parts_useGlobalStyle('color.background'); 44712 const blocks = (0,external_wp_element_namespaceObject.useMemo)(() => { 44713 return (0,external_wp_blocks_namespaceObject.parse)(item.content.raw); 44714 }, [item.content.raw]); 44715 const { 44716 onClick 44717 } = useLink({ 44718 postId: item.id, 44719 postType: item.type, 44720 canvas: 'edit' 44721 }); 44722 const isEmpty = !blocks?.length; 44723 // Wrap everything in a block editor provider to ensure 'styles' that are needed 44724 // for the previews are synced between the site editor store and the block editor store. 44725 // Additionally we need to have the `__experimentalBlockPatterns` setting in order to 44726 // render patterns inside the previews. 44727 // TODO: Same approach is used in the patterns list and it becomes obvious that some of 44728 // the block editor settings are needed in context where we don't have the block editor. 44729 // Explore how we can solve this in a better way. 44730 return (0,external_React_.createElement)(page_templates_template_parts_ExperimentalBlockEditorProvider, { 44731 settings: settings 44732 }, (0,external_React_.createElement)("div", { 44733 className: `page-templates-preview-field is-viewtype-$viewType}`, 44734 style: { 44735 backgroundColor 44736 } 44737 }, viewType === LAYOUT_LIST && !isEmpty && (0,external_React_.createElement)(external_wp_blockEditor_namespaceObject.BlockPreview, { 44738 blocks: blocks 44739 }), viewType !== LAYOUT_LIST && (0,external_React_.createElement)("button", { 44740 className: "page-templates-preview-field__button", 44741 type: "button", 44742 onClick: onClick, 44743 "aria-label": item.title?.rendered || item.title 44744 }, isEmpty && (item.type === constants_TEMPLATE_POST_TYPE ? (0,external_wp_i18n_namespaceObject.__)('Empty template') : (0,external_wp_i18n_namespaceObject.__)('Empty template part')), !isEmpty && (0,external_React_.createElement)(external_wp_blockEditor_namespaceObject.BlockPreview, { 44745 blocks: blocks 44746 })))); 44747 } 44748 function PageTemplatesTemplateParts({ 44749 postType 44750 }) { 44751 const { 44752 params 44753 } = page_templates_template_parts_useLocation(); 44754 const { 44755 activeView = 'all', 44756 layout 44757 } = params; 44758 const defaultView = (0,external_wp_element_namespaceObject.useMemo)(() => { 44759 const usedType = window?.__experimentalAdminViews ? layout !== null && layout !== void 0 ? layout : page_templates_template_parts_DEFAULT_VIEW.type : page_templates_template_parts_DEFAULT_VIEW.type; 44760 return { 44761 ...page_templates_template_parts_DEFAULT_VIEW, 44762 type: usedType, 44763 layout: page_templates_template_parts_defaultConfigPerViewType[usedType], 44764 filters: activeView !== 'all' ? [{ 44765 field: 'author', 44766 operator: 'in', 44767 value: activeView 44768 }] : [] 44769 }; 44770 }, [layout, activeView]); 44771 const [view, setView] = (0,external_wp_element_namespaceObject.useState)(defaultView); 44772 (0,external_wp_element_namespaceObject.useEffect)(() => { 44773 setView(currentView => ({ 44774 ...currentView, 44775 filters: activeView !== 'all' ? [{ 44776 field: 'author', 44777 operator: 'in', 44778 value: activeView 44779 }] : [] 44780 })); 44781 }, [activeView]); 44782 const { 44783 records, 44784 isResolving: isLoadingData 44785 } = (0,external_wp_coreData_namespaceObject.useEntityRecords)('postType', postType, { 44786 per_page: -1 44787 }); 44788 const history = page_templates_template_parts_useHistory(); 44789 const onSelectionChange = (0,external_wp_element_namespaceObject.useCallback)(items => { 44790 if (view?.type === LAYOUT_LIST) { 44791 history.push({ 44792 ...params, 44793 postId: items.length === 1 ? items[0].id : undefined 44794 }); 44795 } 44796 }, [history, params, view?.type]); 44797 const authors = (0,external_wp_element_namespaceObject.useMemo)(() => { 44798 if (!records) { 44799 return page_templates_template_parts_EMPTY_ARRAY; 44800 } 44801 const authorsSet = new Set(); 44802 records.forEach(template => { 44803 authorsSet.add(template.author_text); 44804 }); 44805 return Array.from(authorsSet).map(author => ({ 44806 value: author, 44807 label: author 44808 })); 44809 }, [records]); 44810 const fields = (0,external_wp_element_namespaceObject.useMemo)(() => { 44811 const _fields = [{ 44812 header: (0,external_wp_i18n_namespaceObject.__)('Preview'), 44813 id: 'preview', 44814 render: ({ 44815 item 44816 }) => { 44817 return (0,external_React_.createElement)(page_templates_template_parts_Preview, { 44818 item: item, 44819 viewType: view.type 44820 }); 44821 }, 44822 minWidth: 120, 44823 maxWidth: 120, 44824 enableSorting: false 44825 }, { 44826 header: postType === constants_TEMPLATE_POST_TYPE ? (0,external_wp_i18n_namespaceObject.__)('Template') : (0,external_wp_i18n_namespaceObject.__)('Template Part'), 44827 id: 'title', 44828 getValue: ({ 44829 item 44830 }) => item.title?.rendered, 44831 render: ({ 44832 item 44833 }) => (0,external_React_.createElement)(page_templates_template_parts_Title, { 44834 item: item, 44835 viewType: view.type 44836 }), 44837 maxWidth: 400, 44838 enableHiding: false 44839 }]; 44840 if (postType === constants_TEMPLATE_POST_TYPE) { 44841 _fields.push({ 44842 header: (0,external_wp_i18n_namespaceObject.__)('Description'), 44843 id: 'description', 44844 getValue: ({ 44845 item 44846 }) => item.description, 44847 render: ({ 44848 item 44849 }) => { 44850 return item.description ? (0,external_React_.createElement)("span", { 44851 className: "page-templates-description" 44852 }, (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(item.description)) : view.type === LAYOUT_TABLE && (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(external_wp_components_namespaceObject.__experimentalText, { 44853 variant: "muted", 44854 "aria-hidden": "true" 44855 }, "\u2014"), (0,external_React_.createElement)(external_wp_components_namespaceObject.VisuallyHidden, null, (0,external_wp_i18n_namespaceObject.__)('No description.'))); 44856 }, 44857 maxWidth: 400, 44858 minWidth: 320, 44859 enableSorting: false 44860 }); 44861 } 44862 // TODO: The plan is to support fields reordering, which would require an API like `order` or something 44863 // similar. With the aforementioned API we wouldn't need to construct the fields array like this. 44864 _fields.push({ 44865 header: (0,external_wp_i18n_namespaceObject.__)('Author'), 44866 id: 'author', 44867 getValue: ({ 44868 item 44869 }) => item.author_text, 44870 render: ({ 44871 item 44872 }) => { 44873 return (0,external_React_.createElement)(AuthorField, { 44874 viewType: view.type, 44875 item: item 44876 }); 44877 }, 44878 type: ENUMERATION_TYPE, 44879 elements: authors, 44880 width: '1%' 44881 }); 44882 return _fields; 44883 }, [postType, authors, view.type]); 44884 const { 44885 data, 44886 paginationInfo 44887 } = (0,external_wp_element_namespaceObject.useMemo)(() => { 44888 if (!records) { 44889 return { 44890 data: page_templates_template_parts_EMPTY_ARRAY, 44891 paginationInfo: { 44892 totalItems: 0, 44893 totalPages: 0 44894 } 44895 }; 44896 } 44897 let filteredData = [...records]; 44898 // Handle global search. 44899 if (view.search) { 44900 const normalizedSearch = page_templates_template_parts_normalizeSearchInput(view.search); 44901 filteredData = filteredData.filter(item => { 44902 const title = item.title?.rendered || item.slug; 44903 return page_templates_template_parts_normalizeSearchInput(title).includes(normalizedSearch) || page_templates_template_parts_normalizeSearchInput(item.description).includes(normalizedSearch); 44904 }); 44905 } 44906 44907 // Handle filters. 44908 if (view.filters.length > 0) { 44909 view.filters.forEach(filter => { 44910 if (filter.field === 'author' && filter.operator === OPERATOR_IN && !!filter.value) { 44911 filteredData = filteredData.filter(item => { 44912 return item.author_text === filter.value; 44913 }); 44914 } else if (filter.field === 'author' && filter.operator === OPERATOR_NOT_IN && !!filter.value) { 44915 filteredData = filteredData.filter(item => { 44916 return item.author_text !== filter.value; 44917 }); 44918 } 44919 }); 44920 } 44921 44922 // Handle sorting. 44923 if (view.sort) { 44924 filteredData = sortByTextFields({ 44925 data: filteredData, 44926 view, 44927 fields, 44928 textFields: ['title', 'author'] 44929 }); 44930 } 44931 // Handle pagination. 44932 return getPaginationResults({ 44933 data: filteredData, 44934 view 44935 }); 44936 }, [records, view, fields]); 44937 const resetTemplateAction = useResetTemplateAction(); 44938 const actions = (0,external_wp_element_namespaceObject.useMemo)(() => [resetTemplateAction, deleteTemplateAction, renameTemplateAction, postRevisionsAction], [resetTemplateAction]); 44939 const onChangeView = (0,external_wp_element_namespaceObject.useCallback)(newView => { 44940 if (newView.type !== view.type) { 44941 newView = { 44942 ...newView, 44943 layout: { 44944 ...page_templates_template_parts_defaultConfigPerViewType[newView.type] 44945 } 44946 }; 44947 history.push({ 44948 ...params, 44949 layout: newView.type 44950 }); 44951 } 44952 setView(newView); 44953 }, [view.type, setView, history, params]); 44954 return (0,external_React_.createElement)(Page, { 44955 className: "edit-site-page-template-template-parts-dataviews", 44956 title: postType === constants_TEMPLATE_POST_TYPE ? (0,external_wp_i18n_namespaceObject.__)('Templates') : (0,external_wp_i18n_namespaceObject.__)('Template Parts'), 44957 actions: postType === constants_TEMPLATE_POST_TYPE ? (0,external_React_.createElement)(AddNewTemplate, { 44958 templateType: postType, 44959 showIcon: false, 44960 toggleProps: { 44961 variant: 'primary' 44962 } 44963 }) : (0,external_React_.createElement)(AddNewTemplatePart, null) 44964 }, (0,external_React_.createElement)(DataViews, { 44965 paginationInfo: paginationInfo, 44966 fields: fields, 44967 actions: actions, 44968 data: data, 44969 isLoading: isLoadingData, 44970 view: view, 44971 onChangeView: onChangeView, 44972 onSelectionChange: onSelectionChange, 44973 deferredRendering: !view.hiddenFields?.includes('preview'), 44974 supportedLayouts: page_templates_template_parts_SUPPORTED_LAYOUTS 44975 })); 44976 } 44977 44978 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/layout/router.js 44979 44980 /** 44981 * WordPress dependencies 44982 */ 44983 44984 44985 /** 44986 * Internal dependencies 44987 */ 44988 44989 44990 44991 44992 44993 44994 44995 const { 44996 useLocation: router_useLocation 44997 } = unlock(external_wp_router_namespaceObject.privateApis); 44998 function useLayoutAreas() { 44999 const isSiteEditorLoading = useIsSiteEditorLoading(); 45000 const { 45001 params 45002 } = router_useLocation(); 45003 const { 45004 postType, 45005 postId, 45006 path, 45007 layout, 45008 isCustom, 45009 canvas 45010 } = params !== null && params !== void 0 ? params : {}; 45011 45012 // Note: Since "sidebar" is not yet supported here, 45013 // returning undefined from "mobile" means show the sidebar. 45014 45015 // Regular page 45016 if (path === '/page') { 45017 return { 45018 areas: { 45019 content: undefined, 45020 preview: (0,external_React_.createElement)(Editor, { 45021 isLoading: isSiteEditorLoading 45022 }), 45023 mobile: canvas === 'edit' ? (0,external_React_.createElement)(Editor, { 45024 isLoading: isSiteEditorLoading 45025 }) : undefined 45026 }, 45027 widths: { 45028 content: undefined 45029 } 45030 }; 45031 } 45032 45033 // List layout is still experimental. 45034 // Extracted it here out of the conditionals so it doesn't unintentionally becomes stable. 45035 const isListLayout = isCustom !== 'true' && layout === 'list' && window?.__experimentalAdminViews; 45036 if (path === '/pages') { 45037 return { 45038 areas: { 45039 content: (0,external_React_.createElement)(PagePages, null), 45040 preview: isListLayout && (0,external_React_.createElement)(Editor, { 45041 isLoading: isSiteEditorLoading 45042 }) 45043 }, 45044 widths: { 45045 content: isListLayout ? 380 : undefined 45046 } 45047 }; 45048 } 45049 45050 // Regular other post types 45051 if (postType && postId) { 45052 return { 45053 areas: { 45054 preview: (0,external_React_.createElement)(Editor, { 45055 isLoading: isSiteEditorLoading 45056 }), 45057 mobile: canvas === 'edit' ? (0,external_React_.createElement)(Editor, { 45058 isLoading: isSiteEditorLoading 45059 }) : undefined 45060 } 45061 }; 45062 } 45063 45064 // Templates 45065 if (path === '/wp_template/all') { 45066 return { 45067 areas: { 45068 content: (0,external_React_.createElement)(PageTemplatesTemplateParts, { 45069 postType: constants_TEMPLATE_POST_TYPE 45070 }), 45071 preview: isListLayout && (0,external_React_.createElement)(Editor, { 45072 isLoading: isSiteEditorLoading 45073 }), 45074 mobile: (0,external_React_.createElement)(PageTemplatesTemplateParts, { 45075 postType: constants_TEMPLATE_POST_TYPE 45076 }) 45077 }, 45078 widths: { 45079 content: isListLayout ? 380 : undefined 45080 } 45081 }; 45082 } 45083 45084 // Template parts 45085 if (path === '/wp_template_part/all') { 45086 return { 45087 areas: { 45088 content: (0,external_React_.createElement)(PageTemplatesTemplateParts, { 45089 postType: TEMPLATE_PART_POST_TYPE 45090 }), 45091 preview: isListLayout && (0,external_React_.createElement)(Editor, { 45092 isLoading: isSiteEditorLoading 45093 }), 45094 mobile: (0,external_React_.createElement)(PageTemplatesTemplateParts, { 45095 postType: TEMPLATE_PART_POST_TYPE 45096 }) 45097 }, 45098 widths: { 45099 content: isListLayout ? 380 : undefined 45100 } 45101 }; 45102 } 45103 45104 // Patterns 45105 if (path === '/patterns') { 45106 return { 45107 areas: { 45108 content: (0,external_React_.createElement)(DataviewsPatterns, null), 45109 mobile: (0,external_React_.createElement)(DataviewsPatterns, null) 45110 } 45111 }; 45112 } 45113 45114 // Fallback shows the home page preview 45115 return { 45116 areas: { 45117 preview: (0,external_React_.createElement)(Editor, { 45118 isLoading: isSiteEditorLoading 45119 }), 45120 mobile: canvas === 'edit' ? (0,external_React_.createElement)(Editor, { 45121 isLoading: isSiteEditorLoading 45122 }) : undefined 45123 } 45124 }; 45125 } 45126 45127 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/layout/index.js 45128 45129 /** 45130 * External dependencies 45131 */ 45132 45133 45134 /** 45135 * WordPress dependencies 45136 */ 45137 45138 45139 45140 45141 45142 45143 45144 45145 45146 45147 45148 45149 /** 45150 * Internal dependencies 45151 */ 45152 45153 45154 45155 45156 45157 45158 45159 45160 45161 45162 45163 45164 45165 45166 45167 45168 const { 45169 useCommands 45170 } = unlock(external_wp_coreCommands_namespaceObject.privateApis); 45171 const { 45172 useCommandContext 45173 } = unlock(external_wp_commands_namespaceObject.privateApis); 45174 const { 45175 useGlobalStyle: layout_useGlobalStyle 45176 } = unlock(external_wp_blockEditor_namespaceObject.privateApis); 45177 const ANIMATION_DURATION = 0.5; 45178 function Layout() { 45179 // This ensures the edited entity id and type are initialized properly. 45180 useInitEditedEntityFromURL(); 45181 useSyncCanvasModeWithURL(); 45182 useCommands(); 45183 useEditModeCommands(); 45184 useCommonCommands(); 45185 (0,external_wp_blockEditor_namespaceObject.useBlockCommands)(); 45186 const isMobileViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium', '<'); 45187 const { 45188 isDistractionFree, 45189 hasFixedToolbar, 45190 hasBlockSelected, 45191 canvasMode, 45192 previousShortcut, 45193 nextShortcut 45194 } = (0,external_wp_data_namespaceObject.useSelect)(select => { 45195 const { 45196 getAllShortcutKeyCombinations 45197 } = select(external_wp_keyboardShortcuts_namespaceObject.store); 45198 const { 45199 getCanvasMode 45200 } = unlock(select(store_store)); 45201 return { 45202 canvasMode: getCanvasMode(), 45203 previousShortcut: getAllShortcutKeyCombinations('core/edit-site/previous-region'), 45204 nextShortcut: getAllShortcutKeyCombinations('core/edit-site/next-region'), 45205 hasFixedToolbar: select(external_wp_preferences_namespaceObject.store).get('core', 'fixedToolbar'), 45206 isDistractionFree: select(external_wp_preferences_namespaceObject.store).get('core', 'distractionFree'), 45207 hasBlockSelected: select(external_wp_blockEditor_namespaceObject.store).getBlockSelectionStart() 45208 }; 45209 }, []); 45210 const navigateRegionsProps = (0,external_wp_components_namespaceObject.__unstableUseNavigateRegions)({ 45211 previous: previousShortcut, 45212 next: nextShortcut 45213 }); 45214 const disableMotion = (0,external_wp_compose_namespaceObject.useReducedMotion)(); 45215 const [canvasResizer, canvasSize] = (0,external_wp_compose_namespaceObject.useResizeObserver)(); 45216 const [fullResizer] = (0,external_wp_compose_namespaceObject.useResizeObserver)(); 45217 const isEditorLoading = useIsSiteEditorLoading(); 45218 const [isResizableFrameOversized, setIsResizableFrameOversized] = (0,external_wp_element_namespaceObject.useState)(false); 45219 const { 45220 areas, 45221 widths 45222 } = useLayoutAreas(); 45223 45224 // This determines which animation variant should apply to the header. 45225 // There is also a `isDistractionFreeHovering` state that gets priority 45226 // when hovering the `edit-site-layout__header-container` in distraction 45227 // free mode. It's set via framer and trickles down to all the children 45228 // so they can use this variant state too. 45229 // 45230 // TODO: The issue with this is we want to have the hover state stick when hovering 45231 // a popover opened via the header. We'll probably need to lift this state to 45232 // handle it ourselves. Also, focusWithin the header needs to be handled. 45233 let headerAnimationState; 45234 if (canvasMode === 'view') { 45235 // We need 'view' to always take priority so 'isDistractionFree' 45236 // doesn't bleed over into the view (sidebar) state 45237 headerAnimationState = 'view'; 45238 } else if (isDistractionFree) { 45239 headerAnimationState = 'isDistractionFree'; 45240 } else { 45241 headerAnimationState = canvasMode; // edit, view, init 45242 } 45243 45244 // Sets the right context for the command palette 45245 let commandContext = 'site-editor'; 45246 if (canvasMode === 'edit') { 45247 commandContext = 'site-editor-edit'; 45248 } 45249 if (hasBlockSelected) { 45250 commandContext = 'block-selection-edit'; 45251 } 45252 useCommandContext(commandContext); 45253 const [backgroundColor] = layout_useGlobalStyle('color.background'); 45254 const [gradientValue] = layout_useGlobalStyle('color.gradient'); 45255 45256 // Synchronizing the URL with the store value of canvasMode happens in an effect 45257 // This condition ensures the component is only rendered after the synchronization happens 45258 // which prevents any animations due to potential canvasMode value change. 45259 if (canvasMode === 'init') { 45260 return null; 45261 } 45262 return (0,external_React_.createElement)(external_React_.Fragment, null, (0,external_React_.createElement)(external_wp_commands_namespaceObject.CommandMenu, null), (0,external_React_.createElement)(register, null), (0,external_React_.createElement)(global, null), fullResizer, (0,external_React_.createElement)("div", { 45263 ...navigateRegionsProps, 45264 ref: navigateRegionsProps.ref, 45265 className: classnames_default()('edit-site-layout', navigateRegionsProps.className, { 45266 'is-distraction-free': isDistractionFree && canvasMode === 'edit', 45267 'is-full-canvas': canvasMode === 'edit', 45268 'has-fixed-toolbar': hasFixedToolbar, 45269 'is-block-toolbar-visible': hasBlockSelected 45270 }) 45271 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__unstableMotion.div, { 45272 className: "edit-site-layout__header-container", 45273 variants: { 45274 isDistractionFree: { 45275 opacity: 0, 45276 transition: { 45277 type: 'tween', 45278 delay: 0.8, 45279 delayChildren: 0.8 45280 } // How long to wait before the header exits 45281 }, 45282 isDistractionFreeHovering: { 45283 opacity: 1, 45284 transition: { 45285 type: 'tween', 45286 delay: 0.2, 45287 delayChildren: 0.2 45288 } // How long to wait before the header shows 45289 }, 45290 view: { 45291 opacity: 1 45292 }, 45293 edit: { 45294 opacity: 1 45295 } 45296 }, 45297 whileHover: isDistractionFree ? 'isDistractionFreeHovering' : undefined, 45298 animate: headerAnimationState 45299 }, (0,external_React_.createElement)(site_hub, { 45300 isTransparent: isResizableFrameOversized, 45301 className: "edit-site-layout__hub" 45302 }), (0,external_React_.createElement)(external_wp_components_namespaceObject.__unstableAnimatePresence, { 45303 initial: false 45304 }, canvasMode === 'edit' && (0,external_React_.createElement)(NavigableRegion, { 45305 key: "header", 45306 className: "edit-site-layout__header", 45307 ariaLabel: (0,external_wp_i18n_namespaceObject.__)('Editor top bar'), 45308 as: external_wp_components_namespaceObject.__unstableMotion.div, 45309 variants: { 45310 isDistractionFree: { 45311 opacity: 0, 45312 y: 0 45313 }, 45314 isDistractionFreeHovering: { 45315 opacity: 1, 45316 y: 0 45317 }, 45318 view: { 45319 opacity: 1, 45320 y: '-100%' 45321 }, 45322 edit: { 45323 opacity: 1, 45324 y: 0 45325 } 45326 }, 45327 exit: { 45328 y: '-100%' 45329 }, 45330 initial: { 45331 opacity: isDistractionFree ? 1 : 0, 45332 y: isDistractionFree ? 0 : '-100%' 45333 }, 45334 transition: { 45335 type: 'tween', 45336 duration: disableMotion ? 0 : 0.2, 45337 ease: 'easeOut' 45338 } 45339 }, (0,external_React_.createElement)(HeaderEditMode, null)))), (0,external_React_.createElement)("div", { 45340 className: "edit-site-layout__content" 45341 }, (!isMobileViewport || isMobileViewport && !areas.mobile) && (0,external_React_.createElement)(NavigableRegion, { 45342 ariaLabel: (0,external_wp_i18n_namespaceObject.__)('Navigation'), 45343 className: "edit-site-layout__sidebar-region" 45344 }, (0,external_React_.createElement)(external_wp_components_namespaceObject.__unstableAnimatePresence, null, canvasMode === 'view' && (0,external_React_.createElement)(external_wp_components_namespaceObject.__unstableMotion.div, { 45345 initial: { 45346 opacity: 0 45347 }, 45348 animate: { 45349 opacity: 1 45350 }, 45351 exit: { 45352 opacity: 0 45353 }, 45354 transition: { 45355 type: 'tween', 45356 duration: 45357 // Disable transition in mobile to emulate a full page transition. 45358 disableMotion || isMobileViewport ? 0 : ANIMATION_DURATION, 45359 ease: 'easeOut' 45360 }, 45361 className: "edit-site-layout__sidebar" 45362 }, (0,external_React_.createElement)(sidebar, null)))), (0,external_React_.createElement)(SavePanel, null), isMobileViewport && areas.mobile && (0,external_React_.createElement)("div", { 45363 className: "edit-site-layout__mobile", 45364 style: { 45365 maxWidth: widths?.content 45366 } 45367 }, areas.mobile), !isMobileViewport && areas.content && canvasMode !== 'edit' && (0,external_React_.createElement)("div", { 45368 className: "edit-site-layout__area", 45369 style: { 45370 maxWidth: widths?.content 45371 } 45372 }, areas.content), !isMobileViewport && areas.preview && (0,external_React_.createElement)("div", { 45373 className: "edit-site-layout__canvas-container" 45374 }, canvasResizer, !!canvasSize.width && (0,external_React_.createElement)(external_wp_components_namespaceObject.__unstableMotion.div, { 45375 whileHover: canvasMode === 'view' ? { 45376 scale: 1.005, 45377 transition: { 45378 duration: disableMotion ? 0 : 0.5, 45379 ease: 'easeOut' 45380 } 45381 } : {}, 45382 initial: false, 45383 layout: "position", 45384 className: classnames_default()('edit-site-layout__canvas', { 45385 'is-right-aligned': isResizableFrameOversized 45386 }), 45387 transition: { 45388 type: 'tween', 45389 duration: disableMotion ? 0 : ANIMATION_DURATION, 45390 ease: 'easeOut' 45391 } 45392 }, (0,external_React_.createElement)(ErrorBoundary, null, (0,external_React_.createElement)(resizable_frame, { 45393 isReady: !isEditorLoading, 45394 isFullWidth: canvasMode === 'edit', 45395 defaultSize: { 45396 width: canvasSize.width - 24 /* $canvas-padding */, 45397 height: canvasSize.height 45398 }, 45399 isOversized: isResizableFrameOversized, 45400 setIsOversized: setIsResizableFrameOversized, 45401 innerContentStyle: { 45402 background: gradientValue !== null && gradientValue !== void 0 ? gradientValue : backgroundColor 45403 } 45404 }, areas.preview))))))); 45405 } 45406 45407 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/app/index.js 45408 45409 /** 45410 * WordPress dependencies 45411 */ 45412 45413 45414 45415 45416 45417 45418 45419 45420 /** 45421 * Internal dependencies 45422 */ 45423 45424 45425 45426 const { 45427 RouterProvider 45428 } = unlock(external_wp_router_namespaceObject.privateApis); 45429 function App() { 45430 const { 45431 createErrorNotice 45432 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store); 45433 function onPluginAreaError(name) { 45434 createErrorNotice((0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: plugin name */ 45435 (0,external_wp_i18n_namespaceObject.__)('The "%s" plugin has encountered an error and cannot be rendered.'), name)); 45436 } 45437 return (0,external_React_.createElement)(external_wp_components_namespaceObject.SlotFillProvider, null, (0,external_React_.createElement)(GlobalStylesProvider, null, (0,external_React_.createElement)(external_wp_editor_namespaceObject.UnsavedChangesWarning, null), (0,external_React_.createElement)(RouterProvider, null, (0,external_React_.createElement)(Layout, null), (0,external_React_.createElement)(external_wp_plugins_namespaceObject.PluginArea, { 45438 onError: onPluginAreaError 45439 })))); 45440 } 45441 45442 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/sidebar-edit-mode/plugin-sidebar/index.js 45443 45444 /** 45445 * WordPress dependencies 45446 */ 45447 45448 45449 /** 45450 * Renders a sidebar when activated. The contents within the `PluginSidebar` will appear as content within the sidebar. 45451 * It also automatically renders a corresponding `PluginSidebarMenuItem` component when `isPinnable` flag is set to `true`. 45452 * If you wish to display the sidebar, you can with use the `PluginSidebarMoreMenuItem` component or the `wp.data.dispatch` API: 45453 * 45454 * ```js 45455 * wp.data.dispatch( 'core/edit-site' ).openGeneralSidebar( 'plugin-name/sidebar-name' ); 45456 * ``` 45457 * 45458 * @see PluginSidebarMoreMenuItem 45459 * 45460 * @param {Object} props Element props. 45461 * @param {string} props.name A string identifying the sidebar. Must be unique for every sidebar registered within the scope of your plugin. 45462 * @param {string} [props.className] An optional class name added to the sidebar body. 45463 * @param {string} props.title Title displayed at the top of the sidebar. 45464 * @param {boolean} [props.isPinnable=true] Whether to allow to pin sidebar to the toolbar. When set to `true` it also automatically renders a corresponding menu item. 45465 * @param {WPBlockTypeIconRender} [props.icon=inherits from the plugin] The [Dashicon](https://developer.wordpress.org/resource/dashicons/) icon slug string, or an SVG WP element, to be rendered when the sidebar is pinned to toolbar. 45466 * 45467 * @example 45468 * ```js 45469 * // Using ES5 syntax 45470 * var __ = wp.i18n.__; 45471 * var el = wp.element.createElement; 45472 * var PanelBody = wp.components.PanelBody; 45473 * var PluginSidebar = wp.editSite.PluginSidebar; 45474 * var moreIcon = wp.element.createElement( 'svg' ); //... svg element. 45475 * 45476 * function MyPluginSidebar() { 45477 * return el( 45478 * PluginSidebar, 45479 * { 45480 * name: 'my-sidebar', 45481 * title: 'My sidebar title', 45482 * icon: moreIcon, 45483 * }, 45484 * el( 45485 * PanelBody, 45486 * {}, 45487 * __( 'My sidebar content' ) 45488 * ) 45489 * ); 45490 * } 45491 * ``` 45492 * 45493 * @example 45494 * ```jsx 45495 * // Using ESNext syntax 45496 * import { __ } from '@wordpress/i18n'; 45497 * import { PanelBody } from '@wordpress/components'; 45498 * import { PluginSidebar } from '@wordpress/edit-site'; 45499 * import { more } from '@wordpress/icons'; 45500 * 45501 * const MyPluginSidebar = () => ( 45502 * <PluginSidebar 45503 * name="my-sidebar" 45504 * title="My sidebar title" 45505 * icon={ more } 45506 * > 45507 * <PanelBody> 45508 * { __( 'My sidebar content' ) } 45509 * </PanelBody> 45510 * </PluginSidebar> 45511 * ); 45512 * ``` 45513 */ 45514 function PluginSidebarEditSite({ 45515 className, 45516 ...props 45517 }) { 45518 return (0,external_React_.createElement)(complementary_area, { 45519 panelClassName: className, 45520 className: "edit-site-sidebar-edit-mode", 45521 scope: "core/edit-site", 45522 ...props 45523 }); 45524 } 45525 45526 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/header-edit-mode/plugin-sidebar-more-menu-item/index.js 45527 45528 /** 45529 * WordPress dependencies 45530 */ 45531 45532 45533 /** 45534 * Renders a menu item in `Plugins` group in `More Menu` drop down, 45535 * and can be used to activate the corresponding `PluginSidebar` component. 45536 * The text within the component appears as the menu item label. 45537 * 45538 * @param {Object} props Component props. 45539 * @param {string} props.target A string identifying the target sidebar you wish to be activated by this menu item. Must be the same as the `name` prop you have given to that sidebar. 45540 * @param {WPBlockTypeIconRender} [props.icon=inherits from the plugin] The [Dashicon](https://developer.wordpress.org/resource/dashicons/) icon slug string, or an SVG WP element, to be rendered to the left of the menu item label. 45541 * 45542 * @example 45543 * ```js 45544 * // Using ES5 syntax 45545 * var __ = wp.i18n.__; 45546 * var PluginSidebarMoreMenuItem = wp.editSite.PluginSidebarMoreMenuItem; 45547 * var moreIcon = wp.element.createElement( 'svg' ); //... svg element. 45548 * 45549 * function MySidebarMoreMenuItem() { 45550 * return wp.element.createElement( 45551 * PluginSidebarMoreMenuItem, 45552 * { 45553 * target: 'my-sidebar', 45554 * icon: moreIcon, 45555 * }, 45556 * __( 'My sidebar title' ) 45557 * ) 45558 * } 45559 * ``` 45560 * 45561 * @example 45562 * ```jsx 45563 * // Using ESNext syntax 45564 * import { __ } from '@wordpress/i18n'; 45565 * import { PluginSidebarMoreMenuItem } from '@wordpress/edit-site'; 45566 * import { more } from '@wordpress/icons'; 45567 * 45568 * const MySidebarMoreMenuItem = () => ( 45569 * <PluginSidebarMoreMenuItem 45570 * target="my-sidebar" 45571 * icon={ more } 45572 * > 45573 * { __( 'My sidebar title' ) } 45574 * </PluginSidebarMoreMenuItem> 45575 * ); 45576 * ``` 45577 * 45578 * @return {Component} The component to be rendered. 45579 */ 45580 45581 function PluginSidebarMoreMenuItem(props) { 45582 return (0,external_React_.createElement)(ComplementaryAreaMoreMenuItem 45583 // Menu item is marked with unstable prop for backward compatibility. 45584 // @see https://github.com/WordPress/gutenberg/issues/14457 45585 , { 45586 __unstableExplicitMenuItem: true, 45587 scope: "core/edit-site", 45588 ...props 45589 }); 45590 } 45591 45592 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/components/header-edit-mode/plugin-more-menu-item/index.js 45593 /** 45594 * WordPress dependencies 45595 */ 45596 45597 45598 45599 45600 45601 /** 45602 * Renders a menu item in `Plugins` group in `More Menu` drop down, and can be used to as a button or link depending on the props provided. 45603 * The text within the component appears as the menu item label. 45604 * 45605 * @param {Object} props Component properties. 45606 * @param {string} [props.href] When `href` is provided then the menu item is represented as an anchor rather than button. It corresponds to the `href` attribute of the anchor. 45607 * @param {WPBlockTypeIconRender} [props.icon=inherits from the plugin] The [Dashicon](https://developer.wordpress.org/resource/dashicons/) icon slug string, or an SVG WP element, to be rendered to the left of the menu item label. 45608 * @param {Function} [props.onClick=noop] The callback function to be executed when the user clicks the menu item. 45609 * @param {...*} [props.other] Any additional props are passed through to the underlying [Button](/packages/components/src/button/README.md) component. 45610 * 45611 * @example 45612 * ```js 45613 * // Using ES5 syntax 45614 * var __ = wp.i18n.__; 45615 * var PluginMoreMenuItem = wp.editSite.PluginMoreMenuItem; 45616 * var moreIcon = wp.element.createElement( 'svg' ); //... svg element. 45617 * 45618 * function onButtonClick() { 45619 * alert( 'Button clicked.' ); 45620 * } 45621 * 45622 * function MyButtonMoreMenuItem() { 45623 * return wp.element.createElement( 45624 * PluginMoreMenuItem, 45625 * { 45626 * icon: moreIcon, 45627 * onClick: onButtonClick, 45628 * }, 45629 * __( 'My button title' ) 45630 * ); 45631 * } 45632 * ``` 45633 * 45634 * @example 45635 * ```jsx 45636 * // Using ESNext syntax 45637 * import { __ } from '@wordpress/i18n'; 45638 * import { PluginMoreMenuItem } from '@wordpress/edit-site'; 45639 * import { more } from '@wordpress/icons'; 45640 * 45641 * function onButtonClick() { 45642 * alert( 'Button clicked.' ); 45643 * } 45644 * 45645 * const MyButtonMoreMenuItem = () => ( 45646 * <PluginMoreMenuItem 45647 * icon={ more } 45648 * onClick={ onButtonClick } 45649 * > 45650 * { __( 'My button title' ) } 45651 * </PluginMoreMenuItem> 45652 * ); 45653 * ``` 45654 * 45655 * @return {Component} The component to be rendered. 45656 */ 45657 /* harmony default export */ const plugin_more_menu_item = ((0,external_wp_compose_namespaceObject.compose)((0,external_wp_plugins_namespaceObject.withPluginContext)((context, ownProps) => { 45658 var _ownProps$as; 45659 return { 45660 as: (_ownProps$as = ownProps.as) !== null && _ownProps$as !== void 0 ? _ownProps$as : external_wp_components_namespaceObject.MenuItem, 45661 icon: ownProps.icon || context.icon, 45662 name: 'core/edit-site/plugin-more-menu' 45663 }; 45664 }))(action_item)); 45665 45666 ;// CONCATENATED MODULE: ./node_modules/@wordpress/edit-site/build-module/index.js 45667 45668 /** 45669 * WordPress dependencies 45670 */ 45671 45672 45673 45674 45675 45676 45677 45678 45679 45680 45681 /** 45682 * Internal dependencies 45683 */ 45684 45685 45686 45687 45688 /** 45689 * Initializes the site editor screen. 45690 * 45691 * @param {string} id ID of the root element to render the screen in. 45692 * @param {Object} settings Editor settings. 45693 */ 45694 function initializeEditor(id, settings) { 45695 const target = document.getElementById(id); 45696 const root = (0,external_wp_element_namespaceObject.createRoot)(target); 45697 (0,external_wp_data_namespaceObject.dispatch)(external_wp_blocks_namespaceObject.store).reapplyBlockTypeFilters(); 45698 const coreBlocks = (0,external_wp_blockLibrary_namespaceObject.__experimentalGetCoreBlocks)().filter(({ 45699 name 45700 }) => name !== 'core/freeform'); 45701 (0,external_wp_blockLibrary_namespaceObject.registerCoreBlocks)(coreBlocks); 45702 (0,external_wp_data_namespaceObject.dispatch)(external_wp_blocks_namespaceObject.store).setFreeformFallbackBlockName('core/html'); 45703 (0,external_wp_widgets_namespaceObject.registerLegacyWidgetBlock)({ 45704 inserter: false 45705 }); 45706 (0,external_wp_widgets_namespaceObject.registerWidgetGroupBlock)({ 45707 inserter: false 45708 }); 45709 if (false) {} 45710 45711 // We dispatch actions and update the store synchronously before rendering 45712 // so that we won't trigger unnecessary re-renders with useEffect. 45713 (0,external_wp_data_namespaceObject.dispatch)(external_wp_preferences_namespaceObject.store).setDefaults('core/edit-site', { 45714 welcomeGuide: true, 45715 welcomeGuideStyles: true, 45716 welcomeGuidePage: true, 45717 welcomeGuideTemplate: true 45718 }); 45719 (0,external_wp_data_namespaceObject.dispatch)(external_wp_preferences_namespaceObject.store).setDefaults('core', { 45720 allowRightClickOverrides: true, 45721 distractionFree: false, 45722 editorMode: 'visual', 45723 fixedToolbar: false, 45724 focusMode: false, 45725 inactivePanels: [], 45726 keepCaretInsideBlock: false, 45727 openPanels: ['post-status'], 45728 showBlockBreadcrumbs: true, 45729 showListViewByDefault: false 45730 }); 45731 (0,external_wp_data_namespaceObject.dispatch)(store).setDefaultComplementaryArea('core/edit-site', 'edit-site/template'); 45732 (0,external_wp_data_namespaceObject.dispatch)(store_store).updateSettings(settings); 45733 45734 // Keep the defaultTemplateTypes in the core/editor settings too, 45735 // so that they can be selected with core/editor selectors in any editor. 45736 // This is needed because edit-site doesn't initialize with EditorProvider, 45737 // which internally uses updateEditorSettings as well. 45738 (0,external_wp_data_namespaceObject.dispatch)(external_wp_editor_namespaceObject.store).updateEditorSettings({ 45739 defaultTemplateTypes: settings.defaultTemplateTypes, 45740 defaultTemplatePartAreas: settings.defaultTemplatePartAreas 45741 }); 45742 45743 // Prevent the default browser action for files dropped outside of dropzones. 45744 window.addEventListener('dragover', e => e.preventDefault(), false); 45745 window.addEventListener('drop', e => e.preventDefault(), false); 45746 root.render((0,external_React_.createElement)(App, null)); 45747 return root; 45748 } 45749 function reinitializeEditor() { 45750 external_wp_deprecated_default()('wp.editSite.reinitializeEditor', { 45751 since: '6.2', 45752 version: '6.3' 45753 }); 45754 } 45755 45756 45757 45758 45759 45760 45761 })(); 45762 45763 (window.wp = window.wp || {}).editSite = __webpack_exports__; 45764 /******/ })() 45765 ;
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated : Thu May 9 08:20:02 2024 | Cross-referenced by PHPXref |