diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index 8f70268..0000000 Binary files a/.DS_Store and /dev/null differ diff --git a/.gitignore b/.gitignore index 7e5da87..ce6b860 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ +.DS_Store node_modules/ -vendor/ +vendor/ \ No newline at end of file diff --git a/build/validation-api-settings.js b/build/validation-api-settings.js index e69de29..5dc9de6 100644 --- a/build/validation-api-settings.js +++ b/build/validation-api-settings.js @@ -0,0 +1,19816 @@ +( () => { + var e, + t, + n = { + 489( e ) { + 'use strict'; + e.exports = function e( t, n ) { + if ( t === n ) return ! 0; + if ( t && n && 'object' == typeof t && 'object' == typeof n ) { + if ( t.constructor !== n.constructor ) return ! 1; + var i, r, o; + if ( Array.isArray( t ) ) { + if ( ( i = t.length ) != n.length ) return ! 1; + for ( r = i; 0 !== r--; ) if ( ! e( t[ r ], n[ r ] ) ) return ! 1; + return ! 0; + } + if ( t instanceof Map && n instanceof Map ) { + if ( t.size !== n.size ) return ! 1; + for ( r of t.entries() ) if ( ! n.has( r[ 0 ] ) ) return ! 1; + for ( r of t.entries() ) + if ( ! e( r[ 1 ], n.get( r[ 0 ] ) ) ) return ! 1; + return ! 0; + } + if ( t instanceof Set && n instanceof Set ) { + if ( t.size !== n.size ) return ! 1; + for ( r of t.entries() ) if ( ! n.has( r[ 0 ] ) ) return ! 1; + return ! 0; + } + if ( ArrayBuffer.isView( t ) && ArrayBuffer.isView( n ) ) { + if ( ( i = t.length ) != n.length ) return ! 1; + for ( r = i; 0 !== r--; ) if ( t[ r ] !== n[ r ] ) return ! 1; + return ! 0; + } + if ( t.constructor === RegExp ) + return t.source === n.source && t.flags === n.flags; + if ( t.valueOf !== Object.prototype.valueOf ) + return t.valueOf() === n.valueOf(); + if ( t.toString !== Object.prototype.toString ) + return t.toString() === n.toString(); + if ( ( i = ( o = Object.keys( t ) ).length ) !== Object.keys( n ).length ) + return ! 1; + for ( r = i; 0 !== r--; ) + if ( ! Object.prototype.hasOwnProperty.call( n, o[ r ] ) ) return ! 1; + for ( r = i; 0 !== r--; ) { + var s = o[ r ]; + if ( ! e( t[ s ], n[ s ] ) ) return ! 1; + } + return ! 0; + } + return t != t && n != n; + }; + }, + 686( e ) { + var t = { + À: 'A', + Á: 'A', + Â: 'A', + Ã: 'A', + Ä: 'A', + Å: 'A', + Ấ: 'A', + Ắ: 'A', + Ẳ: 'A', + Ẵ: 'A', + Ặ: 'A', + Æ: 'AE', + Ầ: 'A', + Ằ: 'A', + Ȃ: 'A', + Ả: 'A', + Ạ: 'A', + Ẩ: 'A', + Ẫ: 'A', + Ậ: 'A', + Ç: 'C', + Ḉ: 'C', + È: 'E', + É: 'E', + Ê: 'E', + Ë: 'E', + Ế: 'E', + Ḗ: 'E', + Ề: 'E', + Ḕ: 'E', + Ḝ: 'E', + Ȇ: 'E', + Ẻ: 'E', + Ẽ: 'E', + Ẹ: 'E', + Ể: 'E', + Ễ: 'E', + Ệ: 'E', + Ì: 'I', + Í: 'I', + Î: 'I', + Ï: 'I', + Ḯ: 'I', + Ȋ: 'I', + Ỉ: 'I', + Ị: 'I', + Ð: 'D', + Ñ: 'N', + Ò: 'O', + Ó: 'O', + Ô: 'O', + Õ: 'O', + Ö: 'O', + Ø: 'O', + Ố: 'O', + Ṍ: 'O', + Ṓ: 'O', + Ȏ: 'O', + Ỏ: 'O', + Ọ: 'O', + Ổ: 'O', + Ỗ: 'O', + Ộ: 'O', + Ờ: 'O', + Ở: 'O', + Ỡ: 'O', + Ớ: 'O', + Ợ: 'O', + Ù: 'U', + Ú: 'U', + Û: 'U', + Ü: 'U', + Ủ: 'U', + Ụ: 'U', + Ử: 'U', + Ữ: 'U', + Ự: 'U', + Ý: 'Y', + à: 'a', + á: 'a', + â: 'a', + ã: 'a', + ä: 'a', + å: 'a', + ấ: 'a', + ắ: 'a', + ẳ: 'a', + ẵ: 'a', + ặ: 'a', + æ: 'ae', + ầ: 'a', + ằ: 'a', + ȃ: 'a', + ả: 'a', + ạ: 'a', + ẩ: 'a', + ẫ: 'a', + ậ: 'a', + ç: 'c', + ḉ: 'c', + è: 'e', + é: 'e', + ê: 'e', + ë: 'e', + ế: 'e', + ḗ: 'e', + ề: 'e', + ḕ: 'e', + ḝ: 'e', + ȇ: 'e', + ẻ: 'e', + ẽ: 'e', + ẹ: 'e', + ể: 'e', + ễ: 'e', + ệ: 'e', + ì: 'i', + í: 'i', + î: 'i', + ï: 'i', + ḯ: 'i', + ȋ: 'i', + ỉ: 'i', + ị: 'i', + ð: 'd', + ñ: 'n', + ò: 'o', + ó: 'o', + ô: 'o', + õ: 'o', + ö: 'o', + ø: 'o', + ố: 'o', + ṍ: 'o', + ṓ: 'o', + ȏ: 'o', + ỏ: 'o', + ọ: 'o', + ổ: 'o', + ỗ: 'o', + ộ: 'o', + ờ: 'o', + ở: 'o', + ỡ: 'o', + ớ: 'o', + ợ: 'o', + ù: 'u', + ú: 'u', + û: 'u', + ü: 'u', + ủ: 'u', + ụ: 'u', + ử: 'u', + ữ: 'u', + ự: 'u', + ý: 'y', + ÿ: 'y', + Ā: 'A', + ā: 'a', + Ă: 'A', + ă: 'a', + Ą: 'A', + ą: 'a', + Ć: 'C', + ć: 'c', + Ĉ: 'C', + ĉ: 'c', + Ċ: 'C', + ċ: 'c', + Č: 'C', + č: 'c', + C̆: 'C', + c̆: 'c', + Ď: 'D', + ď: 'd', + Đ: 'D', + đ: 'd', + Ē: 'E', + ē: 'e', + Ĕ: 'E', + ĕ: 'e', + Ė: 'E', + ė: 'e', + Ę: 'E', + ę: 'e', + Ě: 'E', + ě: 'e', + Ĝ: 'G', + Ǵ: 'G', + ĝ: 'g', + ǵ: 'g', + Ğ: 'G', + ğ: 'g', + Ġ: 'G', + ġ: 'g', + Ģ: 'G', + ģ: 'g', + Ĥ: 'H', + ĥ: 'h', + Ħ: 'H', + ħ: 'h', + Ḫ: 'H', + ḫ: 'h', + Ĩ: 'I', + ĩ: 'i', + Ī: 'I', + ī: 'i', + Ĭ: 'I', + ĭ: 'i', + Į: 'I', + į: 'i', + İ: 'I', + ı: 'i', + IJ: 'IJ', + ij: 'ij', + Ĵ: 'J', + ĵ: 'j', + Ķ: 'K', + ķ: 'k', + Ḱ: 'K', + ḱ: 'k', + K̆: 'K', + k̆: 'k', + Ĺ: 'L', + ĺ: 'l', + Ļ: 'L', + ļ: 'l', + Ľ: 'L', + ľ: 'l', + Ŀ: 'L', + ŀ: 'l', + Ł: 'l', + ł: 'l', + Ḿ: 'M', + ḿ: 'm', + M̆: 'M', + m̆: 'm', + Ń: 'N', + ń: 'n', + Ņ: 'N', + ņ: 'n', + Ň: 'N', + ň: 'n', + ʼn: 'n', + N̆: 'N', + n̆: 'n', + Ō: 'O', + ō: 'o', + Ŏ: 'O', + ŏ: 'o', + Ő: 'O', + ő: 'o', + Œ: 'OE', + œ: 'oe', + P̆: 'P', + p̆: 'p', + Ŕ: 'R', + ŕ: 'r', + Ŗ: 'R', + ŗ: 'r', + Ř: 'R', + ř: 'r', + R̆: 'R', + r̆: 'r', + Ȓ: 'R', + ȓ: 'r', + Ś: 'S', + ś: 's', + Ŝ: 'S', + ŝ: 's', + Ş: 'S', + Ș: 'S', + ș: 's', + ş: 's', + Š: 'S', + š: 's', + Ţ: 'T', + ţ: 't', + ț: 't', + Ț: 'T', + Ť: 'T', + ť: 't', + Ŧ: 'T', + ŧ: 't', + T̆: 'T', + t̆: 't', + Ũ: 'U', + ũ: 'u', + Ū: 'U', + ū: 'u', + Ŭ: 'U', + ŭ: 'u', + Ů: 'U', + ů: 'u', + Ű: 'U', + ű: 'u', + Ų: 'U', + ų: 'u', + Ȗ: 'U', + ȗ: 'u', + V̆: 'V', + v̆: 'v', + Ŵ: 'W', + ŵ: 'w', + Ẃ: 'W', + ẃ: 'w', + X̆: 'X', + x̆: 'x', + Ŷ: 'Y', + ŷ: 'y', + Ÿ: 'Y', + Y̆: 'Y', + y̆: 'y', + Ź: 'Z', + ź: 'z', + Ż: 'Z', + ż: 'z', + Ž: 'Z', + ž: 'z', + ſ: 's', + ƒ: 'f', + Ơ: 'O', + ơ: 'o', + Ư: 'U', + ư: 'u', + Ǎ: 'A', + ǎ: 'a', + Ǐ: 'I', + ǐ: 'i', + Ǒ: 'O', + ǒ: 'o', + Ǔ: 'U', + ǔ: 'u', + Ǖ: 'U', + ǖ: 'u', + Ǘ: 'U', + ǘ: 'u', + Ǚ: 'U', + ǚ: 'u', + Ǜ: 'U', + ǜ: 'u', + Ứ: 'U', + ứ: 'u', + Ṹ: 'U', + ṹ: 'u', + Ǻ: 'A', + ǻ: 'a', + Ǽ: 'AE', + ǽ: 'ae', + Ǿ: 'O', + ǿ: 'o', + Þ: 'TH', + þ: 'th', + Ṕ: 'P', + ṕ: 'p', + Ṥ: 'S', + ṥ: 's', + X́: 'X', + x́: 'x', + Ѓ: 'Г', + ѓ: 'г', + Ќ: 'К', + ќ: 'к', + A̋: 'A', + a̋: 'a', + E̋: 'E', + e̋: 'e', + I̋: 'I', + i̋: 'i', + Ǹ: 'N', + ǹ: 'n', + Ồ: 'O', + ồ: 'o', + Ṑ: 'O', + ṑ: 'o', + Ừ: 'U', + ừ: 'u', + Ẁ: 'W', + ẁ: 'w', + Ỳ: 'Y', + ỳ: 'y', + Ȁ: 'A', + ȁ: 'a', + Ȅ: 'E', + ȅ: 'e', + Ȉ: 'I', + ȉ: 'i', + Ȍ: 'O', + ȍ: 'o', + Ȑ: 'R', + ȑ: 'r', + Ȕ: 'U', + ȕ: 'u', + B̌: 'B', + b̌: 'b', + Č̣: 'C', + č̣: 'c', + Ê̌: 'E', + ê̌: 'e', + F̌: 'F', + f̌: 'f', + Ǧ: 'G', + ǧ: 'g', + Ȟ: 'H', + ȟ: 'h', + J̌: 'J', + ǰ: 'j', + Ǩ: 'K', + ǩ: 'k', + M̌: 'M', + m̌: 'm', + P̌: 'P', + p̌: 'p', + Q̌: 'Q', + q̌: 'q', + Ř̩: 'R', + ř̩: 'r', + Ṧ: 'S', + ṧ: 's', + V̌: 'V', + v̌: 'v', + W̌: 'W', + w̌: 'w', + X̌: 'X', + x̌: 'x', + Y̌: 'Y', + y̌: 'y', + A̧: 'A', + a̧: 'a', + B̧: 'B', + b̧: 'b', + Ḑ: 'D', + ḑ: 'd', + Ȩ: 'E', + ȩ: 'e', + Ɛ̧: 'E', + ɛ̧: 'e', + Ḩ: 'H', + ḩ: 'h', + I̧: 'I', + i̧: 'i', + Ɨ̧: 'I', + ɨ̧: 'i', + M̧: 'M', + m̧: 'm', + O̧: 'O', + o̧: 'o', + Q̧: 'Q', + q̧: 'q', + U̧: 'U', + u̧: 'u', + X̧: 'X', + x̧: 'x', + Z̧: 'Z', + z̧: 'z', + й: 'и', + Й: 'И', + ё: 'е', + Ё: 'Е', + }, + n = Object.keys( t ).join( '|' ), + i = new RegExp( n, 'g' ), + r = new RegExp( n, '' ); + function o( e ) { + return t[ e ]; + } + var s = function ( e ) { + return e.replace( i, o ); + }; + ( e.exports = s ), + ( e.exports.has = function ( e ) { + return !! e.match( r ); + } ), + ( e.exports.remove = s ); + }, + 417( e, t, n ) { + 'use strict'; + var i = n( 609 ), + r = + 'function' == typeof Object.is + ? Object.is + : function ( e, t ) { + return ( + ( e === t && ( 0 !== e || 1 / e == 1 / t ) ) || + ( e != e && t != t ) + ); + }, + o = i.useState, + s = i.useEffect, + a = i.useLayoutEffect, + l = i.useDebugValue; + function c( e ) { + var t = e.getSnapshot; + e = e.value; + try { + var n = t(); + return ! r( e, n ); + } catch ( e ) { + return ! 0; + } + } + var u = + 'undefined' == typeof window || + void 0 === window.document || + void 0 === window.document.createElement + ? function ( e, t ) { + return t(); + } + : function ( e, t ) { + var n = t(), + i = o( { inst: { value: n, getSnapshot: t } } ), + r = i[ 0 ].inst, + u = i[ 1 ]; + return ( + a( + function () { + ( r.value = n ), + ( r.getSnapshot = t ), + c( r ) && u( { inst: r } ); + }, + [ e, n, t ] + ), + s( + function () { + return ( + c( r ) && u( { inst: r } ), + e( function () { + c( r ) && u( { inst: r } ); + } ) + ); + }, + [ e ] + ), + l( n ), + n + ); + }; + t.useSyncExternalStore = + void 0 !== i.useSyncExternalStore ? i.useSyncExternalStore : u; + }, + 326( e, t, n ) { + 'use strict'; + var i = n( 609 ), + r = n( 412 ), + o = + 'function' == typeof Object.is + ? Object.is + : function ( e, t ) { + return ( + ( e === t && ( 0 !== e || 1 / e == 1 / t ) ) || + ( e != e && t != t ) + ); + }, + s = r.useSyncExternalStore, + a = i.useRef, + l = i.useEffect, + c = i.useMemo, + u = i.useDebugValue; + t.useSyncExternalStoreWithSelector = function ( e, t, n, i, r ) { + var d = a( null ); + if ( null === d.current ) { + var f = { hasValue: ! 1, value: null }; + d.current = f; + } else f = d.current; + d = c( + function () { + function e( e ) { + if ( ! l ) { + if ( + ( ( l = ! 0 ), + ( s = e ), + ( e = i( e ) ), + void 0 !== r && f.hasValue ) + ) { + var t = f.value; + if ( r( t, e ) ) return ( a = t ); + } + return ( a = e ); + } + if ( ( ( t = a ), o( s, e ) ) ) return t; + var n = i( e ); + return void 0 !== r && r( t, n ) + ? ( ( s = e ), t ) + : ( ( s = e ), ( a = n ) ); + } + var s, + a, + l = ! 1, + c = void 0 === n ? null : n; + return [ + function () { + return e( t() ); + }, + null === c + ? void 0 + : function () { + return e( c() ); + }, + ]; + }, + [ t, n, i, r ] + ); + var m = s( e, d[ 0 ], d[ 1 ] ); + return ( + l( + function () { + ( f.hasValue = ! 0 ), ( f.value = m ); + }, + [ m ] + ), + u( m ), + m + ); + }; + }, + 412( e, t, n ) { + 'use strict'; + e.exports = n( 417 ); + }, + 134( e, t, n ) { + 'use strict'; + e.exports = n( 326 ); + }, + 609( e ) { + 'use strict'; + e.exports = window.React; + }, + }, + i = {}; + function r( e ) { + var t = i[ e ]; + if ( void 0 !== t ) return t.exports; + var o = ( i[ e ] = { exports: {} } ); + return n[ e ]( o, o.exports, r ), o.exports; + } + ( r.n = e => { + var t = e && e.__esModule ? () => e.default : () => e; + return r.d( t, { a: t } ), t; + } ), + ( t = Object.getPrototypeOf ? e => Object.getPrototypeOf( e ) : e => e.__proto__ ), + ( r.t = function ( n, i ) { + if ( ( 1 & i && ( n = this( n ) ), 8 & i ) ) return n; + if ( 'object' == typeof n && n ) { + if ( 4 & i && n.__esModule ) return n; + if ( 16 & i && 'function' == typeof n.then ) return n; + } + var o = Object.create( null ); + r.r( o ); + var s = {}; + e = e || [ null, t( {} ), t( [] ), t( t ) ]; + for ( + var a = 2 & i && n; + ( 'object' == typeof a || 'function' == typeof a ) && ! ~e.indexOf( a ); + a = t( a ) + ) + Object.getOwnPropertyNames( a ).forEach( e => ( s[ e ] = () => n[ e ] ) ); + return ( s.default = () => n ), r.d( o, s ), o; + } ), + ( r.d = ( e, t ) => { + for ( var n in t ) + r.o( t, n ) && + ! r.o( e, n ) && + Object.defineProperty( e, n, { enumerable: ! 0, get: t[ n ] } ); + } ), + ( r.o = ( e, t ) => Object.prototype.hasOwnProperty.call( e, t ) ), + ( r.r = e => { + 'undefined' != typeof Symbol && + Symbol.toStringTag && + Object.defineProperty( e, Symbol.toStringTag, { value: 'Module' } ), + Object.defineProperty( e, '__esModule', { value: ! 0 } ); + } ), + ( () => { + 'use strict'; + const e = window.wp.element, + t = window.wp.components, + n = window.wp.i18n, + i = window.wp.apiFetch; + var o = r.n( i ), + s = r( 686 ); + const a = window.wp.deprecated, + l = window.wp.primitives, + c = window.ReactJSXRuntime; + var u = ( 0, c.jsx )( l.SVG, { + xmlns: 'http://www.w3.org/2000/svg', + viewBox: '0 0 24 24', + children: ( 0, c.jsx )( l.Path, { + d: 'M12 3.9 6.5 9.5l1 1 3.8-3.7V20h1.5V6.8l3.7 3.7 1-1z', + } ), + } ), + d = ( 0, c.jsx )( l.SVG, { + xmlns: 'http://www.w3.org/2000/svg', + viewBox: '0 0 24 24', + children: ( 0, c.jsx )( l.Path, { + d: 'm16.5 13.5-3.7 3.7V4h-1.5v13.2l-3.8-3.7-1 1 5.5 5.6 5.5-5.6z', + } ), + } ), + f = 'isAny', + m = 'isNone', + p = 'isAll', + g = 'isNotAll', + h = 'between', + v = 'inThePast', + b = 'over', + w = 'is', + y = 'isNot', + x = 'lessThan', + C = 'greaterThan', + S = 'lessThanOrEqual', + _ = 'greaterThanOrEqual', + j = 'before', + E = 'after', + k = 'beforeInc', + I = 'afterInc', + V = 'contains', + O = 'notContains', + P = 'startsWith', + M = 'on', + T = 'notOn', + N = [ 'asc', 'desc' ], + A = { asc: '↑', desc: '↓' }, + R = { asc: 'ascending', desc: 'descending' }, + F = { + asc: ( 0, n.__ )( 'Sort ascending' ), + desc: ( 0, n.__ )( 'Sort descending' ), + }, + L = { asc: u, desc: d }, + D = 'table', + B = 'grid'; + const z = window.wp.privateApis; + var { lock: W, unlock: $ } = ( 0, z.__dangerousOptInToUnstableAPIsOnlyForCoreModules )( + 'I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.', + '@wordpress/dataviews' + ); + function H( e, t ) { + let n; + return ( + e?.required && t?.required + ? ( n = t?.required?.message ? t.required : void 0 ) + : e?.pattern && t?.pattern + ? ( n = t.pattern ) + : e?.min && t?.min + ? ( n = t.min ) + : e?.max && t?.max + ? ( n = t.max ) + : e?.minLength && t?.minLength + ? ( n = t.minLength ) + : e?.maxLength && t?.maxLength + ? ( n = t.maxLength ) + : e?.elements && t?.elements + ? ( n = t.elements ) + : t?.custom && ( n = t.custom ), + n + ); + } + var { ValidatedCheckboxControl: q } = $( t.privateApis ), + G = []; + function Y( { elements: t, getElements: n } ) { + const i = Array.isArray( t ) && t.length > 0 ? t : G, + [ r, o ] = ( 0, e.useState )( i ), + [ s, a ] = ( 0, e.useState )( ! 1 ); + return ( + ( 0, e.useEffect )( () => { + if ( ! n ) return void o( i ); + let e = ! 1; + return ( + a( ! 0 ), + n() + .then( t => { + if ( ! e ) { + const e = Array.isArray( t ) && t.length > 0 ? t : i; + o( e ); + } + } ) + .catch( () => { + e || o( i ); + } ) + .finally( () => { + e || a( ! 1 ); + } ), + () => { + e = ! 0; + } + ); + }, [ n, i ] ), + { elements: r, isLoading: s } + ); + } + var { ValidatedComboboxControl: K } = $( t.privateApis ); + function U( { data: n, field: i, onChange: r, hideLabelFromVision: o, validity: s } ) { + const { + label: a, + description: l, + placeholder: u, + getValue: d, + setValue: f, + isValid: m, + } = i, + p = d( { item: n } ) ?? '', + g = ( 0, e.useCallback )( + e => r( f( { item: n, value: e ?? '' } ) ), + [ n, r, f ] + ), + { elements: h, isLoading: v } = Y( { + elements: i.elements, + getElements: i.getElements, + } ); + return v + ? ( 0, c.jsx )( t.Spinner, {} ) + : ( 0, c.jsx )( K, { + required: !! i.isValid?.required, + customValidity: H( m, s ), + label: a, + value: p, + help: l, + placeholder: u, + options: h, + onChange: g, + hideLabelFromVision: o, + allowReset: ! 0, + expandOnFocus: ! 0, + } ); + } + const X = window.wp.date, + Z = function ( e, ...t ) { + const n = new URL( 'https://base-ui.com/production-error' ); + return ( + n.searchParams.set( 'code', e.toString() ), + t.forEach( e => n.searchParams.append( 'args[]', e ) ), + `Base UI error #${ e }; visit ${ n } for the full message.` + ); + }; + const Q = Z; + var J = r( 609 ), + ee = r.t( J, 2 ); + const te = {}; + function ne( e, t ) { + const n = J.useRef( te ); + return n.current === te && ( n.current = e( t ) ), n; + } + function ie( e, t, n, i ) { + const r = ne( re ).current; + return ( + ( function ( e, t, n, i, r ) { + return ( + e.refs[ 0 ] !== t || + e.refs[ 1 ] !== n || + e.refs[ 2 ] !== i || + e.refs[ 3 ] !== r + ); + } )( r, e, t, n, i ) && oe( r, [ e, t, n, i ] ), + r.callback + ); + } + function re() { + return { callback: null, cleanup: null, refs: [] }; + } + function oe( e, t ) { + ( e.refs = t ), + t.every( e => null == e ) + ? ( e.callback = null ) + : ( e.callback = n => { + if ( + ( e.cleanup && ( e.cleanup(), ( e.cleanup = null ) ), + null != n ) + ) { + const i = Array( t.length ).fill( null ); + for ( let e = 0; e < t.length; e += 1 ) { + const r = t[ e ]; + if ( null != r ) + switch ( typeof r ) { + case 'function': { + const t = r( n ); + 'function' == typeof t && ( i[ e ] = t ); + break; + } + case 'object': + r.current = n; + } + } + e.cleanup = () => { + for ( let e = 0; e < t.length; e += 1 ) { + const n = t[ e ]; + if ( null != n ) + switch ( typeof n ) { + case 'function': { + const t = i[ e ]; + 'function' == typeof t ? t() : n( null ); + break; + } + case 'object': + n.current = null; + } + } + }; + } + } ); + } + const se = parseInt( J.version, 10 ); + function ae( e ) { + return se >= e; + } + function le( e ) { + if ( ! J.isValidElement( e ) ) return null; + const t = e, + n = t.props; + return ( ae( 19 ) ? n?.ref : t.ref ) ?? null; + } + function ce( e, t ) { + return e && ! t ? e : ! e && t ? t : e || t ? { ...e, ...t } : void 0; + } + function ue() {} + Object.freeze( [] ); + const de = Object.freeze( {} ), + fe = {}; + function me( e, t, n, i, r ) { + if ( ! ( n || i || r || e ) ) return pe( t ); + let o = pe( e ); + return ( + t && ( o = ge( o, t ) ), + n && ( o = ge( o, n ) ), + i && ( o = ge( o, i ) ), + r && ( o = ge( o, r ) ), + o + ); + } + function pe( e ) { + return ve( e ) + ? { ...be( e, fe ) } + : ( function ( e ) { + const t = { ...e }; + for ( const e in t ) { + const n = t[ e ]; + he( e, n ) && ( t[ e ] = ye( n ) ); + } + return t; + } )( e ); + } + function ge( e, t ) { + return ve( t ) + ? be( t, e ) + : ( function ( e, t ) { + if ( ! t ) return e; + for ( const n in t ) { + const i = t[ n ]; + switch ( n ) { + case 'style': + e[ n ] = ce( e.style, i ); + break; + case 'className': + e[ n ] = Ce( e.className, i ); + break; + default: + he( n, i ) ? ( e[ n ] = we( e[ n ], i ) ) : ( e[ n ] = i ); + } + } + return e; + } )( e, t ); + } + function he( e, t ) { + const n = e.charCodeAt( 0 ), + i = e.charCodeAt( 1 ), + r = e.charCodeAt( 2 ); + return ( + 111 === n && + 110 === i && + r >= 65 && + r <= 90 && + ( 'function' == typeof t || void 0 === t ) + ); + } + function ve( e ) { + return 'function' == typeof e; + } + function be( e, t ) { + return ve( e ) ? e( t ) : e ?? fe; + } + function we( e, t ) { + return t + ? e + ? ( ...n ) => { + const i = n[ 0 ]; + if ( Se( i ) ) { + const r = i; + xe( r ); + const o = t( ...n ); + return r.baseUIHandlerPrevented || e?.( ...n ), o; + } + const r = t( ...n ); + return e?.( ...n ), r; + } + : ye( t ) + : e; + } + function ye( e ) { + return e + ? ( ...t ) => { + const n = t[ 0 ]; + return Se( n ) && xe( n ), e( ...t ); + } + : e; + } + function xe( e ) { + return ( + ( e.preventBaseUIHandler = () => { + e.baseUIHandlerPrevented = ! 0; + } ), + e + ); + } + function Ce( e, t ) { + return t ? ( e ? t + ' ' + e : t ) : e; + } + function Se( e ) { + return null != e && 'object' == typeof e && 'nativeEvent' in e; + } + function _e( e, t, n = {} ) { + const i = t.render, + r = ( function ( e, t = {} ) { + const { className: n, style: i, render: r } = e, + { + state: o = de, + ref: s, + props: a, + stateAttributesMapping: l, + enabled: c = ! 0, + } = t, + u = c + ? ( function ( e, t ) { + return 'function' == typeof e ? e( t ) : e; + } )( n, o ) + : void 0, + d = c + ? ( function ( e, t ) { + return 'function' == typeof e ? e( t ) : e; + } )( i, o ) + : void 0, + f = c + ? ( function ( e, t ) { + const n = {}; + for ( const i in e ) { + const r = e[ i ]; + if ( t?.hasOwnProperty( i ) ) { + const e = t[ i ]( r ); + null != e && Object.assign( n, e ); + continue; + } + ! 0 === r + ? ( n[ `data-${ i.toLowerCase() }` ] = '' ) + : r && + ( n[ `data-${ i.toLowerCase() }` ] = + r.toString() ); + } + return n; + } )( o, l ) + : de, + m = + c && a + ? ( function ( e ) { + return Array.isArray( e ) + ? ( function ( e ) { + if ( 0 === e.length ) return fe; + if ( 1 === e.length ) return pe( e[ 0 ] ); + let t = pe( e[ 0 ] ); + for ( let n = 1; n < e.length; n += 1 ) + t = ge( t, e[ n ] ); + return t; + } )( e ) + : me( void 0, e ); + } )( a ) + : void 0, + p = c ? ce( f, m ) ?? {} : de; + return ( + 'undefined' != typeof document && + ( c + ? Array.isArray( s ) + ? ( p.ref = ( function ( e ) { + const t = ne( re ).current; + return ( + ( function ( e, t ) { + return ( + e.refs.length !== t.length || + e.refs.some( ( e, n ) => e !== t[ n ] ) + ); + } )( t, e ) && oe( t, e ), + t.callback + ); + } )( [ p.ref, le( r ), ...s ] ) ) + : ( p.ref = ie( p.ref, le( r ), s ) ) + : ie( null, null ) ), + c + ? ( void 0 !== u && ( p.className = Ce( p.className, u ) ), + void 0 !== d && ( p.style = ce( p.style, d ) ), + p ) + : de + ); + } )( t, n ); + return ! 1 === n.enabled + ? null + : ( function ( e, t, n, i ) { + if ( t ) { + if ( 'function' == typeof t ) return t( n, i ); + const e = me( n, t.props ); + e.ref = n.ref; + let r = t; + return ( + r?.$$typeof === je && ( r = J.Children.toArray( t )[ 0 ] ), + J.cloneElement( r, e ) + ); + } + if ( e && 'string' == typeof e ) + return ( function ( e, t ) { + return 'button' === e + ? ( 0, J.createElement )( 'button', { + type: 'button', + ...t, + key: t.key, + } ) + : 'img' === e + ? ( 0, J.createElement )( 'img', { + alt: '', + ...t, + key: t.key, + } ) + : J.createElement( e, t ); + } )( e, n ); + throw new Error( Q( 8 ) ); + } )( e, i, r, n.state ?? de ); + } + const je = Symbol.for( 'react.lazy' ); + function Ee( e ) { + return _e( e.defaultTagName ?? 'div', e, e ); + } + var ke = 'data-wp-hash'; + function Ie() { + const e = globalThis; + return ( + e.__wpStyleRuntime || + ( ( e.__wpStyleRuntime = { + documents: new Map(), + styles: new Map(), + injectedStyles: new WeakMap(), + } ), + 'undefined' != typeof document && + ( function ( e ) { + const t = Ie(); + t.documents.set( e, ( t.documents.get( e ) ?? 0 ) + 1 ); + for ( const [ n, i ] of t.styles ) Ve( e, n, i ); + } )( document ) ), + e.__wpStyleRuntime + ); + } + function Ve( e, t, n ) { + if ( ! e.head ) return; + const i = Ie(); + let r = i.injectedStyles.get( e ); + if ( ( r || ( ( r = new Set() ), i.injectedStyles.set( e, r ) ), r.has( t ) ) ) + return; + if ( + ( function ( e, t ) { + if ( ! e.head ) return ! 1; + for ( const n of e.head.querySelectorAll( `style[${ ke }]` ) ) + if ( n.getAttribute( ke ) === t ) return ! 0; + return ! 1; + } )( e, t ) + ) + return void r.add( t ); + const o = e.createElement( 'style' ); + o.setAttribute( ke, t ), + o.appendChild( e.createTextNode( n ) ), + e.head.appendChild( o ), + r.add( t ); + } + ! ( function ( e, t ) { + const n = Ie(); + n.styles.set( e, t ); + for ( const i of n.documents.keys() ) Ve( i, e, t ); + } )( + 'b51ff41489', + '@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._19ce0419607e1896__stack{display:flex}}' + ); + var Oe = { + xs: 'var(--wpds-dimension-gap-xs, 4px)', + sm: 'var(--wpds-dimension-gap-sm, 8px)', + md: 'var(--wpds-dimension-gap-md, 12px)', + lg: 'var(--wpds-dimension-gap-lg, 16px)', + xl: 'var(--wpds-dimension-gap-xl, 24px)', + '2xl': 'var(--wpds-dimension-gap-2xl, 32px)', + '3xl': 'var(--wpds-dimension-gap-3xl, 40px)', + }, + Pe = ( 0, e.forwardRef )( function ( + { direction: e, gap: t, align: n, justify: i, wrap: r, render: o, ...s }, + a + ) { + return Ee( { + render: o, + ref: a, + props: me( s, { + style: { + gap: t && Oe[ t ], + alignItems: n, + justifyContent: i, + flexDirection: e, + flexWrap: r, + }, + className: '_19ce0419607e1896__stack', + } ), + } ); + } ); + function Me( e ) { + var t, + n, + i = ''; + if ( 'string' == typeof e || 'number' == typeof e ) i += e; + else if ( 'object' == typeof e ) + if ( Array.isArray( e ) ) { + var r = e.length; + for ( t = 0; t < r; t++ ) + e[ t ] && ( n = Me( e[ t ] ) ) && ( i && ( i += ' ' ), ( i += n ) ); + } else for ( n in e ) e[ n ] && ( i && ( i += ' ' ), ( i += n ) ); + return i; + } + const Te = function () { + for ( var e, t, n = 0, i = '', r = arguments.length; n < r; n++ ) + ( e = arguments[ n ] ) && ( t = Me( e ) ) && ( i && ( i += ' ' ), ( i += t ) ); + return i; + }; + var Ne = { + [ v ]: [ + { value: 'days', label: ( 0, n.__ )( 'Days' ) }, + { value: 'weeks', label: ( 0, n.__ )( 'Weeks' ) }, + { value: 'months', label: ( 0, n.__ )( 'Months' ) }, + { value: 'years', label: ( 0, n.__ )( 'Years' ) }, + ], + [ b ]: [ + { value: 'days', label: ( 0, n.__ )( 'Days ago' ) }, + { value: 'weeks', label: ( 0, n.__ )( 'Weeks ago' ) }, + { value: 'months', label: ( 0, n.__ )( 'Months ago' ) }, + { value: 'years', label: ( 0, n.__ )( 'Years ago' ) }, + ], + }; + function Ae( { + className: i, + data: r, + field: o, + onChange: s, + hideLabelFromVision: a, + operator: l, + } ) { + const u = Ne[ l === v ? 'inThePast' : 'over' ], + { id: d, label: f, description: m, getValue: p, setValue: g } = o, + h = o.isDisabled( { item: r, field: o } ), + b = p( { item: r } ), + { value: w = '', unit: y = u[ 0 ].value } = b && 'object' == typeof b ? b : {}, + x = ( 0, e.useCallback )( + e => s( g( { item: r, value: { value: Number( e ), unit: y } } ) ), + [ s, g, r, y ] + ), + C = ( 0, e.useCallback )( + e => s( g( { item: r, value: { value: w, unit: e } } ) ), + [ s, g, r, w ] + ); + return ( 0, c.jsx )( t.BaseControl, { + id: d, + className: Te( i, 'dataviews-controls__relative-date' ), + label: f, + hideLabelFromVision: a, + help: m, + children: ( 0, c.jsxs )( Pe, { + direction: 'row', + gap: 'sm', + children: [ + ( 0, c.jsx )( t.__experimentalNumberControl, { + __next40pxDefaultSize: ! 0, + className: 'dataviews-controls__relative-date-number', + spinControls: 'none', + min: 1, + step: 1, + value: w, + onChange: x, + disabled: h, + } ), + ( 0, c.jsx )( t.SelectControl, { + className: 'dataviews-controls__relative-date-unit', + __next40pxDefaultSize: ! 0, + label: ( 0, n.__ )( 'Unit' ), + value: y, + options: u, + onChange: C, + hideLabelFromVision: ! 0, + disabled: h, + } ), + ], + } ), + } ); + } + function Re( t, n ) { + const i = 'string' == typeof t.min?.constraint ? t.min.constraint : void 0, + r = 'string' == typeof t.max?.constraint ? t.max.constraint : void 0, + o = ( 0, e.useMemo )( () => { + const e = []; + if ( i ) { + const t = n( i ); + t && e.push( { before: t } ); + } + if ( r ) { + const t = n( r ); + t && e.push( { after: t } ); + } + return e.length > 0 ? e : void 0; + }, [ i, r, n ] ); + return { minConstraint: i, maxConstraint: r, disabledMatchers: o }; + } + Math.pow( 10, 8 ); + const Fe = 6048e5, + Le = Symbol.for( 'constructDateFrom' ); + function De( e, t ) { + return 'function' == typeof e + ? e( t ) + : e && 'object' == typeof e && Le in e + ? e[ Le ]( t ) + : e instanceof Date + ? new e.constructor( t ) + : new Date( t ); + } + function Be( e, t ) { + return De( t || e, e ); + } + function ze( e ) { + return ! ( + ( ! ( + ( t = e ) instanceof Date || + ( 'object' == typeof t && + '[object Date]' === Object.prototype.toString.call( t ) ) + ) && + 'number' != typeof e ) || + isNaN( +Be( e ) ) + ); + var t; + } + function We( e ) { + if ( ! e ) return null; + const t = ( 0, X.getDate )( e ); + return t && ze( t ) ? t : null; + } + var { DateCalendar: $e, ValidatedInputControl: He } = $( t.privateApis ), + qe = e => ( e ? ( 0, X.dateI18n )( 'Y-m-d\\TH:i', ( 0, X.getDate )( e ) ) : '' ); + function Ge( { + data: i, + field: r, + onChange: o, + hideLabelFromVision: s, + markWhenOptional: a, + validity: l, + config: u, + } ) { + const { compact: d } = u || {}, + { id: f, label: m, description: p, setValue: g, getValue: h, isValid: v } = r, + b = r.isDisabled( { item: i, field: r } ), + w = h( { item: i } ), + y = 'string' == typeof w ? w : void 0, + [ x, C ] = ( 0, e.useState )( () => We( y ) || new Date() ), + S = ( 0, e.useRef )( null ), + _ = ( 0, e.useRef )( void 0 ), + j = ( 0, e.useRef )( null ), + { minConstraint: E, maxConstraint: k, disabledMatchers: I } = Re( v, We ), + V = ( 0, e.useCallback )( e => o( g( { item: i, value: e } ) ), [ i, o, g ] ); + ( 0, e.useEffect )( + () => () => { + _.current && clearTimeout( _.current ); + }, + [] + ); + const O = ( 0, e.useCallback )( + e => { + let t; + if ( e ) { + const n = ( 0, X.dateI18n )( 'Y-m-d', e ); + let i; + i = y + ? ( 0, X.dateI18n )( 'H:i', ( 0, X.getDate )( y ) ) + : ( 0, X.dateI18n )( 'H:i', e ); + const r = ( 0, X.getDate )( `${ n }T${ i }` ); + ( t = r.toISOString() ), + V( t ), + _.current && clearTimeout( _.current ); + } else V( void 0 ); + ( j.current = S.current && S.current.ownerDocument.activeElement ), + ( _.current = setTimeout( () => { + S.current && + ( S.current.focus(), + S.current.blur(), + V( t ), + j.current && + j.current instanceof HTMLElement && + j.current.focus() ); + }, 0 ) ); + }, + [ V, y ] + ), + P = ( 0, e.useCallback )( + e => { + if ( e ) { + const t = ( 0, X.getDate )( e ); + V( t.toISOString() ); + const n = We( t.toISOString() ); + n && C( n ); + } else V( void 0 ); + }, + [ V ] + ), + { format: M } = r, + T = M.weekStartsOn ?? ( 0, X.getSettings )().l10n.startOfWeek, + { + timezone: { string: N }, + } = ( 0, X.getSettings )(); + let A = m; + return ( + ! v?.required || a || s + ? v?.required || + ! a || + s || + ( A = `${ m } (${ ( 0, n.__ )( 'Optional' ) })` ) + : ( A = `${ m } (${ ( 0, n.__ )( 'Required' ) })` ), + ( 0, c.jsx )( t.BaseControl, { + id: f, + label: A, + help: p, + hideLabelFromVision: s, + children: ( 0, c.jsxs )( Pe, { + direction: 'column', + gap: 'lg', + children: [ + ( 0, c.jsx )( He, { + ref: S, + __next40pxDefaultSize: ! 0, + required: !! v?.required, + customValidity: H( v, l ), + type: 'datetime-local', + label: ( 0, n.__ )( 'Date time' ), + hideLabelFromVision: ! 0, + value: qe( y ), + onChange: P, + disabled: b, + min: E ? qe( E ) : void 0, + max: k ? qe( k ) : void 0, + } ), + ! d && + ( 0, c.jsx )( $e, { + style: { width: '100%' }, + selected: ( y && We( y ) ) || void 0, + onSelect: O, + month: x, + onMonthChange: C, + timeZone: N || void 0, + weekStartsOn: T, + disabled: b || I, + } ), + ], + } ), + } ) + ); + } + function Ye( e, t, n ) { + const i = Be( e, n?.in ); + return isNaN( t ) + ? De( n?.in || e, NaN ) + : t + ? ( i.setDate( i.getDate() + t ), i ) + : i; + } + function Ke( e, t, n ) { + return Ye( e, -t, n ); + } + function Ue( e, t, n ) { + const i = Be( e, n?.in ); + if ( isNaN( t ) ) return De( n?.in || e, NaN ); + if ( ! t ) return i; + const r = i.getDate(), + o = De( n?.in || e, i.getTime() ); + return ( + o.setMonth( i.getMonth() + t + 1, 0 ), + r >= o.getDate() ? o : ( i.setFullYear( o.getFullYear(), o.getMonth(), r ), i ) + ); + } + function Xe( e, t, n ) { + return Ue( e, -t, n ); + } + function Ze( e, t ) { + const n = Be( e, t?.in ); + return n.setDate( 1 ), n.setHours( 0, 0, 0, 0 ), n; + } + function Qe( e, t, n ) { + return ( function ( e, t, n ) { + return Ue( e, 12 * t, n ); + } )( e, -t, n ); + } + function Je( e, t ) { + const n = Be( e, t?.in ); + return n.setFullYear( n.getFullYear(), 0, 1 ), n.setHours( 0, 0, 0, 0 ), n; + } + const et = { + lessThanXSeconds: { + one: 'less than a second', + other: 'less than {{count}} seconds', + }, + xSeconds: { one: '1 second', other: '{{count}} seconds' }, + halfAMinute: 'half a minute', + lessThanXMinutes: { + one: 'less than a minute', + other: 'less than {{count}} minutes', + }, + xMinutes: { one: '1 minute', other: '{{count}} minutes' }, + aboutXHours: { one: 'about 1 hour', other: 'about {{count}} hours' }, + xHours: { one: '1 hour', other: '{{count}} hours' }, + xDays: { one: '1 day', other: '{{count}} days' }, + aboutXWeeks: { one: 'about 1 week', other: 'about {{count}} weeks' }, + xWeeks: { one: '1 week', other: '{{count}} weeks' }, + aboutXMonths: { one: 'about 1 month', other: 'about {{count}} months' }, + xMonths: { one: '1 month', other: '{{count}} months' }, + aboutXYears: { one: 'about 1 year', other: 'about {{count}} years' }, + xYears: { one: '1 year', other: '{{count}} years' }, + overXYears: { one: 'over 1 year', other: 'over {{count}} years' }, + almostXYears: { one: 'almost 1 year', other: 'almost {{count}} years' }, + }; + function tt( e ) { + return ( t = {} ) => { + const n = t.width ? String( t.width ) : e.defaultWidth; + return e.formats[ n ] || e.formats[ e.defaultWidth ]; + }; + } + const nt = { + date: tt( { + formats: { + full: 'EEEE, MMMM do, y', + long: 'MMMM do, y', + medium: 'MMM d, y', + short: 'MM/dd/yyyy', + }, + defaultWidth: 'full', + } ), + time: tt( { + formats: { + full: 'h:mm:ss a zzzz', + long: 'h:mm:ss a z', + medium: 'h:mm:ss a', + short: 'h:mm a', + }, + defaultWidth: 'full', + } ), + dateTime: tt( { + formats: { + full: "{{date}} 'at' {{time}}", + long: "{{date}} 'at' {{time}}", + medium: '{{date}}, {{time}}', + short: '{{date}}, {{time}}', + }, + defaultWidth: 'full', + } ), + }, + it = { + lastWeek: "'last' eeee 'at' p", + yesterday: "'yesterday at' p", + today: "'today at' p", + tomorrow: "'tomorrow at' p", + nextWeek: "eeee 'at' p", + other: 'P', + }; + function rt( e ) { + return ( t, n ) => { + let i; + if ( + 'formatting' === ( n?.context ? String( n.context ) : 'standalone' ) && + e.formattingValues + ) { + const t = e.defaultFormattingWidth || e.defaultWidth, + r = n?.width ? String( n.width ) : t; + i = e.formattingValues[ r ] || e.formattingValues[ t ]; + } else { + const t = e.defaultWidth, + r = n?.width ? String( n.width ) : e.defaultWidth; + i = e.values[ r ] || e.values[ t ]; + } + return i[ e.argumentCallback ? e.argumentCallback( t ) : t ]; + }; + } + const ot = { + ordinalNumber: ( e, t ) => { + const n = Number( e ), + i = n % 100; + if ( i > 20 || i < 10 ) + switch ( i % 10 ) { + case 1: + return n + 'st'; + case 2: + return n + 'nd'; + case 3: + return n + 'rd'; + } + return n + 'th'; + }, + era: rt( { + values: { + narrow: [ 'B', 'A' ], + abbreviated: [ 'BC', 'AD' ], + wide: [ 'Before Christ', 'Anno Domini' ], + }, + defaultWidth: 'wide', + } ), + quarter: rt( { + values: { + narrow: [ '1', '2', '3', '4' ], + abbreviated: [ 'Q1', 'Q2', 'Q3', 'Q4' ], + wide: [ '1st quarter', '2nd quarter', '3rd quarter', '4th quarter' ], + }, + defaultWidth: 'wide', + argumentCallback: e => e - 1, + } ), + month: rt( { + values: { + narrow: [ 'J', 'F', 'M', 'A', 'M', 'J', 'J', 'A', 'S', 'O', 'N', 'D' ], + abbreviated: [ + 'Jan', + 'Feb', + 'Mar', + 'Apr', + 'May', + 'Jun', + 'Jul', + 'Aug', + 'Sep', + 'Oct', + 'Nov', + 'Dec', + ], + wide: [ + 'January', + 'February', + 'March', + 'April', + 'May', + 'June', + 'July', + 'August', + 'September', + 'October', + 'November', + 'December', + ], + }, + defaultWidth: 'wide', + } ), + day: rt( { + values: { + narrow: [ 'S', 'M', 'T', 'W', 'T', 'F', 'S' ], + short: [ 'Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa' ], + abbreviated: [ 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat' ], + wide: [ + 'Sunday', + 'Monday', + 'Tuesday', + 'Wednesday', + 'Thursday', + 'Friday', + 'Saturday', + ], + }, + defaultWidth: 'wide', + } ), + dayPeriod: rt( { + values: { + narrow: { + am: 'a', + pm: 'p', + midnight: 'mi', + noon: 'n', + morning: 'morning', + afternoon: 'afternoon', + evening: 'evening', + night: 'night', + }, + abbreviated: { + am: 'AM', + pm: 'PM', + midnight: 'midnight', + noon: 'noon', + morning: 'morning', + afternoon: 'afternoon', + evening: 'evening', + night: 'night', + }, + wide: { + am: 'a.m.', + pm: 'p.m.', + midnight: 'midnight', + noon: 'noon', + morning: 'morning', + afternoon: 'afternoon', + evening: 'evening', + night: 'night', + }, + }, + defaultWidth: 'wide', + formattingValues: { + narrow: { + am: 'a', + pm: 'p', + midnight: 'mi', + noon: 'n', + morning: 'in the morning', + afternoon: 'in the afternoon', + evening: 'in the evening', + night: 'at night', + }, + abbreviated: { + am: 'AM', + pm: 'PM', + midnight: 'midnight', + noon: 'noon', + morning: 'in the morning', + afternoon: 'in the afternoon', + evening: 'in the evening', + night: 'at night', + }, + wide: { + am: 'a.m.', + pm: 'p.m.', + midnight: 'midnight', + noon: 'noon', + morning: 'in the morning', + afternoon: 'in the afternoon', + evening: 'in the evening', + night: 'at night', + }, + }, + defaultFormattingWidth: 'wide', + } ), + }; + function st( e ) { + return ( t, n = {} ) => { + const i = n.width, + r = ( i && e.matchPatterns[ i ] ) || e.matchPatterns[ e.defaultMatchWidth ], + o = t.match( r ); + if ( ! o ) return null; + const s = o[ 0 ], + a = ( i && e.parsePatterns[ i ] ) || e.parsePatterns[ e.defaultParseWidth ], + l = Array.isArray( a ) + ? ( function ( e, t ) { + for ( let n = 0; n < e.length; n++ ) + if ( t( e[ n ] ) ) return n; + } )( a, e => e.test( s ) ) + : ( function ( e, t ) { + for ( const n in e ) + if ( + Object.prototype.hasOwnProperty.call( e, n ) && + t( e[ n ] ) + ) + return n; + } )( a, e => e.test( s ) ); + let c; + return ( + ( c = e.valueCallback ? e.valueCallback( l ) : l ), + ( c = n.valueCallback ? n.valueCallback( c ) : c ), + { value: c, rest: t.slice( s.length ) } + ); + }; + } + const at = { + ordinalNumber: + ( ( lt = { + matchPattern: /^(\d+)(th|st|nd|rd)?/i, + parsePattern: /\d+/i, + valueCallback: e => parseInt( e, 10 ), + } ), + ( e, t = {} ) => { + const n = e.match( lt.matchPattern ); + if ( ! n ) return null; + const i = n[ 0 ], + r = e.match( lt.parsePattern ); + if ( ! r ) return null; + let o = lt.valueCallback ? lt.valueCallback( r[ 0 ] ) : r[ 0 ]; + return ( + ( o = t.valueCallback ? t.valueCallback( o ) : o ), + { value: o, rest: e.slice( i.length ) } + ); + } ), + era: st( { + matchPatterns: { + narrow: /^(b|a)/i, + abbreviated: /^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i, + wide: /^(before christ|before common era|anno domini|common era)/i, + }, + defaultMatchWidth: 'wide', + parsePatterns: { any: [ /^b/i, /^(a|c)/i ] }, + defaultParseWidth: 'any', + } ), + quarter: st( { + matchPatterns: { + narrow: /^[1234]/i, + abbreviated: /^q[1234]/i, + wide: /^[1234](th|st|nd|rd)? quarter/i, + }, + defaultMatchWidth: 'wide', + parsePatterns: { any: [ /1/i, /2/i, /3/i, /4/i ] }, + defaultParseWidth: 'any', + valueCallback: e => e + 1, + } ), + month: st( { + matchPatterns: { + narrow: /^[jfmasond]/i, + abbreviated: /^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i, + wide: /^(january|february|march|april|may|june|july|august|september|october|november|december)/i, + }, + defaultMatchWidth: 'wide', + parsePatterns: { + narrow: [ + /^j/i, + /^f/i, + /^m/i, + /^a/i, + /^m/i, + /^j/i, + /^j/i, + /^a/i, + /^s/i, + /^o/i, + /^n/i, + /^d/i, + ], + any: [ + /^ja/i, + /^f/i, + /^mar/i, + /^ap/i, + /^may/i, + /^jun/i, + /^jul/i, + /^au/i, + /^s/i, + /^o/i, + /^n/i, + /^d/i, + ], + }, + defaultParseWidth: 'any', + } ), + day: st( { + matchPatterns: { + narrow: /^[smtwf]/i, + short: /^(su|mo|tu|we|th|fr|sa)/i, + abbreviated: /^(sun|mon|tue|wed|thu|fri|sat)/i, + wide: /^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i, + }, + defaultMatchWidth: 'wide', + parsePatterns: { + narrow: [ /^s/i, /^m/i, /^t/i, /^w/i, /^t/i, /^f/i, /^s/i ], + any: [ /^su/i, /^m/i, /^tu/i, /^w/i, /^th/i, /^f/i, /^sa/i ], + }, + defaultParseWidth: 'any', + } ), + dayPeriod: st( { + matchPatterns: { + narrow: /^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i, + any: /^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i, + }, + defaultMatchWidth: 'any', + parsePatterns: { + any: { + am: /^a/i, + pm: /^p/i, + midnight: /^mi/i, + noon: /^no/i, + morning: /morning/i, + afternoon: /afternoon/i, + evening: /evening/i, + night: /night/i, + }, + }, + defaultParseWidth: 'any', + } ), + }; + var lt; + const ct = { + code: 'en-US', + formatDistance: ( e, t, n ) => { + let i; + const r = et[ e ]; + return ( + ( i = + 'string' == typeof r + ? r + : 1 === t + ? r.one + : r.other.replace( '{{count}}', t.toString() ) ), + n?.addSuffix + ? n.comparison && n.comparison > 0 + ? 'in ' + i + : i + ' ago' + : i + ); + }, + formatLong: nt, + formatRelative: ( e, t, n, i ) => it[ e ], + localize: ot, + match: at, + options: { weekStartsOn: 0, firstWeekContainsDate: 1 }, + }; + let ut = {}; + function dt() { + return ut; + } + function ft( e ) { + const t = Be( e ), + n = new Date( + Date.UTC( + t.getFullYear(), + t.getMonth(), + t.getDate(), + t.getHours(), + t.getMinutes(), + t.getSeconds(), + t.getMilliseconds() + ) + ); + return n.setUTCFullYear( t.getFullYear() ), +e - +n; + } + function mt( e, t ) { + const n = Be( e, t?.in ); + return n.setHours( 0, 0, 0, 0 ), n; + } + function pt( e, t ) { + const n = Be( e, t?.in ); + return ( + ( function ( e, t, n ) { + const [ i, r ] = ( function ( e, ...t ) { + const n = De.bind( null, e || t.find( e => 'object' == typeof e ) ); + return t.map( n ); + } )( n?.in, e, t ), + o = mt( i ), + s = mt( r ), + a = +o - ft( o ), + l = +s - ft( s ); + return Math.round( ( a - l ) / 864e5 ); + } )( n, Je( n ) ) + 1 + ); + } + function gt( e, t ) { + const n = dt(), + i = + t?.weekStartsOn ?? + t?.locale?.options?.weekStartsOn ?? + n.weekStartsOn ?? + n.locale?.options?.weekStartsOn ?? + 0, + r = Be( e, t?.in ), + o = r.getDay(), + s = ( o < i ? 7 : 0 ) + o - i; + return r.setDate( r.getDate() - s ), r.setHours( 0, 0, 0, 0 ), r; + } + function ht( e, t ) { + return gt( e, { ...t, weekStartsOn: 1 } ); + } + function vt( e, t ) { + const n = Be( e, t?.in ), + i = n.getFullYear(), + r = De( n, 0 ); + r.setFullYear( i + 1, 0, 4 ), r.setHours( 0, 0, 0, 0 ); + const o = ht( r ), + s = De( n, 0 ); + s.setFullYear( i, 0, 4 ), s.setHours( 0, 0, 0, 0 ); + const a = ht( s ); + return n.getTime() >= o.getTime() ? i + 1 : n.getTime() >= a.getTime() ? i : i - 1; + } + function bt( e, t ) { + const n = Be( e, t?.in ), + i = + +ht( n ) - + +( function ( e, t ) { + const n = vt( e, t ), + i = De( t?.in || e, 0 ); + return i.setFullYear( n, 0, 4 ), i.setHours( 0, 0, 0, 0 ), ht( i ); + } )( n ); + return Math.round( i / Fe ) + 1; + } + function wt( e, t ) { + const n = Be( e, t?.in ), + i = n.getFullYear(), + r = dt(), + o = + t?.firstWeekContainsDate ?? + t?.locale?.options?.firstWeekContainsDate ?? + r.firstWeekContainsDate ?? + r.locale?.options?.firstWeekContainsDate ?? + 1, + s = De( t?.in || e, 0 ); + s.setFullYear( i + 1, 0, o ), s.setHours( 0, 0, 0, 0 ); + const a = gt( s, t ), + l = De( t?.in || e, 0 ); + l.setFullYear( i, 0, o ), l.setHours( 0, 0, 0, 0 ); + const c = gt( l, t ); + return +n >= +a ? i + 1 : +n >= +c ? i : i - 1; + } + function yt( e, t ) { + const n = Be( e, t?.in ), + i = + +gt( n, t ) - + +( function ( e, t ) { + const n = dt(), + i = + t?.firstWeekContainsDate ?? + t?.locale?.options?.firstWeekContainsDate ?? + n.firstWeekContainsDate ?? + n.locale?.options?.firstWeekContainsDate ?? + 1, + r = wt( e, t ), + o = De( t?.in || e, 0 ); + return o.setFullYear( r, 0, i ), o.setHours( 0, 0, 0, 0 ), gt( o, t ); + } )( n, t ); + return Math.round( i / Fe ) + 1; + } + function xt( e, t ) { + return ( e < 0 ? '-' : '' ) + Math.abs( e ).toString().padStart( t, '0' ); + } + const Ct = { + y( e, t ) { + const n = e.getFullYear(), + i = n > 0 ? n : 1 - n; + return xt( 'yy' === t ? i % 100 : i, t.length ); + }, + M( e, t ) { + const n = e.getMonth(); + return 'M' === t ? String( n + 1 ) : xt( n + 1, 2 ); + }, + d: ( e, t ) => xt( e.getDate(), t.length ), + a( e, t ) { + const n = e.getHours() / 12 >= 1 ? 'pm' : 'am'; + switch ( t ) { + case 'a': + case 'aa': + return n.toUpperCase(); + case 'aaa': + return n; + case 'aaaaa': + return n[ 0 ]; + default: + return 'am' === n ? 'a.m.' : 'p.m.'; + } + }, + h: ( e, t ) => xt( e.getHours() % 12 || 12, t.length ), + H: ( e, t ) => xt( e.getHours(), t.length ), + m: ( e, t ) => xt( e.getMinutes(), t.length ), + s: ( e, t ) => xt( e.getSeconds(), t.length ), + S( e, t ) { + const n = t.length, + i = e.getMilliseconds(); + return xt( Math.trunc( i * Math.pow( 10, n - 3 ) ), t.length ); + }, + }, + St = { + G: function ( e, t, n ) { + const i = e.getFullYear() > 0 ? 1 : 0; + switch ( t ) { + case 'G': + case 'GG': + case 'GGG': + return n.era( i, { width: 'abbreviated' } ); + case 'GGGGG': + return n.era( i, { width: 'narrow' } ); + default: + return n.era( i, { width: 'wide' } ); + } + }, + y: function ( e, t, n ) { + if ( 'yo' === t ) { + const t = e.getFullYear(), + i = t > 0 ? t : 1 - t; + return n.ordinalNumber( i, { unit: 'year' } ); + } + return Ct.y( e, t ); + }, + Y: function ( e, t, n, i ) { + const r = wt( e, i ), + o = r > 0 ? r : 1 - r; + return 'YY' === t + ? xt( o % 100, 2 ) + : 'Yo' === t + ? n.ordinalNumber( o, { unit: 'year' } ) + : xt( o, t.length ); + }, + R: function ( e, t ) { + return xt( vt( e ), t.length ); + }, + u: function ( e, t ) { + return xt( e.getFullYear(), t.length ); + }, + Q: function ( e, t, n ) { + const i = Math.ceil( ( e.getMonth() + 1 ) / 3 ); + switch ( t ) { + case 'Q': + return String( i ); + case 'QQ': + return xt( i, 2 ); + case 'Qo': + return n.ordinalNumber( i, { unit: 'quarter' } ); + case 'QQQ': + return n.quarter( i, { + width: 'abbreviated', + context: 'formatting', + } ); + case 'QQQQQ': + return n.quarter( i, { width: 'narrow', context: 'formatting' } ); + default: + return n.quarter( i, { width: 'wide', context: 'formatting' } ); + } + }, + q: function ( e, t, n ) { + const i = Math.ceil( ( e.getMonth() + 1 ) / 3 ); + switch ( t ) { + case 'q': + return String( i ); + case 'qq': + return xt( i, 2 ); + case 'qo': + return n.ordinalNumber( i, { unit: 'quarter' } ); + case 'qqq': + return n.quarter( i, { + width: 'abbreviated', + context: 'standalone', + } ); + case 'qqqqq': + return n.quarter( i, { width: 'narrow', context: 'standalone' } ); + default: + return n.quarter( i, { width: 'wide', context: 'standalone' } ); + } + }, + M: function ( e, t, n ) { + const i = e.getMonth(); + switch ( t ) { + case 'M': + case 'MM': + return Ct.M( e, t ); + case 'Mo': + return n.ordinalNumber( i + 1, { unit: 'month' } ); + case 'MMM': + return n.month( i, { + width: 'abbreviated', + context: 'formatting', + } ); + case 'MMMMM': + return n.month( i, { width: 'narrow', context: 'formatting' } ); + default: + return n.month( i, { width: 'wide', context: 'formatting' } ); + } + }, + L: function ( e, t, n ) { + const i = e.getMonth(); + switch ( t ) { + case 'L': + return String( i + 1 ); + case 'LL': + return xt( i + 1, 2 ); + case 'Lo': + return n.ordinalNumber( i + 1, { unit: 'month' } ); + case 'LLL': + return n.month( i, { + width: 'abbreviated', + context: 'standalone', + } ); + case 'LLLLL': + return n.month( i, { width: 'narrow', context: 'standalone' } ); + default: + return n.month( i, { width: 'wide', context: 'standalone' } ); + } + }, + w: function ( e, t, n, i ) { + const r = yt( e, i ); + return 'wo' === t + ? n.ordinalNumber( r, { unit: 'week' } ) + : xt( r, t.length ); + }, + I: function ( e, t, n ) { + const i = bt( e ); + return 'Io' === t + ? n.ordinalNumber( i, { unit: 'week' } ) + : xt( i, t.length ); + }, + d: function ( e, t, n ) { + return 'do' === t + ? n.ordinalNumber( e.getDate(), { unit: 'date' } ) + : Ct.d( e, t ); + }, + D: function ( e, t, n ) { + const i = pt( e ); + return 'Do' === t + ? n.ordinalNumber( i, { unit: 'dayOfYear' } ) + : xt( i, t.length ); + }, + E: function ( e, t, n ) { + const i = e.getDay(); + switch ( t ) { + case 'E': + case 'EE': + case 'EEE': + return n.day( i, { width: 'abbreviated', context: 'formatting' } ); + case 'EEEEE': + return n.day( i, { width: 'narrow', context: 'formatting' } ); + case 'EEEEEE': + return n.day( i, { width: 'short', context: 'formatting' } ); + default: + return n.day( i, { width: 'wide', context: 'formatting' } ); + } + }, + e: function ( e, t, n, i ) { + const r = e.getDay(), + o = ( r - i.weekStartsOn + 8 ) % 7 || 7; + switch ( t ) { + case 'e': + return String( o ); + case 'ee': + return xt( o, 2 ); + case 'eo': + return n.ordinalNumber( o, { unit: 'day' } ); + case 'eee': + return n.day( r, { width: 'abbreviated', context: 'formatting' } ); + case 'eeeee': + return n.day( r, { width: 'narrow', context: 'formatting' } ); + case 'eeeeee': + return n.day( r, { width: 'short', context: 'formatting' } ); + default: + return n.day( r, { width: 'wide', context: 'formatting' } ); + } + }, + c: function ( e, t, n, i ) { + const r = e.getDay(), + o = ( r - i.weekStartsOn + 8 ) % 7 || 7; + switch ( t ) { + case 'c': + return String( o ); + case 'cc': + return xt( o, t.length ); + case 'co': + return n.ordinalNumber( o, { unit: 'day' } ); + case 'ccc': + return n.day( r, { width: 'abbreviated', context: 'standalone' } ); + case 'ccccc': + return n.day( r, { width: 'narrow', context: 'standalone' } ); + case 'cccccc': + return n.day( r, { width: 'short', context: 'standalone' } ); + default: + return n.day( r, { width: 'wide', context: 'standalone' } ); + } + }, + i: function ( e, t, n ) { + const i = e.getDay(), + r = 0 === i ? 7 : i; + switch ( t ) { + case 'i': + return String( r ); + case 'ii': + return xt( r, t.length ); + case 'io': + return n.ordinalNumber( r, { unit: 'day' } ); + case 'iii': + return n.day( i, { width: 'abbreviated', context: 'formatting' } ); + case 'iiiii': + return n.day( i, { width: 'narrow', context: 'formatting' } ); + case 'iiiiii': + return n.day( i, { width: 'short', context: 'formatting' } ); + default: + return n.day( i, { width: 'wide', context: 'formatting' } ); + } + }, + a: function ( e, t, n ) { + const i = e.getHours() / 12 >= 1 ? 'pm' : 'am'; + switch ( t ) { + case 'a': + case 'aa': + return n.dayPeriod( i, { + width: 'abbreviated', + context: 'formatting', + } ); + case 'aaa': + return n + .dayPeriod( i, { width: 'abbreviated', context: 'formatting' } ) + .toLowerCase(); + case 'aaaaa': + return n.dayPeriod( i, { width: 'narrow', context: 'formatting' } ); + default: + return n.dayPeriod( i, { width: 'wide', context: 'formatting' } ); + } + }, + b: function ( e, t, n ) { + const i = e.getHours(); + let r; + switch ( + ( ( r = + 12 === i + ? 'noon' + : 0 === i + ? 'midnight' + : i / 12 >= 1 + ? 'pm' + : 'am' ), + t ) + ) { + case 'b': + case 'bb': + return n.dayPeriod( r, { + width: 'abbreviated', + context: 'formatting', + } ); + case 'bbb': + return n + .dayPeriod( r, { width: 'abbreviated', context: 'formatting' } ) + .toLowerCase(); + case 'bbbbb': + return n.dayPeriod( r, { width: 'narrow', context: 'formatting' } ); + default: + return n.dayPeriod( r, { width: 'wide', context: 'formatting' } ); + } + }, + B: function ( e, t, n ) { + const i = e.getHours(); + let r; + switch ( + ( ( r = + i >= 17 + ? 'evening' + : i >= 12 + ? 'afternoon' + : i >= 4 + ? 'morning' + : 'night' ), + t ) + ) { + case 'B': + case 'BB': + case 'BBB': + return n.dayPeriod( r, { + width: 'abbreviated', + context: 'formatting', + } ); + case 'BBBBB': + return n.dayPeriod( r, { width: 'narrow', context: 'formatting' } ); + default: + return n.dayPeriod( r, { width: 'wide', context: 'formatting' } ); + } + }, + h: function ( e, t, n ) { + if ( 'ho' === t ) { + let t = e.getHours() % 12; + return 0 === t && ( t = 12 ), n.ordinalNumber( t, { unit: 'hour' } ); + } + return Ct.h( e, t ); + }, + H: function ( e, t, n ) { + return 'Ho' === t + ? n.ordinalNumber( e.getHours(), { unit: 'hour' } ) + : Ct.H( e, t ); + }, + K: function ( e, t, n ) { + const i = e.getHours() % 12; + return 'Ko' === t + ? n.ordinalNumber( i, { unit: 'hour' } ) + : xt( i, t.length ); + }, + k: function ( e, t, n ) { + let i = e.getHours(); + return ( + 0 === i && ( i = 24 ), + 'ko' === t ? n.ordinalNumber( i, { unit: 'hour' } ) : xt( i, t.length ) + ); + }, + m: function ( e, t, n ) { + return 'mo' === t + ? n.ordinalNumber( e.getMinutes(), { unit: 'minute' } ) + : Ct.m( e, t ); + }, + s: function ( e, t, n ) { + return 'so' === t + ? n.ordinalNumber( e.getSeconds(), { unit: 'second' } ) + : Ct.s( e, t ); + }, + S: function ( e, t ) { + return Ct.S( e, t ); + }, + X: function ( e, t, n ) { + const i = e.getTimezoneOffset(); + if ( 0 === i ) return 'Z'; + switch ( t ) { + case 'X': + return jt( i ); + case 'XXXX': + case 'XX': + return Et( i ); + default: + return Et( i, ':' ); + } + }, + x: function ( e, t, n ) { + const i = e.getTimezoneOffset(); + switch ( t ) { + case 'x': + return jt( i ); + case 'xxxx': + case 'xx': + return Et( i ); + default: + return Et( i, ':' ); + } + }, + O: function ( e, t, n ) { + const i = e.getTimezoneOffset(); + switch ( t ) { + case 'O': + case 'OO': + case 'OOO': + return 'GMT' + _t( i, ':' ); + default: + return 'GMT' + Et( i, ':' ); + } + }, + z: function ( e, t, n ) { + const i = e.getTimezoneOffset(); + switch ( t ) { + case 'z': + case 'zz': + case 'zzz': + return 'GMT' + _t( i, ':' ); + default: + return 'GMT' + Et( i, ':' ); + } + }, + t: function ( e, t, n ) { + return xt( Math.trunc( +e / 1e3 ), t.length ); + }, + T: function ( e, t, n ) { + return xt( +e, t.length ); + }, + }; + function _t( e, t = '' ) { + const n = e > 0 ? '-' : '+', + i = Math.abs( e ), + r = Math.trunc( i / 60 ), + o = i % 60; + return 0 === o ? n + String( r ) : n + String( r ) + t + xt( o, 2 ); + } + function jt( e, t ) { + return e % 60 == 0 + ? ( e > 0 ? '-' : '+' ) + xt( Math.abs( e ) / 60, 2 ) + : Et( e, t ); + } + function Et( e, t = '' ) { + const n = e > 0 ? '-' : '+', + i = Math.abs( e ); + return n + xt( Math.trunc( i / 60 ), 2 ) + t + xt( i % 60, 2 ); + } + const kt = ( e, t ) => { + switch ( e ) { + case 'P': + return t.date( { width: 'short' } ); + case 'PP': + return t.date( { width: 'medium' } ); + case 'PPP': + return t.date( { width: 'long' } ); + default: + return t.date( { width: 'full' } ); + } + }, + It = ( e, t ) => { + switch ( e ) { + case 'p': + return t.time( { width: 'short' } ); + case 'pp': + return t.time( { width: 'medium' } ); + case 'ppp': + return t.time( { width: 'long' } ); + default: + return t.time( { width: 'full' } ); + } + }, + Vt = { + p: It, + P: ( e, t ) => { + const n = e.match( /(P+)(p+)?/ ) || [], + i = n[ 1 ], + r = n[ 2 ]; + if ( ! r ) return kt( e, t ); + let o; + switch ( i ) { + case 'P': + o = t.dateTime( { width: 'short' } ); + break; + case 'PP': + o = t.dateTime( { width: 'medium' } ); + break; + case 'PPP': + o = t.dateTime( { width: 'long' } ); + break; + default: + o = t.dateTime( { width: 'full' } ); + } + return o + .replace( '{{date}}', kt( i, t ) ) + .replace( '{{time}}', It( r, t ) ); + }, + }, + Ot = /^D+$/, + Pt = /^Y+$/, + Mt = [ 'D', 'DD', 'YY', 'YYYY' ], + Tt = /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g, + Nt = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g, + At = /^'([^]*?)'?$/, + Rt = /''/g, + Ft = /[a-zA-Z]/; + function Lt( e, t, n ) { + const i = dt(), + r = n?.locale ?? i.locale ?? ct, + o = + n?.firstWeekContainsDate ?? + n?.locale?.options?.firstWeekContainsDate ?? + i.firstWeekContainsDate ?? + i.locale?.options?.firstWeekContainsDate ?? + 1, + s = + n?.weekStartsOn ?? + n?.locale?.options?.weekStartsOn ?? + i.weekStartsOn ?? + i.locale?.options?.weekStartsOn ?? + 0, + a = Be( e, n?.in ); + if ( ! ze( a ) ) throw new RangeError( 'Invalid time value' ); + let l = t + .match( Nt ) + .map( e => { + const t = e[ 0 ]; + return 'p' === t || 'P' === t ? ( 0, Vt[ t ] )( e, r.formatLong ) : e; + } ) + .join( '' ) + .match( Tt ) + .map( e => { + if ( "''" === e ) return { isToken: ! 1, value: "'" }; + const t = e[ 0 ]; + if ( "'" === t ) return { isToken: ! 1, value: Dt( e ) }; + if ( St[ t ] ) return { isToken: ! 0, value: e }; + if ( t.match( Ft ) ) + throw new RangeError( + 'Format string contains an unescaped latin alphabet character `' + + t + + '`' + ); + return { isToken: ! 1, value: e }; + } ); + r.localize.preprocessor && ( l = r.localize.preprocessor( a, l ) ); + const c = { firstWeekContainsDate: o, weekStartsOn: s, locale: r }; + return l + .map( i => { + if ( ! i.isToken ) return i.value; + const o = i.value; + return ( + ( ( ! n?.useAdditionalWeekYearTokens && + ( function ( e ) { + return Pt.test( e ); + } )( o ) ) || + ( ! n?.useAdditionalDayOfYearTokens && + ( function ( e ) { + return Ot.test( e ); + } )( o ) ) ) && + ( function ( e, t, n ) { + const i = ( function ( e, t, n ) { + const i = 'Y' === e[ 0 ] ? 'years' : 'days of the month'; + return `Use \`${ e.toLowerCase() }\` instead of \`${ e }\` (in \`${ t }\`) for formatting ${ i } to the input \`${ n }\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`; + } )( e, t, n ); + if ( ( console.warn( i ), Mt.includes( e ) ) ) + throw new RangeError( i ); + } )( o, t, String( e ) ), + ( 0, St[ o[ 0 ] ] )( a, o, r.localize, c ) + ); + } ) + .join( '' ); + } + function Dt( e ) { + const t = e.match( At ); + return t ? t[ 1 ].replace( Rt, "'" ) : e; + } + var Bt = ( 0, c.jsx )( l.SVG, { + xmlns: 'http://www.w3.org/2000/svg', + viewBox: '0 0 24 24', + children: ( 0, c.jsx )( l.Path, { + fillRule: 'evenodd', + clipRule: 'evenodd', + d: 'M12.218 5.377a.25.25 0 0 0-.436 0l-7.29 12.96a.25.25 0 0 0 .218.373h14.58a.25.25 0 0 0 .218-.372l-7.29-12.96Zm-1.743-.735c.669-1.19 2.381-1.19 3.05 0l7.29 12.96a1.75 1.75 0 0 1-1.525 2.608H4.71a1.75 1.75 0 0 1-1.525-2.608l7.29-12.96ZM12.75 17.46h-1.5v-1.5h1.5v1.5Zm-1.5-3h1.5v-5h-1.5v5Z', + } ), + } ), + { DateCalendar: zt, DateRangeCalendar: Wt } = $( t.privateApis ), + $t = [ + { + id: 'today', + label: ( 0, n.__ )( 'Today' ), + getValue: () => ( 0, X.getDate )( null ), + }, + { + id: 'yesterday', + label: ( 0, n.__ )( 'Yesterday' ), + getValue: () => Ke( ( 0, X.getDate )( null ), 1 ), + }, + { + id: 'past-week', + label: ( 0, n.__ )( 'Past week' ), + getValue: () => Ke( ( 0, X.getDate )( null ), 7 ), + }, + { + id: 'past-month', + label: ( 0, n.__ )( 'Past month' ), + getValue: () => Xe( ( 0, X.getDate )( null ), 1 ), + }, + ], + Ht = [ + { + id: 'last-7-days', + label: ( 0, n.__ )( 'Last 7 days' ), + getValue: () => { + const e = ( 0, X.getDate )( null ); + return [ Ke( e, 7 ), e ]; + }, + }, + { + id: 'last-30-days', + label: ( 0, n.__ )( 'Last 30 days' ), + getValue: () => { + const e = ( 0, X.getDate )( null ); + return [ Ke( e, 30 ), e ]; + }, + }, + { + id: 'month-to-date', + label: ( 0, n.__ )( 'Month to date' ), + getValue: () => { + const e = ( 0, X.getDate )( null ); + return [ Ze( e ), e ]; + }, + }, + { + id: 'last-year', + label: ( 0, n.__ )( 'Last year' ), + getValue: () => { + const e = ( 0, X.getDate )( null ); + return [ Qe( e, 1 ), e ]; + }, + }, + { + id: 'year-to-date', + label: ( 0, n.__ )( 'Year to date' ), + getValue: () => { + const e = ( 0, X.getDate )( null ); + return [ Je( e ), e ]; + }, + }, + ], + qt = e => { + if ( ! e ) return null; + const t = ( 0, X.getDate )( e ); + return t && ze( t ) ? t : null; + }, + Gt = e => ( e ? ( 'string' == typeof e ? e : Lt( e, 'yyyy-MM-dd' ) ) : '' ); + function Yt( { + field: n, + validity: i, + inputRefs: r, + isTouched: o, + setIsTouched: s, + children: a, + } ) { + const { isValid: l } = n, + [ u, d ] = ( 0, e.useState )( void 0 ), + f = ( 0, e.useCallback )( () => { + const e = Array.isArray( r ) ? r : [ r ]; + for ( const t of e ) { + const e = t.current; + if ( e && ! e.validity.valid ) + return void d( { type: 'invalid', message: e.validationMessage } ); + } + d( void 0 ); + }, [ r ] ); + return ( + ( 0, e.useEffect )( () => { + const e = Array.isArray( r ) ? r : [ r ], + t = i ? H( l, i ) : void 0; + for ( const n of e ) { + const e = n.current; + e && + e.setCustomValidity( + 'invalid' === t?.type && t.message ? t.message : '' + ); + } + }, [ r, l, i ] ), + ( 0, e.useEffect )( () => { + const e = Array.isArray( r ) ? r : [ r ], + t = e => { + e.preventDefault(), s( ! 0 ); + }; + for ( const n of e ) n.current?.addEventListener( 'invalid', t ); + return () => { + for ( const n of e ) n.current?.removeEventListener( 'invalid', t ); + }; + }, [ r, s ] ), + ( 0, e.useEffect )( () => { + if ( ! o ) return; + const e = i ? H( l, i ) : void 0; + e ? d( e ) : f(); + }, [ o, l, i, f ] ), + ( 0, c.jsxs )( 'div', { + onBlur: e => { + o || + ( e.relatedTarget && + e.currentTarget.contains( e.relatedTarget ) ) || + s( ! 0 ); + }, + children: [ + a, + ( 0, c.jsx )( 'div', { + 'aria-live': 'polite', + children: + u && + ( 0, c.jsxs )( 'p', { + className: Te( + 'components-validated-control__indicator', + 'invalid' === u.type ? 'is-invalid' : void 0 + ), + children: [ + ( 0, c.jsx )( t.Icon, { + className: + 'components-validated-control__indicator-icon', + icon: Bt, + size: 16, + fill: 'currentColor', + } ), + u.message, + ], + } ), + } ), + ], + } ) + ); + } + function Kt( { + data: i, + field: r, + onChange: o, + hideLabelFromVision: s, + markWhenOptional: a, + validity: l, + } ) { + const { + id: u, + label: d, + description: f, + setValue: m, + getValue: p, + isValid: g, + format: h, + } = r, + v = r.isDisabled( { item: i, field: r } ), + [ b, w ] = ( 0, e.useState )( null ), + y = h.weekStartsOn ?? ( 0, X.getSettings )().l10n.startOfWeek, + x = p( { item: i } ), + C = 'string' == typeof x ? x : void 0, + [ S, _ ] = ( 0, e.useState )( () => qt( C ) || new Date() ), + [ j, E ] = ( 0, e.useState )( ! 1 ), + k = ( 0, e.useRef )( null ), + { minConstraint: I, maxConstraint: V, disabledMatchers: O } = Re( g, qt ), + P = ( 0, e.useCallback )( e => o( m( { item: i, value: e } ) ), [ i, o, m ] ), + M = ( 0, e.useCallback )( + e => { + const t = e ? Lt( e, 'yyyy-MM-dd' ) : void 0; + P( t ), w( null ), E( ! 0 ); + }, + [ P ] + ), + T = ( 0, e.useCallback )( + e => { + const t = e.getValue(), + n = Gt( t ); + _( t ), P( n ), w( e.id ), E( ! 0 ); + }, + [ P ] + ), + N = ( 0, e.useCallback )( + e => { + if ( ( P( e ), e ) ) { + const t = qt( e ); + t && _( t ); + } + w( null ), E( ! 0 ); + }, + [ P ] + ), + { + timezone: { string: A }, + } = ( 0, X.getSettings )(); + let R = d; + return ( + g?.required && ! a + ? ( R = `${ d } (${ ( 0, n.__ )( 'Required' ) })` ) + : ! g?.required && a && ( R = `${ d } (${ ( 0, n.__ )( 'Optional' ) })` ), + ( 0, c.jsx )( Yt, { + field: r, + validity: l, + inputRefs: k, + isTouched: j, + setIsTouched: E, + children: ( 0, c.jsx )( t.BaseControl, { + id: u, + className: 'dataviews-controls__date', + label: R, + help: f, + hideLabelFromVision: s, + children: ( 0, c.jsxs )( Pe, { + direction: 'column', + gap: 'lg', + children: [ + ( 0, c.jsxs )( Pe, { + direction: 'row', + gap: 'sm', + wrap: 'wrap', + justify: 'flex-start', + children: [ + $t.map( e => { + const n = b === e.id; + return ( 0, c.jsx )( + t.Button, + { + className: + 'dataviews-controls__date-preset', + variant: 'tertiary', + isPressed: n, + size: 'small', + disabled: v, + accessibleWhenDisabled: ! 0, + onClick: () => T( e ), + children: e.label, + }, + e.id + ); + } ), + ( 0, c.jsx )( t.Button, { + className: 'dataviews-controls__date-preset', + variant: 'tertiary', + isPressed: ! b, + size: 'small', + disabled: !! b || v, + accessibleWhenDisabled: ! 0, + children: ( 0, n.__ )( 'Custom' ), + } ), + ], + } ), + ( 0, c.jsx )( t.__experimentalInputControl, { + __next40pxDefaultSize: ! 0, + ref: k, + type: 'date', + label: ( 0, n.__ )( 'Date' ), + hideLabelFromVision: ! 0, + value: C, + onChange: N, + required: !! r.isValid?.required, + disabled: v, + min: I, + max: V, + } ), + ( 0, c.jsx )( zt, { + style: { width: '100%' }, + selected: ( C && qt( C ) ) || void 0, + onSelect: M, + month: S, + onMonthChange: _, + timeZone: A || void 0, + weekStartsOn: y, + disabled: v || O, + disableNavigation: v, + } ), + ], + } ), + } ), + } ) + ); + } + function Ut( { + data: i, + field: r, + onChange: o, + hideLabelFromVision: s, + markWhenOptional: a, + validity: l, + } ) { + const { + id: u, + label: d, + description: f, + getValue: m, + setValue: p, + isValid: g, + format: h, + } = r, + v = r.isDisabled( { item: i, field: r } ); + let b; + const w = m( { item: i } ); + Array.isArray( w ) && + 2 === w.length && + w.every( e => 'string' == typeof e ) && + ( b = w ); + const y = h.weekStartsOn ?? ( 0, X.getSettings )().l10n.startOfWeek, + { minConstraint: x, maxConstraint: C, disabledMatchers: S } = Re( g, qt ), + _ = ( 0, e.useCallback )( + e => { + o( p( { item: i, value: e } ) ); + }, + [ i, o, p ] + ), + [ j, E ] = ( 0, e.useState )( null ), + k = ( 0, e.useMemo )( () => { + if ( ! b ) return { from: void 0, to: void 0 }; + const [ e, t ] = b; + return { from: qt( e ) || void 0, to: qt( t ) || void 0 }; + }, [ b ] ), + [ I, V ] = ( 0, e.useState )( () => k.from || new Date() ), + [ O, P ] = ( 0, e.useState )( ! 1 ), + M = ( 0, e.useRef )( null ), + T = ( 0, e.useRef )( null ), + N = ( 0, e.useCallback )( + ( e, t ) => { + e && t ? _( [ Gt( e ), Gt( t ) ] ) : e || t || _( void 0 ); + }, + [ _ ] + ), + A = ( 0, e.useCallback )( + e => { + N( e?.from, e?.to ), E( null ), P( ! 0 ); + }, + [ N ] + ), + R = ( 0, e.useCallback )( + e => { + const [ t, n ] = e.getValue(); + V( t ), N( t, n ), E( e.id ), P( ! 0 ); + }, + [ N ] + ), + F = ( 0, e.useCallback )( + ( e, t ) => { + const [ n, i ] = b || [ void 0, void 0 ]; + if ( ( N( 'from' === e ? t : n, 'to' === e ? t : i ), t ) ) { + const e = qt( t ); + e && V( e ); + } + E( null ), P( ! 0 ); + }, + [ b, N ] + ), + { timezone: L } = ( 0, X.getSettings )(); + let D = d; + return ( + r.isValid?.required && ! a + ? ( D = `${ d } (${ ( 0, n.__ )( 'Required' ) })` ) + : ! r.isValid?.required && + a && + ( D = `${ d } (${ ( 0, n.__ )( 'Optional' ) })` ), + ( 0, c.jsx )( Yt, { + field: r, + validity: l, + inputRefs: [ M, T ], + isTouched: O, + setIsTouched: P, + children: ( 0, c.jsx )( t.BaseControl, { + id: u, + className: 'dataviews-controls__date', + label: D, + help: f, + hideLabelFromVision: s, + children: ( 0, c.jsxs )( Pe, { + direction: 'column', + gap: 'lg', + children: [ + ( 0, c.jsxs )( Pe, { + direction: 'row', + gap: 'sm', + wrap: 'wrap', + justify: 'flex-start', + children: [ + Ht.map( e => { + const n = j === e.id; + return ( 0, c.jsx )( + t.Button, + { + className: + 'dataviews-controls__date-preset', + variant: 'tertiary', + isPressed: n, + size: 'small', + disabled: v, + accessibleWhenDisabled: ! 0, + onClick: () => R( e ), + children: e.label, + }, + e.id + ); + } ), + ( 0, c.jsx )( t.Button, { + className: 'dataviews-controls__date-preset', + variant: 'tertiary', + isPressed: ! j, + size: 'small', + accessibleWhenDisabled: ! 0, + disabled: !! j || v, + children: ( 0, n.__ )( 'Custom' ), + } ), + ], + } ), + ( 0, c.jsxs )( Pe, { + direction: 'row', + gap: 'sm', + justify: 'space-between', + className: 'dataviews-controls__date-range-inputs', + children: [ + ( 0, c.jsx )( t.__experimentalInputControl, { + __next40pxDefaultSize: ! 0, + ref: M, + type: 'date', + label: ( 0, n.__ )( 'From' ), + hideLabelFromVision: ! 0, + value: b?.[ 0 ], + onChange: e => F( 'from', e ), + required: !! r.isValid?.required, + disabled: v, + min: x, + max: C, + } ), + ( 0, c.jsx )( t.__experimentalInputControl, { + __next40pxDefaultSize: ! 0, + ref: T, + type: 'date', + label: ( 0, n.__ )( 'To' ), + hideLabelFromVision: ! 0, + value: b?.[ 1 ], + onChange: e => F( 'to', e ), + required: !! r.isValid?.required, + disabled: v, + min: x, + max: C, + } ), + ], + } ), + ( 0, c.jsx )( Wt, { + style: { width: '100%' }, + selected: k, + onSelect: A, + month: I, + onMonthChange: V, + timeZone: L.string || void 0, + weekStartsOn: y, + disabled: v || S, + } ), + ], + } ), + } ), + } ) + ); + } + var { ValidatedSelectControl: Xt } = $( t.privateApis ); + function Zt( { + data: n, + field: i, + onChange: r, + hideLabelFromVision: o, + markWhenOptional: s, + validity: a, + } ) { + const { + type: l, + label: u, + description: d, + getValue: f, + setValue: m, + isValid: p, + } = i, + g = i.isDisabled( { item: n, field: i } ), + h = 'array' === l, + v = f( { item: n } ) ?? ( h ? [] : '' ), + b = ( 0, e.useCallback )( e => r( m( { item: n, value: e } ) ), [ n, r, m ] ), + { elements: w, isLoading: y } = Y( { + elements: i.elements, + getElements: i.getElements, + } ); + return y + ? ( 0, c.jsx )( t.Spinner, {} ) + : ( 0, c.jsx )( Xt, { + required: !! i.isValid?.required, + markWhenOptional: s, + customValidity: H( p, a ), + label: u, + value: v, + help: d, + options: w, + onChange: b, + __next40pxDefaultSize: ! 0, + hideLabelFromVision: o, + multiple: h, + disabled: g, + } ); + } + var Qt = ( 0, c.jsx )( l.SVG, { + xmlns: 'http://www.w3.org/2000/svg', + viewBox: '0 0 24 24', + children: ( 0, c.jsx )( l.Path, { + fillRule: 'evenodd', + clipRule: 'evenodd', + d: 'M3 7c0-1.1.9-2 2-2h14a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7Zm2-.5h14c.3 0 .5.2.5.5v1L12 13.5 4.5 7.9V7c0-.3.2-.5.5-.5Zm-.5 3.3V17c0 .3.2.5.5.5h14c.3 0 .5-.2.5-.5V9.8L12 15.4 4.5 9.8Z', + } ), + } ), + { ValidatedInputControl: Jt } = $( t.privateApis ); + function en( { + data: t, + field: n, + onChange: i, + hideLabelFromVision: r, + markWhenOptional: o, + type: s, + prefix: a, + suffix: l, + validity: u, + } ) { + const { + label: d, + placeholder: f, + description: m, + getValue: p, + setValue: g, + isValid: h, + } = n, + v = p( { item: t } ), + b = n.isDisabled( { item: t, field: n } ), + w = ( 0, e.useCallback )( e => i( g( { item: t, value: e } ) ), [ t, g, i ] ); + return ( 0, c.jsx )( Jt, { + required: !! h.required, + markWhenOptional: o, + customValidity: H( h, u ), + label: d, + placeholder: f, + value: v ?? '', + help: m, + onChange: w, + hideLabelFromVision: r, + type: s, + prefix: a, + suffix: l, + disabled: b, + pattern: h.pattern ? h.pattern.constraint : void 0, + minLength: h.minLength ? h.minLength.constraint : void 0, + maxLength: h.maxLength ? h.maxLength.constraint : void 0, + __next40pxDefaultSize: ! 0, + } ); + } + var tn = ( 0, c.jsx )( l.SVG, { + xmlns: 'http://www.w3.org/2000/svg', + viewBox: '0 0 24 24', + children: ( 0, c.jsx )( l.Path, { + d: 'M15 4H9c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h6c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm.5 14c0 .3-.2.5-.5.5H9c-.3 0-.5-.2-.5-.5V6c0-.3.2-.5.5-.5h6c.3 0 .5.2.5.5v12zm-4.5-.5h2V16h-2v1.5z', + } ), + } ), + nn = ( 0, c.jsx )( l.SVG, { + xmlns: 'http://www.w3.org/2000/svg', + viewBox: '0 0 24 24', + children: ( 0, c.jsx )( l.Path, { + d: 'M10 17.389H8.444A5.194 5.194 0 1 1 8.444 7H10v1.5H8.444a3.694 3.694 0 0 0 0 7.389H10v1.5ZM14 7h1.556a5.194 5.194 0 0 1 0 10.39H14v-1.5h1.556a3.694 3.694 0 0 0 0-7.39H14V7Zm-4.5 6h5v-1.5h-5V13Z', + } ), + } ), + { ValidatedNumberControl: rn } = $( t.privateApis ); + function on( e ) { + if ( '' === e || void 0 === e ) return ''; + const t = Number( e ); + return Number.isFinite( t ) ? t : ''; + } + function sn( { value: i, onChange: r, hideLabelFromVision: o, step: s } ) { + const [ a = '', l = '' ] = i, + u = ( 0, e.useCallback )( e => r( [ on( e ), l ] ), [ r, l ] ), + d = ( 0, e.useCallback )( e => r( [ a, on( e ) ] ), [ r, a ] ); + return ( 0, c.jsx )( t.BaseControl, { + help: ( 0, n.__ )( 'The max. value must be greater than the min. value.' ), + children: ( 0, c.jsxs )( t.Flex, { + direction: 'row', + gap: 4, + children: [ + ( 0, c.jsx )( t.__experimentalNumberControl, { + label: ( 0, n.__ )( 'Min.' ), + value: a, + max: l ? Number( l ) - s : void 0, + onChange: u, + __next40pxDefaultSize: ! 0, + hideLabelFromVision: o, + step: s, + } ), + ( 0, c.jsx )( t.__experimentalNumberControl, { + label: ( 0, n.__ )( 'Max.' ), + value: l, + min: a ? Number( a ) + s : void 0, + onChange: d, + __next40pxDefaultSize: ! 0, + hideLabelFromVision: o, + step: s, + } ), + ], + } ), + } ); + } + function an( { + data: t, + field: n, + onChange: i, + hideLabelFromVision: r, + markWhenOptional: o, + operator: s, + validity: a, + } ) { + const l = n.format?.decimals ?? 0, + u = Math.pow( 10, -1 * Math.abs( l ) ), + { label: d, description: f, getValue: m, setValue: p, isValid: g } = n, + v = m( { item: t } ) ?? '', + b = n.isDisabled( { item: t, field: n } ), + w = ( 0, e.useCallback )( + e => { + i( + p( { + item: t, + value: [ '', void 0 ].includes( e ) ? void 0 : Number( e ), + } ) + ); + }, + [ t, i, p ] + ), + y = ( 0, e.useCallback )( + e => { + i( p( { item: t, value: e } ) ); + }, + [ t, i, p ] + ); + if ( s === h ) { + let e = [ '', '' ]; + return ( + Array.isArray( v ) && + 2 === v.length && + v.every( e => 'number' == typeof e || '' === e ) && + ( e = v ), + ( 0, c.jsx )( sn, { + value: e, + onChange: y, + hideLabelFromVision: r, + step: u, + } ) + ); + } + return ( 0, c.jsx )( rn, { + required: !! g.required, + markWhenOptional: o, + customValidity: H( g, a ), + label: d, + help: f, + value: v, + onChange: w, + __next40pxDefaultSize: ! 0, + hideLabelFromVision: r, + step: u, + min: g.min ? g.min.constraint : void 0, + max: g.max ? g.max.constraint : void 0, + disabled: b, + } ); + } + var { ValidatedRadioControl: ln } = $( t.privateApis ), + { ValidatedToggleControl: cn } = $( t.privateApis ), + { ValidatedTextareaControl: un } = $( t.privateApis ), + { ValidatedToggleGroupControl: dn } = $( t.privateApis ), + { ValidatedFormTokenField: fn } = $( t.privateApis ), + mn = { grad: 0.9, turn: 360, rad: 360 / ( 2 * Math.PI ) }, + pn = function ( e ) { + return 'string' == typeof e ? e.length > 0 : 'number' == typeof e; + }, + gn = function ( e, t, n ) { + return ( + void 0 === t && ( t = 0 ), + void 0 === n && ( n = Math.pow( 10, t ) ), + Math.round( n * e ) / n + 0 + ); + }, + hn = function ( e, t, n ) { + return ( + void 0 === t && ( t = 0 ), + void 0 === n && ( n = 1 ), + e > n ? n : e > t ? e : t + ); + }, + vn = function ( e ) { + return ( e = isFinite( e ) ? e % 360 : 0 ) > 0 ? e : e + 360; + }, + bn = function ( e ) { + return { + r: hn( e.r, 0, 255 ), + g: hn( e.g, 0, 255 ), + b: hn( e.b, 0, 255 ), + a: hn( e.a ), + }; + }, + wn = function ( e ) { + return { r: gn( e.r ), g: gn( e.g ), b: gn( e.b ), a: gn( e.a, 3 ) }; + }, + yn = /^#([0-9a-f]{3,8})$/i, + xn = function ( e ) { + var t = e.toString( 16 ); + return t.length < 2 ? '0' + t : t; + }, + Cn = function ( e ) { + var t = e.r, + n = e.g, + i = e.b, + r = e.a, + o = Math.max( t, n, i ), + s = o - Math.min( t, n, i ), + a = s + ? o === t + ? ( n - i ) / s + : o === n + ? 2 + ( i - t ) / s + : 4 + ( t - n ) / s + : 0; + return { + h: 60 * ( a < 0 ? a + 6 : a ), + s: o ? ( s / o ) * 100 : 0, + v: ( o / 255 ) * 100, + a: r, + }; + }, + Sn = function ( e ) { + var t = e.h, + n = e.s, + i = e.v, + r = e.a; + ( t = ( t / 360 ) * 6 ), ( n /= 100 ), ( i /= 100 ); + var o = Math.floor( t ), + s = i * ( 1 - n ), + a = i * ( 1 - ( t - o ) * n ), + l = i * ( 1 - ( 1 - t + o ) * n ), + c = o % 6; + return { + r: 255 * [ i, a, s, s, l, i ][ c ], + g: 255 * [ l, i, i, a, s, s ][ c ], + b: 255 * [ s, s, l, i, i, a ][ c ], + a: r, + }; + }, + jn = function ( e ) { + return { + h: vn( e.h ), + s: hn( e.s, 0, 100 ), + l: hn( e.l, 0, 100 ), + a: hn( e.a ), + }; + }, + En = function ( e ) { + return { h: gn( e.h ), s: gn( e.s ), l: gn( e.l ), a: gn( e.a, 3 ) }; + }, + kn = function ( e ) { + return Sn( + ( ( n = ( t = e ).s ), + { + h: t.h, + s: + ( n *= ( ( i = t.l ) < 50 ? i : 100 - i ) / 100 ) > 0 + ? ( ( 2 * n ) / ( i + n ) ) * 100 + : 0, + v: i + n, + a: t.a, + } ) + ); + var t, n, i; + }, + In = function ( e ) { + return { + h: ( t = Cn( e ) ).h, + s: + ( r = ( ( 200 - ( n = t.s ) ) * ( i = t.v ) ) / 100 ) > 0 && r < 200 + ? ( ( n * i ) / 100 / ( r <= 100 ? r : 200 - r ) ) * 100 + : 0, + l: r / 2, + a: t.a, + }; + var t, n, i, r; + }, + Vn = + /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, + On = + /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, + Pn = + /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, + Mn = + /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, + Tn = { + string: [ + [ + function ( e ) { + var t = yn.exec( e ); + return t + ? ( e = t[ 1 ] ).length <= 4 + ? { + r: parseInt( e[ 0 ] + e[ 0 ], 16 ), + g: parseInt( e[ 1 ] + e[ 1 ], 16 ), + b: parseInt( e[ 2 ] + e[ 2 ], 16 ), + a: + 4 === e.length + ? gn( + parseInt( e[ 3 ] + e[ 3 ], 16 ) / + 255, + 2 + ) + : 1, + } + : 6 === e.length || 8 === e.length + ? { + r: parseInt( e.substr( 0, 2 ), 16 ), + g: parseInt( e.substr( 2, 2 ), 16 ), + b: parseInt( e.substr( 4, 2 ), 16 ), + a: + 8 === e.length + ? gn( + parseInt( e.substr( 6, 2 ), 16 ) / + 255, + 2 + ) + : 1, + } + : null + : null; + }, + 'hex', + ], + [ + function ( e ) { + var t = Pn.exec( e ) || Mn.exec( e ); + return t + ? t[ 2 ] !== t[ 4 ] || t[ 4 ] !== t[ 6 ] + ? null + : bn( { + 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 ( e ) { + var t = Vn.exec( e ) || On.exec( e ); + if ( ! t ) return null; + var n, + i, + r = jn( { + h: + ( ( n = t[ 1 ] ), + ( i = t[ 2 ] ), + void 0 === i && ( i = 'deg' ), + Number( n ) * ( mn[ i ] || 1 ) ), + s: Number( t[ 3 ] ), + l: Number( t[ 4 ] ), + a: + void 0 === t[ 5 ] + ? 1 + : Number( t[ 5 ] ) / ( t[ 6 ] ? 100 : 1 ), + } ); + return kn( r ); + }, + 'hsl', + ], + ], + object: [ + [ + function ( e ) { + var t = e.r, + n = e.g, + i = e.b, + r = e.a, + o = void 0 === r ? 1 : r; + return pn( t ) && pn( n ) && pn( i ) + ? bn( { + r: Number( t ), + g: Number( n ), + b: Number( i ), + a: Number( o ), + } ) + : null; + }, + 'rgb', + ], + [ + function ( e ) { + var t = e.h, + n = e.s, + i = e.l, + r = e.a, + o = void 0 === r ? 1 : r; + if ( ! pn( t ) || ! pn( n ) || ! pn( i ) ) return null; + var s = jn( { + h: Number( t ), + s: Number( n ), + l: Number( i ), + a: Number( o ), + } ); + return kn( s ); + }, + 'hsl', + ], + [ + function ( e ) { + var t = e.h, + n = e.s, + i = e.v, + r = e.a, + o = void 0 === r ? 1 : r; + if ( ! pn( t ) || ! pn( n ) || ! pn( i ) ) return null; + var s = ( function ( e ) { + return { + h: vn( e.h ), + s: hn( e.s, 0, 100 ), + v: hn( e.v, 0, 100 ), + a: hn( e.a ), + }; + } )( { + h: Number( t ), + s: Number( n ), + v: Number( i ), + a: Number( o ), + } ); + return Sn( s ); + }, + 'hsv', + ], + ], + }, + Nn = function ( e, t ) { + for ( var n = 0; n < t.length; n++ ) { + var i = t[ n ][ 0 ]( e ); + if ( i ) return [ i, t[ n ][ 1 ] ]; + } + return [ null, void 0 ]; + }, + An = function ( e, t ) { + var n = In( e ); + return { h: n.h, s: hn( n.s + 100 * t, 0, 100 ), l: n.l, a: n.a }; + }, + Rn = function ( e ) { + return ( 299 * e.r + 587 * e.g + 114 * e.b ) / 1e3 / 255; + }, + Fn = function ( e, t ) { + var n = In( e ); + return { h: n.h, s: n.s, l: hn( n.l + 100 * t, 0, 100 ), a: n.a }; + }, + Ln = ( function () { + function e( e ) { + ( this.parsed = ( function ( e ) { + return 'string' == typeof e + ? Nn( e.trim(), Tn.string ) + : 'object' == typeof e && null !== e + ? Nn( e, Tn.object ) + : [ null, void 0 ]; + } )( e )[ 0 ] ), + ( this.rgba = this.parsed || { r: 0, g: 0, b: 0, a: 1 } ); + } + return ( + ( e.prototype.isValid = function () { + return null !== this.parsed; + } ), + ( e.prototype.brightness = function () { + return gn( Rn( this.rgba ), 2 ); + } ), + ( e.prototype.isDark = function () { + return Rn( this.rgba ) < 0.5; + } ), + ( e.prototype.isLight = function () { + return Rn( this.rgba ) >= 0.5; + } ), + ( e.prototype.toHex = function () { + return ( + ( t = ( e = wn( this.rgba ) ).r ), + ( n = e.g ), + ( i = e.b ), + ( o = ( r = e.a ) < 1 ? xn( gn( 255 * r ) ) : '' ), + '#' + xn( t ) + xn( n ) + xn( i ) + o + ); + var e, t, n, i, r, o; + } ), + ( e.prototype.toRgb = function () { + return wn( this.rgba ); + } ), + ( e.prototype.toRgbString = function () { + return ( + ( t = ( e = wn( this.rgba ) ).r ), + ( n = e.g ), + ( i = e.b ), + ( r = e.a ) < 1 + ? 'rgba(' + t + ', ' + n + ', ' + i + ', ' + r + ')' + : 'rgb(' + t + ', ' + n + ', ' + i + ')' + ); + var e, t, n, i, r; + } ), + ( e.prototype.toHsl = function () { + return En( In( this.rgba ) ); + } ), + ( e.prototype.toHslString = function () { + return ( + ( t = ( e = En( In( this.rgba ) ) ).h ), + ( n = e.s ), + ( i = e.l ), + ( r = e.a ) < 1 + ? 'hsla(' + t + ', ' + n + '%, ' + i + '%, ' + r + ')' + : 'hsl(' + t + ', ' + n + '%, ' + i + '%)' + ); + var e, t, n, i, r; + } ), + ( e.prototype.toHsv = function () { + return ( + ( e = Cn( this.rgba ) ), + { h: gn( e.h ), s: gn( e.s ), v: gn( e.v ), a: gn( e.a, 3 ) } + ); + var e; + } ), + ( e.prototype.invert = function () { + return Dn( { + r: 255 - ( e = this.rgba ).r, + g: 255 - e.g, + b: 255 - e.b, + a: e.a, + } ); + var e; + } ), + ( e.prototype.saturate = function ( e ) { + return void 0 === e && ( e = 0.1 ), Dn( An( this.rgba, e ) ); + } ), + ( e.prototype.desaturate = function ( e ) { + return void 0 === e && ( e = 0.1 ), Dn( An( this.rgba, -e ) ); + } ), + ( e.prototype.grayscale = function () { + return Dn( An( this.rgba, -1 ) ); + } ), + ( e.prototype.lighten = function ( e ) { + return void 0 === e && ( e = 0.1 ), Dn( Fn( this.rgba, e ) ); + } ), + ( e.prototype.darken = function ( e ) { + return void 0 === e && ( e = 0.1 ), Dn( Fn( this.rgba, -e ) ); + } ), + ( e.prototype.rotate = function ( e ) { + return void 0 === e && ( e = 15 ), this.hue( this.hue() + e ); + } ), + ( e.prototype.alpha = function ( e ) { + return 'number' == typeof e + ? Dn( { r: ( t = this.rgba ).r, g: t.g, b: t.b, a: e } ) + : gn( this.rgba.a, 3 ); + var t; + } ), + ( e.prototype.hue = function ( e ) { + var t = In( this.rgba ); + return 'number' == typeof e + ? Dn( { h: e, s: t.s, l: t.l, a: t.a } ) + : gn( t.h ); + } ), + ( e.prototype.isEqual = function ( e ) { + return this.toHex() === Dn( e ).toHex(); + } ), + e + ); + } )(), + Dn = function ( e ) { + return e instanceof Ln ? e : new Ln( e ); + }, + { ValidatedInputControl: Bn } = $( t.privateApis ), + zn = ( { color: e, onColorChange: i, disabled: r } ) => { + const o = e && Dn( e ).isValid() ? e : '#ffffff'; + return ( 0, c.jsx )( t.Dropdown, { + className: 'dataviews-controls__color-picker-dropdown', + popoverProps: { resize: ! 1 }, + renderToggle: ( { onToggle: e } ) => + ( 0, c.jsx )( t.Button, { + onClick: e, + 'aria-label': ( 0, n.__ )( 'Open color picker' ), + size: 'small', + disabled: r, + accessibleWhenDisabled: ! 0, + icon: () => ( 0, c.jsx )( t.ColorIndicator, { colorValue: o } ), + } ), + renderContent: () => + ( 0, c.jsx )( t.__experimentalDropdownContentWrapper, { + paddingSize: 'none', + children: ( 0, c.jsx )( t.ColorPicker, { + color: o, + onChange: i, + enableAlpha: ! 0, + } ), + } ), + } ); + }, + Wn = ( 0, c.jsx )( l.SVG, { + xmlns: 'http://www.w3.org/2000/svg', + viewBox: '0 0 24 24', + children: ( 0, c.jsx )( l.Path, { + d: 'M20.7 12.7s0-.1-.1-.2c0-.2-.2-.4-.4-.6-.3-.5-.9-1.2-1.6-1.8-.7-.6-1.5-1.3-2.6-1.8l-.6 1.4c.9.4 1.6 1 2.1 1.5.6.6 1.1 1.2 1.4 1.6.1.2.3.4.3.5v.1l.7-.3.7-.3Zm-5.2-9.3-1.8 4c-.5-.1-1.1-.2-1.7-.2-3 0-5.2 1.4-6.6 2.7-.7.7-1.2 1.3-1.6 1.8-.2.3-.3.5-.4.6 0 0 0 .1-.1.2s0 0 .7.3l.7.3V13c0-.1.2-.3.3-.5.3-.4.7-1 1.4-1.6 1.2-1.2 3-2.3 5.5-2.3H13v.3c-.4 0-.8-.1-1.1-.1-1.9 0-3.5 1.6-3.5 3.5s.6 2.3 1.6 2.9l-2 4.4.9.4 7.6-16.2-.9-.4Zm-3 12.6c1.7-.2 3-1.7 3-3.5s-.2-1.4-.6-1.9L12.4 16Z', + } ), + } ), + $n = ( 0, c.jsx )( l.SVG, { + xmlns: 'http://www.w3.org/2000/svg', + viewBox: '0 0 24 24', + children: ( 0, c.jsx )( l.Path, { + d: 'M3.99961 13C4.67043 13.3354 4.6703 13.3357 4.67017 13.3359L4.67298 13.3305C4.67621 13.3242 4.68184 13.3135 4.68988 13.2985C4.70595 13.2686 4.7316 13.2218 4.76695 13.1608C4.8377 13.0385 4.94692 12.8592 5.09541 12.6419C5.39312 12.2062 5.84436 11.624 6.45435 11.0431C7.67308 9.88241 9.49719 8.75 11.9996 8.75C14.502 8.75 16.3261 9.88241 17.5449 11.0431C18.1549 11.624 18.6061 12.2062 18.9038 12.6419C19.0523 12.8592 19.1615 13.0385 19.2323 13.1608C19.2676 13.2218 19.2933 13.2686 19.3093 13.2985C19.3174 13.3135 19.323 13.3242 19.3262 13.3305L19.3291 13.3359C19.3289 13.3357 19.3288 13.3354 19.9996 13C20.6704 12.6646 20.6703 12.6643 20.6701 12.664L20.6697 12.6632L20.6688 12.6614L20.6662 12.6563L20.6583 12.6408C20.6517 12.6282 20.6427 12.6108 20.631 12.5892C20.6078 12.5459 20.5744 12.4852 20.5306 12.4096C20.4432 12.2584 20.3141 12.0471 20.1423 11.7956C19.7994 11.2938 19.2819 10.626 18.5794 9.9569C17.1731 8.61759 14.9972 7.25 11.9996 7.25C9.00203 7.25 6.82614 8.61759 5.41987 9.9569C4.71736 10.626 4.19984 11.2938 3.85694 11.7956C3.68511 12.0471 3.55605 12.2584 3.4686 12.4096C3.42484 12.4852 3.39142 12.5459 3.36818 12.5892C3.35656 12.6108 3.34748 12.6282 3.34092 12.6408L3.33297 12.6563L3.33041 12.6614L3.32948 12.6632L3.32911 12.664C3.32894 12.6643 3.32879 12.6646 3.99961 13ZM11.9996 16C13.9326 16 15.4996 14.433 15.4996 12.5C15.4996 10.567 13.9326 9 11.9996 9C10.0666 9 8.49961 10.567 8.49961 12.5C8.49961 14.433 10.0666 16 11.9996 16Z', + } ), + } ); + function Hn( e ) { + return ( + ( Array.isArray( e.elements ) && e.elements.length > 0 ) || + 'function' == typeof e.getElements + ); + } + var qn = { + adaptiveSelect: function ( e ) { + const { field: t } = e, + { elements: n } = Y( { elements: t.elements, getElements: t.getElements } ); + return n.length >= 10 + ? ( 0, c.jsx )( U, { ...e } ) + : ( 0, c.jsx )( Zt, { ...e } ); + }, + array: function ( { + data: n, + field: i, + onChange: r, + hideLabelFromVision: o, + markWhenOptional: s, + validity: a, + } ) { + const { + label: l, + placeholder: u, + description: d, + getValue: f, + setValue: m, + isValid: p, + } = i, + g = f( { item: n } ), + h = i.isDisabled( { item: n, field: i } ), + { elements: v, isLoading: b } = Y( { + elements: i.elements, + getElements: i.getElements, + } ), + w = ( 0, e.useMemo )( + () => + Array.isArray( g ) + ? g.map( e => { + const t = v?.find( t => t.value === e ); + return t || { value: e, label: e }; + } ) + : [], + [ g, v ] + ), + y = ( 0, e.useCallback )( + e => { + const t = e.map( e => + 'object' == typeof e && 'value' in e ? e.value : e + ); + r( m( { item: n, value: t } ) ); + }, + [ r, m, n ] + ); + return b + ? ( 0, c.jsx )( t.Spinner, {} ) + : ( 0, c.jsx )( fn, { + required: !! p?.required, + markWhenOptional: s, + customValidity: H( p, a ), + label: o ? void 0 : l, + value: w, + onChange: y, + placeholder: u, + suggestions: v?.map( e => e.value ), + disabled: h, + __experimentalValidateInput: e => + ! i.isValid?.elements || + ! v || + v.some( t => t.value === e || t.label === e ), + __experimentalExpandOnFocus: v && v.length > 0, + help: d ?? ( i.isValid?.elements ? '' : void 0 ), + displayTransform: e => { + if ( 'object' == typeof e && 'label' in e ) return e.label; + if ( 'string' == typeof e && v ) { + const t = v.find( t => t.value === e ); + return t?.label || e; + } + return e; + }, + __experimentalRenderItem: ( { item: e } ) => { + if ( 'string' == typeof e && v ) { + const t = v.find( t => t.value === e ); + return ( 0, c.jsx )( 'span', { children: t?.label || e } ); + } + return ( 0, c.jsx )( 'span', { children: e } ); + }, + } ); + }, + checkbox: function ( { + field: t, + onChange: n, + data: i, + hideLabelFromVision: r, + markWhenOptional: o, + validity: s, + } ) { + const { getValue: a, setValue: l, label: u, description: d, isValid: f } = t, + m = t.isDisabled( { item: i, field: t } ), + p = ( 0, e.useCallback )( () => { + n( l( { item: i, value: ! a( { item: i } ) } ) ); + }, [ i, a, n, l ] ); + return ( 0, c.jsx )( q, { + required: !! t.isValid?.required, + markWhenOptional: o, + customValidity: H( f, s ), + hidden: r, + label: u, + help: d, + checked: a( { item: i } ), + onChange: p, + disabled: m, + } ); + }, + color: function ( { + data: n, + field: i, + onChange: r, + hideLabelFromVision: o, + markWhenOptional: s, + validity: a, + } ) { + const { label: l, placeholder: u, description: d, setValue: f, isValid: m } = i, + p = i.isDisabled( { item: n, field: i } ), + g = i.getValue( { item: n } ) || '', + h = ( 0, e.useCallback )( + e => { + r( f( { item: n, value: e } ) ); + }, + [ n, r, f ] + ), + v = ( 0, e.useCallback )( + e => { + r( f( { item: n, value: e || '' } ) ); + }, + [ n, r, f ] + ); + return ( 0, c.jsx )( Bn, { + required: !! i.isValid?.required, + markWhenOptional: s, + customValidity: H( m, a ), + label: l, + placeholder: u, + value: g, + help: d, + onChange: v, + hideLabelFromVision: o, + type: 'text', + disabled: p, + prefix: ( 0, c.jsx )( t.__experimentalInputControlPrefixWrapper, { + variant: 'control', + children: ( 0, c.jsx )( zn, { + color: g, + onColorChange: h, + disabled: p, + } ), + } ), + } ); + }, + combobox: U, + datetime: function ( { + data: e, + field: t, + onChange: n, + hideLabelFromVision: i, + markWhenOptional: r, + operator: o, + validity: s, + config: a, + } ) { + return o === v || o === b + ? ( 0, c.jsx )( Ae, { + className: 'dataviews-controls__datetime', + data: e, + field: t, + onChange: n, + hideLabelFromVision: i, + operator: o, + } ) + : ( 0, c.jsx )( Ge, { + data: e, + field: t, + onChange: n, + hideLabelFromVision: i, + markWhenOptional: r, + validity: s, + config: a, + } ); + }, + date: function ( { + data: e, + field: t, + onChange: n, + hideLabelFromVision: i, + markWhenOptional: r, + operator: o, + validity: s, + } ) { + return o === v || o === b + ? ( 0, c.jsx )( Ae, { + className: 'dataviews-controls__date', + data: e, + field: t, + onChange: n, + hideLabelFromVision: i, + operator: o, + } ) + : o === h + ? ( 0, c.jsx )( Ut, { + data: e, + field: t, + onChange: n, + hideLabelFromVision: i, + markWhenOptional: r, + validity: s, + } ) + : ( 0, c.jsx )( Kt, { + data: e, + field: t, + onChange: n, + hideLabelFromVision: i, + markWhenOptional: r, + validity: s, + } ); + }, + email: function ( { + data: e, + field: n, + onChange: i, + hideLabelFromVision: r, + markWhenOptional: o, + validity: s, + } ) { + return ( 0, c.jsx )( en, { + data: e, + field: n, + onChange: i, + hideLabelFromVision: r, + markWhenOptional: o, + validity: s, + type: 'email', + prefix: ( 0, c.jsx )( t.__experimentalInputControlPrefixWrapper, { + variant: 'icon', + children: ( 0, c.jsx )( t.Icon, { icon: Qt } ), + } ), + } ); + }, + telephone: function ( { + data: e, + field: n, + onChange: i, + hideLabelFromVision: r, + markWhenOptional: o, + validity: s, + } ) { + return ( 0, c.jsx )( en, { + data: e, + field: n, + onChange: i, + hideLabelFromVision: r, + markWhenOptional: o, + validity: s, + type: 'tel', + prefix: ( 0, c.jsx )( t.__experimentalInputControlPrefixWrapper, { + variant: 'icon', + children: ( 0, c.jsx )( t.Icon, { icon: tn } ), + } ), + } ); + }, + url: function ( { + data: e, + field: n, + onChange: i, + hideLabelFromVision: r, + markWhenOptional: o, + validity: s, + } ) { + return ( 0, c.jsx )( en, { + data: e, + field: n, + onChange: i, + hideLabelFromVision: r, + markWhenOptional: o, + validity: s, + type: 'url', + prefix: ( 0, c.jsx )( t.__experimentalInputControlPrefixWrapper, { + variant: 'icon', + children: ( 0, c.jsx )( t.Icon, { icon: nn } ), + } ), + } ); + }, + integer: function ( e ) { + return ( 0, c.jsx )( an, { ...e } ); + }, + number: function ( e ) { + return ( 0, c.jsx )( an, { ...e } ); + }, + password: function ( { + data: i, + field: r, + onChange: o, + hideLabelFromVision: s, + markWhenOptional: a, + validity: l, + } ) { + const [ u, d ] = ( 0, e.useState )( ! 1 ), + f = r.isDisabled( { item: i, field: r } ), + m = ( 0, e.useCallback )( () => { + d( e => ! e ); + }, [] ); + return ( 0, c.jsx )( en, { + data: i, + field: r, + onChange: o, + hideLabelFromVision: s, + markWhenOptional: a, + validity: l, + type: u ? 'text' : 'password', + suffix: ( 0, c.jsx )( t.__experimentalInputControlSuffixWrapper, { + variant: 'control', + children: ( 0, c.jsx )( t.Button, { + icon: u ? Wn : $n, + onClick: m, + size: 'small', + label: u + ? ( 0, n.__ )( 'Hide password' ) + : ( 0, n.__ )( 'Show password' ), + disabled: f, + accessibleWhenDisabled: ! 0, + } ), + } ), + } ); + }, + radio: function ( { + data: n, + field: i, + onChange: r, + hideLabelFromVision: o, + markWhenOptional: s, + validity: a, + } ) { + const { label: l, description: u, getValue: d, setValue: f, isValid: m } = i, + p = i.isDisabled( { item: n, field: i } ), + { elements: g, isLoading: h } = Y( { + elements: i.elements, + getElements: i.getElements, + } ), + v = d( { item: n } ), + b = ( 0, e.useCallback )( + e => r( f( { item: n, value: e } ) ), + [ n, r, f ] + ); + return h + ? ( 0, c.jsx )( t.Spinner, {} ) + : ( 0, c.jsx )( ln, { + required: !! i.isValid?.required, + markWhenOptional: s, + customValidity: H( m, a ), + label: l, + help: u, + onChange: b, + options: g, + selected: v, + hideLabelFromVision: o, + disabled: p, + } ); + }, + select: Zt, + text: function ( { + data: t, + field: n, + onChange: i, + hideLabelFromVision: r, + markWhenOptional: o, + config: s, + validity: a, + } ) { + const { prefix: l, suffix: u } = s || {}; + return ( 0, c.jsx )( en, { + data: t, + field: n, + onChange: i, + hideLabelFromVision: r, + markWhenOptional: o, + validity: a, + prefix: l ? ( 0, e.createElement )( l ) : void 0, + suffix: u ? ( 0, e.createElement )( u ) : void 0, + } ); + }, + toggle: function ( { + field: t, + onChange: n, + data: i, + hideLabelFromVision: r, + markWhenOptional: o, + validity: s, + } ) { + const { label: a, description: l, getValue: u, setValue: d, isValid: f } = t, + m = t.isDisabled( { item: i, field: t } ), + p = ( 0, e.useCallback )( () => { + n( d( { item: i, value: ! u( { item: i } ) } ) ); + }, [ n, d, i, u ] ); + return ( 0, c.jsx )( cn, { + required: !! f.required, + markWhenOptional: o, + customValidity: H( f, s ), + hidden: r, + label: a, + help: l, + checked: u( { item: i } ), + onChange: p, + disabled: m, + } ); + }, + textarea: function ( { + data: t, + field: n, + onChange: i, + hideLabelFromVision: r, + markWhenOptional: o, + config: s, + validity: a, + } ) { + const { rows: l = 4 } = s || {}, + u = n.isDisabled( { item: t, field: n } ), + { label: d, placeholder: f, description: m, setValue: p, isValid: g } = n, + h = n.getValue( { item: t } ), + v = ( 0, e.useCallback )( + e => i( p( { item: t, value: e } ) ), + [ t, i, p ] + ); + return ( 0, c.jsx )( un, { + required: !! g.required, + markWhenOptional: o, + customValidity: H( g, a ), + label: d, + placeholder: f, + value: h ?? '', + help: m, + onChange: v, + rows: l, + disabled: u, + minLength: g.minLength ? g.minLength.constraint : void 0, + maxLength: g.maxLength ? g.maxLength.constraint : void 0, + __next40pxDefaultSize: ! 0, + hideLabelFromVision: r, + } ); + }, + toggleGroup: function ( { + data: n, + field: i, + onChange: r, + hideLabelFromVision: o, + markWhenOptional: s, + validity: a, + } ) { + const { getValue: l, setValue: u, isValid: d } = i, + f = i.isDisabled( { item: n, field: i } ), + m = l( { item: n } ), + p = ( 0, e.useCallback )( + e => r( u( { item: n, value: e } ) ), + [ n, r, u ] + ), + { elements: g, isLoading: h } = Y( { + elements: i.elements, + getElements: i.getElements, + } ); + if ( h ) return ( 0, c.jsx )( t.Spinner, {} ); + if ( 0 === g.length ) return null; + const v = g.find( e => e.value === m ); + return ( 0, c.jsx )( dn, { + required: !! i.isValid?.required, + markWhenOptional: s, + customValidity: H( d, a ), + __next40pxDefaultSize: ! 0, + isBlock: ! 0, + label: i.label, + help: v?.description || i.description, + onChange: p, + value: m, + hideLabelFromVision: o, + children: g.map( e => + ( 0, c.jsx )( + t.__experimentalToggleGroupControlOption, + { label: e.label, value: e.value, disabled: f }, + e.value + ) + ), + } ); + }, + }; + function Gn( e, t ) { + return 'function' == typeof e.Edit + ? e.Edit + : 'string' == typeof e.Edit + ? Yn( e.Edit ) + : ( n = e.Edit ) && 'object' == typeof n && 'string' == typeof n.control + ? ( function ( e ) { + const { control: t, ...n } = e, + i = Yn( t ); + return null === i + ? null + : function ( e ) { + return ( 0, c.jsx )( i, { ...e, config: n } ); + }; + } )( e.Edit ) + : Hn( e ) && 'array' !== e.type + ? Yn( 'adaptiveSelect' ) + : null === t + ? null + : Yn( t ); + var n; + } + function Yn( e ) { + return Object.keys( qn ).includes( e ) ? qn[ e ] : null; + } + var Kn = function ( e, t, n ) { + if ( ! 1 === e.filterBy ) return ! 1; + const i = e.filterBy?.operators?.filter( e => n.includes( e ) ) ?? t; + return 0 !== i.length && { isPrimary: !! e.filterBy?.isPrimary, operators: i }; + }, + Un = + e => + ( { value: t } ) => { + const n = e.split( '.' ), + i = {}; + let r = i; + for ( const e of n.slice( 0, -1 ) ) ( r[ e ] = {} ), ( r = r[ e ] ); + return ( r[ n.at( -1 ) ] = t ), i; + }; + function Xn( { item: e, field: t } ) { + const { elements: n, isLoading: i } = Y( { + elements: t.elements, + getElements: t.getElements, + } ), + r = t.getValue( { item: e } ); + return i || 0 === n.length + ? r + : n?.find( e => e.value === r )?.label || t.getValue( { item: e } ); + } + function Zn( { item: e, field: t } ) { + return t.hasElements + ? ( 0, c.jsx )( Xn, { item: e, field: t } ) + : t.getValueFormatted( { item: e, field: t } ); + } + var Qn = ( e, t, n ) => ( 'asc' === n ? e.localeCompare( t ) : t.localeCompare( e ) ); + function Jn( e, t ) { + const n = t.getValue( { item: e } ); + return ! [ void 0, '', null ].includes( n ); + } + function ei( e, t ) { + if ( 'number' != typeof t.isValid.minLength?.constraint ) return ! 1; + const n = t.getValue( { item: e } ); + return ( + !! [ void 0, '', null ].includes( n ) || + String( n ).length >= t.isValid.minLength.constraint + ); + } + function ti( e, t ) { + if ( 'number' != typeof t.isValid.maxLength?.constraint ) return ! 1; + const n = t.getValue( { item: e } ); + return ( + !! [ void 0, '', null ].includes( n ) || + String( n ).length <= t.isValid.maxLength.constraint + ); + } + function ni( e, t ) { + if ( void 0 === t.isValid.pattern?.constraint ) return ! 0; + try { + const n = new RegExp( t.isValid.pattern.constraint ), + i = t.getValue( { item: e } ); + return !! [ void 0, '', null ].includes( i ) || n.test( String( i ) ); + } catch { + return ! 1; + } + } + function ii( e, t ) { + const n = ( t.elements ?? [] ).map( e => e.value ); + if ( 0 === n.length ) return ! 0; + const i = t.getValue( { item: e } ); + return [].concat( i ).every( e => n.includes( e ) ); + } + var ri = function ( { item: e, field: t } ) { + return t.getValue( { item: e } ); + }, + oi = + /^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/, + si = { + type: 'email', + render: Zn, + Edit: 'email', + sort: Qn, + enableSorting: ! 0, + enableGlobalSearch: ! 1, + defaultOperators: [ f, m ], + validOperators: [ w, y, V, O, P, f, m, p, g ], + format: {}, + getValueFormatted: ri, + validate: { + required: Jn, + pattern: ni, + minLength: ei, + maxLength: ti, + elements: ii, + custom: function ( e, t ) { + const i = t.getValue( { item: e } ); + return [ void 0, '', null ].includes( i ) || oi.test( i ) + ? null + : ( 0, n.__ )( 'Value must be a valid email address.' ); + }, + }, + }, + ai = ( e, t, n ) => ( 'asc' === n ? e - t : t - e ); + function li( e, t ) { + if ( 'number' != typeof t.isValid.min?.constraint ) return ! 1; + const n = t.getValue( { item: e } ); + return ( + !! [ void 0, '', null ].includes( n ) || Number( n ) >= t.isValid.min.constraint + ); + } + function ci( e, t ) { + if ( 'number' != typeof t.isValid.max?.constraint ) return ! 1; + const n = t.getValue( { item: e } ); + return ( + !! [ void 0, '', null ].includes( n ) || Number( n ) <= t.isValid.max.constraint + ); + } + var ui = { separatorThousand: ',' }, + di = { + type: 'integer', + render: Zn, + Edit: 'integer', + sort: ai, + enableSorting: ! 0, + enableGlobalSearch: ! 1, + defaultOperators: [ w, y, x, C, S, _, h ], + validOperators: [ w, y, x, C, S, _, h, f, m, p, g ], + format: ui, + getValueFormatted: function ( { item: e, field: t } ) { + let n, + i = t.getValue( { item: e } ); + if ( null == i ) return ''; + if ( ( ( i = Number( i ) ), ! Number.isFinite( i ) ) ) return String( i ); + n = 'integer' !== t.type ? ui : t.format; + const { separatorThousand: r } = n, + o = Math.trunc( i ); + return r ? String( o ).replace( /\B(?=(\d{3})+(?!\d))/g, r ) : String( o ); + }, + validate: { + required: Jn, + min: li, + max: ci, + elements: ii, + custom: function ( e, t ) { + const i = t.getValue( { item: e } ); + return [ void 0, '', null ].includes( i ) || Number.isInteger( i ) + ? null + : ( 0, n.__ )( 'Value must be an integer.' ); + }, + }, + }, + fi = { separatorThousand: ',', separatorDecimal: '.', decimals: 2 }, + mi = { + type: 'number', + render: Zn, + Edit: 'number', + sort: ai, + enableSorting: ! 0, + enableGlobalSearch: ! 1, + defaultOperators: [ w, y, x, C, S, _, h ], + validOperators: [ w, y, x, C, S, _, h, f, m, p, g ], + format: fi, + getValueFormatted: function ( { item: e, field: t } ) { + let n, + i = t.getValue( { item: e } ); + if ( null == i ) return ''; + if ( ( ( i = Number( i ) ), ! Number.isFinite( i ) ) ) return String( i ); + n = 'number' !== t.type ? fi : t.format; + const { separatorThousand: r, separatorDecimal: o, decimals: s } = n, + a = i.toFixed( s ), + [ l, c ] = a.split( '.' ), + u = r ? l.replace( /\B(?=(\d{3})+(?!\d))/g, r ) : l; + return 0 === s ? u : u + o + c; + }, + validate: { + required: Jn, + min: li, + max: ci, + elements: ii, + custom: function ( e, t ) { + const i = t.getValue( { item: e } ); + return ( function ( e ) { + return '' === e || null == e; + } )( i ) || Number.isFinite( i ) + ? null + : ( 0, n.__ )( 'Value must be a number.' ); + }, + }, + }, + pi = { + type: 'text', + render: Zn, + Edit: 'text', + sort: Qn, + enableSorting: ! 0, + enableGlobalSearch: ! 1, + defaultOperators: [ f, m ], + validOperators: [ w, y, V, O, P, f, m, p, g ], + format: {}, + getValueFormatted: ri, + validate: { + required: Jn, + pattern: ni, + minLength: ei, + maxLength: ti, + elements: ii, + }, + }; + function gi( e ) { + if ( ! e ) return null; + if ( ! ze( new Date( e ) ) ) return null; + const t = ( 0, X.getDate )( e ); + return t && ze( t ) ? t : null; + } + function hi( e, t, n ) { + const i = t.isValid[ n ]?.constraint; + if ( 'string' != typeof i ) return ! 1; + const r = t.getValue( { item: e } ), + o = Array.isArray( r ) ? r[ 'min' === n ? 0 : r.length - 1 ] : r; + if ( null == o || '' === o ) return ! 0; + const s = gi( i ), + a = gi( String( o ) ); + return ( + !! s && + !! a && + ( 'min' === n ? a.getTime() >= s.getTime() : a.getTime() <= s.getTime() ) + ); + } + function vi( e, t ) { + return hi( e, t, 'min' ); + } + function bi( e, t ) { + return hi( e, t, 'max' ); + } + var wi = { + datetime: ( 0, X.getSettings )().formats.datetime, + weekStartsOn: ( 0, X.getSettings )().l10n.startOfWeek, + }, + yi = { + type: 'datetime', + render: Zn, + Edit: 'datetime', + sort: ( e, t, n ) => { + const i = new Date( e ).getTime(), + r = new Date( t ).getTime(); + return 'asc' === n ? i - r : r - i; + }, + enableSorting: ! 0, + enableGlobalSearch: ! 1, + defaultOperators: [ M, T, j, E, k, I, v, b ], + validOperators: [ M, T, j, E, k, I, v, b ], + format: wi, + getValueFormatted: function ( { item: e, field: t } ) { + const n = t.getValue( { item: e } ); + if ( [ '', void 0, null ].includes( n ) ) return ''; + let i; + return ( + ( i = 'datetime' !== t.type ? wi : t.format ), + ( 0, X.dateI18n )( i.datetime, ( 0, X.getDate )( n ) ) + ); + }, + validate: { required: Jn, elements: ii, min: vi, max: bi }, + }, + xi = { + date: ( 0, X.getSettings )().formats.date, + weekStartsOn: ( 0, X.getSettings )().l10n.startOfWeek, + }, + Ci = { + type: 'date', + render: Zn, + Edit: 'date', + sort: ( e, t, n ) => { + const i = new Date( e ).getTime(), + r = new Date( t ).getTime(); + return 'asc' === n ? i - r : r - i; + }, + enableSorting: ! 0, + enableGlobalSearch: ! 1, + defaultOperators: [ M, T, j, E, k, I, v, b, h ], + validOperators: [ M, T, j, E, k, I, v, b, h ], + format: xi, + getValueFormatted: function ( { item: e, field: t } ) { + const n = t.getValue( { item: e } ); + if ( [ '', void 0, null ].includes( n ) ) return ''; + let i; + return ( + ( i = 'date' !== t.type ? xi : t.format ), + ( 0, X.dateI18n )( i.date, ( 0, X.getDate )( n ) ) + ); + }, + validate: { required: Jn, elements: ii, min: vi, max: bi }, + }, + Si = { + type: 'boolean', + render: Zn, + Edit: 'checkbox', + sort: ( e, t, n ) => { + const i = Boolean( e ); + return i === Boolean( t ) ? 0 : 'asc' === n ? ( i ? 1 : -1 ) : i ? -1 : 1; + }, + validate: { + required: function ( e, t ) { + return ! 0 === t.getValue( { item: e } ); + }, + elements: ii, + custom: function ( e, t ) { + const i = t.getValue( { item: e } ); + return [ void 0, '', null ].includes( i ) || [ ! 0, ! 1 ].includes( i ) + ? null + : ( 0, n.__ )( 'Value must be true, false, or undefined' ); + }, + }, + enableSorting: ! 0, + enableGlobalSearch: ! 1, + defaultOperators: [ w, y ], + validOperators: [ w, y ], + format: {}, + getValueFormatted: function ( { item: e, field: t } ) { + const i = t.getValue( { item: e } ); + return ! 0 === i + ? ( 0, n.__ )( 'True' ) + : ! 1 === i + ? ( 0, n.__ )( 'False' ) + : ''; + }, + }, + _i = { + type: 'media', + render: () => null, + Edit: null, + sort: () => 0, + enableSorting: ! 1, + enableGlobalSearch: ! 1, + defaultOperators: [], + validOperators: [], + format: {}, + getValueFormatted: ri, + validate: {}, + }; + function ji( { item: e, field: t } ) { + const n = t.getValue( { item: e } ); + return ( Array.isArray( n ) ? n : [] ).join( ', ' ); + } + var Ei = { + type: 'array', + render: function ( { item: e, field: t } ) { + return ji( { item: e, field: t } ); + }, + Edit: 'array', + sort: ( e, t, n ) => { + const i = Array.isArray( e ) ? e : [], + r = Array.isArray( t ) ? t : []; + if ( i.length !== r.length ) + return 'asc' === n ? i.length - r.length : r.length - i.length; + const o = i.join( ',' ), + s = r.join( ',' ); + return 'asc' === n ? o.localeCompare( s ) : s.localeCompare( o ); + }, + enableSorting: ! 0, + enableGlobalSearch: ! 1, + defaultOperators: [ f, m ], + validOperators: [ f, m, p, g ], + format: {}, + getValueFormatted: ji, + validate: { + required: function ( e, t ) { + const n = t.getValue( { item: e } ); + return ( + Array.isArray( n ) && + n.length > 0 && + n.every( e => ! [ void 0, '', null ].includes( e ) ) + ); + }, + elements: ii, + custom: function ( e, t ) { + const i = t.getValue( { item: e } ); + return [ void 0, '', null ].includes( i ) || Array.isArray( i ) + ? i.every( e => 'string' == typeof e ) + ? null + : ( 0, n.__ )( 'Every value must be a string.' ) + : ( 0, n.__ )( 'Value must be an array.' ); + }, + }, + }, + ki = { + type: 'password', + render: Zn, + Edit: 'password', + sort: () => 0, + enableSorting: ! 1, + enableGlobalSearch: ! 1, + defaultOperators: [], + validOperators: [], + format: {}, + getValueFormatted: function ( { item: e, field: t } ) { + return t.getValue( { item: e } ) ? '••••••••' : ''; + }, + validate: { + required: Jn, + pattern: ni, + minLength: ei, + maxLength: ti, + elements: ii, + }, + }, + Ii = { + type: 'telephone', + render: Zn, + Edit: 'telephone', + sort: Qn, + enableSorting: ! 0, + enableGlobalSearch: ! 1, + defaultOperators: [ f, m ], + validOperators: [ w, y, V, O, P, f, m, p, g ], + format: {}, + getValueFormatted: ri, + validate: { + required: Jn, + pattern: ni, + minLength: ei, + maxLength: ti, + elements: ii, + }, + }, + Vi = { + type: 'color', + render: function ( { item: e, field: t } ) { + if ( t.hasElements ) return ( 0, c.jsx )( Xn, { item: e, field: t } ); + const n = ri( { item: e, field: t } ); + return n && Dn( n ).isValid() + ? ( 0, c.jsxs )( 'div', { + style: { display: 'flex', alignItems: 'center', gap: '8px' }, + children: [ + ( 0, c.jsx )( 'div', { + style: { + width: '16px', + height: '16px', + borderRadius: '50%', + backgroundColor: n, + border: '1px solid #ddd', + flexShrink: 0, + }, + } ), + ( 0, c.jsx )( 'span', { children: n } ), + ], + } ) + : n; + }, + Edit: 'color', + sort: ( e, t, n ) => { + const i = Dn( e ), + r = Dn( t ); + if ( ! i.isValid() && ! r.isValid() ) return 0; + if ( ! i.isValid() ) return 'asc' === n ? 1 : -1; + if ( ! r.isValid() ) return 'asc' === n ? -1 : 1; + const o = i.toHsl(), + s = r.toHsl(); + return o.h !== s.h + ? 'asc' === n + ? o.h - s.h + : s.h - o.h + : o.s !== s.s + ? 'asc' === n + ? o.s - s.s + : s.s - o.s + : 'asc' === n + ? o.l - s.l + : s.l - o.l; + }, + enableSorting: ! 0, + enableGlobalSearch: ! 1, + defaultOperators: [ f, m ], + validOperators: [ w, y, f, m ], + format: {}, + getValueFormatted: ri, + validate: { + required: Jn, + elements: ii, + custom: function ( e, t ) { + const i = t.getValue( { item: e } ); + return [ void 0, '', null ].includes( i ) || Dn( i ).isValid() + ? null + : ( 0, n.__ )( 'Value must be a valid color.' ); + }, + }, + }, + Oi = { + type: 'url', + render: Zn, + Edit: 'url', + sort: Qn, + enableSorting: ! 0, + enableGlobalSearch: ! 1, + defaultOperators: [ f, m ], + validOperators: [ w, y, V, O, P, f, m, p, g ], + format: {}, + getValueFormatted: ri, + validate: { + required: Jn, + pattern: ni, + minLength: ei, + maxLength: ti, + elements: ii, + }, + }; + function Pi( e, t, n ) { + return ( function ( e, t, n ) { + return Ye( e, 7 * t, n ); + } )( e, -t, n ); + } + var Mi = { + Name: ( 0, c.jsx )( 'span', { + className: 'dataviews-filters__summary-filter-text-name', + } ), + Value: ( 0, c.jsx )( 'span', { + className: 'dataviews-filters__summary-filter-text-value', + } ), + }; + function Ti( e, t ) { + switch ( t ) { + case 'days': + return Ke( new Date(), e ); + case 'weeks': + return Pi( new Date(), e ); + case 'months': + return Xe( new Date(), e ); + case 'years': + return Qe( new Date(), e ); + default: + return new Date(); + } + } + var Ni = { + /* translators: DataViews operator name */ + label: ( 0, n.__ )( 'Is none of' ), + filterText: ( t, i ) => + ( 0, e.createInterpolateElement )( + ( 0, n.sprintf )( + /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is none of: Admin, Editor". */ + /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is none of: Admin, Editor". */ + ( 0, n.__ )( '%1$s is none of: %2$s' ), + t.name, + i.map( e => e.label ).join( ', ' ) + ), + Mi + ), + filter: ( e, t, n ) => { + if ( ! n?.length ) return ! 0; + const i = t.getValue( { item: e } ); + return Array.isArray( i ) + ? ! n.some( e => i.includes( e ) ) + : 'string' == typeof i && ! n.includes( i ); + }, + selection: 'multi', + }, + Ai = [ + { + name: f, + /* translators: DataViews operator name */ + label: ( 0, n.__ )( 'Includes' ), + filterText: ( t, i ) => + ( 0, e.createInterpolateElement )( + ( 0, n.sprintf )( + /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is any: Admin, Editor". */ + /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is any: Admin, Editor". */ + ( 0, n.__ )( + '%1$s includes: %2$s' + ), + t.name, + i.map( e => e.label ).join( ', ' ) + ), + Mi + ), + filter( e, t, n ) { + if ( ! n?.length ) return ! 0; + const i = t.getValue( { item: e } ); + return Array.isArray( i ) + ? n.some( e => i.includes( e ) ) + : 'string' == typeof i && n.includes( i ); + }, + selection: 'multi', + }, + { name: m, ...Ni }, + { + name: p, + /* translators: DataViews operator name */ + label: ( 0, n.__ )( 'Includes all' ), + filterText: ( t, i ) => + ( 0, e.createInterpolateElement )( + ( 0, n.sprintf )( + /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author includes all: Admin, Editor". */ + /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author includes all: Admin, Editor". */ + ( 0, n.__ )( + '%1$s includes all: %2$s' + ), + t.name, + i.map( e => e.label ).join( ', ' ) + ), + Mi + ), + filter: ( e, t, n ) => + ! n?.length || n.every( n => t.getValue( { item: e } )?.includes( n ) ), + selection: 'multi', + }, + { name: g, ...Ni }, + { + name: h, + /* translators: DataViews operator name */ + label: ( 0, n.__ )( 'Between (inc)' ), + filterText: ( t, i ) => + ( 0, e.createInterpolateElement )( + ( 0, n.sprintf )( + /* translators: 1: Filter name (e.g. "Item count"). 2: Filter value min. 3: Filter value max. e.g.: "Item count between (inc): 10 and 180". */ + /* translators: 1: Filter name (e.g. "Item count"). 2: Filter value min. 3: Filter value max. e.g.: "Item count between (inc): 10 and 180". */ + ( 0, n.__ )( + '%1$s between (inc): %2$s and %3$s' + ), + t.name, + i[ 0 ].label[ 0 ], + i[ 0 ].label[ 1 ] + ), + Mi + ), + filter( e, t, n ) { + if ( + ! Array.isArray( n ) || + 2 !== n.length || + void 0 === n[ 0 ] || + void 0 === n[ 1 ] + ) + return ! 0; + const i = t.getValue( { item: e } ); + return ( + ( 'number' == typeof i || + i instanceof Date || + 'string' == typeof i ) && + i >= n[ 0 ] && + i <= n[ 1 ] + ); + }, + selection: 'custom', + }, + { + name: v, + /* translators: DataViews operator name */ + label: ( 0, n.__ )( 'In the past' ), + filterText: ( t, i ) => + ( 0, e.createInterpolateElement )( + ( 0, n.sprintf )( + /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "7 days"): "Date is in the past: 7 days". */ + /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "7 days"): "Date is in the past: 7 days". */ + ( 0, n.__ )( + '%1$s is in the past: %2$s' + ), + t.name, + `${ i[ 0 ].value.value } ${ i[ 0 ].value.unit }` + ), + Mi + ), + filter( e, t, n ) { + if ( void 0 === n?.value || void 0 === n?.unit ) return ! 0; + const i = Ti( n.value, n.unit ), + r = ( 0, X.getDate )( t.getValue( { item: e } ) ); + return r >= i && r <= new Date(); + }, + selection: 'custom', + }, + { + name: b, + /* translators: DataViews operator name */ + label: ( 0, n.__ )( 'Over' ), + filterText: ( t, i ) => + ( 0, e.createInterpolateElement )( + ( 0, n.sprintf )( + /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "7 days"): "Date is over: 7 days". */ + /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "7 days"): "Date is over: 7 days". */ + ( 0, n.__ )( '%1$s is over: %2$s' ), + t.name, + `${ i[ 0 ].value.value } ${ i[ 0 ].value.unit }` + ), + Mi + ), + filter( e, t, n ) { + if ( void 0 === n?.value || void 0 === n?.unit ) return ! 0; + const i = Ti( n.value, n.unit ); + return ( 0, X.getDate )( t.getValue( { item: e } ) ) < i; + }, + selection: 'custom', + }, + { + name: w, + /* translators: DataViews operator name */ + label: ( 0, n.__ )( 'Is' ), + filterText: ( t, i ) => + ( 0, e.createInterpolateElement )( + ( 0, n.sprintf )( + /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is: Admin". */ + /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is: Admin". */ + ( 0, n.__ )( '%1$s is: %2$s' ), + t.name, + i[ 0 ].label + ), + Mi + ), + filter: ( e, t, n ) => n === t.getValue( { item: e } ) || void 0 === n, + selection: 'single', + }, + { + name: y, + /* translators: DataViews operator name */ + label: ( 0, n.__ )( 'Is not' ), + filterText: ( t, i ) => + ( 0, e.createInterpolateElement )( + ( 0, n.sprintf )( + /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is not: Admin". */ + /* translators: 1: Filter name (e.g. "Author"). 2: Filter value (e.g. "Admin"): "Author is not: Admin". */ + ( 0, n.__ )( '%1$s is not: %2$s' ), + t.name, + i[ 0 ].label + ), + Mi + ), + filter: ( e, t, n ) => n !== t.getValue( { item: e } ), + selection: 'single', + }, + { + name: x, + /* translators: DataViews operator name */ + label: ( 0, n.__ )( 'Less than' ), + filterText: ( t, i ) => + ( 0, e.createInterpolateElement )( + ( 0, n.sprintf )( + /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is less than: 10". */ + /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is less than: 10". */ + ( 0, n.__ )( + '%1$s is less than: %2$s' + ), + t.name, + i[ 0 ].label + ), + Mi + ), + filter: ( e, t, n ) => void 0 === n || t.getValue( { item: e } ) < n, + selection: 'single', + }, + { + name: C, + /* translators: DataViews operator name */ + label: ( 0, n.__ )( 'Greater than' ), + filterText: ( t, i ) => + ( 0, e.createInterpolateElement )( + ( 0, n.sprintf )( + /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is greater than: 10". */ + /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is greater than: 10". */ + ( 0, n.__ )( + '%1$s is greater than: %2$s' + ), + t.name, + i[ 0 ].label + ), + Mi + ), + filter: ( e, t, n ) => void 0 === n || t.getValue( { item: e } ) > n, + selection: 'single', + }, + { + name: S, + /* translators: DataViews operator name */ + label: ( 0, n.__ )( 'Less than or equal' ), + filterText: ( t, i ) => + ( 0, e.createInterpolateElement )( + ( 0, n.sprintf )( + /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is less than or equal to: 10". */ + /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is less than or equal to: 10". */ + ( 0, n.__ )( + '%1$s is less than or equal to: %2$s' + ), + t.name, + i[ 0 ].label + ), + Mi + ), + filter: ( e, t, n ) => void 0 === n || t.getValue( { item: e } ) <= n, + selection: 'single', + }, + { + name: _, + /* translators: DataViews operator name */ + label: ( 0, n.__ )( 'Greater than or equal' ), + filterText: ( t, i ) => + ( 0, e.createInterpolateElement )( + ( 0, n.sprintf )( + /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is greater than or equal to: 10". */ + /* translators: 1: Filter name (e.g. "Count"). 2: Filter value (e.g. "10"): "Count is greater than or equal to: 10". */ + ( 0, n.__ )( + '%1$s is greater than or equal to: %2$s' + ), + t.name, + i[ 0 ].label + ), + Mi + ), + filter: ( e, t, n ) => void 0 === n || t.getValue( { item: e } ) >= n, + selection: 'single', + }, + { + name: j, + /* translators: DataViews operator name */ + label: ( 0, n.__ )( 'Before' ), + filterText: ( t, i ) => + ( 0, e.createInterpolateElement )( + ( 0, n.sprintf )( + /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is before: 2024-01-01". */ + /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is before: 2024-01-01". */ + ( 0, n.__ )( + '%1$s is before: %2$s' + ), + t.name, + i[ 0 ].label + ), + Mi + ), + filter( e, t, n ) { + if ( void 0 === n ) return ! 0; + const i = ( 0, X.getDate )( n ); + return ( 0, X.getDate )( t.getValue( { item: e } ) ) < i; + }, + selection: 'single', + }, + { + name: E, + /* translators: DataViews operator name */ + label: ( 0, n.__ )( 'After' ), + filterText: ( t, i ) => + ( 0, e.createInterpolateElement )( + ( 0, n.sprintf )( + /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is after: 2024-01-01". */ + /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is after: 2024-01-01". */ + ( 0, n.__ )( + '%1$s is after: %2$s' + ), + t.name, + i[ 0 ].label + ), + Mi + ), + filter( e, t, n ) { + if ( void 0 === n ) return ! 0; + const i = ( 0, X.getDate )( n ); + return ( 0, X.getDate )( t.getValue( { item: e } ) ) > i; + }, + selection: 'single', + }, + { + name: k, + /* translators: DataViews operator name */ + label: ( 0, n.__ )( 'Before (inc)' ), + filterText: ( t, i ) => + ( 0, e.createInterpolateElement )( + ( 0, n.sprintf )( + /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is on or before: 2024-01-01". */ + /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is on or before: 2024-01-01". */ + ( 0, n.__ )( + '%1$s is on or before: %2$s' + ), + t.name, + i[ 0 ].label + ), + Mi + ), + filter( e, t, n ) { + if ( void 0 === n ) return ! 0; + const i = ( 0, X.getDate )( n ); + return ( 0, X.getDate )( t.getValue( { item: e } ) ) <= i; + }, + selection: 'single', + }, + { + name: I, + /* translators: DataViews operator name */ + label: ( 0, n.__ )( 'After (inc)' ), + filterText: ( t, i ) => + ( 0, e.createInterpolateElement )( + ( 0, n.sprintf )( + /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is on or after: 2024-01-01". */ + /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is on or after: 2024-01-01". */ + ( 0, n.__ )( + '%1$s is on or after: %2$s' + ), + t.name, + i[ 0 ].label + ), + Mi + ), + filter( e, t, n ) { + if ( void 0 === n ) return ! 0; + const i = ( 0, X.getDate )( n ); + return ( 0, X.getDate )( t.getValue( { item: e } ) ) >= i; + }, + selection: 'single', + }, + { + name: V, + /* translators: DataViews operator name */ + label: ( 0, n.__ )( 'Contains' ), + filterText: ( t, i ) => + ( 0, e.createInterpolateElement )( + ( 0, n.sprintf )( + /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title contains: Hello". */ + /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title contains: Hello". */ + ( 0, n.__ )( + '%1$s contains: %2$s' + ), + t.name, + i[ 0 ].label + ), + Mi + ), + filter( e, t, n ) { + if ( void 0 === n ) return ! 0; + const i = t.getValue( { item: e } ); + return ( + 'string' == typeof i && + n && + i.toLowerCase().includes( String( n ).toLowerCase() ) + ); + }, + selection: 'single', + }, + { + name: O, + /* translators: DataViews operator name */ + label: ( 0, n.__ )( "Doesn't contain" ), + filterText: ( t, i ) => + ( 0, e.createInterpolateElement )( + ( 0, n.sprintf )( + /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title doesn't contain: Hello". */ + /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title doesn't contain: Hello". */ + ( 0, n.__ )( + "%1$s doesn't contain: %2$s" + ), + t.name, + i[ 0 ].label + ), + Mi + ), + filter( e, t, n ) { + if ( void 0 === n ) return ! 0; + const i = t.getValue( { item: e } ); + return ( + 'string' == typeof i && + n && + ! i.toLowerCase().includes( String( n ).toLowerCase() ) + ); + }, + selection: 'single', + }, + { + name: P, + /* translators: DataViews operator name */ + label: ( 0, n.__ )( 'Starts with' ), + filterText: ( t, i ) => + ( 0, e.createInterpolateElement )( + ( 0, n.sprintf )( + /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title starts with: Hello". */ + /* translators: 1: Filter name (e.g. "Title"). 2: Filter value (e.g. "Hello"): "Title starts with: Hello". */ + ( 0, n.__ )( + '%1$s starts with: %2$s' + ), + t.name, + i[ 0 ].label + ), + Mi + ), + filter( e, t, n ) { + if ( void 0 === n ) return ! 0; + const i = t.getValue( { item: e } ); + return ( + 'string' == typeof i && + n && + i.toLowerCase().startsWith( String( n ).toLowerCase() ) + ); + }, + selection: 'single', + }, + { + name: M, + /* translators: DataViews operator name */ + label: ( 0, n.__ )( 'On' ), + filterText: ( t, i ) => + ( 0, e.createInterpolateElement )( + ( 0, n.sprintf )( + /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is: 2024-01-01". */ + /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is: 2024-01-01". */ + ( 0, n.__ )( '%1$s is: %2$s' ), + t.name, + i[ 0 ].label + ), + Mi + ), + filter( e, t, n ) { + if ( void 0 === n ) return ! 0; + const i = ( 0, X.getDate )( n ), + r = ( 0, X.getDate )( t.getValue( { item: e } ) ); + return i.getTime() === r.getTime(); + }, + selection: 'single', + }, + { + name: T, + /* translators: DataViews operator name */ + label: ( 0, n.__ )( 'Not on' ), + filterText: ( t, i ) => + ( 0, e.createInterpolateElement )( + ( 0, n.sprintf )( + /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is not: 2024-01-01". */ + /* translators: 1: Filter name (e.g. "Date"). 2: Filter value (e.g. "2024-01-01"): "Date is not: 2024-01-01". */ + ( 0, n.__ )( '%1$s is not: %2$s' ), + t.name, + i[ 0 ].label + ), + Mi + ), + filter( e, t, n ) { + if ( void 0 === n ) return ! 0; + const i = ( 0, X.getDate )( n ), + r = ( 0, X.getDate )( t.getValue( { item: e } ) ); + return i.getTime() !== r.getTime(); + }, + selection: 'single', + }, + ], + Ri = e => Ai.find( t => t.name === e ), + Fi = { + render: Zn, + Edit: null, + sort: ( e, t, n ) => + 'number' == typeof e && 'number' == typeof t + ? ai( e, t, n ) + : Qn( e, t, n ), + enableSorting: ! 0, + enableGlobalSearch: ! 1, + defaultOperators: [ w, y ], + validOperators: Ai.map( e => e.name ), + format: {}, + getValueFormatted: ri, + validate: { required: Jn, elements: ii }, + }; + function Li( e, t, n ) { + const i = t.validate[ n ]; + if ( + i && + ( ( 'number' == typeof e && + ( 'integer' === ( r = t.type ) || 'number' === r ) ) || + ( 'string' == typeof e && + ( function ( e ) { + return 'date' === e || 'datetime' === e; + } )( t.type ) ) ) + ) + return { constraint: e, validate: i }; + var r; + } + function Di( e, t ) { + const n = e.isValid; + let i, r; + ! 0 === n?.required && + void 0 !== t.validate.required && + ( i = { constraint: ! 0, validate: t.validate.required } ), + ( ! 0 === n?.elements || + ( void 0 === n?.elements && ( e.elements || e.getElements ) ) ) && + void 0 !== t.validate.elements && + ( r = { constraint: ! 0, validate: t.validate.elements } ); + const o = Li( n?.min, t, 'min' ), + s = Li( n?.max, t, 'max' ), + a = n?.minLength; + let l; + 'number' == typeof a && + void 0 !== t.validate.minLength && + ( l = { constraint: a, validate: t.validate.minLength } ); + const c = n?.maxLength; + let u; + 'number' == typeof c && + void 0 !== t.validate.maxLength && + ( u = { constraint: c, validate: t.validate.maxLength } ); + const d = n?.pattern; + let f; + return ( + void 0 !== d && + void 0 !== t.validate.pattern && + ( f = { constraint: d, validate: t.validate.pattern } ), + { + required: i, + elements: r, + min: o, + max: s, + minLength: l, + maxLength: u, + pattern: f, + custom: n?.custom ?? t.validate.custom, + } + ); + } + function Bi( e ) { + return e.validOperators.reduce( ( e, t ) => { + const n = Ri( t ); + return n?.filter && ( e[ t ] = n.filter ), e; + }, {} ); + } + var zi = function ( e, t ) { + return { ...t.format, ...e.format }; + }; + function Wi( e ) { + return e.map( e => { + const t = ( function ( e ) { + const t = [ si, di, mi, pi, yi, Ci, Si, _i, Ei, ki, Ii, Vi, Oi ].find( + t => t?.type === e + ); + return t || Fi; + } )( e.type ), + n = + e.getValue || + ( ( i = e.id ), + ( { item: e } ) => { + const t = i.split( '.' ); + let n = e; + for ( const e of t ) n = n.hasOwnProperty( e ) ? n[ e ] : void 0; + return n; + } ); + var i; + return { + id: e.id, + label: e.label || e.id, + header: e.header || e.label || e.id, + description: e.description, + placeholder: e.placeholder, + getValue: n, + setValue: e.setValue || Un( e.id ), + elements: e.elements, + getElements: e.getElements, + hasElements: Hn( e ), + isVisible: e.isVisible, + isDisabled: + 'function' == typeof e.isDisabled + ? e.isDisabled + : () => !! e.isDisabled, + enableHiding: e.enableHiding ?? ! 0, + readOnly: e.readOnly ?? ! 1, + type: t.type, + render: e.render ?? t.render, + Edit: Gn( e, t.Edit ), + sort: function ( i, r, o ) { + const s = n( { item: i } ), + a = n( { item: r } ); + return e.sort ? e.sort( s, a, o ) : t.sort( s, a, o ); + }, + enableSorting: e.enableSorting ?? t.enableSorting, + enableGlobalSearch: e.enableGlobalSearch ?? t.enableGlobalSearch, + isValid: Di( e, t ), + filterBy: Kn( e, t.defaultOperators, t.validOperators ), + filter: Bi( t ), + format: zi( e, t ), + getValueFormatted: e.getValueFormatted ?? t.getValueFormatted, + }; + } ); + } + function $i( e = '' ) { + return s( e.trim().toLowerCase() ); + } + var Hi = []; + const qi = window.wp.compose; + var Gi = ( 0, e.createContext )( { + view: { type: D }, + onChangeView: () => {}, + fields: [], + data: [], + paginationInfo: { totalItems: 0, totalPages: 0 }, + selection: [], + onChangeSelection: () => {}, + setOpenedFilter: () => {}, + openedFilter: null, + getItemId: e => e.id, + isItemClickable: () => ! 0, + renderItemLink: void 0, + containerWidth: 0, + containerRef: ( 0, e.createRef )(), + resizeObserverRef: () => {}, + defaultLayouts: { list: {}, grid: {}, table: {} }, + filters: [], + isShowingFilter: ! 1, + setIsShowingFilter: () => {}, + hasInitiallyLoaded: ! 1, + config: { perPageSizes: [] }, + intersectionObserver: null, + } ); + Gi.displayName = 'DataViewsContext'; + var Yi = Gi, + Ki = ( 0, c.jsx )( l.SVG, { + xmlns: 'http://www.w3.org/2000/svg', + viewBox: '0 0 24 24', + children: ( 0, c.jsx )( l.Path, { + d: 'M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zM5 4.5h14c.3 0 .5.2.5.5v3.5h-15V5c0-.3.2-.5.5-.5zm8 5.5h6.5v3.5H13V10zm-1.5 3.5h-7V10h7v3.5zm-7 5.5v-4h7v4.5H5c-.3 0-.5-.2-.5-.5zm14.5.5h-6V15h6.5v4c0 .3-.2.5-.5.5z', + } ), + } ), + Ui = ( 0, c.jsx )( l.SVG, { + xmlns: 'http://www.w3.org/2000/svg', + viewBox: '0 0 24 24', + children: ( 0, c.jsx )( l.Path, { + fillRule: 'evenodd', + clipRule: 'evenodd', + d: 'M6 5.5h3a.5.5 0 01.5.5v3a.5.5 0 01-.5.5H6a.5.5 0 01-.5-.5V6a.5.5 0 01.5-.5zM4 6a2 2 0 012-2h3a2 2 0 012 2v3a2 2 0 01-2 2H6a2 2 0 01-2-2V6zm11-.5h3a.5.5 0 01.5.5v3a.5.5 0 01-.5.5h-3a.5.5 0 01-.5-.5V6a.5.5 0 01.5-.5zM13 6a2 2 0 012-2h3a2 2 0 012 2v3a2 2 0 01-2 2h-3a2 2 0 01-2-2V6zm5 8.5h-3a.5.5 0 00-.5.5v3a.5.5 0 00.5.5h3a.5.5 0 00.5-.5v-3a.5.5 0 00-.5-.5zM15 13a2 2 0 00-2 2v3a2 2 0 002 2h3a2 2 0 002-2v-3a2 2 0 00-2-2h-3zm-9 1.5h3a.5.5 0 01.5.5v3a.5.5 0 01-.5.5H6a.5.5 0 01-.5-.5v-3a.5.5 0 01.5-.5zM4 15a2 2 0 012-2h3a2 2 0 012 2v3a2 2 0 01-2 2H6a2 2 0 01-2-2v-3z', + } ), + } ), + Xi = ( 0, c.jsx )( l.SVG, { + xmlns: 'http://www.w3.org/2000/svg', + viewBox: '0 0 24 24', + children: ( 0, c.jsx )( l.Path, { + d: 'M4 8.8h8.9V7.2H4v1.6zm0 7h8.9v-1.5H4v1.5zM18 13c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0-3c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2z', + } ), + } ), + Zi = ( 0, c.jsx )( l.SVG, { + xmlns: 'http://www.w3.org/2000/svg', + viewBox: '0 0 24 24', + children: ( 0, c.jsx )( l.Path, { + d: 'M11.1 15.8H20v-1.5h-8.9v1.5zm0-8.6v1.5H20V7.2h-8.9zM6 13c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0-7c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z', + } ), + } ), + Qi = ( 0, c.jsx )( l.SVG, { + xmlns: 'http://www.w3.org/2000/svg', + viewBox: '0 0 24 24', + children: ( 0, c.jsx )( l.Path, { + fillRule: 'evenodd', + clipRule: 'evenodd', + d: 'M12 18.5a6.5 6.5 0 1 1 0-13 6.5 6.5 0 0 1 0 13ZM4 12a8 8 0 1 1 16 0 8 8 0 0 1-16 0Zm9 1V8h-1.5v3.5h-2V13H13Z', + } ), + } ); + const Ji = window.wp.keycodes; + function er( { + selection: e, + onChangeSelection: i, + item: r, + getItemId: o, + titleField: s, + disabled: a, + ...l + } ) { + const u = o( r ), + d = e.includes( u ), + f = ! a && d, + m = s?.getValue?.( { item: r } ) || ( 0, n.__ )( '(no title)' ); + return ( 0, c.jsx )( t.CheckboxControl, { + className: 'dataviews-selection-checkbox', + 'aria-label': m, + 'aria-disabled': a, + checked: f, + onChange: () => { + a || i( d ? e.filter( e => u !== e ) : [ ...e, u ] ); + }, + ...l, + } ); + } + var tr = ( 0, c.jsx )( l.SVG, { + xmlns: 'http://www.w3.org/2000/svg', + viewBox: '0 0 24 24', + children: ( 0, c.jsx )( l.Path, { + d: 'M13 19h-2v-2h2v2zm0-6h-2v-2h2v2zm0-6h-2V5h2v2z', + } ), + } ); + const nr = window.wp.data; + var { Menu: ir, kebabCase: rr } = $( t.privateApis ); + function or( { action: e, onClick: n, items: i, variant: r } ) { + const o = 'string' == typeof e.label ? e.label : e.label( i ); + return ( 0, c.jsx )( t.Button, { + disabled: !! e.disabled, + accessibleWhenDisabled: ! 0, + size: 'compact', + variant: r, + onClick: n, + children: o, + } ); + } + function sr( { action: e, onClick: t, items: n } ) { + const i = 'string' == typeof e.label ? e.label : e.label( n ); + return ( 0, c.jsx )( ir.Item, { + disabled: e.disabled, + onClick: t, + children: ( 0, c.jsx )( ir.ItemLabel, { children: i } ), + } ); + } + function ar( { action: e, items: n, closeModal: i } ) { + const r = 'string' == typeof e.label ? e.label : e.label( n ), + o = 'function' == typeof e.modalHeader ? e.modalHeader( n ) : e.modalHeader; + return ( 0, c.jsx )( t.Modal, { + title: o || r, + __experimentalHideHeader: !! e.hideModalHeader, + onRequestClose: i, + focusOnMount: e.modalFocusOnMount ?? ! 0, + size: e.modalSize || 'medium', + overlayClassName: `dataviews-action-modal dataviews-action-modal__${ rr( + e.id + ) }`, + children: ( 0, c.jsx )( e.RenderModal, { items: n, closeModal: i } ), + } ); + } + function lr( { actions: t, item: n, registry: i, setActiveModalAction: r } ) { + const { primaryActions: o, regularActions: s } = ( 0, e.useMemo )( + () => + t.reduce( + ( e, t ) => ( + ( t.isPrimary ? e.primaryActions : e.regularActions ).push( t ), + e + ), + { primaryActions: [], regularActions: [] } + ), + [ t ] + ), + a = e => + e.map( e => + ( 0, c.jsx )( + sr, + { + action: e, + onClick: () => { + 'RenderModal' in e + ? r( e ) + : e.callback( [ n ], { registry: i } ); + }, + items: [ n ], + }, + e.id + ) + ); + return ( 0, c.jsxs )( ir.Group, { children: [ a( o ), a( s ) ] } ); + } + function cr( { item: t, actions: n, isCompact: i } ) { + const r = ( 0, nr.useRegistry )(), + { primaryActions: o, eligibleActions: s } = ( 0, e.useMemo )( () => { + const e = n.filter( e => ! e.isEligible || e.isEligible( t ) ); + return { primaryActions: e.filter( e => e.isPrimary ), eligibleActions: e }; + }, [ n, t ] ), + a = ( 0, qi.useViewportMatch )( 'medium', '<' ); + return i + ? ( 0, c.jsx )( ur, { item: t, actions: s, isSmall: ! 0, registry: r } ) + : ( 0, c.jsxs )( Pe, { + direction: 'row', + justify: 'flex-end', + className: 'dataviews-item-actions', + style: { flexShrink: 0, width: 'auto' }, + children: [ + ( 0, c.jsx )( dr, { item: t, actions: o, registry: r } ), + ( o.length < s.length || a ) && + ( 0, c.jsx )( ur, { item: t, actions: s, registry: r } ), + ], + } ); + } + function ur( { item: i, actions: r, isSmall: o, registry: s } ) { + const [ a, l ] = ( 0, e.useState )( null ); + return ( 0, c.jsxs )( c.Fragment, { + children: [ + ( 0, c.jsxs )( ir, { + placement: 'bottom-end', + children: [ + ( 0, c.jsx )( ir.TriggerButton, { + render: ( 0, c.jsx )( t.Button, { + size: o ? 'small' : 'compact', + icon: tr, + label: ( 0, n.__ )( 'Actions' ), + accessibleWhenDisabled: ! 0, + disabled: ! r.length, + className: 'dataviews-all-actions-button', + } ), + } ), + ( 0, c.jsx )( ir.Popover, { + children: ( 0, c.jsx )( lr, { + actions: r, + item: i, + registry: s, + setActiveModalAction: l, + } ), + } ), + ], + } ), + !! a && + ( 0, c.jsx )( ar, { + action: a, + items: [ i ], + closeModal: () => l( null ), + } ), + ], + } ); + } + function dr( { item: t, actions: n, registry: i, buttonVariant: r } ) { + const [ o, s ] = ( 0, e.useState )( null ); + return ( 0, qi.useViewportMatch )( 'medium', '<' ) + ? null + : Array.isArray( n ) && 0 !== n.length + ? ( 0, c.jsxs )( c.Fragment, { + children: [ + n.map( e => + ( 0, c.jsx )( + or, + { + action: e, + onClick: () => { + 'RenderModal' in e + ? s( e ) + : e.callback( [ t ], { registry: i } ); + }, + items: [ t ], + variant: r, + }, + e.id + ) + ), + !! o && + ( 0, c.jsx )( ar, { + action: o, + items: [ t ], + closeModal: () => s( null ), + } ), + ], + } ) + : null; + } + var fr = ( 0, c.jsx )( l.SVG, { + xmlns: 'http://www.w3.org/2000/svg', + viewBox: '0 0 24 24', + children: ( 0, c.jsx )( l.Path, { + d: 'M12 13.06l3.712 3.713 1.061-1.06L13.061 12l3.712-3.712-1.06-1.06L12 10.938 8.288 7.227l-1.061 1.06L10.939 12l-3.712 3.712 1.06 1.061L12 13.061z', + } ), + } ); + function mr( { action: t, items: n, ActionTriggerComponent: i } ) { + const [ r, o ] = ( 0, e.useState )( ! 1 ), + s = { + action: t, + onClick: () => { + o( ! 0 ); + }, + items: n, + }; + return ( 0, c.jsxs )( c.Fragment, { + children: [ + ( 0, c.jsx )( i, { ...s } ), + r && + ( 0, c.jsx )( ar, { action: t, items: n, closeModal: () => o( ! 1 ) } ), + ], + } ); + } + function pr( t, n ) { + return ( 0, e.useMemo )( + () => t.some( e => e.supportsBulk && ( ! e.isEligible || e.isEligible( n ) ) ), + [ t, n ] + ); + } + function gr( t, n ) { + return ( 0, e.useMemo )( + () => + n.some( e => + t.some( t => t.supportsBulk && ( ! t.isEligible || t.isEligible( e ) ) ) + ), + [ t, n ] + ); + } + function hr( { + selection: i, + onChangeSelection: r, + data: o, + actions: s, + getItemId: a, + disableSelectAll: l = ! 1, + } ) { + const u = ( 0, e.useMemo )( + () => + o.filter( e => + s.some( + t => t.supportsBulk && ( ! t.isEligible || t.isEligible( e ) ) + ) + ), + [ o, s ] + ), + d = o.filter( e => i.includes( a( e ) ) && u.includes( e ) ), + f = i.length > 0, + m = d.length === u.length; + return l + ? ( 0, c.jsx )( t.CheckboxControl, { + className: 'dataviews-view-table-selection-checkbox', + checked: f, + disabled: ! f, + onChange: () => { + r( [] ); + }, + 'aria-label': ( 0, n.__ )( 'Deselect all' ), + } ) + : ( 0, c.jsx )( t.CheckboxControl, { + className: 'dataviews-view-table-selection-checkbox', + checked: m, + indeterminate: ! m && !! d.length, + onChange: () => { + r( m ? [] : u.map( e => a( e ) ) ); + }, + 'aria-label': m + ? ( 0, n.__ )( 'Deselect all' ) + : ( 0, n.__ )( 'Select all' ), + } ); + } + function vr( { action: e, onClick: n, isBusy: i, items: r } ) { + const o = 'string' == typeof e.label ? e.label : e.label( r ); + return ( 0, qi.useViewportMatch )( 'medium', '<' ) + ? ( 0, c.jsx )( t.Button, { + disabled: i, + accessibleWhenDisabled: ! 0, + label: o, + icon: e.icon, + size: 'compact', + onClick: n, + isBusy: i, + } ) + : ( 0, c.jsx )( t.Button, { + disabled: i, + accessibleWhenDisabled: ! 0, + size: 'compact', + onClick: n, + isBusy: i, + children: o, + } ); + } + var br = []; + function wr( { + action: t, + selectedItems: n, + actionInProgress: i, + setActionInProgress: r, + } ) { + const o = ( 0, nr.useRegistry )(), + s = ( 0, e.useMemo )( + () => n.filter( e => ! t.isEligible || t.isEligible( e ) ), + [ t, n ] + ); + return 'RenderModal' in t + ? ( 0, c.jsx )( mr, { action: t, items: s, ActionTriggerComponent: vr }, t.id ) + : ( 0, c.jsx )( + vr, + { + action: t, + onClick: async () => { + r( t.id ), await t.callback( n, { registry: o } ), r( null ); + }, + items: s, + isBusy: i === t.id, + }, + t.id + ); + } + function yr( e, i, r, o, s, a, l, u, d, f, m ) { + const p = ( function ( e, t, i, r = ! 1 ) { + return e > 0 + ? ( 0, n.sprintf )( + /* translators: %d: number of items. */ + /* translators: %d: number of items. */ + ( 0, n._n )( '%d Item selected', '%d Items selected', e ), + e + ) + : r || i <= t + ? ( 0, n.sprintf )( + /* translators: %d: number of items. */ + /* translators: %d: number of items. */ + ( 0, n._n )( '%d Item', '%d Items', i ), + i + ) + : ( 0, n.sprintf )( + /* translators: %1$d: number of items. %2$d: total number of items. */ + /* translators: %1$d: number of items. %2$d: total number of items. */ + ( 0, n._n )( '%1$d of %2$d Item', '%1$d of %2$d Items', i ), + t, + i + ); + } )( s.length, e.length, m.totalItems, o ); + return ( 0, c.jsxs )( Pe, { + direction: 'row', + className: 'dataviews-bulk-actions-footer__container', + gap: 'md', + align: 'center', + children: [ + ( 0, c.jsx )( hr, { + selection: s, + onChangeSelection: f, + data: e, + actions: i, + getItemId: r, + disableSelectAll: o, + } ), + ( 0, c.jsx )( 'span', { + className: 'dataviews-bulk-actions-footer__item-count', + children: p, + } ), + ( 0, c.jsxs )( Pe, { + direction: 'row', + className: 'dataviews-bulk-actions-footer__action-buttons', + gap: 'xs', + children: [ + a.map( e => + ( 0, c.jsx )( + wr, + { + action: e, + selectedItems: l, + actionInProgress: u, + setActionInProgress: d, + }, + e.id + ) + ), + l.length > 0 && + ( 0, c.jsx )( t.Button, { + icon: fr, + showTooltip: ! 0, + tooltipPosition: 'top', + size: 'compact', + label: ( 0, n.__ )( 'Cancel' ), + disabled: !! u, + accessibleWhenDisabled: ! 1, + onClick: () => { + f( br ); + }, + } ), + ], + } ), + ], + } ); + } + function xr( { + selection: t, + actions: n, + onChangeSelection: i, + data: r, + getItemId: o, + isInfiniteScroll: s, + paginationInfo: a, + } ) { + const [ l, c ] = ( 0, e.useState )( null ), + u = ( 0, e.useRef )( void 0 ), + d = ( 0, qi.useViewportMatch )( 'medium', '<' ), + f = ( 0, e.useMemo )( () => n.filter( e => e.supportsBulk ), [ n ] ), + m = ( 0, e.useMemo )( + () => r.filter( e => f.some( t => ! t.isEligible || t.isEligible( e ) ) ), + [ r, f ] + ), + p = ( 0, e.useMemo )( + () => r.filter( e => t.includes( o( e ) ) && m.includes( e ) ), + [ t, r, o, m ] + ), + g = ( 0, e.useMemo )( + () => + n.filter( + e => + e.supportsBulk && + ( ! d || e.icon ) && + p.some( t => ! e.isEligible || e.isEligible( t ) ) + ), + [ n, p, d ] + ); + return l + ? ( u.current || ( u.current = yr( r, n, o, s, t, g, p, l, c, i, a ) ), + u.current ) + : ( u.current && ( u.current = void 0 ), + yr( r, n, o, s, t, g, p, l, c, i, a ) ); + } + function Cr() { + const { + data: t, + selection: n, + actions: i = br, + onChangeSelection: r, + getItemId: o, + paginationInfo: s, + view: a, + } = ( 0, e.useContext )( Yi ); + return ( 0, c.jsx )( xr, { + selection: n, + onChangeSelection: r, + data: t, + actions: i, + getItemId: o, + isInfiniteScroll: !! a.infiniteScrollEnabled, + paginationInfo: s, + } ); + } + var Sr = ( 0, c.jsx )( l.SVG, { + xmlns: 'http://www.w3.org/2000/svg', + viewBox: '0 0 24 24', + children: ( 0, c.jsx )( l.Path, { + d: 'M10 17.5H14V16H10V17.5ZM6 6V7.5H18V6H6ZM8 12.5H16V11H8V12.5Z', + } ), + } ), + _r = ( 0, c.jsx )( l.SVG, { + xmlns: 'http://www.w3.org/2000/svg', + viewBox: '0 0 24 24', + children: ( 0, c.jsx )( l.Path, { + d: 'M20 11.2H6.8l3.7-3.7-1-1L3.9 12l5.6 5.5 1-1-3.7-3.7H20z', + } ), + } ), + jr = ( 0, c.jsx )( l.SVG, { + xmlns: 'http://www.w3.org/2000/svg', + viewBox: '0 0 24 24', + children: ( 0, c.jsx )( l.Path, { + d: 'm14.5 6.5-1 1 3.7 3.7H4v1.6h13.2l-3.7 3.7 1 1 5.6-5.5z', + } ), + } ); + function Er( e, t ) { + const n = [ e?.titleField, e?.mediaField, e?.descriptionField ].filter( Boolean ); + return t.filter( + e => ! n.includes( e.id ) && 'media' !== e.type && ! 1 !== e.enableHiding + ); + } + var { Menu: kr } = $( t.privateApis ); + function Ir( { children: t } ) { + return e.Children.toArray( t ) + .filter( Boolean ) + .map( ( t, n ) => + ( 0, c.jsxs )( + e.Fragment, + { children: [ n > 0 && ( 0, c.jsx )( kr.Separator, {} ), t ] }, + n + ) + ); + } + var Vr = ( 0, e.forwardRef )( function ( + { + fieldId: i, + view: r, + fields: o, + onChangeView: s, + onHide: a, + setOpenedFilter: l, + canMove: u = ! 0, + canInsertLeft: d = ! 0, + canInsertRight: f = ! 0, + }, + m + ) { + const p = r.fields ?? [], + g = p?.indexOf( i ), + h = r.sort?.field === i; + let v = ! 1, + b = ! 1, + w = ! 1, + y = []; + const x = o.find( e => e.id === i ), + { setIsShowingFilter: C } = ( 0, e.useContext )( Yi ); + if ( ! x ) return null; + ( v = ! 1 !== x.enableHiding ), ( b = ! 1 !== x.enableSorting ); + const S = x.header; + if ( + ( ( y = ( !! x.filterBy && x.filterBy?.operators ) || [] ), + ( w = ! ( + r.filters?.some( e => i === e.field ) || + ( ! x.hasElements && ! x.Edit ) || + ! 1 === x.filterBy || + x.filterBy?.isPrimary + ) ), + ! ( b || u || v || w ) ) + ) + return S; + const _ = Er( r, o ).filter( e => ! p.includes( e.id ) ), + j = ( d || f ) && !! _.length, + E = ( 0, n.isRTL )(); + return ( 0, c.jsxs )( kr, { + children: [ + ( 0, c.jsxs )( kr.TriggerButton, { + render: ( 0, c.jsx )( t.Button, { + size: 'compact', + className: 'dataviews-view-table-header-button', + ref: m, + variant: 'tertiary', + } ), + children: [ + S, + r.sort && + h && + ( 0, c.jsx )( 'span', { + 'aria-hidden': 'true', + children: A[ r.sort.direction ], + } ), + ], + } ), + ( 0, c.jsx )( kr.Popover, { + style: { minWidth: '240px' }, + children: ( 0, c.jsxs )( Ir, { + children: [ + b && + ( 0, c.jsx )( kr.Group, { + children: N.map( e => { + const t = r.sort && h && r.sort.direction === e, + n = `${ i }-${ e }`; + return ( 0, c.jsx )( + kr.RadioItem, + { + name: 'view-table-sorting', + value: n, + checked: t, + onChange: () => { + s( { + ...r, + sort: { + field: i, + direction: e, + }, + showLevels: ! 1, + } ); + }, + children: ( 0, c.jsx )( kr.ItemLabel, { + children: F[ e ], + } ), + }, + n + ); + } ), + } ), + w && + ( 0, c.jsx )( kr.Group, { + children: ( 0, c.jsx )( kr.Item, { + prefix: ( 0, c.jsx )( t.Icon, { icon: Sr } ), + onClick: () => { + l( i ), + C( ! 0 ), + s( { + ...r, + page: 1, + filters: [ + ...( r.filters || [] ), + { + field: i, + value: void 0, + operator: y[ 0 ], + }, + ], + } ); + }, + children: ( 0, c.jsx )( kr.ItemLabel, { + children: ( 0, n.__ )( 'Add filter' ), + } ), + } ), + } ), + ( u || v || j ) && + x && + ( 0, c.jsxs )( kr.Group, { + children: [ + u && + ( 0, c.jsx )( kr.Item, { + prefix: ( 0, c.jsx )( t.Icon, { + icon: _r, + } ), + disabled: E ? g >= p.length - 1 : g < 1, + onClick: () => { + const e = E ? g + 1 : g - 1, + t = [ ...p ]; + t.splice( g, 1 ), + t.splice( e, 0, i ), + s( { ...r, fields: t } ); + }, + children: ( 0, c.jsx )( kr.ItemLabel, { + children: ( 0, n.__ )( + 'Move left' + ), + } ), + } ), + u && + ( 0, c.jsx )( kr.Item, { + prefix: ( 0, c.jsx )( t.Icon, { + icon: jr, + } ), + disabled: E ? g < 1 : g >= p.length - 1, + onClick: () => { + const e = E ? g - 1 : g + 1, + t = [ ...p ]; + t.splice( g, 1 ), + t.splice( e, 0, i ), + s( { ...r, fields: t } ); + }, + children: ( 0, c.jsx )( kr.ItemLabel, { + children: ( 0, n.__ )( + 'Move right' + ), + } ), + } ), + d && + !! _.length && + ( 0, c.jsxs )( kr, { + children: [ + ( 0, c.jsx )( + kr.SubmenuTriggerItem, + { + children: ( 0, c.jsx )( + kr.ItemLabel, + { + children: ( 0, + n.__ )( + 'Insert left' + ), + } + ), + } + ), + ( 0, c.jsx )( kr.Popover, { + children: _.map( e => { + const t = E ? g + 1 : g; + return ( 0, c.jsx )( + kr.Item, + { + onClick: () => { + s( { + ...r, + fields: [ + ...p.slice( + 0, + t + ), + e.id, + ...p.slice( + t + ), + ], + } ); + }, + children: ( 0, + c.jsx )( + kr.ItemLabel, + { + children: + e.label, + } + ), + }, + e.id + ); + } ), + } ), + ], + } ), + f && + !! _.length && + ( 0, c.jsxs )( kr, { + children: [ + ( 0, c.jsx )( + kr.SubmenuTriggerItem, + { + children: ( 0, c.jsx )( + kr.ItemLabel, + { + children: ( 0, + n.__ )( + 'Insert right' + ), + } + ), + } + ), + ( 0, c.jsx )( kr.Popover, { + children: _.map( e => { + const t = E ? g : g + 1; + return ( 0, c.jsx )( + kr.Item, + { + onClick: () => { + s( { + ...r, + fields: [ + ...p.slice( + 0, + t + ), + e.id, + ...p.slice( + t + ), + ], + } ); + }, + children: ( 0, + c.jsx )( + kr.ItemLabel, + { + children: + e.label, + } + ), + }, + e.id + ); + } ), + } ), + ], + } ), + v && + x && + ( 0, c.jsx )( kr.Item, { + prefix: ( 0, c.jsx )( t.Icon, { + icon: Wn, + } ), + onClick: () => { + a( x ), + s( { + ...r, + fields: p.filter( + e => e !== i + ), + } ); + }, + children: ( 0, c.jsx )( kr.ItemLabel, { + children: ( 0, n.__ )( + 'Hide column' + ), + } ), + } ), + ], + } ), + ], + } ), + } ), + ], + } ); + } ), + Or = Vr; + function Pr( { + item: t, + isItemClickable: n, + onClickItem: i, + renderItemLink: r, + className: o, + children: s, + ...a + } ) { + if ( ! n( t ) ) return ( 0, c.jsx )( 'div', { className: o, ...a, children: s } ); + if ( r ) { + const n = r( { + item: t, + className: `${ o } ${ o }--clickable`, + ...a, + children: s, + } ); + return ( 0, e.cloneElement )( n, { + onClick: e => { + e.stopPropagation(), n.props.onClick && n.props.onClick( e ); + }, + onKeyDown: e => { + ( 'Enter' !== e.key && '' !== e.key && ' ' !== e.key ) || + ( e.stopPropagation(), + n.props.onKeyDown && n.props.onKeyDown( e ) ); + }, + } ); + } + const l = ( function ( { + item: e, + isItemClickable: t, + onClickItem: n, + className: i, + } ) { + return t( e ) && n + ? { + className: i ? `${ i } ${ i }--clickable` : void 0, + role: 'button', + tabIndex: 0, + onClick: t => { + t.stopPropagation(), n( e ); + }, + onKeyDown: t => { + ( 'Enter' !== t.key && '' !== t.key && ' ' !== t.key ) || + ( t.stopPropagation(), n( e ) ); + }, + } + : { className: i }; + } )( { item: t, isItemClickable: n, onClickItem: i, className: o } ); + return ( 0, c.jsx )( 'div', { ...l, ...a, children: s } ); + } + var Mr = function ( { + item: e, + level: t, + titleField: n, + mediaField: i, + descriptionField: r, + onClickItem: o, + renderItemLink: s, + isItemClickable: a, + } ) { + return ( 0, c.jsxs )( Pe, { + direction: 'row', + gap: 'md', + align: 'flex-start', + justify: 'flex-start', + children: [ + i && + ( 0, c.jsx )( Pr, { + item: e, + isItemClickable: a, + onClickItem: o, + renderItemLink: s, + className: + 'dataviews-view-table__cell-content-wrapper dataviews-column-primary__media', + 'aria-label': + a( e ) && ( o || s ) && n + ? n.getValue?.( { item: e } ) + : void 0, + children: ( 0, c.jsx )( i.render, { + item: e, + field: i, + config: { sizes: '32px' }, + } ), + } ), + ( 0, c.jsxs )( Pe, { + direction: 'column', + align: 'flex-start', + className: 'dataviews-view-table__primary-column-content', + children: [ + n && + ( 0, c.jsxs )( Pr, { + item: e, + isItemClickable: a, + onClickItem: o, + renderItemLink: s, + className: + 'dataviews-view-table__cell-content-wrapper dataviews-title-field', + children: [ + void 0 !== t && + t > 0 && + ( 0, c.jsxs )( 'span', { + className: 'dataviews-view-table__level', + children: [ + Array( t ).fill( '—' ).join( ' ' ), + ' ', + ], + } ), + ( 0, c.jsx )( n.render, { item: e, field: n } ), + ], + } ), + r && ( 0, c.jsx )( r.render, { item: e, field: r } ), + ], + } ), + ], + } ); + }; + function Tr( e, t ) { + return e.reduce( ( e, n ) => { + const i = t.getValue( { item: n } ); + return e.has( i ) || e.set( i, [] ), e.get( i )?.push( n ), e; + }, new Map() ); + } + var Nr = ( 0, c.jsx )( l.SVG, { + xmlns: 'http://www.w3.org/2000/svg', + viewBox: '0 0 24 24', + children: ( 0, c.jsx )( l.Path, { + d: 'M16.5 7.5 10 13.9l-2.5-2.4-1 1 3.5 3.6 7.5-7.6z', + } ), + } ); + function Ar( { field: e, isVisible: n, onToggleVisibility: i } ) { + return ( 0, c.jsx )( t.__experimentalItem, { + onClick: e.enableHiding ? i : void 0, + children: ( 0, c.jsxs )( Pe, { + direction: 'row', + gap: 'sm', + justify: 'flex-start', + align: 'center', + children: [ + ( 0, c.jsx )( 'div', { + style: { height: 24, width: 24 }, + children: n && ( 0, c.jsx )( t.Icon, { icon: Nr } ), + } ), + ( 0, c.jsx )( 'span', { + className: 'dataviews-view-config__label', + children: e.label, + } ), + ], + } ), + } ); + } + function Rr( { showLabel: i = ! 0 } ) { + const { view: r, fields: o, onChangeView: s } = ( 0, e.useContext )( Yi ), + a = Er( r, o ); + if ( ! a?.length ) return null; + const l = o.find( e => e.id === r.titleField ), + u = o.find( e => e.id === r.mediaField ), + d = o.find( e => e.id === r.descriptionField ), + f = [ + { field: l, isVisibleFlag: 'showTitle' }, + { field: u, isVisibleFlag: 'showMedia' }, + { field: d, isVisibleFlag: 'showDescription' }, + ].filter( ( { field: e } ) => !! e ), + m = r.fields ?? [], + p = a.filter( e => m.includes( e.id ) ).length, + g = f.filter( ( { isVisibleFlag: e } ) => r[ e ] ?? ! 0 ), + h = g.length + p, + v = 1 === h && 1 === g.length; + return ( 0, c.jsxs )( Pe, { + direction: 'column', + className: 'dataviews-field-control', + children: [ + i && + ( 0, c.jsx )( t.BaseControl.VisualLabel, { + children: ( 0, n.__ )( 'Properties' ), + } ), + ( 0, c.jsx )( Pe, { + direction: 'column', + className: 'dataviews-view-config__properties', + children: ( 0, c.jsxs )( t.__experimentalItemGroup, { + isBordered: ! 0, + isSeparated: ! 0, + size: 'medium', + children: [ + f.map( ( { field: e, isVisibleFlag: t } ) => { + const n = r[ t ] ?? ! 0, + i = v && n ? { ...e, enableHiding: ! 1 } : e; + return ( 0, c.jsx )( + Ar, + { + field: i, + isVisible: n, + onToggleVisibility: () => { + s( { ...r, [ t ]: ! n } ); + }, + }, + e.id + ); + } ), + a.map( e => { + const t = m.includes( e.id ), + n = 1 === h && t ? { ...e, enableHiding: ! 1 } : e; + return ( 0, c.jsx )( + Ar, + { + field: n, + isVisible: t, + onToggleVisibility: () => { + s( { + ...r, + fields: t + ? m.filter( t => t !== e.id ) + : [ ...m, e.id ], + } ); + }, + }, + e.id + ); + } ), + ], + } ), + } ), + ], + } ); + } + function Fr( t, n = { delay: 400 } ) { + const [ i, r ] = ( 0, e.useState )( ! 1 ); + return ( + ( 0, e.useEffect )( () => { + if ( ! t ) return; + const e = setTimeout( () => { + r( ! 0 ); + }, n.delay ); + return () => { + clearTimeout( e ), r( ! 1 ); + }; + }, [ t, n.delay ] ), + i + ); + } + function Lr( e, t ) { + return e || ( 'integer' === t || 'number' === t ? 'end' : void 0 ); + } + function Dr( { item: e, fields: t, column: n, align: i } ) { + const r = t.find( e => e.id === n ); + if ( ! r ) return null; + const o = Te( 'dataviews-view-table__cell-content-wrapper', { + 'dataviews-view-table__cell-align-end': 'end' === i, + 'dataviews-view-table__cell-align-center': 'center' === i, + } ); + return ( 0, c.jsx )( 'div', { + className: o, + children: ( 0, c.jsx )( r.render, { item: e, field: r } ), + } ); + } + function Br( { + hasBulkActions: t, + item: n, + level: i, + actions: r, + fields: o, + id: s, + view: a, + titleField: l, + mediaField: u, + descriptionField: d, + selection: f, + getItemId: m, + isItemClickable: p, + onClickItem: g, + renderItemLink: h, + onChangeSelection: v, + isActionsColumnSticky: b, + posinset: w, + } ) { + const { paginationInfo: y } = ( 0, e.useContext )( Yi ), + x = pr( r, n ), + C = x && f.includes( s ), + { + showTitle: S = ! 0, + showMedia: _ = ! 0, + showDescription: j = ! 0, + infiniteScrollEnabled: E, + } = a, + k = ( 0, e.useRef )( ! 1 ), + I = a.fields ?? [], + V = ( l && S ) || ( u && _ ) || ( d && j ); + return ( 0, c.jsxs )( 'tr', { + className: Te( 'dataviews-view-table__row', { + 'is-selected': x && C, + 'has-bulk-actions': x, + } ), + onTouchStart: () => { + k.current = ! 0; + }, + 'aria-setsize': E ? y.totalItems : void 0, + 'aria-posinset': w, + role: E ? 'article' : void 0, + onMouseDown: e => { + const t = ( 0, Ji.isAppleOS )() ? e.metaKey : e.ctrlKey; + 0 === e.button && + t && + window.navigator.userAgent.toLowerCase().includes( 'firefox' ) && + e?.preventDefault(); + }, + onClick: e => { + x && + ( ( 0, Ji.isAppleOS )() ? e.metaKey : e.ctrlKey ) && + ! k.current && + 'Range' !== document.getSelection()?.type && + v( f.includes( s ) ? f.filter( e => s !== e ) : [ ...f, s ] ); + }, + children: [ + t && + ( 0, c.jsx )( 'td', { + className: 'dataviews-view-table__checkbox-column', + children: ( 0, c.jsx )( 'div', { + className: 'dataviews-view-table__cell-content-wrapper', + children: ( 0, c.jsx )( er, { + item: n, + selection: f, + onChangeSelection: v, + getItemId: m, + titleField: l, + disabled: ! x, + } ), + } ), + } ), + V && + ( 0, c.jsx )( 'td', { + children: ( 0, c.jsx )( Mr, { + item: n, + level: i, + titleField: S ? l : void 0, + mediaField: _ ? u : void 0, + descriptionField: j ? d : void 0, + isItemClickable: p, + onClickItem: g, + renderItemLink: h, + } ), + } ), + I.map( e => { + const { + width: t, + maxWidth: i, + minWidth: r, + align: s, + } = a.layout?.styles?.[ e ] ?? {}, + l = o.find( t => t.id === e ), + u = Lr( s, l?.type ); + return ( 0, c.jsx )( + 'td', + { + style: { width: t, maxWidth: i, minWidth: r }, + children: ( 0, c.jsx )( Dr, { + fields: o, + item: n, + column: e, + align: u, + } ), + }, + e + ); + } ), + !! r?.length && + ( 0, c.jsx )( 'td', { + className: Te( 'dataviews-view-table__actions-column', { + 'dataviews-view-table__actions-column--sticky': ! 0, + 'dataviews-view-table__actions-column--stuck': b, + } ), + onClick: e => e.stopPropagation(), + children: ( 0, c.jsx )( cr, { item: n, actions: r } ), + } ), + ], + } ); + } + const zr = []; + let Wr; + function $r( e ) { + const t = ( t, n ) => { + const i = ne( Hr ).current; + let r; + try { + Wr = i; + for ( const e of zr ) e.before( i ); + r = e( t, n ); + for ( const e of zr ) e.after( i ); + i.didInitialize = ! 0; + } finally { + Wr = void 0; + } + return r; + }; + return ( t.displayName = e.displayName || e.name ), t; + } + function Hr() { + return { didInitialize: ! 1 }; + } + const qr = 'undefined' != typeof document ? J.useLayoutEffect : () => {}, + Gr = J.createContext( void 0 ); + function Yr( e ) { + const t = J.useContext( Gr ); + if ( void 0 === t && ! e ) throw new Error( Q( 72 ) ); + return t; + } + function Kr( e, t, n, i ) { + return ( + e.addEventListener( t, n, i ), + () => { + e.removeEventListener( t, n, i ); + } + ); + } + function Ur( ...e ) { + return () => { + for ( let t = 0; t < e.length; t += 1 ) { + const n = e[ t ]; + n && n(); + } + }; + } + function Xr( e ) { + return e?.ownerDocument || document; + } + const Zr = { ...ee }, + Qr = Zr.useInsertionEffect, + Jr = Qr && Qr !== Zr.useLayoutEffect ? Qr : e => e(); + function eo( e ) { + const t = ne( to ).current; + return ( t.next = e ), Jr( t.effect ), t.trampoline; + } + function to() { + const e = { + next: void 0, + callback: no, + trampoline: ( ...t ) => e.callback?.( ...t ), + effect: () => { + e.callback = e.next; + }, + }; + return e; + } + function no() {} + const io = []; + function ro( e ) { + J.useEffect( e, io ); + } + class oo { + static create() { + return new oo(); + } + currentId = 0; + start( e, t ) { + this.clear(), + ( this.currentId = setTimeout( () => { + ( this.currentId = 0 ), t(); + }, e ) ); + } + isStarted() { + return 0 !== this.currentId; + } + clear = () => { + 0 !== this.currentId && + ( clearTimeout( this.currentId ), ( this.currentId = 0 ) ); + }; + disposeEffect = () => this.clear; + } + function so() { + const e = ne( oo.create ).current; + return ro( e.disposeEffect ), e; + } + function ao() { + return 'undefined' != typeof window; + } + function lo( e ) { + return fo( e ) ? ( e.nodeName || '' ).toLowerCase() : '#document'; + } + function co( e ) { + var t; + return ( + ( null == e || null == ( t = e.ownerDocument ) ? void 0 : t.defaultView ) || + window + ); + } + function uo( e ) { + var t; + return null == ( t = ( fo( e ) ? e.ownerDocument : e.document ) || window.document ) + ? void 0 + : t.documentElement; + } + function fo( e ) { + return !! ao() && ( e instanceof Node || e instanceof co( e ).Node ); + } + function mo( e ) { + return !! ao() && ( e instanceof Element || e instanceof co( e ).Element ); + } + function po( e ) { + return !! ao() && ( e instanceof HTMLElement || e instanceof co( e ).HTMLElement ); + } + function go( e ) { + return ( + ! ( ! ao() || 'undefined' == typeof ShadowRoot ) && + ( e instanceof ShadowRoot || e instanceof co( e ).ShadowRoot ) + ); + } + function ho( e ) { + const { overflow: t, overflowX: n, overflowY: i, display: r } = Eo( e ); + return ( + /auto|scroll|overlay|hidden|clip/.test( t + i + n ) && + 'inline' !== r && + 'contents' !== r + ); + } + function vo( e ) { + return /^(table|td|th)$/.test( lo( e ) ); + } + function bo( e ) { + try { + if ( e.matches( ':popover-open' ) ) return ! 0; + } catch ( e ) {} + try { + return e.matches( ':modal' ); + } catch ( e ) { + return ! 1; + } + } + const wo = /transform|translate|scale|rotate|perspective|filter/, + yo = /paint|layout|strict|content/, + xo = e => !! e && 'none' !== e; + let Co; + function So( e ) { + const t = mo( e ) ? Eo( e ) : e; + return ( + xo( t.transform ) || + xo( t.translate ) || + xo( t.scale ) || + xo( t.rotate ) || + xo( t.perspective ) || + ( ! _o() && ( xo( t.backdropFilter ) || xo( t.filter ) ) ) || + wo.test( t.willChange || '' ) || + yo.test( t.contain || '' ) + ); + } + function _o() { + return ( + null == Co && + ( Co = + 'undefined' != typeof CSS && + CSS.supports && + CSS.supports( '-webkit-backdrop-filter', 'none' ) ), + Co + ); + } + function jo( e ) { + return /^(html|body|#document)$/.test( lo( e ) ); + } + function Eo( e ) { + return co( e ).getComputedStyle( e ); + } + function ko( e ) { + return mo( e ) + ? { scrollLeft: e.scrollLeft, scrollTop: e.scrollTop } + : { scrollLeft: e.scrollX, scrollTop: e.scrollY }; + } + function Io( e ) { + if ( 'html' === lo( e ) ) return e; + const t = e.assignedSlot || e.parentNode || ( go( e ) && e.host ) || uo( e ); + return go( t ) ? t.host : t; + } + function Vo( e ) { + const t = Io( e ); + return jo( t ) + ? e.ownerDocument + ? e.ownerDocument.body + : e.body + : po( t ) && ho( t ) + ? t + : Vo( t ); + } + function Oo( e, t, n ) { + var i; + void 0 === t && ( t = [] ), void 0 === n && ( n = ! 0 ); + const r = Vo( e ), + o = r === ( null == ( i = e.ownerDocument ) ? void 0 : i.body ), + s = co( r ); + if ( o ) { + const e = Po( s ); + return t.concat( + s, + s.visualViewport || [], + ho( r ) ? r : [], + e && n ? Oo( e ) : [] + ); + } + return t.concat( r, Oo( r, [], n ) ); + } + function Po( e ) { + return e.parent && Object.getPrototypeOf( e.parent ) ? e.frameElement : null; + } + const Mo = J.createContext( null ), + To = J.createContext( null ), + No = () => J.useContext( Mo )?.id || null, + Ao = e => { + const t = J.useContext( To ); + return e ?? t; + }; + function Ro( e, t, n, i ) { + let r = ! 1, + o = ! 1; + const s = i ?? de; + return { + reason: e, + event: t ?? new Event( 'base-ui' ), + cancel() { + r = ! 0; + }, + allowPropagation() { + o = ! 0; + }, + get isCanceled() { + return r; + }, + get isPropagationAllowed() { + return o; + }, + trigger: n, + ...s, + }; + } + const Fo = 'none', + Lo = 'trigger-press', + Do = 'trigger-hover', + Bo = 'trigger-focus', + zo = 'escape-key'; + function Wo( e ) { + return `data-base-ui-${ e }`; + } + const $o = 'undefined' != typeof navigator, + Ho = ( function () { + if ( ! $o ) return { platform: '', maxTouchPoints: -1 }; + const e = navigator.userAgentData; + return e?.platform + ? { platform: e.platform, maxTouchPoints: navigator.maxTouchPoints } + : { + platform: navigator.platform ?? '', + maxTouchPoints: navigator.maxTouchPoints ?? -1, + }; + } )(), + qo = ( function () { + if ( ! $o ) return ''; + const e = navigator.userAgentData; + return e?.platform ? e.platform : navigator.platform ?? ''; + } )(), + Go = ( function () { + if ( ! $o ) return ''; + const e = navigator.userAgentData; + return e && Array.isArray( e.brands ) + ? e.brands + .map( ( { brand: e, version: t } ) => `${ e }/${ t }` ) + .join( ' ' ) + : navigator.userAgent; + } )(), + Yo = + ( ! ( 'undefined' == typeof CSS || ! CSS.supports ) && + CSS.supports( '-webkit-backdrop-filter:none' ), + ( 'MacIntel' === Ho.platform && Ho.maxTouchPoints > 1 ) || + /iP(hone|ad|od)|iOS/.test( Ho.platform ), + $o && /firefox/i.test( Go ), + $o && /apple/i.test( navigator.vendor ) ), + Ko = + ( $o && /Edg/i.test( Go ), + ( $o && /android/i.test( qo ) ) || /android/i.test( Go ), + $o && qo.toLowerCase().startsWith( 'mac' ) && ! navigator.maxTouchPoints ), + Uo = Go.includes( 'jsdom/' ), + Xo = 'data-base-ui-focusable', + Zo = + "input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])"; + function Qo( e ) { + let t = e.activeElement; + for ( ; null != t?.shadowRoot?.activeElement; ) t = t.shadowRoot.activeElement; + return t; + } + function Jo( e, t ) { + if ( ! e || ! t ) return ! 1; + const n = t.getRootNode?.(); + if ( e.contains( t ) ) return ! 0; + if ( n && go( n ) ) { + let n = t; + for ( ; n; ) { + if ( e === n ) return ! 0; + n = n.parentNode || n.host; + } + } + return ! 1; + } + function es( e ) { + return 'composedPath' in e ? e.composedPath()[ 0 ] : e.target; + } + function ts( e, t ) { + if ( ! mo( e ) ) return ! 1; + const n = e; + if ( t.hasElement( n ) ) return ! n.hasAttribute( 'data-trigger-disabled' ); + for ( const [ , e ] of t.entries() ) + if ( Jo( e, n ) ) return ! e.hasAttribute( 'data-trigger-disabled' ); + return ! 1; + } + function ns( e, t ) { + if ( null == t ) return ! 1; + if ( 'composedPath' in e ) return e.composedPath().includes( t ); + const n = e; + return null != n.target && t.contains( n.target ); + } + function is( e, t ) { + const n = [ 'mouse', 'pen' ]; + return t || n.push( '', void 0 ), n.includes( e ); + } + function rs( e, t, n = ! 0 ) { + return e + .filter( e => e.parentId === t ) + .flatMap( t => [ + ...( ! n || t.context?.open ? [ t ] : [] ), + ...rs( e, t.id, n ), + ] ); + } + const os = { intentional: 'onClick', sloppy: 'onPointerDown' }; + function ss() { + return ! 1; + } + function as( e ) { + return null != e && null != e.clientX; + } + let ls = 0; + const cs = Zr.useId; + function us( e, t ) { + if ( void 0 !== cs ) { + const n = cs(); + return e ?? ( t ? `${ t }-${ n }` : n ); + } + return ( function ( e, t = 'mui' ) { + const [ n, i ] = J.useState( e ), + r = e || n; + return ( + J.useEffect( () => { + null == n && ( ( ls += 1 ), i( `${ t }-${ ls }` ) ); + }, [ n, t ] ), + r + ); + } )( e, t ); + } + const ds = ( e, t, n, i, r, o, ...s ) => { + if ( s.length > 0 ) throw new Error( Q( 1 ) ); + let a; + if ( e && t && n && i && r && o ) + a = ( s, a, l, c ) => { + const u = e( s, a, l, c ), + d = t( s, a, l, c ), + f = n( s, a, l, c ), + m = i( s, a, l, c ), + p = r( s, a, l, c ); + return o( u, d, f, m, p, a, l, c ); + }; + else if ( e && t && n && i && r ) + a = ( o, s, a, l ) => { + const c = e( o, s, a, l ), + u = t( o, s, a, l ), + d = n( o, s, a, l ), + f = i( o, s, a, l ); + return r( c, u, d, f, s, a, l ); + }; + else if ( e && t && n && i ) + a = ( r, o, s, a ) => { + const l = e( r, o, s, a ), + c = t( r, o, s, a ), + u = n( r, o, s, a ); + return i( l, c, u, o, s, a ); + }; + else if ( e && t && n ) + a = ( i, r, o, s ) => { + const a = e( i, r, o, s ), + l = t( i, r, o, s ); + return n( a, l, r, o, s ); + }; + else if ( e && t ) + a = ( n, i, r, o ) => { + const s = e( n, i, r, o ); + return t( s, i, r, o ); + }; + else { + if ( ! e ) throw new Error( 'Missing arguments' ); + a = e; + } + return a; + }; + var fs = r( 412 ), + ms = r( 134 ); + const ps = ae( 19 ) + ? function ( e, t, n, i, r ) { + const o = Wr; + if ( ! o ) + return ( function ( e, t, n, i, r ) { + const o = J.useCallback( + () => t( e.getSnapshot(), n, i, r ), + [ e, t, n, i, r ] + ); + return ( 0, fs.useSyncExternalStore )( e.subscribe, o, o ); + } )( e, t, n, i, r ); + const s = o.syncIndex; + let a; + return ( + ( o.syncIndex += 1 ), + o.didInitialize + ? ( ( a = o.syncHooks[ s ] ), + ( a.store === e && + a.selector === t && + Object.is( a.a1, n ) && + Object.is( a.a2, i ) && + Object.is( a.a3, r ) ) || + ( a.store !== e && ( o.didChangeStore = ! 0 ), + ( a.store = e ), + ( a.selector = t ), + ( a.a1 = n ), + ( a.a2 = i ), + ( a.a3 = r ), + ( a.didChange = ! 0 ) ) ) + : ( ( a = { + store: e, + selector: t, + a1: n, + a2: i, + a3: r, + value: t( e.getSnapshot(), n, i, r ), + didChange: ! 1, + } ), + o.syncHooks.push( a ) ), + a.value + ); + } + : function ( e, t, n, i, r ) { + return ( 0, ms.useSyncExternalStoreWithSelector )( + e.subscribe, + e.getSnapshot, + e.getSnapshot, + e => t( e, n, i, r ) + ); + }; + function gs( e, t, n, i, r ) { + return ps( e, t, n, i, r ); + } + var hs; + ( hs = { + before( e ) { + ( e.syncIndex = 0 ), + e.didInitialize || + ( ( e.syncTick = 1 ), + ( e.syncHooks = [] ), + ( e.didChangeStore = ! 0 ), + ( e.getSnapshot = () => { + let t = ! 1; + for ( let n = 0; n < e.syncHooks.length; n += 1 ) { + const i = e.syncHooks[ n ], + r = i.selector( i.store.state, i.a1, i.a2, i.a3 ); + ( ! i.didChange && Object.is( i.value, r ) ) || + ( ( t = ! 0 ), ( i.value = r ), ( i.didChange = ! 1 ) ); + } + return t && ( e.syncTick += 1 ), e.syncTick; + } ) ); + }, + after( e ) { + e.syncHooks.length > 0 && + ( e.didChangeStore && + ( ( e.didChangeStore = ! 1 ), + ( e.subscribe = t => { + const n = new Set(); + for ( const t of e.syncHooks ) n.add( t.store ); + const i = []; + for ( const e of n ) i.push( e.subscribe( t ) ); + return () => { + for ( const e of i ) e(); + }; + } ) ), + ( 0, fs.useSyncExternalStore )( + e.subscribe, + e.getSnapshot, + e.getSnapshot + ) ); + }, + } ), + zr.push( hs ); + class vs { + constructor( e ) { + ( this.state = e ), ( this.listeners = new Set() ), ( this.updateTick = 0 ); + } + subscribe = e => ( + this.listeners.add( e ), + () => { + this.listeners.delete( e ); + } + ); + getSnapshot = () => this.state; + setState( e ) { + if ( this.state === e ) return; + ( this.state = e ), ( this.updateTick += 1 ); + const t = this.updateTick; + for ( const n of this.listeners ) { + if ( t !== this.updateTick ) return; + n( e ); + } + } + update( e ) { + for ( const t in e ) + if ( ! Object.is( this.state[ t ], e[ t ] ) ) + return void this.setState( { ...this.state, ...e } ); + } + set( e, t ) { + Object.is( this.state[ e ], t ) || this.setState( { ...this.state, [ e ]: t } ); + } + notifyAll() { + const e = { ...this.state }; + this.setState( e ); + } + use( e, t, n, i ) { + return gs( this, e, t, n, i ); + } + } + class bs extends vs { + constructor( e, t = {}, n ) { + super( e ), ( this.context = t ), ( this.selectors = n ); + } + useSyncedValue( e, t ) { + J.useDebugValue( e ); + const n = this; + qr( () => { + n.state[ e ] !== t && n.set( e, t ); + }, [ n, e, t ] ); + } + useSyncedValueWithCleanup( e, t ) { + const n = this; + qr( + () => ( + n.state[ e ] !== t && n.set( e, t ), + () => { + n.set( e, void 0 ); + } + ), + [ n, e, t ] + ); + } + useSyncedValues( e ) { + const t = this, + n = Object.values( e ); + qr( () => { + t.update( e ); + }, [ t, ...n ] ); + } + useControlledProp( e, t ) { + J.useDebugValue( e ); + const n = this, + i = void 0 !== t; + qr( () => { + i && + ! Object.is( n.state[ e ], t ) && + n.setState( { ...n.state, [ e ]: t } ); + }, [ n, e, t, i ] ); + } + select( e, t, n, i ) { + return ( 0, this.selectors[ e ] )( this.state, t, n, i ); + } + useState( e, t, n, i ) { + return J.useDebugValue( e ), gs( this, this.selectors[ e ], t, n, i ); + } + useContextCallback( e, t ) { + J.useDebugValue( e ); + const n = eo( t ?? ue ); + this.context[ e ] = n; + } + useStateSetter( e ) { + const t = J.useRef( void 0 ); + return ( + void 0 === t.current && + ( t.current = t => { + this.set( e, t ); + } ), + t.current + ); + } + observe( e, t ) { + let n; + n = 'function' == typeof e ? e : this.selectors[ e ]; + let i = n( this.state ); + return ( + t( i, i, this ), + this.subscribe( e => { + const r = n( e ); + if ( ! Object.is( i, r ) ) { + const e = i; + ( i = r ), t( r, e, this ); + } + } ) + ); + } + } + function ws() { + const e = new Map(); + return { + emit( t, n ) { + e.get( t )?.forEach( e => e( n ) ); + }, + on( t, n ) { + e.has( t ) || e.set( t, new Set() ), e.get( t ).add( n ); + }, + off( t, n ) { + e.get( t )?.delete( n ); + }, + }; + } + const ys = { + open: ds( e => e.open ), + transitionStatus: ds( e => e.transitionStatus ), + domReferenceElement: ds( e => e.domReferenceElement ), + referenceElement: ds( e => e.positionReference ?? e.referenceElement ), + floatingElement: ds( e => e.floatingElement ), + floatingId: ds( e => e.floatingId ), + }; + class xs extends bs { + constructor( e ) { + const { syncOnly: t, nested: n, onOpenChange: i, triggerElements: r, ...o } = e; + super( + { + ...o, + positionReference: o.referenceElement, + domReferenceElement: o.referenceElement, + }, + { + onOpenChange: i, + dataRef: { current: {} }, + events: ws(), + nested: n, + triggerElements: r, + }, + ys + ), + ( this.syncOnly = t ); + } + syncOpenEvent = ( e, t ) => { + ( ! e || + ! this.state.open || + ( null != t && + ( function ( e ) { + const t = e.type; + return ( + 'click' === t || + 'mousedown' === t || + 'keydown' === t || + 'keyup' === t + ); + } )( t ) ) ) && + ( this.context.dataRef.current.openEvent = e ? t : void 0 ); + }; + dispatchOpenChange = ( e, t ) => { + this.syncOpenEvent( e, t.event ); + const n = { + open: e, + reason: t.reason, + nativeEvent: t.event, + nested: this.context.nested, + triggerElement: t.trigger, + }; + this.context.events.emit( 'openchange', n ); + }; + setOpen = ( e, t ) => { + this.syncOnly || this.dispatchOpenChange( e, t ), + this.context.onOpenChange?.( e, t ); + }; + } + const Cs = null; + globalThis.requestAnimationFrame; + const Ss = new ( class { + callbacks = []; + callbacksCount = 0; + nextId = 1; + startId = 1; + isScheduled = ! 1; + tick = e => { + this.isScheduled = ! 1; + const t = this.callbacks, + n = this.callbacksCount; + if ( + ( ( this.callbacks = [] ), + ( this.callbacksCount = 0 ), + ( this.startId = this.nextId ), + n > 0 ) + ) + for ( let n = 0; n < t.length; n += 1 ) t[ n ]?.( e ); + }; + request( e ) { + const t = this.nextId; + return ( + ( this.nextId += 1 ), + this.callbacks.push( e ), + ( this.callbacksCount += 1 ), + this.isScheduled || + ( requestAnimationFrame( this.tick ), ( this.isScheduled = ! 0 ) ), + t + ); + } + cancel( e ) { + const t = e - this.startId; + t < 0 || + t >= this.callbacks.length || + ( ( this.callbacks[ t ] = null ), ( this.callbacksCount -= 1 ) ); + } + } )(); + class _s { + static create() { + return new _s(); + } + static request( e ) { + return Ss.request( e ); + } + static cancel( e ) { + return Ss.cancel( e ); + } + currentId = Cs; + request( e ) { + this.cancel(), + ( this.currentId = Ss.request( () => { + ( this.currentId = Cs ), e(); + } ) ); + } + cancel = () => { + this.currentId !== Cs && + ( Ss.cancel( this.currentId ), ( this.currentId = Cs ) ); + }; + disposeEffect = () => this.cancel; + } + const js = window.ReactDOM; + let Es = ( function ( e ) { + return ( + ( e.startingStyle = 'data-starting-style' ), + ( e.endingStyle = 'data-ending-style' ), + e + ); + } )( {} ); + const ks = { [ Es.startingStyle ]: '' }, + Is = { [ Es.endingStyle ]: '' }, + Vs = { + transitionStatus: e => ( 'starting' === e ? ks : 'ending' === e ? Is : null ), + }; + function Os( e ) { + const { enabled: t = ! 0, open: n, ref: i, onComplete: r } = e, + o = eo( r ), + s = ( function ( e, t = ! 1, n = ! 0 ) { + const i = ( function () { + const e = ne( _s.create ).current; + return ro( e.disposeEffect ), e; + } )(); + return eo( ( r, o = null ) => { + i.cancel(); + const s = null == ( a = e ) ? a : 'current' in a ? a.current : a; + var a; + if ( null == s ) return; + const l = s, + c = () => { + js.flushSync( r ); + }; + if ( + 'function' != typeof l.getAnimations || + globalThis.BASE_UI_ANIMATIONS_DISABLED + ) + r(); + else { + if ( t ) { + const e = Es.startingStyle; + if ( ! l.hasAttribute( e ) ) return void i.request( u ); + const t = new MutationObserver( () => { + l.hasAttribute( e ) || ( t.disconnect(), u() ); + } ); + return ( + t.observe( l, { attributes: ! 0, attributeFilter: [ e ] } ), + void o?.addEventListener( 'abort', () => t.disconnect(), { + once: ! 0, + } ) + ); + } + i.request( u ); + } + function u() { + Promise.all( l.getAnimations().map( e => e.finished ) ) + .then( () => { + o?.aborted || c(); + } ) + .catch( () => { + if ( n ) return void ( o?.aborted || c() ); + const e = l.getAnimations(); + ! o?.aborted && + e.length > 0 && + e.some( + e => e.pending || 'finished' !== e.playState + ) && + u(); + } ); + } + } ); + } )( i, n, ! 1 ); + J.useEffect( () => { + if ( ! t ) return; + const e = new AbortController(); + return ( + s( o, e.signal ), + () => { + e.abort(); + } + ); + }, [ t, n, o, s ] ); + } + const Ps = { tabIndex: -1, [ Xo ]: '' }; + class Ms { + constructor() { + ( this.elementsSet = new Set() ), ( this.idMap = new Map() ); + } + add( e, t ) { + const n = this.idMap.get( e ); + n !== t && + ( void 0 !== n && this.elementsSet.delete( n ), + this.elementsSet.add( t ), + this.idMap.set( e, t ) ); + } + delete( e ) { + const t = this.idMap.get( e ); + t && ( this.elementsSet.delete( t ), this.idMap.delete( e ) ); + } + hasElement( e ) { + return this.elementsSet.has( e ); + } + hasMatchingElement( e ) { + for ( const t of this.elementsSet ) if ( e( t ) ) return ! 0; + return ! 1; + } + getById( e ) { + return this.idMap.get( e ); + } + entries() { + return this.idMap.entries(); + } + elements() { + return this.elementsSet.values(); + } + get size() { + return this.idMap.size; + } + } + const Ts = ds( e => e.triggerIdProp ?? e.activeTriggerId ), + Ns = ds( e => e.openProp ?? e.open ), + As = ds( e => ( e.popupElement?.id ?? e.floatingId ) || void 0 ); + function Rs( e, t ) { + return void 0 !== t && Ns( e ) && Ts( e ) === t; + } + const Fs = { + open: Ns, + mounted: ds( e => e.mounted ), + transitionStatus: ds( e => e.transitionStatus ), + floatingRootContext: ds( e => e.floatingRootContext ), + triggerCount: ds( e => e.triggerCount ), + preventUnmountingOnClose: ds( e => e.preventUnmountingOnClose ), + payload: ds( e => e.payload ), + activeTriggerId: Ts, + activeTriggerElement: ds( e => ( e.mounted ? e.activeTriggerElement : null ) ), + popupId: As, + isTriggerActive: ds( ( e, t ) => void 0 !== t && Ts( e ) === t ), + isOpenedByTrigger: ds( ( e, t ) => Rs( e, t ) ), + isMountedByTrigger: ds( ( e, t ) => void 0 !== t && Ts( e ) === t && e.mounted ), + triggerProps: ds( ( e, t ) => + t ? e.activeTriggerProps : e.inactiveTriggerProps + ), + triggerPopupId: ds( ( e, t ) => + ( function ( e, t ) { + return ( + !! Rs( e, t ) || + ( void 0 !== t && Ns( e ) && null == Ts( e ) && 1 === e.triggerCount ) + ); + } )( e, t ) + ? As( e ) + : void 0 + ), + popupProps: ds( e => e.popupProps ), + popupElement: ds( e => e.popupElement ), + positionerElement: ds( e => e.positionerElement ), + disabled: ds( e => e.disabled ), + instantType: ds( e => e.instantType ), + isInstantPhase: ds( e => e.isInstantPhase ), + trackCursorAxis: ds( e => e.trackCursorAxis ), + disableHoverablePopup: ds( e => e.disableHoverablePopup ), + lastOpenChangeReason: ds( e => e.openChangeReason ), + closeOnClick: ds( e => e.closeOnClick ), + closeDelay: ds( e => e.closeDelay ), + hasViewport: ds( e => e.hasViewport ), + }; + class Ls extends bs { + constructor( e, t, n = ! 1 ) { + const i = new Ms(), + r = { + open: ! 1, + openProp: void 0, + mounted: ! 1, + transitionStatus: void 0, + floatingRootContext: new xs( { + open: ! 1, + transitionStatus: void 0, + floatingElement: null, + referenceElement: null, + triggerElements: new Ms(), + floatingId: void 0, + syncOnly: ! 1, + nested: ! 1, + onOpenChange: void 0, + } ), + floatingId: void 0, + triggerCount: 0, + preventUnmountingOnClose: ! 1, + payload: void 0, + activeTriggerId: null, + activeTriggerElement: null, + triggerIdProp: void 0, + popupElement: null, + positionerElement: null, + activeTriggerProps: de, + inactiveTriggerProps: de, + popupProps: de, + disabled: ! 1, + instantType: void 0, + isInstantPhase: ! 1, + trackCursorAxis: 'none', + disableHoverablePopup: ! 1, + openChangeReason: null, + closeOnClick: ! 0, + closeDelay: 0, + hasViewport: ! 1, + ...e, + }; + ( r.floatingRootContext = ( function ( e, t, n = ! 1 ) { + return new xs( { + open: ! 1, + transitionStatus: void 0, + floatingElement: null, + referenceElement: null, + triggerElements: e, + floatingId: t, + syncOnly: ! 0, + nested: n, + onOpenChange: void 0, + } ); + } )( i, t, n ) ), + super( + r, + { + popupRef: J.createRef(), + onOpenChange: void 0, + onOpenChangeComplete: void 0, + triggerElements: i, + }, + Fs + ); + } + setOpen = ( e, t ) => { + const n = t.reason, + i = n === Do, + r = e && n === Bo, + o = ! e && ( n === Lo || n === zo ); + if ( + ( ( t.preventUnmountOnClose = () => { + this.set( 'preventUnmountingOnClose', ! 0 ); + } ), + this.context.onOpenChange?.( e, t ), + t.isCanceled ) + ) + return; + this.state.floatingRootContext.dispatchOpenChange( e, t ); + const s = () => { + const i = { open: e, openChangeReason: n }; + r + ? ( i.instantType = 'focus' ) + : o + ? ( i.instantType = 'dismiss' ) + : n === Do && ( i.instantType = void 0 ), + ( function ( e, t, n ) { + const i = n?.id ?? null; + ( i || t ) && + ( ( e.activeTriggerId = i ), + ( e.activeTriggerElement = n ?? null ) ); + } )( i, e, t.trigger ), + this.update( i ); + }; + i ? js.flushSync( s ) : s(); + }; + cancelPendingOpen( e ) { + this.state.floatingRootContext.dispatchOpenChange( ! 1, Ro( Lo, e ) ); + } + static useStore( e, t ) { + return ( function ( e, t, n = ! 1 ) { + const i = us(), + r = null != No(), + o = J.useRef( null ); + void 0 === e && null === o.current && ( o.current = t( i, r ) ); + const s = e ?? o.current; + return ( + ( function ( e ) { + const { + popupStore: t, + treatPopupAsFloatingElement: n = ! 1, + floatingRootContext: i, + floatingId: r, + nested: o, + onOpenChange: s, + } = e, + a = t.useState( 'open' ), + l = t.useState( 'activeTriggerElement' ), + c = t.useState( n ? 'popupElement' : 'positionerElement' ), + u = t.context.triggerElements, + d = s, + f = J.useRef( null ); + void 0 === i && + null === f.current && + ( f.current = new xs( { + open: a, + transitionStatus: void 0, + referenceElement: l, + floatingElement: c, + triggerElements: u, + onOpenChange: d, + floatingId: r, + syncOnly: ! 0, + nested: o, + } ) ); + const m = i ?? f.current; + t.useSyncedValue( 'floatingId', r ), + qr( () => { + const e = { + open: a, + floatingId: r, + referenceElement: l, + floatingElement: c, + }; + mo( l ) && ( e.domReferenceElement = l ), + m.state.positionReference === + m.state.referenceElement && + ( e.positionReference = l ), + m.update( e ); + }, [ a, r, l, c, m ] ), + ( m.context.onOpenChange = d ), + ( m.context.nested = o ); + } )( { + popupStore: s, + treatPopupAsFloatingElement: n, + floatingRootContext: s.state.floatingRootContext, + floatingId: i, + nested: r, + onOpenChange: s.setOpen, + } ), + { store: s, internalStore: o.current } + ); + } )( e, ( e, n ) => new Ls( t, e, n ) ).store; + } + } + const Ds = $r( function ( e ) { + const { + disabled: t = ! 1, + defaultOpen: n = ! 1, + open: i, + disableHoverablePopup: r = ! 1, + trackCursorAxis: o = 'none', + actionsRef: s, + onOpenChange: a, + onOpenChangeComplete: l, + handle: u, + triggerId: d, + defaultTriggerId: f = null, + children: m, + } = e, + p = Ls.useStore( u?.store, { + open: n, + openProp: i, + activeTriggerId: f, + triggerIdProp: d, + } ); + ! ( function () { + const e = J.useRef( ! 0 ); + e.current && + ( ( e.current = ! 1 ), + void 0 === i && + ! 1 === p.state.open && + ! 0 === n && + p.update( { open: ! 0, activeTriggerId: f } ) ); + } )(), + p.useControlledProp( 'openProp', i ), + p.useControlledProp( 'triggerIdProp', d ), + p.useContextCallback( 'onOpenChange', a ), + p.useContextCallback( 'onOpenChangeComplete', l ); + const g = p.useState( 'open' ), + h = ! t && g, + v = p.useState( 'activeTriggerId' ), + b = p.useState( 'mounted' ), + w = p.useState( 'payload' ); + p.useSyncedValues( { trackCursorAxis: o, disableHoverablePopup: r } ), + p.useSyncedValue( 'disabled', t ), + ( function ( e ) { + const t = e.useState( 'open' ), + n = e.useState( 'triggerCount' ); + qr( () => { + if ( ! t ) + return void ( + 0 !== e.state.triggerCount && e.set( 'triggerCount', 0 ) + ); + const n = e.context.triggerElements.size, + i = {}; + if ( + ( e.state.triggerCount !== n && ( i.triggerCount = n ), + ! e.select( 'activeTriggerId' ) && 1 === n ) + ) { + const t = e.context.triggerElements.entries().next(); + if ( ! t.done ) { + const [ e, n ] = t.value; + ( i.activeTriggerId = e ), ( i.activeTriggerElement = n ); + } + } + ( void 0 === i.triggerCount && void 0 === i.activeTriggerId ) || + e.update( i ); + }, [ t, e, n ] ); + } )( p ); + const { forceUnmount: y, transitionStatus: x } = ( function ( e, t, n ) { + const { + mounted: i, + setMounted: r, + transitionStatus: o, + } = ( function ( e, t = ! 1, n = ! 1 ) { + const [ i, r ] = J.useState( e && t ? 'idle' : void 0 ), + [ o, s ] = J.useState( e ); + return ( + e && ! o && ( s( ! 0 ), r( 'starting' ) ), + e || ! o || 'ending' === i || n || r( 'ending' ), + e || o || 'ending' !== i || r( void 0 ), + qr( () => { + if ( ! e && o && 'ending' !== i && n ) { + const e = _s.request( () => { + r( 'ending' ); + } ); + return () => { + _s.cancel( e ); + }; + } + }, [ e, o, i, n ] ), + qr( () => { + if ( ! e || t ) return; + const n = _s.request( () => { + r( void 0 ); + } ); + return () => { + _s.cancel( n ); + }; + }, [ t, e ] ), + qr( () => { + if ( ! e || ! t ) return; + e && o && 'idle' !== i && r( 'starting' ); + const n = _s.request( () => { + r( 'idle' ); + } ); + return () => { + _s.cancel( n ); + }; + }, [ t, e, o, i ] ), + { mounted: o, setMounted: s, transitionStatus: i } + ); + } )( e ); + t.useSyncedValues( { mounted: i, transitionStatus: o } ); + const s = eo( () => { + r( ! 1 ), + t.update( { + activeTriggerId: null, + activeTriggerElement: null, + mounted: ! 1, + preventUnmountingOnClose: ! 1, + } ), + n?.(), + t.context.onOpenChangeComplete?.( ! 1 ); + } ), + a = t.useState( 'preventUnmountingOnClose' ); + return ( + Os( { + enabled: i && ! e && ! a, + open: e, + ref: t.context.popupRef, + onComplete() { + e || s(); + }, + } ), + { forceUnmount: s, transitionStatus: o } + ); + } )( h, p ), + C = p.useState( 'isInstantPhase' ), + S = p.useState( 'instantType' ), + _ = p.useState( 'lastOpenChangeReason' ), + j = J.useRef( null ); + qr( () => { + g && t && p.setOpen( ! 1, Ro( 'disabled' ) ); + }, [ g, t, p ] ), + qr( () => { + ( 'ending' === x && _ === Fo ) || ( 'ending' !== x && C ) + ? ( 'delay' !== S && ( j.current = S ), + p.set( 'instantType', 'delay' ) ) + : null !== j.current && + ( p.set( 'instantType', j.current ), ( j.current = null ) ); + }, [ x, C, _, S, p ] ), + qr( () => { + h && null == v && p.set( 'payload', void 0 ); + }, [ p, v, h ] ); + const E = J.useCallback( () => { + p.setOpen( ! 1, Ro( 'imperative-action' ) ); + }, [ p ] ); + J.useImperativeHandle( s, () => ( { unmount: y, close: E } ), [ y, E ] ); + const k = h || b || ( ! t && 'none' !== o ); + return ( 0, c.jsxs )( Gr.Provider, { + value: p, + children: [ + k && ( 0, c.jsx )( Bs, { store: p, disabled: t, trackCursorAxis: o } ), + 'function' == typeof m ? m( { payload: w } ) : m, + ], + } ); + } ); + function Bs( { store: e, disabled: t, trackCursorAxis: n } ) { + const i = e.useState( 'floatingRootContext' ), + r = ( function ( e, t = {} ) { + const { + enabled: n = ! 0, + escapeKey: i = ! 0, + outsidePress: r = ! 0, + outsidePressEvent: o = 'sloppy', + referencePress: s = ss, + referencePressEvent: a = 'sloppy', + bubbles: l, + externalTree: c, + } = t, + u = 'rootStore' in e ? e.rootStore : e, + d = u.useState( 'open' ), + f = u.useState( 'floatingElement' ), + { dataRef: m } = u.context, + p = Ao( c ), + g = eo( 'function' == typeof r ? r : () => ! 1 ), + h = 'function' == typeof r ? g : r, + v = ! 1 !== h, + b = eo( () => o ), + { escapeKey: w, outsidePress: y } = { + escapeKey: 'boolean' == typeof ( x = l ) ? x : x?.escapeKey ?? ! 1, + outsidePress: 'boolean' == typeof x ? x : x?.outsidePress ?? ! 0, + }; + var x; + const C = J.useRef( ! 1 ), + S = J.useRef( ! 1 ), + _ = J.useRef( ! 1 ), + j = J.useRef( ! 1 ), + E = J.useRef( '' ), + k = J.useRef( null ), + I = so(), + V = so(), + O = eo( () => { + V.clear(), ( m.current.insideReactTree = ! 1 ); + } ), + P = eo( e => { + const t = m.current.floatingContext?.nodeId; + return ( p ? rs( p.nodesRef.current, t ) : [] ).some( + t => t.context?.open && ! t.context.dataRef.current[ e ] + ); + } ), + M = eo( + e => + ns( e, u.select( 'floatingElement' ) ) || + ns( e, u.select( 'domReferenceElement' ) ) + ), + T = eo( e => { + s() && u.setOpen( ! 1, Ro( Lo, e.nativeEvent ) ); + } ), + N = eo( e => { + if ( ! d || ! n || ! i || 'Escape' !== e.key ) return; + if ( j.current ) return; + if ( ! w && P( '__escapeKeyBubbles' ) ) return; + const t = ( function ( e ) { + return 'nativeEvent' in e; + } )( e ) + ? e.nativeEvent + : e, + r = Ro( zo, t ); + u.setOpen( ! 1, r ), + r.isCanceled || e.preventDefault(), + w || r.isPropagationAllowed || e.stopPropagation(); + } ), + A = eo( () => { + ( m.current.insideReactTree = ! 0 ), V.start( 0, O ); + } ), + R = eo( e => { + if ( ! d || ! n || 0 !== e.button ) return; + const t = es( e.nativeEvent ); + Jo( u.select( 'floatingElement' ), t ) && + ( C.current || ( ( C.current = ! 0 ), ( S.current = ! 1 ) ) ); + } ), + F = eo( e => { + d && + n && + ( e.defaultPrevented || e.nativeEvent.defaultPrevented ) && + C.current && + ( S.current = ! 0 ); + } ); + J.useEffect( () => { + if ( ! d || ! n ) return; + ( m.current.__escapeKeyBubbles = w ), + ( m.current.__outsidePressBubbles = y ); + const e = new oo(), + t = new oo(); + function r() { + ( _.current = ! 0 ), + t.start( 0, () => { + _.current = ! 1; + } ); + } + function o() { + ( C.current = ! 1 ), ( S.current = ! 1 ); + } + function s() { + const e = E.current, + t = 'pen' !== e && e ? e : 'mouse', + n = b(), + i = 'function' == typeof n ? n() : n; + return 'string' == typeof i ? i : i[ t ]; + } + function a( e ) { + const t = m.current.floatingContext?.nodeId, + n = + p && + rs( p.nodesRef.current, t ).some( t => + ns( e, t.context?.elements.floating ) + ); + return M( e ) || n; + } + function l( e ) { + if ( + ( function ( e ) { + const t = s(); + return ( + ( 'intentional' === t && 'click' !== e.type ) || + ( 'sloppy' === t && 'click' === e.type ) + ); + } )( e ) + ) + return ( + 'click' === e.type || + M( e ) || + ( t.clear(), ( _.current = ! 1 ) ), + void O() + ); + if ( m.current.insideReactTree ) return void O(); + const n = es( e ), + i = `[${ Wo( 'inert' ) }]`, + r = mo( n ) ? n.getRootNode() : null, + o = Array.from( + ( go( r ) + ? r + : Xr( u.select( 'floatingElement' ) ) + ).querySelectorAll( i ) + ), + l = u.context.triggerElements; + if ( + n && + ( l.hasElement( n ) || l.hasMatchingElement( e => Jo( e, n ) ) ) + ) + return; + let c = mo( n ) ? n : null; + for ( ; c && ! jo( c ); ) { + const e = Io( c ); + if ( jo( e ) || ! mo( e ) ) break; + c = e; + } + if ( + ! o.length || + ! mo( n ) || + n.matches( 'html,body' ) || + Jo( n, u.select( 'floatingElement' ) ) || + ! o.every( e => ! Jo( c, e ) ) + ) { + if ( po( n ) && ! ( 'touches' in e ) ) { + const t = jo( n ), + i = Eo( n ), + r = /auto|scroll/, + o = t || r.test( i.overflowX ), + s = t || r.test( i.overflowY ), + a = + o && + n.clientWidth > 0 && + n.scrollWidth > n.clientWidth, + l = + s && + n.clientHeight > 0 && + n.scrollHeight > n.clientHeight, + c = 'rtl' === i.direction, + u = + l && + ( c + ? e.offsetX <= n.offsetWidth - n.clientWidth + : e.offsetX > n.clientWidth ), + d = a && e.offsetY > n.clientHeight; + if ( u || d ) return; + } + if ( ! a( e ) ) + return 'intentional' === s() && _.current + ? ( t.clear(), void ( _.current = ! 1 ) ) + : void ( + ( 'function' != typeof h || h( e ) ) && + ( P( '__outsidePressBubbles' ) || + ( u.setOpen( + ! 1, + Ro( 'outside-press', e ) + ), + O() ) ) + ); + } + } + function c( e ) { + if ( 'sloppy' !== s() || ! u.select( 'open' ) || ! n || M( e ) ) + return; + const t = e.touches[ 0 ]; + t && + ( ( k.current = { + startTime: Date.now(), + startX: t.clientX, + startY: t.clientY, + dismissOnTouchEnd: ! 1, + dismissOnMouseDown: ! 0, + } ), + I.start( 1e3, () => { + k.current && + ( ( k.current.dismissOnTouchEnd = ! 1 ), + ( k.current.dismissOnMouseDown = ! 1 ) ); + } ) ); + } + function g( e, t ) { + const n = es( e ); + if ( ! n ) return; + const i = Kr( n, e.type, () => { + t( e ), i(); + } ); + } + function x( e ) { + I.clear(), + 'pointerdown' === e.type && ( E.current = e.pointerType ), + ( 'mousedown' === e.type && + k.current && + ! k.current.dismissOnMouseDown ) || + g( e, e => { + 'pointerdown' === e.type + ? ( function ( e ) { + 'sloppy' === s() && + 'touch' !== e.pointerType && + u.select( 'open' ) && + n && + ! M( e ) && + l( e ); + } )( e ) + : l( e ); + } ); + } + function V( e ) { + if ( ! C.current ) return; + const n = S.current; + o(), + 'intentional' === s() && + ( 'pointercancel' !== e.type + ? a( e ) || + ( n + ? r() + : ( 'function' != typeof h || h( e ) ) && + ( t.clear(), ( _.current = ! 0 ), O() ) ) + : n && r() ); + } + function T( e ) { + if ( 'sloppy' !== s() || ! k.current || M( e ) ) return; + const t = e.touches[ 0 ]; + if ( ! t ) return; + const n = Math.abs( t.clientX - k.current.startX ), + i = Math.abs( t.clientY - k.current.startY ), + r = Math.sqrt( n * n + i * i ); + r > 5 && ( k.current.dismissOnTouchEnd = ! 0 ), + r > 10 && ( l( e ), I.clear(), ( k.current = null ) ); + } + function A( e ) { + 'sloppy' === s() && + k.current && + ! M( e ) && + ( k.current.dismissOnTouchEnd && l( e ), + I.clear(), + ( k.current = null ) ); + } + const R = Xr( f ), + F = Ur( + i && + Ur( + Kr( R, 'keydown', N ), + Kr( R, 'compositionstart', function () { + e.clear(), ( j.current = ! 0 ); + } ), + Kr( R, 'compositionend', function () { + e.start( _o() ? 5 : 0, () => { + j.current = ! 1; + } ); + } ) + ), + v && + Ur( + Kr( R, 'click', x, ! 0 ), + Kr( R, 'pointerdown', x, ! 0 ), + Kr( R, 'pointerup', V, ! 0 ), + Kr( R, 'pointercancel', V, ! 0 ), + Kr( R, 'mousedown', x, ! 0 ), + Kr( R, 'mouseup', V, ! 0 ), + Kr( + R, + 'touchstart', + function ( e ) { + ( E.current = 'touch' ), g( e, c ); + }, + ! 0 + ), + Kr( + R, + 'touchmove', + function ( e ) { + g( e, T ); + }, + ! 0 + ), + Kr( + R, + 'touchend', + function ( e ) { + g( e, A ); + }, + ! 0 + ) + ) + ); + return () => { + F(), e.clear(), t.clear(), o(), ( _.current = ! 1 ); + }; + }, [ m, f, i, v, h, d, n, w, y, N, O, b, P, M, p, u, I ] ), + J.useEffect( O, [ h, O ] ); + const L = J.useMemo( + () => ( { + onKeyDown: N, + [ os[ a ] ]: T, + ...( 'intentional' !== a && { onClick: T } ), + } ), + [ N, T, a ] + ), + D = J.useMemo( + () => ( { + onKeyDown: N, + onPointerDown: F, + onMouseDown: F, + onClickCapture: A, + onMouseDownCapture( e ) { + A(), R( e ); + }, + onPointerDownCapture( e ) { + A(), R( e ); + }, + onMouseUpCapture: A, + onTouchEndCapture: A, + onTouchMoveCapture: A, + } ), + [ N, A, R, F ] + ); + return J.useMemo( + () => ( n ? { reference: L, floating: D, trigger: L } : {} ), + [ n, L, D ] + ); + } )( i, { enabled: ! t, referencePress: () => e.select( 'closeOnClick' ) } ), + o = ( function ( e, t = {} ) { + const { enabled: n = ! 0, axis: i = 'both' } = t, + r = 'rootStore' in e ? e.rootStore : e, + o = r.useState( 'open' ), + s = r.useState( 'floatingElement' ), + a = r.useState( 'domReferenceElement' ), + l = r.context.dataRef, + c = J.useRef( ! 1 ), + u = J.useRef( null ), + [ d, f ] = J.useState(), + [ m, p ] = J.useState( [] ), + g = eo( e => { + r.set( 'positionReference', e ); + } ), + h = eo( ( e, t, n ) => { + c.current || + ( l.current.openEvent && ! as( l.current.openEvent ) ) || + r.set( + 'positionReference', + ( function ( e, t ) { + let n = null, + i = null, + r = ! 1; + return { + contextElement: e || void 0, + getBoundingClientRect() { + const o = e?.getBoundingClientRect() || { + width: 0, + height: 0, + x: 0, + y: 0, + }, + s = 'x' === t.axis || 'both' === t.axis, + a = 'y' === t.axis || 'both' === t.axis, + l = + [ 'mouseenter', 'mousemove' ].includes( + t.dataRef.current.openEvent?.type || + '' + ) && 'touch' !== t.pointerType; + let c = o.width, + u = o.height, + d = o.x, + f = o.y; + return ( + null == n && t.x && s && ( n = o.x - t.x ), + null == i && t.y && a && ( i = o.y - t.y ), + ( d -= n || 0 ), + ( f -= i || 0 ), + ( c = 0 ), + ( u = 0 ), + ! r || l + ? ( ( c = + 'y' === t.axis ? o.width : 0 ), + ( u = 'x' === t.axis ? o.height : 0 ), + ( d = s && null != t.x ? t.x : d ), + ( f = a && null != t.y ? t.y : f ) ) + : r && + ! l && + ( ( u = + 'x' === t.axis ? o.height : u ), + ( c = + 'y' === t.axis + ? o.width + : c ) ), + ( r = ! 0 ), + { + width: c, + height: u, + x: d, + y: f, + top: f, + right: d + c, + bottom: f + u, + left: d, + } + ); + }, + }; + } )( n ?? a, { + x: e, + y: t, + axis: i, + dataRef: l, + pointerType: d, + } ) + ); + } ), + v = eo( e => { + o + ? u.current || + ( h( e.clientX, e.clientY, e.currentTarget ), p( [] ) ) + : h( e.clientX, e.clientY, e.currentTarget ); + } ), + b = is( d ) ? s : o; + J.useEffect( () => { + if ( ! n ) return void g( a ); + if ( ! b ) return; + function e() { + u.current?.(), ( u.current = null ); + } + const t = co( s ); + return ( + ! l.current.openEvent || as( l.current.openEvent ) + ? ( u.current = Kr( t, 'mousemove', function ( t ) { + const n = es( t ); + Jo( s, n ) ? e() : h( t.clientX, t.clientY ); + } ) ) + : g( a ), + e + ); + }, [ b, n, s, l, a, r, h, g, m ] ), + J.useEffect( + () => () => { + r.set( 'positionReference', null ); + }, + [ r ] + ), + J.useEffect( () => { + n && ! s && ( c.current = ! 1 ); + }, [ n, s ] ), + J.useEffect( () => { + ! n && o && ( c.current = ! 0 ); + }, [ n, o ] ); + const w = J.useMemo( () => { + function e( e ) { + f( e.pointerType ); + } + return { + onPointerDown: e, + onPointerEnter: e, + onMouseMove: v, + onMouseEnter: v, + }; + }, [ v ] ); + return J.useMemo( + () => ( n ? { reference: w, trigger: w } : {} ), + [ n, w ] + ); + } )( i, { enabled: ! t && 'none' !== n, axis: 'none' === n ? void 0 : n } ), + s = J.useMemo( + () => me( o.reference, r.reference ), + [ o.reference, r.reference ] + ), + a = J.useMemo( () => me( o.trigger, r.trigger ), [ o.trigger, r.trigger ] ), + l = J.useMemo( + () => me( Ps, o.floating, r.floating ), + [ o.floating, r.floating ] + ); + return ( + ( function ( e, t ) { + e.useSyncedValues( t ), + qr( + () => () => { + e.update( { + activeTriggerProps: de, + inactiveTriggerProps: de, + popupProps: de, + } ); + }, + [ e ] + ); + } )( e, { activeTriggerProps: s, inactiveTriggerProps: a, popupProps: l } ), + null + ); + } + function zs( e ) { + return ( 0, c.jsx )( Ds, { ...e } ); + } + function Ws( e ) { + const t = ne( $s, e ).current; + return ( t.next = e ), qr( t.effect ), t; + } + function $s( e ) { + const t = { + current: e, + next: e, + effect: () => { + t.current = t.next; + }, + }; + return t; + } + let Hs = ( function ( e ) { + return ( + ( e.open = 'data-open' ), + ( e.closed = 'data-closed' ), + ( e[ ( e.startingStyle = Es.startingStyle ) ] = 'startingStyle' ), + ( e[ ( e.endingStyle = Es.endingStyle ) ] = 'endingStyle' ), + ( e.anchorHidden = 'data-anchor-hidden' ), + ( e.side = 'data-side' ), + ( e.align = 'data-align' ), + e + ); + } )( {} ), + qs = ( function ( e ) { + return ( e.popupOpen = 'data-popup-open' ), ( e.pressed = 'data-pressed' ), e; + } )( {} ); + const Gs = { [ qs.popupOpen ]: '' }, + Ys = ( qs.popupOpen, qs.pressed, { [ Hs.open ]: '' } ), + Ks = { [ Hs.closed ]: '' }, + Us = { [ Hs.anchorHidden ]: '' }, + Xs = { open: e => ( e ? Gs : null ) }, + Zs = { open: e => ( e ? Ys : Ks ), anchorHidden: e => ( e ? Us : null ) }, + Qs = J.createContext( void 0 ); + function Js( e, t, n ) { + const i = ( function ( e, t ) { + return null == t || is( t ) ? ( 'function' == typeof e ? e() : e ) : 0; + } )( e, n ); + return 'number' == typeof i ? i : i?.[ t ]; + } + function ea( e ) { + return 'function' == typeof e ? e() : e; + } + function ta( e, t ) { + return t || 'click' === e || 'mousedown' === e; + } + const na = J.createContext( { + hasProvider: ! 1, + timeoutMs: 0, + delayRef: { current: 0 }, + initialDelayRef: { current: 0 }, + timeout: new oo(), + currentIdRef: { current: null }, + currentContextRef: { current: null }, + } ); + class ia { + constructor() { + ( this.pointerType = void 0 ), + ( this.interactedInside = ! 1 ), + ( this.handler = void 0 ), + ( this.blockMouseMove = ! 0 ), + ( this.performedPointerEventsMutation = ! 1 ), + ( this.pointerEventsScopeElement = null ), + ( this.pointerEventsReferenceElement = null ), + ( this.pointerEventsFloatingElement = null ), + ( this.restTimeoutPending = ! 1 ), + ( this.openChangeTimeout = new oo() ), + ( this.restTimeout = new oo() ), + ( this.handleCloseOptions = void 0 ); + } + static create() { + return new ia(); + } + dispose = () => { + this.openChangeTimeout.clear(), this.restTimeout.clear(); + }; + disposeEffect = () => this.dispose; + } + const ra = new WeakMap(); + function oa( e ) { + if ( ! e.performedPointerEventsMutation ) return; + const t = e.pointerEventsScopeElement; + t && + ra.get( t ) === e && + ( e.pointerEventsScopeElement?.style.removeProperty( 'pointer-events' ), + e.pointerEventsReferenceElement?.style.removeProperty( 'pointer-events' ), + e.pointerEventsFloatingElement?.style.removeProperty( 'pointer-events' ), + ra.delete( t ) ), + ( e.performedPointerEventsMutation = ! 1 ), + ( e.pointerEventsScopeElement = null ), + ( e.pointerEventsReferenceElement = null ), + ( e.pointerEventsFloatingElement = null ); + } + function sa( e, t ) { + const { scopeElement: n, referenceElement: i, floatingElement: r } = t, + o = ra.get( n ); + o && o !== e && oa( o ), + oa( e ), + ( e.performedPointerEventsMutation = ! 0 ), + ( e.pointerEventsScopeElement = n ), + ( e.pointerEventsReferenceElement = i ), + ( e.pointerEventsFloatingElement = r ), + ra.set( n, e ), + ( n.style.pointerEvents = 'none' ), + ( i.style.pointerEvents = 'auto' ), + ( r.style.pointerEvents = 'auto' ); + } + function aa( e ) { + const t = e.context.dataRef.current, + n = ne( () => t.hoverInteractionState ?? ia.create() ).current; + return ( + t.hoverInteractionState || ( t.hoverInteractionState = n ), + ro( t.hoverInteractionState.disposeEffect ), + t.hoverInteractionState + ); + } + const la = { current: null }, + ca = 0.1 * 0.1, + ua = 0.5; + function da( e, t, n, i, r, o ) { + return i >= t != o >= t && e <= ( ( r - n ) * ( t - i ) ) / ( o - i ) + n; + } + function fa( e, t, n, i, r, o, s, a, l, c ) { + let u = ! 1; + return ( + da( e, t, n, i, r, o ) && ( u = ! u ), + da( e, t, r, o, s, a ) && ( u = ! u ), + da( e, t, s, a, l, c ) && ( u = ! u ), + da( e, t, l, c, n, i ) && ( u = ! u ), + u + ); + } + function ma( e, t, n, i, r, o ) { + const s = Math.min( n, r ), + a = Math.max( n, r ), + l = Math.min( i, o ), + c = Math.max( i, o ); + return e >= s && e <= a && t >= l && t <= c; + } + function pa( e = {} ) { + const { blockPointerEvents: t = ! 1 } = e, + n = new oo(), + i = ( { + x: e, + y: t, + placement: i, + elements: r, + onClose: o, + nodeId: s, + tree: a, + } ) => { + const l = i?.split( '-' )[ 0 ]; + let c = ! 1, + u = null, + d = null, + f = 'undefined' != typeof performance ? performance.now() : 0; + return function ( i ) { + n.clear(); + const m = r.domReference, + p = r.floating; + if ( ! m || ! p || null == l || null == e || null == t ) return; + const { clientX: g, clientY: h } = i, + v = es( i ), + b = 'mouseleave' === i.type, + w = Jo( p, v ), + y = Jo( m, v ); + if ( w && ( ( c = ! 0 ), ! b ) ) return; + if ( y && ( ( c = ! 1 ), ! b ) ) return void ( c = ! 0 ); + if ( b && mo( i.relatedTarget ) && Jo( p, i.relatedTarget ) ) return; + function x() { + return Boolean( a && rs( a.nodesRef.current, s ).length > 0 ); + } + function C() { + x() || ( n.clear(), o() ); + } + if ( x() ) return; + const S = m.getBoundingClientRect(), + _ = p.getBoundingClientRect(), + j = e > _.right - _.width / 2, + E = t > _.bottom - _.height / 2, + k = _.width > S.width, + I = _.height > S.height, + V = ( k ? S : _ ).left, + O = ( k ? S : _ ).right, + P = ( I ? S : _ ).top, + M = ( I ? S : _ ).bottom; + if ( + ( 'top' === l && t >= S.bottom - 1 ) || + ( 'bottom' === l && t <= S.top + 1 ) || + ( 'left' === l && e >= S.right - 1 ) || + ( 'right' === l && e <= S.left + 1 ) + ) + return void C(); + let T = ! 1; + switch ( l ) { + case 'top': + T = ma( g, h, V, S.top + 1, O, _.bottom - 1 ); + break; + case 'bottom': + T = ma( g, h, V, _.top + 1, O, S.bottom - 1 ); + break; + case 'left': + T = ma( g, h, _.right - 1, M, S.left + 1, P ); + break; + case 'right': + T = ma( g, h, S.right - 1, M, _.left + 1, P ); + } + if ( T ) return; + if ( + c && + ! ( function ( e, t, n ) { + return ( + e >= n.x && + e <= n.x + n.width && + t >= n.y && + t <= n.y + n.height + ); + } )( g, h, S ) + ) + return void C(); + if ( + ! b && + ( function ( e, t ) { + const n = performance.now(), + i = n - f; + if ( null === u || null === d || 0 === i ) + return ( u = e ), ( d = t ), ( f = n ), ! 1; + const r = e - u, + o = t - d; + return ( + ( u = e ), ( d = t ), ( f = n ), r * r + o * o < i * i * ca + ); + } )( g, h ) + ) + return void C(); + let N = ! 1; + switch ( l ) { + case 'top': { + const n = k ? 0.25 : 2, + i = k || j ? e + n : e - n, + r = k ? e - n : j ? e + n : e - n, + o = t + ua + 1, + s = j || k ? _.bottom - ua : _.top, + a = j ? ( k ? _.bottom - ua : _.top ) : _.bottom - ua; + N = fa( g, h, i, o, r, o, _.left, s, _.right, a ); + break; + } + case 'bottom': { + const n = k ? 0.25 : 2, + i = k || j ? e + n : e - n, + r = k ? e - n : j ? e + n : e - n, + o = t - ua, + s = j || k ? _.top + ua : _.bottom, + a = j ? ( k ? _.top + ua : _.bottom ) : _.top + ua; + N = fa( g, h, i, o, r, o, _.left, s, _.right, a ); + break; + } + case 'left': { + const n = I ? 0.25 : 2, + i = I || E ? t + n : t - n, + r = I ? t - n : E ? t + n : t - n, + o = e + ua + 1, + s = E || I ? _.right - ua : _.left, + a = E ? ( I ? _.right - ua : _.left ) : _.right - ua; + N = fa( g, h, s, _.top, a, _.bottom, o, i, o, r ); + break; + } + case 'right': { + const n = I ? 0.25 : 2, + i = I || E ? t + n : t - n, + r = I ? t - n : E ? t + n : t - n, + o = e - ua, + s = E || I ? _.left + ua : _.right, + a = E ? ( I ? _.left + ua : _.right ) : _.left + ua; + N = fa( g, h, o, i, o, r, s, _.top, a, _.bottom ); + break; + } + } + N ? c || n.start( 40, C ) : C(); + }; + }; + return ( i.__options = { ...e, blockPointerEvents: t } ), i; + } + const ga = Ko && Yo; + function ha( e, t = {} ) { + const { enabled: n = ! 0, delay: i } = t, + r = 'rootStore' in e ? e.rootStore : e, + { events: o, dataRef: s } = r.context, + a = J.useRef( ! 1 ), + l = J.useRef( null ), + c = J.useRef( ! 0 ), + u = so(); + J.useEffect( () => { + const e = r.select( 'domReferenceElement' ); + if ( ! n ) return; + const t = co( e ); + return Ur( + Kr( t, 'blur', function () { + const e = r.select( 'domReferenceElement' ); + ! r.select( 'open' ) && + po( e ) && + e === Qo( Xr( e ) ) && + ( a.current = ! 0 ); + } ), + ga && + Kr( + t, + 'keydown', + function () { + c.current = ! 0; + }, + ! 0 + ), + ga && + Kr( + t, + 'pointerdown', + function () { + c.current = ! 1; + }, + ! 0 + ) + ); + }, [ r, n ] ), + J.useEffect( () => { + if ( n ) + return ( + o.on( 'openchange', e ), + () => { + o.off( 'openchange', e ); + } + ); + function e( e ) { + if ( e.reason === Lo || e.reason === zo ) { + const e = r.select( 'domReferenceElement' ); + mo( e ) && ( ( l.current = e ), ( a.current = ! 0 ) ); + } + } + }, [ o, n, r ] ); + const d = J.useMemo( () => { + function e() { + ( a.current = ! 1 ), ( l.current = null ); + } + return { + onMouseLeave() { + e(); + }, + onFocus( t ) { + const n = t.currentTarget; + if ( a.current ) { + if ( l.current === n ) return; + e(); + } + const o = es( t.nativeEvent ); + if ( mo( o ) ) + if ( ga && ! t.relatedTarget ) { + if ( ! c.current && ( ! po( ( s = o ) ) || ! s.matches( Zo ) ) ) + return; + } else if ( + ! ( function ( e ) { + if ( ! e || Uo ) return ! 0; + try { + return e.matches( ':focus-visible' ); + } catch ( e ) { + return ! 0; + } + } )( o ) + ) + return; + var s; + const d = ts( t.relatedTarget, r.context.triggerElements ), + { nativeEvent: f, currentTarget: m } = t, + p = 'function' == typeof i ? i() : i; + ( r.select( 'open' ) && d ) || 0 === p || void 0 === p + ? r.setOpen( ! 0, Ro( Bo, f, m ) ) + : u.start( p, () => { + a.current || r.setOpen( ! 0, Ro( Bo, f, m ) ); + } ); + }, + onBlur( t ) { + e(); + const n = t.relatedTarget, + i = t.nativeEvent, + o = + mo( n ) && + n.hasAttribute( Wo( 'focus-guard' ) ) && + 'outside' === n.getAttribute( 'data-type' ); + u.start( 0, () => { + const e = r.select( 'domReferenceElement' ), + t = Qo( Xr( e ) ); + ( n || t !== e ) && + ( Jo( s.current.floatingContext?.refs.floating.current, t ) || + Jo( e, t ) || + o || + ts( n ?? t, r.context.triggerElements ) || + r.setOpen( ! 1, Ro( Bo, i ) ) ); + } ); + }, + }; + }, [ s, i, r, u ] ); + return J.useMemo( () => ( n ? { reference: d, trigger: d } : {} ), [ n, d ] ); + } + let va = ( function ( e ) { + return ( + ( e[ ( e.popupOpen = qs.popupOpen ) ] = 'popupOpen' ), + ( e.triggerDisabled = 'data-trigger-disabled' ), + e + ); + } )( {} ); + const ba = 'data-base-ui-tooltip-trigger'; + function wa( e ) { + if ( 'composedPath' in e ) { + const t = e.composedPath(); + for ( let e = 0; e < t.length; e += 1 ) { + const n = t[ e ]; + if ( mo( n ) ) return n; + } + } + const t = e.target; + return mo( t ) ? t : null; + } + const ya = + ( ( xa = function ( e, t ) { + const { + render: n, + className: i, + style: r, + handle: o, + payload: s, + disabled: a, + delay: l, + closeOnClick: c = ! 0, + closeDelay: u, + id: d, + ...f + } = e, + m = Yr( ! 0 ), + p = o?.store ?? m; + if ( ! p ) throw new Error( Q( 82 ) ); + const g = us( d, 'base-ui' ), + h = p.useState( 'isTriggerActive', g ), + v = p.useState( 'isOpenedByTrigger', g ), + b = p.useState( 'floatingRootContext' ), + w = J.useRef( null ), + y = l ?? 600, + x = u ?? 0, + { registerTrigger: C, isMountedByThisTrigger: S } = ( function ( + e, + t, + n, + i + ) { + const r = n.useState( 'isMountedByTrigger', e ), + o = ( function ( e, t ) { + const n = J.useRef( null ), + i = J.useRef( null ); + return J.useCallback( + r => { + if ( void 0 === e ) return; + let o = ! 1; + if ( null !== n.current ) { + const e = n.current, + r = i.current, + s = t.context.triggerElements.getById( e ); + r && + s === r && + ( t.context.triggerElements.delete( e ), + ( o = ! 0 ) ), + ( n.current = null ), + ( i.current = null ); + } + if ( + ( null !== r && + ( ( n.current = e ), + ( i.current = r ), + t.context.triggerElements.add( e, r ), + ( o = ! 0 ) ), + o ) + ) { + const e = t.context.triggerElements.size; + t.select( 'open' ) && + t.state.triggerCount !== e && + t.set( 'triggerCount', e ); + } + }, + [ t, e ] + ); + } )( e, n ), + s = eo( t => { + if ( ( o( t ), ! t ) ) return; + const r = n.select( 'open' ), + s = n.select( 'activeTriggerId' ); + s !== e + ? null == s && + r && + n.update( { + activeTriggerId: e, + activeTriggerElement: t, + ...i, + } ) + : n.update( { + activeTriggerElement: t, + ...( r ? i : null ), + } ); + } ); + return ( + qr( () => { + r && n.update( { activeTriggerElement: t.current, ...i } ); + }, [ r, n, t, ...Object.values( i ) ] ), + { registerTrigger: s, isMountedByThisTrigger: r } + ); + } )( g, w, p, { payload: s, closeOnClick: c, closeDelay: x } ), + _ = J.useContext( Qs ), + { + delayRef: j, + isInstantPhase: E, + hasProvider: k, + } = ( function ( e, t = { open: ! 1 } ) { + const { open: n } = t, + i = 'rootStore' in e ? e.rootStore : e, + r = i.useState( 'floatingId' ), + o = J.useContext( na ), + { + currentIdRef: s, + delayRef: a, + timeoutMs: l, + initialDelayRef: c, + currentContextRef: u, + hasProvider: d, + timeout: f, + } = o, + [ m, p ] = J.useState( ! 1 ); + return ( + qr( () => { + function e() { + p( ! 1 ), + u.current?.setIsInstantPhase( ! 1 ), + ( s.current = null ), + ( u.current = null ), + ( a.current = c.current ); + } + if ( s.current && ! n && s.current === r ) { + if ( ( p( ! 1 ), l ) ) { + const t = r; + return ( + f.start( l, () => { + i.select( 'open' ) || + ( s.current && s.current !== t ) || + e(); + } ), + () => { + f.clear(); + } + ); + } + e(); + } + }, [ n, r, s, a, l, c, u, f, i ] ), + qr( () => { + if ( ! n ) return; + const e = u.current, + t = s.current; + f.clear(), + ( u.current = { + onOpenChange: i.setOpen, + setIsInstantPhase: p, + } ), + ( s.current = r ), + ( a.current = { + open: 0, + close: Js( c.current, 'close' ), + } ), + null !== t && t !== r + ? ( p( ! 0 ), + e?.setIsInstantPhase( ! 0 ), + e?.onOpenChange( ! 1, Ro( Fo ) ) ) + : ( p( ! 1 ), e?.setIsInstantPhase( ! 1 ) ); + }, [ n, r, i, s, a, c, u, f ] ), + qr( + () => () => { + u.current = null; + }, + [ u ] + ), + J.useMemo( + () => ( { hasProvider: d, delayRef: a, isInstantPhase: m } ), + [ d, a, m ] + ) + ); + } )( b, { open: v } ), + I = aa( b ); + p.useSyncedValue( 'isInstantPhase', E ); + const V = p.useState( 'disabled' ), + O = a ?? V, + P = Ws( O ), + M = p.useState( 'trackCursorAxis' ), + T = p.useState( 'disableHoverablePopup' ), + N = J.useRef( ! 1 ), + A = so(), + R = J.useRef( void 0 ); + function F() { + const e = _?.delay, + t = 'object' == typeof j.current ? j.current.open : void 0; + let n = y; + return k && ( n = 0 !== t ? l ?? e ?? y : 0 ), n; + } + function L( e ) { + const t = w.current; + if ( ! t || ! e ) return ! 1; + const n = ( function ( e ) { + let t = e; + for ( ; t; ) { + if ( t.hasAttribute( ba ) ) return t; + const e = t.parentElement; + if ( e ) { + t = e; + continue; + } + const n = t.getRootNode(); + t = 'host' in n && mo( n.host ) ? n.host : null; + } + return null; + } )( e ); + return null !== n && n !== t && Jo( t, n ); + } + const D = ( function ( e, t = {} ) { + const { + enabled: n = ! 0, + delay: i = 0, + handleClose: r = null, + mouseOnly: o = ! 1, + restMs: s = 0, + move: a = ! 0, + triggerElementRef: l = la, + externalTree: c, + isActiveTrigger: u = ! 0, + getHandleCloseContext: d, + isClosing: f, + shouldOpen: m, + } = t, + p = 'rootStore' in e ? e.rootStore : e, + { dataRef: g, events: h } = p.context, + v = Ao( c ), + b = aa( p ), + w = J.useRef( ! 1 ), + y = Ws( r ), + x = Ws( i ), + C = Ws( s ), + S = Ws( n ), + _ = Ws( m ), + j = Ws( f ), + E = eo( () => ta( g.current.openEvent?.type, b.interactedInside ) ), + k = eo( () => ! 1 !== _.current?.() ), + I = eo( ( e, t, n ) => { + const i = p.context.triggerElements; + if ( i.hasElement( t ) ) return ! e || ! Jo( e, t ); + if ( ! mo( n ) ) return ! 1; + const r = n; + return ( + i.hasMatchingElement( e => Jo( e, r ) ) && + ( ! e || ! Jo( e, r ) ) + ); + } ), + V = eo( () => { + b.handler && + ( Xr( + p.select( 'domReferenceElement' ) + ).removeEventListener( 'mousemove', b.handler ), + ( b.handler = void 0 ) ); + } ), + O = eo( () => { + oa( b ); + } ); + return ( + u && ( b.handleCloseOptions = y.current?.__options ), + J.useEffect( () => V, [ V ] ), + J.useEffect( () => { + if ( n ) + return ( + h.on( 'openchange', e ), + () => { + h.off( 'openchange', e ); + } + ); + function e( e ) { + e.open + ? ( w.current = ! 1 ) + : ( ( w.current = e.reason === Do ), + V(), + b.openChangeTimeout.clear(), + b.restTimeout.clear(), + ( b.blockMouseMove = ! 0 ), + ( b.restTimeoutPending = ! 1 ) ); + } + }, [ n, h, b, V ] ), + J.useEffect( () => { + if ( ! n ) return; + function e( e, t = ! 0 ) { + const n = Js( x.current, 'close', b.pointerType ); + n + ? b.openChangeTimeout.start( n, () => { + p.setOpen( ! 1, Ro( Do, e ) ), + v?.events.emit( 'floating.closed', e ); + } ) + : t && + ( b.openChangeTimeout.clear(), + p.setOpen( ! 1, Ro( Do, e ) ), + v?.events.emit( 'floating.closed', e ) ); + } + const t = + l.current ?? + ( u ? p.select( 'domReferenceElement' ) : null ); + if ( mo( t ) ) + return a + ? Ur( + Kr( t, 'mousemove', i, { once: ! 0 } ), + Kr( t, 'mouseenter', i ), + Kr( t, 'mouseleave', r ) + ) + : Ur( + Kr( t, 'mouseenter', i ), + Kr( t, 'mouseleave', r ) + ); + function i( e ) { + if ( + ( b.openChangeTimeout.clear(), + ( b.blockMouseMove = ! 1 ), + o && ! is( b.pointerType ) ) + ) + return; + const t = ea( C.current ), + n = Js( x.current, 'open', b.pointerType ), + i = es( e ), + r = e.currentTarget ?? null, + s = p.select( 'domReferenceElement' ); + let a = r; + if ( + mo( i ) && + ! p.context.triggerElements.hasElement( i ) + ) + for ( const e of p.context.triggerElements.elements() ) + if ( Jo( e, i ) ) { + a = e; + break; + } + mo( r ) && + mo( s ) && + ! p.context.triggerElements.hasElement( r ) && + Jo( r, s ) && + ( a = s ); + const l = null != a && I( s, a, i ), + c = p.select( 'open' ), + u = + j.current?.() ?? + 'ending' === p.select( 'transitionStatus' ), + d = ! c && u && w.current, + f = ! l && mo( a ) && mo( s ) && Jo( s, a ) && d, + m = t > 0 && ! n, + g = ! c || l; + ( l && ( c || d ) ) || f + ? k() && p.setOpen( ! 0, Ro( Do, e, a ) ) + : m || + ( n + ? b.openChangeTimeout.start( n, () => { + g && + k() && + p.setOpen( ! 0, Ro( Do, e, a ) ); + } ) + : g && + k() && + p.setOpen( ! 0, Ro( Do, e, a ) ) ); + } + function r( t ) { + if ( E() ) return void O(); + V(); + const n = Xr( p.select( 'domReferenceElement' ) ); + b.restTimeout.clear(), ( b.restTimeoutPending = ! 1 ); + const i = g.current.floatingContext ?? d?.(); + if ( ! ts( t.relatedTarget, p.context.triggerElements ) ) { + if ( y.current && i ) { + p.select( 'open' ) || b.openChangeTimeout.clear(); + const r = l.current; + return ( + ( b.handler = y.current( { + ...i, + tree: v, + x: t.clientX, + y: t.clientY, + onClose() { + O(), + V(), + S.current && + ! E() && + r === + p.select( + 'domReferenceElement' + ) && + e( t, ! 0 ); + }, + } ) ), + n.addEventListener( 'mousemove', b.handler ), + void b.handler( t ) + ); + } + ( 'touch' !== b.pointerType || + ! Jo( + p.select( 'floatingElement' ), + t.relatedTarget + ) ) && + e( t ); + } + } + }, [ V, O, g, x, p, n, y, b, u, I, E, o, a, C, l, v, S, d, j, k ] ), + J.useMemo( () => { + if ( n ) + return { + onPointerDown: e, + onPointerEnter: e, + onMouseMove( e ) { + const { nativeEvent: t } = e, + n = e.currentTarget, + i = p.select( 'domReferenceElement' ), + r = p.select( 'open' ), + s = I( i, n, e.target ); + if ( o && ! is( b.pointerType ) ) return; + if ( + r && + s && + b.handleCloseOptions?.blockPointerEvents + ) { + const e = p.select( 'floatingElement' ); + if ( e ) { + const t = + b.handleCloseOptions?.getScope?.() ?? + n.ownerDocument.body; + sa( b, { + scopeElement: t, + referenceElement: n, + floatingElement: e, + } ); + } + } + const a = ea( C.current ); + function l() { + if ( ( ( b.restTimeoutPending = ! 1 ), E() ) ) + return; + const e = p.select( 'open' ); + b.blockMouseMove || + ( e && ! s ) || + ! k() || + p.setOpen( ! 0, Ro( Do, t, n ) ); + } + ( r && ! s ) || + 0 === a || + ( ! s && + b.restTimeoutPending && + e.movementX ** 2 + e.movementY ** 2 < 2 ) || + ( b.restTimeout.clear(), + 'touch' === b.pointerType + ? js.flushSync( () => { + l(); + } ) + : s && r + ? l() + : ( ( b.restTimeoutPending = ! 0 ), + b.restTimeout.start( a, l ) ) ); + }, + }; + function e( e ) { + b.pointerType = e.pointerType; + } + }, [ n, b, E, I, o, p, C, k ] ) + ); + } )( b, { + enabled: ! O, + mouseOnly: ! 0, + move: ! 1, + handleClose: T || 'both' === M ? null : pa(), + restMs: F, + delay() { + const e = 'object' == typeof j.current ? j.current.close : void 0; + let t = x; + return null == u && k && ( t = e ), { close: t }; + }, + triggerElementRef: w, + isActiveTrigger: h, + isClosing: () => 'ending' === p.select( 'transitionStatus' ), + shouldOpen: () => ! N.current, + } ), + B = ha( b, { enabled: ! O } ).reference, + z = p.useState( 'triggerProps', S ); + return _e( 'button', e, { + state: { open: v }, + ref: [ t, C, w ], + props: [ + D, + B, + S || 'none' !== M ? z : void 0, + { + onMouseOver( e ) { + ( e => { + const t = N.current, + n = wa( e ), + i = ( function ( e ) { + const t = L( e ); + return ( + ( N.current = t ), + t && + ( I.openChangeTimeout.clear(), + I.restTimeout.clear(), + ( I.restTimeoutPending = ! 1 ), + A.clear() ), + t + ); + } )( n ), + r = w.current, + o = r && n && Jo( r, n ); + if ( + i && + p.select( 'open' ) && + p.select( 'lastOpenChangeReason' ) === Do + ) + p.setOpen( ! 1, Ro( Do, e ) ); + else if ( + t && + ! i && + o && + ! P.current && + ! p.select( 'open' ) && + r && + is( R.current ) + ) { + const t = () => { + N.current || + P.current || + p.select( 'open' ) || + p.setOpen( ! 0, Ro( Do, e, r ) ); + }, + n = F(); + 0 === n ? ( A.clear(), t() ) : A.start( n, t ); + } + } )( e.nativeEvent ); + }, + onFocus( e ) { + L( wa( e.nativeEvent ) ) && e.preventBaseUIHandler(); + }, + onMouseLeave() { + ( N.current = ! 1 ), A.clear(), ( R.current = void 0 ); + }, + onPointerEnter( e ) { + R.current = e.pointerType; + }, + onPointerDown( e ) { + ( R.current = e.pointerType ), + p.set( 'closeOnClick', c ), + c && + ! p.select( 'open' ) && + p.cancelPendingOpen( e.nativeEvent ); + }, + onClick( e ) { + c && + ! p.select( 'open' ) && + p.cancelPendingOpen( e.nativeEvent ); + }, + id: g, + [ va.triggerDisabled ]: O ? '' : void 0, + [ ba ]: O ? void 0 : '', + }, + f, + ], + stateAttributesMapping: Xs, + } ); + } ), + J.forwardRef( $r( xa ) ) ); + var xa, + Ca = ( 0, e.forwardRef )( function ( e, t ) { + return ( 0, c.jsx )( ya, { ref: t, ...e } ); + } ); + const Sa = J.createContext( void 0 ), + _a = { style: { transition: 'none' } }, + ja = { fallbackAxisSide: 'end' }; + function Ea( e ) { + return 'starting' === e ? _a : de; + } + const ka = { ...Zs, ...Vs }, + Ia = J.forwardRef( function ( e, t ) { + const { render: n, className: i, style: r, ...o } = e, + s = Yr(), + { side: a, align: l } = ( function () { + const e = J.useContext( Sa ); + if ( void 0 === e ) throw new Error( Q( 71 ) ); + return e; + } )(), + c = s.useState( 'open' ), + u = s.useState( 'instantType' ), + d = s.useState( 'transitionStatus' ), + f = s.useState( 'popupProps' ), + m = s.useState( 'floatingRootContext' ), + p = s.useState( 'disabled' ), + g = s.useState( 'closeDelay' ); + Os( { + open: c, + ref: s.context.popupRef, + onComplete() { + c && s.context.onOpenChangeComplete?.( ! 0 ); + }, + } ), + ( function ( e, t = {} ) { + const { enabled: n = ! 0, closeDelay: i = 0, nodeId: r } = t, + o = 'rootStore' in e ? e.rootStore : e, + s = o.useState( 'open' ), + a = o.useState( 'floatingElement' ), + l = o.useState( 'domReferenceElement' ), + { dataRef: c } = o.context, + u = Ao(), + d = No(), + f = aa( o ), + m = so(), + p = eo( () => ta( c.current.openEvent?.type, f.interactedInside ) ), + g = eo( () => { + return ( + ( e = c.current.openEvent?.type ), + e?.includes( 'mouse' ) && 'mousedown' !== e + ); + var e; + } ), + h = eo( () => { + oa( f ); + } ); + qr( () => { + s || + ( ( f.pointerType = void 0 ), + ( f.restTimeoutPending = ! 1 ), + ( f.interactedInside = ! 1 ), + h() ); + }, [ s, f, h ] ), + J.useEffect( () => h, [ h ] ), + qr( () => { + if ( + n && + s && + f.handleCloseOptions?.blockPointerEvents && + g() && + mo( l ) && + a + ) { + const e = l, + t = a, + n = Xr( a ), + i = u?.nodesRef.current.find( e => e.id === d )?.context + ?.elements.floating; + i && ( i.style.pointerEvents = '' ); + const r = + f.pointerEventsScopeElement !== t + ? f.pointerEventsScopeElement + : null, + o = i !== t ? i : null, + s = + f.handleCloseOptions?.getScope?.() ?? + r ?? + o ?? + e.closest( '[data-rootownerid]' ) ?? + n.body; + return ( + sa( f, { + scopeElement: s, + referenceElement: e, + floatingElement: t, + } ), + () => { + h(); + } + ); + } + }, [ n, s, l, a, f, g, u, d, h ] ), + J.useEffect( () => { + if ( ! n ) return; + function e() { + return !! ( + u && + d && + rs( u.nodesRef.current, d ).length > 0 + ); + } + function t( n ) { + u && + d && + ! e() && + m.start( 0, () => { + u.events.off( 'floating.closed', t ), + o.setOpen( ! 1, Ro( Do, n ) ), + u.events.emit( 'floating.closed', n ); + } ); + } + const s = a; + return Ur( + s && + Kr( s, 'mouseenter', function () { + f.openChangeTimeout.clear(), + m.clear(), + u?.events.off( 'floating.closed', t ), + h(); + } ), + s && + Kr( s, 'mouseleave', function ( n ) { + if ( e() && u ) + return void u.events.on( 'floating.closed', t ); + if ( + ts( n.relatedTarget, o.context.triggerElements ) + ) + return; + const s = c.current.floatingContext?.nodeId ?? r, + a = n.relatedTarget; + ( u && + s && + mo( a ) && + rs( u.nodesRef.current, s, ! 1 ).some( e => + Jo( e.context?.elements.floating, a ) + ) ) || + ( f.handler + ? f.handler( n ) + : ( h(), + p() || + ( function ( e ) { + const t = Js( + i, + 'close', + f.pointerType + ), + n = () => { + o.setOpen( + ! 1, + Ro( Do, e ) + ), + u?.events.emit( + 'floating.closed', + e + ); + }; + t + ? f.openChangeTimeout.start( + t, + n + ) + : ( f.openChangeTimeout.clear(), + n() ); + } )( n ) ) ); + } ), + s && + Kr( + s, + 'pointerdown', + function ( e ) { + const t = es( e ); + var n; + ( n = t ), + null != + n?.closest( + `button,a[href],[role="button"],select,[tabindex]:not([tabindex="-1"]),${ Zo }` + ) + ? ( f.interactedInside = + null != + t?.closest( + '[aria-haspopup]' + ) ) + : ( f.interactedInside = ! 1 ); + }, + ! 0 + ), + () => { + u?.events.off( 'floating.closed', t ); + } + ); + }, [ n, a, o, c, i, r, p, h, f, u, d, m ] ); + } )( m, { enabled: ! p, closeDelay: g } ); + const h = s.useStateSetter( 'popupElement' ); + return _e( 'div', e, { + state: { open: c, side: a, align: l, instant: u, transitionStatus: d }, + ref: [ t, s.context.popupRef, h ], + props: [ f, Ea( d ), o ], + stateAttributesMapping: ka, + } ); + } ), + Va = window.wp.theme; + var { lock: Oa, unlock: Pa } = ( 0, + z.__dangerousOptInToUnstableAPIsOnlyForCoreModules )( + 'I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.', + '@wordpress/ui' + ); + const Ma = J.createContext( void 0 ), + Ta = J.createContext( null ), + Na = Wo( 'portal' ); + const Aa = J.forwardRef( function ( e, t ) { + const { + children: n, + container: i, + className: r, + render: o, + style: s, + ...a + } = e, + { portalNode: l, portalSubtree: u } = ( function ( e = {} ) { + const { + ref: t, + container: n, + componentProps: i = de, + elementProps: r, + } = e, + o = us(), + s = J.useContext( Ta ), + a = s?.portalNode, + [ l, c ] = J.useState( null ), + [ u, d ] = J.useState( null ), + f = eo( e => { + null !== e && d( e ); + } ), + m = J.useRef( null ); + qr( () => { + if ( null === n ) + return void ( + m.current && ( ( m.current = null ), d( null ), c( null ) ) + ); + if ( null == o ) return; + const e = + ( n && ( fo( n ) ? n : n.current ) ) ?? a ?? document.body; + null != e + ? m.current !== e && ( ( m.current = e ), d( null ), c( e ) ) + : m.current && ( ( m.current = null ), d( null ), c( null ) ); + }, [ n, a, o ] ); + const p = _e( 'div', i, { + ref: [ t, f ], + props: [ { id: o, [ Na ]: '' }, r ], + } ); + return { + portalNode: u, + portalSubtree: l && p ? js.createPortal( p, l ) : null, + }; + } )( { container: i, ref: t, componentProps: e, elementProps: a } ); + return u || l + ? ( 0, c.jsxs )( J.Fragment, { + children: [ u, l && js.createPortal( n, l ) ], + } ) + : null; + } ), + Ra = J.forwardRef( function ( e, t ) { + const { keepMounted: n = ! 1, ...i } = e; + return Yr().useState( 'mounted' ) || n + ? ( 0, c.jsx )( Ma.Provider, { + value: n, + children: ( 0, c.jsx )( Aa, { ref: t, ...i } ), + } ) + : null; + } ); + var Fa = 'data-wp-hash'; + function La() { + const e = globalThis; + return ( + e.__wpStyleRuntime || + ( ( e.__wpStyleRuntime = { + documents: new Map(), + styles: new Map(), + injectedStyles: new WeakMap(), + } ), + 'undefined' != typeof document && + ( function ( e ) { + const t = La(); + t.documents.set( e, ( t.documents.get( e ) ?? 0 ) + 1 ); + for ( const [ n, i ] of t.styles ) Da( e, n, i ); + } )( document ) ), + e.__wpStyleRuntime + ); + } + function Da( e, t, n ) { + if ( ! e.head ) return; + const i = La(); + let r = i.injectedStyles.get( e ); + if ( ( r || ( ( r = new Set() ), i.injectedStyles.set( e, r ) ), r.has( t ) ) ) + return; + if ( + ( function ( e, t ) { + if ( ! e.head ) return ! 1; + for ( const n of e.head.querySelectorAll( `style[${ Fa }]` ) ) + if ( n.getAttribute( Fa ) === t ) return ! 0; + return ! 1; + } )( e, t ) + ) + return void r.add( t ); + const o = e.createElement( 'style' ); + o.setAttribute( Fa, t ), + o.appendChild( e.createTextNode( n ) ), + e.head.appendChild( o ), + r.add( t ); + } + ! ( function ( e, t ) { + const n = La(); + n.styles.set( e, t ); + for ( const i of n.documents.keys() ) Da( i, e, t ); + } )( + '45eb1fe20f', + '@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;._11fc52b637ff8a7e__slot{inset:0;isolation:isolate;pointer-events:none;position:fixed;z-index:1000000003}@layer wp-ui-utilities{._11fc52b637ff8a7e__slot>*{pointer-events:auto}}' + ); + var Ba = '_11fc52b637ff8a7e__slot', + za = 'data-wp-compat-overlay-slot', + Wa = null; + function $a() { + if ( 'undefined' == typeof window ) return; + if ( + ! ( function () { + let e; + try { + e = window.top?.wp; + } catch {} + const t = e ?? window.wp; + return 'object' == typeof t?.components && null !== t.components; + } )() && + ! 0 !== window.__wpUiCompatOverlaySlotEnabled + ) + return; + const e = 'undefined' == typeof document ? null : document; + if ( ! e || ! e.body ) return; + if ( Wa && Wa.ownerDocument === e && Wa.isConnected ) return Wa; + const t = e.querySelector( `[${ za }]` ); + return t instanceof HTMLDivElement + ? ( ( Wa = t ), t ) + : ( Wa?.isConnected && Wa.remove(), + ( Wa = ( function ( e ) { + const t = e.createElement( 'div' ); + return ( + t.setAttribute( za, '' ), + Ba && t.classList.add( Ba ), + e.body.appendChild( t ), + t + ); + } )( e ) ), + Wa ); + } + var Ha = ( 0, e.forwardRef )( function ( { container: e, ...t }, n ) { + return ( 0, c.jsx )( Ra, { container: e ?? $a(), ...t, ref: n } ); + } ); + const qa = [ 'top', 'right', 'bottom', 'left' ], + Ga = Math.min, + Ya = Math.max, + Ka = Math.round, + Ua = Math.floor, + Xa = e => ( { x: e, y: e } ), + Za = { left: 'right', right: 'left', bottom: 'top', top: 'bottom' }; + function Qa( e, t, n ) { + return Ya( e, Ga( t, n ) ); + } + function Ja( e, t ) { + return 'function' == typeof e ? e( t ) : e; + } + function el( e ) { + return e.split( '-' )[ 0 ]; + } + function tl( e ) { + return e.split( '-' )[ 1 ]; + } + function nl( e ) { + return 'x' === e ? 'y' : 'x'; + } + function il( e ) { + return 'y' === e ? 'height' : 'width'; + } + function rl( e ) { + const t = e[ 0 ]; + return 't' === t || 'b' === t ? 'y' : 'x'; + } + function ol( e ) { + return nl( rl( e ) ); + } + function sl( e ) { + return e.includes( 'start' ) + ? e.replace( 'start', 'end' ) + : e.replace( 'end', 'start' ); + } + const al = [ 'left', 'right' ], + ll = [ 'right', 'left' ], + cl = [ 'top', 'bottom' ], + ul = [ 'bottom', 'top' ]; + function dl( e ) { + const t = el( e ); + return Za[ t ] + e.slice( t.length ); + } + function fl( e ) { + return 'number' != typeof e + ? ( function ( e ) { + return { top: 0, right: 0, bottom: 0, left: 0, ...e }; + } )( e ) + : { top: e, right: e, bottom: e, left: e }; + } + function ml( e ) { + const { x: t, y: n, width: i, height: r } = e; + return { + width: i, + height: r, + top: n, + left: t, + right: t + i, + bottom: n + r, + x: t, + y: n, + }; + } + function pl( e, t, n ) { + let { reference: i, floating: r } = e; + const o = rl( t ), + s = ol( t ), + a = il( s ), + l = el( t ), + c = 'y' === o, + u = i.x + i.width / 2 - r.width / 2, + d = i.y + i.height / 2 - r.height / 2, + f = i[ a ] / 2 - r[ a ] / 2; + let m; + switch ( l ) { + case 'top': + m = { x: u, y: i.y - r.height }; + break; + case 'bottom': + m = { x: u, y: i.y + i.height }; + break; + case 'right': + m = { x: i.x + i.width, y: d }; + break; + case 'left': + m = { x: i.x - r.width, y: d }; + break; + default: + m = { x: i.x, y: i.y }; + } + switch ( tl( t ) ) { + case 'start': + m[ s ] -= f * ( n && c ? -1 : 1 ); + break; + case 'end': + m[ s ] += f * ( n && c ? -1 : 1 ); + } + return m; + } + async function gl( e, t ) { + var n; + void 0 === t && ( t = {} ); + const { x: i, y: r, platform: o, rects: s, elements: a, strategy: l } = e, + { + boundary: c = 'clippingAncestors', + rootBoundary: u = 'viewport', + elementContext: d = 'floating', + altBoundary: f = ! 1, + padding: m = 0, + } = Ja( t, e ), + p = fl( m ), + g = a[ f ? ( 'floating' === d ? 'reference' : 'floating' ) : d ], + h = ml( + await o.getClippingRect( { + element: + null == + ( n = await ( null == o.isElement + ? void 0 + : o.isElement( g ) ) ) || n + ? g + : g.contextElement || + ( await ( null == o.getDocumentElement + ? void 0 + : o.getDocumentElement( a.floating ) ) ), + boundary: c, + rootBoundary: u, + strategy: l, + } ) + ), + v = + 'floating' === d + ? { x: i, y: r, width: s.floating.width, height: s.floating.height } + : s.reference, + b = await ( null == o.getOffsetParent + ? void 0 + : o.getOffsetParent( a.floating ) ), + w = ( ( await ( null == o.isElement ? void 0 : o.isElement( b ) ) ) && + ( await ( null == o.getScale ? void 0 : o.getScale( b ) ) ) ) || { + x: 1, + y: 1, + }, + y = ml( + o.convertOffsetParentRelativeRectToViewportRelativeRect + ? await o.convertOffsetParentRelativeRectToViewportRelativeRect( { + elements: a, + rect: v, + offsetParent: b, + strategy: l, + } ) + : v + ); + return { + top: ( h.top - y.top + p.top ) / w.y, + bottom: ( y.bottom - h.bottom + p.bottom ) / w.y, + left: ( h.left - y.left + p.left ) / w.x, + right: ( y.right - h.right + p.right ) / w.x, + }; + } + function hl( e, t ) { + return { + top: e.top - t.height, + right: e.right - t.width, + bottom: e.bottom - t.height, + left: e.left - t.width, + }; + } + function vl( e ) { + return qa.some( t => e[ t ] >= 0 ); + } + const bl = new Set( [ 'left', 'top' ] ); + function wl( e ) { + const t = Eo( e ); + let n = parseFloat( t.width ) || 0, + i = parseFloat( t.height ) || 0; + const r = po( e ), + o = r ? e.offsetWidth : n, + s = r ? e.offsetHeight : i, + a = Ka( n ) !== o || Ka( i ) !== s; + return a && ( ( n = o ), ( i = s ) ), { width: n, height: i, $: a }; + } + function yl( e ) { + return mo( e ) ? e : e.contextElement; + } + function xl( e ) { + const t = yl( e ); + if ( ! po( t ) ) return Xa( 1 ); + const n = t.getBoundingClientRect(), + { width: i, height: r, $: o } = wl( t ); + let s = ( o ? Ka( n.width ) : n.width ) / i, + a = ( o ? Ka( n.height ) : n.height ) / r; + return ( + ( s && Number.isFinite( s ) ) || ( s = 1 ), + ( a && Number.isFinite( a ) ) || ( a = 1 ), + { x: s, y: a } + ); + } + const Cl = Xa( 0 ); + function Sl( e ) { + const t = co( e ); + return _o() && t.visualViewport + ? { x: t.visualViewport.offsetLeft, y: t.visualViewport.offsetTop } + : Cl; + } + function _l( e, t, n, i ) { + void 0 === t && ( t = ! 1 ), void 0 === n && ( n = ! 1 ); + const r = e.getBoundingClientRect(), + o = yl( e ); + let s = Xa( 1 ); + t && ( i ? mo( i ) && ( s = xl( i ) ) : ( s = xl( e ) ) ); + const a = ( function ( e, t, n ) { + return void 0 === t && ( t = ! 1 ), ! ( ! n || ( t && n !== co( e ) ) ) && t; + } )( o, n, i ) + ? Sl( o ) + : Xa( 0 ); + let l = ( r.left + a.x ) / s.x, + c = ( r.top + a.y ) / s.y, + u = r.width / s.x, + d = r.height / s.y; + if ( o ) { + const e = co( o ), + t = i && mo( i ) ? co( i ) : i; + let n = e, + r = Po( n ); + for ( ; r && i && t !== n; ) { + const e = xl( r ), + t = r.getBoundingClientRect(), + i = Eo( r ), + o = t.left + ( r.clientLeft + parseFloat( i.paddingLeft ) ) * e.x, + s = t.top + ( r.clientTop + parseFloat( i.paddingTop ) ) * e.y; + ( l *= e.x ), + ( c *= e.y ), + ( u *= e.x ), + ( d *= e.y ), + ( l += o ), + ( c += s ), + ( n = co( r ) ), + ( r = Po( n ) ); + } + } + return ml( { width: u, height: d, x: l, y: c } ); + } + function jl( e, t ) { + const n = ko( e ).scrollLeft; + return t ? t.left + n : _l( uo( e ) ).left + n; + } + function El( e, t ) { + const n = e.getBoundingClientRect(); + return { x: n.left + t.scrollLeft - jl( e, n ), y: n.top + t.scrollTop }; + } + function kl( e, t, n ) { + let i; + if ( 'viewport' === t ) + i = ( function ( e, t ) { + const n = co( e ), + i = uo( e ), + r = n.visualViewport; + let o = i.clientWidth, + s = i.clientHeight, + a = 0, + l = 0; + if ( r ) { + ( o = r.width ), ( s = r.height ); + const e = _o(); + ( ! e || ( e && 'fixed' === t ) ) && + ( ( a = r.offsetLeft ), ( l = r.offsetTop ) ); + } + const c = jl( i ); + if ( c <= 0 ) { + const e = i.ownerDocument, + t = e.body, + n = getComputedStyle( t ), + r = + ( 'CSS1Compat' === e.compatMode && + parseFloat( n.marginLeft ) + + parseFloat( n.marginRight ) ) || + 0, + s = Math.abs( i.clientWidth - t.clientWidth - r ); + s <= 25 && ( o -= s ); + } else c <= 25 && ( o += c ); + return { width: o, height: s, x: a, y: l }; + } )( e, n ); + else if ( 'document' === t ) + i = ( function ( e ) { + const t = uo( e ), + n = ko( e ), + i = e.ownerDocument.body, + r = Ya( t.scrollWidth, t.clientWidth, i.scrollWidth, i.clientWidth ), + o = Ya( + t.scrollHeight, + t.clientHeight, + i.scrollHeight, + i.clientHeight + ); + let s = -n.scrollLeft + jl( e ); + const a = -n.scrollTop; + return ( + 'rtl' === Eo( i ).direction && + ( s += Ya( t.clientWidth, i.clientWidth ) - r ), + { width: r, height: o, x: s, y: a } + ); + } )( uo( e ) ); + else if ( mo( t ) ) + i = ( function ( e, t ) { + const n = _l( e, ! 0, 'fixed' === t ), + i = n.top + e.clientTop, + r = n.left + e.clientLeft, + o = po( e ) ? xl( e ) : Xa( 1 ); + return { + width: e.clientWidth * o.x, + height: e.clientHeight * o.y, + x: r * o.x, + y: i * o.y, + }; + } )( t, n ); + else { + const n = Sl( e ); + i = { x: t.x - n.x, y: t.y - n.y, width: t.width, height: t.height }; + } + return ml( i ); + } + function Il( e, t ) { + const n = Io( e ); + return ( + ! ( n === t || ! mo( n ) || jo( n ) ) && + ( 'fixed' === Eo( n ).position || Il( n, t ) ) + ); + } + function Vl( e, t, n ) { + const i = po( t ), + r = uo( t ), + o = 'fixed' === n, + s = _l( e, ! 0, o, t ); + let a = { scrollLeft: 0, scrollTop: 0 }; + const l = Xa( 0 ); + function c() { + l.x = jl( r ); + } + if ( i || ( ! i && ! o ) ) + if ( ( ( 'body' !== lo( t ) || ho( r ) ) && ( a = ko( t ) ), i ) ) { + const e = _l( t, ! 0, o, t ); + ( l.x = e.x + t.clientLeft ), ( l.y = e.y + t.clientTop ); + } else r && c(); + o && ! i && r && c(); + const u = ! r || i || o ? Xa( 0 ) : El( r, a ); + return { + x: s.left + a.scrollLeft - l.x - u.x, + y: s.top + a.scrollTop - l.y - u.y, + width: s.width, + height: s.height, + }; + } + function Ol( e ) { + return 'static' === Eo( e ).position; + } + function Pl( e, t ) { + if ( ! po( e ) || 'fixed' === Eo( e ).position ) return null; + if ( t ) return t( e ); + let n = e.offsetParent; + return uo( e ) === n && ( n = n.ownerDocument.body ), n; + } + function Ml( e, t ) { + const n = co( e ); + if ( bo( e ) ) return n; + if ( ! po( e ) ) { + let t = Io( e ); + for ( ; t && ! jo( t ); ) { + if ( mo( t ) && ! Ol( t ) ) return t; + t = Io( t ); + } + return n; + } + let i = Pl( e, t ); + for ( ; i && vo( i ) && Ol( i ); ) i = Pl( i, t ); + return i && jo( i ) && Ol( i ) && ! So( i ) + ? n + : i || + ( function ( e ) { + let t = Io( e ); + for ( ; po( t ) && ! jo( t ); ) { + if ( So( t ) ) return t; + if ( bo( t ) ) return null; + t = Io( t ); + } + return null; + } )( e ) || + n; + } + const Tl = { + convertOffsetParentRelativeRectToViewportRelativeRect: function ( e ) { + let { elements: t, rect: n, offsetParent: i, strategy: r } = e; + const o = 'fixed' === r, + s = uo( i ), + a = !! t && bo( t.floating ); + if ( i === s || ( a && o ) ) return n; + let l = { scrollLeft: 0, scrollTop: 0 }, + c = Xa( 1 ); + const u = Xa( 0 ), + d = po( i ); + if ( + ( d || ( ! d && ! o ) ) && + ( ( 'body' !== lo( i ) || ho( s ) ) && ( l = ko( i ) ), d ) + ) { + const e = _l( i ); + ( c = xl( i ) ), ( u.x = e.x + i.clientLeft ), ( u.y = e.y + i.clientTop ); + } + const f = ! s || d || o ? Xa( 0 ) : El( s, l ); + return { + width: n.width * c.x, + height: n.height * c.y, + x: n.x * c.x - l.scrollLeft * c.x + u.x + f.x, + y: n.y * c.y - l.scrollTop * c.y + u.y + f.y, + }; + }, + getDocumentElement: uo, + getClippingRect: function ( e ) { + let { element: t, boundary: n, rootBoundary: i, strategy: r } = e; + const o = [ + ...( 'clippingAncestors' === n + ? bo( t ) + ? [] + : ( function ( e, t ) { + const n = t.get( e ); + if ( n ) return n; + let i = Oo( e, [], ! 1 ).filter( + e => mo( e ) && 'body' !== lo( e ) + ), + r = null; + const o = 'fixed' === Eo( e ).position; + let s = o ? Io( e ) : e; + for ( ; mo( s ) && ! jo( s ); ) { + const t = Eo( s ), + n = So( s ); + n || 'fixed' !== t.position || ( r = null ), + ( + o + ? ! n && ! r + : ( ! n && + 'static' === t.position && + r && + ( 'absolute' === r.position || + 'fixed' === + r.position ) ) || + ( ho( s ) && ! n && Il( e, s ) ) + ) + ? ( i = i.filter( e => e !== s ) ) + : ( r = t ), + ( s = Io( s ) ); + } + return t.set( e, i ), i; + } )( t, this._c ) + : [].concat( n ) ), + i, + ], + s = kl( t, o[ 0 ], r ); + let a = s.top, + l = s.right, + c = s.bottom, + u = s.left; + for ( let e = 1; e < o.length; e++ ) { + const n = kl( t, o[ e ], r ); + ( a = Ya( n.top, a ) ), + ( l = Ga( n.right, l ) ), + ( c = Ga( n.bottom, c ) ), + ( u = Ya( n.left, u ) ); + } + return { width: l - u, height: c - a, x: u, y: a }; + }, + getOffsetParent: Ml, + getElementRects: async function ( e ) { + const t = this.getOffsetParent || Ml, + n = this.getDimensions, + i = await n( e.floating ); + return { + reference: Vl( e.reference, await t( e.floating ), e.strategy ), + floating: { x: 0, y: 0, width: i.width, height: i.height }, + }; + }, + getClientRects: function ( e ) { + return Array.from( e.getClientRects() ); + }, + getDimensions: function ( e ) { + const { width: t, height: n } = wl( e ); + return { width: t, height: n }; + }, + getScale: xl, + isElement: mo, + isRTL: function ( e ) { + return 'rtl' === Eo( e ).direction; + }, + }; + function Nl( e, t ) { + return e.x === t.x && e.y === t.y && e.width === t.width && e.height === t.height; + } + function Al( e, t, n, i ) { + void 0 === i && ( i = {} ); + const { + ancestorScroll: r = ! 0, + ancestorResize: o = ! 0, + elementResize: s = 'function' == typeof ResizeObserver, + layoutShift: a = 'function' == typeof IntersectionObserver, + animationFrame: l = ! 1, + } = i, + c = yl( e ), + u = r || o ? [ ...( c ? Oo( c ) : [] ), ...( t ? Oo( t ) : [] ) ] : []; + u.forEach( e => { + r && e.addEventListener( 'scroll', n, { passive: ! 0 } ), + o && e.addEventListener( 'resize', n ); + } ); + const d = + c && a + ? ( function ( e, t ) { + let n, + i = null; + const r = uo( e ); + function o() { + var e; + clearTimeout( n ), + null == ( e = i ) || e.disconnect(), + ( i = null ); + } + return ( + ( function s( a, l ) { + void 0 === a && ( a = ! 1 ), void 0 === l && ( l = 1 ), o(); + const c = e.getBoundingClientRect(), + { left: u, top: d, width: f, height: m } = c; + if ( ( a || t(), ! f || ! m ) ) return; + const p = { + rootMargin: + -Ua( d ) + + 'px ' + + -Ua( r.clientWidth - ( u + f ) ) + + 'px ' + + -Ua( r.clientHeight - ( d + m ) ) + + 'px ' + + -Ua( u ) + + 'px', + threshold: Ya( 0, Ga( 1, l ) ) || 1, + }; + let g = ! 0; + function h( t ) { + const i = t[ 0 ].intersectionRatio; + if ( i !== l ) { + if ( ! g ) return s(); + i + ? s( ! 1, i ) + : ( n = setTimeout( () => { + s( ! 1, 1e-7 ); + }, 1e3 ) ); + } + 1 !== i || Nl( c, e.getBoundingClientRect() ) || s(), + ( g = ! 1 ); + } + try { + i = new IntersectionObserver( h, { + ...p, + root: r.ownerDocument, + } ); + } catch ( e ) { + i = new IntersectionObserver( h, p ); + } + i.observe( e ); + } )( ! 0 ), + o + ); + } )( c, n ) + : null; + let f, + m = -1, + p = null; + s && + ( ( p = new ResizeObserver( e => { + let [ i ] = e; + i && + i.target === c && + p && + t && + ( p.unobserve( t ), + cancelAnimationFrame( m ), + ( m = requestAnimationFrame( () => { + var e; + null == ( e = p ) || e.observe( t ); + } ) ) ), + n(); + } ) ), + c && ! l && p.observe( c ), + t && p.observe( t ) ); + let g = l ? _l( e ) : null; + return ( + l && + ( function t() { + const i = _l( e ); + g && ! Nl( g, i ) && n(), ( g = i ), ( f = requestAnimationFrame( t ) ); + } )(), + n(), + () => { + var e; + u.forEach( e => { + r && e.removeEventListener( 'scroll', n ), + o && e.removeEventListener( 'resize', n ); + } ), + null == d || d(), + null == ( e = p ) || e.disconnect(), + ( p = null ), + l && cancelAnimationFrame( f ); + } + ); + } + const Rl = function ( e ) { + return ( + void 0 === e && ( e = {} ), + { + name: 'flip', + options: e, + async fn( t ) { + var n, i; + const { + placement: r, + middlewareData: o, + rects: s, + initialPlacement: a, + platform: l, + elements: c, + } = t, + { + mainAxis: u = ! 0, + crossAxis: d = ! 0, + fallbackPlacements: f, + fallbackStrategy: m = 'bestFit', + fallbackAxisSideDirection: p = 'none', + flipAlignment: g = ! 0, + ...h + } = Ja( e, t ); + if ( null != ( n = o.arrow ) && n.alignmentOffset ) return {}; + const v = el( r ), + b = rl( a ), + w = el( a ) === a, + y = await ( null == l.isRTL ? void 0 : l.isRTL( c.floating ) ), + x = + f || + ( w || ! g + ? [ dl( a ) ] + : ( function ( e ) { + const t = dl( e ); + return [ sl( e ), t, sl( t ) ]; + } )( a ) ), + C = 'none' !== p; + ! f && + C && + x.push( + ...( function ( e, t, n, i ) { + const r = tl( e ); + let o = ( function ( e, t, n ) { + switch ( e ) { + case 'top': + case 'bottom': + return n ? ( t ? ll : al ) : t ? al : ll; + case 'left': + case 'right': + return t ? cl : ul; + default: + return []; + } + } )( el( e ), 'start' === n, i ); + return ( + r && + ( ( o = o.map( e => e + '-' + r ) ), + t && ( o = o.concat( o.map( sl ) ) ) ), + o + ); + } )( a, g, p, y ) + ); + const S = [ a, ...x ], + _ = await l.detectOverflow( t, h ), + j = []; + let E = ( null == ( i = o.flip ) ? void 0 : i.overflows ) || []; + if ( ( u && j.push( _[ v ] ), d ) ) { + const e = ( function ( e, t, n ) { + void 0 === n && ( n = ! 1 ); + const i = tl( e ), + r = ol( e ), + o = il( r ); + let s = + 'x' === r + ? i === ( n ? 'end' : 'start' ) + ? 'right' + : 'left' + : 'start' === i + ? 'bottom' + : 'top'; + return ( + t.reference[ o ] > t.floating[ o ] && ( s = dl( s ) ), + [ s, dl( s ) ] + ); + } )( r, s, y ); + j.push( _[ e[ 0 ] ], _[ e[ 1 ] ] ); + } + if ( + ( ( E = [ ...E, { placement: r, overflows: j } ] ), + ! j.every( e => e <= 0 ) ) + ) { + var k, I; + const e = + ( ( null == ( k = o.flip ) ? void 0 : k.index ) || 0 ) + + 1, + t = S[ e ]; + if ( + t && + ( 'alignment' !== d || + b === rl( t ) || + E.every( + e => rl( e.placement ) !== b || e.overflows[ 0 ] > 0 + ) ) + ) + return { + data: { index: e, overflows: E }, + reset: { placement: t }, + }; + let n = + null == + ( I = E.filter( e => e.overflows[ 0 ] <= 0 ).sort( + ( e, t ) => e.overflows[ 1 ] - t.overflows[ 1 ] + )[ 0 ] ) + ? void 0 + : I.placement; + if ( ! n ) + switch ( m ) { + case 'bestFit': { + var V; + const e = + null == + ( V = E.filter( e => { + if ( C ) { + const t = rl( e.placement ); + return t === b || 'y' === t; + } + return ! 0; + } ) + .map( e => [ + e.placement, + e.overflows + .filter( e => e > 0 ) + .reduce( ( e, t ) => e + t, 0 ), + ] ) + .sort( ( e, t ) => e[ 1 ] - t[ 1 ] )[ 0 ] ) + ? void 0 + : V[ 0 ]; + e && ( n = e ); + break; + } + case 'initialPlacement': + n = a; + } + if ( r !== n ) return { reset: { placement: n } }; + } + return {}; + }, + } + ); + }, + Fl = function ( e ) { + return ( + void 0 === e && ( e = {} ), + { + options: e, + fn( t ) { + const { x: n, y: i, placement: r, rects: o, middlewareData: s } = t, + { + offset: a = 0, + mainAxis: l = ! 0, + crossAxis: c = ! 0, + } = Ja( e, t ), + u = { x: n, y: i }, + d = rl( r ), + f = nl( d ); + let m = u[ f ], + p = u[ d ]; + const g = Ja( a, t ), + h = + 'number' == typeof g + ? { mainAxis: g, crossAxis: 0 } + : { mainAxis: 0, crossAxis: 0, ...g }; + if ( l ) { + const e = 'y' === f ? 'height' : 'width', + t = o.reference[ f ] - o.floating[ e ] + h.mainAxis, + n = o.reference[ f ] + o.reference[ e ] - h.mainAxis; + m < t ? ( m = t ) : m > n && ( m = n ); + } + if ( c ) { + var v, b; + const e = 'y' === f ? 'width' : 'height', + t = bl.has( el( r ) ), + n = + o.reference[ d ] - + o.floating[ e ] + + ( ( t && + ( null == ( v = s.offset ) ? void 0 : v[ d ] ) ) || + 0 ) + + ( t ? 0 : h.crossAxis ), + i = + o.reference[ d ] + + o.reference[ e ] + + ( t + ? 0 + : ( null == ( b = s.offset ) ? void 0 : b[ d ] ) || + 0 ) - + ( t ? h.crossAxis : 0 ); + p < n ? ( p = n ) : p > i && ( p = i ); + } + return { [ f ]: m, [ d ]: p }; + }, + } + ); + }; + var Ll = 'undefined' != typeof document ? J.useLayoutEffect : function () {}; + function Dl( e, t ) { + if ( e === t ) return ! 0; + if ( typeof e != typeof t ) return ! 1; + if ( 'function' == typeof e && e.toString() === t.toString() ) return ! 0; + let n, i, r; + if ( e && t && 'object' == typeof e ) { + if ( Array.isArray( e ) ) { + if ( ( ( n = e.length ), n !== t.length ) ) return ! 1; + for ( i = n; 0 !== i--; ) if ( ! Dl( e[ i ], t[ i ] ) ) return ! 1; + return ! 0; + } + if ( + ( ( r = Object.keys( e ) ), + ( n = r.length ), + n !== Object.keys( t ).length ) + ) + return ! 1; + for ( i = n; 0 !== i--; ) + if ( ! {}.hasOwnProperty.call( t, r[ i ] ) ) return ! 1; + for ( i = n; 0 !== i--; ) { + const n = r[ i ]; + if ( ! ( ( '_owner' === n && e.$$typeof ) || Dl( e[ n ], t[ n ] ) ) ) + return ! 1; + } + return ! 0; + } + return e != e && t != t; + } + function Bl( e ) { + return 'undefined' == typeof window + ? 1 + : ( e.ownerDocument.defaultView || window ).devicePixelRatio || 1; + } + function zl( e, t ) { + const n = Bl( e ); + return Math.round( t * n ) / n; + } + function Wl( e ) { + const t = J.useRef( e ); + return ( + Ll( () => { + t.current = e; + } ), + t + ); + } + function $l( e = {} ) { + const { nodeId: t, externalTree: n } = e, + i = ( function ( e ) { + const { open: t = ! 1, onOpenChange: n, elements: i = {} } = e, + r = us(), + o = null != No(), + s = ne( + () => + new xs( { + open: t, + transitionStatus: void 0, + onOpenChange: n, + referenceElement: i.reference ?? null, + floatingElement: i.floating ?? null, + triggerElements: new Ms(), + floatingId: r, + syncOnly: ! 1, + nested: o, + } ) + ).current; + return ( + qr( () => { + const e = { open: t, floatingId: r }; + void 0 !== i.reference && + ( ( e.referenceElement = i.reference ), + ( e.domReferenceElement = mo( i.reference ) + ? i.reference + : null ) ), + void 0 !== i.floating && ( e.floatingElement = i.floating ), + s.update( e ); + }, [ t, r, i.reference, i.floating, s ] ), + ( s.context.onOpenChange = n ), + ( s.context.nested = o ), + s + ); + } )( e ), + r = e.rootContext || i, + o = r.useState( 'referenceElement' ), + s = r.useState( 'floatingElement' ), + a = r.useState( 'domReferenceElement' ), + l = r.useState( 'open' ), + c = r.useState( 'floatingId' ), + [ u, d ] = J.useState( null ), + [ f, m ] = J.useState( void 0 ), + [ p, g ] = J.useState( void 0 ), + h = J.useRef( null ), + v = Ao( n ), + b = J.useMemo( + () => ( { reference: o, floating: s, domReference: a } ), + [ o, s, a ] + ), + w = ( function ( e ) { + void 0 === e && ( e = {} ); + const { + placement: t = 'bottom', + strategy: n = 'absolute', + middleware: i = [], + platform: r, + elements: { reference: o, floating: s } = {}, + transform: a = ! 0, + whileElementsMounted: l, + open: c, + } = e, + [ u, d ] = J.useState( { + x: 0, + y: 0, + strategy: n, + placement: t, + middlewareData: {}, + isPositioned: ! 1, + } ), + [ f, m ] = J.useState( i ); + Dl( f, i ) || m( i ); + const [ p, g ] = J.useState( null ), + [ h, v ] = J.useState( null ), + b = J.useCallback( e => { + e !== C.current && ( ( C.current = e ), g( e ) ); + }, [] ), + w = J.useCallback( e => { + e !== S.current && ( ( S.current = e ), v( e ) ); + }, [] ), + y = o || p, + x = s || h, + C = J.useRef( null ), + S = J.useRef( null ), + _ = J.useRef( u ), + j = null != l, + E = Wl( l ), + k = Wl( r ), + I = Wl( c ), + V = J.useCallback( () => { + if ( ! C.current || ! S.current ) return; + const e = { placement: t, strategy: n, middleware: f }; + k.current && ( e.platform = k.current ), + ( ( e, t, n ) => { + const i = new Map(), + r = { platform: Tl, ...n }, + o = { ...r.platform, _c: i }; + return ( async ( e, t, n ) => { + const { + placement: i = 'bottom', + strategy: r = 'absolute', + middleware: o = [], + platform: s, + } = n, + a = s.detectOverflow + ? s + : { ...s, detectOverflow: gl }, + l = await ( null == s.isRTL + ? void 0 + : s.isRTL( t ) ); + let c = await s.getElementRects( { + reference: e, + floating: t, + strategy: r, + } ), + { x: u, y: d } = pl( c, i, l ), + f = i, + m = 0; + const p = {}; + for ( let n = 0; n < o.length; n++ ) { + const g = o[ n ]; + if ( ! g ) continue; + const { name: h, fn: v } = g, + { + x: b, + y: w, + data: y, + reset: x, + } = await v( { + x: u, + y: d, + initialPlacement: i, + placement: f, + strategy: r, + middlewareData: p, + rects: c, + platform: a, + elements: { reference: e, floating: t }, + } ); + ( u = null != b ? b : u ), + ( d = null != w ? w : d ), + ( p[ h ] = { ...p[ h ], ...y } ), + x && + m < 50 && + ( m++, + 'object' == typeof x && + ( x.placement && ( f = x.placement ), + x.rects && + ( c = + ! 0 === x.rects + ? await s.getElementRects( { + reference: e, + floating: t, + strategy: r, + } ) + : x.rects ), + ( { x: u, y: d } = pl( c, f, l ) ) ), + ( n = -1 ) ); + } + return { + x: u, + y: d, + placement: f, + strategy: r, + middlewareData: p, + }; + } )( e, t, { ...r, platform: o } ); + } )( C.current, S.current, e ).then( e => { + const t = { ...e, isPositioned: ! 1 !== I.current }; + O.current && + ! Dl( _.current, t ) && + ( ( _.current = t ), + js.flushSync( () => { + d( t ); + } ) ); + } ); + }, [ f, t, n, k, I ] ); + Ll( () => { + ! 1 === c && + _.current.isPositioned && + ( ( _.current.isPositioned = ! 1 ), + d( e => ( { ...e, isPositioned: ! 1 } ) ) ); + }, [ c ] ); + const O = J.useRef( ! 1 ); + Ll( + () => ( + ( O.current = ! 0 ), + () => { + O.current = ! 1; + } + ), + [] + ), + Ll( () => { + if ( ( y && ( C.current = y ), x && ( S.current = x ), y && x ) ) { + if ( E.current ) return E.current( y, x, V ); + V(); + } + }, [ y, x, V, E, j ] ); + const P = J.useMemo( + () => ( { + reference: C, + floating: S, + setReference: b, + setFloating: w, + } ), + [ b, w ] + ), + M = J.useMemo( () => ( { reference: y, floating: x } ), [ y, x ] ), + T = J.useMemo( () => { + const e = { position: n, left: 0, top: 0 }; + if ( ! M.floating ) return e; + const t = zl( M.floating, u.x ), + i = zl( M.floating, u.y ); + return a + ? { + ...e, + transform: 'translate(' + t + 'px, ' + i + 'px)', + ...( Bl( M.floating ) >= 1.5 && { + willChange: 'transform', + } ), + } + : { position: n, left: t, top: i }; + }, [ n, a, M.floating, u.x, u.y ] ); + return J.useMemo( + () => ( { ...u, update: V, refs: P, elements: M, floatingStyles: T } ), + [ u, V, P, M, T ] + ); + } )( { ...e, elements: { ...b, ...( u && { reference: u } ) } } ), + y = mo( f ) ? f : null, + x = void 0 === p ? r.state.floatingElement : p; + r.useSyncedValue( 'referenceElement', f ?? null ), + r.useSyncedValue( 'domReferenceElement', void 0 === f ? a : y ), + r.useSyncedValue( 'floatingElement', x ); + const C = J.useCallback( + e => { + const t = mo( e ) + ? { + getBoundingClientRect: () => e.getBoundingClientRect(), + getClientRects: () => e.getClientRects(), + contextElement: e, + } + : e; + d( t ), w.refs.setReference( t ); + }, + [ w.refs ] + ), + S = J.useCallback( + e => { + ( mo( e ) || null === e ) && ( ( h.current = e ), m( e ) ), + ( mo( w.refs.reference.current ) || + null === w.refs.reference.current || + ( null !== e && ! mo( e ) ) ) && + w.refs.setReference( e ); + }, + [ w.refs, m ] + ), + _ = J.useCallback( + e => { + g( e ), w.refs.setFloating( e ); + }, + [ w.refs ] + ), + j = J.useMemo( + () => ( { + ...w.refs, + setReference: S, + setFloating: _, + setPositionReference: C, + domReference: h, + } ), + [ w.refs, S, _, C ] + ), + E = J.useMemo( + () => ( { ...w.elements, domReference: a } ), + [ w.elements, a ] + ), + k = J.useMemo( + () => ( { + ...w, + dataRef: r.context.dataRef, + open: l, + onOpenChange: r.setOpen, + events: r.context.events, + floatingId: c, + refs: j, + elements: E, + nodeId: t, + rootStore: r, + } ), + [ w, j, E, t, r, l, c ] + ); + return ( + qr( () => { + a && ( h.current = a ); + }, [ a ] ), + qr( () => { + r.context.dataRef.current.floatingContext = k; + const e = v?.nodesRef.current.find( e => e.id === t ); + e && ( e.context = k ); + } ), + J.useMemo( + () => ( { ...w, context: k, refs: j, elements: E, rootStore: r } ), + [ w, j, E, k, r ] + ) + ); + } + const Hl = J.createContext( void 0 ), + ql = e => ( { + name: 'arrow', + options: e, + async fn( t ) { + const { + x: n, + y: i, + placement: r, + rects: o, + platform: s, + elements: a, + middlewareData: l, + } = t, + { + element: c, + padding: u = 0, + offsetParent: d = 'real', + } = Ja( e, t ) || {}; + if ( null == c ) return {}; + const f = fl( u ), + m = { x: n, y: i }, + p = ol( r ), + g = il( p ), + h = await s.getDimensions( c ), + v = 'y' === p, + b = v ? 'top' : 'left', + w = v ? 'bottom' : 'right', + y = v ? 'clientHeight' : 'clientWidth', + x = o.reference[ g ] + o.reference[ p ] - m[ p ] - o.floating[ g ], + C = m[ p ] - o.reference[ p ], + S = 'real' === d ? await s.getOffsetParent?.( c ) : a.floating; + let _ = a.floating[ y ] || o.floating[ g ]; + ( _ && ( await s.isElement?.( S ) ) ) || + ( _ = a.floating[ y ] || o.floating[ g ] ); + const j = x / 2 - C / 2, + E = _ / 2 - h[ g ] / 2 - 1, + k = Math.min( f[ b ], E ), + I = Math.min( f[ w ], E ), + V = k, + O = _ - h[ g ] - I, + P = _ / 2 - h[ g ] / 2 + j, + M = Qa( V, P, O ), + T = + ! l.arrow && + null != tl( r ) && + P !== M && + o.reference[ g ] / 2 - ( P < V ? k : I ) - h[ g ] / 2 < 0, + N = T ? ( P < V ? P - V : P - O ) : 0; + return { + [ p ]: m[ p ] + N, + data: { + [ p ]: M, + centerOffset: P - M - N, + ...( T && { alignmentOffset: N } ), + }, + reset: T, + }; + }, + } ), + Gl = { + name: 'hide', + async fn( e ) { + const { width: t, height: n, x: i, y: r } = e.rects.reference, + o = 0 === t && 0 === n && 0 === i && 0 === r, + s = await ( e => { + const t = ( function ( e ) { + return ( + void 0 === e && ( e = {} ), + { + name: 'hide', + options: e, + async fn( t ) { + const { rects: n, platform: i } = t, + { strategy: r = 'referenceHidden', ...o } = Ja( + e, + t + ); + switch ( r ) { + case 'referenceHidden': { + const e = hl( + await i.detectOverflow( t, { + ...o, + elementContext: 'reference', + } ), + n.reference + ); + return { + data: { + referenceHiddenOffsets: e, + referenceHidden: vl( e ), + }, + }; + } + case 'escaped': { + const e = hl( + await i.detectOverflow( t, { + ...o, + altBoundary: ! 0, + } ), + n.floating + ); + return { + data: { + escapedOffsets: e, + escaped: vl( e ), + }, + }; + } + default: + return {}; + } + }, + } + ); + } )( e ); + return { name: t.name, fn: t.fn, options: [ e, void 0 ] }; + } )().fn( e ); + return { data: { referenceHidden: s.data?.referenceHidden || o } }; + }, + }, + Yl = { sideX: 'left', sideY: 'top' }, + Kl = { + name: 'adaptiveOrigin', + async fn( e ) { + const { + x: t, + y: n, + rects: { floating: i }, + elements: { floating: r }, + platform: o, + strategy: s, + placement: a, + } = e, + l = co( r ), + c = l.getComputedStyle( r ); + if ( '0s' === c.transitionDuration || '' === c.transitionDuration ) + return { x: t, y: n, data: Yl }; + const u = await o.getOffsetParent?.( r ); + let d = { width: 0, height: 0 }; + if ( 'fixed' === s && l?.visualViewport ) + d = { width: l.visualViewport.width, height: l.visualViewport.height }; + else if ( u === l ) { + const e = Xr( r ); + d = { + width: e.documentElement.clientWidth, + height: e.documentElement.clientHeight, + }; + } else ( await o.isElement?.( u ) ) && ( d = await o.getDimensions( u ) ); + const f = el( a ); + let m = t, + p = n; + return ( + 'left' === f && ( m = d.width - ( t + i.width ) ), + 'top' === f && ( p = d.height - ( n + i.height ) ), + { + x: m, + y: p, + data: { + sideX: 'left' === f ? 'right' : Yl.sideX, + sideY: 'top' === f ? 'bottom' : Yl.sideY, + }, + } + ); + }, + }; + function Ul( e, t, n ) { + const i = 'inline-start' === e || 'inline-end' === e; + return { + top: 'top', + right: i ? ( n ? 'inline-start' : 'inline-end' ) : 'right', + bottom: 'bottom', + left: i ? ( n ? 'inline-end' : 'inline-start' ) : 'left', + }[ t ]; + } + function Xl( e, t, n ) { + const { rects: i, placement: r } = e; + return { + side: Ul( t, el( r ), n ), + align: tl( r ) || 'center', + anchor: { width: i.reference.width, height: i.reference.height }, + positioner: { width: i.floating.width, height: i.floating.height }, + }; + } + function Zl( e ) { + const { + anchor: t, + positionMethod: n = 'absolute', + side: i = 'bottom', + sideOffset: r = 0, + align: o = 'center', + alignOffset: s = 0, + collisionBoundary: a, + collisionPadding: l = 5, + sticky: c = ! 1, + arrowPadding: u = 5, + disableAnchorTracking: d = ! 1, + inline: f, + keepMounted: m = ! 1, + floatingRootContext: p, + mounted: g, + collisionAvoidance: h, + shiftCrossAxis: v = ! 1, + nodeId: b, + adaptiveOrigin: w, + lazyFlip: y = ! 1, + externalTree: x, + } = e, + [ C, S ] = J.useState( null ); + g || null === C || S( null ); + const _ = h.side || 'flip', + j = h.align || 'flip', + E = h.fallbackAxisSide || 'end', + k = 'function' == typeof t ? t : void 0, + I = eo( k ), + V = k ? I : t, + O = Ws( t ), + P = Ws( g ), + M = ( function () { + const e = J.useContext( Hl ); + return e?.direction ?? 'ltr'; + } )(), + T = 'rtl' === M, + N = + C || + { + top: 'top', + right: 'right', + bottom: 'bottom', + left: 'left', + 'inline-end': T ? 'left' : 'right', + 'inline-start': T ? 'right' : 'left', + }[ i ], + A = 'center' === o ? N : `${ N }-${ o }`; + let R = l; + const F = 'bottom' === i ? 1 : 0, + L = 'top' === i ? 1 : 0, + D = 'right' === i ? 1 : 0, + B = 'left' === i ? 1 : 0; + 'number' == typeof R + ? ( R = { top: R + F, right: R + B, bottom: R + L, left: R + D } ) + : R && + ( R = { + top: ( R.top || 0 ) + F, + right: ( R.right || 0 ) + B, + bottom: ( R.bottom || 0 ) + L, + left: ( R.left || 0 ) + D, + } ); + const z = { + boundary: 'clipping-ancestors' === a ? 'clippingAncestors' : a, + padding: R, + }, + W = J.useRef( null ), + $ = Ws( r ), + H = Ws( s ), + q = 'function' != typeof r ? r : 0, + G = 'function' != typeof s ? s : 0, + Y = []; + f && Y.push( f ), + Y.push( + ( ( e, t ) => { + const n = ( function ( e ) { + return ( + void 0 === e && ( e = 0 ), + { + name: 'offset', + options: e, + async fn( t ) { + var n, i; + const { + x: r, + y: o, + placement: s, + middlewareData: a, + } = t, + l = await ( async function ( e, t ) { + const { + placement: n, + platform: i, + elements: r, + } = e, + o = await ( null == i.isRTL + ? void 0 + : i.isRTL( r.floating ) ), + s = el( n ), + a = tl( n ), + l = 'y' === rl( n ), + c = bl.has( s ) ? -1 : 1, + u = o && l ? -1 : 1, + d = Ja( t, e ); + let { + mainAxis: f, + crossAxis: m, + alignmentAxis: p, + } = 'number' == typeof d + ? { + mainAxis: d, + crossAxis: 0, + alignmentAxis: null, + } + : { + mainAxis: d.mainAxis || 0, + crossAxis: d.crossAxis || 0, + alignmentAxis: d.alignmentAxis, + }; + return ( + a && + 'number' == typeof p && + ( m = 'end' === a ? -1 * p : p ), + l + ? { x: m * u, y: f * c } + : { x: f * c, y: m * u } + ); + } )( t, e ); + return s === + ( null == ( n = a.offset ) + ? void 0 + : n.placement ) && + null != ( i = a.arrow ) && + i.alignmentOffset + ? {} + : { + x: r + l.x, + y: o + l.y, + data: { ...l, placement: s }, + }; + }, + } + ); + } )( e ); + return { name: n.name, fn: n.fn, options: [ e, t ] }; + } )( + e => { + const t = Xl( e, i, T ), + n = 'function' == typeof $.current ? $.current( t ) : $.current, + r = 'function' == typeof H.current ? H.current( t ) : H.current; + return { mainAxis: n, crossAxis: r, alignmentAxis: r }; + }, + [ q, G, T, i ] + ) + ); + const K = 'none' === j && 'shift' !== _, + U = ! K && ( c || v || 'shift' === _ ), + X = + 'none' === _ + ? null + : ( e => { + const t = Rl( e ); + return { name: t.name, fn: t.fn, options: [ e, void 0 ] }; + } )( { + ...z, + padding: { + top: R.top + 1, + right: R.right + 1, + bottom: R.bottom + 1, + left: R.left + 1, + }, + mainAxis: ! v && 'flip' === _, + crossAxis: 'flip' === j && 'alignment', + fallbackAxisSideDirection: E, + } ), + Z = K + ? null + : ( ( e, t ) => { + const n = ( function ( e ) { + return ( + void 0 === e && ( e = {} ), + { + name: 'shift', + options: e, + async fn( t ) { + const { x: n, y: i, placement: r, platform: o } = t, + { + mainAxis: s = ! 0, + crossAxis: a = ! 1, + limiter: l = { + fn: e => { + let { x: t, y: n } = e; + return { x: t, y: n }; + }, + }, + ...c + } = Ja( e, t ), + u = { x: n, y: i }, + d = await o.detectOverflow( t, c ), + f = rl( el( r ) ), + m = nl( f ); + let p = u[ m ], + g = u[ f ]; + if ( s ) { + const e = 'y' === m ? 'bottom' : 'right'; + p = Qa( + p + d[ 'y' === m ? 'top' : 'left' ], + p, + p - d[ e ] + ); + } + if ( a ) { + const e = 'y' === f ? 'bottom' : 'right'; + g = Qa( + g + d[ 'y' === f ? 'top' : 'left' ], + g, + g - d[ e ] + ); + } + const h = l.fn( { ...t, [ m ]: p, [ f ]: g } ); + return { + ...h, + data: { + x: h.x - n, + y: h.y - i, + enabled: { [ m ]: s, [ f ]: a }, + }, + }; + }, + } + ); + } )( e ); + return { name: n.name, fn: n.fn, options: [ e, t ] }; + } )( + e => { + const t = Xr( e.elements.floating ).documentElement; + return { + ...z, + rootBoundary: v + ? { + x: 0, + y: 0, + width: t.clientWidth, + height: t.clientHeight, + } + : void 0, + mainAxis: 'none' !== j, + crossAxis: U, + limiter: + c || v + ? void 0 + : ( ( n = e => { + if ( ! W.current ) return {}; + const { width: t, height: n } = + W.current.getBoundingClientRect(), + i = rl( el( e.placement ) ); + return { + offset: + ( 'y' === i ? t : n ) / 2 + + ( 'y' === i + ? R.left + R.right + : R.top + R.bottom ) / + 2, + }; + } ), + { fn: Fl( n ).fn, options: [ n, void 0 ] } ), + }; + var n; + }, + [ z, c, v, R, j ] + ); + var Q, ee; + 'shift' === _ || 'shift' === j || 'center' === o ? Y.push( Z, X ) : Y.push( X, Z ), + Y.push( + ( e => { + const t = ( function ( e ) { + return ( + void 0 === e && ( e = {} ), + { + name: 'size', + options: e, + async fn( t ) { + var n, i; + const { + placement: r, + rects: o, + platform: s, + elements: a, + } = t, + { apply: l = () => {}, ...c } = Ja( e, t ), + u = await s.detectOverflow( t, c ), + d = el( r ), + f = tl( r ), + m = 'y' === rl( r ), + { width: p, height: g } = o.floating; + let h, v; + 'top' === d || 'bottom' === d + ? ( ( h = d ), + ( v = + f === + ( ( await ( null == s.isRTL + ? void 0 + : s.isRTL( a.floating ) ) ) + ? 'start' + : 'end' ) + ? 'left' + : 'right' ) ) + : ( ( v = d ), + ( h = 'end' === f ? 'top' : 'bottom' ) ); + const b = g - u.top - u.bottom, + w = p - u.left - u.right, + y = Ga( g - u[ h ], b ), + x = Ga( p - u[ v ], w ), + C = ! t.middlewareData.shift; + let S = y, + _ = x; + if ( + ( null != ( n = t.middlewareData.shift ) && + n.enabled.x && + ( _ = w ), + null != ( i = t.middlewareData.shift ) && + i.enabled.y && + ( S = b ), + C && ! f ) + ) { + const e = Ya( u.left, 0 ), + t = Ya( u.right, 0 ), + n = Ya( u.top, 0 ), + i = Ya( u.bottom, 0 ); + m + ? ( _ = + p - + 2 * + ( 0 !== e || 0 !== t + ? e + t + : Ya( u.left, u.right ) ) ) + : ( S = + g - + 2 * + ( 0 !== n || 0 !== i + ? n + i + : Ya( u.top, u.bottom ) ) ); + } + await l( { + ...t, + availableWidth: _, + availableHeight: S, + } ); + const j = await s.getDimensions( a.floating ); + return p !== j.width || g !== j.height + ? { reset: { rects: ! 0 } } + : {}; + }, + } + ); + } )( e ); + return { name: t.name, fn: t.fn, options: [ e, void 0 ] }; + } )( { + ...z, + apply( { + elements: { floating: e }, + availableWidth: t, + availableHeight: n, + rects: i, + } ) { + if ( ! P.current ) return; + const r = e.style; + r.setProperty( '--available-width', `${ t }px` ), + r.setProperty( '--available-height', `${ n }px` ); + const o = co( e ).devicePixelRatio || 1, + { x: s, y: a, width: l, height: c } = i.reference, + u = ( Math.round( ( s + l ) * o ) - Math.round( s * o ) ) / o, + d = ( Math.round( ( a + c ) * o ) - Math.round( a * o ) ) / o; + r.setProperty( '--anchor-width', `${ u }px` ), + r.setProperty( '--anchor-height', `${ d }px` ); + }, + } ), + ( ( ee = [ u ] ), + { + ...ql( + ( Q = e => ( { + element: + W.current || + Xr( e.elements.floating ).createElement( 'div' ), + padding: u, + offsetParent: 'floating', + } ) ) + ), + options: [ Q, ee ], + } ), + { + name: 'transformOrigin', + fn( e ) { + const { + elements: t, + middlewareData: n, + placement: o, + rects: s, + y: a, + } = e, + l = el( o ), + c = rl( l ), + u = W.current, + d = n.arrow?.x || 0, + f = n.arrow?.y || 0, + m = d + ( u?.clientWidth || 0 ) / 2, + p = f + ( u?.clientHeight || 0 ) / 2, + g = Math.abs( n.shift?.y || 0 ), + h = s.reference.height / 2, + v = 'function' == typeof r ? r( Xl( e, i, T ) ) : r, + b = g > v, + w = { + top: `${ m }px calc(100% + ${ v }px)`, + bottom: `${ m }px ${ -v }px`, + left: `calc(100% + ${ v }px) ${ p }px`, + right: `${ -v }px ${ p }px`, + }[ l ], + y = `${ m }px ${ s.reference.y + h - a }px`; + return ( + t.floating.style.setProperty( + '--transform-origin', + U && 'y' === c && b ? y : w + ), + {} + ); + }, + }, + Gl, + w + ), + qr( () => { + ! g && + p && + p.update( { + referenceElement: null, + floatingElement: null, + domReferenceElement: null, + positionReference: null, + } ); + }, [ g, p ] ); + const te = J.useMemo( + () => ( { + elementResize: ! d && 'undefined' != typeof ResizeObserver, + layoutShift: ! d && 'undefined' != typeof IntersectionObserver, + } ), + [ d ] + ), + { + refs: ne, + elements: ie, + x: re, + y: oe, + middlewareData: se, + update: ae, + placement: le, + context: ce, + isPositioned: ue, + floatingStyles: de, + } = $l( { + rootContext: p, + open: m ? g : void 0, + placement: A, + middleware: Y, + strategy: n, + whileElementsMounted: m ? void 0 : ( ...e ) => Al( ...e, te ), + nodeId: b, + externalTree: x, + } ), + { sideX: fe, sideY: me } = se.adaptiveOrigin || Yl, + pe = ue ? n : 'fixed', + ge = J.useMemo( () => { + const e = w + ? { position: pe, [ fe ]: re, [ me ]: oe } + : { position: pe, ...de }; + return ue || ( e.opacity = 0 ), e; + }, [ w, pe, fe, re, me, oe, de, ue ] ), + he = J.useRef( null ); + qr( () => { + if ( ! g ) return; + const e = O.current, + t = 'function' == typeof e ? e() : e, + n = ( Ql( t ) ? t.current : t ) || null; + n !== he.current && ( ne.setPositionReference( n ), ( he.current = n ) ); + }, [ g, ne, V, O ] ), + J.useEffect( () => { + if ( ! g ) return; + const e = O.current; + 'function' != typeof e && + Ql( e ) && + e.current !== he.current && + ( ne.setPositionReference( e.current ), ( he.current = e.current ) ); + }, [ g, ne, V, O ] ), + J.useEffect( () => { + if ( m && g && ie.domReference && ie.floating ) + return Al( ie.domReference, ie.floating, ae, te ); + }, [ m, g, ie, ae, te ] ); + const ve = el( le ), + be = Ul( i, ve, T ), + we = tl( le ) || 'center', + ye = Boolean( se.hide?.referenceHidden ); + qr( () => { + y && g && ue && S( ve ); + }, [ y, g, ue, ve ] ); + const xe = J.useMemo( + () => ( { position: 'absolute', top: se.arrow?.y, left: se.arrow?.x } ), + [ se.arrow ] + ), + Ce = 0 !== se.arrow?.centerOffset; + return J.useMemo( + () => ( { + positionerStyles: ge, + arrowStyles: xe, + arrowRef: W, + arrowUncentered: Ce, + side: be, + align: we, + physicalSide: ve, + anchorHidden: ye, + refs: ne, + context: ce, + isPositioned: ue, + update: ae, + } ), + [ ge, xe, W, Ce, be, we, ve, ye, ne, ce, ue, ae ] + ); + } + function Ql( e ) { + return null != e && 'current' in e; + } + const Jl = J.forwardRef( function ( e, t ) { + const { + render: n, + className: i, + anchor: r, + positionMethod: o = 'absolute', + side: s = 'top', + align: a = 'center', + sideOffset: l = 0, + alignOffset: u = 0, + collisionBoundary: d = 'clipping-ancestors', + collisionPadding: f = 5, + arrowPadding: m = 5, + sticky: p = ! 1, + disableAnchorTracking: g = ! 1, + collisionAvoidance: h = ja, + style: v, + ...b + } = e, + w = Yr(), + y = ( function () { + const e = J.useContext( Ma ); + if ( void 0 === e ) throw new Error( Q( 70 ) ); + return e; + } )(), + x = w.useState( 'open' ), + C = w.useState( 'mounted' ), + S = w.useState( 'trackCursorAxis' ), + _ = w.useState( 'disableHoverablePopup' ), + j = w.useState( 'floatingRootContext' ), + E = w.useState( 'instantType' ), + k = w.useState( 'transitionStatus' ), + I = Zl( { + anchor: r, + positionMethod: o, + floatingRootContext: j, + mounted: C, + side: s, + sideOffset: l, + align: a, + alignOffset: u, + collisionBoundary: d, + collisionPadding: f, + sticky: p, + arrowPadding: m, + disableAnchorTracking: g, + keepMounted: y, + collisionAvoidance: h, + adaptiveOrigin: w.useState( 'hasViewport' ) ? Kl : void 0, + } ), + V = ( function ( + e, + t, + { + styles: n, + transitionStatus: i, + props: r, + refs: o, + hidden: s, + inert: a = ! 1, + } + ) { + const l = { ...n }; + return ( + a && ( l.pointerEvents = 'none' ), + _e( 'div', e, { + state: t, + ref: o, + props: [ + { role: 'presentation', hidden: s, style: l }, + Ea( i ), + r, + ], + stateAttributesMapping: Zs, + } ) + ); + } )( + e, + J.useMemo( + () => ( { + open: x, + side: I.side, + align: I.align, + anchorHidden: I.anchorHidden, + instant: 'none' !== S ? 'tracking-cursor' : E, + } ), + [ x, I.side, I.align, I.anchorHidden, S, E ] + ), + { + styles: I.positionerStyles, + transitionStatus: k, + props: b, + refs: [ t, w.useStateSetter( 'positionerElement' ) ], + hidden: ! C, + inert: ! x || 'both' === S || _, + } + ); + return ( 0, c.jsx )( Sa.Provider, { value: I, children: V } ); + } ); + var ec = 'data-wp-hash'; + function tc() { + const e = globalThis; + return ( + e.__wpStyleRuntime || + ( ( e.__wpStyleRuntime = { + documents: new Map(), + styles: new Map(), + injectedStyles: new WeakMap(), + } ), + 'undefined' != typeof document && + ( function ( e ) { + const t = tc(); + t.documents.set( e, ( t.documents.get( e ) ?? 0 ) + 1 ); + for ( const [ n, i ] of t.styles ) nc( e, n, i ); + } )( document ) ), + e.__wpStyleRuntime + ); + } + function nc( e, t, n ) { + if ( ! e.head ) return; + const i = tc(); + let r = i.injectedStyles.get( e ); + if ( ( r || ( ( r = new Set() ), i.injectedStyles.set( e, r ) ), r.has( t ) ) ) + return; + if ( + ( function ( e, t ) { + if ( ! e.head ) return ! 1; + for ( const n of e.head.querySelectorAll( `style[${ ec }]` ) ) + if ( n.getAttribute( ec ) === t ) return ! 0; + return ! 1; + } )( e, t ) + ) + return void r.add( t ); + const o = e.createElement( 'style' ); + o.setAttribute( ec, t ), + o.appendChild( e.createTextNode( n ) ), + e.head.appendChild( o ), + r.add( t ); + } + function ic( e, t ) { + const n = tc(); + n.styles.set( e, t ); + for ( const i of n.documents.keys() ) nc( i, e, t ); + } + ic( + 'e3ae230cea', + '@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-utilities{._336cd3e4e743482f__box-sizing{box-sizing:border-box;*,:after,:before{box-sizing:inherit}}}' + ); + ic( + '8293efbb49', + '@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._480b748dd3510e64__positioner{z-index:var(--wp-ui-tooltip-z-index,initial)}._50096b232db7709d__popup{background-color:var(--wpds-color-bg-surface-neutral-strong,#fff);border-radius:var(--wpds-border-radius-sm,2px);box-shadow:var(--wpds-elevation-sm,0 1px 2px 0 #0000000d,0 2px 3px 0 #0000000a,0 6px 6px 0 #00000008,0 8px 8px 0 #00000005);color:var(--wpds-color-fg-content-neutral,#1e1e1e);font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-size:var(--wpds-typography-font-size-sm,12px);line-height:1.4;padding:var(--wpds-dimension-padding-xs,4px) var(--wpds-dimension-padding-sm,8px);@media (forced-colors:active){border-bottom-color:CanvasText;border-bottom-style:solid;border-bottom-width:1px;border-left-color:CanvasText;border-left-style:solid;border-left-width:1px;border-right-color:CanvasText;border-right-style:solid;border-right-width:1px;border-top-color:CanvasText;border-top-style:solid;border-top-width:1px}}}' + ); + var rc = ( 0, e.forwardRef )( function ( + { align: e = 'center', className: t, side: n = 'top', sideOffset: i = 4, ...r }, + o + ) { + return ( 0, c.jsx )( Jl, { + ref: o, + align: e, + side: n, + sideOffset: i, + ...r, + className: Te( + '_336cd3e4e743482f__box-sizing', + '_480b748dd3510e64__positioner', + t + ), + } ); + } ); + function oc( t, n, i ) { + return ( 0, e.cloneElement )( t ?? n, { children: i } ); + } + var sc = 'data-wp-hash'; + function ac() { + const e = globalThis; + return ( + e.__wpStyleRuntime || + ( ( e.__wpStyleRuntime = { + documents: new Map(), + styles: new Map(), + injectedStyles: new WeakMap(), + } ), + 'undefined' != typeof document && + ( function ( e ) { + const t = ac(); + t.documents.set( e, ( t.documents.get( e ) ?? 0 ) + 1 ); + for ( const [ n, i ] of t.styles ) lc( e, n, i ); + } )( document ) ), + e.__wpStyleRuntime + ); + } + function lc( e, t, n ) { + if ( ! e.head ) return; + const i = ac(); + let r = i.injectedStyles.get( e ); + if ( ( r || ( ( r = new Set() ), i.injectedStyles.set( e, r ) ), r.has( t ) ) ) + return; + if ( + ( function ( e, t ) { + if ( ! e.head ) return ! 1; + for ( const n of e.head.querySelectorAll( `style[${ sc }]` ) ) + if ( n.getAttribute( sc ) === t ) return ! 0; + return ! 1; + } )( e, t ) + ) + return void r.add( t ); + const o = e.createElement( 'style' ); + o.setAttribute( sc, t ), + o.appendChild( e.createTextNode( n ) ), + e.head.appendChild( o ), + r.add( t ); + } + ! ( function ( e, t ) { + const n = ac(); + n.styles.set( e, t ); + for ( const i of n.documents.keys() ) lc( i, e, t ); + } )( + '8293efbb49', + '@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._480b748dd3510e64__positioner{z-index:var(--wp-ui-tooltip-z-index,initial)}._50096b232db7709d__popup{background-color:var(--wpds-color-bg-surface-neutral-strong,#fff);border-radius:var(--wpds-border-radius-sm,2px);box-shadow:var(--wpds-elevation-sm,0 1px 2px 0 #0000000d,0 2px 3px 0 #0000000a,0 6px 6px 0 #00000008,0 8px 8px 0 #00000005);color:var(--wpds-color-fg-content-neutral,#1e1e1e);font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-size:var(--wpds-typography-font-size-sm,12px);line-height:1.4;padding:var(--wpds-dimension-padding-xs,4px) var(--wpds-dimension-padding-sm,8px);@media (forced-colors:active){border-bottom-color:CanvasText;border-bottom-style:solid;border-bottom-width:1px;border-left-color:CanvasText;border-left-style:solid;border-left-width:1px;border-right-color:CanvasText;border-right-style:solid;border-right-width:1px;border-top-color:CanvasText;border-top-style:solid;border-top-width:1px}}}' + ); + var cc = Pa( Va.privateApis ).ThemeProvider, + uc = ( 0, e.forwardRef )( function ( + { portal: e, positioner: t, children: n, className: i, ...r }, + o + ) { + const s = ( 0, c.jsx )( cc, { + color: { bg: '#1e1e1e' }, + children: ( 0, c.jsx )( Ia, { + ref: o, + className: Te( '_50096b232db7709d__popup', i ), + ...r, + children: n, + } ), + } ), + a = oc( t, ( 0, c.jsx )( rc, {} ), s ); + return oc( e, ( 0, c.jsx )( Ha, {} ), a ); + } ); + function dc() { + const t = ( 0, e.useContext )( Yi ), + n = t.view; + return ( 0, e.useMemo )( () => { + const e = t.containerWidth, + i = n.layout?.previewSize ?? 230, + r = Math.floor( ( e + 32 ) / ( i + 32 ) ); + return Math.max( 1, r ); + }, [ t.containerWidth, n.layout?.previewSize ] ); + } + var fc = ( 0, e.forwardRef )( ( { className: e, previewSize: t, ...n }, i ) => + ( 0, c.jsx )( 'div', { + ref: i, + className: Te( 'dataviews-view-grid-items', e ), + style: { gridTemplateColumns: t && `repeat(auto-fill, minmax(${ t }px, 1fr))` }, + ...n, + } ) + ); + function mc( t, n ) { + const { intersectionObserver: i } = ( 0, e.useContext )( Yi ); + ( 0, e.useEffect )( () => { + const e = t.current; + if ( e && void 0 !== n && i ) + return ( + i.observe( e ), + () => { + i.unobserve( e ); + } + ); + }, [ t, i, n ] ); + } + function pc( e, t, n ) { + const i = e?.length && t ? e[ 0 ].position : void 0; + return i && n ? ( i - 1 ) % n : 0; + } + var { Badge: gc } = $( t.privateApis ); + function hc( e, t ) { + const n = []; + for ( let i = 0, r = e.length; i < r; i += t ) n.push( e.slice( i, i + t ) ); + return n; + } + var vc = ( 0, e.forwardRef )( function i( + { + view: r, + selection: o, + onChangeSelection: s, + onClickItem: a, + isItemClickable: l, + renderItemLink: u, + getItemId: d, + item: f, + actions: m, + mediaField: p, + titleField: g, + descriptionField: h, + regularFields: v, + badgeFields: b, + hasBulkActions: w, + config: y, + posinset: x, + setsize: C, + ...S + }, + _ + ) { + const { showTitle: j = ! 0, showMedia: E = ! 0, showDescription: k = ! 0 } = r, + I = pr( m, f ), + V = d( f ), + O = ( 0, e.useRef )( null ), + P = ( 0, e.useCallback )( + e => { + ( O.current = e ), + 'function' == typeof _ ? _( e ) : _ && ( _.current = e ); + }, + [ _ ] + ); + mc( O, x ); + const M = ( 0, qi.useInstanceId )( i ), + T = o.includes( V ), + N = ( 0, c.jsx )( 'span', { + className: 'dataviews-view-grid__media-placeholder', + } ), + A = E && p?.render, + R = A ? ( 0, c.jsx )( p.render, { item: f, field: p, config: y } ) : N, + F = j && g?.render ? ( 0, c.jsx )( g.render, { item: f, field: g } ) : null; + let L, D; + return ( + l( f ) && + a && + ( F + ? ( ( L = { + 'aria-labelledby': `dataviews-view-grid__title-field-${ M }`, + } ), + ( D = { id: `dataviews-view-grid__title-field-${ M }` } ) ) + : ( L = { 'aria-label': ( 0, n.__ )( 'Navigate to item' ) } ) ), + ( 0, c.jsxs )( Pe, { + direction: 'column', + ...S, + ref: P, + 'aria-setsize': C, + 'aria-posinset': x, + className: Te( + S.className, + 'dataviews-view-grid__row__gridcell', + 'dataviews-view-grid__card', + { 'is-selected': I && T } + ), + onClickCapture: e => { + if ( + ( S.onClickCapture?.( e ), + ( 0, Ji.isAppleOS )() ? e.metaKey : e.ctrlKey ) + ) { + if ( ( e.stopPropagation(), e.preventDefault(), ! I ) ) return; + s( T ? o.filter( e => V !== e ) : [ ...o, V ] ); + } + }, + children: [ + ( 0, c.jsx )( Pr, { + item: f, + isItemClickable: l, + onClickItem: a, + renderItemLink: u, + className: Te( 'dataviews-view-grid__media', { + 'dataviews-view-grid__media--placeholder': ! A, + } ), + ...L, + children: R, + } ), + w && + ( 0, c.jsx )( er, { + item: f, + selection: o, + onChangeSelection: s, + getItemId: d, + titleField: g, + disabled: ! I, + } ), + !! m?.length && + ( 0, c.jsx )( 'div', { + className: 'dataviews-view-grid__media-actions', + children: ( 0, c.jsx )( cr, { + item: f, + actions: m, + isCompact: ! 0, + } ), + } ), + j && + ( 0, c.jsx )( 'div', { + className: 'dataviews-view-grid__title-actions', + children: ( 0, c.jsx )( Pr, { + item: f, + isItemClickable: l, + onClickItem: a, + renderItemLink: u, + className: + 'dataviews-view-grid__title-field dataviews-title-field', + ...D, + title: + g?.getValueFormatted( { item: f, field: g } ) || void 0, + children: F, + } ), + } ), + ( 0, c.jsxs )( Pe, { + direction: 'column', + gap: 'xs', + children: [ + k && + h?.render && + ( 0, c.jsx )( h.render, { item: f, field: h } ), + !! b?.length && + ( 0, c.jsx )( Pe, { + direction: 'row', + className: 'dataviews-view-grid__badge-fields', + gap: 'sm', + wrap: 'wrap', + align: 'top', + justify: 'flex-start', + children: b.map( e => + ( 0, c.jsx )( + gc, + { + className: + 'dataviews-view-grid__field-value', + children: ( 0, c.jsx )( e.render, { + item: f, + field: e, + } ), + }, + e.id + ) + ), + } ), + !! v?.length && + ( 0, c.jsx )( Pe, { + direction: 'column', + className: 'dataviews-view-grid__fields', + gap: 'xs', + children: v.map( e => + ( 0, c.jsx )( + t.Flex, + { + className: 'dataviews-view-grid__field', + gap: 1, + justify: 'flex-start', + expanded: ! 0, + style: { height: 'auto' }, + direction: 'row', + children: ( 0, c.jsxs )( c.Fragment, { + children: [ + ( 0, c.jsxs )( zs, { + children: [ + ( 0, c.jsx )( Ca, { + render: ( 0, c.jsx )( + t.FlexItem, + { + className: + 'dataviews-view-grid__field-name', + children: + e.header, + } + ), + } ), + ( 0, c.jsx )( uc, { + children: e.label, + } ), + ], + } ), + ( 0, c.jsx )( t.FlexItem, { + className: + 'dataviews-view-grid__field-value', + style: { maxHeight: 'none' }, + children: ( 0, c.jsx )( + e.render, + { item: f, field: e } + ), + } ), + ], + } ), + }, + e.id + ) + ), + } ), + ], + } ), + ], + } ) + ); + } ); + function bc( { + data: i, + isInfiniteScroll: r, + className: o, + inert: s, + isLoading: a, + view: l, + fields: u, + selection: d, + onChangeSelection: f, + onClickItem: m, + isItemClickable: p, + renderItemLink: g, + getItemId: h, + actions: v, + } ) { + const { paginationInfo: b, resizeObserverRef: w } = ( 0, e.useContext )( Yi ), + y = dc(), + x = gr( v, i ), + C = u.find( e => e.id === l?.titleField ), + S = u.find( e => e.id === l?.mediaField ), + _ = u.find( e => e.id === l?.descriptionField ), + j = l.fields ?? [], + { regularFields: E, badgeFields: k } = j.reduce( + ( e, t ) => { + const n = u.find( e => e.id === t ); + return n + ? ( e[ + l.layout?.badgeFields?.includes( t ) + ? 'badgeFields' + : 'regularFields' + ].push( n ), + e ) + : e; + }, + { regularFields: [], badgeFields: [] } + ), + I = '900px', + V = Math.ceil( i.length / y ), + O = pc( i, r, y ); + return ( 0, c.jsxs )( c.Fragment, { + children: [ + r && + ( 0, c.jsxs )( t.Composite, { + render: ( 0, c.jsx )( fc, { + className: Te( 'dataviews-view-grid-infinite-scroll', o, { + [ `has-${ l.layout?.density }-density` ]: + l.layout?.density && + [ 'compact', 'comfortable' ].includes( + l.layout.density + ), + } ), + previewSize: l.layout?.previewSize, + 'aria-busy': a, + ref: w, + } ), + role: 'feed', + focusWrap: ! 0, + inert: s, + children: [ + Array.from( { length: O } ).map( ( e, n ) => + ( 0, c.jsx )( + t.Composite.Item, + { + render: e => + ( 0, c.jsx )( Pe, { + ...e, + direction: 'column', + role: 'article', + className: + 'dataviews-view-grid__row__gridcell dataviews-view-grid__card dataviews-view-grid__placeholder', + } ), + 'aria-hidden': ! 0, + tabIndex: -1, + }, + `placeholder-${ n }` + ) + ), + i.map( e => { + const n = h( e ), + i = e.position; + return ( 0, c.jsx )( + t.Composite.Item, + { + render: t => + ( 0, c.jsx )( vc, { + ...t, + id: n, + role: 'article', + view: l, + selection: d, + onChangeSelection: f, + onClickItem: m, + isItemClickable: p, + renderItemLink: g, + getItemId: h, + item: e, + actions: v, + mediaField: S, + titleField: C, + descriptionField: _, + regularFields: E, + badgeFields: k, + hasBulkActions: x, + posinset: i, + setsize: b.totalItems, + config: { sizes: I }, + } ), + }, + n + ); + } ), + ], + } ), + ! r && + ( 0, c.jsx )( t.Composite, { + role: 'grid', + className: Te( 'dataviews-view-grid', o, { + [ `has-${ l.layout?.density }-density` ]: + l.layout?.density && + [ 'compact', 'comfortable' ].includes( l.layout.density ), + } ), + focusWrap: ! 0, + 'aria-busy': a, + 'aria-rowcount': V, + ref: w, + inert: s, + children: hc( i, y ).map( ( e, i ) => + ( 0, c.jsx )( + t.Composite.Row, + { + render: ( 0, c.jsx )( 'div', { + role: 'row', + 'aria-rowindex': i + 1, + 'aria-label': ( 0, n.sprintf )( + /* translators: %d: The row number in the grid */ + /* translators: %d: The row number in the grid */ + ( 0, n.__ )( 'Row %d' ), + i + 1 + ), + className: 'dataviews-view-grid__row', + style: { + gridTemplateColumns: `repeat( ${ y }, minmax(0, 1fr) )`, + }, + } ), + children: e.map( e => { + const n = h( e ); + return ( 0, c.jsx )( + t.Composite.Item, + { + render: t => + ( 0, c.jsx )( vc, { + ...t, + id: n, + role: 'gridcell', + view: l, + selection: d, + onChangeSelection: f, + onClickItem: m, + isItemClickable: p, + renderItemLink: g, + getItemId: h, + item: e, + actions: v, + mediaField: S, + titleField: C, + descriptionField: _, + regularFields: E, + badgeFields: k, + hasBulkActions: x, + config: { sizes: I }, + } ), + }, + n + ); + } ), + }, + i + ) + ), + } ), + ], + } ); + } + var wc = 'data-wp-hash'; + function yc() { + const e = globalThis; + return ( + e.__wpStyleRuntime || + ( ( e.__wpStyleRuntime = { + documents: new Map(), + styles: new Map(), + injectedStyles: new WeakMap(), + } ), + 'undefined' != typeof document && + ( function ( e ) { + const t = yc(); + t.documents.set( e, ( t.documents.get( e ) ?? 0 ) + 1 ); + for ( const [ n, i ] of t.styles ) xc( e, n, i ); + } )( document ) ), + e.__wpStyleRuntime + ); + } + function xc( e, t, n ) { + if ( ! e.head ) return; + const i = yc(); + let r = i.injectedStyles.get( e ); + if ( ( r || ( ( r = new Set() ), i.injectedStyles.set( e, r ) ), r.has( t ) ) ) + return; + if ( + ( function ( e, t ) { + if ( ! e.head ) return ! 1; + for ( const n of e.head.querySelectorAll( `style[${ wc }]` ) ) + if ( n.getAttribute( wc ) === t ) return ! 0; + return ! 1; + } )( e, t ) + ) + return void r.add( t ); + const o = e.createElement( 'style' ); + o.setAttribute( wc, t ), + o.appendChild( e.createTextNode( n ) ), + e.head.appendChild( o ), + r.add( t ); + } + ! ( function ( e, t ) { + const n = yc(); + n.styles.set( e, t ); + for ( const i of n.documents.keys() ) xc( i, e, t ); + } )( + 'c46e8cb841', + '@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{.f37b9e2e191ebd66__visually-hidden{word-wrap:normal;border:0;clip-path:inset(50%);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px;word-break:normal}}' + ); + var Cc = ( 0, e.forwardRef )( function ( { render: e, ...t }, n ) { + return Ee( { + render: e, + ref: n, + props: me( { className: 'f37b9e2e191ebd66__visually-hidden' }, t, { + 'data-visually-hidden': '', + } ), + } ); + } ), + { Menu: Sc } = $( t.privateApis ); + function _c( e ) { + return `${ e }-item-wrapper`; + } + function jc( e ) { + return `${ e }-dropdown`; + } + function Ec( { idPrefix: n, primaryAction: i, item: r } ) { + const o = ( 0, nr.useRegistry )(), + [ s, a ] = ( 0, e.useState )( ! 1 ), + l = ( function ( e, t ) { + return `${ e }-primary-action-${ t }`; + } )( n, i.id ), + u = 'string' == typeof i.label ? i.label : i.label( [ r ] ); + return 'RenderModal' in i + ? ( 0, c.jsx )( + 'div', + { + role: 'gridcell', + children: ( 0, c.jsx )( t.Composite.Item, { + id: l, + render: ( 0, c.jsx )( t.Button, { + disabled: !! i.disabled, + accessibleWhenDisabled: ! 0, + text: u, + size: 'small', + onClick: () => a( ! 0 ), + } ), + children: + s && + ( 0, c.jsx )( ar, { + action: i, + items: [ r ], + closeModal: () => a( ! 1 ), + } ), + } ), + }, + i.id + ) + : ( 0, c.jsx )( + 'div', + { + role: 'gridcell', + children: ( 0, c.jsx )( t.Composite.Item, { + id: l, + render: ( 0, c.jsx )( t.Button, { + disabled: !! i.disabled, + accessibleWhenDisabled: ! 0, + size: 'small', + onClick: () => { + i.callback( [ r ], { registry: o } ); + }, + children: u, + } ), + } ), + }, + i.id + ); + } + function kc( { + view: i, + actions: r, + idPrefix: o, + isSelected: s, + item: a, + titleField: l, + mediaField: u, + descriptionField: d, + onSelect: f, + otherFields: m, + onDropdownTriggerKeyDown: p, + posinset: g, + } ) { + const { + showTitle: h = ! 0, + showMedia: v = ! 0, + showDescription: b = ! 0, + infiniteScrollEnabled: w, + } = i, + y = ( 0, e.useRef )( null ), + x = `${ o }-label`, + C = `${ o }-description`, + S = ( 0, nr.useRegistry )(), + [ _, j ] = ( 0, e.useState )( ! 1 ), + [ E, k ] = ( 0, e.useState )( null ), + I = ( { type: e } ) => { + j( 'mouseenter' === e ); + }, + { paginationInfo: V } = ( 0, e.useContext )( Yi ); + ( 0, e.useEffect )( () => { + s && + y.current?.scrollIntoView( { + behavior: 'auto', + block: 'nearest', + inline: 'nearest', + } ); + }, [ s ] ); + const { primaryAction: O, eligibleActions: P } = ( 0, e.useMemo )( () => { + const e = r.filter( e => ! e.isEligible || e.isEligible( a ) ); + return { + primaryAction: e.filter( e => e.isPrimary )[ 0 ], + eligibleActions: e, + }; + }, [ r, a ] ), + M = O && 1 === r.length, + T = + v && u?.render + ? ( 0, c.jsx )( 'div', { + className: 'dataviews-view-list__media-wrapper', + children: ( 0, c.jsx )( u.render, { + item: a, + field: u, + config: { sizes: '52px' }, + } ), + } ) + : null, + N = h && l?.render ? ( 0, c.jsx )( l.render, { item: a, field: l } ) : null, + A = b && d?.render, + R = !! T && ! A && ! m.length, + F = + P?.length > 0 && + ( 0, c.jsxs )( Pe, { + direction: 'row', + gap: 'md', + className: 'dataviews-view-list__item-actions', + children: [ + O && ( 0, c.jsx )( Ec, { idPrefix: o, primaryAction: O, item: a } ), + ! M && + ( 0, c.jsxs )( 'div', { + role: 'gridcell', + children: [ + ( 0, c.jsxs )( Sc, { + placement: 'bottom-end', + children: [ + ( 0, c.jsx )( Sc.TriggerButton, { + render: ( 0, c.jsx )( t.Composite.Item, { + id: jc( o ), + render: ( 0, c.jsx )( t.Button, { + size: 'small', + icon: tr, + label: ( 0, n.__ )( 'Actions' ), + accessibleWhenDisabled: ! 0, + disabled: ! r.length, + onKeyDown: p, + } ), + } ), + } ), + ( 0, c.jsx )( Sc.Popover, { + children: ( 0, c.jsx )( lr, { + actions: P, + item: a, + registry: S, + setActiveModalAction: k, + } ), + } ), + ], + } ), + !! E && + ( 0, c.jsx )( ar, { + action: E, + items: [ a ], + closeModal: () => k( null ), + } ), + ], + } ), + ], + } ); + return ( 0, c.jsx )( t.Composite.Row, { + ref: y, + render: ( 0, c.jsx )( 'div', { + 'aria-posinset': g, + 'aria-setsize': w ? V.totalItems : void 0, + } ), + role: w ? 'article' : 'row', + className: Te( { 'is-selected': s, 'is-hovered': _ } ), + onMouseEnter: I, + onMouseLeave: I, + children: ( 0, c.jsxs )( Pe, { + direction: 'row', + className: 'dataviews-view-list__item-wrapper', + children: [ + ( 0, c.jsx )( 'div', { + role: 'gridcell', + children: ( 0, c.jsx )( t.Composite.Item, { + id: _c( o ), + 'aria-pressed': s, + 'aria-labelledby': x, + 'aria-describedby': C, + className: 'dataviews-view-list__item', + onClick: () => f( a ), + } ), + } ), + ( 0, c.jsxs )( Pe, { + direction: 'row', + gap: 'md', + justify: 'start', + align: R ? 'center' : 'flex-start', + style: { flex: 1, minWidth: 0 }, + children: [ + T, + ( 0, c.jsxs )( Pe, { + direction: 'column', + gap: 'xs', + className: 'dataviews-view-list__field-wrapper', + children: [ + ( 0, c.jsxs )( Pe, { + direction: 'row', + align: 'center', + children: [ + ( 0, c.jsx )( 'div', { + className: + 'dataviews-title-field dataviews-view-list__title-field', + id: x, + children: N, + } ), + F, + ], + } ), + A && + ( 0, c.jsx )( 'div', { + className: 'dataviews-view-list__field', + children: ( 0, c.jsx )( d.render, { + item: a, + field: d, + } ), + } ), + ( 0, c.jsx )( 'div', { + className: 'dataviews-view-list__fields', + id: C, + children: m.map( e => + ( 0, c.jsxs )( + 'div', + { + className: 'dataviews-view-list__field', + children: [ + ( 0, c.jsx )( Cc, { + className: + 'dataviews-view-list__field-label', + render: ( 0, c.jsx )( + 'span', + {} + ), + children: e.label, + } ), + ( 0, c.jsx )( 'span', { + className: + 'dataviews-view-list__field-value', + children: ( 0, c.jsx )( + e.render, + { item: a, field: e } + ), + } ), + ], + }, + e.id + ) + ), + } ), + ], + } ), + ], + } ), + ], + } ), + } ); + } + function Ic( e ) { + return !! e; + } + function Vc( { + groupName: t, + groupData: i, + groupField: r, + showLabel: o = ! 0, + children: s, + } ) { + const a = o + ? ( 0, e.createInterpolateElement )( + // translators: %s: The label of the field e.g. "Status". + // translators: %s: The label of the field e.g. "Status". + ( 0, n.sprintf )( ( 0, n.__ )( '%s: ' ), r.label ).trim(), + { groupName: ( 0, c.jsx )( r.render, { item: i[ 0 ], field: r } ) } + ) + : ( 0, c.jsx )( r.render, { item: i[ 0 ], field: r } ); + return ( 0, c.jsxs )( + Pe, + { + direction: 'column', + className: 'dataviews-view-activity__group', + children: [ + ( 0, c.jsx )( 'h3', { + className: 'dataviews-view-activity__group-header', + children: a, + } ), + s, + ], + }, + t + ); + } + var Oc = function ( t ) { + const { + view: n, + actions: i, + item: r, + titleField: o, + mediaField: s, + descriptionField: a, + otherFields: l, + posinset: u, + onClickItem: d, + renderItemLink: f, + isItemClickable: m, + } = t, + { + showTitle: p = ! 0, + showMedia: g = ! 0, + showDescription: h = ! 0, + infiniteScrollEnabled: v, + } = n, + b = ( 0, e.useRef )( null ), + w = ( 0, nr.useRegistry )(), + { paginationInfo: y } = ( 0, e.useContext )( Yi ), + { primaryActions: x, eligibleActions: C } = ( 0, e.useMemo )( () => { + const e = i.filter( e => ! e.isEligible || e.isEligible( r ) ); + return { primaryActions: e.filter( e => e.isPrimary ), eligibleActions: e }; + }, [ i, r ] ), + S = ( 0, qi.useViewportMatch )( 'medium', '<' ), + _ = n.layout?.density ?? 'balanced', + j = + g && 'compact' !== _ && s?.render + ? ( 0, c.jsx )( s.render, { + item: r, + field: s, + config: { sizes: 'comfortable' === _ ? '32px' : '24px' }, + } ) + : null, + E = ( 0, c.jsx )( 'div', { + className: 'dataviews-view-activity__item-type-icon', + children: + j || + ( 0, c.jsx )( 'span', { + className: 'dataviews-view-activity__item-bullet', + 'aria-hidden': 'true', + } ), + } ), + k = p && o?.render ? ( 0, c.jsx )( o.render, { item: r, field: o } ) : null, + I = ( 0, e.useMemo )( () => ( 'comfortable' === _ ? 'md' : 'sm' ), [ _ ] ); + return ( 0, c.jsx )( 'div', { + ref: b, + role: v ? 'article' : void 0, + 'aria-posinset': u, + 'aria-setsize': v ? y.totalItems : void 0, + className: Te( + 'dataviews-view-activity__item', + 'compact' === _ && 'is-compact', + 'balanced' === _ && 'is-balanced', + 'comfortable' === _ && 'is-comfortable' + ), + children: ( 0, c.jsxs )( Pe, { + direction: 'row', + gap: 'lg', + justify: 'start', + align: 'flex-start', + children: [ + ( 0, c.jsx )( Pe, { + direction: 'column', + gap: 'xs', + align: 'center', + className: 'dataviews-view-activity__item-type', + children: E, + } ), + ( 0, c.jsxs )( Pe, { + direction: 'column', + gap: I, + align: 'flex-start', + className: 'dataviews-view-activity__item-content', + children: [ + k && + ( 0, c.jsx )( Pr, { + item: r, + isItemClickable: m, + onClickItem: d, + renderItemLink: f, + className: 'dataviews-view-activity__item-title', + children: k, + } ), + h && + a && + ( 0, c.jsx )( 'div', { + className: 'dataviews-view-activity__item-description', + children: ( 0, c.jsx )( a.render, { + item: r, + field: a, + } ), + } ), + ( 0, c.jsx )( 'div', { + className: 'dataviews-view-activity__item-fields', + children: l.map( e => + ( 0, c.jsxs )( + 'div', + { + className: + 'dataviews-view-activity__item-field', + children: [ + ( 0, c.jsx )( Cc, { + className: + 'dataviews-view-activity__item-field-label', + render: ( 0, c.jsx )( 'span', {} ), + children: e.label, + } ), + ( 0, c.jsx )( 'span', { + className: + 'dataviews-view-activity__item-field-value', + children: ( 0, c.jsx )( e.render, { + item: r, + field: e, + } ), + } ), + ], + }, + e.id + ) + ), + } ), + !! x?.length && + ( 0, c.jsx )( dr, { + item: r, + actions: x, + registry: w, + buttonVariant: 'secondary', + } ), + ], + } ), + ( x.length < C.length || ( S && C.length > 0 ) ) && + ( 0, c.jsx )( 'div', { + className: 'dataviews-view-activity__item-actions', + children: ( 0, c.jsx )( cr, { + item: r, + actions: C, + isCompact: ! 0, + } ), + } ), + ], + } ), + } ); + }; + function Pc( e ) { + return !! e; + } + function Mc( e ) { + const { data: t, fields: n, getItemId: i, view: r } = e, + o = n.find( e => e.id === r.titleField ), + s = n.find( e => e.id === r.mediaField ), + a = n.find( e => e.id === r.descriptionField ), + l = ( r?.fields ?? [] ).map( e => n.find( t => e === t.id ) ).filter( Pc ); + return t.map( ( t, n ) => + ( 0, J.createElement )( Oc, { + ...e, + key: i( t ), + item: t, + mediaField: s, + titleField: o, + descriptionField: a, + otherFields: l, + posinset: r.infiniteScrollEnabled ? n + 1 : void 0, + } ) + ); + } + function Tc( t ) { + return ( 0, e.useMemo )( () => t?.every( e => e.supportsBulk ), [ t ] ); + } + var { Badge: Nc } = $( t.privateApis ); + function Ac( { + view: i, + multiselect: r, + selection: o, + onChangeSelection: s, + getItemId: a, + item: l, + mediaField: u, + titleField: d, + descriptionField: f, + regularFields: m, + badgeFields: p, + config: g, + posinset: h, + setsize: v, + } ) { + const { showTitle: b = ! 0, showMedia: w = ! 0, showDescription: y = ! 0 } = i, + x = a( l ), + C = ( 0, e.useRef )( null ), + S = o.includes( x ); + mc( C, h ); + const _ = u?.render + ? ( 0, c.jsx )( u.render, { item: l, field: u, config: g } ) + : null, + j = b && d?.render ? ( 0, c.jsx )( d.render, { item: l, field: d } ) : null; + return ( 0, c.jsxs )( + t.Composite.Item, + { + ref: C, + 'aria-label': d + ? d.getValue( { item: l } ) || ( 0, n.__ )( '(no title)' ) + : void 0, + render: ( { children: e, ...t } ) => + ( 0, c.jsx )( Pe, { direction: 'column', children: e, ...t } ), + role: 'option', + 'aria-posinset': h, + 'aria-setsize': v, + className: Te( 'dataviews-view-picker-grid__card', { 'is-selected': S } ), + 'aria-selected': S, + onClick: () => { + if ( S ) s( o.filter( e => x !== e ) ); + else { + const e = r ? [ ...o, x ] : [ x ]; + s( e ); + } + }, + children: [ + w && + _ && + ( 0, c.jsx )( 'div', { + className: 'dataviews-view-picker-grid__media', + children: _, + } ), + w && + _ && + ( 0, c.jsx )( er, { + item: l, + selection: o, + onChangeSelection: s, + getItemId: a, + titleField: d, + disabled: ! 1, + 'aria-hidden': ! 0, + tabIndex: -1, + } ), + b && + ( 0, c.jsx )( Pe, { + direction: 'row', + justify: 'space-between', + className: 'dataviews-view-picker-grid__title-actions', + children: ( 0, c.jsx )( 'div', { + className: + 'dataviews-view-picker-grid__title-field dataviews-title-field', + children: j, + } ), + } ), + ( 0, c.jsxs )( Pe, { + direction: 'column', + gap: 'xs', + children: [ + y && + f?.render && + ( 0, c.jsx )( f.render, { item: l, field: f } ), + !! p?.length && + ( 0, c.jsx )( Pe, { + direction: 'row', + className: 'dataviews-view-picker-grid__badge-fields', + gap: 'sm', + wrap: 'wrap', + align: 'top', + justify: 'flex-start', + children: p.map( e => + ( 0, c.jsx )( + Nc, + { + className: + 'dataviews-view-picker-grid__field-value', + children: ( 0, c.jsx )( e.render, { + item: l, + field: e, + } ), + }, + e.id + ) + ), + } ), + !! m?.length && + ( 0, c.jsx )( Pe, { + direction: 'column', + className: 'dataviews-view-picker-grid__fields', + gap: 'xs', + children: m.map( e => + ( 0, c.jsx )( + t.Flex, + { + className: + 'dataviews-view-picker-grid__field', + gap: 1, + justify: 'flex-start', + expanded: ! 0, + style: { height: 'auto' }, + direction: 'row', + children: ( 0, c.jsxs )( c.Fragment, { + children: [ + ( 0, c.jsx )( t.FlexItem, { + className: + 'dataviews-view-picker-grid__field-name', + children: e.header, + } ), + ( 0, c.jsx )( t.FlexItem, { + className: + 'dataviews-view-picker-grid__field-value', + style: { maxHeight: 'none' }, + children: ( 0, c.jsx )( + e.render, + { item: l, field: e } + ), + } ), + ], + } ), + }, + e.id + ) + ), + } ), + ], + } ), + ], + }, + x + ); + } + function Rc( { groupName: e, groupField: t, showLabel: i = ! 0, children: r } ) { + const o = ( 0, qi.useInstanceId )( Rc, 'dataviews-view-picker-grid-group__header' ); + return ( 0, c.jsxs )( + Pe, + { + direction: 'column', + gap: 'sm', + role: 'group', + 'aria-labelledby': o, + children: [ + ( 0, c.jsx )( 'h3', { + className: 'dataviews-view-picker-grid-group__header', + id: o, + children: i + ? ( 0, n.sprintf )( + // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022". + // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022". + ( 0, n.__ )( '%1$s: %2$s' ), + t.label, + e + ) + : e, + } ), + r, + ], + }, + e + ); + } + function Fc( { item: e, fields: t, column: n, align: i } ) { + const r = t.find( e => e.id === n ); + if ( ! r ) return null; + const o = Te( 'dataviews-view-table__cell-content-wrapper', { + 'dataviews-view-table__cell-align-end': 'end' === i, + 'dataviews-view-table__cell-align-center': 'center' === i, + } ); + return ( 0, c.jsx )( 'div', { + className: o, + children: ( 0, c.jsx )( r.render, { item: e, field: r } ), + } ); + } + function Lc( { + item: n, + fields: i, + id: r, + view: o, + titleField: s, + mediaField: a, + descriptionField: l, + selection: u, + getItemId: d, + onChangeSelection: f, + multiselect: m, + posinset: p, + } ) { + const { paginationInfo: g } = ( 0, e.useContext )( Yi ), + h = u.includes( r ), + [ v, b ] = ( 0, e.useState )( ! 1 ), + w = ( 0, e.useRef )( null ); + mc( w, p ); + const { + showTitle: y = ! 0, + showMedia: x = ! 0, + showDescription: C = ! 0, + infiniteScrollEnabled: S, + } = o, + _ = () => { + b( ! 0 ); + }, + j = () => { + b( ! 1 ); + }, + E = o.fields ?? [], + k = ( s && y ) || ( a && x ) || ( l && C ); + return ( 0, c.jsxs )( + t.Composite.Item, + { + ref: w, + render: ( { children: e, ...t } ) => + ( 0, c.jsx )( 'tr', { + className: Te( 'dataviews-view-table__row', { + 'is-selected': h, + 'is-hovered': v, + } ), + onMouseEnter: _, + onMouseLeave: j, + children: e, + ...t, + } ), + 'aria-selected': h, + 'aria-setsize': g.totalItems || void 0, + 'aria-posinset': p, + role: S ? 'article' : 'option', + onMouseDown: e => { + 0 === e.button && + e.currentTarget.parentElement?.focus( { preventScroll: ! 0 } ); + }, + onClick: () => { + if ( h ) f( u.filter( e => r !== e ) ); + else { + const e = m ? [ ...u, r ] : [ r ]; + f( e ); + } + }, + children: [ + ( 0, c.jsx )( 'td', { + className: 'dataviews-view-table__checkbox-column', + role: 'presentation', + children: ( 0, c.jsx )( 'div', { + className: 'dataviews-view-table__cell-content-wrapper', + children: ( 0, c.jsx )( er, { + item: n, + selection: u, + onChangeSelection: f, + getItemId: d, + titleField: s, + disabled: ! 1, + 'aria-hidden': ! 0, + tabIndex: -1, + } ), + } ), + } ), + k && + ( 0, c.jsx )( 'td', { + role: 'presentation', + children: ( 0, c.jsx )( Mr, { + item: n, + titleField: y ? s : void 0, + mediaField: x ? a : void 0, + descriptionField: C ? l : void 0, + isItemClickable: () => ! 1, + } ), + } ), + E.map( e => { + const { + width: t, + maxWidth: r, + minWidth: s, + align: a, + } = o.layout?.styles?.[ e ] ?? {}; + return ( 0, c.jsx )( + 'td', + { + style: { width: t, maxWidth: r, minWidth: s }, + role: 'presentation', + children: ( 0, c.jsx )( Fc, { + fields: i, + item: n, + column: e, + align: a, + } ), + }, + e + ); + } ), + ], + }, + r + ); + } + function Dc() { + const i = ( 0, e.useContext )( Yi ), + r = i.view; + return ( 0, c.jsxs )( t.__experimentalToggleGroupControl, { + size: '__unstable-large', + label: ( 0, n.__ )( 'Density' ), + value: r.layout?.density || 'balanced', + onChange: e => { + i.onChangeView( { ...r, layout: { ...r.layout, density: e } } ); + }, + isBlock: ! 0, + children: [ + ( 0, c.jsx )( + t.__experimentalToggleGroupControlOption, + { + value: 'comfortable', + label: ( 0, n._x )( + 'Comfortable', + 'Density option for DataView layout' + ), + }, + 'comfortable' + ), + ( 0, c.jsx )( + t.__experimentalToggleGroupControlOption, + { + value: 'balanced', + label: ( 0, n._x )( + 'Balanced', + 'Density option for DataView layout' + ), + }, + 'balanced' + ), + ( 0, c.jsx )( + t.__experimentalToggleGroupControlOption, + { + value: 'compact', + label: ( 0, n._x )( + 'Compact', + 'Density option for DataView layout' + ), + }, + 'compact' + ), + ], + } ); + } + var Bc = [ + { value: 120, breakpoint: 1 }, + { value: 170, breakpoint: 1 }, + { value: 230, breakpoint: 1 }, + { value: 290, breakpoint: 1112 }, + { value: 350, breakpoint: 1636 }, + { value: 430, breakpoint: 588 }, + ]; + function zc() { + const i = ( 0, e.useContext )( Yi ), + r = i.view, + o = Bc.filter( e => i.containerWidth >= e.breakpoint ), + s = r.layout?.previewSize ?? 230, + a = + o + .map( ( e, t ) => ( { ...e, index: t } ) ) + .filter( e => e.value <= s ) + .sort( ( e, t ) => t.value - e.value )[ 0 ]?.index ?? 0, + l = o.map( ( e, t ) => ( { value: t } ) ); + return ( 0, c.jsx )( t.RangeControl, { + __next40pxDefaultSize: ! 0, + showTooltip: ! 1, + label: ( 0, n.__ )( 'Preview size' ), + value: a, + min: 0, + max: o.length - 1, + withInputField: ! 1, + onChange: ( e = 0 ) => { + i.onChangeView( { + ...r, + layout: { ...r.layout, previewSize: o[ e ].value }, + } ); + }, + step: 1, + marks: l, + } ); + } + function Wc() { + return ( 0, c.jsxs )( c.Fragment, { + children: [ ( 0, c.jsx )( Dc, {} ), ( 0, c.jsx )( zc, {} ) ], + } ); + } + var $c = [ + { + type: D, + label: ( 0, n.__ )( 'Table' ), + component: function ( { + actions: i, + data: r, + fields: o, + getItemId: s, + getItemLevel: a, + isLoading: l = ! 1, + onChangeView: u, + onChangeSelection: d, + selection: f, + setOpenedFilter: m, + onClickItem: p, + isItemClickable: g, + renderItemLink: h, + view: v, + className: b, + empty: w, + } ) { + const { containerRef: y } = ( 0, e.useContext )( Yi ), + x = Fr( l ), + C = ( 0, e.useRef )( new Map() ), + S = ( 0, e.useRef )( void 0 ), + [ _, j ] = ( 0, e.useState )(), + [ E, k ] = ( 0, e.useState )( null ); + ( 0, e.useEffect )( () => { + S.current && ( S.current.focus(), ( S.current = void 0 ) ); + } ); + const I = ( 0, e.useId )(), + { isHorizontalScrollEnd: V, isVerticallyScrolled: O } = + ( function ( { + scrollContainerRef: t, + enabledHorizontal: i = ! 1, + } ) { + const [ r, o ] = ( 0, e.useState )( ! 1 ), + [ s, a ] = ( 0, e.useState )( ! 1 ), + l = ( 0, e.useCallback )( () => { + const e = t.current; + var r; + e && + ( i && + o( + ( ( r = e ), + ( 0, n.isRTL )() + ? Math.abs( r.scrollLeft ) <= 1 + : r.scrollLeft + r.clientWidth >= + r.scrollWidth - 1 ) + ), + a( e.scrollTop > 0 ) ); + }, [ t, i ] ); + return ( + ( 0, e.useEffect )( () => { + if ( 'undefined' == typeof window || ! t.current ) + return () => {}; + const e = t.current; + return ( + l(), + e.addEventListener( 'scroll', l ), + window.addEventListener( 'resize', l ), + () => { + e.removeEventListener( 'scroll', l ), + window.removeEventListener( + 'resize', + l + ); + } + ); + }, [ t, i, l ] ), + { isHorizontalScrollEnd: r, isVerticallyScrolled: s } + ); + } )( { + scrollContainerRef: y, + enabledHorizontal: !! i?.length, + } ), + P = gr( i, r ); + if ( _ ) return ( S.current = _ ), void j( void 0 ); + const M = e => { + const t = C.current.get( e.id ), + n = t ? C.current.get( t.fallback ) : void 0; + j( n?.node ); + }, + T = e => { + e.preventDefault(), e.stopPropagation(); + const t = { + getBoundingClientRect: () => ( { + x: e.clientX, + y: e.clientY, + top: e.clientY, + left: e.clientX, + right: e.clientX, + bottom: e.clientY, + width: 0, + height: 0, + toJSON: () => ( {} ), + } ), + }; + window.requestAnimationFrame( () => { + k( t ); + } ); + }, + N = !! r?.length, + A = o.find( e => e.id === v.titleField ), + F = o.find( e => e.id === v.mediaField ), + L = o.find( e => e.id === v.descriptionField ), + D = v.groupBy?.field + ? o.find( e => e.id === v.groupBy?.field ) + : null, + B = D ? Tr( r, D ) : null, + { + showTitle: z = ! 0, + showMedia: W = ! 0, + showDescription: $ = ! 0, + } = v, + H = ( A && z ) || ( F && W ) || ( L && $ ), + q = v.fields ?? [], + G = ( e, t ) => n => { + n + ? C.current.set( e, { + node: n, + fallback: q[ t > 0 ? t - 1 : 1 ], + } ) + : C.current.delete( e ); + }, + Y = v.infiniteScrollEnabled && ! B, + K = ( 0, n.isRTL )(); + return N + ? ( 0, c.jsxs )( c.Fragment, { + children: [ + ( 0, c.jsxs )( 'table', { + className: Te( 'dataviews-view-table', b, { + [ `has-${ v.layout?.density }-density` ]: + v.layout?.density && + [ 'compact', 'comfortable' ].includes( + v.layout.density + ), + 'has-bulk-actions': P, + 'is-refreshing': ! Y && x, + } ), + 'aria-busy': l, + 'aria-describedby': I, + role: Y ? 'feed' : void 0, + inert: ! Y && l ? 'true' : void 0, + children: [ + ( 0, c.jsxs )( 'colgroup', { + children: [ + P && + ( 0, c.jsx )( 'col', { + className: + 'dataviews-view-table__col-checkbox', + } ), + H && + ( 0, c.jsx )( 'col', { + className: + 'dataviews-view-table__col-first-data', + } ), + q.map( ( e, t ) => + ( 0, c.jsx )( + 'col', + { + className: Te( + `dataviews-view-table__col-${ e }`, + { + 'dataviews-view-table__col-expand': + ! H && + t === + q.length - + 1, + } + ), + }, + `col-${ e }` + ) + ), + !! i?.length && + ( 0, c.jsx )( 'col', { + className: + 'dataviews-view-table__col-actions', + } ), + ], + } ), + E && + ( 0, c.jsx )( t.Popover, { + anchor: E, + onClose: () => k( null ), + placement: 'bottom-start', + children: ( 0, c.jsx )( Rr, { + showLabel: ! 1, + } ), + } ), + ( 0, c.jsx )( 'thead', { + className: Te( { + 'dataviews-view-table__thead--stuck': O, + } ), + onContextMenu: T, + children: ( 0, c.jsxs )( 'tr', { + className: 'dataviews-view-table__row', + children: [ + P && + ( 0, c.jsx )( 'th', { + className: + 'dataviews-view-table__checkbox-column', + scope: 'col', + onContextMenu: T, + children: ( 0, c.jsx )( + hr, + { + selection: f, + onChangeSelection: + d, + data: r, + actions: i, + getItemId: s, + } + ), + } ), + H && + ( 0, c.jsx )( 'th', { + scope: 'col', + children: + A && + ( 0, c.jsx )( Or, { + ref: G( A.id, 0 ), + fieldId: A.id, + view: v, + fields: o, + onChangeView: u, + onHide: M, + setOpenedFilter: m, + canMove: ! 1, + canInsertLeft: + !! K && + ( v.layout + ?.enableMoving ?? + ! 0 ), + canInsertRight: + ! K && + ( v.layout + ?.enableMoving ?? + ! 0 ), + } ), + } ), + q.map( ( e, t ) => { + const { + width: n, + maxWidth: i, + minWidth: r, + align: s, + } = v.layout?.styles?.[ + e + ] ?? {}, + a = o.find( + t => t.id === e + ), + l = Lr( s, a?.type ), + d = + v.layout + ?.enableMoving ?? + ! 0; + return ( 0, c.jsx )( + 'th', + { + style: { + width: n, + maxWidth: i, + minWidth: r, + textAlign: l, + }, + 'aria-sort': + v.sort?.direction && + v.sort?.field === e + ? R[ + v.sort + .direction + ] + : void 0, + scope: 'col', + children: ( 0, c.jsx )( + Or, + { + ref: G( e, t ), + fieldId: e, + view: v, + fields: o, + onChangeView: u, + onHide: M, + setOpenedFilter: + m, + canMove: d, + canInsertLeft: + d, + canInsertRight: + d, + } + ), + }, + e + ); + } ), + !! i?.length && + ( 0, c.jsx )( 'th', { + className: Te( + 'dataviews-view-table__actions-column', + { + 'dataviews-view-table__actions-column--sticky': + ! 0, + 'dataviews-view-table__actions-column--stuck': + ! V, + } + ), + children: ( 0, c.jsx )( + 'span', + { + className: + 'dataviews-view-table-header', + children: ( 0, + n.__ )( 'Actions' ), + } + ), + } ), + ], + } ), + } ), + N && D && B + ? Array.from( B.entries() ).map( + ( [ e, t ] ) => + ( 0, c.jsxs )( + 'tbody', + { + children: [ + ( 0, c.jsx )( + 'tr', + { + className: + 'dataviews-view-table__group-header-row', + children: + ( 0, + c.jsx )( + 'td', + { + colSpan: + q.length + + ( H + ? 1 + : 0 ) + + ( P + ? 1 + : 0 ) + + ( i?.length + ? 1 + : 0 ), + className: + 'dataviews-view-table__group-header-cell', + children: + ! 1 === + v + .groupBy + ?.showLabel + ? e + : ( 0, + n.sprintf )( + // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022". + // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022". + ( 0, + n.__ )( + '%1$s: %2$s' + ), + D.label, + e + ), + } + ), + } + ), + t.map( ( e, t ) => + ( 0, c.jsx )( + Br, + { + item: e, + level: + v.showLevels && + 'function' == + typeof a + ? a( + e + ) + : void 0, + hasBulkActions: + P, + actions: + i, + fields: o, + id: + s( + e + ) || + t.toString(), + view: v, + titleField: + A, + mediaField: + F, + descriptionField: + L, + selection: + f, + getItemId: + s, + onChangeSelection: + d, + onClickItem: + p, + renderItemLink: + h, + isItemClickable: + g, + isActionsColumnSticky: + ! V, + }, + s( e ) + ) + ), + ], + }, + `group-${ e }` + ) + ) + : ( 0, c.jsx )( 'tbody', { + children: + N && + r.map( ( e, t ) => + ( 0, c.jsx )( + Br, + { + item: e, + level: + v.showLevels && + 'function' == + typeof a + ? a( e ) + : void 0, + hasBulkActions: P, + actions: i, + fields: o, + id: + s( e ) || + t.toString(), + view: v, + titleField: A, + mediaField: F, + descriptionField: L, + selection: f, + getItemId: s, + onChangeSelection: + d, + onClickItem: p, + renderItemLink: h, + isItemClickable: g, + isActionsColumnSticky: + ! V, + posinset: Y + ? t + 1 + : void 0, + }, + s( e ) + ) + ), + } ), + ], + } ), + Y && + l && + ( 0, c.jsx )( 'div', { + className: 'dataviews-loading', + id: I, + children: ( 0, c.jsx )( 'p', { + className: 'dataviews-loading-more', + children: ( 0, c.jsx )( t.Spinner, {} ), + } ), + } ), + ], + } ) + : ( 0, c.jsx )( 'div', { + className: Te( 'dataviews-no-results', { + 'is-refreshing': x, + } ), + id: I, + children: w, + } ); + }, + icon: Ki, + viewConfigOptions: Dc, + }, + { + type: B, + label: ( 0, n.__ )( 'Grid' ), + component: function ( { + actions: e, + data: i, + fields: r, + getItemId: o, + isLoading: s, + onChangeSelection: a, + onClickItem: l, + isItemClickable: u, + renderItemLink: d, + selection: f, + view: m, + className: p, + empty: g, + } ) { + const h = Fr( !! s ), + v = !! i?.length, + b = m.groupBy?.field + ? r.find( e => e.id === m.groupBy?.field ) + : null, + w = b ? Tr( i, b ) : null, + y = m.infiniteScrollEnabled && ! w; + if ( ! v ) + return ( 0, c.jsx )( 'div', { + className: Te( 'dataviews-no-results', { 'is-refreshing': h } ), + children: g, + } ); + const x = { + className: Te( p, { 'is-refreshing': ! y && h } ), + inert: ! y && s ? 'true' : void 0, + isLoading: s, + view: m, + fields: r, + selection: f, + onChangeSelection: a, + onClickItem: l, + isItemClickable: u, + renderItemLink: d, + getItemId: o, + actions: e, + }; + return ( 0, c.jsxs )( c.Fragment, { + children: [ + v && + b && + w && + ( 0, c.jsx )( Pe, { + direction: 'column', + gap: 'lg', + children: Array.from( w.entries() ).map( ( [ e, t ] ) => + ( 0, c.jsxs )( + Pe, + { + direction: 'column', + gap: 'sm', + children: [ + ( 0, c.jsx )( 'h3', { + className: + 'dataviews-view-grid__group-header', + children: + ! 1 === m.groupBy?.showLabel + ? e + : ( 0, n.sprintf )( + // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022". + // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022". + ( 0, n.__ )( + '%1$s: %2$s' + ), + b.label, + e + ), + } ), + ( 0, c.jsx )( bc, { + ...x, + data: t, + isInfiniteScroll: ! 1, + } ), + ], + }, + e + ) + ), + } ), + ! w && + ( 0, c.jsx )( bc, { + ...x, + data: i, + isInfiniteScroll: !! y, + } ), + y && + s && + ( 0, c.jsx )( 'p', { + className: 'dataviews-loading-more', + children: ( 0, c.jsx )( t.Spinner, {} ), + } ), + ], + } ); + }, + icon: Ui, + viewConfigOptions: Wc, + }, + { + type: 'list', + label: ( 0, n.__ )( 'List' ), + component: function i( r ) { + const { + actions: o, + data: s, + fields: a, + getItemId: l, + isLoading: u, + onChangeSelection: d, + selection: f, + view: m, + className: p, + empty: g, + } = r, + h = ( 0, qi.useInstanceId )( i, 'view-list' ), + v = Fr( !! u ), + b = s?.findLast( e => f.includes( l( e ) ) ), + w = a.find( e => e.id === m.titleField ), + y = a.find( e => e.id === m.mediaField ), + x = a.find( e => e.id === m.descriptionField ), + C = ( m?.fields ?? [] ) + .map( e => a.find( t => e === t.id ) ) + .filter( Ic ), + S = e => d( [ l( e ) ] ), + _ = ( 0, e.useCallback )( e => `${ h }-${ l( e ) }`, [ h, l ] ), + j = ( 0, e.useCallback )( + ( e, t ) => t.startsWith( _( e ) ), + [ _ ] + ), + [ E, k ] = ( 0, e.useState )( void 0 ), + I = ( 0, e.useRef )( null ); + ( 0, e.useEffect )( () => { + b && k( _c( _( b ) ) ); + }, [ b, _ ] ); + const V = s.findIndex( e => j( e, E ?? '' ) ), + O = ( 0, qi.usePrevious )( V ), + P = -1 !== V, + M = ( 0, e.useCallback )( + ( e, t ) => { + const n = Math.min( s.length - 1, Math.max( 0, e ) ); + if ( ! s[ n ] ) return; + const i = t( _( s[ n ] ) ); + k( i ), + I.current?.contains( + I.current.ownerDocument.activeElement + ) && document.getElementById( i )?.focus(); + }, + [ s, _ ] + ); + ( 0, e.useEffect )( () => { + ! P && void 0 !== O && -1 !== O && M( O, _c ); + }, [ P, M, O ] ); + const T = ( 0, e.useCallback )( + e => { + 'ArrowDown' === e.key && + ( e.preventDefault(), M( V + 1, jc ) ), + 'ArrowUp' === e.key && + ( e.preventDefault(), M( V - 1, jc ) ); + }, + [ M, V ] + ), + N = !! s?.length, + A = m.groupBy?.field + ? a.find( e => e.id === m.groupBy?.field ) + : null, + R = N && A ? Tr( s, A ) : null, + F = m.infiniteScrollEnabled && ! R; + return N + ? N && A && R + ? ( 0, c.jsx )( t.Composite, { + ref: I, + id: `${ h }`, + render: ( 0, c.jsx )( 'div', {} ), + className: 'dataviews-view-list__group', + role: 'grid', + activeId: E, + setActiveId: k, + children: ( 0, c.jsx )( Pe, { + direction: 'column', + gap: 'lg', + className: Te( 'dataviews-view-list', p ), + children: Array.from( R.entries() ).map( + ( [ e, t ] ) => + ( 0, c.jsxs )( + Pe, + { + direction: 'column', + gap: 'sm', + children: [ + ( 0, c.jsx )( 'h3', { + className: + 'dataviews-view-list__group-header', + children: + ! 1 === + m.groupBy?.showLabel + ? e + : ( 0, n.sprintf )( + // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022". + // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022". + ( 0, n.__ )( + '%1$s: %2$s' + ), + A.label, + e + ), + } ), + t.map( e => { + const t = _( e ); + return ( 0, c.jsx )( + kc, + { + view: m, + idPrefix: t, + actions: o, + item: e, + isSelected: e === b, + onSelect: S, + mediaField: y, + titleField: w, + descriptionField: x, + otherFields: C, + onDropdownTriggerKeyDown: + T, + }, + t + ); + } ), + ], + }, + e + ) + ), + } ), + } ) + : ( 0, c.jsxs )( c.Fragment, { + children: [ + ( 0, c.jsx )( t.Composite, { + ref: I, + id: h, + render: ( 0, c.jsx )( 'div', {} ), + className: Te( 'dataviews-view-list', p, { + [ `has-${ m.layout?.density }-density` ]: + m.layout?.density && + [ 'compact', 'comfortable' ].includes( + m.layout.density + ), + 'is-refreshing': ! F && v, + } ), + role: m.infiniteScrollEnabled ? 'feed' : 'grid', + activeId: E, + setActiveId: k, + inert: ! F && u ? 'true' : void 0, + children: s.map( ( e, t ) => { + const n = _( e ); + return ( 0, c.jsx )( + kc, + { + view: m, + idPrefix: n, + actions: o, + item: e, + isSelected: e === b, + onSelect: S, + mediaField: y, + titleField: w, + descriptionField: x, + otherFields: C, + onDropdownTriggerKeyDown: T, + posinset: m.infiniteScrollEnabled + ? t + 1 + : void 0, + }, + n + ); + } ), + } ), + F && + u && + ( 0, c.jsx )( 'p', { + className: 'dataviews-loading-more', + children: ( 0, c.jsx )( t.Spinner, {} ), + } ), + ], + } ) + : ( 0, c.jsx )( 'div', { + className: Te( 'dataviews-no-results', { + 'is-refreshing': v, + } ), + children: g, + } ); + }, + icon: ( 0, n.isRTL )() ? Xi : Zi, + viewConfigOptions: Dc, + }, + { + type: 'activity', + label: ( 0, n.__ )( 'Activity' ), + component: function ( e ) { + const { + empty: n, + data: i, + fields: r, + isLoading: o, + view: s, + className: a, + } = e, + l = Fr( !! o ), + u = !! i?.length, + d = s.groupBy?.field + ? r.find( e => e.id === s.groupBy?.field ) + : null, + f = u && d ? Tr( i, d ) : null, + m = s.infiniteScrollEnabled && ! f; + if ( ! u ) + return ( 0, c.jsx )( 'div', { + className: Te( 'dataviews-no-results', { 'is-refreshing': l } ), + children: n, + } ); + const p = ! m && !! o, + g = Te( 'dataviews-view-activity', a, { + 'is-refreshing': ! m && l, + } ), + h = f ? Array.from( f.entries() ) : []; + return u && d && f + ? ( 0, c.jsx )( Pe, { + direction: 'column', + gap: 'sm', + className: g, + inert: p ? 'true' : void 0, + children: h.map( ( [ t, n ] ) => + ( 0, c.jsx )( + Vc, + { + groupName: t, + groupData: n, + groupField: d, + showLabel: ! 1 !== s.groupBy?.showLabel, + children: ( 0, c.jsx )( Mc, { ...e, data: n } ), + }, + t + ) + ), + } ) + : ( 0, c.jsxs )( c.Fragment, { + children: [ + ( 0, c.jsx )( 'div', { + className: g, + role: s.infiniteScrollEnabled ? 'feed' : void 0, + inert: p ? 'true' : void 0, + children: ( 0, c.jsx )( Mc, { ...e } ), + } ), + m && + o && + ( 0, c.jsx )( 'p', { + className: 'dataviews-loading-more', + children: ( 0, c.jsx )( t.Spinner, {} ), + } ), + ], + } ); + }, + icon: Qi, + viewConfigOptions: Dc, + }, + { + type: 'pickerGrid', + label: ( 0, n.__ )( 'Grid' ), + component: function ( { + actions: n, + data: i, + fields: r, + getItemId: o, + isLoading: s, + onChangeSelection: a, + selection: l, + view: u, + className: d, + empty: f, + } ) { + const { + resizeObserverRef: m, + paginationInfo: p, + itemListLabel: g, + } = ( 0, e.useContext )( Yi ), + h = r.find( e => e.id === u?.titleField ), + v = r.find( e => e.id === u?.mediaField ), + b = r.find( e => e.id === u?.descriptionField ), + w = u.fields ?? [], + { regularFields: y, badgeFields: x } = w.reduce( + ( e, t ) => { + const n = r.find( e => e.id === t ); + return n + ? ( e[ + u.layout?.badgeFields?.includes( t ) + ? 'badgeFields' + : 'regularFields' + ].push( n ), + e ) + : e; + }, + { regularFields: [], badgeFields: [] } + ), + C = !! i?.length, + S = u.layout?.previewSize, + _ = Tc( n ), + j = '900px', + E = u.groupBy?.field + ? r.find( e => e.id === u.groupBy?.field ) + : null, + k = E ? Tr( i, E ) : null, + I = ( u.infiniteScrollEnabled && ! k ) ?? ! 1, + V = u?.page ?? 1, + O = u?.perPage ?? 0, + P = I ? p?.totalItems : void 0, + M = dc(), + T = pc( i, I, M ); + return ( 0, c.jsxs )( c.Fragment, { + children: [ + C && + E && + k && + ( 0, c.jsx )( t.Composite, { + virtualFocus: ! 0, + orientation: 'horizontal', + role: 'listbox', + 'aria-multiselectable': _, + className: Te( 'dataviews-view-picker-grid', d, { + [ `has-${ u.layout?.density }-density` ]: + u.layout?.density && + [ 'compact', 'comfortable' ].includes( + u.layout.density + ), + } ), + 'aria-label': g, + render: ( { children: e, ...t } ) => + ( 0, c.jsx )( Pe, { + direction: 'column', + gap: 'lg', + children: e, + ...t, + } ), + children: Array.from( k.entries() ).map( ( [ e, t ] ) => + ( 0, c.jsx )( + Rc, + { + groupName: e, + groupField: E, + showLabel: ! 1 !== u.groupBy?.showLabel, + children: ( 0, c.jsx )( fc, { + previewSize: S, + style: { + gridTemplateColumns: + S && + `repeat(auto-fill, minmax(${ S }px, 1fr))`, + }, + 'aria-busy': s, + ref: m, + children: t.map( e => { + const t = + e.position ?? + ( V - 1 ) * O + + i.indexOf( e ) + + 1; + return ( 0, c.jsx )( + Ac, + { + view: u, + multiselect: _, + selection: l, + onChangeSelection: a, + getItemId: o, + item: e, + mediaField: v, + titleField: h, + descriptionField: b, + regularFields: y, + badgeFields: x, + config: { sizes: j }, + posinset: t, + setsize: P, + }, + o( e ) + ); + } ), + } ), + }, + e + ) + ), + } ), + C && + ! k && + ( 0, c.jsxs )( t.Composite, { + render: ( 0, c.jsx )( fc, { + className: Te( 'dataviews-view-picker-grid', d, { + [ `has-${ u.layout?.density }-density` ]: + u.layout?.density && + [ 'compact', 'comfortable' ].includes( + u.layout.density + ), + } ), + previewSize: S, + 'aria-busy': s, + ref: m, + } ), + virtualFocus: ! 0, + orientation: 'horizontal', + role: 'listbox', + 'aria-multiselectable': _, + 'aria-label': g, + children: [ + Array.from( { length: T } ).map( ( e, n ) => + ( 0, c.jsx )( + t.Composite.Item, + { + render: ( { children: e, ...t } ) => + ( 0, c.jsx )( Pe, { + direction: 'column', + children: e, + ...t, + } ), + role: 'option', + 'aria-hidden': ! 0, + tabIndex: -1, + className: + 'dataviews-view-picker-grid__card dataviews-view-picker-grid__placeholder', + }, + `placeholder-${ n }` + ) + ), + i.map( e => { + const t = e.position; + return ( 0, c.jsx )( + Ac, + { + view: u, + multiselect: _, + selection: l, + onChangeSelection: a, + getItemId: o, + item: e, + mediaField: v, + titleField: h, + descriptionField: b, + regularFields: y, + badgeFields: x, + config: { sizes: j }, + posinset: t, + setsize: P, + }, + o( e ) + ); + } ), + ], + } ), + ! C && + ( 0, c.jsx )( 'div', { + className: Te( { + 'dataviews-loading': s, + 'dataviews-no-results': ! s, + } ), + children: s + ? ( 0, c.jsx )( 'p', { + children: ( 0, c.jsx )( t.Spinner, {} ), + } ) + : f, + } ), + C && + s && + ( 0, c.jsx )( 'p', { + className: 'dataviews-loading-more', + children: ( 0, c.jsx )( t.Spinner, {} ), + } ), + ], + } ); + }, + icon: Ui, + viewConfigOptions: Wc, + isPicker: ! 0, + }, + { + type: 'pickerTable', + label: ( 0, n.__ )( 'Table' ), + component: function ( { + actions: i, + data: r, + fields: o, + getItemId: s, + isLoading: a = ! 1, + onChangeView: l, + onChangeSelection: u, + selection: d, + setOpenedFilter: f, + view: m, + className: p, + empty: g, + } ) { + const h = ( 0, e.useRef )( new Map() ), + v = ( 0, e.useRef )( void 0 ), + [ b, w ] = ( 0, e.useState )(), + y = Tc( i ) ?? ! 1; + ( 0, e.useEffect )( () => { + v.current && ( v.current.focus(), ( v.current = void 0 ) ); + } ); + const x = m.groupBy?.field + ? o.find( e => e.id === m.groupBy?.field ) + : null, + C = x ? Tr( r, x ) : null, + S = m.infiniteScrollEnabled && ! C, + _ = ( 0, e.useId )(); + if ( b ) return ( v.current = b ), void w( void 0 ); + const j = e => { + const t = h.current.get( e.id ), + n = t ? h.current.get( t.fallback ) : void 0; + w( n?.node ); + }, + E = !! r?.length, + k = o.find( e => e.id === m.titleField ), + I = o.find( e => e.id === m.mediaField ), + V = o.find( e => e.id === m.descriptionField ), + { + showTitle: O = ! 0, + showMedia: P = ! 0, + showDescription: M = ! 0, + } = m, + T = ( k && O ) || ( I && P ) || ( V && M ), + N = m.fields ?? [], + A = ( e, t ) => n => { + n + ? h.current.set( e, { + node: n, + fallback: N[ t > 0 ? t - 1 : 1 ], + } ) + : h.current.delete( e ); + }; + return ( 0, c.jsxs )( c.Fragment, { + children: [ + ( 0, c.jsxs )( 'table', { + className: Te( + 'dataviews-view-table', + 'dataviews-view-picker-table', + p, + { + [ `has-${ m.layout?.density }-density` ]: + m.layout?.density && + [ 'compact', 'comfortable' ].includes( + m.layout.density + ), + } + ), + 'aria-busy': a, + 'aria-describedby': _, + role: S ? 'feed' : 'listbox', + children: [ + ( 0, c.jsx )( 'thead', { + role: 'presentation', + children: ( 0, c.jsxs )( 'tr', { + className: 'dataviews-view-table__row', + role: 'presentation', + children: [ + ( 0, c.jsx )( 'th', { + className: + 'dataviews-view-table__checkbox-column', + children: + y && + ( 0, c.jsx )( hr, { + selection: d, + onChangeSelection: u, + data: r, + actions: i, + getItemId: s, + disableSelectAll: S, + } ), + } ), + T && + ( 0, c.jsx )( 'th', { + children: + k && + ( 0, c.jsx )( Or, { + ref: A( k.id, 0 ), + fieldId: k.id, + view: m, + fields: o, + onChangeView: l, + onHide: j, + setOpenedFilter: f, + canMove: ! 1, + } ), + } ), + N.map( ( e, t ) => { + const { + width: n, + maxWidth: i, + minWidth: r, + align: s, + } = m.layout?.styles?.[ e ] ?? {}; + return ( 0, c.jsx )( + 'th', + { + style: { + width: n, + maxWidth: i, + minWidth: r, + textAlign: s, + }, + 'aria-sort': + m.sort?.direction && + m.sort?.field === e + ? R[ m.sort.direction ] + : void 0, + scope: 'col', + children: ( 0, c.jsx )( Or, { + ref: A( e, t ), + fieldId: e, + view: m, + fields: o, + onChangeView: l, + onHide: j, + setOpenedFilter: f, + canMove: + m.layout + ?.enableMoving ?? + ! 0, + } ), + }, + e + ); + } ), + ], + } ), + } ), + E && x && C + ? Array.from( C.entries() ).map( ( [ e, i ] ) => + ( 0, c.jsxs )( + t.Composite, + { + virtualFocus: ! 0, + orientation: 'vertical', + render: ( 0, c.jsx )( 'tbody', { + role: 'group', + } ), + children: [ + ( 0, c.jsx )( 'tr', { + className: + 'dataviews-view-table__group-header-row', + role: 'presentation', + children: ( 0, c.jsx )( + 'td', + { + colSpan: + N.length + + ( T ? 1 : 0 ) + + 1, + className: + 'dataviews-view-table__group-header-cell', + role: 'presentation', + children: + ! 1 === + m.groupBy + ?.showLabel + ? e + : ( 0, + n.sprintf )( + // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022". + // translators: 1: The label of the field e.g. "Date". 2: The value of the field, e.g.: "May 2022". + ( 0, + n.__ )( + '%1$s: %2$s' + ), + x.label, + e + ), + } + ), + } ), + i.map( ( e, t ) => + ( 0, c.jsx )( + Lc, + { + item: e, + fields: o, + id: + s( e ) || + t.toString(), + view: m, + titleField: k, + mediaField: I, + descriptionField: V, + selection: d, + getItemId: s, + onChangeSelection: + u, + multiselect: y, + }, + s( e ) + ) + ), + ], + }, + `group-${ e }` + ) + ) + : ( 0, c.jsx )( t.Composite, { + render: ( 0, c.jsx )( 'tbody', { + role: 'presentation', + } ), + virtualFocus: ! 0, + orientation: 'vertical', + children: + E && + r.map( ( e, t ) => { + const n = s( e ), + i = e.position; + return ( 0, c.jsx )( + Lc, + { + item: e, + fields: o, + id: n || t.toString(), + view: m, + titleField: k, + mediaField: I, + descriptionField: V, + selection: d, + getItemId: s, + onChangeSelection: u, + multiselect: y, + posinset: i, + }, + n + ); + } ), + } ), + ], + } ), + ( 0, c.jsxs )( 'div', { + className: Te( { + 'dataviews-loading': a, + 'dataviews-no-results': ! E && ! a, + } ), + id: _, + children: [ + ! E && + ( a + ? ( 0, c.jsx )( 'p', { + children: ( 0, c.jsx )( t.Spinner, {} ), + } ) + : g ), + E && + a && + ( 0, c.jsx )( 'p', { + className: 'dataviews-loading-more', + children: ( 0, c.jsx )( t.Spinner, {} ), + } ), + ], + } ), + ], + } ); + }, + icon: Ki, + viewConfigOptions: Dc, + isPicker: ! 0, + }, + ], + { Menu: Hc } = $( t.privateApis ); + function qc( { + filters: e, + view: t, + onChangeView: n, + setOpenedFilter: i, + triggerProps: r, + } ) { + const o = e.filter( e => ! e.isVisible ); + return ( 0, c.jsxs )( Hc, { + children: [ + ( 0, c.jsx )( Hc.TriggerButton, { ...r } ), + ( 0, c.jsx )( Hc.Popover, { + children: o.map( e => + ( 0, c.jsx )( + Hc.Item, + { + onClick: () => { + i( e.field ), + n( { + ...t, + page: 1, + filters: [ + ...( t.filters || [] ), + { + field: e.field, + value: void 0, + operator: e.operators[ 0 ], + }, + ], + } ); + }, + children: ( 0, c.jsx )( Hc.ItemLabel, { + children: e.name, + } ), + }, + e.field + ) + ), + } ), + ], + } ); + } + var Gc = ( 0, e.forwardRef )( function ( + { filters: e, view: i, onChangeView: r, setOpenedFilter: o }, + s + ) { + if ( ! e.length || e.every( ( { isPrimary: e } ) => e ) ) return null; + const a = e.filter( e => ! e.isVisible ); + return ( 0, c.jsx )( qc, { + triggerProps: { + render: ( 0, c.jsx )( t.Button, { + accessibleWhenDisabled: ! 0, + size: 'compact', + className: 'dataviews-filters-button', + variant: 'tertiary', + disabled: ! a.length, + ref: s, + } ), + children: ( 0, n.__ )( 'Add filter' ), + }, + filters: e, + view: i, + onChangeView: r, + setOpenedFilter: o, + } ); + } ); + function Yc( { buttonRef: t, filtersCount: n, children: i } ) { + return ( + ( 0, e.useEffect )( + () => () => { + t.current?.focus(); + }, + [ t ] + ), + ( 0, c.jsxs )( c.Fragment, { + children: [ + i, + !! n && + ( 0, c.jsx )( 'span', { + className: 'dataviews-filters-toggle__count', + children: n, + } ), + ], + } ) + ); + } + var Kc = function () { + const { + filters: i, + view: r, + onChangeView: o, + setOpenedFilter: s, + isShowingFilter: a, + setIsShowingFilter: l, + } = ( 0, e.useContext )( Yi ), + u = ( 0, e.useRef )( null ), + d = ( 0, e.useCallback )( + e => { + o( e ), l( ! 0 ); + }, + [ o, l ] + ); + if ( 0 === i.length ) return null; + const f = i.some( e => e.isVisible ), + m = { + label: ( 0, n.__ )( 'Add filter' ), + 'aria-expanded': ! 1, + isPressed: ! 1, + }, + p = { + label: ( 0, n._x )( 'Filter', 'verb' ), + 'aria-expanded': a, + isPressed: a, + onClick: () => { + a || s( null ), l( ! a ); + }, + }, + g = i.some( e => e.isPrimary || e.isLocked ), + h = ( 0, c.jsx )( t.Button, { + ref: u, + className: 'dataviews-filters__visibility-toggle', + size: 'compact', + icon: Sr, + disabled: g, + accessibleWhenDisabled: ! 0, + ...( f ? p : m ), + } ); + return ( 0, c.jsx )( 'div', { + className: 'dataviews-filters__container-visibility-toggle', + children: f + ? ( 0, c.jsx )( Yc, { + buttonRef: u, + filtersCount: r.filters?.length, + children: h, + } ) + : ( 0, c.jsx )( qc, { + filters: i, + view: r, + onChangeView: d, + setOpenedFilter: s, + triggerProps: { render: h }, + } ), + } ); + }; + function Uc( e ) { + const t = []; + for ( const n of e ) t.push( ...n ); + return t; + } + function Xc( e ) { + return e.slice().reverse(); + } + const Zc = 'undefined' != typeof window && !! window.document?.createElement; + function Qc( e ) { + return e ? ( 'self' in e ? e.document : e.ownerDocument || document ) : document; + } + function Jc( e, t = ! 1 ) { + const { activeElement: n } = Qc( e ); + if ( ! n?.nodeName ) return null; + if ( 'IFRAME' === n.tagName && n.contentDocument?.body ) + return Jc( n.contentDocument.body, t ); + if ( t ) { + const e = n.getAttribute( 'aria-activedescendant' ); + if ( e ) { + const t = Qc( n ).getElementById( e ); + if ( t ) return t; + } + } + return n; + } + function eu( e, t ) { + return e === t || e.contains( t ); + } + function tu( e ) { + const t = e.tagName.toLowerCase(); + return ( + 'button' === t || + ( ! ( 'input' !== t || ! e.type ) && -1 !== nu.indexOf( e.type ) ) + ); + } + const nu = [ 'button', 'color', 'file', 'image', 'reset', 'submit' ]; + function iu( e ) { + try { + const t = e instanceof HTMLInputElement && null !== e.selectionStart, + n = 'TEXTAREA' === e.tagName; + return t || n || ! 1; + } catch ( e ) { + return ! 1; + } + } + function ru( e ) { + return e.isContentEditable || iu( e ); + } + function ou( e ) { + let t = 0, + n = 0; + if ( iu( e ) ) ( t = e.selectionStart || 0 ), ( n = e.selectionEnd || 0 ); + else if ( e.isContentEditable ) { + const i = Qc( e ).getSelection(); + if ( + i?.rangeCount && + i.anchorNode && + eu( e, i.anchorNode ) && + i.focusNode && + eu( e, i.focusNode ) + ) { + const r = i.getRangeAt( 0 ), + o = r.cloneRange(); + o.selectNodeContents( e ), + o.setEnd( r.startContainer, r.startOffset ), + ( t = o.toString().length ), + o.setEnd( r.endContainer, r.endOffset ), + ( n = o.toString().length ); + } + } + return { start: t, end: n }; + } + function su( e, t ) { + const n = e?.getAttribute( 'role' ); + return n && -1 !== [ 'dialog', 'menu', 'listbox', 'tree', 'grid' ].indexOf( n ) + ? n + : t; + } + function au( e ) { + if ( ! e ) return null; + const t = e => 'auto' === e || 'scroll' === e; + if ( e.clientHeight && e.scrollHeight > e.clientHeight ) { + const { overflowY: n } = getComputedStyle( e ); + if ( t( n ) ) return e; + } else if ( e.clientWidth && e.scrollWidth > e.clientWidth ) { + const { overflowX: n } = getComputedStyle( e ); + if ( t( n ) ) return e; + } + return au( e.parentElement ) || document.scrollingElement || document.body; + } + function lu( e, ...t ) { + /text|search|password|tel|url/i.test( e.type ) && e.setSelectionRange( ...t ); + } + function cu() { + return !! Zc && /mac|iphone|ipad|ipod/i.test( navigator.platform ); + } + function uu() { + return Zc && cu() && /apple/i.test( navigator.vendor ); + } + function du( e ) { + return e.target === e.currentTarget; + } + function fu( e, t ) { + const n = new FocusEvent( 'blur', t ), + i = e.dispatchEvent( n ), + r = { ...t, bubbles: ! 0 }; + return e.dispatchEvent( new FocusEvent( 'focusout', r ) ), i; + } + function mu( e, t ) { + const n = new MouseEvent( 'click', t ); + return e.dispatchEvent( n ); + } + function pu( e, t ) { + const n = t || e.currentTarget, + i = e.relatedTarget; + return ! i || ! eu( n, i ); + } + function gu( e, t, n, i ) { + const r = ( e => { + if ( i ) { + const t = setTimeout( e, i ); + return () => clearTimeout( t ); + } + const t = requestAnimationFrame( e ); + return () => cancelAnimationFrame( t ); + } )( () => { + e.removeEventListener( t, o, ! 0 ), n(); + } ), + o = () => { + r(), n(); + }; + return e.addEventListener( t, o, { once: ! 0, capture: ! 0 } ), r; + } + function hu( e, t, n, i = window ) { + const r = []; + try { + i.document.addEventListener( e, t, n ); + for ( const o of Array.from( i.frames ) ) r.push( hu( e, t, n, o ) ); + } catch {} + return () => { + try { + i.document.removeEventListener( e, t, n ); + } catch {} + for ( const e of r ) e(); + }; + } + function vu( e ) { + return ( + !! e.matches( + "input:not([type='hidden']):not([disabled]), select:not([disabled]), textarea:not([disabled]), a[href], button:not([disabled]), [tabindex], summary, iframe, object, embed, area[href], audio[controls], video[controls], [contenteditable]:not([contenteditable='false'])" + ) && + !! ( function ( e ) { + if ( 'function' == typeof e.checkVisibility ) return e.checkVisibility(); + const t = e; + return ( + t.offsetWidth > 0 || t.offsetHeight > 0 || e.getClientRects().length > 0 + ); + } )( e ) && + ! e.closest( '[inert]' ) + ); + } + function bu( e ) { + const t = Jc( e ); + if ( ! t ) return ! 1; + if ( t === e ) return ! 0; + const n = t.getAttribute( 'aria-activedescendant' ); + return !! n && n === e.id; + } + function wu( ...e ) {} + function yu( e, t ) { + return 'function' == typeof Object.hasOwn + ? Object.hasOwn( e, t ) + : Object.prototype.hasOwnProperty.call( e, t ); + } + function xu( ...e ) { + return ( ...t ) => { + for ( const n of e ) 'function' == typeof n && n( ...t ); + }; + } + function Cu( e ) { + return e.normalize( 'NFD' ).replace( /[\u0300-\u036f]/g, '' ); + } + function Su( e ) { + return e; + } + function _u( e, t ) { + if ( ! e ) { + if ( 'string' != typeof t ) throw new Error( 'Invariant failed' ); + throw new Error( t ); + } + } + function ju( e ) { + return ( + e.disabled || ! 0 === e[ 'aria-disabled' ] || 'true' === e[ 'aria-disabled' ] + ); + } + function Eu( e ) { + const t = {}; + for ( const n in e ) void 0 !== e[ n ] && ( t[ n ] = e[ n ] ); + return t; + } + function ku( ...e ) { + for ( const t of e ) if ( void 0 !== t ) return t; + } + function Iu( e, t ) { + 'function' == typeof e ? e( t ) : e && ( e.current = t ); + } + const Vu = { ...ee }, + Ou = Vu.useId, + Pu = ( Vu.useDeferredValue, Vu.useInsertionEffect ), + Mu = Zc ? J.useLayoutEffect : J.useEffect; + function Tu( e ) { + const t = ( 0, J.useRef )( () => { + throw new Error( 'Cannot call an event handler while rendering.' ); + } ); + return ( + Pu + ? Pu( () => { + t.current = e; + } ) + : ( t.current = e ), + ( 0, J.useCallback )( ( ...e ) => t.current?.( ...e ), [] ) + ); + } + function Nu( ...e ) { + return ( 0, J.useMemo )( () => { + if ( e.some( Boolean ) ) + return t => { + for ( const n of e ) Iu( n, t ); + }; + }, e ); + } + function Au( e ) { + if ( Ou ) { + const t = Ou(); + return e || t; + } + const [ t, n ] = ( 0, J.useState )( e ); + return ( + Mu( () => { + e || t || n( `id-${ Math.random().toString( 36 ).slice( 2, 8 ) }` ); + }, [ e, t ] ), + e || t + ); + } + function Ru( e, t ) { + const n = ( 0, J.useRef )( ! 1 ); + ( 0, J.useEffect )( () => { + if ( n.current ) return e(); + n.current = ! 0; + }, t ), + ( 0, J.useEffect )( + () => () => { + n.current = ! 1; + }, + [] + ); + } + function Fu( e ) { + return Tu( 'function' == typeof e ? e : () => e ); + } + function Lu( e, t, n = [] ) { + const i = ( 0, J.useCallback )( + n => ( e.wrapElement && ( n = e.wrapElement( n ) ), t( n ) ), + [ ...n, e.wrapElement ] + ); + return { ...e, wrapElement: i }; + } + function Du( e, t, n ) { + const i = e.onLoadedMetadataCapture, + r = ( 0, J.useMemo )( + () => + Object.assign( + () => {}, + i, + ...( void 0 !== n ? [ { [ t ]: n } ] : [] ) + ), + [ i, t, n ] + ); + return [ i?.[ t ], { onLoadedMetadataCapture: r } ]; + } + let Bu = ! 1, + zu = ! 1, + Wu = 0, + $u = 0; + function Hu( e ) { + ( function ( e ) { + const t = e.movementX || e.screenX - Wu, + n = e.movementY || e.screenY - $u; + return ( Wu = e.screenX ), ( $u = e.screenY ), t || n || ! 1; + } )( e ) && ( zu = ! 0 ); + } + function qu() { + zu = ! 1; + } + function Gu( e ) { + const t = J.forwardRef( ( t, n ) => e( { ...t, ref: n } ) ); + return ( t.displayName = e.displayName || e.name ), t; + } + function Yu( e, t ) { + return J.memo( e, t ); + } + function Ku( e, t ) { + const { wrapElement: n, render: i, ...r } = t, + o = Nu( + t.ref, + ( function ( e ) { + return ( function ( e ) { + return ( + !! e && + !! ( 0, J.isValidElement )( e ) && + ( 'ref' in e.props || 'ref' in e ) + ); + } )( e ) + ? { ...e.props }.ref || e.ref + : null; + } )( i ) + ); + let s; + if ( J.isValidElement( i ) ) { + const e = { ...i.props, ref: o }; + s = J.cloneElement( + i, + ( function ( e, t ) { + const n = { ...e }; + for ( const i in t ) { + if ( ! yu( t, i ) ) continue; + if ( 'className' === i ) { + const i = 'className', + r = e[ i ], + o = t[ i ]; + n[ i ] = r && o ? `${ r } ${ o }` : o || r; + continue; + } + if ( 'style' === i ) { + const i = 'style'; + n[ i ] = e[ i ] ? { ...e[ i ], ...t[ i ] } : t[ i ]; + continue; + } + const r = t[ i ]; + if ( i.startsWith( 'on' ) ) { + if ( 'function' != typeof r ) continue; + const t = e[ i ]; + if ( 'function' == typeof t ) { + n[ i ] = ( ...e ) => { + r( ...e ), t( ...e ); + }; + continue; + } + } + n[ i ] = r; + } + return n; + } )( r, e ) + ); + } else s = i ? i( r ) : ( 0, c.jsx )( e, { ...r } ); + return n ? n( s ) : s; + } + function Uu( e ) { + const t = ( t = {} ) => e( t ); + return ( t.displayName = e.name ), t; + } + function Xu( e = [], t = [] ) { + const n = J.createContext( void 0 ), + i = J.createContext( void 0 ), + r = () => J.useContext( n ), + o = t => + e.reduceRight( + ( e, n ) => ( 0, c.jsx )( n, { ...t, children: e } ), + ( 0, c.jsx )( n.Provider, { ...t } ) + ); + return { + context: n, + scopedContext: i, + useContext: r, + useScopedContext: ( e = ! 1 ) => { + const t = J.useContext( i ), + n = r(); + return e ? t : t || n; + }, + useProviderContext: () => { + const e = J.useContext( i ), + t = r(); + if ( ! e || e !== t ) return t; + }, + ContextProvider: o, + ScopedContextProvider: e => + ( 0, c.jsx )( o, { + ...e, + children: t.reduceRight( + ( t, n ) => ( 0, c.jsx )( n, { ...e, children: t } ), + ( 0, c.jsx )( i.Provider, { ...e } ) + ), + } ), + }; + } + const Zu = Xu(), + Qu = Zu.useContext, + Ju = + ( Zu.useScopedContext, + Zu.useProviderContext, + Xu( [ Zu.ContextProvider ], [ Zu.ScopedContextProvider ] ) ), + ed = Ju.useContext, + td = ( Ju.useScopedContext, Ju.useProviderContext ), + nd = Ju.ContextProvider, + id = Ju.ScopedContextProvider, + rd = ( 0, J.createContext )( void 0 ), + od = ( 0, J.createContext )( void 0 ), + sd = Xu(), + ad = ( sd.useContext, sd.useScopedContext, sd.useProviderContext ), + ld = Xu( [ sd.ContextProvider ], [ sd.ScopedContextProvider ] ), + cd = + ( ld.useContext, + ld.useScopedContext, + ld.useProviderContext, + ld.ContextProvider ), + ud = ld.ScopedContextProvider, + dd = + ( ( 0, J.createContext )( void 0 ), + ( 0, J.createContext )( void 0 ), + Xu( [ cd ], [ ud ] ) ), + fd = ( dd.useContext, dd.useScopedContext, dd.useProviderContext ), + md = dd.ContextProvider, + pd = dd.ScopedContextProvider, + gd = ( 0, J.createContext )( void 0 ), + hd = Xu( [ md, nd ], [ pd, id ] ), + vd = hd.useContext, + bd = hd.useScopedContext, + wd = hd.useProviderContext, + yd = hd.ContextProvider, + xd = hd.ScopedContextProvider, + Cd = ( 0, J.createContext )( void 0 ), + Sd = ( 0, J.createContext )( ! 1 ); + function _d( e, t ) { + const n = e.__unstableInternals; + return _u( n, 'Invalid store' ), n[ t ]; + } + function jd( e, ...t ) { + let n = e, + i = n, + r = Symbol(), + o = wu; + const s = new Set(), + a = new Set(), + l = new Set(), + c = new Set(), + u = new Set(), + d = new WeakMap(), + f = new WeakMap(), + m = ( e, t, n = c ) => ( + n.add( t ), + f.set( t, e ), + () => { + d.get( t )?.(), d.delete( t ), f.delete( t ), n.delete( t ); + } + ), + p = ( e, o, s = ! 1 ) => { + if ( ! yu( n, e ) ) return; + const l = + ( ( m = o ), + ( p = n[ e ] ), + ( function ( e ) { + return 'function' == typeof e; + } )( m ) + ? m( 'function' == typeof p ? p() : p ) + : m ); + var m, p; + if ( l === n[ e ] ) return; + if ( ! s ) for ( const n of t ) n?.setState?.( e, l ); + const g = n; + n = { ...n, [ e ]: l }; + const h = Symbol(); + ( r = h ), a.add( e ); + const v = ( t, i, r ) => { + const o = f.get( t ); + ( o && ! o.some( t => ( r ? r.has( t ) : t === e ) ) ) || + ( d.get( t )?.(), d.set( t, t( n, i ) ) ); + }; + for ( const e of c ) v( e, g ); + queueMicrotask( () => { + if ( r !== h ) return; + const e = n; + for ( const e of u ) v( e, i, a ); + ( i = e ), a.clear(); + } ); + }, + g = { + getState: () => n, + setState: p, + __unstableInternals: { + setup: e => ( l.add( e ), () => l.delete( e ) ), + init: () => { + const e = s.size, + i = Symbol(); + s.add( i ); + const r = () => { + s.delete( i ), s.size || o(); + }; + if ( e ) return r; + const a = ( ( c = n ), Object.keys( c ) ).map( e => + xu( + ...t.map( t => { + const n = t?.getState?.(); + if ( n && yu( n, e ) ) + return Vd( t, [ e ], t => { + p( e, t[ e ], ! 0 ); + } ); + } ) + ) + ); + var c; + const u = []; + for ( const e of l ) u.push( e() ); + const d = t.map( kd ); + return ( o = xu( ...a, ...u, ...d ) ), r; + }, + subscribe: ( e, t ) => m( e, t ), + sync: ( e, t ) => ( d.set( t, t( n, n ) ), m( e, t ) ), + batch: ( e, t ) => ( d.set( t, t( n, i ) ), m( e, t, u ) ), + pick: e => + jd( + ( function ( e, t ) { + const n = {}; + for ( const i of t ) yu( e, i ) && ( n[ i ] = e[ i ] ); + return n; + } )( n, e ), + g + ), + omit: e => + jd( + ( function ( e, t ) { + const n = { ...e }; + for ( const e of t ) yu( n, e ) && delete n[ e ]; + return n; + } )( n, e ), + g + ), + }, + }; + return g; + } + function Ed( e, ...t ) { + if ( e ) return _d( e, 'setup' )( ...t ); + } + function kd( e, ...t ) { + if ( e ) return _d( e, 'init' )( ...t ); + } + function Id( e, ...t ) { + if ( e ) return _d( e, 'subscribe' )( ...t ); + } + function Vd( e, ...t ) { + if ( e ) return _d( e, 'sync' )( ...t ); + } + function Od( e, ...t ) { + if ( e ) return _d( e, 'batch' )( ...t ); + } + function Pd( e, ...t ) { + if ( e ) return _d( e, 'omit' )( ...t ); + } + function Md( ...e ) { + const t = {}; + for ( const n of e ) { + const e = n?.getState?.(); + e && Object.assign( t, e ); + } + const n = jd( t, ...e ); + return Object.assign( {}, ...e, n ); + } + function Td( e, t ) { + if ( ! t ) return; + const n = Object.entries( e ) + .filter( ( [ e, t ] ) => e.startsWith( 'default' ) && void 0 !== t ) + .map( ( [ e ] ) => { + const t = e.replace( 'default', '' ); + return `${ t[ 0 ]?.toLowerCase() || '' }${ t.slice( 1 ) }`; + } ); + if ( ! n.length ) return; + const i = t.getState(); + if ( n.filter( e => yu( i, e ) ).length ) + throw new Error( + 'Passing a store prop in conjunction with a default state is not supported.\n\nconst store = useSelectStore();\n\n ^ ^\n\nInstead, pass the default state to the topmost store:\n\nconst store = useSelectStore({ defaultValue: "Apple" });\n\n\nSee https://github.com/ariakit/ariakit/pull/2745 for more details.\n\nIf there\'s a particular need for this, please submit a feature request at https://github.com/ariakit/ariakit\n' + ); + } + function Nd( e, t = Su ) { + const n = J.useCallback( t => ( e ? Id( e, null, t ) : () => {} ), [ e ] ), + i = () => { + const n = 'string' == typeof t ? t : null, + i = 'function' == typeof t ? t : null, + r = e?.getState(); + return i ? i( r ) : r && n && yu( r, n ) ? r[ n ] : void 0; + }; + return ( 0, fs.useSyncExternalStore )( n, i, i ); + } + function Ad( e, t ) { + const n = J.useRef( {} ), + i = J.useCallback( t => ( e ? Id( e, null, t ) : () => {} ), [ e ] ), + r = () => { + const i = e?.getState(); + let r = ! 1; + const o = n.current; + for ( const e in t ) { + const n = t[ e ]; + if ( 'function' == typeof n ) { + const t = n( i ); + t !== o[ e ] && ( ( o[ e ] = t ), ( r = ! 0 ) ); + } + if ( 'string' == typeof n ) { + if ( ! i ) continue; + if ( ! yu( i, n ) ) continue; + const t = i[ n ]; + t !== o[ e ] && ( ( o[ e ] = t ), ( r = ! 0 ) ); + } + } + return r && ( n.current = { ...o } ), n.current; + }; + return ( 0, fs.useSyncExternalStore )( i, r, r ); + } + function Rd( e, t, n, i ) { + const r = yu( t, n ) ? t[ n ] : void 0, + o = ( function ( e ) { + const t = ( 0, J.useRef )( e ); + return ( + Mu( () => { + t.current = e; + } ), + t + ); + } )( { value: r, setValue: i ? t[ i ] : void 0 } ); + Mu( + () => + Vd( e, [ n ], ( e, t ) => { + const { value: i, setValue: r } = o.current; + r && e[ n ] !== t[ n ] && e[ n ] !== i && r( e[ n ] ); + } ), + [ e, n ] + ), + Mu( () => { + if ( void 0 !== r ) + return ( + e.setState( n, r ), + Od( e, [ n ], () => { + void 0 !== r && e.setState( n, r ); + } ) + ); + } ); + } + function Fd( e, t, n ) { + return ( + Rd( + ( e = ( function ( e, t, n ) { + return Ru( t, [ n.store ] ), Rd( e, n, 'items', 'setItems' ), e; + } )( e, t, n ) ), + n, + 'activeId', + 'setActiveId' + ), + Rd( e, n, 'includesBaseElement' ), + Rd( e, n, 'virtualFocus' ), + Rd( e, n, 'orientation' ), + Rd( e, n, 'rtl' ), + Rd( e, n, 'focusLoop' ), + Rd( e, n, 'focusWrap' ), + Rd( e, n, 'focusShift' ), + e + ); + } + function Ld( e, t, n ) { + return ( function ( e, t, n ) { + return ( + Ru( t, [ n.store, n.disclosure ] ), + Rd( e, n, 'open', 'setOpen' ), + Rd( e, n, 'mounted', 'setMounted' ), + Rd( e, n, 'animated' ), + Object.assign( e, { disclosure: n.disclosure } ) + ); + } )( e, t, n ); + } + ( 0, J.createContext )( null ), ( 0, J.createContext )( null ); + const Dd = Xu( [ nd ], [ id ] ), + Bd = Dd.useContext; + function zd( e = {} ) { + Td( e, e.store ); + const t = e.store?.getState(), + n = ku( e.items, t?.items, e.defaultItems, [] ), + i = new Map( n.map( e => [ e.id, e ] ) ), + r = { items: n, renderedItems: ku( t?.renderedItems, [] ) }, + o = ( ( s = e.store ), s?.__unstablePrivateStore ); + var s; + const a = jd( { items: n, renderedItems: r.renderedItems }, o ), + l = jd( r, e.store ), + c = e => { + const t = ( function ( e, t ) { + const n = e.map( ( e, t ) => [ t, e ] ); + let i = ! 1; + return ( + n.sort( ( [ e, n ], [ r, o ] ) => { + const s = t( n ), + a = t( o ); + return s === a + ? 0 + : s && a + ? ( function ( e, t ) { + return Boolean( + t.compareDocumentPosition( e ) & + Node.DOCUMENT_POSITION_PRECEDING + ); + } )( s, a ) + ? ( e > r && ( i = ! 0 ), -1 ) + : ( e < r && ( i = ! 0 ), 1 ) + : 0; + } ), + i ? n.map( ( [ e, t ] ) => t ) : e + ); + } )( e, e => e.element ); + a.setState( 'renderedItems', t ), l.setState( 'renderedItems', t ); + }; + Ed( l, () => kd( a ) ), + Ed( a, () => + Od( a, [ 'items' ], e => { + l.setState( 'items', e.items ); + } ) + ), + Ed( a, () => + Od( a, [ 'renderedItems' ], e => { + let t = ! 0, + n = requestAnimationFrame( () => { + const { renderedItems: t } = l.getState(); + e.renderedItems !== t && c( e.renderedItems ); + } ); + if ( 'function' != typeof IntersectionObserver ) + return () => cancelAnimationFrame( n ); + const i = ( function ( e ) { + const t = e.find( e => !! e.element ), + n = [ ...e ].reverse().find( e => !! e.element )?.element; + let i = t?.element?.parentElement; + if ( ! n ) return Qc( i ).body; + for ( ; i; ) { + if ( i.contains( n ) ) return i; + i = i.parentElement; + } + return Qc( i ).body; + } )( e.renderedItems ), + r = new IntersectionObserver( + () => { + t + ? ( t = ! 1 ) + : ( cancelAnimationFrame( n ), + ( n = requestAnimationFrame( () => + c( e.renderedItems ) + ) ) ); + }, + { root: i } + ); + for ( const t of e.renderedItems ) t.element && r.observe( t.element ); + return () => { + cancelAnimationFrame( n ), r.disconnect(); + }; + } ) + ); + const u = ( e, t, n = ! 1 ) => { + let r; + return ( + t( t => { + const n = t.findIndex( ( { id: t } ) => t === e.id ), + o = t.slice(); + if ( -1 !== n ) { + r = t[ n ]; + const s = { ...r, ...e }; + ( o[ n ] = s ), i.set( e.id, s ); + } else o.push( e ), i.set( e.id, e ); + return o; + } ), + () => { + t( t => { + if ( ! r ) + return ( + n && i.delete( e.id ), + t.filter( ( { id: t } ) => t !== e.id ) + ); + const o = t.findIndex( ( { id: t } ) => t === e.id ); + if ( -1 === o ) return t; + const s = t.slice(); + return ( s[ o ] = r ), i.set( e.id, r ), s; + } ); + } + ); + }, + d = e => u( e, e => a.setState( 'items', e ), ! 0 ); + return { + ...l, + registerItem: d, + renderItem: e => + xu( + d( e ), + u( e, e => a.setState( 'renderedItems', e ) ) + ), + item: e => { + if ( ! e ) return null; + let t = i.get( e ); + if ( ! t ) { + const { items: n } = a.getState(); + ( t = n.find( t => t.id === e ) ), t && i.set( e, t ); + } + return t || null; + }, + __unstablePrivateStore: a, + }; + } + Dd.useScopedContext, + Dd.useProviderContext, + Dd.ContextProvider, + Dd.ScopedContextProvider; + const Wd = { id: null }; + function $d( e, t ) { + return e.find( e => ( t ? ! e.disabled && e.id !== t : ! e.disabled ) ); + } + function Hd( e, t ) { + return e.filter( e => e.rowId === t ); + } + function qd( e ) { + const t = []; + for ( const n of e ) { + const e = t.find( e => e[ 0 ]?.rowId === n.rowId ); + e ? e.push( n ) : t.push( [ n ] ); + } + return t; + } + function Gd( e ) { + let t = 0; + for ( const { length: n } of e ) n > t && ( t = n ); + return t; + } + function Yd( e ) { + return { id: '__EMPTY_ITEM__', disabled: ! 0, rowId: e }; + } + const Kd = uu() && Zc && !! navigator.maxTouchPoints; + function Ud( { tag: e, ...t } = {} ) { + const n = Md( + t.store, + ( function ( e, ...t ) { + if ( e ) return _d( e, 'pick' )( ...t ); + } )( e, [ 'value', 'rtl' ] ) + ); + Td( t, n ); + const i = e?.getState(), + r = n?.getState(), + o = ku( t.activeId, r?.activeId, t.defaultActiveId, null ), + s = ( function ( e = {} ) { + const t = e.store?.getState(), + n = zd( e ), + i = ku( e.activeId, t?.activeId, e.defaultActiveId ), + r = jd( + { + ...n.getState(), + id: + ku( e.id, t?.id ) ?? + `id-${ Math.random().toString( 36 ).slice( 2, 8 ) }`, + activeId: i, + baseElement: ku( t?.baseElement, null ), + includesBaseElement: ku( + e.includesBaseElement, + t?.includesBaseElement, + null === i + ), + moves: ku( t?.moves, 0 ), + orientation: ku( e.orientation, t?.orientation, 'both' ), + rtl: ku( e.rtl, t?.rtl, ! 1 ), + virtualFocus: ku( e.virtualFocus, t?.virtualFocus, ! 1 ), + focusLoop: ku( e.focusLoop, t?.focusLoop, ! 1 ), + focusWrap: ku( e.focusWrap, t?.focusWrap, ! 1 ), + focusShift: ku( e.focusShift, t?.focusShift, ! 1 ), + }, + n, + e.store + ); + Ed( r, () => + Vd( r, [ 'renderedItems', 'activeId' ], e => { + r.setState( 'activeId', t => + void 0 !== t ? t : $d( e.renderedItems )?.id + ); + } ) + ); + const o = ( e = 'next', t = {} ) => { + const n = r.getState(), + { + skip: i = 0, + activeId: o = n.activeId, + focusShift: s = n.focusShift, + focusLoop: a = n.focusLoop, + focusWrap: l = n.focusWrap, + includesBaseElement: c = n.includesBaseElement, + renderedItems: u = n.renderedItems, + rtl: d = n.rtl, + } = t, + f = 'up' === e || 'down' === e, + m = 'next' === e || 'down' === e, + p = m ? d && ! f : ! d || f, + g = s && ! i; + let h = f + ? Uc( + ( function ( e, t, n ) { + const i = Gd( e ); + for ( const r of e ) + for ( let e = 0; e < i; e += 1 ) { + const i = r[ e ]; + if ( ! i || ( n && i.disabled ) ) { + const i = + 0 === e && n ? $d( r ) : r[ e - 1 ]; + r[ e ] = + i && t !== i.id && n + ? i + : Yd( i?.rowId ); + } + } + return e; + } )( qd( u ), o, g ) + ) + : u; + if ( + ( ( h = p ? Xc( h ) : h ), + ( h = f + ? ( function ( e ) { + const t = qd( e ), + n = Gd( t ), + i = []; + for ( let e = 0; e < n; e += 1 ) + for ( const n of t ) { + const t = n[ e ]; + t && + i.push( { + ...t, + rowId: t.rowId ? `${ e }` : void 0, + } ); + } + return i; + } )( h ) + : h ), + null == o ) + ) + return $d( h )?.id; + const v = h.find( e => e.id === o ); + if ( ! v ) return $d( h )?.id; + const b = h.some( e => e.rowId ), + w = h.indexOf( v ), + y = h.slice( w + 1 ), + x = Hd( y, v.rowId ); + if ( i ) { + const e = ( function ( e, t ) { + return e.filter( e => + t ? ! e.disabled && e.id !== t : ! e.disabled + ); + } )( x, o ); + return ( e.slice( i )[ 0 ] || e[ e.length - 1 ] )?.id; + } + const C = a && ( f ? 'horizontal' !== a : 'vertical' !== a ), + S = b && l && ( f ? 'horizontal' !== l : 'vertical' !== l ), + _ = m ? ( ! b || f ) && C && c : !! f && c; + if ( C ) + return $d( + ( function ( e, t, n = ! 1 ) { + const i = e.findIndex( e => e.id === t ); + return [ + ...e.slice( i + 1 ), + ...( n ? [ Wd ] : [] ), + ...e.slice( 0, i ), + ]; + } )( S && ! _ ? h : Hd( h, v.rowId ), o, _ ), + o + )?.id; + if ( S ) { + const e = $d( _ ? x : y, o ); + return _ ? e?.id || null : e?.id; + } + const j = $d( x, o ); + return ! j && _ ? null : j?.id; + }; + return { + ...n, + ...r, + setBaseElement: e => r.setState( 'baseElement', e ), + setActiveId: e => r.setState( 'activeId', e ), + move: e => { + void 0 !== e && + ( r.setState( 'activeId', e ), + r.setState( 'moves', e => e + 1 ) ); + }, + first: () => $d( r.getState().renderedItems )?.id, + last: () => $d( Xc( r.getState().renderedItems ) )?.id, + next: e => ( + void 0 !== e && 'number' == typeof e && ( e = { skip: e } ), + o( 'next', e ) + ), + previous: e => ( + void 0 !== e && 'number' == typeof e && ( e = { skip: e } ), + o( 'previous', e ) + ), + down: e => ( + void 0 !== e && 'number' == typeof e && ( e = { skip: e } ), + o( 'down', e ) + ), + up: e => ( + void 0 !== e && 'number' == typeof e && ( e = { skip: e } ), + o( 'up', e ) + ), + }; + } )( { + ...t, + activeId: o, + includesBaseElement: ku( + t.includesBaseElement, + r?.includesBaseElement, + ! 0 + ), + orientation: ku( t.orientation, r?.orientation, 'vertical' ), + focusLoop: ku( t.focusLoop, r?.focusLoop, ! 0 ), + focusWrap: ku( t.focusWrap, r?.focusWrap, ! 0 ), + virtualFocus: ku( t.virtualFocus, r?.virtualFocus, ! 0 ), + } ), + a = ( function ( { popover: e, ...t } = {} ) { + const n = Md( + t.store, + Pd( e, [ + 'arrowElement', + 'anchorElement', + 'contentElement', + 'popoverElement', + 'disclosureElement', + ] ) + ); + Td( t, n ); + const i = n?.getState(), + r = ( function ( e = {} ) { + return ( function ( e = {} ) { + const t = Md( + e.store, + Pd( e.disclosure, [ + 'contentElement', + 'disclosureElement', + ] ) + ); + Td( e, t ); + const n = t?.getState(), + i = ku( e.open, n?.open, e.defaultOpen, ! 1 ), + r = ku( e.animated, n?.animated, ! 1 ), + o = jd( + { + open: i, + animated: r, + animating: !! r && i, + mounted: i, + contentElement: ku( n?.contentElement, null ), + disclosureElement: ku( n?.disclosureElement, null ), + }, + t + ); + return ( + Ed( o, () => + Vd( o, [ 'animated', 'animating' ], e => { + e.animated || o.setState( 'animating', ! 1 ); + } ) + ), + Ed( o, () => + Id( o, [ 'open' ], () => { + o.getState().animated && + o.setState( 'animating', ! 0 ); + } ) + ), + Ed( o, () => + Vd( o, [ 'open', 'animating' ], e => { + o.setState( 'mounted', e.open || e.animating ); + } ) + ), + { + ...o, + disclosure: e.disclosure, + setOpen: e => o.setState( 'open', e ), + show: () => o.setState( 'open', ! 0 ), + hide: () => o.setState( 'open', ! 1 ), + toggle: () => o.setState( 'open', e => ! e ), + stopAnimation: () => o.setState( 'animating', ! 1 ), + setContentElement: e => + o.setState( 'contentElement', e ), + setDisclosureElement: e => + o.setState( 'disclosureElement', e ), + } + ); + } )( e ); + } )( { ...t, store: n } ), + o = ku( t.placement, i?.placement, 'bottom' ), + s = jd( + { + ...r.getState(), + placement: o, + currentPlacement: o, + anchorElement: ku( i?.anchorElement, null ), + popoverElement: ku( i?.popoverElement, null ), + arrowElement: ku( i?.arrowElement, null ), + rendered: Symbol( 'rendered' ), + }, + r, + n + ); + return { + ...r, + ...s, + setAnchorElement: e => s.setState( 'anchorElement', e ), + setPopoverElement: e => s.setState( 'popoverElement', e ), + setArrowElement: e => s.setState( 'arrowElement', e ), + render: () => s.setState( 'rendered', Symbol( 'rendered' ) ), + }; + } )( { ...t, placement: ku( t.placement, r?.placement, 'bottom-start' ) } ), + l = ku( t.value, r?.value, t.defaultValue, '' ), + c = ku( + t.selectedValue, + r?.selectedValue, + i?.values, + t.defaultSelectedValue, + '' + ), + u = Array.isArray( c ), + d = { + ...s.getState(), + ...a.getState(), + value: l, + selectedValue: c, + resetValueOnSelect: ku( t.resetValueOnSelect, r?.resetValueOnSelect, u ), + resetValueOnHide: ku( t.resetValueOnHide, r?.resetValueOnHide, u && ! e ), + activeValue: r?.activeValue, + }, + f = jd( d, s, a, n ); + return ( + Kd && + Ed( f, () => + Vd( f, [ 'virtualFocus' ], () => { + f.setState( 'virtualFocus', ! 1 ); + } ) + ), + Ed( f, () => { + if ( e ) + return xu( + Vd( f, [ 'selectedValue' ], t => { + Array.isArray( t.selectedValue ) && + e.setValues( t.selectedValue ); + } ), + Vd( e, [ 'values' ], e => { + f.setState( 'selectedValue', e.values ); + } ) + ); + } ), + Ed( f, () => + Vd( f, [ 'resetValueOnHide', 'mounted' ], e => { + e.resetValueOnHide && ( e.mounted || f.setState( 'value', l ) ); + } ) + ), + Ed( f, () => + Vd( f, [ 'open' ], e => { + e.open || ( f.setState( 'activeId', o ), f.setState( 'moves', 0 ) ); + } ) + ), + Ed( f, () => + Vd( f, [ 'moves', 'activeId' ], ( e, t ) => { + e.moves === t.moves && f.setState( 'activeValue', void 0 ); + } ) + ), + Ed( f, () => + Od( f, [ 'moves', 'renderedItems' ], ( e, t ) => { + if ( e.moves === t.moves ) return; + const { activeId: n } = f.getState(), + i = s.item( n ); + f.setState( 'activeValue', i?.value ); + } ) + ), + { + ...a, + ...s, + ...f, + tag: e, + setValue: e => f.setState( 'value', e ), + resetValue: () => f.setState( 'value', d.value ), + setSelectedValue: e => f.setState( 'selectedValue', e ), + } + ); + } + function Xd( e = {} ) { + e = ( function ( e ) { + const t = Bd(); + return ( function ( e ) { + return { id: Au( e.id ), ...e }; + } )( ( e = { ...e, tag: void 0 !== e.tag ? e.tag : t } ) ); + } )( e ); + const [ t, n ] = ( function ( e, t ) { + const [ n, i ] = J.useState( () => e( t ) ); + Mu( () => kd( n ), [ n ] ); + const r = J.useCallback( e => Nd( n, e ), [ n ] ); + return [ + J.useMemo( () => ( { ...n, useState: r } ), [ n, r ] ), + Tu( () => { + i( n => e( { ...t, ...n.getState() } ) ); + } ), + ]; + } )( Ud, e ); + return ( function ( e, t, n ) { + return ( + Ru( t, [ n.tag ] ), + Rd( e, n, 'value', 'setValue' ), + Rd( e, n, 'selectedValue', 'setSelectedValue' ), + Rd( e, n, 'resetValueOnHide' ), + Rd( e, n, 'resetValueOnSelect' ), + Object.assign( + Fd( + ( function ( e, t, n ) { + return ( + Ru( t, [ n.popover ] ), + Rd( e, n, 'placement' ), + Ld( e, t, n ) + ); + } )( e, t, n ), + t, + n + ), + { tag: n.tag } + ) + ); + } )( t, n, e ); + } + function Zd( e = {} ) { + return ( 0, c.jsx )( yd, { value: Xd( e ), children: e.children } ); + } + const Qd = Uu( function ( { store: e, ...t } ) { + const n = wd(); + return ( + _u( + ( e = e || n ), + 'ComboboxLabel must receive a `store` prop or be wrapped in a ComboboxProvider component.' + ), + Eu( ( t = { htmlFor: Nd( e, e => e.baseElement?.id ), ...t } ) ) + ); + } ), + Jd = Yu( + Gu( function ( e ) { + return Ku( 'label', Qd( e ) ); + } ) + ), + ef = ( 0, J.createContext )( ! 0 ), + tf = Symbol( 'accessibleWhenDisabled' ), + nf = uu(), + rf = [ + 'text', + 'search', + 'url', + 'tel', + 'email', + 'password', + 'number', + 'date', + 'month', + 'week', + 'time', + 'datetime', + 'datetime-local', + ], + of = [ 'button', 'color', 'file', 'image', 'reset', 'submit' ]; + function sf( { + focusable: e, + trulyDisabled: t, + nativeTabbable: n, + supportsDisabled: i, + safariTabIndex: r, + tabIndexProp: o, + } ) { + return e + ? t + ? n && ! i + ? -1 + : void 0 + : n + ? r && null == o + ? 0 + : o + : o ?? 0 + : o; + } + function af( e, t ) { + return Tu( n => { + e?.( n ), + n.defaultPrevented || ( t && ( n.stopPropagation(), n.preventDefault() ) ); + } ); + } + let lf = ! 1, + cf = ! 0; + function uf( e ) { + const t = e.target; + t && + 'hasAttribute' in t && + ( t.hasAttribute( 'data-focus-visible' ) || ( cf = ! 1 ) ); + } + function df( e ) { + e.metaKey || e.ctrlKey || e.altKey || ( cf = ! 0 ); + } + const ff = Uu( function ( { + focusable: e = ! 0, + accessibleWhenDisabled: t, + autoFocus: n, + onFocusVisible: i, + ...r + } ) { + const o = ( 0, J.useRef )( null ), + [ s, a ] = Du( r, tf, t ); + ( t ??= s ), + ( 0, J.useEffect )( () => { + e && + ( lf || + ( hu( 'mousedown', uf, ! 0 ), + hu( 'keydown', df, ! 0 ), + ( lf = ! 0 ) ) ); + }, [ e ] ); + const l = e && ju( r ), + c = l && ! t, + [ u, d ] = ( 0, J.useState )( ! 1 ); + ( 0, J.useEffect )( () => { + e && c && u && d( ! 1 ); + }, [ e, c, u ] ), + ( 0, J.useEffect )( () => { + if ( ! e ) return; + if ( ! u ) return; + const t = o.current; + if ( ! t ) return; + if ( 'undefined' == typeof IntersectionObserver ) return; + const n = new IntersectionObserver( () => { + vu( t ) || d( ! 1 ); + } ); + return n.observe( t ), () => n.disconnect(); + }, [ e, u ] ); + const f = af( r.onKeyPressCapture, l ), + m = af( r.onMouseDownCapture, l ), + p = af( r.onClickCapture, l ), + g = ( t, n ) => { + if ( ( n && ( t.currentTarget = n ), ! e ) ) return; + const r = t.currentTarget; + r && + bu( r ) && + ( i?.( t ), + t.defaultPrevented || + ( ( r.dataset.focusVisible = 'true' ), d( ! 0 ) ) ); + }, + h = r.onKeyDownCapture, + v = Tu( t => { + if ( ( h?.( t ), t.defaultPrevented ) ) return; + if ( ! e ) return; + if ( u ) return; + if ( t.metaKey ) return; + if ( t.altKey ) return; + if ( t.ctrlKey ) return; + if ( ! du( t ) ) return; + const n = t.currentTarget; + gu( n, 'focusout', () => g( t, n ) ); + } ), + b = r.onFocusCapture, + w = Tu( t => { + if ( ( b?.( t ), t.defaultPrevented ) ) return; + if ( ! e ) return; + if ( ! du( t ) ) return void d( ! 1 ); + const n = t.currentTarget; + cf || + ( function ( e ) { + const { tagName: t, readOnly: n, type: i } = e; + return ( + ( 'TEXTAREA' === t && ! n ) || + ( 'SELECT' === t && ! n ) || + ( 'INPUT' !== t || n + ? !! e.isContentEditable || + ! ( + 'combobox' !== e.getAttribute( 'role' ) || + ! e.dataset.name + ) + : rf.includes( i ) ) + ); + } )( t.target ) + ? gu( t.target, 'focusout', () => g( t, n ) ) + : d( ! 1 ); + } ), + y = r.onBlur, + x = Tu( t => { + y?.( t ), + e && + pu( t ) && + ( t.currentTarget.removeAttribute( 'data-focus-visible' ), + d( ! 1 ) ); + } ), + C = ( 0, J.useContext )( ef ), + S = Tu( t => { + e && + n && + t && + C && + queueMicrotask( () => { + bu( t ) || ( vu( t ) && t.focus() ); + } ); + } ), + _ = ( function ( e, t ) { + const n = e => { + if ( 'string' == typeof e ) return e; + }, + [ i, r ] = ( 0, J.useState )( () => n( t ) ); + return ( + Mu( () => { + r( + ( e && 'current' in e + ? e.current + : e + )?.tagName.toLowerCase() || n( t ) + ); + }, [ e, t ] ), + i + ); + } )( o ), + j = + e && + ( function ( e ) { + return ( + ! e || + 'button' === e || + 'summary' === e || + 'input' === e || + 'select' === e || + 'textarea' === e || + 'a' === e + ); + } )( _ ), + E = + e && + ( function ( e ) { + return ( + ! e || + 'button' === e || + 'input' === e || + 'select' === e || + 'textarea' === e + ); + } )( _ ), + [ k, I ] = ( 0, J.useState )( ! 1 ); + nf && + ( 0, J.useEffect )( () => { + if ( ! e ) return; + const t = o.current; + if ( ! t ) return; + const n = t.tagName.toLowerCase(), + i = t.type; + I( + ( function ( e, t ) { + return ( + 'button' === e || + ( ! ( 'input' !== e || ! t ) && + ( 'checkbox' === t || 'radio' === t || of.includes( t ) ) ) + ); + } )( n, i ) + ); + }, [ e ] ); + const V = r.style, + O = ( 0, J.useMemo )( + () => ( c ? { pointerEvents: 'none', ...V } : V ), + [ c, V ] + ); + return Eu( + ( r = { + 'data-focus-visible': ( e && u ) || void 0, + 'data-autofocus': n || void 0, + 'aria-disabled': l || void 0, + ...r, + ...a, + ref: Nu( o, S, r.ref ), + style: O, + tabIndex: sf( { + focusable: e, + trulyDisabled: c, + nativeTabbable: j, + supportsDisabled: E, + safariTabIndex: k, + tabIndexProp: r.tabIndex, + } ), + disabled: ! ( ! E || ! c ) || void 0, + contentEditable: l ? void 0 : r.contentEditable, + onKeyPressCapture: f, + onClickCapture: p, + onMouseDownCapture: m, + onKeyDownCapture: v, + onFocusCapture: w, + onBlur: x, + } ) + ); + } ); + function mf( e, t ) { + return ( t && e.item( t ) ) || null; + } + Gu( function ( e ) { + return Ku( 'div', ff( e ) ); + } ); + const pf = Symbol( 'FOCUS_SILENTLY' ); + function gf( e, t, n ) { + if ( ! t ) return ! 1; + if ( t === n ) return ! 1; + const i = e.item( t.id ); + return ! ( ! i || ( n && i.element === n ) ); + } + function hf( e, t, n ) { + return Tu( i => { + if ( ( t?.( i ), i.defaultPrevented ) ) return; + if ( i.isPropagationStopped() ) return; + if ( ! du( i ) ) return; + if ( + ( function ( e ) { + return ( + 'Shift' === e.key || + 'Control' === e.key || + 'Alt' === e.key || + 'Meta' === e.key + ); + } )( i ) + ) + return; + if ( + ( function ( e ) { + const t = e.target; + return ! ( + ( t && ! iu( t ) ) || + 1 !== e.key.length || + e.ctrlKey || + e.metaKey + ); + } )( i ) + ) + return; + const r = mf( e, e.getState().activeId )?.element; + if ( ! r ) return; + const { view: o, ...s } = i; + r !== n?.current && r.focus(), + ( function ( e, t, n ) { + const i = new KeyboardEvent( t, n ); + return e.dispatchEvent( i ); + } )( r, i.type, s ) || i.preventDefault(), + i.currentTarget.contains( r ) && i.stopPropagation(); + } ); + } + function vf( e, t ) { + const { virtualFocus: n, baseElement: i } = e.getState(); + if ( ! n || ! i || ! iu( i ) ) return void t(); + const r = i.scrollLeft, + o = i.scrollTop; + t(), ( i.scrollLeft = r ), ( i.scrollTop = o ); + } + const bf = Uu( function ( { + store: e, + composite: t = ! 0, + focusOnMove: n = t, + moveOnKeyPress: i = ! 0, + ...r + } ) { + const o = td(); + _u( + ( e = e || o ), + 'Composite must receive a `store` prop or be wrapped in a CompositeProvider component.' + ); + const s = ( 0, J.useRef )( null ), + a = ( 0, J.useRef )( null ), + l = ( function ( e ) { + const [ t, n ] = ( 0, J.useState )( ! 1 ), + i = ( 0, J.useCallback )( () => n( ! 0 ), [] ), + r = Nd( e, t => mf( e, t.activeId ) ); + return ( + ( 0, J.useEffect )( () => { + const i = r?.element; + t && + i && + ( n( ! 1 ), + vf( e, () => { + i.focus( { preventScroll: ! 0 } ); + } ) ); + }, [ e, r, t ] ), + i + ); + } )( e ), + u = Nd( e, 'moves' ), + [ , d ] = ( function ( e ) { + const [ t, n ] = ( 0, J.useState )( null ); + return ( + Mu( () => { + if ( null == t ) return; + if ( ! e ) return; + let n = null; + return ( + e( e => ( ( n = e ), t ) ), + () => { + e( n ); + } + ); + }, [ t, e ] ), + [ t, n ] + ); + } )( t ? e.setBaseElement : null ); + ( 0, J.useEffect )( () => { + if ( ! e ) return; + if ( ! u ) return; + if ( ! t ) return; + if ( ! n ) return; + const { activeId: i } = e.getState(), + r = mf( e, i )?.element; + r && + vf( e, () => { + var e; + 'scrollIntoView' in ( e = r ) + ? ( e.focus( { preventScroll: ! 0 } ), + e.scrollIntoView( { block: 'nearest', inline: 'nearest' } ) ) + : e.focus(); + } ); + }, [ e, u, t, n ] ), + Mu( () => { + if ( ! e ) return; + if ( ! u ) return; + if ( ! t ) return; + const { baseElement: n, activeId: i } = e.getState(); + if ( null !== i ) return; + if ( ! n ) return; + const r = a.current; + ( a.current = null ), + r && fu( r, { relatedTarget: n } ), + bu( n ) || n.focus(); + }, [ e, u, t ] ); + const f = Nd( e, 'activeId' ), + m = Nd( e, 'virtualFocus' ); + Mu( () => { + if ( ! e ) return; + if ( ! t ) return; + if ( ! m ) return; + const n = a.current; + if ( ( ( a.current = null ), ! n ) ) return; + const i = mf( e, f )?.element || Jc( n ); + i !== n && fu( n, { relatedTarget: i } ); + }, [ e, f, m, t ] ); + const p = hf( e, r.onKeyDownCapture, a ), + g = hf( e, r.onKeyUpCapture, a ), + h = r.onFocusCapture, + v = Tu( t => { + if ( ( h?.( t ), t.defaultPrevented ) ) return; + if ( ! e ) return; + const { virtualFocus: n } = e.getState(); + if ( ! n ) return; + const i = t.relatedTarget, + r = ( function ( e ) { + const t = e[ pf ]; + return delete e[ pf ], t; + } )( t.currentTarget ); + du( t ) && r && ( t.stopPropagation(), ( a.current = i ) ); + } ), + b = r.onFocus, + w = Tu( n => { + if ( ( b?.( n ), n.defaultPrevented ) ) return; + if ( ! t ) return; + if ( ! e ) return; + const { relatedTarget: i } = n, + { virtualFocus: r } = e.getState(); + r + ? du( n ) && ! gf( e, i ) && queueMicrotask( l ) + : du( n ) && e.setActiveId( null ); + } ), + y = r.onBlurCapture, + x = Tu( t => { + if ( ( y?.( t ), t.defaultPrevented ) ) return; + if ( ! e ) return; + const { virtualFocus: n, activeId: i } = e.getState(); + if ( ! n ) return; + const r = mf( e, i )?.element, + o = t.relatedTarget, + s = gf( e, o ), + l = a.current; + ( a.current = null ), + du( t ) && s + ? ( o === r + ? l && l !== o && fu( l, t ) + : r + ? fu( r, t ) + : l && fu( l, t ), + t.stopPropagation() ) + : ! gf( e, t.target ) && r && fu( r, t ); + } ), + C = r.onKeyDown, + S = Fu( i ), + _ = Tu( t => { + if ( ( C?.( t ), t.nativeEvent.isComposing ) ) return; + if ( t.defaultPrevented ) return; + if ( ! e ) return; + if ( ! du( t ) ) return; + const { orientation: n, renderedItems: i, activeId: r } = e.getState(); + if ( mf( e, r )?.element?.isConnected ) return; + const o = 'horizontal' !== n, + s = 'vertical' !== n, + a = i.some( e => !! e.rowId ); + if ( + ( 'ArrowLeft' === t.key || + 'ArrowRight' === t.key || + 'Home' === t.key || + 'End' === t.key ) && + iu( t.currentTarget ) + ) + return; + const l = { + ArrowUp: + ( a || o ) && + ( () => { + return a + ? ( ( t = i ), + ( function ( e ) { + return e.find( e => ! e.disabled ); + } )( + Uc( + Xc( + ( function ( e ) { + const t = []; + for ( const n of e ) { + const e = t.find( + e => + e[ 0 ]?.rowId === + n.rowId + ); + e + ? e.push( n ) + : t.push( [ n ] ); + } + return t; + } )( t ) + ) + ) + ) )?.id + : e?.last(); + var t; + } ), + ArrowRight: ( a || s ) && e.first, + ArrowDown: ( a || o ) && e.first, + ArrowLeft: ( a || s ) && e.last, + Home: e.first, + End: e.last, + PageUp: e.first, + PageDown: e.last, + }[ t.key ]; + if ( l ) { + const n = l(); + if ( void 0 !== n ) { + if ( ! S( t ) ) return; + t.preventDefault(), e.move( n ); + } + } + } ); + return ( + ( r = Lu( r, t => ( 0, c.jsx )( nd, { value: e, children: t } ), [ e ] ) ), + ( r = { + 'aria-activedescendant': Nd( e, n => { + if ( e && t && n.virtualFocus ) return mf( e, n.activeId )?.id; + } ), + ...r, + ref: Nu( s, d, r.ref ), + onKeyDownCapture: p, + onKeyUpCapture: g, + onFocusCapture: v, + onFocus: w, + onBlurCapture: x, + onKeyDown: _, + } ), + ff( { + focusable: Nd( e, e => t && ( e.virtualFocus || null === e.activeId ) ), + ...r, + } ) + ); + } ), + wf = + ( Gu( function ( e ) { + return Ku( 'div', bf( e ) ); + } ), + Uu( function ( { store: e, ...t } ) { + const n = fd(); + return ( e = e || n ), { ...t, ref: Nu( e?.setAnchorElement, t.ref ) }; + } ) ); + function yf( e, t, n ) { + return !! n && e.find( e => ! e.disabled && e.value )?.value === t; + } + function xf( e, t ) { + return ( + !! t && + null != e && + ( ( e = Cu( e ) ), + t.length > e.length && 0 === t.toLowerCase().indexOf( e.toLowerCase() ) ) + ); + } + Gu( function ( e ) { + return Ku( 'div', wf( e ) ); + } ); + const Cf = Uu( function ( { + store: e, + focusable: t = ! 0, + autoSelect: n = ! 1, + getAutoSelectId: i, + setValueOnChange: r, + showMinLength: o = 0, + showOnChange: s, + showOnMouseDown: a, + showOnClick: l = a, + showOnKeyDown: c, + showOnKeyPress: u = c, + blurActiveItemOnClick: d, + setValueOnClick: f = ! 0, + moveOnKeyPress: m = ! 0, + autoComplete: p = 'list', + ...g + } ) { + const h = wd(); + _u( + ( e = e || h ), + 'Combobox must receive a `store` prop or be wrapped in a ComboboxProvider component.' + ); + const v = ( 0, J.useRef )( null ), + [ b, w ] = ( 0, J.useReducer )( () => [], [] ), + y = ( 0, J.useRef )( ! 1 ), + x = ( 0, J.useRef )( ! 1 ), + C = Nd( e, e => e.virtualFocus && n ), + S = 'inline' === p || 'both' === p, + [ _, j ] = ( 0, J.useState )( S ); + ! ( function ( e, t ) { + const n = ( 0, J.useRef )( ! 1 ); + Mu( () => { + n.current ? S && j( ! 0 ) : ( n.current = ! 0 ); + }, t ), + Mu( + () => () => { + n.current = ! 1; + }, + [] + ); + } )( 0, [ S ] ); + const E = Nd( e, 'value' ), + k = ( 0, J.useRef )( void 0 ); + ( 0, J.useEffect )( + () => + Vd( e, [ 'selectedValue', 'activeId' ], ( e, t ) => { + k.current = t.selectedValue; + } ), + [ e ] + ); + const I = Nd( e, e => { + if ( S && _ ) { + if ( e.activeValue && Array.isArray( e.selectedValue ) ) { + if ( e.selectedValue.includes( e.activeValue ) ) return; + if ( k.current?.includes( e.activeValue ) ) return; + } + return e.activeValue; + } + } ), + V = Nd( e, 'renderedItems' ), + O = Nd( e, 'open' ), + P = Nd( e, 'contentElement' ), + M = ( 0, J.useMemo )( + () => + S && _ + ? yf( V, I, C ) + ? xf( E, I ) + ? E + ( I?.slice( E.length ) || '' ) + : E + : I || E + : E, + [ S, _, V, I, C, E ] + ); + ( 0, J.useEffect )( () => { + const e = v.current; + if ( ! e ) return; + const t = () => j( ! 0 ); + return ( + e.addEventListener( 'combobox-item-move', t ), + () => { + e.removeEventListener( 'combobox-item-move', t ); + } + ); + }, [] ), + ( 0, J.useEffect )( () => { + if ( ! S ) return; + if ( ! _ ) return; + if ( ! I ) return; + if ( ! yf( V, I, C ) ) return; + if ( ! xf( E, I ) ) return; + let e = wu; + return ( + queueMicrotask( () => { + const t = v.current; + if ( ! t ) return; + const { start: n, end: i } = ou( t ), + r = E.length, + o = I.length; + lu( t, r, o ), + ( e = () => { + if ( ! bu( t ) ) return; + const { start: e, end: s } = ou( t ); + e === r && s === o && lu( t, n, i ); + } ); + } ), + () => e() + ); + }, [ b, S, _, I, V, C, E ] ); + const T = ( 0, J.useRef )( null ), + N = Tu( i ), + A = ( 0, J.useRef )( null ), + R = ( 0, J.useRef )( ! 1 ), + F = ( 0, J.useRef )( ! 1 ); + ( 0, J.useEffect )( () => { + if ( ! O ) return; + if ( ! P ) return; + const t = au( P ); + if ( ! t ) return; + T.current = t; + const n = () => { + ( y.current = ! 1 ), ( R.current = ! 0 ); + }, + i = () => { + if ( ( F.current || ( R.current = ! 0 ), ! e ) ) return; + if ( ! y.current ) return; + const { activeId: t } = e.getState(); + null !== t && t !== A.current && ( y.current = ! 1 ); + }, + r = { passive: ! 0, capture: ! 0 }; + return ( + t.addEventListener( 'wheel', n, r ), + t.addEventListener( 'touchmove', n, r ), + t.addEventListener( 'scroll', i, r ), + () => { + t.removeEventListener( 'wheel', n, ! 0 ), + t.removeEventListener( 'touchmove', n, ! 0 ), + t.removeEventListener( 'scroll', i, ! 0 ); + } + ); + }, [ O, P, e ] ), + Mu( () => { + ( R.current = ! 1 ), E && ( x.current || ( y.current = ! 0 ) ); + }, [ E ] ), + Mu( () => { + ( 'always' !== C && O ) || ( y.current = O ); + }, [ C, O ] ); + const L = Nd( e, 'resetValueOnSelect' ); + Ru( () => { + const t = y.current; + if ( ! e ) return; + if ( ! O ) return; + if ( ! t && ( ! L || R.current ) ) return; + const { baseElement: n, contentElement: i, activeId: r } = e.getState(); + if ( ! n || bu( n ) ) { + if ( i?.hasAttribute( 'data-placing' ) ) { + const e = new MutationObserver( w ); + return ( + e.observe( i, { attributeFilter: [ 'data-placing' ] } ), + () => e.disconnect() + ); + } + if ( C && t ) { + const t = N( V ), + n = + void 0 !== t + ? t + : ( function ( e ) { + return e.find( + e => + ! e.disabled && + 'tab' !== + e.element?.getAttribute( 'role' ) + )?.id; + } )( V ) ?? e.first(); + ( A.current = n ), e.move( n ?? null ); + } else { + const t = e.item( r || e.first() )?.element; + t && + 'scrollIntoView' in t && + ( ( F.current = ! 0 ), + t.scrollIntoView( { block: 'nearest', inline: 'nearest' } ), + requestAnimationFrame( () => { + F.current = ! 1; + } ) ); + } + } + }, [ e, O, b, E, C, L, N, V ] ), + ( 0, J.useEffect )( () => { + if ( ! S ) return; + const t = v.current; + if ( ! t ) return; + const n = [ t, P ].filter( e => !! e ), + i = t => { + n.every( e => pu( t, e ) ) && e?.setValue( M ); + }; + for ( const e of n ) e.addEventListener( 'focusout', i ); + return () => { + for ( const e of n ) e.removeEventListener( 'focusout', i ); + }; + }, [ S, P, e, M ] ); + const D = e => e.currentTarget.value.length >= o, + B = g.onChange, + z = Fu( s ?? D ), + W = Fu( r ?? ! e.tag ), + $ = Tu( t => { + if ( ( B?.( t ), t.defaultPrevented ) ) return; + if ( ! e ) return; + const n = t.currentTarget, + { value: i, selectionStart: r, selectionEnd: o } = n, + s = t.nativeEvent; + if ( + ( ( y.current = ! 0 ), + ( function ( e ) { + return 'input' === e.type; + } )( s ) && + ( s.isComposing && ( ( y.current = ! 1 ), ( x.current = ! 0 ) ), + S ) ) + ) { + const e = + 'insertText' === s.inputType || + 'insertCompositionText' === s.inputType, + t = r === i.length; + j( e && t ); + } + if ( W( t ) ) { + const t = i === e.getState().value; + e.setValue( i ), + queueMicrotask( () => { + lu( n, r, o ); + } ), + S && C && t && w(); + } + z( t ) && e.show(), ( C && y.current ) || e.setActiveId( null ); + } ), + H = g.onCompositionEnd, + q = Tu( e => { + ( y.current = ! 0 ), + ( x.current = ! 1 ), + H?.( e ), + e.defaultPrevented || ( C && w() ); + } ), + G = g.onMouseDown, + Y = Fu( d ?? ( () => e.getState().includesBaseElement ) ), + K = Fu( f ), + U = Fu( l ?? D ), + X = Tu( t => { + G?.( t ), + t.defaultPrevented || + t.button || + t.ctrlKey || + ( e && + ( Y( t ) && e.setActiveId( null ), + K( t ) && e.setValue( M ), + U( t ) && gu( t.currentTarget, 'mouseup', e.show ) ) ); + } ), + Z = g.onKeyDown, + Q = Fu( u ?? D ), + ee = Tu( t => { + if ( ( Z?.( t ), t.repeat || ( y.current = ! 1 ), t.defaultPrevented ) ) + return; + if ( ! e ) return; + const { open: n } = e.getState(); + n && 'Enter' === t.key + ? t.preventDefault() + : t.ctrlKey || + t.altKey || + t.shiftKey || + t.metaKey || + n || + ( 'ArrowUp' !== t.key && 'ArrowDown' !== t.key ) || + ( Q( t ) && ( t.preventDefault(), e.show() ) ); + } ), + te = g.onBlur, + ne = Tu( e => { + ( y.current = ! 1 ), te?.( e ), e.defaultPrevented; + } ), + ie = Au( g.id ), + re = ( function ( e ) { + return 'inline' === e || 'list' === e || 'both' === e || 'none' === e; + } )( p ) + ? p + : void 0, + oe = Nd( e, e => null === e.activeId ); + return ( + ( g = { + role: 'combobox', + 'aria-autocomplete': re, + 'aria-haspopup': su( P, 'listbox' ), + 'aria-expanded': O, + 'aria-controls': P?.id, + 'data-active-item': oe || void 0, + value: M, + ...g, + id: ie, + ref: Nu( v, g.ref ), + onChange: $, + onCompositionEnd: q, + onMouseDown: X, + onKeyDown: ee, + onBlur: ne, + } ), + ( g = bf( { + store: e, + focusable: t, + ...g, + moveOnKeyPress: e => + ! ( function ( e, ...t ) { + const n = 'function' == typeof e ? e( ...t ) : e; + return null != n && ! n; + } )( m, e ) && ( S && j( ! 0 ), ! 0 ), + } ) ), + ( g = wf( { store: e, ...g } ) ), + { autoComplete: 'off', ...g } + ); + } ), + Sf = Gu( function ( e ) { + return Ku( 'input', Cf( e ) ); + } ); + function _f( e, t ) { + const n = setTimeout( t, e ); + return () => clearTimeout( n ); + } + function jf( ...e ) { + return e + .join( ', ' ) + .split( ', ' ) + .reduce( ( e, t ) => { + const n = t.endsWith( 'ms' ) ? 1 : 1e3, + i = Number.parseFloat( t || '0s' ) * n; + return i > e ? i : e; + }, 0 ); + } + function Ef( e, t, n ) { + return ! ( n || ! 1 === t || ( e && ! t ) ); + } + const kf = Uu( function ( { store: e, alwaysVisible: t, ...n } ) { + const i = ad(); + _u( + ( e = e || i ), + 'DisclosureContent must receive a `store` prop or be wrapped in a DisclosureProvider component.' + ); + const r = ( 0, J.useRef )( null ), + o = Au( n.id ), + [ s, a ] = ( 0, J.useState )( null ), + l = Nd( e, 'open' ), + u = Nd( e, 'mounted' ), + d = Nd( e, 'animated' ), + f = Nd( e, 'contentElement' ), + m = Nd( e.disclosure, 'contentElement' ), + p = ( 0, J.useRef )( ! 1 ); + Mu( () => { + r.current && e?.setContentElement( r.current ); + }, [ e ] ), + Mu( () => { + let t; + return ( + e?.setState( 'animated', e => ( ( t = e ), ! 0 ) ), + () => { + void 0 !== t && e?.setState( 'animated', t ); + } + ); + }, [ e ] ), + Mu( () => { + if ( d ) { + if ( f?.isConnected ) + return ( function ( e ) { + let t = requestAnimationFrame( () => { + t = requestAnimationFrame( e ); + } ); + return () => cancelAnimationFrame( t ); + } )( () => { + a( l ? 'enter' : u ? 'leave' : null ); + } ); + a( null ); + } else + l + ? p.current && ( ( p.current = ! 1 ), a( 'enter' ) ) + : ( ( p.current = ! 0 ), a( null ) ); + }, [ d, f, l, u ] ), + Mu( () => { + if ( ! e ) return; + if ( ! d ) return; + if ( ! s ) return; + if ( ! f ) return; + const t = () => e?.setState( 'animating', ! 1 ), + n = () => ( 0, js.flushSync )( t ); + if ( 'leave' === s && l ) return; + if ( 'enter' === s && ! l ) return; + if ( 'number' == typeof d ) return _f( d, n ); + const { + transitionDuration: i, + animationDuration: r, + transitionDelay: o, + animationDelay: a, + } = getComputedStyle( f ), + { + transitionDuration: c = '0', + animationDuration: u = '0', + transitionDelay: p = '0', + animationDelay: g = '0', + } = m ? getComputedStyle( m ) : {}, + h = jf( o, a, p, g ) + jf( i, r, c, u ); + return h + ? _f( Math.max( h - 1e3 / 60, 0 ), n ) + : ( 'enter' === s && e.setState( 'animated', ! 1 ), void t() ); + }, [ e, d, f, m, l, s ] ), + ( n = Lu( n, t => ( 0, c.jsx )( ud, { value: e, children: t } ), [ e ] ) ); + const g = Ef( u, n.hidden, t ), + h = n.style, + v = ( 0, J.useMemo )( + () => ( g ? { ...h, display: 'none' } : h ), + [ g, h ] + ); + return Eu( + ( n = { + 'data-open': l || void 0, + 'data-enter': 'enter' === s || void 0, + 'data-leave': 'leave' === s || void 0, + hidden: g, + ...n, + id: o, + ref: Nu( o ? e.setContentElement : null, r, n.ref ), + style: v, + } ) + ); + } ), + If = Gu( function ( e ) { + return Ku( 'div', kf( e ) ); + } ), + Vf = + ( Gu( function ( { unmountOnHide: e, ...t } ) { + const n = ad(); + return ! 1 === Nd( t.store || n, t => ! e || t?.mounted ) + ? null + : ( 0, c.jsx )( If, { ...t } ); + } ), + Uu( function ( { store: e, alwaysVisible: t, ...n } ) { + const i = bd( ! 0 ), + r = vd(), + o = !! ( e = e || r ) && e === i; + _u( + e, + 'ComboboxList must receive a `store` prop or be wrapped in a ComboboxProvider component.' + ); + const s = ( 0, J.useRef )( null ), + a = Au( n.id ), + l = Nd( e, 'mounted' ), + u = Ef( l, n.hidden, t ), + d = u ? { ...n.style, display: 'none' } : n.style, + f = Nd( e, e => Array.isArray( e.selectedValue ) ), + m = ( function ( e, t, n ) { + const i = ( function ( e ) { + const [ t ] = ( 0, J.useState )( e ); + return t; + } )( n ), + [ r, o ] = ( 0, J.useState )( i ); + return ( + ( 0, J.useEffect )( () => { + const n = e && 'current' in e ? e.current : e; + if ( ! n ) return; + const r = () => { + const e = n.getAttribute( t ); + o( e ?? i ); + }, + s = new MutationObserver( r ); + return ( + s.observe( n, { attributeFilter: [ t ] } ), + r(), + () => s.disconnect() + ); + }, [ e, t, i ] ), + r + ); + } )( s, 'role', n.role ), + p = + ( ( 'listbox' === m || 'tree' === m || 'grid' === m ) && f ) || + void 0, + [ g, h ] = ( 0, J.useState )( ! 1 ), + v = Nd( e, 'contentElement' ); + Mu( () => { + if ( ! l ) return; + const e = s.current; + if ( ! e ) return; + if ( v !== e ) return; + const t = () => { + h( !! e.querySelector( "[role='listbox']" ) ); + }, + n = new MutationObserver( t ); + return ( + n.observe( e, { + subtree: ! 0, + childList: ! 0, + attributeFilter: [ 'role' ], + } ), + t(), + () => n.disconnect() + ); + }, [ l, v ] ), + g || ( n = { role: 'listbox', 'aria-multiselectable': p, ...n } ), + ( n = Lu( + n, + t => + ( 0, c.jsx )( xd, { + value: e, + children: ( 0, c.jsx )( gd.Provider, { + value: m, + children: t, + } ), + } ), + [ e, m ] + ) ); + const b = ! a || ( i && o ) ? null : e.setContentElement; + return Eu( + ( n = { hidden: u, ...n, id: a, ref: Nu( b, s, n.ref ), style: d } ) + ); + } ) ), + Of = Gu( function ( e ) { + return Ku( 'div', Vf( e ) ); + } ); + function Pf( e ) { + if ( ! e.isTrusted ) return ! 1; + const t = e.currentTarget; + return 'Enter' === e.key + ? tu( t ) || 'SUMMARY' === t.tagName || 'A' === t.tagName + : ' ' === e.key && + ( tu( t ) || + 'SUMMARY' === t.tagName || + 'INPUT' === t.tagName || + 'SELECT' === t.tagName ); + } + const Mf = Symbol( 'command' ), + Tf = Uu( function ( { clickOnEnter: e = ! 0, clickOnSpace: t = ! 0, ...n } ) { + const i = ( 0, J.useRef )( null ), + [ r, o ] = ( 0, J.useState )( ! 1 ); + ( 0, J.useEffect )( () => { + i.current && o( tu( i.current ) ); + }, [] ); + const [ s, a ] = ( 0, J.useState )( ! 1 ), + l = ( 0, J.useRef )( ! 1 ), + c = ju( n ), + [ u, d ] = Du( n, Mf, ! 0 ), + f = n.onKeyDown, + m = Tu( n => { + f?.( n ); + const i = n.currentTarget; + if ( n.defaultPrevented ) return; + if ( u ) return; + if ( c ) return; + if ( ! du( n ) ) return; + if ( iu( i ) ) return; + if ( i.isContentEditable ) return; + const r = e && 'Enter' === n.key, + o = t && ' ' === n.key, + s = 'Enter' === n.key && ! e, + d = ' ' === n.key && ! t; + if ( s || d ) n.preventDefault(); + else if ( r || o ) { + const e = Pf( n ); + if ( r ) { + if ( ! e ) { + n.preventDefault(); + const { view: e, ...t } = n, + r = () => mu( i, t ); + Zc && /firefox\//i.test( navigator.userAgent ) + ? gu( i, 'keyup', r ) + : queueMicrotask( r ); + } + } else + o && + ( ( l.current = ! 0 ), + e || ( n.preventDefault(), a( ! 0 ) ) ); + } + } ), + p = n.onKeyUp, + g = Tu( e => { + if ( ( p?.( e ), e.defaultPrevented ) ) return; + if ( u ) return; + if ( c ) return; + if ( e.metaKey ) return; + const n = t && ' ' === e.key; + if ( l.current && n && ( ( l.current = ! 1 ), ! Pf( e ) ) ) { + e.preventDefault(), a( ! 1 ); + const t = e.currentTarget, + { view: n, ...i } = e; + queueMicrotask( () => mu( t, i ) ); + } + } ); + return ( + ( n = { + 'data-active': s || void 0, + type: r ? 'button' : void 0, + ...d, + ...n, + ref: Nu( i, n.ref ), + onKeyDown: m, + onKeyUp: g, + } ), + ff( n ) + ); + } ), + Nf = + ( Gu( function ( e ) { + return Ku( 'button', Tf( e ) ); + } ), + Uu( function ( { + store: e, + shouldRegisterItem: t = ! 0, + getItem: n = Su, + element: i, + ...r + } ) { + const o = Qu(); + e = e || o; + const s = Au( r.id ), + a = ( 0, J.useRef )( i ); + return ( + ( 0, J.useEffect )( () => { + const i = a.current; + if ( ! s ) return; + if ( ! i ) return; + if ( ! t ) return; + const r = n( { id: s, element: i } ); + return e?.renderItem( r ); + }, [ s, t, n, e ] ), + Eu( ( r = { ...r, ref: Nu( a, r.ref ) } ) ) + ); + } ) ); + function Af( e, t = ! 1 ) { + const { top: n } = e.getBoundingClientRect(); + return t ? n + e.clientHeight : n; + } + function Rf( e, t, n, i = ! 1 ) { + if ( ! t ) return; + if ( ! n ) return; + const { renderedItems: r } = t.getState(), + o = au( e ); + if ( ! o ) return; + const s = ( function ( e, t = ! 1 ) { + const n = e.clientHeight, + { top: i } = e.getBoundingClientRect(), + r = 1.5 * Math.max( 0.875 * n, n - 40 ), + o = t ? n - r + i : r + i; + return 'HTML' === e.tagName ? o + e.scrollTop : o; + } )( o, i ); + let a, l; + for ( let e = 0; e < r.length; e += 1 ) { + const r = a; + if ( ( ( a = n( e ) ), ! a ) ) break; + if ( a === r ) continue; + const o = mf( t, a )?.element; + if ( ! o ) continue; + const c = Af( o, i ) - s, + u = Math.abs( c ); + if ( ( i && c <= 0 ) || ( ! i && c >= 0 ) ) { + void 0 !== l && l < u && ( a = r ); + break; + } + l = u; + } + return a; + } + Gu( function ( e ) { + return Ku( 'div', Nf( e ) ); + } ); + const Ff = Uu( function ( { + store: e, + rowId: t, + preventScrollOnKeyDown: n = ! 1, + moveOnKeyPress: i = ! 0, + tabbable: r = ! 1, + getItem: o, + 'aria-setsize': s, + 'aria-posinset': a, + ...l + } ) { + const u = ed(); + e = e || u; + const d = Au( l.id ), + f = ( 0, J.useRef )( null ), + m = ( 0, J.useContext )( od ), + p = ju( l ) && ! l.accessibleWhenDisabled, + { + rowId: g, + baseElement: h, + isActiveItem: v, + ariaSetSize: b, + ariaPosInSet: w, + isTabbable: y, + } = Ad( e, { + rowId: e => + t || + ( e && m?.baseElement && m.baseElement === e.baseElement + ? m.id + : void 0 ), + baseElement: e => e?.baseElement || void 0, + isActiveItem: e => !! e && e.activeId === d, + ariaSetSize: e => + null != s + ? s + : e && m?.ariaSetSize && m.baseElement === e.baseElement + ? m.ariaSetSize + : void 0, + ariaPosInSet( e ) { + if ( null != a ) return a; + if ( ! e ) return; + if ( ! m?.ariaPosInSet ) return; + if ( m.baseElement !== e.baseElement ) return; + const t = e.renderedItems.filter( e => e.rowId === g ); + return m.ariaPosInSet + t.findIndex( e => e.id === d ); + }, + isTabbable( t ) { + if ( ! t?.renderedItems.length ) return ! 0; + if ( t.virtualFocus ) return ! 1; + if ( r ) return ! 0; + if ( null === t.activeId ) return ! 1; + const n = e?.item( t.activeId ); + return !! n?.disabled || ! n?.element || t.activeId === d; + }, + } ), + x = ( 0, J.useCallback )( + e => { + const t = { + ...e, + id: d || e.id, + rowId: g, + disabled: p, + children: e.element?.textContent, + }; + return o ? o( t ) : t; + }, + [ d, g, p, o ] + ), + C = l.onFocus, + S = ( 0, J.useRef )( ! 1 ), + _ = Tu( t => { + if ( ( C?.( t ), t.defaultPrevented ) ) return; + if ( + ( function ( e ) { + return Boolean( + e.currentTarget && ! eu( e.currentTarget, e.target ) + ); + } )( t ) + ) + return; + if ( ! d ) return; + if ( ! e ) return; + if ( + ( function ( e, t ) { + return ! du( e ) && gf( t, e.target ); + } )( t, e ) + ) + return; + const { virtualFocus: n, baseElement: i } = e.getState(); + var r; + e.setActiveId( d ), + ru( t.currentTarget ) && + ( function ( e, t = ! 1 ) { + if ( iu( e ) ) + e.setSelectionRange( + t ? e.value.length : 0, + e.value.length + ); + else if ( e.isContentEditable ) { + const n = Qc( e ).getSelection(); + n?.selectAllChildren( e ), t && n?.collapseToEnd(); + } + } )( t.currentTarget ), + n && + du( t ) && + ( ru( ( r = t.currentTarget ) ) || + ( 'INPUT' === r.tagName && ! tu( r ) ) || + ( i?.isConnected && + ( uu() && + t.currentTarget.hasAttribute( 'data-autofocus' ) && + t.currentTarget.scrollIntoView( { + block: 'nearest', + inline: 'nearest', + } ), + ( S.current = ! 0 ), + t.relatedTarget === i || gf( e, t.relatedTarget ) + ? ( function ( e ) { + ( e[ pf ] = ! 0 ), + e.focus( { preventScroll: ! 0 } ); + } )( i ) + : i.focus() ) ) ); + } ), + j = l.onBlurCapture, + E = Tu( t => { + j?.( t ), + t.defaultPrevented || + ( e?.getState()?.virtualFocus && + S.current && + ( ( S.current = ! 1 ), + t.preventDefault(), + t.stopPropagation() ) ); + } ), + k = l.onKeyDown, + I = Fu( n ), + V = Fu( i ), + O = Tu( t => { + if ( ( k?.( t ), t.defaultPrevented ) ) return; + if ( ! du( t ) ) return; + if ( ! e ) return; + const { currentTarget: n } = t, + i = e.getState(), + r = !! e.item( d )?.rowId, + o = 'horizontal' !== i.orientation, + s = 'vertical' !== i.orientation, + a = () => ! ( ! r && ! s && i.baseElement && iu( i.baseElement ) ), + l = { + ArrowUp: ( r || o ) && e.up, + ArrowRight: ( r || s ) && e.next, + ArrowDown: ( r || o ) && e.down, + ArrowLeft: ( r || s ) && e.previous, + Home: () => { + if ( a() ) + return ! r || t.ctrlKey ? e?.first() : e?.previous( -1 ); + }, + End: () => { + if ( a() ) return ! r || t.ctrlKey ? e?.last() : e?.next( -1 ); + }, + PageUp: () => Rf( n, e, e?.up, ! 0 ), + PageDown: () => Rf( n, e, e?.down ), + }[ t.key ]; + if ( l ) { + if ( ru( n ) ) { + const e = ou( n ), + i = s && 'ArrowLeft' === t.key, + r = s && 'ArrowRight' === t.key, + a = o && 'ArrowUp' === t.key, + l = o && 'ArrowDown' === t.key; + if ( r || l ) { + const { length: t } = ( function ( e ) { + if ( iu( e ) ) return e.value; + if ( e.isContentEditable ) { + const t = Qc( e ).createRange(); + return t.selectNodeContents( e ), t.toString(); + } + return ''; + } )( n ); + if ( e.end !== t ) return; + } else if ( ( i || a ) && 0 !== e.start ) return; + } + const i = l(); + if ( I( t ) || void 0 !== i ) { + if ( ! V( t ) ) return; + t.preventDefault(), e.move( i ); + } + } + } ), + P = ( 0, J.useMemo )( () => ( { id: d, baseElement: h } ), [ d, h ] ); + return ( + ( l = Lu( l, e => ( 0, c.jsx )( rd.Provider, { value: P, children: e } ), [ + P, + ] ) ), + ( l = { + 'data-active-item': v || void 0, + ...l, + id: d, + ref: Nu( f, l.ref ), + tabIndex: y ? l.tabIndex : -1, + onFocus: _, + onBlurCapture: E, + onKeyDown: O, + } ), + ( l = Tf( l ) ), + ( l = Nf( { + store: e, + ...l, + getItem: x, + shouldRegisterItem: !! d && l.shouldRegisterItem, + } ) ), + Eu( { ...l, 'aria-setsize': b, 'aria-posinset': w } ) + ); + } ); + function Lf( e ) { + const t = e.relatedTarget; + return t?.nodeType === Node.ELEMENT_NODE ? t : null; + } + Yu( + Gu( function ( e ) { + return Ku( 'button', Ff( e ) ); + } ) + ); + const Df = Symbol( 'composite-hover' ), + Bf = Uu( function ( { + store: e, + focusOnHover: t = ! 0, + blurOnHoverEnd: n = !! t, + ...i + } ) { + const r = ed(); + _u( + ( e = e || r ), + 'CompositeHover must be wrapped in a Composite component.' + ); + const o = + ( ( 0, J.useEffect )( () => { + Bu || + ( hu( 'mousemove', Hu, ! 0 ), + hu( 'mousedown', qu, ! 0 ), + hu( 'mouseup', qu, ! 0 ), + hu( 'keydown', qu, ! 0 ), + hu( 'scroll', qu, ! 0 ), + ( Bu = ! 0 ) ); + }, [] ), + Tu( () => zu ) ), + s = i.onMouseMove, + a = Fu( t ), + l = Tu( t => { + if ( ( s?.( t ), ! t.defaultPrevented && o() && a( t ) ) ) { + if ( + ! ( function ( e ) { + const t = Jc( e ); + if ( ! t ) return ! 1; + if ( eu( e, t ) ) return ! 0; + const n = t.getAttribute( 'aria-activedescendant' ); + return ( + !! n && + 'id' in e && + ( n === e.id || + !! e.querySelector( `#${ CSS.escape( n ) }` ) ) + ); + } )( t.currentTarget ) + ) { + const t = e?.getState().baseElement; + t && ! bu( t ) && t.focus(); + } + e?.setActiveId( t.currentTarget.id ); + } + } ), + c = i.onMouseLeave, + u = Fu( n ), + d = Tu( t => { + c?.( t ), + t.defaultPrevented || + ( o() && + ( ( function ( e ) { + const t = Lf( e ); + return !! t && eu( e.currentTarget, t ); + } )( t ) || + ( function ( e ) { + let t = Lf( e ); + if ( ! t ) return ! 1; + do { + if ( yu( t, Df ) && t[ Df ] ) return ! 0; + t = t.parentElement; + } while ( t ); + return ! 1; + } )( t ) || + ( a( t ) && + u( t ) && + ( e?.setActiveId( null ), + e?.getState().baseElement?.focus() ) ) ) ); + } ), + f = ( 0, J.useCallback )( e => { + e && ( e[ Df ] = ! 0 ); + }, [] ); + return Eu( + ( i = { ...i, ref: Nu( f, i.ref ), onMouseMove: l, onMouseLeave: d } ) + ); + } ); + Yu( + Gu( function ( e ) { + return Ku( 'div', Bf( e ) ); + } ) + ); + const zf = Uu( function ( { + store: e, + value: t, + hideOnClick: n, + setValueOnClick: i, + selectValueOnClick: r = ! 0, + resetValueOnSelect: o, + focusOnHover: s = ! 1, + moveOnKeyPress: a = ! 0, + getItem: l, + ...u + } ) { + const d = bd(); + _u( + ( e = e || d ), + 'ComboboxItem must be wrapped in a ComboboxList or ComboboxPopover component.' + ); + const { + resetValueOnSelectState: f, + multiSelectable: m, + selected: p, + } = Ad( e, { + resetValueOnSelectState: 'resetValueOnSelect', + multiSelectable: e => Array.isArray( e.selectedValue ), + selected: e => + ( function ( e, t ) { + if ( null != t ) + return ( + null != e && + ( Array.isArray( e ) ? e.includes( t ) : e === t ) + ); + } )( e.selectedValue, t ), + } ), + g = ( 0, J.useCallback )( + e => { + const n = { ...e, value: t }; + return l ? l( n ) : n; + }, + [ t, l ] + ); + ( i = i ?? ! m ), ( n = n ?? ( null != t && ! m ) ); + const h = u.onClick, + v = Fu( i ), + b = Fu( r ), + w = Fu( o ?? f ?? m ), + y = Fu( n ), + x = Tu( n => { + h?.( n ), + n.defaultPrevented || + ( function ( e ) { + const t = e.currentTarget; + if ( ! t ) return ! 1; + const n = t.tagName.toLowerCase(); + return ( + !! e.altKey && + ( 'a' === n || + ( 'button' === n && 'submit' === t.type ) || + ( 'input' === n && 'submit' === t.type ) ) + ); + } )( n ) || + ( function ( e ) { + const t = e.currentTarget; + if ( ! t ) return ! 1; + const n = cu(); + if ( n && ! e.metaKey ) return ! 1; + if ( ! n && ! e.ctrlKey ) return ! 1; + const i = t.tagName.toLowerCase(); + return ( + 'a' === i || + ( 'button' === i && 'submit' === t.type ) || + ( 'input' === i && 'submit' === t.type ) + ); + } )( n ) || + ( null != t && + ( b( n ) && + ( w( n ) && e?.resetValue(), + e?.setSelectedValue( e => + Array.isArray( e ) + ? e.includes( t ) + ? e.filter( e => e !== t ) + : [ ...e, t ] + : t + ) ), + v( n ) && e?.setValue( t ) ), + y( n ) && e?.hide() ); + } ), + C = u.onKeyDown, + S = Tu( t => { + if ( ( C?.( t ), t.defaultPrevented ) ) return; + const n = e?.getState().baseElement; + n && + ( bu( n ) || + ( 1 !== t.key.length && + 'Backspace' !== t.key && + 'Delete' !== t.key ) || + ( queueMicrotask( () => n.focus() ), + iu( n ) && e?.setValue( n.value ) ) ); + } ); + var _; + m && null != p && ( u = { 'aria-selected': p, ...u } ), + ( u = Lu( + u, + e => + ( 0, c.jsx )( Cd.Provider, { + value: t, + children: ( 0, c.jsx )( Sd.Provider, { + value: p ?? ! 1, + children: e, + } ), + } ), + [ t, p ] + ) ), + ( u = { + role: + ( ( _ = ( 0, J.useContext )( gd ) ), + { menu: 'menuitem', listbox: 'option', tree: 'treeitem' }[ _ ] ?? + 'option' ), + children: t, + ...u, + onClick: x, + onKeyDown: S, + } ); + const j = Fu( a ); + return ( + ( u = Ff( { + store: e, + ...u, + getItem: g, + moveOnKeyPress: t => { + if ( ! j( t ) ) return ! 1; + const n = new Event( 'combobox-item-move' ); + return e?.getState().baseElement?.dispatchEvent( n ), ! 0; + }, + } ) ), + Bf( { store: e, focusOnHover: s, ...u } ) + ); + } ), + Wf = Yu( + Gu( function ( e ) { + return Ku( 'div', zf( e ) ); + } ) + ); + function $f( e ) { + return Cu( e ).toLowerCase(); + } + const Hf = Uu( function ( { store: e, value: t, userValue: n, ...i } ) { + const r = bd(); + e = e || r; + const o = ( 0, J.useContext )( Cd ), + s = t ?? o, + a = Nd( e, e => n ?? e?.value ); + return Eu( + ( i = { + children: ( 0, J.useMemo )( () => { + if ( s ) + return a + ? ( function ( e, t ) { + if ( ! e ) return e; + if ( ! t ) return e; + const n = ( ( i = t ), + Array.isArray( i ) ? i : void 0 !== i ? [ i ] : [] ) + .filter( Boolean ) + .map( $f ); + var i; + const r = [], + o = ( e, t = ! 1 ) => + ( 0, c.jsx )( + 'span', + { + 'data-autocomplete-value': t + ? '' + : void 0, + 'data-user-value': t ? void 0 : '', + children: e, + }, + r.length + ), + s = ( function ( e ) { + return e.sort( ( [ e ], [ t ] ) => e - t ); + } )( + ( function ( e ) { + return e.filter( + ( [ e, t ], n, i ) => + ! i.some( + ( [ i, r ], o ) => + o !== n && + i <= e && + i + r >= e + t + ) + ); + } )( + ( function ( e, t ) { + const n = []; + for ( const i of t ) { + let t = 0; + const r = i.length; + for ( + ; + -1 !== e.indexOf( i, t ); + + ) { + const o = e.indexOf( i, t ); + -1 !== o && + n.push( [ o, r ] ), + ( t = o + 1 ); + } + } + return n; + } )( $f( e ), new Set( n ) ) + ) + ), + a = s[ 0 ]; + if ( ! a ) return r.push( o( e, ! 0 ) ), r; + const [ l ] = a; + return ( + [ + e.slice( 0, l ), + ...s.flatMap( ( [ t, n ], i ) => { + const r = e.slice( t, t + n ), + o = s[ i + 1 ]?.[ 0 ]; + return [ r, e.slice( t + n, o ) ]; + } ), + ].forEach( ( e, t ) => { + e && r.push( o( e, t % 2 == 0 ) ); + } ), + r + ); + } )( s, a ) + : s; + }, [ s, a ] ), + ...i, + } ) + ); + } ), + qf = Gu( function ( e ) { + return Ku( 'span', Hf( e ) ); + } ); + var Gf = ( 0, c.jsx )( l.SVG, { + xmlns: 'http://www.w3.org/2000/svg', + viewBox: '0 0 24 24', + children: ( 0, c.jsx )( l.Path, { + d: 'M13 5c-3.3 0-6 2.7-6 6 0 1.4.5 2.7 1.3 3.7l-3.8 3.8 1.1 1.1 3.8-3.8c1 .8 2.3 1.3 3.7 1.3 3.3 0 6-2.7 6-6S16.3 5 13 5zm0 10.5c-2.5 0-4.5-2-4.5-4.5s2-4.5 4.5-4.5 4.5 2 4.5 4.5-2 4.5-4.5 4.5z', + } ), + } ), + Yf = [], + Kf = ( e, t ) => + e.singleSelection + ? t?.value + : Array.isArray( t?.value ) + ? t.value + : ! Array.isArray( t?.value ) && t?.value + ? [ t.value ] + : Yf; + function Uf( e = '' ) { + return s( e.trim().toLowerCase() ); + } + var Xf = ( e, t, n ) => + e.singleSelection + ? n + : Array.isArray( t?.value ) + ? t.value.includes( n ) + ? t.value.filter( e => e !== n ) + : [ ...t.value, n ] + : [ n ]; + function Zf( e, t ) { + return `${ e }-${ t }`; + } + var Qf = ( { selected: e } ) => + ( 0, c.jsx )( 'span', { + className: Te( + 'dataviews-filters__search-widget-listitem-multi-selection', + { 'is-selected': e } + ), + children: e && ( 0, c.jsx )( t.Icon, { icon: Nr } ), + } ), + Jf = ( { selected: e } ) => + ( 0, c.jsx )( 'span', { + className: Te( + 'dataviews-filters__search-widget-listitem-single-selection', + { 'is-selected': e } + ), + } ); + function em( { view: i, filter: r, onChangeView: o } ) { + const s = ( 0, qi.useInstanceId )( em, 'dataviews-filter-list-box' ), + [ a, l ] = ( 0, e.useState )( 1 === r.operators?.length ? void 0 : null ), + u = i.filters?.find( e => e.field === r.field ), + d = Kf( r, u ); + return ( 0, c.jsx )( t.Composite, { + virtualFocus: ! 0, + focusLoop: ! 0, + activeId: a, + setActiveId: l, + role: 'listbox', + className: 'dataviews-filters__search-widget-listbox', + 'aria-label': ( 0, n.sprintf )( + /* translators: List of items for a filter. 1: Filter name. e.g.: "List of: Author". */ + /* translators: List of items for a filter. 1: Filter name. e.g.: "List of: Author". */ + ( 0, n.__ )( 'List of: %1$s' ), + r.name + ), + onFocusVisible: () => { + ! a && r.elements.length && l( Zf( s, r.elements[ 0 ].value ) ); + }, + render: ( 0, c.jsx )( t.Composite.Typeahead, {} ), + children: r.elements.map( e => + ( 0, c.jsxs )( + t.Composite.Hover, + { + render: ( 0, c.jsx )( t.Composite.Item, { + id: Zf( s, e.value ), + render: ( 0, c.jsx )( 'div', { + 'aria-label': e.label, + role: 'option', + className: 'dataviews-filters__search-widget-listitem', + } ), + onClick: () => { + const t = u + ? [ + ...( i.filters ?? [] ).map( t => + t.field === r.field + ? { + ...t, + operator: + u.operator || + r.operators[ 0 ], + value: Xf( r, u, e.value ), + } + : t + ), + ] + : [ + ...( i.filters ?? [] ), + { + field: r.field, + operator: r.operators[ 0 ], + value: Xf( r, u, e.value ), + }, + ]; + o( { ...i, page: 1, filters: t } ); + }, + } ), + children: [ + r.singleSelection && + ( 0, c.jsx )( Jf, { selected: d === e.value } ), + ! r.singleSelection && + ( 0, c.jsx )( Qf, { selected: d.includes( e.value ) } ), + ( 0, c.jsx )( 'span', { + className: + 'dataviews-filters__search-widget-listitem-value', + title: e.label, + children: e.label, + } ), + ], + }, + e.value + ) + ), + } ); + } + function tm( { view: i, filter: r, onChangeView: o } ) { + const [ s, a ] = ( 0, e.useState )( '' ), + l = ( 0, e.useDeferredValue )( s ), + u = i.filters?.find( e => e.field === r.field ), + d = Kf( r, u ), + f = ( 0, e.useMemo )( () => { + const e = Uf( l ); + return r.elements.filter( t => Uf( t.label ).includes( e ) ); + }, [ r.elements, l ] ); + return ( 0, c.jsxs )( Zd, { + selectedValue: d, + setSelectedValue: e => { + const t = u + ? [ + ...( i.filters ?? [] ).map( t => + t.field === r.field + ? { + ...t, + operator: u.operator || r.operators[ 0 ], + value: e, + } + : t + ), + ] + : [ + ...( i.filters ?? [] ), + { field: r.field, operator: r.operators[ 0 ], value: e }, + ]; + o( { ...i, page: 1, filters: t } ); + }, + setValue: a, + children: [ + ( 0, c.jsxs )( 'div', { + className: 'dataviews-filters__search-widget-filter-combobox__wrapper', + children: [ + ( 0, c.jsx )( Cc, { + render: ( 0, c.jsx )( Jd, {} ), + children: ( 0, n.__ )( 'Search items' ), + } ), + ( 0, c.jsx )( Sf, { + autoSelect: 'always', + placeholder: ( 0, n.__ )( 'Search' ), + className: + 'dataviews-filters__search-widget-filter-combobox__input', + } ), + ( 0, c.jsx )( 'div', { + className: + 'dataviews-filters__search-widget-filter-combobox__icon', + children: ( 0, c.jsx )( t.Icon, { icon: Gf } ), + } ), + ], + } ), + ( 0, c.jsxs )( Of, { + className: 'dataviews-filters__search-widget-filter-combobox-list', + alwaysVisible: ! 0, + children: [ + f.map( e => + ( 0, c.jsxs )( + Wf, + { + resetValueOnSelect: ! 1, + value: e.value, + className: 'dataviews-filters__search-widget-listitem', + hideOnClick: ! 1, + setValueOnClick: ! 1, + focusOnHover: ! 0, + children: [ + r.singleSelection && + ( 0, c.jsx )( Jf, { selected: d === e.value } ), + ! r.singleSelection && + ( 0, c.jsx )( Qf, { + selected: d.includes( e.value ), + } ), + ( 0, c.jsxs )( 'span', { + className: + 'dataviews-filters__search-widget-listitem-value', + title: e.label, + children: [ + ( 0, c.jsx )( qf, { + className: + 'dataviews-filters__search-widget-filter-combobox-item-value', + value: e.label, + } ), + !! e.description && + ( 0, c.jsx )( 'span', { + className: + 'dataviews-filters__search-widget-listitem-description', + children: e.description, + } ), + ], + } ), + ], + }, + e.value + ) + ), + ! f.length && + ( 0, c.jsx )( 'p', { + children: ( 0, n.__ )( 'No results found' ), + } ), + ], + } ), + ], + } ); + } + function nm( e ) { + const { elements: i, isLoading: r } = Y( { + elements: e.filter.elements, + getElements: e.filter.getElements, + } ); + if ( r ) + return ( 0, c.jsx )( 'div', { + className: 'dataviews-filters__search-widget-no-elements', + children: ( 0, c.jsx )( t.Spinner, {} ), + } ); + if ( 0 === i.length ) + return ( 0, c.jsx )( 'div', { + className: 'dataviews-filters__search-widget-no-elements', + children: ( 0, n.__ )( 'No elements found' ), + } ); + const o = i.length > 10 ? tm : em; + return ( 0, c.jsx )( o, { ...e, filter: { ...e.filter, elements: i } } ); + } + var im = r( 489 ); + function rm( { filter: n, view: i, onChangeView: r, fields: o } ) { + const s = i.filters?.find( e => e.field === n.field ), + a = Kf( n, s ), + l = ( 0, e.useMemo )( () => { + const e = o.find( e => e.id === n.field ); + return e + ? { + ...e, + isValid: {}, + isDisabled: () => ! 1, + isVisible: () => ! 0, + getValue: ( { item: t } ) => t[ e.id ], + setValue: ( { value: t } ) => ( { [ e.id ]: t } ), + } + : e; + }, [ o, n.field ] ), + u = ( 0, e.useMemo )( + () => + ( i.filters ?? [] ).reduce( + ( e, t ) => ( ( e[ t.field ] = t.value ), e ), + {} + ), + [ i.filters ] + ), + d = ( 0, qi.useEvent )( e => { + if ( ! l || ! s ) return; + const t = l.getValue( { item: e } ); + im( t, a ) || + r( { + ...i, + filters: ( i.filters ?? [] ).map( e => + e.field === n.field + ? { + ...e, + operator: s.operator || n.operators[ 0 ], + value: '' === t ? void 0 : t, + } + : e + ), + } ); + } ); + return l && l.Edit && s + ? ( 0, c.jsx )( t.Flex, { + className: 'dataviews-filters__user-input-widget', + gap: 2.5, + direction: 'column', + children: ( 0, c.jsx )( l.Edit, { + hideLabelFromVision: ! 0, + data: u, + field: l, + operator: s.operator, + onChange: d, + } ), + } ) + : null; + } + var om = 'Enter', + sm = ' ', + am = ( { activeElements: e, filterInView: t, filter: i } ) => { + if ( void 0 === e || 0 === e.length ) return i.name; + const r = Ri( t?.operator ); + return void 0 !== r + ? r.filterText( i, e ) + : ( 0, n.sprintf )( + /* translators: 1: Filter name e.g.: "Unknown status for Author". */ + /* translators: 1: Filter name e.g.: "Unknown status for Author". */ + ( 0, n.__ )( 'Unknown status for %1$s' ), + i.name + ); + }; + function lm( { filter: e, view: i, onChangeView: r } ) { + const o = e.operators?.map( e => ( { value: e, label: Ri( e )?.label || e } ) ), + s = i.filters?.find( t => t.field === e.field ), + a = s?.operator || e.operators[ 0 ]; + return ( + o.length > 1 && + ( 0, c.jsxs )( Pe, { + direction: 'row', + gap: 'sm', + justify: 'flex-start', + className: 'dataviews-filters__summary-operators-container', + align: 'center', + children: [ + ( 0, c.jsx )( t.FlexItem, { + className: 'dataviews-filters__summary-operators-filter-name', + children: e.name, + } ), + ( 0, c.jsx )( t.SelectControl, { + className: 'dataviews-filters__summary-operators-filter-select', + label: ( 0, n.__ )( 'Conditions' ), + value: a, + options: o, + onChange: t => { + const n = t, + o = s?.operator, + a = s + ? [ + ...( i.filters ?? [] ).map( t => { + if ( t.field === e.field ) { + const e = Ri( o )?.selection, + i = Ri( n )?.selection, + r = + e !== i || + [ e, i ].includes( 'custom' ); + return { + ...t, + value: r ? void 0 : t.value, + operator: n, + }; + } + return t; + } ), + ] + : [ + ...( i.filters ?? [] ), + { field: e.field, operator: n, value: void 0 }, + ]; + r( { ...i, page: 1, filters: a } ); + }, + size: 'small', + variant: 'minimal', + hideLabelFromVision: ! 0, + } ), + ], + } ) + ); + } + function cm( { addFilterRef: i, openedFilter: r, fields: o, ...s } ) { + const a = ( 0, e.useRef )( null ), + { filter: l, view: u, onChangeView: d } = s, + f = u.filters?.find( e => e.field === l.field ); + let m = []; + const p = ( 0, e.useMemo )( () => { + const e = o.find( e => e.id === l.field ); + return e ? { ...e, getValue: ( { item: t } ) => t[ e.id ] } : e; + }, [ o, l.field ] ), + { elements: g } = Y( { elements: l.elements, getElements: l.getElements } ); + if ( g.length > 0 ) + m = g.filter( e => + l.singleSelection ? e.value === f?.value : f?.value?.includes( e.value ) + ); + else if ( Array.isArray( f?.value ) ) { + const e = f.value.map( e => { + const t = p?.getValueFormatted( { item: { [ p.id ]: e }, field: p } ); + return t || String( e ); + } ); + m = [ { value: f.value, label: e } ]; + } else if ( 'object' == typeof f?.value ) + m = [ { value: f.value, label: f.value } ]; + else if ( void 0 !== f?.value ) { + const e = + void 0 !== p + ? p.getValueFormatted( { item: { [ p.id ]: f.value }, field: p } ) + : String( f.value ); + m = [ { value: f.value, label: e } ]; + } + const h = l.isPrimary, + v = f?.isLocked, + b = ! v && void 0 !== f?.value, + w = ! v && ( ! h || b ), + y = h ? ( 0, n.__ )( 'Reset' ) : ( 0, n.__ )( 'Remove' ); + return ( 0, c.jsx )( t.Dropdown, { + defaultOpen: r === l.field, + contentClassName: 'dataviews-filters__summary-popover', + popoverProps: { placement: 'bottom-start', role: 'dialog' }, + onClose: () => { + a.current?.focus(); + }, + renderToggle: ( { isOpen: e, onToggle: r } ) => + ( 0, c.jsxs )( 'div', { + className: 'dataviews-filters__summary-chip-container', + children: [ + ( 0, c.jsxs )( zs, { + children: [ + ( 0, c.jsx )( Ca, { + render: ( 0, c.jsx )( 'div', { + className: Te( 'dataviews-filters__summary-chip', { + 'has-reset': w, + 'has-values': b, + 'is-not-clickable': v, + } ), + role: 'button', + tabIndex: v ? -1 : 0, + onClick: () => { + v || r(); + }, + onKeyDown: e => { + ! v && + [ om, sm ].includes( e.key ) && + ( r(), e.preventDefault() ); + }, + 'aria-disabled': v, + 'aria-pressed': e, + 'aria-expanded': e, + ref: a, + children: ( 0, c.jsx )( am, { + activeElements: m, + filterInView: f, + filter: l, + } ), + } ), + } ), + ( 0, c.jsx )( uc, { + children: ( 0, n.sprintf )( + /* translators: 1: Filter name. */ + /* translators: 1: Filter name. */ + ( 0, n.__ )( 'Filter by: %1$s' ), + l.name.toLowerCase() + ), + } ), + ], + } ), + w && + ( 0, c.jsxs )( zs, { + children: [ + ( 0, c.jsx )( Ca, { + render: ( 0, c.jsx )( 'button', { + className: Te( + 'dataviews-filters__summary-chip-remove', + { 'has-values': b } + ), + 'aria-label': y, + onClick: () => { + d( { + ...u, + page: 1, + filters: u.filters?.filter( + e => e.field !== l.field + ), + } ), + h + ? a.current?.focus() + : i.current?.focus(); + }, + children: ( 0, c.jsx )( t.Icon, { icon: fr } ), + } ), + } ), + ( 0, c.jsx )( uc, { children: y } ), + ], + } ), + ], + } ), + renderContent: () => + ( 0, c.jsxs )( Pe, { + direction: 'column', + justify: 'flex-start', + children: [ + ( 0, c.jsx )( lm, { ...s } ), + s.filter.hasElements + ? ( 0, c.jsx )( nm, { + ...s, + filter: { ...s.filter, elements: g }, + } ) + : ( 0, c.jsx )( rm, { ...s, fields: o } ), + ], + } ), + } ); + } + function um( { filters: e, view: i, onChangeView: r } ) { + const o = + ! i.search && + ! i.filters?.some( t => { + return ! ( + t.isLocked || + ( void 0 === t.value && + ( ( n = t.field ), e.some( e => e.field === n && e.isPrimary ) ) ) + ); + var n; + } ); + return ( 0, c.jsx )( t.Button, { + disabled: o, + accessibleWhenDisabled: ! 0, + size: 'compact', + variant: 'tertiary', + className: 'dataviews-filters__reset-button', + onClick: () => { + r( { + ...i, + page: 1, + search: '', + filters: i.filters?.filter( e => !! e.isLocked ) || [], + } ); + }, + children: ( 0, n.__ )( 'Reset' ), + } ); + } + var dm = function ( t, n ) { + return ( 0, e.useMemo )( () => { + const e = []; + return ( + t.forEach( t => { + if ( ! 1 === t.filterBy || ( ! t.hasElements && ! t.Edit ) ) return; + const i = t.filterBy.operators, + r = !! t.filterBy?.isPrimary, + o = + n.filters?.some( e => e.field === t.id && !! e.isLocked ) ?? + ! 1; + e.push( { + field: t.id, + name: t.label, + elements: t.elements, + getElements: t.getElements, + hasElements: t.hasElements, + singleSelection: i.some( e => { + return ( + ( t = e ), + Ai.filter( e => 'single' === e.selection ).some( + e => e.name === t + ) + ); + var t; + } ), + operators: i, + isVisible: + o || + r || + !! n.filters?.some( e => { + return ( + e.field === t.id && + ( ( n = e.operator ), Ai.some( e => e.name === n ) ) + ); + var n; + } ), + isPrimary: r, + isLocked: o, + } ); + } ), + e.sort( ( e, t ) => + e.isLocked && ! t.isLocked + ? -1 + : ! e.isLocked && t.isLocked + ? 1 + : e.isPrimary && ! t.isPrimary + ? -1 + : ! e.isPrimary && t.isPrimary + ? 1 + : e.name.localeCompare( t.name ) + ), + e + ); + }, [ t, n ] ); + }, + fm = ( 0, e.memo )( function ( { className: t } ) { + const { + fields: n, + view: i, + onChangeView: r, + openedFilter: o, + setOpenedFilter: s, + } = ( 0, e.useContext )( Yi ), + a = ( 0, e.useRef )( null ), + l = dm( n, i ), + u = ( 0, c.jsx )( + Gc, + { filters: l, view: i, onChangeView: r, ref: a, setOpenedFilter: s }, + 'add-filter' + ), + d = l.filter( e => e.isVisible ); + if ( 0 === d.length ) return null; + const f = [ + ...d.map( e => + ( 0, c.jsx )( + cm, + { + filter: e, + view: i, + fields: n, + onChangeView: r, + addFilterRef: a, + openedFilter: o, + }, + e.field + ) + ), + u, + ]; + return ( + f.push( + ( 0, c.jsx )( + um, + { filters: l, view: i, onChangeView: r }, + 'reset-filters' + ) + ), + ( 0, c.jsx )( Pe, { + direction: 'row', + justify: 'flex-start', + gap: 'sm', + style: { width: 'fit-content' }, + wrap: 'wrap', + className: t, + children: f, + } ) + ); + } ), + mm = function ( t ) { + const { isShowingFilter: n } = ( 0, e.useContext )( Yi ); + return n ? ( 0, c.jsx )( fm, { ...t } ) : null; + }; + function pm( { className: i } ) { + const { + actions: r = [], + data: o, + fields: s, + getItemId: a, + getItemLevel: l, + hasInitiallyLoaded: u, + isLoading: d, + view: f, + onChangeView: m, + selection: p, + onChangeSelection: g, + setOpenedFilter: h, + onClickItem: v, + isItemClickable: b, + renderItemLink: w, + defaultLayouts: y, + containerRef: x, + empty: C = ( 0, c.jsx )( 'p', { children: ( 0, n.__ )( 'No results' ) } ), + } = ( 0, e.useContext )( Yi ), + S = Fr( ! u, { delay: 200 } ); + if ( ! u ) + return S + ? ( 0, c.jsx )( 'div', { + className: 'dataviews-loading', + children: ( 0, c.jsx )( 'p', { + children: ( 0, c.jsx )( t.Spinner, {} ), + } ), + } ) + : null; + const _ = $c.find( e => e.type === f.type && y[ e.type ] )?.component; + return ( 0, c.jsx )( 'div', { + className: 'dataviews-layout__container', + ref: x, + children: ( 0, c.jsx )( _, { + className: i, + actions: r, + data: o, + fields: s, + getItemId: a, + getItemLevel: l, + isLoading: d, + onChangeView: m, + onChangeSelection: g, + selection: p, + setOpenedFilter: h, + onClickItem: v, + renderItemLink: w, + isItemClickable: b, + view: f, + empty: C, + } ), + } ); + } + var gm = ( 0, c.jsx )( l.SVG, { + xmlns: 'http://www.w3.org/2000/svg', + viewBox: '0 0 24 24', + children: ( 0, c.jsx )( l.Path, { + d: 'M6.6 6L5.4 7l4.5 5-4.5 5 1.1 1 5.5-6-5.4-6zm6 0l-1.1 1 4.5 5-4.5 5 1.1 1 5.5-6-5.5-6z', + } ), + } ), + hm = ( 0, c.jsx )( l.SVG, { + xmlns: 'http://www.w3.org/2000/svg', + viewBox: '0 0 24 24', + children: ( 0, c.jsx )( l.Path, { + d: 'M11.6 7l-1.1-1L5 12l5.5 6 1.1-1L7 12l4.6-5zm6 0l-1.1-1-5.5 6 5.5 6 1.1-1-4.6-5 4.6-5z', + } ), + } ); + function vm() { + const { + view: i, + onChangeView: r, + paginationInfo: { totalItems: o = 0, totalPages: s }, + } = ( 0, e.useContext )( Yi ); + if ( ! o || ! s || i.infiniteScrollEnabled ) return null; + const a = i.page ?? 1, + l = Array.from( Array( s ) ).map( ( e, t ) => { + const i = t + 1; + return { + value: i.toString(), + label: i.toString(), + 'aria-label': + a === i + ? ( 0, n.sprintf )( + // translators: 1: current page number. 2: total number of pages. + // translators: 1: current page number. 2: total number of pages. + ( 0, n.__ )( 'Page %1$d of %2$d' ), + a, + s + ) + : i.toString(), + }; + } ); + return ( + !! o && + 1 !== s && + ( 0, c.jsxs )( Pe, { + direction: 'row', + className: 'dataviews-pagination', + justify: 'end', + align: 'center', + gap: 'xl', + children: [ + ( 0, c.jsx )( Pe, { + direction: 'row', + justify: 'flex-start', + align: 'center', + gap: 'xs', + className: 'dataviews-pagination__page-select', + children: ( 0, e.createInterpolateElement )( + ( 0, n.sprintf )( + // translators: 1: Current page number, 2: Total number of pages. + // translators: 1: Current page number, 2: Total number of pages. + ( 0, n._x )( + '
Page
%1$s
of %2$d
', + 'paging' + ), + '', + s + ), + { + div: ( 0, c.jsx )( 'div', { 'aria-hidden': ! 0 } ), + CurrentPage: ( 0, c.jsx )( t.SelectControl, { + 'aria-label': ( 0, n.__ )( 'Current page' ), + value: a.toString(), + options: l, + onChange: e => { + r( { ...i, page: +e } ); + }, + size: 'small', + variant: 'minimal', + } ), + } + ), + } ), + ( 0, c.jsxs )( Pe, { + direction: 'row', + gap: 'xs', + align: 'center', + children: [ + ( 0, c.jsx )( t.Button, { + onClick: () => r( { ...i, page: a - 1 } ), + disabled: 1 === a, + accessibleWhenDisabled: ! 0, + label: ( 0, n.__ )( 'Previous page' ), + icon: ( 0, n.isRTL )() ? gm : hm, + showTooltip: ! 0, + size: 'compact', + tooltipPosition: 'top', + } ), + ( 0, c.jsx )( t.Button, { + onClick: () => r( { ...i, page: a + 1 } ), + disabled: a >= s, + accessibleWhenDisabled: ! 0, + label: ( 0, n.__ )( 'Next page' ), + icon: ( 0, n.isRTL )() ? hm : gm, + showTooltip: ! 0, + size: 'compact', + tooltipPosition: 'top', + } ), + ], + } ), + ], + } ) + ); + } + var bm = ( 0, e.memo )( vm ), + wm = []; + function ym() { + const { + view: t, + paginationInfo: { totalItems: n = 0, totalPages: i }, + data: r, + actions: o = wm, + isLoading: s, + hasInitiallyLoaded: a, + } = ( 0, e.useContext )( Yi ), + l = !! s && a && !! r?.length, + u = Fr( !! l ), + d = gr( o, r ) && [ D, B ].includes( t.type ); + return l || ( n && i && ( ! ( i <= 1 ) || d ) ) + ? ( !! n || l ) && + ( 0, c.jsx )( 'div', { + className: 'dataviews-footer', + inert: l ? 'true' : void 0, + children: ( 0, c.jsxs )( Pe, { + direction: 'row', + justify: 'end', + align: 'center', + className: Te( 'dataviews-footer__content', { + 'is-refreshing': u, + } ), + gap: 'sm', + children: [ + d && ( 0, c.jsx )( Cr, {} ), + ( 0, c.jsx )( bm, {} ), + ], + } ), + } ) + : null; + } + var xm = ( 0, e.memo )( function ( { label: i } ) { + const { view: r, onChangeView: o } = ( 0, e.useContext )( Yi ), + [ s, a, l ] = ( 0, qi.useDebouncedInput )( r.search ); + ( 0, e.useEffect )( () => { + r.search !== l && a( r.search ?? '' ); + }, [ r.search, a ] ); + const u = ( 0, e.useRef )( o ), + d = ( 0, e.useRef )( r ); + ( 0, e.useEffect )( () => { + ( u.current = o ), ( d.current = r ); + }, [ o, r ] ), + ( 0, e.useEffect )( () => { + l !== d.current?.search && + u.current( { + ...d.current, + page: r.page ? 1 : void 0, + startPosition: r.startPosition ? 1 : void 0, + search: l, + } ); + }, [ l ] ); + const f = i || ( 0, n.__ )( 'Search' ); + return ( 0, c.jsx )( t.SearchControl, { + className: 'dataviews-search', + onChange: a, + value: s, + label: f, + placeholder: f, + size: 'compact', + } ); + } ), + Cm = ( 0, c.jsx )( l.SVG, { + xmlns: 'http://www.w3.org/2000/svg', + viewBox: '0 0 24 24', + children: ( 0, c.jsx )( l.Path, { + fillRule: 'evenodd', + clipRule: 'evenodd', + d: 'M10.289 4.836A1 1 0 0111.275 4h1.306a1 1 0 01.987.836l.244 1.466c.787.26 1.503.679 2.108 1.218l1.393-.522a1 1 0 011.216.437l.653 1.13a1 1 0 01-.23 1.273l-1.148.944a6.025 6.025 0 010 2.435l1.149.946a1 1 0 01.23 1.272l-.653 1.13a1 1 0 01-1.216.437l-1.394-.522c-.605.54-1.32.958-2.108 1.218l-.244 1.466a1 1 0 01-.987.836h-1.306a1 1 0 01-.986-.836l-.244-1.466a5.995 5.995 0 01-2.108-1.218l-1.394.522a1 1 0 01-1.217-.436l-.653-1.131a1 1 0 01.23-1.272l1.149-.946a6.026 6.026 0 010-2.435l-1.148-.944a1 1 0 01-.23-1.272l.653-1.131a1 1 0 011.217-.437l1.393.522a5.994 5.994 0 012.108-1.218l.244-1.466zM14.929 12a3 3 0 11-6 0 3 3 0 016 0z', + } ), + } ); + const Sm = window.wp.warning; + var { Menu: _m } = $( t.privateApis ), + jm = { className: 'dataviews-config__popover', placement: 'bottom-end', offset: 9 }; + function Em() { + const { view: i, onChangeView: r, defaultLayouts: o } = ( 0, e.useContext )( Yi ), + s = Object.keys( o ); + if ( s.length <= 1 ) return null; + const a = $c.find( e => i.type === e.type ); + return ( 0, c.jsxs )( _m, { + children: [ + ( 0, c.jsx )( _m.TriggerButton, { + render: ( 0, c.jsx )( t.Button, { + size: 'compact', + icon: a?.icon, + label: ( 0, n.__ )( 'Layout' ), + } ), + } ), + ( 0, c.jsx )( _m.Popover, { + children: s.map( e => { + const t = $c.find( t => t.type === e ); + return t + ? ( 0, c.jsx )( + _m.RadioItem, + { + value: e, + name: 'view-actions-available-view', + checked: e === i.type, + hideOnClick: ! 0, + onChange: e => { + switch ( e.target.value ) { + case 'list': + case 'grid': + case 'table': + case 'pickerGrid': + case 'pickerTable': + case 'activity': + const t = { ...i }; + return ( + 'layout' in t && delete t.layout, + r( { + ...t, + type: e.target.value, + ...o[ e.target.value ], + } ) + ); + } + Sm( 'Invalid dataview' ); + }, + children: ( 0, c.jsx )( _m.ItemLabel, { + children: t.label, + } ), + }, + e + ) + : null; + } ), + } ), + ], + } ); + } + function km() { + const { view: i, fields: r, onChangeView: o } = ( 0, e.useContext )( Yi ), + s = ( 0, e.useMemo )( + () => + r + .filter( e => ! 1 !== e.enableSorting ) + .map( e => ( { label: e.label, value: e.id } ) ), + [ r ] + ); + return ( 0, c.jsx )( t.SelectControl, { + __next40pxDefaultSize: ! 0, + label: ( 0, n.__ )( 'Sort by' ), + value: i.sort?.field, + options: s, + onChange: e => { + o( { + ...i, + sort: { direction: i?.sort?.direction || 'desc', field: e }, + showLevels: ! 1, + } ); + }, + } ); + } + function Im() { + const { view: i, fields: r, onChangeView: o } = ( 0, e.useContext )( Yi ); + if ( 0 === r.filter( e => ! 1 !== e.enableSorting ).length ) return null; + let s = i.sort?.direction; + return ( + ! s && i.sort?.field && ( s = 'desc' ), + ( 0, c.jsx )( t.__experimentalToggleGroupControl, { + className: 'dataviews-view-config__sort-direction', + __next40pxDefaultSize: ! 0, + isBlock: ! 0, + label: ( 0, n.__ )( 'Order' ), + value: s, + onChange: e => { + 'asc' !== e && 'desc' !== e + ? Sm( 'Invalid direction' ) + : o( { + ...i, + sort: { + direction: e, + field: + i.sort?.field || + r.find( e => ! 1 !== e.enableSorting )?.id || + '', + }, + showLevels: ! 1, + } ); + }, + children: N.map( e => + ( 0, c.jsx )( + t.__experimentalToggleGroupControlOptionIcon, + { value: e, icon: L[ e ], label: F[ e ] }, + e + ) + ), + } ) + ); + } + function Vm() { + const { view: i, config: r, onChangeView: o } = ( 0, e.useContext )( Yi ), + { infiniteScrollEnabled: s } = i; + return ! r || + ! r.perPageSizes || + r.perPageSizes.length < 2 || + r.perPageSizes.length > 6 || + s + ? null + : ( 0, c.jsx )( t.__experimentalToggleGroupControl, { + __next40pxDefaultSize: ! 0, + isBlock: ! 0, + label: ( 0, n.__ )( 'Items per page' ), + value: i.perPage || 10, + disabled: ! i?.sort?.field, + onChange: e => { + const t = + 'number' == typeof e || void 0 === e ? e : parseInt( e, 10 ); + o( { ...i, perPage: t, page: 1 } ); + }, + children: r.perPageSizes.map( e => + ( 0, c.jsx )( + t.__experimentalToggleGroupControlOption, + { value: e, label: e.toString() }, + e + ) + ), + } ); + } + function Om() { + const { onReset: i } = ( 0, e.useContext )( Yi ); + if ( void 0 === i ) return null; + const r = ! 1 === i; + return ( 0, c.jsx )( t.Button, { + variant: 'tertiary', + size: 'compact', + disabled: r, + accessibleWhenDisabled: ! 0, + className: 'dataviews-view-config__reset-button', + onClick: () => { + 'function' == typeof i && i(); + }, + children: ( 0, n.__ )( 'Reset view' ), + } ); + } + function Pm() { + const { view: i, onReset: r } = ( 0, e.useContext )( Yi ), + o = ( 0, qi.useInstanceId )( Mm, 'dataviews-view-config-dropdown' ), + s = $c.find( e => e.type === i.type ), + a = 'function' == typeof r; + return ( 0, c.jsx )( t.Dropdown, { + expandOnMobile: ! 0, + popoverProps: { ...jm, id: o }, + renderToggle: ( { onToggle: e, isOpen: i } ) => + ( 0, c.jsxs )( 'div', { + className: 'dataviews-view-config__toggle-wrapper', + children: [ + ( 0, c.jsx )( t.Button, { + size: 'compact', + icon: Cm, + label: ( 0, n._x )( 'View options', 'View is used as a noun' ), + onClick: e, + 'aria-expanded': i ? 'true' : 'false', + 'aria-controls': o, + } ), + a && + ( 0, c.jsx )( 'span', { + className: 'dataviews-view-config__modified-indicator', + } ), + ], + } ), + renderContent: () => + ( 0, c.jsx )( t.__experimentalDropdownContentWrapper, { + paddingSize: 'medium', + className: 'dataviews-config__popover-content-wrapper', + children: ( 0, c.jsxs )( Pe, { + direction: 'column', + className: 'dataviews-view-config', + gap: 'xl', + children: [ + ( 0, c.jsxs )( Pe, { + direction: 'row', + justify: 'space-between', + align: 'center', + className: 'dataviews-view-config__header', + children: [ + ( 0, c.jsx )( t.__experimentalHeading, { + level: 2, + className: 'dataviews-settings-section__title', + children: ( 0, n.__ )( 'Appearance' ), + } ), + ( 0, c.jsx )( Om, {} ), + ], + } ), + ( 0, c.jsxs )( Pe, { + direction: 'column', + gap: 'lg', + children: [ + ( 0, c.jsxs )( Pe, { + direction: 'row', + gap: 'sm', + className: 'dataviews-view-config__sort-controls', + children: [ + ( 0, c.jsx )( km, {} ), + ( 0, c.jsx )( Im, {} ), + ], + } ), + !! s?.viewConfigOptions && + ( 0, c.jsx )( s.viewConfigOptions, {} ), + ( 0, c.jsx )( Vm, {} ), + ( 0, c.jsx )( Rr, {} ), + ], + } ), + ], + } ), + } ), + } ); + } + function Mm() { + return ( 0, c.jsxs )( c.Fragment, { + children: [ ( 0, c.jsx )( Em, {} ), ( 0, c.jsx )( Pm, {} ) ], + } ); + } + var Tm = ( 0, e.memo )( Mm ); + function Nm( e, t, n ) { + const i = e.getBoundingClientRect(), + r = i.top + i.height / 2, + o = Array.from( e.querySelectorAll( '[aria-posinset]' ) ); + if ( 0 === o.length ) return ! 1; + const s = o.reduce( ( e, t ) => { + const n = t.getBoundingClientRect(), + i = n.top + n.height / 2, + o = Math.abs( i - r ), + s = e.getBoundingClientRect(), + a = s.top + s.height / 2; + return o < Math.abs( a - r ) ? t : e; + } ), + a = Number( s.getAttribute( 'aria-posinset' ) ), + l = s.getBoundingClientRect(); + return ( + ( t.current = { posinset: a, viewportOffset: l.top - i.top, direction: n } ), + ! 0 + ); + } + var Am = e => e.id, + Rm = () => ! 0, + Fm = [], + Lm = { table: {}, grid: {}, list: {} }, + Dm = $c.filter( e => ! e.isPicker ); + function Bm( { header: t, search: n = ! 0, searchLabel: i } ) { + const { view: r } = ( 0, e.useContext )( Yi ), + o = r.infiniteScrollEnabled; + return ( 0, c.jsxs )( c.Fragment, { + children: [ + ( 0, c.jsxs )( Pe, { + direction: 'row', + align: 'top', + justify: 'space-between', + className: Te( 'dataviews__view-actions', { + 'dataviews__view-actions--infinite-scroll': o, + } ), + gap: 'xs', + children: [ + ( 0, c.jsxs )( Pe, { + direction: 'row', + justify: 'start', + gap: 'sm', + className: 'dataviews__search', + children: [ + n && ( 0, c.jsx )( xm, { label: i } ), + ( 0, c.jsx )( Kc, {} ), + ], + } ), + ( 0, c.jsxs )( Pe, { + direction: 'row', + gap: 'xs', + style: { flexShrink: 0 }, + children: [ ( 0, c.jsx )( Tm, {} ), t ], + } ), + ], + } ), + ( 0, c.jsx )( mm, { className: 'dataviews-filters__container' } ), + ( 0, c.jsx )( pm, {} ), + ( 0, c.jsx )( ym, {} ), + ], + } ); + } + var zm = function ( { + view: t, + onChangeView: n, + fields: i, + search: r = ! 0, + searchLabel: o, + actions: s = Fm, + data: a, + getItemId: l = Am, + getItemLevel: u, + isLoading: d = ! 1, + paginationInfo: f, + defaultLayouts: m = Lm, + selection: p, + onChangeSelection: g, + onClickItem: h, + renderItemLink: v, + isItemClickable: b = Rm, + header: w, + children: y, + config: x = { perPageSizes: [ 10, 20, 50, 100 ] }, + empty: C, + onReset: S, + } ) { + const [ _, j ] = ( 0, e.useState )( [] ), + E = void 0 === p || void 0 === g, + k = E ? _ : p, + { + data: I, + paginationInfo: V, + hasInitiallyLoaded: O, + setVisibleEntries: P, + } = ( function ( { + view: t, + data: n, + getItemId: i, + isLoading: r, + paginationInfo: o, + selection: s, + } ) { + const a = t.infiniteScrollEnabled, + [ l, c ] = ( 0, e.useState )( ! r ); + ( 0, e.useEffect )( () => { + r || c( ! 0 ); + }, [ r ] ); + const u = ( 0, e.useRef )( n ), + d = ( 0, e.useRef )( o ); + ( 0, e.useEffect )( () => { + r || ( ( u.current = n ), ( d.current = o ) ); + }, [ n, r, o ] ); + const [ f, m ] = ( 0, e.useState )( [] ), + p = ( 0, e.useRef )( new Map() ), + g = ( 0, e.useRef )( [] ), + h = ( 0, e.useRef )( { + search: void 0, + filters: void 0, + perPage: void 0, + } ), + v = ( 0, e.useRef )( void 0 ), + b = ( 0, e.useRef )( void 0 ), + w = ( 0, e.useRef )( ! 1 ), + y = ( 0, e.useMemo )( () => { + void 0 !== t.startPosition && + void 0 !== b.current && + ( t.startPosition < b.current + ? ( v.current = 'up' ) + : t.startPosition > b.current && ( v.current = 'down' ) ), + ( b.current = t.startPosition ); + const e = JSON.stringify( t.filters ?? [] ), + r = h.current.filters, + o = + ! w.current || + ! t.infiniteScrollEnabled || + t.search !== h.current.search || + e !== r || + t.perPage !== h.current.perPage; + if ( + ( ( w.current = ! 0 ), + ( h.current = { + search: t.search, + filters: e, + perPage: t.perPage, + } ), + o ) + ) { + p.current.clear(), ( v.current = void 0 ); + const e = t.search ? 1 : t.startPosition ?? 1, + r = n.map( ( t, n ) => { + const r = e + n; + return ( + p.current.set( i( t ), r ), { ...t, position: r } + ); + } ); + return ( g.current = r ), r; + } + const a = g.current, + l = new Set( n.map( i ) ), + c = v.current, + u = t.search ? 1 : t.startPosition ?? 1, + d = n.map( ( e, n ) => { + const r = i( e ), + o = t.infiniteScrollEnabled ? u + n : void 0; + return ( + void 0 !== o && p.current.set( r, o ), + { ...e, position: o } + ); + } ); + if ( 0 === d.length ) return a; + const m = a.filter( e => ! l.has( i( e ) ) ), + y = 'up' === c ? [ ...d, ...m ] : [ ...m, ...d ]; + y.sort( ( e, t ) => e.position - t.position ); + let x = y; + if ( f.length > 0 ) { + const e = Math.min( ...f ), + t = Math.max( ...f ), + n = 20, + r = y.map( e => e.position ), + o = Math.min( ...r ); + ! ( Math.max( ...r ) < e - n || o > t + n ) && + ( x = y.filter( r => { + const o = i( r ), + a = s?.includes( o ); + if ( a ) return ! 0; + const l = r.position; + return 'up' === c + ? l <= t + n + : 'down' === c + ? l >= e - n + : l >= e - n && l <= t + n; + } ) ); + } + return ( g.current = x ), x; + }, [ + n, + t.search, + t.filters, + t.perPage, + t.startPosition, + t.infiniteScrollEnabled, + f, + s, + i, + ] ); + return a + ? { + data: y, + paginationInfo: o, + hasInitiallyLoaded: l, + setVisibleEntries: m, + } + : { + data: ( r && u.current?.length ? u.current : n ).map( e => ( { + ...e, + position: void 0, + } ) ), + paginationInfo: r && u.current?.length ? d.current : o, + hasInitiallyLoaded: l, + setVisibleEntries: void 0, + }; + } )( { + view: t, + data: a, + getItemId: l, + isLoading: d, + selection: k, + paginationInfo: f, + } ), + M = ( 0, e.useRef )( null ), + [ T, N ] = ( 0, e.useState )( 0 ), + A = ( 0, qi.useResizeObserver )( + e => { + N( e[ 0 ].borderBoxSize[ 0 ].inlineSize ); + }, + { box: 'border-box' } + ), + [ R, F ] = ( 0, e.useState )( null ), + L = ( 0, e.useMemo )( () => Wi( i ), [ i ] ), + D = ( 0, e.useMemo )( + () => + t.infiniteScrollEnabled + ? k + : k.filter( e => a.some( t => l( t ) === e ) ), + [ k, a, l, t.infiniteScrollEnabled ] + ), + B = dm( L, t ), + z = ( 0, e.useMemo )( + () => ( B || [] ).some( e => e.isPrimary || e.isLocked ), + [ B ] + ), + [ W, $ ] = ( 0, e.useState )( z ), + { intersectionObserver: H } = ( function ( { + view: t, + onChangeView: n, + isLoading: i, + paginationInfo: r, + containerRef: o, + setVisibleEntries: s, + } ) { + const a = ( 0, e.useRef )( null ), + l = ( 0, e.useRef )( t ), + c = ( 0, e.useRef )( i ), + u = ( 0, e.useRef )( n ), + d = ( 0, e.useRef )( r.totalItems ); + ( 0, e.useLayoutEffect )( () => { + ( l.current = t ), + ( c.current = i ), + ( u.current = n ), + ( d.current = r.totalItems ); + }, [ t, i, n, r.totalItems ] ); + const f = ( 0, e.useCallback )( + e => { + s && + s( t => { + const n = new Set( t ); + let i = ! 1; + return ( + e.forEach( e => { + const t = Number( + e.target?.attributes?.getNamedItem( + 'aria-posinset' + )?.value + ); + isNaN( t ) || + ( e.isIntersecting + ? n.has( t ) || ( n.add( t ), ( i = ! 0 ) ) + : n.has( t ) && + ( n.delete( t ), ( i = ! 0 ) ) ); + } ), + i ? Array.from( n ).sort() : t + ); + } ); + }, + [ s ] + ); + ( 0, e.useLayoutEffect )( () => { + const e = o.current, + n = a.current; + if ( ! e || ! t.infiniteScrollEnabled || ! n || i ) return; + const r = e.querySelector( `[aria-posinset="${ n.posinset }"]` ); + if ( r ) { + const t = e.getBoundingClientRect(), + i = r.getBoundingClientRect().top - t.top - n.viewportOffset; + Math.abs( i ) > 1 && ( e.scrollTop += i ); + } + a.current = null; + }, [ o, i, t.infiniteScrollEnabled ] ); + const m = ( 0, e.useRef )( null ); + return ( + ( 0, e.useEffect )( () => { + if ( t.infiniteScrollEnabled && f ) + return ( + ( m.current = new IntersectionObserver( f, { + root: null, + rootMargin: '0px', + threshold: 0.1, + } ) ), + () => { + m.current && + ( m.current.disconnect(), ( m.current = null ) ); + } + ); + m.current && ( m.current.disconnect(), ( m.current = null ) ); + }, [ t.infiniteScrollEnabled, f ] ), + ( 0, e.useEffect )( () => { + if ( ! t.infiniteScrollEnabled || ! o.current ) return; + let e = 0; + const n = ( 0, qi.throttle )( t => { + const n = l.current, + i = d.current, + r = t.target, + o = r.scrollTop, + s = r.scrollHeight, + f = r.clientHeight, + m = o > e ? 'down' : 'up'; + if ( ( ( e = o ), c.current ) ) return; + const p = n.startPosition || 1, + g = n.perPage || 10, + h = Math.min( p + g, i ); + if ( 'down' === m && o + f >= s - 600 && h < i ) { + const e = h; + Nm( r, a, 'down' ), + u.current( { ...n, startPosition: e } ); + } + if ( 'up' === m && o <= 800 && p > 1 ) { + const e = p - g, + t = e < 6 ? 1 : e; + Nm( r, a, 'up' ), + u.current( { ...n, startPosition: t } ); + } + }, 50 ), + i = o.current; + return ( + i.addEventListener( 'scroll', n ), + () => { + i.removeEventListener( 'scroll', n ), n.cancel(); + } + ); + }, [ o, t.infiniteScrollEnabled ] ), + { intersectionObserver: m.current } + ); + } )( { + view: t, + onChangeView: n, + isLoading: d, + paginationInfo: f, + containerRef: M, + setVisibleEntries: P, + } ); + ( 0, e.useEffect )( () => { + z && ! W && $( ! 0 ); + }, [ z, W ] ); + const q = ( 0, e.useMemo )( + () => + Object.fromEntries( + Object.entries( m ) + .filter( ( [ e ] ) => Dm.some( t => t.type === e ) ) + .map( ( [ e, t ] ) => [ e, ! 0 === t ? {} : t ] ) + ), + [ m ] + ); + return q[ t.type ] + ? ( 0, c.jsx )( Yi.Provider, { + value: { + view: t, + onChangeView: n, + fields: L, + actions: s, + data: I, + isLoading: d, + paginationInfo: V, + selection: D, + onChangeSelection: function ( e ) { + const t = 'function' == typeof e ? e( k ) : e; + E && j( t ), g && g( t ); + }, + openedFilter: R, + setOpenedFilter: F, + getItemId: l, + getItemLevel: u, + isItemClickable: b, + onClickItem: h, + renderItemLink: v, + containerWidth: T, + containerRef: M, + resizeObserverRef: A, + defaultLayouts: q, + filters: B, + isShowingFilter: W, + setIsShowingFilter: $, + config: x, + empty: C, + hasInitiallyLoaded: O, + onReset: S, + intersectionObserver: H, + }, + children: ( 0, c.jsx )( 'div', { + className: 'dataviews-wrapper', + children: + y ?? + ( 0, c.jsx )( Bm, { header: w, search: r, searchLabel: o } ), + } ), + } ) + : null; + }; + ( zm.BulkActionToolbar = Cr ), + ( zm.Filters = fm ), + ( zm.FiltersToggled = mm ), + ( zm.FiltersToggle = Kc ), + ( zm.Layout = pm ), + ( zm.LayoutSwitcher = Em ), + ( zm.Pagination = vm ), + ( zm.Search = xm ), + ( zm.ViewConfig = Pm ), + ( zm.Footer = ym ); + var Wm = zm; + const { blockTitles: $m = {}, postTypeLabels: Hm = {} } = + window.validationApiSettings || {}, + qm = [ + { value: 'error', label: ( 0, n.__ )( 'Error', 'validation-api-settings' ) }, + { + value: 'warning', + label: ( 0, n.__ )( 'Warning', 'validation-api-settings' ), + }, + { value: 'none', label: ( 0, n.__ )( 'Disabled', 'validation-api-settings' ) }, + ]; + function Gm( { value: e, onChange: i } ) { + return ( 0, c.jsx )( t.SelectControl, { + __nextHasNoMarginBottom: ! 0, + label: ( 0, n.__ )( 'Level', 'validation-api-settings' ), + hideLabelFromVision: ! 0, + value: e, + options: qm, + onChange: i, + } ); + } + const Ym = { + type: 'table', + search: '', + filters: [], + page: 1, + perPage: 25, + sort: { field: 'target', direction: 'asc' }, + titleField: 'target', + descriptionField: 'description', + fields: [ 'check_type', 'plugin_name', 'level' ], + }; + function Km() { + const [ i, r ] = ( 0, e.useState )( [] ), + [ s, l ] = ( 0, e.useState )( ! 0 ), + [ u, d ] = ( 0, e.useState )( ! 1 ), + [ f, m ] = ( 0, e.useState )( ! 1 ), + [ p, h ] = ( 0, e.useState )( null ), + [ v, b ] = ( 0, e.useState )( Ym ); + ( 0, e.useEffect )( () => { + ! ( async function () { + try { + const [ e, t ] = await Promise.all( [ + o()( { path: '/wp-validation/v1/checks' } ), + o()( { path: '/validation-api-settings/v1/validation-settings' } ), + ] ); + r( + ( function ( e, t ) { + const n = []; + if ( e.block ) + for ( const [ i, r ] of Object.entries( e.block ) ) + for ( const [ e, o ] of Object.entries( r ) ) { + if ( ! 1 === o.configurable ) continue; + const r = t?.block?.[ i ]?.[ e ] ?? null; + n.push( { + id: `block__${ i }__${ e }`, + scope: 'block', + block_type: i, + check_name: e, + description: o.description || '', + check_type: 'Block', + target: $m[ i ] || i, + plugin_name: o._namespace || '—', + level: r ?? o.level, + default_level: o.level, + has_override: null !== r, + } ); + } + if ( e.meta ) + for ( const [ i, r ] of Object.entries( e.meta ) ) + for ( const [ e, o ] of Object.entries( r ) ) + for ( const [ r, s ] of Object.entries( o ) ) { + if ( ! 1 === s.configurable ) continue; + const o = t?.meta?.[ i ]?.[ e ]?.[ r ] ?? null; + n.push( { + id: `meta__${ i }__${ e }__${ r }`, + scope: 'meta', + post_type: i, + meta_key: e, + check_name: r, + description: s.description || '', + check_type: 'Meta', + target: `${ e } (${ Hm[ i ] || i })`, + plugin_name: s._namespace || '—', + level: o ?? s.level, + default_level: s.level, + has_override: null !== o, + } ); + } + if ( e.editor ) + for ( const [ i, r ] of Object.entries( e.editor ) ) + for ( const [ e, o ] of Object.entries( r ) ) { + if ( ! 1 === o.configurable ) continue; + const r = t?.editor?.[ i ]?.[ e ] ?? null; + n.push( { + id: `editor__${ i }__${ e }`, + scope: 'editor', + post_type: i, + check_name: e, + description: o.description || '', + check_type: 'Editor', + target: Hm[ i ] || i, + plugin_name: o._namespace || '—', + level: r ?? o.level, + default_level: o.level, + has_override: null !== r, + } ); + } + return n; + } )( e, t ) + ); + } catch ( e ) { + h( { + status: 'error', + message: + e.message || + ( 0, n.__ )( + 'Failed to load checks.', + 'validation-api-settings' + ), + } ); + } finally { + l( ! 1 ); + } + } )(); + }, [] ), + ( 0, e.useEffect )( () => { + const e = e => { + f && e.preventDefault(); + }; + return ( + window.addEventListener( 'beforeunload', e ), + () => window.removeEventListener( 'beforeunload', e ) + ); + }, [ f ] ); + const w = ( 0, e.useCallback )( ( e, t ) => { + r( n => + n.map( n => + n.id !== e + ? n + : { ...n, level: t, has_override: t !== n.default_level } + ) + ), + m( ! 0 ); + }, [] ), + y = ( 0, e.useCallback )( e => { + const t = new Set( e.map( e => e.id ) ); + r( e => + e.map( e => + t.has( e.id ) + ? { ...e, level: e.default_level, has_override: ! 1 } + : e + ) + ), + m( ! 0 ); + }, [] ), + x = ( 0, e.useCallback )( async () => { + d( ! 0 ), h( null ); + try { + const e = ( function ( e ) { + const t = {}; + for ( const n of e ) + if ( n.has_override ) + switch ( n.scope ) { + case 'block': + t.block || ( t.block = {} ), + t.block[ n.block_type ] || + ( t.block[ n.block_type ] = {} ), + ( t.block[ n.block_type ][ n.check_name ] = + n.level ); + break; + case 'meta': + t.meta || ( t.meta = {} ), + t.meta[ n.post_type ] || + ( t.meta[ n.post_type ] = {} ), + t.meta[ n.post_type ][ n.meta_key ] || + ( t.meta[ n.post_type ][ n.meta_key ] = + {} ), + ( t.meta[ n.post_type ][ n.meta_key ][ + n.check_name + ] = n.level ); + break; + case 'editor': + t.editor || ( t.editor = {} ), + t.editor[ n.post_type ] || + ( t.editor[ n.post_type ] = {} ), + ( t.editor[ n.post_type ][ n.check_name ] = + n.level ); + } + return t; + } )( i ); + await o()( { + path: '/validation-api-settings/v1/validation-settings', + method: 'POST', + data: e, + } ), + m( ! 1 ), + h( { + status: 'success', + message: ( 0, n.__ )( + 'Settings saved successfully.', + 'validation-api-settings' + ), + } ); + } catch ( e ) { + h( { + status: 'error', + message: + e.message || + ( 0, n.__ )( + 'Failed to save settings.', + 'validation-api-settings' + ), + } ); + } finally { + d( ! 1 ); + } + }, [ i ] ), + C = ( 0, e.useMemo )( () => { + const e = [ ...new Set( i.map( e => e.plugin_name ) ) ].sort(); + return e.map( e => ( { value: e, label: e } ) ); + }, [ i ] ), + S = ( 0, e.useMemo )( + () => [ + { + id: 'description', + label: ( 0, n.__ )( 'Description', 'validation-api-settings' ), + enableGlobalSearch: ! 0, + enableSorting: ! 1, + enableHiding: ! 1, + }, + { + id: 'target', + label: ( 0, n.__ )( 'Target', 'validation-api-settings' ), + enableGlobalSearch: ! 0, + enableSorting: ! 0, + }, + { + id: 'check_type', + label: ( 0, n.__ )( 'Check Type', 'validation-api-settings' ), + enableSorting: ! 0, + elements: [ + { + value: 'Block', + label: ( 0, n.__ )( 'Block', 'validation-api-settings' ), + }, + { + value: 'Meta', + label: ( 0, n.__ )( 'Meta', 'validation-api-settings' ), + }, + { + value: 'Editor', + label: ( 0, n.__ )( 'Editor', 'validation-api-settings' ), + }, + ], + filterBy: { isPrimary: ! 0, operators: [ 'is' ] }, + }, + { + id: 'plugin_name', + label: ( 0, n.__ )( 'Plugin', 'validation-api-settings' ), + enableSorting: ! 0, + enableGlobalSearch: ! 0, + elements: C, + filterBy: { operators: [ 'is' ] }, + }, + { + id: 'level', + label: ( 0, n.__ )( 'Level', 'validation-api-settings' ), + elements: [ + { + value: 'error', + label: ( 0, n.__ )( 'Error', 'validation-api-settings' ), + }, + { + value: 'warning', + label: ( 0, n.__ )( 'Warning', 'validation-api-settings' ), + }, + { + value: 'none', + label: ( 0, n.__ )( 'Disabled', 'validation-api-settings' ), + }, + ], + filterBy: { isPrimary: ! 0, operators: [ 'is' ] }, + render: ( { item: e } ) => + ( 0, c.jsx )( Gm, { + value: e.level, + onChange: t => w( e.id, t ), + } ), + }, + ], + [ C, w ] + ), + _ = ( 0, e.useMemo )( + () => [ + { + id: 'reset-to-default', + label: ( 0, n.__ )( 'Reset to default', 'validation-api-settings' ), + isEligible: e => e.has_override, + callback: e => y( e ), + }, + ], + [ y ] + ), + { data: j, paginationInfo: E } = ( 0, e.useMemo )( + () => + ( function ( e, t, n ) { + if ( ! e ) + return { + data: Hi, + paginationInfo: { totalItems: 0, totalPages: 0 }, + }; + const i = Wi( n ); + let r = [ ...e ]; + if ( t.search ) { + const e = $i( t.search ); + r = r.filter( t => + i + .filter( e => e.enableGlobalSearch ) + .some( n => { + const i = n.getValue( { item: t } ); + return ( Array.isArray( i ) ? i : [ i ] ).some( t => + $i( String( t ) ).includes( e ) + ); + } ) + ); + } + t.filters && + t.filters?.length > 0 && + t.filters.forEach( e => { + const t = i.find( t => t.id === e.field ); + if ( t ) { + e.operator === g && + a( "The 'isNotAll' filter operator", { + since: '7.0', + alternative: "'isNone'", + } ); + const n = t.filter[ e.operator ]; + n && ( r = r.filter( i => n( i, t, e.value ) ) ); + } + } ); + const o = t.sort?.field + ? i.find( + e => + ! 1 !== e.enableSorting && + e.id === t.sort?.field + ) + : null, + s = t.groupBy?.field + ? i.find( + e => + ! 1 !== e.enableSorting && + e.id === t.groupBy?.field + ) + : null; + ( o || s ) && + r.sort( ( e, n ) => { + if ( s ) { + const i = s.sort( e, n, t.groupBy?.direction ?? 'asc' ); + if ( 0 !== i ) return i; + } + return o ? o.sort( e, n, t.sort?.direction ?? 'desc' ) : 0; + } ); + let l = r.length, + c = 1; + if ( + t.infiniteScrollEnabled && + void 0 !== t.startPosition && + void 0 !== t.perPage + ) { + const e = t.startPosition - 1, + n = Math.min( e + t.perPage, l ); + r = r?.slice( e, n ); + } else if ( void 0 !== t.page && void 0 !== t.perPage ) { + const e = ( t.page - 1 ) * t.perPage; + ( l = r?.length || 0 ), + ( c = Math.ceil( l / t.perPage ) ), + ( r = r?.slice( e, e + t.perPage ) ); + } + return { + data: r, + paginationInfo: { totalItems: l, totalPages: c }, + }; + } )( i, v, S ), + [ i, v, S ] + ); + return s + ? ( 0, c.jsxs )( 'div', { + className: 'validation-api-settings', + children: [ + ( 0, c.jsx )( t.Spinner, {} ), + ( 0, c.jsx )( t.VisuallyHidden, { + children: ( 0, n.__ )( + 'Loading checks…', + 'validation-api-settings' + ), + } ), + ], + } ) + : ( 0, c.jsxs )( 'div', { + className: 'validation-api-settings', + children: [ + ( 0, c.jsxs )( 'div', { + className: 'validation-api-settings__header', + children: [ + ( 0, c.jsx )( 'h1', { + children: ( 0, n.__ )( + 'Validation API Settings', + 'validation-api-settings' + ), + } ), + ( 0, c.jsx )( t.Button, { + variant: 'primary', + onClick: x, + isBusy: u, + disabled: ! f || u, + children: ( 0, n.__ )( + 'Save Changes', + 'validation-api-settings' + ), + } ), + ], + } ), + p && + ( 0, c.jsx )( t.Notice, { + status: p.status, + isDismissible: ! 0, + onDismiss: () => h( null ), + children: p.message, + } ), + 0 === i.length + ? ( 0, c.jsx )( t.Notice, { + status: 'warning', + isDismissible: ! 1, + children: ( 0, n.__ )( + 'No validation checks are registered. Activate plugins that register checks with the Validation API.', + 'validation-api-settings' + ), + } ) + : ( 0, c.jsx )( Wm, { + data: j, + fields: S, + view: v, + onChangeView: b, + paginationInfo: E, + actions: _, + defaultLayouts: { table: {} }, + } ), + ], + } ); + } + const Um = document.getElementById( 'validation-api-settings-root' ); + Um && ( 0, e.createRoot )( Um ).render( ( 0, c.jsx )( Km, {} ) ); + } )(); +} )();