From 278f00526fdf928e07a989077bc80beffc79e3e0 Mon Sep 17 00:00:00 2001 From: fahimreza-dev Date: Tue, 13 Oct 2026 05:07:49 +0600 Subject: [PATCH 1/2] fix(updates): major WordPress releases need Saddle's own setting (#359) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit update-core applied a major release when WordPress's "automatic updates for all new versions" switch was on. WordPress turns that on by default for sites installed since 5.6, so on most sites the owner never chose it, and it decides what WordPress does unattended, not what an app may do after a preview. - New setting "Major WordPress releases" in Saddle → Settings → Updates, off by default. agent: read, and its option is protected, so no tool and no module setter can turn it on. - update-core applies a major only when it is on, whatever WordPress's own switch says. Minor and security releases are unchanged. - The runner checks it again when the run starts: turned off after the confirm, the update is skipped and logged. - Copy: tool description, refusal, context line, readme, CLAUDE.md hard line, ROADMAP. .pot regenerated. Closes #359 Co-Authored-By: Claude Opus 5.5 --- CLAUDE.md | 17 +-- ROADMAP.md | 4 +- includes/abilities/core-updates.php | 30 +++--- includes/class-saddle-context.php | 2 +- includes/class-saddle-core-settings.php | 15 ++- includes/class-saddle-offer-runner.php | 42 ++++++++ includes/class-saddle-settings-guard.php | 1 + languages/saddle.pot | 126 +++++++++++++---------- readme.txt | 4 +- tests/core-updates-test.php | 95 +++++++++++++---- tests/module-abilities-test.php | 8 +- tests/settings-registry-test.php | 4 +- 12 files changed, 244 insertions(+), 104 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index 82f1984..fa54dd4 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -147,11 +147,13 @@ dry-run, no diff and no revert. confirmed preview. It never takes a zip, a URL or a file. A new install arrives inactive. Saddle applies core updates only for releases WordPress already offers, through core's automatic updater: minor and security - releases, and a major release only when WordPress would apply it in the - background itself: its own "automatic updates for all new versions" switch - in Dashboard → Updates, which no tool can flip (on by default for sites - installed since WordPress 5.6). Translation updates go through - core's language pack upgrader. Saddle never deletes a plugin or theme. It + releases, and a major release only when the owner has turned on Saddle's + own "Major WordPress releases" setting in Saddle → Settings, which is off by + default and which no tool can change. WordPress's own "automatic updates + for all new versions" switch does not count: it is on by default for sites + installed since 5.6, and it decides only what WordPress does unattended. + Translation updates go through core's language pack upgrader. Saddle never + deletes a plugin or theme. It still never writes a file and never picks a package URL: the package is the one the WordPress.org API names, exactly as on the Add New screen, and a package from anywhere else is refused. @@ -160,8 +162,9 @@ dry-run, no diff and no revert. auto-update switch is WordPress's own option. Updates decided 2026-09-27 evening on Fahim's "research, then take the decision", replacing the same morning's "reported, never run"; installs, core and translations added - 2026-10-12 (#347, Fahim: majors only behind WordPress's own switch; #351 - found that the switch defaults to on for new installs). Applies + 2026-10-12 (#347). Majors were first behind WordPress's own switch (#351); + that switch defaults to on for new installs, so on 2026-10-13 Fahim had + majors moved behind Saddle's own setting, off by default (#359). Applies to Pro too. If a feature seems to need any of these, that is a signal to redesign the diff --git a/ROADMAP.md b/ROADMAP.md index 05aeae2..83f2957 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -64,8 +64,8 @@ when it is picked up; this file names direction, not tickets. the WordPress.org directory, by slug, through WordPress's own installer in the background runner, and arrive inactive; activating stays its own confirmed step, and nothing deletes. Core updates are minor and security - releases, plus a major release only when WordPress's own switch for all - new versions is on (the default since WordPress 5.6 for new installs). No zip or URL + releases, plus a major release only when the owner turns on "Major + WordPress releases" in Saddle → Settings, off by default (#359). No zip or URL installs, no file editors, no delete tools. The hard line was rewritten first (#347). 3. **The agency workflow.** Divi 5 page editing moves to free (2026-09-26 split: diff --git a/includes/abilities/core-updates.php b/includes/abilities/core-updates.php index 808b599..bd560a1 100644 --- a/includes/abilities/core-updates.php +++ b/includes/abilities/core-updates.php @@ -7,13 +7,14 @@ * release WordPress already offers for background updates, through * {@see WP_Automatic_Updater::update()} in {@see Saddle_Update_Runner}, out of * band, after a confirmed preview. Minor and security releases, always. A - * major release only when WordPress itself would apply it in the background - * (Fahim, 2026-10-12): its own switch in Dashboard → Updates, "automatic - * updates for all new versions", which no tool can flip. That switch is on by - * default for sites installed since WordPress 5.6 and "unset" (minor only) - * for sites upgraded from before; an owner who chose "maintenance and - * security releases only" gets every major refused. A major has no automatic - * rollback and upgrades the database, so Saddle never goes past that switch. + * major release only when the owner has turned on Saddle's own setting, + * "Major WordPress releases" in Saddle → Settings, which is off by default + * and which no tool can change (Fahim, 2026-10-13, #359). It replaced + * WordPress's own "automatic updates for all new versions" switch (#351): + * WordPress turns that on by default for sites installed since 5.6, so it + * was rarely the owner's choice, and it decides what WordPress does + * unattended, not what an app may do after a preview. A major has no + * automatic rollback and upgrades the database. * * @package Saddle */ @@ -32,7 +33,7 @@ function saddle_register_core_update_abilities() { 'saddle/update-core', array( 'label' => __( 'Update WordPress', 'saddle' ), - 'description' => __( 'Updates WordPress itself to a release WordPress already offers for background updates (see list-updates). Minor and security releases (7.1.2 to 7.1.3) are always allowed. A major release (7.1 to 7.2) is allowed only when WordPress is set to update itself to all new versions (Dashboard → Updates; the default on sites installed since WordPress 5.6); otherwise it is refused, and the owner updates it there. When both are offered, the minor release comes first. It takes two calls. The first changes nothing: it returns a preview with the installed and new version, whether it is minor or major, the PHP and MySQL versions it needs against this site\'s, and for a major release the active plugins not tested with it and what cannot be undone, plus a confirm_token. Call again with that token to queue the update. WordPress\'s own updater then runs it in the background, with a short maintenance message for visitors; check list-updates a minute later for the result under "runs". A core update cannot be undone: WordPress has no rollback for one, and a major release also upgrades the database. Refuses development versions, a site where the last automatic core update failed critically, and sites where WordPress cannot change files.', 'saddle' ), + 'description' => __( 'Updates WordPress itself to a release WordPress already offers for background updates (see list-updates). Minor and security releases (7.1.2 to 7.1.3) are always allowed. A major release (7.1 to 7.2) is allowed only when the owner has turned on "Major WordPress releases" in Saddle → Settings, which is off by default and which no tool can change; otherwise it is refused, and the owner updates it in Dashboard → Updates or turns that setting on. When both are offered, the minor release comes first. It takes two calls. The first changes nothing: it returns a preview with the installed and new version, whether it is minor or major, the PHP and MySQL versions it needs against this site\'s, and for a major release the active plugins not tested with it and what cannot be undone, plus a confirm_token. Call again with that token to queue the update. WordPress\'s own updater then runs it in the background, with a short maintenance message for visitors; check list-updates a minute later for the result under "runs". A core update cannot be undone: WordPress has no rollback for one, and a major release also upgrades the database. Refuses development versions, a site where the last automatic core update failed critically, and sites where WordPress cannot change files.', 'saddle' ), 'category' => 'saddle', 'input_schema' => array( 'type' => 'object', @@ -237,8 +238,8 @@ public static function update_translations( $input = null ) { /* ------------------------------------------------------------------ */ /** - * The release to offer: the newest minor one, else a major one WordPress - * would apply in the background itself, or a named refusal. + * The release to offer: the newest minor one, else a major one when the + * owner allows majors in Saddle → Settings, or a named refusal. * * @return object|WP_Error An offer from the update_core transient. */ @@ -273,11 +274,11 @@ private static function choose() { $offer = $best['minor']; if ( ! $offer && $best['major'] ) { - if ( ! Core_Upgrader::should_update_to_version( $best['major']->current ) ) { + if ( ! Saddle_Offer_Runner::core_majors_allowed() ) { return new WP_Error( 'saddle_major_core_update', /* translators: %s: new WordPress version. */ - sprintf( __( 'WordPress %s is a major release. Saddle applies one only when WordPress is set to update itself to all new versions, and this site updates itself only for maintenance and security releases. Ask the owner to update it in Dashboard → Updates, or to change that setting there. Do not retry.', 'saddle' ), $best['major']->current ), + sprintf( __( 'WordPress %s is a major release. Saddle applies one only when the owner turns on "Major WordPress releases" in Saddle → Settings, and it is off on this site. Tell the user they can update it in Dashboard → Updates, or turn that setting on and ask again. Do not retry.', 'saddle' ), $best['major']->current ), array( 'status' => 409 ) ); } @@ -315,10 +316,7 @@ private static function choose() { * @return string 'minor' or 'major'. */ private static function kind( $version ) { - $branch = static function ( $v ) { - return implode( '.', array_slice( preg_split( '/[.-]/', (string) $v ), 0, 2 ) ); - }; - return $branch( $version ) === $branch( get_bloginfo( 'version' ) ) ? 'minor' : 'major'; + return Saddle_Offer_Runner::is_major( $version ) ? 'major' : 'minor'; } /** diff --git a/includes/class-saddle-context.php b/includes/class-saddle-context.php index 351fc89..cb33036 100644 --- a/includes/class-saddle-context.php +++ b/includes/class-saddle-context.php @@ -260,7 +260,7 @@ public static function system_context() { $lines[] = '- ' . __( 'A 401 saying no key arrived usually means the web server strips the Authorization header. Ask the user to open Saddle → Settings → Connection check and run it — it can fix this automatically on most hosts.', 'saddle' ); $lines[] = '- ' . __( 'A destructive tool answering with a preview and a confirm_token is NOT an error — that is the approval gate. Show the user the preview; call again with the token only after they agree.', 'saddle' ); $lines[] = '- ' . __( 'Plugins and themes are installed only from the WordPress.org directory, by slug (search-plugins finds a plugin), and arrive inactive: activating is a separate, confirmed step (activate-plugin or activate-theme). Saddle never installs from a zip or a URL and never deletes a plugin or theme, so send the user to wp-admin for those.', 'saddle' ); - $lines[] = '- ' . __( 'update-core applies minor WordPress releases, and a major release only when WordPress is set to update itself to all new versions (Dashboard → Updates). A refusal for a major release is that setting: tell the user, do not retry.', 'saddle' ); + $lines[] = '- ' . __( 'update-core applies minor WordPress releases, and a major release only when the owner has turned on "Major WordPress releases" in Saddle → Settings. A refusal for a major release is that setting: tell the user, do not retry.', 'saddle' ); $lines[] = ''; // Recent-changes recall: what connected agents changed lately, from diff --git a/includes/class-saddle-core-settings.php b/includes/class-saddle-core-settings.php index b220276..dfc40b0 100644 --- a/includes/class-saddle-core-settings.php +++ b/includes/class-saddle-core-settings.php @@ -8,7 +8,7 @@ defined( 'ABSPATH' ) || exit; /** - * Scope `saddle` of the settings registry: the fourteen options Core already + * Scope `saddle` of the settings registry: the fifteen options Core already * keeps, given one shape so the admin draws them, `/preferences/saddle` * serves them and `saddle/get-module-settings` explains them. * @@ -142,6 +142,15 @@ public static function fields() { 'section' => __( 'Security', 'saddle' ), 'level' => 'basic', ), + 'core_major_updates' => array( + 'type' => 'boolean', + 'default' => false, + 'label' => __( 'Major WordPress releases', 'saddle' ), + 'help' => __( 'Let apps update WordPress to a new major version, such as 7.1 to 7.2, after you approve the preview. Minor and security releases never need this.', 'saddle' ), + 'screen' => 'settings/general', + 'section' => __( 'Updates', 'saddle' ), + 'level' => 'basic', + ), 'memory_max_entries' => array( 'type' => 'integer', 'minimum' => 10, @@ -204,6 +213,7 @@ public static function get() { 'unsplash_key' => Saddle_Unsplash::get_key(), 'memory_autoinject_agent' => (bool) get_option( Saddle_Memory::OPTION_AUTOINJECT, false ), 'enforce_tier_domain' => Saddle_Capabilities::is_domain_enforced(), + 'core_major_updates' => Saddle_Offer_Runner::core_majors_allowed(), 'memory_max_entries' => (int) get_option( Saddle_Memory::OPTION_MAX_ENTRIES, Saddle_Memory::DEFAULT_MAX_ENTRIES ), 'memory_core_budget' => (int) get_option( Saddle_Memory::OPTION_CORE_BUDGET, Saddle_Memory::DEFAULT_CORE_BUDGET ), 'memory_recent_changes' => (bool) get_option( self::OPTION_RECENT_CHANGES, true ), @@ -253,6 +263,9 @@ public static function set( array $values ) { case 'enforce_tier_domain': Saddle_Capabilities::set_domain_enforcement( (bool) $value ); break; + case 'core_major_updates': + update_option( Saddle_Offer_Runner::OPTION_CORE_MAJOR, (bool) $value ); + break; case 'memory_max_entries': update_option( Saddle_Memory::OPTION_MAX_ENTRIES, (int) $value ); break; diff --git a/includes/class-saddle-offer-runner.php b/includes/class-saddle-offer-runner.php index fd0f665..0643f7d 100644 --- a/includes/class-saddle-offer-runner.php +++ b/includes/class-saddle-offer-runner.php @@ -28,6 +28,12 @@ */ class Saddle_Offer_Runner { + /** + * Saddle's own switch for major WordPress releases (#359). Off unless the + * owner turns it on in Saddle → Settings; no tool can change it. + */ + const OPTION_CORE_MAJOR = 'saddle_core_major_updates'; + /** * Apply every offered update of one run through core's automatic updater. * Called by the update runner with its lock held and the completion hooks @@ -66,6 +72,15 @@ public static function apply( array &$run, WP_Automatic_Updater $updater ) { continue; } $offer = is_array( $offer ) ? (object) $offer : $offer; + // The owner can turn major releases off between the confirm and + // the run; the switch holds until the update starts. + if ( 'core' === $type && self::is_major( $offer->current ) && ! self::core_majors_allowed() ) { + $item['status'] = 'skipped'; + $item['message'] = __( 'Major WordPress releases were turned off in Saddle → Settings before the update started.', 'saddle' ); + /* translators: %s: new WordPress version. */ + Saddle_Log::record_action( 'update-core', 'core', sprintf( __( 'The update of WordPress to %s did not run: major releases were turned off in Saddle → Settings.', 'saddle' ), $offer->current ) ); + continue; + } // On a failure core's skin opens an output buffer and never closes // it (WP_Upgrader_Skin::error() calls header()). Its messages are // kept by the skin, so close what the update left open. @@ -122,6 +137,33 @@ private static function offers_for( array $run ) { return $offers; } + /** + * Whether the owner lets apps apply a major WordPress release: Saddle's + * own setting, off by default. WordPress's "automatic updates for all new + * versions" switch does not count. It is on by default for sites + * installed since 5.6, and it decides only what WordPress does + * unattended (Fahim, 2026-10-13, #359). + * + * @return bool + */ + public static function core_majors_allowed() { + return (bool) get_option( self::OPTION_CORE_MAJOR, false ); + } + + /** + * Whether a release is a major one, by core's own rule: a release on + * another X.Y branch than the installed one. + * + * @param string $version Offered version. + * @return bool + */ + public static function is_major( $version ) { + $branch = static function ( $v ) { + return implode( '.', array_slice( preg_split( '/[.-]/', (string) $v ), 0, 2 ) ); + }; + return $branch( $version ) !== $branch( get_bloginfo( 'version' ) ); + } + /** * The core releases WordPress offers for background updates: the * `autoupdate` entries of the update_core transient, which diff --git a/includes/class-saddle-settings-guard.php b/includes/class-saddle-settings-guard.php index bf7371b..fae7af1 100644 --- a/includes/class-saddle-settings-guard.php +++ b/includes/class-saddle-settings-guard.php @@ -30,6 +30,7 @@ class Saddle_Settings_Guard { 'saddle_disabled_abilities', 'saddle_tier_domain', 'saddle_enforce_tier_domain', + 'saddle_core_major_updates', ); /** diff --git a/languages/saddle.pot b/languages/saddle.pot index ee56292..2d9a8b8 100644 --- a/languages/saddle.pot +++ b/languages/saddle.pot @@ -9,7 +9,7 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"POT-Creation-Date: 2026-10-11T23:19:51+00:00\n" +"POT-Creation-Date: 2026-10-12T23:07:35+00:00\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "X-Generator: WP-CLI 2.12.0\n" "X-Domain: saddle\n" @@ -1374,83 +1374,83 @@ msgstr[1] "" msgid "The WordPress account this app is connected as cannot see \"%s\" content on this site — only published items are available to it. That is the account's role, not a Saddle setting. Do not retry this status; tell the user to reconnect Saddle as an account that can edit this content." msgstr "" -#: includes/abilities/core-updates.php:34 +#: includes/abilities/core-updates.php:35 msgid "Update WordPress" msgstr "" -#: includes/abilities/core-updates.php:35 -msgid "Updates WordPress itself to a release WordPress already offers for background updates (see list-updates). Minor and security releases (7.1.2 to 7.1.3) are always allowed. A major release (7.1 to 7.2) is allowed only when WordPress is set to update itself to all new versions (Dashboard → Updates; the default on sites installed since WordPress 5.6); otherwise it is refused, and the owner updates it there. When both are offered, the minor release comes first. It takes two calls. The first changes nothing: it returns a preview with the installed and new version, whether it is minor or major, the PHP and MySQL versions it needs against this site's, and for a major release the active plugins not tested with it and what cannot be undone, plus a confirm_token. Call again with that token to queue the update. WordPress's own updater then runs it in the background, with a short maintenance message for visitors; check list-updates a minute later for the result under \"runs\". A core update cannot be undone: WordPress has no rollback for one, and a major release also upgrades the database. Refuses development versions, a site where the last automatic core update failed critically, and sites where WordPress cannot change files." +#: includes/abilities/core-updates.php:36 +msgid "Updates WordPress itself to a release WordPress already offers for background updates (see list-updates). Minor and security releases (7.1.2 to 7.1.3) are always allowed. A major release (7.1 to 7.2) is allowed only when the owner has turned on \"Major WordPress releases\" in Saddle → Settings, which is off by default and which no tool can change; otherwise it is refused, and the owner updates it in Dashboard → Updates or turns that setting on. When both are offered, the minor release comes first. It takes two calls. The first changes nothing: it returns a preview with the installed and new version, whether it is minor or major, the PHP and MySQL versions it needs against this site's, and for a major release the active plugins not tested with it and what cannot be undone, plus a confirm_token. Call again with that token to queue the update. WordPress's own updater then runs it in the background, with a short maintenance message for visitors; check list-updates a minute later for the result under \"runs\". A core update cannot be undone: WordPress has no rollback for one, and a major release also upgrades the database. Refuses development versions, a site where the last automatic core update failed critically, and sites where WordPress cannot change files." msgstr "" -#: includes/abilities/core-updates.php:43 +#: includes/abilities/core-updates.php:44 msgid "Token from the preview step, required to queue the update." msgstr "" -#: includes/abilities/core-updates.php:56 +#: includes/abilities/core-updates.php:57 msgid "Update translations" msgstr "" -#: includes/abilities/core-updates.php:57 +#: includes/abilities/core-updates.php:58 msgid "Applies every translation update WordPress offers for WordPress, plugins and themes (list-updates counts them). It takes two calls. The first changes nothing: it returns a preview listing each translation (what it translates and the language) and a confirm_token. Call again with that token to queue the run. WordPress's own language pack updater then applies them in the background, as it does on its own during background updates; check list-updates a minute later for each result under \"runs\". There is no list to pass and no limit: all offered translations are applied together. Translation updates cannot be undone. Refuses when nothing is offered and on sites where WordPress cannot change files." msgstr "" -#: includes/abilities/core-updates.php:65 +#: includes/abilities/core-updates.php:66 #: includes/abilities/updates.php:48 msgid "Token from the preview step, required to queue the run." msgstr "" -#: includes/abilities/core-updates.php:98 +#: includes/abilities/core-updates.php:99 msgid "The WordPress account this app is connected as cannot update WordPress here (on a multisite network, only a network administrator can). No Saddle setting changes that." msgstr "" -#: includes/abilities/core-updates.php:110 +#: includes/abilities/core-updates.php:111 msgid "WordPress has no automatic rollback for a core update. If the new version breaks a plugin or the theme, the site stays on it until someone fixes it." msgstr "" -#: includes/abilities/core-updates.php:111 +#: includes/abilities/core-updates.php:112 msgid "A major release upgrades the database, so going back means restoring a database backup." msgstr "" -#: includes/abilities/core-updates.php:112 +#: includes/abilities/core-updates.php:113 msgid "Saddle runs on WordPress's own APIs. If the release changes them, this app may lose its connection before it can report the result." msgstr "" #. translators: 1: installed WordPress version, 2: new version. -#: includes/abilities/core-updates.php:124 +#: includes/abilities/core-updates.php:125 #, php-format msgid "Update WordPress from %1$s to %2$s, a major release, in the background. There is no automatic rollback." msgstr "" #. translators: 1: installed WordPress version, 2: new version. -#: includes/abilities/core-updates.php:126 +#: includes/abilities/core-updates.php:127 #, php-format msgid "Update WordPress from %1$s to %2$s, a minor release, in the background." msgstr "" -#: includes/abilities/core-updates.php:138 +#: includes/abilities/core-updates.php:139 msgid "Visitors see a short maintenance message while WordPress updates." msgstr "" #. translators: 1: installed WordPress version, 2: new version. -#: includes/abilities/core-updates.php:142 +#: includes/abilities/core-updates.php:143 #, php-format msgid "Queued update of WordPress from %1$s to %2$s." msgstr "" -#: includes/abilities/core-updates.php:163 +#: includes/abilities/core-updates.php:164 msgid "The update starts within about a minute and reports applied, failed or skipped under \"runs\" in list-updates." msgstr "" -#: includes/abilities/core-updates.php:189 +#: includes/abilities/core-updates.php:190 msgid "The WordPress account this app is connected as cannot update translations here (on a multisite network, only a network administrator can). No Saddle setting changes that." msgstr "" -#: includes/abilities/core-updates.php:203 +#: includes/abilities/core-updates.php:204 msgid "WordPress is not offering any translation updates right now." msgstr "" #. translators: %d: number of translations. -#: includes/abilities/core-updates.php:215 +#: includes/abilities/core-updates.php:216 #, php-format msgid "Update %d translation in the background." msgid_plural "Update %d translations in the background." @@ -1458,7 +1458,7 @@ msgstr[0] "" msgstr[1] "" #. translators: %d: number of translations. -#: includes/abilities/core-updates.php:222 +#: includes/abilities/core-updates.php:223 #, php-format msgid "Queued %d translation update." msgid_plural "Queued %d translation updates." @@ -1466,33 +1466,33 @@ msgstr[0] "" msgstr[1] "" #. translators: %s: installed WordPress version. -#: includes/abilities/core-updates.php:251 +#: includes/abilities/core-updates.php:252 #, php-format msgid "This site runs a development version of WordPress (%s). Saddle does not update development versions; update it in Dashboard → Updates." msgstr "" -#: includes/abilities/core-updates.php:257 +#: includes/abilities/core-updates.php:258 msgid "The last automatic WordPress update on this site failed critically. WordPress stops updating itself until someone updates it in Dashboard → Updates, and Saddle does the same." msgstr "" #. translators: %s: new WordPress version. -#: includes/abilities/core-updates.php:280 +#: includes/abilities/core-updates.php:281 #, php-format -msgid "WordPress %s is a major release. Saddle applies one only when WordPress is set to update itself to all new versions, and this site updates itself only for maintenance and security releases. Ask the owner to update it in Dashboard → Updates, or to change that setting there. Do not retry." +msgid "WordPress %s is a major release. Saddle applies one only when the owner turns on \"Major WordPress releases\" in Saddle → Settings, and it is off on this site. Tell the user they can update it in Dashboard → Updates, or turn that setting on and ask again. Do not retry." msgstr "" -#: includes/abilities/core-updates.php:287 +#: includes/abilities/core-updates.php:288 msgid "WordPress is not offering a core update this site can apply in the background. list-updates shows what is offered; a release offered only in Dashboard → Updates is applied there." msgstr "" #. translators: 1: new WordPress version, 2: required PHP version, 3: this site's PHP version. -#: includes/abilities/core-updates.php:295 +#: includes/abilities/core-updates.php:296 #, php-format msgid "WordPress %1$s needs PHP %2$s or newer; this site runs PHP %3$s. The host has to update PHP first." msgstr "" #. translators: 1: new WordPress version, 2: required MySQL version, 3: this site's MySQL version. -#: includes/abilities/core-updates.php:304 +#: includes/abilities/core-updates.php:305 #, php-format msgid "WordPress %1$s needs MySQL %2$s or newer; this site runs %3$s. The host has to update the database first." msgstr "" @@ -4104,7 +4104,7 @@ msgid "You need to be an administrator to do that." msgstr "" #: includes/admin/class-saddle-rest.php:682 -#: includes/class-saddle-core-settings.php:227 +#: includes/class-saddle-core-settings.php:237 msgid "Unknown access tier." msgstr "" @@ -5319,7 +5319,7 @@ msgid "Plugins and themes are installed only from the WordPress.org directory, b msgstr "" #: includes/class-saddle-context.php:263 -msgid "update-core applies minor WordPress releases, and a major release only when WordPress is set to update itself to all new versions (Dashboard → Updates). A refusal for a major release is that setting: tell the user, do not retry." +msgid "update-core applies minor WordPress releases, and a major release only when the owner has turned on \"Major WordPress releases\" in Saddle → Settings. A refusal for a major release is that setting: tell the user, do not retry." msgstr "" #: includes/class-saddle-context.php:430 @@ -5479,57 +5479,69 @@ msgstr "" msgid "Security" msgstr "" -#: includes/class-saddle-core-settings.php:150 -msgid "Most memory entries kept" +#: includes/class-saddle-core-settings.php:148 +msgid "Major WordPress releases" +msgstr "" + +#: includes/class-saddle-core-settings.php:149 +msgid "Let apps update WordPress to a new major version, such as 7.1 to 7.2, after you approve the preview. Minor and security releases never need this." msgstr "" #: includes/class-saddle-core-settings.php:151 +msgid "Updates" +msgstr "" + +#: includes/class-saddle-core-settings.php:159 +msgid "Most memory entries kept" +msgstr "" + +#: includes/class-saddle-core-settings.php:160 msgid "The oldest, least used entries are dropped past this number." msgstr "" -#: includes/class-saddle-core-settings.php:153 -#: includes/class-saddle-core-settings.php:164 +#: includes/class-saddle-core-settings.php:162 +#: includes/class-saddle-core-settings.php:173 #: admin/build/index.js:96 #: admin/src/components/Memory.jsx:125 msgid "Memory" msgstr "" -#: includes/class-saddle-core-settings.php:161 +#: includes/class-saddle-core-settings.php:170 msgid "Memory in each session" msgstr "" -#: includes/class-saddle-core-settings.php:162 +#: includes/class-saddle-core-settings.php:171 msgid "The most characters of memory handed to an app at the start of a session." msgstr "" -#: includes/class-saddle-core-settings.php:170 +#: includes/class-saddle-core-settings.php:179 msgid "Tell apps about recent changes" msgstr "" -#: includes/class-saddle-core-settings.php:171 +#: includes/class-saddle-core-settings.php:180 msgid "New sessions start with a short list of what was changed lately." msgstr "" -#: includes/class-saddle-core-settings.php:173 -#: includes/class-saddle-core-settings.php:184 +#: includes/class-saddle-core-settings.php:182 +#: includes/class-saddle-core-settings.php:193 #: admin/build/index.js:118 #: admin/src/components/SettingsPage.jsx:366 msgid "Recent changes" msgstr "" -#: includes/class-saddle-core-settings.php:181 +#: includes/class-saddle-core-settings.php:190 msgid "How many recent changes" msgstr "" -#: includes/class-saddle-core-settings.php:182 +#: includes/class-saddle-core-settings.php:191 msgid "The length of that list." msgstr "" -#: includes/class-saddle-core-settings.php:295 +#: includes/class-saddle-core-settings.php:308 msgid "Sign-in for apps needs HTTPS. An access token sent over plain HTTP can be read in transit." msgstr "" -#: includes/class-saddle-core-settings.php:296 +#: includes/class-saddle-core-settings.php:309 msgid "Sign-in for apps needs pretty permalinks. Choose any option but Plain in Settings → Permalinks, then try again." msgstr "" @@ -6005,46 +6017,56 @@ msgstr "" msgid "That notice cannot be dismissed. It goes away once the problem is fixed." msgstr "" -#: includes/class-saddle-offer-runner.php:65 +#: includes/class-saddle-offer-runner.php:71 msgid "No update was offered any more when the run started." msgstr "" -#: includes/class-saddle-offer-runner.php:181 +#: includes/class-saddle-offer-runner.php:79 +msgid "Major WordPress releases were turned off in Saddle → Settings before the update started." +msgstr "" + +#. translators: %s: new WordPress version. +#: includes/class-saddle-offer-runner.php:81 +#, php-format +msgid "The update of WordPress to %s did not run: major releases were turned off in Saddle → Settings." +msgstr "" + +#: includes/class-saddle-offer-runner.php:223 msgid "WordPress declined to update this item on its own (a version-control checkout, missing filesystem access, or a plugin telling it not to)." msgstr "" #. translators: %s: translation, as "Akismet (de_DE)". -#: includes/class-saddle-offer-runner.php:205 +#: includes/class-saddle-offer-runner.php:247 #, php-format msgid "Updated the %s translation." msgstr "" #. translators: 1: translation, as "Akismet (de_DE)", 2: why it was not updated. -#: includes/class-saddle-offer-runner.php:207 +#: includes/class-saddle-offer-runner.php:249 #, php-format msgid "The %1$s translation was not updated: %2$s" msgstr "" #. translators: 1: item name, 2: old version, 3: new version. -#: includes/class-saddle-offer-runner.php:214 +#: includes/class-saddle-offer-runner.php:256 #, php-format msgid "Updated %1$s from %2$s to %3$s." msgstr "" #. translators: 1: item name, 2: new version, 3: old version. -#: includes/class-saddle-offer-runner.php:218 +#: includes/class-saddle-offer-runner.php:260 #, php-format msgid "Update of %1$s to %2$s caused a fatal error; WordPress restored %3$s." msgstr "" #. translators: 1: item name, 2: new version. -#: includes/class-saddle-offer-runner.php:222 +#: includes/class-saddle-offer-runner.php:264 #, php-format msgid "Update of %1$s to %2$s was skipped by WordPress." msgstr "" #. translators: 1: item name, 2: new version, 3: error message. -#: includes/class-saddle-offer-runner.php:226 +#: includes/class-saddle-offer-runner.php:268 #, php-format msgid "Update of %1$s to %2$s failed: %3$s" msgstr "" diff --git a/readme.txt b/readme.txt index 7ae2512..c6a5a4b 100644 --- a/readme.txt +++ b/readme.txt @@ -93,7 +93,7 @@ These tools stay off until you give an app Manage the site. * Settings: Change the site title, permalinks and reading options. * Plugins and themes: Activate and deactivate plugins and switch the active theme, each after a preview. * Install from WordPress.org: Search the WordPress.org plugin directory, and install a plugin or theme from WordPress.org by name after a preview. A new plugin or theme arrives inactive, and turning it on is a separate step. Saddle never installs from a zip file or a link, and never deletes a plugin or theme. -* Updates: See which plugin, theme and WordPress updates are waiting. Apply plugin, theme, WordPress and translation updates through WordPress's own updater, and turn automatic updates on or off per plugin. WordPress keeps a backup and restores a plugin that breaks the site. A major WordPress release is applied only if WordPress is set to update itself to all new versions. +* Updates: See which plugin, theme and WordPress updates are waiting. Apply plugin, theme, WordPress and translation updates through WordPress's own updater, and turn automatic updates on or off per plugin. WordPress keeps a backup and restores a plugin that breaks the site. A major WordPress release is applied only if you turn on Major WordPress releases in Saddle → Settings. It is off by default, and no app can turn it on. * Site Health: Read the results of WordPress's own Site Health checks. * Cache: Clear the site cache. @@ -214,7 +214,7 @@ The WordPress.org version never checks for its own updates. The version from plu * New: Your AI app can search the WordPress.org plugin directory. Each result shows the plugin's version, active installs, rating, last update and the WordPress and PHP versions it needs, and whether it is already installed and active on your site. * New: Your AI app can install a plugin from the WordPress.org directory by its name. It shows a preview first, with warnings when the plugin is not tested with your WordPress or has not been updated in two years, and waits for your approval. WordPress's own installer then adds it in the background. The plugin arrives inactive, so turning it on is a separate step you approve. Saddle never installs from a zip file or a link, and never deletes a plugin. * New: Your AI app can install a theme from the WordPress.org directory the same way. The theme is not activated. A child theme needs its parent theme installed first, so WordPress never adds a theme you did not see. -* New: Your AI app can update WordPress itself to a release WordPress offers. Minor and security releases are always allowed. A major release is allowed only if WordPress is set to update itself to all new versions, under Dashboard → Updates. The preview lists active plugins not tested with the new version, and nothing happens until you approve. +* New: Your AI app can update WordPress itself to a release WordPress offers. Minor and security releases are always allowed. A major release, such as 7.1 to 7.2, is allowed only if you turn on Major WordPress releases in Saddle → Settings. It is off by default, and no app can turn it on. The preview lists active plugins not tested with the new version, and nothing happens until you approve. * New: Your AI app can apply the translation updates WordPress offers, after a preview, through WordPress's own language pack updater. * Fixed: Saddle and the WordPress MCP Adapter plugin 0.7.0 can now run on the same site. Activating the adapter next to Saddle stopped with a fatal error, and with both active every page failed. Saddle now serves its own endpoint itself when the adapter is a version it doesn't support yet, and keeps its built-in copy of the adapter out of the way of the official plugin. * Changed: Bridle and Bridle KB are PlugPress plugins, so their tools are on as soon as the plugin is active, like Mailyard and SEO. You no longer switch them on under Services. diff --git a/tests/core-updates-test.php b/tests/core-updates-test.php index e9b32b2..2d42f2c 100644 --- a/tests/core-updates-test.php +++ b/tests/core-updates-test.php @@ -16,8 +16,8 @@ * What this pins: the admin tier; that a preview changes nothing and a * confirm never runs the upgrader inside the request (the hard line); * single-use tokens bound to the release; minor before major; a major only - * behind WordPress's own switch for all new versions; every refusal; and the - * runner handing exactly the confirmed release to core. For translations: + * behind Saddle's own setting, whatever WordPress's switch says (#359); every + * refusal; and the runner handing exactly the confirmed release to core. For translations: * the same gate, and a real language pack applied by core's * Language_Pack_Upgrader from a local zip. * @@ -79,6 +79,7 @@ public function tear_down() { delete_site_transient( 'update_core' ); delete_site_transient( 'update_plugins' ); delete_site_option( 'auto_update_core_major' ); + delete_option( Saddle_Offer_Runner::OPTION_CORE_MAJOR ); delete_site_option( 'auto_core_update_failed' ); WP_Upgrader::release_lock( 'core_updater' ); wp_clear_scheduled_hook( Saddle_Update_Runner::HOOK ); @@ -240,32 +241,40 @@ public function test_the_minor_release_comes_before_a_major_one() { $this->assertSame( 'minor', $this->preview()['preview']['kind'] ); } - public function test_a_new_install_lets_wordpress_apply_major_releases() { + public function test_wordpress_turns_its_own_major_switch_on_for_new_installs() { // Core's default since WordPress 5.6 (schema.php): a new install - // updates itself to every new version; a site upgraded from before - // 5.6 has "unset", which means minor releases only. Saddle follows - // whichever this site has, so this default decides most sites. + // updates itself to every new version. That is why Saddle does not + // read this switch for majors (#359): on most sites it was never the + // owner's choice, and it decides only what WordPress does unattended. $this->assertSame( 'enabled', get_site_option( 'auto_update_core_major' ) ); } - public function test_a_major_release_is_refused_when_wordpress_updates_itself_only_for_minor_releases() { - if ( defined( 'WP_AUTO_UPDATE_CORE' ) ) { - $this->markTestSkipped( 'WP_AUTO_UPDATE_CORE decides majors on this install.' ); - } - // What Dashboard → Updates' "maintenance and security releases only" - // link stores. A site upgraded from before 5.6 has "unset", which - // core reads the same way. - update_site_option( 'auto_update_core_major', 'disabled' ); + public function test_a_major_release_is_refused_by_default_even_when_wordpress_updates_itself_to_majors() { + update_site_option( 'auto_update_core_major', 'enabled' ); + $this->assertFalse( Saddle_Offer_Runner::core_majors_allowed(), 'Off by default.' ); $this->offer( array( $this->next( 'major' ) ) ); + $result = $this->call(); + $this->assert_refused( $result, 'saddle_major_core_update' ); + $this->assertStringContainsString( 'Saddle → Settings', $result->get_error_message() ); $this->assertStringContainsString( 'Dashboard → Updates', $result->get_error_message() ); } - public function test_a_major_release_wordpress_would_apply_lists_what_can_break() { - if ( defined( 'WP_AUTO_UPDATE_CORE' ) ) { - $this->markTestSkipped( 'WP_AUTO_UPDATE_CORE decides majors on this install.' ); - } + public function test_the_owner_turns_major_releases_on_in_saddle_settings() { + $field = Saddle_Settings_Registry::schema( 'saddle' )['fields']['core_major_updates']; + $this->assertSame( 'boolean', $field['type'] ); + $this->assertFalse( $field['default'] ); + $this->assertSame( 'read', $field['agent'], 'No tool can turn it on.' ); + $this->assertSame( 'settings/general', $field['screen'] ); + $this->assertTrue( Saddle_Settings_Guard::is_protected_option( Saddle_Offer_Runner::OPTION_CORE_MAJOR ) ); + + $this->assertTrue( Saddle_Core_Settings::set( array( 'core_major_updates' => true ) ) ); + $this->assertTrue( Saddle_Offer_Runner::core_majors_allowed() ); + $this->assertTrue( Saddle_Core_Settings::get()['core_major_updates'] ); + } + + public function test_a_major_release_the_owner_allowed_lists_what_can_break() { // An active plugin WordPress.org says was tested only up to this X.Y. $this->plugin_dir = WP_PLUGIN_DIR . '/old-plugin'; wp_mkdir_p( $this->plugin_dir ); @@ -286,7 +295,9 @@ public function test_a_major_release_wordpress_would_apply_lists_what_can_break( ) ); - update_site_option( 'auto_update_core_major', 'enabled' ); + // WordPress's own switch says minor only; Saddle's setting decides. + update_site_option( 'auto_update_core_major', 'disabled' ); + update_option( Saddle_Offer_Runner::OPTION_CORE_MAJOR, true ); $this->offer( array( $this->next( 'major' ) ) ); $shown = $this->preview()['preview']; @@ -383,6 +394,52 @@ public function test_runner_reports_a_release_no_longer_offered() { $this->assertSame( 'up_to_date', $item['status'] ); } + /** Answer core's download with an error, and keep what it asked for. */ + private function refuse_download() { + $asked = new ArrayObject(); + add_filter( + 'upgrader_pre_download', + static function ( $reply, $package ) use ( $asked ) { + $asked[] = $package; + return new WP_Error( 'saddle_test_no_download', 'Not in tests.' ); + }, + 10, + 2 + ); + return $asked; + } + + public function test_runner_hands_an_allowed_major_release_to_core_whatever_wordpress_switch_says() { + update_site_option( 'auto_update_core_major', 'disabled' ); + update_option( Saddle_Offer_Runner::OPTION_CORE_MAJOR, true ); + $this->offer( array( $this->next( 'major' ) ) ); + $done = $this->confirm( $this->preview()['confirm_token'] ); + $asked = $this->refuse_download(); + + Saddle_Update_Runner::run( $done['run_id'] ); + + $item = Saddle_Update_Runner::get_run( $done['run_id'] )['items'][0]; + $this->assertSame( 'failed', $item['status'], 'Core took the release and asked for its package.' ); + $this->assertStringContainsString( 'wordpress-' . $this->next( 'major' ), $asked[0] ); + $this->assertSame( $this->version, wp_get_wp_version() ); + } + + public function test_runner_skips_a_major_release_turned_off_after_the_confirm() { + update_option( Saddle_Offer_Runner::OPTION_CORE_MAJOR, true ); + $this->offer( array( $this->next( 'major' ) ) ); + $done = $this->confirm( $this->preview()['confirm_token'] ); + update_option( Saddle_Offer_Runner::OPTION_CORE_MAJOR, false ); + $this->watch_upgrader(); + + Saddle_Update_Runner::run( $done['run_id'] ); + + $item = Saddle_Update_Runner::get_run( $done['run_id'] )['items'][0]; + $this->assertSame( 'skipped', $item['status'] ); + $this->assertStringContainsString( 'Saddle → Settings', $item['message'] ); + $this->assertSame( 0, $this->upgrader_calls, 'Core was never asked.' ); + $this->assertSame( $this->version, wp_get_wp_version() ); + } + /* -------- update-translations -------- */ /** Offer one language pack for a throwaway plugin, as WordPress.org does. */ diff --git a/tests/module-abilities-test.php b/tests/module-abilities-test.php index 0259908..efa5deb 100644 --- a/tests/module-abilities-test.php +++ b/tests/module-abilities-test.php @@ -100,7 +100,7 @@ public function test_get_module_settings_covers_saddles_own_and_never_a_secret() $body = $this->run_ability( 'get-module-settings', array( 'module' => 'saddle' ) ); - $this->assertCount( 14, $body['fields'] ); + $this->assertCount( 15, $body['fields'] ); $this->assertSame( array( 'read' ), array_values( array_unique( wp_list_pluck( $body['fields'], 'agent' ) ) ) ); $this->assertStringNotContainsString( 'abcdefghijklmnopqrst', wp_json_encode( $body ) ); } @@ -269,12 +269,13 @@ public function test_no_core_field_can_be_changed_by_a_tool() { 'unsplash_key' => 'abcdefghijklmnopqrstuvwx', 'memory_autoinject_agent' => true, 'enforce_tier_domain' => true, + 'core_major_updates' => true, 'memory_max_entries' => 20, 'memory_core_budget' => 300, 'memory_recent_changes' => false, 'memory_recent_limit' => 3, ); - $this->assertCount( 14, $values ); + $this->assertCount( 15, $values ); foreach ( $values as $key => $value ) { $result = $this->run_ability( 'update-module-settings', array( 'module' => 'saddle', 'values' => array( $key => $value ) ) ); @@ -287,6 +288,7 @@ public function test_no_core_field_can_be_changed_by_a_tool() { $this->assertFalse( Saddle_Capabilities::is_paused() ); $this->assertFalse( Saddle_Capabilities::is_rehearsal() ); $this->assertFalse( Saddle_Capabilities::is_drafts_only() ); + $this->assertFalse( Saddle_Offer_Runner::core_majors_allowed() ); } public function test_a_malicious_module_cannot_point_a_writable_field_at_the_tier() { @@ -317,7 +319,7 @@ public function test_a_protected_option_is_put_back_if_a_modules_setter_touches_ } public function test_every_protected_option_is_named_in_one_place() { - foreach ( array( 'saddle_access_tier', 'saddle_paused', 'saddle_rehearsal', 'saddle_drafts_only', 'saddle_enabled_integrations', 'saddle_disabled_abilities', 'saddle_tier_domain', 'saddle_enforce_tier_domain', 'saddle_oauth_enabled', 'saddle_oauth_anything' ) as $name ) { + foreach ( array( 'saddle_access_tier', 'saddle_paused', 'saddle_rehearsal', 'saddle_drafts_only', 'saddle_enabled_integrations', 'saddle_disabled_abilities', 'saddle_tier_domain', 'saddle_enforce_tier_domain', 'saddle_core_major_updates', 'saddle_oauth_enabled', 'saddle_oauth_anything' ) as $name ) { $this->assertTrue( Saddle_Settings_Guard::is_protected_option( $name ), $name ); } $this->assertFalse( Saddle_Settings_Guard::is_protected_option( 'demo_settings' ) ); diff --git a/tests/settings-registry-test.php b/tests/settings-registry-test.php index 9c73d2c..f4eca18 100644 --- a/tests/settings-registry-test.php +++ b/tests/settings-registry-test.php @@ -227,11 +227,13 @@ public function test_core_schema_reads_the_values_the_code_uses() { $body = Saddle_Settings_View::describe( 'saddle', Saddle_Settings_Registry::schema( 'saddle' ) ); $this->assertSame( 'saddle', $body['scope'] ); - $this->assertCount( 14, $body['fields'] ); + $this->assertCount( 15, $body['fields'] ); $by_key = array_column( $body['fields'], null, 'key' ); $this->assertSame( 'read', $by_key['tier']['value'] ); $this->assertFalse( $by_key['paused']['value'] ); + $this->assertFalse( $by_key['core_major_updates']['value'] ); + $this->assertSame( 'Updates', $by_key['core_major_updates']['section'] ); $this->assertTrue( $by_key['oauth_dcr']['value'] ); $this->assertSame( 500, $by_key['memory_max_entries']['value'] ); $this->assertSame( 1500, $by_key['memory_core_budget']['value'] ); From 1efcf116461a18391cd77d5df0cbf94f31631fd0 Mon Sep 17 00:00:00 2001 From: fahimreza-dev Date: Tue, 13 Oct 2026 05:25:00 +0600 Subject: [PATCH 2/2] fix(settings): Major WordPress releases is a Safety switch (#359) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Saddle → Settings is drawn by hand, so a schema field alone never showed: the owner had no switch to flip. It is now the fourth Safety switch, saved on flip through POST /preferences like the other three, with the id the app's refusal links to (#saddle-field-saddle-core_major_updates). The registry field is control: custom so no generic form draws it twice. Set through one setter, Saddle_Offer_Runner::set_core_majors(). Co-Authored-By: Claude Opus 5.5 --- admin/build/index.asset.php | 2 +- admin/build/index.js | 32 ++--- admin/src/components/SettingsPage.jsx | 20 ++- admin/src/settings-logic.js | 1 + includes/admin/class-saddle-rest.php | 39 +++-- includes/class-saddle-core-settings.php | 7 +- includes/class-saddle-offer-runner.php | 11 ++ languages/saddle.pot | 182 +++++++++++++----------- tests/core-updates-test.php | 23 +++ tests/js/settings-logic.test.js | 5 +- tests/settings-registry-test.php | 2 +- 11 files changed, 197 insertions(+), 127 deletions(-) diff --git a/admin/build/index.asset.php b/admin/build/index.asset.php index a78ee21..ee621fb 100644 --- a/admin/build/index.asset.php +++ b/admin/build/index.asset.php @@ -1 +1 @@ - array('react', 'react-dom', 'wp-api-fetch', 'wp-element', 'wp-hooks', 'wp-i18n'), 'version' => '5be3bd6a730a8feec28d'); + array('react', 'react-dom', 'wp-api-fetch', 'wp-element', 'wp-hooks', 'wp-i18n'), 'version' => '2f4f15c59a7d84460eae'); diff --git a/admin/build/index.js b/admin/build/index.js index 94a21d2..18d5bd7 100644 --- a/admin/build/index.js +++ b/admin/build/index.js @@ -1,4 +1,4 @@ -(()=>{"use strict";var e={744(e,t,n){var a=n(609),r=n.t(a,2);const s=window.wp.apiFetch;var o=n.n(s);const l=window.wp.element,i=window.ReactDOM,c=Array(12).fill(0),d=({visible:e,className:t})=>a.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":e},a.createElement("div",{className:"sonner-spinner"},c.map((e,t)=>a.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${t}`})))),u=a.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},a.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",clipRule:"evenodd"})),p=a.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},a.createElement("path",{fillRule:"evenodd",d:"M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",clipRule:"evenodd"})),m=a.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},a.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",clipRule:"evenodd"})),h=a.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},a.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})),f=a.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},a.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),a.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"}));let g=1;const y=new class{constructor(){this.subscribe=e=>(this.subscribers.push(e),()=>{const t=this.subscribers.indexOf(e);this.subscribers.splice(t,1)}),this.publish=e=>{this.subscribers.forEach(t=>t(e))},this.addToast=e=>{this.publish(e),this.toasts=[...this.toasts,e]},this.create=e=>{var t;const{message:n,...a}=e,r="number"==typeof(null==e?void 0:e.id)||(null==(t=e.id)?void 0:t.length)>0?e.id:g++,s=this.toasts.find(e=>e.id===r),o=void 0===e.dismissible||e.dismissible;return this.dismissedToasts.has(r)&&this.dismissedToasts.delete(r),s?this.toasts=this.toasts.map(t=>t.id===r?(this.publish({...t,...e,id:r,title:n}),{...t,...e,id:r,dismissible:o,title:n}):t):this.addToast({title:n,...a,dismissible:o,id:r}),r},this.dismiss=e=>(e?(this.dismissedToasts.add(e),requestAnimationFrame(()=>this.subscribers.forEach(t=>t({id:e,dismiss:!0})))):this.toasts.forEach(e=>{this.subscribers.forEach(t=>t({id:e.id,dismiss:!0}))}),e),this.message=(e,t)=>this.create({...t,message:e}),this.error=(e,t)=>this.create({...t,message:e,type:"error"}),this.success=(e,t)=>this.create({...t,type:"success",message:e}),this.info=(e,t)=>this.create({...t,type:"info",message:e}),this.warning=(e,t)=>this.create({...t,type:"warning",message:e}),this.loading=(e,t)=>this.create({...t,type:"loading",message:e}),this.promise=(e,t)=>{if(!t)return;let n;void 0!==t.loading&&(n=this.create({...t,promise:e,type:"loading",message:t.loading,description:"function"!=typeof t.description?t.description:void 0}));const r=Promise.resolve(e instanceof Function?e():e);let s,o=void 0!==n;const l=r.then(async e=>{if(s=["resolve",e],a.isValidElement(e))o=!1,this.create({id:n,type:"default",message:e});else if(v(e)&&!e.ok){o=!1;const r="function"==typeof t.error?await t.error(`HTTP error! status: ${e.status}`):t.error,s="function"==typeof t.description?await t.description(`HTTP error! status: ${e.status}`):t.description,l="object"!=typeof r||a.isValidElement(r)?{message:r}:r;this.create({id:n,type:"error",description:s,...l})}else if(e instanceof Error){o=!1;const r="function"==typeof t.error?await t.error(e):t.error,s="function"==typeof t.description?await t.description(e):t.description,l="object"!=typeof r||a.isValidElement(r)?{message:r}:r;this.create({id:n,type:"error",description:s,...l})}else if(void 0!==t.success){o=!1;const r="function"==typeof t.success?await t.success(e):t.success,s="function"==typeof t.description?await t.description(e):t.description,l="object"!=typeof r||a.isValidElement(r)?{message:r}:r;this.create({id:n,type:"success",description:s,...l})}}).catch(async e=>{if(s=["reject",e],void 0!==t.error){o=!1;const r="function"==typeof t.error?await t.error(e):t.error,s="function"==typeof t.description?await t.description(e):t.description,l="object"!=typeof r||a.isValidElement(r)?{message:r}:r;this.create({id:n,type:"error",description:s,...l})}}).finally(()=>{o&&(this.dismiss(n),n=void 0),null==t.finally||t.finally.call(t)}),i=()=>new Promise((e,t)=>l.then(()=>"reject"===s[0]?t(s[1]):e(s[1])).catch(t));return"string"!=typeof n&&"number"!=typeof n?{unwrap:i}:Object.assign(n,{unwrap:i})},this.custom=(e,t)=>{const n=(null==t?void 0:t.id)||g++;return this.create({jsx:e(n),id:n,...t}),n},this.getActiveToasts=()=>this.toasts.filter(e=>!this.dismissedToasts.has(e.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}},v=e=>e&&"object"==typeof e&&"ok"in e&&"boolean"==typeof e.ok&&"status"in e&&"number"==typeof e.status,b=Object.assign((e,t)=>{const n=(null==t?void 0:t.id)||g++;return y.addToast({title:e,...t,id:n}),n},{success:y.success,info:y.info,warning:y.warning,error:y.error,custom:y.custom,message:y.message,promise:y.promise,dismiss:y.dismiss,loading:y.loading},{getHistory:()=>y.toasts,getToasts:()=>y.getActiveToasts()});function w(e){return void 0!==e.label}!function(e){if("undefined"==typeof document)return;let t=document.head||document.getElementsByTagName("head")[0],n=document.createElement("style");n.type="text/css",t.appendChild(n),n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e))}("[data-sonner-toaster][dir=ltr],html[dir=ltr]{--toast-icon-margin-start:-3px;--toast-icon-margin-end:4px;--toast-svg-margin-start:-1px;--toast-svg-margin-end:0px;--toast-button-margin-start:auto;--toast-button-margin-end:0;--toast-close-button-start:0;--toast-close-button-end:unset;--toast-close-button-transform:translate(-35%, -35%)}[data-sonner-toaster][dir=rtl],html[dir=rtl]{--toast-icon-margin-start:4px;--toast-icon-margin-end:-3px;--toast-svg-margin-start:0px;--toast-svg-margin-end:-1px;--toast-button-margin-start:0;--toast-button-margin-end:auto;--toast-close-button-start:unset;--toast-close-button-end:0;--toast-close-button-transform:translate(35%, -35%)}[data-sonner-toaster]{position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1:hsl(0, 0%, 99%);--gray2:hsl(0, 0%, 97.3%);--gray3:hsl(0, 0%, 95.1%);--gray4:hsl(0, 0%, 93%);--gray5:hsl(0, 0%, 90.9%);--gray6:hsl(0, 0%, 88.7%);--gray7:hsl(0, 0%, 85.8%);--gray8:hsl(0, 0%, 78%);--gray9:hsl(0, 0%, 56.1%);--gray10:hsl(0, 0%, 52.3%);--gray11:hsl(0, 0%, 43.5%);--gray12:hsl(0, 0%, 9%);--border-radius:8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:0;z-index:999999999;transition:transform .4s ease}@media (hover:none) and (pointer:coarse){[data-sonner-toaster][data-lifted=true]{transform:none}}[data-sonner-toaster][data-x-position=right]{right:var(--offset-right)}[data-sonner-toaster][data-x-position=left]{left:var(--offset-left)}[data-sonner-toaster][data-x-position=center]{left:50%;transform:translateX(-50%)}[data-sonner-toaster][data-y-position=top]{top:var(--offset-top)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--offset-bottom)}[data-sonner-toast]{--y:translateY(100%);--lift-amount:calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:0;overflow-wrap:anywhere}[data-sonner-toast][data-styled=true]{padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px rgba(0,0,0,.1);width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}[data-sonner-toast]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-y-position=top]{top:0;--y:translateY(-100%);--lift:1;--lift-amount:calc(1 * var(--gap))}[data-sonner-toast][data-y-position=bottom]{bottom:0;--y:translateY(100%);--lift:-1;--lift-amount:calc(var(--lift) * var(--gap))}[data-sonner-toast][data-styled=true] [data-description]{font-weight:400;line-height:1.4;color:#3f3f3f}[data-rich-colors=true][data-sonner-toast][data-styled=true] [data-description]{color:inherit}[data-sonner-toaster][data-sonner-theme=dark] [data-description]{color:#e8e8e8}[data-sonner-toast][data-styled=true] [data-title]{font-weight:500;line-height:1.5;color:inherit}[data-sonner-toast][data-styled=true] [data-icon]{display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}[data-sonner-toast][data-promise=true] [data-icon]>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}[data-sonner-toast][data-styled=true] [data-icon]>*{flex-shrink:0}[data-sonner-toast][data-styled=true] [data-icon] svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}[data-sonner-toast][data-styled=true] [data-content]{display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;font-weight:500;cursor:pointer;outline:0;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}[data-sonner-toast][data-styled=true] [data-button]:focus-visible{box-shadow:0 0 0 2px rgba(0,0,0,.4)}[data-sonner-toast][data-styled=true] [data-button]:first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}[data-sonner-toast][data-styled=true] [data-cancel]{color:var(--normal-text);background:rgba(0,0,0,.08)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-styled=true] [data-cancel]{background:rgba(255,255,255,.3)}[data-sonner-toast][data-styled=true] [data-close-button]{position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);background:var(--normal-bg);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast][data-styled=true] [data-close-button]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-styled=true] [data-disabled=true]{cursor:not-allowed}[data-sonner-toast][data-styled=true]:hover [data-close-button]:hover{background:var(--gray2);border-color:var(--gray5)}[data-sonner-toast][data-swiping=true]::before{content:'';position:absolute;left:-100%;right:-100%;height:100%;z-index:-1}[data-sonner-toast][data-y-position=top][data-swiping=true]::before{bottom:50%;transform:scaleY(3) translateY(50%)}[data-sonner-toast][data-y-position=bottom][data-swiping=true]::before{top:50%;transform:scaleY(3) translateY(-50%)}[data-sonner-toast][data-swiping=false][data-removed=true]::before{content:'';position:absolute;inset:0;transform:scaleY(2)}[data-sonner-toast][data-expanded=true]::after{content:'';position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}[data-sonner-toast][data-mounted=true]{--y:translateY(0);opacity:1}[data-sonner-toast][data-expanded=false][data-front=false]{--scale:var(--toasts-before) * 0.05 + 1;--y:translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}[data-sonner-toast]>*{transition:opacity .4s}[data-sonner-toast][data-x-position=right]{right:0}[data-sonner-toast][data-x-position=left]{left:0}[data-sonner-toast][data-expanded=false][data-front=false][data-styled=true]>*{opacity:0}[data-sonner-toast][data-visible=false]{opacity:0;pointer-events:none}[data-sonner-toast][data-mounted=true][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}[data-sonner-toast][data-removed=true][data-front=true][data-swipe-out=false]{--y:translateY(calc(var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=false]{--y:translateY(40%);opacity:0;transition:transform .5s,opacity .2s}[data-sonner-toast][data-removed=true][data-front=false]::before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y,0)) translateX(var(--swipe-amount-x,0));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width:600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-sonner-theme=light]{--normal-bg:#fff;--normal-border:var(--gray4);--normal-text:var(--gray12);--success-bg:hsl(143, 85%, 96%);--success-border:hsl(145, 92%, 87%);--success-text:hsl(140, 100%, 27%);--info-bg:hsl(208, 100%, 97%);--info-border:hsl(221, 91%, 93%);--info-text:hsl(210, 92%, 45%);--warning-bg:hsl(49, 100%, 97%);--warning-border:hsl(49, 91%, 84%);--warning-text:hsl(31, 92%, 45%);--error-bg:hsl(359, 100%, 97%);--error-border:hsl(359, 100%, 94%);--error-text:hsl(360, 100%, 45%)}[data-sonner-toaster][data-sonner-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg:#000;--normal-border:hsl(0, 0%, 20%);--normal-text:var(--gray1)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg:#fff;--normal-border:var(--gray3);--normal-text:var(--gray12)}[data-sonner-toaster][data-sonner-theme=dark]{--normal-bg:#000;--normal-bg-hover:hsl(0, 0%, 12%);--normal-border:hsl(0, 0%, 20%);--normal-border-hover:hsl(0, 0%, 25%);--normal-text:var(--gray1);--success-bg:hsl(150, 100%, 6%);--success-border:hsl(147, 100%, 12%);--success-text:hsl(150, 86%, 65%);--info-bg:hsl(215, 100%, 6%);--info-border:hsl(223, 43%, 17%);--info-text:hsl(216, 87%, 65%);--warning-bg:hsl(64, 100%, 6%);--warning-border:hsl(60, 100%, 9%);--warning-text:hsl(46, 87%, 65%);--error-bg:hsl(358, 76%, 10%);--error-border:hsl(357, 89%, 16%);--error-text:hsl(358, 100%, 81%)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size:16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:first-child{animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}100%{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}100%{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}100%{opacity:.15}}@media (prefers-reduced-motion){.sonner-loading-bar,[data-sonner-toast],[data-sonner-toast]>*{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}");const _=3,j=14;function k(...e){return e.filter(Boolean).join(" ")}const x=e=>{var t,n,r,s,o,l,i,c,g;const{invert:y,toast:v,unstyled:b,interacting:_,setHeights:j,visibleToasts:x,heights:M,index:N,toasts:E,expanded:I,removeToast:C,defaultRichColors:L,closeButton:S,style:D,cancelButtonStyle:T,actionButtonStyle:A,className:O="",descriptionClassName:z="",duration:P,position:R,gap:Z,expandByDefault:W,classNames:Y,icons:G,closeButtonAriaLabel:B="Close toast"}=e,[V,U]=a.useState(null),[F,H]=a.useState(null),[Q,X]=a.useState(!1),[$,J]=a.useState(!1),[K,q]=a.useState(!1),[ee,te]=a.useState(!1),[ne,ae]=a.useState(!1),[re,se]=a.useState(0),[oe,le]=a.useState(0),ie=a.useRef(v.duration||P||4e3),ce=a.useRef(null),de=a.useRef(null),ue=0===N,pe=N+1<=x,me=v.type,he=!1!==v.dismissible,fe=v.className||"",ge=v.descriptionClassName||"",ye=a.useMemo(()=>M.findIndex(e=>e.toastId===v.id)||0,[M,v.id]),ve=a.useMemo(()=>{var e;return null!=(e=v.closeButton)?e:S},[v.closeButton,S]),be=a.useMemo(()=>v.duration||P||4e3,[v.duration,P]),we=a.useRef(0),_e=a.useRef(0),je=a.useRef(0),ke=a.useRef(null),[xe,Me]=R.split("-"),Ne=a.useMemo(()=>M.reduce((e,t,n)=>n>=ye?e:e+t.height,0),[M,ye]),Ee=(()=>{const[e,t]=a.useState(document.hidden);return a.useEffect(()=>{const e=()=>{t(document.hidden)};return document.addEventListener("visibilitychange",e),()=>window.removeEventListener("visibilitychange",e)},[]),e})(),Ie=v.invert||y,Ce="loading"===me;_e.current=a.useMemo(()=>ye*Z+Ne,[ye,Ne]),a.useEffect(()=>{ie.current=be},[be]),a.useEffect(()=>{X(!0)},[]),a.useEffect(()=>{const e=de.current;if(e){const t=e.getBoundingClientRect().height;return le(t),j(e=>[{toastId:v.id,height:t,position:v.position},...e]),()=>j(e=>e.filter(e=>e.toastId!==v.id))}},[j,v.id]),a.useLayoutEffect(()=>{if(!Q)return;const e=de.current,t=e.style.height;e.style.height="auto";const n=e.getBoundingClientRect().height;e.style.height=t,le(n),j(e=>e.find(e=>e.toastId===v.id)?e.map(e=>e.toastId===v.id?{...e,height:n}:e):[{toastId:v.id,height:n,position:v.position},...e])},[Q,v.title,v.description,j,v.id,v.jsx,v.action,v.cancel]);const Le=a.useCallback(()=>{J(!0),se(_e.current),j(e=>e.filter(e=>e.toastId!==v.id)),setTimeout(()=>{C(v)},200)},[v,C,j,_e]);a.useEffect(()=>{if(v.promise&&"loading"===me||v.duration===1/0||"loading"===v.type)return;let e;return I||_||Ee?(()=>{if(je.current{null==v.onAutoClose||v.onAutoClose.call(v,v),Le()},ie.current)),()=>clearTimeout(e)},[I,_,v,me,Ee,Le]),a.useEffect(()=>{v.delete&&(Le(),null==v.onDismiss||v.onDismiss.call(v,v))},[Le,v.delete]);const Se=v.icon||(null==G?void 0:G[me])||(e=>{switch(e){case"success":return u;case"info":return m;case"warning":return p;case"error":return h;default:return null}})(me);var De,Te;return a.createElement("li",{tabIndex:0,ref:de,className:k(O,fe,null==Y?void 0:Y.toast,null==v||null==(t=v.classNames)?void 0:t.toast,null==Y?void 0:Y.default,null==Y?void 0:Y[me],null==v||null==(n=v.classNames)?void 0:n[me]),"data-sonner-toast":"","data-rich-colors":null!=(De=v.richColors)?De:L,"data-styled":!Boolean(v.jsx||v.unstyled||b),"data-mounted":Q,"data-promise":Boolean(v.promise),"data-swiped":ne,"data-removed":$,"data-visible":pe,"data-y-position":xe,"data-x-position":Me,"data-index":N,"data-front":ue,"data-swiping":K,"data-dismissible":he,"data-type":me,"data-invert":Ie,"data-swipe-out":ee,"data-swipe-direction":F,"data-expanded":Boolean(I||W&&Q),"data-testid":v.testId,style:{"--index":N,"--toasts-before":N,"--z-index":E.length-N,"--offset":`${$?re:_e.current}px`,"--initial-height":W?"auto":`${oe}px`,...D,...v.style},onDragEnd:()=>{q(!1),U(null),ke.current=null},onPointerDown:e=>{2!==e.button&&!Ce&&he&&(ce.current=new Date,se(_e.current),e.target.setPointerCapture(e.pointerId),"BUTTON"!==e.target.tagName&&(q(!0),ke.current={x:e.clientX,y:e.clientY}))},onPointerUp:()=>{var e,t,n;if(ee||!he)return;ke.current=null;const a=Number((null==(e=de.current)?void 0:e.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),r=Number((null==(t=de.current)?void 0:t.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),s=(new Date).getTime()-(null==(n=ce.current)?void 0:n.getTime()),o="x"===V?a:r,l=Math.abs(o)/s;if(Math.abs(o)>=45||l>.11)return se(_e.current),null==v.onDismiss||v.onDismiss.call(v,v),H("x"===V?a>0?"right":"left":r>0?"down":"up"),Le(),void te(!0);var i,c;null==(i=de.current)||i.style.setProperty("--swipe-amount-x","0px"),null==(c=de.current)||c.style.setProperty("--swipe-amount-y","0px"),ae(!1),q(!1),U(null)},onPointerMove:t=>{var n,a,r;if(!ke.current||!he)return;if((null==(n=window.getSelection())?void 0:n.toString().length)>0)return;const s=t.clientY-ke.current.y,o=t.clientX-ke.current.x;var l;const i=null!=(l=e.swipeDirections)?l:function(e){const[t,n]=e.split("-"),a=[];return t&&a.push(t),n&&a.push(n),a}(R);!V&&(Math.abs(o)>1||Math.abs(s)>1)&&U(Math.abs(o)>Math.abs(s)?"x":"y");let c={x:0,y:0};const d=e=>1/(1.5+Math.abs(e)/20);if("y"===V){if(i.includes("top")||i.includes("bottom"))if(i.includes("top")&&s<0||i.includes("bottom")&&s>0)c.y=s;else{const e=s*d(s);c.y=Math.abs(e)0)c.x=o;else{const e=o*d(o);c.x=Math.abs(e)0||Math.abs(c.y)>0)&&ae(!0),null==(a=de.current)||a.style.setProperty("--swipe-amount-x",`${c.x}px`),null==(r=de.current)||r.style.setProperty("--swipe-amount-y",`${c.y}px`)}},ve&&!v.jsx&&"loading"!==me?a.createElement("button",{"aria-label":B,"data-disabled":Ce,"data-close-button":!0,onClick:Ce||!he?()=>{}:()=>{Le(),null==v.onDismiss||v.onDismiss.call(v,v)},className:k(null==Y?void 0:Y.closeButton,null==v||null==(r=v.classNames)?void 0:r.closeButton)},null!=(Te=null==G?void 0:G.close)?Te:f):null,(me||v.icon||v.promise)&&null!==v.icon&&(null!==(null==G?void 0:G[me])||v.icon)?a.createElement("div",{"data-icon":"",className:k(null==Y?void 0:Y.icon,null==v||null==(s=v.classNames)?void 0:s.icon)},v.promise||"loading"===v.type&&!v.icon?v.icon||function(){var e,t;return(null==G?void 0:G.loading)?a.createElement("div",{className:k(null==Y?void 0:Y.loader,null==v||null==(t=v.classNames)?void 0:t.loader,"sonner-loader"),"data-visible":"loading"===me},G.loading):a.createElement(d,{className:k(null==Y?void 0:Y.loader,null==v||null==(e=v.classNames)?void 0:e.loader),visible:"loading"===me})}():null,"loading"!==v.type?Se:null):null,a.createElement("div",{"data-content":"",className:k(null==Y?void 0:Y.content,null==v||null==(o=v.classNames)?void 0:o.content)},a.createElement("div",{"data-title":"",className:k(null==Y?void 0:Y.title,null==v||null==(l=v.classNames)?void 0:l.title)},v.jsx?v.jsx:"function"==typeof v.title?v.title():v.title),v.description?a.createElement("div",{"data-description":"",className:k(z,ge,null==Y?void 0:Y.description,null==v||null==(i=v.classNames)?void 0:i.description)},"function"==typeof v.description?v.description():v.description):null),a.isValidElement(v.cancel)?v.cancel:v.cancel&&w(v.cancel)?a.createElement("button",{"data-button":!0,"data-cancel":!0,style:v.cancelButtonStyle||T,onClick:e=>{w(v.cancel)&&he&&(null==v.cancel.onClick||v.cancel.onClick.call(v.cancel,e),Le())},className:k(null==Y?void 0:Y.cancelButton,null==v||null==(c=v.classNames)?void 0:c.cancelButton)},v.cancel.label):null,a.isValidElement(v.action)?v.action:v.action&&w(v.action)?a.createElement("button",{"data-button":!0,"data-action":!0,style:v.actionButtonStyle||A,onClick:e=>{w(v.action)&&(null==v.action.onClick||v.action.onClick.call(v.action,e),e.defaultPrevented||Le())},className:k(null==Y?void 0:Y.actionButton,null==v||null==(g=v.classNames)?void 0:g.actionButton)},v.action.label):null)};function M(){if("undefined"==typeof window)return"ltr";if("undefined"==typeof document)return"ltr";const e=document.documentElement.getAttribute("dir");return"auto"!==e&&e?e:window.getComputedStyle(document.documentElement).direction}function N(e,t){const n={};return[e,t].forEach((e,t)=>{const a=1===t,r=a?"--mobile-offset":"--offset",s=a?"16px":"24px";function o(e){["top","right","bottom","left"].forEach(t=>{n[`${r}-${t}`]="number"==typeof e?`${e}px`:e})}"number"==typeof e||"string"==typeof e?o(e):"object"==typeof e?["top","right","bottom","left"].forEach(t=>{void 0===e[t]?n[`${r}-${t}`]=s:n[`${r}-${t}`]="number"==typeof e[t]?`${e[t]}px`:e[t]}):o(s)}),n}const E=a.forwardRef(function(e,t){const{id:n,invert:r,position:s="bottom-right",hotkey:o=["altKey","KeyT"],expand:l,closeButton:c,className:d,offset:u,mobileOffset:p,theme:m="light",richColors:h,duration:f,style:g,visibleToasts:v=_,toastOptions:b,dir:w=M(),gap:k=j,icons:E,containerAriaLabel:I="Notifications"}=e,[C,L]=a.useState([]),S=a.useMemo(()=>n?C.filter(e=>e.toasterId===n):C.filter(e=>!e.toasterId),[C,n]),D=a.useMemo(()=>Array.from(new Set([s].concat(S.filter(e=>e.position).map(e=>e.position)))),[S,s]),[T,A]=a.useState([]),[O,z]=a.useState(!1),[P,R]=a.useState(!1),[Z,W]=a.useState("system"!==m?m:"undefined"!=typeof window&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),Y=a.useRef(null),G=o.join("+").replace(/Key/g,"").replace(/Digit/g,""),B=a.useRef(null),V=a.useRef(!1),U=a.useCallback(e=>{L(t=>{var n;return(null==(n=t.find(t=>t.id===e.id))?void 0:n.delete)||y.dismiss(e.id),t.filter(({id:t})=>t!==e.id)})},[]);return a.useEffect(()=>y.subscribe(e=>{e.dismiss?requestAnimationFrame(()=>{L(t=>t.map(t=>t.id===e.id?{...t,delete:!0}:t))}):setTimeout(()=>{i.flushSync(()=>{L(t=>{const n=t.findIndex(t=>t.id===e.id);return-1!==n?[...t.slice(0,n),{...t[n],...e},...t.slice(n+1)]:[e,...t]})})})}),[C]),a.useEffect(()=>{if("system"!==m)return void W(m);if("system"===m&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?W("dark"):W("light")),"undefined"==typeof window)return;const e=window.matchMedia("(prefers-color-scheme: dark)");try{e.addEventListener("change",({matches:e})=>{W(e?"dark":"light")})}catch(t){e.addListener(({matches:e})=>{try{W(e?"dark":"light")}catch(e){console.error(e)}})}},[m]),a.useEffect(()=>{C.length<=1&&z(!1)},[C]),a.useEffect(()=>{const e=e=>{var t;var n;o.every(t=>e[t]||e.code===t)&&(z(!0),null==(n=Y.current)||n.focus()),"Escape"!==e.code||document.activeElement!==Y.current&&!(null==(t=Y.current)?void 0:t.contains(document.activeElement))||z(!1)};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[o]),a.useEffect(()=>{if(Y.current)return()=>{B.current&&(B.current.focus({preventScroll:!0}),B.current=null,V.current=!1)}},[Y.current]),a.createElement("section",{ref:t,"aria-label":`${I} ${G}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},D.map((t,n)=>{var s;const[o,i]=t.split("-");return S.length?a.createElement("ol",{key:t,dir:"auto"===w?M():w,tabIndex:-1,ref:Y,className:d,"data-sonner-toaster":!0,"data-sonner-theme":Z,"data-y-position":o,"data-x-position":i,style:{"--front-toast-height":`${(null==(s=T[0])?void 0:s.height)||0}px`,"--width":"356px","--gap":`${k}px`,...g,...N(u,p)},onBlur:e=>{V.current&&!e.currentTarget.contains(e.relatedTarget)&&(V.current=!1,B.current&&(B.current.focus({preventScroll:!0}),B.current=null))},onFocus:e=>{e.target instanceof HTMLElement&&"false"===e.target.dataset.dismissible||V.current||(V.current=!0,B.current=e.relatedTarget)},onMouseEnter:()=>z(!0),onMouseMove:()=>z(!0),onMouseLeave:()=>{P||z(!1)},onDragEnd:()=>z(!1),onPointerDown:e=>{e.target instanceof HTMLElement&&"false"===e.target.dataset.dismissible||R(!0)},onPointerUp:()=>R(!1)},S.filter(e=>!e.position&&0===n||e.position===t).map((n,s)=>{var o,i;return a.createElement(x,{key:n.id,icons:E,index:s,toast:n,defaultRichColors:h,duration:null!=(o=null==b?void 0:b.duration)?o:f,className:null==b?void 0:b.className,descriptionClassName:null==b?void 0:b.descriptionClassName,invert:r,visibleToasts:v,closeButton:null!=(i=null==b?void 0:b.closeButton)?i:c,interacting:P,position:t,style:null==b?void 0:b.style,unstyled:null==b?void 0:b.unstyled,classNames:null==b?void 0:b.classNames,cancelButtonStyle:null==b?void 0:b.cancelButtonStyle,actionButtonStyle:null==b?void 0:b.actionButtonStyle,closeButtonAriaLabel:null==b?void 0:b.closeButtonAriaLabel,removeToast:U,toasts:S.filter(e=>e.position==n.position),heights:T.filter(e=>e.position==n.position),setHeights:A,expandByDefault:l,gap:k,expanded:O,swipeDirections:e.swipeDirections})})):null}))});var I=n(848);const C=e=>{const t=(e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,n)=>n?n.toUpperCase():t.toLowerCase()))(e);return t.charAt(0).toUpperCase()+t.slice(1)},L=(...e)=>e.filter((e,t,n)=>Boolean(e)&&""!==e.trim()&&n.indexOf(e)===t).join(" ").trim(),S=e=>{for(const t in e)if(t.startsWith("aria-")||"role"===t||"title"===t)return!0};var D={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const T=(0,a.forwardRef)(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:s="",children:o,iconNode:l,...i},c)=>(0,a.createElement)("svg",{ref:c,...D,width:t,height:t,stroke:e,strokeWidth:r?24*Number(n)/Number(t):n,className:L("lucide",s),...!o&&!S(i)&&{"aria-hidden":"true"},...i},[...l.map(([e,t])=>(0,a.createElement)(e,t)),...Array.isArray(o)?o:[o]])),A=(e,t)=>{const n=(0,a.forwardRef)(({className:n,...r},s)=>{return(0,a.createElement)(T,{ref:s,iconNode:t,className:L(`lucide-${o=C(e),o.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}`,`lucide-${e}`,n),...r});var o});return n.displayName=C(e),n},O=A("search",[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]);function z(e,[t,n]){return Math.min(n,Math.max(t,e))}function P(e,t,{checkForDefaultPrevented:n=!0}={}){return function(a){if(e?.(a),!1===n||!a||!a.defaultPrevented)return t?.(a)}}function R(e,t=[]){let n=[];const r=()=>{const t=n.map(e=>a.createContext(e));return function(n){const r=n?.[e]||t;return a.useMemo(()=>({[`__scope${e}`]:{...n,[e]:r}}),[n,r])}};return r.scopeName=e,[function(t,r){const s=a.createContext(r);s.displayName=t+"Context";const o=n.length;n=[...n,r];const l=t=>{const{scope:n,children:r,...l}=t,i=n?.[e]?.[o]||s,c=a.useMemo(()=>l,Object.values(l));return(0,I.jsx)(i.Provider,{value:c,children:r})};return l.displayName=t+"Provider",[l,function(n,l,i={}){const{optional:c=!1}=i,d=l?.[e]?.[o]||s,u=a.useContext(d);if(u)return u;if(void 0!==r)return r;if(!c)throw new Error(`\`${n}\` must be used within \`${t}\``)}]},Z(r,...t)]}function Z(...e){const t=e[0];if(1===e.length)return t;const n=()=>{const n=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return function(e){const r=n.reduce((t,{useScope:n,scopeName:a})=>({...t,...n(e)[`__scope${a}`]}),{});return a.useMemo(()=>({[`__scope${t.scopeName}`]:r}),[r])}};return n.scopeName=t.scopeName,n}function W(e,t){if("function"==typeof e)return e(t);null!=e&&(e.current=t)}function Y(...e){return a.useCallback(function(...e){return t=>{let n=!1;const a=e.map(e=>{const a=W(e,t);return n||"function"!=typeof a||(n=!0),a});if(n)return()=>{for(let t=0;t{let{children:r,...s}=t,o=null,l=!1;const i=[];F(r)&&"function"==typeof X&&(r=X(r._payload)),a.Children.forEach(r,e=>{if(t=e,a.isValidElement(t)&&"function"==typeof t.type&&"__radixId"in t.type&&t.type.__radixId===B){l=!0;const t=e;let n="child"in t.props?t.props.child:t.props.children;F(n)&&"function"==typeof X&&(n=X(n._payload)),o=V(t,n),i.push(o?.props?.children)}else i.push(e);var t}),o?o=a.cloneElement(o,void 0,i):!l&&1===a.Children.count(r)&&a.isValidElement(r)&&(o=r);const c=o?function(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}(o):void 0,d=Y(n,c);if(!o){if(r||0===r)throw new Error(l?Q(e):H(e));return r}const u=function(e,t){const n={...t};for(const a in t){const r=e[a],s=t[a];/^on[A-Z]/.test(a)?r&&s?n[a]=(...e)=>{const t=s(...e);return r(...e),t}:r&&(n[a]=r):"style"===a?n[a]={...r,...s}:"className"===a&&(n[a]=[r,s].filter(Boolean).join(" "))}return{...e,...n}}(s,o.props??{});return o.type!==a.Fragment&&(u.ref=n?d:c),a.cloneElement(o,u)});return t.displayName=`${e}.Slot`,t}"undefined"==typeof window||!window.document||window.document.createElement;var B=Symbol.for("radix.slottable");var V=(e,t)=>{if("child"in e.props){const t=e.props.child;return a.isValidElement(t)?a.cloneElement(t,void 0,e.props.children(t.props.children)):null}return a.isValidElement(t)?t:null},U=Symbol.for("react.lazy");function F(e){return null!=e&&"object"==typeof e&&"$$typeof"in e&&e.$$typeof===U&&"_payload"in e&&"object"==typeof(t=e._payload)&&null!==t&&"then"in t;var t}var H=e=>`${e} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,Q=e=>`${e} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,X=r[" use ".trim().toString()];function $(e){const t=e+"CollectionProvider",[n,r]=R(t),[s,o]=n(t,{collectionRef:{current:null},itemMap:new Map}),l=e=>{const{scope:t,children:n}=e,r=a.useRef(null),o=a.useRef(new Map).current;return(0,I.jsx)(s,{scope:t,itemMap:o,collectionRef:r,children:n})};l.displayName=t;const i=e+"CollectionSlot",c=G(i),d=a.forwardRef((e,t)=>{const{scope:n,children:a}=e,r=Y(t,o(i,n).collectionRef);return(0,I.jsx)(c,{ref:r,children:a})});d.displayName=i;const u=e+"CollectionItemSlot",p="data-radix-collection-item",m=G(u),h=a.forwardRef((e,t)=>{const{scope:n,children:r,...s}=e,l=a.useRef(null),i=Y(t,l),c=o(u,n);return a.useEffect(()=>(c.itemMap.set(l,{ref:l,...s}),()=>{c.itemMap.delete(l)})),(0,I.jsx)(m,{[p]:"",ref:i,children:r})});return h.displayName=u,[{Provider:l,Slot:d,ItemSlot:h},function(t){const n=o(e+"CollectionConsumer",t);return a.useCallback(()=>{const e=n.collectionRef.current;if(!e)return[];const t=Array.from(e.querySelectorAll(`[${p}]`));return Array.from(n.itemMap.values()).sort((e,n)=>t.indexOf(e.ref.current)-t.indexOf(n.ref.current))},[n.collectionRef,n.itemMap])},r]}Map;var J=a.createContext(void 0);function K(e){const t=a.useContext(J);return e||t||"ltr"}var q=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((e,t)=>{const n=G(`Primitive.${t}`),r=a.forwardRef((e,a)=>{const{asChild:r,...s}=e,o=r?n:t;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),(0,I.jsx)(o,{...s,ref:a})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function ee(e,t){e&&i.flushSync(()=>e.dispatchEvent(t))}function te(e){const t=a.useRef(e);return a.useEffect(()=>{t.current=e}),a.useMemo(()=>(...e)=>t.current?.(...e),[])}var ne,ae="dismissableLayer.update",re=a.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),se=a.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,deferPointerDownOutside:r=!1,onEscapeKeyDown:s,onPointerDownOutside:o,onFocusOutside:l,onInteractOutside:i,onDismiss:c,...d}=e,u=a.useContext(re),[p,m]=a.useState(null),h=p?.ownerDocument??globalThis?.document,[,f]=a.useState({}),g=Y(t,m),y=Array.from(u.layers),[v]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),b=v?y.indexOf(v):-1,w=p?y.indexOf(p):-1,_=u.layersWithOutsidePointerEventsDisabled.size>0,j=w>=b,k=a.useRef(!1),x=function(e,t){const{ownerDocument:n=globalThis?.document,deferPointerDownOutside:r=!1,isDeferredPointerDownOutsideRef:s,dismissableSurfaces:o,shouldHandlePointerDownOutside:l=oe}=t,i=te(e),c=a.useRef(!1),d=a.useRef(!1),u=a.useRef(new Map),p=a.useRef(()=>{});return a.useEffect(()=>{function e(){d.current=!1,s.current=!1,u.current.clear()}function t(e){if(!d.current)return;const t=e.target;t instanceof Node&&[...o].some(e=>e.contains(t))||u.current.set(e.type,!0),"click"===e.type&&window.setTimeout(()=>{d.current&&p.current()},0)}function a(e){d.current&&u.current.set(e.type,!1)}const m=t=>{if(t.target&&!c.current){let a=function(){n.removeEventListener("click",p.current);const t=Array.from(u.current.values()).some(Boolean);e(),t||ie("dismissableLayer.pointerDownOutside",i,o,{discrete:!0})};if(!l(t.target))return n.removeEventListener("click",p.current),e(),void(c.current=!1);const o={originalEvent:t};d.current=!0,s.current=r&&0===t.button,u.current.clear(),r&&0===t.button?(n.removeEventListener("click",p.current),p.current=a,n.addEventListener("click",p.current,{once:!0})):a()}else n.removeEventListener("click",p.current),e();c.current=!1},h=["pointerup","mousedown","mouseup","touchstart","touchend","click"];for(const e of h)n.addEventListener(e,t,!0),n.addEventListener(e,a);const f=window.setTimeout(()=>{n.addEventListener("pointerdown",m)},0);return()=>{window.clearTimeout(f),n.removeEventListener("pointerdown",m),n.removeEventListener("click",p.current);for(const e of h)n.removeEventListener(e,t,!0),n.removeEventListener(e,a)}},[n,i,r,s,o,l]),{onPointerDownCapture:()=>c.current=!0}}(e=>{o?.(e),i?.(e),e.defaultPrevented||c?.()},{ownerDocument:h,deferPointerDownOutside:r,isDeferredPointerDownOutsideRef:k,dismissableSurfaces:u.dismissableSurfaces,shouldHandlePointerDownOutside:a.useCallback(e=>{if(!(e instanceof Node))return!1;const t=[...u.branches].some(t=>t.contains(e));return j&&!t},[u.branches,j])}),M=function(e,t=globalThis?.document){const n=te(e),r=a.useRef(!1);return a.useEffect(()=>{const e=e=>{e.target&&!r.current&&ie("dismissableLayer.focusOutside",n,{originalEvent:e},{discrete:!1})};return t.addEventListener("focusin",e),()=>t.removeEventListener("focusin",e)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}(e=>{if(r&&k.current)return;const t=e.target;[...u.branches].some(e=>e.contains(t))||(l?.(e),i?.(e),e.defaultPrevented||c?.())},h),N=!!p&&w===y.length-1,E=te(e=>{"Escape"===e.key&&(s?.(e),!e.defaultPrevented&&c&&(e.preventDefault(),c()))});return a.useEffect(()=>{if(N)return h.addEventListener("keydown",E,{capture:!0}),()=>h.removeEventListener("keydown",E,{capture:!0})},[h,N,E]),a.useEffect(()=>{if(p)return n&&(0===u.layersWithOutsidePointerEventsDisabled.size&&(ne=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(p)),u.layers.add(p),le(),()=>{n&&(u.layersWithOutsidePointerEventsDisabled.delete(p),0===u.layersWithOutsidePointerEventsDisabled.size&&(h.body.style.pointerEvents=ne))}},[p,h,n,u]),a.useEffect(()=>()=>{p&&(u.layers.delete(p),u.layersWithOutsidePointerEventsDisabled.delete(p),le())},[p,u]),a.useEffect(()=>{const e=()=>f({});return document.addEventListener(ae,e),()=>document.removeEventListener(ae,e)},[]),(0,I.jsx)(q.div,{...d,ref:g,style:{pointerEvents:_?j?"auto":"none":void 0,...e.style},onFocusCapture:P(e.onFocusCapture,M.onFocusCapture),onBlurCapture:P(e.onBlurCapture,M.onBlurCapture),onPointerDownCapture:P(e.onPointerDownCapture,x.onPointerDownCapture)})});se.displayName="DismissableLayer",a.forwardRef((e,t)=>{const n=a.useContext(re),r=a.useRef(null),s=Y(t,r);return a.useEffect(()=>{const e=r.current;if(e)return n.branches.add(e),()=>{n.branches.delete(e)}},[n.branches]),(0,I.jsx)(q.div,{...e,ref:s})}).displayName="DismissableLayerBranch";var oe=()=>!0;function le(){const e=new CustomEvent(ae);document.dispatchEvent(e)}function ie(e,t,n,{discrete:a}){const r=n.originalEvent.target,s=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&r.addEventListener(e,t,{once:!0}),a?ee(r,s):r.dispatchEvent(s)}var ce=0,de=null;function ue(){a.useEffect(()=>{de||(de={start:pe(),end:pe()});const{start:e,end:t}=de;return document.body.firstElementChild!==e&&document.body.insertAdjacentElement("afterbegin",e),document.body.lastElementChild!==t&&document.body.insertAdjacentElement("beforeend",t),ce++,()=>{1===ce&&(de?.start.remove(),de?.end.remove(),de=null),ce=Math.max(0,ce-1)}},[])}function pe(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var me="focusScope.autoFocusOnMount",he="focusScope.autoFocusOnUnmount",fe={bubbles:!1,cancelable:!0},ge=a.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:s,onUnmountAutoFocus:o,...l}=e,[i,c]=a.useState(null),d=te(s),u=te(o),p=a.useRef(null),m=Y(t,c),h=a.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;a.useEffect(()=>{if(r){let e=function(e){if(h.paused||!i)return;const t=e.target;i.contains(t)?p.current=t:we(p.current,{select:!0})},t=function(e){if(h.paused||!i)return;const t=e.relatedTarget;null!==t&&(i.contains(t)||we(p.current,{select:!0}))},n=function(e){if(document.activeElement===document.body)for(const t of e)t.removedNodes.length>0&&we(i)};document.addEventListener("focusin",e),document.addEventListener("focusout",t);const a=new MutationObserver(n);return i&&a.observe(i,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",e),document.removeEventListener("focusout",t),a.disconnect()}}},[r,i,h.paused]),a.useEffect(()=>{if(i){_e.add(h);const e=document.activeElement;if(!i.contains(e)){const t=new CustomEvent(me,fe);i.addEventListener(me,d),i.dispatchEvent(t),t.defaultPrevented||(function(e,{select:t=!1}={}){const n=document.activeElement;for(const a of e)if(we(a,{select:t}),document.activeElement!==n)return}(ye(i).filter(e=>"A"!==e.tagName),{select:!0}),document.activeElement===e&&we(i))}return()=>{i.removeEventListener(me,d),setTimeout(()=>{const t=new CustomEvent(he,fe);i.addEventListener(he,u),i.dispatchEvent(t),t.defaultPrevented||we(e??document.body,{select:!0}),i.removeEventListener(he,u),_e.remove(h)},0)}}},[i,d,u,h]);const f=a.useCallback(e=>{if(!n&&!r)return;if(h.paused)return;const t="Tab"===e.key&&!e.altKey&&!e.ctrlKey&&!e.metaKey,a=document.activeElement;if(t&&a){const t=e.currentTarget,[r,s]=function(e){const t=ye(e);return[ve(t,e),ve(t.reverse(),e)]}(t);r&&s?e.shiftKey||a!==s?e.shiftKey&&a===r&&(e.preventDefault(),n&&we(s,{select:!0})):(e.preventDefault(),n&&we(r,{select:!0})):a===t&&e.preventDefault()}},[n,r,h.paused]);return(0,I.jsx)(q.div,{tabIndex:-1,...l,ref:m,onKeyDown:f})});function ye(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>{const t="INPUT"===e.tagName&&"hidden"===e.type;return e.disabled||e.hidden||t?NodeFilter.FILTER_SKIP:e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function ve(e,t){const n="function"==typeof t.checkVisibility&&t.checkVisibility({checkVisibilityCSS:!0});for(const a of e)if(!(n?!a.checkVisibility({checkVisibilityCSS:!0}):be(a,{upTo:t})))return a}function be(e,{upTo:t}){if("hidden"===getComputedStyle(e).visibility)return!0;for(;e;){if(void 0!==t&&e===t)return!1;if("none"===getComputedStyle(e).display)return!0;e=e.parentElement}return!1}function we(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&function(e){return e instanceof HTMLInputElement&&"select"in e}(e)&&t&&e.select()}}ge.displayName="FocusScope";var _e=function(){let e=[];return{add(t){const n=e[0];t!==n&&n?.pause(),e=je(e,t),e.unshift(t)},remove(t){e=je(e,t),e[0]?.resume()}}}();function je(e,t){const n=[...e],a=n.indexOf(t);return-1!==a&&n.splice(a,1),n}var ke=globalThis?.document?a.useLayoutEffect:()=>{},xe=r[" useId ".trim().toString()]||(()=>{}),Me=0;function Ne(e){const[t,n]=a.useState(xe());return ke(()=>{e||n(e=>e??String(Me++))},[e]),e||(t?`radix-${t}`:"")}const Ee=["top","right","bottom","left"],Ie=Math.min,Ce=Math.max,Le=Math.round,Se=Math.floor,De=e=>({x:e,y:e}),Te={left:"right",right:"left",bottom:"top",top:"bottom"};function Ae(e,t,n){return Ce(e,Ie(t,n))}function Oe(e,t){return"function"==typeof e?e(t):e}function ze(e){return e.split("-")[0]}function Pe(e){return e.split("-")[1]}function Re(e){return"x"===e?"y":"x"}function Ze(e){return"y"===e?"height":"width"}function We(e){const t=e[0];return"t"===t||"b"===t?"y":"x"}function Ye(e){return Re(We(e))}function Ge(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const Be=["left","right"],Ve=["right","left"],Ue=["top","bottom"],Fe=["bottom","top"];function He(e){const t=ze(e);return Te[t]+e.slice(t.length)}function Qe(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 Xe(e){const{x:t,y:n,width:a,height:r}=e;return{width:a,height:r,top:n,left:t,right:t+a,bottom:n+r,x:t,y:n}}function $e(e,t,n){let{reference:a,floating:r}=e;const s=We(t),o=Ye(t),l=Ze(o),i=ze(t),c="y"===s,d=a.x+a.width/2-r.width/2,u=a.y+a.height/2-r.height/2,p=a[l]/2-r[l]/2;let m;switch(i){case"top":m={x:d,y:a.y-r.height};break;case"bottom":m={x:d,y:a.y+a.height};break;case"right":m={x:a.x+a.width,y:u};break;case"left":m={x:a.x-r.width,y:u};break;default:m={x:a.x,y:a.y}}switch(Pe(t)){case"start":m[o]-=p*(n&&c?-1:1);break;case"end":m[o]+=p*(n&&c?-1:1)}return m}async function Je(e,t){var n;void 0===t&&(t={});const{x:a,y:r,platform:s,rects:o,elements:l,strategy:i}=e,{boundary:c="clippingAncestors",rootBoundary:d="viewport",elementContext:u="floating",altBoundary:p=!1,padding:m=0}=Oe(t,e),h=Qe(m),f=l[p?"floating"===u?"reference":"floating":u],g=Xe(await s.getClippingRect({element:null==(n=await(null==s.isElement?void 0:s.isElement(f)))||n?f:f.contextElement||await(null==s.getDocumentElement?void 0:s.getDocumentElement(l.floating)),boundary:c,rootBoundary:d,strategy:i})),y="floating"===u?{x:a,y:r,width:o.floating.width,height:o.floating.height}:o.reference,v=await(null==s.getOffsetParent?void 0:s.getOffsetParent(l.floating)),b=await(null==s.isElement?void 0:s.isElement(v))&&await(null==s.getScale?void 0:s.getScale(v))||{x:1,y:1},w=Xe(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:y,offsetParent:v,strategy:i}):y);return{top:(g.top-w.top+h.top)/b.y,bottom:(w.bottom-g.bottom+h.bottom)/b.y,left:(g.left-w.left+h.left)/b.x,right:(w.right-g.right+h.right)/b.x}}function Ke(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function qe(e){return Ee.some(t=>e[t]>=0)}const et=new Set(["left","top"]);function tt(){return"undefined"!=typeof window}function nt(e){return st(e)?(e.nodeName||"").toLowerCase():"#document"}function at(e){var t;return(null==e||null==(t=e.ownerDocument)?void 0:t.defaultView)||window}function rt(e){var t;return null==(t=(st(e)?e.ownerDocument:e.document)||window.document)?void 0:t.documentElement}function st(e){return!!tt()&&(e instanceof Node||e instanceof at(e).Node)}function ot(e){return!!tt()&&(e instanceof Element||e instanceof at(e).Element)}function lt(e){return!!tt()&&(e instanceof HTMLElement||e instanceof at(e).HTMLElement)}function it(e){return!(!tt()||"undefined"==typeof ShadowRoot)&&(e instanceof ShadowRoot||e instanceof at(e).ShadowRoot)}function ct(e){const{overflow:t,overflowX:n,overflowY:a,display:r}=bt(e);return/auto|scroll|overlay|hidden|clip/.test(t+a+n)&&"inline"!==r&&"contents"!==r}function dt(e){return/^(table|td|th)$/.test(nt(e))}function ut(e){try{if(e.matches(":popover-open"))return!0}catch(e){}try{return e.matches(":modal")}catch(e){return!1}}const pt=/transform|translate|scale|rotate|perspective|filter/,mt=/paint|layout|strict|content/,ht=e=>!!e&&"none"!==e;let ft;function gt(e){const t=ot(e)?bt(e):e;return ht(t.transform)||ht(t.translate)||ht(t.scale)||ht(t.rotate)||ht(t.perspective)||!yt()&&(ht(t.backdropFilter)||ht(t.filter))||pt.test(t.willChange||"")||mt.test(t.contain||"")}function yt(){return null==ft&&(ft="undefined"!=typeof CSS&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),ft}function vt(e){return/^(html|body|#document)$/.test(nt(e))}function bt(e){return at(e).getComputedStyle(e)}function wt(e){return ot(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function _t(e){if("html"===nt(e))return e;const t=e.assignedSlot||e.parentNode||it(e)&&e.host||rt(e);return it(t)?t.host:t}function jt(e){const t=_t(e);return vt(t)?e.ownerDocument?e.ownerDocument.body:e.body:lt(t)&&ct(t)?t:jt(t)}function kt(e,t,n){var a;void 0===t&&(t=[]),void 0===n&&(n=!0);const r=jt(e),s=r===(null==(a=e.ownerDocument)?void 0:a.body),o=at(r);if(s){const e=xt(o);return t.concat(o,o.visualViewport||[],ct(r)?r:[],e&&n?kt(e):[])}return t.concat(r,kt(r,[],n))}function xt(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Mt(e){const t=bt(e);let n=parseFloat(t.width)||0,a=parseFloat(t.height)||0;const r=lt(e),s=r?e.offsetWidth:n,o=r?e.offsetHeight:a,l=Le(n)!==s||Le(a)!==o;return l&&(n=s,a=o),{width:n,height:a,$:l}}function Nt(e){return ot(e)?e:e.contextElement}function Et(e){const t=Nt(e);if(!lt(t))return De(1);const n=t.getBoundingClientRect(),{width:a,height:r,$:s}=Mt(t);let o=(s?Le(n.width):n.width)/a,l=(s?Le(n.height):n.height)/r;return o&&Number.isFinite(o)||(o=1),l&&Number.isFinite(l)||(l=1),{x:o,y:l}}const It=De(0);function Ct(e){const t=at(e);return yt()&&t.visualViewport?{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}:It}function Lt(e,t,n,a){void 0===t&&(t=!1),void 0===n&&(n=!1);const r=e.getBoundingClientRect(),s=Nt(e);let o=De(1);t&&(a?ot(a)&&(o=Et(a)):o=Et(e));const l=function(e,t,n){return void 0===t&&(t=!1),!(!n||t&&n!==at(e))&&t}(s,n,a)?Ct(s):De(0);let i=(r.left+l.x)/o.x,c=(r.top+l.y)/o.y,d=r.width/o.x,u=r.height/o.y;if(s){const e=at(s),t=a&&ot(a)?at(a):a;let n=e,r=xt(n);for(;r&&a&&t!==n;){const e=Et(r),t=r.getBoundingClientRect(),a=bt(r),s=t.left+(r.clientLeft+parseFloat(a.paddingLeft))*e.x,o=t.top+(r.clientTop+parseFloat(a.paddingTop))*e.y;i*=e.x,c*=e.y,d*=e.x,u*=e.y,i+=s,c+=o,n=at(r),r=xt(n)}}return Xe({width:d,height:u,x:i,y:c})}function St(e,t){const n=wt(e).scrollLeft;return t?t.left+n:Lt(rt(e)).left+n}function Dt(e,t){const n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-St(e,n),y:n.top+t.scrollTop}}function Tt(e,t,n){let a;if("viewport"===t)a=function(e,t){const n=at(e),a=rt(e),r=n.visualViewport;let s=a.clientWidth,o=a.clientHeight,l=0,i=0;if(r){s=r.width,o=r.height;const e=yt();(!e||e&&"fixed"===t)&&(l=r.offsetLeft,i=r.offsetTop)}const c=St(a);if(c<=0){const e=a.ownerDocument,t=e.body,n=getComputedStyle(t),r="CSS1Compat"===e.compatMode&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,o=Math.abs(a.clientWidth-t.clientWidth-r);o<=25&&(s-=o)}else c<=25&&(s+=c);return{width:s,height:o,x:l,y:i}}(e,n);else if("document"===t)a=function(e){const t=rt(e),n=wt(e),a=e.ownerDocument.body,r=Ce(t.scrollWidth,t.clientWidth,a.scrollWidth,a.clientWidth),s=Ce(t.scrollHeight,t.clientHeight,a.scrollHeight,a.clientHeight);let o=-n.scrollLeft+St(e);const l=-n.scrollTop;return"rtl"===bt(a).direction&&(o+=Ce(t.clientWidth,a.clientWidth)-r),{width:r,height:s,x:o,y:l}}(rt(e));else if(ot(t))a=function(e,t){const n=Lt(e,!0,"fixed"===t),a=n.top+e.clientTop,r=n.left+e.clientLeft,s=lt(e)?Et(e):De(1);return{width:e.clientWidth*s.x,height:e.clientHeight*s.y,x:r*s.x,y:a*s.y}}(t,n);else{const n=Ct(e);a={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return Xe(a)}function At(e,t){const n=_t(e);return!(n===t||!ot(n)||vt(n))&&("fixed"===bt(n).position||At(n,t))}function Ot(e,t,n){const a=lt(t),r=rt(t),s="fixed"===n,o=Lt(e,!0,s,t);let l={scrollLeft:0,scrollTop:0};const i=De(0);function c(){i.x=St(r)}if(a||!a&&!s)if(("body"!==nt(t)||ct(r))&&(l=wt(t)),a){const e=Lt(t,!0,s,t);i.x=e.x+t.clientLeft,i.y=e.y+t.clientTop}else r&&c();s&&!a&&r&&c();const d=!r||a||s?De(0):Dt(r,l);return{x:o.left+l.scrollLeft-i.x-d.x,y:o.top+l.scrollTop-i.y-d.y,width:o.width,height:o.height}}function zt(e){return"static"===bt(e).position}function Pt(e,t){if(!lt(e)||"fixed"===bt(e).position)return null;if(t)return t(e);let n=e.offsetParent;return rt(e)===n&&(n=n.ownerDocument.body),n}function Rt(e,t){const n=at(e);if(ut(e))return n;if(!lt(e)){let t=_t(e);for(;t&&!vt(t);){if(ot(t)&&!zt(t))return t;t=_t(t)}return n}let a=Pt(e,t);for(;a&&dt(a)&&zt(a);)a=Pt(a,t);return a&&vt(a)&&zt(a)&&!gt(a)?n:a||function(e){let t=_t(e);for(;lt(t)&&!vt(t);){if(gt(t))return t;if(ut(t))return null;t=_t(t)}return null}(e)||n}const Zt={convertOffsetParentRelativeRectToViewportRelativeRect:function(e){let{elements:t,rect:n,offsetParent:a,strategy:r}=e;const s="fixed"===r,o=rt(a),l=!!t&&ut(t.floating);if(a===o||l&&s)return n;let i={scrollLeft:0,scrollTop:0},c=De(1);const d=De(0),u=lt(a);if((u||!u&&!s)&&(("body"!==nt(a)||ct(o))&&(i=wt(a)),u)){const e=Lt(a);c=Et(a),d.x=e.x+a.clientLeft,d.y=e.y+a.clientTop}const p=!o||u||s?De(0):Dt(o,i);return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-i.scrollLeft*c.x+d.x+p.x,y:n.y*c.y-i.scrollTop*c.y+d.y+p.y}},getDocumentElement:rt,getClippingRect:function(e){let{element:t,boundary:n,rootBoundary:a,strategy:r}=e;const s="clippingAncestors"===n?ut(t)?[]:function(e,t){const n=t.get(e);if(n)return n;let a=kt(e,[],!1).filter(e=>ot(e)&&"body"!==nt(e)),r=null;const s="fixed"===bt(e).position;let o=s?_t(e):e;for(;ot(o)&&!vt(o);){const t=bt(o),n=gt(o);n||"fixed"!==t.position||(r=null),(s?!n&&!r:!n&&"static"===t.position&&r&&("absolute"===r.position||"fixed"===r.position)||ct(o)&&!n&&At(e,o))?a=a.filter(e=>e!==o):r=t,o=_t(o)}return t.set(e,a),a}(t,this._c):[].concat(n),o=[...s,a],l=Tt(t,o[0],r);let i=l.top,c=l.right,d=l.bottom,u=l.left;for(let e=1;ee+"-"+r),t&&(s=s.concat(s.map(Ge)))),s}(l,f,h,w));const k=[l,..._],x=await i.detectOverflow(t,g),M=[];let N=(null==(a=s.flip)?void 0:a.overflows)||[];if(d&&M.push(x[y]),u){const e=function(e,t,n){void 0===n&&(n=!1);const a=Pe(e),r=Ye(e),s=Ze(r);let o="x"===r?a===(n?"end":"start")?"right":"left":"start"===a?"bottom":"top";return t.reference[s]>t.floating[s]&&(o=He(o)),[o,He(o)]}(r,o,w);M.push(x[e[0]],x[e[1]])}if(N=[...N,{placement:r,overflows:M}],!M.every(e=>e<=0)){var E,I;const e=((null==(E=s.flip)?void 0:E.index)||0)+1,t=k[e];if(t&&("alignment"!==u||v===We(t)||N.every(e=>We(e.placement)!==v||e.overflows[0]>0)))return{data:{index:e,overflows:N},reset:{placement:t}};let n=null==(I=N.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 C;const e=null==(C=N.filter(e=>{if(j){const t=We(e.placement);return t===v||"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:C[0];e&&(n=e);break}case"initialPlacement":n=l}if(r!==n)return{reset:{placement:n}}}return{}}}},Gt=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:a,placement:r,rects:s,platform:o,elements:l,middlewareData:i}=t,{element:c,padding:d=0}=Oe(e,t)||{};if(null==c)return{};const u=Qe(d),p={x:n,y:a},m=Ye(r),h=Ze(m),f=await o.getDimensions(c),g="y"===m,y=g?"top":"left",v=g?"bottom":"right",b=g?"clientHeight":"clientWidth",w=s.reference[h]+s.reference[m]-p[m]-s.floating[h],_=p[m]-s.reference[m],j=await(null==o.getOffsetParent?void 0:o.getOffsetParent(c));let k=j?j[b]:0;k&&await(null==o.isElement?void 0:o.isElement(j))||(k=l.floating[b]||s.floating[h]);const x=w/2-_/2,M=k/2-f[h]/2-1,N=Ie(u[y],M),E=Ie(u[v],M),I=N,C=k-f[h]-E,L=k/2-f[h]/2+x,S=Ae(I,L,C),D=!i.arrow&&null!=Pe(r)&&L!==S&&s.reference[h]/2-(Ln&&(m=n)}if(c){var y,v;const e="y"===p?"width":"height",t=et.has(ze(r)),n=s.reference[u]-s.floating[e]+(t&&(null==(y=o.offset)?void 0:y[u])||0)+(t?0:g.crossAxis),a=s.reference[u]+s.reference[e]+(t?0:(null==(v=o.offset)?void 0:v[u])||0)-(t?g.crossAxis:0);ha&&(h=a)}return{[p]:m,[u]:h}}}},Vt=(e,t,n)=>{const a=new Map,r={platform:Zt,...n},s={...r.platform,_c:a};return(async(e,t,n)=>{const{placement:a="bottom",strategy:r="absolute",middleware:s=[],platform:o}=n,l=o.detectOverflow?o:{...o,detectOverflow:Je},i=await(null==o.isRTL?void 0:o.isRTL(t));let c=await o.getElementRects({reference:e,floating:t,strategy:r}),{x:d,y:u}=$e(c,a,i),p=a,m=0;const h={};for(let n=0;n{t.current=e}),t}const $t=(e,t)=>{const n=function(e){return void 0===e&&(e=0),{name:"offset",options:e,async fn(t){var n,a;const{x:r,y:s,placement:o,middlewareData:l}=t,i=await async function(e,t){const{placement:n,platform:a,elements:r}=e,s=await(null==a.isRTL?void 0:a.isRTL(r.floating)),o=ze(n),l=Pe(n),i="y"===We(n),c=et.has(o)?-1:1,d=s&&i?-1:1,u=Oe(t,e);let{mainAxis:p,crossAxis:m,alignmentAxis:h}="number"==typeof u?{mainAxis:u,crossAxis:0,alignmentAxis:null}:{mainAxis:u.mainAxis||0,crossAxis:u.crossAxis||0,alignmentAxis:u.alignmentAxis};return l&&"number"==typeof h&&(m="end"===l?-1*h:h),i?{x:m*d,y:p*c}:{x:p*c,y:m*d}}(t,e);return o===(null==(n=l.offset)?void 0:n.placement)&&null!=(a=l.arrow)&&a.alignmentOffset?{}:{x:r+i.x,y:s+i.y,data:{...i,placement:o}}}}}(e);return{name:n.name,fn:n.fn,options:[e,t]}},Jt=(e,t)=>{const n=function(e){return void 0===e&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:a,placement:r,platform:s}=t,{mainAxis:o=!0,crossAxis:l=!1,limiter:i={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...c}=Oe(e,t),d={x:n,y:a},u=await s.detectOverflow(t,c),p=We(ze(r)),m=Re(p);let h=d[m],f=d[p];if(o){const e="y"===m?"bottom":"right";h=Ae(h+u["y"===m?"top":"left"],h,h-u[e])}if(l){const e="y"===p?"bottom":"right";f=Ae(f+u["y"===p?"top":"left"],f,f-u[e])}const g=i.fn({...t,[m]:h,[p]:f});return{...g,data:{x:g.x-n,y:g.y-a,enabled:{[m]:o,[p]:l}}}}}}(e);return{name:n.name,fn:n.fn,options:[e,t]}},Kt=(e,t)=>({fn:Bt(e).fn,options:[e,t]}),qt=(e,t)=>{const n=Yt(e);return{name:n.name,fn:n.fn,options:[e,t]}},en=(e,t)=>{const n=function(e){return void 0===e&&(e={}),{name:"size",options:e,async fn(t){var n,a;const{placement:r,rects:s,platform:o,elements:l}=t,{apply:i=()=>{},...c}=Oe(e,t),d=await o.detectOverflow(t,c),u=ze(r),p=Pe(r),m="y"===We(r),{width:h,height:f}=s.floating;let g,y;"top"===u||"bottom"===u?(g=u,y=p===(await(null==o.isRTL?void 0:o.isRTL(l.floating))?"start":"end")?"left":"right"):(y=u,g="end"===p?"top":"bottom");const v=f-d.top-d.bottom,b=h-d.left-d.right,w=Ie(f-d[g],v),_=Ie(h-d[y],b),j=!t.middlewareData.shift;let k=w,x=_;if(null!=(n=t.middlewareData.shift)&&n.enabled.x&&(x=b),null!=(a=t.middlewareData.shift)&&a.enabled.y&&(k=v),j&&!p){const e=Ce(d.left,0),t=Ce(d.right,0),n=Ce(d.top,0),a=Ce(d.bottom,0);m?x=h-2*(0!==e||0!==t?e+t:Ce(d.left,d.right)):k=f-2*(0!==n||0!==a?n+a:Ce(d.top,d.bottom))}await i({...t,availableWidth:x,availableHeight:k});const M=await o.getDimensions(l.floating);return h!==M.width||f!==M.height?{reset:{rects:!0}}:{}}}}(e);return{name:n.name,fn:n.fn,options:[e,t]}},tn=(e,t)=>{const n=function(e){return void 0===e&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:a}=t,{strategy:r="referenceHidden",...s}=Oe(e,t);switch(r){case"referenceHidden":{const e=Ke(await a.detectOverflow(t,{...s,elementContext:"reference"}),n.reference);return{data:{referenceHiddenOffsets:e,referenceHidden:qe(e)}}}case"escaped":{const e=Ke(await a.detectOverflow(t,{...s,altBoundary:!0}),n.floating);return{data:{escapedOffsets:e,escaped:qe(e)}}}default:return{}}}}}(e);return{name:n.name,fn:n.fn,options:[e,t]}},nn=(e,t)=>{const n=(e=>({name:"arrow",options:e,fn(t){const{element:n,padding:a}="function"==typeof e?e(t):e;return n&&(r=n,{}.hasOwnProperty.call(r,"current"))?null!=n.current?Gt({element:n.current,padding:a}).fn(t):{}:n?Gt({element:n,padding:a}).fn(t):{};var r}}))(e);return{name:n.name,fn:n.fn,options:[e,t]}};var an=a.forwardRef((e,t)=>{const{children:n,width:a=10,height:r=5,...s}=e;return(0,I.jsx)(q.svg,{...s,ref:t,width:a,height:r,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:(0,I.jsx)("polygon",{points:"0,0 30,0 15,10"})})});an.displayName="Arrow";var rn=an,sn="Popper",[on,ln]=R(sn),[cn,dn]=on(sn),un=e=>{const{__scopePopper:t,children:n}=e,[r,s]=a.useState(null),[o,l]=a.useState(void 0);return(0,I.jsx)(cn,{scope:t,anchor:r,onAnchorChange:s,placementState:o,setPlacementState:l,children:n})};un.displayName=sn;var pn="PopperAnchor",mn=a.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...s}=e,o=dn(pn,n),l=a.useRef(null),i=o.onAnchorChange,c=Y(t,a.useCallback(e=>{l.current=e,e&&i(e)},[i])),d=a.useRef(null);a.useEffect(()=>{if(!r)return;const e=d.current;d.current=r.current,e!==d.current&&i(d.current)});const u=o.placementState&&xn(o.placementState),p=u?.[0],m=u?.[1];return r?null:(0,I.jsx)(q.div,{"data-radix-popper-side":p,"data-radix-popper-align":m,...s,ref:c})});mn.displayName=pn;var hn="PopperContent",[fn,gn]=on(hn),yn=a.forwardRef((e,t)=>{const{__scopePopper:n,side:r="bottom",sideOffset:s=0,align:o="center",alignOffset:l=0,arrowPadding:c=0,avoidCollisions:d=!0,collisionBoundary:u=[],collisionPadding:p=0,sticky:m="partial",hideWhenDetached:h=!1,updatePositionStrategy:f="optimized",onPlaced:g,...y}=e,v=dn(hn,n),[b,w]=a.useState(null),_=Y(t,w),[j,k]=a.useState(null),x=function(e){const[t,n]=a.useState(void 0);return ke(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const t=new ResizeObserver(t=>{if(!Array.isArray(t))return;if(!t.length)return;const a=t[0];let r,s;if("borderBoxSize"in a){const e=a.borderBoxSize,t=Array.isArray(e)?e[0]:e;r=t.inlineSize,s=t.blockSize}else r=e.offsetWidth,s=e.offsetHeight;n({width:r,height:s})});return t.observe(e,{box:"border-box"}),()=>t.unobserve(e)}n(void 0)},[e]),t}(j),M=x?.width??0,N=x?.height??0,E=r+("center"!==o?"-"+o:""),C="number"==typeof p?p:{top:0,right:0,bottom:0,left:0,...p},L=Array.isArray(u)?u:[u],S=L.length>0,D={padding:C,boundary:L.filter(jn),altBoundary:S},{refs:T,floatingStyles:A,placement:O,isPositioned:z,middlewareData:P}=function(e){void 0===e&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:s,elements:{reference:o,floating:l}={},transform:c=!0,whileElementsMounted:d,open:u}=e,[p,m]=a.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[h,f]=a.useState(r);Ft(h,r)||f(r);const[g,y]=a.useState(null),[v,b]=a.useState(null),w=a.useCallback(e=>{e!==x.current&&(x.current=e,y(e))},[]),_=a.useCallback(e=>{e!==M.current&&(M.current=e,b(e))},[]),j=o||g,k=l||v,x=a.useRef(null),M=a.useRef(null),N=a.useRef(p),E=null!=d,I=Xt(d),C=Xt(s),L=Xt(u),S=a.useCallback(()=>{if(!x.current||!M.current)return;const e={placement:t,strategy:n,middleware:h};C.current&&(e.platform=C.current),Vt(x.current,M.current,e).then(e=>{const t={...e,isPositioned:!1!==L.current};D.current&&!Ft(N.current,t)&&(N.current=t,i.flushSync(()=>{m(t)}))})},[h,t,n,C,L]);Ut(()=>{!1===u&&N.current.isPositioned&&(N.current.isPositioned=!1,m(e=>({...e,isPositioned:!1})))},[u]);const D=a.useRef(!1);Ut(()=>(D.current=!0,()=>{D.current=!1}),[]),Ut(()=>{if(j&&(x.current=j),k&&(M.current=k),j&&k){if(I.current)return I.current(j,k,S);S()}},[j,k,S,I,E]);const T=a.useMemo(()=>({reference:x,floating:M,setReference:w,setFloating:_}),[w,_]),A=a.useMemo(()=>({reference:j,floating:k}),[j,k]),O=a.useMemo(()=>{const e={position:n,left:0,top:0};if(!A.floating)return e;const t=Qt(A.floating,p.x),a=Qt(A.floating,p.y);return c?{...e,transform:"translate("+t+"px, "+a+"px)",...Ht(A.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:t,top:a}},[n,c,A.floating,p.x,p.y]);return a.useMemo(()=>({...p,update:S,refs:T,elements:A,floatingStyles:O}),[p,S,T,A,O])}({strategy:"fixed",placement:E,whileElementsMounted:(...e)=>function(e,t,n,a){void 0===a&&(a={});const{ancestorScroll:r=!0,ancestorResize:s=!0,elementResize:o="function"==typeof ResizeObserver,layoutShift:l="function"==typeof IntersectionObserver,animationFrame:i=!1}=a,c=Nt(e),d=r||s?[...c?kt(c):[],...t?kt(t):[]]:[];d.forEach(e=>{r&&e.addEventListener("scroll",n,{passive:!0}),s&&e.addEventListener("resize",n)});const u=c&&l?function(e,t){let n,a=null;const r=rt(e);function s(){var e;clearTimeout(n),null==(e=a)||e.disconnect(),a=null}return function o(l,i){void 0===l&&(l=!1),void 0===i&&(i=1),s();const c=e.getBoundingClientRect(),{left:d,top:u,width:p,height:m}=c;if(l||t(),!p||!m)return;const h={rootMargin:-Se(u)+"px "+-Se(r.clientWidth-(d+p))+"px "+-Se(r.clientHeight-(u+m))+"px "+-Se(d)+"px",threshold:Ce(0,Ie(1,i))||1};let f=!0;function g(t){const a=t[0].intersectionRatio;if(a!==i){if(!f)return o();a?o(!1,a):n=setTimeout(()=>{o(!1,1e-7)},1e3)}1!==a||Wt(c,e.getBoundingClientRect())||o(),f=!1}try{a=new IntersectionObserver(g,{...h,root:r.ownerDocument})}catch(e){a=new IntersectionObserver(g,h)}a.observe(e)}(!0),s}(c,n):null;let p,m=-1,h=null;o&&(h=new ResizeObserver(e=>{let[a]=e;a&&a.target===c&&h&&t&&(h.unobserve(t),cancelAnimationFrame(m),m=requestAnimationFrame(()=>{var e;null==(e=h)||e.observe(t)})),n()}),c&&!i&&h.observe(c),t&&h.observe(t));let f=i?Lt(e):null;return i&&function t(){const a=Lt(e);f&&!Wt(f,a)&&n(),f=a,p=requestAnimationFrame(t)}(),n(),()=>{var e;d.forEach(e=>{r&&e.removeEventListener("scroll",n),s&&e.removeEventListener("resize",n)}),null==u||u(),null==(e=h)||e.disconnect(),h=null,i&&cancelAnimationFrame(p)}}(...e,{animationFrame:"always"===f}),elements:{reference:v.anchor},middleware:[$t({mainAxis:s+N,alignmentAxis:l}),d&&Jt({mainAxis:!0,crossAxis:!1,limiter:"partial"===m?Kt():void 0,...D}),d&&qt({...D}),en({...D,apply:({elements:e,rects:t,availableWidth:n,availableHeight:a})=>{const{width:r,height:s}=t.reference,o=e.floating.style;o.setProperty("--radix-popper-available-width",`${n}px`),o.setProperty("--radix-popper-available-height",`${a}px`),o.setProperty("--radix-popper-anchor-width",`${r}px`),o.setProperty("--radix-popper-anchor-height",`${s}px`)}}),j&&nn({element:j,padding:c}),kn({arrowWidth:M,arrowHeight:N}),h&&tn({strategy:"referenceHidden",...D,boundary:S?D.boundary:void 0})]}),R=v.setPlacementState;ke(()=>(R(O),()=>{R(void 0)}),[O,R]);const[Z,W]=xn(O),G=te(g);ke(()=>{z&&G?.()},[z,G]);const B=P.arrow?.x,V=P.arrow?.y,U=0!==P.arrow?.centerOffset,[F,H]=a.useState();return ke(()=>{b&&H(window.getComputedStyle(b).zIndex)},[b]),(0,I.jsx)("div",{ref:T.setFloating,"data-radix-popper-content-wrapper":"",style:{...A,transform:z?A.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:F,"--radix-popper-transform-origin":[P.transformOrigin?.x,P.transformOrigin?.y].join(" "),...P.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:(0,I.jsx)(fn,{scope:n,placedSide:Z,placedAlign:W,onArrowChange:k,arrowX:B,arrowY:V,shouldHideArrow:U,children:(0,I.jsx)(q.div,{"data-side":Z,"data-align":W,...y,ref:_,style:{...y.style,animation:z?void 0:"none"}})})})});yn.displayName=hn;var vn="PopperArrow",bn={top:"bottom",right:"left",bottom:"top",left:"right"},wn=a.forwardRef(function(e,t){const{__scopePopper:n,...a}=e,r=gn(vn,n),s=bn[r.placedSide];return(0,I.jsx)("span",{ref:r.onArrowChange,style:{position:"absolute",left:r.arrowX,top:r.arrowY,[s]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[r.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[r.placedSide],visibility:r.shouldHideArrow?"hidden":void 0},children:(0,I.jsx)(rn,{...a,ref:t,style:{...a.style,display:"block"}})})});function jn(e){return null!==e}wn.displayName=vn;var kn=e=>({name:"transformOrigin",options:e,fn(t){const{placement:n,rects:a,middlewareData:r}=t,s=0!==r.arrow?.centerOffset,o=s?0:e.arrowWidth,l=s?0:e.arrowHeight,[i,c]=xn(n),d={start:"0%",center:"50%",end:"100%"}[c],u=(r.arrow?.x??0)+o/2,p=(r.arrow?.y??0)+l/2;let m="",h="";return"bottom"===i?(m=s?d:`${u}px`,h=-l+"px"):"top"===i?(m=s?d:`${u}px`,h=`${a.floating.height+l}px`):"right"===i?(m=-l+"px",h=s?d:`${p}px`):"left"===i&&(m=`${a.floating.width+l}px`,h=s?d:`${p}px`),{data:{x:m,y:h}}}});function xn(e){const[t,n="center"]=e.split("-");return[t,n]}var Mn=un,Nn=mn,En=yn,In=wn,Cn=a.forwardRef((e,t)=>{const{container:n,...r}=e,[s,o]=a.useState(!1);ke(()=>o(!0),[]);const l=n||s&&globalThis?.document?.body;return l?i.createPortal((0,I.jsx)(q.div,{...r,ref:t}),l):null});Cn.displayName="Portal";var Ln=e=>{const{present:t,children:n}=e,r=function(e){const[t,n]=a.useState(),r=a.useRef(null),s=a.useRef(e),o=a.useRef("none"),l=a.useRef(void 0),i=e?"mounted":"unmounted",[c,d]=function(e,t){return a.useReducer((e,n)=>t[e][n]??e,e)}(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return a.useEffect(()=>{"mounted"===c?(o.current=l.current??Dn(r.current),l.current=void 0):o.current="none"},[c]),ke(()=>{const t=r.current,n=s.current;if(n!==e){const a=o.current,r=Dn(t);e?(l.current=r,d("MOUNT")):d("none"===r||"none"===t?.display?"UNMOUNT":n&&a!==r?"ANIMATION_OUT":"UNMOUNT"),s.current=e}},[e,d]),ke(()=>{if(t){let e;const n=t.ownerDocument.defaultView??window,a=a=>{const o=Dn(r.current).includes(CSS.escape(a.animationName));if(a.target===t&&o&&(d("ANIMATION_END"),!s.current)){const a=t.style.animationFillMode;t.style.animationFillMode="forwards",e=n.setTimeout(()=>{"forwards"===t.style.animationFillMode&&(t.style.animationFillMode=a)})}},l=e=>{e.target===t&&(o.current=Dn(r.current))};return t.addEventListener("animationstart",l),t.addEventListener("animationcancel",a),t.addEventListener("animationend",a),()=>{n.clearTimeout(e),t.removeEventListener("animationstart",l),t.removeEventListener("animationcancel",a),t.removeEventListener("animationend",a)}}d("ANIMATION_END")},[t,d]),{isPresent:["mounted","unmountSuspended"].includes(c),ref:a.useCallback(e=>{if(e){const t=getComputedStyle(e);r.current=t,l.current=Dn(t)}else r.current=null;n(e)},[])}}(t),s="function"==typeof n?n({present:r.isPresent}):a.Children.only(n),o=function(...e){const t=a.useRef(e);return t.current=e,a.useCallback(e=>{const n=t.current;let a=!1;const r=n.map(t=>{const n=Sn(t,e);return a||"function"!=typeof n||(a=!0),n});if(a)return()=>{for(let e=0;e{},caller:r}){const[s,o,l]=function({defaultProp:e,onChange:t}){const[n,r]=a.useState(e),s=a.useRef(n),o=a.useRef(t);return Tn(()=>{o.current=t},[t]),a.useEffect(()=>{s.current!==n&&(o.current?.(n),s.current=n)},[n,s]),[n,r,o]}({defaultProp:t,onChange:n}),i=void 0!==e,c=i?e:s;{const t=a.useRef(void 0!==e);a.useEffect(()=>{const e=t.current;if(e!==i){const t=e?"controlled":"uncontrolled",n=i?"controlled":"uncontrolled";console.warn(`${r} is changing from ${t} to ${n}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`)}t.current=i},[i,r])}const d=a.useCallback(t=>{if(i){const n=function(e){return"function"==typeof e}(t)?t(e):t;n!==e&&l.current?.(n)}else o(t)},[i,e,o,l]);return[c,d]}Symbol("RADIX:SYNC_STATE");var On=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),zn=a.forwardRef((e,t)=>(0,I.jsx)(q.span,{...e,ref:t,style:{...On,...e.style}}));zn.displayName="VisuallyHidden";var Pn=zn,Rn=new WeakMap,Zn=new WeakMap,Wn={},Yn=0,Gn=function(e){return e&&(e.host||Gn(e.parentNode))},Bn=function(e,t,n){void 0===n&&(n="data-aria-hidden");var a=Array.from(Array.isArray(e)?e:[e]),r=t||function(e){return"undefined"==typeof document?null:(Array.isArray(e)?e[0]:e).ownerDocument.body}(e);return r?(a.push.apply(a,Array.from(r.querySelectorAll("[aria-live], script"))),function(e,t,n,a){var r=function(e,t){return t.map(function(t){if(e.contains(t))return t;var n=Gn(t);return n&&e.contains(n)?n:(console.error("aria-hidden",t,"in not contained inside",e,". Doing nothing"),null)}).filter(function(e){return Boolean(e)})}(t,Array.isArray(e)?e:[e]);Wn[n]||(Wn[n]=new WeakMap);var s=Wn[n],o=[],l=new Set,i=new Set(r),c=function(e){e&&!l.has(e)&&(l.add(e),c(e.parentNode))};r.forEach(c);var d=function(e){e&&!i.has(e)&&Array.prototype.forEach.call(e.children,function(e){if(l.has(e))d(e);else try{var t=e.getAttribute(a),r=null!==t&&"false"!==t,i=(Rn.get(e)||0)+1,c=(s.get(e)||0)+1;Rn.set(e,i),s.set(e,c),o.push(e),1===i&&r&&Zn.set(e,!0),1===c&&e.setAttribute(n,"true"),r||e.setAttribute(a,"true")}catch(t){console.error("aria-hidden: cannot operate on ",e,t)}})};return d(t),l.clear(),Yn++,function(){o.forEach(function(e){var t=Rn.get(e)-1,r=s.get(e)-1;Rn.set(e,t),s.set(e,r),t||(Zn.has(e)||e.removeAttribute(a),Zn.delete(e)),r||e.removeAttribute(n)}),--Yn||(Rn=new WeakMap,Rn=new WeakMap,Zn=new WeakMap,Wn={})}}(a,r,n,"aria-hidden")):function(){return null}},Vn=function(){return Vn=Object.assign||function(e){for(var t,n=1,a=arguments.length;n