From fee284618cc8397b70196a4821ab3a729675e6c8 Mon Sep 17 00:00:00 2001 From: Pisarev Alexei <6171687+xiregroup@users.noreply.github.com> Date: Wed, 18 Nov 2026 00:55:26 +0300 Subject: [PATCH 1/2] feat(errors): error tracking in the site's own database A new module, alveby/atrium-errors: a small Sentry inside the site. - Captures PHP exceptions, failed queue jobs, failed scheduled tasks and JavaScript errors of visitors' browsers (a rate-limited endpoint and a small script added to public pages). - Groups events by class and the in-app frames, so one bug is one issue; statuses new, resolved, ignored, with regression when a resolved bug happens again and "resolve in next release". - Site health > Errors: the list with search, status, site, release and path filters; the issue page with the trace and code around each frame, the request, tops, a chart and every occurrence; a dashboard tile. - Mail and Telegram alerts for new issues, regressions and spikes, throttled. - Secrets and personal data are scrubbed before anything is stored; sampling, a per-minute cap, writing after the response or on a queue, a fallback log, 90 days kept by a pruning command. - Drivers: database, sentry (Sentry or GlitchTip by DSN, no SDK) and log, behind a documented ErrorReporter contract for Bugsnag, Rollbar or a webhook. - Rights errors.view and errors.settings; administrators of some sites see only their sites' errors. - Docs in English and Russian, the package in every README. --- .ci/coverage/errors | 1 + CHANGELOG.md | 1 + README.md | 2 + composer.json | 3 + composer.lock | 122 ++++- config/atrium.php | 1 + docs/errors.md | 244 +++++++++ docs/errors.ru.md | 244 +++++++++ docs/readme/README.be.md | 2 + docs/readme/README.de.md | 2 + docs/readme/README.es.md | 2 + docs/readme/README.fr.md | 2 + docs/readme/README.it.md | 2 + docs/readme/README.ja.md | 2 + docs/readme/README.kk.md | 2 + docs/readme/README.pl.md | 2 + docs/readme/README.pt-BR.md | 2 + docs/readme/README.ru.md | 2 + docs/readme/README.tr.md | 2 + docs/readme/README.uk.md | 2 + docs/readme/README.uz.md | 2 + docs/readme/README.zh-CN.md | 2 + .../Admin/Dashboard/ErrorsGadget.vue | 53 ++ .../js/Components/Admin/UI/BarChart.vue | 70 +++ .../resources/js/Pages/Admin/Dashboard.vue | 2 + .../resources/js/Pages/Admin/Errors/Index.vue | 160 ++++++ .../resources/js/Pages/Admin/Errors/Show.vue | 277 ++++++++++ packages/errors/LICENSE | 21 + packages/errors/README.md | 33 ++ packages/errors/composer.json | 64 +++ packages/errors/config/atrium-errors.php | 105 ++++ .../2026_11_20_100001_create_error_tables.php | 72 +++ packages/errors/lang/be/errors.php | 183 +++++++ packages/errors/lang/de/errors.php | 183 +++++++ packages/errors/lang/en/errors.php | 183 +++++++ packages/errors/lang/es/errors.php | 183 +++++++ packages/errors/lang/fr/errors.php | 183 +++++++ packages/errors/lang/it/errors.php | 183 +++++++ packages/errors/lang/ja/errors.php | 183 +++++++ packages/errors/lang/kk/errors.php | 183 +++++++ packages/errors/lang/pl/errors.php | 183 +++++++ packages/errors/lang/pt_BR/errors.php | 183 +++++++ packages/errors/lang/ru/errors.php | 183 +++++++ packages/errors/lang/tr/errors.php | 183 +++++++ packages/errors/lang/uk/errors.php | 183 +++++++ packages/errors/lang/uz/errors.php | 183 +++++++ packages/errors/lang/zh_CN/errors.php | 183 +++++++ packages/errors/phpunit.xml.dist | 16 + packages/errors/resources/js/atrium-errors.js | 66 +++ .../resources/views/mail/alert.blade.php | 5 + packages/errors/src/Alerts/Alert.php | 58 +++ packages/errors/src/Alerts/AlertMail.php | 37 ++ packages/errors/src/Alerts/Alerter.php | 97 ++++ packages/errors/src/Alerts/Channels.php | 82 +++ packages/errors/src/Capture/Breadcrumbs.php | 67 +++ packages/errors/src/Capture/EventFactory.php | 265 ++++++++++ packages/errors/src/Capture/Fingerprint.php | 74 +++ packages/errors/src/Capture/Frames.php | 197 +++++++ packages/errors/src/Capture/Release.php | 85 +++ packages/errors/src/Capture/Scrubber.php | 178 +++++++ packages/errors/src/Console/PruneCommand.php | 57 +++ packages/errors/src/Console/TestCommand.php | 49 ++ .../errors/src/Contracts/ErrorReporter.php | 32 ++ .../errors/src/Dashboard/ErrorsGadget.php | 82 +++ packages/errors/src/Errors.php | 126 +++++ packages/errors/src/ErrorsServiceProvider.php | 197 +++++++ packages/errors/src/ErrorsSettings.php | 91 ++++ packages/errors/src/Event.php | 147 ++++++ .../Http/Controllers/BrowserController.php | 72 +++ .../src/Http/Controllers/IssueController.php | 231 +++++++++ .../src/Http/Middleware/AuthorizeErrors.php | 42 ++ .../Http/Middleware/InjectBrowserScript.php | 73 +++ packages/errors/src/Menu.php | 61 +++ packages/errors/src/Models/Issue.php | 103 ++++ packages/errors/src/Models/Occurrence.php | 64 +++ packages/errors/src/Pipeline/DeliverEvent.php | 35 ++ packages/errors/src/Pipeline/Drivers.php | 66 +++ packages/errors/src/Pipeline/Sender.php | 119 +++++ .../errors/src/Reporters/DatabaseReporter.php | 124 +++++ packages/errors/src/Reporters/LogReporter.php | 42 ++ packages/errors/src/Reporters/Sentry/Dsn.php | 75 +++ .../src/Reporters/Sentry/HttpTransport.php | 60 +++ .../errors/src/Reporters/Sentry/Transport.php | 22 + .../errors/src/Reporters/SentryReporter.php | 117 +++++ packages/errors/src/Support/FallbackLog.php | 58 +++ packages/errors/src/Support/Frequency.php | 84 +++ packages/errors/src/Support/Limiter.php | 93 ++++ packages/errors/src/Support/Options.php | 102 ++++ packages/errors/src/Support/SiteAccess.php | 37 ++ packages/errors/tests/Feature/AdminTest.php | 367 +++++++++++++ .../errors/tests/Feature/AlertDetailsTest.php | 267 ++++++++++ packages/errors/tests/Feature/AlertsTest.php | 208 ++++++++ .../tests/Feature/BrowserDetailsTest.php | 303 +++++++++++ packages/errors/tests/Feature/BrowserTest.php | 187 +++++++ .../tests/Feature/CaptureDetailsTest.php | 397 +++++++++++++++ packages/errors/tests/Feature/CaptureTest.php | 286 +++++++++++ .../tests/Feature/DatabaseReporterTest.php | 160 ++++++ .../errors/tests/Feature/GroupingTest.php | 175 +++++++ .../errors/tests/Feature/IssueScreensTest.php | 464 +++++++++++++++++ packages/errors/tests/Feature/LimiterTest.php | 211 ++++++++ .../tests/Feature/ModuleDetailsTest.php | 482 ++++++++++++++++++ .../errors/tests/Feature/NotInstalledTest.php | 42 ++ packages/errors/tests/Feature/OptionsTest.php | 205 ++++++++ .../errors/tests/Feature/PipelineTest.php | 330 ++++++++++++ packages/errors/tests/Feature/ScrubTest.php | 220 ++++++++ .../tests/Feature/SentryDetailsTest.php | 167 ++++++ packages/errors/tests/Feature/SentryTest.php | 215 ++++++++ packages/errors/tests/Feature/SupportTest.php | 289 +++++++++++ packages/errors/tests/Feature/WiringTest.php | 63 +++ packages/errors/tests/Fixtures/FailingJob.php | 26 + .../errors/tests/Fixtures/LeakyCheckout.php | 27 + packages/errors/tests/TestCase.php | 218 ++++++++ packages/errors/tests/Unit/EventTest.php | 71 +++ .../errors/tests/Unit/FallbackLogTest.php | 200 ++++++++ .../errors/tests/Unit/FingerprintTest.php | 149 ++++++ packages/errors/tests/Unit/FramesTest.php | 332 ++++++++++++ packages/errors/tests/Unit/ReleaseTest.php | 176 +++++++ .../errors/tests/Unit/ScrubberTextTest.php | 131 +++++ .../errors/tests/Unit/SentryPayloadTest.php | 216 ++++++++ phpstan.neon | 3 + phpunit.xml | 2 + tests/Browser/Admin/ErrorsTest.php | 160 ++++++ tests/Browser/Admin/HeaderTest.php | 21 +- 123 files changed, 14680 insertions(+), 26 deletions(-) create mode 100644 .ci/coverage/errors create mode 100644 docs/errors.md create mode 100644 docs/errors.ru.md create mode 100644 packages/admin/resources/js/Components/Admin/Dashboard/ErrorsGadget.vue create mode 100644 packages/admin/resources/js/Components/Admin/UI/BarChart.vue create mode 100644 packages/admin/resources/js/Pages/Admin/Errors/Index.vue create mode 100644 packages/admin/resources/js/Pages/Admin/Errors/Show.vue create mode 100644 packages/errors/LICENSE create mode 100644 packages/errors/README.md create mode 100644 packages/errors/composer.json create mode 100644 packages/errors/config/atrium-errors.php create mode 100644 packages/errors/database/migrations/2026_11_20_100001_create_error_tables.php create mode 100644 packages/errors/lang/be/errors.php create mode 100644 packages/errors/lang/de/errors.php create mode 100644 packages/errors/lang/en/errors.php create mode 100644 packages/errors/lang/es/errors.php create mode 100644 packages/errors/lang/fr/errors.php create mode 100644 packages/errors/lang/it/errors.php create mode 100644 packages/errors/lang/ja/errors.php create mode 100644 packages/errors/lang/kk/errors.php create mode 100644 packages/errors/lang/pl/errors.php create mode 100644 packages/errors/lang/pt_BR/errors.php create mode 100644 packages/errors/lang/ru/errors.php create mode 100644 packages/errors/lang/tr/errors.php create mode 100644 packages/errors/lang/uk/errors.php create mode 100644 packages/errors/lang/uz/errors.php create mode 100644 packages/errors/lang/zh_CN/errors.php create mode 100644 packages/errors/phpunit.xml.dist create mode 100644 packages/errors/resources/js/atrium-errors.js create mode 100644 packages/errors/resources/views/mail/alert.blade.php create mode 100644 packages/errors/src/Alerts/Alert.php create mode 100644 packages/errors/src/Alerts/AlertMail.php create mode 100644 packages/errors/src/Alerts/Alerter.php create mode 100644 packages/errors/src/Alerts/Channels.php create mode 100644 packages/errors/src/Capture/Breadcrumbs.php create mode 100644 packages/errors/src/Capture/EventFactory.php create mode 100644 packages/errors/src/Capture/Fingerprint.php create mode 100644 packages/errors/src/Capture/Frames.php create mode 100644 packages/errors/src/Capture/Release.php create mode 100644 packages/errors/src/Capture/Scrubber.php create mode 100644 packages/errors/src/Console/PruneCommand.php create mode 100644 packages/errors/src/Console/TestCommand.php create mode 100644 packages/errors/src/Contracts/ErrorReporter.php create mode 100644 packages/errors/src/Dashboard/ErrorsGadget.php create mode 100644 packages/errors/src/Errors.php create mode 100644 packages/errors/src/ErrorsServiceProvider.php create mode 100644 packages/errors/src/ErrorsSettings.php create mode 100644 packages/errors/src/Event.php create mode 100644 packages/errors/src/Http/Controllers/BrowserController.php create mode 100644 packages/errors/src/Http/Controllers/IssueController.php create mode 100644 packages/errors/src/Http/Middleware/AuthorizeErrors.php create mode 100644 packages/errors/src/Http/Middleware/InjectBrowserScript.php create mode 100644 packages/errors/src/Menu.php create mode 100644 packages/errors/src/Models/Issue.php create mode 100644 packages/errors/src/Models/Occurrence.php create mode 100644 packages/errors/src/Pipeline/DeliverEvent.php create mode 100644 packages/errors/src/Pipeline/Drivers.php create mode 100644 packages/errors/src/Pipeline/Sender.php create mode 100644 packages/errors/src/Reporters/DatabaseReporter.php create mode 100644 packages/errors/src/Reporters/LogReporter.php create mode 100644 packages/errors/src/Reporters/Sentry/Dsn.php create mode 100644 packages/errors/src/Reporters/Sentry/HttpTransport.php create mode 100644 packages/errors/src/Reporters/Sentry/Transport.php create mode 100644 packages/errors/src/Reporters/SentryReporter.php create mode 100644 packages/errors/src/Support/FallbackLog.php create mode 100644 packages/errors/src/Support/Frequency.php create mode 100644 packages/errors/src/Support/Limiter.php create mode 100644 packages/errors/src/Support/Options.php create mode 100644 packages/errors/src/Support/SiteAccess.php create mode 100644 packages/errors/tests/Feature/AdminTest.php create mode 100644 packages/errors/tests/Feature/AlertDetailsTest.php create mode 100644 packages/errors/tests/Feature/AlertsTest.php create mode 100644 packages/errors/tests/Feature/BrowserDetailsTest.php create mode 100644 packages/errors/tests/Feature/BrowserTest.php create mode 100644 packages/errors/tests/Feature/CaptureDetailsTest.php create mode 100644 packages/errors/tests/Feature/CaptureTest.php create mode 100644 packages/errors/tests/Feature/DatabaseReporterTest.php create mode 100644 packages/errors/tests/Feature/GroupingTest.php create mode 100644 packages/errors/tests/Feature/IssueScreensTest.php create mode 100644 packages/errors/tests/Feature/LimiterTest.php create mode 100644 packages/errors/tests/Feature/ModuleDetailsTest.php create mode 100644 packages/errors/tests/Feature/NotInstalledTest.php create mode 100644 packages/errors/tests/Feature/OptionsTest.php create mode 100644 packages/errors/tests/Feature/PipelineTest.php create mode 100644 packages/errors/tests/Feature/ScrubTest.php create mode 100644 packages/errors/tests/Feature/SentryDetailsTest.php create mode 100644 packages/errors/tests/Feature/SentryTest.php create mode 100644 packages/errors/tests/Feature/SupportTest.php create mode 100644 packages/errors/tests/Feature/WiringTest.php create mode 100644 packages/errors/tests/Fixtures/FailingJob.php create mode 100644 packages/errors/tests/Fixtures/LeakyCheckout.php create mode 100644 packages/errors/tests/TestCase.php create mode 100644 packages/errors/tests/Unit/EventTest.php create mode 100644 packages/errors/tests/Unit/FallbackLogTest.php create mode 100644 packages/errors/tests/Unit/FingerprintTest.php create mode 100644 packages/errors/tests/Unit/FramesTest.php create mode 100644 packages/errors/tests/Unit/ReleaseTest.php create mode 100644 packages/errors/tests/Unit/ScrubberTextTest.php create mode 100644 packages/errors/tests/Unit/SentryPayloadTest.php create mode 100644 tests/Browser/Admin/ErrorsTest.php diff --git a/.ci/coverage/errors b/.ci/coverage/errors new file mode 100644 index 00000000..e46029e7 --- /dev/null +++ b/.ci/coverage/errors @@ -0,0 +1 @@ +100.00% of lines, 0 not covered diff --git a/CHANGELOG.md b/CHANGELOG.md index e35a2296..62ec91ce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ All notable changes are listed here. The format follows [Keep a Changelog](https ## [Unreleased] ### Added +- Error tracking (`alveby/atrium-errors`, `atrium:module:install alveby/atrium-errors`), kept in the site's own database: PHP exceptions, queue jobs that failed for good, failed scheduled tasks and, when switched on, JavaScript errors of the site and the admin (a small script the module adds to the pages itself, reported to a rate-limited endpoint). Grouped by class and the first five frames of the app's own code, line numbers and changing values left out. **Site health → Errors**: the list with status buttons, search and filters by site, release, level, source and address; an error's page with its trace and code, the request, what happened before, a chart by hour or by day with the number on every bar, the addresses and releases it happens in, every event; resolve, **resolve in next release** (comes back only in another release), ignore, reopen. An **Errors in 24 hours** dashboard tile. E-mail and Telegram alerts for new errors, errors that came back and spikes, once per reason and ten in ten minutes at most. Secrets and personal data scrubbed before anything is stored (no headers, cookies, body or IP; filtered keys, e-mails, cards checked with Luhn, phones). Sampling, a per-minute cap, writing after the response or through a queue, a fallback log when the database is down, 90 days kept (`atrium:errors:prune`). Drivers: `database`, `sentry` (Sentry, self-hosted Sentry or GlitchTip with only a DSN, no SDK), `log`, and your own through `Atrium\Errors\Contracts\ErrorReporter` (Bugsnag, Rollbar, a webhook). Rights `errors.view` and `errors.settings`; an administrator of some sites sees only their errors. `atrium:errors:test` sends a test error everywhere. Guide in `docs/errors.md`. Labels in 15 languages; the chart's colours measured in all five themes. - Custom fields (`alveby/atrium-custom-fields`, `atrium:module:install alveby/atrium-custom-fields`): editors add fields to any module from a **Fields** button on its list, with no migration: line, text, integer, decimal, yes/no, date, list, multiple choice, link to a record, file and image, with a name and hint per content language, a tab of the module's form, and the flags required, show in the list, filterable, sortable, searchable, translatable and per site (or shown on one site only). Values live in a JSON column `custom` added with the first field; the filterable and sortable ones are also kept in a typed index table (`custom_field_index`), updated on every save and delete and rebuilt by `atrium:custom-fields:reindex`. `whereCustom()`, `whereCustomBetween()`, `whereCustomFilters()` and `orderByCustom()` on every Eloquent query, and `CustomFacets::for(Product::class, $query)->filters($filters)->counts([...])` / `->ranges([...])` for a filter panel (each field counted with every filter but its own). `atrium:custom-fields:promote` moves a hot field into a real indexed column of the module's table. The fields are in the API (`filter[code]=`, `sort=`, `search=`), its documentation and the MCP tool `describe_module`. On 100 000 records a filtered page of 24 takes 54–185 ms and its three facets 76–374 ms (SQLite, PostgreSQL 17, MySQL 8.4). With `atrium:install --demo` the catalog's products get five filterable fields (weight, battery life, waterproof, connectivity, warranty), named in all 15 languages and weighed in pounds for an English (US) shop, in kilograms elsewhere. Guide in `docs/custom-fields.md`. Admin labels in 15 languages. - Ready-made sites (`alveby/atrium-solutions`): `php artisan atrium:solution:install law` turns a fresh project into a whole site: the modules it needs on and the others off (their data kept), the migrations, its content languages, the brand as the site name, its names for the modules in the admin and on the site, their addresses and the site menu, and its content in English, German and Russian; a second run doubles nothing. `atrium:solution:list` lists the solutions and the modules each still lacks; `--json` is the catalogue (texts in every language, modules, palette, fonts, screenshots, pages, install command). A solution is a folder with a `solution.json` and a seeder extending `SolutionSeeder`; other packages add their folders to `atrium-solutions.paths`. The first one is `law`: Vellmar Oake, a made-up law firm with six practice areas, six lawyers in two departments, insights, two offices, a consultation form, a fees FAQ and client reviews. - Backup module (`alveby/atrium-backup`, on spatie/laravel-backup): the databases (MySQL, MariaDB, PostgreSQL, SQLite) in a consistent dump and the chosen disks and folders in one zip, encrypted with `ATRIUM_BACKUP_PASSWORD`, copied to a local folder, S3 or S3-compatible storage, FTP, SFTP or Google Drive, daily or weekly, with daily/weekly/monthly/yearly retention and a size cap. An e-mail to superadmins when a backup or a destination fails, the newest archive is too old or its size jumps. A **Backups** screen for superadmins only: the archives on every destination, **Back up now**, download, delete, destination health, and a restore that first shows what the archive will change (dumps, target databases, new/changed/extra files, warnings), asks for the archive's name and makes a safety backup; the same from `atrium:backup:restore` with `--dry-run`. Runs after the response or on a queue, one at a time, logged with who did it. See [docs/backup.md](docs/backup.md). diff --git a/README.md b/README.md index 2e7afb52..5e7af0f4 100644 --- a/README.md +++ b/README.md @@ -122,6 +122,7 @@ The Bitrix database is only read. The tabs, field order and list columns come ou - [Cache: fast pages with dozens of properties, Redis, the page cache, CDN headers](docs/cache.md) - [Moving from 1C-Bitrix, step by step](docs/bitrix.md) - [Backups: databases and files to several places, schedules, health checks, restore](docs/backup.md) +- [Errors: PHP, queue and JavaScript errors in the site's database, alerts, Sentry and your own drivers](docs/errors.md) - [CDN: pictures, resized copies and WebP/AVIF, cache purge, uploads to S3](docs/cdn.md) - [Two-factor sign-in: authenticator apps, passkeys, codes, the sign-in log](docs/two-factor.md) - [Social sign-in: providers, app registration, redirect URLs](docs/social-login.md) @@ -138,6 +139,7 @@ The Bitrix database is only read. The tabs, field order and list columns come ou | [`alveby/atrium-seo`](packages/seo/README.md) | Meta templates, hreflang, sitemaps, schema.org, redirects and an SEO check | | [`alveby/atrium-docs`](packages/docs/README.md) | Documentation pages from Markdown, with versions and search | | [`alveby/atrium-backup`](packages/backup/README.md) | Backups of the databases and files, restore from the admin | +| [`alveby/atrium-errors`](packages/errors/README.md) | Error tracking in the site's database, alerts, Sentry | | [`alveby/atrium-news`](packages/news/README.md) | News | | [`alveby/atrium-pages`](packages/pages/README.md) | Static pages, with an import of 1C-Bitrix pages | | [`alveby/atrium-catalog`](packages/catalog/README.md) | Product catalog with nested sections | diff --git a/composer.json b/composer.json index 2f6cf826..9ad7a84f 100644 --- a/composer.json +++ b/composer.json @@ -22,6 +22,7 @@ "alveby/atrium-catalog": "@dev", "alveby/atrium-custom-fields": "@dev", "alveby/atrium-docs": "@dev", + "alveby/atrium-errors": "@dev", "alveby/atrium-faq": "@dev", "alveby/atrium-forms": "@dev", "alveby/atrium-news": "@dev", @@ -73,6 +74,7 @@ "Atrium\\Catalog\\Tests\\": "packages/catalog/tests/", "Atrium\\CustomFields\\Tests\\": "packages/custom-fields/tests/", "Atrium\\Docs\\Tests\\": "packages/docs/tests/", + "Atrium\\Errors\\Tests\\": "packages/errors/tests/", "Atrium\\Faq\\Tests\\": "packages/faq/tests/", "Atrium\\Forms\\Tests\\": "packages/forms/tests/", "Atrium\\News\\Tests\\": "packages/news/tests/", @@ -164,6 +166,7 @@ "alveby/atrium-catalog": "0.1.x-dev", "alveby/atrium-custom-fields": "0.1.x-dev", "alveby/atrium-docs": "0.1.x-dev", + "alveby/atrium-errors": "0.1.x-dev", "alveby/atrium-faq": "0.1.x-dev", "alveby/atrium-forms": "0.1.x-dev", "alveby/atrium-news": "0.1.x-dev", diff --git a/composer.lock b/composer.lock index b9170651..23ef77ff 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "fdf954aed638fe72ac3112f7ef28c221", + "content-hash": "0e6dc885b5d747dac2fe3141fe781260", "packages": [ { "name": "alveby/atrium", @@ -12,7 +12,7 @@ "dist": { "type": "path", "url": "packages/admin", - "reference": "cdaa0b836013cd3908ada0ab730cfc5bc8709a68" + "reference": "4f925755003390f651058c88303838daa3f239a4" }, "require": { "illuminate/database": "^13.0", @@ -79,7 +79,7 @@ "dist": { "type": "path", "url": "packages/two-factor", - "reference": "f20265625e90c0593c2feb1db67a19dbbe1a7b1a" + "reference": "69c1be51c773088af110ad9c2d3b34ba1d1839e9" }, "require": { "alveby/atrium": "^0.1", @@ -152,7 +152,7 @@ "dist": { "type": "path", "url": "packages/ai", - "reference": "2e0813b9c0c452ba8b21bd93ec0f06480921661d" + "reference": "f3fd3c28faeba0a00162138a47c2610dffe51205" }, "require": { "alveby/atrium": "^0.1", @@ -219,7 +219,7 @@ "dist": { "type": "path", "url": "packages/backup", - "reference": "6cd4306c9665e6293081ce166e6ee454d68437d1" + "reference": "66f1dba5a4d7d3f32cb3c3930cfaa0da298cf712" }, "require": { "alveby/atrium": "^0.1", @@ -293,7 +293,7 @@ "dist": { "type": "path", "url": "packages/brands", - "reference": "6b176d381821cdf2ba9b506caa5ad8e138b66082" + "reference": "72791048383e904d3eecb482ca53f9631833c197" }, "require": { "alveby/atrium": "^0.1", @@ -359,7 +359,7 @@ "dist": { "type": "path", "url": "packages/catalog", - "reference": "22791fc20e06571ac7fdaf8814715a7eb719dfbd" + "reference": "e496239e03faad46990cb4e022aa792fcd3cb35e" }, "require": { "alveby/atrium": "^0.1", @@ -448,7 +448,7 @@ "dist": { "type": "path", "url": "packages/custom-fields", - "reference": "784df30eb21b9991700ae9082101ba69648428c0" + "reference": "eb1b79bd24ede1ae7c8acd49a0d454212070d2cf" }, "require": { "alveby/atrium": "^0.1", @@ -521,7 +521,7 @@ "dist": { "type": "path", "url": "packages/docs", - "reference": "0f9b77a42229bceb4ad4e26be20a4144ae997a36" + "reference": "98a06714746d959af086dddfd000d757fcb74a58" }, "require": { "alveby/atrium": "^0.1", @@ -579,13 +579,90 @@ "relative": true } }, + { + "name": "alveby/atrium-errors", + "version": "0.1.x-dev", + "dist": { + "type": "path", + "url": "packages/errors", + "reference": "d29b8df0555b34f989e35601139a93ed79e1452b" + }, + "require": { + "alveby/atrium": "^0.1", + "illuminate/support": "^13.0", + "php": "^8.3" + }, + "require-dev": { + "orchestra/testbench": "^11.0", + "phpunit/phpunit": "^12.5" + }, + "suggest": { + "alveby/atrium-mail": "Sends the alert letters through the account picked for the \"errors\" purpose", + "sentry/sentry-laravel": "The official Sentry SDK, for tracing and profiling on top of what the sentry driver sends" + }, + "type": "atrium-module", + "extra": { + "atrium": { + "migrations": "database/migrations", + "settings": "Atrium\\Errors\\ErrorsSettings", + "permissions": { + "view": { + "label": "atrium-errors::errors.permissions.view", + "with": "errors.settings" + } + }, + "title": "atrium-errors::errors.title" + }, + "laravel": { + "providers": [ + "Atrium\\Errors\\ErrorsServiceProvider" + ] + }, + "branch-alias": { + "dev-main": "0.1.x-dev" + } + }, + "autoload": { + "psr-4": { + "Atrium\\Errors\\": "src/" + } + }, + "autoload-dev": { + "psr-4": { + "Atrium\\Errors\\Tests\\": "tests/" + } + }, + "license": [ + "MIT" + ], + "description": "Error tracking for Atrium: PHP, queue, schedule and browser errors grouped into issues in the site's own database, with Sentry, GlitchTip or any other service as an extra or a replacement", + "homepage": "https://github.com/AlveBy/atrium", + "keywords": [ + "admin", + "error-tracking", + "errors", + "exceptions", + "glitchtip", + "laravel", + "monitoring", + "sentry" + ], + "support": { + "issues": "https://github.com/AlveBy/atrium/issues", + "source": "https://github.com/AlveBy/atrium" + }, + "transport-options": { + "symlink": true, + "relative": true + } + }, { "name": "alveby/atrium-faq", "version": "0.1.x-dev", "dist": { "type": "path", "url": "packages/faq", - "reference": "a645787060d1bd09423c2763b7b92181bd3b3adc" + "reference": "d1565935218104d15eb3a5d221d8d04c2b0ef886" }, "require": { "alveby/atrium": "^0.1", @@ -663,7 +740,7 @@ "dist": { "type": "path", "url": "packages/forms", - "reference": "4a1bfb284ac1d9a22ddbf46c39fc88874474cf2a" + "reference": "699975b6ac11473e7539de3aa9499e9a80706640" }, "require": { "alveby/atrium": "^0.1", @@ -731,7 +808,7 @@ "dist": { "type": "path", "url": "packages/news", - "reference": "573e8f15a3ff69d31802c0620ede7c5735d68d3f" + "reference": "5066371aff93dc118eee5875c6d8f78c77b304b6" }, "require": { "alveby/atrium": "^0.1", @@ -804,7 +881,7 @@ "dist": { "type": "path", "url": "packages/pages", - "reference": "b254787a41b93719022081c7f5f9c6a79e63c5d9" + "reference": "a6965ef11be2495d5a834c53042aa6742a7b1edb" }, "require": { "alveby/atrium": "^0.1", @@ -880,7 +957,7 @@ "dist": { "type": "path", "url": "packages/reviews", - "reference": "e7e6d6dec15af01672d00266d8ed3b7f58917a62" + "reference": "32803cbcbe5a56f35594f13e65b9cc9622a89015" }, "require": { "alveby/atrium": "^0.1", @@ -950,7 +1027,7 @@ "dist": { "type": "path", "url": "packages/seo", - "reference": "5d7b2e2195d35c8893fd84b8d0da5f43ceabe49b" + "reference": "9b03717a22cd8a886cf2a9c5b222fb074c9bbba5" }, "require": { "alveby/atrium": "^0.1", @@ -1043,7 +1120,7 @@ "dist": { "type": "path", "url": "packages/social-login", - "reference": "8006eb568380b3fabd049ac4907f0058357dc995" + "reference": "af5b0489019d706516fe43da8d9414f9ab10691f" }, "require": { "alveby/atrium": "^0.1", @@ -1121,7 +1198,7 @@ "dist": { "type": "path", "url": "packages/solutions", - "reference": "9b3927801278789e3fe6148200000de32d2db5b4" + "reference": "e87c079d6ef7ae818e246929ed4f598ce715cf22" }, "require": { "alveby/atrium": "^0.1", @@ -1196,7 +1273,7 @@ "dist": { "type": "path", "url": "packages/stores", - "reference": "b580a595228cb8d6a65245d6c707c6fb28b3181a" + "reference": "208bef5ab7a53b7f30028de14fba4da01318f2f0" }, "require": { "alveby/atrium": "^0.1", @@ -1268,7 +1345,7 @@ "dist": { "type": "path", "url": "packages/team", - "reference": "bfcdacf4ea838f140dd33ff12cad6d92a3bc64dd" + "reference": "cdaadf5f35685d722eac18ea61c1449294d24105" }, "require": { "alveby/atrium": "^0.1", @@ -1346,7 +1423,7 @@ "dist": { "type": "path", "url": "packages/theme", - "reference": "a26995ec0bdb8cc6c5474e77625b39806d8df880" + "reference": "b04ef49e254ae590df471bc038aa6db8e2e9e72c" }, "require": { "alveby/atrium": "^0.1", @@ -9602,7 +9679,7 @@ "dist": { "type": "path", "url": "packages/bitrix", - "reference": "a0d14867aa5127d3c26ef546165607dcb83f867d" + "reference": "16c2ad4cf3372b0b013bc0a449a6fe8ab843cab2" }, "require": { "alveby/atrium": "^0.1", @@ -9666,7 +9743,7 @@ "dist": { "type": "path", "url": "packages/wordpress", - "reference": "6f6f30e14b1a2a3cd9346fa2c87d79db2574c514" + "reference": "bd8bbf61c8d395b8f84c405e26a36b8f0bb940b5" }, "require": { "alveby/atrium": "^0.1", @@ -14758,6 +14835,7 @@ "alveby/atrium-catalog": 20, "alveby/atrium-custom-fields": 20, "alveby/atrium-docs": 20, + "alveby/atrium-errors": 20, "alveby/atrium-faq": 20, "alveby/atrium-forms": 20, "alveby/atrium-news": 20, diff --git a/config/atrium.php b/config/atrium.php index 17292057..f6bb77a9 100644 --- a/config/atrium.php +++ b/config/atrium.php @@ -66,6 +66,7 @@ 'alveby/atrium-2fa', 'alveby/atrium-social-login', 'alveby/atrium-seo', + 'alveby/atrium-errors', ], /* diff --git a/docs/errors.md b/docs/errors.md new file mode 100644 index 00000000..68eefd00 --- /dev/null +++ b/docs/errors.md @@ -0,0 +1,244 @@ +# Errors + +[English](errors.md) · [Русский](errors.ru.md) + +`alveby/atrium-errors` catches the site's errors and keeps them in the site's own database: PHP exceptions, failed queue jobs, failed scheduled tasks and JavaScript errors in visitors' browsers. Errors of one kind from one place make one line in the admin, with the number of times it happened, the trace, the requests and a chart. It e-mails or messages Telegram when a new error appears or a fixed one comes back. It can also send everything to Sentry or GlitchTip, or to any service you write a driver for. + +It is a small Sentry inside the site: nothing to host, nothing to pay, and the data stays on your server. When you outgrow it, switch Sentry on next to it or instead of it. + +- [Install](#install) +- [What is caught](#what-is-caught) +- [How errors are grouped](#how-errors-are-grouped) +- [The admin screens](#the-admin-screens) +- [Statuses and «resolve in next release»](#statuses-and-resolve-in-next-release) +- [Alerts](#alerts) +- [Drivers: database, Sentry, log](#drivers-database-sentry-log) +- [Your own driver: Bugsnag, Rollbar, a webhook](#your-own-driver-bugsnag-rollbar-a-webhook) +- [Using sentry-laravel instead](#using-sentry-laravel-instead) +- [JavaScript errors](#javascript-errors) +- [Secrets and personal data](#secrets-and-personal-data) +- [Load: sampling, the cap, the queue](#load-sampling-the-cap-the-queue) +- [Permissions and sites](#permissions-and-sites) +- [Settings](#settings) +- [Commands](#commands) + +## Install + +```bash +composer require alveby/atrium-errors +php artisan atrium:module:install alveby/atrium-errors +``` + +The install creates two tables (`error_issues`, `error_events`), adds **Site health → Errors** to the menu, the **Errors in 24 hours** tile to the dashboard, and gives the right to see errors to every role that may change the module's settings. Old events are deleted at night by Laravel's scheduler, so cron must call `php artisan schedule:run` every minute, as for any Atrium site. + +Check that it works: + +```bash +php artisan atrium:errors:test +``` + +A test error appears in **Site health → Errors** and in every other driver that is switched on. + +## What is caught + +| Source | How | +|---|---| +| PHP exceptions of pages and commands | Laravel's exception handler; what Laravel does not report anyway (validation, 404, sign-in) is skipped | +| Queue jobs that failed for good | the `JobFailed` event, with the job's name, queue and connection | +| Scheduled tasks that failed | the `ScheduledTaskFailed` event, with the command and its schedule | +| JavaScript errors | a small script in the pages, [switched on in the settings](#javascript-errors) | + +Each event keeps the exception chain (up to three previous exceptions) with code around every line of the trace, the request kept thin on purpose — the address with secret query parameters taken out, the method, the route, the site, the language and the signed-in user's id — the release, the environment, versions of PHP and Laravel, and the last 30 queries and log lines before the error. Headers, cookies, the request body and the IP address are never stored. + +To report something yourself: + +```php +use Atrium\Errors\Errors; + +app(Errors::class)->capture($exception, context: ['order' => $order->id]); +``` + +Exceptions listed in `ignore` in `config/atrium-errors.php` are never caught. + +## How errors are grouped + +An error is the same one when it has the same class and happens in the same place: the first five frames of your own code, by file and function. Line numbers do not count, so an edit above the line does not make a new error; neither do numbers, ids or quoted values in the message. Compiled views and built bundles are recognised by name without their hash. When there is no code to tell the place by, the message with the changing parts blanked decides. + +## The admin screens + +**Site health → Errors** lists one line per error: its class and message, where it happens, the level and the source, how many times and for how many users, and when it was seen last. Buttons above the list switch between unresolved, resolved, ignored and all; the filters look for words in the class, message and place, and narrow the list by site, release, level, source and address. It sorts by last or first seen, by events or by users. + +An error's page shows: + +- buttons to resolve, resolve in the next release, ignore or reopen; +- events, users, first and last seen, first and last release; +- a chart by hour for the last 24 hours or by day for 30 days, with the number on every bar; +- the addresses and releases it happens in most; +- the trace of one event: your own frames with the code around them, the framework's frames behind a button; +- the request, the environment and what happened before the error; +- every event, newest first, each opening its own trace. + +The **Errors in 24 hours** tile on the dashboard counts events, new errors, errors that came back and unresolved ones, draws the events hour by hour and lists the five noisiest errors. + +## Statuses and «resolve in next release» + +| Status | Meaning | +|---|---| +| Unresolved | New or reopened. Alerts are sent | +| Resolved | Fixed. A new event reopens it and sends a «came back» alert | +| Ignored | Known and harmless. Events are still counted, no alerts | + +**Resolve in next release** is for an error fixed in code that is not deployed yet. The error is marked resolved in the release running now; events from this release do not reopen it, and the first event of any other release does. The release is the git commit of the checkout, or `ATRIUM_RELEASE` if you set it in the deploy script, or else the application's version from Composer. + +## Alerts + +Alerts go by e-mail, to Telegram, or both: + +- a **new** error; +- an error that **came back** after it was resolved; +- a **spike**: an error with more events in an hour than the threshold (100 by default; 0 turns spikes off). + +Each error alerts once per reason, a spike at most once an hour, and all of them together at most ten times in ten minutes, so an outage does not bury the inbox. Mail goes through the admin's mail settings under its own purpose, so it may use its own sender. For Telegram, create a bot with `@BotFather`, add it to a chat, and put its token and the chat id in the settings. + +## Drivers: database, Sentry, log + +An event goes to every driver that is switched on, each on its own: one that fails does not stop the others, and its error goes to the fallback log. + +| Driver | What it does | +|---|---| +| `database` | Keeps events in the site's database for the admin screens. On by default | +| `sentry` | Sends events to Sentry, self-hosted Sentry or [GlitchTip](https://glitchtip.com), which speaks the same protocol. Needs only the DSN, no SDK | +| `log` | Writes a line to the application's log, for log collectors that already read it | + +```dotenv +ATRIUM_ERRORS_DRIVERS=database,sentry +ATRIUM_ERRORS_SENTRY_DSN=https://public-key@errors.example.com/7 +``` + +The `sentry` driver also takes `SENTRY_LARAVEL_DSN` or `SENTRY_DSN` when `ATRIUM_ERRORS_SENTRY_DSN` is empty. + +## Your own driver: Bugsnag, Rollbar, a webhook + +A driver is a class implementing `Atrium\Errors\Contracts\ErrorReporter`: + +```php +namespace App\Errors; + +use Atrium\Errors\Contracts\ErrorReporter; +use Atrium\Errors\Event; +use Illuminate\Support\Facades\Http; + +final class WebhookReporter implements ErrorReporter +{ + public function report(Event $event): void + { + Http::timeout(3)->post('https://hooks.example.com/errors', [ + 'id' => $event->id, + 'level' => $event->level, + 'title' => $event->class.': '.$event->message, + 'release' => $event->release, + 'fingerprint' => $event->fingerprint, + ]); + } +} +``` + +Register it under a name and switch it on: + +```php +// config/atrium-errors.php +'reporters' => [ + 'webhook' => App\Errors\WebhookReporter::class, +], +``` + +```dotenv +ATRIUM_ERRORS_DRIVERS=database,webhook +``` + +The class is made by the container, so its constructor may ask for anything bound there. The event arrives already scrubbed, sampled and within the cap. `report()` runs after the response has gone to the visitor, or in a queue job, so it must not rely on the request. It may throw: the error goes to the fallback log, and the other drivers still get the event. + +`Event` holds `id`, `kind` (`php`, `job`, `schedule`, `browser`, `message`), `level`, `class`, `message`, `exceptions` (each with `class`, `message` and `frames`, the frame of the throw first), `request` (`url`, `path`, `method`, `route`, `site_id`, `locale`, `user_id`), `context`, `breadcrumbs`, `environment`, `release`, `runtime`, `fingerprint` and `timestamp`. + +For Bugsnag or Rollbar, call their PHP client in `report()`: `Bugsnag::notifyError($event->class, $event->message)` or `Rollbar::log($event->level, $event->message, [...])`. Pass the `fingerprint` as their grouping hash so that both group errors the same way. + +## Using sentry-laravel instead + +If you prefer Sentry's own SDK (`sentry/sentry-laravel`) for its performance tracing, install it as Sentry's docs say and leave `sentry` out of `ATRIUM_ERRORS_DRIVERS`, so each error is not sent twice. Both can run together: the SDK reports to Sentry, this module keeps its own copy for the admin. + +## JavaScript errors + +Switch on **Catch JavaScript errors on the site** or **in the admin** in the settings (or `ATRIUM_ERRORS_BROWSER_SITE=true`, `ATRIUM_ERRORS_BROWSER_ADMIN=true`). The module then adds a small script to every full HTML page itself; no layout or theme needs editing. A page with a Content-Security-Policy gets the script with Vite's nonce. + +The script sends at most five errors per page and never the same one twice, with only the message, the type and the stack. The server adds the address and scrubs it. Reports go to `POST /atrium-errors/browser`, which accepts ten per minute from one visitor and 16 KB at most each. + +## Secrets and personal data + +Before an event is stored or sent anywhere, it is scrubbed: + +- headers, cookies, the request body and the IP address are not taken at all; +- values under keys that name a password, secret, token, API key, authorization, cookie, session, CSRF token, card, CVV, IBAN, signature, DSN, e-mail, phone, PIN or one-time code are replaced with `[Filtered]` — in the context and the job's data, including keys like `user_password` or `X-Api-Key`, and in query parameters of the address; +- in any text — messages, addresses, queries, log lines — `password=…`-like pairs are filtered; e-mails become `[email]`, card numbers (checked with Luhn, so an order number stays) become `[card]`, phone numbers become `[phone]`. + +Add your own keys in `scrub_keys` in `config/atrium-errors.php`. + +## Load: sampling, the cap, the queue + +The tracker must never take the site down with it: + +- **Sampling**: keep only part of the events, 1–100 percent (`ATRIUM_ERRORS_SAMPLE_RATE`, 100 by default). +- **Cap**: at most this many events a minute for the whole site (`ATRIUM_ERRORS_PER_MINUTE`, 60 by default); the rest is dropped before any work is done. +- **Writing later**: events are stored after the response has gone to the visitor; with `ATRIUM_ERRORS_QUEUE=redis` they go through that queue connection instead. +- **Fallback log**: when the database cannot be written to, the event goes to `storage/logs/atrium-errors.log`, one JSON line each. +- **Retention**: events older than 90 days are deleted at 03:40 every night (`ATRIUM_ERRORS_RETENTION_DAYS`); errors left without events go with them. + +An error inside the tracker itself goes to the fallback log and is never thrown. + +## Permissions and sites + +Two rights in **Roles**: + +| Right | Gives | +|---|---| +| `errors.view` — View errors | The list, the error pages, the status buttons and the dashboard tile | +| `errors.settings` — Settings | The module's settings: drivers, DSN, alerts, sampling | + +On install, roles that have the settings right also get the view right. One does not include the other: a role may see errors without changing where they go, or the other way round. + +An administrator limited to some sites sees only errors that happened on those sites, and only their events. Errors with no site (commands, queue jobs) are seen only by administrators of all sites. + +## Settings + +**Modules → Errors → Settings** in the admin; a value saved there wins over `.env`, which gives the defaults. The DSN and the Telegram token are better kept in `.env`. + +| In the admin | `.env` | Default | +|---|---|---| +| Drivers | `ATRIUM_ERRORS_DRIVERS` | `database` | +| Sentry DSN | `ATRIUM_ERRORS_SENTRY_DSN` | `SENTRY_LARAVEL_DSN`, `SENTRY_DSN` | +| Events kept, % | `ATRIUM_ERRORS_SAMPLE_RATE` | 100 | +| Events a minute at most | `ATRIUM_ERRORS_PER_MINUTE` | 60 | +| Days to keep | `ATRIUM_ERRORS_RETENTION_DAYS` | 90 | +| Alert e-mail | `ATRIUM_ERRORS_ALERT_EMAIL` | none | +| Telegram bot token | `ATRIUM_ERRORS_TELEGRAM_TOKEN` | none | +| Telegram chat | `ATRIUM_ERRORS_TELEGRAM_CHAT` | none | +| Alert on new / came back | | on / on | +| Spike: events an hour | | 100 | +| JavaScript on the site / in the admin | `ATRIUM_ERRORS_BROWSER_SITE`, `ATRIUM_ERRORS_BROWSER_ADMIN` | off / off | + +Only in `.env`: + +| `.env` | Default | What it does | +|---|---|---| +| `ATRIUM_ERRORS_ENABLED` | `true` | `false`: nothing is caught; the admin screens stay | +| `ATRIUM_RELEASE` | git commit, else Composer version | The release events are grouped by | +| `ATRIUM_ERRORS_QUEUE` | none: after the response | A queue connection to store events through | + +The rest — ignored exceptions, extra keys to scrub, breadcrumbs kept, code lines around the trace, the fallback log's path — is in `config/atrium-errors.php` after `php artisan vendor:publish --tag=atrium-errors-config`. + +## Commands + +```bash +php artisan atrium:errors:test # send a test error to every driver +php artisan atrium:errors:prune # delete old events now +php artisan atrium:errors:prune --days=30 +``` diff --git a/docs/errors.ru.md b/docs/errors.ru.md new file mode 100644 index 00000000..bf990e57 --- /dev/null +++ b/docs/errors.ru.md @@ -0,0 +1,244 @@ +# Ошибки + +[English](errors.md) · [Русский](errors.ru.md) + +`alveby/atrium-errors` ловит ошибки сайта и хранит их в собственной базе сайта: исключения PHP, упавшие задачи очереди, упавшие задачи по расписанию и ошибки JavaScript в браузерах посетителей. Ошибки одного вида из одного места складываются в одну строку админки — со счётчиком, трассировкой, запросами и графиком. Когда появляется новая ошибка или возвращается исправленная, приходит письмо или сообщение в Telegram. Всё можно отправлять и в Sentry или GlitchTip, или в любой сервис, для которого вы напишете драйвер. + +Это маленький Sentry внутри сайта: ничего не нужно разворачивать и оплачивать, данные остаются на вашем сервере. Когда его станет мало, включите Sentry рядом или вместо. + +- [Установка](#установка) +- [Что ловится](#что-ловится) +- [Как ошибки группируются](#как-ошибки-группируются) +- [Экраны админки](#экраны-админки) +- [Статусы и «Решено в следующем релизе»](#статусы-и-решено-в-следующем-релизе) +- [Оповещения](#оповещения) +- [Драйверы: база, Sentry, журнал](#драйверы-база-sentry-журнал) +- [Свой драйвер: Bugsnag, Rollbar, вебхук](#свой-драйвер-bugsnag-rollbar-вебхук) +- [Вместо этого — sentry-laravel](#вместо-этого--sentry-laravel) +- [Ошибки JavaScript](#ошибки-javascript) +- [Секреты и персональные данные](#секреты-и-персональные-данные) +- [Нагрузка: выборка, потолок, очередь](#нагрузка-выборка-потолок-очередь) +- [Права и сайты](#права-и-сайты) +- [Настройки](#настройки) +- [Команды](#команды) + +## Установка + +```bash +composer require alveby/atrium-errors +php artisan atrium:module:install alveby/atrium-errors +``` + +Установка создаёт две таблицы (`error_issues`, `error_events`), добавляет в меню **Состояние сайта → Ошибки**, на рабочий стол — плитку **Ошибки за сутки**, и даёт право просмотра ошибок всем ролям, которым можно менять настройки модуля. Старые события удаляются ночью планировщиком Laravel, поэтому cron должен раз в минуту вызывать `php artisan schedule:run` — как на любом сайте Atrium. + +Проверить, что всё работает: + +```bash +php artisan atrium:errors:test +``` + +Тестовая ошибка появится в **Состояние сайта → Ошибки** и во всех остальных включённых драйверах. + +## Что ловится + +| Источник | Как | +|---|---| +| Исключения PHP на страницах и в командах | обработчик исключений Laravel; то, о чём Laravel и так не сообщает (валидация, 404, вход), пропускается | +| Задачи очереди, упавшие окончательно | событие `JobFailed`, с именем задачи, очередью и подключением | +| Задачи по расписанию, которые упали | событие `ScheduledTaskFailed`, с командой и её расписанием | +| Ошибки JavaScript | небольшой скрипт в страницах, [включается в настройках](#ошибки-javascript) | + +Каждое событие хранит цепочку исключений (до трёх предыдущих) с кодом вокруг каждой строки трассировки; запрос — намеренно скупо: адрес без секретных параметров, метод, маршрут, сайт, язык и id вошедшего пользователя; релиз, окружение, версии PHP и Laravel и последние 30 запросов к базе и строк журнала перед ошибкой. Заголовки, куки, тело запроса и IP-адрес не сохраняются никогда. + +Сообщить об ошибке самому: + +```php +use Atrium\Errors\Errors; + +app(Errors::class)->capture($exception, context: ['order' => $order->id]); +``` + +Исключения из списка `ignore` в `config/atrium-errors.php` не ловятся никогда. + +## Как ошибки группируются + +Ошибка считается той же, если у неё тот же класс и она случается в том же месте: первые пять кадров вашего собственного кода, по файлу и функции. Номера строк не учитываются — правка выше строки не создаёт новую ошибку; числа, id и значения в кавычках в сообщении тоже. Скомпилированные шаблоны и собранные бандлы узнаются по имени без хеша. Если места по коду не определить, решает сообщение с вычищенными меняющимися частями. + +## Экраны админки + +**Состояние сайта → Ошибки** — по строке на ошибку: класс и сообщение, где случается, уровень и источник, сколько раз и у скольких пользователей, когда была в последний раз. Кнопки над списком переключают нерешённые, решённые, скрытые и все; фильтры ищут слова в классе, сообщении и месте и сужают список по сайту, релизу, уровню, источнику и адресу. Сортировка — по последнему или первому появлению, по событиям или по пользователям. + +Страница ошибки показывает: + +- кнопки «Решено», «Решено в следующем релизе», «Скрыть» или «Открыть снова»; +- события, пользователей, первое и последнее появление, первый и последний релиз; +- график по часам за сутки или по дням за 30 дней, с числом на каждом столбике; +- адреса и релизы, где она случается чаще всего; +- трассировку одного события: кадры вашего кода с кодом вокруг, кадры фреймворка — за кнопкой; +- запрос, окружение и то, что происходило перед ошибкой; +- все события, новые сверху; каждое открывает свою трассировку. + +Плитка **Ошибки за сутки** на рабочем столе считает события, новые ошибки, вернувшиеся и нерешённые, рисует события по часам и показывает пять самых частых ошибок. + +## Статусы и «Решено в следующем релизе» + +| Статус | Значит | +|---|---| +| Не решена | Новая или открытая снова. Оповещения приходят | +| Решена | Исправлена. Новое событие открывает её снова и присылает оповещение «вернулась» | +| Скрыта | Известна и безвредна. События считаются, оповещений нет | + +**Решено в следующем релизе** — для ошибки, которая исправлена в коде, но ещё не выложена. Ошибка помечается решённой в релизе, который работает сейчас: события этого релиза её не открывают, а первое событие любого другого — открывает. Релиз — это коммит git рабочей копии, или `ATRIUM_RELEASE`, если вы задаёте его в скрипте выкладки, или версия приложения из Composer. + +## Оповещения + +Оповещения приходят письмом, в Telegram или туда и туда: + +- **новая** ошибка; +- ошибка **вернулась** после того, как её отметили решённой; +- **всплеск**: у ошибки за час событий больше порога (по умолчанию 100; 0 выключает всплески). + +Каждая ошибка оповещает один раз по каждой причине, всплеск — не чаще раза в час, а все вместе — не больше десяти раз за десять минут, чтобы авария не завалила почту. Письма идут через почтовые настройки админки со своим назначением, поэтому у них может быть свой отправитель. Для Telegram создайте бота через `@BotFather`, добавьте его в чат и впишите в настройки его токен и id чата. + +## Драйверы: база, Sentry, журнал + +Событие уходит во все включённые драйверы, в каждый отдельно: упавший не мешает остальным, а его ошибка записывается в запасной журнал. + +| Драйвер | Что делает | +|---|---| +| `database` | Хранит события в базе сайта для экранов админки. Включён по умолчанию | +| `sentry` | Отправляет события в Sentry, свой Sentry или [GlitchTip](https://glitchtip.com), который говорит на том же протоколе. Нужен только DSN, SDK не нужен | +| `log` | Пишет строку в журнал приложения — для сборщиков журналов, которые его уже читают | + +```dotenv +ATRIUM_ERRORS_DRIVERS=database,sentry +ATRIUM_ERRORS_SENTRY_DSN=https://public-key@errors.example.com/7 +``` + +Если `ATRIUM_ERRORS_SENTRY_DSN` пуст, драйвер `sentry` берёт `SENTRY_LARAVEL_DSN` или `SENTRY_DSN`. + +## Свой драйвер: Bugsnag, Rollbar, вебхук + +Драйвер — это класс, реализующий `Atrium\Errors\Contracts\ErrorReporter`: + +```php +namespace App\Errors; + +use Atrium\Errors\Contracts\ErrorReporter; +use Atrium\Errors\Event; +use Illuminate\Support\Facades\Http; + +final class WebhookReporter implements ErrorReporter +{ + public function report(Event $event): void + { + Http::timeout(3)->post('https://hooks.example.com/errors', [ + 'id' => $event->id, + 'level' => $event->level, + 'title' => $event->class.': '.$event->message, + 'release' => $event->release, + 'fingerprint' => $event->fingerprint, + ]); + } +} +``` + +Зарегистрируйте его под именем и включите: + +```php +// config/atrium-errors.php +'reporters' => [ + 'webhook' => App\Errors\WebhookReporter::class, +], +``` + +```dotenv +ATRIUM_ERRORS_DRIVERS=database,webhook +``` + +Класс создаётся контейнером, так что конструктор может просить всё, что там зарегистрировано. Событие приходит уже очищенным, после выборки и потолка. `report()` выполняется после того, как ответ ушёл посетителю, или в задаче очереди, поэтому на запрос полагаться нельзя. Бросать исключения можно: ошибка уйдёт в запасной журнал, а остальные драйверы событие всё равно получат. + +В `Event` есть `id`, `kind` (`php`, `job`, `schedule`, `browser`, `message`), `level`, `class`, `message`, `exceptions` (у каждого `class`, `message` и `frames`, кадр броска первым), `request` (`url`, `path`, `method`, `route`, `site_id`, `locale`, `user_id`), `context`, `breadcrumbs`, `environment`, `release`, `runtime`, `fingerprint` и `timestamp`. + +Для Bugsnag или Rollbar вызовите в `report()` их PHP-клиент: `Bugsnag::notifyError($event->class, $event->message)` или `Rollbar::log($event->level, $event->message, [...])`. Передайте `fingerprint` как их ключ группировки — тогда обе системы будут группировать ошибки одинаково. + +## Вместо этого — sentry-laravel + +Если вам нужен собственный SDK Sentry (`sentry/sentry-laravel`) ради трассировки производительности, установите его по документации Sentry и не указывайте `sentry` в `ATRIUM_ERRORS_DRIVERS`, чтобы ошибки не уходили дважды. Работать вместе они могут: SDK отправляет в Sentry, модуль хранит свою копию для админки. + +## Ошибки JavaScript + +Включите в настройках **Ловить ошибки JavaScript на сайте** или **в админке** (или `ATRIUM_ERRORS_BROWSER_SITE=true`, `ATRIUM_ERRORS_BROWSER_ADMIN=true`). Модуль сам добавит небольшой скрипт в каждую полную HTML-страницу — шаблоны и тему править не нужно. Странице с Content-Security-Policy скрипт достаётся с nonce от Vite. + +Скрипт отправляет не больше пяти ошибок со страницы и никогда одну и ту же дважды — только сообщение, тип и стек. Адрес добавляет и чистит сервер. Отчёты приходят на `POST /atrium-errors/browser`, который принимает десять в минуту от одного посетителя и не больше 16 КБ каждый. + +## Секреты и персональные данные + +Перед тем как событие сохраняется или куда-то уходит, оно очищается: + +- заголовки, куки, тело запроса и IP-адрес не берутся вовсе; +- значения под ключами, в названии которых есть пароль, секрет, токен, ключ API, авторизация, куки, сессия, CSRF-токен, карта, CVV, IBAN, подпись, DSN, e-mail, телефон, PIN или одноразовый код, заменяются на `[Filtered]` — в контексте и данных задачи, включая ключи вроде `user_password` или `X-Api-Key`, и в параметрах адреса; +- в любом тексте — сообщениях, адресах, запросах к базе, строках журнала — пары вида `password=…` вычищаются; e-mail становится `[email]`, номер карты (проверяется по Луну, так что номер заказа остаётся) — `[card]`, телефон — `[phone]`. + +Свои ключи добавляются в `scrub_keys` в `config/atrium-errors.php`. + +## Нагрузка: выборка, потолок, очередь + +Учёт ошибок не должен ронять сайт вместе с собой: + +- **Выборка**: хранить только часть событий, 1–100 процентов (`ATRIUM_ERRORS_SAMPLE_RATE`, по умолчанию 100). +- **Потолок**: не больше стольких событий в минуту на весь сайт (`ATRIUM_ERRORS_PER_MINUTE`, по умолчанию 60); лишнее отбрасывается до всякой работы. +- **Запись потом**: события сохраняются после того, как ответ ушёл посетителю; с `ATRIUM_ERRORS_QUEUE=redis` — через это подключение очереди. +- **Запасной журнал**: если в базу записать нельзя, событие уходит в `storage/logs/atrium-errors.log`, по строке JSON на каждое. +- **Срок хранения**: события старше 90 дней удаляются каждую ночь в 03:40 (`ATRIUM_ERRORS_RETENTION_DAYS`); ошибки, у которых не осталось событий, — вместе с ними. + +Ошибка внутри самого модуля записывается в запасной журнал и никогда не пробрасывается дальше. + +## Права и сайты + +Два права в **Ролях**: + +| Право | Даёт | +|---|---| +| `errors.view` — Просмотр ошибок | Список, страницы ошибок, кнопки статусов и плитку на рабочем столе | +| `errors.settings` — Настройки | Настройки модуля: драйверы, DSN, оповещения, выборку | + +При установке роли с правом на настройки получают и право просмотра. Одно не включает другое: роль может видеть ошибки, не меняя, куда они уходят, и наоборот. + +Администратор, ограниченный частью сайтов, видит только ошибки, случившиеся на этих сайтах, и только их события. Ошибки без сайта (команды, задачи очереди) видят только администраторы всех сайтов. + +## Настройки + +**Модули → Ошибки → Настройки** в админке; сохранённое там важнее `.env`, который задаёт значения по умолчанию. DSN и токен Telegram лучше держать в `.env`. + +| В админке | `.env` | По умолчанию | +|---|---|---| +| Драйверы | `ATRIUM_ERRORS_DRIVERS` | `database` | +| DSN Sentry | `ATRIUM_ERRORS_SENTRY_DSN` | `SENTRY_LARAVEL_DSN`, `SENTRY_DSN` | +| Хранить событий, % | `ATRIUM_ERRORS_SAMPLE_RATE` | 100 | +| Событий в минуту, не больше | `ATRIUM_ERRORS_PER_MINUTE` | 60 | +| Хранить дней | `ATRIUM_ERRORS_RETENTION_DAYS` | 90 | +| Почта для оповещений | `ATRIUM_ERRORS_ALERT_EMAIL` | нет | +| Токен бота Telegram | `ATRIUM_ERRORS_TELEGRAM_TOKEN` | нет | +| Чат Telegram | `ATRIUM_ERRORS_TELEGRAM_CHAT` | нет | +| Оповещать о новых / вернувшихся | | да / да | +| Всплеск: событий в час | | 100 | +| JavaScript на сайте / в админке | `ATRIUM_ERRORS_BROWSER_SITE`, `ATRIUM_ERRORS_BROWSER_ADMIN` | нет / нет | + +Только в `.env`: + +| `.env` | По умолчанию | Что делает | +|---|---|---| +| `ATRIUM_ERRORS_ENABLED` | `true` | `false`: ничего не ловится, экраны админки остаются | +| `ATRIUM_RELEASE` | коммит git, иначе версия Composer | Релиз, по которому группируются события | +| `ATRIUM_ERRORS_QUEUE` | нет: после ответа | Подключение очереди, через которое сохраняются события | + +Остальное — исключения, которые не ловить, дополнительные ключи для очистки, сколько хранить предыстории, сколько строк кода показывать, путь запасного журнала — в `config/atrium-errors.php` после `php artisan vendor:publish --tag=atrium-errors-config`. + +## Команды + +```bash +php artisan atrium:errors:test # отправить тестовую ошибку во все драйверы +php artisan atrium:errors:prune # удалить старые события сейчас +php artisan atrium:errors:prune --days=30 +``` diff --git a/docs/readme/README.be.md b/docs/readme/README.be.md index 3b8de5e9..1da7b3ab 100644 --- a/docs/readme/README.be.md +++ b/docs/readme/README.be.md @@ -123,6 +123,7 @@ php artisan atrium:bitrix:parity - [Кэш: хуткія старонкі з дзясяткамі ўласцівасцей, Redis, кэш старонак, загалоўкі для CDN](../cache.md) - [Пераезд з 1С-Бітрыкс крок за крокам](../bitrix.md) - [Рэзервовыя копіі: базы і файлы ў некалькі месцаў, расклад, праверкі, аднаўленне](../backup.md) +- [Памылкі: памылкі PHP, чэргаў і JavaScript у базе сайта, абвесткі, Sentry і свае драйверы](../errors.md) - [CDN: выявы, паменшаныя копіі і WebP/AVIF, ачыстка кэша, загрузкі ў S3](../cdn.md) ## Пакеты @@ -136,6 +137,7 @@ php artisan atrium:bitrix:parity | [`alveby/atrium-custom-fields`](../../packages/custom-fields/README.md) | Палі, якія дадаюць у любы модуль з адмінкі, з фільтрамі і фасетамі | | [`alveby/atrium-docs`](../../packages/docs/README.md) | Дакументацыя з Markdown: версіі і пошук | | [`alveby/atrium-backup`](../../packages/backup/README.md) | Рэзервовыя копіі баз і файлаў, аднаўленне з адмінкі | +| [`alveby/atrium-errors`](../../packages/errors/README.md) | Улік памылак у базе сайта, абвесткі, Sentry | Калі 0.1 з'явіцца на Packagist, у гатовую праграму на Laravel 13 Atrium будзе ўсталёўвацца так: diff --git a/docs/readme/README.de.md b/docs/readme/README.de.md index 52f1fb85..856515d4 100644 --- a/docs/readme/README.de.md +++ b/docs/readme/README.de.md @@ -123,6 +123,7 @@ Die Bitrix-Datenbank wird nur gelesen. Tabs, Feldreihenfolge und Listenspalten k - [Cache: schnelle Seiten mit Dutzenden Eigenschaften, Redis, Seiten-Cache, CDN-Header](../cache.md) - [Umzug von 1C-Bitrix, Schritt für Schritt](../bitrix.md) - [Backups: Datenbanken und Dateien an mehrere Orte, Zeitpläne, Prüfungen, Wiederherstellung](../backup.md) +- [Fehler: PHP-, Warteschlangen- und JavaScript-Fehler in der Datenbank der Website, Benachrichtigungen, Sentry und eigene Treiber](../errors.md) - [CDN: Bilder, verkleinerte Kopien und WebP/AVIF, Cache leeren, Uploads zu S3](../cdn.md) ## Pakete @@ -136,6 +137,7 @@ Die Bitrix-Datenbank wird nur gelesen. Tabs, Feldreihenfolge und Listenspalten k | [`alveby/atrium-custom-fields`](../../packages/custom-fields/README.md) | Felder für jedes Modul, im Admin-Bereich angelegt, mit Filtern und Facetten | | [`alveby/atrium-docs`](../../packages/docs/README.md) | Dokumentation aus Markdown, mit Versionen und Suche | | [`alveby/atrium-backup`](../../packages/backup/README.md) | Backups der Datenbanken und Dateien, Wiederherstellung im Admin-Bereich | +| [`alveby/atrium-errors`](../../packages/errors/README.md) | Fehlererfassung in der Datenbank der Website, Benachrichtigungen, Sentry | Sobald 0.1 auf Packagist ist, bekommt eine bestehende Laravel-13-Anwendung Atrium so: diff --git a/docs/readme/README.es.md b/docs/readme/README.es.md index d085b75b..68cbee78 100644 --- a/docs/readme/README.es.md +++ b/docs/readme/README.es.md @@ -123,6 +123,7 @@ La base de datos de Bitrix solo se lee. Las pestañas, el orden de los campos y - [Caché: páginas rápidas con decenas de propiedades, Redis, caché de páginas, cabeceras para CDN](../cache.md) - [Migrar desde 1C-Bitrix, paso a paso](../bitrix.md) - [Copias de seguridad: bases de datos y archivos en varios destinos, horarios, comprobaciones, restauración](../backup.md) +- [Errores: errores de PHP, de colas y de JavaScript en la base de datos del sitio, alertas, Sentry y controladores propios](../errors.md) - [CDN: imágenes, copias redimensionadas y WebP/AVIF, purga de caché, subidas a S3](../cdn.md) ## Paquetes @@ -136,6 +137,7 @@ La base de datos de Bitrix solo se lee. Las pestañas, el orden de los campos y | [`alveby/atrium-custom-fields`](../../packages/custom-fields/README.md) | Campos que se añaden a cualquier módulo desde el panel, con filtros y facetas | | [`alveby/atrium-docs`](../../packages/docs/README.md) | Documentación desde Markdown, con versiones y búsqueda | | [`alveby/atrium-backup`](../../packages/backup/README.md) | Copias de seguridad de bases de datos y archivos, restauración desde el panel | +| [`alveby/atrium-errors`](../../packages/errors/README.md) | Registro de errores en la base de datos del sitio, alertas, Sentry | Cuando la 0.1 esté en Packagist, una aplicación Laravel 13 existente podrá añadir Atrium con: diff --git a/docs/readme/README.fr.md b/docs/readme/README.fr.md index ae7ffd1f..41ed5600 100644 --- a/docs/readme/README.fr.md +++ b/docs/readme/README.fr.md @@ -123,6 +123,7 @@ La base de données Bitrix est uniquement lue. Les onglets, l'ordre des champs e - [Cache : des pages rapides avec des dizaines de propriétés, Redis, cache de pages, en-têtes CDN](../cache.md) - [Migrer depuis 1C-Bitrix, pas à pas](../bitrix.md) - [Sauvegardes : bases de données et fichiers vers plusieurs destinations, planification, contrôles, restauration](../backup.md) +- [Erreurs : erreurs PHP, de file d'attente et JavaScript dans la base du site, alertes, Sentry et vos propres pilotes](../errors.md) - [CDN : images, copies redimensionnées et WebP/AVIF, purge du cache, envois vers S3](../cdn.md) ## Paquets @@ -136,6 +137,7 @@ La base de données Bitrix est uniquement lue. Les onglets, l'ordre des champs e | [`alveby/atrium-custom-fields`](../../packages/custom-fields/README.md) | Champs ajoutés à tout module depuis l'administration, avec filtres et facettes | | [`alveby/atrium-docs`](../../packages/docs/README.md) | Documentation à partir de Markdown, avec versions et recherche | | [`alveby/atrium-backup`](../../packages/backup/README.md) | Sauvegardes des bases de données et des fichiers, restauration depuis l'administration | +| [`alveby/atrium-errors`](../../packages/errors/README.md) | Suivi des erreurs dans la base du site, alertes, Sentry | Une fois la 0.1 publiée sur Packagist, une application Laravel 13 existante obtiendra Atrium avec : diff --git a/docs/readme/README.it.md b/docs/readme/README.it.md index eaca51df..119671e6 100644 --- a/docs/readme/README.it.md +++ b/docs/readme/README.it.md @@ -123,6 +123,7 @@ Il database di Bitrix viene solo letto. Le schede, l'ordine dei campi e le colon - [Cache: pagine veloci con decine di proprietà, Redis, cache delle pagine, intestazioni per CDN](../cache.md) - [Migrare da 1C-Bitrix, passo per passo](../bitrix.md) - [Backup: database e file in più destinazioni, pianificazione, controlli, ripristino](../backup.md) +- [Errori: errori PHP, delle code e JavaScript nel database del sito, avvisi, Sentry e driver propri](../errors.md) - [CDN: immagini, copie ridimensionate e WebP/AVIF, svuotamento della cache, caricamenti su S3](../cdn.md) ## Pacchetti @@ -136,6 +137,7 @@ Il database di Bitrix viene solo letto. Le schede, l'ordine dei campi e le colon | [`alveby/atrium-custom-fields`](../../packages/custom-fields/README.md) | Campi aggiunti a qualsiasi modulo dal pannello, con filtri e faccette | | [`alveby/atrium-docs`](../../packages/docs/README.md) | Documentazione da Markdown, con versioni e ricerca | | [`alveby/atrium-backup`](../../packages/backup/README.md) | Backup di database e file, ripristino dal pannello | +| [`alveby/atrium-errors`](../../packages/errors/README.md) | Tracciamento degli errori nel database del sito, avvisi, Sentry | Quando la 0.1 sarà su Packagist, un'app Laravel 13 esistente potrà aggiungere Atrium con: diff --git a/docs/readme/README.ja.md b/docs/readme/README.ja.md index 2fc1a5b9..ad073e2d 100644 --- a/docs/readme/README.ja.md +++ b/docs/readme/README.ja.md @@ -123,6 +123,7 @@ Bitrix のデータベースは読み取るだけです。タブ、フィール - [キャッシュ:数十のプロパティでも速いページ、Redis、ページキャッシュ、CDN ヘッダー](../cache.md) - [1C-Bitrix からの移行(手順)](../bitrix.md) - [バックアップ:データベースとファイルを複数の保存先へ、スケジュール、ヘルスチェック、復元](../backup.md) +- [エラー:PHP・キュー・JavaScript のエラーをサイトのデータベースに保存、通知、Sentry、独自ドライバー](../errors.md) - [CDN:画像、リサイズしたコピーと WebP/AVIF、キャッシュの削除、S3 へのアップロード](../cdn.md) ## パッケージ @@ -136,6 +137,7 @@ Bitrix のデータベースは読み取るだけです。タブ、フィール | [`alveby/atrium-custom-fields`](../../packages/custom-fields/README.md) | 管理画面から任意のモジュールに追加するフィールド(フィルターとファセット付き) | | [`alveby/atrium-docs`](../../packages/docs/README.md) | Markdownから作るドキュメント(バージョンと検索つき) | | [`alveby/atrium-backup`](../../packages/backup/README.md) | データベースとファイルのバックアップ、管理画面からの復元 | +| [`alveby/atrium-errors`](../../packages/errors/README.md) | サイトのデータベースでのエラー追跡、通知、Sentry | 0.1 が Packagist に公開されたら、既存の Laravel 13 アプリには次のコマンドで Atrium を導入できます。 diff --git a/docs/readme/README.kk.md b/docs/readme/README.kk.md index fb3d80d7..e2009b59 100644 --- a/docs/readme/README.kk.md +++ b/docs/readme/README.kk.md @@ -123,6 +123,7 @@ php artisan atrium:bitrix:parity - [Кэш: ондаған қасиеті бар жылдам беттер, Redis, беттер кэші, CDN тақырыптары](../cache.md) - [1С-Битрикстен көшу, қадам-қадаммен](../bitrix.md) - [Сақтық көшірмелер: дерекқорлар мен файлдар бірнеше орынға, кесте, тексерулер, қалпына келтіру](../backup.md) +- [Қателер: PHP, кезек және JavaScript қателері сайт дерекқорында, хабарламалар, Sentry және өз драйверлеріңіз](../errors.md) - [CDN: суреттер, кішірейтілген көшірмелер және WebP/AVIF, кэшті тазалау, S3-ке жүктеу](../cdn.md) ## Пакеттер @@ -136,6 +137,7 @@ php artisan atrium:bitrix:parity | [`alveby/atrium-custom-fields`](../../packages/custom-fields/README.md) | Кез келген модульге әкімшілік панельден қосылатын өрістер, сүзгілер мен фасеттермен | | [`alveby/atrium-docs`](../../packages/docs/README.md) | Markdown-тан құжаттама: нұсқалар мен іздеу | | [`alveby/atrium-backup`](../../packages/backup/README.md) | Дерекқорлар мен файлдардың сақтық көшірмелері, әкімшілік панельден қалпына келтіру | +| [`alveby/atrium-errors`](../../packages/errors/README.md) | Сайт дерекқорындағы қателер есебі, хабарламалар, Sentry | 0.1 Packagist-те пайда болғанда, Laravel 13-тегі дайын қосымшаға Atrium былай орнатылады: diff --git a/docs/readme/README.pl.md b/docs/readme/README.pl.md index ab332e4e..7851dcc2 100644 --- a/docs/readme/README.pl.md +++ b/docs/readme/README.pl.md @@ -123,6 +123,7 @@ Baza danych Bitrixa jest tylko odczytywana. Karty, kolejność pól i kolumny li - [Cache: szybkie strony z dziesiątkami właściwości, Redis, cache stron, nagłówki dla CDN](../cache.md) - [Przeprowadzka z 1C-Bitrix krok po kroku](../bitrix.md) - [Kopie zapasowe: bazy danych i pliki w kilku miejscach, harmonogram, kontrole, przywracanie](../backup.md) +- [Błędy: błędy PHP, kolejek i JavaScriptu w bazie strony, powiadomienia, Sentry i własne sterowniki](../errors.md) - [CDN: obrazy, pomniejszone kopie i WebP/AVIF, czyszczenie pamięci podręcznej, przesyłanie do S3](../cdn.md) ## Pakiety @@ -136,6 +137,7 @@ Baza danych Bitrixa jest tylko odczytywana. Karty, kolejność pól i kolumny li | [`alveby/atrium-custom-fields`](../../packages/custom-fields/README.md) | Pola dodawane do dowolnego modułu z panelu, z filtrami i fasetami | | [`alveby/atrium-docs`](../../packages/docs/README.md) | Dokumentacja z Markdown, z wersjami i wyszukiwaniem | | [`alveby/atrium-backup`](../../packages/backup/README.md) | Kopie zapasowe baz danych i plików, przywracanie z panelu | +| [`alveby/atrium-errors`](../../packages/errors/README.md) | Rejestr błędów w bazie strony, powiadomienia, Sentry | Gdy 0.1 trafi na Packagist, do istniejącej aplikacji na Laravel 13 dodasz Atrium tak: diff --git a/docs/readme/README.pt-BR.md b/docs/readme/README.pt-BR.md index 6a9001b0..f72cda63 100644 --- a/docs/readme/README.pt-BR.md +++ b/docs/readme/README.pt-BR.md @@ -123,6 +123,7 @@ O banco de dados do Bitrix é apenas lido. As abas, a ordem dos campos e as colu - [Cache: páginas rápidas com dezenas de propriedades, Redis, cache de páginas, cabeçalhos para CDN](../cache.md) - [Migrar do 1C-Bitrix, passo a passo](../bitrix.md) - [Backups: bancos de dados e arquivos em vários destinos, agendamento, verificações, restauração](../backup.md) +- [Erros: erros de PHP, de filas e de JavaScript no banco do site, alertas, Sentry e drivers próprios](../errors.md) - [CDN: imagens, cópias redimensionadas e WebP/AVIF, limpeza de cache, uploads para S3](../cdn.md) ## Pacotes @@ -136,6 +137,7 @@ O banco de dados do Bitrix é apenas lido. As abas, a ordem dos campos e as colu | [`alveby/atrium-custom-fields`](../../packages/custom-fields/README.md) | Campos adicionados a qualquer módulo pelo painel, com filtros e facetas | | [`alveby/atrium-docs`](../../packages/docs/README.md) | Documentação a partir de Markdown, com versões e busca | | [`alveby/atrium-backup`](../../packages/backup/README.md) | Backups dos bancos de dados e arquivos, restauração pelo painel | +| [`alveby/atrium-errors`](../../packages/errors/README.md) | Registro de erros no banco do site, alertas, Sentry | Quando a 0.1 estiver no Packagist, uma aplicação Laravel 13 existente poderá receber o Atrium com: diff --git a/docs/readme/README.ru.md b/docs/readme/README.ru.md index 61cec146..079ef9fa 100644 --- a/docs/readme/README.ru.md +++ b/docs/readme/README.ru.md @@ -121,6 +121,7 @@ php artisan atrium:bitrix:parity - [Кеш: быстрые страницы с десятками свойств, Redis, кеш страниц, заголовки для CDN](../cache.ru.md) - [Переезд с 1С-Битрикс по шагам](../bitrix.ru.md) - [Резервные копии: базы и файлы в несколько мест, расписание, проверки, восстановление](../backup.ru.md) +- [Ошибки: ошибки PHP, очередей и JavaScript в базе сайта, оповещения, Sentry и свои драйверы](../errors.ru.md) - [CDN: картинки, уменьшенные копии и WebP/AVIF, сброс кеша, загрузки в S3](../cdn.ru.md) ## Пакеты @@ -134,6 +135,7 @@ php artisan atrium:bitrix:parity | [`alveby/atrium-custom-fields`](../../packages/custom-fields/README.md) | Поля, которые добавляют в любой модуль из админки, с фильтрами и фасетами | | [`alveby/atrium-docs`](../../packages/docs/README.md) | Документация из Markdown: версии и поиск | | [`alveby/atrium-backup`](../../packages/backup/README.md) | Резервные копии баз и файлов, восстановление из админки | +| [`alveby/atrium-errors`](../../packages/errors/README.md) | Учёт ошибок в базе сайта, оповещения, Sentry | Когда 0.1 появится на Packagist, в готовое приложение на Laravel 13 Atrium будет ставиться так: diff --git a/docs/readme/README.tr.md b/docs/readme/README.tr.md index 0eb437c6..f3ccd41a 100644 --- a/docs/readme/README.tr.md +++ b/docs/readme/README.tr.md @@ -123,6 +123,7 @@ Bitrix veritabanından yalnızca okuma yapılır. Sekmeler, alan sırası ve lis - [Önbellek: onlarca özellikli hızlı sayfalar, Redis, sayfa önbelleği, CDN başlıkları](../cache.md) - [1C-Bitrix’ten adım adım taşınma](../bitrix.md) - [Yedekler: veritabanları ve dosyalar birden çok yere, zamanlama, sağlık kontrolleri, geri yükleme](../backup.md) +- [Hatalar: PHP, kuyruk ve JavaScript hataları sitenin veritabanında, uyarılar, Sentry ve kendi sürücüleriniz](../errors.md) - [CDN: görseller, küçültülmüş kopyalar ve WebP/AVIF, önbellek temizleme, S3'e yükleme](../cdn.md) ## Paketler @@ -136,6 +137,7 @@ Bitrix veritabanından yalnızca okuma yapılır. Sekmeler, alan sırası ve lis | [`alveby/atrium-custom-fields`](../../packages/custom-fields/README.md) | Yönetim panelinden her modüle eklenen alanlar, filtreler ve faset sayılarıyla | | [`alveby/atrium-docs`](../../packages/docs/README.md) | Markdown’dan belgeler, sürümler ve arama ile | | [`alveby/atrium-backup`](../../packages/backup/README.md) | Veritabanı ve dosya yedekleri, yönetim panelinden geri yükleme | +| [`alveby/atrium-errors`](../../packages/errors/README.md) | Sitenin veritabanında hata takibi, uyarılar, Sentry | 0.1 Packagist'te yayımlandığında, mevcut bir Laravel 13 uygulamasına Atrium şu şekilde eklenecek: diff --git a/docs/readme/README.uk.md b/docs/readme/README.uk.md index 1cdeb7a6..d7c1e544 100644 --- a/docs/readme/README.uk.md +++ b/docs/readme/README.uk.md @@ -123,6 +123,7 @@ php artisan atrium:bitrix:parity - [Кеш: швидкі сторінки з десятками властивостей, Redis, кеш сторінок, заголовки для CDN](../cache.md) - [Переїзд з 1С-Бітрікс крок за кроком](../bitrix.md) - [Резервні копії: бази й файли в кілька місць, розклад, перевірки, відновлення](../backup.md) +- [Помилки: помилки PHP, черг і JavaScript у базі сайту, сповіщення, Sentry і власні драйвери](../errors.md) - [CDN: зображення, зменшені копії й WebP/AVIF, очищення кешу, завантаження в S3](../cdn.md) ## Пакети @@ -136,6 +137,7 @@ php artisan atrium:bitrix:parity | [`alveby/atrium-custom-fields`](../../packages/custom-fields/README.md) | Поля, які додають у будь-який модуль з адмінки, з фільтрами й фасетами | | [`alveby/atrium-docs`](../../packages/docs/README.md) | Документація з Markdown: версії та пошук | | [`alveby/atrium-backup`](../../packages/backup/README.md) | Резервні копії баз і файлів, відновлення з адмінки | +| [`alveby/atrium-errors`](../../packages/errors/README.md) | Облік помилок у базі сайту, сповіщення, Sentry | Коли 0.1 з'явиться на Packagist, у готовий застосунок на Laravel 13 Atrium встановлюватиметься так: diff --git a/docs/readme/README.uz.md b/docs/readme/README.uz.md index 869393de..7777a42f 100644 --- a/docs/readme/README.uz.md +++ b/docs/readme/README.uz.md @@ -123,6 +123,7 @@ Bitrix maʼlumotlar bazasi faqat oʻqiladi. Yorliqlar, maydonlar tartibi va roʻ - [Kesh: oʻnlab xususiyatli tez sahifalar, Redis, sahifalar keshi, CDN sarlavhalari](../cache.md) - [1C-Bitrixdan koʻchish, qadamma-qadam](../bitrix.md) - [Zaxira nusxalar: bazalar va fayllar bir nechta joyga, jadval, tekshiruvlar, tiklash](../backup.md) +- [Xatolar: PHP, navbat va JavaScript xatolari sayt bazasida, ogohlantirishlar, Sentry va oʻz drayverlaringiz](../errors.md) - [CDN: rasmlar, kichraytirilgan nusxalar va WebP/AVIF, keshni tozalash, S3 ga yuklash](../cdn.md) ## Paketlar @@ -136,6 +137,7 @@ Bitrix maʼlumotlar bazasi faqat oʻqiladi. Yorliqlar, maydonlar tartibi va roʻ | [`alveby/atrium-custom-fields`](../../packages/custom-fields/README.md) | Istalgan modulga admin paneldan qoʻshiladigan maydonlar, filtrlar va fasetlar bilan | | [`alveby/atrium-docs`](../../packages/docs/README.md) | Markdown’dan hujjatlar: versiyalar va qidiruv | | [`alveby/atrium-backup`](../../packages/backup/README.md) | Bazalar va fayllarning zaxira nusxalari, admin paneldan tiklash | +| [`alveby/atrium-errors`](../../packages/errors/README.md) | Sayt bazasida xatolar hisobi, ogohlantirishlar, Sentry | 0.1 versiyasi Packagist saytida paydo boʻlgach, mavjud Laravel 13 ilovasiga Atrium quyidagicha oʻrnatiladi: diff --git a/docs/readme/README.zh-CN.md b/docs/readme/README.zh-CN.md index 19436d84..707ad241 100644 --- a/docs/readme/README.zh-CN.md +++ b/docs/readme/README.zh-CN.md @@ -123,6 +123,7 @@ Bitrix 数据库只读不写。标签页、字段顺序和列表列会保持编 - [缓存:带几十个属性也很快的页面、Redis、页面缓存、CDN 头](../cache.md) - [从 1C-Bitrix 迁移,分步说明](../bitrix.md) - [备份:数据库和文件同时存到多个位置、计划任务、健康检查、恢复](../backup.md) +- [错误:PHP、队列和 JavaScript 错误保存在站点数据库中,告警、Sentry 和自定义驱动](../errors.md) - [CDN:图片、缩放副本与 WebP/AVIF、清除缓存、上传到 S3](../cdn.md) ## 软件包 @@ -136,6 +137,7 @@ Bitrix 数据库只读不写。标签页、字段顺序和列表列会保持编 | [`alveby/atrium-custom-fields`](../../packages/custom-fields/README.md) | 在后台为任意模块添加的字段,支持筛选与分面 | | [`alveby/atrium-docs`](../../packages/docs/README.md) | 由 Markdown 生成的文档,支持版本和搜索 | | [`alveby/atrium-backup`](../../packages/backup/README.md) | 数据库和文件的备份,可在后台恢复 | +| [`alveby/atrium-errors`](../../packages/errors/README.md) | 在站点数据库中跟踪错误,告警、Sentry | 0.1 上架 Packagist 后,现有的 Laravel 13 应用可以这样安装 Atrium: diff --git a/packages/admin/resources/js/Components/Admin/Dashboard/ErrorsGadget.vue b/packages/admin/resources/js/Components/Admin/Dashboard/ErrorsGadget.vue new file mode 100644 index 00000000..d1dc9660 --- /dev/null +++ b/packages/admin/resources/js/Components/Admin/Dashboard/ErrorsGadget.vue @@ -0,0 +1,53 @@ + + + diff --git a/packages/admin/resources/js/Components/Admin/UI/BarChart.vue b/packages/admin/resources/js/Components/Admin/UI/BarChart.vue new file mode 100644 index 00000000..afd71810 --- /dev/null +++ b/packages/admin/resources/js/Components/Admin/UI/BarChart.vue @@ -0,0 +1,70 @@ + + + diff --git a/packages/admin/resources/js/Pages/Admin/Dashboard.vue b/packages/admin/resources/js/Pages/Admin/Dashboard.vue index a6422835..346e7905 100644 --- a/packages/admin/resources/js/Pages/Admin/Dashboard.vue +++ b/packages/admin/resources/js/Pages/Admin/Dashboard.vue @@ -15,11 +15,13 @@ import AdminLayout from '@atrium/Layouts/AdminLayout.vue' import SiteSpeedGadget from '@atrium/Components/Admin/Dashboard/SiteSpeedGadget.vue' import PerformanceGadget from '@atrium/Components/Admin/Dashboard/PerformanceGadget.vue' import RecentElementsGadget from '@atrium/Components/Admin/Dashboard/RecentElementsGadget.vue' +import ErrorsGadget from '@atrium/Components/Admin/Dashboard/ErrorsGadget.vue' const COMPONENTS = { SiteSpeedGadget, PerformanceGadget, RecentElementsGadget, + ErrorsGadget, } const props = defineProps({ diff --git a/packages/admin/resources/js/Pages/Admin/Errors/Index.vue b/packages/admin/resources/js/Pages/Admin/Errors/Index.vue new file mode 100644 index 00000000..3a549b47 --- /dev/null +++ b/packages/admin/resources/js/Pages/Admin/Errors/Index.vue @@ -0,0 +1,160 @@ + + + diff --git a/packages/admin/resources/js/Pages/Admin/Errors/Show.vue b/packages/admin/resources/js/Pages/Admin/Errors/Show.vue new file mode 100644 index 00000000..1a78706e --- /dev/null +++ b/packages/admin/resources/js/Pages/Admin/Errors/Show.vue @@ -0,0 +1,277 @@ + + + diff --git a/packages/errors/LICENSE b/packages/errors/LICENSE new file mode 100644 index 00000000..27de5bfc --- /dev/null +++ b/packages/errors/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2026 AlveBy + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/packages/errors/README.md b/packages/errors/README.md new file mode 100644 index 00000000..32b3151b --- /dev/null +++ b/packages/errors/README.md @@ -0,0 +1,33 @@ +# Atrium Errors + +Error tracking for the [Atrium](https://github.com/AlveBy/atrium) admin, kept in the site's own database — a small Sentry inside the site: + +- PHP exceptions, failed queue jobs, failed scheduled tasks and JavaScript errors of visitors' browsers; +- grouped by class and place, so one bug is one line, with a status that comes back by itself when a fixed bug happens again; +- **Site health → Errors**: the list with filters, and each error with its trace and code, requests, a chart and every event; **Resolve in next release**; a dashboard tile; +- e-mail and Telegram alerts for new errors, errors that came back and spikes, throttled; +- secrets and personal data scrubbed before anything is stored; sampling, a per-minute cap, writing after the response, a fallback log, 90 days kept; +- the same events to Sentry or GlitchTip with only a DSN, to the log, or to your own driver (Bugsnag, Rollbar, a webhook) through one small interface. + +## Install + +```bash +composer require alveby/atrium-errors +php artisan atrium:module:install alveby/atrium-errors +php artisan atrium:errors:test +``` + +To send errors to Sentry or GlitchTip as well: + +```dotenv +ATRIUM_ERRORS_DRIVERS=database,sentry +ATRIUM_ERRORS_SENTRY_DSN=https://public-key@errors.example.com/7 +``` + +Seeing errors takes the `errors.view` right, changing the settings `errors.settings`. An administrator of some sites sees only their errors. + +Everything else — drivers, your own driver, alerts, the browser script, what is scrubbed, settings: [docs/errors.md](https://github.com/AlveBy/atrium/blob/main/docs/errors.md). + +## License + +MIT diff --git a/packages/errors/composer.json b/packages/errors/composer.json new file mode 100644 index 00000000..dba41cf2 --- /dev/null +++ b/packages/errors/composer.json @@ -0,0 +1,64 @@ +{ + "name": "alveby/atrium-errors", + "description": "Error tracking for Atrium: PHP, queue, schedule and browser errors grouped into issues in the site's own database, with Sentry, GlitchTip or any other service as an extra or a replacement", + "type": "atrium-module", + "license": "MIT", + "homepage": "https://github.com/AlveBy/atrium", + "support": { + "issues": "https://github.com/AlveBy/atrium/issues", + "source": "https://github.com/AlveBy/atrium" + }, + "keywords": [ + "laravel", + "admin", + "errors", + "exceptions", + "error-tracking", + "sentry", + "glitchtip", + "monitoring" + ], + "require": { + "php": "^8.3", + "illuminate/support": "^13.0", + "alveby/atrium": "^0.1" + }, + "require-dev": { + "orchestra/testbench": "^11.0", + "phpunit/phpunit": "^12.5" + }, + "suggest": { + "sentry/sentry-laravel": "The official Sentry SDK, for tracing and profiling on top of what the sentry driver sends", + "alveby/atrium-mail": "Sends the alert letters through the account picked for the \"errors\" purpose" + }, + "autoload": { + "psr-4": { + "Atrium\\Errors\\": "src/" + } + }, + "autoload-dev": { + "psr-4": { + "Atrium\\Errors\\Tests\\": "tests/" + } + }, + "extra": { + "atrium": { + "migrations": "database/migrations", + "settings": "Atrium\\Errors\\ErrorsSettings", + "permissions": { + "view": {"label": "atrium-errors::errors.permissions.view", "with": "errors.settings"} + }, + "title": "atrium-errors::errors.title" + }, + "laravel": { + "providers": [ + "Atrium\\Errors\\ErrorsServiceProvider" + ] + }, + "branch-alias": { + "dev-main": "0.1.x-dev" + } + }, + "minimum-stability": "dev", + "prefer-stable": true +} diff --git a/packages/errors/config/atrium-errors.php b/packages/errors/config/atrium-errors.php new file mode 100644 index 00000000..4aca3d16 --- /dev/null +++ b/packages/errors/config/atrium-errors.php @@ -0,0 +1,105 @@ + (bool) env('ATRIUM_ERRORS_ENABLED', true), + + /* + | Where an event goes, several at once: database (the admin screens), + | sentry (Sentry, GlitchTip or anything that speaks the Sentry protocol), + | log (a line in the application log). Your own drivers are added in + | `reporters` below and named here. + */ + 'drivers' => array_values(array_filter(explode(',', (string) env('ATRIUM_ERRORS_DRIVERS', 'database')))), + + // name => class implementing Atrium\Errors\Contracts\ErrorReporter. + 'reporters' => [ + // 'bugsnag' => App\Errors\BugsnagReporter::class, + ], + + 'sentry' => [ + 'dsn' => env('ATRIUM_ERRORS_SENTRY_DSN', env('SENTRY_LARAVEL_DSN', env('SENTRY_DSN'))), + 'timeout' => 3, + ], + + // The release events are grouped by. Empty: the git commit of the + // checkout, else the version Composer gives the application. + 'release' => env('ATRIUM_RELEASE'), + + // Percentage of events kept (1–100) and the hard cap per minute; what is + // above is dropped before any work is done. + 'sample_rate' => (int) env('ATRIUM_ERRORS_SAMPLE_RATE', 100), + 'per_minute' => (int) env('ATRIUM_ERRORS_PER_MINUTE', 60), + + // A queue connection to store events through. Empty: they are kept in + // memory and written after the response has gone to the visitor. + 'queue' => env('ATRIUM_ERRORS_QUEUE'), + + // Days an event is kept; issues without events go with them. + 'retention_days' => (int) env('ATRIUM_ERRORS_RETENTION_DAYS', 90), + + // When the database cannot be written to, the event goes here. + 'fallback_log' => storage_path('logs/atrium-errors.log'), + + // Recent queries and log lines kept with an event. + 'breadcrumbs' => 30, + + // Lines of code shown around each line of the trace. + 'context_lines' => 5, + + /* + | Exceptions never captured. The framework's own "don't report" list + | (validation, 404, authentication…) is respected anyway. + */ + 'ignore' => [ + // App\Exceptions\HarmlessException::class, + ], + + /* + | Extra key names whose values are never stored, on top of passwords, + | tokens, cookies, Authorization, cards, emails and phones. + */ + 'scrub_keys' => [], + + 'alerts' => [ + 'email' => env('ATRIUM_ERRORS_ALERT_EMAIL'), + 'telegram_token' => env('ATRIUM_ERRORS_TELEGRAM_TOKEN'), + 'telegram_chat' => env('ATRIUM_ERRORS_TELEGRAM_CHAT'), + 'new' => true, + 'regression' => true, + // An issue that gets this many events within an hour is a spike; + // 0 turns spike alerts off. + 'spike_per_hour' => 100, + // At most this many alerts in ten minutes, whatever happens. + 'max_per_10_minutes' => 10, + ], + + 'browser' => [ + // Catch JavaScript errors on the public site and in the admin. + 'site' => (bool) env('ATRIUM_ERRORS_BROWSER_SITE', false), + 'admin' => (bool) env('ATRIUM_ERRORS_BROWSER_ADMIN', false), + // Reports a visitor may send per minute. + 'per_minute' => 10, + // Largest accepted report, in bytes. + 'max_bytes' => 16384, + ], +]; diff --git a/packages/errors/database/migrations/2026_11_20_100001_create_error_tables.php b/packages/errors/database/migrations/2026_11_20_100001_create_error_tables.php new file mode 100644 index 00000000..41612cd6 --- /dev/null +++ b/packages/errors/database/migrations/2026_11_20_100001_create_error_tables.php @@ -0,0 +1,72 @@ +id(); + $table->char('fingerprint', 40)->unique(); + $table->string('kind', 16); + $table->string('level', 16)->index(); + $table->string('class'); + $table->text('message'); + $table->string('culprit')->nullable(); + $table->string('status', 16)->default('new')->index(); + // The release an issue was resolved in when it should only come + // back in a newer one ("resolve in next release"). + $table->string('resolved_in')->nullable(); + $table->unsignedInteger('times_seen')->default(0); + $table->unsignedInteger('users_seen')->default(0); + $table->string('first_release')->nullable(); + $table->string('last_release')->nullable()->index(); + $table->timestamp('first_seen_at')->nullable(); + $table->timestamp('last_seen_at')->nullable()->index(); + $table->timestamp('resolved_at')->nullable(); + $table->timestamp('regressed_at')->nullable(); + $table->timestamps(); + }); + + Schema::create('error_events', function (Blueprint $table): void { + $table->id(); + $table->foreignId('issue_id')->index(); + $table->foreignId('site_id')->nullable()->index(); + $table->string('level', 16); + $table->string('release')->nullable()->index(); + $table->string('environment', 32)->nullable(); + $table->string('method', 8)->nullable(); + $table->string('path', 512)->nullable(); + $table->string('route')->nullable(); + $table->string('locale', 16)->nullable(); + $table->unsignedBigInteger('user_id')->nullable(); + // Text, not JSON: MySQL reorders the keys of a JSON column, and the + // event is shown as it was captured. It is never searched inside. + $table->longText('payload'); + $table->timestamp('created_at')->nullable()->index(); + + $table->index(['issue_id', 'created_at']); + $table->index(['issue_id', 'user_id']); + }); + } + + public function down(): void + { + Schema::dropIfExists('error_events'); + Schema::dropIfExists('error_issues'); + } +}; diff --git a/packages/errors/lang/be/errors.php b/packages/errors/lang/be/errors.php new file mode 100644 index 00000000..c96ef00d --- /dev/null +++ b/packages/errors/lang/be/errors.php @@ -0,0 +1,183 @@ + 'Памылкі', + 'health' => 'Стан сайта', + 'subtitle' => 'Памылкі сайта і яго старонак, адзін радок на адну паломку', + + 'statuses' => [ + 'new' => 'Не вырашаны', + 'resolved' => 'Вырашаны', + 'ignored' => 'Схаваны', + 'all' => 'Усе', + ], + + 'levels' => [ + 'fatal' => 'Фатальная', + 'error' => 'Памылка', + 'warning' => 'Папярэджанне', + 'info' => 'Звесткі', + ], + + 'kinds' => [ + 'php' => 'PHP', + 'job' => 'Задача чаргі', + 'schedule' => 'Задача па раскладзе', + 'browser' => 'Браўзер', + 'message' => 'Паведамленне', + ], + + 'drivers' => [ + 'database' => 'База сайта (экраны адмінкі)', + 'sentry' => 'Sentry або GlitchTip', + 'log' => 'Журнал праграмы', + ], + + 'list' => [ + 'search' => 'Пошук па класе, тэксце або месцы', + 'site' => 'Сайт', + 'all_sites' => 'Усе сайты', + 'level' => 'Узровень', + 'any_level' => 'Любы ўзровень', + 'kind' => 'Крыніца', + 'any_kind' => 'Любая крыніца', + 'status' => 'Статус', + 'release' => 'Рэліз', + 'any_release' => 'Любы рэліз', + 'path' => 'Адрас', + 'path_placeholder' => '/catalog', + 'sort' => 'Парадак', + 'sorts' => [ + 'last_seen_at' => 'Спачатку свежыя', + 'first_seen_at' => 'Спачатку новыя', + 'times_seen' => 'Больш за ўсё падзей', + 'users_seen' => 'Больш за ўсё людзей', + ], + 'filter' => 'Паказаць', + 'reset' => 'Скінуць', + 'empty' => 'Памылак няма. Добрая навіна.', + 'issue' => 'Памылка', + 'events' => 'Падзеі', + 'users' => 'Людзі', + 'last_seen' => 'Апошні раз', + 'first_seen' => 'Упершыню', + ], + + 'issue' => [ + 'back' => 'Усе памылкі', + 'resolve' => 'Вырашана', + 'resolve_next' => 'Вырашана ў наступным рэлізе', + 'resolve_next_hint' => 'Памылка вернецца, толькі калі паўторыцца ў рэлізе навейшым за :release.', + 'ignore' => 'Схаваць', + 'reopen' => 'Адкрыць зноў', + 'trace' => 'Стэк выклікаў', + 'caused_by' => 'Прычына', + 'all_frames' => 'Паказаць выклікі фрэймворка', + 'app_frames' => 'Схаваць выклікі фрэймворка', + 'request' => 'Запыт', + 'context' => 'Кантэкст', + 'breadcrumbs' => 'Перад памылкай', + 'environment' => 'Асяроддзе', + 'occurrences' => 'Выпадкі', + 'frequency' => 'Частата', + 'last_24h' => '24 гадзіны', + 'last_30d' => '30 дзён', + 'top_paths' => 'Адрасы', + 'top_releases' => 'Рэлізы', + 'first_release' => 'Першы рэліз', + 'last_release' => 'Апошні рэліз', + 'resolved_in' => 'Вырашана ў рэлізе :release', + 'regressed' => 'Вярнулася', + 'no_event' => 'Выпадкаў гэтай памылкі больш не захоўваецца: яны старэйшыя за тэрмін захоўвання.', + 'open' => 'Адкрыць', + 'shown' => 'Паказана', + 'time' => 'Час', + 'user' => 'Карыстальнік', + 'method' => 'Метад', + 'url' => 'Адрас', + 'route' => 'Маршрут', + 'site' => 'Сайт', + 'locale' => 'Мова', + 'release' => 'Рэліз', + 'php' => 'PHP', + 'laravel' => 'Laravel', + 'none' => '—', + ], + + 'status_saved' => [ + 'new' => 'Памылка зноў адкрыта.', + 'resolved' => 'Памылка пазначана вырашанай.', + 'ignored' => 'Памылка схавана.', + ], + + 'gadget' => [ + 'title' => 'Памылкі за суткі', + 'events' => 'падзей', + 'new' => 'новых', + 'regressed' => 'вярнуліся', + 'unresolved' => 'не вырашана', + 'none' => 'За апошнія суткі памылак не было.', + 'top' => 'Часцей за ўсё', + 'all' => 'Усе памылкі', + 'chart' => 'Падзеі па гадзінах', + ], + + 'permissions' => [ + 'view' => 'Прагляд памылак', + ], + + 'settings' => [ + 'description' => 'Куды складаць і адпраўляць памылкі, колькі і каго паведамляць. Пустое поле бярэ значэнне з config/atrium-errors.php або .env — сакрэты лепш трымаць там.', + 'drivers' => 'Адпраўляць памылкі', + 'drivers_hint' => 'Можна ў некалькі месцаў адразу. Экранам адмінкі і апавяшчэнням патрэбная база сайта.', + 'sentry_dsn' => 'DSN Sentry', + 'sentry_dsn_hint' => 'З Sentry, GlitchTip або іншага сервісу, сумяшчальнага з Sentry: https://ключ@хост/праект. Лепш у .env як ATRIUM_ERRORS_SENTRY_DSN.', + 'sample_rate' => 'Захоўваць, %', + 'sample_rate_hint' => 'Доля падзей, якія захоўваюцца, ад 1 да 100.', + 'per_minute' => 'Не больш за хвіліну', + 'per_minute_hint' => 'Падзеі звыш гэтага ліку за хвіліну адкідаюцца. 0 — без абмежавання.', + 'retention_days' => 'Захоўваць падзеі, дзён', + 'alert_email' => 'Пошта для апавяшчэнняў', + 'alert_email_hint' => 'Адрасы праз коску.', + 'telegram_token' => 'Токен бота Telegram', + 'telegram_token_hint' => 'Выдае @BotFather. Лепш у .env як ATRIUM_ERRORS_TELEGRAM_TOKEN.', + 'telegram_chat' => 'ID чата Telegram', + 'alert_new' => 'Паведамляць пра новую памылку', + 'alert_regression' => 'Паведамляць, калі вырашаная памылка вярнулася', + 'spike_per_hour' => 'Усплёск: падзей адной памылкі за гадзіну', + 'spike_per_hour_hint' => 'Калі за гадзіну больш — прыйдзе апавяшчэнне. 0 — выключана.', + 'browser_site' => 'Лавіць памылкі JavaScript на сайце', + 'browser_admin' => 'Лавіць памылкі JavaScript у адмінцы', + ], + + 'alerts' => [ + 'purpose' => 'Апавяшчэнні пра памылкі', + 'subject' => [ + 'new' => 'Новая памылка на :site: :class', + 'regression' => 'Памылка вярнулася на :site: :class', + 'spike' => 'Усплёск памылкі на :site: :class', + ], + 'where' => 'Дзе: :place', + 'counts' => 'Падзей: :events, людзей: :users', + 'release' => 'Рэліз: :release', + ], + + 'prune' => [ + 'invalid' => 'Колькасць дзён павінна быць не менш за 1.', + 'done' => 'Выдалена падзей: :events, памылак: :issues — усё старэйшае за :days дн.', + ], + + 'test' => [ + 'no_drivers' => 'Не ўключана ніводнага спосабу адпраўкі памылак.', + 'message' => 'Atrium errors: праверачная памылка, яе можна пазначыць вырашанай', + 'skipped' => 'Не адпраўлена: збор выключаны або падзею адсеклі выбарка ці ліміт за хвіліну.', + 'sent' => 'Праверачная памылка :id адпраўлена: :drivers.', + ], +]; diff --git a/packages/errors/lang/de/errors.php b/packages/errors/lang/de/errors.php new file mode 100644 index 00000000..4e541ab4 --- /dev/null +++ b/packages/errors/lang/de/errors.php @@ -0,0 +1,183 @@ + 'Fehler', + 'health' => 'Website-Zustand', + 'subtitle' => 'Fehler der Website und ihrer Seiten, eine Zeile pro Problem', + + 'statuses' => [ + 'new' => 'Ungelöst', + 'resolved' => 'Gelöst', + 'ignored' => 'Ignoriert', + 'all' => 'Alle', + ], + + 'levels' => [ + 'fatal' => 'Fatal', + 'error' => 'Fehler', + 'warning' => 'Warnung', + 'info' => 'Info', + ], + + 'kinds' => [ + 'php' => 'PHP', + 'job' => 'Queue-Job', + 'schedule' => 'Geplante Aufgabe', + 'browser' => 'Browser', + 'message' => 'Meldung', + ], + + 'drivers' => [ + 'database' => 'Website-Datenbank (die Admin-Ansichten)', + 'sentry' => 'Sentry oder GlitchTip', + 'log' => 'Anwendungslog', + ], + + 'list' => [ + 'search' => 'Suche nach Klasse, Meldung oder Ort', + 'site' => 'Website', + 'all_sites' => 'Alle Websites', + 'level' => 'Level', + 'any_level' => 'Beliebiges Level', + 'kind' => 'Quelle', + 'any_kind' => 'Beliebige Quelle', + 'status' => 'Status', + 'release' => 'Release', + 'any_release' => 'Beliebiges Release', + 'path' => 'Adresse', + 'path_placeholder' => '/catalog', + 'sort' => 'Sortierung', + 'sorts' => [ + 'last_seen_at' => 'Zuletzt gesehen', + 'first_seen_at' => 'Zuerst gesehen', + 'times_seen' => 'Meiste Ereignisse', + 'users_seen' => 'Meiste Nutzer', + ], + 'filter' => 'Anzeigen', + 'reset' => 'Zurücksetzen', + 'empty' => 'Keine Fehler hier. Gute Nachrichten.', + 'issue' => 'Fehler', + 'events' => 'Ereignisse', + 'users' => 'Nutzer', + 'last_seen' => 'Zuletzt gesehen', + 'first_seen' => 'Zuerst gesehen', + ], + + 'issue' => [ + 'back' => 'Alle Fehler', + 'resolve' => 'Lösen', + 'resolve_next' => 'Im nächsten Release lösen', + 'resolve_next_hint' => 'Er kommt nur zurück, wenn er in einem Release nach :release auftritt.', + 'ignore' => 'Ignorieren', + 'reopen' => 'Wieder öffnen', + 'trace' => 'Stacktrace', + 'caused_by' => 'Verursacht durch', + 'all_frames' => 'Framework-Frames anzeigen', + 'app_frames' => 'Framework-Frames ausblenden', + 'request' => 'Anfrage', + 'context' => 'Kontext', + 'breadcrumbs' => 'Vor dem Fehler', + 'environment' => 'Umgebung', + 'occurrences' => 'Vorkommen', + 'frequency' => 'Häufigkeit', + 'last_24h' => '24 Stunden', + 'last_30d' => '30 Tage', + 'top_paths' => 'Adressen', + 'top_releases' => 'Releases', + 'first_release' => 'Erstes Release', + 'last_release' => 'Letztes Release', + 'resolved_in' => 'Gelöst in Release :release', + 'regressed' => 'Wieder aufgetreten', + 'no_event' => 'Für diesen Fehler werden keine Ereignisse mehr gespeichert: Sie sind älter als die Aufbewahrungsdauer.', + 'open' => 'Öffnen', + 'shown' => 'Angezeigt', + 'time' => 'Zeit', + 'user' => 'Nutzer', + 'method' => 'Methode', + 'url' => 'Adresse', + 'route' => 'Route', + 'site' => 'Website', + 'locale' => 'Sprache', + 'release' => 'Release', + 'php' => 'PHP', + 'laravel' => 'Laravel', + 'none' => '—', + ], + + 'status_saved' => [ + 'new' => 'Der Fehler ist wieder offen.', + 'resolved' => 'Der Fehler ist gelöst.', + 'ignored' => 'Der Fehler wird ignoriert.', + ], + + 'gadget' => [ + 'title' => 'Fehler in 24 Stunden', + 'events' => 'Ereignisse', + 'new' => 'neu', + 'regressed' => 'wieder aufgetreten', + 'unresolved' => 'ungelöst', + 'none' => 'Keine Fehler in den letzten 24 Stunden.', + 'top' => 'Am lautesten', + 'all' => 'Alle Fehler', + 'chart' => 'Ereignisse pro Stunde', + ], + + 'permissions' => [ + 'view' => 'Fehler ansehen', + ], + + 'settings' => [ + 'description' => 'Wo Fehler gespeichert und hingeschickt werden, wie viele und wer benachrichtigt wird. Ein leeres Feld übernimmt den Wert aus config/atrium-errors.php oder .env; Geheimnisse gehören dorthin.', + 'drivers' => 'Fehler senden an', + 'drivers_hint' => 'Mehrere gleichzeitig. Die Admin-Ansichten und Benachrichtigungen brauchen die Website-Datenbank.', + 'sentry_dsn' => 'Sentry-DSN', + 'sentry_dsn_hint' => 'Von Sentry, GlitchTip oder einem anderen Sentry-kompatiblen Dienst: https://schlüssel@host/projekt. Besser in .env als ATRIUM_ERRORS_SENTRY_DSN.', + 'sample_rate' => 'Behalten, %', + 'sample_rate_hint' => 'Anteil der behaltenen Ereignisse, 1 bis 100.', + 'per_minute' => 'Höchstens pro Minute', + 'per_minute_hint' => 'Ereignisse darüber hinaus werden innerhalb einer Minute verworfen. 0: keine Grenze.', + 'retention_days' => 'Ereignisse behalten, Tage', + 'alert_email' => 'Benachrichtigungs-E-Mails', + 'alert_email_hint' => 'Adressen, durch Kommas getrennt.', + 'telegram_token' => 'Telegram-Bot-Token', + 'telegram_token_hint' => 'Von @BotFather. Besser in .env als ATRIUM_ERRORS_TELEGRAM_TOKEN.', + 'telegram_chat' => 'Telegram-Chat-ID', + 'alert_new' => 'Bei neuem Fehler benachrichtigen', + 'alert_regression' => 'Benachrichtigen, wenn ein gelöster Fehler wiederkommt', + 'spike_per_hour' => 'Spitze: Ereignisse eines Fehlers pro Stunde', + 'spike_per_hour_hint' => 'Mehr als das in einer Stunde löst eine Benachrichtigung aus. 0: aus.', + 'browser_site' => 'JavaScript-Fehler auf der Website erfassen', + 'browser_admin' => 'JavaScript-Fehler im Adminbereich erfassen', + ], + + 'alerts' => [ + 'purpose' => 'Fehlerbenachrichtigungen', + 'subject' => [ + 'new' => 'Neuer Fehler auf :site: :class', + 'regression' => 'Fehler wieder aufgetreten auf :site: :class', + 'spike' => 'Fehlerspitze auf :site: :class', + ], + 'where' => 'Ort: :place', + 'counts' => 'Ereignisse: :events, Nutzer: :users', + 'release' => 'Release: :release', + ], + + 'prune' => [ + 'invalid' => 'Die Anzahl der Tage muss mindestens 1 betragen.', + 'done' => ':events Ereignisse und :issues Fehler gelöscht, die älter als :days Tage sind.', + ], + + 'test' => [ + 'no_drivers' => 'Kein Fehlertreiber ist eingeschaltet.', + 'message' => 'Atrium errors: ein Testfehler, kann bedenkenlos gelöst werden', + 'skipped' => 'Nicht gesendet: Die Erfassung ist aus oder Sampling bzw. das Limit pro Minute hat ihn verworfen.', + 'sent' => 'Testfehler :id gesendet an: :drivers.', + ], +]; diff --git a/packages/errors/lang/en/errors.php b/packages/errors/lang/en/errors.php new file mode 100644 index 00000000..037ccc41 --- /dev/null +++ b/packages/errors/lang/en/errors.php @@ -0,0 +1,183 @@ + 'Errors', + 'health' => 'Site health', + 'subtitle' => 'Errors of the site and its pages, one line per bug', + + 'statuses' => [ + 'new' => 'Unresolved', + 'resolved' => 'Resolved', + 'ignored' => 'Ignored', + 'all' => 'All', + ], + + 'levels' => [ + 'fatal' => 'Fatal', + 'error' => 'Error', + 'warning' => 'Warning', + 'info' => 'Info', + ], + + 'kinds' => [ + 'php' => 'PHP', + 'job' => 'Queue job', + 'schedule' => 'Scheduled task', + 'browser' => 'Browser', + 'message' => 'Message', + ], + + 'drivers' => [ + 'database' => 'Site database (the admin screens)', + 'sentry' => 'Sentry or GlitchTip', + 'log' => 'Application log', + ], + + 'list' => [ + 'search' => 'Search by class, message or place', + 'site' => 'Site', + 'all_sites' => 'All sites', + 'level' => 'Level', + 'any_level' => 'Any level', + 'kind' => 'Source', + 'any_kind' => 'Any source', + 'status' => 'Status', + 'release' => 'Release', + 'any_release' => 'Any release', + 'path' => 'Address', + 'path_placeholder' => '/catalog', + 'sort' => 'Sort', + 'sorts' => [ + 'last_seen_at' => 'Last seen', + 'first_seen_at' => 'First seen', + 'times_seen' => 'Most events', + 'users_seen' => 'Most users', + ], + 'filter' => 'Show', + 'reset' => 'Reset', + 'empty' => 'No errors here. Good news.', + 'issue' => 'Error', + 'events' => 'Events', + 'users' => 'Users', + 'last_seen' => 'Last seen', + 'first_seen' => 'First seen', + ], + + 'issue' => [ + 'back' => 'All errors', + 'resolve' => 'Resolve', + 'resolve_next' => 'Resolve in next release', + 'resolve_next_hint' => 'It comes back only if it happens in a release after :release.', + 'ignore' => 'Ignore', + 'reopen' => 'Reopen', + 'trace' => 'Stack trace', + 'caused_by' => 'Caused by', + 'all_frames' => 'Show framework frames', + 'app_frames' => 'Hide framework frames', + 'request' => 'Request', + 'context' => 'Context', + 'breadcrumbs' => 'Before the error', + 'environment' => 'Environment', + 'occurrences' => 'Occurrences', + 'frequency' => 'Frequency', + 'last_24h' => '24 hours', + 'last_30d' => '30 days', + 'top_paths' => 'Addresses', + 'top_releases' => 'Releases', + 'first_release' => 'First release', + 'last_release' => 'Last release', + 'resolved_in' => 'Resolved in release :release', + 'regressed' => 'Came back', + 'no_event' => 'No events are kept for this error any more: they are older than the retention period.', + 'open' => 'Open', + 'shown' => 'Shown', + 'time' => 'Time', + 'user' => 'User', + 'method' => 'Method', + 'url' => 'Address', + 'route' => 'Route', + 'site' => 'Site', + 'locale' => 'Language', + 'release' => 'Release', + 'php' => 'PHP', + 'laravel' => 'Laravel', + 'none' => '—', + ], + + 'status_saved' => [ + 'new' => 'The error is open again.', + 'resolved' => 'The error is resolved.', + 'ignored' => 'The error is ignored.', + ], + + 'gadget' => [ + 'title' => 'Errors in 24 hours', + 'events' => 'events', + 'new' => 'new', + 'regressed' => 'came back', + 'unresolved' => 'unresolved', + 'none' => 'No errors in the last 24 hours.', + 'top' => 'Noisiest', + 'all' => 'All errors', + 'chart' => 'Events per hour', + ], + + 'permissions' => [ + 'view' => 'View errors', + ], + + 'settings' => [ + 'description' => 'Where errors are stored and sent, how many, and who is told. An empty field takes the value from config/atrium-errors.php or .env; keep secrets there.', + 'drivers' => 'Send errors to', + 'drivers_hint' => 'Several at once. The admin screens and alerts need the site database.', + 'sentry_dsn' => 'Sentry DSN', + 'sentry_dsn_hint' => 'From Sentry, GlitchTip or another Sentry-compatible service: https://key@host/project. Better in .env as ATRIUM_ERRORS_SENTRY_DSN.', + 'sample_rate' => 'Keep, %', + 'sample_rate_hint' => 'Share of events kept, 1 to 100.', + 'per_minute' => 'At most per minute', + 'per_minute_hint' => 'Events above this in one minute are dropped. 0: no limit.', + 'retention_days' => 'Keep events, days', + 'alert_email' => 'Alert emails', + 'alert_email_hint' => 'Addresses separated by commas.', + 'telegram_token' => 'Telegram bot token', + 'telegram_token_hint' => 'From @BotFather. Better in .env as ATRIUM_ERRORS_TELEGRAM_TOKEN.', + 'telegram_chat' => 'Telegram chat id', + 'alert_new' => 'Alert on a new error', + 'alert_regression' => 'Alert when a resolved error comes back', + 'spike_per_hour' => 'Spike: events of one error per hour', + 'spike_per_hour_hint' => 'More than this in an hour sends an alert. 0: off.', + 'browser_site' => 'Catch JavaScript errors on the site', + 'browser_admin' => 'Catch JavaScript errors in the admin', + ], + + 'alerts' => [ + 'purpose' => 'Error alerts', + 'subject' => [ + 'new' => 'New error on :site: :class', + 'regression' => 'An error came back on :site: :class', + 'spike' => 'Error spike on :site: :class', + ], + 'where' => 'Where: :place', + 'counts' => 'Events: :events, users: :users', + 'release' => 'Release: :release', + ], + + 'prune' => [ + 'invalid' => 'The number of days must be 1 or more.', + 'done' => 'Deleted :events events and :issues errors older than :days days.', + ], + + 'test' => [ + 'no_drivers' => 'No error driver is switched on.', + 'message' => 'Atrium errors: a test error, safe to resolve', + 'skipped' => 'Not sent: tracking is off, or sampling or the per-minute cap dropped it.', + 'sent' => 'Test error :id sent to: :drivers.', + ], +]; diff --git a/packages/errors/lang/es/errors.php b/packages/errors/lang/es/errors.php new file mode 100644 index 00000000..1102d7b9 --- /dev/null +++ b/packages/errors/lang/es/errors.php @@ -0,0 +1,183 @@ + 'Errores', + 'health' => 'Estado del sitio', + 'subtitle' => 'Errores del sitio y sus páginas, una línea por fallo', + + 'statuses' => [ + 'new' => 'Sin resolver', + 'resolved' => 'Resueltos', + 'ignored' => 'Ignorados', + 'all' => 'Todos', + ], + + 'levels' => [ + 'fatal' => 'Fatal', + 'error' => 'Error', + 'warning' => 'Advertencia', + 'info' => 'Info', + ], + + 'kinds' => [ + 'php' => 'PHP', + 'job' => 'Tarea en cola', + 'schedule' => 'Tarea programada', + 'browser' => 'Navegador', + 'message' => 'Mensaje', + ], + + 'drivers' => [ + 'database' => 'Base de datos del sitio (las pantallas del administrador)', + 'sentry' => 'Sentry o GlitchTip', + 'log' => 'Registro de la aplicación', + ], + + 'list' => [ + 'search' => 'Buscar por clase, mensaje o lugar', + 'site' => 'Sitio', + 'all_sites' => 'Todos los sitios', + 'level' => 'Nivel', + 'any_level' => 'Cualquier nivel', + 'kind' => 'Origen', + 'any_kind' => 'Cualquier origen', + 'status' => 'Estado', + 'release' => 'Versión', + 'any_release' => 'Cualquier versión', + 'path' => 'Dirección', + 'path_placeholder' => '/catalog', + 'sort' => 'Orden', + 'sorts' => [ + 'last_seen_at' => 'Visto por última vez', + 'first_seen_at' => 'Visto por primera vez', + 'times_seen' => 'Más eventos', + 'users_seen' => 'Más usuarios', + ], + 'filter' => 'Mostrar', + 'reset' => 'Restablecer', + 'empty' => 'No hay errores. Buenas noticias.', + 'issue' => 'Error', + 'events' => 'Eventos', + 'users' => 'Usuarios', + 'last_seen' => 'Visto por última vez', + 'first_seen' => 'Visto por primera vez', + ], + + 'issue' => [ + 'back' => 'Todos los errores', + 'resolve' => 'Resolver', + 'resolve_next' => 'Resolver en la próxima versión', + 'resolve_next_hint' => 'Solo vuelve a aparecer si ocurre en una versión posterior a :release.', + 'ignore' => 'Ignorar', + 'reopen' => 'Reabrir', + 'trace' => 'Traza de pila', + 'caused_by' => 'Causado por', + 'all_frames' => 'Mostrar llamadas del framework', + 'app_frames' => 'Ocultar llamadas del framework', + 'request' => 'Solicitud', + 'context' => 'Contexto', + 'breadcrumbs' => 'Antes del error', + 'environment' => 'Entorno', + 'occurrences' => 'Ocurrencias', + 'frequency' => 'Frecuencia', + 'last_24h' => '24 horas', + 'last_30d' => '30 días', + 'top_paths' => 'Direcciones', + 'top_releases' => 'Versiones', + 'first_release' => 'Primera versión', + 'last_release' => 'Última versión', + 'resolved_in' => 'Resuelto en la versión :release', + 'regressed' => 'Reapareció', + 'no_event' => 'Ya no se conservan eventos de este error: son más antiguos que el período de retención.', + 'open' => 'Abrir', + 'shown' => 'Mostrado', + 'time' => 'Hora', + 'user' => 'Usuario', + 'method' => 'Método', + 'url' => 'Dirección', + 'route' => 'Ruta', + 'site' => 'Sitio', + 'locale' => 'Idioma', + 'release' => 'Versión', + 'php' => 'PHP', + 'laravel' => 'Laravel', + 'none' => '—', + ], + + 'status_saved' => [ + 'new' => 'El error se ha vuelto a abrir.', + 'resolved' => 'El error está resuelto.', + 'ignored' => 'El error se ignora.', + ], + + 'gadget' => [ + 'title' => 'Errores en 24 horas', + 'events' => 'eventos', + 'new' => 'nuevos', + 'regressed' => 'reaparecieron', + 'unresolved' => 'sin resolver', + 'none' => 'No hay errores en las últimas 24 horas.', + 'top' => 'Los más ruidosos', + 'all' => 'Todos los errores', + 'chart' => 'Eventos por hora', + ], + + 'permissions' => [ + 'view' => 'Ver errores', + ], + + 'settings' => [ + 'description' => 'Dónde se guardan y se envían los errores, cuántos y a quién se avisa. Un campo vacío toma el valor de config/atrium-errors.php o .env; guarda allí los secretos.', + 'drivers' => 'Enviar errores a', + 'drivers_hint' => 'Varios a la vez. Las pantallas del administrador y las alertas necesitan la base de datos del sitio.', + 'sentry_dsn' => 'DSN de Sentry', + 'sentry_dsn_hint' => 'De Sentry, GlitchTip u otro servicio compatible con Sentry: https://clave@host/proyecto. Mejor en .env como ATRIUM_ERRORS_SENTRY_DSN.', + 'sample_rate' => 'Conservar, %', + 'sample_rate_hint' => 'Porcentaje de eventos conservados, de 1 a 100.', + 'per_minute' => 'Máximo por minuto', + 'per_minute_hint' => 'Los eventos por encima de esta cifra en un minuto se descartan. 0: sin límite.', + 'retention_days' => 'Conservar eventos, días', + 'alert_email' => 'Correos de alerta', + 'alert_email_hint' => 'Direcciones separadas por comas.', + 'telegram_token' => 'Token del bot de Telegram', + 'telegram_token_hint' => 'Lo da @BotFather. Mejor en .env como ATRIUM_ERRORS_TELEGRAM_TOKEN.', + 'telegram_chat' => 'ID del chat de Telegram', + 'alert_new' => 'Avisar de un error nuevo', + 'alert_regression' => 'Avisar cuando un error resuelto vuelve a aparecer', + 'spike_per_hour' => 'Pico: eventos de un error por hora', + 'spike_per_hour_hint' => 'Si se supera en una hora, se envía una alerta. 0: desactivado.', + 'browser_site' => 'Capturar errores de JavaScript en el sitio', + 'browser_admin' => 'Capturar errores de JavaScript en el administrador', + ], + + 'alerts' => [ + 'purpose' => 'Alertas de errores', + 'subject' => [ + 'new' => 'Error nuevo en :site: :class', + 'regression' => 'Un error ha reaparecido en :site: :class', + 'spike' => 'Pico de errores en :site: :class', + ], + 'where' => 'Dónde: :place', + 'counts' => 'Eventos: :events, usuarios: :users', + 'release' => 'Versión: :release', + ], + + 'prune' => [ + 'invalid' => 'El número de días debe ser 1 o más.', + 'done' => 'Se eliminaron :events eventos y :issues errores con más de :days días.', + ], + + 'test' => [ + 'no_drivers' => 'No hay ningún controlador de errores activado.', + 'message' => 'Atrium errors: un error de prueba, se puede resolver sin problema', + 'skipped' => 'No enviado: el seguimiento está desactivado, o el muestreo o el límite por minuto lo descartó.', + 'sent' => 'Error de prueba :id enviado a: :drivers.', + ], +]; diff --git a/packages/errors/lang/fr/errors.php b/packages/errors/lang/fr/errors.php new file mode 100644 index 00000000..baf6cc16 --- /dev/null +++ b/packages/errors/lang/fr/errors.php @@ -0,0 +1,183 @@ + 'Erreurs', + 'health' => 'État du site', + 'subtitle' => 'Les erreurs du site et de ses pages, une ligne par bug', + + 'statuses' => [ + 'new' => 'Non résolues', + 'resolved' => 'Résolues', + 'ignored' => 'Ignorées', + 'all' => 'Toutes', + ], + + 'levels' => [ + 'fatal' => 'Fatale', + 'error' => 'Erreur', + 'warning' => 'Avertissement', + 'info' => 'Info', + ], + + 'kinds' => [ + 'php' => 'PHP', + 'job' => 'Tâche de file d\'attente', + 'schedule' => 'Tâche planifiée', + 'browser' => 'Navigateur', + 'message' => 'Message', + ], + + 'drivers' => [ + 'database' => 'Base de données du site (les écrans d\'administration)', + 'sentry' => 'Sentry ou GlitchTip', + 'log' => 'Journal de l\'application', + ], + + 'list' => [ + 'search' => 'Rechercher par classe, message ou lieu', + 'site' => 'Site', + 'all_sites' => 'Tous les sites', + 'level' => 'Niveau', + 'any_level' => 'Tous les niveaux', + 'kind' => 'Source', + 'any_kind' => 'Toutes les sources', + 'status' => 'Statut', + 'release' => 'Version', + 'any_release' => 'Toutes les versions', + 'path' => 'Adresse', + 'path_placeholder' => '/catalog', + 'sort' => 'Tri', + 'sorts' => [ + 'last_seen_at' => 'Dernière apparition', + 'first_seen_at' => 'Première apparition', + 'times_seen' => 'Plus d\'événements', + 'users_seen' => 'Plus d\'utilisateurs', + ], + 'filter' => 'Afficher', + 'reset' => 'Réinitialiser', + 'empty' => 'Aucune erreur ici. Bonne nouvelle.', + 'issue' => 'Erreur', + 'events' => 'Événements', + 'users' => 'Utilisateurs', + 'last_seen' => 'Dernière apparition', + 'first_seen' => 'Première apparition', + ], + + 'issue' => [ + 'back' => 'Toutes les erreurs', + 'resolve' => 'Résoudre', + 'resolve_next' => 'Résoudre dans la prochaine version', + 'resolve_next_hint' => 'Elle ne revient que si elle se produit dans une version postérieure à :release.', + 'ignore' => 'Ignorer', + 'reopen' => 'Rouvrir', + 'trace' => 'Pile d\'appels', + 'caused_by' => 'Causée par', + 'all_frames' => 'Afficher les appels du framework', + 'app_frames' => 'Masquer les appels du framework', + 'request' => 'Requête', + 'context' => 'Contexte', + 'breadcrumbs' => 'Avant l\'erreur', + 'environment' => 'Environnement', + 'occurrences' => 'Occurrences', + 'frequency' => 'Fréquence', + 'last_24h' => '24 heures', + 'last_30d' => '30 jours', + 'top_paths' => 'Adresses', + 'top_releases' => 'Versions', + 'first_release' => 'Première version', + 'last_release' => 'Dernière version', + 'resolved_in' => 'Résolue dans la version :release', + 'regressed' => 'Réapparue', + 'no_event' => 'Aucun événement n\'est conservé pour cette erreur : ils dépassent la durée de conservation.', + 'open' => 'Ouvrir', + 'shown' => 'Affichée', + 'time' => 'Heure', + 'user' => 'Utilisateur', + 'method' => 'Méthode', + 'url' => 'Adresse', + 'route' => 'Route', + 'site' => 'Site', + 'locale' => 'Langue', + 'release' => 'Version', + 'php' => 'PHP', + 'laravel' => 'Laravel', + 'none' => '—', + ], + + 'status_saved' => [ + 'new' => 'L\'erreur est de nouveau ouverte.', + 'resolved' => 'L\'erreur est résolue.', + 'ignored' => 'L\'erreur est ignorée.', + ], + + 'gadget' => [ + 'title' => 'Erreurs sur 24 heures', + 'events' => 'événements', + 'new' => 'nouvelles', + 'regressed' => 'réapparues', + 'unresolved' => 'non résolues', + 'none' => 'Aucune erreur ces dernières 24 heures.', + 'top' => 'Les plus bruyantes', + 'all' => 'Toutes les erreurs', + 'chart' => 'Événements par heure', + ], + + 'permissions' => [ + 'view' => 'Voir les erreurs', + ], + + 'settings' => [ + 'description' => 'Où les erreurs sont stockées et envoyées, en quelle quantité, et qui est prévenu. Un champ vide prend la valeur de config/atrium-errors.php ou .env ; gardez-y les secrets.', + 'drivers' => 'Envoyer les erreurs vers', + 'drivers_hint' => 'Plusieurs à la fois. Les écrans d\'administration et les alertes ont besoin de la base de données du site.', + 'sentry_dsn' => 'DSN Sentry', + 'sentry_dsn_hint' => 'Fourni par Sentry, GlitchTip ou un autre service compatible Sentry : https://clé@hôte/projet. Mieux dans .env sous ATRIUM_ERRORS_SENTRY_DSN.', + 'sample_rate' => 'Conserver, %', + 'sample_rate_hint' => 'Part des événements conservés, de 1 à 100.', + 'per_minute' => 'Maximum par minute', + 'per_minute_hint' => 'Les événements au-delà de ce seuil en une minute sont ignorés. 0 : aucune limite.', + 'retention_days' => 'Conserver les événements, jours', + 'alert_email' => 'E-mails d\'alerte', + 'alert_email_hint' => 'Adresses séparées par des virgules.', + 'telegram_token' => 'Jeton du bot Telegram', + 'telegram_token_hint' => 'Fourni par @BotFather. Mieux dans .env sous ATRIUM_ERRORS_TELEGRAM_TOKEN.', + 'telegram_chat' => 'ID du chat Telegram', + 'alert_new' => 'Alerter pour une nouvelle erreur', + 'alert_regression' => 'Alerter quand une erreur résolue réapparaît', + 'spike_per_hour' => 'Pic : événements d\'une erreur par heure', + 'spike_per_hour_hint' => 'Au-delà de ce nombre en une heure, une alerte est envoyée. 0 : désactivé.', + 'browser_site' => 'Capturer les erreurs JavaScript sur le site', + 'browser_admin' => 'Capturer les erreurs JavaScript dans l\'administration', + ], + + 'alerts' => [ + 'purpose' => 'Alertes d\'erreurs', + 'subject' => [ + 'new' => 'Nouvelle erreur sur :site : :class', + 'regression' => 'Une erreur est réapparue sur :site : :class', + 'spike' => 'Pic d\'erreurs sur :site : :class', + ], + 'where' => 'Où : :place', + 'counts' => 'Événements : :events, utilisateurs : :users', + 'release' => 'Version : :release', + ], + + 'prune' => [ + 'invalid' => 'Le nombre de jours doit être d\'au moins 1.', + 'done' => ':events événements et :issues erreurs de plus de :days jours supprimés.', + ], + + 'test' => [ + 'no_drivers' => 'Aucun pilote d\'erreurs n\'est activé.', + 'message' => 'Atrium errors: une erreur de test, à résoudre sans crainte', + 'skipped' => 'Non envoyée : le suivi est désactivé, ou l\'échantillonnage ou la limite par minute l\'a écartée.', + 'sent' => 'Erreur de test :id envoyée à : :drivers.', + ], +]; diff --git a/packages/errors/lang/it/errors.php b/packages/errors/lang/it/errors.php new file mode 100644 index 00000000..efba0142 --- /dev/null +++ b/packages/errors/lang/it/errors.php @@ -0,0 +1,183 @@ + 'Errori', + 'health' => 'Stato del sito', + 'subtitle' => 'Gli errori del sito e delle sue pagine, una riga per problema', + + 'statuses' => [ + 'new' => 'Non risolti', + 'resolved' => 'Risolti', + 'ignored' => 'Ignorati', + 'all' => 'Tutti', + ], + + 'levels' => [ + 'fatal' => 'Fatale', + 'error' => 'Errore', + 'warning' => 'Avviso', + 'info' => 'Info', + ], + + 'kinds' => [ + 'php' => 'PHP', + 'job' => 'Job in coda', + 'schedule' => 'Attività pianificata', + 'browser' => 'Browser', + 'message' => 'Messaggio', + ], + + 'drivers' => [ + 'database' => 'Database del sito (le schermate dell\'amministrazione)', + 'sentry' => 'Sentry o GlitchTip', + 'log' => 'Log dell\'applicazione', + ], + + 'list' => [ + 'search' => 'Cerca per classe, messaggio o posizione', + 'site' => 'Sito', + 'all_sites' => 'Tutti i siti', + 'level' => 'Livello', + 'any_level' => 'Qualsiasi livello', + 'kind' => 'Origine', + 'any_kind' => 'Qualsiasi origine', + 'status' => 'Stato', + 'release' => 'Release', + 'any_release' => 'Qualsiasi release', + 'path' => 'Indirizzo', + 'path_placeholder' => '/catalog', + 'sort' => 'Ordina', + 'sorts' => [ + 'last_seen_at' => 'Ultima occorrenza', + 'first_seen_at' => 'Prima occorrenza', + 'times_seen' => 'Più eventi', + 'users_seen' => 'Più utenti', + ], + 'filter' => 'Mostra', + 'reset' => 'Reimposta', + 'empty' => 'Nessun errore qui. Buone notizie.', + 'issue' => 'Errore', + 'events' => 'Eventi', + 'users' => 'Utenti', + 'last_seen' => 'Ultima occorrenza', + 'first_seen' => 'Prima occorrenza', + ], + + 'issue' => [ + 'back' => 'Tutti gli errori', + 'resolve' => 'Risolvi', + 'resolve_next' => 'Risolvi nella prossima release', + 'resolve_next_hint' => 'Torna solo se si ripresenta in una release successiva a :release.', + 'ignore' => 'Ignora', + 'reopen' => 'Riapri', + 'trace' => 'Stack trace', + 'caused_by' => 'Causato da', + 'all_frames' => 'Mostra i frame del framework', + 'app_frames' => 'Nascondi i frame del framework', + 'request' => 'Richiesta', + 'context' => 'Contesto', + 'breadcrumbs' => 'Prima dell\'errore', + 'environment' => 'Ambiente', + 'occurrences' => 'Occorrenze', + 'frequency' => 'Frequenza', + 'last_24h' => '24 ore', + 'last_30d' => '30 giorni', + 'top_paths' => 'Indirizzi', + 'top_releases' => 'Release', + 'first_release' => 'Prima release', + 'last_release' => 'Ultima release', + 'resolved_in' => 'Risolto nella release :release', + 'regressed' => 'Ripresentato', + 'no_event' => 'Per questo errore non è più conservato alcun evento: sono più vecchi del periodo di conservazione.', + 'open' => 'Apri', + 'shown' => 'Mostrato', + 'time' => 'Ora', + 'user' => 'Utente', + 'method' => 'Metodo', + 'url' => 'Indirizzo', + 'route' => 'Route', + 'site' => 'Sito', + 'locale' => 'Lingua', + 'release' => 'Release', + 'php' => 'PHP', + 'laravel' => 'Laravel', + 'none' => '—', + ], + + 'status_saved' => [ + 'new' => 'L\'errore è stato riaperto.', + 'resolved' => 'L\'errore è stato risolto.', + 'ignored' => 'L\'errore viene ignorato.', + ], + + 'gadget' => [ + 'title' => 'Errori nelle 24 ore', + 'events' => 'eventi', + 'new' => 'nuovi', + 'regressed' => 'ripresentati', + 'unresolved' => 'non risolti', + 'none' => 'Nessun errore nelle ultime 24 ore.', + 'top' => 'I più rumorosi', + 'all' => 'Tutti gli errori', + 'chart' => 'Eventi per ora', + ], + + 'permissions' => [ + 'view' => 'Visualizzare gli errori', + ], + + 'settings' => [ + 'description' => 'Dove vengono salvati e inviati gli errori, quanti e chi viene avvisato. Un campo vuoto prende il valore da config/atrium-errors.php o .env; tieni lì i segreti.', + 'drivers' => 'Invia gli errori a', + 'drivers_hint' => 'Più destinazioni insieme. Le schermate dell\'amministrazione e gli avvisi richiedono il database del sito.', + 'sentry_dsn' => 'DSN di Sentry', + 'sentry_dsn_hint' => 'Da Sentry, GlitchTip o un altro servizio compatibile con Sentry: https://chiave@host/progetto. Meglio in .env come ATRIUM_ERRORS_SENTRY_DSN.', + 'sample_rate' => 'Conserva, %', + 'sample_rate_hint' => 'Percentuale di eventi conservati, da 1 a 100.', + 'per_minute' => 'Massimo al minuto', + 'per_minute_hint' => 'Gli eventi oltre questo numero in un minuto vengono scartati. 0: nessun limite.', + 'retention_days' => 'Conserva gli eventi, giorni', + 'alert_email' => 'E-mail di avviso', + 'alert_email_hint' => 'Indirizzi separati da virgole.', + 'telegram_token' => 'Token del bot Telegram', + 'telegram_token_hint' => 'Lo fornisce @BotFather. Meglio in .env come ATRIUM_ERRORS_TELEGRAM_TOKEN.', + 'telegram_chat' => 'ID della chat Telegram', + 'alert_new' => 'Avvisa per un nuovo errore', + 'alert_regression' => 'Avvisa quando un errore risolto si ripresenta', + 'spike_per_hour' => 'Picco: eventi di un errore all\'ora', + 'spike_per_hour_hint' => 'Più di questo valore in un\'ora invia un avviso. 0: disattivato.', + 'browser_site' => 'Intercetta gli errori JavaScript sul sito', + 'browser_admin' => 'Intercetta gli errori JavaScript nell\'amministrazione', + ], + + 'alerts' => [ + 'purpose' => 'Avvisi di errore', + 'subject' => [ + 'new' => 'Nuovo errore su :site: :class', + 'regression' => 'Un errore si è ripresentato su :site: :class', + 'spike' => 'Picco di errori su :site: :class', + ], + 'where' => 'Dove: :place', + 'counts' => 'Eventi: :events, utenti: :users', + 'release' => 'Release: :release', + ], + + 'prune' => [ + 'invalid' => 'Il numero di giorni deve essere 1 o più.', + 'done' => 'Eliminati :events eventi e :issues errori più vecchi di :days giorni.', + ], + + 'test' => [ + 'no_drivers' => 'Nessun driver degli errori è attivo.', + 'message' => 'Atrium errors: un errore di prova, si può risolvere senza problemi', + 'skipped' => 'Non inviato: il tracciamento è disattivato, oppure il campionamento o il limite al minuto lo ha scartato.', + 'sent' => 'Errore di prova :id inviato a: :drivers.', + ], +]; diff --git a/packages/errors/lang/ja/errors.php b/packages/errors/lang/ja/errors.php new file mode 100644 index 00000000..345d570f --- /dev/null +++ b/packages/errors/lang/ja/errors.php @@ -0,0 +1,183 @@ + 'エラー', + 'health' => 'サイトの状態', + 'subtitle' => 'サイトとそのページのエラー。不具合ごとに1行', + + 'statuses' => [ + 'new' => '未解決', + 'resolved' => '解決済み', + 'ignored' => '無視', + 'all' => 'すべて', + ], + + 'levels' => [ + 'fatal' => '致命的', + 'error' => 'エラー', + 'warning' => '警告', + 'info' => '情報', + ], + + 'kinds' => [ + 'php' => 'PHP', + 'job' => 'キュージョブ', + 'schedule' => 'スケジュールタスク', + 'browser' => 'ブラウザ', + 'message' => 'メッセージ', + ], + + 'drivers' => [ + 'database' => 'サイトのデータベース(管理画面用)', + 'sentry' => 'Sentry または GlitchTip', + 'log' => 'アプリケーションログ', + ], + + 'list' => [ + 'search' => 'クラス、メッセージ、場所で検索', + 'site' => 'サイト', + 'all_sites' => 'すべてのサイト', + 'level' => 'レベル', + 'any_level' => 'すべてのレベル', + 'kind' => 'ソース', + 'any_kind' => 'すべてのソース', + 'status' => 'ステータス', + 'release' => 'リリース', + 'any_release' => 'すべてのリリース', + 'path' => 'アドレス', + 'path_placeholder' => '/catalog', + 'sort' => '並び順', + 'sorts' => [ + 'last_seen_at' => '最終発生', + 'first_seen_at' => '初回発生', + 'times_seen' => 'イベント数が多い順', + 'users_seen' => 'ユーザー数が多い順', + ], + 'filter' => '表示', + 'reset' => 'リセット', + 'empty' => 'エラーはありません。良いニュースです。', + 'issue' => 'エラー', + 'events' => 'イベント', + 'users' => 'ユーザー', + 'last_seen' => '最終発生', + 'first_seen' => '初回発生', + ], + + 'issue' => [ + 'back' => 'すべてのエラー', + 'resolve' => '解決', + 'resolve_next' => '次のリリースで解決', + 'resolve_next_hint' => ':release より後のリリースで発生した場合にのみ再発扱いになります。', + 'ignore' => '無視', + 'reopen' => '再オープン', + 'trace' => 'スタックトレース', + 'caused_by' => '原因', + 'all_frames' => 'フレームワークのフレームを表示', + 'app_frames' => 'フレームワークのフレームを非表示', + 'request' => 'リクエスト', + 'context' => 'コンテキスト', + 'breadcrumbs' => 'エラーの前', + 'environment' => '環境', + 'occurrences' => '発生履歴', + 'frequency' => '頻度', + 'last_24h' => '24時間', + 'last_30d' => '30日', + 'top_paths' => 'アドレス', + 'top_releases' => 'リリース', + 'first_release' => '最初のリリース', + 'last_release' => '最新のリリース', + 'resolved_in' => 'リリース :release で解決', + 'regressed' => '再発', + 'no_event' => 'このエラーのイベントはもう保存されていません。保持期間より古いためです。', + 'open' => '開く', + 'shown' => '表示済み', + 'time' => '時刻', + 'user' => 'ユーザー', + 'method' => 'メソッド', + 'url' => 'アドレス', + 'route' => 'ルート', + 'site' => 'サイト', + 'locale' => '言語', + 'release' => 'リリース', + 'php' => 'PHP', + 'laravel' => 'Laravel', + 'none' => '—', + ], + + 'status_saved' => [ + 'new' => 'エラーを再オープンしました。', + 'resolved' => 'エラーを解決済みにしました。', + 'ignored' => 'エラーを無視しました。', + ], + + 'gadget' => [ + 'title' => '24時間のエラー', + 'events' => 'イベント', + 'new' => '新規', + 'regressed' => '再発', + 'unresolved' => '未解決', + 'none' => '過去24時間のエラーはありません。', + 'top' => '多い順', + 'all' => 'すべてのエラー', + 'chart' => '1時間あたりのイベント', + ], + + 'permissions' => [ + 'view' => 'エラーの閲覧', + ], + + 'settings' => [ + 'description' => 'エラーの保存先と送信先、件数、通知する相手を設定します。空欄の場合は config/atrium-errors.php または .env の値が使われます。秘密情報はそちらで管理してください。', + 'drivers' => 'エラーの送信先', + 'drivers_hint' => '複数を同時に選べます。管理画面とアラートにはサイトのデータベースが必要です。', + 'sentry_dsn' => 'Sentry DSN', + 'sentry_dsn_hint' => 'Sentry、GlitchTip、または Sentry 互換サービスで取得できます: https://キー@ホスト/プロジェクト。.env に ATRIUM_ERRORS_SENTRY_DSN として設定するのがおすすめです。', + 'sample_rate' => '保存率、%', + 'sample_rate_hint' => '保存するイベントの割合(1〜100)。', + 'per_minute' => '1分あたりの上限', + 'per_minute_hint' => '1分間にこの数を超えたイベントは破棄されます。0: 無制限。', + 'retention_days' => 'イベントの保存日数', + 'alert_email' => 'アラートのメール', + 'alert_email_hint' => 'アドレスはカンマで区切ります。', + 'telegram_token' => 'Telegram ボットのトークン', + 'telegram_token_hint' => '@BotFather で取得できます。.env に ATRIUM_ERRORS_TELEGRAM_TOKEN として設定するのがおすすめです。', + 'telegram_chat' => 'Telegram チャット ID', + 'alert_new' => '新しいエラーで通知', + 'alert_regression' => '解決済みのエラーが再発したときに通知', + 'spike_per_hour' => 'スパイク: 1つのエラーの1時間あたりのイベント数', + 'spike_per_hour_hint' => '1時間にこの数を超えるとアラートを送ります。0: オフ。', + 'browser_site' => 'サイトの JavaScript エラーを収集', + 'browser_admin' => '管理画面の JavaScript エラーを収集', + ], + + 'alerts' => [ + 'purpose' => 'エラーアラート', + 'subject' => [ + 'new' => ':site で新しいエラー: :class', + 'regression' => ':site でエラーが再発: :class', + 'spike' => ':site でエラーが急増: :class', + ], + 'where' => '場所: :place', + 'counts' => 'イベント: :events、ユーザー: :users', + 'release' => 'リリース: :release', + ], + + 'prune' => [ + 'invalid' => '日数は1以上にしてください。', + 'done' => ':days 日より古いイベント :events 件とエラー :issues 件を削除しました。', + ], + + 'test' => [ + 'no_drivers' => '有効なエラードライバーがありません。', + 'message' => 'Atrium errors: テストエラーです。解決済みにして問題ありません', + 'skipped' => '送信されませんでした: 追跡がオフか、サンプリングまたは1分あたりの上限で破棄されました。', + 'sent' => 'テストエラー :id を送信しました: :drivers。', + ], +]; diff --git a/packages/errors/lang/kk/errors.php b/packages/errors/lang/kk/errors.php new file mode 100644 index 00000000..5279bd0b --- /dev/null +++ b/packages/errors/lang/kk/errors.php @@ -0,0 +1,183 @@ + 'Қателер', + 'health' => 'Сайт жағдайы', + 'subtitle' => 'Сайт пен оның беттеріндегі қателер, бір ақау — бір жол', + + 'statuses' => [ + 'new' => 'Шешілмеген', + 'resolved' => 'Шешілген', + 'ignored' => 'Жасырылған', + 'all' => 'Барлығы', + ], + + 'levels' => [ + 'fatal' => 'Фатальды', + 'error' => 'Қате', + 'warning' => 'Ескерту', + 'info' => 'Мәлімет', + ], + + 'kinds' => [ + 'php' => 'PHP', + 'job' => 'Кезек тапсырмасы', + 'schedule' => 'Кесте бойынша тапсырма', + 'browser' => 'Браузер', + 'message' => 'Хабарлама', + ], + + 'drivers' => [ + 'database' => 'Сайт дерекқоры (әкімші экрандары)', + 'sentry' => 'Sentry немесе GlitchTip', + 'log' => 'Қолданба журналы', + ], + + 'list' => [ + 'search' => 'Класс, мәтін немесе орын бойынша іздеу', + 'site' => 'Сайт', + 'all_sites' => 'Барлық сайттар', + 'level' => 'Деңгей', + 'any_level' => 'Кез келген деңгей', + 'kind' => 'Көз', + 'any_kind' => 'Кез келген көз', + 'status' => 'Мәртебе', + 'release' => 'Релиз', + 'any_release' => 'Кез келген релиз', + 'path' => 'Мекенжай', + 'path_placeholder' => '/catalog', + 'sort' => 'Реті', + 'sorts' => [ + 'last_seen_at' => 'Алдымен соңғылары', + 'first_seen_at' => 'Алдымен жаңадан пайда болғандар', + 'times_seen' => 'Оқиғасы көбірек', + 'users_seen' => 'Адамы көбірек', + ], + 'filter' => 'Көрсету', + 'reset' => 'Тазалау', + 'empty' => 'Қателер жоқ. Жақсы жаңалық.', + 'issue' => 'Қате', + 'events' => 'Оқиғалар', + 'users' => 'Адамдар', + 'last_seen' => 'Соңғы рет', + 'first_seen' => 'Алғаш рет', + ], + + 'issue' => [ + 'back' => 'Барлық қателер', + 'resolve' => 'Шешілді', + 'resolve_next' => 'Келесі релизде шешілді', + 'resolve_next_hint' => 'Қате :release релизінен кейінгі релизде қайталанса ғана қайта оралады.', + 'ignore' => 'Жасыру', + 'reopen' => 'Қайта ашу', + 'trace' => 'Шақырулар стегі', + 'caused_by' => 'Себебі', + 'all_frames' => 'Фреймворк шақыруларын көрсету', + 'app_frames' => 'Фреймворк шақыруларын жасыру', + 'request' => 'Сұраныс', + 'context' => 'Контекст', + 'breadcrumbs' => 'Қатеге дейін', + 'environment' => 'Орта', + 'occurrences' => 'Жағдайлар', + 'frequency' => 'Жиілігі', + 'last_24h' => '24 сағат', + 'last_30d' => '30 күн', + 'top_paths' => 'Мекенжайлар', + 'top_releases' => 'Релиздер', + 'first_release' => 'Алғашқы релиз', + 'last_release' => 'Соңғы релиз', + 'resolved_in' => ':release релизінде шешілді', + 'regressed' => 'Қайта пайда болды', + 'no_event' => 'Бұл қатенің жағдайлары енді сақталмайды: олар сақтау мерзімінен ескі.', + 'open' => 'Ашу', + 'shown' => 'Көрсетілді', + 'time' => 'Уақыт', + 'user' => 'Пайдаланушы', + 'method' => 'Әдіс', + 'url' => 'Мекенжай', + 'route' => 'Маршрут', + 'site' => 'Сайт', + 'locale' => 'Тіл', + 'release' => 'Релиз', + 'php' => 'PHP', + 'laravel' => 'Laravel', + 'none' => '—', + ], + + 'status_saved' => [ + 'new' => 'Қате қайта ашылды.', + 'resolved' => 'Қате шешілді деп белгіленді.', + 'ignored' => 'Қате жасырылды.', + ], + + 'gadget' => [ + 'title' => 'Тәуліктегі қателер', + 'events' => 'оқиға', + 'new' => 'жаңа', + 'regressed' => 'қайта оралды', + 'unresolved' => 'шешілмеген', + 'none' => 'Соңғы тәулікте қателер болған жоқ.', + 'top' => 'Ең жиі', + 'all' => 'Барлық қателер', + 'chart' => 'Сағат бойынша оқиғалар', + ], + + 'permissions' => [ + 'view' => 'Қателерді қарау', + ], + + 'settings' => [ + 'description' => 'Қателерді қайда сақтап, қайда жіберу керек, қанша және кімге хабарлау керек. Бос өріс мәнді config/atrium-errors.php немесе .env файлынан алады — құпияларды сонда сақтаған жөн.', + 'drivers' => 'Қателерді жіберу', + 'drivers_hint' => 'Бірден бірнеше жерге болады. Әкімші экрандары мен хабарландыруларға сайт дерекқоры қажет.', + 'sentry_dsn' => 'Sentry DSN', + 'sentry_dsn_hint' => 'Sentry, GlitchTip немесе Sentry-мен үйлесімді басқа қызметтен: https://кілт@хост/жоба. .env файлында ATRIUM_ERRORS_SENTRY_DSN ретінде сақтаған жөн.', + 'sample_rate' => 'Сақтау, %', + 'sample_rate_hint' => 'Сақталатын оқиғалар үлесі, 1-ден 100-ге дейін.', + 'per_minute' => 'Минутына ең көбі', + 'per_minute_hint' => 'Бір минутта осы саннан асатын оқиғалар тасталады. 0 — шектеусіз.', + 'retention_days' => 'Оқиғаларды сақтау, күн', + 'alert_email' => 'Хабарландыру поштасы', + 'alert_email_hint' => 'Мекенжайлар үтір арқылы.', + 'telegram_token' => 'Telegram бот токені', + 'telegram_token_hint' => '@BotFather береді. .env файлында ATRIUM_ERRORS_TELEGRAM_TOKEN ретінде сақтаған жөн.', + 'telegram_chat' => 'Telegram чат ID', + 'alert_new' => 'Жаңа қате туралы хабарлау', + 'alert_regression' => 'Шешілген қате қайта оралғанда хабарлау', + 'spike_per_hour' => 'Өсім: бір қатенің сағатына оқиғалары', + 'spike_per_hour_hint' => 'Сағатына осыдан көп болса — хабарландыру келеді. 0 — өшірулі.', + 'browser_site' => 'Сайттағы JavaScript қателерін ұстау', + 'browser_admin' => 'Әкімші панеліндегі JavaScript қателерін ұстау', + ], + + 'alerts' => [ + 'purpose' => 'Қателер туралы хабарландырулар', + 'subject' => [ + 'new' => ':site сайтында жаңа қате: :class', + 'regression' => ':site сайтында қате қайта пайда болды: :class', + 'spike' => ':site сайтында қателер өсімі: :class', + ], + 'where' => 'Қайда: :place', + 'counts' => 'Оқиға: :events, адам: :users', + 'release' => 'Релиз: :release', + ], + + 'prune' => [ + 'invalid' => 'Күн саны кемінде 1 болуы керек.', + 'done' => 'Жойылды: :events оқиға, :issues қате — барлығы :days күннен ескі.', + ], + + 'test' => [ + 'no_drivers' => 'Қателерді жіберудің бірде-бір тәсілі қосылмаған.', + 'message' => 'Atrium errors: тексеру қатесі, оны шешілді деп белгілеуге болады', + 'skipped' => 'Жіберілмеді: жинау өшірулі немесе оқиғаны іріктеу не минуттық лимит қиып тастады.', + 'sent' => ':id тексеру қатесі жіберілді: :drivers.', + ], +]; diff --git a/packages/errors/lang/pl/errors.php b/packages/errors/lang/pl/errors.php new file mode 100644 index 00000000..427da4de --- /dev/null +++ b/packages/errors/lang/pl/errors.php @@ -0,0 +1,183 @@ + 'Błędy', + 'health' => 'Stan witryny', + 'subtitle' => 'Błędy witryny i jej stron, jeden wiersz na jedną usterkę', + + 'statuses' => [ + 'new' => 'Nierozwiązane', + 'resolved' => 'Rozwiązane', + 'ignored' => 'Ignorowane', + 'all' => 'Wszystkie', + ], + + 'levels' => [ + 'fatal' => 'Krytyczny', + 'error' => 'Błąd', + 'warning' => 'Ostrzeżenie', + 'info' => 'Informacja', + ], + + 'kinds' => [ + 'php' => 'PHP', + 'job' => 'Zadanie kolejki', + 'schedule' => 'Zadanie cykliczne', + 'browser' => 'Przeglądarka', + 'message' => 'Komunikat', + ], + + 'drivers' => [ + 'database' => 'Baza danych witryny (ekrany panelu)', + 'sentry' => 'Sentry lub GlitchTip', + 'log' => 'Dziennik aplikacji', + ], + + 'list' => [ + 'search' => 'Szukaj po klasie, treści lub miejscu', + 'site' => 'Witryna', + 'all_sites' => 'Wszystkie witryny', + 'level' => 'Poziom', + 'any_level' => 'Dowolny poziom', + 'kind' => 'Źródło', + 'any_kind' => 'Dowolne źródło', + 'status' => 'Status', + 'release' => 'Wydanie', + 'any_release' => 'Dowolne wydanie', + 'path' => 'Adres', + 'path_placeholder' => '/catalog', + 'sort' => 'Sortuj', + 'sorts' => [ + 'last_seen_at' => 'Ostatnio widziane', + 'first_seen_at' => 'Pierwszy raz widziane', + 'times_seen' => 'Najwięcej zdarzeń', + 'users_seen' => 'Najwięcej użytkowników', + ], + 'filter' => 'Pokaż', + 'reset' => 'Resetuj', + 'empty' => 'Brak błędów. Dobra wiadomość.', + 'issue' => 'Błąd', + 'events' => 'Zdarzenia', + 'users' => 'Użytkownicy', + 'last_seen' => 'Ostatnio', + 'first_seen' => 'Pierwszy raz', + ], + + 'issue' => [ + 'back' => 'Wszystkie błędy', + 'resolve' => 'Rozwiąż', + 'resolve_next' => 'Rozwiąż w następnym wydaniu', + 'resolve_next_hint' => 'Wróci tylko wtedy, gdy wystąpi w wydaniu nowszym niż :release.', + 'ignore' => 'Ignoruj', + 'reopen' => 'Otwórz ponownie', + 'trace' => 'Ślad stosu', + 'caused_by' => 'Spowodowany przez', + 'all_frames' => 'Pokaż wywołania frameworka', + 'app_frames' => 'Ukryj wywołania frameworka', + 'request' => 'Żądanie', + 'context' => 'Kontekst', + 'breadcrumbs' => 'Przed błędem', + 'environment' => 'Środowisko', + 'occurrences' => 'Wystąpienia', + 'frequency' => 'Częstotliwość', + 'last_24h' => '24 godziny', + 'last_30d' => '30 dni', + 'top_paths' => 'Adresy', + 'top_releases' => 'Wydania', + 'first_release' => 'Pierwsze wydanie', + 'last_release' => 'Ostatnie wydanie', + 'resolved_in' => 'Rozwiązano w wydaniu :release', + 'regressed' => 'Wrócił', + 'no_event' => 'Zdarzenia tego błędu nie są już przechowywane: są starsze niż okres przechowywania.', + 'open' => 'Otwórz', + 'shown' => 'Wyświetlono', + 'time' => 'Czas', + 'user' => 'Użytkownik', + 'method' => 'Metoda', + 'url' => 'Adres', + 'route' => 'Trasa', + 'site' => 'Witryna', + 'locale' => 'Język', + 'release' => 'Wydanie', + 'php' => 'PHP', + 'laravel' => 'Laravel', + 'none' => '—', + ], + + 'status_saved' => [ + 'new' => 'Błąd został otwarty ponownie.', + 'resolved' => 'Błąd został rozwiązany.', + 'ignored' => 'Błąd jest ignorowany.', + ], + + 'gadget' => [ + 'title' => 'Błędy z 24 godzin', + 'events' => 'zdarzeń', + 'new' => 'nowych', + 'regressed' => 'wróciło', + 'unresolved' => 'nierozwiązanych', + 'none' => 'Brak błędów w ostatnich 24 godzinach.', + 'top' => 'Najgłośniejsze', + 'all' => 'Wszystkie błędy', + 'chart' => 'Zdarzenia na godzinę', + ], + + 'permissions' => [ + 'view' => 'Przeglądanie błędów', + ], + + 'settings' => [ + 'description' => 'Gdzie błędy są zapisywane i wysyłane, ile ich i kogo powiadamiać. Puste pole bierze wartość z config/atrium-errors.php lub .env; sekrety lepiej trzymać tam.', + 'drivers' => 'Wysyłaj błędy do', + 'drivers_hint' => 'Kilka naraz. Ekrany panelu i alerty wymagają bazy danych witryny.', + 'sentry_dsn' => 'DSN Sentry', + 'sentry_dsn_hint' => 'Z Sentry, GlitchTip lub innej usługi zgodnej z Sentry: https://klucz@host/projekt. Lepiej w .env jako ATRIUM_ERRORS_SENTRY_DSN.', + 'sample_rate' => 'Zachowuj, %', + 'sample_rate_hint' => 'Odsetek zachowywanych zdarzeń, od 1 do 100.', + 'per_minute' => 'Najwyżej na minutę', + 'per_minute_hint' => 'Zdarzenia ponad ten limit w ciągu minuty są odrzucane. 0: bez limitu.', + 'retention_days' => 'Przechowuj zdarzenia, dni', + 'alert_email' => 'E-maile z alertami', + 'alert_email_hint' => 'Adresy oddzielone przecinkami.', + 'telegram_token' => 'Token bota Telegram', + 'telegram_token_hint' => 'Od @BotFather. Lepiej w .env jako ATRIUM_ERRORS_TELEGRAM_TOKEN.', + 'telegram_chat' => 'ID czatu Telegram', + 'alert_new' => 'Alert o nowym błędzie', + 'alert_regression' => 'Alert, gdy rozwiązany błąd wróci', + 'spike_per_hour' => 'Skok: zdarzeń jednego błędu na godzinę', + 'spike_per_hour_hint' => 'Więcej niż tyle w ciągu godziny wysyła alert. 0: wyłączone.', + 'browser_site' => 'Wychwytuj błędy JavaScript na witrynie', + 'browser_admin' => 'Wychwytuj błędy JavaScript w panelu', + ], + + 'alerts' => [ + 'purpose' => 'Alerty o błędach', + 'subject' => [ + 'new' => 'Nowy błąd na :site: :class', + 'regression' => 'Błąd wrócił na :site: :class', + 'spike' => 'Skok liczby błędów na :site: :class', + ], + 'where' => 'Gdzie: :place', + 'counts' => 'Zdarzenia: :events, użytkownicy: :users', + 'release' => 'Wydanie: :release', + ], + + 'prune' => [ + 'invalid' => 'Liczba dni musi wynosić co najmniej 1.', + 'done' => 'Usunięto zdarzeń: :events i błędów: :issues starszych niż :days dni.', + ], + + 'test' => [ + 'no_drivers' => 'Żaden sterownik błędów nie jest włączony.', + 'message' => 'Atrium errors: testowy błąd, można go spokojnie rozwiązać', + 'skipped' => 'Nie wysłano: śledzenie jest wyłączone albo próbkowanie lub limit na minutę go odrzuciły.', + 'sent' => 'Testowy błąd :id wysłano do: :drivers.', + ], +]; diff --git a/packages/errors/lang/pt_BR/errors.php b/packages/errors/lang/pt_BR/errors.php new file mode 100644 index 00000000..d6c8a44f --- /dev/null +++ b/packages/errors/lang/pt_BR/errors.php @@ -0,0 +1,183 @@ + 'Erros', + 'health' => 'Saúde do site', + 'subtitle' => 'Erros do site e de suas páginas, uma linha por problema', + + 'statuses' => [ + 'new' => 'Não resolvidos', + 'resolved' => 'Resolvidos', + 'ignored' => 'Ignorados', + 'all' => 'Todos', + ], + + 'levels' => [ + 'fatal' => 'Fatal', + 'error' => 'Erro', + 'warning' => 'Aviso', + 'info' => 'Info', + ], + + 'kinds' => [ + 'php' => 'PHP', + 'job' => 'Job da fila', + 'schedule' => 'Tarefa agendada', + 'browser' => 'Navegador', + 'message' => 'Mensagem', + ], + + 'drivers' => [ + 'database' => 'Banco de dados do site (as telas do admin)', + 'sentry' => 'Sentry ou GlitchTip', + 'log' => 'Log da aplicação', + ], + + 'list' => [ + 'search' => 'Buscar por classe, mensagem ou local', + 'site' => 'Site', + 'all_sites' => 'Todos os sites', + 'level' => 'Nível', + 'any_level' => 'Qualquer nível', + 'kind' => 'Origem', + 'any_kind' => 'Qualquer origem', + 'status' => 'Status', + 'release' => 'Versão', + 'any_release' => 'Qualquer versão', + 'path' => 'Endereço', + 'path_placeholder' => '/catalog', + 'sort' => 'Ordem', + 'sorts' => [ + 'last_seen_at' => 'Visto por último', + 'first_seen_at' => 'Visto pela primeira vez', + 'times_seen' => 'Mais eventos', + 'users_seen' => 'Mais usuários', + ], + 'filter' => 'Mostrar', + 'reset' => 'Limpar', + 'empty' => 'Nenhum erro aqui. Boas notícias.', + 'issue' => 'Erro', + 'events' => 'Eventos', + 'users' => 'Usuários', + 'last_seen' => 'Visto por último', + 'first_seen' => 'Visto pela primeira vez', + ], + + 'issue' => [ + 'back' => 'Todos os erros', + 'resolve' => 'Resolver', + 'resolve_next' => 'Resolver na próxima versão', + 'resolve_next_hint' => 'Ele só volta se ocorrer em uma versão posterior à :release.', + 'ignore' => 'Ignorar', + 'reopen' => 'Reabrir', + 'trace' => 'Stack trace', + 'caused_by' => 'Causado por', + 'all_frames' => 'Mostrar frames do framework', + 'app_frames' => 'Ocultar frames do framework', + 'request' => 'Requisição', + 'context' => 'Contexto', + 'breadcrumbs' => 'Antes do erro', + 'environment' => 'Ambiente', + 'occurrences' => 'Ocorrências', + 'frequency' => 'Frequência', + 'last_24h' => '24 horas', + 'last_30d' => '30 dias', + 'top_paths' => 'Endereços', + 'top_releases' => 'Versões', + 'first_release' => 'Primeira versão', + 'last_release' => 'Última versão', + 'resolved_in' => 'Resolvido na versão :release', + 'regressed' => 'Voltou', + 'no_event' => 'Não há mais eventos guardados para este erro: eles são mais antigos que o período de retenção.', + 'open' => 'Abrir', + 'shown' => 'Exibido', + 'time' => 'Hora', + 'user' => 'Usuário', + 'method' => 'Método', + 'url' => 'Endereço', + 'route' => 'Rota', + 'site' => 'Site', + 'locale' => 'Idioma', + 'release' => 'Versão', + 'php' => 'PHP', + 'laravel' => 'Laravel', + 'none' => '—', + ], + + 'status_saved' => [ + 'new' => 'O erro foi reaberto.', + 'resolved' => 'O erro foi resolvido.', + 'ignored' => 'O erro está sendo ignorado.', + ], + + 'gadget' => [ + 'title' => 'Erros em 24 horas', + 'events' => 'eventos', + 'new' => 'novos', + 'regressed' => 'voltaram', + 'unresolved' => 'não resolvidos', + 'none' => 'Nenhum erro nas últimas 24 horas.', + 'top' => 'Os mais barulhentos', + 'all' => 'Todos os erros', + 'chart' => 'Eventos por hora', + ], + + 'permissions' => [ + 'view' => 'Ver erros', + ], + + 'settings' => [ + 'description' => 'Onde os erros são guardados e enviados, quantos e quem é avisado. Um campo vazio usa o valor de config/atrium-errors.php ou .env; deixe os segredos lá.', + 'drivers' => 'Enviar erros para', + 'drivers_hint' => 'Vários ao mesmo tempo. As telas do admin e os alertas precisam do banco de dados do site.', + 'sentry_dsn' => 'DSN do Sentry', + 'sentry_dsn_hint' => 'Do Sentry, GlitchTip ou outro serviço compatível com o Sentry: https://chave@host/projeto. Melhor no .env como ATRIUM_ERRORS_SENTRY_DSN.', + 'sample_rate' => 'Manter, %', + 'sample_rate_hint' => 'Parcela dos eventos mantidos, de 1 a 100.', + 'per_minute' => 'No máximo por minuto', + 'per_minute_hint' => 'Eventos acima disso em um minuto são descartados. 0: sem limite.', + 'retention_days' => 'Manter eventos, dias', + 'alert_email' => 'E-mails de alerta', + 'alert_email_hint' => 'Endereços separados por vírgulas.', + 'telegram_token' => 'Token do bot do Telegram', + 'telegram_token_hint' => 'Fornecido pelo @BotFather. Melhor no .env como ATRIUM_ERRORS_TELEGRAM_TOKEN.', + 'telegram_chat' => 'ID do chat do Telegram', + 'alert_new' => 'Alertar sobre um erro novo', + 'alert_regression' => 'Alertar quando um erro resolvido voltar', + 'spike_per_hour' => 'Pico: eventos de um erro por hora', + 'spike_per_hour_hint' => 'Mais do que isso em uma hora envia um alerta. 0: desligado.', + 'browser_site' => 'Capturar erros de JavaScript no site', + 'browser_admin' => 'Capturar erros de JavaScript no admin', + ], + + 'alerts' => [ + 'purpose' => 'Alertas de erro', + 'subject' => [ + 'new' => 'Novo erro em :site: :class', + 'regression' => 'Um erro voltou em :site: :class', + 'spike' => 'Pico de erros em :site: :class', + ], + 'where' => 'Onde: :place', + 'counts' => 'Eventos: :events, usuários: :users', + 'release' => 'Versão: :release', + ], + + 'prune' => [ + 'invalid' => 'O número de dias deve ser 1 ou mais.', + 'done' => ':events eventos e :issues erros com mais de :days dias foram apagados.', + ], + + 'test' => [ + 'no_drivers' => 'Nenhum driver de erros está ligado.', + 'message' => 'Atrium errors: um erro de teste, pode resolver sem medo', + 'skipped' => 'Não enviado: o rastreamento está desligado, ou a amostragem ou o limite por minuto o descartou.', + 'sent' => 'Erro de teste :id enviado para: :drivers.', + ], +]; diff --git a/packages/errors/lang/ru/errors.php b/packages/errors/lang/ru/errors.php new file mode 100644 index 00000000..6aacdaa8 --- /dev/null +++ b/packages/errors/lang/ru/errors.php @@ -0,0 +1,183 @@ + 'Ошибки', + 'health' => 'Состояние сайта', + 'subtitle' => 'Ошибки сайта и его страниц, одна строка на одну поломку', + + 'statuses' => [ + 'new' => 'Не решены', + 'resolved' => 'Решены', + 'ignored' => 'Скрыты', + 'all' => 'Все', + ], + + 'levels' => [ + 'fatal' => 'Фатальная', + 'error' => 'Ошибка', + 'warning' => 'Предупреждение', + 'info' => 'Сведения', + ], + + 'kinds' => [ + 'php' => 'PHP', + 'job' => 'Задача очереди', + 'schedule' => 'Задача по расписанию', + 'browser' => 'Браузер', + 'message' => 'Сообщение', + ], + + 'drivers' => [ + 'database' => 'База сайта (экраны админки)', + 'sentry' => 'Sentry или GlitchTip', + 'log' => 'Журнал приложения', + ], + + 'list' => [ + 'search' => 'Поиск по классу, тексту или месту', + 'site' => 'Сайт', + 'all_sites' => 'Все сайты', + 'level' => 'Уровень', + 'any_level' => 'Любой уровень', + 'kind' => 'Источник', + 'any_kind' => 'Любой источник', + 'status' => 'Статус', + 'release' => 'Релиз', + 'any_release' => 'Любой релиз', + 'path' => 'Адрес', + 'path_placeholder' => '/catalog', + 'sort' => 'Порядок', + 'sorts' => [ + 'last_seen_at' => 'Сначала свежие', + 'first_seen_at' => 'Сначала новые', + 'times_seen' => 'Больше всего событий', + 'users_seen' => 'Больше всего людей', + ], + 'filter' => 'Показать', + 'reset' => 'Сбросить', + 'empty' => 'Ошибок нет. Хорошая новость.', + 'issue' => 'Ошибка', + 'events' => 'События', + 'users' => 'Люди', + 'last_seen' => 'Последний раз', + 'first_seen' => 'Впервые', + ], + + 'issue' => [ + 'back' => 'Все ошибки', + 'resolve' => 'Решено', + 'resolve_next' => 'Решено в следующем релизе', + 'resolve_next_hint' => 'Ошибка вернётся, только если повторится в релизе новее :release.', + 'ignore' => 'Скрыть', + 'reopen' => 'Открыть снова', + 'trace' => 'Стек вызовов', + 'caused_by' => 'Причина', + 'all_frames' => 'Показать вызовы фреймворка', + 'app_frames' => 'Скрыть вызовы фреймворка', + 'request' => 'Запрос', + 'context' => 'Контекст', + 'breadcrumbs' => 'Перед ошибкой', + 'environment' => 'Окружение', + 'occurrences' => 'Случаи', + 'frequency' => 'Частота', + 'last_24h' => '24 часа', + 'last_30d' => '30 дней', + 'top_paths' => 'Адреса', + 'top_releases' => 'Релизы', + 'first_release' => 'Первый релиз', + 'last_release' => 'Последний релиз', + 'resolved_in' => 'Решено в релизе :release', + 'regressed' => 'Вернулась', + 'no_event' => 'Случаев этой ошибки больше не хранится: они старше срока хранения.', + 'open' => 'Открыть', + 'shown' => 'Показан', + 'time' => 'Время', + 'user' => 'Пользователь', + 'method' => 'Метод', + 'url' => 'Адрес', + 'route' => 'Маршрут', + 'site' => 'Сайт', + 'locale' => 'Язык', + 'release' => 'Релиз', + 'php' => 'PHP', + 'laravel' => 'Laravel', + 'none' => '—', + ], + + 'status_saved' => [ + 'new' => 'Ошибка снова открыта.', + 'resolved' => 'Ошибка отмечена решённой.', + 'ignored' => 'Ошибка скрыта.', + ], + + 'gadget' => [ + 'title' => 'Ошибки за сутки', + 'events' => 'событий', + 'new' => 'новых', + 'regressed' => 'вернулись', + 'unresolved' => 'не решено', + 'none' => 'За последние сутки ошибок не было.', + 'top' => 'Чаще всего', + 'all' => 'Все ошибки', + 'chart' => 'События по часам', + ], + + 'permissions' => [ + 'view' => 'Просмотр ошибок', + ], + + 'settings' => [ + 'description' => 'Куда складывать и отправлять ошибки, сколько и кому сообщать. Пустое поле берёт значение из config/atrium-errors.php или .env — секреты лучше держать там.', + 'drivers' => 'Отправлять ошибки', + 'drivers_hint' => 'Можно в несколько мест сразу. Экранам админки и оповещениям нужна база сайта.', + 'sentry_dsn' => 'DSN Sentry', + 'sentry_dsn_hint' => 'Из Sentry, GlitchTip или другого сервиса, совместимого с Sentry: https://ключ@хост/проект. Лучше в .env как ATRIUM_ERRORS_SENTRY_DSN.', + 'sample_rate' => 'Сохранять, %', + 'sample_rate_hint' => 'Доля сохраняемых событий, от 1 до 100.', + 'per_minute' => 'Не больше в минуту', + 'per_minute_hint' => 'События сверх этого числа за минуту отбрасываются. 0 — без ограничения.', + 'retention_days' => 'Хранить события, дней', + 'alert_email' => 'Почта для оповещений', + 'alert_email_hint' => 'Адреса через запятую.', + 'telegram_token' => 'Токен бота Telegram', + 'telegram_token_hint' => 'Выдаёт @BotFather. Лучше в .env как ATRIUM_ERRORS_TELEGRAM_TOKEN.', + 'telegram_chat' => 'ID чата Telegram', + 'alert_new' => 'Сообщать о новой ошибке', + 'alert_regression' => 'Сообщать, когда решённая ошибка вернулась', + 'spike_per_hour' => 'Всплеск: событий одной ошибки в час', + 'spike_per_hour_hint' => 'Если за час больше — придёт оповещение. 0 — выключено.', + 'browser_site' => 'Ловить ошибки JavaScript на сайте', + 'browser_admin' => 'Ловить ошибки JavaScript в админке', + ], + + 'alerts' => [ + 'purpose' => 'Оповещения об ошибках', + 'subject' => [ + 'new' => 'Новая ошибка на :site: :class', + 'regression' => 'Ошибка вернулась на :site: :class', + 'spike' => 'Всплеск ошибки на :site: :class', + ], + 'where' => 'Где: :place', + 'counts' => 'Событий: :events, людей: :users', + 'release' => 'Релиз: :release', + ], + + 'prune' => [ + 'invalid' => 'Число дней должно быть не меньше 1.', + 'done' => 'Удалено событий: :events, ошибок: :issues — всё старше :days дн.', + ], + + 'test' => [ + 'no_drivers' => 'Не включено ни одного способа отправки ошибок.', + 'message' => 'Atrium errors: проверочная ошибка, её можно отметить решённой', + 'skipped' => 'Не отправлено: сбор выключен или событие отсекли выборка либо лимит в минуту.', + 'sent' => 'Проверочная ошибка :id отправлена: :drivers.', + ], +]; diff --git a/packages/errors/lang/tr/errors.php b/packages/errors/lang/tr/errors.php new file mode 100644 index 00000000..f40b52a0 --- /dev/null +++ b/packages/errors/lang/tr/errors.php @@ -0,0 +1,183 @@ + 'Hatalar', + 'health' => 'Site sağlığı', + 'subtitle' => 'Sitenin ve sayfalarının hataları, her arıza için bir satır', + + 'statuses' => [ + 'new' => 'Çözülmemiş', + 'resolved' => 'Çözülmüş', + 'ignored' => 'Yok sayılan', + 'all' => 'Tümü', + ], + + 'levels' => [ + 'fatal' => 'Ölümcül', + 'error' => 'Hata', + 'warning' => 'Uyarı', + 'info' => 'Bilgi', + ], + + 'kinds' => [ + 'php' => 'PHP', + 'job' => 'Kuyruk işi', + 'schedule' => 'Zamanlanmış görev', + 'browser' => 'Tarayıcı', + 'message' => 'Mesaj', + ], + + 'drivers' => [ + 'database' => 'Site veritabanı (yönetim ekranları)', + 'sentry' => 'Sentry veya GlitchTip', + 'log' => 'Uygulama günlüğü', + ], + + 'list' => [ + 'search' => 'Sınıfa, mesaja veya yere göre ara', + 'site' => 'Site', + 'all_sites' => 'Tüm siteler', + 'level' => 'Seviye', + 'any_level' => 'Herhangi bir seviye', + 'kind' => 'Kaynak', + 'any_kind' => 'Herhangi bir kaynak', + 'status' => 'Durum', + 'release' => 'Sürüm', + 'any_release' => 'Herhangi bir sürüm', + 'path' => 'Adres', + 'path_placeholder' => '/catalog', + 'sort' => 'Sırala', + 'sorts' => [ + 'last_seen_at' => 'Son görülme', + 'first_seen_at' => 'İlk görülme', + 'times_seen' => 'En çok olay', + 'users_seen' => 'En çok kullanıcı', + ], + 'filter' => 'Göster', + 'reset' => 'Sıfırla', + 'empty' => 'Burada hata yok. Güzel haber.', + 'issue' => 'Hata', + 'events' => 'Olaylar', + 'users' => 'Kullanıcılar', + 'last_seen' => 'Son görülme', + 'first_seen' => 'İlk görülme', + ], + + 'issue' => [ + 'back' => 'Tüm hatalar', + 'resolve' => 'Çöz', + 'resolve_next' => 'Sonraki sürümde çöz', + 'resolve_next_hint' => 'Yalnızca :release sürümünden sonraki bir sürümde yeniden olursa geri gelir.', + 'ignore' => 'Yok say', + 'reopen' => 'Yeniden aç', + 'trace' => 'Yığın izi', + 'caused_by' => 'Nedeni', + 'all_frames' => 'Framework çağrılarını göster', + 'app_frames' => 'Framework çağrılarını gizle', + 'request' => 'İstek', + 'context' => 'Bağlam', + 'breadcrumbs' => 'Hatadan önce', + 'environment' => 'Ortam', + 'occurrences' => 'Oluşumlar', + 'frequency' => 'Sıklık', + 'last_24h' => '24 saat', + 'last_30d' => '30 gün', + 'top_paths' => 'Adresler', + 'top_releases' => 'Sürümler', + 'first_release' => 'İlk sürüm', + 'last_release' => 'Son sürüm', + 'resolved_in' => ':release sürümünde çözüldü', + 'regressed' => 'Geri geldi', + 'no_event' => 'Bu hata için artık olay saklanmıyor: saklama süresinden daha eskiler.', + 'open' => 'Aç', + 'shown' => 'Gösterilen', + 'time' => 'Zaman', + 'user' => 'Kullanıcı', + 'method' => 'Yöntem', + 'url' => 'Adres', + 'route' => 'Rota', + 'site' => 'Site', + 'locale' => 'Dil', + 'release' => 'Sürüm', + 'php' => 'PHP', + 'laravel' => 'Laravel', + 'none' => '—', + ], + + 'status_saved' => [ + 'new' => 'Hata yeniden açıldı.', + 'resolved' => 'Hata çözüldü.', + 'ignored' => 'Hata yok sayıldı.', + ], + + 'gadget' => [ + 'title' => '24 saatteki hatalar', + 'events' => 'olay', + 'new' => 'yeni', + 'regressed' => 'geri geldi', + 'unresolved' => 'çözülmemiş', + 'none' => 'Son 24 saatte hata yok.', + 'top' => 'En gürültülü', + 'all' => 'Tüm hatalar', + 'chart' => 'Saatlik olaylar', + ], + + 'permissions' => [ + 'view' => 'Hataları görüntüleme', + ], + + 'settings' => [ + 'description' => 'Hataların nerede saklanıp nereye gönderileceği, kaç tane olacağı ve kimin bilgilendirileceği. Boş alan değeri config/atrium-errors.php veya .env dosyasından alır; gizli bilgileri orada tutun.', + 'drivers' => 'Hataları şuraya gönder', + 'drivers_hint' => 'Aynı anda birkaçı olabilir. Yönetim ekranları ve uyarılar için site veritabanı gerekir.', + 'sentry_dsn' => 'Sentry DSN', + 'sentry_dsn_hint' => 'Sentry, GlitchTip veya Sentry uyumlu başka bir hizmetten: https://anahtar@sunucu/proje. .env içinde ATRIUM_ERRORS_SENTRY_DSN olarak tutmak daha iyi.', + 'sample_rate' => 'Sakla, %', + 'sample_rate_hint' => 'Saklanan olayların oranı, 1 ile 100 arası.', + 'per_minute' => 'Dakikada en fazla', + 'per_minute_hint' => 'Bir dakikada bunun üzerindeki olaylar atılır. 0: sınır yok.', + 'retention_days' => 'Olayları sakla, gün', + 'alert_email' => 'Uyarı e-postaları', + 'alert_email_hint' => 'Adresler virgülle ayrılır.', + 'telegram_token' => 'Telegram bot belirteci', + 'telegram_token_hint' => '@BotFather verir. .env içinde ATRIUM_ERRORS_TELEGRAM_TOKEN olarak tutmak daha iyi.', + 'telegram_chat' => 'Telegram sohbet kimliği', + 'alert_new' => 'Yeni hatada uyar', + 'alert_regression' => 'Çözülmüş bir hata geri geldiğinde uyar', + 'spike_per_hour' => 'Ani artış: bir hatanın saatlik olay sayısı', + 'spike_per_hour_hint' => 'Bir saatte bundan fazlası uyarı gönderir. 0: kapalı.', + 'browser_site' => 'Sitedeki JavaScript hatalarını yakala', + 'browser_admin' => 'Yönetimdeki JavaScript hatalarını yakala', + ], + + 'alerts' => [ + 'purpose' => 'Hata uyarıları', + 'subject' => [ + 'new' => ':site sitesinde yeni hata: :class', + 'regression' => ':site sitesinde bir hata geri geldi: :class', + 'spike' => ':site sitesinde hata artışı: :class', + ], + 'where' => 'Yer: :place', + 'counts' => 'Olay: :events, kullanıcı: :users', + 'release' => 'Sürüm: :release', + ], + + 'prune' => [ + 'invalid' => 'Gün sayısı 1 veya daha fazla olmalı.', + 'done' => ':days günden eski :events olay ve :issues hata silindi.', + ], + + 'test' => [ + 'no_drivers' => 'Hiçbir hata sürücüsü açık değil.', + 'message' => 'Atrium errors: bir test hatası, güvenle çözülebilir', + 'skipped' => 'Gönderilmedi: izleme kapalı ya da örnekleme veya dakika sınırı onu attı.', + 'sent' => ':id test hatası şuraya gönderildi: :drivers.', + ], +]; diff --git a/packages/errors/lang/uk/errors.php b/packages/errors/lang/uk/errors.php new file mode 100644 index 00000000..b49447dc --- /dev/null +++ b/packages/errors/lang/uk/errors.php @@ -0,0 +1,183 @@ + 'Помилки', + 'health' => 'Стан сайту', + 'subtitle' => 'Помилки сайту та його сторінок, один рядок на одну поломку', + + 'statuses' => [ + 'new' => 'Не вирішені', + 'resolved' => 'Вирішені', + 'ignored' => 'Приховані', + 'all' => 'Усі', + ], + + 'levels' => [ + 'fatal' => 'Фатальна', + 'error' => 'Помилка', + 'warning' => 'Попередження', + 'info' => 'Відомості', + ], + + 'kinds' => [ + 'php' => 'PHP', + 'job' => 'Завдання черги', + 'schedule' => 'Завдання за розкладом', + 'browser' => 'Браузер', + 'message' => 'Повідомлення', + ], + + 'drivers' => [ + 'database' => 'База сайту (екрани адмінки)', + 'sentry' => 'Sentry або GlitchTip', + 'log' => 'Журнал застосунку', + ], + + 'list' => [ + 'search' => 'Пошук за класом, текстом або місцем', + 'site' => 'Сайт', + 'all_sites' => 'Усі сайти', + 'level' => 'Рівень', + 'any_level' => 'Будь-який рівень', + 'kind' => 'Джерело', + 'any_kind' => 'Будь-яке джерело', + 'status' => 'Статус', + 'release' => 'Реліз', + 'any_release' => 'Будь-який реліз', + 'path' => 'Адреса', + 'path_placeholder' => '/catalog', + 'sort' => 'Порядок', + 'sorts' => [ + 'last_seen_at' => 'Спочатку свіжі', + 'first_seen_at' => 'Спочатку нові', + 'times_seen' => 'Найбільше подій', + 'users_seen' => 'Найбільше людей', + ], + 'filter' => 'Показати', + 'reset' => 'Скинути', + 'empty' => 'Помилок немає. Гарна новина.', + 'issue' => 'Помилка', + 'events' => 'Події', + 'users' => 'Люди', + 'last_seen' => 'Востаннє', + 'first_seen' => 'Уперше', + ], + + 'issue' => [ + 'back' => 'Усі помилки', + 'resolve' => 'Вирішено', + 'resolve_next' => 'Вирішено в наступному релізі', + 'resolve_next_hint' => 'Помилка повернеться, лише якщо повториться в релізі новішому за :release.', + 'ignore' => 'Приховати', + 'reopen' => 'Відкрити знову', + 'trace' => 'Стек викликів', + 'caused_by' => 'Причина', + 'all_frames' => 'Показати виклики фреймворку', + 'app_frames' => 'Сховати виклики фреймворку', + 'request' => 'Запит', + 'context' => 'Контекст', + 'breadcrumbs' => 'Перед помилкою', + 'environment' => 'Середовище', + 'occurrences' => 'Випадки', + 'frequency' => 'Частота', + 'last_24h' => '24 години', + 'last_30d' => '30 днів', + 'top_paths' => 'Адреси', + 'top_releases' => 'Релізи', + 'first_release' => 'Перший реліз', + 'last_release' => 'Останній реліз', + 'resolved_in' => 'Вирішено в релізі :release', + 'regressed' => 'Повернулась', + 'no_event' => 'Випадків цієї помилки більше не зберігається: вони старші за строк зберігання.', + 'open' => 'Відкрити', + 'shown' => 'Показано', + 'time' => 'Час', + 'user' => 'Користувач', + 'method' => 'Метод', + 'url' => 'Адреса', + 'route' => 'Маршрут', + 'site' => 'Сайт', + 'locale' => 'Мова', + 'release' => 'Реліз', + 'php' => 'PHP', + 'laravel' => 'Laravel', + 'none' => '—', + ], + + 'status_saved' => [ + 'new' => 'Помилку знову відкрито.', + 'resolved' => 'Помилку позначено вирішеною.', + 'ignored' => 'Помилку приховано.', + ], + + 'gadget' => [ + 'title' => 'Помилки за добу', + 'events' => 'подій', + 'new' => 'нових', + 'regressed' => 'повернулись', + 'unresolved' => 'не вирішено', + 'none' => 'За останню добу помилок не було.', + 'top' => 'Найчастіше', + 'all' => 'Усі помилки', + 'chart' => 'Події за годинами', + ], + + 'permissions' => [ + 'view' => 'Перегляд помилок', + ], + + 'settings' => [ + 'description' => 'Куди складати й надсилати помилки, скільки та кого сповіщати. Порожнє поле бере значення з config/atrium-errors.php або .env — секрети краще тримати там.', + 'drivers' => 'Надсилати помилки', + 'drivers_hint' => 'Можна в кілька місць одразу. Екранам адмінки та сповіщенням потрібна база сайту.', + 'sentry_dsn' => 'DSN Sentry', + 'sentry_dsn_hint' => 'Із Sentry, GlitchTip або іншого сервісу, сумісного із Sentry: https://ключ@хост/проєкт. Краще в .env як ATRIUM_ERRORS_SENTRY_DSN.', + 'sample_rate' => 'Зберігати, %', + 'sample_rate_hint' => 'Частка збережених подій, від 1 до 100.', + 'per_minute' => 'Не більше за хвилину', + 'per_minute_hint' => 'Події понад це число за хвилину відкидаються. 0 — без обмежень.', + 'retention_days' => 'Зберігати події, днів', + 'alert_email' => 'Пошта для сповіщень', + 'alert_email_hint' => 'Адреси через кому.', + 'telegram_token' => 'Токен бота Telegram', + 'telegram_token_hint' => 'Видає @BotFather. Краще в .env як ATRIUM_ERRORS_TELEGRAM_TOKEN.', + 'telegram_chat' => 'ID чату Telegram', + 'alert_new' => 'Повідомляти про нову помилку', + 'alert_regression' => 'Повідомляти, коли вирішена помилка повернулась', + 'spike_per_hour' => 'Сплеск: подій однієї помилки за годину', + 'spike_per_hour_hint' => 'Якщо за годину більше — надійде сповіщення. 0 — вимкнено.', + 'browser_site' => 'Ловити помилки JavaScript на сайті', + 'browser_admin' => 'Ловити помилки JavaScript в адмінці', + ], + + 'alerts' => [ + 'purpose' => 'Сповіщення про помилки', + 'subject' => [ + 'new' => 'Нова помилка на :site: :class', + 'regression' => 'Помилка повернулась на :site: :class', + 'spike' => 'Сплеск помилки на :site: :class', + ], + 'where' => 'Де: :place', + 'counts' => 'Подій: :events, людей: :users', + 'release' => 'Реліз: :release', + ], + + 'prune' => [ + 'invalid' => 'Кількість днів має бути не менше 1.', + 'done' => 'Видалено подій: :events, помилок: :issues — усе старше за :days дн.', + ], + + 'test' => [ + 'no_drivers' => 'Не ввімкнено жодного способу надсилання помилок.', + 'message' => 'Atrium errors: перевірочна помилка, її можна позначити вирішеною', + 'skipped' => 'Не надіслано: збір вимкнено або подію відсікли вибірка чи ліміт за хвилину.', + 'sent' => 'Перевірочну помилку :id надіслано: :drivers.', + ], +]; diff --git a/packages/errors/lang/uz/errors.php b/packages/errors/lang/uz/errors.php new file mode 100644 index 00000000..4b903c9c --- /dev/null +++ b/packages/errors/lang/uz/errors.php @@ -0,0 +1,183 @@ + 'Xatolar', + 'health' => 'Sayt holati', + 'subtitle' => 'Sayt va uning sahifalaridagi xatolar, bitta nosozlik — bitta qator', + + 'statuses' => [ + 'new' => 'Hal qilinmagan', + 'resolved' => 'Hal qilingan', + 'ignored' => 'Yashirilgan', + 'all' => 'Barchasi', + ], + + 'levels' => [ + 'fatal' => 'Halokatli', + 'error' => 'Xato', + 'warning' => 'Ogohlantirish', + 'info' => 'Ma\'lumot', + ], + + 'kinds' => [ + 'php' => 'PHP', + 'job' => 'Navbat vazifasi', + 'schedule' => 'Jadval bo\'yicha vazifa', + 'browser' => 'Brauzer', + 'message' => 'Xabar', + ], + + 'drivers' => [ + 'database' => 'Sayt bazasi (admin ekranlari)', + 'sentry' => 'Sentry yoki GlitchTip', + 'log' => 'Ilova jurnali', + ], + + 'list' => [ + 'search' => 'Klass, matn yoki joy bo\'yicha qidirish', + 'site' => 'Sayt', + 'all_sites' => 'Barcha saytlar', + 'level' => 'Daraja', + 'any_level' => 'Istalgan daraja', + 'kind' => 'Manba', + 'any_kind' => 'Istalgan manba', + 'status' => 'Holat', + 'release' => 'Reliz', + 'any_release' => 'Istalgan reliz', + 'path' => 'Manzil', + 'path_placeholder' => '/catalog', + 'sort' => 'Tartib', + 'sorts' => [ + 'last_seen_at' => 'Avval yangilari', + 'first_seen_at' => 'Avval yangi paydo bo\'lganlari', + 'times_seen' => 'Hodisalari ko\'proq', + 'users_seen' => 'Odamlari ko\'proq', + ], + 'filter' => 'Ko\'rsatish', + 'reset' => 'Tozalash', + 'empty' => 'Xatolar yo\'q. Yaxshi xabar.', + 'issue' => 'Xato', + 'events' => 'Hodisalar', + 'users' => 'Odamlar', + 'last_seen' => 'Oxirgi marta', + 'first_seen' => 'Birinchi marta', + ], + + 'issue' => [ + 'back' => 'Barcha xatolar', + 'resolve' => 'Hal qilindi', + 'resolve_next' => 'Keyingi relizda hal qilindi', + 'resolve_next_hint' => 'Xato faqat :release dan keyingi relizda takrorlansagina qaytadi.', + 'ignore' => 'Yashirish', + 'reopen' => 'Qayta ochish', + 'trace' => 'Chaqiruvlar steki', + 'caused_by' => 'Sababi', + 'all_frames' => 'Freymvork chaqiruvlarini ko\'rsatish', + 'app_frames' => 'Freymvork chaqiruvlarini yashirish', + 'request' => 'So\'rov', + 'context' => 'Kontekst', + 'breadcrumbs' => 'Xatodan oldin', + 'environment' => 'Muhit', + 'occurrences' => 'Holatlar', + 'frequency' => 'Chastota', + 'last_24h' => '24 soat', + 'last_30d' => '30 kun', + 'top_paths' => 'Manzillar', + 'top_releases' => 'Relizlar', + 'first_release' => 'Birinchi reliz', + 'last_release' => 'Oxirgi reliz', + 'resolved_in' => ':release relizida hal qilindi', + 'regressed' => 'Qaytdi', + 'no_event' => 'Bu xatoning holatlari endi saqlanmaydi: ular saqlash muddatidan eski.', + 'open' => 'Ochish', + 'shown' => 'Ko\'rsatilgan', + 'time' => 'Vaqt', + 'user' => 'Foydalanuvchi', + 'method' => 'Usul', + 'url' => 'Manzil', + 'route' => 'Marshrut', + 'site' => 'Sayt', + 'locale' => 'Til', + 'release' => 'Reliz', + 'php' => 'PHP', + 'laravel' => 'Laravel', + 'none' => '—', + ], + + 'status_saved' => [ + 'new' => 'Xato qayta ochildi.', + 'resolved' => 'Xato hal qilingan deb belgilandi.', + 'ignored' => 'Xato yashirildi.', + ], + + 'gadget' => [ + 'title' => 'Sutkadagi xatolar', + 'events' => 'hodisa', + 'new' => 'yangi', + 'regressed' => 'qaytdi', + 'unresolved' => 'hal qilinmagan', + 'none' => 'Oxirgi sutkada xatolar bo\'lmadi.', + 'top' => 'Eng ko\'p', + 'all' => 'Barcha xatolar', + 'chart' => 'Soatlar bo\'yicha hodisalar', + ], + + 'permissions' => [ + 'view' => 'Xatolarni koʻrish', + ], + + 'settings' => [ + 'description' => 'Xatolar qayerga saqlanadi va yuboriladi, qancha va kimga xabar beriladi. Bo\'sh maydon qiymatni config/atrium-errors.php yoki .env dan oladi — sirlarni o\'sha yerda saqlagan ma\'qul.', + 'drivers' => 'Xatolarni yuborish', + 'drivers_hint' => 'Bir vaqtning o\'zida bir nechta joyga bo\'ladi. Admin ekranlari va ogohlantirishlar uchun sayt bazasi kerak.', + 'sentry_dsn' => 'Sentry DSN', + 'sentry_dsn_hint' => 'Sentry, GlitchTip yoki Sentry bilan mos boshqa xizmatdan: https://kalit@host/loyiha. .env da ATRIUM_ERRORS_SENTRY_DSN sifatida saqlagan ma\'qul.', + 'sample_rate' => 'Saqlash, %', + 'sample_rate_hint' => 'Saqlanadigan hodisalar ulushi, 1 dan 100 gacha.', + 'per_minute' => 'Daqiqasiga ko\'pi bilan', + 'per_minute_hint' => 'Bir daqiqada shundan oshgan hodisalar tashlab yuboriladi. 0 — cheklovsiz.', + 'retention_days' => 'Hodisalarni saqlash, kun', + 'alert_email' => 'Ogohlantirish pochtasi', + 'alert_email_hint' => 'Manzillar vergul bilan.', + 'telegram_token' => 'Telegram bot tokeni', + 'telegram_token_hint' => '@BotFather beradi. .env da ATRIUM_ERRORS_TELEGRAM_TOKEN sifatida saqlagan ma\'qul.', + 'telegram_chat' => 'Telegram chat ID', + 'alert_new' => 'Yangi xato haqida xabar berish', + 'alert_regression' => 'Hal qilingan xato qaytganda xabar berish', + 'spike_per_hour' => 'Keskin o\'sish: bitta xatoning soatiga hodisalari', + 'spike_per_hour_hint' => 'Soatiga bundan ko\'p bo\'lsa — ogohlantirish keladi. 0 — o\'chirilgan.', + 'browser_site' => 'Saytdagi JavaScript xatolarini ushlash', + 'browser_admin' => 'Adminkadagi JavaScript xatolarini ushlash', + ], + + 'alerts' => [ + 'purpose' => 'Xatolar haqida ogohlantirishlar', + 'subject' => [ + 'new' => ':site saytida yangi xato: :class', + 'regression' => ':site saytida xato qaytdi: :class', + 'spike' => ':site saytida xatolar keskin o\'sdi: :class', + ], + 'where' => 'Qayerda: :place', + 'counts' => 'Hodisalar: :events, odamlar: :users', + 'release' => 'Reliz: :release', + ], + + 'prune' => [ + 'invalid' => 'Kunlar soni kamida 1 bo\'lishi kerak.', + 'done' => 'O\'chirildi: :events hodisa, :issues xato — hammasi :days kundan eski.', + ], + + 'test' => [ + 'no_drivers' => 'Xatolarni yuborishning birorta usuli yoqilmagan.', + 'message' => 'Atrium errors: tekshiruv xatosi, uni hal qilingan deb belgilash mumkin', + 'skipped' => 'Yuborilmadi: yig\'ish o\'chirilgan yoki hodisani tanlama yoki daqiqalik limit kesib tashladi.', + 'sent' => 'Tekshiruv xatosi :id yuborildi: :drivers.', + ], +]; diff --git a/packages/errors/lang/zh_CN/errors.php b/packages/errors/lang/zh_CN/errors.php new file mode 100644 index 00000000..fa142e56 --- /dev/null +++ b/packages/errors/lang/zh_CN/errors.php @@ -0,0 +1,183 @@ + '错误', + 'health' => '站点健康', + 'subtitle' => '站点及其页面的错误,每个问题一行', + + 'statuses' => [ + 'new' => '未解决', + 'resolved' => '已解决', + 'ignored' => '已忽略', + 'all' => '全部', + ], + + 'levels' => [ + 'fatal' => '致命', + 'error' => '错误', + 'warning' => '警告', + 'info' => '信息', + ], + + 'kinds' => [ + 'php' => 'PHP', + 'job' => '队列任务', + 'schedule' => '计划任务', + 'browser' => '浏览器', + 'message' => '消息', + ], + + 'drivers' => [ + 'database' => '站点数据库(后台页面)', + 'sentry' => 'Sentry 或 GlitchTip', + 'log' => '应用日志', + ], + + 'list' => [ + 'search' => '按类、消息或位置搜索', + 'site' => '站点', + 'all_sites' => '所有站点', + 'level' => '级别', + 'any_level' => '任意级别', + 'kind' => '来源', + 'any_kind' => '任意来源', + 'status' => '状态', + 'release' => '版本', + 'any_release' => '任意版本', + 'path' => '地址', + 'path_placeholder' => '/catalog', + 'sort' => '排序', + 'sorts' => [ + 'last_seen_at' => '最近出现', + 'first_seen_at' => '首次出现', + 'times_seen' => '事件最多', + 'users_seen' => '用户最多', + ], + 'filter' => '显示', + 'reset' => '重置', + 'empty' => '这里没有错误,好消息。', + 'issue' => '错误', + 'events' => '事件', + 'users' => '用户', + 'last_seen' => '最近出现', + 'first_seen' => '首次出现', + ], + + 'issue' => [ + 'back' => '所有错误', + 'resolve' => '标记为已解决', + 'resolve_next' => '在下一版本中解决', + 'resolve_next_hint' => '仅当在 :release 之后的版本中再次出现时才会重新打开。', + 'ignore' => '忽略', + 'reopen' => '重新打开', + 'trace' => '堆栈跟踪', + 'caused_by' => '原因', + 'all_frames' => '显示框架调用帧', + 'app_frames' => '隐藏框架调用帧', + 'request' => '请求', + 'context' => '上下文', + 'breadcrumbs' => '错误发生前', + 'environment' => '环境', + 'occurrences' => '出现记录', + 'frequency' => '频率', + 'last_24h' => '24 小时', + 'last_30d' => '30 天', + 'top_paths' => '地址', + 'top_releases' => '版本', + 'first_release' => '首个版本', + 'last_release' => '最新版本', + 'resolved_in' => '已在版本 :release 中解决', + 'regressed' => '再次出现', + 'no_event' => '此错误已不再保留任何事件:它们已超过保留期限。', + 'open' => '打开', + 'shown' => '已显示', + 'time' => '时间', + 'user' => '用户', + 'method' => '方法', + 'url' => '地址', + 'route' => '路由', + 'site' => '站点', + 'locale' => '语言', + 'release' => '版本', + 'php' => 'PHP', + 'laravel' => 'Laravel', + 'none' => '—', + ], + + 'status_saved' => [ + 'new' => '错误已重新打开。', + 'resolved' => '错误已解决。', + 'ignored' => '错误已忽略。', + ], + + 'gadget' => [ + 'title' => '24 小时内的错误', + 'events' => '个事件', + 'new' => '新增', + 'regressed' => '再次出现', + 'unresolved' => '未解决', + 'none' => '过去 24 小时内没有错误。', + 'top' => '最频繁', + 'all' => '所有错误', + 'chart' => '每小时事件数', + ], + + 'permissions' => [ + 'view' => '查看错误', + ], + + 'settings' => [ + 'description' => '错误存放和发送的位置、数量以及通知对象。留空的字段会取自 config/atrium-errors.php 或 .env;密钥请保存在那里。', + 'drivers' => '将错误发送到', + 'drivers_hint' => '可同时选择多个。后台页面和告警需要站点数据库。', + 'sentry_dsn' => 'Sentry DSN', + 'sentry_dsn_hint' => '来自 Sentry、GlitchTip 或其他兼容 Sentry 的服务:https://密钥@主机/项目。建议放在 .env 中,变量名 ATRIUM_ERRORS_SENTRY_DSN。', + 'sample_rate' => '保留比例,%', + 'sample_rate_hint' => '保留的事件占比,1 到 100。', + 'per_minute' => '每分钟最多', + 'per_minute_hint' => '一分钟内超过此数量的事件会被丢弃。0:不限制。', + 'retention_days' => '事件保留天数', + 'alert_email' => '告警邮箱', + 'alert_email_hint' => '多个地址用逗号分隔。', + 'telegram_token' => 'Telegram 机器人令牌', + 'telegram_token_hint' => '由 @BotFather 提供。建议放在 .env 中,变量名 ATRIUM_ERRORS_TELEGRAM_TOKEN。', + 'telegram_chat' => 'Telegram 聊天 ID', + 'alert_new' => '出现新错误时告警', + 'alert_regression' => '已解决的错误再次出现时告警', + 'spike_per_hour' => '激增:单个错误每小时的事件数', + 'spike_per_hour_hint' => '一小时内超过此数量会发送告警。0:关闭。', + 'browser_site' => '捕获站点上的 JavaScript 错误', + 'browser_admin' => '捕获后台中的 JavaScript 错误', + ], + + 'alerts' => [ + 'purpose' => '错误告警', + 'subject' => [ + 'new' => ':site 上出现新错误::class', + 'regression' => ':site 上的错误再次出现::class', + 'spike' => ':site 上的错误激增::class', + ], + 'where' => '位置::place', + 'counts' => '事件::events,用户::users', + 'release' => '版本::release', + ], + + 'prune' => [ + 'invalid' => '天数必须为 1 或更大。', + 'done' => '已删除 :days 天前的 :events 个事件和 :issues 个错误。', + ], + + 'test' => [ + 'no_drivers' => '未启用任何错误驱动。', + 'message' => 'Atrium errors: 测试错误,可放心标记为已解决', + 'skipped' => '未发送:跟踪已关闭,或被采样或每分钟上限丢弃。', + 'sent' => '测试错误 :id 已发送到::drivers。', + ], +]; diff --git a/packages/errors/phpunit.xml.dist b/packages/errors/phpunit.xml.dist new file mode 100644 index 00000000..8fdc2ec8 --- /dev/null +++ b/packages/errors/phpunit.xml.dist @@ -0,0 +1,16 @@ + + + + + tests + + + + + src + + + diff --git a/packages/errors/resources/js/atrium-errors.js b/packages/errors/resources/js/atrium-errors.js new file mode 100644 index 00000000..3574dde0 --- /dev/null +++ b/packages/errors/resources/js/atrium-errors.js @@ -0,0 +1,66 @@ +/* + * This file is part of Atrium (https://github.com/AlveBy/atrium). + * Copyright (c) 2026 AlveBy. Licensed under the MIT License, see LICENSE. + */ + +/* + * Reports JavaScript errors of the page to the site, at most five per page + * and never the same one twice. Sends only the error itself: the message, + * its type and the stack. The server adds the page address and scrubs it. + */ +(function () { + var script = document.currentScript; + if (!script || !window.JSON) { + return; + } + + var endpoint = script.getAttribute('data-endpoint'); + var source = script.getAttribute('data-source') || 'site'; + var sent = {}; + var left = 5; + + function send(report) { + var key = report.message + '|' + report.url + '|' + report.line; + if (!endpoint || left <= 0 || sent[key]) { + return; + } + sent[key] = true; + left--; + + var body = JSON.stringify(report).slice(0, 16000); + try { + if (navigator.sendBeacon && navigator.sendBeacon(endpoint, new Blob([body], { type: 'application/json' }))) { + return; + } + fetch(endpoint, { method: 'POST', body: body, keepalive: true, credentials: 'same-origin', headers: { 'Content-Type': 'application/json' } }); + } catch (e) { + // Reporting must never break the page. + } + } + + function fromError(error, fallback) { + error = error || {}; + return { + message: String(error.message || fallback.message || 'Unknown error').slice(0, 1000), + name: String(error.name || 'Error').slice(0, 64), + stack: String(error.stack || '').slice(0, 10000), + url: String(fallback.url || ''), + line: fallback.line || 0, + column: fallback.column || 0, + source: source + }; + } + + window.addEventListener('error', function (event) { + // A failed or ', + e(route('atrium.errors.script', [], false)), + e(route('atrium.errors.browser', [], false)), + $source, + $nonce !== null ? ' nonce="'.e($nonce).'"' : '', + ); + + $response->setContent(substr($content, 0, $head).$tag.substr($content, $head)); + + return $response; + } + + private function isAdmin(Request $request): bool + { + $prefix = trim((string) config('atrium.prefix', 'admin'), '/'); + + return $request->is($prefix, $prefix.'/*'); + } + + private function isHtmlPage(Request $request, Response $response): bool + { + return $response->getStatusCode() < 300 + && ! $request->headers->has('X-Inertia') + && str_contains((string) $response->headers->get('Content-Type'), 'text/html') + && ! $response->headers->has('Content-Disposition'); + } +} diff --git a/packages/errors/src/Menu.php b/packages/errors/src/Menu.php new file mode 100644 index 00000000..167e8311 --- /dev/null +++ b/packages/errors/src/Menu.php @@ -0,0 +1,61 @@ + + * `site-health`), the other adds its entries to it. Each module carries the + * group's label, so either works alone. + */ +final class Menu +{ + public const GROUP = 'site-health'; + + public const ROUTE = 'admin.errors.index'; + + /** + * Left out for an administrator who may not open it. + * + * @param array> $menu + * @return array> + */ + public static function add(array $menu, mixed $user = null): array + { + if (($user !== null && ! AuthorizeErrors::allows($user)) || str_contains((string) json_encode($menu), '"'.self::ROUTE.'"')) { + return $menu; + } + + $entry = ['label' => 'atrium-errors::errors.title', 'route' => self::ROUTE, 'icon' => 'info']; + + foreach ($menu as $index => $item) { + if (($item['key'] ?? null) === self::GROUP) { + $menu[$index]['children'] = [...($item['children'] ?? []), $entry]; + + return $menu; + } + } + + $group = ['key' => self::GROUP, 'label' => 'atrium-errors::errors.health', 'icon' => 'chart', 'children' => [$entry]]; + + // Before "Modules", which stays last. + $modules = array_search('admin.modules.index', array_map(static fn (array $item): mixed => $item['route'] ?? null, $menu), true); + + if ($modules === false) { + $menu[] = $group; + } else { + array_splice($menu, (int) $modules, 0, [$group]); + } + + return $menu; + } +} diff --git a/packages/errors/src/Models/Issue.php b/packages/errors/src/Models/Issue.php new file mode 100644 index 00000000..85c38870 --- /dev/null +++ b/packages/errors/src/Models/Issue.php @@ -0,0 +1,103 @@ + self::NEW, + 'times_seen' => 0, + 'users_seen' => 0, + ]; + + protected function casts(): array + { + return [ + 'times_seen' => 'integer', + 'users_seen' => 'integer', + 'first_seen_at' => 'datetime', + 'last_seen_at' => 'datetime', + 'resolved_at' => 'datetime', + 'regressed_at' => 'datetime', + ]; + } + + /** + * @return HasMany + */ + public function occurrences(): HasMany + { + return $this->hasMany(Occurrence::class, 'issue_id'); + } + + /** + * Only the issues seen on a site the administrator may see. + * + * @param Builder $query + * @return Builder + */ + protected function scopeVisible(Builder $query): Builder + { + $sites = SiteAccess::ids(); + + return $sites === null ? $query : $query->whereHas('occurrences', static fn (Builder $occurrences) => $occurrences->whereIn('site_id', $sites)); + } + + /** + * Whether an event of this release brings a resolved issue back. + */ + public function reopensIn(string $release): bool + { + return $this->status === self::RESOLVED && ($this->resolved_in === null || $this->resolved_in !== $release); + } +} diff --git a/packages/errors/src/Models/Occurrence.php b/packages/errors/src/Models/Occurrence.php new file mode 100644 index 00000000..e1e3ffab --- /dev/null +++ b/packages/errors/src/Models/Occurrence.php @@ -0,0 +1,64 @@ + $payload + * @property Carbon|null $created_at + */ +final class Occurrence extends Model +{ + public const UPDATED_AT = null; + + protected $table = 'error_events'; + + protected $guarded = ['id']; + + protected function casts(): array + { + return [ + 'payload' => 'array', + 'site_id' => 'integer', + 'user_id' => 'integer', + 'created_at' => 'datetime', + ]; + } + + /** + * Only the events of the sites the administrator may see. + * + * @param Builder $query + * @return Builder + */ + protected function scopeVisible(Builder $query): Builder + { + $sites = SiteAccess::ids(); + + return $sites === null ? $query : $query->whereIn($this->qualifyColumn('site_id'), $sites); + } +} diff --git a/packages/errors/src/Pipeline/DeliverEvent.php b/packages/errors/src/Pipeline/DeliverEvent.php new file mode 100644 index 00000000..9a4e6630 --- /dev/null +++ b/packages/errors/src/Pipeline/DeliverEvent.php @@ -0,0 +1,35 @@ + $event + */ + public function __construct(public readonly array $event) {} + + public function handle(Sender $sender): void + { + $sender->deliver(Event::fromArray($this->event)); + } +} diff --git a/packages/errors/src/Pipeline/Drivers.php b/packages/errors/src/Pipeline/Drivers.php new file mode 100644 index 00000000..4e7ea844 --- /dev/null +++ b/packages/errors/src/Pipeline/Drivers.php @@ -0,0 +1,66 @@ + DatabaseReporter::class, + 'sentry' => SentryReporter::class, + 'log' => LogReporter::class, + ]; + + public function __construct( + private readonly Container $container, + ) {} + + /** + * Every known driver: name => class. + * + * @return array + */ + public function known(): array + { + $custom = array_filter((array) config('atrium-errors.reporters', []), static fn (mixed $class): bool => is_string($class) && is_subclass_of($class, ErrorReporter::class)); + + return [...self::BUILT_IN, ...$custom]; + } + + /** + * The drivers switched on, resolved; unknown names are skipped. + * + * @return array + */ + public function active(): array + { + $known = $this->known(); + $active = []; + + // Resolved each time: the sender keeps this object for the whole + // process, the settings live as long as a request or a job. + foreach ($this->container->make(Options::class)->drivers() as $name) { + if (isset($known[$name])) { + $active[$name] = $this->container->make($known[$name]); + } + } + + return $active; + } +} diff --git a/packages/errors/src/Pipeline/Sender.php b/packages/errors/src/Pipeline/Sender.php new file mode 100644 index 00000000..acefe507 --- /dev/null +++ b/packages/errors/src/Pipeline/Sender.php @@ -0,0 +1,119 @@ + */ + private array $buffer = []; + + private bool $flushRegistered = false; + + public function __construct( + private readonly Application $app, + private readonly Drivers $drivers, + private readonly FallbackLog $fallback, + ) {} + + public function send(Event $event): void + { + $connection = config('atrium-errors.queue'); + + if (is_string($connection) && $connection !== '') { + try { + $this->app->make(Queue::class)->connection($connection)->push(new DeliverEvent($event->toArray())); + + return; + } catch (Throwable) { + // No queue right now: keep it here. + } + } + + if ($this->app->runningInConsole()) { + $this->deliver($event); + + return; + } + + if (count($this->buffer) >= self::BUFFER) { + return; + } + + $this->buffer[] = $event; + + if (! $this->flushRegistered) { + $this->flushRegistered = true; + $this->app->terminating(fn () => $this->flush()); + } + } + + private function flush(): void + { + $events = $this->buffer; + $this->buffer = []; + + foreach ($events as $event) { + $this->deliver($event); + } + } + + public function deliver(Event $event): void + { + try { + $drivers = $this->drivers->active(); + } catch (Throwable $e) { + $this->fallback->write($event, $e); + $drivers = []; + } + + foreach ($drivers as $name => $driver) { + try { + $driver->report($event); + } catch (Throwable $e) { + if ($name === 'database') { + $this->fallback->write($event, $e); + } else { + $this->fallback->note($name.' driver failed: '.$e::class.': '.$e->getMessage()); + } + } + } + } + + /** + * Events still waiting: for tests. + * + * @return array + */ + public function pending(): array + { + return $this->buffer; + } +} diff --git a/packages/errors/src/Reporters/DatabaseReporter.php b/packages/errors/src/Reporters/DatabaseReporter.php new file mode 100644 index 00000000..5979a364 --- /dev/null +++ b/packages/errors/src/Reporters/DatabaseReporter.php @@ -0,0 +1,124 @@ +record($event); + + $this->alerter->consider($issue, $outcome); + } + + /** + * @return array{0:Issue,1:string} + */ + public function record(Event $event): array + { + return DB::transaction(function () use ($event): array { + $now = $event->timestamp; + $issue = Issue::query()->where('fingerprint', $event->fingerprint)->lockForUpdate()->first(); + $outcome = self::OUTCOME_SEEN; + + if ($issue === null) { + try { + // A savepoint: on PostgreSQL a failed insert spoils the + // whole transaction otherwise. + $issue = DB::transaction(fn (): Issue => Issue::query()->create([ + 'fingerprint' => $event->fingerprint, + 'kind' => $event->kind, + 'level' => $event->level, + 'class' => mb_substr($event->class, 0, 255), + 'message' => $event->message, + 'culprit' => $this->cut($event->culprit()), + 'first_release' => $event->release, + 'first_seen_at' => $now, + ])); + $outcome = self::OUTCOME_NEW; + } catch (UniqueConstraintViolationException) { + // Another process created it a moment ago. + $issue = Issue::query()->where('fingerprint', $event->fingerprint)->lockForUpdate()->firstOrFail(); + } + } + + if ($issue->reopensIn($event->release)) { + $issue->status = Issue::NEW; + $issue->resolved_in = null; + $issue->resolved_at = null; + $issue->regressed_at = $now; + $outcome = self::OUTCOME_REGRESSION; + } + + $userId = $event->userId(); + $newUser = $userId !== null && ! Occurrence::query()->where('issue_id', $issue->id)->where('user_id', $userId)->exists(); + + Occurrence::query()->create([ + 'issue_id' => $issue->id, + 'site_id' => $event->request['site_id'] ?? null, + 'level' => $event->level, + 'release' => $event->release, + 'environment' => mb_substr($event->environment, 0, 32), + 'method' => isset($event->request['method']) ? mb_substr((string) $event->request['method'], 0, 8) : null, + 'path' => $event->request['path'] ?? null, + 'route' => $this->cut($event->request['route'] ?? null), + 'locale' => isset($event->request['locale']) ? mb_substr((string) $event->request['locale'], 0, 16) : null, + 'user_id' => $userId, + 'payload' => [ + 'id' => $event->id, + 'kind' => $event->kind, + 'exceptions' => $event->exceptions, + 'request' => $event->request, + 'context' => $event->context, + 'breadcrumbs' => $event->breadcrumbs, + 'runtime' => $event->runtime, + ], + 'created_at' => $now, + ]); + + $issue->times_seen++; + $issue->users_seen += $newUser ? 1 : 0; + $issue->level = $event->level; + $issue->message = $event->message; + $issue->last_release = $event->release; + $issue->last_seen_at = $now; + $issue->save(); + + return [$issue, $outcome]; + }); + } + + private function cut(?string $value): ?string + { + return $value === null ? null : mb_substr($value, 0, 255); + } +} diff --git a/packages/errors/src/Reporters/LogReporter.php b/packages/errors/src/Reporters/LogReporter.php new file mode 100644 index 00000000..c138b7b4 --- /dev/null +++ b/packages/errors/src/Reporters/LogReporter.php @@ -0,0 +1,42 @@ +level) { + 'fatal' => 'critical', + 'warning' => 'warning', + 'info' => 'info', + default => 'error', + }; + + $this->log->channel((string) config('logging.default'))->log($level, '[atrium-errors] '.$event->class.': '.$event->message, [ + 'fingerprint' => $event->fingerprint, + 'kind' => $event->kind, + 'release' => $event->release, + 'culprit' => $event->culprit(), + 'path' => $event->request['path'] ?? null, + 'user_id' => $event->userId(), + ]); + } +} diff --git a/packages/errors/src/Reporters/Sentry/Dsn.php b/packages/errors/src/Reporters/Sentry/Dsn.php new file mode 100644 index 00000000..c9b33db8 --- /dev/null +++ b/packages/errors/src/Reporters/Sentry/Dsn.php @@ -0,0 +1,75 @@ +scheme.'://'.$this->host.($this->port !== null ? ':'.$this->port : '').$this->path.'/api/'.$this->projectId.'/envelope/'; + } + + public function authHeader(string $client): string + { + return 'Sentry sentry_version=7, sentry_client='.$client.', sentry_key='.$this->publicKey; + } + + public function __toString(): string + { + return $this->original; + } +} diff --git a/packages/errors/src/Reporters/Sentry/HttpTransport.php b/packages/errors/src/Reporters/Sentry/HttpTransport.php new file mode 100644 index 00000000..7f75a828 --- /dev/null +++ b/packages/errors/src/Reporters/Sentry/HttpTransport.php @@ -0,0 +1,60 @@ +http + ->timeout($this->timeout) + ->withHeaders([ + 'X-Sentry-Auth' => $dsn->authHeader(self::CLIENT), + 'Content-Type' => 'application/x-sentry-envelope', + ]) + ->withBody(self::envelope($dsn, $event), 'application/x-sentry-envelope') + ->post($dsn->envelopeUrl()); + + if ($response->failed()) { + throw new RuntimeException('Sentry answered '.$response->status()); + } + } + + /** + * Header, item header and the event, one JSON per line. + * + * @param array $event + */ + public static function envelope(Dsn $dsn, array $event): string + { + $flags = JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_PARTIAL_OUTPUT_ON_ERROR | JSON_THROW_ON_ERROR; + $body = json_encode($event, $flags); + + return implode("\n", [ + json_encode(['event_id' => $event['event_id'] ?? null, 'dsn' => (string) $dsn, 'sent_at' => gmdate('Y-m-d\TH:i:s\Z')], $flags), + json_encode(['type' => 'event', 'length' => strlen($body)], $flags), + $body, + ])."\n"; + } +} diff --git a/packages/errors/src/Reporters/Sentry/Transport.php b/packages/errors/src/Reporters/Sentry/Transport.php new file mode 100644 index 00000000..eca039d8 --- /dev/null +++ b/packages/errors/src/Reporters/Sentry/Transport.php @@ -0,0 +1,22 @@ + $event the event in the Sentry format + */ + public function send(Dsn $dsn, array $event): void; +} diff --git a/packages/errors/src/Reporters/SentryReporter.php b/packages/errors/src/Reporters/SentryReporter.php new file mode 100644 index 00000000..97a23a18 --- /dev/null +++ b/packages/errors/src/Reporters/SentryReporter.php @@ -0,0 +1,117 @@ +options->string('sentry_dsn'); + + if ($dsn === '') { + return; + } + + $this->transport->send(Dsn::parse($dsn), self::payload($event)); + } + + /** + * The event in the Sentry format. + * + * @return array + */ + public static function payload(Event $event): array + { + $exceptions = []; + + // Sentry lists the chain innermost first and frames oldest first. + foreach (array_reverse($event->exceptions) as $exception) { + $exceptions[] = [ + 'type' => $exception['class'], + 'value' => $exception['message'], + 'stacktrace' => ['frames' => array_map(self::frame(...), array_reverse($exception['frames']))], + ]; + } + + $request = $event->request; + + return array_filter([ + 'event_id' => $event->id, + 'timestamp' => $event->timestamp->getTimestamp() + $event->timestamp->micro / 1_000_000, + 'platform' => $event->kind === 'browser' ? 'javascript' : 'php', + 'level' => $event->level, + 'logger' => 'atrium-errors', + 'release' => $event->release, + 'environment' => $event->environment, + 'message' => $event->kind === 'message' ? ['formatted' => $event->message] : null, + 'exception' => $event->kind === 'message' ? null : ['values' => $exceptions], + 'fingerprint' => [$event->fingerprint], + 'request' => isset($request['url']) ? array_filter(['url' => $request['url'], 'method' => $request['method'] ?? null]) : null, + 'user' => $event->userId() !== null ? ['id' => (string) $event->userId()] : null, + 'tags' => array_filter([ + 'kind' => $event->kind, + 'route' => $request['route'] ?? null, + 'site' => isset($request['site_id']) ? (string) $request['site_id'] : null, + 'locale' => $request['locale'] ?? null, + ], static fn (mixed $value): bool => $value !== null && $value !== ''), + 'extra' => $event->context !== [] ? $event->context : null, + 'breadcrumbs' => $event->breadcrumbs !== [] ? ['values' => array_map(static fn (array $crumb): array => [ + 'category' => $crumb['category'], + 'message' => $crumb['message'], + 'level' => str_contains($crumb['category'], 'error') ? 'error' : 'info', + ], $event->breadcrumbs)] : null, + 'contexts' => [ + 'runtime' => ['name' => 'php', 'version' => $event->runtime['php'] ?? null], + 'framework' => ['name' => 'Laravel', 'version' => $event->runtime['laravel'] ?? null], + 'os' => ['name' => $event->runtime['os'] ?? null], + ], + ], static fn (mixed $value): bool => $value !== null); + } + + /** + * @param array $frame + * @return array + */ + private static function frame(array $frame): array + { + $context = $frame['context'] ?? null; + + return array_filter([ + 'filename' => $frame['file'] ?? '', + 'lineno' => $frame['line'] ?? 0, + 'function' => ($frame['function'] ?? '') !== '' ? $frame['function'] : null, + 'in_app' => (bool) ($frame['in_app'] ?? false), + 'pre_context' => $context['pre'] ?? null, + 'context_line' => $context['line'] ?? null, + 'post_context' => $context['post'] ?? null, + ], static fn (mixed $value): bool => $value !== null); + } +} diff --git a/packages/errors/src/Support/FallbackLog.php b/packages/errors/src/Support/FallbackLog.php new file mode 100644 index 00000000..769303af --- /dev/null +++ b/packages/errors/src/Support/FallbackLog.php @@ -0,0 +1,58 @@ + $event->timestamp->toIso8601ZuluString(), + 'reason' => $reason !== null ? $reason::class.': '.mb_substr($reason->getMessage(), 0, 300) : null, + 'event' => $event->toArray(), + ]; + + $this->append((string) json_encode($line, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_PARTIAL_OUTPUT_ON_ERROR)); + } + + /** + * When even building the event failed: the bare minimum. + */ + public function note(string $message): void + { + $this->append((string) json_encode(['time' => gmdate('c'), 'note' => mb_substr($message, 0, 1000)], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES)); + } + + public function path(): string + { + return $this->path; + } + + private function append(string $line): void + { + $folder = dirname($this->path); + + if (! is_dir($folder)) { + @mkdir($folder, 0775, true); + } + + @file_put_contents($this->path, $line.PHP_EOL, FILE_APPEND | LOCK_EX); + } +} diff --git a/packages/errors/src/Support/Frequency.php b/packages/errors/src/Support/Frequency.php new file mode 100644 index 00000000..b8c49685 --- /dev/null +++ b/packages/errors/src/Support/Frequency.php @@ -0,0 +1,84 @@ + + */ + public function hourly(?int $issueId = null): array + { + $now = CarbonImmutable::now()->startOfHour(); + + return $this->series($issueId, $now->subHours(23), 24, 'hour', 'H:00'); + } + + /** + * The last 30 days, day by day. + * + * @return array + */ + public function daily(?int $issueId = null): array + { + $today = CarbonImmutable::now()->startOfDay(); + + return $this->series($issueId, $today->subDays(29), 30, 'day', 'D MMM'); + } + + /** + * @return array + */ + private function series(?int $issueId, CarbonImmutable $from, int $buckets, string $unit, string $format): array + { + $expression = self::bucketExpression((new Occurrence)->getConnection()->getDriverName(), $unit); + + $counts = Occurrence::query() + ->visible() + ->when($issueId !== null, static fn (Builder $query) => $query->where('issue_id', $issueId)) + ->where('created_at', '>=', $from) + ->selectRaw($expression.' as bucket, count(*) as total') + ->groupByRaw($expression) + ->pluck('total', 'bucket') + ->all(); + + $series = []; + + for ($i = 0; $i < $buckets; $i++) { + $moment = $unit === 'hour' ? $from->addHours($i) : $from->addDays($i); + $key = $moment->format($unit === 'hour' ? 'Y-m-d H' : 'Y-m-d'); + $series[] = ['label' => $moment->locale(app()->getLocale())->isoFormat($format), 'value' => (int) ($counts[$key] ?? 0)]; + } + + return $series; + } + + /** + * The SQL that turns created_at into "2026-11-17 14" or "2026-11-17". + */ + public static function bucketExpression(string $driver, string $unit): string + { + return match ($driver) { + 'mysql', 'mariadb' => $unit === 'hour' ? "DATE_FORMAT(created_at, '%Y-%m-%d %H')" : "DATE_FORMAT(created_at, '%Y-%m-%d')", + 'pgsql' => $unit === 'hour' ? "to_char(created_at, 'YYYY-MM-DD HH24')" : "to_char(created_at, 'YYYY-MM-DD')", + default => $unit === 'hour' ? "strftime('%Y-%m-%d %H', created_at)" : "strftime('%Y-%m-%d', created_at)", + }; + } +} diff --git a/packages/errors/src/Support/Limiter.php b/packages/errors/src/Support/Limiter.php new file mode 100644 index 00000000..01818cd9 --- /dev/null +++ b/packages/errors/src/Support/Limiter.php @@ -0,0 +1,93 @@ +random = $random ?? static fn (): float => mt_rand() / mt_getrandmax(); + } + + /** + * Whether this event may go on. + */ + public function allow(): bool + { + $rate = $this->options()->int('sample_rate'); + + if ($rate < 100 && ($this->random)() * 100 >= $rate) { + return false; + } + + $cap = $this->options()->int('per_minute'); + + return $cap <= 0 || $this->count() <= $cap; + } + + /** + * Use a fixed dice in tests. + * + * @param Closure(): float $random + */ + public function useRandom(Closure $random): void + { + $this->random = $random; + } + + /** + * Resolved each time: this object lives as long as the process, the + * settings only as long as a request or a job. + */ + private function options(): Options + { + return app(Options::class); + } + + private function count(): int + { + $minute = intdiv(now()->getTimestamp(), 60); + $key = 'atrium-errors:minute:'.$minute; + + try { + $this->cache->add($key, 0, 120); + + return (int) $this->cache->increment($key); + } catch (Throwable) { + if ($this->localMinute !== $minute) { + $this->localMinute = $minute; + $this->localCount = 0; + } + + return ++$this->localCount; + } + } +} diff --git a/packages/errors/src/Support/Options.php b/packages/errors/src/Support/Options.php new file mode 100644 index 00000000..e21b7c55 --- /dev/null +++ b/packages/errors/src/Support/Options.php @@ -0,0 +1,102 @@ + config key under atrium-errors. */ + public const MAP = [ + 'drivers' => 'drivers', + 'sentry_dsn' => 'sentry.dsn', + 'sample_rate' => 'sample_rate', + 'per_minute' => 'per_minute', + 'retention_days' => 'retention_days', + 'alert_email' => 'alerts.email', + 'telegram_token' => 'alerts.telegram_token', + 'telegram_chat' => 'alerts.telegram_chat', + 'alert_new' => 'alerts.new', + 'alert_regression' => 'alerts.regression', + 'spike_per_hour' => 'alerts.spike_per_hour', + 'browser_site' => 'browser.site', + 'browser_admin' => 'browser.admin', + ]; + + /** @var array|null */ + private ?array $saved = null; + + public function get(string $name): mixed + { + $saved = $this->saved(); + + if (array_key_exists($name, $saved) && $saved[$name] !== null && $saved[$name] !== '' && $saved[$name] !== []) { + return $saved[$name]; + } + + return config('atrium-errors.'.(self::MAP[$name] ?? $name)); + } + + public function int(string $name): int + { + return (int) $this->get($name); + } + + public function bool(string $name): bool + { + return filter_var($this->get($name), FILTER_VALIDATE_BOOLEAN); + } + + public function string(string $name): string + { + $value = $this->get($name); + + return is_scalar($value) ? trim((string) $value) : ''; + } + + /** + * @return array + */ + public function drivers(): array + { + $drivers = $this->get('drivers'); + $drivers = is_string($drivers) ? explode(',', $drivers) : (array) $drivers; + + return array_values(array_unique(array_filter(array_map(static fn (mixed $name): string => trim((string) $name), $drivers)))); + } + + /** + * Forget what was read: after the settings were saved, and between tests. + */ + public function flush(): void + { + $this->saved = null; + } + + /** + * @return array + */ + private function saved(): array + { + if ($this->saved !== null) { + return $this->saved; + } + + // Settings answers [] by itself when the database is down or not migrated. + return $this->saved = app(Settings::class)->stored('errors'); + } +} diff --git a/packages/errors/src/Support/SiteAccess.php b/packages/errors/src/Support/SiteAccess.php new file mode 100644 index 00000000..595a08eb --- /dev/null +++ b/packages/errors/src/Support/SiteAccess.php @@ -0,0 +1,37 @@ +|null + */ + public static function ids(): ?array + { + $user = auth((string) config('atrium.auth.guard', 'admin'))->user(); + + if (! $user instanceof AdminUser || (array) $user->site_ids === []) { + return null; + } + + return $user->allowedSites()->map(static fn ($site): int => $site->id)->values()->all(); + } +} diff --git a/packages/errors/tests/Feature/AdminTest.php b/packages/errors/tests/Feature/AdminTest.php new file mode 100644 index 00000000..e6734570 --- /dev/null +++ b/packages/errors/tests/Feature/AdminTest.php @@ -0,0 +1,367 @@ +issue(['message' => 'Open one', 'times_seen' => 4, 'users_seen' => 2]); + $this->issue(['message' => 'Done one', 'status' => Issue::RESOLVED]); + + $this->actingAs($this->admin(), 'admin') + ->get('/admin/errors') + ->assertOk() + ->assertInertia(fn (AssertableInertia $page) => $page + ->component('Admin/Errors/Index') + ->where('filters.status', 'new') + ->has('issues.data', 1) + ->where('issues.data.0.id', $open->id) + ->where('issues.data.0.short_class', 'RoomUnavailable') + ->where('issues.data.0.times_seen', 4) + ->where('issues.data.0.users_seen', 2) + ->where('issues.data.0.url', route('admin.errors.show', $open->id)) + ->where('options.statuses', ['new', 'resolved', 'ignored']) + ->where('options.releases', ['2.4.0']) + ->where('strings.title', 'Errors') + ->where('strings.issue.resolve_next', 'Resolve in next release')); + } + + public function test_the_list_is_filtered_and_sorted(): void + { + $site = Site::query()->create(['name' => 'Second site', 'code' => 'second', 'domains' => ['second.example.test'], 'is_active' => true]); + + $checkout = $this->issue(['class' => 'App\\Checkout\\PaymentFailed', 'message' => 'Gateway timeout', 'level' => 'fatal', 'times_seen' => 9]); + $this->occurrence($checkout, ['path' => '/checkout', 'release' => '2.3.0', 'site_id' => $site->id]); + $browser = $this->issue(['kind' => 'browser', 'class' => 'TypeError', 'message' => 'x is undefined', 'level' => 'error', 'times_seen' => 30, 'culprit' => 'renderGallery (/build/app.js)']); + $this->occurrence($browser, ['path' => '/gallery']); + $ignored = $this->issue(['status' => Issue::IGNORED, 'message' => 'Bot noise']); + + $this->actingAs($this->admin(), 'admin'); + $ids = fn (string $query): array => collect($this->get('/admin/errors?'.$query)->assertOk()->viewData('page')['props']['issues']['data'])->pluck('id')->all(); + + $this->assertSame([$checkout->id], $ids('q=gateway')); + $this->assertSame([$browser->id], $ids('q=renderGallery')); + $this->assertSame([], $ids('q=100%25')); + $this->assertSame([$checkout->id], $ids('level=fatal')); + $this->assertSame([$browser->id], $ids('kind=browser')); + $this->assertSame([$checkout->id], $ids('site='.$site->id)); + $this->assertSame([$checkout->id], $ids('release=2.3.0')); + $this->assertSame([$checkout->id], $ids('path=checkout?step=2')); + $this->assertSame([$browser->id, $checkout->id], $ids('sort=times_seen')); + $this->assertSame([$ignored->id], $ids('status=ignored')); + $this->assertCount(3, $ids('status=all')); + // Unknown values fall back to the defaults instead of failing. + $this->assertCount(2, $ids('status=deleted&level=loud&kind=cron&sort=name&site=abc')); + } + + public function test_an_issue_shows_its_last_event_occurrences_and_chart(): void + { + $issue = $this->issue(['times_seen' => 2, 'resolved_in' => null]); + $old = $this->occurrence($issue, ['created_at' => now()->subHours(3), 'path' => '/rooms/1', 'user_id' => 7]); + $new = $this->occurrence($issue, ['path' => '/rooms/2', 'site_id' => 999]); + + $this->actingAs($this->admin(), 'admin') + ->get('/admin/errors/'.$issue->id) + ->assertOk() + ->assertInertia(fn (AssertableInertia $page) => $page + ->component('Admin/Errors/Show') + ->where('issue.id', $issue->id) + ->where('issue.message', $issue->message) + ->where('event.id', $new->id) + ->where('event.site', '#999') + ->has('event.uuid') + ->has('event.exceptions.0.frames') + ->has('occurrences.data', 2) + ->where('occurrences.data.1.user_id', 7) + ->where('top.paths', [['value' => '/rooms/1', 'count' => 1], ['value' => '/rooms/2', 'count' => 1]]) + ->where('top.releases', [['value' => '2.4.0', 'count' => 2]]) + ->has('chart.hourly', 24) + ->has('chart.daily', 30) + ->where('chart.hourly.23.value', 1) + ->where('chart.hourly.20.value', 1) + ->where('currentRelease', '2.4.0') + ->missing('monitoring')); + + $this->get('/admin/errors/'.$issue->id.'?event='.$old->id) + ->assertInertia(fn (AssertableInertia $page) => $page->where('event.id', $old->id)); + $this->get('/admin/errors/'.$issue->id.'?event=999999') + ->assertInertia(fn (AssertableInertia $page) => $page->where('event.id', $new->id)); + } + + public function test_an_issue_whose_events_were_pruned_still_opens(): void + { + $issue = $this->issue(); + + $this->actingAs($this->admin(), 'admin') + ->get('/admin/errors/'.$issue->id) + ->assertOk() + ->assertInertia(fn (AssertableInertia $page) => $page->where('event', null)); + + $this->get('/admin/errors/999999')->assertNotFound(); + $this->get('/admin/errors/abc')->assertNotFound(); + } + + public function test_the_status_is_changed(): void + { + $issue = $this->issue(); + $this->actingAs($this->admin(), 'admin')->from('/admin/errors/'.$issue->id); + + $this->post('/admin/errors/'.$issue->id.'/status', ['status' => 'resolved']) + ->assertRedirect('/admin/errors/'.$issue->id) + ->assertSessionHas('success', 'The error is resolved.'); + $issue->refresh(); + $this->assertSame(Issue::RESOLVED, $issue->status); + $this->assertNotNull($issue->resolved_at); + $this->assertNull($issue->resolved_in); + + $this->post('/admin/errors/'.$issue->id.'/status', ['status' => 'resolved', 'next_release' => true]); + $this->assertSame('2.4.0', $issue->refresh()->resolved_in); + + $this->post('/admin/errors/'.$issue->id.'/status', ['status' => 'ignored'])->assertSessionHas('success', 'The error is ignored.'); + $issue->refresh(); + $this->assertSame(Issue::IGNORED, $issue->status); + $this->assertNull($issue->resolved_at); + $this->assertNull($issue->resolved_in); + + $this->post('/admin/errors/'.$issue->id.'/status', ['status' => 'new'])->assertSessionHas('success', 'The error is open again.'); + $this->assertSame(Issue::NEW, $issue->refresh()->status); + } + + public function test_a_wrong_status_is_refused(): void + { + $issue = $this->issue(); + $this->actingAs($this->admin(), 'admin'); + + $this->post('/admin/errors/'.$issue->id.'/status', ['status' => 'deleted'])->assertSessionHasErrors('status'); + $this->post('/admin/errors/'.$issue->id.'/status', [])->assertSessionHasErrors('status'); + $this->post('/admin/errors/'.$issue->id.'/status', ['status' => 'resolved', 'next_release' => 'maybe'])->assertSessionHasErrors('next_release'); + + $this->assertSame(Issue::NEW, $issue->refresh()->status); + } + + public function test_only_administrators_with_the_permission_get_in(): void + { + $issue = $this->issue(); + + $this->get('/admin/errors')->assertRedirect(); + + $this->actingAs($this->editor(['news.view']), 'admin'); + $this->get('/admin/errors')->assertForbidden(); + $this->get('/admin/errors/'.$issue->id)->assertForbidden(); + $this->post('/admin/errors/'.$issue->id.'/status', ['status' => 'ignored'])->assertForbidden(); + $this->assertSame(Issue::NEW, $issue->refresh()->status); + + // Settings alone do not open the errors: they are a separate right. + $this->actingAs($this->editor(['errors.settings']), 'admin'); + $this->get('/admin/errors')->assertForbidden(); + $this->get('/admin/modules/errors/settings')->assertOk(); + + // Support: reads and triages errors, may not change where they go. + $this->actingAs($this->editor(['errors.view']), 'admin'); + $this->get('/admin/errors')->assertOk(); + $this->get('/admin/errors/'.$issue->id)->assertOk(); + $this->post('/admin/errors/'.$issue->id.'/status', ['status' => 'ignored'])->assertRedirect(); + $this->assertSame(Issue::IGNORED, $issue->refresh()->status); + $this->get('/admin/modules/errors/settings')->assertForbidden(); + $this->put('/admin/modules/errors/settings', ['drivers' => ['log']])->assertForbidden(); + $this->assertSame(['database'], $this->app->make(Options::class)->drivers()); + } + + public function test_both_rights_are_in_the_role_form_and_view_comes_with_settings(): void + { + $section = collect($this->app->make(Permissions::class)->sections())->firstWhere('key', 'errors'); + + $this->assertSame(['settings', 'view'], $section['actions']); + $this->assertSame('View errors', $section['labels']['view']); + + $module = Module::fromPath(dirname(__DIR__, 2)); + $this->assertSame(['errors.view' => ['label' => 'atrium-errors::errors.permissions.view', 'with' => 'errors.settings']], $module?->declaredPermissions); + + // The core's installer gives "view" to the roles that may set the module up. + } + + public function test_an_administrator_of_one_site_sees_only_its_errors(): void + { + $main = Site::query()->where('is_default', true)->firstOrFail(); + $other = Site::query()->create(['code' => 'coast', 'name' => 'Coast Hotels', 'domains' => ['coast.example.test'], 'languages' => ['en']]); + $mine = $this->issue(['class' => 'App\\Mine']); + $this->occurrence($mine, ['site_id' => $main->id, 'path' => '/mine', 'release' => '2.4.0']); + $theirs = $this->issue(['class' => 'App\\Theirs', 'last_release' => '9.9.9']); + $theirEvent = $this->occurrence($theirs, ['site_id' => $other->id, 'path' => '/theirs', 'release' => '9.9.9']); + $shared = $this->issue(['class' => 'App\\Shared']); + $sharedHere = $this->occurrence($shared, ['site_id' => $main->id, 'path' => '/shared-main']); + $this->occurrence($shared, ['site_id' => $other->id, 'path' => '/shared-coast']); + $console = $this->issue(['class' => 'App\\Console']); + $this->occurrence($console, ['site_id' => null]); + + $editor = $this->editor(['errors.view']); + $editor->update(['site_ids' => [(string) $main->id]]); + $this->actingAs($editor, 'admin'); + + $this->get('/admin/errors?status=all')->assertOk()->assertInertia(fn (AssertableInertia $page) => $page + ->where('issues.data', fn ($rows): bool => collect($rows)->pluck('id')->sort()->values()->all() === [$mine->id, $shared->id]) + ->where('options.sites', [['id' => $main->id, 'name' => $main->name]]) + ->where('options.releases', ['2.4.0'])); + $this->get('/admin/errors/'.$theirs->id)->assertNotFound(); + $this->get('/admin/errors/'.$console->id)->assertNotFound(); + $this->post('/admin/errors/'.$theirs->id.'/status', ['status' => 'ignored'])->assertNotFound(); + $this->assertSame(Issue::NEW, $theirs->refresh()->status); + + // A shared bug opens with this site's events only, even when asked for the other one. + $this->get('/admin/errors/'.$shared->id.'?event='.$theirEvent->id)->assertOk()->assertInertia(fn (AssertableInertia $page) => $page + ->where('event.id', $sharedHere->id) + ->has('occurrences.data', 1) + ->where('top.paths', [['value' => '/shared-main', 'count' => 1]]) + ->where('chart.hourly.23.value', 1)); + + $tile = (new ErrorsGadget)->data(); + $this->assertSame(2, $tile['events']); + $this->assertSame(2, $tile['unresolved']); + $this->assertEqualsCanonicalizing([$mine->id, $shared->id], array_column($tile['top'], 'id')); + + // An administrator of every site sees them all, and the errors outside any site. + $this->actingAs($this->editor(['errors.view']), 'admin'); + $this->get('/admin/errors?status=all')->assertInertia(fn (AssertableInertia $page) => $page->has('issues.data', 4)->has('options.sites', 2)); + $this->get('/admin/errors/'.$console->id)->assertOk(); + $this->assertSame(5, (new ErrorsGadget)->data()['events']); + } + + public function test_the_menu_gets_a_site_health_group(): void + { + $items = $this->app->make(AdminMenu::class)->items($this->admin()); + $group = collect($items)->firstWhere('key', Menu::GROUP); + + $this->assertSame('Site health', $group['label']); + $this->assertSame([['label' => 'Errors', 'route' => 'admin.errors.index', 'icon' => 'info']], $group['children']); + // Before "Modules", which stays last. + $this->assertSame('admin.modules.index', end($items)['route']); + + $this->assertNull(collect($this->app->make(AdminMenu::class)->items($this->editor(['news.view'])))->firstWhere('key', Menu::GROUP)); + } + + public function test_the_menu_joins_a_site_health_group_another_module_made(): void + { + $monitoring = [['label' => 'Dashboard', 'route' => 'admin.dashboard'], ['key' => 'site-health', 'label' => 'Site health', 'children' => [['label' => 'Speed', 'route' => 'admin.monitoring.pages']]]]; + + $menu = Menu::add($monitoring); + + $this->assertSame(['admin.monitoring.pages', 'admin.errors.index'], array_column($menu[1]['children'], 'route')); + $this->assertSame($menu, Menu::add($menu), 'Added once'); + $this->assertSame([['label' => 'X'], ['key' => 'site-health', 'label' => 'atrium-errors::errors.health', 'icon' => 'chart', 'children' => [['label' => 'atrium-errors::errors.title', 'route' => 'admin.errors.index', 'icon' => 'info']]]], Menu::add([['label' => 'X']])); + } + + public function test_the_dashboard_tile_counts_the_last_day(): void + { + $noisy = $this->issue(['class' => 'App\\Feeds\\Timeout', 'first_seen_at' => now()->subHours(2)]); + foreach (range(1, 3) as $i) { + $this->occurrence($noisy); + } + $back = $this->issue(['regressed_at' => now()->subHour(), 'first_seen_at' => now()->subDays(5)]); + $this->occurrence($back); + $this->occurrence($back, ['created_at' => now()->subDays(2)]); + $this->issue(['status' => Issue::RESOLVED, 'first_seen_at' => now()->subDays(9)]); + + $gadget = new ErrorsGadget(['width' => 'full', 'title' => 'Bugs']); + $data = $gadget->data(); + + $this->assertSame('ErrorsGadget', $gadget->component()); + $this->assertSame('Bugs', $gadget->title()); + $this->assertSame('full', $gadget->width()); + $this->assertSame('half', (new ErrorsGadget)->width()); + $this->assertSame('Errors in 24 hours', (new ErrorsGadget)->title()); + $this->assertSame(4, $data['events']); + $this->assertSame(1, $data['new']); + $this->assertSame(1, $data['regressed']); + $this->assertSame(2, $data['unresolved']); + $this->assertSame([3, 1], array_column($data['top'], 'count')); + $this->assertSame('Timeout', $data['top'][0]['class']); + $this->assertSame(route('admin.errors.show', $noisy->id), $data['top'][0]['url']); + $this->assertCount(24, $data['chart']); + $this->assertSame(4, $data['chart'][23]['value']); + $this->assertSame('No errors in the last 24 hours.', $data['strings']['none']); + } + + public function test_the_tile_is_on_the_dashboard_for_those_who_may_see_errors(): void + { + $this->assertContains(ErrorsGadget::class, config('atrium.dashboard.gadgets')); + + $this->actingAs($this->admin(), 'admin'); + $this->assertTrue((new ErrorsGadget)->isVisible()); + $this->get('/admin')->assertInertia(fn (AssertableInertia $page) => $page->where('gadgets', fn ($gadgets): bool => collect($gadgets)->contains('component', 'ErrorsGadget'))); + + $this->actingAs($this->editor(['news.view']), 'admin'); + $this->assertFalse((new ErrorsGadget)->isVisible()); + $this->assertFalse((new ErrorsGadget(['enabled' => false]))->isVisible()); + $this->assertInstanceOf(Gadget::class, new ErrorsGadget); + } + + public function test_the_settings_page_lists_every_setting_and_saves_them(): void + { + config(['atrium-errors.reporters' => ['rollbar' => PipelineTestReporter::class]]); + $fields = collect((new ErrorsSettings)->fields())->map(static fn ($field) => $field->toArray()); + + $this->assertSame( + ['drivers', 'sentry_dsn', 'sample_rate', 'per_minute', 'retention_days', 'alert_email', 'telegram_token', 'telegram_chat', 'alert_new', 'alert_regression', 'spike_per_hour', 'browser_site', 'browser_admin'], + $fields->pluck('name')->all(), + ); + $drivers = $fields->firstWhere('name', 'drivers'); + $this->assertStringContainsString('Sentry or GlitchTip', (string) json_encode($drivers)); + $this->assertStringContainsString('rollbar', (string) json_encode($drivers)); + $this->assertStringContainsString('ATRIUM_ERRORS_SENTRY_DSN', (string) json_encode($fields)); + + $this->actingAs($this->admin(), 'admin') + ->get('/admin/modules/errors/settings') + ->assertOk(); + + $this->put('/admin/modules/errors/settings', ['drivers' => ['database', 'log'], 'sentry_dsn' => 'not a dsn', 'sample_rate' => 101, 'telegram_token' => 'nope', 'telegram_chat' => 'x y']) + ->assertSessionHasErrors(['sentry_dsn', 'sample_rate', 'telegram_token', 'telegram_chat']); + + $this->put('/admin/modules/errors/settings', ['drivers' => ['database', 'log'], 'sentry_dsn' => 'https://key@sentry.example.test/5', 'sample_rate' => 50, 'per_minute' => 30, 'retention_days' => 30, 'telegram_token' => '123:abc_DEF', 'telegram_chat' => '@north_ops', 'alert_new' => true, 'alert_regression' => false, 'spike_per_hour' => 10, 'browser_site' => true, 'browser_admin' => false]) + ->assertSessionDoesntHaveErrors(); + + $options = $this->app->make(Options::class); + $options->flush(); + $this->assertSame(['database', 'log'], $options->drivers()); + $this->assertSame(50, $options->int('sample_rate')); + $this->assertFalse($options->bool('alert_regression')); + $this->assertTrue($options->bool('browser_site')); + } + + public function test_the_mail_module_knows_the_alert_purpose(): void + { + $this->assertSame('atrium-errors::errors.alerts.purpose', config('atrium-mail.purposes.errors')); + $this->assertSame('Error alerts', __(config('atrium-mail.purposes.errors'))); + } +} + +final class PipelineTestReporter implements ErrorReporter +{ + public function report(Event $event): void {} +} diff --git a/packages/errors/tests/Feature/AlertDetailsTest.php b/packages/errors/tests/Feature/AlertDetailsTest.php new file mode 100644 index 00000000..368bab79 --- /dev/null +++ b/packages/errors/tests/Feature/AlertDetailsTest.php @@ -0,0 +1,267 @@ +travelTo(CarbonImmutable::parse('2026-11-17 12:07:00 UTC')); + } + + public function test_an_alert_tells_what_where_how_often_and_where_to_look(): void + { + $issue = $this->issue(['times_seen' => 3, 'users_seen' => 1]); + $alert = new Alert($issue, Alerter::NEW); + + $this->assertSame([ + 'App\\Booking\\RoomUnavailable: Room 12 is not free on the chosen dates', + 'Where: App\\Booking\\Reserve::handle (app/Booking/Reserve.php)', + 'Events: 3, users: 1', + 'Release: 2.4.0', + ], $alert->lines()); + $this->assertSame(route('admin.errors.show', $issue->id), $alert->url()); + $this->assertSame( + "New error on Northwind Travel: RoomUnavailable\n\n".implode("\n", $alert->lines())."\n\n".route('admin.errors.show', $issue->id), + $alert->text(), + ); + } + + #[DataProvider('messages')] + public function test_the_message_of_an_alert_is_cut_by_characters_not_bytes(string $message, string $shown): void + { + $alert = new Alert($this->issue(['message' => $message, 'culprit' => null, 'last_release' => null]), Alerter::NEW); + + $this->assertSame('App\\Booking\\RoomUnavailable: '.$shown, $alert->lines()[0]); + } + + /** + * @return array + */ + public static function messages(): array + { + return [ + 'short' => ['Room 12', 'Room 12'], + 'longest kept' => [str_repeat('a', 300), str_repeat('a', 300)], + 'one too long' => [str_repeat('a', 301), str_repeat('a', 300)], + 'Cyrillic' => [str_repeat('я', 400), str_repeat('я', 300)], + 'Chinese' => [str_repeat('花', 400), str_repeat('花', 300)], + 'emoji' => [str_repeat('🪑', 400), str_repeat('🪑', 300)], + ]; + } + + public function test_the_mail_is_a_plain_text_view_of_the_alert(): void + { + $alert = new Alert($this->issue(), Alerter::SPIKE); + $content = (new AlertMail($alert))->content(); + + $this->assertSame('atrium-errors::mail.alert', $content->text); + $this->assertSame(['text' => $alert->text()], $content->with); + } + + public function test_the_site_name_in_the_subject_is_the_application_name(): void + { + config(['app.name' => 'Рога и копыта']); + + $this->assertSame('Error spike on Рога и копыта: RoomUnavailable', (new Alert($this->issue(), Alerter::SPIKE))->subject()); + } + + public function test_a_new_error_is_remembered_for_thirty_days(): void + { + $this->settings(['alert_email' => 'ops@example.com']); + $alerter = $this->app->make(Alerter::class); + $issue = $this->issue(); + + $this->assertSame(Alerter::NEW, $alerter->consider($issue, DatabaseReporter::OUTCOME_NEW)); + $this->assertTrue(Cache::get('atrium-errors:alert:new:'.$issue->id)); + $this->assertFalse(Cache::has('atrium-errors:alert:new:'.($issue->id + 1))); + + $this->travel(30 * 86400 - 1)->seconds(); + $this->assertNull($alerter->consider($issue, DatabaseReporter::OUTCOME_NEW)); + + $this->travel(1)->seconds(); + $this->assertSame(Alerter::NEW, $alerter->consider($issue, DatabaseReporter::OUTCOME_NEW)); + } + + public function test_a_spike_is_remembered_for_an_hour(): void + { + $this->settings(['alert_email' => 'ops@example.com', 'alert_new' => false, 'spike_per_hour' => 2]); + $reporter = $this->app->make(DatabaseReporter::class); + $alerter = $this->app->make(Alerter::class); + $consider = function () use ($reporter, $alerter): ?string { + [$issue, $outcome] = $reporter->record($this->app->make(EventFactory::class)->fromThrowable(new \RuntimeException('Spiking'))); + + return $alerter->consider($issue, $outcome); + }; + + $consider(); + $this->assertSame(Alerter::SPIKE, $consider()); + $this->assertTrue(Cache::has('atrium-errors:alert:spike:'.Issue::query()->value('id'))); + + $this->travel(3599)->seconds(); + $this->assertNull($consider()); + + $this->travel(1)->seconds(); + $this->assertSame(Alerter::SPIKE, $consider()); + } + + public function test_a_regression_is_remembered_by_the_moment_it_came_back(): void + { + $this->settings(['alert_email' => 'ops@example.com']); + $alerter = $this->app->make(Alerter::class); + $back = CarbonImmutable::parse('2026-11-17 11:00:00 UTC'); + $issue = $this->issue(['regressed_at' => $back]); + + $this->assertSame(Alerter::REGRESSION, $alerter->consider($issue, DatabaseReporter::OUTCOME_REGRESSION)); + $this->assertTrue(Cache::has('atrium-errors:alert:regression:'.$issue->id.':'.$back->getTimestamp())); + $this->assertNull($alerter->consider($issue, DatabaseReporter::OUTCOME_REGRESSION)); + } + + public function test_a_regression_without_a_moment_is_still_alerted_once(): void + { + $this->settings(['alert_email' => 'ops@example.com']); + $alerter = $this->app->make(Alerter::class); + $issue = $this->issue(['regressed_at' => null]); + + $this->assertSame(Alerter::REGRESSION, $alerter->consider($issue, DatabaseReporter::OUTCOME_REGRESSION)); + $this->assertTrue(Cache::has('atrium-errors:alert:regression:'.$issue->id.':')); + $this->assertNull($alerter->consider($issue, DatabaseReporter::OUTCOME_REGRESSION)); + } + + public function test_the_ten_minutes_are_counted_in_windows_that_are_forgotten_after_fifteen(): void + { + $this->settings(['alert_email' => 'ops@example.com']); + $alerter = $this->app->make(Alerter::class); + $window = 'atrium-errors:alerts:'.intdiv(CarbonImmutable::now()->getTimestamp(), 600); + + $alerter->consider($this->issue(), DatabaseReporter::OUTCOME_NEW); + $alerter->consider($this->issue(), DatabaseReporter::OUTCOME_NEW); + + $this->assertSame(2, Cache::get($window)); + + $this->travel(899)->seconds(); + $this->assertSame(2, Cache::get($window)); + + $this->travel(1)->seconds(); + $this->assertNull(Cache::get($window)); + } + + #[DataProvider('limits')] + public function test_the_limit_of_alerts_in_ten_minutes(?int $limit, int $sent): void + { + $this->settings(['alert_email' => 'ops@example.com']); + $alerts = ['email' => 'ops@example.com', 'new' => true, 'regression' => true, 'spike_per_hour' => 100]; + config(['atrium-errors.alerts' => $limit === null ? $alerts : [...$alerts, 'max_per_10_minutes' => $limit]]); + $alerter = $this->app->make(Alerter::class); + + $reasons = []; + for ($i = 0; $i < 14; $i++) { + $reasons[] = $alerter->consider($this->issue(), DatabaseReporter::OUTCOME_NEW); + } + + $this->assertCount($sent, array_filter($reasons)); + Mail::assertSentCount($sent); + } + + /** + * @return array + */ + public static function limits(): array + { + return [ + 'not configured: ten' => [null, 10], + 'one' => [1, 1], + 'two' => [2, 2], + 'zero still lets one through' => [0, 1], + 'negative still lets one through' => [-5, 1], + 'more than there are errors' => [50, 14], + ]; + } + + public function test_a_telegram_message_is_cut_to_four_thousand_characters_and_waits_five_seconds(): void + { + $timeouts = []; + Http::globalMiddleware(static function (callable $handler) use (&$timeouts): callable { + return static function ($request, array $options) use ($handler, &$timeouts) { + $timeouts[] = $options['timeout'] ?? null; + + return $handler($request, $options); + }; + }); + Http::fake(['api.telegram.org/*' => Http::response(['ok' => true])]); + config(['app.name' => str_repeat('Я', 4100)]); + $this->settings(['telegram_token' => '1:abc', 'telegram_chat' => '42']); + + $this->errors()->capture(new \RuntimeException('Long')); + + Http::assertSent(static fn (Request $request): bool => mb_strlen((string) $request['text']) === 4000 && str_starts_with((string) $request['text'], 'New error on ')); + $this->assertSame([5], $timeouts); + } + + public function test_the_token_is_taken_out_of_a_connection_failure(): void + { + Http::fake(['api.telegram.org/*' => static fn () => throw new ConnectionException('cURL error 28: timed out for https://api.telegram.org/bot987:SECRET-token/sendMessage')]); + $this->settings(['telegram_token' => '987:SECRET-token', 'telegram_chat' => '42']); + + $this->errors()->capture(new \RuntimeException('Unreachable')); + + $this->assertSame( + 'alert telegram failed: cURL error 28: timed out for https://api.telegram.org/bot[Filtered]/sendMessage', + $this->fallbackLines()[0]['note'], + ); + } + + #[DataProvider('halfConfiguredTelegram')] + public function test_telegram_needs_both_the_token_and_the_chat(string $token, string $chat): void + { + Http::fake(); + $this->settings(['telegram_token' => $token, 'telegram_chat' => $chat]); + + $this->errors()->capture(new \RuntimeException('Half configured')); + + Http::assertNothingSent(); + Mail::assertNothingSent(); + } + + /** + * @return array + */ + public static function halfConfiguredTelegram(): array + { + return [ + 'token only' => ['123:abc', ''], + 'chat only' => ['', '42'], + 'chat of spaces' => ['123:abc', ' '], + 'token of spaces' => [' ', '42'], + ]; + } +} diff --git a/packages/errors/tests/Feature/AlertsTest.php b/packages/errors/tests/Feature/AlertsTest.php new file mode 100644 index 00000000..dfe4137a --- /dev/null +++ b/packages/errors/tests/Feature/AlertsTest.php @@ -0,0 +1,208 @@ + Http::response(['ok' => $status === 200], $status)]); + } + + public function test_a_new_error_is_mailed_and_sent_to_telegram(): void + { + $this->telegramAnswers(); + $this->settings([ + 'alert_email' => 'ops@example.com, oncall@example.com; not-an-address', + 'telegram_token' => '123456:ABC-def_ghi', + 'telegram_chat' => '-1001234567', + ]); + + $this->errors()->capture(new RuntimeException('Checkout is broken')); + $issue = Issue::query()->sole(); + + Mail::assertSent(AlertMail::class, function (AlertMail $mail) use ($issue): bool { + $this->assertSame('New error on Northwind Travel: RuntimeException', $mail->envelope()->subject); + $this->assertTrue($mail->hasMetadata('atrium_purpose', 'errors')); + $text = $mail->alert->text(); + $this->assertStringContainsString('RuntimeException: Checkout is broken', $text); + $this->assertStringContainsString('Events: 1, users: 0', $text); + $this->assertStringContainsString('Release: 2.4.0', $text); + $this->assertStringContainsString(route('admin.errors.show', $issue->id), $text); + $mail->assertSeeInText('Checkout is broken'); + + return $mail->hasTo('ops@example.com') && $mail->hasTo('oncall@example.com') && ! $mail->hasTo('not-an-address'); + }); + + Http::assertSent(static fn (Request $request): bool => $request->url() === 'https://api.telegram.org/bot123456:ABC-def_ghi/sendMessage' + && $request['chat_id'] === '-1001234567' + && str_starts_with((string) $request['text'], 'New error on Northwind Travel: RuntimeException') + && $request['disable_web_page_preview'] === true); + } + + public function test_the_second_event_of_an_issue_alerts_nobody(): void + { + $this->settings(['alert_email' => 'ops@example.com']); + + foreach (['first', 'second', 'third'] as $text) { + $this->errors()->capture(new RuntimeException('Same bug '.$text)); + } + + Mail::assertSentCount(1); + } + + public function test_a_returning_error_alerts_again_each_time_it_returns(): void + { + $this->settings(['alert_email' => 'ops@example.com']); + $reporter = $this->app->make(DatabaseReporter::class); + $alerter = $this->app->make(Alerter::class); + + [$issue] = $reporter->record($this->event()); + $this->assertSame(Alerter::NEW, $alerter->consider($issue, DatabaseReporter::OUTCOME_NEW)); + + foreach ([1, 2] as $round) { + $issue->update(['status' => Issue::RESOLVED]); + $this->travel(1)->minutes(); + [$issue, $outcome] = $reporter->record($this->event()); + $this->assertSame(DatabaseReporter::OUTCOME_REGRESSION, $outcome); + $this->assertSame(Alerter::REGRESSION, $alerter->consider($issue, $outcome), 'Round '.$round); + } + + Mail::assertSent(AlertMail::class, static fn (AlertMail $mail): bool => str_starts_with($mail->envelope()->subject, 'An error came back')); + } + + public function test_a_spike_alerts_once_an_hour(): void + { + $this->settings(['alert_email' => 'ops@example.com', 'alert_new' => false, 'spike_per_hour' => 3]); + $reporter = $this->app->make(DatabaseReporter::class); + $alerter = $this->app->make(Alerter::class); + + $reasons = []; + for ($i = 0; $i < 5; $i++) { + [$issue, $outcome] = $reporter->record($this->event()); + $reasons[] = $alerter->consider($issue, $outcome); + } + + $this->assertSame([null, null, Alerter::SPIKE, null, null], $reasons); + + $this->travel(61)->minutes(); + for ($i = 0; $i < 3; $i++) { + [$issue, $outcome] = $reporter->record($this->event()); + $last = $alerter->consider($issue, $outcome); + } + $this->assertSame(Alerter::SPIKE, $last); + Mail::assertSent(AlertMail::class, static fn (AlertMail $mail): bool => str_starts_with($mail->envelope()->subject, 'Error spike')); + } + + public function test_no_more_than_the_limit_goes_out_in_ten_minutes(): void + { + $this->settings(['alert_email' => 'ops@example.com']); + config(['atrium-errors.alerts.max_per_10_minutes' => 2]); + + foreach (range(1, 5) as $n) { + $this->errors()->capture($this->elsewhere($n)); + } + + $this->assertSame(5, Issue::query()->count()); + Mail::assertSentCount(2); + } + + public function test_switched_off_reasons_ignored_issues_and_no_channels_stay_silent(): void + { + Http::fake(); + $alerter = $this->app->make(Alerter::class); + $issue = $this->issue(); + + // No channel set. + $this->assertNull($alerter->consider($issue, DatabaseReporter::OUTCOME_NEW)); + + $this->settings(['alert_email' => 'ops@example.com', 'alert_new' => false, 'alert_regression' => false, 'spike_per_hour' => 0]); + $this->assertNull($alerter->consider($issue, DatabaseReporter::OUTCOME_NEW)); + $this->assertNull($alerter->consider($issue, DatabaseReporter::OUTCOME_REGRESSION)); + $this->assertNull($alerter->consider($issue, DatabaseReporter::OUTCOME_SEEN)); + + $this->settings(['alert_email' => 'ops@example.com', 'alert_new' => true]); + $issue->update(['status' => Issue::IGNORED]); + $this->assertNull($alerter->consider($issue, DatabaseReporter::OUTCOME_NEW)); + + Mail::assertNothingSent(); + Http::assertNothingSent(); + } + + public function test_a_failing_channel_is_noted_without_the_token_and_the_other_still_works(): void + { + $this->telegramAnswers(400); + $this->settings(['alert_email' => 'ops@example.com', 'telegram_token' => '987:SECRET-token', 'telegram_chat' => '@northwind_ops']); + + $this->errors()->capture(new RuntimeException('Telegram is wrong')); + + Mail::assertSentCount(1); + $notes = implode("\n", array_column($this->fallbackLines(), 'note')); + $this->assertStringContainsString('alert telegram failed', $notes); + $this->assertStringNotContainsString('SECRET-token', $notes); + } + + public function test_a_failing_mailer_is_noted_and_telegram_still_gets_it(): void + { + $this->telegramAnswers(); + Mail::shouldReceive('to')->andThrow(new RuntimeException('SMTP refused')); + $this->settings(['alert_email' => 'ops@example.com', 'telegram_token' => '1:abc', 'telegram_chat' => '42']); + + $this->errors()->capture(new RuntimeException('Mail is down')); + + Http::assertSentCount(1); + $this->assertSame('alert email failed: SMTP refused', $this->fallbackLines()[0]['note']); + } + + public function test_an_alert_without_place_or_release_and_without_the_admin_route(): void + { + $issue = $this->issue(['culprit' => null, 'last_release' => null, 'message' => str_repeat('m', 400)]); + $alert = new Alert($issue, Alerter::NEW); + + $this->assertSame([$issue->class.': '.str_repeat('m', 300), 'Events: 0, users: 0'], $alert->lines()); + $this->assertNotNull($alert->url()); + } + + private function event(): Event + { + return $this->app->make(EventFactory::class)->fromThrowable(new RuntimeException('Repeating')); + } + + private function elsewhere(int $n): \Exception + { + // Another class per issue: five different bugs. + $classes = [\LogicException::class, \DomainException::class, \RangeException::class, \UnexpectedValueException::class, \OverflowException::class]; + + return new $classes[$n - 1]('Bug '.$n); + } +} diff --git a/packages/errors/tests/Feature/BrowserDetailsTest.php b/packages/errors/tests/Feature/BrowserDetailsTest.php new file mode 100644 index 00000000..6dc1b34a --- /dev/null +++ b/packages/errors/tests/Feature/BrowserDetailsTest.php @@ -0,0 +1,303 @@ +group(static function (): void { + Route::get('/tours', static fn () => response('ToursTours')); + Route::get('/upper', static fn () => response('x')); + Route::get('/no-head', static fn () => response('

Fragment

')); + Route::get('/multiple', static fn () => response('', 300)); + Route::get('/created', static fn () => response('', 201)); + Route::get('/streamed', static fn () => response()->stream(static function (): void { + echo ''; + }, 200, ['Content-Type' => 'text/html'])); + Route::get('/admin/help', static fn () => response('Help')); + }); + } + + protected function setUp(): void + { + parent::setUp(); + + // Far above anything one test sends: the throttle has its own tests. + config(['atrium-errors.browser.per_minute' => 10000]); + } + + public function test_a_switched_off_endpoint_says_it_does_not_accept(): void + { + $this->postJson('/atrium-errors/browser', ['message' => 'x']) + ->assertNotFound() + ->assertExactJson(['message' => 'Not accepted']); + + $this->assertSame(0, Occurrence::query()->count()); + } + + public function test_an_endpoint_switched_on_for_the_admin_only_accepts_too(): void + { + $this->settings(['browser_admin' => true]); + + $this->postJson('/atrium-errors/browser', ['message' => 'x', 'source' => 'admin'])->assertStatus(202); + } + + public function test_a_report_that_is_not_valid_is_refused_in_so_many_words(): void + { + $this->settings(['browser_site' => true]); + + $this->postJson('/atrium-errors/browser', ['name' => 'TypeError']) + ->assertStatus(422) + ->assertExactJson(['message' => 'Invalid report']); + $this->postJson('/atrium-errors/browser', ['message' => 'x', 'source' => 'mobile'])->assertStatus(422); + $this->call('POST', '/atrium-errors/browser', [], [], [], ['CONTENT_TYPE' => 'application/json'], '[1,2')->assertStatus(422); + $this->call('POST', '/atrium-errors/browser', [], [], [], ['CONTENT_TYPE' => 'application/json'], '"text"')->assertStatus(422); + } + + public function test_every_optional_field_may_be_null(): void + { + $this->settings(['browser_site' => true]); + + $this->postJson('/atrium-errors/browser', ['message' => 'x', 'name' => null, 'stack' => null, 'url' => null, 'line' => null, 'column' => null, 'source' => null]) + ->assertStatus(202); + + $this->assertSame(['source' => 'site'], Occurrence::query()->sole()->payload['context']); + } + + #[DataProvider('fieldLimits')] + public function test_a_field_is_refused_just_over_its_limit_and_taken_on_it(string $field, mixed $fits, mixed $over): void + { + $this->settings(['browser_site' => true]); + + $this->postJson('/atrium-errors/browser', ['message' => 'x', $field => $fits])->assertStatus(202); + $this->postJson('/atrium-errors/browser', ['message' => 'x', $field => $over])->assertStatus(422); + } + + /** + * @return array + */ + public static function fieldLimits(): array + { + return [ + 'message' => ['message', str_repeat('a', 1000), str_repeat('a', 1001)], + 'name' => ['name', str_repeat('a', 64), str_repeat('a', 65)], + 'stack' => ['stack', str_repeat('a', 10000), str_repeat('a', 10001)], + 'url' => ['url', str_repeat('a', 2000), str_repeat('a', 2001)], + 'line' => ['line', 10000000, 10000001], + 'column' => ['column', 10000000, 10000001], + ]; + } + + #[DataProvider('numbersBelowZero')] + public function test_a_line_or_a_column_below_zero_is_refused(string $field): void + { + $this->settings(['browser_site' => true]); + + $this->postJson('/atrium-errors/browser', ['message' => 'x', $field => 0])->assertStatus(202); + $this->postJson('/atrium-errors/browser', ['message' => 'x', $field => -1])->assertStatus(422); + } + + /** + * @return array + */ + public static function numbersBelowZero(): array + { + return ['line' => ['line'], 'column' => ['column']]; + } + + #[DataProvider('limits')] + public function test_the_body_may_be_as_long_as_the_limit_and_not_a_byte_more(?int $configured, int $limit): void + { + $this->settings(['browser_site' => true]); + config(['atrium-errors.browser' => ['per_minute' => 10000] + ($configured === null ? [] : ['max_bytes' => $configured])]); + + $this->postBody($this->body($limit))->assertStatus(202); + $this->postBody($this->body($limit + 1))->assertStatus(413)->assertExactJson(['message' => 'Too large']); + } + + /** + * @return array + */ + public static function limits(): array + { + return [ + 'the default is sixteen kilobytes' => [null, 16384], + 'a configured limit' => [5000, 5000], + 'a limit under a kilobyte is a kilobyte' => [100, 1024], + 'a limit of zero is a kilobyte too' => [0, 1024], + 'exactly a kilobyte' => [1024, 1024], + 'one over a kilobyte' => [1025, 1025], + ]; + } + + public function test_a_body_that_says_it_is_too_long_is_refused_before_its_length_is_looked_at(): void + { + $this->settings(['browser_site' => true]); + config(['atrium-errors.browser.max_bytes' => 2000]); + + $this->postBody($this->body(100), ['CONTENT_LENGTH' => 2000])->assertStatus(202); + $this->postBody($this->body(100), ['CONTENT_LENGTH' => 2001])->assertStatus(413); + $this->postBody($this->body(100), ['CONTENT_LENGTH' => 99999])->assertStatus(413); + } + + public function test_the_throttle_counts_per_address_with_ten_a_minute_by_default(): void + { + $this->settings(['browser_site' => true]); + config(['atrium-errors.browser' => []]); + + $codes = []; + for ($i = 0; $i < 11; $i++) { + $codes[] = $this->withServerVariables(['REMOTE_ADDR' => '10.0.0.1'])->postJson('/atrium-errors/browser', ['message' => 'x'])->getStatusCode(); + } + + $this->assertSame([...array_fill(0, 10, 202), 429], $codes); + $this->assertSame(202, $this->withServerVariables(['REMOTE_ADDR' => '10.0.0.2'])->postJson('/atrium-errors/browser', ['message' => 'x'])->getStatusCode()); + $this->assertSame(10, RateLimiter::attempts(md5('atrium-errors-browser'.'atrium-errors|10.0.0.1'))); + } + + #[DataProvider('perMinute')] + public function test_the_throttle_lets_the_configured_number_through_and_at_least_one(int $configured, int $allowed): void + { + $this->settings(['browser_site' => true]); + config(['atrium-errors.browser.per_minute' => $configured]); + + $codes = []; + for ($i = 0; $i < $allowed + 1; $i++) { + $codes[] = $this->postJson('/atrium-errors/browser', ['message' => 'x'])->getStatusCode(); + } + + $this->assertSame([...array_fill(0, $allowed, 202), 429], $codes); + } + + /** + * @return array + */ + public static function perMinute(): array + { + return [ + 'one' => [1, 1], + 'two' => [2, 2], + 'three' => [3, 3], + 'zero still lets one through' => [0, 1], + 'below zero too' => [-4, 1], + ]; + } + + public function test_the_endpoint_takes_no_csrf_token_and_gets_no_script_but_is_throttled(): void + { + $route = Route::getRoutes()->getByName('atrium.errors.browser'); + + $this->assertNotNull($route); + $this->assertSame(['web', 'throttle:atrium-errors-browser'], $route->middleware()); + $this->assertSame([ValidateCsrfToken::class, InjectBrowserScript::class], $route->excludedMiddleware()); + } + + public function test_the_admin_screens_are_behind_the_admin_middleware(): void + { + $route = Route::getRoutes()->getByName('admin.errors.index'); + + $this->assertNotNull($route); + $this->assertSame(['web', 'atrium.inertia', 'admin.auth', 'atrium.site', AuthorizeErrors::class], $route->middleware()); + $this->assertSame('admin/errors', $route->uri()); + } + + public function test_the_script_is_put_in_front_of_the_end_of_the_head_and_nowhere_else(): void + { + $this->settings(['browser_site' => true]); + + $this->assertSame( + 'ToursTours', + $this->get('/tours')->assertOk()->getContent(), + ); + $this->assertSame( + 'x', + $this->get('/upper')->assertOk()->getContent(), + ); + } + + public function test_a_page_without_a_head_is_left_as_it_is(): void + { + $this->settings(['browser_site' => true]); + + $this->assertSame('

Fragment

', $this->get('/no-head')->assertOk()->getContent()); + } + + public function test_a_streamed_page_is_left_as_it_is(): void + { + $this->settings(['browser_site' => true]); + + $response = $this->get('/streamed')->assertOk(); + + $this->assertSame('', $response->streamedContent()); + } + + public function test_only_answers_under_three_hundred_get_the_script(): void + { + $this->settings(['browser_site' => true]); + + $this->assertStringContainsString('atrium-errors.js', (string) $this->get('/created')->assertStatus(201)->getContent()); + $this->assertSame('', $this->get('/multiple')->assertStatus(300)->getContent()); + } + + #[DataProvider('prefixes')] + public function test_the_admin_is_told_by_the_prefix_of_the_panel_with_or_without_slashes(string $prefix): void + { + $this->settings(['browser_admin' => true]); + config(['atrium.prefix' => $prefix]); + + $this->assertStringContainsString('data-source="admin"', (string) $this->get('/admin/help')->getContent()); + } + + /** + * @return array + */ + public static function prefixes(): array + { + return [ + 'plain' => ['admin'], + 'with a slash in front' => ['/admin'], + 'with a slash behind' => ['admin/'], + 'with both' => ['/admin/'], + ]; + } + + /** + * A valid report of exactly this many bytes. + */ + private function body(int $bytes): string + { + $base = (string) json_encode(['message' => 'x', 'pad' => '']); + + return (string) json_encode(['message' => 'x', 'pad' => str_repeat('a', $bytes - strlen($base))]); + } + + /** + * @param array $server + */ + private function postBody(string $body, array $server = []): TestResponse + { + return $this->call('POST', '/atrium-errors/browser', [], [], [], ['CONTENT_TYPE' => 'application/json', 'HTTP_ACCEPT' => 'application/json'] + $server, $body); + } +} diff --git a/packages/errors/tests/Feature/BrowserTest.php b/packages/errors/tests/Feature/BrowserTest.php new file mode 100644 index 00000000..f963e4af --- /dev/null +++ b/packages/errors/tests/Feature/BrowserTest.php @@ -0,0 +1,187 @@ +group(static function (): void { + Route::get('/tours', static fn () => response('ToursTours')); + Route::get('/no-head', static fn () => response('

Fragment

')); + Route::get('/data.json', static fn () => response()->json(['ok' => true])); + Route::get('/brochure', static fn () => response('', 200, ['Content-Type' => 'text/html', 'Content-Disposition' => 'attachment; filename=brochure.html'])); + Route::get('/moved', static fn () => redirect('/tours')); + Route::get('/admin/help', static fn () => response('Help')); + }); + } + + public function test_a_report_is_stored_with_its_stack_and_page(): void + { + $this->settings(['browser_site' => true]); + + $this->withHeader('Referer', 'http://localhost/tours/greece?utm_source=mail&token=abc123') + ->postJson('/atrium-errors/browser', [ + 'message' => "Cannot read properties of undefined (reading 'price')", + 'name' => 'TypeError', + 'stack' => "TypeError: Cannot read properties of undefined\n at renderPrice (http://localhost/build/app-Bx91kQ2z.js?v=3:10:5)\n at http://localhost/build/app-Bx91kQ2z.js:20:1\n at https://cdn.example.test/lib.js:1:1", + 'source' => 'site', + 'line' => 10, + 'column' => 5, + ]) + ->assertStatus(202); + + $issue = Issue::query()->sole(); + $this->assertSame('browser', $issue->kind); + $this->assertSame('TypeError', $issue->class); + + $event = Occurrence::query()->sole(); + $this->assertSame('/tours/greece', $event->path); + $payload = $event->payload; + $this->assertSame(['source' => 'site'], $payload['context']); + $this->assertStringNotContainsString('abc123', (string) $payload['request']['url']); + + $frames = $payload['exceptions'][0]['frames']; + $this->assertSame(['/build/app-Bx91kQ2z.js', '/build/app-Bx91kQ2z.js', 'https://cdn.example.test/lib.js'], array_column($frames, 'file')); + $this->assertSame(['renderPrice', '', ''], array_column($frames, 'function')); + $this->assertSame([true, true, false], array_column($frames, 'in_app')); + } + + public function test_firefox_stacks_and_reports_without_a_stack_are_understood(): void + { + $this->settings(['browser_admin' => true]); + + $this->postJson('/atrium-errors/browser', ['message' => 'a is null', 'stack' => "save@http://localhost/admin.js:4:2\n@http://localhost/admin.js:9:1", 'source' => 'admin'])->assertStatus(202); + $this->postJson('/atrium-errors/browser', ['message' => 'Script error.', 'url' => 'http://localhost/inline.js', 'line' => 3, 'name' => 'bad name!'])->assertStatus(202); + + $first = Occurrence::query()->orderBy('id')->first()?->payload; + $this->assertSame(['save', ''], array_column($first['exceptions'][0]['frames'], 'function')); + $this->assertSame(['source' => 'admin'], $first['context']); + + $second = Occurrence::query()->orderByDesc('id')->first()?->payload; + $this->assertSame('/inline.js', $second['exceptions'][0]['frames'][0]['file']); + $this->assertSame('Error', $second['exceptions'][0]['class']); + $this->assertNull(Occurrence::query()->orderByDesc('id')->first()?->path); + } + + public function test_the_endpoint_is_closed_while_both_switches_are_off(): void + { + $this->postJson('/atrium-errors/browser', ['message' => 'x'])->assertNotFound(); + + $this->assertSame(0, Occurrence::query()->count()); + } + + /** + * @return array + */ + public static function junk(): array + { + return [ + 'not json' => ['message=hello'], + 'json string' => ['"just a string"'], + 'empty object' => ['{}'], + 'no message' => ['{"stack":"at x"}'], + 'message not text' => ['{"message":["a","b"]}'], + 'line not a number' => ['{"message":"x","line":"ten"}'], + 'negative column' => ['{"message":"x","column":-1}'], + 'unknown source' => ['{"message":"x","source":"mobile-app"}'], + 'message too long' => ['{"message":"'.str_repeat('a', 1001).'"}'], + 'name too long' => ['{"message":"x","name":"'.str_repeat('N', 65).'"}'], + 'broken json' => ['{"message": "x"'], + ]; + } + + #[DataProvider('junk')] + public function test_junk_is_refused(string $body): void + { + $this->settings(['browser_site' => true]); + + $this->call('POST', '/atrium-errors/browser', [], [], [], ['CONTENT_TYPE' => 'application/json'], $body)->assertStatus(422); + + $this->assertSame(0, Occurrence::query()->count()); + } + + public function test_an_oversized_report_is_refused_before_it_is_read(): void + { + $this->settings(['browser_site' => true]); + + $big = (string) json_encode(['message' => 'x', 'stack' => str_repeat('at f (http://localhost/a.js:1:1)'."\n", 600)]); + $this->assertGreaterThan(16384, strlen($big)); + + $this->call('POST', '/atrium-errors/browser', [], [], [], ['CONTENT_TYPE' => 'application/json'], $big)->assertStatus(413); + $this->call('POST', '/atrium-errors/browser', [], [], [], ['CONTENT_TYPE' => 'application/json', 'HTTP_CONTENT_LENGTH' => '999999'], '{"message":"x"}')->assertStatus(413); + + $this->assertSame(0, Occurrence::query()->count()); + } + + public function test_a_visitor_is_throttled(): void + { + $this->settings(['browser_site' => true]); + config(['atrium-errors.browser.per_minute' => 3]); + + $statuses = []; + for ($i = 0; $i < 5; $i++) { + $statuses[] = $this->postJson('/atrium-errors/browser', ['message' => 'Flood '.$i])->status(); + } + + $this->assertSame([202, 202, 202, 429, 429], $statuses); + } + + public function test_the_script_is_served(): void + { + $response = $this->get('/atrium-errors.js')->assertOk(); + + $this->assertStringContainsString('application/javascript', (string) $response->headers->get('Content-Type')); + $this->assertStringContainsString('max-age=86400', (string) $response->headers->get('Cache-Control')); + $this->assertStringContainsString('sendBeacon', (string) $response->getContent()); + } + + public function test_the_script_goes_into_site_pages_when_switched_on(): void + { + $this->get('/tours')->assertDontSee('atrium-errors.js', false); + + $this->settings(['browser_site' => true]); + + $this->get('/tours') + ->assertSee('', false); + $this->get('/admin/help')->assertDontSee('atrium-errors.js', false); + } + + public function test_the_script_goes_into_admin_pages_with_the_csp_nonce(): void + { + $this->settings(['browser_admin' => true]); + Vite::useCspNonce('n0nce'); + + $this->get('/admin/help')->assertSee('data-source="admin" defer nonce="n0nce">', false); + $this->get('/tours')->assertDontSee('atrium-errors.js', false); + } + + public function test_only_full_html_pages_get_the_script(): void + { + $this->settings(['browser_site' => true]); + + $this->get('/no-head')->assertDontSee('atrium-errors.js', false); + $this->get('/data.json')->assertDontSee('atrium-errors.js', false); + $this->get('/brochure')->assertDontSee('atrium-errors.js', false); + $this->get('/moved')->assertRedirect('/tours'); + $this->withHeader('X-Inertia', 'true')->get('/tours')->assertDontSee('atrium-errors.js', false); + } +} diff --git a/packages/errors/tests/Feature/CaptureDetailsTest.php b/packages/errors/tests/Feature/CaptureDetailsTest.php new file mode 100644 index 00000000..f30e6861 --- /dev/null +++ b/packages/errors/tests/Feature/CaptureDetailsTest.php @@ -0,0 +1,397 @@ +travelTo('2026-11-17 10:20:30.123456'); + $crumbs = new Breadcrumbs; + + $crumbs->add('cache', 'miss'); + + $this->assertSame([['time' => '10:20:30.123', 'category' => 'cache', 'message' => 'miss']], $crumbs->all()); + } + + public function test_by_default_the_last_thirty_are_kept(): void + { + $crumbs = new Breadcrumbs; + for ($i = 1; $i <= 31; $i++) { + $crumbs->add('n', (string) $i); + } + + $messages = array_column($crumbs->all(), 'message'); + + $this->assertCount(30, $messages); + $this->assertSame('2', $messages[0]); + $this->assertSame('31', $messages[29]); + } + + public function test_a_ring_of_one_keeps_one_and_a_ring_of_none_keeps_nothing(): void + { + $one = new Breadcrumbs(1); + $one->add('n', 'first'); + $one->add('n', 'second'); + $none = new Breadcrumbs(0); + $none->add('n', 'first'); + + $this->assertSame(['second'], array_column($one->all(), 'message')); + $this->assertSame([], $none->all()); + } + + public function test_clear_empties_the_ring(): void + { + $crumbs = new Breadcrumbs; + $crumbs->add('n', 'x'); + + $crumbs->clear(); + + $this->assertSame([], $crumbs->all()); + } + + /** + * @param array{float,string} $case + */ + #[DataProvider('queries')] + public function test_a_query_is_its_sql_and_how_long_it_took(string $sql, float $took, string $expected): void + { + $this->travelTo('2026-11-17 10:20:30'); + $crumbs = new Breadcrumbs; + + $crumbs->query(new QueryExecuted($sql, ['secret@example.test'], $took, DB::connection())); + + $this->assertSame([['time' => '10:20:30.000', 'category' => 'query', 'message' => $expected]], $crumbs->all()); + } + + /** + * @return array + */ + public static function queries(): array + { + return [ + 'short, rounded to a tenth' => ['select 1', 12.36, 'select 1 [12.4 ms]'], + 'rounded down' => ['select 1', 0.04, 'select 1 [0 ms]'], + 'whole' => ['select 1', 3.0, 'select 1 [3 ms]'], + 'exactly as long as it may be' => [str_repeat('я', 500), 1.5, str_repeat('я', 500).' [1.5 ms]'], + 'one over' => [str_repeat('я', 501), 1.5, str_repeat('я', 500).' [1.5 ms]'], + 'far over' => [str_repeat('я', 900), 1.5, str_repeat('я', 500).' [1.5 ms]'], + ]; + } + + #[DataProvider('logLines')] + public function test_a_log_line_is_its_level_and_its_message_cut_to_five_hundred_characters(string $message, string $expected): void + { + $this->travelTo('2026-11-17 10:20:30'); + $crumbs = new Breadcrumbs; + + $crumbs->log(new MessageLogged('warning', $message, ['user' => 'secret'])); + + $this->assertSame([['time' => '10:20:30.000', 'category' => 'log.warning', 'message' => $expected]], $crumbs->all()); + } + + /** + * @return array + */ + public static function logLines(): array + { + return [ + 'short' => ['Disk is almost full', 'Disk is almost full'], + 'exactly as long as it may be' => [str_repeat('я', 500), str_repeat('я', 500)], + 'one over' => [str_repeat('я', 501), str_repeat('я', 500)], + ]; + } + + // ---- the event factory: the browser --------------------------------- + + public function test_a_browser_error_without_a_stack_takes_its_place_from_the_url_and_line(): void + { + $event = $this->factory()->fromBrowser(['message' => 'x', 'url' => 'http://localhost/assets/app.js', 'line' => 7, 'column' => 9], $this->page()); + + $this->assertSame(7, $event->exceptions[0]['frames'][0]['line']); + $this->assertSame('/assets/app.js', $event->exceptions[0]['frames'][0]['file']); + } + + public function test_a_browser_error_with_a_url_alone_is_on_line_zero(): void + { + $event = $this->factory()->fromBrowser(['message' => 'x', 'url' => 'http://localhost/assets/app.js'], $this->page()); + + $this->assertSame(0, $event->exceptions[0]['frames'][0]['line']); + $this->assertSame('/assets/app.js', $event->exceptions[0]['frames'][0]['file']); + } + + public function test_a_browser_error_keeps_the_stack_when_it_has_one(): void + { + $event = $this->factory()->fromBrowser([ + 'message' => 'x', + 'stack' => "Error: x\n at run (http://localhost/assets/app.js:12:3)", + 'url' => 'http://localhost/assets/other.js', + 'line' => 99, + ], $this->page()); + + $this->assertCount(1, $event->exceptions[0]['frames']); + $this->assertSame(12, $event->exceptions[0]['frames'][0]['line']); + $this->assertSame('run', $event->exceptions[0]['frames'][0]['function']); + } + + public function test_a_browser_error_without_url_or_stack_has_no_frames(): void + { + $this->assertSame([], $this->factory()->fromBrowser(['message' => 'x', 'url' => ''], $this->page())->exceptions[0]['frames']); + $this->assertSame([], $this->factory()->fromBrowser(['message' => 'x'], $this->page())->exceptions[0]['frames']); + } + + /** + * @return array + */ + public static function names(): array + { + return [ + 'a plain name' => ['TypeError', 'TypeError'], + 'with a dollar and digits' => ['My_Error$2', 'My_Error$2'], + 'a single letter' => ['E', 'E'], + 'sixty-four characters' => [str_repeat('a', 64), str_repeat('a', 64)], + 'sixty-five characters' => [str_repeat('a', 65), 'Error'], + 'starts with a digit' => ['1TypeError', 'Error'], + 'has a dash' => ['My-Error', 'Error'], + 'has a space in front' => [' TypeError', 'Error'], + 'empty' => ['', 'Error'], + ]; + } + + #[DataProvider('names')] + public function test_a_browser_error_is_named_by_the_page_only_when_the_name_is_safe(string $name, string $expected): void + { + $this->assertSame($expected, $this->factory()->fromBrowser(['message' => 'x', 'name' => $name], $this->page())->class); + } + + public function test_a_browser_error_without_a_name_is_just_an_error(): void + { + $this->assertSame('Error', $this->factory()->fromBrowser(['message' => 'x'], $this->page())->class); + } + + #[DataProvider('browserMessages')] + public function test_a_browser_message_is_cut_to_a_thousand_characters_everywhere(string $message, string $expected): void + { + $event = $this->factory()->fromBrowser(['message' => $message], $this->page()); + + $this->assertSame($expected, $event->message); + $this->assertSame($expected, $event->exceptions[0]['message']); + } + + /** + * @return array + */ + public static function browserMessages(): array + { + return [ + 'short' => ['Cannot read properties', 'Cannot read properties'], + 'exactly as long as it may be' => [str_repeat('я', 1000), str_repeat('я', 1000)], + 'one over' => [str_repeat('я', 1001), str_repeat('я', 1000)], + ]; + } + + public function test_a_browser_error_remembers_the_page_it_happened_on(): void + { + $request = $this->page(); + $request->headers->set('referer', 'https://shop.example.test/cart?step=2&session=abc&lang=ru'); + + $event = $this->factory()->fromBrowser(['message' => 'x'], $request); + + $this->assertSame('https://shop.example.test/cart?step=2&session=[Filtered]&lang=ru', $event->request['url']); + $this->assertSame('/cart', $event->request['path']); + $this->assertNull($event->request['method']); + $this->assertNull($event->request['route']); + } + + public function test_a_browser_error_without_a_referer_knows_no_page(): void + { + $event = $this->factory()->fromBrowser(['message' => 'x'], $this->page()); + + $this->assertNull($event->request['url']); + $this->assertNull($event->request['path']); + } + + public function test_a_query_parameter_named_in_the_config_loses_its_value_in_the_page_address(): void + { + config(['atrium-errors.scrub_keys' => ['room_code']]); + $this->app->forgetInstance(Scrubber::class); + $this->app->forgetInstance(EventFactory::class); + $request = $this->page(); + $request->headers->set('referer', 'https://shop.example.test/cart?lang=ru&room_code=r-42'); + + $url = $this->factory()->fromBrowser(['message' => 'x'], $request)->request['url']; + + $this->assertSame('https://shop.example.test/cart?lang=ru&room_code=[Filtered]', $url); + } + + public function test_a_page_address_with_an_empty_query_keeps_its_question_mark(): void + { + $request = $this->page(); + $request->headers->set('referer', 'https://shop.example.test/cart?'); + + $this->assertSame('https://shop.example.test/cart?', $this->factory()->fromBrowser(['message' => 'x'], $request)->request['url']); + } + + public function test_a_page_address_without_a_query_comes_back_as_it_is(): void + { + $request = $this->page(); + $request->headers->set('referer', 'https://shop.example.test/cart'); + + $this->assertSame('https://shop.example.test/cart', $this->factory()->fromBrowser(['message' => 'x'], $request)->request['url']); + } + + #[DataProvider('pathLengths')] + public function test_the_path_of_a_page_is_cut_to_five_hundred_and_twelve_characters(int $length, int $kept): void + { + $request = $this->page(); + $request->headers->set('referer', 'https://shop.example.test/'.str_repeat('б', $length - 1)); + + $this->assertSame('/'.str_repeat('б', $kept - 1), $this->factory()->fromBrowser(['message' => 'x'], $request)->request['path']); + } + + /** + * @return array + */ + public static function pathLengths(): array + { + return ['short' => [10, 10], 'exactly' => [512, 512], 'one over' => [513, 512], 'far over' => [900, 512]]; + } + + // ---- the event factory: messages and exceptions --------------------- + + public function test_a_message_is_cut_to_a_thousand_characters(): void + { + $factory = $this->factory(); + + $this->assertSame(str_repeat('я', 1000), $factory->fromMessage(str_repeat('я', 1000))->message); + $this->assertSame(str_repeat('я', 1000), $factory->fromMessage(str_repeat('я', 1001))->message); + $this->assertSame(str_repeat('я', 1000), $factory->fromMessage(str_repeat('я', 1001))->exceptions[0]['message']); + } + + public function test_an_exception_message_is_cut_to_two_thousand_characters(): void + { + $factory = $this->factory(); + + $this->assertSame(str_repeat('я', 2000), $factory->fromThrowable(new Exception(str_repeat('я', 2000)))->message); + $this->assertSame(str_repeat('я', 2000), $factory->fromThrowable(new Exception(str_repeat('я', 2001)))->message); + } + + public function test_the_level_of_an_exception_can_be_given(): void + { + $factory = $this->factory(); + + $this->assertSame('warning', $factory->fromThrowable(new Exception('x'), 'php', [], 'warning')->level); + $this->assertSame('error', $factory->fromThrowable(new Exception('x'))->level); + } + + public function test_an_event_id_is_thirty_two_hex_digits(): void + { + $this->assertMatchesRegularExpression('/^[0-9a-f]{32}$/', $this->factory()->fromMessage('x')->id); + } + + #[DataProvider('functionNames')] + public function test_the_function_of_a_browser_frame_is_cut_to_two_hundred_and_fifty_five_characters(int $length, int $kept): void + { + $name = str_repeat('я', $length); + + $event = $this->factory()->fromBrowser(['message' => 'x', 'stack' => 'at '.$name.' (http://localhost/app.js:1:1)'], $this->page()); + + $this->assertSame(str_repeat('я', $kept), $event->exceptions[0]['frames'][0]['function']); + } + + /** + * @return array + */ + public static function functionNames(): array + { + return ['short' => [10, 10], 'exactly' => [255, 255], 'one over' => [256, 255], 'far over' => [400, 255]]; + } + + // ---- the event factory: who ---------------------------------------- + + public function test_the_user_is_found_on_the_site_guard(): void + { + $this->actingAs(new GenericUser(['id' => 41])); + + $this->assertSame(41, $this->factory()->fromMessage('x')->request['user_id']); + } + + public function test_the_user_is_found_on_the_admin_guard_when_the_site_has_none(): void + { + $admin = $this->admin(); + $this->actingAs($admin, 'admin'); + + $this->assertSame($admin->id, $this->factory()->fromMessage('x')->request['user_id']); + } + + public function test_an_identifier_the_database_hands_out_as_text_is_a_number(): void + { + $this->actingAs(new GenericUser(['id' => '41'])); + + $this->assertSame(41, $this->factory()->fromMessage('x')->request['user_id']); + } + + public function test_nobody_signed_in_is_no_user(): void + { + $this->assertNull($this->factory()->fromMessage('x')->request['user_id']); + } + + // ---- the sender ----------------------------------------------------- + + public function test_the_end_of_the_response_is_awaited_once_however_many_events_there_are(): void + { + (new ReflectionProperty($this->app, 'isRunningInConsole'))->setValue($this->app, false); + $this->app->forgetInstance(Sender::class); + $this->app->forgetInstance(Errors::class); + $callbacks = new ReflectionProperty($this->app, 'terminatingCallbacks'); + $before = count($callbacks->getValue($this->app)); + + $this->errors()->capture(new RuntimeException('One')); + $this->errors()->capture(new RuntimeException('Two')); + $this->errors()->capture(new RuntimeException('Three')); + + $this->assertSame($before + 1, count($callbacks->getValue($this->app))); + $this->app->terminate(); + $this->assertSame(3, Occurrence::query()->count()); + } + + private function factory(): EventFactory + { + return $this->app->make(EventFactory::class); + } + + private function page(): Request + { + return Request::create('http://localhost/atrium-errors/browser', 'POST'); + } +} diff --git a/packages/errors/tests/Feature/CaptureTest.php b/packages/errors/tests/Feature/CaptureTest.php new file mode 100644 index 00000000..f976d508 --- /dev/null +++ b/packages/errors/tests/Feature/CaptureTest.php @@ -0,0 +1,286 @@ +get('/rooms/{room}', static function (): never { + throw new RuntimeException('Room is not available'); + })->name('rooms.show'); + + Route::middleware('web')->get('/admin-only', static function (): never { + throw new LogicException('Price list is empty'); + }); + } + + public function test_an_exception_of_a_page_is_stored_with_the_request(): void + { + $this->get('/rooms/12?ref=newsletter&token=open-sesame')->assertStatus(500); + + $issue = Issue::query()->sole(); + $this->assertSame(RuntimeException::class, $issue->class); + $this->assertSame('Room is not available', $issue->message); + $this->assertSame('php', $issue->kind); + $this->assertSame('error', $issue->level); + $this->assertSame(Issue::NEW, $issue->status); + $this->assertSame(1, $issue->times_seen); + $this->assertSame('2.4.0', $issue->first_release); + $this->assertNotNull($issue->culprit); + + $event = Occurrence::query()->sole(); + $this->assertSame('/rooms/12', $event->path); + $this->assertSame('GET', $event->method); + $this->assertSame('rooms.show', $event->route); + $this->assertSame('en', $event->locale); + $this->assertNotNull($event->site_id); + $this->assertSame('testing', $event->environment); + + $payload = $event->payload; + $this->assertStringContainsString('ref=newsletter', $payload['request']['url']); + $this->assertStringNotContainsString('open-sesame', $payload['request']['url']); + $this->assertSame(PHP_VERSION, $payload['runtime']['php']); + $this->assertSame(app()->version(), $payload['runtime']['laravel']); + + // The frame of the throw comes first, with the code around it. + $frame = $payload['exceptions'][0]['frames'][0]; + $this->assertStringEndsWith('CaptureTest.php', $frame['file']); + $this->assertStringContainsString("throw new RuntimeException('Room is not available')", $frame['context']['line']); + $this->assertNotEmpty($frame['context']['pre']); + $this->assertArrayNotHasKey('args', $frame); + } + + public function test_the_user_id_is_kept_and_nothing_else_about_the_user(): void + { + $admin = $this->admin('ops@example.com'); + + $this->actingAs($admin, 'admin')->get('/admin-only')->assertStatus(500); + + $event = Occurrence::query()->sole(); + $this->assertSame($admin->id, $event->user_id); + $this->assertSame(1, Issue::query()->sole()->users_seen); + $this->assertStringNotContainsString('ops@example.com', $this->stored()); + } + + public function test_the_same_bug_twice_is_one_issue_with_two_events_and_one_user(): void + { + $admin = $this->admin(); + + $this->actingAs($admin, 'admin')->get('/admin-only'); + $this->get('/admin-only'); + + $issue = Issue::query()->sole(); + $this->assertSame(2, $issue->times_seen); + $this->assertSame(1, $issue->users_seen); + $this->assertSame(2, $issue->occurrences()->count()); + } + + public function test_breadcrumbs_keep_queries_without_values_and_log_lines(): void + { + DB::select('select ? as guest', ['anna.lind@example.org']); + Log::info('Checkout started'); + + $this->errors()->capture(new RuntimeException('Card declined')); + + $crumbs = Occurrence::query()->sole()->payload['breadcrumbs']; + $categories = array_column($crumbs, 'category'); + $this->assertContains('query', $categories); + $this->assertContains('log.info', $categories); + $this->assertStringContainsString('select ? as guest', json_encode($crumbs) ?: ''); + $this->assertStringNotContainsString('anna.lind', $this->stored()); + } + + public function test_a_failed_queue_job_is_stored_once_with_the_job(): void + { + config(['queue.default' => 'sync']); + + try { + dispatch(new FailingJob('Supplier feed timed out')); + $this->fail('The job should have thrown'); + } catch (RuntimeException $e) { + // The handler reports it too: still one event. + $this->app->make(ExceptionHandler::class)->report($e); + } + + $issue = Issue::query()->sole(); + $this->assertSame('job', $issue->kind); + $this->assertSame('Supplier feed timed out', $issue->message); + + $context = Occurrence::query()->sole()->payload['context']; + $this->assertSame(FailingJob::class, $context['job']); + $this->assertSame('sync', $context['connection']); + $this->assertSame(1, $context['attempts']); + } + + public function test_a_failed_scheduled_task_is_stored_with_the_task(): void + { + $this->app->make(Schedule::class) + ->call(static function (): never { + throw new RuntimeException('Nightly sitemap failed'); + }) + ->everyMinute() + ->name('nightly-sitemap'); + + $this->artisan('schedule:run')->assertSuccessful(); + + $issue = Issue::query()->sole(); + $this->assertSame('schedule', $issue->kind); + $this->assertSame('Nightly sitemap failed', $issue->message); + + $context = Occurrence::query()->sole()->payload['context']; + $this->assertSame('nightly-sitemap', $context['task']); + $this->assertSame('* * * * *', $context['expression']); + } + + public function test_a_message_is_stored_without_an_exception(): void + { + $event = $this->errors()->message('Payment gateway answered in 9 s', 'warning', ['gateway' => 'demo-pay']); + + $this->assertNotNull($event); + $issue = Issue::query()->sole(); + $this->assertSame('message', $issue->kind); + $this->assertSame('warning', $issue->level); + $this->assertSame('Message', $issue->class); + $this->assertSame(['gateway' => 'demo-pay'], Occurrence::query()->sole()->payload['context']); + } + + public function test_an_unknown_message_level_becomes_info(): void + { + $this->errors()->message('Cache warmed', 'shouting'); + + $this->assertSame('info', Issue::query()->sole()->level); + } + + public function test_levels_follow_the_kind_of_error(): void + { + $levels = array_map(fn ($e): ?string => $this->errors()->capture($e)?->level, [ + new ErrorException('Undefined array key "room"', 0, E_WARNING), + new ErrorException('Allowed memory size exhausted', 0, E_ERROR), + new TypeError('Argument #1 must be of type int'), + new InvalidArgumentException('Unknown currency'), + ]); + + $this->assertSame(['warning', 'fatal', 'fatal', 'error'], $levels); + // The two ErrorExceptions come from the same place: one issue, at the last level. + $this->assertSame(3, Issue::query()->count()); + $this->assertSame('fatal', Issue::query()->where('class', ErrorException::class)->sole()->level); + } + + public function test_previous_exceptions_are_kept_up_to_three(): void + { + $e = new RuntimeException('level 0', 0, new RuntimeException('level 1', 0, new RuntimeException('level 2', 0, new RuntimeException('level 3', 0, new RuntimeException('level 4'))))); + + $this->errors()->capture($e); + + $this->assertSame(['level 0', 'level 1', 'level 2', 'level 3'], array_column(Occurrence::query()->sole()->payload['exceptions'], 'message')); + } + + public function test_a_query_error_keeps_the_sql_without_the_values(): void + { + $e = new QueryException('testing', 'select * from guests where email = ? and card = ?', ['mila.berg@example.net', '4111111111111111'], new PDOException('SQLSTATE[42S22]: Column not found: 1054 Unknown column')); + + $this->errors()->capture($e); + + $message = Issue::query()->sole()->message; + $this->assertStringContainsString('Column not found', $message); + $this->assertStringContainsString('(SQL: select * from guests where email = ? and card = ?)', $message); + $this->assertStringNotContainsString('mila.berg', $this->stored()); + $this->assertStringNotContainsString('4111111111111111', $this->stored()); + } + + public function test_ignored_classes_and_switched_off_tracking_store_nothing(): void + { + config(['atrium-errors.ignore' => [InvalidArgumentException::class, 123]]); + + $this->assertNull($this->errors()->capture(new InvalidArgumentException('Expected'))); + $this->assertNotNull($this->errors()->capture(new LogicException('Not expected'))); + + config(['atrium-errors.enabled' => false]); + $this->assertNull($this->errors()->capture(new RuntimeException('While off'))); + $this->assertNull($this->errors()->message('While off')); + + $this->assertSame([LogicException::class], Issue::query()->pluck('class')->all()); + } + + public function test_the_same_exception_object_is_captured_once(): void + { + $e = new RuntimeException('Twice reported'); + + $this->assertNotNull($this->errors()->capture($e)); + $this->assertNull($this->errors()->capture($e)); + + $this->assertSame(1, Occurrence::query()->count()); + } + + public function test_a_command_or_a_worker_keeps_no_request_but_a_browser_report_does(): void + { + $this->app['env'] = 'production'; + + try { + $this->errors()->capture(new RuntimeException('In a worker')); + $browser = $this->app->make(EventFactory::class) + ->fromBrowser(['message' => 'x is null'], Request::create('/atrium-errors/browser', 'POST', server: ['HTTP_REFERER' => 'http://localhost/rooms'])); + } finally { + $this->app['env'] = 'testing'; + } + + $this->assertSame([], Occurrence::query()->sole()->payload['request']); + $this->assertSame('/rooms', $browser->request['path']); + } + + public function test_a_guard_that_cannot_be_built_does_not_hide_the_administrator(): void + { + $admin = $this->admin(); + $this->actingAs($admin, 'admin'); + // The site's default guard points at a driver nobody registered. + config(['auth.defaults.guard' => 'site', 'auth.guards.site' => ['driver' => 'no-such-driver']]); + + $this->errors()->capture(new RuntimeException('Behind a broken guard')); + + $this->assertSame($admin->id, Occurrence::query()->sole()->user_id); + } + + public function test_the_trackers_own_job_failing_is_not_captured(): void + { + $job = $this->createStub(Job::class); + $job->method('resolveName')->willReturn(DeliverEvent::class); + + event(new JobFailed('redis', $job, new RuntimeException('Delivery failed'))); + + $this->assertSame(0, Issue::query()->count()); + } +} diff --git a/packages/errors/tests/Feature/DatabaseReporterTest.php b/packages/errors/tests/Feature/DatabaseReporterTest.php new file mode 100644 index 00000000..05920371 --- /dev/null +++ b/packages/errors/tests/Feature/DatabaseReporterTest.php @@ -0,0 +1,160 @@ +event( + request: ['site_id' => 3, 'method' => 'POST', 'path' => '/rooms/12', 'route' => 'rooms.update', 'locale' => 'ru', 'user_id' => 7, 'url' => 'https://example.test/rooms/12'], + ); + + [$issue, $outcome] = $this->reporter()->record($event); + + $this->assertSame(DatabaseReporter::OUTCOME_NEW, $outcome); + $this->assertSame('fp-1', $issue->fingerprint); + $this->assertSame('job', $issue->kind); + $this->assertSame('error', $issue->level); + $this->assertSame('App\\Booking\\RoomUnavailable', $issue->class); + $this->assertSame('Room 12 is not free', $issue->message); + $this->assertSame('2.4.0', $issue->first_release); + $this->assertSame('2.4.0', $issue->last_release); + $this->assertSame(1, $issue->times_seen); + $this->assertSame(1, $issue->users_seen); + + $occurrence = Occurrence::query()->sole(); + $this->assertSame($issue->id, $occurrence->issue_id); + $this->assertSame(3, $occurrence->site_id); + $this->assertSame('error', $occurrence->level); + $this->assertSame('2.4.0', $occurrence->release); + $this->assertSame('production', $occurrence->environment); + $this->assertSame('POST', $occurrence->method); + $this->assertSame('/rooms/12', $occurrence->path); + $this->assertSame('rooms.update', $occurrence->route); + $this->assertSame('ru', $occurrence->locale); + $this->assertSame(7, $occurrence->user_id); + $this->assertSame('2026-11-17 12:07:03', $occurrence->created_at?->format('Y-m-d H:i:s')); + $this->assertSame([ + 'id' => 'evt-1', + 'kind' => 'job', + 'exceptions' => $event->exceptions, + 'request' => $event->request, + 'context' => ['job' => 'Sync'], + 'breadcrumbs' => [['time' => 't', 'category' => 'query', 'message' => 'select 1']], + 'runtime' => ['php' => '8.4.1'], + ], $occurrence->payload); + } + + public function test_an_event_without_a_request_has_no_request_columns(): void + { + $this->reporter()->record($this->event(request: [])); + + $occurrence = Occurrence::query()->sole(); + $this->assertNull($occurrence->site_id); + $this->assertNull($occurrence->method); + $this->assertNull($occurrence->path); + $this->assertNull($occurrence->route); + $this->assertNull($occurrence->locale); + $this->assertNull($occurrence->user_id); + } + + #[DataProvider('widths')] + public function test_every_text_is_cut_to_the_width_of_its_column_in_characters(string $field, int $width): void + { + $long = str_repeat('я', $width + 45); + $exact = str_repeat('я', $width); + $frames = [['file' => $field === 'culprit' ? $long : 'app/X.php', 'line' => 1, 'function' => '', 'in_app' => true]]; + $event = $this->event( + class: $field === 'class' ? $long : 'E', + environment: $field === 'environment' ? $long : 'production', + request: [ + 'method' => $field === 'method' ? $long : 'GET', + 'locale' => $field === 'locale' ? $long : 'en', + 'route' => $field === 'route' ? $long : 'r', + ], + frames: $frames, + ); + + [$issue] = $this->reporter()->record($event); + $occurrence = Occurrence::query()->sole(); + + $shown = match ($field) { + 'class' => $issue->class, + 'culprit' => $issue->culprit, + 'environment' => $occurrence->environment, + 'method' => $occurrence->method, + 'locale' => $occurrence->locale, + 'route' => $occurrence->route, + }; + $this->assertSame($field === 'culprit' ? mb_substr($long.':1', 0, $width) : $exact, $shown); + } + + /** + * @return array + */ + public static function widths(): array + { + return [ + 'the class of the error' => ['class', 255], + 'where it happened' => ['culprit', 255], + 'the environment' => ['environment', 32], + 'the method' => ['method', 8], + 'the locale' => ['locale', 16], + 'the route' => ['route', 255], + ]; + } + + public function test_a_text_that_fits_is_kept_whole(): void + { + $this->reporter()->record($this->event( + class: str_repeat('c', 255), + environment: str_repeat('e', 32), + request: ['method' => str_repeat('m', 8), 'locale' => str_repeat('l', 16), 'route' => str_repeat('r', 255)], + )); + + $occurrence = Occurrence::query()->sole(); + $this->assertSame(str_repeat('c', 255), Issue::query()->sole()->class); + $this->assertSame(str_repeat('e', 32), $occurrence->environment); + $this->assertSame(str_repeat('m', 8), $occurrence->method); + $this->assertSame(str_repeat('l', 16), $occurrence->locale); + $this->assertSame(str_repeat('r', 255), $occurrence->route); + } + + /** + * @param array $request + * @param array> $frames + */ + private function event(string $class = 'App\\Booking\\RoomUnavailable', string $environment = 'production', array $request = [], array $frames = []): Event + { + return new Event( + 'evt-1', 'job', 'error', $class, 'Room 12 is not free', + [['class' => $class, 'message' => 'Room 12 is not free', 'frames' => $frames]], + $request, ['job' => 'Sync'], [['time' => 't', 'category' => 'query', 'message' => 'select 1']], + $environment, '2.4.0', ['php' => '8.4.1'], 'fp-1', CarbonImmutable::parse('2026-11-17 12:07:03 UTC'), + ); + } + + private function reporter(): DatabaseReporter + { + return $this->app->make(DatabaseReporter::class); + } +} diff --git a/packages/errors/tests/Feature/GroupingTest.php b/packages/errors/tests/Feature/GroupingTest.php new file mode 100644 index 00000000..6823265c --- /dev/null +++ b/packages/errors/tests/Feature/GroupingTest.php @@ -0,0 +1,175 @@ +errors()->capture(new RuntimeException('Room 12 is taken')); + + $second = $this->errors()->capture(new RuntimeException('Room 31 is taken')); + + $this->assertNotNull($first); + $this->assertNotNull($second); + $this->assertNotSame($first->frames()[0]['line'], $second->frames()[0]['line']); + $this->assertSame($first->fingerprint, $second->fingerprint); + $this->assertSame(1, Issue::query()->count()); + $this->assertSame('Room 31 is taken', Issue::query()->sole()->message); + } + + public function test_another_class_or_another_place_is_another_issue(): void + { + $a = $this->errors()->capture(new RuntimeException('Same text')); + $b = $this->errors()->capture(new LogicException('Same text')); + $c = $this->throwElsewhere(); + + $this->assertCount(3, array_unique([$a?->fingerprint, $b?->fingerprint, $c?->fingerprint])); + $this->assertSame(3, Issue::query()->count()); + } + + public function test_line_numbers_never_decide(): void + { + $fingerprint = new Fingerprint; + $frames = static fn (int $shift): array => [ + ['file' => 'app/Booking/Reserve.php', 'line' => 40 + $shift, 'function' => 'App\\Booking\\Reserve::handle', 'in_app' => true], + ['file' => 'vendor/laravel/framework/src/Pipeline.php', 'line' => 100, 'function' => 'Illuminate\\Pipeline::then', 'in_app' => false], + ['file' => 'app/Http/Controllers/BookingController.php', 'line' => 12 + $shift, 'function' => 'App\\Http\\Controllers\\BookingController::{closure}', 'in_app' => true], + ]; + + $this->assertSame($fingerprint->of('Error', 'x', $frames(0)), $fingerprint->of('Error', 'y', $frames(7))); + } + + public function test_build_hashes_of_views_and_bundles_do_not_split_an_issue(): void + { + $fingerprint = new Fingerprint; + $view = static fn (string $hash): array => [['file' => 'storage/framework/views/'.$hash.'.php', 'line' => 3, 'function' => 'require', 'in_app' => false]]; + $bundle = static fn (string $hash): array => [['file' => '/build/assets/app-'.$hash.'.js', 'line' => 1, 'function' => 'render', 'in_app' => true]]; + + $this->assertSame($fingerprint->of('ErrorException', 'a', $view('3f2a9c0d1e')), $fingerprint->of('ErrorException', 'a', $view('9b8c7d6e5f'))); + $this->assertSame($fingerprint->of('TypeError', 'a', $bundle('Bx91kQ2z')), $fingerprint->of('TypeError', 'a', $bundle('Zz00aa11'))); + } + + public function test_without_frames_the_message_decides_with_numbers_and_ids_blanked(): void + { + $fingerprint = new Fingerprint; + $empty = [['file' => '', 'line' => 0, 'function' => '', 'in_app' => false]]; + + $this->assertSame( + $fingerprint->of('TypeError', "Cannot read properties of undefined (reading 'price') at 12", []), + $fingerprint->of('TypeError', "Cannot read properties of undefined (reading 'title') at 99", $empty), + ); + $this->assertNotSame($fingerprint->of('TypeError', 'Script error', []), $fingerprint->of('TypeError', 'Network down', [])); + $this->assertSame('Order of for ', Fingerprint::normalizeMessage('Order 42 of 0x9f3a2b1c7d for "Anna"')); + } + + public function test_a_resolved_issue_reopens_when_the_bug_comes_back(): void + { + $this->recordAgain('Tax rate missing'); + $issue = Issue::query()->sole(); + $issue->update(['status' => Issue::RESOLVED, 'resolved_at' => now()]); + + [$again, $outcome] = $this->recordAgain('Tax rate missing'); + + $this->assertSame(DatabaseReporter::OUTCOME_REGRESSION, $outcome); + $this->assertSame(Issue::NEW, $again->status); + $this->assertNotNull($again->regressed_at); + $this->assertNull($again->resolved_at); + $this->assertSame(2, $again->times_seen); + } + + public function test_resolved_in_the_next_release_stays_resolved_in_this_one(): void + { + $this->recordAgain('Old cache key'); + Issue::query()->sole()->update(['status' => Issue::RESOLVED, 'resolved_in' => '2.4.0', 'resolved_at' => now()]); + + // The same release is still running: late events change nothing. + [$same, $outcome] = $this->recordAgain('Old cache key'); + $this->assertSame(DatabaseReporter::OUTCOME_SEEN, $outcome); + $this->assertSame(Issue::RESOLVED, $same->status); + + // The fix went out in 2.5.0 and the bug is still there. + config(['atrium-errors.release' => '2.5.0']); + $this->app->forgetInstance(Release::class); + [$next, $outcome] = $this->recordAgain('Old cache key'); + + $this->assertSame(DatabaseReporter::OUTCOME_REGRESSION, $outcome); + $this->assertSame(Issue::NEW, $next->status); + $this->assertNull($next->resolved_in); + $this->assertSame('2.5.0', $next->last_release); + $this->assertSame('2.4.0', $next->first_release); + } + + public function test_an_ignored_issue_keeps_counting_and_stays_ignored(): void + { + $this->recordAgain('Bot hit a dead link'); + Issue::query()->sole()->update(['status' => Issue::IGNORED]); + + [$issue, $outcome] = $this->recordAgain('Bot hit a dead link'); + + $this->assertSame(DatabaseReporter::OUTCOME_SEEN, $outcome); + $this->assertSame(Issue::IGNORED, $issue->status); + $this->assertSame(2, $issue->times_seen); + } + + public function test_an_issue_created_meanwhile_by_another_process_is_reused(): void + { + $event = $this->app->make(EventFactory::class)->fromThrowable(new RuntimeException('Race')); + + // Another worker inserts the same issue right after our look-up + // found nothing, and before our insert. + $done = false; + DB::listen(static function (QueryExecuted $query) use (&$done, $event): void { + if (! $done && str_starts_with(strtolower($query->sql), 'select') && str_contains($query->sql, 'error_issues')) { + $done = true; + DB::table('error_issues')->insert(['fingerprint' => $event->fingerprint, 'kind' => 'php', 'level' => 'error', 'class' => 'RuntimeException', 'message' => 'Race', 'status' => 'new', 'times_seen' => 0, 'users_seen' => 0, 'first_seen_at' => now()]); + } + }); + + [$issue, $outcome] = $this->app->make(DatabaseReporter::class)->record($event); + + $this->assertSame(DatabaseReporter::OUTCOME_SEEN, $outcome); + $this->assertSame(1, Issue::query()->count()); + $this->assertSame(1, $issue->times_seen); + } + + /** + * An event from always the same place, through the reporter, to see its outcome. + * + * @return array{0:Issue,1:string} + */ + private function recordAgain(string $message): array + { + $event = $this->app->make(EventFactory::class)->fromThrowable(new RuntimeException($message)); + + return $this->app->make(DatabaseReporter::class)->record($event); + } + + private function throwElsewhere(): ?Event + { + return $this->errors()->capture(new RuntimeException('Same text')); + } +} diff --git a/packages/errors/tests/Feature/IssueScreensTest.php b/packages/errors/tests/Feature/IssueScreensTest.php new file mode 100644 index 00000000..9dc05a16 --- /dev/null +++ b/packages/errors/tests/Feature/IssueScreensTest.php @@ -0,0 +1,464 @@ +travelTo(CarbonImmutable::parse('2026-11-17 12:07:00 UTC')); + $this->actingAs($this->admin(), 'admin'); + } + + public function test_a_row_of_the_list_says_everything_the_screen_shows(): void + { + $issue = $this->issue([ + 'class' => 'App\\Booking\\RoomUnavailable', + 'message' => 'Room 12 is not free', + 'culprit' => 'Reserve::handle (app/Booking/Reserve.php)', + 'status' => Issue::NEW, + 'level' => 'fatal', + 'kind' => 'job', + 'times_seen' => 7, + 'users_seen' => 3, + 'first_seen_at' => '2026-11-10 08:00:00', + 'last_seen_at' => '2026-11-17 11:00:00', + 'last_release' => '2.5.0', + ]); + + $row = $this->props('/admin/errors')['issues']['data'][0]; + + $this->assertSame([ + 'id' => $issue->id, + 'class' => 'App\\Booking\\RoomUnavailable', + 'short_class' => 'RoomUnavailable', + 'title' => 'Room 12 is not free', + 'culprit' => 'Reserve::handle (app/Booking/Reserve.php)', + 'status' => 'new', + 'level' => 'fatal', + 'kind' => 'job', + 'times_seen' => 7, + 'users_seen' => 3, + 'first_seen_at' => '2026-11-10T08:00:00+00:00', + 'last_seen_at' => '2026-11-17T11:00:00+00:00', + 'last_release' => '2.5.0', + 'url' => route('admin.errors.show', $issue->id), + ], $row); + } + + public function test_the_title_of_a_row_is_the_first_two_hundred_characters_of_the_message(): void + { + $this->issue(['message' => str_repeat('я', 201)]); + + $this->assertSame(str_repeat('я', 200), $this->props('/admin/errors')['issues']['data'][0]['title']); + } + + public function test_a_row_without_moments_has_none(): void + { + $this->issue(['first_seen_at' => null, 'last_seen_at' => null]); + + $row = $this->props('/admin/errors')['issues']['data'][0]; + + $this->assertNull($row['first_seen_at']); + $this->assertNull($row['last_seen_at']); + } + + public function test_the_filters_come_back_as_they_were_understood(): void + { + $this->assertSame([ + 'q' => '', + 'status' => 'new', + 'level' => '', + 'kind' => '', + 'site' => null, + 'release' => '', + 'path' => '', + 'sort' => 'last_seen_at', + ], $this->props('/admin/errors')['filters']); + + $this->assertSame([ + 'q' => 'timeout', + 'status' => 'ignored', + 'level' => 'warning', + 'kind' => 'schedule', + 'site' => 12, + 'release' => '2.3.0', + 'path' => '/checkout?step=2', + 'sort' => 'users_seen', + ], $this->props('/admin/errors?'.http_build_query([ + 'q' => ' timeout ', + 'status' => 'ignored', + 'level' => 'warning', + 'kind' => 'schedule', + 'site' => '12', + 'release' => ' 2.3.0 ', + 'path' => ' /checkout?step=2 ', + 'sort' => 'users_seen', + ]))['filters']); + } + + public function test_the_filters_are_trimmed_even_when_the_host_does_not_trim_requests(): void + { + $this->withoutMiddleware(TrimStrings::class); + + $filters = $this->props('/admin/errors?'.http_build_query(['q' => ' timeout ', 'release' => ' 2.3.0 ', 'path' => ' /checkout ']))['filters']; + + $this->assertSame(['timeout', '2.3.0', '/checkout'], [$filters['q'], $filters['release'], $filters['path']]); + } + + #[DataProvider('sorts')] + public function test_every_sort_orders_by_its_own_column_and_not_by_the_last_seen(string $sort): void + { + $low = $this->issue(['times_seen' => 1, 'users_seen' => 1, 'first_seen_at' => now()->subDays(9), 'last_seen_at' => now()]); + $high = $this->issue(['times_seen' => 9, 'users_seen' => 9, 'first_seen_at' => now()->subDays(1), 'last_seen_at' => now()->subHour()]); + + $props = $this->props('/admin/errors?sort='.$sort); + + $this->assertSame($sort, $props['filters']['sort']); + $this->assertSame( + $sort === 'last_seen_at' ? [$low->id, $high->id] : [$high->id, $low->id], + array_column($props['issues']['data'], 'id'), + ); + } + + /** + * @return array + */ + public static function sorts(): array + { + return [ + 'last seen' => ['last_seen_at'], + 'first seen' => ['first_seen_at'], + 'times seen' => ['times_seen'], + 'users seen' => ['users_seen'], + ]; + } + + public function test_an_unknown_sort_is_the_last_seen_and_not_a_column_of_the_request(): void + { + $older = $this->issue(['times_seen' => 9, 'last_seen_at' => now()->subHour()]); + $newer = $this->issue(['times_seen' => 1, 'last_seen_at' => now()]); + + $props = $this->props('/admin/errors?sort=message'); + + $this->assertSame('last_seen_at', $props['filters']['sort']); + $this->assertSame([$newer->id, $older->id], array_column($props['issues']['data'], 'id')); + } + + public function test_the_search_finds_the_words_anywhere_in_the_class_message_or_culprit(): void + { + $byMessage = $this->issue(['class' => 'A', 'message' => 'The gateway timeout came', 'culprit' => 'x']); + $byClass = $this->issue(['class' => 'App\\GatewayError', 'message' => 'm', 'culprit' => 'x']); + $byCulprit = $this->issue(['class' => 'B', 'message' => 'm', 'culprit' => 'in the Gateway::send']); + $this->issue(['class' => 'C', 'message' => 'nothing', 'culprit' => 'x']); + + $ids = array_column($this->props('/admin/errors?q='.urlencode(' gateway '))['issues']['data'], 'id'); + + $this->assertEqualsCanonicalizing([$byMessage->id, $byClass->id, $byCulprit->id], $ids); + $this->assertSame([$byMessage->id], array_column($this->props('/admin/errors?q=timeout')['issues']['data'], 'id')); + $this->assertSame([$byMessage->id], array_column($this->props('/admin/errors?q=came')['issues']['data'], 'id')); + } + + public function test_the_path_may_be_given_with_or_without_the_slash_and_with_a_query(): void + { + $checkout = $this->issue(); + $this->occurrence($checkout, ['path' => '/checkout']); + $other = $this->issue(); + $this->occurrence($other, ['path' => '/rooms']); + + foreach (['/checkout', 'checkout', '/checkout?step=2', '//checkout', 'checkout?a=b#c'] as $path) { + $this->assertSame([$checkout->id], array_column($this->props('/admin/errors?path='.urlencode($path))['issues']['data'], 'id'), $path); + } + } + + public function test_the_release_and_the_path_are_cut_by_characters_and_trimmed(): void + { + $release = $this->props('/admin/errors?release='.urlencode(' '.str_repeat('я', 300)))['filters']['release']; + $path = $this->props('/admin/errors?path='.urlencode(' '.str_repeat('ж', 600)))['filters']['path']; + + $this->assertSame(str_repeat('я', 255), $release); + $this->assertSame(str_repeat('ж', 512), $path); + } + + public function test_the_release_and_the_path_are_kept_whole_when_they_fit(): void + { + $this->assertSame(str_repeat('a', 255), $this->props('/admin/errors?release='.str_repeat('a', 255))['filters']['release']); + $this->assertSame(str_repeat('a', 512), $this->props('/admin/errors?path='.str_repeat('a', 512))['filters']['path']); + } + + public function test_the_list_has_twenty_five_to_a_page(): void + { + for ($i = 0; $i < 26; $i++) { + $this->issue(['last_seen_at' => now()->subMinutes($i)]); + } + + $first = $this->props('/admin/errors')['issues']; + $second = $this->props('/admin/errors?page=2')['issues']; + + $this->assertSame(25, $first['per_page']); + $this->assertCount(25, $first['data']); + $this->assertSame(26, $first['total']); + $this->assertCount(1, $second['data']); + } + + public function test_the_sites_to_choose_from_are_named_by_id(): void + { + $site = Site::query()->create(['name' => 'Second site', 'code' => 'second', 'domains' => ['second.example.test'], 'is_active' => true]); + + $sites = $this->props('/admin/errors')['options']['sites']; + + $this->assertContains(['id' => $site->id, 'name' => 'Second site'], $sites); + } + + public function test_the_releases_to_choose_from_are_the_thirty_newest_of_the_last_two_hundred_errors(): void + { + // 199 errors of one release, the 200th of another, the 201st of a third, then 33 more, older still. + for ($i = 1; $i <= 199; $i++) { + $this->issue(['last_release' => 'A', 'last_seen_at' => now()->subMinutes($i)]); + } + $this->issue(['last_release' => 'B', 'last_seen_at' => now()->subMinutes(200)]); + $this->issue(['last_release' => 'C', 'last_seen_at' => now()->subMinutes(201)]); + + $this->assertSame(['A', 'B'], $this->props('/admin/errors?status=all')['options']['releases']); + } + + public function test_the_releases_to_choose_from_are_cut_at_thirty(): void + { + for ($i = 1; $i <= 35; $i++) { + $this->issue(['last_release' => sprintf('r%02d', $i), 'last_seen_at' => now()->subMinutes($i)]); + } + + $releases = $this->props('/admin/errors')['options']['releases']; + + $this->assertCount(30, $releases); + $this->assertSame('r01', $releases[0]); + $this->assertSame('r30', $releases[29]); + } + + public function test_an_error_tells_the_whole_story_of_its_row_and_more(): void + { + $issue = $this->issue([ + 'message' => 'Room 12 is not free', + 'status' => Issue::RESOLVED, + 'resolved_in' => '2.6.0', + 'first_release' => '2.3.0', + 'resolved_at' => '2026-11-16 10:00:00', + 'regressed_at' => '2026-11-17 09:30:00', + ]); + + $props = $this->props('/admin/errors/'.$issue->id); + + $this->assertSame('Room 12 is not free', $props['issue']['message']); + $this->assertSame('2.6.0', $props['issue']['resolved_in']); + $this->assertSame('2.3.0', $props['issue']['first_release']); + $this->assertSame('2026-11-16T10:00:00+00:00', $props['issue']['resolved_at']); + $this->assertSame('2026-11-17T09:30:00+00:00', $props['issue']['regressed_at']); + $this->assertSame($issue->id, $props['issue']['id']); + $this->assertSame('resolved', $props['issue']['status']); + $this->assertSame('Errors', $props['strings']['title']); + } + + public function test_an_error_that_was_never_resolved_has_no_such_moments(): void + { + $issue = $this->issue(['resolved_at' => null, 'regressed_at' => null]); + + $props = $this->props('/admin/errors/'.$issue->id); + + $this->assertArrayHasKey('resolved_at', $props['issue']); + $this->assertNull($props['issue']['resolved_at']); + $this->assertNull($props['issue']['regressed_at']); + } + + public function test_the_event_of_an_error_is_the_payload_with_the_columns_over_it(): void + { + $site = Site::query()->create(['name' => 'Second site', 'code' => 'second', 'domains' => ['second.example.test'], 'is_active' => true]); + $issue = $this->issue(); + $event = $this->occurrence($issue, ['site_id' => $site->id, 'release' => '2.4.1', 'environment' => 'staging', 'created_at' => '2026-11-17 11:15:00']); + + $shown = $this->props('/admin/errors/'.$issue->id)['event']; + + $this->assertSame($event->id, $shown['id']); + $this->assertSame($event->payload['id'], $shown['uuid']); + $this->assertSame('2026-11-17T11:15:00+00:00', $shown['created_at']); + $this->assertSame('2.4.1', $shown['release']); + $this->assertSame('staging', $shown['environment']); + $this->assertSame('Second site', $shown['site']); + $this->assertSame('php', $shown['kind']); + } + + public function test_an_event_of_no_site_names_none_and_of_an_unknown_one_its_number(): void + { + $issue = $this->issue(); + $this->occurrence($issue, ['site_id' => null]); + + $this->assertNull($this->props('/admin/errors/'.$issue->id)['event']['site']); + + $this->occurrence($issue, ['site_id' => 4242]); + + $this->assertSame('#4242', $this->props('/admin/errors/'.$issue->id)['event']['site']); + } + + public function test_an_event_without_a_moment_still_shows(): void + { + $issue = $this->issue(); + $this->occurrence($issue, ['created_at' => null]); + + $props = $this->props('/admin/errors/'.$issue->id); + + $this->assertNull($props['event']['created_at']); + $this->assertNull($props['occurrences']['data'][0]['created_at']); + } + + public function test_the_occurrences_are_listed_newest_first_twenty_to_a_page(): void + { + $site = Site::query()->create(['name' => 'Second site', 'code' => 'second', 'domains' => ['second.example.test'], 'is_active' => true]); + $issue = $this->issue(); + $made = []; + for ($i = 0; $i < 21; $i++) { + $made[] = $this->occurrence($issue, ['path' => '/rooms/'.$i, 'user_id' => $i, 'site_id' => $i === 20 ? $site->id : ($i === 19 ? 777 : null), 'release' => '2.'.$i, 'environment' => 'env'.$i, 'method' => $i === 20 ? 'POST' : 'GET']); + } + + $props = $this->props('/admin/errors/'.$issue->id); + $page = $props['occurrences']; + + $this->assertSame(20, $page['per_page']); + $this->assertSame(21, $page['total']); + $this->assertCount(20, $page['data']); + $this->assertSame([ + 'id' => $made[20]->id, + 'created_at' => '2026-11-17T12:07:00+00:00', + 'release' => '2.20', + 'environment' => 'env20', + 'method' => 'POST', + 'path' => '/rooms/20', + 'site' => 'Second site', + 'user_id' => 20, + ], $page['data'][0]); + $this->assertSame('#777', $page['data'][1]['site']); + $this->assertNull($page['data'][2]['site']); + $this->assertSame($made[1]->id, $page['data'][19]['id']); + $this->assertSame([$made[0]->id], array_column($this->props('/admin/errors/'.$issue->id.'?page=2')['occurrences']['data'], 'id')); + } + + public function test_the_top_lists_hold_five_each_most_often_first_then_by_name(): void + { + $issue = $this->issue(); + foreach (['/b' => 2, '/a' => 2, '/c' => 3, '/d' => 1, '/e' => 1, '/f' => 1, '/g' => 1] as $path => $times) { + for ($i = 0; $i < $times; $i++) { + $this->occurrence($issue, ['path' => $path, 'release' => $path === '/c' ? '2.5.0' : '2.4.0']); + } + } + $this->occurrence($issue, ['path' => null, 'release' => null]); + + $top = $this->props('/admin/errors/'.$issue->id)['top']; + + $this->assertSame([ + ['value' => '/c', 'count' => 3], + ['value' => '/a', 'count' => 2], + ['value' => '/b', 'count' => 2], + ['value' => '/d', 'count' => 1], + ['value' => '/e', 'count' => 1], + ], $top['paths']); + $this->assertSame([ + ['value' => '2.4.0', 'count' => 8], + ['value' => '2.5.0', 'count' => 3], + ], $top['releases']); + } + + public function test_the_top_counts_are_numbers_even_when_the_database_hands_out_strings(): void + { + $issue = $this->issue(); + $this->occurrence($issue, ['path' => '/rooms']); + $this->occurrence($issue, ['path' => '/rooms']); + $pdo = DB::connection()->getPdo(); + $pdo->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true); + + try { + $top = $this->props('/admin/errors/'.$issue->id)['top']; + } finally { + $pdo->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, false); + } + + $this->assertSame([['value' => '/rooms', 'count' => 2]], $top['paths']); + } + + public function test_a_status_without_the_next_release_flag_is_accepted(): void + { + $issue = $this->issue(); + + $this->post('/admin/errors/'.$issue->id.'/status', ['status' => 'resolved'])->assertSessionHasNoErrors(); + + $this->assertSame(Issue::RESOLVED, $issue->refresh()->status); + } + + /** + * @return array}> + */ + public static function searches(): array + { + return [ + 'percent is a percent' => ['50%', ['Discount of 50% refused']], + 'digits without it' => ['500', ['Discount of 500 refused']], + 'underscore is an underscore' => ['a_b', ['Field a_b missing']], + 'the escape character itself' => ['!x', ['Code !x invalid']], + 'a backslash' => ['C:\\temp', ['Cannot write C:\\temp']], + 'class' => ['CouponExpired', ['Coupon gone']], + 'place' => ['Checkout::apply', ['Discount of 50% refused']], + 'nothing like it' => ['50%off', []], + 'small letters find capitals' => ['coupon GONE', ['Coupon gone']], + 'capitals of any alphabet' => ['ЗАНЯТ', ['Номер занят']], + ]; + } + + /** + * @param list $expected + */ + #[DataProvider('searches')] + public function test_the_search_finds_signs_as_they_are_typed(string $q, array $expected): void + { + $this->issue(['message' => 'Discount of 50% refused', 'culprit' => 'App\\Shop\\Checkout::apply (app/Shop/Checkout.php)']); + $this->issue(['message' => 'Discount of 500 refused']); + $this->issue(['message' => 'Field a_b missing']); + $this->issue(['message' => 'Field axb missing']); + $this->issue(['message' => 'Code !x invalid']); + $this->issue(['message' => 'Code x invalid']); + $this->issue(['message' => 'Cannot write C:\\temp']); + $this->issue(['message' => 'Coupon gone', 'class' => 'App\\Shop\\CouponExpired']); + $this->issue(['message' => 'Номер занят']); + + $found = array_column($this->props('/admin/errors?'.http_build_query(['q' => $q]))['issues']['data'], 'title'); + + $this->assertSame($expected, $found); + } + + /** + * The props Inertia handed to the page. + * + * @return array + */ + private function props(string $url): array + { + return $this->get($url)->assertOk()->viewData('page')['props']; + } +} diff --git a/packages/errors/tests/Feature/LimiterTest.php b/packages/errors/tests/Feature/LimiterTest.php new file mode 100644 index 00000000..e36526ae --- /dev/null +++ b/packages/errors/tests/Feature/LimiterTest.php @@ -0,0 +1,211 @@ +travelTo(CarbonImmutable::parse('2026-11-17 12:07:12 UTC')); + } + + #[DataProvider('shares')] + public function test_the_share_of_events_kept_is_the_sample_rate(int $rate, float $dice, bool $kept): void + { + config(['atrium-errors.sample_rate' => $rate]); + $limiter = new Limiter(Cache::store()); + $limiter->useRandom(static fn (): float => $dice); + + $this->assertSame($kept, $limiter->allow()); + } + + public function test_the_dice_given_to_the_constructor_is_the_one_rolled(): void + { + config(['atrium-errors.sample_rate' => 60]); + $rolled = 0; + $limiter = new Limiter(Cache::store(), static function () use (&$rolled): float { + $rolled++; + + return 0.59; + }); + + $this->assertTrue($limiter->allow()); + $this->assertSame(1, $rolled); + } + + /** + * @return array + */ + public static function shares(): array + { + return [ + 'everything at 100, the dice at its top' => [100, 1.0, true], + 'everything above 100' => [101, 1.0, true], + 'everything far above 100' => [250, 1.0, true], + 'nothing at 0' => [0, 0.0, false], + 'nothing at 0, whatever the dice' => [0, 0.5, false], + 'nothing below 0' => [-5, 0.0, false], + 'one percent, dice under it' => [1, 0.0099, true], + 'one percent, dice on it' => [1, 0.01, false], + 'ninety-nine, dice just under it' => [99, 0.9805, true], + 'ninety-nine, dice on it' => [99, 0.99, false], + 'ninety-nine, dice above it' => [99, 0.995, false], + 'half, dice under it' => [50, 0.499, true], + 'half, dice on it' => [50, 0.5, false], + ]; + } + + public function test_a_dice_given_to_the_constructor_is_the_one_that_rolls(): void + { + config(['atrium-errors.sample_rate' => 50]); + + $this->assertTrue((new Limiter(Cache::store(), static fn (): float => 0.1))->allow()); + $this->assertFalse((new Limiter(Cache::store(), static fn (): float => 0.9))->allow()); + } + + public function test_without_a_dice_of_its_own_it_rolls_between_zero_and_one(): void + { + $limiter = new Limiter(Cache::store()); + mt_srand(2026); + + config(['atrium-errors.sample_rate' => 99]); + $kept = 0; + for ($i = 0; $i < 200; $i++) { + $kept += $limiter->allow() ? 1 : 0; + } + // 99 of 100 stay: never all of them lost, never all kept by luck of a seed that is fixed. + $this->assertGreaterThan(150, $kept); + + config(['atrium-errors.sample_rate' => 1]); + $kept = 0; + for ($i = 0; $i < 200; $i++) { + $kept += $limiter->allow() ? 1 : 0; + } + $this->assertLessThan(50, $kept); + } + + public function test_the_dice_is_not_rolled_when_everything_is_kept(): void + { + config(['atrium-errors.sample_rate' => 100]); + $limiter = new Limiter(Cache::store()); + $limiter->useRandom(static fn (): float => throw new RuntimeException('Rolled')); + + $this->assertTrue($limiter->allow()); + } + + public function test_the_events_of_a_minute_are_counted_under_a_key_of_that_minute(): void + { + config(['atrium-errors.sample_rate' => 100, 'atrium-errors.per_minute' => 10]); + $limiter = new Limiter(Cache::store()); + $minute = intdiv(CarbonImmutable::parse('2026-11-17 12:07:12 UTC')->getTimestamp(), 60); + + $limiter->allow(); + $limiter->allow(); + $limiter->allow(); + + $this->assertSame(3, Cache::get('atrium-errors:minute:'.$minute)); + $this->assertNull(Cache::get('atrium-errors:minute:'.($minute + 1))); + $this->assertNull(Cache::get('atrium-errors:minute:'.($minute - 1))); + } + + public function test_the_minute_turns_exactly_on_the_sixtieth_second(): void + { + config(['atrium-errors.sample_rate' => 100, 'atrium-errors.per_minute' => 1]); + $limiter = new Limiter(Cache::store()); + + $this->travelTo(CarbonImmutable::parse('2026-11-17 12:07:00 UTC')); + $this->assertTrue($limiter->allow()); + $this->travelTo(CarbonImmutable::parse('2026-11-17 12:07:59 UTC')); + $this->assertFalse($limiter->allow()); + $this->travelTo(CarbonImmutable::parse('2026-11-17 12:08:00 UTC')); + $this->assertTrue($limiter->allow()); + $this->assertFalse($limiter->allow()); + } + + public function test_the_counter_of_a_minute_is_forgotten_after_two_minutes(): void + { + config(['atrium-errors.sample_rate' => 100, 'atrium-errors.per_minute' => 10]); + $limiter = new Limiter(Cache::store()); + $this->travelTo(CarbonImmutable::parse('2026-11-17 12:07:00 UTC')); + $key = 'atrium-errors:minute:'.intdiv(CarbonImmutable::parse('2026-11-17 12:07:00 UTC')->getTimestamp(), 60); + + $limiter->allow(); + + $this->travelTo(CarbonImmutable::parse('2026-11-17 12:08:59 UTC')); + $this->assertSame(1, Cache::get($key)); + $this->travelTo(CarbonImmutable::parse('2026-11-17 12:09:00 UTC')); + $this->assertNull(Cache::get($key)); + } + + #[DataProvider('caps')] + public function test_the_cap_per_minute_lets_that_many_through(int $cap, int $sent, int $through): void + { + config(['atrium-errors.sample_rate' => 100, 'atrium-errors.per_minute' => $cap]); + $limiter = new Limiter(Cache::store()); + + $kept = 0; + for ($i = 0; $i < $sent; $i++) { + $kept += $limiter->allow() ? 1 : 0; + } + + $this->assertSame($through, $kept); + } + + /** + * @return array + */ + public static function caps(): array + { + return [ + 'one' => [1, 4, 1], + 'two' => [2, 4, 2], + 'as many as sent' => [4, 4, 4], + 'no cap at zero' => [0, 5, 5], + 'no cap below zero' => [-3, 5, 5], + ]; + } + + public function test_a_cache_that_answers_nothing_to_the_counter_does_not_stop_events(): void + { + config(['atrium-errors.sample_rate' => 100, 'atrium-errors.per_minute' => 5]); + $cache = $this->createMock(Repository::class); + $cache->method('add')->willReturn(false); + $cache->method('increment')->willReturn(false); + + $this->assertTrue((new Limiter($cache))->allow()); + } + + public function test_without_a_cache_the_count_starts_again_with_every_minute(): void + { + config(['atrium-errors.sample_rate' => 100, 'atrium-errors.per_minute' => 2]); + $broken = $this->createMock(Repository::class); + $broken->method('add')->willThrowException(new RuntimeException('Redis is down')); + $limiter = new Limiter($broken); + + $this->assertSame([true, true, false, false], [$limiter->allow(), $limiter->allow(), $limiter->allow(), $limiter->allow()]); + + $this->travelTo(CarbonImmutable::parse('2026-11-17 12:08:01 UTC')); + $this->assertSame([true, true, false], [$limiter->allow(), $limiter->allow(), $limiter->allow()]); + } +} diff --git a/packages/errors/tests/Feature/ModuleDetailsTest.php b/packages/errors/tests/Feature/ModuleDetailsTest.php new file mode 100644 index 00000000..14c78a24 --- /dev/null +++ b/packages/errors/tests/Feature/ModuleDetailsTest.php @@ -0,0 +1,482 @@ + 'X', 'route' => 'other.admin.errors.index'], ['label' => 'Y', 'route' => 'admin.errors.index.legacy']]; + + $menu = Menu::add($other); + + $this->assertCount(3, $menu); + $this->assertSame(Menu::GROUP, $menu[2]['key']); + } + + public function test_the_entry_is_not_added_twice(): void + { + $menu = [['label' => 'X', 'route' => 'admin.errors.index']]; + + $this->assertSame($menu, Menu::add($menu)); + } + + public function test_the_entry_joins_a_group_with_several_children_and_leaves_them_all(): void + { + $menu = [ + ['label' => 'Home', 'route' => 'admin.dashboard'], + ['key' => Menu::GROUP, 'label' => 'Health', 'children' => [['route' => 'one'], ['route' => 'two'], ['route' => 'three']]], + ['label' => 'Modules', 'route' => 'admin.modules.index'], + ]; + + $joined = Menu::add($menu); + + $this->assertCount(3, $joined); + $this->assertSame(['one', 'two', 'three', 'admin.errors.index'], array_column($joined[1]['children'], 'route')); + $this->assertSame($menu[0], $joined[0]); + $this->assertSame($menu[2], $joined[2]); + } + + public function test_a_group_without_children_gets_ours_as_the_only_one(): void + { + $joined = Menu::add([['key' => Menu::GROUP, 'label' => 'Health']]); + + $this->assertCount(1, $joined); + $this->assertSame(['admin.errors.index'], array_column($joined[0]['children'], 'route')); + } + + public function test_the_group_goes_before_modules_and_nothing_else_is_lost(): void + { + $menu = [ + ['label' => 'Home', 'route' => 'admin.dashboard'], + ['label' => 'Modules', 'route' => 'admin.modules.index'], + ['label' => 'Settings', 'route' => 'admin.settings'], + ['label' => 'Help', 'route' => 'admin.help'], + ]; + + $added = Menu::add($menu); + + $this->assertSame(['admin.dashboard', null, 'admin.modules.index', 'admin.settings', 'admin.help'], array_map(static fn (array $item): mixed => $item['route'] ?? null, $added)); + $this->assertSame(Menu::GROUP, $added[1]['key']); + $this->assertSame([['label' => 'atrium-errors::errors.title', 'route' => 'admin.errors.index', 'icon' => 'info']], $added[1]['children']); + } + + public function test_the_group_goes_first_when_modules_is_first(): void + { + $added = Menu::add([['label' => 'Modules', 'route' => 'admin.modules.index']]); + + $this->assertSame(Menu::GROUP, $added[0]['key']); + $this->assertSame('admin.modules.index', $added[1]['route']); + } + + // ---- prune ---------------------------------------------------------- + + public function test_prune_with_one_day_is_valid_and_with_none_is_not(): void + { + $this->artisan('atrium:errors:prune', ['--days' => '1']) + ->expectsOutput('Deleted 0 events and 0 errors older than 1 days.') + ->assertSuccessful(); + $this->artisan('atrium:errors:prune', ['--days' => '0'])->expectsOutputToContain('days')->assertFailed(); + $this->artisan('atrium:errors:prune', ['--days' => '-5'])->assertFailed(); + } + + public function test_prune_with_nothing_old_deletes_nothing_and_says_zero(): void + { + $issue = $this->issue(); + $this->occurrence($issue); + + $this->artisan('atrium:errors:prune')->expectsOutput('Deleted 0 events and 0 errors older than 90 days.')->assertSuccessful(); + + $this->assertSame(1, Occurrence::query()->count()); + } + + public function test_prune_takes_the_days_from_the_settings_without_the_option(): void + { + $this->settings(['retention_days' => 7]); + $issue = $this->issue(); + $this->occurrence($issue, ['created_at' => now()->subDays(8)]); + $this->occurrence($issue, ['created_at' => now()->subDays(6)]); + + $this->artisan('atrium:errors:prune')->expectsOutput('Deleted 1 events and 0 errors older than 7 days.')->assertSuccessful(); + } + + public function test_prune_deletes_a_thousand_events_at_a_time(): void + { + $issue = $this->issue(); + $rows = []; + for ($i = 0; $i < 1001; $i++) { + $rows[] = ['issue_id' => $issue->id, 'level' => 'error', 'payload' => '{}', 'created_at' => now()->subDays(100)->toDateTimeString()]; + } + foreach (array_chunk($rows, 500) as $chunk) { + DB::table('error_events')->insert($chunk); + } + $deletes = 0; + DB::listen(static function ($query) use (&$deletes): void { + $deletes += str_starts_with($query->sql, 'delete from "error_events"') || str_starts_with($query->sql, 'delete from `error_events`') ? 1 : 0; + }); + + $this->artisan('atrium:errors:prune', ['--days' => '90'])->expectsOutput('Deleted 1001 events and 0 errors older than 90 days.')->assertSuccessful(); + + $this->assertSame(2, $deletes); + $this->assertSame(0, Occurrence::query()->count()); + } + + // ---- the test command ----------------------------------------------- + + public function test_the_test_command_names_the_event_it_sent(): void + { + Artisan::call('atrium:errors:test'); + + $output = Artisan::output(); + $this->assertStringContainsString('Test error '.Occurrence::query()->sole()->payload['id'].' sent to: database.', $output); + } + + // ---- the log driver ------------------------------------------------- + + public function test_the_log_driver_writes_what_is_needed_to_find_the_error_again(): void + { + config(['logging.default' => 'stack']); + $logger = $this->createMock(LoggerInterface::class); + $logger->expects($this->once())->method('log')->with( + 'critical', + '[atrium-errors] App\\Boom: It broke', + [ + 'fingerprint' => 'fp-1', + 'kind' => 'job', + 'release' => '2.4.0', + 'culprit' => 'Boom::run (app/Boom.php)', + 'path' => '/rooms/12', + 'user_id' => 7, + ], + ); + $manager = $this->createMock(LogManager::class); + $manager->expects($this->once())->method('channel')->with('stack')->willReturn($logger); + + (new LogReporter($manager))->report(new Event( + 'evt-1', 'job', 'fatal', 'App\\Boom', 'It broke', + [['class' => 'App\\Boom', 'message' => 'It broke', 'frames' => [['file' => 'app/Boom.php', 'line' => 3, 'function' => 'Boom::run', 'in_app' => true]]]], + ['path' => '/rooms/12', 'user_id' => 7], [], [], 'production', '2.4.0', [], 'fp-1', CarbonImmutable::now(), + )); + } + + // ---- the error handler ---------------------------------------------- + + public function test_the_tracker_says_whether_it_is_on(): void + { + $this->assertTrue($this->errors()->enabled()); + + config(['atrium-errors.enabled' => false]); + + $this->assertFalse($this->errors()->enabled()); + } + + // ---- the models ----------------------------------------------------- + + public function test_the_counters_of_an_issue_are_integers_even_when_the_database_hands_out_strings(): void + { + $id = $this->issue(['times_seen' => 3, 'users_seen' => 2])->id; + $pdo = DB::connection()->getPdo(); + $pdo->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true); + + try { + $issue = Issue::query()->findOrFail($id); + $seen = [$issue->times_seen, $issue->users_seen]; + } finally { + $pdo->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, false); + } + + $this->assertSame([3, 2], $seen); + } + + // ---- the dashboard tile --------------------------------------------- + + public function test_the_tile_lists_five_errors_at_most_the_most_frequent_first(): void + { + for ($i = 1; $i <= 6; $i++) { + $issue = $this->issue(['class' => 'App\\Err'.$i]); + for ($n = 0; $n < $i; $n++) { + $this->occurrence($issue); + } + } + + $top = (new ErrorsGadget)->data()['top']; + + $this->assertSame([6, 5, 4, 3, 2], array_column($top, 'count')); + $this->assertSame(['Err6', 'Err5', 'Err4', 'Err3', 'Err2'], array_column($top, 'class')); + } + + public function test_the_tile_cuts_a_title_to_a_hundred_and_twenty_characters(): void + { + $this->occurrence($this->issue(['message' => str_repeat('я', 130)])); + $this->occurrence($this->issue(['message' => str_repeat('я', 120)])); + + $titles = array_column((new ErrorsGadget)->data()['top'], 'title'); + + $this->assertSame([str_repeat('я', 120), str_repeat('я', 120)], $titles); + } + + public function test_the_tile_counts_are_integers_even_when_the_database_hands_out_strings(): void + { + $this->occurrence($this->issue()); + $pdo = DB::connection()->getPdo(); + $pdo->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true); + + try { + $top = (new ErrorsGadget)->data()['top']; + } finally { + $pdo->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, false); + } + + $this->assertSame(1, $top[0]['count']); + } + + public function test_the_tile_words_are_always_a_list_even_when_a_translation_is_a_plain_string(): void + { + Lang::addLines(['errors.gadget' => 'plain'], 'en', 'atrium-errors'); + + $this->assertSame(['plain'], (new ErrorsGadget)->data()['strings']); + } + + // ---- the settings form ---------------------------------------------- + + public function test_the_drivers_to_choose_from_are_named_in_words_and_the_unknown_ones_by_name(): void + { + config(['atrium-errors.reporters' => ['rollbar' => BrokenReporter::class]]); + + $drivers = collect((new ErrorsSettings)->fields())->map(static fn ($field) => $field->toArray())->firstWhere('name', 'drivers'); + + $this->assertSame([ + ['value' => 'database', 'label' => 'Site database (the admin screens)'], + ['value' => 'sentry', 'label' => 'Sentry or GlitchTip'], + ['value' => 'log', 'label' => 'Application log'], + ['value' => 'rollbar', 'label' => 'rollbar'], + ], $drivers['options']); + } + + public function test_every_setting_may_be_left_empty(): void + { + $this->actingAs($this->admin(), 'admin'); + + $this->put('/admin/modules/errors/settings', [ + 'drivers' => null, 'sentry_dsn' => null, 'sample_rate' => null, 'per_minute' => null, 'retention_days' => null, + 'alert_email' => null, 'telegram_token' => null, 'telegram_chat' => null, 'spike_per_hour' => null, + ])->assertSessionDoesntHaveErrors(); + } + + /** + * @param array $values + */ + #[DataProvider('limits')] + public function test_a_setting_is_refused_just_outside_its_limits_and_taken_on_them(string $field, mixed $inside, mixed $outside): void + { + $this->actingAs($this->admin(), 'admin'); + + $this->put('/admin/modules/errors/settings', [$field => $inside])->assertSessionDoesntHaveErrors(); + $this->put('/admin/modules/errors/settings', [$field => $outside])->assertSessionHasErrors($field); + } + + /** + * @return array + */ + public static function limits(): array + { + return [ + 'sample rate, at its lowest' => ['sample_rate', 1, 0], + 'sample rate, at its highest' => ['sample_rate', 100, 101], + 'per minute, at its lowest' => ['per_minute', 0, -1], + 'per minute, at its highest' => ['per_minute', 100000, 100001], + 'retention, at its lowest' => ['retention_days', 1, 0], + 'retention, at its highest' => ['retention_days', 3650, 3651], + 'spike, at its lowest' => ['spike_per_hour', 0, -1], + 'spike, at its highest' => ['spike_per_hour', 1000000, 1000001], + 'the emails, at their longest' => ['alert_email', str_repeat('a', 1000), str_repeat('a', 1001)], + 'the dsn, as a dsn' => ['sentry_dsn', 'https://key@sentry.example.test/9', 'https://key@sentry.example.test/'], + 'the token, as a token' => ['telegram_token', '123:abc_DEF', '123abc'], + 'the chat, as a number' => ['telegram_chat', '-1001234', 'chat'], + 'the chat, as a name' => ['telegram_chat', '@north_ops', '@abc'], + ]; + } + + // ---- the wiring ----------------------------------------------------- + + public function test_the_options_are_one_for_a_request(): void + { + $this->assertSame($this->app->make(Options::class), $this->app->make(Options::class)); + } + + public function test_the_breadcrumbs_keep_thirty_by_default_and_as_many_as_configured(): void + { + $this->withoutConfig('breadcrumbs'); + $this->app->forgetInstance(Breadcrumbs::class); + $this->assertCount(30, $this->crumbs()); + + config(['atrium-errors.breadcrumbs' => 4]); + $this->app->forgetInstance(Breadcrumbs::class); + $this->assertCount(4, $this->crumbs()); + } + + public function test_the_code_around_a_throw_is_five_lines_by_default_and_as_many_as_configured(): void + { + $file = sys_get_temp_dir().'/atrium-errors-code-'.bin2hex(random_bytes(4)).'.php'; + file_put_contents($file, implode("\n", array_map(static fn (int $n): string => 'line '.$n, range(1, 40)))."\n"); + + try { + $this->withoutConfig('context_lines'); + $this->app->forgetInstance(Frames::class); + $context = $this->app->make(Frames::class)->of($this->thrownAt($file, 20))[0]['context']; + $this->assertCount(5, $context['pre']); + $this->assertCount(5, $context['post']); + + config(['atrium-errors.context_lines' => 2]); + $this->app->forgetInstance(Frames::class); + $context = $this->app->make(Frames::class)->of($this->thrownAt($file, 20))[0]['context']; + $this->assertCount(2, $context['pre']); + $this->assertCount(2, $context['post']); + } finally { + @unlink($file); + } + } + + public function test_the_scrubber_takes_the_extra_keys_of_the_config_that_are_strings(): void + { + config(['atrium-errors.scrub_keys' => [5 => 'x_custom', 'k' => 'y_custom', 7 => 99, 8 => null]]); + $this->app->forgetInstance(Scrubber::class); + + $scrubbed = $this->app->make(Scrubber::class)->scrub(['x_custom' => 'a', 'y_custom' => 'b', 'plain' => 'c']); + + $this->assertSame(['x_custom' => Scrubber::FILTERED, 'y_custom' => Scrubber::FILTERED, 'plain' => 'c'], $scrubbed); + } + + public function test_the_config_and_the_words_can_be_published(): void + { + $dir = dirname((string) (new \ReflectionClass(ErrorsServiceProvider::class))->getFileName()); + + $this->assertSame( + [$dir.'/../config/atrium-errors.php' => config_path('atrium-errors.php')], + ServiceProvider::pathsToPublish(ErrorsServiceProvider::class, 'atrium-errors-config'), + ); + $this->assertSame( + [$dir.'/../lang' => $this->app->langPath('vendor/atrium-errors')], + ServiceProvider::pathsToPublish(ErrorsServiceProvider::class, 'atrium-errors-lang'), + ); + } + + public function test_a_failed_job_is_captured_with_where_it_ran(): void + { + $job = $this->createStub(Job::class); + $job->method('resolveName')->willReturn('App\\Jobs\\Sync'); + $job->method('getQueue')->willReturn('emails'); + $job->method('attempts')->willReturn(3); + + event(new JobFailed('redis', $job, new RuntimeException('Sync failed'))); + + $this->assertSame(['job' => 'App\\Jobs\\Sync', 'queue' => 'emails', 'connection' => 'redis', 'attempts' => 3], Occurrence::query()->sole()->payload['context']); + $this->assertSame('job', Issue::query()->sole()->kind); + } + + #[DataProvider('tasks')] + public function test_a_failed_scheduled_task_is_captured_with_its_name_cut_to_two_hundred_and_fifty_five_characters(string $name, string $shown): void + { + $task = (new Schedule)->call(static fn () => null)->description($name)->cron('5 4 * * *'); + + event(new ScheduledTaskFailed($task, new RuntimeException('Task failed'))); + + $this->assertSame(['task' => $shown, 'expression' => '5 4 * * *'], Occurrence::query()->sole()->payload['context']); + $this->assertSame('schedule', Issue::query()->sole()->kind); + } + + /** + * @return array + */ + public static function tasks(): array + { + return [ + 'short' => ['Nightly report', 'Nightly report'], + 'exactly as long as it may be' => [str_repeat('я', 255), str_repeat('я', 255)], + 'one over' => [str_repeat('я', 256), str_repeat('я', 255)], + 'far over' => [str_repeat('я', 400), str_repeat('я', 255)], + ]; + } + + public function test_the_error_handler_reports_an_exception_once_whatever_the_kind(): void + { + $error = new RuntimeException('Once'); + + $this->assertNotNull($this->app->make(Errors::class)->capture($error, 'job')); + $this->assertNull($this->app->make(Errors::class)->capture($error, 'php')); + $this->assertSame(1, Occurrence::query()->count()); + } + + private function crumbs(): array + { + $ring = $this->app->make(Breadcrumbs::class); + for ($i = 0; $i < 40; $i++) { + $ring->add('cat', 'message '.$i); + } + + return $ring->all(); + } + + private function withoutConfig(string $key): void + { + $all = config('atrium-errors'); + unset($all[$key]); + config(['atrium-errors' => $all]); + } + + private function thrownAt(string $file, int $line): Exception + { + return new class($file, $line) extends Exception + { + public function __construct(string $file, int $line) + { + parent::__construct('Somewhere'); + $this->file = $file; + $this->line = $line; + } + }; + } +} diff --git a/packages/errors/tests/Feature/NotInstalledTest.php b/packages/errors/tests/Feature/NotInstalledTest.php new file mode 100644 index 00000000..c77aa89d --- /dev/null +++ b/packages/errors/tests/Feature/NotInstalledTest.php @@ -0,0 +1,42 @@ +set('atrium.modules', []); + } + + public function test_a_module_that_is_not_installed_adds_nothing(): void + { + $this->assertNull(Route::getRoutes()->getByName('admin.errors.index')); + $this->assertNull(Route::getRoutes()->getByName('atrium.errors.browser')); + $this->assertNull(RateLimiter::limiter('atrium-errors-browser')); + $this->assertNotContains(ErrorsGadget::class, (array) config('atrium.dashboard.gadgets', [])); + $this->assertNull(config('atrium-mail.purposes.errors')); + $this->assertSame([['label' => 'Home']], Hook::apply('atrium.admin.menu', [['label' => 'Home']])); + $this->assertSame([], array_filter($this->app->make(Schedule::class)->events(), static fn ($event): bool => str_contains((string) $event->command, 'atrium:errors:prune'))); + } +} diff --git a/packages/errors/tests/Feature/OptionsTest.php b/packages/errors/tests/Feature/OptionsTest.php new file mode 100644 index 00000000..3e4291dd --- /dev/null +++ b/packages/errors/tests/Feature/OptionsTest.php @@ -0,0 +1,205 @@ + 40, 'atrium-errors.alerts.email' => 'ops@example.test']); + + $this->assertSame(40, $this->read()->get('sample_rate')); + $this->assertSame('ops@example.test', $this->read()->get('alert_email')); + $this->assertNull($this->read()->get('sentry_dsn')); + } + + public function test_a_name_that_is_not_a_setting_is_read_from_the_config_as_it_is(): void + { + config(['atrium-errors.release' => '9.9.9']); + + $this->assertSame('9.9.9', $this->read()->get('release')); + } + + public function test_what_is_saved_wins_over_the_config(): void + { + config(['atrium-errors.sample_rate' => 40]); + $this->settings(['sample_rate' => 25]); + + $this->assertSame(25, $this->read()->get('sample_rate')); + } + + #[DataProvider('emptyValues')] + public function test_an_empty_saved_value_leaves_the_config_to_answer(mixed $saved): void + { + config(['atrium-errors.sample_rate' => 40]); + $this->settings(['sample_rate' => $saved]); + + $this->assertSame(40, $this->read()->get('sample_rate')); + } + + /** + * @return array + */ + public static function emptyValues(): array + { + return [ + 'null' => [null], + 'an empty string' => [''], + 'an empty list' => [[]], + ]; + } + + #[DataProvider('falsyButSaved')] + public function test_a_saved_zero_or_false_is_a_value_not_an_empty_one(mixed $saved): void + { + config(['atrium-errors.sample_rate' => 40]); + $this->settings(['sample_rate' => $saved]); + + $this->assertSame($saved, $this->read()->get('sample_rate')); + } + + /** + * @return array + */ + public static function falsyButSaved(): array + { + return [ + 'zero' => [0], + 'false' => [false], + 'a zero string' => ['0'], + ]; + } + + public function test_what_was_read_is_kept_until_it_is_flushed(): void + { + $options = $this->read(); + $this->settings(['sample_rate' => 10]); + $this->assertSame(10, $options->int('sample_rate')); + + $this->app->make(Settings::class)->save('errors', ['sample_rate' => 20]); + $this->assertSame(10, $options->int('sample_rate')); + + $options->flush(); + $this->assertSame(20, $options->int('sample_rate')); + } + + #[DataProvider('integers')] + public function test_a_number_is_read_as_an_integer(mixed $value, int $expected): void + { + config(['atrium-errors.per_minute' => $value]); + + $this->assertSame($expected, $this->read()->int('per_minute')); + } + + /** + * @return array + */ + public static function integers(): array + { + return [ + 'an integer' => [30, 30], + 'a numeric string' => ['45', 45], + 'a string with words' => ['12 per minute', 12], + 'nothing' => [null, 0], + 'a negative' => [-3, -3], + ]; + } + + #[DataProvider('switches')] + public function test_a_switch_is_read_as_a_boolean(mixed $value, bool $expected): void + { + config(['atrium-errors.alerts.new' => $value]); + + $this->assertSame($expected, $this->read()->bool('alert_new')); + } + + /** + * @return array + */ + public static function switches(): array + { + return [ + 'true' => [true, true], + 'on' => ['on', true], + 'yes' => ['yes', true], + 'one' => ['1', true], + 'false' => [false, false], + 'off' => ['off', false], + 'zero' => ['0', false], + 'nothing' => [null, false], + 'words' => ['maybe', false], + ]; + } + + #[DataProvider('strings')] + public function test_a_string_is_trimmed_and_only_scalars_are_strings(mixed $value, string $expected): void + { + config(['atrium-errors.alerts.telegram_chat' => $value]); + + $this->assertSame($expected, $this->read()->string('telegram_chat')); + } + + /** + * @return array + */ + public static function strings(): array + { + return [ + 'as it is' => ['@north_ops', '@north_ops'], + 'with spaces around' => [' @north_ops ', '@north_ops'], + 'with a newline around' => ["\n@north_ops\t", '@north_ops'], + 'a number' => [-1001234, '-1001234'], + 'nothing' => [null, ''], + 'a list' => [['a'], ''], + ]; + } + + /** + * @param array $expected + */ + #[DataProvider('drivers')] + public function test_the_drivers_are_names_without_spaces_blanks_and_repeats(mixed $configured, array $expected): void + { + config(['atrium-errors.drivers' => $configured]); + + $this->assertSame($expected, $this->read()->drivers()); + } + + /** + * @return array}> + */ + public static function drivers(): array + { + return [ + 'a list' => [['database', 'log'], ['database', 'log']], + 'a comma-separated string' => ['database,log', ['database', 'log']], + 'a string with spaces, blanks and repeats' => [' database , ,log,database,', ['database', 'log']], + 'a list with spaces' => [[' log ', 'database'], ['log', 'database']], + 'a list with blanks and repeats, counted again from zero' => [['', ' log ', 'log', '', 'database'], ['log', 'database']], + 'a list with keys' => [['a' => 'log', 'b' => 'sentry'], ['log', 'sentry']], + 'a number among the names' => [[5, 'log'], ['5', 'log']], + 'nothing' => [null, []], + 'an empty string' => ['', []], + ]; + } + + private function read(): Options + { + return $this->app->make(Options::class); + } +} diff --git a/packages/errors/tests/Feature/PipelineTest.php b/packages/errors/tests/Feature/PipelineTest.php new file mode 100644 index 00000000..2cec7a9e --- /dev/null +++ b/packages/errors/tests/Feature/PipelineTest.php @@ -0,0 +1,330 @@ + 40]); + $limiter = $this->app->make(Limiter::class); + + $limiter->useRandom(static fn (): float => 0.39); + $this->assertNotNull($this->errors()->capture(new RuntimeException('kept'))); + + $limiter->useRandom(static fn (): float => 0.4); + $this->assertNull($this->errors()->capture(new RuntimeException('dropped'))); + + $this->assertSame(['kept'], Issue::query()->pluck('message')->all()); + } + + public function test_the_cap_per_minute_drops_what_is_above_it(): void + { + $this->settings(['per_minute' => 3]); + + $kept = 0; + for ($i = 0; $i < 10; $i++) { + $kept += $this->errors()->capture(new RuntimeException('Loop '.$i)) !== null ? 1 : 0; + } + + $this->assertSame(3, $kept); + $this->assertSame(3, Occurrence::query()->count()); + } + + public function test_without_a_cache_the_cap_is_counted_by_the_process(): void + { + $broken = $this->createMock(Repository::class); + $broken->method('add')->willThrowException(new RuntimeException('Redis is down')); + $limiter = new Limiter($broken); + config(['atrium-errors.per_minute' => 2]); + + $this->assertSame([true, true, false], [$limiter->allow(), $limiter->allow(), $limiter->allow()]); + } + + public function test_when_the_database_is_down_the_event_goes_to_the_fallback_log(): void + { + $default = config('database.default'); + config(['database.connections.down' => ['driver' => 'sqlite', 'database' => '/nonexistent-folder/atrium.sqlite', 'prefix' => '']]); + + try { + config(['database.default' => 'down']); + $event = $this->errors()->capture(new RuntimeException('Disk is full')); + } finally { + config(['database.default' => $default]); + DB::purge('down'); + } + + $this->assertNotNull($event); + $lines = $this->fallbackLines(); + $this->assertCount(1, $lines); + $this->assertSame($event->id, $lines[0]['event']['id']); + $this->assertSame('Disk is full', $lines[0]['event']['message']); + $this->assertNotEmpty($lines[0]['reason']); + $this->assertSame(0, Occurrence::query()->count()); + } + + public function test_a_failing_driver_does_not_stop_the_others(): void + { + config([ + 'atrium-errors.drivers' => ['broken', 'database'], + 'atrium-errors.reporters' => ['broken' => BrokenReporter::class], + ]); + + $this->errors()->capture(new RuntimeException('Still stored')); + + $this->assertSame(1, Occurrence::query()->count()); + $this->assertStringContainsString('broken driver failed: '.RuntimeException::class.': Out of order', (string) $this->fallbackLines()[0]['note']); + } + + public function test_an_error_inside_the_tracker_is_noted_not_thrown(): void + { + config(['atrium-errors.sample_rate' => 50]); + $this->app->make(Limiter::class)->useRandom(static fn (): float => throw new RuntimeException('Dice broke')); + + $this->assertNull($this->errors()->capture(new RuntimeException('Lost'))); + + $this->assertStringContainsString('could not capture an error: '.RuntimeException::class.': Dice broke', (string) $this->fallbackLines()[0]['note']); + } + + public function test_an_error_inside_a_driver_is_not_captured_again(): void + { + config([ + 'atrium-errors.drivers' => ['recursive', 'database'], + 'atrium-errors.reporters' => ['recursive' => RecursiveReporter::class], + ]); + + $this->errors()->capture(new RuntimeException('Outer')); + + $this->assertSame(['Outer'], Issue::query()->pluck('message')->all()); + $this->assertSame(1, RecursiveReporter::$calls); + } + + public function test_when_drivers_cannot_be_resolved_the_event_is_kept_in_the_fallback_log(): void + { + config([ + 'atrium-errors.drivers' => ['unbuildable', 'database'], + 'atrium-errors.reporters' => ['unbuildable' => UnbuildableReporter::class], + ]); + + $this->errors()->capture(new RuntimeException('Kept anyway')); + + $line = $this->fallbackLines()[0]; + $this->assertSame('Kept anyway', $line['event']['message']); + $this->assertStringContainsString('Missing SDK', (string) $line['reason']); + } + + public function test_unknown_drivers_and_classes_that_are_not_reporters_are_skipped(): void + { + config([ + 'atrium-errors.drivers' => 'nowhere, database ,database', + 'atrium-errors.reporters' => ['fake' => \stdClass::class, 'number' => 5], + ]); + + $drivers = $this->app->make(Drivers::class); + + $this->assertSame(['database', 'sentry', 'log'], array_keys($drivers->known())); + $this->assertSame(['database'], array_keys($drivers->active())); + } + + public function test_with_a_queue_the_event_is_queued_and_delivered_by_the_job(): void + { + Queue::fake(); + config(['atrium-errors.queue' => 'redis']); + + $event = $this->errors()->capture(new RuntimeException('Queued')); + + $this->assertSame(0, Occurrence::query()->count()); + Queue::assertPushed(DeliverEvent::class, function (DeliverEvent $job) use ($event): bool { + $this->assertSame(1, $job->tries); + $job->handle($this->app->make(Sender::class)); + + return $job->event['id'] === $event?->id; + }); + $this->assertSame(1, Occurrence::query()->count()); + } + + public function test_when_the_queue_refuses_the_event_is_delivered_at_once(): void + { + config(['atrium-errors.queue' => 'no-such-connection']); + + $this->errors()->capture(new RuntimeException('No queue')); + + $this->assertSame(1, Occurrence::query()->count()); + } + + public function test_in_a_web_request_events_wait_for_the_end_of_the_response(): void + { + $this->pretendWeb(); + $sender = $this->app->make(Sender::class); + + $this->errors()->capture(new RuntimeException('First')); + $this->errors()->capture(new RuntimeException('Second')); + + $this->assertCount(2, $sender->pending()); + $this->assertSame(0, Occurrence::query()->count()); + + $this->app->terminate(); + + $this->assertSame([], $sender->pending()); + $this->assertSame(2, Occurrence::query()->count()); + } + + public function test_the_buffer_has_a_limit(): void + { + $this->pretendWeb(); + $sender = $this->app->make(Sender::class); + $event = $this->app->make(EventFactory::class)->fromMessage('Flood'); + + for ($i = 0; $i < Sender::BUFFER + 5; $i++) { + $sender->send($event); + } + + $this->assertCount(Sender::BUFFER, $sender->pending()); + } + + public function test_the_event_survives_the_queue_as_an_array(): void + { + $event = $this->app->make(EventFactory::class)->fromThrowable(new RuntimeException('Round trip'), 'job', ['job' => 'Export']); + + $copy = Event::fromArray(json_decode((string) json_encode($event->toArray()), true)); + + $this->assertEquals($event->toArray(), $copy->toArray()); + $this->assertSame($event->culprit(), $copy->culprit()); + } + + public function test_the_culprit_falls_back_to_the_first_frame_and_to_nothing(): void + { + $make = static fn (array $frames): Event => new Event('id', 'php', 'error', 'E', 'm', [['class' => 'E', 'message' => 'm', 'frames' => $frames]], [], [], [], 'testing', '1', [], 'fp', CarbonImmutable::now()); + + $this->assertSame('vendor/x.php:7', $make([['file' => 'vendor/x.php', 'line' => 7, 'function' => '', 'in_app' => false]])->culprit()); + $this->assertSame('Vendor\\Lib::run (vendor/x.php)', $make([['file' => 'vendor/x.php', 'line' => 7, 'function' => 'Vendor\\Lib::run', 'in_app' => false]])->culprit()); + $this->assertNull($make([])->culprit()); + $this->assertNull($make([])->userId()); + } + + public function test_the_log_driver_writes_a_line(): void + { + config(['atrium-errors.drivers' => ['log']]); + Log::shouldReceive('channel')->andReturnSelf(); + Log::shouldReceive('log')->once()->withArgs(static fn (string $level, string $message, array $context): bool => $level === 'critical' + && $message === '[atrium-errors] Error: Call to undefined method' + && $context['kind'] === 'php' + && strlen($context['fingerprint']) === 40); + Log::shouldReceive('log')->once()->withArgs(static fn (string $level): bool => $level === 'warning'); + Log::shouldReceive('log')->once()->withArgs(static fn (string $level): bool => $level === 'info'); + Log::shouldReceive('log')->once()->withArgs(static fn (string $level): bool => $level === 'error'); + + $this->errors()->capture(new \Error('Call to undefined method')); + $this->errors()->message('Slow', 'warning'); + $this->errors()->message('Note', 'info'); + $this->errors()->capture(new RuntimeException('Plain')); + + $this->assertSame(0, Occurrence::query()->count()); + } + + public function test_the_fallback_log_creates_its_folder(): void + { + $folder = sys_get_temp_dir().'/atrium-errors-'.bin2hex(random_bytes(4)); + $log = new FallbackLog($folder.'/deep/errors.log'); + + $log->note('Hello'); + + $this->assertSame($folder.'/deep/errors.log', $log->path()); + $this->assertStringContainsString('"note":"Hello"', (string) file_get_contents($log->path())); + @unlink($log->path()); + @rmdir($folder.'/deep'); + @rmdir($folder); + } + + private function pretendWeb(): void + { + (new ReflectionProperty($this->app, 'isRunningInConsole'))->setValue($this->app, false); + $this->app->forgetInstance(Sender::class); + $this->app->forgetInstance(Errors::class); + } +} + +final class BrokenReporter implements ErrorReporter +{ + public function report(Event $event): void + { + throw new RuntimeException('Out of order'); + } +} + +final class RecursiveReporter implements ErrorReporter +{ + public static int $calls = 0; + + public function report(Event $event): void + { + self::$calls++; + app(Errors::class)->capture(new RuntimeException('Inner')); + } +} + +final class UnbuildableReporter implements ErrorReporter +{ + public function __construct() + { + throw new RuntimeException('Missing SDK'); + } + + public function report(Event $event): void {} + + public function test_settings_fall_back_to_the_config_when_the_database_is_down(): void + { + config(['atrium-errors.drivers' => ['database', 'log']]); + $this->settings(['drivers' => ['database']]); + $options = $this->app->make(Options::class); + $this->assertSame(['database'], $options->drivers()); + + $default = config('database.default'); + config(['database.connections.down' => ['driver' => 'sqlite', 'database' => '/nonexistent-folder/atrium.sqlite', 'prefix' => '']]); + + try { + config(['database.default' => 'down']); + $this->app->make(Settings::class)->flush(); + $options->flush(); + $drivers = $options->drivers(); + } finally { + config(['database.default' => $default]); + DB::purge('down'); + } + + $this->assertSame(['database', 'log'], $drivers); + } +} diff --git a/packages/errors/tests/Feature/ScrubTest.php b/packages/errors/tests/Feature/ScrubTest.php new file mode 100644 index 00000000..cae8a3e7 --- /dev/null +++ b/packages/errors/tests/Feature/ScrubTest.php @@ -0,0 +1,220 @@ + + */ + public static function leakyMessages(): array + { + return [ + 'email' => ['Mail to ivan.kovalenko@example.org bounced', 'ivan.kovalenko@example.org'], + 'email with plus' => ['Unknown user Mary+test@sub.example.co.uk', 'Mary+test@sub.example.co.uk'], + 'phone with plus' => ['SMS to +375 (29) 765-43-21 failed', '765-43-21'], + 'phone with dashes' => ['Callback 8-029-555-12-34 not reached', '555-12-34'], + 'visa card' => ['Charge 4111 1111 1111 1111 declined', '4111 1111 1111 1111'], + 'mastercard no spaces' => ['Card 5555555555554444 expired', '5555555555554444'], + 'password pair' => ['Login failed: password=Hunter2!', 'Hunter2!'], + 'json password' => ['Bad payload {"password":"s3cr3t-pw","name":"x"}', 's3cr3t-pw'], + 'api key in query' => ['GET /api?api_key=K9x2Lm77Qa&page=2 refused', 'K9x2Lm77Qa'], + 'token colon' => ['Rejected token: tk_live_778899', 'tk_live_778899'], + 'bearer' => ['Header Authorization: Bearer abcDEF123456789xyz invalid', 'abcDEF123456789xyz'], + 'basic auth' => ['Proxy said Basic dXNlcjpwYXNzd29yZA== is wrong', 'dXNlcjpwYXNzd29yZA'], + 'url password' => ['Cannot connect to mysql://shop:Pa55word@db.internal/shop', 'Pa55word'], + // A made-up token, written in parts so secret scanners do not take it for a real one. + 'jwt' => ['Expired eyJhbGciOiJIUzI1NiJ9'.'.eyJzdWIiOiIxMjM0NTY3ODkwIn0'.'.dozjgNryP4J3jVmNHl0w5N_XgL0n3I9PlFUP0THsR8U', 'dozjgNryP4J3jVmNHl0w5N'], + 'long api key' => ['Key sk9f8e7d6c5b4a3928170fedcba9876543210abcd not valid', 'sk9f8e7d6c5b4a3928170fedcba9876543210abcd'], + 'php array secret' => ["Config ['secret' => 'q1w2e3r4t5'] rejected", 'q1w2e3r4t5'], + 'cookie pair' => ['laravel_session=abcdef0123456789 expired; cookie=zzz111', 'abcdef0123456789'], + ]; + } + + #[DataProvider('leakyMessages')] + public function test_secrets_in_a_message_never_reach_the_database(string $message, string $secret): void + { + $this->errors()->capture(new RuntimeException($message)); + + $this->assertSame(1, Occurrence::query()->count()); + $this->assertStringNotContainsString($secret, $this->stored()); + } + + public function test_a_laravel_encrypted_value_is_not_stored_even_as_cipher(): void + { + // Split in the source: the lines around the capture are stored too. + $cipher = Crypt::encryptString('passport AB'.'1234567'); + + $this->errors()->capture(new RuntimeException('Cannot decrypt '.$cipher)); + + $this->assertStringNotContainsString(substr($cipher, 0, 40), $this->stored()); + $this->assertStringNotContainsString('AB'.'1234567', $this->stored()); + $this->assertStringContainsString('[encrypted]', $this->stored()); + } + + public function test_context_keys_that_name_secrets_lose_their_values(): void + { + $this->errors()->capture(new RuntimeException('Sync failed'), 'php', [ + 'order' => 1042, + 'password' => 'correct horse', + 'user' => ['email' => 'nina@example.com', 'name' => 'Nina', 'phone_number' => '80291234567'], + 'headers' => ['Authorization' => 'Basic Zm9vOmJhcg==', 'X-Api-Key' => 'k-778', 'Cookie' => 'sid=1', 'Accept' => 'text/html'], + 'rememberToken' => 'rt-31337', + 'stripe-secret' => 'whsec_9', + 'card_number' => '4000000000000002', + 'nested' => ['deeper' => ['credentials' => ['login' => 'bob', 'pin' => '0000']]], + 'flag' => true, + 'object' => new \stdClass, + ]); + + $context = Occurrence::query()->sole()->payload['context']; + $this->assertSame(1042, $context['order']); + $this->assertSame('[Filtered]', $context['password']); + $this->assertSame('[Filtered]', $context['user']['email']); + $this->assertSame('Nina', $context['user']['name']); + $this->assertSame('[Filtered]', $context['user']['phone_number']); + $this->assertSame('[Filtered]', $context['headers']['Authorization']); + $this->assertSame('[Filtered]', $context['headers']['X-Api-Key']); + $this->assertSame('[Filtered]', $context['headers']['Cookie']); + $this->assertSame('text/html', $context['headers']['Accept']); + $this->assertSame('[Filtered]', $context['rememberToken']); + $this->assertSame('[Filtered]', $context['stripe-secret']); + $this->assertSame('[Filtered]', $context['card_number']); + $this->assertSame('[Filtered]', $context['nested']['deeper']['credentials']); + $this->assertTrue($context['flag']); + $this->assertSame('[Filtered]', $context['object']); + + foreach (['correct horse', 'nina@example.com', '80291234567', 'Zm9vOmJhcg', 'k-778', 'rt-31337', 'whsec_9', '4000000000000002', '0000'] as $secret) { + $this->assertStringNotContainsString($secret, $this->stored()); + } + } + + public function test_lines_of_code_around_the_error_are_scrubbed_too(): void + { + try { + (new LeakyCheckout)->pay(); + } catch (Throwable $e) { + $this->errors()->capture($e); + } + + $frame = Occurrence::query()->sole()->payload['exceptions'][0]['frames'][0]; + $this->assertStringContainsString('throw new RuntimeException', $frame['context']['line']); + $this->assertNotEmpty($frame['context']['pre']); + + foreach (['Tr0ub4dor', 'olga.petrova', '123-45-67'] as $secret) { + $this->assertStringNotContainsString($secret, $this->stored()); + } + } + + public function test_the_address_and_the_breadcrumbs_are_scrubbed(): void + { + Log::warning('Reset link sent to pavel@example.com, token=reset-998877'); + + $this->call('GET', '/missing-page?email=pavel%40example.com&reset_token=rt-5544&page=3'); + $this->errors()->capture(new RuntimeException('After the page')); + + $stored = $this->stored(); + foreach (['pav'.'el', 'rt-'.'5544', 'reset-'.'998877'] as $secret) { + $this->assertStringNotContainsString($secret, $stored); + } + $this->assertStringContainsString('page=3', $stored); + } + + /** + * @return array + */ + public static function harmlessTexts(): array + { + return [ + 'order number fails luhn' => ['Order 1234567812345678 not found'], + 'time of day' => ['Lock held since 2026-11-17 10:20:00'], + 'host and port' => ['Connection refused 10.20.30.40:3306'], + 'version' => ['Requires PHP 8.4.12 or newer'], + 'short number' => ['Room 12 on floor 3'], + 'sql placeholder' => ['where email = ? and token = :token'], + 'class name' => ['Class App\\Http\\Controllers\\BookingController not found'], + ]; + } + + #[DataProvider('harmlessTexts')] + public function test_harmless_text_stays_as_it_was(string $text): void + { + $this->assertSame($text, (new Scrubber)->text($text)); + } + + /** + * @return array + */ + public static function keys(): array + { + return [ + 'password' => ['password', true], + 'new_password_confirmation' => ['new_password_confirmation', true], + 'camel token' => ['accessToken', true], + 'kebab' => ['x-auth-token', true], + 'header' => ['Authorization', true], + 'api key' => ['APIKEY', true], + 'email' => ['contact_email', true], + 'tel' => ['tel', true], + 'iban' => ['payout_iban', true], + 'name' => ['name', false], + 'title' => ['title', false], + 'passenger' => ['passengers', false], + 'empty' => ['', false], + 'number' => [7, false], + 'mailbox word' => ['mailbox_size', false], + 'glued password' => ['userpassword', true], + 'glued secret' => ['clientsecretvalue', true], + 'glued token' => ['refreshtokens', true], + 'glued authorization' => ['proxyauthorizationheader', true], + 'glued cookie' => ['sessioncookiejar', true], + 'glued api key' => ['legacyapikeyhash', true], + 'glued harmless' => ['passengercount', false], + ]; + } + + #[DataProvider('keys')] + public function test_which_keys_are_secret(string|int $key, bool $secret): void + { + $this->assertSame($secret, (new Scrubber)->isSensitiveKey($key)); + } + + public function test_project_keys_are_added_from_the_config(): void + { + $scrubber = new Scrubber(['loyalty_no']); + + $this->assertTrue($scrubber->isSensitiveKey('Loyalty-No')); + $this->assertSame(['loyalty_no' => '[Filtered]', 'city' => 'Minsk'], $scrubber->scrub(['loyalty_no' => 'L-77', 'city' => 'Minsk'])); + } + + public function test_empty_values_and_deep_structures(): void + { + $scrubber = new Scrubber; + $deep = ['a' => ['b' => ['c' => ['d' => ['e' => ['f' => ['g' => ['h' => ['i' => ['j' => 'x']]]]]]]]]]; + + $this->assertSame(['password' => '', 'token' => null, 'secret' => false], $scrubber->scrub(['password' => '', 'token' => null, 'secret' => false])); + $this->assertSame('', $scrubber->text('')); + $this->assertSame('[Filtered]', $scrubber->scrub($deep)['a']['b']['c']['d']['e']['f']['g']['h']['i']); + } +} diff --git a/packages/errors/tests/Feature/SentryDetailsTest.php b/packages/errors/tests/Feature/SentryDetailsTest.php new file mode 100644 index 00000000..3685958f --- /dev/null +++ b/packages/errors/tests/Feature/SentryDetailsTest.php @@ -0,0 +1,167 @@ +createMock(Transport::class); + $transport->expects($this->never())->method('send'); + config(['atrium-errors.sentry.dsn' => null]); + + (new SentryReporter($transport, $this->app->make(Options::class)))->report($this->event()); + + $this->addToAssertionCount(1); + } + + public function test_the_reporter_hands_the_parsed_dsn_and_the_payload_to_the_transport(): void + { + $event = $this->event(); + $transport = $this->createMock(Transport::class); + $transport->expects($this->once())->method('send')->with( + $this->callback(static fn (Dsn $dsn): bool => $dsn->envelopeUrl() === 'https://sentry.example.test/api/9/envelope/'), + SentryReporter::payload($event), + ); + config(['atrium-errors.sentry.dsn' => ' https://key@sentry.example.test/9 ']); + + (new SentryReporter($transport, $this->app->make(Options::class)))->report($event); + } + + public function test_an_envelope_is_a_header_an_item_header_and_the_event_each_on_a_line_with_a_last_newline(): void + { + $dsn = Dsn::parse('https://key@sentry.example.test/9'); + $event = ['event_id' => 'evt-1', 'message' => 'Нет /места']; + + $envelope = HttpTransport::envelope($dsn, $event); + + $this->assertStringEndsWith("\n", $envelope); + $this->assertStringStartsNotWith("\n", $envelope); + $lines = explode("\n", $envelope); + $this->assertCount(4, $lines); + $this->assertSame('', $lines[3]); + $header = json_decode($lines[0], true); + $this->assertSame(['event_id', 'dsn', 'sent_at'], array_keys($header)); + $this->assertSame('evt-1', $header['event_id']); + $this->assertSame('https://key@sentry.example.test/9', $header['dsn']); + $this->assertMatchesRegularExpression('/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\dZ$/', $header['sent_at']); + $this->assertSame('{"event_id":"evt-1","message":"Нет /места"}', $lines[2]); + $this->assertSame('{"type":"event","length":'.strlen($lines[2]).'}', $lines[1]); + $this->assertStringContainsString('"dsn":"https://key@sentry.example.test/9"', $lines[0]); + } + + public function test_an_event_without_an_id_has_a_null_one_in_the_header(): void + { + $header = json_decode(explode("\n", HttpTransport::envelope(Dsn::parse('https://key@sentry.example.test/9'), ['message' => 'x']))[0], true); + + $this->assertArrayHasKey('event_id', $header); + $this->assertNull($header['event_id']); + } + + public function test_an_event_that_cannot_be_encoded_is_still_sent_in_part(): void + { + $envelope = HttpTransport::envelope(Dsn::parse('https://key@sentry.example.test/9'), ['event_id' => 'evt-1', 'message' => "Broken \xB1\x31", 'level' => 'error']); + + $lines = explode("\n", $envelope); + $this->assertSame(['event_id' => 'evt-1', 'message' => null, 'level' => 'error'], json_decode($lines[2], true)); + } + + public function test_the_wait_for_sentry_is_three_seconds_unless_told_otherwise(): void + { + $timeouts = []; + Http::globalMiddleware(static function (callable $handler) use (&$timeouts): callable { + return static function ($request, array $options) use ($handler, &$timeouts) { + $timeouts[] = $options['timeout'] ?? null; + + return $handler($request, $options); + }; + }); + Http::fake(['*' => Http::response(['id' => 'abc'])]); + $dsn = Dsn::parse('https://key@sentry.example.test/9'); + $factory = $this->app->make(Factory::class); + + (new HttpTransport($factory))->send($dsn, ['event_id' => 'a']); + (new HttpTransport($factory, 8))->send($dsn, ['event_id' => 'b']); + + $this->assertSame([3, 8], $timeouts); + } + + public function test_the_container_waits_for_sentry_as_configured_and_three_seconds_by_default(): void + { + $timeouts = []; + Http::globalMiddleware(static function (callable $handler) use (&$timeouts): callable { + return static function ($request, array $options) use ($handler, &$timeouts) { + $timeouts[] = $options['timeout'] ?? null; + + return $handler($request, $options); + }; + }); + Http::fake(['*' => Http::response(['id' => 'abc'])]); + $dsn = Dsn::parse('https://key@sentry.example.test/9'); + + config(['atrium-errors.sentry' => ['dsn' => null]]); + $this->app->make(Transport::class)->send($dsn, ['event_id' => 'a']); + + config(['atrium-errors.sentry' => ['dsn' => null, 'timeout' => 7]]); + $this->app->make(Transport::class)->send($dsn, ['event_id' => 'b']); + + $this->assertSame([3, 7], $timeouts); + } + + #[DataProvider('paddedDsns')] + public function test_a_dsn_with_spaces_around_it_is_the_dsn_without_them(string $given): void + { + $dsn = Dsn::parse($given); + + $this->assertSame('https://key@sentry.example.test/9', (string) $dsn); + $this->assertSame('https://sentry.example.test/api/9/envelope/', $dsn->envelopeUrl()); + } + + /** + * @return array + */ + public static function paddedDsns(): array + { + return [ + 'none' => ['https://key@sentry.example.test/9'], + 'before' => [' https://key@sentry.example.test/9'], + 'after' => ["https://key@sentry.example.test/9 \n"], + 'both' => ["\t https://key@sentry.example.test/9 \r\n"], + ]; + } + + public function test_a_dsn_made_only_of_spaces_is_refused(): void + { + $this->expectException(InvalidArgumentException::class); + + Dsn::parse(' '); + } + + private function event(): Event + { + return new Event('evt-1', 'php', 'error', 'E', 'm', [], [], [], [], 'production', '2.4.0', [], 'fp-1', CarbonImmutable::parse('2025-11-17 12:07:03 UTC')); + } +} diff --git a/packages/errors/tests/Feature/SentryTest.php b/packages/errors/tests/Feature/SentryTest.php new file mode 100644 index 00000000..9be9ec50 --- /dev/null +++ b/packages/errors/tests/Feature/SentryTest.php @@ -0,0 +1,215 @@ +transport = new FakeTransport; + $this->app->instance(Transport::class, $this->transport); + config([ + 'atrium-errors.drivers' => ['database', 'sentry'], + 'atrium-errors.sentry.dsn' => 'https://public123@errors.example.test/42', + ]); + } + + public function test_an_exception_goes_to_sentry_and_to_the_database(): void + { + $event = $this->errors()->capture(new RuntimeException('Booking failed', 0, new LogicException('No rooms left for user@example.com')), 'job', ['job' => 'Sync']); + + $this->assertSame(1, Occurrence::query()->count()); + $this->assertCount(1, $this->transport->sent); + [$dsn, $payload] = $this->transport->sent[0]; + + $this->assertSame('https://errors.example.test/api/42/envelope/', $dsn->envelopeUrl()); + $this->assertSame($event?->id, $payload['event_id']); + $this->assertSame('php', $payload['platform']); + $this->assertSame('error', $payload['level']); + $this->assertSame('2.4.0', $payload['release']); + $this->assertSame('testing', $payload['environment']); + $this->assertSame([$event?->fingerprint], $payload['fingerprint']); + $this->assertSame('job', $payload['tags']['kind']); + $this->assertSame(['job' => 'Sync'], $payload['extra']); + $this->assertSame('Laravel', $payload['contexts']['framework']['name']); + + // Innermost first, frames oldest first: as Sentry expects. + $this->assertSame([LogicException::class, RuntimeException::class], array_column($payload['exception']['values'], 'type')); + $frames = $payload['exception']['values'][1]['stacktrace']['frames']; + $last = end($frames); + $this->assertStringEndsWith('SentryTest.php', $last['filename']); + $this->assertTrue($last['in_app']); + $this->assertArrayHasKey('context_line', $last); + + $this->assertStringNotContainsString('user@example.com', (string) json_encode($payload)); + } + + public function test_a_message_and_a_browser_error_are_mapped_as_such(): void + { + $this->errors()->message('Low disk space', 'warning'); + $message = $this->transport->sent[0][1]; + + $this->assertSame(['formatted' => 'Low disk space'], $message['message']); + $this->assertArrayNotHasKey('exception', $message); + $this->assertSame('warning', $message['level']); + + $event = $this->app->make(EventFactory::class)->fromBrowser(['message' => 'x is undefined', 'stack' => 'at render (https://localhost/app.js:3:9)'], request()); + $this->assertSame('javascript', SentryReporter::payload($event)['platform']); + } + + public function test_the_request_user_and_breadcrumbs_are_mapped(): void + { + $admin = $this->admin(); + $this->actingAs($admin, 'admin'); + Log::error('Payment provider timeout'); + + $this->errors()->capture(new RuntimeException('After a log line')); + $payload = $this->transport->sent[0][1]; + + $this->assertSame(['id' => (string) $admin->id], $payload['user']); + $this->assertSame('GET', $payload['request']['method']); + $levels = array_column($payload['breadcrumbs']['values'], 'level', 'category'); + $this->assertSame('error', $levels['log.error']); + } + + public function test_without_a_dsn_nothing_is_sent(): void + { + config(['atrium-errors.sentry.dsn' => null]); + + $this->errors()->capture(new RuntimeException('Local only')); + + $this->assertSame([], $this->transport->sent); + $this->assertSame(1, Occurrence::query()->count()); + } + + public function test_a_dsn_saved_in_the_admin_wins_over_the_config(): void + { + $this->settings(['sentry_dsn' => 'https://k@glitchtip.example.test/7']); + + $this->errors()->capture(new RuntimeException('To GlitchTip')); + + $this->assertSame('https://glitchtip.example.test/api/7/envelope/', $this->transport->sent[0][0]->envelopeUrl()); + } + + public function test_the_http_transport_posts_an_envelope(): void + { + Http::fake(['*' => Http::response(['id' => 'abc'])]); + $this->app->forgetInstance(Transport::class); + $this->app->offsetUnset(Transport::class); + $this->app->bind(Transport::class, fn (): Transport => new HttpTransport($this->app->make(Factory::class), 2)); + + $event = $this->errors()->capture(new RuntimeException('Over HTTP')); + + Http::assertSent(static function (Request $request) use ($event): bool { + [$header, $item, $body] = explode("\n", trim($request->body())); + $header = json_decode($header, true); + $item = json_decode($item, true); + + return $request->url() === 'https://errors.example.test/api/42/envelope/' + && $request->header('X-Sentry-Auth')[0] === 'Sentry sentry_version=7, sentry_client='.HttpTransport::CLIENT.', sentry_key=public123' + && $header['event_id'] === $event?->id + && $header['dsn'] === 'https://public123@errors.example.test/42' + && $item === ['type' => 'event', 'length' => strlen($body)] + && json_decode($body, true)['event_id'] === $event?->id; + }); + } + + public function test_a_refusing_sentry_is_noted_and_the_database_still_gets_the_event(): void + { + Http::fake(['*' => Http::response('rate limited', 429)]); + $this->app->offsetUnset(Transport::class); + $this->app->bind(Transport::class, fn (): Transport => new HttpTransport($this->app->make(Factory::class))); + + $this->errors()->capture(new RuntimeException('Sentry is busy')); + + $this->assertSame(1, Occurrence::query()->count()); + $this->assertSame('sentry driver failed: RuntimeException: Sentry answered 429', $this->fallbackLines()[0]['note']); + } + + /** + * @return array + */ + public static function dsns(): array + { + return [ + 'sentry.io' => ['https://abc@o123.ingest.sentry.io/456', 'https://o123.ingest.sentry.io/api/456/envelope/', 'abc'], + 'with secret' => ['https://abc:old-secret@sentry.example.test/9', 'https://sentry.example.test/api/9/envelope/', 'abc'], + 'port and path' => ['http://key@localhost:9000/sentry/12/', 'http://localhost:9000/sentry/api/12/envelope/', 'key'], + ]; + } + + #[DataProvider('dsns')] + public function test_dsns_are_parsed(string $dsn, string $url, string $key): void + { + $parsed = Dsn::parse($dsn); + + $this->assertSame($url, $parsed->envelopeUrl()); + $this->assertSame($key, $parsed->publicKey); + $this->assertSame(trim($dsn), (string) $parsed); + } + + /** + * @return array + */ + public static function badDsns(): array + { + return [ + 'empty' => [''], + 'no key' => ['https://sentry.example.test/1'], + 'no project' => ['https://key@sentry.example.test/'], + 'ftp' => ['ftp://key@sentry.example.test/1'], + 'odd project' => ['https://key@sentry.example.test/a-b'], + 'garbage' => ['http:///:@'], + ]; + } + + #[DataProvider('badDsns')] + public function test_bad_dsns_are_refused(string $dsn): void + { + $this->expectException(InvalidArgumentException::class); + + Dsn::parse($dsn); + } +} + +final class FakeTransport implements Transport +{ + /** @var array}> */ + public array $sent = []; + + public function send(Dsn $dsn, array $event): void + { + $this->sent[] = [$dsn, $event]; + } +} diff --git a/packages/errors/tests/Feature/SupportTest.php b/packages/errors/tests/Feature/SupportTest.php new file mode 100644 index 00000000..f9f3cf31 --- /dev/null +++ b/packages/errors/tests/Feature/SupportTest.php @@ -0,0 +1,289 @@ + */ + private array $folders = []; + + protected function tearDown(): void + { + foreach ($this->folders as $folder) { + File::deleteDirectory($folder); + } + + parent::tearDown(); + } + + public function test_prune_deletes_old_events_and_issues_left_empty(): void + { + $old = $this->issue(['last_seen_at' => now()->subDays(100)]); + $this->occurrence($old, ['created_at' => now()->subDays(100)]); + $mixed = $this->issue(); + $this->occurrence($mixed, ['created_at' => now()->subDays(95)]); + $this->occurrence($mixed); + $fresh = $this->issue(['last_seen_at' => now()->subDays(10)]); + $this->occurrence($fresh, ['created_at' => now()->subDays(10)]); + // Seen just now, its event not written yet (sampled away, still queued): stays. + $pending = $this->issue(); + + $this->artisan('atrium:errors:prune') + ->expectsOutput('Deleted 2 events and 1 errors older than 90 days.') + ->assertSuccessful(); + + $this->assertEqualsCanonicalizing([$mixed->id, $fresh->id, $pending->id], Issue::query()->pluck('id')->all()); + $this->assertSame(2, Occurrence::query()->count()); + // The counters stay as they were. + $this->assertSame($mixed->times_seen, $mixed->fresh()?->times_seen); + + $this->artisan('atrium:errors:prune', ['--days' => 5])->expectsOutput('Deleted 1 events and 1 errors older than 5 days.'); + $this->assertEqualsCanonicalizing([$mixed->id, $pending->id], Issue::query()->pluck('id')->all()); + } + + public function test_prune_works_in_chunks_and_follows_the_setting(): void + { + $issue = $this->issue(['last_seen_at' => now()->subDays(40)]); + $rows = array_fill(0, 1001, ['issue_id' => $issue->id, 'level' => 'error', 'release' => '1', 'environment' => 'production', 'payload' => '{}', 'created_at' => now()->subDays(40)]); + foreach (array_chunk($rows, 250) as $chunk) { + Occurrence::query()->insert($chunk); + } + $this->settings(['retention_days' => 30]); + + $this->artisan('atrium:errors:prune')->expectsOutput('Deleted 1001 events and 1 errors older than 30 days.')->assertSuccessful(); + } + + public function test_prune_refuses_a_zero_period(): void + { + $this->artisan('atrium:errors:prune', ['--days' => 0]) + ->expectsOutput('The number of days must be 1 or more.') + ->assertFailed(); + } + + public function test_prune_is_scheduled_daily(): void + { + $events = collect($this->app->make(Schedule::class)->events()) + ->filter(static fn ($event): bool => str_contains((string) $event->command, 'atrium:errors:prune')); + + $this->assertCount(1, $events); + $this->assertSame('40 3 * * *', $events->first()->expression); + } + + public function test_the_test_command_sends_a_test_error(): void + { + $this->artisan('atrium:errors:test') + ->expectsOutputToContain('sent to: database') + ->assertSuccessful(); + + $this->assertSame('Atrium errors: a test error, safe to resolve', Issue::query()->sole()->message); + $this->assertSame(['test' => true], Occurrence::query()->sole()->payload['context']); + } + + public function test_the_test_command_says_when_nothing_can_be_sent(): void + { + config(['atrium-errors.drivers' => []]); + $this->artisan('atrium:errors:test')->expectsOutput('No error driver is switched on.')->assertFailed(); + + config(['atrium-errors.drivers' => ['database'], 'atrium-errors.enabled' => false]); + $this->artisan('atrium:errors:test')->expectsOutputToContain('Not sent')->assertFailed(); + } + + public function test_the_release_comes_from_the_config_then_git_then_composer(): void + { + $this->assertSame('v3.0.1', (new Release('/nowhere', ' v3.0.1 '))->current()); + + $detached = $this->folder(); + File::put($detached.'/.git/HEAD', str_repeat('a1', 20)."\n"); + $this->assertSame(str_repeat('a1', 6), (new Release($detached))->current()); + + $branch = $this->folder(); + File::put($branch.'/.git/HEAD', "ref: refs/heads/main\n"); + File::ensureDirectoryExists($branch.'/.git/refs/heads'); + File::put($branch.'/.git/refs/heads/main', str_repeat('b2', 20)."\n"); + $this->assertSame(str_repeat('b2', 6), (new Release($branch))->current()); + + $packed = $this->folder(); + File::put($packed.'/.git/HEAD', "ref: refs/heads/release\n"); + File::put($packed.'/.git/packed-refs', "# pack-refs\n".str_repeat('c3', 20)." refs/heads/release\n"); + $this->assertSame(str_repeat('c3', 6), (new Release($packed))->current()); + + // A worktree: .git is a file, the refs are in the common folder. + $main = $this->folder(); + $worktree = $this->folder(false); + File::ensureDirectoryExists($main.'/.git/worktrees/feature/'); + File::put($worktree.'/.git', 'gitdir: '.$main.'/.git/worktrees/feature'); + File::put($main.'/.git/worktrees/feature/HEAD', "ref: refs/heads/feature\n"); + File::put($main.'/.git/worktrees/feature/commondir', '../..'); + File::ensureDirectoryExists($main.'/.git/refs/heads'); + File::put($main.'/.git/refs/heads/feature', str_repeat('d4', 20)); + $this->assertSame(str_repeat('d4', 6), (new Release($worktree))->current()); + + $relative = $this->folder(false); + File::ensureDirectoryExists($relative.'/real-git'); + File::put($relative.'/.git', 'gitdir: real-git'); + File::put($relative.'/real-git/HEAD', str_repeat('e5', 20)); + $this->assertSame(str_repeat('e5', 6), (new Release($relative))->current()); + + // An unknown ref and no git at all: Composer's version of the app. + $broken = $this->folder(); + File::put($broken.'/.git/HEAD', "ref: refs/heads/gone\n"); + $composer = InstalledVersions::getRootPackage()['pretty_version']; + $this->assertSame($composer, (new Release($broken))->current()); + $odd = $this->folder(); + File::put($odd.'/.git/HEAD', 'garbage'); + $this->assertSame($composer, (new Release($odd))->current()); + } + + public function test_chart_buckets_for_every_database(): void + { + $this->assertSame("DATE_FORMAT(created_at, '%Y-%m-%d %H')", Frequency::bucketExpression('mysql', 'hour')); + $this->assertSame("DATE_FORMAT(created_at, '%Y-%m-%d')", Frequency::bucketExpression('mariadb', 'day')); + $this->assertSame("to_char(created_at, 'YYYY-MM-DD HH24')", Frequency::bucketExpression('pgsql', 'hour')); + $this->assertSame("to_char(created_at, 'YYYY-MM-DD')", Frequency::bucketExpression('pgsql', 'day')); + $this->assertSame("strftime('%Y-%m-%d %H', created_at)", Frequency::bucketExpression('sqlite', 'hour')); + $this->assertSame("strftime('%Y-%m-%d', created_at)", Frequency::bucketExpression('sqlite', 'day')); + } + + public function test_the_daily_chart_counts_thirty_days(): void + { + $this->travelTo(now()->setTime(12, 0)); + $issue = $this->issue(); + $this->occurrence($issue, ['created_at' => now()->subDays(3)]); + $this->occurrence($issue, ['created_at' => now()->subDays(3)->subHour()]); + $this->occurrence($issue, ['created_at' => now()->subDays(40)]); + $other = $this->issue(); + $this->occurrence($other); + + $daily = $this->app->make(Frequency::class)->daily($issue->id); + + $this->assertCount(30, $daily); + $this->assertSame(2, $daily[26]['value']); + $this->assertSame(2, array_sum(array_column($daily, 'value'))); + $this->assertSame(now()->locale('en')->isoFormat('D MMM'), $daily[29]['label']); + $this->assertSame(3, array_sum(array_column($this->app->make(Frequency::class)->daily(), 'value'))); + } + + public function test_the_chart_counts_are_numbers_even_when_the_database_hands_out_strings(): void + { + $this->travelTo(now()->setTime(12, 0)); + $issue = $this->issue(); + $this->occurrence($issue, ['created_at' => now()->subDays(3)]); + $pdo = DB::connection()->getPdo(); + $pdo->setAttribute(\PDO::ATTR_STRINGIFY_FETCHES, true); + + try { + $daily = $this->app->make(Frequency::class)->daily($issue->id); + } finally { + $pdo->setAttribute(\PDO::ATTR_STRINGIFY_FETCHES, false); + } + + $this->assertSame(1, $daily[26]['value']); + $this->assertSame(0, $daily[25]['value']); + } + + public function test_breadcrumbs_are_a_ring_and_start_clean_for_each_job(): void + { + $ring = new Breadcrumbs(2); + $ring->add('a', '1'); + $ring->add('b', '2'); + $ring->add('c', '3'); + $this->assertSame(['b', 'c'], array_column($ring->all(), 'category')); + + $off = new Breadcrumbs(0); + $off->add('a', '1'); + $this->assertSame([], $off->all()); + + $shared = $this->app->make(Breadcrumbs::class); + $shared->add('log.info', 'before the job'); + event(new JobProcessing('sync', $this->createMock(Job::class))); + $this->assertSame([], $shared->all()); + } + + public function test_frames_have_limits_and_skip_unreadable_files(): void + { + $deep = static function (int $n) use (&$deep): never { + $n === 0 ? throw new RuntimeException('Deep') : $deep($n - 1); + }; + + try { + $deep(80); + } catch (RuntimeException $e) { + $frames = (new Frames(base_path(), 2))->of($e); + } + + $this->assertCount(Frames::MAX_FRAMES, $frames); + $this->assertCount(2, $frames[0]['context']['pre']); + $this->assertCount(15, array_filter($frames, static fn (array $frame): bool => isset($frame['context']))); + + $without = (new Frames(base_path(), 0))->of(new RuntimeException('No code')); + $this->assertArrayNotHasKey('context', $without[0]); + + $eval = eval('return new RuntimeException("From eval");'); + $this->assertArrayNotHasKey('context', (new Frames(base_path()))->of($eval)[0]); + } + + public function test_the_module_listens_only_when_installed(): void + { + config(['atrium.modules' => []]); + $provider = new ErrorsServiceProvider($this->app); + + $this->assertFalse($provider::installed()); + $provider->boot(); + + config(['atrium.modules' => ['alveby/atrium-errors']]); + $this->assertTrue($provider::installed()); + } + + private function folder(bool $git = true): string + { + $folder = sys_get_temp_dir().'/atrium-release-'.bin2hex(random_bytes(4)); + File::ensureDirectoryExists($git ? $folder.'/.git' : $folder); + $this->folders[] = $folder; + + return $folder; + } + + public function test_a_browser_stack_is_cut_at_the_frame_limit(): void + { + $frames = (new Frames(base_path()))->ofBrowserStack(str_repeat("at render (http://localhost/app.js:1:1)\n", Frames::MAX_FRAMES + 5), 'http://localhost'); + + $this->assertCount(Frames::MAX_FRAMES, $frames); + } + + public function test_a_line_past_the_end_of_the_file_has_no_code(): void + { + $e = new RuntimeException('Moved code'); + (new \ReflectionProperty($e, 'line'))->setValue($e, 99999); + + $frame = (new Frames(base_path()))->of($e)[0]; + + $this->assertSame(99999, $frame['line']); + $this->assertArrayNotHasKey('context', $frame); + } +} diff --git a/packages/errors/tests/Feature/WiringTest.php b/packages/errors/tests/Feature/WiringTest.php new file mode 100644 index 00000000..55059e01 --- /dev/null +++ b/packages/errors/tests/Feature/WiringTest.php @@ -0,0 +1,63 @@ +assertSame(['web', 'throttle:90,1', 'atrium.inertia', 'admin.auth', 'atrium.site', AuthorizeErrors::class], $this->adminRoute()->middleware()); + } + + #[DefineEnvironment('noMiddleware')] + public function test_a_host_that_names_no_middleware_gets_the_web_group(): void + { + $this->assertSame(['web', 'atrium.inertia', 'admin.auth', 'atrium.site', AuthorizeErrors::class], $this->adminRoute()->middleware()); + } + + public function test_an_exception_whose_class_is_named_in_the_ignore_list_as_text_is_ignored(): void + { + config(['atrium-errors.ignore' => RuntimeException::class]); + + $this->assertNull($this->errors()->capture(new RuntimeException('Quiet'))); + } + + public function twoMiddleware(Application $app): void + { + $app['config']->set('atrium.middleware', ['web', 'throttle:90,1']); + } + + public function noMiddleware(Application $app): void + { + $atrium = $app['config']->get('atrium'); + unset($atrium['middleware']); + $app['config']->set('atrium', $atrium); + } + + private function adminRoute(): \Illuminate\Routing\Route + { + $route = Route::getRoutes()->getByName('admin.errors.index'); + $this->assertNotNull($route); + + return $route; + } +} diff --git a/packages/errors/tests/Fixtures/FailingJob.php b/packages/errors/tests/Fixtures/FailingJob.php new file mode 100644 index 00000000..f88f8914 --- /dev/null +++ b/packages/errors/tests/Fixtures/FailingJob.php @@ -0,0 +1,26 @@ +reason); + } +} diff --git a/packages/errors/tests/Fixtures/LeakyCheckout.php b/packages/errors/tests/Fixtures/LeakyCheckout.php new file mode 100644 index 00000000..5c57f25d --- /dev/null +++ b/packages/errors/tests/Fixtures/LeakyCheckout.php @@ -0,0 +1,27 @@ +fallback = sys_get_temp_dir().'/atrium-errors-'.getmypid().'-'.bin2hex(random_bytes(4)).'.log'; + + $config = $app['config']; + $config->set('app.key', 'base64:'.base64_encode(str_repeat('a', 32))); + $config->set('app.name', 'Northwind Travel'); + $target = env('DB_CONNECTION'); + $config->set('database.default', in_array($target, ['mysql', 'pgsql'], true) ? $target : 'testing'); + $config->set('cache.default', 'array'); + $config->set('mail.default', 'array'); + $config->set('atrium.demo', false); + $config->set('atrium.modules', ['alveby/atrium-errors']); + $config->set('atrium.auth.two_factor.enabled', false); + $config->set('atrium.dashboard.timings.enabled', false); + $config->set('atrium-errors.release', '2.4.0'); + $config->set('atrium-errors.fallback_log', $this->fallback); + $config->set('atrium-errors.drivers', ['database']); + $config->set('atrium-errors.per_minute', 0); + $config->set('atrium-errors.alerts.email', null); + $config->set('atrium-errors.alerts.telegram_token', null); + $config->set('atrium-errors.alerts.telegram_chat', null); + } + + protected function setUp(): void + { + parent::setUp(); + + $this->withoutVite(); + } + + protected function tearDown(): void + { + if (getenv('KEEP_FALLBACK') && is_file($this->fallback)) { + copy($this->fallback, '/private/tmp/claude-501/fallback.log'); + } + @unlink($this->fallback); + + parent::tearDown(); + } + + /** + * On MySQL and PostgreSQL the whole suite shares one database, set up by + * whichever package's tests run first: the error tables come with these. + */ + protected function defineDatabaseMigrations(): void + { + $this->loadMigrationsFrom(__DIR__.'/../database/migrations'); + } + + protected function errors(): Errors + { + return $this->app->make(Errors::class); + } + + /** + * Settings as saved in the admin. + * + * @param array $values + */ + protected function settings(array $values): void + { + $this->app->make(Settings::class)->save('errors', $values); + $this->app->make(Settings::class)->flush(); + $this->app->make(Options::class)->flush(); + } + + protected function admin(string $email = 'admin@example.com'): AdminUser + { + $admin = AdminUser::query()->create([ + 'name' => 'Admin', + 'email' => $email, + 'password' => 'secret-password', + 'is_active' => true, + ]); + + $admin->forceFill(['is_superadmin' => true])->save(); + + return $admin; + } + + /** + * An administrator who is not a superadmin, with these permissions only. + * + * @param array $permissions + */ + protected function editor(array $permissions = []): AdminUser + { + $editor = AdminUser::query()->create([ + 'name' => 'Editor', + 'email' => 'editor-'.bin2hex(random_bytes(4)).'@example.com', + 'password' => 'secret-password', + 'is_active' => true, + ]); + + $role = AdminRole::query()->create(['name' => 'Role '.bin2hex(random_bytes(4)), 'permissions' => $permissions]); + $editor->roles()->attach($role); + + return $editor->fresh() ?? $editor; + } + + /** + * An issue as the tracker leaves it, for the screens. + * + * @param array $attributes + */ + protected function issue(array $attributes = []): Issue + { + static $n = 0; + $n++; + + return Issue::query()->create([ + 'fingerprint' => sha1('issue-'.$n.'-'.microtime()), + 'kind' => 'php', + 'level' => 'error', + 'class' => 'App\\Booking\\RoomUnavailable', + 'message' => 'Room 12 is not free on the chosen dates', + 'culprit' => 'App\\Booking\\Reserve::handle (app/Booking/Reserve.php)', + 'first_release' => '2.4.0', + 'last_release' => '2.4.0', + 'first_seen_at' => now()->subDay(), + 'last_seen_at' => now(), + ...$attributes, + ]); + } + + /** + * @param array $attributes + */ + protected function occurrence(Issue $issue, array $attributes = []): Occurrence + { + return Occurrence::query()->create([ + 'issue_id' => $issue->id, + 'level' => $issue->level, + 'release' => '2.4.0', + 'environment' => 'production', + 'method' => 'GET', + 'path' => '/rooms', + 'payload' => ['id' => bin2hex(random_bytes(16)), 'kind' => 'php', 'exceptions' => [['class' => $issue->class, 'message' => $issue->message, 'frames' => []]], 'request' => [], 'context' => [], 'breadcrumbs' => [], 'runtime' => ['php' => PHP_VERSION]], + 'created_at' => CarbonImmutable::now(), + ...$attributes, + ]); + } + + /** + * Everything the tracker stored, as one string: what a secret must never be part of. + */ + protected function stored(): string + { + return json_encode([ + DB::table('error_issues')->get()->all(), + DB::table('error_events')->get()->all(), + ], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) ?: ''; + } + + /** + * The lines of the fallback log, decoded. + * + * @return array> + */ + protected function fallbackLines(): array + { + if (! is_file($this->fallback)) { + return []; + } + + return array_map( + static fn (string $line): array => (array) json_decode($line, true), + array_values(array_filter(explode("\n", (string) file_get_contents($this->fallback)))), + ); + } +} diff --git a/packages/errors/tests/Unit/EventTest.php b/packages/errors/tests/Unit/EventTest.php new file mode 100644 index 00000000..459b4d55 --- /dev/null +++ b/packages/errors/tests/Unit/EventTest.php @@ -0,0 +1,71 @@ +> $frames + */ + #[DataProvider('culprits')] + public function test_the_culprit_is_the_first_frame_of_the_application_else_the_first_frame(array $frames, ?string $expected): void + { + $this->assertSame($expected, $this->event($frames)->culprit()); + } + + /** + * @return array>,?string}> + */ + public static function culprits(): array + { + return [ + 'no frames' => [[], null], + 'the only frame, of the application' => [[['file' => 'app/A.php', 'line' => 4, 'function' => 'A::run', 'in_app' => true]], 'A::run (app/A.php)'], + 'the first of the application, not the first' => [[ + ['file' => 'vendor/lib.php', 'line' => 1, 'function' => 'lib', 'in_app' => false], + ['file' => 'app/B.php', 'line' => 2, 'function' => 'B::go', 'in_app' => true], + ['file' => 'app/C.php', 'line' => 3, 'function' => 'C::go', 'in_app' => true], + ], 'B::go (app/B.php)'], + 'none of the application: the first frame' => [[ + ['file' => 'vendor/one.php', 'line' => 1, 'function' => 'one', 'in_app' => false], + ['file' => 'vendor/two.php', 'line' => 2, 'function' => 'two', 'in_app' => false], + ], 'one (vendor/one.php)'], + 'a frame that does not say is not the application' => [[ + ['file' => 'vendor/one.php', 'line' => 1, 'function' => 'one'], + ['file' => 'app/B.php', 'line' => 2, 'function' => 'B::go', 'in_app' => true], + ], 'B::go (app/B.php)'], + 'no frame says, so the first' => [[ + ['file' => 'x.php', 'line' => 1, 'function' => 'x'], + ['file' => 'y.php', 'line' => 2, 'function' => 'y'], + ], 'x (x.php)'], + 'without a function: the file and the line' => [[['file' => 'app/A.php', 'line' => 4, 'function' => '', 'in_app' => true]], 'app/A.php:4'], + 'without a function key' => [[['file' => 'app/A.php', 'line' => 4, 'in_app' => true]], 'app/A.php:4'], + 'without a line: line zero' => [[['file' => 'app/A.php', 'function' => '', 'in_app' => true]], 'app/A.php:0'], + 'without anything' => [[[]], ':0'], + 'a function that is false is none' => [[['file' => 'app/A.php', 'line' => 4, 'function' => false, 'in_app' => true]], 'app/A.php:4'], + ]; + } + + /** + * @param array> $frames + */ + private function event(array $frames): Event + { + return new Event('evt-1', 'php', 'error', 'E', 'm', [['class' => 'E', 'message' => 'm', 'frames' => $frames]], [], [], [], 'production', '2.4.0', [], 'fp-1', CarbonImmutable::parse('2026-11-17 12:07:03 UTC')); + } +} diff --git a/packages/errors/tests/Unit/FallbackLogTest.php b/packages/errors/tests/Unit/FallbackLogTest.php new file mode 100644 index 00000000..6d387dbd --- /dev/null +++ b/packages/errors/tests/Unit/FallbackLogTest.php @@ -0,0 +1,200 @@ +folder = sys_get_temp_dir().'/atrium-fallback-'.bin2hex(random_bytes(6)); + } + + protected function tearDown(): void + { + (new Filesystem)->deleteDirectory($this->folder); + + parent::tearDown(); + } + + public function test_an_event_is_written_with_its_time_the_reason_and_everything_it_holds(): void + { + $event = $this->event('Disk is full'); + $log = new FallbackLog($this->folder.'/errors.log'); + + $log->write($event, new RuntimeException('Connection refused')); + + $line = $this->lines($log)[0]; + $this->assertSame(['time', 'reason', 'event'], array_keys($line)); + $this->assertSame('2026-11-17T12:07:03Z', $line['time']); + $this->assertSame(RuntimeException::class.': Connection refused', $line['reason']); + $this->assertSame($event->toArray(), $line['event']); + } + + public function test_an_event_without_a_reason_is_written_with_a_null_one(): void + { + $log = new FallbackLog($this->folder.'/errors.log'); + + $log->write($this->event('Queue is full')); + + $line = $this->lines($log)[0]; + $this->assertArrayHasKey('reason', $line); + $this->assertNull($line['reason']); + } + + #[DataProvider('reasons')] + public function test_the_reason_is_cut_to_three_hundred_characters_not_bytes(string $message, string $shown): void + { + $log = new FallbackLog($this->folder.'/errors.log'); + + $log->write($this->event('x'), new RuntimeException($message)); + + $this->assertSame(RuntimeException::class.': '.$shown, $this->lines($log)[0]['reason']); + } + + /** + * @return array + */ + public static function reasons(): array + { + return [ + 'short' => ['Gone', 'Gone'], + 'exactly three hundred' => [str_repeat('a', 300), str_repeat('a', 300)], + 'one over' => [str_repeat('a', 301), str_repeat('a', 300)], + 'cyrillic is counted in characters' => [str_repeat('я', 301), str_repeat('я', 300)], + ]; + } + + public function test_text_is_written_as_it_is_not_escaped(): void + { + $log = new FallbackLog($this->folder.'/errors.log'); + + $log->write($this->event('Нет места на диске: /var/www'), new RuntimeException('Сбой /tmp')); + + $raw = (string) file_get_contents($log->path()); + $this->assertStringContainsString('"message":"Нет места на диске: /var/www"', $raw); + $this->assertStringContainsString('Сбой /tmp', $raw); + $this->assertStringNotContainsString('\\u', $raw); + $this->assertStringNotContainsString('\\/', $raw); + } + + public function test_an_event_that_cannot_be_encoded_is_still_written_in_part(): void + { + $log = new FallbackLog($this->folder.'/errors.log'); + + $log->write($this->event("Broken \xB1\x31 bytes")); + + $line = $this->lines($log)[0]; + $this->assertSame('2026-11-17T12:07:03Z', $line['time']); + $this->assertNull($line['event']['message']); + $this->assertSame('abc', $line['event']['id']); + } + + public function test_a_note_is_a_time_and_the_message_as_it_is(): void + { + $log = new FallbackLog($this->folder.'/errors.log'); + + $log->note('Ошибка в /app'); + + $raw = (string) file_get_contents($log->path()); + $line = json_decode($raw, true); + $this->assertSame(['time', 'note'], array_keys($line)); + $this->assertSame('Ошибка в /app', $line['note']); + $this->assertStringContainsString('"note":"Ошибка в /app"', $raw); + $this->assertMatchesRegularExpression('/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d\+00:00$/', $line['time']); + $this->assertEqualsWithDelta(time(), strtotime($line['time']), 5); + } + + #[DataProvider('notes')] + public function test_a_note_is_cut_to_a_thousand_characters_not_bytes(string $message, string $shown): void + { + $log = new FallbackLog($this->folder.'/errors.log'); + + $log->note($message); + + $this->assertSame($shown, $this->lines($log)[0]['note']); + } + + /** + * @return array + */ + public static function notes(): array + { + return [ + 'short' => ['Gone', 'Gone'], + 'exactly a thousand' => [str_repeat('a', 1000), str_repeat('a', 1000)], + 'one over' => [str_repeat('a', 1001), str_repeat('a', 1000)], + 'cyrillic is counted in characters' => [str_repeat('я', 1001), str_repeat('я', 1000)], + ]; + } + + public function test_lines_pile_up_one_per_call_each_ending_in_a_newline(): void + { + $log = new FallbackLog($this->folder.'/errors.log'); + + $log->note('first'); + $log->write($this->event('second')); + $log->note('third'); + + $raw = (string) file_get_contents($log->path()); + $this->assertStringEndsWith(PHP_EOL, $raw); + $lines = explode(PHP_EOL, $raw); + $this->assertCount(4, $lines); + $this->assertSame('', $lines[3]); + $this->assertSame('first', json_decode($lines[0], true)['note']); + $this->assertSame('second', json_decode($lines[1], true)['event']['message']); + $this->assertSame('third', json_decode($lines[2], true)['note']); + } + + public function test_the_missing_folders_are_made_open_for_the_group_but_not_for_others_to_write(): void + { + $log = new FallbackLog($this->folder.'/storage/logs/errors.log'); + $before = umask(0); + + try { + $log->note('Hello'); + } finally { + umask($before); + } + + $this->assertSame(0775, fileperms($this->folder.'/storage') & 0777); + $this->assertSame(0775, fileperms($this->folder.'/storage/logs') & 0777); + } + + /** + * @return array> + */ + private function lines(FallbackLog $log): array + { + return array_map( + static fn (string $line): array => json_decode($line, true), + array_values(array_filter(explode(PHP_EOL, (string) file_get_contents($log->path())))), + ); + } + + private function event(string $message): Event + { + return new Event('abc', 'php', 'error', RuntimeException::class, $message, [], [], [], [], 'testing', '2.4.0', [], 'fp', CarbonImmutable::parse('2026-11-17 12:07:03 UTC')); + } +} diff --git a/packages/errors/tests/Unit/FingerprintTest.php b/packages/errors/tests/Unit/FingerprintTest.php new file mode 100644 index 00000000..a6e1ca1f --- /dev/null +++ b/packages/errors/tests/Unit/FingerprintTest.php @@ -0,0 +1,149 @@ + 'vendor/lib/a.php', 'function' => 'lib', 'in_app' => false], + ['file' => 'app/Pay.php', 'function' => 'Pay::run', 'in_app' => true], + ['file' => 'app/Cart.php', 'function' => 'Cart::buy', 'in_app' => true], + ]; + + $this->assertSame(sha1("Boom\napp/Pay.php|Pay::run\napp/Cart.php|Cart::buy"), (new Fingerprint)->of('Boom', 'ignored', $frames)); + } + + public function test_a_frame_that_does_not_say_it_is_the_applications_is_not(): void + { + $frames = [ + ['file' => 'one.php', 'function' => 'one'], + ['file' => 'two.php', 'function' => 'two', 'in_app' => true], + ]; + + $this->assertSame(sha1("Boom\ntwo.php|two"), (new Fingerprint)->of('Boom', '', $frames)); + } + + public function test_the_flag_may_be_any_truthy_or_falsy_value(): void + { + $frames = [ + ['file' => 'zero.php', 'function' => 'zero', 'in_app' => 0], + ['file' => 'one.php', 'function' => 'one', 'in_app' => 1], + ['file' => 'empty.php', 'function' => 'empty', 'in_app' => ''], + ['file' => 'text.php', 'function' => 'text', 'in_app' => 'yes'], + ]; + + $this->assertSame(sha1("Boom\none.php|one\ntext.php|text"), (new Fingerprint)->of('Boom', '', $frames)); + } + + public function test_without_any_frame_of_the_application_the_first_frames_are_used(): void + { + $frames = array_map(static fn (int $n): array => ['file' => "f{$n}.php", 'function' => "g{$n}", 'in_app' => false], range(1, 7)); + + $this->assertSame(sha1("Boom\nf1.php|g1\nf2.php|g2\nf3.php|g3\nf4.php|g4\nf5.php|g5"), (new Fingerprint)->of('Boom', '', $frames)); + } + + public function test_only_the_top_five_frames_of_the_application_decide(): void + { + $frames = array_map(static fn (int $n): array => ['file' => "f{$n}.php", 'function' => "g{$n}", 'in_app' => true], range(1, 7)); + $same = array_slice($frames, 0, 5); + + $this->assertSame((new Fingerprint)->of('Boom', '', $same), (new Fingerprint)->of('Boom', '', $frames)); + $this->assertSame(sha1("Boom\nf1.php|g1\nf2.php|g2\nf3.php|g3\nf4.php|g4\nf5.php|g5"), (new Fingerprint)->of('Boom', '', $frames)); + } + + public function test_a_frame_with_a_file_only_or_a_function_only_still_counts_and_an_empty_one_does_not(): void + { + $frames = [ + ['file' => 'a.php', 'in_app' => true], + ['function' => 'g', 'in_app' => true], + ['in_app' => true], + ['file' => '', 'function' => '', 'in_app' => true], + // Whatever a frame holds is read as text: false is as empty as ''. + ['file' => false, 'function' => false, 'in_app' => true], + ]; + + $this->assertSame(sha1("Boom\na.php|\n|g"), (new Fingerprint)->of('Boom', '', $frames)); + } + + public function test_the_class_alone_tells_nothing_so_the_message_does(): void + { + $this->assertSame(sha1("Boom\nUser not found"), (new Fingerprint)->of('Boom', 'User 42 not found', [])); + $this->assertSame(sha1("Boom\nUser not found"), (new Fingerprint)->of('Boom', 'User 42 not found', [['in_app' => true]])); + $this->assertNotSame((new Fingerprint)->of('Boom', 'User 42 not found', []), (new Fingerprint)->of('Other', 'User 42 not found', [])); + } + + public function test_the_message_is_not_used_when_there_are_frames(): void + { + $frames = [['file' => 'a.php', 'function' => 'f', 'in_app' => true]]; + + $this->assertSame((new Fingerprint)->of('Boom', 'one', $frames), (new Fingerprint)->of('Boom', 'two', $frames)); + } + + #[DataProvider('files')] + public function test_a_hash_in_the_name_of_a_file_is_left_out(string $file, string $expected): void + { + $frames = [['file' => $file, 'function' => 'f', 'in_app' => true]]; + + $this->assertSame(sha1("Boom\n{$expected}|f"), (new Fingerprint)->of('Boom', '', $frames)); + } + + /** + * @return array + */ + public static function files(): array + { + return [ + 'a compiled view' => ['storage/framework/views/3f9a0c1b2d.php', 'storage/framework/views/compiled.php'], + 'a view under another folder stays' => ['app/storage/framework/views/3f9a0c1b2d.php', 'app/storage/framework/views/3f9a0c1b2d.php'], + 'a view with letters beyond hex stays' => ['storage/framework/views/zzz.php', 'storage/framework/views/zzz.php'], + 'a bundle with a dash' => ['build/assets/app-4f3a9b2c.js', 'build/assets/app.js'], + 'a bundle with a dot' => ['build/assets/app.4f3a9b2c.css', 'build/assets/app.css'], + 'a module bundle' => ['build/assets/chunk-AbCdEf_12.mjs', 'build/assets/chunk.mjs'], + 'a short suffix stays' => ['build/assets/app-4f3a9b.js', 'build/assets/app-4f3a9b.js'], + 'an ordinary file' => ['app/Http/Kernel.php', 'app/Http/Kernel.php'], + ]; + } + + #[DataProvider('messages')] + public function test_the_message_is_blanked_of_what_changes_from_event_to_event(string $message, string $expected): void + { + $this->assertSame($expected, Fingerprint::normalizeMessage($message)); + } + + /** + * @return array + */ + public static function messages(): array + { + return [ + 'numbers' => ['Order 1234 of 3.5 kg', 'Order of kg'], + 'quotes' => ['No "alice" and \'bob\'', 'No and '], + 'a quote across lines' => ["Said \"a\nb\" twice", 'Said twice'], + 'a hex id' => ['Token deadbeef12 gone', 'Token gone'], + 'a prefixed hex id' => ['At 0xDEADBEEF now', 'At now'], + 'a short hex stays but its digits go' => ['Code abc123', 'Code abc'], + 'whitespace folds and the ends go' => [" a \n\t b c \n", 'a b c'], + 'a message cut to five hundred' => [str_repeat('x', 501), str_repeat('x', 500)], + 'five hundred stay' => [str_repeat('x', 500), str_repeat('x', 500)], + 'five hundred characters, not bytes' => [str_repeat('я', 501), str_repeat('я', 500)], + 'nothing to blank' => ['Plain words', 'Plain words'], + 'empty' => ['', ''], + ]; + } +} diff --git a/packages/errors/tests/Unit/FramesTest.php b/packages/errors/tests/Unit/FramesTest.php new file mode 100644 index 00000000..2da7dcf4 --- /dev/null +++ b/packages/errors/tests/Unit/FramesTest.php @@ -0,0 +1,332 @@ +folder = sys_get_temp_dir().'/atrium-frames-'.bin2hex(random_bytes(6)); + mkdir($this->folder.'/app', 0775, true); + } + + protected function tearDown(): void + { + (new Filesystem)->deleteDirectory($this->folder); + + parent::tearDown(); + } + + /** + * An exception that says it was thrown in this file, on this line. + */ + private function thrownAt(string $file, int $line): Throwable + { + return new class($file, $line) extends Exception + { + public function __construct(string $file, int $line) + { + parent::__construct('Somewhere'); + $this->file = $file; + $this->line = $line; + } + }; + } + + /** + * A file of numbered lines: "line 1", "line 2"… + */ + private function code(int $lines, string $name = 'app/Code.php'): string + { + $path = $this->folder.'/'.$name; + @mkdir(dirname($path), 0775, true); + file_put_contents($path, implode("\n", array_map(static fn (int $n): string => 'line '.$n, range(1, $lines)))."\n"); + + return $path; + } + + /** + * @return array + */ + private function firstFrame(Frames $frames, string $file, int $line): array + { + return $frames->of($this->thrownAt($file, $line))[0]; + } + + public function test_each_frame_names_the_function_that_was_running_in_it(): void + { + try { + array_map(static function (): never { + throw new RuntimeException('Inside a callback'); + }, [1]); + } catch (Throwable $e) { + } + + $frames = (new Frames($this->folder))->of($e); + + // The same name on every PHP version, whatever the version calls it. + $this->assertSame(self::class.'::{closure}', $frames[0]['function']); + // PHP itself called the callback: that frame has no place of its own. + $this->assertSame(['file' => '', 'line' => 0, 'function' => 'array_map', 'in_app' => false], array_diff_key($frames[1], ['context' => 1])); + $this->assertSame(self::class.'::'.__FUNCTION__, $frames[2]['function']); + $this->assertSame(__FILE__, $frames[2]['file']); + $this->assertSame('', end($frames)['function']); + } + + /** + * @return array + */ + public static function places(): array + { + return [ + 'application code' => ['app/Booking/Reserve.php', true], + 'a package of the application' => ['packages/shop/src/Cart.php', true], + 'vendor code' => ['vendor/laravel/framework/src/Router.php', false], + 'vendor code deeper down' => ['packages/shop/vendor/lib/Thing.php', false], + 'a folder that only starts like vendor' => ['vendorish/Thing.php', true], + 'compiled views' => ['storage/framework/views/0123abcd.php', false], + 'a storage folder that is not the framework\'s' => ['storage/app/Export.php', true], + 'views in a nested storage folder' => ['app/storage/framework/Thing.php', true], + 'no file at all' => ['', false], + ]; + } + + #[DataProvider('places')] + public function test_only_the_applications_own_code_is_marked_as_such(string $relative, bool $inApp): void + { + $frame = $this->firstFrame(new Frames('/srv/app'), $relative === '' ? '' : '/srv/app/'.$relative, 10); + + $this->assertSame($relative, $frame['file']); + $this->assertSame($inApp, $frame['in_app']); + } + + public function test_code_outside_the_project_is_the_applications_unless_it_is_vendor_code(): void + { + $frames = new Frames('/srv/app'); + + $this->assertTrue($this->firstFrame($frames, '/opt/shared/Thing.php', 1)['in_app']); + $this->assertFalse($this->firstFrame($frames, '/opt/shared/vendor/lib/Thing.php', 1)['in_app']); + } + + /** + * @return array + */ + public static function paths(): array + { + return [ + 'inside the project' => ['/srv/app', '/srv/app/app/Foo.php', 'app/Foo.php'], + 'the project written with a slash at the end' => ['/srv/app/', '/srv/app/app/Foo.php', 'app/Foo.php'], + 'the project written with slashes at the end' => ['/srv/app//', '/srv/app/app/Foo.php', 'app/Foo.php'], + 'backslashes inside the project' => ['/srv/app', '/srv/app/app\\Sub\\Foo.php', 'app/Sub/Foo.php'], + 'a folder next to the project with the same start' => ['/srv/app', '/srv/application/Foo.php', '/srv/application/Foo.php'], + 'outside the project' => ['/srv/app', '/opt/Foo.php', '/opt/Foo.php'], + 'backslashes outside the project' => ['/srv/app', '/opt\\lib\\Foo.php', '/opt/lib/Foo.php'], + ]; + } + + #[DataProvider('paths')] + public function test_a_file_is_named_from_the_project_root_with_forward_slashes(string $base, string $file, string $shown): void + { + $this->assertSame($shown, $this->firstFrame(new Frames($base), $file, 3)['file']); + } + + public function test_the_lines_around_the_throw_are_five_each_way_unless_told_otherwise(): void + { + $frame = $this->firstFrame(new Frames($this->folder), $this->code(30), 10); + + $this->assertSame(['line 5', 'line 6', 'line 7', 'line 8', 'line 9'], $frame['context']['pre']); + $this->assertSame('line 10', $frame['context']['line']); + $this->assertSame(['line 11', 'line 12', 'line 13', 'line 14', 'line 15'], $frame['context']['post']); + } + + /** + * @return array,string,array}> + */ + public static function edges(): array + { + return [ + 'the first line' => [3, 1, [], 'line 1', ['line 2', 'line 3', 'line 4']], + 'the second line' => [3, 2, ['line 1'], 'line 2', ['line 3', 'line 4', 'line 5']], + 'the line right after the first window' => [2, 4, ['line 2', 'line 3'], 'line 4', ['line 5', 'line 6']], + 'the last line' => [3, 12, ['line 9', 'line 10', 'line 11'], 'line 12', []], + 'the one before the last' => [3, 11, ['line 8', 'line 9', 'line 10'], 'line 11', ['line 12']], + 'one line each way' => [1, 6, ['line 5'], 'line 6', ['line 7']], + ]; + } + + /** + * @param array $pre + * @param array $post + */ + #[DataProvider('edges')] + public function test_the_window_of_code_is_cut_at_the_ends_of_the_file(int $around, int $line, array $pre, string $shown, array $post): void + { + $frame = $this->firstFrame(new Frames($this->folder, $around), $this->code(12), $line); + + $this->assertSame(['pre' => $pre, 'line' => $shown, 'post' => $post], $frame['context']); + } + + /** + * @return array + */ + public static function noCode(): array + { + return [ + 'a line past the end' => ['past'], + 'line zero' => ['zero'], + 'a negative line' => ['negative'], + 'a file that is not there' => ['missing'], + 'a folder' => ['folder'], + 'no file name' => ['unnamed'], + ]; + } + + #[DataProvider('noCode')] + public function test_a_frame_without_readable_code_has_none(string $case): void + { + $file = $this->code(5); + [$file, $line] = match ($case) { + 'past' => [$file, 6], + 'zero' => [$file, 0], + 'negative' => [$file, -1], + 'missing' => [$this->folder.'/app/Gone.php', 2], + 'folder' => [$this->folder.'/app', 2], + 'unnamed' => ['', 2], + }; + + $this->assertArrayNotHasKey('context', $this->firstFrame(new Frames($this->folder), $file, $line)); + } + + public function test_long_lines_of_code_are_cut_to_three_hundred_characters(): void + { + $path = $this->folder.'/app/Wide.php'; + $wide = static fn (string $letter): string => str_repeat($letter, 400); + file_put_contents($path, implode("\n", [$wide('я'), $wide('花'), str_repeat('a', 300), $wide('🪑'), $wide('b')])."\n"); + + $context = $this->firstFrame(new Frames($this->folder, 2), $path, 3)['context']; + + $this->assertSame([str_repeat('я', 300), str_repeat('花', 300)], $context['pre']); + $this->assertSame(str_repeat('a', 300), $context['line']); + $this->assertSame([str_repeat('🪑', 300), str_repeat('b', 300)], $context['post']); + } + + public function test_a_line_of_exactly_three_hundred_characters_is_kept_whole_and_one_more_is_cut(): void + { + $path = $this->folder.'/app/Edge.php'; + file_put_contents($path, str_repeat('x', 300)."\n".str_repeat('y', 301)."\n"); + + $this->assertSame(str_repeat('x', 300), $this->firstFrame(new Frames($this->folder), $path, 1)['context']['line']); + $this->assertSame(str_repeat('y', 300), $this->firstFrame(new Frames($this->folder), $path, 2)['context']['line']); + } + + /** + * @return array + */ + public static function sizes(): array + { + return [ + 'just under two megabytes' => [1_999_999, true], + 'two megabytes' => [2_000_000, true], + 'one byte more' => [2_000_001, false], + ]; + } + + #[DataProvider('sizes')] + public function test_a_file_over_two_megabytes_is_not_read(int $bytes, bool $read): void + { + $path = $this->folder.'/app/Huge.php'; + $head = "first\nsecond\n"; + file_put_contents($path, $head.str_repeat('z', $bytes - strlen($head))); + + $frame = $this->firstFrame(new Frames($this->folder), $path, 1); + + $this->assertSame($read, isset($frame['context'])); + if ($read) { + $this->assertSame('first', $frame['context']['line']); + } + } + + public function test_the_place_of_the_throw_has_code_even_in_vendor(): void + { + $file = $this->code(10, 'vendor/lib/Thing.php'); + + $frames = (new Frames($this->folder))->of($this->thrownAt($file, 4)); + + $this->assertFalse($frames[0]['in_app']); + $this->assertSame('line 4', $frames[0]['context']['line']); + } + + /** + * @return array}> + */ + public static function browserStacks(): array + { + return [ + 'Chrome, a named function' => [ + ' at render (http://localhost/app.js:10:5)', + ['file' => '/app.js', 'line' => 10, 'function' => 'render', 'in_app' => true], + ], + 'Chrome, an anonymous function' => [ + ' at http://localhost/app.js:7:1', + ['file' => '/app.js', 'line' => 7, 'function' => '', 'in_app' => true], + ], + 'Firefox and Safari' => [ + 'render@http://localhost/app.js:3:4', + ['file' => '/app.js', 'line' => 3, 'function' => 'render', 'in_app' => true], + ], + 'a function name with spaces around it' => [ + 'render @http://localhost/app.js:3:4', + ['file' => '/app.js', 'line' => 3, 'function' => 'render', 'in_app' => true], + ], + 'a script of another site' => [ + 'at load (https://cdn.example.com/lib.js:99:2)', + ['file' => 'https://cdn.example.com/lib.js', 'line' => 99, 'function' => 'load', 'in_app' => false], + ], + 'a query string and no column' => [ + 'at load (http://localhost/app.js?v=3#top:12)', + ['file' => '/app.js', 'line' => 12, 'function' => 'load', 'in_app' => true], + ], + ]; + } + + /** + * @param array $expected + */ + #[DataProvider('browserStacks')] + public function test_a_browser_stack_row_becomes_a_frame(string $row, array $expected): void + { + $this->assertSame([$expected], (new Frames($this->folder))->ofBrowserStack($row, 'http://localhost')); + } + + public function test_rows_that_are_not_frames_are_skipped(): void + { + $stack = "TypeError: x is undefined\n at render (http://localhost/app.js:10:5)\nnot a frame\n\n" + ."Error: it failed at render (http://localhost/app.js:11:5)\n" + ." at render (http://localhost/app.js:12:5) and then some\n"; + + $this->assertCount(1, (new Frames($this->folder))->ofBrowserStack($stack, 'http://localhost')); + $this->assertSame([], (new Frames($this->folder))->ofBrowserStack('', 'http://localhost')); + } +} diff --git a/packages/errors/tests/Unit/ReleaseTest.php b/packages/errors/tests/Unit/ReleaseTest.php new file mode 100644 index 00000000..75b1da62 --- /dev/null +++ b/packages/errors/tests/Unit/ReleaseTest.php @@ -0,0 +1,176 @@ +folder = sys_get_temp_dir().'/atrium-release-'.bin2hex(random_bytes(6)); + mkdir($this->folder, 0775, true); + } + + protected function tearDown(): void + { + (new Filesystem)->deleteDirectory($this->folder); + + parent::tearDown(); + } + + /** + * @param array $files path inside the project => content; {base} stands for the project folder + */ + private function project(array $files): Release + { + foreach ($files as $path => $content) { + @mkdir(dirname($this->folder.'/'.$path), 0775, true); + file_put_contents($this->folder.'/'.$path, str_replace('{base}', $this->folder, $content)); + } + + return new Release($this->folder); + } + + private function composerVersion(): string + { + return InstalledVersions::getRootPackage()['pretty_version']; + } + + public function test_the_release_is_worked_out_once(): void + { + $release = $this->project(['.git/HEAD' => self::SHA]); + + $this->assertSame('0123456789ab', $release->current()); + + file_put_contents($this->folder.'/.git/HEAD', 'f'.substr(self::SHA, 1)); + + $this->assertSame('0123456789ab', $release->current()); + } + + /** + * @return array + */ + public static function configured(): array + { + return [ + 'as written' => ['v3.0.1', 'v3.0.1'], + 'with spaces around' => [' v3.0.1 ', 'v3.0.1'], + 'ninety-nine characters' => [str_repeat('a', 99), str_repeat('a', 99)], + 'a hundred characters' => [str_repeat('a', 100), str_repeat('a', 100)], + 'a hundred and one characters' => [str_repeat('a', 101), str_repeat('a', 100)], + 'Cyrillic is cut by characters' => [str_repeat('я', 150), str_repeat('я', 100)], + 'Chinese is cut by characters' => [str_repeat('花', 150), str_repeat('花', 100)], + 'only spaces: not configured' => [' ', 'composer'], + 'empty: not configured' => ['', 'composer'], + 'null: not configured' => [null, 'composer'], + ]; + } + + #[DataProvider('configured')] + public function test_a_configured_release_wins(?string $value, string $expected): void + { + $release = new Release($this->folder, $value); + + $this->assertSame($expected === 'composer' ? $this->composerVersion() : $expected, $release->current()); + } + + /** + * @return array,string}> + */ + public static function repositories(): array + { + $short = '0123456789ab'; + $other = 'fedcba987654'; + $otherSha = $other.str_repeat('0', 28); + + return [ + 'a detached head' => [['.git/HEAD' => self::SHA."\n"], $short], + 'a detached head written with Windows line ends' => [['.git/HEAD' => self::SHA."\r\n"], $short], + 'a detached head with spaces around' => [['.git/HEAD' => ' '.self::SHA.' '], $short], + 'forty-one hex digits are not a commit' => [['.git/HEAD' => self::SHA.'0'], 'composer'], + 'text before a commit is not a commit' => [['.git/HEAD' => 'x'.self::SHA], 'composer'], + 'thirty-nine hex digits are not a commit' => [['.git/HEAD' => substr(self::SHA, 1)], 'composer'], + 'a branch' => [['.git/HEAD' => "ref: refs/heads/main\n", '.git/refs/heads/main' => $otherSha."\n"], $other], + 'a branch, the head written with Windows line ends' => [['.git/HEAD' => "ref: refs/heads/main\r\n", '.git/refs/heads/main' => $otherSha], $other], + 'a branch, the head with spaces around' => [['.git/HEAD' => " ref: refs/heads/main \n", '.git/refs/heads/main' => $otherSha], $other], + 'a branch whose commit has spaces around it' => [['.git/HEAD' => 'ref: refs/heads/main', '.git/refs/heads/main' => "\n ".$otherSha."\n"], $other], + 'a head with something after the branch is not a branch' => [['.git/HEAD' => 'ref: refs/heads/main now', '.git/refs/heads/main' => $otherSha], 'composer'], + 'a head with something before the ref is not a ref' => [['.git/HEAD' => 'xref: refs/heads/main', '.git/refs/heads/main' => $otherSha], 'composer'], + 'a branch that is gone' => [['.git/HEAD' => 'ref: refs/heads/gone'], 'composer'], + 'a head that says nothing' => [['.git/HEAD' => 'garbage'], 'composer'], + 'no git at all' => [[], 'composer'], + 'packed refs' => [['.git/HEAD' => 'ref: refs/heads/main', '.git/packed-refs' => "# pack-refs with: peeled\n".$otherSha." refs/heads/main\n".self::SHA." refs/heads/other\n"], $other], + 'packed refs, the branch is not among them' => [['.git/HEAD' => 'ref: refs/heads/main', '.git/packed-refs' => self::SHA." refs/heads/other\n"], 'composer'], + 'packed refs, a longer branch name is not this branch' => [['.git/HEAD' => 'ref: refs/heads/main', '.git/packed-refs' => self::SHA." refs/heads/main-2\n"], 'composer'], + 'a worktree: .git is a file with an absolute path' => [[ + '.git' => "gitdir: {base}/wt\n", + 'wt/HEAD' => 'ref: refs/heads/feature', + 'wt/commondir' => "../common\n", + 'common/refs/heads/feature' => $otherSha, + ], $other], + 'a worktree whose path is written with Windows line ends' => [[ + '.git' => "gitdir: {base}/wt\r\n", + 'wt/HEAD' => 'ref: refs/heads/feature', + 'wt/commondir' => '../common', + 'common/refs/heads/feature' => $otherSha, + ], $other], + 'a worktree with a path relative to the project' => [[ + '.git' => "gitdir: wt\n", + 'wt/HEAD' => self::SHA, + ], $short], + 'a worktree with a relative path written with Windows line ends' => [[ + '.git' => "gitdir: wt \r\n", + 'wt/HEAD' => self::SHA, + ], $short], + 'a worktree whose gitdir is not on the first line' => [[ + '.git' => "# written by git\ngitdir: wt\n", + 'wt/HEAD' => self::SHA, + ], $short], + 'a line that only contains gitdir is not a gitdir line' => [[ + '.git' => "see gitdir: wt\n", + 'wt/HEAD' => self::SHA, + ], 'composer'], + 'a worktree keeps a ref of its own in its own folder' => [[ + '.git' => 'gitdir: {base}/wt', + 'wt/HEAD' => 'ref: refs/bisect/bad', + 'wt/commondir' => '../common', + 'wt/refs/bisect/bad' => $otherSha, + ], $other], + 'a worktree without commondir keeps its refs in its own folder' => [[ + '.git' => 'gitdir: {base}/wt', + 'wt/HEAD' => 'ref: refs/heads/feature', + 'wt/refs/heads/feature' => $otherSha, + ], $other], + ]; + } + + /** + * @param array $files + */ + #[DataProvider('repositories')] + public function test_without_a_configured_release_the_commit_is_read_from_git(array $files, string $expected): void + { + $this->assertSame($expected === 'composer' ? $this->composerVersion() : $expected, $this->project($files)->current()); + } +} diff --git a/packages/errors/tests/Unit/ScrubberTextTest.php b/packages/errors/tests/Unit/ScrubberTextTest.php new file mode 100644 index 00000000..73a57949 --- /dev/null +++ b/packages/errors/tests/Unit/ScrubberTextTest.php @@ -0,0 +1,131 @@ + + */ + public static function numbers(): array + { + return [ + 'a phone of nine digits' => ['call +12 345 678 9 now', 'call [phone] now'], + 'a phone of ten digits' => ['call +12 345 678 98 now', 'call [phone] now'], + 'a phone of fifteen digits' => ['call +123 456 789 012 345 now', 'call [phone] now'], + 'eight digits are too few for a phone' => ['call +1234 5678 now', 'call +1234 5678 now'], + 'sixteen digits are too many for a phone' => ['call +123 456 789 012 3456 now', 'call +123 456 789 012 3456 now'], + 'a card with spaces' => ['card 5555 5555 5555 4444 ok', 'card [card] ok'], + 'a card with dashes' => ['card 4111-1111-1111-1111 ok', 'card [card] ok'], + 'a card without separators' => ['card 4012888888881881 ok', 'card [card] ok'], + 'a card of fifteen digits' => ['card 378282246310005 ok', 'card [card] ok'], + 'a card of thirteen digits' => ['card 4222222222222 ok', 'card [card] ok'], + 'a card that ends in nine' => ['card 9999999999999995 x', 'card [card] x'], + 'a card with every doubled digit above four' => ['card 5105105105105100 ok', 'card [card] ok'], + 'sixteen digits that are not a card' => ['order 5555 5555 5555 4443 shipped', 'order 5555 5555 5555 4443 shipped'], + 'thirteen digits that are not a card' => ['order 4222222222223 shipped', 'order 4222222222223 shipped'], + 'a long number of digits only' => ['id '.str_repeat('1', 32).' end', 'id '.str_repeat('1', 32).' end'], + ]; + } + + #[DataProvider('numbers')] + public function test_numbers_are_hidden_only_when_they_look_like_a_phone_or_a_card(string $text, string $expected): void + { + $this->assertSame($expected, (new Scrubber)->text($text)); + } + + /** + * @return array + */ + public static function keys(): array + { + return [ + 'letters and digits' => ['key '.str_repeat('a1', 16).' end', 'key [token] end'], + 'letters with one digit at the end' => ['key '.str_repeat('a', 31).'1 end', 'key [token] end'], + 'letters only' => ['word '.str_repeat('a', 32).' end', 'word '.str_repeat('a', 32).' end'], + 'a long name of letters and underscores' => ['name '.str_repeat('Ab', 16).' end', 'name '.str_repeat('Ab', 16).' end'], + 'digits only' => ['id '.str_repeat('7', 40).' end', 'id '.str_repeat('7', 40).' end'], + 'with a double underscore, as the names of code are' => ['x '.str_repeat('a1_', 11).'__a1 y', 'x '.str_repeat('a1_', 11).'__a1 y'], + 'one character short of a key' => ['x '.str_repeat('a1', 15).'a y', 'x '.str_repeat('a1', 15).'a y'], + ]; + } + + #[DataProvider('keys')] + public function test_a_long_string_is_a_key_when_it_has_both_letters_and_digits(string $text, string $expected): void + { + $this->assertSame($expected, (new Scrubber)->text($text)); + } + + /** + * @return array + */ + public static function replacements(): array + { + return [ + 'nothing' => ['', ''], + 'a Laravel encrypted value' => ['value eyJpdiI6'.str_repeat('A1', 40).'= end', 'value [encrypted] end'], + 'a bearer token' => ['Rejected Bearer abcDEF123456789xyz!', 'Rejected Bearer [Filtered]!'], + 'a basic one, whatever the case' => ['proxy basic dXNlcjpwYXNzd29yZA== wrong', 'proxy basic [Filtered] wrong'], + 'a token after the word Token' => ['Token abc12345678 bad', 'Token [Filtered] bad'], + 'a word after Bearer that is too short to be a token' => ['Bearer short', 'Bearer short'], + 'a user and a password in an address' => ['Cannot connect to mysql://shop:Pa55word@db.internal/shop', 'Cannot connect to mysql://[Filtered]@db.internal/shop'], + 'a user without a password in an address' => ['ftp://olga@host/x', 'ftp://[Filtered]@host/x'], + 'a password in a sentence' => ['Login failed: password=Hunter2!', 'Login failed: password=[Filtered]'], + 'a password in JSON' => ['Bad payload {"password":"s3cr3t-pw","name":"x"}', 'Bad payload {"password":[Filtered],"name":"x"}'], + 'a key in a query string' => ['GET /api?api_key=K9x2Lm77Qa&page=2 refused', 'GET /api?api_key=[Filtered]&page=2 refused'], + 'a secret in a PHP array' => ["Config ['secret' => 'q1w2e3r4t5'] rejected", "Config ['secret' => [Filtered]] rejected"], + 'a token with a colon' => ['a token: tk_live_778899 b', 'a token: [Filtered] b'], + 'a placeholder of a query is not a value' => ['x email = ? y', 'x email = ? y'], + ]; + } + + #[DataProvider('replacements')] + public function test_each_kind_of_secret_is_replaced_by_its_own_mark(string $text, string $expected): void + { + $this->assertSame($expected, (new Scrubber)->text($text)); + } + + /** + * @return array + */ + public static function names(): array + { + return [ + 'a PIN in camel case' => ['userPIN', true], + 'a PIN in capitals' => ['USER_PIN', true], + 'a CVV' => ['myCVV', true], + 'a cookie header' => ['HTTP_COOKIE', true], + 'a harmless name' => ['userName', false], + 'a harmless name in capitals' => ['USER_NAME', false], + ]; + } + + #[DataProvider('names')] + public function test_a_name_is_secret_whatever_its_case(string $key, bool $secret): void + { + $this->assertSame($secret, (new Scrubber)->isSensitiveKey($key)); + } + + public function test_a_name_of_no_letters_is_not_secret_even_when_a_project_key_is_empty_once_squashed(): void + { + $scrubber = new Scrubber(['-', 'x-token-y']); + + $this->assertFalse($scrubber->isSensitiveKey('_')); + $this->assertFalse($scrubber->isSensitiveKey('***')); + $this->assertTrue($scrubber->isSensitiveKey('X_Token_Y')); + } +} diff --git a/packages/errors/tests/Unit/SentryPayloadTest.php b/packages/errors/tests/Unit/SentryPayloadTest.php new file mode 100644 index 00000000..6d957c21 --- /dev/null +++ b/packages/errors/tests/Unit/SentryPayloadTest.php @@ -0,0 +1,216 @@ +event( + exceptions: [ + ['class' => 'App\\Outer', 'message' => 'Outer failed', 'frames' => [ + ['file' => 'app/Outer.php', 'line' => 10, 'function' => 'Outer::run', 'in_app' => true, 'context' => ['pre' => ['a'], 'line' => 'b', 'post' => ['c']]], + ['file' => 'vendor/lib.php', 'line' => 20, 'function' => 'lib', 'in_app' => false], + ]], + ['class' => 'App\\Inner', 'message' => 'Inner failed', 'frames' => [ + ['file' => 'app/Inner.php', 'line' => 3, 'function' => 'Inner::go', 'in_app' => true], + ]], + ], + request: ['url' => 'https://example.test/rooms', 'method' => 'POST', 'route' => 'rooms.store', 'site_id' => 5, 'locale' => 'ru', 'user_id' => 7], + context: ['job' => 'Sync'], + breadcrumbs: [ + ['time' => 't', 'category' => 'query', 'message' => 'select 1'], + ['time' => 't', 'category' => 'log.error', 'message' => 'Gone'], + ], + runtime: ['php' => '8.4.1', 'laravel' => '12.0', 'os' => 'Linux'], + ); + + $this->assertSame([ + 'event_id' => 'evt-1', + 'timestamp' => 1_763_381_223.25, + 'platform' => 'php', + 'level' => 'error', + 'logger' => 'atrium-errors', + 'release' => '2.4.0', + 'environment' => 'production', + 'exception' => ['values' => [ + ['type' => 'App\\Inner', 'value' => 'Inner failed', 'stacktrace' => ['frames' => [ + ['filename' => 'app/Inner.php', 'lineno' => 3, 'function' => 'Inner::go', 'in_app' => true], + ]]], + ['type' => 'App\\Outer', 'value' => 'Outer failed', 'stacktrace' => ['frames' => [ + ['filename' => 'vendor/lib.php', 'lineno' => 20, 'function' => 'lib', 'in_app' => false], + ['filename' => 'app/Outer.php', 'lineno' => 10, 'function' => 'Outer::run', 'in_app' => true, 'pre_context' => ['a'], 'context_line' => 'b', 'post_context' => ['c']], + ]]], + ]], + 'fingerprint' => ['fp-1'], + 'request' => ['url' => 'https://example.test/rooms', 'method' => 'POST'], + 'user' => ['id' => '7'], + 'tags' => ['kind' => 'php', 'route' => 'rooms.store', 'site' => '5', 'locale' => 'ru'], + 'extra' => ['job' => 'Sync'], + 'breadcrumbs' => ['values' => [ + ['category' => 'query', 'message' => 'select 1', 'level' => 'info'], + ['category' => 'log.error', 'message' => 'Gone', 'level' => 'error'], + ]], + 'contexts' => [ + 'runtime' => ['name' => 'php', 'version' => '8.4.1'], + 'framework' => ['name' => 'Laravel', 'version' => '12.0'], + 'os' => ['name' => 'Linux'], + ], + ], SentryReporter::payload($event)); + } + + public function test_an_event_with_nothing_but_the_basics_has_only_those(): void + { + $payload = SentryReporter::payload($this->event()); + + $this->assertSame([ + 'event_id' => 'evt-1', + 'timestamp' => 1_763_381_223.25, + 'platform' => 'php', + 'level' => 'error', + 'logger' => 'atrium-errors', + 'release' => '2.4.0', + 'environment' => 'production', + 'exception' => ['values' => []], + 'fingerprint' => ['fp-1'], + 'tags' => ['kind' => 'php'], + 'contexts' => [ + 'runtime' => ['name' => 'php', 'version' => null], + 'framework' => ['name' => 'Laravel', 'version' => null], + 'os' => ['name' => null], + ], + ], $payload); + } + + public function test_the_moment_is_in_seconds_with_the_microseconds_as_a_fraction(): void + { + $at = fn (string $moment): float => SentryReporter::payload($this->event(timestamp: CarbonImmutable::parse($moment.' UTC')))['timestamp']; + + $this->assertSame(1_763_381_223.0, $at('2025-11-17 12:07:03')); + $this->assertEqualsWithDelta(1_763_381_223.000001, $at('2025-11-17 12:07:03.000001'), 1e-9); + $this->assertEqualsWithDelta(1_763_381_223.999999, $at('2025-11-17 12:07:03.999999'), 1e-9); + $this->assertEqualsWithDelta(1_763_381_223.5, $at('2025-11-17 12:07:03.5'), 1e-9); + } + + public function test_a_message_has_its_text_and_no_exception(): void + { + $payload = SentryReporter::payload($this->event(kind: 'message', message: 'Low disk space', level: 'warning')); + + $this->assertSame(['formatted' => 'Low disk space'], $payload['message']); + $this->assertArrayNotHasKey('exception', $payload); + $this->assertSame('php', $payload['platform']); + $this->assertSame('warning', $payload['level']); + $this->assertSame('message', $payload['tags']['kind']); + } + + public function test_an_event_that_is_not_a_message_has_no_message(): void + { + $this->assertArrayNotHasKey('message', SentryReporter::payload($this->event(kind: 'job'))); + } + + public function test_a_browser_error_is_a_javascript_one(): void + { + $this->assertSame('javascript', SentryReporter::payload($this->event(kind: 'browser'))['platform']); + } + + #[DataProvider('requests')] + public function test_the_request_is_the_url_with_the_method_when_there_is_a_url(array $request, ?array $expected): void + { + $payload = SentryReporter::payload($this->event(request: $request)); + + if ($expected === null) { + $this->assertArrayNotHasKey('request', $payload); + } else { + $this->assertSame($expected, $payload['request']); + } + } + + /** + * @return array,array|null}> + */ + public static function requests(): array + { + return [ + 'a url and a method' => [['url' => 'https://x.test/a', 'method' => 'GET'], ['url' => 'https://x.test/a', 'method' => 'GET']], + 'a url alone' => [['url' => 'https://x.test/a'], ['url' => 'https://x.test/a']], + 'a method alone' => [['method' => 'GET'], null], + 'nothing' => [[], null], + ]; + } + + #[DataProvider('tags')] + public function test_a_tag_that_is_empty_or_missing_is_left_out(array $request, array $expected): void + { + $this->assertSame($expected, SentryReporter::payload($this->event(request: $request))['tags']); + } + + /** + * @return array,array}> + */ + public static function tags(): array + { + return [ + 'all four' => [['route' => 'r', 'site_id' => 3, 'locale' => 'en'], ['kind' => 'php', 'route' => 'r', 'site' => '3', 'locale' => 'en']], + 'a site of zero is a site' => [['site_id' => 0], ['kind' => 'php', 'site' => '0']], + 'an empty route' => [['route' => '', 'locale' => 'en'], ['kind' => 'php', 'locale' => 'en']], + 'an empty locale' => [['route' => 'r', 'locale' => ''], ['kind' => 'php', 'route' => 'r']], + 'no site' => [['site_id' => null], ['kind' => 'php']], + ]; + } + + public function test_a_frame_without_details_has_the_defaults(): void + { + $payload = SentryReporter::payload($this->event(exceptions: [['class' => 'E', 'message' => 'm', 'frames' => [[], ['function' => '', 'in_app' => 1, 'line' => 0]]]])); + + $this->assertSame([ + ['filename' => '', 'lineno' => 0, 'in_app' => false], + ['filename' => '', 'lineno' => 0, 'in_app' => true], + ], array_reverse($payload['exception']['values'][0]['stacktrace']['frames'])); + } + + public function test_a_frame_that_is_not_the_applications_is_marked_so_even_without_the_flag_being_a_boolean(): void + { + $payload = SentryReporter::payload($this->event(exceptions: [['class' => 'E', 'message' => 'm', 'frames' => [['in_app' => 0], ['in_app' => 'yes']]]])); + + $frames = $payload['exception']['values'][0]['stacktrace']['frames']; + $this->assertFalse($frames[1]['in_app']); + $this->assertTrue($frames[0]['in_app']); + } + + /** + * @param array> $exceptions + * @param array $request + * @param array $context + * @param array $breadcrumbs + * @param array $runtime + */ + private function event( + string $kind = 'php', + string $level = 'error', + string $message = 'm', + array $exceptions = [], + array $request = [], + array $context = [], + array $breadcrumbs = [], + array $runtime = [], + ?CarbonImmutable $timestamp = null, + ): Event { + return new Event('evt-1', $kind, $level, 'E', $message, $exceptions, $request, $context, $breadcrumbs, 'production', '2.4.0', $runtime, 'fp-1', $timestamp ?? CarbonImmutable::parse('2025-11-17 12:07:03.25 UTC')); + } +} diff --git a/phpstan.neon b/phpstan.neon index 134d897e..a066db10 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -22,6 +22,7 @@ parameters: # The trait is for apps' models; this one uses it, so it is analysed. - packages/custom-fields/tests/Fixtures - packages/docs/src + - packages/errors/src - packages/faq/src - packages/forms/src - packages/news/src @@ -44,6 +45,7 @@ parameters: - packages/bitrix/config - packages/custom-fields/config - packages/docs/config + - packages/errors/config - packages/forms/config - packages/seo/config - packages/solutions/config @@ -58,6 +60,7 @@ parameters: - packages/brands/database/migrations - packages/catalog/database/migrations - packages/custom-fields/database/migrations + - packages/errors/database/migrations - packages/faq/database/migrations - packages/forms/database/migrations - packages/news/database/migrations diff --git a/phpunit.xml b/phpunit.xml index 6d63347a..b743a513 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -20,6 +20,7 @@ packages/catalog/tests packages/custom-fields/tests packages/docs/tests + packages/errors/tests packages/faq/tests packages/forms/tests packages/news/tests @@ -46,6 +47,7 @@ packages/catalog/src packages/custom-fields/src packages/docs/src + packages/errors/src packages/faq/src packages/forms/src packages/news/src diff --git a/tests/Browser/Admin/ErrorsTest.php b/tests/Browser/Admin/ErrorsTest.php new file mode 100644 index 00000000..0a15b7bc --- /dev/null +++ b/tests/Browser/Admin/ErrorsTest.php @@ -0,0 +1,160 @@ +admin(); + $room = $this->capture(2, fn (): RuntimeException => $this->roomTaken()); + $feed = $this->capture(1, fn (): RuntimeException => $this->feedSilent()); + + $this->browse(function (Browser $browser) use ($admin, $room, $feed): void { + $browser->loginAs($admin, 'admin') + ->visit('/admin/errors') + ->waitFor('@errors-table') + ->assertAttribute('@errors-status-new', 'aria-pressed', 'true') + ->assertSeeIn('@errors-table', 'Room 12 is not free') + ->assertSeeIn('@errors-table', 'The price feed did not answer') + ->screenshot('errors/list') + ->type('@errors-search', 'Room 12') + ->click('@errors-apply') + ->waitUntilMissingText('The price feed did not answer') + ->assertSeeIn('@errors-table', 'Room 12 is not free') + ->type('@errors-search', 'nothing like this') + ->click('@errors-apply') + ->waitFor('@errors-empty') + ->click('@errors-reset') + ->waitFor('@errors-table') + ->assertSeeIn('@errors-table', 'The price feed did not answer') + ->clickAtXPath('//tr[@dusk="errors-row"][.//*[contains(., "Room 12")]]//a[@dusk="errors-open"]') + ->waitFor('@error-message') + ->assertPathIs('/admin/errors/'.$room->id) + ->assertSeeIn('@error-message', 'Room 12 is not free on the chosen dates') + ->assertSeeIn('@error-status', 'Unresolved') + // The trace points at this file, with the code around the line. + ->assertSeeIn('@error-exception', RuntimeException::class) + ->assertSeeIn('@error-frame', 'ErrorsTest.php') + ->assertPresent('@error-code') + ->assertPresent('@bar-chart') + ->click('@error-chart-daily') + ->assertAttribute('@error-chart-daily', 'aria-pressed', 'true') + ->click('@error-chart-hourly') + ->assertAttribute('@error-chart-hourly', 'aria-pressed', 'true') + // The event on screen is marked; the other one is a link to it. + ->assertCount('@error-occurrences tbody tr', 2) + ->assertCount('@error-occurrence', 1) + ->click('@error-occurrence') + ->waitUntil('location.search.includes("event=")') + ->assertQueryStringHas('event') + ->assertCount('@error-occurrence', 1); + + // The sticky header would take a click on a button scrolled under it. + $browser->script('window.scrollTo(0, 0)'); + $browser->resize(1440, 2600) + ->screenshot('errors/issue') + ->resize(1920, 1080) + ->click('@error-resolve-next') + ->waitFor('@error-reopen') + ->assertSeeIn('@error-status', 'Resolved') + ->assertMissing('@error-resolve'); + + $room->refresh(); + $this->assertSame(Issue::RESOLVED, $room->status); + $this->assertNotNull($room->resolved_in); + $this->assertSame(Issue::NEW, $feed->refresh()->status); + + // A resolved error leaves the default list and is found under its status. + $browser->click('@error-back') + ->waitFor('@errors-table') + ->assertDontSeeIn('@errors-table', 'Room 12 is not free') + ->click('@errors-status-resolved') + ->waitForTextIn('@errors-table', 'Room 12 is not free') + ->assertDontSeeIn('@errors-table', 'The price feed did not answer'); + }); + } + + public function test_the_dashboard_tile_counts_the_day_and_opens_the_noisiest_error(): void + { + $admin = $this->admin(); + $room = $this->capture(3, fn (): RuntimeException => $this->roomTaken()); + $this->capture(1, fn (): RuntimeException => $this->feedSilent()); + + $this->browse(function (Browser $browser) use ($admin, $room): void { + $browser->loginAs($admin, 'admin') + ->visit('/admin') + ->waitFor('@errors-gadget') + ->assertSeeIn('@errors-gadget [data-count="events"]', '4') + ->assertSeeIn('@errors-gadget [data-count="new"]', '2') + ->assertSeeIn('@errors-gadget [data-count="unresolved"]', '2') + ->assertSeeIn('@errors-gadget [data-bar-value]', '4') + ->screenshot('errors/gadget') + ->assertSeeIn('@errors-gadget-issue', 'Room 12 is not free') + ->click('@errors-gadget-issue') + ->waitFor('@error-message') + ->assertPathIs('/admin/errors/'.$room->id); + }); + } + + public function test_without_errors_the_tile_and_the_list_say_so(): void + { + $admin = $this->admin(); + + $this->browse(function (Browser $browser) use ($admin): void { + $browser->loginAs($admin, 'admin') + ->visit('/admin') + ->waitFor('@errors-gadget') + ->assertSeeIn('@errors-gadget', 'No errors in the last 24 hours.') + ->assertMissing('@errors-gadget @bar-chart') + ->click('@errors-gadget-all') + ->waitFor('@errors-empty') + ->assertMissing('@errors-table'); + }); + + $this->assertSame(0, Issue::query()->count()); + } + + /** + * The same bug caught $times times through the real tracker. + * + * @param callable(): RuntimeException $bug + */ + private function capture(int $times, callable $bug): Issue + { + $message = ''; + foreach (range(1, $times) as $ignored) { + $e = $bug(); + $message = $e->getMessage(); + app(Errors::class)->capture($e); + } + + return Issue::query()->where('message', $message)->sole(); + } + + private function roomTaken(): RuntimeException + { + return new RuntimeException('Room 12 is not free on the chosen dates'); + } + + private function feedSilent(): RuntimeException + { + return new RuntimeException('The price feed did not answer in 3 seconds'); + } +} diff --git a/tests/Browser/Admin/HeaderTest.php b/tests/Browser/Admin/HeaderTest.php index 7140e98b..ab77ae34 100644 --- a/tests/Browser/Admin/HeaderTest.php +++ b/tests/Browser/Admin/HeaderTest.php @@ -44,8 +44,8 @@ public function test_the_header_fits_a_phone_screen(): void Site::query()->create(['name' => 'Second site with a long name', 'code' => 'second']); $this->browse(function (Browser $browser) use ($admin): void { - $browser->resize(375, 812) - ->loginAs($admin, 'admin') + $this->phone($browser, true); + $browser->loginAs($admin, 'admin') ->visit('/admin') ->waitFor('[data-site-switcher]'); @@ -65,8 +65,21 @@ public function test_the_header_fits_a_phone_screen(): void $browser->assertSeeIn('header', __('atrium::layout.site', [], 'en')) ->assertSeeIn('header', __('atrium::layout.admin_language', [], 'en')) // The language itself is shown by its code. - ->assertSeeIn('header', 'EN') - ->resize(1920, 1080); + ->assertSeeIn('header', 'EN'); + $this->phone($browser, false); }); } + + /** + * A phone 375 pixels wide, not a narrow desktop window: a desktop + * window has a floor of 500 pixels on macOS, and on Linux its scroll + * bar takes 15 of them as soon as the dashboard is taller than the + * screen. A phone draws its scroll bar over the page. + */ + private function phone(Browser $browser, bool $on): void + { + $browser->driver->executeCustomCommand('/session/:sessionId/goog/cdp/execute', 'POST', $on + ? ['cmd' => 'Emulation.setDeviceMetricsOverride', 'params' => ['width' => 375, 'height' => 812, 'deviceScaleFactor' => 2, 'mobile' => true]] + : ['cmd' => 'Emulation.clearDeviceMetricsOverride', 'params' => (object) []]); + } } From c5cbf0e84e3d6418b7833bb3108c695e00a15547 Mon Sep 17 00:00:00 2001 From: Pisarev Alexei <6171687+xiregroup@users.noreply.github.com> Date: Wed, 18 Nov 2026 22:19:24 +0300 Subject: [PATCH 2/2] build(admin): rebuild the bundle with the errors screens and tile --- ...on-Bx141Bs3.js => AdminButton-KiIJ2sLW.js} | 2 +- .../admin/dist/assets/AdminCard--HubMtUj.js | 1 - .../admin/dist/assets/AdminCard-YbEwPtJz.js | 1 + .../dist/assets/AdminDataTable-6eKgKDeA.js | 1 + .../dist/assets/AdminDataTable-BaQwb_6U.js | 1 - ...ut--RXJFj9t.js => AdminLayout-DBeSErmz.js} | 2 +- ...dal-DNJ_V4iq.js => AdminModal-DKazeNNa.js} | 2 +- .../dist/assets/AdminPagination-D7rwNfhd.js | 1 + .../admin/dist/assets/BarChart-wks0RLo_.js | 1 + ...-.js => ContentLocaleSwitcher-HJzbB87a.js} | 2 +- packages/admin/dist/assets/Create-BxhK0Jvn.js | 1 - packages/admin/dist/assets/Create-C61-lS2c.js | 1 - packages/admin/dist/assets/Create-CbxIXc0Q.js | 1 + packages/admin/dist/assets/Create-DutDQiBS.js | 1 + .../admin/dist/assets/Dashboard-BU7gtvAo.js | 1 - .../admin/dist/assets/Dashboard-C9RqcuE0.js | 1 + packages/admin/dist/assets/Edit-BEWPbBmM.js | 1 + .../{Edit-pGNJhUsL.js => Edit-Bm3W6F3v.js} | 2 +- packages/admin/dist/assets/Edit-CHndUQJ2.js | 1 - packages/admin/dist/assets/Edit-Cp-LIO0D.js | 1 + .../{Edit-D-yhP5A2.js => Edit-CyzBsvwt.js} | 2 +- packages/admin/dist/assets/Edit-DGjzU-uC.js | 1 - ...ield-xD6LELDV.js => FormField-B-XX4VFv.js} | 76 ++--- packages/admin/dist/assets/Index-1mD_GBWn.js | 1 - packages/admin/dist/assets/Index-9-V30Hlc.js | 1 - packages/admin/dist/assets/Index-B9KqS9R5.js | 1 + packages/admin/dist/assets/Index-BNmU5PEL.js | 1 + packages/admin/dist/assets/Index-C63EL5RF.js | 1 + packages/admin/dist/assets/Index-CG3NSbtt.js | 1 + packages/admin/dist/assets/Index-CjLWl74m.js | 1 - packages/admin/dist/assets/Index-DEbfZBFs.js | 1 - packages/admin/dist/assets/Index-D_2Ij5S1.js | 1 + packages/admin/dist/assets/Index-DaeZ92GY.js | 1 + packages/admin/dist/assets/Index-DsLgvcm0.js | 1 + packages/admin/dist/assets/Index-P5jX14JD.js | 1 - .../{Index-C_p9UH4T.js => Index-ZYMbBsuF.js} | 2 +- packages/admin/dist/assets/Index-bqKVRXw8.js | 1 - .../dist/assets/LocaleSwitcher-DAWnmZni.js | 1 + .../dist/assets/LocaleSwitcher-DdLJ9WTE.js | 1 - .../{Login-D_P0ceoZ.js => Login-DTW3u1G9.js} | 2 +- ...tings-C2VyFPrB.js => Settings-BrbOStcv.js} | 2 +- packages/admin/dist/assets/Show-CS6rq4RP.js | 1 + .../{app-BNjy5Z6H.js => app-BCJOqmKO.js} | 4 +- packages/admin/dist/assets/app-BncygNAT.css | 2 - packages/admin/dist/assets/app-XteR4oRF.css | 2 + ...-BtGD-iBF.js => contentLocale-BV_E0iGS.js} | 2 +- .../{dist-MY__znoP.js => dist-Bie52OmN.js} | 2 +- packages/admin/dist/manifest.json | 288 ++++++++++-------- 48 files changed, 237 insertions(+), 189 deletions(-) rename packages/admin/dist/assets/{AdminButton-Bx141Bs3.js => AdminButton-KiIJ2sLW.js} (83%) delete mode 100644 packages/admin/dist/assets/AdminCard--HubMtUj.js create mode 100644 packages/admin/dist/assets/AdminCard-YbEwPtJz.js create mode 100644 packages/admin/dist/assets/AdminDataTable-6eKgKDeA.js delete mode 100644 packages/admin/dist/assets/AdminDataTable-BaQwb_6U.js rename packages/admin/dist/assets/{AdminLayout--RXJFj9t.js => AdminLayout-DBeSErmz.js} (62%) rename packages/admin/dist/assets/{AdminModal-DNJ_V4iq.js => AdminModal-DKazeNNa.js} (62%) create mode 100644 packages/admin/dist/assets/AdminPagination-D7rwNfhd.js create mode 100644 packages/admin/dist/assets/BarChart-wks0RLo_.js rename packages/admin/dist/assets/{ContentLocaleSwitcher-BJIieXK-.js => ContentLocaleSwitcher-HJzbB87a.js} (59%) delete mode 100644 packages/admin/dist/assets/Create-BxhK0Jvn.js delete mode 100644 packages/admin/dist/assets/Create-C61-lS2c.js create mode 100644 packages/admin/dist/assets/Create-CbxIXc0Q.js create mode 100644 packages/admin/dist/assets/Create-DutDQiBS.js delete mode 100644 packages/admin/dist/assets/Dashboard-BU7gtvAo.js create mode 100644 packages/admin/dist/assets/Dashboard-C9RqcuE0.js create mode 100644 packages/admin/dist/assets/Edit-BEWPbBmM.js rename packages/admin/dist/assets/{Edit-pGNJhUsL.js => Edit-Bm3W6F3v.js} (59%) delete mode 100644 packages/admin/dist/assets/Edit-CHndUQJ2.js create mode 100644 packages/admin/dist/assets/Edit-Cp-LIO0D.js rename packages/admin/dist/assets/{Edit-D-yhP5A2.js => Edit-CyzBsvwt.js} (51%) delete mode 100644 packages/admin/dist/assets/Edit-DGjzU-uC.js rename packages/admin/dist/assets/{FormField-xD6LELDV.js => FormField-B-XX4VFv.js} (50%) delete mode 100644 packages/admin/dist/assets/Index-1mD_GBWn.js delete mode 100644 packages/admin/dist/assets/Index-9-V30Hlc.js create mode 100644 packages/admin/dist/assets/Index-B9KqS9R5.js create mode 100644 packages/admin/dist/assets/Index-BNmU5PEL.js create mode 100644 packages/admin/dist/assets/Index-C63EL5RF.js create mode 100644 packages/admin/dist/assets/Index-CG3NSbtt.js delete mode 100644 packages/admin/dist/assets/Index-CjLWl74m.js delete mode 100644 packages/admin/dist/assets/Index-DEbfZBFs.js create mode 100644 packages/admin/dist/assets/Index-D_2Ij5S1.js create mode 100644 packages/admin/dist/assets/Index-DaeZ92GY.js create mode 100644 packages/admin/dist/assets/Index-DsLgvcm0.js delete mode 100644 packages/admin/dist/assets/Index-P5jX14JD.js rename packages/admin/dist/assets/{Index-C_p9UH4T.js => Index-ZYMbBsuF.js} (50%) delete mode 100644 packages/admin/dist/assets/Index-bqKVRXw8.js create mode 100644 packages/admin/dist/assets/LocaleSwitcher-DAWnmZni.js delete mode 100644 packages/admin/dist/assets/LocaleSwitcher-DdLJ9WTE.js rename packages/admin/dist/assets/{Login-D_P0ceoZ.js => Login-DTW3u1G9.js} (54%) rename packages/admin/dist/assets/{Settings-C2VyFPrB.js => Settings-BrbOStcv.js} (55%) create mode 100644 packages/admin/dist/assets/Show-CS6rq4RP.js rename packages/admin/dist/assets/{app-BNjy5Z6H.js => app-BCJOqmKO.js} (87%) delete mode 100644 packages/admin/dist/assets/app-BncygNAT.css create mode 100644 packages/admin/dist/assets/app-XteR4oRF.css rename packages/admin/dist/assets/{contentLocale-BtGD-iBF.js => contentLocale-BV_E0iGS.js} (89%) rename packages/admin/dist/assets/{dist-MY__znoP.js => dist-Bie52OmN.js} (99%) diff --git a/packages/admin/dist/assets/AdminButton-Bx141Bs3.js b/packages/admin/dist/assets/AdminButton-KiIJ2sLW.js similarity index 83% rename from packages/admin/dist/assets/AdminButton-Bx141Bs3.js rename to packages/admin/dist/assets/AdminButton-KiIJ2sLW.js index 5149d638..8fb334f5 100644 --- a/packages/admin/dist/assets/AdminButton-Bx141Bs3.js +++ b/packages/admin/dist/assets/AdminButton-KiIJ2sLW.js @@ -1 +1 @@ -import{C as e,I as t,Q as n,S as r,V as i,W as a,b as o,i as s,w as c,x as l,z as u}from"./dist-MY__znoP.js";var d={key:0,class:`animate-spin -ml-1 mr-2 h-4 w-4`,fill:`none`,viewBox:`0 0 24 24`},f={__name:`AdminButton`,props:{type:{type:String,default:`button`},href:{type:String,default:null},variant:{type:String,default:`primary`,validator:e=>[`primary`,`secondary`,`danger`,`success`,`warning`,`outline`].includes(e)},size:{type:String,default:`md`,validator:e=>[`sm`,`md`,`lg`].includes(e)},loading:Boolean,disabled:Boolean,block:Boolean},setup(f){let p=f,m=o(()=>[`inline-flex items-center justify-center font-medium rounded-md transition-colors focus:outline-none focus:ring-2 focus:ring-offset-2 disabled:opacity-50 disabled:cursor-not-allowed`,{primary:`bg-accent text-on-accent hover:bg-accent-hover focus:ring-focus`,secondary:`border border-line bg-off text-off-fg hover:border-field focus:ring-focus`,danger:`bg-danger text-on-danger hover:bg-danger-hover focus:ring-danger`,success:`border border-success bg-success-soft text-success-soft-fg hover:border-fg focus:ring-focus`,warning:`border border-warning-soft-fg bg-warning-soft text-warning-soft-fg hover:border-fg focus:ring-focus`,outline:`border border-field bg-surface text-fg hover:bg-hover focus:ring-focus`}[p.variant],{sm:`px-2.5 py-1.5 text-xs`,md:`px-4 py-2 text-sm`,lg:`px-6 py-3 text-base`}[p.size],p.block?`w-full`:``].join(` `)),h=o(()=>p.href?s:`button`);return(o,s)=>(t(),r(i(h.value),{href:f.href,type:f.href?null:f.type,disabled:f.disabled||f.loading,class:n(m.value)},{default:a(()=>[f.loading?(t(),c(`svg`,d,[...s[0]||=[l(`circle`,{class:`opacity-25`,cx:`12`,cy:`12`,r:`10`,stroke:`currentColor`,"stroke-width":`4`},null,-1),l(`path`,{class:`opacity-75`,fill:`currentColor`,d:`M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z`},null,-1)]])):e(``,!0),u(o.$slots,`default`)]),_:3},8,[`href`,`type`,`disabled`,`class`]))}};export{f as t}; \ No newline at end of file +import{$ as e,C as t,I as n,S as r,V as i,W as a,b as o,i as s,w as c,x as l,z as u}from"./dist-Bie52OmN.js";var d={key:0,class:`animate-spin -ml-1 mr-2 h-4 w-4`,fill:`none`,viewBox:`0 0 24 24`},f={__name:`AdminButton`,props:{type:{type:String,default:`button`},href:{type:String,default:null},variant:{type:String,default:`primary`,validator:e=>[`primary`,`secondary`,`danger`,`success`,`warning`,`outline`].includes(e)},size:{type:String,default:`md`,validator:e=>[`sm`,`md`,`lg`].includes(e)},loading:Boolean,disabled:Boolean,block:Boolean},setup(f){let p=f,m=o(()=>[`inline-flex items-center justify-center font-medium rounded-md transition-colors focus:outline-none focus:ring-2 focus:ring-offset-2 disabled:opacity-50 disabled:cursor-not-allowed`,{primary:`bg-accent text-on-accent hover:bg-accent-hover focus:ring-focus`,secondary:`border border-line bg-off text-off-fg hover:border-field focus:ring-focus`,danger:`bg-danger text-on-danger hover:bg-danger-hover focus:ring-danger`,success:`border border-success bg-success-soft text-success-soft-fg hover:border-fg focus:ring-focus`,warning:`border border-warning-soft-fg bg-warning-soft text-warning-soft-fg hover:border-fg focus:ring-focus`,outline:`border border-field bg-surface text-fg hover:bg-hover focus:ring-focus`}[p.variant],{sm:`px-2.5 py-1.5 text-xs`,md:`px-4 py-2 text-sm`,lg:`px-6 py-3 text-base`}[p.size],p.block?`w-full`:``].join(` `)),h=o(()=>p.href?s:`button`);return(o,s)=>(n(),r(i(h.value),{href:f.href,type:f.href?null:f.type,disabled:f.disabled||f.loading,class:e(m.value)},{default:a(()=>[f.loading?(n(),c(`svg`,d,[...s[0]||=[l(`circle`,{class:`opacity-25`,cx:`12`,cy:`12`,r:`10`,stroke:`currentColor`,"stroke-width":`4`},null,-1),l(`path`,{class:`opacity-75`,fill:`currentColor`,d:`M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z`},null,-1)]])):t(``,!0),u(o.$slots,`default`)]),_:3},8,[`href`,`type`,`disabled`,`class`]))}};export{f as t}; \ No newline at end of file diff --git a/packages/admin/dist/assets/AdminCard--HubMtUj.js b/packages/admin/dist/assets/AdminCard--HubMtUj.js deleted file mode 100644 index 35a71230..00000000 --- a/packages/admin/dist/assets/AdminCard--HubMtUj.js +++ /dev/null @@ -1 +0,0 @@ -import{C as e,I as t,Q as n,et as r,w as i,x as a,z as o}from"./dist-MY__znoP.js";var s={class:`bg-surface rounded-lg shadow`},c={key:0,class:`px-6 py-4 border-b border-line`},l={class:`text-lg font-medium text-fg`},u={key:0,class:`mt-1 text-sm text-muted`},d={key:1,class:`px-6 py-4 border-t border-line bg-surface-alt rounded-b-lg`},f={__name:`AdminCard`,props:{title:String,subtitle:String,noPadding:Boolean},setup(f){return(p,m)=>(t(),i(`div`,s,[f.title||p.$slots.header?(t(),i(`div`,c,[o(p.$slots,`header`,{},()=>[a(`h3`,l,r(f.title),1),f.subtitle?(t(),i(`p`,u,r(f.subtitle),1)):e(``,!0)])])):e(``,!0),a(`div`,{class:n(f.noPadding?``:`p-6`)},[o(p.$slots,`default`)],2),p.$slots.footer?(t(),i(`div`,d,[o(p.$slots,`footer`)])):e(``,!0)]))}};export{f as t}; \ No newline at end of file diff --git a/packages/admin/dist/assets/AdminCard-YbEwPtJz.js b/packages/admin/dist/assets/AdminCard-YbEwPtJz.js new file mode 100644 index 00000000..8635cc8f --- /dev/null +++ b/packages/admin/dist/assets/AdminCard-YbEwPtJz.js @@ -0,0 +1 @@ +import{$ as e,C as t,I as n,tt as r,w as i,x as a,z as o}from"./dist-Bie52OmN.js";var s={class:`bg-surface rounded-lg shadow`},c={key:0,class:`px-6 py-4 border-b border-line`},l={class:`text-lg font-medium text-fg`},u={key:0,class:`mt-1 text-sm text-muted`},d={key:1,class:`px-6 py-4 border-t border-line bg-surface-alt rounded-b-lg`},f={__name:`AdminCard`,props:{title:String,subtitle:String,noPadding:Boolean},setup(f){return(p,m)=>(n(),i(`div`,s,[f.title||p.$slots.header?(n(),i(`div`,c,[o(p.$slots,`header`,{},()=>[a(`h3`,l,r(f.title),1),f.subtitle?(n(),i(`p`,u,r(f.subtitle),1)):t(``,!0)])])):t(``,!0),a(`div`,{class:e(f.noPadding?``:`p-6`)},[o(p.$slots,`default`)],2),p.$slots.footer?(n(),i(`div`,d,[o(p.$slots,`footer`)])):t(``,!0)]))}};export{f as t}; \ No newline at end of file diff --git a/packages/admin/dist/assets/AdminDataTable-6eKgKDeA.js b/packages/admin/dist/assets/AdminDataTable-6eKgKDeA.js new file mode 100644 index 00000000..6598c630 --- /dev/null +++ b/packages/admin/dist/assets/AdminDataTable-6eKgKDeA.js @@ -0,0 +1 @@ +import{$ as e,C as t,I as n,Q as r,R as i,S as a,T as o,W as s,et as c,i as l,tt as u,v as d,w as f,x as p,z as m}from"./dist-Bie52OmN.js";import{t as h}from"./AdminPagination-D7rwNfhd.js";var g={class:`isolate bg-surface rounded-lg shadow overflow-hidden`},_={class:`overflow-x-auto`},v={class:`min-w-full border-separate border-spacing-0`},y={class:`bg-surface-alt`},b=[`data-column`,`data-sortable`,`onClick`],x={class:`flex items-center space-x-1`},S={key:0,class:`w-4 h-4`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`},C={key:1,class:`w-4 h-4`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`},w={key:2,class:`w-4 h-4 text-muted`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`},T={class:`sticky right-0 z-10 border-b border-l border-line bg-surface-alt px-3 py-2 text-right text-xs font-medium text-muted uppercase tracking-wider`},E={class:`bg-surface`},D={key:0},O=[`colspan`],k={key:1},A=[`colspan`],j=[`data-row-id`],M=[`title`],N={key:0,"data-badge":`on`,class:`inline-flex items-center gap-1.5 px-2.5 py-0.5 rounded-full border border-badge-line text-xs font-semibold bg-accent-soft text-accent-soft-fg`},P={key:1,"data-badge":`off`,class:`inline-flex items-center gap-1.5 px-2.5 py-0.5 rounded-full border border-badge-line text-xs font-semibold bg-off text-off-fg`},F=[`src`,`alt`],I={key:1,class:`text-muted`},L=[`href`],R={key:1,class:`text-fg`},z={class:`sticky right-0 z-10 border-b border-l border-line bg-inherit px-3 py-2 whitespace-nowrap text-right text-sm font-medium`},B=[`onClick`,`title`,`aria-label`],V=[`onClick`,`title`,`aria-label`],H={__name:`AdminDataTable`,props:{columns:{type:Array,required:!0},items:{type:Object,required:!0},sortBy:{type:String,default:``},sortDirection:{type:String,default:`asc`},loading:Boolean,canDelete:{type:Boolean,default:!0},rowActions:{type:Array,default:()=>[]}},emits:[`sort`,`edit`,`delete`],setup(H,{emit:U}){let W=H,G=U,K=e=>{if(!e.sortable)return;let t=W.sortBy===e.name&&W.sortDirection===`asc`?`desc`:`asc`;G(`sort`,{column:e.name,direction:t})},q=e=>{let t=Array.isArray(e)?e.length?e[0]:null:e;if(!t)return null;let n=typeof t==`object`?t.url??t.path??null:t;return typeof n!=`string`||n===``?null:/^(https?:)?\/\//i.test(n)||n.startsWith(`/`)?n:`/storage/`+n},J=e=>W.sortBy===e.name?W.sortDirection===`asc`?`up`:`down`:null,Y=(e,t)=>{if(!t.urlFrom)return null;let n=e[t.urlFrom],r=e[t.name];return r==null||r===``?null:typeof n==`string`&&n!==``?n:null},X=(e,t)=>{if(t.type===`image`||t.type===`boolean`)return null;let n=e[t.name];return n==null||n===``?null:String(n)};return(U,W)=>(n(),f(`div`,g,[p(`div`,_,[p(`table`,v,[p(`thead`,y,[p(`tr`,null,[(n(!0),f(d,null,i(H.columns,r=>(n(),f(`th`,{key:r.name,"data-column":r.name,"data-sortable":r.sortable?`true`:`false`,class:e([`border-b border-line px-3 py-2 text-left text-xs font-medium text-muted uppercase tracking-wider whitespace-nowrap`,{"cursor-pointer hover:bg-hover":r.sortable}]),style:c(r.width?{width:r.width}:{}),onClick:e=>K(r)},[p(`div`,x,[p(`span`,null,u(r.label),1),r.sortable?(n(),f(d,{key:0},[J(r)===`up`?(n(),f(`svg`,S,[...W[0]||=[p(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M5 15l7-7 7 7`},null,-1)]])):J(r)===`down`?(n(),f(`svg`,C,[...W[1]||=[p(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M19 9l-7 7-7-7`},null,-1)]])):(n(),f(`svg`,w,[...W[2]||=[p(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M7 16V4m0 0L3 8m4-4l4 4m6 0v12m0 0l4-4m-4 4l-4-4`},null,-1)]]))],64)):t(``,!0)])],14,b))),128)),p(`th`,T,u(U.$t(`common.actions`)),1)])]),p(`tbody`,E,[H.loading?(n(),f(`tr`,D,[p(`td`,{colspan:H.columns.length+1,class:`px-6 py-12 text-center`},[...W[3]||=[p(`svg`,{class:`animate-spin h-8 w-8 text-accent mx-auto`,fill:`none`,viewBox:`0 0 24 24`},[p(`circle`,{class:`opacity-25`,cx:`12`,cy:`12`,r:`10`,stroke:`currentColor`,"stroke-width":`4`}),p(`path`,{class:`opacity-75`,fill:`currentColor`,d:`M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z`})],-1)]],8,O)])):H.items.data?.length?(n(!0),f(d,{key:2},i(H.items.data,e=>(n(),f(`tr`,{key:e.id,"data-row-id":e.id,class:`bg-surface hover:bg-hover`},[(n(!0),f(d,null,i(H.columns,t=>(n(),f(`td`,{key:t.name,class:`border-b border-line px-3 py-2 whitespace-nowrap text-sm max-w-xs truncate`,title:X(e,t)},[m(U.$slots,`cell-${t.name}`,{item:e,value:e[t.name]},()=>[t.type===`boolean`?(n(),f(d,{key:0},[e[t.name]?(n(),f(`span`,N,[W[4]||=p(`span`,{class:`h-2 w-2 rounded-full bg-current`,"aria-hidden":`true`},null,-1),o(` `+u(t.trueLabel||U.$t(`common.yes`)),1)])):(n(),f(`span`,P,[W[5]||=p(`span`,{class:`h-2 w-2 rounded-full border-2 border-current`,"aria-hidden":`true`},null,-1),o(` `+u(t.falseLabel||U.$t(`common.no`)),1)]))],64)):t.type===`image`?(n(),f(d,{key:1},[q(e[t.name])?(n(),f(`img`,{key:0,src:q(e[t.name]),alt:t.label,class:`h-10 w-10 rounded object-cover`},null,8,F)):(n(),f(`span`,I,`—`))],64)):t.type===`date`?(n(),f(d,{key:2},[o(u(e[t.name]?new Date(e[t.name]).toLocaleDateString(`ru-RU`):`—`),1)],64)):(n(),f(d,{key:3},[Y(e,t)?(n(),f(`a`,{key:0,href:Y(e,t),target:`_blank`,rel:`noopener`,class:`text-accent hover:text-accent-hover hover:underline`},u(e[t.name]),9,L)):(n(),f(`span`,R,u(e[t.name]??`—`),1))],64))])],8,M))),128)),p(`td`,z,[m(U.$slots,`actions`,{item:e},()=>[(n(!0),f(d,null,i(H.rowActions,t=>(n(),a(r(l),{key:t.name,href:t.href(e),"data-action":t.name,class:`mr-1 inline-flex items-center rounded px-2 py-1 text-xs text-accent hover:bg-accent-soft hover:text-accent-hover`},{default:s(()=>[W[6]||=p(`svg`,{class:`mr-1 h-3.5 w-3.5`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,"aria-hidden":`true`},[p(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M12 4v16m8-8H4`})],-1),o(` `+u(t.label),1)]),_:2},1032,[`href`,`data-action`]))),128)),p(`button`,{"data-action":`edit`,onClick:t=>U.$emit(`edit`,e),class:`inline-flex items-center rounded p-1.5 text-accent hover:bg-accent-soft hover:text-accent-hover`,title:U.$t(`common.edit`),"aria-label":U.$t(`common.edit`)},[...W[7]||=[p(`svg`,{class:`h-4 w-4`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,"stroke-width":`2`},[p(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,d:`M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z`})],-1)]],8,B),H.canDelete?(n(),f(`button`,{key:0,"data-action":`delete`,onClick:t=>U.$emit(`delete`,e),class:`ml-1 inline-flex items-center rounded p-1.5 text-danger hover:bg-danger-soft hover:text-danger-soft-fg`,title:U.$t(`common.delete`),"aria-label":U.$t(`common.delete`)},[...W[8]||=[p(`svg`,{class:`h-4 w-4`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,"stroke-width":`2`},[p(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,d:`M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16`})],-1)]],8,V)):t(``,!0)])])],8,j))),128)):(n(),f(`tr`,k,[p(`td`,{colspan:H.columns.length+1,class:`px-6 py-12 text-center text-muted`},u(U.$t(`resource.table.empty`)),9,A)]))])])]),H.items.total>H.items.per_page?(n(),a(h,{key:0,paginator:H.items},null,8,[`paginator`])):t(``,!0)]))}};export{H as t}; \ No newline at end of file diff --git a/packages/admin/dist/assets/AdminDataTable-BaQwb_6U.js b/packages/admin/dist/assets/AdminDataTable-BaQwb_6U.js deleted file mode 100644 index f6d38215..00000000 --- a/packages/admin/dist/assets/AdminDataTable-BaQwb_6U.js +++ /dev/null @@ -1 +0,0 @@ -import{$ as e,C as t,I as n,Q as r,R as i,S as a,T as o,W as s,Z as c,b as l,et as u,i as d,v as f,w as p,x as m,z as h}from"./dist-MY__znoP.js";var g={class:`bg-surface px-4 py-3 border-t border-line sm:px-6`},_={class:`flex items-center justify-between`},v={class:`text-sm text-fg`},y={class:`inline-flex -space-x-px rounded-md shadow-sm`},b={key:1,class:`relative inline-flex items-center rounded-l-md px-2 py-2 text-muted ring-1 ring-inset ring-field`},x={key:0,class:`relative inline-flex items-center px-4 py-2 text-sm font-semibold text-fg ring-1 ring-inset ring-field`},S={key:3,class:`relative inline-flex items-center rounded-r-md px-2 py-2 text-muted ring-1 ring-inset ring-field`},C={__name:`AdminPagination`,props:{paginator:{type:Object,required:!0}},setup(e){let t=e,h=l(()=>{let e=t.paginator.current_page,n=t.paginator.last_page,r=[],i=[];for(let t=1;t<=n;t++)(t===1||t===n||t>=e-2&&t<=e+2)&&r.push(t);let a=null;for(let e of r)a&&(e-a===2?i.push(a+1):e-a!==1&&i.push(`...`)),i.push(e),a=e;return i});return(t,l)=>(n(),p(`div`,g,[m(`div`,_,[m(`div`,v,u(t.$t(`resource.pagination.showing`,{from:e.paginator.from,to:e.paginator.to,total:e.paginator.total})),1),m(`nav`,y,[e.paginator.prev_page_url?(n(),a(c(d),{key:0,href:e.paginator.prev_page_url,class:`relative inline-flex items-center rounded-l-md px-2 py-2 text-muted ring-1 ring-inset ring-field hover:bg-hover`,"preserve-scroll":``},{default:s(()=>[...l[0]||=[m(`svg`,{class:`h-5 w-5`,viewBox:`0 0 20 20`,fill:`currentColor`},[m(`path`,{"fill-rule":`evenodd`,d:`M12.79 5.23a.75.75 0 01-.02 1.06L8.832 10l3.938 3.71a.75.75 0 11-1.04 1.08l-4.5-4.25a.75.75 0 010-1.08l4.5-4.25a.75.75 0 011.06.02z`,"clip-rule":`evenodd`})],-1)]]),_:1},8,[`href`])):(n(),p(`span`,b,[...l[1]||=[m(`svg`,{class:`h-5 w-5`,viewBox:`0 0 20 20`,fill:`currentColor`},[m(`path`,{"fill-rule":`evenodd`,d:`M12.79 5.23a.75.75 0 01-.02 1.06L8.832 10l3.938 3.71a.75.75 0 11-1.04 1.08l-4.5-4.25a.75.75 0 010-1.08l4.5-4.25a.75.75 0 011.06.02z`,"clip-rule":`evenodd`})],-1)]])),(n(!0),p(f,null,i(h.value,t=>(n(),p(f,{key:t},[t===`...`?(n(),p(`span`,x,` ... `)):(n(),a(c(d),{key:1,href:`${e.paginator.path}?page=${t}`,class:r([`relative inline-flex items-center px-4 py-2 text-sm font-semibold ring-1 ring-inset ring-field`,t===e.paginator.current_page?`z-10 bg-accent text-on-accent focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus`:`text-fg hover:bg-hover`]),"preserve-scroll":``},{default:s(()=>[o(u(t),1)]),_:2},1032,[`href`,`class`]))],64))),128)),e.paginator.next_page_url?(n(),a(c(d),{key:2,href:e.paginator.next_page_url,class:`relative inline-flex items-center rounded-r-md px-2 py-2 text-muted ring-1 ring-inset ring-field hover:bg-hover`,"preserve-scroll":``},{default:s(()=>[...l[2]||=[m(`svg`,{class:`h-5 w-5`,viewBox:`0 0 20 20`,fill:`currentColor`},[m(`path`,{"fill-rule":`evenodd`,d:`M7.21 14.77a.75.75 0 01.02-1.06L11.168 10 7.23 6.29a.75.75 0 111.04-1.08l4.5 4.25a.75.75 0 010 1.08l-4.5 4.25a.75.75 0 01-1.06-.02z`,"clip-rule":`evenodd`})],-1)]]),_:1},8,[`href`])):(n(),p(`span`,S,[...l[3]||=[m(`svg`,{class:`h-5 w-5`,viewBox:`0 0 20 20`,fill:`currentColor`},[m(`path`,{"fill-rule":`evenodd`,d:`M7.21 14.77a.75.75 0 01.02-1.06L11.168 10 7.23 6.29a.75.75 0 111.04-1.08l4.5 4.25a.75.75 0 010 1.08l-4.5 4.25a.75.75 0 01-1.06-.02z`,"clip-rule":`evenodd`})],-1)]]))])])]))}},w={class:`isolate bg-surface rounded-lg shadow overflow-hidden`},T={class:`overflow-x-auto`},E={class:`min-w-full border-separate border-spacing-0`},D={class:`bg-surface-alt`},O=[`data-column`,`data-sortable`,`onClick`],k={class:`flex items-center space-x-1`},A={key:0,class:`w-4 h-4`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`},j={key:1,class:`w-4 h-4`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`},M={key:2,class:`w-4 h-4 text-muted`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`},N={class:`sticky right-0 z-10 border-b border-l border-line bg-surface-alt px-3 py-2 text-right text-xs font-medium text-muted uppercase tracking-wider`},P={class:`bg-surface`},F={key:0},I=[`colspan`],L={key:1},R=[`colspan`],z=[`data-row-id`],B=[`title`],V={key:0,"data-badge":`on`,class:`inline-flex items-center gap-1.5 px-2.5 py-0.5 rounded-full border border-badge-line text-xs font-semibold bg-accent-soft text-accent-soft-fg`},H={key:1,"data-badge":`off`,class:`inline-flex items-center gap-1.5 px-2.5 py-0.5 rounded-full border border-badge-line text-xs font-semibold bg-off text-off-fg`},U=[`src`,`alt`],W={key:1,class:`text-muted`},G=[`href`],K={key:1,class:`text-fg`},q={class:`sticky right-0 z-10 border-b border-l border-line bg-inherit px-3 py-2 whitespace-nowrap text-right text-sm font-medium`},J=[`onClick`,`title`,`aria-label`],Y=[`onClick`,`title`,`aria-label`],X={__name:`AdminDataTable`,props:{columns:{type:Array,required:!0},items:{type:Object,required:!0},sortBy:{type:String,default:``},sortDirection:{type:String,default:`asc`},loading:Boolean,canDelete:{type:Boolean,default:!0},rowActions:{type:Array,default:()=>[]}},emits:[`sort`,`edit`,`delete`],setup(l,{emit:g}){let _=l,v=g,y=e=>{if(!e.sortable)return;let t=_.sortBy===e.name&&_.sortDirection===`asc`?`desc`:`asc`;v(`sort`,{column:e.name,direction:t})},b=e=>{let t=Array.isArray(e)?e.length?e[0]:null:e;if(!t)return null;let n=typeof t==`object`?t.url??t.path??null:t;return typeof n!=`string`||n===``?null:/^(https?:)?\/\//i.test(n)||n.startsWith(`/`)?n:`/storage/`+n},x=e=>_.sortBy===e.name?_.sortDirection===`asc`?`up`:`down`:null,S=(e,t)=>{if(!t.urlFrom)return null;let n=e[t.urlFrom],r=e[t.name];return r==null||r===``?null:typeof n==`string`&&n!==``?n:null},X=(e,t)=>{if(t.type===`image`||t.type===`boolean`)return null;let n=e[t.name];return n==null||n===``?null:String(n)};return(g,_)=>(n(),p(`div`,w,[m(`div`,T,[m(`table`,E,[m(`thead`,D,[m(`tr`,null,[(n(!0),p(f,null,i(l.columns,i=>(n(),p(`th`,{key:i.name,"data-column":i.name,"data-sortable":i.sortable?`true`:`false`,class:r([`border-b border-line px-3 py-2 text-left text-xs font-medium text-muted uppercase tracking-wider whitespace-nowrap`,{"cursor-pointer hover:bg-hover":i.sortable}]),style:e(i.width?{width:i.width}:{}),onClick:e=>y(i)},[m(`div`,k,[m(`span`,null,u(i.label),1),i.sortable?(n(),p(f,{key:0},[x(i)===`up`?(n(),p(`svg`,A,[..._[0]||=[m(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M5 15l7-7 7 7`},null,-1)]])):x(i)===`down`?(n(),p(`svg`,j,[..._[1]||=[m(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M19 9l-7 7-7-7`},null,-1)]])):(n(),p(`svg`,M,[..._[2]||=[m(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M7 16V4m0 0L3 8m4-4l4 4m6 0v12m0 0l4-4m-4 4l-4-4`},null,-1)]]))],64)):t(``,!0)])],14,O))),128)),m(`th`,N,u(g.$t(`common.actions`)),1)])]),m(`tbody`,P,[l.loading?(n(),p(`tr`,F,[m(`td`,{colspan:l.columns.length+1,class:`px-6 py-12 text-center`},[..._[3]||=[m(`svg`,{class:`animate-spin h-8 w-8 text-accent mx-auto`,fill:`none`,viewBox:`0 0 24 24`},[m(`circle`,{class:`opacity-25`,cx:`12`,cy:`12`,r:`10`,stroke:`currentColor`,"stroke-width":`4`}),m(`path`,{class:`opacity-75`,fill:`currentColor`,d:`M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z`})],-1)]],8,I)])):l.items.data?.length?(n(!0),p(f,{key:2},i(l.items.data,e=>(n(),p(`tr`,{key:e.id,"data-row-id":e.id,class:`bg-surface hover:bg-hover`},[(n(!0),p(f,null,i(l.columns,t=>(n(),p(`td`,{key:t.name,class:`border-b border-line px-3 py-2 whitespace-nowrap text-sm max-w-xs truncate`,title:X(e,t)},[h(g.$slots,`cell-${t.name}`,{item:e,value:e[t.name]},()=>[t.type===`boolean`?(n(),p(f,{key:0},[e[t.name]?(n(),p(`span`,V,[_[4]||=m(`span`,{class:`h-2 w-2 rounded-full bg-current`,"aria-hidden":`true`},null,-1),o(` `+u(t.trueLabel||g.$t(`common.yes`)),1)])):(n(),p(`span`,H,[_[5]||=m(`span`,{class:`h-2 w-2 rounded-full border-2 border-current`,"aria-hidden":`true`},null,-1),o(` `+u(t.falseLabel||g.$t(`common.no`)),1)]))],64)):t.type===`image`?(n(),p(f,{key:1},[b(e[t.name])?(n(),p(`img`,{key:0,src:b(e[t.name]),alt:t.label,class:`h-10 w-10 rounded object-cover`},null,8,U)):(n(),p(`span`,W,`—`))],64)):t.type===`date`?(n(),p(f,{key:2},[o(u(e[t.name]?new Date(e[t.name]).toLocaleDateString(`ru-RU`):`—`),1)],64)):(n(),p(f,{key:3},[S(e,t)?(n(),p(`a`,{key:0,href:S(e,t),target:`_blank`,rel:`noopener`,class:`text-accent hover:text-accent-hover hover:underline`},u(e[t.name]),9,G)):(n(),p(`span`,K,u(e[t.name]??`—`),1))],64))])],8,B))),128)),m(`td`,q,[h(g.$slots,`actions`,{item:e},()=>[(n(!0),p(f,null,i(l.rowActions,t=>(n(),a(c(d),{key:t.name,href:t.href(e),"data-action":t.name,class:`mr-1 inline-flex items-center rounded px-2 py-1 text-xs text-accent hover:bg-accent-soft hover:text-accent-hover`},{default:s(()=>[_[6]||=m(`svg`,{class:`mr-1 h-3.5 w-3.5`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,"aria-hidden":`true`},[m(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M12 4v16m8-8H4`})],-1),o(` `+u(t.label),1)]),_:2},1032,[`href`,`data-action`]))),128)),m(`button`,{"data-action":`edit`,onClick:t=>g.$emit(`edit`,e),class:`inline-flex items-center rounded p-1.5 text-accent hover:bg-accent-soft hover:text-accent-hover`,title:g.$t(`common.edit`),"aria-label":g.$t(`common.edit`)},[..._[7]||=[m(`svg`,{class:`h-4 w-4`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,"stroke-width":`2`},[m(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,d:`M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z`})],-1)]],8,J),l.canDelete?(n(),p(`button`,{key:0,"data-action":`delete`,onClick:t=>g.$emit(`delete`,e),class:`ml-1 inline-flex items-center rounded p-1.5 text-danger hover:bg-danger-soft hover:text-danger-soft-fg`,title:g.$t(`common.delete`),"aria-label":g.$t(`common.delete`)},[..._[8]||=[m(`svg`,{class:`h-4 w-4`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,"stroke-width":`2`},[m(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,d:`M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16`})],-1)]],8,Y)):t(``,!0)])])],8,z))),128)):(n(),p(`tr`,L,[m(`td`,{colspan:l.columns.length+1,class:`px-6 py-12 text-center text-muted`},u(g.$t(`resource.table.empty`)),9,R)]))])])]),l.items.total>l.items.per_page?(n(),a(C,{key:0,paginator:l.items},null,8,[`paginator`])):t(``,!0)]))}};export{X as t}; \ No newline at end of file diff --git a/packages/admin/dist/assets/AdminLayout--RXJFj9t.js b/packages/admin/dist/assets/AdminLayout-DBeSErmz.js similarity index 62% rename from packages/admin/dist/assets/AdminLayout--RXJFj9t.js rename to packages/admin/dist/assets/AdminLayout-DBeSErmz.js index 72f26aa9..d8a04ddb 100644 --- a/packages/admin/dist/assets/AdminLayout--RXJFj9t.js +++ b/packages/admin/dist/assets/AdminLayout-DBeSErmz.js @@ -1 +1 @@ -import{C as e,E as t,F as n,G as r,H as i,I as a,M as o,P as s,Q as c,R as l,S as u,T as d,W as f,Y as p,Z as m,_ as h,b as g,c as _,et as v,h as y,i as b,m as x,o as S,r as C,s as w,v as T,w as E,x as D,z as O}from"./dist-MY__znoP.js";import{n as k,r as A,t as j}from"./LocaleSwitcher-DdLJ9WTE.js";import{n as M,t as N}from"./app-BNjy5Z6H.js";var P=[`aria-expanded`,`title`],F={class:`flex items-center`},I=[`innerHTML`],L={key:0},R=[`innerHTML`],z={key:0,class:`mt-1 ml-4 space-y-1 border-l border-sidebar-line pl-3`},B=[`innerHTML`],V={key:0},H=`flex items-center px-3 py-2 text-sm rounded-lg transition-colors duration-200 focus:outline-none focus-visible:ring-2 focus-visible:ring-sidebar-accent`,U=`bg-sidebar-active text-sidebar-active-fg font-semibold shadow-[inset_3px_0_0_var(--atrium-sidebar-accent)]`,W=`text-sidebar-fg font-medium hover:bg-sidebar-hover`,G={__name:`AdminMenuItem`,props:{item:{type:Object,required:!0},collapsed:Boolean},setup(n){let i=n,o=S(),s=p(!1),h=g(()=>i.item.children&&i.item.children.length>0),_=e=>{let t=route(e,void 0,!1),n=o.url.split(`?`)[0];return n===t||t!==route(`admin.dashboard`,void 0,!1)&&n.startsWith(t+`/`)},x=g(()=>!!i.item.route&&_(i.item.route)),C=g(()=>h.value?i.item.children.some(e=>e.route&&_(e.route)):!1),w=()=>{h.value&&(s.value=!s.value)};C.value&&(s.value=!0);let O={home:``,users:``,settings:``,folder:``,document:``,chart:``,"file-text":``,package:``,"help-circle":``,briefcase:``,star:``,tool:``,info:``,image:``,inbox:``,"shopping-cart":``,globe:``,shield:``,chevronDown:``,default:``},k=e=>_(e.route),A=g(()=>O[i.item.icon]||O.default);return(i,o)=>(a(),E(`li`,null,[h.value?(a(),E(T,{key:0},[D(`button`,{onClick:w,class:c([`w-full flex items-center px-3 py-2 text-sm rounded-lg transition-colors duration-200 hover:bg-sidebar-hover focus:outline-none focus-visible:ring-2 focus-visible:ring-sidebar-accent`,[C.value?`text-sidebar-fg font-semibold`:`text-sidebar-fg font-medium`,n.collapsed?`justify-center`:`justify-between`]]),"aria-expanded":s.value?`true`:`false`,title:n.collapsed?n.item.label:``},[D(`span`,F,[(a(),E(`svg`,{class:c([`w-5 h-5 flex-shrink-0 text-sidebar-muted`,n.collapsed?``:`mr-3`]),fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,"aria-hidden":`true`,innerHTML:A.value},null,10,I)),n.collapsed?e(``,!0):(a(),E(`span`,L,v(n.item.label),1))]),n.collapsed?e(``,!0):(a(),E(`svg`,{key:0,class:c([`w-4 h-4 text-sidebar-muted transition-transform duration-200`,{"rotate-180":s.value}]),"aria-hidden":`true`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,innerHTML:O.chevronDown},null,10,R))],10,P),n.collapsed?e(``,!0):r((a(),E(`ul`,z,[(a(!0),E(T,null,l(n.item.children,e=>(a(),E(`li`,{key:e.route},[t(m(b),{"data-menu-route":e.route,href:i.route(e.route),class:c([H,k(e)?U:W]),"aria-current":k(e)?`page`:void 0},{default:f(()=>[d(v(e.label),1)]),_:2},1032,[`data-menu-route`,`href`,`class`,`aria-current`])]))),128))],512)),[[y,s.value]])],64)):(a(),u(m(b),{key:1,"data-menu-route":n.item.route,href:i.route(n.item.route),class:c([H,x.value?U:W,n.collapsed?`justify-center`:``]),"aria-current":x.value?`page`:void 0,title:n.collapsed?n.item.label:``},{default:f(()=>[(a(),E(`svg`,{class:c([`w-5 h-5 flex-shrink-0`,[n.collapsed?``:`mr-3`,x.value?``:`text-sidebar-muted`]]),fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,"aria-hidden":`true`,innerHTML:A.value},null,10,B)),n.collapsed?e(``,!0):(a(),E(`span`,V,v(n.item.label),1))]),_:1},8,[`data-menu-route`,`href`,`class`,`aria-current`,`title`]))]))}},K={class:`h-16 flex items-center justify-between px-4 border-b border-sidebar-line`},q=[`src`,`alt`],J={key:1,class:`text-xl font-bold truncate`},Y={class:`flex-1 overflow-y-auto py-4 px-3`},ee={class:`space-y-1`},te={class:`lg:hidden border-t border-sidebar-line p-4`},ne={class:`flex items-center space-x-3`},re={class:`w-10 h-10 rounded-full bg-sidebar-active text-sidebar-active-fg flex items-center justify-center`},ie={class:`text-lg font-medium`},ae={key:0},oe={class:`text-sm font-medium`},se={class:`text-xs text-sidebar-muted`},ce={__name:`AdminSidebar`,props:{open:Boolean,collapsed:Boolean,menu:{type:Array,default:()=>[]},branding:{type:Object,default:()=>({})}},emits:[`close`],setup(n,{emit:r}){let i=S();return g(()=>i.url),(r,i)=>(a(),E(`aside`,{class:c([`fixed inset-y-0 left-0 z-50 flex flex-col bg-sidebar text-sidebar-fg border-r border-sidebar-line transform transition-transform duration-300 lg:translate-x-0`,[n.open?`translate-x-0`:`-translate-x-full`,n.collapsed?`lg:w-20`:`lg:w-64`,`w-64`]])},[D(`div`,K,[t(m(b),{href:r.route(`admin.dashboard`),"data-sidebar-brand":``,class:`flex min-w-0 items-center space-x-3 rounded-md focus:outline-none focus-visible:ring-2 focus-visible:ring-sidebar-accent`},{default:f(()=>[n.branding.logo?(a(),E(`img`,{key:0,src:n.branding.logo,alt:n.branding.name,class:`h-8 w-auto`},null,8,q)):e(``,!0),n.branding.logo&&!n.collapsed?(a(),E(`span`,J,v(n.branding.name||r.$t(`layout.brand_short`)),1)):e(``,!0),n.branding.logo?e(``,!0):(a(),u(A,{key:2,name:n.branding.name||`Atrium`,wordmark:!n.collapsed,size:28},null,8,[`name`,`wordmark`]))]),_:1},8,[`href`]),D(`button`,{onClick:i[0]||=e=>r.$emit(`close`),class:`lg:hidden p-2 rounded-md text-sidebar-muted hover:text-sidebar-fg hover:bg-sidebar-hover focus:outline-none focus-visible:ring-2 focus-visible:ring-sidebar-accent`},[...i[1]||=[D(`svg`,{class:`w-6 h-6`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`},[D(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M6 18L18 6M6 6l12 12`})],-1)]])]),D(`nav`,Y,[D(`ul`,ee,[(a(!0),E(T,null,l(n.menu,e=>(a(),u(G,{key:e.route,item:e,collapsed:n.collapsed},null,8,[`item`,`collapsed`]))),128))])]),D(`div`,te,[D(`div`,ne,[D(`div`,re,[D(`span`,ie,v(r.$page.props.auth?.user?.name?.charAt(0)||`A`),1)]),n.collapsed?e(``,!0):(a(),E(`div`,ae,[D(`p`,oe,v(r.$page.props.auth?.user?.name),1),D(`p`,se,v(r.$page.props.auth?.user?.email),1)]))])]),t(k,{on:`sidebar`,compact:n.collapsed,class:c([`border-t border-sidebar-line px-4 py-3`,n.collapsed?`lg:px-2 lg:text-center`:``])},null,8,[`compact`,`class`])],2))}},le=[`aria-expanded`],ue={class:`w-8 h-8 rounded-full bg-accent-soft flex items-center justify-center text-accent-soft-fg font-semibold`},de={class:`hidden md:block text-left`},fe={class:`text-sm font-medium text-fg`},pe={class:`text-xs text-muted`},me={key:0,class:`absolute right-0 mt-2 w-56 bg-surface rounded-lg shadow-lg border border-line py-1 z-50`},he={class:`px-4 py-3 border-b border-line`},ge={class:`text-sm font-medium text-fg`},_e={class:`text-xs text-muted truncate`},ve={class:`py-1`},ye=[`aria-label`],be={class:`px-4 pt-2 pb-1 text-xs font-semibold uppercase tracking-wide text-muted`},xe=[`aria-checked`,`data-theme-option`,`onClick`],Se=[`data-theme`],Ce={key:1,class:`flex h-4 w-6 flex-none overflow-hidden rounded-sm ring-1 ring-field`,"aria-hidden":`true`},we={class:`flex-1 text-left`},Te={key:2,class:`h-4 w-4 flex-none text-accent`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,"aria-hidden":`true`},Ee={class:`border-t border-line py-1`},De={__name:`AdminUserDropdown`,props:{user:{type:Object,default:()=>({})}},setup(r){let i=p(!1),o=p(null),u=()=>{i.value=!i.value},h=()=>{i.value=!1},y=S(),x=g(()=>y.props.themes||[]),C=g(()=>y.props.theme),O=e=>{N(e),w.put(route(`admin.profile.theme`),{theme:e},{preserveScroll:!0,preserveState:!0})},k=()=>{w.post(route(`admin.logout`))},A=e=>{o.value&&!o.value.contains(e.target)&&h()};return s(()=>{document.addEventListener(`click`,A)}),n(()=>{document.removeEventListener(`click`,A)}),(n,s)=>(a(),E(`div`,{ref_key:`dropdownRef`,ref:o,class:`relative`},[D(`button`,{"data-action":`user-menu`,onClick:u,"aria-expanded":i.value?`true`:`false`,class:`flex items-center gap-3 p-2 rounded-lg hover:bg-hover transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-focus`},[D(`div`,ue,v(r.user.name?.charAt(0)?.toUpperCase()||`A`),1),D(`div`,de,[D(`p`,fe,v(r.user.name),1),D(`p`,pe,v(r.user.email),1)]),s[0]||=D(`svg`,{class:`hidden sm:block w-4 h-4 text-muted`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`},[D(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M19 9l-7 7-7-7`})],-1)],8,le),t(_,{"enter-active-class":`transition ease-out duration-100`,"enter-from-class":`transform opacity-0 scale-95`,"enter-to-class":`transform opacity-100 scale-100`,"leave-active-class":`transition ease-in duration-75`,"leave-from-class":`transform opacity-100 scale-100`,"leave-to-class":`transform opacity-0 scale-95`},{default:f(()=>[i.value?(a(),E(`div`,me,[D(`div`,he,[D(`p`,ge,v(r.user.name),1),D(`p`,_e,v(r.user.email),1)]),D(`div`,ve,[t(m(b),{href:n.route(`admin.profile.edit`),class:`flex items-center px-4 py-2 text-sm text-fg hover:bg-hover`,onClick:h},{default:f(()=>[s[1]||=D(`svg`,{class:`w-4 h-4 mr-3 text-muted`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`},[D(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z`})],-1),d(` `+v(n.$t(`layout.user_menu.profile`)),1)]),_:1},8,[`href`])]),D(`div`,{class:`border-t border-line py-1`,role:`radiogroup`,"aria-label":n.$t(`layout.theme.label`)},[D(`p`,be,v(n.$t(`layout.theme.label`)),1),(a(!0),E(T,null,l(x.value,t=>(a(),E(`button`,{key:t,type:`button`,role:`radio`,"aria-checked":t===C.value?`true`:`false`,"data-theme-option":t,class:c([`flex items-center w-full gap-3 px-4 py-2 text-sm text-fg hover:bg-hover focus:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-focus`,t===C.value?`font-semibold`:``]),onClick:e=>O(t)},[t===`system`?(a(),E(`span`,Ce,[...s[3]||=[D(`span`,{"data-theme":`graphite`,class:`flex-1 bg-page`},null,-1),D(`span`,{"data-theme":`night`,class:`flex-1 bg-page`},null,-1)]])):(a(),E(`span`,{key:0,"data-theme":t,class:`flex h-4 w-6 flex-none overflow-hidden rounded-sm ring-1 ring-field`,"aria-hidden":`true`},[...s[2]||=[D(`span`,{class:`w-2 bg-sidebar`},null,-1),D(`span`,{class:`flex flex-1 items-center justify-center bg-page`},[D(`span`,{class:`h-1.5 w-1.5 rounded-full bg-accent`})],-1)]],8,Se)),D(`span`,we,v(n.$t(`layout.theme.${t}`)),1),t===C.value?(a(),E(`svg`,Te,[...s[4]||=[D(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2.5`,d:`M5 13l4 4L19 7`},null,-1)]])):e(``,!0)],10,xe))),128))],8,ye),D(`div`,Ee,[D(`button`,{"data-action":`logout`,onClick:k,class:`flex items-center w-full px-4 py-2 text-sm text-danger hover:bg-danger-soft`},[s[5]||=D(`svg`,{class:`w-4 h-4 mr-3`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`},[D(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M17 16l4-4m0 0l-4-4m4 4H7m6 4v1a3 3 0 01-3 3H6a3 3 0 01-3-3V7a3 3 0 013-3h4a3 3 0 013 3v1`})],-1),d(` `+v(n.$t(`layout.user_menu.logout`)),1)])])])):e(``,!0)]),_:1})],512))}},Oe={key:0,class:`relative flex min-w-0 items-center gap-1 rounded-lg px-1 py-1 text-muted hover:bg-hover hover:text-fg sm:gap-2 sm:px-2`},ke={class:`flex min-w-0 flex-col text-left leading-tight`,"aria-hidden":`true`},Ae={"data-switcher-caption":``,class:`truncate text-[11px] sm:text-xs`},je={class:`max-w-14 truncate text-sm font-medium text-fg sm:max-w-32 xl:max-w-48`},Me=[`aria-label`,`aria-description`,`title`,`value`],Ne=[`value`],Pe={__name:`SiteSwitcher`,setup(t){let n=S(),r=g(()=>n.props.sites||[]),i=g(()=>n.props.currentSite?.id),o=g(()=>n.props.currentSite?.name??``),s=e=>{w.post(route(`admin.site`),{site_id:e.target.value},{preserveScroll:!0,preserveState:!1})};return(t,n)=>r.value.length>1?(a(),E(`div`,Oe,[n[0]||=D(`svg`,{class:`h-5 w-5 shrink-0`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,"aria-hidden":`true`},[D(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M3 8.25V18a2.25 2.25 0 002.25 2.25h13.5A2.25 2.25 0 0021 18V8.25m-18 0V6a2.25 2.25 0 012.25-2.25h13.5A2.25 2.25 0 0121 6v2.25m-18 0h18M5.25 6h.008v.008H5.25V6zm2.25 0h.008v.008H7.5V6zm2.25 0h.008v.008H9.75V6z`})],-1),D(`span`,ke,[D(`span`,Ae,v(t.$t(`layout.site`)),1),D(`span`,je,v(o.value),1)]),n[1]||=D(`svg`,{class:`hidden h-4 w-4 shrink-0 sm:block`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,"aria-hidden":`true`},[D(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M19 9l-7 7-7-7`})],-1),D(`select`,{"data-site-switcher":``,name:`site_id`,"aria-label":t.$t(`layout.site`),"aria-description":t.$t(`layout.site_hint`),title:t.$t(`layout.site_hint`),value:i.value,class:`absolute inset-0 h-full w-full cursor-pointer appearance-none rounded-lg bg-transparent text-transparent focus:outline-none focus-visible:ring-2 focus-visible:ring-focus`,onChange:s},[(a(!0),E(T,null,l(r.value,e=>(a(),E(`option`,{key:e.id,value:e.id,class:`bg-surface text-fg`},v(e.name),9,Ne))),128))],40,Me)])):e(``,!0)}},Fe={class:`sticky top-0 z-30 transform-gpu h-16 bg-surface border-b border-line flex items-center justify-between gap-1 px-3 sm:gap-2 sm:px-4 lg:px-6`},Ie={class:`flex shrink-0 items-center gap-1 sm:gap-4`},Le=[`href`,`title`],Re={class:`hidden sm:inline`},ze={class:`flex min-w-0 items-center gap-1 sm:gap-2 lg:gap-3`},Be={__name:`AdminHeader`,props:{user:{type:Object,default:()=>({})},branding:{type:Object,default:()=>({})}},emits:[`toggle-sidebar`,`toggle-collapse`],setup(e,{emit:n}){return(n,r)=>(a(),E(`header`,Fe,[D(`div`,Ie,[D(`button`,{onClick:r[0]||=e=>n.$emit(`toggle-sidebar`),class:`lg:hidden p-2 rounded-md text-muted hover:text-fg hover:bg-hover`},[...r[2]||=[D(`svg`,{class:`w-6 h-6`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`},[D(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M4 6h16M4 12h16M4 18h16`})],-1)]]),D(`button`,{"data-action":`collapse-sidebar`,onClick:r[1]||=e=>n.$emit(`toggle-collapse`),class:`hidden lg:block p-2 rounded-md text-muted hover:text-fg hover:bg-hover`},[...r[3]||=[D(`svg`,{class:`w-5 h-5`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`},[D(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M4 6h16M4 12h8m-8 6h16`})],-1)]]),D(`a`,{"data-action":`visit-site`,href:n.$page.props.currentSite?.url||`/`,target:`_blank`,rel:`noopener`,class:`flex items-center gap-2 rounded-md px-2 py-2 text-sm text-muted hover:bg-hover hover:text-fg`,title:n.$t(`layout.visit_site_hint`)},[r[4]||=D(`svg`,{class:`w-5 h-5`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`},[D(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M21 12a9 9 0 11-18 0 9 9 0 0118 0zM3.6 9h16.8M3.6 15h16.8M12 3a15 15 0 010 18M12 3a15 15 0 000 18`})],-1),D(`span`,Re,v(n.$t(`layout.visit_site`)),1)],8,Le)]),D(`div`,ze,[t(Pe),t(j),t(De,{user:e.user},null,8,[`user`])])]))}};function X(){return M(`fields.upload.session_expired`)}function Ve(e){let t=document.cookie.match(RegExp(`(?:^|;\\s*)`+e+`=([^;]*)`));if(!t)return null;try{return decodeURIComponent(t[1])}catch{return t[1]}}function He(){let e=Ve(`XSRF-TOKEN`);if(e)return{"X-XSRF-TOKEN":e};let t=document.querySelector(`meta[name="csrf-token"]`)?.getAttribute(`content`);return t?{"X-CSRF-TOKEN":t}:{}}function Z(e={}){return{Accept:`application/json`,"X-Requested-With":`XMLHttpRequest`,...He(),...e}}async function Q(e,t=M(`fields.upload.request_failed`)){return e.status===419?X():e.status===413?M(`fields.upload.too_large`):(await e.json().catch(()=>({}))).message||t}var Ue=(e,t)=>{let n=e.__vccOpts||e;for(let[e,r]of t)n[e]=r;return n},We=[`aria-label`],Ge={class:`flex items-center justify-between gap-2 border-b border-line px-4 py-2.5`},Ke={class:`text-sm font-semibold`},qe={class:`flex items-center gap-3 text-xs`},Je=[`aria-label`],Ye={class:`rounded-lg bg-surface-alt px-3 py-2`},Xe={key:0,class:`max-w-[85%] whitespace-pre-wrap rounded-lg bg-accent-soft px-3 py-2 text-accent-soft-fg`,dusk:`ai-question`},Ze=[`dusk`,`innerHTML`],Qe={key:0,class:`text-muted`,dusk:`ai-thinking`},$e={class:`flex items-end gap-2`},et=[`placeholder`,`aria-label`],tt=[`disabled`],$={class:`mt-2 text-xs text-muted`},nt=[`aria-label`,`aria-expanded`,`title`],rt={viewBox:`0 0 48 52`,class:`h-full w-full overflow-visible`,"aria-hidden":`true`},it={class:`ai-mascot-body`},at={class:`ai-mascot-eyes`},ot=[`cx`,`cy`],st=[`cx`,`cy`],ct=Ue({__name:`AiHelper`,setup(t){let u=S(),d=g(()=>u.props.ai?.help||null),f=g(()=>d.value?.labels||{}),m=g(()=>u.props.ai?.url||``),_=g(()=>`atrium-ai-help:${u.props.auth?.user?.id??``}`),y=p(!1),b=p(!1),C=p(``),O=p([]),k=p(null),A=p(null),j=p({x:0,y:0}),M=p(null),N=null,P=0;s(()=>{try{O.value=JSON.parse(sessionStorage.getItem(_.value)||`[]`)}catch{O.value=[]}window.addEventListener(`pointermove`,F)}),n(()=>{I(),window.removeEventListener(`pointermove`,F)}),i(O,e=>{try{sessionStorage.setItem(_.value,JSON.stringify(e.slice(-20)))}catch{}},{deep:!0});function F(e){let t=M.value?.getBoundingClientRect();if(!t)return;let n=e.clientX-(t.left+t.width/2),r=e.clientY-(t.top+t.height/3),i=Math.hypot(n,r)||1;j.value={x:n/i*.9,y:r/i*.9}}function I(){clearTimeout(N),N=null,P++}async function L(){y.value=!y.value,y.value&&(await o(),z(),A.value?.focus())}function R(){I(),b.value=!1,O.value=[],A.value?.focus()}async function z(){await o(),k.value&&(k.value.scrollTop=k.value.scrollHeight)}async function B(){let e=C.value.trim();if(e===``||b.value)return;let t=O.value.filter(e=>!e.error).slice(-10).map(({role:e,text:t})=>({role:e,text:t}));O.value.push({role:`user`,text:e}),C.value=``,b.value=!0,z(),I();let n=P;try{let r=await fetch(d.value.url,{method:`POST`,credentials:`same-origin`,headers:Z({"Content-Type":`application/json`}),body:JSON.stringify({question:e,history:t})});if(!r.ok)throw Error(await Q(r,f.value.error));V(await r.json(),n)}catch(e){n===P&&U(e.message)}}function V(e,t){t===P&&(e.status===`done`?(b.value=!1,O.value.push({role:`assistant`,text:e.value||``}),z()):e.status===`failed`?U(e.message):N=setTimeout(()=>H(e.id,t),1500))}async function H(e,t){try{let n=await fetch(`${m.value}/${e}`,{credentials:`same-origin`,headers:Z()});if(!n.ok)throw Error(await Q(n,f.value.error));V(await n.json(),t)}catch(e){t===P&&U(e.message)}}function U(e){b.value=!1,O.value.push({role:`assistant`,text:e||f.value.error,error:!0}),z()}function W(e){e.key===`Enter`&&!e.shiftKey&&!e.isComposing&&(e.preventDefault(),B())}let G={"&":`&`,"<":`<`,">":`>`,'"':`"`,"'":`'`},K=e=>String(e).replace(/[&<>"']/g,e=>G[e]);function q(e){let t=e=>K(e).replace(/\*\*(.+?)\*\*/g,`$1`).replace(/\[([^\]]+)\]\(([^)\s]+)\)/g,(e,t,n)=>n.startsWith(`/`)&&!n.startsWith(`//`)?`${t}`:t),n=[],r=[],i=()=>{r.length&&(n.push(`
    ${r.map(e=>`
  • ${e}
  • `).join(``)}
`),r=[])};for(let a of String(e).split(/\r?\n/)){let e=a.match(/^\s*[-*]\s+(.*)$/);e?r.push(t(e[1])):(i(),a.trim()!==``&&n.push(`

${t(a)}

`))}return i(),n.join(``)}function J(e){let t=e.target.closest?.(`a[data-ai-link]`);t&&(e.preventDefault(),w.visit(t.getAttribute(`href`)))}function Y(e){e.key===`Escape`&&y.value&&(y.value=!1)}return(t,n)=>d.value?(a(),E(`div`,{key:0,class:`fixed bottom-4 right-4 z-40 flex flex-col items-end gap-3`,dusk:`ai-helper`,onKeydown:Y},[y.value?(a(),E(`section`,{key:0,class:`flex w-[22rem] max-w-[calc(100vw-2rem)] max-h-[min(36rem,calc(100vh-8rem))] flex-col rounded-lg border border-line bg-surface text-fg shadow-xl`,role:`dialog`,"aria-label":f.value.title,dusk:`ai-chat`},[D(`header`,Ge,[D(`h2`,Ke,v(f.value.title),1),D(`div`,qe,[O.value.length?(a(),E(`button`,{key:0,type:`button`,class:`text-muted hover:text-fg`,dusk:`ai-clear`,onClick:R},v(f.value.clear),1)):e(``,!0),D(`button`,{type:`button`,class:`text-muted hover:text-fg`,"aria-label":f.value.close,dusk:`ai-close`,onClick:n[0]||=e=>y.value=!1},[...n[2]||=[D(`svg`,{class:`h-4 w-4`,viewBox:`0 0 20 20`,fill:`currentColor`,"aria-hidden":`true`},[D(`path`,{d:`M5.3 4.3 10 9l4.7-4.7 1 1L11 10l4.7 4.7-1 1L10 11l-4.7 4.7-1-1L9 10 4.3 5.3z`})],-1)]],8,Je)])]),D(`div`,{ref_key:`list`,ref:k,class:`flex-1 space-y-3 overflow-y-auto px-4 py-3 text-sm`,"aria-live":`polite`,onClick:J},[D(`p`,Ye,v(f.value.hello),1),(a(!0),E(T,null,l(O.value,(e,t)=>(a(),E(`div`,{key:t,class:c([`flex`,e.role===`user`?`justify-end`:`justify-start`])},[e.role===`user`?(a(),E(`p`,Xe,v(e.text),1)):(a(),E(`div`,{key:1,class:c([`max-w-[90%] space-y-2 rounded-lg px-3 py-2`,e.error?`border border-danger bg-danger-soft text-danger-soft-fg`:`bg-surface-alt`]),dusk:e.error?`ai-error`:`ai-answer`,innerHTML:q(e.text)},null,10,Ze))],2))),128)),b.value?(a(),E(`p`,Qe,v(f.value.thinking),1)):e(``,!0)],512),D(`form`,{class:`border-t border-line p-3`,onSubmit:h(B,[`prevent`])},[D(`div`,$e,[r(D(`textarea`,{ref_key:`input`,ref:A,"onUpdate:modelValue":n[1]||=e=>C.value=e,rows:`2`,maxlength:`2000`,class:`flex-1 resize-none rounded-md border border-field bg-surface px-3 py-2 text-sm text-fg focus:border-focus focus:outline-none focus:ring-1 focus:ring-focus`,placeholder:f.value.placeholder,"aria-label":f.value.placeholder,dusk:`ai-input`,onKeydown:W},null,40,et),[[x,C.value]]),D(`button`,{type:`submit`,class:`rounded-md bg-accent px-3 py-2 text-sm font-medium text-on-accent hover:bg-accent-hover disabled:opacity-50`,disabled:b.value||C.value.trim()===``,dusk:`ai-send`},v(f.value.send),9,tt)]),D(`p`,$,v(f.value.note),1)],32)],8,We)):e(``,!0),D(`button`,{ref_key:`mascot`,ref:M,type:`button`,class:c([`ai-mascot group relative h-16 w-16 rounded-full focus:outline-none focus-visible:ring-2 focus-visible:ring-focus`,{"is-thinking":b.value,"is-open":y.value}]),"aria-label":f.value.open,"aria-expanded":y.value,title:f.value.open,dusk:`ai-mascot`,onClick:L},[(a(),E(`svg`,rt,[n[9]||=D(`ellipse`,{class:`ai-mascot-shadow fill-fg`,cx:`24`,cy:`49`,rx:`15`,ry:`2.2`,opacity:`0.15`},null,-1),D(`g`,it,[n[5]||=D(`path`,{class:`fill-fg`,d:`M6 42V22a18 18 0 0 1 36 0v20H32V22a8 8 0 0 0-16 0v20z`},null,-1),n[6]||=D(`rect`,{class:`ai-mascot-belt fill-accent`,x:`16`,y:`28`,width:`16`,height:`5`},null,-1),n[7]||=D(`rect`,{class:`fill-fg`,x:`4`,y:`41`,width:`13`,height:`3.5`,rx:`1.75`},null,-1),n[8]||=D(`rect`,{class:`fill-fg`,x:`31`,y:`41`,width:`13`,height:`3.5`,rx:`1.75`},null,-1),D(`g`,at,[n[3]||=D(`circle`,{class:`fill-surface`,cx:`19`,cy:`10.5`,r:`3`},null,-1),n[4]||=D(`circle`,{class:`fill-surface`,cx:`29`,cy:`10.5`,r:`3`},null,-1),D(`circle`,{class:`fill-fg`,cx:19+j.value.x,cy:10.5+j.value.y,r:`1.4`},null,8,ot),D(`circle`,{class:`fill-fg`,cx:29+j.value.x,cy:10.5+j.value.y,r:`1.4`},null,8,st)])])]))],10,nt)],32)):e(``,!0)}},[[`__scopeId`,`data-v-6928fa25`]]),lt={class:`min-h-screen bg-page`},ut={"data-page-content":`true`,class:`p-4 lg:p-6`},dt={key:0,"data-flash":`success`,class:`mb-4 p-4 bg-success-soft border border-success text-success-soft-fg rounded`},ft={key:1,"data-flash":`error`,class:`mb-4 p-4 bg-danger-soft border border-danger text-danger-soft-fg rounded`},pt={__name:`AdminLayout`,props:{title:{type:String,default:``}},setup(n){let r=S(),i=p(!1),o=p(!1),s=g(()=>r.props.branding||{}),l=g(()=>r.props.menu||[]),u=g(()=>r.props.auth?.user||{}),d=()=>{i.value=!i.value},f=()=>{o.value=!o.value},h=()=>{i.value=!1};return(r,p)=>(a(),E(T,null,[t(m(C),{title:n.title||``},null,8,[`title`]),D(`div`,lt,[i.value?(a(),E(`div`,{key:0,class:`fixed inset-0 z-40 bg-black/50 lg:hidden`,onClick:h})):e(``,!0),t(ce,{open:i.value,collapsed:o.value,menu:l.value,branding:s.value,onClose:h},null,8,[`open`,`collapsed`,`menu`,`branding`]),D(`div`,{class:c([`transition-all duration-300`,o.value?`lg:pl-20`:`lg:pl-64`])},[t(Be,{user:u.value,branding:s.value,onToggleSidebar:d,onToggleCollapse:f},null,8,[`user`,`branding`]),D(`main`,ut,[r.$page.props.flash?.success?(a(),E(`div`,dt,v(r.$page.props.flash.success),1)):e(``,!0),r.$page.props.flash?.error?(a(),E(`div`,ft,v(r.$page.props.flash.error),1)):e(``,!0),O(r.$slots,`default`)])],2),t(ct)])],64))}};export{X as i,Z as n,Q as r,pt as t}; \ No newline at end of file +import{$ as e,C as t,E as n,F as r,G as i,H as a,I as o,M as s,P as c,Q as l,R as u,S as d,T as f,W as p,X as m,_ as h,b as g,c as _,h as v,i as y,m as b,o as x,r as S,s as C,tt as w,v as T,w as E,x as D,z as O}from"./dist-Bie52OmN.js";import{n as k,r as A,t as j}from"./LocaleSwitcher-DAWnmZni.js";import{n as M,t as N}from"./app-BCJOqmKO.js";var P=[`aria-expanded`,`title`],F={class:`flex items-center`},I=[`innerHTML`],L={key:0},R=[`innerHTML`],z={key:0,class:`mt-1 ml-4 space-y-1 border-l border-sidebar-line pl-3`},B=[`innerHTML`],V={key:0},H=`flex items-center px-3 py-2 text-sm rounded-lg transition-colors duration-200 focus:outline-none focus-visible:ring-2 focus-visible:ring-sidebar-accent`,U=`bg-sidebar-active text-sidebar-active-fg font-semibold shadow-[inset_3px_0_0_var(--atrium-sidebar-accent)]`,W=`text-sidebar-fg font-medium hover:bg-sidebar-hover`,G={__name:`AdminMenuItem`,props:{item:{type:Object,required:!0},collapsed:Boolean},setup(r){let a=r,s=x(),c=m(!1),h=g(()=>a.item.children&&a.item.children.length>0),_=e=>{let t=route(e,void 0,!1),n=s.url.split(`?`)[0];return n===t||t!==route(`admin.dashboard`,void 0,!1)&&n.startsWith(t+`/`)},b=g(()=>!!a.item.route&&_(a.item.route)),S=g(()=>h.value?a.item.children.some(e=>e.route&&_(e.route)):!1),C=()=>{h.value&&(c.value=!c.value)};S.value&&(c.value=!0);let O={home:``,users:``,settings:``,folder:``,document:``,chart:``,"file-text":``,package:``,"help-circle":``,briefcase:``,star:``,tool:``,info:``,image:``,inbox:``,"shopping-cart":``,globe:``,shield:``,chevronDown:``,default:``},k=e=>_(e.route),A=g(()=>O[a.item.icon]||O.default);return(a,s)=>(o(),E(`li`,null,[h.value?(o(),E(T,{key:0},[D(`button`,{onClick:C,class:e([`w-full flex items-center px-3 py-2 text-sm rounded-lg transition-colors duration-200 hover:bg-sidebar-hover focus:outline-none focus-visible:ring-2 focus-visible:ring-sidebar-accent`,[S.value?`text-sidebar-fg font-semibold`:`text-sidebar-fg font-medium`,r.collapsed?`justify-center`:`justify-between`]]),"aria-expanded":c.value?`true`:`false`,title:r.collapsed?r.item.label:``},[D(`span`,F,[(o(),E(`svg`,{class:e([`w-5 h-5 flex-shrink-0 text-sidebar-muted`,r.collapsed?``:`mr-3`]),fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,"aria-hidden":`true`,innerHTML:A.value},null,10,I)),r.collapsed?t(``,!0):(o(),E(`span`,L,w(r.item.label),1))]),r.collapsed?t(``,!0):(o(),E(`svg`,{key:0,class:e([`w-4 h-4 text-sidebar-muted transition-transform duration-200`,{"rotate-180":c.value}]),"aria-hidden":`true`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,innerHTML:O.chevronDown},null,10,R))],10,P),r.collapsed?t(``,!0):i((o(),E(`ul`,z,[(o(!0),E(T,null,u(r.item.children,t=>(o(),E(`li`,{key:t.route},[n(l(y),{"data-menu-route":t.route,href:a.route(t.route),class:e([H,k(t)?U:W]),"aria-current":k(t)?`page`:void 0},{default:p(()=>[f(w(t.label),1)]),_:2},1032,[`data-menu-route`,`href`,`class`,`aria-current`])]))),128))],512)),[[v,c.value]])],64)):(o(),d(l(y),{key:1,"data-menu-route":r.item.route,href:a.route(r.item.route),class:e([H,b.value?U:W,r.collapsed?`justify-center`:``]),"aria-current":b.value?`page`:void 0,title:r.collapsed?r.item.label:``},{default:p(()=>[(o(),E(`svg`,{class:e([`w-5 h-5 flex-shrink-0`,[r.collapsed?``:`mr-3`,b.value?``:`text-sidebar-muted`]]),fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,"aria-hidden":`true`,innerHTML:A.value},null,10,B)),r.collapsed?t(``,!0):(o(),E(`span`,V,w(r.item.label),1))]),_:1},8,[`data-menu-route`,`href`,`class`,`aria-current`,`title`]))]))}},K={class:`h-16 flex items-center justify-between px-4 border-b border-sidebar-line`},q=[`src`,`alt`],J={key:1,class:`text-xl font-bold truncate`},Y={class:`flex-1 overflow-y-auto py-4 px-3`},ee={class:`space-y-1`},te={class:`lg:hidden border-t border-sidebar-line p-4`},ne={class:`flex items-center space-x-3`},re={class:`w-10 h-10 rounded-full bg-sidebar-active text-sidebar-active-fg flex items-center justify-center`},ie={class:`text-lg font-medium`},ae={key:0},oe={class:`text-sm font-medium`},se={class:`text-xs text-sidebar-muted`},ce={__name:`AdminSidebar`,props:{open:Boolean,collapsed:Boolean,menu:{type:Array,default:()=>[]},branding:{type:Object,default:()=>({})}},emits:[`close`],setup(r,{emit:i}){let a=x();return g(()=>a.url),(i,a)=>(o(),E(`aside`,{class:e([`fixed inset-y-0 left-0 z-50 flex flex-col bg-sidebar text-sidebar-fg border-r border-sidebar-line transform transition-transform duration-300 lg:translate-x-0`,[r.open?`translate-x-0`:`-translate-x-full`,r.collapsed?`lg:w-20`:`lg:w-64`,`w-64`]])},[D(`div`,K,[n(l(y),{href:i.route(`admin.dashboard`),"data-sidebar-brand":``,class:`flex min-w-0 items-center space-x-3 rounded-md focus:outline-none focus-visible:ring-2 focus-visible:ring-sidebar-accent`},{default:p(()=>[r.branding.logo?(o(),E(`img`,{key:0,src:r.branding.logo,alt:r.branding.name,class:`h-8 w-auto`},null,8,q)):t(``,!0),r.branding.logo&&!r.collapsed?(o(),E(`span`,J,w(r.branding.name||i.$t(`layout.brand_short`)),1)):t(``,!0),r.branding.logo?t(``,!0):(o(),d(A,{key:2,name:r.branding.name||`Atrium`,wordmark:!r.collapsed,size:28},null,8,[`name`,`wordmark`]))]),_:1},8,[`href`]),D(`button`,{onClick:a[0]||=e=>i.$emit(`close`),class:`lg:hidden p-2 rounded-md text-sidebar-muted hover:text-sidebar-fg hover:bg-sidebar-hover focus:outline-none focus-visible:ring-2 focus-visible:ring-sidebar-accent`},[...a[1]||=[D(`svg`,{class:`w-6 h-6`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`},[D(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M6 18L18 6M6 6l12 12`})],-1)]])]),D(`nav`,Y,[D(`ul`,ee,[(o(!0),E(T,null,u(r.menu,e=>(o(),d(G,{key:e.route,item:e,collapsed:r.collapsed},null,8,[`item`,`collapsed`]))),128))])]),D(`div`,te,[D(`div`,ne,[D(`div`,re,[D(`span`,ie,w(i.$page.props.auth?.user?.name?.charAt(0)||`A`),1)]),r.collapsed?t(``,!0):(o(),E(`div`,ae,[D(`p`,oe,w(i.$page.props.auth?.user?.name),1),D(`p`,se,w(i.$page.props.auth?.user?.email),1)]))])]),n(k,{on:`sidebar`,compact:r.collapsed,class:e([`border-t border-sidebar-line px-4 py-3`,r.collapsed?`lg:px-2 lg:text-center`:``])},null,8,[`compact`,`class`])],2))}},le=[`aria-expanded`],ue={class:`w-8 h-8 rounded-full bg-accent-soft flex items-center justify-center text-accent-soft-fg font-semibold`},de={class:`hidden md:block text-left`},fe={class:`text-sm font-medium text-fg`},pe={class:`text-xs text-muted`},me={key:0,class:`absolute right-0 mt-2 w-56 bg-surface rounded-lg shadow-lg border border-line py-1 z-50`},he={class:`px-4 py-3 border-b border-line`},ge={class:`text-sm font-medium text-fg`},_e={class:`text-xs text-muted truncate`},ve={class:`py-1`},ye=[`aria-label`],be={class:`px-4 pt-2 pb-1 text-xs font-semibold uppercase tracking-wide text-muted`},xe=[`aria-checked`,`data-theme-option`,`onClick`],Se=[`data-theme`],Ce={key:1,class:`flex h-4 w-6 flex-none overflow-hidden rounded-sm ring-1 ring-field`,"aria-hidden":`true`},we={class:`flex-1 text-left`},Te={key:2,class:`h-4 w-4 flex-none text-accent`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,"aria-hidden":`true`},Ee={class:`border-t border-line py-1`},De={__name:`AdminUserDropdown`,props:{user:{type:Object,default:()=>({})}},setup(i){let a=m(!1),s=m(null),d=()=>{a.value=!a.value},h=()=>{a.value=!1},v=x(),b=g(()=>v.props.themes||[]),S=g(()=>v.props.theme),O=e=>{N(e),C.put(route(`admin.profile.theme`),{theme:e},{preserveScroll:!0,preserveState:!0})},k=()=>{C.post(route(`admin.logout`))},A=e=>{s.value&&!s.value.contains(e.target)&&h()};return c(()=>{document.addEventListener(`click`,A)}),r(()=>{document.removeEventListener(`click`,A)}),(r,c)=>(o(),E(`div`,{ref_key:`dropdownRef`,ref:s,class:`relative`},[D(`button`,{"data-action":`user-menu`,onClick:d,"aria-expanded":a.value?`true`:`false`,class:`flex items-center gap-3 p-2 rounded-lg hover:bg-hover transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-focus`},[D(`div`,ue,w(i.user.name?.charAt(0)?.toUpperCase()||`A`),1),D(`div`,de,[D(`p`,fe,w(i.user.name),1),D(`p`,pe,w(i.user.email),1)]),c[0]||=D(`svg`,{class:`hidden sm:block w-4 h-4 text-muted`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`},[D(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M19 9l-7 7-7-7`})],-1)],8,le),n(_,{"enter-active-class":`transition ease-out duration-100`,"enter-from-class":`transform opacity-0 scale-95`,"enter-to-class":`transform opacity-100 scale-100`,"leave-active-class":`transition ease-in duration-75`,"leave-from-class":`transform opacity-100 scale-100`,"leave-to-class":`transform opacity-0 scale-95`},{default:p(()=>[a.value?(o(),E(`div`,me,[D(`div`,he,[D(`p`,ge,w(i.user.name),1),D(`p`,_e,w(i.user.email),1)]),D(`div`,ve,[n(l(y),{href:r.route(`admin.profile.edit`),class:`flex items-center px-4 py-2 text-sm text-fg hover:bg-hover`,onClick:h},{default:p(()=>[c[1]||=D(`svg`,{class:`w-4 h-4 mr-3 text-muted`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`},[D(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z`})],-1),f(` `+w(r.$t(`layout.user_menu.profile`)),1)]),_:1},8,[`href`])]),D(`div`,{class:`border-t border-line py-1`,role:`radiogroup`,"aria-label":r.$t(`layout.theme.label`)},[D(`p`,be,w(r.$t(`layout.theme.label`)),1),(o(!0),E(T,null,u(b.value,n=>(o(),E(`button`,{key:n,type:`button`,role:`radio`,"aria-checked":n===S.value?`true`:`false`,"data-theme-option":n,class:e([`flex items-center w-full gap-3 px-4 py-2 text-sm text-fg hover:bg-hover focus:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-focus`,n===S.value?`font-semibold`:``]),onClick:e=>O(n)},[n===`system`?(o(),E(`span`,Ce,[...c[3]||=[D(`span`,{"data-theme":`graphite`,class:`flex-1 bg-page`},null,-1),D(`span`,{"data-theme":`night`,class:`flex-1 bg-page`},null,-1)]])):(o(),E(`span`,{key:0,"data-theme":n,class:`flex h-4 w-6 flex-none overflow-hidden rounded-sm ring-1 ring-field`,"aria-hidden":`true`},[...c[2]||=[D(`span`,{class:`w-2 bg-sidebar`},null,-1),D(`span`,{class:`flex flex-1 items-center justify-center bg-page`},[D(`span`,{class:`h-1.5 w-1.5 rounded-full bg-accent`})],-1)]],8,Se)),D(`span`,we,w(r.$t(`layout.theme.${n}`)),1),n===S.value?(o(),E(`svg`,Te,[...c[4]||=[D(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2.5`,d:`M5 13l4 4L19 7`},null,-1)]])):t(``,!0)],10,xe))),128))],8,ye),D(`div`,Ee,[D(`button`,{"data-action":`logout`,onClick:k,class:`flex items-center w-full px-4 py-2 text-sm text-danger hover:bg-danger-soft`},[c[5]||=D(`svg`,{class:`w-4 h-4 mr-3`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`},[D(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M17 16l4-4m0 0l-4-4m4 4H7m6 4v1a3 3 0 01-3 3H6a3 3 0 01-3-3V7a3 3 0 013-3h4a3 3 0 013 3v1`})],-1),f(` `+w(r.$t(`layout.user_menu.logout`)),1)])])])):t(``,!0)]),_:1})],512))}},Oe={key:0,class:`relative flex min-w-0 items-center gap-1 rounded-lg px-1 py-1 text-muted hover:bg-hover hover:text-fg sm:gap-2 sm:px-2`},ke={class:`flex min-w-0 flex-col text-left leading-tight`,"aria-hidden":`true`},Ae={"data-switcher-caption":``,class:`truncate text-[11px] sm:text-xs`},je={class:`max-w-14 truncate text-sm font-medium text-fg sm:max-w-32 xl:max-w-48`},Me=[`aria-label`,`aria-description`,`title`,`value`],Ne=[`value`],Pe={__name:`SiteSwitcher`,setup(e){let n=x(),r=g(()=>n.props.sites||[]),i=g(()=>n.props.currentSite?.id),a=g(()=>n.props.currentSite?.name??``),s=e=>{C.post(route(`admin.site`),{site_id:e.target.value},{preserveScroll:!0,preserveState:!1})};return(e,n)=>r.value.length>1?(o(),E(`div`,Oe,[n[0]||=D(`svg`,{class:`h-5 w-5 shrink-0`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,"aria-hidden":`true`},[D(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M3 8.25V18a2.25 2.25 0 002.25 2.25h13.5A2.25 2.25 0 0021 18V8.25m-18 0V6a2.25 2.25 0 012.25-2.25h13.5A2.25 2.25 0 0121 6v2.25m-18 0h18M5.25 6h.008v.008H5.25V6zm2.25 0h.008v.008H7.5V6zm2.25 0h.008v.008H9.75V6z`})],-1),D(`span`,ke,[D(`span`,Ae,w(e.$t(`layout.site`)),1),D(`span`,je,w(a.value),1)]),n[1]||=D(`svg`,{class:`hidden h-4 w-4 shrink-0 sm:block`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,"aria-hidden":`true`},[D(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M19 9l-7 7-7-7`})],-1),D(`select`,{"data-site-switcher":``,name:`site_id`,"aria-label":e.$t(`layout.site`),"aria-description":e.$t(`layout.site_hint`),title:e.$t(`layout.site_hint`),value:i.value,class:`absolute inset-0 h-full w-full cursor-pointer appearance-none rounded-lg bg-transparent text-transparent focus:outline-none focus-visible:ring-2 focus-visible:ring-focus`,onChange:s},[(o(!0),E(T,null,u(r.value,e=>(o(),E(`option`,{key:e.id,value:e.id,class:`bg-surface text-fg`},w(e.name),9,Ne))),128))],40,Me)])):t(``,!0)}},Fe={class:`sticky top-0 z-30 transform-gpu h-16 bg-surface border-b border-line flex items-center justify-between gap-1 px-3 sm:gap-2 sm:px-4 lg:px-6`},Ie={class:`flex shrink-0 items-center gap-1 sm:gap-4`},Le=[`href`,`title`],Re={class:`hidden sm:inline`},ze={class:`flex min-w-0 items-center gap-1 sm:gap-2 lg:gap-3`},Be={__name:`AdminHeader`,props:{user:{type:Object,default:()=>({})},branding:{type:Object,default:()=>({})}},emits:[`toggle-sidebar`,`toggle-collapse`],setup(e,{emit:t}){return(t,r)=>(o(),E(`header`,Fe,[D(`div`,Ie,[D(`button`,{onClick:r[0]||=e=>t.$emit(`toggle-sidebar`),class:`lg:hidden p-2 rounded-md text-muted hover:text-fg hover:bg-hover`},[...r[2]||=[D(`svg`,{class:`w-6 h-6`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`},[D(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M4 6h16M4 12h16M4 18h16`})],-1)]]),D(`button`,{"data-action":`collapse-sidebar`,onClick:r[1]||=e=>t.$emit(`toggle-collapse`),class:`hidden lg:block p-2 rounded-md text-muted hover:text-fg hover:bg-hover`},[...r[3]||=[D(`svg`,{class:`w-5 h-5`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`},[D(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M4 6h16M4 12h8m-8 6h16`})],-1)]]),D(`a`,{"data-action":`visit-site`,href:t.$page.props.currentSite?.url||`/`,target:`_blank`,rel:`noopener`,class:`flex items-center gap-2 rounded-md px-2 py-2 text-sm text-muted hover:bg-hover hover:text-fg`,title:t.$t(`layout.visit_site_hint`)},[r[4]||=D(`svg`,{class:`w-5 h-5`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`},[D(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M21 12a9 9 0 11-18 0 9 9 0 0118 0zM3.6 9h16.8M3.6 15h16.8M12 3a15 15 0 010 18M12 3a15 15 0 000 18`})],-1),D(`span`,Re,w(t.$t(`layout.visit_site`)),1)],8,Le)]),D(`div`,ze,[n(Pe),n(j),n(De,{user:e.user},null,8,[`user`])])]))}};function X(){return M(`fields.upload.session_expired`)}function Ve(e){let t=document.cookie.match(RegExp(`(?:^|;\\s*)`+e+`=([^;]*)`));if(!t)return null;try{return decodeURIComponent(t[1])}catch{return t[1]}}function He(){let e=Ve(`XSRF-TOKEN`);if(e)return{"X-XSRF-TOKEN":e};let t=document.querySelector(`meta[name="csrf-token"]`)?.getAttribute(`content`);return t?{"X-CSRF-TOKEN":t}:{}}function Z(e={}){return{Accept:`application/json`,"X-Requested-With":`XMLHttpRequest`,...He(),...e}}async function Q(e,t=M(`fields.upload.request_failed`)){return e.status===419?X():e.status===413?M(`fields.upload.too_large`):(await e.json().catch(()=>({}))).message||t}var Ue=(e,t)=>{let n=e.__vccOpts||e;for(let[e,r]of t)n[e]=r;return n},We=[`aria-label`],Ge={class:`flex items-center justify-between gap-2 border-b border-line px-4 py-2.5`},Ke={class:`text-sm font-semibold`},qe={class:`flex items-center gap-3 text-xs`},Je=[`aria-label`],Ye={class:`rounded-lg bg-surface-alt px-3 py-2`},Xe={key:0,class:`max-w-[85%] whitespace-pre-wrap rounded-lg bg-accent-soft px-3 py-2 text-accent-soft-fg`,dusk:`ai-question`},Ze=[`dusk`,`innerHTML`],Qe={key:0,class:`text-muted`,dusk:`ai-thinking`},$e={class:`flex items-end gap-2`},et=[`placeholder`,`aria-label`],tt=[`disabled`],$={class:`mt-2 text-xs text-muted`},nt=[`aria-label`,`aria-expanded`,`title`],rt={viewBox:`0 0 48 52`,class:`h-full w-full overflow-visible`,"aria-hidden":`true`},it={class:`ai-mascot-body`},at={class:`ai-mascot-eyes`},ot=[`cx`,`cy`],st=[`cx`,`cy`],ct=Ue({__name:`AiHelper`,setup(n){let l=x(),d=g(()=>l.props.ai?.help||null),f=g(()=>d.value?.labels||{}),p=g(()=>l.props.ai?.url||``),_=g(()=>`atrium-ai-help:${l.props.auth?.user?.id??``}`),v=m(!1),y=m(!1),S=m(``),O=m([]),k=m(null),A=m(null),j=m({x:0,y:0}),M=m(null),N=null,P=0;c(()=>{try{O.value=JSON.parse(sessionStorage.getItem(_.value)||`[]`)}catch{O.value=[]}window.addEventListener(`pointermove`,F)}),r(()=>{I(),window.removeEventListener(`pointermove`,F)}),a(O,e=>{try{sessionStorage.setItem(_.value,JSON.stringify(e.slice(-20)))}catch{}},{deep:!0});function F(e){let t=M.value?.getBoundingClientRect();if(!t)return;let n=e.clientX-(t.left+t.width/2),r=e.clientY-(t.top+t.height/3),i=Math.hypot(n,r)||1;j.value={x:n/i*.9,y:r/i*.9}}function I(){clearTimeout(N),N=null,P++}async function L(){v.value=!v.value,v.value&&(await s(),z(),A.value?.focus())}function R(){I(),y.value=!1,O.value=[],A.value?.focus()}async function z(){await s(),k.value&&(k.value.scrollTop=k.value.scrollHeight)}async function B(){let e=S.value.trim();if(e===``||y.value)return;let t=O.value.filter(e=>!e.error).slice(-10).map(({role:e,text:t})=>({role:e,text:t}));O.value.push({role:`user`,text:e}),S.value=``,y.value=!0,z(),I();let n=P;try{let r=await fetch(d.value.url,{method:`POST`,credentials:`same-origin`,headers:Z({"Content-Type":`application/json`}),body:JSON.stringify({question:e,history:t})});if(!r.ok)throw Error(await Q(r,f.value.error));V(await r.json(),n)}catch(e){n===P&&U(e.message)}}function V(e,t){t===P&&(e.status===`done`?(y.value=!1,O.value.push({role:`assistant`,text:e.value||``}),z()):e.status===`failed`?U(e.message):N=setTimeout(()=>H(e.id,t),1500))}async function H(e,t){try{let n=await fetch(`${p.value}/${e}`,{credentials:`same-origin`,headers:Z()});if(!n.ok)throw Error(await Q(n,f.value.error));V(await n.json(),t)}catch(e){t===P&&U(e.message)}}function U(e){y.value=!1,O.value.push({role:`assistant`,text:e||f.value.error,error:!0}),z()}function W(e){e.key===`Enter`&&!e.shiftKey&&!e.isComposing&&(e.preventDefault(),B())}let G={"&":`&`,"<":`<`,">":`>`,'"':`"`,"'":`'`},K=e=>String(e).replace(/[&<>"']/g,e=>G[e]);function q(e){let t=e=>K(e).replace(/\*\*(.+?)\*\*/g,`$1`).replace(/\[([^\]]+)\]\(([^)\s]+)\)/g,(e,t,n)=>n.startsWith(`/`)&&!n.startsWith(`//`)?`${t}`:t),n=[],r=[],i=()=>{r.length&&(n.push(`
    ${r.map(e=>`
  • ${e}
  • `).join(``)}
`),r=[])};for(let a of String(e).split(/\r?\n/)){let e=a.match(/^\s*[-*]\s+(.*)$/);e?r.push(t(e[1])):(i(),a.trim()!==``&&n.push(`

${t(a)}

`))}return i(),n.join(``)}function J(e){let t=e.target.closest?.(`a[data-ai-link]`);t&&(e.preventDefault(),C.visit(t.getAttribute(`href`)))}function Y(e){e.key===`Escape`&&v.value&&(v.value=!1)}return(n,r)=>d.value?(o(),E(`div`,{key:0,class:`fixed bottom-4 right-4 z-40 flex flex-col items-end gap-3`,dusk:`ai-helper`,onKeydown:Y},[v.value?(o(),E(`section`,{key:0,class:`flex w-[22rem] max-w-[calc(100vw-2rem)] max-h-[min(36rem,calc(100vh-8rem))] flex-col rounded-lg border border-line bg-surface text-fg shadow-xl`,role:`dialog`,"aria-label":f.value.title,dusk:`ai-chat`},[D(`header`,Ge,[D(`h2`,Ke,w(f.value.title),1),D(`div`,qe,[O.value.length?(o(),E(`button`,{key:0,type:`button`,class:`text-muted hover:text-fg`,dusk:`ai-clear`,onClick:R},w(f.value.clear),1)):t(``,!0),D(`button`,{type:`button`,class:`text-muted hover:text-fg`,"aria-label":f.value.close,dusk:`ai-close`,onClick:r[0]||=e=>v.value=!1},[...r[2]||=[D(`svg`,{class:`h-4 w-4`,viewBox:`0 0 20 20`,fill:`currentColor`,"aria-hidden":`true`},[D(`path`,{d:`M5.3 4.3 10 9l4.7-4.7 1 1L11 10l4.7 4.7-1 1L10 11l-4.7 4.7-1-1L9 10 4.3 5.3z`})],-1)]],8,Je)])]),D(`div`,{ref_key:`list`,ref:k,class:`flex-1 space-y-3 overflow-y-auto px-4 py-3 text-sm`,"aria-live":`polite`,onClick:J},[D(`p`,Ye,w(f.value.hello),1),(o(!0),E(T,null,u(O.value,(t,n)=>(o(),E(`div`,{key:n,class:e([`flex`,t.role===`user`?`justify-end`:`justify-start`])},[t.role===`user`?(o(),E(`p`,Xe,w(t.text),1)):(o(),E(`div`,{key:1,class:e([`max-w-[90%] space-y-2 rounded-lg px-3 py-2`,t.error?`border border-danger bg-danger-soft text-danger-soft-fg`:`bg-surface-alt`]),dusk:t.error?`ai-error`:`ai-answer`,innerHTML:q(t.text)},null,10,Ze))],2))),128)),y.value?(o(),E(`p`,Qe,w(f.value.thinking),1)):t(``,!0)],512),D(`form`,{class:`border-t border-line p-3`,onSubmit:h(B,[`prevent`])},[D(`div`,$e,[i(D(`textarea`,{ref_key:`input`,ref:A,"onUpdate:modelValue":r[1]||=e=>S.value=e,rows:`2`,maxlength:`2000`,class:`flex-1 resize-none rounded-md border border-field bg-surface px-3 py-2 text-sm text-fg focus:border-focus focus:outline-none focus:ring-1 focus:ring-focus`,placeholder:f.value.placeholder,"aria-label":f.value.placeholder,dusk:`ai-input`,onKeydown:W},null,40,et),[[b,S.value]]),D(`button`,{type:`submit`,class:`rounded-md bg-accent px-3 py-2 text-sm font-medium text-on-accent hover:bg-accent-hover disabled:opacity-50`,disabled:y.value||S.value.trim()===``,dusk:`ai-send`},w(f.value.send),9,tt)]),D(`p`,$,w(f.value.note),1)],32)],8,We)):t(``,!0),D(`button`,{ref_key:`mascot`,ref:M,type:`button`,class:e([`ai-mascot group relative h-16 w-16 rounded-full focus:outline-none focus-visible:ring-2 focus-visible:ring-focus`,{"is-thinking":y.value,"is-open":v.value}]),"aria-label":f.value.open,"aria-expanded":v.value,title:f.value.open,dusk:`ai-mascot`,onClick:L},[(o(),E(`svg`,rt,[r[9]||=D(`ellipse`,{class:`ai-mascot-shadow fill-fg`,cx:`24`,cy:`49`,rx:`15`,ry:`2.2`,opacity:`0.15`},null,-1),D(`g`,it,[r[5]||=D(`path`,{class:`fill-fg`,d:`M6 42V22a18 18 0 0 1 36 0v20H32V22a8 8 0 0 0-16 0v20z`},null,-1),r[6]||=D(`rect`,{class:`ai-mascot-belt fill-accent`,x:`16`,y:`28`,width:`16`,height:`5`},null,-1),r[7]||=D(`rect`,{class:`fill-fg`,x:`4`,y:`41`,width:`13`,height:`3.5`,rx:`1.75`},null,-1),r[8]||=D(`rect`,{class:`fill-fg`,x:`31`,y:`41`,width:`13`,height:`3.5`,rx:`1.75`},null,-1),D(`g`,at,[r[3]||=D(`circle`,{class:`fill-surface`,cx:`19`,cy:`10.5`,r:`3`},null,-1),r[4]||=D(`circle`,{class:`fill-surface`,cx:`29`,cy:`10.5`,r:`3`},null,-1),D(`circle`,{class:`fill-fg`,cx:19+j.value.x,cy:10.5+j.value.y,r:`1.4`},null,8,ot),D(`circle`,{class:`fill-fg`,cx:29+j.value.x,cy:10.5+j.value.y,r:`1.4`},null,8,st)])])]))],10,nt)],32)):t(``,!0)}},[[`__scopeId`,`data-v-6928fa25`]]),lt={class:`min-h-screen bg-page`},ut={"data-page-content":`true`,class:`p-4 lg:p-6`},dt={key:0,"data-flash":`success`,class:`mb-4 p-4 bg-success-soft border border-success text-success-soft-fg rounded`},ft={key:1,"data-flash":`error`,class:`mb-4 p-4 bg-danger-soft border border-danger text-danger-soft-fg rounded`},pt={__name:`AdminLayout`,props:{title:{type:String,default:``}},setup(r){let i=x(),a=m(!1),s=m(!1),c=g(()=>i.props.branding||{}),u=g(()=>i.props.menu||[]),d=g(()=>i.props.auth?.user||{}),f=()=>{a.value=!a.value},p=()=>{s.value=!s.value},h=()=>{a.value=!1};return(i,m)=>(o(),E(T,null,[n(l(S),{title:r.title||``},null,8,[`title`]),D(`div`,lt,[a.value?(o(),E(`div`,{key:0,class:`fixed inset-0 z-40 bg-black/50 lg:hidden`,onClick:h})):t(``,!0),n(ce,{open:a.value,collapsed:s.value,menu:u.value,branding:c.value,onClose:h},null,8,[`open`,`collapsed`,`menu`,`branding`]),D(`div`,{class:e([`transition-all duration-300`,s.value?`lg:pl-20`:`lg:pl-64`])},[n(Be,{user:d.value,branding:c.value,onToggleSidebar:f,onToggleCollapse:p},null,8,[`user`,`branding`]),D(`main`,ut,[i.$page.props.flash?.success?(o(),E(`div`,dt,w(i.$page.props.flash.success),1)):t(``,!0),i.$page.props.flash?.error?(o(),E(`div`,ft,w(i.$page.props.flash.error),1)):t(``,!0),O(i.$slots,`default`)])],2),n(ct)])],64))}};export{X as i,Z as n,Q as r,pt as t}; \ No newline at end of file diff --git a/packages/admin/dist/assets/AdminModal-DNJ_V4iq.js b/packages/admin/dist/assets/AdminModal-DKazeNNa.js similarity index 62% rename from packages/admin/dist/assets/AdminModal-DNJ_V4iq.js rename to packages/admin/dist/assets/AdminModal-DKazeNNa.js index 717bcf40..3ee85084 100644 --- a/packages/admin/dist/assets/AdminModal-DNJ_V4iq.js +++ b/packages/admin/dist/assets/AdminModal-DKazeNNa.js @@ -1 +1 @@ -import{C as e,E as t,H as n,I as r,Q as i,S as a,W as o,c as s,et as c,w as l,x as u,y as d,z as f}from"./dist-MY__znoP.js";var p={key:0,"data-modal":`true`,class:`fixed inset-0 z-50 overflow-y-auto`},m={class:`flex min-h-full items-center justify-center p-4`},h={key:0,class:`px-6 py-4 border-b border-line`},g={class:`text-lg font-medium text-fg`},_={class:`p-6`},v={key:1,class:`px-6 py-4 border-t border-line bg-surface-alt flex justify-end space-x-3`},y={__name:`AdminModal`,props:{show:Boolean,maxWidth:{type:String,default:`md`},closeable:{type:Boolean,default:!0},title:String},emits:[`close`],setup(y,{emit:b}){let x=y,S=b,C=()=>{x.closeable&&S(`close`)},w={sm:`sm:max-w-sm`,md:`sm:max-w-md`,lg:`sm:max-w-lg`,xl:`sm:max-w-xl`,"2xl":`sm:max-w-2xl`};return n(()=>x.show,e=>{e?document.body.style.overflow=`hidden`:document.body.style.overflow=``}),(n,b)=>(r(),a(d,{to:`body`},[t(s,{"enter-active-class":`ease-out duration-300`,"enter-from-class":`opacity-0`,"enter-to-class":`opacity-100`,"leave-active-class":`ease-in duration-200`,"leave-from-class":`opacity-100`,"leave-to-class":`opacity-0`},{default:o(()=>[y.show?(r(),l(`div`,p,[u(`div`,{class:`fixed inset-0 bg-black/50 transition-opacity`,onClick:C}),u(`div`,m,[t(s,{"enter-active-class":`ease-out duration-300`,"enter-from-class":`opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95`,"enter-to-class":`opacity-100 translate-y-0 sm:scale-100`,"leave-active-class":`ease-in duration-200`,"leave-from-class":`opacity-100 translate-y-0 sm:scale-100`,"leave-to-class":`opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95`},{default:o(()=>[y.show?(r(),l(`div`,{key:0,class:i([`relative transform overflow-hidden rounded-lg bg-surface shadow-xl transition-all sm:my-8 sm:w-full`,w[y.maxWidth]])},[y.title||n.$slots.header?(r(),l(`div`,h,[f(n.$slots,`header`,{},()=>[u(`h3`,g,c(y.title),1)]),y.closeable?(r(),l(`button`,{key:0,onClick:C,class:`absolute top-4 right-4 text-muted hover:text-fg`},[...b[0]||=[u(`svg`,{class:`h-5 w-5`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`},[u(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M6 18L18 6M6 6l12 12`})],-1)]])):e(``,!0)])):e(``,!0),u(`div`,_,[f(n.$slots,`default`)]),n.$slots.footer?(r(),l(`div`,v,[f(n.$slots,`footer`)])):e(``,!0)],2)):e(``,!0)]),_:3})])])):e(``,!0)]),_:3})]))}};export{y as t}; \ No newline at end of file +import{$ as e,C as t,E as n,H as r,I as i,S as a,W as o,c as s,tt as c,w as l,x as u,y as d,z as f}from"./dist-Bie52OmN.js";var p={key:0,"data-modal":`true`,class:`fixed inset-0 z-50 overflow-y-auto`},m={class:`flex min-h-full items-center justify-center p-4`},h={key:0,class:`px-6 py-4 border-b border-line`},g={class:`text-lg font-medium text-fg`},_={class:`p-6`},v={key:1,class:`px-6 py-4 border-t border-line bg-surface-alt flex justify-end space-x-3`},y={__name:`AdminModal`,props:{show:Boolean,maxWidth:{type:String,default:`md`},closeable:{type:Boolean,default:!0},title:String},emits:[`close`],setup(y,{emit:b}){let x=y,S=b,C=()=>{x.closeable&&S(`close`)},w={sm:`sm:max-w-sm`,md:`sm:max-w-md`,lg:`sm:max-w-lg`,xl:`sm:max-w-xl`,"2xl":`sm:max-w-2xl`};return r(()=>x.show,e=>{e?document.body.style.overflow=`hidden`:document.body.style.overflow=``}),(r,b)=>(i(),a(d,{to:`body`},[n(s,{"enter-active-class":`ease-out duration-300`,"enter-from-class":`opacity-0`,"enter-to-class":`opacity-100`,"leave-active-class":`ease-in duration-200`,"leave-from-class":`opacity-100`,"leave-to-class":`opacity-0`},{default:o(()=>[y.show?(i(),l(`div`,p,[u(`div`,{class:`fixed inset-0 bg-black/50 transition-opacity`,onClick:C}),u(`div`,m,[n(s,{"enter-active-class":`ease-out duration-300`,"enter-from-class":`opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95`,"enter-to-class":`opacity-100 translate-y-0 sm:scale-100`,"leave-active-class":`ease-in duration-200`,"leave-from-class":`opacity-100 translate-y-0 sm:scale-100`,"leave-to-class":`opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95`},{default:o(()=>[y.show?(i(),l(`div`,{key:0,class:e([`relative transform overflow-hidden rounded-lg bg-surface shadow-xl transition-all sm:my-8 sm:w-full`,w[y.maxWidth]])},[y.title||r.$slots.header?(i(),l(`div`,h,[f(r.$slots,`header`,{},()=>[u(`h3`,g,c(y.title),1)]),y.closeable?(i(),l(`button`,{key:0,onClick:C,class:`absolute top-4 right-4 text-muted hover:text-fg`},[...b[0]||=[u(`svg`,{class:`h-5 w-5`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`},[u(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M6 18L18 6M6 6l12 12`})],-1)]])):t(``,!0)])):t(``,!0),u(`div`,_,[f(r.$slots,`default`)]),r.$slots.footer?(i(),l(`div`,v,[f(r.$slots,`footer`)])):t(``,!0)],2)):t(``,!0)]),_:3})])])):t(``,!0)]),_:3})]))}};export{y as t}; \ No newline at end of file diff --git a/packages/admin/dist/assets/AdminPagination-D7rwNfhd.js b/packages/admin/dist/assets/AdminPagination-D7rwNfhd.js new file mode 100644 index 00000000..27ba5a53 --- /dev/null +++ b/packages/admin/dist/assets/AdminPagination-D7rwNfhd.js @@ -0,0 +1 @@ +import{$ as e,I as t,Q as n,R as r,S as i,T as a,W as o,b as s,i as c,tt as l,v as u,w as d,x as f}from"./dist-Bie52OmN.js";var p={class:`bg-surface px-4 py-3 border-t border-line sm:px-6`},m={class:`flex items-center justify-between`},h={class:`text-sm text-fg`},g={class:`inline-flex -space-x-px rounded-md shadow-sm`},_={key:1,class:`relative inline-flex items-center rounded-l-md px-2 py-2 text-muted ring-1 ring-inset ring-field`},v={key:0,class:`relative inline-flex items-center px-4 py-2 text-sm font-semibold text-fg ring-1 ring-inset ring-field`},y={key:3,class:`relative inline-flex items-center rounded-r-md px-2 py-2 text-muted ring-1 ring-inset ring-field`},b={__name:`AdminPagination`,props:{paginator:{type:Object,required:!0}},setup(b){let x=b,S=s(()=>{let e=x.paginator.current_page,t=x.paginator.last_page,n=[],r=[];for(let r=1;r<=t;r++)(r===1||r===t||r>=e-2&&r<=e+2)&&n.push(r);let i=null;for(let e of n)i&&(e-i===2?r.push(i+1):e-i!==1&&r.push(`...`)),r.push(e),i=e;return r});return(s,x)=>(t(),d(`div`,p,[f(`div`,m,[f(`div`,h,l(s.$t(`resource.pagination.showing`,{from:b.paginator.from,to:b.paginator.to,total:b.paginator.total})),1),f(`nav`,g,[b.paginator.prev_page_url?(t(),i(n(c),{key:0,href:b.paginator.prev_page_url,class:`relative inline-flex items-center rounded-l-md px-2 py-2 text-muted ring-1 ring-inset ring-field hover:bg-hover`,"preserve-scroll":``},{default:o(()=>[...x[0]||=[f(`svg`,{class:`h-5 w-5`,viewBox:`0 0 20 20`,fill:`currentColor`},[f(`path`,{"fill-rule":`evenodd`,d:`M12.79 5.23a.75.75 0 01-.02 1.06L8.832 10l3.938 3.71a.75.75 0 11-1.04 1.08l-4.5-4.25a.75.75 0 010-1.08l4.5-4.25a.75.75 0 011.06.02z`,"clip-rule":`evenodd`})],-1)]]),_:1},8,[`href`])):(t(),d(`span`,_,[...x[1]||=[f(`svg`,{class:`h-5 w-5`,viewBox:`0 0 20 20`,fill:`currentColor`},[f(`path`,{"fill-rule":`evenodd`,d:`M12.79 5.23a.75.75 0 01-.02 1.06L8.832 10l3.938 3.71a.75.75 0 11-1.04 1.08l-4.5-4.25a.75.75 0 010-1.08l4.5-4.25a.75.75 0 011.06.02z`,"clip-rule":`evenodd`})],-1)]])),(t(!0),d(u,null,r(S.value,r=>(t(),d(u,{key:r},[r===`...`?(t(),d(`span`,v,` ... `)):(t(),i(n(c),{key:1,href:`${b.paginator.path}?page=${r}`,class:e([`relative inline-flex items-center px-4 py-2 text-sm font-semibold ring-1 ring-inset ring-field`,r===b.paginator.current_page?`z-10 bg-accent text-on-accent focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus`:`text-fg hover:bg-hover`]),"preserve-scroll":``},{default:o(()=>[a(l(r),1)]),_:2},1032,[`href`,`class`]))],64))),128)),b.paginator.next_page_url?(t(),i(n(c),{key:2,href:b.paginator.next_page_url,class:`relative inline-flex items-center rounded-r-md px-2 py-2 text-muted ring-1 ring-inset ring-field hover:bg-hover`,"preserve-scroll":``},{default:o(()=>[...x[2]||=[f(`svg`,{class:`h-5 w-5`,viewBox:`0 0 20 20`,fill:`currentColor`},[f(`path`,{"fill-rule":`evenodd`,d:`M7.21 14.77a.75.75 0 01.02-1.06L11.168 10 7.23 6.29a.75.75 0 111.04-1.08l4.5 4.25a.75.75 0 010 1.08l-4.5 4.25a.75.75 0 01-1.06-.02z`,"clip-rule":`evenodd`})],-1)]]),_:1},8,[`href`])):(t(),d(`span`,y,[...x[3]||=[f(`svg`,{class:`h-5 w-5`,viewBox:`0 0 20 20`,fill:`currentColor`},[f(`path`,{"fill-rule":`evenodd`,d:`M7.21 14.77a.75.75 0 01.02-1.06L11.168 10 7.23 6.29a.75.75 0 111.04-1.08l4.5 4.25a.75.75 0 010 1.08l-4.5 4.25a.75.75 0 01-1.06-.02z`,"clip-rule":`evenodd`})],-1)]]))])])]))}};export{b as t}; \ No newline at end of file diff --git a/packages/admin/dist/assets/BarChart-wks0RLo_.js b/packages/admin/dist/assets/BarChart-wks0RLo_.js new file mode 100644 index 00000000..f561b188 --- /dev/null +++ b/packages/admin/dist/assets/BarChart-wks0RLo_.js @@ -0,0 +1 @@ +import{C as e,I as t,R as n,b as r,et as i,o as a,tt as o,v as s,w as c,x as l}from"./dist-Bie52OmN.js";var u=[`aria-label`],d=[`title`],f={key:0,class:`mb-0.5 text-[10px] leading-none text-fg tabular-nums`,"data-bar-value":``},p={class:`mt-1 flex gap-px`,"aria-hidden":`true`},m={class:`sr-only`},h={key:0},g={scope:`row`},_=14,v={__name:`BarChart`,props:{points:{type:Array,required:!0},every:{type:Number,default:1},label:{type:String,default:``},height:{type:Number,default:96}},setup(v){let y=v,b=a(),x=r(()=>new Intl.NumberFormat(String(b.props.locale||`en`).replace(`_`,`-`),{notation:`compact`})),S=r(()=>Math.max(1,...y.points.map(e=>Number(e.value)||0)));function C(e){return e>0?`${Math.max(2,e/S.value*(y.height-_))}px`:`0px`}return(r,a)=>(t(),c(`figure`,{class:`w-full`,"aria-label":v.label,dusk:`bar-chart`},[l(`div`,{class:`flex items-end gap-px`,style:i({height:`${v.height}px`}),"aria-hidden":`true`},[(t(!0),c(s,null,n(v.points,(n,r)=>(t(),c(`div`,{key:r,class:`flex-1 min-w-0 h-full flex flex-col items-center justify-end`,title:`${n.label}: ${n.value}`,"data-bar":``},[n.value>0?(t(),c(`span`,f,o(x.value.format(n.value)),1)):e(``,!0),l(`div`,{class:`w-full rounded-t-sm bg-accent`,style:i({height:C(n.value)})},null,4)],8,d))),128))],4),a[0]||=l(`div`,{class:`h-px bg-field`,"aria-hidden":`true`},null,-1),l(`div`,p,[(t(!0),c(s,null,n(v.points,(e,n)=>(t(),c(`span`,{key:n,class:`flex-1 min-w-0 text-[10px] text-muted tabular-nums whitespace-nowrap`},o(n%v.every===0?e.label:``),1))),128))]),l(`table`,m,[v.label?(t(),c(`caption`,h,o(v.label),1)):e(``,!0),l(`tbody`,null,[(t(!0),c(s,null,n(v.points,(e,n)=>(t(),c(`tr`,{key:n},[l(`th`,g,o(e.label),1),l(`td`,null,o(e.value),1)]))),128))])])],8,u))}};export{v as t}; \ No newline at end of file diff --git a/packages/admin/dist/assets/ContentLocaleSwitcher-BJIieXK-.js b/packages/admin/dist/assets/ContentLocaleSwitcher-HJzbB87a.js similarity index 59% rename from packages/admin/dist/assets/ContentLocaleSwitcher-BJIieXK-.js rename to packages/admin/dist/assets/ContentLocaleSwitcher-HJzbB87a.js index b3a342e0..b0197cf3 100644 --- a/packages/admin/dist/assets/ContentLocaleSwitcher-BJIieXK-.js +++ b/packages/admin/dist/assets/ContentLocaleSwitcher-HJzbB87a.js @@ -1 +1 @@ -import{C as e,G as t,H as n,I as r,Q as i,R as a,T as o,Y as s,b as c,et as l,h as u,v as d,w as f,x as p,z as m}from"./dist-MY__znoP.js";var h={class:`admin-tabs`},g={class:`border-b border-line`},_=[`aria-label`],v=[`data-tab`,`data-tab-active`,`onClick`],y=[`innerHTML`],b=[`data-tab-badge`],x={class:`mt-6`},S={__name:`AdminTabs`,props:{tabs:{type:Array,required:!0,default:()=>[]},modelValue:{type:String,default:``}},emits:[`update:modelValue`],setup(t,{emit:n}){let s=t,u=n,S=c({get:()=>s.modelValue||s.tabs[0]?.name||``,set:e=>u(`update:modelValue`,e)}),C={"document-text":``,search:``,cog:``,collection:``,puzzle:``,folder:``},w=e=>C[e]||C[`document-text`];return(n,s)=>(r(),f(`div`,h,[p(`div`,g,[p(`nav`,{class:`-mb-px flex space-x-8`,"aria-label":n.$t(`fields.tabs.label`)},[(r(!0),f(d,null,a(t.tabs,t=>(r(),f(`button`,{key:t.name,type:`button`,"data-tab":t.name,"data-tab-active":S.value===t.name?`true`:`false`,onClick:e=>S.value=t.name,class:i([S.value===t.name?`border-focus text-accent`:`border-transparent text-muted hover:text-fg hover:border-field`,`group inline-flex items-center py-4 px-1 border-b-2 font-medium text-sm whitespace-nowrap transition-colors duration-150`])},[t.icon?(r(),f(`svg`,{key:0,class:i([S.value===t.name?`text-accent`:`text-muted group-hover:text-fg`,`-ml-0.5 mr-2 h-5 w-5 transition-colors duration-150`]),xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,innerHTML:w(t.icon)},null,10,y)):e(``,!0),o(` `+l(t.label)+` `,1),t.badge?(r(),f(`span`,{key:1,"data-tab-badge":t.name,class:i([S.value===t.name?`bg-accent-soft text-accent`:`bg-danger-soft text-danger`,`ml-2 py-0.5 px-2 rounded-full text-xs font-medium`])},l(t.badge),11,b)):e(``,!0)],10,v))),128))],8,_)]),p(`div`,x,[m(n.$slots,`default`,{activeTab:S.value})])]))}},C=[`data-tab-panel`,`data-tab-active`],w={__name:`AdminTabPanel`,props:{name:{type:String,required:!0},activeTab:{type:String,required:!0},lazy:{type:Boolean,default:!1}},setup(a){let o=a,l=c(()=>o.activeTab===o.name),d=s(!1);n(l,e=>{e&&(d.value=!0)},{immediate:!0});let p=c(()=>!o.lazy||d.value);return(n,o)=>p.value?t((r(),f(`div`,{key:0,class:i([`admin-tab-panel`,{"is-active":l.value}]),"data-tab-panel":a.name,"data-tab-active":l.value?`true`:`false`,role:`tabpanel`},[m(n.$slots,`default`)],10,C)),[[u,l.value]]):e(``,!0)}},T=[`aria-label`],E={class:`text-sm text-muted mr-1`},D=[`data-content-locale`,`aria-pressed`,`onClick`],O={key:0,class:`inline-flex items-center justify-center min-w-5 h-5 px-1 text-xs font-semibold rounded-full bg-danger-hover text-on-danger`},k={__name:`ContentLocaleSwitcher`,props:{modelValue:{type:String,default:null},locales:{type:Array,required:!0},fields:{type:Array,required:!0},errors:{type:Object,default:()=>({})}},emits:[`update:modelValue`],setup(t,{emit:n}){let s=t,u=n,m=c(()=>s.fields.filter(e=>e.translatable).map(e=>e.name));function h(e){return Object.keys(s.errors).filter(t=>m.value.some(n=>t===`${n}.${e}`)).length}return(n,s)=>(r(),f(`div`,{class:`flex flex-wrap items-center gap-2 mb-6`,role:`group`,"aria-label":n.$t(`languages.switch`)},[p(`span`,E,l(n.$t(`languages.switch`))+`:`,1),(r(!0),f(d,null,a(t.locales,n=>(r(),f(`button`,{key:n.code,type:`button`,"data-content-locale":n.code,"aria-pressed":t.modelValue===n.code?`true`:`false`,class:i([`inline-flex items-center gap-1.5 px-3 py-1.5 text-sm rounded-md border transition-colors`,t.modelValue===n.code?`bg-accent-hover border-accent-hover text-on-accent`:`bg-surface border-field text-fg hover:bg-hover`]),onClick:e=>u(`update:modelValue`,n.code)},[o(l(n.name)+` `,1),h(n.code)>0?(r(),f(`span`,O,l(h(n.code)),1)):e(``,!0)],10,D))),128))],8,T))}};export{w as n,S as r,k as t}; \ No newline at end of file +import{$ as e,C as t,G as n,H as r,I as i,R as a,T as o,X as s,b as c,h as l,tt as u,v as d,w as f,x as p,z as m}from"./dist-Bie52OmN.js";var h={class:`admin-tabs`},g={class:`border-b border-line`},_=[`aria-label`],v=[`data-tab`,`data-tab-active`,`onClick`],y=[`innerHTML`],b=[`data-tab-badge`],x={class:`mt-6`},S={__name:`AdminTabs`,props:{tabs:{type:Array,required:!0,default:()=>[]},modelValue:{type:String,default:``}},emits:[`update:modelValue`],setup(n,{emit:r}){let s=n,l=r,S=c({get:()=>s.modelValue||s.tabs[0]?.name||``,set:e=>l(`update:modelValue`,e)}),C={"document-text":``,search:``,cog:``,collection:``,puzzle:``,folder:``},w=e=>C[e]||C[`document-text`];return(r,s)=>(i(),f(`div`,h,[p(`div`,g,[p(`nav`,{class:`-mb-px flex space-x-8`,"aria-label":r.$t(`fields.tabs.label`)},[(i(!0),f(d,null,a(n.tabs,n=>(i(),f(`button`,{key:n.name,type:`button`,"data-tab":n.name,"data-tab-active":S.value===n.name?`true`:`false`,onClick:e=>S.value=n.name,class:e([S.value===n.name?`border-focus text-accent`:`border-transparent text-muted hover:text-fg hover:border-field`,`group inline-flex items-center py-4 px-1 border-b-2 font-medium text-sm whitespace-nowrap transition-colors duration-150`])},[n.icon?(i(),f(`svg`,{key:0,class:e([S.value===n.name?`text-accent`:`text-muted group-hover:text-fg`,`-ml-0.5 mr-2 h-5 w-5 transition-colors duration-150`]),xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,innerHTML:w(n.icon)},null,10,y)):t(``,!0),o(` `+u(n.label)+` `,1),n.badge?(i(),f(`span`,{key:1,"data-tab-badge":n.name,class:e([S.value===n.name?`bg-accent-soft text-accent`:`bg-danger-soft text-danger`,`ml-2 py-0.5 px-2 rounded-full text-xs font-medium`])},u(n.badge),11,b)):t(``,!0)],10,v))),128))],8,_)]),p(`div`,x,[m(r.$slots,`default`,{activeTab:S.value})])]))}},C=[`data-tab-panel`,`data-tab-active`],w={__name:`AdminTabPanel`,props:{name:{type:String,required:!0},activeTab:{type:String,required:!0},lazy:{type:Boolean,default:!1}},setup(a){let o=a,u=c(()=>o.activeTab===o.name),d=s(!1);r(u,e=>{e&&(d.value=!0)},{immediate:!0});let p=c(()=>!o.lazy||d.value);return(r,o)=>p.value?n((i(),f(`div`,{key:0,class:e([`admin-tab-panel`,{"is-active":u.value}]),"data-tab-panel":a.name,"data-tab-active":u.value?`true`:`false`,role:`tabpanel`},[m(r.$slots,`default`)],10,C)),[[l,u.value]]):t(``,!0)}},T=[`aria-label`],E={class:`text-sm text-muted mr-1`},D=[`data-content-locale`,`aria-pressed`,`onClick`],O={key:0,class:`inline-flex items-center justify-center min-w-5 h-5 px-1 text-xs font-semibold rounded-full bg-danger-hover text-on-danger`},k={__name:`ContentLocaleSwitcher`,props:{modelValue:{type:String,default:null},locales:{type:Array,required:!0},fields:{type:Array,required:!0},errors:{type:Object,default:()=>({})}},emits:[`update:modelValue`],setup(n,{emit:r}){let s=n,l=r,m=c(()=>s.fields.filter(e=>e.translatable).map(e=>e.name));function h(e){return Object.keys(s.errors).filter(t=>m.value.some(n=>t===`${n}.${e}`)).length}return(r,s)=>(i(),f(`div`,{class:`flex flex-wrap items-center gap-2 mb-6`,role:`group`,"aria-label":r.$t(`languages.switch`)},[p(`span`,E,u(r.$t(`languages.switch`))+`:`,1),(i(!0),f(d,null,a(n.locales,r=>(i(),f(`button`,{key:r.code,type:`button`,"data-content-locale":r.code,"aria-pressed":n.modelValue===r.code?`true`:`false`,class:e([`inline-flex items-center gap-1.5 px-3 py-1.5 text-sm rounded-md border transition-colors`,n.modelValue===r.code?`bg-accent-hover border-accent-hover text-on-accent`:`bg-surface border-field text-fg hover:bg-hover`]),onClick:e=>l(`update:modelValue`,r.code)},[o(u(r.name)+` `,1),h(r.code)>0?(i(),f(`span`,O,u(h(r.code)),1)):t(``,!0)],10,D))),128))],8,T))}};export{w as n,S as r,k as t}; \ No newline at end of file diff --git a/packages/admin/dist/assets/Create-BxhK0Jvn.js b/packages/admin/dist/assets/Create-BxhK0Jvn.js deleted file mode 100644 index 8b4414b8..00000000 --- a/packages/admin/dist/assets/Create-BxhK0Jvn.js +++ /dev/null @@ -1 +0,0 @@ -import{C as e,E as t,I as n,L as r,R as i,S as a,T as o,W as s,Y as c,Z as l,_ as u,a as d,b as f,et as p,i as m,q as h,v as g,w as _,x as v}from"./dist-MY__znoP.js";import{t as y}from"./AdminLayout--RXJFj9t.js";import{t as b}from"./AdminButton-Bx141Bs3.js";import{t as x}from"./AdminCard--HubMtUj.js";import{n as S,r as C,t as w}from"./ContentLocaleSwitcher-BJIieXK-.js";import{t as T}from"./FormField-xD6LELDV.js";import{n as E,r as D,t as O}from"./contentLocale-BtGD-iBF.js";var k={class:`mb-6`},A={class:`flex`,"aria-label":`Breadcrumb`},j={class:`inline-flex items-center space-x-1 md:space-x-3`},M={class:`inline-flex items-center`},N={class:`flex items-center`},P={class:`ml-1 text-muted`},F={class:`max-w-4xl`},I={class:`text-2xl font-bold text-fg mb-6`},L=[`data-resource`],R={class:`space-y-6`},z={key:0,class:`text-center py-12 text-muted`},B={key:2,class:`space-y-6`},V={class:`flex items-center justify-end space-x-3 pt-6 mt-6 border-t`},H={__name:`Create`,props:{routeName:String,createLabel:String,fields:Array,fieldsByTab:Object,tabs:Array,useTabs:Boolean,title:String,adminLabel:String},setup(H){let U=H,W=c(U.tabs?.[0]?.name||`main`),G={};U.useTabs&&U.fieldsByTab?Object.values(U.fieldsByTab).flat().forEach(e=>{G[e.name]=E(e,void 0)}):U.fields.forEach(e=>{G[e.name]=E(e,void 0)});let K=d(G),q=()=>(U.useTabs&&U.fieldsByTab?Object.values(U.fieldsByTab).flat():U.fields)||[],{locale:J,locales:Y,showSwitcher:X}=D(q),Z=f(()=>({...K.data()}));r(`formData`,Z),r(`aiModule`,U.routeName?.replace(/^admin\./,``)||null);let Q=()=>{K.submit(`post`,route(`${U.routeName}.store`))},$=e=>U.fieldsByTab?.[e]?U.fieldsByTab[e].filter(e=>O(K.errors,e)).length:0,ee=f(()=>U.tabs?U.tabs.map(e=>({...e,badge:$(e.name)>0?String($(e.name)):null})):[]);return(r,c)=>(n(),a(y,{title:H.title},{default:s(()=>[v(`div`,k,[v(`nav`,A,[v(`ol`,j,[v(`li`,M,[t(l(m),{href:r.route(`${U.routeName}.index`),class:`text-muted hover:text-accent`},{default:s(()=>[o(p(H.adminLabel),1)]),_:1},8,[`href`])]),v(`li`,null,[v(`div`,N,[c[2]||=v(`svg`,{class:`w-4 h-4 text-muted`,fill:`currentColor`,viewBox:`0 0 20 20`},[v(`path`,{"fill-rule":`evenodd`,d:`M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z`,"clip-rule":`evenodd`})],-1),v(`span`,P,p(r.$t(`resource.form.breadcrumb_create`)),1)])])])])]),v(`div`,F,[v(`h1`,I,p(H.title),1),t(x,null,{default:s(()=>[v(`form`,{onSubmit:u(Q,[`prevent`]),"data-admin-form":`true`,"data-resource":H.routeName,"data-context":`create`},[l(X)?(n(),a(w,{key:0,modelValue:l(J),"onUpdate:modelValue":c[0]||=e=>h(J)?J.value=e:null,locales:l(Y),fields:q(),errors:l(K).errors},null,8,[`modelValue`,`locales`,`fields`,`errors`])):e(``,!0),H.useTabs&&H.tabs&&H.fieldsByTab?(n(),a(C,{key:1,tabs:ee.value,modelValue:W.value,"onUpdate:modelValue":c[1]||=e=>W.value=e},{default:s(({activeTab:t})=>[(n(!0),_(g,null,i(H.tabs,o=>(n(),a(S,{key:o.name,name:o.name,activeTab:t},{default:s(()=>[v(`div`,R,[(n(!0),_(g,null,i(H.fieldsByTab[o.name],e=>(n(),a(T,{key:e.name,field:e,modelValue:l(K)[e.name],"onUpdate:modelValue":t=>l(K)[e.name]=t,errors:l(K).errors},null,8,[`field`,`modelValue`,`onUpdate:modelValue`,`errors`]))),128)),H.fieldsByTab[o.name]?.length?e(``,!0):(n(),_(`div`,z,[v(`p`,null,p(r.$t(`resource.form.empty_tab`)),1)]))])]),_:2},1032,[`name`,`activeTab`]))),128))]),_:1},8,[`tabs`,`modelValue`])):(n(),_(`div`,B,[(n(!0),_(g,null,i(H.fields,e=>(n(),a(T,{key:e.name,field:e,modelValue:l(K)[e.name],"onUpdate:modelValue":t=>l(K)[e.name]=t,errors:l(K).errors},null,8,[`field`,`modelValue`,`onUpdate:modelValue`,`errors`]))),128))])),v(`div`,V,[t(b,{"data-action":`cancel`,href:r.route(`${U.routeName}.index`),variant:`secondary`},{default:s(()=>[o(p(r.$t(`common.cancel`)),1)]),_:1},8,[`href`]),t(b,{"data-action":`save`,type:`submit`,loading:l(K).processing},{default:s(()=>[o(p(r.$t(`common.create`)),1)]),_:1},8,[`loading`])])],40,L)]),_:1})])]),_:1},8,[`title`]))}};export{H as default}; \ No newline at end of file diff --git a/packages/admin/dist/assets/Create-C61-lS2c.js b/packages/admin/dist/assets/Create-C61-lS2c.js deleted file mode 100644 index 276f1ff8..00000000 --- a/packages/admin/dist/assets/Create-C61-lS2c.js +++ /dev/null @@ -1 +0,0 @@ -import{C as e,E as t,G as n,I as r,Q as i,R as a,S as o,T as s,W as c,Z as l,_ as u,a as d,d as f,et as p,i as m,u as h,v as g,w as _,x as v}from"./dist-MY__znoP.js";import{t as y}from"./AdminLayout--RXJFj9t.js";import{t as b}from"./AdminButton-Bx141Bs3.js";import{t as x}from"./AdminCard--HubMtUj.js";import{t as S}from"./FormField-xD6LELDV.js";var C={class:`mb-6`},w={class:`flex`,"aria-label":`Breadcrumb`},T={class:`inline-flex items-center space-x-1 md:space-x-3`},E={class:`inline-flex items-center`},D={class:`flex items-center`},O={class:`ml-1 text-muted`},k={class:`max-w-2xl`},A={class:`text-2xl font-bold text-fg mb-6`},j={key:1},M={key:0,class:`flex items-center`},N=[`id`,`onUpdate:modelValue`],P=[`for`],F=[`for`],I={key:0,class:`text-danger`},L=[`id`,`onUpdate:modelValue`,`type`,`placeholder`,`required`],R={key:2,class:`mt-1 text-sm text-muted`},z={key:3,class:`mt-1 text-sm text-danger`},B={class:`flex items-center justify-end space-x-3 pt-4 border-t`},V={__name:`Create`,props:{fields:Array,title:String},setup(V){let H=V,U={};H.fields.forEach(e=>{U[e.name]=e.default??``});let W=d(U),G=()=>{W.post(route(`admin.users.store`))},K=e=>[`text`,`email`,`password`,`checkbox`].includes(e.type);return(d,H)=>(r(),o(y,{title:V.title},{default:c(()=>[v(`div`,C,[v(`nav`,w,[v(`ol`,T,[v(`li`,E,[t(l(m),{href:d.route(`admin.users.index`),class:`text-muted hover:text-accent`},{default:c(()=>[s(p(d.$t(`menu.administrators`)),1)]),_:1},8,[`href`])]),v(`li`,null,[v(`div`,D,[H[0]||=v(`svg`,{class:`w-4 h-4 text-muted`,fill:`currentColor`,viewBox:`0 0 20 20`},[v(`path`,{"fill-rule":`evenodd`,d:`M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z`,"clip-rule":`evenodd`})],-1),v(`span`,O,p(d.$t(`account.users.creating`)),1)])])])])]),v(`div`,k,[v(`h1`,A,p(V.title),1),t(x,null,{default:c(()=>[v(`form`,{onSubmit:u(G,[`prevent`]),class:`space-y-6`},[(r(!0),_(g,null,a(V.fields,t=>(r(),_(g,{key:t.name},[K(t)?(r(),_(`div`,j,[t.type===`checkbox`?(r(),_(`div`,M,[n(v(`input`,{id:t.name,"onUpdate:modelValue":e=>l(W)[t.name]=e,type:`checkbox`,class:`h-4 w-4 text-accent focus:ring-focus border-field rounded`},null,8,N),[[h,l(W)[t.name]]]),v(`label`,{for:t.name,class:`ml-2 text-sm text-fg`},p(t.label),9,P)])):(r(),_(g,{key:1},[v(`label`,{for:t.name,class:`block text-sm font-medium text-fg mb-1`},[s(p(t.label)+` `,1),t.required?(r(),_(`span`,I,`*`)):e(``,!0)],8,F),n(v(`input`,{id:t.name,"onUpdate:modelValue":e=>l(W)[t.name]=e,type:t.type===`password`?`password`:t.type===`email`?`email`:`text`,placeholder:t.placeholder,required:t.required,class:i([`w-full px-3 py-2 border border-field rounded-md shadow-sm focus:ring-focus focus:border-focus`,{"border-danger":l(W).errors[t.name]}])},null,10,L),[[f,l(W)[t.name]]])],64)),t.hint?(r(),_(`p`,R,p(t.hint),1)):e(``,!0),l(W).errors[t.name]?(r(),_(`p`,z,p(l(W).errors[t.name]),1)):e(``,!0)])):(r(),o(S,{key:0,field:t,modelValue:l(W)[t.name],"onUpdate:modelValue":e=>l(W)[t.name]=e,errors:l(W).errors},null,8,[`field`,`modelValue`,`onUpdate:modelValue`,`errors`]))],64))),128)),v(`div`,B,[t(b,{href:d.route(`admin.users.index`),variant:`secondary`},{default:c(()=>[s(p(d.$t(`common.cancel`)),1)]),_:1},8,[`href`]),t(b,{"data-action":`save`,type:`submit`,loading:l(W).processing},{default:c(()=>[s(p(d.$t(`common.create`)),1)]),_:1},8,[`loading`])])],32)]),_:1})])]),_:1},8,[`title`]))}};export{V as default}; \ No newline at end of file diff --git a/packages/admin/dist/assets/Create-CbxIXc0Q.js b/packages/admin/dist/assets/Create-CbxIXc0Q.js new file mode 100644 index 00000000..945aeb7e --- /dev/null +++ b/packages/admin/dist/assets/Create-CbxIXc0Q.js @@ -0,0 +1 @@ +import{$ as e,C as t,E as n,G as r,I as i,Q as a,R as o,S as s,T as c,W as l,_ as u,a as d,d as f,i as p,tt as m,u as h,v as g,w as _,x as v}from"./dist-Bie52OmN.js";import{t as y}from"./AdminLayout-DBeSErmz.js";import{t as b}from"./AdminButton-KiIJ2sLW.js";import{t as x}from"./AdminCard-YbEwPtJz.js";import{t as S}from"./FormField-B-XX4VFv.js";var C={class:`mb-6`},w={class:`flex`,"aria-label":`Breadcrumb`},T={class:`inline-flex items-center space-x-1 md:space-x-3`},E={class:`inline-flex items-center`},D={class:`flex items-center`},O={class:`ml-1 text-muted`},k={class:`max-w-2xl`},A={class:`text-2xl font-bold text-fg mb-6`},j={key:1},M={key:0,class:`flex items-center`},N=[`id`,`onUpdate:modelValue`],P=[`for`],F=[`for`],I={key:0,class:`text-danger`},L=[`id`,`onUpdate:modelValue`,`type`,`placeholder`,`required`],R={key:2,class:`mt-1 text-sm text-muted`},z={key:3,class:`mt-1 text-sm text-danger`},B={class:`flex items-center justify-end space-x-3 pt-4 border-t`},V={__name:`Create`,props:{fields:Array,title:String},setup(V){let H=V,U={};H.fields.forEach(e=>{U[e.name]=e.default??``});let W=d(U),G=()=>{W.post(route(`admin.users.store`))},K=e=>[`text`,`email`,`password`,`checkbox`].includes(e.type);return(d,H)=>(i(),s(y,{title:V.title},{default:l(()=>[v(`div`,C,[v(`nav`,w,[v(`ol`,T,[v(`li`,E,[n(a(p),{href:d.route(`admin.users.index`),class:`text-muted hover:text-accent`},{default:l(()=>[c(m(d.$t(`menu.administrators`)),1)]),_:1},8,[`href`])]),v(`li`,null,[v(`div`,D,[H[0]||=v(`svg`,{class:`w-4 h-4 text-muted`,fill:`currentColor`,viewBox:`0 0 20 20`},[v(`path`,{"fill-rule":`evenodd`,d:`M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z`,"clip-rule":`evenodd`})],-1),v(`span`,O,m(d.$t(`account.users.creating`)),1)])])])])]),v(`div`,k,[v(`h1`,A,m(V.title),1),n(x,null,{default:l(()=>[v(`form`,{onSubmit:u(G,[`prevent`]),class:`space-y-6`},[(i(!0),_(g,null,o(V.fields,n=>(i(),_(g,{key:n.name},[K(n)?(i(),_(`div`,j,[n.type===`checkbox`?(i(),_(`div`,M,[r(v(`input`,{id:n.name,"onUpdate:modelValue":e=>a(W)[n.name]=e,type:`checkbox`,class:`h-4 w-4 text-accent focus:ring-focus border-field rounded`},null,8,N),[[h,a(W)[n.name]]]),v(`label`,{for:n.name,class:`ml-2 text-sm text-fg`},m(n.label),9,P)])):(i(),_(g,{key:1},[v(`label`,{for:n.name,class:`block text-sm font-medium text-fg mb-1`},[c(m(n.label)+` `,1),n.required?(i(),_(`span`,I,`*`)):t(``,!0)],8,F),r(v(`input`,{id:n.name,"onUpdate:modelValue":e=>a(W)[n.name]=e,type:n.type===`password`?`password`:n.type===`email`?`email`:`text`,placeholder:n.placeholder,required:n.required,class:e([`w-full px-3 py-2 border border-field rounded-md shadow-sm focus:ring-focus focus:border-focus`,{"border-danger":a(W).errors[n.name]}])},null,10,L),[[f,a(W)[n.name]]])],64)),n.hint?(i(),_(`p`,R,m(n.hint),1)):t(``,!0),a(W).errors[n.name]?(i(),_(`p`,z,m(a(W).errors[n.name]),1)):t(``,!0)])):(i(),s(S,{key:0,field:n,modelValue:a(W)[n.name],"onUpdate:modelValue":e=>a(W)[n.name]=e,errors:a(W).errors},null,8,[`field`,`modelValue`,`onUpdate:modelValue`,`errors`]))],64))),128)),v(`div`,B,[n(b,{href:d.route(`admin.users.index`),variant:`secondary`},{default:l(()=>[c(m(d.$t(`common.cancel`)),1)]),_:1},8,[`href`]),n(b,{"data-action":`save`,type:`submit`,loading:a(W).processing},{default:l(()=>[c(m(d.$t(`common.create`)),1)]),_:1},8,[`loading`])])],32)]),_:1})])]),_:1},8,[`title`]))}};export{V as default}; \ No newline at end of file diff --git a/packages/admin/dist/assets/Create-DutDQiBS.js b/packages/admin/dist/assets/Create-DutDQiBS.js new file mode 100644 index 00000000..d809074f --- /dev/null +++ b/packages/admin/dist/assets/Create-DutDQiBS.js @@ -0,0 +1 @@ +import{C as e,E as t,I as n,L as r,Q as i,R as a,S as o,T as s,W as c,X as l,_ as u,a as d,b as f,i as p,q as m,tt as h,v as g,w as _,x as v}from"./dist-Bie52OmN.js";import{t as y}from"./AdminLayout-DBeSErmz.js";import{t as b}from"./AdminButton-KiIJ2sLW.js";import{t as x}from"./AdminCard-YbEwPtJz.js";import{n as S,r as C,t as w}from"./ContentLocaleSwitcher-HJzbB87a.js";import{t as T}from"./FormField-B-XX4VFv.js";import{n as E,r as D,t as O}from"./contentLocale-BV_E0iGS.js";var k={class:`mb-6`},A={class:`flex`,"aria-label":`Breadcrumb`},j={class:`inline-flex items-center space-x-1 md:space-x-3`},M={class:`inline-flex items-center`},N={class:`flex items-center`},P={class:`ml-1 text-muted`},F={class:`max-w-4xl`},I={class:`text-2xl font-bold text-fg mb-6`},L=[`data-resource`],R={class:`space-y-6`},z={key:0,class:`text-center py-12 text-muted`},B={key:2,class:`space-y-6`},V={class:`flex items-center justify-end space-x-3 pt-6 mt-6 border-t`},H={__name:`Create`,props:{routeName:String,createLabel:String,fields:Array,fieldsByTab:Object,tabs:Array,useTabs:Boolean,title:String,adminLabel:String},setup(H){let U=H,W=l(U.tabs?.[0]?.name||`main`),G={};U.useTabs&&U.fieldsByTab?Object.values(U.fieldsByTab).flat().forEach(e=>{G[e.name]=E(e,void 0)}):U.fields.forEach(e=>{G[e.name]=E(e,void 0)});let K=d(G),q=()=>(U.useTabs&&U.fieldsByTab?Object.values(U.fieldsByTab).flat():U.fields)||[],{locale:J,locales:Y,showSwitcher:X}=D(q),Z=f(()=>({...K.data()}));r(`formData`,Z),r(`aiModule`,U.routeName?.replace(/^admin\./,``)||null);let Q=()=>{K.submit(`post`,route(`${U.routeName}.store`))},$=e=>U.fieldsByTab?.[e]?U.fieldsByTab[e].filter(e=>O(K.errors,e)).length:0,ee=f(()=>U.tabs?U.tabs.map(e=>({...e,badge:$(e.name)>0?String($(e.name)):null})):[]);return(r,l)=>(n(),o(y,{title:H.title},{default:c(()=>[v(`div`,k,[v(`nav`,A,[v(`ol`,j,[v(`li`,M,[t(i(p),{href:r.route(`${U.routeName}.index`),class:`text-muted hover:text-accent`},{default:c(()=>[s(h(H.adminLabel),1)]),_:1},8,[`href`])]),v(`li`,null,[v(`div`,N,[l[2]||=v(`svg`,{class:`w-4 h-4 text-muted`,fill:`currentColor`,viewBox:`0 0 20 20`},[v(`path`,{"fill-rule":`evenodd`,d:`M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z`,"clip-rule":`evenodd`})],-1),v(`span`,P,h(r.$t(`resource.form.breadcrumb_create`)),1)])])])])]),v(`div`,F,[v(`h1`,I,h(H.title),1),t(x,null,{default:c(()=>[v(`form`,{onSubmit:u(Q,[`prevent`]),"data-admin-form":`true`,"data-resource":H.routeName,"data-context":`create`},[i(X)?(n(),o(w,{key:0,modelValue:i(J),"onUpdate:modelValue":l[0]||=e=>m(J)?J.value=e:null,locales:i(Y),fields:q(),errors:i(K).errors},null,8,[`modelValue`,`locales`,`fields`,`errors`])):e(``,!0),H.useTabs&&H.tabs&&H.fieldsByTab?(n(),o(C,{key:1,tabs:ee.value,modelValue:W.value,"onUpdate:modelValue":l[1]||=e=>W.value=e},{default:c(({activeTab:t})=>[(n(!0),_(g,null,a(H.tabs,s=>(n(),o(S,{key:s.name,name:s.name,activeTab:t},{default:c(()=>[v(`div`,R,[(n(!0),_(g,null,a(H.fieldsByTab[s.name],e=>(n(),o(T,{key:e.name,field:e,modelValue:i(K)[e.name],"onUpdate:modelValue":t=>i(K)[e.name]=t,errors:i(K).errors},null,8,[`field`,`modelValue`,`onUpdate:modelValue`,`errors`]))),128)),H.fieldsByTab[s.name]?.length?e(``,!0):(n(),_(`div`,z,[v(`p`,null,h(r.$t(`resource.form.empty_tab`)),1)]))])]),_:2},1032,[`name`,`activeTab`]))),128))]),_:1},8,[`tabs`,`modelValue`])):(n(),_(`div`,B,[(n(!0),_(g,null,a(H.fields,e=>(n(),o(T,{key:e.name,field:e,modelValue:i(K)[e.name],"onUpdate:modelValue":t=>i(K)[e.name]=t,errors:i(K).errors},null,8,[`field`,`modelValue`,`onUpdate:modelValue`,`errors`]))),128))])),v(`div`,V,[t(b,{"data-action":`cancel`,href:r.route(`${U.routeName}.index`),variant:`secondary`},{default:c(()=>[s(h(r.$t(`common.cancel`)),1)]),_:1},8,[`href`]),t(b,{"data-action":`save`,type:`submit`,loading:i(K).processing},{default:c(()=>[s(h(r.$t(`common.create`)),1)]),_:1},8,[`loading`])])],40,L)]),_:1})])]),_:1},8,[`title`]))}};export{H as default}; \ No newline at end of file diff --git a/packages/admin/dist/assets/Dashboard-BU7gtvAo.js b/packages/admin/dist/assets/Dashboard-BU7gtvAo.js deleted file mode 100644 index 21369017..00000000 --- a/packages/admin/dist/assets/Dashboard-BU7gtvAo.js +++ /dev/null @@ -1 +0,0 @@ -import{$ as e,C as t,I as n,Q as r,R as i,S as a,T as o,V as s,W as c,Y as l,b as u,et as d,v as f,w as p,x as m}from"./dist-MY__znoP.js";import{t as h}from"./AdminLayout--RXJFj9t.js";var g={class:`bg-surface rounded-lg shadow px-5 py-4`,"data-gadget":`site-speed`},_={class:`text-sm font-semibold text-fg`},v={class:`mt-3 flex items-baseline gap-2`},y={class:`text-3xl font-semibold text-fg tabular-nums`},b={class:`text-sm text-muted`},x={class:`mt-4`},S={class:`relative h-2 rounded-full bg-off overflow-hidden`},C={class:`mt-1.5 grid grid-cols-5 gap-1 text-xs text-muted`},w={class:`mt-1 flex justify-between text-xs text-muted tabular-nums`},T={class:`mt-3 text-xs text-muted`},E={__name:`SiteSpeedGadget`,props:{title:{type:String,default:``},data:{type:Object,required:!0}},setup(a){let s=a,c=u(()=>s.data.bands.indexOf(s.data.label));return(s,l)=>(n(),p(`div`,g,[m(`h2`,_,d(a.title||s.$t(`dashboard.site_speed.title`)),1),m(`div`,v,[a.data.seconds?(n(),p(f,{key:0},[m(`span`,y,d(a.data.seconds),1),m(`span`,b,d(a.data.unit),1)],64)):t(``,!0),m(`span`,{class:r([`text-sm font-medium text-fg`,{"ml-2":a.data.seconds}]),"data-speed-band":``},d(a.data.label),3)]),m(`div`,x,[m(`div`,S,[a.data.percent===null?t(``,!0):(n(),p(`div`,{key:0,class:`absolute inset-y-0 left-0 bg-accent`,style:e({width:a.data.percent+`%`})},null,4)),(n(),p(f,null,i([20,40,60,80],t=>m(`span`,{key:t,class:`absolute inset-y-0 w-0.5 bg-surface`,style:e({left:t+`%`})},null,4)),64))]),m(`div`,C,[(n(!0),p(f,null,i(a.data.bands,(e,t)=>(n(),p(`span`,{key:e,class:r([`text-center leading-tight`,{"font-semibold text-fg":t===c.value}])},d(e),3))),128))]),m(`div`,w,[l[0]||=m(`span`,null,`0`,-1),m(`span`,null,d(a.data.scaleSeconds)+` `+d(a.data.unit),1)])]),m(`p`,T,[a.data.samples?(n(),p(f,{key:0},[o(d(s.$t(`dashboard.site_speed.samples_note`,{samples:a.data.samples,days:a.data.windowDays})),1)],64)):(n(),p(f,{key:1},[o(d(s.$t(`dashboard.site_speed.no_samples`)),1)],64))])]))}},D={class:`bg-surface rounded-lg shadow px-5 py-4`,"data-gadget":`performance`},O={class:`flex items-start justify-between gap-4`},k={class:`text-sm font-semibold text-fg`},A=[`aria-expanded`],j={key:0,class:`mt-3`},M={class:`flex items-baseline gap-2`},N={class:`text-3xl font-semibold text-fg tabular-nums`},P={class:`text-sm text-muted`},F={class:`text-xs text-muted`},ee={key:1,class:`mt-3 text-sm text-muted`},I={key:2,class:`mt-3 text-xs text-muted`},L={key:3,class:`mt-3 border-t border-line pt-3`,"data-performance-details":``},R={class:`text-xs font-semibold text-fg`},z={class:`mt-1 divide-y divide-line text-sm`},B=[`title`],V={class:`whitespace-nowrap text-muted tabular-nums`},H={__name:`PerformanceGadget`,props:{title:{type:String,default:``},data:{type:Object,required:!0}},setup(e){let r=l(!1);return(a,o)=>(n(),p(`div`,D,[m(`div`,O,[m(`h2`,k,d(e.title||a.$t(`dashboard.performance.title`)),1),e.data.slowest.length?(n(),p(`button`,{key:0,type:`button`,class:`rounded-md border border-field bg-surface px-3 py-1 text-sm text-fg hover:bg-hover focus:outline-none focus-visible:ring-2 focus-visible:ring-focus`,"aria-expanded":r.value?`true`:`false`,"data-action":`performance-details`,onClick:o[0]||=e=>r.value=!r.value},d(r.value?a.$t(`dashboard.performance.collapse`):a.$t(`dashboard.performance.details`)),9,A)):t(``,!0)]),e.data.rate?(n(),p(`div`,j,[m(`div`,M,[m(`span`,N,d(e.data.rate),1),m(`span`,P,d(e.data.unit),1)]),m(`div`,F,d(e.data.caption),1)])):(n(),p(`p`,ee,d(a.$t(`dashboard.performance.pending`)),1)),e.data.rate?(n(),p(`p`,I,d(a.$t(`dashboard.performance.note`,{seconds:e.data.averageSeconds,pages:e.data.samples,days:e.data.windowDays})),1)):t(``,!0),r.value?(n(),p(`div`,L,[m(`h3`,R,d(a.$t(`dashboard.performance.slowest_title`)),1),m(`ul`,z,[(n(!0),p(f,null,i(e.data.slowest,e=>(n(),p(`li`,{key:e.path,class:`flex justify-between gap-3 py-1.5`},[m(`span`,{class:`truncate text-fg`,title:e.path},d(e.path),9,B),m(`span`,V,d(a.$t(`dashboard.performance.slowest_row`,{ms:e.ms,hits:e.hits})),1)]))),128))])])):t(``,!0)]))}},U={class:`bg-surface rounded-lg shadow px-5 py-4`,"data-gadget":`recent`},W={class:`text-sm font-semibold text-fg`},G={key:0,class:`mt-3 divide-y divide-line`},K=[`src`],q={key:1,class:`h-12 w-12 flex-none rounded bg-off`},J={class:`min-w-0`},Y={key:0,class:`text-xs text-muted`},X=[`href`],Z={key:2,class:`text-sm text-fg line-clamp-2`},Q={key:1,class:`mt-3 text-sm text-muted`},$=[`href`],te={__name:`RecentElementsGadget`,props:{title:{type:String,default:``},data:{type:Object,required:!0}},setup(e){return(r,a)=>(n(),p(`div`,U,[m(`h2`,W,d(e.title||r.$t(`dashboard.recent.title`)),1),e.data.items.length?(n(),p(`ul`,G,[(n(!0),p(f,null,i(e.data.items,e=>(n(),p(`li`,{key:e.id,class:`flex gap-3 py-2`},[e.image?(n(),p(`img`,{key:0,src:e.image,alt:``,class:`h-12 w-12 flex-none rounded object-cover bg-off`},null,8,K)):(n(),p(`div`,q)),m(`div`,J,[e.date?(n(),p(`div`,Y,d(e.date),1)):t(``,!0),e.url?(n(),p(`a`,{key:1,href:e.url,class:`text-sm text-accent hover:underline line-clamp-2`},d(e.name),9,X)):(n(),p(`span`,Z,d(e.name),1))])]))),128))])):(n(),p(`p`,Q,d(r.$t(`dashboard.recent.empty`)),1)),e.data.allUrl?(n(),p(`a`,{key:2,href:e.data.allUrl,class:`mt-3 inline-block text-sm text-accent hover:underline`},d(e.data.allLabel),9,$)):t(``,!0)]))}},ne={class:`mb-6`},re={class:`text-2xl font-bold text-fg`},ie={class:`grid grid-cols-1 gap-6 lg:grid-cols-2`},ae={__name:`Dashboard`,props:{gadgets:{type:Array,default:()=>[]}},setup(e){let t={SiteSpeedGadget:E,PerformanceGadget:H,RecentElementsGadget:te},o=e,l=u(()=>o.gadgets.filter(e=>t[e.component]));return(e,o)=>(n(),a(h,{title:e.$t(`dashboard.title`)},{default:c(()=>[m(`div`,ne,[m(`h1`,re,d(e.$t(`dashboard.title`)),1)]),m(`div`,ie,[(n(!0),p(f,null,i(l.value,e=>(n(),a(s(t[e.component]),{key:e.key,title:e.title,data:e.data,class:r(e.width===`full`?`lg:col-span-2`:``)},null,8,[`title`,`data`,`class`]))),128))])]),_:1},8,[`title`]))}};export{ae as default}; \ No newline at end of file diff --git a/packages/admin/dist/assets/Dashboard-C9RqcuE0.js b/packages/admin/dist/assets/Dashboard-C9RqcuE0.js new file mode 100644 index 00000000..970f4d54 --- /dev/null +++ b/packages/admin/dist/assets/Dashboard-C9RqcuE0.js @@ -0,0 +1 @@ +import{$ as e,C as t,E as n,I as r,Q as i,R as a,S as o,T as s,V as c,W as l,X as ee,b as u,et as d,i as f,tt as p,v as m,w as h,x as g}from"./dist-Bie52OmN.js";import{t as _}from"./AdminLayout-DBeSErmz.js";import{t as v}from"./BarChart-wks0RLo_.js";var y={class:`bg-surface rounded-lg shadow px-5 py-4`,"data-gadget":`site-speed`},b={class:`text-sm font-semibold text-fg`},x={class:`mt-3 flex items-baseline gap-2`},S={class:`text-3xl font-semibold text-fg tabular-nums`},C={class:`text-sm text-muted`},w={class:`mt-4`},T={class:`relative h-2 rounded-full bg-off overflow-hidden`},E={class:`mt-1.5 grid grid-cols-5 gap-1 text-xs text-muted`},D={class:`mt-1 flex justify-between text-xs text-muted tabular-nums`},O={class:`mt-3 text-xs text-muted`},k={__name:`SiteSpeedGadget`,props:{title:{type:String,default:``},data:{type:Object,required:!0}},setup(n){let i=n,o=u(()=>i.data.bands.indexOf(i.data.label));return(i,c)=>(r(),h(`div`,y,[g(`h2`,b,p(n.title||i.$t(`dashboard.site_speed.title`)),1),g(`div`,x,[n.data.seconds?(r(),h(m,{key:0},[g(`span`,S,p(n.data.seconds),1),g(`span`,C,p(n.data.unit),1)],64)):t(``,!0),g(`span`,{class:e([`text-sm font-medium text-fg`,{"ml-2":n.data.seconds}]),"data-speed-band":``},p(n.data.label),3)]),g(`div`,w,[g(`div`,T,[n.data.percent===null?t(``,!0):(r(),h(`div`,{key:0,class:`absolute inset-y-0 left-0 bg-accent`,style:d({width:n.data.percent+`%`})},null,4)),(r(),h(m,null,a([20,40,60,80],e=>g(`span`,{key:e,class:`absolute inset-y-0 w-0.5 bg-surface`,style:d({left:e+`%`})},null,4)),64))]),g(`div`,E,[(r(!0),h(m,null,a(n.data.bands,(t,n)=>(r(),h(`span`,{key:t,class:e([`text-center leading-tight`,{"font-semibold text-fg":n===o.value}])},p(t),3))),128))]),g(`div`,D,[c[0]||=g(`span`,null,`0`,-1),g(`span`,null,p(n.data.scaleSeconds)+` `+p(n.data.unit),1)])]),g(`p`,O,[n.data.samples?(r(),h(m,{key:0},[s(p(i.$t(`dashboard.site_speed.samples_note`,{samples:n.data.samples,days:n.data.windowDays})),1)],64)):(r(),h(m,{key:1},[s(p(i.$t(`dashboard.site_speed.no_samples`)),1)],64))])]))}},A={class:`bg-surface rounded-lg shadow px-5 py-4`,"data-gadget":`performance`},j={class:`flex items-start justify-between gap-4`},M={class:`text-sm font-semibold text-fg`},N=[`aria-expanded`],P={key:0,class:`mt-3`},F={class:`flex items-baseline gap-2`},I={class:`text-3xl font-semibold text-fg tabular-nums`},L={class:`text-sm text-muted`},R={class:`text-xs text-muted`},z={key:1,class:`mt-3 text-sm text-muted`},B={key:2,class:`mt-3 text-xs text-muted`},V={key:3,class:`mt-3 border-t border-line pt-3`,"data-performance-details":``},H={class:`text-xs font-semibold text-fg`},U={class:`mt-1 divide-y divide-line text-sm`},W=[`title`],te={class:`whitespace-nowrap text-muted tabular-nums`},G={__name:`PerformanceGadget`,props:{title:{type:String,default:``},data:{type:Object,required:!0}},setup(e){let n=ee(!1);return(i,o)=>(r(),h(`div`,A,[g(`div`,j,[g(`h2`,M,p(e.title||i.$t(`dashboard.performance.title`)),1),e.data.slowest.length?(r(),h(`button`,{key:0,type:`button`,class:`rounded-md border border-field bg-surface px-3 py-1 text-sm text-fg hover:bg-hover focus:outline-none focus-visible:ring-2 focus-visible:ring-focus`,"aria-expanded":n.value?`true`:`false`,"data-action":`performance-details`,onClick:o[0]||=e=>n.value=!n.value},p(n.value?i.$t(`dashboard.performance.collapse`):i.$t(`dashboard.performance.details`)),9,N)):t(``,!0)]),e.data.rate?(r(),h(`div`,P,[g(`div`,F,[g(`span`,I,p(e.data.rate),1),g(`span`,L,p(e.data.unit),1)]),g(`div`,R,p(e.data.caption),1)])):(r(),h(`p`,z,p(i.$t(`dashboard.performance.pending`)),1)),e.data.rate?(r(),h(`p`,B,p(i.$t(`dashboard.performance.note`,{seconds:e.data.averageSeconds,pages:e.data.samples,days:e.data.windowDays})),1)):t(``,!0),n.value?(r(),h(`div`,V,[g(`h3`,H,p(i.$t(`dashboard.performance.slowest_title`)),1),g(`ul`,U,[(r(!0),h(m,null,a(e.data.slowest,e=>(r(),h(`li`,{key:e.path,class:`flex justify-between gap-3 py-1.5`},[g(`span`,{class:`truncate text-fg`,title:e.path},p(e.path),9,W),g(`span`,te,p(i.$t(`dashboard.performance.slowest_row`,{ms:e.ms,hits:e.hits})),1)]))),128))])])):t(``,!0)]))}},K={class:`bg-surface rounded-lg shadow px-5 py-4`,"data-gadget":`recent`},q={class:`text-sm font-semibold text-fg`},J={key:0,class:`mt-3 divide-y divide-line`},Y=[`src`],X={key:1,class:`h-12 w-12 flex-none rounded bg-off`},Z={class:`min-w-0`},Q={key:0,class:`text-xs text-muted`},ne=[`href`],re={key:2,class:`text-sm text-fg line-clamp-2`},ie={key:1,class:`mt-3 text-sm text-muted`},ae=[`href`],oe={__name:`RecentElementsGadget`,props:{title:{type:String,default:``},data:{type:Object,required:!0}},setup(e){return(n,i)=>(r(),h(`div`,K,[g(`h2`,q,p(e.title||n.$t(`dashboard.recent.title`)),1),e.data.items.length?(r(),h(`ul`,J,[(r(!0),h(m,null,a(e.data.items,e=>(r(),h(`li`,{key:e.id,class:`flex gap-3 py-2`},[e.image?(r(),h(`img`,{key:0,src:e.image,alt:``,class:`h-12 w-12 flex-none rounded object-cover bg-off`},null,8,Y)):(r(),h(`div`,X)),g(`div`,Z,[e.date?(r(),h(`div`,Q,p(e.date),1)):t(``,!0),e.url?(r(),h(`a`,{key:1,href:e.url,class:`text-sm text-accent hover:underline line-clamp-2`},p(e.name),9,ne)):(r(),h(`span`,re,p(e.name),1))])]))),128))])):(r(),h(`p`,ie,p(n.$t(`dashboard.recent.empty`)),1)),e.data.allUrl?(r(),h(`a`,{key:2,href:e.data.allUrl,class:`mt-3 inline-block text-sm text-accent hover:underline`},p(e.data.allLabel),9,ae)):t(``,!0)]))}},se={class:`bg-surface rounded-lg shadow px-5 py-4`,"data-gadget":`errors`,dusk:`errors-gadget`},ce={class:`flex items-baseline justify-between gap-3`},le={class:`text-sm font-semibold text-fg`},ue={class:`mt-3 grid grid-cols-2 sm:grid-cols-4 gap-3`},de=[`data-count`],fe={class:`text-xs text-muted`},pe={class:`text-2xl font-semibold text-fg tabular-nums`},$={key:0,class:`mt-4 text-sm text-muted`},me={class:`mt-4`},he={class:`mt-4 text-xs font-semibold uppercase tracking-wide text-muted`},ge={class:`mt-2 divide-y divide-line`},_e={class:`w-10 shrink-0 text-right font-semibold text-fg tabular-nums`},ve={class:`font-medium`},ye={__name:`ErrorsGadget`,props:{title:{type:String,default:``},data:{type:Object,required:!0}},setup(e){return(t,o)=>(r(),h(`div`,se,[g(`div`,ce,[g(`h2`,le,p(e.title||e.data.strings.title),1),n(i(f),{href:e.data.url,class:`text-sm text-accent hover:text-accent-hover hover:underline`,dusk:`errors-gadget-all`},{default:l(()=>[s(p(e.data.strings.all),1)]),_:1},8,[`href`])]),g(`dl`,ue,[(r(),h(m,null,a([`events`,`new`,`regressed`,`unresolved`],t=>g(`div`,{key:t,class:`flex flex-col-reverse`,"data-count":t},[g(`dt`,fe,p(e.data.strings[t]),1),g(`dd`,pe,p(e.data[t]),1)],8,de)),64))]),e.data.events?(r(),h(m,{key:1},[g(`div`,me,[n(v,{points:e.data.chart,every:6,height:72,label:e.data.strings.chart},null,8,[`points`,`label`])]),g(`h3`,he,p(e.data.strings.top),1),g(`ul`,ge,[(r(!0),h(m,null,a(e.data.top,e=>(r(),h(`li`,{key:e.id,class:`py-1.5 flex items-baseline gap-3 text-sm`},[g(`span`,_e,p(e.count),1),n(i(f),{href:e.url,class:`min-w-0 truncate text-accent hover:text-accent-hover hover:underline`,dusk:`errors-gadget-issue`},{default:l(()=>[g(`span`,ve,p(e.class),1),s(`: `+p(e.title),1)]),_:2},1032,[`href`])]))),128))])],64)):(r(),h(`p`,$,p(e.data.strings.none),1))]))}},be={class:`mb-6`},xe={class:`text-2xl font-bold text-fg`},Se={class:`grid grid-cols-1 gap-6 lg:grid-cols-2`},Ce={__name:`Dashboard`,props:{gadgets:{type:Array,default:()=>[]}},setup(t){let n={SiteSpeedGadget:k,PerformanceGadget:G,RecentElementsGadget:oe,ErrorsGadget:ye},i=t,s=u(()=>i.gadgets.filter(e=>n[e.component]));return(t,i)=>(r(),o(_,{title:t.$t(`dashboard.title`)},{default:l(()=>[g(`div`,be,[g(`h1`,xe,p(t.$t(`dashboard.title`)),1)]),g(`div`,Se,[(r(!0),h(m,null,a(s.value,t=>(r(),o(c(n[t.component]),{key:t.key,title:t.title,data:t.data,class:e(t.width===`full`?`lg:col-span-2`:``)},null,8,[`title`,`data`,`class`]))),128))])]),_:1},8,[`title`]))}};export{Ce as default}; \ No newline at end of file diff --git a/packages/admin/dist/assets/Edit-BEWPbBmM.js b/packages/admin/dist/assets/Edit-BEWPbBmM.js new file mode 100644 index 00000000..0634b700 --- /dev/null +++ b/packages/admin/dist/assets/Edit-BEWPbBmM.js @@ -0,0 +1 @@ +import{C as e,E as t,I as n,L as r,Q as i,R as a,S as o,T as s,W as c,X as l,_ as u,a as d,b as f,i as p,q as m,tt as h,v as g,w as _,x as v}from"./dist-Bie52OmN.js";import{t as y}from"./AdminLayout-DBeSErmz.js";import{t as b}from"./AdminButton-KiIJ2sLW.js";import{t as x}from"./AdminCard-YbEwPtJz.js";import{n as S,r as C,t as w}from"./ContentLocaleSwitcher-HJzbB87a.js";import{t as T}from"./FormField-B-XX4VFv.js";import{n as E,r as D,t as ee}from"./contentLocale-BV_E0iGS.js";import{t as O}from"./recordActions-CtRs42tG.js";var k={class:`mb-6`},A={class:`flex`,"aria-label":`Breadcrumb`},j={class:`inline-flex items-center space-x-1 md:space-x-3`},M={class:`inline-flex items-center`},N={class:`flex items-center`},P={class:`ml-1 text-muted`},F={class:`max-w-4xl`},I={class:`mb-6 flex flex-wrap items-center justify-between gap-4`},L={class:`text-2xl font-bold text-fg`},R={key:0,class:`flex gap-2`},z={key:0,"data-read-only":``,class:`mb-6 rounded-md border border-field bg-surface-alt px-4 py-3 text-sm text-fg`},B=[`data-resource`,`data-item-id`],V=[`disabled`],H={class:`space-y-6`},te={key:0,class:`text-center py-12 text-muted`},U={key:2,class:`space-y-6`},W={class:`flex items-center justify-end space-x-3 pt-6 mt-6 border-t`},G={__name:`Edit`,props:{routeName:String,createLabel:String,item:Object,itemTitle:String,fields:Array,fieldsByTab:Object,tabs:Array,useTabs:Boolean,title:String,adminLabel:String,can:{type:Object,default:()=>({})},actions:{type:Array,default:()=>[]}},setup(G){let K=G,q=f(()=>K.can.update===!1),J=l(K.tabs?.[0]?.name||`main`),Y={};K.useTabs&&K.fieldsByTab?Object.values(K.fieldsByTab).flat().forEach(e=>{Y[e.name]=E(e,K.item[e.name])}):K.fields.forEach(e=>{Y[e.name]=E(e,K.item[e.name])});let X=d(Y),Z=()=>(K.useTabs&&K.fieldsByTab?Object.values(K.fieldsByTab).flat():K.fields)||[],{locale:Q,locales:ne,showSwitcher:re}=D(Z),ie=f(()=>({...K.item,...X.data()}));r(`formData`,ie),r(`aiModule`,K.routeName?.replace(/^admin\./,``)||null);let ae=()=>{X.submit(`put`,route(`${K.routeName}.update`,K.item.id))},$=e=>K.fieldsByTab?.[e]?K.fieldsByTab[e].filter(e=>ee(X.errors,e)).length:0,oe=f(()=>K.tabs?K.tabs.map(e=>({...e,badge:$(e.name)>0?String($(e.name)):null})):[]);return(r,l)=>(n(),o(y,{title:G.title},{default:c(()=>[v(`div`,k,[v(`nav`,A,[v(`ol`,j,[v(`li`,M,[t(i(p),{href:r.route(`${K.routeName}.index`),class:`text-muted hover:text-accent`},{default:c(()=>[s(h(G.adminLabel),1)]),_:1},8,[`href`])]),v(`li`,null,[v(`div`,N,[l[2]||=v(`svg`,{class:`w-4 h-4 text-muted`,fill:`currentColor`,viewBox:`0 0 20 20`},[v(`path`,{"fill-rule":`evenodd`,d:`M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z`,"clip-rule":`evenodd`})],-1),v(`span`,P,h(G.itemTitle||`#`+G.item.id),1)])])])])]),v(`div`,F,[v(`div`,I,[v(`h1`,L,h(G.title),1),G.actions.length?(n(),_(`div`,R,[(n(!0),_(g,null,a(G.actions,e=>(n(),o(b,{key:e.name,"data-action":e.name,variant:`secondary`,href:i(O)(G.routeName,e,G.item)},{default:c(()=>[s(h(e.label),1)]),_:2},1032,[`data-action`,`href`]))),128))])):e(``,!0)]),t(x,null,{default:c(()=>[q.value?(n(),_(`p`,z,h(r.$t(`resource.form.read_only`)),1)):e(``,!0),v(`form`,{onSubmit:u(ae,[`prevent`]),"data-admin-form":`true`,"data-resource":G.routeName,"data-context":`edit`,"data-item-id":G.item.id},[v(`fieldset`,{disabled:q.value,class:`contents`},[i(re)?(n(),o(w,{key:0,modelValue:i(Q),"onUpdate:modelValue":l[0]||=e=>m(Q)?Q.value=e:null,locales:i(ne),fields:Z(),errors:i(X).errors},null,8,[`modelValue`,`locales`,`fields`,`errors`])):e(``,!0),G.useTabs&&G.tabs&&G.fieldsByTab?(n(),o(C,{key:1,tabs:oe.value,modelValue:J.value,"onUpdate:modelValue":l[1]||=e=>J.value=e},{default:c(({activeTab:t})=>[(n(!0),_(g,null,a(G.tabs,s=>(n(),o(S,{key:s.name,name:s.name,activeTab:t},{default:c(()=>[v(`div`,H,[(n(!0),_(g,null,a(G.fieldsByTab[s.name],e=>(n(),o(T,{key:e.name,field:e,modelValue:i(X)[e.name],"onUpdate:modelValue":t=>i(X)[e.name]=t,errors:i(X).errors},null,8,[`field`,`modelValue`,`onUpdate:modelValue`,`errors`]))),128)),G.fieldsByTab[s.name]?.length?e(``,!0):(n(),_(`div`,te,[v(`p`,null,h(r.$t(`resource.form.empty_tab`)),1)]))])]),_:2},1032,[`name`,`activeTab`]))),128))]),_:1},8,[`tabs`,`modelValue`])):(n(),_(`div`,U,[(n(!0),_(g,null,a(G.fields,e=>(n(),o(T,{key:e.name,field:e,modelValue:i(X)[e.name],"onUpdate:modelValue":t=>i(X)[e.name]=t,errors:i(X).errors},null,8,[`field`,`modelValue`,`onUpdate:modelValue`,`errors`]))),128))]))],8,V),v(`div`,W,[t(b,{"data-action":`cancel`,href:r.route(`${K.routeName}.index`),variant:`secondary`},{default:c(()=>[s(h(q.value?r.$t(`common.back`):r.$t(`common.cancel`)),1)]),_:1},8,[`href`]),q.value?e(``,!0):(n(),o(b,{key:0,"data-action":`save`,type:`submit`,loading:i(X).processing},{default:c(()=>[s(h(r.$t(`common.save`)),1)]),_:1},8,[`loading`]))])],40,B)]),_:1})])]),_:1},8,[`title`]))}};export{G as default}; \ No newline at end of file diff --git a/packages/admin/dist/assets/Edit-pGNJhUsL.js b/packages/admin/dist/assets/Edit-Bm3W6F3v.js similarity index 59% rename from packages/admin/dist/assets/Edit-pGNJhUsL.js rename to packages/admin/dist/assets/Edit-Bm3W6F3v.js index 3dce9a7b..ce6b8979 100644 --- a/packages/admin/dist/assets/Edit-pGNJhUsL.js +++ b/packages/admin/dist/assets/Edit-Bm3W6F3v.js @@ -1 +1 @@ -import{C as e,E as t,G as n,I as r,R as i,S as a,T as o,W as s,Z as c,_ as l,a as u,et as d,i as f,m as p,v as m,w as h,x as g}from"./dist-MY__znoP.js";import{t as _}from"./AdminLayout--RXJFj9t.js";import{t as v}from"./AdminButton-Bx141Bs3.js";import{t as y}from"./AdminCard--HubMtUj.js";import{n as b}from"./app-BNjy5Z6H.js";var x={class:`mb-6`},S={class:`max-w-4xl`},ee={class:`text-2xl font-bold text-fg mb-6`},te={for:`role-name`,class:`block text-sm font-medium text-fg mb-1`},ne={key:0,class:`mt-1 text-sm text-danger`},re={class:`flex flex-wrap items-center justify-between gap-2`},ie={class:`text-sm font-medium text-fg`},C={class:`flex gap-2`},w={class:`mt-1 text-sm text-muted`},T={key:0,class:`mt-1 text-sm text-danger`},E={class:`mt-2 overflow-x-auto border border-line rounded-md`},D={class:`min-w-full text-sm`},O={class:`bg-surface-alt`},k={class:`px-3 py-2 text-left font-medium text-fg`},A={key:0,class:`px-3 py-2 text-left font-medium text-fg`},j={class:`px-3 py-2 w-20 text-center font-medium text-fg`},M={class:`divide-y divide-line`},N=[`data-section`],P={class:`px-3 py-1.5`},F={class:`ml-1 text-xs text-muted font-mono`},I=[`data-permission`,`aria-label`,`checked`,`onChange`],L={key:0,class:`px-3 py-1.5`},ae=[`data-permission`,`checked`,`onChange`],R=[`colspan`],z=[`data-permission`,`checked`,`onChange`],B={class:`px-3 py-1.5 text-center`},V=[`aria-label`,`checked`,`onChange`],H={class:`flex items-center justify-end space-x-3 pt-4 border-t`},U={__name:`Edit`,props:{role:{type:Object,default:null},sections:{type:Array,required:!0},title:String},setup(U){let W=U,G=[`view`,`create`,`update`,`delete`],K=u({name:W.role?.name??``,permissions:[...W.role?.permissions??[]]}),q=(e,t)=>K.permissions.includes(`${e.key}.${t}`),J=e=>G.every(t=>e.actions.includes(t)),Y=e=>J(e)?e.actions.filter(e=>!G.includes(e)):[],X=W.sections.some(e=>Y(e).length>0),Z=(e,t)=>e.labels?.[t]??b(`permissions.actions.${t}`),Q=(e,t)=>{let n=new Set(K.permissions),r=`${e.key}.${t}`;n.has(r)?(n.delete(r),t===`view`&&G.forEach(t=>n.delete(`${e.key}.${t}`))):(n.add(r),J(e)&&G.includes(t)&&t!==`view`&&n.add(`${e.key}.view`)),K.permissions=[...n]},$=e=>e.actions.every(t=>q(e,t)),oe=e=>{let t=new Set(K.permissions),n=$(e);e.actions.forEach(r=>n?t.delete(`${e.key}.${r}`):t.add(`${e.key}.${r}`)),K.permissions=[...t]},se=()=>{K.permissions=W.sections.flatMap(e=>e.actions.map(t=>`${e.key}.${t}`))},ce=()=>{W.role?K.put(route(`admin.roles.update`,W.role.id)):K.post(route(`admin.roles.store`))};return(u,b)=>(r(),a(_,{title:U.title},{default:s(()=>[g(`div`,x,[t(c(f),{href:u.route(`admin.roles.index`),class:`text-muted hover:text-accent`},{default:s(()=>[o(d(u.$t(`menu.roles`)),1)]),_:1},8,[`href`])]),g(`div`,S,[g(`h1`,ee,d(U.title),1),t(y,null,{default:s(()=>[g(`form`,{class:`space-y-6`,"data-role-form":``,onSubmit:l(ce,[`prevent`])},[g(`div`,null,[g(`label`,te,[o(d(u.$t(`permissions.name`))+` `,1),b[2]||=g(`span`,{class:`text-danger`},`*`,-1)]),n(g(`input`,{id:`role-name`,"onUpdate:modelValue":b[0]||=e=>c(K).name=e,type:`text`,required:``,class:`w-full px-3 py-2 border border-field rounded-md shadow-sm focus:ring-focus focus:border-focus`},null,512),[[p,c(K).name]]),c(K).errors.name?(r(),h(`p`,ne,d(c(K).errors.name),1)):e(``,!0)]),g(`div`,null,[g(`div`,re,[g(`span`,ie,d(u.$t(`permissions.permissions`)),1),g(`div`,C,[t(v,{type:`button`,size:`sm`,variant:`outline`,onClick:se},{default:s(()=>[o(d(u.$t(`permissions.select_all`)),1)]),_:1}),t(v,{type:`button`,size:`sm`,variant:`outline`,onClick:b[1]||=e=>c(K).permissions=[]},{default:s(()=>[o(d(u.$t(`permissions.clear`)),1)]),_:1})])]),g(`p`,w,d(u.$t(`permissions.matrix_hint`)),1),c(K).errors.permissions?(r(),h(`p`,T,d(c(K).errors.permissions),1)):e(``,!0),g(`div`,E,[g(`table`,D,[g(`thead`,O,[g(`tr`,null,[g(`th`,k,d(u.$t(`permissions.section`)),1),(r(),h(m,null,i(G,e=>g(`th`,{key:e,class:`px-3 py-2 w-24 text-center font-medium text-fg`},d(u.$t(`permissions.actions.${e}`)),1)),64)),c(X)?(r(),h(`th`,A,d(u.$t(`permissions.other`)),1)):e(``,!0),g(`th`,j,d(u.$t(`permissions.all`)),1)])]),g(`tbody`,M,[(r(!0),h(m,null,i(U.sections,t=>(r(),h(`tr`,{key:t.key,"data-section":t.key},[g(`td`,P,[o(d(t.label)+` `,1),g(`span`,F,d(t.key),1)]),J(t)?(r(),h(m,{key:0},[(r(),h(m,null,i(G,e=>g(`td`,{key:e,class:`px-3 py-1.5 text-center`},[g(`input`,{type:`checkbox`,class:`h-4 w-4`,"data-permission":`${t.key}.${e}`,"aria-label":`${t.label}: ${u.$t(`permissions.actions.${e}`)}`,checked:q(t,e),onChange:n=>Q(t,e)},null,40,I)])),64)),c(X)?(r(),h(`td`,L,[(r(!0),h(m,null,i(Y(t),e=>(r(),h(`label`,{key:e,class:`inline-flex items-center gap-2 mr-3`},[g(`input`,{type:`checkbox`,class:`h-4 w-4`,"data-permission":`${t.key}.${e}`,checked:q(t,e),onChange:n=>Q(t,e)},null,40,ae),o(` `+d(Z(t,e)),1)]))),128))])):e(``,!0)],64)):(r(),h(`td`,{key:1,colspan:c(X)?5:4,class:`px-3 py-1.5`},[(r(!0),h(m,null,i(t.actions,e=>(r(),h(`label`,{key:e,class:`inline-flex items-center gap-2 mr-3`},[g(`input`,{type:`checkbox`,class:`h-4 w-4`,"data-permission":`${t.key}.${e}`,checked:q(t,e),onChange:n=>Q(t,e)},null,40,z),o(` `+d(Z(t,e)),1)]))),128))],8,R)),g(`td`,B,[g(`input`,{type:`checkbox`,class:`h-4 w-4`,"aria-label":`${t.label}: ${u.$t(`permissions.all`)}`,checked:$(t),onChange:e=>oe(t)},null,40,V)])],8,N))),128))])])])]),g(`div`,H,[t(v,{href:u.route(`admin.roles.index`),variant:`secondary`},{default:s(()=>[o(d(u.$t(`common.cancel`)),1)]),_:1},8,[`href`]),t(v,{"data-action":`save`,type:`submit`,loading:c(K).processing},{default:s(()=>[o(d(u.$t(`common.save`)),1)]),_:1},8,[`loading`])])],32)]),_:1})])]),_:1},8,[`title`]))}};export{U as default}; \ No newline at end of file +import{C as e,E as t,G as n,I as r,Q as i,R as a,S as o,T as s,W as c,_ as l,a as u,i as d,m as f,tt as p,v as m,w as h,x as g}from"./dist-Bie52OmN.js";import{t as _}from"./AdminLayout-DBeSErmz.js";import{t as v}from"./AdminButton-KiIJ2sLW.js";import{t as y}from"./AdminCard-YbEwPtJz.js";import{n as b}from"./app-BCJOqmKO.js";var x={class:`mb-6`},S={class:`max-w-4xl`},ee={class:`text-2xl font-bold text-fg mb-6`},te={for:`role-name`,class:`block text-sm font-medium text-fg mb-1`},ne={key:0,class:`mt-1 text-sm text-danger`},re={class:`flex flex-wrap items-center justify-between gap-2`},ie={class:`text-sm font-medium text-fg`},C={class:`flex gap-2`},w={class:`mt-1 text-sm text-muted`},T={key:0,class:`mt-1 text-sm text-danger`},E={class:`mt-2 overflow-x-auto border border-line rounded-md`},D={class:`min-w-full text-sm`},O={class:`bg-surface-alt`},k={class:`px-3 py-2 text-left font-medium text-fg`},A={key:0,class:`px-3 py-2 text-left font-medium text-fg`},j={class:`px-3 py-2 w-20 text-center font-medium text-fg`},M={class:`divide-y divide-line`},N=[`data-section`],P={class:`px-3 py-1.5`},F={class:`ml-1 text-xs text-muted font-mono`},I=[`data-permission`,`aria-label`,`checked`,`onChange`],L={key:0,class:`px-3 py-1.5`},ae=[`data-permission`,`checked`,`onChange`],R=[`colspan`],z=[`data-permission`,`checked`,`onChange`],B={class:`px-3 py-1.5 text-center`},V=[`aria-label`,`checked`,`onChange`],H={class:`flex items-center justify-end space-x-3 pt-4 border-t`},U={__name:`Edit`,props:{role:{type:Object,default:null},sections:{type:Array,required:!0},title:String},setup(U){let W=U,G=[`view`,`create`,`update`,`delete`],K=u({name:W.role?.name??``,permissions:[...W.role?.permissions??[]]}),q=(e,t)=>K.permissions.includes(`${e.key}.${t}`),J=e=>G.every(t=>e.actions.includes(t)),Y=e=>J(e)?e.actions.filter(e=>!G.includes(e)):[],X=W.sections.some(e=>Y(e).length>0),Z=(e,t)=>e.labels?.[t]??b(`permissions.actions.${t}`),Q=(e,t)=>{let n=new Set(K.permissions),r=`${e.key}.${t}`;n.has(r)?(n.delete(r),t===`view`&&G.forEach(t=>n.delete(`${e.key}.${t}`))):(n.add(r),J(e)&&G.includes(t)&&t!==`view`&&n.add(`${e.key}.view`)),K.permissions=[...n]},$=e=>e.actions.every(t=>q(e,t)),oe=e=>{let t=new Set(K.permissions),n=$(e);e.actions.forEach(r=>n?t.delete(`${e.key}.${r}`):t.add(`${e.key}.${r}`)),K.permissions=[...t]},se=()=>{K.permissions=W.sections.flatMap(e=>e.actions.map(t=>`${e.key}.${t}`))},ce=()=>{W.role?K.put(route(`admin.roles.update`,W.role.id)):K.post(route(`admin.roles.store`))};return(u,b)=>(r(),o(_,{title:U.title},{default:c(()=>[g(`div`,x,[t(i(d),{href:u.route(`admin.roles.index`),class:`text-muted hover:text-accent`},{default:c(()=>[s(p(u.$t(`menu.roles`)),1)]),_:1},8,[`href`])]),g(`div`,S,[g(`h1`,ee,p(U.title),1),t(y,null,{default:c(()=>[g(`form`,{class:`space-y-6`,"data-role-form":``,onSubmit:l(ce,[`prevent`])},[g(`div`,null,[g(`label`,te,[s(p(u.$t(`permissions.name`))+` `,1),b[2]||=g(`span`,{class:`text-danger`},`*`,-1)]),n(g(`input`,{id:`role-name`,"onUpdate:modelValue":b[0]||=e=>i(K).name=e,type:`text`,required:``,class:`w-full px-3 py-2 border border-field rounded-md shadow-sm focus:ring-focus focus:border-focus`},null,512),[[f,i(K).name]]),i(K).errors.name?(r(),h(`p`,ne,p(i(K).errors.name),1)):e(``,!0)]),g(`div`,null,[g(`div`,re,[g(`span`,ie,p(u.$t(`permissions.permissions`)),1),g(`div`,C,[t(v,{type:`button`,size:`sm`,variant:`outline`,onClick:se},{default:c(()=>[s(p(u.$t(`permissions.select_all`)),1)]),_:1}),t(v,{type:`button`,size:`sm`,variant:`outline`,onClick:b[1]||=e=>i(K).permissions=[]},{default:c(()=>[s(p(u.$t(`permissions.clear`)),1)]),_:1})])]),g(`p`,w,p(u.$t(`permissions.matrix_hint`)),1),i(K).errors.permissions?(r(),h(`p`,T,p(i(K).errors.permissions),1)):e(``,!0),g(`div`,E,[g(`table`,D,[g(`thead`,O,[g(`tr`,null,[g(`th`,k,p(u.$t(`permissions.section`)),1),(r(),h(m,null,a(G,e=>g(`th`,{key:e,class:`px-3 py-2 w-24 text-center font-medium text-fg`},p(u.$t(`permissions.actions.${e}`)),1)),64)),i(X)?(r(),h(`th`,A,p(u.$t(`permissions.other`)),1)):e(``,!0),g(`th`,j,p(u.$t(`permissions.all`)),1)])]),g(`tbody`,M,[(r(!0),h(m,null,a(U.sections,t=>(r(),h(`tr`,{key:t.key,"data-section":t.key},[g(`td`,P,[s(p(t.label)+` `,1),g(`span`,F,p(t.key),1)]),J(t)?(r(),h(m,{key:0},[(r(),h(m,null,a(G,e=>g(`td`,{key:e,class:`px-3 py-1.5 text-center`},[g(`input`,{type:`checkbox`,class:`h-4 w-4`,"data-permission":`${t.key}.${e}`,"aria-label":`${t.label}: ${u.$t(`permissions.actions.${e}`)}`,checked:q(t,e),onChange:n=>Q(t,e)},null,40,I)])),64)),i(X)?(r(),h(`td`,L,[(r(!0),h(m,null,a(Y(t),e=>(r(),h(`label`,{key:e,class:`inline-flex items-center gap-2 mr-3`},[g(`input`,{type:`checkbox`,class:`h-4 w-4`,"data-permission":`${t.key}.${e}`,checked:q(t,e),onChange:n=>Q(t,e)},null,40,ae),s(` `+p(Z(t,e)),1)]))),128))])):e(``,!0)],64)):(r(),h(`td`,{key:1,colspan:i(X)?5:4,class:`px-3 py-1.5`},[(r(!0),h(m,null,a(t.actions,e=>(r(),h(`label`,{key:e,class:`inline-flex items-center gap-2 mr-3`},[g(`input`,{type:`checkbox`,class:`h-4 w-4`,"data-permission":`${t.key}.${e}`,checked:q(t,e),onChange:n=>Q(t,e)},null,40,z),s(` `+p(Z(t,e)),1)]))),128))],8,R)),g(`td`,B,[g(`input`,{type:`checkbox`,class:`h-4 w-4`,"aria-label":`${t.label}: ${u.$t(`permissions.all`)}`,checked:$(t),onChange:e=>oe(t)},null,40,V)])],8,N))),128))])])])]),g(`div`,H,[t(v,{href:u.route(`admin.roles.index`),variant:`secondary`},{default:c(()=>[s(p(u.$t(`common.cancel`)),1)]),_:1},8,[`href`]),t(v,{"data-action":`save`,type:`submit`,loading:i(K).processing},{default:c(()=>[s(p(u.$t(`common.save`)),1)]),_:1},8,[`loading`])])],32)]),_:1})])]),_:1},8,[`title`]))}};export{U as default}; \ No newline at end of file diff --git a/packages/admin/dist/assets/Edit-CHndUQJ2.js b/packages/admin/dist/assets/Edit-CHndUQJ2.js deleted file mode 100644 index 42835efe..00000000 --- a/packages/admin/dist/assets/Edit-CHndUQJ2.js +++ /dev/null @@ -1 +0,0 @@ -import{C as e,E as t,I as n,L as r,R as i,S as a,T as o,W as s,Y as c,Z as l,_ as u,a as d,b as f,et as p,i as m,q as h,v as g,w as _,x as v}from"./dist-MY__znoP.js";import{t as y}from"./AdminLayout--RXJFj9t.js";import{t as b}from"./AdminButton-Bx141Bs3.js";import{t as x}from"./AdminCard--HubMtUj.js";import{n as S,r as C,t as w}from"./ContentLocaleSwitcher-BJIieXK-.js";import{t as T}from"./FormField-xD6LELDV.js";import{n as E,r as ee,t as D}from"./contentLocale-BtGD-iBF.js";import{t as O}from"./recordActions-CtRs42tG.js";var k={class:`mb-6`},A={class:`flex`,"aria-label":`Breadcrumb`},j={class:`inline-flex items-center space-x-1 md:space-x-3`},M={class:`inline-flex items-center`},N={class:`flex items-center`},P={class:`ml-1 text-muted`},F={class:`max-w-4xl`},I={class:`mb-6 flex flex-wrap items-center justify-between gap-4`},L={class:`text-2xl font-bold text-fg`},R={key:0,class:`flex gap-2`},z={key:0,"data-read-only":``,class:`mb-6 rounded-md border border-field bg-surface-alt px-4 py-3 text-sm text-fg`},B=[`data-resource`,`data-item-id`],V=[`disabled`],H={class:`space-y-6`},te={key:0,class:`text-center py-12 text-muted`},U={key:2,class:`space-y-6`},W={class:`flex items-center justify-end space-x-3 pt-6 mt-6 border-t`},G={__name:`Edit`,props:{routeName:String,createLabel:String,item:Object,itemTitle:String,fields:Array,fieldsByTab:Object,tabs:Array,useTabs:Boolean,title:String,adminLabel:String,can:{type:Object,default:()=>({})},actions:{type:Array,default:()=>[]}},setup(G){let K=G,q=f(()=>K.can.update===!1),J=c(K.tabs?.[0]?.name||`main`),Y={};K.useTabs&&K.fieldsByTab?Object.values(K.fieldsByTab).flat().forEach(e=>{Y[e.name]=E(e,K.item[e.name])}):K.fields.forEach(e=>{Y[e.name]=E(e,K.item[e.name])});let X=d(Y),Z=()=>(K.useTabs&&K.fieldsByTab?Object.values(K.fieldsByTab).flat():K.fields)||[],{locale:Q,locales:ne,showSwitcher:re}=ee(Z),ie=f(()=>({...K.item,...X.data()}));r(`formData`,ie),r(`aiModule`,K.routeName?.replace(/^admin\./,``)||null);let ae=()=>{X.submit(`put`,route(`${K.routeName}.update`,K.item.id))},$=e=>K.fieldsByTab?.[e]?K.fieldsByTab[e].filter(e=>D(X.errors,e)).length:0,oe=f(()=>K.tabs?K.tabs.map(e=>({...e,badge:$(e.name)>0?String($(e.name)):null})):[]);return(r,c)=>(n(),a(y,{title:G.title},{default:s(()=>[v(`div`,k,[v(`nav`,A,[v(`ol`,j,[v(`li`,M,[t(l(m),{href:r.route(`${K.routeName}.index`),class:`text-muted hover:text-accent`},{default:s(()=>[o(p(G.adminLabel),1)]),_:1},8,[`href`])]),v(`li`,null,[v(`div`,N,[c[2]||=v(`svg`,{class:`w-4 h-4 text-muted`,fill:`currentColor`,viewBox:`0 0 20 20`},[v(`path`,{"fill-rule":`evenodd`,d:`M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z`,"clip-rule":`evenodd`})],-1),v(`span`,P,p(G.itemTitle||`#`+G.item.id),1)])])])])]),v(`div`,F,[v(`div`,I,[v(`h1`,L,p(G.title),1),G.actions.length?(n(),_(`div`,R,[(n(!0),_(g,null,i(G.actions,e=>(n(),a(b,{key:e.name,"data-action":e.name,variant:`secondary`,href:l(O)(G.routeName,e,G.item)},{default:s(()=>[o(p(e.label),1)]),_:2},1032,[`data-action`,`href`]))),128))])):e(``,!0)]),t(x,null,{default:s(()=>[q.value?(n(),_(`p`,z,p(r.$t(`resource.form.read_only`)),1)):e(``,!0),v(`form`,{onSubmit:u(ae,[`prevent`]),"data-admin-form":`true`,"data-resource":G.routeName,"data-context":`edit`,"data-item-id":G.item.id},[v(`fieldset`,{disabled:q.value,class:`contents`},[l(re)?(n(),a(w,{key:0,modelValue:l(Q),"onUpdate:modelValue":c[0]||=e=>h(Q)?Q.value=e:null,locales:l(ne),fields:Z(),errors:l(X).errors},null,8,[`modelValue`,`locales`,`fields`,`errors`])):e(``,!0),G.useTabs&&G.tabs&&G.fieldsByTab?(n(),a(C,{key:1,tabs:oe.value,modelValue:J.value,"onUpdate:modelValue":c[1]||=e=>J.value=e},{default:s(({activeTab:t})=>[(n(!0),_(g,null,i(G.tabs,o=>(n(),a(S,{key:o.name,name:o.name,activeTab:t},{default:s(()=>[v(`div`,H,[(n(!0),_(g,null,i(G.fieldsByTab[o.name],e=>(n(),a(T,{key:e.name,field:e,modelValue:l(X)[e.name],"onUpdate:modelValue":t=>l(X)[e.name]=t,errors:l(X).errors},null,8,[`field`,`modelValue`,`onUpdate:modelValue`,`errors`]))),128)),G.fieldsByTab[o.name]?.length?e(``,!0):(n(),_(`div`,te,[v(`p`,null,p(r.$t(`resource.form.empty_tab`)),1)]))])]),_:2},1032,[`name`,`activeTab`]))),128))]),_:1},8,[`tabs`,`modelValue`])):(n(),_(`div`,U,[(n(!0),_(g,null,i(G.fields,e=>(n(),a(T,{key:e.name,field:e,modelValue:l(X)[e.name],"onUpdate:modelValue":t=>l(X)[e.name]=t,errors:l(X).errors},null,8,[`field`,`modelValue`,`onUpdate:modelValue`,`errors`]))),128))]))],8,V),v(`div`,W,[t(b,{"data-action":`cancel`,href:r.route(`${K.routeName}.index`),variant:`secondary`},{default:s(()=>[o(p(q.value?r.$t(`common.back`):r.$t(`common.cancel`)),1)]),_:1},8,[`href`]),q.value?e(``,!0):(n(),a(b,{key:0,"data-action":`save`,type:`submit`,loading:l(X).processing},{default:s(()=>[o(p(r.$t(`common.save`)),1)]),_:1},8,[`loading`]))])],40,B)]),_:1})])]),_:1},8,[`title`]))}};export{G as default}; \ No newline at end of file diff --git a/packages/admin/dist/assets/Edit-Cp-LIO0D.js b/packages/admin/dist/assets/Edit-Cp-LIO0D.js new file mode 100644 index 00000000..f15a7b11 --- /dev/null +++ b/packages/admin/dist/assets/Edit-Cp-LIO0D.js @@ -0,0 +1 @@ +import{$ as e,C as t,E as n,G as r,I as i,L as a,Q as o,R as s,S as c,T as l,W as u,_ as d,a as f,b as p,d as m,i as h,tt as g,u as _,v,w as y,x as b}from"./dist-Bie52OmN.js";import{t as x}from"./AdminLayout-DBeSErmz.js";import{t as S}from"./AdminButton-KiIJ2sLW.js";import{t as C}from"./AdminCard-YbEwPtJz.js";import{t as w}from"./FormField-B-XX4VFv.js";var T={class:`mb-6`},E={class:`flex`,"aria-label":`Breadcrumb`},D={class:`inline-flex items-center space-x-1 md:space-x-3`},O={class:`inline-flex items-center`},k={class:`flex items-center`},A={class:`ml-1 text-muted`},j={class:`max-w-2xl`},M={class:`text-2xl font-bold text-fg mb-6`},N={key:0,"data-read-only":``,class:`mb-6 rounded-md border border-field bg-surface-alt px-4 py-3 text-sm text-fg`},P=[`disabled`],F={key:1},I=[`for`],L={key:0,class:`text-danger`},R={key:0,class:`flex items-center`},z=[`id`,`onUpdate:modelValue`],B=[`for`],V=[`id`,`onUpdate:modelValue`,`type`,`placeholder`,`required`],H={key:2,class:`mt-1 text-sm text-muted`},U={key:3,class:`mt-1 text-sm text-muted`},W={key:4,class:`mt-1 text-sm text-danger`},G={class:`flex items-center justify-end space-x-3 pt-4 border-t`},K={__name:`Edit`,props:{item:Object,fields:Array,title:String,can:{type:Object,default:()=>({})}},setup(K){let q=K,J=e=>[`text`,`email`,`password`,`checkbox`].includes(e.type),Y=p(()=>q.can.update===!1),X={};q.fields.forEach(e=>{X[e.name]=q.item[e.name]??e.default??``}),X.password=``,X.password_confirmation=``;let Z=f(X),Q=p(()=>({...q.item,...Z.data()}));a(`formData`,Q);let $=()=>{Z.put(route(`admin.users.update`,q.item.id))};return(a,f)=>(i(),c(x,{title:K.title},{default:u(()=>[b(`div`,T,[b(`nav`,E,[b(`ol`,D,[b(`li`,O,[n(o(h),{href:a.route(`admin.users.index`),class:`text-muted hover:text-accent`},{default:u(()=>[l(g(a.$t(`menu.administrators`)),1)]),_:1},8,[`href`])]),b(`li`,null,[b(`div`,k,[f[0]||=b(`svg`,{class:`w-4 h-4 text-muted`,fill:`currentColor`,viewBox:`0 0 20 20`},[b(`path`,{"fill-rule":`evenodd`,d:`M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z`,"clip-rule":`evenodd`})],-1),b(`span`,A,g(K.item.name),1)])])])])]),b(`div`,j,[b(`h1`,M,g(K.title),1),n(C,null,{default:u(()=>[Y.value?(i(),y(`p`,N,g(a.$t(`resource.form.read_only`)),1)):t(``,!0),b(`form`,{onSubmit:d($,[`prevent`]),class:`space-y-6`},[b(`fieldset`,{disabled:Y.value,class:`space-y-6`},[(i(!0),y(v,null,s(K.fields,n=>(i(),y(v,{key:n.name},[J(n)?(i(),y(`div`,F,[b(`label`,{for:n.name,class:`block text-sm font-medium text-fg mb-1`},[l(g(n.label)+` `,1),n.required&&n.type!==`password`?(i(),y(`span`,L,`*`)):t(``,!0)],8,I),n.type===`checkbox`?(i(),y(`div`,R,[r(b(`input`,{id:n.name,"onUpdate:modelValue":e=>o(Z)[n.name]=e,type:`checkbox`,class:`h-4 w-4 text-accent focus:ring-focus border-field rounded`},null,8,z),[[_,o(Z)[n.name]]]),b(`label`,{for:n.name,class:`ml-2 text-sm text-fg`},g(n.label),9,B)])):r((i(),y(`input`,{key:1,id:n.name,"onUpdate:modelValue":e=>o(Z)[n.name]=e,type:n.type===`password`?`password`:n.type===`email`?`email`:`text`,placeholder:n.type===`password`?a.$t(`account.users.password_keep_placeholder`):n.placeholder,required:n.required&&n.type!==`password`,class:e([`w-full px-3 py-2 border border-field rounded-md shadow-sm focus:ring-focus focus:border-focus`,{"border-danger":o(Z).errors[n.name]}])},null,10,V)),[[m,o(Z)[n.name]]]),n.hint?(i(),y(`p`,H,g(n.hint),1)):t(``,!0),n.type===`password`&&n.name===`password`?(i(),y(`p`,U,g(a.$t(`account.users.password_keep_hint`)),1)):t(``,!0),o(Z).errors[n.name]?(i(),y(`p`,W,g(o(Z).errors[n.name]),1)):t(``,!0)])):(i(),c(w,{key:0,field:n,modelValue:o(Z)[n.name],"onUpdate:modelValue":e=>o(Z)[n.name]=e,errors:o(Z).errors},null,8,[`field`,`modelValue`,`onUpdate:modelValue`,`errors`]))],64))),128))],8,P),b(`div`,G,[n(S,{href:a.route(`admin.users.index`),variant:`secondary`},{default:u(()=>[l(g(Y.value?a.$t(`common.back`):a.$t(`common.cancel`)),1)]),_:1},8,[`href`]),Y.value?t(``,!0):(i(),c(S,{key:0,"data-action":`save`,type:`submit`,loading:o(Z).processing},{default:u(()=>[l(g(a.$t(`common.save`)),1)]),_:1},8,[`loading`]))])],32)]),_:1})])]),_:1},8,[`title`]))}};export{K as default}; \ No newline at end of file diff --git a/packages/admin/dist/assets/Edit-D-yhP5A2.js b/packages/admin/dist/assets/Edit-CyzBsvwt.js similarity index 51% rename from packages/admin/dist/assets/Edit-D-yhP5A2.js rename to packages/admin/dist/assets/Edit-CyzBsvwt.js index 1a7d4f85..ff7eef0e 100644 --- a/packages/admin/dist/assets/Edit-D-yhP5A2.js +++ b/packages/admin/dist/assets/Edit-CyzBsvwt.js @@ -1 +1 @@ -import{C as e,G as t,I as n,Q as r,S as i,W as a,Z as o,_ as s,a as c,et as l,m as u,w as d,x as f}from"./dist-MY__znoP.js";import{t as p}from"./AdminLayout--RXJFj9t.js";var m={class:`mb-8`},h={class:`text-2xl font-bold text-fg`},g={class:`mt-1 text-sm text-muted`},_={class:`max-w-2xl space-y-6`},v={class:`bg-surface rounded-lg shadow`},y={class:`p-6 border-b border-line`},b={class:`text-lg font-medium text-fg`},x={class:`mt-1 text-sm text-muted`},S={for:`name`,class:`block text-sm font-medium text-fg`},C={key:0,class:`mt-1 text-sm text-danger`},w={for:`email`,class:`block text-sm font-medium text-fg`},T={key:0,class:`mt-1 text-sm text-danger`},E={class:`flex justify-end`},D=[`disabled`],O={class:`bg-surface rounded-lg shadow`},k={class:`p-6 border-b border-line`},A={class:`text-lg font-medium text-fg`},j={class:`mt-1 text-sm text-muted`},M={for:`current_password`,class:`block text-sm font-medium text-fg`},N={key:0,class:`mt-1 text-sm text-danger`},P={for:`password`,class:`block text-sm font-medium text-fg`},F={key:0,class:`mt-1 text-sm text-danger`},I={for:`password_confirmation`,class:`block text-sm font-medium text-fg`},L={class:`flex justify-end`},R=[`disabled`],z={__name:`Edit`,props:{user:{type:Object,required:!0}},setup(z){let B=z,V=c({name:B.user.name,email:B.user.email}),H=c({current_password:``,password:``,password_confirmation:``}),U=()=>{V.put(route(`admin.profile.update`),{preserveScroll:!0})},W=()=>{H.put(route(`admin.profile.password`),{preserveScroll:!0,onSuccess:()=>H.reset()})};return(c,z)=>(n(),i(p,{title:c.$t(`account.profile.title`)},{default:a(()=>[f(`div`,m,[f(`h1`,h,l(c.$t(`account.profile.title`)),1),f(`p`,g,l(c.$t(`account.profile.subtitle`)),1)]),f(`div`,_,[f(`div`,v,[f(`div`,y,[f(`h2`,b,l(c.$t(`account.profile.info_title`)),1),f(`p`,x,l(c.$t(`account.profile.info_subtitle`)),1)]),f(`form`,{onSubmit:s(U,[`prevent`]),class:`p-6 space-y-4`},[f(`div`,null,[f(`label`,S,l(c.$t(`account.profile.name`)),1),t(f(`input`,{id:`name`,"onUpdate:modelValue":z[0]||=e=>o(V).name=e,type:`text`,class:r([`mt-1 block w-full px-3 py-2 border border-field rounded-md shadow-sm focus:outline-none focus:ring-focus focus:border-focus sm:text-sm`,{"border-danger":o(V).errors.name}])},null,2),[[u,o(V).name]]),o(V).errors.name?(n(),d(`p`,C,l(o(V).errors.name),1)):e(``,!0)]),f(`div`,null,[f(`label`,w,l(c.$t(`account.profile.email`)),1),t(f(`input`,{id:`email`,"onUpdate:modelValue":z[1]||=e=>o(V).email=e,type:`email`,class:r([`mt-1 block w-full px-3 py-2 border border-field rounded-md shadow-sm focus:outline-none focus:ring-focus focus:border-focus sm:text-sm`,{"border-danger":o(V).errors.email}])},null,2),[[u,o(V).email]]),o(V).errors.email?(n(),d(`p`,T,l(o(V).errors.email),1)):e(``,!0)]),f(`div`,E,[f(`button`,{type:`submit`,disabled:o(V).processing,class:`px-4 py-2 bg-accent text-on-accent text-sm font-medium rounded-md hover:bg-accent-hover focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-focus disabled:opacity-50`},l(o(V).processing?c.$t(`common.saving`):c.$t(`common.save`)),9,D)])],32)]),f(`div`,O,[f(`div`,k,[f(`h2`,A,l(c.$t(`account.profile.password_title`)),1),f(`p`,j,l(c.$t(`account.profile.password_subtitle`)),1)]),f(`form`,{onSubmit:s(W,[`prevent`]),class:`p-6 space-y-4`},[f(`div`,null,[f(`label`,M,l(c.$t(`account.profile.current_password`)),1),t(f(`input`,{id:`current_password`,"onUpdate:modelValue":z[2]||=e=>o(H).current_password=e,type:`password`,class:r([`mt-1 block w-full px-3 py-2 border border-field rounded-md shadow-sm focus:outline-none focus:ring-focus focus:border-focus sm:text-sm`,{"border-danger":o(H).errors.current_password}])},null,2),[[u,o(H).current_password]]),o(H).errors.current_password?(n(),d(`p`,N,l(o(H).errors.current_password),1)):e(``,!0)]),f(`div`,null,[f(`label`,P,l(c.$t(`account.profile.new_password`)),1),t(f(`input`,{id:`password`,"onUpdate:modelValue":z[3]||=e=>o(H).password=e,type:`password`,class:r([`mt-1 block w-full px-3 py-2 border border-field rounded-md shadow-sm focus:outline-none focus:ring-focus focus:border-focus sm:text-sm`,{"border-danger":o(H).errors.password}])},null,2),[[u,o(H).password]]),o(H).errors.password?(n(),d(`p`,F,l(o(H).errors.password),1)):e(``,!0)]),f(`div`,null,[f(`label`,I,l(c.$t(`account.profile.password_confirmation`)),1),t(f(`input`,{id:`password_confirmation`,"onUpdate:modelValue":z[4]||=e=>o(H).password_confirmation=e,type:`password`,class:`mt-1 block w-full px-3 py-2 border border-field rounded-md shadow-sm focus:outline-none focus:ring-focus focus:border-focus sm:text-sm`},null,512),[[u,o(H).password_confirmation]])]),f(`div`,L,[f(`button`,{type:`submit`,disabled:o(H).processing,class:`px-4 py-2 bg-accent text-on-accent text-sm font-medium rounded-md hover:bg-accent-hover focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-focus disabled:opacity-50`},l(o(H).processing?c.$t(`common.saving`):c.$t(`account.profile.change_password`)),9,R)])],32)])])]),_:1},8,[`title`]))}};export{z as default}; \ No newline at end of file +import{$ as e,C as t,G as n,I as r,Q as i,S as a,W as o,_ as s,a as c,m as l,tt as u,w as d,x as f}from"./dist-Bie52OmN.js";import{t as p}from"./AdminLayout-DBeSErmz.js";var m={class:`mb-8`},h={class:`text-2xl font-bold text-fg`},g={class:`mt-1 text-sm text-muted`},_={class:`max-w-2xl space-y-6`},v={class:`bg-surface rounded-lg shadow`},y={class:`p-6 border-b border-line`},b={class:`text-lg font-medium text-fg`},x={class:`mt-1 text-sm text-muted`},S={for:`name`,class:`block text-sm font-medium text-fg`},C={key:0,class:`mt-1 text-sm text-danger`},w={for:`email`,class:`block text-sm font-medium text-fg`},T={key:0,class:`mt-1 text-sm text-danger`},E={class:`flex justify-end`},D=[`disabled`],O={class:`bg-surface rounded-lg shadow`},k={class:`p-6 border-b border-line`},A={class:`text-lg font-medium text-fg`},j={class:`mt-1 text-sm text-muted`},M={for:`current_password`,class:`block text-sm font-medium text-fg`},N={key:0,class:`mt-1 text-sm text-danger`},P={for:`password`,class:`block text-sm font-medium text-fg`},F={key:0,class:`mt-1 text-sm text-danger`},I={for:`password_confirmation`,class:`block text-sm font-medium text-fg`},L={class:`flex justify-end`},R=[`disabled`],z={__name:`Edit`,props:{user:{type:Object,required:!0}},setup(z){let B=z,V=c({name:B.user.name,email:B.user.email}),H=c({current_password:``,password:``,password_confirmation:``}),U=()=>{V.put(route(`admin.profile.update`),{preserveScroll:!0})},W=()=>{H.put(route(`admin.profile.password`),{preserveScroll:!0,onSuccess:()=>H.reset()})};return(c,z)=>(r(),a(p,{title:c.$t(`account.profile.title`)},{default:o(()=>[f(`div`,m,[f(`h1`,h,u(c.$t(`account.profile.title`)),1),f(`p`,g,u(c.$t(`account.profile.subtitle`)),1)]),f(`div`,_,[f(`div`,v,[f(`div`,y,[f(`h2`,b,u(c.$t(`account.profile.info_title`)),1),f(`p`,x,u(c.$t(`account.profile.info_subtitle`)),1)]),f(`form`,{onSubmit:s(U,[`prevent`]),class:`p-6 space-y-4`},[f(`div`,null,[f(`label`,S,u(c.$t(`account.profile.name`)),1),n(f(`input`,{id:`name`,"onUpdate:modelValue":z[0]||=e=>i(V).name=e,type:`text`,class:e([`mt-1 block w-full px-3 py-2 border border-field rounded-md shadow-sm focus:outline-none focus:ring-focus focus:border-focus sm:text-sm`,{"border-danger":i(V).errors.name}])},null,2),[[l,i(V).name]]),i(V).errors.name?(r(),d(`p`,C,u(i(V).errors.name),1)):t(``,!0)]),f(`div`,null,[f(`label`,w,u(c.$t(`account.profile.email`)),1),n(f(`input`,{id:`email`,"onUpdate:modelValue":z[1]||=e=>i(V).email=e,type:`email`,class:e([`mt-1 block w-full px-3 py-2 border border-field rounded-md shadow-sm focus:outline-none focus:ring-focus focus:border-focus sm:text-sm`,{"border-danger":i(V).errors.email}])},null,2),[[l,i(V).email]]),i(V).errors.email?(r(),d(`p`,T,u(i(V).errors.email),1)):t(``,!0)]),f(`div`,E,[f(`button`,{type:`submit`,disabled:i(V).processing,class:`px-4 py-2 bg-accent text-on-accent text-sm font-medium rounded-md hover:bg-accent-hover focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-focus disabled:opacity-50`},u(i(V).processing?c.$t(`common.saving`):c.$t(`common.save`)),9,D)])],32)]),f(`div`,O,[f(`div`,k,[f(`h2`,A,u(c.$t(`account.profile.password_title`)),1),f(`p`,j,u(c.$t(`account.profile.password_subtitle`)),1)]),f(`form`,{onSubmit:s(W,[`prevent`]),class:`p-6 space-y-4`},[f(`div`,null,[f(`label`,M,u(c.$t(`account.profile.current_password`)),1),n(f(`input`,{id:`current_password`,"onUpdate:modelValue":z[2]||=e=>i(H).current_password=e,type:`password`,class:e([`mt-1 block w-full px-3 py-2 border border-field rounded-md shadow-sm focus:outline-none focus:ring-focus focus:border-focus sm:text-sm`,{"border-danger":i(H).errors.current_password}])},null,2),[[l,i(H).current_password]]),i(H).errors.current_password?(r(),d(`p`,N,u(i(H).errors.current_password),1)):t(``,!0)]),f(`div`,null,[f(`label`,P,u(c.$t(`account.profile.new_password`)),1),n(f(`input`,{id:`password`,"onUpdate:modelValue":z[3]||=e=>i(H).password=e,type:`password`,class:e([`mt-1 block w-full px-3 py-2 border border-field rounded-md shadow-sm focus:outline-none focus:ring-focus focus:border-focus sm:text-sm`,{"border-danger":i(H).errors.password}])},null,2),[[l,i(H).password]]),i(H).errors.password?(r(),d(`p`,F,u(i(H).errors.password),1)):t(``,!0)]),f(`div`,null,[f(`label`,I,u(c.$t(`account.profile.password_confirmation`)),1),n(f(`input`,{id:`password_confirmation`,"onUpdate:modelValue":z[4]||=e=>i(H).password_confirmation=e,type:`password`,class:`mt-1 block w-full px-3 py-2 border border-field rounded-md shadow-sm focus:outline-none focus:ring-focus focus:border-focus sm:text-sm`},null,512),[[l,i(H).password_confirmation]])]),f(`div`,L,[f(`button`,{type:`submit`,disabled:i(H).processing,class:`px-4 py-2 bg-accent text-on-accent text-sm font-medium rounded-md hover:bg-accent-hover focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-focus disabled:opacity-50`},u(i(H).processing?c.$t(`common.saving`):c.$t(`account.profile.change_password`)),9,R)])],32)])])]),_:1},8,[`title`]))}};export{z as default}; \ No newline at end of file diff --git a/packages/admin/dist/assets/Edit-DGjzU-uC.js b/packages/admin/dist/assets/Edit-DGjzU-uC.js deleted file mode 100644 index 6ca4030c..00000000 --- a/packages/admin/dist/assets/Edit-DGjzU-uC.js +++ /dev/null @@ -1 +0,0 @@ -import{C as e,E as t,G as n,I as r,L as i,Q as a,R as o,S as s,T as c,W as l,Z as u,_ as d,a as f,b as p,d as m,et as h,i as g,u as _,v,w as y,x as b}from"./dist-MY__znoP.js";import{t as x}from"./AdminLayout--RXJFj9t.js";import{t as S}from"./AdminButton-Bx141Bs3.js";import{t as C}from"./AdminCard--HubMtUj.js";import{t as w}from"./FormField-xD6LELDV.js";var T={class:`mb-6`},E={class:`flex`,"aria-label":`Breadcrumb`},D={class:`inline-flex items-center space-x-1 md:space-x-3`},O={class:`inline-flex items-center`},k={class:`flex items-center`},A={class:`ml-1 text-muted`},j={class:`max-w-2xl`},M={class:`text-2xl font-bold text-fg mb-6`},N={key:0,"data-read-only":``,class:`mb-6 rounded-md border border-field bg-surface-alt px-4 py-3 text-sm text-fg`},P=[`disabled`],F={key:1},I=[`for`],L={key:0,class:`text-danger`},R={key:0,class:`flex items-center`},z=[`id`,`onUpdate:modelValue`],B=[`for`],V=[`id`,`onUpdate:modelValue`,`type`,`placeholder`,`required`],H={key:2,class:`mt-1 text-sm text-muted`},U={key:3,class:`mt-1 text-sm text-muted`},W={key:4,class:`mt-1 text-sm text-danger`},G={class:`flex items-center justify-end space-x-3 pt-4 border-t`},K={__name:`Edit`,props:{item:Object,fields:Array,title:String,can:{type:Object,default:()=>({})}},setup(K){let q=K,J=e=>[`text`,`email`,`password`,`checkbox`].includes(e.type),Y=p(()=>q.can.update===!1),X={};q.fields.forEach(e=>{X[e.name]=q.item[e.name]??e.default??``}),X.password=``,X.password_confirmation=``;let Z=f(X),Q=p(()=>({...q.item,...Z.data()}));i(`formData`,Q);let $=()=>{Z.put(route(`admin.users.update`,q.item.id))};return(i,f)=>(r(),s(x,{title:K.title},{default:l(()=>[b(`div`,T,[b(`nav`,E,[b(`ol`,D,[b(`li`,O,[t(u(g),{href:i.route(`admin.users.index`),class:`text-muted hover:text-accent`},{default:l(()=>[c(h(i.$t(`menu.administrators`)),1)]),_:1},8,[`href`])]),b(`li`,null,[b(`div`,k,[f[0]||=b(`svg`,{class:`w-4 h-4 text-muted`,fill:`currentColor`,viewBox:`0 0 20 20`},[b(`path`,{"fill-rule":`evenodd`,d:`M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z`,"clip-rule":`evenodd`})],-1),b(`span`,A,h(K.item.name),1)])])])])]),b(`div`,j,[b(`h1`,M,h(K.title),1),t(C,null,{default:l(()=>[Y.value?(r(),y(`p`,N,h(i.$t(`resource.form.read_only`)),1)):e(``,!0),b(`form`,{onSubmit:d($,[`prevent`]),class:`space-y-6`},[b(`fieldset`,{disabled:Y.value,class:`space-y-6`},[(r(!0),y(v,null,o(K.fields,t=>(r(),y(v,{key:t.name},[J(t)?(r(),y(`div`,F,[b(`label`,{for:t.name,class:`block text-sm font-medium text-fg mb-1`},[c(h(t.label)+` `,1),t.required&&t.type!==`password`?(r(),y(`span`,L,`*`)):e(``,!0)],8,I),t.type===`checkbox`?(r(),y(`div`,R,[n(b(`input`,{id:t.name,"onUpdate:modelValue":e=>u(Z)[t.name]=e,type:`checkbox`,class:`h-4 w-4 text-accent focus:ring-focus border-field rounded`},null,8,z),[[_,u(Z)[t.name]]]),b(`label`,{for:t.name,class:`ml-2 text-sm text-fg`},h(t.label),9,B)])):n((r(),y(`input`,{key:1,id:t.name,"onUpdate:modelValue":e=>u(Z)[t.name]=e,type:t.type===`password`?`password`:t.type===`email`?`email`:`text`,placeholder:t.type===`password`?i.$t(`account.users.password_keep_placeholder`):t.placeholder,required:t.required&&t.type!==`password`,class:a([`w-full px-3 py-2 border border-field rounded-md shadow-sm focus:ring-focus focus:border-focus`,{"border-danger":u(Z).errors[t.name]}])},null,10,V)),[[m,u(Z)[t.name]]]),t.hint?(r(),y(`p`,H,h(t.hint),1)):e(``,!0),t.type===`password`&&t.name===`password`?(r(),y(`p`,U,h(i.$t(`account.users.password_keep_hint`)),1)):e(``,!0),u(Z).errors[t.name]?(r(),y(`p`,W,h(u(Z).errors[t.name]),1)):e(``,!0)])):(r(),s(w,{key:0,field:t,modelValue:u(Z)[t.name],"onUpdate:modelValue":e=>u(Z)[t.name]=e,errors:u(Z).errors},null,8,[`field`,`modelValue`,`onUpdate:modelValue`,`errors`]))],64))),128))],8,P),b(`div`,G,[t(S,{href:i.route(`admin.users.index`),variant:`secondary`},{default:l(()=>[c(h(Y.value?i.$t(`common.back`):i.$t(`common.cancel`)),1)]),_:1},8,[`href`]),Y.value?e(``,!0):(r(),s(S,{key:0,"data-action":`save`,type:`submit`,loading:u(Z).processing},{default:l(()=>[c(h(i.$t(`common.save`)),1)]),_:1},8,[`loading`]))])],32)]),_:1})])]),_:1},8,[`title`]))}};export{K as default}; \ No newline at end of file diff --git a/packages/admin/dist/assets/FormField-xD6LELDV.js b/packages/admin/dist/assets/FormField-B-XX4VFv.js similarity index 50% rename from packages/admin/dist/assets/FormField-xD6LELDV.js rename to packages/admin/dist/assets/FormField-B-XX4VFv.js index 9e944d07..c4ca012a 100644 --- a/packages/admin/dist/assets/FormField-xD6LELDV.js +++ b/packages/admin/dist/assets/FormField-B-XX4VFv.js @@ -1,27 +1,27 @@ -import{$ as e,A as t,B as n,C as r,D as i,E as a,F as o,G as s,H as c,I as l,J as u,K as d,M as f,N as p,O as m,P as h,Q as g,R as _,S as v,T as y,U as b,V as x,W as S,X as C,Y as w,Z as T,_ as E,b as D,c as ee,d as te,et as O,f as ne,g as k,h as re,j as ie,k as ae,m as oe,o as se,p as ce,u as le,v as A,w as j,x as M,y as ue,z as N}from"./dist-MY__znoP.js";import{n as P}from"./app-BNjy5Z6H.js";import{i as de,n as fe,r as pe}from"./AdminLayout--RXJFj9t.js";import{t as me}from"./AdminModal-DNJ_V4iq.js";import{t as he}from"./AdminButton-Bx141Bs3.js";var ge=Object.defineProperty,_e=(e,t)=>{let n={};for(var r in e)ge(n,r,{get:e[r],enumerable:!0});return t||ge(n,Symbol.toStringTag,{value:`Module`}),n};function ve(e){this.content=e}ve.prototype={constructor:ve,find:function(e){for(var t=0;t>1}},ve.from=function(e){if(e instanceof ve)return e;var t=[];if(e)for(var n in e)t.push(n,e[n]);return new ve(t)};function ye(e,t,n){for(let r=0;;r++){if(r==e.childCount||r==t.childCount)return e.childCount==t.childCount?null:n;let i=e.child(r),a=t.child(r);if(i==a)n+=i.nodeSize;else{if(!i.sameMarkup(a))return n;if(i.isText&&i.text!=a.text){let e=i.text,t=a.text,r=0;for(;e[r]==t[r];r++)n++;return r&&r0&&a>0&&e[i-1]==t[a-1];)i--,a--,n--,r--;return i&&a&&i=56320&&e<57344}function Se(e){return e>=55296&&e<56320}var F=class e{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let t=0;te&&n(s,r+o,i||null,a)!==!1&&s.content.size){let i=o+1;s.nodesBetween(Math.max(0,e-i),Math.min(s.content.size,t-i),n,r+i)}o=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,n,r){let i=``,a=!0;return this.nodesBetween(e,t,(o,s)=>{let c=o.isText?o.text.slice(Math.max(e,s)-s,t-s):o.isLeaf?r?typeof r==`function`?r(o):r:o.type.spec.leafText?o.type.spec.leafText(o):``:``;o.isBlock&&(o.isLeaf&&c||o.isTextblock)&&n&&(a?a=!1:i+=n),i+=c},0),i}append(t){if(!t.size)return this;if(!this.size)return t;let n=this.lastChild,r=t.firstChild,i=this.content.slice(),a=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),a=1);at)for(let e=0,a=0;at&&((an)&&(o=o.isText?o.cut(Math.max(0,t-a),Math.min(o.text.length,n-a)):o.cut(Math.max(0,t-a-1),Math.min(o.content.size,n-a-1))),r.push(o),i+=o.nodeSize),a=s}return new e(r,i)}cutByIndex(t,n){return t==n?e.empty:t==0&&n==this.content.length?this:new e(this.content.slice(t,n))}replaceChild(t,n){let r=this.content[t];if(r==n)return this;let i=this.content.slice(),a=this.size+n.nodeSize-r.nodeSize;return i[t]=n,new e(i,a)}addToStart(t){return new e([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new e(this.content.concat(t),this.size+t.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;tthis.size||e<0)throw RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,n=0;;t++){let r=this.child(t),i=n+r.nodeSize;if(i>=e)return i==e?we(t+1,i):we(t,n);n=i}}toString(){return`<`+this.toStringInner()+`>`}toStringInner(){return this.content.join(`, `)}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(t,n){if(!n)return e.empty;if(!Array.isArray(n))throw RangeError(`Invalid input for Fragment.fromJSON`);return e.fromArray(n.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return e.empty;let n,r=0;for(let e=0;ethis.type.rank&&(t||=e.slice(0,r),t.push(this),n=!0),t&&t.push(i)}return t||=e.slice(),n||t.push(this),t}removeFromSet(e){for(let t=0;te.type.rank-t.type.rank),n}};I.none=[];var Ee=class extends Error{},L=class e{constructor(e,t,n){this.content=e,this.openStart=t,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,n){let r=Oe(this.content,t+this.openStart,n,this.openStart+1,this.openEnd+1);return r&&new e(r,this.openStart,this.openEnd)}removeBetween(t,n){return new e(De(this.content,t+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+`(`+this.openStart+`,`+this.openEnd+`)`}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(t,n){if(!n)return e.empty;let r=n.openStart||0,i=n.openEnd||0;if(typeof r!=`number`||typeof i!=`number`)throw RangeError(`Invalid input for Slice.fromJSON`);return new e(F.fromJSON(t,n.content),r,i)}static maxOpen(t,n=!0){let r=0,i=0;for(let e=t.firstChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.firstChild)r++;for(let e=t.lastChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.lastChild)i++;return new e(t,r,i)}};L.empty=new L(F.empty,0,0);function De(e,t,n){let{index:r,offset:i}=e.findIndex(t),a=e.maybeChild(r),{index:o,offset:s}=e.findIndex(n);if(i==t||a.isText){if(s!=n&&!e.child(o).isText)throw RangeError(`Removing non-flat range`);return e.cut(0,t).append(e.cut(n))}if(r!=o)throw RangeError(`Removing non-flat range`);return e.replaceChild(r,a.copy(De(a.content,t-i-1,n-i-1)))}function Oe(e,t,n,r,i,a){let{index:o,offset:s}=e.findIndex(t),c=e.maybeChild(o);if(s==t||c.isText)return a&&r<=0&&i<=0&&!a.canReplace(o,o,n)?null:e.cut(0,t).append(n).append(e.cut(t));let l=Oe(c.content,t-s-1,n,o==0?r-1:0,o==e.childCount-1?i-1:0,c);return l&&e.replaceChild(o,c.copy(l))}function ke(e,t,n){if(n.openStart>e.depth)throw new Ee(`Inserted content deeper than insertion position`);if(e.depth-n.openStart!=t.depth-n.openEnd)throw new Ee(`Inconsistent open depths`);return Ae(e,t,n,0)}function Ae(e,t,n,r){let i=e.index(r),a=e.node(r);if(i==t.index(r)&&r=0&&e.isText&&e.sameMarkup(t[n])?t[n]=e.withText(t[n].text+e.text):t.push(e)}function Pe(e,t,n,r){let i=(t||e).node(n),a=0,o=t?t.index(n):i.childCount;e&&(a=e.index(n),e.depth>n?a++:e.textOffset&&(Ne(e.nodeAfter,r),a++));for(let e=a;ei&&Me(e,t,i+1),o=r.depth>i&&Me(n,r,i+1),s=[];return Pe(null,e,i,s),a&&o&&t.index(i)==n.index(i)?(je(a,o),Ne(Fe(a,Ie(e,t,n,r,i+1)),s)):(a&&Ne(Fe(a,Le(e,t,i+1)),s),Pe(t,n,i,s),o&&Ne(Fe(o,Le(n,r,i+1)),s)),Pe(r,null,i,s),new F(s)}function Le(e,t,n){let r=[];return Pe(null,e,n,r),e.depth>n&&Ne(Fe(Me(e,t,n+1),Le(e,t,n+1)),r),Pe(t,null,n,r),new F(r)}function Re(e,t){let n=t.depth-e.openStart,r=t.node(n).copy(e.content);for(let e=n-1;e>=0;e--)r=t.node(e).copy(F.from(r));return{start:r.resolveNoCache(e.openStart+n),end:r.resolveNoCache(r.content.size-e.openEnd-n)}}var ze=class e{constructor(e,t,n){this.pos=e,this.path=t,this.parentOffset=n,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw RangeError(`There is no position before the top-level node`);return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw RangeError(`There is no position after the top-level node`);return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let n=this.pos-this.path[this.path.length-1],r=e.child(t);return n?e.child(t).cut(n):r}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let n=this.path[t*3],r=t==0?0:this.path[t*3-1]+1;for(let t=0;t0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos=0;n--)if(e.pos<=this.end(n)&&(!t||t(this.node(n))))return new Ue(this,e,n);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos=0&&n<=t.content.size))throw RangeError(`Position `+n+` out of range`);let r=[],i=0,a=n;for(let e=t;;){let{index:t,offset:n}=e.content.findIndex(a),o=a-n;if(r.push(e,t,i+n),!o||(e=e.child(t),e.isText))break;a=o-1,i+=n+1}return new e(n,r,a)}static resolveCached(t,n){let r=He.get(t);if(r)for(let e=0;ee&&this.nodesBetween(e,t,e=>(n.isInSet(e.marks)&&(r=!0),!r)),r}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+=`(`+this.content.toStringInner()+`)`),Je(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw Error(`Called contentMatchAt on a node with invalid content`);return t}canReplace(e,t,n=F.empty,r=0,i=n.childCount){let a=this.contentMatchAt(e).matchFragment(n,r,i),o=a&&a.matchFragment(this.content,t);if(!o||!o.validEnd)return!1;for(let e=r;ee.type.name)}`);this.content.forEach(e=>e.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(e=>e.toJSON())),e}static fromJSON(e,t){if(!t)throw RangeError(`Invalid input for Node.fromJSON`);let n;if(t.marks){if(!Array.isArray(t.marks))throw RangeError(`Invalid mark data for Node.fromJSON`);n=t.marks.map(e.markFromJSON)}if(t.type==`text`){if(typeof t.text!=`string`)throw RangeError(`Invalid text node in JSON`);return e.text(t.text,n)}let r=F.fromJSON(e,t.content);return e.nodeType(t.type).create(t.attrs,r,n)}};Ge.prototype.text=void 0;var Ke=(()=>{let{stack:e}=Error(`/`);if(!e||!/\n\s*at\s/.test(e))return e=>e;let t=Object.create(null);return e=>(t[e],e)})(),qe=class e extends Ge{constructor(e,t,n,r){if(super(e,t,null,r),!n)throw RangeError(`Empty text nodes are not allowed`);this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Je(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return Ke(this.text.slice(e,t))}get nodeSize(){return this.text.length}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.text,t)}withText(t){return t==this.text?this:new e(this.type,this.attrs,t,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(Ke(this.text.slice(e,t)))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}};function Je(e,t){for(let n=e.length-1;n>=0;n--)t=e[n].type.name+`(`+t+`)`;return t}function Ye(e,t,n,r){for(let i in t)if(!(i in e))throw RangeError(`Unsupported attribute ${i} for ${n} of type ${r}`);for(let n in e)e[n].validate&&e[n].validate(t[n])}var Xe=class e{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(t,n){let r=new Ze(t,n);if(r.next==null)return e.empty;let i=Qe(r);r.next&&r.err(`Unexpected trailing text`);let a=ct(at(i));return lt(a,r),a}matchType(e){for(let t=0;te.createAndFill()));for(let e=0;e=this.next.length)throw RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(n){e.push(n);for(let r=0;r{let r=n+(t.validEnd?`*`:` `)+` `;for(let n=0;n`+e.indexOf(t.next[n].next);return r}).join(` -`)}};Xe.empty=new Xe(!0);var Ze=class{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==``&&this.tokens.pop(),this.tokens[0]==``&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw SyntaxError(e+` (in content expression '`+this.string+`')`)}};function Qe(e){let t=[];do t.push($e(e));while(e.eat(`|`));return t.length==1?t[0]:{type:`choice`,exprs:t}}function $e(e){let t=[];do t.push(et(e));while(e.next&&e.next!=`)`&&e.next!=`|`);return t.length==1?t[0]:{type:`seq`,exprs:t}}function et(e){let t=it(e);for(;;)if(e.eat(`+`))t={type:`plus`,expr:t};else if(e.eat(`*`))t={type:`star`,expr:t};else if(e.eat(`?`))t={type:`opt`,expr:t};else if(e.eat(`{`))t=nt(e,t);else break;return t}function tt(e){/\D/.test(e.next)&&e.err(`Expected number, got '`+e.next+`'`);let t=Number(e.next);return e.pos++,t}function nt(e,t){let n=tt(e),r=n;return e.eat(`,`)&&(r=e.next==`}`?-1:tt(e)),e.eat(`}`)||e.err(`Unclosed braced range`),{type:`range`,min:n,max:r,expr:t}}function rt(e,t){let n=e.nodeTypes,r=n[t];if(r)return[r];let i=[];for(let e in n){let r=n[e];r.isInGroup(t)&&i.push(r)}return i.length==0&&e.err(`No node type or group '`+t+`' found`),i}function it(e){if(e.eat(`(`)){let t=Qe(e);return e.eat(`)`)||e.err(`Missing closing paren`),t}if(/\W/.test(e.next))e.err(`Unexpected token '`+e.next+`'`);else{let t=rt(e,e.next).map(t=>(e.inline==null?e.inline=t.isInline:e.inline!=t.isInline&&e.err(`Mixing inline and block content`),{type:`name`,value:t}));return e.pos++,t.length==1?t[0]:{type:`choice`,exprs:t}}}function at(e){let t=[[]];return i(a(e,0),n()),t;function n(){return t.push([])-1}function r(e,n,r){let i={term:r,to:n};return t[e].push(i),i}function i(e,t){e.forEach(e=>e.to=t)}function a(e,t){if(e.type==`choice`)return e.exprs.reduce((e,n)=>e.concat(a(n,t)),[]);if(e.type==`seq`)for(let r=0;;r++){let o=a(e.exprs[r],t);if(r==e.exprs.length-1)return o;i(o,t=n())}else if(e.type==`star`){let o=n();return r(t,o),i(a(e.expr,o),o),[r(o)]}else if(e.type==`plus`){let o=n();return i(a(e.expr,t),o),i(a(e.expr,o),o),[r(o)]}else if(e.type==`opt`)return[r(t)].concat(a(e.expr,t));else if(e.type==`range`){let o=t;for(let t=0;t{e[t].forEach(({term:t,to:n})=>{if(!t)return;let r;for(let e=0;e{r||i.push([t,r=[]]),r.indexOf(e)==-1&&r.push(e)})})});let a=t[r.join(`,`)]=new Xe(r.indexOf(e.length-1)>-1);for(let e=0;e-1}get whitespace(){return this.spec.whitespace||(this.spec.code?`pre`:`normal`)}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:dt(this.attrs,e)}create(e=null,t,n){if(this.isText)throw Error(`NodeType.create can't construct text nodes`);return new Ge(this,this.computeAttrs(e),F.from(t),I.setFrom(n))}createChecked(e=null,t,n){return t=F.from(t),this.checkContent(t),new Ge(this,this.computeAttrs(e),t,I.setFrom(n))}createAndFill(e=null,t,n){if(e=this.computeAttrs(e),t=F.from(t),t.size){let e=this.contentMatch.fillBefore(t);if(!e)return null;t=e.append(t)}let r=this.contentMatch.matchFragment(t),i=r&&r.fillBefore(F.empty,!0);return i?new Ge(this,e,t.append(i),I.setFrom(n)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let t=0;t-1}allowsMarks(e){if(this.markSet==null)return!0;for(let t=0;tr[t]=new e(t,n,i));let i=n.spec.topNode||`doc`;if(!r[i])throw RangeError(`Schema is missing its top node type ('`+i+`')`);if(!r.text)throw RangeError(`Every schema needs a 'text' type`);for(let e in r.text.attrs)throw RangeError(`The text node type should not have attributes`);return r}};function mt(e,t,n){let r=n.split(`|`);return n=>{let i=n===null?`null`:typeof n;if(r.indexOf(i)<0)throw RangeError(`Expected value of type ${r} for attribute ${t} on type ${e}, got ${i}`)}}var ht=class{constructor(e,t,n){this.hasDefault=Object.prototype.hasOwnProperty.call(n,`default`),this.default=n.default,this.validate=typeof n.validate==`string`?mt(e,t,n.validate):n.validate}get isRequired(){return!this.hasDefault}},gt=class e{constructor(e,t,n,r){this.name=e,this.rank=t,this.schema=n,this.spec=r,this.attrs=ft(e,r.attrs),this.excluded=null;let i=ut(this.attrs);this.instance=i?new I(this,i):null}create(e=null){return!e&&this.instance?this.instance:new I(this,dt(this.attrs,e))}static compile(t,n){let r=Object.create(null),i=0;return t.forEach((t,a)=>r[t]=new e(t,i++,n,a)),r}removeFromSet(e){for(var t=0;t-1}},_t=class{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let n in e)t[n]=e[n];t.nodes=ve.from(e.nodes),t.marks=ve.from(e.marks||{}),this.nodes=pt.compile(this.spec.nodes,this),this.marks=gt.compile(this.spec.marks,this);let n=Object.create(null);for(let e in this.nodes){if(e in this.marks)throw RangeError(e+` can not be both a node and a mark`);let t=this.nodes[e],r=t.spec.content||``,i=t.spec.marks;if(t.contentMatch=n[r]||(n[r]=Xe.parse(r,this.nodes)),t.inlineContent=t.contentMatch.inlineContent,t.spec.linebreakReplacement){if(this.linebreakReplacement)throw RangeError(`Multiple linebreak nodes defined`);if(!t.isInline||!t.isLeaf)throw RangeError(`Linebreak replacement nodes must be inline leaf nodes`);this.linebreakReplacement=t}t.markSet=i==`_`?null:i?vt(this,i.split(` `)):i==``||!t.inlineContent?[]:null}for(let e in this.marks){let t=this.marks[e],n=t.spec.excludes;t.excluded=n==null?[t]:n==``?[]:vt(this,n.split(` `))}this.nodeFromJSON=e=>Ge.fromJSON(this,e),this.markFromJSON=e=>I.fromJSON(this,e),this.topNodeType=this.nodes[this.spec.topNode||`doc`],this.cached.wrappings=Object.create(null)}node(e,t=null,n,r){if(typeof e==`string`)e=this.nodeType(e);else if(!(e instanceof pt))throw RangeError(`Invalid node type: `+e);else if(e.schema!=this)throw RangeError(`Node type from different schema used (`+e.name+`)`);return e.createChecked(t,n,r)}text(e,t){let n=this.nodes.text;return new qe(n,n.defaultAttrs,e,I.setFrom(t))}mark(e,t){return typeof e==`string`&&(e=this.marks[e]),e.create(t)}nodeType(e){let t=this.nodes[e];if(!t)throw RangeError(`Unknown node type: `+e);return t}};function vt(e,t){let n=[];for(let r=0;r-1)&&n.push(o=r)}if(!o)throw SyntaxError(`Unknown mark type: '`+t[r]+`'`)}return n}function yt(e){return e.tag!=null}function bt(e){return e.style!=null}var xt=class e{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let n=this.matchedStyles=[];t.forEach(e=>{if(yt(e))this.tags.push(e);else if(bt(e)){let t=/[^=]*/.exec(e.style)[0];n.indexOf(t)<0&&n.push(t),this.styles.push(e)}}),this.normalizeLists=!this.tags.some(t=>{if(!/^(ul|ol)\b/.test(t.tag)||!t.node)return!1;let n=e.nodes[t.node];return n.contentMatch.matchType(n)})}parse(e,t={}){let n=new At(this,t,!1);return n.addAll(e,I.none,t.from,t.to),n.finish()}parseSlice(e,t={}){let n=new At(this,t,!0);return n.addAll(e,I.none,t.from,t.to),L.maxOpen(n.finish())}matchTag(e,t,n){for(let r=n?this.tags.indexOf(n)+1:0;re.length&&(a.charCodeAt(e.length)!=61||a.slice(e.length+1)!=t))){if(r.getAttrs){let e=r.getAttrs(t);if(e===!1)continue;r.attrs=e||void 0}return r}}}static schemaRules(e){let t=[];function n(e){let n=e.priority==null?50:e.priority,r=0;for(;r{n(e=Nt(e)),e.mark||e.ignore||e.clearMark||(e.mark=t)})}for(let t in e.nodes){let r=e.nodes[t].spec.parseDOM;r&&r.forEach(e=>{n(e=Nt(e)),e.node||e.ignore||e.mark||(e.node=t)})}return t}static fromSchema(t){return t.cached.domParser||(t.cached.domParser=new e(t,e.schemaRules(t)))}},St={address:!0,article:!0,aside:!0,blockquote:!0,body:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},Ct={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},wt={ol:!0,ul:!0},Tt=1,Et=2,Dt=4;function Ot(e,t,n){return t==null?e&&e.whitespace==`pre`?3:n&-5:(t?Tt:0)|(t===`full`?Et:0)}var kt=class{constructor(e,t,n,r,i,a){this.type=e,this.attrs=t,this.marks=n,this.solid=r,this.options=a,this.content=[],this.activeMarks=I.none,this.match=i||(a&Dt?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(F.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let t=this.type.contentMatch,n;return(n=t.findWrapping(e.type))?(this.match=t,n):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&Tt)){let e=this.content[this.content.length-1],t;if(e&&e.isText&&(t=/[ \t\r\n\u000c]+$/.exec(e.text))){let n=e;e.text.length==t[0].length?this.content.pop():this.content[this.content.length-1]=n.withText(n.text.slice(0,n.text.length-t[0].length))}}let t=F.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(F.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!St.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}},At=class{constructor(e,t,n){this.parser=e,this.options=t,this.isOpen=n,this.open=0,this.localPreserveWS=!1;let r=t.topNode,i,a=Ot(null,t.preserveWhitespace,0)|(n?Dt:0);i=r?new kt(r.type,r.attrs,I.none,!0,t.topMatch||r.type.contentMatch,a):n?new kt(null,null,I.none,!0,null,a):new kt(e.schema.topNodeType,null,I.none,!0,null,a),this.nodes=[i],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let n=e.nodeValue,r=this.top,i=r.options&Et?`full`:this.localPreserveWS||(r.options&Tt)>0,{schema:a}=this.parser;if(i===`full`||r.inlineContext(e)||/[^ \t\r\n\u000c]/.test(n)){if(!i){if(n=n.replace(/[ \t\r\n\u000c]+/g,` `),/^[ \t\r\n\u000c]/.test(n)&&this.open==this.nodes.length-1){let t=r.content[r.content.length-1],i=e.previousSibling;(!t||i&&i.nodeName==`BR`||t.isText&&/[ \t\r\n\u000c]$/.test(t.text))&&(n=n.slice(1))}}else if(i===`full`)n=n.replace(/\r\n?/g,` -`);else if(a.linebreakReplacement&&/[\r\n]/.test(n)&&this.top.findWrapping(a.linebreakReplacement.create())){let e=n.split(/\r?\n|\r/);for(let n=0;n!n.clearMark(e)):t.concat(this.parser.schema.marks[n.mark].create(n.attrs)),n.consuming===!1)e=n;else break}}return t}addElementByRule(e,t,n,r){let i,a;if(t.node){if(a=this.parser.schema.nodes[t.node],a.isLeaf)this.insertNode(a.create(t.attrs),n,e.nodeName==`BR`)||this.leafFallback(e,n);else{let e=this.enter(a,t.attrs||null,n,t.preserveWhitespace);e&&(i=!0,n=e)}}else{let e=this.parser.schema.marks[t.mark];n=n.concat(e.create(t.attrs))}let o=this.top;if(a&&a.isLeaf)this.findInside(e);else if(r)this.addElement(e,n,r);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(e=>this.insertNode(e,n,!1));else{let r=e;typeof t.contentElement==`string`?r=e.querySelector(t.contentElement):typeof t.contentElement==`function`?r=t.contentElement(e):t.contentElement&&(r=t.contentElement),this.findAround(e,r,!0),this.addAll(r,n),this.findAround(e,r,!1)}i&&this.sync(o)&&this.open--}addAll(e,t,n,r){let i=n||0;for(let a=n?e.childNodes[n]:e.firstChild,o=r==null?null:e.childNodes[r];a!=o;a=a.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(a,t);this.findAtPoint(e,i)}findPlace(e,t,n){let r,i;for(let t=this.open,a=0;t>=0;t--){let o=this.nodes[t],s=o.findWrapping(e);if(s&&(!r||r.length>s.length+a)&&(r=s,i=o,!s.length))break;if(o.solid){if(n)break;a+=2}}if(!r)return null;this.sync(i);for(let e=0;e!(a.type?a.type.allowsMarkType(t.type):Pt(t.type,e))||(s=t.addToSet(s),!1)),this.nodes.push(new kt(e,t,s,r,null,o)),this.open++,n}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--)if(this.nodes[t]==e)return this.open=t,!0;else this.localPreserveWS&&(this.nodes[t].options|=Tt);return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let n=this.nodes[t].content;for(let t=n.length-1;t>=0;t--)e+=n[t].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let n=0;n-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split(`/`),n=this.options.context,r=!this.isOpen&&(!n||n.parent.type==this.nodes[0].type),i=-(n?n.depth+1:0)+ +!r,a=(e,o)=>{for(;e>=0;e--){let s=t[e];if(s==``){if(e==t.length-1||e==0)continue;for(;o>=i;o--)if(a(e-1,o))return!0;return!1}{let e=o>0||o==0&&r?this.nodes[o].type:n&&o>=i?n.node(o-i).type:null;if(!e||e.name!=s&&!e.isInGroup(s))return!1;o--}}return!0};return a(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let n=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(let e in this.parser.schema.nodes){let t=this.parser.schema.nodes[e];if(t.isTextblock&&t.defaultAttrs)return t}}};function jt(e){for(let t=e.firstChild,n=null;t;t=t.nextSibling){let e=t.nodeType==1?t.nodeName.toLowerCase():null;e&&wt.hasOwnProperty(e)&&n?(n.appendChild(t),t=n):e==`li`?n=t:e&&(n=null)}}function Mt(e,t){return(e.matches||e.msMatchesSelector||e.webkitMatchesSelector||e.mozMatchesSelector).call(e,t)}function Nt(e){let t={};for(let n in e)t[n]=e[n];return t}function Pt(e,t){let n=t.schema.nodes;for(let r in n){let i=n[r];if(!i.allowsMarkType(e))continue;let a=[],o=e=>{a.push(e);for(let n=0;n{if(i.length||e.marks.length){let n=0,a=0;for(;n=0;r--){let i=this.serializeMark(e.marks[r],e.isInline,t);i&&((i.contentDOM||i.dom).appendChild(n),n=i.dom)}return n}serializeMark(e,t,n={}){let r=this.marks[e.type.name];return r&&Vt(Lt(n),r(e,t),null,e.attrs)}static renderSpec(e,t,n=null,r){return typeof t==`string`?{dom:e.createTextNode(t)}:Vt(e,t,n,r)}static fromSchema(t){return t.cached.domSerializer||(t.cached.domSerializer=new e(this.nodesFromSchema(t),this.marksFromSchema(t)))}static nodesFromSchema(e){let t=It(e.nodes);return t.text||=e=>e.text,t}static marksFromSchema(e){return It(e.marks)}};function It(e){let t={};for(let n in e){let r=e[n].spec.toDOM;r&&(t[n]=r)}return t}function Lt(e){return e.document||window.document}var Rt=new WeakMap;function zt(e){let t=Rt.get(e);return t===void 0&&Rt.set(e,t=Bt(e)),t}function Bt(e){let t=null;function n(e){if(e&&typeof e==`object`){if(Array.isArray(e)){if(typeof e[0]==`string`)t||=[],t.push(e);else for(let t=0;t-1)throw RangeError(`Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.`);let o=i.indexOf(` `);o>0&&(n=i.slice(0,o),i=i.slice(o+1));let s,c=n?e.createElementNS(n,i):e.createElement(i),l=t[1],u=1;if(l&&typeof l==`object`&&l.nodeType==null&&!Array.isArray(l)){u=2;for(let e in l)if(l[e]!=null){let t=e.indexOf(` `);t>0?c.setAttributeNS(e.slice(0,t),e.slice(t+1),l[e]):e==`style`&&c.style?c.style.cssText=l[e]:c.setAttribute(e,l[e])}}for(let i=u;iu)throw RangeError(`Content hole must be the only child of its parent node`);return{dom:c,contentDOM:c}}if(typeof a==`string`)c.appendChild(e.createTextNode(a));else{let{dom:t,contentDOM:i}=Vt(e,a,n,r);if(c.appendChild(t),i){if(s)throw RangeError(`Multiple content holes`);s=i}}}return{dom:c,contentDOM:s}}var Ht=65535,Ut=2**16;function Wt(e,t){return e+t*Ut}function Gt(e){return e&Ht}function Kt(e){return(e-(e&Ht))/Ut}var qt=1,Jt=2,Yt=4,Xt=8,Zt=class{constructor(e,t,n){this.pos=e,this.delInfo=t,this.recover=n}get deleted(){return(this.delInfo&Xt)>0}get deletedBefore(){return(this.delInfo&5)>0}get deletedAfter(){return(this.delInfo&6)>0}get deletedAcross(){return(this.delInfo&Yt)>0}},Qt=class e{constructor(t,n=!1){if(this.ranges=t,this.inverted=n,!t.length&&e.empty)return e.empty}recover(e){let t=0,n=Gt(e);if(!this.inverted)for(let e=0;ee)break;let c=this.ranges[o+i],l=this.ranges[o+a],u=s+c;if(e<=u){let i=c?e==s?-1:e==u?1:t:t,a=s+r+(i<0?0:l);if(n)return a;let d=e==(t<0?s:u)?null:Wt(o/3,e-s),f=0;return c&&(f|=e==s?Jt:e==u?qt:Yt,(t<0?e!=s:e!=u)&&(f|=Xt)),new Zt(a,f,d)}r+=l-c}return n?e+r:new Zt(e+r,0,null)}touches(e,t){let n=0,r=Gt(t),i=this.inverted?2:1,a=this.inverted?1:2;for(let t=0;te)break;let s=this.ranges[t+i];if(e<=o+s&&t==r*3)return!0;n+=this.ranges[t+a]-s}return!1}forEach(e){let t=this.inverted?2:1,n=this.inverted?1:2;for(let r=0,i=0;r=0;t--){let r=e.getMirror(t);this.appendMap(e._maps[t].invert(),r!=null&&r>t?n-r-1:void 0)}}invert(){let t=new e;return t.appendMappingInverted(this),t}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let n=this.from;nn&&t!e.isAtom||!t.type.allowsMarkType(this.mark.type)?e:e.mark(this.mark.addToSet(e.marks)),r),t.openStart,t.openEnd);return nn.fromReplace(e,this.from,this.to,i)}invert(t){let n=[];return t.nodesBetween(this.from,this.to,(t,r)=>{if(t.isInline&&t.isAtom){let i=this.mark.addToSet(t.marks);if(!I.sameSet(i,t.marks)){let a=Math.max(this.from,r),o=Math.min(this.to,r+t.nodeSize);sn(on,a,o,this.mark,n);for(let r of t.marks)r.isInSet(i)||sn(e,a,o,r,n)}}}),n.length==1?n[0]:new cn(n)}map(t){let n=t.map(this.from,1),r=t.map(this.to,-1);return n>=r?null:new e(n,r,this.mark)}merge(t){return t instanceof e&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new e(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:`addMark`,mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for AddMarkStep.fromJSON`);return new e(n.from,n.to,t.markFromJSON(n.mark))}};tn.jsonID(`addMark`,an);var on=class e extends tn{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=new L(rn(t.content,e=>e.mark(this.mark.removeFromSet(e.marks)),e),t.openStart,t.openEnd);return nn.fromReplace(e,this.from,this.to,n)}invert(e){let t=[];return e.nodesBetween(this.from,this.to,(e,n)=>{e.isInline&&e.isAtom&&this.mark.isInSet(e.marks)&&sn(an,Math.max(this.from,n),Math.min(this.to,n+e.nodeSize),this.mark,t)}),t.length==1?t[0]:new cn(t)}map(t){let n=t.map(this.from,1),r=t.map(this.to,-1);return n>=r?null:new e(n,r,this.mark)}merge(t){return t instanceof e&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new e(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:`removeMark`,mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for RemoveMarkStep.fromJSON`);return new e(n.from,n.to,t.markFromJSON(n.mark))}};tn.jsonID(`removeMark`,on);function sn(e,t,n,r,i){let a=i.length?i[i.length-1]:null;a&&a instanceof e&&a.to==t&&a.mark.eq(r)?i[i.length-1]=new e(a.from,n,r):i.push(new e(t,n,r))}var cn=class e extends tn{constructor(e){super(),this.steps=e}apply(e){for(let t of this.steps){let n=t.apply(e);if(!n.doc)return n;e=n.doc}return new nn(e,null)}invert(t){return new e(this.steps.map(e=>e.invert(t)))}map(t){let n=[];for(let e of this.steps){let r=e.map(t);r&&n.push(r)}return n.length?new e(n):null}toJSON(){return{stepType:`markSet`,steps:this.steps.map(e=>e.toJSON())}}static fromJSON(t,n){if(!Array.isArray(n.steps)||!n.steps.every(e=>e.stepType==`addMark`||e.stepType==`removeMark`))throw RangeError(`Invalid JSON for MarkSetStep`);return new e(n.steps.map(e=>tn.fromJSON(t,e)))}};tn.jsonID(`markSet`,cn);var ln=class e extends tn{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return nn.fail(`No node at mark step's position`);let n=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return nn.fromReplace(e,this.pos,this.pos+1,new L(F.from(n),0,+!t.isLeaf))}invert(t){let n=t.nodeAt(this.pos);if(n){let t=this.mark.addToSet(n.marks);if(t.length==n.marks.length){for(let r=0;rr.pos||i>a?null:new e(n.pos,r.pos,i,a,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:`replaceAround`,from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`||typeof n.gapFrom!=`number`||typeof n.gapTo!=`number`||typeof n.insert!=`number`)throw RangeError(`Invalid input for ReplaceAroundStep.fromJSON`);return new e(n.from,n.to,n.gapFrom,n.gapTo,L.fromJSON(t,n.slice),n.insert,!!n.structure)}};tn.jsonID(`replaceAround`,fn);function pn(e,t,n){let r=e.resolve(t),i=n-t,a=r.depth;for(;i>0&&a>0&&r.indexAfter(a)==r.node(a).childCount;)a--,i--;if(i>0){let e=r.node(a).maybeChild(r.indexAfter(a));for(;i>0;){if(!e||e.isLeaf)return!0;e=e.firstChild,i--}}return!1}function mn(e,t,n,r){let i=[];e.doc.nodesBetween(t,n,(e,a,o)=>{if(!e.isInline)return;let s=e.marks;!r.isInSet(s)&&o.type.allowsMarkType(r.type)&&sn(an,Math.max(a,t),Math.min(a+e.nodeSize,n),r,i)}),i.forEach(t=>e.step(t))}function hn(e,t,n,r){let i=[],a=0;e.doc.nodesBetween(t,n,(e,o)=>{if(!e.isInline||!e.isAtom)return;a++;let s=null;if(r instanceof gt){let t=e.marks,n;for(;n=r.isInSet(t);)(s||=[]).push(n),t=n.removeFromSet(t)}else r?r.isInSet(e.marks)&&(s=[r]):s=e.marks;if(s&&s.length){let r=Math.min(o+e.nodeSize,n);for(let e=0;ee.step(new on(t.from,t.to,t.style)))}function gn(e,t,n,r=n.contentMatch,i=!0){let a=e.doc.nodeAt(t),o=[],s=t+1;for(let t=0;t=0;t--)e.step(o[t])}function _n(e,t,n){return(t==0||e.canReplace(t,e.childCount))&&(n==e.childCount||e.canReplace(0,n))}function vn(e){let t=e.parent.content.cutByIndex(e.startIndex,e.endIndex);for(let n=e.depth,r=0,i=0;;--n){let a=e.$from.node(n),o=e.$from.index(n)+r,s=e.$to.indexAfter(n)-i;if(nn;e--)t||r.index(e)>0?(t=!0,u=F.from(r.node(e).copy(u)),d++):c--;let f=F.empty,p=0;for(let e=a,t=!1;e>n;e--)t||i.after(e+1)=0;e--){if(r.size){let t=n[e].type.contentMatch.matchFragment(r);if(!t||!t.validEnd)throw RangeError(`Wrapper type given to Transform.wrap does not form valid content of its parent wrapper`)}r=F.from(n[e].type.create(n[e].attrs,r))}let i=t.start,a=t.end;e.step(new fn(i,a,i,a,new L(r,0,0),n.length,!0))}function Tn(e,t,n,r,i){if(!r.isTextblock)throw RangeError(`Type given to setBlockType should be a textblock`);let a=e.steps.length;e.doc.nodesBetween(t,n,(t,n)=>{let o=typeof i==`function`?i(t):i;if(t.isTextblock&&!t.hasMarkup(r,o)&&On(e.doc,e.mapping.slice(a).map(n),r)){let i=null;if(r.schema.linebreakReplacement){let e=r.whitespace==`pre`,t=!!r.contentMatch.matchType(r.schema.linebreakReplacement);e&&!t?i=!1:!e&&t&&(i=!0)}i===!1&&Dn(e,t,n,a),gn(e,e.mapping.slice(a).map(n,1),r,void 0,i===null);let s=e.mapping.slice(a),c=s.map(n,1),l=s.map(n+t.nodeSize,1);return e.step(new fn(c,l,c+1,l-1,new L(F.from(r.create(o,null,t.marks)),0,0),1,!0)),i===!0&&En(e,t,n,a),!1}})}function En(e,t,n,r){t.forEach((i,a)=>{if(i.isText){let o,s=/\r?\n|\r/g;for(;o=s.exec(i.text);){let i=e.mapping.slice(r).map(n+1+a+o.index);e.replaceWith(i,i+1,t.type.schema.linebreakReplacement.create())}}})}function Dn(e,t,n,r){t.forEach((i,a)=>{if(i.type==i.type.schema.linebreakReplacement){let i=e.mapping.slice(r).map(n+1+a);e.replaceWith(i,i+1,t.type.schema.text(` -`))}})}function On(e,t,n){let r=e.resolve(t),i=r.index();return r.parent.canReplaceWith(i,i+1,n)}function kn(e,t,n,r,i){let a=e.doc.nodeAt(t);if(!a)throw RangeError(`No node at given position`);n||=a.type;let o=n.create(r,null,i||a.marks);if(a.isLeaf)return e.replaceWith(t,t+a.nodeSize,o);if(!n.validContent(a.content))throw RangeError(`Invalid content for node type `+n.name);e.step(new fn(t,t+a.nodeSize,t+1,t+a.nodeSize-1,new L(F.from(o),0,0),1,!0))}function An(e,t,n=1,r){let i=e.resolve(t),a=i.depth-n,o=r&&r[r.length-1]||i.parent;if(a<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!o.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let e=i.depth-1,t=n-2;e>a;e--,t--){let n=i.node(e),a=i.index(e);if(n.type.spec.isolating)return!1;let o=n.content.cutByIndex(a,n.childCount),s=r&&r[t+1];s&&(o=o.replaceChild(0,s.type.create(s.attrs)));let c=r&&r[t]||n;if(!n.canReplace(a+1,n.childCount)||!c.type.validContent(o))return!1}let s=i.indexAfter(a),c=r&&r[0];return i.node(a).canReplaceWith(s,s,c?c.type:i.node(a+1).type)}function jn(e,t,n=1,r){let i=e.doc.resolve(t),a=F.empty,o=F.empty;for(let e=i.depth,t=i.depth-n,s=n-1;e>t;e--,s--){a=F.from(i.node(e).copy(a));let t=r&&r[s];o=F.from(t?t.type.create(t.attrs,o):i.node(e).copy(o))}e.step(new dn(t,t,new L(a.append(o),n,n),!0))}function Mn(e,t){let n=e.resolve(t),r=n.index();return Pn(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function Nn(e,t){t.content.size||e.type.compatibleContent(t.type);let n=e.contentMatchAt(e.childCount),{linebreakReplacement:r}=e.type.schema;for(let i=0;i0?(i=r.node(e+1),o++,a=r.node(e).maybeChild(o)):(i=r.node(e).maybeChild(o-1),a=r.node(e+1)),i&&!i.isTextblock&&Pn(i,a)&&r.node(e).canReplace(o,o+1))return t;if(e==0)break;t=n<0?r.before(e):r.after(e)}}function In(e,t,n){let r=null,{linebreakReplacement:i}=e.doc.type.schema,a=e.doc.resolve(t-n),o=a.node().type;if(i&&o.inlineContent){let e=o.whitespace==`pre`,t=!!o.contentMatch.matchType(i);e&&!t?r=!1:!e&&t&&(r=!0)}let s=e.steps.length;if(r===!1){let r=e.doc.resolve(t+n);Dn(e,r.node(),r.before(),s)}o.inlineContent&&gn(e,t+n-1,o,a.node().contentMatchAt(a.index()),r==null);let c=e.mapping.slice(s),l=c.map(t-n);if(e.step(new dn(l,c.map(t+n,-1),L.empty,!0)),r===!0){let t=e.doc.resolve(l);En(e,t.node(),t.before(),e.steps.length)}return e}function Ln(e,t,n){let r=e.resolve(t);if(r.parent.canReplaceWith(r.index(),r.index(),n))return t;if(r.parentOffset==0)for(let e=r.depth-1;e>=0;e--){let t=r.index(e);if(r.node(e).canReplaceWith(t,t,n))return r.before(e+1);if(t>0)return null}if(r.parentOffset==r.parent.content.size)for(let e=r.depth-1;e>=0;e--){let t=r.indexAfter(e);if(r.node(e).canReplaceWith(t,t,n))return r.after(e+1);if(t=0;t--){let n=t==r.depth?0:r.pos<=(r.start(t+1)+r.end(t+1))/2?-1:1,a=r.index(t)+ +(n>0),o=r.node(t),s=!1;if(e==1)s=o.canReplace(a,a,i);else{let e=o.contentMatchAt(a).findWrapping(i.firstChild.type);s=e&&o.canReplaceWith(a,a,e[0])}if(s)return n==0?r.pos:n<0?r.before(t+1):r.after(t+1)}return null}function zn(e,t,n=t,r=L.empty){if(t==n&&!r.size)return null;let i=e.resolve(t),a=e.resolve(n);return Bn(i,a,r)?new dn(t,n,r):new Vn(i,a,r).fit()}function Bn(e,t,n){return!n.openStart&&!n.openEnd&&e.start()==t.start()&&e.parent.canReplace(e.index(),t.index(),n.content)}var Vn=class{constructor(e,t,n){this.$from=e,this.$to=t,this.unplaced=n,this.frontier=[],this.placed=F.empty;for(let t=0;t<=e.depth;t++){let n=e.node(t);this.frontier.push({type:n.type,match:n.contentMatchAt(e.indexAfter(t))})}for(let t=e.depth;t>0;t--)this.placed=F.from(e.node(t).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let e=this.findFittable();e?this.placeNodes(e):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,n=this.$from,r=this.close(e<0?this.$to:n.doc.resolve(e));if(!r)return null;let i=this.placed,a=n.depth,o=r.depth;for(;a&&o&&i.childCount==1;)i=i.firstChild.content,a--,o--;let s=new L(i,a,o);return e>-1?new fn(n.pos,e,this.$to.pos,this.$to.end(),s,t):s.size||n.pos!=this.$to.pos?new dn(n.pos,r.pos,s):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,n=0,r=this.unplaced.openEnd;n1&&(r=0),i.type.spec.isolating&&r<=n){e=n;break}t=i.content}for(let t=1;t<=2;t++)for(let n=t==1?e:this.unplaced.openStart;n>=0;n--){let e,r=null;n?(r=Wn(this.unplaced.content,n-1).firstChild,e=r.content):e=this.unplaced.content;let i=e.firstChild;for(let e=this.depth;e>=0;e--){let{type:a,match:o}=this.frontier[e],s,c=null;if(t==1&&(i?o.matchType(i.type)||(c=o.fillBefore(F.from(i),!1)):r&&a.compatibleContent(r.type)))return{sliceDepth:n,frontierDepth:e,parent:r,inject:c};if(t==2&&i&&(s=o.findWrapping(i.type)))return{sliceDepth:n,frontierDepth:e,parent:r,wrap:s};if(r&&o.matchType(r.type))break}}}openMore(){let{content:e,openStart:t,openEnd:n}=this.unplaced;return Yn(e,-1)<=t?!1:(this.unplaced.size>1&&Yn(e,1)>n&&n++,this.unplaced=new L(e,t+1,n),!0)}dropNode(){let{content:e,openStart:t,openEnd:n}=this.unplaced,r=Wn(e,t);if(r.childCount<=1&&t>0){let i=e.size-t<=t+r.size;this.unplaced=new L(Hn(e,t-1,1),t-1,i?t-1:n)}else this.unplaced=new L(Hn(e,t,1),t,n)}placeNodes({sliceDepth:e,frontierDepth:t,parent:n,inject:r,wrap:i}){for(;this.depth>t;)this.closeFrontierNode();if(i)for(let e=0;e1||s==0||e.content.size)&&(u=t,l.push(Gn(e.mark(d.allowedMarks(e.marks)),c==1?s:0,c==o.childCount?f:-1)))}let p=c==o.childCount;p||(f=-1),this.placed=Un(this.placed,t,F.from(l)),this.frontier[t].match=u,p&&f<0&&n&&n.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let e=0,t=l[l.length-1];t&&e1&&r==this.$to.end(--n);)++r;return r}findCloseLevel(e){scan:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:n,type:r}=this.frontier[t],i=t=0;n--){let{match:t,type:r}=this.frontier[n],i=Kn(e,n,r,t,!0);if(!i||i.childCount)continue scan}return{depth:t,fit:a,move:i?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=Un(this.placed,t.depth,t.fit)),e=t.move;for(let n=t.depth+1;n<=e.depth;n++){let t=e.node(n),r=t.type.contentMatch.fillBefore(t.content,!0,e.index(n));this.openFrontierNode(t.type,t.attrs,r)}return e}openFrontierNode(e,t=null,n){let r=this.frontier[this.depth];r.match=r.match.matchType(e),this.placed=Un(this.placed,this.depth,F.from(e.create(t,n))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let e=this.frontier.pop().match.fillBefore(F.empty,!0);e.childCount&&(this.placed=Un(this.placed,this.frontier.length,e))}};function Hn(e,t,n){return t==0?e.cutByIndex(n,e.childCount):e.replaceChild(0,e.firstChild.copy(Hn(e.firstChild.content,t-1,n)))}function Un(e,t,n){return t==0?e.append(n):e.replaceChild(e.childCount-1,e.lastChild.copy(Un(e.lastChild.content,t-1,n)))}function Wn(e,t){for(let n=0;n1&&(r=r.replaceChild(0,Gn(r.firstChild,t-1,r.childCount==1?n-1:0))),t>0&&(r=e.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(e.type.contentMatch.matchFragment(r).fillBefore(F.empty,!0)))),e.copy(r)}function Kn(e,t,n,r,i){let a=e.node(t),o=i?e.indexAfter(t):e.index(t);if(o==a.childCount&&!n.compatibleContent(a.type))return null;let s=r.fillBefore(a.content,!0,o);return s&&!qn(n,a.content,o)?s:null}function qn(e,t,n){for(let r=n;r0;e--,t--){let n=i.node(e).type.spec;if(n.defining||n.definingAsContext||n.isolating)break;o.indexOf(e)>-1?s=e:i.before(e)==t&&o.splice(1,0,-e)}let c=o.indexOf(s),l=[],u=r.openStart;for(let e=r.content,t=0;;t++){let n=e.firstChild;if(l.push(n),t==r.openStart)break;e=n.content}for(let e=u-1;e>=0;e--){let t=l[e],n=Jn(t.type);if(n&&!t.sameMarkup(i.node(Math.abs(s)-1)))u=e;else if(n||!t.type.isTextblock)break}for(let t=r.openStart;t>=0;t--){let s=(t+u+1)%(r.openStart+1),d=l[s];if(d)for(let t=0;t=0&&(e.replace(t,n,r),!(e.steps.length>d));s--){let e=o[s];e<0||(t=i.before(e),n=a.after(e))}}function Zn(e,t,n,r,i){if(tr){let t=i.contentMatchAt(0),n=t.fillBefore(e).append(e);e=n.append(t.matchFragment(n).fillBefore(F.empty,!0))}return e}function Qn(e,t,n,r){if(!r.isInline&&t==n&&e.doc.resolve(t).parent.content.size){let i=Ln(e.doc,t,r.type);i!=null&&(t=n=i)}e.replaceRange(t,n,new L(F.from(r),0,0))}function $n(e,t,n){let r=e.doc.resolve(t),i=e.doc.resolve(n);if(r.parent.isTextblock&&i.parent.isTextblock&&r.start()!=i.start()&&r.parentOffset==0&&i.parentOffset==0){let a=r.sharedDepth(n),o=!1;for(let e=r.depth;e>a;e--)r.node(e).type.spec.isolating&&(o=!0);for(let e=i.depth;e>a;e--)i.node(e).type.spec.isolating&&(o=!0);if(!o){for(let e=r.depth;e>0&&t==r.start(e);e--)t=r.before(e);for(let e=i.depth;e>0&&n==i.start(e);e--)n=i.before(e);r=e.doc.resolve(t),i=e.doc.resolve(n)}}let a=er(r,i);for(let t=0;t0&&(o||r.node(n-1).canReplace(r.index(n-1),i.indexAfter(n-1))))return e.delete(r.before(n),i.after(n))}for(let a=1;a<=r.depth&&a<=i.depth;a++)if(t-r.start(a)==r.depth-a&&n>r.end(a)&&i.end(a)-n!=i.depth-a&&r.start(a-1)==i.start(a-1)&&r.node(a-1).canReplace(r.index(a-1),i.index(a-1)))return e.delete(r.before(a),n);e.delete(t,n)}function er(e,t){let n=[],r=Math.min(e.depth,t.depth);for(let i=r;i>=0;i--){let r=e.start(i);if(rt.pos+(t.depth-i)||e.node(i).type.spec.isolating||t.node(i).type.spec.isolating)break;(r==t.start(i)||i==e.depth&&i==t.depth&&e.parent.inlineContent&&t.parent.inlineContent&&i&&t.start(i-1)==r-1)&&n.push(i)}return n}var tr=class e extends tn{constructor(e,t,n){super(),this.pos=e,this.attr=t,this.value=n}apply(e){let t=e.nodeAt(this.pos);if(!t)return nn.fail(`No node at attribute step's position`);let n=Object.create(null);for(let e in t.attrs)n[e]=t.attrs[e];n[this.attr]=this.value;let r=t.type.create(n,null,t.marks);return nn.fromReplace(e,this.pos,this.pos+1,new L(F.from(r),0,+!t.isLeaf))}getMap(){return Qt.empty}invert(t){return new e(this.pos,this.attr,t.nodeAt(this.pos).attrs[this.attr])}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new e(n.pos,this.attr,this.value)}toJSON(){return{stepType:`attr`,pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(t,n){if(typeof n.pos!=`number`||typeof n.attr!=`string`)throw RangeError(`Invalid input for AttrStep.fromJSON`);return new e(n.pos,n.attr,n.value)}};tn.jsonID(`attr`,tr);var nr=class e extends tn{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let n in e.attrs)t[n]=e.attrs[n];t[this.attr]=this.value;let n=e.type.create(t,e.content,e.marks);return nn.ok(n)}getMap(){return Qt.empty}invert(t){return new e(this.attr,t.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:`docAttr`,attr:this.attr,value:this.value}}static fromJSON(t,n){if(typeof n.attr!=`string`)throw RangeError(`Invalid input for DocAttrStep.fromJSON`);return new e(n.attr,n.value)}};tn.jsonID(`docAttr`,nr);var rr=class extends Error{};rr=function e(t){let n=Error.call(this,t);return n.__proto__=e.prototype,n},rr.prototype=Object.create(Error.prototype),rr.prototype.constructor=rr,rr.prototype.name=`TransformError`;var ir=class{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new $t}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new rr(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}changedRange(){let e=1e9,t=-1e9;for(let n=0;n{e=Math.min(e,i),t=Math.max(t,a)})}return e==1e9?null:{from:e,to:t}}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,n=L.empty){let r=zn(this.doc,e,t,n);return r&&this.step(r),this}replaceWith(e,t,n){return this.replace(e,t,new L(F.from(n),0,0))}delete(e,t){return this.replace(e,t,L.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,n){return Xn(this,e,t,n),this}replaceRangeWith(e,t,n){return Qn(this,e,t,n),this}deleteRange(e,t){return $n(this,e,t),this}lift(e,t){return yn(this,e,t),this}join(e,t=1){return In(this,e,t),this}wrap(e,t){return wn(this,e,t),this}setBlockType(e,t=e,n,r=null){return Tn(this,e,t,n,r),this}setNodeMarkup(e,t,n=null,r){return kn(this,e,t,n,r),this}setNodeAttribute(e,t,n){return this.step(new tr(e,t,n)),this}setDocAttribute(e,t){return this.step(new nr(e,t)),this}addNodeMark(e,t){return this.step(new ln(e,t)),this}removeNodeMark(e,t){let n=this.doc.nodeAt(e);if(!n)throw RangeError(`No node at position `+e);if(t instanceof I)t.isInSet(n.marks)&&this.step(new un(e,t));else{let r=n.marks,i,a=[];for(;i=t.isInSet(r);)a.push(new un(e,i)),r=i.removeFromSet(r);for(let e=a.length-1;e>=0;e--)this.step(a[e])}return this}split(e,t=1,n){return jn(this,e,t,n),this}addMark(e,t,n){return mn(this,e,t,n),this}removeMark(e,t,n){return hn(this,e,t,n),this}clearIncompatible(e,t,n){return gn(this,e,t,n),this}},ar=Object.create(null),R=class{constructor(e,t,n){this.$anchor=e,this.$head=t,this.ranges=n||[new or(e.min(t),e.max(t))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let t=0;t=0;r--){let i=t<0?pr(e.node(0),e.node(r),e.before(r+1),e.index(r),t,n):pr(e.node(0),e.node(r),e.after(r+1),e.index(r)+1,t,n);if(i)return i}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new dr(e.node(0))}static atStart(e){return pr(e,e,0,0,1)||new dr(e)}static atEnd(e){return pr(e,e,e.content.size,e.childCount,-1)||new dr(e)}static fromJSON(e,t){if(!t||!t.type)throw RangeError(`Invalid input for Selection.fromJSON`);let n=ar[t.type];if(!n)throw RangeError(`No selection type ${t.type} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in ar)throw RangeError(`Duplicate use of selection JSON ID `+e);return ar[e]=t,t.prototype.jsonID=e,t}getBookmark(){return z.between(this.$anchor,this.$head).getBookmark()}};R.prototype.visible=!0;var or=class{constructor(e,t){this.$from=e,this.$to=t}},sr=!1;function cr(e){!sr&&!e.parent.inlineContent&&(sr=!0,console.warn(`TextSelection endpoint not pointing into a node with inline content (`+e.parent.type.name+`)`))}var z=class e extends R{constructor(e,t=e){cr(e),cr(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(t,n){let r=t.resolve(n.map(this.head));if(!r.parent.inlineContent)return R.near(r);let i=t.resolve(n.map(this.anchor));return new e(i.parent.inlineContent?i:r,r)}replace(e,t=L.empty){if(super.replace(e,t),t==L.empty){let t=this.$from.marksAcross(this.$to);t&&e.ensureMarks(t)}}eq(t){return t instanceof e&&t.anchor==this.anchor&&t.head==this.head}getBookmark(){return new lr(this.anchor,this.head)}toJSON(){return{type:`text`,anchor:this.anchor,head:this.head}}static fromJSON(t,n){if(typeof n.anchor!=`number`||typeof n.head!=`number`)throw RangeError(`Invalid input for TextSelection.fromJSON`);return new e(t.resolve(n.anchor),t.resolve(n.head))}static create(e,t,n=t){let r=e.resolve(t);return new this(r,n==t?r:e.resolve(n))}static between(t,n,r){let i=t.pos-n.pos;if((!r||i)&&(r=i>=0?1:-1),!n.parent.inlineContent){let e=R.findFrom(n,r,!0)||R.findFrom(n,-r,!0);if(e)n=e.$head;else return R.near(n,r)}return t.parent.inlineContent||(i==0?t=n:(t=(R.findFrom(t,-r,!0)||R.findFrom(t,r,!0)).$anchor,t.pos0?0:1);i>0?o=0;o+=i){let r=t.child(o);if(!r.isAtom){let t=pr(e,r,n+i,i<0?r.childCount:0,i,a);if(t)return t}else if(!a&&B.isSelectable(r))return B.create(e,n-(i<0?r.nodeSize:0));n+=r.nodeSize*i}return null}function mr(e,t,n){let r=e.steps.length-1;if(r{o??=r}),e.setSelection(R.near(e.doc.resolve(o),n))}var hr=1,gr=2,_r=4,vr=class extends ir{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor0}setStoredMarks(e){return this.storedMarks=e,this.updated|=gr,this}ensureMarks(e){return I.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&gr)>0}addStep(e,t){super.addStep(e,t),this.updated&=-3,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let n=this.selection;return t&&(e=e.mark(this.storedMarks||(n.empty?n.$from.marks():n.$from.marksAcross(n.$to)||I.none))),n.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,n){let r=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(r.text(e),!0):this.deleteSelection();{if(n??=t,!e)return this.deleteRange(t,n);let i=this.storedMarks;if(!i){let e=this.doc.resolve(t);i=n==t?e.marks():e.marksAcross(this.doc.resolve(n))}return this.replaceRangeWith(t,n,r.text(e,i)),!this.selection.empty&&this.selection.to==t+e.length&&this.setSelection(R.near(this.selection.$to)),this}}setMeta(e,t){return this.meta[typeof e==`string`?e:e.key]=t,this}getMeta(e){return this.meta[typeof e==`string`?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=_r,this}get scrolledIntoView(){return(this.updated&_r)>0}};function yr(e,t){return!t||!e?e:e.bind(t)}var br=class{constructor(e,t,n){this.name=e,this.init=yr(t.init,n),this.apply=yr(t.apply,n)}},xr=[new br(`doc`,{init(e){return e.doc||e.schema.topNodeType.createAndFill()},apply(e){return e.doc}}),new br(`selection`,{init(e,t){return e.selection||R.atStart(t.doc)},apply(e){return e.selection}}),new br(`storedMarks`,{init(e){return e.storedMarks||null},apply(e,t,n,r){return r.selection.$cursor?e.storedMarks:null}}),new br(`scrollToSelection`,{init(){return 0},apply(e,t){return e.scrolledIntoView?t+1:t}})],Sr=class{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=xr.slice(),t&&t.forEach(e=>{if(this.pluginsByKey[e.key])throw RangeError(`Adding different instances of a keyed plugin (`+e.key+`)`);this.plugins.push(e),this.pluginsByKey[e.key]=e,e.spec.state&&this.fields.push(new br(e.key,e.spec.state,e))})}},Cr=class e{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,t=-1){for(let n=0;ne.toJSON())),e&&typeof e==`object`)for(let n in e){if(n==`doc`||n==`selection`)throw RangeError("The JSON fields `doc` and `selection` are reserved");let r=e[n],i=r.spec.state;i&&i.toJSON&&(t[n]=i.toJSON.call(r,this[r.key]))}return t}static fromJSON(t,n,r){if(!n)throw RangeError(`Invalid input for EditorState.fromJSON`);if(!t.schema)throw RangeError(`Required config field 'schema' missing`);let i=new Sr(t.schema,t.plugins),a=new e(i);return i.fields.forEach(e=>{if(e.name==`doc`)a.doc=Ge.fromJSON(t.schema,n.doc);else if(e.name==`selection`)a.selection=R.fromJSON(a.doc,n.selection);else if(e.name==`storedMarks`)n.storedMarks&&(a.storedMarks=n.storedMarks.map(t.schema.markFromJSON));else{if(r)for(let i in r){let o=r[i],s=o.spec.state;if(o.key==e.name&&s&&s.fromJSON&&Object.prototype.hasOwnProperty.call(n,i)){a[e.name]=s.fromJSON.call(o,t,n[i],a);return}}a[e.name]=e.init(t,a)}}),a}};function wr(e,t,n){for(let r in e){let i=e[r];i instanceof Function?i=i.bind(t):r==`handleDOMEvents`&&(i=wr(i,t,{})),n[r]=i}return n}var V=class{constructor(e){this.spec=e,this.props={},e.props&&wr(e.props,this,this.props),this.key=e.key?e.key.key:Er(`plugin`)}getState(e){return e[this.key]}},Tr=Object.create(null);function Er(e){return e in Tr?e+`$`+ ++Tr[e]:(Tr[e]=0,e+`$`)}var H=class{constructor(e=`key`){this.key=Er(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}},Dr=(e,t)=>!e.selection.empty&&(t&&t(e.tr.deleteSelection().scrollIntoView()),!0);function Or(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock(`backward`,e):n.parentOffset>0)?null:n}var kr=(e,t,n)=>{let r=Or(e,n);if(!r)return!1;let i=Fr(r);if(!i){let n=r.blockRange(),i=n&&vn(n);return i!=null&&(t&&t(e.tr.lift(n,i).scrollIntoView()),!0)}let a=i.nodeBefore;if($r(e,i,t,-1))return!0;if(r.parent.content.size==0&&(Nr(a,`end`)||B.isSelectable(a)))for(let n=r.depth;;n--){let o=zn(e.doc,r.before(n),r.after(n),L.empty);if(o&&o.slice.size1)break}return a.isAtom&&i.depth==r.depth-1?(t&&t(e.tr.delete(i.pos-a.nodeSize,i.pos).scrollIntoView()),!0):!1},Ar=(e,t,n)=>{let r=Or(e,n);if(!r)return!1;let i=Fr(r);return i?Mr(e,i,t):!1},jr=(e,t,n)=>{let r=Ir(e,n);if(!r)return!1;let i=zr(r);return i?Mr(e,i,t):!1};function Mr(e,t,n){let r=t.nodeBefore,i=t.pos-1;for(;!r.isTextblock;i--){if(r.type.spec.isolating)return!1;let e=r.lastChild;if(!e)return!1;r=e}let a=t.nodeAfter,o=t.pos+1;for(;!a.isTextblock;o++){if(a.type.spec.isolating)return!1;let e=a.firstChild;if(!e)return!1;a=e}let s=zn(e.doc,i,o,L.empty);if(!s||s.from!=i||s instanceof dn&&s.slice.size>=o-i)return!1;if(n){let t=e.tr.step(s);t.setSelection(z.create(t.doc,i)),n(t.scrollIntoView())}return!0}function Nr(e,t,n=!1){for(let r=e;r;r=t==`start`?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&r.childCount!=1)return!1}return!1}var Pr=(e,t,n)=>{let{$head:r,empty:i}=e.selection,a=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock(`backward`,e):r.parentOffset>0)return!1;a=Fr(r)}let o=a&&a.nodeBefore;return!o||!B.isSelectable(o)?!1:(t&&t(e.tr.setSelection(B.create(e.doc,a.pos-o.nodeSize)).scrollIntoView()),!0)};function Fr(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){if(e.index(t)>0)return e.doc.resolve(e.before(t+1));if(e.node(t).type.spec.isolating)break}return null}function Ir(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock(`forward`,e):n.parentOffset{let r=Ir(e,n);if(!r)return!1;let i=zr(r);if(!i)return!1;let a=i.nodeAfter;if($r(e,i,t,1))return!0;if(r.parent.content.size==0&&(Nr(a,`start`)||B.isSelectable(a))){let n=zn(e.doc,r.before(),r.after(),L.empty);if(n&&n.slice.size{let{$head:r,empty:i}=e.selection,a=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock(`forward`,e):r.parentOffset=0;t--){let n=e.node(t);if(e.index(t)+1{let n=e.selection,r=n instanceof B,i;if(r){if(n.node.isTextblock||!Mn(e.doc,n.from))return!1;i=n.from}else if(i=Fn(e.doc,n.from,-1),i==null)return!1;if(t){let n=e.tr.join(i);r&&n.setSelection(B.create(n.doc,i-e.doc.resolve(i).nodeBefore.nodeSize)),t(n.scrollIntoView())}return!0},Vr=(e,t)=>{let n=e.selection,r;if(n instanceof B){if(n.node.isTextblock||!Mn(e.doc,n.to))return!1;r=n.to}else if(r=Fn(e.doc,n.to,1),r==null)return!1;return t&&t(e.tr.join(r).scrollIntoView()),!0},Hr=(e,t)=>{let{$from:n,$to:r}=e.selection,i=n.blockRange(r),a=i&&vn(i);return a!=null&&(t&&t(e.tr.lift(i,a).scrollIntoView()),!0)},Ur=(e,t)=>{let{$head:n,$anchor:r}=e.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(t&&t(e.tr.insertText(` -`).scrollIntoView()),!0)};function Wr(e){for(let t=0;t{let{$head:n,$anchor:r}=e.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let i=n.node(-1),a=n.indexAfter(-1),o=Wr(i.contentMatchAt(a));if(!o||!i.canReplaceWith(a,a,o))return!1;if(t){let r=n.after(),i=e.tr.replaceWith(r,r,o.createAndFill());i.setSelection(R.near(i.doc.resolve(r),1)),t(i.scrollIntoView())}return!0},Kr=(e,t)=>{let n=e.selection,{$from:r,$to:i}=n;if(n instanceof dr||r.parent.inlineContent||i.parent.inlineContent)return!1;let a=Wr(i.parent.contentMatchAt(i.indexAfter()));if(!a||!a.isTextblock)return!1;if(t){let n=(!r.parentOffset&&i.index(){let{$cursor:n}=e.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let r=n.before();if(An(e.doc,r))return t&&t(e.tr.split(r).scrollIntoView()),!0}let r=n.blockRange(),i=r&&vn(r);return i!=null&&(t&&t(e.tr.lift(r,i).scrollIntoView()),!0)};function Jr(e){return(t,n)=>{if(t.selection instanceof B&&t.selection.node.isBlock){let{$from:e}=t.selection;return!e.parentOffset||!An(t.doc,e.pos)?!1:(n&&n(t.tr.split(e.pos).scrollIntoView()),!0)}if(!t.selection.$from.depth)return!1;let r=t.tr;!t.selection.empty&&(t.selection instanceof z||t.selection instanceof dr)&&r.deleteSelection();let{$from:i}=r.selection,a=r.steps.length,o=[],s,c,l=!1,u=!1;for(let t=i.depth;;t--)if(i.node(t).isBlock){l=i.end(t)==i.pos+(i.depth-t),u=i.start(t)==i.pos-(i.depth-t),c=Wr(i.node(t-1).contentMatchAt(i.indexAfter(t-1)));let n=e&&e(i.parent,l,i);o.unshift(n||(l&&c?{type:c}:null)),s=t;break}else{if(t==1)return!1;o.unshift(null)}let d=i.pos,f=An(r.doc,d,o.length,o);if(f||=(o[0]=c?{type:c}:null,An(r.doc,d,o.length,o)),!f)return!1;if(r.split(d,o.length,o),!l&&u&&i.node(s).type!=c){let e=r.mapping.slice(a),t=e.map(i.before(s)),n=r.doc.resolve(t);c&&i.node(s-1).canReplaceWith(n.index(),n.index()+1,c)&&r.setNodeMarkup(e.map(i.before(s)),c)}return n&&n(r.scrollIntoView()),!0}}var Yr=Jr(),Xr=(e,t)=>{let{$from:n,to:r}=e.selection,i,a=n.sharedDepth(r);return a!=0&&(i=n.before(a),t&&t(e.tr.setSelection(B.create(e.doc,i))),!0)},Zr=(e,t)=>(t&&t(e.tr.setSelection(new dr(e.doc))),!0);function Qr(e,t,n){let r=t.nodeBefore,i=t.nodeAfter,a=t.index();return!r||!i||!r.type.compatibleContent(i.type)?!1:!r.content.size&&t.parent.canReplace(a-1,a)?(n&&n(e.tr.delete(t.pos-r.nodeSize,t.pos).scrollIntoView()),!0):!t.parent.canReplace(a,a+1)||!(i.isTextblock||Mn(e.doc,t.pos))?!1:(n&&n(e.tr.join(t.pos).scrollIntoView()),!0)}function $r(e,t,n,r){let i=t.nodeBefore,a=t.nodeAfter,o,s,c=i.type.spec.isolating||a.type.spec.isolating;if(!c&&Qr(e,t,n))return!0;let l=!c&&t.parent.canReplace(t.index(),t.index()+1);if(l&&(o=(s=i.contentMatchAt(i.childCount)).findWrapping(a.type))&&s.matchType(o[0]||a.type).validEnd){if(n){let r=t.pos+a.nodeSize,s=F.empty;for(let e=o.length-1;e>=0;e--)s=F.from(o[e].create(null,s));s=F.from(i.copy(s));let c=e.tr.step(new fn(t.pos-1,r,t.pos,r,new L(s,1,0),o.length,!0)),l=c.doc.resolve(r+2*o.length);l.nodeAfter&&l.nodeAfter.type==i.type&&Mn(c.doc,l.pos)&&c.join(l.pos),n(c.scrollIntoView())}return!0}let u=a.type.spec.isolating||r>0&&c?null:R.findFrom(t,1),d=u&&u.$from.blockRange(u.$to),f=d&&vn(d);if(f!=null&&f>=t.depth)return n&&n(e.tr.lift(d,f).scrollIntoView()),!0;if(l&&Nr(a,`start`,!0)&&Nr(i,`end`)){let r=i,o=[];for(;o.push(r),!r.isTextblock;)r=r.lastChild;let s=a,c=1;for(;!s.isTextblock;s=s.firstChild)c++;if(r.canReplace(r.childCount,r.childCount,s.content)){if(n){let r=F.empty;for(let e=o.length-1;e>=0;e--)r=F.from(o[e].copy(r));n(e.tr.step(new fn(t.pos-o.length,t.pos+a.nodeSize,t.pos+c,t.pos+a.nodeSize-c,new L(r,o.length,0),0,!0)).scrollIntoView())}return!0}}return!1}function ei(e){return function(t,n){let r=t.selection,i=e<0?r.$from:r.$to,a=i.depth;for(;i.node(a).isInline;){if(!a)return!1;a--}return i.node(a).isTextblock?(n&&n(t.tr.setSelection(z.create(t.doc,e<0?i.start(a):i.end(a)))),!0):!1}}var ti=ei(-1),ni=ei(1);function ri(e,t=null){return function(n,r){let{$from:i,$to:a}=n.selection,o=i.blockRange(a),s=o&&bn(o,e,t);return s?(r&&r(n.tr.wrap(o,s).scrollIntoView()),!0):!1}}function ii(e,t=null){return function(n,r){let i=!1;for(let r=0;r{if(i)return!1;if(r.isTextblock&&!r.hasMarkup(e,t)){if(r.type==e)i=!0;else{let t=n.doc.resolve(a),r=t.index();i=t.parent.canReplaceWith(r,r+1,e)}}})}if(!i)return!1;if(r){let i=n.tr;for(let r=0;r=2&&t.$from.node(t.depth-1).type.compatibleContent(n)&&t.startIndex==0){if(t.$from.index(t.depth-1)==0)return!1;let e=o.resolve(t.start-2);a=new Ue(e,e,t.depth),t.endIndex=0;e--)a=F.from(n[e].type.create(n[e].attrs,a));e.step(new fn(t.start-(r?2:0),t.end,t.start,t.end,new L(a,0,0),n.length,!0));let o=0;for(let e=0;e-1}function mi(e){return function(t,n){let{$from:r,$to:i}=t.selection,a=r.blockRange(i,t=>t.childCount>0&&pi(e,t.firstChild.type));return a?n?pi(e,r.node(a.depth-1).type)?hi(t,n,a):gi(t,n,a):!0:!1}}function hi(e,t,n){let r=e.tr,i=n.end,a=n.$to.end(n.depth),o=n.parent.child(n.endIndex-1).type;ia;t--)e-=i.child(t).nodeSize,r.delete(e-1,e+1);let a=r.doc.resolve(n.start),o=a.nodeAfter;if(r.mapping.map(n.end)!=n.start+a.nodeAfter.nodeSize)return!1;let s=n.startIndex==0,c=n.endIndex==i.childCount,l=a.node(-1),u=a.index(-1);if(!l.canReplace(u+ +!s,u+1,o.content.append(c?F.empty:F.from(i))))return!1;let d=a.pos,f=d+o.nodeSize;return r.step(new fn(d-+!!s,f+ +!!c,d+1,f-1,new L((s?F.empty:F.from(i.copy(F.empty))).append(c?F.empty:F.from(i.copy(F.empty))),+!s,+!c),+!s)),t(r.scrollIntoView()),!0}function _i(e){return function(t,n){let{$from:r,$to:i}=t.selection,a=r.blockRange(i,t=>t.childCount>0&&pi(e,t.firstChild.type));if(!a)return!1;let o=a.startIndex;if(o==0)return!1;let s=a.parent,c=s.child(o-1);if(!pi(e,c.type))return!1;if(n){let e=c.lastChild&&c.lastChild.type==s.type,r=F.from(e?c.lastChild.lastChild.type.create():null),i=new L(F.from(c.type.create(null,F.from(s.type.create(null,r)))),e?3:1,0),o=a.start,l=a.end;n(t.tr.step(new fn(o-(e?3:1),l,o,l,i,1,!0)).scrollIntoView())}return!0}}var vi=function(e){for(var t=0;;t++)if(e=e.previousSibling,!e)return t},yi=function(e){let t=e.assignedSlot||e.parentNode;return t&&t.nodeType==11?t.host:t},bi=null,xi=function(e,t,n){let r=bi||=document.createRange();return r.setEnd(e,n??e.nodeValue.length),r.setStart(e,t||0),r},Si=function(){bi=null},Ci=function(e,t,n,r){return n&&(Ti(e,t,n,r,-1)||Ti(e,t,n,r,1))},wi=/^(img|br|input|textarea|hr)$/i;function Ti(e,t,n,r,i){for(;;){if(e==n&&t==r)return!0;if(t==(i<0?0:Ei(e))){let n=e.parentNode;if(!n||!U(n)||Mi(e)||wi.test(e.nodeName)||e.contentEditable==`false`)return!1;t=vi(e)+(i<0?0:1),e=n}else if(U(e)){let n=e.childNodes[t+(i<0?-1:0)];if(U(n)&&n.contentEditable==`false`){if(n.pmViewDesc?.ignoreForSelection)t+=i;else return!1}else e=n,t=i<0?Ei(e):0}else return!1}}function Ei(e){return e.nodeType==3?e.nodeValue.length:e.childNodes.length}function U(e){return e.nodeType==1}function Di(e){return e.nodeType==3}function Oi(e,t){return t?e.contains(U(t)?t:t.parentNode):!1}function ki(e,t){for(;;){if(Di(e)&&t)return e;if(U(e)&&t>0){if(e.contentEditable==`false`)return null;e=e.childNodes[t-1],t=Ei(e)}else if(e.parentNode&&!Mi(e))t=vi(e),e=e.parentNode;else return null}}function Ai(e,t){for(;;){if(Di(e)&&t2),Zi=Xi||(Li?/Mac/.test(Li.platform):!1),Qi=Li?/Win/.test(Li.platform):!1,$i=/Android \d/.test(zi),ea=!!Ri&&`webkitFontSmoothing`in Ri.documentElement.style,ta=ea?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function na(e){let t=e.defaultView&&e.defaultView.visualViewport;return t?{left:0,right:t.width,top:0,bottom:t.height}:{left:0,right:e.documentElement.clientWidth,top:0,bottom:e.documentElement.clientHeight}}function ra(e,t){return typeof e==`number`?e:e[t]}function ia(e){let t=e.getBoundingClientRect(),n=t.width/e.offsetWidth||1,r=t.height/e.offsetHeight||1;return{left:t.left,right:t.left+e.clientWidth*n,top:t.top,bottom:t.top+e.clientHeight*r}}function aa(e,t,n){if(!ba(t)&&t.left==0)return;let r=e.someProp(`scrollThreshold`)||0,i=e.someProp(`scrollMargin`)||5,a=e.dom.ownerDocument;for(let o=n||e.dom;o;){if(!U(o)){o=yi(o);continue}let e=o==a.body,n=e?na(a):ia(o),s=0,c=0;if(t.topn.bottom-ra(r,`bottom`)&&(c=t.bottom-t.top>n.bottom-n.top?t.top+ra(i,`top`)-n.top:t.bottom-n.bottom+ra(i,`bottom`)),t.leftn.right-ra(r,`right`)&&(s=t.right-n.right+ra(i,`right`)),s||c){if(e)a.defaultView.scrollBy(s,c);else{let e=o.scrollLeft,n=o.scrollTop;c&&(o.scrollTop+=c),s&&(o.scrollLeft+=s);let r=o.scrollLeft-e,i=o.scrollTop-n;t={left:t.left-r,top:t.top-i,right:t.right-r,bottom:t.bottom-i}}}let l=e?`fixed`:getComputedStyle(o).position;if(/^(fixed|sticky)$/.test(l))break;o=l==`absolute`?o.offsetParent:yi(o)}}function oa(e){let t=e.dom.getBoundingClientRect(),n=Math.max(0,t.top),r,i;for(let a=(t.left+t.right)/2,o=n+1;o=n-20){r=t,i=s.top;break}}return{refDOM:r,refTop:i,stack:sa(e.dom)}}function sa(e){let t=[],n=e.ownerDocument;for(let r=e;r&&(t.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),e!=n);r=yi(r));return t}function ca({refDOM:e,refTop:t,stack:n}){let r=e?e.getBoundingClientRect().top:0;la(n,r==0?0:r-t)}function la(e,t){for(let n=0;n=s){o=Math.max(p.bottom,o),s=Math.min(p.top,s);let e=p.left>t.left?p.left-t.left:p.right=(p.left+p.right)/2));continue}}else p.top>t.top&&!c&&p.left<=t.left&&p.right>=t.left&&(c=u,l={left:Math.max(p.left,Math.min(p.right,t.left)),top:p.top});!n&&(t.left>=p.right&&t.top>=p.top||t.left>=p.left&&t.top>=p.bottom)&&(a=d+1)}}return!n&&c&&(n=c,i=l,r=0),n&&Di(n)?pa(n,i):!n||r?{node:e,offset:a}:fa(n,i)}function pa(e,t){let n=e.nodeValue.length,r=document.createRange(),i;for(let a=0;a=(n.left+n.right)/2)};break}}return r.detach(),i||{node:e,offset:0}}function ma(e,t){return e.left>=t.left-1&&e.left<=t.right+1&&e.top>=t.top-1&&e.top<=t.bottom+1}function ha(e,t){let n=e.parentNode;return n&&/^li$/i.test(n.nodeName)&&t.left(e.left+e.right)/2?1:-1}return e.docView.posFromDOM(r,i,a)}function _a(e,t,n,r){let i=-1;for(let n=t,a=!1;n!=e.dom;){let t=e.docView.nearestDesc(n,!0),o;if(!t)return null;if(U(t.dom)&&(t.node.isBlock&&t.parent||!t.contentDOM)&&((o=t.dom.getBoundingClientRect()).width||o.height)&&(t.node.isBlock&&t.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(t.dom.nodeName)&&(!a&&o.left>r.left||o.top>r.top?i=t.posBefore:(!a&&o.right-1?i:e.docView.posFromDOM(t,n,-1)}function va(e,t,n){let r=e.childNodes.length;if(r&&n.topt.top&&i++}let n;ea&&i&&U(r)&&U(n=r.childNodes[i-1])&&n.contentEditable==`false`&&n.getBoundingClientRect().top>=t.top&&i--,r==e.dom&&i==r.childNodes.length-1&&U(r.lastChild)&&t.top>r.lastChild.getBoundingClientRect().bottom?s=e.state.doc.content.size:i!=0&&U(r)&&r.childNodes[i-1].nodeName==`BR`||(s=_a(e,r,i,t))}s??=ga(e,o,t);let c=e.docView.nearestDesc(o,!0);return{pos:s,inside:c?c.posAtStart-c.border:-1}}function ba(e){return e.top=0&&i==r.nodeValue.length?(e--,a=1):n<0?e--:t++,wa(xa(xi(r,e,t),a),a<0)}}if(!e.state.doc.resolve(t-(a||0)).parent.inlineContent){if(a==null&&i&&(n<0||i==Ei(r))){let e=r.childNodes[i-1];if(U(e))return Ta(e.getBoundingClientRect(),!1)}if(a==null&&i=0)}if(a==null&&i&&(n<0||i==Ei(r))){let e=r.childNodes[i-1],t=Di(e)?xi(e,Ei(e)-+!o):U(e)&&(e.nodeName!=`BR`||!e.nextSibling)?e:null;if(t)return wa(xa(t,1),!1)}if(a==null&&i=0)}function wa(e,t){if(e.width==0)return e;let n=t?e.left:e.right;return{top:e.top,bottom:e.bottom,left:n,right:n}}function Ta(e,t){if(e.height==0)return e;let n=t?e.top:e.bottom;return{top:n,bottom:n,left:e.left,right:e.right}}function Ea(e,t,n){let r=e.state,i=e.root.activeElement;r!=t&&e.updateState(t),i!=e.dom&&e.focus();try{return n()}finally{r!=t&&e.updateState(r),i!=e.dom&&i&&i.focus()}}function Da(e,t,n){let r=t.selection,i=n==`up`?r.$from:r.$to;return Ea(e,t,()=>{let{node:t}=e.docView.domFromPos(i.pos,n==`up`?-1:1);for(;;){let n=e.docView.nearestDesc(t,!0);if(!n)break;if(n.node.isBlock){t=n.contentDOM||n.dom;break}t=n.dom.parentNode}let r=Ca(e,i.pos,1);for(let e=t.firstChild;e;e=e.nextSibling){let t;if(U(e))t=e.getClientRects();else if(Di(e))t=xi(e,0,e.nodeValue.length).getClientRects();else continue;for(let e=0;ei.top+1&&(n==`up`?r.top-i.top>(i.bottom-r.top)*2:i.bottom-r.bottom>(r.bottom-i.top)*2))return!1}}return!0})}var Oa=/[\u0590-\u08ac]/;function ka(e,t,n){let{$head:r}=t.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,a=!i,o=i==r.parent.content.size,s=e.domSelection();return s?!Oa.test(r.parent.textContent)||!s.modify?n==`left`||n==`backward`?a:o:Ea(e,t,()=>{let{focusNode:t,focusOffset:i,anchorNode:a,anchorOffset:o}=e.domSelectionRange(),c=s.caretBidiLevel;s.modify(`move`,n,`character`);let l=r.depth?e.docView.domAfterPos(r.before()):e.dom,{focusNode:u,focusOffset:d}=e.domSelectionRange(),f=u&&!Oi(l,u)||t==u&&i==d;try{s.collapse(a,o),t&&(t!=a||i!=o)&&s.extend&&s.extend(t,i)}catch{}return c!=null&&(s.caretBidiLevel=c),f}):r.pos==r.start()||r.pos==r.end()}var Aa=null,ja=null,Ma=!1;function Na(e,t,n){return Aa==t&&ja==n?Ma:(Aa=t,ja=n,Ma=n==`up`||n==`down`?Da(e,t,n):ka(e,t,n))}var Pa=0,Fa=1,Ia=2,La=3,Ra=class{constructor(e,t,n,r){this.parent=e,this.children=t,this.dom=n,this.contentDOM=r,this.dirty=Pa,n.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,n){return!1}matchesHack(e){return!1}parseRule(e){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;tvi(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM)){let n=e.compareDocumentPosition(this.contentDOM);r=n&16?t>Array.from(e.childNodes).findIndex(e=>e.contains(this.contentDOM)):!(n&4)}else if(this.dom.firstChild){if(t==0)for(let t=e;;t=t.parentNode){if(t==this.dom){r=!1;break}if(t.previousSibling)break}if(r==null&&t==e.childNodes.length)for(let t=e;;t=t.parentNode){if(t==this.dom){r=!0;break}if(t.nextSibling)break}}return r??n>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let n=!0,r=e;r;r=r.parentNode){let i=this.getDesc(r),a;if(i&&(!t||i.node)){if(n&&(a=i.nodeDOM)&&!(U(a)?Oi(a,e):a==e))n=!1;else return i}}}getDesc(e){let t=e.pmViewDesc;for(let e=t;e;e=e.parent)if(e==this)return t}posFromDOM(e,t,n){for(let r=e;r;r=r.parentNode){let i=this.getDesc(r);if(i)return i.localPosFromDOM(e,t,n)}return-1}descAt(e){for(let t=0,n=0;te){r=e-t;break}t=a}if(r)return this.children[n].domFromPos(r-this.children[n].border,t);for(;n>0;n--){let e=this.children[n-1];if(e.size||!(e instanceof Ga||e instanceof za&&e.side>=0))break}if(t<=0){let e,r=!0;for(;e=n?this.children[n-1]:null,e&&e.dom.parentNode!=this.contentDOM;n--,r=!1);return e&&t&&r&&!e.border&&!e.domAtom?e.domFromPos(e.size,t):{node:this.contentDOM,offset:e?vi(e.dom)+1:0}}{let e,r=!0;for(;e=n=i&&t<=s-n.border&&n.node&&n.contentDOM&&this.contentDOM.contains(n.contentDOM))return n.parseRange(e,t,i);e=a;for(let t=o;t>0;t--){let n=this.children[t-1];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(1)){r=vi(n.dom)+1;break}e-=n.size}r==-1&&(r=0)}if(r>-1&&(s>t||o==this.children.length-1)){t=s;for(let e=o+1;es&&at){let e=o;o=s,s=e}let n=document.createRange();n.setEnd(s.node,s.offset),n.setStart(o.node,o.offset),c.removeAllRanges(),c.addRange(n)}}ignoreMutation(e){return!this.contentDOM&&e.type!=`selection`}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let n=0,r=0;r=n:en){let r=n+i.border,o=a-i.border;if(e>=r&&t<=o){this.dirty=e==n||t==a?Ia:Fa,e==r&&t==o&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=La:i.markDirty(e-r,t-r);return}i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?Ia:La}n=a}this.dirty=Ia}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let n=e==1?Ia:Fa;t.dirty{if(!i)return r;if(i.parent)return i.parent.posBeforeChild(i)})),!t.type.spec.raw){let e=U(a)?a:document.createElement(`span`);e!=a&&(e.appendChild(a),a=e),e.hasAttribute(`contenteditable`)||(e.contentEditable=`false`),e.classList.add(`ProseMirror-widget`)}super(e,[],a,null),this.widget=t,this.widget=t,i=this}matchesWidget(e){return this.dirty==Pa&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return t?t(e):!1}ignoreMutation(e){return e.type!=`selection`||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}},Ba=class extends Ra{constructor(e,t,n,r){super(e,[],t,null),this.textDOM=n,this.text=r}get size(){return this.text.length}localPosFromDOM(e,t){return e==this.textDOM?this.posAtStart+t:this.posAtStart+(t?this.size:0)}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type===`characterData`&&e.target.nodeValue==e.oldValue}},Va=class e extends Ra{constructor(e,t,n,r,i){super(e,[],n,r),this.mark=t,this.spec=i}static create(t,n,r,i){let a=i.nodeViews[n.type.name],o=a&&a(n,i,r);return o&&o.dom||(o=Ft.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new e(t,n,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty&La||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=La&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=Pa){let e=this.parent;for(;!e.node;)e=e.parent;e.dirty0&&(a=co(a,0,t,r));for(let e=0;e{if(!c)return o;if(c.parent)return c.parent.posBeforeChild(c)},r,i),u=l&&l.dom,d=l&&l.contentDOM;if(n.isText){if(!u)u=document.createTextNode(n.text);else if(!Di(u))throw RangeError(`Text must be rendered as a DOM text node`)}else if(!u){let e=Ft.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs);({dom:u,contentDOM:d}=e)}!d&&!n.isText&&u.nodeName!=`BR`&&(u.hasAttribute(`contenteditable`)||(u.contentEditable=`false`),n.type.spec.draggable&&(u.draggable=!0));let f=u;return u=$a(u,r,n),l?c=new Ka(t,n,r,i,u,d||null,f,l):n.isText?new Wa(t,n,r,i,u,f):new e(t,n,r,i,u,d||null,f)}parseRule(e){if(this.node.type.spec.reparseInView)return null;let t={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace==`pre`&&(t.preserveWhitespace=`full`),!this.contentDOM)t.getContent=()=>this.node.content;else if(!this.contentLost)t.contentElement=this.contentDOM;else{for(let e=this.children.length-1;e>=0;e--){let n=this.children[e];if(this.dom.contains(n.dom.parentNode)){t.contentElement=n.dom.parentNode;break}}if(!t.contentElement){let n=e&&e.find(t=>U(t)&&e.indexOf(t.parentNode)<0&&this.dom.contains(t));n?t.contentElement=n:t.getContent=()=>F.empty}}return t}matchesNode(e,t,n){return this.dirty==Pa&&e.eq(this.node)&&eo(t,this.outerDeco)&&n.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return+!this.node.isLeaf}updateChildren(e,t){let n=this.node.inlineContent,r=t,i=e.composing?this.localCompositionInfo(e,t):null,a=i&&i.pos>-1?i:null,o=i&&i.pos<0,s=new no(this,a&&a.node,e),c=this.node.inlineContent,l=c&&this.node.isBlock;ao(this.node,this.innerDeco,(t,i,a)=>{t.spec.marks?s.syncToMarks(t.spec.marks,n,e,i):t.type.side>=0&&!a&&s.syncToMarks(i==this.node.childCount?I.none:this.node.child(i).marks,n,e,i),s.placeWidget(t,e,r)},(t,a,u,d)=>{s.syncToMarks(t.marks,n,e,d),l&&t.isAtom&&!t.isText&&s.addHackNode(`IMG`,s.top);let f;s.findNodeMatch(t,a,u,d)||o&&e.state.selection.from>r&&e.state.selection.to-1&&s.updateNodeAt(t,a,u,f,e)||s.updateNextNode(t,a,u,e,d,r)||s.addNode(t,a,u,e,r),r+=t.nodeSize,c&&(l=t.isAtom&&!t.isText)}),s.syncToMarks([],n,e,0),this.node.isTextblock&&s.addTextblockHacks(),s.destroyRest(),(s.changed||this.dirty==Ia)&&(a&&this.protectLocalComposition(e,a),qa(this.contentDOM,this.children,e),Xi&&oo(this.dom))}localCompositionInfo(e,t){let{from:n,to:r}=e.state.selection;if(!(e.state.selection instanceof z)||nt+this.node.content.size)return null;let i=e.input.compositionNode;if(!i||!this.dom.contains(i.parentNode))return null;if(this.node.inlineContent){let e=i.nodeValue,a=so(this.node.content,e,n-t,r-t);return a<0?null:{node:i,pos:a,text:e}}return{node:i,pos:-1,text:``}}protectLocalComposition(e,{node:t,pos:n,text:r}){if(this.getDesc(t))return;let i=t;for(;i.parentNode!=this.contentDOM;i=i.parentNode){for(;i.previousSibling;)i.parentNode.removeChild(i.previousSibling);for(;i.nextSibling;)i.parentNode.removeChild(i.nextSibling);i.pmViewDesc&&(i.pmViewDesc=void 0)}let a=new Ba(this,i,t,r);e.input.compositionNodes.push(a),this.children=co(this.children,n,n+r.length,e,a)}update(e,t,n,r){return this.dirty==La||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,n,r),!0)}updateInner(e,t,n,r){this.updateOuterDeco(t),this.node=e,this.innerDeco=n,this.contentDOM&&this.updateChildren(r,this.posAtStart),this.dirty=Pa}updateOuterDeco(e){if(eo(e,this.outerDeco))return;let t=!U(this.nodeDOM),n=this.dom;this.dom=Za(this.dom,this.nodeDOM,Xa(this.outerDeco,this.node,t),Xa(e,this.node,t)),this.dom!=n&&(n.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){U(this.nodeDOM)&&(this.nodeDOM.classList.add(`ProseMirror-selectednode`),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){U(this.nodeDOM)&&(this.nodeDOM.classList.remove(`ProseMirror-selectednode`),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute(`draggable`))}get domAtom(){return this.node.isAtom}};function Ua(e,t,n,r,i){$a(r,t,e);let a=new Ha(void 0,e,t,n,r,r,r);return a.contentDOM&&a.updateChildren(i,0),a}var Wa=class e extends Ha{constructor(e,t,n,r,i,a){super(e,t,n,r,i,null,a)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,n,r){return this.dirty==La||this.dirty!=Pa&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=Pa||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,r.trackWrites==this.nodeDOM&&(r.trackWrites=null)),this.node=e,this.dirty=Pa,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,n){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,n)}ignoreMutation(e){return e.type!=`characterData`&&e.type!=`selection`}slice(t,n,r){let i=this.node.cut(t,n),a=document.createTextNode(i.text);return new e(this.parent,i,this.outerDeco,this.innerDeco,a,a)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=La)}get domAtom(){return!1}isText(e){return this.node.text==e}},Ga=class extends Ra{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Pa&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName==`IMG`}},Ka=class extends Ha{constructor(e,t,n,r,i,a,o,s){super(e,t,n,r,i,a,o),this.spec=s}update(e,t,n,r){if(this.dirty==La)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let i=this.spec.update(e,t,n);return i&&this.updateInner(e,t,n,r),i}return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,n,r)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,n,r){this.spec.setSelection?this.spec.setSelection(e,t,n.root):super.setSelection(e,t,n,r)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}};function qa(e,t,n){let r=e.firstChild,i=!1;for(let a=0;a>1,o=Math.min(a,e.length);for(;i-1)i>this.index&&(this.changed=!0,this.destroyBetween(this.index,i)),this.top=this.top.children[this.index];else{let r=Va.create(this.top,e[a],t,n);this.top.children.splice(this.index,0,r),this.top=r,this.changed=!0}this.index=0,a++}}findNodeMatch(e,t,n,r){let i=-1,a;if(r>=this.preMatch.index&&(a=this.preMatch.matches[r-this.preMatch.index]).parent==this.top&&a.matchesNode(e,t,n))i=this.top.children.indexOf(a,this.index);else for(let r=this.index,a=Math.min(this.top.children.length,r+5);r0;){let s;for(;;)if(r){let e=n.children[r-1];if(e instanceof Va)n=e,r=e.children.length;else{s=e,r--;break}}else if(n==t)break outer;else r=n.parent.children.indexOf(n),n=n.parent;let c=s.node;if(c){if(c!=e.child(i-1))break;--i,a.set(s,i),o.push(s)}}return{index:i,matched:a,matches:o.reverse()}}function io(e,t){return e.type.side-t.type.side}function ao(e,t,n,r){let i=t.locals(e),a=0;if(i.length==0){for(let n=0;na;)s.push(i[o++]);let m=a+f.nodeSize;if(f.isText){let e=m;o!e.inline):s.slice();r(f,h,t.forChild(a,f),p),a=m}}function oo(e){if(e.nodeName==`UL`||e.nodeName==`OL`){let t=e.style.cssText;e.style.cssText=t+`; list-style: square !important`,window.getComputedStyle(e).listStyle,e.style.cssText=t}}function so(e,t,n,r){for(let i=0,a=0;i=n){if(a>=r&&c.slice(r-t.length-s,r-s)==t)return r-t.length;let e=s=0&&e+t.length+s>=n)return s+e;if(n==r&&c.length>=r+t.length-s&&c.slice(r-s,r-s+t.length)==t)return r}}return-1}function co(e,t,n,r,i){let a=[];for(let o=0,s=0;o=n||u<=t?a.push(c):(ln&&a.push(c.slice(n-l,c.size,r)))}return a}function lo(e,t=null){let n=e.domSelectionRange(),r=e.state.doc;if(!n.focusNode)return null;let i=e.docView.nearestDesc(n.focusNode),a=i&&i.size==0,o=e.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(o<0)return null;let s=r.resolve(o),c,l;if(Ni(n)){for(c=o;i&&!i.node;)i=i.parent;if(i&&i.node.isAtom&&B.isSelectable(i.node)&&i.parent&&!(i.node.isInline&&ji(n.focusNode,n.focusOffset,i.dom))){let e=i.posBefore;l=new B(o==e?s:r.resolve(e))}else if(Gi&&t==`key`&&o>e.state.selection.to&&U(n.focusNode)&&n.focusOffset==n.focusNode.childNodes.length&&i&&i.posAtStart>e.state.selection.to)for(let e=n.focusNode;;e=e.parentNode){if(getComputedStyle(e).overflow!=`visible`){l=R.findFrom(r.resolve(i.posAtStart),1);break}if(e==i.dom||e.nextSibling||!e.parentNode||!U(e.parentNode))break}}else{if(n instanceof e.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let t=o,i=o;for(let r=0;r{(n.anchorNode!=r||n.anchorOffset!=i)&&(t.removeEventListener(`selectionchange`,e.input.hideSelectionGuard),setTimeout(()=>{(!uo(e)||e.state.selection.visible)&&e.dom.classList.remove(`ProseMirror-hideselection`)},20))})}function vo(e){let t=e.domSelection();if(!t)return;let n=e.cursorWrapper.dom,r=n.nodeName==`IMG`;r?t.collapse(n.parentNode,vi(n)+1):t.collapse(n,0),!r&&!e.state.selection.visible&&Ui&&Wi<=11&&(n.disabled=!0,n.disabled=!1)}function yo(e,t){if(t instanceof B){let n=e.docView.descAt(t.from);n!=e.lastSelectedViewDesc&&(bo(e),n&&n.selectNode(),e.lastSelectedViewDesc=n)}else bo(e)}function bo(e){e.lastSelectedViewDesc&&=(e.lastSelectedViewDesc.parent&&e.lastSelectedViewDesc.deselectNode(),void 0)}function xo(e,t,n,r){return e.someProp(`createSelectionBetween`,r=>r(e,t,n))||z.between(t,n,r)}function So(e){return e.editable&&!e.hasFocus()?!1:Co(e)}function Co(e){let t=e.domSelectionRange();if(!t.anchorNode)return!1;try{return Oi(e.dom,t.anchorNode)&&(e.editable||Oi(e.dom,t.focusNode))}catch{return!1}}function wo(e){let t=e.docView.domFromPos(e.state.selection.anchor,0),n=e.domSelectionRange();return Ci(t.node,t.offset,n.anchorNode,n.anchorOffset)}function To(e,t){let{$anchor:n,$head:r}=e.selection,i=t>0?n.max(r):n.min(r),a=i.parent.inlineContent?i.depth?e.doc.resolve(t>0?i.after():i.before()):null:i;return a&&R.findFrom(a,t)}function Eo(e,t){return e.dispatch(e.state.tr.setSelection(t).scrollIntoView()),!0}function Do(e,t,n){let r=e.state.selection;if(r instanceof z){if(n.indexOf(`s`)>-1){let{$head:n}=r,i=n.textOffset?null:t<0?n.nodeBefore:n.nodeAfter;if(!i||i.isText||!i.isLeaf)return!1;let a=e.state.doc.resolve(n.pos+i.nodeSize*(t<0?-1:1));return Eo(e,new z(r.$anchor,a))}if(!r.empty)return!1;if(e.endOfTextblock(t>0?`forward`:`backward`)){let n=To(e.state,t);return n&&n instanceof B?Eo(e,n):!1}if(!Zi||n.indexOf(`m`)<0){let n=r.$head,i=n.textOffset?null:t<0?n.nodeBefore:n.nodeAfter,a;if(!i||i.isText)return!1;let o=t<0?n.pos-i.nodeSize:n.pos;return i.isAtom||(a=e.docView.descAt(o))&&!a.contentDOM?B.isSelectable(i)?Eo(e,new B(t<0?e.state.doc.resolve(n.pos-i.nodeSize):n)):Eo(e,new z(e.state.doc.resolve(t<0?o:o+i.nodeSize))):!1}}else if(r instanceof B&&r.node.isInline)return Eo(e,new z(t>0?r.$to:r.$from));else{let n=To(e.state,t);return n?Eo(e,n):!1}}function Oo(e,t){let n=e.pmViewDesc;return n?n.size==0&&(t<0||e.nextSibling||e.nodeName!=`BR`):U(e)&&e.contentEditable==`false`}function ko(e,t){return t<0?Ao(e):jo(e)}function Ao(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let i,a,o=!1;for(Gi&&U(n)&&r0){if(!U(n))break;let e=n.childNodes[r-1];if(Oo(e,-1))i=n,a=--r;else if(Di(e))n=e,r=n.nodeValue.length;else break}else if(Mo(n))break;else{let t=n.previousSibling;for(;t&&Oo(t,-1);)i=n.parentNode,a=vi(t),t=t.previousSibling;if(t)n=t,r=Ei(n);else{if(n=n.parentNode,n==e.dom)break;r=0}}o?Fo(e,n,r):i&&Fo(e,i,a)}function jo(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let i=Ei(n),a,o;for(;;)if(r{e.state==a&&fo(e)},50)}function Io(e,t){let n=e.state.doc.resolve(t);if(!(qi||Qi)&&n.parent.inlineContent){let r=e.coordsAtPos(t);if(t>n.start()){let n=e.coordsAtPos(t-1),i=(n.top+n.bottom)/2;if(i>r.top&&i1)return n.leftr.top&&i1)return n.left>r.left?`ltr`:`rtl`}}let r=e.dom;for(let t=n.depth;t>0;t--)if(n.node(t).isBlock){r=e.nodeDOM(n.before(t))||r;break}return getComputedStyle(r).direction==`rtl`?`rtl`:`ltr`}function Lo(e,t,n){let r=e.state.selection;if(r instanceof z&&!r.empty||n.indexOf(`s`)>-1||Zi&&n.indexOf(`m`)>-1)return!1;let{$from:i,$to:a}=r;if(!i.parent.inlineContent||e.endOfTextblock(t<0?`up`:`down`)){let n=To(e.state,t);if(n&&n instanceof B)return Eo(e,n)}if(!i.parent.inlineContent){let n=t<0?i:a,o=r instanceof dr?R.near(n,t):R.findFrom(n,t);return o?Eo(e,o):!1}return!1}function Ro(e,t){if(!(e.state.selection instanceof z))return!0;let{$head:n,$anchor:r,empty:i}=e.state.selection;if(!n.sameParent(r))return!0;if(!i)return!1;if(e.endOfTextblock(t>0?`forward`:`backward`))return!0;let a=!n.textOffset&&(t<0?n.nodeBefore:n.nodeAfter);if(a&&!a.isText){let r=e.state.tr;return t<0?r.delete(n.pos-a.nodeSize,n.pos):r.delete(n.pos,n.pos+a.nodeSize),e.dispatch(r),!0}return!1}function zo(e,t,n){e.domObserver.stop(),t.contentEditable=n,e.domObserver.start()}function Bo(e){if(!Yi||e.state.selection.$head.parentOffset>0)return!1;let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(t&&U(t)&&n==0&&t.firstChild&&U(t.firstChild)&&t.firstChild.contentEditable==`false`){let n=t.firstChild;zo(e,n,`true`),setTimeout(()=>zo(e,n,`false`),20)}return!1}function Vo(e){let t=``;return e.ctrlKey&&(t+=`c`),e.metaKey&&(t+=`m`),e.altKey&&(t+=`a`),e.shiftKey&&(t+=`s`),t}function Ho(e,t){let n=t.keyCode,r=Vo(t);if(n==8||Zi&&n==72&&r==`c`)return Ro(e,-1)||ko(e,-1);if(n==46&&!t.shiftKey||Zi&&n==68&&r==`c`)return Ro(e,1)||ko(e,1);if(n==13||n==27)return!0;if(n==37||Zi&&n==66&&r==`c`){let t=n==37?Io(e,e.state.selection.from)==`ltr`?-1:1:-1;return Do(e,t,r)||ko(e,t)}if(n==39||Zi&&n==70&&r==`c`){let t=n==39?Io(e,e.state.selection.from)==`ltr`?1:-1:1;return Do(e,t,r)||ko(e,t)}return n==38||Zi&&n==80&&r==`c`?Lo(e,-1,r)||ko(e,-1):n==40||Zi&&n==78&&r==`c`?Bo(e)||Lo(e,1,r)||ko(e,1):!(r!=(Zi?`m`:`c`)||n!=66&&n!=73&&n!=89&&n!=90)}function Uo(e,t){e.someProp(`transformCopied`,n=>{t=n(t,e)});let n=[],{content:r,openStart:i,openEnd:a}=t;for(;i>1&&a>1&&r.childCount==1&&r.firstChild.childCount==1;){i--,a--;let e=r.firstChild;n.push(e.type.name,e.attrs==e.type.defaultAttrs?null:e.attrs),r=e.content}let o=e.someProp(`clipboardSerializer`)||Ft.fromSchema(e.state.schema),s=$o(),c=s.createElement(`div`);c.appendChild(o.serializeFragment(r,{document:s}));let l=c.firstChild,u,d=0;for(;l&&U(l)&&(u=Qo[l.nodeName.toLowerCase()]);){for(let e=u.length-1;e>=0;e--){let t=s.createElement(u[e]);for(;c.firstChild;)t.appendChild(c.firstChild);c.appendChild(t),d++}l=c.firstChild}return l&&U(l)&&l.setAttribute(`data-pm-slice`,`${i} ${a}${d?` -${d}`:``} ${JSON.stringify(n)}`),{dom:c,text:e.someProp(`clipboardTextSerializer`,n=>n(t,e))||t.content.textBetween(0,t.content.size,` - -`),slice:t}}function Wo(e,t,n,r,i){let a=i.parent.type.spec.code,o,s;if(!n&&!t)return null;let c=!!t&&(r||a||!n);if(c){if(e.someProp(`transformPastedText`,n=>{t=n(t,a||r,e)}),a)return s=new L(F.from(e.state.schema.text(t.replace(/\r\n?/g,` -`))),0,0),e.someProp(`transformPasted`,t=>{s=t(s,e,!0)}),s;let n=e.someProp(`clipboardTextParser`,n=>n(t,i,r,e));if(n)s=n;else{let n=i.marks(),{schema:r}=e.state,a=Ft.fromSchema(r);o=document.createElement(`div`),t.split(/(?:\r\n?|\n)+/).forEach(e=>{let t=o.appendChild(document.createElement(`p`));e&&t.appendChild(a.serializeNode(r.text(e,n)))})}}else e.someProp(`transformPastedHTML`,t=>{n=t(n,e)}),o=ns(n),ea&&rs(o);let l=o&&o.querySelector(`[data-pm-slice]`),u=l&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(l.getAttribute(`data-pm-slice`)||``);if(u&&u[3])for(let e=+u[3];e>0;e--){let e=o.firstChild;for(;e&&!U(e);)e=e.nextSibling;if(!e)break;o=e}if(s||=(e.someProp(`clipboardParser`)||e.someProp(`domParser`)||xt.fromSchema(e.state.schema)).parseSlice(o,{preserveWhitespace:!!(c||u),context:i,ruleFromNode(e){return e.nodeName==`BR`&&!e.nextSibling&&e.parentNode&&!Go.test(e.parentNode.nodeName)?{ignore:!0}:null}}),u)s=is(Zo(s,+u[1],+u[2]),u[4]);else if(s=L.maxOpen(Ko(s.content,i),!0),s.openStart||s.openEnd){let e=0,t=0;for(let t=s.content.firstChild;e{s=t(s,e,c)}),s}var Go=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function Ko(e,t){if(e.childCount<2)return e;for(let n=t.depth;n>=0;n--){let r=t.node(n).contentMatchAt(t.index(n)),i,a=[];if(e.forEach(e=>{if(!a)return;let t=r.findWrapping(e.type),n;if(!t)return a=null;if(n=a.length&&i.length&&Jo(t,i,e,a[a.length-1],0))a[a.length-1]=n;else{a.length&&(a[a.length-1]=Yo(a[a.length-1],i.length));let n=qo(e,t);a.push(n),r=r.matchType(n.type),i=t}}),a)return F.from(a)}return e}function qo(e,t,n=0){for(let r=t.length-1;r>=n;r--)e=t[r].create(null,F.from(e));return e}function Jo(e,t,n,r,i){if(i1&&(a=0),i=n&&(s=t<0?o.contentMatchAt(0).fillBefore(s,a<=i).append(s):s.append(o.contentMatchAt(o.childCount).fillBefore(F.empty,!0))),e.replaceChild(t<0?0:e.childCount-1,o.copy(s))}function Zo(e,t,n){return te})}return es.createHTML(e)}function ns(e){let t=/^(\s*]*>)*/.exec(e);t&&(e=e.slice(t[0].length));let n=$o(),r=n.body,i=/<([a-z][^>\s]+)/i.exec(e),a;if((a=i&&Qo[i[1].toLowerCase()])&&(e=a.map(e=>`<`+e+`>`).join(``)+e+a.map(e=>``).reverse().join(``)),r.innerHTML=ts(e),a)for(let e=0;e=0;e-=2){let t=n.nodes[r[e]];if(!t||t.hasRequiredAttrs())break;try{i=F.from(t.create(r[e+1],i))}catch{break}a++,o++}return new L(i,a,o)}var as={},ss={},cs={touchstart:!0,touchmove:!0},ls=class{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastKeyDispatched=!1,this.lastClick={time:0,x:0,y:0,type:``,button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}};function us(e){for(let t in as){let n=as[t];e.dom.addEventListener(t,e.input.eventHandlers[t]=t=>{hs(e,t)&&!ms(e,t)&&(e.editable||!(t.type in ss))&&n(e,t)},cs[t]?{passive:!0}:void 0)}Yi&&e.dom.addEventListener(`input`,()=>null),ps(e)}function ds(e,t){e.input.lastSelectionOrigin=t,e.input.lastSelectionTime=Date.now()}function fs(e){e.input.mouseDown&&e.input.mouseDown.done(),e.domObserver.stop();for(let t in e.input.eventHandlers)e.dom.removeEventListener(t,e.input.eventHandlers[t]);clearTimeout(e.input.composingTimeout),clearTimeout(e.input.lastIOSEnterFallbackTimeout)}function ps(e){e.someProp(`handleDOMEvents`,t=>{for(let n in t)e.input.eventHandlers[n]||e.dom.addEventListener(n,e.input.eventHandlers[n]=t=>ms(e,t))})}function ms(e,t){return e.someProp(`handleDOMEvents`,n=>{let r=n[t.type];return r?r(e,t)||t.defaultPrevented:!1})}function hs(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let n=t.target;n!=e.dom;n=n.parentNode)if(!n||n.nodeType==11||n.pmViewDesc&&n.pmViewDesc.stopEvent(t))return!1;return!0}function gs(e,t){!ms(e,t)&&as[t.type]&&(e.editable||!(t.type in ss))&&as[t.type](e,t)}function _s(e,t){let{input:n}=e;return n.lastKeyDispatched||e.composing?!1:(n.lastKeyDispatched=!0,typeof t==`string`&&(t=Pi(t==`Backspace`?8:13,t)),e.someProp(`handleKeyDown`,n=>n(e,t)))}ss.keydown=(e,t)=>{let n=t;if(e.input.shiftKey=n.keyCode==16||n.shiftKey,!Ps(e)&&(e.input.lastKeyCode=n.keyCode,e.input.lastKeyCodeTime=Date.now(),e.input.lastKeyDispatched=!1,!($i&&qi&&n.keyCode==13))){if(n.keyCode!=229&&e.domObserver.forceFlush(),Xi&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let t=Date.now();e.input.lastIOSEnter=t,e.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{e.input.lastIOSEnter==t&&(_s(e,`Enter`),e.input.lastIOSEnter=0)},200)}else _s(e,n)||Ho(e,n)?n.preventDefault():ds(e,`key`)}},ss.keyup=(e,t)=>{t.keyCode==16&&(e.input.shiftKey=!1)},ss.keypress=(e,t)=>{let n=t;if(Ps(e)||!n.charCode||n.ctrlKey&&!n.altKey||Zi&&n.metaKey)return;if(e.someProp(`handleKeyPress`,t=>t(e,n))){n.preventDefault();return}let r=e.state.selection;if(!(r instanceof z)||!r.$from.sameParent(r.$to)){let t=String.fromCharCode(n.charCode),i=()=>e.state.tr.insertText(t).scrollIntoView();!/[\r\n]/.test(t)&&!e.someProp(`handleTextInput`,n=>n(e,r.$from.pos,r.$to.pos,t,i))&&e.dispatch(i()),n.preventDefault()}};function vs(e){return{left:e.clientX,top:e.clientY}}function ys(e,t){let n=t.x-e.clientX,r=t.y-e.clientY;return n*n+r*r<100}function bs(e,t,n,r,i){if(r==-1)return!1;let a=e.state.doc.resolve(r);for(let r=a.depth+1;r>0;r--)if(e.someProp(t,t=>r>a.depth?t(e,n,a.nodeAfter,a.before(r),i,!0):t(e,n,a.node(r),a.before(r),i,!1)))return!0;return!1}function xs(e,t,n){if(e.focused||e.focus(),e.state.selection.eq(t))return;let r=e.state.tr.setSelection(t);r.setMeta(`pointer`,!0),e.dispatch(r)}function Ss(e,t){if(t==-1)return!1;let n=e.state.doc.resolve(t),r=n.nodeAfter;return r&&r.isAtom&&B.isSelectable(r)?(xs(e,new B(n)),!0):!1}function Cs(e,t){if(t==-1)return!1;let n=e.state.selection,r,i;n instanceof B&&(r=n.node);let a=e.state.doc.resolve(t);for(let e=a.depth+1;e>0;e--){let t=e>a.depth?a.nodeAfter:a.node(e);if(B.isSelectable(t)){i=r&&n.$from.depth>0&&e>=n.$from.depth&&a.before(n.$from.depth+1)==n.$from.pos?a.before(n.$from.depth):a.before(e);break}}return i!=null&&(xs(e,B.create(e.state.doc,i)),!0)}function ws(e,t,n,r,i){return bs(e,`handleClickOn`,t,n,r)||e.someProp(`handleClick`,n=>n(e,t,r))||(i?Cs(e,n):Ss(e,n))}function Ts(e,t,n,r){return bs(e,`handleDoubleClickOn`,t,n,r)||e.someProp(`handleDoubleClick`,n=>n(e,t,r))}function Es(e,t,n,r){return bs(e,`handleTripleClickOn`,t,n,r)||e.someProp(`handleTripleClick`,n=>n(e,t,r))||Ds(e,n,r)}function Ds(e,t,n){if(n.button!=0)return!1;let r=Os(e,t,!0),i=e.state.doc;return r?(xs(e,r),r instanceof z&&i.eq(e.state.doc)&&(e.input.mouseDown=new Ns(e,r)),!0):!1}function Os(e,t,n){let r=e.state.doc;if(t==-1)return r.inlineContent?z.create(r,0,r.content.size):null;let i=r.resolve(t);for(let e=i.depth+1;e>0;e--){let t=e>i.depth?i.nodeAfter:i.node(e),a=i.before(e);if(t.inlineContent)return z.create(r,a+1,a+1+t.content.size);if(n&&B.isSelectable(t))return B.create(r,a)}return null}function ks(e){return Bs(e)}var As=Zi?`metaKey`:`ctrlKey`;as.mousedown=(e,t)=>{let n=t;e.input.shiftKey=n.shiftKey;let r=ks(e),i=Date.now(),a=`singleClick`;i-e.input.lastClick.time<500&&ys(n,e.input.lastClick)&&!n[As]&&e.input.lastClick.button==n.button&&(e.input.lastClick.type==`singleClick`?a=`doubleClick`:e.input.lastClick.type==`doubleClick`&&(a=`tripleClick`)),e.input.lastClick={time:i,x:n.clientX,y:n.clientY,type:a,button:n.button},e.input.mouseDown&&e.input.mouseDown.done();let o=e.posAtCoords(vs(n));o&&(a==`singleClick`?e.input.mouseDown=new Ms(e,o,n,!!r):(a==`doubleClick`?Ts:Es)(e,o.pos,o.inside,n)?n.preventDefault():ds(e,`pointer`))};var js=class{constructor(e){this.view=e,this.mightDrag=null,e.root.addEventListener(`mouseup`,this.up=this.up.bind(this)),e.root.addEventListener(`mousemove`,this.move=this.move.bind(this))}up(e){this.done()}move(e){e.buttons==0&&this.done()}done(){this.view.root.removeEventListener(`mouseup`,this.up),this.view.root.removeEventListener(`mousemove`,this.move),this.view.input.mouseDown==this&&(this.view.input.mouseDown=null)}delaySelUpdate(){return!1}},Ms=class extends js{constructor(e,t,n,r){super(e),this.pos=t,this.event=n,this.flushed=r,this.delayedSelectionSync=!1,this.startDoc=e.state.doc,this.selectNode=!!n[As],this.allowDefault=n.shiftKey;let i,a;if(t.inside>-1)i=e.state.doc.nodeAt(t.inside),a=t.inside;else{let n=e.state.doc.resolve(t.pos);i=n.parent,a=n.depth?n.before():0}let o=r?null:n.target,s=o?e.docView.nearestDesc(o,!0):null;this.target=s&&U(s.nodeDOM)?s.nodeDOM:null;let{selection:c}=e.state;n.button==0&&(i.type.spec.draggable&&i.type.spec.selectable!==!1||c instanceof B&&c.from<=a&&c.to>a)&&(this.mightDrag={node:i,pos:a,addAttr:!(!this.target||this.target.draggable),setUneditable:!!(this.target&&Gi&&!this.target.hasAttribute(`contentEditable`))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute(`contentEditable`,`false`)},20),this.view.domObserver.start()),ds(e,`pointer`)}done(){super.done(),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute(`draggable`),this.mightDrag.setUneditable&&this.target.removeAttribute(`contentEditable`),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>{this.view.isDestroyed||fo(this.view)})}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(vs(e))),this.updateAllowDefault(e),this.allowDefault||!t?ds(this.view,`pointer`):ws(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||Yi&&this.mightDrag&&!this.mightDrag.node.isAtom||qi&&!this.view.state.selection.visible&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?(xs(this.view,R.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):ds(this.view,`pointer`)}move(e){this.updateAllowDefault(e),ds(this.view,`pointer`),super.move(e)}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}delaySelUpdate(){return this.allowDefault?(this.delayedSelectionSync=!0,!0):!1}},Ns=class extends js{constructor(e,t){super(e),this.startSelection=t,this.startDoc=e.state.doc}move(e){if(e.buttons==0||this.view.isDestroyed||!this.view.state.doc.eq(this.startDoc)){this.done();return}e.preventDefault(),ds(this.view,`pointer`);let t=this.view.posAtCoords(vs(e)),n=t&&Os(this.view,t.inside,!1);if(!n)return;let{doc:r}=this.view.state,i=this.startSelection,[a,o]=n.from{e.input.lastTouch=Date.now(),ks(e),ds(e,`pointer`)},as.touchmove=e=>{e.input.lastTouch=Date.now(),ds(e,`pointer`)},as.contextmenu=e=>ks(e);function Ps(e,t){return e.composing?!0:Yi&&Math.abs(Date.now()-e.input.compositionEndedAt)<500?(e.input.compositionEndedAt=-2e8,!0):!1}var Fs=$i?5e3:-1;ss.compositionstart=ss.compositionupdate=e=>{if(!e.composing){e.domObserver.flush();let{state:t}=e,n=t.selection.$to;if(t.selection instanceof z&&t.selection.empty&&(t.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(e=>e.type.spec.inclusive===!1)||qi&&Qi&&Is(e)))e.markCursor=e.state.storedMarks||n.marks(),Bs(e,!0),e.markCursor=null;else if(Bs(e,!t.selection.empty),Gi&&t.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let t=e.domSelectionRange();for(let n=t.focusNode,r=t.focusOffset;n&&U(n)&&r!=0;){let t=r<0?n.lastChild:n.childNodes[r-1];if(!t)break;if(Di(t)){let n=e.domSelection();n&&n.collapse(t,t.nodeValue.length);break}n=t,r=-1}}e.input.composing=!0}Ls(e,Fs)};function Is(e){let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(!t||!U(t)||n>=t.childNodes.length)return!1;let r=t.childNodes[n];return U(r)&&r.contentEditable==`false`}ss.compositionend=(e,t)=>{e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=Date.now(),e.input.compositionPendingChanges=e.domObserver.pendingRecords().length?e.input.compositionID:0,e.input.compositionNode=null,e.input.badSafariComposition?e.domObserver.forceFlush():e.input.compositionPendingChanges&&Promise.resolve().then(()=>e.domObserver.flush()),e.input.compositionID++,Ls(e,20))};function Ls(e,t){clearTimeout(e.input.composingTimeout),t>-1&&(e.input.composingTimeout=setTimeout(()=>Bs(e),t))}function Rs(e){for(e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=Date.now());e.input.compositionNodes.length>0;)e.input.compositionNodes.pop().markParentsDirty()}function zs(e){let t=e.domSelectionRange();if(!t.focusNode)return null;let n=ki(t.focusNode,t.focusOffset),r=Ai(t.focusNode,t.focusOffset);if(n&&r&&n!=r){let t=r.pmViewDesc,i=e.domObserver.lastChangedTextNode;if(n==i||r==i)return i;if(!t||!t.isText(r.nodeValue))return r;if(e.input.compositionNode==r){let e=n.pmViewDesc;if(e&&e.isText(n.nodeValue))return r}}return n||r}function Bs(e,t=!1){if(!($i&&e.domObserver.flushingSoon>=0)){if(e.domObserver.forceFlush(),Rs(e),t||e.docView&&e.docView.dirty){let n=lo(e),r=e.state.selection;return n&&!n.eq(r)?e.dispatch(e.state.tr.setSelection(n)):(e.markCursor||t)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?e.dispatch(e.state.tr.deleteSelection()):e.updateState(e.state),!0}return!1}}function Vs(e,t){if(!e.dom.parentNode)return;let n=e.dom.parentNode.appendChild(document.createElement(`div`));n.appendChild(t),n.style.cssText=`position: fixed; left: -10000px; top: 10px`;let r=getSelection(),i=document.createRange();i.selectNodeContents(t),e.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),e.focus()},50)}var Hs=Ui&&Wi<15||Xi&&ta<604;as.copy=ss.cut=(e,t)=>{let n=t,r=e.state.selection,i=n.type==`cut`;if(r.empty)return;let a=Hs?null:n.clipboardData,{dom:o,text:s}=Uo(e,r.content());a?(n.preventDefault(),a.clearData(),a.setData(`text/html`,o.innerHTML),a.setData(`text/plain`,s)):Vs(e,o),i&&e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta(`uiEvent`,`cut`))};function Us(e){return e.openStart==0&&e.openEnd==0&&e.content.childCount==1?e.content.firstChild:null}function Ws(e,t){if(!e.dom.parentNode)return;let n=e.input.shiftKey||e.state.selection.$from.parent.type.spec.code,r=e.dom.parentNode.appendChild(document.createElement(n?`textarea`:`div`));n||(r.contentEditable=`true`),r.style.cssText=`position: fixed; left: -10000px; top: 10px`,r.focus();let i=e.input.shiftKey&&e.input.lastKeyCode!=45;setTimeout(()=>{e.focus(),r.parentNode&&r.parentNode.removeChild(r),n?Gs(e,r.value,null,i,t):Gs(e,r.textContent,r.innerHTML,i,t)},50)}function Gs(e,t,n,r,i){let a=Wo(e,t,n,r,e.state.selection.$from);if(e.someProp(`handlePaste`,t=>t(e,i,a||L.empty)))return!0;if(!a)return!1;let o=Us(a),s=o?e.state.tr.replaceSelectionWith(o,r):e.state.tr.replaceSelection(a);return e.dispatch(s.scrollIntoView().setMeta(`paste`,!0).setMeta(`uiEvent`,`paste`)),!0}function Ks(e){let t=e.getData(`text/plain`)||e.getData(`Text`);if(t)return t;let n=e.getData(`text/uri-list`);return n?n.replace(/\r?\n/g,` `):``}ss.paste=(e,t)=>{let n=t;if(e.composing&&!$i)return;let r=Hs?null:n.clipboardData,i=e.input.shiftKey&&e.input.lastKeyCode!=45;r&&Gs(e,Ks(r),r.getData(`text/html`),i,n)?n.preventDefault():Ws(e,n)};var qs=class{constructor(e,t,n){this.slice=e,this.move=t,this.node=n}},Js=Zi?`altKey`:`ctrlKey`;function Ys(e,t){let n;return e.someProp(`dragCopies`,e=>{n||=e(t)}),n==null?!t[Js]:!n}as.dragstart=(e,t)=>{let n=t,r=e.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let i=e.state.selection,a=i.empty?null:e.posAtCoords(vs(n)),o;if(!(a&&a.pos>=i.from&&a.pos<=(i instanceof B?i.to-1:i.to))){if(r&&r.mightDrag)o=B.create(e.state.doc,r.mightDrag.pos);else if(n.target&&U(n.target)){let t=e.docView.nearestDesc(n.target,!0);t&&t.node.type.spec.draggable&&t!=e.docView&&(o=B.create(e.state.doc,t.posBefore))}}let{dom:s,text:c,slice:l}=Uo(e,(o||e.state.selection).content());(!n.dataTransfer.files.length||!qi||Ji>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(Hs?`Text`:`text/html`,s.innerHTML),n.dataTransfer.effectAllowed=`copyMove`,Hs||n.dataTransfer.setData(`text/plain`,c),e.dragging=new qs(l,Ys(e,n),o)},as.dragend=e=>{let t=e.dragging;window.setTimeout(()=>{e.dragging==t&&(e.dragging=null)},50)},ss.dragover=ss.dragenter=(e,t)=>t.preventDefault(),ss.drop=(e,t)=>{try{Xs(e,t,e.dragging)}finally{e.dragging=null}};function Xs(e,t,n){if(!t.dataTransfer)return;let r=e.posAtCoords(vs(t));if(!r)return;let i=e.state.doc.resolve(r.pos),a=n&&n.slice;a?e.someProp(`transformPasted`,t=>{a=t(a,e,!1)}):a=Wo(e,Ks(t.dataTransfer),Hs?null:t.dataTransfer.getData(`text/html`),!1,i);let o=!!(n&&Ys(e,t));if(e.someProp(`handleDrop`,n=>n(e,t,a||L.empty,o))){t.preventDefault();return}if(!a)return;t.preventDefault();let s=a?Rn(e.state.doc,i.pos,a):i.pos;s??=i.pos;let c=e.state.tr;if(o){let{node:e}=n;e?e.replace(c):c.deleteSelection()}let l=c.mapping.map(s),u=a.openStart==0&&a.openEnd==0&&a.content.childCount==1,d=c.doc;if(u?c.replaceRangeWith(l,l,a.content.firstChild):c.replaceRange(l,l,a),c.doc.eq(d))return;let f=c.doc.resolve(l);if(u&&B.isSelectable(a.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(a.content.firstChild))c.setSelection(new B(f));else{let t=c.mapping.map(s);c.mapping.maps[c.mapping.maps.length-1].forEach((e,n,r,i)=>t=i),c.setSelection(xo(e,f,c.doc.resolve(t)))}e.focus(),e.dispatch(c.setMeta(`uiEvent`,`drop`))}as.focus=e=>{if(e.input.lastFocus=Date.now(),!e.focused){e.domObserver.stop(),e.dom.classList.add(`ProseMirror-focused`),e.domObserver.start(),e.focused=!0;let t=e.domSelectionRange();if(!e.domObserver.currentSelection.eq(t)){let{focusNode:n,focusOffset:r}=t;setTimeout(()=>{let t=e.domSelectionRange();t.focusNode==n&&t.focusOffset==r&&e.docView&&e.hasFocus()&&fo(e)},20)}}},as.blur=(e,t)=>{let n=t;e.focused&&=(e.domObserver.stop(),e.dom.classList.remove(`ProseMirror-focused`),e.domObserver.start(),n.relatedTarget&&e.dom.contains(n.relatedTarget)&&e.domObserver.currentSelection.clear(),!1)},as.beforeinput=(e,t)=>{if($i&&t.inputType==`deleteContentBackward`){e.domObserver.flushSoon();let{domChangeCount:t}=e.input;setTimeout(()=>{if(e.input.domChangeCount!=t||e.domObserver.pendingRecords().length||(e.dom.blur(),e.focus(),_s(e,`Backspace`)))return;let{$cursor:n}=e.state.selection;n&&n.pos>0&&e.dispatch(e.state.tr.delete(n.pos-1,n.pos).scrollIntoView())},50)}};for(let e in ss)as[e]=ss[e];function Zs(e,t){if(e==t)return!0;for(let n in e)if(e[n]!==t[n])return!1;for(let n in t)if(!(n in e))return!1;return!0}var Qs=class{constructor(e){this.frag=e,this.index=0,this.off=0}nodeAt(e){for(;this.off<=e&&this.index=a?null:new nc(i,a,this)}valid(e,t){return t.from=e&&(!i||i(o.spec))&&n.push(o.copy(o.from+r,o.to+r))}for(let a=0;ae){let o=this.children[a]+1;this.children[a+2].findInner(e-o,t-o,n,r+o,i)}}map(e,t,n){return this==ac||e.maps.length==0?this:this.mapInner(e,t,0,0,n||ic)}mapInner(t,n,r,i,a){let o;if(this.local.length){let e=new Qs(n.content);for(let s=0;s{let o=t+r,s;if(s=uc(n,e,o)){for(i||=this.children.slice();aa&&n.to=t){this.children[e]==t&&(r=this.children[e+2]);break}let a=t+1,o=a+n.content.size;for(let e=0;ea&&t.type instanceof ec){let e=Math.max(a,t.from)-a,n=Math.min(o,t.to)-a;ee.map(t,n,ic));return e.from(r)}forChild(t,n){if(n.isLeaf)return W.empty;let r=[];for(let i=0;ie instanceof W)?t:t.reduce((e,t)=>e.concat(t instanceof W?t:t.members),[]))}}forEachSet(e){for(let t=0;t{let o=a-i-(n-e);for(let i=0;ia+t-r)continue;let c=s[i]+t-r;n>=c?s[i+1]=e<=c?-2:-1:e>=t&&o&&(s[i]+=o,s[i+1]+=o)}r+=o}),t=n.maps[e].map(t,-1)}let c=!1;for(let t=0;t=r.content.size){c=!0;continue}let d=n.map(e[t+1]+a,-1)-i,{index:f,offset:p}=r.content.findIndex(u),m=r.maybeChild(f);if(m&&p==u&&p+m.nodeSize==d){let r=s[t+2].mapInner(n,m,l+1,e[t]+a+1,o);r==ac?(s[t+1]=-2,c=!0):(s[t]=u,s[t+1]=d,s[t+2]=r)}else c=!0}if(c){let c=fc(lc(s,e,t,n,i,a,o),r,0,o);t=c.local;for(let e=0;en&&a.to{let s=uc(e,t,o+n);if(s){a=!0;let e=fc(s,t,n+o+1,r);e!=ac&&i.push(o,o+t.nodeSize,e)}});let o=cc(a?dc(e):e,-n).sort(pc);if(o.length){let e=new Qs(t.content);for(let n=0;n0;)t++;e.splice(t,0,n)}function gc(e){let t=[];return e.someProp(`decorations`,n=>{let r=n(e.state);r&&r!=ac&&t.push(r)}),e.cursorWrapper&&t.push(W.create(e.state.doc,[e.cursorWrapper.deco])),oc.from(t)}var _c={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},vc=Ui&&Wi<=11,yc=class{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}},bc=class{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new yc,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(t=>{for(let e=0;ee.type==`childList`&&e.removedNodes.length||e.type==`characterData`&&e.oldValue.length>e.target.nodeValue.length)?this.flushSoon():Yi&&e.composing&&t.some(e=>e.type==`childList`&&e.target.nodeName==`TR`)?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),vc&&(this.onCharData=e=>{this.queue.push({target:e.target,type:`characterData`,oldValue:e.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,_c)),this.onCharData&&this.view.dom.addEventListener(`DOMCharacterDataModified`,this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let t=0;tthis.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener(`DOMCharacterDataModified`,this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener(`selectionchange`,this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener(`selectionchange`,this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(So(this.view)){if(this.suppressingSelectionUpdates)return fo(this.view);if(Ui&&Wi<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Ci(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t=new Set,n;for(let n=e.focusNode;n;n=yi(n))t.add(n);for(let r=e.anchorNode;r;r=yi(r))if(t.has(r)){n=r;break}let r=n&&this.view.docView.nearestDesc(n);if(r&&r.ignoreMutation({type:`selection`,target:Di(n)?n.parentNode:n}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let n,r=!1;!this.suppressingSelectionUpdates&&So(e)&&(n=e.domSelectionRange(),r=!this.currentSelection.eq(n)&&!this.ignoreSelectionChange(n));let i=-1,a=-1,o=!1,s=[];if(e.editable)for(let e=0;ee.nodeName==`BR`)&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46||qi&&(e.composing||e.input.compositionEndedAt>Date.now()-50)&&t.some(e=>e.type==`childList`&&e.removedNodes.length))){for(let e of s)if(e.nodeName==`BR`&&e.parentNode){let t=e.nextSibling;for(;t&&U(t);){if(t.contentEditable==`false`){e.parentNode.removeChild(e);break}t=t.firstChild}}}else if(Gi&&s.length){let t=s.filter(e=>e.nodeName==`BR`);if(t.length==2){let[e,n]=t;e.parentNode&&e.parentNode.parentNode==n.parentNode?n.remove():e.remove()}else{let{focusNode:n}=this.currentSelection;for(let r of t){let t=r.parentNode;t&&t.nodeName==`LI`&&(!n||Ec(e,n)!=t)&&r.remove()}}}let c=null;i<0&&r&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)-1||r)&&(i>-1&&(e.docView.markDirty(i,a),Cc(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,Dc(e,s)),this.handleDOMChange(i,a,o,s),e.docView&&e.docView.dirty?e.updateState(e.state):n&&!this.currentSelection.eq(n)&&fo(e),n&&this.currentSelection.set(n))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let n=this.view.docView.nearestDesc(e.target);if(e.type==`attributes`&&(n==this.view.docView||e.attributeName==`contenteditable`||e.attributeName==`style`&&!e.oldValue&&!e.target.getAttribute(`style`))||!n||n.ignoreMutation(e))return null;if(e.type==`childList`){for(let n=0;na;e--){let t=i.childNodes[e-1],n=t.pmViewDesc;if(t.nodeName==`BR`&&!n){o=e;break}if(!n||n.size)break}let f=e.state.doc,p=e.someProp(`domParser`)||xt.fromSchema(e.state.schema),m=f.resolve(s),h=null,g=p.parse(i,{topNode:m.parent,topMatch:m.parent.contentMatchAt(m.index()),topOpen:!0,from:a,to:o,preserveWhitespace:m.parent.type.whitespace!=`pre`||`full`,findPositions:u,ruleFromNode:kc(r),context:m});if(u&&u[0].pos!=null){let e=u[0].pos,t=u[1]&&u[1].pos;t??=e,h={anchor:e+s,head:t+s}}return{doc:g,sel:h,from:s,to:c}}var kc=e=>t=>{let n=t.pmViewDesc;if(n)return n.parseRule(e);if(t.nodeName==`BR`&&t.parentNode){if(Yi&&/^(ul|ol)$/i.test(t.parentNode.nodeName)){let e=document.createElement(`div`);return e.appendChild(document.createElement(`li`)),{skip:e}}if(t.parentNode.lastChild==t||Yi&&/^(tr|table)$/i.test(t.parentNode.nodeName))return{ignore:!0}}else if(t.nodeName==`IMG`&&t.getAttribute(`mark-placeholder`))return{ignore:!0};return null},Ac=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function jc(e,t,n,r,i){let a=e.input.compositionPendingChanges||(e.composing?e.input.compositionID:0);if(e.input.compositionPendingChanges=0,t<0){let t=e.input.lastSelectionTime>Date.now()-50?e.input.lastSelectionOrigin:null,n=lo(e,t);if(n&&!e.state.selection.eq(n)){if(qi&&$i&&e.input.lastKeyCode===13&&Date.now()-100Date.now()-225||$i)&&i.some(e=>U(e)&&!Ac.test(e.nodeName))&&(!m||m.endA>=m.endB)&&_s(e,`Enter`)){e.input.lastIOSEnter=0;return}if(!m){if(r&&c instanceof z&&!c.empty&&c.$head.sameParent(c.$anchor)&&!e.composing&&!(l.sel&&l.sel.anchor!=l.sel.head))m={start:c.from,endA:c.to,endB:c.to};else{if(l.sel){let t=Mc(e,e.state.doc,l.sel);if(t&&!t.eq(e.state.selection)){let n=e.state.tr.setSelection(t);a&&n.setMeta(`composition`,a),e.dispatch(n)}}return}}e.state.selection.frome.state.selection.from&&m.start<=e.state.selection.from+2&&e.state.selection.from>=l.from?m.start=e.state.selection.from:m.endA=e.state.selection.to-2&&e.state.selection.to<=l.to&&(m.endB+=e.state.selection.to-m.endA,m.endA=e.state.selection.to)),Ui&&Wi<=11&&m.endB==m.start+1&&m.endA==m.start&&m.start>l.from&&l.doc.textBetween(m.start-l.from-1,m.start-l.from+1)==` \xA0`&&(m.start--,m.endA--,m.endB--);let h=l.doc.resolveNoCache(m.start-l.from),g=l.doc.resolveNoCache(m.endB-l.from),_=u.resolve(m.start),v=h.sameParent(g)&&h.parent.inlineContent&&_.end()>=m.endA;if((Xi&&e.input.lastIOSEnter>Date.now()-225&&(!v||i.some(e=>e.nodeName==`DIV`||e.nodeName==`P`))||!v&&Fc(l.doc,h.pos,g.pos))&&_s(e,`Enter`)){e.input.lastIOSEnter=0;return}if(e.state.selection.anchor>m.start&&(v?m.endA>m.start&&m.endB==m.start:Pc(u,m.start,m.endA,h,g))&&_s(e,`Backspace`)){$i&&qi&&e.domObserver.suppressSelectionUpdates();return}qi&&m.endB==m.start&&(e.input.lastChromeDelete=Date.now()),$i&&!v&&h.start()!=g.start()&&g.parentOffset==0&&h.depth==g.depth&&l.sel&&l.sel.anchor==l.sel.head&&l.sel.head==m.endA&&(m.endB-=2,g=l.doc.resolveNoCache(m.endB-l.from),setTimeout(()=>_s(e,`Enter`),20));let y=m.start,b=m.endA,x=t=>{let n=t||e.state.tr.replace(y,b,l.doc.slice(m.start-l.from,m.endB-l.from));if(l.sel){let t=Mc(e,n.doc,l.sel);t&&!(qi&&e.composing&&t.empty&&(m.start!=m.endB||e.input.lastChromeDeletefo(e),20));let t=x(e.state.tr.delete(y,b)),n=u.resolve(m.start).marksAcross(u.resolve(m.endA));n&&t.ensureMarks(n),e.dispatch(t)}else if(m.endA==m.endB&&(S=Nc(h.parent.content.cut(h.parentOffset,g.parentOffset),_.parent.content.cut(_.parentOffset,m.endA-_.start())))){let t=x(e.state.tr);S.type==`add`?t.addMark(y,b,S.mark):t.removeMark(y,b,S.mark),e.dispatch(t)}else if(h.parent.child(h.index()).isText&&h.index()==g.index()-+!g.textOffset){let t=h.parent.textBetween(h.parentOffset,g.parentOffset),n=()=>x(e.state.tr.insertText(t,y,b));e.someProp(`handleTextInput`,r=>r(e,y,b,t,n))||e.dispatch(n())}else e.dispatch(x())}else e.dispatch(x())}function Mc(e,t,n){return Math.max(n.anchor,n.head)>t.content.size?null:xo(e,t.resolve(n.anchor),t.resolve(n.head))}function Nc(e,t){let n=e.firstChild.marks,r=t.firstChild.marks,i=n,a=r,o,s,c;for(let e=0;ee.mark(s.addToSet(e.marks));else if(i.length==0&&a.length==1)s=a[0],o=`remove`,c=e=>e.mark(s.removeFromSet(e.marks));else return null;let l=[];for(let e=0;en||Ic(o,!0,!1){e.isTextblock&&a>=t&&a0&&(t||e.indexAfter(r)==e.node(r).childCount);)r--,i++,t=!1;if(n){let t=e.node(r).maybeChild(e.indexAfter(r));for(;t&&!t.isLeaf;)t=t.firstChild,i++}return i}function Lc(e,t,n,r,i){let a=e.findDiffStart(t,n),o=n+e.size,s=n+t.size;if(a==null)return null;let{a:c,b:l}=e.findDiffEnd(t,o,s);if(i==`end`){let e=Math.max(0,a-Math.min(c,l));r-=c+e-a}if(c=c?a-r:0;a-=e,l=a+(l-c),c=a}else if(l=l?a-r:0;a-=e,c=a+(c-l),l=a}return{start:a,endA:c,endB:l}}var Rc=class{constructor(e,t){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new ls,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(Gc),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement(`div`),e&&(e.appendChild?e.appendChild(this.dom):typeof e==`function`?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=Vc(this),Bc(this),this.nodeViews=Uc(this),this.docView=Ua(this.state.doc,zc(this),gc(this),this.dom,this),this.domObserver=new bc(this,(e,t,n,r)=>jc(this,e,t,n,r)),this.domObserver.start(),us(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let t in e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&ps(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Gc),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let e in this._props)t[e]=this._props[e];t.state=this.state;for(let n in e)t[n]=e[n];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){let n=this.state,r=!1,i=!1;e.storedMarks&&this.composing&&(Rs(this),i=!0),this.state=e;let a=n.plugins!=e.plugins||this._props.plugins!=t.plugins;if(a||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let e=Uc(this);Wc(e,this.nodeViews)&&(this.nodeViews=e,r=!0)}(a||t.handleDOMEvents!=this._props.handleDOMEvents)&&ps(this),this.editable=Vc(this),Bc(this);let o=gc(this),s=zc(this),c=n.plugins!=e.plugins&&!n.doc.eq(e.doc)?`reset`:e.scrollToSelection>n.scrollToSelection?`to selection`:`preserve`,l=r||!this.docView.matchesNode(e.doc,s,o);(l||!e.selection.eq(n.selection))&&(i=!0);let u=c==`preserve`&&i&&this.dom.style.overflowAnchor==null&&oa(this);if(i){this.domObserver.stop();let t=l&&(Ui||qi)&&!this.composing&&!n.selection.empty&&!e.selection.empty&&Hc(n.selection,e.selection);if(l){let n=qi?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=zs(this)),(r||!this.docView.update(e.doc,s,o,this))&&(this.docView.updateOuterDeco(s),this.docView.destroy(),this.docView=Ua(e.doc,s,o,this.dom,this)),!n||this.trackWrites&&this.dom.contains(this.trackWrites)||(t=!0)}let i=this.input.mouseDown;t||!(i&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&wo(this)&&i.delaySelUpdate())?fo(this,t):(yo(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(n),this.dragging?.node&&!n.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,n),c==`reset`?this.dom.scrollTop=0:c==`to selection`?this.scrollToSelection():u&&ca(u)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(e&&Oi(this.dom,e)&&!this.someProp(`handleScrollToSelection`,e=>e(this))){if(this.state.selection instanceof B){let t=this.docView.domAfterPos(this.state.selection.from);U(t)&&aa(this,t.getBoundingClientRect(),e)}else aa(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let e=0;e0&&ee.ownerDocument.getSelection()),this._root=e}return e||document}updateRoot(){this._root=null}posAtCoords(e){return ya(this,e)}coordsAtPos(e,t=1){return Ca(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,n=-1){let r=this.docView.posFromDOM(e,t,n);if(r==null)throw RangeError(`DOM position not inside the editor`);return r}endOfTextblock(e,t){return Na(this,t||this.state,e)}pasteHTML(e,t){return Gs(this,``,e,!1,t||new ClipboardEvent(`paste`))}pasteText(e,t){return Gs(this,e,null,!0,t||new ClipboardEvent(`paste`))}serializeForClipboard(e){return Uo(this,e)}destroy(){this.docView&&(fs(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],gc(this),this),this.dom.textContent=``):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Si())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return gs(this,e)}domSelectionRange(){let e=this.dom.isConnected!==!1&&this.domSelection();return e?Yi&&this.root.nodeType===11&&Fi(this.dom.ownerDocument)==this.dom&&Tc(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}};Rc.prototype.dispatch=function(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))};function zc(e){let t=Object.create(null);return t.class=`ProseMirror`,t.contenteditable=String(e.editable),e.someProp(`attributes`,n=>{if(typeof n==`function`&&(n=n(e.state)),n)for(let e in n)e==`class`?t.class+=` `+n[e]:e==`style`?t.style=(t.style?t.style+`;`:``)+n[e]:!t[e]&&e!=`contenteditable`&&e!=`nodeName`&&(t[e]=String(n[e]))}),t.translate||=`no`,[nc.node(0,e.state.doc.content.size,t)]}function Bc(e){if(e.markCursor){let t=document.createElement(`img`);t.className=`ProseMirror-separator`,t.setAttribute(`mark-placeholder`,`true`),t.setAttribute(`alt`,``),e.cursorWrapper={dom:t,deco:nc.widget(e.state.selection.from,t,{raw:!0,marks:e.markCursor})}}else e.cursorWrapper=null}function Vc(e){return!e.someProp(`editable`,t=>t(e.state)===!1)}function Hc(e,t){let n=Math.min(e.$anchor.sharedDepth(e.head),t.$anchor.sharedDepth(t.head));return e.$anchor.start(n)!=t.$anchor.start(n)}function Uc(e){let t=Object.create(null);function n(e){for(let n in e)Object.prototype.hasOwnProperty.call(t,n)||(t[n]=e[n])}return e.someProp(`nodeViews`,n),e.someProp(`markViews`,n),t}function Wc(e,t){let n=0,r=0;for(let r in e){if(e[r]!=t[r])return!0;n++}for(let e in t)r++;return n!=r}function Gc(e){if(e.spec.state||e.spec.filterTransaction||e.spec.appendTransaction)throw RangeError(`Plugins passed directly to the view must not have a state component`)}for(var Kc={8:`Backspace`,9:`Tab`,10:`Enter`,12:`NumLock`,13:`Enter`,16:`Shift`,17:`Control`,18:`Alt`,20:`CapsLock`,27:`Escape`,32:` `,33:`PageUp`,34:`PageDown`,35:`End`,36:`Home`,37:`ArrowLeft`,38:`ArrowUp`,39:`ArrowRight`,40:`ArrowDown`,44:`PrintScreen`,45:`Insert`,46:`Delete`,59:`;`,61:`=`,91:`Meta`,92:`Meta`,106:`*`,107:`+`,108:`,`,109:`-`,110:`.`,111:`/`,144:`NumLock`,145:`ScrollLock`,160:`Shift`,161:`Shift`,162:`Control`,163:`Control`,164:`Alt`,165:`Alt`,173:`-`,186:`;`,187:`=`,188:`,`,189:`-`,190:`.`,191:`/`,192:"`",219:`[`,220:`\\`,221:`]`,222:`'`},qc={48:`)`,49:`!`,50:`@`,51:`#`,52:`$`,53:`%`,54:`^`,55:`&`,56:`*`,57:`(`,59:`:`,61:`+`,173:`_`,186:`:`,187:`+`,188:`<`,189:`_`,190:`>`,191:`?`,192:`~`,219:`{`,220:`|`,221:`}`,222:`"`},Jc=typeof navigator<`u`&&/Mac/.test(navigator.platform),Yc=typeof navigator<`u`&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),Xc=0;Xc<10;Xc++)Kc[48+Xc]=Kc[96+Xc]=String(Xc);for(var Xc=1;Xc<=24;Xc++)Kc[Xc+111]=`F`+Xc;for(var Xc=65;Xc<=90;Xc++)Kc[Xc]=String.fromCharCode(Xc+32),qc[Xc]=String.fromCharCode(Xc);for(var Zc in Kc)qc.hasOwnProperty(Zc)||(qc[Zc]=Kc[Zc]);function Qc(e){var t=!(Jc&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||Yc&&e.shiftKey&&e.key&&e.key.length==1||e.key==`Unidentified`)&&e.key||(e.shiftKey?qc:Kc)[e.keyCode]||e.key||`Unidentified`;return t==`Esc`&&(t=`Escape`),t==`Del`&&(t=`Delete`),t==`Left`&&(t=`ArrowLeft`),t==`Up`&&(t=`ArrowUp`),t==`Right`&&(t=`ArrowRight`),t==`Down`&&(t=`ArrowDown`),t}var $c=typeof navigator<`u`&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),el=typeof navigator<`u`&&/Win/.test(navigator.platform);function tl(e){let t=e.split(/-(?!$)/),n=t[t.length-1];n==`Space`&&(n=` `);let r,i,a,o;for(let e=0;e=t?sl.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},sl.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},sl.prototype.forEach=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length),t<=n?this.forEachInner(e,t,n,0):this.forEachInvertedInner(e,t,n,0)},sl.prototype.map=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length);var r=[];return this.forEach(function(t,n){return r.push(e(t,n))},t,n),r},sl.from=function(e){return e instanceof sl?e:e&&e.length?new cl(e):sl.empty};var cl=function(e){function t(t){e.call(this),this.values=t}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var n={length:{configurable:!0},depth:{configurable:!0}};return t.prototype.flatten=function(){return this.values},t.prototype.sliceInner=function(e,n){return e==0&&n==this.length?this:new t(this.values.slice(e,n))},t.prototype.getInner=function(e){return this.values[e]},t.prototype.forEachInner=function(e,t,n,r){for(var i=t;i=n;i--)if(e(this.values[i],r+i)===!1)return!1},t.prototype.leafAppend=function(e){if(this.length+e.length<=ol)return new t(this.values.concat(e.flatten()))},t.prototype.leafPrepend=function(e){if(this.length+e.length<=ol)return new t(e.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(t.prototype,n),t}(sl);sl.empty=new cl([]);var ll=function(e){function t(t,n){e.call(this),this.left=t,this.right=n,this.length=t.length+n.length,this.depth=Math.max(t.depth,n.depth)+1}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},t.prototype.getInner=function(e){return ei&&this.right.forEachInner(e,Math.max(t-i,0),Math.min(this.length,n)-i,r+i)===!1)return!1},t.prototype.forEachInvertedInner=function(e,t,n,r){var i=this.left.length;if(t>i&&this.right.forEachInvertedInner(e,t-i,Math.max(n,i)-i,r+i)===!1||n=n?this.right.slice(e-n,t-n):this.left.slice(e,n).append(this.right.slice(0,t-n))},t.prototype.leafAppend=function(e){var n=this.right.leafAppend(e);if(n)return new t(this.left,n)},t.prototype.leafPrepend=function(e){var n=this.left.leafPrepend(e);if(n)return new t(n,this.right)},t.prototype.appendInner=function(e){return this.left.depth>=Math.max(this.right.depth,e.depth)+1?new t(this.left,new t(this.right,e)):new t(this,e)},t}(sl),ul=500,dl=class e{constructor(e,t){this.items=e,this.eventCount=t}popEvent(t,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let i,a;n&&(i=this.remapping(r,this.items.length),a=i.maps.length);let o=t.tr,s,c,l=[],u=[];return this.items.forEach((t,n)=>{if(!t.step)i||(i=this.remapping(r,n+1),a=i.maps.length),a--,u.push(t);else{if(i){u.push(new pl(t.map));let e=t.step.map(i.slice(a)),n;e&&o.maybeStep(e).doc&&(n=o.mapping.maps[o.mapping.maps.length-1],l.push(new pl(n,void 0,void 0,l.length+u.length))),a--,n&&i.appendMap(n,a)}else o.maybeStep(t.step);if(t.selection)return s=i?t.selection.map(i.slice(a)):t.selection,c=new e(this.items.slice(0,r).append(u.reverse().concat(l)),this.eventCount-1),!1}},this.items.length,0),{remaining:c,transform:o,selection:s}}addTransform(t,n,r,i){let a=[],o=this.eventCount,s=this.items,c=!i&&s.length?s.get(s.length-1):null;for(let e=0;ehl&&(s=fl(s,l),o-=l),new e(s.append(a),o)}remapping(e,t){let n=new $t;return this.items.forEach((t,r)=>{let i=t.mirrorOffset!=null&&r-t.mirrorOffset>=e?n.maps.length-t.mirrorOffset:void 0;n.appendMap(t.map,i)},e,t),n}addMaps(t){return this.eventCount==0?this:new e(this.items.append(t.map(e=>new pl(e))),this.eventCount)}rebased(t,n){if(!this.eventCount)return this;n=Math.min(this.items.length,n);let r=[],i=this.items.length-n,a=t.mapping,o=t.steps.length,s=this.eventCount;this.items.forEach(e=>{e.selection&&s--},i);let c=n;this.items.forEach(e=>{let n=a.getMirror(--c);if(n==null)return;o=Math.min(o,n);let i=a.maps[n];if(e.step){let o=t.steps[n].invert(t.docs[n]),l=e.selection&&e.selection.map(a.slice(c+1,n));l&&s++,r.push(new pl(i,o,l))}else r.push(new pl(i))},i);let l=[];for(let e=n;eul&&(d=d.compress(this.items.length-r.length)),d}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(t=this.items.length){let n=this.remapping(0,t),r=n.maps.length,i=[],a=0;return this.items.forEach((e,o)=>{if(o>=t)i.push(e),e.selection&&a++;else if(e.step){let t=e.step.map(n.slice(r)),o=t&&t.getMap();if(r--,o&&n.appendMap(o,r),t){let s=e.selection&&e.selection.map(n.slice(r));s&&a++;let c=new pl(o.invert(),t,s),l,u=i.length-1;(l=i.length&&i[u].merge(c))?i[u]=l:i.push(c)}}else e.map&&r--},this.items.length,0),new e(sl.from(i.reverse()),a)}};dl.empty=new dl(sl.empty,0);function fl(e,t){let n;return e.forEach((e,r)=>{if(e.selection&&t--==0)return n=r,!1}),e.slice(n)}var pl=class e{constructor(e,t,n,r){this.map=e,this.step=t,this.selection=n,this.mirrorOffset=r}merge(t){if(this.step&&t.step&&!t.selection){let n=t.step.merge(this.step);if(n)return new e(n.getMap().invert(),n,this.selection)}}},ml=class{constructor(e,t,n,r,i){this.done=e,this.undone=t,this.prevRanges=n,this.prevTime=r,this.prevComposition=i}},hl=20;function gl(e,t,n,r){let i=n.getMeta(Tl),a;if(i)return i.historyState;n.getMeta(El)&&(e=new ml(e.done,e.undone,null,0,-1));let o=n.getMeta(`appendedTransaction`);if(n.steps.length==0)return e;if(o&&o.getMeta(Tl))return o.getMeta(Tl).redo?new ml(e.done.addTransform(n,void 0,r,Cl(t)),e.undone,vl(n.mapping.maps),e.prevTime,e.prevComposition):new ml(e.done,e.undone.addTransform(n,void 0,r,Cl(t)),null,e.prevTime,e.prevComposition);if(n.getMeta(`addToHistory`)!==!1&&!(o&&o.getMeta(`addToHistory`)===!1)){let i=n.getMeta(`composition`),a=e.prevTime==0||!o&&e.prevComposition!=i&&(e.prevTime<(n.time||0)-r.newGroupDelay||!_l(n,e.prevRanges)),s=o?yl(e.prevRanges,n.mapping):vl(n.mapping.maps);return new ml(e.done.addTransform(n,a?t.selection.getBookmark():void 0,r,Cl(t)),dl.empty,s,n.time,i??e.prevComposition)}return(a=n.getMeta(`rebased`))?new ml(e.done.rebased(n,a),e.undone.rebased(n,a),yl(e.prevRanges,n.mapping),e.prevTime,e.prevComposition):new ml(e.done.addMaps(n.mapping.maps),e.undone.addMaps(n.mapping.maps),yl(e.prevRanges,n.mapping),e.prevTime,e.prevComposition)}function _l(e,t){if(!t)return!1;if(!e.docChanged)return!0;let n=!1;return e.mapping.maps[0].forEach((e,r)=>{for(let i=0;i=t[i]&&(n=!0)}),n}function vl(e){let t=[];for(let n=e.length-1;n>=0&&t.length==0;n--)e[n].forEach((e,n,r,i)=>t.push(r,i));return t}function yl(e,t){if(!e)return null;let n=[];for(let r=0;r{let i=Tl.getState(n);if(!i||(e?i.undone:i.done).eventCount==0)return!1;if(r){let a=bl(i,n,e);a&&r(t?a.scrollIntoView():a)}return!0}}var kl=Ol(!1,!0),Al=Ol(!0,!0);function jl(e){return e.getMeta(Tl)!=null}function Ml(e){let{state:t,transaction:n}=e,{selection:r}=n,{doc:i}=n,{storedMarks:a}=n;return{...t,apply:t.apply.bind(t),applyTransaction:t.applyTransaction.bind(t),plugins:t.plugins,schema:t.schema,reconfigure:t.reconfigure.bind(t),toJSON:t.toJSON.bind(t),get storedMarks(){return a},get selection(){return r},get doc(){return i},get tr(){return r=n.selection,i=n.doc,a=n.storedMarks,n}}}var Nl=class e{constructor(e){this.editor=e.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=e.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){let{rawCommands:e,editor:t,state:n}=this,{view:r}=t,{tr:i}=n,a=this.buildProps(i);return Object.fromEntries(Object.entries(e).map(([e,t])=>[e,(...e)=>{let n=t(...e)(a);return!i.getMeta(`preventDispatch`)&&!this.hasCustomState&&r.dispatch(i),n}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(e,t=!0){let{rawCommands:n,editor:r,state:i}=this,{view:a}=r,o=[],s=!!e,c=e||i.tr,l=()=>(!s&&t&&!c.getMeta(`preventDispatch`)&&!this.hasCustomState&&a.dispatch(c),o.every(e=>e===!0)),u={...Object.fromEntries(Object.entries(n).map(([e,n])=>[e,(...e)=>{let r=this.buildProps(c,t),i=n(...e)(r);return o.push(i),u}])),run:l};return u}static createFakeChain(){let e=new Proxy({},{get:(t,n)=>{if(n!==`then`)return n===`run`?()=>!1:()=>e}});return e}createCan(e){let{rawCommands:t,state:n}=this,r=e||n.tr,i=this.buildProps(r,!1);return{...Object.fromEntries(Object.entries(t).map(([e,t])=>[e,(...e)=>t(...e)({...i,dispatch:void 0})])),chain:()=>this.createChain(r,!1)}}static createFallbackCan(){let t=e.createFakeChain();return new Proxy({chain:()=>t},{get:(e,t)=>{if(t!==`then`)return t===`chain`?e.chain:()=>!1}})}buildProps(e,t=!0){let{rawCommands:n,editor:r,state:i}=this,{view:a}=r,o={tr:e,editor:r,view:a,state:Ml({state:i,transaction:e}),dispatch:t?()=>void 0:void 0,chain:()=>this.createChain(e,t),can:()=>this.createCan(e),get commands(){return Object.fromEntries(Object.entries(n).map(([e,t])=>[e,(...e)=>t(...e)(o)]))}};return o}},Pl=()=>({editor:e,view:t})=>(requestAnimationFrame(()=>{if(!e.isDestroyed){var n;t.dom.blur(),(n=window)==null||(n=n.getSelection())==null||n.removeAllRanges()}}),!0),Fl=(e=!0)=>({commands:t})=>t.setContent(``,{emitUpdate:e}),Il=()=>({tr:e,dispatch:t})=>{let{selection:n}=e,{ranges:r}=n;if(!t)return!0;let i=e.mapping.maps.length;return r.forEach(({$from:t,$to:n})=>{let r=t.pos,a=n.pos,o=e.mapping.slice(i),s=1;e.doc.nodesBetween(o.map(r),o.map(a),(t,n)=>{s=Math.max(s,e.doc.resolve(n).depth+1)});for(let t=0;t{if(t.type.isText)return;e.mapping.maps.length!==s&&(s=e.mapping.maps.length,c=e.mapping.slice(n));let i=e.doc.resolve(c.map(r)),a=e.doc.resolve(c.map(r+t.nodeSize)),o=i.blockRange(a);if(!o)return;let l=vn(o);if(t.type.isTextblock){let{defaultType:t}=i.parent.contentMatchAt(i.index()),n=e.doc.nodeAt(o.start);t&&n&&!n.hasMarkup(t)&&t.validContent(n.content)&&e.setNodeMarkup(o.start,t)}(l||l===0)&&e.lift(o,l)}),e.doc.eq(t))break}}),!0},Ll=e=>t=>e(t),Rl=()=>({state:e,dispatch:t})=>Kr(e,t),zl=(e,t)=>({editor:n,tr:r})=>{let{state:i}=n,a=i.doc.slice(e.from,e.to);r.deleteRange(e.from,e.to);let o=r.mapping.map(t);return r.insert(o,a.content),r.setSelection(new z(r.doc.resolve(Math.max(o-1,0)))),!0},Bl=()=>({tr:e,dispatch:t})=>{let{selection:n}=e,r=n.$anchor.node();if(r.content.size>0)return!1;let i=e.selection.$anchor;for(let n=i.depth;n>0;--n)if(i.node(n).type===r.type){if(t){let t=i.before(n),r=i.after(n);e.delete(t,r).scrollIntoView()}return!0}return!1};function Vl(e,t){if(typeof e==`string`){if(!t.nodes[e])throw Error(`There is no node type named '${e}'. Maybe you forgot to add the extension?`);return t.nodes[e]}return e}var Hl=e=>({tr:t,state:n,dispatch:r})=>{let i=Vl(e,n.schema),a=t.selection.$anchor;for(let e=a.depth;e>0;--e)if(a.node(e).type===i){if(r){let n=a.before(e),r=a.after(e);t.delete(n,r).scrollIntoView()}return!0}return!1},Ul=e=>({tr:t,dispatch:n})=>{let{from:r,to:i}=e;return n&&t.delete(r,i),!0},Wl=e=>e.content?/^text(\*|\+)/.test(e.content):!1,Gl=(e,t,n)=>{if(!e.parent.isInline||n===`left`&&e.pos>e.start()||n===`right`&&e.pos({from:Gl(e,n,`left`),to:Gl(t,n,`right`)}),ql=()=>({state:e,dispatch:t})=>{if(e.selection.empty)return!1;if(t){let n=e.tr,{ranges:r}=e.selection,i=e.selection instanceof z?e.selection.$from.marksAcross(e.selection.$to):null,a=n.steps.length;r.forEach(t=>{let r=n.mapping.slice(a),{from:i,to:o}=Kl(n.doc.resolve(r.map(t.$from.pos)),n.doc.resolve(r.map(t.$to.pos)),e.schema);n.deleteRange(i,o)}),n.selection.empty||n.setSelection(z.near(n.doc.resolve(n.selection.from))),i&&n.ensureMarks(i),n.scrollIntoView(),t(n)}return!0},Jl=()=>({commands:e})=>e.keyboardShortcut(`Enter`),Yl=()=>({state:e,dispatch:t})=>Gr(e,t);function Xl(e){return Object.prototype.toString.call(e)===`[object RegExp]`}function Zl(e,t,n={strict:!0}){let r=Object.keys(t);return!r.length||r.every(r=>n.strict?t[r]===e[r]:Xl(t[r])?t[r].test(e[r]):t[r]===e[r])}function Ql(e,t,n={}){return e.find(e=>e.type===t&&Zl(Object.fromEntries(Object.keys(n).map(t=>[t,e.attrs[t]])),n))}function $l(e,t,n={}){return!!Ql(e,t,n)}function eu(e,t,n){if(!e||!t)return;let r=e.parent.childAfter(e.parentOffset);if(r.node&&r.node.marks.some(e=>e.type===t)||(r=e.parent.childBefore(e.parentOffset)),!r.node||!r.node.marks.some(e=>e.type===t))return;if(!n){let e=r.node.marks.find(e=>e.type===t);e&&(n=e.attrs)}if(!Ql([...r.node.marks],t,n))return;let i=r.index,a=e.start()+r.offset,o=i+1,s=a+r.node.nodeSize;for(;i>0&&$l([...e.parent.child(i-1).marks],t,n);)--i,a-=e.parent.child(i).nodeSize;for(;o({tr:n,state:r,dispatch:i})=>{let a=tu(e,r.schema),{doc:o,selection:s}=n,{$from:c,from:l,to:u}=s;if(i){let e=eu(c,a,t);if(e&&e.from<=l&&e.to>=u){let t=z.create(o,e.from,e.to);n.setSelection(t)}}return!0},ru=e=>t=>{let n=typeof e==`function`?e(t):e;for(let e=0;e({editor:n,view:r,tr:i,dispatch:a})=>{t={scrollIntoView:!0,...t};let o=()=>{(cu()||su())&&r.dom.focus(),lu()&&!cu()&&!su()&&r.dom.focus({preventScroll:!0}),requestAnimationFrame(()=>{n.isDestroyed||(r.focus(),t?.scrollIntoView&&n.commands.scrollIntoView())})};try{if(r.hasFocus()&&e===null||e===!1)return!0}catch{return!1}if(a&&e===null&&!iu(n.state.selection))return o(),!0;let s=ou(i.doc,e)||n.state.selection,c=n.state.selection.eq(s);return a&&(c||i.setSelection(s),c&&i.storedMarks&&i.setStoredMarks(i.storedMarks),o()),!0},du=(e,t)=>n=>e.every((e,r)=>t(e,{...n,index:r})),fu=(e,t)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},e,t),pu=e=>{let t=e.childNodes;for(let n=t.length-1;n>=0;--n){let r=t[n];r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?e.removeChild(r):r.nodeType===1&&pu(r)}return e};function mu(e){if(typeof window>`u`)throw Error(`[tiptap error]: there is no window object available, so this function cannot be used`);let t=`${e}`,n=new window.DOMParser().parseFromString(t,`text/html`).body;return pu(n)}function hu(e){return typeof e?.nodesBetween==`function`}function gu(e,t,n){if(hu(e))return e;let r=typeof e==`object`&&!!e;n={slice:!0,parseOptions:{},...n};let i=typeof e==`string`;if(r)try{if(Array.isArray(e)&&e.length>0)return F.fromArray(e.map(e=>t.nodeFromJSON(e)));let r=t.nodeFromJSON(e);return n.errorOnInvalidContent&&r.check(),r}catch(r){if(n.errorOnInvalidContent)throw Error(`[tiptap error]: Invalid JSON content`,{cause:r});return console.warn(`[tiptap warn]: Invalid content.`,`Passed value:`,e,`Error:`,r),gu(``,t,n)}if(i){if(n.errorOnInvalidContent){let r=!1,i=``,a=new _t({topNode:t.spec.topNode,marks:t.spec.marks,nodes:t.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:`inline*`,group:`block`,parseDOM:[{tag:`*`,getAttrs:e=>(r=!0,i=typeof e==`string`?e:e.outerHTML,null)}]}})});if(n.slice?xt.fromSchema(a).parseSlice(mu(e),n.parseOptions):xt.fromSchema(a).parse(mu(e),n.parseOptions),n.errorOnInvalidContent&&r)throw Error(`[tiptap error]: Invalid HTML content`,{cause:Error(`Invalid element found: ${i}`)})}let r=xt.fromSchema(t);return n.slice?r.parseSlice(mu(e),n.parseOptions).content:r.parse(mu(e),n.parseOptions)}return gu(``,t,n)}function _u(e){return!(`type`in e)}function vu(e,t,n){let r=e.steps.length-1;if(r{o===0&&(o=r)}),e.setSelection(R.near(e.doc.resolve(o),n))}var yu=(e,t,n)=>({tr:r,dispatch:i,editor:a})=>{if(i){n={parseOptions:a.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};let i,o=e=>{a.emit(`contentError`,{editor:a,error:e,disableCollaboration:()=>{`collaboration`in a.storage&&typeof a.storage.collaboration==`object`&&a.storage.collaboration&&(a.storage.collaboration.isDisabled=!0)}})},s={preserveWhitespace:`full`,...n.parseOptions};if(!n.errorOnInvalidContent&&!a.options.enableContentCheck&&a.options.emitContentError)try{gu(t,a.schema,{parseOptions:s,errorOnInvalidContent:!0})}catch(e){o(e)}try{i=gu(t,a.schema,{parseOptions:s,errorOnInvalidContent:n.errorOnInvalidContent??a.options.enableContentCheck})}catch(e){return o(e),!1}let{from:c,to:l}=typeof e==`number`?{from:e,to:e}:{from:e.from,to:e.to},u=!0,d=!0,f=_u(i)?i.content:[i];if(f.forEach(e=>{e.check(),u=u?e.isText&&e.marks.length===0:!1,d=d?e.isBlock:!1}),c===l&&d){let{parent:e}=r.doc.resolve(c);e.isTextblock&&!e.type.spec.code&&!e.childCount&&(--c,l+=1)}let p;if(u)p=Array.isArray(t)?t.map(e=>e.text||``).join(``):hu(t)?f.map(e=>e.text??``).join(``):typeof t==`object`&&t&&t.text?t.text:t,r.insertText(p,c,l);else{p=F.from(f);let e=r.doc.resolve(c),t=e.node(),n=e.parentOffset===0,i=t.isText||t.isTextblock,a=t.content.size>0;n&&i&&a&&d&&(c=Math.max(0,c-1)),r.replaceWith(c,l,f)}n.updateSelection&&vu(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta(`applyInputRules`,{from:c,text:p}),n.applyPasteRules&&r.setMeta(`applyPasteRules`,{from:c,text:p})}return!0};function bu(e){for(let t=0;t({tr:t,dispatch:n,editor:r})=>{let{pos:i,attrs:a,content:o,updateSelection:s=!0}=e,c;c=typeof i==`number`?t.doc.resolve(i):i||t.selection.$from;let l=bu(c.parent.contentMatchAt(c.index()));if(!l)return!1;let u=Object.keys(l.spec.attrs||{}),d=a?Object.fromEntries(Object.entries(a).filter(([e])=>u.includes(e))):{},f;if(o){let e=gu(o,r.schema);f=l.createAndFill(d,e)}else f=l.createAndFill(d);return f?(n&&(t.insert(c.pos,f),s&&vu(t,t.steps.length-1,-1)),!0):!1},Su=()=>({state:e,dispatch:t})=>Br(e,t),Cu=()=>({state:e,dispatch:t})=>Vr(e,t),wu=()=>({state:e,dispatch:t})=>kr(e,t),Tu=()=>({state:e,dispatch:t})=>Lr(e,t),Eu=(e,t)=>{let n=e.resolve(t),r=n.nodeBefore,i=n.nodeAfter;return!r||!i?!1:!r.type.spec.isolating&&!i.type.spec.isolating},Du=()=>({state:e,dispatch:t,tr:n})=>{try{let r=Fn(e.doc,e.selection.$from.pos,-1);return r==null||!Eu(e.doc,r)?!1:(n.join(r,2),t&&t(n),!0)}catch{return!1}},Ou=()=>({state:e,dispatch:t,tr:n})=>{try{let r=Fn(e.doc,e.selection.$from.pos,1);return r==null||!Eu(e.doc,r)?!1:(n.join(r,2),t&&t(n),!0)}catch{return!1}},ku=()=>({state:e,dispatch:t})=>Ar(e,t),Au=()=>({state:e,dispatch:t})=>jr(e,t);function ju(){return typeof navigator<`u`&&/Mac/.test(navigator.platform)}function Mu(e){let t=e.split(/-(?!$)/),n=t[t.length-1];n===`Space`&&(n=` `);let r,i,a,o;for(let e=0;e({editor:t,view:n,tr:r,dispatch:i})=>{let a=Mu(e).split(/-(?!$)/),o=a.find(e=>![`Alt`,`Ctrl`,`Meta`,`Shift`].includes(e)),s=new KeyboardEvent(`keydown`,{key:o===`Space`?` `:o,altKey:a.includes(`Alt`),ctrlKey:a.includes(`Ctrl`),metaKey:a.includes(`Meta`),shiftKey:a.includes(`Shift`),bubbles:!0,cancelable:!0});return t.captureTransaction(()=>{n.someProp(`handleKeyDown`,e=>e(n,s))})?.steps.forEach(e=>{let t=e.map(r.mapping);t&&i&&r.maybeStep(t)}),!0};function Pu(e,t,n={}){let{from:r,to:i,empty:a}=e.selection,o=t?Vl(t,e.schema):null,s=[];e.doc.nodesBetween(r,i,(e,t)=>{if(e.isText)return;let n=Math.max(r,t),a=Math.min(i,t+e.nodeSize);s.push({node:e,from:n,to:a})});let c=i-r,l=s.filter(e=>!o||o.name===e.node.type.name).filter(e=>Zl(e.node.attrs,n,{strict:!1}));return a?!!l.length:l.reduce((e,t)=>e+t.to-t.from,0)>=c}var Fu=(e,t={})=>({state:n,dispatch:r})=>Pu(n,Vl(e,n.schema),t)?Hr(n,r):!1,Iu=()=>({state:e,dispatch:t})=>qr(e,t),Lu=e=>({state:t,dispatch:n})=>mi(Vl(e,t.schema))(t,n),Ru=()=>({state:e,dispatch:t})=>Ur(e,t);function zu(e,t){return t.nodes[e]?`node`:t.marks[e]?`mark`:null}function Bu(e,t){let n=typeof t==`string`?[t]:t;return Object.keys(e).reduce((t,r)=>(n.includes(r)||(t[r]=e[r]),t),{})}var Vu=(e,t)=>({tr:n,state:r,dispatch:i})=>{let a=null,o=null,s=zu(typeof e==`string`?e:e.name,r.schema);if(!s)return!1;s===`node`&&(a=Vl(e,r.schema)),s===`mark`&&(o=tu(e,r.schema));let c=!1;return n.selection.ranges.forEach(e=>{r.doc.nodesBetween(e.$from.pos,e.$to.pos,(e,r)=>{a&&a===e.type&&(c=!0,i&&n.setNodeMarkup(r,void 0,Bu(e.attrs,t))),o&&e.marks.length&&e.marks.forEach(a=>{o===a.type&&(c=!0,i&&n.addMark(r,r+e.nodeSize,o.create(Bu(a.attrs,t))))})})}),c},Hu=()=>({tr:e,dispatch:t})=>(t&&e.scrollIntoView(),!0),Uu=()=>({tr:e,dispatch:t})=>{if(t){let t=new dr(e.doc);e.setSelection(t)}return!0},Wu=()=>({state:e,dispatch:t})=>Pr(e,t),Gu=()=>({state:e,dispatch:t})=>Rr(e,t),Ku=()=>({state:e,dispatch:t})=>Xr(e,t),qu=()=>({state:e,dispatch:t})=>ni(e,t),Ju=()=>({state:e,dispatch:t})=>ti(e,t);function Yu(e,t,n={},r={}){return gu(e,t,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var Xu=(e,{errorOnInvalidContent:t,emitUpdate:n=!0,parseOptions:r={}}={})=>({editor:i,tr:a,dispatch:o,commands:s})=>{let{doc:c}=a;if(r.preserveWhitespace!==`full`){let s=Yu(e,i.schema,r,{errorOnInvalidContent:t??i.options.enableContentCheck});if(o){let e=_u(s)?s.content:[s];a.replaceWith(0,c.content.size,e).setMeta(`preventUpdate`,!n)}return!0}return o&&a.setMeta(`preventUpdate`,!n),s.insertContentAt({from:0,to:c.content.size},e,{parseOptions:r,errorOnInvalidContent:t??i.options.enableContentCheck})};function Zu(e,t){let n=tu(t,e.schema),{from:r,to:i,empty:a}=e.selection,o=[];a?(e.storedMarks&&o.push(...e.storedMarks),o.push(...e.selection.$head.marks())):e.doc.nodesBetween(r,i,e=>{o.push(...e.marks)});let s=o.find(e=>e.type.name===n.name);return s?{...s.attrs}:{}}function Qu(e,t){let n=new ir(e);return t.forEach(e=>{e.steps.forEach(e=>{n.step(e)})}),n}function $u(e,t,n){let r=[];return e.nodesBetween(t.from,t.to,(e,t)=>{n(e)&&r.push({node:e,pos:t})}),r}function ed(e,t){for(let n=e.depth;n>0;--n){let r=e.node(n);if(t(r))return{pos:n>0?e.before(n):0,start:e.start(n),depth:n,node:r}}}function td(e){return t=>ed(t.$from,e)}function G(e,t,n){return e.config[t]===void 0&&e.parent?G(e.parent,t,n):typeof e.config[t]==`function`?e.config[t].bind({...n,parent:e.parent?G(e.parent,t,n):null}):e.config[t]}function nd(e){return e.map(e=>{let t=G(e,`addExtensions`,{name:e.name,options:e.options,storage:e.storage});return t?[e,...nd(t())]:e}).flat(10)}function rd(e,t){let n=Ft.fromSchema(t).serializeFragment(e),r=document.implementation.createHTMLDocument().createElement(`div`);return r.appendChild(n),r.innerHTML}function id(e,t){let n=new Map;for(let t of e){let e=n.get(t.type)??new Map;e.set(t.name,t),n.set(t.type,e)}return[...Object.values(t.nodes),...Object.values(t.marks)].flatMap(e=>Object.entries(e.spec.attrs??{}).map(([t,r])=>{let i=n.get(e.name)?.get(t),a=Object.hasOwn(r,`default`);return{type:e.name,name:t,attribute:{rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,...i?.attribute,default:r.default,isRequired:!a,validate:r.validate}}}))}var ad={content:`string`,marks:`string`,group:`string`,inline:`boolean`,atom:`boolean`,selectable:`boolean`,draggable:`boolean`,code:`boolean`,whitespace:[`pre`,`normal`],definingAsContext:`boolean`,definingForContent:`boolean`,defining:`boolean`,isolating:`boolean`,linebreakReplacement:`boolean`},od={inclusive:`boolean`,excludes:`string`,group:`string`,spanning:`boolean`,code:`boolean`};function sd(e,t,n){return Object.fromEntries(Object.entries(t).flatMap(([t,r])=>{let i=e[t];if(i===void 0)return[];if(!(typeof r==`string`?typeof i===r:typeof i==`string`&&r.includes(i)))throw RangeError(`Invalid schemaSpec field '${n}.${t}'`);return[[t,i]]}))}function cd(e,t,n,r){return{...Object.fromEntries(Object.entries(t).filter(([e])=>e!==`attrs`&&!Object.hasOwn(r,e))),...sd(n,r,e),attrs:n.attrs}}function ld(e,t,n){for(let r of Object.keys(t))if(!Object.hasOwn(e,r))throw RangeError(`schemaSpec requires a local ${n} extension named '${r}'`);for(let r of Object.keys(e))if(!Object.hasOwn(t,r))throw RangeError(`Local ${n} extension '${r}' is not in schemaSpec`)}function ud(e,t){ld(e.nodes,t.nodes,`node`),ld(e.marks,t.marks,`mark`);let n=t.spec.nodes,r=t.spec.marks;return t.spec.nodes.forEach((t,r)=>{n=n.update(t,cd(t,e.nodes[t],r,ad))}),t.spec.marks.forEach((t,n)=>{r=r.update(t,cd(t,e.marks[t],n,od))}),{topNode:t.topNodeType.name,nodes:n,marks:r}}function dd(e){let t=e.filter((t,n)=>e.indexOf(t)!==n);return Array.from(new Set(t))}function fd(e){return{baseExtensions:e.filter(e=>e.type===`extension`),nodeExtensions:e.filter(e=>e.type===`node`),markExtensions:e.filter(e=>e.type===`mark`)}}function pd(e){let t=[],{nodeExtensions:n,markExtensions:r}=fd(e),i=[...n,...r],a={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1},o=n.filter(e=>e.name!==`text`).map(e=>e.name),s=r.map(e=>e.name),c=[...o,...s];return e.forEach(e=>{let n=G(e,`addGlobalAttributes`,{name:e.name,options:e.options,storage:e.storage,extensions:i});n&&n().forEach(e=>{let n;n=Array.isArray(e.types)?e.types:e.types===`*`?c:e.types===`nodes`?o:e.types===`marks`?s:[],n.forEach(n=>{Object.entries(e.attributes).forEach(([e,r])=>{t.push({type:n,name:e,attribute:{...a,...r}})})})})}),i.forEach(e=>{let n=G(e,`addAttributes`,{name:e.name,options:e.options,storage:e.storage});if(!n)return;let r=n();Object.entries(r).forEach(([n,r])=>{let i={...a,...r};typeof i?.default==`function`&&(i.default=i.default()),i?.isRequired&&i?.default===void 0&&delete i.default,t.push({type:e.name,name:n,attribute:i})})}),t}function md(e){return typeof e==`function`}function K(e,t=void 0,...n){return md(e)?t?e.bind(t)(...n):e(...n):e}function hd(e={}){return Object.keys(e).length===0&&e.constructor===Object}function gd(e){let t=[],n=``,r=!1,i=!1,a=0,o=e.length;for(let s=0;s0){--a,n+=o;continue}if(o===`;`&&a===0){t.push(n),n=``;continue}}n+=o}}return n&&t.push(n),t}function _d(e){let t=[],n=gd(e||``),r=n.length;for(let e=0;e!!e).reduce((e,t)=>{let n={...e};return Object.entries(t).forEach(([e,t])=>{if(e===`__proto__`)Object.defineProperty(n,e,{configurable:!0,enumerable:!0,value:t,writable:!0});else if(!n[e])n[e]=t;else if(e===`class`){let r=t?String(t).split(` `):[],i=n[e]?n[e].split(` `):[],a=r.filter(e=>!i.includes(e));n[e]=[...i,...a].join(` `)}else if(e===`style`){let r=new Map([..._d(n[e]),..._d(t)]);n[e]=Array.from(r.entries()).map(([e,t])=>`${e}: ${t}`).join(`; `)}else n[e]=t}),n},{})}function vd(e,t){return t.filter(t=>t.type===e.type.name).filter(e=>e.attribute.rendered).map(t=>t.attribute.renderHTML?t.attribute.renderHTML(e.attrs)||{}:{[t.name]:e.attrs[t.name]}).reduce((e,t)=>q(e,t),{})}function yd(e){return typeof e==`string`?e.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(e):e===`true`||e!==`false`&&e:e}function bd(e,t){return`style`in e?e:{...e,getAttrs:n=>{let r=e.getAttrs?e.getAttrs(n):e.attrs;if(r===!1)return!1;let i=t.reduce((e,t)=>{let r=t.attribute.parseHTML?t.attribute.parseHTML(n):yd(n.getAttribute(t.name));return r==null?e:{...e,[t.name]:r}},{});return{...r,...i}}}}function xd(e){return Object.fromEntries(Object.entries(e).filter(([e,t])=>e===`attrs`&&hd(t)?!1:t!=null))}function Sd(e){var t,n;let r={};return!(e!=null&&(t=e.attribute)!=null&&t.isRequired)&&`default`in(e?.attribute||{})&&(r.default=e.attribute.default),(e==null||(n=e.attribute)==null?void 0:n.validate)!==void 0&&(r.validate=e.attribute.validate),[e.name,r]}function Cd(e,t,n=pd(e)){let{nodeExtensions:r,markExtensions:i}=fd(e);return{topNode:r.find(e=>G(e,`topNode`))?.name,nodes:Object.fromEntries(r.map(r=>{let i=n.filter(e=>e.type===r.name),a={name:r.name,options:r.options,storage:r.storage,editor:t},o=xd({...e.reduce((e,t)=>{let n=G(t,`extendNodeSchema`,a);return{...e,...n?n(r):{}}},{}),content:K(G(r,`content`,a)),marks:K(G(r,`marks`,a)),group:K(G(r,`group`,a)),inline:K(G(r,`inline`,a)),atom:K(G(r,`atom`,a)),selectable:K(G(r,`selectable`,a)),draggable:K(G(r,`draggable`,a)),code:K(G(r,`code`,a)),whitespace:K(G(r,`whitespace`,a)),linebreakReplacement:K(G(r,`linebreakReplacement`,a)),defining:K(G(r,`defining`,a)),isolating:K(G(r,`isolating`,a)),attrs:Object.fromEntries(i.map(Sd))}),s=K(G(r,`parseHTML`,a));s&&(o.parseDOM=s.map(e=>bd(e,i)));let c=G(r,`renderHTML`,a);c&&(o.toDOM=e=>c({node:e,HTMLAttributes:vd(e,i)}));let l=G(r,`renderText`,a);return l&&(o.toText=l),[r.name,o]})),marks:Object.fromEntries(i.map(r=>{let i=n.filter(e=>e.type===r.name),a={name:r.name,options:r.options,storage:r.storage,editor:t},o=xd({...e.reduce((e,t)=>{let n=G(t,`extendMarkSchema`,a);return{...e,...n?n(r):{}}},{}),inclusive:K(G(r,`inclusive`,a)),excludes:K(G(r,`excludes`,a)),group:K(G(r,`group`,a)),spanning:K(G(r,`spanning`,a)),code:K(G(r,`code`,a)),attrs:Object.fromEntries(i.map(Sd))}),s=K(G(r,`parseHTML`,a));s&&(o.parseDOM=s.map(e=>bd(e,i)));let c=G(r,`renderHTML`,a);return c&&(o.toDOM=e=>c({mark:e,HTMLAttributes:vd(e,i)})),[r.name,o]}))}}function wd(e,t,n){if(n===void 0)return new _t(Cd(e,t));let r=dd(e.filter(e=>e.type!==`extension`).map(e=>e.name));if(r.length)throw RangeError(`Duplicate local schema types: ${r.join(`, `)}`);let i=new _t(n);return new _t(ud(Cd(e,t,id(pd(e),i)),i))}function Td(e){return e.sort((e,t)=>{let n=G(e,`priority`)||100,r=G(t,`priority`)||100;return n>r?-1:+(ne.name));return n.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${n.map(e=>`'${e}'`).join(`, `)}]. This can lead to issues.`),t}function Dd(e,t,n){let{from:r,to:i}=t,{blockSeparator:a=` - -`,textSerializers:o={}}=n||{},s=``;return e.nodesBetween(r,i,(e,n,c,l)=>{e.isBlock&&n>r&&(s+=a);let u=o?.[e.type.name];if(u)return c&&(s+=u({node:e,pos:n,parent:c,index:l,range:t})),!1;if(e.isText){var d;s+=e==null||(d=e.text)==null?void 0:d.slice(Math.max(r,n)-n,i-n)}}),s}function Od(e,t){return Dd(e,{from:0,to:e.content.size},t)}function kd(e){return Object.fromEntries(Object.entries(e.nodes).filter(([,e])=>e.spec.toText).map(([e,t])=>[e,t.spec.toText]))}function Ad(e,t){let n=Vl(t,e.schema),{from:r,to:i}=e.selection,a=[];e.doc.nodesBetween(r,i,e=>{a.push(e)});let o=a.reverse().find(e=>e.type.name===n.name);return o?{...o.attrs}:{}}function jd(e,t){let n=zu(typeof t==`string`?t:t.name,e.schema);return n===`node`?Ad(e,t):n===`mark`?Zu(e,t):{}}function Md(e,t=JSON.stringify){let n={};return e.filter(e=>{let r=t(e);return Object.prototype.hasOwnProperty.call(n,r)?!1:n[r]=!0})}function Nd(e){let t=Md(e);return t.length===1?t:t.filter((e,n)=>!t.filter((e,t)=>t!==n).some(t=>e.oldRange.from>=t.oldRange.from&&e.oldRange.to<=t.oldRange.to&&e.newRange.from>=t.newRange.from&&e.newRange.to<=t.newRange.to))}function Pd(e){let{mapping:t,steps:n}=e,r=[],i=t.invert();return t.maps.forEach((e,a)=>{let o=[];if(e.ranges.length)e.forEach((e,t)=>{o.push({from:e,to:t})});else{let{from:e,to:t}=n[a];if(e===void 0||t===void 0)return;o.push({from:e,to:t})}let s=t.slice(a);o.forEach(({from:e,to:t})=>{let n=s.map(e,-1),a=s.map(t),o=i.map(n,-1),c=i.map(a);r.push({oldRange:{from:o,to:c},newRange:{from:n,to:a}})})}),Nd(r)}function Fd(e,t,n){let r=[];return e===t?n.resolve(e).marks().forEach(t=>{let i=eu(n.resolve(e),t.type);i&&r.push({mark:t,...i})}):n.nodesBetween(e,t,(e,t)=>{e&&e?.nodeSize!==void 0&&r.push(...e.marks.map(n=>({from:t,to:t+e.nodeSize,mark:n})))}),r}var Id=(e,t,n,r=20)=>{let i=e.doc.resolve(n),a=r,o=null;for(;a>0&&o===null;){let e=i.node(a);e?.type.name===t?o=e:--a}return[o,a]},Ld=e=>{let t=e.depth-1;if(t<0)return null;let n=e.index(t);return n===0?null:e.node(t).child(n-1)};function Rd(e,t){return t.nodes[e]||t.marks[e]||null}function zd(e,t,n){return Object.fromEntries(Object.entries(n).filter(([n])=>{let r=e.find(e=>e.type===t&&e.name===n);return r?r.attribute.keepOnSplit:!1}))}var Bd=(e,t=500)=>{let n=``,r=e.parentOffset;return e.parent.nodesBetween(Math.max(0,r-t),r,(e,t,i,a)=>{var o;let s=(o=e.type.spec).toText?.call(o,{node:e,pos:t,parent:i,index:a})||e.textContent||`%leaf%`;n+=e.isAtom&&!e.isText?s:s.slice(0,Math.max(0,r-t))}),n};function Vd(e,t,n={}){let{empty:r,ranges:i}=e.selection,a=t?tu(t,e.schema):null;if(r)return!!(e.storedMarks||e.selection.$from.marks()).filter(e=>!a||a.name===e.type.name).find(e=>Zl(e.attrs,n,{strict:!1}));let o=0,s=[];if(i.forEach(({$from:t,$to:n})=>{let r=t.pos,i=n.pos;e.doc.nodesBetween(r,i,(e,t)=>{if(a&&e.inlineContent&&!e.type.allowsMarkType(a))return!1;if(!e.isText&&!e.marks.length)return;let n=Math.max(r,t),c=Math.min(i,t+e.nodeSize),l=c-n;o+=l,s.push(...e.marks.map(e=>({mark:e,from:n,to:c})))})}),o===0)return!1;let c=s.filter(e=>!a||a.name===e.mark.type.name).filter(e=>Zl(e.mark.attrs,n,{strict:!1})).reduce((e,t)=>e+t.to-t.from,0),l=s.filter(e=>!a||e.mark.type!==a&&e.mark.type.excludes(a)).reduce((e,t)=>e+t.to-t.from,0);return(c>0?c+l:c)>=o}function Hd(e,t,n={}){if(!t)return Pu(e,null,n)||Vd(e,null,n);let r=zu(t,e.schema);return r===`node`?Pu(e,t,n):r===`mark`&&Vd(e,t,n)}var Ud=(e,t)=>{let{$from:n,$to:r,$anchor:i}=e.selection;if(t){let n=td(e=>e.type.name===t)(e.selection);if(!n)return!1;let r=e.doc.resolve(n.pos+1);return i.pos+1===r.end()}return!(r.parentOffset{let{$from:t,$to:n}=e.selection;return!(t.parentOffset>0||t.pos!==n.pos)};function Gd(e,t){return Array.isArray(t)?t.some(t=>(typeof t==`string`?t:t.name)===e.name):t}function Kd(e,t){let{nodeExtensions:n}=fd(t),r=n.find(t=>t.name===e);if(!r)return!1;let i=K(G(r,`group`,{name:r.name,options:r.options,storage:r.storage}));return typeof i==`string`&&i.split(` `).includes(`list`)}function qd(e,{checkChildren:t=!0,ignoreWhitespace:n=!1}={}){if(n){if(e.type.name===`hardBreak`)return!0;if(e.isText)return!/\S/.test(e.text??``)}if(e.isText)return!e.text;if(e.isAtom||e.isLeaf)return!1;if(e.content.childCount===0)return!0;if(t){let r=!0;return e.content.forEach(e=>{r!==!1&&(qd(e,{ignoreWhitespace:n,checkChildren:t})||(r=!1))}),r}return!1}function Jd(e){return e instanceof B}function Yd(e){if(typeof e!=`object`||!e)return!1;let t=e;return typeof t.apply==`function`&&typeof t.getMap==`function`&&typeof t.invert==`function`&&typeof t.map==`function`&&typeof t.merge==`function`&&typeof t.toJSON==`function`}function Xd(e){if(typeof e!=`object`||!e)return!1;let t=e;if(!Yd(t))return!1;let n=t.toJSON();return!(typeof n!=`object`||!n||n.stepType!==`replace`)}var Zd=class e{constructor(e){this.position=e}static fromJSON(t){return new e(t.position)}toJSON(){return{position:this.position}}};function Qd(e,t){let n=t.mapping.mapResult(e.position);return{position:new Zd(n.pos),mapResult:n}}function $d(e){return new Zd(e)}function ef(e,t,n){let{selection:r}=t,i=null;if(iu(r)&&(i=r.$cursor),i){let t=e.storedMarks??i.marks();return i.parent.type.allowsMarkType(n)&&(!!n.isInSet(t)||!t.some(e=>e.type.excludes(n)))}let{ranges:a}=r;return a.some(({$from:t,$to:r})=>{let i=t.depth===0&&e.doc.inlineContent&&e.doc.type.allowsMarkType(n);return e.doc.nodesBetween(t.pos,r.pos,(e,t,r)=>{if(i)return!1;if(e.isInline){let t=!r||r.type.allowsMarkType(n),a=!!n.isInSet(e.marks)||!e.marks.some(e=>e.type.excludes(n));i=t&&a}return!i}),i})}var tf=(e,t={})=>({tr:n,state:r,dispatch:i})=>{let{selection:a}=n,{empty:o,ranges:s}=a,c=tu(e,r.schema);if(i){if(o){let e=Zu(r,c);n.addStoredMark(c.create({...e,...t}))}else s.forEach(e=>{let i=e.$from.pos,a=e.$to.pos;r.doc.nodesBetween(i,a,(e,r)=>{let o=Math.max(r,i),s=Math.min(r+e.nodeSize,a);e.marks.find(e=>e.type===c)?e.marks.forEach(e=>{c===e.type&&n.addMark(o,s,c.create({...e.attrs,...t}))}):n.addMark(o,s,c.create(t))})})}return ef(r,n,c)},nf=(e,t)=>({tr:n})=>(n.setMeta(e,t),!0),rf=(e,t={})=>({state:n,dispatch:r,chain:i})=>{let a=Vl(e,n.schema),o;return n.selection.$anchor.sameParent(n.selection.$head)&&(o=n.selection.$anchor.parent.attrs),a.isTextblock?i().command(({commands:e})=>ii(a,{...o,...t})(n)?!0:e.clearNodes()).command(({state:e})=>ii(a,{...o,...t})(e,r)).run():(console.warn(`[tiptap warn]: Currently "setNode()" only supports text block nodes.`),!1)},af=e=>({tr:t,dispatch:n})=>{if(n){let{doc:n}=t,r=au(e,0,n.content.size),i=B.create(n,r);t.setSelection(i)}return!0},of=(e,t)=>({tr:n,state:r,dispatch:i})=>{let{selection:a}=r,o,s;return typeof t==`number`?(o=t,s=t):t&&`from`in t&&`to`in t?(o=t.from,s=t.to):(o=a.from,s=a.to),i&&n.doc.nodesBetween(o,s,(t,r)=>{t.isText||n.setNodeMarkup(r,void 0,{...t.attrs,dir:e})}),!0},sf=e=>({tr:t,dispatch:n})=>{if(n){let{doc:n}=t,{from:r,to:i}=typeof e==`number`?{from:e,to:e}:e,a=z.atStart(n).from,o=z.atEnd(n).to,s=au(r,a,o),c=au(i,a,o),l=z.create(n,s,c);t.setSelection(l)}return!0},cf=e=>({state:t,dispatch:n})=>_i(Vl(e,t.schema))(t,n);function lf(e,t){let n=e.storedMarks||e.selection.$to.parentOffset&&e.selection.$from.marks();if(n){let r=n.filter(e=>t?.includes(e.type.name));e.tr.ensureMarks(r)}}var uf=({keepMarks:e=!0}={})=>({tr:t,state:n,dispatch:r,editor:i})=>{let{selection:a,doc:o}=t,{$from:s,$to:c}=a,l=i.extensionManager.attributes,u=zd(l,s.node().type.name,s.node().attrs);if(a instanceof B&&a.node.isBlock)return!s.parentOffset||!An(o,s.pos)?!1:(r&&(e&&lf(n,i.extensionManager.splittableMarks),t.split(s.pos).scrollIntoView()),!0);if(!s.parent.isBlock)return!1;let d=c.parentOffset===c.parent.content.size,f=s.depth===0?void 0:bu(s.node(-1).contentMatchAt(s.indexAfter(-1))),p=d&&f?[{type:f,attrs:u}]:void 0,m=a instanceof z&&!a.empty?Cr.create({doc:t.doc,selection:a}).tr.deleteSelection():null,h=m?m.doc:t.doc,g=m?m.mapping.map(s.pos):s.pos,_=An(h,g,1,p);if(!p&&!_&&An(h,g,1,f?[{type:f}]:void 0)&&(_=!0,p=f?[{type:f,attrs:u}]:void 0),r){if(_){let e=t.steps.length;if(a instanceof z&&t.deleteSelection(),t.split(t.mapping.slice(e).map(s.pos),1,p),f&&!d&&!s.parentOffset&&s.parent.type!==f){let n=t.mapping.slice(e).map(s.before()),r=t.doc.resolve(n);s.node(-1).canReplaceWith(r.index(),r.index()+1,f)&&t.setNodeMarkup(t.mapping.slice(e).map(s.before()),f)}}e&&lf(n,i.extensionManager.splittableMarks),t.scrollIntoView()}return _},df=(e,t={})=>({tr:n,state:r,dispatch:i,editor:a})=>{let o=Vl(e,r.schema),{$from:s,$to:c}=r.selection,l=r.selection.node;if(l&&l.isBlock||s.depth<2||!s.sameParent(c))return!1;let u=s.node(-1);if(u.type!==o)return!1;let d=a.extensionManager.attributes;if(s.parent.content.size===0&&s.node(-1).childCount===s.indexAfter(-1)){if(s.depth===2||s.node(-3).type!==o||s.index(-2)!==s.node(-2).childCount-1)return!1;if(i){let e=F.empty,r=s.index(-1)?1:s.index(-2)?2:3;for(let t=s.depth-r;t>=s.depth-3;--t)e=F.from(s.node(t).copy(e));let i=s.indexAfter(-1){if(u>-1)return!1;e.isTextblock&&e.content.size===0&&(u=t+1)}),u>-1&&n.setSelection(z.near(n.doc.resolve(u))),n.scrollIntoView()}return!0}let f=c.pos===s.end()?u.contentMatchAt(0).defaultType:null,p={...zd(d,u.type.name,u.attrs),...t},m={...zd(d,s.node().type.name,s.node().attrs),...t},h=s.parentOffset===0&&s.index(-1)===0,g=s.before(-1);n.delete(s.pos,c.pos);let _=h?u.attrs:p,v=f?[{type:o,attrs:_},{type:f,attrs:m}]:[{type:o,attrs:_}];if(!An(n.doc,s.pos,2))return!1;if(i){let{selection:e,storedMarks:t}=r,{splittableMarks:o}=a.extensionManager,c=t||e.$to.parentOffset&&e.$from.marks();if(n.split(s.pos,2,v).scrollIntoView(),h&&n.setNodeMarkup(g,void 0,p),!c||!i)return!0;let l=c.filter(e=>o.includes(e.type.name));n.ensureMarks(l)}return!0};function ff(e,t,n){if(!e.validContent(t))return null;try{return e.create(n,t)}catch{return null}}function pf(e,t){if(e.pendingContent.length===0)return!0;let n=ff(t,F.from(e.pendingContent));return n?(e.items.push(n),e.pendingContent=[],!0):!1}function mf(e,t,n){return n.validContent(F.from([...t.pendingContent,e]))?(t.pendingContent.push(e),!0):!pf(t,n)||!n.validContent(F.from(e))?!1:(t.pendingContent.push(e),!0)}function hf(e,t,n,r){let i=r(e,n);if(!i)return!1;let a=ff(n.listType,F.from(i),e.attrs);return a?n.itemType.validContent(F.from([...t.pendingContent,a]))?(t.pendingContent.push(a),!0):pf(t,n.itemType)?(t.items.push(...i),!0):!1:!1}function gf(e,t,n){let r={items:[],pendingContent:[]};for(let i=0;ie!==t||(n=r,!1)),n}function yf(e){return!e||e===`1`?null:e}function bf(e,t){return yf(e)===yf(t)}var xf=(e,t)=>{let n=td(e=>e.type===t)(e.selection);if(!n)return!0;let r=e.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(r===void 0)return!0;let i=e.doc.nodeAt(r);return!(n.node.type===i?.type&&Mn(e.doc,n.pos))||!bf(n.node.attrs.type,i?.attrs.type)||e.join(n.pos),!0},Sf=(e,t)=>{let n=td(e=>e.type===t)(e.selection);if(!n)return!0;let r=e.doc.resolve(n.start).after(n.depth);if(r===void 0)return!0;let i=e.doc.nodeAt(r);return!(n.node.type===i?.type&&Mn(e.doc,r))||!bf(n.node.attrs.type,i?.attrs.type)||e.join(r),!0};function Cf(e){let t=e.doc,n=t.firstChild;if(!n)return null;let r=t.resolve(1),i=t.resolve(n.nodeSize-1);return z.between(r,i)}var wf=(e,t,n,r={})=>({editor:i,tr:a,state:o,dispatch:s,chain:c,commands:l,can:u})=>{let{extensions:d,splittableMarks:f}=i.extensionManager,p=Vl(e,o.schema),m=Vl(t,o.schema),{selection:h,storedMarks:g}=o,{$from:_,$to:v}=h,y=_.blockRange(v),b=g||h.$to.parentOffset&&h.$from.marks();if(!y)return!1;let x=td(e=>Kd(e.type.name,d))(h),S=h.from===0&&h.to===o.doc.content.size,C=o.doc.content.content,w=C.length===1?C[0]:null,T=S&&w&&Kd(w.type.name,d)?{node:w,pos:0,depth:0}:null,E=x??T,D=!!x&&y.depth>=1&&y.depth-x.depth<=1,ee=!!T;if((D||ee)&&E){if(E.node.type===p)return S&&ee?c().command(({tr:e,dispatch:t})=>{let n=Cf(e);return n?(e.setSelection(n),t&&t(e),!0):!1}).liftListItem(m).run():l.liftListItem(m);if(Kd(E.node.type.name,d)&&p.validContent(E.node.content))return c().command(()=>(a.setNodeMarkup(E.pos,p),!0)).command(()=>xf(a,p)).command(()=>Sf(a,p)).run();if(Kd(E.node.type.name,d)){let e=E.node.firstChild?.type;if(e&&e!==m){let e=_f(E.node,{listType:p,itemType:m,isListNode:e=>Kd(e.type.name,d)}),t=e?F.from(e):null;return!t||!p.validContent(t)?!1:c().command(()=>{let{$anchor:e,$head:n}=a.selection,i=e.parent,o=n.parent,s=e.parentOffset,c=n.parentOffset,l;try{l=p.create(r,t)}catch{return!1}if(a.replaceWith(E.pos,E.pos+E.node.nodeSize,l),i.inlineContent&&o.inlineContent){let e=vf(l,i),t=vf(l,o);if(e!==null&&t!==null){let n=E.pos+e+2+s,r=E.pos+t+2+c;a.setSelection(z.create(a.doc,n,r))}}return!0}).command(()=>xf(a,p)).command(()=>Sf(a,p)).run()}}}return!n||!b||!s?c().command(()=>u().wrapInList(p,r)?!0:l.clearNodes()).wrapInList(p,r).command(()=>xf(a,p)).command(()=>Sf(a,p)).run():c().command(()=>{let e=u().wrapInList(p,r),t=b.filter(e=>f.includes(e.type.name));return a.ensureMarks(t),e?!0:l.clearNodes()}).wrapInList(p,r).command(()=>xf(a,p)).command(()=>Sf(a,p)).run()},Tf=(e,t={},n={})=>({state:r,commands:i})=>{let{extendEmptyMarkRange:a=!1}=n,o=tu(e,r.schema);return Vd(r,o,t)?i.unsetMark(o,{extendEmptyMarkRange:a}):i.setMark(o,t)},Ef=(e,t,n={})=>({state:r,commands:i})=>{let a=Vl(e,r.schema),o=Vl(t,r.schema),s=Pu(r,a,n),c;return r.selection.$anchor.sameParent(r.selection.$head)&&(c=r.selection.$anchor.parent.attrs),s?i.setNode(o,c):i.setNode(a,{...c,...n})},Df=(e,t={})=>({state:n,commands:r})=>{let i=Vl(e,n.schema);return Pu(n,i,t)?r.lift(i):r.wrapIn(i,t)},Of=()=>({state:e,dispatch:t})=>{let n=e.plugins;for(let r=0;r=0;--e)t.step(n.steps[e].invert(n.docs[e]));if(a.text){let n=t.doc.resolve(a.from).marks();t.replaceWith(a.from,a.to,e.schema.text(a.text,n))}else t.delete(a.from,a.to)}return!0}}return!1},kf=(e={})=>({tr:t,dispatch:n,editor:r})=>{let{ignoreClearable:i=!1}=e,{selection:a}=t,{empty:o,ranges:s}=a;if(o)return!0;let{nonClearableMarks:c}=r.extensionManager;if(n){let e=Object.values(r.schema.marks).filter(e=>i||!c.includes(e.name));s.forEach(n=>{for(let r of e)t.removeMark(n.$from.pos,n.$to.pos,r)})}return!0},Af=(e,t={})=>({tr:n,state:r,dispatch:i})=>{let{extendEmptyMarkRange:a=!1}=t,{selection:o}=n,s=tu(e,r.schema),{$from:c,empty:l,ranges:u}=o;if(!i)return!0;if(l&&a){let{from:e,to:t}=o,r=eu(c,s,c.marks().find(e=>e.type===s)?.attrs);r&&(e=r.from,t=r.to),n.removeMark(e,t,s)}else u.forEach(e=>{n.removeMark(e.$from.pos,e.$to.pos,s)});return n.removeStoredMark(s),!0},jf=e=>({tr:t,state:n,dispatch:r})=>{let{selection:i}=n,a,o;return typeof e==`number`?(a=e,o=e):e&&`from`in e&&`to`in e?(a=e.from,o=e.to):(a=i.from,o=i.to),r&&t.doc.nodesBetween(a,o,(e,n)=>{if(e.isText)return;let r={...e.attrs};delete r.dir,t.setNodeMarkup(n,void 0,r)}),!0},Mf=(e,t={})=>({tr:n,state:r,dispatch:i})=>{let a=null,o=null,s=zu(typeof e==`string`?e:e.name,r.schema);if(!s)return!1;s===`node`&&(a=Vl(e,r.schema)),s===`mark`&&(o=tu(e,r.schema));let c=!1;return n.selection.ranges.forEach(e=>{let s=e.$from.pos,l=e.$to.pos,u,d,f,p;n.selection.empty?r.doc.nodesBetween(s,l,(e,t)=>{a&&a===e.type&&(c=!0,f=Math.max(t,s),p=Math.min(t+e.nodeSize,l),u=t,d=e)}):r.doc.nodesBetween(s,l,(e,r)=>{r=s&&r<=l&&(a&&a===e.type&&(c=!0,i&&n.setNodeMarkup(r,void 0,{...e.attrs,...t})),o&&e.marks.length&&e.marks.forEach(a=>{if(o===a.type&&(c=!0,i)){let i=Math.max(r,s),c=Math.min(r+e.nodeSize,l);n.addMark(i,c,o.create({...a.attrs,...t}))}}))}),d&&(u!==void 0&&i&&n.setNodeMarkup(u,void 0,{...d.attrs,...t}),o&&d.marks.length&&d.marks.forEach(e=>{o===e.type&&i&&n.addMark(f,p,o.create({...e.attrs,...t}))}))}),c},Nf=new H(`__tiptap_decorations__`),Pf=e=>({tr:t,dispatch:n})=>(n&&t.setMeta(Nf,{type:`force`,name:e}),!0),Ff=(e,t={})=>({state:n,dispatch:r})=>ri(Vl(e,n.schema),t)(n,r),If=(e,t={})=>({state:n,dispatch:r})=>ui(Vl(e,n.schema),t)(n,r),Lf=_e({blur:()=>Pl,clearContent:()=>Fl,clearNodes:()=>Il,command:()=>Ll,createParagraphNear:()=>Rl,cut:()=>zl,deleteCurrentNode:()=>Bl,deleteNode:()=>Hl,deleteRange:()=>Ul,deleteSelection:()=>ql,enter:()=>Jl,exitCode:()=>Yl,extendMarkRange:()=>nu,first:()=>ru,focus:()=>uu,forEach:()=>du,insertContent:()=>fu,insertContentAt:()=>yu,insertDefaultBlock:()=>xu,joinBackward:()=>wu,joinDown:()=>Cu,joinForward:()=>Tu,joinItemBackward:()=>Du,joinItemForward:()=>Ou,joinTextblockBackward:()=>ku,joinTextblockForward:()=>Au,joinUp:()=>Su,keyboardShortcut:()=>Nu,lift:()=>Fu,liftEmptyBlock:()=>Iu,liftListItem:()=>Lu,newlineInCode:()=>Ru,resetAttributes:()=>Vu,scrollIntoView:()=>Hu,selectAll:()=>Uu,selectNodeBackward:()=>Wu,selectNodeForward:()=>Gu,selectParentNode:()=>Ku,selectTextblockEnd:()=>qu,selectTextblockStart:()=>Ju,setContent:()=>Xu,setMark:()=>tf,setMeta:()=>nf,setNode:()=>rf,setNodeSelection:()=>af,setTextDirection:()=>of,setTextSelection:()=>sf,sinkListItem:()=>cf,splitBlock:()=>uf,splitListItem:()=>df,toggleList:()=>wf,toggleMark:()=>Tf,toggleNode:()=>Ef,toggleWrap:()=>Df,undoInputRule:()=>Of,unsetAllMarks:()=>kf,unsetMark:()=>Af,unsetTextDirection:()=>jf,updateAttributes:()=>Mf,updateDecorations:()=>Pf,wrapIn:()=>Ff,wrapInList:()=>If}),Rf=new WeakMap;function zf(e,t){Rf.set(e,(Rf.get(e)??0)+1);try{return t()}finally{let t=(Rf.get(e)??1)-1;t>0?Rf.set(e,t):Rf.delete(e)}}function Bf(e){return Rf.has(e)}var Vf=class{constructor(){this.callbacks={}}on(e,t){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(t),this}emit(e,...t){let n=this.callbacks[e];return n&&n.forEach(e=>e.apply(this,t)),this}off(e,t){let n=this.callbacks[e];return n&&(t?this.callbacks[e]=n.filter(e=>e!==t):delete this.callbacks[e]),this}once(e,t){let n=(...r)=>{this.off(e,n),t.apply(this,r)};return this.on(e,n)}removeAllListeners(){this.callbacks={}}},Hf=typeof process<`u`&&!1;function Uf(e){return e.kind===`widget`}function Wf(e,t){let n=[],r=new Set;for(let i of e)i.kind===`widget`&&Uf(i)&&r.add(i.key),n.push(i.toPMDecoration(t));return{decorations:n,widgetKeys:r}}function Gf(e,t,n){let{decorations:r,widgetKeys:i}=Wf(t,n);return{set:W.create(e,r),widgetKeys:i}}function Kf({position:e,from:t,to:n,docSize:r}){return eKf({position:e.anchor,from:t,to:n,docSize:r})?!0:(e.anchor===n||a.has(i)||(a.add(i),console.warn(`[tiptap warn]: Extension "${i}" returned a decoration outside the requested range [${t}, ${n}). It was ignored.`)),!1))}function Jf(e){let t=e.spec?.key;return typeof t==`string`?t:void 0}function Yf(e){let t=new Map,n=new Map;for(let r of e.find()){let e=Jf(r);if(!e)continue;let i=r.spec.extensionName??`unknown`,a=t.get(e)??new Set;a.add(i),t.set(e,a),n.set(e,(n.get(e)??0)+1)}return Array.from(t,([e,t])=>({key:e,extensions:t})).filter(({key:e})=>(n.get(e)??0)>1)}function Xf(e){return e.jsonID===`attr`}function Zf(e){let t=!1;if(e.getMap().forEach(()=>{t=!0}),t||Xf(e))return!0;let n=e;return typeof n.from==`number`&&typeof n.to==`number`}function Qf(e,t){let n=null,r=0,i=0;for(let a=0;at.to);a+=1){let o=i+e.child(a).nodeSize;o>=t.from&&(n===null&&(n=i),r=o),i=o}return n===null?null:{from:n,to:r}}function $f(e,t){if(e.steps.some(e=>!Zf(e)))return{type:`full`};let n=Pd(e).map(({newRange:e})=>e);e.steps.forEach((t,r)=>{if(!Xf(t))return;let i=e.mapping.slice(r);n.push({from:i.map(t.pos,-1),to:i.map(t.pos+1)})});let r=[];for(let e of n){let n=Qf(t,e);n&&r.push(n)}r.sort((e,t)=>e.from-t.from);let i=[];for(let e of r){let t=i[i.length-1];t&&e.from<=t.to?t.to=Math.max(t.to,e.to):i.push({...e})}return{type:`ranges`,ranges:i}}function ep(e,t,n,r){return e.map(t,n,{onRemove:e=>{let t=e?.key;typeof t==`string`&&r.delete(t)}})}function tp(e,t,n){let r=t.decorationSetsByExtension[e]??W.empty,i=new Set(t.widgetKeysByExtension[e]??[]);return{set:ep(r,n.mapping,n.doc,i),widgetKeys:i}}function np(e,t){let n=Object.values(t).flatMap(e=>e.find());return W.create(e,n)}function rp(e){let t=new Set;for(let n of Object.values(e))for(let e of n)t.add(e);return t}function ip(e,t){switch(t.update??`document`){case`document`:if(t.createInRange)throw Error(`[tiptap error]: Extension "${e}" provides createInRange() but does not use the "changedRanges" decoration update strategy.`);return;case`changedRanges`:if(!t.createInRange)throw Error(`[tiptap error]: Extension "${e}" uses the "changedRanges" decoration update strategy but does not provide createInRange().`);return;case`manual`:if(t.createInRange)throw Error(`[tiptap error]: Extension "${e}" uses the "manual" decoration update strategy, which is not compatible with createInRange(). createInRange() requires the "changedRanges" strategy.`);if(t.shouldUpdate)throw Error(`[tiptap error]: Extension "${e}" cannot combine the "manual" decoration update strategy with shouldUpdate().`);return;default:throw Error(`[tiptap error]: Extension "${e}" uses an unknown decoration update strategy. Expected "document", "changedRanges", or "manual".`)}}function ap(e,t,n){return n?!0:e.update===`manual`?!1:e.shouldUpdate?e.shouldUpdate(t):t.tr.docChanged}var op=new Set,sp=class{constructor(e){this.warnedWidgetKeys=new Set,this.warnedOutOfRangeExtensions=new Set,this.handleBeforeTransaction=({nextState:e})=>{let t=Nf.getState(e);t&&this.warnDuplicateWidgetKeys(t)},this.editor=e.editor,this.entries=this.resolveEntries(e.entries),this.entries.forEach(({name:e,spec:t})=>ip(e,t)),this.plugin=this.entries.length>0?this.createPlugin():null,this.editor.on(`beforeTransaction`,this.handleBeforeTransaction)}destroy(){this.editor.off(`beforeTransaction`,this.handleBeforeTransaction)}liveWidgetKeys(){return Nf.getState(this.editor.state)?.widgetKeys??op}get mountedView(){return this.editor.isDestroyed?null:this.editor.view}resolveEntries(e){let t=[];for(let{name:n,addDecorations:r}of e){let e=r();e&&t.push({name:n,spec:e})}return t}createPlugin(){let{editor:e,entries:t}=this;return new V({key:Nf,state:{init:(e,n)=>{let r={},i={};for(let{name:e,spec:a}of t){let{set:t,widgetKeys:o}=this.buildFullSet(e,a,n);r[e]=t,i[e]=o}let a={decorationSetsByExtension:r,widgetKeysByExtension:i,mergedDecorationSet:this.buildMergedSet(n.doc,r),widgetKeys:rp(i)};return this.warnDuplicateWidgetKeys(a),a},apply:(n,r,i,a)=>{let o=n.getMeta(Nf),s=o?.type===`force`&&!o.name,c=o?.type===`force`?o.name:void 0,l={},u={},d=new Set;return zf(e,()=>{for(let{name:o,spec:f}of t){let t=s||c===o;if(!ap(f,{editor:e,tr:n,oldState:i,newState:a},t)){let e=tp(o,r,n);l[o]=e.set,u[o]=e.widgetKeys}else if(f.update===`changedRanges`&&n.docChanged&&!t){let e=this.applyChangedRangesRecompute(o,f,r,n,a);l[o]=e.set,u[o]=e.widgetKeys,d.add(o)}else{let{set:e,widgetKeys:t}=this.buildFullSet(o,f,a);l[o]=e,u[o]=t,d.add(o)}}}),d.size===0&&!n.docChanged?r:{decorationSetsByExtension:l,widgetKeysByExtension:u,mergedDecorationSet:this.mergeAfterApply({entries:t,previous:r,tr:n,decorationSetsByExtension:l,recomputedNames:d}),widgetKeys:rp(u)}}},props:{decorations(e){return Nf.getState(e)?.mergedDecorationSet??W.empty}}})}applyChangedRangesRecompute(e,t,n,r,i){let a=$f(r,i.doc);return a.type===`full`?this.buildFullSet(e,t,i):this.rebuildRanges(e,t,n,r,i,a.ranges)}rebuildRanges(e,t,n,r,i,a){let o=n.decorationSetsByExtension[e]??W.empty,s=new Set(n.widgetKeysByExtension[e]??[]),c=ep(o,r.mapping,r.doc,s),l=i.doc.content.size;for(let{from:n,to:r}of a){let a=c.find(n,r).filter(e=>Kf({position:e.from,from:n,to:r,docSize:l}));for(let e of a){let t=Jf(e);t&&s.delete(t)}c=c.remove(a);let{decorations:o,widgetKeys:u}=Wf(qf({decorations:this.runCreate(e,`createInRange`,()=>t.createInRange({editor:this.editor,state:i,view:this.mountedView,from:n,to:r})),from:n,to:r,docSize:l,extensionName:e,warnedExtensions:this.warnedOutOfRangeExtensions}),e);c=c.add(i.doc,o);for(let e of u)s.add(e)}return{set:c,widgetKeys:s}}buildFullSet(e,t,n){let r=this.runCreate(e,`create`,()=>t.create({editor:this.editor,state:n,view:this.mountedView}));return Gf(n.doc,r,e)}runCreate(e,t,n){try{return n()}catch(n){return console.error(`[tiptap error]: Extension "${e}" threw in \`addDecorations().${t}()\`. Its decorations were dropped for this update.`,n),[]}}warnDuplicateWidgetKeys(e){if(!Hf)return;if(e.widgetKeys.size===0){this.warnedWidgetKeys.clear();return}let t=Yf(e.mergedDecorationSet),n=new Set(t.map(({key:e})=>e));for(let{key:e,extensions:n}of t){if(this.warnedWidgetKeys.has(e))continue;let t=Array.from(n).map(e=>`"${e}"`).join(`, `);console.warn(`[tiptap warn]: Duplicate widget decoration key "${e}" in extension${n.size===1?``:`s`} ${t}. Widget decoration keys must be globally unique, otherwise ProseMirror misplaces the widget DOM. Use a stable, unique key (e.g. \`comment-\${id}\`).`)}this.warnedWidgetKeys=n}buildMergedSet(e,t){let n=Object.keys(t);return n.length===1?t[n[0]]:np(e,t)}mergeAfterApply({entries:e,previous:t,tr:n,decorationSetsByExtension:r,recomputedNames:i}){return e.length===1?r[e[0].name]:i.size===0?t.mergedDecorationSet.map(n.mapping,n.doc):np(n.doc,r)}};function cp(e,t){let{selection:n}=e,{$from:r}=n;if(n instanceof B){let e=r.index();return r.parent.canReplaceWith(e,e+1,t)}let i=r.depth;for(;i>=0;){let e=r.index(i);if(r.node(i).contentMatchAt(e).matchType(t))return!0;--i}return!1}function lp(e,t,n){let r=document.querySelector(`style[data-tiptap-style${n?`-${n}`:``}]`);if(r!==null)return r;let i=document.createElement(`style`);return t&&i.setAttribute(`nonce`,t),i.setAttribute(`data-tiptap-style${n?`-${n}`:``}`,``),i.innerHTML=e,document.getElementsByTagName(`head`)[0].appendChild(i),i}function up(e,t){let n=e.getAttribute(`style`);if(!n)return null;let r=n.split(`;`).map(e=>e.trim()).filter(Boolean),i=t.toLowerCase();for(let e=r.length-1;e>=0;--e){let t=r[e],n=t.indexOf(`:`);if(n!==-1&&t.slice(0,n).trim().toLowerCase()===i)return t.slice(n+1).trim()}return null}function dp(e){return typeof e==`number`}function fp(e){return Object.prototype.toString.call(e).slice(8,-1)}function pp(e){return fp(e)===`Object`&&e.constructor===Object&&Object.getPrototypeOf(e)===Object.prototype}function mp(e){return typeof e==`string`&&e.trim().length>0&&!/[;{}]/.test(e)}function hp(e,t){return e.replace(/^[ \t]*/,e=>{let n=0;for(let t of e)n+=t===` `?4-n%4:1;return` `.repeat(Math.max(0,n-t))})}function gp(e,t){let n=`text\n${e}\n`,r=t(n)[0];return(r?.type===`paragraph`||r?.type===`text`)&&r.raw===n}function _p(e,t,n){let r=t.split(` -`),i=n.isParagraphContinuation??(e=>gp(e,n.blockTokens)),a=0;for(let e of r){if(!e.trim()||!i(e))break;a+=1}return{mainContent:[e,...r.slice(0,a).map(e=>e.trimStart())].join(` +import{$ as e,A as t,B as n,C as r,D as i,E as a,F as o,G as s,H as c,I as l,J as u,K as d,M as f,N as p,O as m,P as h,Q as g,R as _,S as v,T as y,U as b,V as x,W as S,X as C,Z as w,_ as T,b as E,c as ee,d as te,et as ne,f as re,g as D,h as ie,j as ae,k as oe,m as se,o as ce,p as le,tt as O,u as ue,v as k,w as A,x as j,y as de,z as M}from"./dist-Bie52OmN.js";import{n as N}from"./app-BCJOqmKO.js";import{i as fe,n as pe,r as me}from"./AdminLayout-DBeSErmz.js";import{t as he}from"./AdminModal-DKazeNNa.js";import{t as ge}from"./AdminButton-KiIJ2sLW.js";var _e=Object.defineProperty,ve=(e,t)=>{let n={};for(var r in e)_e(n,r,{get:e[r],enumerable:!0});return t||_e(n,Symbol.toStringTag,{value:`Module`}),n};function ye(e){this.content=e}ye.prototype={constructor:ye,find:function(e){for(var t=0;t>1}},ye.from=function(e){if(e instanceof ye)return e;var t=[];if(e)for(var n in e)t.push(n,e[n]);return new ye(t)};function be(e,t,n){for(let r=0;;r++){if(r==e.childCount||r==t.childCount)return e.childCount==t.childCount?null:n;let i=e.child(r),a=t.child(r);if(i==a)n+=i.nodeSize;else{if(!i.sameMarkup(a))return n;if(i.isText&&i.text!=a.text){let e=i.text,t=a.text,r=0;for(;e[r]==t[r];r++)n++;return r&&r0&&a>0&&e[i-1]==t[a-1];)i--,a--,n--,r--;return i&&a&&i=56320&&e<57344}function Ce(e){return e>=55296&&e<56320}var P=class e{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let t=0;te&&n(s,r+o,i||null,a)!==!1&&s.content.size){let i=o+1;s.nodesBetween(Math.max(0,e-i),Math.min(s.content.size,t-i),n,r+i)}o=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,n,r){let i=``,a=!0;return this.nodesBetween(e,t,(o,s)=>{let c=o.isText?o.text.slice(Math.max(e,s)-s,t-s):o.isLeaf?r?typeof r==`function`?r(o):r:o.type.spec.leafText?o.type.spec.leafText(o):``:``;o.isBlock&&(o.isLeaf&&c||o.isTextblock)&&n&&(a?a=!1:i+=n),i+=c},0),i}append(t){if(!t.size)return this;if(!this.size)return t;let n=this.lastChild,r=t.firstChild,i=this.content.slice(),a=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),a=1);at)for(let e=0,a=0;at&&((an)&&(o=o.isText?o.cut(Math.max(0,t-a),Math.min(o.text.length,n-a)):o.cut(Math.max(0,t-a-1),Math.min(o.content.size,n-a-1))),r.push(o),i+=o.nodeSize),a=s}return new e(r,i)}cutByIndex(t,n){return t==n?e.empty:t==0&&n==this.content.length?this:new e(this.content.slice(t,n))}replaceChild(t,n){let r=this.content[t];if(r==n)return this;let i=this.content.slice(),a=this.size+n.nodeSize-r.nodeSize;return i[t]=n,new e(i,a)}addToStart(t){return new e([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new e(this.content.concat(t),this.size+t.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;tthis.size||e<0)throw RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,n=0;;t++){let r=this.child(t),i=n+r.nodeSize;if(i>=e)return i==e?Te(t+1,i):Te(t,n);n=i}}toString(){return`<`+this.toStringInner()+`>`}toStringInner(){return this.content.join(`, `)}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(t,n){if(!n)return e.empty;if(!Array.isArray(n))throw RangeError(`Invalid input for Fragment.fromJSON`);return e.fromArray(n.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return e.empty;let n,r=0;for(let e=0;ethis.type.rank&&(t||=e.slice(0,r),t.push(this),n=!0),t&&t.push(i)}return t||=e.slice(),n||t.push(this),t}removeFromSet(e){for(let t=0;te.type.rank-t.type.rank),n}};F.none=[];var De=class extends Error{},I=class e{constructor(e,t,n){this.content=e,this.openStart=t,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,n){let r=ke(this.content,t+this.openStart,n,this.openStart+1,this.openEnd+1);return r&&new e(r,this.openStart,this.openEnd)}removeBetween(t,n){return new e(Oe(this.content,t+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+`(`+this.openStart+`,`+this.openEnd+`)`}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(t,n){if(!n)return e.empty;let r=n.openStart||0,i=n.openEnd||0;if(typeof r!=`number`||typeof i!=`number`)throw RangeError(`Invalid input for Slice.fromJSON`);return new e(P.fromJSON(t,n.content),r,i)}static maxOpen(t,n=!0){let r=0,i=0;for(let e=t.firstChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.firstChild)r++;for(let e=t.lastChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.lastChild)i++;return new e(t,r,i)}};I.empty=new I(P.empty,0,0);function Oe(e,t,n){let{index:r,offset:i}=e.findIndex(t),a=e.maybeChild(r),{index:o,offset:s}=e.findIndex(n);if(i==t||a.isText){if(s!=n&&!e.child(o).isText)throw RangeError(`Removing non-flat range`);return e.cut(0,t).append(e.cut(n))}if(r!=o)throw RangeError(`Removing non-flat range`);return e.replaceChild(r,a.copy(Oe(a.content,t-i-1,n-i-1)))}function ke(e,t,n,r,i,a){let{index:o,offset:s}=e.findIndex(t),c=e.maybeChild(o);if(s==t||c.isText)return a&&r<=0&&i<=0&&!a.canReplace(o,o,n)?null:e.cut(0,t).append(n).append(e.cut(t));let l=ke(c.content,t-s-1,n,o==0?r-1:0,o==e.childCount-1?i-1:0,c);return l&&e.replaceChild(o,c.copy(l))}function Ae(e,t,n){if(n.openStart>e.depth)throw new De(`Inserted content deeper than insertion position`);if(e.depth-n.openStart!=t.depth-n.openEnd)throw new De(`Inconsistent open depths`);return je(e,t,n,0)}function je(e,t,n,r){let i=e.index(r),a=e.node(r);if(i==t.index(r)&&r=0&&e.isText&&e.sameMarkup(t[n])?t[n]=e.withText(t[n].text+e.text):t.push(e)}function Fe(e,t,n,r){let i=(t||e).node(n),a=0,o=t?t.index(n):i.childCount;e&&(a=e.index(n),e.depth>n?a++:e.textOffset&&(Pe(e.nodeAfter,r),a++));for(let e=a;ei&&Ne(e,t,i+1),o=r.depth>i&&Ne(n,r,i+1),s=[];return Fe(null,e,i,s),a&&o&&t.index(i)==n.index(i)?(Me(a,o),Pe(Ie(a,Le(e,t,n,r,i+1)),s)):(a&&Pe(Ie(a,Re(e,t,i+1)),s),Fe(t,n,i,s),o&&Pe(Ie(o,Re(n,r,i+1)),s)),Fe(r,null,i,s),new P(s)}function Re(e,t,n){let r=[];return Fe(null,e,n,r),e.depth>n&&Pe(Ie(Ne(e,t,n+1),Re(e,t,n+1)),r),Fe(t,null,n,r),new P(r)}function ze(e,t){let n=t.depth-e.openStart,r=t.node(n).copy(e.content);for(let e=n-1;e>=0;e--)r=t.node(e).copy(P.from(r));return{start:r.resolveNoCache(e.openStart+n),end:r.resolveNoCache(r.content.size-e.openEnd-n)}}var Be=class e{constructor(e,t,n){this.pos=e,this.path=t,this.parentOffset=n,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw RangeError(`There is no position before the top-level node`);return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw RangeError(`There is no position after the top-level node`);return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let n=this.pos-this.path[this.path.length-1],r=e.child(t);return n?e.child(t).cut(n):r}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let n=this.path[t*3],r=t==0?0:this.path[t*3-1]+1;for(let t=0;t0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos=0;n--)if(e.pos<=this.end(n)&&(!t||t(this.node(n))))return new We(this,e,n);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos=0&&n<=t.content.size))throw RangeError(`Position `+n+` out of range`);let r=[],i=0,a=n;for(let e=t;;){let{index:t,offset:n}=e.content.findIndex(a),o=a-n;if(r.push(e,t,i+n),!o||(e=e.child(t),e.isText))break;a=o-1,i+=n+1}return new e(n,r,a)}static resolveCached(t,n){let r=Ue.get(t);if(r)for(let e=0;ee&&this.nodesBetween(e,t,e=>(n.isInSet(e.marks)&&(r=!0),!r)),r}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+=`(`+this.content.toStringInner()+`)`),Ye(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw Error(`Called contentMatchAt on a node with invalid content`);return t}canReplace(e,t,n=P.empty,r=0,i=n.childCount){let a=this.contentMatchAt(e).matchFragment(n,r,i),o=a&&a.matchFragment(this.content,t);if(!o||!o.validEnd)return!1;for(let e=r;ee.type.name)}`);this.content.forEach(e=>e.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(e=>e.toJSON())),e}static fromJSON(e,t){if(!t)throw RangeError(`Invalid input for Node.fromJSON`);let n;if(t.marks){if(!Array.isArray(t.marks))throw RangeError(`Invalid mark data for Node.fromJSON`);n=t.marks.map(e.markFromJSON)}if(t.type==`text`){if(typeof t.text!=`string`)throw RangeError(`Invalid text node in JSON`);return e.text(t.text,n)}let r=P.fromJSON(e,t.content);return e.nodeType(t.type).create(t.attrs,r,n)}};Ke.prototype.text=void 0;var qe=(()=>{let{stack:e}=Error(`/`);if(!e||!/\n\s*at\s/.test(e))return e=>e;let t=Object.create(null);return e=>(t[e],e)})(),Je=class e extends Ke{constructor(e,t,n,r){if(super(e,t,null,r),!n)throw RangeError(`Empty text nodes are not allowed`);this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Ye(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return qe(this.text.slice(e,t))}get nodeSize(){return this.text.length}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.text,t)}withText(t){return t==this.text?this:new e(this.type,this.attrs,t,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(qe(this.text.slice(e,t)))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}};function Ye(e,t){for(let n=e.length-1;n>=0;n--)t=e[n].type.name+`(`+t+`)`;return t}function Xe(e,t,n,r){for(let i in t)if(!(i in e))throw RangeError(`Unsupported attribute ${i} for ${n} of type ${r}`);for(let n in e)e[n].validate&&e[n].validate(t[n])}var Ze=class e{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(t,n){let r=new Qe(t,n);if(r.next==null)return e.empty;let i=$e(r);r.next&&r.err(`Unexpected trailing text`);let a=lt(ot(i));return ut(a,r),a}matchType(e){for(let t=0;te.createAndFill()));for(let e=0;e=this.next.length)throw RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(n){e.push(n);for(let r=0;r{let r=n+(t.validEnd?`*`:` `)+` `;for(let n=0;n`+e.indexOf(t.next[n].next);return r}).join(` +`)}};Ze.empty=new Ze(!0);var Qe=class{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==``&&this.tokens.pop(),this.tokens[0]==``&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw SyntaxError(e+` (in content expression '`+this.string+`')`)}};function $e(e){let t=[];do t.push(et(e));while(e.eat(`|`));return t.length==1?t[0]:{type:`choice`,exprs:t}}function et(e){let t=[];do t.push(tt(e));while(e.next&&e.next!=`)`&&e.next!=`|`);return t.length==1?t[0]:{type:`seq`,exprs:t}}function tt(e){let t=at(e);for(;;)if(e.eat(`+`))t={type:`plus`,expr:t};else if(e.eat(`*`))t={type:`star`,expr:t};else if(e.eat(`?`))t={type:`opt`,expr:t};else if(e.eat(`{`))t=rt(e,t);else break;return t}function nt(e){/\D/.test(e.next)&&e.err(`Expected number, got '`+e.next+`'`);let t=Number(e.next);return e.pos++,t}function rt(e,t){let n=nt(e),r=n;return e.eat(`,`)&&(r=e.next==`}`?-1:nt(e)),e.eat(`}`)||e.err(`Unclosed braced range`),{type:`range`,min:n,max:r,expr:t}}function it(e,t){let n=e.nodeTypes,r=n[t];if(r)return[r];let i=[];for(let e in n){let r=n[e];r.isInGroup(t)&&i.push(r)}return i.length==0&&e.err(`No node type or group '`+t+`' found`),i}function at(e){if(e.eat(`(`)){let t=$e(e);return e.eat(`)`)||e.err(`Missing closing paren`),t}if(/\W/.test(e.next))e.err(`Unexpected token '`+e.next+`'`);else{let t=it(e,e.next).map(t=>(e.inline==null?e.inline=t.isInline:e.inline!=t.isInline&&e.err(`Mixing inline and block content`),{type:`name`,value:t}));return e.pos++,t.length==1?t[0]:{type:`choice`,exprs:t}}}function ot(e){let t=[[]];return i(a(e,0),n()),t;function n(){return t.push([])-1}function r(e,n,r){let i={term:r,to:n};return t[e].push(i),i}function i(e,t){e.forEach(e=>e.to=t)}function a(e,t){if(e.type==`choice`)return e.exprs.reduce((e,n)=>e.concat(a(n,t)),[]);if(e.type==`seq`)for(let r=0;;r++){let o=a(e.exprs[r],t);if(r==e.exprs.length-1)return o;i(o,t=n())}else if(e.type==`star`){let o=n();return r(t,o),i(a(e.expr,o),o),[r(o)]}else if(e.type==`plus`){let o=n();return i(a(e.expr,t),o),i(a(e.expr,o),o),[r(o)]}else if(e.type==`opt`)return[r(t)].concat(a(e.expr,t));else if(e.type==`range`){let o=t;for(let t=0;t{e[t].forEach(({term:t,to:n})=>{if(!t)return;let r;for(let e=0;e{r||i.push([t,r=[]]),r.indexOf(e)==-1&&r.push(e)})})});let a=t[r.join(`,`)]=new Ze(r.indexOf(e.length-1)>-1);for(let e=0;e-1}get whitespace(){return this.spec.whitespace||(this.spec.code?`pre`:`normal`)}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:ft(this.attrs,e)}create(e=null,t,n){if(this.isText)throw Error(`NodeType.create can't construct text nodes`);return new Ke(this,this.computeAttrs(e),P.from(t),F.setFrom(n))}createChecked(e=null,t,n){return t=P.from(t),this.checkContent(t),new Ke(this,this.computeAttrs(e),t,F.setFrom(n))}createAndFill(e=null,t,n){if(e=this.computeAttrs(e),t=P.from(t),t.size){let e=this.contentMatch.fillBefore(t);if(!e)return null;t=e.append(t)}let r=this.contentMatch.matchFragment(t),i=r&&r.fillBefore(P.empty,!0);return i?new Ke(this,e,t.append(i),F.setFrom(n)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let t=0;t-1}allowsMarks(e){if(this.markSet==null)return!0;for(let t=0;tr[t]=new e(t,n,i));let i=n.spec.topNode||`doc`;if(!r[i])throw RangeError(`Schema is missing its top node type ('`+i+`')`);if(!r.text)throw RangeError(`Every schema needs a 'text' type`);for(let e in r.text.attrs)throw RangeError(`The text node type should not have attributes`);return r}};function ht(e,t,n){let r=n.split(`|`);return n=>{let i=n===null?`null`:typeof n;if(r.indexOf(i)<0)throw RangeError(`Expected value of type ${r} for attribute ${t} on type ${e}, got ${i}`)}}var gt=class{constructor(e,t,n){this.hasDefault=Object.prototype.hasOwnProperty.call(n,`default`),this.default=n.default,this.validate=typeof n.validate==`string`?ht(e,t,n.validate):n.validate}get isRequired(){return!this.hasDefault}},_t=class e{constructor(e,t,n,r){this.name=e,this.rank=t,this.schema=n,this.spec=r,this.attrs=pt(e,r.attrs),this.excluded=null;let i=dt(this.attrs);this.instance=i?new F(this,i):null}create(e=null){return!e&&this.instance?this.instance:new F(this,ft(this.attrs,e))}static compile(t,n){let r=Object.create(null),i=0;return t.forEach((t,a)=>r[t]=new e(t,i++,n,a)),r}removeFromSet(e){for(var t=0;t-1}},vt=class{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let n in e)t[n]=e[n];t.nodes=ye.from(e.nodes),t.marks=ye.from(e.marks||{}),this.nodes=mt.compile(this.spec.nodes,this),this.marks=_t.compile(this.spec.marks,this);let n=Object.create(null);for(let e in this.nodes){if(e in this.marks)throw RangeError(e+` can not be both a node and a mark`);let t=this.nodes[e],r=t.spec.content||``,i=t.spec.marks;if(t.contentMatch=n[r]||(n[r]=Ze.parse(r,this.nodes)),t.inlineContent=t.contentMatch.inlineContent,t.spec.linebreakReplacement){if(this.linebreakReplacement)throw RangeError(`Multiple linebreak nodes defined`);if(!t.isInline||!t.isLeaf)throw RangeError(`Linebreak replacement nodes must be inline leaf nodes`);this.linebreakReplacement=t}t.markSet=i==`_`?null:i?yt(this,i.split(` `)):i==``||!t.inlineContent?[]:null}for(let e in this.marks){let t=this.marks[e],n=t.spec.excludes;t.excluded=n==null?[t]:n==``?[]:yt(this,n.split(` `))}this.nodeFromJSON=e=>Ke.fromJSON(this,e),this.markFromJSON=e=>F.fromJSON(this,e),this.topNodeType=this.nodes[this.spec.topNode||`doc`],this.cached.wrappings=Object.create(null)}node(e,t=null,n,r){if(typeof e==`string`)e=this.nodeType(e);else if(!(e instanceof mt))throw RangeError(`Invalid node type: `+e);else if(e.schema!=this)throw RangeError(`Node type from different schema used (`+e.name+`)`);return e.createChecked(t,n,r)}text(e,t){let n=this.nodes.text;return new Je(n,n.defaultAttrs,e,F.setFrom(t))}mark(e,t){return typeof e==`string`&&(e=this.marks[e]),e.create(t)}nodeType(e){let t=this.nodes[e];if(!t)throw RangeError(`Unknown node type: `+e);return t}};function yt(e,t){let n=[];for(let r=0;r-1)&&n.push(o=r)}if(!o)throw SyntaxError(`Unknown mark type: '`+t[r]+`'`)}return n}function bt(e){return e.tag!=null}function xt(e){return e.style!=null}var St=class e{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let n=this.matchedStyles=[];t.forEach(e=>{if(bt(e))this.tags.push(e);else if(xt(e)){let t=/[^=]*/.exec(e.style)[0];n.indexOf(t)<0&&n.push(t),this.styles.push(e)}}),this.normalizeLists=!this.tags.some(t=>{if(!/^(ul|ol)\b/.test(t.tag)||!t.node)return!1;let n=e.nodes[t.node];return n.contentMatch.matchType(n)})}parse(e,t={}){let n=new jt(this,t,!1);return n.addAll(e,F.none,t.from,t.to),n.finish()}parseSlice(e,t={}){let n=new jt(this,t,!0);return n.addAll(e,F.none,t.from,t.to),I.maxOpen(n.finish())}matchTag(e,t,n){for(let r=n?this.tags.indexOf(n)+1:0;re.length&&(a.charCodeAt(e.length)!=61||a.slice(e.length+1)!=t))){if(r.getAttrs){let e=r.getAttrs(t);if(e===!1)continue;r.attrs=e||void 0}return r}}}static schemaRules(e){let t=[];function n(e){let n=e.priority==null?50:e.priority,r=0;for(;r{n(e=Pt(e)),e.mark||e.ignore||e.clearMark||(e.mark=t)})}for(let t in e.nodes){let r=e.nodes[t].spec.parseDOM;r&&r.forEach(e=>{n(e=Pt(e)),e.node||e.ignore||e.mark||(e.node=t)})}return t}static fromSchema(t){return t.cached.domParser||(t.cached.domParser=new e(t,e.schemaRules(t)))}},Ct={address:!0,article:!0,aside:!0,blockquote:!0,body:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},wt={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Tt={ol:!0,ul:!0},Et=1,Dt=2,Ot=4;function kt(e,t,n){return t==null?e&&e.whitespace==`pre`?3:n&-5:(t?Et:0)|(t===`full`?Dt:0)}var At=class{constructor(e,t,n,r,i,a){this.type=e,this.attrs=t,this.marks=n,this.solid=r,this.options=a,this.content=[],this.activeMarks=F.none,this.match=i||(a&Ot?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(P.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let t=this.type.contentMatch,n;return(n=t.findWrapping(e.type))?(this.match=t,n):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&Et)){let e=this.content[this.content.length-1],t;if(e&&e.isText&&(t=/[ \t\r\n\u000c]+$/.exec(e.text))){let n=e;e.text.length==t[0].length?this.content.pop():this.content[this.content.length-1]=n.withText(n.text.slice(0,n.text.length-t[0].length))}}let t=P.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(P.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!Ct.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}},jt=class{constructor(e,t,n){this.parser=e,this.options=t,this.isOpen=n,this.open=0,this.localPreserveWS=!1;let r=t.topNode,i,a=kt(null,t.preserveWhitespace,0)|(n?Ot:0);i=r?new At(r.type,r.attrs,F.none,!0,t.topMatch||r.type.contentMatch,a):n?new At(null,null,F.none,!0,null,a):new At(e.schema.topNodeType,null,F.none,!0,null,a),this.nodes=[i],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let n=e.nodeValue,r=this.top,i=r.options&Dt?`full`:this.localPreserveWS||(r.options&Et)>0,{schema:a}=this.parser;if(i===`full`||r.inlineContext(e)||/[^ \t\r\n\u000c]/.test(n)){if(!i){if(n=n.replace(/[ \t\r\n\u000c]+/g,` `),/^[ \t\r\n\u000c]/.test(n)&&this.open==this.nodes.length-1){let t=r.content[r.content.length-1],i=e.previousSibling;(!t||i&&i.nodeName==`BR`||t.isText&&/[ \t\r\n\u000c]$/.test(t.text))&&(n=n.slice(1))}}else if(i===`full`)n=n.replace(/\r\n?/g,` +`);else if(a.linebreakReplacement&&/[\r\n]/.test(n)&&this.top.findWrapping(a.linebreakReplacement.create())){let e=n.split(/\r?\n|\r/);for(let n=0;n!n.clearMark(e)):t.concat(this.parser.schema.marks[n.mark].create(n.attrs)),n.consuming===!1)e=n;else break}}return t}addElementByRule(e,t,n,r){let i,a;if(t.node){if(a=this.parser.schema.nodes[t.node],a.isLeaf)this.insertNode(a.create(t.attrs),n,e.nodeName==`BR`)||this.leafFallback(e,n);else{let e=this.enter(a,t.attrs||null,n,t.preserveWhitespace);e&&(i=!0,n=e)}}else{let e=this.parser.schema.marks[t.mark];n=n.concat(e.create(t.attrs))}let o=this.top;if(a&&a.isLeaf)this.findInside(e);else if(r)this.addElement(e,n,r);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(e=>this.insertNode(e,n,!1));else{let r=e;typeof t.contentElement==`string`?r=e.querySelector(t.contentElement):typeof t.contentElement==`function`?r=t.contentElement(e):t.contentElement&&(r=t.contentElement),this.findAround(e,r,!0),this.addAll(r,n),this.findAround(e,r,!1)}i&&this.sync(o)&&this.open--}addAll(e,t,n,r){let i=n||0;for(let a=n?e.childNodes[n]:e.firstChild,o=r==null?null:e.childNodes[r];a!=o;a=a.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(a,t);this.findAtPoint(e,i)}findPlace(e,t,n){let r,i;for(let t=this.open,a=0;t>=0;t--){let o=this.nodes[t],s=o.findWrapping(e);if(s&&(!r||r.length>s.length+a)&&(r=s,i=o,!s.length))break;if(o.solid){if(n)break;a+=2}}if(!r)return null;this.sync(i);for(let e=0;e!(a.type?a.type.allowsMarkType(t.type):Ft(t.type,e))||(s=t.addToSet(s),!1)),this.nodes.push(new At(e,t,s,r,null,o)),this.open++,n}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--)if(this.nodes[t]==e)return this.open=t,!0;else this.localPreserveWS&&(this.nodes[t].options|=Et);return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let n=this.nodes[t].content;for(let t=n.length-1;t>=0;t--)e+=n[t].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let n=0;n-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split(`/`),n=this.options.context,r=!this.isOpen&&(!n||n.parent.type==this.nodes[0].type),i=-(n?n.depth+1:0)+ +!r,a=(e,o)=>{for(;e>=0;e--){let s=t[e];if(s==``){if(e==t.length-1||e==0)continue;for(;o>=i;o--)if(a(e-1,o))return!0;return!1}{let e=o>0||o==0&&r?this.nodes[o].type:n&&o>=i?n.node(o-i).type:null;if(!e||e.name!=s&&!e.isInGroup(s))return!1;o--}}return!0};return a(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let n=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(let e in this.parser.schema.nodes){let t=this.parser.schema.nodes[e];if(t.isTextblock&&t.defaultAttrs)return t}}};function Mt(e){for(let t=e.firstChild,n=null;t;t=t.nextSibling){let e=t.nodeType==1?t.nodeName.toLowerCase():null;e&&Tt.hasOwnProperty(e)&&n?(n.appendChild(t),t=n):e==`li`?n=t:e&&(n=null)}}function Nt(e,t){return(e.matches||e.msMatchesSelector||e.webkitMatchesSelector||e.mozMatchesSelector).call(e,t)}function Pt(e){let t={};for(let n in e)t[n]=e[n];return t}function Ft(e,t){let n=t.schema.nodes;for(let r in n){let i=n[r];if(!i.allowsMarkType(e))continue;let a=[],o=e=>{a.push(e);for(let n=0;n{if(i.length||e.marks.length){let n=0,a=0;for(;n=0;r--){let i=this.serializeMark(e.marks[r],e.isInline,t);i&&((i.contentDOM||i.dom).appendChild(n),n=i.dom)}return n}serializeMark(e,t,n={}){let r=this.marks[e.type.name];return r&&Ht(Rt(n),r(e,t),null,e.attrs)}static renderSpec(e,t,n=null,r){return typeof t==`string`?{dom:e.createTextNode(t)}:Ht(e,t,n,r)}static fromSchema(t){return t.cached.domSerializer||(t.cached.domSerializer=new e(this.nodesFromSchema(t),this.marksFromSchema(t)))}static nodesFromSchema(e){let t=Lt(e.nodes);return t.text||=e=>e.text,t}static marksFromSchema(e){return Lt(e.marks)}};function Lt(e){let t={};for(let n in e){let r=e[n].spec.toDOM;r&&(t[n]=r)}return t}function Rt(e){return e.document||window.document}var zt=new WeakMap;function Bt(e){let t=zt.get(e);return t===void 0&&zt.set(e,t=Vt(e)),t}function Vt(e){let t=null;function n(e){if(e&&typeof e==`object`){if(Array.isArray(e)){if(typeof e[0]==`string`)t||=[],t.push(e);else for(let t=0;t-1)throw RangeError(`Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.`);let o=i.indexOf(` `);o>0&&(n=i.slice(0,o),i=i.slice(o+1));let s,c=n?e.createElementNS(n,i):e.createElement(i),l=t[1],u=1;if(l&&typeof l==`object`&&l.nodeType==null&&!Array.isArray(l)){u=2;for(let e in l)if(l[e]!=null){let t=e.indexOf(` `);t>0?c.setAttributeNS(e.slice(0,t),e.slice(t+1),l[e]):e==`style`&&c.style?c.style.cssText=l[e]:c.setAttribute(e,l[e])}}for(let i=u;iu)throw RangeError(`Content hole must be the only child of its parent node`);return{dom:c,contentDOM:c}}if(typeof a==`string`)c.appendChild(e.createTextNode(a));else{let{dom:t,contentDOM:i}=Ht(e,a,n,r);if(c.appendChild(t),i){if(s)throw RangeError(`Multiple content holes`);s=i}}}return{dom:c,contentDOM:s}}var Ut=65535,Wt=2**16;function Gt(e,t){return e+t*Wt}function Kt(e){return e&Ut}function qt(e){return(e-(e&Ut))/Wt}var Jt=1,Yt=2,Xt=4,Zt=8,Qt=class{constructor(e,t,n){this.pos=e,this.delInfo=t,this.recover=n}get deleted(){return(this.delInfo&Zt)>0}get deletedBefore(){return(this.delInfo&5)>0}get deletedAfter(){return(this.delInfo&6)>0}get deletedAcross(){return(this.delInfo&Xt)>0}},$t=class e{constructor(t,n=!1){if(this.ranges=t,this.inverted=n,!t.length&&e.empty)return e.empty}recover(e){let t=0,n=Kt(e);if(!this.inverted)for(let e=0;ee)break;let c=this.ranges[o+i],l=this.ranges[o+a],u=s+c;if(e<=u){let i=c?e==s?-1:e==u?1:t:t,a=s+r+(i<0?0:l);if(n)return a;let d=e==(t<0?s:u)?null:Gt(o/3,e-s),f=0;return c&&(f|=e==s?Yt:e==u?Jt:Xt,(t<0?e!=s:e!=u)&&(f|=Zt)),new Qt(a,f,d)}r+=l-c}return n?e+r:new Qt(e+r,0,null)}touches(e,t){let n=0,r=Kt(t),i=this.inverted?2:1,a=this.inverted?1:2;for(let t=0;te)break;let s=this.ranges[t+i];if(e<=o+s&&t==r*3)return!0;n+=this.ranges[t+a]-s}return!1}forEach(e){let t=this.inverted?2:1,n=this.inverted?1:2;for(let r=0,i=0;r=0;t--){let r=e.getMirror(t);this.appendMap(e._maps[t].invert(),r!=null&&r>t?n-r-1:void 0)}}invert(){let t=new e;return t.appendMappingInverted(this),t}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let n=this.from;nn&&t!e.isAtom||!t.type.allowsMarkType(this.mark.type)?e:e.mark(this.mark.addToSet(e.marks)),r),t.openStart,t.openEnd);return rn.fromReplace(e,this.from,this.to,i)}invert(t){let n=[];return t.nodesBetween(this.from,this.to,(t,r)=>{if(t.isInline&&t.isAtom){let i=this.mark.addToSet(t.marks);if(!F.sameSet(i,t.marks)){let a=Math.max(this.from,r),o=Math.min(this.to,r+t.nodeSize);cn(sn,a,o,this.mark,n);for(let r of t.marks)r.isInSet(i)||cn(e,a,o,r,n)}}}),n.length==1?n[0]:new ln(n)}map(t){let n=t.map(this.from,1),r=t.map(this.to,-1);return n>=r?null:new e(n,r,this.mark)}merge(t){return t instanceof e&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new e(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:`addMark`,mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for AddMarkStep.fromJSON`);return new e(n.from,n.to,t.markFromJSON(n.mark))}};nn.jsonID(`addMark`,on);var sn=class e extends nn{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=new I(an(t.content,e=>e.mark(this.mark.removeFromSet(e.marks)),e),t.openStart,t.openEnd);return rn.fromReplace(e,this.from,this.to,n)}invert(e){let t=[];return e.nodesBetween(this.from,this.to,(e,n)=>{e.isInline&&e.isAtom&&this.mark.isInSet(e.marks)&&cn(on,Math.max(this.from,n),Math.min(this.to,n+e.nodeSize),this.mark,t)}),t.length==1?t[0]:new ln(t)}map(t){let n=t.map(this.from,1),r=t.map(this.to,-1);return n>=r?null:new e(n,r,this.mark)}merge(t){return t instanceof e&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new e(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:`removeMark`,mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for RemoveMarkStep.fromJSON`);return new e(n.from,n.to,t.markFromJSON(n.mark))}};nn.jsonID(`removeMark`,sn);function cn(e,t,n,r,i){let a=i.length?i[i.length-1]:null;a&&a instanceof e&&a.to==t&&a.mark.eq(r)?i[i.length-1]=new e(a.from,n,r):i.push(new e(t,n,r))}var ln=class e extends nn{constructor(e){super(),this.steps=e}apply(e){for(let t of this.steps){let n=t.apply(e);if(!n.doc)return n;e=n.doc}return new rn(e,null)}invert(t){return new e(this.steps.map(e=>e.invert(t)))}map(t){let n=[];for(let e of this.steps){let r=e.map(t);r&&n.push(r)}return n.length?new e(n):null}toJSON(){return{stepType:`markSet`,steps:this.steps.map(e=>e.toJSON())}}static fromJSON(t,n){if(!Array.isArray(n.steps)||!n.steps.every(e=>e.stepType==`addMark`||e.stepType==`removeMark`))throw RangeError(`Invalid JSON for MarkSetStep`);return new e(n.steps.map(e=>nn.fromJSON(t,e)))}};nn.jsonID(`markSet`,ln);var un=class e extends nn{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return rn.fail(`No node at mark step's position`);let n=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return rn.fromReplace(e,this.pos,this.pos+1,new I(P.from(n),0,+!t.isLeaf))}invert(t){let n=t.nodeAt(this.pos);if(n){let t=this.mark.addToSet(n.marks);if(t.length==n.marks.length){for(let r=0;rr.pos||i>a?null:new e(n.pos,r.pos,i,a,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:`replaceAround`,from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`||typeof n.gapFrom!=`number`||typeof n.gapTo!=`number`||typeof n.insert!=`number`)throw RangeError(`Invalid input for ReplaceAroundStep.fromJSON`);return new e(n.from,n.to,n.gapFrom,n.gapTo,I.fromJSON(t,n.slice),n.insert,!!n.structure)}};nn.jsonID(`replaceAround`,pn);function mn(e,t,n){let r=e.resolve(t),i=n-t,a=r.depth;for(;i>0&&a>0&&r.indexAfter(a)==r.node(a).childCount;)a--,i--;if(i>0){let e=r.node(a).maybeChild(r.indexAfter(a));for(;i>0;){if(!e||e.isLeaf)return!0;e=e.firstChild,i--}}return!1}function hn(e,t,n,r){let i=[];e.doc.nodesBetween(t,n,(e,a,o)=>{if(!e.isInline)return;let s=e.marks;!r.isInSet(s)&&o.type.allowsMarkType(r.type)&&cn(on,Math.max(a,t),Math.min(a+e.nodeSize,n),r,i)}),i.forEach(t=>e.step(t))}function gn(e,t,n,r){let i=[],a=0;e.doc.nodesBetween(t,n,(e,o)=>{if(!e.isInline||!e.isAtom)return;a++;let s=null;if(r instanceof _t){let t=e.marks,n;for(;n=r.isInSet(t);)(s||=[]).push(n),t=n.removeFromSet(t)}else r?r.isInSet(e.marks)&&(s=[r]):s=e.marks;if(s&&s.length){let r=Math.min(o+e.nodeSize,n);for(let e=0;ee.step(new sn(t.from,t.to,t.style)))}function _n(e,t,n,r=n.contentMatch,i=!0){let a=e.doc.nodeAt(t),o=[],s=t+1;for(let t=0;t=0;t--)e.step(o[t])}function vn(e,t,n){return(t==0||e.canReplace(t,e.childCount))&&(n==e.childCount||e.canReplace(0,n))}function yn(e){let t=e.parent.content.cutByIndex(e.startIndex,e.endIndex);for(let n=e.depth,r=0,i=0;;--n){let a=e.$from.node(n),o=e.$from.index(n)+r,s=e.$to.indexAfter(n)-i;if(nn;e--)t||r.index(e)>0?(t=!0,u=P.from(r.node(e).copy(u)),d++):c--;let f=P.empty,p=0;for(let e=a,t=!1;e>n;e--)t||i.after(e+1)=0;e--){if(r.size){let t=n[e].type.contentMatch.matchFragment(r);if(!t||!t.validEnd)throw RangeError(`Wrapper type given to Transform.wrap does not form valid content of its parent wrapper`)}r=P.from(n[e].type.create(n[e].attrs,r))}let i=t.start,a=t.end;e.step(new pn(i,a,i,a,new I(r,0,0),n.length,!0))}function En(e,t,n,r,i){if(!r.isTextblock)throw RangeError(`Type given to setBlockType should be a textblock`);let a=e.steps.length;e.doc.nodesBetween(t,n,(t,n)=>{let o=typeof i==`function`?i(t):i;if(t.isTextblock&&!t.hasMarkup(r,o)&&kn(e.doc,e.mapping.slice(a).map(n),r)){let i=null;if(r.schema.linebreakReplacement){let e=r.whitespace==`pre`,t=!!r.contentMatch.matchType(r.schema.linebreakReplacement);e&&!t?i=!1:!e&&t&&(i=!0)}i===!1&&On(e,t,n,a),_n(e,e.mapping.slice(a).map(n,1),r,void 0,i===null);let s=e.mapping.slice(a),c=s.map(n,1),l=s.map(n+t.nodeSize,1);return e.step(new pn(c,l,c+1,l-1,new I(P.from(r.create(o,null,t.marks)),0,0),1,!0)),i===!0&&Dn(e,t,n,a),!1}})}function Dn(e,t,n,r){t.forEach((i,a)=>{if(i.isText){let o,s=/\r?\n|\r/g;for(;o=s.exec(i.text);){let i=e.mapping.slice(r).map(n+1+a+o.index);e.replaceWith(i,i+1,t.type.schema.linebreakReplacement.create())}}})}function On(e,t,n,r){t.forEach((i,a)=>{if(i.type==i.type.schema.linebreakReplacement){let i=e.mapping.slice(r).map(n+1+a);e.replaceWith(i,i+1,t.type.schema.text(` +`))}})}function kn(e,t,n){let r=e.resolve(t),i=r.index();return r.parent.canReplaceWith(i,i+1,n)}function An(e,t,n,r,i){let a=e.doc.nodeAt(t);if(!a)throw RangeError(`No node at given position`);n||=a.type;let o=n.create(r,null,i||a.marks);if(a.isLeaf)return e.replaceWith(t,t+a.nodeSize,o);if(!n.validContent(a.content))throw RangeError(`Invalid content for node type `+n.name);e.step(new pn(t,t+a.nodeSize,t+1,t+a.nodeSize-1,new I(P.from(o),0,0),1,!0))}function jn(e,t,n=1,r){let i=e.resolve(t),a=i.depth-n,o=r&&r[r.length-1]||i.parent;if(a<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!o.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let e=i.depth-1,t=n-2;e>a;e--,t--){let n=i.node(e),a=i.index(e);if(n.type.spec.isolating)return!1;let o=n.content.cutByIndex(a,n.childCount),s=r&&r[t+1];s&&(o=o.replaceChild(0,s.type.create(s.attrs)));let c=r&&r[t]||n;if(!n.canReplace(a+1,n.childCount)||!c.type.validContent(o))return!1}let s=i.indexAfter(a),c=r&&r[0];return i.node(a).canReplaceWith(s,s,c?c.type:i.node(a+1).type)}function Mn(e,t,n=1,r){let i=e.doc.resolve(t),a=P.empty,o=P.empty;for(let e=i.depth,t=i.depth-n,s=n-1;e>t;e--,s--){a=P.from(i.node(e).copy(a));let t=r&&r[s];o=P.from(t?t.type.create(t.attrs,o):i.node(e).copy(o))}e.step(new fn(t,t,new I(a.append(o),n,n),!0))}function Nn(e,t){let n=e.resolve(t),r=n.index();return Fn(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function Pn(e,t){t.content.size||e.type.compatibleContent(t.type);let n=e.contentMatchAt(e.childCount),{linebreakReplacement:r}=e.type.schema;for(let i=0;i0?(i=r.node(e+1),o++,a=r.node(e).maybeChild(o)):(i=r.node(e).maybeChild(o-1),a=r.node(e+1)),i&&!i.isTextblock&&Fn(i,a)&&r.node(e).canReplace(o,o+1))return t;if(e==0)break;t=n<0?r.before(e):r.after(e)}}function Ln(e,t,n){let r=null,{linebreakReplacement:i}=e.doc.type.schema,a=e.doc.resolve(t-n),o=a.node().type;if(i&&o.inlineContent){let e=o.whitespace==`pre`,t=!!o.contentMatch.matchType(i);e&&!t?r=!1:!e&&t&&(r=!0)}let s=e.steps.length;if(r===!1){let r=e.doc.resolve(t+n);On(e,r.node(),r.before(),s)}o.inlineContent&&_n(e,t+n-1,o,a.node().contentMatchAt(a.index()),r==null);let c=e.mapping.slice(s),l=c.map(t-n);if(e.step(new fn(l,c.map(t+n,-1),I.empty,!0)),r===!0){let t=e.doc.resolve(l);Dn(e,t.node(),t.before(),e.steps.length)}return e}function Rn(e,t,n){let r=e.resolve(t);if(r.parent.canReplaceWith(r.index(),r.index(),n))return t;if(r.parentOffset==0)for(let e=r.depth-1;e>=0;e--){let t=r.index(e);if(r.node(e).canReplaceWith(t,t,n))return r.before(e+1);if(t>0)return null}if(r.parentOffset==r.parent.content.size)for(let e=r.depth-1;e>=0;e--){let t=r.indexAfter(e);if(r.node(e).canReplaceWith(t,t,n))return r.after(e+1);if(t=0;t--){let n=t==r.depth?0:r.pos<=(r.start(t+1)+r.end(t+1))/2?-1:1,a=r.index(t)+ +(n>0),o=r.node(t),s=!1;if(e==1)s=o.canReplace(a,a,i);else{let e=o.contentMatchAt(a).findWrapping(i.firstChild.type);s=e&&o.canReplaceWith(a,a,e[0])}if(s)return n==0?r.pos:n<0?r.before(t+1):r.after(t+1)}return null}function Bn(e,t,n=t,r=I.empty){if(t==n&&!r.size)return null;let i=e.resolve(t),a=e.resolve(n);return Vn(i,a,r)?new fn(t,n,r):new Hn(i,a,r).fit()}function Vn(e,t,n){return!n.openStart&&!n.openEnd&&e.start()==t.start()&&e.parent.canReplace(e.index(),t.index(),n.content)}var Hn=class{constructor(e,t,n){this.$from=e,this.$to=t,this.unplaced=n,this.frontier=[],this.placed=P.empty;for(let t=0;t<=e.depth;t++){let n=e.node(t);this.frontier.push({type:n.type,match:n.contentMatchAt(e.indexAfter(t))})}for(let t=e.depth;t>0;t--)this.placed=P.from(e.node(t).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let e=this.findFittable();e?this.placeNodes(e):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,n=this.$from,r=this.close(e<0?this.$to:n.doc.resolve(e));if(!r)return null;let i=this.placed,a=n.depth,o=r.depth;for(;a&&o&&i.childCount==1;)i=i.firstChild.content,a--,o--;let s=new I(i,a,o);return e>-1?new pn(n.pos,e,this.$to.pos,this.$to.end(),s,t):s.size||n.pos!=this.$to.pos?new fn(n.pos,r.pos,s):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,n=0,r=this.unplaced.openEnd;n1&&(r=0),i.type.spec.isolating&&r<=n){e=n;break}t=i.content}for(let t=1;t<=2;t++)for(let n=t==1?e:this.unplaced.openStart;n>=0;n--){let e,r=null;n?(r=Gn(this.unplaced.content,n-1).firstChild,e=r.content):e=this.unplaced.content;let i=e.firstChild;for(let e=this.depth;e>=0;e--){let{type:a,match:o}=this.frontier[e],s,c=null;if(t==1&&(i?o.matchType(i.type)||(c=o.fillBefore(P.from(i),!1)):r&&a.compatibleContent(r.type)))return{sliceDepth:n,frontierDepth:e,parent:r,inject:c};if(t==2&&i&&(s=o.findWrapping(i.type)))return{sliceDepth:n,frontierDepth:e,parent:r,wrap:s};if(r&&o.matchType(r.type))break}}}openMore(){let{content:e,openStart:t,openEnd:n}=this.unplaced;return Xn(e,-1)<=t?!1:(this.unplaced.size>1&&Xn(e,1)>n&&n++,this.unplaced=new I(e,t+1,n),!0)}dropNode(){let{content:e,openStart:t,openEnd:n}=this.unplaced,r=Gn(e,t);if(r.childCount<=1&&t>0){let i=e.size-t<=t+r.size;this.unplaced=new I(Un(e,t-1,1),t-1,i?t-1:n)}else this.unplaced=new I(Un(e,t,1),t,n)}placeNodes({sliceDepth:e,frontierDepth:t,parent:n,inject:r,wrap:i}){for(;this.depth>t;)this.closeFrontierNode();if(i)for(let e=0;e1||s==0||e.content.size)&&(u=t,l.push(Kn(e.mark(d.allowedMarks(e.marks)),c==1?s:0,c==o.childCount?f:-1)))}let p=c==o.childCount;p||(f=-1),this.placed=Wn(this.placed,t,P.from(l)),this.frontier[t].match=u,p&&f<0&&n&&n.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let e=0,t=l[l.length-1];t&&e1&&r==this.$to.end(--n);)++r;return r}findCloseLevel(e){scan:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:n,type:r}=this.frontier[t],i=t=0;n--){let{match:t,type:r}=this.frontier[n],i=qn(e,n,r,t,!0);if(!i||i.childCount)continue scan}return{depth:t,fit:a,move:i?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=Wn(this.placed,t.depth,t.fit)),e=t.move;for(let n=t.depth+1;n<=e.depth;n++){let t=e.node(n),r=t.type.contentMatch.fillBefore(t.content,!0,e.index(n));this.openFrontierNode(t.type,t.attrs,r)}return e}openFrontierNode(e,t=null,n){let r=this.frontier[this.depth];r.match=r.match.matchType(e),this.placed=Wn(this.placed,this.depth,P.from(e.create(t,n))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let e=this.frontier.pop().match.fillBefore(P.empty,!0);e.childCount&&(this.placed=Wn(this.placed,this.frontier.length,e))}};function Un(e,t,n){return t==0?e.cutByIndex(n,e.childCount):e.replaceChild(0,e.firstChild.copy(Un(e.firstChild.content,t-1,n)))}function Wn(e,t,n){return t==0?e.append(n):e.replaceChild(e.childCount-1,e.lastChild.copy(Wn(e.lastChild.content,t-1,n)))}function Gn(e,t){for(let n=0;n1&&(r=r.replaceChild(0,Kn(r.firstChild,t-1,r.childCount==1?n-1:0))),t>0&&(r=e.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(e.type.contentMatch.matchFragment(r).fillBefore(P.empty,!0)))),e.copy(r)}function qn(e,t,n,r,i){let a=e.node(t),o=i?e.indexAfter(t):e.index(t);if(o==a.childCount&&!n.compatibleContent(a.type))return null;let s=r.fillBefore(a.content,!0,o);return s&&!Jn(n,a.content,o)?s:null}function Jn(e,t,n){for(let r=n;r0;e--,t--){let n=i.node(e).type.spec;if(n.defining||n.definingAsContext||n.isolating)break;o.indexOf(e)>-1?s=e:i.before(e)==t&&o.splice(1,0,-e)}let c=o.indexOf(s),l=[],u=r.openStart;for(let e=r.content,t=0;;t++){let n=e.firstChild;if(l.push(n),t==r.openStart)break;e=n.content}for(let e=u-1;e>=0;e--){let t=l[e],n=Yn(t.type);if(n&&!t.sameMarkup(i.node(Math.abs(s)-1)))u=e;else if(n||!t.type.isTextblock)break}for(let t=r.openStart;t>=0;t--){let s=(t+u+1)%(r.openStart+1),d=l[s];if(d)for(let t=0;t=0&&(e.replace(t,n,r),!(e.steps.length>d));s--){let e=o[s];e<0||(t=i.before(e),n=a.after(e))}}function Qn(e,t,n,r,i){if(tr){let t=i.contentMatchAt(0),n=t.fillBefore(e).append(e);e=n.append(t.matchFragment(n).fillBefore(P.empty,!0))}return e}function $n(e,t,n,r){if(!r.isInline&&t==n&&e.doc.resolve(t).parent.content.size){let i=Rn(e.doc,t,r.type);i!=null&&(t=n=i)}e.replaceRange(t,n,new I(P.from(r),0,0))}function er(e,t,n){let r=e.doc.resolve(t),i=e.doc.resolve(n);if(r.parent.isTextblock&&i.parent.isTextblock&&r.start()!=i.start()&&r.parentOffset==0&&i.parentOffset==0){let a=r.sharedDepth(n),o=!1;for(let e=r.depth;e>a;e--)r.node(e).type.spec.isolating&&(o=!0);for(let e=i.depth;e>a;e--)i.node(e).type.spec.isolating&&(o=!0);if(!o){for(let e=r.depth;e>0&&t==r.start(e);e--)t=r.before(e);for(let e=i.depth;e>0&&n==i.start(e);e--)n=i.before(e);r=e.doc.resolve(t),i=e.doc.resolve(n)}}let a=tr(r,i);for(let t=0;t0&&(o||r.node(n-1).canReplace(r.index(n-1),i.indexAfter(n-1))))return e.delete(r.before(n),i.after(n))}for(let a=1;a<=r.depth&&a<=i.depth;a++)if(t-r.start(a)==r.depth-a&&n>r.end(a)&&i.end(a)-n!=i.depth-a&&r.start(a-1)==i.start(a-1)&&r.node(a-1).canReplace(r.index(a-1),i.index(a-1)))return e.delete(r.before(a),n);e.delete(t,n)}function tr(e,t){let n=[],r=Math.min(e.depth,t.depth);for(let i=r;i>=0;i--){let r=e.start(i);if(rt.pos+(t.depth-i)||e.node(i).type.spec.isolating||t.node(i).type.spec.isolating)break;(r==t.start(i)||i==e.depth&&i==t.depth&&e.parent.inlineContent&&t.parent.inlineContent&&i&&t.start(i-1)==r-1)&&n.push(i)}return n}var nr=class e extends nn{constructor(e,t,n){super(),this.pos=e,this.attr=t,this.value=n}apply(e){let t=e.nodeAt(this.pos);if(!t)return rn.fail(`No node at attribute step's position`);let n=Object.create(null);for(let e in t.attrs)n[e]=t.attrs[e];n[this.attr]=this.value;let r=t.type.create(n,null,t.marks);return rn.fromReplace(e,this.pos,this.pos+1,new I(P.from(r),0,+!t.isLeaf))}getMap(){return $t.empty}invert(t){return new e(this.pos,this.attr,t.nodeAt(this.pos).attrs[this.attr])}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new e(n.pos,this.attr,this.value)}toJSON(){return{stepType:`attr`,pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(t,n){if(typeof n.pos!=`number`||typeof n.attr!=`string`)throw RangeError(`Invalid input for AttrStep.fromJSON`);return new e(n.pos,n.attr,n.value)}};nn.jsonID(`attr`,nr);var rr=class e extends nn{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let n in e.attrs)t[n]=e.attrs[n];t[this.attr]=this.value;let n=e.type.create(t,e.content,e.marks);return rn.ok(n)}getMap(){return $t.empty}invert(t){return new e(this.attr,t.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:`docAttr`,attr:this.attr,value:this.value}}static fromJSON(t,n){if(typeof n.attr!=`string`)throw RangeError(`Invalid input for DocAttrStep.fromJSON`);return new e(n.attr,n.value)}};nn.jsonID(`docAttr`,rr);var ir=class extends Error{};ir=function e(t){let n=Error.call(this,t);return n.__proto__=e.prototype,n},ir.prototype=Object.create(Error.prototype),ir.prototype.constructor=ir,ir.prototype.name=`TransformError`;var ar=class{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new en}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new ir(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}changedRange(){let e=1e9,t=-1e9;for(let n=0;n{e=Math.min(e,i),t=Math.max(t,a)})}return e==1e9?null:{from:e,to:t}}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,n=I.empty){let r=Bn(this.doc,e,t,n);return r&&this.step(r),this}replaceWith(e,t,n){return this.replace(e,t,new I(P.from(n),0,0))}delete(e,t){return this.replace(e,t,I.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,n){return Zn(this,e,t,n),this}replaceRangeWith(e,t,n){return $n(this,e,t,n),this}deleteRange(e,t){return er(this,e,t),this}lift(e,t){return bn(this,e,t),this}join(e,t=1){return Ln(this,e,t),this}wrap(e,t){return Tn(this,e,t),this}setBlockType(e,t=e,n,r=null){return En(this,e,t,n,r),this}setNodeMarkup(e,t,n=null,r){return An(this,e,t,n,r),this}setNodeAttribute(e,t,n){return this.step(new nr(e,t,n)),this}setDocAttribute(e,t){return this.step(new rr(e,t)),this}addNodeMark(e,t){return this.step(new un(e,t)),this}removeNodeMark(e,t){let n=this.doc.nodeAt(e);if(!n)throw RangeError(`No node at position `+e);if(t instanceof F)t.isInSet(n.marks)&&this.step(new dn(e,t));else{let r=n.marks,i,a=[];for(;i=t.isInSet(r);)a.push(new dn(e,i)),r=i.removeFromSet(r);for(let e=a.length-1;e>=0;e--)this.step(a[e])}return this}split(e,t=1,n){return Mn(this,e,t,n),this}addMark(e,t,n){return hn(this,e,t,n),this}removeMark(e,t,n){return gn(this,e,t,n),this}clearIncompatible(e,t,n){return _n(this,e,t,n),this}},or=Object.create(null),L=class{constructor(e,t,n){this.$anchor=e,this.$head=t,this.ranges=n||[new sr(e.min(t),e.max(t))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let t=0;t=0;r--){let i=t<0?mr(e.node(0),e.node(r),e.before(r+1),e.index(r),t,n):mr(e.node(0),e.node(r),e.after(r+1),e.index(r)+1,t,n);if(i)return i}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new fr(e.node(0))}static atStart(e){return mr(e,e,0,0,1)||new fr(e)}static atEnd(e){return mr(e,e,e.content.size,e.childCount,-1)||new fr(e)}static fromJSON(e,t){if(!t||!t.type)throw RangeError(`Invalid input for Selection.fromJSON`);let n=or[t.type];if(!n)throw RangeError(`No selection type ${t.type} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in or)throw RangeError(`Duplicate use of selection JSON ID `+e);return or[e]=t,t.prototype.jsonID=e,t}getBookmark(){return R.between(this.$anchor,this.$head).getBookmark()}};L.prototype.visible=!0;var sr=class{constructor(e,t){this.$from=e,this.$to=t}},cr=!1;function lr(e){!cr&&!e.parent.inlineContent&&(cr=!0,console.warn(`TextSelection endpoint not pointing into a node with inline content (`+e.parent.type.name+`)`))}var R=class e extends L{constructor(e,t=e){lr(e),lr(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(t,n){let r=t.resolve(n.map(this.head));if(!r.parent.inlineContent)return L.near(r);let i=t.resolve(n.map(this.anchor));return new e(i.parent.inlineContent?i:r,r)}replace(e,t=I.empty){if(super.replace(e,t),t==I.empty){let t=this.$from.marksAcross(this.$to);t&&e.ensureMarks(t)}}eq(t){return t instanceof e&&t.anchor==this.anchor&&t.head==this.head}getBookmark(){return new ur(this.anchor,this.head)}toJSON(){return{type:`text`,anchor:this.anchor,head:this.head}}static fromJSON(t,n){if(typeof n.anchor!=`number`||typeof n.head!=`number`)throw RangeError(`Invalid input for TextSelection.fromJSON`);return new e(t.resolve(n.anchor),t.resolve(n.head))}static create(e,t,n=t){let r=e.resolve(t);return new this(r,n==t?r:e.resolve(n))}static between(t,n,r){let i=t.pos-n.pos;if((!r||i)&&(r=i>=0?1:-1),!n.parent.inlineContent){let e=L.findFrom(n,r,!0)||L.findFrom(n,-r,!0);if(e)n=e.$head;else return L.near(n,r)}return t.parent.inlineContent||(i==0?t=n:(t=(L.findFrom(t,-r,!0)||L.findFrom(t,r,!0)).$anchor,t.pos0?0:1);i>0?o=0;o+=i){let r=t.child(o);if(!r.isAtom){let t=mr(e,r,n+i,i<0?r.childCount:0,i,a);if(t)return t}else if(!a&&z.isSelectable(r))return z.create(e,n-(i<0?r.nodeSize:0));n+=r.nodeSize*i}return null}function hr(e,t,n){let r=e.steps.length-1;if(r{o??=r}),e.setSelection(L.near(e.doc.resolve(o),n))}var gr=1,_r=2,vr=4,yr=class extends ar{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor0}setStoredMarks(e){return this.storedMarks=e,this.updated|=_r,this}ensureMarks(e){return F.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&_r)>0}addStep(e,t){super.addStep(e,t),this.updated&=-3,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let n=this.selection;return t&&(e=e.mark(this.storedMarks||(n.empty?n.$from.marks():n.$from.marksAcross(n.$to)||F.none))),n.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,n){let r=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(r.text(e),!0):this.deleteSelection();{if(n??=t,!e)return this.deleteRange(t,n);let i=this.storedMarks;if(!i){let e=this.doc.resolve(t);i=n==t?e.marks():e.marksAcross(this.doc.resolve(n))}return this.replaceRangeWith(t,n,r.text(e,i)),!this.selection.empty&&this.selection.to==t+e.length&&this.setSelection(L.near(this.selection.$to)),this}}setMeta(e,t){return this.meta[typeof e==`string`?e:e.key]=t,this}getMeta(e){return this.meta[typeof e==`string`?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=vr,this}get scrolledIntoView(){return(this.updated&vr)>0}};function br(e,t){return!t||!e?e:e.bind(t)}var xr=class{constructor(e,t,n){this.name=e,this.init=br(t.init,n),this.apply=br(t.apply,n)}},Sr=[new xr(`doc`,{init(e){return e.doc||e.schema.topNodeType.createAndFill()},apply(e){return e.doc}}),new xr(`selection`,{init(e,t){return e.selection||L.atStart(t.doc)},apply(e){return e.selection}}),new xr(`storedMarks`,{init(e){return e.storedMarks||null},apply(e,t,n,r){return r.selection.$cursor?e.storedMarks:null}}),new xr(`scrollToSelection`,{init(){return 0},apply(e,t){return e.scrolledIntoView?t+1:t}})],Cr=class{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=Sr.slice(),t&&t.forEach(e=>{if(this.pluginsByKey[e.key])throw RangeError(`Adding different instances of a keyed plugin (`+e.key+`)`);this.plugins.push(e),this.pluginsByKey[e.key]=e,e.spec.state&&this.fields.push(new xr(e.key,e.spec.state,e))})}},wr=class e{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,t=-1){for(let n=0;ne.toJSON())),e&&typeof e==`object`)for(let n in e){if(n==`doc`||n==`selection`)throw RangeError("The JSON fields `doc` and `selection` are reserved");let r=e[n],i=r.spec.state;i&&i.toJSON&&(t[n]=i.toJSON.call(r,this[r.key]))}return t}static fromJSON(t,n,r){if(!n)throw RangeError(`Invalid input for EditorState.fromJSON`);if(!t.schema)throw RangeError(`Required config field 'schema' missing`);let i=new Cr(t.schema,t.plugins),a=new e(i);return i.fields.forEach(e=>{if(e.name==`doc`)a.doc=Ke.fromJSON(t.schema,n.doc);else if(e.name==`selection`)a.selection=L.fromJSON(a.doc,n.selection);else if(e.name==`storedMarks`)n.storedMarks&&(a.storedMarks=n.storedMarks.map(t.schema.markFromJSON));else{if(r)for(let i in r){let o=r[i],s=o.spec.state;if(o.key==e.name&&s&&s.fromJSON&&Object.prototype.hasOwnProperty.call(n,i)){a[e.name]=s.fromJSON.call(o,t,n[i],a);return}}a[e.name]=e.init(t,a)}}),a}};function Tr(e,t,n){for(let r in e){let i=e[r];i instanceof Function?i=i.bind(t):r==`handleDOMEvents`&&(i=Tr(i,t,{})),n[r]=i}return n}var B=class{constructor(e){this.spec=e,this.props={},e.props&&Tr(e.props,this,this.props),this.key=e.key?e.key.key:Dr(`plugin`)}getState(e){return e[this.key]}},Er=Object.create(null);function Dr(e){return e in Er?e+`$`+ ++Er[e]:(Er[e]=0,e+`$`)}var V=class{constructor(e=`key`){this.key=Dr(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}},Or=(e,t)=>!e.selection.empty&&(t&&t(e.tr.deleteSelection().scrollIntoView()),!0);function kr(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock(`backward`,e):n.parentOffset>0)?null:n}var Ar=(e,t,n)=>{let r=kr(e,n);if(!r)return!1;let i=Ir(r);if(!i){let n=r.blockRange(),i=n&&yn(n);return i!=null&&(t&&t(e.tr.lift(n,i).scrollIntoView()),!0)}let a=i.nodeBefore;if(ei(e,i,t,-1))return!0;if(r.parent.content.size==0&&(Pr(a,`end`)||z.isSelectable(a)))for(let n=r.depth;;n--){let o=Bn(e.doc,r.before(n),r.after(n),I.empty);if(o&&o.slice.size1)break}return a.isAtom&&i.depth==r.depth-1?(t&&t(e.tr.delete(i.pos-a.nodeSize,i.pos).scrollIntoView()),!0):!1},jr=(e,t,n)=>{let r=kr(e,n);if(!r)return!1;let i=Ir(r);return i?Nr(e,i,t):!1},Mr=(e,t,n)=>{let r=Lr(e,n);if(!r)return!1;let i=Br(r);return i?Nr(e,i,t):!1};function Nr(e,t,n){let r=t.nodeBefore,i=t.pos-1;for(;!r.isTextblock;i--){if(r.type.spec.isolating)return!1;let e=r.lastChild;if(!e)return!1;r=e}let a=t.nodeAfter,o=t.pos+1;for(;!a.isTextblock;o++){if(a.type.spec.isolating)return!1;let e=a.firstChild;if(!e)return!1;a=e}let s=Bn(e.doc,i,o,I.empty);if(!s||s.from!=i||s instanceof fn&&s.slice.size>=o-i)return!1;if(n){let t=e.tr.step(s);t.setSelection(R.create(t.doc,i)),n(t.scrollIntoView())}return!0}function Pr(e,t,n=!1){for(let r=e;r;r=t==`start`?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&r.childCount!=1)return!1}return!1}var Fr=(e,t,n)=>{let{$head:r,empty:i}=e.selection,a=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock(`backward`,e):r.parentOffset>0)return!1;a=Ir(r)}let o=a&&a.nodeBefore;return!o||!z.isSelectable(o)?!1:(t&&t(e.tr.setSelection(z.create(e.doc,a.pos-o.nodeSize)).scrollIntoView()),!0)};function Ir(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){if(e.index(t)>0)return e.doc.resolve(e.before(t+1));if(e.node(t).type.spec.isolating)break}return null}function Lr(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock(`forward`,e):n.parentOffset{let r=Lr(e,n);if(!r)return!1;let i=Br(r);if(!i)return!1;let a=i.nodeAfter;if(ei(e,i,t,1))return!0;if(r.parent.content.size==0&&(Pr(a,`start`)||z.isSelectable(a))){let n=Bn(e.doc,r.before(),r.after(),I.empty);if(n&&n.slice.size{let{$head:r,empty:i}=e.selection,a=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock(`forward`,e):r.parentOffset=0;t--){let n=e.node(t);if(e.index(t)+1{let n=e.selection,r=n instanceof z,i;if(r){if(n.node.isTextblock||!Nn(e.doc,n.from))return!1;i=n.from}else if(i=In(e.doc,n.from,-1),i==null)return!1;if(t){let n=e.tr.join(i);r&&n.setSelection(z.create(n.doc,i-e.doc.resolve(i).nodeBefore.nodeSize)),t(n.scrollIntoView())}return!0},Hr=(e,t)=>{let n=e.selection,r;if(n instanceof z){if(n.node.isTextblock||!Nn(e.doc,n.to))return!1;r=n.to}else if(r=In(e.doc,n.to,1),r==null)return!1;return t&&t(e.tr.join(r).scrollIntoView()),!0},Ur=(e,t)=>{let{$from:n,$to:r}=e.selection,i=n.blockRange(r),a=i&&yn(i);return a!=null&&(t&&t(e.tr.lift(i,a).scrollIntoView()),!0)},Wr=(e,t)=>{let{$head:n,$anchor:r}=e.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(t&&t(e.tr.insertText(` +`).scrollIntoView()),!0)};function Gr(e){for(let t=0;t{let{$head:n,$anchor:r}=e.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let i=n.node(-1),a=n.indexAfter(-1),o=Gr(i.contentMatchAt(a));if(!o||!i.canReplaceWith(a,a,o))return!1;if(t){let r=n.after(),i=e.tr.replaceWith(r,r,o.createAndFill());i.setSelection(L.near(i.doc.resolve(r),1)),t(i.scrollIntoView())}return!0},qr=(e,t)=>{let n=e.selection,{$from:r,$to:i}=n;if(n instanceof fr||r.parent.inlineContent||i.parent.inlineContent)return!1;let a=Gr(i.parent.contentMatchAt(i.indexAfter()));if(!a||!a.isTextblock)return!1;if(t){let n=(!r.parentOffset&&i.index(){let{$cursor:n}=e.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let r=n.before();if(jn(e.doc,r))return t&&t(e.tr.split(r).scrollIntoView()),!0}let r=n.blockRange(),i=r&&yn(r);return i!=null&&(t&&t(e.tr.lift(r,i).scrollIntoView()),!0)};function Yr(e){return(t,n)=>{if(t.selection instanceof z&&t.selection.node.isBlock){let{$from:e}=t.selection;return!e.parentOffset||!jn(t.doc,e.pos)?!1:(n&&n(t.tr.split(e.pos).scrollIntoView()),!0)}if(!t.selection.$from.depth)return!1;let r=t.tr;!t.selection.empty&&(t.selection instanceof R||t.selection instanceof fr)&&r.deleteSelection();let{$from:i}=r.selection,a=r.steps.length,o=[],s,c,l=!1,u=!1;for(let t=i.depth;;t--)if(i.node(t).isBlock){l=i.end(t)==i.pos+(i.depth-t),u=i.start(t)==i.pos-(i.depth-t),c=Gr(i.node(t-1).contentMatchAt(i.indexAfter(t-1)));let n=e&&e(i.parent,l,i);o.unshift(n||(l&&c?{type:c}:null)),s=t;break}else{if(t==1)return!1;o.unshift(null)}let d=i.pos,f=jn(r.doc,d,o.length,o);if(f||=(o[0]=c?{type:c}:null,jn(r.doc,d,o.length,o)),!f)return!1;if(r.split(d,o.length,o),!l&&u&&i.node(s).type!=c){let e=r.mapping.slice(a),t=e.map(i.before(s)),n=r.doc.resolve(t);c&&i.node(s-1).canReplaceWith(n.index(),n.index()+1,c)&&r.setNodeMarkup(e.map(i.before(s)),c)}return n&&n(r.scrollIntoView()),!0}}var Xr=Yr(),Zr=(e,t)=>{let{$from:n,to:r}=e.selection,i,a=n.sharedDepth(r);return a!=0&&(i=n.before(a),t&&t(e.tr.setSelection(z.create(e.doc,i))),!0)},Qr=(e,t)=>(t&&t(e.tr.setSelection(new fr(e.doc))),!0);function $r(e,t,n){let r=t.nodeBefore,i=t.nodeAfter,a=t.index();return!r||!i||!r.type.compatibleContent(i.type)?!1:!r.content.size&&t.parent.canReplace(a-1,a)?(n&&n(e.tr.delete(t.pos-r.nodeSize,t.pos).scrollIntoView()),!0):!t.parent.canReplace(a,a+1)||!(i.isTextblock||Nn(e.doc,t.pos))?!1:(n&&n(e.tr.join(t.pos).scrollIntoView()),!0)}function ei(e,t,n,r){let i=t.nodeBefore,a=t.nodeAfter,o,s,c=i.type.spec.isolating||a.type.spec.isolating;if(!c&&$r(e,t,n))return!0;let l=!c&&t.parent.canReplace(t.index(),t.index()+1);if(l&&(o=(s=i.contentMatchAt(i.childCount)).findWrapping(a.type))&&s.matchType(o[0]||a.type).validEnd){if(n){let r=t.pos+a.nodeSize,s=P.empty;for(let e=o.length-1;e>=0;e--)s=P.from(o[e].create(null,s));s=P.from(i.copy(s));let c=e.tr.step(new pn(t.pos-1,r,t.pos,r,new I(s,1,0),o.length,!0)),l=c.doc.resolve(r+2*o.length);l.nodeAfter&&l.nodeAfter.type==i.type&&Nn(c.doc,l.pos)&&c.join(l.pos),n(c.scrollIntoView())}return!0}let u=a.type.spec.isolating||r>0&&c?null:L.findFrom(t,1),d=u&&u.$from.blockRange(u.$to),f=d&&yn(d);if(f!=null&&f>=t.depth)return n&&n(e.tr.lift(d,f).scrollIntoView()),!0;if(l&&Pr(a,`start`,!0)&&Pr(i,`end`)){let r=i,o=[];for(;o.push(r),!r.isTextblock;)r=r.lastChild;let s=a,c=1;for(;!s.isTextblock;s=s.firstChild)c++;if(r.canReplace(r.childCount,r.childCount,s.content)){if(n){let r=P.empty;for(let e=o.length-1;e>=0;e--)r=P.from(o[e].copy(r));n(e.tr.step(new pn(t.pos-o.length,t.pos+a.nodeSize,t.pos+c,t.pos+a.nodeSize-c,new I(r,o.length,0),0,!0)).scrollIntoView())}return!0}}return!1}function ti(e){return function(t,n){let r=t.selection,i=e<0?r.$from:r.$to,a=i.depth;for(;i.node(a).isInline;){if(!a)return!1;a--}return i.node(a).isTextblock?(n&&n(t.tr.setSelection(R.create(t.doc,e<0?i.start(a):i.end(a)))),!0):!1}}var ni=ti(-1),ri=ti(1);function ii(e,t=null){return function(n,r){let{$from:i,$to:a}=n.selection,o=i.blockRange(a),s=o&&xn(o,e,t);return s?(r&&r(n.tr.wrap(o,s).scrollIntoView()),!0):!1}}function ai(e,t=null){return function(n,r){let i=!1;for(let r=0;r{if(i)return!1;if(r.isTextblock&&!r.hasMarkup(e,t)){if(r.type==e)i=!0;else{let t=n.doc.resolve(a),r=t.index();i=t.parent.canReplaceWith(r,r+1,e)}}})}if(!i)return!1;if(r){let i=n.tr;for(let r=0;r=2&&t.$from.node(t.depth-1).type.compatibleContent(n)&&t.startIndex==0){if(t.$from.index(t.depth-1)==0)return!1;let e=o.resolve(t.start-2);a=new We(e,e,t.depth),t.endIndex=0;e--)a=P.from(n[e].type.create(n[e].attrs,a));e.step(new pn(t.start-(r?2:0),t.end,t.start,t.end,new I(a,0,0),n.length,!0));let o=0;for(let e=0;e-1}function hi(e){return function(t,n){let{$from:r,$to:i}=t.selection,a=r.blockRange(i,t=>t.childCount>0&&mi(e,t.firstChild.type));return a?n?mi(e,r.node(a.depth-1).type)?gi(t,n,a):_i(t,n,a):!0:!1}}function gi(e,t,n){let r=e.tr,i=n.end,a=n.$to.end(n.depth),o=n.parent.child(n.endIndex-1).type;ia;t--)e-=i.child(t).nodeSize,r.delete(e-1,e+1);let a=r.doc.resolve(n.start),o=a.nodeAfter;if(r.mapping.map(n.end)!=n.start+a.nodeAfter.nodeSize)return!1;let s=n.startIndex==0,c=n.endIndex==i.childCount,l=a.node(-1),u=a.index(-1);if(!l.canReplace(u+ +!s,u+1,o.content.append(c?P.empty:P.from(i))))return!1;let d=a.pos,f=d+o.nodeSize;return r.step(new pn(d-+!!s,f+ +!!c,d+1,f-1,new I((s?P.empty:P.from(i.copy(P.empty))).append(c?P.empty:P.from(i.copy(P.empty))),+!s,+!c),+!s)),t(r.scrollIntoView()),!0}function vi(e){return function(t,n){let{$from:r,$to:i}=t.selection,a=r.blockRange(i,t=>t.childCount>0&&mi(e,t.firstChild.type));if(!a)return!1;let o=a.startIndex;if(o==0)return!1;let s=a.parent,c=s.child(o-1);if(!mi(e,c.type))return!1;if(n){let e=c.lastChild&&c.lastChild.type==s.type,r=P.from(e?c.lastChild.lastChild.type.create():null),i=new I(P.from(c.type.create(null,P.from(s.type.create(null,r)))),e?3:1,0),o=a.start,l=a.end;n(t.tr.step(new pn(o-(e?3:1),l,o,l,i,1,!0)).scrollIntoView())}return!0}}var yi=function(e){for(var t=0;;t++)if(e=e.previousSibling,!e)return t},bi=function(e){let t=e.assignedSlot||e.parentNode;return t&&t.nodeType==11?t.host:t},xi=null,Si=function(e,t,n){let r=xi||=document.createRange();return r.setEnd(e,n??e.nodeValue.length),r.setStart(e,t||0),r},Ci=function(){xi=null},wi=function(e,t,n,r){return n&&(Ei(e,t,n,r,-1)||Ei(e,t,n,r,1))},Ti=/^(img|br|input|textarea|hr)$/i;function Ei(e,t,n,r,i){for(;;){if(e==n&&t==r)return!0;if(t==(i<0?0:Di(e))){let n=e.parentNode;if(!n||!H(n)||Ni(e)||Ti.test(e.nodeName)||e.contentEditable==`false`)return!1;t=yi(e)+(i<0?0:1),e=n}else if(H(e)){let n=e.childNodes[t+(i<0?-1:0)];if(H(n)&&n.contentEditable==`false`){if(n.pmViewDesc?.ignoreForSelection)t+=i;else return!1}else e=n,t=i<0?Di(e):0}else return!1}}function Di(e){return e.nodeType==3?e.nodeValue.length:e.childNodes.length}function H(e){return e.nodeType==1}function Oi(e){return e.nodeType==3}function ki(e,t){return t?e.contains(H(t)?t:t.parentNode):!1}function Ai(e,t){for(;;){if(Oi(e)&&t)return e;if(H(e)&&t>0){if(e.contentEditable==`false`)return null;e=e.childNodes[t-1],t=Di(e)}else if(e.parentNode&&!Ni(e))t=yi(e),e=e.parentNode;else return null}}function ji(e,t){for(;;){if(Oi(e)&&t2),Qi=Zi||(Ri?/Mac/.test(Ri.platform):!1),$i=Ri?/Win/.test(Ri.platform):!1,ea=/Android \d/.test(Bi),ta=!!zi&&`webkitFontSmoothing`in zi.documentElement.style,na=ta?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function ra(e){let t=e.defaultView&&e.defaultView.visualViewport;return t?{left:0,right:t.width,top:0,bottom:t.height}:{left:0,right:e.documentElement.clientWidth,top:0,bottom:e.documentElement.clientHeight}}function ia(e,t){return typeof e==`number`?e:e[t]}function aa(e){let t=e.getBoundingClientRect(),n=t.width/e.offsetWidth||1,r=t.height/e.offsetHeight||1;return{left:t.left,right:t.left+e.clientWidth*n,top:t.top,bottom:t.top+e.clientHeight*r}}function oa(e,t,n){if(!xa(t)&&t.left==0)return;let r=e.someProp(`scrollThreshold`)||0,i=e.someProp(`scrollMargin`)||5,a=e.dom.ownerDocument;for(let o=n||e.dom;o;){if(!H(o)){o=bi(o);continue}let e=o==a.body,n=e?ra(a):aa(o),s=0,c=0;if(t.topn.bottom-ia(r,`bottom`)&&(c=t.bottom-t.top>n.bottom-n.top?t.top+ia(i,`top`)-n.top:t.bottom-n.bottom+ia(i,`bottom`)),t.leftn.right-ia(r,`right`)&&(s=t.right-n.right+ia(i,`right`)),s||c){if(e)a.defaultView.scrollBy(s,c);else{let e=o.scrollLeft,n=o.scrollTop;c&&(o.scrollTop+=c),s&&(o.scrollLeft+=s);let r=o.scrollLeft-e,i=o.scrollTop-n;t={left:t.left-r,top:t.top-i,right:t.right-r,bottom:t.bottom-i}}}let l=e?`fixed`:getComputedStyle(o).position;if(/^(fixed|sticky)$/.test(l))break;o=l==`absolute`?o.offsetParent:bi(o)}}function sa(e){let t=e.dom.getBoundingClientRect(),n=Math.max(0,t.top),r,i;for(let a=(t.left+t.right)/2,o=n+1;o=n-20){r=t,i=s.top;break}}return{refDOM:r,refTop:i,stack:ca(e.dom)}}function ca(e){let t=[],n=e.ownerDocument;for(let r=e;r&&(t.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),e!=n);r=bi(r));return t}function la({refDOM:e,refTop:t,stack:n}){let r=e?e.getBoundingClientRect().top:0;ua(n,r==0?0:r-t)}function ua(e,t){for(let n=0;n=s){o=Math.max(p.bottom,o),s=Math.min(p.top,s);let e=p.left>t.left?p.left-t.left:p.right=(p.left+p.right)/2));continue}}else p.top>t.top&&!c&&p.left<=t.left&&p.right>=t.left&&(c=u,l={left:Math.max(p.left,Math.min(p.right,t.left)),top:p.top});!n&&(t.left>=p.right&&t.top>=p.top||t.left>=p.left&&t.top>=p.bottom)&&(a=d+1)}}return!n&&c&&(n=c,i=l,r=0),n&&Oi(n)?ma(n,i):!n||r?{node:e,offset:a}:pa(n,i)}function ma(e,t){let n=e.nodeValue.length,r=document.createRange(),i;for(let a=0;a=(n.left+n.right)/2)};break}}return r.detach(),i||{node:e,offset:0}}function ha(e,t){return e.left>=t.left-1&&e.left<=t.right+1&&e.top>=t.top-1&&e.top<=t.bottom+1}function ga(e,t){let n=e.parentNode;return n&&/^li$/i.test(n.nodeName)&&t.left(e.left+e.right)/2?1:-1}return e.docView.posFromDOM(r,i,a)}function va(e,t,n,r){let i=-1;for(let n=t,a=!1;n!=e.dom;){let t=e.docView.nearestDesc(n,!0),o;if(!t)return null;if(H(t.dom)&&(t.node.isBlock&&t.parent||!t.contentDOM)&&((o=t.dom.getBoundingClientRect()).width||o.height)&&(t.node.isBlock&&t.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(t.dom.nodeName)&&(!a&&o.left>r.left||o.top>r.top?i=t.posBefore:(!a&&o.right-1?i:e.docView.posFromDOM(t,n,-1)}function ya(e,t,n){let r=e.childNodes.length;if(r&&n.topt.top&&i++}let n;ta&&i&&H(r)&&H(n=r.childNodes[i-1])&&n.contentEditable==`false`&&n.getBoundingClientRect().top>=t.top&&i--,r==e.dom&&i==r.childNodes.length-1&&H(r.lastChild)&&t.top>r.lastChild.getBoundingClientRect().bottom?s=e.state.doc.content.size:i!=0&&H(r)&&r.childNodes[i-1].nodeName==`BR`||(s=va(e,r,i,t))}s??=_a(e,o,t);let c=e.docView.nearestDesc(o,!0);return{pos:s,inside:c?c.posAtStart-c.border:-1}}function xa(e){return e.top=0&&i==r.nodeValue.length?(e--,a=1):n<0?e--:t++,Ta(Sa(Si(r,e,t),a),a<0)}}if(!e.state.doc.resolve(t-(a||0)).parent.inlineContent){if(a==null&&i&&(n<0||i==Di(r))){let e=r.childNodes[i-1];if(H(e))return Ea(e.getBoundingClientRect(),!1)}if(a==null&&i=0)}if(a==null&&i&&(n<0||i==Di(r))){let e=r.childNodes[i-1],t=Oi(e)?Si(e,Di(e)-+!o):H(e)&&(e.nodeName!=`BR`||!e.nextSibling)?e:null;if(t)return Ta(Sa(t,1),!1)}if(a==null&&i=0)}function Ta(e,t){if(e.width==0)return e;let n=t?e.left:e.right;return{top:e.top,bottom:e.bottom,left:n,right:n}}function Ea(e,t){if(e.height==0)return e;let n=t?e.top:e.bottom;return{top:n,bottom:n,left:e.left,right:e.right}}function Da(e,t,n){let r=e.state,i=e.root.activeElement;r!=t&&e.updateState(t),i!=e.dom&&e.focus();try{return n()}finally{r!=t&&e.updateState(r),i!=e.dom&&i&&i.focus()}}function Oa(e,t,n){let r=t.selection,i=n==`up`?r.$from:r.$to;return Da(e,t,()=>{let{node:t}=e.docView.domFromPos(i.pos,n==`up`?-1:1);for(;;){let n=e.docView.nearestDesc(t,!0);if(!n)break;if(n.node.isBlock){t=n.contentDOM||n.dom;break}t=n.dom.parentNode}let r=wa(e,i.pos,1);for(let e=t.firstChild;e;e=e.nextSibling){let t;if(H(e))t=e.getClientRects();else if(Oi(e))t=Si(e,0,e.nodeValue.length).getClientRects();else continue;for(let e=0;ei.top+1&&(n==`up`?r.top-i.top>(i.bottom-r.top)*2:i.bottom-r.bottom>(r.bottom-i.top)*2))return!1}}return!0})}var ka=/[\u0590-\u08ac]/;function Aa(e,t,n){let{$head:r}=t.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,a=!i,o=i==r.parent.content.size,s=e.domSelection();return s?!ka.test(r.parent.textContent)||!s.modify?n==`left`||n==`backward`?a:o:Da(e,t,()=>{let{focusNode:t,focusOffset:i,anchorNode:a,anchorOffset:o}=e.domSelectionRange(),c=s.caretBidiLevel;s.modify(`move`,n,`character`);let l=r.depth?e.docView.domAfterPos(r.before()):e.dom,{focusNode:u,focusOffset:d}=e.domSelectionRange(),f=u&&!ki(l,u)||t==u&&i==d;try{s.collapse(a,o),t&&(t!=a||i!=o)&&s.extend&&s.extend(t,i)}catch{}return c!=null&&(s.caretBidiLevel=c),f}):r.pos==r.start()||r.pos==r.end()}var ja=null,Ma=null,Na=!1;function Pa(e,t,n){return ja==t&&Ma==n?Na:(ja=t,Ma=n,Na=n==`up`||n==`down`?Oa(e,t,n):Aa(e,t,n))}var Fa=0,Ia=1,La=2,Ra=3,za=class{constructor(e,t,n,r){this.parent=e,this.children=t,this.dom=n,this.contentDOM=r,this.dirty=Fa,n.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,n){return!1}matchesHack(e){return!1}parseRule(e){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;tyi(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM)){let n=e.compareDocumentPosition(this.contentDOM);r=n&16?t>Array.from(e.childNodes).findIndex(e=>e.contains(this.contentDOM)):!(n&4)}else if(this.dom.firstChild){if(t==0)for(let t=e;;t=t.parentNode){if(t==this.dom){r=!1;break}if(t.previousSibling)break}if(r==null&&t==e.childNodes.length)for(let t=e;;t=t.parentNode){if(t==this.dom){r=!0;break}if(t.nextSibling)break}}return r??n>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let n=!0,r=e;r;r=r.parentNode){let i=this.getDesc(r),a;if(i&&(!t||i.node)){if(n&&(a=i.nodeDOM)&&!(H(a)?ki(a,e):a==e))n=!1;else return i}}}getDesc(e){let t=e.pmViewDesc;for(let e=t;e;e=e.parent)if(e==this)return t}posFromDOM(e,t,n){for(let r=e;r;r=r.parentNode){let i=this.getDesc(r);if(i)return i.localPosFromDOM(e,t,n)}return-1}descAt(e){for(let t=0,n=0;te){r=e-t;break}t=a}if(r)return this.children[n].domFromPos(r-this.children[n].border,t);for(;n>0;n--){let e=this.children[n-1];if(e.size||!(e instanceof Ka||e instanceof Ba&&e.side>=0))break}if(t<=0){let e,r=!0;for(;e=n?this.children[n-1]:null,e&&e.dom.parentNode!=this.contentDOM;n--,r=!1);return e&&t&&r&&!e.border&&!e.domAtom?e.domFromPos(e.size,t):{node:this.contentDOM,offset:e?yi(e.dom)+1:0}}{let e,r=!0;for(;e=n=i&&t<=s-n.border&&n.node&&n.contentDOM&&this.contentDOM.contains(n.contentDOM))return n.parseRange(e,t,i);e=a;for(let t=o;t>0;t--){let n=this.children[t-1];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(1)){r=yi(n.dom)+1;break}e-=n.size}r==-1&&(r=0)}if(r>-1&&(s>t||o==this.children.length-1)){t=s;for(let e=o+1;es&&at){let e=o;o=s,s=e}let n=document.createRange();n.setEnd(s.node,s.offset),n.setStart(o.node,o.offset),c.removeAllRanges(),c.addRange(n)}}ignoreMutation(e){return!this.contentDOM&&e.type!=`selection`}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let n=0,r=0;r=n:en){let r=n+i.border,o=a-i.border;if(e>=r&&t<=o){this.dirty=e==n||t==a?La:Ia,e==r&&t==o&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=Ra:i.markDirty(e-r,t-r);return}i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?La:Ra}n=a}this.dirty=La}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let n=e==1?La:Ia;t.dirty{if(!i)return r;if(i.parent)return i.parent.posBeforeChild(i)})),!t.type.spec.raw){let e=H(a)?a:document.createElement(`span`);e!=a&&(e.appendChild(a),a=e),e.hasAttribute(`contenteditable`)||(e.contentEditable=`false`),e.classList.add(`ProseMirror-widget`)}super(e,[],a,null),this.widget=t,this.widget=t,i=this}matchesWidget(e){return this.dirty==Fa&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return t?t(e):!1}ignoreMutation(e){return e.type!=`selection`||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}},Va=class extends za{constructor(e,t,n,r){super(e,[],t,null),this.textDOM=n,this.text=r}get size(){return this.text.length}localPosFromDOM(e,t){return e==this.textDOM?this.posAtStart+t:this.posAtStart+(t?this.size:0)}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type===`characterData`&&e.target.nodeValue==e.oldValue}},Ha=class e extends za{constructor(e,t,n,r,i){super(e,[],n,r),this.mark=t,this.spec=i}static create(t,n,r,i){let a=i.nodeViews[n.type.name],o=a&&a(n,i,r);return o&&o.dom||(o=It.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new e(t,n,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty&Ra||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=Ra&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=Fa){let e=this.parent;for(;!e.node;)e=e.parent;e.dirty0&&(a=lo(a,0,t,r));for(let e=0;e{if(!c)return o;if(c.parent)return c.parent.posBeforeChild(c)},r,i),u=l&&l.dom,d=l&&l.contentDOM;if(n.isText){if(!u)u=document.createTextNode(n.text);else if(!Oi(u))throw RangeError(`Text must be rendered as a DOM text node`)}else if(!u){let e=It.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs);({dom:u,contentDOM:d}=e)}!d&&!n.isText&&u.nodeName!=`BR`&&(u.hasAttribute(`contenteditable`)||(u.contentEditable=`false`),n.type.spec.draggable&&(u.draggable=!0));let f=u;return u=eo(u,r,n),l?c=new qa(t,n,r,i,u,d||null,f,l):n.isText?new Ga(t,n,r,i,u,f):new e(t,n,r,i,u,d||null,f)}parseRule(e){if(this.node.type.spec.reparseInView)return null;let t={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace==`pre`&&(t.preserveWhitespace=`full`),!this.contentDOM)t.getContent=()=>this.node.content;else if(!this.contentLost)t.contentElement=this.contentDOM;else{for(let e=this.children.length-1;e>=0;e--){let n=this.children[e];if(this.dom.contains(n.dom.parentNode)){t.contentElement=n.dom.parentNode;break}}if(!t.contentElement){let n=e&&e.find(t=>H(t)&&e.indexOf(t.parentNode)<0&&this.dom.contains(t));n?t.contentElement=n:t.getContent=()=>P.empty}}return t}matchesNode(e,t,n){return this.dirty==Fa&&e.eq(this.node)&&to(t,this.outerDeco)&&n.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return+!this.node.isLeaf}updateChildren(e,t){let n=this.node.inlineContent,r=t,i=e.composing?this.localCompositionInfo(e,t):null,a=i&&i.pos>-1?i:null,o=i&&i.pos<0,s=new ro(this,a&&a.node,e),c=this.node.inlineContent,l=c&&this.node.isBlock;oo(this.node,this.innerDeco,(t,i,a)=>{t.spec.marks?s.syncToMarks(t.spec.marks,n,e,i):t.type.side>=0&&!a&&s.syncToMarks(i==this.node.childCount?F.none:this.node.child(i).marks,n,e,i),s.placeWidget(t,e,r)},(t,a,u,d)=>{s.syncToMarks(t.marks,n,e,d),l&&t.isAtom&&!t.isText&&s.addHackNode(`IMG`,s.top);let f;s.findNodeMatch(t,a,u,d)||o&&e.state.selection.from>r&&e.state.selection.to-1&&s.updateNodeAt(t,a,u,f,e)||s.updateNextNode(t,a,u,e,d,r)||s.addNode(t,a,u,e,r),r+=t.nodeSize,c&&(l=t.isAtom&&!t.isText)}),s.syncToMarks([],n,e,0),this.node.isTextblock&&s.addTextblockHacks(),s.destroyRest(),(s.changed||this.dirty==La)&&(a&&this.protectLocalComposition(e,a),Ja(this.contentDOM,this.children,e),Zi&&so(this.dom))}localCompositionInfo(e,t){let{from:n,to:r}=e.state.selection;if(!(e.state.selection instanceof R)||nt+this.node.content.size)return null;let i=e.input.compositionNode;if(!i||!this.dom.contains(i.parentNode))return null;if(this.node.inlineContent){let e=i.nodeValue,a=co(this.node.content,e,n-t,r-t);return a<0?null:{node:i,pos:a,text:e}}return{node:i,pos:-1,text:``}}protectLocalComposition(e,{node:t,pos:n,text:r}){if(this.getDesc(t))return;let i=t;for(;i.parentNode!=this.contentDOM;i=i.parentNode){for(;i.previousSibling;)i.parentNode.removeChild(i.previousSibling);for(;i.nextSibling;)i.parentNode.removeChild(i.nextSibling);i.pmViewDesc&&(i.pmViewDesc=void 0)}let a=new Va(this,i,t,r);e.input.compositionNodes.push(a),this.children=lo(this.children,n,n+r.length,e,a)}update(e,t,n,r){return this.dirty==Ra||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,n,r),!0)}updateInner(e,t,n,r){this.updateOuterDeco(t),this.node=e,this.innerDeco=n,this.contentDOM&&this.updateChildren(r,this.posAtStart),this.dirty=Fa}updateOuterDeco(e){if(to(e,this.outerDeco))return;let t=!H(this.nodeDOM),n=this.dom;this.dom=Qa(this.dom,this.nodeDOM,Za(this.outerDeco,this.node,t),Za(e,this.node,t)),this.dom!=n&&(n.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){H(this.nodeDOM)&&(this.nodeDOM.classList.add(`ProseMirror-selectednode`),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){H(this.nodeDOM)&&(this.nodeDOM.classList.remove(`ProseMirror-selectednode`),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute(`draggable`))}get domAtom(){return this.node.isAtom}};function Wa(e,t,n,r,i){eo(r,t,e);let a=new Ua(void 0,e,t,n,r,r,r);return a.contentDOM&&a.updateChildren(i,0),a}var Ga=class e extends Ua{constructor(e,t,n,r,i,a){super(e,t,n,r,i,null,a)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,n,r){return this.dirty==Ra||this.dirty!=Fa&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=Fa||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,r.trackWrites==this.nodeDOM&&(r.trackWrites=null)),this.node=e,this.dirty=Fa,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,n){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,n)}ignoreMutation(e){return e.type!=`characterData`&&e.type!=`selection`}slice(t,n,r){let i=this.node.cut(t,n),a=document.createTextNode(i.text);return new e(this.parent,i,this.outerDeco,this.innerDeco,a,a)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=Ra)}get domAtom(){return!1}isText(e){return this.node.text==e}},Ka=class extends za{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Fa&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName==`IMG`}},qa=class extends Ua{constructor(e,t,n,r,i,a,o,s){super(e,t,n,r,i,a,o),this.spec=s}update(e,t,n,r){if(this.dirty==Ra)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let i=this.spec.update(e,t,n);return i&&this.updateInner(e,t,n,r),i}return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,n,r)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,n,r){this.spec.setSelection?this.spec.setSelection(e,t,n.root):super.setSelection(e,t,n,r)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}};function Ja(e,t,n){let r=e.firstChild,i=!1;for(let a=0;a>1,o=Math.min(a,e.length);for(;i-1)i>this.index&&(this.changed=!0,this.destroyBetween(this.index,i)),this.top=this.top.children[this.index];else{let r=Ha.create(this.top,e[a],t,n);this.top.children.splice(this.index,0,r),this.top=r,this.changed=!0}this.index=0,a++}}findNodeMatch(e,t,n,r){let i=-1,a;if(r>=this.preMatch.index&&(a=this.preMatch.matches[r-this.preMatch.index]).parent==this.top&&a.matchesNode(e,t,n))i=this.top.children.indexOf(a,this.index);else for(let r=this.index,a=Math.min(this.top.children.length,r+5);r0;){let s;for(;;)if(r){let e=n.children[r-1];if(e instanceof Ha)n=e,r=e.children.length;else{s=e,r--;break}}else if(n==t)break outer;else r=n.parent.children.indexOf(n),n=n.parent;let c=s.node;if(c){if(c!=e.child(i-1))break;--i,a.set(s,i),o.push(s)}}return{index:i,matched:a,matches:o.reverse()}}function ao(e,t){return e.type.side-t.type.side}function oo(e,t,n,r){let i=t.locals(e),a=0;if(i.length==0){for(let n=0;na;)s.push(i[o++]);let m=a+f.nodeSize;if(f.isText){let e=m;o!e.inline):s.slice();r(f,h,t.forChild(a,f),p),a=m}}function so(e){if(e.nodeName==`UL`||e.nodeName==`OL`){let t=e.style.cssText;e.style.cssText=t+`; list-style: square !important`,window.getComputedStyle(e).listStyle,e.style.cssText=t}}function co(e,t,n,r){for(let i=0,a=0;i=n){if(a>=r&&c.slice(r-t.length-s,r-s)==t)return r-t.length;let e=s=0&&e+t.length+s>=n)return s+e;if(n==r&&c.length>=r+t.length-s&&c.slice(r-s,r-s+t.length)==t)return r}}return-1}function lo(e,t,n,r,i){let a=[];for(let o=0,s=0;o=n||u<=t?a.push(c):(ln&&a.push(c.slice(n-l,c.size,r)))}return a}function uo(e,t=null){let n=e.domSelectionRange(),r=e.state.doc;if(!n.focusNode)return null;let i=e.docView.nearestDesc(n.focusNode),a=i&&i.size==0,o=e.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(o<0)return null;let s=r.resolve(o),c,l;if(Pi(n)){for(c=o;i&&!i.node;)i=i.parent;if(i&&i.node.isAtom&&z.isSelectable(i.node)&&i.parent&&!(i.node.isInline&&Mi(n.focusNode,n.focusOffset,i.dom))){let e=i.posBefore;l=new z(o==e?s:r.resolve(e))}else if(Ki&&t==`key`&&o>e.state.selection.to&&H(n.focusNode)&&n.focusOffset==n.focusNode.childNodes.length&&i&&i.posAtStart>e.state.selection.to)for(let e=n.focusNode;;e=e.parentNode){if(getComputedStyle(e).overflow!=`visible`){l=L.findFrom(r.resolve(i.posAtStart),1);break}if(e==i.dom||e.nextSibling||!e.parentNode||!H(e.parentNode))break}}else{if(n instanceof e.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let t=o,i=o;for(let r=0;r{(n.anchorNode!=r||n.anchorOffset!=i)&&(t.removeEventListener(`selectionchange`,e.input.hideSelectionGuard),setTimeout(()=>{(!fo(e)||e.state.selection.visible)&&e.dom.classList.remove(`ProseMirror-hideselection`)},20))})}function yo(e){let t=e.domSelection();if(!t)return;let n=e.cursorWrapper.dom,r=n.nodeName==`IMG`;r?t.collapse(n.parentNode,yi(n)+1):t.collapse(n,0),!r&&!e.state.selection.visible&&Wi&&Gi<=11&&(n.disabled=!0,n.disabled=!1)}function bo(e,t){if(t instanceof z){let n=e.docView.descAt(t.from);n!=e.lastSelectedViewDesc&&(xo(e),n&&n.selectNode(),e.lastSelectedViewDesc=n)}else xo(e)}function xo(e){e.lastSelectedViewDesc&&=(e.lastSelectedViewDesc.parent&&e.lastSelectedViewDesc.deselectNode(),void 0)}function So(e,t,n,r){return e.someProp(`createSelectionBetween`,r=>r(e,t,n))||R.between(t,n,r)}function Co(e){return e.editable&&!e.hasFocus()?!1:wo(e)}function wo(e){let t=e.domSelectionRange();if(!t.anchorNode)return!1;try{return ki(e.dom,t.anchorNode)&&(e.editable||ki(e.dom,t.focusNode))}catch{return!1}}function To(e){let t=e.docView.domFromPos(e.state.selection.anchor,0),n=e.domSelectionRange();return wi(t.node,t.offset,n.anchorNode,n.anchorOffset)}function Eo(e,t){let{$anchor:n,$head:r}=e.selection,i=t>0?n.max(r):n.min(r),a=i.parent.inlineContent?i.depth?e.doc.resolve(t>0?i.after():i.before()):null:i;return a&&L.findFrom(a,t)}function Do(e,t){return e.dispatch(e.state.tr.setSelection(t).scrollIntoView()),!0}function Oo(e,t,n){let r=e.state.selection;if(r instanceof R){if(n.indexOf(`s`)>-1){let{$head:n}=r,i=n.textOffset?null:t<0?n.nodeBefore:n.nodeAfter;if(!i||i.isText||!i.isLeaf)return!1;let a=e.state.doc.resolve(n.pos+i.nodeSize*(t<0?-1:1));return Do(e,new R(r.$anchor,a))}if(!r.empty)return!1;if(e.endOfTextblock(t>0?`forward`:`backward`)){let n=Eo(e.state,t);return n&&n instanceof z?Do(e,n):!1}if(!Qi||n.indexOf(`m`)<0){let n=r.$head,i=n.textOffset?null:t<0?n.nodeBefore:n.nodeAfter,a;if(!i||i.isText)return!1;let o=t<0?n.pos-i.nodeSize:n.pos;return i.isAtom||(a=e.docView.descAt(o))&&!a.contentDOM?z.isSelectable(i)?Do(e,new z(t<0?e.state.doc.resolve(n.pos-i.nodeSize):n)):Do(e,new R(e.state.doc.resolve(t<0?o:o+i.nodeSize))):!1}}else if(r instanceof z&&r.node.isInline)return Do(e,new R(t>0?r.$to:r.$from));else{let n=Eo(e.state,t);return n?Do(e,n):!1}}function ko(e,t){let n=e.pmViewDesc;return n?n.size==0&&(t<0||e.nextSibling||e.nodeName!=`BR`):H(e)&&e.contentEditable==`false`}function Ao(e,t){return t<0?jo(e):Mo(e)}function jo(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let i,a,o=!1;for(Ki&&H(n)&&r0){if(!H(n))break;let e=n.childNodes[r-1];if(ko(e,-1))i=n,a=--r;else if(Oi(e))n=e,r=n.nodeValue.length;else break}else if(No(n))break;else{let t=n.previousSibling;for(;t&&ko(t,-1);)i=n.parentNode,a=yi(t),t=t.previousSibling;if(t)n=t,r=Di(n);else{if(n=n.parentNode,n==e.dom)break;r=0}}o?Io(e,n,r):i&&Io(e,i,a)}function Mo(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let i=Di(n),a,o;for(;;)if(r{e.state==a&&po(e)},50)}function Lo(e,t){let n=e.state.doc.resolve(t);if(!(Ji||$i)&&n.parent.inlineContent){let r=e.coordsAtPos(t);if(t>n.start()){let n=e.coordsAtPos(t-1),i=(n.top+n.bottom)/2;if(i>r.top&&i1)return n.leftr.top&&i1)return n.left>r.left?`ltr`:`rtl`}}let r=e.dom;for(let t=n.depth;t>0;t--)if(n.node(t).isBlock){r=e.nodeDOM(n.before(t))||r;break}return getComputedStyle(r).direction==`rtl`?`rtl`:`ltr`}function Ro(e,t,n){let r=e.state.selection;if(r instanceof R&&!r.empty||n.indexOf(`s`)>-1||Qi&&n.indexOf(`m`)>-1)return!1;let{$from:i,$to:a}=r;if(!i.parent.inlineContent||e.endOfTextblock(t<0?`up`:`down`)){let n=Eo(e.state,t);if(n&&n instanceof z)return Do(e,n)}if(!i.parent.inlineContent){let n=t<0?i:a,o=r instanceof fr?L.near(n,t):L.findFrom(n,t);return o?Do(e,o):!1}return!1}function zo(e,t){if(!(e.state.selection instanceof R))return!0;let{$head:n,$anchor:r,empty:i}=e.state.selection;if(!n.sameParent(r))return!0;if(!i)return!1;if(e.endOfTextblock(t>0?`forward`:`backward`))return!0;let a=!n.textOffset&&(t<0?n.nodeBefore:n.nodeAfter);if(a&&!a.isText){let r=e.state.tr;return t<0?r.delete(n.pos-a.nodeSize,n.pos):r.delete(n.pos,n.pos+a.nodeSize),e.dispatch(r),!0}return!1}function Bo(e,t,n){e.domObserver.stop(),t.contentEditable=n,e.domObserver.start()}function Vo(e){if(!Xi||e.state.selection.$head.parentOffset>0)return!1;let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(t&&H(t)&&n==0&&t.firstChild&&H(t.firstChild)&&t.firstChild.contentEditable==`false`){let n=t.firstChild;Bo(e,n,`true`),setTimeout(()=>Bo(e,n,`false`),20)}return!1}function Ho(e){let t=``;return e.ctrlKey&&(t+=`c`),e.metaKey&&(t+=`m`),e.altKey&&(t+=`a`),e.shiftKey&&(t+=`s`),t}function Uo(e,t){let n=t.keyCode,r=Ho(t);if(n==8||Qi&&n==72&&r==`c`)return zo(e,-1)||Ao(e,-1);if(n==46&&!t.shiftKey||Qi&&n==68&&r==`c`)return zo(e,1)||Ao(e,1);if(n==13||n==27)return!0;if(n==37||Qi&&n==66&&r==`c`){let t=n==37?Lo(e,e.state.selection.from)==`ltr`?-1:1:-1;return Oo(e,t,r)||Ao(e,t)}if(n==39||Qi&&n==70&&r==`c`){let t=n==39?Lo(e,e.state.selection.from)==`ltr`?1:-1:1;return Oo(e,t,r)||Ao(e,t)}return n==38||Qi&&n==80&&r==`c`?Ro(e,-1,r)||Ao(e,-1):n==40||Qi&&n==78&&r==`c`?Vo(e)||Ro(e,1,r)||Ao(e,1):!(r!=(Qi?`m`:`c`)||n!=66&&n!=73&&n!=89&&n!=90)}function Wo(e,t){e.someProp(`transformCopied`,n=>{t=n(t,e)});let n=[],{content:r,openStart:i,openEnd:a}=t;for(;i>1&&a>1&&r.childCount==1&&r.firstChild.childCount==1;){i--,a--;let e=r.firstChild;n.push(e.type.name,e.attrs==e.type.defaultAttrs?null:e.attrs),r=e.content}let o=e.someProp(`clipboardSerializer`)||It.fromSchema(e.state.schema),s=es(),c=s.createElement(`div`);c.appendChild(o.serializeFragment(r,{document:s}));let l=c.firstChild,u,d=0;for(;l&&H(l)&&(u=$o[l.nodeName.toLowerCase()]);){for(let e=u.length-1;e>=0;e--){let t=s.createElement(u[e]);for(;c.firstChild;)t.appendChild(c.firstChild);c.appendChild(t),d++}l=c.firstChild}return l&&H(l)&&l.setAttribute(`data-pm-slice`,`${i} ${a}${d?` -${d}`:``} ${JSON.stringify(n)}`),{dom:c,text:e.someProp(`clipboardTextSerializer`,n=>n(t,e))||t.content.textBetween(0,t.content.size,` + +`),slice:t}}function Go(e,t,n,r,i){let a=i.parent.type.spec.code,o,s;if(!n&&!t)return null;let c=!!t&&(r||a||!n);if(c){if(e.someProp(`transformPastedText`,n=>{t=n(t,a||r,e)}),a)return s=new I(P.from(e.state.schema.text(t.replace(/\r\n?/g,` +`))),0,0),e.someProp(`transformPasted`,t=>{s=t(s,e,!0)}),s;let n=e.someProp(`clipboardTextParser`,n=>n(t,i,r,e));if(n)s=n;else{let n=i.marks(),{schema:r}=e.state,a=It.fromSchema(r);o=document.createElement(`div`),t.split(/(?:\r\n?|\n)+/).forEach(e=>{let t=o.appendChild(document.createElement(`p`));e&&t.appendChild(a.serializeNode(r.text(e,n)))})}}else e.someProp(`transformPastedHTML`,t=>{n=t(n,e)}),o=rs(n),ta&&is(o);let l=o&&o.querySelector(`[data-pm-slice]`),u=l&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(l.getAttribute(`data-pm-slice`)||``);if(u&&u[3])for(let e=+u[3];e>0;e--){let e=o.firstChild;for(;e&&!H(e);)e=e.nextSibling;if(!e)break;o=e}if(s||=(e.someProp(`clipboardParser`)||e.someProp(`domParser`)||St.fromSchema(e.state.schema)).parseSlice(o,{preserveWhitespace:!!(c||u),context:i,ruleFromNode(e){return e.nodeName==`BR`&&!e.nextSibling&&e.parentNode&&!Ko.test(e.parentNode.nodeName)?{ignore:!0}:null}}),u)s=as(Qo(s,+u[1],+u[2]),u[4]);else if(s=I.maxOpen(qo(s.content,i),!0),s.openStart||s.openEnd){let e=0,t=0;for(let t=s.content.firstChild;e{s=t(s,e,c)}),s}var Ko=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function qo(e,t){if(e.childCount<2)return e;for(let n=t.depth;n>=0;n--){let r=t.node(n).contentMatchAt(t.index(n)),i,a=[];if(e.forEach(e=>{if(!a)return;let t=r.findWrapping(e.type),n;if(!t)return a=null;if(n=a.length&&i.length&&Yo(t,i,e,a[a.length-1],0))a[a.length-1]=n;else{a.length&&(a[a.length-1]=Xo(a[a.length-1],i.length));let n=Jo(e,t);a.push(n),r=r.matchType(n.type),i=t}}),a)return P.from(a)}return e}function Jo(e,t,n=0){for(let r=t.length-1;r>=n;r--)e=t[r].create(null,P.from(e));return e}function Yo(e,t,n,r,i){if(i1&&(a=0),i=n&&(s=t<0?o.contentMatchAt(0).fillBefore(s,a<=i).append(s):s.append(o.contentMatchAt(o.childCount).fillBefore(P.empty,!0))),e.replaceChild(t<0?0:e.childCount-1,o.copy(s))}function Qo(e,t,n){return te})}return ts.createHTML(e)}function rs(e){let t=/^(\s*]*>)*/.exec(e);t&&(e=e.slice(t[0].length));let n=es(),r=n.body,i=/<([a-z][^>\s]+)/i.exec(e),a;if((a=i&&$o[i[1].toLowerCase()])&&(e=a.map(e=>`<`+e+`>`).join(``)+e+a.map(e=>``).reverse().join(``)),r.innerHTML=ns(e),a)for(let e=0;e=0;e-=2){let t=n.nodes[r[e]];if(!t||t.hasRequiredAttrs())break;try{i=P.from(t.create(r[e+1],i))}catch{break}a++,o++}return new I(i,a,o)}var ss={},cs={},ls={touchstart:!0,touchmove:!0},us=class{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastKeyDispatched=!1,this.lastClick={time:0,x:0,y:0,type:``,button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}};function ds(e){for(let t in ss){let n=ss[t];e.dom.addEventListener(t,e.input.eventHandlers[t]=t=>{gs(e,t)&&!hs(e,t)&&(e.editable||!(t.type in cs))&&n(e,t)},ls[t]?{passive:!0}:void 0)}Xi&&e.dom.addEventListener(`input`,()=>null),ms(e)}function fs(e,t){e.input.lastSelectionOrigin=t,e.input.lastSelectionTime=Date.now()}function ps(e){e.input.mouseDown&&e.input.mouseDown.done(),e.domObserver.stop();for(let t in e.input.eventHandlers)e.dom.removeEventListener(t,e.input.eventHandlers[t]);clearTimeout(e.input.composingTimeout),clearTimeout(e.input.lastIOSEnterFallbackTimeout)}function ms(e){e.someProp(`handleDOMEvents`,t=>{for(let n in t)e.input.eventHandlers[n]||e.dom.addEventListener(n,e.input.eventHandlers[n]=t=>hs(e,t))})}function hs(e,t){return e.someProp(`handleDOMEvents`,n=>{let r=n[t.type];return r?r(e,t)||t.defaultPrevented:!1})}function gs(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let n=t.target;n!=e.dom;n=n.parentNode)if(!n||n.nodeType==11||n.pmViewDesc&&n.pmViewDesc.stopEvent(t))return!1;return!0}function _s(e,t){!hs(e,t)&&ss[t.type]&&(e.editable||!(t.type in cs))&&ss[t.type](e,t)}function vs(e,t){let{input:n}=e;return n.lastKeyDispatched||e.composing?!1:(n.lastKeyDispatched=!0,typeof t==`string`&&(t=Fi(t==`Backspace`?8:13,t)),e.someProp(`handleKeyDown`,n=>n(e,t)))}cs.keydown=(e,t)=>{let n=t;if(e.input.shiftKey=n.keyCode==16||n.shiftKey,!Fs(e)&&(e.input.lastKeyCode=n.keyCode,e.input.lastKeyCodeTime=Date.now(),e.input.lastKeyDispatched=!1,!(ea&&Ji&&n.keyCode==13))){if(n.keyCode!=229&&e.domObserver.forceFlush(),Zi&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let t=Date.now();e.input.lastIOSEnter=t,e.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{e.input.lastIOSEnter==t&&(vs(e,`Enter`),e.input.lastIOSEnter=0)},200)}else vs(e,n)||Uo(e,n)?n.preventDefault():fs(e,`key`)}},cs.keyup=(e,t)=>{t.keyCode==16&&(e.input.shiftKey=!1)},cs.keypress=(e,t)=>{let n=t;if(Fs(e)||!n.charCode||n.ctrlKey&&!n.altKey||Qi&&n.metaKey)return;if(e.someProp(`handleKeyPress`,t=>t(e,n))){n.preventDefault();return}let r=e.state.selection;if(!(r instanceof R)||!r.$from.sameParent(r.$to)){let t=String.fromCharCode(n.charCode),i=()=>e.state.tr.insertText(t).scrollIntoView();!/[\r\n]/.test(t)&&!e.someProp(`handleTextInput`,n=>n(e,r.$from.pos,r.$to.pos,t,i))&&e.dispatch(i()),n.preventDefault()}};function ys(e){return{left:e.clientX,top:e.clientY}}function bs(e,t){let n=t.x-e.clientX,r=t.y-e.clientY;return n*n+r*r<100}function xs(e,t,n,r,i){if(r==-1)return!1;let a=e.state.doc.resolve(r);for(let r=a.depth+1;r>0;r--)if(e.someProp(t,t=>r>a.depth?t(e,n,a.nodeAfter,a.before(r),i,!0):t(e,n,a.node(r),a.before(r),i,!1)))return!0;return!1}function Ss(e,t,n){if(e.focused||e.focus(),e.state.selection.eq(t))return;let r=e.state.tr.setSelection(t);r.setMeta(`pointer`,!0),e.dispatch(r)}function Cs(e,t){if(t==-1)return!1;let n=e.state.doc.resolve(t),r=n.nodeAfter;return r&&r.isAtom&&z.isSelectable(r)?(Ss(e,new z(n)),!0):!1}function ws(e,t){if(t==-1)return!1;let n=e.state.selection,r,i;n instanceof z&&(r=n.node);let a=e.state.doc.resolve(t);for(let e=a.depth+1;e>0;e--){let t=e>a.depth?a.nodeAfter:a.node(e);if(z.isSelectable(t)){i=r&&n.$from.depth>0&&e>=n.$from.depth&&a.before(n.$from.depth+1)==n.$from.pos?a.before(n.$from.depth):a.before(e);break}}return i!=null&&(Ss(e,z.create(e.state.doc,i)),!0)}function Ts(e,t,n,r,i){return xs(e,`handleClickOn`,t,n,r)||e.someProp(`handleClick`,n=>n(e,t,r))||(i?ws(e,n):Cs(e,n))}function Es(e,t,n,r){return xs(e,`handleDoubleClickOn`,t,n,r)||e.someProp(`handleDoubleClick`,n=>n(e,t,r))}function Ds(e,t,n,r){return xs(e,`handleTripleClickOn`,t,n,r)||e.someProp(`handleTripleClick`,n=>n(e,t,r))||Os(e,n,r)}function Os(e,t,n){if(n.button!=0)return!1;let r=ks(e,t,!0),i=e.state.doc;return r?(Ss(e,r),r instanceof R&&i.eq(e.state.doc)&&(e.input.mouseDown=new Ps(e,r)),!0):!1}function ks(e,t,n){let r=e.state.doc;if(t==-1)return r.inlineContent?R.create(r,0,r.content.size):null;let i=r.resolve(t);for(let e=i.depth+1;e>0;e--){let t=e>i.depth?i.nodeAfter:i.node(e),a=i.before(e);if(t.inlineContent)return R.create(r,a+1,a+1+t.content.size);if(n&&z.isSelectable(t))return z.create(r,a)}return null}function As(e){return Vs(e)}var js=Qi?`metaKey`:`ctrlKey`;ss.mousedown=(e,t)=>{let n=t;e.input.shiftKey=n.shiftKey;let r=As(e),i=Date.now(),a=`singleClick`;i-e.input.lastClick.time<500&&bs(n,e.input.lastClick)&&!n[js]&&e.input.lastClick.button==n.button&&(e.input.lastClick.type==`singleClick`?a=`doubleClick`:e.input.lastClick.type==`doubleClick`&&(a=`tripleClick`)),e.input.lastClick={time:i,x:n.clientX,y:n.clientY,type:a,button:n.button},e.input.mouseDown&&e.input.mouseDown.done();let o=e.posAtCoords(ys(n));o&&(a==`singleClick`?e.input.mouseDown=new Ns(e,o,n,!!r):(a==`doubleClick`?Es:Ds)(e,o.pos,o.inside,n)?n.preventDefault():fs(e,`pointer`))};var Ms=class{constructor(e){this.view=e,this.mightDrag=null,e.root.addEventListener(`mouseup`,this.up=this.up.bind(this)),e.root.addEventListener(`mousemove`,this.move=this.move.bind(this))}up(e){this.done()}move(e){e.buttons==0&&this.done()}done(){this.view.root.removeEventListener(`mouseup`,this.up),this.view.root.removeEventListener(`mousemove`,this.move),this.view.input.mouseDown==this&&(this.view.input.mouseDown=null)}delaySelUpdate(){return!1}},Ns=class extends Ms{constructor(e,t,n,r){super(e),this.pos=t,this.event=n,this.flushed=r,this.delayedSelectionSync=!1,this.startDoc=e.state.doc,this.selectNode=!!n[js],this.allowDefault=n.shiftKey;let i,a;if(t.inside>-1)i=e.state.doc.nodeAt(t.inside),a=t.inside;else{let n=e.state.doc.resolve(t.pos);i=n.parent,a=n.depth?n.before():0}let o=r?null:n.target,s=o?e.docView.nearestDesc(o,!0):null;this.target=s&&H(s.nodeDOM)?s.nodeDOM:null;let{selection:c}=e.state;n.button==0&&(i.type.spec.draggable&&i.type.spec.selectable!==!1||c instanceof z&&c.from<=a&&c.to>a)&&(this.mightDrag={node:i,pos:a,addAttr:!(!this.target||this.target.draggable),setUneditable:!!(this.target&&Ki&&!this.target.hasAttribute(`contentEditable`))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute(`contentEditable`,`false`)},20),this.view.domObserver.start()),fs(e,`pointer`)}done(){super.done(),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute(`draggable`),this.mightDrag.setUneditable&&this.target.removeAttribute(`contentEditable`),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>{this.view.isDestroyed||po(this.view)})}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(ys(e))),this.updateAllowDefault(e),this.allowDefault||!t?fs(this.view,`pointer`):Ts(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||Xi&&this.mightDrag&&!this.mightDrag.node.isAtom||Ji&&!this.view.state.selection.visible&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?(Ss(this.view,L.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):fs(this.view,`pointer`)}move(e){this.updateAllowDefault(e),fs(this.view,`pointer`),super.move(e)}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}delaySelUpdate(){return this.allowDefault?(this.delayedSelectionSync=!0,!0):!1}},Ps=class extends Ms{constructor(e,t){super(e),this.startSelection=t,this.startDoc=e.state.doc}move(e){if(e.buttons==0||this.view.isDestroyed||!this.view.state.doc.eq(this.startDoc)){this.done();return}e.preventDefault(),fs(this.view,`pointer`);let t=this.view.posAtCoords(ys(e)),n=t&&ks(this.view,t.inside,!1);if(!n)return;let{doc:r}=this.view.state,i=this.startSelection,[a,o]=n.from{e.input.lastTouch=Date.now(),As(e),fs(e,`pointer`)},ss.touchmove=e=>{e.input.lastTouch=Date.now(),fs(e,`pointer`)},ss.contextmenu=e=>As(e);function Fs(e,t){return e.composing?!0:Xi&&Math.abs(Date.now()-e.input.compositionEndedAt)<500?(e.input.compositionEndedAt=-2e8,!0):!1}var Is=ea?5e3:-1;cs.compositionstart=cs.compositionupdate=e=>{if(!e.composing){e.domObserver.flush();let{state:t}=e,n=t.selection.$to;if(t.selection instanceof R&&t.selection.empty&&(t.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(e=>e.type.spec.inclusive===!1)||Ji&&$i&&Ls(e)))e.markCursor=e.state.storedMarks||n.marks(),Vs(e,!0),e.markCursor=null;else if(Vs(e,!t.selection.empty),Ki&&t.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let t=e.domSelectionRange();for(let n=t.focusNode,r=t.focusOffset;n&&H(n)&&r!=0;){let t=r<0?n.lastChild:n.childNodes[r-1];if(!t)break;if(Oi(t)){let n=e.domSelection();n&&n.collapse(t,t.nodeValue.length);break}n=t,r=-1}}e.input.composing=!0}Rs(e,Is)};function Ls(e){let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(!t||!H(t)||n>=t.childNodes.length)return!1;let r=t.childNodes[n];return H(r)&&r.contentEditable==`false`}cs.compositionend=(e,t)=>{e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=Date.now(),e.input.compositionPendingChanges=e.domObserver.pendingRecords().length?e.input.compositionID:0,e.input.compositionNode=null,e.input.badSafariComposition?e.domObserver.forceFlush():e.input.compositionPendingChanges&&Promise.resolve().then(()=>e.domObserver.flush()),e.input.compositionID++,Rs(e,20))};function Rs(e,t){clearTimeout(e.input.composingTimeout),t>-1&&(e.input.composingTimeout=setTimeout(()=>Vs(e),t))}function zs(e){for(e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=Date.now());e.input.compositionNodes.length>0;)e.input.compositionNodes.pop().markParentsDirty()}function Bs(e){let t=e.domSelectionRange();if(!t.focusNode)return null;let n=Ai(t.focusNode,t.focusOffset),r=ji(t.focusNode,t.focusOffset);if(n&&r&&n!=r){let t=r.pmViewDesc,i=e.domObserver.lastChangedTextNode;if(n==i||r==i)return i;if(!t||!t.isText(r.nodeValue))return r;if(e.input.compositionNode==r){let e=n.pmViewDesc;if(e&&e.isText(n.nodeValue))return r}}return n||r}function Vs(e,t=!1){if(!(ea&&e.domObserver.flushingSoon>=0)){if(e.domObserver.forceFlush(),zs(e),t||e.docView&&e.docView.dirty){let n=uo(e),r=e.state.selection;return n&&!n.eq(r)?e.dispatch(e.state.tr.setSelection(n)):(e.markCursor||t)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?e.dispatch(e.state.tr.deleteSelection()):e.updateState(e.state),!0}return!1}}function Hs(e,t){if(!e.dom.parentNode)return;let n=e.dom.parentNode.appendChild(document.createElement(`div`));n.appendChild(t),n.style.cssText=`position: fixed; left: -10000px; top: 10px`;let r=getSelection(),i=document.createRange();i.selectNodeContents(t),e.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),e.focus()},50)}var Us=Wi&&Gi<15||Zi&&na<604;ss.copy=cs.cut=(e,t)=>{let n=t,r=e.state.selection,i=n.type==`cut`;if(r.empty)return;let a=Us?null:n.clipboardData,{dom:o,text:s}=Wo(e,r.content());a?(n.preventDefault(),a.clearData(),a.setData(`text/html`,o.innerHTML),a.setData(`text/plain`,s)):Hs(e,o),i&&e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta(`uiEvent`,`cut`))};function Ws(e){return e.openStart==0&&e.openEnd==0&&e.content.childCount==1?e.content.firstChild:null}function Gs(e,t){if(!e.dom.parentNode)return;let n=e.input.shiftKey||e.state.selection.$from.parent.type.spec.code,r=e.dom.parentNode.appendChild(document.createElement(n?`textarea`:`div`));n||(r.contentEditable=`true`),r.style.cssText=`position: fixed; left: -10000px; top: 10px`,r.focus();let i=e.input.shiftKey&&e.input.lastKeyCode!=45;setTimeout(()=>{e.focus(),r.parentNode&&r.parentNode.removeChild(r),n?Ks(e,r.value,null,i,t):Ks(e,r.textContent,r.innerHTML,i,t)},50)}function Ks(e,t,n,r,i){let a=Go(e,t,n,r,e.state.selection.$from);if(e.someProp(`handlePaste`,t=>t(e,i,a||I.empty)))return!0;if(!a)return!1;let o=Ws(a),s=o?e.state.tr.replaceSelectionWith(o,r):e.state.tr.replaceSelection(a);return e.dispatch(s.scrollIntoView().setMeta(`paste`,!0).setMeta(`uiEvent`,`paste`)),!0}function qs(e){let t=e.getData(`text/plain`)||e.getData(`Text`);if(t)return t;let n=e.getData(`text/uri-list`);return n?n.replace(/\r?\n/g,` `):``}cs.paste=(e,t)=>{let n=t;if(e.composing&&!ea)return;let r=Us?null:n.clipboardData,i=e.input.shiftKey&&e.input.lastKeyCode!=45;r&&Ks(e,qs(r),r.getData(`text/html`),i,n)?n.preventDefault():Gs(e,n)};var Js=class{constructor(e,t,n){this.slice=e,this.move=t,this.node=n}},Ys=Qi?`altKey`:`ctrlKey`;function Xs(e,t){let n;return e.someProp(`dragCopies`,e=>{n||=e(t)}),n==null?!t[Ys]:!n}ss.dragstart=(e,t)=>{let n=t,r=e.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let i=e.state.selection,a=i.empty?null:e.posAtCoords(ys(n)),o;if(!(a&&a.pos>=i.from&&a.pos<=(i instanceof z?i.to-1:i.to))){if(r&&r.mightDrag)o=z.create(e.state.doc,r.mightDrag.pos);else if(n.target&&H(n.target)){let t=e.docView.nearestDesc(n.target,!0);t&&t.node.type.spec.draggable&&t!=e.docView&&(o=z.create(e.state.doc,t.posBefore))}}let{dom:s,text:c,slice:l}=Wo(e,(o||e.state.selection).content());(!n.dataTransfer.files.length||!Ji||Yi>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(Us?`Text`:`text/html`,s.innerHTML),n.dataTransfer.effectAllowed=`copyMove`,Us||n.dataTransfer.setData(`text/plain`,c),e.dragging=new Js(l,Xs(e,n),o)},ss.dragend=e=>{let t=e.dragging;window.setTimeout(()=>{e.dragging==t&&(e.dragging=null)},50)},cs.dragover=cs.dragenter=(e,t)=>t.preventDefault(),cs.drop=(e,t)=>{try{Zs(e,t,e.dragging)}finally{e.dragging=null}};function Zs(e,t,n){if(!t.dataTransfer)return;let r=e.posAtCoords(ys(t));if(!r)return;let i=e.state.doc.resolve(r.pos),a=n&&n.slice;a?e.someProp(`transformPasted`,t=>{a=t(a,e,!1)}):a=Go(e,qs(t.dataTransfer),Us?null:t.dataTransfer.getData(`text/html`),!1,i);let o=!!(n&&Xs(e,t));if(e.someProp(`handleDrop`,n=>n(e,t,a||I.empty,o))){t.preventDefault();return}if(!a)return;t.preventDefault();let s=a?zn(e.state.doc,i.pos,a):i.pos;s??=i.pos;let c=e.state.tr;if(o){let{node:e}=n;e?e.replace(c):c.deleteSelection()}let l=c.mapping.map(s),u=a.openStart==0&&a.openEnd==0&&a.content.childCount==1,d=c.doc;if(u?c.replaceRangeWith(l,l,a.content.firstChild):c.replaceRange(l,l,a),c.doc.eq(d))return;let f=c.doc.resolve(l);if(u&&z.isSelectable(a.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(a.content.firstChild))c.setSelection(new z(f));else{let t=c.mapping.map(s);c.mapping.maps[c.mapping.maps.length-1].forEach((e,n,r,i)=>t=i),c.setSelection(So(e,f,c.doc.resolve(t)))}e.focus(),e.dispatch(c.setMeta(`uiEvent`,`drop`))}ss.focus=e=>{if(e.input.lastFocus=Date.now(),!e.focused){e.domObserver.stop(),e.dom.classList.add(`ProseMirror-focused`),e.domObserver.start(),e.focused=!0;let t=e.domSelectionRange();if(!e.domObserver.currentSelection.eq(t)){let{focusNode:n,focusOffset:r}=t;setTimeout(()=>{let t=e.domSelectionRange();t.focusNode==n&&t.focusOffset==r&&e.docView&&e.hasFocus()&&po(e)},20)}}},ss.blur=(e,t)=>{let n=t;e.focused&&=(e.domObserver.stop(),e.dom.classList.remove(`ProseMirror-focused`),e.domObserver.start(),n.relatedTarget&&e.dom.contains(n.relatedTarget)&&e.domObserver.currentSelection.clear(),!1)},ss.beforeinput=(e,t)=>{if(ea&&t.inputType==`deleteContentBackward`){e.domObserver.flushSoon();let{domChangeCount:t}=e.input;setTimeout(()=>{if(e.input.domChangeCount!=t||e.domObserver.pendingRecords().length||(e.dom.blur(),e.focus(),vs(e,`Backspace`)))return;let{$cursor:n}=e.state.selection;n&&n.pos>0&&e.dispatch(e.state.tr.delete(n.pos-1,n.pos).scrollIntoView())},50)}};for(let e in cs)ss[e]=cs[e];function Qs(e,t){if(e==t)return!0;for(let n in e)if(e[n]!==t[n])return!1;for(let n in t)if(!(n in e))return!1;return!0}var $s=class{constructor(e){this.frag=e,this.index=0,this.off=0}nodeAt(e){for(;this.off<=e&&this.index=a?null:new rc(i,a,this)}valid(e,t){return t.from=e&&(!i||i(o.spec))&&n.push(o.copy(o.from+r,o.to+r))}for(let a=0;ae){let o=this.children[a]+1;this.children[a+2].findInner(e-o,t-o,n,r+o,i)}}map(e,t,n){return this==oc||e.maps.length==0?this:this.mapInner(e,t,0,0,n||ac)}mapInner(t,n,r,i,a){let o;if(this.local.length){let e=new $s(n.content);for(let s=0;s{let o=t+r,s;if(s=dc(n,e,o)){for(i||=this.children.slice();aa&&n.to=t){this.children[e]==t&&(r=this.children[e+2]);break}let a=t+1,o=a+n.content.size;for(let e=0;ea&&t.type instanceof tc){let e=Math.max(a,t.from)-a,n=Math.min(o,t.to)-a;ee.map(t,n,ac));return e.from(r)}forChild(t,n){if(n.isLeaf)return U.empty;let r=[];for(let i=0;ie instanceof U)?t:t.reduce((e,t)=>e.concat(t instanceof U?t:t.members),[]))}}forEachSet(e){for(let t=0;t{let o=a-i-(n-e);for(let i=0;ia+t-r)continue;let c=s[i]+t-r;n>=c?s[i+1]=e<=c?-2:-1:e>=t&&o&&(s[i]+=o,s[i+1]+=o)}r+=o}),t=n.maps[e].map(t,-1)}let c=!1;for(let t=0;t=r.content.size){c=!0;continue}let d=n.map(e[t+1]+a,-1)-i,{index:f,offset:p}=r.content.findIndex(u),m=r.maybeChild(f);if(m&&p==u&&p+m.nodeSize==d){let r=s[t+2].mapInner(n,m,l+1,e[t]+a+1,o);r==oc?(s[t+1]=-2,c=!0):(s[t]=u,s[t+1]=d,s[t+2]=r)}else c=!0}if(c){let c=pc(uc(s,e,t,n,i,a,o),r,0,o);t=c.local;for(let e=0;en&&a.to{let s=dc(e,t,o+n);if(s){a=!0;let e=pc(s,t,n+o+1,r);e!=oc&&i.push(o,o+t.nodeSize,e)}});let o=lc(a?fc(e):e,-n).sort(mc);if(o.length){let e=new $s(t.content);for(let n=0;n0;)t++;e.splice(t,0,n)}function _c(e){let t=[];return e.someProp(`decorations`,n=>{let r=n(e.state);r&&r!=oc&&t.push(r)}),e.cursorWrapper&&t.push(U.create(e.state.doc,[e.cursorWrapper.deco])),sc.from(t)}var vc={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},yc=Wi&&Gi<=11,bc=class{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}},xc=class{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new bc,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(t=>{for(let e=0;ee.type==`childList`&&e.removedNodes.length||e.type==`characterData`&&e.oldValue.length>e.target.nodeValue.length)?this.flushSoon():Xi&&e.composing&&t.some(e=>e.type==`childList`&&e.target.nodeName==`TR`)?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),yc&&(this.onCharData=e=>{this.queue.push({target:e.target,type:`characterData`,oldValue:e.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,vc)),this.onCharData&&this.view.dom.addEventListener(`DOMCharacterDataModified`,this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let t=0;tthis.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener(`DOMCharacterDataModified`,this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener(`selectionchange`,this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener(`selectionchange`,this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(Co(this.view)){if(this.suppressingSelectionUpdates)return po(this.view);if(Wi&&Gi<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&wi(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t=new Set,n;for(let n=e.focusNode;n;n=bi(n))t.add(n);for(let r=e.anchorNode;r;r=bi(r))if(t.has(r)){n=r;break}let r=n&&this.view.docView.nearestDesc(n);if(r&&r.ignoreMutation({type:`selection`,target:Oi(n)?n.parentNode:n}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let n,r=!1;!this.suppressingSelectionUpdates&&Co(e)&&(n=e.domSelectionRange(),r=!this.currentSelection.eq(n)&&!this.ignoreSelectionChange(n));let i=-1,a=-1,o=!1,s=[];if(e.editable)for(let e=0;ee.nodeName==`BR`)&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46||Ji&&(e.composing||e.input.compositionEndedAt>Date.now()-50)&&t.some(e=>e.type==`childList`&&e.removedNodes.length))){for(let e of s)if(e.nodeName==`BR`&&e.parentNode){let t=e.nextSibling;for(;t&&H(t);){if(t.contentEditable==`false`){e.parentNode.removeChild(e);break}t=t.firstChild}}}else if(Ki&&s.length){let t=s.filter(e=>e.nodeName==`BR`);if(t.length==2){let[e,n]=t;e.parentNode&&e.parentNode.parentNode==n.parentNode?n.remove():e.remove()}else{let{focusNode:n}=this.currentSelection;for(let r of t){let t=r.parentNode;t&&t.nodeName==`LI`&&(!n||Dc(e,n)!=t)&&r.remove()}}}let c=null;i<0&&r&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)-1||r)&&(i>-1&&(e.docView.markDirty(i,a),wc(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,Oc(e,s)),this.handleDOMChange(i,a,o,s),e.docView&&e.docView.dirty?e.updateState(e.state):n&&!this.currentSelection.eq(n)&&po(e),n&&this.currentSelection.set(n))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let n=this.view.docView.nearestDesc(e.target);if(e.type==`attributes`&&(n==this.view.docView||e.attributeName==`contenteditable`||e.attributeName==`style`&&!e.oldValue&&!e.target.getAttribute(`style`))||!n||n.ignoreMutation(e))return null;if(e.type==`childList`){for(let n=0;na;e--){let t=i.childNodes[e-1],n=t.pmViewDesc;if(t.nodeName==`BR`&&!n){o=e;break}if(!n||n.size)break}let f=e.state.doc,p=e.someProp(`domParser`)||St.fromSchema(e.state.schema),m=f.resolve(s),h=null,g=p.parse(i,{topNode:m.parent,topMatch:m.parent.contentMatchAt(m.index()),topOpen:!0,from:a,to:o,preserveWhitespace:m.parent.type.whitespace!=`pre`||`full`,findPositions:u,ruleFromNode:Ac(r),context:m});if(u&&u[0].pos!=null){let e=u[0].pos,t=u[1]&&u[1].pos;t??=e,h={anchor:e+s,head:t+s}}return{doc:g,sel:h,from:s,to:c}}var Ac=e=>t=>{let n=t.pmViewDesc;if(n)return n.parseRule(e);if(t.nodeName==`BR`&&t.parentNode){if(Xi&&/^(ul|ol)$/i.test(t.parentNode.nodeName)){let e=document.createElement(`div`);return e.appendChild(document.createElement(`li`)),{skip:e}}if(t.parentNode.lastChild==t||Xi&&/^(tr|table)$/i.test(t.parentNode.nodeName))return{ignore:!0}}else if(t.nodeName==`IMG`&&t.getAttribute(`mark-placeholder`))return{ignore:!0};return null},jc=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function Mc(e,t,n,r,i){let a=e.input.compositionPendingChanges||(e.composing?e.input.compositionID:0);if(e.input.compositionPendingChanges=0,t<0){let t=e.input.lastSelectionTime>Date.now()-50?e.input.lastSelectionOrigin:null,n=uo(e,t);if(n&&!e.state.selection.eq(n)){if(Ji&&ea&&e.input.lastKeyCode===13&&Date.now()-100Date.now()-225||ea)&&i.some(e=>H(e)&&!jc.test(e.nodeName))&&(!m||m.endA>=m.endB)&&vs(e,`Enter`)){e.input.lastIOSEnter=0;return}if(!m){if(r&&c instanceof R&&!c.empty&&c.$head.sameParent(c.$anchor)&&!e.composing&&!(l.sel&&l.sel.anchor!=l.sel.head))m={start:c.from,endA:c.to,endB:c.to};else{if(l.sel){let t=Nc(e,e.state.doc,l.sel);if(t&&!t.eq(e.state.selection)){let n=e.state.tr.setSelection(t);a&&n.setMeta(`composition`,a),e.dispatch(n)}}return}}e.state.selection.frome.state.selection.from&&m.start<=e.state.selection.from+2&&e.state.selection.from>=l.from?m.start=e.state.selection.from:m.endA=e.state.selection.to-2&&e.state.selection.to<=l.to&&(m.endB+=e.state.selection.to-m.endA,m.endA=e.state.selection.to)),Wi&&Gi<=11&&m.endB==m.start+1&&m.endA==m.start&&m.start>l.from&&l.doc.textBetween(m.start-l.from-1,m.start-l.from+1)==` \xA0`&&(m.start--,m.endA--,m.endB--);let h=l.doc.resolveNoCache(m.start-l.from),g=l.doc.resolveNoCache(m.endB-l.from),_=u.resolve(m.start),v=h.sameParent(g)&&h.parent.inlineContent&&_.end()>=m.endA;if((Zi&&e.input.lastIOSEnter>Date.now()-225&&(!v||i.some(e=>e.nodeName==`DIV`||e.nodeName==`P`))||!v&&Ic(l.doc,h.pos,g.pos))&&vs(e,`Enter`)){e.input.lastIOSEnter=0;return}if(e.state.selection.anchor>m.start&&(v?m.endA>m.start&&m.endB==m.start:Fc(u,m.start,m.endA,h,g))&&vs(e,`Backspace`)){ea&&Ji&&e.domObserver.suppressSelectionUpdates();return}Ji&&m.endB==m.start&&(e.input.lastChromeDelete=Date.now()),ea&&!v&&h.start()!=g.start()&&g.parentOffset==0&&h.depth==g.depth&&l.sel&&l.sel.anchor==l.sel.head&&l.sel.head==m.endA&&(m.endB-=2,g=l.doc.resolveNoCache(m.endB-l.from),setTimeout(()=>vs(e,`Enter`),20));let y=m.start,b=m.endA,x=t=>{let n=t||e.state.tr.replace(y,b,l.doc.slice(m.start-l.from,m.endB-l.from));if(l.sel){let t=Nc(e,n.doc,l.sel);t&&!(Ji&&e.composing&&t.empty&&(m.start!=m.endB||e.input.lastChromeDeletepo(e),20));let t=x(e.state.tr.delete(y,b)),n=u.resolve(m.start).marksAcross(u.resolve(m.endA));n&&t.ensureMarks(n),e.dispatch(t)}else if(m.endA==m.endB&&(S=Pc(h.parent.content.cut(h.parentOffset,g.parentOffset),_.parent.content.cut(_.parentOffset,m.endA-_.start())))){let t=x(e.state.tr);S.type==`add`?t.addMark(y,b,S.mark):t.removeMark(y,b,S.mark),e.dispatch(t)}else if(h.parent.child(h.index()).isText&&h.index()==g.index()-+!g.textOffset){let t=h.parent.textBetween(h.parentOffset,g.parentOffset),n=()=>x(e.state.tr.insertText(t,y,b));e.someProp(`handleTextInput`,r=>r(e,y,b,t,n))||e.dispatch(n())}else e.dispatch(x())}else e.dispatch(x())}function Nc(e,t,n){return Math.max(n.anchor,n.head)>t.content.size?null:So(e,t.resolve(n.anchor),t.resolve(n.head))}function Pc(e,t){let n=e.firstChild.marks,r=t.firstChild.marks,i=n,a=r,o,s,c;for(let e=0;ee.mark(s.addToSet(e.marks));else if(i.length==0&&a.length==1)s=a[0],o=`remove`,c=e=>e.mark(s.removeFromSet(e.marks));else return null;let l=[];for(let e=0;en||Lc(o,!0,!1){e.isTextblock&&a>=t&&a0&&(t||e.indexAfter(r)==e.node(r).childCount);)r--,i++,t=!1;if(n){let t=e.node(r).maybeChild(e.indexAfter(r));for(;t&&!t.isLeaf;)t=t.firstChild,i++}return i}function Rc(e,t,n,r,i){let a=e.findDiffStart(t,n),o=n+e.size,s=n+t.size;if(a==null)return null;let{a:c,b:l}=e.findDiffEnd(t,o,s);if(i==`end`){let e=Math.max(0,a-Math.min(c,l));r-=c+e-a}if(c=c?a-r:0;a-=e,l=a+(l-c),c=a}else if(l=l?a-r:0;a-=e,c=a+(c-l),l=a}return{start:a,endA:c,endB:l}}var zc=class{constructor(e,t){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new us,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(Kc),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement(`div`),e&&(e.appendChild?e.appendChild(this.dom):typeof e==`function`?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=Hc(this),Vc(this),this.nodeViews=Wc(this),this.docView=Wa(this.state.doc,Bc(this),_c(this),this.dom,this),this.domObserver=new xc(this,(e,t,n,r)=>Mc(this,e,t,n,r)),this.domObserver.start(),ds(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let t in e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&ms(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Kc),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let e in this._props)t[e]=this._props[e];t.state=this.state;for(let n in e)t[n]=e[n];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){let n=this.state,r=!1,i=!1;e.storedMarks&&this.composing&&(zs(this),i=!0),this.state=e;let a=n.plugins!=e.plugins||this._props.plugins!=t.plugins;if(a||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let e=Wc(this);Gc(e,this.nodeViews)&&(this.nodeViews=e,r=!0)}(a||t.handleDOMEvents!=this._props.handleDOMEvents)&&ms(this),this.editable=Hc(this),Vc(this);let o=_c(this),s=Bc(this),c=n.plugins!=e.plugins&&!n.doc.eq(e.doc)?`reset`:e.scrollToSelection>n.scrollToSelection?`to selection`:`preserve`,l=r||!this.docView.matchesNode(e.doc,s,o);(l||!e.selection.eq(n.selection))&&(i=!0);let u=c==`preserve`&&i&&this.dom.style.overflowAnchor==null&&sa(this);if(i){this.domObserver.stop();let t=l&&(Wi||Ji)&&!this.composing&&!n.selection.empty&&!e.selection.empty&&Uc(n.selection,e.selection);if(l){let n=Ji?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=Bs(this)),(r||!this.docView.update(e.doc,s,o,this))&&(this.docView.updateOuterDeco(s),this.docView.destroy(),this.docView=Wa(e.doc,s,o,this.dom,this)),!n||this.trackWrites&&this.dom.contains(this.trackWrites)||(t=!0)}let i=this.input.mouseDown;t||!(i&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&To(this)&&i.delaySelUpdate())?po(this,t):(bo(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(n),this.dragging?.node&&!n.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,n),c==`reset`?this.dom.scrollTop=0:c==`to selection`?this.scrollToSelection():u&&la(u)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(e&&ki(this.dom,e)&&!this.someProp(`handleScrollToSelection`,e=>e(this))){if(this.state.selection instanceof z){let t=this.docView.domAfterPos(this.state.selection.from);H(t)&&oa(this,t.getBoundingClientRect(),e)}else oa(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let e=0;e0&&ee.ownerDocument.getSelection()),this._root=e}return e||document}updateRoot(){this._root=null}posAtCoords(e){return ba(this,e)}coordsAtPos(e,t=1){return wa(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,n=-1){let r=this.docView.posFromDOM(e,t,n);if(r==null)throw RangeError(`DOM position not inside the editor`);return r}endOfTextblock(e,t){return Pa(this,t||this.state,e)}pasteHTML(e,t){return Ks(this,``,e,!1,t||new ClipboardEvent(`paste`))}pasteText(e,t){return Ks(this,e,null,!0,t||new ClipboardEvent(`paste`))}serializeForClipboard(e){return Wo(this,e)}destroy(){this.docView&&(ps(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],_c(this),this),this.dom.textContent=``):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Ci())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return _s(this,e)}domSelectionRange(){let e=this.dom.isConnected!==!1&&this.domSelection();return e?Xi&&this.root.nodeType===11&&Ii(this.dom.ownerDocument)==this.dom&&Ec(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}};zc.prototype.dispatch=function(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))};function Bc(e){let t=Object.create(null);return t.class=`ProseMirror`,t.contenteditable=String(e.editable),e.someProp(`attributes`,n=>{if(typeof n==`function`&&(n=n(e.state)),n)for(let e in n)e==`class`?t.class+=` `+n[e]:e==`style`?t.style=(t.style?t.style+`;`:``)+n[e]:!t[e]&&e!=`contenteditable`&&e!=`nodeName`&&(t[e]=String(n[e]))}),t.translate||=`no`,[rc.node(0,e.state.doc.content.size,t)]}function Vc(e){if(e.markCursor){let t=document.createElement(`img`);t.className=`ProseMirror-separator`,t.setAttribute(`mark-placeholder`,`true`),t.setAttribute(`alt`,``),e.cursorWrapper={dom:t,deco:rc.widget(e.state.selection.from,t,{raw:!0,marks:e.markCursor})}}else e.cursorWrapper=null}function Hc(e){return!e.someProp(`editable`,t=>t(e.state)===!1)}function Uc(e,t){let n=Math.min(e.$anchor.sharedDepth(e.head),t.$anchor.sharedDepth(t.head));return e.$anchor.start(n)!=t.$anchor.start(n)}function Wc(e){let t=Object.create(null);function n(e){for(let n in e)Object.prototype.hasOwnProperty.call(t,n)||(t[n]=e[n])}return e.someProp(`nodeViews`,n),e.someProp(`markViews`,n),t}function Gc(e,t){let n=0,r=0;for(let r in e){if(e[r]!=t[r])return!0;n++}for(let e in t)r++;return n!=r}function Kc(e){if(e.spec.state||e.spec.filterTransaction||e.spec.appendTransaction)throw RangeError(`Plugins passed directly to the view must not have a state component`)}for(var qc={8:`Backspace`,9:`Tab`,10:`Enter`,12:`NumLock`,13:`Enter`,16:`Shift`,17:`Control`,18:`Alt`,20:`CapsLock`,27:`Escape`,32:` `,33:`PageUp`,34:`PageDown`,35:`End`,36:`Home`,37:`ArrowLeft`,38:`ArrowUp`,39:`ArrowRight`,40:`ArrowDown`,44:`PrintScreen`,45:`Insert`,46:`Delete`,59:`;`,61:`=`,91:`Meta`,92:`Meta`,106:`*`,107:`+`,108:`,`,109:`-`,110:`.`,111:`/`,144:`NumLock`,145:`ScrollLock`,160:`Shift`,161:`Shift`,162:`Control`,163:`Control`,164:`Alt`,165:`Alt`,173:`-`,186:`;`,187:`=`,188:`,`,189:`-`,190:`.`,191:`/`,192:"`",219:`[`,220:`\\`,221:`]`,222:`'`},Jc={48:`)`,49:`!`,50:`@`,51:`#`,52:`$`,53:`%`,54:`^`,55:`&`,56:`*`,57:`(`,59:`:`,61:`+`,173:`_`,186:`:`,187:`+`,188:`<`,189:`_`,190:`>`,191:`?`,192:`~`,219:`{`,220:`|`,221:`}`,222:`"`},Yc=typeof navigator<`u`&&/Mac/.test(navigator.platform),Xc=typeof navigator<`u`&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),Zc=0;Zc<10;Zc++)qc[48+Zc]=qc[96+Zc]=String(Zc);for(var Zc=1;Zc<=24;Zc++)qc[Zc+111]=`F`+Zc;for(var Zc=65;Zc<=90;Zc++)qc[Zc]=String.fromCharCode(Zc+32),Jc[Zc]=String.fromCharCode(Zc);for(var Qc in qc)Jc.hasOwnProperty(Qc)||(Jc[Qc]=qc[Qc]);function $c(e){var t=!(Yc&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||Xc&&e.shiftKey&&e.key&&e.key.length==1||e.key==`Unidentified`)&&e.key||(e.shiftKey?Jc:qc)[e.keyCode]||e.key||`Unidentified`;return t==`Esc`&&(t=`Escape`),t==`Del`&&(t=`Delete`),t==`Left`&&(t=`ArrowLeft`),t==`Up`&&(t=`ArrowUp`),t==`Right`&&(t=`ArrowRight`),t==`Down`&&(t=`ArrowDown`),t}var el=typeof navigator<`u`&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),tl=typeof navigator<`u`&&/Win/.test(navigator.platform);function nl(e){let t=e.split(/-(?!$)/),n=t[t.length-1];n==`Space`&&(n=` `);let r,i,a,o;for(let e=0;e=t?cl.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},cl.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},cl.prototype.forEach=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length),t<=n?this.forEachInner(e,t,n,0):this.forEachInvertedInner(e,t,n,0)},cl.prototype.map=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length);var r=[];return this.forEach(function(t,n){return r.push(e(t,n))},t,n),r},cl.from=function(e){return e instanceof cl?e:e&&e.length?new ll(e):cl.empty};var ll=function(e){function t(t){e.call(this),this.values=t}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var n={length:{configurable:!0},depth:{configurable:!0}};return t.prototype.flatten=function(){return this.values},t.prototype.sliceInner=function(e,n){return e==0&&n==this.length?this:new t(this.values.slice(e,n))},t.prototype.getInner=function(e){return this.values[e]},t.prototype.forEachInner=function(e,t,n,r){for(var i=t;i=n;i--)if(e(this.values[i],r+i)===!1)return!1},t.prototype.leafAppend=function(e){if(this.length+e.length<=sl)return new t(this.values.concat(e.flatten()))},t.prototype.leafPrepend=function(e){if(this.length+e.length<=sl)return new t(e.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(t.prototype,n),t}(cl);cl.empty=new ll([]);var ul=function(e){function t(t,n){e.call(this),this.left=t,this.right=n,this.length=t.length+n.length,this.depth=Math.max(t.depth,n.depth)+1}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},t.prototype.getInner=function(e){return ei&&this.right.forEachInner(e,Math.max(t-i,0),Math.min(this.length,n)-i,r+i)===!1)return!1},t.prototype.forEachInvertedInner=function(e,t,n,r){var i=this.left.length;if(t>i&&this.right.forEachInvertedInner(e,t-i,Math.max(n,i)-i,r+i)===!1||n=n?this.right.slice(e-n,t-n):this.left.slice(e,n).append(this.right.slice(0,t-n))},t.prototype.leafAppend=function(e){var n=this.right.leafAppend(e);if(n)return new t(this.left,n)},t.prototype.leafPrepend=function(e){var n=this.left.leafPrepend(e);if(n)return new t(n,this.right)},t.prototype.appendInner=function(e){return this.left.depth>=Math.max(this.right.depth,e.depth)+1?new t(this.left,new t(this.right,e)):new t(this,e)},t}(cl),dl=500,fl=class e{constructor(e,t){this.items=e,this.eventCount=t}popEvent(t,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let i,a;n&&(i=this.remapping(r,this.items.length),a=i.maps.length);let o=t.tr,s,c,l=[],u=[];return this.items.forEach((t,n)=>{if(!t.step)i||(i=this.remapping(r,n+1),a=i.maps.length),a--,u.push(t);else{if(i){u.push(new ml(t.map));let e=t.step.map(i.slice(a)),n;e&&o.maybeStep(e).doc&&(n=o.mapping.maps[o.mapping.maps.length-1],l.push(new ml(n,void 0,void 0,l.length+u.length))),a--,n&&i.appendMap(n,a)}else o.maybeStep(t.step);if(t.selection)return s=i?t.selection.map(i.slice(a)):t.selection,c=new e(this.items.slice(0,r).append(u.reverse().concat(l)),this.eventCount-1),!1}},this.items.length,0),{remaining:c,transform:o,selection:s}}addTransform(t,n,r,i){let a=[],o=this.eventCount,s=this.items,c=!i&&s.length?s.get(s.length-1):null;for(let e=0;egl&&(s=pl(s,l),o-=l),new e(s.append(a),o)}remapping(e,t){let n=new en;return this.items.forEach((t,r)=>{let i=t.mirrorOffset!=null&&r-t.mirrorOffset>=e?n.maps.length-t.mirrorOffset:void 0;n.appendMap(t.map,i)},e,t),n}addMaps(t){return this.eventCount==0?this:new e(this.items.append(t.map(e=>new ml(e))),this.eventCount)}rebased(t,n){if(!this.eventCount)return this;n=Math.min(this.items.length,n);let r=[],i=this.items.length-n,a=t.mapping,o=t.steps.length,s=this.eventCount;this.items.forEach(e=>{e.selection&&s--},i);let c=n;this.items.forEach(e=>{let n=a.getMirror(--c);if(n==null)return;o=Math.min(o,n);let i=a.maps[n];if(e.step){let o=t.steps[n].invert(t.docs[n]),l=e.selection&&e.selection.map(a.slice(c+1,n));l&&s++,r.push(new ml(i,o,l))}else r.push(new ml(i))},i);let l=[];for(let e=n;edl&&(d=d.compress(this.items.length-r.length)),d}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(t=this.items.length){let n=this.remapping(0,t),r=n.maps.length,i=[],a=0;return this.items.forEach((e,o)=>{if(o>=t)i.push(e),e.selection&&a++;else if(e.step){let t=e.step.map(n.slice(r)),o=t&&t.getMap();if(r--,o&&n.appendMap(o,r),t){let s=e.selection&&e.selection.map(n.slice(r));s&&a++;let c=new ml(o.invert(),t,s),l,u=i.length-1;(l=i.length&&i[u].merge(c))?i[u]=l:i.push(c)}}else e.map&&r--},this.items.length,0),new e(cl.from(i.reverse()),a)}};fl.empty=new fl(cl.empty,0);function pl(e,t){let n;return e.forEach((e,r)=>{if(e.selection&&t--==0)return n=r,!1}),e.slice(n)}var ml=class e{constructor(e,t,n,r){this.map=e,this.step=t,this.selection=n,this.mirrorOffset=r}merge(t){if(this.step&&t.step&&!t.selection){let n=t.step.merge(this.step);if(n)return new e(n.getMap().invert(),n,this.selection)}}},hl=class{constructor(e,t,n,r,i){this.done=e,this.undone=t,this.prevRanges=n,this.prevTime=r,this.prevComposition=i}},gl=20;function _l(e,t,n,r){let i=n.getMeta(El),a;if(i)return i.historyState;n.getMeta(Dl)&&(e=new hl(e.done,e.undone,null,0,-1));let o=n.getMeta(`appendedTransaction`);if(n.steps.length==0)return e;if(o&&o.getMeta(El))return o.getMeta(El).redo?new hl(e.done.addTransform(n,void 0,r,wl(t)),e.undone,yl(n.mapping.maps),e.prevTime,e.prevComposition):new hl(e.done,e.undone.addTransform(n,void 0,r,wl(t)),null,e.prevTime,e.prevComposition);if(n.getMeta(`addToHistory`)!==!1&&!(o&&o.getMeta(`addToHistory`)===!1)){let i=n.getMeta(`composition`),a=e.prevTime==0||!o&&e.prevComposition!=i&&(e.prevTime<(n.time||0)-r.newGroupDelay||!vl(n,e.prevRanges)),s=o?bl(e.prevRanges,n.mapping):yl(n.mapping.maps);return new hl(e.done.addTransform(n,a?t.selection.getBookmark():void 0,r,wl(t)),fl.empty,s,n.time,i??e.prevComposition)}return(a=n.getMeta(`rebased`))?new hl(e.done.rebased(n,a),e.undone.rebased(n,a),bl(e.prevRanges,n.mapping),e.prevTime,e.prevComposition):new hl(e.done.addMaps(n.mapping.maps),e.undone.addMaps(n.mapping.maps),bl(e.prevRanges,n.mapping),e.prevTime,e.prevComposition)}function vl(e,t){if(!t)return!1;if(!e.docChanged)return!0;let n=!1;return e.mapping.maps[0].forEach((e,r)=>{for(let i=0;i=t[i]&&(n=!0)}),n}function yl(e){let t=[];for(let n=e.length-1;n>=0&&t.length==0;n--)e[n].forEach((e,n,r,i)=>t.push(r,i));return t}function bl(e,t){if(!e)return null;let n=[];for(let r=0;r{let i=El.getState(n);if(!i||(e?i.undone:i.done).eventCount==0)return!1;if(r){let a=xl(i,n,e);a&&r(t?a.scrollIntoView():a)}return!0}}var Al=kl(!1,!0),jl=kl(!0,!0);function Ml(e){return e.getMeta(El)!=null}function Nl(e){let{state:t,transaction:n}=e,{selection:r}=n,{doc:i}=n,{storedMarks:a}=n;return{...t,apply:t.apply.bind(t),applyTransaction:t.applyTransaction.bind(t),plugins:t.plugins,schema:t.schema,reconfigure:t.reconfigure.bind(t),toJSON:t.toJSON.bind(t),get storedMarks(){return a},get selection(){return r},get doc(){return i},get tr(){return r=n.selection,i=n.doc,a=n.storedMarks,n}}}var Pl=class e{constructor(e){this.editor=e.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=e.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){let{rawCommands:e,editor:t,state:n}=this,{view:r}=t,{tr:i}=n,a=this.buildProps(i);return Object.fromEntries(Object.entries(e).map(([e,t])=>[e,(...e)=>{let n=t(...e)(a);return!i.getMeta(`preventDispatch`)&&!this.hasCustomState&&r.dispatch(i),n}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(e,t=!0){let{rawCommands:n,editor:r,state:i}=this,{view:a}=r,o=[],s=!!e,c=e||i.tr,l=()=>(!s&&t&&!c.getMeta(`preventDispatch`)&&!this.hasCustomState&&a.dispatch(c),o.every(e=>e===!0)),u={...Object.fromEntries(Object.entries(n).map(([e,n])=>[e,(...e)=>{let r=this.buildProps(c,t),i=n(...e)(r);return o.push(i),u}])),run:l};return u}static createFakeChain(){let e=new Proxy({},{get:(t,n)=>{if(n!==`then`)return n===`run`?()=>!1:()=>e}});return e}createCan(e){let{rawCommands:t,state:n}=this,r=e||n.tr,i=this.buildProps(r,!1);return{...Object.fromEntries(Object.entries(t).map(([e,t])=>[e,(...e)=>t(...e)({...i,dispatch:void 0})])),chain:()=>this.createChain(r,!1)}}static createFallbackCan(){let t=e.createFakeChain();return new Proxy({chain:()=>t},{get:(e,t)=>{if(t!==`then`)return t===`chain`?e.chain:()=>!1}})}buildProps(e,t=!0){let{rawCommands:n,editor:r,state:i}=this,{view:a}=r,o={tr:e,editor:r,view:a,state:Nl({state:i,transaction:e}),dispatch:t?()=>void 0:void 0,chain:()=>this.createChain(e,t),can:()=>this.createCan(e),get commands(){return Object.fromEntries(Object.entries(n).map(([e,t])=>[e,(...e)=>t(...e)(o)]))}};return o}},Fl=()=>({editor:e,view:t})=>(requestAnimationFrame(()=>{if(!e.isDestroyed){var n;t.dom.blur(),(n=window)==null||(n=n.getSelection())==null||n.removeAllRanges()}}),!0),Il=(e=!0)=>({commands:t})=>t.setContent(``,{emitUpdate:e}),Ll=()=>({tr:e,dispatch:t})=>{let{selection:n}=e,{ranges:r}=n;if(!t)return!0;let i=e.mapping.maps.length;return r.forEach(({$from:t,$to:n})=>{let r=t.pos,a=n.pos,o=e.mapping.slice(i),s=1;e.doc.nodesBetween(o.map(r),o.map(a),(t,n)=>{s=Math.max(s,e.doc.resolve(n).depth+1)});for(let t=0;t{if(t.type.isText)return;e.mapping.maps.length!==s&&(s=e.mapping.maps.length,c=e.mapping.slice(n));let i=e.doc.resolve(c.map(r)),a=e.doc.resolve(c.map(r+t.nodeSize)),o=i.blockRange(a);if(!o)return;let l=yn(o);if(t.type.isTextblock){let{defaultType:t}=i.parent.contentMatchAt(i.index()),n=e.doc.nodeAt(o.start);t&&n&&!n.hasMarkup(t)&&t.validContent(n.content)&&e.setNodeMarkup(o.start,t)}(l||l===0)&&e.lift(o,l)}),e.doc.eq(t))break}}),!0},Rl=e=>t=>e(t),zl=()=>({state:e,dispatch:t})=>qr(e,t),Bl=(e,t)=>({editor:n,tr:r})=>{let{state:i}=n,a=i.doc.slice(e.from,e.to);r.deleteRange(e.from,e.to);let o=r.mapping.map(t);return r.insert(o,a.content),r.setSelection(new R(r.doc.resolve(Math.max(o-1,0)))),!0},Vl=()=>({tr:e,dispatch:t})=>{let{selection:n}=e,r=n.$anchor.node();if(r.content.size>0)return!1;let i=e.selection.$anchor;for(let n=i.depth;n>0;--n)if(i.node(n).type===r.type){if(t){let t=i.before(n),r=i.after(n);e.delete(t,r).scrollIntoView()}return!0}return!1};function Hl(e,t){if(typeof e==`string`){if(!t.nodes[e])throw Error(`There is no node type named '${e}'. Maybe you forgot to add the extension?`);return t.nodes[e]}return e}var Ul=e=>({tr:t,state:n,dispatch:r})=>{let i=Hl(e,n.schema),a=t.selection.$anchor;for(let e=a.depth;e>0;--e)if(a.node(e).type===i){if(r){let n=a.before(e),r=a.after(e);t.delete(n,r).scrollIntoView()}return!0}return!1},Wl=e=>({tr:t,dispatch:n})=>{let{from:r,to:i}=e;return n&&t.delete(r,i),!0},Gl=e=>e.content?/^text(\*|\+)/.test(e.content):!1,Kl=(e,t,n)=>{if(!e.parent.isInline||n===`left`&&e.pos>e.start()||n===`right`&&e.pos({from:Kl(e,n,`left`),to:Kl(t,n,`right`)}),Jl=()=>({state:e,dispatch:t})=>{if(e.selection.empty)return!1;if(t){let n=e.tr,{ranges:r}=e.selection,i=e.selection instanceof R?e.selection.$from.marksAcross(e.selection.$to):null,a=n.steps.length;r.forEach(t=>{let r=n.mapping.slice(a),{from:i,to:o}=ql(n.doc.resolve(r.map(t.$from.pos)),n.doc.resolve(r.map(t.$to.pos)),e.schema);n.deleteRange(i,o)}),n.selection.empty||n.setSelection(R.near(n.doc.resolve(n.selection.from))),i&&n.ensureMarks(i),n.scrollIntoView(),t(n)}return!0},Yl=()=>({commands:e})=>e.keyboardShortcut(`Enter`),Xl=()=>({state:e,dispatch:t})=>Kr(e,t);function Zl(e){return Object.prototype.toString.call(e)===`[object RegExp]`}function Ql(e,t,n={strict:!0}){let r=Object.keys(t);return!r.length||r.every(r=>n.strict?t[r]===e[r]:Zl(t[r])?t[r].test(e[r]):t[r]===e[r])}function $l(e,t,n={}){return e.find(e=>e.type===t&&Ql(Object.fromEntries(Object.keys(n).map(t=>[t,e.attrs[t]])),n))}function eu(e,t,n={}){return!!$l(e,t,n)}function tu(e,t,n){if(!e||!t)return;let r=e.parent.childAfter(e.parentOffset);if(r.node&&r.node.marks.some(e=>e.type===t)||(r=e.parent.childBefore(e.parentOffset)),!r.node||!r.node.marks.some(e=>e.type===t))return;if(!n){let e=r.node.marks.find(e=>e.type===t);e&&(n=e.attrs)}if(!$l([...r.node.marks],t,n))return;let i=r.index,a=e.start()+r.offset,o=i+1,s=a+r.node.nodeSize;for(;i>0&&eu([...e.parent.child(i-1).marks],t,n);)--i,a-=e.parent.child(i).nodeSize;for(;o({tr:n,state:r,dispatch:i})=>{let a=nu(e,r.schema),{doc:o,selection:s}=n,{$from:c,from:l,to:u}=s;if(i){let e=tu(c,a,t);if(e&&e.from<=l&&e.to>=u){let t=R.create(o,e.from,e.to);n.setSelection(t)}}return!0},iu=e=>t=>{let n=typeof e==`function`?e(t):e;for(let e=0;e({editor:n,view:r,tr:i,dispatch:a})=>{t={scrollIntoView:!0,...t};let o=()=>{(lu()||cu())&&r.dom.focus(),uu()&&!lu()&&!cu()&&r.dom.focus({preventScroll:!0}),requestAnimationFrame(()=>{n.isDestroyed||(r.focus(),t?.scrollIntoView&&n.commands.scrollIntoView())})};try{if(r.hasFocus()&&e===null||e===!1)return!0}catch{return!1}if(a&&e===null&&!au(n.state.selection))return o(),!0;let s=su(i.doc,e)||n.state.selection,c=n.state.selection.eq(s);return a&&(c||i.setSelection(s),c&&i.storedMarks&&i.setStoredMarks(i.storedMarks),o()),!0},fu=(e,t)=>n=>e.every((e,r)=>t(e,{...n,index:r})),pu=(e,t)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},e,t),mu=e=>{let t=e.childNodes;for(let n=t.length-1;n>=0;--n){let r=t[n];r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?e.removeChild(r):r.nodeType===1&&mu(r)}return e};function hu(e){if(typeof window>`u`)throw Error(`[tiptap error]: there is no window object available, so this function cannot be used`);let t=`${e}`,n=new window.DOMParser().parseFromString(t,`text/html`).body;return mu(n)}function gu(e){return typeof e?.nodesBetween==`function`}function _u(e,t,n){if(gu(e))return e;let r=typeof e==`object`&&!!e;n={slice:!0,parseOptions:{},...n};let i=typeof e==`string`;if(r)try{if(Array.isArray(e)&&e.length>0)return P.fromArray(e.map(e=>t.nodeFromJSON(e)));let r=t.nodeFromJSON(e);return n.errorOnInvalidContent&&r.check(),r}catch(r){if(n.errorOnInvalidContent)throw Error(`[tiptap error]: Invalid JSON content`,{cause:r});return console.warn(`[tiptap warn]: Invalid content.`,`Passed value:`,e,`Error:`,r),_u(``,t,n)}if(i){if(n.errorOnInvalidContent){let r=!1,i=``,a=new vt({topNode:t.spec.topNode,marks:t.spec.marks,nodes:t.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:`inline*`,group:`block`,parseDOM:[{tag:`*`,getAttrs:e=>(r=!0,i=typeof e==`string`?e:e.outerHTML,null)}]}})});if(n.slice?St.fromSchema(a).parseSlice(hu(e),n.parseOptions):St.fromSchema(a).parse(hu(e),n.parseOptions),n.errorOnInvalidContent&&r)throw Error(`[tiptap error]: Invalid HTML content`,{cause:Error(`Invalid element found: ${i}`)})}let r=St.fromSchema(t);return n.slice?r.parseSlice(hu(e),n.parseOptions).content:r.parse(hu(e),n.parseOptions)}return _u(``,t,n)}function vu(e){return!(`type`in e)}function yu(e,t,n){let r=e.steps.length-1;if(r{o===0&&(o=r)}),e.setSelection(L.near(e.doc.resolve(o),n))}var bu=(e,t,n)=>({tr:r,dispatch:i,editor:a})=>{if(i){n={parseOptions:a.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};let i,o=e=>{a.emit(`contentError`,{editor:a,error:e,disableCollaboration:()=>{`collaboration`in a.storage&&typeof a.storage.collaboration==`object`&&a.storage.collaboration&&(a.storage.collaboration.isDisabled=!0)}})},s={preserveWhitespace:`full`,...n.parseOptions};if(!n.errorOnInvalidContent&&!a.options.enableContentCheck&&a.options.emitContentError)try{_u(t,a.schema,{parseOptions:s,errorOnInvalidContent:!0})}catch(e){o(e)}try{i=_u(t,a.schema,{parseOptions:s,errorOnInvalidContent:n.errorOnInvalidContent??a.options.enableContentCheck})}catch(e){return o(e),!1}let{from:c,to:l}=typeof e==`number`?{from:e,to:e}:{from:e.from,to:e.to},u=!0,d=!0,f=vu(i)?i.content:[i];if(f.forEach(e=>{e.check(),u=u?e.isText&&e.marks.length===0:!1,d=d?e.isBlock:!1}),c===l&&d){let{parent:e}=r.doc.resolve(c);e.isTextblock&&!e.type.spec.code&&!e.childCount&&(--c,l+=1)}let p;if(u)p=Array.isArray(t)?t.map(e=>e.text||``).join(``):gu(t)?f.map(e=>e.text??``).join(``):typeof t==`object`&&t&&t.text?t.text:t,r.insertText(p,c,l);else{p=P.from(f);let e=r.doc.resolve(c),t=e.node(),n=e.parentOffset===0,i=t.isText||t.isTextblock,a=t.content.size>0;n&&i&&a&&d&&(c=Math.max(0,c-1)),r.replaceWith(c,l,f)}n.updateSelection&&yu(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta(`applyInputRules`,{from:c,text:p}),n.applyPasteRules&&r.setMeta(`applyPasteRules`,{from:c,text:p})}return!0};function xu(e){for(let t=0;t({tr:t,dispatch:n,editor:r})=>{let{pos:i,attrs:a,content:o,updateSelection:s=!0}=e,c;c=typeof i==`number`?t.doc.resolve(i):i||t.selection.$from;let l=xu(c.parent.contentMatchAt(c.index()));if(!l)return!1;let u=Object.keys(l.spec.attrs||{}),d=a?Object.fromEntries(Object.entries(a).filter(([e])=>u.includes(e))):{},f;if(o){let e=_u(o,r.schema);f=l.createAndFill(d,e)}else f=l.createAndFill(d);return f?(n&&(t.insert(c.pos,f),s&&yu(t,t.steps.length-1,-1)),!0):!1},Cu=()=>({state:e,dispatch:t})=>Vr(e,t),wu=()=>({state:e,dispatch:t})=>Hr(e,t),Tu=()=>({state:e,dispatch:t})=>Ar(e,t),Eu=()=>({state:e,dispatch:t})=>Rr(e,t),Du=(e,t)=>{let n=e.resolve(t),r=n.nodeBefore,i=n.nodeAfter;return!r||!i?!1:!r.type.spec.isolating&&!i.type.spec.isolating},Ou=()=>({state:e,dispatch:t,tr:n})=>{try{let r=In(e.doc,e.selection.$from.pos,-1);return r==null||!Du(e.doc,r)?!1:(n.join(r,2),t&&t(n),!0)}catch{return!1}},ku=()=>({state:e,dispatch:t,tr:n})=>{try{let r=In(e.doc,e.selection.$from.pos,1);return r==null||!Du(e.doc,r)?!1:(n.join(r,2),t&&t(n),!0)}catch{return!1}},Au=()=>({state:e,dispatch:t})=>jr(e,t),ju=()=>({state:e,dispatch:t})=>Mr(e,t);function Mu(){return typeof navigator<`u`&&/Mac/.test(navigator.platform)}function Nu(e){let t=e.split(/-(?!$)/),n=t[t.length-1];n===`Space`&&(n=` `);let r,i,a,o;for(let e=0;e({editor:t,view:n,tr:r,dispatch:i})=>{let a=Nu(e).split(/-(?!$)/),o=a.find(e=>![`Alt`,`Ctrl`,`Meta`,`Shift`].includes(e)),s=new KeyboardEvent(`keydown`,{key:o===`Space`?` `:o,altKey:a.includes(`Alt`),ctrlKey:a.includes(`Ctrl`),metaKey:a.includes(`Meta`),shiftKey:a.includes(`Shift`),bubbles:!0,cancelable:!0});return t.captureTransaction(()=>{n.someProp(`handleKeyDown`,e=>e(n,s))})?.steps.forEach(e=>{let t=e.map(r.mapping);t&&i&&r.maybeStep(t)}),!0};function Fu(e,t,n={}){let{from:r,to:i,empty:a}=e.selection,o=t?Hl(t,e.schema):null,s=[];e.doc.nodesBetween(r,i,(e,t)=>{if(e.isText)return;let n=Math.max(r,t),a=Math.min(i,t+e.nodeSize);s.push({node:e,from:n,to:a})});let c=i-r,l=s.filter(e=>!o||o.name===e.node.type.name).filter(e=>Ql(e.node.attrs,n,{strict:!1}));return a?!!l.length:l.reduce((e,t)=>e+t.to-t.from,0)>=c}var Iu=(e,t={})=>({state:n,dispatch:r})=>Fu(n,Hl(e,n.schema),t)?Ur(n,r):!1,Lu=()=>({state:e,dispatch:t})=>Jr(e,t),Ru=e=>({state:t,dispatch:n})=>hi(Hl(e,t.schema))(t,n),zu=()=>({state:e,dispatch:t})=>Wr(e,t);function Bu(e,t){return t.nodes[e]?`node`:t.marks[e]?`mark`:null}function Vu(e,t){let n=typeof t==`string`?[t]:t;return Object.keys(e).reduce((t,r)=>(n.includes(r)||(t[r]=e[r]),t),{})}var Hu=(e,t)=>({tr:n,state:r,dispatch:i})=>{let a=null,o=null,s=Bu(typeof e==`string`?e:e.name,r.schema);if(!s)return!1;s===`node`&&(a=Hl(e,r.schema)),s===`mark`&&(o=nu(e,r.schema));let c=!1;return n.selection.ranges.forEach(e=>{r.doc.nodesBetween(e.$from.pos,e.$to.pos,(e,r)=>{a&&a===e.type&&(c=!0,i&&n.setNodeMarkup(r,void 0,Vu(e.attrs,t))),o&&e.marks.length&&e.marks.forEach(a=>{o===a.type&&(c=!0,i&&n.addMark(r,r+e.nodeSize,o.create(Vu(a.attrs,t))))})})}),c},Uu=()=>({tr:e,dispatch:t})=>(t&&e.scrollIntoView(),!0),Wu=()=>({tr:e,dispatch:t})=>{if(t){let t=new fr(e.doc);e.setSelection(t)}return!0},Gu=()=>({state:e,dispatch:t})=>Fr(e,t),Ku=()=>({state:e,dispatch:t})=>zr(e,t),qu=()=>({state:e,dispatch:t})=>Zr(e,t),Ju=()=>({state:e,dispatch:t})=>ri(e,t),Yu=()=>({state:e,dispatch:t})=>ni(e,t);function Xu(e,t,n={},r={}){return _u(e,t,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var Zu=(e,{errorOnInvalidContent:t,emitUpdate:n=!0,parseOptions:r={}}={})=>({editor:i,tr:a,dispatch:o,commands:s})=>{let{doc:c}=a;if(r.preserveWhitespace!==`full`){let s=Xu(e,i.schema,r,{errorOnInvalidContent:t??i.options.enableContentCheck});if(o){let e=vu(s)?s.content:[s];a.replaceWith(0,c.content.size,e).setMeta(`preventUpdate`,!n)}return!0}return o&&a.setMeta(`preventUpdate`,!n),s.insertContentAt({from:0,to:c.content.size},e,{parseOptions:r,errorOnInvalidContent:t??i.options.enableContentCheck})};function Qu(e,t){let n=nu(t,e.schema),{from:r,to:i,empty:a}=e.selection,o=[];a?(e.storedMarks&&o.push(...e.storedMarks),o.push(...e.selection.$head.marks())):e.doc.nodesBetween(r,i,e=>{o.push(...e.marks)});let s=o.find(e=>e.type.name===n.name);return s?{...s.attrs}:{}}function $u(e,t){let n=new ar(e);return t.forEach(e=>{e.steps.forEach(e=>{n.step(e)})}),n}function ed(e,t,n){let r=[];return e.nodesBetween(t.from,t.to,(e,t)=>{n(e)&&r.push({node:e,pos:t})}),r}function td(e,t){for(let n=e.depth;n>0;--n){let r=e.node(n);if(t(r))return{pos:n>0?e.before(n):0,start:e.start(n),depth:n,node:r}}}function nd(e){return t=>td(t.$from,e)}function W(e,t,n){return e.config[t]===void 0&&e.parent?W(e.parent,t,n):typeof e.config[t]==`function`?e.config[t].bind({...n,parent:e.parent?W(e.parent,t,n):null}):e.config[t]}function rd(e){return e.map(e=>{let t=W(e,`addExtensions`,{name:e.name,options:e.options,storage:e.storage});return t?[e,...rd(t())]:e}).flat(10)}function id(e,t){let n=It.fromSchema(t).serializeFragment(e),r=document.implementation.createHTMLDocument().createElement(`div`);return r.appendChild(n),r.innerHTML}function ad(e,t){let n=new Map;for(let t of e){let e=n.get(t.type)??new Map;e.set(t.name,t),n.set(t.type,e)}return[...Object.values(t.nodes),...Object.values(t.marks)].flatMap(e=>Object.entries(e.spec.attrs??{}).map(([t,r])=>{let i=n.get(e.name)?.get(t),a=Object.hasOwn(r,`default`);return{type:e.name,name:t,attribute:{rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,...i?.attribute,default:r.default,isRequired:!a,validate:r.validate}}}))}var od={content:`string`,marks:`string`,group:`string`,inline:`boolean`,atom:`boolean`,selectable:`boolean`,draggable:`boolean`,code:`boolean`,whitespace:[`pre`,`normal`],definingAsContext:`boolean`,definingForContent:`boolean`,defining:`boolean`,isolating:`boolean`,linebreakReplacement:`boolean`},sd={inclusive:`boolean`,excludes:`string`,group:`string`,spanning:`boolean`,code:`boolean`};function cd(e,t,n){return Object.fromEntries(Object.entries(t).flatMap(([t,r])=>{let i=e[t];if(i===void 0)return[];if(!(typeof r==`string`?typeof i===r:typeof i==`string`&&r.includes(i)))throw RangeError(`Invalid schemaSpec field '${n}.${t}'`);return[[t,i]]}))}function ld(e,t,n,r){return{...Object.fromEntries(Object.entries(t).filter(([e])=>e!==`attrs`&&!Object.hasOwn(r,e))),...cd(n,r,e),attrs:n.attrs}}function ud(e,t,n){for(let r of Object.keys(t))if(!Object.hasOwn(e,r))throw RangeError(`schemaSpec requires a local ${n} extension named '${r}'`);for(let r of Object.keys(e))if(!Object.hasOwn(t,r))throw RangeError(`Local ${n} extension '${r}' is not in schemaSpec`)}function dd(e,t){ud(e.nodes,t.nodes,`node`),ud(e.marks,t.marks,`mark`);let n=t.spec.nodes,r=t.spec.marks;return t.spec.nodes.forEach((t,r)=>{n=n.update(t,ld(t,e.nodes[t],r,od))}),t.spec.marks.forEach((t,n)=>{r=r.update(t,ld(t,e.marks[t],n,sd))}),{topNode:t.topNodeType.name,nodes:n,marks:r}}function fd(e){let t=e.filter((t,n)=>e.indexOf(t)!==n);return Array.from(new Set(t))}function pd(e){return{baseExtensions:e.filter(e=>e.type===`extension`),nodeExtensions:e.filter(e=>e.type===`node`),markExtensions:e.filter(e=>e.type===`mark`)}}function md(e){let t=[],{nodeExtensions:n,markExtensions:r}=pd(e),i=[...n,...r],a={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1},o=n.filter(e=>e.name!==`text`).map(e=>e.name),s=r.map(e=>e.name),c=[...o,...s];return e.forEach(e=>{let n=W(e,`addGlobalAttributes`,{name:e.name,options:e.options,storage:e.storage,extensions:i});n&&n().forEach(e=>{let n;n=Array.isArray(e.types)?e.types:e.types===`*`?c:e.types===`nodes`?o:e.types===`marks`?s:[],n.forEach(n=>{Object.entries(e.attributes).forEach(([e,r])=>{t.push({type:n,name:e,attribute:{...a,...r}})})})})}),i.forEach(e=>{let n=W(e,`addAttributes`,{name:e.name,options:e.options,storage:e.storage});if(!n)return;let r=n();Object.entries(r).forEach(([n,r])=>{let i={...a,...r};typeof i?.default==`function`&&(i.default=i.default()),i?.isRequired&&i?.default===void 0&&delete i.default,t.push({type:e.name,name:n,attribute:i})})}),t}function hd(e){return typeof e==`function`}function G(e,t=void 0,...n){return hd(e)?t?e.bind(t)(...n):e(...n):e}function gd(e={}){return Object.keys(e).length===0&&e.constructor===Object}function _d(e){let t=[],n=``,r=!1,i=!1,a=0,o=e.length;for(let s=0;s0){--a,n+=o;continue}if(o===`;`&&a===0){t.push(n),n=``;continue}}n+=o}}return n&&t.push(n),t}function vd(e){let t=[],n=_d(e||``),r=n.length;for(let e=0;e!!e).reduce((e,t)=>{let n={...e};return Object.entries(t).forEach(([e,t])=>{if(e===`__proto__`)Object.defineProperty(n,e,{configurable:!0,enumerable:!0,value:t,writable:!0});else if(!n[e])n[e]=t;else if(e===`class`){let r=t?String(t).split(` `):[],i=n[e]?n[e].split(` `):[],a=r.filter(e=>!i.includes(e));n[e]=[...i,...a].join(` `)}else if(e===`style`){let r=new Map([...vd(n[e]),...vd(t)]);n[e]=Array.from(r.entries()).map(([e,t])=>`${e}: ${t}`).join(`; `)}else n[e]=t}),n},{})}function yd(e,t){return t.filter(t=>t.type===e.type.name).filter(e=>e.attribute.rendered).map(t=>t.attribute.renderHTML?t.attribute.renderHTML(e.attrs)||{}:{[t.name]:e.attrs[t.name]}).reduce((e,t)=>K(e,t),{})}function bd(e){return typeof e==`string`?e.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(e):e===`true`||e!==`false`&&e:e}function xd(e,t){return`style`in e?e:{...e,getAttrs:n=>{let r=e.getAttrs?e.getAttrs(n):e.attrs;if(r===!1)return!1;let i=t.reduce((e,t)=>{let r=t.attribute.parseHTML?t.attribute.parseHTML(n):bd(n.getAttribute(t.name));return r==null?e:{...e,[t.name]:r}},{});return{...r,...i}}}}function Sd(e){return Object.fromEntries(Object.entries(e).filter(([e,t])=>e===`attrs`&&gd(t)?!1:t!=null))}function Cd(e){var t,n;let r={};return!(e!=null&&(t=e.attribute)!=null&&t.isRequired)&&`default`in(e?.attribute||{})&&(r.default=e.attribute.default),(e==null||(n=e.attribute)==null?void 0:n.validate)!==void 0&&(r.validate=e.attribute.validate),[e.name,r]}function wd(e,t,n=md(e)){let{nodeExtensions:r,markExtensions:i}=pd(e);return{topNode:r.find(e=>W(e,`topNode`))?.name,nodes:Object.fromEntries(r.map(r=>{let i=n.filter(e=>e.type===r.name),a={name:r.name,options:r.options,storage:r.storage,editor:t},o=Sd({...e.reduce((e,t)=>{let n=W(t,`extendNodeSchema`,a);return{...e,...n?n(r):{}}},{}),content:G(W(r,`content`,a)),marks:G(W(r,`marks`,a)),group:G(W(r,`group`,a)),inline:G(W(r,`inline`,a)),atom:G(W(r,`atom`,a)),selectable:G(W(r,`selectable`,a)),draggable:G(W(r,`draggable`,a)),code:G(W(r,`code`,a)),whitespace:G(W(r,`whitespace`,a)),linebreakReplacement:G(W(r,`linebreakReplacement`,a)),defining:G(W(r,`defining`,a)),isolating:G(W(r,`isolating`,a)),attrs:Object.fromEntries(i.map(Cd))}),s=G(W(r,`parseHTML`,a));s&&(o.parseDOM=s.map(e=>xd(e,i)));let c=W(r,`renderHTML`,a);c&&(o.toDOM=e=>c({node:e,HTMLAttributes:yd(e,i)}));let l=W(r,`renderText`,a);return l&&(o.toText=l),[r.name,o]})),marks:Object.fromEntries(i.map(r=>{let i=n.filter(e=>e.type===r.name),a={name:r.name,options:r.options,storage:r.storage,editor:t},o=Sd({...e.reduce((e,t)=>{let n=W(t,`extendMarkSchema`,a);return{...e,...n?n(r):{}}},{}),inclusive:G(W(r,`inclusive`,a)),excludes:G(W(r,`excludes`,a)),group:G(W(r,`group`,a)),spanning:G(W(r,`spanning`,a)),code:G(W(r,`code`,a)),attrs:Object.fromEntries(i.map(Cd))}),s=G(W(r,`parseHTML`,a));s&&(o.parseDOM=s.map(e=>xd(e,i)));let c=W(r,`renderHTML`,a);return c&&(o.toDOM=e=>c({mark:e,HTMLAttributes:yd(e,i)})),[r.name,o]}))}}function Td(e,t,n){if(n===void 0)return new vt(wd(e,t));let r=fd(e.filter(e=>e.type!==`extension`).map(e=>e.name));if(r.length)throw RangeError(`Duplicate local schema types: ${r.join(`, `)}`);let i=new vt(n);return new vt(dd(wd(e,t,ad(md(e),i)),i))}function Ed(e){return e.sort((e,t)=>{let n=W(e,`priority`)||100,r=W(t,`priority`)||100;return n>r?-1:+(ne.name));return n.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${n.map(e=>`'${e}'`).join(`, `)}]. This can lead to issues.`),t}function Od(e,t,n){let{from:r,to:i}=t,{blockSeparator:a=` + +`,textSerializers:o={}}=n||{},s=``;return e.nodesBetween(r,i,(e,n,c,l)=>{e.isBlock&&n>r&&(s+=a);let u=o?.[e.type.name];if(u)return c&&(s+=u({node:e,pos:n,parent:c,index:l,range:t})),!1;if(e.isText){var d;s+=e==null||(d=e.text)==null?void 0:d.slice(Math.max(r,n)-n,i-n)}}),s}function kd(e,t){return Od(e,{from:0,to:e.content.size},t)}function Ad(e){return Object.fromEntries(Object.entries(e.nodes).filter(([,e])=>e.spec.toText).map(([e,t])=>[e,t.spec.toText]))}function jd(e,t){let n=Hl(t,e.schema),{from:r,to:i}=e.selection,a=[];e.doc.nodesBetween(r,i,e=>{a.push(e)});let o=a.reverse().find(e=>e.type.name===n.name);return o?{...o.attrs}:{}}function Md(e,t){let n=Bu(typeof t==`string`?t:t.name,e.schema);return n===`node`?jd(e,t):n===`mark`?Qu(e,t):{}}function Nd(e,t=JSON.stringify){let n={};return e.filter(e=>{let r=t(e);return Object.prototype.hasOwnProperty.call(n,r)?!1:n[r]=!0})}function Pd(e){let t=Nd(e);return t.length===1?t:t.filter((e,n)=>!t.filter((e,t)=>t!==n).some(t=>e.oldRange.from>=t.oldRange.from&&e.oldRange.to<=t.oldRange.to&&e.newRange.from>=t.newRange.from&&e.newRange.to<=t.newRange.to))}function Fd(e){let{mapping:t,steps:n}=e,r=[],i=t.invert();return t.maps.forEach((e,a)=>{let o=[];if(e.ranges.length)e.forEach((e,t)=>{o.push({from:e,to:t})});else{let{from:e,to:t}=n[a];if(e===void 0||t===void 0)return;o.push({from:e,to:t})}let s=t.slice(a);o.forEach(({from:e,to:t})=>{let n=s.map(e,-1),a=s.map(t),o=i.map(n,-1),c=i.map(a);r.push({oldRange:{from:o,to:c},newRange:{from:n,to:a}})})}),Pd(r)}function Id(e,t,n){let r=[];return e===t?n.resolve(e).marks().forEach(t=>{let i=tu(n.resolve(e),t.type);i&&r.push({mark:t,...i})}):n.nodesBetween(e,t,(e,t)=>{e&&e?.nodeSize!==void 0&&r.push(...e.marks.map(n=>({from:t,to:t+e.nodeSize,mark:n})))}),r}var Ld=(e,t,n,r=20)=>{let i=e.doc.resolve(n),a=r,o=null;for(;a>0&&o===null;){let e=i.node(a);e?.type.name===t?o=e:--a}return[o,a]},Rd=e=>{let t=e.depth-1;if(t<0)return null;let n=e.index(t);return n===0?null:e.node(t).child(n-1)};function zd(e,t){return t.nodes[e]||t.marks[e]||null}function Bd(e,t,n){return Object.fromEntries(Object.entries(n).filter(([n])=>{let r=e.find(e=>e.type===t&&e.name===n);return r?r.attribute.keepOnSplit:!1}))}var Vd=(e,t=500)=>{let n=``,r=e.parentOffset;return e.parent.nodesBetween(Math.max(0,r-t),r,(e,t,i,a)=>{var o;let s=(o=e.type.spec).toText?.call(o,{node:e,pos:t,parent:i,index:a})||e.textContent||`%leaf%`;n+=e.isAtom&&!e.isText?s:s.slice(0,Math.max(0,r-t))}),n};function Hd(e,t,n={}){let{empty:r,ranges:i}=e.selection,a=t?nu(t,e.schema):null;if(r)return!!(e.storedMarks||e.selection.$from.marks()).filter(e=>!a||a.name===e.type.name).find(e=>Ql(e.attrs,n,{strict:!1}));let o=0,s=[];if(i.forEach(({$from:t,$to:n})=>{let r=t.pos,i=n.pos;e.doc.nodesBetween(r,i,(e,t)=>{if(a&&e.inlineContent&&!e.type.allowsMarkType(a))return!1;if(!e.isText&&!e.marks.length)return;let n=Math.max(r,t),c=Math.min(i,t+e.nodeSize),l=c-n;o+=l,s.push(...e.marks.map(e=>({mark:e,from:n,to:c})))})}),o===0)return!1;let c=s.filter(e=>!a||a.name===e.mark.type.name).filter(e=>Ql(e.mark.attrs,n,{strict:!1})).reduce((e,t)=>e+t.to-t.from,0),l=s.filter(e=>!a||e.mark.type!==a&&e.mark.type.excludes(a)).reduce((e,t)=>e+t.to-t.from,0);return(c>0?c+l:c)>=o}function Ud(e,t,n={}){if(!t)return Fu(e,null,n)||Hd(e,null,n);let r=Bu(t,e.schema);return r===`node`?Fu(e,t,n):r===`mark`&&Hd(e,t,n)}var Wd=(e,t)=>{let{$from:n,$to:r,$anchor:i}=e.selection;if(t){let n=nd(e=>e.type.name===t)(e.selection);if(!n)return!1;let r=e.doc.resolve(n.pos+1);return i.pos+1===r.end()}return!(r.parentOffset{let{$from:t,$to:n}=e.selection;return!(t.parentOffset>0||t.pos!==n.pos)};function Kd(e,t){return Array.isArray(t)?t.some(t=>(typeof t==`string`?t:t.name)===e.name):t}function qd(e,t){let{nodeExtensions:n}=pd(t),r=n.find(t=>t.name===e);if(!r)return!1;let i=G(W(r,`group`,{name:r.name,options:r.options,storage:r.storage}));return typeof i==`string`&&i.split(` `).includes(`list`)}function Jd(e,{checkChildren:t=!0,ignoreWhitespace:n=!1}={}){if(n){if(e.type.name===`hardBreak`)return!0;if(e.isText)return!/\S/.test(e.text??``)}if(e.isText)return!e.text;if(e.isAtom||e.isLeaf)return!1;if(e.content.childCount===0)return!0;if(t){let r=!0;return e.content.forEach(e=>{r!==!1&&(Jd(e,{ignoreWhitespace:n,checkChildren:t})||(r=!1))}),r}return!1}function Yd(e){return e instanceof z}function Xd(e){if(typeof e!=`object`||!e)return!1;let t=e;return typeof t.apply==`function`&&typeof t.getMap==`function`&&typeof t.invert==`function`&&typeof t.map==`function`&&typeof t.merge==`function`&&typeof t.toJSON==`function`}function Zd(e){if(typeof e!=`object`||!e)return!1;let t=e;if(!Xd(t))return!1;let n=t.toJSON();return!(typeof n!=`object`||!n||n.stepType!==`replace`)}var Qd=class e{constructor(e){this.position=e}static fromJSON(t){return new e(t.position)}toJSON(){return{position:this.position}}};function $d(e,t){let n=t.mapping.mapResult(e.position);return{position:new Qd(n.pos),mapResult:n}}function ef(e){return new Qd(e)}function tf(e,t,n){let{selection:r}=t,i=null;if(au(r)&&(i=r.$cursor),i){let t=e.storedMarks??i.marks();return i.parent.type.allowsMarkType(n)&&(!!n.isInSet(t)||!t.some(e=>e.type.excludes(n)))}let{ranges:a}=r;return a.some(({$from:t,$to:r})=>{let i=t.depth===0&&e.doc.inlineContent&&e.doc.type.allowsMarkType(n);return e.doc.nodesBetween(t.pos,r.pos,(e,t,r)=>{if(i)return!1;if(e.isInline){let t=!r||r.type.allowsMarkType(n),a=!!n.isInSet(e.marks)||!e.marks.some(e=>e.type.excludes(n));i=t&&a}return!i}),i})}var nf=(e,t={})=>({tr:n,state:r,dispatch:i})=>{let{selection:a}=n,{empty:o,ranges:s}=a,c=nu(e,r.schema);if(i){if(o){let e=Qu(r,c);n.addStoredMark(c.create({...e,...t}))}else s.forEach(e=>{let i=e.$from.pos,a=e.$to.pos;r.doc.nodesBetween(i,a,(e,r)=>{let o=Math.max(r,i),s=Math.min(r+e.nodeSize,a);e.marks.find(e=>e.type===c)?e.marks.forEach(e=>{c===e.type&&n.addMark(o,s,c.create({...e.attrs,...t}))}):n.addMark(o,s,c.create(t))})})}return tf(r,n,c)},rf=(e,t)=>({tr:n})=>(n.setMeta(e,t),!0),af=(e,t={})=>({state:n,dispatch:r,chain:i})=>{let a=Hl(e,n.schema),o;return n.selection.$anchor.sameParent(n.selection.$head)&&(o=n.selection.$anchor.parent.attrs),a.isTextblock?i().command(({commands:e})=>ai(a,{...o,...t})(n)?!0:e.clearNodes()).command(({state:e})=>ai(a,{...o,...t})(e,r)).run():(console.warn(`[tiptap warn]: Currently "setNode()" only supports text block nodes.`),!1)},of=e=>({tr:t,dispatch:n})=>{if(n){let{doc:n}=t,r=ou(e,0,n.content.size),i=z.create(n,r);t.setSelection(i)}return!0},sf=(e,t)=>({tr:n,state:r,dispatch:i})=>{let{selection:a}=r,o,s;return typeof t==`number`?(o=t,s=t):t&&`from`in t&&`to`in t?(o=t.from,s=t.to):(o=a.from,s=a.to),i&&n.doc.nodesBetween(o,s,(t,r)=>{t.isText||n.setNodeMarkup(r,void 0,{...t.attrs,dir:e})}),!0},cf=e=>({tr:t,dispatch:n})=>{if(n){let{doc:n}=t,{from:r,to:i}=typeof e==`number`?{from:e,to:e}:e,a=R.atStart(n).from,o=R.atEnd(n).to,s=ou(r,a,o),c=ou(i,a,o),l=R.create(n,s,c);t.setSelection(l)}return!0},lf=e=>({state:t,dispatch:n})=>vi(Hl(e,t.schema))(t,n);function uf(e,t){let n=e.storedMarks||e.selection.$to.parentOffset&&e.selection.$from.marks();if(n){let r=n.filter(e=>t?.includes(e.type.name));e.tr.ensureMarks(r)}}var df=({keepMarks:e=!0}={})=>({tr:t,state:n,dispatch:r,editor:i})=>{let{selection:a,doc:o}=t,{$from:s,$to:c}=a,l=i.extensionManager.attributes,u=Bd(l,s.node().type.name,s.node().attrs);if(a instanceof z&&a.node.isBlock)return!s.parentOffset||!jn(o,s.pos)?!1:(r&&(e&&uf(n,i.extensionManager.splittableMarks),t.split(s.pos).scrollIntoView()),!0);if(!s.parent.isBlock)return!1;let d=c.parentOffset===c.parent.content.size,f=s.depth===0?void 0:xu(s.node(-1).contentMatchAt(s.indexAfter(-1))),p=d&&f?[{type:f,attrs:u}]:void 0,m=a instanceof R&&!a.empty?wr.create({doc:t.doc,selection:a}).tr.deleteSelection():null,h=m?m.doc:t.doc,g=m?m.mapping.map(s.pos):s.pos,_=jn(h,g,1,p);if(!p&&!_&&jn(h,g,1,f?[{type:f}]:void 0)&&(_=!0,p=f?[{type:f,attrs:u}]:void 0),r){if(_){let e=t.steps.length;if(a instanceof R&&t.deleteSelection(),t.split(t.mapping.slice(e).map(s.pos),1,p),f&&!d&&!s.parentOffset&&s.parent.type!==f){let n=t.mapping.slice(e).map(s.before()),r=t.doc.resolve(n);s.node(-1).canReplaceWith(r.index(),r.index()+1,f)&&t.setNodeMarkup(t.mapping.slice(e).map(s.before()),f)}}e&&uf(n,i.extensionManager.splittableMarks),t.scrollIntoView()}return _},ff=(e,t={})=>({tr:n,state:r,dispatch:i,editor:a})=>{let o=Hl(e,r.schema),{$from:s,$to:c}=r.selection,l=r.selection.node;if(l&&l.isBlock||s.depth<2||!s.sameParent(c))return!1;let u=s.node(-1);if(u.type!==o)return!1;let d=a.extensionManager.attributes;if(s.parent.content.size===0&&s.node(-1).childCount===s.indexAfter(-1)){if(s.depth===2||s.node(-3).type!==o||s.index(-2)!==s.node(-2).childCount-1)return!1;if(i){let e=P.empty,r=s.index(-1)?1:s.index(-2)?2:3;for(let t=s.depth-r;t>=s.depth-3;--t)e=P.from(s.node(t).copy(e));let i=s.indexAfter(-1){if(u>-1)return!1;e.isTextblock&&e.content.size===0&&(u=t+1)}),u>-1&&n.setSelection(R.near(n.doc.resolve(u))),n.scrollIntoView()}return!0}let f=c.pos===s.end()?u.contentMatchAt(0).defaultType:null,p={...Bd(d,u.type.name,u.attrs),...t},m={...Bd(d,s.node().type.name,s.node().attrs),...t},h=s.parentOffset===0&&s.index(-1)===0,g=s.before(-1);n.delete(s.pos,c.pos);let _=h?u.attrs:p,v=f?[{type:o,attrs:_},{type:f,attrs:m}]:[{type:o,attrs:_}];if(!jn(n.doc,s.pos,2))return!1;if(i){let{selection:e,storedMarks:t}=r,{splittableMarks:o}=a.extensionManager,c=t||e.$to.parentOffset&&e.$from.marks();if(n.split(s.pos,2,v).scrollIntoView(),h&&n.setNodeMarkup(g,void 0,p),!c||!i)return!0;let l=c.filter(e=>o.includes(e.type.name));n.ensureMarks(l)}return!0};function pf(e,t,n){if(!e.validContent(t))return null;try{return e.create(n,t)}catch{return null}}function mf(e,t){if(e.pendingContent.length===0)return!0;let n=pf(t,P.from(e.pendingContent));return n?(e.items.push(n),e.pendingContent=[],!0):!1}function hf(e,t,n){return n.validContent(P.from([...t.pendingContent,e]))?(t.pendingContent.push(e),!0):!mf(t,n)||!n.validContent(P.from(e))?!1:(t.pendingContent.push(e),!0)}function gf(e,t,n,r){let i=r(e,n);if(!i)return!1;let a=pf(n.listType,P.from(i),e.attrs);return a?n.itemType.validContent(P.from([...t.pendingContent,a]))?(t.pendingContent.push(a),!0):mf(t,n.itemType)?(t.items.push(...i),!0):!1:!1}function _f(e,t,n){let r={items:[],pendingContent:[]};for(let i=0;ie!==t||(n=r,!1)),n}function bf(e){return!e||e===`1`?null:e}function xf(e,t){return bf(e)===bf(t)}var Sf=(e,t)=>{let n=nd(e=>e.type===t)(e.selection);if(!n)return!0;let r=e.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(r===void 0)return!0;let i=e.doc.nodeAt(r);return!(n.node.type===i?.type&&Nn(e.doc,n.pos))||!xf(n.node.attrs.type,i?.attrs.type)||e.join(n.pos),!0},Cf=(e,t)=>{let n=nd(e=>e.type===t)(e.selection);if(!n)return!0;let r=e.doc.resolve(n.start).after(n.depth);if(r===void 0)return!0;let i=e.doc.nodeAt(r);return!(n.node.type===i?.type&&Nn(e.doc,r))||!xf(n.node.attrs.type,i?.attrs.type)||e.join(r),!0};function wf(e){let t=e.doc,n=t.firstChild;if(!n)return null;let r=t.resolve(1),i=t.resolve(n.nodeSize-1);return R.between(r,i)}var Tf=(e,t,n,r={})=>({editor:i,tr:a,state:o,dispatch:s,chain:c,commands:l,can:u})=>{let{extensions:d,splittableMarks:f}=i.extensionManager,p=Hl(e,o.schema),m=Hl(t,o.schema),{selection:h,storedMarks:g}=o,{$from:_,$to:v}=h,y=_.blockRange(v),b=g||h.$to.parentOffset&&h.$from.marks();if(!y)return!1;let x=nd(e=>qd(e.type.name,d))(h),S=h.from===0&&h.to===o.doc.content.size,C=o.doc.content.content,w=C.length===1?C[0]:null,T=S&&w&&qd(w.type.name,d)?{node:w,pos:0,depth:0}:null,E=x??T,ee=!!x&&y.depth>=1&&y.depth-x.depth<=1,te=!!T;if((ee||te)&&E){if(E.node.type===p)return S&&te?c().command(({tr:e,dispatch:t})=>{let n=wf(e);return n?(e.setSelection(n),t&&t(e),!0):!1}).liftListItem(m).run():l.liftListItem(m);if(qd(E.node.type.name,d)&&p.validContent(E.node.content))return c().command(()=>(a.setNodeMarkup(E.pos,p),!0)).command(()=>Sf(a,p)).command(()=>Cf(a,p)).run();if(qd(E.node.type.name,d)){let e=E.node.firstChild?.type;if(e&&e!==m){let e=vf(E.node,{listType:p,itemType:m,isListNode:e=>qd(e.type.name,d)}),t=e?P.from(e):null;return!t||!p.validContent(t)?!1:c().command(()=>{let{$anchor:e,$head:n}=a.selection,i=e.parent,o=n.parent,s=e.parentOffset,c=n.parentOffset,l;try{l=p.create(r,t)}catch{return!1}if(a.replaceWith(E.pos,E.pos+E.node.nodeSize,l),i.inlineContent&&o.inlineContent){let e=yf(l,i),t=yf(l,o);if(e!==null&&t!==null){let n=E.pos+e+2+s,r=E.pos+t+2+c;a.setSelection(R.create(a.doc,n,r))}}return!0}).command(()=>Sf(a,p)).command(()=>Cf(a,p)).run()}}}return!n||!b||!s?c().command(()=>u().wrapInList(p,r)?!0:l.clearNodes()).wrapInList(p,r).command(()=>Sf(a,p)).command(()=>Cf(a,p)).run():c().command(()=>{let e=u().wrapInList(p,r),t=b.filter(e=>f.includes(e.type.name));return a.ensureMarks(t),e?!0:l.clearNodes()}).wrapInList(p,r).command(()=>Sf(a,p)).command(()=>Cf(a,p)).run()},Ef=(e,t={},n={})=>({state:r,commands:i})=>{let{extendEmptyMarkRange:a=!1}=n,o=nu(e,r.schema);return Hd(r,o,t)?i.unsetMark(o,{extendEmptyMarkRange:a}):i.setMark(o,t)},Df=(e,t,n={})=>({state:r,commands:i})=>{let a=Hl(e,r.schema),o=Hl(t,r.schema),s=Fu(r,a,n),c;return r.selection.$anchor.sameParent(r.selection.$head)&&(c=r.selection.$anchor.parent.attrs),s?i.setNode(o,c):i.setNode(a,{...c,...n})},Of=(e,t={})=>({state:n,commands:r})=>{let i=Hl(e,n.schema);return Fu(n,i,t)?r.lift(i):r.wrapIn(i,t)},kf=()=>({state:e,dispatch:t})=>{let n=e.plugins;for(let r=0;r=0;--e)t.step(n.steps[e].invert(n.docs[e]));if(a.text){let n=t.doc.resolve(a.from).marks();t.replaceWith(a.from,a.to,e.schema.text(a.text,n))}else t.delete(a.from,a.to)}return!0}}return!1},Af=(e={})=>({tr:t,dispatch:n,editor:r})=>{let{ignoreClearable:i=!1}=e,{selection:a}=t,{empty:o,ranges:s}=a;if(o)return!0;let{nonClearableMarks:c}=r.extensionManager;if(n){let e=Object.values(r.schema.marks).filter(e=>i||!c.includes(e.name));s.forEach(n=>{for(let r of e)t.removeMark(n.$from.pos,n.$to.pos,r)})}return!0},jf=(e,t={})=>({tr:n,state:r,dispatch:i})=>{let{extendEmptyMarkRange:a=!1}=t,{selection:o}=n,s=nu(e,r.schema),{$from:c,empty:l,ranges:u}=o;if(!i)return!0;if(l&&a){let{from:e,to:t}=o,r=tu(c,s,c.marks().find(e=>e.type===s)?.attrs);r&&(e=r.from,t=r.to),n.removeMark(e,t,s)}else u.forEach(e=>{n.removeMark(e.$from.pos,e.$to.pos,s)});return n.removeStoredMark(s),!0},Mf=e=>({tr:t,state:n,dispatch:r})=>{let{selection:i}=n,a,o;return typeof e==`number`?(a=e,o=e):e&&`from`in e&&`to`in e?(a=e.from,o=e.to):(a=i.from,o=i.to),r&&t.doc.nodesBetween(a,o,(e,n)=>{if(e.isText)return;let r={...e.attrs};delete r.dir,t.setNodeMarkup(n,void 0,r)}),!0},Nf=(e,t={})=>({tr:n,state:r,dispatch:i})=>{let a=null,o=null,s=Bu(typeof e==`string`?e:e.name,r.schema);if(!s)return!1;s===`node`&&(a=Hl(e,r.schema)),s===`mark`&&(o=nu(e,r.schema));let c=!1;return n.selection.ranges.forEach(e=>{let s=e.$from.pos,l=e.$to.pos,u,d,f,p;n.selection.empty?r.doc.nodesBetween(s,l,(e,t)=>{a&&a===e.type&&(c=!0,f=Math.max(t,s),p=Math.min(t+e.nodeSize,l),u=t,d=e)}):r.doc.nodesBetween(s,l,(e,r)=>{r=s&&r<=l&&(a&&a===e.type&&(c=!0,i&&n.setNodeMarkup(r,void 0,{...e.attrs,...t})),o&&e.marks.length&&e.marks.forEach(a=>{if(o===a.type&&(c=!0,i)){let i=Math.max(r,s),c=Math.min(r+e.nodeSize,l);n.addMark(i,c,o.create({...a.attrs,...t}))}}))}),d&&(u!==void 0&&i&&n.setNodeMarkup(u,void 0,{...d.attrs,...t}),o&&d.marks.length&&d.marks.forEach(e=>{o===e.type&&i&&n.addMark(f,p,o.create({...e.attrs,...t}))}))}),c},Pf=new V(`__tiptap_decorations__`),Ff=e=>({tr:t,dispatch:n})=>(n&&t.setMeta(Pf,{type:`force`,name:e}),!0),If=(e,t={})=>({state:n,dispatch:r})=>ii(Hl(e,n.schema),t)(n,r),Lf=(e,t={})=>({state:n,dispatch:r})=>di(Hl(e,n.schema),t)(n,r),Rf=ve({blur:()=>Fl,clearContent:()=>Il,clearNodes:()=>Ll,command:()=>Rl,createParagraphNear:()=>zl,cut:()=>Bl,deleteCurrentNode:()=>Vl,deleteNode:()=>Ul,deleteRange:()=>Wl,deleteSelection:()=>Jl,enter:()=>Yl,exitCode:()=>Xl,extendMarkRange:()=>ru,first:()=>iu,focus:()=>du,forEach:()=>fu,insertContent:()=>pu,insertContentAt:()=>bu,insertDefaultBlock:()=>Su,joinBackward:()=>Tu,joinDown:()=>wu,joinForward:()=>Eu,joinItemBackward:()=>Ou,joinItemForward:()=>ku,joinTextblockBackward:()=>Au,joinTextblockForward:()=>ju,joinUp:()=>Cu,keyboardShortcut:()=>Pu,lift:()=>Iu,liftEmptyBlock:()=>Lu,liftListItem:()=>Ru,newlineInCode:()=>zu,resetAttributes:()=>Hu,scrollIntoView:()=>Uu,selectAll:()=>Wu,selectNodeBackward:()=>Gu,selectNodeForward:()=>Ku,selectParentNode:()=>qu,selectTextblockEnd:()=>Ju,selectTextblockStart:()=>Yu,setContent:()=>Zu,setMark:()=>nf,setMeta:()=>rf,setNode:()=>af,setNodeSelection:()=>of,setTextDirection:()=>sf,setTextSelection:()=>cf,sinkListItem:()=>lf,splitBlock:()=>df,splitListItem:()=>ff,toggleList:()=>Tf,toggleMark:()=>Ef,toggleNode:()=>Df,toggleWrap:()=>Of,undoInputRule:()=>kf,unsetAllMarks:()=>Af,unsetMark:()=>jf,unsetTextDirection:()=>Mf,updateAttributes:()=>Nf,updateDecorations:()=>Ff,wrapIn:()=>If,wrapInList:()=>Lf}),zf=new WeakMap;function Bf(e,t){zf.set(e,(zf.get(e)??0)+1);try{return t()}finally{let t=(zf.get(e)??1)-1;t>0?zf.set(e,t):zf.delete(e)}}function Vf(e){return zf.has(e)}var Hf=class{constructor(){this.callbacks={}}on(e,t){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(t),this}emit(e,...t){let n=this.callbacks[e];return n&&n.forEach(e=>e.apply(this,t)),this}off(e,t){let n=this.callbacks[e];return n&&(t?this.callbacks[e]=n.filter(e=>e!==t):delete this.callbacks[e]),this}once(e,t){let n=(...r)=>{this.off(e,n),t.apply(this,r)};return this.on(e,n)}removeAllListeners(){this.callbacks={}}},Uf=typeof process<`u`&&!1;function Wf(e){return e.kind===`widget`}function Gf(e,t){let n=[],r=new Set;for(let i of e)i.kind===`widget`&&Wf(i)&&r.add(i.key),n.push(i.toPMDecoration(t));return{decorations:n,widgetKeys:r}}function Kf(e,t,n){let{decorations:r,widgetKeys:i}=Gf(t,n);return{set:U.create(e,r),widgetKeys:i}}function qf({position:e,from:t,to:n,docSize:r}){return eqf({position:e.anchor,from:t,to:n,docSize:r})?!0:(e.anchor===n||a.has(i)||(a.add(i),console.warn(`[tiptap warn]: Extension "${i}" returned a decoration outside the requested range [${t}, ${n}). It was ignored.`)),!1))}function Yf(e){let t=e.spec?.key;return typeof t==`string`?t:void 0}function Xf(e){let t=new Map,n=new Map;for(let r of e.find()){let e=Yf(r);if(!e)continue;let i=r.spec.extensionName??`unknown`,a=t.get(e)??new Set;a.add(i),t.set(e,a),n.set(e,(n.get(e)??0)+1)}return Array.from(t,([e,t])=>({key:e,extensions:t})).filter(({key:e})=>(n.get(e)??0)>1)}function Zf(e){return e.jsonID===`attr`}function Qf(e){let t=!1;if(e.getMap().forEach(()=>{t=!0}),t||Zf(e))return!0;let n=e;return typeof n.from==`number`&&typeof n.to==`number`}function $f(e,t){let n=null,r=0,i=0;for(let a=0;at.to);a+=1){let o=i+e.child(a).nodeSize;o>=t.from&&(n===null&&(n=i),r=o),i=o}return n===null?null:{from:n,to:r}}function ep(e,t){if(e.steps.some(e=>!Qf(e)))return{type:`full`};let n=Fd(e).map(({newRange:e})=>e);e.steps.forEach((t,r)=>{if(!Zf(t))return;let i=e.mapping.slice(r);n.push({from:i.map(t.pos,-1),to:i.map(t.pos+1)})});let r=[];for(let e of n){let n=$f(t,e);n&&r.push(n)}r.sort((e,t)=>e.from-t.from);let i=[];for(let e of r){let t=i[i.length-1];t&&e.from<=t.to?t.to=Math.max(t.to,e.to):i.push({...e})}return{type:`ranges`,ranges:i}}function tp(e,t,n,r){return e.map(t,n,{onRemove:e=>{let t=e?.key;typeof t==`string`&&r.delete(t)}})}function np(e,t,n){let r=t.decorationSetsByExtension[e]??U.empty,i=new Set(t.widgetKeysByExtension[e]??[]);return{set:tp(r,n.mapping,n.doc,i),widgetKeys:i}}function rp(e,t){let n=Object.values(t).flatMap(e=>e.find());return U.create(e,n)}function ip(e){let t=new Set;for(let n of Object.values(e))for(let e of n)t.add(e);return t}function ap(e,t){switch(t.update??`document`){case`document`:if(t.createInRange)throw Error(`[tiptap error]: Extension "${e}" provides createInRange() but does not use the "changedRanges" decoration update strategy.`);return;case`changedRanges`:if(!t.createInRange)throw Error(`[tiptap error]: Extension "${e}" uses the "changedRanges" decoration update strategy but does not provide createInRange().`);return;case`manual`:if(t.createInRange)throw Error(`[tiptap error]: Extension "${e}" uses the "manual" decoration update strategy, which is not compatible with createInRange(). createInRange() requires the "changedRanges" strategy.`);if(t.shouldUpdate)throw Error(`[tiptap error]: Extension "${e}" cannot combine the "manual" decoration update strategy with shouldUpdate().`);return;default:throw Error(`[tiptap error]: Extension "${e}" uses an unknown decoration update strategy. Expected "document", "changedRanges", or "manual".`)}}function op(e,t,n){return n?!0:e.update===`manual`?!1:e.shouldUpdate?e.shouldUpdate(t):t.tr.docChanged}var sp=new Set,cp=class{constructor(e){this.warnedWidgetKeys=new Set,this.warnedOutOfRangeExtensions=new Set,this.handleBeforeTransaction=({nextState:e})=>{let t=Pf.getState(e);t&&this.warnDuplicateWidgetKeys(t)},this.editor=e.editor,this.entries=this.resolveEntries(e.entries),this.entries.forEach(({name:e,spec:t})=>ap(e,t)),this.plugin=this.entries.length>0?this.createPlugin():null,this.editor.on(`beforeTransaction`,this.handleBeforeTransaction)}destroy(){this.editor.off(`beforeTransaction`,this.handleBeforeTransaction)}liveWidgetKeys(){return Pf.getState(this.editor.state)?.widgetKeys??sp}get mountedView(){return this.editor.isDestroyed?null:this.editor.view}resolveEntries(e){let t=[];for(let{name:n,addDecorations:r}of e){let e=r();e&&t.push({name:n,spec:e})}return t}createPlugin(){let{editor:e,entries:t}=this;return new B({key:Pf,state:{init:(e,n)=>{let r={},i={};for(let{name:e,spec:a}of t){let{set:t,widgetKeys:o}=this.buildFullSet(e,a,n);r[e]=t,i[e]=o}let a={decorationSetsByExtension:r,widgetKeysByExtension:i,mergedDecorationSet:this.buildMergedSet(n.doc,r),widgetKeys:ip(i)};return this.warnDuplicateWidgetKeys(a),a},apply:(n,r,i,a)=>{let o=n.getMeta(Pf),s=o?.type===`force`&&!o.name,c=o?.type===`force`?o.name:void 0,l={},u={},d=new Set;return Bf(e,()=>{for(let{name:o,spec:f}of t){let t=s||c===o;if(!op(f,{editor:e,tr:n,oldState:i,newState:a},t)){let e=np(o,r,n);l[o]=e.set,u[o]=e.widgetKeys}else if(f.update===`changedRanges`&&n.docChanged&&!t){let e=this.applyChangedRangesRecompute(o,f,r,n,a);l[o]=e.set,u[o]=e.widgetKeys,d.add(o)}else{let{set:e,widgetKeys:t}=this.buildFullSet(o,f,a);l[o]=e,u[o]=t,d.add(o)}}}),d.size===0&&!n.docChanged?r:{decorationSetsByExtension:l,widgetKeysByExtension:u,mergedDecorationSet:this.mergeAfterApply({entries:t,previous:r,tr:n,decorationSetsByExtension:l,recomputedNames:d}),widgetKeys:ip(u)}}},props:{decorations(e){return Pf.getState(e)?.mergedDecorationSet??U.empty}}})}applyChangedRangesRecompute(e,t,n,r,i){let a=ep(r,i.doc);return a.type===`full`?this.buildFullSet(e,t,i):this.rebuildRanges(e,t,n,r,i,a.ranges)}rebuildRanges(e,t,n,r,i,a){let o=n.decorationSetsByExtension[e]??U.empty,s=new Set(n.widgetKeysByExtension[e]??[]),c=tp(o,r.mapping,r.doc,s),l=i.doc.content.size;for(let{from:n,to:r}of a){let a=c.find(n,r).filter(e=>qf({position:e.from,from:n,to:r,docSize:l}));for(let e of a){let t=Yf(e);t&&s.delete(t)}c=c.remove(a);let{decorations:o,widgetKeys:u}=Gf(Jf({decorations:this.runCreate(e,`createInRange`,()=>t.createInRange({editor:this.editor,state:i,view:this.mountedView,from:n,to:r})),from:n,to:r,docSize:l,extensionName:e,warnedExtensions:this.warnedOutOfRangeExtensions}),e);c=c.add(i.doc,o);for(let e of u)s.add(e)}return{set:c,widgetKeys:s}}buildFullSet(e,t,n){let r=this.runCreate(e,`create`,()=>t.create({editor:this.editor,state:n,view:this.mountedView}));return Kf(n.doc,r,e)}runCreate(e,t,n){try{return n()}catch(n){return console.error(`[tiptap error]: Extension "${e}" threw in \`addDecorations().${t}()\`. Its decorations were dropped for this update.`,n),[]}}warnDuplicateWidgetKeys(e){if(!Uf)return;if(e.widgetKeys.size===0){this.warnedWidgetKeys.clear();return}let t=Xf(e.mergedDecorationSet),n=new Set(t.map(({key:e})=>e));for(let{key:e,extensions:n}of t){if(this.warnedWidgetKeys.has(e))continue;let t=Array.from(n).map(e=>`"${e}"`).join(`, `);console.warn(`[tiptap warn]: Duplicate widget decoration key "${e}" in extension${n.size===1?``:`s`} ${t}. Widget decoration keys must be globally unique, otherwise ProseMirror misplaces the widget DOM. Use a stable, unique key (e.g. \`comment-\${id}\`).`)}this.warnedWidgetKeys=n}buildMergedSet(e,t){let n=Object.keys(t);return n.length===1?t[n[0]]:rp(e,t)}mergeAfterApply({entries:e,previous:t,tr:n,decorationSetsByExtension:r,recomputedNames:i}){return e.length===1?r[e[0].name]:i.size===0?t.mergedDecorationSet.map(n.mapping,n.doc):rp(n.doc,r)}};function lp(e,t){let{selection:n}=e,{$from:r}=n;if(n instanceof z){let e=r.index();return r.parent.canReplaceWith(e,e+1,t)}let i=r.depth;for(;i>=0;){let e=r.index(i);if(r.node(i).contentMatchAt(e).matchType(t))return!0;--i}return!1}function up(e,t,n){let r=document.querySelector(`style[data-tiptap-style${n?`-${n}`:``}]`);if(r!==null)return r;let i=document.createElement(`style`);return t&&i.setAttribute(`nonce`,t),i.setAttribute(`data-tiptap-style${n?`-${n}`:``}`,``),i.innerHTML=e,document.getElementsByTagName(`head`)[0].appendChild(i),i}function dp(e,t){let n=e.getAttribute(`style`);if(!n)return null;let r=n.split(`;`).map(e=>e.trim()).filter(Boolean),i=t.toLowerCase();for(let e=r.length-1;e>=0;--e){let t=r[e],n=t.indexOf(`:`);if(n!==-1&&t.slice(0,n).trim().toLowerCase()===i)return t.slice(n+1).trim()}return null}function fp(e){return typeof e==`number`}function pp(e){return Object.prototype.toString.call(e).slice(8,-1)}function mp(e){return pp(e)===`Object`&&e.constructor===Object&&Object.getPrototypeOf(e)===Object.prototype}function hp(e){return typeof e==`string`&&e.trim().length>0&&!/[;{}]/.test(e)}function gp(e,t){return e.replace(/^[ \t]*/,e=>{let n=0;for(let t of e)n+=t===` `?4-n%4:1;return` `.repeat(Math.max(0,n-t))})}function _p(e,t){let n=`text\n${e}\n`,r=t(n)[0];return(r?.type===`paragraph`||r?.type===`text`)&&r.raw===n}function vp(e,t,n){let r=t.split(` +`),i=n.isParagraphContinuation??(e=>_p(e,n.blockTokens)),a=0;for(let e of r){if(!e.trim()||!i(e))break;a+=1}return{mainContent:[e,...r.slice(0,a).map(e=>e.trimStart())].join(` `),nestedContent:r.slice(a).join(` -`)}}function vp(e,t,n){let r=e.split(` -`),i=[],a=``,o=0,s=t.baseIndentSize||2;for(;o0)break;if(e.trim()===``){o+=1,a=`${a}${e}\n`;continue}return}let d=t.extractItemData(u),{indentLevel:f,mainContent:p}=d;a=`${a}${e}\n`;let m=[p];for(o+=1;oe.trim()!==``);if(t===-1)break;if((((l=r[o+1+t].match(/^(\s*)/))==null||(l=l[1])==null?void 0:l.length)||0)>f){m.push(e),a=`${a}${e}\n`,o+=1;continue}break}if((((c=e.match(/^(\s*)/))==null||(c=c[1])==null?void 0:c.length)||0)>f)m.push(e),a=`${a}${e}\n`,o+=1;else break}let h,g=m.slice(1);if(g.length>0){let e=_p(p,g.map(e=>hp(e,f+s)).join(` -`),n);d.mainContent=e.mainContent;let r=e.nestedContent;r.trim()&&(h=t.customNestedParser?t.customNestedParser(r):n.blockTokens(r))}let _=t.createToken(d,h);i.push(_)}if(i.length!==0)return{items:i,raw:a.slice(0,e.length)}}var yp=4;function bp(e){let t=0;for(let n of e)t=n===` `?t+yp-t%yp:t+1;return t}function xp(e,t,n,r,i){if(!e||!Array.isArray(e.content))return``;let a=typeof n==`function`?n(r):n,[o,...s]=e.content,c=t.renderChildren([o]),l=`${a}${i?.indentMainContent?c.split(` +`)}}function yp(e,t,n){let r=e.split(` +`),i=[],a=``,o=0,s=t.baseIndentSize||2;for(;o0)break;if(e.trim()===``){o+=1,a=`${a}${e}\n`;continue}return}let d=t.extractItemData(u),{indentLevel:f,mainContent:p}=d;a=`${a}${e}\n`;let m=[p];for(o+=1;oe.trim()!==``);if(t===-1)break;if((((l=r[o+1+t].match(/^(\s*)/))==null||(l=l[1])==null?void 0:l.length)||0)>f){m.push(e),a=`${a}${e}\n`,o+=1;continue}break}if((((c=e.match(/^(\s*)/))==null||(c=c[1])==null?void 0:c.length)||0)>f)m.push(e),a=`${a}${e}\n`,o+=1;else break}let h,g=m.slice(1);if(g.length>0){let e=vp(p,g.map(e=>gp(e,f+s)).join(` +`),n);d.mainContent=e.mainContent;let r=e.nestedContent;r.trim()&&(h=t.customNestedParser?t.customNestedParser(r):n.blockTokens(r))}let _=t.createToken(d,h);i.push(_)}if(i.length!==0)return{items:i,raw:a.slice(0,e.length)}}var bp=4;function xp(e){let t=0;for(let n of e)t=n===` `?t+bp-t%bp:t+1;return t}function Sp(e,t,n,r,i){if(!e||!Array.isArray(e.content))return``;let a=typeof n==`function`?n(r):n,[o,...s]=e.content,c=t.renderChildren([o]),l=`${a}${i?.indentMainContent?c.split(` `).map((e,n)=>n===0?e:t.indent(e)).join(` -`):c}`;return s&&s.length>0&&s.forEach((e,n)=>{let r=t.renderChild?.call(t,e,n+1)??t.renderChildren([e]);if(r!=null){let n=e=>{if(!i?.alignNestedToPrefix)return t.indent(e);let n=t.indent(``),r=bp(a);return(bp(n)>=r?n:` `.repeat(r))+e},o=r.split(` +`):c}`;return s&&s.length>0&&s.forEach((e,n)=>{let r=t.renderChild?.call(t,e,n+1)??t.renderChildren([e]);if(r!=null){let n=e=>{if(!i?.alignNestedToPrefix)return t.indent(e);let n=t.indent(``),r=xp(a);return(xp(n)>=r?n:` `.repeat(r))+e},o=r.split(` `).map(e=>n(e||``)).join(` -`);l+=e.type===`paragraph`?`\n\n${o}`:`\n${o}`}}),l}function Sp(e,t){let n={...e};return pp(e)&&pp(t)&&Object.keys(t).forEach(r=>{pp(t[r])&&pp(e[r])?n[r]=Sp(e[r],t[r]):n[r]=t[r]}),n}function Cp(e,t,n={}){let{state:r}=t,{doc:i,tr:a}=r,o=e;i.descendants((t,r)=>{let i=a.mapping.map(r),s=a.mapping.map(r)+t.nodeSize,c=null;if(t.marks.forEach(e=>{if(e!==o)return!1;c=e}),!c)return;let l=!1;if(Object.keys(n).forEach(e=>{n[e]!==c.attrs[e]&&(l=!0)}),l){let t=e.type.create({...e.attrs,...n});a.removeMark(i,s,e.type),a.addMark(i,s,t)}}),a.docChanged&&t.view.dispatch(a)}var wp=class{constructor(e){this.find=e.find,this.handler=e.handler,this.undoable=e.undoable??!0}},Tp=(e,t)=>{if(Xl(t))return t.exec(e);let n=t(e);if(!n)return null;let r=[n.text];return r.index=n.index,r.input=e,r.data=n.data,n.replaceWith&&(n.text.includes(n.replaceWith)||console.warn(`[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".`),r.push(n.replaceWith)),r};function Ep(e){let{editor:t,from:n,to:r,text:i,insertText:a}=e;if(!a)return{inputTransaction:null,tr:t.view.state.tr};let o=t.view.state.tr.insertText(i,n,r);return{inputTransaction:o,tr:Cr.create({doc:o.doc,selection:o.selection,storedMarks:o.storedMarks}).tr}}function Dp(e){let{editor:t,from:n,to:r,text:i,rule:a,match:o,plugin:s,insertText:c}=e,{view:l}=t,{inputTransaction:u,tr:d}=Ep({editor:t,from:n,to:r,text:i,insertText:c}),f=u?n+i.length:r,p=Ml({state:l.state,transaction:d}),m={from:n-(o[0].length-i.length),to:f},{commands:h,chain:g,can:_}=new Nl({editor:t,state:p});return a.handler({state:p,range:m,match:o,commands:h,chain:g,can:_})===null||!d.steps.length?!1:(u&&(l.dispatch(u),!l.state.doc.eq(u.doc))||(wl(d),d.setMeta(`inputRule`,!0),a.undoable&&d.setMeta(s,{transform:d,from:n,to:f,text:i}),l.dispatch(d)),!0)}function Op(e,t,n){let r=t[0].length-n.length;if(r<=0)return!0;let i=e.parentOffset-r;return i>=0&&e.parent.textBetween(i,e.parentOffset)===t[0].slice(0,r)}function kp(e){let{editor:t,from:n,to:r,text:i,rules:a,plugin:o,insertText:s}=e,{view:c}=t;if(c.composing)return!1;let l=c.state.doc.resolve(n);if(l.parent.type.spec.code||(l.nodeBefore||l.nodeAfter)?.marks.find(e=>e.type.spec.code))return!1;let u=Bd(l)+i;for(let e of a){let a=Tp(u,e.find);if(a&&Op(l,a,i)&&Dp({editor:t,from:n,to:r,text:i,rule:e,match:a,plugin:o,insertText:s}))return!0}return!1}function Ap(e){let{editor:t,rules:n}=e,r=new V({state:{init(){return null},apply(e,i,a){let o=e.getMeta(r);if(o)return o;if(i&&e.getMeta(`appendedTransaction`)?.getMeta(r)){let t=new ir(i.transform.before);for(let n of[...i.transform.steps,...e.steps])t.step(n);return{...i,transform:t}}let s=e.getMeta(`applyInputRules`);return s&&setTimeout(()=>{let{text:e}=s;e=typeof e==`string`?e:rd(F.from(e),a.schema);let{from:i}=s,o=i+e.length;kp({editor:t,from:i,to:o,text:e,rules:n,plugin:r})}),e.selectionSet||e.docChanged?null:i}},props:{handleTextInput(e,i,a,o){return kp({editor:t,from:i,to:a,text:o,rules:n,plugin:r,insertText:!0})},handleDOMEvents:{compositionend:e=>(setTimeout(()=>{let{$cursor:i}=e.state.selection;i&&kp({editor:t,from:i.pos,to:i.pos,text:``,rules:n,plugin:r})}),!1)},handleKeyDown(e,i){if(i.key!==`Enter`)return!1;let{$cursor:a}=e.state.selection;return a?kp({editor:t,from:a.pos,to:a.pos,text:` -`,rules:n,plugin:r}):!1}},isInputRules:!0});return r}var jp=class{constructor(e={}){this.type=`extendable`,this.parent=null,this.child=null,this.name=``,this.config={name:this.name},this.config={...this.config,...e},this.name=this.config.name}get options(){return{...K(G(this,`addOptions`,{name:this.name}))}}get storage(){return{...K(G(this,`addStorage`,{name:this.name,options:this.options}))}}configure(e={}){let t=this.extend({...this.config,addOptions:()=>Sp(this.options,e)});return t.name=this.name,t.parent=this.parent,this.child=null,t}extend(e={}){let t=new this.constructor({...this.config,...e});return t.parent=this,this.child=t,t.name=`name`in e?e.name:t.parent.name,t}},Mp=class e extends jp{constructor(...e){super(...e),this.type=`mark`}static create(t={}){let n=typeof t==`function`?t():t;return new e(n)}static handleExit({editor:e,mark:t}){let{tr:n}=e.state,r=e.state.selection.$from;if(r.pos===r.end()){let i=r.marks();if(!i.find(e=>e?.type.name===t.name))return!1;let a=i.find(e=>e?.type.name===t.name);return a&&n.removeStoredMark(a),n.insertText(` `,r.pos),e.view.dispatch(n),!0}return!1}configure(e){return super.configure(e)}extend(e){let t=typeof e==`function`?e():e;return super.extend(t)}},Np=class{constructor(e){this.find=e.find,this.handler=e.handler}},Pp=(e,t,n)=>{if(Xl(t))return[...e.matchAll(t)];let r=t(e,n);return r?r.map(t=>{let n=[t.text];return n.index=t.index,n.input=e,n.data=t.data,t.replaceWith&&(t.text.includes(t.replaceWith)||console.warn(`[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".`),n.push(t.replaceWith)),n}):[]};function Fp(e){let{editor:t,state:n,from:r,to:i,rule:a,pasteEvent:o,dropEvent:s}=e,{commands:c,chain:l,can:u}=new Nl({editor:t,state:n}),d=[];return n.doc.nodesBetween(r,i,(e,t)=>{var f;if((f=e.type)!=null&&(f=f.spec)!=null&&f.code||!(e.isText||e.isTextblock||e.isInline))return;let p=e.content?.size??e.nodeSize??0,m=Math.max(r,t),h=Math.min(i,t+p);m>=h||Pp(e.isText?e.text||``:e.textBetween(m-t,h-t,void 0,``),a.find,o).forEach(e=>{if(e.index===void 0)return;let t=m+e.index+1,r=t+e[0].length,i={from:n.tr.mapping.map(t),to:n.tr.mapping.map(r)},f=a.handler({state:n,range:i,match:e,commands:c,chain:l,can:u,pasteEvent:o,dropEvent:s});d.push(f)})}),d.every(e=>e!==null)}var Ip=null,Lp=e=>{var t;let n=new ClipboardEvent(`paste`,{clipboardData:new DataTransfer});return(t=n.clipboardData)==null||t.setData(`text/html`,e),n};function Rp(e){let{editor:t,rules:n}=e,r=null,i=!1,a=!1,o=typeof ClipboardEvent<`u`?new ClipboardEvent(`paste`):null,s;try{s=typeof DragEvent<`u`?new DragEvent(`drop`):null}catch{s=null}let c=({state:e,from:n,to:r,rule:i,pasteEvt:a})=>{let c=e.tr,l=Ml({state:e,transaction:c});if(Fp({editor:t,state:l,from:Math.max(n-1,0),to:r.b-1,rule:i,pasteEvent:a,dropEvent:s})&&c.steps.length){try{s=typeof DragEvent<`u`?new DragEvent(`drop`):null}catch{s=null}return o=typeof ClipboardEvent<`u`?new ClipboardEvent(`paste`):null,c}};return t.on(`destroy`,()=>{Ip===t&&(Ip=null)}),n.map(e=>new V({view(e){let n=n=>{r=e.dom.parentElement?.contains(n.target)?e.dom.parentElement:null,r&&(Ip=t)},i=()=>{Ip&&=null};return window.addEventListener(`dragstart`,n),window.addEventListener(`dragend`,i),{destroy(){window.removeEventListener(`dragstart`,n),window.removeEventListener(`dragend`,i)}}},props:{handleDOMEvents:{drop:(e,t)=>{if(a=r===e.dom.parentElement,s=t,!a){let e=Ip;e?.isEditable&&setTimeout(()=>{if(e.isDestroyed)return;let t=e.state.selection;t&&e.commands.deleteRange({from:t.from,to:t.to})},10)}return!1},paste:(e,t)=>{let n=t.clipboardData?.getData(`text/html`);return o=t,i=!!n?.includes(`data-pm-slice`),!1}}},appendTransaction:(t,n,r)=>{let s=t[0],l=s.getMeta(`uiEvent`)===`paste`&&!i,u=s.getMeta(`uiEvent`)===`drop`&&!a,d=s.getMeta(`applyPasteRules`),f=!!d;if(!l&&!u&&!f)return;if(f){let{text:t}=d;t=typeof t==`string`?t:rd(F.from(t),r.schema);let{from:n}=d,i=n+t.length,a=Lp(t);return c({rule:e,state:r,from:n,to:{b:i},pasteEvt:a})}let p=n.doc.content.findDiffStart(r.doc.content),m=n.doc.content.findDiffEnd(r.doc.content);if(dp(p)&&m&&p!==m.b)return c({rule:e,state:r,from:p,to:m,pasteEvt:o})}}))}var zp=class{constructor(e,t){this.splittableMarks=[],this.nonClearableMarks=[],this.decorationManager=null,this.editor=t,this.baseExtensions=e,this.extensions=Ed(e),this.hasSchemaSpec=t.options.schemaSpec!==void 0,this.schema=wd(this.extensions,t,t.options.schemaSpec),this.setupExtensions()}get commands(){return this.extensions.reduce((e,t)=>{let n=G(t,`addCommands`,{name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:this.editor,type:Rd(t.name,this.schema)});return n?{...e,...n()}:e},{})}get plugins(){let{editor:e}=this,t=Td([...this.extensions].reverse()).flatMap(t=>{let n={name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:e,type:Rd(t.name,this.schema)},r=[],i=G(t,`addKeyboardShortcuts`,n),a={};if(t.type===`mark`&&G(t,`exitable`,n)&&(a.ArrowRight=()=>Mp.handleExit({editor:e,mark:t})),i){let t=Object.fromEntries(Object.entries(i()).map(([t,n])=>[t,()=>n({editor:e})]));a={...a,...t}}let o=il(a);r.push(o);let s=G(t,`addInputRules`,n);if(Gd(t,e.options.enableInputRules)&&s){let t=s();if(t&&t.length){let n=Ap({editor:e,rules:t}),i=Array.isArray(n)?n:[n];r.push(...i)}}let c=G(t,`addPasteRules`,n);if(Gd(t,e.options.enablePasteRules)&&c){let t=c();if(t&&t.length){let n=Rp({editor:e,rules:t});r.push(...n)}}let l=G(t,`addProseMirrorPlugins`,n);if(l){let e=l();r.push(...e)}return r}),n=this.createDecorationPlugin();return n&&t.push(n),t}createDecorationPlugin(){var e;let{editor:t}=this;(e=this.decorationManager)==null||e.destroy();let n=[];return this.extensions.forEach(e=>{let r=G(e,`addDecorations`,{name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:t,type:Rd(e.name,this.schema)});r&&n.push({name:e.name,addDecorations:r})}),this.decorationManager=new sp({editor:t,entries:n}),this.decorationManager.plugin}get attributes(){let e=pd(this.extensions);return this.hasSchemaSpec?id(e,this.schema):e}get nodeViews(){let{editor:e}=this,{nodeExtensions:t}=fd(this.extensions);return Object.fromEntries(t.filter(e=>!!G(e,`addNodeView`)).map(t=>{let n=this.attributes.filter(e=>e.type===t.name),r=G(t,`addNodeView`,{name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:e,type:Vl(t.name,this.schema)});if(!r)return[];let i=r();return i?[t.name,(r,a,o,s,c)=>{let l=vd(r,n);return i({node:r,view:a,getPos:o,decorations:s,innerDecorations:c,editor:e,extension:t,HTMLAttributes:l})}]:[]}))}dispatchTransaction(e){let{editor:t}=this;return Td([...this.extensions].reverse()).reduceRight((e,n)=>{let r={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:Rd(n.name,this.schema)},i=G(n,`dispatchTransaction`,r);return i?t=>{i.call(r,{transaction:t,next:e})}:e},e)}transformPastedHTML(e){let{editor:t}=this;return Td([...this.extensions]).reduce((e,n)=>{let r={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:Rd(n.name,this.schema)},i=G(n,`transformPastedHTML`,r);return i?(t,n)=>{let a=e(t,n);return i.call(r,a)}:e},e||(e=>e))}get markViews(){let{editor:e}=this,{markExtensions:t}=fd(this.extensions);return Object.fromEntries(t.filter(e=>!!G(e,`addMarkView`)).map(t=>{let n=this.attributes.filter(e=>e.type===t.name),r=G(t,`addMarkView`,{name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:e,type:tu(t.name,this.schema)});return r?[t.name,(i,a,o)=>{let s=vd(i,n);return r()({mark:i,view:a,inline:o,editor:e,extension:t,HTMLAttributes:s,updateAttributes:t=>{Cp(i,e,t)}})}]:[]}))}destroy(){var e;(e=this.decorationManager)==null||e.destroy(),this.extensions.forEach(e=>{let t=e;for(;t.parent;){let e=t.parent;e.child===t&&(e.child=null),t=e}}),this.extensions=[],this.baseExtensions=[],this.decorationManager=null,this.schema=null,this.editor=null}setupExtensions(){let e=this.extensions;this.editor.extensionStorage=Object.fromEntries(e.map(e=>[e.name,e.storage])),e.forEach(e=>{let t={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:Rd(e.name,this.schema)};e.type===`mark`&&((K(G(e,`keepOnSplit`,t))??!0)&&this.splittableMarks.push(e.name),(K(G(e,`clearable`,t))??!0)||this.nonClearableMarks.push(e.name));let n=G(e,`onBeforeCreate`,t),r=G(e,`onCreate`,t),i=G(e,`onUpdate`,t),a=G(e,`onSelectionUpdate`,t),o=G(e,`onTransaction`,t),s=G(e,`onFocus`,t),c=G(e,`onBlur`,t),l=G(e,`onDestroy`,t);n&&this.editor.on(`beforeCreate`,n),r&&this.editor.on(`create`,r),i&&this.editor.on(`update`,i),a&&this.editor.on(`selectionUpdate`,a),o&&this.editor.on(`transaction`,o),s&&this.editor.on(`focus`,s),c&&this.editor.on(`blur`,c),l&&this.editor.on(`destroy`,l)})}};zp.resolve=Ed,zp.sort=Td,zp.flatten=nd;var J=class e extends jp{constructor(...e){super(...e),this.type=`extension`}static create(t={}){let n=typeof t==`function`?t():t;return new e(n)}configure(e){return super.configure(e)}extend(e){let t=typeof e==`function`?e():e;return super.extend(t)}},Bp=J.create({name:`clipboardTextSerializer`,addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new V({key:new H(`clipboardTextSerializer`),props:{clipboardTextSerializer:()=>{let{editor:e}=this,{state:t,schema:n}=e,{doc:r,selection:i}=t,a=kd(n),{blockSeparator:o}=this.options,s={...o===void 0?{}:{blockSeparator:o},textSerializers:a};return[...i.ranges].sort((e,t)=>e.$from.pos-t.$from.pos).map(({$from:e,$to:t})=>Dd(r,{from:e.pos,to:t.pos},s)).join(o??` +`);l+=e.type===`paragraph`?`\n\n${o}`:`\n${o}`}}),l}function Cp(e,t){let n={...e};return mp(e)&&mp(t)&&Object.keys(t).forEach(r=>{mp(t[r])&&mp(e[r])?n[r]=Cp(e[r],t[r]):n[r]=t[r]}),n}function wp(e,t,n={}){let{state:r}=t,{doc:i,tr:a}=r,o=e;i.descendants((t,r)=>{let i=a.mapping.map(r),s=a.mapping.map(r)+t.nodeSize,c=null;if(t.marks.forEach(e=>{if(e!==o)return!1;c=e}),!c)return;let l=!1;if(Object.keys(n).forEach(e=>{n[e]!==c.attrs[e]&&(l=!0)}),l){let t=e.type.create({...e.attrs,...n});a.removeMark(i,s,e.type),a.addMark(i,s,t)}}),a.docChanged&&t.view.dispatch(a)}var Tp=class{constructor(e){this.find=e.find,this.handler=e.handler,this.undoable=e.undoable??!0}},Ep=(e,t)=>{if(Zl(t))return t.exec(e);let n=t(e);if(!n)return null;let r=[n.text];return r.index=n.index,r.input=e,r.data=n.data,n.replaceWith&&(n.text.includes(n.replaceWith)||console.warn(`[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".`),r.push(n.replaceWith)),r};function Dp(e){let{editor:t,from:n,to:r,text:i,insertText:a}=e;if(!a)return{inputTransaction:null,tr:t.view.state.tr};let o=t.view.state.tr.insertText(i,n,r);return{inputTransaction:o,tr:wr.create({doc:o.doc,selection:o.selection,storedMarks:o.storedMarks}).tr}}function Op(e){let{editor:t,from:n,to:r,text:i,rule:a,match:o,plugin:s,insertText:c}=e,{view:l}=t,{inputTransaction:u,tr:d}=Dp({editor:t,from:n,to:r,text:i,insertText:c}),f=u?n+i.length:r,p=Nl({state:l.state,transaction:d}),m={from:n-(o[0].length-i.length),to:f},{commands:h,chain:g,can:_}=new Pl({editor:t,state:p});return a.handler({state:p,range:m,match:o,commands:h,chain:g,can:_})===null||!d.steps.length?!1:(u&&(l.dispatch(u),!l.state.doc.eq(u.doc))||(Tl(d),d.setMeta(`inputRule`,!0),a.undoable&&d.setMeta(s,{transform:d,from:n,to:f,text:i}),l.dispatch(d)),!0)}function kp(e,t,n){let r=t[0].length-n.length;if(r<=0)return!0;let i=e.parentOffset-r;return i>=0&&e.parent.textBetween(i,e.parentOffset)===t[0].slice(0,r)}function Ap(e){let{editor:t,from:n,to:r,text:i,rules:a,plugin:o,insertText:s}=e,{view:c}=t;if(c.composing)return!1;let l=c.state.doc.resolve(n);if(l.parent.type.spec.code||(l.nodeBefore||l.nodeAfter)?.marks.find(e=>e.type.spec.code))return!1;let u=Vd(l)+i;for(let e of a){let a=Ep(u,e.find);if(a&&kp(l,a,i)&&Op({editor:t,from:n,to:r,text:i,rule:e,match:a,plugin:o,insertText:s}))return!0}return!1}function jp(e){let{editor:t,rules:n}=e,r=new B({state:{init(){return null},apply(e,i,a){let o=e.getMeta(r);if(o)return o;if(i&&e.getMeta(`appendedTransaction`)?.getMeta(r)){let t=new ar(i.transform.before);for(let n of[...i.transform.steps,...e.steps])t.step(n);return{...i,transform:t}}let s=e.getMeta(`applyInputRules`);return s&&setTimeout(()=>{let{text:e}=s;e=typeof e==`string`?e:id(P.from(e),a.schema);let{from:i}=s,o=i+e.length;Ap({editor:t,from:i,to:o,text:e,rules:n,plugin:r})}),e.selectionSet||e.docChanged?null:i}},props:{handleTextInput(e,i,a,o){return Ap({editor:t,from:i,to:a,text:o,rules:n,plugin:r,insertText:!0})},handleDOMEvents:{compositionend:e=>(setTimeout(()=>{let{$cursor:i}=e.state.selection;i&&Ap({editor:t,from:i.pos,to:i.pos,text:``,rules:n,plugin:r})}),!1)},handleKeyDown(e,i){if(i.key!==`Enter`)return!1;let{$cursor:a}=e.state.selection;return a?Ap({editor:t,from:a.pos,to:a.pos,text:` +`,rules:n,plugin:r}):!1}},isInputRules:!0});return r}var Mp=class{constructor(e={}){this.type=`extendable`,this.parent=null,this.child=null,this.name=``,this.config={name:this.name},this.config={...this.config,...e},this.name=this.config.name}get options(){return{...G(W(this,`addOptions`,{name:this.name}))}}get storage(){return{...G(W(this,`addStorage`,{name:this.name,options:this.options}))}}configure(e={}){let t=this.extend({...this.config,addOptions:()=>Cp(this.options,e)});return t.name=this.name,t.parent=this.parent,this.child=null,t}extend(e={}){let t=new this.constructor({...this.config,...e});return t.parent=this,this.child=t,t.name=`name`in e?e.name:t.parent.name,t}},Np=class e extends Mp{constructor(...e){super(...e),this.type=`mark`}static create(t={}){let n=typeof t==`function`?t():t;return new e(n)}static handleExit({editor:e,mark:t}){let{tr:n}=e.state,r=e.state.selection.$from;if(r.pos===r.end()){let i=r.marks();if(!i.find(e=>e?.type.name===t.name))return!1;let a=i.find(e=>e?.type.name===t.name);return a&&n.removeStoredMark(a),n.insertText(` `,r.pos),e.view.dispatch(n),!0}return!1}configure(e){return super.configure(e)}extend(e){let t=typeof e==`function`?e():e;return super.extend(t)}},Pp=class{constructor(e){this.find=e.find,this.handler=e.handler}},Fp=(e,t,n)=>{if(Zl(t))return[...e.matchAll(t)];let r=t(e,n);return r?r.map(t=>{let n=[t.text];return n.index=t.index,n.input=e,n.data=t.data,t.replaceWith&&(t.text.includes(t.replaceWith)||console.warn(`[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".`),n.push(t.replaceWith)),n}):[]};function Ip(e){let{editor:t,state:n,from:r,to:i,rule:a,pasteEvent:o,dropEvent:s}=e,{commands:c,chain:l,can:u}=new Pl({editor:t,state:n}),d=[];return n.doc.nodesBetween(r,i,(e,t)=>{var f;if((f=e.type)!=null&&(f=f.spec)!=null&&f.code||!(e.isText||e.isTextblock||e.isInline))return;let p=e.content?.size??e.nodeSize??0,m=Math.max(r,t),h=Math.min(i,t+p);m>=h||Fp(e.isText?e.text||``:e.textBetween(m-t,h-t,void 0,``),a.find,o).forEach(e=>{if(e.index===void 0)return;let t=m+e.index+1,r=t+e[0].length,i={from:n.tr.mapping.map(t),to:n.tr.mapping.map(r)},f=a.handler({state:n,range:i,match:e,commands:c,chain:l,can:u,pasteEvent:o,dropEvent:s});d.push(f)})}),d.every(e=>e!==null)}var Lp=null,Rp=e=>{var t;let n=new ClipboardEvent(`paste`,{clipboardData:new DataTransfer});return(t=n.clipboardData)==null||t.setData(`text/html`,e),n};function zp(e){let{editor:t,rules:n}=e,r=null,i=!1,a=!1,o=typeof ClipboardEvent<`u`?new ClipboardEvent(`paste`):null,s;try{s=typeof DragEvent<`u`?new DragEvent(`drop`):null}catch{s=null}let c=({state:e,from:n,to:r,rule:i,pasteEvt:a})=>{let c=e.tr,l=Nl({state:e,transaction:c});if(Ip({editor:t,state:l,from:Math.max(n-1,0),to:r.b-1,rule:i,pasteEvent:a,dropEvent:s})&&c.steps.length){try{s=typeof DragEvent<`u`?new DragEvent(`drop`):null}catch{s=null}return o=typeof ClipboardEvent<`u`?new ClipboardEvent(`paste`):null,c}};return t.on(`destroy`,()=>{Lp===t&&(Lp=null)}),n.map(e=>new B({view(e){let n=n=>{r=e.dom.parentElement?.contains(n.target)?e.dom.parentElement:null,r&&(Lp=t)},i=()=>{Lp&&=null};return window.addEventListener(`dragstart`,n),window.addEventListener(`dragend`,i),{destroy(){window.removeEventListener(`dragstart`,n),window.removeEventListener(`dragend`,i)}}},props:{handleDOMEvents:{drop:(e,t)=>{if(a=r===e.dom.parentElement,s=t,!a){let e=Lp;e?.isEditable&&setTimeout(()=>{if(e.isDestroyed)return;let t=e.state.selection;t&&e.commands.deleteRange({from:t.from,to:t.to})},10)}return!1},paste:(e,t)=>{let n=t.clipboardData?.getData(`text/html`);return o=t,i=!!n?.includes(`data-pm-slice`),!1}}},appendTransaction:(t,n,r)=>{let s=t[0],l=s.getMeta(`uiEvent`)===`paste`&&!i,u=s.getMeta(`uiEvent`)===`drop`&&!a,d=s.getMeta(`applyPasteRules`),f=!!d;if(!l&&!u&&!f)return;if(f){let{text:t}=d;t=typeof t==`string`?t:id(P.from(t),r.schema);let{from:n}=d,i=n+t.length,a=Rp(t);return c({rule:e,state:r,from:n,to:{b:i},pasteEvt:a})}let p=n.doc.content.findDiffStart(r.doc.content),m=n.doc.content.findDiffEnd(r.doc.content);if(fp(p)&&m&&p!==m.b)return c({rule:e,state:r,from:p,to:m,pasteEvt:o})}}))}var Bp=class{constructor(e,t){this.splittableMarks=[],this.nonClearableMarks=[],this.decorationManager=null,this.editor=t,this.baseExtensions=e,this.extensions=Dd(e),this.hasSchemaSpec=t.options.schemaSpec!==void 0,this.schema=Td(this.extensions,t,t.options.schemaSpec),this.setupExtensions()}get commands(){return this.extensions.reduce((e,t)=>{let n=W(t,`addCommands`,{name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:this.editor,type:zd(t.name,this.schema)});return n?{...e,...n()}:e},{})}get plugins(){let{editor:e}=this,t=Ed([...this.extensions].reverse()).flatMap(t=>{let n={name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:e,type:zd(t.name,this.schema)},r=[],i=W(t,`addKeyboardShortcuts`,n),a={};if(t.type===`mark`&&W(t,`exitable`,n)&&(a.ArrowRight=()=>Np.handleExit({editor:e,mark:t})),i){let t=Object.fromEntries(Object.entries(i()).map(([t,n])=>[t,()=>n({editor:e})]));a={...a,...t}}let o=al(a);r.push(o);let s=W(t,`addInputRules`,n);if(Kd(t,e.options.enableInputRules)&&s){let t=s();if(t&&t.length){let n=jp({editor:e,rules:t}),i=Array.isArray(n)?n:[n];r.push(...i)}}let c=W(t,`addPasteRules`,n);if(Kd(t,e.options.enablePasteRules)&&c){let t=c();if(t&&t.length){let n=zp({editor:e,rules:t});r.push(...n)}}let l=W(t,`addProseMirrorPlugins`,n);if(l){let e=l();r.push(...e)}return r}),n=this.createDecorationPlugin();return n&&t.push(n),t}createDecorationPlugin(){var e;let{editor:t}=this;(e=this.decorationManager)==null||e.destroy();let n=[];return this.extensions.forEach(e=>{let r=W(e,`addDecorations`,{name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:t,type:zd(e.name,this.schema)});r&&n.push({name:e.name,addDecorations:r})}),this.decorationManager=new cp({editor:t,entries:n}),this.decorationManager.plugin}get attributes(){let e=md(this.extensions);return this.hasSchemaSpec?ad(e,this.schema):e}get nodeViews(){let{editor:e}=this,{nodeExtensions:t}=pd(this.extensions);return Object.fromEntries(t.filter(e=>!!W(e,`addNodeView`)).map(t=>{let n=this.attributes.filter(e=>e.type===t.name),r=W(t,`addNodeView`,{name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:e,type:Hl(t.name,this.schema)});if(!r)return[];let i=r();return i?[t.name,(r,a,o,s,c)=>{let l=yd(r,n);return i({node:r,view:a,getPos:o,decorations:s,innerDecorations:c,editor:e,extension:t,HTMLAttributes:l})}]:[]}))}dispatchTransaction(e){let{editor:t}=this;return Ed([...this.extensions].reverse()).reduceRight((e,n)=>{let r={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:zd(n.name,this.schema)},i=W(n,`dispatchTransaction`,r);return i?t=>{i.call(r,{transaction:t,next:e})}:e},e)}transformPastedHTML(e){let{editor:t}=this;return Ed([...this.extensions]).reduce((e,n)=>{let r={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:zd(n.name,this.schema)},i=W(n,`transformPastedHTML`,r);return i?(t,n)=>{let a=e(t,n);return i.call(r,a)}:e},e||(e=>e))}get markViews(){let{editor:e}=this,{markExtensions:t}=pd(this.extensions);return Object.fromEntries(t.filter(e=>!!W(e,`addMarkView`)).map(t=>{let n=this.attributes.filter(e=>e.type===t.name),r=W(t,`addMarkView`,{name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:e,type:nu(t.name,this.schema)});return r?[t.name,(i,a,o)=>{let s=yd(i,n);return r()({mark:i,view:a,inline:o,editor:e,extension:t,HTMLAttributes:s,updateAttributes:t=>{wp(i,e,t)}})}]:[]}))}destroy(){var e;(e=this.decorationManager)==null||e.destroy(),this.extensions.forEach(e=>{let t=e;for(;t.parent;){let e=t.parent;e.child===t&&(e.child=null),t=e}}),this.extensions=[],this.baseExtensions=[],this.decorationManager=null,this.schema=null,this.editor=null}setupExtensions(){let e=this.extensions;this.editor.extensionStorage=Object.fromEntries(e.map(e=>[e.name,e.storage])),e.forEach(e=>{let t={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:zd(e.name,this.schema)};e.type===`mark`&&((G(W(e,`keepOnSplit`,t))??!0)&&this.splittableMarks.push(e.name),(G(W(e,`clearable`,t))??!0)||this.nonClearableMarks.push(e.name));let n=W(e,`onBeforeCreate`,t),r=W(e,`onCreate`,t),i=W(e,`onUpdate`,t),a=W(e,`onSelectionUpdate`,t),o=W(e,`onTransaction`,t),s=W(e,`onFocus`,t),c=W(e,`onBlur`,t),l=W(e,`onDestroy`,t);n&&this.editor.on(`beforeCreate`,n),r&&this.editor.on(`create`,r),i&&this.editor.on(`update`,i),a&&this.editor.on(`selectionUpdate`,a),o&&this.editor.on(`transaction`,o),s&&this.editor.on(`focus`,s),c&&this.editor.on(`blur`,c),l&&this.editor.on(`destroy`,l)})}};Bp.resolve=Dd,Bp.sort=Ed,Bp.flatten=rd;var q=class e extends Mp{constructor(...e){super(...e),this.type=`extension`}static create(t={}){let n=typeof t==`function`?t():t;return new e(n)}configure(e){return super.configure(e)}extend(e){let t=typeof e==`function`?e():e;return super.extend(t)}},Vp=q.create({name:`clipboardTextSerializer`,addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new B({key:new V(`clipboardTextSerializer`),props:{clipboardTextSerializer:()=>{let{editor:e}=this,{state:t,schema:n}=e,{doc:r,selection:i}=t,a=Ad(n),{blockSeparator:o}=this.options,s={...o===void 0?{}:{blockSeparator:o},textSerializers:a};return[...i.ranges].sort((e,t)=>e.$from.pos-t.$from.pos).map(({$from:e,$to:t})=>Od(r,{from:e.pos,to:t.pos},s)).join(o??` -`)}}})]}}),Vp=J.create({name:`commands`,addCommands(){return{...Lf}}}),Hp=J.create({name:`delete`,onUpdate({transaction:e,appendedTransactions:t}){var n;let r=()=>{var n,r;if(((n=this.editor.options.coreExtensionOptions)==null||(n=n.delete)==null||(r=n.filterTransaction)==null?void 0:r.call(n,e))??e.getMeta(`y-sync$`))return;let i=Qu(e.before,[e,...t]);Pd(i).forEach(t=>{i.mapping.mapResult(t.oldRange.from).deletedAfter&&i.mapping.mapResult(t.oldRange.to).deletedBefore&&i.before.nodesBetween(t.oldRange.from,t.oldRange.to,(n,r)=>{let a=r+n.nodeSize-2,o=t.oldRange.from<=r&&a<=t.oldRange.to;this.editor.emit(`delete`,{type:`node`,node:n,from:r,to:a,newFrom:i.mapping.map(r),newTo:i.mapping.map(a),deletedRange:t.oldRange,newRange:t.newRange,partial:!o,editor:this.editor,transaction:e,combinedTransform:i})})});let a=i.mapping;i.steps.forEach((t,n)=>{if(t instanceof on){let r=a.slice(n).map(t.from,-1),o=a.slice(n).map(t.to),s=a.invert().map(r,-1),c=a.invert().map(o),l=r>0&&i.doc.nodeAt(r-1)?.marks.some(e=>e.eq(t.mark)),u=i.doc.nodeAt(o)?.marks.some(e=>e.eq(t.mark));this.editor.emit(`delete`,{type:`mark`,mark:t.mark,from:t.from,to:t.to,deletedRange:{from:s,to:c},newRange:{from:r,to:o},partial:!!(u||l),editor:this.editor,transaction:e,combinedTransform:i})}})};((n=this.editor.options.coreExtensionOptions)==null||(n=n.delete)==null?void 0:n.async)??!0?setTimeout(r,0):r()}}),Up=J.create({name:`drop`,addProseMirrorPlugins(){return[new V({key:new H(`tiptapDrop`),props:{handleDrop:(e,t,n,r)=>{this.editor.emit(`drop`,{editor:this.editor,event:t,slice:n,moved:r})}}})]}}),Wp=J.create({name:`editable`,addProseMirrorPlugins(){return[new V({key:new H(`editable`),props:{editable:()=>this.editor.options.editable}})]}}),Gp=new H(`focusEvents`),Kp=J.create({name:`focusEvents`,addProseMirrorPlugins(){let{editor:e}=this;return[new V({key:Gp,props:{handleDOMEvents:{focus:(t,n)=>{e.isFocused=!0;let r=e.state.tr.setMeta(`focus`,{event:n}).setMeta(`addToHistory`,!1);return t.dispatch(r),!1},blur:(t,n)=>{e.isFocused=!1;let r=e.state.tr.setMeta(`blur`,{event:n}).setMeta(`addToHistory`,!1);return t.dispatch(r),!1}}}})]}});function qp(e){let{empty:t,from:n,to:r}=e.selection;return!t&&n===R.atStart(e.doc).from&&r===R.atEnd(e.doc).to}var Jp=J.create({name:`keymap`,addKeyboardShortcuts(){let e=()=>this.editor.commands.first(({commands:e})=>[()=>e.undoInputRule(),()=>e.command(({tr:t})=>{let{selection:n,doc:r}=t,{empty:i,$anchor:a}=n,{pos:o,parent:s}=a,c=a.parent.isTextblock&&o>0?t.doc.resolve(o-1):a,l=c.parent.type.spec.isolating,u=a.pos-a.parentOffset,d=l&&c.parent.childCount===1?u===a.pos:R.atStart(r).from===o;return!i||!s.type.isTextblock||s.textContent.length||!d||d&&a.parent.type.name===`paragraph`?!1:e.clearNodes()}),()=>e.deleteSelection(),()=>e.joinBackward(),()=>e.selectNodeBackward()]),t=()=>this.editor.commands.first(({commands:e})=>[()=>e.deleteSelection(),()=>e.deleteCurrentNode(),()=>e.joinForward(),()=>e.selectNodeForward()]),n={Enter:()=>this.editor.commands.first(({commands:e})=>[()=>e.newlineInCode(),()=>e.createParagraphNear(),()=>e.liftEmptyBlock(),()=>e.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:e,"Mod-Backspace":e,"Shift-Backspace":e,Delete:t,"Mod-Delete":t,"Mod-a":()=>this.editor.commands.selectAll()},r={...n},i={...n,"Ctrl-h":e,"Alt-Backspace":e,"Ctrl-d":t,"Ctrl-Alt-Backspace":t,"Alt-Delete":t,"Alt-d":t,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return cu()||ju()?i:r},addProseMirrorPlugins(){return[new V({key:new H(`clearDocument`),appendTransaction:(e,t,n)=>{if(e.some(e=>e.getMeta(`composition`)))return;let r=e.some(e=>e.docChanged)&&!t.doc.eq(n.doc),i=e.some(e=>e.getMeta(`preventClearDocument`));if(!r||i||!qp(t)||!qd(n.doc))return;let a=n.tr,o=Ml({state:n,transaction:a}),{commands:s}=new Nl({editor:this.editor,state:o});if(s.clearNodes(),a.steps.length||n.storedMarks)return a.setStoredMarks(null)}})]}}),Yp=J.create({name:`paste`,addProseMirrorPlugins(){return[new V({key:new H(`tiptapPaste`),props:{handlePaste:(e,t,n)=>{this.editor.emit(`paste`,{editor:this.editor,event:t,slice:n})}}})]}}),Xp=J.create({name:`tabindex`,addOptions(){return{value:void 0}},addProseMirrorPlugins(){return[new V({key:new H(`tabindex`),props:{attributes:()=>!this.editor.isEditable&&this.options.value===void 0?{}:{tabindex:this.options.value??`0`}}})]}}),Zp=J.create({name:`textDirection`,addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];let{nodeExtensions:e}=fd(this.extensions);return[{types:e.filter(e=>e.name!==`text`).map(e=>e.name),attributes:{dir:{default:this.options.direction,parseHTML:e=>{let t=e.getAttribute(`dir`);return t&&(t===`ltr`||t===`rtl`||t===`auto`)?t:this.options.direction},renderHTML:e=>e.dir?{dir:e.dir}:{}}}}]},addProseMirrorPlugins(){return[new V({key:new H(`textDirection`),props:{attributes:()=>{let e=this.options.direction;return e?{dir:e}:{}}}})]}}),Qp=!1;function $p(e){if(Qp)return;Qp=!0;let t;try{let n=dn.fromJSON(e,{from:0,to:0});if(!Xd(n))return;t=n.slice.content}catch{return}t instanceof F||console.warn(`[tiptap warn]: prosemirror-model is loaded more than once. Wrapping and splitting nodes will fail. Deduplicate it in your lock file, or alias it to a single copy in your bundler.`)}var em=class e{get name(){return this.node.type.name}constructor(e,t,n=!1,r=null){this.currentNode=null,this.actualDepth=null,this.isBlock=n,this.resolvedPos=e,this.editor=t,this.currentNode=r}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){return this.actualDepth??this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let t=this.from,n=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can’t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}t=this.from+1,n=this.to-1}this.editor.commands.insertContentAt({from:t,to:n},e)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+ +!this.node.isText}get parent(){if(this.depth===0)return null;let t=this.resolvedPos.start(this.resolvedPos.depth-1),n=this.resolvedPos.doc.resolve(t);return new e(n,this.editor)}get before(){let t=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return t.depth!==this.depth&&(t=this.resolvedPos.doc.resolve(this.from-3)),new e(t,this.editor)}get after(){let t=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return t.depth!==this.depth&&(t=this.resolvedPos.doc.resolve(this.to+3)),new e(t,this.editor)}get children(){let t=[];return this.node.content.forEach((n,r)=>{let i=n.isBlock&&!n.isTextblock,a=n.isAtom&&!n.isText,o=n.isInline,s=this.pos+r+ +!a;if(s<0||s>this.resolvedPos.doc.nodeSize-2)return;let c=this.resolvedPos.doc.resolve(s);if(!i&&!o&&c.depth<=this.depth)return;let l=new e(c,this.editor,i,i||o?n:null);i&&(l.actualDepth=this.depth+1),t.push(l)}),t}get firstChild(){return this.children[0]||null}get lastChild(){let e=this.children;return e[e.length-1]||null}closest(e,t={}){let n=null,r=this.parent;for(;r&&!n;){if(r.node.type.name===e){if(Object.keys(t).length>0){let e=r.node.attrs,n=Object.keys(t);for(let r=0;r{n&&r.length>0||(a.node.type.name===e&&i.every(e=>t[e]===a.node.attrs[e])&&r.push(a),n&&r.length>0||(r=r.concat(a.querySelectorAll(e,t,n))))}),r}setAttribute(e){let{tr:t}=this.editor.state;t.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(t)}},tm=`.ProseMirror { +`)}}})]}}),Hp=q.create({name:`commands`,addCommands(){return{...Rf}}}),Up=q.create({name:`delete`,onUpdate({transaction:e,appendedTransactions:t}){var n;let r=()=>{var n,r;if(((n=this.editor.options.coreExtensionOptions)==null||(n=n.delete)==null||(r=n.filterTransaction)==null?void 0:r.call(n,e))??e.getMeta(`y-sync$`))return;let i=$u(e.before,[e,...t]);Fd(i).forEach(t=>{i.mapping.mapResult(t.oldRange.from).deletedAfter&&i.mapping.mapResult(t.oldRange.to).deletedBefore&&i.before.nodesBetween(t.oldRange.from,t.oldRange.to,(n,r)=>{let a=r+n.nodeSize-2,o=t.oldRange.from<=r&&a<=t.oldRange.to;this.editor.emit(`delete`,{type:`node`,node:n,from:r,to:a,newFrom:i.mapping.map(r),newTo:i.mapping.map(a),deletedRange:t.oldRange,newRange:t.newRange,partial:!o,editor:this.editor,transaction:e,combinedTransform:i})})});let a=i.mapping;i.steps.forEach((t,n)=>{if(t instanceof sn){let r=a.slice(n).map(t.from,-1),o=a.slice(n).map(t.to),s=a.invert().map(r,-1),c=a.invert().map(o),l=r>0&&i.doc.nodeAt(r-1)?.marks.some(e=>e.eq(t.mark)),u=i.doc.nodeAt(o)?.marks.some(e=>e.eq(t.mark));this.editor.emit(`delete`,{type:`mark`,mark:t.mark,from:t.from,to:t.to,deletedRange:{from:s,to:c},newRange:{from:r,to:o},partial:!!(u||l),editor:this.editor,transaction:e,combinedTransform:i})}})};((n=this.editor.options.coreExtensionOptions)==null||(n=n.delete)==null?void 0:n.async)??!0?setTimeout(r,0):r()}}),Wp=q.create({name:`drop`,addProseMirrorPlugins(){return[new B({key:new V(`tiptapDrop`),props:{handleDrop:(e,t,n,r)=>{this.editor.emit(`drop`,{editor:this.editor,event:t,slice:n,moved:r})}}})]}}),Gp=q.create({name:`editable`,addProseMirrorPlugins(){return[new B({key:new V(`editable`),props:{editable:()=>this.editor.options.editable}})]}}),Kp=new V(`focusEvents`),qp=q.create({name:`focusEvents`,addProseMirrorPlugins(){let{editor:e}=this;return[new B({key:Kp,props:{handleDOMEvents:{focus:(t,n)=>{e.isFocused=!0;let r=e.state.tr.setMeta(`focus`,{event:n}).setMeta(`addToHistory`,!1);return t.dispatch(r),!1},blur:(t,n)=>{e.isFocused=!1;let r=e.state.tr.setMeta(`blur`,{event:n}).setMeta(`addToHistory`,!1);return t.dispatch(r),!1}}}})]}});function Jp(e){let{empty:t,from:n,to:r}=e.selection;return!t&&n===L.atStart(e.doc).from&&r===L.atEnd(e.doc).to}var Yp=q.create({name:`keymap`,addKeyboardShortcuts(){let e=()=>this.editor.commands.first(({commands:e})=>[()=>e.undoInputRule(),()=>e.command(({tr:t})=>{let{selection:n,doc:r}=t,{empty:i,$anchor:a}=n,{pos:o,parent:s}=a,c=a.parent.isTextblock&&o>0?t.doc.resolve(o-1):a,l=c.parent.type.spec.isolating,u=a.pos-a.parentOffset,d=l&&c.parent.childCount===1?u===a.pos:L.atStart(r).from===o;return!i||!s.type.isTextblock||s.textContent.length||!d||d&&a.parent.type.name===`paragraph`?!1:e.clearNodes()}),()=>e.deleteSelection(),()=>e.joinBackward(),()=>e.selectNodeBackward()]),t=()=>this.editor.commands.first(({commands:e})=>[()=>e.deleteSelection(),()=>e.deleteCurrentNode(),()=>e.joinForward(),()=>e.selectNodeForward()]),n={Enter:()=>this.editor.commands.first(({commands:e})=>[()=>e.newlineInCode(),()=>e.createParagraphNear(),()=>e.liftEmptyBlock(),()=>e.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:e,"Mod-Backspace":e,"Shift-Backspace":e,Delete:t,"Mod-Delete":t,"Mod-a":()=>this.editor.commands.selectAll()},r={...n},i={...n,"Ctrl-h":e,"Alt-Backspace":e,"Ctrl-d":t,"Ctrl-Alt-Backspace":t,"Alt-Delete":t,"Alt-d":t,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return lu()||Mu()?i:r},addProseMirrorPlugins(){return[new B({key:new V(`clearDocument`),appendTransaction:(e,t,n)=>{if(e.some(e=>e.getMeta(`composition`)))return;let r=e.some(e=>e.docChanged)&&!t.doc.eq(n.doc),i=e.some(e=>e.getMeta(`preventClearDocument`));if(!r||i||!Jp(t)||!Jd(n.doc))return;let a=n.tr,o=Nl({state:n,transaction:a}),{commands:s}=new Pl({editor:this.editor,state:o});if(s.clearNodes(),a.steps.length||n.storedMarks)return a.setStoredMarks(null)}})]}}),Xp=q.create({name:`paste`,addProseMirrorPlugins(){return[new B({key:new V(`tiptapPaste`),props:{handlePaste:(e,t,n)=>{this.editor.emit(`paste`,{editor:this.editor,event:t,slice:n})}}})]}}),Zp=q.create({name:`tabindex`,addOptions(){return{value:void 0}},addProseMirrorPlugins(){return[new B({key:new V(`tabindex`),props:{attributes:()=>!this.editor.isEditable&&this.options.value===void 0?{}:{tabindex:this.options.value??`0`}}})]}}),Qp=q.create({name:`textDirection`,addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];let{nodeExtensions:e}=pd(this.extensions);return[{types:e.filter(e=>e.name!==`text`).map(e=>e.name),attributes:{dir:{default:this.options.direction,parseHTML:e=>{let t=e.getAttribute(`dir`);return t&&(t===`ltr`||t===`rtl`||t===`auto`)?t:this.options.direction},renderHTML:e=>e.dir?{dir:e.dir}:{}}}}]},addProseMirrorPlugins(){return[new B({key:new V(`textDirection`),props:{attributes:()=>{let e=this.options.direction;return e?{dir:e}:{}}}})]}}),$p=!1;function em(e){if($p)return;$p=!0;let t;try{let n=fn.fromJSON(e,{from:0,to:0});if(!Zd(n))return;t=n.slice.content}catch{return}t instanceof P||console.warn(`[tiptap warn]: prosemirror-model is loaded more than once. Wrapping and splitting nodes will fail. Deduplicate it in your lock file, or alias it to a single copy in your bundler.`)}var tm=class e{get name(){return this.node.type.name}constructor(e,t,n=!1,r=null){this.currentNode=null,this.actualDepth=null,this.isBlock=n,this.resolvedPos=e,this.editor=t,this.currentNode=r}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){return this.actualDepth??this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let t=this.from,n=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can’t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}t=this.from+1,n=this.to-1}this.editor.commands.insertContentAt({from:t,to:n},e)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+ +!this.node.isText}get parent(){if(this.depth===0)return null;let t=this.resolvedPos.start(this.resolvedPos.depth-1),n=this.resolvedPos.doc.resolve(t);return new e(n,this.editor)}get before(){let t=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return t.depth!==this.depth&&(t=this.resolvedPos.doc.resolve(this.from-3)),new e(t,this.editor)}get after(){let t=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return t.depth!==this.depth&&(t=this.resolvedPos.doc.resolve(this.to+3)),new e(t,this.editor)}get children(){let t=[];return this.node.content.forEach((n,r)=>{let i=n.isBlock&&!n.isTextblock,a=n.isAtom&&!n.isText,o=n.isInline,s=this.pos+r+ +!a;if(s<0||s>this.resolvedPos.doc.nodeSize-2)return;let c=this.resolvedPos.doc.resolve(s);if(!i&&!o&&c.depth<=this.depth)return;let l=new e(c,this.editor,i,i||o?n:null);i&&(l.actualDepth=this.depth+1),t.push(l)}),t}get firstChild(){return this.children[0]||null}get lastChild(){let e=this.children;return e[e.length-1]||null}closest(e,t={}){let n=null,r=this.parent;for(;r&&!n;){if(r.node.type.name===e){if(Object.keys(t).length>0){let e=r.node.attrs,n=Object.keys(t);for(let r=0;r{n&&r.length>0||(a.node.type.name===e&&i.every(e=>t[e]===a.node.attrs[e])&&r.push(a),n&&r.length>0||(r=r.concat(a.querySelectorAll(e,t,n))))}),r}setAttribute(e){let{tr:t}=this.editor.state;t.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(t)}},nm=`.ProseMirror { position: relative; } @@ -91,37 +91,37 @@ img.ProseMirror-separator { .ProseMirror-focused .ProseMirror-gapcursor { display: block; -}`,nm=class extends Vf{constructor(e={}){super(),this.css=null,this.className=`tiptap`,this.editorView=null,this.isFocused=!1,this.destroyed=!1,this.isInitialized=!1,this.extensionStorage={},this.instanceId=Math.random().toString(36).slice(2,9),this.hasWarnedStaleDecorationRead=!1,this.options={element:typeof document<`u`?document.createElement(`div`):null,content:``,injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,textDirection:void 0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,emitContentError:!1,onBeforeCreate:()=>null,onCreate:()=>null,onMount:()=>null,onUnmount:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:e})=>{throw e},onPaste:()=>null,onDrop:()=>null,onDelete:()=>null,enableExtensionDispatchTransaction:!0},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.utils={getUpdatedPosition:Qd,createMappablePosition:$d},this.setOptions(e),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on(`beforeCreate`,this.options.onBeforeCreate),this.emit(`beforeCreate`,{editor:this}),this.on(`mount`,this.options.onMount),this.on(`unmount`,this.options.onUnmount),this.on(`contentError`,this.options.onContentError),this.on(`create`,this.options.onCreate),this.on(`update`,this.options.onUpdate),this.on(`selectionUpdate`,this.options.onSelectionUpdate),this.on(`transaction`,this.options.onTransaction),this.on(`focus`,this.options.onFocus),this.on(`blur`,this.options.onBlur),this.on(`destroy`,this.options.onDestroy),this.on(`drop`,({event:e,slice:t,moved:n})=>this.options.onDrop(e,t,n)),this.on(`paste`,({event:e,slice:t})=>this.options.onPaste(e,t)),this.on(`delete`,this.options.onDelete);let t=this.createDoc();if(!this.editorState){let e=ou(t,this.options.autofocus);this.editorState=Cr.create({doc:t,schema:this.schema,selection:e||void 0})}$p(this.schema),this.options.element&&this.mount(this.options.element)}mount(e){if(typeof document>`u`)throw Error(`[tiptap error]: The editor cannot be mounted because there is no 'document' defined in this environment.`);this.createView(e),this.emit(`mount`,{editor:this}),this.css&&!document.head.contains(this.css)&&document.head.appendChild(this.css),window.setTimeout(()=>{this.isDestroyed||(this.options.autofocus!==!1&&this.options.autofocus!==null&&this.commands.focus(this.options.autofocus),this.emit(`create`,{editor:this}),this.isInitialized=!0)},0)}unmount(){if(this.editorView){this.editorState=this.editorView.state;let e=this.editorView.dom;e?.editor&&delete e.editor,this.editorView.destroy()}if(this.editorView=null,this.isInitialized=!1,this.css&&!document.querySelectorAll(`.${this.className}`).length)try{typeof this.css.remove==`function`?this.css.remove():this.css.parentNode&&this.css.parentNode.removeChild(this.css)}catch(e){console.warn(`Failed to remove CSS element:`,e)}this.css=null,this.emit(`unmount`,{editor:this})}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager?this.commandManager.chain():Nl.createFakeChain()}can(){return this.commandManager?this.commandManager.can():Nl.createFallbackCan()}injectCSS(){this.options.injectCSS&&typeof document<`u`&&(this.css=lp(tm,this.options.injectNonce))}setOptions(e={}){this.options={...this.options,...e},this.editorView&&this.state&&!this.isDestroyed&&(this.options.editorProps&&this.view.setProps({...this.options.editorProps,attributes:this.getEditorViewAttributes()}),this.view.updateState(this.state))}setEditable(e,t=!0){this.setOptions({editable:e}),t&&this.emit(`update`,{editor:this,transaction:this.state.tr,appendedTransactions:[]})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get view(){return this.editorView?this.editorView:new Proxy({state:this.editorState,updateState:e=>{this.editorState=e},dispatch:e=>{this.dispatchTransaction(e)},composing:!1,dragging:null,editable:!0,isDestroyed:!1},{get:(e,t)=>{if(this.editorView)return this.editorView[t];if(t===`state`)return this.editorState;if(t in e)return Reflect.get(e,t);throw Error(`[tiptap error]: The editor view is not available. Cannot access view['${t}']. The editor may not be mounted yet.`)}})}get state(){return Hf&&!this.hasWarnedStaleDecorationRead&&Bf(this)&&(this.hasWarnedStaleDecorationRead=!0,console.warn("[tiptap warn]: `editor.state` was read while decoration `create()` was running. It returns the pre-transaction document. Use the `state` argument passed to `create()` instead. Helpers like `editor.isActive()` read `editor.state` too, so pass `state` to their standalone versions instead of calling them on the editor.")),this.editorView&&(this.editorState=this.view.state),this.editorState}registerPlugin(e,t){let n=md(t)?t(e,[...this.state.plugins]):[...this.state.plugins,e],r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}unregisterPlugin(e){if(this.isDestroyed)return;let t=this.state.plugins,n=t;if([].concat(e).forEach(e=>{let t=typeof e==`string`?`${e}$`:e.key;n=n.filter(e=>!e.key.startsWith(t))}),t.length===n.length)return;let r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}createExtensionManager(){var e,t;let n=[...this.options.enableCoreExtensions?[Wp,Bp.configure({blockSeparator:(e=this.options.coreExtensionOptions)==null||(e=e.clipboardTextSerializer)==null?void 0:e.blockSeparator}),Vp,Kp,Jp,Xp.configure({value:(t=this.options.coreExtensionOptions)==null||(t=t.tabindex)==null?void 0:t.value}),Up,Yp,Hp,Zp.configure({direction:this.options.textDirection})].filter(e=>typeof this.options.enableCoreExtensions!=`object`||this.options.enableCoreExtensions[e.name]!==!1):[],...this.options.extensions].filter(e=>[`extension`,`node`,`mark`].includes(e?.type));this.extensionManager=new zp(n,this)}createCommandManager(){this.commandManager=new Nl({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let e;try{e=Yu(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(e){if(!(e instanceof Error)||![`[tiptap error]: Invalid JSON content`,`[tiptap error]: Invalid HTML content`].includes(e.message))throw e;let t=Yu(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1});return this.editorState=Cr.create({doc:t,schema:this.schema,selection:ou(t,this.options.autofocus)||void 0}),this.emit(`contentError`,{editor:this,error:e,disableCollaboration:()=>{`collaboration`in this.storage&&typeof this.storage.collaboration==`object`&&this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter(e=>e.name!==`collaboration`),this.createExtensionManager()}}),this.editorState.doc}return e}getEditorViewAttributes(){let e=this.options.editorProps?.attributes;return md(e)?t=>({role:`textbox`,...e(t)}):{role:`textbox`,...e}}createView(e){let{editorProps:t,enableExtensionDispatchTransaction:n}=this.options,r=t.dispatchTransaction||this.dispatchTransaction.bind(this),i=n?this.extensionManager.dispatchTransaction(r):r,a=t.transformPastedHTML,o=this.extensionManager.transformPastedHTML(a);this.editorView=new Rc(e,{...t,attributes:this.getEditorViewAttributes(),dispatchTransaction:i,transformPastedHTML:o,state:this.editorState,markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews});let s=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(s),this.prependClass(),this.injectCSS();let c=this.view.dom;c.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`${this.className} ${this.view.dom.className}`}captureTransaction(e){this.isCapturingTransaction=!0,e(),this.isCapturingTransaction=!1;let t=this.capturedTransaction;return this.capturedTransaction=null,t}dispatchTransaction(e){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=e;return}e.steps.forEach(e=>this.capturedTransaction?.step(e));return}let{state:t,transactions:n}=this.state.applyTransaction(e),r=!this.state.selection.eq(t.selection),i=n.includes(e),a=this.state;if(this.emit(`beforeTransaction`,{editor:this,transaction:e,nextState:t}),!i)return;this.view.updateState(t),this.emit(`transaction`,{editor:this,transaction:e,appendedTransactions:n.slice(1)}),r&&this.emit(`selectionUpdate`,{editor:this,transaction:e});let o=n.findLast(e=>e.getMeta(`focus`)||e.getMeta(`blur`)),s=o?.getMeta(`focus`),c=o?.getMeta(`blur`);s&&this.emit(`focus`,{editor:this,event:s.event,transaction:o}),c&&this.emit(`blur`,{editor:this,event:c.event,transaction:o}),e.getMeta(`preventUpdate`)||!n.some(e=>e.docChanged)||a.doc.eq(t.doc)||this.emit(`update`,{editor:this,transaction:e,appendedTransactions:n.slice(1)})}getAttributes(e){return jd(this.state,e)}isActive(e,t){let n=typeof e==`string`?e:null,r=typeof e==`string`?t:e;return Hd(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return rd(this.state.doc.content,this.schema)}getText(e){let{blockSeparator:t=` +}`,rm=class extends Hf{constructor(e={}){super(),this.css=null,this.className=`tiptap`,this.editorView=null,this.isFocused=!1,this.destroyed=!1,this.isInitialized=!1,this.extensionStorage={},this.instanceId=Math.random().toString(36).slice(2,9),this.hasWarnedStaleDecorationRead=!1,this.options={element:typeof document<`u`?document.createElement(`div`):null,content:``,injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,textDirection:void 0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,emitContentError:!1,onBeforeCreate:()=>null,onCreate:()=>null,onMount:()=>null,onUnmount:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:e})=>{throw e},onPaste:()=>null,onDrop:()=>null,onDelete:()=>null,enableExtensionDispatchTransaction:!0},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.utils={getUpdatedPosition:$d,createMappablePosition:ef},this.setOptions(e),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on(`beforeCreate`,this.options.onBeforeCreate),this.emit(`beforeCreate`,{editor:this}),this.on(`mount`,this.options.onMount),this.on(`unmount`,this.options.onUnmount),this.on(`contentError`,this.options.onContentError),this.on(`create`,this.options.onCreate),this.on(`update`,this.options.onUpdate),this.on(`selectionUpdate`,this.options.onSelectionUpdate),this.on(`transaction`,this.options.onTransaction),this.on(`focus`,this.options.onFocus),this.on(`blur`,this.options.onBlur),this.on(`destroy`,this.options.onDestroy),this.on(`drop`,({event:e,slice:t,moved:n})=>this.options.onDrop(e,t,n)),this.on(`paste`,({event:e,slice:t})=>this.options.onPaste(e,t)),this.on(`delete`,this.options.onDelete);let t=this.createDoc();if(!this.editorState){let e=su(t,this.options.autofocus);this.editorState=wr.create({doc:t,schema:this.schema,selection:e||void 0})}em(this.schema),this.options.element&&this.mount(this.options.element)}mount(e){if(typeof document>`u`)throw Error(`[tiptap error]: The editor cannot be mounted because there is no 'document' defined in this environment.`);this.createView(e),this.emit(`mount`,{editor:this}),this.css&&!document.head.contains(this.css)&&document.head.appendChild(this.css),window.setTimeout(()=>{this.isDestroyed||(this.options.autofocus!==!1&&this.options.autofocus!==null&&this.commands.focus(this.options.autofocus),this.emit(`create`,{editor:this}),this.isInitialized=!0)},0)}unmount(){if(this.editorView){this.editorState=this.editorView.state;let e=this.editorView.dom;e?.editor&&delete e.editor,this.editorView.destroy()}if(this.editorView=null,this.isInitialized=!1,this.css&&!document.querySelectorAll(`.${this.className}`).length)try{typeof this.css.remove==`function`?this.css.remove():this.css.parentNode&&this.css.parentNode.removeChild(this.css)}catch(e){console.warn(`Failed to remove CSS element:`,e)}this.css=null,this.emit(`unmount`,{editor:this})}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager?this.commandManager.chain():Pl.createFakeChain()}can(){return this.commandManager?this.commandManager.can():Pl.createFallbackCan()}injectCSS(){this.options.injectCSS&&typeof document<`u`&&(this.css=up(nm,this.options.injectNonce))}setOptions(e={}){this.options={...this.options,...e},this.editorView&&this.state&&!this.isDestroyed&&(this.options.editorProps&&this.view.setProps({...this.options.editorProps,attributes:this.getEditorViewAttributes()}),this.view.updateState(this.state))}setEditable(e,t=!0){this.setOptions({editable:e}),t&&this.emit(`update`,{editor:this,transaction:this.state.tr,appendedTransactions:[]})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get view(){return this.editorView?this.editorView:new Proxy({state:this.editorState,updateState:e=>{this.editorState=e},dispatch:e=>{this.dispatchTransaction(e)},composing:!1,dragging:null,editable:!0,isDestroyed:!1},{get:(e,t)=>{if(this.editorView)return this.editorView[t];if(t===`state`)return this.editorState;if(t in e)return Reflect.get(e,t);throw Error(`[tiptap error]: The editor view is not available. Cannot access view['${t}']. The editor may not be mounted yet.`)}})}get state(){return Uf&&!this.hasWarnedStaleDecorationRead&&Vf(this)&&(this.hasWarnedStaleDecorationRead=!0,console.warn("[tiptap warn]: `editor.state` was read while decoration `create()` was running. It returns the pre-transaction document. Use the `state` argument passed to `create()` instead. Helpers like `editor.isActive()` read `editor.state` too, so pass `state` to their standalone versions instead of calling them on the editor.")),this.editorView&&(this.editorState=this.view.state),this.editorState}registerPlugin(e,t){let n=hd(t)?t(e,[...this.state.plugins]):[...this.state.plugins,e],r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}unregisterPlugin(e){if(this.isDestroyed)return;let t=this.state.plugins,n=t;if([].concat(e).forEach(e=>{let t=typeof e==`string`?`${e}$`:e.key;n=n.filter(e=>!e.key.startsWith(t))}),t.length===n.length)return;let r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}createExtensionManager(){var e,t;let n=[...this.options.enableCoreExtensions?[Gp,Vp.configure({blockSeparator:(e=this.options.coreExtensionOptions)==null||(e=e.clipboardTextSerializer)==null?void 0:e.blockSeparator}),Hp,qp,Yp,Zp.configure({value:(t=this.options.coreExtensionOptions)==null||(t=t.tabindex)==null?void 0:t.value}),Wp,Xp,Up,Qp.configure({direction:this.options.textDirection})].filter(e=>typeof this.options.enableCoreExtensions!=`object`||this.options.enableCoreExtensions[e.name]!==!1):[],...this.options.extensions].filter(e=>[`extension`,`node`,`mark`].includes(e?.type));this.extensionManager=new Bp(n,this)}createCommandManager(){this.commandManager=new Pl({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let e;try{e=Xu(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(e){if(!(e instanceof Error)||![`[tiptap error]: Invalid JSON content`,`[tiptap error]: Invalid HTML content`].includes(e.message))throw e;let t=Xu(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1});return this.editorState=wr.create({doc:t,schema:this.schema,selection:su(t,this.options.autofocus)||void 0}),this.emit(`contentError`,{editor:this,error:e,disableCollaboration:()=>{`collaboration`in this.storage&&typeof this.storage.collaboration==`object`&&this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter(e=>e.name!==`collaboration`),this.createExtensionManager()}}),this.editorState.doc}return e}getEditorViewAttributes(){let e=this.options.editorProps?.attributes;return hd(e)?t=>({role:`textbox`,...e(t)}):{role:`textbox`,...e}}createView(e){let{editorProps:t,enableExtensionDispatchTransaction:n}=this.options,r=t.dispatchTransaction||this.dispatchTransaction.bind(this),i=n?this.extensionManager.dispatchTransaction(r):r,a=t.transformPastedHTML,o=this.extensionManager.transformPastedHTML(a);this.editorView=new zc(e,{...t,attributes:this.getEditorViewAttributes(),dispatchTransaction:i,transformPastedHTML:o,state:this.editorState,markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews});let s=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(s),this.prependClass(),this.injectCSS();let c=this.view.dom;c.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`${this.className} ${this.view.dom.className}`}captureTransaction(e){this.isCapturingTransaction=!0,e(),this.isCapturingTransaction=!1;let t=this.capturedTransaction;return this.capturedTransaction=null,t}dispatchTransaction(e){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=e;return}e.steps.forEach(e=>this.capturedTransaction?.step(e));return}let{state:t,transactions:n}=this.state.applyTransaction(e),r=!this.state.selection.eq(t.selection),i=n.includes(e),a=this.state;if(this.emit(`beforeTransaction`,{editor:this,transaction:e,nextState:t}),!i)return;this.view.updateState(t),this.emit(`transaction`,{editor:this,transaction:e,appendedTransactions:n.slice(1)}),r&&this.emit(`selectionUpdate`,{editor:this,transaction:e});let o=n.findLast(e=>e.getMeta(`focus`)||e.getMeta(`blur`)),s=o?.getMeta(`focus`),c=o?.getMeta(`blur`);s&&this.emit(`focus`,{editor:this,event:s.event,transaction:o}),c&&this.emit(`blur`,{editor:this,event:c.event,transaction:o}),e.getMeta(`preventUpdate`)||!n.some(e=>e.docChanged)||a.doc.eq(t.doc)||this.emit(`update`,{editor:this,transaction:e,appendedTransactions:n.slice(1)})}getAttributes(e){return Md(this.state,e)}isActive(e,t){let n=typeof e==`string`?e:null,r=typeof e==`string`?t:e;return Ud(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return id(this.state.doc.content,this.schema)}getText(e){let{blockSeparator:t=` -`,textSerializers:n={}}=e||{};return Od(this.state.doc,{blockSeparator:t,textSerializers:{...kd(this.schema),...n}})}get isEmpty(){return qd(this.state.doc)}destroy(){this.destroyed||(this.destroyed=!0,this.emit(`destroy`),this.unmount(),this.removeAllListeners(),this.extensionManager.destroy(),this.extensionManager=null,this.schema=null,this.commandManager=null,this.extensionStorage={})}get isDestroyed(){return this.editorView?.isDestroyed??!0}$node(e,t){return this.$doc?.querySelector(e,t)||null}$nodes(e,t){return this.$doc?.querySelectorAll(e,t)||null}$pos(e){let t=this.state.doc.resolve(e),n=e>0&&t.nodeAfter&&!t.nodeAfter.isText&&t.nodeAfter.isAtom?t.nodeAfter:null;return new em(t,this,!1,n)}get $doc(){return this.$pos(0)}};function rm(e){return new wp({find:e.find,handler:({state:t,range:n,match:r})=>{let i=K(e.getAttributes,void 0,r);if(i===!1||i===null)return null;let{tr:a}=t,o=r[r.length-1],s=r[0];if(o){let r=s.search(/\S/),c=n.from+s.indexOf(o),l=c+o.length;if(Fd(n.from,n.to,t.doc).filter(t=>t.mark.type.excluded.find(n=>n===e.type&&n!==t.mark.type)).filter(e=>e.to>c).length)return null;ln.from&&a.delete(n.from+r,c);let u=n.from+r+o.length;a.addMark(n.from+r,u,e.type.create(i||{})),a.removeStoredMark(e.type)}},undoable:e.undoable})}function im(e){return new wp({find:e.find,handler:({state:t,range:n,match:r})=>{let i=K(e.getAttributes,void 0,r)||{},{tr:a}=t,o=n.from,s=n.to,c=e.type.create(i);if(r[1]){let e=o+r[0].lastIndexOf(r[1]);e>s?e=s:s=e+r[1].length;let t=r[0][r[0].length-1];a.insertText(t,o+r[0].length-1),a.replaceWith(e,s,c)}else if(r[0]){let t=e.type.isInline?o:o-1;a.insert(t,e.type.create(i)).delete(a.mapping.map(o),a.mapping.map(s))}a.scrollIntoView()},undoable:e.undoable})}function am(e){return new wp({find:e.find,handler:({state:t,range:n,match:r})=>{let i=t.doc.resolve(n.from),a=K(e.getAttributes,void 0,r)||{};if(!i.node(-1).canReplaceWith(i.index(-1),i.indexAfter(-1),e.type))return null;t.tr.delete(n.from,n.to).setBlockType(n.from,n.from,e.type,a)},undoable:e.undoable})}function om(e){return new wp({find:e.find,handler:({state:t,range:n,match:r,chain:i})=>{let a=K(e.getAttributes,void 0,r)||{},o=t.tr.delete(n.from,n.to),s=o.doc.resolve(n.from).blockRange(),c=s&&bn(s,e.type,a);if(!c)return null;if(o.wrap(s,c),e.keepMarks&&e.editor){let{selection:n,storedMarks:r}=t,{splittableMarks:i}=e.editor.extensionManager,a=r||n.$to.parentOffset&&n.$from.marks();if(a){let e=a.filter(e=>i.includes(e.type.name));o.ensureMarks(e)}}if(e.keepAttributes){let t=e.type.name===`bulletList`||e.type.name===`orderedList`?`listItem`:`taskList`;i().updateAttributes(t,a).run()}let l=o.doc.resolve(n.from-1).nodeBefore;l&&l.type===e.type&&Mn(o.doc,n.from-1)&&(!e.joinPredicate||e.joinPredicate(r,l))&&o.join(n.from-1)},undoable:e.undoable})}var sm=e=>`touches`in e,cm=class{constructor(e){var t;this.directions=[`bottom-left`,`bottom-right`,`top-left`,`top-right`],this.minSize={height:8,width:8},this.preserveAspectRatio=!1,this.classNames={container:``,wrapper:``,handle:``,resizing:``},this.initialWidth=0,this.initialHeight=0,this.aspectRatio=1,this.isResizing=!1,this.activeHandle=null,this.startX=0,this.startY=0,this.startWidth=0,this.startHeight=0,this.isShiftKeyPressed=!1,this.lastEditableState=void 0,this.handleMap=new Map,this.handleEditorUpdate=()=>{let e=this.editor.isEditable;e!==this.lastEditableState&&(this.lastEditableState=e,e?e&&this.handleMap.size===0&&this.attachHandles():this.removeHandles())},this.handleMouseMove=e=>{if(!this.isResizing||!this.activeHandle)return;let t=e.clientX-this.startX,n=e.clientY-this.startY;this.handleResize(t,n)},this.handleTouchMove=e=>{if(!this.isResizing||!this.activeHandle)return;let t=e.touches[0];if(!t)return;let n=t.clientX-this.startX,r=t.clientY-this.startY;this.handleResize(n,r)},this.handleMouseUp=()=>{if(!this.isResizing)return;let e=this.element.offsetWidth,t=this.element.offsetHeight;this.onCommit(e,t),this.isResizing=!1,this.activeHandle=null,this.container.dataset.resizeState=`false`,this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener(`mousemove`,this.handleMouseMove),document.removeEventListener(`mouseup`,this.handleMouseUp),document.removeEventListener(`keydown`,this.handleKeyDown),document.removeEventListener(`keyup`,this.handleKeyUp)},this.handleKeyDown=e=>{e.key===`Shift`&&(this.isShiftKeyPressed=!0)},this.handleKeyUp=e=>{e.key===`Shift`&&(this.isShiftKeyPressed=!1)},this.node=e.node,this.editor=e.editor,this.element=e.element,this.element.draggable=!1,this.contentElement=e.contentElement,this.getPos=e.getPos,this.onResize=e.onResize,this.onCommit=e.onCommit,this.onUpdate=e.onUpdate,e.options?.min&&(this.minSize={...this.minSize,...e.options.min}),e.options?.max&&(this.maxSize=e.options.max),e!=null&&(t=e.options)!=null&&t.directions&&(this.directions=e.options.directions),e.options?.preserveAspectRatio&&(this.preserveAspectRatio=e.options.preserveAspectRatio),e.options?.className&&(this.classNames={container:e.options.className.container||``,wrapper:e.options.className.wrapper||``,handle:e.options.className.handle||``,resizing:e.options.className.resizing||``}),e.options?.createCustomHandle&&(this.createCustomHandle=e.options.createCustomHandle),this.wrapper=this.createWrapper(),this.container=this.createContainer(),this.applyInitialSize(),this.attachHandles(),this.editor.on(`update`,this.handleEditorUpdate)}get dom(){return this.container}get contentDOM(){return this.contentElement??null}update(e,t,n){return e.type===this.node.type&&(this.node=e,!this.onUpdate||this.onUpdate(e,t,n))}destroy(){this.isResizing&&(this.container.dataset.resizeState=`false`,this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener(`mousemove`,this.handleMouseMove),document.removeEventListener(`mouseup`,this.handleMouseUp),document.removeEventListener(`keydown`,this.handleKeyDown),document.removeEventListener(`keyup`,this.handleKeyUp),this.isResizing=!1,this.activeHandle=null),this.editor.off(`update`,this.handleEditorUpdate),this.container.remove()}createContainer(){let e=document.createElement(`div`);return e.dataset.resizeContainer=``,e.dataset.node=this.node.type.name,e.style.display=this.node.type.isInline?`inline-flex`:`flex`,this.classNames.container&&(e.className=this.classNames.container),e.appendChild(this.wrapper),e}createWrapper(){let e=document.createElement(`div`);return e.style.position=`relative`,e.style.display=`block`,e.dataset.resizeWrapper=``,this.classNames.wrapper&&(e.className=this.classNames.wrapper),e.appendChild(this.element),e}createHandle(e){let t=document.createElement(`div`);return t.dataset.resizeHandle=e,t.style.position=`absolute`,this.classNames.handle&&(t.className=this.classNames.handle),t}positionHandle(e,t){let n=t.includes(`top`),r=t.includes(`bottom`),i=t.includes(`left`),a=t.includes(`right`);n&&(e.style.top=`0`),r&&(e.style.bottom=`0`),i&&(e.style.left=`0`),a&&(e.style.right=`0`),(t===`top`||t===`bottom`)&&(e.style.left=`0`,e.style.right=`0`),(t===`left`||t===`right`)&&(e.style.top=`0`,e.style.bottom=`0`)}attachHandles(){this.directions.forEach(e=>{let t;t=this.createCustomHandle?this.createCustomHandle(e):this.createHandle(e),t instanceof HTMLElement||(console.warn(`[ResizableNodeView] createCustomHandle("${e}") did not return an HTMLElement. Falling back to default handle.`),t=this.createHandle(e)),this.createCustomHandle||this.positionHandle(t,e),t.addEventListener(`mousedown`,t=>this.handleResizeStart(t,e)),t.addEventListener(`touchstart`,t=>this.handleResizeStart(t,e)),this.handleMap.set(e,t),this.wrapper.appendChild(t)})}removeHandles(){this.handleMap.forEach(e=>e.remove()),this.handleMap.clear()}applyInitialSize(){let e=this.node.attrs.width,t=this.node.attrs.height;e?(this.element.style.width=`${e}px`,this.initialWidth=e):this.initialWidth=this.element.offsetWidth,t?(this.element.style.height=`${t}px`,this.initialHeight=t):this.initialHeight=this.element.offsetHeight,this.initialWidth>0&&this.initialHeight>0&&(this.aspectRatio=this.initialWidth/this.initialHeight)}handleResizeStart(e,t){e.preventDefault(),e.stopPropagation(),this.isResizing=!0,this.activeHandle=t,sm(e)?(this.startX=e.touches[0].clientX,this.startY=e.touches[0].clientY):(this.startX=e.clientX,this.startY=e.clientY),this.startWidth=this.element.offsetWidth,this.startHeight=this.element.offsetHeight,this.startWidth>0&&this.startHeight>0&&(this.aspectRatio=this.startWidth/this.startHeight),this.getPos(),this.container.dataset.resizeState=`true`,this.classNames.resizing&&this.container.classList.add(this.classNames.resizing),document.addEventListener(`mousemove`,this.handleMouseMove),document.addEventListener(`touchmove`,this.handleTouchMove),document.addEventListener(`mouseup`,this.handleMouseUp),document.addEventListener(`keydown`,this.handleKeyDown),document.addEventListener(`keyup`,this.handleKeyUp)}handleResize(e,t){if(!this.activeHandle)return;let n=this.preserveAspectRatio||this.isShiftKeyPressed,{width:r,height:i}=this.calculateNewDimensions(this.activeHandle,e,t),a=this.applyConstraints(r,i,n);this.element.style.width=`${a.width}px`,this.element.style.height=`${a.height}px`,this.onResize&&this.onResize(a.width,a.height)}calculateNewDimensions(e,t,n){let r=this.startWidth,i=this.startHeight,a=e.includes(`right`),o=e.includes(`left`),s=e.includes(`bottom`),c=e.includes(`top`);return a?r=this.startWidth+t:o&&(r=this.startWidth-t),s?i=this.startHeight+n:c&&(i=this.startHeight-n),(e===`right`||e===`left`)&&(r=this.startWidth+(a?t:-t)),(e===`top`||e===`bottom`)&&(i=this.startHeight+(s?n:-n)),this.preserveAspectRatio||this.isShiftKeyPressed?this.applyAspectRatio(r,i,e):{width:r,height:i}}applyConstraints(e,t,n){if(!n){let n=Math.max(this.minSize.width,e),r=Math.max(this.minSize.height,t);return this.maxSize?.width&&(n=Math.min(this.maxSize.width,n)),this.maxSize?.height&&(r=Math.min(this.maxSize.height,r)),{width:n,height:r}}let r=e,i=t;return rthis.maxSize.width&&(r=this.maxSize.width,i=r/this.aspectRatio),this.maxSize?.height&&i>this.maxSize.height&&(i=this.maxSize.height,r=i*this.aspectRatio),{width:r,height:i}}applyAspectRatio(e,t,n){return n===`left`||n===`right`?{width:e,height:e/this.aspectRatio}:n===`top`||n===`bottom`?{width:t*this.aspectRatio,height:t}:{width:e,height:e/this.aspectRatio}}},lm=class e extends jp{constructor(...e){super(...e),this.type=`node`}static create(t={}){let n=typeof t==`function`?t():t;return new e(n)}configure(e){return super.configure(e)}extend(e){let t=typeof e==`function`?e():e;return super.extend(t)}};function um(e){return new Np({find:e.find,handler:({state:t,range:n,match:r,pasteEvent:i})=>{let a=K(e.getAttributes,void 0,r,i);if(a===!1||a===null)return null;let{tr:o}=t,s=r[r.length-1],c=r[0],l=n.to;if(s){let i=c.search(/\S/),u=n.from+c.indexOf(s),d=u+s.length;if(Fd(n.from,n.to,t.doc).filter(t=>t.mark.type.excluded.find(n=>n===e.type&&n!==t.mark.type)).filter(e=>e.to>u).length)return null;dn.from&&o.delete(n.from+i,u),l=n.from+i+s.length,o.addMark(n.from+i,l,e.type.create(a||{})),r.index!==void 0&&r.input!==void 0&&r.index+r[0].length>=r.input.length||o.removeStoredMark(e.type)}}})}function dm(e){return d((t,n)=>({get(){return t(),e},set(t){e=t,requestAnimationFrame(()=>{requestAnimationFrame(()=>{n()})})}}))}var fm=class extends nm{constructor(e={}){return super(e),this.contentComponent=null,this.appContext=null,this.reactiveState=dm(this.view.state),this.reactiveExtensionStorage=dm(this.extensionStorage),this.on(`beforeTransaction`,({nextState:e})=>{this.reactiveState.value=e,this.reactiveExtensionStorage.value=this.extensionStorage}),u(this)}get state(){var e;return(e=this.reactiveState)==null||e.value,super.state}get storage(){return this.reactiveExtensionStorage?this.reactiveExtensionStorage.value:super.storage}registerPlugin(e,t){let n=super.registerPlugin(e,t);return this.reactiveState&&(this.reactiveState.value=n),n}unregisterPlugin(e){let t=super.unregisterPlugin(e);return this.reactiveState&&t&&(this.reactiveState.value=t),t}},pm=i({name:`EditorContent`,props:{editor:{default:null,type:Object}},setup(e){let t=w(),n=m();return b(()=>{let r=e.editor;r&&r.options.element&&t.value&&f(()=>{if(!t.value||!r.view.dom?.parentNode)return;let e=T(t.value);t.value.append(...r.view.dom.parentNode.childNodes),r.view.updateRoot(),r.contentComponent=n.ctx._,n&&(r.appContext={...n.appContext,provides:n.provides}),r.setOptions({element:e}),r.createNodeViews()})}),p(()=>{let t=e.editor;t&&(t.contentComponent=null,t.appContext=null)}),{rootEl:t}},render(){return ae(`div`,{ref:e=>{this.rootEl=e}})}});i({name:`NodeViewContent`,props:{as:{type:String,default:`div`}},inject:{nodeViewContentRef:{default:void 0}},mounted(){let e=this.nodeViewContentRef;e&&this.$el&&e(this.$el)},beforeUnmount(){let e=this.nodeViewContentRef;e&&e(null)},render(){return ae(this.as,{style:{whiteSpace:`pre-wrap`},"data-node-view-content":``})}}),i({name:`NodeViewWrapper`,props:{as:{type:String,default:`div`}},inject:[`onDragStart`,`decorationClasses`],render(){var e;return ae(this.as,{class:this.decorationClasses,style:{whiteSpace:`normal`},"data-node-view-wrapper":``,onDragstart:this.onDragStart},(e=this.$slots).default?.call(e))}});var mm=(e={})=>{let t=C();return h(()=>{t.value=new fm(e)}),p(()=>{var e;(e=t.value)==null||e.destroy()}),t};i({name:`MarkViewContent`,props:{as:{type:String,default:`span`}},render(){return ae(this.as,{style:{whiteSpace:`inherit`},"data-mark-view-content":``})}});function hm(e={}){return new V({view(t){return new gm(t,e)}})}var gm=class{constructor(e,t){this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.lastDragEvent=null,this.width=t.width??1,this.color=t.color===!1?void 0:t.color||`black`,this.class=t.class,this.handlers=[`dragover`,`dragend`,`drop`,`dragleave`].map(t=>{let n=e=>{this[t](e)};return e.dom.addEventListener(t,n),{name:t,handler:n}})}destroy(){this.setCursor(null),this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){if(this.cursorPos!=null&&t.doc!=e.state.doc){if(this.lastDragEvent){let e=this.computeTarget(this.lastDragEvent);e==this.cursorPos?this.updateOverlay():this.setCursor(e)}else this.updateOverlay()}}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),t=!e.parent.inlineContent,n,r=this.editorView.dom,i=r.getBoundingClientRect(),a=i.width/r.offsetWidth,o=i.height/r.offsetHeight;if(t){let t=e.nodeBefore,r=e.nodeAfter;if(t||r){let e=this.editorView.nodeDOM(this.cursorPos-(t?t.nodeSize:0));if(e){let i=e.getBoundingClientRect(),a=t?i.bottom:i.top;t&&r&&(a=(a+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let s=this.width/2*o;n={left:i.left,right:i.right,top:a-s,bottom:a+s}}}}if(!n){let e=this.editorView.coordsAtPos(this.cursorPos),t=this.width/2*a;n={left:e.left-t,right:e.left+t,top:e.top,bottom:e.bottom}}let s=this.editorView.dom.offsetParent;this.element||(this.element=s.appendChild(document.createElement(`div`)),this.class&&(this.element.className=this.class),this.element.style.cssText=`position: absolute; z-index: 50; pointer-events: none;`,this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle(`prosemirror-dropcursor-block`,t),this.element.classList.toggle(`prosemirror-dropcursor-inline`,!t);let c,l;if(!s||s==document.body&&getComputedStyle(s).position==`static`)c=-pageXOffset,l=-pageYOffset;else{let e=s.getBoundingClientRect(),t=e.width/s.offsetWidth,n=e.height/s.offsetHeight;c=e.left-s.scrollLeft*t,l=e.top-s.scrollTop*n}this.element.style.left=(n.left-c)/a+`px`,this.element.style.top=(n.top-l)/o+`px`,this.element.style.width=(n.right-n.left)/a+`px`,this.element.style.height=(n.bottom-n.top)/o+`px`}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}computeTarget(e){let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),n=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),r=n&&n.type.spec.disableDropCursor,i=typeof r==`function`?r(this.editorView,t,e):r;if(!t||i)return null;let a=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let e=Rn(this.editorView.state.doc,a,this.editorView.dragging.slice);e!=null&&(a=e)}return a}dragover(e){if(!this.editorView.editable)return;this.lastDragEvent=e;let t=this.computeTarget(e);t!=null&&(this.setCursor(t),this.scheduleRemoval(5e3))}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}},_m=class e extends R{constructor(e){super(e,e)}map(t,n){let r=t.resolve(n.map(this.head));return e.valid(r)?new e(r):R.near(r)}content(){return L.empty}eq(t){return t instanceof e&&t.head==this.head}toJSON(){return{type:`gapcursor`,pos:this.head}}static fromJSON(t,n){if(typeof n.pos!=`number`)throw RangeError(`Invalid input for GapCursor.fromJSON`);return new e(t.resolve(n.pos))}getBookmark(){return new vm(this.anchor)}static valid(e){let t=e.parent;if(t.inlineContent||!bm(e)||!xm(e))return!1;let n=t.type.spec.allowGapCursor;if(n!=null)return n;let r=t.contentMatchAt(e.index()).defaultType;return r&&r.isTextblock}static findGapCursorFrom(t,n,r=!1){search:for(;;){if(!r&&e.valid(t))return t;let i=t.pos,a=null;for(let r=t.depth;;r--){let o=t.node(r);if(n>0?t.indexAfter(r)0){a=o.child(n>0?t.indexAfter(r):t.index(r)-1);break}if(r==0)return null;i+=n;let s=t.doc.resolve(i);if(e.valid(s))return s}for(;;){let o=n>0?a.firstChild:a.lastChild;if(!o){if(a.isAtom&&!a.isText&&!B.isSelectable(a)){t=t.doc.resolve(i+a.nodeSize*n),r=!1;continue search}break}a=o,i+=n;let s=t.doc.resolve(i);if(e.valid(s))return s}return null}}};_m.prototype.visible=!1,_m.findFrom=_m.findGapCursorFrom,R.jsonID(`gapcursor`,_m);var vm=class e{constructor(e){this.pos=e}map(t){return new e(t.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return _m.valid(t)?new _m(t):R.near(t)}};function ym(e){return e.isAtom||e.spec.isolating||e.spec.createGapCursor}function bm(e){for(let t=e.depth;t>=0;t--){let n=e.index(t),r=e.node(t);if(n==0){if(r.type.spec.isolating)return!0}else for(let e=r.child(n-1);;e=e.lastChild){if(e.childCount==0&&!e.inlineContent||ym(e.type))return!0;if(e.inlineContent)return!1}}return!0}function xm(e){for(let t=e.depth;t>=0;t--){let n=e.indexAfter(t),r=e.node(t);if(n==r.childCount){if(r.type.spec.isolating)return!0}else for(let e=r.child(n);;e=e.firstChild){if(e.childCount==0&&!e.inlineContent||ym(e.type))return!0;if(e.inlineContent)return!1}}return!0}function Sm(){return new V({props:{decorations:Dm,createSelectionBetween(e,t,n){return t.pos==n.pos&&_m.valid(n)?new _m(n):null},handleClick:Tm,handleKeyDown:Cm,handleDOMEvents:{beforeinput:Em}}})}var Cm=al({ArrowLeft:wm(`horiz`,-1),ArrowRight:wm(`horiz`,1),ArrowUp:wm(`vert`,-1),ArrowDown:wm(`vert`,1)});function wm(e,t){let n=e==`vert`?t>0?`down`:`up`:t>0?`right`:`left`;return function(e,r,i){let a=e.selection,o=t>0?a.$to:a.$from,s=a.empty;if(a instanceof z){if(!i.endOfTextblock(n)||o.depth==0)return!1;s=!1,o=e.doc.resolve(t>0?o.after():o.before())}let c=_m.findGapCursorFrom(o,t,s);return c?(r&&r(e.tr.setSelection(new _m(c))),!0):!1}}function Tm(e,t,n){if(!e||!e.editable)return!1;let r=e.state.doc.resolve(t);if(!_m.valid(r))return!1;let i=e.posAtCoords({left:n.clientX,top:n.clientY});return i&&i.inside>-1&&B.isSelectable(e.state.doc.nodeAt(i.inside))?!1:(e.dispatch(e.state.tr.setSelection(new _m(r))),!0)}function Em(e,t){if(t.inputType!=`insertCompositionText`||!(e.state.selection instanceof _m))return!1;let{$from:n}=e.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(e.state.schema.nodes.text);if(!r)return!1;let i=F.empty;for(let e=r.length-1;e>=0;e--)i=F.from(r[e].createAndFill(null,i));let a=e.state.tr.replace(n.pos,n.pos,new L(i,0,0));return a.setSelection(z.near(a.doc.resolve(n.pos+1))),e.dispatch(a),!1}function Dm(e){if(!(e.selection instanceof _m))return null;let t=document.createElement(`div`);return t.className=`ProseMirror-gapcursor`,W.create(e.doc,[nc.widget(e.selection.head,t,{key:`gapcursor`})])}var Om=J.create({name:`characterCount`,addOptions(){return{limit:null,autoTrim:!0,mode:`textSize`,textCounter:e=>e.length,wordCounter:e=>e.split(` `).filter(e=>e!==``).length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=e=>{let t=e?.node||this.editor.state.doc;if((e?.mode||this.options.mode)===`textSize`){let e=t.textBetween(0,t.content.size,void 0,` `);return this.options.textCounter(e)}return t.nodeSize},this.storage.words=e=>{let t=e?.node||this.editor.state.doc,n=t.textBetween(0,t.content.size,` `,` `);return this.options.wordCounter(n)}},addProseMirrorPlugins(){let e=!1;return[new V({key:new H(`characterCount`),appendTransaction:(t,n,r)=>{if(e)return;let i=this.options.limit,a=this.options.autoTrim;if(i==null||i===0||a===!1){e=!0;return}let o=this.storage.characters({node:r.doc});if(o>i){let t=o-i;console.warn(`[CharacterCount] Initial content exceeded limit of ${i} characters. Content was automatically trimmed.`);let n=r.tr.deleteRange(0,t);return e=!0,n}e=!0},filterTransaction:(e,t)=>{let n=this.options.limit;if(!e.docChanged||n===0||n==null)return!0;let r=this.storage.characters({node:t.doc}),i=this.storage.characters({node:e.doc});if(i<=n||r>n&&i>n&&i<=r)return!0;if(r>n&&i>n&&i>r||!e.getMeta(`paste`))return!1;let a=e.selection.$head.pos,o=a-(i-n),s=a;return e.deleteRange(o,s),!(this.storage.characters({node:e.doc})>n)}})]}}),km=J.create({name:`dropCursor`,addOptions(){return{color:`currentColor`,width:1,class:void 0}},addProseMirrorPlugins(){return[hm(this.options)]}});J.create({name:`focus`,addOptions(){return{className:`has-focus`,mode:`all`}},addProseMirrorPlugins(){return[new V({key:new H(`focus`),props:{decorations:({doc:e,selection:t})=>{let{isEditable:n,isFocused:r}=this.editor,{anchor:i}=t,a=[];if(!n||!r)return W.create(e,[]);let o=0;this.options.mode===`deepest`&&e.descendants((e,t)=>{if(!e.isText){if(!(i>=t&&i<=t+e.nodeSize-1))return!1;o+=1}});let s=0;return e.descendants((e,t)=>{if(e.isText||!(i>=t&&i<=t+e.nodeSize-1))return!1;if(s+=1,this.options.mode===`deepest`&&o-s>0||this.options.mode===`shallowest`&&s>1)return this.options.mode===`deepest`;a.push(nc.node(t,t+e.nodeSize,{class:this.options.className}))}),W.create(e,a)}}})]}});var Am=J.create({name:`gapCursor`,addProseMirrorPlugins(){return[Sm()]},extendNodeSchema(e){return{allowGapCursor:K(G(e,`allowGapCursor`,{name:e.name,options:e.options,storage:e.storage}))??null}}}),jm=`placeholder`,Mm=new H(`tiptap__placeholder`);function Nm(e){let{editor:t,placeholder:n,dataAttribute:r,pos:i,node:a,isEmptyDoc:o,hasAnchor:s,classes:{emptyNode:c,emptyEditor:l}}=e,u=[c];return o&&u.push(l),nc.node(i,i+a.nodeSize,{class:u.join(` `),[r]:typeof n==`function`?n({editor:t,node:a,pos:i,hasAnchor:s}):n})}function Pm(e,t){return typeof e==`function`?e(t):e}function Fm({editor:e,options:t,dataAttribute:n,doc:r,selection:i,from:a,to:o}){let{anchor:s}=i,c=[],l=e.isEmpty;return r.nodesBetween(a,o,(r,i)=>{let a=s>=i&&s<=i+r.nodeSize,o=!r.isLeaf&&qd(r);return r.type.isTextblock&&(a||!t.showOnlyCurrent)&&o&&c.push(Nm({editor:e,isEmptyDoc:l,dataAttribute:n,hasAnchor:a,placeholder:t.placeholder,classes:{emptyEditor:t.emptyEditorClass,emptyNode:Pm(t.emptyNodeClass,{editor:e,node:r,pos:i,hasAnchor:a})},node:r,pos:i})),t.includeChildren}),c}function Im({editor:e,options:t,dataAttribute:n,doc:r,selection:i}){if(!e.isEditable&&t.showOnlyWhenEditable)return null;let{anchor:a}=i,o=[],s=e.isEmpty;if(t.showOnlyCurrent&&!t.includeChildren){let i=r.resolve(a),c=i.depth>0?i.node(1):i.nodeAfter,l=i.depth>0?i.before(1):a;if(c&&c.type.isTextblock&&qd(c)){let r=a>=l&&a<=l+c.nodeSize;o.push(Nm({editor:e,isEmptyDoc:s,dataAttribute:n,hasAnchor:r,placeholder:t.placeholder,classes:{emptyEditor:t.emptyEditorClass,emptyNode:Pm(t.emptyNodeClass,{editor:e,node:c,pos:l,hasAnchor:r})},node:c,pos:l}))}}else o.push(...Fm({editor:e,options:t,dataAttribute:n,doc:r,selection:i,from:0,to:r.content.size}));return W.create(r,o)}function Lm(e,t){let n=e.resolve(t);if(n.depth===0){let e=n.nodeAfter??n.nodeBefore;if(!e)return{from:t,to:t};let r=n.nodeAfter?t:t-e.nodeSize;return{from:r,to:r+e.nodeSize}}let r=n.before(1);return{from:r,to:r+n.node(1).nodeSize}}function Rm(e,t){return{from:Math.max(0,t.from),to:Math.min(e.content.size,t.to)}}function zm(e,t,n){let r=[];return e.forEach((e,i)=>{let a=i,o=a+e.nodeSize,s=a+1,c=o+1;st&&r.push({from:a,to:o})}),r}function Bm(e){if(e.length===0)return[];let t=[...e].sort((e,t)=>e.from-t.from),n=[{...t[0]}];for(let e=1;et.from?n.push(Rm(e,Lm(e,Math.min(t.to,e.content.size+1)-1))):t.frome.from>=t&&e.to<=c);l.length&&(s=s.remove(l));let u=Fm({editor:n,options:r,dataAttribute:i,doc:a,selection:o,from:t,to:c});u.length&&(s=s.add(a,u))}return s}function Gm({editor:e,options:t,dataAttribute:n}){return{init(r,i){return Im({editor:e,options:t,dataAttribute:n,doc:i.doc,selection:i.selection})??W.empty},apply(r,i,a,o){return!r.docChanged&&!r.selectionSet?i:Wm({decorations:i.map(r.mapping,r.doc),ranges:Hm(r,a,o),editor:e,options:t,dataAttribute:n,doc:o.doc,selection:o.selection})}}}function Km(e){return e.replace(/\s+/g,`-`).replace(/[^a-zA-Z0-9-]/g,``).replace(/^[0-9-]+/,``).replace(/^-+/,``).toLowerCase()}function qm({editor:e,options:t}){let n=t.dataAttribute?`data-${Km(t.dataAttribute)}`:`data-${jm}`,r=t.showOnlyCurrent&&!t.includeChildren;return new V({key:Mm,...r?{}:{state:Gm({editor:e,options:t,dataAttribute:n})},props:{decorations:r?({doc:r,selection:i})=>Im({editor:e,options:t,dataAttribute:n,doc:r,selection:i}):n=>t.showOnlyWhenEditable&&!e.isEditable?W.empty:Mm.getState(n)??W.empty}})}var Jm=J.create({name:`placeholder`,addOptions(){return{emptyEditorClass:`is-editor-empty`,emptyNodeClass:`is-empty`,dataAttribute:jm,placeholder:`Write something …`,showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[qm({editor:this.editor,options:this.options})]}});function Ym(e,t){return!e.selection.empty&&!Jd(e.selection)&&t.isEditable}function Xm(e,t){return Ym(e,t)&&!t.isFocused&&!t.view.dragging}function Zm(){var e;(e=window.getSelection())==null||e.removeAllRanges()}function Qm(e){e.focus()}J.create({name:`selection`,addOptions(){return{className:`selection`}},addProseMirrorPlugins(){let{editor:e,options:t}=this;return[new V({key:new H(`selection`),props:{decorations(n){return Xm(n,e)?W.create(n.doc,[nc.inline(n.selection.from,n.selection.to,{class:t.className})]):null},handleDOMEvents:{blur(t){return Ym(t.state,e)&&Zm(),!1},focus(t){return Ym(t.state,e)&&requestAnimationFrame(()=>{!e.isDestroyed&&t.hasFocus()&&Qm(t)}),!1}}}})]}});function $m({types:e,node:t}){return t&&Array.isArray(e)&&e.includes(t.type)||t?.type===e}var eh=J.create({name:`trailingNode`,addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){let e=new H(this.name),t=this.options.node||this.editor.schema.topNodeType.contentMatch.defaultType?.name||`paragraph`,n=Object.entries(this.editor.schema.nodes).map(([,e])=>e).filter(e=>(this.options.notAfter||[]).concat(t).includes(e.name));return[new V({key:e,appendTransaction:(n,r,i)=>{let{doc:a,tr:o,schema:s}=i,c=e.getState(i),l=a.content.size,u=s.nodes[t];if(!n.some(e=>e.getMeta(`skipTrailingNode`))&&c)return o.insert(l,u.create())},state:{init:(e,t)=>{let r=t.tr.doc.lastChild;return!$m({node:r,types:n})},apply:(e,t)=>{if(!e.docChanged||e.getMeta(`__uniqueIDTransaction`))return t;let r=e.doc.lastChild;return!$m({node:r,types:n})}}})]}}),th=J.create({name:`undoRedo`,addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:e,dispatch:t})=>kl(e,t),redo:()=>({state:e,dispatch:t})=>Al(e,t)}},addProseMirrorPlugins(){return[Dl(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}),nh=Om,rh=new WeakSet,ih=new WeakSet;function ah(e){let t=e;return rh.add(t),t}function oh(e){return Array.isArray(e)&&rh.has(e)}function sh(e){return e.flatMap(e=>e==null?[]:Array.isArray(e)&&ih.has(e)&&!oh(e)?sh(e):[e])}function ch(e,t){if(e===`slot`)return 0;if(e instanceof Function){let n=e(t);return Array.isArray(n)&&!oh(n)&&!ih.has(n)?ah(n):n}let{children:n,...r}=t??{};if(e===`svg`)throw Error(`SVG elements are not supported in the JSX syntax, use the array syntax instead`);if(Array.isArray(n)){if(oh(n))return ah([e,r,n]);if(n.length===0)return ah([e,r]);let t=sh(n);return t.length===0?ah([e,r]):ah([e,r,...t])}return ah(n==null?[e,r]:[e,r,n])}var lh=(e,t)=>ch(e,t),uh=(e,t)=>{let{state:n}=e,{selection:r}=n;if(!r.empty)return!1;let{$from:i}=r;if(i.parentOffset!==0)return!1;let a=i.depth-1;if(a<0)return!1;let o=i.node(a),s=i.index(a);if(s===0)return!1;if(o.type===t)return e.commands.lift(t.name);let c=o.child(s-1);if(c.type!==t||!c.lastChild?.isTextblock)return!1;let l=i.before()-1-1;return e.commands.command(({tr:e,dispatch:t})=>{if(!t)return!0;let n=i.parent.content,r=new L(n,0,0);return e.replace(l,i.after(),r),e.setSelection(z.create(e.doc,l)),e.scrollIntoView(),t(e),!0})},dh=/^\s*>\s$/,fh=lm.create({name:`blockquote`,addOptions(){return{HTMLAttributes:{}}},content:`block+`,group:`block`,defining:!0,parseHTML(){return[{tag:`blockquote`}]},renderHTML({HTMLAttributes:e}){return lh(`blockquote`,{...q(this.options.HTMLAttributes,e),children:lh(`slot`,{})})},parseMarkdown:(e,t)=>{let n=t.parseBlockChildren??t.parseChildren;return t.createNode(`blockquote`,void 0,n(e.tokens||[]))},renderMarkdown:(e,t)=>{if(!e.content)return``;let n=[];return e.content.forEach((e,r)=>{let i=(t.renderChild?.call(t,e,r)??t.renderChildren([e])).split(` +`,textSerializers:n={}}=e||{};return kd(this.state.doc,{blockSeparator:t,textSerializers:{...Ad(this.schema),...n}})}get isEmpty(){return Jd(this.state.doc)}destroy(){this.destroyed||(this.destroyed=!0,this.emit(`destroy`),this.unmount(),this.removeAllListeners(),this.extensionManager.destroy(),this.extensionManager=null,this.schema=null,this.commandManager=null,this.extensionStorage={})}get isDestroyed(){return this.editorView?.isDestroyed??!0}$node(e,t){return this.$doc?.querySelector(e,t)||null}$nodes(e,t){return this.$doc?.querySelectorAll(e,t)||null}$pos(e){let t=this.state.doc.resolve(e),n=e>0&&t.nodeAfter&&!t.nodeAfter.isText&&t.nodeAfter.isAtom?t.nodeAfter:null;return new tm(t,this,!1,n)}get $doc(){return this.$pos(0)}};function im(e){return new Tp({find:e.find,handler:({state:t,range:n,match:r})=>{let i=G(e.getAttributes,void 0,r);if(i===!1||i===null)return null;let{tr:a}=t,o=r[r.length-1],s=r[0];if(o){let r=s.search(/\S/),c=n.from+s.indexOf(o),l=c+o.length;if(Id(n.from,n.to,t.doc).filter(t=>t.mark.type.excluded.find(n=>n===e.type&&n!==t.mark.type)).filter(e=>e.to>c).length)return null;ln.from&&a.delete(n.from+r,c);let u=n.from+r+o.length;a.addMark(n.from+r,u,e.type.create(i||{})),a.removeStoredMark(e.type)}},undoable:e.undoable})}function am(e){return new Tp({find:e.find,handler:({state:t,range:n,match:r})=>{let i=G(e.getAttributes,void 0,r)||{},{tr:a}=t,o=n.from,s=n.to,c=e.type.create(i);if(r[1]){let e=o+r[0].lastIndexOf(r[1]);e>s?e=s:s=e+r[1].length;let t=r[0][r[0].length-1];a.insertText(t,o+r[0].length-1),a.replaceWith(e,s,c)}else if(r[0]){let t=e.type.isInline?o:o-1;a.insert(t,e.type.create(i)).delete(a.mapping.map(o),a.mapping.map(s))}a.scrollIntoView()},undoable:e.undoable})}function om(e){return new Tp({find:e.find,handler:({state:t,range:n,match:r})=>{let i=t.doc.resolve(n.from),a=G(e.getAttributes,void 0,r)||{};if(!i.node(-1).canReplaceWith(i.index(-1),i.indexAfter(-1),e.type))return null;t.tr.delete(n.from,n.to).setBlockType(n.from,n.from,e.type,a)},undoable:e.undoable})}function sm(e){return new Tp({find:e.find,handler:({state:t,range:n,match:r,chain:i})=>{let a=G(e.getAttributes,void 0,r)||{},o=t.tr.delete(n.from,n.to),s=o.doc.resolve(n.from).blockRange(),c=s&&xn(s,e.type,a);if(!c)return null;if(o.wrap(s,c),e.keepMarks&&e.editor){let{selection:n,storedMarks:r}=t,{splittableMarks:i}=e.editor.extensionManager,a=r||n.$to.parentOffset&&n.$from.marks();if(a){let e=a.filter(e=>i.includes(e.type.name));o.ensureMarks(e)}}if(e.keepAttributes){let t=e.type.name===`bulletList`||e.type.name===`orderedList`?`listItem`:`taskList`;i().updateAttributes(t,a).run()}let l=o.doc.resolve(n.from-1).nodeBefore;l&&l.type===e.type&&Nn(o.doc,n.from-1)&&(!e.joinPredicate||e.joinPredicate(r,l))&&o.join(n.from-1)},undoable:e.undoable})}var cm=e=>`touches`in e,lm=class{constructor(e){var t;this.directions=[`bottom-left`,`bottom-right`,`top-left`,`top-right`],this.minSize={height:8,width:8},this.preserveAspectRatio=!1,this.classNames={container:``,wrapper:``,handle:``,resizing:``},this.initialWidth=0,this.initialHeight=0,this.aspectRatio=1,this.isResizing=!1,this.activeHandle=null,this.startX=0,this.startY=0,this.startWidth=0,this.startHeight=0,this.isShiftKeyPressed=!1,this.lastEditableState=void 0,this.handleMap=new Map,this.handleEditorUpdate=()=>{let e=this.editor.isEditable;e!==this.lastEditableState&&(this.lastEditableState=e,e?e&&this.handleMap.size===0&&this.attachHandles():this.removeHandles())},this.handleMouseMove=e=>{if(!this.isResizing||!this.activeHandle)return;let t=e.clientX-this.startX,n=e.clientY-this.startY;this.handleResize(t,n)},this.handleTouchMove=e=>{if(!this.isResizing||!this.activeHandle)return;let t=e.touches[0];if(!t)return;let n=t.clientX-this.startX,r=t.clientY-this.startY;this.handleResize(n,r)},this.handleMouseUp=()=>{if(!this.isResizing)return;let e=this.element.offsetWidth,t=this.element.offsetHeight;this.onCommit(e,t),this.isResizing=!1,this.activeHandle=null,this.container.dataset.resizeState=`false`,this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener(`mousemove`,this.handleMouseMove),document.removeEventListener(`mouseup`,this.handleMouseUp),document.removeEventListener(`keydown`,this.handleKeyDown),document.removeEventListener(`keyup`,this.handleKeyUp)},this.handleKeyDown=e=>{e.key===`Shift`&&(this.isShiftKeyPressed=!0)},this.handleKeyUp=e=>{e.key===`Shift`&&(this.isShiftKeyPressed=!1)},this.node=e.node,this.editor=e.editor,this.element=e.element,this.element.draggable=!1,this.contentElement=e.contentElement,this.getPos=e.getPos,this.onResize=e.onResize,this.onCommit=e.onCommit,this.onUpdate=e.onUpdate,e.options?.min&&(this.minSize={...this.minSize,...e.options.min}),e.options?.max&&(this.maxSize=e.options.max),e!=null&&(t=e.options)!=null&&t.directions&&(this.directions=e.options.directions),e.options?.preserveAspectRatio&&(this.preserveAspectRatio=e.options.preserveAspectRatio),e.options?.className&&(this.classNames={container:e.options.className.container||``,wrapper:e.options.className.wrapper||``,handle:e.options.className.handle||``,resizing:e.options.className.resizing||``}),e.options?.createCustomHandle&&(this.createCustomHandle=e.options.createCustomHandle),this.wrapper=this.createWrapper(),this.container=this.createContainer(),this.applyInitialSize(),this.attachHandles(),this.editor.on(`update`,this.handleEditorUpdate)}get dom(){return this.container}get contentDOM(){return this.contentElement??null}update(e,t,n){return e.type===this.node.type&&(this.node=e,!this.onUpdate||this.onUpdate(e,t,n))}destroy(){this.isResizing&&(this.container.dataset.resizeState=`false`,this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener(`mousemove`,this.handleMouseMove),document.removeEventListener(`mouseup`,this.handleMouseUp),document.removeEventListener(`keydown`,this.handleKeyDown),document.removeEventListener(`keyup`,this.handleKeyUp),this.isResizing=!1,this.activeHandle=null),this.editor.off(`update`,this.handleEditorUpdate),this.container.remove()}createContainer(){let e=document.createElement(`div`);return e.dataset.resizeContainer=``,e.dataset.node=this.node.type.name,e.style.display=this.node.type.isInline?`inline-flex`:`flex`,this.classNames.container&&(e.className=this.classNames.container),e.appendChild(this.wrapper),e}createWrapper(){let e=document.createElement(`div`);return e.style.position=`relative`,e.style.display=`block`,e.dataset.resizeWrapper=``,this.classNames.wrapper&&(e.className=this.classNames.wrapper),e.appendChild(this.element),e}createHandle(e){let t=document.createElement(`div`);return t.dataset.resizeHandle=e,t.style.position=`absolute`,this.classNames.handle&&(t.className=this.classNames.handle),t}positionHandle(e,t){let n=t.includes(`top`),r=t.includes(`bottom`),i=t.includes(`left`),a=t.includes(`right`);n&&(e.style.top=`0`),r&&(e.style.bottom=`0`),i&&(e.style.left=`0`),a&&(e.style.right=`0`),(t===`top`||t===`bottom`)&&(e.style.left=`0`,e.style.right=`0`),(t===`left`||t===`right`)&&(e.style.top=`0`,e.style.bottom=`0`)}attachHandles(){this.directions.forEach(e=>{let t;t=this.createCustomHandle?this.createCustomHandle(e):this.createHandle(e),t instanceof HTMLElement||(console.warn(`[ResizableNodeView] createCustomHandle("${e}") did not return an HTMLElement. Falling back to default handle.`),t=this.createHandle(e)),this.createCustomHandle||this.positionHandle(t,e),t.addEventListener(`mousedown`,t=>this.handleResizeStart(t,e)),t.addEventListener(`touchstart`,t=>this.handleResizeStart(t,e)),this.handleMap.set(e,t),this.wrapper.appendChild(t)})}removeHandles(){this.handleMap.forEach(e=>e.remove()),this.handleMap.clear()}applyInitialSize(){let e=this.node.attrs.width,t=this.node.attrs.height;e?(this.element.style.width=`${e}px`,this.initialWidth=e):this.initialWidth=this.element.offsetWidth,t?(this.element.style.height=`${t}px`,this.initialHeight=t):this.initialHeight=this.element.offsetHeight,this.initialWidth>0&&this.initialHeight>0&&(this.aspectRatio=this.initialWidth/this.initialHeight)}handleResizeStart(e,t){e.preventDefault(),e.stopPropagation(),this.isResizing=!0,this.activeHandle=t,cm(e)?(this.startX=e.touches[0].clientX,this.startY=e.touches[0].clientY):(this.startX=e.clientX,this.startY=e.clientY),this.startWidth=this.element.offsetWidth,this.startHeight=this.element.offsetHeight,this.startWidth>0&&this.startHeight>0&&(this.aspectRatio=this.startWidth/this.startHeight),this.getPos(),this.container.dataset.resizeState=`true`,this.classNames.resizing&&this.container.classList.add(this.classNames.resizing),document.addEventListener(`mousemove`,this.handleMouseMove),document.addEventListener(`touchmove`,this.handleTouchMove),document.addEventListener(`mouseup`,this.handleMouseUp),document.addEventListener(`keydown`,this.handleKeyDown),document.addEventListener(`keyup`,this.handleKeyUp)}handleResize(e,t){if(!this.activeHandle)return;let n=this.preserveAspectRatio||this.isShiftKeyPressed,{width:r,height:i}=this.calculateNewDimensions(this.activeHandle,e,t),a=this.applyConstraints(r,i,n);this.element.style.width=`${a.width}px`,this.element.style.height=`${a.height}px`,this.onResize&&this.onResize(a.width,a.height)}calculateNewDimensions(e,t,n){let r=this.startWidth,i=this.startHeight,a=e.includes(`right`),o=e.includes(`left`),s=e.includes(`bottom`),c=e.includes(`top`);return a?r=this.startWidth+t:o&&(r=this.startWidth-t),s?i=this.startHeight+n:c&&(i=this.startHeight-n),(e===`right`||e===`left`)&&(r=this.startWidth+(a?t:-t)),(e===`top`||e===`bottom`)&&(i=this.startHeight+(s?n:-n)),this.preserveAspectRatio||this.isShiftKeyPressed?this.applyAspectRatio(r,i,e):{width:r,height:i}}applyConstraints(e,t,n){if(!n){let n=Math.max(this.minSize.width,e),r=Math.max(this.minSize.height,t);return this.maxSize?.width&&(n=Math.min(this.maxSize.width,n)),this.maxSize?.height&&(r=Math.min(this.maxSize.height,r)),{width:n,height:r}}let r=e,i=t;return rthis.maxSize.width&&(r=this.maxSize.width,i=r/this.aspectRatio),this.maxSize?.height&&i>this.maxSize.height&&(i=this.maxSize.height,r=i*this.aspectRatio),{width:r,height:i}}applyAspectRatio(e,t,n){return n===`left`||n===`right`?{width:e,height:e/this.aspectRatio}:n===`top`||n===`bottom`?{width:t*this.aspectRatio,height:t}:{width:e,height:e/this.aspectRatio}}},um=class e extends Mp{constructor(...e){super(...e),this.type=`node`}static create(t={}){let n=typeof t==`function`?t():t;return new e(n)}configure(e){return super.configure(e)}extend(e){let t=typeof e==`function`?e():e;return super.extend(t)}};function dm(e){return new Pp({find:e.find,handler:({state:t,range:n,match:r,pasteEvent:i})=>{let a=G(e.getAttributes,void 0,r,i);if(a===!1||a===null)return null;let{tr:o}=t,s=r[r.length-1],c=r[0],l=n.to;if(s){let i=c.search(/\S/),u=n.from+c.indexOf(s),d=u+s.length;if(Id(n.from,n.to,t.doc).filter(t=>t.mark.type.excluded.find(n=>n===e.type&&n!==t.mark.type)).filter(e=>e.to>u).length)return null;dn.from&&o.delete(n.from+i,u),l=n.from+i+s.length,o.addMark(n.from+i,l,e.type.create(a||{})),r.index!==void 0&&r.input!==void 0&&r.index+r[0].length>=r.input.length||o.removeStoredMark(e.type)}}})}function fm(e){return d((t,n)=>({get(){return t(),e},set(t){e=t,requestAnimationFrame(()=>{requestAnimationFrame(()=>{n()})})}}))}var pm=class extends rm{constructor(e={}){return super(e),this.contentComponent=null,this.appContext=null,this.reactiveState=fm(this.view.state),this.reactiveExtensionStorage=fm(this.extensionStorage),this.on(`beforeTransaction`,({nextState:e})=>{this.reactiveState.value=e,this.reactiveExtensionStorage.value=this.extensionStorage}),u(this)}get state(){var e;return(e=this.reactiveState)==null||e.value,super.state}get storage(){return this.reactiveExtensionStorage?this.reactiveExtensionStorage.value:super.storage}registerPlugin(e,t){let n=super.registerPlugin(e,t);return this.reactiveState&&(this.reactiveState.value=n),n}unregisterPlugin(e){let t=super.unregisterPlugin(e);return this.reactiveState&&t&&(this.reactiveState.value=t),t}},mm=i({name:`EditorContent`,props:{editor:{default:null,type:Object}},setup(e){let t=C(),n=m();return b(()=>{let r=e.editor;r&&r.options.element&&t.value&&f(()=>{if(!t.value||!r.view.dom?.parentNode)return;let e=g(t.value);t.value.append(...r.view.dom.parentNode.childNodes),r.view.updateRoot(),r.contentComponent=n.ctx._,n&&(r.appContext={...n.appContext,provides:n.provides}),r.setOptions({element:e}),r.createNodeViews()})}),p(()=>{let t=e.editor;t&&(t.contentComponent=null,t.appContext=null)}),{rootEl:t}},render(){return oe(`div`,{ref:e=>{this.rootEl=e}})}});i({name:`NodeViewContent`,props:{as:{type:String,default:`div`}},inject:{nodeViewContentRef:{default:void 0}},mounted(){let e=this.nodeViewContentRef;e&&this.$el&&e(this.$el)},beforeUnmount(){let e=this.nodeViewContentRef;e&&e(null)},render(){return oe(this.as,{style:{whiteSpace:`pre-wrap`},"data-node-view-content":``})}}),i({name:`NodeViewWrapper`,props:{as:{type:String,default:`div`}},inject:[`onDragStart`,`decorationClasses`],render(){var e;return oe(this.as,{class:this.decorationClasses,style:{whiteSpace:`normal`},"data-node-view-wrapper":``,onDragstart:this.onDragStart},(e=this.$slots).default?.call(e))}});var hm=(e={})=>{let t=w();return h(()=>{t.value=new pm(e)}),p(()=>{var e;(e=t.value)==null||e.destroy()}),t};i({name:`MarkViewContent`,props:{as:{type:String,default:`span`}},render(){return oe(this.as,{style:{whiteSpace:`inherit`},"data-mark-view-content":``})}});function gm(e={}){return new B({view(t){return new _m(t,e)}})}var _m=class{constructor(e,t){this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.lastDragEvent=null,this.width=t.width??1,this.color=t.color===!1?void 0:t.color||`black`,this.class=t.class,this.handlers=[`dragover`,`dragend`,`drop`,`dragleave`].map(t=>{let n=e=>{this[t](e)};return e.dom.addEventListener(t,n),{name:t,handler:n}})}destroy(){this.setCursor(null),this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){if(this.cursorPos!=null&&t.doc!=e.state.doc){if(this.lastDragEvent){let e=this.computeTarget(this.lastDragEvent);e==this.cursorPos?this.updateOverlay():this.setCursor(e)}else this.updateOverlay()}}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),t=!e.parent.inlineContent,n,r=this.editorView.dom,i=r.getBoundingClientRect(),a=i.width/r.offsetWidth,o=i.height/r.offsetHeight;if(t){let t=e.nodeBefore,r=e.nodeAfter;if(t||r){let e=this.editorView.nodeDOM(this.cursorPos-(t?t.nodeSize:0));if(e){let i=e.getBoundingClientRect(),a=t?i.bottom:i.top;t&&r&&(a=(a+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let s=this.width/2*o;n={left:i.left,right:i.right,top:a-s,bottom:a+s}}}}if(!n){let e=this.editorView.coordsAtPos(this.cursorPos),t=this.width/2*a;n={left:e.left-t,right:e.left+t,top:e.top,bottom:e.bottom}}let s=this.editorView.dom.offsetParent;this.element||(this.element=s.appendChild(document.createElement(`div`)),this.class&&(this.element.className=this.class),this.element.style.cssText=`position: absolute; z-index: 50; pointer-events: none;`,this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle(`prosemirror-dropcursor-block`,t),this.element.classList.toggle(`prosemirror-dropcursor-inline`,!t);let c,l;if(!s||s==document.body&&getComputedStyle(s).position==`static`)c=-pageXOffset,l=-pageYOffset;else{let e=s.getBoundingClientRect(),t=e.width/s.offsetWidth,n=e.height/s.offsetHeight;c=e.left-s.scrollLeft*t,l=e.top-s.scrollTop*n}this.element.style.left=(n.left-c)/a+`px`,this.element.style.top=(n.top-l)/o+`px`,this.element.style.width=(n.right-n.left)/a+`px`,this.element.style.height=(n.bottom-n.top)/o+`px`}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}computeTarget(e){let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),n=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),r=n&&n.type.spec.disableDropCursor,i=typeof r==`function`?r(this.editorView,t,e):r;if(!t||i)return null;let a=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let e=zn(this.editorView.state.doc,a,this.editorView.dragging.slice);e!=null&&(a=e)}return a}dragover(e){if(!this.editorView.editable)return;this.lastDragEvent=e;let t=this.computeTarget(e);t!=null&&(this.setCursor(t),this.scheduleRemoval(5e3))}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}},vm=class e extends L{constructor(e){super(e,e)}map(t,n){let r=t.resolve(n.map(this.head));return e.valid(r)?new e(r):L.near(r)}content(){return I.empty}eq(t){return t instanceof e&&t.head==this.head}toJSON(){return{type:`gapcursor`,pos:this.head}}static fromJSON(t,n){if(typeof n.pos!=`number`)throw RangeError(`Invalid input for GapCursor.fromJSON`);return new e(t.resolve(n.pos))}getBookmark(){return new ym(this.anchor)}static valid(e){let t=e.parent;if(t.inlineContent||!xm(e)||!Sm(e))return!1;let n=t.type.spec.allowGapCursor;if(n!=null)return n;let r=t.contentMatchAt(e.index()).defaultType;return r&&r.isTextblock}static findGapCursorFrom(t,n,r=!1){search:for(;;){if(!r&&e.valid(t))return t;let i=t.pos,a=null;for(let r=t.depth;;r--){let o=t.node(r);if(n>0?t.indexAfter(r)0){a=o.child(n>0?t.indexAfter(r):t.index(r)-1);break}if(r==0)return null;i+=n;let s=t.doc.resolve(i);if(e.valid(s))return s}for(;;){let o=n>0?a.firstChild:a.lastChild;if(!o){if(a.isAtom&&!a.isText&&!z.isSelectable(a)){t=t.doc.resolve(i+a.nodeSize*n),r=!1;continue search}break}a=o,i+=n;let s=t.doc.resolve(i);if(e.valid(s))return s}return null}}};vm.prototype.visible=!1,vm.findFrom=vm.findGapCursorFrom,L.jsonID(`gapcursor`,vm);var ym=class e{constructor(e){this.pos=e}map(t){return new e(t.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return vm.valid(t)?new vm(t):L.near(t)}};function bm(e){return e.isAtom||e.spec.isolating||e.spec.createGapCursor}function xm(e){for(let t=e.depth;t>=0;t--){let n=e.index(t),r=e.node(t);if(n==0){if(r.type.spec.isolating)return!0}else for(let e=r.child(n-1);;e=e.lastChild){if(e.childCount==0&&!e.inlineContent||bm(e.type))return!0;if(e.inlineContent)return!1}}return!0}function Sm(e){for(let t=e.depth;t>=0;t--){let n=e.indexAfter(t),r=e.node(t);if(n==r.childCount){if(r.type.spec.isolating)return!0}else for(let e=r.child(n);;e=e.firstChild){if(e.childCount==0&&!e.inlineContent||bm(e.type))return!0;if(e.inlineContent)return!1}}return!0}function Cm(){return new B({props:{decorations:Om,createSelectionBetween(e,t,n){return t.pos==n.pos&&vm.valid(n)?new vm(n):null},handleClick:Em,handleKeyDown:wm,handleDOMEvents:{beforeinput:Dm}}})}var wm=ol({ArrowLeft:Tm(`horiz`,-1),ArrowRight:Tm(`horiz`,1),ArrowUp:Tm(`vert`,-1),ArrowDown:Tm(`vert`,1)});function Tm(e,t){let n=e==`vert`?t>0?`down`:`up`:t>0?`right`:`left`;return function(e,r,i){let a=e.selection,o=t>0?a.$to:a.$from,s=a.empty;if(a instanceof R){if(!i.endOfTextblock(n)||o.depth==0)return!1;s=!1,o=e.doc.resolve(t>0?o.after():o.before())}let c=vm.findGapCursorFrom(o,t,s);return c?(r&&r(e.tr.setSelection(new vm(c))),!0):!1}}function Em(e,t,n){if(!e||!e.editable)return!1;let r=e.state.doc.resolve(t);if(!vm.valid(r))return!1;let i=e.posAtCoords({left:n.clientX,top:n.clientY});return i&&i.inside>-1&&z.isSelectable(e.state.doc.nodeAt(i.inside))?!1:(e.dispatch(e.state.tr.setSelection(new vm(r))),!0)}function Dm(e,t){if(t.inputType!=`insertCompositionText`||!(e.state.selection instanceof vm))return!1;let{$from:n}=e.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(e.state.schema.nodes.text);if(!r)return!1;let i=P.empty;for(let e=r.length-1;e>=0;e--)i=P.from(r[e].createAndFill(null,i));let a=e.state.tr.replace(n.pos,n.pos,new I(i,0,0));return a.setSelection(R.near(a.doc.resolve(n.pos+1))),e.dispatch(a),!1}function Om(e){if(!(e.selection instanceof vm))return null;let t=document.createElement(`div`);return t.className=`ProseMirror-gapcursor`,U.create(e.doc,[rc.widget(e.selection.head,t,{key:`gapcursor`})])}var km=q.create({name:`characterCount`,addOptions(){return{limit:null,autoTrim:!0,mode:`textSize`,textCounter:e=>e.length,wordCounter:e=>e.split(` `).filter(e=>e!==``).length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=e=>{let t=e?.node||this.editor.state.doc;if((e?.mode||this.options.mode)===`textSize`){let e=t.textBetween(0,t.content.size,void 0,` `);return this.options.textCounter(e)}return t.nodeSize},this.storage.words=e=>{let t=e?.node||this.editor.state.doc,n=t.textBetween(0,t.content.size,` `,` `);return this.options.wordCounter(n)}},addProseMirrorPlugins(){let e=!1;return[new B({key:new V(`characterCount`),appendTransaction:(t,n,r)=>{if(e)return;let i=this.options.limit,a=this.options.autoTrim;if(i==null||i===0||a===!1){e=!0;return}let o=this.storage.characters({node:r.doc});if(o>i){let t=o-i;console.warn(`[CharacterCount] Initial content exceeded limit of ${i} characters. Content was automatically trimmed.`);let n=r.tr.deleteRange(0,t);return e=!0,n}e=!0},filterTransaction:(e,t)=>{let n=this.options.limit;if(!e.docChanged||n===0||n==null)return!0;let r=this.storage.characters({node:t.doc}),i=this.storage.characters({node:e.doc});if(i<=n||r>n&&i>n&&i<=r)return!0;if(r>n&&i>n&&i>r||!e.getMeta(`paste`))return!1;let a=e.selection.$head.pos,o=a-(i-n),s=a;return e.deleteRange(o,s),!(this.storage.characters({node:e.doc})>n)}})]}}),Am=q.create({name:`dropCursor`,addOptions(){return{color:`currentColor`,width:1,class:void 0}},addProseMirrorPlugins(){return[gm(this.options)]}});q.create({name:`focus`,addOptions(){return{className:`has-focus`,mode:`all`}},addProseMirrorPlugins(){return[new B({key:new V(`focus`),props:{decorations:({doc:e,selection:t})=>{let{isEditable:n,isFocused:r}=this.editor,{anchor:i}=t,a=[];if(!n||!r)return U.create(e,[]);let o=0;this.options.mode===`deepest`&&e.descendants((e,t)=>{if(!e.isText){if(!(i>=t&&i<=t+e.nodeSize-1))return!1;o+=1}});let s=0;return e.descendants((e,t)=>{if(e.isText||!(i>=t&&i<=t+e.nodeSize-1))return!1;if(s+=1,this.options.mode===`deepest`&&o-s>0||this.options.mode===`shallowest`&&s>1)return this.options.mode===`deepest`;a.push(rc.node(t,t+e.nodeSize,{class:this.options.className}))}),U.create(e,a)}}})]}});var jm=q.create({name:`gapCursor`,addProseMirrorPlugins(){return[Cm()]},extendNodeSchema(e){return{allowGapCursor:G(W(e,`allowGapCursor`,{name:e.name,options:e.options,storage:e.storage}))??null}}}),Mm=`placeholder`,Nm=new V(`tiptap__placeholder`);function Pm(e){let{editor:t,placeholder:n,dataAttribute:r,pos:i,node:a,isEmptyDoc:o,hasAnchor:s,classes:{emptyNode:c,emptyEditor:l}}=e,u=[c];return o&&u.push(l),rc.node(i,i+a.nodeSize,{class:u.join(` `),[r]:typeof n==`function`?n({editor:t,node:a,pos:i,hasAnchor:s}):n})}function Fm(e,t){return typeof e==`function`?e(t):e}function Im({editor:e,options:t,dataAttribute:n,doc:r,selection:i,from:a,to:o}){let{anchor:s}=i,c=[],l=e.isEmpty;return r.nodesBetween(a,o,(r,i)=>{let a=s>=i&&s<=i+r.nodeSize,o=!r.isLeaf&&Jd(r);return r.type.isTextblock&&(a||!t.showOnlyCurrent)&&o&&c.push(Pm({editor:e,isEmptyDoc:l,dataAttribute:n,hasAnchor:a,placeholder:t.placeholder,classes:{emptyEditor:t.emptyEditorClass,emptyNode:Fm(t.emptyNodeClass,{editor:e,node:r,pos:i,hasAnchor:a})},node:r,pos:i})),t.includeChildren}),c}function Lm({editor:e,options:t,dataAttribute:n,doc:r,selection:i}){if(!e.isEditable&&t.showOnlyWhenEditable)return null;let{anchor:a}=i,o=[],s=e.isEmpty;if(t.showOnlyCurrent&&!t.includeChildren){let i=r.resolve(a),c=i.depth>0?i.node(1):i.nodeAfter,l=i.depth>0?i.before(1):a;if(c&&c.type.isTextblock&&Jd(c)){let r=a>=l&&a<=l+c.nodeSize;o.push(Pm({editor:e,isEmptyDoc:s,dataAttribute:n,hasAnchor:r,placeholder:t.placeholder,classes:{emptyEditor:t.emptyEditorClass,emptyNode:Fm(t.emptyNodeClass,{editor:e,node:c,pos:l,hasAnchor:r})},node:c,pos:l}))}}else o.push(...Im({editor:e,options:t,dataAttribute:n,doc:r,selection:i,from:0,to:r.content.size}));return U.create(r,o)}function Rm(e,t){let n=e.resolve(t);if(n.depth===0){let e=n.nodeAfter??n.nodeBefore;if(!e)return{from:t,to:t};let r=n.nodeAfter?t:t-e.nodeSize;return{from:r,to:r+e.nodeSize}}let r=n.before(1);return{from:r,to:r+n.node(1).nodeSize}}function zm(e,t){return{from:Math.max(0,t.from),to:Math.min(e.content.size,t.to)}}function Bm(e,t,n){let r=[];return e.forEach((e,i)=>{let a=i,o=a+e.nodeSize,s=a+1,c=o+1;st&&r.push({from:a,to:o})}),r}function Vm(e){if(e.length===0)return[];let t=[...e].sort((e,t)=>e.from-t.from),n=[{...t[0]}];for(let e=1;et.from?n.push(zm(e,Rm(e,Math.min(t.to,e.content.size+1)-1))):t.frome.from>=t&&e.to<=c);l.length&&(s=s.remove(l));let u=Im({editor:n,options:r,dataAttribute:i,doc:a,selection:o,from:t,to:c});u.length&&(s=s.add(a,u))}return s}function Km({editor:e,options:t,dataAttribute:n}){return{init(r,i){return Lm({editor:e,options:t,dataAttribute:n,doc:i.doc,selection:i.selection})??U.empty},apply(r,i,a,o){return!r.docChanged&&!r.selectionSet?i:Gm({decorations:i.map(r.mapping,r.doc),ranges:Um(r,a,o),editor:e,options:t,dataAttribute:n,doc:o.doc,selection:o.selection})}}}function qm(e){return e.replace(/\s+/g,`-`).replace(/[^a-zA-Z0-9-]/g,``).replace(/^[0-9-]+/,``).replace(/^-+/,``).toLowerCase()}function Jm({editor:e,options:t}){let n=t.dataAttribute?`data-${qm(t.dataAttribute)}`:`data-${Mm}`,r=t.showOnlyCurrent&&!t.includeChildren;return new B({key:Nm,...r?{}:{state:Km({editor:e,options:t,dataAttribute:n})},props:{decorations:r?({doc:r,selection:i})=>Lm({editor:e,options:t,dataAttribute:n,doc:r,selection:i}):n=>t.showOnlyWhenEditable&&!e.isEditable?U.empty:Nm.getState(n)??U.empty}})}var Ym=q.create({name:`placeholder`,addOptions(){return{emptyEditorClass:`is-editor-empty`,emptyNodeClass:`is-empty`,dataAttribute:Mm,placeholder:`Write something …`,showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[Jm({editor:this.editor,options:this.options})]}});function Xm(e,t){return!e.selection.empty&&!Yd(e.selection)&&t.isEditable}function Zm(e,t){return Xm(e,t)&&!t.isFocused&&!t.view.dragging}function Qm(){var e;(e=window.getSelection())==null||e.removeAllRanges()}function $m(e){e.focus()}q.create({name:`selection`,addOptions(){return{className:`selection`}},addProseMirrorPlugins(){let{editor:e,options:t}=this;return[new B({key:new V(`selection`),props:{decorations(n){return Zm(n,e)?U.create(n.doc,[rc.inline(n.selection.from,n.selection.to,{class:t.className})]):null},handleDOMEvents:{blur(t){return Xm(t.state,e)&&Qm(),!1},focus(t){return Xm(t.state,e)&&requestAnimationFrame(()=>{!e.isDestroyed&&t.hasFocus()&&$m(t)}),!1}}}})]}});function eh({types:e,node:t}){return t&&Array.isArray(e)&&e.includes(t.type)||t?.type===e}var th=q.create({name:`trailingNode`,addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){let e=new V(this.name),t=this.options.node||this.editor.schema.topNodeType.contentMatch.defaultType?.name||`paragraph`,n=Object.entries(this.editor.schema.nodes).map(([,e])=>e).filter(e=>(this.options.notAfter||[]).concat(t).includes(e.name));return[new B({key:e,appendTransaction:(n,r,i)=>{let{doc:a,tr:o,schema:s}=i,c=e.getState(i),l=a.content.size,u=s.nodes[t];if(!n.some(e=>e.getMeta(`skipTrailingNode`))&&c)return o.insert(l,u.create())},state:{init:(e,t)=>{let r=t.tr.doc.lastChild;return!eh({node:r,types:n})},apply:(e,t)=>{if(!e.docChanged||e.getMeta(`__uniqueIDTransaction`))return t;let r=e.doc.lastChild;return!eh({node:r,types:n})}}})]}}),nh=q.create({name:`undoRedo`,addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:e,dispatch:t})=>Al(e,t),redo:()=>({state:e,dispatch:t})=>jl(e,t)}},addProseMirrorPlugins(){return[Ol(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}),rh=km,ih=new WeakSet,ah=new WeakSet;function oh(e){let t=e;return ih.add(t),t}function sh(e){return Array.isArray(e)&&ih.has(e)}function ch(e){return e.flatMap(e=>e==null?[]:Array.isArray(e)&&ah.has(e)&&!sh(e)?ch(e):[e])}function lh(e,t){if(e===`slot`)return 0;if(e instanceof Function){let n=e(t);return Array.isArray(n)&&!sh(n)&&!ah.has(n)?oh(n):n}let{children:n,...r}=t??{};if(e===`svg`)throw Error(`SVG elements are not supported in the JSX syntax, use the array syntax instead`);if(Array.isArray(n)){if(sh(n))return oh([e,r,n]);if(n.length===0)return oh([e,r]);let t=ch(n);return t.length===0?oh([e,r]):oh([e,r,...t])}return oh(n==null?[e,r]:[e,r,n])}var uh=(e,t)=>lh(e,t),dh=(e,t)=>{let{state:n}=e,{selection:r}=n;if(!r.empty)return!1;let{$from:i}=r;if(i.parentOffset!==0)return!1;let a=i.depth-1;if(a<0)return!1;let o=i.node(a),s=i.index(a);if(s===0)return!1;if(o.type===t)return e.commands.lift(t.name);let c=o.child(s-1);if(c.type!==t||!c.lastChild?.isTextblock)return!1;let l=i.before()-1-1;return e.commands.command(({tr:e,dispatch:t})=>{if(!t)return!0;let n=i.parent.content,r=new I(n,0,0);return e.replace(l,i.after(),r),e.setSelection(R.create(e.doc,l)),e.scrollIntoView(),t(e),!0})},fh=/^\s*>\s$/,ph=um.create({name:`blockquote`,addOptions(){return{HTMLAttributes:{}}},content:`block+`,group:`block`,defining:!0,parseHTML(){return[{tag:`blockquote`}]},renderHTML({HTMLAttributes:e}){return uh(`blockquote`,{...K(this.options.HTMLAttributes,e),children:uh(`slot`,{})})},parseMarkdown:(e,t)=>{let n=t.parseBlockChildren??t.parseChildren;return t.createNode(`blockquote`,void 0,n(e.tokens||[]))},renderMarkdown:(e,t)=>{if(!e.content)return``;let n=[];return e.content.forEach((e,r)=>{let i=(t.renderChild?.call(t,e,r)??t.renderChildren([e])).split(` `).map(e=>e.trim()===``?`>`:`> ${e}`);n.push(i.join(` `))}),n.join(` > -`)},addCommands(){return{setBlockquote:()=>({commands:e})=>e.wrapIn(this.name),toggleBlockquote:()=>({commands:e})=>e.toggleWrap(this.name),unsetBlockquote:()=>({commands:e})=>e.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote(),Backspace:()=>uh(this.editor,this.type)}},addInputRules(){return[om({find:dh,type:this.type})]}}),ph=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,mh=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,hh=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,gh=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,_h=Mp.create({name:`bold`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`strong`},{tag:`b`,getAttrs:e=>e.style.fontWeight!==`normal`&&null},{style:`font-weight=400`,clearMark:e=>e.type.name===this.name},{style:`font-weight`,getAttrs:e=>/^(bold(er)?|[5-9]\d{2,})$/.test(e)&&null}]},renderHTML({HTMLAttributes:e}){return lh(`strong`,{...q(this.options.HTMLAttributes,e),children:lh(`slot`,{})})},markdownTokenName:`strong`,parseMarkdown:(e,t)=>t.applyMark(`bold`,t.parseInline(e.tokens||[])),markdownOptions:{htmlReopen:{open:``,close:``}},renderMarkdown:(e,t)=>`**${t.renderChildren(e)}**`,addCommands(){return{setBold:()=>({commands:e})=>e.setMark(this.name),toggleBold:()=>({commands:e})=>e.toggleMark(this.name),unsetBold:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[rm({find:ph,type:this.type}),rm({find:hh,type:this.type})]},addPasteRules(){return[um({find:mh,type:this.type}),um({find:gh,type:this.type})]}}),vh=e=>{let t=/`([^`]+)`(?!`)$/.exec(e);return!t||t.index>0&&e[t.index-1]==="`"?null:{index:t.index,text:t[0],replaceWith:t[1]}},yh=e=>{let t=/`([^`]+)`(?!`)/g,n=[],r;for(;(r=t.exec(e))!==null;)r.index>0&&e[r.index-1]==="`"||n.push({index:r.index,text:r[0],replaceWith:r[1]});return n};function bh(e){let t=new Set((e.match(/`+/g)||[]).map(e=>e.length)),n=1;for(;t.has(n);)n+=1;return n}var xh=Mp.create({name:`code`,addOptions(){return{HTMLAttributes:{}}},excludes:`_`,code:!0,exitable:!0,parseHTML(){return[{tag:`code`}]},renderHTML({HTMLAttributes:e}){return[`code`,q(this.options.HTMLAttributes,e),0]},markdownTokenName:`codespan`,parseMarkdown:(e,t)=>t.applyMark(`code`,[{type:`text`,text:e.text||``}]),renderMarkdown:(e,t,n)=>{var r;if(!e.content)return``;let i=typeof(n==null||(r=n.meta)==null?void 0:r.markText)==`string`?n.meta.markText:``,a="`".repeat(bh(i)),o=i.startsWith("`")||i.endsWith("`")?` `:``;return`${a}${o}${t.renderChildren(e.content)}${o}${a}`},addCommands(){return{setCode:()=>({commands:e})=>e.setMark(this.name),toggleCode:()=>({commands:e})=>e.toggleMark(this.name),unsetCode:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[rm({find:vh,type:this.type})]},addPasteRules(){return[um({find:yh,type:this.type})]}}),Sh=4,Ch=/^```([a-z]+)?[\s\n]$/,wh=/^~~~([a-z]+)?[\s\n]$/,Th=lm.create({name:`codeBlock`,addOptions(){return{languageClassPrefix:`language-`,exitOnTripleEnter:!0,exitOnArrowDown:!0,exitOnArrowUp:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:Sh,HTMLAttributes:{}}},content:`text*`,marks:``,group:`block`,code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:e=>{let{languageClassPrefix:t}=this.options;return t&&[...e.firstElementChild?.classList||[]].filter(e=>e.startsWith(t)).map(e=>e.replace(t,``))[0]||null},rendered:!1}}},parseHTML(){return[{tag:`pre`,preserveWhitespace:`full`}]},renderHTML({node:e,HTMLAttributes:t}){return[`pre`,q(this.options.HTMLAttributes,t),[`code`,{class:e.attrs.language?this.options.languageClassPrefix+e.attrs.language:null},0]]},markdownTokenName:`code`,parseMarkdown:(e,t)=>e.raw?.startsWith("```")===!1&&e.raw?.startsWith(`~~~`)===!1&&e.codeBlockStyle!==`indented`?[]:t.createNode(`codeBlock`,{language:e.lang||null},e.text?[t.createTextNode(e.text)]:[]),renderMarkdown:(e,t)=>{let n=``,r=e.attrs?.language||``;return n=e.content?[`\`\`\`${r}`,t.renderChildren(e.content),"```"].join(` -`):`\`\`\`${r}\n\n\`\`\``,n},addCommands(){return{setCodeBlock:e=>({commands:t})=>t.setNode(this.name,e),toggleCodeBlock:e=>({commands:t})=>t.toggleNode(this.name,`paragraph`,e)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{let{empty:e,$anchor:t}=this.editor.state.selection,n=t.pos===1;return!e||t.parent.type.name!==this.name?!1:n||!t.parent.textContent.length?this.editor.commands.clearNodes():!1},Tab:({editor:e})=>{if(!this.options.enableTabIndentation)return!1;let t=this.options.tabSize??Sh,{state:n}=e,{selection:r}=n,{$from:i,empty:a}=r;if(i.parent.type!==this.type)return!1;let o=` `.repeat(t);return a?e.commands.insertContent(o):e.commands.command(({tr:e})=>{let{from:t,to:i}=r,a=n.doc.textBetween(t,i,` +`)},addCommands(){return{setBlockquote:()=>({commands:e})=>e.wrapIn(this.name),toggleBlockquote:()=>({commands:e})=>e.toggleWrap(this.name),unsetBlockquote:()=>({commands:e})=>e.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote(),Backspace:()=>dh(this.editor,this.type)}},addInputRules(){return[sm({find:fh,type:this.type})]}}),mh=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,hh=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,gh=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,_h=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,vh=Np.create({name:`bold`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`strong`},{tag:`b`,getAttrs:e=>e.style.fontWeight!==`normal`&&null},{style:`font-weight=400`,clearMark:e=>e.type.name===this.name},{style:`font-weight`,getAttrs:e=>/^(bold(er)?|[5-9]\d{2,})$/.test(e)&&null}]},renderHTML({HTMLAttributes:e}){return uh(`strong`,{...K(this.options.HTMLAttributes,e),children:uh(`slot`,{})})},markdownTokenName:`strong`,parseMarkdown:(e,t)=>t.applyMark(`bold`,t.parseInline(e.tokens||[])),markdownOptions:{htmlReopen:{open:``,close:``}},renderMarkdown:(e,t)=>`**${t.renderChildren(e)}**`,addCommands(){return{setBold:()=>({commands:e})=>e.setMark(this.name),toggleBold:()=>({commands:e})=>e.toggleMark(this.name),unsetBold:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[im({find:mh,type:this.type}),im({find:gh,type:this.type})]},addPasteRules(){return[dm({find:hh,type:this.type}),dm({find:_h,type:this.type})]}}),yh=e=>{let t=/`([^`]+)`(?!`)$/.exec(e);return!t||t.index>0&&e[t.index-1]==="`"?null:{index:t.index,text:t[0],replaceWith:t[1]}},bh=e=>{let t=/`([^`]+)`(?!`)/g,n=[],r;for(;(r=t.exec(e))!==null;)r.index>0&&e[r.index-1]==="`"||n.push({index:r.index,text:r[0],replaceWith:r[1]});return n};function xh(e){let t=new Set((e.match(/`+/g)||[]).map(e=>e.length)),n=1;for(;t.has(n);)n+=1;return n}var Sh=Np.create({name:`code`,addOptions(){return{HTMLAttributes:{}}},excludes:`_`,code:!0,exitable:!0,parseHTML(){return[{tag:`code`}]},renderHTML({HTMLAttributes:e}){return[`code`,K(this.options.HTMLAttributes,e),0]},markdownTokenName:`codespan`,parseMarkdown:(e,t)=>t.applyMark(`code`,[{type:`text`,text:e.text||``}]),renderMarkdown:(e,t,n)=>{var r;if(!e.content)return``;let i=typeof(n==null||(r=n.meta)==null?void 0:r.markText)==`string`?n.meta.markText:``,a="`".repeat(xh(i)),o=i.startsWith("`")||i.endsWith("`")?` `:``;return`${a}${o}${t.renderChildren(e.content)}${o}${a}`},addCommands(){return{setCode:()=>({commands:e})=>e.setMark(this.name),toggleCode:()=>({commands:e})=>e.toggleMark(this.name),unsetCode:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[im({find:yh,type:this.type})]},addPasteRules(){return[dm({find:bh,type:this.type})]}}),Ch=4,wh=/^```([a-z]+)?[\s\n]$/,Th=/^~~~([a-z]+)?[\s\n]$/,Eh=um.create({name:`codeBlock`,addOptions(){return{languageClassPrefix:`language-`,exitOnTripleEnter:!0,exitOnArrowDown:!0,exitOnArrowUp:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:Ch,HTMLAttributes:{}}},content:`text*`,marks:``,group:`block`,code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:e=>{let{languageClassPrefix:t}=this.options;return t&&[...e.firstElementChild?.classList||[]].filter(e=>e.startsWith(t)).map(e=>e.replace(t,``))[0]||null},rendered:!1}}},parseHTML(){return[{tag:`pre`,preserveWhitespace:`full`}]},renderHTML({node:e,HTMLAttributes:t}){return[`pre`,K(this.options.HTMLAttributes,t),[`code`,{class:e.attrs.language?this.options.languageClassPrefix+e.attrs.language:null},0]]},markdownTokenName:`code`,parseMarkdown:(e,t)=>e.raw?.startsWith("```")===!1&&e.raw?.startsWith(`~~~`)===!1&&e.codeBlockStyle!==`indented`?[]:t.createNode(`codeBlock`,{language:e.lang||null},e.text?[t.createTextNode(e.text)]:[]),renderMarkdown:(e,t)=>{let n=``,r=e.attrs?.language||``;return n=e.content?[`\`\`\`${r}`,t.renderChildren(e.content),"```"].join(` +`):`\`\`\`${r}\n\n\`\`\``,n},addCommands(){return{setCodeBlock:e=>({commands:t})=>t.setNode(this.name,e),toggleCodeBlock:e=>({commands:t})=>t.toggleNode(this.name,`paragraph`,e)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{let{empty:e,$anchor:t}=this.editor.state.selection,n=t.pos===1;return!e||t.parent.type.name!==this.name?!1:n||!t.parent.textContent.length?this.editor.commands.clearNodes():!1},Tab:({editor:e})=>{if(!this.options.enableTabIndentation)return!1;let t=this.options.tabSize??Ch,{state:n}=e,{selection:r}=n,{$from:i,empty:a}=r;if(i.parent.type!==this.type)return!1;let o=` `.repeat(t);return a?e.commands.insertContent(o):e.commands.command(({tr:e})=>{let{from:t,to:i}=r,a=n.doc.textBetween(t,i,` `,` `).split(` `).map(e=>o+e).join(` -`);return e.replaceWith(t,i,n.schema.text(a)),!0})},"Shift-Tab":({editor:e})=>{if(!this.options.enableTabIndentation)return!1;let t=this.options.tabSize??Sh,{state:n}=e,{selection:r}=n,{$from:i,empty:a}=r;return i.parent.type===this.type?a?e.commands.command(({tr:e})=>{let{pos:r}=i,a=i.start(),o=i.end(),s=n.doc.textBetween(a,o,` +`);return e.replaceWith(t,i,n.schema.text(a)),!0})},"Shift-Tab":({editor:e})=>{if(!this.options.enableTabIndentation)return!1;let t=this.options.tabSize??Ch,{state:n}=e,{selection:r}=n,{$from:i,empty:a}=r;return i.parent.type===this.type?a?e.commands.command(({tr:e})=>{let{pos:r}=i,a=i.start(),o=i.end(),s=n.doc.textBetween(a,o,` `,` `).split(` -`),c=0,l=0,u=r-a;for(let e=0;e=u){c=e;break}l+=s[e].length+1}let d=s[c].match(/^ */)?.[0]||``,f=Math.min(d.length,t);if(f===0)return!0;let p=a;for(let e=0;e{let{from:i,to:a}=r,o=n.doc.textBetween(i,a,` +`),c=0,l=0,u=r-a;for(let e=0;e=u){c=e;break}l+=s[e].length+1}let d=s[c].match(/^ */)?.[0]||``,f=Math.min(d.length,t);if(f===0)return!0;let p=a;for(let e=0;e{let{from:i,to:a}=r,o=n.doc.textBetween(i,a,` `,` `).split(` `).map(e=>{let n=e.match(/^ */)?.[0]||``,r=Math.min(n.length,t);return e.slice(r)}).join(` `);return e.replaceWith(i,a,n.schema.text(o)),!0}):!1},Enter:({editor:e})=>{if(!this.options.exitOnTripleEnter)return!1;let{state:t}=e,{selection:n}=t,{$from:r,empty:i}=n;if(!i||r.parent.type!==this.type)return!1;let a=r.parentOffset===r.parent.nodeSize-2,o=r.parent.textContent.endsWith(` -`);return!a||!o?!1:e.chain().command(({tr:e})=>(e.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowUp:({editor:e})=>{if(!this.options.exitOnArrowUp)return!1;let{state:t}=e,{selection:n}=t,{$from:r,empty:i}=n;if(!i||r.parent.type!==this.type||r.parentOffset!==0)return!1;let a=r.before();return a>0?!1:e.commands.insertDefaultBlock({pos:a})},ArrowDown:({editor:e})=>{if(!this.options.exitOnArrowDown)return!1;let{state:t}=e,{selection:n,doc:r}=t,{$from:i,empty:a}=n;if(!a||i.parent.type!==this.type||i.parentOffset!==i.parent.nodeSize-2)return!1;let o=i.after();return o===void 0?!1:r.nodeAt(o)?e.commands.command(({tr:e})=>(e.setSelection(R.near(r.resolve(o))),!0)):e.commands.exitCode()}}},addInputRules(){return[am({find:Ch,type:this.type,getAttributes:e=>({language:e[1]})}),am({find:wh,type:this.type,getAttributes:e=>({language:e[1]})})]},addProseMirrorPlugins(){return[new V({key:new H(`codeBlockVSCodeHandler`),props:{handlePaste:(e,t)=>{if(!t.clipboardData||this.editor.isActive(this.type.name))return!1;let n=t.clipboardData.getData(`text/plain`),r=t.clipboardData.getData(`vscode-editor-data`),i=(r?JSON.parse(r):void 0)?.mode;if(!n||!i)return!1;let{tr:a,schema:o}=e.state,s=o.text(n.replace(/\r\n?/g,` -`));return a.replaceSelectionWith(this.type.create({language:i},s)),a.selection.$from.parent.type!==this.type&&a.setSelection(z.near(a.doc.resolve(Math.max(0,a.selection.from-2)))),a.setMeta(`paste`,!0),e.dispatch(a),!0}}})]}}),Eh=lm.create({name:`doc`,topNode:!0,content:`block+`,renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,` +`);return!a||!o?!1:e.chain().command(({tr:e})=>(e.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowUp:({editor:e})=>{if(!this.options.exitOnArrowUp)return!1;let{state:t}=e,{selection:n}=t,{$from:r,empty:i}=n;if(!i||r.parent.type!==this.type||r.parentOffset!==0)return!1;let a=r.before();return a>0?!1:e.commands.insertDefaultBlock({pos:a})},ArrowDown:({editor:e})=>{if(!this.options.exitOnArrowDown)return!1;let{state:t}=e,{selection:n,doc:r}=t,{$from:i,empty:a}=n;if(!a||i.parent.type!==this.type||i.parentOffset!==i.parent.nodeSize-2)return!1;let o=i.after();return o===void 0?!1:r.nodeAt(o)?e.commands.command(({tr:e})=>(e.setSelection(L.near(r.resolve(o))),!0)):e.commands.exitCode()}}},addInputRules(){return[om({find:wh,type:this.type,getAttributes:e=>({language:e[1]})}),om({find:Th,type:this.type,getAttributes:e=>({language:e[1]})})]},addProseMirrorPlugins(){return[new B({key:new V(`codeBlockVSCodeHandler`),props:{handlePaste:(e,t)=>{if(!t.clipboardData||this.editor.isActive(this.type.name))return!1;let n=t.clipboardData.getData(`text/plain`),r=t.clipboardData.getData(`vscode-editor-data`),i=(r?JSON.parse(r):void 0)?.mode;if(!n||!i)return!1;let{tr:a,schema:o}=e.state,s=o.text(n.replace(/\r\n?/g,` +`));return a.replaceSelectionWith(this.type.create({language:i},s)),a.selection.$from.parent.type!==this.type&&a.setSelection(R.near(a.doc.resolve(Math.max(0,a.selection.from-2)))),a.setMeta(`paste`,!0),e.dispatch(a),!0}}})]}}),Dh=um.create({name:`doc`,topNode:!0,content:`block+`,renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,` -`):``}),Dh=lm.create({name:`hardBreak`,markdownTokenName:`br`,addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:`inline`,selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:`br`}]},renderHTML({HTMLAttributes:e}){return[`br`,q(this.options.HTMLAttributes,e)]},renderText(){return` +`):``}),Oh=um.create({name:`hardBreak`,markdownTokenName:`br`,addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:`inline`,selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:`br`}]},renderHTML({HTMLAttributes:e}){return[`br`,K(this.options.HTMLAttributes,e)]},renderText(){return` `},renderMarkdown:()=>` -`,parseMarkdown:()=>({type:`hardBreak`}),addCommands(){return{setHardBreak:()=>({commands:e,chain:t,state:n,editor:r})=>e.first([()=>e.exitCode(),()=>e.command(()=>{let{selection:e,storedMarks:i}=n;if(e.$from.parent.type.spec.isolating)return!1;let{keepMarks:a}=this.options,{splittableMarks:o}=r.extensionManager,s=i||e.$to.parentOffset&&e.$from.marks();return t().insertContent({type:this.name}).command(({tr:e,dispatch:t})=>{if(t&&s&&a){let t=s.filter(e=>o.includes(e.type.name));e.ensureMarks(t)}return!0}).scrollIntoView().run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),Oh=lm.create({name:`heading`,addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:`inline*`,group:`block`,defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(e=>({tag:`h${e}`,attrs:{level:e}}))},renderHTML({node:e,HTMLAttributes:t}){return[`h${this.options.levels.includes(e.attrs.level)?e.attrs.level:this.options.levels[0]}`,q(this.options.HTMLAttributes,t),0]},parseMarkdown(e,t){let n=e.depth||1;return this.options.levels.includes(n)?t.createNode(`heading`,{level:n},t.parseInline(e.tokens||[])):t.createNode(`paragraph`,void 0,t.parseInline(e.tokens||[]))},renderMarkdown:(e,t)=>{let n=e.attrs?.level?parseInt(e.attrs.level,10):1,r=`#`.repeat(n);return e.content?`${r} ${t.renderChildren(e.content)}`:``},addCommands(){return{setHeading:e=>({commands:t})=>this.options.levels.includes(e.level)?t.setNode(this.name,e):!1,toggleHeading:e=>({commands:t})=>this.options.levels.includes(e.level)?t.toggleNode(this.name,`paragraph`,e):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((e,t)=>({...e,[`Mod-Alt-${t}`]:()=>this.editor.commands.toggleHeading({level:t})}),{})},addInputRules(){return this.options.levels.map(e=>am({find:RegExp(`^(#{${Math.min(...this.options.levels)},${e}})\\s$`),type:this.type,getAttributes:{level:e}}))}}),kh=lm.create({name:`horizontalRule`,addOptions(){return{HTMLAttributes:{},nextNodeType:`paragraph`}},group:`block`,parseHTML(){return[{tag:`hr`}]},renderHTML({HTMLAttributes:e}){return[`hr`,q(this.options.HTMLAttributes,e)]},markdownTokenName:`hr`,parseMarkdown:(e,t)=>t.createNode(`horizontalRule`),renderMarkdown:()=>`---`,addCommands(){return{setHorizontalRule:()=>({chain:e,state:t})=>{if(!cp(t,t.schema.nodes[this.name]))return!1;let{selection:n}=t,{$to:r}=n,i=e();return Jd(n)?i.insertContentAt(r.pos,{type:this.name}):i.insertContent({type:this.name}),i.command(({state:e,tr:t,dispatch:n})=>{if(n){let{$to:n}=t.selection,r=n.end();if(n.nodeAfter)n.nodeAfter.isTextblock?t.setSelection(z.create(t.doc,n.pos+1)):n.nodeAfter.isBlock?t.setSelection(B.create(t.doc,n.pos)):t.setSelection(z.create(t.doc,n.pos));else{let i=(e.schema.nodes[this.options.nextNodeType]||n.parent.type.contentMatch.defaultType)?.create();i&&(t.insert(r,i),t.setSelection(z.create(t.doc,r+1)))}t.scrollIntoView()}return!0}).run()}}},addInputRules(){return[im({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),Ah=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,jh=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,Mh=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,Nh=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,Ph=Mp.create({name:`italic`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`em`},{tag:`i`,getAttrs:e=>e.style.fontStyle!==`normal`&&null},{style:`font-style=normal`,clearMark:e=>e.type.name===this.name},{style:`font-style=italic`}]},renderHTML({HTMLAttributes:e}){return[`em`,q(this.options.HTMLAttributes,e),0]},addCommands(){return{setItalic:()=>({commands:e})=>e.setMark(this.name),toggleItalic:()=>({commands:e})=>e.toggleMark(this.name),unsetItalic:()=>({commands:e})=>e.unsetMark(this.name)}},markdownTokenName:`em`,parseMarkdown:(e,t)=>t.applyMark(`italic`,t.parseInline(e.tokens||[])),markdownOptions:{htmlReopen:{open:``,close:``}},renderMarkdown:(e,t)=>`*${t.renderChildren(e)}*`,addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[rm({find:Ah,type:this.type}),rm({find:Mh,type:this.type})]},addPasteRules(){return[um({find:jh,type:this.type}),um({find:Nh,type:this.type})]}}),Fh=`aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2odyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos6kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rck0msd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12b0cam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2oodside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2`,Ih=`ελ1υ2бг1ел3дети4ею2католик6ом3мкд2он1сква6онлайн5рг3рус2ф2сайт3рб3укр3қаз3հայ3ישראל5קום3ابوظبي5رامكو5لاردن4بحرين5جزائر5سعودية6عليان5مغرب5مارات5یران5بارت2زار4يتك3ھارت5تونس4سودان3رية5شبكة4عراق2ب2مان4فلسطين6قطر3كاثوليك6وم3مصر2ليسيا5وريتانيا7قع4همراه5پاکستان7ڀارت4कॉम3नेट3भारत0म्3ोत5संगठन5বাংলা5ভারত2ৰত4ਭਾਰਤ4ભારત4ଭାରତ4இந்தியா6லங்கை6சிங்கப்பூர்11భారత్5ಭಾರತ4ഭാരതം5ලංකා4คอม3ไทย3ລາວ3გე2みんな3アマゾン4クラウド4グーグル4コム2ストア3セール3ファッション6ポイント4世界2中信1国1國1文网3亚马逊3企业2佛山2信息2健康2八卦2公司1益2台湾1灣2商城1店1标2嘉里0大酒店5在线2大拿2天主教3娱乐2家電2广东2微博2慈善2我爱你3手机2招聘2政务1府2新加坡2闻2时尚2書籍2机构2淡马锡3游戏2澳門2点看2移动2组织机构4网址1店1站1络2联通2谷歌2购物2通販2集团2電訊盈科4飞利浦3食品2餐厅2香格里拉3港2닷넷1컴2삼성2한국2`,Lh=`numeric`,Rh=`ascii`,zh=`alpha`,Bh=`asciinumeric`,Vh=`alphanumeric`,Hh=`domain`,Uh=`emoji`,Wh=`scheme`,Gh=`slashscheme`,Kh=`whitespace`;function qh(e,t){return e in t||(t[e]=[]),t[e]}function Jh(e,t,n){t[Lh]&&(t[Bh]=!0,t[Vh]=!0),t[Rh]&&(t[Bh]=!0,t[zh]=!0),t[Bh]&&(t[Vh]=!0),t[zh]&&(t[Vh]=!0),t[Vh]&&(t[Hh]=!0),t[Uh]&&(t[Hh]=!0);for(let r in t){let t=qh(r,n);t.indexOf(e)<0&&t.push(e)}}function Yh(e,t){let n={};for(let r in t)t[r].indexOf(e)>=0&&(n[r]=!0);return n}function Xh(e=null){this.j={},this.jr=[],this.jd=null,this.t=e}Xh.groups={},Xh.prototype={accepts(){return!!this.t},go(e){let t=this,n=t.j[e];if(n)return n;for(let n=0;ne.ta(t,n,r,i),Zh=(e,t,n,r,i)=>e.tr(t,n,r,i),Qh=(e,t,n,r,i)=>e.ts(t,n,r,i),X=(e,t,n,r,i)=>e.tt(t,n,r,i),$h=`WORD`,eg=`UWORD`,tg=`ASCIINUMERICAL`,ng=`ALPHANUMERICAL`,rg=`LOCALHOST`,ig=`TLD`,ag=`UTLD`,og=`SCHEME`,sg=`SLASH_SCHEME`,cg=`NUM`,lg=`WS`,ug=`NL`,dg=`OPENBRACE`,fg=`CLOSEBRACE`,pg=`OPENBRACKET`,mg=`CLOSEBRACKET`,hg=`OPENPAREN`,gg=`CLOSEPAREN`,_g=`OPENANGLEBRACKET`,vg=`CLOSEANGLEBRACKET`,yg=`FULLWIDTHLEFTPAREN`,bg=`FULLWIDTHRIGHTPAREN`,xg=`LEFTCORNERBRACKET`,Sg=`RIGHTCORNERBRACKET`,Cg=`LEFTWHITECORNERBRACKET`,wg=`RIGHTWHITECORNERBRACKET`,Tg=`FULLWIDTHLESSTHAN`,Eg=`FULLWIDTHGREATERTHAN`,Dg=`AMPERSAND`,Og=`APOSTROPHE`,kg=`ASTERISK`,Ag=`AT`,jg=`BACKSLASH`,Mg=`BACKTICK`,Ng=`CARET`,Pg=`COLON`,Fg=`COMMA`,Ig=`DOLLAR`,Lg=`DOT`,Rg=`EQUALS`,zg=`EXCLAMATION`,Bg=`HYPHEN`,Vg=`PERCENT`,Hg=`PIPE`,Ug=`PLUS`,Wg=`POUND`,Gg=`QUERY`,Kg=`QUOTE`,qg=`FULLWIDTHMIDDLEDOT`,Jg=`SEMI`,Yg=`SLASH`,Xg=`TILDE`,Zg=`UNDERSCORE`,Qg=`EMOJI`,$g=`SYM`,e_=Object.freeze({__proto__:null,ALPHANUMERICAL:ng,AMPERSAND:Dg,APOSTROPHE:Og,ASCIINUMERICAL:tg,ASTERISK:kg,AT:Ag,BACKSLASH:jg,BACKTICK:Mg,CARET:Ng,CLOSEANGLEBRACKET:vg,CLOSEBRACE:fg,CLOSEBRACKET:mg,CLOSEPAREN:gg,COLON:Pg,COMMA:Fg,DOLLAR:Ig,DOT:Lg,EMOJI:Qg,EQUALS:Rg,EXCLAMATION:zg,FULLWIDTHGREATERTHAN:Eg,FULLWIDTHLEFTPAREN:yg,FULLWIDTHLESSTHAN:Tg,FULLWIDTHMIDDLEDOT:qg,FULLWIDTHRIGHTPAREN:bg,HYPHEN:Bg,LEFTCORNERBRACKET:xg,LEFTWHITECORNERBRACKET:Cg,LOCALHOST:rg,NL:ug,NUM:cg,OPENANGLEBRACKET:_g,OPENBRACE:dg,OPENBRACKET:pg,OPENPAREN:hg,PERCENT:Vg,PIPE:Hg,PLUS:Ug,POUND:Wg,QUERY:Gg,QUOTE:Kg,RIGHTCORNERBRACKET:Sg,RIGHTWHITECORNERBRACKET:wg,SCHEME:og,SEMI:Jg,SLASH:Yg,SLASH_SCHEME:sg,SYM:$g,TILDE:Xg,TLD:ig,UNDERSCORE:Zg,UTLD:ag,UWORD:eg,WORD:$h,WS:lg}),t_=/[a-z]/,n_=/[a-z]/i,r_=/[\u{1F000}-\u{1FAFF}\u{2600}-\u{27BF}]|\u{FE0F}/u;try{n_=RegExp(`\\p{L}`,`u`),r_=RegExp(`\\p{Emoji}`,`u`)}catch{}var i_=/\d/,a_=/\s/,o_=`\r`,s_=` -`,c_=`️`,l_=`‍`,u_=``,d_=null,f_=null;function p_(e=[]){let t={};Xh.groups=t;let n=new Xh;d_??=__(Fh),f_??=__(Ih),X(n,`'`,Og),X(n,`{`,dg),X(n,`}`,fg),X(n,`[`,pg),X(n,`]`,mg),X(n,`(`,hg),X(n,`)`,gg),X(n,`<`,_g),X(n,`>`,vg),X(n,`(`,yg),X(n,`)`,bg),X(n,`「`,xg),X(n,`」`,Sg),X(n,`『`,Cg),X(n,`』`,wg),X(n,`<`,Tg),X(n,`>`,Eg),X(n,`&`,Dg),X(n,`*`,kg),X(n,`@`,Ag),X(n,"`",Mg),X(n,`^`,Ng),X(n,`:`,Pg),X(n,`,`,Fg),X(n,`$`,Ig),X(n,`.`,Lg),X(n,`=`,Rg),X(n,`!`,zg),X(n,`-`,Bg),X(n,`%`,Vg),X(n,`|`,Hg),X(n,`+`,Ug),X(n,`#`,Wg),X(n,`?`,Gg),X(n,`"`,Kg),X(n,`/`,Yg),X(n,`;`,Jg),X(n,`~`,Xg),X(n,`_`,Zg),X(n,`\\`,jg),X(n,`・`,qg);let r=Zh(n,i_,cg,{[Lh]:!0});Zh(r,i_,r);let i=Zh(r,t_,tg,{[Bh]:!0}),a=Zh(r,n_,ng,{[Vh]:!0}),o=Zh(n,t_,$h,{[Rh]:!0});Zh(o,i_,i),Zh(o,t_,o),Zh(i,i_,i),Zh(i,t_,i);let s=Zh(n,n_,eg,{[zh]:!0});Zh(s,t_),Zh(s,i_,a),Zh(s,n_,s),Zh(a,i_,a),Zh(a,t_),Zh(a,n_,a);let c=X(n,s_,ug,{[Kh]:!0}),l=X(n,o_,lg,{[Kh]:!0}),u=Zh(n,a_,lg,{[Kh]:!0});X(n,u_,u),X(l,s_,c),X(l,u_,u),Zh(l,a_,u),X(u,o_),X(u,s_),Zh(u,a_,u),X(u,u_,u);let d=Zh(n,r_,Qg,{[Uh]:!0});X(d,`#`),Zh(d,r_,d),X(d,c_,d);let f=X(d,l_);X(f,`#`),Zh(f,r_,d);let p=[[t_,o],[i_,i]],m=[[t_,null],[n_,s],[i_,a]];for(let e=0;ee[0]>t[0]?1:-1);for(let t=0;t=0?i[Hh]=!0:t_.test(r)?i_.test(r)?i[Bh]=!0:i[Rh]=!0:i[Lh]=!0,Qh(n,r,r,i)}return Qh(n,`localhost`,rg,{ascii:!0}),n.jd=new Xh($g),{start:n,tokens:Object.assign({groups:t},e_)}}function m_(e,t){let n=h_(t.replace(/[A-Z]/g,e=>e.toLowerCase())),r=n.length,i=[],a=0,o=0;for(;o=0&&(d+=n[o].length,f++),l+=n[o].length,a+=n[o].length,o++;a-=d,o-=f,l-=d,i.push({t:u.t,v:t.slice(a-l,a),s:a-l,e:a})}return i}function h_(e){let t=[],n=e.length,r=0;for(;r56319||r+1===n||(a=e.charCodeAt(r+1))<56320||a>57343?e[r]:e.slice(r,r+2);t.push(o),r+=o.length}return t}function g_(e,t,n,r,i){let a,o=t.length;for(let n=0;n=0;)i++;if(i>0){t.push(n.join(``));for(let t=parseInt(e.substring(r,r+i),10);t>0;t--)n.pop();r+=i}else n.push(e[r]),r++}return t}var v_={defaultProtocol:`http`,events:null,format:b_,formatHref:b_,nl2br:!1,tagName:`a`,target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],ignoreClasses:[],render:null};function y_(e,t=null){let n=Object.assign({},v_);e&&(n=Object.assign(n,e instanceof y_?e.o:e));let r=n.ignoreTags,i=[];for(let e=0;e=0)return!0;return!1},defaultRender(e){return e},check(e){return this.get(`validate`,e.toString(),e)},get(e,t,n){let r=t!=null,i=this.o[e];return i&&(typeof i==`object`?(i=n.t in i?i[n.t]:v_[e],typeof i==`function`&&r&&(i=i(t,n))):typeof i==`function`&&r&&(i=i(t,n.t,n)),i)},getObj(e,t,n){let r=this.o[e];return typeof r==`function`&&t!=null&&(r=r(t,n.t,n)),r},render(e){let t=e.render(this);return(this.get(`render`,null,e)||this.defaultRender)(t,e.t,e)}};function b_(e){return e}function x_(e,t){this.t=`token`,this.v=e,this.tk=t}x_.prototype={isLink:!1,toString(){return this.v},toHref(e){return this.toString()},toFormattedString(e){let t=this.toString(),n=e.get(`truncate`,t,this),r=e.get(`format`,t,this);return n&&r.length>n?r.substring(0,n)+`…`:r},toFormattedHref(e){return e.get(`formatHref`,this.toHref(e.get(`defaultProtocol`)),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(e=v_.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(e),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(e){return{type:this.t,value:this.toFormattedString(e),isLink:this.isLink,href:this.toFormattedHref(e),start:this.startIndex(),end:this.endIndex()}},validate(e){return e.get(`validate`,this.toString(),this)},render(e){let t=this,n=this.toHref(e.get(`defaultProtocol`)),r=e.get(`formatHref`,n,this),i=e.get(`tagName`,n,t),a=this.toFormattedString(e),o={},s=e.get(`className`,n,t),c=e.get(`target`,n,t),l=e.get(`rel`,n,t),u=e.getObj(`attributes`,n,t),d=e.getObj(`events`,n,t);return o.href=r,s&&(o.class=s),c&&(o.target=c),l&&(o.rel=l),u&&Object.assign(o,u),{tagName:i,attributes:o,content:a,eventListeners:d}}};function S_(e,t){class n extends x_{constructor(t,n){super(t,n),this.t=e}}for(let e in t)n.prototype[e]=t[e];return n.t=e,n}var C_=S_(`email`,{isLink:!0,toHref(){return`mailto:`+this.toString()}}),w_=S_(`text`),T_=S_(`nl`),E_=S_(`url`,{isLink:!0,toHref(e=v_.defaultProtocol){return this.hasProtocol()?this.v:`${e}://${this.v}`},hasProtocol(){let e=this.tk;return e.length>=2&&e[0].t!==rg&&e[1].t===Pg}}),D_=e=>new Xh(e);function O_({groups:e}){let t=e.domain.concat([Dg,kg,Ag,jg,Mg,Ng,Ig,Rg,Bg,cg,Vg,Hg,Ug,Wg,Yg,$g,Xg,Zg]),n=[Og,Pg,Fg,Lg,zg,Vg,Gg,Kg,Jg,_g,vg,dg,fg,mg,pg,hg,gg,yg,bg,xg,Sg,Cg,wg,Tg,Eg],r=[Dg,Og,kg,jg,Mg,Ng,Ig,Rg,Bg,dg,fg,Vg,Hg,Ug,Wg,Gg,Yg,$g,Xg,Zg],i=D_(),a=X(i,Xg);Y(a,r,a),Y(a,e.domain,a);let o=D_(),s=D_(),c=D_();Y(i,e.domain,o),Y(i,e.scheme,s),Y(i,e.slashscheme,c),Y(o,r,a),Y(o,e.domain,o);let l=X(o,Ag);X(a,Ag,l),X(s,Ag,l),X(c,Ag,l);let u=X(a,Lg);Y(u,r,a),Y(u,e.domain,a);let d=D_();Y(l,e.domain,d),Y(d,e.domain,d);let f=X(d,Lg);Y(f,e.domain,d);let p=D_(C_);Y(f,e.tld,p),Y(f,e.utld,p),X(l,rg,p);let m=X(d,Bg);X(m,Bg,m),Y(m,e.domain,d),Y(p,e.domain,d),X(p,Lg,f),X(p,Bg,m);let h=X(o,Bg),g=X(o,Lg);X(h,Bg,h),Y(h,e.domain,o),Y(g,r,a),Y(g,e.domain,o);let _=D_(E_);Y(g,e.tld,_),Y(g,e.utld,_),Y(_,e.domain,o),Y(_,r,a),X(_,Lg,g),X(_,Bg,h),X(_,Ag,l);let v=X(_,Pg),y=D_(E_);Y(v,e.numeric,y);let b=D_(E_),x=D_();Y(b,t,b),Y(b,n,x),Y(x,t,b),Y(x,n,x),X(_,Yg,b),X(y,Yg,b),X(_,Gg,x),X(_,Wg,b),X(y,Gg,x),X(y,Wg,b);let S=X(s,Pg),C=X(X(X(c,Pg),Yg),Yg);Y(s,e.domain,o),X(s,Lg,g),X(s,Bg,h),Y(c,e.domain,o),X(c,Lg,g),X(c,Bg,h),Y(S,e.domain,b),X(S,Yg,b),X(S,Gg,b),Y(C,e.domain,b),Y(C,t,b),X(C,Yg,b);let w=[[dg,fg],[pg,mg],[hg,gg],[_g,vg],[yg,bg],[xg,Sg],[Cg,wg],[Tg,Eg]];for(let e=0;e=0&&p++,m.push(c),s[i]&&s[i].has(c))break;for(let e=0,t=i-m.length+1;e0&&(a.push(A_(w_,t,o)),o=[]),i-=p,d-=p;let e=f.t,r=n.slice(i-d,i);a.push(A_(e,t,r))}}return o.length>0&&a.push(A_(w_,t,o)),a}function A_(e,t,n){let r=n[0].s,i=n[n.length-1].e;return new e(t.slice(r,i),n)}var j_=typeof console<`u`&&console&&console.warn||(()=>{}),M_=`until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.`,Z={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function N_(){return Xh.groups={},Z.scanner=null,Z.parser=null,Z.tokenQueue=[],Z.pluginQueue=[],Z.customSchemes=[],Z.initialized=!1,Z}function P_(e,t=!1){if(Z.initialized&&j_(`linkifyjs: already initialized - will not register custom scheme "${e}" ${M_}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(e))throw Error(`linkifyjs: incorrect scheme format. +`,parseMarkdown:()=>({type:`hardBreak`}),addCommands(){return{setHardBreak:()=>({commands:e,chain:t,state:n,editor:r})=>e.first([()=>e.exitCode(),()=>e.command(()=>{let{selection:e,storedMarks:i}=n;if(e.$from.parent.type.spec.isolating)return!1;let{keepMarks:a}=this.options,{splittableMarks:o}=r.extensionManager,s=i||e.$to.parentOffset&&e.$from.marks();return t().insertContent({type:this.name}).command(({tr:e,dispatch:t})=>{if(t&&s&&a){let t=s.filter(e=>o.includes(e.type.name));e.ensureMarks(t)}return!0}).scrollIntoView().run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),kh=um.create({name:`heading`,addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:`inline*`,group:`block`,defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(e=>({tag:`h${e}`,attrs:{level:e}}))},renderHTML({node:e,HTMLAttributes:t}){return[`h${this.options.levels.includes(e.attrs.level)?e.attrs.level:this.options.levels[0]}`,K(this.options.HTMLAttributes,t),0]},parseMarkdown(e,t){let n=e.depth||1;return this.options.levels.includes(n)?t.createNode(`heading`,{level:n},t.parseInline(e.tokens||[])):t.createNode(`paragraph`,void 0,t.parseInline(e.tokens||[]))},renderMarkdown:(e,t)=>{let n=e.attrs?.level?parseInt(e.attrs.level,10):1,r=`#`.repeat(n);return e.content?`${r} ${t.renderChildren(e.content)}`:``},addCommands(){return{setHeading:e=>({commands:t})=>this.options.levels.includes(e.level)?t.setNode(this.name,e):!1,toggleHeading:e=>({commands:t})=>this.options.levels.includes(e.level)?t.toggleNode(this.name,`paragraph`,e):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((e,t)=>({...e,[`Mod-Alt-${t}`]:()=>this.editor.commands.toggleHeading({level:t})}),{})},addInputRules(){return this.options.levels.map(e=>om({find:RegExp(`^(#{${Math.min(...this.options.levels)},${e}})\\s$`),type:this.type,getAttributes:{level:e}}))}}),Ah=um.create({name:`horizontalRule`,addOptions(){return{HTMLAttributes:{},nextNodeType:`paragraph`}},group:`block`,parseHTML(){return[{tag:`hr`}]},renderHTML({HTMLAttributes:e}){return[`hr`,K(this.options.HTMLAttributes,e)]},markdownTokenName:`hr`,parseMarkdown:(e,t)=>t.createNode(`horizontalRule`),renderMarkdown:()=>`---`,addCommands(){return{setHorizontalRule:()=>({chain:e,state:t})=>{if(!lp(t,t.schema.nodes[this.name]))return!1;let{selection:n}=t,{$to:r}=n,i=e();return Yd(n)?i.insertContentAt(r.pos,{type:this.name}):i.insertContent({type:this.name}),i.command(({state:e,tr:t,dispatch:n})=>{if(n){let{$to:n}=t.selection,r=n.end();if(n.nodeAfter)n.nodeAfter.isTextblock?t.setSelection(R.create(t.doc,n.pos+1)):n.nodeAfter.isBlock?t.setSelection(z.create(t.doc,n.pos)):t.setSelection(R.create(t.doc,n.pos));else{let i=(e.schema.nodes[this.options.nextNodeType]||n.parent.type.contentMatch.defaultType)?.create();i&&(t.insert(r,i),t.setSelection(R.create(t.doc,r+1)))}t.scrollIntoView()}return!0}).run()}}},addInputRules(){return[am({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),jh=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,Mh=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,Nh=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,Ph=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,Fh=Np.create({name:`italic`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`em`},{tag:`i`,getAttrs:e=>e.style.fontStyle!==`normal`&&null},{style:`font-style=normal`,clearMark:e=>e.type.name===this.name},{style:`font-style=italic`}]},renderHTML({HTMLAttributes:e}){return[`em`,K(this.options.HTMLAttributes,e),0]},addCommands(){return{setItalic:()=>({commands:e})=>e.setMark(this.name),toggleItalic:()=>({commands:e})=>e.toggleMark(this.name),unsetItalic:()=>({commands:e})=>e.unsetMark(this.name)}},markdownTokenName:`em`,parseMarkdown:(e,t)=>t.applyMark(`italic`,t.parseInline(e.tokens||[])),markdownOptions:{htmlReopen:{open:``,close:``}},renderMarkdown:(e,t)=>`*${t.renderChildren(e)}*`,addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[im({find:jh,type:this.type}),im({find:Nh,type:this.type})]},addPasteRules(){return[dm({find:Mh,type:this.type}),dm({find:Ph,type:this.type})]}}),Ih=`aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2odyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos6kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rck0msd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12b0cam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2oodside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2`,Lh=`ελ1υ2бг1ел3дети4ею2католик6ом3мкд2он1сква6онлайн5рг3рус2ф2сайт3рб3укр3қаз3հայ3ישראל5קום3ابوظبي5رامكو5لاردن4بحرين5جزائر5سعودية6عليان5مغرب5مارات5یران5بارت2زار4يتك3ھارت5تونس4سودان3رية5شبكة4عراق2ب2مان4فلسطين6قطر3كاثوليك6وم3مصر2ليسيا5وريتانيا7قع4همراه5پاکستان7ڀارت4कॉम3नेट3भारत0म्3ोत5संगठन5বাংলা5ভারত2ৰত4ਭਾਰਤ4ભારત4ଭାରତ4இந்தியா6லங்கை6சிங்கப்பூர்11భారత్5ಭಾರತ4ഭാരതം5ලංකා4คอม3ไทย3ລາວ3გე2みんな3アマゾン4クラウド4グーグル4コム2ストア3セール3ファッション6ポイント4世界2中信1国1國1文网3亚马逊3企业2佛山2信息2健康2八卦2公司1益2台湾1灣2商城1店1标2嘉里0大酒店5在线2大拿2天主教3娱乐2家電2广东2微博2慈善2我爱你3手机2招聘2政务1府2新加坡2闻2时尚2書籍2机构2淡马锡3游戏2澳門2点看2移动2组织机构4网址1店1站1络2联通2谷歌2购物2通販2集团2電訊盈科4飞利浦3食品2餐厅2香格里拉3港2닷넷1컴2삼성2한국2`,Rh=`numeric`,zh=`ascii`,Bh=`alpha`,Vh=`asciinumeric`,Hh=`alphanumeric`,Uh=`domain`,Wh=`emoji`,Gh=`scheme`,Kh=`slashscheme`,qh=`whitespace`;function Jh(e,t){return e in t||(t[e]=[]),t[e]}function Yh(e,t,n){t[Rh]&&(t[Vh]=!0,t[Hh]=!0),t[zh]&&(t[Vh]=!0,t[Bh]=!0),t[Vh]&&(t[Hh]=!0),t[Bh]&&(t[Hh]=!0),t[Hh]&&(t[Uh]=!0),t[Wh]&&(t[Uh]=!0);for(let r in t){let t=Jh(r,n);t.indexOf(e)<0&&t.push(e)}}function Xh(e,t){let n={};for(let r in t)t[r].indexOf(e)>=0&&(n[r]=!0);return n}function Zh(e=null){this.j={},this.jr=[],this.jd=null,this.t=e}Zh.groups={},Zh.prototype={accepts(){return!!this.t},go(e){let t=this,n=t.j[e];if(n)return n;for(let n=0;ne.ta(t,n,r,i),Y=(e,t,n,r,i)=>e.tr(t,n,r,i),Qh=(e,t,n,r,i)=>e.ts(t,n,r,i),X=(e,t,n,r,i)=>e.tt(t,n,r,i),$h=`WORD`,eg=`UWORD`,tg=`ASCIINUMERICAL`,ng=`ALPHANUMERICAL`,rg=`LOCALHOST`,ig=`TLD`,ag=`UTLD`,og=`SCHEME`,sg=`SLASH_SCHEME`,cg=`NUM`,lg=`WS`,ug=`NL`,dg=`OPENBRACE`,fg=`CLOSEBRACE`,pg=`OPENBRACKET`,mg=`CLOSEBRACKET`,hg=`OPENPAREN`,gg=`CLOSEPAREN`,_g=`OPENANGLEBRACKET`,vg=`CLOSEANGLEBRACKET`,yg=`FULLWIDTHLEFTPAREN`,bg=`FULLWIDTHRIGHTPAREN`,xg=`LEFTCORNERBRACKET`,Sg=`RIGHTCORNERBRACKET`,Cg=`LEFTWHITECORNERBRACKET`,wg=`RIGHTWHITECORNERBRACKET`,Tg=`FULLWIDTHLESSTHAN`,Eg=`FULLWIDTHGREATERTHAN`,Dg=`AMPERSAND`,Og=`APOSTROPHE`,kg=`ASTERISK`,Ag=`AT`,jg=`BACKSLASH`,Mg=`BACKTICK`,Ng=`CARET`,Pg=`COLON`,Fg=`COMMA`,Ig=`DOLLAR`,Lg=`DOT`,Rg=`EQUALS`,zg=`EXCLAMATION`,Bg=`HYPHEN`,Vg=`PERCENT`,Hg=`PIPE`,Ug=`PLUS`,Wg=`POUND`,Gg=`QUERY`,Kg=`QUOTE`,qg=`FULLWIDTHMIDDLEDOT`,Jg=`SEMI`,Yg=`SLASH`,Xg=`TILDE`,Zg=`UNDERSCORE`,Qg=`EMOJI`,$g=`SYM`,e_=Object.freeze({__proto__:null,ALPHANUMERICAL:ng,AMPERSAND:Dg,APOSTROPHE:Og,ASCIINUMERICAL:tg,ASTERISK:kg,AT:Ag,BACKSLASH:jg,BACKTICK:Mg,CARET:Ng,CLOSEANGLEBRACKET:vg,CLOSEBRACE:fg,CLOSEBRACKET:mg,CLOSEPAREN:gg,COLON:Pg,COMMA:Fg,DOLLAR:Ig,DOT:Lg,EMOJI:Qg,EQUALS:Rg,EXCLAMATION:zg,FULLWIDTHGREATERTHAN:Eg,FULLWIDTHLEFTPAREN:yg,FULLWIDTHLESSTHAN:Tg,FULLWIDTHMIDDLEDOT:qg,FULLWIDTHRIGHTPAREN:bg,HYPHEN:Bg,LEFTCORNERBRACKET:xg,LEFTWHITECORNERBRACKET:Cg,LOCALHOST:rg,NL:ug,NUM:cg,OPENANGLEBRACKET:_g,OPENBRACE:dg,OPENBRACKET:pg,OPENPAREN:hg,PERCENT:Vg,PIPE:Hg,PLUS:Ug,POUND:Wg,QUERY:Gg,QUOTE:Kg,RIGHTCORNERBRACKET:Sg,RIGHTWHITECORNERBRACKET:wg,SCHEME:og,SEMI:Jg,SLASH:Yg,SLASH_SCHEME:sg,SYM:$g,TILDE:Xg,TLD:ig,UNDERSCORE:Zg,UTLD:ag,UWORD:eg,WORD:$h,WS:lg}),t_=/[a-z]/,n_=/[a-z]/i,r_=/[\u{1F000}-\u{1FAFF}\u{2600}-\u{27BF}]|\u{FE0F}/u;try{n_=RegExp(`\\p{L}`,`u`),r_=RegExp(`\\p{Emoji}`,`u`)}catch{}var i_=/\d/,a_=/\s/,o_=`\r`,s_=` +`,c_=`️`,l_=`‍`,u_=``,d_=null,f_=null;function p_(e=[]){let t={};Zh.groups=t;let n=new Zh;d_??=__(Ih),f_??=__(Lh),X(n,`'`,Og),X(n,`{`,dg),X(n,`}`,fg),X(n,`[`,pg),X(n,`]`,mg),X(n,`(`,hg),X(n,`)`,gg),X(n,`<`,_g),X(n,`>`,vg),X(n,`(`,yg),X(n,`)`,bg),X(n,`「`,xg),X(n,`」`,Sg),X(n,`『`,Cg),X(n,`』`,wg),X(n,`<`,Tg),X(n,`>`,Eg),X(n,`&`,Dg),X(n,`*`,kg),X(n,`@`,Ag),X(n,"`",Mg),X(n,`^`,Ng),X(n,`:`,Pg),X(n,`,`,Fg),X(n,`$`,Ig),X(n,`.`,Lg),X(n,`=`,Rg),X(n,`!`,zg),X(n,`-`,Bg),X(n,`%`,Vg),X(n,`|`,Hg),X(n,`+`,Ug),X(n,`#`,Wg),X(n,`?`,Gg),X(n,`"`,Kg),X(n,`/`,Yg),X(n,`;`,Jg),X(n,`~`,Xg),X(n,`_`,Zg),X(n,`\\`,jg),X(n,`・`,qg);let r=Y(n,i_,cg,{[Rh]:!0});Y(r,i_,r);let i=Y(r,t_,tg,{[Vh]:!0}),a=Y(r,n_,ng,{[Hh]:!0}),o=Y(n,t_,$h,{[zh]:!0});Y(o,i_,i),Y(o,t_,o),Y(i,i_,i),Y(i,t_,i);let s=Y(n,n_,eg,{[Bh]:!0});Y(s,t_),Y(s,i_,a),Y(s,n_,s),Y(a,i_,a),Y(a,t_),Y(a,n_,a);let c=X(n,s_,ug,{[qh]:!0}),l=X(n,o_,lg,{[qh]:!0}),u=Y(n,a_,lg,{[qh]:!0});X(n,u_,u),X(l,s_,c),X(l,u_,u),Y(l,a_,u),X(u,o_),X(u,s_),Y(u,a_,u),X(u,u_,u);let d=Y(n,r_,Qg,{[Wh]:!0});X(d,`#`),Y(d,r_,d),X(d,c_,d);let f=X(d,l_);X(f,`#`),Y(f,r_,d);let p=[[t_,o],[i_,i]],m=[[t_,null],[n_,s],[i_,a]];for(let e=0;ee[0]>t[0]?1:-1);for(let t=0;t=0?i[Uh]=!0:t_.test(r)?i_.test(r)?i[Vh]=!0:i[zh]=!0:i[Rh]=!0,Qh(n,r,r,i)}return Qh(n,`localhost`,rg,{ascii:!0}),n.jd=new Zh($g),{start:n,tokens:Object.assign({groups:t},e_)}}function m_(e,t){let n=h_(t.replace(/[A-Z]/g,e=>e.toLowerCase())),r=n.length,i=[],a=0,o=0;for(;o=0&&(d+=n[o].length,f++),l+=n[o].length,a+=n[o].length,o++;a-=d,o-=f,l-=d,i.push({t:u.t,v:t.slice(a-l,a),s:a-l,e:a})}return i}function h_(e){let t=[],n=e.length,r=0;for(;r56319||r+1===n||(a=e.charCodeAt(r+1))<56320||a>57343?e[r]:e.slice(r,r+2);t.push(o),r+=o.length}return t}function g_(e,t,n,r,i){let a,o=t.length;for(let n=0;n=0;)i++;if(i>0){t.push(n.join(``));for(let t=parseInt(e.substring(r,r+i),10);t>0;t--)n.pop();r+=i}else n.push(e[r]),r++}return t}var v_={defaultProtocol:`http`,events:null,format:b_,formatHref:b_,nl2br:!1,tagName:`a`,target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],ignoreClasses:[],render:null};function y_(e,t=null){let n=Object.assign({},v_);e&&(n=Object.assign(n,e instanceof y_?e.o:e));let r=n.ignoreTags,i=[];for(let e=0;e=0)return!0;return!1},defaultRender(e){return e},check(e){return this.get(`validate`,e.toString(),e)},get(e,t,n){let r=t!=null,i=this.o[e];return i&&(typeof i==`object`?(i=n.t in i?i[n.t]:v_[e],typeof i==`function`&&r&&(i=i(t,n))):typeof i==`function`&&r&&(i=i(t,n.t,n)),i)},getObj(e,t,n){let r=this.o[e];return typeof r==`function`&&t!=null&&(r=r(t,n.t,n)),r},render(e){let t=e.render(this);return(this.get(`render`,null,e)||this.defaultRender)(t,e.t,e)}};function b_(e){return e}function x_(e,t){this.t=`token`,this.v=e,this.tk=t}x_.prototype={isLink:!1,toString(){return this.v},toHref(e){return this.toString()},toFormattedString(e){let t=this.toString(),n=e.get(`truncate`,t,this),r=e.get(`format`,t,this);return n&&r.length>n?r.substring(0,n)+`…`:r},toFormattedHref(e){return e.get(`formatHref`,this.toHref(e.get(`defaultProtocol`)),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(e=v_.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(e),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(e){return{type:this.t,value:this.toFormattedString(e),isLink:this.isLink,href:this.toFormattedHref(e),start:this.startIndex(),end:this.endIndex()}},validate(e){return e.get(`validate`,this.toString(),this)},render(e){let t=this,n=this.toHref(e.get(`defaultProtocol`)),r=e.get(`formatHref`,n,this),i=e.get(`tagName`,n,t),a=this.toFormattedString(e),o={},s=e.get(`className`,n,t),c=e.get(`target`,n,t),l=e.get(`rel`,n,t),u=e.getObj(`attributes`,n,t),d=e.getObj(`events`,n,t);return o.href=r,s&&(o.class=s),c&&(o.target=c),l&&(o.rel=l),u&&Object.assign(o,u),{tagName:i,attributes:o,content:a,eventListeners:d}}};function S_(e,t){class n extends x_{constructor(t,n){super(t,n),this.t=e}}for(let e in t)n.prototype[e]=t[e];return n.t=e,n}var C_=S_(`email`,{isLink:!0,toHref(){return`mailto:`+this.toString()}}),w_=S_(`text`),T_=S_(`nl`),E_=S_(`url`,{isLink:!0,toHref(e=v_.defaultProtocol){return this.hasProtocol()?this.v:`${e}://${this.v}`},hasProtocol(){let e=this.tk;return e.length>=2&&e[0].t!==rg&&e[1].t===Pg}}),D_=e=>new Zh(e);function O_({groups:e}){let t=e.domain.concat([Dg,kg,Ag,jg,Mg,Ng,Ig,Rg,Bg,cg,Vg,Hg,Ug,Wg,Yg,$g,Xg,Zg]),n=[Og,Pg,Fg,Lg,zg,Vg,Gg,Kg,Jg,_g,vg,dg,fg,mg,pg,hg,gg,yg,bg,xg,Sg,Cg,wg,Tg,Eg],r=[Dg,Og,kg,jg,Mg,Ng,Ig,Rg,Bg,dg,fg,Vg,Hg,Ug,Wg,Gg,Yg,$g,Xg,Zg],i=D_(),a=X(i,Xg);J(a,r,a),J(a,e.domain,a);let o=D_(),s=D_(),c=D_();J(i,e.domain,o),J(i,e.scheme,s),J(i,e.slashscheme,c),J(o,r,a),J(o,e.domain,o);let l=X(o,Ag);X(a,Ag,l),X(s,Ag,l),X(c,Ag,l);let u=X(a,Lg);J(u,r,a),J(u,e.domain,a);let d=D_();J(l,e.domain,d),J(d,e.domain,d);let f=X(d,Lg);J(f,e.domain,d);let p=D_(C_);J(f,e.tld,p),J(f,e.utld,p),X(l,rg,p);let m=X(d,Bg);X(m,Bg,m),J(m,e.domain,d),J(p,e.domain,d),X(p,Lg,f),X(p,Bg,m);let h=X(o,Bg),g=X(o,Lg);X(h,Bg,h),J(h,e.domain,o),J(g,r,a),J(g,e.domain,o);let _=D_(E_);J(g,e.tld,_),J(g,e.utld,_),J(_,e.domain,o),J(_,r,a),X(_,Lg,g),X(_,Bg,h),X(_,Ag,l);let v=X(_,Pg),y=D_(E_);J(v,e.numeric,y);let b=D_(E_),x=D_();J(b,t,b),J(b,n,x),J(x,t,b),J(x,n,x),X(_,Yg,b),X(y,Yg,b),X(_,Gg,x),X(_,Wg,b),X(y,Gg,x),X(y,Wg,b);let S=X(s,Pg),C=X(X(X(c,Pg),Yg),Yg);J(s,e.domain,o),X(s,Lg,g),X(s,Bg,h),J(c,e.domain,o),X(c,Lg,g),X(c,Bg,h),J(S,e.domain,b),X(S,Yg,b),X(S,Gg,b),J(C,e.domain,b),J(C,t,b),X(C,Yg,b);let w=[[dg,fg],[pg,mg],[hg,gg],[_g,vg],[yg,bg],[xg,Sg],[Cg,wg],[Tg,Eg]];for(let e=0;e=0&&p++,m.push(c),s[i]&&s[i].has(c))break;for(let e=0,t=i-m.length+1;e0&&(a.push(A_(w_,t,o)),o=[]),i-=p,d-=p;let e=f.t,r=n.slice(i-d,i);a.push(A_(e,t,r))}}return o.length>0&&a.push(A_(w_,t,o)),a}function A_(e,t,n){let r=n[0].s,i=n[n.length-1].e;return new e(t.slice(r,i),n)}var j_=typeof console<`u`&&console&&console.warn||(()=>{}),M_=`until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.`,Z={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function N_(){return Zh.groups={},Z.scanner=null,Z.parser=null,Z.tokenQueue=[],Z.pluginQueue=[],Z.customSchemes=[],Z.initialized=!1,Z}function P_(e,t=!1){if(Z.initialized&&j_(`linkifyjs: already initialized - will not register custom scheme "${e}" ${M_}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(e))throw Error(`linkifyjs: incorrect scheme format. 1. Must only contain digits, lowercase ASCII letters or "-" 2. Cannot start or end with "-" -3. "-" cannot repeat`);Z.customSchemes.push([e,t])}function F_(){Z.scanner=p_(Z.customSchemes);for(let e=0;ee.mark.type===n);if(!o.length)return;let{nodeAfter:s}=r;if(s&&o.some(e=>e.mark.isInSet(s.marks)))return;let c=e.storedMarks;e.removeMark(a,t.to,n),e.setStoredMarks(c),e.selection.empty&&e.selection.from===t.to&&e.removeStoredMark(n)}function W_(e){return e.length===1?e[0].isLink:e.length===3&&e[1].isLink?[`()`,`[]`].includes(e[0].value+e[2].value):!1}function G_(e){return new V({key:new H(`autolink`),appendTransaction:(t,n,r)=>{let i=t.some(e=>e.docChanged)&&!n.doc.eq(r.doc),a=t.some(e=>e.getMeta(`preventAutolink`));if(!i||a)return;let{tr:o}=r,s=Qu(n.doc,[...t]);if(!t.some(jl)){let t=[];s.steps.forEach((e,n)=>{if(!(e instanceof dn)||!e.slice.size)return;let r=s.mapping.slice(n+1),i=r.map(e.from,1),a=r.map(e.from+e.slice.size,-1);it.to-e.to),t.forEach(t=>U_(o,t,e.type))}if(Pd(s).forEach(({newRange:t})=>{let n=$u(r.doc,t,e=>e.isTextblock),i,a;if(n.length>1)i=n[0],a=r.doc.textBetween(i.pos,i.pos+i.node.nodeSize,void 0,` `);else if(n.length){let e=r.doc.textBetween(t.from,t.to,` `,` `);if(!B_.test(e))return;i=n[0],a=r.doc.textBetween(i.pos,t.to,void 0,` `)}if(i&&a){let t=a.split(z_).filter(Boolean);if(t.length<=0)return!1;let n=t[t.length-1],s=i.pos+a.lastIndexOf(n);if(!n)return!1;let c=I_(n).map(t=>t.toObject(e.defaultProtocol));if(!W_(c))return!1;c.filter(e=>e.isLink).map(e=>({...e,from:s+e.start+1,to:s+e.end+1})).filter(e=>!r.schema.marks.code||!r.doc.rangeHasMark(e.from,e.to,r.schema.marks.code)).filter(t=>e.validate(t.value)).filter(t=>e.shouldAutoLink(t.value)).forEach(t=>{Fd(t.from,t.to,r.doc).some(t=>t.mark.type===e.type)||o.addMark(t.from,t.to,e.type.create({href:t.href}))})}}),o.steps.length)return o}})}function K_(e){return new V({key:new H(`handleClickLink`),props:{handleClick:(t,n,r)=>{if(r.button!==0||!t.editable)return!1;let i=null;if(r.target instanceof HTMLAnchorElement)i=r.target;else{let t=r.target;if(!t)return!1;let n=e.editor.view.dom;i=t.closest(`a`),i&&!n.contains(i)&&(i=null)}if(!i)return!1;let a=!1;if(e.enableClickSelection&&(a=e.editor.commands.extendMarkRange(e.type.name)),e.openOnClick){let n=jd(t.state,e.type.name),r=i.href??n.href,o=i.target??n.target;r&&(window.open(r,o),a=!0)}return a}}})}var q_=/\[([^[\]]+)\]\(((?:[^\s()]|\([^\s()]*\))+)(?:\s+(?:(["'])(.*?)\3|“(.*?)”|‘(.*?)’))?\)$/,J_=/\[([^[\]]+)\]\(((?:[^\s()]|\([^\s()]*\))+)(?:\s+(?:(["'])(.*?)\3|“(.*?)”|‘(.*?)’))?\)/g;function Y_(e,t){let n=0;for(let r=t-1;r>=0&&e[r]===`\\`;--r)n+=1;return n%2==1}function X_(e,t){let n=0,r=0;for(;r0}function Z_(e,t,n){let[,r,i]=t;return(t.index?e[t.index-1]:void 0)===`!`||Y_(e,t.index??0)||X_(e,t.index??0)?!1:!!r.trim()&&n(i)}function Q_(e){let[t,n,r,,i,a,o]=e,s=i??a??o;return{index:e.index??0,text:t,replaceWith:n,data:{href:r,title:s||null,markdown:!0}}}function $_(e,t){return e.index{let n=q_.exec(t);return!n||!Z_(t,n,e.isAllowedHref)?null:Q_(n)},type:e.type,getAttributes:ev});return new wp({find:t.find,handler:e=>{let n=t.handler(e);return n!==null&&e.state.tr.steps.length&&e.state.tr.setMeta(`preventAutolink`,!0),n}})}function nv(e){let t=um({find:t=>{let n=[];for(let r of t.matchAll(J_))Z_(t,r,e.isAllowedHref)&&n.push(Q_(r));let r=(e.findPlainUrls?.call(e,t)??[]).filter(e=>!n.some(t=>$_(t,e)));return[...n,...r]},type:e.type,getAttributes:ev});return new Np({find:t.find,handler:e=>{let n=t.handler(e);return n!==null&&e.state.tr.steps.length&&e.match.data?.markdown&&e.state.tr.setMeta(`preventAutolink`,!0),n}})}function rv(e){return new V({key:new H(`handlePasteLink`),props:{handlePaste:(t,n,r)=>{let{shouldAutoLink:i}=e,{state:a}=t,{selection:o}=a,{empty:s}=o;if(s)return!1;let c=``;r.content.forEach(e=>{c+=e.textContent});let l=L_(c,{defaultProtocol:e.defaultProtocol}).find(e=>e.isLink&&e.value===c);return!c||!l||i!==void 0&&!i(l.value)?!1:e.editor.commands.setMark(e.type,{href:l.href})}}})}function iv(e,t){let n=[`http`,`https`,`ftp`,`ftps`,`mailto`,`tel`,`callto`,`sms`,`cid`,`xmpp`];return t&&t.forEach(e=>{let t=typeof e==`string`?e:e.scheme;t&&n.push(t)}),!e||e.replace(H_,``).match(RegExp(`^(?:(?:${n.map(e=>e.replace(/[-/\\^$*+?.()|[\]{}]/g,`\\$&`)).join(`|`)}):|[^a-z]|[a-z0-9+.\\-]+(?:[^a-z+.\\-:]|$))`,`i`))}var av=Mp.create({name:`link`,priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate,console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(e=>{typeof e==`string`?P_(e):P_(e.scheme,e.optionalSlashes)})},onDestroy(){N_()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,enableClickSelection:!1,linkOnPaste:!0,markdownLinks:!1,autolink:!0,protocols:[],defaultProtocol:`http`,HTMLAttributes:{target:`_blank`,rel:`noopener noreferrer nofollow`,class:null},isAllowedUri:(e,t)=>!!iv(e,t.protocols),validate:e=>!!e,shouldAutoLink:e=>{let t=/^[a-z][a-z0-9+.-]*:\/\//i.test(e),n=/^[a-z][a-z0-9+.-]*:/i.test(e);if(t||n&&!e.includes(`@`))return!0;let r=(e.includes(`@`)?e.split(`@`).pop():e).split(/[/?#:]/)[0];return!(/^\d{1,3}(\.\d{1,3}){3}$/.test(r)||!/\./.test(r))}}},addAttributes(){return{href:{default:null,parseHTML(e){return e.getAttribute(`href`)}},target:{default:this.options.HTMLAttributes.target??null},rel:{default:this.options.HTMLAttributes.rel??null},class:{default:this.options.HTMLAttributes.class??null},title:{default:null}}},parseHTML(){return[{tag:`a[href]`,getAttrs:e=>{let t=e.getAttribute(`href`);return!t||!this.options.isAllowedUri(t,{defaultValidate:e=>!!iv(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:e}){return this.options.isAllowedUri(e.href,{defaultValidate:e=>!!iv(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?[`a`,q(this.options.HTMLAttributes,e),0]:[`a`,q(this.options.HTMLAttributes,{...e,href:``}),0]},markdownTokenName:`link`,parseMarkdown:(e,t)=>t.applyMark(`link`,t.parseInline(e.tokens||[]),{href:e.href,title:e.title||null}),renderMarkdown:(e,t)=>{let n=e.attrs?.href??``,r=e.attrs?.title??``,i=t.renderChildren(e);return r?`[${i}](${n} "${r}")`:`[${i}](${n})`},addCommands(){return{setLink:e=>({chain:t})=>{let{href:n}=e;return this.options.isAllowedUri(n,{defaultValidate:e=>!!iv(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?t().setMark(this.name,e).setMeta(`preventAutolink`,!0).run():!1},toggleLink:e=>({chain:t})=>{let{href:n}=e||{};return n&&!this.options.isAllowedUri(n,{defaultValidate:e=>!!iv(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:t().toggleMark(this.name,e,{extendEmptyMarkRange:!0}).setMeta(`preventAutolink`,!0).run()},unsetLink:()=>({chain:e})=>e().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta(`preventAutolink`,!0).run()}},addInputRules(){return this.options.markdownLinks?[tv({type:this.type,isAllowedHref:e=>this.options.isAllowedUri(e,{defaultValidate:e=>!!iv(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})})]:[]},addPasteRules(){let e=e=>{let t=[];if(e){let{protocols:n,defaultProtocol:r}=this.options;L_(e,{defaultProtocol:r}).filter(e=>e.isLink&&this.options.isAllowedUri(e.value,{defaultValidate:e=>!!iv(e,n),protocols:n,defaultProtocol:r})).forEach(e=>{this.options.shouldAutoLink(e.value)&&t.push({text:e.value,data:{href:e.href},index:e.start})})}return t};return this.options.markdownLinks?[nv({type:this.type,isAllowedHref:e=>this.options.isAllowedUri(e,{defaultValidate:e=>!!iv(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol}),findPlainUrls:e})]:[um({find:e,type:this.type,getAttributes:e=>({href:e.data?.href})})]},addProseMirrorPlugins(){let e=[],{protocols:t,defaultProtocol:n}=this.options;return this.options.autolink&&e.push(G_({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:e=>this.options.isAllowedUri(e,{defaultValidate:e=>!!iv(e,t),protocols:t,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),e.push(K_({type:this.type,editor:this.editor,openOnClick:this.options.openOnClick===`whenNotEditable`||this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&e.push(rv({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),e}}),ov=av,sv=`listItem`,cv=`textStyle`,lv=/^\s*([-+*])\s$/,uv=lm.create({name:`bulletList`,addOptions(){return{itemTypeName:`listItem`,HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:`block list`,content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul`}]},renderHTML({HTMLAttributes:e}){return[`ul`,q(this.options.HTMLAttributes,e),0]},markdownTokenName:`list`,parseMarkdown:(e,t)=>e.type!==`list`||e.ordered?[]:{type:`bulletList`,content:e.items?t.parseChildren(e.items):[]},renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,` -`):``,markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:e,chain:t})=>this.options.keepAttributes?t().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(sv,this.editor.getAttributes(cv)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let e=om({find:lv,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(e=om({find:lv,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(cv),editor:this.editor})),[e]}}),dv=(e,t,n)=>{let{selection:r}=e;if(!r.empty)return null;let{$from:i}=r;if(!i.parent.isTextblock||i.parentOffset!==i.parent.content.size)return null;let a=-1;for(let e=i.depth;e>0;--e)if(i.node(e).type.name===t){a=e;break}if(a<0)return null;let o=i.node(a),s=i.index(a);if(s+1>=o.childCount)return null;let c=o.child(s+1);if(!n.includes(c.type.name))return null;let l=e.schema.nodes[t],u=!1;if(c.forEach(e=>{e.type===l&&e.childCount>1&&(u=!0)}),!u)return null;let d=e.doc.resolve(i.after()).nodeAfter;if(!d||!n.includes(d.type.name))return null;let f=[];return d.forEach(e=>{f.push(e)}),f.length===0?null:{listItemDepth:a,nestedList:d,nestedListPos:i.after(),insertPos:i.after(a),items:f}},fv=(e,t,n,r)=>{let i=dv(e,n,r);if(!i)return!1;let{selection:a}=e,{nestedList:o,nestedListPos:s,insertPos:c,items:l}=i,u=e.tr;u.delete(s,s+o.nodeSize);let d=u.mapping.map(c);return u.insert(d,F.from(l)),u.setSelection(a.map(u.doc,u.mapping)),t&&t(u),!0},pv=(e,t,n)=>fv(e.state,e.view.dispatch,t,n),mv=(e,t)=>J.create({name:`${e}BranchingDeleteKeymap`,priority:101,addKeyboardShortcuts(){let n=()=>pv(this.editor,e,t);return{Delete:n,"Mod-Delete":n}}}),hv=[[1e3,`m`],[900,`cm`],[500,`d`],[400,`cd`],[100,`c`],[90,`xc`],[50,`l`],[40,`xl`],[10,`x`],[9,`ix`],[5,`v`],[4,`iv`],[1,`i`]],gv=`abcdefghijklmnopqrstuvwxyz`,_v=String.raw`\d+|[ivxlcdmIVXLCDM]+|${`[a-zA-Z]{1,2}`}`;function vv(e){let t=e,n=``;for(let[e,r]of hv)for(;t>=e;)n+=r,t-=e;return n}function yv(e){return vv(e).toUpperCase()}function bv(e){let t=e.toLowerCase(),n=0,r=0;for(;n0?t:1}let n=parseInt(e,10);return Number.isNaN(n)?1:n}function Ev(e,t){if(e===`numeric`)return String(t);switch(e){case`a`:return Cv(t);case`A`:return Cv(t).toUpperCase();case`i`:return vv(t);case`I`:return yv(t);default:return String(t)}}function Dv(e){if(e.length===0)return!1;let t=wv(e[0])??`numeric`,n=Tv(e[0]);if(n<1)return!1;for(let r=0;r(e?.level??Pv)>Pv;function Iv(e){let t=e.tokens?.[0];return!!(e.text&&e.tokens?.length===1&&t?.type===`list`&&t.ordered&&t.raw===e.text)}function Lv(e,t){return t.tokenizeInline?t.parseInline(t.tokenizeInline(e)):t.parseInline([{type:`text`,raw:e,text:e}])}var Rv=lm.create({name:`listItem`,addOptions(){return{HTMLAttributes:{},bulletListTypeName:`bulletList`,orderedListTypeName:`orderedList`}},content:`paragraph block*`,defining:!0,parseHTML(){return[{tag:`li`}]},renderHTML({HTMLAttributes:e}){return[`li`,q(this.options.HTMLAttributes,e),0]},markdownTokenName:`list_item`,parseMarkdown:(e,t)=>{if(e.type!==`list_item`)return[];let n=t.parseBlockChildren??t.parseChildren,r=[];if(e.tokens&&e.tokens.length>0){if(Iv(e))return{type:`listItem`,content:[{type:`paragraph`,content:Lv(e.text||``,t)}]};let[i,...a]=e.tokens;if(i.type===`heading`)return{type:`listItem`,content:[{type:`paragraph`,content:t.parseInline(i.tokens??[])},...a.length>0?n(a):[]]};if(e.tokens.some(e=>e.type===`paragraph`))r=n(e.tokens);else if(i.type===`text`&&i.tokens&&i.tokens.length>0){if(r=[{type:`paragraph`,content:t.parseInline(i.tokens)}],e.tokens.length>1){let t=n(e.tokens.slice(1));r.push(...t)}}else r=n(e.tokens)}return r.length===0&&(r=[{type:`paragraph`,content:[]}]),{type:`listItem`,content:jv(r)}},renderMarkdown:(e,t,n)=>{let r=e=>{if(e.parentType===`bulletList`)return`- `;if(e.parentType===`orderedList`){var t,n;let r=((t=e.meta)==null||(t=t.parentAttrs)==null?void 0:t.start)||1;return Av((n=e.meta)==null||(n=n.parentAttrs)==null?void 0:n.type,r-1+(e.index||0),`. `)}return`- `},i=xp(e,t,r,n,{alignNestedToPrefix:n?.parentType===`orderedList`});if(!Mv(e)||!Fv(n))return i;let a=r(n);return`${a}${Nv}${i.slice(a.length)}`},addExtensions(){return[mv(this.name,[this.options.bulletListTypeName,this.options.orderedListTypeName])]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),zv=(e,t)=>{let{$from:n}=t.selection,r=Vl(e,t.schema),i=null,a=n.depth,o=n.pos,s=null;for(;a>0&&s===null;)i=n.node(a),i.type===r?s=a:(--a,--o);return s===null?null:{$pos:t.doc.resolve(o),depth:s}},Bv=(e,t)=>{let n=zv(e,t);if(!n)return!1;let[,r]=Id(t,e,n.$pos.pos+4);return r},Vv=(e,t,n)=>{let{$anchor:r}=e.selection,i=Math.max(0,r.pos-2),a=e.doc.resolve(i).node();return!(!a||!n.includes(a.type.name))},Hv=(e,t,n)=>{if(e.commands.undoInputRule())return!0;if(e.state.selection.from!==e.state.selection.to)return!1;if(!Pu(e.state,t)&&Vv(e.state,t,n)){let{$anchor:n}=e.state.selection,r=e.state.doc.resolve(n.before()-1),i=[];r.node().descendants((e,n)=>{e.type.name===t&&i.push({node:e,pos:n})});let a=i.at(-1);if(!a)return!1;let o=e.state.doc.resolve(r.start()+a.pos+1);return e.chain().command(({tr:e})=>{let t=o.end();return e.delete(n.before(),n.after()).insert(t,n.parent),e.setSelection(z.create(e.doc,t+1)),!0}).command(({state:e,dispatch:t})=>(Ar(e,t),!0)).run()}if(!Pu(e.state,t)||!Wd(e.state))return!1;let{$from:r}=e.state.selection,i=r.depth-1;return r.node(i).type!==e.schema.nodes[t]||r.index(i)!==0?!1:e.chain().liftListItem(t).run()},Uv=(e,t)=>{let n=Bv(e,t),r=zv(e,t);return!r||!n?!1:n>r.depth},Wv=(e,t)=>{let n=Bv(e,t),r=zv(e,t);return!r||!n?!1:n!Pu(e.state,t)||!Ud(e.state,t)||!e.state.selection.empty?!1:Uv(t,e.state)?e.chain().focus(e.state.selection.from+4).lift(t).joinBackward().run():Wv(t,e.state)?e.commands.command(({state:e,dispatch:t})=>jr(e,t)):e.commands.joinItemForward(),Kv=(e,t,n)=>{let{state:r}=e,{selection:i}=r;if(!i.empty)return!1;let{$from:a}=i;if(a.parentOffset!==0||!a.parent.isTextblock||Pu(r,t))return!1;let o=Ld(a);if(!o||!n.includes(o.type.name))return!1;let s=o.lastChild;if(!s||s.type.name!==t)return!1;let c=a.parent;if(!s.canReplace(s.childCount,s.childCount,F.from(c)))return!1;let l=a.before(),u=a.after(),d=l-2;return e.commands.command(({tr:e,dispatch:t})=>(t&&(e.delete(l,u).insert(d,F.from(c)),e.setSelection(z.create(e.doc,d+1)),e.scrollIntoView()),!0))},qv=J.create({name:`listKeymap`,addOptions(){return{listTypes:[{itemName:`listItem`,wrapperNames:[`bulletList`,`orderedList`]},{itemName:`taskItem`,wrapperNames:[`taskList`]}]}},addKeyboardShortcuts(){return{Delete:({editor:e})=>{let t=!1;return this.options.listTypes.forEach(({itemName:n})=>{e.state.schema.nodes[n]!==void 0&&Gv(e,n)&&(t=!0)}),t},"Mod-Delete":({editor:e})=>{let t=!1;return this.options.listTypes.forEach(({itemName:n})=>{e.state.schema.nodes[n]!==void 0&&Gv(e,n)&&(t=!0)}),t},Backspace:({editor:e})=>{let t=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{e.state.schema.nodes[n]!==void 0&&Hv(e,n,r)&&(t=!0)}),t},"Mod-Backspace":({editor:e})=>{let t=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{e.state.schema.nodes[n]!==void 0&&Hv(e,n,r)&&(t=!0)}),t},Tab:({editor:e})=>{for(let{itemName:t,wrapperNames:n}of this.options.listTypes)if(e.state.schema.nodes[t]!==void 0&&Kv(e,t,n))return!0;return!1}}}}),Jv=RegExp(`^(\\s*)(${_v})([.)])\\s+(.*)$`),Yv=/^\s/,Xv={heading:/^#{1,6}(?:\s|$)/,bulletItem:/^[-+*]\s+/,codeFence:/^(?:```|~~~)/,blockMath:/^\$\$/,thematicBreak:/^(?:(?:-[ \t]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})$/};function Zv(e){return Jv.test(e.trimStart())}function Qv(e){let t=e.trimStart();return Xv.bulletItem.test(t)||Zv(t)||Xv.heading.test(t)||Xv.thematicBreak.test(t)&&!t.startsWith(`-`)||/^>\s?/.test(t)||Xv.codeFence.test(t)||Xv.blockMath.test(t)}function $v(e){return Object.values(Xv).some(t=>t.test(e))}function ey(e){let t=[],n=[],r=!1;return e.forEach(e=>{r?n.push(e):e.trim()===``||t.length>0&&Qv(e)?(r=!0,n.push(e)):t.push(e)}),{paragraphLines:t,blockLines:n}}function ty(e){let t=[],n=0,r=0;for(;ne.mark.type===n);if(!o.length)return;let{nodeAfter:s}=r;if(s&&o.some(e=>e.mark.isInSet(s.marks)))return;let c=e.storedMarks;e.removeMark(a,t.to,n),e.setStoredMarks(c),e.selection.empty&&e.selection.from===t.to&&e.removeStoredMark(n)}function W_(e){return e.length===1?e[0].isLink:e.length===3&&e[1].isLink?[`()`,`[]`].includes(e[0].value+e[2].value):!1}function G_(e){return new B({key:new V(`autolink`),appendTransaction:(t,n,r)=>{let i=t.some(e=>e.docChanged)&&!n.doc.eq(r.doc),a=t.some(e=>e.getMeta(`preventAutolink`));if(!i||a)return;let{tr:o}=r,s=$u(n.doc,[...t]);if(!t.some(Ml)){let t=[];s.steps.forEach((e,n)=>{if(!(e instanceof fn)||!e.slice.size)return;let r=s.mapping.slice(n+1),i=r.map(e.from,1),a=r.map(e.from+e.slice.size,-1);it.to-e.to),t.forEach(t=>U_(o,t,e.type))}if(Fd(s).forEach(({newRange:t})=>{let n=ed(r.doc,t,e=>e.isTextblock),i,a;if(n.length>1)i=n[0],a=r.doc.textBetween(i.pos,i.pos+i.node.nodeSize,void 0,` `);else if(n.length){let e=r.doc.textBetween(t.from,t.to,` `,` `);if(!B_.test(e))return;i=n[0],a=r.doc.textBetween(i.pos,t.to,void 0,` `)}if(i&&a){let t=a.split(z_).filter(Boolean);if(t.length<=0)return!1;let n=t[t.length-1],s=i.pos+a.lastIndexOf(n);if(!n)return!1;let c=I_(n).map(t=>t.toObject(e.defaultProtocol));if(!W_(c))return!1;c.filter(e=>e.isLink).map(e=>({...e,from:s+e.start+1,to:s+e.end+1})).filter(e=>!r.schema.marks.code||!r.doc.rangeHasMark(e.from,e.to,r.schema.marks.code)).filter(t=>e.validate(t.value)).filter(t=>e.shouldAutoLink(t.value)).forEach(t=>{Id(t.from,t.to,r.doc).some(t=>t.mark.type===e.type)||o.addMark(t.from,t.to,e.type.create({href:t.href}))})}}),o.steps.length)return o}})}function K_(e){return new B({key:new V(`handleClickLink`),props:{handleClick:(t,n,r)=>{if(r.button!==0||!t.editable)return!1;let i=null;if(r.target instanceof HTMLAnchorElement)i=r.target;else{let t=r.target;if(!t)return!1;let n=e.editor.view.dom;i=t.closest(`a`),i&&!n.contains(i)&&(i=null)}if(!i)return!1;let a=!1;if(e.enableClickSelection&&(a=e.editor.commands.extendMarkRange(e.type.name)),e.openOnClick){let n=Md(t.state,e.type.name),r=i.href??n.href,o=i.target??n.target;r&&(window.open(r,o),a=!0)}return a}}})}var q_=/\[([^[\]]+)\]\(((?:[^\s()]|\([^\s()]*\))+)(?:\s+(?:(["'])(.*?)\3|“(.*?)”|‘(.*?)’))?\)$/,J_=/\[([^[\]]+)\]\(((?:[^\s()]|\([^\s()]*\))+)(?:\s+(?:(["'])(.*?)\3|“(.*?)”|‘(.*?)’))?\)/g;function Y_(e,t){let n=0;for(let r=t-1;r>=0&&e[r]===`\\`;--r)n+=1;return n%2==1}function X_(e,t){let n=0,r=0;for(;r0}function Z_(e,t,n){let[,r,i]=t;return(t.index?e[t.index-1]:void 0)===`!`||Y_(e,t.index??0)||X_(e,t.index??0)?!1:!!r.trim()&&n(i)}function Q_(e){let[t,n,r,,i,a,o]=e,s=i??a??o;return{index:e.index??0,text:t,replaceWith:n,data:{href:r,title:s||null,markdown:!0}}}function $_(e,t){return e.index{let n=q_.exec(t);return!n||!Z_(t,n,e.isAllowedHref)?null:Q_(n)},type:e.type,getAttributes:ev});return new Tp({find:t.find,handler:e=>{let n=t.handler(e);return n!==null&&e.state.tr.steps.length&&e.state.tr.setMeta(`preventAutolink`,!0),n}})}function nv(e){let t=dm({find:t=>{let n=[];for(let r of t.matchAll(J_))Z_(t,r,e.isAllowedHref)&&n.push(Q_(r));let r=(e.findPlainUrls?.call(e,t)??[]).filter(e=>!n.some(t=>$_(t,e)));return[...n,...r]},type:e.type,getAttributes:ev});return new Pp({find:t.find,handler:e=>{let n=t.handler(e);return n!==null&&e.state.tr.steps.length&&e.match.data?.markdown&&e.state.tr.setMeta(`preventAutolink`,!0),n}})}function rv(e){return new B({key:new V(`handlePasteLink`),props:{handlePaste:(t,n,r)=>{let{shouldAutoLink:i}=e,{state:a}=t,{selection:o}=a,{empty:s}=o;if(s)return!1;let c=``;r.content.forEach(e=>{c+=e.textContent});let l=L_(c,{defaultProtocol:e.defaultProtocol}).find(e=>e.isLink&&e.value===c);return!c||!l||i!==void 0&&!i(l.value)?!1:e.editor.commands.setMark(e.type,{href:l.href})}}})}function iv(e,t){let n=[`http`,`https`,`ftp`,`ftps`,`mailto`,`tel`,`callto`,`sms`,`cid`,`xmpp`];return t&&t.forEach(e=>{let t=typeof e==`string`?e:e.scheme;t&&n.push(t)}),!e||e.replace(H_,``).match(RegExp(`^(?:(?:${n.map(e=>e.replace(/[-/\\^$*+?.()|[\]{}]/g,`\\$&`)).join(`|`)}):|[^a-z]|[a-z0-9+.\\-]+(?:[^a-z+.\\-:]|$))`,`i`))}var av=Np.create({name:`link`,priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate,console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(e=>{typeof e==`string`?P_(e):P_(e.scheme,e.optionalSlashes)})},onDestroy(){N_()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,enableClickSelection:!1,linkOnPaste:!0,markdownLinks:!1,autolink:!0,protocols:[],defaultProtocol:`http`,HTMLAttributes:{target:`_blank`,rel:`noopener noreferrer nofollow`,class:null},isAllowedUri:(e,t)=>!!iv(e,t.protocols),validate:e=>!!e,shouldAutoLink:e=>{let t=/^[a-z][a-z0-9+.-]*:\/\//i.test(e),n=/^[a-z][a-z0-9+.-]*:/i.test(e);if(t||n&&!e.includes(`@`))return!0;let r=(e.includes(`@`)?e.split(`@`).pop():e).split(/[/?#:]/)[0];return!(/^\d{1,3}(\.\d{1,3}){3}$/.test(r)||!/\./.test(r))}}},addAttributes(){return{href:{default:null,parseHTML(e){return e.getAttribute(`href`)}},target:{default:this.options.HTMLAttributes.target??null},rel:{default:this.options.HTMLAttributes.rel??null},class:{default:this.options.HTMLAttributes.class??null},title:{default:null}}},parseHTML(){return[{tag:`a[href]`,getAttrs:e=>{let t=e.getAttribute(`href`);return!t||!this.options.isAllowedUri(t,{defaultValidate:e=>!!iv(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:e}){return this.options.isAllowedUri(e.href,{defaultValidate:e=>!!iv(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?[`a`,K(this.options.HTMLAttributes,e),0]:[`a`,K(this.options.HTMLAttributes,{...e,href:``}),0]},markdownTokenName:`link`,parseMarkdown:(e,t)=>t.applyMark(`link`,t.parseInline(e.tokens||[]),{href:e.href,title:e.title||null}),renderMarkdown:(e,t)=>{let n=e.attrs?.href??``,r=e.attrs?.title??``,i=t.renderChildren(e);return r?`[${i}](${n} "${r}")`:`[${i}](${n})`},addCommands(){return{setLink:e=>({chain:t})=>{let{href:n}=e;return this.options.isAllowedUri(n,{defaultValidate:e=>!!iv(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?t().setMark(this.name,e).setMeta(`preventAutolink`,!0).run():!1},toggleLink:e=>({chain:t})=>{let{href:n}=e||{};return n&&!this.options.isAllowedUri(n,{defaultValidate:e=>!!iv(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:t().toggleMark(this.name,e,{extendEmptyMarkRange:!0}).setMeta(`preventAutolink`,!0).run()},unsetLink:()=>({chain:e})=>e().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta(`preventAutolink`,!0).run()}},addInputRules(){return this.options.markdownLinks?[tv({type:this.type,isAllowedHref:e=>this.options.isAllowedUri(e,{defaultValidate:e=>!!iv(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})})]:[]},addPasteRules(){let e=e=>{let t=[];if(e){let{protocols:n,defaultProtocol:r}=this.options;L_(e,{defaultProtocol:r}).filter(e=>e.isLink&&this.options.isAllowedUri(e.value,{defaultValidate:e=>!!iv(e,n),protocols:n,defaultProtocol:r})).forEach(e=>{this.options.shouldAutoLink(e.value)&&t.push({text:e.value,data:{href:e.href},index:e.start})})}return t};return this.options.markdownLinks?[nv({type:this.type,isAllowedHref:e=>this.options.isAllowedUri(e,{defaultValidate:e=>!!iv(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol}),findPlainUrls:e})]:[dm({find:e,type:this.type,getAttributes:e=>({href:e.data?.href})})]},addProseMirrorPlugins(){let e=[],{protocols:t,defaultProtocol:n}=this.options;return this.options.autolink&&e.push(G_({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:e=>this.options.isAllowedUri(e,{defaultValidate:e=>!!iv(e,t),protocols:t,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),e.push(K_({type:this.type,editor:this.editor,openOnClick:this.options.openOnClick===`whenNotEditable`||this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&e.push(rv({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),e}}),ov=av,sv=`listItem`,cv=`textStyle`,lv=/^\s*([-+*])\s$/,uv=um.create({name:`bulletList`,addOptions(){return{itemTypeName:`listItem`,HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:`block list`,content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul`}]},renderHTML({HTMLAttributes:e}){return[`ul`,K(this.options.HTMLAttributes,e),0]},markdownTokenName:`list`,parseMarkdown:(e,t)=>e.type!==`list`||e.ordered?[]:{type:`bulletList`,content:e.items?t.parseChildren(e.items):[]},renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,` +`):``,markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:e,chain:t})=>this.options.keepAttributes?t().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(sv,this.editor.getAttributes(cv)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let e=sm({find:lv,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(e=sm({find:lv,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(cv),editor:this.editor})),[e]}}),dv=(e,t,n)=>{let{selection:r}=e;if(!r.empty)return null;let{$from:i}=r;if(!i.parent.isTextblock||i.parentOffset!==i.parent.content.size)return null;let a=-1;for(let e=i.depth;e>0;--e)if(i.node(e).type.name===t){a=e;break}if(a<0)return null;let o=i.node(a),s=i.index(a);if(s+1>=o.childCount)return null;let c=o.child(s+1);if(!n.includes(c.type.name))return null;let l=e.schema.nodes[t],u=!1;if(c.forEach(e=>{e.type===l&&e.childCount>1&&(u=!0)}),!u)return null;let d=e.doc.resolve(i.after()).nodeAfter;if(!d||!n.includes(d.type.name))return null;let f=[];return d.forEach(e=>{f.push(e)}),f.length===0?null:{listItemDepth:a,nestedList:d,nestedListPos:i.after(),insertPos:i.after(a),items:f}},fv=(e,t,n,r)=>{let i=dv(e,n,r);if(!i)return!1;let{selection:a}=e,{nestedList:o,nestedListPos:s,insertPos:c,items:l}=i,u=e.tr;u.delete(s,s+o.nodeSize);let d=u.mapping.map(c);return u.insert(d,P.from(l)),u.setSelection(a.map(u.doc,u.mapping)),t&&t(u),!0},pv=(e,t,n)=>fv(e.state,e.view.dispatch,t,n),mv=(e,t)=>q.create({name:`${e}BranchingDeleteKeymap`,priority:101,addKeyboardShortcuts(){let n=()=>pv(this.editor,e,t);return{Delete:n,"Mod-Delete":n}}}),hv=[[1e3,`m`],[900,`cm`],[500,`d`],[400,`cd`],[100,`c`],[90,`xc`],[50,`l`],[40,`xl`],[10,`x`],[9,`ix`],[5,`v`],[4,`iv`],[1,`i`]],gv=`abcdefghijklmnopqrstuvwxyz`,_v=String.raw`\d+|[ivxlcdmIVXLCDM]+|${`[a-zA-Z]{1,2}`}`;function vv(e){let t=e,n=``;for(let[e,r]of hv)for(;t>=e;)n+=r,t-=e;return n}function yv(e){return vv(e).toUpperCase()}function bv(e){let t=e.toLowerCase(),n=0,r=0;for(;n0?t:1}let n=parseInt(e,10);return Number.isNaN(n)?1:n}function Ev(e,t){if(e===`numeric`)return String(t);switch(e){case`a`:return Cv(t);case`A`:return Cv(t).toUpperCase();case`i`:return vv(t);case`I`:return yv(t);default:return String(t)}}function Dv(e){if(e.length===0)return!1;let t=wv(e[0])??`numeric`,n=Tv(e[0]);if(n<1)return!1;for(let r=0;r(e?.level??Pv)>Pv;function Iv(e){let t=e.tokens?.[0];return!!(e.text&&e.tokens?.length===1&&t?.type===`list`&&t.ordered&&t.raw===e.text)}function Lv(e,t){return t.tokenizeInline?t.parseInline(t.tokenizeInline(e)):t.parseInline([{type:`text`,raw:e,text:e}])}var Rv=um.create({name:`listItem`,addOptions(){return{HTMLAttributes:{},bulletListTypeName:`bulletList`,orderedListTypeName:`orderedList`}},content:`paragraph block*`,defining:!0,parseHTML(){return[{tag:`li`}]},renderHTML({HTMLAttributes:e}){return[`li`,K(this.options.HTMLAttributes,e),0]},markdownTokenName:`list_item`,parseMarkdown:(e,t)=>{if(e.type!==`list_item`)return[];let n=t.parseBlockChildren??t.parseChildren,r=[];if(e.tokens&&e.tokens.length>0){if(Iv(e))return{type:`listItem`,content:[{type:`paragraph`,content:Lv(e.text||``,t)}]};let[i,...a]=e.tokens;if(i.type===`heading`)return{type:`listItem`,content:[{type:`paragraph`,content:t.parseInline(i.tokens??[])},...a.length>0?n(a):[]]};if(e.tokens.some(e=>e.type===`paragraph`))r=n(e.tokens);else if(i.type===`text`&&i.tokens&&i.tokens.length>0){if(r=[{type:`paragraph`,content:t.parseInline(i.tokens)}],e.tokens.length>1){let t=n(e.tokens.slice(1));r.push(...t)}}else r=n(e.tokens)}return r.length===0&&(r=[{type:`paragraph`,content:[]}]),{type:`listItem`,content:jv(r)}},renderMarkdown:(e,t,n)=>{let r=e=>{if(e.parentType===`bulletList`)return`- `;if(e.parentType===`orderedList`){var t,n;let r=((t=e.meta)==null||(t=t.parentAttrs)==null?void 0:t.start)||1;return Av((n=e.meta)==null||(n=n.parentAttrs)==null?void 0:n.type,r-1+(e.index||0),`. `)}return`- `},i=Sp(e,t,r,n,{alignNestedToPrefix:n?.parentType===`orderedList`});if(!Mv(e)||!Fv(n))return i;let a=r(n);return`${a}${Nv}${i.slice(a.length)}`},addExtensions(){return[mv(this.name,[this.options.bulletListTypeName,this.options.orderedListTypeName])]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),zv=(e,t)=>{let{$from:n}=t.selection,r=Hl(e,t.schema),i=null,a=n.depth,o=n.pos,s=null;for(;a>0&&s===null;)i=n.node(a),i.type===r?s=a:(--a,--o);return s===null?null:{$pos:t.doc.resolve(o),depth:s}},Bv=(e,t)=>{let n=zv(e,t);if(!n)return!1;let[,r]=Ld(t,e,n.$pos.pos+4);return r},Vv=(e,t,n)=>{let{$anchor:r}=e.selection,i=Math.max(0,r.pos-2),a=e.doc.resolve(i).node();return!(!a||!n.includes(a.type.name))},Hv=(e,t,n)=>{if(e.commands.undoInputRule())return!0;if(e.state.selection.from!==e.state.selection.to)return!1;if(!Fu(e.state,t)&&Vv(e.state,t,n)){let{$anchor:n}=e.state.selection,r=e.state.doc.resolve(n.before()-1),i=[];r.node().descendants((e,n)=>{e.type.name===t&&i.push({node:e,pos:n})});let a=i.at(-1);if(!a)return!1;let o=e.state.doc.resolve(r.start()+a.pos+1);return e.chain().command(({tr:e})=>{let t=o.end();return e.delete(n.before(),n.after()).insert(t,n.parent),e.setSelection(R.create(e.doc,t+1)),!0}).command(({state:e,dispatch:t})=>(jr(e,t),!0)).run()}if(!Fu(e.state,t)||!Gd(e.state))return!1;let{$from:r}=e.state.selection,i=r.depth-1;return r.node(i).type!==e.schema.nodes[t]||r.index(i)!==0?!1:e.chain().liftListItem(t).run()},Uv=(e,t)=>{let n=Bv(e,t),r=zv(e,t);return!r||!n?!1:n>r.depth},Wv=(e,t)=>{let n=Bv(e,t),r=zv(e,t);return!r||!n?!1:n!Fu(e.state,t)||!Wd(e.state,t)||!e.state.selection.empty?!1:Uv(t,e.state)?e.chain().focus(e.state.selection.from+4).lift(t).joinBackward().run():Wv(t,e.state)?e.commands.command(({state:e,dispatch:t})=>Mr(e,t)):e.commands.joinItemForward(),Kv=(e,t,n)=>{let{state:r}=e,{selection:i}=r;if(!i.empty)return!1;let{$from:a}=i;if(a.parentOffset!==0||!a.parent.isTextblock||Fu(r,t))return!1;let o=Rd(a);if(!o||!n.includes(o.type.name))return!1;let s=o.lastChild;if(!s||s.type.name!==t)return!1;let c=a.parent;if(!s.canReplace(s.childCount,s.childCount,P.from(c)))return!1;let l=a.before(),u=a.after(),d=l-2;return e.commands.command(({tr:e,dispatch:t})=>(t&&(e.delete(l,u).insert(d,P.from(c)),e.setSelection(R.create(e.doc,d+1)),e.scrollIntoView()),!0))},qv=q.create({name:`listKeymap`,addOptions(){return{listTypes:[{itemName:`listItem`,wrapperNames:[`bulletList`,`orderedList`]},{itemName:`taskItem`,wrapperNames:[`taskList`]}]}},addKeyboardShortcuts(){return{Delete:({editor:e})=>{let t=!1;return this.options.listTypes.forEach(({itemName:n})=>{e.state.schema.nodes[n]!==void 0&&Gv(e,n)&&(t=!0)}),t},"Mod-Delete":({editor:e})=>{let t=!1;return this.options.listTypes.forEach(({itemName:n})=>{e.state.schema.nodes[n]!==void 0&&Gv(e,n)&&(t=!0)}),t},Backspace:({editor:e})=>{let t=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{e.state.schema.nodes[n]!==void 0&&Hv(e,n,r)&&(t=!0)}),t},"Mod-Backspace":({editor:e})=>{let t=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{e.state.schema.nodes[n]!==void 0&&Hv(e,n,r)&&(t=!0)}),t},Tab:({editor:e})=>{for(let{itemName:t,wrapperNames:n}of this.options.listTypes)if(e.state.schema.nodes[t]!==void 0&&Kv(e,t,n))return!0;return!1}}}}),Jv=RegExp(`^(\\s*)(${_v})([.)])\\s+(.*)$`),Yv=/^\s/,Xv={heading:/^#{1,6}(?:\s|$)/,bulletItem:/^[-+*]\s+/,codeFence:/^(?:```|~~~)/,blockMath:/^\$\$/,thematicBreak:/^(?:(?:-[ \t]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})$/};function Zv(e){return Jv.test(e.trimStart())}function Qv(e){let t=e.trimStart();return Xv.bulletItem.test(t)||Zv(t)||Xv.heading.test(t)||Xv.thematicBreak.test(t)&&!t.startsWith(`-`)||/^>\s?/.test(t)||Xv.codeFence.test(t)||Xv.blockMath.test(t)}function $v(e){return Object.values(Xv).some(t=>t.test(e))}function ey(e){let t=[],n=[],r=!1;return e.forEach(e=>{r?n.push(e):e.trim()===``||t.length>0&&Qv(e)?(r=!0,n.push(e)):t.push(e)}),{paragraphLines:t,blockLines:n}}function ty(e){let t=[],n=0,r=0;for(;ne.trim().length>0);if(t.length===0)return null;let n=[];for(let e of t){let t=e.trim().match(ny);if(!t)return null;n.push({marker:t[1],content:t[3]})}return Dv(n.map(e=>e.marker))?{type:`orderedList`,attrs:kv(n[0].marker),content:n.map(e=>({type:`listItem`,content:[{type:`paragraph`,content:[{type:`text`,text:e.content}]}]}))}:null}function iy(e,t,n){let r=[],i=0;for(;it;)f.push(e[d]),d+=1;if(f.length>0){let e=iy(f,Math.min(...f.map(e=>e.indent)),n);l.push({type:`list`,ordered:!0,start:f[0].number,typeMarker:f[0].type,items:e,raw:f.map(e=>e.raw).join(` `)})}r.push({type:`list_item`,raw:a.raw,tokens:l}),i=d}else i+=1}return r}function ay(e,t){return e.map(e=>{if(e.type!==`list_item`)return t.parseChildren([e])[0];let n=[];return e.tokens&&e.tokens.length>0&&e.tokens.forEach(e=>{if(e.type===`paragraph`||e.type===`list`||e.type===`blockquote`||e.type===`code`)n.push(...t.parseChildren([e]));else if(e.type===`text`&&e.tokens){let r=t.parseChildren([e]);n.push({type:`paragraph`,content:r})}else{let r=t.parseChildren([e]);r.length>0&&n.push(...r)}}),{type:`listItem`,content:n}})}var oy=64;function sy(e,t){let n=[],r=0;for(;n.lengthe.hasAttribute(`start`)?parseInt(e.getAttribute(`start`)||``,10):1},type:{default:null,parseHTML:e=>{let t=e.getAttribute(`type`);if(t)return t;let n=e.getAttribute(`style`);if(n){let e=fy(n);if(e)return e}let r=e.querySelector(`li`);if(r){let e=r.getAttribute(`style`);if(e){let t=fy(e);if(t)return t}}return null}}}},parseHTML(){return[{tag:`ol`}]},renderHTML({HTMLAttributes:e}){let{start:t,type:n,...r}=e,i=q(this.options.HTMLAttributes,r);return t!==1&&(i.start=t),n&&n!==`1`&&(i.type=n),[`ol`,i,0]},markdownTokenName:`list`,parseMarkdown:(e,t)=>{if(e.type!==`list`||!e.ordered)return[];let n=e.start||1,r=e.typeMarker,i=e.items?ay(e.items,t):[],a={};return n!==1&&(a.start=n),r&&(a.type=r),Object.keys(a).length>0?{type:`orderedList`,attrs:a,content:i}:{type:`orderedList`,content:i}},renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,` +`),n=t===-1?e:e.slice(0,t);if(!Jv.test(n))return[[],0,[]];let r=oy,i=sy(e,r),a=ty(i);for(;a[1]===i.length&&i.length===r;)r*=2,i=sy(e,r),a=ty(i);return[a[0],a[1],i]}var ly=`listItem`,uy=`textStyle`,dy=/^(\d+)\.\s$/;function fy(e){let t=e.match(/list-style-type\s*:\s*([^;]+)/i);if(!t)return null;switch(t[1].trim().toLowerCase()){case`upper-roman`:return`I`;case`lower-roman`:return`i`;case`upper-alpha`:case`upper-latin`:return`A`;case`lower-alpha`:case`lower-latin`:return`a`;default:return null}}var py=um.create({name:`orderedList`,addOptions(){return{itemTypeName:`listItem`,HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:`block list`,content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:e=>e.hasAttribute(`start`)?parseInt(e.getAttribute(`start`)||``,10):1},type:{default:null,parseHTML:e=>{let t=e.getAttribute(`type`);if(t)return t;let n=e.getAttribute(`style`);if(n){let e=fy(n);if(e)return e}let r=e.querySelector(`li`);if(r){let e=r.getAttribute(`style`);if(e){let t=fy(e);if(t)return t}}return null}}}},parseHTML(){return[{tag:`ol`}]},renderHTML({HTMLAttributes:e}){let{start:t,type:n,...r}=e,i=K(this.options.HTMLAttributes,r);return t!==1&&(i.start=t),n&&n!==`1`&&(i.type=n),[`ol`,i,0]},markdownTokenName:`list`,parseMarkdown:(e,t)=>{if(e.type!==`list`||!e.ordered)return[];let n=e.start||1,r=e.typeMarker,i=e.items?ay(e.items,t):[],a={};return n!==1&&(a.start=n),r&&(a.type=r),Object.keys(a).length>0?{type:`orderedList`,attrs:a,content:i}:{type:`orderedList`,content:i}},renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,` `):``,markdownTokenizer:{name:`orderedList`,level:`block`,start:()=>-1,tokenize:(e,t,n)=>{let[r,i,a]=cy(e);if(r.length===0)return;let o=iy(r,r[0].indent,n);if(o.length!==0)return{type:`list`,ordered:!0,start:r[0]?.number||1,typeMarker:r[0]?.type,items:o,raw:a.slice(0,i).join(` -`)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:e,chain:t})=>this.options.keepAttributes?t().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(ly,this.editor.getAttributes(uy)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addProseMirrorPlugins(){return[new V({props:{handlePaste:(e,t)=>{if((t.clipboardData?.getData(`text/html`))?.trim())return!1;let n=t.clipboardData?.getData(`text/plain`);if(!n)return!1;let r=ry(n);if(!r)return!1;try{let t=e.state.schema.nodeFromJSON(r),n=e.state.tr.replaceSelectionWith(t);return e.dispatch(n),!0}catch{return!1}}}})]},addInputRules(){let e=(e,t)=>(!t.attrs.type||t.attrs.type===`1`)&&t.childCount+t.attrs.start===+e[1],t=om({find:dy,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:e});return(this.options.keepMarks||this.options.keepAttributes)&&(t=om({find:dy,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(uy)}),joinPredicate:e,editor:this.editor})),[t]}}),my=/^\s*(\[([( |x])?\])\s$/,hy=`position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0`,gy=(e,t,n)=>{var r;return(n==null||(r=n.checkboxLabel)==null?void 0:r.call(n,e,t))||`Task item checkbox for ${e.textContent||`empty task item`}`},_y=lm.create({name:`taskItem`,addOptions(){return{nested:!1,HTMLAttributes:{},taskListTypeName:`taskList`,a11y:void 0}},content(){return this.options.nested?`paragraph block*`:`paragraph+`},defining:!0,addAttributes(){return{checked:{default:!1,keepOnSplit:!1,parseHTML:e=>{let t=e.getAttribute(`data-checked`);return t===``||t===`true`},renderHTML:e=>({"data-checked":e.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51,contentElement:e=>e.querySelector(`div`)??e}]},renderHTML({node:e,HTMLAttributes:t}){return[`li`,q(this.options.HTMLAttributes,t,{"data-type":this.name}),[`label`,[`input`,{type:`checkbox`,checked:e.attrs.checked?`checked`:null}],[`span`]],[`div`,0]]},parseMarkdown:(e,t)=>{let n=[];if(e.tokens&&e.tokens.length>0?n.push(t.createNode(`paragraph`,{},t.parseInline(e.tokens))):e.text?n.push(t.createNode(`paragraph`,{},[t.createNode(`text`,{text:e.text})])):n.push(t.createNode(`paragraph`,{},[])),e.nestedTokens&&e.nestedTokens.length>0){let r=t.parseChildren(e.nestedTokens);n.push(...r)}return t.createNode(`taskItem`,{checked:e.checked||!1},n)},renderMarkdown:(e,t)=>xp(e,t,`- [${e.attrs?.checked?`x`:` `}] `,void 0,{indentMainContent:!0}),addExtensions(){return this.options.nested?[mv(this.name,[this.options.taskListTypeName])]:[]},addKeyboardShortcuts(){let e={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...e,Tab:()=>this.editor.commands.sinkListItem(this.name)}:e},addNodeView(){return({node:e,HTMLAttributes:t,getPos:n,editor:r})=>{let i=document.createElement(`li`),a=document.createElement(`label`),o=document.createElement(`span`),s=document.createElement(`input`),c=document.createElement(`div`);o.style.cssText=hy;let l=e=>{let t=gy(e,e.attrs.checked,this.options.a11y);s.setAttribute(`aria-label`,t),o.textContent=t};l(e),a.contentEditable=`false`,s.type=`checkbox`,s.addEventListener(`mousedown`,e=>e.preventDefault()),s.addEventListener(`change`,t=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){s.checked=!s.checked;return}let{checked:i}=t.target;r.isEditable&&typeof n==`function`&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:e})=>{let t=n();if(typeof t!=`number`)return!1;let r=e.doc.nodeAt(t);return e.setNodeMarkup(t,void 0,{...r?.attrs,checked:i}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(e,i)||(s.checked=!s.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([e,t])=>{i.setAttribute(e,t)}),i.dataset.checked=e.attrs.checked,s.checked=e.attrs.checked,a.append(s,o),i.append(a,c),Object.entries(t).forEach(([e,t])=>{i.setAttribute(e,t)});let u=new Set(Object.keys(t));return{dom:i,contentDOM:c,update:e=>{if(e.type!==this.type)return!1;i.dataset.checked=e.attrs.checked,s.checked=e.attrs.checked,l(e);let t=r.extensionManager.attributes,n=vd(e,t),a=new Set(Object.keys(n)),o=this.options.HTMLAttributes;return u.forEach(e=>{a.has(e)||(e in o?i.setAttribute(e,o[e]):i.removeAttribute(e))}),Object.entries(n).forEach(([e,t])=>{t==null?e in o?i.setAttribute(e,o[e]):i.removeAttribute(e):i.setAttribute(e,t)}),u=a,!0}}}},addInputRules(){return[om({find:my,type:this.type,getAttributes:e=>({checked:e[e.length-1]===`x`})})]}}),vy=lm.create({name:`taskList`,addOptions(){return{itemTypeName:`taskItem`,HTMLAttributes:{}}},group:`block list`,content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:e}){return[`ul`,q(this.options.HTMLAttributes,e,{"data-type":this.name}),0]},parseMarkdown:(e,t)=>t.createNode(`taskList`,{},t.parseChildren(e.items||[])),renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,` -`):``,markdownTokenizer:{name:`taskList`,level:`block`,start(e){let t=e.match(/^\s*[-+*]\s+\[([ xX])\]\s+/)?.index;return t===void 0?-1:t},tokenize(e,t,n){let r=e=>{let t=vp(e,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:e=>({indentLevel:e[1].length,mainContent:e[4],checked:e[3].toLowerCase()===`x`}),createToken:(e,t)=>({type:`taskItem`,raw:``,mainContent:e.mainContent,indentLevel:e.indentLevel,checked:e.checked,text:e.mainContent,tokens:n.inlineTokens(e.mainContent),nestedTokens:t}),customNestedParser:r},n);if(t){let r={type:`taskList`,raw:t.raw,items:t.items},i=e.slice(t.raw.length);return i.trim()?[r,...n.blockTokens(i)]:[r]}return n.blockTokens(e)},i=vp(e,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:e=>({indentLevel:e[1].length,mainContent:e[4],checked:e[3].toLowerCase()===`x`}),createToken:(e,t)=>({type:`taskItem`,raw:``,mainContent:e.mainContent,indentLevel:e.indentLevel,checked:e.checked,text:e.mainContent,tokens:n.inlineTokens(e.mainContent),nestedTokens:t}),customNestedParser:r},n);if(i)return{type:`taskList`,raw:i.raw,items:i.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:e})=>e.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});J.create({name:`listKit`,addExtensions(){let e=[];return this.options.bulletList!==!1&&e.push(uv.configure(this.options.bulletList)),this.options.listItem!==!1&&e.push(Rv.configure(this.options.listItem)),this.options.listKeymap!==!1&&e.push(qv.configure(this.options.listKeymap)),this.options.orderedList!==!1&&e.push(py.configure(this.options.orderedList)),this.options.taskItem!==!1&&e.push(_y.configure(this.options.taskItem)),this.options.taskList!==!1&&e.push(vy.configure(this.options.taskList)),e}});var yy=` `,by=`\xA0`,xy=lm.create({name:`paragraph`,priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:`block`,content:`inline*`,parseHTML(){return[{tag:`p`}]},renderHTML({HTMLAttributes:e}){return[`p`,q(this.options.HTMLAttributes,e),0]},parseMarkdown:(e,t)=>{let n=e.tokens||[];if(n.length===1&&n[0].type===`image`)return t.parseChildren([n[0]]);let r=t.parseInline(n);return n.length===1&&n[0].type===`text`&&(n[0].raw===yy||n[0].text===yy||n[0].raw===by||n[0].text===by)&&r.length===1&&r[0].type===`text`&&(r[0].text===yy||r[0].text===by)?t.createNode(`paragraph`,void 0,[]):t.createNode(`paragraph`,void 0,r)},renderMarkdown:(e,t,n)=>{if(!e)return``;let r=Array.isArray(e.content)?e.content:[];if(r.length===0){var i,a;let e=Array.isArray(n==null||(i=n.previousNode)==null?void 0:i.content)?n.previousNode.content:[];return(n==null||(a=n.previousNode)==null?void 0:a.type)===`paragraph`&&e.length===0?yy:``}return t.renderChildren(r)},addCommands(){return{setParagraph:()=>({commands:e})=>e.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),Sy=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,Cy=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,wy=Mp.create({name:`strike`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`s`},{tag:`del`},{tag:`strike`},{style:`text-decoration`,consuming:!1,getAttrs:e=>e.includes(`line-through`)?{}:!1}]},renderHTML({HTMLAttributes:e}){return[`s`,q(this.options.HTMLAttributes,e),0]},markdownTokenName:`del`,parseMarkdown:(e,t)=>t.applyMark(`strike`,t.parseInline(e.tokens||[])),renderMarkdown:(e,t)=>`~~${t.renderChildren(e)}~~`,addCommands(){return{setStrike:()=>({commands:e})=>e.setMark(this.name),toggleStrike:()=>({commands:e})=>e.toggleMark(this.name),unsetStrike:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[rm({find:Sy,type:this.type})]},addPasteRules(){return[um({find:Cy,type:this.type})]}}),Ty=lm.create({name:`text`,group:`inline`,parseMarkdown:e=>({type:`text`,text:e.text||``}),renderMarkdown:e=>e.text||``}),Ey=Mp.create({name:`underline`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`u`},{style:`text-decoration`,consuming:!1,getAttrs:e=>e.includes(`underline`)?{}:!1}]},renderHTML({HTMLAttributes:e}){return[`u`,q(this.options.HTMLAttributes,e),0]},parseMarkdown(e,t){return t.applyMark(this.name||`underline`,t.parseInline(e.tokens||[]))},renderMarkdown(e,t){return`${t.renderChildren(e)}`},markdownTokenizer:{name:`underline`,level:`inline`,start(e){return e.toLowerCase().indexOf(``)},tokenize(e,t,n){if(!/^/i.test(e))return;let r=/\\[\s\S]|`+|<\/u>/gi;r.lastIndex=3;let i=r.exec(e);for(;i;){if(i[0].startsWith("`")){let t=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/.exec(e.slice(i.index));t&&(r.lastIndex=i.index+t[0].length)}else if(!i[0].startsWith(`\\`)){let t=e.slice(3,i.index);return t?{type:`underline`,raw:e.slice(0,r.lastIndex),text:t,tokens:n.inlineTokens(t)}:void 0}i=r.exec(e)}}},addCommands(){return{setUnderline:()=>({commands:e})=>e.setMark(this.name),toggleUnderline:()=>({commands:e})=>e.toggleMark(this.name),unsetUnderline:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}}),Dy=Ey,Oy=J.create({name:`starterKit`,addExtensions(){let e=[];return this.options.bold!==!1&&e.push(_h.configure(this.options.bold)),this.options.blockquote!==!1&&e.push(fh.configure(this.options.blockquote)),this.options.bulletList!==!1&&e.push(uv.configure(this.options.bulletList)),this.options.code!==!1&&e.push(xh.configure(this.options.code)),this.options.codeBlock!==!1&&e.push(Th.configure(this.options.codeBlock)),this.options.document!==!1&&e.push(Eh.configure(this.options.document)),this.options.dropcursor!==!1&&e.push(km.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&e.push(Am.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&e.push(Dh.configure(this.options.hardBreak)),this.options.heading!==!1&&e.push(Oh.configure(this.options.heading)),this.options.undoRedo!==!1&&e.push(th.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&e.push(kh.configure(this.options.horizontalRule)),this.options.italic!==!1&&e.push(Ph.configure(this.options.italic)),this.options.listItem!==!1&&e.push(Rv.configure(this.options.listItem)),this.options.listKeymap!==!1&&e.push(qv.configure(this.options?.listKeymap)),this.options.link!==!1&&e.push(av.configure(this.options?.link)),this.options.orderedList!==!1&&e.push(py.configure(this.options.orderedList)),this.options.paragraph!==!1&&e.push(xy.configure(this.options.paragraph)),this.options.strike!==!1&&e.push(wy.configure(this.options.strike)),this.options.text!==!1&&e.push(Ty.configure(this.options.text)),this.options.underline!==!1&&e.push(Ey.configure(this.options?.underline)),this.options.trailingNode!==!1&&e.push(eh.configure(this.options?.trailingNode)),e}}),ky=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,Ay=lm.create({name:`image`,addOptions(){return{inline:!1,allowBase64:!1,HTMLAttributes:{},resize:!1}},inline(){return this.options.inline},group(){return this.options.inline?`inline`:`block`},draggable:!0,addAttributes(){return{src:{default:null},alt:{default:null},title:{default:null},width:{default:null},height:{default:null}}},parseHTML(){return[{tag:this.options.allowBase64?`img[src]`:`img[src]:not([src^="data:"])`}]},renderHTML({HTMLAttributes:e}){return[`img`,q(this.options.HTMLAttributes,e)]},parseMarkdown:(e,t)=>t.createNode(`image`,{src:e.href,title:e.title,alt:e.text}),renderMarkdown:e=>{let t=e.attrs?.src??``,n=e.attrs?.alt??``,r=e.attrs?.title??``;return r?`![${n}](${t} "${r}")`:`![${n}](${t})`},addNodeView(){if(!this.options.resize||!this.options.resize.enabled||typeof document>`u`)return null;let{directions:e,minWidth:t,minHeight:n,alwaysPreserveAspectRatio:r}=this.options.resize,i=new Set([`src`,`width`,`height`]);return({node:a,getPos:o,HTMLAttributes:s,editor:c})=>{let l=document.createElement(`img`);l.draggable=!1;let u=q(this.options.HTMLAttributes,s);Object.entries(u).forEach(([e,t])=>{if(t!=null)switch(e){case`src`:case`width`:case`height`:break;default:l.setAttribute(e,t)}}),u.src!==null&&(l.src=u.src);let d={...s},f=e=>{typeof e==`string`&&e!==``?l.getAttribute(`src`)!==e&&(l.src=e):(l.hasAttribute(`src`)&&l.removeAttribute(`src`),l.src!==``&&(l.src=``))};f(s.src);let p=new cm({element:l,editor:c,node:a,getPos:o,onResize:(e,t)=>{l.style.width=`${e}px`,l.style.height=`${t}px`},onCommit:(e,t)=>{let n=o();n!==void 0&&this.editor.chain().setNodeSelection(n).updateAttributes(this.name,{width:e,height:t}).run()},onUpdate:e=>{if(e.type!==a.type)return!1;let t=vd(e,c.extensionManager.attributes.filter(t=>t.type===e.type.name));return Object.keys(d).forEach(e=>{!i.has(e)&&!(e in t)&&l.removeAttribute(e)}),Object.entries(t).forEach(([e,t])=>{i.has(e)||(t==null?l.removeAttribute(e):l.setAttribute(e,t))}),f(t.src),d=t,!0},options:{directions:e,min:{width:t,height:n},preserveAspectRatio:r===!0}}),m=p.dom,h=()=>{m.style.visibility=``,m.style.pointerEvents=``};return m.style.visibility=`hidden`,m.style.pointerEvents=`none`,l.complete&&l.naturalWidth>0?h():(l.onload=h,l.onerror=h),p}},addCommands(){return{setImage:e=>({commands:t})=>t.insertContent({type:this.name,attrs:e})}},addInputRules(){return[im({find:ky,type:this.type,getAttributes:e=>{let[,,t,n,r]=e;return{src:n,alt:t,title:r}}})]}}),jy=Jm,My,Ny;if(typeof WeakMap<`u`){let e=new WeakMap;My=t=>e.get(t),Ny=(t,n)=>(e.set(t,n),n)}else{let e=[],t=0;My=t=>{for(let n=0;n(t==10&&(t=0),e[t++]=n,e[t++]=r)}var Q=class{constructor(e,t,n,r){this.width=e,this.height=t,this.map=n,this.problems=r}findCell(e){for(let t=0;t=n){(a||=[]).push({type:`overlong_rowspan`,pos:c,n:f-e});break}let l=i+e*t;for(let e=0;er&&(a+=i.attrs.colspan)}}for(let e=0;e1&&(n=!0)}t==-1?t=a:t!=a&&(t=Math.max(t,a))}return t}function Iy(e,t,n){e.problems||=[];let r={};for(let i=0;i0;t--)if(e.node(t).type.spec.tableRole==`row`)return e.node(0).resolve(e.before(t+1));return null}function Vy(e){for(let t=e.depth;t>0;t--){let n=e.node(t).type.spec.tableRole;if(n===`cell`||n===`header_cell`)return e.node(t)}return null}function Hy(e){let t=e.selection.$head;for(let e=t.depth;e>0;e--)if(t.node(e).type.spec.tableRole==`row`)return!0;return!1}function Uy(e){let t=e.selection;if(`$anchorCell`in t&&t.$anchorCell)return t.$anchorCell.pos>t.$headCell.pos?t.$anchorCell:t.$headCell;if(`node`in t&&t.node&&t.node.type.spec.tableRole==`cell`)return t.$anchor;let n=By(t.$head)||Wy(t.$head);if(n)return n;throw RangeError(`No cell found around position ${t.head}`)}function Wy(e){for(let t=e.nodeAfter,n=e.pos;t;t=t.firstChild,n++){let r=t.type.spec.tableRole;if(r==`cell`||r==`header_cell`)return e.doc.resolve(n)}for(let t=e.nodeBefore,n=e.pos;t;t=t.lastChild,n--){let r=t.type.spec.tableRole;if(r==`cell`||r==`header_cell`)return e.doc.resolve(n-t.nodeSize)}}function Gy(e){return e.parent.type.spec.tableRole==`row`&&!!e.nodeAfter}function Ky(e){return e.node(0).resolve(e.pos+e.nodeAfter.nodeSize)}function qy(e,t){return e.depth==t.depth&&e.pos>=t.start(-1)&&e.pos<=t.end(-1)}function Jy(e,t,n){let r=e.node(-1),i=Q.get(r),a=e.start(-1),o=i.nextCell(e.pos-a,t,n);return o==null?null:e.node(0).resolve(a+o)}function Yy(e,t,n=1){let r={...e,colspan:e.colspan-n};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(t,n),r.colwidth.some(e=>e>0)||(r.colwidth=null)),r}function Xy(e,t,n=1){let r={...e,colspan:e.colspan+n};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let e=0;ee!=t.pos-i);s.unshift(t.pos-i);let c=s.map(e=>{let t=n.nodeAt(e);if(!t)throw RangeError(`No cell with offset ${e} found`);let r=i+e+1;return new or(o.resolve(r),o.resolve(r+t.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=t}map(t,n){let r=t.resolve(n.map(this.$anchorCell.pos)),i=t.resolve(n.map(this.$headCell.pos));if(Gy(r)&&Gy(i)&&qy(r,i)){let t=this.$anchorCell.node(-1)!=r.node(-1);return t&&this.isRowSelection()?e.rowSelection(r,i):t&&this.isColSelection()?e.colSelection(r,i):new e(r,i)}return z.between(r,i)}content(){let e=this.$anchorCell.node(-1),t=Q.get(e),n=this.$anchorCell.start(-1),r=t.rectBetween(this.$anchorCell.pos-n,this.$headCell.pos-n),i={},a=[];for(let n=r.top;n0||u>0){let e=c.attrs;if(l>0&&(e=Yy(e,0,l)),u>0&&(e=Yy(e,e.colspan-u,u)),s.leftr.bottom){let e={...c.attrs,rowspan:Math.min(s.bottom,r.bottom)-Math.max(s.top,r.top)};c=s.top0)return!1;let n=e+this.$anchorCell.nodeAfter.attrs.rowspan,r=t+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(n,r)==this.$headCell.node(-1).childCount}static colSelection(t,n=t){let r=t.node(-1),i=Q.get(r),a=t.start(-1),o=i.findCell(t.pos-a),s=i.findCell(n.pos-a),c=t.node(0);return o.top<=s.top?(o.top>0&&(t=c.resolve(a+i.map[o.left])),s.bottom0&&(n=c.resolve(a+i.map[s.left])),o.bottom0)return!1;let a=r+this.$anchorCell.nodeAfter.attrs.colspan,o=i+this.$headCell.nodeAfter.attrs.colspan;return Math.max(a,o)==t.width}eq(t){return t instanceof e&&t.$anchorCell.pos==this.$anchorCell.pos&&t.$headCell.pos==this.$headCell.pos}static rowSelection(t,n=t){let r=t.node(-1),i=Q.get(r),a=t.start(-1),o=i.findCell(t.pos-a),s=i.findCell(n.pos-a),c=t.node(0);return o.left<=s.left?(o.left>0&&(t=c.resolve(a+i.map[o.top*i.width])),s.right0&&(n=c.resolve(a+i.map[s.top*i.width])),o.right{t.push(nc.node(n,n+e.nodeSize,{class:`selectedCell`}))}),W.create(e.doc,t)}function eb({$from:e,$to:t}){if(e.pos==t.pos||e.pos=0&&!(e.after(i+1)=0&&!(t.before(e+1)>t.start(e));e--,r--);return n==r&&/row|table/.test(e.node(i).type.spec.tableRole)}function tb({$from:e,$to:t}){let n,r;for(let t=e.depth;t>0;t--){let r=e.node(t);if(r.type.spec.tableRole===`cell`||r.type.spec.tableRole===`header_cell`){n=r;break}}for(let e=t.depth;e>0;e--){let n=t.node(e);if(n.type.spec.tableRole===`cell`||n.type.spec.tableRole===`header_cell`){r=n;break}}return n!==r&&t.parentOffset===0}function nb(e,t,n){let r=(t||e).selection,i=(t||e).doc,a,o;if(r instanceof B&&(o=r.node.type.spec.tableRole)){if(o==`cell`||o==`header_cell`)a=$.create(i,r.from);else if(o==`row`){let e=i.resolve(r.from+1);a=$.rowSelection(e,e)}else if(!n){let e=Q.get(r.node),t=r.from+1,n=t+e.map[e.width*e.height-1];a=$.create(i,t+1,n)}}else r instanceof z&&eb(r)?a=z.create(i,r.from):r instanceof z&&tb(r)&&(a=z.create(i,r.$from.start(),r.$from.end()));return a&&(t||=e.tr).setSelection(a),t}var rb=new H(`fix-tables`);function ib(e,t,n,r){let i=e.childCount,a=t.childCount;outer:for(let o=0,s=0;o{t.type.spec.tableRole==`table`&&(n=ob(e,t,r,n))};return t?t.doc!=e.doc&&ib(t.doc,e.doc,0,r):e.doc.descendants(r),n}function ob(e,t,n,r){let i=Q.get(t);if(!i.problems)return r;r||=e.tr;let a=[];for(let e=0;e0){let t=`cell`;n.firstChild&&(t=n.firstChild.type.spec.tableRole);let a=[];for(let n=0;n0?-1:0;Zy(t,r,i+a)&&(a=i==0||i==t.width?null:0);for(let o=0;o0&&i0&&t.map[s-1]==c||i0?-1:0;pb(t,r,i+s)&&(s=i==0||i==t.height?null:0);for(let a=0,c=t.width*i;a0&&i0&&l==t.map[o-t.width]){let t=n.nodeAt(l).attrs;e.setNodeMarkup(e.mapping.slice(s).map(l+r),null,{...t,rowspan:t.rowspan-1}),a+=t.colspan-1}else if(i0&&n[a]==n[a-1]||r.right0&&n[i]==n[i-e]||r.bottom0){let e=s+1+c.content.size,t=yb(c)?s+1:e;n.replaceWith(t+r.tableStart,e+r.tableStart,o)}n.setSelection(new $(n.doc.resolve(s+r.tableStart))),t(n)}return!0}function Sb(e,t){let n=Ry(e.schema);return Cb(({node:e})=>n[e.type.spec.tableRole])(e,t)}function Cb(e){return(t,n)=>{let r=t.selection,i,a;if(r instanceof $){if(r.$anchorCell.pos!=r.$headCell.pos)return!1;i=r.$anchorCell.nodeAfter,a=r.$anchorCell.pos}else{if(i=Vy(r.$from),!i)return!1;a=By(r.$from)?.pos}if(i==null||a==null||i.attrs.colspan==1&&i.attrs.rowspan==1)return!1;if(n){let o=i.attrs,s=[],c=o.colwidth;o.rowspan>1&&(o={...o,rowspan:1}),o.colspan>1&&(o={...o,colspan:1});let l=sb(t),u=t.tr;for(let e=0;e{n.attrs[e]!==t&&a.setNodeMarkup(r,null,{...n.attrs,[e]:t})}):a.setNodeMarkup(i.pos,null,{...i.nodeAfter.attrs,[e]:t}),r(a)}return!0}}function Tb(e){return function(t,n){if(!Hy(t))return!1;if(n){let r=Ry(t.schema),i=sb(t),a=t.tr,o=i.map.cellsInRect(e==`column`?{left:i.left,top:0,right:i.right,bottom:i.map.height}:e==`row`?{left:0,top:i.top,right:i.map.width,bottom:i.bottom}:i),s=o.map(e=>i.table.nodeAt(e));for(let e=0;e{let t=e+i.tableStart,n=a.doc.nodeAt(t);n&&a.setNodeMarkup(t,u,n.attrs)}),n(a)}return!0}}Db(`row`,{useDeprecatedLogic:!0}),Db(`column`,{useDeprecatedLogic:!0});var Ob=Db(`cell`,{useDeprecatedLogic:!0});function kb(e,t){if(t<0){let t=e.nodeBefore;if(t)return e.pos-t.nodeSize;for(let t=e.index(-1)-1,n=e.before();t>=0;t--){let r=e.node(-1).child(t),i=r.lastChild;if(i)return n-1-i.nodeSize;n-=r.nodeSize}}else{if(e.index()0;r--)if(n.node(r).type.spec.tableRole==`table`)return t&&t(e.tr.delete(n.before(r),n.after(r)).scrollIntoView()),!0;return!1}function Mb(e,t){let n=e.selection;if(!(n instanceof $))return!1;if(t){let r=e.tr,i=Ry(e.schema).cell.createAndFill().content;n.forEachCell((e,t)=>{e.content.eq(i)||r.replace(r.mapping.map(t+1),r.mapping.map(t+e.nodeSize-1),new L(i,0,0))}),r.docChanged&&t(r)}return!0}function Nb(e){if(e.size===0)return null;let{content:t,openStart:n,openEnd:r}=e;for(;t.childCount==1&&(n>0&&r>0||t.child(0).type.spec.tableRole==`table`);)n--,r--,t=t.child(0).content;let i=t.child(0),a=i.type.spec.tableRole,o=i.type.schema,s=[];if(a==`row`)for(let e=0;e=0;t--){let{rowspan:i,colspan:a}=r.child(t).attrs;for(let t=e;t=t.length&&t.push(F.empty),n[i]r&&(s=s.type.createChecked(Yy(s.attrs,s.attrs.colspan,n+s.attrs.colspan-r),s.content)),o.push(s),n+=s.attrs.colspan;for(let n=1;ni&&(t=t.type.create({...t.attrs,rowspan:Math.max(1,i-t.attrs.rowspan)},t.content)),o.push(t)}e.push(F.from(o))}n=e,t=i}return{width:e,height:t,rows:n}}function Lb(e,t,n,r,i,a,o){let s=e.doc.type.schema,c=Ry(s),l,u;if(i>t.width)for(let a=0,s=0;at.height){let s=[];for(let e=0,r=(t.height-1)*t.width;e=t.width?!1:n.nodeAt(t.map[r+e]).type==c.header_cell;s.push(i?u||=c.header_cell.createAndFill():l||=c.cell.createAndFill())}let d=c.row.create(null,F.from(s)),f=[];for(let e=t.height;e{if(!i)return!1;let a=n.selection;if(a instanceof $)return Hb(n,r,R.near(a.$headCell,t));if(e!=`horiz`&&!a.empty)return!1;let o=Jb(i,e,t);if(o==null)return!1;if(e==`horiz`)return Hb(n,r,R.near(n.doc.resolve(a.head+t),t));{let i=n.doc.resolve(o),a=Jy(i,e,t),s;return s=a?R.near(a,1):t<0?R.near(n.doc.resolve(i.before(-1)),-1):R.near(n.doc.resolve(i.after(-1)),1),Hb(n,r,s)}}}function Wb(e,t){return(n,r,i)=>{if(!i)return!1;let a=n.selection,o;if(a instanceof $)o=a;else{let r=Jb(i,e,t);if(r==null)return!1;o=new $(n.doc.resolve(r))}let s=Jy(o.$headCell,e,t);return s?Hb(n,r,new $(o.$anchorCell,s)):!1}}function Gb(e,t){let n=e.state.doc,r=By(n.resolve(t));return r?(e.dispatch(e.state.tr.setSelection(new $(r))),!0):!1}function Kb(e,t,n){if(!Hy(e.state))return!1;let r=Nb(n),i=e.state.selection;if(i instanceof $){r||={width:1,height:1,rows:[F.from(Fb(Ry(e.state.schema).cell,n))]};let t=i.$anchorCell.node(-1),a=i.$anchorCell.start(-1),o=Q.get(t).rectBetween(i.$anchorCell.pos-a,i.$headCell.pos-a);return r=Ib(r,o.right-o.left,o.bottom-o.top),Bb(e.state,e.dispatch,a,o,r),!0}if(r){let t=Uy(e.state),n=t.start(-1);return Bb(e.state,e.dispatch,n,Q.get(t.node(-1)).findCell(t.pos-n),r),!0}return!1}function qb(e,t){if(t.button!=0||t.ctrlKey||t.metaKey)return;let n=Yb(e,t.target),r;if(t.shiftKey&&e.state.selection instanceof $)i(e.state.selection.$anchorCell,t),t.preventDefault();else if(t.shiftKey&&n&&(r=By(e.state.selection.$anchor))!=null&&Xb(e,t)?.pos!=r.pos)i(r,t),t.preventDefault();else if(!n)return;function i(t,n){let r=Xb(e,n),i=zy.getState(e.state)==null;if(!r||!qy(t,r)){if(i)r=t;else return}let a=new $(t,r);if(i||!e.state.selection.eq(a)){let n=e.state.tr.setSelection(a);i&&n.setMeta(zy,t.pos),e.dispatch(n)}}function a(){e.root.removeEventListener(`mouseup`,a),e.root.removeEventListener(`dragstart`,a),e.root.removeEventListener(`mousemove`,o),zy.getState(e.state)!=null&&e.dispatch(e.state.tr.setMeta(zy,-1))}function o(r){let o=r,s=zy.getState(e.state),c;if(s!=null)c=e.state.doc.resolve(s);else if(Yb(e,o.target)!=n&&(c=Xb(e,t),!c))return a();c&&i(c,o)}e.root.addEventListener(`mouseup`,a),e.root.addEventListener(`dragstart`,a),e.root.addEventListener(`mousemove`,o)}function Jb(e,t,n){if(!(e.state.selection instanceof z))return null;let{$head:r}=e.state.selection;for(let i=r.depth-1;i>=0;i--){let a=r.node(i);if((n<0?r.index(i):r.indexAfter(i))!=(n<0?0:a.childCount))return null;if(a.type.spec.tableRole==`cell`||a.type.spec.tableRole==`header_cell`){let a=r.before(i),o=t==`vert`?n>0?`down`:`up`:n>0?`right`:`left`;return e.endOfTextblock(o)?a:null}}return null}function Yb(e,t){for(;t&&t!=e.dom;t=t.parentNode)if(t.nodeName==`TD`||t.nodeName==`TH`)return t;return null}function Xb(e,t){let n=e.posAtCoords({left:t.clientX,top:t.clientY});if(!n)return null;let{inside:r,pos:i}=n;return r>=0&&By(e.state.doc.resolve(r))||By(e.state.doc.resolve(i))}var Zb=class{constructor(e,t){this.node=e,this.defaultCellMinWidth=t,this.dom=document.createElement(`div`),this.dom.className=`tableWrapper`,this.table=this.dom.appendChild(document.createElement(`table`)),this.table.style.setProperty(`--default-cell-min-width`,`${t}px`),this.colgroup=this.table.appendChild(document.createElement(`colgroup`)),Qb(e,this.colgroup,this.table,t),this.contentDOM=this.table.appendChild(document.createElement(`tbody`))}update(e){return e.type==this.node.type&&(this.node=e,Qb(e,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(e){return e.type==`attributes`&&(e.target==this.table||this.colgroup.contains(e.target))}};function Qb(e,t,n,r,i,a){let o=0,s=!0,c=t.firstChild,l=e.firstChild;if(l){for(let e=0,n=0;enew r(e,n,t)),new tx(-1,!1)},apply(e,t){return t.apply(e)}},props:{attributes:e=>{let t=$b.getState(e);return t&&t.activeHandle>-1?{class:`resize-cursor`}:{}},handleDOMEvents:{mousemove:(t,n)=>{nx(t,n,e,i)},mouseleave:e=>{rx(e)},mousedown:(e,r)=>{ix(e,r,t,n)}},decorations:e=>{let t=$b.getState(e);if(t&&t.activeHandle>-1)return px(e,t.activeHandle)},nodeViews:{}}});return a}var tx=class e{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(t){let n=this,r=t.getMeta($b);if(r&&r.setHandle!=null)return new e(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new e(n.activeHandle,r.setDragging);if(n.activeHandle>-1&&t.docChanged){let r=t.mapping.map(n.activeHandle,-1);return Gy(t.doc.resolve(r))||(r=-1),new e(r,n.dragging)}return n}};function nx(e,t,n,r){if(!e.editable)return;let i=$b.getState(e.state);if(i&&!i.dragging){let a=ox(t.target),o=-1;if(a){let{left:r,right:i}=a.getBoundingClientRect();t.clientX-r<=n?o=sx(e,t,`left`,n):i-t.clientX<=n&&(o=sx(e,t,`right`,n))}if(o!=i.activeHandle){if(!r&&o!==-1){let t=e.state.doc.resolve(o),n=t.node(-1),r=Q.get(n),i=t.start(-1);if(r.colCount(t.pos-i)+t.nodeAfter.attrs.colspan-1==r.width-1)return}lx(e,o)}}}function rx(e){if(!e.editable)return;let t=$b.getState(e.state);t&&t.activeHandle>-1&&!t.dragging&&lx(e,-1)}function ix(e,t,n,r){if(!e.editable)return!1;let i=e.dom.ownerDocument.defaultView??window,a=$b.getState(e.state);if(!a||a.activeHandle==-1||a.dragging)return!1;let o=e.state.doc.nodeAt(a.activeHandle),s=ax(e,a.activeHandle,o.attrs);e.dispatch(e.state.tr.setMeta($b,{setDragging:{startX:t.clientX,startWidth:s}}));function c(t){i.removeEventListener(`mouseup`,c),i.removeEventListener(`mousemove`,l);let r=$b.getState(e.state);r?.dragging&&(ux(e,r.activeHandle,cx(r.dragging,t,n)),e.dispatch(e.state.tr.setMeta($b,{setDragging:null})))}function l(t){if(!t.which)return c(t);let i=$b.getState(e.state);if(i&&i.dragging){let a=cx(i.dragging,t,n);dx(e,i.activeHandle,a,r)}}return dx(e,a.activeHandle,s,r),i.addEventListener(`mouseup`,c),i.addEventListener(`mousemove`,l),t.preventDefault(),!0}function ax(e,t,{colspan:n,colwidth:r}){let i=r&&r[r.length-1];if(i)return i;let a=e.domAtPos(t),o=a.node.childNodes[a.offset].offsetWidth,s=n;if(r)for(let e=0;egx(e),renderHTML:e=>{let t=hx(e.align);return mp(t)?{style:`text-align: ${t}`}:{}}}}function yx(e){let t=e.parentElement,n=e.closest(`table`);if(!t||!n)return null;let r=Array.from(t.children).indexOf(e),i=n.querySelectorAll(`colgroup > col`)[r]?.getAttribute(`width`);return i?[parseInt(i,10)]:null}function bx(e){let t=e.getAttribute(`colwidth`);return t?t.split(`,`).map(e=>parseInt(e,10)):yx(e)}var xx=/[ \t\r\n\f]+/g;function Sx(e){return e.children.length>0?!1:(e.textContent??``).replace(xx,``)===``}function Cx(e){let t=e.createAndFill();if(!t)throw Error(`[tiptap error]: "${e.name}" has no default content to backfill.`);return t.content}function wx(e,t,n){if(!(n in t))return;let r=t[n];(r===1||r===`1`||r==null)&&delete e[n]}var Tx=lm.create({name:`tableCell`,addOptions(){return{HTMLAttributes:{}}},content:`block+`,addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:bx},align:vx()}},tableRole:`cell`,isolating:!0,parseHTML(){return[{tag:`td`,getAttrs:e=>Sx(e)?{}:!1,getContent:(e,t)=>Cx(t.nodes[this.name])},{tag:`td`}]},renderHTML({HTMLAttributes:e}){let t=q(this.options.HTMLAttributes,e);return wx(t,e,`colspan`),wx(t,e,`rowspan`),[`td`,t,0]}}),Ex=lm.create({name:`tableHeader`,addOptions(){return{HTMLAttributes:{}}},content:`block+`,addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:bx},align:vx()}},tableRole:`header_cell`,isolating:!0,parseHTML(){return[{tag:`th`,getAttrs:e=>Sx(e)?{}:!1,getContent:(e,t)=>Cx(t.nodes[this.name])},{tag:`th`}]},renderHTML({HTMLAttributes:e}){let t=q(this.options.HTMLAttributes,e);return wx(t,e,`colspan`),wx(t,e,`rowspan`),[`th`,t,0]}}),Dx=lm.create({name:`tableRow`,addOptions(){return{HTMLAttributes:{}}},content:`(tableCell | tableHeader)*`,tableRole:`row`,parseHTML(){return[{tag:`tr`}]},renderHTML({HTMLAttributes:e}){return[`tr`,q(this.options.HTMLAttributes,e),0]}});function Ox(e,t){return t?[`width`,`${Math.max(t,e)}px`]:[`min-width`,`${e}px`]}function kx(e,t,n,r,i,a){let o=0,s=!0,c=t.firstChild,l=e.firstChild;if(l!==null)for(let e=0,n=0;e{let r=e.nodes[n];r.spec.tableRole&&(t[r.spec.tableRole]=r)}),e.cached.tableNodeTypes=t,t}function Px(e,t,n,r,i){let a=Nx(e),o=[],s=[];for(let e=0;e{let{selection:t}=e.state;if(!Fx(t))return!1;let n=0;return ed(t.ranges[0].$from,e=>e.type.name===`table`)?.node.descendants(e=>{if(e.type.name===`table`)return!1;[`tableCell`,`tableHeader`].includes(e.type.name)&&(n+=1)}),n===t.ranges.length&&(e.commands.deleteTable(),!0)};function Lx(e,t){let n=e.mapping.map(t);if(ed(e.selection.$from,e=>e.type.name===`table`)?.pos===n)return;let r=e.doc.nodeAt(n);if(!r)return;let i=n+r.nodeSize-1;e.setSelection(z.near(e.doc.resolve(i),-1))}function Rx(e){let t=``,n=0;for(;ne===`|`?`\\|`:e)+e.slice(i,i+r),n=i+r,a=!0;break}i+=o}a||(t+=e.slice(n,n+r),n+=r)}return t}function zx(e){return e.split(` +`)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:e,chain:t})=>this.options.keepAttributes?t().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(ly,this.editor.getAttributes(uy)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addProseMirrorPlugins(){return[new B({props:{handlePaste:(e,t)=>{if((t.clipboardData?.getData(`text/html`))?.trim())return!1;let n=t.clipboardData?.getData(`text/plain`);if(!n)return!1;let r=ry(n);if(!r)return!1;try{let t=e.state.schema.nodeFromJSON(r),n=e.state.tr.replaceSelectionWith(t);return e.dispatch(n),!0}catch{return!1}}}})]},addInputRules(){let e=(e,t)=>(!t.attrs.type||t.attrs.type===`1`)&&t.childCount+t.attrs.start===+e[1],t=sm({find:dy,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:e});return(this.options.keepMarks||this.options.keepAttributes)&&(t=sm({find:dy,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(uy)}),joinPredicate:e,editor:this.editor})),[t]}}),my=/^\s*(\[([( |x])?\])\s$/,hy=`position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0`,gy=(e,t,n)=>{var r;return(n==null||(r=n.checkboxLabel)==null?void 0:r.call(n,e,t))||`Task item checkbox for ${e.textContent||`empty task item`}`},_y=um.create({name:`taskItem`,addOptions(){return{nested:!1,HTMLAttributes:{},taskListTypeName:`taskList`,a11y:void 0}},content(){return this.options.nested?`paragraph block*`:`paragraph+`},defining:!0,addAttributes(){return{checked:{default:!1,keepOnSplit:!1,parseHTML:e=>{let t=e.getAttribute(`data-checked`);return t===``||t===`true`},renderHTML:e=>({"data-checked":e.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51,contentElement:e=>e.querySelector(`div`)??e}]},renderHTML({node:e,HTMLAttributes:t}){return[`li`,K(this.options.HTMLAttributes,t,{"data-type":this.name}),[`label`,[`input`,{type:`checkbox`,checked:e.attrs.checked?`checked`:null}],[`span`]],[`div`,0]]},parseMarkdown:(e,t)=>{let n=[];if(e.tokens&&e.tokens.length>0?n.push(t.createNode(`paragraph`,{},t.parseInline(e.tokens))):e.text?n.push(t.createNode(`paragraph`,{},[t.createNode(`text`,{text:e.text})])):n.push(t.createNode(`paragraph`,{},[])),e.nestedTokens&&e.nestedTokens.length>0){let r=t.parseChildren(e.nestedTokens);n.push(...r)}return t.createNode(`taskItem`,{checked:e.checked||!1},n)},renderMarkdown:(e,t)=>Sp(e,t,`- [${e.attrs?.checked?`x`:` `}] `,void 0,{indentMainContent:!0}),addExtensions(){return this.options.nested?[mv(this.name,[this.options.taskListTypeName])]:[]},addKeyboardShortcuts(){let e={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...e,Tab:()=>this.editor.commands.sinkListItem(this.name)}:e},addNodeView(){return({node:e,HTMLAttributes:t,getPos:n,editor:r})=>{let i=document.createElement(`li`),a=document.createElement(`label`),o=document.createElement(`span`),s=document.createElement(`input`),c=document.createElement(`div`);o.style.cssText=hy;let l=e=>{let t=gy(e,e.attrs.checked,this.options.a11y);s.setAttribute(`aria-label`,t),o.textContent=t};l(e),a.contentEditable=`false`,s.type=`checkbox`,s.addEventListener(`mousedown`,e=>e.preventDefault()),s.addEventListener(`change`,t=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){s.checked=!s.checked;return}let{checked:i}=t.target;r.isEditable&&typeof n==`function`&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:e})=>{let t=n();if(typeof t!=`number`)return!1;let r=e.doc.nodeAt(t);return e.setNodeMarkup(t,void 0,{...r?.attrs,checked:i}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(e,i)||(s.checked=!s.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([e,t])=>{i.setAttribute(e,t)}),i.dataset.checked=e.attrs.checked,s.checked=e.attrs.checked,a.append(s,o),i.append(a,c),Object.entries(t).forEach(([e,t])=>{i.setAttribute(e,t)});let u=new Set(Object.keys(t));return{dom:i,contentDOM:c,update:e=>{if(e.type!==this.type)return!1;i.dataset.checked=e.attrs.checked,s.checked=e.attrs.checked,l(e);let t=r.extensionManager.attributes,n=yd(e,t),a=new Set(Object.keys(n)),o=this.options.HTMLAttributes;return u.forEach(e=>{a.has(e)||(e in o?i.setAttribute(e,o[e]):i.removeAttribute(e))}),Object.entries(n).forEach(([e,t])=>{t==null?e in o?i.setAttribute(e,o[e]):i.removeAttribute(e):i.setAttribute(e,t)}),u=a,!0}}}},addInputRules(){return[sm({find:my,type:this.type,getAttributes:e=>({checked:e[e.length-1]===`x`})})]}}),vy=um.create({name:`taskList`,addOptions(){return{itemTypeName:`taskItem`,HTMLAttributes:{}}},group:`block list`,content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:e}){return[`ul`,K(this.options.HTMLAttributes,e,{"data-type":this.name}),0]},parseMarkdown:(e,t)=>t.createNode(`taskList`,{},t.parseChildren(e.items||[])),renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,` +`):``,markdownTokenizer:{name:`taskList`,level:`block`,start(e){let t=e.match(/^\s*[-+*]\s+\[([ xX])\]\s+/)?.index;return t===void 0?-1:t},tokenize(e,t,n){let r=e=>{let t=yp(e,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:e=>({indentLevel:e[1].length,mainContent:e[4],checked:e[3].toLowerCase()===`x`}),createToken:(e,t)=>({type:`taskItem`,raw:``,mainContent:e.mainContent,indentLevel:e.indentLevel,checked:e.checked,text:e.mainContent,tokens:n.inlineTokens(e.mainContent),nestedTokens:t}),customNestedParser:r},n);if(t){let r={type:`taskList`,raw:t.raw,items:t.items},i=e.slice(t.raw.length);return i.trim()?[r,...n.blockTokens(i)]:[r]}return n.blockTokens(e)},i=yp(e,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:e=>({indentLevel:e[1].length,mainContent:e[4],checked:e[3].toLowerCase()===`x`}),createToken:(e,t)=>({type:`taskItem`,raw:``,mainContent:e.mainContent,indentLevel:e.indentLevel,checked:e.checked,text:e.mainContent,tokens:n.inlineTokens(e.mainContent),nestedTokens:t}),customNestedParser:r},n);if(i)return{type:`taskList`,raw:i.raw,items:i.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:e})=>e.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});q.create({name:`listKit`,addExtensions(){let e=[];return this.options.bulletList!==!1&&e.push(uv.configure(this.options.bulletList)),this.options.listItem!==!1&&e.push(Rv.configure(this.options.listItem)),this.options.listKeymap!==!1&&e.push(qv.configure(this.options.listKeymap)),this.options.orderedList!==!1&&e.push(py.configure(this.options.orderedList)),this.options.taskItem!==!1&&e.push(_y.configure(this.options.taskItem)),this.options.taskList!==!1&&e.push(vy.configure(this.options.taskList)),e}});var yy=` `,by=`\xA0`,xy=um.create({name:`paragraph`,priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:`block`,content:`inline*`,parseHTML(){return[{tag:`p`}]},renderHTML({HTMLAttributes:e}){return[`p`,K(this.options.HTMLAttributes,e),0]},parseMarkdown:(e,t)=>{let n=e.tokens||[];if(n.length===1&&n[0].type===`image`)return t.parseChildren([n[0]]);let r=t.parseInline(n);return n.length===1&&n[0].type===`text`&&(n[0].raw===yy||n[0].text===yy||n[0].raw===by||n[0].text===by)&&r.length===1&&r[0].type===`text`&&(r[0].text===yy||r[0].text===by)?t.createNode(`paragraph`,void 0,[]):t.createNode(`paragraph`,void 0,r)},renderMarkdown:(e,t,n)=>{if(!e)return``;let r=Array.isArray(e.content)?e.content:[];if(r.length===0){var i,a;let e=Array.isArray(n==null||(i=n.previousNode)==null?void 0:i.content)?n.previousNode.content:[];return(n==null||(a=n.previousNode)==null?void 0:a.type)===`paragraph`&&e.length===0?yy:``}return t.renderChildren(r)},addCommands(){return{setParagraph:()=>({commands:e})=>e.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),Sy=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,Cy=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,wy=Np.create({name:`strike`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`s`},{tag:`del`},{tag:`strike`},{style:`text-decoration`,consuming:!1,getAttrs:e=>e.includes(`line-through`)?{}:!1}]},renderHTML({HTMLAttributes:e}){return[`s`,K(this.options.HTMLAttributes,e),0]},markdownTokenName:`del`,parseMarkdown:(e,t)=>t.applyMark(`strike`,t.parseInline(e.tokens||[])),renderMarkdown:(e,t)=>`~~${t.renderChildren(e)}~~`,addCommands(){return{setStrike:()=>({commands:e})=>e.setMark(this.name),toggleStrike:()=>({commands:e})=>e.toggleMark(this.name),unsetStrike:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[im({find:Sy,type:this.type})]},addPasteRules(){return[dm({find:Cy,type:this.type})]}}),Ty=um.create({name:`text`,group:`inline`,parseMarkdown:e=>({type:`text`,text:e.text||``}),renderMarkdown:e=>e.text||``}),Ey=Np.create({name:`underline`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`u`},{style:`text-decoration`,consuming:!1,getAttrs:e=>e.includes(`underline`)?{}:!1}]},renderHTML({HTMLAttributes:e}){return[`u`,K(this.options.HTMLAttributes,e),0]},parseMarkdown(e,t){return t.applyMark(this.name||`underline`,t.parseInline(e.tokens||[]))},renderMarkdown(e,t){return`${t.renderChildren(e)}`},markdownTokenizer:{name:`underline`,level:`inline`,start(e){return e.toLowerCase().indexOf(``)},tokenize(e,t,n){if(!/^/i.test(e))return;let r=/\\[\s\S]|`+|<\/u>/gi;r.lastIndex=3;let i=r.exec(e);for(;i;){if(i[0].startsWith("`")){let t=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/.exec(e.slice(i.index));t&&(r.lastIndex=i.index+t[0].length)}else if(!i[0].startsWith(`\\`)){let t=e.slice(3,i.index);return t?{type:`underline`,raw:e.slice(0,r.lastIndex),text:t,tokens:n.inlineTokens(t)}:void 0}i=r.exec(e)}}},addCommands(){return{setUnderline:()=>({commands:e})=>e.setMark(this.name),toggleUnderline:()=>({commands:e})=>e.toggleMark(this.name),unsetUnderline:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}}),Dy=Ey,Oy=q.create({name:`starterKit`,addExtensions(){let e=[];return this.options.bold!==!1&&e.push(vh.configure(this.options.bold)),this.options.blockquote!==!1&&e.push(ph.configure(this.options.blockquote)),this.options.bulletList!==!1&&e.push(uv.configure(this.options.bulletList)),this.options.code!==!1&&e.push(Sh.configure(this.options.code)),this.options.codeBlock!==!1&&e.push(Eh.configure(this.options.codeBlock)),this.options.document!==!1&&e.push(Dh.configure(this.options.document)),this.options.dropcursor!==!1&&e.push(Am.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&e.push(jm.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&e.push(Oh.configure(this.options.hardBreak)),this.options.heading!==!1&&e.push(kh.configure(this.options.heading)),this.options.undoRedo!==!1&&e.push(nh.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&e.push(Ah.configure(this.options.horizontalRule)),this.options.italic!==!1&&e.push(Fh.configure(this.options.italic)),this.options.listItem!==!1&&e.push(Rv.configure(this.options.listItem)),this.options.listKeymap!==!1&&e.push(qv.configure(this.options?.listKeymap)),this.options.link!==!1&&e.push(av.configure(this.options?.link)),this.options.orderedList!==!1&&e.push(py.configure(this.options.orderedList)),this.options.paragraph!==!1&&e.push(xy.configure(this.options.paragraph)),this.options.strike!==!1&&e.push(wy.configure(this.options.strike)),this.options.text!==!1&&e.push(Ty.configure(this.options.text)),this.options.underline!==!1&&e.push(Ey.configure(this.options?.underline)),this.options.trailingNode!==!1&&e.push(th.configure(this.options?.trailingNode)),e}}),ky=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,Ay=um.create({name:`image`,addOptions(){return{inline:!1,allowBase64:!1,HTMLAttributes:{},resize:!1}},inline(){return this.options.inline},group(){return this.options.inline?`inline`:`block`},draggable:!0,addAttributes(){return{src:{default:null},alt:{default:null},title:{default:null},width:{default:null},height:{default:null}}},parseHTML(){return[{tag:this.options.allowBase64?`img[src]`:`img[src]:not([src^="data:"])`}]},renderHTML({HTMLAttributes:e}){return[`img`,K(this.options.HTMLAttributes,e)]},parseMarkdown:(e,t)=>t.createNode(`image`,{src:e.href,title:e.title,alt:e.text}),renderMarkdown:e=>{let t=e.attrs?.src??``,n=e.attrs?.alt??``,r=e.attrs?.title??``;return r?`![${n}](${t} "${r}")`:`![${n}](${t})`},addNodeView(){if(!this.options.resize||!this.options.resize.enabled||typeof document>`u`)return null;let{directions:e,minWidth:t,minHeight:n,alwaysPreserveAspectRatio:r}=this.options.resize,i=new Set([`src`,`width`,`height`]);return({node:a,getPos:o,HTMLAttributes:s,editor:c})=>{let l=document.createElement(`img`);l.draggable=!1;let u=K(this.options.HTMLAttributes,s);Object.entries(u).forEach(([e,t])=>{if(t!=null)switch(e){case`src`:case`width`:case`height`:break;default:l.setAttribute(e,t)}}),u.src!==null&&(l.src=u.src);let d={...s},f=e=>{typeof e==`string`&&e!==``?l.getAttribute(`src`)!==e&&(l.src=e):(l.hasAttribute(`src`)&&l.removeAttribute(`src`),l.src!==``&&(l.src=``))};f(s.src);let p=new lm({element:l,editor:c,node:a,getPos:o,onResize:(e,t)=>{l.style.width=`${e}px`,l.style.height=`${t}px`},onCommit:(e,t)=>{let n=o();n!==void 0&&this.editor.chain().setNodeSelection(n).updateAttributes(this.name,{width:e,height:t}).run()},onUpdate:e=>{if(e.type!==a.type)return!1;let t=yd(e,c.extensionManager.attributes.filter(t=>t.type===e.type.name));return Object.keys(d).forEach(e=>{!i.has(e)&&!(e in t)&&l.removeAttribute(e)}),Object.entries(t).forEach(([e,t])=>{i.has(e)||(t==null?l.removeAttribute(e):l.setAttribute(e,t))}),f(t.src),d=t,!0},options:{directions:e,min:{width:t,height:n},preserveAspectRatio:r===!0}}),m=p.dom,h=()=>{m.style.visibility=``,m.style.pointerEvents=``};return m.style.visibility=`hidden`,m.style.pointerEvents=`none`,l.complete&&l.naturalWidth>0?h():(l.onload=h,l.onerror=h),p}},addCommands(){return{setImage:e=>({commands:t})=>t.insertContent({type:this.name,attrs:e})}},addInputRules(){return[am({find:ky,type:this.type,getAttributes:e=>{let[,,t,n,r]=e;return{src:n,alt:t,title:r}}})]}}),jy=Ym,My,Ny;if(typeof WeakMap<`u`){let e=new WeakMap;My=t=>e.get(t),Ny=(t,n)=>(e.set(t,n),n)}else{let e=[],t=0;My=t=>{for(let n=0;n(t==10&&(t=0),e[t++]=n,e[t++]=r)}var Q=class{constructor(e,t,n,r){this.width=e,this.height=t,this.map=n,this.problems=r}findCell(e){for(let t=0;t=n){(a||=[]).push({type:`overlong_rowspan`,pos:c,n:f-e});break}let l=i+e*t;for(let e=0;er&&(a+=i.attrs.colspan)}}for(let e=0;e1&&(n=!0)}t==-1?t=a:t!=a&&(t=Math.max(t,a))}return t}function Iy(e,t,n){e.problems||=[];let r={};for(let i=0;i0;t--)if(e.node(t).type.spec.tableRole==`row`)return e.node(0).resolve(e.before(t+1));return null}function Vy(e){for(let t=e.depth;t>0;t--){let n=e.node(t).type.spec.tableRole;if(n===`cell`||n===`header_cell`)return e.node(t)}return null}function Hy(e){let t=e.selection.$head;for(let e=t.depth;e>0;e--)if(t.node(e).type.spec.tableRole==`row`)return!0;return!1}function Uy(e){let t=e.selection;if(`$anchorCell`in t&&t.$anchorCell)return t.$anchorCell.pos>t.$headCell.pos?t.$anchorCell:t.$headCell;if(`node`in t&&t.node&&t.node.type.spec.tableRole==`cell`)return t.$anchor;let n=By(t.$head)||Wy(t.$head);if(n)return n;throw RangeError(`No cell found around position ${t.head}`)}function Wy(e){for(let t=e.nodeAfter,n=e.pos;t;t=t.firstChild,n++){let r=t.type.spec.tableRole;if(r==`cell`||r==`header_cell`)return e.doc.resolve(n)}for(let t=e.nodeBefore,n=e.pos;t;t=t.lastChild,n--){let r=t.type.spec.tableRole;if(r==`cell`||r==`header_cell`)return e.doc.resolve(n-t.nodeSize)}}function Gy(e){return e.parent.type.spec.tableRole==`row`&&!!e.nodeAfter}function Ky(e){return e.node(0).resolve(e.pos+e.nodeAfter.nodeSize)}function qy(e,t){return e.depth==t.depth&&e.pos>=t.start(-1)&&e.pos<=t.end(-1)}function Jy(e,t,n){let r=e.node(-1),i=Q.get(r),a=e.start(-1),o=i.nextCell(e.pos-a,t,n);return o==null?null:e.node(0).resolve(a+o)}function Yy(e,t,n=1){let r={...e,colspan:e.colspan-n};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(t,n),r.colwidth.some(e=>e>0)||(r.colwidth=null)),r}function Xy(e,t,n=1){let r={...e,colspan:e.colspan+n};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let e=0;ee!=t.pos-i);s.unshift(t.pos-i);let c=s.map(e=>{let t=n.nodeAt(e);if(!t)throw RangeError(`No cell with offset ${e} found`);let r=i+e+1;return new sr(o.resolve(r),o.resolve(r+t.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=t}map(t,n){let r=t.resolve(n.map(this.$anchorCell.pos)),i=t.resolve(n.map(this.$headCell.pos));if(Gy(r)&&Gy(i)&&qy(r,i)){let t=this.$anchorCell.node(-1)!=r.node(-1);return t&&this.isRowSelection()?e.rowSelection(r,i):t&&this.isColSelection()?e.colSelection(r,i):new e(r,i)}return R.between(r,i)}content(){let e=this.$anchorCell.node(-1),t=Q.get(e),n=this.$anchorCell.start(-1),r=t.rectBetween(this.$anchorCell.pos-n,this.$headCell.pos-n),i={},a=[];for(let n=r.top;n0||u>0){let e=c.attrs;if(l>0&&(e=Yy(e,0,l)),u>0&&(e=Yy(e,e.colspan-u,u)),s.leftr.bottom){let e={...c.attrs,rowspan:Math.min(s.bottom,r.bottom)-Math.max(s.top,r.top)};c=s.top0)return!1;let n=e+this.$anchorCell.nodeAfter.attrs.rowspan,r=t+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(n,r)==this.$headCell.node(-1).childCount}static colSelection(t,n=t){let r=t.node(-1),i=Q.get(r),a=t.start(-1),o=i.findCell(t.pos-a),s=i.findCell(n.pos-a),c=t.node(0);return o.top<=s.top?(o.top>0&&(t=c.resolve(a+i.map[o.left])),s.bottom0&&(n=c.resolve(a+i.map[s.left])),o.bottom0)return!1;let a=r+this.$anchorCell.nodeAfter.attrs.colspan,o=i+this.$headCell.nodeAfter.attrs.colspan;return Math.max(a,o)==t.width}eq(t){return t instanceof e&&t.$anchorCell.pos==this.$anchorCell.pos&&t.$headCell.pos==this.$headCell.pos}static rowSelection(t,n=t){let r=t.node(-1),i=Q.get(r),a=t.start(-1),o=i.findCell(t.pos-a),s=i.findCell(n.pos-a),c=t.node(0);return o.left<=s.left?(o.left>0&&(t=c.resolve(a+i.map[o.top*i.width])),s.right0&&(n=c.resolve(a+i.map[s.top*i.width])),o.right{t.push(rc.node(n,n+e.nodeSize,{class:`selectedCell`}))}),U.create(e.doc,t)}function eb({$from:e,$to:t}){if(e.pos==t.pos||e.pos=0&&!(e.after(i+1)=0&&!(t.before(e+1)>t.start(e));e--,r--);return n==r&&/row|table/.test(e.node(i).type.spec.tableRole)}function tb({$from:e,$to:t}){let n,r;for(let t=e.depth;t>0;t--){let r=e.node(t);if(r.type.spec.tableRole===`cell`||r.type.spec.tableRole===`header_cell`){n=r;break}}for(let e=t.depth;e>0;e--){let n=t.node(e);if(n.type.spec.tableRole===`cell`||n.type.spec.tableRole===`header_cell`){r=n;break}}return n!==r&&t.parentOffset===0}function nb(e,t,n){let r=(t||e).selection,i=(t||e).doc,a,o;if(r instanceof z&&(o=r.node.type.spec.tableRole)){if(o==`cell`||o==`header_cell`)a=$.create(i,r.from);else if(o==`row`){let e=i.resolve(r.from+1);a=$.rowSelection(e,e)}else if(!n){let e=Q.get(r.node),t=r.from+1,n=t+e.map[e.width*e.height-1];a=$.create(i,t+1,n)}}else r instanceof R&&eb(r)?a=R.create(i,r.from):r instanceof R&&tb(r)&&(a=R.create(i,r.$from.start(),r.$from.end()));return a&&(t||=e.tr).setSelection(a),t}var rb=new V(`fix-tables`);function ib(e,t,n,r){let i=e.childCount,a=t.childCount;outer:for(let o=0,s=0;o{t.type.spec.tableRole==`table`&&(n=ob(e,t,r,n))};return t?t.doc!=e.doc&&ib(t.doc,e.doc,0,r):e.doc.descendants(r),n}function ob(e,t,n,r){let i=Q.get(t);if(!i.problems)return r;r||=e.tr;let a=[];for(let e=0;e0){let t=`cell`;n.firstChild&&(t=n.firstChild.type.spec.tableRole);let a=[];for(let n=0;n0?-1:0;Zy(t,r,i+a)&&(a=i==0||i==t.width?null:0);for(let o=0;o0&&i0&&t.map[s-1]==c||i0?-1:0;pb(t,r,i+s)&&(s=i==0||i==t.height?null:0);for(let a=0,c=t.width*i;a0&&i0&&l==t.map[o-t.width]){let t=n.nodeAt(l).attrs;e.setNodeMarkup(e.mapping.slice(s).map(l+r),null,{...t,rowspan:t.rowspan-1}),a+=t.colspan-1}else if(i0&&n[a]==n[a-1]||r.right0&&n[i]==n[i-e]||r.bottom0){let e=s+1+c.content.size,t=yb(c)?s+1:e;n.replaceWith(t+r.tableStart,e+r.tableStart,o)}n.setSelection(new $(n.doc.resolve(s+r.tableStart))),t(n)}return!0}function Sb(e,t){let n=Ry(e.schema);return Cb(({node:e})=>n[e.type.spec.tableRole])(e,t)}function Cb(e){return(t,n)=>{let r=t.selection,i,a;if(r instanceof $){if(r.$anchorCell.pos!=r.$headCell.pos)return!1;i=r.$anchorCell.nodeAfter,a=r.$anchorCell.pos}else{if(i=Vy(r.$from),!i)return!1;a=By(r.$from)?.pos}if(i==null||a==null||i.attrs.colspan==1&&i.attrs.rowspan==1)return!1;if(n){let o=i.attrs,s=[],c=o.colwidth;o.rowspan>1&&(o={...o,rowspan:1}),o.colspan>1&&(o={...o,colspan:1});let l=sb(t),u=t.tr;for(let e=0;e{n.attrs[e]!==t&&a.setNodeMarkup(r,null,{...n.attrs,[e]:t})}):a.setNodeMarkup(i.pos,null,{...i.nodeAfter.attrs,[e]:t}),r(a)}return!0}}function Tb(e){return function(t,n){if(!Hy(t))return!1;if(n){let r=Ry(t.schema),i=sb(t),a=t.tr,o=i.map.cellsInRect(e==`column`?{left:i.left,top:0,right:i.right,bottom:i.map.height}:e==`row`?{left:0,top:i.top,right:i.map.width,bottom:i.bottom}:i),s=o.map(e=>i.table.nodeAt(e));for(let e=0;e{let t=e+i.tableStart,n=a.doc.nodeAt(t);n&&a.setNodeMarkup(t,u,n.attrs)}),n(a)}return!0}}Db(`row`,{useDeprecatedLogic:!0}),Db(`column`,{useDeprecatedLogic:!0});var Ob=Db(`cell`,{useDeprecatedLogic:!0});function kb(e,t){if(t<0){let t=e.nodeBefore;if(t)return e.pos-t.nodeSize;for(let t=e.index(-1)-1,n=e.before();t>=0;t--){let r=e.node(-1).child(t),i=r.lastChild;if(i)return n-1-i.nodeSize;n-=r.nodeSize}}else{if(e.index()0;r--)if(n.node(r).type.spec.tableRole==`table`)return t&&t(e.tr.delete(n.before(r),n.after(r)).scrollIntoView()),!0;return!1}function Mb(e,t){let n=e.selection;if(!(n instanceof $))return!1;if(t){let r=e.tr,i=Ry(e.schema).cell.createAndFill().content;n.forEachCell((e,t)=>{e.content.eq(i)||r.replace(r.mapping.map(t+1),r.mapping.map(t+e.nodeSize-1),new I(i,0,0))}),r.docChanged&&t(r)}return!0}function Nb(e){if(e.size===0)return null;let{content:t,openStart:n,openEnd:r}=e;for(;t.childCount==1&&(n>0&&r>0||t.child(0).type.spec.tableRole==`table`);)n--,r--,t=t.child(0).content;let i=t.child(0),a=i.type.spec.tableRole,o=i.type.schema,s=[];if(a==`row`)for(let e=0;e=0;t--){let{rowspan:i,colspan:a}=r.child(t).attrs;for(let t=e;t=t.length&&t.push(P.empty),n[i]r&&(s=s.type.createChecked(Yy(s.attrs,s.attrs.colspan,n+s.attrs.colspan-r),s.content)),o.push(s),n+=s.attrs.colspan;for(let n=1;ni&&(t=t.type.create({...t.attrs,rowspan:Math.max(1,i-t.attrs.rowspan)},t.content)),o.push(t)}e.push(P.from(o))}n=e,t=i}return{width:e,height:t,rows:n}}function Lb(e,t,n,r,i,a,o){let s=e.doc.type.schema,c=Ry(s),l,u;if(i>t.width)for(let a=0,s=0;at.height){let s=[];for(let e=0,r=(t.height-1)*t.width;e=t.width?!1:n.nodeAt(t.map[r+e]).type==c.header_cell;s.push(i?u||=c.header_cell.createAndFill():l||=c.cell.createAndFill())}let d=c.row.create(null,P.from(s)),f=[];for(let e=t.height;e{if(!i)return!1;let a=n.selection;if(a instanceof $)return Hb(n,r,L.near(a.$headCell,t));if(e!=`horiz`&&!a.empty)return!1;let o=Jb(i,e,t);if(o==null)return!1;if(e==`horiz`)return Hb(n,r,L.near(n.doc.resolve(a.head+t),t));{let i=n.doc.resolve(o),a=Jy(i,e,t),s;return s=a?L.near(a,1):t<0?L.near(n.doc.resolve(i.before(-1)),-1):L.near(n.doc.resolve(i.after(-1)),1),Hb(n,r,s)}}}function Wb(e,t){return(n,r,i)=>{if(!i)return!1;let a=n.selection,o;if(a instanceof $)o=a;else{let r=Jb(i,e,t);if(r==null)return!1;o=new $(n.doc.resolve(r))}let s=Jy(o.$headCell,e,t);return s?Hb(n,r,new $(o.$anchorCell,s)):!1}}function Gb(e,t){let n=e.state.doc,r=By(n.resolve(t));return r?(e.dispatch(e.state.tr.setSelection(new $(r))),!0):!1}function Kb(e,t,n){if(!Hy(e.state))return!1;let r=Nb(n),i=e.state.selection;if(i instanceof $){r||={width:1,height:1,rows:[P.from(Fb(Ry(e.state.schema).cell,n))]};let t=i.$anchorCell.node(-1),a=i.$anchorCell.start(-1),o=Q.get(t).rectBetween(i.$anchorCell.pos-a,i.$headCell.pos-a);return r=Ib(r,o.right-o.left,o.bottom-o.top),Bb(e.state,e.dispatch,a,o,r),!0}if(r){let t=Uy(e.state),n=t.start(-1);return Bb(e.state,e.dispatch,n,Q.get(t.node(-1)).findCell(t.pos-n),r),!0}return!1}function qb(e,t){if(t.button!=0||t.ctrlKey||t.metaKey)return;let n=Yb(e,t.target),r;if(t.shiftKey&&e.state.selection instanceof $)i(e.state.selection.$anchorCell,t),t.preventDefault();else if(t.shiftKey&&n&&(r=By(e.state.selection.$anchor))!=null&&Xb(e,t)?.pos!=r.pos)i(r,t),t.preventDefault();else if(!n)return;function i(t,n){let r=Xb(e,n),i=zy.getState(e.state)==null;if(!r||!qy(t,r)){if(i)r=t;else return}let a=new $(t,r);if(i||!e.state.selection.eq(a)){let n=e.state.tr.setSelection(a);i&&n.setMeta(zy,t.pos),e.dispatch(n)}}function a(){e.root.removeEventListener(`mouseup`,a),e.root.removeEventListener(`dragstart`,a),e.root.removeEventListener(`mousemove`,o),zy.getState(e.state)!=null&&e.dispatch(e.state.tr.setMeta(zy,-1))}function o(r){let o=r,s=zy.getState(e.state),c;if(s!=null)c=e.state.doc.resolve(s);else if(Yb(e,o.target)!=n&&(c=Xb(e,t),!c))return a();c&&i(c,o)}e.root.addEventListener(`mouseup`,a),e.root.addEventListener(`dragstart`,a),e.root.addEventListener(`mousemove`,o)}function Jb(e,t,n){if(!(e.state.selection instanceof R))return null;let{$head:r}=e.state.selection;for(let i=r.depth-1;i>=0;i--){let a=r.node(i);if((n<0?r.index(i):r.indexAfter(i))!=(n<0?0:a.childCount))return null;if(a.type.spec.tableRole==`cell`||a.type.spec.tableRole==`header_cell`){let a=r.before(i),o=t==`vert`?n>0?`down`:`up`:n>0?`right`:`left`;return e.endOfTextblock(o)?a:null}}return null}function Yb(e,t){for(;t&&t!=e.dom;t=t.parentNode)if(t.nodeName==`TD`||t.nodeName==`TH`)return t;return null}function Xb(e,t){let n=e.posAtCoords({left:t.clientX,top:t.clientY});if(!n)return null;let{inside:r,pos:i}=n;return r>=0&&By(e.state.doc.resolve(r))||By(e.state.doc.resolve(i))}var Zb=class{constructor(e,t){this.node=e,this.defaultCellMinWidth=t,this.dom=document.createElement(`div`),this.dom.className=`tableWrapper`,this.table=this.dom.appendChild(document.createElement(`table`)),this.table.style.setProperty(`--default-cell-min-width`,`${t}px`),this.colgroup=this.table.appendChild(document.createElement(`colgroup`)),Qb(e,this.colgroup,this.table,t),this.contentDOM=this.table.appendChild(document.createElement(`tbody`))}update(e){return e.type==this.node.type&&(this.node=e,Qb(e,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(e){return e.type==`attributes`&&(e.target==this.table||this.colgroup.contains(e.target))}};function Qb(e,t,n,r,i,a){let o=0,s=!0,c=t.firstChild,l=e.firstChild;if(l){for(let e=0,n=0;enew r(e,n,t)),new tx(-1,!1)},apply(e,t){return t.apply(e)}},props:{attributes:e=>{let t=$b.getState(e);return t&&t.activeHandle>-1?{class:`resize-cursor`}:{}},handleDOMEvents:{mousemove:(t,n)=>{nx(t,n,e,i)},mouseleave:e=>{rx(e)},mousedown:(e,r)=>{ix(e,r,t,n)}},decorations:e=>{let t=$b.getState(e);if(t&&t.activeHandle>-1)return px(e,t.activeHandle)},nodeViews:{}}});return a}var tx=class e{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(t){let n=this,r=t.getMeta($b);if(r&&r.setHandle!=null)return new e(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new e(n.activeHandle,r.setDragging);if(n.activeHandle>-1&&t.docChanged){let r=t.mapping.map(n.activeHandle,-1);return Gy(t.doc.resolve(r))||(r=-1),new e(r,n.dragging)}return n}};function nx(e,t,n,r){if(!e.editable)return;let i=$b.getState(e.state);if(i&&!i.dragging){let a=ox(t.target),o=-1;if(a){let{left:r,right:i}=a.getBoundingClientRect();t.clientX-r<=n?o=sx(e,t,`left`,n):i-t.clientX<=n&&(o=sx(e,t,`right`,n))}if(o!=i.activeHandle){if(!r&&o!==-1){let t=e.state.doc.resolve(o),n=t.node(-1),r=Q.get(n),i=t.start(-1);if(r.colCount(t.pos-i)+t.nodeAfter.attrs.colspan-1==r.width-1)return}lx(e,o)}}}function rx(e){if(!e.editable)return;let t=$b.getState(e.state);t&&t.activeHandle>-1&&!t.dragging&&lx(e,-1)}function ix(e,t,n,r){if(!e.editable)return!1;let i=e.dom.ownerDocument.defaultView??window,a=$b.getState(e.state);if(!a||a.activeHandle==-1||a.dragging)return!1;let o=e.state.doc.nodeAt(a.activeHandle),s=ax(e,a.activeHandle,o.attrs);e.dispatch(e.state.tr.setMeta($b,{setDragging:{startX:t.clientX,startWidth:s}}));function c(t){i.removeEventListener(`mouseup`,c),i.removeEventListener(`mousemove`,l);let r=$b.getState(e.state);r?.dragging&&(ux(e,r.activeHandle,cx(r.dragging,t,n)),e.dispatch(e.state.tr.setMeta($b,{setDragging:null})))}function l(t){if(!t.which)return c(t);let i=$b.getState(e.state);if(i&&i.dragging){let a=cx(i.dragging,t,n);dx(e,i.activeHandle,a,r)}}return dx(e,a.activeHandle,s,r),i.addEventListener(`mouseup`,c),i.addEventListener(`mousemove`,l),t.preventDefault(),!0}function ax(e,t,{colspan:n,colwidth:r}){let i=r&&r[r.length-1];if(i)return i;let a=e.domAtPos(t),o=a.node.childNodes[a.offset].offsetWidth,s=n;if(r)for(let e=0;egx(e),renderHTML:e=>{let t=hx(e.align);return hp(t)?{style:`text-align: ${t}`}:{}}}}function yx(e){let t=e.parentElement,n=e.closest(`table`);if(!t||!n)return null;let r=Array.from(t.children).indexOf(e),i=n.querySelectorAll(`colgroup > col`)[r]?.getAttribute(`width`);return i?[parseInt(i,10)]:null}function bx(e){let t=e.getAttribute(`colwidth`);return t?t.split(`,`).map(e=>parseInt(e,10)):yx(e)}var xx=/[ \t\r\n\f]+/g;function Sx(e){return e.children.length>0?!1:(e.textContent??``).replace(xx,``)===``}function Cx(e){let t=e.createAndFill();if(!t)throw Error(`[tiptap error]: "${e.name}" has no default content to backfill.`);return t.content}function wx(e,t,n){if(!(n in t))return;let r=t[n];(r===1||r===`1`||r==null)&&delete e[n]}var Tx=um.create({name:`tableCell`,addOptions(){return{HTMLAttributes:{}}},content:`block+`,addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:bx},align:vx()}},tableRole:`cell`,isolating:!0,parseHTML(){return[{tag:`td`,getAttrs:e=>Sx(e)?{}:!1,getContent:(e,t)=>Cx(t.nodes[this.name])},{tag:`td`}]},renderHTML({HTMLAttributes:e}){let t=K(this.options.HTMLAttributes,e);return wx(t,e,`colspan`),wx(t,e,`rowspan`),[`td`,t,0]}}),Ex=um.create({name:`tableHeader`,addOptions(){return{HTMLAttributes:{}}},content:`block+`,addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:bx},align:vx()}},tableRole:`header_cell`,isolating:!0,parseHTML(){return[{tag:`th`,getAttrs:e=>Sx(e)?{}:!1,getContent:(e,t)=>Cx(t.nodes[this.name])},{tag:`th`}]},renderHTML({HTMLAttributes:e}){let t=K(this.options.HTMLAttributes,e);return wx(t,e,`colspan`),wx(t,e,`rowspan`),[`th`,t,0]}}),Dx=um.create({name:`tableRow`,addOptions(){return{HTMLAttributes:{}}},content:`(tableCell | tableHeader)*`,tableRole:`row`,parseHTML(){return[{tag:`tr`}]},renderHTML({HTMLAttributes:e}){return[`tr`,K(this.options.HTMLAttributes,e),0]}});function Ox(e,t){return t?[`width`,`${Math.max(t,e)}px`]:[`min-width`,`${e}px`]}function kx(e,t,n,r,i,a){let o=0,s=!0,c=t.firstChild,l=e.firstChild;if(l!==null)for(let e=0,n=0;e{let r=e.nodes[n];r.spec.tableRole&&(t[r.spec.tableRole]=r)}),e.cached.tableNodeTypes=t,t}function Px(e,t,n,r,i){let a=Nx(e),o=[],s=[];for(let e=0;e{let{selection:t}=e.state;if(!Fx(t))return!1;let n=0;return td(t.ranges[0].$from,e=>e.type.name===`table`)?.node.descendants(e=>{if(e.type.name===`table`)return!1;[`tableCell`,`tableHeader`].includes(e.type.name)&&(n+=1)}),n===t.ranges.length&&(e.commands.deleteTable(),!0)};function Lx(e,t){let n=e.mapping.map(t);if(td(e.selection.$from,e=>e.type.name===`table`)?.pos===n)return;let r=e.doc.nodeAt(n);if(!r)return;let i=n+r.nodeSize-1;e.setSelection(R.near(e.doc.resolve(i),-1))}function Rx(e){let t=``,n=0;for(;ne===`|`?`\\|`:e)+e.slice(i,i+r),n=i+r,a=!0;break}i+=o}a||(t+=e.slice(n,n+r),n+=r)}return t}function zx(e){return e.split(` `).map(e=>!e.includes(`|`)||!e.includes("`")?e:Rx(e)).join(` `)}function Bx(e){return(e||``).replaceAll(``,` `).replace(/\s+/g,` `).trim()}function Vx(e,t){return t?e.split(t).join(` `):e}function Hx(e){return e.replace(/\\.|\|/g,e=>e===`|`?`\\|`:e)}function Ux(e,t,n={}){if(!e||!e.content||e.content.length===0)return``;let r=[];e.content.forEach(e=>{let i=[];e.content&&e.content.forEach(e=>{let r=``;r=e.content&&Array.isArray(e.content)&&e.content.length>1?e.content.map(e=>Vx(t.renderChildren(e),n.cellLineSeparator)).join(` `):Vx(e.content?t.renderChildren(e.content):``,n.cellLineSeparator);let a=Hx(Bx(r.replace(/[ \t]*\r?\n[ \t]*/g,`
`))),o=e.type===`tableHeader`,s=_x(e.attrs);i.push({text:a,isHeader:o,align:s})}),r.push(i)});let i=r.reduce((e,t)=>Math.max(e,t.length),0);if(i===0)return``;let a=Array.from({length:i}).fill(0);r.forEach(e=>{for(let t=0;ta[t]&&(a[t]=n),a[t]<3&&(a[t]=3)}});let o=(e,t)=>e+` `.repeat(Math.max(0,t-e.length)),s=r[0],c=s.some(e=>e.isHeader),l=Array.from({length:i}).fill(null);r.forEach(e=>{for(let t=0;tc&&s[t]&&s[t].text||``);return u+=`| ${d.map((e,t)=>o(e,a[t])).join(` | `)} |\n`,u+=`| ${a.map((e,t)=>{let n=Math.max(3,e),r=l[t];return r===`left`?`:${`-`.repeat(n)}`:r===`right`?`${`-`.repeat(n)}:`:r===`center`?`:${`-`.repeat(n)}:`:`-`.repeat(n)}).join(` | `)} |\n`,(c?r.slice(1):r).forEach(e=>{u+=`| ${Array.from({length:i}).fill(0).map((t,n)=>o(e[n]&&e[n].text||``,a[n])).join(` | `)} |\n`}),u}var Wx=new H(`preserveCellSelectionOnContextMenu`);function Gx(e,t){let n=e.posAtCoords({left:t.clientX,top:t.clientY});if(n)return n.pos;if(!(t.target instanceof Node))return null;try{return e.posAtDOM(t.target,0)}catch{return null}}function Kx(e,t){let n=!1;return e.forEachCell((e,r)=>{t>=r&&t{let n=[],r=Array.isArray(e.align)?e.align:[];if(e.header){let i=[];e.header.forEach((e,n)=>{let a=hx(r[n]??e.align),o=a?{align:a}:{};i.push(t.createNode(`tableHeader`,o,[{type:`paragraph`,content:t.parseInline(e.tokens)}]))}),n.push(t.createNode(`tableRow`,{},i))}return e.rows&&e.rows.forEach(e=>{let i=[];e.forEach((e,n)=>{let a=hx(r[n]??e.align),o=a?{align:a}:{};i.push(t.createNode(`tableCell`,o,[{type:`paragraph`,content:t.parseInline(e.tokens)}]))}),n.push(t.createNode(`tableRow`,{},i))}),t.createNode(`table`,void 0,n)},renderMarkdown:(e,t)=>Ux(e,t),markdownTokenizer:{name:`table`,level:`block`,start:e=>{let t=e.split(` +`,d=Array.from({length:i}).map((e,t)=>c&&s[t]&&s[t].text||``);return u+=`| ${d.map((e,t)=>o(e,a[t])).join(` | `)} |\n`,u+=`| ${a.map((e,t)=>{let n=Math.max(3,e),r=l[t];return r===`left`?`:${`-`.repeat(n)}`:r===`right`?`${`-`.repeat(n)}:`:r===`center`?`:${`-`.repeat(n)}:`:`-`.repeat(n)}).join(` | `)} |\n`,(c?r.slice(1):r).forEach(e=>{u+=`| ${Array.from({length:i}).fill(0).map((t,n)=>o(e[n]&&e[n].text||``,a[n])).join(` | `)} |\n`}),u}var Wx=new V(`preserveCellSelectionOnContextMenu`);function Gx(e,t){let n=e.posAtCoords({left:t.clientX,top:t.clientY});if(n)return n.pos;if(!(t.target instanceof Node))return null;try{return e.posAtDOM(t.target,0)}catch{return null}}function Kx(e,t){let n=!1;return e.forEachCell((e,r)=>{t>=r&&t{let n=[],r=Array.isArray(e.align)?e.align:[];if(e.header){let i=[];e.header.forEach((e,n)=>{let a=hx(r[n]??e.align),o=a?{align:a}:{};i.push(t.createNode(`tableHeader`,o,[{type:`paragraph`,content:t.parseInline(e.tokens)}]))}),n.push(t.createNode(`tableRow`,{},i))}return e.rows&&e.rows.forEach(e=>{let i=[];e.forEach((e,n)=>{let a=hx(r[n]??e.align),o=a?{align:a}:{};i.push(t.createNode(`tableCell`,o,[{type:`paragraph`,content:t.parseInline(e.tokens)}]))}),n.push(t.createNode(`tableRow`,{},i))}),t.createNode(`table`,void 0,n)},renderMarkdown:(e,t)=>Ux(e,t),markdownTokenizer:{name:`table`,level:`block`,start:e=>{let t=e.split(` `);if(t.length<2)return-1;let n=t[1];return!/^[ \t|:]*-[ \t|:-]*$/.test(n)||!n.includes(`|`)?-1:t[0].includes(`|`)?0:-1},tokenize(e,t,n){let r=e.indexOf(` `),i=r>=0?e.slice(0,r):e,a=i.split(` `);if(a.length<2)return;let o=a[1];if(!/^[ \t|:]*-[ \t|:-]*$/.test(o)||!o.includes(`|`))return;let s=zx(i);if(s===i)return;let c=n.blockTokens(s)[0];if(c?.type!==`table`||!c.raw)return;let l=c.raw.split(` `).length,u=e.split(` `).slice(0,l).join(` -`);return{...c,raw:u}}},addCommands(){return{insertTable:({rows:e=3,cols:t=3,withHeaderRow:n=!0}={})=>({tr:r,dispatch:i,editor:a})=>{let o=Px(a.schema,e,t,n);if(i){let e=r.selection.from+1;r.replaceSelectionWith(o).scrollIntoView().setSelection(z.near(r.doc.resolve(e)))}return!0},addColumnBefore:()=>({state:e,dispatch:t})=>lb(e,t),addColumnAfter:()=>({state:e,dispatch:t})=>ub(e,t),deleteColumn:()=>({state:e,dispatch:t})=>{let n=ed(e.selection.$from,e=>e.type.name===`table`);return fb(e,t&&(e=>{n&&Lx(e,n.pos),t(e)}))},addRowBefore:()=>({state:e,dispatch:t})=>hb(e,t),addRowAfter:()=>({state:e,dispatch:t})=>gb(e,t),deleteRow:()=>({state:e,dispatch:t})=>{let n=ed(e.selection.$from,e=>e.type.name===`table`);return vb(e,t&&(e=>{n&&Lx(e,n.pos),t(e)}))},deleteTable:()=>({state:e,dispatch:t})=>jb(e,t),mergeCells:()=>({state:e,dispatch:t})=>xb(e,t),splitCell:()=>({state:e,dispatch:t})=>Sb(e,t),toggleHeaderColumn:()=>({state:e,dispatch:t})=>Db(`column`)(e,t),toggleHeaderRow:()=>({state:e,dispatch:t})=>Db(`row`)(e,t),toggleHeaderCell:()=>({state:e,dispatch:t})=>Ob(e,t),mergeOrSplit:()=>({state:e,dispatch:t})=>xb(e,t)?!0:Sb(e,t),setCellAttribute:(e,t)=>({state:n,dispatch:r})=>wb(e,t)(n,r),goToNextCell:()=>({state:e,dispatch:t})=>Ab(1)(e,t),goToPreviousCell:()=>({state:e,dispatch:t})=>Ab(-1)(e,t),fixTables:()=>({state:e,dispatch:t})=>(t&&ab(e),!0),setCellSelection:e=>({tr:t,dispatch:n})=>{if(n){let n=$.create(t.doc,e.anchorCell,e.headCell);t.setSelection(n)}return!0}}},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.goToNextCell()?!0:this.editor.can().addRowAfter()?this.editor.chain().addRowAfter().goToNextCell().run():!1,"Shift-Tab":()=>this.editor.commands.goToPreviousCell(),Backspace:Ix,"Mod-Backspace":Ix,Delete:Ix,"Mod-Delete":Ix}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[ex({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:null,lastColumnResizable:this.options.lastColumnResizable})]:[],mx({allowTableNodeSelection:this.options.allowTableNodeSelection}),qx()]},addNodeView(){let e=this.options.View;return e?({node:t,view:n,HTMLAttributes:r})=>{let i=q(this.options.HTMLAttributes,r);return new e(t,this.options.cellMinWidth,n,i)}:null},extendNodeSchema(e){return{tableRole:K(G(e,`tableRole`,{name:e.name,options:e.options,storage:e.storage}))}}});J.create({name:`tableKit`,addExtensions(){let e=[];return this.options.table!==!1&&e.push(Jx.configure(this.options.table)),this.options.tableCell!==!1&&e.push(Tx.configure(this.options.tableCell)),this.options.tableHeader!==!1&&e.push(Ex.configure(this.options.tableHeader)),this.options.tableRow!==!1&&e.push(Dx.configure(this.options.tableRow)),e}});var Yx=20,Xx=(e,t=0)=>{let n=[];return!e.children.length||t>Yx||Array.from(e.children).forEach(e=>{e.tagName===`SPAN`?n.push(e):e.children.length&&n.push(...Xx(e,t+1))}),n},Zx=e=>{if(!e.children.length)return;let t=Xx(e);t&&t.forEach(e=>{var t;let n=e.getAttribute(`style`),r=(t=e.parentElement)==null||(t=t.closest(`span`))==null?void 0:t.getAttribute(`style`);e.setAttribute(`style`,`${r};${n}`)})},Qx=Mp.create({name:`textStyle`,priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!0}},parseHTML(){return[{tag:`span`,consuming:!1,getAttrs:e=>e.hasAttribute(`style`)?(this.options.mergeNestedSpanStyles&&Zx(e),{}):!1}]},renderHTML({HTMLAttributes:e}){return[`span`,q(this.options.HTMLAttributes,e),0]},addCommands(){return{toggleTextStyle:e=>({commands:t})=>t.toggleMark(this.name,e),removeEmptyTextStyle:()=>({tr:e})=>{let{selection:t}=e;return e.doc.nodesBetween(t.from,t.to,(t,n)=>{if(!t.isInline)return!0;t.marks.filter(e=>e.type===this.type).some(e=>Object.values(e.attrs).some(e=>!!e))||e.removeMark(n,n+t.nodeSize,this.type)}),!0}}}}),$x=J.create({name:`backgroundColor`,addOptions(){return{types:[`textStyle`]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{backgroundColor:{default:null,parseHTML:e=>(up(e,`background-color`)??e.style.backgroundColor)?.replace(/['"]+/g,``),renderHTML:e=>mp(e.backgroundColor)?{style:`background-color: ${e.backgroundColor}`}:{}}}}]},addCommands(){return{setBackgroundColor:e=>({chain:t})=>t().setMark(`textStyle`,{backgroundColor:e}).run(),unsetBackgroundColor:()=>({chain:e})=>e().setMark(`textStyle`,{backgroundColor:null}).removeEmptyTextStyle().run()}}}),eS=J.create({name:`color`,addOptions(){return{types:[`textStyle`]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{color:{default:null,parseHTML:e=>(up(e,`color`)??e.style.color)?.replace(/['"]+/g,``),renderHTML:e=>mp(e.color)?{style:`color: ${e.color}`}:{}}}}]},addCommands(){return{setColor:e=>({chain:t})=>t().setMark(`textStyle`,{color:e}).run(),unsetColor:()=>({chain:e})=>e().setMark(`textStyle`,{color:null}).removeEmptyTextStyle().run()}}}),tS=J.create({name:`fontFamily`,addOptions(){return{types:[`textStyle`]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontFamily:{default:null,parseHTML:e=>up(e,`font-family`)??e.style.fontFamily,renderHTML:e=>mp(e.fontFamily)?{style:`font-family: ${e.fontFamily}`}:{}}}}]},addCommands(){return{setFontFamily:e=>({chain:t})=>t().setMark(`textStyle`,{fontFamily:e}).run(),unsetFontFamily:()=>({chain:e})=>e().setMark(`textStyle`,{fontFamily:null}).removeEmptyTextStyle().run()}}}),nS=J.create({name:`fontSize`,addOptions(){return{types:[`textStyle`]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontSize:{default:null,parseHTML:e=>up(e,`font-size`)??e.style.fontSize,renderHTML:e=>mp(e.fontSize)?{style:`font-size: ${e.fontSize}`}:{}}}}]},addCommands(){return{setFontSize:e=>({chain:t})=>t().setMark(`textStyle`,{fontSize:e}).run(),unsetFontSize:()=>({chain:e})=>e().setMark(`textStyle`,{fontSize:null}).removeEmptyTextStyle().run()}}}),rS=J.create({name:`lineHeight`,addOptions(){return{types:[`textStyle`]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{lineHeight:{default:null,parseHTML:e=>up(e,`line-height`)??e.style.lineHeight,renderHTML:e=>mp(e.lineHeight)?{style:`line-height: ${e.lineHeight}`}:{}}}}]},addCommands(){return{setLineHeight:e=>({chain:t})=>t().setMark(`textStyle`,{lineHeight:e}).run(),unsetLineHeight:()=>({chain:e})=>e().setMark(`textStyle`,{lineHeight:null}).removeEmptyTextStyle().run()}}}),iS=J.create({name:`textStyleKit`,addExtensions(){let e=[];return this.options.backgroundColor!==!1&&e.push($x.configure(this.options.backgroundColor)),this.options.color!==!1&&e.push(eS.configure(this.options.color)),this.options.fontFamily!==!1&&e.push(tS.configure(this.options.fontFamily)),this.options.fontSize!==!1&&e.push(nS.configure(this.options.fontSize)),this.options.lineHeight!==!1&&e.push(rS.configure(this.options.lineHeight)),this.options.textStyle!==!1&&e.push(Qx.configure(this.options.textStyle)),e}}),aS=J.create({name:`textAlign`,addOptions(){return{types:[],alignments:[`left`,`center`,`right`,`justify`],defaultAlignment:null}},addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:e=>{let t=e.style.textAlign;return this.options.alignments.includes(t)?t:this.options.defaultAlignment},renderHTML:e=>!mp(e.textAlign)||!this.options.alignments.includes(e.textAlign)?{}:{style:`text-align: ${e.textAlign}`}}}}]},addCommands(){return{setTextAlign:e=>({commands:t})=>this.options.alignments.includes(e)?this.options.types.map(n=>t.updateAttributes(n,{textAlign:e})).some(e=>e):!1,unsetTextAlign:()=>({commands:e})=>this.options.types.map(t=>e.resetAttributes(t,`textAlign`)).some(e=>e),toggleTextAlign:e=>({editor:t,commands:n})=>this.options.alignments.includes(e)?t.isActive({textAlign:e})?n.unsetTextAlign():n.setTextAlign(e):!1}},addKeyboardShortcuts(){return{"Mod-Shift-l":()=>this.editor.commands.setTextAlign(`left`),"Mod-Shift-e":()=>this.editor.commands.setTextAlign(`center`),"Mod-Shift-r":()=>this.editor.commands.setTextAlign(`right`),"Mod-Shift-j":()=>this.editor.commands.setTextAlign(`justify`)}}});function oS(e){return{default:null,parseHTML:t=>t.getAttribute(e),renderHTML:t=>t[e]?{[e]:t[e]}:{}}}function sS(e,t){return e.extend({addAttributes(){let e={...this.parent?.()??{}};return t.forEach(t=>{e[t]=oS(t)}),e}})}var cS=[`style`,`class`,`align`,`valign`,`bgcolor`,`width`],lS=[`style`,`class`,`border`,`cellpadding`,`cellspacing`,`width`,`align`],uS=[`style`,`class`],dS=[{value:`left`,name:`alignLeft`,title:`fields.editor.align_left`},{value:`center`,name:`alignCenter`,title:`fields.editor.align_center`},{value:`right`,name:`alignRight`,title:`fields.editor.align_right`},{value:`justify`,name:`alignJustify`,title:`fields.editor.align_justify`}],fS=aS.extend({addGlobalAttributes(){let{types:e,alignments:t}=this.options;return[{types:e,attributes:{textAlign:{default:null,parseHTML:e=>{let n=e.style.textAlign||e.getAttribute(`align`)||``;return t.includes(n)?n:null},renderHTML:e=>e.textAlign?{style:`text-align: ${e.textAlign}`}:{}}}}]}}).configure({types:[`paragraph`,`heading`,`blockquote`],alignments:dS.map(e=>e.value)});function pS({placeholder:e=P(`fields.editor.placeholder`),extra:t=[]}={}){return[Oy.configure({link:!1,underline:!1}),Dy,ov.configure({openOnClick:!1}),Ay.configure({inline:!0}),iS,fS,sS(Jx,lS),sS(Dx,uS),sS(Ex,cS),sS(Tx,cS),jy.configure({placeholder:e}),...t]}function mS(e,t){let n=()=>!!e.value?.isActive(`table`),r=()=>e.value?.chain().focus();return[{name:`table`,title:P(`fields.editor.table_insert`),icon:t.table,action:()=>r()?.insertTable({rows:3,cols:3,withHeaderRow:!0}).run()},{name:`addRowAfter`,title:P(`fields.editor.table_add_row`),icon:t.rowPlus,action:()=>r()?.addRowAfter().run(),visible:n},{name:`deleteRow`,title:P(`fields.editor.table_delete_row`),icon:t.rowMinus,action:()=>r()?.deleteRow().run(),visible:n},{name:`addColumnAfter`,title:P(`fields.editor.table_add_column`),icon:t.columnPlus,action:()=>r()?.addColumnAfter().run(),visible:n},{name:`deleteColumn`,title:P(`fields.editor.table_delete_column`),icon:t.columnMinus,action:()=>r()?.deleteColumn().run(),visible:n},{name:`mergeOrSplit`,title:P(`fields.editor.table_merge_split`),icon:t.mergeCells,action:()=>r()?.mergeOrSplit().run(),visible:n},{name:`deleteTable`,title:P(`fields.editor.table_delete`),icon:t.tableMinus,action:()=>r()?.deleteTable().run(),visible:n}]}function hS(e,t){let n=()=>dS.find(({value:t})=>e.value?.isActive({textAlign:t}))?.value??`left`;return dS.map(({value:r,name:i,title:a})=>({name:i,title:P(a),icon:t[i],action:()=>e.value?.chain().focus().setTextAlign(r).run(),isActive:()=>n()===r}))}function gS(e){let t=e?.view,n=typeof window>`u`?null:window.getSelection();if(!t||!n||n.rangeCount===0)return null;let{anchorNode:r,anchorOffset:i,focusNode:a,focusOffset:o}=n;if(!r||!t.dom.contains(r))return null;try{let e=t.posAtDOM(r,i),n=a&&t.dom.contains(a)?t.posAtDOM(a,o):e;return{from:Math.min(e,n),to:Math.max(e,n)}}catch{return null}}function _S(e,t,n=null){if(!e)return;let r=e.state.doc.content.size,i=e.chain().focus().setTextSelection(n??{from:r,to:r});if(t.is_image)i.setImage({src:t.url});else{let e=t.filename||t.url;i.insertContent(`${e}`)}i.run()}var vS={class:`relative bg-surface rounded-xl shadow-2xl w-full max-w-4xl max-h-[90vh] flex flex-col mx-4`},yS={class:`flex items-center justify-between px-6 py-4 border-b border-line`},bS={class:`text-lg font-semibold text-fg`},xS={class:`flex items-center gap-3 px-6 py-3 border-b border-line bg-surface-alt`},SS={class:`flex items-center gap-1 ml-2`},CS=[`onClick`],wS={value:0},TS=[`value`],ES={class:`ml-auto relative`},DS=[`placeholder`],OS={key:0,class:`px-6 py-2 bg-accent-soft border-b border-accent-soft`},kS={class:`flex items-center gap-3`},AS={class:`text-sm text-accent-soft-fg`},jS={key:1,class:`px-6 py-2 bg-danger-soft border-b border-danger-soft`},MS={class:`flex items-center justify-between`},NS={class:`text-sm text-danger-soft-fg`},PS={class:`flex-1 overflow-y-auto p-6`},FS={key:0,class:`flex items-center justify-center py-16`},IS={key:1,class:`flex flex-col items-center justify-center py-16 text-muted`},LS={class:`text-sm`},RS={key:2,class:`grid grid-cols-4 sm:grid-cols-6 gap-3`},zS=[`onClick`,`onDblclick`],BS={class:`w-full aspect-square rounded-md overflow-hidden bg-off flex items-center justify-center mb-2`},VS=[`src`,`alt`],HS={key:1,class:`flex flex-col items-center justify-center text-muted`},US={key:0,class:`w-10 h-10 text-accent`,fill:`currentColor`,viewBox:`0 0 24 24`},WS={key:1,class:`w-10 h-10 text-danger`,fill:`currentColor`,viewBox:`0 0 24 24`},GS={key:2,class:`w-10 h-10 text-success`,fill:`currentColor`,viewBox:`0 0 24 24`},KS={key:3,class:`w-10 h-10`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`},qS={class:`text-xs mt-1 font-medium uppercase`},JS=[`title`],YS=[`onClick`,`title`],XS={key:3,class:`flex justify-center mt-6`},ZS=[`disabled`],QS={class:`flex items-center justify-between px-6 py-4 border-t border-line bg-surface-alt rounded-b-xl`},$S={key:0,class:`flex items-center gap-3 text-sm text-muted min-w-0 flex-1 mr-4`},eC={class:`truncate`},tC={class:`text-muted flex-shrink-0`},nC={key:1,class:`text-sm text-muted`},rC={class:`flex items-center gap-2 flex-shrink-0`},iC=[`disabled`],aC=`image/jpeg,image/png,image/gif,image/webp,application/pdf,.doc,.docx,.xls,.xlsx`,oC={__name:`FileManager`,props:{show:{type:Boolean,default:!1},type:{type:String,default:`all`},uploadUrl:{type:String,default:`/admin/upload`},listUrl:{type:String,default:`/admin/filemanager`},deleteUrl:{type:String,default:`/admin/filemanager`}},emits:[`select`,`close`],setup(e,{emit:t}){let n=e,i=t,a=w(null),u=w([]),d=w(null),f=w(!1),p=w(!1),m=w(``),b=w(n.type),x=w([]),S=w(0),C=w(``),T=w(1),D=w(1),ee=w(!1),te=null,ne=[{value:`all`,label:`files.filters.all`},{value:`image`,label:`files.filters.images`},{value:`document`,label:`files.filters.documents`}];async function re(e=!1){f.value=!0;try{let t=new URLSearchParams({type:b.value,search:C.value,collection:String(S.value||``),page:String(T.value)}),r=await fetch(`${n.listUrl}?${t}`,{headers:{Accept:`application/json`}});if(!r.ok)throw Error(`Failed to load files`);let i=await r.json();e?u.value=[...u.value,...i.files]:u.value=i.files,x.value=i.collections||[],D.value=i.last_page,ee.value=T.value{T.value=1,re()},300)}c([b,S],()=>{T.value=1,d.value=null,re()}),c(()=>n.show,e=>{e&&(b.value=n.type,S.value=0,T.value=1,d.value=null,C.value=``,m.value=``,re())});function se(){a.value?.click()}async function le(e){let t=Array.from(e.target.files);if(t.length){p.value=!0,m.value=``;for(let e of t)await N(e);p.value=!1,e.target.value=``,T.value=1,await re()}}async function N(e){let t=new FormData;t.append(`file`,e);try{let r=await fetch(n.uploadUrl,{method:`POST`,body:t,headers:fe()});if(!r.ok)throw Error(await pe(r,P(`files.errors.upload_failed`,{name:e.name})));let i=await r.json();d.value=i}catch(t){m.value=t.message||P(`files.errors.upload_failed`,{name:e.name})}}async function de(e){if(confirm(P(`files.remove_confirm`,{name:e.filename})))try{let t=await fetch(n.deleteUrl,{method:`DELETE`,headers:fe({"Content-Type":`application/json`}),body:JSON.stringify({id:e.id,path:e.path})});if(!t.ok)throw Error(await pe(t,P(`files.errors.remove_failed`,{name:e.filename})));u.value=u.value.filter(t=>t.id!==e.id),d.value?.id===e.id&&(d.value=null)}catch(e){m.value=e.message||P(`files.errors.delete_failed`)}}function me(e){d.value=e}function he(e){i(`select`,e),_e()}function ge(){d.value&&(i(`select`,d.value),_e())}function _e(){i(`close`)}function ve(e){return[`doc`,`docx`].includes(e.extension)}function ye(e){return e.extension===`pdf`}function be(e){return[`xls`,`xlsx`].includes(e.extension)}function xe(e){if(!e)return``;let t=[`B`,`KB`,`MB`,`GB`],n=0,r=e;for(;r>=1024&&n{document.addEventListener(`keydown`,Se)}),o(()=>{document.removeEventListener(`keydown`,Se),clearTimeout(te)}),(t,n)=>(l(),v(ue,{to:`body`},[e.show?(l(),j(`div`,{key:0,class:`fixed inset-0 z-50 flex items-center justify-center`,onKeydown:k(_e,[`escape`])},[M(`div`,{class:`fixed inset-0 bg-black/50`,onClick:_e}),M(`div`,vS,[M(`div`,yS,[M(`h2`,bS,O(t.$t(`files.title`)),1),M(`button`,{type:`button`,onClick:_e,class:`p-1 text-muted hover:text-fg rounded`},[...n[3]||=[M(`svg`,{class:`w-5 h-5`,viewBox:`0 0 20 20`,fill:`currentColor`},[M(`path`,{"fill-rule":`evenodd`,d:`M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z`,"clip-rule":`evenodd`})],-1)]])]),M(`div`,xS,[M(`button`,{type:`button`,onClick:se,class:`inline-flex items-center gap-2 px-4 py-2 bg-accent text-on-accent text-sm font-medium rounded-lg hover:bg-accent-hover transition-colors`},[n[4]||=M(`svg`,{class:`w-4 h-4`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`},[M(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M7 16a4 4 0 01-.88-7.903A5 5 0 1115.9 6L16 6a5 5 0 011 9.9M15 13l-3-3m0 0l-3 3m3-3v12`})],-1),y(` `+O(t.$t(`common.upload`)),1)]),M(`input`,{ref_key:`fileInput`,ref:a,type:`file`,accept:aC,multiple:``,class:`hidden`,"data-role":`library-upload`,onChange:le},null,544),M(`div`,SS,[(l(),j(A,null,_(ne,e=>M(`button`,{key:e.value,type:`button`,onClick:t=>b.value=e.value,class:g([`px-3 py-1.5 text-sm rounded-md transition-colors`,b.value===e.value?`bg-accent-soft text-accent-soft-fg font-medium`:`text-muted hover:bg-hover`])},O(t.$t(e.label)),11,CS)),64))]),x.value.length?s((l(),j(`select`,{key:0,"onUpdate:modelValue":n[0]||=e=>S.value=e,class:`px-3 py-1.5 text-sm border border-field rounded-md focus:ring-focus focus:border-focus max-w-56`},[M(`option`,wS,O(t.$t(`files.all_collections`)),1),(l(!0),j(A,null,_(x.value,e=>(l(),j(`option`,{key:e.id,value:e.id},O(e.name)+` (`+O(e.count)+`) `,9,TS))),128))],512)),[[ce,S.value]]):r(``,!0),M(`div`,ES,[s(M(`input`,{"onUpdate:modelValue":n[1]||=e=>C.value=e,type:`text`,placeholder:t.$t(`files.search_placeholder`),class:`w-56 pl-8 pr-3 py-1.5 text-sm border border-field rounded-md focus:ring-focus focus:border-focus`,onInput:ae},null,40,DS),[[oe,C.value]]),n[5]||=M(`svg`,{class:`absolute left-2.5 top-2 w-4 h-4 text-muted`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`},[M(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z`})],-1)])]),p.value?(l(),j(`div`,OS,[M(`div`,kS,[n[6]||=M(`svg`,{class:`animate-spin h-4 w-4 text-accent`,xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`},[M(`circle`,{class:`opacity-25`,cx:`12`,cy:`12`,r:`10`,stroke:`currentColor`,"stroke-width":`4`}),M(`path`,{class:`opacity-75`,fill:`currentColor`,d:`M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z`})],-1),M(`span`,AS,O(t.$t(`files.uploading`)),1)])])):r(``,!0),m.value?(l(),j(`div`,jS,[M(`div`,MS,[M(`span`,NS,O(m.value),1),M(`button`,{type:`button`,onClick:n[2]||=e=>m.value=``,class:`text-danger hover:text-danger`},[...n[7]||=[M(`svg`,{class:`w-4 h-4`,viewBox:`0 0 20 20`,fill:`currentColor`},[M(`path`,{"fill-rule":`evenodd`,d:`M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z`,"clip-rule":`evenodd`})],-1)]])])])):r(``,!0),M(`div`,PS,[f.value&&!u.value.length?(l(),j(`div`,FS,[...n[8]||=[M(`svg`,{class:`animate-spin h-8 w-8 text-accent`,xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`},[M(`circle`,{class:`opacity-25`,cx:`12`,cy:`12`,r:`10`,stroke:`currentColor`,"stroke-width":`4`}),M(`path`,{class:`opacity-75`,fill:`currentColor`,d:`M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z`})],-1)]])):u.value.length?(l(),j(`div`,RS,[(l(!0),j(A,null,_(u.value,e=>(l(),j(`div`,{key:e.id,onClick:t=>me(e),onDblclick:t=>he(e),class:g([`group relative flex flex-col items-center p-2 rounded-lg border-2 cursor-pointer transition-all`,d.value?.id===e.id?`border-focus bg-accent-soft`:`border-transparent hover:border-field hover:bg-hover`])},[M(`div`,BS,[e.is_image?(l(),j(`img`,{key:0,src:e.url,alt:e.filename,class:`w-full h-full object-cover`,loading:`lazy`},null,8,VS)):(l(),j(`div`,HS,[ve(e)?(l(),j(`svg`,US,[...n[10]||=[M(`path`,{d:`M14 2H6a2 2 0 00-2 2v16a2 2 0 002 2h12a2 2 0 002-2V8l-6-6zM6 20V4h7v5h5v11H6z`},null,-1),M(`path`,{d:`M8 12h8v2H8zm0 4h8v2H8zm0-8h3v2H8z`},null,-1)]])):ye(e)?(l(),j(`svg`,WS,[...n[11]||=[M(`path`,{d:`M14 2H6a2 2 0 00-2 2v16a2 2 0 002 2h12a2 2 0 002-2V8l-6-6zM6 20V4h7v5h5v11H6z`},null,-1),M(`path`,{d:`M10.5 11c-.3 0-.5.2-.5.5v5c0 .3.2.5.5.5s.5-.2.5-.5V15h1.5c1.1 0 2-.9 2-2s-.9-2-2-2h-2zm2 3h-1.5v-2h1.5c.6 0 1 .4 1 1s-.4 1-1 1z`},null,-1)]])):be(e)?(l(),j(`svg`,GS,[...n[12]||=[M(`path`,{d:`M14 2H6a2 2 0 00-2 2v16a2 2 0 002 2h12a2 2 0 002-2V8l-6-6zM6 20V4h7v5h5v11H6z`},null,-1),M(`path`,{d:`M8 12l2.5 3L8 18h1.5l1.75-2.25L13 18h1.5l-2.5-3 2.5-3H13l-1.75 2.25L9.5 12H8z`},null,-1)]])):(l(),j(`svg`,KS,[...n[13]||=[M(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`1.5`,d:`M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z`},null,-1)]])),M(`span`,qS,O(e.extension),1)]))]),M(`p`,{class:`text-xs text-muted text-center truncate w-full`,title:e.filename},O(e.filename),9,JS),M(`button`,{type:`button`,onClick:E(t=>de(e),[`stop`]),class:`absolute top-1 right-1 p-1 bg-danger text-on-danger rounded-full opacity-0 group-hover:opacity-100 transition-opacity hover:bg-danger-hover`,title:t.$t(`common.delete`)},[...n[14]||=[M(`svg`,{class:`w-3 h-3`,viewBox:`0 0 20 20`,fill:`currentColor`},[M(`path`,{"fill-rule":`evenodd`,d:`M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z`,"clip-rule":`evenodd`})],-1)]],8,YS)],42,zS))),128))])):(l(),j(`div`,IS,[n[9]||=M(`svg`,{class:`w-16 h-16 mb-4`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`},[M(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`1`,d:`M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z`})],-1),M(`p`,LS,O(t.$t(`files.empty`)),1)])),ee.value?(l(),j(`div`,XS,[M(`button`,{type:`button`,onClick:ie,class:`px-4 py-2 text-sm text-accent border border-accent rounded-lg hover:bg-accent-soft transition-colors`,disabled:f.value},O(f.value?t.$t(`common.loading`):t.$t(`files.load_more`)),9,ZS)])):r(``,!0)]),M(`div`,QS,[d.value?(l(),j(`div`,$S,[M(`span`,eC,O(d.value.filename),1),M(`span`,tC,O(xe(d.value.size)),1)])):(l(),j(`div`,nC,O(t.$t(`files.select_hint`)),1)),M(`div`,rC,[M(`button`,{type:`button`,onClick:_e,class:`px-4 py-2 text-sm text-fg border border-field rounded-lg hover:bg-hover transition-colors`},O(t.$t(`common.cancel`)),1),M(`button`,{type:`button`,"data-action":`library-insert`,onClick:ge,disabled:!d.value,class:`px-4 py-2 text-sm text-on-accent bg-accent rounded-lg hover:bg-accent-hover disabled:opacity-50 disabled:cursor-not-allowed transition-colors`},O(t.$t(`files.insert`)),9,iC)])])])],32)):r(``,!0)]))}},sC={class:`wysiwyg-field`},cC={key:0,class:`block text-sm font-medium text-fg mb-1`},lC={key:0,class:`text-danger`},uC=[`onClick`,`title`],dC={key:0,class:`flex justify-end p-2 bg-surface-alt border-t border-field text-sm text-muted`},fC={key:1,class:`mt-1 text-sm text-muted`},pC={key:2,class:`mt-1 text-sm text-danger`},mC={__name:`WysiwygField`,props:{modelValue:String,label:String,required:Boolean,toolbar:{type:Array,default:()=>[`bold`,`italic`,`underline`,`link`,`bulletList`,`orderedList`,`heading`]},minHeight:{type:Number,default:200},maxHeight:Number,maxLength:Number,allowImages:{type:Boolean,default:!0},placeholder:String,hint:String,error:String},emits:[`update:modelValue`],setup(t,{emit:n}){let i=t,s=n,u=w(!1),d=w(!1),f=w(`all`),p=w(null);function m(){p.value=gS(S.value)}function h(e=`all`){f.value=e,d.value=!0}function b(e){_S(S.value,e,p.value)}let S=mm({content:i.modelValue,extensions:pS({placeholder:i.placeholder||P(`fields.editor.placeholder`),extra:[nh.configure({limit:i.maxLength})]}),onUpdate:({editor:e})=>{s(`update:modelValue`,e.getHTML())},onFocus:()=>{u.value=!0},onBlur:()=>{u.value=!1}}),C=D(()=>S.value?.storage.characterCount.characters()||0),E=D(()=>{let e=[];return i.toolbar.includes(`bold`)&&e.push({name:`bold`,title:P(`fields.editor.bold`),icon:`IconBold`,action:()=>S.value?.chain().focus().toggleBold().run(),isActive:()=>S.value?.isActive(`bold`)}),i.toolbar.includes(`italic`)&&e.push({name:`italic`,title:P(`fields.editor.italic`),icon:`IconItalic`,action:()=>S.value?.chain().focus().toggleItalic().run(),isActive:()=>S.value?.isActive(`italic`)}),i.toolbar.includes(`underline`)&&e.push({name:`underline`,title:P(`fields.editor.underline`),icon:`IconUnderline`,action:()=>S.value?.chain().focus().toggleUnderline().run(),isActive:()=>S.value?.isActive(`underline`)}),i.toolbar.includes(`link`)&&e.push({name:`link`,title:P(`fields.editor.link`),icon:`IconLink`,action:()=>{let e=prompt(P(`fields.editor.link_prompt`));e&&S.value?.chain().focus().setLink({href:e}).run()},isActive:()=>S.value?.isActive(`link`)}),i.toolbar.includes(`bulletList`)&&e.push({name:`bulletList`,title:P(`fields.editor.bullet_list`),icon:`IconList`,action:()=>S.value?.chain().focus().toggleBulletList().run(),isActive:()=>S.value?.isActive(`bulletList`)}),i.toolbar.includes(`orderedList`)&&e.push({name:`orderedList`,title:P(`fields.editor.ordered_list`),icon:`IconListOrdered`,action:()=>S.value?.chain().focus().toggleOrderedList().run(),isActive:()=>S.value?.isActive(`orderedList`)}),i.toolbar.includes(`heading`)&&e.push({name:`heading`,title:P(`fields.editor.heading`),icon:`IconHeading`,action:()=>S.value?.chain().focus().toggleHeading({level:2}).run(),isActive:()=>S.value?.isActive(`heading`)}),i.toolbar.includes(`image`)&&i.allowImages&&e.push({name:`image`,title:P(`fields.editor.image`),icon:`IconImage`,action:()=>h(`image`)}),i.toolbar.includes(`file`)&&e.push({name:`file`,title:P(`fields.editor.file`),icon:`IconFile`,action:()=>h(`all`)}),e});return c(()=>i.modelValue,e=>{S.value&&e!==S.value.getHTML()&&S.value.commands.setContent(e,{emitUpdate:!1})}),o(()=>{S.value?.destroy()}),(n,i)=>(l(),j(`div`,sC,[t.label?(l(),j(`label`,cC,[y(O(t.label)+` `,1),t.required?(l(),j(`span`,lC,`*`)):r(``,!0)])):r(``,!0),M(`div`,{class:g([`border border-field rounded-lg overflow-hidden`,{"border-danger":t.error,"ring-2 ring-focus":u.value}])},[M(`div`,{class:`flex flex-wrap gap-1 p-2 bg-surface-alt border-b border-field`,onMousedown:m},[(l(!0),j(A,null,_(E.value,e=>(l(),j(`button`,{key:e.name,type:`button`,onClick:e.action,class:g([`p-2 rounded hover:bg-hover`,{"bg-accent-soft text-accent-soft-fg":e.isActive?.()}]),title:e.title},[(l(),v(x(e.icon),{class:`h-4 w-4`}))],10,uC))),128))],32),a(T(pm),{editor:T(S),class:`max-w-none p-4`,style:e({minHeight:t.minHeight+`px`,maxHeight:t.maxHeight?t.maxHeight+`px`:`auto`})},null,8,[`editor`,`style`]),t.maxLength?(l(),j(`div`,dC,O(C.value)+` / `+O(t.maxLength),1)):r(``,!0)],2),t.hint&&!t.error?(l(),j(`p`,fC,O(t.hint),1)):r(``,!0),t.error?(l(),j(`p`,pC,O(t.error),1)):r(``,!0),a(oC,{show:d.value,type:f.value,onSelect:b,onClose:i[0]||=e=>d.value=!1},null,8,[`show`,`type`])]))}},hC={class:`color-field`},gC={key:0,class:`block text-sm font-medium text-fg mb-1`},_C={key:0,class:`text-danger`},vC={class:`flex items-center gap-3`},yC=[`value`],bC=[`value`],xC={key:1,class:`flex flex-wrap gap-2 mt-3`},SC=[`onClick`],CC={key:2,class:`mt-1 text-sm text-muted`},wC={key:3,class:`mt-1 text-sm text-danger`},TC={__name:`ColorField`,props:{modelValue:String,label:String,required:Boolean,presetColors:{type:Array,default:()=>[]},allowCustom:{type:Boolean,default:!0},hint:String,error:String},emits:[`update:modelValue`],setup(t,{emit:n}){let i=w(null);function a(){i.value?.click()}return(n,o)=>(l(),j(`div`,hC,[t.label?(l(),j(`label`,gC,[y(O(t.label)+` `,1),t.required?(l(),j(`span`,_C,`*`)):r(``,!0)])):r(``,!0),M(`div`,vC,[M(`div`,{class:`w-10 h-10 rounded-lg border border-field cursor-pointer`,style:e({backgroundColor:t.modelValue||`#ffffff`}),onClick:a},null,4),t.allowCustom?(l(),j(`input`,{key:0,type:`text`,value:t.modelValue,onInput:o[0]||=e=>n.$emit(`update:modelValue`,e.target.value),class:g([`flex-1 border border-field rounded-md px-3 py-2 text-sm focus:outline-none focus:ring-1 focus:ring-focus focus:border-focus`,{"border-danger":t.error}]),placeholder:`#000000`},null,42,yC)):r(``,!0),M(`input`,{ref_key:`colorPicker`,ref:i,type:`color`,value:t.modelValue,onInput:o[1]||=e=>n.$emit(`update:modelValue`,e.target.value),class:`sr-only`},null,40,bC)]),t.presetColors.length?(l(),j(`div`,xC,[(l(!0),j(A,null,_(t.presetColors,r=>(l(),j(`button`,{key:r,type:`button`,class:g([`w-8 h-8 rounded-lg border-2 transition-all`,t.modelValue===r?`border-focus scale-110`:`border-transparent hover:scale-105`]),style:e({backgroundColor:r}),onClick:e=>n.$emit(`update:modelValue`,r)},null,14,SC))),128))])):r(``,!0),t.hint&&!t.error?(l(),j(`p`,CC,O(t.hint),1)):r(``,!0),t.error?(l(),j(`p`,wC,O(t.error),1)):r(``,!0)]))}},EC={class:`slug-field`},DC={key:0,class:`block text-sm font-medium text-fg mb-1`},OC={key:0,class:`text-danger`},kC={class:`flex gap-2`},AC={class:`relative flex-1`},jC=[`value`,`placeholder`,`disabled`],MC=[`title`],NC={key:1,class:`mt-2 text-sm text-muted`},PC={class:`font-medium`},FC=[`href`],IC={key:2,class:`mt-1 text-sm text-muted`},LC={key:3,class:`mt-1 text-sm text-danger`},RC={__name:`SlugField`,props:{modelValue:String,label:String,required:Boolean,fromField:{type:String,default:`name`},autoGenerate:{type:Boolean,default:!0},showPreview:{type:Boolean,default:!0},baseUrl:String,publicPrefix:String,parentField:String,parentPaths:{type:Object,default:()=>({})},placeholder:String,disabled:Boolean,hint:String,error:String},emits:[`update:modelValue`],setup(e,{emit:n}){let i=e,a=n,o=t(`formData`,{}),s=t(`contentLocale`,w(null)),u=D(()=>{let e=o.value?.[i.fromField];return e&&typeof e==`object`?e[s.value]||``:e||``}),d=w(!i.modelValue),f=D(()=>{if(!i.parentField)return``;let e=o.value?.[i.parentField];return e&&i.parentPaths?.[e]||``}),p=D(()=>`${(i.baseUrl||window.location.origin).replace(/\/+$/,``)}/${[i.publicPrefix,f.value,i.modelValue].filter(Boolean).join(`/`)}`);function m(e){let t=e.target,n=t.selectionStart,r=v(t.value);d.value=r===``,t.value!==r&&(t.value=r,t.setSelectionRange(n,n)),a(`update:modelValue`,r)}function h(e){let t=b(i.modelValue||``);e.target.value!==t&&(e.target.value=t),t!==i.modelValue&&a(`update:modelValue`,t)}function _(){u.value&&(d.value=!0,a(`update:modelValue`,x(u.value)))}function v(e){return S(e).toLowerCase().replace(/[^a-z0-9\-]/g,`-`).replace(/-+/g,`-`)}function b(e){return e.replace(/^-+|-+$/g,``)}function x(e){return b(v(e))}function S(e){let t={а:`a`,б:`b`,в:`v`,г:`g`,д:`d`,е:`e`,ё:`yo`,ж:`zh`,з:`z`,и:`i`,й:`y`,к:`k`,л:`l`,м:`m`,н:`n`,о:`o`,п:`p`,р:`r`,с:`s`,т:`t`,у:`u`,ф:`f`,х:`h`,ц:`ts`,ч:`ch`,ш:`sh`,щ:`sch`,ъ:``,ы:`y`,ь:``,э:`e`,ю:`yu`,я:`ya`,і:`i`,ў:`u`,ґ:`g`,є:`ie`,ї:`i`,"’":``,"'":``};return e.toLowerCase().split(``).map(e=>t[e]??e).join(``).normalize(`NFD`).replace(/[\u0300-\u036f]/g,``)}return c(u,e=>{i.autoGenerate&&d.value&&e&&a(`update:modelValue`,x(e))}),(t,n)=>(l(),j(`div`,EC,[e.label?(l(),j(`label`,DC,[y(O(e.label)+` `,1),e.required?(l(),j(`span`,OC,`*`)):r(``,!0)])):r(``,!0),M(`div`,kC,[M(`div`,AC,[M(`input`,{type:`text`,value:e.modelValue,onInput:m,onBlur:h,class:g([`w-full border border-field rounded-md px-3 py-2 pr-10 text-sm focus:outline-none focus:ring-1 focus:ring-focus focus:border-focus`,{"border-danger":e.error}]),placeholder:e.placeholder||t.$t(`fields.slug.placeholder`),disabled:e.disabled},null,42,jC),e.autoGenerate&&u.value?(l(),j(`button`,{key:0,type:`button`,onClick:_,class:`absolute right-2 top-1/2 -translate-y-1/2 text-muted hover:text-accent`,title:t.$t(`fields.slug.generate`)},[...n[0]||=[M(`svg`,{class:`h-5 w-5`,viewBox:`0 0 20 20`,fill:`currentColor`},[M(`path`,{"fill-rule":`evenodd`,d:`M4 2a1 1 0 011 1v2.101a7.002 7.002 0 0111.601 2.566 1 1 0 11-1.885.666A5.002 5.002 0 005.999 7H9a1 1 0 010 2H4a1 1 0 01-1-1V3a1 1 0 011-1zm.008 9.057a1 1 0 011.276.61A5.002 5.002 0 0014.001 13H11a1 1 0 110-2h5a1 1 0 011 1v5a1 1 0 11-2 0v-2.101a7.002 7.002 0 01-11.601-2.566 1 1 0 01.61-1.276z`,"clip-rule":`evenodd`})],-1)]],8,MC)):r(``,!0)])]),e.showPreview&&e.modelValue?(l(),j(`div`,NC,[M(`span`,PC,O(t.$t(`fields.slug.url_label`)),1),M(`a`,{href:p.value,target:`_blank`,class:`text-accent hover:text-accent-soft-fg break-all`},O(p.value),9,FC)])):r(``,!0),e.hint&&!e.error?(l(),j(`p`,IC,O(e.hint),1)):r(``,!0),e.error?(l(),j(`p`,LC,O(e.error),1)):r(``,!0)]))}},zC={class:`tree-node`},BC=[`data-tree-value`,`data-tree-selected`],VC={key:1,class:`w-6`},HC={key:2,class:`h-5 w-5 text-accent`,viewBox:`0 0 20 20`,fill:`currentColor`},UC={key:0},WC={__name:`TreeNode`,props:{node:{type:Object,required:!0},depth:{type:Number,default:0},selectedValue:[String,Number,Array],expandedNodes:{type:Set,default:()=>new Set}},emits:[`select`,`toggle`],setup(e,{emit:t}){let i=e,a=t,o=D(()=>i.node.children?.length>0),s=D(()=>i.expandedNodes.has(i.node.value)),c=D(()=>Array.isArray(i.selectedValue)?i.selectedValue.includes(i.node.value):i.selectedValue===i.node.value);function u(){a(`select`,i.node.value)}function d(){a(`toggle`,i.node.value)}return(t,i)=>{let a=n(`tree-node`,!0);return l(),j(`div`,zC,[M(`div`,{class:g([`flex items-center px-3 py-2 cursor-pointer hover:bg-hover`,{"bg-accent-soft":c.value,"pl-6":e.depth===1,"pl-9":e.depth===2,"pl-12":e.depth>=3}]),"data-tree-value":e.node.value,"data-tree-selected":c.value?`true`:`false`,onClick:u},[o.value?(l(),j(`button`,{key:0,type:`button`,class:`mr-2 text-muted hover:text-fg focus:outline-none`,onClick:E(d,[`stop`])},[(l(),j(`svg`,{class:g([`h-4 w-4 transform transition-transform`,{"rotate-90":s.value}]),viewBox:`0 0 20 20`,fill:`currentColor`},[...i[2]||=[M(`path`,{"fill-rule":`evenodd`,d:`M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z`,"clip-rule":`evenodd`},null,-1)]],2))])):(l(),j(`span`,VC)),M(`span`,{class:g([`flex-1 truncate`,{"font-medium text-accent":c.value}])},O(e.node.label),3),c.value?(l(),j(`svg`,HC,[...i[3]||=[M(`path`,{"fill-rule":`evenodd`,d:`M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z`,"clip-rule":`evenodd`},null,-1)]])):r(``,!0)],10,BC),o.value&&s.value?(l(),j(`div`,UC,[(l(!0),j(A,null,_(e.node.children,n=>(l(),v(a,{key:n.value,node:n,depth:e.depth+1,"selected-value":e.selectedValue,"expanded-nodes":e.expandedNodes,onSelect:i[0]||=e=>t.$emit(`select`,e),onToggle:i[1]||=e=>t.$emit(`toggle`,e)},null,8,[`node`,`depth`,`selected-value`,`expanded-nodes`]))),128))])):r(``,!0)])}}},GC={class:`tree-select-field`},KC={key:0,class:`block text-sm font-medium text-fg mb-1`},qC={key:0,class:`text-danger`},JC={class:`relative`},YC={key:0,class:`block truncate`},XC={key:1,class:`block truncate text-muted`},ZC={key:0,class:`absolute z-10 mt-1 w-full bg-surface shadow-lg max-h-60 rounded-md py-1 text-base ring-1 ring-line overflow-auto focus:outline-none sm:text-sm`},QC={key:0,class:`px-3 py-2`},$C=[`placeholder`],ew=[`data-tree-selected`],tw={key:0,class:`h-5 w-5 text-accent`,viewBox:`0 0 20 20`,fill:`currentColor`},nw={key:2,class:`px-3 py-2 border-b`},rw={key:1,class:`mt-1 text-sm text-muted`},iw={key:2,class:`mt-1 text-sm text-danger`},aw={__name:`TreeSelectField`,props:{modelValue:[String,Number,Array],options:{type:Array,default:()=>[]},label:String,placeholder:String,required:Boolean,searchable:{type:Boolean,default:!0},clearable:{type:Boolean,default:!0},multiple:Boolean,expandAll:Boolean,rootLabel:String,hint:String,error:String},emits:[`update:modelValue`],setup(e,{emit:t}){let n=e,i=t,a=w(!1),c=w(``),u=w(new Set),d=D(()=>{if(!c.value)return n.options;let e=c.value.toLowerCase();return S(n.options,e)}),f=D(()=>n.modelValue===null||n.modelValue===void 0||n.modelValue===``),p=D(()=>!!n.rootLabel&&!n.multiple&&b(n.rootLabel)),m=D(()=>{if(f.value)return n.rootLabel||``;let e=C(n.options,n.modelValue);return e?e.label:``});function b(e){return!c.value||String(e).toLowerCase().includes(c.value.toLowerCase())}function x(){i(`update:modelValue`,null),a.value=!1}function S(e,t){return e.reduce((e,n)=>{let r=n.label.toLowerCase().includes(t),i=n.children?S(n.children,t):[];return(r||i.length)&&e.push({...n,children:i.length?i:n.children}),e},[])}function C(e,t){for(let n of e){if(n.value===t)return n;if(n.children){let e=C(n.children,t);if(e)return e}}return null}function T(){a.value=!a.value}function E(e){i(`update:modelValue`,e),n.multiple||(a.value=!1)}function ee(e){u.value.has(e)?u.value.delete(e):u.value.add(e)}function te(){i(`update:modelValue`,null),a.value=!1}function ne(e){e.target.closest(`.tree-select-field`)||(a.value=!1)}return h(()=>{if(document.addEventListener(`click`,ne),n.expandAll){let e=t=>{t.forEach(t=>{t.children?.length&&(u.value.add(t.value),e(t.children))})};e(n.options)}}),o(()=>{document.removeEventListener(`click`,ne)}),(t,n)=>(l(),j(`div`,GC,[e.label?(l(),j(`label`,KC,[y(O(e.label)+` `,1),e.required?(l(),j(`span`,qC,`*`)):r(``,!0)])):r(``,!0),M(`div`,JC,[M(`button`,{type:`button`,onClick:T,class:g([`relative w-full bg-surface border border-field rounded-md shadow-sm pl-3 pr-10 py-2 text-left cursor-pointer focus:outline-none focus:ring-1 focus:ring-focus focus:border-focus`,{"border-danger":e.error}])},[m.value?(l(),j(`span`,YC,O(m.value),1)):(l(),j(`span`,XC,O(e.placeholder||t.$t(`common.select`)),1)),n[1]||=M(`span`,{class:`absolute inset-y-0 right-0 flex items-center pr-2`},[M(`svg`,{class:`h-5 w-5 text-muted`,viewBox:`0 0 20 20`,fill:`currentColor`},[M(`path`,{"fill-rule":`evenodd`,d:`M10 3a1 1 0 01.707.293l3 3a1 1 0 01-1.414 1.414L10 5.414 7.707 7.707a1 1 0 01-1.414-1.414l3-3A1 1 0 0110 3zm-3.707 9.293a1 1 0 011.414 0L10 14.586l2.293-2.293a1 1 0 011.414 1.414l-3 3a1 1 0 01-1.414 0l-3-3a1 1 0 010-1.414z`,"clip-rule":`evenodd`})])],-1)],2),a.value?(l(),j(`div`,ZC,[e.searchable?(l(),j(`div`,QC,[s(M(`input`,{"onUpdate:modelValue":n[0]||=e=>c.value=e,type:`text`,class:`w-full border border-field rounded-md px-3 py-1 text-sm focus:outline-none focus:ring-1 focus:ring-focus`,placeholder:t.$t(`fields.tree.search_placeholder`)},null,8,$C),[[oe,c.value]])])):r(``,!0),p.value?(l(),j(`div`,{key:1,class:g([`flex items-center px-3 py-2 cursor-pointer hover:bg-hover border-b`,{"bg-accent-soft":f.value}]),"data-tree-value":``,"data-tree-selected":f.value?`true`:`false`,onClick:x},[n[3]||=M(`span`,{class:`w-6`},null,-1),M(`span`,{class:g([`flex-1 truncate`,{"font-medium text-accent":f.value}])},O(e.rootLabel),3),f.value?(l(),j(`svg`,tw,[...n[2]||=[M(`path`,{"fill-rule":`evenodd`,d:`M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z`,"clip-rule":`evenodd`},null,-1)]])):r(``,!0)],10,ew)):r(``,!0),e.clearable&&!e.rootLabel&&e.modelValue?(l(),j(`div`,nw,[M(`button`,{type:`button`,onClick:te,class:`text-sm text-muted hover:text-fg`},O(t.$t(`fields.clear`)),1)])):r(``,!0),(l(!0),j(A,null,_(d.value,t=>(l(),v(WC,{key:t.value,node:t,"selected-value":e.modelValue,"expanded-nodes":u.value,onSelect:E,onToggle:ee},null,8,[`node`,`selected-value`,`expanded-nodes`]))),128))])):r(``,!0)]),e.hint&&!e.error?(l(),j(`p`,rw,O(e.hint),1)):r(``,!0),e.error?(l(),j(`p`,iw,O(e.error),1)):r(``,!0)]))}},ow={class:`gallery-field`},sw={key:0,class:`block text-sm font-medium text-fg mb-1`},cw={key:0,class:`text-danger`},lw=[`onDragstart`,`onDrop`],uw=[`src`,`alt`],dw=[`href`,`title`],fw={class:`mt-1 text-xs text-muted break-all line-clamp-2`},pw={class:`absolute inset-0 bg-black/50 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center gap-2`},mw=[`onClick`,`title`],hw={key:2,class:`absolute top-2 left-2 bg-surface/75 rounded px-2 py-1 text-xs font-medium cursor-move`},gw={class:`text-center`},_w={class:`mt-1 block text-sm text-muted`},vw=[`accept`],yw={key:2,class:`mt-2 text-sm text-muted`},bw={key:3,class:`mt-2 text-sm text-danger`},xw={class:`mt-2 text-sm text-muted`},Sw={__name:`GalleryField`,props:{modelValue:{type:Array,default:()=>[]},label:String,required:Boolean,maxFiles:{type:Number,default:20},maxSize:{type:Number,default:5120},accept:{type:String,default:`image/*`},sortable:{type:Boolean,default:!0},hint:String,error:String,uploadUrl:{type:String,default:`/admin/upload`}},emits:[`update:modelValue`],setup(e,{emit:t}){let n=e,i=t,o=w(null),s=w(null),c=D(()=>n.modelValue||[]);function u(e){let t=typeof e==`string`?e:e?.url??e?.path??``;return typeof t!=`string`||t===``?``:/^(https?:)?\/\//i.test(t)||t.startsWith(`/`)?t:`/storage/`+t}function d(e){return e&&typeof e==`object`&&e.filename?e.filename:u(e).split(`/`).filter(Boolean).pop()||``}function f(e){return/\.(jpe?g|png|gif|webp|bmp|svg|avif)(\?|$)/i.test(e.src||``)}let p=D(()=>c.value.map(e=>({src:u(e),filename:d(e)})));function m(e){return typeof e?.url==`string`&&/^https?:\/\//i.test(e.url)?e.url:e&&typeof e.path==`string`&&e.path!==``?`/storage/`+e.path.replace(/^\/+/,``):u(e)}let h=D(()=>c.value.lengthu(e)===t)||i(`update:modelValue`,[...c.value,t]))}function b(){o.value?.click()}async function x(e){let t=Array.from(e.target.files);for(let e of t){if(!h.value)break;e.size>n.maxSize*1024?alert(P(`fields.gallery.file_too_big`,{name:e.name,max:n.maxSize})):await S(e)}e.target.value=``}async function S(e){let t=new FormData;t.append(`file`,e);try{let r=await fetch(n.uploadUrl,{method:`POST`,body:t,headers:fe()});if(!r.ok)throw Error(await pe(r,P(`fields.gallery.upload_failed`,{name:e.name})));let a=await r.json();i(`update:modelValue`,[...c.value,m(a)])}catch(e){console.error(`Upload error:`,e),alert(e.message||P(`fields.upload.failed`))}}function C(e){Array.from(e.dataTransfer.files).forEach(e=>{h.value&&e.type.startsWith(`image/`)&&S(e)})}function T(e){let t=[...c.value];t.splice(e,1),i(`update:modelValue`,t)}function ee(e){s.value=e}function te(e){if(s.value===null||s.value===e)return;let t=[...c.value],[n]=t.splice(s.value,1);t.splice(e,0,n),i(`update:modelValue`,t),s.value=null}return(t,n)=>(l(),j(`div`,ow,[e.label?(l(),j(`label`,sw,[y(O(e.label)+` `,1),e.required?(l(),j(`span`,cw,`*`)):r(``,!0)])):r(``,!0),M(`div`,{class:`grid grid-cols-4 gap-4`,onDragover:n[1]||=E(()=>{},[`prevent`]),onDrop:C},[(l(!0),j(A,null,_(p.value,(i,a)=>(l(),j(`div`,{key:i.src||a,class:`relative group aspect-square bg-off rounded-lg overflow-hidden`,draggable:`true`,onDragstart:e=>ee(a),onDragover:n[0]||=E(()=>{},[`prevent`]),onDrop:e=>te(a)},[f(i)?(l(),j(`img`,{key:0,src:i.src,alt:i.filename,class:`w-full h-full object-cover`},null,8,uw)):(l(),j(`a`,{key:1,href:i.src,target:`_blank`,rel:`noopener`,class:`w-full h-full flex flex-col items-center justify-center p-2 text-center hover:bg-hover`,title:i.filename},[n[4]||=M(`svg`,{class:`h-8 w-8 text-muted`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`},[M(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z`})],-1),M(`span`,fw,O(i.filename),1)],8,dw)),M(`div`,pw,[M(`button`,{type:`button`,onClick:e=>T(a),title:t.$t(`common.remove`),class:`p-2 bg-danger text-on-danger rounded-full hover:bg-danger-hover`},[...n[5]||=[M(`svg`,{class:`h-4 w-4`,viewBox:`0 0 20 20`,fill:`currentColor`},[M(`path`,{"fill-rule":`evenodd`,d:`M9 2a1 1 0 00-.894.553L7.382 4H4a1 1 0 000 2v10a2 2 0 002 2h8a2 2 0 002-2V6a1 1 0 100-2h-3.382l-.724-1.447A1 1 0 0011 2H9zM7 8a1 1 0 012 0v6a1 1 0 11-2 0V8zm5-1a1 1 0 00-1 1v6a1 1 0 102 0V8a1 1 0 00-1-1z`,"clip-rule":`evenodd`})],-1)]],8,mw)]),e.sortable?(l(),j(`div`,hw,O(a+1),1)):r(``,!0)],40,lw))),128)),h.value?(l(),j(`div`,{key:0,class:`aspect-square border-2 border-dashed border-field rounded-lg flex items-center justify-center hover:border-focus hover:bg-accent-soft cursor-pointer transition-colors`,onClick:b},[M(`div`,gw,[n[6]||=M(`svg`,{class:`mx-auto h-8 w-8 text-muted`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`},[M(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M12 4v16m8-8H4`})],-1),M(`span`,_w,O(t.$t(`common.add`)),1)])])):r(``,!0)],32),M(`input`,{ref_key:`fileInput`,ref:o,type:`file`,accept:e.accept,multiple:``,class:`hidden`,onChange:x},null,40,vw),h.value?(l(),j(`button`,{key:1,type:`button`,onClick:n[2]||=e=>g.value=!0,"data-action":`pick-from-library`,class:`mt-3 px-3 py-2 text-sm font-medium text-fg bg-surface border border-field rounded-md hover:bg-hover`},O(t.$t(`fields.gallery.add_from_library`)),1)):r(``,!0),a(oC,{show:g.value,type:`image`,onSelect:v,onClose:n[3]||=e=>g.value=!1},null,8,[`show`]),e.hint&&!e.error?(l(),j(`p`,yw,O(e.hint),1)):r(``,!0),e.error?(l(),j(`p`,bw,O(e.error),1)):r(``,!0),M(`p`,xw,O(t.$tc(`fields.gallery.counter`,e.maxFiles,{current:c.value.length})),1)]))}},Cw=[`data-content-field`],ww={key:0,class:`block text-sm font-medium text-fg mb-1`},Tw={key:0,class:`text-danger`},Ew={class:`flex items-center gap-4 mb-2`},Dw=[`name`,`value`,`data-content-mode`],Ow={class:`ml-1.5 text-sm text-fg`},kw=[`placeholder`,`required`,`disabled`,`rows`],Aw=[`placeholder`,`required`,`disabled`,`rows`],jw=[`value`,`title`],Mw=[`value`],Nw=[`value`,`title`],Pw=[`value`],Fw=[`title`],Iw=[`value`],Lw=[`data-editor-button`,`onClick`,`title`],Rw=[`innerHTML`],zw={key:4,class:`mt-1 text-sm text-muted`},Bw={key:5,class:`mt-1 text-sm text-danger`},Vw={__name:`ContentField`,props:{modelValue:String,name:String,label:String,required:Boolean,disabled:Boolean,placeholder:String,hint:String,error:String,defaultMode:{type:String,default:`wysiwyg`},modes:{type:Array,default:()=>[`text`,`html`,`wysiwyg`]},rows:{type:Number,default:6},toolbar:{type:Array,default:()=>[`bold`,`italic`,`underline`,`strike`,`color`,`link`,`bulletList`,`orderedList`,`align`,`heading`,`fontSize`,`image`,`file`,`table`]},minHeight:{type:Number,default:200}},emits:[`update:modelValue`],setup(t,{emit:n}){let i=t,u=n,d={text:`fields.content.mode_text`,html:`fields.content.mode_html`,wysiwyg:`fields.content.mode_wysiwyg`},f=D(()=>i.modes.map(e=>({value:e,label:d[e]?P(d[e]):e}))),p=D(()=>`content-field-mode-${i.name}`),m=w(localStorage.getItem(p.value)||i.defaultMode);c(m,e=>{localStorage.setItem(p.value,e)});let h=D({get:()=>i.modelValue||``,set:e=>u(`update:modelValue`,e)}),v=w(!1),b=w(!1),x=w(`all`),S=w(null),C=w(null);function E(){C.value=gS(k.value)}function ee(e=`all`,t=null){x.value=e,S.value=t,b.value=!0}function te(e){S.value?(S.value(e),S.value=null):_S(k.value,e,C.value)}let k=mm({content:i.modelValue||``,extensions:pS({placeholder:i.placeholder||P(`fields.editor.placeholder`)}),onUpdate:({editor:e})=>{m.value===`wysiwyg`&&u(`update:modelValue`,e.getHTML())},onFocus:()=>{v.value=!0},onBlur:()=>{v.value=!1}});c(m,e=>{e===`wysiwyg`&&k.value&&k.value.commands.setContent(i.modelValue||``,{emitUpdate:!1})}),c(()=>i.modelValue,e=>{m.value===`wysiwyg`&&k.value&&e!==k.value.getHTML()&&k.value.commands.setContent(e||``,{emitUpdate:!1})});let re=[{value:`paragraph`,label:`fields.editor.format_paragraph`},{value:`h1`,label:`fields.editor.format_h1`},{value:`h2`,label:`fields.editor.format_h2`},{value:`h3`,label:`fields.editor.format_h3`},{value:`h4`,label:`fields.editor.format_h4`},{value:`h5`,label:`fields.editor.format_h5`},{value:`h6`,label:`fields.editor.format_h6`},{value:`blockquote`,label:`fields.editor.format_blockquote`}];function ie(){if(!k.value)return`paragraph`;if(k.value.isActive(`blockquote`))return`blockquote`;for(let e=1;e<=6;e++)if(k.value.isActive(`heading`,{level:e}))return`h${e}`;return`paragraph`}function ae(e){if(!k.value)return;let t=k.value.chain().focus();k.value.isActive(`blockquote`)&&e!==`blockquote`&&t.unsetBlockquote(),e===`blockquote`?t.setParagraph().setBlockquote().run():e===`paragraph`?t.setParagraph().run():t.setHeading({level:Number(e.slice(1))}).run()}function se(){return k.value?.getAttributes(`textStyle`)?.color||`#000000`}let ce=[8,9,10,11,12,14,16,18,20,24,28,36,48,72];function le(){let e=[{value:``,label:P(`fields.editor.font_size_default`)},...ce.map(e=>({value:`${e}pt`,label:P(`fields.editor.font_size_pt`,{size:e})}))],t=ue();return t&&!e.some(e=>e.value===t)&&e.push({value:t,label:t}),e}function ue(){return k.value?.getAttributes(`textStyle`)?.fontSize||``}function N(e){if(!k.value)return;let t=k.value.chain().focus();e?t.setFontSize(e).run():t.unsetFontSize().run()}let de={bold:``,italic:``,underline:``,strike:``,link:``,bulletList:``,orderedList:``,image:``,file:``,alignLeft:``,alignCenter:``,alignRight:``,alignJustify:``,table:``,rowPlus:``,rowMinus:``,columnPlus:``,columnMinus:``,mergeCells:``,tableMinus:``},fe=D(()=>{let e=[];return i.toolbar.includes(`bold`)&&e.push({name:`bold`,title:P(`fields.editor.bold_shortcut`),icon:de.bold,action:()=>k.value?.chain().focus().toggleBold().run(),isActive:()=>k.value?.isActive(`bold`)}),i.toolbar.includes(`italic`)&&e.push({name:`italic`,title:P(`fields.editor.italic_shortcut`),icon:de.italic,action:()=>k.value?.chain().focus().toggleItalic().run(),isActive:()=>k.value?.isActive(`italic`)}),i.toolbar.includes(`underline`)&&e.push({name:`underline`,title:P(`fields.editor.underline_shortcut`),icon:de.underline,action:()=>k.value?.chain().focus().toggleUnderline().run(),isActive:()=>k.value?.isActive(`underline`)}),i.toolbar.includes(`strike`)&&e.push({name:`strike`,title:P(`fields.editor.strike`),icon:de.strike,action:()=>k.value?.chain().focus().toggleStrike().run(),isActive:()=>k.value?.isActive(`strike`)}),i.toolbar.includes(`link`)&&e.push({name:`link`,title:P(`fields.editor.link`),icon:de.link,action:()=>{let e=prompt(P(`fields.editor.link_prompt`));e&&k.value?.chain().focus().setLink({href:e}).run()},isActive:()=>k.value?.isActive(`link`)}),i.toolbar.includes(`bulletList`)&&e.push({name:`bulletList`,title:P(`fields.editor.bullet_list`),icon:de.bulletList,action:()=>k.value?.chain().focus().toggleBulletList().run(),isActive:()=>k.value?.isActive(`bulletList`)}),i.toolbar.includes(`orderedList`)&&e.push({name:`orderedList`,title:P(`fields.editor.ordered_list`),icon:de.orderedList,action:()=>k.value?.chain().focus().toggleOrderedList().run(),isActive:()=>k.value?.isActive(`orderedList`)}),i.toolbar.includes(`align`)&&e.push(...hS(k,de)),i.toolbar.includes(`image`)&&e.push({name:`image`,title:P(`fields.editor.image`),icon:de.image,action:()=>ee(`image`)}),i.toolbar.includes(`file`)&&e.push({name:`file`,title:P(`fields.editor.file`),icon:de.file,action:()=>ee(`all`)}),i.toolbar.includes(`table`)&&e.push(...mS(k,de)),e});return o(()=>{k.value?.destroy()}),(n,i)=>(l(),j(`div`,{class:`content-field`,"data-content-field":t.name},[t.label?(l(),j(`label`,ww,[y(O(t.label)+` `,1),t.required?(l(),j(`span`,Tw,`*`)):r(``,!0)])):r(``,!0),M(`div`,Ew,[(l(!0),j(A,null,_(f.value,e=>(l(),j(`label`,{key:e.value,class:`flex items-center cursor-pointer`},[s(M(`input`,{type:`radio`,name:t.name+`_mode`,value:e.value,"data-content-mode":e.value,"onUpdate:modelValue":i[0]||=e=>m.value=e,class:`h-4 w-4 text-accent focus:ring-focus border-field`},null,8,Dw),[[ne,m.value]]),M(`span`,Ow,O(e.label),1)]))),128))]),m.value===`text`?s((l(),j(`textarea`,{key:1,"onUpdate:modelValue":i[1]||=e=>h.value=e,placeholder:t.placeholder,required:t.required,disabled:t.disabled,rows:t.rows,class:g([`w-full px-3 py-2 border border-field rounded-md shadow-sm focus:ring-focus focus:border-focus resize-y`,{"border-danger":t.error}])},null,10,kw)),[[oe,h.value]]):m.value===`html`?s((l(),j(`textarea`,{key:2,"onUpdate:modelValue":i[2]||=e=>h.value=e,placeholder:t.placeholder,required:t.required,disabled:t.disabled,rows:t.rows,class:g([`w-full px-3 py-2 border border-field rounded-md shadow-sm focus:ring-focus focus:border-focus resize-y font-mono text-sm bg-surface-alt`,{"border-danger":t.error}])},null,10,Aw)),[[oe,h.value]]):m.value===`wysiwyg`?(l(),j(`div`,{key:3,class:g([`border border-field rounded-lg overflow-hidden`,{"border-danger":t.error,"ring-2 ring-focus":v.value}])},[M(`div`,{class:`flex flex-wrap items-center gap-1 p-2 bg-surface-alt border-b border-field`,onMousedown:E},[t.toolbar.includes(`heading`)?(l(),j(`select`,{key:0,"data-editor-format":`true`,class:`mr-1 h-8 rounded border border-field bg-surface px-2 text-sm text-fg`,value:ie(),onChange:i[3]||=e=>ae(e.target.value),title:n.$t(`fields.editor.format`)},[(l(),j(A,null,_(re,e=>M(`option`,{key:e.value,value:e.value},O(n.$t(e.label)),9,Mw)),64))],40,jw)):r(``,!0),t.toolbar.includes(`fontSize`)?(l(),j(`select`,{key:1,"data-editor-font-size":`true`,class:`mr-1 h-8 rounded border border-field bg-surface px-2 text-sm text-fg`,value:ue(),onChange:i[4]||=e=>N(e.target.value),title:n.$t(`fields.editor.font_size`)},[(l(!0),j(A,null,_(le(),e=>(l(),j(`option`,{key:e.value,value:e.value},O(e.label),9,Pw))),128))],40,Nw)):r(``,!0),t.toolbar.includes(`color`)?(l(),j(`label`,{key:2,class:`flex h-8 cursor-pointer items-center gap-1 rounded px-1.5 hover:bg-hover`,title:n.$t(`fields.editor.text_color`)},[i[7]||=M(`span`,{class:`text-sm font-semibold text-fg`},`A`,-1),M(`input`,{type:`color`,"data-editor-color":`true`,class:`h-5 w-6 cursor-pointer border-0 bg-transparent p-0`,value:se(),onInput:i[5]||=e=>T(k)?.chain().focus().setColor(e.target.value).run()},null,40,Iw)],8,Fw)):r(``,!0),(l(!0),j(A,null,_(fe.value,e=>(l(),j(A,{key:e.name},[!e.visible||e.visible()?(l(),j(`button`,{key:0,type:`button`,"data-editor-button":e.name,onClick:e.action,class:g([`p-2 rounded hover:bg-hover`,{"bg-accent-soft text-accent-soft-fg":e.isActive?.()}]),title:e.title},[M(`span`,{innerHTML:e.icon,class:`w-4 h-4 block`},null,8,Rw)],10,Lw)):r(``,!0)],64))),128))],32),a(T(pm),{editor:T(k),class:`max-w-none p-4 overflow-x-auto`,style:e({minHeight:t.minHeight+`px`})},null,8,[`editor`,`style`])],2)):r(``,!0),t.hint&&!t.error?(l(),j(`p`,zw,O(t.hint),1)):r(``,!0),t.error?(l(),j(`p`,Bw,O(t.error),1)):r(``,!0),a(oC,{show:b.value,type:x.value,onSelect:te,onClose:i[6]||=e=>b.value=!1},null,8,[`show`,`type`])],8,Cw))}},Hw={class:`repeatable-field`},Uw={key:0,class:`block text-sm font-medium text-fg mb-2`},Ww={key:0,class:`text-danger`},Gw={key:1,class:`space-y-3`},Kw=[`data-repeatable-item`],qw={class:`flex items-center justify-between mb-2`},Jw={class:`text-sm font-medium text-fg`},Yw={class:`flex items-center gap-1`},Xw=[`onClick`,`disabled`,`title`],Zw=[`onClick`,`disabled`,`title`],Qw=[`onClick`,`title`],$w={key:2,class:`space-y-2`},eT=[`data-repeatable-item`],tT={class:`flex flex-col gap-0.5`},nT=[`onClick`,`disabled`,`title`],rT=[`onClick`,`disabled`,`title`],iT=[`type`,`value`,`onInput`,`placeholder`,`disabled`],aT=[`onClick`,`disabled`,`title`],oT={key:3,class:`text-muted text-sm py-2`},sT={key:5,class:`mt-1 text-xs text-muted`},cT={__name:`RepeatableField`,props:{itemLabel:{type:String,default:``},itemModes:{type:Array,default:()=>[`text`,`html`,`wysiwyg`]},itemToolbar:{type:Array,default:null},modelValue:{type:Array,default:()=>[]},name:{type:String,required:!0},label:{type:String,default:``},itemType:{type:String,default:`text`},maxItems:{type:Number,default:0},minItems:{type:Number,default:0},addLabel:{type:String,default:``},placeholder:{type:String,default:``},required:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},error:{type:String,default:null}},emits:[`update:modelValue`],setup(e,{emit:t}){let n=e,i=t,o=D({get:()=>Array.isArray(n.modelValue)?n.modelValue:[],set:e=>i(`update:modelValue`,e)}),s=D(()=>!n.disabled&&(n.maxItems===0||o.value.length!n.disabled&&o.value.length>n.minItems),u=D(()=>({text:`text`,number:`number`,date:`date`,datetime:`datetime-local`,email:`email`,url:`url`,tel:`tel`})[n.itemType]||`text`),d=D(()=>n.itemType===`content`),f=D(()=>n.addLabel||P(`common.add`));function p(e){let t=n.itemLabel||n.label||P(`fields.repeatable.item`);return P(`fields.repeatable.item_title`,{label:t,number:e+1})}function m(){s.value&&(o.value=[...o.value,``])}function h(e){if(c.value){let t=[...o.value];t.splice(e,1),o.value=t}}function v(e,t){let n=[...o.value];n[e]=t,o.value=n}function b(e,t){if(t<0||t>=o.value.length)return;let n=[...o.value],[r]=n.splice(e,1);n.splice(t,0,r),o.value=n}return(t,n)=>(l(),j(`div`,Hw,[e.label?(l(),j(`label`,Uw,[y(O(e.label)+` `,1),e.required?(l(),j(`span`,Ww,`*`)):r(``,!0)])):r(``,!0),d.value?(l(),j(`div`,Gw,[(l(!0),j(A,null,_(o.value,(i,s)=>(l(),j(`div`,{key:s,"data-repeatable-item":s,class:`border border-line rounded-lg p-3 bg-surface`},[M(`div`,qw,[M(`span`,Jw,O(p(s)),1),M(`div`,Yw,[M(`button`,{type:`button`,onClick:e=>b(s,s-1),disabled:e.disabled||s===0,class:`p-1 text-muted hover:text-fg disabled:opacity-30 disabled:cursor-not-allowed`,title:t.$t(`fields.repeatable.move_up`)},[...n[0]||=[M(`svg`,{class:`w-4 h-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[M(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M5 15l7-7 7 7`})],-1)]],8,Xw),M(`button`,{type:`button`,onClick:e=>b(s,s+1),disabled:e.disabled||s===o.value.length-1,class:`p-1 text-muted hover:text-fg disabled:opacity-30 disabled:cursor-not-allowed`,title:t.$t(`fields.repeatable.move_down`)},[...n[1]||=[M(`svg`,{class:`w-4 h-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[M(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M19 9l-7 7-7-7`})],-1)]],8,Zw),c.value?(l(),j(`button`,{key:0,type:`button`,onClick:e=>h(s),class:`p-1 text-danger hover:text-danger-soft-fg hover:bg-danger-soft rounded`,title:t.$t(`common.delete`)},[...n[2]||=[M(`svg`,{class:`w-4 h-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[M(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16`})],-1)]],8,Qw)):r(``,!0)])]),a(Vw,ie({"model-value":i,"onUpdate:modelValue":e=>v(s,e),name:`${e.name}_${s}`,modes:e.itemModes},{ref_for:!0},e.itemToolbar?{toolbar:e.itemToolbar}:{},{disabled:e.disabled,rows:8}),null,16,[`model-value`,`onUpdate:modelValue`,`name`,`modes`,`disabled`])],8,Kw))),128))])):(l(),j(`div`,$w,[(l(!0),j(A,null,_(o.value,(i,a)=>(l(),j(`div`,{key:a,"data-repeatable-item":a,class:`flex items-center gap-2`},[M(`div`,tT,[M(`button`,{type:`button`,onClick:e=>b(a,a-1),disabled:e.disabled||a===0,class:`p-0.5 text-muted hover:text-fg disabled:opacity-30 disabled:cursor-not-allowed`,title:t.$t(`fields.repeatable.move_up`)},[...n[3]||=[M(`svg`,{class:`w-4 h-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[M(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M5 15l7-7 7 7`})],-1)]],8,nT),M(`button`,{type:`button`,onClick:e=>b(a,a+1),disabled:e.disabled||a===o.value.length-1,class:`p-0.5 text-muted hover:text-fg disabled:opacity-30 disabled:cursor-not-allowed`,title:t.$t(`fields.repeatable.move_down`)},[...n[4]||=[M(`svg`,{class:`w-4 h-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[M(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M19 9l-7 7-7-7`})],-1)]],8,rT)]),M(`input`,{type:u.value,value:i,onInput:e=>v(a,e.target.value),placeholder:e.placeholder||t.$t(`fields.repeatable.item_title`,{label:e.label,number:a+1}),disabled:e.disabled,class:g([`flex-1 px-3 py-2 border border-field rounded-md shadow-sm focus:ring-focus focus:border-focus disabled:bg-off disabled:cursor-not-allowed`,{"border-danger":e.error}])},null,42,iT),c.value?(l(),j(`button`,{key:0,type:`button`,onClick:e=>h(a),disabled:!c.value,class:`p-2 text-danger hover:text-danger-soft-fg hover:bg-danger-soft rounded-md disabled:opacity-30 disabled:cursor-not-allowed`,title:t.$t(`common.delete`)},[...n[5]||=[M(`svg`,{class:`w-5 h-5`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[M(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16`})],-1)]],8,aT)):r(``,!0)],8,eT))),128))])),o.value.length===0?(l(),j(`div`,oT,O(t.$t(`fields.repeatable.empty`,{add:f.value})),1)):r(``,!0),s.value?(l(),j(`button`,{key:4,"data-action":`repeatable-add`,type:`button`,onClick:m,class:`mt-2 inline-flex items-center px-3 py-2 text-sm font-medium text-accent bg-accent-soft hover:bg-accent-soft rounded-md border border-accent-soft transition-colors`},[n[6]||=M(`svg`,{class:`w-4 h-4 mr-1.5`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[M(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M12 4v16m8-8H4`})],-1),y(` `+O(f.value),1)])):r(``,!0),e.maxItems>0?(l(),j(`div`,sT,O(o.value.length)+` / `+O(e.maxItems),1)):r(``,!0)]))}},lT={class:`belongs-to-many-field`},uT=[`for`],dT={key:0,class:`text-danger`},fT={key:0,class:`mb-2 flex flex-wrap gap-1`},pT=[`onClick`,`disabled`],mT=[`disabled`],hT=[`data-option-value`,`data-option-selected`],gT=[`checked`,`onChange`,`disabled`],_T={class:`ml-2 text-sm text-fg`},vT={key:2,class:`border border-field rounded-md px-3 py-4 text-center text-muted text-sm`},yT={key:3,class:`mt-1 text-sm text-muted`},bT={key:4,class:`mt-1 text-sm text-danger`},xT={__name:`BelongsToManyField`,props:{name:{type:String,required:!0},label:{type:String,default:``},modelValue:{type:Array,default:()=>[]},options:{type:Array,default:()=>[]},required:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},placeholder:{type:String,default:null},error:{type:String,default:null},hint:{type:String,default:null},multiple:{type:Boolean,default:!0}},emits:[`update:modelValue`],setup(e,{emit:t}){let n=e,i=t,a=D({get:()=>n.modelValue?Array.isArray(n.modelValue)?n.modelValue:[n.modelValue]:[],set:e=>i(`update:modelValue`,e||[])}),o=e=>a.value.map(String).includes(String(e)),s=e=>{if(n.disabled)return;let t=[...a.value],r=t.findIndex(t=>String(t)===String(e));r===-1?t.push(e):t.splice(r,1),i(`update:modelValue`,t)},c=D(()=>a.value.map(e=>n.options.find(t=>String(t.value)===String(e))?.label).filter(Boolean)),u=()=>{n.disabled||i(`update:modelValue`,[])};return(t,n)=>(l(),j(`div`,lT,[M(`label`,{for:e.name,class:`block text-sm font-medium text-fg mb-1`},[y(O(e.label)+` `,1),e.required?(l(),j(`span`,dT,`*`)):r(``,!0)],8,uT),a.value.length>0?(l(),j(`div`,fT,[(l(!0),j(A,null,_(c.value,(t,r)=>(l(),j(`span`,{key:r,class:`inline-flex items-center px-2 py-1 rounded-md text-sm bg-accent-soft text-accent-hover`},[y(O(t)+` `,1),M(`button`,{type:`button`,onClick:e=>s(a.value[r]),class:`ml-1 text-accent hover:text-accent-hover`,disabled:e.disabled},[...n[0]||=[M(`svg`,{class:`w-3 h-3`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[M(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M6 18L18 6M6 6l12 12`})],-1)]],8,pT)]))),128)),a.value.length>1?(l(),j(`button`,{key:0,type:`button`,onClick:u,class:`text-xs text-muted hover:text-danger`,disabled:e.disabled},O(t.$t(`fields.belongs_to_many.clear_all`)),9,mT)):r(``,!0)])):r(``,!0),e.options.length>0?(l(),j(`div`,{key:1,class:g([`border border-field rounded-md max-h-64 overflow-y-auto`,{"border-danger":e.error,"opacity-50":e.disabled}])},[(l(!0),j(A,null,_(e.options,t=>(l(),j(`label`,{key:t.value,"data-option-value":t.value,"data-option-selected":o(t.value)?`true`:`false`,class:g([`flex items-center px-3 py-2 hover:bg-hover cursor-pointer border-b border-line last:border-b-0`,{"bg-accent-soft":o(t.value)}])},[M(`input`,{type:`checkbox`,checked:o(t.value),onChange:e=>s(t.value),disabled:e.disabled,class:`h-4 w-4 text-accent focus:ring-focus border-field rounded`},null,40,gT),M(`span`,_T,O(t.label),1)],10,hT))),128))],2)):(l(),j(`div`,vT,O(t.$t(`fields.belongs_to_many.no_options`)),1)),e.hint&&!e.error?(l(),j(`p`,yT,O(e.hint),1)):r(``,!0),e.error?(l(),j(`p`,bT,O(e.error),1)):r(``,!0)]))}};function ST(e){return e===0?!1:Array.isArray(e)&&e.length===0?!0:!e}function CT(e){return(...t)=>!e(...t)}function wT(e,t){return e===void 0&&(e=`undefined`),e===null&&(e=`null`),e===!1&&(e=`false`),e.toString().toLowerCase().indexOf(t.trim())!==-1}function TT(e){return e.filter(e=>!e.$isLabel)}function ET(e,t){return n=>n.reduce((n,r)=>r[e]&&r[e].length?(n.push({$groupLabel:r[t],$isLabel:!0}),n.concat(r[e])):n,[])}var DT=(...e)=>t=>e.reduce((e,t)=>t(e),t),OT={name:`vue-multiselect`,mixins:[{data(){return{search:``,isOpen:!1,preferredOpenDirection:`below`,optimizedHeight:this.maxHeight}},props:{internalSearch:{type:Boolean,default:!0},options:{type:Array,required:!0},multiple:{type:Boolean,default:!1},trackBy:{type:String},label:{type:String},searchable:{type:Boolean,default:!0},clearOnSelect:{type:Boolean,default:!0},hideSelected:{type:Boolean,default:!1},placeholder:{type:String,default:`Select option`},allowEmpty:{type:Boolean,default:!0},resetAfter:{type:Boolean,default:!1},closeOnSelect:{type:Boolean,default:!0},customLabel:{type:Function,default(e,t){return ST(e)?``:t?e[t]:e}},taggable:{type:Boolean,default:!1},tagPlaceholder:{type:String,default:`Press enter to create a tag`},tagPosition:{type:String,default:`top`},max:{type:[Number,Boolean],default:!1},id:{default:null},optionsLimit:{type:Number,default:1e3},groupValues:{type:String},groupLabel:{type:String},groupSelect:{type:Boolean,default:!1},blockKeys:{type:Array,default(){return[]}},preserveSearch:{type:Boolean,default:!1},preselectFirst:{type:Boolean,default:!1},preventAutofocus:{type:Boolean,default:!1},filteringSortFunc:{type:Function,default:null}},mounted(){!this.multiple&&this.max&&console.warn(`[Vue-Multiselect warn]: Max prop should not be used when prop Multiple equals false.`),this.preselectFirst&&!this.internalValue.length&&this.options.length&&this.select(this.filteredOptions[0])},computed:{internalValue(){return this.modelValue||this.modelValue===0?Array.isArray(this.modelValue)?this.modelValue:[this.modelValue]:[]},filteredOptions(){let e=this.search||``,t=e.toLowerCase().trim(),n=this.options.concat();return n=this.internalSearch?this.groupValues?this.filterAndFlat(n,t,this.label):this.filterOptions(n,t,this.label,this.customLabel):this.groupValues?ET(this.groupValues,this.groupLabel)(n):n,n=this.hideSelected?n.filter(CT(this.isSelected)):n,this.taggable&&t.length&&!this.isExistingOption(t)&&(this.tagPosition===`bottom`?n.push({isTag:!0,label:e}):n.unshift({isTag:!0,label:e})),n.slice(0,this.optionsLimit)},valueKeys(){return this.trackBy?this.internalValue.map(e=>e[this.trackBy]):this.internalValue},optionKeys(){return(this.groupValues?this.flatAndStrip(this.options):this.options).map(e=>this.customLabel(e,this.label).toString().toLowerCase())},currentOptionLabel(){return this.multiple?this.searchable?``:this.placeholder:this.internalValue.length?this.getOptionLabel(this.internalValue[0]):this.searchable?``:this.placeholder}},watch:{internalValue:{handler(){this.resetAfter&&this.internalValue.length&&(this.search=``,this.$emit(`update:modelValue`,this.multiple?[]:null))},deep:!0},search(){this.$emit(`search-change`,this.search)}},emits:[`open`,`search-change`,`close`,`select`,`update:modelValue`,`remove`,`tag`],methods:{getValue(){return this.multiple?this.internalValue:this.internalValue.length===0?null:this.internalValue[0]},filterAndFlat(e,t,n){return DT(this.filterGroups(t,n,this.groupValues,this.groupLabel,this.customLabel),ET(this.groupValues,this.groupLabel))(e)},flatAndStrip(e){return DT(ET(this.groupValues,this.groupLabel),TT)(e)},updateSearch(e){this.search=e},isExistingOption(e){return this.options?this.optionKeys.indexOf(e)>-1:!1},isSelected(e){let t=this.trackBy?e[this.trackBy]:e;return this.valueKeys.indexOf(t)>-1},isOptionDisabled(e){return!!e.$isDisabled},getOptionLabel(e){if(ST(e))return``;if(e.isTag)return e.label;if(e.$isLabel)return e.$groupLabel;let t=this.customLabel(e,this.label);return ST(t)?``:t},select(e,t){if(e.$isLabel&&this.groupSelect)this.selectGroup(e);else if(!(this.blockKeys.indexOf(t)!==-1||this.disabled||e.$isDisabled||e.$isLabel)&&!(this.max&&this.multiple&&this.internalValue.length===this.max)&&(t!==`Tab`||this.pointerDirty)){if(e.isTag)this.$emit(`tag`,e.label,this.id),this.search=``,this.closeOnSelect&&!this.multiple&&this.deactivate();else{if(this.isSelected(e)){t!==`Tab`&&this.removeElement(e);return}this.multiple?this.$emit(`update:modelValue`,this.internalValue.concat([e])):this.$emit(`update:modelValue`,e),this.$emit(`select`,e,this.id),this.clearOnSelect&&(this.search=``)}this.closeOnSelect&&this.deactivate()}},selectGroup(e){let t=this.options.find(t=>t[this.groupLabel]===e.$groupLabel);if(t){if(this.wholeGroupSelected(t)){this.$emit(`remove`,t[this.groupValues],this.id);let e=this.trackBy?t[this.groupValues].map(e=>e[this.trackBy]):t[this.groupValues],n=this.internalValue.filter(t=>e.indexOf(this.trackBy?t[this.trackBy]:t)===-1);this.$emit(`update:modelValue`,n)}else{let e=t[this.groupValues].filter(e=>!(this.isOptionDisabled(e)||this.isSelected(e)));this.max&&e.splice(this.max-this.internalValue.length),this.$emit(`select`,e,this.id),this.$emit(`update:modelValue`,this.internalValue.concat(e))}this.closeOnSelect&&this.deactivate()}},wholeGroupSelected(e){return e[this.groupValues].every(e=>this.isSelected(e)||this.isOptionDisabled(e))},wholeGroupDisabled(e){return e[this.groupValues].every(this.isOptionDisabled)},removeElement(e,t=!0){if(this.disabled||e.$isDisabled)return;if(!this.allowEmpty&&this.internalValue.length<=1){this.deactivate();return}let n=typeof e==`object`?this.valueKeys.indexOf(e[this.trackBy]):this.valueKeys.indexOf(e);if(this.multiple){let e=this.internalValue.slice(0,n).concat(this.internalValue.slice(n+1));this.$emit(`update:modelValue`,e)}else this.$emit(`update:modelValue`,null);this.$emit(`remove`,e,this.id),this.closeOnSelect&&t&&this.deactivate()},removeLastElement(){this.blockKeys.indexOf(`Delete`)===-1&&this.search.length===0&&Array.isArray(this.internalValue)&&this.internalValue.length&&this.removeElement(this.internalValue[this.internalValue.length-1],!1)},activate(){this.isOpen||this.disabled||(this.adjustPosition(),this.groupValues&&this.pointer===0&&this.filteredOptions.length&&(this.pointer=1),this.isOpen=!0,this.searchable?(this.preserveSearch||(this.search=``),this.preventAutofocus||this.$nextTick(()=>this.$refs.search&&this.$refs.search.focus())):this.preventAutofocus||this.$el!==void 0&&this.$el.focus(),this.$emit(`open`,this.id))},deactivate(){this.isOpen&&(this.isOpen=!1,this.searchable?this.$refs.search!==null&&this.$refs.search!==void 0&&this.$refs.search.blur():this.$el!==void 0&&this.$el.blur(),this.preserveSearch||(this.search=``),this.$emit(`close`,this.getValue(),this.id))},toggle(){this.isOpen?this.deactivate():this.activate()},adjustPosition(){if(typeof window>`u`)return;let e=this.$el.getBoundingClientRect().top,t=window.innerHeight-this.$el.getBoundingClientRect().bottom;t>this.maxHeight||t>e||this.openDirection===`below`||this.openDirection===`bottom`?(this.preferredOpenDirection=`below`,this.optimizedHeight=Math.min(t-40,this.maxHeight)):(this.preferredOpenDirection=`above`,this.optimizedHeight=Math.min(e-40,this.maxHeight))},filterOptions(e,t,n,r){return t?e.filter(e=>wT(r(e,n),t)).sort((e,t)=>typeof this.filteringSortFunc==`function`?this.filteringSortFunc(e,t):r(e,n).length-r(t,n).length):e},filterGroups(e,t,n,r,i){return a=>a.map(a=>{if(!a[n])return console.warn(`Options passed to vue-multiselect do not contain groups, despite the config.`),[];let o=this.filterOptions(a[n],e,t,i);return o.length?{[r]:a[r],[n]:o}:[]})}}},{data(){return{pointer:0,pointerDirty:!1}},props:{showPointer:{type:Boolean,default:!0},optionHeight:{type:Number,default:40}},computed:{pointerPosition(){return this.pointer*this.optionHeight},visibleElements(){return this.optimizedHeight/this.optionHeight}},watch:{filteredOptions(){this.pointerAdjust()},isOpen(){this.pointerDirty=!1},pointer(){this.$refs.search&&this.$refs.search.setAttribute(`aria-activedescendant`,this.id+`-`+this.pointer.toString())}},methods:{optionHighlight(e,t){return{"multiselect__option--highlight":e===this.pointer&&this.showPointer,"multiselect__option--selected":this.isSelected(t)}},groupHighlight(e,t){if(!this.groupSelect)return[`multiselect__option--disabled`,{"multiselect__option--group":t.$isLabel}];let n=this.options.find(e=>e[this.groupLabel]===t.$groupLabel);return n&&!this.wholeGroupDisabled(n)?[`multiselect__option--group`,{"multiselect__option--highlight":e===this.pointer&&this.showPointer},{"multiselect__option--group-selected":this.wholeGroupSelected(n)}]:`multiselect__option--disabled`},addPointerElement({key:e}=`Enter`){this.filteredOptions.length>0&&this.select(this.filteredOptions[this.pointer],e),this.pointerReset()},pointerForward(){this.pointer0?(this.pointer--,this.$refs.list?.scrollTop>=this.pointerPosition&&(this.$refs.list.scrollTop=this.pointerPosition),this.filteredOptions[this.pointer]&&this.filteredOptions[this.pointer].$isLabel&&!this.groupSelect&&this.pointerBackward()):this.filteredOptions[this.pointer]&&this.filteredOptions[0].$isLabel&&!this.groupSelect&&this.pointerForward(),this.pointerDirty=!0},pointerReset(){this.closeOnSelect&&(this.pointer=0,this.$refs.list&&(this.$refs.list.scrollTop=0))},pointerAdjust(){this.pointer>=this.filteredOptions.length-1&&(this.pointer=this.filteredOptions.length?this.filteredOptions.length-1:0),this.filteredOptions.length>0&&this.filteredOptions[this.pointer]&&this.filteredOptions[this.pointer].$isLabel&&!this.groupSelect&&this.pointerForward()},pointerSet(e){this.pointer=e,this.pointerDirty=!0}}}],compatConfig:{MODE:3,ATTR_ENUMERATED_COERCION:!1},props:{name:{type:String,default:``},modelValue:{type:null,default(){return[]}},selectLabel:{type:String,default:`Press enter to select`},selectGroupLabel:{type:String,default:`Press enter to select group`},selectedLabel:{type:String,default:`Selected`},deselectLabel:{type:String,default:`Press enter to remove`},deselectGroupLabel:{type:String,default:`Press enter to deselect group`},showLabels:{type:Boolean,default:!0},limit:{type:Number,default:99999},maxHeight:{type:Number,default:300},limitText:{type:Function,default:e=>`and ${e} more`},loading:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},spellcheck:{type:Boolean,default:!1},openDirection:{type:String,default:``},showNoOptions:{type:Boolean,default:!0},showNoResults:{type:Boolean,default:!0},tabindex:{type:Number,default:0},required:{type:Boolean,default:!1},useTeleport:{type:Boolean,default:!1},teleportTarget:{type:[String,Object],default:`body`},contentWrapperClass:{type:[String,Array,Object],default:``}},data(){return{dropdownStyles:{},ready:!1}},computed:{hasOptionGroup(){return this.groupValues&&this.groupLabel&&this.groupSelect},isSingleLabelVisible(){return(this.singleValue||this.singleValue===0)&&(!this.isOpen||!this.searchable)&&!this.visibleValues.length},isPlaceholderVisible(){return!this.internalValue.length&&(!this.searchable||!this.isOpen)},visibleValues(){return this.multiple?this.internalValue.slice(0,this.limit):[]},singleValue(){return this.internalValue[0]},deselectLabelText(){return this.showLabels?this.deselectLabel:``},deselectGroupLabelText(){return this.showLabels?this.deselectGroupLabel:``},selectLabelText(){return this.showLabels?this.selectLabel:``},selectGroupLabelText(){return this.showLabels?this.selectGroupLabel:``},selectedLabelText(){return this.showLabels?this.selectedLabel:``},inputStyle(){return this.searchable||this.multiple&&this.modelValue&&this.modelValue.length?this.isOpen?{width:`100%`}:{width:`0`,position:`absolute`,padding:`0`}:``},contentStyle(){return this.options.length?{display:`inline-block`}:{display:`block`}},isAbove(){return this.openDirection===`above`||this.openDirection===`top`?!0:this.openDirection===`below`||this.openDirection===`bottom`?!1:this.preferredOpenDirection===`above`},showSearchInput(){return this.searchable&&(this.hasSingleSelectedSlot&&(this.visibleSingleValue||this.visibleSingleValue===0)?this.isOpen:!0)},isRequired(){return this.required!==!1&&this.internalValue.length<=0}},watch:{isOpen(e){e&&(this.useTeleport?(this.ready=!1,this.$nextTick(()=>{let e=this.$el.getBoundingClientRect();this.dropdownStyles={position:`absolute`,top:`${e.bottom+window.scrollY}px`,left:`${e.left+window.scrollX}px`,width:`${e.width}px`,zIndex:9999},this.ready=!0})):this.ready=!0)}}},kT=[`tabindex`,`aria-expanded`,`aria-owns`,`aria-activedescendant`],AT={ref:`tags`,class:`multiselect__tags`},jT={class:`multiselect__tags-wrap`},MT=[`textContent`],NT=[`onKeydown`,`onMousedown`],PT=[`textContent`],FT={class:`multiselect__spinner`},IT=[`name`,`id`,`spellcheck`,`placeholder`,`required`,`value`,`disabled`,`tabindex`,`aria-label`,`aria-controls`],LT=[`id`,`aria-multiselectable`],RT={key:0},zT={class:`multiselect__option`},BT=[`aria-selected`,`id`,`role`],VT=[`onClick`,`onMouseenter`,`data-select`,`data-selected`,`data-deselect`],HT=[`data-select`,`data-deselect`,`onMouseenter`,`onMousedown`],UT={class:`multiselect__option`},WT={class:`multiselect__option`};function GT(t,n,i,o,c,u){return l(),j(`div`,{tabindex:t.searchable?-1:i.tabindex,class:g([{"multiselect--active":t.isOpen,"multiselect--disabled":i.disabled,"multiselect--above":u.isAbove,"multiselect--has-options-group":u.hasOptionGroup},`multiselect`]),onFocus:n[14]||=e=>t.activate(),onBlur:n[15]||=e=>!t.searchable&&t.deactivate(),onKeydown:[n[16]||=k(E(e=>t.pointerForward(),[`self`,`prevent`]),[`down`]),n[17]||=k(E(e=>t.pointerBackward(),[`self`,`prevent`]),[`up`]),n[18]||=k(E(e=>t.addPointerElement(e),[`stop`,`self`]),[`enter`,`tab`])],onKeyup:n[19]||=k(e=>t.deactivate(),[`esc`]),role:`combobox`,"aria-expanded":t.isOpen,"aria-owns":`listbox-`+t.id,"aria-activedescendant":t.isOpen&&t.pointer!==null?t.id+`-`+t.pointer:null},[N(t.$slots,`caret`,{toggle:t.toggle},()=>[M(`div`,{onMousedown:n[0]||=E(e=>t.toggle(),[`prevent`,`stop`]),class:`multiselect__select`},null,32)]),N(t.$slots,`clear`,{search:t.search}),M(`div`,AT,[N(t.$slots,`selection`,{search:t.search,remove:t.removeElement,values:u.visibleValues,isOpen:t.isOpen},()=>[s(M(`div`,jT,[(l(!0),j(A,null,_(u.visibleValues,(e,r)=>N(t.$slots,`tag`,{option:e,search:t.search,remove:t.removeElement},()=>[(l(),j(`span`,{class:`multiselect__tag`,key:r,onMousedown:n[1]||=E(()=>{},[`prevent`])},[M(`span`,{textContent:O(t.getOptionLabel(e))},null,8,MT),M(`i`,{tabindex:`1`,onKeydown:k(E(n=>t.removeElement(e),[`prevent`]),[`enter`]),onMousedown:E(n=>t.removeElement(e),[`prevent`]),class:`multiselect__tag-icon`},null,40,NT)],32))])),256))],512),[[re,u.visibleValues.length>0]]),t.internalValue&&t.internalValue.length>i.limit?N(t.$slots,`limit`,{key:0},()=>[M(`strong`,{class:`multiselect__strong`,textContent:O(i.limitText(t.internalValue.length-i.limit))},null,8,PT)]):r(`v-if`,!0)]),a(ee,{name:`multiselect__loading`},{default:S(()=>[N(t.$slots,`loading`,{},()=>[s(M(`div`,FT,null,512),[[re,i.loading]])])]),_:3}),t.searchable?(l(),j(`input`,{key:0,ref:`search`,name:i.name,id:t.id,type:`text`,autocomplete:`off`,spellcheck:i.spellcheck,placeholder:t.placeholder,required:u.isRequired,style:e(u.inputStyle),value:t.search,disabled:i.disabled,tabindex:i.tabindex,"aria-label":i.name+`-searchbox`,onInput:n[2]||=e=>t.updateSearch(e.target.value),onFocus:n[3]||=E(e=>t.activate(),[`prevent`]),onBlur:n[4]||=E(e=>t.deactivate(),[`prevent`]),onKeyup:n[5]||=k(e=>t.deactivate(),[`esc`]),onKeydown:[n[6]||=k(E(e=>t.pointerForward(),[`prevent`]),[`down`]),n[7]||=k(E(e=>t.pointerBackward(),[`prevent`]),[`up`]),n[8]||=k(E(e=>t.addPointerElement(e),[`prevent`,`stop`,`self`]),[`enter`]),n[9]||=k(E(e=>t.removeLastElement(),[`stop`]),[`delete`])],class:`multiselect__input`,"aria-controls":`listbox-`+t.id},null,44,IT)):r(`v-if`,!0),u.isSingleLabelVisible?(l(),j(`span`,{key:1,class:`multiselect__single`,onMousedown:n[10]||=E((...e)=>t.toggle&&t.toggle(...e),[`prevent`])},[N(t.$slots,`singleLabel`,{option:u.singleValue},()=>[y(O(t.currentOptionLabel),1)])],32)):r(`v-if`,!0),u.isPlaceholderVisible?(l(),j(`span`,{key:2,class:`multiselect__placeholder`,onMousedown:n[11]||=E((...e)=>t.toggle&&t.toggle(...e),[`prevent`])},[N(t.$slots,`placeholder`,{},()=>[y(O(t.placeholder),1)])],32)):r(`v-if`,!0)],512),(l(),v(ue,{to:i.teleportTarget,disabled:!i.useTeleport},[a(ee,{name:`multiselect`},{default:S(()=>[t.isOpen&&c.ready?(l(),j(`div`,{key:0,class:g([`multiselect__content-wrapper`,i.contentWrapperClass]),onFocus:n[12]||=(...e)=>t.activate&&t.activate(...e),tabindex:`-1`,onMousedown:n[13]||=E(()=>{},[`prevent`]),style:e([c.dropdownStyles,{maxHeight:t.optimizedHeight+`px`}]),ref:`list`},[M(`ul`,{class:`multiselect__content`,style:e(u.contentStyle),role:`listbox`,id:`listbox-`+t.id,"aria-multiselectable":t.multiple},[N(t.$slots,`beforeList`),t.multiple&&t.max===t.internalValue.length?(l(),j(`li`,RT,[M(`span`,zT,[N(t.$slots,`maxElements`,{},()=>[y(`Maximum of `+O(t.max)+` options selected. First remove a selected option to select another.`,1)])])])):r(`v-if`,!0),!t.max||t.internalValue.length(l(),j(`li`,{class:`multiselect__element`,key:n,"aria-selected":t.isSelected(e),id:t.id+`-`+n,role:e&&(e.$isLabel||e.$isDisabled)?null:`option`},[e&&(e.$isLabel||e.$isDisabled)?r(`v-if`,!0):(l(),j(`span`,{key:0,class:g([t.optionHighlight(n,e),`multiselect__option`]),onClick:E(n=>t.select(e),[`stop`]),onMouseenter:E(e=>t.pointerSet(n),[`self`]),"data-select":e&&e.isTag?t.tagPlaceholder:u.selectLabelText,"data-selected":u.selectedLabelText,"data-deselect":u.deselectLabelText},[N(t.$slots,`option`,{option:e,search:t.search,index:n},()=>[M(`span`,null,O(t.getOptionLabel(e)),1)])],42,VT)),e&&(e.$isLabel||e.$isDisabled)?(l(),j(`span`,{key:1,"data-select":t.groupSelect&&u.selectGroupLabelText,"data-deselect":t.groupSelect&&u.deselectGroupLabelText,class:g([t.groupHighlight(n,e),`multiselect__option`]),onMouseenter:E(e=>t.groupSelect&&t.pointerSet(n),[`self`]),onMousedown:E(n=>t.selectGroup(e),[`prevent`])},[N(t.$slots,`option`,{option:e,search:t.search,index:n},()=>[M(`span`,null,O(t.getOptionLabel(e)),1)])],42,HT)):r(`v-if`,!0)],8,BT))),128)):r(`v-if`,!0),s(M(`li`,null,[M(`span`,UT,[N(t.$slots,`noResult`,{search:t.search},()=>[n[20]||=y(`No elements found. Consider changing the search query.`)])])],512),[[re,i.showNoResults&&t.filteredOptions.length===0&&t.search&&!i.loading]]),s(M(`li`,null,[M(`span`,WT,[N(t.$slots,`noOptions`,{},()=>[n[21]||=y(`List is empty.`)])])],512),[[re,i.showNoOptions&&t.filteredOptions.length===0&&!t.search&&!i.loading]]),N(t.$slots,`afterList`)],12,LT)],38)):r(`v-if`,!0)]),_:3})],8,[`to`,`disabled`]))],42,kT)}OT.render=GT;var KT=[`data-selected-value`],qT=[`aria-label`,`disabled`,`onMousedown`,`onKeydown`],JT=[`data-option-value`,`data-option-selected`],YT={class:`atrium-multiselect__check`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`,"aria-hidden":`true`},XT={key:0,"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2.5`,d:`M5 13l4 4L19 7`},ZT={__name:`MultiSelectField`,props:{id:{type:String,required:!0},modelValue:{type:[Array,String,Number],default:()=>[]},options:{type:Array,default:()=>[]},placeholder:{type:String,default:``},disabled:{type:Boolean,default:!1},error:{type:String,default:null}},emits:[`update:modelValue`],setup(e,{emit:t}){let n=e,i=t,a=D(()=>n.modelValue===null||n.modelValue===void 0||n.modelValue===``?[]:(Array.isArray(n.modelValue)?n.modelValue:[n.modelValue]).map(String)),o=D({get:()=>a.value.map(e=>n.options.find(t=>String(t.value)===e)).filter(Boolean),set:e=>i(`update:modelValue`,e.map(e=>e.value))}),s=e=>a.value.includes(String(e.value));return(t,n)=>(l(),v(T(OT),{modelValue:o.value,"onUpdate:modelValue":n[0]||=e=>o.value=e,id:e.id,options:e.options,"track-by":`value`,label:`label`,multiple:!0,"close-on-select":!1,"clear-on-select":!1,"show-labels":!1,placeholder:e.placeholder,disabled:e.disabled,class:g([`atrium-multiselect`,{"atrium-multiselect--error":e.error}]),"data-multiselect":e.id},{tag:S(({option:r,remove:i})=>[M(`span`,{class:`atrium-multiselect__tag`,"data-selected-value":r.value},[y(O(r.label)+` `,1),M(`button`,{type:`button`,class:`atrium-multiselect__remove`,"aria-label":t.$t(`common.delete`)+`: `+r.label,disabled:e.disabled,onMousedown:E(e=>i(r),[`prevent`,`stop`]),onKeydown:k(E(e=>i(r),[`prevent`]),[`enter`])},[...n[1]||=[M(`svg`,{class:`w-3 h-3`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`,"aria-hidden":`true`},[M(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M6 18L18 6M6 6l12 12`})],-1)]],40,qT)],8,KT)]),option:S(({option:e})=>[M(`span`,{class:`atrium-multiselect__option`,"data-option-value":e.value,"data-option-selected":s(e)?`true`:`false`},[(l(),j(`svg`,YT,[s(e)?(l(),j(`path`,XT)):r(``,!0)])),y(` `+O(e.label),1)],8,JT)]),noResult:S(()=>[y(O(t.$t(`fields.multi_select.nothing_found`)),1)]),noOptions:S(()=>[y(O(t.$t(`fields.belongs_to_many.no_options`)),1)]),_:1},8,[`modelValue`,`id`,`options`,`placeholder`,`disabled`,`class`,`data-multiselect`]))}},QT={class:`map-field`},$T=[`for`],eE={key:0,class:`text-danger`},tE=[`id`,`value`,`placeholder`,`disabled`,`readonly`],nE={class:`grid grid-cols-2 gap-2 mt-2`},rE={class:`block text-xs text-muted mb-1`},iE=[`value`,`placeholder`,`disabled`,`readonly`],aE={class:`block text-xs text-muted mb-1`},oE=[`value`,`placeholder`,`disabled`,`readonly`],sE={class:`mt-2 flex items-center gap-3`},cE=[`href`],lE={key:1,class:`mt-1 text-sm text-warning-soft-fg`},uE={key:2,class:`mt-1 text-sm text-muted`},dE={key:3,class:`mt-1 text-sm text-danger`},fE={__name:`MapField`,props:{modelValue:{type:[String,Number,Object,Array],default:null},name:{type:String,default:``},label:{type:String,default:``},type:{type:String,default:`map`},component:{type:String,default:null},required:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},readonly:{type:Boolean,default:!1},hint:{type:String,default:null},placeholder:{type:String,default:null},default:{type:[String,Number,Object,Array],default:null},attributes:{type:Object,default:()=>({})},tab:{type:String,default:null},tabOrder:{type:Number,default:null},error:{type:String,default:null},mapType:{type:String,default:`yandex`},defaultLat:{type:[Number,String],default:null},defaultLng:{type:[Number,String],default:null},defaultZoom:{type:[Number,String],default:null},searchEnabled:{type:Boolean,default:!1},apiKey:{type:String,default:null}},emits:[`update:modelValue`],setup(e,{emit:t}){let n=e,i=t,a=/^-?\d+(\.\d+)?$/,o=w(``),s=w(``),u=w(``),d,f=!1;function p(e){let t={lat:``,lng:``,raw:``,ok:!1};if(e==null)return t;if(Array.isArray(e))return m(e[0],e[1]);if(typeof e==`object`)return m(e.lat??e.latitude??e[0],e.lng??e.lon??e.longitude??e[1]);let n=String(e).trim().replace(/^"+|"+$/g,``).trim();if(n===``)return t;let r=n.split(`,`),i=(r[0]??``).trim(),o=(r[1]??``).trim(),s=a.test(i),c=a.test(o);return{lat:s?i:``,lng:c?o:``,raw:n,ok:s&&c&&r.length===2}}function m(e,t){let n=e==null?``:String(e).trim(),r=t==null?``:String(t).trim(),i=a.test(n),o=a.test(r);return{lat:i?n:``,lng:o?r:``,raw:n===``&&r===``?``:`${n},${r}`,ok:i&&o}}function h(e){let t=p(e);o.value=t.lat,s.value=t.lng,u.value=t.raw}c(()=>n.modelValue,e=>{f&&e===d||h(e)},{immediate:!0});function _(e){d=e,f=!0,i(`update:modelValue`,e)}function v(){let e=o.value.trim(),t=s.value.trim();e===``&&t===``?(u.value=``,_(null)):(u.value=`${e},${t}`,_(u.value))}function b(e){o.value=e.target.value,v()}function x(e){s.value=e.target.value,v()}function S(e){let t=e.target.value;u.value=t;let n=p(t);o.value=n.lat,s.value=n.lng;let r=t.trim();_(r===``?null:r)}function C(){let e=p(u.value);if(!e.ok)return;let t=`${e.lat},${e.lng}`;t!==u.value&&(u.value=t,_(t))}function T(){o.value=``,s.value=``,u.value=``,_(null)}let E=D(()=>p(u.value)),ee=D(()=>u.value!==``),te=D(()=>ee.value&&!E.value.ok),ne=D(()=>{if(!E.value.ok)return null;let e=encodeURIComponent(`${E.value.lat},${E.value.lng}`);if(n.mapType===`google`)return`https://www.google.com/maps/search/?api=1&query=${e}`;let t=Number(n.defaultZoom);return`https://yandex.ru/maps/?text=${e}${Number.isFinite(t)&&t>0?`&z=${t}`:``}`}),k=D(()=>n.defaultLat===null?`55.7558`:String(n.defaultLat)),re=D(()=>n.defaultLng===null?`37.6173`:String(n.defaultLng)),ie=D(()=>`${k.value},${re.value}`);return(t,n)=>(l(),j(`div`,QT,[e.label?(l(),j(`label`,{key:0,for:e.name,class:`block text-sm font-medium text-fg mb-1`},[y(O(e.label)+` `,1),e.required?(l(),j(`span`,eE,`*`)):r(``,!0)],8,$T)):r(``,!0),M(`input`,{id:e.name,type:`text`,"data-map-value":``,value:u.value,placeholder:e.placeholder||ie.value,disabled:e.disabled,readonly:e.readonly,class:g([`w-full border border-field rounded-md px-3 py-2 text-sm focus:outline-none focus:ring-1 focus:ring-focus focus:border-focus`,{"border-danger":e.error}]),onInput:S,onChange:C},null,42,tE),M(`div`,nE,[M(`div`,null,[M(`span`,rE,O(t.$t(`fields.map.latitude`)),1),M(`input`,{type:`number`,"data-map-lat":``,step:`any`,value:o.value,placeholder:k.value,disabled:e.disabled,readonly:e.readonly,class:g([`w-full border border-field rounded-md px-3 py-2 text-sm focus:outline-none focus:ring-1 focus:ring-focus focus:border-focus`,{"border-danger":e.error}]),onInput:b},null,42,iE)]),M(`div`,null,[M(`span`,aE,O(t.$t(`fields.map.longitude`)),1),M(`input`,{type:`number`,"data-map-lng":``,step:`any`,value:s.value,placeholder:re.value,disabled:e.disabled,readonly:e.readonly,class:g([`w-full border border-field rounded-md px-3 py-2 text-sm focus:outline-none focus:ring-1 focus:ring-focus focus:border-focus`,{"border-danger":e.error}]),onInput:x},null,42,oE)])]),M(`div`,sE,[ne.value?(l(),j(`a`,{key:0,href:ne.value,target:`_blank`,rel:`noopener noreferrer`,"data-map-link":``,class:`text-sm text-accent hover:text-accent-soft-fg`},O(t.$t(`fields.map.open_on_map`)),9,cE)):r(``,!0),ee.value&&!e.disabled&&!e.readonly?(l(),j(`button`,{key:1,type:`button`,"data-map-clear":``,class:`text-sm text-muted hover:text-danger`,onClick:T},O(t.$t(`fields.clear`)),1)):r(``,!0)]),te.value?(l(),j(`p`,lE,O(t.$t(`fields.map.parse_error`,{example:`55.7558,37.6173`})),1)):r(``,!0),e.hint&&!e.error?(l(),j(`p`,uE,O(e.hint),1)):r(``,!0),e.error?(l(),j(`p`,dE,O(e.error),1)):r(``,!0)]))}},pE=[`data-field`,`data-field-type`,`data-field-tab`,`data-field-required`],mE=[`for`],hE={key:0,class:`text-danger`},gE={key:2,class:`flex items-center`},_E=[`id`,`true-value`,`false-value`,`disabled`,`readonly`],vE=[`for`],yE={key:0,class:`text-danger`},bE=[`id`,`innerHTML`],xE=[`id`,`placeholder`,`required`,`disabled`,`readonly`,`rows`],SE=[`id`,`required`,`disabled`],CE={key:0,value:``},wE=[`value`],TE=[`data-upload-state`],EE={key:0,class:`relative w-24 h-24 rounded-lg overflow-hidden border border-line shrink-0`},DE=[`src`],OE=[`disabled`,`title`],kE=[`id`,`accept`,`disabled`],AE=[`disabled`],jE={key:0,class:`mt-2`},ME={class:`h-1.5 w-full bg-off rounded overflow-hidden`},NE=[`data-upload-progress`],PE={class:`mt-1 text-xs text-muted`},FE={key:1,"data-upload-error":``,class:`mt-1 text-sm text-danger`},IE=[`data-upload-state`],LE={key:0,"data-file-name":``,class:`flex items-center space-x-2 shrink-0`},RE=[`href`,`title`],zE=[`disabled`,`title`],BE=[`id`,`accept`,`disabled`],VE=[`disabled`],HE={key:0,class:`mt-2`},UE={class:`h-1.5 w-full bg-off rounded overflow-hidden`},WE=[`data-upload-progress`],GE={class:`mt-1 text-xs text-muted`},KE={key:1,"data-upload-error":``,class:`mt-1 text-sm text-danger`},qE=[`id`,`type`,`placeholder`,`required`,`disabled`,`readonly`,`min`,`max`,`step`],JE={key:10,class:`mt-1 text-sm text-muted`},YE={key:11,"data-error":``,class:`mt-1 text-sm text-danger`},XE={__name:`AdminFieldRenderer`,props:{field:{type:Object,required:!0},modelValue:{type:[String,Number,Boolean,Array,Object],default:null},error:{type:String,default:null}},emits:[`update:modelValue`],setup(t,{emit:n}){let i=t,a=n,o={wysiwyg:u(mC),color:u(TC),slug:u(RC),treeSelect:u(aw),gallery:u(Sw),repeatable:u(cT),content:u(Vw),belongsToMany:u(xT),map:u(fE)},c=D(()=>i.field.type in o),d=D(()=>c.value&&i.field.type!==`repeatable`),f=D(()=>o[i.field.type]||null),p=D(()=>({text:`text`,email:`email`,password:`password`,number:`number`,date:`date`,datetime:`datetime-local`,url:`url`,tel:`tel`})[i.field.type]||`text`),m=D({get:()=>i.modelValue,set:e=>a(`update:modelValue`,e)}),h=D({get:()=>{let e=m.value;if(i.field.type!==`date`&&i.field.type!==`datetime`||typeof e!=`string`||e===``)return e;let t=e.replace(` `,`T`);return i.field.type===`date`?t.slice(0,10):t.slice(0,16)},set:e=>{m.value=e}}),b=D(()=>i.field.type===`checkbox`),S=D(()=>i.field.type===`display`),C=D(()=>i.field.type===`textarea`),T=D(()=>i.field.type===`select`||i.field.type===`belongsTo`&&!(i.field.searchable&&i.field.searchRoute)),E=D(()=>i.field.type===`image`),ee=D(()=>i.field.type===`file`);function ne(e){return typeof e!=`string`||e===``?null:/^(https?:)?\/\//i.test(e)||e.startsWith(`/`)?e:`/storage/`+e}let k=D(()=>ne(m.value)),re=D(()=>ne(m.value)),ae=D(()=>{if(typeof m.value!=`string`||m.value===``)return null;let e=m.value.split(`?`)[0].split(`#`)[0],t=e.split(`/`).filter(Boolean).pop()||e;try{return decodeURIComponent(t)}catch{return t}}),se=w(!1),ue=w(0),N=w(null),pe=D(()=>se.value?`uploading`:N.value?`error`:`idle`),me=D(()=>{if(i.field.uploadUrl)return i.field.uploadUrl;try{if(typeof route==`function`)return route(`admin.upload`,void 0,!1)}catch{}return`/admin/upload`});function he(e){if(e.response&&typeof e.response==`object`)return e.response;if(typeof e.response==`string`&&e.response!==``)try{return JSON.parse(e.response)}catch{return null}return null}function ge(e){if(!e)return null;let t=e.errors?.file;return Array.isArray(t)&&t.length>0?String(t[0]):typeof e.message==`string`&&e.message!==``?e.message:null}function _e(e){return new Promise((t,n)=>{let r=new FormData;r.append(`file`,e);let i=new XMLHttpRequest;i.open(`POST`,me.value,!0),i.responseType=`json`;let a=fe();Object.keys(a).forEach(e=>i.setRequestHeader(e,a[e])),i.upload.onprogress=e=>{e.lengthComputable&&e.total>0&&(ue.value=Math.round(e.loaded/e.total*100))},i.onerror=()=>n(Error(P(`fields.upload.network_error`))),i.onabort=()=>n(Error(P(`fields.upload.aborted`))),i.onload=()=>{let e=i.status,r=he(i);e>=200&&e<300?r&&typeof r.url==`string`&&r.url!==``?t(r):n(Error(P(`fields.upload.no_url`))):n(Error(e===401||e===419?de():e===413?P(`fields.upload.too_large`):ge(r)||P(`fields.upload.http_error`,{status:e})))},i.send(r)})}function ve(e){if(typeof e?.url==`string`&&/^https?:\/\//i.test(e.url))return e.url;if(e&&typeof e.path==`string`&&e.path!==``)return`/storage/`+e.path.replace(/^\/+/,``);let t=e?.url;if(typeof t!=`string`||t===``)return null;try{let e=new URL(t,window.location.origin);return e.origin===window.location.origin?e.pathname+e.search:t}catch{return t}}async function ye(e){let t=e.target,n=t.files&&t.files[0];if(!n)return;N.value=null;let r=Number(i.field.maxSize)||0;if(r>0&&n.size>r*1024)N.value=P(`fields.upload.too_big`,{max:r}),t.value=``;else{se.value=!0,ue.value=0;try{let e=await _e(n);m.value=ve(e)}catch(e){N.value=e?.message||P(`fields.upload.failed`)}finally{se.value=!1,t.value=``}}}function be(){m.value=null,N.value=null}let xe=w(!1);function Se(e){m.value=e?.url||null,N.value=null,xe.value=!1}return(n,i)=>(l(),j(`div`,{class:g([`admin-field`,{"has-error":t.error}]),"data-field":t.field.name,"data-field-type":t.field.type,"data-field-tab":t.field.tab,"data-field-required":t.field.required?`true`:`false`},[!b.value&&!c.value?(l(),j(`label`,{key:0,for:t.field.name,class:`block text-sm font-medium text-fg mb-1`},[y(O(t.field.label)+` `,1),t.field.required?(l(),j(`span`,hE,`*`)):r(``,!0)],8,mE)):r(``,!0),c.value?(l(),v(x(f.value),ie({key:1},t.field,{modelValue:m.value,"onUpdate:modelValue":i[0]||=e=>m.value=e,error:t.error}),null,16,[`modelValue`,`error`])):b.value?(l(),j(`div`,gE,[s(M(`input`,{id:t.field.name,"onUpdate:modelValue":i[1]||=e=>m.value=e,type:`checkbox`,"true-value":t.field.checkedValue??!0,"false-value":t.field.checkedValue?null:!1,disabled:t.field.disabled,readonly:t.field.readonly,class:`h-4 w-4 text-accent focus:ring-focus border-field rounded`},null,8,_E),[[le,m.value]]),M(`label`,{for:t.field.name,class:`ml-2 text-sm text-fg`},[y(O(t.field.label)+` `,1),t.field.required?(l(),j(`span`,yE,`*`)):r(``,!0)],8,vE)])):S.value?(l(),j(`div`,{key:3,id:t.field.name,class:`admin-display text-sm text-fg`,innerHTML:m.value},null,8,bE)):C.value?s((l(),j(`textarea`,{key:4,id:t.field.name,"onUpdate:modelValue":i[2]||=e=>m.value=e,placeholder:t.field.placeholder,required:t.field.required,disabled:t.field.disabled,readonly:t.field.readonly,rows:t.field.rows||4,class:g([`w-full px-3 py-2 border border-field rounded-md shadow-sm focus:ring-focus focus:border-focus resize-y`,{"border-danger":t.error}])},null,10,xE)),[[oe,m.value]]):t.field.type===`multiSelect`?(l(),v(ZT,{key:5,id:t.field.name,modelValue:m.value,"onUpdate:modelValue":i[3]||=e=>m.value=e,options:t.field.options,placeholder:t.field.placeholder||n.$t(`common.select`),disabled:t.field.disabled,error:t.error},null,8,[`id`,`modelValue`,`options`,`placeholder`,`disabled`,`error`])):T.value?s((l(),j(`select`,{key:6,id:t.field.name,"onUpdate:modelValue":i[4]||=e=>m.value=e,required:t.field.required,disabled:t.field.disabled,class:g([`w-full px-3 py-2 border border-field rounded-md shadow-sm focus:ring-focus focus:border-focus bg-surface`,{"border-danger":t.error}])},[t.field.required?r(``,!0):(l(),j(`option`,CE,O(t.field.placeholder||n.$t(`common.select`)),1)),(l(!0),j(A,null,_(t.field.options,e=>(l(),j(`option`,{key:e.value,value:e.value},O(e.label),9,wE))),128))],10,SE)),[[ce,m.value]]):E.value?(l(),j(A,{key:7},[M(`div`,{class:`flex items-center space-x-4`,"data-upload-state":pe.value},[k.value?(l(),j(`div`,EE,[M(`img`,{src:k.value,class:`w-full h-full object-cover`},null,8,DE),M(`button`,{type:`button`,onClick:be,disabled:se.value,"data-action":`remove-upload`,title:n.$t(`common.delete`),class:`absolute top-1 right-1 p-1 bg-danger text-on-danger rounded-full hover:bg-danger-hover disabled:opacity-50`},[...i[9]||=[M(`svg`,{class:`w-3 h-3`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[M(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M6 18L18 6M6 6l12 12`})],-1)]],8,OE)])):r(``,!0),M(`input`,{id:t.field.name,type:`file`,accept:t.field.accept||`image/*`,disabled:t.field.disabled||se.value,onChange:ye,class:`block w-full text-sm text-muted file:mr-4 file:py-2 file:px-4 file:rounded-md file:border-0 file:text-sm file:font-medium file:bg-accent-soft file:text-accent-hover hover:file:bg-accent-soft disabled:opacity-50`},null,40,kE),M(`button`,{type:`button`,onClick:i[5]||=e=>xe.value=!0,disabled:t.field.disabled||se.value,"data-action":`pick-from-library`,class:`shrink-0 px-3 py-2 text-sm font-medium text-fg bg-surface border border-field rounded-md hover:bg-hover disabled:opacity-50 whitespace-nowrap`},O(n.$t(`fields.upload.from_library`)),9,AE)],8,TE),se.value?(l(),j(`div`,jE,[M(`div`,ME,[M(`div`,{class:`h-full bg-accent transition-all`,style:e({width:ue.value+`%`}),"data-upload-progress":ue.value},null,12,NE)]),M(`p`,PE,O(n.$t(`fields.upload.progress`,{percent:ue.value})),1)])):r(``,!0),N.value?(l(),j(`p`,FE,O(N.value),1)):r(``,!0)],64)):ee.value?(l(),j(A,{key:8},[M(`div`,{class:`flex items-center space-x-4`,"data-upload-state":pe.value},[ae.value?(l(),j(`div`,LE,[M(`a`,{href:re.value,target:`_blank`,rel:`noopener`,title:m.value,class:`text-sm text-accent hover:underline break-all`},O(ae.value),9,RE),M(`button`,{type:`button`,onClick:be,disabled:se.value,"data-action":`remove-upload`,title:n.$t(`common.delete`),class:`p-1 text-danger hover:text-danger disabled:opacity-50`},[...i[10]||=[M(`svg`,{class:`w-3 h-3`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[M(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M6 18L18 6M6 6l12 12`})],-1)]],8,zE)])):r(``,!0),M(`input`,{id:t.field.name,type:`file`,accept:t.field.accept||void 0,disabled:t.field.disabled||se.value,onChange:ye,class:`block w-full text-sm text-muted file:mr-4 file:py-2 file:px-4 file:rounded-md file:border-0 file:text-sm file:font-medium file:bg-accent-soft file:text-accent-hover hover:file:bg-accent-soft disabled:opacity-50`},null,40,BE),M(`button`,{type:`button`,onClick:i[6]||=e=>xe.value=!0,disabled:t.field.disabled||se.value,"data-action":`pick-from-library`,class:`shrink-0 px-3 py-2 text-sm font-medium text-fg bg-surface border border-field rounded-md hover:bg-hover disabled:opacity-50 whitespace-nowrap`},O(n.$t(`fields.upload.from_library`)),9,VE)],8,IE),se.value?(l(),j(`div`,HE,[M(`div`,UE,[M(`div`,{class:`h-full bg-accent transition-all`,style:e({width:ue.value+`%`}),"data-upload-progress":ue.value},null,12,WE)]),M(`p`,GE,O(n.$t(`fields.upload.progress`,{percent:ue.value})),1)])):r(``,!0),N.value?(l(),j(`p`,KE,O(N.value),1)):r(``,!0)],64)):s((l(),j(`input`,{key:9,id:t.field.name,"onUpdate:modelValue":i[7]||=e=>h.value=e,type:p.value,placeholder:t.field.placeholder,required:t.field.required,disabled:t.field.disabled,readonly:t.field.readonly,min:t.field.min,max:t.field.max,step:t.field.step,class:g([`w-full px-3 py-2 border border-field rounded-md shadow-sm focus:ring-focus focus:border-focus`,{"border-danger":t.error}])},null,10,qE)),[[te,h.value]]),t.field.hint&&!t.error&&!d.value?(l(),j(`p`,JE,O(t.field.hint),1)):r(``,!0),t.error&&!d.value?(l(),j(`p`,YE,O(t.error),1)):r(``,!0),E.value||ee.value?(l(),v(oC,{key:12,show:xe.value,type:E.value?`image`:`all`,onSelect:Se,onClose:i[8]||=e=>xe.value=!1},null,8,[`show`,`type`])):r(``,!0)],10,pE))}},ZE={key:0,class:`mt-1 flex justify-end gap-3 text-xs`,"data-ai":``},QE=[`data-ai-generate`],$E=[`data-ai-translate`],eD={key:0,class:`text-sm text-fg`,"data-ai-working":``},tD={key:1,class:`rounded-md border border-danger bg-danger-soft px-4 py-3 text-sm text-danger-soft-fg`,"data-ai-error":``},nD={key:2,class:`space-y-4`},rD={class:`mb-1 block font-medium text-fg`},iD=[`onUpdate:modelValue`,`data-ai-result`],aD={key:4,class:`mt-2 text-xs text-fg`},oD={__name:`AiAssist`,props:{field:{type:Object,required:!0},locale:{type:String,default:null},translatable:{type:Boolean,default:!1}},emits:[`apply`,`apply-all`],setup(e,{emit:n}){let i=e,c=n,u=se(),d=D(()=>u.props.ai||null),f=t(`aiModule`,null),p=t(`formData`,w({})),m=D(()=>u.props.contentLocales||[]),h=D(()=>d.value?.labels||{}),g=D(()=>!!(d.value&&f&&i.field.ai&&d.value.tasks.includes(i.field.ai.task))),b=D(()=>!!(g.value&&i.translatable&&m.value.length>1&&d.value.tasks.includes(`translate`))),x=w(!1),C=w(!1),T=w(!1),E=w(null),ee=w(``),te=w({}),ne=w(null),k=null,re=0,ie=D(()=>((C.value?h.value.translate_title:h.value.dialog_title)||``).replace(`:field`,i.field.label||i.field.name)),ae=D(()=>[h.value.check,ne.value?(h.value.by||``).replace(`:provider`,ne.value):null].filter(Boolean).join(` `)),ce=D(()=>m.value.filter(e=>e.code!==i.locale));function le(){clearTimeout(k),k=null,re++}o(le);async function ue(e){le();let t=re;C.value=e,x.value=!0,T.value=!0,E.value=null,ee.value=``,te.value={},ne.value=null;try{let n=await fetch(d.value.url,{method:`POST`,credentials:`same-origin`,headers:fe({"Content-Type":`application/json`}),body:JSON.stringify({module:f,field:i.field.name,values:p.value,locale:i.locale,translate:e})});if(!n.ok){let e=n.status===422?await n.clone().json().catch(()=>({})):{};throw Error(e.errors?.field?.[0]||await pe(n,h.value.error))}N(await n.json(),t)}catch(e){t===re&&de(e.message)}}function N(e,t){t===re&&(e.status===`done`?(T.value=!1,ne.value=e.provider||null,ee.value=e.value??``,te.value={...e.values||{}}):e.status===`failed`?de(e.message):k=setTimeout(()=>P(e.id,t),1500))}async function P(e,t){try{let n=await fetch(`${d.value.url}/${e}`,{credentials:`same-origin`,headers:fe()});if(!n.ok)throw Error(await pe(n,h.value.error));N(await n.json(),t)}catch(e){t===re&&de(e.message)}}function de(e){T.value=!1,E.value=e||h.value.error}function ge(){le(),x.value=!1}function _e(){C.value?c(`apply-all`,Object.fromEntries(Object.entries(te.value).filter(([,e])=>String(e??``).trim()!==``))):c(`apply`,ee.value),ge()}return(t,n)=>g.value?(l(),j(`div`,ZE,[M(`button`,{type:`button`,class:`inline-flex items-center gap-1 text-accent hover:text-accent-hover disabled:text-muted disabled:cursor-not-allowed`,"data-ai-generate":e.field.name,onClick:n[0]||=e=>ue(!1)},[n[4]||=M(`svg`,{class:`h-3.5 w-3.5`,viewBox:`0 0 20 20`,fill:`currentColor`,"aria-hidden":`true`},[M(`path`,{d:`M10 1l1.8 5.2L17 8l-5.2 1.8L10 15l-1.8-5.2L3 8l5.2-1.8L10 1zm6 11l.9 2.1L19 15l-2.1.9L16 18l-.9-2.1L13 15l2.1-.9L16 12z`})],-1),y(` `+O(h.value.generate),1)],8,QE),b.value?(l(),j(`button`,{key:0,type:`button`,class:`text-accent hover:text-accent-hover disabled:text-muted disabled:cursor-not-allowed`,"data-ai-translate":e.field.name,onClick:n[1]||=e=>ue(!0)},O(h.value.translate),9,$E)):r(``,!0),a(me,{show:x.value,title:ie.value,"max-width":`2xl`,onClose:ge},{footer:S(()=>[a(he,{variant:`outline`,onClick:ge},{default:S(()=>[y(O(h.value.cancel),1)]),_:1}),E.value?(l(),v(he,{key:0,variant:`secondary`,onClick:n[3]||=e=>ue(C.value)},{default:S(()=>[y(O(h.value.retry),1)]),_:1})):(l(),v(he,{key:1,disabled:T.value,"data-ai-accept":``,onClick:_e},{default:S(()=>[y(O(h.value.accept),1)]),_:1},8,[`disabled`]))]),default:S(()=>[T.value?(l(),j(`p`,eD,O(h.value.working),1)):E.value?(l(),j(`div`,tD,O(E.value),1)):C.value?(l(),j(`div`,nD,[(l(!0),j(A,null,_(ce.value,e=>(l(),j(`label`,{key:e.code,class:`block text-sm`},[M(`span`,rD,O(e.name),1),s(M(`textarea`,{"onUpdate:modelValue":t=>te.value[e.code]=t,rows:`4`,class:`w-full rounded-md border border-field bg-surface px-3 py-2 text-sm text-fg focus:border-focus focus:outline-none focus:ring-1 focus:ring-focus`,"data-ai-result":e.code},null,8,iD),[[oe,te.value[e.code]]])]))),128))])):s((l(),j(`textarea`,{key:3,"onUpdate:modelValue":n[2]||=e=>ee.value=e,rows:`8`,class:`w-full rounded-md border border-field bg-surface px-3 py-2 text-sm text-fg focus:border-focus focus:outline-none focus:ring-1 focus:ring-focus`,"data-ai-result":``},null,512)),[[oe,ee.value]]),!T.value&&!E.value?(l(),j(`p`,aD,O(ae.value),1)):r(``,!0)]),_:1},8,[`show`,`title`])])):r(``,!0)}},sD={__name:`FormField`,props:{field:{type:Object,required:!0},modelValue:{type:[String,Number,Boolean,Array,Object],default:null},errors:{type:Object,default:()=>({})}},emits:[`update:modelValue`],setup(e,{emit:n}){let i=e,a=n,o=t(`contentLocale`,w(null)),s=D(()=>se().props.contentLocales||[]),c=D(()=>s.value.find(e=>e.code===o.value)),u=D(()=>!!(i.field.translatable&&c.value)),d=D(()=>{if(!u.value)return i.field;let e={...i.field};return s.value.length>1&&(e.label=`${e.label} (${c.value.name})`),c.value.default||(e.required=!1),e}),f=D(()=>u.value?i.modelValue?.[o.value]??``:i.modelValue),p=D(()=>u.value?i.errors[`${i.field.name}.${o.value}`]??i.errors[i.field.name]:i.errors[i.field.name]);function m(e){a(`update:modelValue`,u.value?{...i.modelValue||{},[o.value]:e}:e)}function h(e){a(`update:modelValue`,{...i.modelValue||{},...e})}return(t,n)=>(l(),j(A,null,[(l(),v(XE,{key:u.value?T(o):`value`,field:d.value,"model-value":f.value,error:p.value,"data-content-locale-field":u.value?T(o):null,"onUpdate:modelValue":m},null,8,[`field`,`model-value`,`error`,`data-content-locale-field`])),e.field.ai?(l(),v(oD,{key:0,field:d.value,locale:u.value?T(o):null,translatable:u.value,onApply:m,onApplyAll:h},null,8,[`field`,`locale`,`translatable`])):r(``,!0)],64))}};export{sD as t}; \ No newline at end of file +`);return{...c,raw:u}}},addCommands(){return{insertTable:({rows:e=3,cols:t=3,withHeaderRow:n=!0}={})=>({tr:r,dispatch:i,editor:a})=>{let o=Px(a.schema,e,t,n);if(i){let e=r.selection.from+1;r.replaceSelectionWith(o).scrollIntoView().setSelection(R.near(r.doc.resolve(e)))}return!0},addColumnBefore:()=>({state:e,dispatch:t})=>lb(e,t),addColumnAfter:()=>({state:e,dispatch:t})=>ub(e,t),deleteColumn:()=>({state:e,dispatch:t})=>{let n=td(e.selection.$from,e=>e.type.name===`table`);return fb(e,t&&(e=>{n&&Lx(e,n.pos),t(e)}))},addRowBefore:()=>({state:e,dispatch:t})=>hb(e,t),addRowAfter:()=>({state:e,dispatch:t})=>gb(e,t),deleteRow:()=>({state:e,dispatch:t})=>{let n=td(e.selection.$from,e=>e.type.name===`table`);return vb(e,t&&(e=>{n&&Lx(e,n.pos),t(e)}))},deleteTable:()=>({state:e,dispatch:t})=>jb(e,t),mergeCells:()=>({state:e,dispatch:t})=>xb(e,t),splitCell:()=>({state:e,dispatch:t})=>Sb(e,t),toggleHeaderColumn:()=>({state:e,dispatch:t})=>Db(`column`)(e,t),toggleHeaderRow:()=>({state:e,dispatch:t})=>Db(`row`)(e,t),toggleHeaderCell:()=>({state:e,dispatch:t})=>Ob(e,t),mergeOrSplit:()=>({state:e,dispatch:t})=>xb(e,t)?!0:Sb(e,t),setCellAttribute:(e,t)=>({state:n,dispatch:r})=>wb(e,t)(n,r),goToNextCell:()=>({state:e,dispatch:t})=>Ab(1)(e,t),goToPreviousCell:()=>({state:e,dispatch:t})=>Ab(-1)(e,t),fixTables:()=>({state:e,dispatch:t})=>(t&&ab(e),!0),setCellSelection:e=>({tr:t,dispatch:n})=>{if(n){let n=$.create(t.doc,e.anchorCell,e.headCell);t.setSelection(n)}return!0}}},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.goToNextCell()?!0:this.editor.can().addRowAfter()?this.editor.chain().addRowAfter().goToNextCell().run():!1,"Shift-Tab":()=>this.editor.commands.goToPreviousCell(),Backspace:Ix,"Mod-Backspace":Ix,Delete:Ix,"Mod-Delete":Ix}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[ex({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:null,lastColumnResizable:this.options.lastColumnResizable})]:[],mx({allowTableNodeSelection:this.options.allowTableNodeSelection}),qx()]},addNodeView(){let e=this.options.View;return e?({node:t,view:n,HTMLAttributes:r})=>{let i=K(this.options.HTMLAttributes,r);return new e(t,this.options.cellMinWidth,n,i)}:null},extendNodeSchema(e){return{tableRole:G(W(e,`tableRole`,{name:e.name,options:e.options,storage:e.storage}))}}});q.create({name:`tableKit`,addExtensions(){let e=[];return this.options.table!==!1&&e.push(Jx.configure(this.options.table)),this.options.tableCell!==!1&&e.push(Tx.configure(this.options.tableCell)),this.options.tableHeader!==!1&&e.push(Ex.configure(this.options.tableHeader)),this.options.tableRow!==!1&&e.push(Dx.configure(this.options.tableRow)),e}});var Yx=20,Xx=(e,t=0)=>{let n=[];return!e.children.length||t>Yx||Array.from(e.children).forEach(e=>{e.tagName===`SPAN`?n.push(e):e.children.length&&n.push(...Xx(e,t+1))}),n},Zx=e=>{if(!e.children.length)return;let t=Xx(e);t&&t.forEach(e=>{var t;let n=e.getAttribute(`style`),r=(t=e.parentElement)==null||(t=t.closest(`span`))==null?void 0:t.getAttribute(`style`);e.setAttribute(`style`,`${r};${n}`)})},Qx=Np.create({name:`textStyle`,priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!0}},parseHTML(){return[{tag:`span`,consuming:!1,getAttrs:e=>e.hasAttribute(`style`)?(this.options.mergeNestedSpanStyles&&Zx(e),{}):!1}]},renderHTML({HTMLAttributes:e}){return[`span`,K(this.options.HTMLAttributes,e),0]},addCommands(){return{toggleTextStyle:e=>({commands:t})=>t.toggleMark(this.name,e),removeEmptyTextStyle:()=>({tr:e})=>{let{selection:t}=e;return e.doc.nodesBetween(t.from,t.to,(t,n)=>{if(!t.isInline)return!0;t.marks.filter(e=>e.type===this.type).some(e=>Object.values(e.attrs).some(e=>!!e))||e.removeMark(n,n+t.nodeSize,this.type)}),!0}}}}),$x=q.create({name:`backgroundColor`,addOptions(){return{types:[`textStyle`]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{backgroundColor:{default:null,parseHTML:e=>(dp(e,`background-color`)??e.style.backgroundColor)?.replace(/['"]+/g,``),renderHTML:e=>hp(e.backgroundColor)?{style:`background-color: ${e.backgroundColor}`}:{}}}}]},addCommands(){return{setBackgroundColor:e=>({chain:t})=>t().setMark(`textStyle`,{backgroundColor:e}).run(),unsetBackgroundColor:()=>({chain:e})=>e().setMark(`textStyle`,{backgroundColor:null}).removeEmptyTextStyle().run()}}}),eS=q.create({name:`color`,addOptions(){return{types:[`textStyle`]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{color:{default:null,parseHTML:e=>(dp(e,`color`)??e.style.color)?.replace(/['"]+/g,``),renderHTML:e=>hp(e.color)?{style:`color: ${e.color}`}:{}}}}]},addCommands(){return{setColor:e=>({chain:t})=>t().setMark(`textStyle`,{color:e}).run(),unsetColor:()=>({chain:e})=>e().setMark(`textStyle`,{color:null}).removeEmptyTextStyle().run()}}}),tS=q.create({name:`fontFamily`,addOptions(){return{types:[`textStyle`]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontFamily:{default:null,parseHTML:e=>dp(e,`font-family`)??e.style.fontFamily,renderHTML:e=>hp(e.fontFamily)?{style:`font-family: ${e.fontFamily}`}:{}}}}]},addCommands(){return{setFontFamily:e=>({chain:t})=>t().setMark(`textStyle`,{fontFamily:e}).run(),unsetFontFamily:()=>({chain:e})=>e().setMark(`textStyle`,{fontFamily:null}).removeEmptyTextStyle().run()}}}),nS=q.create({name:`fontSize`,addOptions(){return{types:[`textStyle`]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontSize:{default:null,parseHTML:e=>dp(e,`font-size`)??e.style.fontSize,renderHTML:e=>hp(e.fontSize)?{style:`font-size: ${e.fontSize}`}:{}}}}]},addCommands(){return{setFontSize:e=>({chain:t})=>t().setMark(`textStyle`,{fontSize:e}).run(),unsetFontSize:()=>({chain:e})=>e().setMark(`textStyle`,{fontSize:null}).removeEmptyTextStyle().run()}}}),rS=q.create({name:`lineHeight`,addOptions(){return{types:[`textStyle`]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{lineHeight:{default:null,parseHTML:e=>dp(e,`line-height`)??e.style.lineHeight,renderHTML:e=>hp(e.lineHeight)?{style:`line-height: ${e.lineHeight}`}:{}}}}]},addCommands(){return{setLineHeight:e=>({chain:t})=>t().setMark(`textStyle`,{lineHeight:e}).run(),unsetLineHeight:()=>({chain:e})=>e().setMark(`textStyle`,{lineHeight:null}).removeEmptyTextStyle().run()}}}),iS=q.create({name:`textStyleKit`,addExtensions(){let e=[];return this.options.backgroundColor!==!1&&e.push($x.configure(this.options.backgroundColor)),this.options.color!==!1&&e.push(eS.configure(this.options.color)),this.options.fontFamily!==!1&&e.push(tS.configure(this.options.fontFamily)),this.options.fontSize!==!1&&e.push(nS.configure(this.options.fontSize)),this.options.lineHeight!==!1&&e.push(rS.configure(this.options.lineHeight)),this.options.textStyle!==!1&&e.push(Qx.configure(this.options.textStyle)),e}}),aS=q.create({name:`textAlign`,addOptions(){return{types:[],alignments:[`left`,`center`,`right`,`justify`],defaultAlignment:null}},addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:e=>{let t=e.style.textAlign;return this.options.alignments.includes(t)?t:this.options.defaultAlignment},renderHTML:e=>!hp(e.textAlign)||!this.options.alignments.includes(e.textAlign)?{}:{style:`text-align: ${e.textAlign}`}}}}]},addCommands(){return{setTextAlign:e=>({commands:t})=>this.options.alignments.includes(e)?this.options.types.map(n=>t.updateAttributes(n,{textAlign:e})).some(e=>e):!1,unsetTextAlign:()=>({commands:e})=>this.options.types.map(t=>e.resetAttributes(t,`textAlign`)).some(e=>e),toggleTextAlign:e=>({editor:t,commands:n})=>this.options.alignments.includes(e)?t.isActive({textAlign:e})?n.unsetTextAlign():n.setTextAlign(e):!1}},addKeyboardShortcuts(){return{"Mod-Shift-l":()=>this.editor.commands.setTextAlign(`left`),"Mod-Shift-e":()=>this.editor.commands.setTextAlign(`center`),"Mod-Shift-r":()=>this.editor.commands.setTextAlign(`right`),"Mod-Shift-j":()=>this.editor.commands.setTextAlign(`justify`)}}});function oS(e){return{default:null,parseHTML:t=>t.getAttribute(e),renderHTML:t=>t[e]?{[e]:t[e]}:{}}}function sS(e,t){return e.extend({addAttributes(){let e={...this.parent?.()??{}};return t.forEach(t=>{e[t]=oS(t)}),e}})}var cS=[`style`,`class`,`align`,`valign`,`bgcolor`,`width`],lS=[`style`,`class`,`border`,`cellpadding`,`cellspacing`,`width`,`align`],uS=[`style`,`class`],dS=[{value:`left`,name:`alignLeft`,title:`fields.editor.align_left`},{value:`center`,name:`alignCenter`,title:`fields.editor.align_center`},{value:`right`,name:`alignRight`,title:`fields.editor.align_right`},{value:`justify`,name:`alignJustify`,title:`fields.editor.align_justify`}],fS=aS.extend({addGlobalAttributes(){let{types:e,alignments:t}=this.options;return[{types:e,attributes:{textAlign:{default:null,parseHTML:e=>{let n=e.style.textAlign||e.getAttribute(`align`)||``;return t.includes(n)?n:null},renderHTML:e=>e.textAlign?{style:`text-align: ${e.textAlign}`}:{}}}}]}}).configure({types:[`paragraph`,`heading`,`blockquote`],alignments:dS.map(e=>e.value)});function pS({placeholder:e=N(`fields.editor.placeholder`),extra:t=[]}={}){return[Oy.configure({link:!1,underline:!1}),Dy,ov.configure({openOnClick:!1}),Ay.configure({inline:!0}),iS,fS,sS(Jx,lS),sS(Dx,uS),sS(Ex,cS),sS(Tx,cS),jy.configure({placeholder:e}),...t]}function mS(e,t){let n=()=>!!e.value?.isActive(`table`),r=()=>e.value?.chain().focus();return[{name:`table`,title:N(`fields.editor.table_insert`),icon:t.table,action:()=>r()?.insertTable({rows:3,cols:3,withHeaderRow:!0}).run()},{name:`addRowAfter`,title:N(`fields.editor.table_add_row`),icon:t.rowPlus,action:()=>r()?.addRowAfter().run(),visible:n},{name:`deleteRow`,title:N(`fields.editor.table_delete_row`),icon:t.rowMinus,action:()=>r()?.deleteRow().run(),visible:n},{name:`addColumnAfter`,title:N(`fields.editor.table_add_column`),icon:t.columnPlus,action:()=>r()?.addColumnAfter().run(),visible:n},{name:`deleteColumn`,title:N(`fields.editor.table_delete_column`),icon:t.columnMinus,action:()=>r()?.deleteColumn().run(),visible:n},{name:`mergeOrSplit`,title:N(`fields.editor.table_merge_split`),icon:t.mergeCells,action:()=>r()?.mergeOrSplit().run(),visible:n},{name:`deleteTable`,title:N(`fields.editor.table_delete`),icon:t.tableMinus,action:()=>r()?.deleteTable().run(),visible:n}]}function hS(e,t){let n=()=>dS.find(({value:t})=>e.value?.isActive({textAlign:t}))?.value??`left`;return dS.map(({value:r,name:i,title:a})=>({name:i,title:N(a),icon:t[i],action:()=>e.value?.chain().focus().setTextAlign(r).run(),isActive:()=>n()===r}))}function gS(e){let t=e?.view,n=typeof window>`u`?null:window.getSelection();if(!t||!n||n.rangeCount===0)return null;let{anchorNode:r,anchorOffset:i,focusNode:a,focusOffset:o}=n;if(!r||!t.dom.contains(r))return null;try{let e=t.posAtDOM(r,i),n=a&&t.dom.contains(a)?t.posAtDOM(a,o):e;return{from:Math.min(e,n),to:Math.max(e,n)}}catch{return null}}function _S(e,t,n=null){if(!e)return;let r=e.state.doc.content.size,i=e.chain().focus().setTextSelection(n??{from:r,to:r});if(t.is_image)i.setImage({src:t.url});else{let e=t.filename||t.url;i.insertContent(`${e}`)}i.run()}var vS={class:`relative bg-surface rounded-xl shadow-2xl w-full max-w-4xl max-h-[90vh] flex flex-col mx-4`},yS={class:`flex items-center justify-between px-6 py-4 border-b border-line`},bS={class:`text-lg font-semibold text-fg`},xS={class:`flex items-center gap-3 px-6 py-3 border-b border-line bg-surface-alt`},SS={class:`flex items-center gap-1 ml-2`},CS=[`onClick`],wS={value:0},TS=[`value`],ES={class:`ml-auto relative`},DS=[`placeholder`],OS={key:0,class:`px-6 py-2 bg-accent-soft border-b border-accent-soft`},kS={class:`flex items-center gap-3`},AS={class:`text-sm text-accent-soft-fg`},jS={key:1,class:`px-6 py-2 bg-danger-soft border-b border-danger-soft`},MS={class:`flex items-center justify-between`},NS={class:`text-sm text-danger-soft-fg`},PS={class:`flex-1 overflow-y-auto p-6`},FS={key:0,class:`flex items-center justify-center py-16`},IS={key:1,class:`flex flex-col items-center justify-center py-16 text-muted`},LS={class:`text-sm`},RS={key:2,class:`grid grid-cols-4 sm:grid-cols-6 gap-3`},zS=[`onClick`,`onDblclick`],BS={class:`w-full aspect-square rounded-md overflow-hidden bg-off flex items-center justify-center mb-2`},VS=[`src`,`alt`],HS={key:1,class:`flex flex-col items-center justify-center text-muted`},US={key:0,class:`w-10 h-10 text-accent`,fill:`currentColor`,viewBox:`0 0 24 24`},WS={key:1,class:`w-10 h-10 text-danger`,fill:`currentColor`,viewBox:`0 0 24 24`},GS={key:2,class:`w-10 h-10 text-success`,fill:`currentColor`,viewBox:`0 0 24 24`},KS={key:3,class:`w-10 h-10`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`},qS={class:`text-xs mt-1 font-medium uppercase`},JS=[`title`],YS=[`onClick`,`title`],XS={key:3,class:`flex justify-center mt-6`},ZS=[`disabled`],QS={class:`flex items-center justify-between px-6 py-4 border-t border-line bg-surface-alt rounded-b-xl`},$S={key:0,class:`flex items-center gap-3 text-sm text-muted min-w-0 flex-1 mr-4`},eC={class:`truncate`},tC={class:`text-muted flex-shrink-0`},nC={key:1,class:`text-sm text-muted`},rC={class:`flex items-center gap-2 flex-shrink-0`},iC=[`disabled`],aC=`image/jpeg,image/png,image/gif,image/webp,application/pdf,.doc,.docx,.xls,.xlsx`,oC={__name:`FileManager`,props:{show:{type:Boolean,default:!1},type:{type:String,default:`all`},uploadUrl:{type:String,default:`/admin/upload`},listUrl:{type:String,default:`/admin/filemanager`},deleteUrl:{type:String,default:`/admin/filemanager`}},emits:[`select`,`close`],setup(t,{emit:n}){let i=t,a=n,u=C(null),d=C([]),f=C(null),p=C(!1),m=C(!1),g=C(``),b=C(i.type),x=C([]),S=C(0),w=C(``),E=C(1),ee=C(1),te=C(!1),ne=null,re=[{value:`all`,label:`files.filters.all`},{value:`image`,label:`files.filters.images`},{value:`document`,label:`files.filters.documents`}];async function ie(e=!1){p.value=!0;try{let t=new URLSearchParams({type:b.value,search:w.value,collection:String(S.value||``),page:String(E.value)}),n=await fetch(`${i.listUrl}?${t}`,{headers:{Accept:`application/json`}});if(!n.ok)throw Error(`Failed to load files`);let r=await n.json();e?d.value=[...d.value,...r.files]:d.value=r.files,x.value=r.collections||[],ee.value=r.last_page,te.value=E.value{E.value=1,ie()},300)}c([b,S],()=>{E.value=1,f.value=null,ie()}),c(()=>i.show,e=>{e&&(b.value=i.type,S.value=0,E.value=1,f.value=null,w.value=``,g.value=``,ie())});function ce(){u.value?.click()}async function ue(e){let t=Array.from(e.target.files);if(t.length){m.value=!0,g.value=``;for(let e of t)await M(e);m.value=!1,e.target.value=``,E.value=1,await ie()}}async function M(e){let t=new FormData;t.append(`file`,e);try{let n=await fetch(i.uploadUrl,{method:`POST`,body:t,headers:pe()});if(!n.ok)throw Error(await me(n,N(`files.errors.upload_failed`,{name:e.name})));let r=await n.json();f.value=r}catch(t){g.value=t.message||N(`files.errors.upload_failed`,{name:e.name})}}async function fe(e){if(confirm(N(`files.remove_confirm`,{name:e.filename})))try{let t=await fetch(i.deleteUrl,{method:`DELETE`,headers:pe({"Content-Type":`application/json`}),body:JSON.stringify({id:e.id,path:e.path})});if(!t.ok)throw Error(await me(t,N(`files.errors.remove_failed`,{name:e.filename})));d.value=d.value.filter(t=>t.id!==e.id),f.value?.id===e.id&&(f.value=null)}catch(e){g.value=e.message||N(`files.errors.delete_failed`)}}function he(e){f.value=e}function ge(e){a(`select`,e),ve()}function _e(){f.value&&(a(`select`,f.value),ve())}function ve(){a(`close`)}function ye(e){return[`doc`,`docx`].includes(e.extension)}function be(e){return e.extension===`pdf`}function xe(e){return[`xls`,`xlsx`].includes(e.extension)}function Se(e){if(!e)return``;let t=[`B`,`KB`,`MB`,`GB`],n=0,r=e;for(;r>=1024&&n{document.addEventListener(`keydown`,Ce)}),o(()=>{document.removeEventListener(`keydown`,Ce),clearTimeout(ne)}),(n,i)=>(l(),v(de,{to:`body`},[t.show?(l(),A(`div`,{key:0,class:`fixed inset-0 z-50 flex items-center justify-center`,onKeydown:D(ve,[`escape`])},[j(`div`,{class:`fixed inset-0 bg-black/50`,onClick:ve}),j(`div`,vS,[j(`div`,yS,[j(`h2`,bS,O(n.$t(`files.title`)),1),j(`button`,{type:`button`,onClick:ve,class:`p-1 text-muted hover:text-fg rounded`},[...i[3]||=[j(`svg`,{class:`w-5 h-5`,viewBox:`0 0 20 20`,fill:`currentColor`},[j(`path`,{"fill-rule":`evenodd`,d:`M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z`,"clip-rule":`evenodd`})],-1)]])]),j(`div`,xS,[j(`button`,{type:`button`,onClick:ce,class:`inline-flex items-center gap-2 px-4 py-2 bg-accent text-on-accent text-sm font-medium rounded-lg hover:bg-accent-hover transition-colors`},[i[4]||=j(`svg`,{class:`w-4 h-4`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`},[j(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M7 16a4 4 0 01-.88-7.903A5 5 0 1115.9 6L16 6a5 5 0 011 9.9M15 13l-3-3m0 0l-3 3m3-3v12`})],-1),y(` `+O(n.$t(`common.upload`)),1)]),j(`input`,{ref_key:`fileInput`,ref:u,type:`file`,accept:aC,multiple:``,class:`hidden`,"data-role":`library-upload`,onChange:ue},null,544),j(`div`,SS,[(l(),A(k,null,_(re,t=>j(`button`,{key:t.value,type:`button`,onClick:e=>b.value=t.value,class:e([`px-3 py-1.5 text-sm rounded-md transition-colors`,b.value===t.value?`bg-accent-soft text-accent-soft-fg font-medium`:`text-muted hover:bg-hover`])},O(n.$t(t.label)),11,CS)),64))]),x.value.length?s((l(),A(`select`,{key:0,"onUpdate:modelValue":i[0]||=e=>S.value=e,class:`px-3 py-1.5 text-sm border border-field rounded-md focus:ring-focus focus:border-focus max-w-56`},[j(`option`,wS,O(n.$t(`files.all_collections`)),1),(l(!0),A(k,null,_(x.value,e=>(l(),A(`option`,{key:e.id,value:e.id},O(e.name)+` (`+O(e.count)+`) `,9,TS))),128))],512)),[[le,S.value]]):r(``,!0),j(`div`,ES,[s(j(`input`,{"onUpdate:modelValue":i[1]||=e=>w.value=e,type:`text`,placeholder:n.$t(`files.search_placeholder`),class:`w-56 pl-8 pr-3 py-1.5 text-sm border border-field rounded-md focus:ring-focus focus:border-focus`,onInput:oe},null,40,DS),[[se,w.value]]),i[5]||=j(`svg`,{class:`absolute left-2.5 top-2 w-4 h-4 text-muted`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`},[j(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z`})],-1)])]),m.value?(l(),A(`div`,OS,[j(`div`,kS,[i[6]||=j(`svg`,{class:`animate-spin h-4 w-4 text-accent`,xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`},[j(`circle`,{class:`opacity-25`,cx:`12`,cy:`12`,r:`10`,stroke:`currentColor`,"stroke-width":`4`}),j(`path`,{class:`opacity-75`,fill:`currentColor`,d:`M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z`})],-1),j(`span`,AS,O(n.$t(`files.uploading`)),1)])])):r(``,!0),g.value?(l(),A(`div`,jS,[j(`div`,MS,[j(`span`,NS,O(g.value),1),j(`button`,{type:`button`,onClick:i[2]||=e=>g.value=``,class:`text-danger hover:text-danger`},[...i[7]||=[j(`svg`,{class:`w-4 h-4`,viewBox:`0 0 20 20`,fill:`currentColor`},[j(`path`,{"fill-rule":`evenodd`,d:`M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z`,"clip-rule":`evenodd`})],-1)]])])])):r(``,!0),j(`div`,PS,[p.value&&!d.value.length?(l(),A(`div`,FS,[...i[8]||=[j(`svg`,{class:`animate-spin h-8 w-8 text-accent`,xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`},[j(`circle`,{class:`opacity-25`,cx:`12`,cy:`12`,r:`10`,stroke:`currentColor`,"stroke-width":`4`}),j(`path`,{class:`opacity-75`,fill:`currentColor`,d:`M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z`})],-1)]])):d.value.length?(l(),A(`div`,RS,[(l(!0),A(k,null,_(d.value,t=>(l(),A(`div`,{key:t.id,onClick:e=>he(t),onDblclick:e=>ge(t),class:e([`group relative flex flex-col items-center p-2 rounded-lg border-2 cursor-pointer transition-all`,f.value?.id===t.id?`border-focus bg-accent-soft`:`border-transparent hover:border-field hover:bg-hover`])},[j(`div`,BS,[t.is_image?(l(),A(`img`,{key:0,src:t.url,alt:t.filename,class:`w-full h-full object-cover`,loading:`lazy`},null,8,VS)):(l(),A(`div`,HS,[ye(t)?(l(),A(`svg`,US,[...i[10]||=[j(`path`,{d:`M14 2H6a2 2 0 00-2 2v16a2 2 0 002 2h12a2 2 0 002-2V8l-6-6zM6 20V4h7v5h5v11H6z`},null,-1),j(`path`,{d:`M8 12h8v2H8zm0 4h8v2H8zm0-8h3v2H8z`},null,-1)]])):be(t)?(l(),A(`svg`,WS,[...i[11]||=[j(`path`,{d:`M14 2H6a2 2 0 00-2 2v16a2 2 0 002 2h12a2 2 0 002-2V8l-6-6zM6 20V4h7v5h5v11H6z`},null,-1),j(`path`,{d:`M10.5 11c-.3 0-.5.2-.5.5v5c0 .3.2.5.5.5s.5-.2.5-.5V15h1.5c1.1 0 2-.9 2-2s-.9-2-2-2h-2zm2 3h-1.5v-2h1.5c.6 0 1 .4 1 1s-.4 1-1 1z`},null,-1)]])):xe(t)?(l(),A(`svg`,GS,[...i[12]||=[j(`path`,{d:`M14 2H6a2 2 0 00-2 2v16a2 2 0 002 2h12a2 2 0 002-2V8l-6-6zM6 20V4h7v5h5v11H6z`},null,-1),j(`path`,{d:`M8 12l2.5 3L8 18h1.5l1.75-2.25L13 18h1.5l-2.5-3 2.5-3H13l-1.75 2.25L9.5 12H8z`},null,-1)]])):(l(),A(`svg`,KS,[...i[13]||=[j(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`1.5`,d:`M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z`},null,-1)]])),j(`span`,qS,O(t.extension),1)]))]),j(`p`,{class:`text-xs text-muted text-center truncate w-full`,title:t.filename},O(t.filename),9,JS),j(`button`,{type:`button`,onClick:T(e=>fe(t),[`stop`]),class:`absolute top-1 right-1 p-1 bg-danger text-on-danger rounded-full opacity-0 group-hover:opacity-100 transition-opacity hover:bg-danger-hover`,title:n.$t(`common.delete`)},[...i[14]||=[j(`svg`,{class:`w-3 h-3`,viewBox:`0 0 20 20`,fill:`currentColor`},[j(`path`,{"fill-rule":`evenodd`,d:`M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z`,"clip-rule":`evenodd`})],-1)]],8,YS)],42,zS))),128))])):(l(),A(`div`,IS,[i[9]||=j(`svg`,{class:`w-16 h-16 mb-4`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`},[j(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`1`,d:`M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z`})],-1),j(`p`,LS,O(n.$t(`files.empty`)),1)])),te.value?(l(),A(`div`,XS,[j(`button`,{type:`button`,onClick:ae,class:`px-4 py-2 text-sm text-accent border border-accent rounded-lg hover:bg-accent-soft transition-colors`,disabled:p.value},O(p.value?n.$t(`common.loading`):n.$t(`files.load_more`)),9,ZS)])):r(``,!0)]),j(`div`,QS,[f.value?(l(),A(`div`,$S,[j(`span`,eC,O(f.value.filename),1),j(`span`,tC,O(Se(f.value.size)),1)])):(l(),A(`div`,nC,O(n.$t(`files.select_hint`)),1)),j(`div`,rC,[j(`button`,{type:`button`,onClick:ve,class:`px-4 py-2 text-sm text-fg border border-field rounded-lg hover:bg-hover transition-colors`},O(n.$t(`common.cancel`)),1),j(`button`,{type:`button`,"data-action":`library-insert`,onClick:_e,disabled:!f.value,class:`px-4 py-2 text-sm text-on-accent bg-accent rounded-lg hover:bg-accent-hover disabled:opacity-50 disabled:cursor-not-allowed transition-colors`},O(n.$t(`files.insert`)),9,iC)])])])],32)):r(``,!0)]))}},sC={class:`wysiwyg-field`},cC={key:0,class:`block text-sm font-medium text-fg mb-1`},lC={key:0,class:`text-danger`},uC=[`onClick`,`title`],dC={key:0,class:`flex justify-end p-2 bg-surface-alt border-t border-field text-sm text-muted`},fC={key:1,class:`mt-1 text-sm text-muted`},pC={key:2,class:`mt-1 text-sm text-danger`},mC={__name:`WysiwygField`,props:{modelValue:String,label:String,required:Boolean,toolbar:{type:Array,default:()=>[`bold`,`italic`,`underline`,`link`,`bulletList`,`orderedList`,`heading`]},minHeight:{type:Number,default:200},maxHeight:Number,maxLength:Number,allowImages:{type:Boolean,default:!0},placeholder:String,hint:String,error:String},emits:[`update:modelValue`],setup(t,{emit:n}){let i=t,s=n,u=C(!1),d=C(!1),f=C(`all`),p=C(null);function m(){p.value=gS(S.value)}function h(e=`all`){f.value=e,d.value=!0}function b(e){_S(S.value,e,p.value)}let S=hm({content:i.modelValue,extensions:pS({placeholder:i.placeholder||N(`fields.editor.placeholder`),extra:[rh.configure({limit:i.maxLength})]}),onUpdate:({editor:e})=>{s(`update:modelValue`,e.getHTML())},onFocus:()=>{u.value=!0},onBlur:()=>{u.value=!1}}),w=E(()=>S.value?.storage.characterCount.characters()||0),T=E(()=>{let e=[];return i.toolbar.includes(`bold`)&&e.push({name:`bold`,title:N(`fields.editor.bold`),icon:`IconBold`,action:()=>S.value?.chain().focus().toggleBold().run(),isActive:()=>S.value?.isActive(`bold`)}),i.toolbar.includes(`italic`)&&e.push({name:`italic`,title:N(`fields.editor.italic`),icon:`IconItalic`,action:()=>S.value?.chain().focus().toggleItalic().run(),isActive:()=>S.value?.isActive(`italic`)}),i.toolbar.includes(`underline`)&&e.push({name:`underline`,title:N(`fields.editor.underline`),icon:`IconUnderline`,action:()=>S.value?.chain().focus().toggleUnderline().run(),isActive:()=>S.value?.isActive(`underline`)}),i.toolbar.includes(`link`)&&e.push({name:`link`,title:N(`fields.editor.link`),icon:`IconLink`,action:()=>{let e=prompt(N(`fields.editor.link_prompt`));e&&S.value?.chain().focus().setLink({href:e}).run()},isActive:()=>S.value?.isActive(`link`)}),i.toolbar.includes(`bulletList`)&&e.push({name:`bulletList`,title:N(`fields.editor.bullet_list`),icon:`IconList`,action:()=>S.value?.chain().focus().toggleBulletList().run(),isActive:()=>S.value?.isActive(`bulletList`)}),i.toolbar.includes(`orderedList`)&&e.push({name:`orderedList`,title:N(`fields.editor.ordered_list`),icon:`IconListOrdered`,action:()=>S.value?.chain().focus().toggleOrderedList().run(),isActive:()=>S.value?.isActive(`orderedList`)}),i.toolbar.includes(`heading`)&&e.push({name:`heading`,title:N(`fields.editor.heading`),icon:`IconHeading`,action:()=>S.value?.chain().focus().toggleHeading({level:2}).run(),isActive:()=>S.value?.isActive(`heading`)}),i.toolbar.includes(`image`)&&i.allowImages&&e.push({name:`image`,title:N(`fields.editor.image`),icon:`IconImage`,action:()=>h(`image`)}),i.toolbar.includes(`file`)&&e.push({name:`file`,title:N(`fields.editor.file`),icon:`IconFile`,action:()=>h(`all`)}),e});return c(()=>i.modelValue,e=>{S.value&&e!==S.value.getHTML()&&S.value.commands.setContent(e,{emitUpdate:!1})}),o(()=>{S.value?.destroy()}),(n,i)=>(l(),A(`div`,sC,[t.label?(l(),A(`label`,cC,[y(O(t.label)+` `,1),t.required?(l(),A(`span`,lC,`*`)):r(``,!0)])):r(``,!0),j(`div`,{class:e([`border border-field rounded-lg overflow-hidden`,{"border-danger":t.error,"ring-2 ring-focus":u.value}])},[j(`div`,{class:`flex flex-wrap gap-1 p-2 bg-surface-alt border-b border-field`,onMousedown:m},[(l(!0),A(k,null,_(T.value,t=>(l(),A(`button`,{key:t.name,type:`button`,onClick:t.action,class:e([`p-2 rounded hover:bg-hover`,{"bg-accent-soft text-accent-soft-fg":t.isActive?.()}]),title:t.title},[(l(),v(x(t.icon),{class:`h-4 w-4`}))],10,uC))),128))],32),a(g(mm),{editor:g(S),class:`max-w-none p-4`,style:ne({minHeight:t.minHeight+`px`,maxHeight:t.maxHeight?t.maxHeight+`px`:`auto`})},null,8,[`editor`,`style`]),t.maxLength?(l(),A(`div`,dC,O(w.value)+` / `+O(t.maxLength),1)):r(``,!0)],2),t.hint&&!t.error?(l(),A(`p`,fC,O(t.hint),1)):r(``,!0),t.error?(l(),A(`p`,pC,O(t.error),1)):r(``,!0),a(oC,{show:d.value,type:f.value,onSelect:b,onClose:i[0]||=e=>d.value=!1},null,8,[`show`,`type`])]))}},hC={class:`color-field`},gC={key:0,class:`block text-sm font-medium text-fg mb-1`},_C={key:0,class:`text-danger`},vC={class:`flex items-center gap-3`},yC=[`value`],bC=[`value`],xC={key:1,class:`flex flex-wrap gap-2 mt-3`},SC=[`onClick`],CC={key:2,class:`mt-1 text-sm text-muted`},wC={key:3,class:`mt-1 text-sm text-danger`},TC={__name:`ColorField`,props:{modelValue:String,label:String,required:Boolean,presetColors:{type:Array,default:()=>[]},allowCustom:{type:Boolean,default:!0},hint:String,error:String},emits:[`update:modelValue`],setup(t,{emit:n}){let i=C(null);function a(){i.value?.click()}return(n,o)=>(l(),A(`div`,hC,[t.label?(l(),A(`label`,gC,[y(O(t.label)+` `,1),t.required?(l(),A(`span`,_C,`*`)):r(``,!0)])):r(``,!0),j(`div`,vC,[j(`div`,{class:`w-10 h-10 rounded-lg border border-field cursor-pointer`,style:ne({backgroundColor:t.modelValue||`#ffffff`}),onClick:a},null,4),t.allowCustom?(l(),A(`input`,{key:0,type:`text`,value:t.modelValue,onInput:o[0]||=e=>n.$emit(`update:modelValue`,e.target.value),class:e([`flex-1 border border-field rounded-md px-3 py-2 text-sm focus:outline-none focus:ring-1 focus:ring-focus focus:border-focus`,{"border-danger":t.error}]),placeholder:`#000000`},null,42,yC)):r(``,!0),j(`input`,{ref_key:`colorPicker`,ref:i,type:`color`,value:t.modelValue,onInput:o[1]||=e=>n.$emit(`update:modelValue`,e.target.value),class:`sr-only`},null,40,bC)]),t.presetColors.length?(l(),A(`div`,xC,[(l(!0),A(k,null,_(t.presetColors,r=>(l(),A(`button`,{key:r,type:`button`,class:e([`w-8 h-8 rounded-lg border-2 transition-all`,t.modelValue===r?`border-focus scale-110`:`border-transparent hover:scale-105`]),style:ne({backgroundColor:r}),onClick:e=>n.$emit(`update:modelValue`,r)},null,14,SC))),128))])):r(``,!0),t.hint&&!t.error?(l(),A(`p`,CC,O(t.hint),1)):r(``,!0),t.error?(l(),A(`p`,wC,O(t.error),1)):r(``,!0)]))}},EC={class:`slug-field`},DC={key:0,class:`block text-sm font-medium text-fg mb-1`},OC={key:0,class:`text-danger`},kC={class:`flex gap-2`},AC={class:`relative flex-1`},jC=[`value`,`placeholder`,`disabled`],MC=[`title`],NC={key:1,class:`mt-2 text-sm text-muted`},PC={class:`font-medium`},FC=[`href`],IC={key:2,class:`mt-1 text-sm text-muted`},LC={key:3,class:`mt-1 text-sm text-danger`},RC={__name:`SlugField`,props:{modelValue:String,label:String,required:Boolean,fromField:{type:String,default:`name`},autoGenerate:{type:Boolean,default:!0},showPreview:{type:Boolean,default:!0},baseUrl:String,publicPrefix:String,parentField:String,parentPaths:{type:Object,default:()=>({})},placeholder:String,disabled:Boolean,hint:String,error:String},emits:[`update:modelValue`],setup(n,{emit:i}){let a=n,o=i,s=t(`formData`,{}),u=t(`contentLocale`,C(null)),d=E(()=>{let e=s.value?.[a.fromField];return e&&typeof e==`object`?e[u.value]||``:e||``}),f=C(!a.modelValue),p=E(()=>{if(!a.parentField)return``;let e=s.value?.[a.parentField];return e&&a.parentPaths?.[e]||``}),m=E(()=>`${(a.baseUrl||window.location.origin).replace(/\/+$/,``)}/${[a.publicPrefix,p.value,a.modelValue].filter(Boolean).join(`/`)}`);function h(e){let t=e.target,n=t.selectionStart,r=v(t.value);f.value=r===``,t.value!==r&&(t.value=r,t.setSelectionRange(n,n)),o(`update:modelValue`,r)}function g(e){let t=b(a.modelValue||``);e.target.value!==t&&(e.target.value=t),t!==a.modelValue&&o(`update:modelValue`,t)}function _(){d.value&&(f.value=!0,o(`update:modelValue`,x(d.value)))}function v(e){return S(e).toLowerCase().replace(/[^a-z0-9\-]/g,`-`).replace(/-+/g,`-`)}function b(e){return e.replace(/^-+|-+$/g,``)}function x(e){return b(v(e))}function S(e){let t={а:`a`,б:`b`,в:`v`,г:`g`,д:`d`,е:`e`,ё:`yo`,ж:`zh`,з:`z`,и:`i`,й:`y`,к:`k`,л:`l`,м:`m`,н:`n`,о:`o`,п:`p`,р:`r`,с:`s`,т:`t`,у:`u`,ф:`f`,х:`h`,ц:`ts`,ч:`ch`,ш:`sh`,щ:`sch`,ъ:``,ы:`y`,ь:``,э:`e`,ю:`yu`,я:`ya`,і:`i`,ў:`u`,ґ:`g`,є:`ie`,ї:`i`,"’":``,"'":``};return e.toLowerCase().split(``).map(e=>t[e]??e).join(``).normalize(`NFD`).replace(/[\u0300-\u036f]/g,``)}return c(d,e=>{a.autoGenerate&&f.value&&e&&o(`update:modelValue`,x(e))}),(t,i)=>(l(),A(`div`,EC,[n.label?(l(),A(`label`,DC,[y(O(n.label)+` `,1),n.required?(l(),A(`span`,OC,`*`)):r(``,!0)])):r(``,!0),j(`div`,kC,[j(`div`,AC,[j(`input`,{type:`text`,value:n.modelValue,onInput:h,onBlur:g,class:e([`w-full border border-field rounded-md px-3 py-2 pr-10 text-sm focus:outline-none focus:ring-1 focus:ring-focus focus:border-focus`,{"border-danger":n.error}]),placeholder:n.placeholder||t.$t(`fields.slug.placeholder`),disabled:n.disabled},null,42,jC),n.autoGenerate&&d.value?(l(),A(`button`,{key:0,type:`button`,onClick:_,class:`absolute right-2 top-1/2 -translate-y-1/2 text-muted hover:text-accent`,title:t.$t(`fields.slug.generate`)},[...i[0]||=[j(`svg`,{class:`h-5 w-5`,viewBox:`0 0 20 20`,fill:`currentColor`},[j(`path`,{"fill-rule":`evenodd`,d:`M4 2a1 1 0 011 1v2.101a7.002 7.002 0 0111.601 2.566 1 1 0 11-1.885.666A5.002 5.002 0 005.999 7H9a1 1 0 010 2H4a1 1 0 01-1-1V3a1 1 0 011-1zm.008 9.057a1 1 0 011.276.61A5.002 5.002 0 0014.001 13H11a1 1 0 110-2h5a1 1 0 011 1v5a1 1 0 11-2 0v-2.101a7.002 7.002 0 01-11.601-2.566 1 1 0 01.61-1.276z`,"clip-rule":`evenodd`})],-1)]],8,MC)):r(``,!0)])]),n.showPreview&&n.modelValue?(l(),A(`div`,NC,[j(`span`,PC,O(t.$t(`fields.slug.url_label`)),1),j(`a`,{href:m.value,target:`_blank`,class:`text-accent hover:text-accent-soft-fg break-all`},O(m.value),9,FC)])):r(``,!0),n.hint&&!n.error?(l(),A(`p`,IC,O(n.hint),1)):r(``,!0),n.error?(l(),A(`p`,LC,O(n.error),1)):r(``,!0)]))}},zC={class:`tree-node`},BC=[`data-tree-value`,`data-tree-selected`],VC={key:1,class:`w-6`},HC={key:2,class:`h-5 w-5 text-accent`,viewBox:`0 0 20 20`,fill:`currentColor`},UC={key:0},WC={__name:`TreeNode`,props:{node:{type:Object,required:!0},depth:{type:Number,default:0},selectedValue:[String,Number,Array],expandedNodes:{type:Set,default:()=>new Set}},emits:[`select`,`toggle`],setup(t,{emit:i}){let a=t,o=i,s=E(()=>a.node.children?.length>0),c=E(()=>a.expandedNodes.has(a.node.value)),u=E(()=>Array.isArray(a.selectedValue)?a.selectedValue.includes(a.node.value):a.selectedValue===a.node.value);function d(){o(`select`,a.node.value)}function f(){o(`toggle`,a.node.value)}return(i,a)=>{let o=n(`tree-node`,!0);return l(),A(`div`,zC,[j(`div`,{class:e([`flex items-center px-3 py-2 cursor-pointer hover:bg-hover`,{"bg-accent-soft":u.value,"pl-6":t.depth===1,"pl-9":t.depth===2,"pl-12":t.depth>=3}]),"data-tree-value":t.node.value,"data-tree-selected":u.value?`true`:`false`,onClick:d},[s.value?(l(),A(`button`,{key:0,type:`button`,class:`mr-2 text-muted hover:text-fg focus:outline-none`,onClick:T(f,[`stop`])},[(l(),A(`svg`,{class:e([`h-4 w-4 transform transition-transform`,{"rotate-90":c.value}]),viewBox:`0 0 20 20`,fill:`currentColor`},[...a[2]||=[j(`path`,{"fill-rule":`evenodd`,d:`M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z`,"clip-rule":`evenodd`},null,-1)]],2))])):(l(),A(`span`,VC)),j(`span`,{class:e([`flex-1 truncate`,{"font-medium text-accent":u.value}])},O(t.node.label),3),u.value?(l(),A(`svg`,HC,[...a[3]||=[j(`path`,{"fill-rule":`evenodd`,d:`M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z`,"clip-rule":`evenodd`},null,-1)]])):r(``,!0)],10,BC),s.value&&c.value?(l(),A(`div`,UC,[(l(!0),A(k,null,_(t.node.children,e=>(l(),v(o,{key:e.value,node:e,depth:t.depth+1,"selected-value":t.selectedValue,"expanded-nodes":t.expandedNodes,onSelect:a[0]||=e=>i.$emit(`select`,e),onToggle:a[1]||=e=>i.$emit(`toggle`,e)},null,8,[`node`,`depth`,`selected-value`,`expanded-nodes`]))),128))])):r(``,!0)])}}},GC={class:`tree-select-field`},KC={key:0,class:`block text-sm font-medium text-fg mb-1`},qC={key:0,class:`text-danger`},JC={class:`relative`},YC={key:0,class:`block truncate`},XC={key:1,class:`block truncate text-muted`},ZC={key:0,class:`absolute z-10 mt-1 w-full bg-surface shadow-lg max-h-60 rounded-md py-1 text-base ring-1 ring-line overflow-auto focus:outline-none sm:text-sm`},QC={key:0,class:`px-3 py-2`},$C=[`placeholder`],ew=[`data-tree-selected`],tw={key:0,class:`h-5 w-5 text-accent`,viewBox:`0 0 20 20`,fill:`currentColor`},nw={key:2,class:`px-3 py-2 border-b`},rw={key:1,class:`mt-1 text-sm text-muted`},iw={key:2,class:`mt-1 text-sm text-danger`},aw={__name:`TreeSelectField`,props:{modelValue:[String,Number,Array],options:{type:Array,default:()=>[]},label:String,placeholder:String,required:Boolean,searchable:{type:Boolean,default:!0},clearable:{type:Boolean,default:!0},multiple:Boolean,expandAll:Boolean,rootLabel:String,hint:String,error:String},emits:[`update:modelValue`],setup(t,{emit:n}){let i=t,a=n,c=C(!1),u=C(``),d=C(new Set),f=E(()=>{if(!u.value)return i.options;let e=u.value.toLowerCase();return S(i.options,e)}),p=E(()=>i.modelValue===null||i.modelValue===void 0||i.modelValue===``),m=E(()=>!!i.rootLabel&&!i.multiple&&b(i.rootLabel)),g=E(()=>{if(p.value)return i.rootLabel||``;let e=w(i.options,i.modelValue);return e?e.label:``});function b(e){return!u.value||String(e).toLowerCase().includes(u.value.toLowerCase())}function x(){a(`update:modelValue`,null),c.value=!1}function S(e,t){return e.reduce((e,n)=>{let r=n.label.toLowerCase().includes(t),i=n.children?S(n.children,t):[];return(r||i.length)&&e.push({...n,children:i.length?i:n.children}),e},[])}function w(e,t){for(let n of e){if(n.value===t)return n;if(n.children){let e=w(n.children,t);if(e)return e}}return null}function T(){c.value=!c.value}function ee(e){a(`update:modelValue`,e),i.multiple||(c.value=!1)}function te(e){d.value.has(e)?d.value.delete(e):d.value.add(e)}function ne(){a(`update:modelValue`,null),c.value=!1}function re(e){e.target.closest(`.tree-select-field`)||(c.value=!1)}return h(()=>{if(document.addEventListener(`click`,re),i.expandAll){let e=t=>{t.forEach(t=>{t.children?.length&&(d.value.add(t.value),e(t.children))})};e(i.options)}}),o(()=>{document.removeEventListener(`click`,re)}),(n,i)=>(l(),A(`div`,GC,[t.label?(l(),A(`label`,KC,[y(O(t.label)+` `,1),t.required?(l(),A(`span`,qC,`*`)):r(``,!0)])):r(``,!0),j(`div`,JC,[j(`button`,{type:`button`,onClick:T,class:e([`relative w-full bg-surface border border-field rounded-md shadow-sm pl-3 pr-10 py-2 text-left cursor-pointer focus:outline-none focus:ring-1 focus:ring-focus focus:border-focus`,{"border-danger":t.error}])},[g.value?(l(),A(`span`,YC,O(g.value),1)):(l(),A(`span`,XC,O(t.placeholder||n.$t(`common.select`)),1)),i[1]||=j(`span`,{class:`absolute inset-y-0 right-0 flex items-center pr-2`},[j(`svg`,{class:`h-5 w-5 text-muted`,viewBox:`0 0 20 20`,fill:`currentColor`},[j(`path`,{"fill-rule":`evenodd`,d:`M10 3a1 1 0 01.707.293l3 3a1 1 0 01-1.414 1.414L10 5.414 7.707 7.707a1 1 0 01-1.414-1.414l3-3A1 1 0 0110 3zm-3.707 9.293a1 1 0 011.414 0L10 14.586l2.293-2.293a1 1 0 011.414 1.414l-3 3a1 1 0 01-1.414 0l-3-3a1 1 0 010-1.414z`,"clip-rule":`evenodd`})])],-1)],2),c.value?(l(),A(`div`,ZC,[t.searchable?(l(),A(`div`,QC,[s(j(`input`,{"onUpdate:modelValue":i[0]||=e=>u.value=e,type:`text`,class:`w-full border border-field rounded-md px-3 py-1 text-sm focus:outline-none focus:ring-1 focus:ring-focus`,placeholder:n.$t(`fields.tree.search_placeholder`)},null,8,$C),[[se,u.value]])])):r(``,!0),m.value?(l(),A(`div`,{key:1,class:e([`flex items-center px-3 py-2 cursor-pointer hover:bg-hover border-b`,{"bg-accent-soft":p.value}]),"data-tree-value":``,"data-tree-selected":p.value?`true`:`false`,onClick:x},[i[3]||=j(`span`,{class:`w-6`},null,-1),j(`span`,{class:e([`flex-1 truncate`,{"font-medium text-accent":p.value}])},O(t.rootLabel),3),p.value?(l(),A(`svg`,tw,[...i[2]||=[j(`path`,{"fill-rule":`evenodd`,d:`M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z`,"clip-rule":`evenodd`},null,-1)]])):r(``,!0)],10,ew)):r(``,!0),t.clearable&&!t.rootLabel&&t.modelValue?(l(),A(`div`,nw,[j(`button`,{type:`button`,onClick:ne,class:`text-sm text-muted hover:text-fg`},O(n.$t(`fields.clear`)),1)])):r(``,!0),(l(!0),A(k,null,_(f.value,e=>(l(),v(WC,{key:e.value,node:e,"selected-value":t.modelValue,"expanded-nodes":d.value,onSelect:ee,onToggle:te},null,8,[`node`,`selected-value`,`expanded-nodes`]))),128))])):r(``,!0)]),t.hint&&!t.error?(l(),A(`p`,rw,O(t.hint),1)):r(``,!0),t.error?(l(),A(`p`,iw,O(t.error),1)):r(``,!0)]))}},ow={class:`gallery-field`},sw={key:0,class:`block text-sm font-medium text-fg mb-1`},cw={key:0,class:`text-danger`},lw=[`onDragstart`,`onDrop`],uw=[`src`,`alt`],dw=[`href`,`title`],fw={class:`mt-1 text-xs text-muted break-all line-clamp-2`},pw={class:`absolute inset-0 bg-black/50 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center gap-2`},mw=[`onClick`,`title`],hw={key:2,class:`absolute top-2 left-2 bg-surface/75 rounded px-2 py-1 text-xs font-medium cursor-move`},gw={class:`text-center`},_w={class:`mt-1 block text-sm text-muted`},vw=[`accept`],yw={key:2,class:`mt-2 text-sm text-muted`},bw={key:3,class:`mt-2 text-sm text-danger`},xw={class:`mt-2 text-sm text-muted`},Sw={__name:`GalleryField`,props:{modelValue:{type:Array,default:()=>[]},label:String,required:Boolean,maxFiles:{type:Number,default:20},maxSize:{type:Number,default:5120},accept:{type:String,default:`image/*`},sortable:{type:Boolean,default:!0},hint:String,error:String,uploadUrl:{type:String,default:`/admin/upload`}},emits:[`update:modelValue`],setup(e,{emit:t}){let n=e,i=t,o=C(null),s=C(null),c=E(()=>n.modelValue||[]);function u(e){let t=typeof e==`string`?e:e?.url??e?.path??``;return typeof t!=`string`||t===``?``:/^(https?:)?\/\//i.test(t)||t.startsWith(`/`)?t:`/storage/`+t}function d(e){return e&&typeof e==`object`&&e.filename?e.filename:u(e).split(`/`).filter(Boolean).pop()||``}function f(e){return/\.(jpe?g|png|gif|webp|bmp|svg|avif)(\?|$)/i.test(e.src||``)}let p=E(()=>c.value.map(e=>({src:u(e),filename:d(e)})));function m(e){return typeof e?.url==`string`&&/^https?:\/\//i.test(e.url)?e.url:e&&typeof e.path==`string`&&e.path!==``?`/storage/`+e.path.replace(/^\/+/,``):u(e)}let h=E(()=>c.value.lengthu(e)===t)||i(`update:modelValue`,[...c.value,t]))}function b(){o.value?.click()}async function x(e){let t=Array.from(e.target.files);for(let e of t){if(!h.value)break;e.size>n.maxSize*1024?alert(N(`fields.gallery.file_too_big`,{name:e.name,max:n.maxSize})):await S(e)}e.target.value=``}async function S(e){let t=new FormData;t.append(`file`,e);try{let r=await fetch(n.uploadUrl,{method:`POST`,body:t,headers:pe()});if(!r.ok)throw Error(await me(r,N(`fields.gallery.upload_failed`,{name:e.name})));let a=await r.json();i(`update:modelValue`,[...c.value,m(a)])}catch(e){console.error(`Upload error:`,e),alert(e.message||N(`fields.upload.failed`))}}function w(e){Array.from(e.dataTransfer.files).forEach(e=>{h.value&&e.type.startsWith(`image/`)&&S(e)})}function ee(e){let t=[...c.value];t.splice(e,1),i(`update:modelValue`,t)}function te(e){s.value=e}function ne(e){if(s.value===null||s.value===e)return;let t=[...c.value],[n]=t.splice(s.value,1);t.splice(e,0,n),i(`update:modelValue`,t),s.value=null}return(t,n)=>(l(),A(`div`,ow,[e.label?(l(),A(`label`,sw,[y(O(e.label)+` `,1),e.required?(l(),A(`span`,cw,`*`)):r(``,!0)])):r(``,!0),j(`div`,{class:`grid grid-cols-4 gap-4`,onDragover:n[1]||=T(()=>{},[`prevent`]),onDrop:w},[(l(!0),A(k,null,_(p.value,(i,a)=>(l(),A(`div`,{key:i.src||a,class:`relative group aspect-square bg-off rounded-lg overflow-hidden`,draggable:`true`,onDragstart:e=>te(a),onDragover:n[0]||=T(()=>{},[`prevent`]),onDrop:e=>ne(a)},[f(i)?(l(),A(`img`,{key:0,src:i.src,alt:i.filename,class:`w-full h-full object-cover`},null,8,uw)):(l(),A(`a`,{key:1,href:i.src,target:`_blank`,rel:`noopener`,class:`w-full h-full flex flex-col items-center justify-center p-2 text-center hover:bg-hover`,title:i.filename},[n[4]||=j(`svg`,{class:`h-8 w-8 text-muted`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`},[j(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z`})],-1),j(`span`,fw,O(i.filename),1)],8,dw)),j(`div`,pw,[j(`button`,{type:`button`,onClick:e=>ee(a),title:t.$t(`common.remove`),class:`p-2 bg-danger text-on-danger rounded-full hover:bg-danger-hover`},[...n[5]||=[j(`svg`,{class:`h-4 w-4`,viewBox:`0 0 20 20`,fill:`currentColor`},[j(`path`,{"fill-rule":`evenodd`,d:`M9 2a1 1 0 00-.894.553L7.382 4H4a1 1 0 000 2v10a2 2 0 002 2h8a2 2 0 002-2V6a1 1 0 100-2h-3.382l-.724-1.447A1 1 0 0011 2H9zM7 8a1 1 0 012 0v6a1 1 0 11-2 0V8zm5-1a1 1 0 00-1 1v6a1 1 0 102 0V8a1 1 0 00-1-1z`,"clip-rule":`evenodd`})],-1)]],8,mw)]),e.sortable?(l(),A(`div`,hw,O(a+1),1)):r(``,!0)],40,lw))),128)),h.value?(l(),A(`div`,{key:0,class:`aspect-square border-2 border-dashed border-field rounded-lg flex items-center justify-center hover:border-focus hover:bg-accent-soft cursor-pointer transition-colors`,onClick:b},[j(`div`,gw,[n[6]||=j(`svg`,{class:`mx-auto h-8 w-8 text-muted`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`},[j(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M12 4v16m8-8H4`})],-1),j(`span`,_w,O(t.$t(`common.add`)),1)])])):r(``,!0)],32),j(`input`,{ref_key:`fileInput`,ref:o,type:`file`,accept:e.accept,multiple:``,class:`hidden`,onChange:x},null,40,vw),h.value?(l(),A(`button`,{key:1,type:`button`,onClick:n[2]||=e=>g.value=!0,"data-action":`pick-from-library`,class:`mt-3 px-3 py-2 text-sm font-medium text-fg bg-surface border border-field rounded-md hover:bg-hover`},O(t.$t(`fields.gallery.add_from_library`)),1)):r(``,!0),a(oC,{show:g.value,type:`image`,onSelect:v,onClose:n[3]||=e=>g.value=!1},null,8,[`show`]),e.hint&&!e.error?(l(),A(`p`,yw,O(e.hint),1)):r(``,!0),e.error?(l(),A(`p`,bw,O(e.error),1)):r(``,!0),j(`p`,xw,O(t.$tc(`fields.gallery.counter`,e.maxFiles,{current:c.value.length})),1)]))}},Cw=[`data-content-field`],ww={key:0,class:`block text-sm font-medium text-fg mb-1`},Tw={key:0,class:`text-danger`},Ew={class:`flex items-center gap-4 mb-2`},Dw=[`name`,`value`,`data-content-mode`],Ow={class:`ml-1.5 text-sm text-fg`},kw=[`placeholder`,`required`,`disabled`,`rows`],Aw=[`placeholder`,`required`,`disabled`,`rows`],jw=[`value`,`title`],Mw=[`value`],Nw=[`value`,`title`],Pw=[`value`],Fw=[`title`],Iw=[`value`],Lw=[`data-editor-button`,`onClick`,`title`],Rw=[`innerHTML`],zw={key:4,class:`mt-1 text-sm text-muted`},Bw={key:5,class:`mt-1 text-sm text-danger`},Vw={__name:`ContentField`,props:{modelValue:String,name:String,label:String,required:Boolean,disabled:Boolean,placeholder:String,hint:String,error:String,defaultMode:{type:String,default:`wysiwyg`},modes:{type:Array,default:()=>[`text`,`html`,`wysiwyg`]},rows:{type:Number,default:6},toolbar:{type:Array,default:()=>[`bold`,`italic`,`underline`,`strike`,`color`,`link`,`bulletList`,`orderedList`,`align`,`heading`,`fontSize`,`image`,`file`,`table`]},minHeight:{type:Number,default:200}},emits:[`update:modelValue`],setup(t,{emit:n}){let i=t,u=n,d={text:`fields.content.mode_text`,html:`fields.content.mode_html`,wysiwyg:`fields.content.mode_wysiwyg`},f=E(()=>i.modes.map(e=>({value:e,label:d[e]?N(d[e]):e}))),p=E(()=>`content-field-mode-${i.name}`),m=C(localStorage.getItem(p.value)||i.defaultMode);c(m,e=>{localStorage.setItem(p.value,e)});let h=E({get:()=>i.modelValue||``,set:e=>u(`update:modelValue`,e)}),v=C(!1),b=C(!1),x=C(`all`),S=C(null),w=C(null);function T(){w.value=gS(D.value)}function ee(e=`all`,t=null){x.value=e,S.value=t,b.value=!0}function te(e){S.value?(S.value(e),S.value=null):_S(D.value,e,w.value)}let D=hm({content:i.modelValue||``,extensions:pS({placeholder:i.placeholder||N(`fields.editor.placeholder`)}),onUpdate:({editor:e})=>{m.value===`wysiwyg`&&u(`update:modelValue`,e.getHTML())},onFocus:()=>{v.value=!0},onBlur:()=>{v.value=!1}});c(m,e=>{e===`wysiwyg`&&D.value&&D.value.commands.setContent(i.modelValue||``,{emitUpdate:!1})}),c(()=>i.modelValue,e=>{m.value===`wysiwyg`&&D.value&&e!==D.value.getHTML()&&D.value.commands.setContent(e||``,{emitUpdate:!1})});let ie=[{value:`paragraph`,label:`fields.editor.format_paragraph`},{value:`h1`,label:`fields.editor.format_h1`},{value:`h2`,label:`fields.editor.format_h2`},{value:`h3`,label:`fields.editor.format_h3`},{value:`h4`,label:`fields.editor.format_h4`},{value:`h5`,label:`fields.editor.format_h5`},{value:`h6`,label:`fields.editor.format_h6`},{value:`blockquote`,label:`fields.editor.format_blockquote`}];function ae(){if(!D.value)return`paragraph`;if(D.value.isActive(`blockquote`))return`blockquote`;for(let e=1;e<=6;e++)if(D.value.isActive(`heading`,{level:e}))return`h${e}`;return`paragraph`}function oe(e){if(!D.value)return;let t=D.value.chain().focus();D.value.isActive(`blockquote`)&&e!==`blockquote`&&t.unsetBlockquote(),e===`blockquote`?t.setParagraph().setBlockquote().run():e===`paragraph`?t.setParagraph().run():t.setHeading({level:Number(e.slice(1))}).run()}function ce(){return D.value?.getAttributes(`textStyle`)?.color||`#000000`}let le=[8,9,10,11,12,14,16,18,20,24,28,36,48,72];function ue(){let e=[{value:``,label:N(`fields.editor.font_size_default`)},...le.map(e=>({value:`${e}pt`,label:N(`fields.editor.font_size_pt`,{size:e})}))],t=de();return t&&!e.some(e=>e.value===t)&&e.push({value:t,label:t}),e}function de(){return D.value?.getAttributes(`textStyle`)?.fontSize||``}function M(e){if(!D.value)return;let t=D.value.chain().focus();e?t.setFontSize(e).run():t.unsetFontSize().run()}let fe={bold:``,italic:``,underline:``,strike:``,link:``,bulletList:``,orderedList:``,image:``,file:``,alignLeft:``,alignCenter:``,alignRight:``,alignJustify:``,table:``,rowPlus:``,rowMinus:``,columnPlus:``,columnMinus:``,mergeCells:``,tableMinus:``},pe=E(()=>{let e=[];return i.toolbar.includes(`bold`)&&e.push({name:`bold`,title:N(`fields.editor.bold_shortcut`),icon:fe.bold,action:()=>D.value?.chain().focus().toggleBold().run(),isActive:()=>D.value?.isActive(`bold`)}),i.toolbar.includes(`italic`)&&e.push({name:`italic`,title:N(`fields.editor.italic_shortcut`),icon:fe.italic,action:()=>D.value?.chain().focus().toggleItalic().run(),isActive:()=>D.value?.isActive(`italic`)}),i.toolbar.includes(`underline`)&&e.push({name:`underline`,title:N(`fields.editor.underline_shortcut`),icon:fe.underline,action:()=>D.value?.chain().focus().toggleUnderline().run(),isActive:()=>D.value?.isActive(`underline`)}),i.toolbar.includes(`strike`)&&e.push({name:`strike`,title:N(`fields.editor.strike`),icon:fe.strike,action:()=>D.value?.chain().focus().toggleStrike().run(),isActive:()=>D.value?.isActive(`strike`)}),i.toolbar.includes(`link`)&&e.push({name:`link`,title:N(`fields.editor.link`),icon:fe.link,action:()=>{let e=prompt(N(`fields.editor.link_prompt`));e&&D.value?.chain().focus().setLink({href:e}).run()},isActive:()=>D.value?.isActive(`link`)}),i.toolbar.includes(`bulletList`)&&e.push({name:`bulletList`,title:N(`fields.editor.bullet_list`),icon:fe.bulletList,action:()=>D.value?.chain().focus().toggleBulletList().run(),isActive:()=>D.value?.isActive(`bulletList`)}),i.toolbar.includes(`orderedList`)&&e.push({name:`orderedList`,title:N(`fields.editor.ordered_list`),icon:fe.orderedList,action:()=>D.value?.chain().focus().toggleOrderedList().run(),isActive:()=>D.value?.isActive(`orderedList`)}),i.toolbar.includes(`align`)&&e.push(...hS(D,fe)),i.toolbar.includes(`image`)&&e.push({name:`image`,title:N(`fields.editor.image`),icon:fe.image,action:()=>ee(`image`)}),i.toolbar.includes(`file`)&&e.push({name:`file`,title:N(`fields.editor.file`),icon:fe.file,action:()=>ee(`all`)}),i.toolbar.includes(`table`)&&e.push(...mS(D,fe)),e});return o(()=>{D.value?.destroy()}),(n,i)=>(l(),A(`div`,{class:`content-field`,"data-content-field":t.name},[t.label?(l(),A(`label`,ww,[y(O(t.label)+` `,1),t.required?(l(),A(`span`,Tw,`*`)):r(``,!0)])):r(``,!0),j(`div`,Ew,[(l(!0),A(k,null,_(f.value,e=>(l(),A(`label`,{key:e.value,class:`flex items-center cursor-pointer`},[s(j(`input`,{type:`radio`,name:t.name+`_mode`,value:e.value,"data-content-mode":e.value,"onUpdate:modelValue":i[0]||=e=>m.value=e,class:`h-4 w-4 text-accent focus:ring-focus border-field`},null,8,Dw),[[re,m.value]]),j(`span`,Ow,O(e.label),1)]))),128))]),m.value===`text`?s((l(),A(`textarea`,{key:1,"onUpdate:modelValue":i[1]||=e=>h.value=e,placeholder:t.placeholder,required:t.required,disabled:t.disabled,rows:t.rows,class:e([`w-full px-3 py-2 border border-field rounded-md shadow-sm focus:ring-focus focus:border-focus resize-y`,{"border-danger":t.error}])},null,10,kw)),[[se,h.value]]):m.value===`html`?s((l(),A(`textarea`,{key:2,"onUpdate:modelValue":i[2]||=e=>h.value=e,placeholder:t.placeholder,required:t.required,disabled:t.disabled,rows:t.rows,class:e([`w-full px-3 py-2 border border-field rounded-md shadow-sm focus:ring-focus focus:border-focus resize-y font-mono text-sm bg-surface-alt`,{"border-danger":t.error}])},null,10,Aw)),[[se,h.value]]):m.value===`wysiwyg`?(l(),A(`div`,{key:3,class:e([`border border-field rounded-lg overflow-hidden`,{"border-danger":t.error,"ring-2 ring-focus":v.value}])},[j(`div`,{class:`flex flex-wrap items-center gap-1 p-2 bg-surface-alt border-b border-field`,onMousedown:T},[t.toolbar.includes(`heading`)?(l(),A(`select`,{key:0,"data-editor-format":`true`,class:`mr-1 h-8 rounded border border-field bg-surface px-2 text-sm text-fg`,value:ae(),onChange:i[3]||=e=>oe(e.target.value),title:n.$t(`fields.editor.format`)},[(l(),A(k,null,_(ie,e=>j(`option`,{key:e.value,value:e.value},O(n.$t(e.label)),9,Mw)),64))],40,jw)):r(``,!0),t.toolbar.includes(`fontSize`)?(l(),A(`select`,{key:1,"data-editor-font-size":`true`,class:`mr-1 h-8 rounded border border-field bg-surface px-2 text-sm text-fg`,value:de(),onChange:i[4]||=e=>M(e.target.value),title:n.$t(`fields.editor.font_size`)},[(l(!0),A(k,null,_(ue(),e=>(l(),A(`option`,{key:e.value,value:e.value},O(e.label),9,Pw))),128))],40,Nw)):r(``,!0),t.toolbar.includes(`color`)?(l(),A(`label`,{key:2,class:`flex h-8 cursor-pointer items-center gap-1 rounded px-1.5 hover:bg-hover`,title:n.$t(`fields.editor.text_color`)},[i[7]||=j(`span`,{class:`text-sm font-semibold text-fg`},`A`,-1),j(`input`,{type:`color`,"data-editor-color":`true`,class:`h-5 w-6 cursor-pointer border-0 bg-transparent p-0`,value:ce(),onInput:i[5]||=e=>g(D)?.chain().focus().setColor(e.target.value).run()},null,40,Iw)],8,Fw)):r(``,!0),(l(!0),A(k,null,_(pe.value,t=>(l(),A(k,{key:t.name},[!t.visible||t.visible()?(l(),A(`button`,{key:0,type:`button`,"data-editor-button":t.name,onClick:t.action,class:e([`p-2 rounded hover:bg-hover`,{"bg-accent-soft text-accent-soft-fg":t.isActive?.()}]),title:t.title},[j(`span`,{innerHTML:t.icon,class:`w-4 h-4 block`},null,8,Rw)],10,Lw)):r(``,!0)],64))),128))],32),a(g(mm),{editor:g(D),class:`max-w-none p-4 overflow-x-auto`,style:ne({minHeight:t.minHeight+`px`})},null,8,[`editor`,`style`])],2)):r(``,!0),t.hint&&!t.error?(l(),A(`p`,zw,O(t.hint),1)):r(``,!0),t.error?(l(),A(`p`,Bw,O(t.error),1)):r(``,!0),a(oC,{show:b.value,type:x.value,onSelect:te,onClose:i[6]||=e=>b.value=!1},null,8,[`show`,`type`])],8,Cw))}},Hw={class:`repeatable-field`},Uw={key:0,class:`block text-sm font-medium text-fg mb-2`},Ww={key:0,class:`text-danger`},Gw={key:1,class:`space-y-3`},Kw=[`data-repeatable-item`],qw={class:`flex items-center justify-between mb-2`},Jw={class:`text-sm font-medium text-fg`},Yw={class:`flex items-center gap-1`},Xw=[`onClick`,`disabled`,`title`],Zw=[`onClick`,`disabled`,`title`],Qw=[`onClick`,`title`],$w={key:2,class:`space-y-2`},eT=[`data-repeatable-item`],tT={class:`flex flex-col gap-0.5`},nT=[`onClick`,`disabled`,`title`],rT=[`onClick`,`disabled`,`title`],iT=[`type`,`value`,`onInput`,`placeholder`,`disabled`],aT=[`onClick`,`disabled`,`title`],oT={key:3,class:`text-muted text-sm py-2`},sT={key:5,class:`mt-1 text-xs text-muted`},cT={__name:`RepeatableField`,props:{itemLabel:{type:String,default:``},itemModes:{type:Array,default:()=>[`text`,`html`,`wysiwyg`]},itemToolbar:{type:Array,default:null},modelValue:{type:Array,default:()=>[]},name:{type:String,required:!0},label:{type:String,default:``},itemType:{type:String,default:`text`},maxItems:{type:Number,default:0},minItems:{type:Number,default:0},addLabel:{type:String,default:``},placeholder:{type:String,default:``},required:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},error:{type:String,default:null}},emits:[`update:modelValue`],setup(t,{emit:n}){let i=t,o=n,s=E({get:()=>Array.isArray(i.modelValue)?i.modelValue:[],set:e=>o(`update:modelValue`,e)}),c=E(()=>!i.disabled&&(i.maxItems===0||s.value.length!i.disabled&&s.value.length>i.minItems),d=E(()=>({text:`text`,number:`number`,date:`date`,datetime:`datetime-local`,email:`email`,url:`url`,tel:`tel`})[i.itemType]||`text`),f=E(()=>i.itemType===`content`),p=E(()=>i.addLabel||N(`common.add`));function m(e){let t=i.itemLabel||i.label||N(`fields.repeatable.item`);return N(`fields.repeatable.item_title`,{label:t,number:e+1})}function h(){c.value&&(s.value=[...s.value,``])}function g(e){if(u.value){let t=[...s.value];t.splice(e,1),s.value=t}}function v(e,t){let n=[...s.value];n[e]=t,s.value=n}function b(e,t){if(t<0||t>=s.value.length)return;let n=[...s.value],[r]=n.splice(e,1);n.splice(t,0,r),s.value=n}return(n,i)=>(l(),A(`div`,Hw,[t.label?(l(),A(`label`,Uw,[y(O(t.label)+` `,1),t.required?(l(),A(`span`,Ww,`*`)):r(``,!0)])):r(``,!0),f.value?(l(),A(`div`,Gw,[(l(!0),A(k,null,_(s.value,(e,o)=>(l(),A(`div`,{key:o,"data-repeatable-item":o,class:`border border-line rounded-lg p-3 bg-surface`},[j(`div`,qw,[j(`span`,Jw,O(m(o)),1),j(`div`,Yw,[j(`button`,{type:`button`,onClick:e=>b(o,o-1),disabled:t.disabled||o===0,class:`p-1 text-muted hover:text-fg disabled:opacity-30 disabled:cursor-not-allowed`,title:n.$t(`fields.repeatable.move_up`)},[...i[0]||=[j(`svg`,{class:`w-4 h-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[j(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M5 15l7-7 7 7`})],-1)]],8,Xw),j(`button`,{type:`button`,onClick:e=>b(o,o+1),disabled:t.disabled||o===s.value.length-1,class:`p-1 text-muted hover:text-fg disabled:opacity-30 disabled:cursor-not-allowed`,title:n.$t(`fields.repeatable.move_down`)},[...i[1]||=[j(`svg`,{class:`w-4 h-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[j(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M19 9l-7 7-7-7`})],-1)]],8,Zw),u.value?(l(),A(`button`,{key:0,type:`button`,onClick:e=>g(o),class:`p-1 text-danger hover:text-danger-soft-fg hover:bg-danger-soft rounded`,title:n.$t(`common.delete`)},[...i[2]||=[j(`svg`,{class:`w-4 h-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[j(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16`})],-1)]],8,Qw)):r(``,!0)])]),a(Vw,ae({"model-value":e,"onUpdate:modelValue":e=>v(o,e),name:`${t.name}_${o}`,modes:t.itemModes},{ref_for:!0},t.itemToolbar?{toolbar:t.itemToolbar}:{},{disabled:t.disabled,rows:8}),null,16,[`model-value`,`onUpdate:modelValue`,`name`,`modes`,`disabled`])],8,Kw))),128))])):(l(),A(`div`,$w,[(l(!0),A(k,null,_(s.value,(a,o)=>(l(),A(`div`,{key:o,"data-repeatable-item":o,class:`flex items-center gap-2`},[j(`div`,tT,[j(`button`,{type:`button`,onClick:e=>b(o,o-1),disabled:t.disabled||o===0,class:`p-0.5 text-muted hover:text-fg disabled:opacity-30 disabled:cursor-not-allowed`,title:n.$t(`fields.repeatable.move_up`)},[...i[3]||=[j(`svg`,{class:`w-4 h-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[j(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M5 15l7-7 7 7`})],-1)]],8,nT),j(`button`,{type:`button`,onClick:e=>b(o,o+1),disabled:t.disabled||o===s.value.length-1,class:`p-0.5 text-muted hover:text-fg disabled:opacity-30 disabled:cursor-not-allowed`,title:n.$t(`fields.repeatable.move_down`)},[...i[4]||=[j(`svg`,{class:`w-4 h-4`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[j(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M19 9l-7 7-7-7`})],-1)]],8,rT)]),j(`input`,{type:d.value,value:a,onInput:e=>v(o,e.target.value),placeholder:t.placeholder||n.$t(`fields.repeatable.item_title`,{label:t.label,number:o+1}),disabled:t.disabled,class:e([`flex-1 px-3 py-2 border border-field rounded-md shadow-sm focus:ring-focus focus:border-focus disabled:bg-off disabled:cursor-not-allowed`,{"border-danger":t.error}])},null,42,iT),u.value?(l(),A(`button`,{key:0,type:`button`,onClick:e=>g(o),disabled:!u.value,class:`p-2 text-danger hover:text-danger-soft-fg hover:bg-danger-soft rounded-md disabled:opacity-30 disabled:cursor-not-allowed`,title:n.$t(`common.delete`)},[...i[5]||=[j(`svg`,{class:`w-5 h-5`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[j(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16`})],-1)]],8,aT)):r(``,!0)],8,eT))),128))])),s.value.length===0?(l(),A(`div`,oT,O(n.$t(`fields.repeatable.empty`,{add:p.value})),1)):r(``,!0),c.value?(l(),A(`button`,{key:4,"data-action":`repeatable-add`,type:`button`,onClick:h,class:`mt-2 inline-flex items-center px-3 py-2 text-sm font-medium text-accent bg-accent-soft hover:bg-accent-soft rounded-md border border-accent-soft transition-colors`},[i[6]||=j(`svg`,{class:`w-4 h-4 mr-1.5`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[j(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M12 4v16m8-8H4`})],-1),y(` `+O(p.value),1)])):r(``,!0),t.maxItems>0?(l(),A(`div`,sT,O(s.value.length)+` / `+O(t.maxItems),1)):r(``,!0)]))}},lT={class:`belongs-to-many-field`},uT=[`for`],dT={key:0,class:`text-danger`},fT={key:0,class:`mb-2 flex flex-wrap gap-1`},pT=[`onClick`,`disabled`],mT=[`disabled`],hT=[`data-option-value`,`data-option-selected`],gT=[`checked`,`onChange`,`disabled`],_T={class:`ml-2 text-sm text-fg`},vT={key:2,class:`border border-field rounded-md px-3 py-4 text-center text-muted text-sm`},yT={key:3,class:`mt-1 text-sm text-muted`},bT={key:4,class:`mt-1 text-sm text-danger`},xT={__name:`BelongsToManyField`,props:{name:{type:String,required:!0},label:{type:String,default:``},modelValue:{type:Array,default:()=>[]},options:{type:Array,default:()=>[]},required:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},placeholder:{type:String,default:null},error:{type:String,default:null},hint:{type:String,default:null},multiple:{type:Boolean,default:!0}},emits:[`update:modelValue`],setup(t,{emit:n}){let i=t,a=n,o=E({get:()=>i.modelValue?Array.isArray(i.modelValue)?i.modelValue:[i.modelValue]:[],set:e=>a(`update:modelValue`,e||[])}),s=e=>o.value.map(String).includes(String(e)),c=e=>{if(i.disabled)return;let t=[...o.value],n=t.findIndex(t=>String(t)===String(e));n===-1?t.push(e):t.splice(n,1),a(`update:modelValue`,t)},u=E(()=>o.value.map(e=>i.options.find(t=>String(t.value)===String(e))?.label).filter(Boolean)),d=()=>{i.disabled||a(`update:modelValue`,[])};return(n,i)=>(l(),A(`div`,lT,[j(`label`,{for:t.name,class:`block text-sm font-medium text-fg mb-1`},[y(O(t.label)+` `,1),t.required?(l(),A(`span`,dT,`*`)):r(``,!0)],8,uT),o.value.length>0?(l(),A(`div`,fT,[(l(!0),A(k,null,_(u.value,(e,n)=>(l(),A(`span`,{key:n,class:`inline-flex items-center px-2 py-1 rounded-md text-sm bg-accent-soft text-accent-hover`},[y(O(e)+` `,1),j(`button`,{type:`button`,onClick:e=>c(o.value[n]),class:`ml-1 text-accent hover:text-accent-hover`,disabled:t.disabled},[...i[0]||=[j(`svg`,{class:`w-3 h-3`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[j(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M6 18L18 6M6 6l12 12`})],-1)]],8,pT)]))),128)),o.value.length>1?(l(),A(`button`,{key:0,type:`button`,onClick:d,class:`text-xs text-muted hover:text-danger`,disabled:t.disabled},O(n.$t(`fields.belongs_to_many.clear_all`)),9,mT)):r(``,!0)])):r(``,!0),t.options.length>0?(l(),A(`div`,{key:1,class:e([`border border-field rounded-md max-h-64 overflow-y-auto`,{"border-danger":t.error,"opacity-50":t.disabled}])},[(l(!0),A(k,null,_(t.options,n=>(l(),A(`label`,{key:n.value,"data-option-value":n.value,"data-option-selected":s(n.value)?`true`:`false`,class:e([`flex items-center px-3 py-2 hover:bg-hover cursor-pointer border-b border-line last:border-b-0`,{"bg-accent-soft":s(n.value)}])},[j(`input`,{type:`checkbox`,checked:s(n.value),onChange:e=>c(n.value),disabled:t.disabled,class:`h-4 w-4 text-accent focus:ring-focus border-field rounded`},null,40,gT),j(`span`,_T,O(n.label),1)],10,hT))),128))],2)):(l(),A(`div`,vT,O(n.$t(`fields.belongs_to_many.no_options`)),1)),t.hint&&!t.error?(l(),A(`p`,yT,O(t.hint),1)):r(``,!0),t.error?(l(),A(`p`,bT,O(t.error),1)):r(``,!0)]))}};function ST(e){return e===0?!1:Array.isArray(e)&&e.length===0?!0:!e}function CT(e){return(...t)=>!e(...t)}function wT(e,t){return e===void 0&&(e=`undefined`),e===null&&(e=`null`),e===!1&&(e=`false`),e.toString().toLowerCase().indexOf(t.trim())!==-1}function TT(e){return e.filter(e=>!e.$isLabel)}function ET(e,t){return n=>n.reduce((n,r)=>r[e]&&r[e].length?(n.push({$groupLabel:r[t],$isLabel:!0}),n.concat(r[e])):n,[])}var DT=(...e)=>t=>e.reduce((e,t)=>t(e),t),OT={name:`vue-multiselect`,mixins:[{data(){return{search:``,isOpen:!1,preferredOpenDirection:`below`,optimizedHeight:this.maxHeight}},props:{internalSearch:{type:Boolean,default:!0},options:{type:Array,required:!0},multiple:{type:Boolean,default:!1},trackBy:{type:String},label:{type:String},searchable:{type:Boolean,default:!0},clearOnSelect:{type:Boolean,default:!0},hideSelected:{type:Boolean,default:!1},placeholder:{type:String,default:`Select option`},allowEmpty:{type:Boolean,default:!0},resetAfter:{type:Boolean,default:!1},closeOnSelect:{type:Boolean,default:!0},customLabel:{type:Function,default(e,t){return ST(e)?``:t?e[t]:e}},taggable:{type:Boolean,default:!1},tagPlaceholder:{type:String,default:`Press enter to create a tag`},tagPosition:{type:String,default:`top`},max:{type:[Number,Boolean],default:!1},id:{default:null},optionsLimit:{type:Number,default:1e3},groupValues:{type:String},groupLabel:{type:String},groupSelect:{type:Boolean,default:!1},blockKeys:{type:Array,default(){return[]}},preserveSearch:{type:Boolean,default:!1},preselectFirst:{type:Boolean,default:!1},preventAutofocus:{type:Boolean,default:!1},filteringSortFunc:{type:Function,default:null}},mounted(){!this.multiple&&this.max&&console.warn(`[Vue-Multiselect warn]: Max prop should not be used when prop Multiple equals false.`),this.preselectFirst&&!this.internalValue.length&&this.options.length&&this.select(this.filteredOptions[0])},computed:{internalValue(){return this.modelValue||this.modelValue===0?Array.isArray(this.modelValue)?this.modelValue:[this.modelValue]:[]},filteredOptions(){let e=this.search||``,t=e.toLowerCase().trim(),n=this.options.concat();return n=this.internalSearch?this.groupValues?this.filterAndFlat(n,t,this.label):this.filterOptions(n,t,this.label,this.customLabel):this.groupValues?ET(this.groupValues,this.groupLabel)(n):n,n=this.hideSelected?n.filter(CT(this.isSelected)):n,this.taggable&&t.length&&!this.isExistingOption(t)&&(this.tagPosition===`bottom`?n.push({isTag:!0,label:e}):n.unshift({isTag:!0,label:e})),n.slice(0,this.optionsLimit)},valueKeys(){return this.trackBy?this.internalValue.map(e=>e[this.trackBy]):this.internalValue},optionKeys(){return(this.groupValues?this.flatAndStrip(this.options):this.options).map(e=>this.customLabel(e,this.label).toString().toLowerCase())},currentOptionLabel(){return this.multiple?this.searchable?``:this.placeholder:this.internalValue.length?this.getOptionLabel(this.internalValue[0]):this.searchable?``:this.placeholder}},watch:{internalValue:{handler(){this.resetAfter&&this.internalValue.length&&(this.search=``,this.$emit(`update:modelValue`,this.multiple?[]:null))},deep:!0},search(){this.$emit(`search-change`,this.search)}},emits:[`open`,`search-change`,`close`,`select`,`update:modelValue`,`remove`,`tag`],methods:{getValue(){return this.multiple?this.internalValue:this.internalValue.length===0?null:this.internalValue[0]},filterAndFlat(e,t,n){return DT(this.filterGroups(t,n,this.groupValues,this.groupLabel,this.customLabel),ET(this.groupValues,this.groupLabel))(e)},flatAndStrip(e){return DT(ET(this.groupValues,this.groupLabel),TT)(e)},updateSearch(e){this.search=e},isExistingOption(e){return this.options?this.optionKeys.indexOf(e)>-1:!1},isSelected(e){let t=this.trackBy?e[this.trackBy]:e;return this.valueKeys.indexOf(t)>-1},isOptionDisabled(e){return!!e.$isDisabled},getOptionLabel(e){if(ST(e))return``;if(e.isTag)return e.label;if(e.$isLabel)return e.$groupLabel;let t=this.customLabel(e,this.label);return ST(t)?``:t},select(e,t){if(e.$isLabel&&this.groupSelect)this.selectGroup(e);else if(!(this.blockKeys.indexOf(t)!==-1||this.disabled||e.$isDisabled||e.$isLabel)&&!(this.max&&this.multiple&&this.internalValue.length===this.max)&&(t!==`Tab`||this.pointerDirty)){if(e.isTag)this.$emit(`tag`,e.label,this.id),this.search=``,this.closeOnSelect&&!this.multiple&&this.deactivate();else{if(this.isSelected(e)){t!==`Tab`&&this.removeElement(e);return}this.multiple?this.$emit(`update:modelValue`,this.internalValue.concat([e])):this.$emit(`update:modelValue`,e),this.$emit(`select`,e,this.id),this.clearOnSelect&&(this.search=``)}this.closeOnSelect&&this.deactivate()}},selectGroup(e){let t=this.options.find(t=>t[this.groupLabel]===e.$groupLabel);if(t){if(this.wholeGroupSelected(t)){this.$emit(`remove`,t[this.groupValues],this.id);let e=this.trackBy?t[this.groupValues].map(e=>e[this.trackBy]):t[this.groupValues],n=this.internalValue.filter(t=>e.indexOf(this.trackBy?t[this.trackBy]:t)===-1);this.$emit(`update:modelValue`,n)}else{let e=t[this.groupValues].filter(e=>!(this.isOptionDisabled(e)||this.isSelected(e)));this.max&&e.splice(this.max-this.internalValue.length),this.$emit(`select`,e,this.id),this.$emit(`update:modelValue`,this.internalValue.concat(e))}this.closeOnSelect&&this.deactivate()}},wholeGroupSelected(e){return e[this.groupValues].every(e=>this.isSelected(e)||this.isOptionDisabled(e))},wholeGroupDisabled(e){return e[this.groupValues].every(this.isOptionDisabled)},removeElement(e,t=!0){if(this.disabled||e.$isDisabled)return;if(!this.allowEmpty&&this.internalValue.length<=1){this.deactivate();return}let n=typeof e==`object`?this.valueKeys.indexOf(e[this.trackBy]):this.valueKeys.indexOf(e);if(this.multiple){let e=this.internalValue.slice(0,n).concat(this.internalValue.slice(n+1));this.$emit(`update:modelValue`,e)}else this.$emit(`update:modelValue`,null);this.$emit(`remove`,e,this.id),this.closeOnSelect&&t&&this.deactivate()},removeLastElement(){this.blockKeys.indexOf(`Delete`)===-1&&this.search.length===0&&Array.isArray(this.internalValue)&&this.internalValue.length&&this.removeElement(this.internalValue[this.internalValue.length-1],!1)},activate(){this.isOpen||this.disabled||(this.adjustPosition(),this.groupValues&&this.pointer===0&&this.filteredOptions.length&&(this.pointer=1),this.isOpen=!0,this.searchable?(this.preserveSearch||(this.search=``),this.preventAutofocus||this.$nextTick(()=>this.$refs.search&&this.$refs.search.focus())):this.preventAutofocus||this.$el!==void 0&&this.$el.focus(),this.$emit(`open`,this.id))},deactivate(){this.isOpen&&(this.isOpen=!1,this.searchable?this.$refs.search!==null&&this.$refs.search!==void 0&&this.$refs.search.blur():this.$el!==void 0&&this.$el.blur(),this.preserveSearch||(this.search=``),this.$emit(`close`,this.getValue(),this.id))},toggle(){this.isOpen?this.deactivate():this.activate()},adjustPosition(){if(typeof window>`u`)return;let e=this.$el.getBoundingClientRect().top,t=window.innerHeight-this.$el.getBoundingClientRect().bottom;t>this.maxHeight||t>e||this.openDirection===`below`||this.openDirection===`bottom`?(this.preferredOpenDirection=`below`,this.optimizedHeight=Math.min(t-40,this.maxHeight)):(this.preferredOpenDirection=`above`,this.optimizedHeight=Math.min(e-40,this.maxHeight))},filterOptions(e,t,n,r){return t?e.filter(e=>wT(r(e,n),t)).sort((e,t)=>typeof this.filteringSortFunc==`function`?this.filteringSortFunc(e,t):r(e,n).length-r(t,n).length):e},filterGroups(e,t,n,r,i){return a=>a.map(a=>{if(!a[n])return console.warn(`Options passed to vue-multiselect do not contain groups, despite the config.`),[];let o=this.filterOptions(a[n],e,t,i);return o.length?{[r]:a[r],[n]:o}:[]})}}},{data(){return{pointer:0,pointerDirty:!1}},props:{showPointer:{type:Boolean,default:!0},optionHeight:{type:Number,default:40}},computed:{pointerPosition(){return this.pointer*this.optionHeight},visibleElements(){return this.optimizedHeight/this.optionHeight}},watch:{filteredOptions(){this.pointerAdjust()},isOpen(){this.pointerDirty=!1},pointer(){this.$refs.search&&this.$refs.search.setAttribute(`aria-activedescendant`,this.id+`-`+this.pointer.toString())}},methods:{optionHighlight(e,t){return{"multiselect__option--highlight":e===this.pointer&&this.showPointer,"multiselect__option--selected":this.isSelected(t)}},groupHighlight(e,t){if(!this.groupSelect)return[`multiselect__option--disabled`,{"multiselect__option--group":t.$isLabel}];let n=this.options.find(e=>e[this.groupLabel]===t.$groupLabel);return n&&!this.wholeGroupDisabled(n)?[`multiselect__option--group`,{"multiselect__option--highlight":e===this.pointer&&this.showPointer},{"multiselect__option--group-selected":this.wholeGroupSelected(n)}]:`multiselect__option--disabled`},addPointerElement({key:e}=`Enter`){this.filteredOptions.length>0&&this.select(this.filteredOptions[this.pointer],e),this.pointerReset()},pointerForward(){this.pointer0?(this.pointer--,this.$refs.list?.scrollTop>=this.pointerPosition&&(this.$refs.list.scrollTop=this.pointerPosition),this.filteredOptions[this.pointer]&&this.filteredOptions[this.pointer].$isLabel&&!this.groupSelect&&this.pointerBackward()):this.filteredOptions[this.pointer]&&this.filteredOptions[0].$isLabel&&!this.groupSelect&&this.pointerForward(),this.pointerDirty=!0},pointerReset(){this.closeOnSelect&&(this.pointer=0,this.$refs.list&&(this.$refs.list.scrollTop=0))},pointerAdjust(){this.pointer>=this.filteredOptions.length-1&&(this.pointer=this.filteredOptions.length?this.filteredOptions.length-1:0),this.filteredOptions.length>0&&this.filteredOptions[this.pointer]&&this.filteredOptions[this.pointer].$isLabel&&!this.groupSelect&&this.pointerForward()},pointerSet(e){this.pointer=e,this.pointerDirty=!0}}}],compatConfig:{MODE:3,ATTR_ENUMERATED_COERCION:!1},props:{name:{type:String,default:``},modelValue:{type:null,default(){return[]}},selectLabel:{type:String,default:`Press enter to select`},selectGroupLabel:{type:String,default:`Press enter to select group`},selectedLabel:{type:String,default:`Selected`},deselectLabel:{type:String,default:`Press enter to remove`},deselectGroupLabel:{type:String,default:`Press enter to deselect group`},showLabels:{type:Boolean,default:!0},limit:{type:Number,default:99999},maxHeight:{type:Number,default:300},limitText:{type:Function,default:e=>`and ${e} more`},loading:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},spellcheck:{type:Boolean,default:!1},openDirection:{type:String,default:``},showNoOptions:{type:Boolean,default:!0},showNoResults:{type:Boolean,default:!0},tabindex:{type:Number,default:0},required:{type:Boolean,default:!1},useTeleport:{type:Boolean,default:!1},teleportTarget:{type:[String,Object],default:`body`},contentWrapperClass:{type:[String,Array,Object],default:``}},data(){return{dropdownStyles:{},ready:!1}},computed:{hasOptionGroup(){return this.groupValues&&this.groupLabel&&this.groupSelect},isSingleLabelVisible(){return(this.singleValue||this.singleValue===0)&&(!this.isOpen||!this.searchable)&&!this.visibleValues.length},isPlaceholderVisible(){return!this.internalValue.length&&(!this.searchable||!this.isOpen)},visibleValues(){return this.multiple?this.internalValue.slice(0,this.limit):[]},singleValue(){return this.internalValue[0]},deselectLabelText(){return this.showLabels?this.deselectLabel:``},deselectGroupLabelText(){return this.showLabels?this.deselectGroupLabel:``},selectLabelText(){return this.showLabels?this.selectLabel:``},selectGroupLabelText(){return this.showLabels?this.selectGroupLabel:``},selectedLabelText(){return this.showLabels?this.selectedLabel:``},inputStyle(){return this.searchable||this.multiple&&this.modelValue&&this.modelValue.length?this.isOpen?{width:`100%`}:{width:`0`,position:`absolute`,padding:`0`}:``},contentStyle(){return this.options.length?{display:`inline-block`}:{display:`block`}},isAbove(){return this.openDirection===`above`||this.openDirection===`top`?!0:this.openDirection===`below`||this.openDirection===`bottom`?!1:this.preferredOpenDirection===`above`},showSearchInput(){return this.searchable&&(this.hasSingleSelectedSlot&&(this.visibleSingleValue||this.visibleSingleValue===0)?this.isOpen:!0)},isRequired(){return this.required!==!1&&this.internalValue.length<=0}},watch:{isOpen(e){e&&(this.useTeleport?(this.ready=!1,this.$nextTick(()=>{let e=this.$el.getBoundingClientRect();this.dropdownStyles={position:`absolute`,top:`${e.bottom+window.scrollY}px`,left:`${e.left+window.scrollX}px`,width:`${e.width}px`,zIndex:9999},this.ready=!0})):this.ready=!0)}}},kT=[`tabindex`,`aria-expanded`,`aria-owns`,`aria-activedescendant`],AT={ref:`tags`,class:`multiselect__tags`},jT={class:`multiselect__tags-wrap`},MT=[`textContent`],NT=[`onKeydown`,`onMousedown`],PT=[`textContent`],FT={class:`multiselect__spinner`},IT=[`name`,`id`,`spellcheck`,`placeholder`,`required`,`value`,`disabled`,`tabindex`,`aria-label`,`aria-controls`],LT=[`id`,`aria-multiselectable`],RT={key:0},zT={class:`multiselect__option`},BT=[`aria-selected`,`id`,`role`],VT=[`onClick`,`onMouseenter`,`data-select`,`data-selected`,`data-deselect`],HT=[`data-select`,`data-deselect`,`onMouseenter`,`onMousedown`],UT={class:`multiselect__option`},WT={class:`multiselect__option`};function GT(t,n,i,o,c,u){return l(),A(`div`,{tabindex:t.searchable?-1:i.tabindex,class:e([{"multiselect--active":t.isOpen,"multiselect--disabled":i.disabled,"multiselect--above":u.isAbove,"multiselect--has-options-group":u.hasOptionGroup},`multiselect`]),onFocus:n[14]||=e=>t.activate(),onBlur:n[15]||=e=>!t.searchable&&t.deactivate(),onKeydown:[n[16]||=D(T(e=>t.pointerForward(),[`self`,`prevent`]),[`down`]),n[17]||=D(T(e=>t.pointerBackward(),[`self`,`prevent`]),[`up`]),n[18]||=D(T(e=>t.addPointerElement(e),[`stop`,`self`]),[`enter`,`tab`])],onKeyup:n[19]||=D(e=>t.deactivate(),[`esc`]),role:`combobox`,"aria-expanded":t.isOpen,"aria-owns":`listbox-`+t.id,"aria-activedescendant":t.isOpen&&t.pointer!==null?t.id+`-`+t.pointer:null},[M(t.$slots,`caret`,{toggle:t.toggle},()=>[j(`div`,{onMousedown:n[0]||=T(e=>t.toggle(),[`prevent`,`stop`]),class:`multiselect__select`},null,32)]),M(t.$slots,`clear`,{search:t.search}),j(`div`,AT,[M(t.$slots,`selection`,{search:t.search,remove:t.removeElement,values:u.visibleValues,isOpen:t.isOpen},()=>[s(j(`div`,jT,[(l(!0),A(k,null,_(u.visibleValues,(e,r)=>M(t.$slots,`tag`,{option:e,search:t.search,remove:t.removeElement},()=>[(l(),A(`span`,{class:`multiselect__tag`,key:r,onMousedown:n[1]||=T(()=>{},[`prevent`])},[j(`span`,{textContent:O(t.getOptionLabel(e))},null,8,MT),j(`i`,{tabindex:`1`,onKeydown:D(T(n=>t.removeElement(e),[`prevent`]),[`enter`]),onMousedown:T(n=>t.removeElement(e),[`prevent`]),class:`multiselect__tag-icon`},null,40,NT)],32))])),256))],512),[[ie,u.visibleValues.length>0]]),t.internalValue&&t.internalValue.length>i.limit?M(t.$slots,`limit`,{key:0},()=>[j(`strong`,{class:`multiselect__strong`,textContent:O(i.limitText(t.internalValue.length-i.limit))},null,8,PT)]):r(`v-if`,!0)]),a(ee,{name:`multiselect__loading`},{default:S(()=>[M(t.$slots,`loading`,{},()=>[s(j(`div`,FT,null,512),[[ie,i.loading]])])]),_:3}),t.searchable?(l(),A(`input`,{key:0,ref:`search`,name:i.name,id:t.id,type:`text`,autocomplete:`off`,spellcheck:i.spellcheck,placeholder:t.placeholder,required:u.isRequired,style:ne(u.inputStyle),value:t.search,disabled:i.disabled,tabindex:i.tabindex,"aria-label":i.name+`-searchbox`,onInput:n[2]||=e=>t.updateSearch(e.target.value),onFocus:n[3]||=T(e=>t.activate(),[`prevent`]),onBlur:n[4]||=T(e=>t.deactivate(),[`prevent`]),onKeyup:n[5]||=D(e=>t.deactivate(),[`esc`]),onKeydown:[n[6]||=D(T(e=>t.pointerForward(),[`prevent`]),[`down`]),n[7]||=D(T(e=>t.pointerBackward(),[`prevent`]),[`up`]),n[8]||=D(T(e=>t.addPointerElement(e),[`prevent`,`stop`,`self`]),[`enter`]),n[9]||=D(T(e=>t.removeLastElement(),[`stop`]),[`delete`])],class:`multiselect__input`,"aria-controls":`listbox-`+t.id},null,44,IT)):r(`v-if`,!0),u.isSingleLabelVisible?(l(),A(`span`,{key:1,class:`multiselect__single`,onMousedown:n[10]||=T((...e)=>t.toggle&&t.toggle(...e),[`prevent`])},[M(t.$slots,`singleLabel`,{option:u.singleValue},()=>[y(O(t.currentOptionLabel),1)])],32)):r(`v-if`,!0),u.isPlaceholderVisible?(l(),A(`span`,{key:2,class:`multiselect__placeholder`,onMousedown:n[11]||=T((...e)=>t.toggle&&t.toggle(...e),[`prevent`])},[M(t.$slots,`placeholder`,{},()=>[y(O(t.placeholder),1)])],32)):r(`v-if`,!0)],512),(l(),v(de,{to:i.teleportTarget,disabled:!i.useTeleport},[a(ee,{name:`multiselect`},{default:S(()=>[t.isOpen&&c.ready?(l(),A(`div`,{key:0,class:e([`multiselect__content-wrapper`,i.contentWrapperClass]),onFocus:n[12]||=(...e)=>t.activate&&t.activate(...e),tabindex:`-1`,onMousedown:n[13]||=T(()=>{},[`prevent`]),style:ne([c.dropdownStyles,{maxHeight:t.optimizedHeight+`px`}]),ref:`list`},[j(`ul`,{class:`multiselect__content`,style:ne(u.contentStyle),role:`listbox`,id:`listbox-`+t.id,"aria-multiselectable":t.multiple},[M(t.$slots,`beforeList`),t.multiple&&t.max===t.internalValue.length?(l(),A(`li`,RT,[j(`span`,zT,[M(t.$slots,`maxElements`,{},()=>[y(`Maximum of `+O(t.max)+` options selected. First remove a selected option to select another.`,1)])])])):r(`v-if`,!0),!t.max||t.internalValue.length(l(),A(`li`,{class:`multiselect__element`,key:i,"aria-selected":t.isSelected(n),id:t.id+`-`+i,role:n&&(n.$isLabel||n.$isDisabled)?null:`option`},[n&&(n.$isLabel||n.$isDisabled)?r(`v-if`,!0):(l(),A(`span`,{key:0,class:e([t.optionHighlight(i,n),`multiselect__option`]),onClick:T(e=>t.select(n),[`stop`]),onMouseenter:T(e=>t.pointerSet(i),[`self`]),"data-select":n&&n.isTag?t.tagPlaceholder:u.selectLabelText,"data-selected":u.selectedLabelText,"data-deselect":u.deselectLabelText},[M(t.$slots,`option`,{option:n,search:t.search,index:i},()=>[j(`span`,null,O(t.getOptionLabel(n)),1)])],42,VT)),n&&(n.$isLabel||n.$isDisabled)?(l(),A(`span`,{key:1,"data-select":t.groupSelect&&u.selectGroupLabelText,"data-deselect":t.groupSelect&&u.deselectGroupLabelText,class:e([t.groupHighlight(i,n),`multiselect__option`]),onMouseenter:T(e=>t.groupSelect&&t.pointerSet(i),[`self`]),onMousedown:T(e=>t.selectGroup(n),[`prevent`])},[M(t.$slots,`option`,{option:n,search:t.search,index:i},()=>[j(`span`,null,O(t.getOptionLabel(n)),1)])],42,HT)):r(`v-if`,!0)],8,BT))),128)):r(`v-if`,!0),s(j(`li`,null,[j(`span`,UT,[M(t.$slots,`noResult`,{search:t.search},()=>[n[20]||=y(`No elements found. Consider changing the search query.`)])])],512),[[ie,i.showNoResults&&t.filteredOptions.length===0&&t.search&&!i.loading]]),s(j(`li`,null,[j(`span`,WT,[M(t.$slots,`noOptions`,{},()=>[n[21]||=y(`List is empty.`)])])],512),[[ie,i.showNoOptions&&t.filteredOptions.length===0&&!t.search&&!i.loading]]),M(t.$slots,`afterList`)],12,LT)],38)):r(`v-if`,!0)]),_:3})],8,[`to`,`disabled`]))],42,kT)}OT.render=GT;var KT=[`data-selected-value`],qT=[`aria-label`,`disabled`,`onMousedown`,`onKeydown`],JT=[`data-option-value`,`data-option-selected`],YT={class:`atrium-multiselect__check`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`,"aria-hidden":`true`},XT={key:0,"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2.5`,d:`M5 13l4 4L19 7`},ZT={__name:`MultiSelectField`,props:{id:{type:String,required:!0},modelValue:{type:[Array,String,Number],default:()=>[]},options:{type:Array,default:()=>[]},placeholder:{type:String,default:``},disabled:{type:Boolean,default:!1},error:{type:String,default:null}},emits:[`update:modelValue`],setup(t,{emit:n}){let i=t,a=n,o=E(()=>i.modelValue===null||i.modelValue===void 0||i.modelValue===``?[]:(Array.isArray(i.modelValue)?i.modelValue:[i.modelValue]).map(String)),s=E({get:()=>o.value.map(e=>i.options.find(t=>String(t.value)===e)).filter(Boolean),set:e=>a(`update:modelValue`,e.map(e=>e.value))}),c=e=>o.value.includes(String(e.value));return(n,i)=>(l(),v(g(OT),{modelValue:s.value,"onUpdate:modelValue":i[0]||=e=>s.value=e,id:t.id,options:t.options,"track-by":`value`,label:`label`,multiple:!0,"close-on-select":!1,"clear-on-select":!1,"show-labels":!1,placeholder:t.placeholder,disabled:t.disabled,class:e([`atrium-multiselect`,{"atrium-multiselect--error":t.error}]),"data-multiselect":t.id},{tag:S(({option:e,remove:r})=>[j(`span`,{class:`atrium-multiselect__tag`,"data-selected-value":e.value},[y(O(e.label)+` `,1),j(`button`,{type:`button`,class:`atrium-multiselect__remove`,"aria-label":n.$t(`common.delete`)+`: `+e.label,disabled:t.disabled,onMousedown:T(t=>r(e),[`prevent`,`stop`]),onKeydown:D(T(t=>r(e),[`prevent`]),[`enter`])},[...i[1]||=[j(`svg`,{class:`w-3 h-3`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`,"aria-hidden":`true`},[j(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M6 18L18 6M6 6l12 12`})],-1)]],40,qT)],8,KT)]),option:S(({option:e})=>[j(`span`,{class:`atrium-multiselect__option`,"data-option-value":e.value,"data-option-selected":c(e)?`true`:`false`},[(l(),A(`svg`,YT,[c(e)?(l(),A(`path`,XT)):r(``,!0)])),y(` `+O(e.label),1)],8,JT)]),noResult:S(()=>[y(O(n.$t(`fields.multi_select.nothing_found`)),1)]),noOptions:S(()=>[y(O(n.$t(`fields.belongs_to_many.no_options`)),1)]),_:1},8,[`modelValue`,`id`,`options`,`placeholder`,`disabled`,`class`,`data-multiselect`]))}},QT={class:`map-field`},$T=[`for`],eE={key:0,class:`text-danger`},tE=[`id`,`value`,`placeholder`,`disabled`,`readonly`],nE={class:`grid grid-cols-2 gap-2 mt-2`},rE={class:`block text-xs text-muted mb-1`},iE=[`value`,`placeholder`,`disabled`,`readonly`],aE={class:`block text-xs text-muted mb-1`},oE=[`value`,`placeholder`,`disabled`,`readonly`],sE={class:`mt-2 flex items-center gap-3`},cE=[`href`],lE={key:1,class:`mt-1 text-sm text-warning-soft-fg`},uE={key:2,class:`mt-1 text-sm text-muted`},dE={key:3,class:`mt-1 text-sm text-danger`},fE={__name:`MapField`,props:{modelValue:{type:[String,Number,Object,Array],default:null},name:{type:String,default:``},label:{type:String,default:``},type:{type:String,default:`map`},component:{type:String,default:null},required:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},readonly:{type:Boolean,default:!1},hint:{type:String,default:null},placeholder:{type:String,default:null},default:{type:[String,Number,Object,Array],default:null},attributes:{type:Object,default:()=>({})},tab:{type:String,default:null},tabOrder:{type:Number,default:null},error:{type:String,default:null},mapType:{type:String,default:`yandex`},defaultLat:{type:[Number,String],default:null},defaultLng:{type:[Number,String],default:null},defaultZoom:{type:[Number,String],default:null},searchEnabled:{type:Boolean,default:!1},apiKey:{type:String,default:null}},emits:[`update:modelValue`],setup(t,{emit:n}){let i=t,a=n,o=/^-?\d+(\.\d+)?$/,s=C(``),u=C(``),d=C(``),f,p=!1;function m(e){let t={lat:``,lng:``,raw:``,ok:!1};if(e==null)return t;if(Array.isArray(e))return h(e[0],e[1]);if(typeof e==`object`)return h(e.lat??e.latitude??e[0],e.lng??e.lon??e.longitude??e[1]);let n=String(e).trim().replace(/^"+|"+$/g,``).trim();if(n===``)return t;let r=n.split(`,`),i=(r[0]??``).trim(),a=(r[1]??``).trim(),s=o.test(i),c=o.test(a);return{lat:s?i:``,lng:c?a:``,raw:n,ok:s&&c&&r.length===2}}function h(e,t){let n=e==null?``:String(e).trim(),r=t==null?``:String(t).trim(),i=o.test(n),a=o.test(r);return{lat:i?n:``,lng:a?r:``,raw:n===``&&r===``?``:`${n},${r}`,ok:i&&a}}function g(e){let t=m(e);s.value=t.lat,u.value=t.lng,d.value=t.raw}c(()=>i.modelValue,e=>{p&&e===f||g(e)},{immediate:!0});function _(e){f=e,p=!0,a(`update:modelValue`,e)}function v(){let e=s.value.trim(),t=u.value.trim();e===``&&t===``?(d.value=``,_(null)):(d.value=`${e},${t}`,_(d.value))}function b(e){s.value=e.target.value,v()}function x(e){u.value=e.target.value,v()}function S(e){let t=e.target.value;d.value=t;let n=m(t);s.value=n.lat,u.value=n.lng;let r=t.trim();_(r===``?null:r)}function w(){let e=m(d.value);if(!e.ok)return;let t=`${e.lat},${e.lng}`;t!==d.value&&(d.value=t,_(t))}function T(){s.value=``,u.value=``,d.value=``,_(null)}let ee=E(()=>m(d.value)),te=E(()=>d.value!==``),ne=E(()=>te.value&&!ee.value.ok),re=E(()=>{if(!ee.value.ok)return null;let e=encodeURIComponent(`${ee.value.lat},${ee.value.lng}`);if(i.mapType===`google`)return`https://www.google.com/maps/search/?api=1&query=${e}`;let t=Number(i.defaultZoom);return`https://yandex.ru/maps/?text=${e}${Number.isFinite(t)&&t>0?`&z=${t}`:``}`}),D=E(()=>i.defaultLat===null?`55.7558`:String(i.defaultLat)),ie=E(()=>i.defaultLng===null?`37.6173`:String(i.defaultLng)),ae=E(()=>`${D.value},${ie.value}`);return(n,i)=>(l(),A(`div`,QT,[t.label?(l(),A(`label`,{key:0,for:t.name,class:`block text-sm font-medium text-fg mb-1`},[y(O(t.label)+` `,1),t.required?(l(),A(`span`,eE,`*`)):r(``,!0)],8,$T)):r(``,!0),j(`input`,{id:t.name,type:`text`,"data-map-value":``,value:d.value,placeholder:t.placeholder||ae.value,disabled:t.disabled,readonly:t.readonly,class:e([`w-full border border-field rounded-md px-3 py-2 text-sm focus:outline-none focus:ring-1 focus:ring-focus focus:border-focus`,{"border-danger":t.error}]),onInput:S,onChange:w},null,42,tE),j(`div`,nE,[j(`div`,null,[j(`span`,rE,O(n.$t(`fields.map.latitude`)),1),j(`input`,{type:`number`,"data-map-lat":``,step:`any`,value:s.value,placeholder:D.value,disabled:t.disabled,readonly:t.readonly,class:e([`w-full border border-field rounded-md px-3 py-2 text-sm focus:outline-none focus:ring-1 focus:ring-focus focus:border-focus`,{"border-danger":t.error}]),onInput:b},null,42,iE)]),j(`div`,null,[j(`span`,aE,O(n.$t(`fields.map.longitude`)),1),j(`input`,{type:`number`,"data-map-lng":``,step:`any`,value:u.value,placeholder:ie.value,disabled:t.disabled,readonly:t.readonly,class:e([`w-full border border-field rounded-md px-3 py-2 text-sm focus:outline-none focus:ring-1 focus:ring-focus focus:border-focus`,{"border-danger":t.error}]),onInput:x},null,42,oE)])]),j(`div`,sE,[re.value?(l(),A(`a`,{key:0,href:re.value,target:`_blank`,rel:`noopener noreferrer`,"data-map-link":``,class:`text-sm text-accent hover:text-accent-soft-fg`},O(n.$t(`fields.map.open_on_map`)),9,cE)):r(``,!0),te.value&&!t.disabled&&!t.readonly?(l(),A(`button`,{key:1,type:`button`,"data-map-clear":``,class:`text-sm text-muted hover:text-danger`,onClick:T},O(n.$t(`fields.clear`)),1)):r(``,!0)]),ne.value?(l(),A(`p`,lE,O(n.$t(`fields.map.parse_error`,{example:`55.7558,37.6173`})),1)):r(``,!0),t.hint&&!t.error?(l(),A(`p`,uE,O(t.hint),1)):r(``,!0),t.error?(l(),A(`p`,dE,O(t.error),1)):r(``,!0)]))}},pE=[`data-field`,`data-field-type`,`data-field-tab`,`data-field-required`],mE=[`for`],hE={key:0,class:`text-danger`},gE={key:2,class:`flex items-center`},_E=[`id`,`true-value`,`false-value`,`disabled`,`readonly`],vE=[`for`],yE={key:0,class:`text-danger`},bE=[`id`,`innerHTML`],xE=[`id`,`placeholder`,`required`,`disabled`,`readonly`,`rows`],SE=[`id`,`required`,`disabled`],CE={key:0,value:``},wE=[`value`],TE=[`data-upload-state`],EE={key:0,class:`relative w-24 h-24 rounded-lg overflow-hidden border border-line shrink-0`},DE=[`src`],OE=[`disabled`,`title`],kE=[`id`,`accept`,`disabled`],AE=[`disabled`],jE={key:0,class:`mt-2`},ME={class:`h-1.5 w-full bg-off rounded overflow-hidden`},NE=[`data-upload-progress`],PE={class:`mt-1 text-xs text-muted`},FE={key:1,"data-upload-error":``,class:`mt-1 text-sm text-danger`},IE=[`data-upload-state`],LE={key:0,"data-file-name":``,class:`flex items-center space-x-2 shrink-0`},RE=[`href`,`title`],zE=[`disabled`,`title`],BE=[`id`,`accept`,`disabled`],VE=[`disabled`],HE={key:0,class:`mt-2`},UE={class:`h-1.5 w-full bg-off rounded overflow-hidden`},WE=[`data-upload-progress`],GE={class:`mt-1 text-xs text-muted`},KE={key:1,"data-upload-error":``,class:`mt-1 text-sm text-danger`},qE=[`id`,`type`,`placeholder`,`required`,`disabled`,`readonly`,`min`,`max`,`step`],JE={key:10,class:`mt-1 text-sm text-muted`},YE={key:11,"data-error":``,class:`mt-1 text-sm text-danger`},XE={__name:`AdminFieldRenderer`,props:{field:{type:Object,required:!0},modelValue:{type:[String,Number,Boolean,Array,Object],default:null},error:{type:String,default:null}},emits:[`update:modelValue`],setup(t,{emit:n}){let i=t,a=n,o={wysiwyg:u(mC),color:u(TC),slug:u(RC),treeSelect:u(aw),gallery:u(Sw),repeatable:u(cT),content:u(Vw),belongsToMany:u(xT),map:u(fE)},c=E(()=>i.field.type in o),d=E(()=>c.value&&i.field.type!==`repeatable`),f=E(()=>o[i.field.type]||null),p=E(()=>({text:`text`,email:`email`,password:`password`,number:`number`,date:`date`,datetime:`datetime-local`,url:`url`,tel:`tel`})[i.field.type]||`text`),m=E({get:()=>i.modelValue,set:e=>a(`update:modelValue`,e)}),h=E({get:()=>{let e=m.value;if(i.field.type!==`date`&&i.field.type!==`datetime`||typeof e!=`string`||e===``)return e;let t=e.replace(` `,`T`);return i.field.type===`date`?t.slice(0,10):t.slice(0,16)},set:e=>{m.value=e}}),g=E(()=>i.field.type===`checkbox`),b=E(()=>i.field.type===`display`),S=E(()=>i.field.type===`textarea`),w=E(()=>i.field.type===`select`||i.field.type===`belongsTo`&&!(i.field.searchable&&i.field.searchRoute)),T=E(()=>i.field.type===`image`),ee=E(()=>i.field.type===`file`);function re(e){return typeof e!=`string`||e===``?null:/^(https?:)?\/\//i.test(e)||e.startsWith(`/`)?e:`/storage/`+e}let D=E(()=>re(m.value)),ie=E(()=>re(m.value)),oe=E(()=>{if(typeof m.value!=`string`||m.value===``)return null;let e=m.value.split(`?`)[0].split(`#`)[0],t=e.split(`/`).filter(Boolean).pop()||e;try{return decodeURIComponent(t)}catch{return t}}),ce=C(!1),de=C(0),M=C(null),me=E(()=>ce.value?`uploading`:M.value?`error`:`idle`),he=E(()=>{if(i.field.uploadUrl)return i.field.uploadUrl;try{if(typeof route==`function`)return route(`admin.upload`,void 0,!1)}catch{}return`/admin/upload`});function ge(e){if(e.response&&typeof e.response==`object`)return e.response;if(typeof e.response==`string`&&e.response!==``)try{return JSON.parse(e.response)}catch{return null}return null}function _e(e){if(!e)return null;let t=e.errors?.file;return Array.isArray(t)&&t.length>0?String(t[0]):typeof e.message==`string`&&e.message!==``?e.message:null}function ve(e){return new Promise((t,n)=>{let r=new FormData;r.append(`file`,e);let i=new XMLHttpRequest;i.open(`POST`,he.value,!0),i.responseType=`json`;let a=pe();Object.keys(a).forEach(e=>i.setRequestHeader(e,a[e])),i.upload.onprogress=e=>{e.lengthComputable&&e.total>0&&(de.value=Math.round(e.loaded/e.total*100))},i.onerror=()=>n(Error(N(`fields.upload.network_error`))),i.onabort=()=>n(Error(N(`fields.upload.aborted`))),i.onload=()=>{let e=i.status,r=ge(i);e>=200&&e<300?r&&typeof r.url==`string`&&r.url!==``?t(r):n(Error(N(`fields.upload.no_url`))):n(Error(e===401||e===419?fe():e===413?N(`fields.upload.too_large`):_e(r)||N(`fields.upload.http_error`,{status:e})))},i.send(r)})}function ye(e){if(typeof e?.url==`string`&&/^https?:\/\//i.test(e.url))return e.url;if(e&&typeof e.path==`string`&&e.path!==``)return`/storage/`+e.path.replace(/^\/+/,``);let t=e?.url;if(typeof t!=`string`||t===``)return null;try{let e=new URL(t,window.location.origin);return e.origin===window.location.origin?e.pathname+e.search:t}catch{return t}}async function be(e){let t=e.target,n=t.files&&t.files[0];if(!n)return;M.value=null;let r=Number(i.field.maxSize)||0;if(r>0&&n.size>r*1024)M.value=N(`fields.upload.too_big`,{max:r}),t.value=``;else{ce.value=!0,de.value=0;try{let e=await ve(n);m.value=ye(e)}catch(e){M.value=e?.message||N(`fields.upload.failed`)}finally{ce.value=!1,t.value=``}}}function xe(){m.value=null,M.value=null}let Se=C(!1);function Ce(e){m.value=e?.url||null,M.value=null,Se.value=!1}return(n,i)=>(l(),A(`div`,{class:e([`admin-field`,{"has-error":t.error}]),"data-field":t.field.name,"data-field-type":t.field.type,"data-field-tab":t.field.tab,"data-field-required":t.field.required?`true`:`false`},[!g.value&&!c.value?(l(),A(`label`,{key:0,for:t.field.name,class:`block text-sm font-medium text-fg mb-1`},[y(O(t.field.label)+` `,1),t.field.required?(l(),A(`span`,hE,`*`)):r(``,!0)],8,mE)):r(``,!0),c.value?(l(),v(x(f.value),ae({key:1},t.field,{modelValue:m.value,"onUpdate:modelValue":i[0]||=e=>m.value=e,error:t.error}),null,16,[`modelValue`,`error`])):g.value?(l(),A(`div`,gE,[s(j(`input`,{id:t.field.name,"onUpdate:modelValue":i[1]||=e=>m.value=e,type:`checkbox`,"true-value":t.field.checkedValue??!0,"false-value":t.field.checkedValue?null:!1,disabled:t.field.disabled,readonly:t.field.readonly,class:`h-4 w-4 text-accent focus:ring-focus border-field rounded`},null,8,_E),[[ue,m.value]]),j(`label`,{for:t.field.name,class:`ml-2 text-sm text-fg`},[y(O(t.field.label)+` `,1),t.field.required?(l(),A(`span`,yE,`*`)):r(``,!0)],8,vE)])):b.value?(l(),A(`div`,{key:3,id:t.field.name,class:`admin-display text-sm text-fg`,innerHTML:m.value},null,8,bE)):S.value?s((l(),A(`textarea`,{key:4,id:t.field.name,"onUpdate:modelValue":i[2]||=e=>m.value=e,placeholder:t.field.placeholder,required:t.field.required,disabled:t.field.disabled,readonly:t.field.readonly,rows:t.field.rows||4,class:e([`w-full px-3 py-2 border border-field rounded-md shadow-sm focus:ring-focus focus:border-focus resize-y`,{"border-danger":t.error}])},null,10,xE)),[[se,m.value]]):t.field.type===`multiSelect`?(l(),v(ZT,{key:5,id:t.field.name,modelValue:m.value,"onUpdate:modelValue":i[3]||=e=>m.value=e,options:t.field.options,placeholder:t.field.placeholder||n.$t(`common.select`),disabled:t.field.disabled,error:t.error},null,8,[`id`,`modelValue`,`options`,`placeholder`,`disabled`,`error`])):w.value?s((l(),A(`select`,{key:6,id:t.field.name,"onUpdate:modelValue":i[4]||=e=>m.value=e,required:t.field.required,disabled:t.field.disabled,class:e([`w-full px-3 py-2 border border-field rounded-md shadow-sm focus:ring-focus focus:border-focus bg-surface`,{"border-danger":t.error}])},[t.field.required?r(``,!0):(l(),A(`option`,CE,O(t.field.placeholder||n.$t(`common.select`)),1)),(l(!0),A(k,null,_(t.field.options,e=>(l(),A(`option`,{key:e.value,value:e.value},O(e.label),9,wE))),128))],10,SE)),[[le,m.value]]):T.value?(l(),A(k,{key:7},[j(`div`,{class:`flex items-center space-x-4`,"data-upload-state":me.value},[D.value?(l(),A(`div`,EE,[j(`img`,{src:D.value,class:`w-full h-full object-cover`},null,8,DE),j(`button`,{type:`button`,onClick:xe,disabled:ce.value,"data-action":`remove-upload`,title:n.$t(`common.delete`),class:`absolute top-1 right-1 p-1 bg-danger text-on-danger rounded-full hover:bg-danger-hover disabled:opacity-50`},[...i[9]||=[j(`svg`,{class:`w-3 h-3`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[j(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M6 18L18 6M6 6l12 12`})],-1)]],8,OE)])):r(``,!0),j(`input`,{id:t.field.name,type:`file`,accept:t.field.accept||`image/*`,disabled:t.field.disabled||ce.value,onChange:be,class:`block w-full text-sm text-muted file:mr-4 file:py-2 file:px-4 file:rounded-md file:border-0 file:text-sm file:font-medium file:bg-accent-soft file:text-accent-hover hover:file:bg-accent-soft disabled:opacity-50`},null,40,kE),j(`button`,{type:`button`,onClick:i[5]||=e=>Se.value=!0,disabled:t.field.disabled||ce.value,"data-action":`pick-from-library`,class:`shrink-0 px-3 py-2 text-sm font-medium text-fg bg-surface border border-field rounded-md hover:bg-hover disabled:opacity-50 whitespace-nowrap`},O(n.$t(`fields.upload.from_library`)),9,AE)],8,TE),ce.value?(l(),A(`div`,jE,[j(`div`,ME,[j(`div`,{class:`h-full bg-accent transition-all`,style:ne({width:de.value+`%`}),"data-upload-progress":de.value},null,12,NE)]),j(`p`,PE,O(n.$t(`fields.upload.progress`,{percent:de.value})),1)])):r(``,!0),M.value?(l(),A(`p`,FE,O(M.value),1)):r(``,!0)],64)):ee.value?(l(),A(k,{key:8},[j(`div`,{class:`flex items-center space-x-4`,"data-upload-state":me.value},[oe.value?(l(),A(`div`,LE,[j(`a`,{href:ie.value,target:`_blank`,rel:`noopener`,title:m.value,class:`text-sm text-accent hover:underline break-all`},O(oe.value),9,RE),j(`button`,{type:`button`,onClick:xe,disabled:ce.value,"data-action":`remove-upload`,title:n.$t(`common.delete`),class:`p-1 text-danger hover:text-danger disabled:opacity-50`},[...i[10]||=[j(`svg`,{class:`w-3 h-3`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`},[j(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M6 18L18 6M6 6l12 12`})],-1)]],8,zE)])):r(``,!0),j(`input`,{id:t.field.name,type:`file`,accept:t.field.accept||void 0,disabled:t.field.disabled||ce.value,onChange:be,class:`block w-full text-sm text-muted file:mr-4 file:py-2 file:px-4 file:rounded-md file:border-0 file:text-sm file:font-medium file:bg-accent-soft file:text-accent-hover hover:file:bg-accent-soft disabled:opacity-50`},null,40,BE),j(`button`,{type:`button`,onClick:i[6]||=e=>Se.value=!0,disabled:t.field.disabled||ce.value,"data-action":`pick-from-library`,class:`shrink-0 px-3 py-2 text-sm font-medium text-fg bg-surface border border-field rounded-md hover:bg-hover disabled:opacity-50 whitespace-nowrap`},O(n.$t(`fields.upload.from_library`)),9,VE)],8,IE),ce.value?(l(),A(`div`,HE,[j(`div`,UE,[j(`div`,{class:`h-full bg-accent transition-all`,style:ne({width:de.value+`%`}),"data-upload-progress":de.value},null,12,WE)]),j(`p`,GE,O(n.$t(`fields.upload.progress`,{percent:de.value})),1)])):r(``,!0),M.value?(l(),A(`p`,KE,O(M.value),1)):r(``,!0)],64)):s((l(),A(`input`,{key:9,id:t.field.name,"onUpdate:modelValue":i[7]||=e=>h.value=e,type:p.value,placeholder:t.field.placeholder,required:t.field.required,disabled:t.field.disabled,readonly:t.field.readonly,min:t.field.min,max:t.field.max,step:t.field.step,class:e([`w-full px-3 py-2 border border-field rounded-md shadow-sm focus:ring-focus focus:border-focus`,{"border-danger":t.error}])},null,10,qE)),[[te,h.value]]),t.field.hint&&!t.error&&!d.value?(l(),A(`p`,JE,O(t.field.hint),1)):r(``,!0),t.error&&!d.value?(l(),A(`p`,YE,O(t.error),1)):r(``,!0),T.value||ee.value?(l(),v(oC,{key:12,show:Se.value,type:T.value?`image`:`all`,onSelect:Ce,onClose:i[8]||=e=>Se.value=!1},null,8,[`show`,`type`])):r(``,!0)],10,pE))}},ZE={key:0,class:`mt-1 flex justify-end gap-3 text-xs`,"data-ai":``},QE=[`data-ai-generate`],$E=[`data-ai-translate`],eD={key:0,class:`text-sm text-fg`,"data-ai-working":``},tD={key:1,class:`rounded-md border border-danger bg-danger-soft px-4 py-3 text-sm text-danger-soft-fg`,"data-ai-error":``},nD={key:2,class:`space-y-4`},rD={class:`mb-1 block font-medium text-fg`},iD=[`onUpdate:modelValue`,`data-ai-result`],aD={key:4,class:`mt-2 text-xs text-fg`},oD={__name:`AiAssist`,props:{field:{type:Object,required:!0},locale:{type:String,default:null},translatable:{type:Boolean,default:!1}},emits:[`apply`,`apply-all`],setup(e,{emit:n}){let i=e,c=n,u=ce(),d=E(()=>u.props.ai||null),f=t(`aiModule`,null),p=t(`formData`,C({})),m=E(()=>u.props.contentLocales||[]),h=E(()=>d.value?.labels||{}),g=E(()=>!!(d.value&&f&&i.field.ai&&d.value.tasks.includes(i.field.ai.task))),b=E(()=>!!(g.value&&i.translatable&&m.value.length>1&&d.value.tasks.includes(`translate`))),x=C(!1),w=C(!1),T=C(!1),ee=C(null),te=C(``),ne=C({}),re=C(null),D=null,ie=0,ae=E(()=>((w.value?h.value.translate_title:h.value.dialog_title)||``).replace(`:field`,i.field.label||i.field.name)),oe=E(()=>[h.value.check,re.value?(h.value.by||``).replace(`:provider`,re.value):null].filter(Boolean).join(` `)),le=E(()=>m.value.filter(e=>e.code!==i.locale));function ue(){clearTimeout(D),D=null,ie++}o(ue);async function de(e){ue();let t=ie;w.value=e,x.value=!0,T.value=!0,ee.value=null,te.value=``,ne.value={},re.value=null;try{let n=await fetch(d.value.url,{method:`POST`,credentials:`same-origin`,headers:pe({"Content-Type":`application/json`}),body:JSON.stringify({module:f,field:i.field.name,values:p.value,locale:i.locale,translate:e})});if(!n.ok){let e=n.status===422?await n.clone().json().catch(()=>({})):{};throw Error(e.errors?.field?.[0]||await me(n,h.value.error))}M(await n.json(),t)}catch(e){t===ie&&fe(e.message)}}function M(e,t){t===ie&&(e.status===`done`?(T.value=!1,re.value=e.provider||null,te.value=e.value??``,ne.value={...e.values||{}}):e.status===`failed`?fe(e.message):D=setTimeout(()=>N(e.id,t),1500))}async function N(e,t){try{let n=await fetch(`${d.value.url}/${e}`,{credentials:`same-origin`,headers:pe()});if(!n.ok)throw Error(await me(n,h.value.error));M(await n.json(),t)}catch(e){t===ie&&fe(e.message)}}function fe(e){T.value=!1,ee.value=e||h.value.error}function _e(){ue(),x.value=!1}function ve(){w.value?c(`apply-all`,Object.fromEntries(Object.entries(ne.value).filter(([,e])=>String(e??``).trim()!==``))):c(`apply`,te.value),_e()}return(t,n)=>g.value?(l(),A(`div`,ZE,[j(`button`,{type:`button`,class:`inline-flex items-center gap-1 text-accent hover:text-accent-hover disabled:text-muted disabled:cursor-not-allowed`,"data-ai-generate":e.field.name,onClick:n[0]||=e=>de(!1)},[n[4]||=j(`svg`,{class:`h-3.5 w-3.5`,viewBox:`0 0 20 20`,fill:`currentColor`,"aria-hidden":`true`},[j(`path`,{d:`M10 1l1.8 5.2L17 8l-5.2 1.8L10 15l-1.8-5.2L3 8l5.2-1.8L10 1zm6 11l.9 2.1L19 15l-2.1.9L16 18l-.9-2.1L13 15l2.1-.9L16 12z`})],-1),y(` `+O(h.value.generate),1)],8,QE),b.value?(l(),A(`button`,{key:0,type:`button`,class:`text-accent hover:text-accent-hover disabled:text-muted disabled:cursor-not-allowed`,"data-ai-translate":e.field.name,onClick:n[1]||=e=>de(!0)},O(h.value.translate),9,$E)):r(``,!0),a(he,{show:x.value,title:ae.value,"max-width":`2xl`,onClose:_e},{footer:S(()=>[a(ge,{variant:`outline`,onClick:_e},{default:S(()=>[y(O(h.value.cancel),1)]),_:1}),ee.value?(l(),v(ge,{key:0,variant:`secondary`,onClick:n[3]||=e=>de(w.value)},{default:S(()=>[y(O(h.value.retry),1)]),_:1})):(l(),v(ge,{key:1,disabled:T.value,"data-ai-accept":``,onClick:ve},{default:S(()=>[y(O(h.value.accept),1)]),_:1},8,[`disabled`]))]),default:S(()=>[T.value?(l(),A(`p`,eD,O(h.value.working),1)):ee.value?(l(),A(`div`,tD,O(ee.value),1)):w.value?(l(),A(`div`,nD,[(l(!0),A(k,null,_(le.value,e=>(l(),A(`label`,{key:e.code,class:`block text-sm`},[j(`span`,rD,O(e.name),1),s(j(`textarea`,{"onUpdate:modelValue":t=>ne.value[e.code]=t,rows:`4`,class:`w-full rounded-md border border-field bg-surface px-3 py-2 text-sm text-fg focus:border-focus focus:outline-none focus:ring-1 focus:ring-focus`,"data-ai-result":e.code},null,8,iD),[[se,ne.value[e.code]]])]))),128))])):s((l(),A(`textarea`,{key:3,"onUpdate:modelValue":n[2]||=e=>te.value=e,rows:`8`,class:`w-full rounded-md border border-field bg-surface px-3 py-2 text-sm text-fg focus:border-focus focus:outline-none focus:ring-1 focus:ring-focus`,"data-ai-result":``},null,512)),[[se,te.value]]),!T.value&&!ee.value?(l(),A(`p`,aD,O(oe.value),1)):r(``,!0)]),_:1},8,[`show`,`title`])])):r(``,!0)}},sD={__name:`FormField`,props:{field:{type:Object,required:!0},modelValue:{type:[String,Number,Boolean,Array,Object],default:null},errors:{type:Object,default:()=>({})}},emits:[`update:modelValue`],setup(e,{emit:n}){let i=e,a=n,o=t(`contentLocale`,C(null)),s=E(()=>ce().props.contentLocales||[]),c=E(()=>s.value.find(e=>e.code===o.value)),u=E(()=>!!(i.field.translatable&&c.value)),d=E(()=>{if(!u.value)return i.field;let e={...i.field};return s.value.length>1&&(e.label=`${e.label} (${c.value.name})`),c.value.default||(e.required=!1),e}),f=E(()=>u.value?i.modelValue?.[o.value]??``:i.modelValue),p=E(()=>u.value?i.errors[`${i.field.name}.${o.value}`]??i.errors[i.field.name]:i.errors[i.field.name]);function m(e){a(`update:modelValue`,u.value?{...i.modelValue||{},[o.value]:e}:e)}function h(e){a(`update:modelValue`,{...i.modelValue||{},...e})}return(t,n)=>(l(),A(k,null,[(l(),v(XE,{key:u.value?g(o):`value`,field:d.value,"model-value":f.value,error:p.value,"data-content-locale-field":u.value?g(o):null,"onUpdate:modelValue":m},null,8,[`field`,`model-value`,`error`,`data-content-locale-field`])),e.field.ai?(l(),v(oD,{key:0,field:d.value,locale:u.value?g(o):null,translatable:u.value,onApply:m,onApplyAll:h},null,8,[`field`,`locale`,`translatable`])):r(``,!0)],64))}};export{sD as t}; \ No newline at end of file diff --git a/packages/admin/dist/assets/Index-1mD_GBWn.js b/packages/admin/dist/assets/Index-1mD_GBWn.js deleted file mode 100644 index 6539e871..00000000 --- a/packages/admin/dist/assets/Index-1mD_GBWn.js +++ /dev/null @@ -1 +0,0 @@ -import{C as e,E as t,I as n,Q as r,R as i,S as a,T as o,W as s,Z as ee,et as c,n as l,s as u,v as d,w as f,x as p}from"./dist-MY__znoP.js";import{t as te}from"./AdminLayout--RXJFj9t.js";import{t as m}from"./AdminButton-Bx141Bs3.js";var h={class:`mb-6`},g={"data-page-title":`admin.modules`,class:`text-2xl font-bold text-fg`},_={class:`mt-1 text-sm text-muted`},v={class:`bg-surface rounded-lg shadow overflow-hidden`},y={key:0,class:`p-6 text-sm text-muted`},b={key:1,class:`min-w-full text-sm`},x={class:`bg-surface-alt`},S={class:`px-4 py-2 text-left font-medium text-fg`},C={class:`px-4 py-2 text-left font-medium text-fg`},w={class:`divide-y divide-line`},T=[`data-module`,`data-parent`,`data-enabled`],E={key:0,"aria-hidden":`true`,class:`mr-1 text-muted`},D={key:1,class:`ml-2 rounded bg-surface-alt px-1.5 py-0.5 text-xs font-normal text-muted`},O={key:0,class:`text-muted`},k={class:`px-4 py-2 font-mono text-xs text-muted`},A={class:`px-4 py-2 text-right whitespace-nowrap space-x-2`},j={key:0,"data-section":`required`,class:`mt-8`},M={class:`text-lg font-semibold text-fg`},N={class:`mt-1 text-sm text-muted`},P={class:`mt-3 bg-surface rounded-lg shadow divide-y divide-line text-sm`},ne=[`data-required`],F={class:`font-medium text-fg`},I={key:0,class:`text-muted`},L={class:`mt-1 block font-mono text-xs text-fg select-all`},R={key:1,"data-section":`catalogue`,class:`mt-8`},z={class:`text-lg font-semibold text-fg`},B={class:`mt-1 text-sm text-muted`},V={class:`mt-3 text-sm text-muted`},H={key:0,"data-catalogue":`unavailable`,class:`mt-3 text-sm text-muted`},U={key:1,class:`mt-3 text-sm text-muted`},W={key:2,class:`mt-3 bg-surface rounded-lg shadow divide-y divide-line text-sm`},G=[`data-package`,`data-status`],K={class:`flex flex-wrap items-baseline gap-x-3`},q=[`href`],J={key:0,class:`rounded bg-surface-alt px-1.5 py-0.5 text-xs text-muted`},Y={class:`text-xs text-muted`},X={key:0,class:`text-muted`},Z={key:0,class:`mt-1 block font-mono text-xs text-fg select-all`},re={class:`mt-1 block font-mono text-xs text-fg select-all`},Q={__name:`Index`,props:{modules:Array,required:Array,canManage:Boolean,catalogue:Object,title:String},setup(Q){let ie=e=>{u.post(route(e.enabled?`admin.modules.disable`:`admin.modules.enable`,e.key),{},{preserveScroll:!0})},$=e=>`php artisan atrium:module:install ${e}`;return(u,ae)=>(n(),a(te,{title:Q.title},{default:s(()=>[p(`div`,h,[p(`h1`,g,c(Q.title),1),p(`p`,_,c(u.$t(`modules.index_hint`)),1)]),p(`div`,v,[Q.modules.length===0?(n(),f(`p`,y,c(u.$t(`modules.empty`)),1)):(n(),f(`table`,b,[p(`thead`,x,[p(`tr`,null,[p(`th`,S,c(u.$t(`modules.module`)),1),p(`th`,C,c(u.$t(`modules.package`)),1),ae[0]||=p(`th`,{class:`px-4 py-2`},null,-1)])]),p(`tbody`,w,[(n(!0),f(d,null,i(Q.modules,t=>(n(),f(`tr`,{key:t.name,"data-module":t.name,"data-parent":t.parent,"data-enabled":t.enabled?`true`:`false`},[p(`td`,{class:r([`py-2 pr-4`,t.parent?`pl-10`:`pl-4`])},[p(`div`,{class:r([`font-medium`,t.enabled?`text-fg`:`text-muted`])},[t.parent?(n(),f(`span`,E,`↳`)):e(``,!0),o(c(t.label)+` `,1),t.enabled?e(``,!0):(n(),f(`span`,D,c(u.$t(`modules.status_disabled`)),1))],2),t.description?(n(),f(`div`,O,c(t.description),1)):e(``,!0)],2),p(`td`,k,c(t.name),1),p(`td`,A,[t.settings?(n(),a(m,{key:0,size:`sm`,variant:`outline`,"data-action":`settings`,href:u.route(`admin.modules.settings`,t.key)},{default:s(()=>[o(c(u.$t(`modules.settings`)),1)]),_:1},8,[`href`])):e(``,!0),Q.canManage?(n(),a(m,{key:1,size:`sm`,variant:t.enabled?`secondary`:`success`,"data-action":t.enabled?`disable`:`enable`,onClick:e=>ie(t)},{default:s(()=>[o(c(t.enabled?u.$t(`modules.disable`):u.$t(`modules.enable`)),1)]),_:2},1032,[`variant`,`data-action`,`onClick`])):e(``,!0)])],8,T))),128))])]))]),Q.canManage&&Q.required.length?(n(),f(`section`,j,[p(`h2`,M,c(u.$t(`modules.required_title`)),1),p(`p`,N,c(u.$t(`modules.required_hint`)),1),p(`ul`,P,[(n(!0),f(d,null,i(Q.required,t=>(n(),f(`li`,{key:t.name,"data-required":t.name,class:`px-4 py-3`},[p(`div`,F,c(t.label),1),t.description?(n(),f(`div`,I,c(t.description),1)):e(``,!0),p(`code`,L,c($(t.name)),1)],8,ne))),128))])])):e(``,!0),Q.canManage?(n(),f(`section`,R,[p(`h2`,z,c(u.$t(`modules.catalogue_title`)),1),p(`p`,B,c(u.$t(`modules.catalogue_hint`)),1),t(ee(l),{data:`catalogue`},{fallback:s(()=>[p(`p`,V,c(u.$t(`modules.catalogue_loading`)),1)]),default:s(()=>[Q.catalogue.packages===null?(n(),f(`p`,H,c(u.$t(`modules.catalogue_unavailable`)),1)):Q.catalogue.packages.length===0?(n(),f(`p`,U,c(u.$t(`modules.catalogue_empty`)),1)):(n(),f(`ul`,W,[(n(!0),f(d,null,i(Q.catalogue.packages,t=>(n(),f(`li`,{key:t.name,"data-package":t.name,"data-status":t.status,class:`px-4 py-3`},[p(`div`,K,[p(`a`,{href:t.url,target:`_blank`,rel:`noopener`,class:`font-mono text-sm font-medium text-fg hover:underline`},c(t.name),9,q),t.status===`available`?e(``,!0):(n(),f(`span`,J,c(u.$t(`modules.status_${t.status}`)),1)),p(`span`,Y,c(u.$t(`modules.downloads`,{count:t.downloads})),1)]),t.description?(n(),f(`div`,X,c(t.description),1)):e(``,!0),t.status===`available`||t.status===`required`?(n(),f(d,{key:1},[t.status===`available`?(n(),f(`code`,Z,`composer require `+c(t.name),1)):e(``,!0),p(`code`,re,c($(t.name)),1)],64)):e(``,!0)],8,G))),128))]))]),_:1})])):e(``,!0)]),_:1},8,[`title`]))}};export{Q as default}; \ No newline at end of file diff --git a/packages/admin/dist/assets/Index-9-V30Hlc.js b/packages/admin/dist/assets/Index-9-V30Hlc.js deleted file mode 100644 index 65fcb8cf..00000000 --- a/packages/admin/dist/assets/Index-9-V30Hlc.js +++ /dev/null @@ -1 +0,0 @@ -import{C as e,E as t,G as n,H as r,I as i,N as a,Q as o,R as s,S as ee,T as c,W as l,Y as u,b as d,et as f,m as p,o as te,s as m,u as h,v as g,w as _,x as v}from"./dist-MY__znoP.js";import{n as y,r as ne,t as re}from"./AdminLayout--RXJFj9t.js";import{t as b}from"./AdminButton-Bx141Bs3.js";import{t as x}from"./AdminCard--HubMtUj.js";import{t as S}from"./AdminModal-DNJ_V4iq.js";var ie={class:`mb-6 flex flex-wrap items-start justify-between gap-4`},ae={class:`text-2xl font-bold text-fg`},oe={class:`mt-1 text-sm text-muted`},se={class:`flex flex-wrap gap-2`},ce={key:0,dusk:`backup-running`,role:`status`,class:`mb-6 flex items-center gap-3 p-4 bg-accent-soft text-accent-soft-fg border border-line rounded-lg text-sm`},le={class:`space-y-6`},ue={key:0,class:`p-6 text-sm text-muted`},de={key:1,class:`overflow-x-auto`},fe={dusk:`backups`,class:`min-w-full text-sm`},pe={class:`bg-surface-alt`},me={class:`px-4 py-2 text-left font-medium text-fg`},he={class:`px-4 py-2 text-left font-medium text-fg`},ge={class:`px-4 py-2 text-left font-medium text-fg`},_e={class:`px-4 py-2 text-right font-medium text-fg`},ve={class:`divide-y divide-line`},ye=[`data-backup`],be={class:`px-4 py-2 font-mono text-fg`},xe={class:`px-4 py-2 text-fg`},C={class:`px-4 py-2 text-fg`},w={class:`px-4 py-2 text-right text-fg whitespace-nowrap`},T={class:`px-4 py-2 text-right whitespace-nowrap space-x-2`},E=[`href`],D=[`disabled`,`onClick`],O=[`onClick`],k={class:`grid gap-6 lg:grid-cols-2`},A={class:`space-y-4`},j=[`data-destination`,`dusk`],M={class:`flex flex-wrap items-center gap-2`},Se={class:`font-medium text-fg`},Ce={key:0,class:`mt-1 text-sm text-fg`},we={key:1,class:`mt-1 list-disc pl-5 text-sm text-danger`},Te={class:`grid grid-cols-1 sm:grid-cols-3 gap-x-4 gap-y-3 text-sm`},Ee={class:`font-medium text-fg`},De={class:`sm:col-span-2 text-fg`},Oe={class:`font-medium text-fg`},ke={class:`sm:col-span-2 text-fg break-all`},Ae={class:`font-medium text-fg`},je={class:`sm:col-span-2 text-fg`},Me={class:`font-medium text-fg`},Ne={class:`sm:col-span-2 text-fg`},Pe={key:0},Fe={class:`font-medium text-fg`},Ie={class:`sm:col-span-2 text-fg`},Le={class:`font-medium text-fg`},Re={class:`sm:col-span-2 text-fg`},ze={key:0,class:`p-6 text-sm text-muted`},Be={key:1,class:`overflow-x-auto`},Ve={dusk:`backup-log`,class:`min-w-full text-sm`},He={class:`bg-surface-alt`},Ue={class:`px-4 py-2 text-left font-medium text-fg`},We={class:`px-4 py-2 text-left font-medium text-fg`},Ge={class:`px-4 py-2 text-left font-medium text-fg`},Ke={class:`px-4 py-2 text-left font-medium text-fg`},qe={class:`divide-y divide-line`},Je={class:`px-4 py-2 text-fg whitespace-nowrap`},Ye={class:`px-4 py-2 text-fg`},Xe={class:`px-4 py-2`},Ze={class:`px-4 py-2 text-fg break-words`},Qe={class:`p-6`},$e={class:`text-fg`},et={class:`mt-6 flex justify-end gap-2`},tt={key:0,dusk:`restore-dialog`,class:`p-6 space-y-5 text-sm`},nt={class:`text-fg`},rt={class:`flex flex-wrap items-end gap-3`},it={class:`flex-1 min-w-48`},at={for:`backup-password`,class:`block font-medium text-fg`},ot={class:`mt-1 text-xs text-muted`},st={key:0,"data-error":``,class:`text-danger`,role:`alert`},ct={key:0,class:`text-fg`},lt={key:1,class:`overflow-x-auto border border-line rounded-md`},ut={dusk:`plan-databases`,class:`min-w-full`},dt={class:`bg-surface-alt`},ft={class:`px-3 py-2 text-left font-medium text-fg`},pt={class:`px-3 py-2 text-left font-medium text-fg`},mt={class:`px-3 py-2 text-right font-medium text-fg`},ht={class:`px-3 py-2 text-left font-medium text-fg`},gt={class:`divide-y divide-line`},_t={class:`px-3 py-1.5 text-fg`},vt={class:`px-3 py-1.5 text-fg`},yt={class:`px-3 py-1.5 text-right text-fg`},bt={class:`px-3 py-1.5 text-fg break-all`},xt={key:2,class:`overflow-x-auto border border-line rounded-md`},St={dusk:`plan-folders`,class:`min-w-full`},Ct={class:`bg-surface-alt`},N={class:`px-3 py-2 text-left font-medium text-fg`},wt={class:`px-3 py-2 text-right font-medium text-fg`},Tt={class:`px-3 py-2 text-right font-medium text-fg`},Et={class:`px-3 py-2 text-right font-medium text-fg`},Dt={class:`px-3 py-2 text-right font-medium text-fg`},Ot={class:`px-3 py-2 text-right font-medium text-fg`},kt={class:`divide-y divide-line`},At={class:`px-3 py-1.5 text-fg break-all`},jt={class:`px-3 py-1.5 text-right text-fg`},Mt={class:`px-3 py-1.5 text-right text-fg`},Nt={class:`px-3 py-1.5 text-right text-fg`},Pt={class:`px-3 py-1.5 text-right text-fg`},Ft={class:`px-3 py-1.5 text-right text-fg`},It={key:3,class:`list-disc pl-5 bg-warning-soft text-warning-soft-fg border border-line rounded-md p-3 space-y-1`},Lt={class:`space-y-2`},Rt={class:`flex items-center gap-2 text-fg`},zt={class:`flex items-center gap-2 text-fg`},Bt={class:`flex items-center gap-2 text-fg ml-6`},Vt=[`disabled`],Ht={class:`flex items-center gap-2 text-fg`},Ut={class:`p-4 bg-surface text-fg border-2 border-danger rounded-lg`},Wt={class:`font-medium`},Gt={class:`mt-2 list-disc pl-5 space-y-1`},Kt={key:0},qt={key:1},Jt={key:2},Yt={for:`backup-confirm`,class:`block font-medium text-fg`},Xt={key:0,"data-error":``,class:`mt-1 text-danger`},Zt={class:`flex justify-end gap-2`},P={__name:`Index`,props:{backups:Array,running:Object,log:Array,health:Array,settings:Object,labels:Object},setup(P){let F=P,Qt=te(),I=d(()=>String(Qt.props.locale||`en`).replace(`_`,`-`));function L(e,t={}){let n=F.labels?.[e]??e;for(let[e,r]of Object.entries(t))n=n.replaceAll(`:${e}`,String(r??``));return n}function R(e){let t=[`B`,`KB`,`MB`,`GB`,`TB`],n=Number(e)||0,r=0;for(;n>=1024&&r1)})} ${t[r]}`}function z(e){return e?new Date(e).toLocaleString(I.value,{dateStyle:`medium`,timeStyle:`short`}):``}let B=u({backups:F.backups,running:F.running,log:F.log}),V=null;r(()=>[F.backups,F.running,F.log],()=>{B.value={backups:F.backups,running:F.running,log:F.log}});async function H(){let e=await fetch(route(`admin.backups.status`),{headers:y()}).catch(()=>null);if(e?.ok){let t=await e.json(),n=B.value.running&&!t.running;B.value=t,n&&m.reload({only:[`health`,`backups`,`running`,`log`]})}}r(()=>B.value.running,e=>{clearInterval(V),V=e?setInterval(H,3e3):null},{immediate:!0}),a(()=>clearInterval(V));let U=u(!1);function W(e=null){U.value=!0,m.post(route(`admin.backups.store`),{only:e},{preserveScroll:!0,onSuccess:()=>H(),onFinish:()=>{U.value=!1}})}let G=u(null);function $t(){m.delete(route(`admin.backups.destroy`,G.value.id),{preserveScroll:!0,onFinish:()=>{G.value=null}})}let K=u(null),q=u(null),J=u(``),Y=u(!1),X=u({}),Z=u({}),Q=u(!1);function en(e){K.value=e,q.value=null,J.value=``,Z.value={},X.value={password:``,database:!0,files:!0,delete_extra:!1,safety_backup:!0,confirm:``}}async function tn(){Y.value=!0,J.value=``;try{let e=await fetch(route(`admin.backups.plan`,K.value.id),{method:`POST`,headers:y({"Content-Type":`application/json`}),body:JSON.stringify({password:X.value.password||null})});if(!e.ok){J.value=await ne(e,L(`preview_failed`)),q.value=null;return}q.value=(await e.json()).plan}catch{J.value=L(`preview_failed`)}finally{Y.value=!1}}let nn=d(()=>q.value&&(X.value.database||X.value.files)&&X.value.confirm.trim()===K.value?.file);function rn(){Q.value=!0,m.post(route(`admin.backups.restore`,K.value.id),{...X.value,confirm:X.value.confirm.trim(),password:X.value.password||null},{preserveScroll:!0,onSuccess:()=>{K.value=null,H()},onError:e=>{Z.value=e},onFinish:()=>{Q.value=!1}})}let an=d(()=>{let e=F.settings?.schedule||{};return e.frequency===`daily`?L(`schedule_daily`,{time:e.time}):e.frequency===`weekly`?L(`schedule_weekly`,{weekday:F.settings.weekday,time:e.time}):L(`schedule_off`)}),on=d(()=>{let e=F.settings?.retention||{};return L(`retention_text`,{all:e.keep_all_days,daily:e.daily,weekly:e.weekly,monthly:e.monthly,yearly:e.yearly})}),$={ok:`bg-success-soft text-success-soft-fg`,partial:`bg-warning-soft text-warning-soft-fg`,failed:`bg-danger-soft text-danger-soft-fg`};function sn(e){let t=[];return e.trigger&&t.push(L(`trigger_${e.trigger}`)),e.by&&t.push(e.by),e.file&&t.push(e.disk?`${e.file} (${e.disk})`:e.file),e.disks?.length&&t.push(L(`copied_to`,{disks:e.disks.join(`, `)})),e.failed?.length&&t.push(L(`not_copied_to`,{disks:e.failed.map(e=>e.disk??e).join(`, `)})),e.action===`restore`&&e.status===`ok`&&t.push(L(`restored`,{databases:(e.databases||[]).join(`, `)||`—`,files:e.files??0,deleted:e.deleted??0})),e.seconds!==void 0&&t.push(L(`seconds`,{seconds:e.seconds})),e.message&&t.push(e.message),t.join(` · `)}return(r,a)=>(i(),ee(re,{title:L(`menu`)},{default:l(()=>[v(`div`,ie,[v(`div`,null,[v(`h1`,ae,f(P.labels.menu),1),v(`p`,oe,f(L(`subtitle`)),1)]),v(`div`,se,[t(b,{dusk:`backup-now`,loading:U.value,disabled:!!B.value.running,onClick:a[0]||=e=>W()},{default:l(()=>[c(f(L(`back_up_now`)),1)]),_:1},8,[`loading`,`disabled`]),t(b,{variant:`secondary`,disabled:U.value||!!B.value.running,onClick:a[1]||=e=>W(`database`)},{default:l(()=>[c(f(L(`only_database`)),1)]),_:1},8,[`disabled`]),t(b,{variant:`secondary`,disabled:U.value||!!B.value.running,onClick:a[2]||=e=>W(`files`)},{default:l(()=>[c(f(L(`only_files`)),1)]),_:1},8,[`disabled`])])]),B.value.running?(i(),_(`div`,ce,[a[13]||=v(`svg`,{class:`animate-spin h-5 w-5`,fill:`none`,viewBox:`0 0 24 24`,"aria-hidden":`true`},[v(`circle`,{class:`opacity-25`,cx:`12`,cy:`12`,r:`10`,stroke:`currentColor`,"stroke-width":`4`}),v(`path`,{class:`opacity-75`,fill:`currentColor`,d:`M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z`})],-1),c(` `+f(L(B.value.running.action===`restore`?`running_restore`:`running_backup`,{time:z(B.value.running.started_at)})),1)])):e(``,!0),v(`div`,le,[t(x,{title:L(`archives`),"no-padding":``},{default:l(()=>[B.value.backups.length?(i(),_(`div`,de,[v(`table`,fe,[v(`thead`,pe,[v(`tr`,null,[v(`th`,me,f(L(`file`)),1),v(`th`,he,f(L(`destination`)),1),v(`th`,ge,f(L(`date`)),1),v(`th`,_e,f(L(`size`)),1),a[14]||=v(`th`,{class:`px-4 py-2`},null,-1)])]),v(`tbody`,ve,[(i(!0),_(g,null,s(B.value.backups,e=>(i(),_(`tr`,{key:e.id,"data-backup":e.file,dusk:`backup`},[v(`td`,be,f(e.file),1),v(`td`,xe,f(e.disk),1),v(`td`,C,f(z(e.date)),1),v(`td`,w,f(R(e.size)),1),v(`td`,T,[v(`a`,{href:e.download_url,class:`text-accent underline`},f(L(`download`)),9,E),v(`button`,{type:`button`,dusk:`restore`,class:`text-accent underline`,disabled:!!B.value.running,onClick:t=>en(e)},f(L(`restore`)),9,D),v(`button`,{type:`button`,dusk:`delete`,class:`text-danger underline`,onClick:t=>G.value=e},f(L(`delete`)),9,O)])],8,ye))),128))])])])):(i(),_(`p`,ue,f(L(`empty`)),1))]),_:1},8,[`title`]),v(`div`,k,[t(x,{title:L(`destinations`)},{default:l(()=>[v(`ul`,A,[(i(!0),_(g,null,s(P.health,t=>(i(),_(`li`,{key:t.disk,"data-destination":t.disk,dusk:`destination-${t.disk}`},[v(`div`,M,[v(`span`,Se,f(t.disk),1),v(`span`,{class:o([`px-2 py-0.5 rounded text-xs font-medium`,!t.reachable||!t.healthy?$.failed:$.ok])},f(t.reachable?t.healthy?L(`healthy`):L(`unhealthy`):L(`unreachable`)),3)]),t.reachable?(i(),_(`p`,Ce,f(L(`stored`,{count:t.count,size:R(t.used)}))+` · `+f(t.newest?L(`newest`,{date:z(t.newest)}):L(`no_archive`)),1)):e(``,!0),t.problems.length?(i(),_(`ul`,we,[(i(!0),_(g,null,s(t.problems,e=>(i(),_(`li`,{key:e},f(e),1))),128))])):e(``,!0)],8,j))),128))])]),_:1},8,[`title`]),t(x,{title:L(`settings`),subtitle:L(`settings_note`)},{default:l(()=>[v(`dl`,Te,[v(`dt`,Ee,f(L(`databases`)),1),v(`dd`,De,f(P.settings.databases.map(e=>`${e.connection} (${e.driver})`).join(`, `)||L(`nothing`)),1),v(`dt`,Oe,f(L(`folders`)),1),v(`dd`,ke,f(P.settings.folders.join(`, `)||L(`nothing`)),1),v(`dt`,Ae,f(L(`destinations`)),1),v(`dd`,je,f(P.settings.destinations.join(`, `)),1),v(`dt`,Me,f(L(`schedule`)),1),v(`dd`,Ne,[c(f(an.value),1),P.settings.queue?(i(),_(`span`,Pe,`. `+f(L(`queue`,{queue:P.settings.queue})),1)):e(``,!0)]),v(`dt`,Fe,f(L(`retention`)),1),v(`dd`,Ie,f(on.value),1),v(`dt`,Le,f(L(`encryption`)),1),v(`dd`,Re,f(P.settings.encrypted?L(`encrypted`):L(`not_encrypted`)),1)])]),_:1},8,[`title`,`subtitle`])]),t(x,{title:L(`log`),"no-padding":``},{default:l(()=>[B.value.log.length?(i(),_(`div`,Be,[v(`table`,Ve,[v(`thead`,He,[v(`tr`,null,[v(`th`,Ue,f(L(`when`)),1),v(`th`,We,f(L(`what`)),1),v(`th`,Ge,f(L(`result`)),1),v(`th`,Ke,f(L(`details`)),1)])]),v(`tbody`,qe,[(i(!0),_(g,null,s(B.value.log,(e,t)=>(i(),_(`tr`,{key:t},[v(`td`,Je,f(z(e.at)),1),v(`td`,Ye,f(L(`action_${e.action}`)),1),v(`td`,Xe,[v(`span`,{class:o([`px-2 py-0.5 rounded text-xs font-medium`,$[e.status]||$.failed])},f(L(`status_${e.status}`)),3)]),v(`td`,Ze,f(sn(e)),1)]))),128))])])])):(i(),_(`p`,ze,f(L(`log_empty`)),1))]),_:1},8,[`title`])]),t(S,{show:!!G.value,title:L(`delete`),onClose:a[4]||=e=>G.value=null},{default:l(()=>[v(`div`,Qe,[v(`p`,$e,f(G.value?L(`delete_confirm`,{file:G.value.file,disk:G.value.disk}):``),1),v(`div`,et,[t(b,{variant:`secondary`,onClick:a[3]||=e=>G.value=null},{default:l(()=>[c(f(L(`cancel`)),1)]),_:1}),t(b,{dusk:`confirm-delete`,variant:`danger`,onClick:$t},{default:l(()=>[c(f(L(`delete`)),1)]),_:1})])])]),_:1},8,[`show`,`title`]),t(S,{show:!!K.value,"max-width":`2xl`,title:K.value?L(`restore_title`,{file:K.value.file}):``,onClose:a[12]||=e=>K.value=null},{default:l(()=>[K.value?(i(),_(`div`,tt,[v(`p`,nt,f(L(`restore_intro`)),1),v(`div`,rt,[v(`div`,it,[v(`label`,at,f(L(`password`)),1),n(v(`input`,{id:`backup-password`,"onUpdate:modelValue":a[5]||=e=>X.value.password=e,type:`password`,autocomplete:`off`,class:`mt-1 block w-full px-3 py-2 border border-field rounded-md shadow-sm focus:outline-none focus:ring-focus focus:border-focus`},null,512),[[p,X.value.password]]),v(`p`,ot,f(L(`password_hint`)),1)]),t(b,{dusk:`preview`,variant:`secondary`,loading:Y.value,onClick:tn},{default:l(()=>[c(f(L(`preview`)),1)]),_:1},8,[`loading`])]),J.value?(i(),_(`p`,st,f(J.value),1)):e(``,!0),q.value?(i(),_(g,{key:1},[q.value.created_at?(i(),_(`p`,ct,f(L(`made`,{date:z(q.value.created_at)})),1)):e(``,!0),q.value.databases.length?(i(),_(`div`,lt,[v(`table`,ut,[v(`thead`,dt,[v(`tr`,null,[v(`th`,ft,f(L(`connection`)),1),v(`th`,pt,f(L(`driver`)),1),v(`th`,mt,f(L(`dump`)),1),v(`th`,ht,f(L(`replaces`)),1)])]),v(`tbody`,gt,[(i(!0),_(g,null,s(q.value.databases,e=>(i(),_(`tr`,{key:e.connection},[v(`td`,_t,f(e.connection),1),v(`td`,vt,f(e.driver),1),v(`td`,yt,f(R(e.size)),1),v(`td`,bt,f(e.restorable?e.target:L(`skipped`)),1)]))),128))])])])):e(``,!0),q.value.folders.length?(i(),_(`div`,xt,[v(`table`,St,[v(`thead`,Ct,[v(`tr`,null,[v(`th`,N,f(L(`into`)),1),v(`th`,wt,f(L(`files`)),1),v(`th`,Tt,f(L(`new`)),1),v(`th`,Et,f(L(`changed`)),1),v(`th`,Dt,f(L(`unchanged`)),1),v(`th`,Ot,f(L(`extra`)),1)])]),v(`tbody`,kt,[(i(!0),_(g,null,s(q.value.folders,e=>(i(),_(`tr`,{key:e.prefix},[v(`td`,At,f(e.target),1),v(`td`,jt,f(e.files),1),v(`td`,Mt,f(e.new),1),v(`td`,Nt,f(e.changed),1),v(`td`,Pt,f(e.unchanged),1),v(`td`,Ft,f(e.extra),1)]))),128))])])])):e(``,!0),q.value.warnings.length?(i(),_(`ul`,It,[(i(!0),_(g,null,s(q.value.warnings,e=>(i(),_(`li`,{key:e,class:`ml-3`},f(e),1))),128))])):e(``,!0),v(`fieldset`,Lt,[v(`label`,Rt,[n(v(`input`,{"onUpdate:modelValue":a[6]||=e=>X.value.database=e,type:`checkbox`,class:`h-4 w-4 text-accent border-field rounded focus:ring-focus`},null,512),[[h,X.value.database]]),c(` `+f(L(`restore_database`)),1)]),v(`label`,zt,[n(v(`input`,{"onUpdate:modelValue":a[7]||=e=>X.value.files=e,type:`checkbox`,class:`h-4 w-4 text-accent border-field rounded focus:ring-focus`},null,512),[[h,X.value.files]]),c(` `+f(L(`restore_files`)),1)]),v(`label`,Bt,[n(v(`input`,{"onUpdate:modelValue":a[8]||=e=>X.value.delete_extra=e,type:`checkbox`,class:`h-4 w-4 text-accent border-field rounded focus:ring-focus`,disabled:!X.value.files},null,8,Vt),[[h,X.value.delete_extra]]),c(` `+f(L(`delete_extra`)),1)]),v(`label`,Ht,[n(v(`input`,{"onUpdate:modelValue":a[9]||=e=>X.value.safety_backup=e,type:`checkbox`,class:`h-4 w-4 text-accent border-field rounded focus:ring-focus`},null,512),[[h,X.value.safety_backup]]),c(` `+f(L(`safety_backup`)),1)])]),v(`div`,Ut,[v(`p`,Wt,f(L(`risks`)),1),v(`ul`,Gt,[X.value.database?(i(),_(`li`,Kt,f(L(`risk_database`,{date:z(q.value.created_at||K.value.date)})),1)):e(``,!0),X.value.database?(i(),_(`li`,qt,f(L(`risk_sessions`)),1)):e(``,!0),X.value.files?(i(),_(`li`,Jt,f(L(`risk_files`)),1)):e(``,!0),v(`li`,null,f(L(`risk_site`)),1)])]),v(`div`,null,[v(`label`,Yt,f(L(`confirm`,{file:K.value.file})),1),n(v(`input`,{id:`backup-confirm`,dusk:`restore-confirm`,"onUpdate:modelValue":a[10]||=e=>X.value.confirm=e,type:`text`,autocomplete:`off`,spellcheck:`false`,class:`mt-1 block w-full px-3 py-2 font-mono border border-field rounded-md shadow-sm focus:outline-none focus:ring-focus focus:border-focus`},null,512),[[p,X.value.confirm]]),Z.value.confirm?(i(),_(`p`,Xt,f(Z.value.confirm),1)):e(``,!0)])],64)):e(``,!0),v(`div`,Zt,[t(b,{dusk:`cancel-restore`,variant:`secondary`,onClick:a[11]||=e=>K.value=null},{default:l(()=>[c(f(L(`cancel`)),1)]),_:1}),t(b,{dusk:`start-restore`,variant:`danger`,loading:Q.value,disabled:!nn.value,onClick:rn},{default:l(()=>[c(f(L(`start_restore`)),1)]),_:1},8,[`loading`,`disabled`])])])):e(``,!0)]),_:1},8,[`show`,`title`])]),_:1},8,[`title`]))}};export{P as default}; \ No newline at end of file diff --git a/packages/admin/dist/assets/Index-B9KqS9R5.js b/packages/admin/dist/assets/Index-B9KqS9R5.js new file mode 100644 index 00000000..e50a4fe1 --- /dev/null +++ b/packages/admin/dist/assets/Index-B9KqS9R5.js @@ -0,0 +1 @@ +import{$ as e,C as t,E as n,I as r,Q as i,R as a,S as o,T as s,W as c,n as ee,s as l,tt as u,v as d,w as f,x as p}from"./dist-Bie52OmN.js";import{t as te}from"./AdminLayout-DBeSErmz.js";import{t as m}from"./AdminButton-KiIJ2sLW.js";var h={class:`mb-6`},g={"data-page-title":`admin.modules`,class:`text-2xl font-bold text-fg`},_={class:`mt-1 text-sm text-muted`},v={class:`bg-surface rounded-lg shadow overflow-hidden`},y={key:0,class:`p-6 text-sm text-muted`},b={key:1,class:`min-w-full text-sm`},x={class:`bg-surface-alt`},S={class:`px-4 py-2 text-left font-medium text-fg`},C={class:`px-4 py-2 text-left font-medium text-fg`},w={class:`divide-y divide-line`},T=[`data-module`,`data-parent`,`data-enabled`],E={key:0,"aria-hidden":`true`,class:`mr-1 text-muted`},D={key:1,class:`ml-2 rounded bg-surface-alt px-1.5 py-0.5 text-xs font-normal text-muted`},O={key:0,class:`text-muted`},k={class:`px-4 py-2 font-mono text-xs text-muted`},A={class:`px-4 py-2 text-right whitespace-nowrap space-x-2`},j={key:0,"data-section":`required`,class:`mt-8`},M={class:`text-lg font-semibold text-fg`},N={class:`mt-1 text-sm text-muted`},P={class:`mt-3 bg-surface rounded-lg shadow divide-y divide-line text-sm`},ne=[`data-required`],F={class:`font-medium text-fg`},I={key:0,class:`text-muted`},L={class:`mt-1 block font-mono text-xs text-fg select-all`},R={key:1,"data-section":`catalogue`,class:`mt-8`},z={class:`text-lg font-semibold text-fg`},B={class:`mt-1 text-sm text-muted`},V={class:`mt-3 text-sm text-muted`},H={key:0,"data-catalogue":`unavailable`,class:`mt-3 text-sm text-muted`},U={key:1,class:`mt-3 text-sm text-muted`},W={key:2,class:`mt-3 bg-surface rounded-lg shadow divide-y divide-line text-sm`},G=[`data-package`,`data-status`],K={class:`flex flex-wrap items-baseline gap-x-3`},q=[`href`],J={key:0,class:`rounded bg-surface-alt px-1.5 py-0.5 text-xs text-muted`},Y={class:`text-xs text-muted`},X={key:0,class:`text-muted`},Z={key:0,class:`mt-1 block font-mono text-xs text-fg select-all`},re={class:`mt-1 block font-mono text-xs text-fg select-all`},Q={__name:`Index`,props:{modules:Array,required:Array,canManage:Boolean,catalogue:Object,title:String},setup(Q){let ie=e=>{l.post(route(e.enabled?`admin.modules.disable`:`admin.modules.enable`,e.key),{},{preserveScroll:!0})},$=e=>`php artisan atrium:module:install ${e}`;return(l,ae)=>(r(),o(te,{title:Q.title},{default:c(()=>[p(`div`,h,[p(`h1`,g,u(Q.title),1),p(`p`,_,u(l.$t(`modules.index_hint`)),1)]),p(`div`,v,[Q.modules.length===0?(r(),f(`p`,y,u(l.$t(`modules.empty`)),1)):(r(),f(`table`,b,[p(`thead`,x,[p(`tr`,null,[p(`th`,S,u(l.$t(`modules.module`)),1),p(`th`,C,u(l.$t(`modules.package`)),1),ae[0]||=p(`th`,{class:`px-4 py-2`},null,-1)])]),p(`tbody`,w,[(r(!0),f(d,null,a(Q.modules,n=>(r(),f(`tr`,{key:n.name,"data-module":n.name,"data-parent":n.parent,"data-enabled":n.enabled?`true`:`false`},[p(`td`,{class:e([`py-2 pr-4`,n.parent?`pl-10`:`pl-4`])},[p(`div`,{class:e([`font-medium`,n.enabled?`text-fg`:`text-muted`])},[n.parent?(r(),f(`span`,E,`↳`)):t(``,!0),s(u(n.label)+` `,1),n.enabled?t(``,!0):(r(),f(`span`,D,u(l.$t(`modules.status_disabled`)),1))],2),n.description?(r(),f(`div`,O,u(n.description),1)):t(``,!0)],2),p(`td`,k,u(n.name),1),p(`td`,A,[n.settings?(r(),o(m,{key:0,size:`sm`,variant:`outline`,"data-action":`settings`,href:l.route(`admin.modules.settings`,n.key)},{default:c(()=>[s(u(l.$t(`modules.settings`)),1)]),_:1},8,[`href`])):t(``,!0),Q.canManage?(r(),o(m,{key:1,size:`sm`,variant:n.enabled?`secondary`:`success`,"data-action":n.enabled?`disable`:`enable`,onClick:e=>ie(n)},{default:c(()=>[s(u(n.enabled?l.$t(`modules.disable`):l.$t(`modules.enable`)),1)]),_:2},1032,[`variant`,`data-action`,`onClick`])):t(``,!0)])],8,T))),128))])]))]),Q.canManage&&Q.required.length?(r(),f(`section`,j,[p(`h2`,M,u(l.$t(`modules.required_title`)),1),p(`p`,N,u(l.$t(`modules.required_hint`)),1),p(`ul`,P,[(r(!0),f(d,null,a(Q.required,e=>(r(),f(`li`,{key:e.name,"data-required":e.name,class:`px-4 py-3`},[p(`div`,F,u(e.label),1),e.description?(r(),f(`div`,I,u(e.description),1)):t(``,!0),p(`code`,L,u($(e.name)),1)],8,ne))),128))])])):t(``,!0),Q.canManage?(r(),f(`section`,R,[p(`h2`,z,u(l.$t(`modules.catalogue_title`)),1),p(`p`,B,u(l.$t(`modules.catalogue_hint`)),1),n(i(ee),{data:`catalogue`},{fallback:c(()=>[p(`p`,V,u(l.$t(`modules.catalogue_loading`)),1)]),default:c(()=>[Q.catalogue.packages===null?(r(),f(`p`,H,u(l.$t(`modules.catalogue_unavailable`)),1)):Q.catalogue.packages.length===0?(r(),f(`p`,U,u(l.$t(`modules.catalogue_empty`)),1)):(r(),f(`ul`,W,[(r(!0),f(d,null,a(Q.catalogue.packages,e=>(r(),f(`li`,{key:e.name,"data-package":e.name,"data-status":e.status,class:`px-4 py-3`},[p(`div`,K,[p(`a`,{href:e.url,target:`_blank`,rel:`noopener`,class:`font-mono text-sm font-medium text-fg hover:underline`},u(e.name),9,q),e.status===`available`?t(``,!0):(r(),f(`span`,J,u(l.$t(`modules.status_${e.status}`)),1)),p(`span`,Y,u(l.$t(`modules.downloads`,{count:e.downloads})),1)]),e.description?(r(),f(`div`,X,u(e.description),1)):t(``,!0),e.status===`available`||e.status===`required`?(r(),f(d,{key:1},[e.status===`available`?(r(),f(`code`,Z,`composer require `+u(e.name),1)):t(``,!0),p(`code`,re,u($(e.name)),1)],64)):t(``,!0)],8,G))),128))]))]),_:1})])):t(``,!0)]),_:1},8,[`title`]))}};export{Q as default}; \ No newline at end of file diff --git a/packages/admin/dist/assets/Index-BNmU5PEL.js b/packages/admin/dist/assets/Index-BNmU5PEL.js new file mode 100644 index 00000000..2b4c28ab --- /dev/null +++ b/packages/admin/dist/assets/Index-BNmU5PEL.js @@ -0,0 +1 @@ +import{E as e,I as t,R as n,S as r,T as i,W as a,X as o,s,tt as c,v as l,w as u,x as d}from"./dist-Bie52OmN.js";import{t as f}from"./AdminLayout-DBeSErmz.js";import{t as p}from"./AdminButton-KiIJ2sLW.js";import{t as m}from"./AdminModal-DKazeNNa.js";var h={class:`mb-6 flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4`},g={"data-page-title":`admin.roles`,class:`text-2xl font-bold text-fg`},_={class:`mt-1 text-sm text-muted`},v={class:`bg-surface rounded-lg shadow overflow-hidden`},y={key:0,class:`p-6 text-sm text-muted`},b={key:1,class:`min-w-full text-sm`},x={class:`bg-surface-alt`},S={class:`px-4 py-2 text-left font-medium text-fg`},C={class:`px-4 py-2 text-left font-medium text-fg`},w={class:`px-4 py-2 text-left font-medium text-fg`},T={class:`divide-y divide-line`},E={class:`px-4 py-2 font-medium text-fg`},D={class:`px-4 py-2 text-fg`},O={class:`px-4 py-2 text-fg`},k={class:`px-4 py-2 text-right whitespace-nowrap`},A={class:`text-muted`},j={__name:`Index`,props:{roles:Array,title:String},setup(j){let M=o(null),N=()=>{s.delete(route(`admin.roles.destroy`,M.value.id),{preserveScroll:!0,onFinish:()=>{M.value=null}})};return(o,s)=>(t(),r(f,{title:j.title},{default:a(()=>[d(`div`,h,[d(`div`,null,[d(`h1`,g,c(j.title),1),d(`p`,_,c(o.$t(`permissions.index_hint`)),1)]),e(p,{"data-action":`create`,href:o.route(`admin.roles.create`)},{default:a(()=>[s[2]||=d(`svg`,{class:`w-4 h-4 mr-2`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`},[d(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M12 4v16m8-8H4`})],-1),i(` `+c(o.$t(`common.create`)),1)]),_:1},8,[`href`])]),d(`div`,v,[j.roles.length===0?(t(),u(`p`,y,c(o.$t(`permissions.empty`)),1)):(t(),u(`table`,b,[d(`thead`,x,[d(`tr`,null,[d(`th`,S,c(o.$t(`permissions.name`)),1),d(`th`,C,c(o.$t(`permissions.permissions_count`)),1),d(`th`,w,c(o.$t(`permissions.users_count`)),1),s[3]||=d(`th`,{class:`px-4 py-2`},null,-1)])]),d(`tbody`,T,[(t(!0),u(l,null,n(j.roles,n=>(t(),u(`tr`,{key:n.id,"data-role-row":``},[d(`td`,E,c(n.name),1),d(`td`,D,c(n.permissions_count),1),d(`td`,O,c(n.users_count),1),d(`td`,k,[e(p,{size:`sm`,variant:`outline`,"data-action":`edit`,href:o.route(`admin.roles.edit`,n.id)},{default:a(()=>[i(c(o.$t(`common.edit`)),1)]),_:1},8,[`href`]),e(p,{size:`sm`,variant:`danger`,"data-action":`delete`,class:`ml-2`,onClick:e=>M.value=n},{default:a(()=>[i(c(o.$t(`common.delete`)),1)]),_:1},8,[`onClick`])])]))),128))])]))]),e(m,{show:M.value!==null,title:o.$t(`permissions.delete_title`),onClose:s[1]||=e=>M.value=null},{footer:a(()=>[e(p,{variant:`secondary`,onClick:s[0]||=e=>M.value=null},{default:a(()=>[i(c(o.$t(`common.cancel`)),1)]),_:1}),e(p,{variant:`danger`,"data-action":`delete-confirm`,onClick:N},{default:a(()=>[i(c(o.$t(`common.delete`)),1)]),_:1})]),default:a(()=>[d(`p`,A,[d(`strong`,null,c(M.value?.name),1),i(` — `+c(o.$t(`permissions.delete_confirm`)),1)])]),_:1},8,[`show`,`title`])]),_:1},8,[`title`]))}};export{j as default}; \ No newline at end of file diff --git a/packages/admin/dist/assets/Index-C63EL5RF.js b/packages/admin/dist/assets/Index-C63EL5RF.js new file mode 100644 index 00000000..41f94c42 --- /dev/null +++ b/packages/admin/dist/assets/Index-C63EL5RF.js @@ -0,0 +1 @@ +import{C as e,E as t,G as n,I as r,S as i,T as a,W as o,X as s,g as c,m as l,s as u,tt as d,w as f,x as p}from"./dist-Bie52OmN.js";import{t as m}from"./AdminLayout-DBeSErmz.js";import{t as h}from"./AdminButton-KiIJ2sLW.js";import{t as g}from"./AdminDataTable-6eKgKDeA.js";import{t as _}from"./AdminModal-DKazeNNa.js";var v={class:`mb-6 flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4`},y={class:`text-2xl font-bold text-fg`},b={class:`mt-1 text-sm text-muted`},x={class:`mb-6`},S={class:`flex gap-4`},C={class:`flex-1 max-w-md`},w=[`placeholder`],T={class:`text-muted`},E={key:0},D={class:`mt-2 text-sm text-danger`},O={__name:`Index`,props:{items:Object,columns:Array,filters:Object,title:String,can:{type:Object,default:()=>({})}},setup(O){let k=O,A=s(k.filters.search||``),j=s(!1),M=s(null),N=()=>{u.get(route(`admin.users.index`),{search:A.value},{preserveState:!0,preserveScroll:!0})},P=({column:e,direction:t})=>{u.get(route(`admin.users.index`),{...k.filters,sort:e,direction:t},{preserveState:!0,preserveScroll:!0})},F=e=>{u.visit(route(`admin.users.edit`,e.id))},I=e=>{M.value=e,j.value=!0},L=()=>{M.value&&u.delete(route(`admin.users.destroy`,M.value.id),{onSuccess:()=>{j.value=!1,M.value=null}})};return(s,u)=>(r(),i(m,{title:O.title},{default:o(()=>[p(`div`,v,[p(`div`,null,[p(`h1`,y,d(O.title),1),p(`p`,b,d(s.$t(`account.users.total`,{count:O.items.total})),1)]),O.can.create===!1?e(``,!0):(r(),i(h,{key:0,"data-action":`create`,href:s.route(`admin.users.create`)},{default:o(()=>[u[3]||=p(`svg`,{class:`w-4 h-4 mr-2`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`},[p(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M12 4v16m8-8H4`})],-1),a(` `+d(s.$t(`common.create`)),1)]),_:1},8,[`href`]))]),p(`div`,x,[p(`div`,S,[p(`div`,C,[n(p(`input`,{"onUpdate:modelValue":u[0]||=e=>A.value=e,type:`text`,placeholder:s.$t(`account.users.search_placeholder`),class:`w-full px-4 py-2 border border-field rounded-lg focus:ring-focus focus:border-focus`,onKeyup:c(N,[`enter`])},null,40,w),[[l,A.value]])]),t(h,{onClick:N,variant:`secondary`},{default:o(()=>[a(d(s.$t(`common.search`)),1)]),_:1})])]),t(g,{columns:O.columns,items:O.items,"sort-by":O.filters.sort,"sort-direction":O.filters.direction,"can-delete":O.can.delete!==!1,onSort:P,onEdit:F,onDelete:I},null,8,[`columns`,`items`,`sort-by`,`sort-direction`,`can-delete`]),t(_,{show:j.value,title:s.$t(`account.users.delete_title`),onClose:u[2]||=e=>j.value=!1},{footer:o(()=>[t(h,{variant:`secondary`,onClick:u[1]||=e=>j.value=!1},{default:o(()=>[a(d(s.$t(`common.cancel`)),1)]),_:1}),t(h,{variant:`danger`,onClick:L},{default:o(()=>[a(d(s.$t(`common.delete`)),1)]),_:1})]),default:o(()=>[p(`p`,T,[a(d(s.$t(`account.users.delete_confirm`))+` `,1),M.value?(r(),f(`strong`,E,d(M.value.name),1)):e(``,!0)]),p(`p`,D,d(s.$t(`account.users.delete_irreversible`)),1)]),_:1},8,[`show`,`title`])]),_:1},8,[`title`]))}};export{O as default}; \ No newline at end of file diff --git a/packages/admin/dist/assets/Index-CG3NSbtt.js b/packages/admin/dist/assets/Index-CG3NSbtt.js new file mode 100644 index 00000000..e2c7b270 --- /dev/null +++ b/packages/admin/dist/assets/Index-CG3NSbtt.js @@ -0,0 +1 @@ +import{$ as e,C as t,E as n,G as r,H as i,I as a,N as o,R as s,S as ee,T as c,W as l,X as u,b as d,m as f,o as te,s as p,tt as m,u as h,v as g,w as _,x as v}from"./dist-Bie52OmN.js";import{n as y,r as ne,t as re}from"./AdminLayout-DBeSErmz.js";import{t as b}from"./AdminButton-KiIJ2sLW.js";import{t as x}from"./AdminCard-YbEwPtJz.js";import{t as S}from"./AdminModal-DKazeNNa.js";var ie={class:`mb-6 flex flex-wrap items-start justify-between gap-4`},ae={class:`text-2xl font-bold text-fg`},oe={class:`mt-1 text-sm text-muted`},se={class:`flex flex-wrap gap-2`},ce={key:0,dusk:`backup-running`,role:`status`,class:`mb-6 flex items-center gap-3 p-4 bg-accent-soft text-accent-soft-fg border border-line rounded-lg text-sm`},le={class:`space-y-6`},ue={key:0,class:`p-6 text-sm text-muted`},de={key:1,class:`overflow-x-auto`},fe={dusk:`backups`,class:`min-w-full text-sm`},pe={class:`bg-surface-alt`},me={class:`px-4 py-2 text-left font-medium text-fg`},he={class:`px-4 py-2 text-left font-medium text-fg`},ge={class:`px-4 py-2 text-left font-medium text-fg`},_e={class:`px-4 py-2 text-right font-medium text-fg`},ve={class:`divide-y divide-line`},ye=[`data-backup`],be={class:`px-4 py-2 font-mono text-fg`},xe={class:`px-4 py-2 text-fg`},C={class:`px-4 py-2 text-fg`},w={class:`px-4 py-2 text-right text-fg whitespace-nowrap`},T={class:`px-4 py-2 text-right whitespace-nowrap space-x-2`},E=[`href`],D=[`disabled`,`onClick`],O=[`onClick`],k={class:`grid gap-6 lg:grid-cols-2`},A={class:`space-y-4`},j=[`data-destination`,`dusk`],M={class:`flex flex-wrap items-center gap-2`},Se={class:`font-medium text-fg`},Ce={key:0,class:`mt-1 text-sm text-fg`},we={key:1,class:`mt-1 list-disc pl-5 text-sm text-danger`},Te={class:`grid grid-cols-1 sm:grid-cols-3 gap-x-4 gap-y-3 text-sm`},Ee={class:`font-medium text-fg`},De={class:`sm:col-span-2 text-fg`},Oe={class:`font-medium text-fg`},ke={class:`sm:col-span-2 text-fg break-all`},Ae={class:`font-medium text-fg`},je={class:`sm:col-span-2 text-fg`},Me={class:`font-medium text-fg`},Ne={class:`sm:col-span-2 text-fg`},Pe={key:0},Fe={class:`font-medium text-fg`},Ie={class:`sm:col-span-2 text-fg`},Le={class:`font-medium text-fg`},Re={class:`sm:col-span-2 text-fg`},ze={key:0,class:`p-6 text-sm text-muted`},Be={key:1,class:`overflow-x-auto`},Ve={dusk:`backup-log`,class:`min-w-full text-sm`},He={class:`bg-surface-alt`},Ue={class:`px-4 py-2 text-left font-medium text-fg`},We={class:`px-4 py-2 text-left font-medium text-fg`},Ge={class:`px-4 py-2 text-left font-medium text-fg`},Ke={class:`px-4 py-2 text-left font-medium text-fg`},qe={class:`divide-y divide-line`},Je={class:`px-4 py-2 text-fg whitespace-nowrap`},Ye={class:`px-4 py-2 text-fg`},Xe={class:`px-4 py-2`},Ze={class:`px-4 py-2 text-fg break-words`},Qe={class:`p-6`},$e={class:`text-fg`},et={class:`mt-6 flex justify-end gap-2`},tt={key:0,dusk:`restore-dialog`,class:`p-6 space-y-5 text-sm`},nt={class:`text-fg`},rt={class:`flex flex-wrap items-end gap-3`},it={class:`flex-1 min-w-48`},N={for:`backup-password`,class:`block font-medium text-fg`},at={class:`mt-1 text-xs text-muted`},ot={key:0,"data-error":``,class:`text-danger`,role:`alert`},st={key:0,class:`text-fg`},ct={key:1,class:`overflow-x-auto border border-line rounded-md`},lt={dusk:`plan-databases`,class:`min-w-full`},ut={class:`bg-surface-alt`},dt={class:`px-3 py-2 text-left font-medium text-fg`},ft={class:`px-3 py-2 text-left font-medium text-fg`},pt={class:`px-3 py-2 text-right font-medium text-fg`},mt={class:`px-3 py-2 text-left font-medium text-fg`},ht={class:`divide-y divide-line`},gt={class:`px-3 py-1.5 text-fg`},_t={class:`px-3 py-1.5 text-fg`},vt={class:`px-3 py-1.5 text-right text-fg`},yt={class:`px-3 py-1.5 text-fg break-all`},bt={key:2,class:`overflow-x-auto border border-line rounded-md`},xt={dusk:`plan-folders`,class:`min-w-full`},St={class:`bg-surface-alt`},Ct={class:`px-3 py-2 text-left font-medium text-fg`},wt={class:`px-3 py-2 text-right font-medium text-fg`},Tt={class:`px-3 py-2 text-right font-medium text-fg`},Et={class:`px-3 py-2 text-right font-medium text-fg`},Dt={class:`px-3 py-2 text-right font-medium text-fg`},Ot={class:`px-3 py-2 text-right font-medium text-fg`},kt={class:`divide-y divide-line`},At={class:`px-3 py-1.5 text-fg break-all`},jt={class:`px-3 py-1.5 text-right text-fg`},Mt={class:`px-3 py-1.5 text-right text-fg`},Nt={class:`px-3 py-1.5 text-right text-fg`},Pt={class:`px-3 py-1.5 text-right text-fg`},Ft={class:`px-3 py-1.5 text-right text-fg`},It={key:3,class:`list-disc pl-5 bg-warning-soft text-warning-soft-fg border border-line rounded-md p-3 space-y-1`},Lt={class:`space-y-2`},Rt={class:`flex items-center gap-2 text-fg`},zt={class:`flex items-center gap-2 text-fg`},Bt={class:`flex items-center gap-2 text-fg ml-6`},Vt=[`disabled`],Ht={class:`flex items-center gap-2 text-fg`},Ut={class:`p-4 bg-surface text-fg border-2 border-danger rounded-lg`},Wt={class:`font-medium`},Gt={class:`mt-2 list-disc pl-5 space-y-1`},Kt={key:0},qt={key:1},Jt={key:2},Yt={for:`backup-confirm`,class:`block font-medium text-fg`},Xt={key:0,"data-error":``,class:`mt-1 text-danger`},Zt={class:`flex justify-end gap-2`},P={__name:`Index`,props:{backups:Array,running:Object,log:Array,health:Array,settings:Object,labels:Object},setup(P){let F=P,Qt=te(),I=d(()=>String(Qt.props.locale||`en`).replace(`_`,`-`));function L(e,t={}){let n=F.labels?.[e]??e;for(let[e,r]of Object.entries(t))n=n.replaceAll(`:${e}`,String(r??``));return n}function R(e){let t=[`B`,`KB`,`MB`,`GB`,`TB`],n=Number(e)||0,r=0;for(;n>=1024&&r1)})} ${t[r]}`}function z(e){return e?new Date(e).toLocaleString(I.value,{dateStyle:`medium`,timeStyle:`short`}):``}let B=u({backups:F.backups,running:F.running,log:F.log}),V=null;i(()=>[F.backups,F.running,F.log],()=>{B.value={backups:F.backups,running:F.running,log:F.log}});async function H(){let e=await fetch(route(`admin.backups.status`),{headers:y()}).catch(()=>null);if(e?.ok){let t=await e.json(),n=B.value.running&&!t.running;B.value=t,n&&p.reload({only:[`health`,`backups`,`running`,`log`]})}}i(()=>B.value.running,e=>{clearInterval(V),V=e?setInterval(H,3e3):null},{immediate:!0}),o(()=>clearInterval(V));let U=u(!1);function W(e=null){U.value=!0,p.post(route(`admin.backups.store`),{only:e},{preserveScroll:!0,onSuccess:()=>H(),onFinish:()=>{U.value=!1}})}let G=u(null);function $t(){p.delete(route(`admin.backups.destroy`,G.value.id),{preserveScroll:!0,onFinish:()=>{G.value=null}})}let K=u(null),q=u(null),J=u(``),Y=u(!1),X=u({}),Z=u({}),Q=u(!1);function en(e){K.value=e,q.value=null,J.value=``,Z.value={},X.value={password:``,database:!0,files:!0,delete_extra:!1,safety_backup:!0,confirm:``}}async function tn(){Y.value=!0,J.value=``;try{let e=await fetch(route(`admin.backups.plan`,K.value.id),{method:`POST`,headers:y({"Content-Type":`application/json`}),body:JSON.stringify({password:X.value.password||null})});if(!e.ok){J.value=await ne(e,L(`preview_failed`)),q.value=null;return}q.value=(await e.json()).plan}catch{J.value=L(`preview_failed`)}finally{Y.value=!1}}let nn=d(()=>q.value&&(X.value.database||X.value.files)&&X.value.confirm.trim()===K.value?.file);function rn(){Q.value=!0,p.post(route(`admin.backups.restore`,K.value.id),{...X.value,confirm:X.value.confirm.trim(),password:X.value.password||null},{preserveScroll:!0,onSuccess:()=>{K.value=null,H()},onError:e=>{Z.value=e},onFinish:()=>{Q.value=!1}})}let an=d(()=>{let e=F.settings?.schedule||{};return e.frequency===`daily`?L(`schedule_daily`,{time:e.time}):e.frequency===`weekly`?L(`schedule_weekly`,{weekday:F.settings.weekday,time:e.time}):L(`schedule_off`)}),on=d(()=>{let e=F.settings?.retention||{};return L(`retention_text`,{all:e.keep_all_days,daily:e.daily,weekly:e.weekly,monthly:e.monthly,yearly:e.yearly})}),$={ok:`bg-success-soft text-success-soft-fg`,partial:`bg-warning-soft text-warning-soft-fg`,failed:`bg-danger-soft text-danger-soft-fg`};function sn(e){let t=[];return e.trigger&&t.push(L(`trigger_${e.trigger}`)),e.by&&t.push(e.by),e.file&&t.push(e.disk?`${e.file} (${e.disk})`:e.file),e.disks?.length&&t.push(L(`copied_to`,{disks:e.disks.join(`, `)})),e.failed?.length&&t.push(L(`not_copied_to`,{disks:e.failed.map(e=>e.disk??e).join(`, `)})),e.action===`restore`&&e.status===`ok`&&t.push(L(`restored`,{databases:(e.databases||[]).join(`, `)||`—`,files:e.files??0,deleted:e.deleted??0})),e.seconds!==void 0&&t.push(L(`seconds`,{seconds:e.seconds})),e.message&&t.push(e.message),t.join(` · `)}return(i,o)=>(a(),ee(re,{title:L(`menu`)},{default:l(()=>[v(`div`,ie,[v(`div`,null,[v(`h1`,ae,m(P.labels.menu),1),v(`p`,oe,m(L(`subtitle`)),1)]),v(`div`,se,[n(b,{dusk:`backup-now`,loading:U.value,disabled:!!B.value.running,onClick:o[0]||=e=>W()},{default:l(()=>[c(m(L(`back_up_now`)),1)]),_:1},8,[`loading`,`disabled`]),n(b,{variant:`secondary`,disabled:U.value||!!B.value.running,onClick:o[1]||=e=>W(`database`)},{default:l(()=>[c(m(L(`only_database`)),1)]),_:1},8,[`disabled`]),n(b,{variant:`secondary`,disabled:U.value||!!B.value.running,onClick:o[2]||=e=>W(`files`)},{default:l(()=>[c(m(L(`only_files`)),1)]),_:1},8,[`disabled`])])]),B.value.running?(a(),_(`div`,ce,[o[13]||=v(`svg`,{class:`animate-spin h-5 w-5`,fill:`none`,viewBox:`0 0 24 24`,"aria-hidden":`true`},[v(`circle`,{class:`opacity-25`,cx:`12`,cy:`12`,r:`10`,stroke:`currentColor`,"stroke-width":`4`}),v(`path`,{class:`opacity-75`,fill:`currentColor`,d:`M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z`})],-1),c(` `+m(L(B.value.running.action===`restore`?`running_restore`:`running_backup`,{time:z(B.value.running.started_at)})),1)])):t(``,!0),v(`div`,le,[n(x,{title:L(`archives`),"no-padding":``},{default:l(()=>[B.value.backups.length?(a(),_(`div`,de,[v(`table`,fe,[v(`thead`,pe,[v(`tr`,null,[v(`th`,me,m(L(`file`)),1),v(`th`,he,m(L(`destination`)),1),v(`th`,ge,m(L(`date`)),1),v(`th`,_e,m(L(`size`)),1),o[14]||=v(`th`,{class:`px-4 py-2`},null,-1)])]),v(`tbody`,ve,[(a(!0),_(g,null,s(B.value.backups,e=>(a(),_(`tr`,{key:e.id,"data-backup":e.file,dusk:`backup`},[v(`td`,be,m(e.file),1),v(`td`,xe,m(e.disk),1),v(`td`,C,m(z(e.date)),1),v(`td`,w,m(R(e.size)),1),v(`td`,T,[v(`a`,{href:e.download_url,class:`text-accent underline`},m(L(`download`)),9,E),v(`button`,{type:`button`,dusk:`restore`,class:`text-accent underline`,disabled:!!B.value.running,onClick:t=>en(e)},m(L(`restore`)),9,D),v(`button`,{type:`button`,dusk:`delete`,class:`text-danger underline`,onClick:t=>G.value=e},m(L(`delete`)),9,O)])],8,ye))),128))])])])):(a(),_(`p`,ue,m(L(`empty`)),1))]),_:1},8,[`title`]),v(`div`,k,[n(x,{title:L(`destinations`)},{default:l(()=>[v(`ul`,A,[(a(!0),_(g,null,s(P.health,n=>(a(),_(`li`,{key:n.disk,"data-destination":n.disk,dusk:`destination-${n.disk}`},[v(`div`,M,[v(`span`,Se,m(n.disk),1),v(`span`,{class:e([`px-2 py-0.5 rounded text-xs font-medium`,!n.reachable||!n.healthy?$.failed:$.ok])},m(n.reachable?n.healthy?L(`healthy`):L(`unhealthy`):L(`unreachable`)),3)]),n.reachable?(a(),_(`p`,Ce,m(L(`stored`,{count:n.count,size:R(n.used)}))+` · `+m(n.newest?L(`newest`,{date:z(n.newest)}):L(`no_archive`)),1)):t(``,!0),n.problems.length?(a(),_(`ul`,we,[(a(!0),_(g,null,s(n.problems,e=>(a(),_(`li`,{key:e},m(e),1))),128))])):t(``,!0)],8,j))),128))])]),_:1},8,[`title`]),n(x,{title:L(`settings`),subtitle:L(`settings_note`)},{default:l(()=>[v(`dl`,Te,[v(`dt`,Ee,m(L(`databases`)),1),v(`dd`,De,m(P.settings.databases.map(e=>`${e.connection} (${e.driver})`).join(`, `)||L(`nothing`)),1),v(`dt`,Oe,m(L(`folders`)),1),v(`dd`,ke,m(P.settings.folders.join(`, `)||L(`nothing`)),1),v(`dt`,Ae,m(L(`destinations`)),1),v(`dd`,je,m(P.settings.destinations.join(`, `)),1),v(`dt`,Me,m(L(`schedule`)),1),v(`dd`,Ne,[c(m(an.value),1),P.settings.queue?(a(),_(`span`,Pe,`. `+m(L(`queue`,{queue:P.settings.queue})),1)):t(``,!0)]),v(`dt`,Fe,m(L(`retention`)),1),v(`dd`,Ie,m(on.value),1),v(`dt`,Le,m(L(`encryption`)),1),v(`dd`,Re,m(P.settings.encrypted?L(`encrypted`):L(`not_encrypted`)),1)])]),_:1},8,[`title`,`subtitle`])]),n(x,{title:L(`log`),"no-padding":``},{default:l(()=>[B.value.log.length?(a(),_(`div`,Be,[v(`table`,Ve,[v(`thead`,He,[v(`tr`,null,[v(`th`,Ue,m(L(`when`)),1),v(`th`,We,m(L(`what`)),1),v(`th`,Ge,m(L(`result`)),1),v(`th`,Ke,m(L(`details`)),1)])]),v(`tbody`,qe,[(a(!0),_(g,null,s(B.value.log,(t,n)=>(a(),_(`tr`,{key:n},[v(`td`,Je,m(z(t.at)),1),v(`td`,Ye,m(L(`action_${t.action}`)),1),v(`td`,Xe,[v(`span`,{class:e([`px-2 py-0.5 rounded text-xs font-medium`,$[t.status]||$.failed])},m(L(`status_${t.status}`)),3)]),v(`td`,Ze,m(sn(t)),1)]))),128))])])])):(a(),_(`p`,ze,m(L(`log_empty`)),1))]),_:1},8,[`title`])]),n(S,{show:!!G.value,title:L(`delete`),onClose:o[4]||=e=>G.value=null},{default:l(()=>[v(`div`,Qe,[v(`p`,$e,m(G.value?L(`delete_confirm`,{file:G.value.file,disk:G.value.disk}):``),1),v(`div`,et,[n(b,{variant:`secondary`,onClick:o[3]||=e=>G.value=null},{default:l(()=>[c(m(L(`cancel`)),1)]),_:1}),n(b,{dusk:`confirm-delete`,variant:`danger`,onClick:$t},{default:l(()=>[c(m(L(`delete`)),1)]),_:1})])])]),_:1},8,[`show`,`title`]),n(S,{show:!!K.value,"max-width":`2xl`,title:K.value?L(`restore_title`,{file:K.value.file}):``,onClose:o[12]||=e=>K.value=null},{default:l(()=>[K.value?(a(),_(`div`,tt,[v(`p`,nt,m(L(`restore_intro`)),1),v(`div`,rt,[v(`div`,it,[v(`label`,N,m(L(`password`)),1),r(v(`input`,{id:`backup-password`,"onUpdate:modelValue":o[5]||=e=>X.value.password=e,type:`password`,autocomplete:`off`,class:`mt-1 block w-full px-3 py-2 border border-field rounded-md shadow-sm focus:outline-none focus:ring-focus focus:border-focus`},null,512),[[f,X.value.password]]),v(`p`,at,m(L(`password_hint`)),1)]),n(b,{dusk:`preview`,variant:`secondary`,loading:Y.value,onClick:tn},{default:l(()=>[c(m(L(`preview`)),1)]),_:1},8,[`loading`])]),J.value?(a(),_(`p`,ot,m(J.value),1)):t(``,!0),q.value?(a(),_(g,{key:1},[q.value.created_at?(a(),_(`p`,st,m(L(`made`,{date:z(q.value.created_at)})),1)):t(``,!0),q.value.databases.length?(a(),_(`div`,ct,[v(`table`,lt,[v(`thead`,ut,[v(`tr`,null,[v(`th`,dt,m(L(`connection`)),1),v(`th`,ft,m(L(`driver`)),1),v(`th`,pt,m(L(`dump`)),1),v(`th`,mt,m(L(`replaces`)),1)])]),v(`tbody`,ht,[(a(!0),_(g,null,s(q.value.databases,e=>(a(),_(`tr`,{key:e.connection},[v(`td`,gt,m(e.connection),1),v(`td`,_t,m(e.driver),1),v(`td`,vt,m(R(e.size)),1),v(`td`,yt,m(e.restorable?e.target:L(`skipped`)),1)]))),128))])])])):t(``,!0),q.value.folders.length?(a(),_(`div`,bt,[v(`table`,xt,[v(`thead`,St,[v(`tr`,null,[v(`th`,Ct,m(L(`into`)),1),v(`th`,wt,m(L(`files`)),1),v(`th`,Tt,m(L(`new`)),1),v(`th`,Et,m(L(`changed`)),1),v(`th`,Dt,m(L(`unchanged`)),1),v(`th`,Ot,m(L(`extra`)),1)])]),v(`tbody`,kt,[(a(!0),_(g,null,s(q.value.folders,e=>(a(),_(`tr`,{key:e.prefix},[v(`td`,At,m(e.target),1),v(`td`,jt,m(e.files),1),v(`td`,Mt,m(e.new),1),v(`td`,Nt,m(e.changed),1),v(`td`,Pt,m(e.unchanged),1),v(`td`,Ft,m(e.extra),1)]))),128))])])])):t(``,!0),q.value.warnings.length?(a(),_(`ul`,It,[(a(!0),_(g,null,s(q.value.warnings,e=>(a(),_(`li`,{key:e,class:`ml-3`},m(e),1))),128))])):t(``,!0),v(`fieldset`,Lt,[v(`label`,Rt,[r(v(`input`,{"onUpdate:modelValue":o[6]||=e=>X.value.database=e,type:`checkbox`,class:`h-4 w-4 text-accent border-field rounded focus:ring-focus`},null,512),[[h,X.value.database]]),c(` `+m(L(`restore_database`)),1)]),v(`label`,zt,[r(v(`input`,{"onUpdate:modelValue":o[7]||=e=>X.value.files=e,type:`checkbox`,class:`h-4 w-4 text-accent border-field rounded focus:ring-focus`},null,512),[[h,X.value.files]]),c(` `+m(L(`restore_files`)),1)]),v(`label`,Bt,[r(v(`input`,{"onUpdate:modelValue":o[8]||=e=>X.value.delete_extra=e,type:`checkbox`,class:`h-4 w-4 text-accent border-field rounded focus:ring-focus`,disabled:!X.value.files},null,8,Vt),[[h,X.value.delete_extra]]),c(` `+m(L(`delete_extra`)),1)]),v(`label`,Ht,[r(v(`input`,{"onUpdate:modelValue":o[9]||=e=>X.value.safety_backup=e,type:`checkbox`,class:`h-4 w-4 text-accent border-field rounded focus:ring-focus`},null,512),[[h,X.value.safety_backup]]),c(` `+m(L(`safety_backup`)),1)])]),v(`div`,Ut,[v(`p`,Wt,m(L(`risks`)),1),v(`ul`,Gt,[X.value.database?(a(),_(`li`,Kt,m(L(`risk_database`,{date:z(q.value.created_at||K.value.date)})),1)):t(``,!0),X.value.database?(a(),_(`li`,qt,m(L(`risk_sessions`)),1)):t(``,!0),X.value.files?(a(),_(`li`,Jt,m(L(`risk_files`)),1)):t(``,!0),v(`li`,null,m(L(`risk_site`)),1)])]),v(`div`,null,[v(`label`,Yt,m(L(`confirm`,{file:K.value.file})),1),r(v(`input`,{id:`backup-confirm`,dusk:`restore-confirm`,"onUpdate:modelValue":o[10]||=e=>X.value.confirm=e,type:`text`,autocomplete:`off`,spellcheck:`false`,class:`mt-1 block w-full px-3 py-2 font-mono border border-field rounded-md shadow-sm focus:outline-none focus:ring-focus focus:border-focus`},null,512),[[f,X.value.confirm]]),Z.value.confirm?(a(),_(`p`,Xt,m(Z.value.confirm),1)):t(``,!0)])],64)):t(``,!0),v(`div`,Zt,[n(b,{dusk:`cancel-restore`,variant:`secondary`,onClick:o[11]||=e=>K.value=null},{default:l(()=>[c(m(L(`cancel`)),1)]),_:1}),n(b,{dusk:`start-restore`,variant:`danger`,loading:Q.value,disabled:!nn.value,onClick:rn},{default:l(()=>[c(m(L(`start_restore`)),1)]),_:1},8,[`loading`,`disabled`])])])):t(``,!0)]),_:1},8,[`show`,`title`])]),_:1},8,[`title`]))}};export{P as default}; \ No newline at end of file diff --git a/packages/admin/dist/assets/Index-CjLWl74m.js b/packages/admin/dist/assets/Index-CjLWl74m.js deleted file mode 100644 index 200de985..00000000 --- a/packages/admin/dist/assets/Index-CjLWl74m.js +++ /dev/null @@ -1 +0,0 @@ -import{C as e,E as t,G as n,I as r,R as i,S as a,T as o,W as s,Y as c,Z as l,et as u,g as d,m as f,s as p,v as m,w as h,x as g}from"./dist-MY__znoP.js";import{t as _}from"./AdminLayout--RXJFj9t.js";import{t as v}from"./AdminButton-Bx141Bs3.js";import{t as y}from"./AdminDataTable-BaQwb_6U.js";import{t as b}from"./AdminModal-DNJ_V4iq.js";import{t as x}from"./recordActions-CtRs42tG.js";var S={class:`mb-6 flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4`},C=[`data-page-title`],w={class:`mt-1 text-sm text-muted`},T={class:`flex flex-wrap items-center gap-2`},E={class:`mb-6`},D={class:`flex gap-4`},O={class:`flex-1 max-w-md`},k=[`placeholder`],A={class:`text-muted`},j={__name:`Index`,props:{routeName:String,createLabel:String,items:Object,columns:Array,filters:Object,title:String,can:{type:Object,default:()=>({})},actions:{type:Array,default:()=>[]},links:{type:Array,default:()=>[]}},setup(j){let M=j,N=Object.fromEntries(Object.entries(M.filters||{}).filter(([e])=>![`search`,`sort`,`direction`].includes(e))),P=M.actions.map(e=>({...e,href:t=>x(M.routeName,e,t)})),F=c(M.filters.search||``),I=c(!1),L=c(null),R=()=>{p.get(route(`${M.routeName}.index`),{...N,search:F.value},{preserveState:!0,preserveScroll:!0})},z=({column:e,direction:t})=>{p.get(route(`${M.routeName}.index`),{...M.filters,sort:e,direction:t},{preserveState:!0,preserveScroll:!0})},B=e=>{p.visit(route(`${M.routeName}.edit`,e.id))},V=e=>{L.value=e,I.value=!0},H=()=>{L.value&&p.delete(route(`${M.routeName}.destroy`,L.value.id),{onSuccess:()=>{I.value=!1,L.value=null}})};return(c,p)=>(r(),a(_,{title:j.title},{default:s(()=>[g(`div`,S,[g(`div`,null,[g(`h1`,{"data-page-title":j.routeName,class:`text-2xl font-bold text-fg`},u(j.title),9,C),g(`p`,w,u(c.$t(`resource.index.total`,{count:j.items.total})),1)]),g(`div`,T,[(r(!0),h(m,null,i(j.links,e=>(r(),a(v,{key:e.name,"data-link":e.name,href:e.href,variant:`secondary`},{default:s(()=>[o(u(e.label),1)]),_:2},1032,[`data-link`,`href`]))),128)),j.can.create===!1?e(``,!0):(r(),a(v,{key:0,"data-action":`create`,href:c.route(`${M.routeName}.create`,l(N))},{default:s(()=>[p[3]||=g(`svg`,{class:`w-4 h-4 mr-2`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`},[g(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M12 4v16m8-8H4`})],-1),o(` `+u(c.$t(`common.create`)),1)]),_:1},8,[`href`]))])]),g(`div`,E,[g(`div`,D,[g(`div`,O,[n(g(`input`,{"onUpdate:modelValue":p[0]||=e=>F.value=e,type:`text`,placeholder:c.$t(`resource.index.search_placeholder`),"data-search-input":`true`,class:`w-full px-4 py-2 border border-field rounded-lg focus:ring-focus focus:border-focus`,onKeyup:d(R,[`enter`])},null,40,k),[[f,F.value]])]),t(v,{"data-action":`search`,onClick:R,variant:`secondary`},{default:s(()=>[o(u(c.$t(`resource.index.search_button`)),1)]),_:1})])]),t(y,{columns:j.columns,items:j.items,"sort-by":j.filters.sort,"sort-direction":j.filters.direction,"can-delete":j.can.delete!==!1,"row-actions":l(P),onSort:z,onEdit:B,onDelete:V},null,8,[`columns`,`items`,`sort-by`,`sort-direction`,`can-delete`,`row-actions`]),t(b,{show:I.value,title:c.$t(`resource.delete.title`),onClose:p[2]||=e=>I.value=!1},{footer:s(()=>[t(v,{"data-action":`delete-cancel`,variant:`secondary`,onClick:p[1]||=e=>I.value=!1},{default:s(()=>[o(u(c.$t(`common.cancel`)),1)]),_:1}),t(v,{"data-action":`delete-confirm`,variant:`danger`,onClick:H},{default:s(()=>[o(u(c.$t(`common.delete`)),1)]),_:1})]),default:s(()=>[g(`p`,A,u(c.$t(`resource.delete.confirm`)),1)]),_:1},8,[`show`,`title`])]),_:1},8,[`title`]))}};export{j as default}; \ No newline at end of file diff --git a/packages/admin/dist/assets/Index-DEbfZBFs.js b/packages/admin/dist/assets/Index-DEbfZBFs.js deleted file mode 100644 index 003ae54d..00000000 --- a/packages/admin/dist/assets/Index-DEbfZBFs.js +++ /dev/null @@ -1 +0,0 @@ -import{C as e,E as t,G as n,I as r,S as i,T as a,W as o,Y as s,et as c,g as l,m as u,s as d,w as f,x as p}from"./dist-MY__znoP.js";import{t as m}from"./AdminLayout--RXJFj9t.js";import{t as h}from"./AdminButton-Bx141Bs3.js";import{t as g}from"./AdminDataTable-BaQwb_6U.js";import{t as _}from"./AdminModal-DNJ_V4iq.js";var v={class:`mb-6 flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4`},y={class:`text-2xl font-bold text-fg`},b={class:`mt-1 text-sm text-muted`},x={class:`mb-6`},S={class:`flex gap-4`},C={class:`flex-1 max-w-md`},w=[`placeholder`],T={class:`text-muted`},E={key:0},D={class:`mt-2 text-sm text-danger`},O={__name:`Index`,props:{items:Object,columns:Array,filters:Object,title:String,can:{type:Object,default:()=>({})}},setup(O){let k=O,A=s(k.filters.search||``),j=s(!1),M=s(null),N=()=>{d.get(route(`admin.users.index`),{search:A.value},{preserveState:!0,preserveScroll:!0})},P=({column:e,direction:t})=>{d.get(route(`admin.users.index`),{...k.filters,sort:e,direction:t},{preserveState:!0,preserveScroll:!0})},F=e=>{d.visit(route(`admin.users.edit`,e.id))},I=e=>{M.value=e,j.value=!0},L=()=>{M.value&&d.delete(route(`admin.users.destroy`,M.value.id),{onSuccess:()=>{j.value=!1,M.value=null}})};return(s,d)=>(r(),i(m,{title:O.title},{default:o(()=>[p(`div`,v,[p(`div`,null,[p(`h1`,y,c(O.title),1),p(`p`,b,c(s.$t(`account.users.total`,{count:O.items.total})),1)]),O.can.create===!1?e(``,!0):(r(),i(h,{key:0,"data-action":`create`,href:s.route(`admin.users.create`)},{default:o(()=>[d[3]||=p(`svg`,{class:`w-4 h-4 mr-2`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`},[p(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M12 4v16m8-8H4`})],-1),a(` `+c(s.$t(`common.create`)),1)]),_:1},8,[`href`]))]),p(`div`,x,[p(`div`,S,[p(`div`,C,[n(p(`input`,{"onUpdate:modelValue":d[0]||=e=>A.value=e,type:`text`,placeholder:s.$t(`account.users.search_placeholder`),class:`w-full px-4 py-2 border border-field rounded-lg focus:ring-focus focus:border-focus`,onKeyup:l(N,[`enter`])},null,40,w),[[u,A.value]])]),t(h,{onClick:N,variant:`secondary`},{default:o(()=>[a(c(s.$t(`common.search`)),1)]),_:1})])]),t(g,{columns:O.columns,items:O.items,"sort-by":O.filters.sort,"sort-direction":O.filters.direction,"can-delete":O.can.delete!==!1,onSort:P,onEdit:F,onDelete:I},null,8,[`columns`,`items`,`sort-by`,`sort-direction`,`can-delete`]),t(_,{show:j.value,title:s.$t(`account.users.delete_title`),onClose:d[2]||=e=>j.value=!1},{footer:o(()=>[t(h,{variant:`secondary`,onClick:d[1]||=e=>j.value=!1},{default:o(()=>[a(c(s.$t(`common.cancel`)),1)]),_:1}),t(h,{variant:`danger`,onClick:L},{default:o(()=>[a(c(s.$t(`common.delete`)),1)]),_:1})]),default:o(()=>[p(`p`,T,[a(c(s.$t(`account.users.delete_confirm`))+` `,1),M.value?(r(),f(`strong`,E,c(M.value.name),1)):e(``,!0)]),p(`p`,D,c(s.$t(`account.users.delete_irreversible`)),1)]),_:1},8,[`show`,`title`])]),_:1},8,[`title`]))}};export{O as default}; \ No newline at end of file diff --git a/packages/admin/dist/assets/Index-D_2Ij5S1.js b/packages/admin/dist/assets/Index-D_2Ij5S1.js new file mode 100644 index 00000000..af1c68ae --- /dev/null +++ b/packages/admin/dist/assets/Index-D_2Ij5S1.js @@ -0,0 +1 @@ +import{$ as e,C as t,E as n,G as r,I as i,Q as ee,R as a,S as o,T as s,W as c,Y as te,_ as ne,b as l,i as re,m as u,o as ie,p as d,s as f,tt as p,v as m,w as h,x as g}from"./dist-Bie52OmN.js";import{t as ae}from"./AdminLayout-DBeSErmz.js";import{t as _}from"./AdminButton-KiIJ2sLW.js";import{t as v}from"./AdminPagination-D7rwNfhd.js";var y={class:`mb-6`},b={class:`text-2xl font-bold text-fg`},x={class:`mt-1 text-sm text-muted`},S=[`aria-label`],C=[`aria-pressed`,`dusk`,`onClick`],w={class:`sm:col-span-2 text-sm text-fg`},T={class:`sr-only`},E=[`placeholder`],D={class:`text-sm text-fg`},O={class:`block mb-1 text-muted`},k={value:``},A=[`value`],j={class:`text-sm text-fg`},M={class:`block mb-1 text-muted`},N={value:``},P=[`value`],F={class:`text-sm text-fg`},I={class:`block mb-1 text-muted`},L={value:``},R=[`value`],z={class:`text-sm text-fg`},B={class:`block mb-1 text-muted`},V={value:``},H=[`value`],U={class:`text-sm text-fg`},W={class:`block mb-1 text-muted`},G=[`placeholder`],oe={class:`text-sm text-fg`},K={class:`block mb-1 text-muted`},q=[`value`],se={class:`sm:col-span-2 lg:col-span-4 flex gap-2`},ce={class:`bg-surface rounded-lg shadow overflow-hidden`},le={key:0,class:`px-6 py-10 text-center text-sm text-muted`,dusk:`errors-empty`},ue={key:1,class:`min-w-full divide-y divide-line text-sm`,dusk:`errors-table`},de={class:`bg-surface-alt`},fe={scope:`col`,class:`px-4 py-3 text-left font-medium text-fg`},pe={scope:`col`,class:`px-4 py-3 text-left font-medium text-fg`},me={scope:`col`,class:`px-4 py-3 text-right font-medium text-fg`},he={scope:`col`,class:`px-4 py-3 text-right font-medium text-fg`},ge={scope:`col`,class:`px-4 py-3 text-left font-medium text-fg`},_e={class:`divide-y divide-line`},ve={class:`px-4 py-3 max-w-xl`},ye={key:0,class:`ml-2 inline-block px-1.5 py-0.5 rounded text-xs bg-off text-off-fg`},be={class:`mt-0.5 text-fg break-words`},xe={key:1,class:`mt-0.5 text-xs text-muted font-mono break-all`},Se={class:`px-4 py-3 whitespace-nowrap text-fg`},Ce={class:`block text-xs text-muted`},we={class:`px-4 py-3 text-right tabular-nums text-fg`},Te={class:`px-4 py-3 text-right tabular-nums text-fg`},J={class:`px-4 py-3 whitespace-nowrap text-fg`},Ee={key:0,class:`block text-xs text-muted`},Y=`block w-full rounded-md border border-field bg-surface text-fg text-sm px-3 py-2 focus:outline-none focus:ring-2 focus:ring-focus`,X={__name:`Index`,props:{issues:{type:Object,required:!0},filters:{type:Object,required:!0},options:{type:Object,required:!0},strings:{type:Object,required:!0}},setup(X){let Z=X,De=ie(),Oe=l(()=>String(De.props.locale||`en`).replace(`_`,`-`)),Q=te({...Z.filters,site:Z.filters.site??``}),ke=l(()=>[...Z.options.statuses,`all`]);function $(){let e=Object.fromEntries(Object.entries(Q).filter(([,e])=>e!==``&&e!==null));f.get(route(`admin.errors.index`),e,{preserveState:!0,preserveScroll:!0})}function Ae(e){Q.status=e,$()}function je(){f.get(route(`admin.errors.index`))}function Me(e){return e?new Date(e).toLocaleString(Oe.value,{dateStyle:`medium`,timeStyle:`short`}):Z.strings.issue.none}return(te,l)=>(i(),o(ae,{title:X.strings.title},{default:c(()=>[g(`div`,y,[g(`h1`,b,p(X.strings.title),1),g(`p`,x,p(X.strings.subtitle),1)]),g(`nav`,{class:`mb-4 flex flex-wrap gap-2`,"aria-label":X.strings.list.status},[(i(!0),h(m,null,a(ke.value,t=>(i(),h(`button`,{key:t,type:`button`,class:e([`px-3 py-1.5 rounded-md text-sm font-medium border`,Q.status===t?`bg-accent text-on-accent border-accent`:`bg-surface text-fg border-field hover:bg-hover`]),"aria-pressed":Q.status===t,dusk:`errors-status-${t}`,onClick:e=>Ae(t)},p(X.strings.statuses[t]),11,C))),128))],8,S),g(`form`,{class:`bg-surface rounded-lg shadow p-4 mb-6 grid gap-3 sm:grid-cols-2 lg:grid-cols-4`,dusk:`errors-filters`,onSubmit:ne($,[`prevent`])},[g(`label`,w,[g(`span`,T,p(X.strings.list.search),1),r(g(`input`,{"onUpdate:modelValue":l[0]||=e=>Q.q=e,type:`search`,placeholder:X.strings.list.search,class:e(Y),dusk:`errors-search`},null,8,E),[[u,Q.q]])]),g(`label`,D,[g(`span`,O,p(X.strings.list.site),1),r(g(`select`,{"onUpdate:modelValue":l[1]||=e=>Q.site=e,class:e(Y),dusk:`errors-site`},[g(`option`,k,p(X.strings.list.all_sites),1),(i(!0),h(m,null,a(X.options.sites,e=>(i(),h(`option`,{key:e.id,value:e.id},p(e.name),9,A))),128))],512),[[d,Q.site]])]),g(`label`,j,[g(`span`,M,p(X.strings.list.release),1),r(g(`select`,{"onUpdate:modelValue":l[2]||=e=>Q.release=e,class:e(Y),dusk:`errors-release`},[g(`option`,N,p(X.strings.list.any_release),1),(i(!0),h(m,null,a(X.options.releases,e=>(i(),h(`option`,{key:e,value:e},p(e),9,P))),128))],512),[[d,Q.release]])]),g(`label`,F,[g(`span`,I,p(X.strings.list.level),1),r(g(`select`,{"onUpdate:modelValue":l[3]||=e=>Q.level=e,class:e(Y),dusk:`errors-level`},[g(`option`,L,p(X.strings.list.any_level),1),(i(!0),h(m,null,a(X.options.levels,e=>(i(),h(`option`,{key:e,value:e},p(X.strings.levels[e]),9,R))),128))],512),[[d,Q.level]])]),g(`label`,z,[g(`span`,B,p(X.strings.list.kind),1),r(g(`select`,{"onUpdate:modelValue":l[4]||=e=>Q.kind=e,class:e(Y),dusk:`errors-kind`},[g(`option`,V,p(X.strings.list.any_kind),1),(i(!0),h(m,null,a(X.options.kinds,e=>(i(),h(`option`,{key:e,value:e},p(X.strings.kinds[e]),9,H))),128))],512),[[d,Q.kind]])]),g(`label`,U,[g(`span`,W,p(X.strings.list.path),1),r(g(`input`,{"onUpdate:modelValue":l[5]||=e=>Q.path=e,type:`text`,placeholder:X.strings.list.path_placeholder,class:e(Y),dusk:`errors-path`},null,8,G),[[u,Q.path]])]),g(`label`,oe,[g(`span`,K,p(X.strings.list.sort),1),r(g(`select`,{"onUpdate:modelValue":l[6]||=e=>Q.sort=e,class:e(Y),dusk:`errors-sort`},[(i(!0),h(m,null,a(X.strings.list.sorts,(e,t)=>(i(),h(`option`,{key:t,value:t},p(e),9,q))),128))],512),[[d,Q.sort]])]),g(`div`,se,[n(_,{type:`submit`,dusk:`errors-apply`},{default:c(()=>[s(p(X.strings.list.filter),1)]),_:1}),n(_,{type:`button`,variant:`secondary`,dusk:`errors-reset`,onClick:je},{default:c(()=>[s(p(X.strings.list.reset),1)]),_:1})])],32),g(`div`,ce,[X.issues.data.length?(i(),h(`table`,ue,[g(`thead`,de,[g(`tr`,null,[g(`th`,fe,p(X.strings.list.issue),1),g(`th`,pe,p(X.strings.list.level),1),g(`th`,me,p(X.strings.list.events),1),g(`th`,he,p(X.strings.list.users),1),g(`th`,ge,p(X.strings.list.last_seen),1)])]),g(`tbody`,_e,[(i(!0),h(m,null,a(X.issues.data,e=>(i(),h(`tr`,{key:e.id,class:`hover:bg-hover`,dusk:`errors-row`},[g(`td`,ve,[n(ee(re),{href:e.url,class:`font-semibold text-accent hover:text-accent-hover hover:underline`,dusk:`errors-open`},{default:c(()=>[s(p(e.short_class),1)]),_:2},1032,[`href`]),e.status===`new`?t(``,!0):(i(),h(`span`,ye,p(X.strings.statuses[e.status]),1)),g(`p`,be,p(e.title),1),e.culprit?(i(),h(`p`,xe,p(e.culprit),1)):t(``,!0)]),g(`td`,Se,[s(p(X.strings.levels[e.level]??e.level)+` `,1),g(`span`,Ce,p(X.strings.kinds[e.kind]??e.kind),1)]),g(`td`,we,p(e.times_seen),1),g(`td`,Te,p(e.users_seen),1),g(`td`,J,[s(p(Me(e.last_seen_at))+` `,1),e.last_release?(i(),h(`span`,Ee,p(e.last_release),1)):t(``,!0)])]))),128))])])):(i(),h(`p`,le,p(X.strings.list.empty),1)),X.issues.last_page>1?(i(),o(v,{key:2,paginator:X.issues},null,8,[`paginator`])):t(``,!0)])]),_:1},8,[`title`]))}};export{X as default}; \ No newline at end of file diff --git a/packages/admin/dist/assets/Index-DaeZ92GY.js b/packages/admin/dist/assets/Index-DaeZ92GY.js new file mode 100644 index 00000000..13f5a18b --- /dev/null +++ b/packages/admin/dist/assets/Index-DaeZ92GY.js @@ -0,0 +1 @@ +import{C as e,E as t,G as n,I as r,Q as i,R as a,S as o,T as s,W as c,X as l,g as u,m as d,s as f,tt as p,v as m,w as h,x as g}from"./dist-Bie52OmN.js";import{t as _}from"./AdminLayout-DBeSErmz.js";import{t as v}from"./AdminButton-KiIJ2sLW.js";import{t as y}from"./AdminDataTable-6eKgKDeA.js";import{t as b}from"./AdminModal-DKazeNNa.js";import{t as x}from"./recordActions-CtRs42tG.js";var S={class:`mb-6 flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4`},C=[`data-page-title`],w={class:`mt-1 text-sm text-muted`},T={class:`flex flex-wrap items-center gap-2`},E={class:`mb-6`},D={class:`flex gap-4`},O={class:`flex-1 max-w-md`},k=[`placeholder`],A={class:`text-muted`},j={__name:`Index`,props:{routeName:String,createLabel:String,items:Object,columns:Array,filters:Object,title:String,can:{type:Object,default:()=>({})},actions:{type:Array,default:()=>[]},links:{type:Array,default:()=>[]}},setup(j){let M=j,N=Object.fromEntries(Object.entries(M.filters||{}).filter(([e])=>![`search`,`sort`,`direction`].includes(e))),P=M.actions.map(e=>({...e,href:t=>x(M.routeName,e,t)})),F=l(M.filters.search||``),I=l(!1),L=l(null),R=()=>{f.get(route(`${M.routeName}.index`),{...N,search:F.value},{preserveState:!0,preserveScroll:!0})},z=({column:e,direction:t})=>{f.get(route(`${M.routeName}.index`),{...M.filters,sort:e,direction:t},{preserveState:!0,preserveScroll:!0})},B=e=>{f.visit(route(`${M.routeName}.edit`,e.id))},V=e=>{L.value=e,I.value=!0},H=()=>{L.value&&f.delete(route(`${M.routeName}.destroy`,L.value.id),{onSuccess:()=>{I.value=!1,L.value=null}})};return(l,f)=>(r(),o(_,{title:j.title},{default:c(()=>[g(`div`,S,[g(`div`,null,[g(`h1`,{"data-page-title":j.routeName,class:`text-2xl font-bold text-fg`},p(j.title),9,C),g(`p`,w,p(l.$t(`resource.index.total`,{count:j.items.total})),1)]),g(`div`,T,[(r(!0),h(m,null,a(j.links,e=>(r(),o(v,{key:e.name,"data-link":e.name,href:e.href,variant:`secondary`},{default:c(()=>[s(p(e.label),1)]),_:2},1032,[`data-link`,`href`]))),128)),j.can.create===!1?e(``,!0):(r(),o(v,{key:0,"data-action":`create`,href:l.route(`${M.routeName}.create`,i(N))},{default:c(()=>[f[3]||=g(`svg`,{class:`w-4 h-4 mr-2`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`},[g(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M12 4v16m8-8H4`})],-1),s(` `+p(l.$t(`common.create`)),1)]),_:1},8,[`href`]))])]),g(`div`,E,[g(`div`,D,[g(`div`,O,[n(g(`input`,{"onUpdate:modelValue":f[0]||=e=>F.value=e,type:`text`,placeholder:l.$t(`resource.index.search_placeholder`),"data-search-input":`true`,class:`w-full px-4 py-2 border border-field rounded-lg focus:ring-focus focus:border-focus`,onKeyup:u(R,[`enter`])},null,40,k),[[d,F.value]])]),t(v,{"data-action":`search`,onClick:R,variant:`secondary`},{default:c(()=>[s(p(l.$t(`resource.index.search_button`)),1)]),_:1})])]),t(y,{columns:j.columns,items:j.items,"sort-by":j.filters.sort,"sort-direction":j.filters.direction,"can-delete":j.can.delete!==!1,"row-actions":i(P),onSort:z,onEdit:B,onDelete:V},null,8,[`columns`,`items`,`sort-by`,`sort-direction`,`can-delete`,`row-actions`]),t(b,{show:I.value,title:l.$t(`resource.delete.title`),onClose:f[2]||=e=>I.value=!1},{footer:c(()=>[t(v,{"data-action":`delete-cancel`,variant:`secondary`,onClick:f[1]||=e=>I.value=!1},{default:c(()=>[s(p(l.$t(`common.cancel`)),1)]),_:1}),t(v,{"data-action":`delete-confirm`,variant:`danger`,onClick:H},{default:c(()=>[s(p(l.$t(`common.delete`)),1)]),_:1})]),default:c(()=>[g(`p`,A,p(l.$t(`resource.delete.confirm`)),1)]),_:1},8,[`show`,`title`])]),_:1},8,[`title`]))}};export{j as default}; \ No newline at end of file diff --git a/packages/admin/dist/assets/Index-DsLgvcm0.js b/packages/admin/dist/assets/Index-DsLgvcm0.js new file mode 100644 index 00000000..3712e2c2 --- /dev/null +++ b/packages/admin/dist/assets/Index-DsLgvcm0.js @@ -0,0 +1 @@ +import{$ as e,C as t,E as n,G as r,I as i,R as a,S as o,T as s,W as c,X as l,p as u,s as d,tt as f,v as p,w as m,x as h}from"./dist-Bie52OmN.js";import{t as g}from"./AdminLayout-DBeSErmz.js";import{t as _}from"./AdminButton-KiIJ2sLW.js";var v={class:`mb-6`},ee={"data-page-title":`admin.cache`,class:`text-2xl font-bold text-gray-900`},y={class:`mt-1 text-sm text-gray-600`},b={class:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4 mb-6`},x={class:`bg-white rounded-lg shadow p-4`,"data-cache-stat":`rate`},S={class:`text-sm text-gray-600`},C={class:`mt-1 text-2xl font-semibold text-gray-900`},w={class:`mt-1 text-xs text-gray-500`},T={class:`bg-white rounded-lg shadow p-4`,"data-cache-stat":`size`},E={class:`text-sm text-gray-600`},D={class:`mt-1 text-2xl font-semibold text-gray-900`},O={class:`mt-1 text-xs text-gray-500`},k={class:`bg-white rounded-lg shadow p-4`,"data-cache-stat":`store`},A={class:`text-sm text-gray-600`},j={class:`mt-1 text-2xl font-semibold text-gray-900`},M={class:`mt-1 text-xs text-gray-500`},N={class:`bg-white rounded-lg shadow p-4`,"data-cache-stat":`state`},P={class:`text-sm text-gray-600`},F={class:`mt-1 text-xs text-gray-500`},I={class:`bg-white rounded-lg shadow p-6 space-y-6`},L={class:`text-sm text-gray-600`},R={key:0,class:`flex flex-col sm:flex-row sm:items-end gap-3`},z={class:`flex-1`},B={class:`block text-sm font-medium text-gray-700 mb-1`},V=[`value`],H={key:1,class:`flex flex-col sm:flex-row sm:items-end gap-3`},U={class:`flex-1`},W={class:`block text-sm font-medium text-gray-700 mb-1`},G=[`value`],K={class:`flex flex-wrap gap-3 pt-2 border-t border-gray-100`},q={__name:`Index`,props:{status:Object,modules:Array,sites:Array},setup(q){let J=q,Y=l(J.modules[0]?.key??``),X=l(J.sites[0]?.id??``),Z=l(!1),Q=(e,t={})=>{Z.value=!0,d.post(route(`admin.cache.clear`),{scope:e,...t},{preserveScroll:!0,onFinish:()=>{Z.value=!1}})},$=e=>e==null?`—`:new Intl.NumberFormat().format(e),te=e=>{if(e==null)return`—`;let t=[`B`,`KB`,`MB`,`GB`],n=e,r=0;for(;n>=1024&&r(i(),o(g,{title:l.$t(`menu.cache`)},{default:c(()=>[h(`div`,v,[h(`h1`,ee,f(l.$t(`menu.cache`)),1),h(`p`,y,f(l.$t(`cache.subtitle`)),1)]),h(`div`,b,[h(`div`,x,[h(`div`,S,f(l.$t(`cache.hit_rate`)),1),h(`div`,C,f(q.status.rate===null?`—`:`${q.status.rate}%`),1),h(`div`,w,f(l.$t(`cache.hits`))+`: `+f($(q.status.hits))+` · `+f(l.$t(`cache.misses`))+`: `+f($(q.status.misses)),1)]),h(`div`,T,[h(`div`,E,f(l.$t(`cache.size`)),1),h(`div`,D,f(te(q.status.bytes)),1),h(`div`,O,f(l.$t(`cache.entries`))+`: `+f($(q.status.entries)),1)]),h(`div`,k,[h(`div`,A,f(l.$t(`cache.store`)),1),h(`div`,j,f(q.status.driver),1),h(`div`,M,f(q.status.tags?l.$t(`cache.with_tags`):l.$t(`cache.without_tags`)),1)]),h(`div`,N,[h(`div`,P,f(l.$t(`cache.records`)),1),h(`div`,{class:e([`mt-1 text-2xl font-semibold`,q.status.enabled?`text-green-700`:`text-gray-500`])},f(q.status.enabled?l.$t(`cache.on`):l.$t(`cache.off`)),3),h(`div`,F,f(l.$t(`cache.pages`))+`: `+f(q.status.pages?l.$t(`cache.on`):l.$t(`cache.off`)),1)])]),h(`div`,I,[h(`p`,L,f(l.$t(`cache.clear_hint`)),1),q.modules.length?(i(),m(`div`,R,[h(`label`,z,[h(`span`,B,f(l.$t(`cache.module`)),1),r(h(`select`,{"onUpdate:modelValue":d[0]||=e=>Y.value=e,"data-cache-module":``,class:`w-full rounded-md border-gray-300 text-sm`},[(i(!0),m(p,null,a(q.modules,e=>(i(),m(`option`,{key:e.key,value:e.key},f(e.label),9,V))),128))],512),[[u,Y.value]])]),n(_,{variant:`outline`,"data-action":`clear-module`,disabled:Z.value,onClick:d[1]||=e=>Q(`module`,{module:Y.value})},{default:c(()=>[s(f(l.$t(`cache.clear_module`)),1)]),_:1},8,[`disabled`])])):t(``,!0),q.sites.length>1?(i(),m(`div`,H,[h(`label`,U,[h(`span`,W,f(l.$t(`cache.site`)),1),r(h(`select`,{"onUpdate:modelValue":d[2]||=e=>X.value=e,"data-cache-site":``,class:`w-full rounded-md border-gray-300 text-sm`},[(i(!0),m(p,null,a(q.sites,e=>(i(),m(`option`,{key:e.id,value:e.id},f(e.name),9,G))),128))],512),[[u,X.value]])]),n(_,{variant:`outline`,"data-action":`clear-site`,disabled:Z.value,onClick:d[3]||=e=>Q(`site`,{site:X.value})},{default:c(()=>[s(f(l.$t(`cache.clear_site`)),1)]),_:1},8,[`disabled`])])):t(``,!0),h(`div`,K,[n(_,{variant:`danger`,"data-action":`clear-all`,disabled:Z.value,onClick:d[4]||=e=>Q(`all`)},{default:c(()=>[s(f(l.$t(`cache.clear_all`)),1)]),_:1},8,[`disabled`]),n(_,{variant:`secondary`,"data-action":`reset-stats`,disabled:Z.value,onClick:d[5]||=e=>Q(`stats`)},{default:c(()=>[s(f(l.$t(`cache.reset_stats`)),1)]),_:1},8,[`disabled`])])])]),_:1},8,[`title`]))}};export{q as default}; \ No newline at end of file diff --git a/packages/admin/dist/assets/Index-P5jX14JD.js b/packages/admin/dist/assets/Index-P5jX14JD.js deleted file mode 100644 index c28e70cc..00000000 --- a/packages/admin/dist/assets/Index-P5jX14JD.js +++ /dev/null @@ -1 +0,0 @@ -import{E as e,I as t,R as n,S as r,T as i,W as a,Y as o,et as s,s as c,v as l,w as u,x as d}from"./dist-MY__znoP.js";import{t as f}from"./AdminLayout--RXJFj9t.js";import{t as p}from"./AdminButton-Bx141Bs3.js";import{t as m}from"./AdminModal-DNJ_V4iq.js";var h={class:`mb-6 flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4`},g={"data-page-title":`admin.roles`,class:`text-2xl font-bold text-fg`},_={class:`mt-1 text-sm text-muted`},v={class:`bg-surface rounded-lg shadow overflow-hidden`},y={key:0,class:`p-6 text-sm text-muted`},b={key:1,class:`min-w-full text-sm`},x={class:`bg-surface-alt`},S={class:`px-4 py-2 text-left font-medium text-fg`},C={class:`px-4 py-2 text-left font-medium text-fg`},w={class:`px-4 py-2 text-left font-medium text-fg`},T={class:`divide-y divide-line`},E={class:`px-4 py-2 font-medium text-fg`},D={class:`px-4 py-2 text-fg`},O={class:`px-4 py-2 text-fg`},k={class:`px-4 py-2 text-right whitespace-nowrap`},A={class:`text-muted`},j={__name:`Index`,props:{roles:Array,title:String},setup(j){let M=o(null),N=()=>{c.delete(route(`admin.roles.destroy`,M.value.id),{preserveScroll:!0,onFinish:()=>{M.value=null}})};return(o,c)=>(t(),r(f,{title:j.title},{default:a(()=>[d(`div`,h,[d(`div`,null,[d(`h1`,g,s(j.title),1),d(`p`,_,s(o.$t(`permissions.index_hint`)),1)]),e(p,{"data-action":`create`,href:o.route(`admin.roles.create`)},{default:a(()=>[c[2]||=d(`svg`,{class:`w-4 h-4 mr-2`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`},[d(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M12 4v16m8-8H4`})],-1),i(` `+s(o.$t(`common.create`)),1)]),_:1},8,[`href`])]),d(`div`,v,[j.roles.length===0?(t(),u(`p`,y,s(o.$t(`permissions.empty`)),1)):(t(),u(`table`,b,[d(`thead`,x,[d(`tr`,null,[d(`th`,S,s(o.$t(`permissions.name`)),1),d(`th`,C,s(o.$t(`permissions.permissions_count`)),1),d(`th`,w,s(o.$t(`permissions.users_count`)),1),c[3]||=d(`th`,{class:`px-4 py-2`},null,-1)])]),d(`tbody`,T,[(t(!0),u(l,null,n(j.roles,n=>(t(),u(`tr`,{key:n.id,"data-role-row":``},[d(`td`,E,s(n.name),1),d(`td`,D,s(n.permissions_count),1),d(`td`,O,s(n.users_count),1),d(`td`,k,[e(p,{size:`sm`,variant:`outline`,"data-action":`edit`,href:o.route(`admin.roles.edit`,n.id)},{default:a(()=>[i(s(o.$t(`common.edit`)),1)]),_:1},8,[`href`]),e(p,{size:`sm`,variant:`danger`,"data-action":`delete`,class:`ml-2`,onClick:e=>M.value=n},{default:a(()=>[i(s(o.$t(`common.delete`)),1)]),_:1},8,[`onClick`])])]))),128))])]))]),e(m,{show:M.value!==null,title:o.$t(`permissions.delete_title`),onClose:c[1]||=e=>M.value=null},{footer:a(()=>[e(p,{variant:`secondary`,onClick:c[0]||=e=>M.value=null},{default:a(()=>[i(s(o.$t(`common.cancel`)),1)]),_:1}),e(p,{variant:`danger`,"data-action":`delete-confirm`,onClick:N},{default:a(()=>[i(s(o.$t(`common.delete`)),1)]),_:1})]),default:a(()=>[d(`p`,A,[d(`strong`,null,s(M.value?.name),1),i(` — `+s(o.$t(`permissions.delete_confirm`)),1)])]),_:1},8,[`show`,`title`])]),_:1},8,[`title`]))}};export{j as default}; \ No newline at end of file diff --git a/packages/admin/dist/assets/Index-C_p9UH4T.js b/packages/admin/dist/assets/Index-ZYMbBsuF.js similarity index 50% rename from packages/admin/dist/assets/Index-C_p9UH4T.js rename to packages/admin/dist/assets/Index-ZYMbBsuF.js index 82fcf859..93e05ab1 100644 --- a/packages/admin/dist/assets/Index-C_p9UH4T.js +++ b/packages/admin/dist/assets/Index-ZYMbBsuF.js @@ -1 +1 @@ -import{C as e,E as t,G as n,I as r,R as i,S as a,T as o,W as s,Y as c,Z as l,_ as ee,a as u,et as d,m as f,s as te,v as p,w as m,x as h}from"./dist-MY__znoP.js";import{t as g}from"./AdminLayout--RXJFj9t.js";import{n as ne}from"./app-BNjy5Z6H.js";import{t as _}from"./AdminButton-Bx141Bs3.js";import{t as v}from"./AdminCard--HubMtUj.js";import{t as re}from"./AdminModal-DNJ_V4iq.js";var ie={class:`space-y-6`},ae={key:0,"data-api-token-plain":``,class:`p-4 bg-warning-soft border-2 border-warning-soft-fg rounded-lg`},oe={class:`font-medium text-fg`},y={class:`mt-3 flex flex-col sm:flex-row gap-2`},b={class:`flex-1 px-3 py-2 bg-surface border border-field rounded font-mono text-sm break-all`},x={class:`space-y-1 text-sm`},S=[`href`],C=[`href`],w={class:`grid gap-4 sm:grid-cols-2`},T={for:`token-name`,class:`block text-sm font-medium text-fg`},E=[`placeholder`],D={key:0,class:`mt-1 text-sm text-danger`},O={for:`token-expires`,class:`block text-sm font-medium text-fg`},k={key:0,class:`mt-1 text-sm text-danger`},A={class:`flex flex-wrap items-center justify-between gap-2`},j={class:`text-sm font-medium text-fg`},M={class:`flex gap-2`},N={key:0,class:`mt-1 text-sm text-danger`},P={class:`mt-2 max-h-96 overflow-y-auto border border-line rounded-md`},F={class:`min-w-full text-sm`},I={class:`bg-surface-alt sticky top-0`},L={class:`px-3 py-2 text-left font-medium text-fg`},R={class:`px-3 py-2 w-24 text-center font-medium text-fg`},z={class:`px-3 py-2 w-24 text-center font-medium text-fg`},B={class:`divide-y divide-line`},V={class:`px-3 py-1.5`},H={class:`ml-1 text-xs text-muted font-mono`},U={class:`px-3 py-1.5 text-center`},W=[`aria-label`,`checked`,`onChange`],G={class:`px-3 py-1.5 text-center`},K=[`aria-label`,`checked`,`onChange`],se={class:`flex justify-end`},ce={key:0,class:`p-6 text-sm text-muted`},le={key:1,class:`overflow-x-auto`},ue={class:`min-w-full text-sm`},de={class:`bg-surface-alt`},fe={class:`px-4 py-2 text-left font-medium text-fg`},pe={class:`px-4 py-2 text-left font-medium text-fg`},me={class:`px-4 py-2 text-left font-medium text-fg`},he={class:`px-4 py-2 text-left font-medium text-fg`},ge={class:`px-4 py-2 text-left font-medium text-fg`},_e={class:`divide-y divide-line`},ve={class:`px-4 py-2 font-medium text-fg`},ye={class:`px-4 py-2 text-fg`},be={class:`cursor-pointer`},xe={class:`mt-1 space-y-0.5`},Se={class:`px-4 py-2 text-fg`},Ce={class:`text-xs text-muted`},we={class:`px-4 py-2 text-fg`},Te={class:`px-4 py-2 text-fg`},Ee={key:0,class:`font-medium`},q={class:`px-4 py-2 text-right`},De={class:`text-muted`},J={__name:`ApiTokensManager`,props:{tokens:{type:Array,required:!0},modules:{type:Array,required:!0},plainToken:{type:String,default:null},docsUrl:{type:String,required:!0},openApiUrl:{type:String,required:!0}},setup(a){let g=a,J=u({name:``,abilities:[],expires_at:``}),Y=c(!1),X=c(null),Z=e=>J.abilities.includes(e),Q=(e,t)=>{let n=`${e}:${t}`,r=new Set(J.abilities);r.has(n)?(r.delete(n),t===`read`&&r.delete(`${e}:write`)):(r.add(n),t===`write`&&r.add(`${e}:read`)),J.abilities=[...r]},$=e=>{let t=new Set(J.abilities);for(let n of g.modules)t.add(`${n.key}:read`),e===`write`&&n.writable&&t.add(`${n.key}:write`);J.abilities=[...t]},Oe=()=>{J.post(route(`admin.api-tokens.store`),{onSuccess:()=>J.reset()})},ke=async()=>{await navigator.clipboard.writeText(g.plainToken),Y.value=!0},Ae=()=>{te.delete(route(`admin.api-tokens.destroy`,X.value.id),{preserveScroll:!0,onFinish:()=>{X.value=null}})},je=e=>{let[t,n]=e.split(`:`),r=g.modules.find(e=>e.key===t);return ne(n===`write`?`account.api_tokens.ability_write`:`account.api_tokens.ability_read`,{module:r?r.label:t})};return(c,u)=>(r(),m(`div`,ie,[a.plainToken?(r(),m(`div`,ae,[h(`p`,oe,d(c.$t(`account.api_tokens.plain_notice`)),1),h(`div`,y,[h(`code`,b,d(a.plainToken),1),t(_,{variant:`outline`,onClick:ke},{default:s(()=>[o(d(Y.value?c.$t(`common.copied`):c.$t(`common.copy`)),1)]),_:1})])])):e(``,!0),t(v,{title:c.$t(`account.api_tokens.docs_title`),subtitle:c.$t(`account.api_tokens.docs_subtitle`)},{default:s(()=>[h(`ul`,x,[h(`li`,null,[o(d(c.$t(`account.api_tokens.docs_page`))+` `,1),h(`a`,{href:a.docsUrl,target:`_blank`,class:`text-accent-hover underline break-all`},d(a.docsUrl),9,S)]),h(`li`,null,[o(d(c.$t(`account.api_tokens.openapi_schema`))+` `,1),h(`a`,{href:a.openApiUrl,target:`_blank`,class:`text-accent-hover underline break-all`},d(a.openApiUrl),9,C)])])]),_:1},8,[`title`,`subtitle`]),t(v,{title:c.$t(`account.api_tokens.create_title`)},{default:s(()=>[h(`form`,{class:`space-y-5`,onSubmit:ee(Oe,[`prevent`])},[h(`div`,w,[h(`div`,null,[h(`label`,T,d(c.$t(`account.api_tokens.name`)),1),n(h(`input`,{id:`token-name`,"onUpdate:modelValue":u[0]||=e=>l(J).name=e,type:`text`,placeholder:c.$t(`account.api_tokens.name_placeholder`),class:`mt-1 block w-full px-3 py-2 border border-field rounded-md shadow-sm focus:outline-none focus:ring-focus focus:border-focus sm:text-sm`},null,8,E),[[f,l(J).name]]),l(J).errors.name?(r(),m(`p`,D,d(l(J).errors.name),1)):e(``,!0)]),h(`div`,null,[h(`label`,O,d(c.$t(`account.api_tokens.expires_at`)),1),n(h(`input`,{id:`token-expires`,"onUpdate:modelValue":u[1]||=e=>l(J).expires_at=e,type:`date`,class:`mt-1 block w-full px-3 py-2 border border-field rounded-md shadow-sm focus:outline-none focus:ring-focus focus:border-focus sm:text-sm`},null,512),[[f,l(J).expires_at]]),l(J).errors.expires_at?(r(),m(`p`,k,d(l(J).errors.expires_at),1)):e(``,!0)])]),h(`div`,null,[h(`div`,A,[h(`span`,j,d(c.$t(`account.api_tokens.abilities`)),1),h(`div`,M,[t(_,{type:`button`,size:`sm`,variant:`outline`,onClick:u[2]||=e=>$(`read`)},{default:s(()=>[o(d(c.$t(`account.api_tokens.select_read_all`)),1)]),_:1}),t(_,{type:`button`,size:`sm`,variant:`outline`,onClick:u[3]||=e=>$(`write`)},{default:s(()=>[o(d(c.$t(`account.api_tokens.select_all`)),1)]),_:1}),t(_,{type:`button`,size:`sm`,variant:`outline`,onClick:u[4]||=e=>l(J).abilities=[]},{default:s(()=>[o(d(c.$t(`account.api_tokens.clear`)),1)]),_:1})])]),l(J).errors.abilities?(r(),m(`p`,N,d(l(J).errors.abilities),1)):e(``,!0),h(`div`,P,[h(`table`,F,[h(`thead`,I,[h(`tr`,null,[h(`th`,L,d(c.$t(`account.api_tokens.module`)),1),h(`th`,R,d(c.$t(`account.api_tokens.read`)),1),h(`th`,z,d(c.$t(`account.api_tokens.write`)),1)])]),h(`tbody`,B,[(r(!0),m(p,null,i(a.modules,t=>(r(),m(`tr`,{key:t.key},[h(`td`,V,[o(d(t.label)+` `,1),h(`span`,H,d(t.key),1)]),h(`td`,U,[h(`input`,{type:`checkbox`,class:`h-4 w-4`,"aria-label":c.$t(`account.api_tokens.ability_read`,{module:t.label}),checked:Z(`${t.key}:read`),onChange:e=>Q(t.key,`read`)},null,40,W)]),h(`td`,G,[t.writable?(r(),m(`input`,{key:0,type:`checkbox`,class:`h-4 w-4`,"aria-label":c.$t(`account.api_tokens.ability_write`,{module:t.label}),checked:Z(`${t.key}:write`),onChange:e=>Q(t.key,`write`)},null,40,K)):e(``,!0)])]))),128))])])])]),h(`div`,se,[t(_,{type:`submit`,loading:l(J).processing,disabled:l(J).processing},{default:s(()=>[o(d(c.$t(`account.api_tokens.submit`)),1)]),_:1},8,[`loading`,`disabled`])])],32)]),_:1},8,[`title`]),t(v,{title:c.$t(`account.api_tokens.list_title`),"no-padding":``},{default:s(()=>[a.tokens.length===0?(r(),m(`p`,ce,d(c.$t(`account.api_tokens.empty`)),1)):(r(),m(`div`,le,[h(`table`,ue,[h(`thead`,de,[h(`tr`,null,[h(`th`,fe,d(c.$t(`account.api_tokens.name`)),1),h(`th`,pe,d(c.$t(`account.api_tokens.abilities`)),1),h(`th`,me,d(c.$t(`account.api_tokens.owner`)),1),h(`th`,he,d(c.$t(`account.api_tokens.last_used`)),1),h(`th`,ge,d(c.$t(`account.api_tokens.expiry`)),1),u[7]||=h(`th`,{class:`px-4 py-2`},null,-1)])]),h(`tbody`,_e,[(r(!0),m(p,null,i(a.tokens,n=>(r(),m(`tr`,{key:n.id,"data-api-token-row":``},[h(`td`,ve,d(n.name),1),h(`td`,ye,[h(`details`,null,[h(`summary`,be,d(c.$tc(`account.api_tokens.abilities_count`,n.abilities.length)),1),h(`ul`,xe,[(r(!0),m(p,null,i(n.abilities,e=>(r(),m(`li`,{key:e},d(je(e)),1))),128))])])]),h(`td`,Se,[o(d(n.owner),1),h(`div`,Ce,d(n.created_at),1)]),h(`td`,we,d(n.last_used_at||c.$t(`account.api_tokens.never_used`)),1),h(`td`,Te,[n.expires_at?(r(),m(p,{key:0},[o(d(c.$t(`account.api_tokens.until`,{date:n.expires_at})),1),n.expired?(r(),m(`span`,Ee,d(c.$t(`account.api_tokens.expired`)),1)):e(``,!0)],64)):(r(),m(p,{key:1},[o(d(c.$t(`account.api_tokens.no_expiry`)),1)],64))]),h(`td`,q,[t(_,{size:`sm`,variant:`danger`,onClick:e=>X.value=n},{default:s(()=>[o(d(c.$t(`account.api_tokens.revoke`)),1)]),_:1},8,[`onClick`])])]))),128))])])]))]),_:1},8,[`title`]),t(re,{show:X.value!==null,title:c.$t(`account.api_tokens.revoke_title`),onClose:u[6]||=e=>X.value=null},{footer:s(()=>[t(_,{variant:`secondary`,onClick:u[5]||=e=>X.value=null},{default:s(()=>[o(d(c.$t(`common.cancel`)),1)]),_:1}),t(_,{variant:`danger`,onClick:Ae},{default:s(()=>[o(d(c.$t(`account.api_tokens.revoke`)),1)]),_:1})]),default:s(()=>[h(`p`,De,[o(d(c.$t(`account.api_tokens.revoke_confirm_before`))+` `,1),h(`strong`,null,d(X.value?.name),1),o(` `+d(c.$t(`account.api_tokens.revoke_confirm_after`)),1)])]),_:1},8,[`show`,`title`])]))}},Y={class:`mb-6`},X={class:`text-2xl font-bold text-fg`},Z={class:`mt-1 text-sm text-muted`},Q={__name:`Index`,props:{tokens:Array,modules:Array,plainToken:String,docsUrl:String,openApiUrl:String},setup(e){return(n,i)=>(r(),a(g,{title:n.$t(`menu.api_tokens`)},{default:s(()=>[h(`div`,Y,[h(`h1`,X,d(n.$t(`menu.api_tokens`)),1),h(`p`,Z,d(n.$t(`account.api_tokens.subtitle`)),1)]),t(J,{tokens:e.tokens,modules:e.modules,"plain-token":e.plainToken,"docs-url":e.docsUrl,"open-api-url":e.openApiUrl},null,8,[`tokens`,`modules`,`plain-token`,`docs-url`,`open-api-url`])]),_:1},8,[`title`]))}};export{Q as default}; \ No newline at end of file +import{C as e,E as t,G as n,I as r,Q as i,R as a,S as o,T as s,W as c,X as l,_ as ee,a as u,m as d,s as te,tt as f,v as p,w as m,x as h}from"./dist-Bie52OmN.js";import{t as g}from"./AdminLayout-DBeSErmz.js";import{n as ne}from"./app-BCJOqmKO.js";import{t as _}from"./AdminButton-KiIJ2sLW.js";import{t as v}from"./AdminCard-YbEwPtJz.js";import{t as re}from"./AdminModal-DKazeNNa.js";var ie={class:`space-y-6`},ae={key:0,"data-api-token-plain":``,class:`p-4 bg-warning-soft border-2 border-warning-soft-fg rounded-lg`},oe={class:`font-medium text-fg`},y={class:`mt-3 flex flex-col sm:flex-row gap-2`},b={class:`flex-1 px-3 py-2 bg-surface border border-field rounded font-mono text-sm break-all`},x={class:`space-y-1 text-sm`},S=[`href`],C=[`href`],w={class:`grid gap-4 sm:grid-cols-2`},T={for:`token-name`,class:`block text-sm font-medium text-fg`},E=[`placeholder`],D={key:0,class:`mt-1 text-sm text-danger`},O={for:`token-expires`,class:`block text-sm font-medium text-fg`},k={key:0,class:`mt-1 text-sm text-danger`},A={class:`flex flex-wrap items-center justify-between gap-2`},j={class:`text-sm font-medium text-fg`},M={class:`flex gap-2`},N={key:0,class:`mt-1 text-sm text-danger`},P={class:`mt-2 max-h-96 overflow-y-auto border border-line rounded-md`},F={class:`min-w-full text-sm`},I={class:`bg-surface-alt sticky top-0`},L={class:`px-3 py-2 text-left font-medium text-fg`},R={class:`px-3 py-2 w-24 text-center font-medium text-fg`},z={class:`px-3 py-2 w-24 text-center font-medium text-fg`},B={class:`divide-y divide-line`},V={class:`px-3 py-1.5`},H={class:`ml-1 text-xs text-muted font-mono`},U={class:`px-3 py-1.5 text-center`},W=[`aria-label`,`checked`,`onChange`],G={class:`px-3 py-1.5 text-center`},K=[`aria-label`,`checked`,`onChange`],se={class:`flex justify-end`},ce={key:0,class:`p-6 text-sm text-muted`},le={key:1,class:`overflow-x-auto`},ue={class:`min-w-full text-sm`},de={class:`bg-surface-alt`},fe={class:`px-4 py-2 text-left font-medium text-fg`},pe={class:`px-4 py-2 text-left font-medium text-fg`},me={class:`px-4 py-2 text-left font-medium text-fg`},he={class:`px-4 py-2 text-left font-medium text-fg`},ge={class:`px-4 py-2 text-left font-medium text-fg`},_e={class:`divide-y divide-line`},ve={class:`px-4 py-2 font-medium text-fg`},ye={class:`px-4 py-2 text-fg`},be={class:`cursor-pointer`},xe={class:`mt-1 space-y-0.5`},Se={class:`px-4 py-2 text-fg`},Ce={class:`text-xs text-muted`},we={class:`px-4 py-2 text-fg`},Te={class:`px-4 py-2 text-fg`},Ee={key:0,class:`font-medium`},q={class:`px-4 py-2 text-right`},De={class:`text-muted`},J={__name:`ApiTokensManager`,props:{tokens:{type:Array,required:!0},modules:{type:Array,required:!0},plainToken:{type:String,default:null},docsUrl:{type:String,required:!0},openApiUrl:{type:String,required:!0}},setup(o){let g=o,J=u({name:``,abilities:[],expires_at:``}),Y=l(!1),X=l(null),Z=e=>J.abilities.includes(e),Q=(e,t)=>{let n=`${e}:${t}`,r=new Set(J.abilities);r.has(n)?(r.delete(n),t===`read`&&r.delete(`${e}:write`)):(r.add(n),t===`write`&&r.add(`${e}:read`)),J.abilities=[...r]},$=e=>{let t=new Set(J.abilities);for(let n of g.modules)t.add(`${n.key}:read`),e===`write`&&n.writable&&t.add(`${n.key}:write`);J.abilities=[...t]},Oe=()=>{J.post(route(`admin.api-tokens.store`),{onSuccess:()=>J.reset()})},ke=async()=>{await navigator.clipboard.writeText(g.plainToken),Y.value=!0},Ae=()=>{te.delete(route(`admin.api-tokens.destroy`,X.value.id),{preserveScroll:!0,onFinish:()=>{X.value=null}})},je=e=>{let[t,n]=e.split(`:`),r=g.modules.find(e=>e.key===t);return ne(n===`write`?`account.api_tokens.ability_write`:`account.api_tokens.ability_read`,{module:r?r.label:t})};return(l,u)=>(r(),m(`div`,ie,[o.plainToken?(r(),m(`div`,ae,[h(`p`,oe,f(l.$t(`account.api_tokens.plain_notice`)),1),h(`div`,y,[h(`code`,b,f(o.plainToken),1),t(_,{variant:`outline`,onClick:ke},{default:c(()=>[s(f(Y.value?l.$t(`common.copied`):l.$t(`common.copy`)),1)]),_:1})])])):e(``,!0),t(v,{title:l.$t(`account.api_tokens.docs_title`),subtitle:l.$t(`account.api_tokens.docs_subtitle`)},{default:c(()=>[h(`ul`,x,[h(`li`,null,[s(f(l.$t(`account.api_tokens.docs_page`))+` `,1),h(`a`,{href:o.docsUrl,target:`_blank`,class:`text-accent-hover underline break-all`},f(o.docsUrl),9,S)]),h(`li`,null,[s(f(l.$t(`account.api_tokens.openapi_schema`))+` `,1),h(`a`,{href:o.openApiUrl,target:`_blank`,class:`text-accent-hover underline break-all`},f(o.openApiUrl),9,C)])])]),_:1},8,[`title`,`subtitle`]),t(v,{title:l.$t(`account.api_tokens.create_title`)},{default:c(()=>[h(`form`,{class:`space-y-5`,onSubmit:ee(Oe,[`prevent`])},[h(`div`,w,[h(`div`,null,[h(`label`,T,f(l.$t(`account.api_tokens.name`)),1),n(h(`input`,{id:`token-name`,"onUpdate:modelValue":u[0]||=e=>i(J).name=e,type:`text`,placeholder:l.$t(`account.api_tokens.name_placeholder`),class:`mt-1 block w-full px-3 py-2 border border-field rounded-md shadow-sm focus:outline-none focus:ring-focus focus:border-focus sm:text-sm`},null,8,E),[[d,i(J).name]]),i(J).errors.name?(r(),m(`p`,D,f(i(J).errors.name),1)):e(``,!0)]),h(`div`,null,[h(`label`,O,f(l.$t(`account.api_tokens.expires_at`)),1),n(h(`input`,{id:`token-expires`,"onUpdate:modelValue":u[1]||=e=>i(J).expires_at=e,type:`date`,class:`mt-1 block w-full px-3 py-2 border border-field rounded-md shadow-sm focus:outline-none focus:ring-focus focus:border-focus sm:text-sm`},null,512),[[d,i(J).expires_at]]),i(J).errors.expires_at?(r(),m(`p`,k,f(i(J).errors.expires_at),1)):e(``,!0)])]),h(`div`,null,[h(`div`,A,[h(`span`,j,f(l.$t(`account.api_tokens.abilities`)),1),h(`div`,M,[t(_,{type:`button`,size:`sm`,variant:`outline`,onClick:u[2]||=e=>$(`read`)},{default:c(()=>[s(f(l.$t(`account.api_tokens.select_read_all`)),1)]),_:1}),t(_,{type:`button`,size:`sm`,variant:`outline`,onClick:u[3]||=e=>$(`write`)},{default:c(()=>[s(f(l.$t(`account.api_tokens.select_all`)),1)]),_:1}),t(_,{type:`button`,size:`sm`,variant:`outline`,onClick:u[4]||=e=>i(J).abilities=[]},{default:c(()=>[s(f(l.$t(`account.api_tokens.clear`)),1)]),_:1})])]),i(J).errors.abilities?(r(),m(`p`,N,f(i(J).errors.abilities),1)):e(``,!0),h(`div`,P,[h(`table`,F,[h(`thead`,I,[h(`tr`,null,[h(`th`,L,f(l.$t(`account.api_tokens.module`)),1),h(`th`,R,f(l.$t(`account.api_tokens.read`)),1),h(`th`,z,f(l.$t(`account.api_tokens.write`)),1)])]),h(`tbody`,B,[(r(!0),m(p,null,a(o.modules,t=>(r(),m(`tr`,{key:t.key},[h(`td`,V,[s(f(t.label)+` `,1),h(`span`,H,f(t.key),1)]),h(`td`,U,[h(`input`,{type:`checkbox`,class:`h-4 w-4`,"aria-label":l.$t(`account.api_tokens.ability_read`,{module:t.label}),checked:Z(`${t.key}:read`),onChange:e=>Q(t.key,`read`)},null,40,W)]),h(`td`,G,[t.writable?(r(),m(`input`,{key:0,type:`checkbox`,class:`h-4 w-4`,"aria-label":l.$t(`account.api_tokens.ability_write`,{module:t.label}),checked:Z(`${t.key}:write`),onChange:e=>Q(t.key,`write`)},null,40,K)):e(``,!0)])]))),128))])])])]),h(`div`,se,[t(_,{type:`submit`,loading:i(J).processing,disabled:i(J).processing},{default:c(()=>[s(f(l.$t(`account.api_tokens.submit`)),1)]),_:1},8,[`loading`,`disabled`])])],32)]),_:1},8,[`title`]),t(v,{title:l.$t(`account.api_tokens.list_title`),"no-padding":``},{default:c(()=>[o.tokens.length===0?(r(),m(`p`,ce,f(l.$t(`account.api_tokens.empty`)),1)):(r(),m(`div`,le,[h(`table`,ue,[h(`thead`,de,[h(`tr`,null,[h(`th`,fe,f(l.$t(`account.api_tokens.name`)),1),h(`th`,pe,f(l.$t(`account.api_tokens.abilities`)),1),h(`th`,me,f(l.$t(`account.api_tokens.owner`)),1),h(`th`,he,f(l.$t(`account.api_tokens.last_used`)),1),h(`th`,ge,f(l.$t(`account.api_tokens.expiry`)),1),u[7]||=h(`th`,{class:`px-4 py-2`},null,-1)])]),h(`tbody`,_e,[(r(!0),m(p,null,a(o.tokens,n=>(r(),m(`tr`,{key:n.id,"data-api-token-row":``},[h(`td`,ve,f(n.name),1),h(`td`,ye,[h(`details`,null,[h(`summary`,be,f(l.$tc(`account.api_tokens.abilities_count`,n.abilities.length)),1),h(`ul`,xe,[(r(!0),m(p,null,a(n.abilities,e=>(r(),m(`li`,{key:e},f(je(e)),1))),128))])])]),h(`td`,Se,[s(f(n.owner),1),h(`div`,Ce,f(n.created_at),1)]),h(`td`,we,f(n.last_used_at||l.$t(`account.api_tokens.never_used`)),1),h(`td`,Te,[n.expires_at?(r(),m(p,{key:0},[s(f(l.$t(`account.api_tokens.until`,{date:n.expires_at})),1),n.expired?(r(),m(`span`,Ee,f(l.$t(`account.api_tokens.expired`)),1)):e(``,!0)],64)):(r(),m(p,{key:1},[s(f(l.$t(`account.api_tokens.no_expiry`)),1)],64))]),h(`td`,q,[t(_,{size:`sm`,variant:`danger`,onClick:e=>X.value=n},{default:c(()=>[s(f(l.$t(`account.api_tokens.revoke`)),1)]),_:1},8,[`onClick`])])]))),128))])])]))]),_:1},8,[`title`]),t(re,{show:X.value!==null,title:l.$t(`account.api_tokens.revoke_title`),onClose:u[6]||=e=>X.value=null},{footer:c(()=>[t(_,{variant:`secondary`,onClick:u[5]||=e=>X.value=null},{default:c(()=>[s(f(l.$t(`common.cancel`)),1)]),_:1}),t(_,{variant:`danger`,onClick:Ae},{default:c(()=>[s(f(l.$t(`account.api_tokens.revoke`)),1)]),_:1})]),default:c(()=>[h(`p`,De,[s(f(l.$t(`account.api_tokens.revoke_confirm_before`))+` `,1),h(`strong`,null,f(X.value?.name),1),s(` `+f(l.$t(`account.api_tokens.revoke_confirm_after`)),1)])]),_:1},8,[`show`,`title`])]))}},Y={class:`mb-6`},X={class:`text-2xl font-bold text-fg`},Z={class:`mt-1 text-sm text-muted`},Q={__name:`Index`,props:{tokens:Array,modules:Array,plainToken:String,docsUrl:String,openApiUrl:String},setup(e){return(n,i)=>(r(),o(g,{title:n.$t(`menu.api_tokens`)},{default:c(()=>[h(`div`,Y,[h(`h1`,X,f(n.$t(`menu.api_tokens`)),1),h(`p`,Z,f(n.$t(`account.api_tokens.subtitle`)),1)]),t(J,{tokens:e.tokens,modules:e.modules,"plain-token":e.plainToken,"docs-url":e.docsUrl,"open-api-url":e.openApiUrl},null,8,[`tokens`,`modules`,`plain-token`,`docs-url`,`open-api-url`])]),_:1},8,[`title`]))}};export{Q as default}; \ No newline at end of file diff --git a/packages/admin/dist/assets/Index-bqKVRXw8.js b/packages/admin/dist/assets/Index-bqKVRXw8.js deleted file mode 100644 index 50e9d09c..00000000 --- a/packages/admin/dist/assets/Index-bqKVRXw8.js +++ /dev/null @@ -1 +0,0 @@ -import{C as e,E as t,G as n,I as r,Q as i,R as a,S as o,T as s,W as c,Y as l,et as u,p as d,s as f,v as p,w as m,x as h}from"./dist-MY__znoP.js";import{t as g}from"./AdminLayout--RXJFj9t.js";import{t as _}from"./AdminButton-Bx141Bs3.js";var v={class:`mb-6`},y={"data-page-title":`admin.cache`,class:`text-2xl font-bold text-gray-900`},b={class:`mt-1 text-sm text-gray-600`},x={class:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4 mb-6`},S={class:`bg-white rounded-lg shadow p-4`,"data-cache-stat":`rate`},C={class:`text-sm text-gray-600`},w={class:`mt-1 text-2xl font-semibold text-gray-900`},T={class:`mt-1 text-xs text-gray-500`},E={class:`bg-white rounded-lg shadow p-4`,"data-cache-stat":`size`},D={class:`text-sm text-gray-600`},O={class:`mt-1 text-2xl font-semibold text-gray-900`},k={class:`mt-1 text-xs text-gray-500`},A={class:`bg-white rounded-lg shadow p-4`,"data-cache-stat":`store`},j={class:`text-sm text-gray-600`},M={class:`mt-1 text-2xl font-semibold text-gray-900`},N={class:`mt-1 text-xs text-gray-500`},P={class:`bg-white rounded-lg shadow p-4`,"data-cache-stat":`state`},F={class:`text-sm text-gray-600`},I={class:`mt-1 text-xs text-gray-500`},L={class:`bg-white rounded-lg shadow p-6 space-y-6`},R={class:`text-sm text-gray-600`},ee={key:0,class:`flex flex-col sm:flex-row sm:items-end gap-3`},z={class:`flex-1`},B={class:`block text-sm font-medium text-gray-700 mb-1`},V=[`value`],H={key:1,class:`flex flex-col sm:flex-row sm:items-end gap-3`},U={class:`flex-1`},W={class:`block text-sm font-medium text-gray-700 mb-1`},G=[`value`],K={class:`flex flex-wrap gap-3 pt-2 border-t border-gray-100`},q={__name:`Index`,props:{status:Object,modules:Array,sites:Array},setup(q){let J=q,Y=l(J.modules[0]?.key??``),X=l(J.sites[0]?.id??``),Z=l(!1),Q=(e,t={})=>{Z.value=!0,f.post(route(`admin.cache.clear`),{scope:e,...t},{preserveScroll:!0,onFinish:()=>{Z.value=!1}})},$=e=>e==null?`—`:new Intl.NumberFormat().format(e),te=e=>{if(e==null)return`—`;let t=[`B`,`KB`,`MB`,`GB`],n=e,r=0;for(;n>=1024&&r(r(),o(g,{title:l.$t(`menu.cache`)},{default:c(()=>[h(`div`,v,[h(`h1`,y,u(l.$t(`menu.cache`)),1),h(`p`,b,u(l.$t(`cache.subtitle`)),1)]),h(`div`,x,[h(`div`,S,[h(`div`,C,u(l.$t(`cache.hit_rate`)),1),h(`div`,w,u(q.status.rate===null?`—`:`${q.status.rate}%`),1),h(`div`,T,u(l.$t(`cache.hits`))+`: `+u($(q.status.hits))+` · `+u(l.$t(`cache.misses`))+`: `+u($(q.status.misses)),1)]),h(`div`,E,[h(`div`,D,u(l.$t(`cache.size`)),1),h(`div`,O,u(te(q.status.bytes)),1),h(`div`,k,u(l.$t(`cache.entries`))+`: `+u($(q.status.entries)),1)]),h(`div`,A,[h(`div`,j,u(l.$t(`cache.store`)),1),h(`div`,M,u(q.status.driver),1),h(`div`,N,u(q.status.tags?l.$t(`cache.with_tags`):l.$t(`cache.without_tags`)),1)]),h(`div`,P,[h(`div`,F,u(l.$t(`cache.records`)),1),h(`div`,{class:i([`mt-1 text-2xl font-semibold`,q.status.enabled?`text-green-700`:`text-gray-500`])},u(q.status.enabled?l.$t(`cache.on`):l.$t(`cache.off`)),3),h(`div`,I,u(l.$t(`cache.pages`))+`: `+u(q.status.pages?l.$t(`cache.on`):l.$t(`cache.off`)),1)])]),h(`div`,L,[h(`p`,R,u(l.$t(`cache.clear_hint`)),1),q.modules.length?(r(),m(`div`,ee,[h(`label`,z,[h(`span`,B,u(l.$t(`cache.module`)),1),n(h(`select`,{"onUpdate:modelValue":f[0]||=e=>Y.value=e,"data-cache-module":``,class:`w-full rounded-md border-gray-300 text-sm`},[(r(!0),m(p,null,a(q.modules,e=>(r(),m(`option`,{key:e.key,value:e.key},u(e.label),9,V))),128))],512),[[d,Y.value]])]),t(_,{variant:`outline`,"data-action":`clear-module`,disabled:Z.value,onClick:f[1]||=e=>Q(`module`,{module:Y.value})},{default:c(()=>[s(u(l.$t(`cache.clear_module`)),1)]),_:1},8,[`disabled`])])):e(``,!0),q.sites.length>1?(r(),m(`div`,H,[h(`label`,U,[h(`span`,W,u(l.$t(`cache.site`)),1),n(h(`select`,{"onUpdate:modelValue":f[2]||=e=>X.value=e,"data-cache-site":``,class:`w-full rounded-md border-gray-300 text-sm`},[(r(!0),m(p,null,a(q.sites,e=>(r(),m(`option`,{key:e.id,value:e.id},u(e.name),9,G))),128))],512),[[d,X.value]])]),t(_,{variant:`outline`,"data-action":`clear-site`,disabled:Z.value,onClick:f[3]||=e=>Q(`site`,{site:X.value})},{default:c(()=>[s(u(l.$t(`cache.clear_site`)),1)]),_:1},8,[`disabled`])])):e(``,!0),h(`div`,K,[t(_,{variant:`danger`,"data-action":`clear-all`,disabled:Z.value,onClick:f[4]||=e=>Q(`all`)},{default:c(()=>[s(u(l.$t(`cache.clear_all`)),1)]),_:1},8,[`disabled`]),t(_,{variant:`secondary`,"data-action":`reset-stats`,disabled:Z.value,onClick:f[5]||=e=>Q(`stats`)},{default:c(()=>[s(u(l.$t(`cache.reset_stats`)),1)]),_:1},8,[`disabled`])])])]),_:1},8,[`title`]))}};export{q as default}; \ No newline at end of file diff --git a/packages/admin/dist/assets/LocaleSwitcher-DAWnmZni.js b/packages/admin/dist/assets/LocaleSwitcher-DAWnmZni.js new file mode 100644 index 00000000..856fa47c --- /dev/null +++ b/packages/admin/dist/assets/LocaleSwitcher-DAWnmZni.js @@ -0,0 +1 @@ +import{$ as e,C as t,I as n,R as r,b as i,et as a,o,s,tt as c,v as l,w as u,x as d}from"./dist-Bie52OmN.js";var f={class:`inline-flex items-center gap-2.5`,"data-atrium-logo":``},p=[`width`,`height`],m={__name:`AtriumLogo`,props:{name:{type:String,default:`Atrium`},on:{type:String,default:`sidebar`},size:{type:Number,default:28},wordmark:{type:Boolean,default:!0}},setup(r){return(i,o)=>(n(),u(`span`,f,[(n(),u(`svg`,{width:r.size,height:r.size,viewBox:`0 0 48 48`,"aria-hidden":`true`,class:`block flex-none`},[d(`path`,{d:`M6 42V22a18 18 0 0 1 36 0v20H32V22a8 8 0 0 0-16 0v20z`,class:e(r.on===`surface`?`fill-fg`:`fill-mark`)},null,2),d(`rect`,{x:`16`,y:`28`,width:`16`,height:`5`,class:e(r.on===`surface`?`fill-accent`:`fill-mark-accent`)},null,2)],8,p)),r.wordmark?(n(),u(`span`,{key:0,class:e([`font-brand font-semibold tracking-[-0.01em] truncate`,r.on===`surface`?`text-fg`:`text-sidebar-fg`]),style:a({fontSize:Math.round(r.size*.72)+`px`})},c(r.name),7)):t(``,!0)]))}},h=[`data-credit-on`],g=[`aria-label`,`title`],_={key:0,"data-credit-text":``},v={__name:`AdminCredit`,props:{on:{type:String,default:`page`},compact:{type:Boolean,default:!1}},setup(r){let a=r,s=o(),l=i(()=>s.props.credit!==!1),f=i(()=>a.on===`sidebar`);return(i,a)=>l.value?(n(),u(`div`,{key:0,"data-credit":``,"data-credit-on":f.value?`sidebar`:`page`},[d(`a`,{"data-credit-link":``,href:`https://alve.by/en/`,target:`_blank`,rel:`noopener`,"aria-label":r.compact?i.$t(`layout.made_by`):void 0,title:r.compact?i.$t(`layout.made_by`):void 0,class:e([`inline-flex flex-col gap-1.5 rounded-md text-xs transition-colors focus:outline-none focus-visible:ring-2`,f.value?`items-start text-sidebar-muted hover:text-sidebar-fg focus-visible:ring-sidebar-accent`:`items-center text-muted hover:text-fg focus-visible:ring-focus`])},[d(`span`,{"data-credit-logo":``,"aria-hidden":`true`,class:e([`block h-4 bg-contain bg-no-repeat`,r.compact?`w-12 bg-center`:[`w-[4.75rem]`,f.value?`bg-left`:`bg-center`]]),style:{"background-image":`var(--atrium-credit-logo)`}},null,2),r.compact?t(``,!0):(n(),u(`span`,_,c(i.$t(`layout.made_by`)),1))],10,g)],8,h)):t(``,!0)}},y={class:`relative flex min-w-0 items-center gap-1 rounded-lg px-1 py-1 text-muted hover:bg-hover hover:text-fg sm:gap-2 sm:px-2`},b={class:`flex min-w-0 flex-col text-left leading-tight`,"aria-hidden":`true`},x={"data-switcher-caption":``,class:`truncate text-[11px] sm:text-xs`},S=[`lang`],C={class:`text-sm font-medium text-fg sm:hidden`},w=[`aria-label`,`aria-description`,`title`,`value`],T=[`value`,`lang`],E={__name:`LocaleSwitcher`,setup(e){let t=o(),a=i(()=>t.props.locales||{}),f=i(()=>t.props.locale),p=i(()=>a.value[f.value]??f.value),m=i(()=>String(f.value??``).split(`_`)[0].toUpperCase()),h=e=>{s.post(route(`admin.locale`),{locale:e.target.value},{preserveScroll:!0,preserveState:!1})};return(e,t)=>(n(),u(`div`,y,[t[0]||=d(`svg`,{class:`h-5 w-5 shrink-0`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,"aria-hidden":`true`},[d(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M10.5 21l5.25-11.25L21 21m-9-3h7.5M3 5.621a48.474 48.474 0 016-.371m0 0c1.12 0 2.233.038 3.334.114M9 5.25V3m3.334 2.364C11.176 10.658 7.69 15.08 3 17.502m9.334-12.138c.896.061 1.785.147 2.666.257m-4.589 8.495a18.023 18.023 0 01-3.827-5.802`})],-1),d(`span`,b,[d(`span`,x,c(e.$t(`layout.admin_language`)),1),d(`span`,{class:`hidden truncate text-sm font-medium text-fg sm:inline`,lang:String(f.value).replace(`_`,`-`)},c(p.value),9,S),d(`span`,C,c(m.value),1)]),t[1]||=d(`svg`,{class:`hidden h-4 w-4 shrink-0 sm:block`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,"aria-hidden":`true`},[d(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M19 9l-7 7-7-7`})],-1),d(`select`,{"data-locale-switcher":``,name:`locale`,"aria-label":e.$t(`layout.admin_language`),"aria-description":e.$t(`layout.admin_language_hint`),title:e.$t(`layout.admin_language_hint`),value:f.value,class:`absolute inset-0 h-full w-full cursor-pointer appearance-none rounded-lg bg-transparent text-transparent focus:outline-none focus-visible:ring-2 focus-visible:ring-focus`,onChange:h},[(n(!0),u(l,null,r(a.value,(e,t)=>(n(),u(`option`,{key:t,value:t,lang:t.replace(`_`,`-`),class:`bg-surface text-fg`},c(e),9,T))),128))],40,w)]))}};export{v as n,m as r,E as t}; \ No newline at end of file diff --git a/packages/admin/dist/assets/LocaleSwitcher-DdLJ9WTE.js b/packages/admin/dist/assets/LocaleSwitcher-DdLJ9WTE.js deleted file mode 100644 index 337df02a..00000000 --- a/packages/admin/dist/assets/LocaleSwitcher-DdLJ9WTE.js +++ /dev/null @@ -1 +0,0 @@ -import{$ as e,C as t,I as n,Q as r,R as i,b as a,et as o,o as s,s as c,v as l,w as u,x as d}from"./dist-MY__znoP.js";var f={class:`inline-flex items-center gap-2.5`,"data-atrium-logo":``},p=[`width`,`height`],m={__name:`AtriumLogo`,props:{name:{type:String,default:`Atrium`},on:{type:String,default:`sidebar`},size:{type:Number,default:28},wordmark:{type:Boolean,default:!0}},setup(i){return(a,s)=>(n(),u(`span`,f,[(n(),u(`svg`,{width:i.size,height:i.size,viewBox:`0 0 48 48`,"aria-hidden":`true`,class:`block flex-none`},[d(`path`,{d:`M6 42V22a18 18 0 0 1 36 0v20H32V22a8 8 0 0 0-16 0v20z`,class:r(i.on===`surface`?`fill-fg`:`fill-mark`)},null,2),d(`rect`,{x:`16`,y:`28`,width:`16`,height:`5`,class:r(i.on===`surface`?`fill-accent`:`fill-mark-accent`)},null,2)],8,p)),i.wordmark?(n(),u(`span`,{key:0,class:r([`font-brand font-semibold tracking-[-0.01em] truncate`,i.on===`surface`?`text-fg`:`text-sidebar-fg`]),style:e({fontSize:Math.round(i.size*.72)+`px`})},o(i.name),7)):t(``,!0)]))}},h=[`data-credit-on`],g=[`aria-label`,`title`],_={key:0,"data-credit-text":``},v={__name:`AdminCredit`,props:{on:{type:String,default:`page`},compact:{type:Boolean,default:!1}},setup(e){let i=e,c=s(),l=a(()=>c.props.credit!==!1),f=a(()=>i.on===`sidebar`);return(i,a)=>l.value?(n(),u(`div`,{key:0,"data-credit":``,"data-credit-on":f.value?`sidebar`:`page`},[d(`a`,{"data-credit-link":``,href:`https://alve.by/en/`,target:`_blank`,rel:`noopener`,"aria-label":e.compact?i.$t(`layout.made_by`):void 0,title:e.compact?i.$t(`layout.made_by`):void 0,class:r([`inline-flex flex-col gap-1.5 rounded-md text-xs transition-colors focus:outline-none focus-visible:ring-2`,f.value?`items-start text-sidebar-muted hover:text-sidebar-fg focus-visible:ring-sidebar-accent`:`items-center text-muted hover:text-fg focus-visible:ring-focus`])},[d(`span`,{"data-credit-logo":``,"aria-hidden":`true`,class:r([`block h-4 bg-contain bg-no-repeat`,e.compact?`w-12 bg-center`:[`w-[4.75rem]`,f.value?`bg-left`:`bg-center`]]),style:{"background-image":`var(--atrium-credit-logo)`}},null,2),e.compact?t(``,!0):(n(),u(`span`,_,o(i.$t(`layout.made_by`)),1))],10,g)],8,h)):t(``,!0)}},y={class:`relative flex min-w-0 items-center gap-1 rounded-lg px-1 py-1 text-muted hover:bg-hover hover:text-fg sm:gap-2 sm:px-2`},b={class:`flex min-w-0 flex-col text-left leading-tight`,"aria-hidden":`true`},x={"data-switcher-caption":``,class:`truncate text-[11px] sm:text-xs`},S=[`lang`],C={class:`text-sm font-medium text-fg sm:hidden`},w=[`aria-label`,`aria-description`,`title`,`value`],T=[`value`,`lang`],E={__name:`LocaleSwitcher`,setup(e){let t=s(),r=a(()=>t.props.locales||{}),f=a(()=>t.props.locale),p=a(()=>r.value[f.value]??f.value),m=a(()=>String(f.value??``).split(`_`)[0].toUpperCase()),h=e=>{c.post(route(`admin.locale`),{locale:e.target.value},{preserveScroll:!0,preserveState:!1})};return(e,t)=>(n(),u(`div`,y,[t[0]||=d(`svg`,{class:`h-5 w-5 shrink-0`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,"aria-hidden":`true`},[d(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M10.5 21l5.25-11.25L21 21m-9-3h7.5M3 5.621a48.474 48.474 0 016-.371m0 0c1.12 0 2.233.038 3.334.114M9 5.25V3m3.334 2.364C11.176 10.658 7.69 15.08 3 17.502m9.334-12.138c.896.061 1.785.147 2.666.257m-4.589 8.495a18.023 18.023 0 01-3.827-5.802`})],-1),d(`span`,b,[d(`span`,x,o(e.$t(`layout.admin_language`)),1),d(`span`,{class:`hidden truncate text-sm font-medium text-fg sm:inline`,lang:String(f.value).replace(`_`,`-`)},o(p.value),9,S),d(`span`,C,o(m.value),1)]),t[1]||=d(`svg`,{class:`hidden h-4 w-4 shrink-0 sm:block`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,"aria-hidden":`true`},[d(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M19 9l-7 7-7-7`})],-1),d(`select`,{"data-locale-switcher":``,name:`locale`,"aria-label":e.$t(`layout.admin_language`),"aria-description":e.$t(`layout.admin_language_hint`),title:e.$t(`layout.admin_language_hint`),value:f.value,class:`absolute inset-0 h-full w-full cursor-pointer appearance-none rounded-lg bg-transparent text-transparent focus:outline-none focus-visible:ring-2 focus-visible:ring-focus`,onChange:h},[(n(!0),u(l,null,i(r.value,(e,t)=>(n(),u(`option`,{key:t,value:t,lang:t.replace(`_`,`-`),class:`bg-surface text-fg`},o(e),9,T))),128))],40,w)]))}};export{v as n,m as r,E as t}; \ No newline at end of file diff --git a/packages/admin/dist/assets/Login-D_P0ceoZ.js b/packages/admin/dist/assets/Login-DTW3u1G9.js similarity index 54% rename from packages/admin/dist/assets/Login-D_P0ceoZ.js rename to packages/admin/dist/assets/Login-DTW3u1G9.js index 5235e605..4ad93dca 100644 --- a/packages/admin/dist/assets/Login-D_P0ceoZ.js +++ b/packages/admin/dist/assets/Login-DTW3u1G9.js @@ -1 +1 @@ -import{C as e,E as t,G as n,I as r,Q as i,R as a,T as o,Y as s,Z as c,_ as l,a as u,d,et as f,m as p,o as m,r as h,u as g,v as _,w as v,x as y}from"./dist-MY__znoP.js";import{n as b,r as x,t as S}from"./LocaleSwitcher-DdLJ9WTE.js";var C={class:`min-h-screen flex items-center justify-center bg-page py-12 px-4 sm:px-6 lg:px-8`},w={class:`absolute top-4 right-4`},T={class:`max-w-md w-full`},E={class:`text-center mb-8`},D=[`src`,`alt`],O={key:1,class:`flex justify-center`},k={class:`mt-2 text-sm text-muted`},A={class:`bg-surface border border-line rounded-lg shadow-lg p-8`},j={for:`email`,class:`block text-sm font-medium text-fg`},M={key:0,"data-error":``,class:`mt-1 text-sm text-danger`},N={for:`password`,class:`block text-sm font-medium text-fg`},P={class:`mt-1 relative`},F=[`type`],I={key:0,class:`h-5 w-5`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`},L={key:1,class:`h-5 w-5`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`},R={key:0,"data-error":``,class:`mt-1 text-sm text-danger`},z={class:`flex items-center`},B={for:`remember`,class:`ml-2 block text-sm text-fg`},V=[`disabled`],H={key:0,class:`animate-spin -ml-1 mr-2 h-4 w-4`,fill:`none`,viewBox:`0 0 24 24`},U={key:0,class:`mt-6`,dusk:`login-methods`},W={class:`flex items-center gap-3 text-sm text-muted`,"aria-hidden":`true`},G={class:`mt-4 space-y-2`},K=[`href`,`dusk`],q=[`innerHTML`],J={__name:`Login`,props:{branding:{type:Object,default:()=>({})},methods:{type:Array,default:()=>[]}},setup(J){let Y=u({email:``,password:``,remember:!1});Y.setError({...m().props.errors||{}});let X=s(!1),Z=()=>{Y.post(route(`admin.login`),{onFinish:()=>Y.reset(`password`)})};return(s,u)=>(r(),v(_,null,[t(c(h),{title:s.$t(`auth.login.title`)},null,8,[`title`]),y(`div`,C,[y(`div`,w,[t(S)]),y(`div`,T,[y(`div`,E,[J.branding.logo?(r(),v(`img`,{key:0,src:J.branding.logo,alt:J.branding.name,class:`mx-auto h-12 w-auto`},null,8,D)):(r(),v(`h2`,O,[t(x,{on:`surface`,size:48,name:J.branding.name||`Atrium`},null,8,[`name`])])),y(`p`,k,f(s.$t(`auth.login.subtitle`)),1)]),y(`div`,A,[y(`form`,{onSubmit:l(Z,[`prevent`]),class:`space-y-6`},[y(`div`,null,[y(`label`,j,f(s.$t(`auth.login.email`)),1),n(y(`input`,{id:`email`,"onUpdate:modelValue":u[0]||=e=>c(Y).email=e,type:`email`,autocomplete:`email`,required:``,class:i([`mt-1 block w-full px-3 py-2 border border-field rounded-md shadow-sm placeholder-muted focus:outline-none focus:ring-focus focus:border-focus sm:text-sm`,{"border-danger":c(Y).errors.email}]),placeholder:`admin@example.com`},null,2),[[p,c(Y).email]]),c(Y).errors.email?(r(),v(`p`,M,f(c(Y).errors.email),1)):e(``,!0)]),y(`div`,null,[y(`label`,N,f(s.$t(`auth.login.password`)),1),y(`div`,P,[n(y(`input`,{id:`password`,"onUpdate:modelValue":u[1]||=e=>c(Y).password=e,type:X.value?`text`:`password`,autocomplete:`current-password`,required:``,class:i([`block w-full px-3 py-2 border border-field rounded-md shadow-sm placeholder-muted focus:outline-none focus:ring-focus focus:border-focus sm:text-sm pr-10`,{"border-danger":c(Y).errors.password}])},null,10,F),[[d,c(Y).password]]),y(`button`,{type:`button`,onClick:u[2]||=e=>X.value=!X.value,class:`absolute inset-y-0 right-0 pr-3 flex items-center text-muted hover:text-fg`},[X.value?(r(),v(`svg`,L,[...u[5]||=[y(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M13.875 18.825A10.05 10.05 0 0112 19c-4.478 0-8.268-2.943-9.543-7a9.97 9.97 0 011.563-3.029m5.858.908a3 3 0 114.243 4.243M9.878 9.878l4.242 4.242M9.88 9.88l-3.29-3.29m7.532 7.532l3.29 3.29M3 3l3.59 3.59m0 0A9.953 9.953 0 0112 5c4.478 0 8.268 2.943 9.543 7a10.025 10.025 0 01-4.132 5.411m0 0L21 21`},null,-1)]])):(r(),v(`svg`,I,[...u[4]||=[y(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M15 12a3 3 0 11-6 0 3 3 0 016 0z`},null,-1),y(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z`},null,-1)]]))])]),c(Y).errors.password?(r(),v(`p`,R,f(c(Y).errors.password),1)):e(``,!0)]),y(`div`,z,[n(y(`input`,{id:`remember`,"onUpdate:modelValue":u[3]||=e=>c(Y).remember=e,type:`checkbox`,class:`h-4 w-4 text-accent focus:ring-focus border-field rounded`},null,512),[[g,c(Y).remember]]),y(`label`,B,f(s.$t(`auth.login.remember`)),1)]),y(`button`,{type:`submit`,disabled:c(Y).processing,class:`w-full flex justify-center py-2 px-4 border border-transparent rounded-md shadow-sm text-sm font-medium text-on-accent bg-accent hover:bg-accent-hover focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-focus disabled:opacity-50 disabled:cursor-not-allowed`},[c(Y).processing?(r(),v(`svg`,H,[...u[6]||=[y(`circle`,{class:`opacity-25`,cx:`12`,cy:`12`,r:`10`,stroke:`currentColor`,"stroke-width":`4`},null,-1),y(`path`,{class:`opacity-75`,fill:`currentColor`,d:`M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z`},null,-1)]])):e(``,!0),o(` `+f(c(Y).processing?s.$t(`auth.login.submitting`):s.$t(`auth.login.submit`)),1)],8,V)],32),J.methods.length?(r(),v(`div`,U,[y(`div`,W,[u[7]||=y(`span`,{class:`h-px flex-1 bg-line`},null,-1),o(` `+f(s.$t(`auth.login.or`))+` `,1),u[8]||=y(`span`,{class:`h-px flex-1 bg-line`},null,-1)]),y(`ul`,G,[(r(!0),v(_,null,a(J.methods,t=>(r(),v(`li`,{key:t.key},[y(`a`,{href:t.url,dusk:`login-method-${t.key}`,class:`w-full flex items-center justify-center gap-2 py-2 px-4 border border-field rounded-md text-sm font-medium text-fg bg-surface hover:bg-hover focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-focus`},[t.icon?(r(),v(`span`,{key:0,class:`h-5 w-5 shrink-0`,"aria-hidden":`true`,innerHTML:t.icon},null,8,q)):e(``,!0),o(` `+f(t.label),1)],8,K)]))),128))])])):e(``,!0)]),t(b,{class:`mt-8 text-center`})])])],64))}};export{J as default}; \ No newline at end of file +import{$ as e,C as t,E as n,G as r,I as i,Q as a,R as o,T as s,X as c,_ as l,a as u,d,m as f,o as p,r as m,tt as h,u as g,v as _,w as v,x as y}from"./dist-Bie52OmN.js";import{n as b,r as x,t as S}from"./LocaleSwitcher-DAWnmZni.js";var C={class:`min-h-screen flex items-center justify-center bg-page py-12 px-4 sm:px-6 lg:px-8`},w={class:`absolute top-4 right-4`},T={class:`max-w-md w-full`},E={class:`text-center mb-8`},D=[`src`,`alt`],O={key:1,class:`flex justify-center`},k={class:`mt-2 text-sm text-muted`},A={class:`bg-surface border border-line rounded-lg shadow-lg p-8`},j={for:`email`,class:`block text-sm font-medium text-fg`},M={key:0,"data-error":``,class:`mt-1 text-sm text-danger`},N={for:`password`,class:`block text-sm font-medium text-fg`},P={class:`mt-1 relative`},F=[`type`],I={key:0,class:`h-5 w-5`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`},L={key:1,class:`h-5 w-5`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`},R={key:0,"data-error":``,class:`mt-1 text-sm text-danger`},z={class:`flex items-center`},B={for:`remember`,class:`ml-2 block text-sm text-fg`},V=[`disabled`],H={key:0,class:`animate-spin -ml-1 mr-2 h-4 w-4`,fill:`none`,viewBox:`0 0 24 24`},U={key:0,class:`mt-6`,dusk:`login-methods`},W={class:`flex items-center gap-3 text-sm text-muted`,"aria-hidden":`true`},G={class:`mt-4 space-y-2`},K=[`href`,`dusk`],q=[`innerHTML`],J={__name:`Login`,props:{branding:{type:Object,default:()=>({})},methods:{type:Array,default:()=>[]}},setup(J){let Y=u({email:``,password:``,remember:!1});Y.setError({...p().props.errors||{}});let X=c(!1),Z=()=>{Y.post(route(`admin.login`),{onFinish:()=>Y.reset(`password`)})};return(c,u)=>(i(),v(_,null,[n(a(m),{title:c.$t(`auth.login.title`)},null,8,[`title`]),y(`div`,C,[y(`div`,w,[n(S)]),y(`div`,T,[y(`div`,E,[J.branding.logo?(i(),v(`img`,{key:0,src:J.branding.logo,alt:J.branding.name,class:`mx-auto h-12 w-auto`},null,8,D)):(i(),v(`h2`,O,[n(x,{on:`surface`,size:48,name:J.branding.name||`Atrium`},null,8,[`name`])])),y(`p`,k,h(c.$t(`auth.login.subtitle`)),1)]),y(`div`,A,[y(`form`,{onSubmit:l(Z,[`prevent`]),class:`space-y-6`},[y(`div`,null,[y(`label`,j,h(c.$t(`auth.login.email`)),1),r(y(`input`,{id:`email`,"onUpdate:modelValue":u[0]||=e=>a(Y).email=e,type:`email`,autocomplete:`email`,required:``,class:e([`mt-1 block w-full px-3 py-2 border border-field rounded-md shadow-sm placeholder-muted focus:outline-none focus:ring-focus focus:border-focus sm:text-sm`,{"border-danger":a(Y).errors.email}]),placeholder:`admin@example.com`},null,2),[[f,a(Y).email]]),a(Y).errors.email?(i(),v(`p`,M,h(a(Y).errors.email),1)):t(``,!0)]),y(`div`,null,[y(`label`,N,h(c.$t(`auth.login.password`)),1),y(`div`,P,[r(y(`input`,{id:`password`,"onUpdate:modelValue":u[1]||=e=>a(Y).password=e,type:X.value?`text`:`password`,autocomplete:`current-password`,required:``,class:e([`block w-full px-3 py-2 border border-field rounded-md shadow-sm placeholder-muted focus:outline-none focus:ring-focus focus:border-focus sm:text-sm pr-10`,{"border-danger":a(Y).errors.password}])},null,10,F),[[d,a(Y).password]]),y(`button`,{type:`button`,onClick:u[2]||=e=>X.value=!X.value,class:`absolute inset-y-0 right-0 pr-3 flex items-center text-muted hover:text-fg`},[X.value?(i(),v(`svg`,L,[...u[5]||=[y(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M13.875 18.825A10.05 10.05 0 0112 19c-4.478 0-8.268-2.943-9.543-7a9.97 9.97 0 011.563-3.029m5.858.908a3 3 0 114.243 4.243M9.878 9.878l4.242 4.242M9.88 9.88l-3.29-3.29m7.532 7.532l3.29 3.29M3 3l3.59 3.59m0 0A9.953 9.953 0 0112 5c4.478 0 8.268 2.943 9.543 7a10.025 10.025 0 01-4.132 5.411m0 0L21 21`},null,-1)]])):(i(),v(`svg`,I,[...u[4]||=[y(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M15 12a3 3 0 11-6 0 3 3 0 016 0z`},null,-1),y(`path`,{"stroke-linecap":`round`,"stroke-linejoin":`round`,"stroke-width":`2`,d:`M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z`},null,-1)]]))])]),a(Y).errors.password?(i(),v(`p`,R,h(a(Y).errors.password),1)):t(``,!0)]),y(`div`,z,[r(y(`input`,{id:`remember`,"onUpdate:modelValue":u[3]||=e=>a(Y).remember=e,type:`checkbox`,class:`h-4 w-4 text-accent focus:ring-focus border-field rounded`},null,512),[[g,a(Y).remember]]),y(`label`,B,h(c.$t(`auth.login.remember`)),1)]),y(`button`,{type:`submit`,disabled:a(Y).processing,class:`w-full flex justify-center py-2 px-4 border border-transparent rounded-md shadow-sm text-sm font-medium text-on-accent bg-accent hover:bg-accent-hover focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-focus disabled:opacity-50 disabled:cursor-not-allowed`},[a(Y).processing?(i(),v(`svg`,H,[...u[6]||=[y(`circle`,{class:`opacity-25`,cx:`12`,cy:`12`,r:`10`,stroke:`currentColor`,"stroke-width":`4`},null,-1),y(`path`,{class:`opacity-75`,fill:`currentColor`,d:`M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z`},null,-1)]])):t(``,!0),s(` `+h(a(Y).processing?c.$t(`auth.login.submitting`):c.$t(`auth.login.submit`)),1)],8,V)],32),J.methods.length?(i(),v(`div`,U,[y(`div`,W,[u[7]||=y(`span`,{class:`h-px flex-1 bg-line`},null,-1),s(` `+h(c.$t(`auth.login.or`))+` `,1),u[8]||=y(`span`,{class:`h-px flex-1 bg-line`},null,-1)]),y(`ul`,G,[(i(!0),v(_,null,o(J.methods,e=>(i(),v(`li`,{key:e.key},[y(`a`,{href:e.url,dusk:`login-method-${e.key}`,class:`w-full flex items-center justify-center gap-2 py-2 px-4 border border-field rounded-md text-sm font-medium text-fg bg-surface hover:bg-hover focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-focus`},[e.icon?(i(),v(`span`,{key:0,class:`h-5 w-5 shrink-0`,"aria-hidden":`true`,innerHTML:e.icon},null,8,q)):t(``,!0),s(` `+h(e.label),1)],8,K)]))),128))])])):t(``,!0)]),n(b,{class:`mt-8 text-center`})])])],64))}};export{J as default}; \ No newline at end of file diff --git a/packages/admin/dist/assets/Settings-C2VyFPrB.js b/packages/admin/dist/assets/Settings-BrbOStcv.js similarity index 55% rename from packages/admin/dist/assets/Settings-C2VyFPrB.js rename to packages/admin/dist/assets/Settings-BrbOStcv.js index e04f9bea..800737b7 100644 --- a/packages/admin/dist/assets/Settings-C2VyFPrB.js +++ b/packages/admin/dist/assets/Settings-BrbOStcv.js @@ -1 +1 @@ -import{C as e,E as t,I as n,L as r,R as i,S as a,T as o,W as s,Z as c,_ as l,a as u,b as d,et as f,i as p,v as m,w as h,x as g}from"./dist-MY__znoP.js";import{t as _}from"./AdminLayout--RXJFj9t.js";import{t as v}from"./AdminButton-Bx141Bs3.js";import{t as y}from"./AdminCard--HubMtUj.js";import{t as b}from"./FormField-xD6LELDV.js";import{n as x}from"./contentLocale-BtGD-iBF.js";var S={class:`mb-6`},C={class:`max-w-4xl`},w={"data-page-title":`admin.modules.settings`,class:`text-2xl font-bold text-fg`},T={key:0,class:`mt-1 text-sm text-muted`},E={key:1,"data-settings-site":``,class:`mt-1 text-sm text-muted`},D=[`data-module`],O={class:`space-y-6`},k={class:`flex items-center justify-end space-x-3 pt-6 mt-6 border-t`},A={__name:`Settings`,props:{module:Object,description:String,fields:Array,values:Object,site:{type:Object,default:null},title:String},setup(A){let j=A,M={};j.fields.forEach(e=>{M[e.name]=x(e,j.values[e.name])});let N=u(M);r(`formData`,d(()=>N.data()));let P=()=>{N.submit(`put`,route(`admin.modules.settings.update`,j.module.key),{preserveScroll:!0})};return(r,u)=>(n(),a(_,{title:A.title},{default:s(()=>[g(`div`,S,[t(c(p),{href:r.route(`admin.modules.index`),class:`text-muted hover:text-accent`},{default:s(()=>[o(f(r.$t(`menu.modules`)),1)]),_:1},8,[`href`])]),g(`div`,C,[g(`h1`,w,f(A.title),1),A.description?(n(),h(`p`,T,f(A.description),1)):e(``,!0),A.site?(n(),h(`p`,E,f(r.$t(`modules.per_site`,{site:A.site.name})),1)):e(``,!0),t(y,{class:`mt-6`},{default:s(()=>[g(`form`,{"data-settings-form":``,"data-module":A.module.key,onSubmit:l(P,[`prevent`])},[g(`div`,O,[(n(!0),h(m,null,i(A.fields,e=>(n(),a(b,{key:e.name,field:e,modelValue:c(N)[e.name],"onUpdate:modelValue":t=>c(N)[e.name]=t,errors:c(N).errors},null,8,[`field`,`modelValue`,`onUpdate:modelValue`,`errors`]))),128))]),g(`div`,k,[t(v,{href:r.route(`admin.modules.index`),variant:`secondary`},{default:s(()=>[o(f(r.$t(`common.cancel`)),1)]),_:1},8,[`href`]),t(v,{"data-action":`save`,type:`submit`,loading:c(N).processing},{default:s(()=>[o(f(r.$t(`common.save`)),1)]),_:1},8,[`loading`])])],40,D)]),_:1})])]),_:1},8,[`title`]))}};export{A as default}; \ No newline at end of file +import{C as e,E as t,I as n,L as r,Q as i,R as a,S as o,T as s,W as c,_ as l,a as u,b as d,i as f,tt as p,v as m,w as h,x as g}from"./dist-Bie52OmN.js";import{t as _}from"./AdminLayout-DBeSErmz.js";import{t as v}from"./AdminButton-KiIJ2sLW.js";import{t as y}from"./AdminCard-YbEwPtJz.js";import{t as b}from"./FormField-B-XX4VFv.js";import{n as x}from"./contentLocale-BV_E0iGS.js";var S={class:`mb-6`},C={class:`max-w-4xl`},w={"data-page-title":`admin.modules.settings`,class:`text-2xl font-bold text-fg`},T={key:0,class:`mt-1 text-sm text-muted`},E={key:1,"data-settings-site":``,class:`mt-1 text-sm text-muted`},D=[`data-module`],O={class:`space-y-6`},k={class:`flex items-center justify-end space-x-3 pt-6 mt-6 border-t`},A={__name:`Settings`,props:{module:Object,description:String,fields:Array,values:Object,site:{type:Object,default:null},title:String},setup(A){let j=A,M={};j.fields.forEach(e=>{M[e.name]=x(e,j.values[e.name])});let N=u(M);r(`formData`,d(()=>N.data()));let P=()=>{N.submit(`put`,route(`admin.modules.settings.update`,j.module.key),{preserveScroll:!0})};return(r,u)=>(n(),o(_,{title:A.title},{default:c(()=>[g(`div`,S,[t(i(f),{href:r.route(`admin.modules.index`),class:`text-muted hover:text-accent`},{default:c(()=>[s(p(r.$t(`menu.modules`)),1)]),_:1},8,[`href`])]),g(`div`,C,[g(`h1`,w,p(A.title),1),A.description?(n(),h(`p`,T,p(A.description),1)):e(``,!0),A.site?(n(),h(`p`,E,p(r.$t(`modules.per_site`,{site:A.site.name})),1)):e(``,!0),t(y,{class:`mt-6`},{default:c(()=>[g(`form`,{"data-settings-form":``,"data-module":A.module.key,onSubmit:l(P,[`prevent`])},[g(`div`,O,[(n(!0),h(m,null,a(A.fields,e=>(n(),o(b,{key:e.name,field:e,modelValue:i(N)[e.name],"onUpdate:modelValue":t=>i(N)[e.name]=t,errors:i(N).errors},null,8,[`field`,`modelValue`,`onUpdate:modelValue`,`errors`]))),128))]),g(`div`,k,[t(v,{href:r.route(`admin.modules.index`),variant:`secondary`},{default:c(()=>[s(p(r.$t(`common.cancel`)),1)]),_:1},8,[`href`]),t(v,{"data-action":`save`,type:`submit`,loading:i(N).processing},{default:c(()=>[s(p(r.$t(`common.save`)),1)]),_:1},8,[`loading`])])],40,D)]),_:1})])]),_:1},8,[`title`]))}};export{A as default}; \ No newline at end of file diff --git a/packages/admin/dist/assets/Show-CS6rq4RP.js b/packages/admin/dist/assets/Show-CS6rq4RP.js new file mode 100644 index 00000000..31760a7b --- /dev/null +++ b/packages/admin/dist/assets/Show-CS6rq4RP.js @@ -0,0 +1 @@ +import{$ as e,C as t,E as n,I as r,Q as i,R as a,S as o,T as s,W as c,X as l,b as u,i as d,o as ee,s as te,tt as f,v as p,w as m,x as h}from"./dist-Bie52OmN.js";import{t as ne}from"./AdminLayout-DBeSErmz.js";import{t as g}from"./AdminButton-KiIJ2sLW.js";import{t as _}from"./AdminCard-YbEwPtJz.js";import{t as re}from"./AdminPagination-D7rwNfhd.js";import{t as ie}from"./BarChart-wks0RLo_.js";var ae={class:`mt-3 mb-6 flex flex-col lg:flex-row lg:items-start lg:justify-between gap-4`},oe={class:`min-w-0`},se={class:`text-2xl font-bold text-fg break-all`},ce={class:`mt-1 text-xs text-muted font-mono break-all`},le={class:`mt-2 text-fg break-words whitespace-pre-line`,dusk:`error-message`},ue={key:0,class:`mt-1 text-sm text-muted font-mono break-all`},v={class:`mt-3 flex flex-wrap gap-2 text-xs`},y={class:`px-2 py-0.5 rounded bg-off text-off-fg`,dusk:`error-status`},b={class:`px-2 py-0.5 rounded bg-off text-off-fg`},x={class:`px-2 py-0.5 rounded bg-off text-off-fg`},S={key:0,class:`px-2 py-0.5 rounded bg-success-soft text-success-soft-fg`},C={key:1,class:`px-2 py-0.5 rounded bg-warning-soft text-warning-soft-fg`},w={class:`flex flex-wrap gap-2 shrink-0`},T={key:0,class:`-mt-4 mb-6 text-xs text-muted`},E={class:`mb-6 grid grid-cols-2 md:grid-cols-3 xl:grid-cols-6 gap-3`},D={class:`text-xs text-muted`},O={class:`text-lg font-semibold text-fg tabular-nums break-words`},k={class:`grid gap-6 lg:grid-cols-3 mb-6`},A={class:`flex items-center justify-between gap-3`},j={class:`text-lg font-medium text-fg`},M={class:`flex gap-1`,role:`group`},N=[`aria-pressed`,`dusk`,`onClick`],P={class:`text-sm font-semibold text-fg`},F={class:`mt-2 mb-4 text-sm`,dusk:`error-top-paths`},I={class:`font-mono text-fg break-all`},L={class:`tabular-nums text-fg`},R={key:0,class:`text-muted`},z={class:`text-sm font-semibold text-fg`},B={class:`mt-2 text-sm`},V={class:`font-mono text-fg break-all`},H={class:`tabular-nums text-fg`},U={key:0,class:`text-muted`},de={key:1,class:`mb-6 bg-surface rounded-lg shadow px-6 py-6 text-sm text-muted`,dusk:`error-no-event`},fe={class:`flex flex-wrap items-center justify-between gap-3`},pe={class:`text-lg font-medium text-fg`},me={class:`text-xs text-muted`},he={key:0,class:`mb-1 text-xs font-semibold uppercase tracking-wide text-muted`},ge={class:`font-semibold text-fg break-all`},_e={class:`mb-3 text-sm text-fg break-words whitespace-pre-line`},ve={class:`space-y-2`},ye={class:`px-3 py-1.5 text-sm bg-surface-alt`},be={class:`font-mono text-fg break-all`},xe={class:`ml-2 font-mono text-xs text-muted break-all`},Se={key:0,class:`overflow-x-auto text-xs leading-5 font-mono py-1`,dusk:`error-code`},Ce={class:`inline-block w-12 select-none text-right pr-3`},we={class:`block px-3 bg-accent-soft text-accent-soft-fg font-semibold`},W={class:`inline-block w-12 select-none text-right pr-3`},Te={class:`inline-block w-12 select-none text-right pr-3`},Ee={class:`grid gap-6 lg:grid-cols-2 mb-6`},De={class:`grid grid-cols-[auto_1fr] gap-x-4 gap-y-1 text-sm`,dusk:`error-request`},Oe={class:`text-muted`},ke={class:`text-fg font-mono break-all`},Ae={class:`text-muted`},je={class:`text-fg font-mono break-all`},Me={class:`text-muted font-mono`},Ne={class:`text-fg font-mono break-all`},Pe={class:`text-sm space-y-1`,dusk:`error-breadcrumbs`},Fe={class:`font-mono text-muted tabular-nums`},Ie={class:`font-mono text-muted`},Le={class:`text-fg break-words`},Re={key:0,class:`text-muted`},ze={class:`min-w-full divide-y divide-line text-sm`,dusk:`error-occurrences`},Be={class:`bg-surface-alt`},Ve={class:`divide-y divide-line`},He={class:`px-4 py-2 whitespace-nowrap`},Ue={key:0,class:`font-semibold`},We={class:`px-4 py-2`},Ge={class:`px-4 py-2 font-mono`},Ke={class:`px-4 py-2 font-mono break-all`},qe={class:`px-4 py-2 font-mono`},Je={class:`px-4 py-2 tabular-nums`},G={__name:`Show`,props:{issue:{type:Object,required:!0},event:{type:Object,default:null},occurrences:{type:Object,required:!0},top:{type:Object,required:!0},chart:{type:Object,required:!0},currentRelease:{type:String,default:``},strings:{type:Object,required:!0}},setup(G){let K=G,Ye=ee(),Xe=u(()=>String(Ye.props.locale||`en`).replace(`_`,`-`)),q=u(()=>K.strings.issue);function J(e){return e?new Date(e).toLocaleString(Xe.value,{dateStyle:`medium`,timeStyle:`short`}):q.value.none}function Y(e,t){return Object.entries(t).reduce((e,[t,n])=>e.replaceAll(`:${t}`,String(n??``)),e)}let X=l(!1);function Z(e,t=!1){X.value=!0,te.post(route(`admin.errors.status`,K.issue.id),{status:e,next_release:t},{preserveScroll:!0,onFinish:()=>{X.value=!1}})}let Q=l(`hourly`),$=l(!1),Ze=u(()=>(K.event?.exceptions??[]).map(e=>{let t=e.frames??[],n=t.filter(e=>e.in_app);return{...e,shown:$.value||n.length===0?t:n,hidden:t.length-n.length}}));function Qe(e){return[e.file,e.line].filter(Boolean).join(`:`)}let $e=u(()=>{let e=K.event?.request??{};return[[`method`,e.method],[`url`,e.url],[`route`,e.route],[`site`,K.event?.site],[`locale`,e.locale],[`user`,e.user_id]].filter(([,e])=>e!=null&&e!==``)}),et=u(()=>{let e=K.event??{};return[[`release`,e.release],[`php`,e.runtime?.php],[`laravel`,e.runtime?.laravel]].filter(([,e])=>e)}),tt=u(()=>Object.entries(K.event?.context??{}));function nt(e){return typeof e==`string`?e:JSON.stringify(e)}return(l,u)=>(r(),o(ne,{title:G.issue.short_class},{default:c(()=>[n(i(d),{href:l.route(`admin.errors.index`),class:`text-sm text-accent hover:text-accent-hover hover:underline`,dusk:`error-back`},{default:c(()=>[s(`← `+f(q.value.back),1)]),_:1},8,[`href`]),h(`div`,ae,[h(`div`,oe,[h(`h1`,se,f(G.issue.short_class),1),h(`p`,ce,f(G.issue.class),1),h(`p`,le,f(G.issue.message),1),G.issue.culprit?(r(),m(`p`,ue,f(G.issue.culprit),1)):t(``,!0),h(`p`,v,[h(`span`,y,f(G.strings.statuses[G.issue.status]),1),h(`span`,b,f(G.strings.levels[G.issue.level]??G.issue.level),1),h(`span`,x,f(G.strings.kinds[G.issue.kind]??G.issue.kind),1),G.issue.resolved_in?(r(),m(`span`,S,f(Y(q.value.resolved_in,{release:G.issue.resolved_in})),1)):t(``,!0),G.issue.regressed_at?(r(),m(`span`,C,f(q.value.regressed)+`: `+f(J(G.issue.regressed_at)),1)):t(``,!0)])]),h(`div`,w,[G.issue.status===`new`?(r(),m(p,{key:0},[n(g,{disabled:X.value,dusk:`error-resolve`,onClick:u[0]||=e=>Z(`resolved`)},{default:c(()=>[s(f(q.value.resolve),1)]),_:1},8,[`disabled`]),n(g,{variant:`secondary`,disabled:X.value,title:Y(q.value.resolve_next_hint,{release:G.currentRelease}),dusk:`error-resolve-next`,onClick:u[1]||=e=>Z(`resolved`,!0)},{default:c(()=>[s(f(q.value.resolve_next),1)]),_:1},8,[`disabled`,`title`]),n(g,{variant:`secondary`,disabled:X.value,dusk:`error-ignore`,onClick:u[2]||=e=>Z(`ignored`)},{default:c(()=>[s(f(q.value.ignore),1)]),_:1},8,[`disabled`])],64)):(r(),o(g,{key:1,variant:`secondary`,disabled:X.value,dusk:`error-reopen`,onClick:u[3]||=e=>Z(`new`)},{default:c(()=>[s(f(q.value.reopen),1)]),_:1},8,[`disabled`]))])]),G.issue.status===`new`?(r(),m(`p`,T,f(Y(q.value.resolve_next_hint,{release:G.currentRelease})),1)):t(``,!0),h(`dl`,E,[(r(!0),m(p,null,a([[G.strings.list.events,G.issue.times_seen],[G.strings.list.users,G.issue.users_seen],[G.strings.list.first_seen,J(G.issue.first_seen_at)],[G.strings.list.last_seen,J(G.issue.last_seen_at)],[q.value.first_release,G.issue.first_release||q.value.none],[q.value.last_release,G.issue.last_release||q.value.none]],([e,t])=>(r(),m(`div`,{key:e,class:`bg-surface rounded-lg shadow px-4 py-3 flex flex-col-reverse`},[h(`dt`,D,f(e),1),h(`dd`,O,f(t),1)]))),128))]),h(`div`,k,[n(_,{class:`lg:col-span-2`},{header:c(()=>[h(`div`,A,[h(`h2`,j,f(q.value.frequency),1),h(`div`,M,[(r(!0),m(p,null,a([[`hourly`,q.value.last_24h],[`daily`,q.value.last_30d]],([t,n])=>(r(),m(`button`,{key:t,type:`button`,class:e([`px-2.5 py-1 rounded text-sm border`,Q.value===t?`bg-accent text-on-accent border-accent`:`bg-surface text-fg border-field hover:bg-hover`]),"aria-pressed":Q.value===t,dusk:`error-chart-${t}`,onClick:e=>Q.value=t},f(n),11,N))),128))])])]),default:c(()=>[n(ie,{points:G.chart[Q.value],every:Q.value===`hourly`?3:5,label:`${q.value.frequency}, ${Q.value===`hourly`?q.value.last_24h:q.value.last_30d}`},null,8,[`points`,`every`,`label`])]),_:1}),n(_,null,{default:c(()=>[h(`h3`,P,f(q.value.top_paths),1),h(`ul`,F,[(r(!0),m(p,null,a(G.top.paths,e=>(r(),m(`li`,{key:e.value,class:`flex justify-between gap-3 py-0.5`},[h(`span`,I,f(e.value),1),h(`span`,L,f(e.count),1)]))),128)),G.top.paths.length?t(``,!0):(r(),m(`li`,R,f(q.value.none),1))]),h(`h3`,z,f(q.value.top_releases),1),h(`ul`,B,[(r(!0),m(p,null,a(G.top.releases,e=>(r(),m(`li`,{key:e.value,class:`flex justify-between gap-3 py-0.5`},[h(`span`,V,f(e.value),1),h(`span`,H,f(e.count),1)]))),128)),G.top.releases.length?t(``,!0):(r(),m(`li`,U,f(q.value.none),1))])]),_:1})]),G.event?(r(),m(p,{key:2},[n(_,{class:`mb-6`},{header:c(()=>[h(`div`,fe,[h(`h2`,pe,f(q.value.trace),1),h(`span`,me,f(q.value.shown)+`: `+f(J(G.event.created_at)),1),h(`button`,{type:`button`,class:`text-sm text-accent hover:text-accent-hover hover:underline`,dusk:`error-all-frames`,onClick:u[4]||=e=>$.value=!$.value},f($.value?q.value.app_frames:q.value.all_frames),1)])]),default:c(()=>[(r(!0),m(p,null,a(Ze.value,(e,n)=>(r(),m(`section`,{key:n,class:`mb-6 last:mb-0`,dusk:`error-exception`},[n>0?(r(),m(`p`,he,f(q.value.caused_by),1)):t(``,!0),h(`p`,ge,f(e.class),1),h(`p`,_e,f(e.message),1),h(`ol`,ve,[(r(!0),m(p,null,a(e.shown,(e,n)=>(r(),m(`li`,{key:n,class:`rounded border border-line`,dusk:`error-frame`},[h(`p`,ye,[h(`span`,be,f(e.function||q.value.none),1),h(`span`,xe,f(Qe(e)),1)]),e.context?(r(),m(`pre`,Se,[h(`code`,null,[(r(!0),m(p,null,a(e.context.pre,(t,n)=>(r(),m(`span`,{key:`pre${n}`,class:`block px-3 text-muted`},[h(`span`,Ce,f(e.line-e.context.pre.length+n),1),s(f(t),1)]))),128)),h(`span`,we,[h(`span`,W,f(e.line),1),s(f(e.context.line),1)]),(r(!0),m(p,null,a(e.context.post,(t,n)=>(r(),m(`span`,{key:`post${n}`,class:`block px-3 text-muted`},[h(`span`,Te,f(e.line+1+n),1),s(f(t),1)]))),128))])])):t(``,!0)]))),128))])]))),128))]),_:1}),h(`div`,Ee,[n(_,{title:q.value.request},{default:c(()=>[h(`dl`,De,[(r(!0),m(p,null,a($e.value,([e,t])=>(r(),m(p,{key:e},[h(`dt`,Oe,f(q.value[e]),1),h(`dd`,ke,f(t),1)],64))),128)),(r(!0),m(p,null,a(et.value,([e,t])=>(r(),m(p,{key:e},[h(`dt`,Ae,f(q.value[e]),1),h(`dd`,je,f(t),1)],64))),128)),(r(!0),m(p,null,a(tt.value,([e,t])=>(r(),m(p,{key:`context-${e}`},[h(`dt`,Me,f(e),1),h(`dd`,Ne,f(nt(t)),1)],64))),128))])]),_:1},8,[`title`]),n(_,{title:q.value.breadcrumbs},{default:c(()=>[h(`ol`,Pe,[(r(!0),m(p,null,a(G.event.breadcrumbs,(e,t)=>(r(),m(`li`,{key:t,class:`grid grid-cols-[auto_auto_1fr] gap-3`},[h(`span`,Fe,f(e.time),1),h(`span`,Ie,f(e.category),1),h(`span`,Le,f(e.message),1)]))),128)),G.event.breadcrumbs?.length?t(``,!0):(r(),m(`li`,Re,f(q.value.none),1))])]),_:1},8,[`title`])])],64)):(r(),m(`p`,de,f(q.value.no_event),1)),n(_,{title:q.value.occurrences,"no-padding":``},{default:c(()=>[h(`table`,ze,[h(`thead`,Be,[h(`tr`,null,[(r(),m(p,null,a([`time`,`site`,`method`,`url`,`release`,`user`],e=>h(`th`,{key:e,scope:`col`,class:`px-4 py-2 text-left font-medium text-fg`},f(q.value[e]),1)),64))])]),h(`tbody`,Ve,[(r(!0),m(p,null,a(G.occurrences.data,t=>(r(),m(`tr`,{key:t.id,class:e(t.id===G.event?.id?`bg-accent-soft text-accent-soft-fg`:`hover:bg-hover`)},[h(`td`,He,[t.id===G.event?.id?(r(),m(`span`,Ue,f(J(t.created_at))+` · `+f(q.value.shown),1)):(r(),o(i(d),{key:1,href:l.route(`admin.errors.show`,{issue:G.issue.id,event:t.id}),"preserve-scroll":``,class:`text-accent hover:text-accent-hover hover:underline`,dusk:`error-occurrence`},{default:c(()=>[s(f(J(t.created_at)),1)]),_:2},1032,[`href`]))]),h(`td`,We,f(t.site??q.value.none),1),h(`td`,Ge,f(t.method??q.value.none),1),h(`td`,Ke,f(t.path??q.value.none),1),h(`td`,qe,f(t.release),1),h(`td`,Je,f(t.user_id??q.value.none),1)],2))),128))])]),G.occurrences.last_page>1?(r(),o(re,{key:0,paginator:G.occurrences},null,8,[`paginator`])):t(``,!0)]),_:1},8,[`title`])]),_:1},8,[`title`]))}};export{G as default}; \ No newline at end of file diff --git a/packages/admin/dist/assets/app-BNjy5Z6H.js b/packages/admin/dist/assets/app-BCJOqmKO.js similarity index 87% rename from packages/admin/dist/assets/app-BNjy5Z6H.js rename to packages/admin/dist/assets/app-BCJOqmKO.js index 982986f2..0032554c 100644 --- a/packages/admin/dist/assets/app-BNjy5Z6H.js +++ b/packages/admin/dist/assets/app-BCJOqmKO.js @@ -1,2 +1,2 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/Index-C_p9UH4T.js","assets/dist-MY__znoP.js","assets/AdminLayout--RXJFj9t.js","assets/LocaleSwitcher-DdLJ9WTE.js","assets/AdminLayout-QfjingjX.css","assets/AdminButton-Bx141Bs3.js","assets/AdminCard--HubMtUj.js","assets/AdminModal-DNJ_V4iq.js","assets/Login-D_P0ceoZ.js","assets/Index-9-V30Hlc.js","assets/Index-bqKVRXw8.js","assets/Dashboard-BU7gtvAo.js","assets/Index-1mD_GBWn.js","assets/Settings-C2VyFPrB.js","assets/FormField-xD6LELDV.js","assets/FormField-0qI8GE1v.css","assets/contentLocale-BtGD-iBF.js","assets/Edit-D-yhP5A2.js","assets/Create-BxhK0Jvn.js","assets/ContentLocaleSwitcher-BJIieXK-.js","assets/Edit-CHndUQJ2.js","assets/recordActions-CtRs42tG.js","assets/Index-CjLWl74m.js","assets/AdminDataTable-BaQwb_6U.js","assets/Edit-pGNJhUsL.js","assets/Index-P5jX14JD.js","assets/Create-C61-lS2c.js","assets/Edit-DGjzU-uC.js","assets/Index-DEbfZBFs.js"])))=>i.map(i=>d[i]); -import{k as e,l as t,o as n,s as r,t as i}from"./dist-MY__znoP.js";var a=`modulepreload`,o=function(e){return`/vendor/atrium/`+e},s={},c=function(e){return e.pathname.endsWith(`.css`)},l=function(e,t,n){if(t in e)return e[t];let r=n();if(!r){e[t]=void 0;return}let i=r.then(()=>{e[t]=void 0},n=>{throw e[t]=void 0,n});return e[t]=i,i},u=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e,i=document.querySelector(`meta[property=csp-nonce]`),u=i?.nonce||i?.getAttribute(`nonce`);function d(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function f(e){return import.meta.resolve?new URL(import.meta.resolve(e)):new URL(e,import.meta.url)}r=d(t.map(t=>{t=o(t,n);let r=f(t),i=c(r);return l(s,r.href,()=>{if(e===void 0){e={all:new Set,styles:new Set};let t=document.getElementsByTagName(`link`);for(let n=t.length-1;n>=0;n--){let r=t[n];e.all.add(r.href),r.rel===`stylesheet`&&e.styles.add(r.href)}}if((i?e.styles:e.all).has(r.href))return;let t=document.createElement(`link`);if(t.rel=i?`stylesheet`:a,i||(t.as=`script`),t.crossOrigin=``,t.href=r.href,u&&t.setAttribute(`nonce`,u),document.head.appendChild(t),i)return new Promise((e,n)=>{let i=a=>{t.removeEventListener(`load`,i),t.removeEventListener(`error`,i),a.type===`error`?n(Error(`Unable to preload CSS for ${r}`)):e(a)};t.addEventListener(`load`,i),t.addEventListener(`error`,i)})})}).filter(e=>e!==void 0))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},d=String.prototype.replace,f=/%20/g,p={RFC1738:`RFC1738`,RFC3986:`RFC3986`},m={RFC1738:function(e){return d.call(e,f,`+`)},RFC3986:function(e){return String(e)}},h=p.RFC1738;p.RFC3986;var g=p.RFC3986,_=Object.prototype.hasOwnProperty,v=Array.isArray,y=new WeakMap,b=function(e,t){return y.set(e,t),e};function x(e){return y.has(e)}var S=function(e){return y.get(e)},C=function(e,t){y.set(e,t)},w=(function(){let e=[];for(let t=0;t<256;++t)e.push(`%`+((t<16?`0`:``)+t.toString(16)).toUpperCase());return e})(),T=function(e){for(;e.length>1;){let t=e.pop(),n=t.obj[t.prop];if(v(n)){let e=[];for(let t=0;t=0&&e>S(t)&&C(t,e)}return t},l)},te=function(e){let t=e.replace(/\+/g,` `);try{return decodeURIComponent(t)}catch{return t}},D=1024,ne=function(e,t,n,r){if(e.length===0)return e;let i=e;typeof e==`symbol`?i=Symbol.prototype.toString.call(e):typeof e!=`string`&&(i=String(e));let a=``;for(let e=0;e=D?i.slice(e,e+D):i;if(e+D=55296&&n<=56319&&(t=t.slice(0,-1),--e)}let n=[];for(let e=0;e=48&&i<=57||i>=65&&i<=90||i>=97&&i<=122||r===h&&(i===40||i===41)?n[n.length]=t.charAt(e):i<128?n[n.length]=w[i]:i<2048?n[n.length]=w[192|i>>6]+w[128|i&63]:i<55296||i>=57344?n[n.length]=w[224|i>>12]+w[128|i>>6&63]+w[128|i&63]:(e+=1,i=65536+((i&1023)<<10|t.charCodeAt(e)&1023),n[n.length]=w[240|i>>18]+w[128|i>>12&63]+w[128|i>>6&63]+w[128|i&63])}a+=n.join(``)}return a},re=function(e){let t=[{obj:{o:e},prop:`o`}],n=new WeakMap;for(let e=0;en?b(E(a,{plainObjects:r}),a.length-1):a},k=function(e,t){if(v(e)){let n=[];for(let r=0;r0?_.join(`,`)||null:void 0}];else if(j(l))S=l;else{let e=Object.keys(_);S=u?e.sort(u):e}let C=s?t.replace(/\./g,`%2E`):t,w=r&&j(_)&&_.length===1?C+`[]`:C;if(i&&j(_)&&_.length===0)return w+`[]`;for(let t=0;t0?d+u:``}var L=Object.prototype.hasOwnProperty,R=Array.isArray,z={allowDots:!1,allowEmptyArrays:!1,allowPrototypes:!1,allowSparse:!1,arrayLimit:20,comma:!1,decodeDotInKeys:!1,decoder:te,delimiter:`&`,depth:5,duplicates:`combine`,ignoreQueryPrefix:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictNullHandling:!1},B=function(e,t){return e&&typeof e==`string`&&t.comma&&e.indexOf(`,`)>-1?e.split(`,`):e},fe=function(e,t){let n={__proto__:null},r=t.ignoreQueryPrefix?e.replace(/^\?/,``):e,i=t.parameterLimit===1/0?void 0:t.parameterLimit,a=r.split(t.delimiter,i),o=0;for(;o-1&&(c=R(c)?[c]:c),t.comma&&R(c)&&c.length>t.arrayLimit&&(c=O([],c,t.arrayLimit,t.plainObjects));let l=L.call(n,s);l&&t.duplicates===`combine`?n[s]=O(n[s],c,t.arrayLimit,t.plainObjects):l&&t.duplicates!==`last`||(n[s]=c)}return n},pe=function(e,t,n,r){let i=r?t:B(t,n);for(let t=e.length-1;t>=0;--t){let r,a=e[t];if(a===`[]`&&n.parseArrays)r=x(i)?i:n.allowEmptyArrays&&(i===``||n.strictNullHandling&&i===null)?[]:O([],i,n.arrayLimit,n.plainObjects);else{r=n.plainObjects?Object.create(null):{};let e=a.charAt(0)===`[`&&a.charAt(a.length-1)===`]`?a.slice(1,-1):a,t=n.decodeDotInKeys?e.replace(/%2E/g,`.`):e,o=parseInt(t,10),s=!isNaN(o)&&a!==t&&String(o)===t&&o>=0&&n.parseArrays;!n.parseArrays&&t===``?r={0:i}:s&&o<=n.arrayLimit?(r=[],r[o]=i):s?(r[o]=i,b(r,o)):t!==`__proto__`&&(r[t]=i)}i=r}return i},me=function(e,t,n,r){if(!e)return;let i=n.allowDots?e.replace(/\.([^.[]+)/g,`[$1]`):e,a=/(\[[^[\]]*])/,o=/(\[[^[\]]*])/g,s=n.depth>0&&a.exec(i),c=s?i.slice(0,s.index):i,l=[];if(c){if(!n.plainObjects&&L.call(Object.prototype,c)&&!n.allowPrototypes)return;l.push(c)}let u=0;for(;n.depth>0&&(s=o.exec(i))!==null&&u{try{return decodeURIComponent(e)}catch{return e}})}var H=class{constructor(e,t,n){this.name=e,this.definition=t,this.bindings=t.bindings??{},this.wheres=t.wheres??{},this.config=n}get template(){let e=`${this.origin}/${this.definition.uri}`.replace(/\/+$/,``);return e===``?`/`:e}get origin(){return this.config.absolute?this.definition.domain?`${this.config.url.match(/^\w+:\/\//)[0]}${this.definition.domain}${this.config.port?`:${this.config.port}`:``}`:this.config.url:``}get parameterSegments(){return this.template.match(/{[^}?]+\??}/g)?.map(e=>({name:e.replace(/{|\??}/g,``),required:!/\?}$/.test(e)}))??[]}matchesUrl(e){if(!this.definition.methods.includes(`GET`))return!1;let t=this.template.replace(/[.*+$()[\]]/g,`\\$&`).replace(/(\/?){([^}?]*)(\??)}/g,(e,t,n,r)=>{let i=`(?<${n}>${this.wheres[n]?.replace(/(^\^)|(\$$)/g,``)||`[^/?]+`})`;return r?`(${t}${i})?`:`${t}${i}`}).replace(/^\w+:\/\//,``),[n,r]=e.replace(/^\w+:\/\//,``).split(`?`),i=RegExp(`^${t}/?$`).exec(n);if(!i)try{i=RegExp(`^${t}/?$`).exec(decodeURI(n))}catch{}if(i){for(let e in i.groups)typeof i.groups[e]==`string`&&(i.groups[e]=V(i.groups[e]));return{params:i.groups,query:ge(r)}}return!1}compile(e){return this.parameterSegments.length?this.template.replace(/{([^}?]+)(\??)}/g,(t,n,r)=>{if(!r&&[null,void 0].includes(e[n]))throw Error(`Ziggy error: '${n}' parameter is required for route '${this.name}'.`);if(this.wheres[n]&&!RegExp(`^${r?`(${this.wheres[n]})?`:this.wheres[n]}$`).test(e[n]??``))throw Error(`Ziggy error: '${n}' parameter '${e[n]}' does not match required format '${this.wheres[n]}' for route '${this.name}'.`);return encodeURI(e[n]??``).replace(/%7C/g,`|`).replace(/%25/g,`%`).replace(/\$/g,`%24`)}).replace(this.config.absolute?/(\.[^/]+?)(\/\/)/:/(^)(\/\/)/,`$1/`).replace(/\/+$/,``):this.template}};function U(e){"@babel/helpers - typeof";return U=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},U(e)}function _e(e,t){if(U(e)!=`object`||!e)return e;var n;if(typeof Symbol<`u`&&(n=e[Symbol.toPrimitive])!==void 0){var r=n.call(e,t||`default`);if(U(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function ve(e){var t=_e(e,`string`);return U(t)==`symbol`?t:t+``}function ye(e,t,n){return(t=ve(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function W(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function G(e){for(var t=1;t!this._route.parameterSegments.some(({name:t})=>t===e)).filter(e=>e!==`_query`).reduce((e,t)=>G(G({},e),{},{[t]:this._params[t]}),{});return this._route.compile(this._params)+de(G(G({},e),this._params._query),{addQueryPrefix:!0,arrayFormat:`indices`,encodeValuesOnly:!0,skipNulls:!0,encoder:(e,t)=>typeof e==`boolean`?Number(e):t(e)})}_unresolve(e){e?this._config.absolute&&e.startsWith(`/`)&&(e=this._location().host+e):e=this._currentUrl();let t={},[n,r]=Object.entries(this._config.routes).find(([n,r])=>t=new H(n,r,this._config).matchesUrl(e))||[void 0,void 0];return G(G({name:n},t),{},{route:r})}_currentUrl(){let{host:e,pathname:t,search:n}=this._location();return(this._config.absolute?e+t:t.replace(this._config.url.replace(/^\w*:\/\/[^/]+/,``),``).replace(/^\/+/,`/`))+n}current(e,t){let{name:n,params:r,query:i,route:a}=this._unresolve();if(!e)return n;let o=RegExp(`^${e.replace(/\./g,`\\.`).replace(/\*/g,`.*`)}$`).test(n);if([null,void 0].includes(t)||!o)return o;let s=new H(n,a,this._config);t=this._parse(t,s);let c=G(G({},r),i);if(Object.values(t).every(e=>!e)&&!Object.values(c).some(e=>e!==void 0))return!0;let l=(e,t)=>Object.entries(e).every(([e,n])=>Array.isArray(n)&&Array.isArray(t[e])?n.every(n=>t[e].includes(n)||t[e].includes(V(String(n)))):typeof n==`object`&&typeof t[e]==`object`&&n!==null&&t[e]!==null?l(n,t[e]):t[e]==n||t[e]==V(String(n)));return l(t,c)}_location(){let{host:e=``,pathname:t=``,search:n=``}=typeof window<`u`?window.location:{},r=typeof this._config.location==`string`?new URL(this._config.location):this._config.location;return{host:r?.host??e,pathname:r?.pathname??t,search:r?.search??n}}get params(){let{params:e,query:t}=this._unresolve();return G(G({},e),t)}get routeParams(){return this._unresolve().params}get queryParams(){return this._unresolve().query}has(e){return this._config.routes.hasOwnProperty(e)}_parse(e={},t=this._route){e??={},e=[`string`,`number`].includes(typeof e)?[e]:e;let n=t.parameterSegments.filter(({name:e})=>!this._config.defaults[e]);return Array.isArray(e)?e=e.reduce((e,t,r)=>n[r]?G(G({},e),{},{[n[r].name]:t}):typeof t==`object`?G(G({},e),t):G(G({},e),{},{[t]:``}),{}):n.length===1&&!e.hasOwnProperty(n[0].name)&&(e.hasOwnProperty(Object.values(t.bindings)[0])||e.hasOwnProperty(`id`))&&(e={[n[0].name]:e}),G(G({},this._defaults(t)),this._substituteBindings(e,t))}_defaults(e){return e.parameterSegments.filter(({name:e})=>this._config.defaults[e]).reduce((e,{name:t},n)=>G(G({},e),{},{[t]:this._config.defaults[t]}),{})}_substituteBindings(e,{bindings:t,parameterSegments:n}){return Object.entries(e).reduce((e,[r,i])=>{if(!i||typeof i!=`object`||Array.isArray(i)||!n.some(({name:e})=>e===r))return G(G({},e),{},{[r]:i});let a=i.hasOwnProperty(t[r])?t[r]:i.hasOwnProperty(`id`)?`id`:void 0;if(a===void 0)throw Error(`Ziggy error: object passed as '${r}' parameter is missing route model binding key '${t[r]}'.`);return G(G({},e),{},{[r]:i[a]})},{})}valueOf(){return this.toString()}};function xe(e,t,n,r){let i=new be(e,t,n,r);return e?i.toString():i}var Se={install(e,t){let n=(e,n,r,i=t)=>xe(e,n,r,typeof i==`function`?i():i);parseInt(e.version)>2?(e.config.globalProperties.route=n,e.provide(`route`,n)):e.mixin({methods:{route:n}})}};function Ce(e,t){let n=Math.trunc(t)%10,r=Math.trunc(t)%100;switch(e){case`ja`:case`zh_CN`:case`tr`:case`kk`:case`uz`:return 0;case`fr`:return t===0||t===1?0:1;case`ru`:case`uk`:case`be`:return n===1&&r!==11?0:n>=2&&n<=4&&(r<10||r>=20)?1:2;case`pl`:return t===1?0:n>=2&&n<=4&&(r<12||r>14)?1:2;default:return t===1?0:1}}function K(){return n().props.translations||{}}function we(){return n().props.locale||`en`}function q(e,t){return Object.entries(t).reduce((e,[t,n])=>e.replaceAll(`:${t}`,String(n??``)),e)}function J(e,t={}){let n=K()[e];return typeof n==`string`?q(n,t):e}function Te(e,t,n={}){let r=K()[e];if(typeof r!=`string`)return e;let i=r.split(`|`),a=i[Math.min(Ce(we(),t),i.length-1)];return q(a,{count:t,...n})}var Ee={install(e){e.config.globalProperties.$t=J,e.config.globalProperties.$tc=Te}},De=[`graphite`,`day`,`night`,`sand`,`contrast`],Y=typeof window<`u`&&window.matchMedia?window.matchMedia(`(prefers-color-scheme: dark)`):null,X=null,Oe=e=>e===`system`?Y?.matches?`night`:`graphite`:De.includes(e)?e:`graphite`;function Z(e){if(!e)return;X=e;let t=document.documentElement;t.dataset.themeChoice=e,t.dataset.theme=Oe(e)}Y?.addEventListener(`change`,()=>{X===`system`&&Z(X)});var Q=e=>{let t=e.detail.page.props.locale;t&&(document.documentElement.lang=t.replace(`_`,`-`))};r.on(`success`,Q),r.on(`navigate`,Q);var $=e=>Z(e.detail.page.props.theme);r.on(`success`,$),r.on(`navigate`,$);var ke=Object.assign({"./Pages/Admin/ApiTokens/Index.vue":()=>u(()=>import(`./Index-C_p9UH4T.js`),__vite__mapDeps([0,1,2,3,4,5,6,7])),"./Pages/Admin/Auth/Login.vue":()=>u(()=>import(`./Login-D_P0ceoZ.js`),__vite__mapDeps([8,1,3])),"./Pages/Admin/Backups/Index.vue":()=>u(()=>import(`./Index-9-V30Hlc.js`),__vite__mapDeps([9,1,2,3,4,5,6,7])),"./Pages/Admin/Cache/Index.vue":()=>u(()=>import(`./Index-bqKVRXw8.js`),__vite__mapDeps([10,1,2,3,4,5])),"./Pages/Admin/Dashboard.vue":()=>u(()=>import(`./Dashboard-BU7gtvAo.js`),__vite__mapDeps([11,1,2,3,4])),"./Pages/Admin/Modules/Index.vue":()=>u(()=>import(`./Index-1mD_GBWn.js`),__vite__mapDeps([12,1,2,3,4,5])),"./Pages/Admin/Modules/Settings.vue":()=>u(()=>import(`./Settings-C2VyFPrB.js`),__vite__mapDeps([13,1,2,3,4,5,6,14,7,15,16])),"./Pages/Admin/Profile/Edit.vue":()=>u(()=>import(`./Edit-D-yhP5A2.js`),__vite__mapDeps([17,1,2,3,4])),"./Pages/Admin/Resource/Create.vue":()=>u(()=>import(`./Create-BxhK0Jvn.js`),__vite__mapDeps([18,1,2,3,4,5,6,19,14,7,15,16])),"./Pages/Admin/Resource/Edit.vue":()=>u(()=>import(`./Edit-CHndUQJ2.js`),__vite__mapDeps([20,1,2,3,4,5,6,19,14,7,15,16,21])),"./Pages/Admin/Resource/Index.vue":()=>u(()=>import(`./Index-CjLWl74m.js`),__vite__mapDeps([22,1,2,3,4,5,23,7,21])),"./Pages/Admin/Roles/Edit.vue":()=>u(()=>import(`./Edit-pGNJhUsL.js`),__vite__mapDeps([24,1,2,3,4,5,6])),"./Pages/Admin/Roles/Index.vue":()=>u(()=>import(`./Index-P5jX14JD.js`),__vite__mapDeps([25,1,2,3,4,5,7])),"./Pages/Admin/Users/Create.vue":()=>u(()=>import(`./Create-C61-lS2c.js`),__vite__mapDeps([26,1,2,3,4,5,6,14,7,15])),"./Pages/Admin/Users/Edit.vue":()=>u(()=>import(`./Edit-DGjzU-uC.js`),__vite__mapDeps([27,1,2,3,4,5,6,14,7,15])),"./Pages/Admin/Users/Index.vue":()=>u(()=>import(`./Index-DEbfZBFs.js`),__vite__mapDeps([28,1,2,3,4,5,23,7]))});i({title:e=>{let t=document.querySelector(`title`)?.dataset.brand||`Atrium`;return e?`${e} — ${t}`:t},resolve:e=>{let t=ke[`./Pages/${e}.vue`];if(!t)throw Error(`Atrium: page "${e}" not found`);return t()},setup({el:n,App:r,props:i,plugin:a}){Z(i.initialPage.props.theme),t({render:()=>e(r,i)}).use(a).use(Se).use(Ee).mount(n)},progress:{color:`var(--atrium-accent)`}});export{J as n,Z as t}; \ No newline at end of file +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/Index-ZYMbBsuF.js","assets/dist-Bie52OmN.js","assets/AdminLayout-DBeSErmz.js","assets/LocaleSwitcher-DAWnmZni.js","assets/AdminLayout-QfjingjX.css","assets/AdminButton-KiIJ2sLW.js","assets/AdminCard-YbEwPtJz.js","assets/AdminModal-DKazeNNa.js","assets/Login-DTW3u1G9.js","assets/Index-CG3NSbtt.js","assets/Index-DsLgvcm0.js","assets/Dashboard-C9RqcuE0.js","assets/BarChart-wks0RLo_.js","assets/Index-D_2Ij5S1.js","assets/AdminPagination-D7rwNfhd.js","assets/Show-CS6rq4RP.js","assets/Index-B9KqS9R5.js","assets/Settings-BrbOStcv.js","assets/FormField-B-XX4VFv.js","assets/FormField-0qI8GE1v.css","assets/contentLocale-BV_E0iGS.js","assets/Edit-CyzBsvwt.js","assets/Create-DutDQiBS.js","assets/ContentLocaleSwitcher-HJzbB87a.js","assets/Edit-BEWPbBmM.js","assets/recordActions-CtRs42tG.js","assets/Index-DaeZ92GY.js","assets/AdminDataTable-6eKgKDeA.js","assets/Edit-Bm3W6F3v.js","assets/Index-BNmU5PEL.js","assets/Create-CbxIXc0Q.js","assets/Edit-Cp-LIO0D.js","assets/Index-C63EL5RF.js"])))=>i.map(i=>d[i]); +import{k as e,l as t,o as n,s as r,t as i}from"./dist-Bie52OmN.js";var a=`modulepreload`,o=function(e){return`/vendor/atrium/`+e},s={},c=function(e){return e.pathname.endsWith(`.css`)},l=function(e,t,n){if(t in e)return e[t];let r=n();if(!r){e[t]=void 0;return}let i=r.then(()=>{e[t]=void 0},n=>{throw e[t]=void 0,n});return e[t]=i,i},u=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e,i=document.querySelector(`meta[property=csp-nonce]`),u=i?.nonce||i?.getAttribute(`nonce`);function d(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function f(e){return import.meta.resolve?new URL(import.meta.resolve(e)):new URL(e,import.meta.url)}r=d(t.map(t=>{t=o(t,n);let r=f(t),i=c(r);return l(s,r.href,()=>{if(e===void 0){e={all:new Set,styles:new Set};let t=document.getElementsByTagName(`link`);for(let n=t.length-1;n>=0;n--){let r=t[n];e.all.add(r.href),r.rel===`stylesheet`&&e.styles.add(r.href)}}if((i?e.styles:e.all).has(r.href))return;let t=document.createElement(`link`);if(t.rel=i?`stylesheet`:a,i||(t.as=`script`),t.crossOrigin=``,t.href=r.href,u&&t.setAttribute(`nonce`,u),document.head.appendChild(t),i)return new Promise((e,n)=>{let i=a=>{t.removeEventListener(`load`,i),t.removeEventListener(`error`,i),a.type===`error`?n(Error(`Unable to preload CSS for ${r}`)):e(a)};t.addEventListener(`load`,i),t.addEventListener(`error`,i)})})}).filter(e=>e!==void 0))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},d=String.prototype.replace,f=/%20/g,p={RFC1738:`RFC1738`,RFC3986:`RFC3986`},m={RFC1738:function(e){return d.call(e,f,`+`)},RFC3986:function(e){return String(e)}},h=p.RFC1738;p.RFC3986;var g=p.RFC3986,_=Object.prototype.hasOwnProperty,v=Array.isArray,y=new WeakMap,b=function(e,t){return y.set(e,t),e};function x(e){return y.has(e)}var S=function(e){return y.get(e)},C=function(e,t){y.set(e,t)},w=(function(){let e=[];for(let t=0;t<256;++t)e.push(`%`+((t<16?`0`:``)+t.toString(16)).toUpperCase());return e})(),T=function(e){for(;e.length>1;){let t=e.pop(),n=t.obj[t.prop];if(v(n)){let e=[];for(let t=0;t=0&&e>S(t)&&C(t,e)}return t},l)},te=function(e){let t=e.replace(/\+/g,` `);try{return decodeURIComponent(t)}catch{return t}},D=1024,ne=function(e,t,n,r){if(e.length===0)return e;let i=e;typeof e==`symbol`?i=Symbol.prototype.toString.call(e):typeof e!=`string`&&(i=String(e));let a=``;for(let e=0;e=D?i.slice(e,e+D):i;if(e+D=55296&&n<=56319&&(t=t.slice(0,-1),--e)}let n=[];for(let e=0;e=48&&i<=57||i>=65&&i<=90||i>=97&&i<=122||r===h&&(i===40||i===41)?n[n.length]=t.charAt(e):i<128?n[n.length]=w[i]:i<2048?n[n.length]=w[192|i>>6]+w[128|i&63]:i<55296||i>=57344?n[n.length]=w[224|i>>12]+w[128|i>>6&63]+w[128|i&63]:(e+=1,i=65536+((i&1023)<<10|t.charCodeAt(e)&1023),n[n.length]=w[240|i>>18]+w[128|i>>12&63]+w[128|i>>6&63]+w[128|i&63])}a+=n.join(``)}return a},re=function(e){let t=[{obj:{o:e},prop:`o`}],n=new WeakMap;for(let e=0;en?b(E(a,{plainObjects:r}),a.length-1):a},k=function(e,t){if(v(e)){let n=[];for(let r=0;r0?_.join(`,`)||null:void 0}];else if(j(l))S=l;else{let e=Object.keys(_);S=u?e.sort(u):e}let C=s?t.replace(/\./g,`%2E`):t,w=r&&j(_)&&_.length===1?C+`[]`:C;if(i&&j(_)&&_.length===0)return w+`[]`;for(let t=0;t0?d+u:``}var L=Object.prototype.hasOwnProperty,R=Array.isArray,z={allowDots:!1,allowEmptyArrays:!1,allowPrototypes:!1,allowSparse:!1,arrayLimit:20,comma:!1,decodeDotInKeys:!1,decoder:te,delimiter:`&`,depth:5,duplicates:`combine`,ignoreQueryPrefix:!1,parameterLimit:1e3,parseArrays:!0,plainObjects:!1,strictNullHandling:!1},B=function(e,t){return e&&typeof e==`string`&&t.comma&&e.indexOf(`,`)>-1?e.split(`,`):e},fe=function(e,t){let n={__proto__:null},r=t.ignoreQueryPrefix?e.replace(/^\?/,``):e,i=t.parameterLimit===1/0?void 0:t.parameterLimit,a=r.split(t.delimiter,i),o=0;for(;o-1&&(c=R(c)?[c]:c),t.comma&&R(c)&&c.length>t.arrayLimit&&(c=O([],c,t.arrayLimit,t.plainObjects));let l=L.call(n,s);l&&t.duplicates===`combine`?n[s]=O(n[s],c,t.arrayLimit,t.plainObjects):l&&t.duplicates!==`last`||(n[s]=c)}return n},pe=function(e,t,n,r){let i=r?t:B(t,n);for(let t=e.length-1;t>=0;--t){let r,a=e[t];if(a===`[]`&&n.parseArrays)r=x(i)?i:n.allowEmptyArrays&&(i===``||n.strictNullHandling&&i===null)?[]:O([],i,n.arrayLimit,n.plainObjects);else{r=n.plainObjects?Object.create(null):{};let e=a.charAt(0)===`[`&&a.charAt(a.length-1)===`]`?a.slice(1,-1):a,t=n.decodeDotInKeys?e.replace(/%2E/g,`.`):e,o=parseInt(t,10),s=!isNaN(o)&&a!==t&&String(o)===t&&o>=0&&n.parseArrays;!n.parseArrays&&t===``?r={0:i}:s&&o<=n.arrayLimit?(r=[],r[o]=i):s?(r[o]=i,b(r,o)):t!==`__proto__`&&(r[t]=i)}i=r}return i},me=function(e,t,n,r){if(!e)return;let i=n.allowDots?e.replace(/\.([^.[]+)/g,`[$1]`):e,a=/(\[[^[\]]*])/,o=/(\[[^[\]]*])/g,s=n.depth>0&&a.exec(i),c=s?i.slice(0,s.index):i,l=[];if(c){if(!n.plainObjects&&L.call(Object.prototype,c)&&!n.allowPrototypes)return;l.push(c)}let u=0;for(;n.depth>0&&(s=o.exec(i))!==null&&u{try{return decodeURIComponent(e)}catch{return e}})}var H=class{constructor(e,t,n){this.name=e,this.definition=t,this.bindings=t.bindings??{},this.wheres=t.wheres??{},this.config=n}get template(){let e=`${this.origin}/${this.definition.uri}`.replace(/\/+$/,``);return e===``?`/`:e}get origin(){return this.config.absolute?this.definition.domain?`${this.config.url.match(/^\w+:\/\//)[0]}${this.definition.domain}${this.config.port?`:${this.config.port}`:``}`:this.config.url:``}get parameterSegments(){return this.template.match(/{[^}?]+\??}/g)?.map(e=>({name:e.replace(/{|\??}/g,``),required:!/\?}$/.test(e)}))??[]}matchesUrl(e){if(!this.definition.methods.includes(`GET`))return!1;let t=this.template.replace(/[.*+$()[\]]/g,`\\$&`).replace(/(\/?){([^}?]*)(\??)}/g,(e,t,n,r)=>{let i=`(?<${n}>${this.wheres[n]?.replace(/(^\^)|(\$$)/g,``)||`[^/?]+`})`;return r?`(${t}${i})?`:`${t}${i}`}).replace(/^\w+:\/\//,``),[n,r]=e.replace(/^\w+:\/\//,``).split(`?`),i=RegExp(`^${t}/?$`).exec(n);if(!i)try{i=RegExp(`^${t}/?$`).exec(decodeURI(n))}catch{}if(i){for(let e in i.groups)typeof i.groups[e]==`string`&&(i.groups[e]=V(i.groups[e]));return{params:i.groups,query:ge(r)}}return!1}compile(e){return this.parameterSegments.length?this.template.replace(/{([^}?]+)(\??)}/g,(t,n,r)=>{if(!r&&[null,void 0].includes(e[n]))throw Error(`Ziggy error: '${n}' parameter is required for route '${this.name}'.`);if(this.wheres[n]&&!RegExp(`^${r?`(${this.wheres[n]})?`:this.wheres[n]}$`).test(e[n]??``))throw Error(`Ziggy error: '${n}' parameter '${e[n]}' does not match required format '${this.wheres[n]}' for route '${this.name}'.`);return encodeURI(e[n]??``).replace(/%7C/g,`|`).replace(/%25/g,`%`).replace(/\$/g,`%24`)}).replace(this.config.absolute?/(\.[^/]+?)(\/\/)/:/(^)(\/\/)/,`$1/`).replace(/\/+$/,``):this.template}};function U(e){"@babel/helpers - typeof";return U=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},U(e)}function _e(e,t){if(U(e)!=`object`||!e)return e;var n;if(typeof Symbol<`u`&&(n=e[Symbol.toPrimitive])!==void 0){var r=n.call(e,t||`default`);if(U(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function ve(e){var t=_e(e,`string`);return U(t)==`symbol`?t:t+``}function ye(e,t,n){return(t=ve(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function W(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function G(e){for(var t=1;t!this._route.parameterSegments.some(({name:t})=>t===e)).filter(e=>e!==`_query`).reduce((e,t)=>G(G({},e),{},{[t]:this._params[t]}),{});return this._route.compile(this._params)+de(G(G({},e),this._params._query),{addQueryPrefix:!0,arrayFormat:`indices`,encodeValuesOnly:!0,skipNulls:!0,encoder:(e,t)=>typeof e==`boolean`?Number(e):t(e)})}_unresolve(e){e?this._config.absolute&&e.startsWith(`/`)&&(e=this._location().host+e):e=this._currentUrl();let t={},[n,r]=Object.entries(this._config.routes).find(([n,r])=>t=new H(n,r,this._config).matchesUrl(e))||[void 0,void 0];return G(G({name:n},t),{},{route:r})}_currentUrl(){let{host:e,pathname:t,search:n}=this._location();return(this._config.absolute?e+t:t.replace(this._config.url.replace(/^\w*:\/\/[^/]+/,``),``).replace(/^\/+/,`/`))+n}current(e,t){let{name:n,params:r,query:i,route:a}=this._unresolve();if(!e)return n;let o=RegExp(`^${e.replace(/\./g,`\\.`).replace(/\*/g,`.*`)}$`).test(n);if([null,void 0].includes(t)||!o)return o;let s=new H(n,a,this._config);t=this._parse(t,s);let c=G(G({},r),i);if(Object.values(t).every(e=>!e)&&!Object.values(c).some(e=>e!==void 0))return!0;let l=(e,t)=>Object.entries(e).every(([e,n])=>Array.isArray(n)&&Array.isArray(t[e])?n.every(n=>t[e].includes(n)||t[e].includes(V(String(n)))):typeof n==`object`&&typeof t[e]==`object`&&n!==null&&t[e]!==null?l(n,t[e]):t[e]==n||t[e]==V(String(n)));return l(t,c)}_location(){let{host:e=``,pathname:t=``,search:n=``}=typeof window<`u`?window.location:{},r=typeof this._config.location==`string`?new URL(this._config.location):this._config.location;return{host:r?.host??e,pathname:r?.pathname??t,search:r?.search??n}}get params(){let{params:e,query:t}=this._unresolve();return G(G({},e),t)}get routeParams(){return this._unresolve().params}get queryParams(){return this._unresolve().query}has(e){return this._config.routes.hasOwnProperty(e)}_parse(e={},t=this._route){e??={},e=[`string`,`number`].includes(typeof e)?[e]:e;let n=t.parameterSegments.filter(({name:e})=>!this._config.defaults[e]);return Array.isArray(e)?e=e.reduce((e,t,r)=>n[r]?G(G({},e),{},{[n[r].name]:t}):typeof t==`object`?G(G({},e),t):G(G({},e),{},{[t]:``}),{}):n.length===1&&!e.hasOwnProperty(n[0].name)&&(e.hasOwnProperty(Object.values(t.bindings)[0])||e.hasOwnProperty(`id`))&&(e={[n[0].name]:e}),G(G({},this._defaults(t)),this._substituteBindings(e,t))}_defaults(e){return e.parameterSegments.filter(({name:e})=>this._config.defaults[e]).reduce((e,{name:t},n)=>G(G({},e),{},{[t]:this._config.defaults[t]}),{})}_substituteBindings(e,{bindings:t,parameterSegments:n}){return Object.entries(e).reduce((e,[r,i])=>{if(!i||typeof i!=`object`||Array.isArray(i)||!n.some(({name:e})=>e===r))return G(G({},e),{},{[r]:i});let a=i.hasOwnProperty(t[r])?t[r]:i.hasOwnProperty(`id`)?`id`:void 0;if(a===void 0)throw Error(`Ziggy error: object passed as '${r}' parameter is missing route model binding key '${t[r]}'.`);return G(G({},e),{},{[r]:i[a]})},{})}valueOf(){return this.toString()}};function xe(e,t,n,r){let i=new be(e,t,n,r);return e?i.toString():i}var Se={install(e,t){let n=(e,n,r,i=t)=>xe(e,n,r,typeof i==`function`?i():i);parseInt(e.version)>2?(e.config.globalProperties.route=n,e.provide(`route`,n)):e.mixin({methods:{route:n}})}};function Ce(e,t){let n=Math.trunc(t)%10,r=Math.trunc(t)%100;switch(e){case`ja`:case`zh_CN`:case`tr`:case`kk`:case`uz`:return 0;case`fr`:return t===0||t===1?0:1;case`ru`:case`uk`:case`be`:return n===1&&r!==11?0:n>=2&&n<=4&&(r<10||r>=20)?1:2;case`pl`:return t===1?0:n>=2&&n<=4&&(r<12||r>14)?1:2;default:return t===1?0:1}}function K(){return n().props.translations||{}}function we(){return n().props.locale||`en`}function q(e,t){return Object.entries(t).reduce((e,[t,n])=>e.replaceAll(`:${t}`,String(n??``)),e)}function J(e,t={}){let n=K()[e];return typeof n==`string`?q(n,t):e}function Te(e,t,n={}){let r=K()[e];if(typeof r!=`string`)return e;let i=r.split(`|`),a=i[Math.min(Ce(we(),t),i.length-1)];return q(a,{count:t,...n})}var Ee={install(e){e.config.globalProperties.$t=J,e.config.globalProperties.$tc=Te}},De=[`graphite`,`day`,`night`,`sand`,`contrast`],Y=typeof window<`u`&&window.matchMedia?window.matchMedia(`(prefers-color-scheme: dark)`):null,X=null,Oe=e=>e===`system`?Y?.matches?`night`:`graphite`:De.includes(e)?e:`graphite`;function Z(e){if(!e)return;X=e;let t=document.documentElement;t.dataset.themeChoice=e,t.dataset.theme=Oe(e)}Y?.addEventListener(`change`,()=>{X===`system`&&Z(X)});var Q=e=>{let t=e.detail.page.props.locale;t&&(document.documentElement.lang=t.replace(`_`,`-`))};r.on(`success`,Q),r.on(`navigate`,Q);var $=e=>Z(e.detail.page.props.theme);r.on(`success`,$),r.on(`navigate`,$);var ke=Object.assign({"./Pages/Admin/ApiTokens/Index.vue":()=>u(()=>import(`./Index-ZYMbBsuF.js`),__vite__mapDeps([0,1,2,3,4,5,6,7])),"./Pages/Admin/Auth/Login.vue":()=>u(()=>import(`./Login-DTW3u1G9.js`),__vite__mapDeps([8,1,3])),"./Pages/Admin/Backups/Index.vue":()=>u(()=>import(`./Index-CG3NSbtt.js`),__vite__mapDeps([9,1,2,3,4,5,6,7])),"./Pages/Admin/Cache/Index.vue":()=>u(()=>import(`./Index-DsLgvcm0.js`),__vite__mapDeps([10,1,2,3,4,5])),"./Pages/Admin/Dashboard.vue":()=>u(()=>import(`./Dashboard-C9RqcuE0.js`),__vite__mapDeps([11,1,2,3,4,12])),"./Pages/Admin/Errors/Index.vue":()=>u(()=>import(`./Index-D_2Ij5S1.js`),__vite__mapDeps([13,1,2,3,4,5,14])),"./Pages/Admin/Errors/Show.vue":()=>u(()=>import(`./Show-CS6rq4RP.js`),__vite__mapDeps([15,1,2,3,4,5,6,14,12])),"./Pages/Admin/Modules/Index.vue":()=>u(()=>import(`./Index-B9KqS9R5.js`),__vite__mapDeps([16,1,2,3,4,5])),"./Pages/Admin/Modules/Settings.vue":()=>u(()=>import(`./Settings-BrbOStcv.js`),__vite__mapDeps([17,1,2,3,4,5,6,18,7,19,20])),"./Pages/Admin/Profile/Edit.vue":()=>u(()=>import(`./Edit-CyzBsvwt.js`),__vite__mapDeps([21,1,2,3,4])),"./Pages/Admin/Resource/Create.vue":()=>u(()=>import(`./Create-DutDQiBS.js`),__vite__mapDeps([22,1,2,3,4,5,6,23,18,7,19,20])),"./Pages/Admin/Resource/Edit.vue":()=>u(()=>import(`./Edit-BEWPbBmM.js`),__vite__mapDeps([24,1,2,3,4,5,6,23,18,7,19,20,25])),"./Pages/Admin/Resource/Index.vue":()=>u(()=>import(`./Index-DaeZ92GY.js`),__vite__mapDeps([26,1,2,3,4,5,27,14,7,25])),"./Pages/Admin/Roles/Edit.vue":()=>u(()=>import(`./Edit-Bm3W6F3v.js`),__vite__mapDeps([28,1,2,3,4,5,6])),"./Pages/Admin/Roles/Index.vue":()=>u(()=>import(`./Index-BNmU5PEL.js`),__vite__mapDeps([29,1,2,3,4,5,7])),"./Pages/Admin/Users/Create.vue":()=>u(()=>import(`./Create-CbxIXc0Q.js`),__vite__mapDeps([30,1,2,3,4,5,6,18,7,19])),"./Pages/Admin/Users/Edit.vue":()=>u(()=>import(`./Edit-Cp-LIO0D.js`),__vite__mapDeps([31,1,2,3,4,5,6,18,7,19])),"./Pages/Admin/Users/Index.vue":()=>u(()=>import(`./Index-C63EL5RF.js`),__vite__mapDeps([32,1,2,3,4,5,27,14,7]))});i({title:e=>{let t=document.querySelector(`title`)?.dataset.brand||`Atrium`;return e?`${e} — ${t}`:t},resolve:e=>{let t=ke[`./Pages/${e}.vue`];if(!t)throw Error(`Atrium: page "${e}" not found`);return t()},setup({el:n,App:r,props:i,plugin:a}){Z(i.initialPage.props.theme),t({render:()=>e(r,i)}).use(a).use(Se).use(Ee).mount(n)},progress:{color:`var(--atrium-accent)`}});export{J as n,Z as t}; \ No newline at end of file diff --git a/packages/admin/dist/assets/app-BncygNAT.css b/packages/admin/dist/assets/app-BncygNAT.css deleted file mode 100644 index 5f3e10fa..00000000 --- a/packages/admin/dist/assets/app-BncygNAT.css +++ /dev/null @@ -1,2 +0,0 @@ -/*! tailwindcss v4.3.5 | MIT License | https://tailwindcss.com */ -@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:block))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-translate-z:0;--tw-scale-x:1;--tw-scale-y:1;--tw-scale-z:1;--tw-rotate-x:initial;--tw-rotate-y:initial;--tw-rotate-z:initial;--tw-skew-x:initial;--tw-skew-y:initial;--tw-space-y-reverse:0;--tw-space-x-reverse:0;--tw-divide-y-reverse:0;--tw-border-style:solid;--tw-leading:initial;--tw-font-weight:initial;--tw-tracking:initial;--tw-ordinal:initial;--tw-slashed-zero:initial;--tw-numeric-figure:initial;--tw-numeric-spacing:initial;--tw-numeric-fraction:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-outline-style:solid;--tw-blur:initial;--tw-brightness:initial;--tw-contrast:initial;--tw-grayscale:initial;--tw-hue-rotate:initial;--tw-invert:initial;--tw-opacity:initial;--tw-saturate:initial;--tw-sepia:initial;--tw-drop-shadow:initial;--tw-drop-shadow-color:initial;--tw-drop-shadow-alpha:100%;--tw-drop-shadow-size:initial;--tw-duration:initial;--tw-ease:initial}}}@layer theme{:root,:host{--font-sans:ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";--font-mono:ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;--spacing:.25rem;--container-xs:20rem;--container-sm:24rem;--container-md:28rem;--container-lg:32rem;--container-xl:36rem;--container-2xl:42rem;--container-4xl:56rem;--text-xs:.75rem;--text-xs--line-height:calc(1 / .75);--text-sm:.875rem;--text-sm--line-height:calc(1.25 / .875);--text-base:1rem;--text-base--line-height:calc(1.5 / 1);--text-lg:1.125rem;--text-lg--line-height:calc(1.75 / 1.125);--text-xl:1.25rem;--text-xl--line-height:calc(1.75 / 1.25);--text-2xl:1.5rem;--text-2xl--line-height:calc(2 / 1.5);--text-3xl:1.875rem;--text-3xl--line-height:calc(2.25 / 1.875);--font-weight-normal:400;--font-weight-medium:500;--font-weight-semibold:600;--font-weight-bold:700;--tracking-wide:.025em;--tracking-wider:.05em;--leading-tight:1.25;--radius-sm:.25rem;--radius-md:.375rem;--radius-lg:.5rem;--radius-xl:.75rem;--ease-in:cubic-bezier(.4, 0, 1, 1);--ease-out:cubic-bezier(0, 0, .2, 1);--ease-in-out:cubic-bezier(.4, 0, .2, 1);--animate-spin:spin 1s linear infinite;--default-transition-duration:.15s;--default-transition-timing-function:cubic-bezier(.4, 0, .2, 1);--default-font-family:var(--font-sans);--default-mono-font-family:var(--font-mono);--font-brand:"Space Grotesk", var(--font-sans)}}@layer base{*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;tab-size:4;line-height:1.5;font-family:var(--default-font-family,-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family,ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-variation-settings:var(--default-mono-font-variation-settings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring:where(:not(iframe)){outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab, red, red)){::placeholder{color:color-mix(in oklab, currentcolor 50%, transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit{padding-block:0}::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-month-field{padding-block:0}::-webkit-datetime-edit-day-field{padding-block:0}::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field{padding-block:0}::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-datetime-edit-meridiem-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){appearance:button}::file-selector-button{appearance:button}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}html{accent-color:var(--atrium-accent);background-color:var(--atrium-page);color:var(--atrium-fg)}*{--tw-ring-offset-color:var(--atrium-surface)}::placeholder{color:var(--atrium-muted);opacity:1}select:not([multiple]):not([size]){appearance:none;background-color:var(--atrium-surface);background-image:linear-gradient(45deg,#0000 50%,currentColor 50%),linear-gradient(135deg,currentColor 50%,#0000 50%);background-position:calc(100% - 1rem),calc(100% - .6875rem);background-repeat:no-repeat;background-size:.3125rem .3125rem}select option{background-color:var(--atrium-surface);color:var(--atrium-fg)}}@layer components;@layer utilities{.collapse{visibility:collapse}.visible{visibility:visible}.sr-only{clip-path:inset(50%);white-space:nowrap;border-width:0;width:1px;height:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}.absolute{position:absolute}.fixed{position:fixed}.relative{position:relative}.static{position:static}.sticky{position:sticky}.inset-0{inset:0}.inset-y-0{inset-block:0}.top-0{top:0}.top-1{top:var(--spacing)}.top-1\/2{top:50%}.top-2{top:calc(var(--spacing) * 2)}.top-4{top:calc(var(--spacing) * 4)}.right-0{right:0}.right-1{right:var(--spacing)}.right-2{right:calc(var(--spacing) * 2)}.right-4{right:calc(var(--spacing) * 4)}.bottom-4{bottom:calc(var(--spacing) * 4)}.left-0{left:0}.left-2{left:calc(var(--spacing) * 2)}.left-2\.5{left:calc(var(--spacing) * 2.5)}.isolate{isolation:isolate}.z-10{z-index:10}.z-30{z-index:30}.z-40{z-index:40}.z-50{z-index:50}.container{width:100%}@media (width>=40rem){.container{max-width:40rem}}@media (width>=48rem){.container{max-width:48rem}}@media (width>=64rem){.container{max-width:64rem}}@media (width>=80rem){.container{max-width:80rem}}@media (width>=96rem){.container{max-width:96rem}}.mx-4{margin-inline:calc(var(--spacing) * 4)}.mx-auto{margin-inline:auto}.mt-1{margin-top:var(--spacing)}.mt-1\.5{margin-top:calc(var(--spacing) * 1.5)}.mt-2{margin-top:calc(var(--spacing) * 2)}.mt-3{margin-top:calc(var(--spacing) * 3)}.mt-4{margin-top:calc(var(--spacing) * 4)}.mt-6{margin-top:calc(var(--spacing) * 6)}.mt-8{margin-top:calc(var(--spacing) * 8)}.mr-1{margin-right:var(--spacing)}.mr-1\.5{margin-right:calc(var(--spacing) * 1.5)}.mr-2{margin-right:calc(var(--spacing) * 2)}.mr-3{margin-right:calc(var(--spacing) * 3)}.mr-4{margin-right:calc(var(--spacing) * 4)}.-mb-px{margin-bottom:-1px}.mb-1{margin-bottom:var(--spacing)}.mb-2{margin-bottom:calc(var(--spacing) * 2)}.mb-4{margin-bottom:calc(var(--spacing) * 4)}.mb-6{margin-bottom:calc(var(--spacing) * 6)}.mb-8{margin-bottom:calc(var(--spacing) * 8)}.-ml-0\.5{margin-left:calc(var(--spacing) * -.5)}.-ml-1{margin-left:calc(var(--spacing) * -1)}.ml-1{margin-left:var(--spacing)}.ml-1\.5{margin-left:calc(var(--spacing) * 1.5)}.ml-2{margin-left:calc(var(--spacing) * 2)}.ml-3{margin-left:calc(var(--spacing) * 3)}.ml-4{margin-left:calc(var(--spacing) * 4)}.ml-6{margin-left:calc(var(--spacing) * 6)}.ml-auto{margin-left:auto}.line-clamp-2{-webkit-line-clamp:2;-webkit-box-orient:vertical;display:-webkit-box;overflow:hidden}.block{display:block}.contents{display:contents}.flex{display:flex}.grid{display:grid}.hidden{display:none}.inline{display:inline}.inline-block{display:inline-block}.inline-flex{display:inline-flex}.table{display:table}.aspect-square{aspect-ratio:1}.h-1\.5{height:calc(var(--spacing) * 1.5)}.h-2{height:calc(var(--spacing) * 2)}.h-3{height:calc(var(--spacing) * 3)}.h-3\.5{height:calc(var(--spacing) * 3.5)}.h-4{height:calc(var(--spacing) * 4)}.h-5{height:calc(var(--spacing) * 5)}.h-6{height:calc(var(--spacing) * 6)}.h-8{height:calc(var(--spacing) * 8)}.h-10{height:calc(var(--spacing) * 10)}.h-12{height:calc(var(--spacing) * 12)}.h-16{height:calc(var(--spacing) * 16)}.h-24{height:calc(var(--spacing) * 24)}.h-full{height:100%}.h-px{height:1px}.max-h-60{max-height:calc(var(--spacing) * 60)}.max-h-64{max-height:calc(var(--spacing) * 64)}.max-h-96{max-height:calc(var(--spacing) * 96)}.max-h-\[90vh\]{max-height:90vh}.max-h-\[min\(36rem\,calc\(100vh-8rem\)\)\]{max-height:min(36rem,100vh - 8rem)}.min-h-full{min-height:100%}.min-h-screen{min-height:100vh}.w-0\.5{width:calc(var(--spacing) * .5)}.w-1\.5{width:calc(var(--spacing) * 1.5)}.w-2{width:calc(var(--spacing) * 2)}.w-3{width:calc(var(--spacing) * 3)}.w-3\.5{width:calc(var(--spacing) * 3.5)}.w-4{width:calc(var(--spacing) * 4)}.w-5{width:calc(var(--spacing) * 5)}.w-6{width:calc(var(--spacing) * 6)}.w-8{width:calc(var(--spacing) * 8)}.w-10{width:calc(var(--spacing) * 10)}.w-12{width:calc(var(--spacing) * 12)}.w-16{width:calc(var(--spacing) * 16)}.w-20{width:calc(var(--spacing) * 20)}.w-24{width:calc(var(--spacing) * 24)}.w-56{width:calc(var(--spacing) * 56)}.w-64{width:calc(var(--spacing) * 64)}.w-\[4\.75rem\]{width:4.75rem}.w-\[22rem\]{width:22rem}.w-auto{width:auto}.w-full{width:100%}.max-w-2xl{max-width:var(--container-2xl)}.max-w-4xl{max-width:var(--container-4xl)}.max-w-14{max-width:calc(var(--spacing) * 14)}.max-w-56{max-width:calc(var(--spacing) * 56)}.max-w-\[85\%\]{max-width:85%}.max-w-\[90\%\]{max-width:90%}.max-w-\[calc\(100vw-2rem\)\]{max-width:calc(100vw - 2rem)}.max-w-md{max-width:var(--container-md)}.max-w-none{max-width:none}.max-w-xs{max-width:var(--container-xs)}.min-w-0{min-width:0}.min-w-5{min-width:calc(var(--spacing) * 5)}.min-w-48{min-width:calc(var(--spacing) * 48)}.min-w-full{min-width:100%}.flex-1{flex:1}.flex-none{flex:none}.flex-shrink{flex-shrink:1}.flex-shrink-0,.shrink-0{flex-shrink:0}.border-separate{border-collapse:separate}.border-spacing-0{--tw-border-spacing-x:0px;--tw-border-spacing-y:0px;border-spacing:var(--tw-border-spacing-x) var(--tw-border-spacing-y)}.-translate-x-full{--tw-translate-x:-100%;translate:var(--tw-translate-x) var(--tw-translate-y)}.translate-x-0{--tw-translate-x:0px;translate:var(--tw-translate-x) var(--tw-translate-y)}.-translate-y-1\/2{--tw-translate-y:calc(calc(1 / 2 * 100%) * -1);translate:var(--tw-translate-x) var(--tw-translate-y)}.translate-y-0{--tw-translate-y:0px;translate:var(--tw-translate-x) var(--tw-translate-y)}.translate-y-4{--tw-translate-y:calc(var(--spacing) * 4);translate:var(--tw-translate-x) var(--tw-translate-y)}.scale-95{--tw-scale-x:95%;--tw-scale-y:95%;--tw-scale-z:95%;scale:var(--tw-scale-x) var(--tw-scale-y)}.scale-100{--tw-scale-x:100%;--tw-scale-y:100%;--tw-scale-z:100%;scale:var(--tw-scale-x) var(--tw-scale-y)}.scale-110{--tw-scale-x:110%;--tw-scale-y:110%;--tw-scale-z:110%;scale:var(--tw-scale-x) var(--tw-scale-y)}.rotate-90{rotate:90deg}.rotate-180{rotate:180deg}.transform{transform:var(--tw-rotate-x, ) var(--tw-rotate-y, ) var(--tw-rotate-z, ) var(--tw-skew-x, ) var(--tw-skew-y, )}.transform-gpu{transform:translateZ(0) var(--tw-rotate-x, ) var(--tw-rotate-y, ) var(--tw-rotate-z, ) var(--tw-skew-x, ) var(--tw-skew-y, )}.animate-spin{animation:var(--animate-spin)}.cursor-move{cursor:move}.cursor-pointer{cursor:pointer}.resize{resize:both}.resize-none{resize:none}.resize-y{resize:vertical}.list-disc{list-style-type:disc}.appearance-none{appearance:none}.grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.grid-cols-5{grid-template-columns:repeat(5,minmax(0,1fr))}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.items-baseline{align-items:baseline}.items-center{align-items:center}.items-end{align-items:flex-end}.items-start{align-items:flex-start}.justify-between{justify-content:space-between}.justify-center{justify-content:center}.justify-end{justify-content:flex-end}.justify-start{justify-content:flex-start}.gap-0\.5{gap:calc(var(--spacing) * .5)}.gap-1{gap:var(--spacing)}.gap-1\.5{gap:calc(var(--spacing) * 1.5)}.gap-2{gap:calc(var(--spacing) * 2)}.gap-2\.5{gap:calc(var(--spacing) * 2.5)}.gap-3{gap:calc(var(--spacing) * 3)}.gap-4{gap:calc(var(--spacing) * 4)}.gap-6{gap:calc(var(--spacing) * 6)}:where(.space-y-0\.5>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * .5) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * .5) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-1>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(var(--spacing) * var(--tw-space-y-reverse));margin-block-end:calc(var(--spacing) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-2>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 2) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 2) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-3>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 3) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 3) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-4>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 4) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 4) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-5>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 5) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 5) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-6>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 6) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 6) * calc(1 - var(--tw-space-y-reverse)))}.gap-x-3{column-gap:calc(var(--spacing) * 3)}.gap-x-4{column-gap:calc(var(--spacing) * 4)}:where(.-space-x-px>:not(:last-child)){--tw-space-x-reverse:0;margin-inline-start:calc(-1px * var(--tw-space-x-reverse));margin-inline-end:calc(-1px * calc(1 - var(--tw-space-x-reverse)))}:where(.space-x-1>:not(:last-child)){--tw-space-x-reverse:0;margin-inline-start:calc(var(--spacing) * var(--tw-space-x-reverse));margin-inline-end:calc(var(--spacing) * calc(1 - var(--tw-space-x-reverse)))}:where(.space-x-2>:not(:last-child)){--tw-space-x-reverse:0;margin-inline-start:calc(calc(var(--spacing) * 2) * var(--tw-space-x-reverse));margin-inline-end:calc(calc(var(--spacing) * 2) * calc(1 - var(--tw-space-x-reverse)))}:where(.space-x-3>:not(:last-child)){--tw-space-x-reverse:0;margin-inline-start:calc(calc(var(--spacing) * 3) * var(--tw-space-x-reverse));margin-inline-end:calc(calc(var(--spacing) * 3) * calc(1 - var(--tw-space-x-reverse)))}:where(.space-x-4>:not(:last-child)){--tw-space-x-reverse:0;margin-inline-start:calc(calc(var(--spacing) * 4) * var(--tw-space-x-reverse));margin-inline-end:calc(calc(var(--spacing) * 4) * calc(1 - var(--tw-space-x-reverse)))}:where(.space-x-8>:not(:last-child)){--tw-space-x-reverse:0;margin-inline-start:calc(calc(var(--spacing) * 8) * var(--tw-space-x-reverse));margin-inline-end:calc(calc(var(--spacing) * 8) * calc(1 - var(--tw-space-x-reverse)))}.gap-y-3{row-gap:calc(var(--spacing) * 3)}:where(.divide-y>:not(:last-child)){--tw-divide-y-reverse:0;border-bottom-style:var(--tw-border-style);border-top-style:var(--tw-border-style);border-top-width:calc(1px * var(--tw-divide-y-reverse));border-bottom-width:calc(1px * calc(1 - var(--tw-divide-y-reverse)))}:where(.divide-line>:not(:last-child)){border-color:var(--atrium-line)}.truncate{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.overflow-auto{overflow:auto}.overflow-hidden{overflow:hidden}.overflow-visible{overflow:visible}.overflow-x-auto{overflow-x:auto}.overflow-y-auto{overflow-y:auto}.rounded{border-radius:.25rem}.rounded-full{border-radius:2147483647px}.rounded-lg{border-radius:var(--radius-lg)}.rounded-md{border-radius:var(--radius-md)}.rounded-sm{border-radius:var(--radius-sm)}.rounded-xl{border-radius:var(--radius-xl)}.rounded-l-md{border-top-left-radius:var(--radius-md);border-bottom-left-radius:var(--radius-md)}.rounded-r-md{border-top-right-radius:var(--radius-md);border-bottom-right-radius:var(--radius-md)}.rounded-b-lg{border-bottom-right-radius:var(--radius-lg);border-bottom-left-radius:var(--radius-lg)}.rounded-b-xl{border-bottom-right-radius:var(--radius-xl);border-bottom-left-radius:var(--radius-xl)}.border{border-style:var(--tw-border-style);border-width:1px}.border-0{border-style:var(--tw-border-style);border-width:0}.border-2{border-style:var(--tw-border-style);border-width:2px}.border-t{border-top-style:var(--tw-border-style);border-top-width:1px}.border-r{border-right-style:var(--tw-border-style);border-right-width:1px}.border-b{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}.border-b-2{border-bottom-style:var(--tw-border-style);border-bottom-width:2px}.border-l{border-left-style:var(--tw-border-style);border-left-width:1px}.border-dashed{--tw-border-style:dashed;border-style:dashed}.border-accent{border-color:var(--atrium-accent)}.border-accent-hover{border-color:var(--atrium-accent-hover)}.border-accent-soft{border-color:var(--atrium-accent-soft)}.border-badge-line{border-color:var(--atrium-badge-line)}.border-current{border-color:currentColor}.border-danger{border-color:var(--atrium-danger)}.border-danger-soft{border-color:var(--atrium-danger-soft)}.border-field{border-color:var(--atrium-field)}.border-focus{border-color:var(--atrium-focus)}.border-line{border-color:var(--atrium-line)}.border-sidebar-line{border-color:var(--atrium-sidebar-line)}.border-success{border-color:var(--atrium-success)}.border-transparent{border-color:#0000}.border-warning-soft-fg{border-color:var(--atrium-warning-soft-fg)}.bg-accent{background-color:var(--atrium-accent)}.bg-accent-hover{background-color:var(--atrium-accent-hover)}.bg-accent-soft{background-color:var(--atrium-accent-soft)}.bg-black\/50{background-color:oklab(0% none none/.5)}.bg-current{background-color:currentColor}.bg-danger{background-color:var(--atrium-danger)}.bg-danger-hover{background-color:var(--atrium-danger-hover)}.bg-danger-soft{background-color:var(--atrium-danger-soft)}.bg-inherit{background-color:inherit}.bg-line{background-color:var(--atrium-line)}.bg-off{background-color:var(--atrium-off)}.bg-page{background-color:var(--atrium-page)}.bg-sidebar{background-color:var(--atrium-sidebar)}.bg-sidebar-active{background-color:var(--atrium-sidebar-active)}.bg-success-soft{background-color:var(--atrium-success-soft)}.bg-surface{background-color:var(--atrium-surface)}.bg-surface-alt{background-color:var(--atrium-surface-alt)}.bg-surface\/75{background-color:var(--atrium-surface)}@supports (color:color-mix(in lab, red, red)){.bg-surface\/75{background-color:color-mix(in oklab, var(--atrium-surface) 75%, transparent)}}.bg-transparent{background-color:#0000}.bg-warning-soft{background-color:var(--atrium-warning-soft)}.bg-white{background-color:#fff}.bg-contain{background-size:contain}.bg-center{background-position:50%}.bg-left{background-position:0}.bg-no-repeat{background-repeat:no-repeat}.fill-accent{fill:var(--atrium-accent)}.fill-fg{fill:var(--atrium-fg)}.fill-mark{fill:var(--atrium-mark)}.fill-mark-accent{fill:var(--atrium-mark-accent)}.fill-surface{fill:var(--atrium-surface)}.object-cover{object-fit:cover}.p-0{padding:0}.p-0\.5{padding:calc(var(--spacing) * .5)}.p-1{padding:var(--spacing)}.p-1\.5{padding:calc(var(--spacing) * 1.5)}.p-2{padding:calc(var(--spacing) * 2)}.p-3{padding:calc(var(--spacing) * 3)}.p-4{padding:calc(var(--spacing) * 4)}.p-6{padding:calc(var(--spacing) * 6)}.p-8{padding:calc(var(--spacing) * 8)}.px-1{padding-inline:var(--spacing)}.px-1\.5{padding-inline:calc(var(--spacing) * 1.5)}.px-2{padding-inline:calc(var(--spacing) * 2)}.px-2\.5{padding-inline:calc(var(--spacing) * 2.5)}.px-3{padding-inline:calc(var(--spacing) * 3)}.px-4{padding-inline:calc(var(--spacing) * 4)}.px-5{padding-inline:calc(var(--spacing) * 5)}.px-6{padding-inline:calc(var(--spacing) * 6)}.py-0\.5{padding-block:calc(var(--spacing) * .5)}.py-1{padding-block:var(--spacing)}.py-1\.5{padding-block:calc(var(--spacing) * 1.5)}.py-2{padding-block:calc(var(--spacing) * 2)}.py-2\.5{padding-block:calc(var(--spacing) * 2.5)}.py-3{padding-block:calc(var(--spacing) * 3)}.py-4{padding-block:calc(var(--spacing) * 4)}.py-12{padding-block:calc(var(--spacing) * 12)}.py-16{padding-block:calc(var(--spacing) * 16)}.pt-2{padding-top:calc(var(--spacing) * 2)}.pt-3{padding-top:calc(var(--spacing) * 3)}.pt-4{padding-top:calc(var(--spacing) * 4)}.pt-6{padding-top:calc(var(--spacing) * 6)}.pr-2{padding-right:calc(var(--spacing) * 2)}.pr-3{padding-right:calc(var(--spacing) * 3)}.pr-4{padding-right:calc(var(--spacing) * 4)}.pr-10{padding-right:calc(var(--spacing) * 10)}.pb-1{padding-bottom:var(--spacing)}.pl-3{padding-left:calc(var(--spacing) * 3)}.pl-4{padding-left:calc(var(--spacing) * 4)}.pl-5{padding-left:calc(var(--spacing) * 5)}.pl-6{padding-left:calc(var(--spacing) * 6)}.pl-8{padding-left:calc(var(--spacing) * 8)}.pl-9{padding-left:calc(var(--spacing) * 9)}.pl-10{padding-left:calc(var(--spacing) * 10)}.pl-12{padding-left:calc(var(--spacing) * 12)}.text-center{text-align:center}.text-left{text-align:left}.text-right{text-align:right}.font-brand{font-family:var(--font-brand)}.font-mono{font-family:var(--font-mono)}.text-2xl{font-size:var(--text-2xl);line-height:var(--tw-leading,var(--text-2xl--line-height))}.text-3xl{font-size:var(--text-3xl);line-height:var(--tw-leading,var(--text-3xl--line-height))}.text-base{font-size:var(--text-base);line-height:var(--tw-leading,var(--text-base--line-height))}.text-lg{font-size:var(--text-lg);line-height:var(--tw-leading,var(--text-lg--line-height))}.text-sm{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.text-xl{font-size:var(--text-xl);line-height:var(--tw-leading,var(--text-xl--line-height))}.text-xs{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}.text-\[11px\]{font-size:11px}.leading-tight{--tw-leading:var(--leading-tight);line-height:var(--leading-tight)}.font-bold{--tw-font-weight:var(--font-weight-bold);font-weight:var(--font-weight-bold)}.font-medium{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.font-normal{--tw-font-weight:var(--font-weight-normal);font-weight:var(--font-weight-normal)}.font-semibold{--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.tracking-\[-0\.01em\]{--tw-tracking:-.01em;letter-spacing:-.01em}.tracking-wide{--tw-tracking:var(--tracking-wide);letter-spacing:var(--tracking-wide)}.tracking-wider{--tw-tracking:var(--tracking-wider);letter-spacing:var(--tracking-wider)}.break-words{overflow-wrap:break-word}.break-all{word-break:break-all}.whitespace-nowrap{white-space:nowrap}.whitespace-pre-wrap{white-space:pre-wrap}.text-accent{color:var(--atrium-accent)}.text-accent-hover{color:var(--atrium-accent-hover)}.text-accent-soft-fg{color:var(--atrium-accent-soft-fg)}.text-danger{color:var(--atrium-danger)}.text-danger-soft-fg{color:var(--atrium-danger-soft-fg)}.text-fg{color:var(--atrium-fg)}.text-muted{color:var(--atrium-muted)}.text-off-fg{color:var(--atrium-off-fg)}.text-on-accent{color:var(--atrium-on-accent)}.text-on-danger{color:var(--atrium-on-danger)}.text-sidebar-active-fg{color:var(--atrium-sidebar-active-fg)}.text-sidebar-fg{color:var(--atrium-sidebar-fg)}.text-sidebar-muted{color:var(--atrium-sidebar-muted)}.text-success{color:var(--atrium-success)}.text-success-soft-fg{color:var(--atrium-success-soft-fg)}.text-transparent{color:#0000}.text-warning-soft-fg{color:var(--atrium-warning-soft-fg)}.lowercase{text-transform:lowercase}.uppercase{text-transform:uppercase}.italic{font-style:italic}.tabular-nums{--tw-numeric-spacing:tabular-nums;font-variant-numeric:var(--tw-ordinal, ) var(--tw-slashed-zero, ) var(--tw-numeric-figure, ) var(--tw-numeric-spacing, ) var(--tw-numeric-fraction, )}.underline{text-decoration-line:underline}.antialiased{-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.placeholder-muted::placeholder{color:var(--atrium-muted)}.accent-hover{accent-color:var(--atrium-hover)}.opacity-0{opacity:0}.opacity-25{opacity:.25}.opacity-50{opacity:.5}.opacity-75{opacity:.75}.opacity-100{opacity:1}.shadow{--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a), 0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.shadow-2xl{--tw-shadow:0 25px 50px -12px var(--tw-shadow-color,#00000040);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.shadow-\[inset_3px_0_0_var\(--atrium-sidebar-accent\)\]{--tw-shadow:inset 3px 0 0 var(--tw-shadow-color,var(--atrium-sidebar-accent));box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.shadow-lg{--tw-shadow:0 10px 15px -3px var(--tw-shadow-color,#0000001a), 0 4px 6px -4px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.shadow-sm{--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a), 0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.shadow-xl{--tw-shadow:0 20px 25px -5px var(--tw-shadow-color,#0000001a), 0 8px 10px -6px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.ring,.ring-1{--tw-ring-shadow:var(--tw-ring-inset, ) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.ring-2{--tw-ring-shadow:var(--tw-ring-inset, ) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.ring-field{--tw-ring-color:var(--atrium-field)}.ring-focus{--tw-ring-color:var(--atrium-focus)}.ring-line{--tw-ring-color:var(--atrium-line)}.outline{outline-style:var(--tw-outline-style);outline-width:1px}.filter{filter:var(--tw-blur, ) var(--tw-brightness, ) var(--tw-contrast, ) var(--tw-grayscale, ) var(--tw-hue-rotate, ) var(--tw-invert, ) var(--tw-saturate, ) var(--tw-sepia, ) var(--tw-drop-shadow, )}.transition{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to,opacity,box-shadow,transform,translate,scale,rotate,filter,-webkit-backdrop-filter,backdrop-filter,display,content-visibility,overlay,pointer-events;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-all{transition-property:all;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-colors{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-opacity{transition-property:opacity;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-transform{transition-property:transform,translate,scale,rotate;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.duration-75{--tw-duration:75ms;transition-duration:75ms}.duration-100{--tw-duration:.1s;transition-duration:.1s}.duration-150{--tw-duration:.15s;transition-duration:.15s}.duration-200{--tw-duration:.2s;transition-duration:.2s}.duration-300{--tw-duration:.3s;transition-duration:.3s}.ease-in{--tw-ease:var(--ease-in);transition-timing-function:var(--ease-in)}.ease-in-out{--tw-ease:var(--ease-in-out);transition-timing-function:var(--ease-in-out)}.ease-out{--tw-ease:var(--ease-out);transition-timing-function:var(--ease-out)}.select-all{-webkit-user-select:all;user-select:all}.ring-inset{--tw-ring-inset:inset}@media (hover:hover){:is(:where(.group):hover .group-hover\:text-fg){color:var(--atrium-fg)}:is(:where(.group):hover .group-hover\:opacity-100){opacity:1}}.file\:mr-4::file-selector-button{margin-right:calc(var(--spacing) * 4)}.file\:rounded-md::file-selector-button{border-radius:var(--radius-md)}.file\:border-0::file-selector-button{border-style:var(--tw-border-style);border-width:0}.file\:bg-accent-soft::file-selector-button{background-color:var(--atrium-accent-soft)}.file\:px-4::file-selector-button{padding-inline:calc(var(--spacing) * 4)}.file\:py-2::file-selector-button{padding-block:calc(var(--spacing) * 2)}.file\:text-sm::file-selector-button{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.file\:font-medium::file-selector-button{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.file\:text-accent-hover::file-selector-button{color:var(--atrium-accent-hover)}.last\:border-b-0:last-child{border-bottom-style:var(--tw-border-style);border-bottom-width:0}@media (hover:hover){.hover\:scale-105:hover{--tw-scale-x:105%;--tw-scale-y:105%;--tw-scale-z:105%;scale:var(--tw-scale-x) var(--tw-scale-y)}.hover\:border-fg:hover{border-color:var(--atrium-fg)}.hover\:border-field:hover{border-color:var(--atrium-field)}.hover\:border-focus:hover{border-color:var(--atrium-focus)}.hover\:bg-accent-hover:hover{background-color:var(--atrium-accent-hover)}.hover\:bg-accent-soft:hover{background-color:var(--atrium-accent-soft)}.hover\:bg-danger-hover:hover{background-color:var(--atrium-danger-hover)}.hover\:bg-danger-soft:hover{background-color:var(--atrium-danger-soft)}.hover\:bg-hover:hover{background-color:var(--atrium-hover)}.hover\:bg-sidebar-hover:hover{background-color:var(--atrium-sidebar-hover)}.hover\:text-accent:hover{color:var(--atrium-accent)}.hover\:text-accent-hover:hover{color:var(--atrium-accent-hover)}.hover\:text-accent-soft-fg:hover{color:var(--atrium-accent-soft-fg)}.hover\:text-danger:hover{color:var(--atrium-danger)}.hover\:text-danger-soft-fg:hover{color:var(--atrium-danger-soft-fg)}.hover\:text-fg:hover{color:var(--atrium-fg)}.hover\:text-sidebar-fg:hover{color:var(--atrium-sidebar-fg)}.hover\:underline:hover{text-decoration-line:underline}.hover\:file\:bg-accent-soft:hover::file-selector-button{background-color:var(--atrium-accent-soft)}}.focus\:border-focus:focus{border-color:var(--atrium-focus)}.focus\:ring-1:focus{--tw-ring-shadow:var(--tw-ring-inset, ) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.focus\:ring-2:focus{--tw-ring-shadow:var(--tw-ring-inset, ) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.focus\:ring-danger:focus{--tw-ring-color:var(--atrium-danger)}.focus\:ring-focus:focus{--tw-ring-color:var(--atrium-focus)}.focus\:ring-offset-2:focus{--tw-ring-offset-width:2px;--tw-ring-offset-shadow:var(--tw-ring-inset, ) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color)}.focus\:outline-none:focus{--tw-outline-style:none;outline-style:none}.focus-visible\:ring-2:focus-visible{--tw-ring-shadow:var(--tw-ring-inset, ) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.focus-visible\:ring-focus:focus-visible{--tw-ring-color:var(--atrium-focus)}.focus-visible\:ring-sidebar-accent:focus-visible{--tw-ring-color:var(--atrium-sidebar-accent)}.focus-visible\:outline:focus-visible{outline-style:var(--tw-outline-style);outline-width:1px}.focus-visible\:outline-2:focus-visible{outline-style:var(--tw-outline-style);outline-width:2px}.focus-visible\:outline-offset-2:focus-visible{outline-offset:2px}.focus-visible\:outline-focus:focus-visible{outline-color:var(--atrium-focus)}.focus-visible\:ring-inset:focus-visible{--tw-ring-inset:inset}.disabled\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\:bg-off:disabled{background-color:var(--atrium-off)}.disabled\:text-muted:disabled{color:var(--atrium-muted)}.disabled\:opacity-30:disabled{opacity:.3}.disabled\:opacity-50:disabled{opacity:.5}@media (width>=40rem){.sm\:col-span-2{grid-column:span 2/span 2}.sm\:my-8{margin-block:calc(var(--spacing) * 8)}.sm\:block{display:block}.sm\:hidden{display:none}.sm\:inline{display:inline}.sm\:w-full{width:100%}.sm\:max-w-2xl{max-width:var(--container-2xl)}.sm\:max-w-32{max-width:calc(var(--spacing) * 32)}.sm\:max-w-lg{max-width:var(--container-lg)}.sm\:max-w-md{max-width:var(--container-md)}.sm\:max-w-sm{max-width:var(--container-sm)}.sm\:max-w-xl{max-width:var(--container-xl)}.sm\:translate-y-0{--tw-translate-y:0px;translate:var(--tw-translate-x) var(--tw-translate-y)}.sm\:scale-95{--tw-scale-x:95%;--tw-scale-y:95%;--tw-scale-z:95%;scale:var(--tw-scale-x) var(--tw-scale-y)}.sm\:scale-100{--tw-scale-x:100%;--tw-scale-y:100%;--tw-scale-z:100%;scale:var(--tw-scale-x) var(--tw-scale-y)}.sm\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.sm\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.sm\:grid-cols-6{grid-template-columns:repeat(6,minmax(0,1fr))}.sm\:flex-row{flex-direction:row}.sm\:items-center{align-items:center}.sm\:items-end{align-items:flex-end}.sm\:justify-between{justify-content:space-between}.sm\:gap-2{gap:calc(var(--spacing) * 2)}.sm\:gap-4{gap:calc(var(--spacing) * 4)}.sm\:px-2{padding-inline:calc(var(--spacing) * 2)}.sm\:px-4{padding-inline:calc(var(--spacing) * 4)}.sm\:px-6{padding-inline:calc(var(--spacing) * 6)}.sm\:text-sm{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.sm\:text-xs{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}}@media (width>=48rem){.md\:block{display:block}:where(.md\:space-x-3>:not(:last-child)){--tw-space-x-reverse:0;margin-inline-start:calc(calc(var(--spacing) * 3) * var(--tw-space-x-reverse));margin-inline-end:calc(calc(var(--spacing) * 3) * calc(1 - var(--tw-space-x-reverse)))}}@media (width>=64rem){.lg\:col-span-2{grid-column:span 2/span 2}.lg\:block{display:block}.lg\:hidden{display:none}.lg\:w-20{width:calc(var(--spacing) * 20)}.lg\:w-64{width:calc(var(--spacing) * 64)}.lg\:translate-x-0{--tw-translate-x:0px;translate:var(--tw-translate-x) var(--tw-translate-y)}.lg\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.lg\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.lg\:gap-3{gap:calc(var(--spacing) * 3)}.lg\:p-6{padding:calc(var(--spacing) * 6)}.lg\:px-2{padding-inline:calc(var(--spacing) * 2)}.lg\:px-6{padding-inline:calc(var(--spacing) * 6)}.lg\:px-8{padding-inline:calc(var(--spacing) * 8)}.lg\:pl-20{padding-left:calc(var(--spacing) * 20)}.lg\:pl-64{padding-left:calc(var(--spacing) * 64)}.lg\:text-center{text-align:center}}@media (width>=80rem){.xl\:max-w-48{max-width:calc(var(--spacing) * 48)}}}@font-face{font-family:Space Grotesk;font-style:normal;font-display:swap;font-weight:600;src:url(/vendor/atrium/assets/space-grotesk-latin-600-normal-DjKNqYRj.woff2)format("woff2"),url(/vendor/atrium/assets/space-grotesk-latin-600-normal-BflQw4A9.woff)format("woff")}:root,[data-theme=graphite]{--lightningcss-light:initial;--lightningcss-dark: ;color-scheme:light;--atrium-sidebar:#111827;--atrium-sidebar-fg:#f9fafb;--atrium-sidebar-muted:#9ca3af;--atrium-sidebar-hover:#1f2937;--atrium-sidebar-active:#1f2937;--atrium-sidebar-active-fg:#fff;--atrium-sidebar-accent:#60a5fa;--atrium-sidebar-line:#1f2937;--atrium-page:#f3f4f6;--atrium-surface:#fff;--atrium-surface-alt:#f9fafb;--atrium-hover:#f3f4f6;--atrium-fg:#111827;--atrium-muted:#4b5563;--atrium-line:#e5e7eb;--atrium-field:#7e8691;--atrium-accent:#2563eb;--atrium-accent-hover:#1d4ed8;--atrium-on-accent:#fff;--atrium-accent-soft:#dbeafe;--atrium-accent-soft-fg:#1e40af;--atrium-focus:#2563eb;--atrium-off:#f3f4f6;--atrium-off-fg:#374151;--atrium-badge-line:transparent;--atrium-danger:#c81e1e;--atrium-danger-hover:#991b1b;--atrium-on-danger:#fff;--atrium-danger-soft:#fee2e2;--atrium-danger-soft-fg:#991b1b;--atrium-success:#15803d;--atrium-success-soft:#dcfce7;--atrium-success-soft-fg:#166534;--atrium-warning-soft:#fef3c7;--atrium-warning-soft-fg:#92400e;--atrium-mark:#fff;--atrium-mark-accent:#60a5fa}[data-theme=day]{--lightningcss-light:initial;--lightningcss-dark: ;color-scheme:light;--atrium-sidebar:#fff;--atrium-sidebar-fg:#1f2937;--atrium-sidebar-muted:#64748b;--atrium-sidebar-hover:#f1f5f9;--atrium-sidebar-active:#eef2ff;--atrium-sidebar-active-fg:#3730a3;--atrium-sidebar-accent:#4f46e5;--atrium-sidebar-line:#e2e8f0;--atrium-page:#f8fafc;--atrium-surface:#fff;--atrium-surface-alt:#f8fafc;--atrium-hover:#f1f5f9;--atrium-fg:#0f172a;--atrium-muted:#475569;--atrium-line:#e2e8f0;--atrium-field:#8391a5;--atrium-accent:#4f46e5;--atrium-accent-hover:#4338ca;--atrium-on-accent:#fff;--atrium-accent-soft:#e0e7ff;--atrium-accent-soft-fg:#3730a3;--atrium-focus:#4f46e5;--atrium-off:#f1f5f9;--atrium-off-fg:#334155;--atrium-badge-line:transparent;--atrium-danger:#c81e1e;--atrium-danger-hover:#991b1b;--atrium-on-danger:#fff;--atrium-danger-soft:#fee2e2;--atrium-danger-soft-fg:#991b1b;--atrium-success:#15803d;--atrium-success-soft:#dcfce7;--atrium-success-soft-fg:#166534;--atrium-warning-soft:#fef3c7;--atrium-warning-soft-fg:#92400e;--atrium-mark:#0f172a;--atrium-mark-accent:#4f46e5}[data-theme=night]{--lightningcss-light: ;--lightningcss-dark:initial;color-scheme:dark;--atrium-sidebar:#0a0e14;--atrium-sidebar-fg:#e6eaf0;--atrium-sidebar-muted:#8b95a5;--atrium-sidebar-hover:#141b26;--atrium-sidebar-active:#1a2230;--atrium-sidebar-active-fg:#fff;--atrium-sidebar-accent:#8ab4ff;--atrium-sidebar-line:#1a2230;--atrium-page:#0f141b;--atrium-surface:#161d27;--atrium-surface-alt:#121821;--atrium-hover:#1f2733;--atrium-fg:#e6eaf0;--atrium-muted:#a0aaba;--atrium-line:#253041;--atrium-field:#5f6d82;--atrium-accent:#8ab4ff;--atrium-accent-hover:#b0ccff;--atrium-on-accent:#0a0e14;--atrium-accent-soft:#1e2f4d;--atrium-accent-soft-fg:#b9d1ff;--atrium-focus:#8ab4ff;--atrium-off:#222b38;--atrium-off-fg:#c3cbd6;--atrium-badge-line:transparent;--atrium-danger:#ff8a8a;--atrium-danger-hover:#ffb0b0;--atrium-on-danger:#0a0e14;--atrium-danger-soft:#3d1c22;--atrium-danger-soft-fg:#ffc2c2;--atrium-success:#5fd38d;--atrium-success-soft:#173524;--atrium-success-soft-fg:#a6ebc0;--atrium-warning-soft:#3a2e12;--atrium-warning-soft-fg:#fcd98a;--atrium-mark:#fff;--atrium-mark-accent:#8ab4ff}[data-theme=sand]{--lightningcss-light:initial;--lightningcss-dark: ;color-scheme:light;--atrium-sidebar:#1f1a14;--atrium-sidebar-fg:#f5efe6;--atrium-sidebar-muted:#b3a796;--atrium-sidebar-hover:#2b241c;--atrium-sidebar-active:#342b21;--atrium-sidebar-active-fg:#fff;--atrium-sidebar-accent:#f2a65a;--atrium-sidebar-line:#342b21;--atrium-page:#f7f3ec;--atrium-surface:#fff;--atrium-surface-alt:#fbf8f3;--atrium-hover:#f1ece4;--atrium-fg:#1f1a14;--atrium-muted:#5c5246;--atrium-line:#e7dfd2;--atrium-field:#958672;--atrium-accent:#a6490a;--atrium-accent-hover:#853a07;--atrium-on-accent:#fff;--atrium-accent-soft:#fce7d2;--atrium-accent-soft-fg:#7a3506;--atrium-focus:#a6490a;--atrium-off:#f1ece4;--atrium-off-fg:#4a4137;--atrium-badge-line:transparent;--atrium-danger:#b42318;--atrium-danger-hover:#912018;--atrium-on-danger:#fff;--atrium-danger-soft:#fde4e1;--atrium-danger-soft-fg:#8a1c12;--atrium-success:#2e7d32;--atrium-success-soft:#e3f2df;--atrium-success-soft-fg:#1f5a23;--atrium-warning-soft:#fbefc5;--atrium-warning-soft-fg:#7a4a06;--atrium-mark:#f5efe6;--atrium-mark-accent:#f2a65a}[data-theme=contrast]{--lightningcss-light:initial;--lightningcss-dark: ;color-scheme:light;--atrium-sidebar:#000;--atrium-sidebar-fg:#fff;--atrium-sidebar-muted:#d4d4d4;--atrium-sidebar-hover:#262626;--atrium-sidebar-active:#ffd400;--atrium-sidebar-active-fg:#000;--atrium-sidebar-accent:#ffd400;--atrium-sidebar-line:#fff;--atrium-page:#fff;--atrium-surface:#fff;--atrium-surface-alt:#fff;--atrium-hover:#fff2a8;--atrium-fg:#000;--atrium-muted:#262626;--atrium-line:#000;--atrium-field:#000;--atrium-accent:#0033a0;--atrium-accent-hover:#001f66;--atrium-on-accent:#fff;--atrium-accent-soft:#ffd400;--atrium-accent-soft-fg:#000;--atrium-focus:#0033a0;--atrium-off:#fff;--atrium-off-fg:#000;--atrium-badge-line:#000;--atrium-danger:#b00020;--atrium-danger-hover:#7a0016;--atrium-on-danger:#fff;--atrium-danger-soft:#ffe0e0;--atrium-danger-soft-fg:#7a0016;--atrium-success:#006b2d;--atrium-success-soft:#d9f5e3;--atrium-success-soft-fg:#003d1a;--atrium-warning-soft:#ffd400;--atrium-warning-soft-fg:#000;--atrium-mark:#fff;--atrium-mark-accent:#ffd400}[data-theme=contrast] .border{border-width:2px}[data-theme=contrast] .border-t{border-top-width:2px}[data-theme=contrast] .border-b{border-bottom-width:2px}[data-theme=contrast] .border-l{border-left-width:2px}[data-theme=contrast] .border-r{border-right-width:2px}[data-theme=contrast] .divide-y>:not(:last-child){border-bottom-width:2px}[data-credit]{--atrium-credit-logo:url(/vendor/atrium/assets/logo-DDS3n-zU.svg)}:where([data-theme=graphite],[data-theme=night],[data-theme=sand],[data-theme=contrast]) [data-credit-on=sidebar],:where([data-theme=night]) [data-credit-on=page]{--atrium-credit-logo:url(/vendor/atrium/assets/logo-white-BqJt87jq.svg)}select:not([multiple]):not([size]){padding-right:2rem}@property --tw-border-spacing-x{syntax:"";inherits:false;initial-value:0}@property --tw-border-spacing-y{syntax:"";inherits:false;initial-value:0}@property --tw-translate-x{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-y{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-z{syntax:"*";inherits:false;initial-value:0}@property --tw-scale-x{syntax:"*";inherits:false;initial-value:1}@property --tw-scale-y{syntax:"*";inherits:false;initial-value:1}@property --tw-scale-z{syntax:"*";inherits:false;initial-value:1}@property --tw-rotate-x{syntax:"*";inherits:false}@property --tw-rotate-y{syntax:"*";inherits:false}@property --tw-rotate-z{syntax:"*";inherits:false}@property --tw-skew-x{syntax:"*";inherits:false}@property --tw-skew-y{syntax:"*";inherits:false}@property --tw-space-y-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-space-x-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-divide-y-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-leading{syntax:"*";inherits:false}@property --tw-font-weight{syntax:"*";inherits:false}@property --tw-tracking{syntax:"*";inherits:false}@property --tw-ordinal{syntax:"*";inherits:false}@property --tw-slashed-zero{syntax:"*";inherits:false}@property --tw-numeric-figure{syntax:"*";inherits:false}@property --tw-numeric-spacing{syntax:"*";inherits:false}@property --tw-numeric-fraction{syntax:"*";inherits:false}@property --tw-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:"*";inherits:false}@property --tw-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:"*";inherits:false}@property --tw-inset-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:"*";inherits:false}@property --tw-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:"*";inherits:false}@property --tw-inset-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:"*";inherits:false}@property --tw-ring-offset-width{syntax:"";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:"*";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-outline-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-blur{syntax:"*";inherits:false}@property --tw-brightness{syntax:"*";inherits:false}@property --tw-contrast{syntax:"*";inherits:false}@property --tw-grayscale{syntax:"*";inherits:false}@property --tw-hue-rotate{syntax:"*";inherits:false}@property --tw-invert{syntax:"*";inherits:false}@property --tw-opacity{syntax:"*";inherits:false}@property --tw-saturate{syntax:"*";inherits:false}@property --tw-sepia{syntax:"*";inherits:false}@property --tw-drop-shadow{syntax:"*";inherits:false}@property --tw-drop-shadow-color{syntax:"*";inherits:false}@property --tw-drop-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-drop-shadow-size{syntax:"*";inherits:false}@property --tw-duration{syntax:"*";inherits:false}@property --tw-ease{syntax:"*";inherits:false}@keyframes spin{to{transform:rotate(360deg)}} diff --git a/packages/admin/dist/assets/app-XteR4oRF.css b/packages/admin/dist/assets/app-XteR4oRF.css new file mode 100644 index 00000000..222780a6 --- /dev/null +++ b/packages/admin/dist/assets/app-XteR4oRF.css @@ -0,0 +1,2 @@ +/*! tailwindcss v4.3.5 | MIT License | https://tailwindcss.com */ +@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:block))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-translate-z:0;--tw-scale-x:1;--tw-scale-y:1;--tw-scale-z:1;--tw-rotate-x:initial;--tw-rotate-y:initial;--tw-rotate-z:initial;--tw-skew-x:initial;--tw-skew-y:initial;--tw-space-y-reverse:0;--tw-space-x-reverse:0;--tw-divide-y-reverse:0;--tw-border-style:solid;--tw-leading:initial;--tw-font-weight:initial;--tw-tracking:initial;--tw-ordinal:initial;--tw-slashed-zero:initial;--tw-numeric-figure:initial;--tw-numeric-spacing:initial;--tw-numeric-fraction:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-outline-style:solid;--tw-blur:initial;--tw-brightness:initial;--tw-contrast:initial;--tw-grayscale:initial;--tw-hue-rotate:initial;--tw-invert:initial;--tw-opacity:initial;--tw-saturate:initial;--tw-sepia:initial;--tw-drop-shadow:initial;--tw-drop-shadow-color:initial;--tw-drop-shadow-alpha:100%;--tw-drop-shadow-size:initial;--tw-duration:initial;--tw-ease:initial}}}@layer theme{:root,:host{--font-sans:ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";--font-mono:ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;--spacing:.25rem;--container-xs:20rem;--container-sm:24rem;--container-md:28rem;--container-lg:32rem;--container-xl:36rem;--container-2xl:42rem;--container-4xl:56rem;--text-xs:.75rem;--text-xs--line-height:calc(1 / .75);--text-sm:.875rem;--text-sm--line-height:calc(1.25 / .875);--text-base:1rem;--text-base--line-height:calc(1.5 / 1);--text-lg:1.125rem;--text-lg--line-height:calc(1.75 / 1.125);--text-xl:1.25rem;--text-xl--line-height:calc(1.75 / 1.25);--text-2xl:1.5rem;--text-2xl--line-height:calc(2 / 1.5);--text-3xl:1.875rem;--text-3xl--line-height:calc(2.25 / 1.875);--font-weight-normal:400;--font-weight-medium:500;--font-weight-semibold:600;--font-weight-bold:700;--tracking-wide:.025em;--tracking-wider:.05em;--leading-tight:1.25;--radius-sm:.25rem;--radius-md:.375rem;--radius-lg:.5rem;--radius-xl:.75rem;--ease-in:cubic-bezier(.4, 0, 1, 1);--ease-out:cubic-bezier(0, 0, .2, 1);--ease-in-out:cubic-bezier(.4, 0, .2, 1);--animate-spin:spin 1s linear infinite;--default-transition-duration:.15s;--default-transition-timing-function:cubic-bezier(.4, 0, .2, 1);--default-font-family:var(--font-sans);--default-mono-font-family:var(--font-mono);--font-brand:"Space Grotesk", var(--font-sans)}}@layer base{*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;tab-size:4;line-height:1.5;font-family:var(--default-font-family,-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family,ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-variation-settings:var(--default-mono-font-variation-settings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring:where(:not(iframe)){outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab, red, red)){::placeholder{color:color-mix(in oklab, currentcolor 50%, transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit{padding-block:0}::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-month-field{padding-block:0}::-webkit-datetime-edit-day-field{padding-block:0}::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field{padding-block:0}::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-datetime-edit-meridiem-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){appearance:button}::file-selector-button{appearance:button}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}html{accent-color:var(--atrium-accent);background-color:var(--atrium-page);color:var(--atrium-fg)}*{--tw-ring-offset-color:var(--atrium-surface)}::placeholder{color:var(--atrium-muted);opacity:1}select:not([multiple]):not([size]){appearance:none;background-color:var(--atrium-surface);background-image:linear-gradient(45deg,#0000 50%,currentColor 50%),linear-gradient(135deg,currentColor 50%,#0000 50%);background-position:calc(100% - 1rem),calc(100% - .6875rem);background-repeat:no-repeat;background-size:.3125rem .3125rem}select option{background-color:var(--atrium-surface);color:var(--atrium-fg)}}@layer components;@layer utilities{.collapse{visibility:collapse}.visible{visibility:visible}.sr-only{clip-path:inset(50%);white-space:nowrap;border-width:0;width:1px;height:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}.absolute{position:absolute}.fixed{position:fixed}.relative{position:relative}.static{position:static}.sticky{position:sticky}.inset-0{inset:0}.inset-y-0{inset-block:0}.top-0{top:0}.top-1{top:var(--spacing)}.top-1\/2{top:50%}.top-2{top:calc(var(--spacing) * 2)}.top-4{top:calc(var(--spacing) * 4)}.right-0{right:0}.right-1{right:var(--spacing)}.right-2{right:calc(var(--spacing) * 2)}.right-4{right:calc(var(--spacing) * 4)}.bottom-4{bottom:calc(var(--spacing) * 4)}.left-0{left:0}.left-2{left:calc(var(--spacing) * 2)}.left-2\.5{left:calc(var(--spacing) * 2.5)}.isolate{isolation:isolate}.z-10{z-index:10}.z-30{z-index:30}.z-40{z-index:40}.z-50{z-index:50}.container{width:100%}@media (width>=40rem){.container{max-width:40rem}}@media (width>=48rem){.container{max-width:48rem}}@media (width>=64rem){.container{max-width:64rem}}@media (width>=80rem){.container{max-width:80rem}}@media (width>=96rem){.container{max-width:96rem}}.mx-4{margin-inline:calc(var(--spacing) * 4)}.mx-auto{margin-inline:auto}.-mt-4{margin-top:calc(var(--spacing) * -4)}.mt-0\.5{margin-top:calc(var(--spacing) * .5)}.mt-1{margin-top:var(--spacing)}.mt-1\.5{margin-top:calc(var(--spacing) * 1.5)}.mt-2{margin-top:calc(var(--spacing) * 2)}.mt-3{margin-top:calc(var(--spacing) * 3)}.mt-4{margin-top:calc(var(--spacing) * 4)}.mt-6{margin-top:calc(var(--spacing) * 6)}.mt-8{margin-top:calc(var(--spacing) * 8)}.mr-1{margin-right:var(--spacing)}.mr-1\.5{margin-right:calc(var(--spacing) * 1.5)}.mr-2{margin-right:calc(var(--spacing) * 2)}.mr-3{margin-right:calc(var(--spacing) * 3)}.mr-4{margin-right:calc(var(--spacing) * 4)}.-mb-px{margin-bottom:-1px}.mb-0\.5{margin-bottom:calc(var(--spacing) * .5)}.mb-1{margin-bottom:var(--spacing)}.mb-2{margin-bottom:calc(var(--spacing) * 2)}.mb-3{margin-bottom:calc(var(--spacing) * 3)}.mb-4{margin-bottom:calc(var(--spacing) * 4)}.mb-6{margin-bottom:calc(var(--spacing) * 6)}.mb-8{margin-bottom:calc(var(--spacing) * 8)}.-ml-0\.5{margin-left:calc(var(--spacing) * -.5)}.-ml-1{margin-left:calc(var(--spacing) * -1)}.ml-1{margin-left:var(--spacing)}.ml-1\.5{margin-left:calc(var(--spacing) * 1.5)}.ml-2{margin-left:calc(var(--spacing) * 2)}.ml-3{margin-left:calc(var(--spacing) * 3)}.ml-4{margin-left:calc(var(--spacing) * 4)}.ml-6{margin-left:calc(var(--spacing) * 6)}.ml-auto{margin-left:auto}.line-clamp-2{-webkit-line-clamp:2;-webkit-box-orient:vertical;display:-webkit-box;overflow:hidden}.block{display:block}.contents{display:contents}.flex{display:flex}.grid{display:grid}.hidden{display:none}.inline{display:inline}.inline-block{display:inline-block}.inline-flex{display:inline-flex}.table{display:table}.aspect-square{aspect-ratio:1}.h-1\.5{height:calc(var(--spacing) * 1.5)}.h-2{height:calc(var(--spacing) * 2)}.h-3{height:calc(var(--spacing) * 3)}.h-3\.5{height:calc(var(--spacing) * 3.5)}.h-4{height:calc(var(--spacing) * 4)}.h-5{height:calc(var(--spacing) * 5)}.h-6{height:calc(var(--spacing) * 6)}.h-8{height:calc(var(--spacing) * 8)}.h-10{height:calc(var(--spacing) * 10)}.h-12{height:calc(var(--spacing) * 12)}.h-16{height:calc(var(--spacing) * 16)}.h-24{height:calc(var(--spacing) * 24)}.h-full{height:100%}.h-px{height:1px}.max-h-60{max-height:calc(var(--spacing) * 60)}.max-h-64{max-height:calc(var(--spacing) * 64)}.max-h-96{max-height:calc(var(--spacing) * 96)}.max-h-\[90vh\]{max-height:90vh}.max-h-\[min\(36rem\,calc\(100vh-8rem\)\)\]{max-height:min(36rem,100vh - 8rem)}.min-h-full{min-height:100%}.min-h-screen{min-height:100vh}.w-0\.5{width:calc(var(--spacing) * .5)}.w-1\.5{width:calc(var(--spacing) * 1.5)}.w-2{width:calc(var(--spacing) * 2)}.w-3{width:calc(var(--spacing) * 3)}.w-3\.5{width:calc(var(--spacing) * 3.5)}.w-4{width:calc(var(--spacing) * 4)}.w-5{width:calc(var(--spacing) * 5)}.w-6{width:calc(var(--spacing) * 6)}.w-8{width:calc(var(--spacing) * 8)}.w-10{width:calc(var(--spacing) * 10)}.w-12{width:calc(var(--spacing) * 12)}.w-16{width:calc(var(--spacing) * 16)}.w-20{width:calc(var(--spacing) * 20)}.w-24{width:calc(var(--spacing) * 24)}.w-56{width:calc(var(--spacing) * 56)}.w-64{width:calc(var(--spacing) * 64)}.w-\[4\.75rem\]{width:4.75rem}.w-\[22rem\]{width:22rem}.w-auto{width:auto}.w-full{width:100%}.max-w-2xl{max-width:var(--container-2xl)}.max-w-4xl{max-width:var(--container-4xl)}.max-w-14{max-width:calc(var(--spacing) * 14)}.max-w-56{max-width:calc(var(--spacing) * 56)}.max-w-\[85\%\]{max-width:85%}.max-w-\[90\%\]{max-width:90%}.max-w-\[calc\(100vw-2rem\)\]{max-width:calc(100vw - 2rem)}.max-w-md{max-width:var(--container-md)}.max-w-none{max-width:none}.max-w-xl{max-width:var(--container-xl)}.max-w-xs{max-width:var(--container-xs)}.min-w-0{min-width:0}.min-w-5{min-width:calc(var(--spacing) * 5)}.min-w-48{min-width:calc(var(--spacing) * 48)}.min-w-full{min-width:100%}.flex-1{flex:1}.flex-none{flex:none}.flex-shrink{flex-shrink:1}.flex-shrink-0,.shrink-0{flex-shrink:0}.border-separate{border-collapse:separate}.border-spacing-0{--tw-border-spacing-x:0px;--tw-border-spacing-y:0px;border-spacing:var(--tw-border-spacing-x) var(--tw-border-spacing-y)}.-translate-x-full{--tw-translate-x:-100%;translate:var(--tw-translate-x) var(--tw-translate-y)}.translate-x-0{--tw-translate-x:0px;translate:var(--tw-translate-x) var(--tw-translate-y)}.-translate-y-1\/2{--tw-translate-y:calc(calc(1 / 2 * 100%) * -1);translate:var(--tw-translate-x) var(--tw-translate-y)}.translate-y-0{--tw-translate-y:0px;translate:var(--tw-translate-x) var(--tw-translate-y)}.translate-y-4{--tw-translate-y:calc(var(--spacing) * 4);translate:var(--tw-translate-x) var(--tw-translate-y)}.scale-95{--tw-scale-x:95%;--tw-scale-y:95%;--tw-scale-z:95%;scale:var(--tw-scale-x) var(--tw-scale-y)}.scale-100{--tw-scale-x:100%;--tw-scale-y:100%;--tw-scale-z:100%;scale:var(--tw-scale-x) var(--tw-scale-y)}.scale-110{--tw-scale-x:110%;--tw-scale-y:110%;--tw-scale-z:110%;scale:var(--tw-scale-x) var(--tw-scale-y)}.rotate-90{rotate:90deg}.rotate-180{rotate:180deg}.transform{transform:var(--tw-rotate-x, ) var(--tw-rotate-y, ) var(--tw-rotate-z, ) var(--tw-skew-x, ) var(--tw-skew-y, )}.transform-gpu{transform:translateZ(0) var(--tw-rotate-x, ) var(--tw-rotate-y, ) var(--tw-rotate-z, ) var(--tw-skew-x, ) var(--tw-skew-y, )}.animate-spin{animation:var(--animate-spin)}.cursor-move{cursor:move}.cursor-pointer{cursor:pointer}.resize{resize:both}.resize-none{resize:none}.resize-y{resize:vertical}.list-disc{list-style-type:disc}.appearance-none{appearance:none}.grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.grid-cols-5{grid-template-columns:repeat(5,minmax(0,1fr))}.grid-cols-\[auto_1fr\]{grid-template-columns:auto 1fr}.grid-cols-\[auto_auto_1fr\]{grid-template-columns:auto auto 1fr}.flex-col{flex-direction:column}.flex-col-reverse{flex-direction:column-reverse}.flex-wrap{flex-wrap:wrap}.items-baseline{align-items:baseline}.items-center{align-items:center}.items-end{align-items:flex-end}.items-start{align-items:flex-start}.justify-between{justify-content:space-between}.justify-center{justify-content:center}.justify-end{justify-content:flex-end}.justify-start{justify-content:flex-start}.gap-0\.5{gap:calc(var(--spacing) * .5)}.gap-1{gap:var(--spacing)}.gap-1\.5{gap:calc(var(--spacing) * 1.5)}.gap-2{gap:calc(var(--spacing) * 2)}.gap-2\.5{gap:calc(var(--spacing) * 2.5)}.gap-3{gap:calc(var(--spacing) * 3)}.gap-4{gap:calc(var(--spacing) * 4)}.gap-6{gap:calc(var(--spacing) * 6)}.gap-px{gap:1px}:where(.space-y-0\.5>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * .5) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * .5) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-1>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(var(--spacing) * var(--tw-space-y-reverse));margin-block-end:calc(var(--spacing) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-2>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 2) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 2) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-3>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 3) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 3) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-4>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 4) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 4) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-5>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 5) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 5) * calc(1 - var(--tw-space-y-reverse)))}:where(.space-y-6>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(calc(var(--spacing) * 6) * var(--tw-space-y-reverse));margin-block-end:calc(calc(var(--spacing) * 6) * calc(1 - var(--tw-space-y-reverse)))}.gap-x-3{column-gap:calc(var(--spacing) * 3)}.gap-x-4{column-gap:calc(var(--spacing) * 4)}:where(.-space-x-px>:not(:last-child)){--tw-space-x-reverse:0;margin-inline-start:calc(-1px * var(--tw-space-x-reverse));margin-inline-end:calc(-1px * calc(1 - var(--tw-space-x-reverse)))}:where(.space-x-1>:not(:last-child)){--tw-space-x-reverse:0;margin-inline-start:calc(var(--spacing) * var(--tw-space-x-reverse));margin-inline-end:calc(var(--spacing) * calc(1 - var(--tw-space-x-reverse)))}:where(.space-x-2>:not(:last-child)){--tw-space-x-reverse:0;margin-inline-start:calc(calc(var(--spacing) * 2) * var(--tw-space-x-reverse));margin-inline-end:calc(calc(var(--spacing) * 2) * calc(1 - var(--tw-space-x-reverse)))}:where(.space-x-3>:not(:last-child)){--tw-space-x-reverse:0;margin-inline-start:calc(calc(var(--spacing) * 3) * var(--tw-space-x-reverse));margin-inline-end:calc(calc(var(--spacing) * 3) * calc(1 - var(--tw-space-x-reverse)))}:where(.space-x-4>:not(:last-child)){--tw-space-x-reverse:0;margin-inline-start:calc(calc(var(--spacing) * 4) * var(--tw-space-x-reverse));margin-inline-end:calc(calc(var(--spacing) * 4) * calc(1 - var(--tw-space-x-reverse)))}:where(.space-x-8>:not(:last-child)){--tw-space-x-reverse:0;margin-inline-start:calc(calc(var(--spacing) * 8) * var(--tw-space-x-reverse));margin-inline-end:calc(calc(var(--spacing) * 8) * calc(1 - var(--tw-space-x-reverse)))}.gap-y-1{row-gap:var(--spacing)}.gap-y-3{row-gap:calc(var(--spacing) * 3)}:where(.divide-y>:not(:last-child)){--tw-divide-y-reverse:0;border-bottom-style:var(--tw-border-style);border-top-style:var(--tw-border-style);border-top-width:calc(1px * var(--tw-divide-y-reverse));border-bottom-width:calc(1px * calc(1 - var(--tw-divide-y-reverse)))}:where(.divide-line>:not(:last-child)){border-color:var(--atrium-line)}.truncate{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.overflow-auto{overflow:auto}.overflow-hidden{overflow:hidden}.overflow-visible{overflow:visible}.overflow-x-auto{overflow-x:auto}.overflow-y-auto{overflow-y:auto}.rounded{border-radius:.25rem}.rounded-full{border-radius:2147483647px}.rounded-lg{border-radius:var(--radius-lg)}.rounded-md{border-radius:var(--radius-md)}.rounded-sm{border-radius:var(--radius-sm)}.rounded-xl{border-radius:var(--radius-xl)}.rounded-t-sm{border-top-left-radius:var(--radius-sm);border-top-right-radius:var(--radius-sm)}.rounded-l-md{border-top-left-radius:var(--radius-md);border-bottom-left-radius:var(--radius-md)}.rounded-r-md{border-top-right-radius:var(--radius-md);border-bottom-right-radius:var(--radius-md)}.rounded-b-lg{border-bottom-right-radius:var(--radius-lg);border-bottom-left-radius:var(--radius-lg)}.rounded-b-xl{border-bottom-right-radius:var(--radius-xl);border-bottom-left-radius:var(--radius-xl)}.border{border-style:var(--tw-border-style);border-width:1px}.border-0{border-style:var(--tw-border-style);border-width:0}.border-2{border-style:var(--tw-border-style);border-width:2px}.border-t{border-top-style:var(--tw-border-style);border-top-width:1px}.border-r{border-right-style:var(--tw-border-style);border-right-width:1px}.border-b{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}.border-b-2{border-bottom-style:var(--tw-border-style);border-bottom-width:2px}.border-l{border-left-style:var(--tw-border-style);border-left-width:1px}.border-dashed{--tw-border-style:dashed;border-style:dashed}.border-accent{border-color:var(--atrium-accent)}.border-accent-hover{border-color:var(--atrium-accent-hover)}.border-accent-soft{border-color:var(--atrium-accent-soft)}.border-badge-line{border-color:var(--atrium-badge-line)}.border-current{border-color:currentColor}.border-danger{border-color:var(--atrium-danger)}.border-danger-soft{border-color:var(--atrium-danger-soft)}.border-field{border-color:var(--atrium-field)}.border-focus{border-color:var(--atrium-focus)}.border-line{border-color:var(--atrium-line)}.border-sidebar-line{border-color:var(--atrium-sidebar-line)}.border-success{border-color:var(--atrium-success)}.border-transparent{border-color:#0000}.border-warning-soft-fg{border-color:var(--atrium-warning-soft-fg)}.bg-accent{background-color:var(--atrium-accent)}.bg-accent-hover{background-color:var(--atrium-accent-hover)}.bg-accent-soft{background-color:var(--atrium-accent-soft)}.bg-black\/50{background-color:oklab(0% none none/.5)}.bg-current{background-color:currentColor}.bg-danger{background-color:var(--atrium-danger)}.bg-danger-hover{background-color:var(--atrium-danger-hover)}.bg-danger-soft{background-color:var(--atrium-danger-soft)}.bg-field{background-color:var(--atrium-field)}.bg-inherit{background-color:inherit}.bg-line{background-color:var(--atrium-line)}.bg-off{background-color:var(--atrium-off)}.bg-page{background-color:var(--atrium-page)}.bg-sidebar{background-color:var(--atrium-sidebar)}.bg-sidebar-active{background-color:var(--atrium-sidebar-active)}.bg-success-soft{background-color:var(--atrium-success-soft)}.bg-surface{background-color:var(--atrium-surface)}.bg-surface-alt{background-color:var(--atrium-surface-alt)}.bg-surface\/75{background-color:var(--atrium-surface)}@supports (color:color-mix(in lab, red, red)){.bg-surface\/75{background-color:color-mix(in oklab, var(--atrium-surface) 75%, transparent)}}.bg-transparent{background-color:#0000}.bg-warning-soft{background-color:var(--atrium-warning-soft)}.bg-white{background-color:#fff}.bg-contain{background-size:contain}.bg-center{background-position:50%}.bg-left{background-position:0}.bg-no-repeat{background-repeat:no-repeat}.fill-accent{fill:var(--atrium-accent)}.fill-fg{fill:var(--atrium-fg)}.fill-mark{fill:var(--atrium-mark)}.fill-mark-accent{fill:var(--atrium-mark-accent)}.fill-surface{fill:var(--atrium-surface)}.object-cover{object-fit:cover}.p-0{padding:0}.p-0\.5{padding:calc(var(--spacing) * .5)}.p-1{padding:var(--spacing)}.p-1\.5{padding:calc(var(--spacing) * 1.5)}.p-2{padding:calc(var(--spacing) * 2)}.p-3{padding:calc(var(--spacing) * 3)}.p-4{padding:calc(var(--spacing) * 4)}.p-6{padding:calc(var(--spacing) * 6)}.p-8{padding:calc(var(--spacing) * 8)}.px-1{padding-inline:var(--spacing)}.px-1\.5{padding-inline:calc(var(--spacing) * 1.5)}.px-2{padding-inline:calc(var(--spacing) * 2)}.px-2\.5{padding-inline:calc(var(--spacing) * 2.5)}.px-3{padding-inline:calc(var(--spacing) * 3)}.px-4{padding-inline:calc(var(--spacing) * 4)}.px-5{padding-inline:calc(var(--spacing) * 5)}.px-6{padding-inline:calc(var(--spacing) * 6)}.py-0\.5{padding-block:calc(var(--spacing) * .5)}.py-1{padding-block:var(--spacing)}.py-1\.5{padding-block:calc(var(--spacing) * 1.5)}.py-2{padding-block:calc(var(--spacing) * 2)}.py-2\.5{padding-block:calc(var(--spacing) * 2.5)}.py-3{padding-block:calc(var(--spacing) * 3)}.py-4{padding-block:calc(var(--spacing) * 4)}.py-6{padding-block:calc(var(--spacing) * 6)}.py-10{padding-block:calc(var(--spacing) * 10)}.py-12{padding-block:calc(var(--spacing) * 12)}.py-16{padding-block:calc(var(--spacing) * 16)}.pt-2{padding-top:calc(var(--spacing) * 2)}.pt-3{padding-top:calc(var(--spacing) * 3)}.pt-4{padding-top:calc(var(--spacing) * 4)}.pt-6{padding-top:calc(var(--spacing) * 6)}.pr-2{padding-right:calc(var(--spacing) * 2)}.pr-3{padding-right:calc(var(--spacing) * 3)}.pr-4{padding-right:calc(var(--spacing) * 4)}.pr-10{padding-right:calc(var(--spacing) * 10)}.pb-1{padding-bottom:var(--spacing)}.pl-3{padding-left:calc(var(--spacing) * 3)}.pl-4{padding-left:calc(var(--spacing) * 4)}.pl-5{padding-left:calc(var(--spacing) * 5)}.pl-6{padding-left:calc(var(--spacing) * 6)}.pl-8{padding-left:calc(var(--spacing) * 8)}.pl-9{padding-left:calc(var(--spacing) * 9)}.pl-10{padding-left:calc(var(--spacing) * 10)}.pl-12{padding-left:calc(var(--spacing) * 12)}.text-center{text-align:center}.text-left{text-align:left}.text-right{text-align:right}.font-brand{font-family:var(--font-brand)}.font-mono{font-family:var(--font-mono)}.text-2xl{font-size:var(--text-2xl);line-height:var(--tw-leading,var(--text-2xl--line-height))}.text-3xl{font-size:var(--text-3xl);line-height:var(--tw-leading,var(--text-3xl--line-height))}.text-base{font-size:var(--text-base);line-height:var(--tw-leading,var(--text-base--line-height))}.text-lg{font-size:var(--text-lg);line-height:var(--tw-leading,var(--text-lg--line-height))}.text-sm{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.text-xl{font-size:var(--text-xl);line-height:var(--tw-leading,var(--text-xl--line-height))}.text-xs{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}.text-\[10px\]{font-size:10px}.text-\[11px\]{font-size:11px}.leading-5{--tw-leading:calc(var(--spacing) * 5);line-height:calc(var(--spacing) * 5)}.leading-none{--tw-leading:1;line-height:1}.leading-tight{--tw-leading:var(--leading-tight);line-height:var(--leading-tight)}.font-bold{--tw-font-weight:var(--font-weight-bold);font-weight:var(--font-weight-bold)}.font-medium{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.font-normal{--tw-font-weight:var(--font-weight-normal);font-weight:var(--font-weight-normal)}.font-semibold{--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.tracking-\[-0\.01em\]{--tw-tracking:-.01em;letter-spacing:-.01em}.tracking-wide{--tw-tracking:var(--tracking-wide);letter-spacing:var(--tracking-wide)}.tracking-wider{--tw-tracking:var(--tracking-wider);letter-spacing:var(--tracking-wider)}.break-words{overflow-wrap:break-word}.break-all{word-break:break-all}.whitespace-nowrap{white-space:nowrap}.whitespace-pre-line{white-space:pre-line}.whitespace-pre-wrap{white-space:pre-wrap}.text-accent{color:var(--atrium-accent)}.text-accent-hover{color:var(--atrium-accent-hover)}.text-accent-soft-fg{color:var(--atrium-accent-soft-fg)}.text-danger{color:var(--atrium-danger)}.text-danger-soft-fg{color:var(--atrium-danger-soft-fg)}.text-fg{color:var(--atrium-fg)}.text-muted{color:var(--atrium-muted)}.text-off-fg{color:var(--atrium-off-fg)}.text-on-accent{color:var(--atrium-on-accent)}.text-on-danger{color:var(--atrium-on-danger)}.text-sidebar-active-fg{color:var(--atrium-sidebar-active-fg)}.text-sidebar-fg{color:var(--atrium-sidebar-fg)}.text-sidebar-muted{color:var(--atrium-sidebar-muted)}.text-success{color:var(--atrium-success)}.text-success-soft-fg{color:var(--atrium-success-soft-fg)}.text-transparent{color:#0000}.text-warning-soft-fg{color:var(--atrium-warning-soft-fg)}.lowercase{text-transform:lowercase}.uppercase{text-transform:uppercase}.italic{font-style:italic}.tabular-nums{--tw-numeric-spacing:tabular-nums;font-variant-numeric:var(--tw-ordinal, ) var(--tw-slashed-zero, ) var(--tw-numeric-figure, ) var(--tw-numeric-spacing, ) var(--tw-numeric-fraction, )}.underline{text-decoration-line:underline}.antialiased{-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.placeholder-muted::placeholder{color:var(--atrium-muted)}.accent-hover{accent-color:var(--atrium-hover)}.opacity-0{opacity:0}.opacity-25{opacity:.25}.opacity-50{opacity:.5}.opacity-75{opacity:.75}.opacity-100{opacity:1}.shadow{--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a), 0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.shadow-2xl{--tw-shadow:0 25px 50px -12px var(--tw-shadow-color,#00000040);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.shadow-\[inset_3px_0_0_var\(--atrium-sidebar-accent\)\]{--tw-shadow:inset 3px 0 0 var(--tw-shadow-color,var(--atrium-sidebar-accent));box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.shadow-lg{--tw-shadow:0 10px 15px -3px var(--tw-shadow-color,#0000001a), 0 4px 6px -4px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.shadow-sm{--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a), 0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.shadow-xl{--tw-shadow:0 20px 25px -5px var(--tw-shadow-color,#0000001a), 0 8px 10px -6px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.ring,.ring-1{--tw-ring-shadow:var(--tw-ring-inset, ) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.ring-2{--tw-ring-shadow:var(--tw-ring-inset, ) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.ring-field{--tw-ring-color:var(--atrium-field)}.ring-focus{--tw-ring-color:var(--atrium-focus)}.ring-line{--tw-ring-color:var(--atrium-line)}.outline{outline-style:var(--tw-outline-style);outline-width:1px}.filter{filter:var(--tw-blur, ) var(--tw-brightness, ) var(--tw-contrast, ) var(--tw-grayscale, ) var(--tw-hue-rotate, ) var(--tw-invert, ) var(--tw-saturate, ) var(--tw-sepia, ) var(--tw-drop-shadow, )}.transition{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to,opacity,box-shadow,transform,translate,scale,rotate,filter,-webkit-backdrop-filter,backdrop-filter,display,content-visibility,overlay,pointer-events;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-all{transition-property:all;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-colors{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-opacity{transition-property:opacity;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-transform{transition-property:transform,translate,scale,rotate;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.duration-75{--tw-duration:75ms;transition-duration:75ms}.duration-100{--tw-duration:.1s;transition-duration:.1s}.duration-150{--tw-duration:.15s;transition-duration:.15s}.duration-200{--tw-duration:.2s;transition-duration:.2s}.duration-300{--tw-duration:.3s;transition-duration:.3s}.ease-in{--tw-ease:var(--ease-in);transition-timing-function:var(--ease-in)}.ease-in-out{--tw-ease:var(--ease-in-out);transition-timing-function:var(--ease-in-out)}.ease-out{--tw-ease:var(--ease-out);transition-timing-function:var(--ease-out)}.select-all{-webkit-user-select:all;user-select:all}.select-none{-webkit-user-select:none;user-select:none}.ring-inset{--tw-ring-inset:inset}@media (hover:hover){:is(:where(.group):hover .group-hover\:text-fg){color:var(--atrium-fg)}:is(:where(.group):hover .group-hover\:opacity-100){opacity:1}}.file\:mr-4::file-selector-button{margin-right:calc(var(--spacing) * 4)}.file\:rounded-md::file-selector-button{border-radius:var(--radius-md)}.file\:border-0::file-selector-button{border-style:var(--tw-border-style);border-width:0}.file\:bg-accent-soft::file-selector-button{background-color:var(--atrium-accent-soft)}.file\:px-4::file-selector-button{padding-inline:calc(var(--spacing) * 4)}.file\:py-2::file-selector-button{padding-block:calc(var(--spacing) * 2)}.file\:text-sm::file-selector-button{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.file\:font-medium::file-selector-button{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.file\:text-accent-hover::file-selector-button{color:var(--atrium-accent-hover)}.last\:mb-0:last-child{margin-bottom:0}.last\:border-b-0:last-child{border-bottom-style:var(--tw-border-style);border-bottom-width:0}@media (hover:hover){.hover\:scale-105:hover{--tw-scale-x:105%;--tw-scale-y:105%;--tw-scale-z:105%;scale:var(--tw-scale-x) var(--tw-scale-y)}.hover\:border-fg:hover{border-color:var(--atrium-fg)}.hover\:border-field:hover{border-color:var(--atrium-field)}.hover\:border-focus:hover{border-color:var(--atrium-focus)}.hover\:bg-accent-hover:hover{background-color:var(--atrium-accent-hover)}.hover\:bg-accent-soft:hover{background-color:var(--atrium-accent-soft)}.hover\:bg-danger-hover:hover{background-color:var(--atrium-danger-hover)}.hover\:bg-danger-soft:hover{background-color:var(--atrium-danger-soft)}.hover\:bg-hover:hover{background-color:var(--atrium-hover)}.hover\:bg-sidebar-hover:hover{background-color:var(--atrium-sidebar-hover)}.hover\:text-accent:hover{color:var(--atrium-accent)}.hover\:text-accent-hover:hover{color:var(--atrium-accent-hover)}.hover\:text-accent-soft-fg:hover{color:var(--atrium-accent-soft-fg)}.hover\:text-danger:hover{color:var(--atrium-danger)}.hover\:text-danger-soft-fg:hover{color:var(--atrium-danger-soft-fg)}.hover\:text-fg:hover{color:var(--atrium-fg)}.hover\:text-sidebar-fg:hover{color:var(--atrium-sidebar-fg)}.hover\:underline:hover{text-decoration-line:underline}.hover\:file\:bg-accent-soft:hover::file-selector-button{background-color:var(--atrium-accent-soft)}}.focus\:border-focus:focus{border-color:var(--atrium-focus)}.focus\:ring-1:focus{--tw-ring-shadow:var(--tw-ring-inset, ) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.focus\:ring-2:focus{--tw-ring-shadow:var(--tw-ring-inset, ) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.focus\:ring-danger:focus{--tw-ring-color:var(--atrium-danger)}.focus\:ring-focus:focus{--tw-ring-color:var(--atrium-focus)}.focus\:ring-offset-2:focus{--tw-ring-offset-width:2px;--tw-ring-offset-shadow:var(--tw-ring-inset, ) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color)}.focus\:outline-none:focus{--tw-outline-style:none;outline-style:none}.focus-visible\:ring-2:focus-visible{--tw-ring-shadow:var(--tw-ring-inset, ) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.focus-visible\:ring-focus:focus-visible{--tw-ring-color:var(--atrium-focus)}.focus-visible\:ring-sidebar-accent:focus-visible{--tw-ring-color:var(--atrium-sidebar-accent)}.focus-visible\:outline:focus-visible{outline-style:var(--tw-outline-style);outline-width:1px}.focus-visible\:outline-2:focus-visible{outline-style:var(--tw-outline-style);outline-width:2px}.focus-visible\:outline-offset-2:focus-visible{outline-offset:2px}.focus-visible\:outline-focus:focus-visible{outline-color:var(--atrium-focus)}.focus-visible\:ring-inset:focus-visible{--tw-ring-inset:inset}.disabled\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\:bg-off:disabled{background-color:var(--atrium-off)}.disabled\:text-muted:disabled{color:var(--atrium-muted)}.disabled\:opacity-30:disabled{opacity:.3}.disabled\:opacity-50:disabled{opacity:.5}@media (width>=40rem){.sm\:col-span-2{grid-column:span 2/span 2}.sm\:my-8{margin-block:calc(var(--spacing) * 8)}.sm\:block{display:block}.sm\:hidden{display:none}.sm\:inline{display:inline}.sm\:w-full{width:100%}.sm\:max-w-2xl{max-width:var(--container-2xl)}.sm\:max-w-32{max-width:calc(var(--spacing) * 32)}.sm\:max-w-lg{max-width:var(--container-lg)}.sm\:max-w-md{max-width:var(--container-md)}.sm\:max-w-sm{max-width:var(--container-sm)}.sm\:max-w-xl{max-width:var(--container-xl)}.sm\:translate-y-0{--tw-translate-y:0px;translate:var(--tw-translate-x) var(--tw-translate-y)}.sm\:scale-95{--tw-scale-x:95%;--tw-scale-y:95%;--tw-scale-z:95%;scale:var(--tw-scale-x) var(--tw-scale-y)}.sm\:scale-100{--tw-scale-x:100%;--tw-scale-y:100%;--tw-scale-z:100%;scale:var(--tw-scale-x) var(--tw-scale-y)}.sm\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.sm\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.sm\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.sm\:grid-cols-6{grid-template-columns:repeat(6,minmax(0,1fr))}.sm\:flex-row{flex-direction:row}.sm\:items-center{align-items:center}.sm\:items-end{align-items:flex-end}.sm\:justify-between{justify-content:space-between}.sm\:gap-2{gap:calc(var(--spacing) * 2)}.sm\:gap-4{gap:calc(var(--spacing) * 4)}.sm\:px-2{padding-inline:calc(var(--spacing) * 2)}.sm\:px-4{padding-inline:calc(var(--spacing) * 4)}.sm\:px-6{padding-inline:calc(var(--spacing) * 6)}.sm\:text-sm{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.sm\:text-xs{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}}@media (width>=48rem){.md\:block{display:block}.md\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}:where(.md\:space-x-3>:not(:last-child)){--tw-space-x-reverse:0;margin-inline-start:calc(calc(var(--spacing) * 3) * var(--tw-space-x-reverse));margin-inline-end:calc(calc(var(--spacing) * 3) * calc(1 - var(--tw-space-x-reverse)))}}@media (width>=64rem){.lg\:col-span-2{grid-column:span 2/span 2}.lg\:col-span-4{grid-column:span 4/span 4}.lg\:block{display:block}.lg\:hidden{display:none}.lg\:w-20{width:calc(var(--spacing) * 20)}.lg\:w-64{width:calc(var(--spacing) * 64)}.lg\:translate-x-0{--tw-translate-x:0px;translate:var(--tw-translate-x) var(--tw-translate-y)}.lg\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.lg\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.lg\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.lg\:flex-row{flex-direction:row}.lg\:items-start{align-items:flex-start}.lg\:justify-between{justify-content:space-between}.lg\:gap-3{gap:calc(var(--spacing) * 3)}.lg\:p-6{padding:calc(var(--spacing) * 6)}.lg\:px-2{padding-inline:calc(var(--spacing) * 2)}.lg\:px-6{padding-inline:calc(var(--spacing) * 6)}.lg\:px-8{padding-inline:calc(var(--spacing) * 8)}.lg\:pl-20{padding-left:calc(var(--spacing) * 20)}.lg\:pl-64{padding-left:calc(var(--spacing) * 64)}.lg\:text-center{text-align:center}}@media (width>=80rem){.xl\:max-w-48{max-width:calc(var(--spacing) * 48)}.xl\:grid-cols-6{grid-template-columns:repeat(6,minmax(0,1fr))}}}@font-face{font-family:Space Grotesk;font-style:normal;font-display:swap;font-weight:600;src:url(/vendor/atrium/assets/space-grotesk-latin-600-normal-DjKNqYRj.woff2)format("woff2"),url(/vendor/atrium/assets/space-grotesk-latin-600-normal-BflQw4A9.woff)format("woff")}:root,[data-theme=graphite]{--lightningcss-light:initial;--lightningcss-dark: ;color-scheme:light;--atrium-sidebar:#111827;--atrium-sidebar-fg:#f9fafb;--atrium-sidebar-muted:#9ca3af;--atrium-sidebar-hover:#1f2937;--atrium-sidebar-active:#1f2937;--atrium-sidebar-active-fg:#fff;--atrium-sidebar-accent:#60a5fa;--atrium-sidebar-line:#1f2937;--atrium-page:#f3f4f6;--atrium-surface:#fff;--atrium-surface-alt:#f9fafb;--atrium-hover:#f3f4f6;--atrium-fg:#111827;--atrium-muted:#4b5563;--atrium-line:#e5e7eb;--atrium-field:#7e8691;--atrium-accent:#2563eb;--atrium-accent-hover:#1d4ed8;--atrium-on-accent:#fff;--atrium-accent-soft:#dbeafe;--atrium-accent-soft-fg:#1e40af;--atrium-focus:#2563eb;--atrium-off:#f3f4f6;--atrium-off-fg:#374151;--atrium-badge-line:transparent;--atrium-danger:#c81e1e;--atrium-danger-hover:#991b1b;--atrium-on-danger:#fff;--atrium-danger-soft:#fee2e2;--atrium-danger-soft-fg:#991b1b;--atrium-success:#15803d;--atrium-success-soft:#dcfce7;--atrium-success-soft-fg:#166534;--atrium-warning-soft:#fef3c7;--atrium-warning-soft-fg:#92400e;--atrium-mark:#fff;--atrium-mark-accent:#60a5fa}[data-theme=day]{--lightningcss-light:initial;--lightningcss-dark: ;color-scheme:light;--atrium-sidebar:#fff;--atrium-sidebar-fg:#1f2937;--atrium-sidebar-muted:#64748b;--atrium-sidebar-hover:#f1f5f9;--atrium-sidebar-active:#eef2ff;--atrium-sidebar-active-fg:#3730a3;--atrium-sidebar-accent:#4f46e5;--atrium-sidebar-line:#e2e8f0;--atrium-page:#f8fafc;--atrium-surface:#fff;--atrium-surface-alt:#f8fafc;--atrium-hover:#f1f5f9;--atrium-fg:#0f172a;--atrium-muted:#475569;--atrium-line:#e2e8f0;--atrium-field:#8391a5;--atrium-accent:#4f46e5;--atrium-accent-hover:#4338ca;--atrium-on-accent:#fff;--atrium-accent-soft:#e0e7ff;--atrium-accent-soft-fg:#3730a3;--atrium-focus:#4f46e5;--atrium-off:#f1f5f9;--atrium-off-fg:#334155;--atrium-badge-line:transparent;--atrium-danger:#c81e1e;--atrium-danger-hover:#991b1b;--atrium-on-danger:#fff;--atrium-danger-soft:#fee2e2;--atrium-danger-soft-fg:#991b1b;--atrium-success:#15803d;--atrium-success-soft:#dcfce7;--atrium-success-soft-fg:#166534;--atrium-warning-soft:#fef3c7;--atrium-warning-soft-fg:#92400e;--atrium-mark:#0f172a;--atrium-mark-accent:#4f46e5}[data-theme=night]{--lightningcss-light: ;--lightningcss-dark:initial;color-scheme:dark;--atrium-sidebar:#0a0e14;--atrium-sidebar-fg:#e6eaf0;--atrium-sidebar-muted:#8b95a5;--atrium-sidebar-hover:#141b26;--atrium-sidebar-active:#1a2230;--atrium-sidebar-active-fg:#fff;--atrium-sidebar-accent:#8ab4ff;--atrium-sidebar-line:#1a2230;--atrium-page:#0f141b;--atrium-surface:#161d27;--atrium-surface-alt:#121821;--atrium-hover:#1f2733;--atrium-fg:#e6eaf0;--atrium-muted:#a0aaba;--atrium-line:#253041;--atrium-field:#5f6d82;--atrium-accent:#8ab4ff;--atrium-accent-hover:#b0ccff;--atrium-on-accent:#0a0e14;--atrium-accent-soft:#1e2f4d;--atrium-accent-soft-fg:#b9d1ff;--atrium-focus:#8ab4ff;--atrium-off:#222b38;--atrium-off-fg:#c3cbd6;--atrium-badge-line:transparent;--atrium-danger:#ff8a8a;--atrium-danger-hover:#ffb0b0;--atrium-on-danger:#0a0e14;--atrium-danger-soft:#3d1c22;--atrium-danger-soft-fg:#ffc2c2;--atrium-success:#5fd38d;--atrium-success-soft:#173524;--atrium-success-soft-fg:#a6ebc0;--atrium-warning-soft:#3a2e12;--atrium-warning-soft-fg:#fcd98a;--atrium-mark:#fff;--atrium-mark-accent:#8ab4ff}[data-theme=sand]{--lightningcss-light:initial;--lightningcss-dark: ;color-scheme:light;--atrium-sidebar:#1f1a14;--atrium-sidebar-fg:#f5efe6;--atrium-sidebar-muted:#b3a796;--atrium-sidebar-hover:#2b241c;--atrium-sidebar-active:#342b21;--atrium-sidebar-active-fg:#fff;--atrium-sidebar-accent:#f2a65a;--atrium-sidebar-line:#342b21;--atrium-page:#f7f3ec;--atrium-surface:#fff;--atrium-surface-alt:#fbf8f3;--atrium-hover:#f1ece4;--atrium-fg:#1f1a14;--atrium-muted:#5c5246;--atrium-line:#e7dfd2;--atrium-field:#958672;--atrium-accent:#a6490a;--atrium-accent-hover:#853a07;--atrium-on-accent:#fff;--atrium-accent-soft:#fce7d2;--atrium-accent-soft-fg:#7a3506;--atrium-focus:#a6490a;--atrium-off:#f1ece4;--atrium-off-fg:#4a4137;--atrium-badge-line:transparent;--atrium-danger:#b42318;--atrium-danger-hover:#912018;--atrium-on-danger:#fff;--atrium-danger-soft:#fde4e1;--atrium-danger-soft-fg:#8a1c12;--atrium-success:#2e7d32;--atrium-success-soft:#e3f2df;--atrium-success-soft-fg:#1f5a23;--atrium-warning-soft:#fbefc5;--atrium-warning-soft-fg:#7a4a06;--atrium-mark:#f5efe6;--atrium-mark-accent:#f2a65a}[data-theme=contrast]{--lightningcss-light:initial;--lightningcss-dark: ;color-scheme:light;--atrium-sidebar:#000;--atrium-sidebar-fg:#fff;--atrium-sidebar-muted:#d4d4d4;--atrium-sidebar-hover:#262626;--atrium-sidebar-active:#ffd400;--atrium-sidebar-active-fg:#000;--atrium-sidebar-accent:#ffd400;--atrium-sidebar-line:#fff;--atrium-page:#fff;--atrium-surface:#fff;--atrium-surface-alt:#fff;--atrium-hover:#fff2a8;--atrium-fg:#000;--atrium-muted:#262626;--atrium-line:#000;--atrium-field:#000;--atrium-accent:#0033a0;--atrium-accent-hover:#001f66;--atrium-on-accent:#fff;--atrium-accent-soft:#ffd400;--atrium-accent-soft-fg:#000;--atrium-focus:#0033a0;--atrium-off:#fff;--atrium-off-fg:#000;--atrium-badge-line:#000;--atrium-danger:#b00020;--atrium-danger-hover:#7a0016;--atrium-on-danger:#fff;--atrium-danger-soft:#ffe0e0;--atrium-danger-soft-fg:#7a0016;--atrium-success:#006b2d;--atrium-success-soft:#d9f5e3;--atrium-success-soft-fg:#003d1a;--atrium-warning-soft:#ffd400;--atrium-warning-soft-fg:#000;--atrium-mark:#fff;--atrium-mark-accent:#ffd400}[data-theme=contrast] .border{border-width:2px}[data-theme=contrast] .border-t{border-top-width:2px}[data-theme=contrast] .border-b{border-bottom-width:2px}[data-theme=contrast] .border-l{border-left-width:2px}[data-theme=contrast] .border-r{border-right-width:2px}[data-theme=contrast] .divide-y>:not(:last-child){border-bottom-width:2px}[data-credit]{--atrium-credit-logo:url(/vendor/atrium/assets/logo-DDS3n-zU.svg)}:where([data-theme=graphite],[data-theme=night],[data-theme=sand],[data-theme=contrast]) [data-credit-on=sidebar],:where([data-theme=night]) [data-credit-on=page]{--atrium-credit-logo:url(/vendor/atrium/assets/logo-white-BqJt87jq.svg)}select:not([multiple]):not([size]){padding-right:2rem}@property --tw-border-spacing-x{syntax:"";inherits:false;initial-value:0}@property --tw-border-spacing-y{syntax:"";inherits:false;initial-value:0}@property --tw-translate-x{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-y{syntax:"*";inherits:false;initial-value:0}@property --tw-translate-z{syntax:"*";inherits:false;initial-value:0}@property --tw-scale-x{syntax:"*";inherits:false;initial-value:1}@property --tw-scale-y{syntax:"*";inherits:false;initial-value:1}@property --tw-scale-z{syntax:"*";inherits:false;initial-value:1}@property --tw-rotate-x{syntax:"*";inherits:false}@property --tw-rotate-y{syntax:"*";inherits:false}@property --tw-rotate-z{syntax:"*";inherits:false}@property --tw-skew-x{syntax:"*";inherits:false}@property --tw-skew-y{syntax:"*";inherits:false}@property --tw-space-y-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-space-x-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-divide-y-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-leading{syntax:"*";inherits:false}@property --tw-font-weight{syntax:"*";inherits:false}@property --tw-tracking{syntax:"*";inherits:false}@property --tw-ordinal{syntax:"*";inherits:false}@property --tw-slashed-zero{syntax:"*";inherits:false}@property --tw-numeric-figure{syntax:"*";inherits:false}@property --tw-numeric-spacing{syntax:"*";inherits:false}@property --tw-numeric-fraction{syntax:"*";inherits:false}@property --tw-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:"*";inherits:false}@property --tw-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:"*";inherits:false}@property --tw-inset-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:"*";inherits:false}@property --tw-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:"*";inherits:false}@property --tw-inset-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:"*";inherits:false}@property --tw-ring-offset-width{syntax:"";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:"*";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-outline-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-blur{syntax:"*";inherits:false}@property --tw-brightness{syntax:"*";inherits:false}@property --tw-contrast{syntax:"*";inherits:false}@property --tw-grayscale{syntax:"*";inherits:false}@property --tw-hue-rotate{syntax:"*";inherits:false}@property --tw-invert{syntax:"*";inherits:false}@property --tw-opacity{syntax:"*";inherits:false}@property --tw-saturate{syntax:"*";inherits:false}@property --tw-sepia{syntax:"*";inherits:false}@property --tw-drop-shadow{syntax:"*";inherits:false}@property --tw-drop-shadow-color{syntax:"*";inherits:false}@property --tw-drop-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-drop-shadow-size{syntax:"*";inherits:false}@property --tw-duration{syntax:"*";inherits:false}@property --tw-ease{syntax:"*";inherits:false}@keyframes spin{to{transform:rotate(360deg)}} diff --git a/packages/admin/dist/assets/contentLocale-BtGD-iBF.js b/packages/admin/dist/assets/contentLocale-BV_E0iGS.js similarity index 89% rename from packages/admin/dist/assets/contentLocale-BtGD-iBF.js rename to packages/admin/dist/assets/contentLocale-BV_E0iGS.js index 65b78af3..a9721c8d 100644 --- a/packages/admin/dist/assets/contentLocale-BtGD-iBF.js +++ b/packages/admin/dist/assets/contentLocale-BV_E0iGS.js @@ -1 +1 @@ -import{L as e,Y as t,b as n,o as r}from"./dist-MY__znoP.js";function i(i){let a=n(()=>r().props.contentLocales||[]),o=a.value.find(e=>e.default)||a.value[0],s=t(o?o.code:null);return e(`contentLocale`,s),{locale:s,locales:a,showSwitcher:n(()=>a.value.length>1&&i().some(e=>e.translatable))}}function a(e,t){if(!e.translatable)return t??e.default??``;let n=r().props.contentLocales||[],i=t&&typeof t==`object`&&!Array.isArray(t)?t:{},a={};return n.forEach(t=>{a[t.code]=i[t.code]??(t.default?e.default??``:``)}),a}function o(e,t){return Object.keys(e).some(e=>e===t.name||e.startsWith(`${t.name}.`))}export{a as n,i as r,o as t}; \ No newline at end of file +import{L as e,X as t,b as n,o as r}from"./dist-Bie52OmN.js";function i(i){let a=n(()=>r().props.contentLocales||[]),o=a.value.find(e=>e.default)||a.value[0],s=t(o?o.code:null);return e(`contentLocale`,s),{locale:s,locales:a,showSwitcher:n(()=>a.value.length>1&&i().some(e=>e.translatable))}}function a(e,t){if(!e.translatable)return t??e.default??``;let n=r().props.contentLocales||[],i=t&&typeof t==`object`&&!Array.isArray(t)?t:{},a={};return n.forEach(t=>{a[t.code]=i[t.code]??(t.default?e.default??``:``)}),a}function o(e,t){return Object.keys(e).some(e=>e===t.name||e.startsWith(`${t.name}.`))}export{a as n,i as r,o as t}; \ No newline at end of file diff --git a/packages/admin/dist/assets/dist-MY__znoP.js b/packages/admin/dist/assets/dist-Bie52OmN.js similarity index 99% rename from packages/admin/dist/assets/dist-MY__znoP.js rename to packages/admin/dist/assets/dist-Bie52OmN.js index 8a83df54..beeff8d9 100644 --- a/packages/admin/dist/assets/dist-MY__znoP.js +++ b/packages/admin/dist/assets/dist-Bie52OmN.js @@ -89,4 +89,4 @@ function e(e){let t=Object.create(null);for(let n of e.split(`,`))t[n]=1;return 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } } - `,document.head.appendChild(t)},$p={configure:zp,isStarted:Vp,done:Up,set:Bp,remove:qp,start:Hp,status:Lp,show:()=>{if(Rp=!1,Z?.isConnected){if(Fp)try{Z.showPopover()}catch{}else Z.style.display=``}},hide:()=>{if(Rp=!0,Z?.isConnected){if(Fp)try{Z.hidePopover()}catch{}else Z.style.display=`none`}}},em=new class{hideCount=0;start(){$p.start()}reveal(e=!1){this.hideCount=Math.max(0,this.hideCount-1),(e||this.hideCount===0)&&$p.show()}hide(){this.hideCount++,$p.hide()}set(e){$p.set(Math.max(0,Math.min(1,e)))}finish(){$p.done()}reset(){$p.set(0)}remove(){$p.done(),$p.remove()}isStarted(){return $p.isStarted()}getStatus(){return $p.status}};function tm(e){document.addEventListener(`inertia:start`,t=>nm(t,e)),document.addEventListener(`inertia:progress`,rm)}function nm(e,t){e.detail.visit.showProgress||em.hide();let n=setTimeout(()=>em.start(),t);document.addEventListener(`inertia:finish`,e=>im(e,n),{once:!0})}function rm(e){em.isStarted()&&e.detail.progress?.percentage&&em.set(Math.max(em.getStatus(),e.detail.progress.percentage/100*.9))}function im(e,t){clearTimeout(t),em.isStarted()&&(e.detail.visit.completed?em.finish():e.detail.visit.interrupted?em.reset():e.detail.visit.cancelled&&em.remove())}function am({delay:e=250,color:t=`#29d`,includeCSS:n=!0,showSpinner:r=!1,popover:i=null}={}){tm(e),$p.configure({showSpinner:r,includeCSS:n,color:t,popover:i})}function om(e,t,n){return`