From c40208295dafc9ed9cb20d46a0aee99da3779624 Mon Sep 17 00:00:00 2001 From: Malik Alleyne-Jones Date: Sun, 31 May 2026 15:54:35 -0400 Subject: [PATCH] Add a TipTap formatting toolbar to the comment editor Adds a configurable formatting toolbar above the comment editor with bold, italic, underline, strike, heading, list, code, blockquote and link buttons. Buttons are configured globally via the `toolbar` config key (a flat list, or grouped into arrays for visual separators) and can be overridden per component with ->toolbarButtons(), or disabled entirely. Because the toolbar lets users produce richer HTML (notably links), comment bodies are now sanitized server-side via symfony/html-sanitizer against an allowlist matching exactly what the editor can emit. Links are restricted to http/https/mailto schemes and forced to rel="noopener noreferrer" on both the client and the server to close the reverse-tabnabbing vector. Toolbar and link-prompt strings are translatable. --- README.md | 44 +++++++ composer.json | 1 + config/commentions.php | 24 ++++ package-lock.json | 38 +++++++ package.json | 2 + resources/css/commentions.css | 36 ++++++ resources/dist/commentions.css | 2 +- resources/dist/commentions.js | 42 +++---- resources/js/commentions.js | 89 ++++++++++++++- resources/lang/en/comments.php | 18 +++ resources/views/comment-list.blade.php | 1 + resources/views/comment.blade.php | 3 +- resources/views/comments-modal.blade.php | 1 + resources/views/comments.blade.php | 4 +- .../components/comments-entry.blade.php | 1 + resources/views/partials/toolbar.blade.php | 64 +++++++++++ src/Actions/SanitizeCommentHtml.php | 57 ++++++++++ src/Comment.php | 8 ++ src/Config.php | 52 ++++++++- src/Filament/Actions/CommentsAction.php | 3 + src/Filament/Actions/CommentsTableAction.php | 3 + src/Filament/Concerns/HasToolbar.php | 38 +++++++ .../Infolists/Components/CommentsEntry.php | 2 + src/Livewire/Comment.php | 2 + src/Livewire/CommentList.php | 2 + src/Livewire/Comments.php | 2 + src/Livewire/Concerns/HasToolbarButtons.php | 28 +++++ tests/Livewire/CommentToolbarTest.php | 107 ++++++++++++++++++ tests/SanitizeCommentHtmlTest.php | 101 +++++++++++++++++ 29 files changed, 749 insertions(+), 26 deletions(-) create mode 100644 resources/views/partials/toolbar.blade.php create mode 100644 src/Actions/SanitizeCommentHtml.php create mode 100644 src/Filament/Concerns/HasToolbar.php create mode 100644 src/Livewire/Concerns/HasToolbarButtons.php create mode 100644 tests/Livewire/CommentToolbarTest.php create mode 100644 tests/SanitizeCommentHtmlTest.php diff --git a/README.md b/README.md index 354711c..dfb8368 100644 --- a/README.md +++ b/README.md @@ -430,6 +430,50 @@ CommentsAction::make() **Important**: Make sure to whitelist the classes in your Tailwind config if you override them. +### Editor toolbar + +The comment editor shows a formatting toolbar above the input. The available buttons are: + +`bold`, `italic`, `underline`, `strike`, `h1`, `h2`, `h3`, `blockquote`, `bulletList`, `orderedList`, `code`, `link`. + +You can configure which buttons appear globally via the `toolbar` option in your `config/commentions.php` file. Buttons may be a flat list, or grouped into arrays to render visual separators between groups: + +```php + 'toolbar' => [ + 'enabled' => env('COMMENTIONS_TOOLBAR_ENABLED', true), + + 'buttons' => [ + ['bold', 'italic', 'underline'], + ['bulletList', 'orderedList'], + ['link'], + ], + ], +``` + +To hide the toolbar entirely, set `enabled` to `false` (or set `COMMENTIONS_TOOLBAR_ENABLED=false` in your `.env`). + +You can also override the buttons on a per-component basis using the `toolbarButtons()` method: + +```php +use Kirschbaum\Commentions\Filament\Infolists\Components\CommentsEntry; + +CommentsEntry::make('comments') + ->mentionables(fn (Model $record) => User::all()) + ->toolbarButtons([['bold', 'italic'], ['link']]) +``` + +Or with actions: + +```php +use Kirschbaum\Commentions\Filament\Actions\CommentsAction; + +CommentsAction::make() + ->mentionables(User::all()) + ->toolbarButtons(['bold', 'italic', 'link']) +``` + +Pass an empty array (`->toolbarButtons([])`) to hide the toolbar for a single component. + ### Translations You can publish the package translation files and override any strings used by the UI. diff --git a/composer.json b/composer.json index 9b3089d..5a297f3 100644 --- a/composer.json +++ b/composer.json @@ -23,6 +23,7 @@ "require": { "spatie/laravel-package-tools": "^1.18", "league/html-to-markdown": "^5.1", + "symfony/html-sanitizer": "^7.0|^8.0", "illuminate/support": "^11.0|^12.0|^13.0", "illuminate/database": "^11.0|^12.0|^13.0", "livewire/livewire": "^3.5|^4.0", diff --git a/config/commentions.php b/config/commentions.php index 4267451..d3efb98 100644 --- a/config/commentions.php +++ b/config/commentions.php @@ -46,6 +46,30 @@ 'allowed' => ['👍', '❤️', '😂', '😮', '😢', '🤔'], ], + /* + |-------------------------------------------------------------------------- + | Editor toolbar + |-------------------------------------------------------------------------- + | + | The formatting toolbar shown above the comment editor. Set `enabled` to + | false to hide it globally, or override the buttons per component with + | CommentsEntry::make()->toolbarButtons([...]). Buttons may be a flat list + | or grouped into arrays to render visual separators between groups. + | + | Available buttons: bold, italic, underline, strike, h1, h2, h3, + | blockquote, bulletList, orderedList, code, link. + | + */ + 'toolbar' => [ + 'enabled' => env('COMMENTIONS_TOOLBAR_ENABLED', true), + + 'buttons' => [ + ['bold', 'italic', 'underline'], + ['bulletList', 'orderedList'], + ['link'], + ], + ], + /* |-------------------------------------------------------------------------- | Subscriptions diff --git a/package-lock.json b/package-lock.json index 831552b..b99206a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,8 +8,10 @@ "dependencies": { "@tailwindcss/cli": "^4.0.6", "@tiptap/core": "^2.11.2", + "@tiptap/extension-link": "^2.27.2", "@tiptap/extension-mention": "^2.11.2", "@tiptap/extension-placeholder": "^2.11.2", + "@tiptap/extension-underline": "^2.27.2", "@tiptap/pm": "^2.11.2", "@tiptap/starter-kit": "^2.11.2", "@tiptap/suggestion": "^2.11.2", @@ -1145,6 +1147,23 @@ "@tiptap/core": "^2.7.0" } }, + "node_modules/@tiptap/extension-link": { + "version": "2.27.2", + "resolved": "https://registry.npmjs.org/@tiptap/extension-link/-/extension-link-2.27.2.tgz", + "integrity": "sha512-bnP61qkr0Kj9Cgnop1hxn2zbOCBzNtmawxr92bVTOE31fJv6FhtCnQiD6tuPQVGMYhcmAj7eihtvuEMFfqEPcQ==", + "license": "MIT", + "dependencies": { + "linkifyjs": "^4.3.2" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/ueberdosis" + }, + "peerDependencies": { + "@tiptap/core": "^2.7.0", + "@tiptap/pm": "^2.7.0" + } + }, "node_modules/@tiptap/extension-list-item": { "version": "2.11.2", "resolved": "https://registry.npmjs.org/@tiptap/extension-list-item/-/extension-list-item-2.11.2.tgz", @@ -1252,6 +1271,19 @@ "@tiptap/core": "^2.7.0" } }, + "node_modules/@tiptap/extension-underline": { + "version": "2.27.2", + "resolved": "https://registry.npmjs.org/@tiptap/extension-underline/-/extension-underline-2.27.2.tgz", + "integrity": "sha512-gPOsbAcw1S07ezpAISwoO8f0RxpjcSH7VsHEFDVuXm4ODE32nhvSinvHQjv2icRLOXev+bnA7oIBu7Oy859gWQ==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/ueberdosis" + }, + "peerDependencies": { + "@tiptap/core": "^2.7.0" + } + }, "node_modules/@tiptap/pm": { "version": "2.11.2", "resolved": "https://registry.npmjs.org/@tiptap/pm/-/pm-2.11.2.tgz", @@ -2803,6 +2835,12 @@ "uc.micro": "^2.0.0" } }, + "node_modules/linkifyjs": { + "version": "4.3.3", + "resolved": "https://registry.npmjs.org/linkifyjs/-/linkifyjs-4.3.3.tgz", + "integrity": "sha512-P8aEP5U/D1/IlTY2OeYsErdwh9bGuLE30NcXtKEjgdHcahveQoQwM2yZNsioQHsWFz0P7KKudisbrzCgR0sDHg==", + "license": "MIT" + }, "node_modules/load-json-file": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-4.0.0.tgz", diff --git a/package.json b/package.json index 6e28a02..315d6e5 100644 --- a/package.json +++ b/package.json @@ -12,8 +12,10 @@ "dependencies": { "@tailwindcss/cli": "^4.0.6", "@tiptap/core": "^2.11.2", + "@tiptap/extension-link": "^2.27.2", "@tiptap/extension-mention": "^2.11.2", "@tiptap/extension-placeholder": "^2.11.2", + "@tiptap/extension-underline": "^2.27.2", "@tiptap/pm": "^2.11.2", "@tiptap/starter-kit": "^2.11.2", "@tiptap/suggestion": "^2.11.2", diff --git a/resources/css/commentions.css b/resources/css/commentions.css index 695c00d..01c45de 100644 --- a/resources/css/commentions.css +++ b/resources/css/commentions.css @@ -44,3 +44,39 @@ .mention-item:hover { @apply comm:bg-gray-100; } + +.tip-tap-container { + @apply comm:rounded-lg comm:border comm:border-gray-300 comm:dark:border-gray-700 comm:bg-white comm:dark:bg-gray-900 comm:overflow-hidden comm:focus-within:ring-2 comm:focus-within:ring-blue-500/50 comm:focus-within:border-blue-500; +} + +.commentions-toolbar { + @apply comm:flex comm:flex-wrap comm:items-center comm:gap-1 comm:p-1 comm:border-b comm:border-gray-300 comm:dark:border-gray-700 comm:bg-gray-50 comm:dark:bg-gray-800; +} + +.commentions-toolbar-group { + @apply comm:flex comm:items-center comm:gap-0.5; +} + +.commentions-toolbar-group:not(:last-child) { + @apply comm:pr-1 comm:mr-1 comm:border-r comm:border-gray-300 comm:dark:border-gray-700; +} + +.commentions-toolbar-button { + @apply comm:flex comm:items-center comm:justify-center comm:p-1.5 comm:rounded comm:text-gray-600 comm:dark:text-gray-300 comm:cursor-pointer; +} + +.commentions-toolbar-button:hover { + @apply comm:bg-gray-200 comm:dark:bg-gray-700; +} + +.commentions-toolbar-button:focus-visible { + @apply comm:bg-gray-200 comm:dark:bg-gray-700 comm:outline-none; +} + +.commentions-toolbar-button-active { + @apply comm:bg-gray-200 comm:dark:bg-gray-700 comm:text-blue-600 comm:dark:text-blue-400; +} + +.tiptap a.comm-link { + @apply comm:text-blue-600 comm:dark:text-blue-400 comm:underline; +} diff --git a/resources/dist/commentions.css b/resources/dist/commentions.css index 1807ccf..5bbe670 100644 --- a/resources/dist/commentions.css +++ b/resources/dist/commentions.css @@ -1,2 +1,2 @@ /*! tailwindcss v4.0.6 | MIT License | https://tailwindcss.com */ -@layer theme{:root,:host{--comm-font-sans:ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";--comm-font-serif:ui-serif,Georgia,Cambria,"Times New Roman",Times,serif;--comm-font-mono:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;--comm-color-red-50:oklch(.971 .013 17.38);--comm-color-red-100:oklch(.936 .032 17.717);--comm-color-red-200:oklch(.885 .062 18.334);--comm-color-red-300:oklch(.808 .114 19.571);--comm-color-red-400:oklch(.704 .191 22.216);--comm-color-red-500:oklch(.637 .237 25.331);--comm-color-red-600:oklch(.577 .245 27.325);--comm-color-red-700:oklch(.505 .213 27.518);--comm-color-red-800:oklch(.444 .177 26.899);--comm-color-red-900:oklch(.396 .141 25.723);--comm-color-red-950:oklch(.258 .092 26.042);--comm-color-orange-50:oklch(.98 .016 73.684);--comm-color-orange-100:oklch(.954 .038 75.164);--comm-color-orange-200:oklch(.901 .076 70.697);--comm-color-orange-300:oklch(.837 .128 66.29);--comm-color-orange-400:oklch(.75 .183 55.934);--comm-color-orange-500:oklch(.705 .213 47.604);--comm-color-orange-600:oklch(.646 .222 41.116);--comm-color-orange-700:oklch(.553 .195 38.402);--comm-color-orange-800:oklch(.47 .157 37.304);--comm-color-orange-900:oklch(.408 .123 38.172);--comm-color-orange-950:oklch(.266 .079 36.259);--comm-color-amber-50:oklch(.987 .022 95.277);--comm-color-amber-100:oklch(.962 .059 95.617);--comm-color-amber-200:oklch(.924 .12 95.746);--comm-color-amber-300:oklch(.879 .169 91.605);--comm-color-amber-400:oklch(.828 .189 84.429);--comm-color-amber-500:oklch(.769 .188 70.08);--comm-color-amber-600:oklch(.666 .179 58.318);--comm-color-amber-700:oklch(.555 .163 48.998);--comm-color-amber-800:oklch(.473 .137 46.201);--comm-color-amber-900:oklch(.414 .112 45.904);--comm-color-amber-950:oklch(.279 .077 45.635);--comm-color-yellow-50:oklch(.987 .026 102.212);--comm-color-yellow-100:oklch(.973 .071 103.193);--comm-color-yellow-200:oklch(.945 .129 101.54);--comm-color-yellow-300:oklch(.905 .182 98.111);--comm-color-yellow-400:oklch(.852 .199 91.936);--comm-color-yellow-500:oklch(.795 .184 86.047);--comm-color-yellow-600:oklch(.681 .162 75.834);--comm-color-yellow-700:oklch(.554 .135 66.442);--comm-color-yellow-800:oklch(.476 .114 61.907);--comm-color-yellow-900:oklch(.421 .095 57.708);--comm-color-yellow-950:oklch(.286 .066 53.813);--comm-color-lime-50:oklch(.986 .031 120.757);--comm-color-lime-100:oklch(.967 .067 122.328);--comm-color-lime-200:oklch(.938 .127 124.321);--comm-color-lime-300:oklch(.897 .196 126.665);--comm-color-lime-400:oklch(.841 .238 128.85);--comm-color-lime-500:oklch(.768 .233 130.85);--comm-color-lime-600:oklch(.648 .2 131.684);--comm-color-lime-700:oklch(.532 .157 131.589);--comm-color-lime-800:oklch(.453 .124 130.933);--comm-color-lime-900:oklch(.405 .101 131.063);--comm-color-lime-950:oklch(.274 .072 132.109);--comm-color-green-50:oklch(.982 .018 155.826);--comm-color-green-100:oklch(.962 .044 156.743);--comm-color-green-200:oklch(.925 .084 155.995);--comm-color-green-300:oklch(.871 .15 154.449);--comm-color-green-400:oklch(.792 .209 151.711);--comm-color-green-500:oklch(.723 .219 149.579);--comm-color-green-600:oklch(.627 .194 149.214);--comm-color-green-700:oklch(.527 .154 150.069);--comm-color-green-800:oklch(.448 .119 151.328);--comm-color-green-900:oklch(.393 .095 152.535);--comm-color-green-950:oklch(.266 .065 152.934);--comm-color-emerald-50:oklch(.979 .021 166.113);--comm-color-emerald-100:oklch(.95 .052 163.051);--comm-color-emerald-200:oklch(.905 .093 164.15);--comm-color-emerald-300:oklch(.845 .143 164.978);--comm-color-emerald-400:oklch(.765 .177 163.223);--comm-color-emerald-500:oklch(.696 .17 162.48);--comm-color-emerald-600:oklch(.596 .145 163.225);--comm-color-emerald-700:oklch(.508 .118 165.612);--comm-color-emerald-800:oklch(.432 .095 166.913);--comm-color-emerald-900:oklch(.378 .077 168.94);--comm-color-emerald-950:oklch(.262 .051 172.552);--comm-color-teal-50:oklch(.984 .014 180.72);--comm-color-teal-100:oklch(.953 .051 180.801);--comm-color-teal-200:oklch(.91 .096 180.426);--comm-color-teal-300:oklch(.855 .138 181.071);--comm-color-teal-400:oklch(.777 .152 181.912);--comm-color-teal-500:oklch(.704 .14 182.503);--comm-color-teal-600:oklch(.6 .118 184.704);--comm-color-teal-700:oklch(.511 .096 186.391);--comm-color-teal-800:oklch(.437 .078 188.216);--comm-color-teal-900:oklch(.386 .063 188.416);--comm-color-teal-950:oklch(.277 .046 192.524);--comm-color-cyan-50:oklch(.984 .019 200.873);--comm-color-cyan-100:oklch(.956 .045 203.388);--comm-color-cyan-200:oklch(.917 .08 205.041);--comm-color-cyan-300:oklch(.865 .127 207.078);--comm-color-cyan-400:oklch(.789 .154 211.53);--comm-color-cyan-500:oklch(.715 .143 215.221);--comm-color-cyan-600:oklch(.609 .126 221.723);--comm-color-cyan-700:oklch(.52 .105 223.128);--comm-color-cyan-800:oklch(.45 .085 224.283);--comm-color-cyan-900:oklch(.398 .07 227.392);--comm-color-cyan-950:oklch(.302 .056 229.695);--comm-color-sky-50:oklch(.977 .013 236.62);--comm-color-sky-100:oklch(.951 .026 236.824);--comm-color-sky-200:oklch(.901 .058 230.902);--comm-color-sky-300:oklch(.828 .111 230.318);--comm-color-sky-400:oklch(.746 .16 232.661);--comm-color-sky-500:oklch(.685 .169 237.323);--comm-color-sky-600:oklch(.588 .158 241.966);--comm-color-sky-700:oklch(.5 .134 242.749);--comm-color-sky-800:oklch(.443 .11 240.79);--comm-color-sky-900:oklch(.391 .09 240.876);--comm-color-sky-950:oklch(.293 .066 243.157);--comm-color-blue-50:oklch(.97 .014 254.604);--comm-color-blue-100:oklch(.932 .032 255.585);--comm-color-blue-200:oklch(.882 .059 254.128);--comm-color-blue-300:oklch(.809 .105 251.813);--comm-color-blue-400:oklch(.707 .165 254.624);--comm-color-blue-500:oklch(.623 .214 259.815);--comm-color-blue-600:oklch(.546 .245 262.881);--comm-color-blue-700:oklch(.488 .243 264.376);--comm-color-blue-800:oklch(.424 .199 265.638);--comm-color-blue-900:oklch(.379 .146 265.522);--comm-color-blue-950:oklch(.282 .091 267.935);--comm-color-indigo-50:oklch(.962 .018 272.314);--comm-color-indigo-100:oklch(.93 .034 272.788);--comm-color-indigo-200:oklch(.87 .065 274.039);--comm-color-indigo-300:oklch(.785 .115 274.713);--comm-color-indigo-400:oklch(.673 .182 276.935);--comm-color-indigo-500:oklch(.585 .233 277.117);--comm-color-indigo-600:oklch(.511 .262 276.966);--comm-color-indigo-700:oklch(.457 .24 277.023);--comm-color-indigo-800:oklch(.398 .195 277.366);--comm-color-indigo-900:oklch(.359 .144 278.697);--comm-color-indigo-950:oklch(.257 .09 281.288);--comm-color-violet-50:oklch(.969 .016 293.756);--comm-color-violet-100:oklch(.943 .029 294.588);--comm-color-violet-200:oklch(.894 .057 293.283);--comm-color-violet-300:oklch(.811 .111 293.571);--comm-color-violet-400:oklch(.702 .183 293.541);--comm-color-violet-500:oklch(.606 .25 292.717);--comm-color-violet-600:oklch(.541 .281 293.009);--comm-color-violet-700:oklch(.491 .27 292.581);--comm-color-violet-800:oklch(.432 .232 292.759);--comm-color-violet-900:oklch(.38 .189 293.745);--comm-color-violet-950:oklch(.283 .141 291.089);--comm-color-purple-50:oklch(.977 .014 308.299);--comm-color-purple-100:oklch(.946 .033 307.174);--comm-color-purple-200:oklch(.902 .063 306.703);--comm-color-purple-300:oklch(.827 .119 306.383);--comm-color-purple-400:oklch(.714 .203 305.504);--comm-color-purple-500:oklch(.627 .265 303.9);--comm-color-purple-600:oklch(.558 .288 302.321);--comm-color-purple-700:oklch(.496 .265 301.924);--comm-color-purple-800:oklch(.438 .218 303.724);--comm-color-purple-900:oklch(.381 .176 304.987);--comm-color-purple-950:oklch(.291 .149 302.717);--comm-color-fuchsia-50:oklch(.977 .017 320.058);--comm-color-fuchsia-100:oklch(.952 .037 318.852);--comm-color-fuchsia-200:oklch(.903 .076 319.62);--comm-color-fuchsia-300:oklch(.833 .145 321.434);--comm-color-fuchsia-400:oklch(.74 .238 322.16);--comm-color-fuchsia-500:oklch(.667 .295 322.15);--comm-color-fuchsia-600:oklch(.591 .293 322.896);--comm-color-fuchsia-700:oklch(.518 .253 323.949);--comm-color-fuchsia-800:oklch(.452 .211 324.591);--comm-color-fuchsia-900:oklch(.401 .17 325.612);--comm-color-fuchsia-950:oklch(.293 .136 325.661);--comm-color-pink-50:oklch(.971 .014 343.198);--comm-color-pink-100:oklch(.948 .028 342.258);--comm-color-pink-200:oklch(.899 .061 343.231);--comm-color-pink-300:oklch(.823 .12 346.018);--comm-color-pink-400:oklch(.718 .202 349.761);--comm-color-pink-500:oklch(.656 .241 354.308);--comm-color-pink-600:oklch(.592 .249 .584);--comm-color-pink-700:oklch(.525 .223 3.958);--comm-color-pink-800:oklch(.459 .187 3.815);--comm-color-pink-900:oklch(.408 .153 2.432);--comm-color-pink-950:oklch(.284 .109 3.907);--comm-color-rose-50:oklch(.969 .015 12.422);--comm-color-rose-100:oklch(.941 .03 12.58);--comm-color-rose-200:oklch(.892 .058 10.001);--comm-color-rose-300:oklch(.81 .117 11.638);--comm-color-rose-400:oklch(.712 .194 13.428);--comm-color-rose-500:oklch(.645 .246 16.439);--comm-color-rose-600:oklch(.586 .253 17.585);--comm-color-rose-700:oklch(.514 .222 16.935);--comm-color-rose-800:oklch(.455 .188 13.697);--comm-color-rose-900:oklch(.41 .159 10.272);--comm-color-rose-950:oklch(.271 .105 12.094);--comm-color-slate-50:oklch(.984 .003 247.858);--comm-color-slate-100:oklch(.968 .007 247.896);--comm-color-slate-200:oklch(.929 .013 255.508);--comm-color-slate-300:oklch(.869 .022 252.894);--comm-color-slate-400:oklch(.704 .04 256.788);--comm-color-slate-500:oklch(.554 .046 257.417);--comm-color-slate-600:oklch(.446 .043 257.281);--comm-color-slate-700:oklch(.372 .044 257.287);--comm-color-slate-800:oklch(.279 .041 260.031);--comm-color-slate-900:oklch(.208 .042 265.755);--comm-color-slate-950:oklch(.129 .042 264.695);--comm-color-gray-50:oklch(.985 .002 247.839);--comm-color-gray-100:oklch(.967 .003 264.542);--comm-color-gray-200:oklch(.928 .006 264.531);--comm-color-gray-300:oklch(.872 .01 258.338);--comm-color-gray-400:oklch(.707 .022 261.325);--comm-color-gray-500:oklch(.551 .027 264.364);--comm-color-gray-600:oklch(.446 .03 256.802);--comm-color-gray-700:oklch(.373 .034 259.733);--comm-color-gray-800:oklch(.278 .033 256.848);--comm-color-gray-900:oklch(.21 .034 264.665);--comm-color-gray-950:oklch(.13 .028 261.692);--comm-color-zinc-50:oklch(.985 0 0);--comm-color-zinc-100:oklch(.967 .001 286.375);--comm-color-zinc-200:oklch(.92 .004 286.32);--comm-color-zinc-300:oklch(.871 .006 286.286);--comm-color-zinc-400:oklch(.705 .015 286.067);--comm-color-zinc-500:oklch(.552 .016 285.938);--comm-color-zinc-600:oklch(.442 .017 285.786);--comm-color-zinc-700:oklch(.37 .013 285.805);--comm-color-zinc-800:oklch(.274 .006 286.033);--comm-color-zinc-900:oklch(.21 .006 285.885);--comm-color-zinc-950:oklch(.141 .005 285.823);--comm-color-neutral-50:oklch(.985 0 0);--comm-color-neutral-100:oklch(.97 0 0);--comm-color-neutral-200:oklch(.922 0 0);--comm-color-neutral-300:oklch(.87 0 0);--comm-color-neutral-400:oklch(.708 0 0);--comm-color-neutral-500:oklch(.556 0 0);--comm-color-neutral-600:oklch(.439 0 0);--comm-color-neutral-700:oklch(.371 0 0);--comm-color-neutral-800:oklch(.269 0 0);--comm-color-neutral-900:oklch(.205 0 0);--comm-color-neutral-950:oklch(.145 0 0);--comm-color-stone-50:oklch(.985 .001 106.423);--comm-color-stone-100:oklch(.97 .001 106.424);--comm-color-stone-200:oklch(.923 .003 48.717);--comm-color-stone-300:oklch(.869 .005 56.366);--comm-color-stone-400:oklch(.709 .01 56.259);--comm-color-stone-500:oklch(.553 .013 58.071);--comm-color-stone-600:oklch(.444 .011 73.639);--comm-color-stone-700:oklch(.374 .01 67.558);--comm-color-stone-800:oklch(.268 .007 34.298);--comm-color-stone-900:oklch(.216 .006 56.043);--comm-color-stone-950:oklch(.147 .004 49.25);--comm-color-black:#000;--comm-color-white:#fff;--comm-spacing:.25rem;--comm-breakpoint-sm:40rem;--comm-breakpoint-md:48rem;--comm-breakpoint-lg:64rem;--comm-breakpoint-xl:80rem;--comm-breakpoint-2xl:96rem;--comm-container-3xs:16rem;--comm-container-2xs:18rem;--comm-container-xs:20rem;--comm-container-sm:24rem;--comm-container-md:28rem;--comm-container-lg:32rem;--comm-container-xl:36rem;--comm-container-2xl:42rem;--comm-container-3xl:48rem;--comm-container-4xl:56rem;--comm-container-5xl:64rem;--comm-container-6xl:72rem;--comm-container-7xl:80rem;--comm-text-xs:.75rem;--comm-text-xs--line-height:calc(1/.75);--comm-text-sm:.875rem;--comm-text-sm--line-height:calc(1.25/.875);--comm-text-base:1rem;--comm-text-base--line-height:calc(1.5/1);--comm-text-lg:1.125rem;--comm-text-lg--line-height:calc(1.75/1.125);--comm-text-xl:1.25rem;--comm-text-xl--line-height:calc(1.75/1.25);--comm-text-2xl:1.5rem;--comm-text-2xl--line-height:calc(2/1.5);--comm-text-3xl:1.875rem;--comm-text-3xl--line-height:calc(2.25/1.875);--comm-text-4xl:2.25rem;--comm-text-4xl--line-height:calc(2.5/2.25);--comm-text-5xl:3rem;--comm-text-5xl--line-height:1;--comm-text-6xl:3.75rem;--comm-text-6xl--line-height:1;--comm-text-7xl:4.5rem;--comm-text-7xl--line-height:1;--comm-text-8xl:6rem;--comm-text-8xl--line-height:1;--comm-text-9xl:8rem;--comm-text-9xl--line-height:1;--comm-font-weight-thin:100;--comm-font-weight-extralight:200;--comm-font-weight-light:300;--comm-font-weight-normal:400;--comm-font-weight-medium:500;--comm-font-weight-semibold:600;--comm-font-weight-bold:700;--comm-font-weight-extrabold:800;--comm-font-weight-black:900;--comm-tracking-tighter:-.05em;--comm-tracking-tight:-.025em;--comm-tracking-normal:0em;--comm-tracking-wide:.025em;--comm-tracking-wider:.05em;--comm-tracking-widest:.1em;--comm-leading-tight:1.25;--comm-leading-snug:1.375;--comm-leading-normal:1.5;--comm-leading-relaxed:1.625;--comm-leading-loose:2;--comm-radius-xs:.125rem;--comm-radius-sm:.25rem;--comm-radius-md:.375rem;--comm-radius-lg:.5rem;--comm-radius-xl:.75rem;--comm-radius-2xl:1rem;--comm-radius-3xl:1.5rem;--comm-radius-4xl:2rem;--comm-shadow-2xs:0 1px #0000000d;--comm-shadow-xs:0 1px 2px 0 #0000000d;--comm-shadow-sm:0 1px 3px 0 #0000001a,0 1px 2px -1px #0000001a;--comm-shadow-md:0 4px 6px -1px #0000001a,0 2px 4px -2px #0000001a;--comm-shadow-lg:0 10px 15px -3px #0000001a,0 4px 6px -4px #0000001a;--comm-shadow-xl:0 20px 25px -5px #0000001a,0 8px 10px -6px #0000001a;--comm-shadow-2xl:0 25px 50px -12px #00000040;--comm-inset-shadow-2xs:inset 0 1px #0000000d;--comm-inset-shadow-xs:inset 0 1px 1px #0000000d;--comm-inset-shadow-sm:inset 0 2px 4px #0000000d;--comm-drop-shadow-xs:0 1px 1px #0000000d;--comm-drop-shadow-sm:0 1px 2px #00000026;--comm-drop-shadow-md:0 3px 3px #0000001f;--comm-drop-shadow-lg:0 4px 4px #00000026;--comm-drop-shadow-xl:0 9px 7px #0000001a;--comm-drop-shadow-2xl:0 25px 25px #00000026;--comm-ease-in:cubic-bezier(.4,0,1,1);--comm-ease-out:cubic-bezier(0,0,.2,1);--comm-ease-in-out:cubic-bezier(.4,0,.2,1);--comm-animate-spin:spin 1s linear infinite;--comm-animate-ping:ping 1s cubic-bezier(0,0,.2,1)infinite;--comm-animate-pulse:pulse 2s cubic-bezier(.4,0,.6,1)infinite;--comm-animate-bounce:bounce 1s infinite;--comm-blur-xs:4px;--comm-blur-sm:8px;--comm-blur-md:12px;--comm-blur-lg:16px;--comm-blur-xl:24px;--comm-blur-2xl:40px;--comm-blur-3xl:64px;--comm-perspective-dramatic:100px;--comm-perspective-near:300px;--comm-perspective-normal:500px;--comm-perspective-midrange:800px;--comm-perspective-distant:1200px;--comm-aspect-video:16/9;--comm-default-transition-duration:.15s;--comm-default-transition-timing-function:cubic-bezier(.4,0,.2,1);--comm-default-font-family:var(--font-sans);--comm-default-font-feature-settings:var(--font-sans--font-feature-settings);--comm-default-font-variation-settings:var(--font-sans--font-variation-settings);--comm-default-mono-font-family:var(--font-mono);--comm-default-mono-font-feature-settings:var(--font-mono--font-feature-settings);--comm-default-mono-font-variation-settings:var(--font-mono--font-variation-settings)}}@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,ui-sans-serif,system-ui,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}body{line-height:inherit}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;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{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;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}:-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}}@layer components;@layer utilities{.comm\:absolute{position:absolute!important}.comm\:relative{position:relative!important}.comm\:sticky{position:sticky!important}.comm\:top-4{top:calc(var(--comm-spacing)*4)!important}.comm\:bottom-full{bottom:100%!important}.comm\:z-10{z-index:10!important}.comm\:mt-0\.5{margin-top:calc(var(--comm-spacing)*.5)!important}.comm\:mt-1{margin-top:calc(var(--comm-spacing)*1)!important}.comm\:mt-2{margin-top:calc(var(--comm-spacing)*2)!important}.comm\:mb-2{margin-bottom:calc(var(--comm-spacing)*2)!important}.comm\:mb-3{margin-bottom:calc(var(--comm-spacing)*3)!important}.comm\:ml-1{margin-left:calc(var(--comm-spacing)*1)!important}.comm\:ml-2{margin-left:calc(var(--comm-spacing)*2)!important}.comm\:flex{display:flex!important}.comm\:hidden{display:none!important}.comm\:inline-block{display:inline-block!important}.comm\:inline-flex{display:inline-flex!important}.comm\:h-3{height:calc(var(--comm-spacing)*3)!important}.comm\:h-4{height:calc(var(--comm-spacing)*4)!important}.comm\:h-8{height:calc(var(--comm-spacing)*8)!important}.comm\:h-10{height:calc(var(--comm-spacing)*10)!important}.comm\:h-full{height:100%!important}.comm\:w-3{width:calc(var(--comm-spacing)*3)!important}.comm\:w-4{width:calc(var(--comm-spacing)*4)!important}.comm\:w-8{width:calc(var(--comm-spacing)*8)!important}.comm\:w-10{width:calc(var(--comm-spacing)*10)!important}.comm\:w-48{width:calc(var(--comm-spacing)*48)!important}.comm\:w-full{width:100%!important}.comm\:w-max{width:max-content!important}.comm\:max-w-xs{max-width:var(--comm-container-xs)!important}.comm\:min-w-full{min-width:100%!important}.comm\:flex-1{flex:1!important}.comm\:flex-shrink-0{flex-shrink:0!important}.comm\:flex-col{flex-direction:column!important}.comm\:flex-wrap{flex-wrap:wrap!important}.comm\:items-center{align-items:center!important}.comm\:items-start{align-items:flex-start!important}.comm\:justify-between{justify-content:space-between!important}.comm\:justify-center{justify-content:center!important}.comm\:justify-end{justify-content:flex-end!important}.comm\:gap-1{gap:calc(var(--comm-spacing)*1)!important}.comm\:gap-2{gap:calc(var(--comm-spacing)*2)!important}.comm\:gap-4{gap:calc(var(--comm-spacing)*4)!important}.comm\:gap-x-1{column-gap:calc(var(--comm-spacing)*1)!important}.comm\:gap-x-2{column-gap:calc(var(--comm-spacing)*2)!important}.comm\:gap-x-4{column-gap:calc(var(--comm-spacing)*4)!important}:where(.comm\:space-y-1>:not(:last-child)){--tw-space-y-reverse:0!important;margin-block-start:calc(calc(var(--comm-spacing)*1)*var(--tw-space-y-reverse))!important;margin-block-end:calc(calc(var(--comm-spacing)*1)*calc(1 - var(--tw-space-y-reverse)))!important}:where(.comm\:space-y-2>:not(:last-child)){--tw-space-y-reverse:0!important;margin-block-start:calc(calc(var(--comm-spacing)*2)*var(--tw-space-y-reverse))!important;margin-block-end:calc(calc(var(--comm-spacing)*2)*calc(1 - var(--tw-space-y-reverse)))!important}:where(.comm\:space-y-6>:not(:last-child)){--tw-space-y-reverse:0!important;margin-block-start:calc(calc(var(--comm-spacing)*6)*var(--tw-space-y-reverse))!important;margin-block-end:calc(calc(var(--comm-spacing)*6)*calc(1 - var(--tw-space-y-reverse)))!important}.comm\:gap-y-2{row-gap:calc(var(--comm-spacing)*2)!important}.comm\:truncate{text-overflow:ellipsis!important;white-space:nowrap!important;overflow:hidden!important}.comm\:rounded-full{border-radius:3.40282e38px!important}.comm\:rounded-lg{border-radius:var(--comm-radius-lg)!important}.comm\:rounded-md{border-radius:var(--comm-radius-md)!important}.comm\:border{border-style:var(--tw-border-style)!important;border-width:1px!important}.comm\:border-t{border-top-style:var(--tw-border-style)!important;border-top-width:1px!important}.comm\:border-dashed{--tw-border-style:dashed!important;border-style:dashed!important}.comm\:border-gray-200{border-color:var(--comm-color-gray-200)!important}.comm\:border-gray-300{border-color:var(--comm-color-gray-300)!important}.comm\:bg-blue-100{background-color:var(--comm-color-blue-100)!important}.comm\:bg-gray-50{background-color:var(--comm-color-gray-50)!important}.comm\:bg-gray-100{background-color:var(--comm-color-gray-100)!important}.comm\:bg-gray-300{background-color:var(--comm-color-gray-300)!important}.comm\:bg-white{background-color:var(--comm-color-white)!important}.comm\:object-cover{object-fit:cover!important}.comm\:object-center{object-position:center!important}.comm\:p-1{padding:calc(var(--comm-spacing)*1)!important}.comm\:p-2{padding:calc(var(--comm-spacing)*2)!important}.comm\:p-4{padding:calc(var(--comm-spacing)*4)!important}.comm\:p-6{padding:calc(var(--comm-spacing)*6)!important}.comm\:px-1\.5{padding-inline:calc(var(--comm-spacing)*1.5)!important}.comm\:px-2{padding-inline:calc(var(--comm-spacing)*2)!important}.comm\:py-0\.5{padding-block:calc(var(--comm-spacing)*.5)!important}.comm\:py-4{padding-block:calc(var(--comm-spacing)*4)!important}.comm\:pt-2{padding-top:calc(var(--comm-spacing)*2)!important}.comm\:pt-3{padding-top:calc(var(--comm-spacing)*3)!important}.comm\:pl-2{padding-left:calc(var(--comm-spacing)*2)!important}.comm\:pl-6{padding-left:calc(var(--comm-spacing)*6)!important}.comm\:text-center{text-align:center!important}.comm\:text-sm{font-size:var(--comm-text-sm)!important;line-height:var(--tw-leading,var(--comm-text-sm--line-height))!important}.comm\:text-xs{font-size:var(--comm-text-xs)!important;line-height:var(--tw-leading,var(--comm-text-xs--line-height))!important}.comm\:font-bold{--tw-font-weight:var(--comm-font-weight-bold)!important;font-weight:var(--comm-font-weight-bold)!important}.comm\:font-medium{--tw-font-weight:var(--comm-font-weight-medium)!important;font-weight:var(--comm-font-weight-medium)!important}.comm\:whitespace-nowrap{white-space:nowrap!important}.comm\:text-gray-300{color:var(--comm-color-gray-300)!important}.comm\:text-gray-400{color:var(--comm-color-gray-400)!important}.comm\:text-gray-500{color:var(--comm-color-gray-500)!important}.comm\:text-gray-600{color:var(--comm-color-gray-600)!important}.comm\:text-gray-700{color:var(--comm-color-gray-700)!important}.comm\:text-gray-800{color:var(--comm-color-gray-800)!important}.comm\:text-gray-900{color:var(--comm-color-gray-900)!important}.comm\:shadow-lg{--tw-shadow:0 10px 15px -3px var(--tw-shadow-color,#0000001a),0 4px 6px -4px var(--tw-shadow-color,#0000001a)!important;box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)!important}.comm\:shadow-sm{--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a),0 1px 2px -1px var(--tw-shadow-color,#0000001a)!important;box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)!important}.comm\: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!important;transition-timing-function:var(--tw-ease,var(--comm-default-transition-timing-function))!important;transition-duration:var(--tw-duration,var(--comm-default-transition-duration))!important}@media (hover:hover){.comm\:hover\:bg-gray-100:hover{background-color:var(--comm-color-gray-100)!important}.comm\:hover\:bg-gray-200:hover{background-color:var(--comm-color-gray-200)!important}}.comm\: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)!important;box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)!important}.comm\:focus\:ring-offset-2:focus{--tw-ring-offset-width:2px!important;--tw-ring-offset-shadow:var(--tw-ring-inset,)0 0 0 var(--tw-ring-offset-width)var(--tw-ring-offset-color)!important}.comm\:focus\:outline-none:focus{--tw-outline-style:none!important;outline-style:none!important}.comm\:disabled\:cursor-not-allowed:disabled{cursor:not-allowed!important}.comm\:disabled\:opacity-50:disabled{opacity:.5!important}.comm\:dark\:border-gray-600:where(.dark,.dark *){border-color:var(--comm-color-gray-600)!important}.comm\:dark\:border-gray-700:where(.dark,.dark *){border-color:var(--comm-color-gray-700)!important}.comm\:dark\:bg-gray-600:where(.dark,.dark *){background-color:var(--comm-color-gray-600)!important}.comm\:dark\:bg-gray-800:where(.dark,.dark *){background-color:var(--comm-color-gray-800)!important}.comm\:dark\:bg-gray-900:where(.dark,.dark *){background-color:var(--comm-color-gray-900)!important}.comm\:dark\:text-gray-100:where(.dark,.dark *){color:var(--comm-color-gray-100)!important}.comm\:dark\:text-gray-200:where(.dark,.dark *){color:var(--comm-color-gray-200)!important}.comm\:dark\:text-gray-300:where(.dark,.dark *){color:var(--comm-color-gray-300)!important}.comm\:dark\:text-gray-400:where(.dark,.dark *){color:var(--comm-color-gray-400)!important}.comm\:dark\:text-gray-500:where(.dark,.dark *){color:var(--comm-color-gray-500)!important}@media (hover:hover){.comm\:dark\:hover\:bg-gray-600:where(.dark,.dark *):hover{background-color:var(--comm-color-gray-600)!important}.comm\:dark\:hover\:bg-gray-700:where(.dark,.dark *):hover{background-color:var(--comm-color-gray-700)!important}}}[x-cloak]{display:none}.tiptap{font-size:var(--comm-text-sm)!important;line-height:var(--tw-leading,var(--comm-text-sm--line-height))!important;--tw-leading:var(--comm-leading-normal)!important;line-height:var(--comm-leading-normal)!important}.tiptap p.is-editor-empty:before{color:#adb5bd;content:attr(data-placeholder);float:inline-start;pointer-events:none;height:0}.tiptap .mention{background-color:var(--comm-color-gray-200)!important;padding-inline:calc(var(--comm-spacing)*1)!important;padding-block:calc(var(--comm-spacing)*.5)!important;--tw-font-weight:var(--comm-font-weight-bold)!important;font-weight:var(--comm-font-weight-bold)!important;color:var(--comm-color-blue-500)!important;border-radius:.25rem!important;display:inline-block!important}.mention-suggestion{z-index:1000;background:#fff;border:1px solid #ddd;border-radius:5px;max-height:150px;padding:5px;overflow-y:auto}.mention-item{cursor:pointer;padding:5px 10px}.mention-item:hover{background-color:var(--comm-color-gray-100)!important}@keyframes spin{to{transform:rotate(360deg)}}@keyframes ping{75%,to{opacity:0;transform:scale(2)}}@keyframes pulse{50%{opacity:.5}}@keyframes bounce{0%,to{animation-timing-function:cubic-bezier(.8,0,1,1);transform:translateY(-25%)}50%{animation-timing-function:cubic-bezier(0,0,.2,1);transform:none}}@property --tw-space-y-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-font-weight{syntax:"*";inherits:false}@property --tw-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:"*";inherits:false}@property --tw-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:"*";inherits:false}@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-leading{syntax:"*";inherits:false} \ No newline at end of file +@layer theme{:root,:host{--comm-font-sans:ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";--comm-font-serif:ui-serif,Georgia,Cambria,"Times New Roman",Times,serif;--comm-font-mono:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;--comm-color-red-50:oklch(.971 .013 17.38);--comm-color-red-100:oklch(.936 .032 17.717);--comm-color-red-200:oklch(.885 .062 18.334);--comm-color-red-300:oklch(.808 .114 19.571);--comm-color-red-400:oklch(.704 .191 22.216);--comm-color-red-500:oklch(.637 .237 25.331);--comm-color-red-600:oklch(.577 .245 27.325);--comm-color-red-700:oklch(.505 .213 27.518);--comm-color-red-800:oklch(.444 .177 26.899);--comm-color-red-900:oklch(.396 .141 25.723);--comm-color-red-950:oklch(.258 .092 26.042);--comm-color-orange-50:oklch(.98 .016 73.684);--comm-color-orange-100:oklch(.954 .038 75.164);--comm-color-orange-200:oklch(.901 .076 70.697);--comm-color-orange-300:oklch(.837 .128 66.29);--comm-color-orange-400:oklch(.75 .183 55.934);--comm-color-orange-500:oklch(.705 .213 47.604);--comm-color-orange-600:oklch(.646 .222 41.116);--comm-color-orange-700:oklch(.553 .195 38.402);--comm-color-orange-800:oklch(.47 .157 37.304);--comm-color-orange-900:oklch(.408 .123 38.172);--comm-color-orange-950:oklch(.266 .079 36.259);--comm-color-amber-50:oklch(.987 .022 95.277);--comm-color-amber-100:oklch(.962 .059 95.617);--comm-color-amber-200:oklch(.924 .12 95.746);--comm-color-amber-300:oklch(.879 .169 91.605);--comm-color-amber-400:oklch(.828 .189 84.429);--comm-color-amber-500:oklch(.769 .188 70.08);--comm-color-amber-600:oklch(.666 .179 58.318);--comm-color-amber-700:oklch(.555 .163 48.998);--comm-color-amber-800:oklch(.473 .137 46.201);--comm-color-amber-900:oklch(.414 .112 45.904);--comm-color-amber-950:oklch(.279 .077 45.635);--comm-color-yellow-50:oklch(.987 .026 102.212);--comm-color-yellow-100:oklch(.973 .071 103.193);--comm-color-yellow-200:oklch(.945 .129 101.54);--comm-color-yellow-300:oklch(.905 .182 98.111);--comm-color-yellow-400:oklch(.852 .199 91.936);--comm-color-yellow-500:oklch(.795 .184 86.047);--comm-color-yellow-600:oklch(.681 .162 75.834);--comm-color-yellow-700:oklch(.554 .135 66.442);--comm-color-yellow-800:oklch(.476 .114 61.907);--comm-color-yellow-900:oklch(.421 .095 57.708);--comm-color-yellow-950:oklch(.286 .066 53.813);--comm-color-lime-50:oklch(.986 .031 120.757);--comm-color-lime-100:oklch(.967 .067 122.328);--comm-color-lime-200:oklch(.938 .127 124.321);--comm-color-lime-300:oklch(.897 .196 126.665);--comm-color-lime-400:oklch(.841 .238 128.85);--comm-color-lime-500:oklch(.768 .233 130.85);--comm-color-lime-600:oklch(.648 .2 131.684);--comm-color-lime-700:oklch(.532 .157 131.589);--comm-color-lime-800:oklch(.453 .124 130.933);--comm-color-lime-900:oklch(.405 .101 131.063);--comm-color-lime-950:oklch(.274 .072 132.109);--comm-color-green-50:oklch(.982 .018 155.826);--comm-color-green-100:oklch(.962 .044 156.743);--comm-color-green-200:oklch(.925 .084 155.995);--comm-color-green-300:oklch(.871 .15 154.449);--comm-color-green-400:oklch(.792 .209 151.711);--comm-color-green-500:oklch(.723 .219 149.579);--comm-color-green-600:oklch(.627 .194 149.214);--comm-color-green-700:oklch(.527 .154 150.069);--comm-color-green-800:oklch(.448 .119 151.328);--comm-color-green-900:oklch(.393 .095 152.535);--comm-color-green-950:oklch(.266 .065 152.934);--comm-color-emerald-50:oklch(.979 .021 166.113);--comm-color-emerald-100:oklch(.95 .052 163.051);--comm-color-emerald-200:oklch(.905 .093 164.15);--comm-color-emerald-300:oklch(.845 .143 164.978);--comm-color-emerald-400:oklch(.765 .177 163.223);--comm-color-emerald-500:oklch(.696 .17 162.48);--comm-color-emerald-600:oklch(.596 .145 163.225);--comm-color-emerald-700:oklch(.508 .118 165.612);--comm-color-emerald-800:oklch(.432 .095 166.913);--comm-color-emerald-900:oklch(.378 .077 168.94);--comm-color-emerald-950:oklch(.262 .051 172.552);--comm-color-teal-50:oklch(.984 .014 180.72);--comm-color-teal-100:oklch(.953 .051 180.801);--comm-color-teal-200:oklch(.91 .096 180.426);--comm-color-teal-300:oklch(.855 .138 181.071);--comm-color-teal-400:oklch(.777 .152 181.912);--comm-color-teal-500:oklch(.704 .14 182.503);--comm-color-teal-600:oklch(.6 .118 184.704);--comm-color-teal-700:oklch(.511 .096 186.391);--comm-color-teal-800:oklch(.437 .078 188.216);--comm-color-teal-900:oklch(.386 .063 188.416);--comm-color-teal-950:oklch(.277 .046 192.524);--comm-color-cyan-50:oklch(.984 .019 200.873);--comm-color-cyan-100:oklch(.956 .045 203.388);--comm-color-cyan-200:oklch(.917 .08 205.041);--comm-color-cyan-300:oklch(.865 .127 207.078);--comm-color-cyan-400:oklch(.789 .154 211.53);--comm-color-cyan-500:oklch(.715 .143 215.221);--comm-color-cyan-600:oklch(.609 .126 221.723);--comm-color-cyan-700:oklch(.52 .105 223.128);--comm-color-cyan-800:oklch(.45 .085 224.283);--comm-color-cyan-900:oklch(.398 .07 227.392);--comm-color-cyan-950:oklch(.302 .056 229.695);--comm-color-sky-50:oklch(.977 .013 236.62);--comm-color-sky-100:oklch(.951 .026 236.824);--comm-color-sky-200:oklch(.901 .058 230.902);--comm-color-sky-300:oklch(.828 .111 230.318);--comm-color-sky-400:oklch(.746 .16 232.661);--comm-color-sky-500:oklch(.685 .169 237.323);--comm-color-sky-600:oklch(.588 .158 241.966);--comm-color-sky-700:oklch(.5 .134 242.749);--comm-color-sky-800:oklch(.443 .11 240.79);--comm-color-sky-900:oklch(.391 .09 240.876);--comm-color-sky-950:oklch(.293 .066 243.157);--comm-color-blue-50:oklch(.97 .014 254.604);--comm-color-blue-100:oklch(.932 .032 255.585);--comm-color-blue-200:oklch(.882 .059 254.128);--comm-color-blue-300:oklch(.809 .105 251.813);--comm-color-blue-400:oklch(.707 .165 254.624);--comm-color-blue-500:oklch(.623 .214 259.815);--comm-color-blue-600:oklch(.546 .245 262.881);--comm-color-blue-700:oklch(.488 .243 264.376);--comm-color-blue-800:oklch(.424 .199 265.638);--comm-color-blue-900:oklch(.379 .146 265.522);--comm-color-blue-950:oklch(.282 .091 267.935);--comm-color-indigo-50:oklch(.962 .018 272.314);--comm-color-indigo-100:oklch(.93 .034 272.788);--comm-color-indigo-200:oklch(.87 .065 274.039);--comm-color-indigo-300:oklch(.785 .115 274.713);--comm-color-indigo-400:oklch(.673 .182 276.935);--comm-color-indigo-500:oklch(.585 .233 277.117);--comm-color-indigo-600:oklch(.511 .262 276.966);--comm-color-indigo-700:oklch(.457 .24 277.023);--comm-color-indigo-800:oklch(.398 .195 277.366);--comm-color-indigo-900:oklch(.359 .144 278.697);--comm-color-indigo-950:oklch(.257 .09 281.288);--comm-color-violet-50:oklch(.969 .016 293.756);--comm-color-violet-100:oklch(.943 .029 294.588);--comm-color-violet-200:oklch(.894 .057 293.283);--comm-color-violet-300:oklch(.811 .111 293.571);--comm-color-violet-400:oklch(.702 .183 293.541);--comm-color-violet-500:oklch(.606 .25 292.717);--comm-color-violet-600:oklch(.541 .281 293.009);--comm-color-violet-700:oklch(.491 .27 292.581);--comm-color-violet-800:oklch(.432 .232 292.759);--comm-color-violet-900:oklch(.38 .189 293.745);--comm-color-violet-950:oklch(.283 .141 291.089);--comm-color-purple-50:oklch(.977 .014 308.299);--comm-color-purple-100:oklch(.946 .033 307.174);--comm-color-purple-200:oklch(.902 .063 306.703);--comm-color-purple-300:oklch(.827 .119 306.383);--comm-color-purple-400:oklch(.714 .203 305.504);--comm-color-purple-500:oklch(.627 .265 303.9);--comm-color-purple-600:oklch(.558 .288 302.321);--comm-color-purple-700:oklch(.496 .265 301.924);--comm-color-purple-800:oklch(.438 .218 303.724);--comm-color-purple-900:oklch(.381 .176 304.987);--comm-color-purple-950:oklch(.291 .149 302.717);--comm-color-fuchsia-50:oklch(.977 .017 320.058);--comm-color-fuchsia-100:oklch(.952 .037 318.852);--comm-color-fuchsia-200:oklch(.903 .076 319.62);--comm-color-fuchsia-300:oklch(.833 .145 321.434);--comm-color-fuchsia-400:oklch(.74 .238 322.16);--comm-color-fuchsia-500:oklch(.667 .295 322.15);--comm-color-fuchsia-600:oklch(.591 .293 322.896);--comm-color-fuchsia-700:oklch(.518 .253 323.949);--comm-color-fuchsia-800:oklch(.452 .211 324.591);--comm-color-fuchsia-900:oklch(.401 .17 325.612);--comm-color-fuchsia-950:oklch(.293 .136 325.661);--comm-color-pink-50:oklch(.971 .014 343.198);--comm-color-pink-100:oklch(.948 .028 342.258);--comm-color-pink-200:oklch(.899 .061 343.231);--comm-color-pink-300:oklch(.823 .12 346.018);--comm-color-pink-400:oklch(.718 .202 349.761);--comm-color-pink-500:oklch(.656 .241 354.308);--comm-color-pink-600:oklch(.592 .249 .584);--comm-color-pink-700:oklch(.525 .223 3.958);--comm-color-pink-800:oklch(.459 .187 3.815);--comm-color-pink-900:oklch(.408 .153 2.432);--comm-color-pink-950:oklch(.284 .109 3.907);--comm-color-rose-50:oklch(.969 .015 12.422);--comm-color-rose-100:oklch(.941 .03 12.58);--comm-color-rose-200:oklch(.892 .058 10.001);--comm-color-rose-300:oklch(.81 .117 11.638);--comm-color-rose-400:oklch(.712 .194 13.428);--comm-color-rose-500:oklch(.645 .246 16.439);--comm-color-rose-600:oklch(.586 .253 17.585);--comm-color-rose-700:oklch(.514 .222 16.935);--comm-color-rose-800:oklch(.455 .188 13.697);--comm-color-rose-900:oklch(.41 .159 10.272);--comm-color-rose-950:oklch(.271 .105 12.094);--comm-color-slate-50:oklch(.984 .003 247.858);--comm-color-slate-100:oklch(.968 .007 247.896);--comm-color-slate-200:oklch(.929 .013 255.508);--comm-color-slate-300:oklch(.869 .022 252.894);--comm-color-slate-400:oklch(.704 .04 256.788);--comm-color-slate-500:oklch(.554 .046 257.417);--comm-color-slate-600:oklch(.446 .043 257.281);--comm-color-slate-700:oklch(.372 .044 257.287);--comm-color-slate-800:oklch(.279 .041 260.031);--comm-color-slate-900:oklch(.208 .042 265.755);--comm-color-slate-950:oklch(.129 .042 264.695);--comm-color-gray-50:oklch(.985 .002 247.839);--comm-color-gray-100:oklch(.967 .003 264.542);--comm-color-gray-200:oklch(.928 .006 264.531);--comm-color-gray-300:oklch(.872 .01 258.338);--comm-color-gray-400:oklch(.707 .022 261.325);--comm-color-gray-500:oklch(.551 .027 264.364);--comm-color-gray-600:oklch(.446 .03 256.802);--comm-color-gray-700:oklch(.373 .034 259.733);--comm-color-gray-800:oklch(.278 .033 256.848);--comm-color-gray-900:oklch(.21 .034 264.665);--comm-color-gray-950:oklch(.13 .028 261.692);--comm-color-zinc-50:oklch(.985 0 0);--comm-color-zinc-100:oklch(.967 .001 286.375);--comm-color-zinc-200:oklch(.92 .004 286.32);--comm-color-zinc-300:oklch(.871 .006 286.286);--comm-color-zinc-400:oklch(.705 .015 286.067);--comm-color-zinc-500:oklch(.552 .016 285.938);--comm-color-zinc-600:oklch(.442 .017 285.786);--comm-color-zinc-700:oklch(.37 .013 285.805);--comm-color-zinc-800:oklch(.274 .006 286.033);--comm-color-zinc-900:oklch(.21 .006 285.885);--comm-color-zinc-950:oklch(.141 .005 285.823);--comm-color-neutral-50:oklch(.985 0 0);--comm-color-neutral-100:oklch(.97 0 0);--comm-color-neutral-200:oklch(.922 0 0);--comm-color-neutral-300:oklch(.87 0 0);--comm-color-neutral-400:oklch(.708 0 0);--comm-color-neutral-500:oklch(.556 0 0);--comm-color-neutral-600:oklch(.439 0 0);--comm-color-neutral-700:oklch(.371 0 0);--comm-color-neutral-800:oklch(.269 0 0);--comm-color-neutral-900:oklch(.205 0 0);--comm-color-neutral-950:oklch(.145 0 0);--comm-color-stone-50:oklch(.985 .001 106.423);--comm-color-stone-100:oklch(.97 .001 106.424);--comm-color-stone-200:oklch(.923 .003 48.717);--comm-color-stone-300:oklch(.869 .005 56.366);--comm-color-stone-400:oklch(.709 .01 56.259);--comm-color-stone-500:oklch(.553 .013 58.071);--comm-color-stone-600:oklch(.444 .011 73.639);--comm-color-stone-700:oklch(.374 .01 67.558);--comm-color-stone-800:oklch(.268 .007 34.298);--comm-color-stone-900:oklch(.216 .006 56.043);--comm-color-stone-950:oklch(.147 .004 49.25);--comm-color-black:#000;--comm-color-white:#fff;--comm-spacing:.25rem;--comm-breakpoint-sm:40rem;--comm-breakpoint-md:48rem;--comm-breakpoint-lg:64rem;--comm-breakpoint-xl:80rem;--comm-breakpoint-2xl:96rem;--comm-container-3xs:16rem;--comm-container-2xs:18rem;--comm-container-xs:20rem;--comm-container-sm:24rem;--comm-container-md:28rem;--comm-container-lg:32rem;--comm-container-xl:36rem;--comm-container-2xl:42rem;--comm-container-3xl:48rem;--comm-container-4xl:56rem;--comm-container-5xl:64rem;--comm-container-6xl:72rem;--comm-container-7xl:80rem;--comm-text-xs:.75rem;--comm-text-xs--line-height:calc(1/.75);--comm-text-sm:.875rem;--comm-text-sm--line-height:calc(1.25/.875);--comm-text-base:1rem;--comm-text-base--line-height:calc(1.5/1);--comm-text-lg:1.125rem;--comm-text-lg--line-height:calc(1.75/1.125);--comm-text-xl:1.25rem;--comm-text-xl--line-height:calc(1.75/1.25);--comm-text-2xl:1.5rem;--comm-text-2xl--line-height:calc(2/1.5);--comm-text-3xl:1.875rem;--comm-text-3xl--line-height:calc(2.25/1.875);--comm-text-4xl:2.25rem;--comm-text-4xl--line-height:calc(2.5/2.25);--comm-text-5xl:3rem;--comm-text-5xl--line-height:1;--comm-text-6xl:3.75rem;--comm-text-6xl--line-height:1;--comm-text-7xl:4.5rem;--comm-text-7xl--line-height:1;--comm-text-8xl:6rem;--comm-text-8xl--line-height:1;--comm-text-9xl:8rem;--comm-text-9xl--line-height:1;--comm-font-weight-thin:100;--comm-font-weight-extralight:200;--comm-font-weight-light:300;--comm-font-weight-normal:400;--comm-font-weight-medium:500;--comm-font-weight-semibold:600;--comm-font-weight-bold:700;--comm-font-weight-extrabold:800;--comm-font-weight-black:900;--comm-tracking-tighter:-.05em;--comm-tracking-tight:-.025em;--comm-tracking-normal:0em;--comm-tracking-wide:.025em;--comm-tracking-wider:.05em;--comm-tracking-widest:.1em;--comm-leading-tight:1.25;--comm-leading-snug:1.375;--comm-leading-normal:1.5;--comm-leading-relaxed:1.625;--comm-leading-loose:2;--comm-radius-xs:.125rem;--comm-radius-sm:.25rem;--comm-radius-md:.375rem;--comm-radius-lg:.5rem;--comm-radius-xl:.75rem;--comm-radius-2xl:1rem;--comm-radius-3xl:1.5rem;--comm-radius-4xl:2rem;--comm-shadow-2xs:0 1px #0000000d;--comm-shadow-xs:0 1px 2px 0 #0000000d;--comm-shadow-sm:0 1px 3px 0 #0000001a,0 1px 2px -1px #0000001a;--comm-shadow-md:0 4px 6px -1px #0000001a,0 2px 4px -2px #0000001a;--comm-shadow-lg:0 10px 15px -3px #0000001a,0 4px 6px -4px #0000001a;--comm-shadow-xl:0 20px 25px -5px #0000001a,0 8px 10px -6px #0000001a;--comm-shadow-2xl:0 25px 50px -12px #00000040;--comm-inset-shadow-2xs:inset 0 1px #0000000d;--comm-inset-shadow-xs:inset 0 1px 1px #0000000d;--comm-inset-shadow-sm:inset 0 2px 4px #0000000d;--comm-drop-shadow-xs:0 1px 1px #0000000d;--comm-drop-shadow-sm:0 1px 2px #00000026;--comm-drop-shadow-md:0 3px 3px #0000001f;--comm-drop-shadow-lg:0 4px 4px #00000026;--comm-drop-shadow-xl:0 9px 7px #0000001a;--comm-drop-shadow-2xl:0 25px 25px #00000026;--comm-ease-in:cubic-bezier(.4,0,1,1);--comm-ease-out:cubic-bezier(0,0,.2,1);--comm-ease-in-out:cubic-bezier(.4,0,.2,1);--comm-animate-spin:spin 1s linear infinite;--comm-animate-ping:ping 1s cubic-bezier(0,0,.2,1)infinite;--comm-animate-pulse:pulse 2s cubic-bezier(.4,0,.6,1)infinite;--comm-animate-bounce:bounce 1s infinite;--comm-blur-xs:4px;--comm-blur-sm:8px;--comm-blur-md:12px;--comm-blur-lg:16px;--comm-blur-xl:24px;--comm-blur-2xl:40px;--comm-blur-3xl:64px;--comm-perspective-dramatic:100px;--comm-perspective-near:300px;--comm-perspective-normal:500px;--comm-perspective-midrange:800px;--comm-perspective-distant:1200px;--comm-aspect-video:16/9;--comm-default-transition-duration:.15s;--comm-default-transition-timing-function:cubic-bezier(.4,0,.2,1);--comm-default-font-family:var(--font-sans);--comm-default-font-feature-settings:var(--font-sans--font-feature-settings);--comm-default-font-variation-settings:var(--font-sans--font-variation-settings);--comm-default-mono-font-family:var(--font-mono);--comm-default-mono-font-feature-settings:var(--font-mono--font-feature-settings);--comm-default-mono-font-variation-settings:var(--font-mono--font-variation-settings)}}@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,ui-sans-serif,system-ui,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}body{line-height:inherit}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;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{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;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}:-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}}@layer components;@layer utilities{.comm\:absolute{position:absolute!important}.comm\:relative{position:relative!important}.comm\:sticky{position:sticky!important}.comm\:top-4{top:calc(var(--comm-spacing)*4)!important}.comm\:bottom-full{bottom:100%!important}.comm\:z-10{z-index:10!important}.comm\:mt-0\.5{margin-top:calc(var(--comm-spacing)*.5)!important}.comm\:mt-1{margin-top:calc(var(--comm-spacing)*1)!important}.comm\:mt-2{margin-top:calc(var(--comm-spacing)*2)!important}.comm\:mb-2{margin-bottom:calc(var(--comm-spacing)*2)!important}.comm\:mb-3{margin-bottom:calc(var(--comm-spacing)*3)!important}.comm\:ml-1{margin-left:calc(var(--comm-spacing)*1)!important}.comm\:ml-2{margin-left:calc(var(--comm-spacing)*2)!important}.comm\:flex{display:flex!important}.comm\:hidden{display:none!important}.comm\:inline-block{display:inline-block!important}.comm\:inline-flex{display:inline-flex!important}.comm\:h-3{height:calc(var(--comm-spacing)*3)!important}.comm\:h-4{height:calc(var(--comm-spacing)*4)!important}.comm\:h-8{height:calc(var(--comm-spacing)*8)!important}.comm\:h-10{height:calc(var(--comm-spacing)*10)!important}.comm\:h-full{height:100%!important}.comm\:w-3{width:calc(var(--comm-spacing)*3)!important}.comm\:w-4{width:calc(var(--comm-spacing)*4)!important}.comm\:w-8{width:calc(var(--comm-spacing)*8)!important}.comm\:w-10{width:calc(var(--comm-spacing)*10)!important}.comm\:w-48{width:calc(var(--comm-spacing)*48)!important}.comm\:w-full{width:100%!important}.comm\:w-max{width:max-content!important}.comm\:max-w-xs{max-width:var(--comm-container-xs)!important}.comm\:min-w-full{min-width:100%!important}.comm\:flex-1{flex:1!important}.comm\:flex-shrink-0{flex-shrink:0!important}.comm\:flex-col{flex-direction:column!important}.comm\:flex-wrap{flex-wrap:wrap!important}.comm\:items-center{align-items:center!important}.comm\:items-start{align-items:flex-start!important}.comm\:justify-between{justify-content:space-between!important}.comm\:justify-center{justify-content:center!important}.comm\:justify-end{justify-content:flex-end!important}.comm\:gap-1{gap:calc(var(--comm-spacing)*1)!important}.comm\:gap-2{gap:calc(var(--comm-spacing)*2)!important}.comm\:gap-4{gap:calc(var(--comm-spacing)*4)!important}.comm\:gap-x-1{column-gap:calc(var(--comm-spacing)*1)!important}.comm\:gap-x-2{column-gap:calc(var(--comm-spacing)*2)!important}.comm\:gap-x-4{column-gap:calc(var(--comm-spacing)*4)!important}:where(.comm\:space-y-1>:not(:last-child)){--tw-space-y-reverse:0!important;margin-block-start:calc(calc(var(--comm-spacing)*1)*var(--tw-space-y-reverse))!important;margin-block-end:calc(calc(var(--comm-spacing)*1)*calc(1 - var(--tw-space-y-reverse)))!important}:where(.comm\:space-y-2>:not(:last-child)){--tw-space-y-reverse:0!important;margin-block-start:calc(calc(var(--comm-spacing)*2)*var(--tw-space-y-reverse))!important;margin-block-end:calc(calc(var(--comm-spacing)*2)*calc(1 - var(--tw-space-y-reverse)))!important}:where(.comm\:space-y-6>:not(:last-child)){--tw-space-y-reverse:0!important;margin-block-start:calc(calc(var(--comm-spacing)*6)*var(--tw-space-y-reverse))!important;margin-block-end:calc(calc(var(--comm-spacing)*6)*calc(1 - var(--tw-space-y-reverse)))!important}.comm\:gap-y-2{row-gap:calc(var(--comm-spacing)*2)!important}.comm\:truncate{text-overflow:ellipsis!important;white-space:nowrap!important;overflow:hidden!important}.comm\:rounded-full{border-radius:3.40282e38px!important}.comm\:rounded-lg{border-radius:var(--comm-radius-lg)!important}.comm\:rounded-md{border-radius:var(--comm-radius-md)!important}.comm\:border{border-style:var(--tw-border-style)!important;border-width:1px!important}.comm\:border-t{border-top-style:var(--tw-border-style)!important;border-top-width:1px!important}.comm\:border-dashed{--tw-border-style:dashed!important;border-style:dashed!important}.comm\:border-gray-200{border-color:var(--comm-color-gray-200)!important}.comm\:border-gray-300{border-color:var(--comm-color-gray-300)!important}.comm\:bg-blue-100{background-color:var(--comm-color-blue-100)!important}.comm\:bg-gray-50{background-color:var(--comm-color-gray-50)!important}.comm\:bg-gray-100{background-color:var(--comm-color-gray-100)!important}.comm\:bg-gray-300{background-color:var(--comm-color-gray-300)!important}.comm\:bg-white{background-color:var(--comm-color-white)!important}.comm\:object-cover{object-fit:cover!important}.comm\:object-center{object-position:center!important}.comm\:p-1{padding:calc(var(--comm-spacing)*1)!important}.comm\:p-2{padding:calc(var(--comm-spacing)*2)!important}.comm\:p-4{padding:calc(var(--comm-spacing)*4)!important}.comm\:p-6{padding:calc(var(--comm-spacing)*6)!important}.comm\:px-1\.5{padding-inline:calc(var(--comm-spacing)*1.5)!important}.comm\:px-2{padding-inline:calc(var(--comm-spacing)*2)!important}.comm\:py-0\.5{padding-block:calc(var(--comm-spacing)*.5)!important}.comm\:py-4{padding-block:calc(var(--comm-spacing)*4)!important}.comm\:pt-2{padding-top:calc(var(--comm-spacing)*2)!important}.comm\:pt-3{padding-top:calc(var(--comm-spacing)*3)!important}.comm\:pl-2{padding-left:calc(var(--comm-spacing)*2)!important}.comm\:pl-6{padding-left:calc(var(--comm-spacing)*6)!important}.comm\:text-center{text-align:center!important}.comm\:text-sm{font-size:var(--comm-text-sm)!important;line-height:var(--tw-leading,var(--comm-text-sm--line-height))!important}.comm\:text-xs{font-size:var(--comm-text-xs)!important;line-height:var(--tw-leading,var(--comm-text-xs--line-height))!important}.comm\:font-bold{--tw-font-weight:var(--comm-font-weight-bold)!important;font-weight:var(--comm-font-weight-bold)!important}.comm\:font-medium{--tw-font-weight:var(--comm-font-weight-medium)!important;font-weight:var(--comm-font-weight-medium)!important}.comm\:whitespace-nowrap{white-space:nowrap!important}.comm\:text-gray-300{color:var(--comm-color-gray-300)!important}.comm\:text-gray-400{color:var(--comm-color-gray-400)!important}.comm\:text-gray-500{color:var(--comm-color-gray-500)!important}.comm\:text-gray-600{color:var(--comm-color-gray-600)!important}.comm\:text-gray-700{color:var(--comm-color-gray-700)!important}.comm\:text-gray-800{color:var(--comm-color-gray-800)!important}.comm\:text-gray-900{color:var(--comm-color-gray-900)!important}.comm\:shadow-lg{--tw-shadow:0 10px 15px -3px var(--tw-shadow-color,#0000001a),0 4px 6px -4px var(--tw-shadow-color,#0000001a)!important;box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)!important}.comm\:shadow-sm{--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a),0 1px 2px -1px var(--tw-shadow-color,#0000001a)!important;box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)!important}.comm\: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!important;transition-timing-function:var(--tw-ease,var(--comm-default-transition-timing-function))!important;transition-duration:var(--tw-duration,var(--comm-default-transition-duration))!important}@media (hover:hover){.comm\:hover\:bg-gray-100:hover{background-color:var(--comm-color-gray-100)!important}.comm\:hover\:bg-gray-200:hover{background-color:var(--comm-color-gray-200)!important}}.comm\: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)!important;box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)!important}.comm\:focus\:ring-offset-2:focus{--tw-ring-offset-width:2px!important;--tw-ring-offset-shadow:var(--tw-ring-inset,)0 0 0 var(--tw-ring-offset-width)var(--tw-ring-offset-color)!important}.comm\:focus\:outline-none:focus{--tw-outline-style:none!important;outline-style:none!important}.comm\:disabled\:cursor-not-allowed:disabled{cursor:not-allowed!important}.comm\:disabled\:opacity-50:disabled{opacity:.5!important}.comm\:dark\:border-gray-600:where(.dark,.dark *){border-color:var(--comm-color-gray-600)!important}.comm\:dark\:border-gray-700:where(.dark,.dark *){border-color:var(--comm-color-gray-700)!important}.comm\:dark\:bg-gray-600:where(.dark,.dark *){background-color:var(--comm-color-gray-600)!important}.comm\:dark\:bg-gray-800:where(.dark,.dark *){background-color:var(--comm-color-gray-800)!important}.comm\:dark\:bg-gray-900:where(.dark,.dark *){background-color:var(--comm-color-gray-900)!important}.comm\:dark\:text-gray-100:where(.dark,.dark *){color:var(--comm-color-gray-100)!important}.comm\:dark\:text-gray-200:where(.dark,.dark *){color:var(--comm-color-gray-200)!important}.comm\:dark\:text-gray-300:where(.dark,.dark *){color:var(--comm-color-gray-300)!important}.comm\:dark\:text-gray-400:where(.dark,.dark *){color:var(--comm-color-gray-400)!important}.comm\:dark\:text-gray-500:where(.dark,.dark *){color:var(--comm-color-gray-500)!important}@media (hover:hover){.comm\:dark\:hover\:bg-gray-600:where(.dark,.dark *):hover{background-color:var(--comm-color-gray-600)!important}.comm\:dark\:hover\:bg-gray-700:where(.dark,.dark *):hover{background-color:var(--comm-color-gray-700)!important}}}[x-cloak]{display:none}.tiptap{font-size:var(--comm-text-sm)!important;line-height:var(--tw-leading,var(--comm-text-sm--line-height))!important;--tw-leading:var(--comm-leading-normal)!important;line-height:var(--comm-leading-normal)!important}.tiptap p.is-editor-empty:before{color:#adb5bd;content:attr(data-placeholder);float:inline-start;pointer-events:none;height:0}.tiptap .mention{background-color:var(--comm-color-gray-200)!important;padding-inline:calc(var(--comm-spacing)*1)!important;padding-block:calc(var(--comm-spacing)*.5)!important;--tw-font-weight:var(--comm-font-weight-bold)!important;font-weight:var(--comm-font-weight-bold)!important;color:var(--comm-color-blue-500)!important;border-radius:.25rem!important;display:inline-block!important}.mention-suggestion{z-index:1000;background:#fff;border:1px solid #ddd;border-radius:5px;max-height:150px;padding:5px;overflow-y:auto}.mention-item{cursor:pointer;padding:5px 10px}.mention-item:hover{background-color:var(--comm-color-gray-100)!important}.tip-tap-container{border-radius:var(--comm-radius-lg)!important;border-style:var(--tw-border-style)!important;border-width:1px!important;border-color:var(--comm-color-gray-300)!important;background-color:var(--comm-color-white)!important;overflow:hidden!important}.tip-tap-container:focus-within{border-color:var(--comm-color-blue-500)!important;--tw-ring-shadow:var(--tw-ring-inset,)0 0 0 calc(2px + var(--tw-ring-offset-width))var(--tw-ring-color,currentColor)!important;box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)!important;--tw-ring-color:color-mix(in oklab,var(--comm-color-blue-500)50%,transparent)!important}.tip-tap-container:where(.dark,.dark *){border-color:var(--comm-color-gray-700)!important;background-color:var(--comm-color-gray-900)!important}.commentions-toolbar{align-items:center!important;gap:calc(var(--comm-spacing)*1)!important;border-bottom-style:var(--tw-border-style)!important;border-bottom-width:1px!important;border-color:var(--comm-color-gray-300)!important;background-color:var(--comm-color-gray-50)!important;padding:calc(var(--comm-spacing)*1)!important;flex-wrap:wrap!important;display:flex!important}.commentions-toolbar:where(.dark,.dark *){border-color:var(--comm-color-gray-700)!important;background-color:var(--comm-color-gray-800)!important}.commentions-toolbar-group{align-items:center!important;gap:calc(var(--comm-spacing)*.5)!important;display:flex!important}.commentions-toolbar-group:not(:last-child){margin-right:calc(var(--comm-spacing)*1)!important;border-right-style:var(--tw-border-style)!important;border-right-width:1px!important;border-color:var(--comm-color-gray-300)!important;padding-right:calc(var(--comm-spacing)*1)!important}.commentions-toolbar-group:not(:last-child):where(.dark,.dark *){border-color:var(--comm-color-gray-700)!important}.commentions-toolbar-button{cursor:pointer!important;padding:calc(var(--comm-spacing)*1.5)!important;color:var(--comm-color-gray-600)!important;border-radius:.25rem!important;justify-content:center!important;align-items:center!important;display:flex!important}.commentions-toolbar-button:where(.dark,.dark *){color:var(--comm-color-gray-300)!important}.commentions-toolbar-button:hover{background-color:var(--comm-color-gray-200)!important}.commentions-toolbar-button:hover:where(.dark,.dark *){background-color:var(--comm-color-gray-700)!important}.commentions-toolbar-button:focus-visible{background-color:var(--comm-color-gray-200)!important;--tw-outline-style:none!important;outline-style:none!important}.commentions-toolbar-button:focus-visible:where(.dark,.dark *){background-color:var(--comm-color-gray-700)!important}.commentions-toolbar-button-active{background-color:var(--comm-color-gray-200)!important;color:var(--comm-color-blue-600)!important}.commentions-toolbar-button-active:where(.dark,.dark *){background-color:var(--comm-color-gray-700)!important;color:var(--comm-color-blue-400)!important}.tiptap a.comm-link{color:var(--comm-color-blue-600)!important;text-decoration-line:underline!important}.tiptap a.comm-link:where(.dark,.dark *){color:var(--comm-color-blue-400)!important}@keyframes spin{to{transform:rotate(360deg)}}@keyframes ping{75%,to{opacity:0;transform:scale(2)}}@keyframes pulse{50%{opacity:.5}}@keyframes bounce{0%,to{animation-timing-function:cubic-bezier(.8,0,1,1);transform:translateY(-25%)}50%{animation-timing-function:cubic-bezier(0,0,.2,1);transform:none}}@property --tw-space-y-reverse{syntax:"*";inherits:false;initial-value:0}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-font-weight{syntax:"*";inherits:false}@property --tw-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:"*";inherits:false}@property --tw-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:"*";inherits:false}@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-leading{syntax:"*";inherits:false} \ No newline at end of file diff --git a/resources/dist/commentions.js b/resources/dist/commentions.js index 3cf2d26..eca31b7 100644 --- a/resources/dist/commentions.js +++ b/resources/dist/commentions.js @@ -1,16 +1,16 @@ -function ye(n){this.content=n}ye.prototype={constructor:ye,find:function(n){for(var e=0;e>1}};ye.from=function(n){if(n instanceof ye)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new ye(e)};var Li=ye;function Ys(n,e,t){for(let r=0;;r++){if(r==n.childCount||r==e.childCount)return n.childCount==e.childCount?null:t;let i=n.child(r),o=e.child(r);if(i==o){t+=i.nodeSize;continue}if(!i.sameMarkup(o))return t;if(i.isText&&i.text!=o.text){for(let s=0;i.text[s]==o.text[s];s++)t++;return t}if(i.content.size||o.content.size){let s=Ys(i.content,o.content,t+1);if(s!=null)return s}t+=i.nodeSize}}function Xs(n,e,t,r){for(let i=n.childCount,o=e.childCount;;){if(i==0||o==0)return i==o?null:{a:t,b:r};let s=n.child(--i),l=e.child(--o),a=s.nodeSize;if(s==l){t-=a,r-=a;continue}if(!s.sameMarkup(l))return{a:t,b:r};if(s.isText&&s.text!=l.text){let c=0,f=Math.min(s.text.length,l.text.length);for(;ce&&r(a,i+l,o||null,s)!==!1&&a.content.size){let f=l+1;a.nodesBetween(Math.max(0,e-f),Math.min(a.content.size,t-f),r,i+f)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,r,i){let o="",s=!0;return this.nodesBetween(e,t,(l,a)=>{let c=l.isText?l.text.slice(Math.max(e,a)-a,t-a):l.isLeaf?i?typeof i=="function"?i(l):i:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&r&&(s?s=!1:o+=r),o+=c},0),o}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,r=e.firstChild,i=this.content.slice(),o=0;for(t.isText&&t.sameMarkup(r)&&(i[i.length-1]=t.withText(t.text+r.text),o=1);oe)for(let o=0,s=0;se&&((st)&&(l.isText?l=l.cut(Math.max(0,e-s),Math.min(l.text.length,t-s)):l=l.cut(Math.max(0,e-s-1),Math.min(l.content.size,t-s-1))),r.push(l),i+=l.nodeSize),s=a}return new n(r,i)}cutByIndex(e,t){return e==t?n.empty:e==0&&t==this.content.length?this:new n(this.content.slice(e,t))}replaceChild(e,t){let r=this.content[e];if(r==t)return this;let i=this.content.slice(),o=this.size+t.nodeSize-r.nodeSize;return i[e]=t,new n(i,o)}addToStart(e){return new n([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new n(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;tthis.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let r=0,i=0;;r++){let o=this.child(r),s=i+o.nodeSize;if(s>=e)return s==e||t>0?Pr(r+1,s):Pr(r,i);i=s}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return n.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new n(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return n.empty;let t,r=0;for(let i=0;ithis.type.rank&&(t||(t=e.slice(0,i)),t.push(this),r=!0),t&&t.push(o)}}return t||(t=e.slice()),r||t.push(this),t}removeFromSet(e){for(let t=0;tr.type.rank-i.type.rank),t}};$.none=[];var Ft=class extends Error{},M=class n{constructor(e,t,r){this.content=e,this.openStart=t,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let r=Qs(this.content,e+this.openStart,t);return r&&new n(r,this.openStart,this.openEnd)}removeBetween(e,t){return new n(Zs(this.content,e+this.openStart,t+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(e,t){if(!t)return n.empty;let r=t.openStart||0,i=t.openEnd||0;if(typeof r!="number"||typeof i!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new n(S.fromJSON(e,t.content),r,i)}static maxOpen(e,t=!0){let r=0,i=0;for(let o=e.firstChild;o&&!o.isLeaf&&(t||!o.type.spec.isolating);o=o.firstChild)r++;for(let o=e.lastChild;o&&!o.isLeaf&&(t||!o.type.spec.isolating);o=o.lastChild)i++;return new n(e,r,i)}};M.empty=new M(S.empty,0,0);function Zs(n,e,t){let{index:r,offset:i}=n.findIndex(e),o=n.maybeChild(r),{index:s,offset:l}=n.findIndex(t);if(i==e||o.isText){if(l!=t&&!n.child(s).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(r!=s)throw new RangeError("Removing non-flat range");return n.replaceChild(r,o.copy(Zs(o.content,e-i-1,t-i-1)))}function Qs(n,e,t,r){let{index:i,offset:o}=n.findIndex(e),s=n.maybeChild(i);if(o==e||s.isText)return r&&!r.canReplace(i,i,t)?null:n.cut(0,e).append(t).append(n.cut(e));let l=Qs(s.content,e-o-1,t);return l&&n.replaceChild(i,s.copy(l))}function eu(n,e,t){if(t.openStart>n.depth)throw new Ft("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new Ft("Inconsistent open depths");return el(n,e,t,0)}function el(n,e,t,r){let i=n.index(r),o=n.node(r);if(i==e.index(r)&&r=0&&n.isText&&n.sameMarkup(e[t])?e[t]=n.withText(e[t].text+n.text):e.push(n)}function Vn(n,e,t,r){let i=(e||n).node(t),o=0,s=e?e.index(t):i.childCount;n&&(o=n.index(t),n.depth>t?o++:n.textOffset&&(Bt(n.nodeAfter,r),o++));for(let l=o;li&&Vi(n,e,i+1),s=r.depth>i&&Vi(t,r,i+1),l=[];return Vn(null,n,i,l),o&&s&&e.index(i)==t.index(i)?(tl(o,s),Bt(Lt(o,nl(n,e,t,r,i+1)),l)):(o&&Bt(Lt(o,Br(n,e,i+1)),l),Vn(e,t,i,l),s&&Bt(Lt(s,Br(t,r,i+1)),l)),Vn(r,null,i,l),new S(l)}function Br(n,e,t){let r=[];if(Vn(null,n,t,r),n.depth>t){let i=Vi(n,e,t+1);Bt(Lt(i,Br(n,e,t+1)),r)}return Vn(e,null,t,r),new S(r)}function tu(n,e){let t=e.depth-n.openStart,i=e.node(t).copy(n.content);for(let o=t-1;o>=0;o--)i=e.node(o).copy(S.from(i));return{start:i.resolveNoCache(n.openStart+t),end:i.resolveNoCache(i.content.size-n.openEnd-t)}}var Lr=class n{constructor(e,t,r){this.pos=e,this.path=t,this.parentOffset=r,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 new 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 new 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 r=this.pos-this.path[this.path.length-1],i=e.child(t);return r?e.child(t).cut(r):i}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 r=this.path[t*3],i=t==0?0:this.path[t*3-1]+1;for(let o=0;o0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos=0;r--)if(e.pos<=this.end(r)&&(!t||t(this.node(r))))return new zt(this,e,r);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&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let r=[],i=0,o=t;for(let s=e;;){let{index:l,offset:a}=s.content.findIndex(o),c=o-a;if(r.push(s,l,i+a),!c||(s=s.child(l),s.isText))break;o=c-1,i+=a+1}return new n(t,r,o)}static resolveCached(e,t){let r=Hs.get(e);if(r)for(let o=0;oe&&this.nodesBetween(e,t,o=>(r.isInSet(o.marks)&&(i=!0),!i)),i}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()+")"),rl(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,r=S.empty,i=0,o=r.childCount){let s=this.contentMatchAt(e).matchFragment(r,i,o),l=s&&s.matchFragment(this.content,t);if(!l||!l.validEnd)return!1;for(let a=i;at.type.name)}`);this.content.forEach(t=>t.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(t=>t.toJSON())),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let r;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=t.marks.map(e.markFromJSON)}if(t.type=="text"){if(typeof t.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(t.text,r)}let i=S.fromJSON(e,t.content),o=e.nodeType(t.type).create(t.attrs,i,r);return o.type.checkAttrs(o.attrs),o}};Re.prototype.text=void 0;var Hi=class n extends Re{constructor(e,t,r,i){if(super(e,t,null,i),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):rl(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new n(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new n(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(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 rl(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}var Vt=class n{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let r=new Wi(e,t);if(r.next==null)return n.empty;let i=il(r);r.next&&r.err("Unexpected trailing text");let o=fu(cu(i));return uu(o,r),o}matchType(e){for(let t=0;tc.createAndFill()));for(let c=0;c=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(r){e.push(r);for(let i=0;i{let o=i+(r.validEnd?"*":" ")+" ";for(let s=0;s"+e.indexOf(r.next[s].next);return o}).join(` -`)}};Vt.empty=new Vt(!0);var Wi=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 new SyntaxError(e+" (in content expression '"+this.string+"')")}};function il(n){let e=[];do e.push(iu(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function iu(n){let e=[];do e.push(ou(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function ou(n){let e=au(n);for(;;)if(n.eat("+"))e={type:"plus",expr:e};else if(n.eat("*"))e={type:"star",expr:e};else if(n.eat("?"))e={type:"opt",expr:e};else if(n.eat("{"))e=su(n,e);else break;return e}function Ws(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function su(n,e){let t=Ws(n),r=t;return n.eat(",")&&(n.next!="}"?r=Ws(n):r=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:r,expr:e}}function lu(n,e){let t=n.nodeTypes,r=t[e];if(r)return[r];let i=[];for(let o in t){let s=t[o];s.isInGroup(e)&&i.push(s)}return i.length==0&&n.err("No node type or group '"+e+"' found"),i}function au(n){if(n.eat("(")){let e=il(n);return n.eat(")")||n.err("Missing closing paren"),e}else if(/\W/.test(n.next))n.err("Unexpected token '"+n.next+"'");else{let e=lu(n,n.next).map(t=>(n.inline==null?n.inline=t.isInline:n.inline!=t.isInline&&n.err("Mixing inline and block content"),{type:"name",value:t}));return n.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function cu(n){let e=[[]];return i(o(n,0),t()),e;function t(){return e.push([])-1}function r(s,l,a){let c={term:a,to:l};return e[s].push(c),c}function i(s,l){s.forEach(a=>a.to=l)}function o(s,l){if(s.type=="choice")return s.exprs.reduce((a,c)=>a.concat(o(c,l)),[]);if(s.type=="seq")for(let a=0;;a++){let c=o(s.exprs[a],l);if(a==s.exprs.length-1)return c;i(c,l=t())}else if(s.type=="star"){let a=t();return r(l,a),i(o(s.expr,a),a),[r(a)]}else if(s.type=="plus"){let a=t();return i(o(s.expr,l),a),i(o(s.expr,a),a),[r(a)]}else{if(s.type=="opt")return[r(l)].concat(o(s.expr,l));if(s.type=="range"){let a=l;for(let c=0;c{n[s].forEach(({term:l,to:a})=>{if(!l)return;let c;for(let f=0;f{c||i.push([l,c=[]]),c.indexOf(f)==-1&&c.push(f)})})});let o=e[r.join(",")]=new Vt(r.indexOf(n.length-1)>-1);for(let s=0;s-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:ll(this.attrs,e)}create(e=null,t,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Re(this,this.computeAttrs(e),S.from(t),$.setFrom(r))}createChecked(e=null,t,r){return t=S.from(t),this.checkContent(t),new Re(this,this.computeAttrs(e),t,$.setFrom(r))}createAndFill(e=null,t,r){if(e=this.computeAttrs(e),t=S.from(t),t.size){let s=this.contentMatch.fillBefore(t);if(!s)return null;t=s.append(t)}let i=this.contentMatch.matchFragment(t),o=i&&i.fillBefore(S.empty,!0);return o?new Re(this,e,t.append(o),$.setFrom(r)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let r=0;r-1}allowsMarks(e){if(this.markSet==null)return!0;for(let t=0;tr[o]=new n(o,t,s));let i=t.spec.topNode||"doc";if(!r[i])throw new RangeError("Schema is missing its top node type ('"+i+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let o in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function du(n,e,t){let r=t.split("|");return i=>{let o=i===null?"null":typeof i;if(r.indexOf(o)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${n}, got ${o}`)}}var ji=class{constructor(e,t,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?du(e,t,r.validate):r.validate}get isRequired(){return!this.hasDefault}},Hn=class n{constructor(e,t,r,i){this.name=e,this.rank=t,this.schema=r,this.spec=i,this.attrs=cl(e,i.attrs),this.excluded=null;let o=sl(this.attrs);this.instance=o?new $(this,o):null}create(e=null){return!e&&this.instance?this.instance:new $(this,ll(this.attrs,e))}static compile(e,t){let r=Object.create(null),i=0;return e.forEach((o,s)=>r[o]=new n(o,i++,t,s)),r}removeFromSet(e){for(var t=0;t-1}},Wn=class{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let i in e)t[i]=e[i];t.nodes=Li.from(e.nodes),t.marks=Li.from(e.marks||{}),this.nodes=Fr.compile(this.spec.nodes,this),this.marks=Hn.compile(this.spec.marks,this);let r=Object.create(null);for(let i in this.nodes){if(i in this.marks)throw new RangeError(i+" can not be both a node and a mark");let o=this.nodes[i],s=o.spec.content||"",l=o.spec.marks;if(o.contentMatch=r[s]||(r[s]=Vt.parse(s,this.nodes)),o.inlineContent=o.contentMatch.inlineContent,o.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!o.isInline||!o.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=o}o.markSet=l=="_"?null:l?qs(this,l.split(" ")):l==""||!o.inlineContent?[]:null}for(let i in this.marks){let o=this.marks[i],s=o.spec.excludes;o.excluded=s==null?[o]:s==""?[]:qs(this,s.split(" "))}this.nodeFromJSON=this.nodeFromJSON.bind(this),this.markFromJSON=this.markFromJSON.bind(this),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,r,i){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof Fr){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(t,r,i)}text(e,t){let r=this.nodes.text;return new Hi(r,r.defaultAttrs,e,$.setFrom(t))}mark(e,t){return typeof e=="string"&&(e=this.marks[e]),e.create(t)}nodeFromJSON(e){return Re.fromJSON(this,e)}markFromJSON(e){return $.fromJSON(this,e)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}};function qs(n,e){let t=[];for(let r=0;r-1)&&t.push(s=a)}if(!s)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return t}function pu(n){return n.tag!=null}function hu(n){return n.style!=null}var at=class n{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let r=this.matchedStyles=[];t.forEach(i=>{if(pu(i))this.tags.push(i);else if(hu(i)){let o=/[^=]*/.exec(i.style)[0];r.indexOf(o)<0&&r.push(o),this.styles.push(i)}}),this.normalizeLists=!this.tags.some(i=>{if(!/^(ul|ol)\b/.test(i.tag)||!i.node)return!1;let o=e.nodes[i.node];return o.contentMatch.matchType(o)})}parse(e,t={}){let r=new zr(this,t,!1);return r.addAll(e,$.none,t.from,t.to),r.finish()}parseSlice(e,t={}){let r=new zr(this,t,!0);return r.addAll(e,$.none,t.from,t.to),M.maxOpen(r.finish())}matchTag(e,t,r){for(let i=r?this.tags.indexOf(r)+1:0;ie.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=t))){if(s.getAttrs){let a=s.getAttrs(t);if(a===!1)continue;s.attrs=a||void 0}return s}}}static schemaRules(e){let t=[];function r(i){let o=i.priority==null?50:i.priority,s=0;for(;s{r(s=_s(s)),s.mark||s.ignore||s.clearMark||(s.mark=i)})}for(let i in e.nodes){let o=e.nodes[i].spec.parseDOM;o&&o.forEach(s=>{r(s=_s(s)),s.node||s.ignore||s.mark||(s.node=i)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new n(e,n.schemaRules(e)))}},fl={address:!0,article:!0,aside:!0,blockquote:!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},mu={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},ul={ol:!0,ul:!0},jn=1,qi=2,$n=4;function Js(n,e,t){return e!=null?(e?jn:0)|(e==="full"?qi:0):n&&n.whitespace=="pre"?jn|qi:t&~$n}var hn=class{constructor(e,t,r,i,o,s){this.type=e,this.attrs=t,this.marks=r,this.solid=i,this.options=s,this.content=[],this.activeMarks=$.none,this.match=o||(s&$n?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(S.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let r=this.type.contentMatch,i;return(i=r.findWrapping(e.type))?(this.match=r,i):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&jn)){let r=this.content[this.content.length-1],i;if(r&&r.isText&&(i=/[ \t\r\n\u000c]+$/.exec(r.text))){let o=r;r.text.length==i[0].length?this.content.pop():this.content[this.content.length-1]=o.withText(o.text.slice(0,o.text.length-i[0].length))}}let t=S.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(S.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&&!fl.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}},zr=class{constructor(e,t,r){this.parser=e,this.options=t,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let i=t.topNode,o,s=Js(null,t.preserveWhitespace,0)|(r?$n:0);i?o=new hn(i.type,i.attrs,$.none,!0,t.topMatch||i.type.contentMatch,s):r?o=new hn(null,null,$.none,!0,null,s):o=new hn(e.schema.topNodeType,null,$.none,!0,null,s),this.nodes=[o],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 r=e.nodeValue,i=this.top,o=i.options&qi?"full":this.localPreserveWS||(i.options&jn)>0;if(o==="full"||i.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(o)o!=="full"?r=r.replace(/\r?\n|\r/g," "):r=r.replace(/\r\n?/g,` -`);else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let s=i.content[i.content.length-1],l=e.previousSibling;(!s||l&&l.nodeName=="BR"||s.isText&&/[ \t\r\n\u000c]$/.test(s.text))&&(r=r.slice(1))}r&&this.insertNode(this.parser.schema.text(r),t),this.findInText(e)}else this.findInside(e)}addElement(e,t,r){let i=this.localPreserveWS,o=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let s=e.nodeName.toLowerCase(),l;ul.hasOwnProperty(s)&&this.parser.normalizeLists&&gu(e);let a=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,r));e:if(a?a.ignore:mu.hasOwnProperty(s))this.findInside(e),this.ignoreFallback(e,t);else if(!a||a.skip||a.closeParent){a&&a.closeParent?this.open=Math.max(0,this.open-1):a&&a.skip.nodeType&&(e=a.skip);let c,f=this.needsBlock;if(fl.hasOwnProperty(s))o.content.length&&o.content[0].isInline&&this.open&&(this.open--,o=this.top),c=!0,o.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break e}let u=a&&a.skip?t:this.readStyles(e,t);u&&this.addAll(e,u),c&&this.sync(o),this.needsBlock=f}else{let c=this.readStyles(e,t);c&&this.addElementByRule(e,a,c,a.consuming===!1?l:void 0)}this.localPreserveWS=i}leafFallback(e,t){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(` -`),t)}ignoreFallback(e,t){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),t)}readStyles(e,t){let r=e.style;if(r&&r.length)for(let i=0;i!a.clearMark(c)):t=t.concat(this.parser.schema.marks[a.mark].create(a.attrs)),a.consuming===!1)l=a;else break}}return t}addElementByRule(e,t,r,i){let o,s;if(t.node)if(s=this.parser.schema.nodes[t.node],s.isLeaf)this.insertNode(s.create(t.attrs),r)||this.leafFallback(e,r);else{let a=this.enter(s,t.attrs||null,r,t.preserveWhitespace);a&&(o=!0,r=a)}else{let a=this.parser.schema.marks[t.mark];r=r.concat(a.create(t.attrs))}let l=this.top;if(s&&s.isLeaf)this.findInside(e);else if(i)this.addElement(e,r,i);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a,r));else{let a=e;typeof t.contentElement=="string"?a=e.querySelector(t.contentElement):typeof t.contentElement=="function"?a=t.contentElement(e):t.contentElement&&(a=t.contentElement),this.findAround(e,a,!0),this.addAll(a,r),this.findAround(e,a,!1)}o&&this.sync(l)&&this.open--}addAll(e,t,r,i){let o=r||0;for(let s=r?e.childNodes[r]:e.firstChild,l=i==null?null:e.childNodes[i];s!=l;s=s.nextSibling,++o)this.findAtPoint(e,o),this.addDOM(s,t);this.findAtPoint(e,o)}findPlace(e,t){let r,i;for(let o=this.open;o>=0;o--){let s=this.nodes[o],l=s.findWrapping(e);if(l&&(!r||r.length>l.length)&&(r=l,i=s,!l.length)||s.solid)break}if(!r)return null;this.sync(i);for(let o=0;o(s.type?s.type.allowsMarkType(c.type):Ks(c.type,e))?(a=c.addToSet(a),!1):!0),this.nodes.push(new hn(e,t,a,i,null,l)),this.open++,r}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;this.localPreserveWS&&(this.nodes[t].options|=jn)}return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let r=this.nodes[t].content;for(let i=r.length-1;i>=0;i--)e+=r[i].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let r=0;r-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),r=this.options.context,i=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),o=-(r?r.depth+1:0)+(i?0:1),s=(l,a)=>{for(;l>=0;l--){let c=t[l];if(c==""){if(l==t.length-1||l==0)continue;for(;a>=o;a--)if(s(l-1,a))return!0;return!1}else{let f=a>0||a==0&&i?this.nodes[a].type:r&&a>=o?r.node(a-o).type:null;if(!f||f.name!=c&&!f.isInGroup(c))return!1;a--}}return!0};return s(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let r=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let t in this.parser.schema.nodes){let r=this.parser.schema.nodes[t];if(r.isTextblock&&r.defaultAttrs)return r}}};function gu(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&ul.hasOwnProperty(r)&&t?(t.appendChild(e),e=t):r=="li"?t=e:r&&(t=null)}}function yu(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function _s(n){let e={};for(let t in n)e[t]=n[t];return e}function Ks(n,e){let t=e.schema.nodes;for(let r in t){let i=t[r];if(!i.allowsMarkType(n))continue;let o=[],s=l=>{o.push(l);for(let a=0;a{if(o.length||s.marks.length){let l=0,a=0;for(;l=0;i--){let o=this.serializeMark(e.marks[i],e.isInline,t);o&&((o.contentDOM||o.dom).appendChild(r),r=o.dom)}return r}serializeMark(e,t,r={}){let i=this.marks[e.type.name];return i&&Ir(zi(r),i(e,t),null,e.attrs)}static renderSpec(e,t,r=null,i){return Ir(e,t,r,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new n(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=Us(e.nodes);return t.text||(t.text=r=>r.text),t}static marksFromSchema(e){return Us(e.marks)}};function Us(n){let e={};for(let t in n){let r=n[t].spec.toDOM;r&&(e[t]=r)}return e}function zi(n){return n.document||window.document}var Gs=new WeakMap;function bu(n){let e=Gs.get(n);return e===void 0&&Gs.set(n,e=vu(n)),e}function vu(n){let e=null;function t(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let i=0;i-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let s=i.indexOf(" ");s>0&&(t=i.slice(0,s),i=i.slice(s+1));let l,a=t?n.createElementNS(t,i):n.createElement(i),c=e[1],f=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){f=2;for(let u in c)if(c[u]!=null){let d=u.indexOf(" ");d>0?a.setAttributeNS(u.slice(0,d),u.slice(d+1),c[u]):a.setAttribute(u,c[u])}}for(let u=f;uf)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else{let{dom:p,contentDOM:h}=Ir(n,d,t,r);if(a.appendChild(p),h){if(l)throw new RangeError("Multiple content holes");l=h}}}return{dom:a,contentDOM:l}}var hl=65535,ml=Math.pow(2,16);function xu(n,e){return n+e*ml}function dl(n){return n&hl}function ku(n){return(n-(n&hl))/ml}var gl=1,yl=2,Vr=4,bl=8,_n=class{constructor(e,t,r){this.pos=e,this.delInfo=t,this.recover=r}get deleted(){return(this.delInfo&bl)>0}get deletedBefore(){return(this.delInfo&(gl|Vr))>0}get deletedAfter(){return(this.delInfo&(yl|Vr))>0}get deletedAcross(){return(this.delInfo&Vr)>0}},ft=class n{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&n.empty)return n.empty}recover(e){let t=0,r=dl(e);if(!this.inverted)for(let i=0;ie)break;let c=this.ranges[l+o],f=this.ranges[l+s],u=a+c;if(e<=u){let d=c?e==a?-1:e==u?1:t:t,p=a+i+(d<0?0:f);if(r)return p;let h=e==(t<0?a:u)?null:xu(l/3,e-a),m=e==a?yl:e==u?gl:Vr;return(t<0?e!=a:e!=u)&&(m|=bl),new _n(p,m,h)}i+=f-c}return r?e+i:new _n(e+i,0,null)}touches(e,t){let r=0,i=dl(t),o=this.inverted?2:1,s=this.inverted?1:2;for(let l=0;le)break;let c=this.ranges[l+o],f=a+c;if(e<=f&&l==i*3)return!0;r+=this.ranges[l+s]-c}return!1}forEach(e){let t=this.inverted?2:1,r=this.inverted?1:2;for(let i=0,o=0;i=0;t--){let i=e.getMirror(t);this.appendMap(e.maps[t].invert(),i!=null&&i>t?r-i-1:void 0)}}invert(){let e=new n;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let r=this.from;ro&&a!s.isAtom||!l.type.allowsMarkType(this.mark.type)?s:s.mark(this.mark.addToSet(s.marks)),i),t.openStart,t.openEnd);return de.fromReplace(e,this.from,this.to,o)}invert(){return new $t(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new n(t.pos,r.pos,this.mark)}merge(e){return e instanceof n&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new n(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new n(t.from,t.to,e.markFromJSON(t.mark))}};oe.jsonID("addMark",Un);var $t=class n extends oe{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=new M(Yi(t.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),t.openStart,t.openEnd);return de.fromReplace(e,this.from,this.to,r)}invert(){return new Un(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new n(t.pos,r.pos,this.mark)}merge(e){return e instanceof n&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new n(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new n(t.from,t.to,e.markFromJSON(t.mark))}};oe.jsonID("removeMark",$t);var Gn=class n extends oe{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return de.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return de.fromReplace(e,this.pos,this.pos+1,new M(S.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let r=this.mark.addToSet(t.marks);if(r.length==t.marks.length){for(let i=0;ir.pos?null:new n(t.pos,r.pos,i,o,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(e,t){if(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new n(t.from,t.to,t.gapFrom,t.gapTo,M.fromJSON(e,t.slice),t.insert,!!t.structure)}};oe.jsonID("replaceAround",Q);function Ui(n,e,t){let r=n.resolve(e),i=t-e,o=r.depth;for(;i>0&&o>0&&r.indexAfter(o)==r.node(o).childCount;)o--,i--;if(i>0){let s=r.node(o).maybeChild(r.indexAfter(o));for(;i>0;){if(!s||s.isLeaf)return!0;s=s.firstChild,i--}}return!1}function Su(n,e,t,r){let i=[],o=[],s,l;n.doc.nodesBetween(e,t,(a,c,f)=>{if(!a.isInline)return;let u=a.marks;if(!r.isInSet(u)&&f.type.allowsMarkType(r.type)){let d=Math.max(c,e),p=Math.min(c+a.nodeSize,t),h=r.addToSet(u);for(let m=0;mn.step(a)),o.forEach(a=>n.step(a))}function wu(n,e,t,r){let i=[],o=0;n.doc.nodesBetween(e,t,(s,l)=>{if(!s.isInline)return;o++;let a=null;if(r instanceof Hn){let c=s.marks,f;for(;f=r.isInSet(c);)(a||(a=[])).push(f),c=f.removeFromSet(c)}else r?r.isInSet(s.marks)&&(a=[r]):a=s.marks;if(a&&a.length){let c=Math.min(l+s.nodeSize,t);for(let f=0;fn.step(new $t(s.from,s.to,s.style)))}function Xi(n,e,t,r=t.contentMatch,i=!0){let o=n.doc.nodeAt(e),s=[],l=e+1;for(let a=0;a=0;a--)n.step(s[a])}function Mu(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function ut(n){let t=n.parent.content.cutByIndex(n.startIndex,n.endIndex);for(let r=n.depth;;--r){let i=n.$from.node(r),o=n.$from.index(r),s=n.$to.indexAfter(r);if(rt;h--)m||r.index(h)>0?(m=!0,f=S.from(r.node(h).copy(f)),u++):a--;let d=S.empty,p=0;for(let h=o,m=!1;h>t;h--)m||i.after(h+1)=0;s--){if(r.size){let l=t[s].type.contentMatch.matchFragment(r);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=S.from(t[s].type.create(t[s].attrs,r))}let i=e.start,o=e.end;n.step(new Q(i,o,i,o,new M(r,0,0),t.length,!0))}function Au(n,e,t,r,i){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let o=n.steps.length;n.doc.nodesBetween(e,t,(s,l)=>{let a=typeof i=="function"?i(s):i;if(s.isTextblock&&!s.hasMarkup(r,a)&&Nu(n.doc,n.mapping.slice(o).map(l),r)){let c=null;if(r.schema.linebreakReplacement){let p=r.whitespace=="pre",h=!!r.contentMatch.matchType(r.schema.linebreakReplacement);p&&!h?c=!1:!p&&h&&(c=!0)}c===!1&&xl(n,s,l,o),Xi(n,n.mapping.slice(o).map(l,1),r,void 0,c===null);let f=n.mapping.slice(o),u=f.map(l,1),d=f.map(l+s.nodeSize,1);return n.step(new Q(u,d,u+1,d-1,new M(S.from(r.create(a,null,s.marks)),0,0),1,!0)),c===!0&&vl(n,s,l,o),!1}})}function vl(n,e,t,r){e.forEach((i,o)=>{if(i.isText){let s,l=/\r?\n|\r/g;for(;s=l.exec(i.text);){let a=n.mapping.slice(r).map(t+1+o+s.index);n.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function xl(n,e,t,r){e.forEach((i,o)=>{if(i.type==i.type.schema.linebreakReplacement){let s=n.mapping.slice(r).map(t+1+o);n.replaceWith(s,s+1,e.type.schema.text(` -`))}})}function Nu(n,e,t){let r=n.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,t)}function Du(n,e,t,r,i){let o=n.doc.nodeAt(e);if(!o)throw new RangeError("No node at given position");t||(t=o.type);let s=t.create(r,null,i||o.marks);if(o.isLeaf)return n.replaceWith(e,e+o.nodeSize,s);if(!t.validContent(o.content))throw new RangeError("Invalid content for node type "+t.name);n.step(new Q(e,e+o.nodeSize,e+1,e+o.nodeSize-1,new M(S.from(s),0,0),1,!0))}function Be(n,e,t=1,r){let i=n.resolve(e),o=i.depth-t,s=r&&r[r.length-1]||i.parent;if(o<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!s.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let c=i.depth-1,f=t-2;c>o;c--,f--){let u=i.node(c),d=i.index(c);if(u.type.spec.isolating)return!1;let p=u.content.cutByIndex(d,u.childCount),h=r&&r[f+1];h&&(p=p.replaceChild(0,h.type.create(h.attrs)));let m=r&&r[f]||u;if(!u.canReplace(d+1,u.childCount)||!m.type.validContent(p))return!1}let l=i.indexAfter(o),a=r&&r[0];return i.node(o).canReplaceWith(l,l,a?a.type:i.node(o+1).type)}function Pu(n,e,t=1,r){let i=n.doc.resolve(e),o=S.empty,s=S.empty;for(let l=i.depth,a=i.depth-t,c=t-1;l>a;l--,c--){o=S.from(i.node(l).copy(o));let f=r&&r[c];s=S.from(f?f.type.create(f.attrs,s):i.node(l).copy(s))}n.step(new be(e,e,new M(o.append(s),t,t),!0))}function qe(n,e){let t=n.resolve(e),r=t.index();return kl(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(r,r+1)}function Iu(n,e){e.content.size||n.type.compatibleContent(e.type);let t=n.contentMatchAt(n.childCount),{linebreakReplacement:r}=n.type.schema;for(let i=0;i0?(o=r.node(i+1),l++,s=r.node(i).maybeChild(l)):(o=r.node(i).maybeChild(l-1),s=r.node(i+1)),o&&!o.isTextblock&&kl(o,s)&&r.node(i).canReplace(l,l+1))return e;if(i==0)break;e=t<0?r.before(i):r.after(i)}}function Ru(n,e,t){let r=null,{linebreakReplacement:i}=n.doc.type.schema,o=n.doc.resolve(e-t),s=o.node().type;if(i&&s.inlineContent){let f=s.whitespace=="pre",u=!!s.contentMatch.matchType(i);f&&!u?r=!1:!f&&u&&(r=!0)}let l=n.steps.length;if(r===!1){let f=n.doc.resolve(e+t);xl(n,f.node(),f.before(),l)}s.inlineContent&&Xi(n,e+t-1,s,o.node().contentMatchAt(o.index()),r==null);let a=n.mapping.slice(l),c=a.map(e-t);if(n.step(new be(c,a.map(e+t,-1),M.empty,!0)),r===!0){let f=n.doc.resolve(c);vl(n,f.node(),f.before(),n.steps.length)}return n}function Bu(n,e,t){let r=n.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),t))return e;if(r.parentOffset==0)for(let i=r.depth-1;i>=0;i--){let o=r.index(i);if(r.node(i).canReplaceWith(o,o,t))return r.before(i+1);if(o>0)return null}if(r.parentOffset==r.parent.content.size)for(let i=r.depth-1;i>=0;i--){let o=r.indexAfter(i);if(r.node(i).canReplaceWith(o,o,t))return r.after(i+1);if(o=0;s--){let l=s==r.depth?0:r.pos<=(r.start(s+1)+r.end(s+1))/2?-1:1,a=r.index(s)+(l>0?1:0),c=r.node(s),f=!1;if(o==1)f=c.canReplace(a,a,i);else{let u=c.contentMatchAt(a).findWrapping(i.firstChild.type);f=u&&c.canReplaceWith(a,a,u[0])}if(f)return l==0?r.pos:l<0?r.before(s+1):r.after(s+1)}return null}function Zn(n,e,t=e,r=M.empty){if(e==t&&!r.size)return null;let i=n.resolve(e),o=n.resolve(t);return Sl(i,o,r)?new be(e,t,r):new Gi(i,o,r).fit()}function Sl(n,e,t){return!t.openStart&&!t.openEnd&&n.start()==e.start()&&n.parent.canReplace(n.index(),e.index(),t.content)}var Gi=class{constructor(e,t,r){this.$from=e,this.$to=t,this.unplaced=r,this.frontier=[],this.placed=S.empty;for(let i=0;i<=e.depth;i++){let o=e.node(i);this.frontier.push({type:o.type,match:o.contentMatchAt(e.indexAfter(i))})}for(let i=e.depth;i>0;i--)this.placed=S.from(e.node(i).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let c=this.findFittable();c?this.placeNodes(c):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,r=this.$from,i=this.close(e<0?this.$to:r.doc.resolve(e));if(!i)return null;let o=this.placed,s=r.depth,l=i.depth;for(;s&&l&&o.childCount==1;)o=o.firstChild.content,s--,l--;let a=new M(o,s,l);return e>-1?new Q(r.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||r.pos!=this.$to.pos?new be(r.pos,i.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,r=0,i=this.unplaced.openEnd;r1&&(i=0),o.type.spec.isolating&&i<=r){e=r;break}t=o.content}for(let t=1;t<=2;t++)for(let r=t==1?e:this.unplaced.openStart;r>=0;r--){let i,o=null;r?(o=_i(this.unplaced.content,r-1).firstChild,i=o.content):i=this.unplaced.content;let s=i.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:c}=this.frontier[l],f,u=null;if(t==1&&(s?c.matchType(s.type)||(u=c.fillBefore(S.from(s),!1)):o&&a.compatibleContent(o.type)))return{sliceDepth:r,frontierDepth:l,parent:o,inject:u};if(t==2&&s&&(f=c.findWrapping(s.type)))return{sliceDepth:r,frontierDepth:l,parent:o,wrap:f};if(o&&c.matchType(o.type))break}}}openMore(){let{content:e,openStart:t,openEnd:r}=this.unplaced,i=_i(e,t);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new M(e,t+1,Math.max(r,i.size+t>=e.size-r?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:r}=this.unplaced,i=_i(e,t);if(i.childCount<=1&&t>0){let o=e.size-t<=t+i.size;this.unplaced=new M(qn(e,t-1,1),t-1,o?t-1:r)}else this.unplaced=new M(qn(e,t,1),t,r)}placeNodes({sliceDepth:e,frontierDepth:t,parent:r,inject:i,wrap:o}){for(;this.depth>t;)this.closeFrontierNode();if(o)for(let m=0;m1||a==0||m.content.size)&&(u=g,f.push(wl(m.mark(d.allowedMarks(m.marks)),c==1?a:0,c==l.childCount?p:-1)))}let h=c==l.childCount;h||(p=-1),this.placed=Jn(this.placed,t,S.from(f)),this.frontier[t].match=u,h&&p<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let m=0,g=l;m1&&i==this.$to.end(--r);)++i;return i}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:r,type:i}=this.frontier[t],o=t=0;l--){let{match:a,type:c}=this.frontier[l],f=Ki(e,l,c,a,!0);if(!f||f.childCount)continue e}return{depth:t,fit:s,move:o?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=Jn(this.placed,t.depth,t.fit)),e=t.move;for(let r=t.depth+1;r<=e.depth;r++){let i=e.node(r),o=i.type.contentMatch.fillBefore(i.content,!0,e.index(r));this.openFrontierNode(i.type,i.attrs,o)}return e}openFrontierNode(e,t=null,r){let i=this.frontier[this.depth];i.match=i.match.matchType(e),this.placed=Jn(this.placed,this.depth,S.from(e.create(t,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(S.empty,!0);t.childCount&&(this.placed=Jn(this.placed,this.frontier.length,t))}};function qn(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(qn(n.firstChild.content,e-1,t)))}function Jn(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy(Jn(n.lastChild.content,e-1,t)))}function _i(n,e){for(let t=0;t1&&(r=r.replaceChild(0,wl(r.firstChild,e-1,r.childCount==1?t-1:0))),e>0&&(r=n.type.contentMatch.fillBefore(r).append(r),t<=0&&(r=r.append(n.type.contentMatch.matchFragment(r).fillBefore(S.empty,!0)))),n.copy(r)}function Ki(n,e,t,r,i){let o=n.node(e),s=i?n.indexAfter(e):n.index(e);if(s==o.childCount&&!t.compatibleContent(o.type))return null;let l=r.fillBefore(o.content,!0,s);return l&&!Lu(t,o.content,s)?l:null}function Lu(n,e,t){for(let r=t;r0;d--,p--){let h=i.node(d).type.spec;if(h.defining||h.definingAsContext||h.isolating)break;s.indexOf(d)>-1?l=d:i.before(d)==p&&s.splice(1,0,-d)}let a=s.indexOf(l),c=[],f=r.openStart;for(let d=r.content,p=0;;p++){let h=d.firstChild;if(c.push(h),p==r.openStart)break;d=h.content}for(let d=f-1;d>=0;d--){let p=c[d],h=Fu(p.type);if(h&&!p.sameMarkup(i.node(Math.abs(l)-1)))f=d;else if(h||!p.type.isTextblock)break}for(let d=r.openStart;d>=0;d--){let p=(d+f+1)%(r.openStart+1),h=c[p];if(h)for(let m=0;m=0&&(n.replace(e,t,r),!(n.steps.length>u));d--){let p=s[d];p<0||(e=i.before(p),t=o.after(p))}}function Ml(n,e,t,r,i){if(er){let o=i.contentMatchAt(0),s=o.fillBefore(n).append(n);n=s.append(o.matchFragment(s).fillBefore(S.empty,!0))}return n}function Vu(n,e,t,r){if(!r.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let i=Bu(n.doc,e,r.type);i!=null&&(e=t=i)}n.replaceRange(e,t,new M(S.from(r),0,0))}function $u(n,e,t){let r=n.doc.resolve(e),i=n.doc.resolve(t),o=Cl(r,i);for(let s=0;s0&&(a||r.node(l-1).canReplace(r.index(l-1),i.indexAfter(l-1))))return n.delete(r.before(l),i.after(l))}for(let s=1;s<=r.depth&&s<=i.depth;s++)if(e-r.start(s)==r.depth-s&&t>r.end(s)&&i.end(s)-t!=i.depth-s&&r.start(s-1)==i.start(s-1)&&r.node(s-1).canReplace(r.index(s-1),i.index(s-1)))return n.delete(r.before(s),t);n.delete(e,t)}function Cl(n,e){let t=[],r=Math.min(n.depth,e.depth);for(let i=r;i>=0;i--){let o=n.start(i);if(oe.pos+(e.depth-i)||n.node(i).type.spec.isolating||e.node(i).type.spec.isolating)break;(o==e.start(i)||i==n.depth&&i==e.depth&&n.parent.inlineContent&&e.parent.inlineContent&&i&&e.start(i-1)==o-1)&&t.push(i)}return t}var $r=class n extends oe{constructor(e,t,r){super(),this.pos=e,this.attr=t,this.value=r}apply(e){let t=e.nodeAt(this.pos);if(!t)return de.fail("No node at attribute step's position");let r=Object.create(null);for(let o in t.attrs)r[o]=t.attrs[o];r[this.attr]=this.value;let i=t.type.create(r,null,t.marks);return de.fromReplace(e,this.pos,this.pos+1,new M(S.from(i),0,t.isLeaf?0:1))}getMap(){return ft.empty}invert(e){return new n(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new n(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.pos!="number"||typeof t.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new n(t.pos,t.attr,t.value)}};oe.jsonID("attr",$r);var Hr=class n extends oe{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let i in e.attrs)t[i]=e.attrs[i];t[this.attr]=this.value;let r=e.type.create(t,e.content,e.marks);return de.ok(r)}getMap(){return ft.empty}invert(e){return new n(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new n(t.attr,t.value)}};oe.jsonID("docAttr",Hr);var mn=class extends Error{};mn=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t};mn.prototype=Object.create(Error.prototype);mn.prototype.constructor=mn;mn.prototype.name="TransformError";var Xn=class{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Kn}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new mn(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}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,r=M.empty){let i=Zn(this.doc,e,t,r);return i&&this.step(i),this}replaceWith(e,t,r){return this.replace(e,t,new M(S.from(r),0,0))}delete(e,t){return this.replace(e,t,M.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,r){return zu(this,e,t,r),this}replaceRangeWith(e,t,r){return Vu(this,e,t,r),this}deleteRange(e,t){return $u(this,e,t),this}lift(e,t){return Cu(this,e,t),this}join(e,t=1){return Ru(this,e,t),this}wrap(e,t){return Eu(this,e,t),this}setBlockType(e,t=e,r,i=null){return Au(this,e,t,r,i),this}setNodeMarkup(e,t,r=null,i){return Du(this,e,t,r,i),this}setNodeAttribute(e,t,r){return this.step(new $r(e,t,r)),this}setDocAttribute(e,t){return this.step(new Hr(e,t)),this}addNodeMark(e,t){return this.step(new Gn(e,t)),this}removeNodeMark(e,t){if(!(t instanceof $)){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(t=t.isInSet(r.marks),!t)return this}return this.step(new Yn(e,t)),this}split(e,t=1,r){return Pu(this,e,t,r),this}addMark(e,t,r){return Su(this,e,t,r),this}removeMark(e,t,r){return wu(this,e,t,r),this}clearIncompatible(e,t,r){return Xi(this,e,t,r),this}};var Zi=Object.create(null),D=class{constructor(e,t,r){this.$anchor=e,this.$head=t,this.ranges=r||[new qr(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;o--){let s=t<0?bn(e.node(0),e.node(o),e.before(o+1),e.index(o),t,r):bn(e.node(0),e.node(o),e.after(o+1),e.index(o)+1,t,r);if(s)return s}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new we(e.node(0))}static atStart(e){return bn(e,e,0,0,1)||new we(e)}static atEnd(e){return bn(e,e,e.content.size,e.childCount,-1)||new we(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Zi[t.type];if(!r)throw new RangeError(`No selection type ${t.type} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in Zi)throw new RangeError("Duplicate use of selection JSON ID "+e);return Zi[e]=t,t.prototype.jsonID=e,t}getBookmark(){return P.between(this.$anchor,this.$head).getBookmark()}};D.prototype.visible=!0;var qr=class{constructor(e,t){this.$from=e,this.$to=t}},Ol=!1;function Tl(n){!Ol&&!n.parent.inlineContent&&(Ol=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}var P=class n extends D{constructor(e,t=e){Tl(e),Tl(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let r=e.resolve(t.map(this.head));if(!r.parent.inlineContent)return D.near(r);let i=e.resolve(t.map(this.anchor));return new n(i.parent.inlineContent?i:r,r)}replace(e,t=M.empty){if(super.replace(e,t),t==M.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof n&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Jr(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if(typeof t.anchor!="number"||typeof t.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new n(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){let i=e.resolve(t);return new this(i,r==t?i:e.resolve(r))}static between(e,t,r){let i=e.pos-t.pos;if((!r||i)&&(r=i>=0?1:-1),!t.parent.inlineContent){let o=D.findFrom(t,r,!0)||D.findFrom(t,-r,!0);if(o)t=o.$head;else return D.near(t,r)}return e.parent.inlineContent||(i==0?e=t:(e=(D.findFrom(e,-r,!0)||D.findFrom(e,r,!0)).$anchor,e.pos0?0:1);i>0?s=0;s+=i){let l=e.child(s);if(l.isAtom){if(!o&&A.isSelectable(l))return A.create(n,t-(i<0?l.nodeSize:0))}else{let a=bn(n,l,t+i,i<0?l.childCount:0,i,o);if(a)return a}t+=l.nodeSize*i}return null}function El(n,e,t){let r=n.steps.length-1;if(r{s==null&&(s=f)}),n.setSelection(D.near(n.doc.resolve(s),t))}var Al=1,jr=2,Nl=4,to=class extends Xn{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|=jr,this}ensureMarks(e){return $.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&jr)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&~jr,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let r=this.selection;return t&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||$.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,r){let i=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(i.text(e),!0):this.deleteSelection();{if(r==null&&(r=t),r=r??t,!e)return this.deleteRange(t,r);let o=this.storedMarks;if(!o){let s=this.doc.resolve(t);o=r==t?s.marks():s.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(t,r,i.text(e,o)),this.selection.empty||this.setSelection(D.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|=Nl,this}get scrolledIntoView(){return(this.updated&Nl)>0}};function Dl(n,e){return!e||!n?n:n.bind(e)}var Ht=class{constructor(e,t,r){this.name=e,this.init=Dl(t.init,r),this.apply=Dl(t.apply,r)}},Wu=[new Ht("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new Ht("selection",{init(n,e){return n.selection||D.atStart(e.doc)},apply(n){return n.selection}}),new Ht("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,r){return r.selection.$cursor?n.storedMarks:null}}),new Ht("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}})],Qn=class{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=Wu.slice(),t&&t.forEach(r=>{if(this.pluginsByKey[r.key])throw new RangeError("Adding different instances of a keyed plugin ("+r.key+")");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new Ht(r.key,r.spec.state,r))})}},_r=class n{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 r=0;rr.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let i=e[r],o=i.spec.state;o&&o.toJSON&&(t[r]=o.toJSON.call(i,this[i.key]))}return t}static fromJSON(e,t,r){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let i=new Qn(e.schema,e.plugins),o=new n(i);return i.fields.forEach(s=>{if(s.name=="doc")o.doc=Re.fromJSON(e.schema,t.doc);else if(s.name=="selection")o.selection=D.fromJSON(o.doc,t.selection);else if(s.name=="storedMarks")t.storedMarks&&(o.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let l in r){let a=r[l],c=a.spec.state;if(a.key==s.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(t,l)){o[s.name]=c.fromJSON.call(a,e,t[l],o);return}}o[s.name]=s.init(e,o)}}),o}};function Pl(n,e,t){for(let r in n){let i=n[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=Pl(i,e,{})),t[r]=i}return t}var q=class{constructor(e){this.spec=e,this.props={},e.props&&Pl(e.props,this,this.props),this.key=e.key?e.key.key:Il("plugin")}getState(e){return e[this.key]}},Qi=Object.create(null);function Il(n){return n in Qi?n+"$"+ ++Qi[n]:(Qi[n]=0,n+"$")}var X=class{constructor(e="key"){this.key=Il(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}};var pe=function(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e},rr=function(n){let e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e},lo=null,pt=function(n,e,t){let r=lo||(lo=document.createRange());return r.setEnd(n,t??n.nodeValue.length),r.setStart(n,e||0),r},ju=function(){lo=null},Ut=function(n,e,t,r){return t&&(Rl(n,e,t,r,-1)||Rl(n,e,t,r,1))},qu=/^(img|br|input|textarea|hr)$/i;function Rl(n,e,t,r,i){for(;;){if(n==t&&e==r)return!0;if(e==(i<0?0:Fe(n))){let o=n.parentNode;if(!o||o.nodeType!=1||lr(n)||qu.test(n.nodeName)||n.contentEditable=="false")return!1;e=pe(n)+(i<0?0:1),n=o}else if(n.nodeType==1){if(n=n.childNodes[e+(i<0?-1:0)],n.contentEditable=="false")return!1;e=i<0?Fe(n):0}else return!1}}function Fe(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Ju(n,e){for(;;){if(n.nodeType==3&&e)return n;if(n.nodeType==1&&e>0){if(n.contentEditable=="false")return null;n=n.childNodes[e-1],e=Fe(n)}else if(n.parentNode&&!lr(n))e=pe(n),n=n.parentNode;else return null}}function _u(n,e){for(;;){if(n.nodeType==3&&e2),Le=wn||(Xe?/Mac/.test(Xe.platform):!1),Yu=Xe?/Win/.test(Xe.platform):!1,ht=/Android \d/.test(Tt),ar=!!Bl&&"webkitFontSmoothing"in Bl.documentElement.style,Xu=ar?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Zu(n){let e=n.defaultView&&n.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:n.documentElement.clientWidth,top:0,bottom:n.documentElement.clientHeight}}function dt(n,e){return typeof n=="number"?n:n[e]}function Qu(n){let e=n.getBoundingClientRect(),t=e.width/n.offsetWidth||1,r=e.height/n.offsetHeight||1;return{left:e.left,right:e.left+n.clientWidth*t,top:e.top,bottom:e.top+n.clientHeight*r}}function Ll(n,e,t){let r=n.someProp("scrollThreshold")||0,i=n.someProp("scrollMargin")||5,o=n.dom.ownerDocument;for(let s=t||n.dom;s;s=rr(s)){if(s.nodeType!=1)continue;let l=s,a=l==o.body,c=a?Zu(o):Qu(l),f=0,u=0;if(e.topc.bottom-dt(r,"bottom")&&(u=e.bottom-e.top>c.bottom-c.top?e.top+dt(i,"top")-c.top:e.bottom-c.bottom+dt(i,"bottom")),e.leftc.right-dt(r,"right")&&(f=e.right-c.right+dt(i,"right")),f||u)if(a)o.defaultView.scrollBy(f,u);else{let d=l.scrollLeft,p=l.scrollTop;u&&(l.scrollTop+=u),f&&(l.scrollLeft+=f);let h=l.scrollLeft-d,m=l.scrollTop-p;e={left:e.left-h,top:e.top-m,right:e.right-h,bottom:e.bottom-m}}if(a||/^(fixed|sticky)$/.test(getComputedStyle(s).position))break}}function ed(n){let e=n.dom.getBoundingClientRect(),t=Math.max(0,e.top),r,i;for(let o=(e.left+e.right)/2,s=t+1;s=t-20){r=l,i=a.top;break}}return{refDOM:r,refTop:i,stack:ma(n.dom)}}function ma(n){let e=[],t=n.ownerDocument;for(let r=n;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),n!=t);r=rr(r));return e}function td({refDOM:n,refTop:e,stack:t}){let r=n?n.getBoundingClientRect().top:0;ga(t,r==0?0:r-e)}function ga(n,e){for(let t=0;t=l){s=Math.max(h.bottom,s),l=Math.min(h.top,l);let m=h.left>e.left?h.left-e.left:h.right=(h.left+h.right)/2?1:0));continue}}else h.top>e.top&&!a&&h.left<=e.left&&h.right>=e.left&&(a=f,c={left:Math.max(h.left,Math.min(h.right,e.left)),top:h.top});!t&&(e.left>=h.right&&e.top>=h.top||e.left>=h.left&&e.top>=h.bottom)&&(o=u+1)}}return!t&&a&&(t=a,i=c,r=0),t&&t.nodeType==3?rd(t,i):!t||r&&t.nodeType==1?{node:n,offset:o}:ya(t,i)}function rd(n,e){let t=n.nodeValue.length,r=document.createRange();for(let i=0;i=(o.left+o.right)/2?1:0)}}return{node:n,offset:0}}function Oo(n,e){return n.left>=e.left-1&&n.left<=e.right+1&&n.top>=e.top-1&&n.top<=e.bottom+1}function id(n,e){let t=n.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left(s.left+s.right)/2?1:-1}return n.docView.posFromDOM(r,i,o)}function sd(n,e,t,r){let i=-1;for(let o=e,s=!1;o!=n.dom;){let l=n.docView.nearestDesc(o,!0),a;if(!l)return null;if(l.dom.nodeType==1&&(l.node.isBlock&&l.parent||!l.contentDOM)&&((a=l.dom.getBoundingClientRect()).width||a.height)&&(l.node.isBlock&&l.parent&&(!s&&a.left>r.left||a.top>r.top?i=l.posBefore:(!s&&a.right-1?i:n.docView.posFromDOM(e,t,-1)}function ba(n,e,t){let r=n.childNodes.length;if(r&&t.tope.top&&i++}let c;ar&&i&&r.nodeType==1&&(c=r.childNodes[i-1]).nodeType==1&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&i--,r==n.dom&&i==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?l=n.state.doc.content.size:(i==0||r.nodeType!=1||r.childNodes[i-1].nodeName!="BR")&&(l=sd(n,r,i,e))}l==null&&(l=od(n,s,e));let a=n.docView.nearestDesc(s,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function Fl(n){return n.top=0&&i==r.nodeValue.length?(a--,f=1):t<0?a--:c++,er(St(pt(r,a,c),f),f<0)}if(!n.state.doc.resolve(e-(o||0)).parent.inlineContent){if(o==null&&i&&(t<0||i==Fe(r))){let a=r.childNodes[i-1];if(a.nodeType==1)return no(a.getBoundingClientRect(),!1)}if(o==null&&i=0)}if(o==null&&i&&(t<0||i==Fe(r))){let a=r.childNodes[i-1],c=a.nodeType==3?pt(a,Fe(a)-(s?0:1)):a.nodeType==1&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(c)return er(St(c,1),!1)}if(o==null&&i=0)}function er(n,e){if(n.width==0)return n;let t=e?n.left:n.right;return{top:n.top,bottom:n.bottom,left:t,right:t}}function no(n,e){if(n.height==0)return n;let t=e?n.top:n.bottom;return{top:t,bottom:t,left:n.left,right:n.right}}function xa(n,e,t){let r=n.state,i=n.root.activeElement;r!=e&&n.updateState(e),i!=n.dom&&n.focus();try{return t()}finally{r!=e&&n.updateState(r),i!=n.dom&&i&&i.focus()}}function cd(n,e,t){let r=e.selection,i=t=="up"?r.$from:r.$to;return xa(n,e,()=>{let{node:o}=n.docView.domFromPos(i.pos,t=="up"?-1:1);for(;;){let l=n.docView.nearestDesc(o,!0);if(!l)break;if(l.node.isBlock){o=l.contentDOM||l.dom;break}o=l.dom.parentNode}let s=va(n,i.pos,1);for(let l=o.firstChild;l;l=l.nextSibling){let a;if(l.nodeType==1)a=l.getClientRects();else if(l.nodeType==3)a=pt(l,0,l.nodeValue.length).getClientRects();else continue;for(let c=0;cf.top+1&&(t=="up"?s.top-f.top>(f.bottom-s.top)*2:f.bottom-s.bottom>(s.bottom-f.top)*2))return!1}}return!0})}var fd=/[\u0590-\u08ac]/;function ud(n,e,t){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,o=!i,s=i==r.parent.content.size,l=n.domSelection();return l?!fd.test(r.parent.textContent)||!l.modify?t=="left"||t=="backward"?o:s:xa(n,e,()=>{let{focusNode:a,focusOffset:c,anchorNode:f,anchorOffset:u}=n.domSelectionRange(),d=l.caretBidiLevel;l.modify("move",t,"character");let p=r.depth?n.docView.domAfterPos(r.before()):n.dom,{focusNode:h,focusOffset:m}=n.domSelectionRange(),g=h&&!p.contains(h.nodeType==1?h:h.parentNode)||a==h&&c==m;try{l.collapse(f,u),a&&(a!=f||c!=u)&&l.extend&&l.extend(a,c)}catch{}return d!=null&&(l.caretBidiLevel=d),g}):r.pos==r.start()||r.pos==r.end()}var zl=null,Vl=null,$l=!1;function dd(n,e,t){return zl==e&&Vl==t?$l:(zl=e,Vl=t,$l=t=="up"||t=="down"?cd(n,e,t):ud(n,e,t))}var ze=0,Hl=1,jt=2,Ze=3,Gt=class{constructor(e,t,r,i){this.parent=e,this.children=t,this.dom=r,this.contentDOM=i,this.dirty=ze,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,r){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;tpe(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))i=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(t==0)for(let o=e;;o=o.parentNode){if(o==this.dom){i=!1;break}if(o.previousSibling)break}if(i==null&&t==e.childNodes.length)for(let o=e;;o=o.parentNode){if(o==this.dom){i=!0;break}if(o.nextSibling)break}}return i??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let r=!0,i=e;i;i=i.parentNode){let o=this.getDesc(i),s;if(o&&(!t||o.node))if(r&&(s=o.nodeDOM)&&!(s.nodeType==1?s.contains(e.nodeType==1?e:e.parentNode):s==e))r=!1;else return o}}getDesc(e){let t=e.pmViewDesc;for(let r=t;r;r=r.parent)if(r==this)return t}posFromDOM(e,t,r){for(let i=e;i;i=i.parentNode){let o=this.getDesc(i);if(o)return o.localPosFromDOM(e,t,r)}return-1}descAt(e){for(let t=0,r=0;te||s instanceof Gr){i=e-o;break}o=l}if(i)return this.children[r].domFromPos(i-this.children[r].border,t);for(let o;r&&!(o=this.children[r-1]).size&&o instanceof Kr&&o.side>=0;r--);if(t<=0){let o,s=!0;for(;o=r?this.children[r-1]:null,!(!o||o.dom.parentNode==this.contentDOM);r--,s=!1);return o&&t&&s&&!o.border&&!o.domAtom?o.domFromPos(o.size,t):{node:this.contentDOM,offset:o?pe(o.dom)+1:0}}else{let o,s=!0;for(;o=r=f&&t<=c-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,t,f);e=s;for(let u=l;u>0;u--){let d=this.children[u-1];if(d.size&&d.dom.parentNode==this.contentDOM&&!d.emptyChildAt(1)){i=pe(d.dom)+1;break}e-=d.size}i==-1&&(i=0)}if(i>-1&&(c>t||l==this.children.length-1)){t=c;for(let f=l+1;fh&&st){let h=l;l=a,a=h}let p=document.createRange();p.setEnd(a.node,a.offset),p.setStart(l.node,l.offset),c.removeAllRanges(),c.addRange(p)}}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 r=0,i=0;i=r:er){let l=r+o.border,a=s-o.border;if(e>=l&&t<=a){this.dirty=e==r||t==s?jt:Hl,e==l&&t==a&&(o.contentLost||o.dom.parentNode!=this.contentDOM)?o.dirty=Ze:o.markDirty(e-l,t-l);return}else o.dirty=o.dom==o.contentDOM&&o.dom.parentNode==this.contentDOM&&!o.children.length?jt:Ze}r=s}this.dirty=jt}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let r=e==1?jt:Hl;t.dirty{if(!o)return i;if(o.parent)return o.parent.posBeforeChild(o)})),!t.type.spec.raw){if(s.nodeType!=1){let l=document.createElement("span");l.appendChild(s),s=l}s.contentEditable="false",s.classList.add("ProseMirror-widget")}super(e,[],s,null),this.widget=t,this.widget=t,o=this}matchesWidget(e){return this.dirty==ze&&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 side(){return this.widget.type.side}},uo=class extends Gt{constructor(e,t,r,i){super(e,[],t,null),this.textDOM=r,this.text=i}get size(){return this.text.length}localPosFromDOM(e,t){return e!=this.textDOM?this.posAtStart+(t?this.size:0):this.posAtStart+t}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}},Mn=class n extends Gt{constructor(e,t,r,i,o){super(e,[],r,i),this.mark=t,this.spec=o}static create(e,t,r,i){let o=i.nodeViews[t.type.name],s=o&&o(t,i,r);return(!s||!s.dom)&&(s=ct.renderSpec(document,t.type.spec.toDOM(t,r),null,t.attrs)),new n(e,t,s.dom,s.contentDOM||s.dom,s)}parseRule(){return this.dirty&Ze||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=Ze&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=ze){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty0&&(o=go(o,0,e,r));for(let l=0;l{if(!a)return s;if(a.parent)return a.parent.posBeforeChild(a)},r,i),f=c&&c.dom,u=c&&c.contentDOM;if(t.isText){if(!f)f=document.createTextNode(t.text);else if(f.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else f||({dom:f,contentDOM:u}=ct.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs));!u&&!t.isText&&f.nodeName!="BR"&&(f.hasAttribute("contenteditable")||(f.contentEditable="false"),t.type.spec.draggable&&(f.draggable=!0));let d=f;return f=wa(f,r,t),c?a=new po(e,t,r,i,f,u||null,d,c,o,s+1):t.isText?new Ur(e,t,r,i,f,d,o):new n(e,t,r,i,f,u||null,d,o,s+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let t=this.children.length-1;t>=0;t--){let r=this.children[t];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>S.empty)}return e}matchesNode(e,t,r){return this.dirty==ze&&e.eq(this.node)&&Yr(t,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let r=this.node.inlineContent,i=t,o=e.composing?this.localCompositionInfo(e,t):null,s=o&&o.pos>-1?o:null,l=o&&o.pos<0,a=new mo(this,s&&s.node,e);gd(this.node,this.innerDeco,(c,f,u)=>{c.spec.marks?a.syncToMarks(c.spec.marks,r,e):c.type.side>=0&&!u&&a.syncToMarks(f==this.node.childCount?$.none:this.node.child(f).marks,r,e),a.placeWidget(c,e,i)},(c,f,u,d)=>{a.syncToMarks(c.marks,r,e);let p;a.findNodeMatch(c,f,u,d)||l&&e.state.selection.from>i&&e.state.selection.to-1&&a.updateNodeAt(c,f,u,p,e)||a.updateNextNode(c,f,u,e,d,i)||a.addNode(c,f,u,e,i),i+=c.nodeSize}),a.syncToMarks([],r,e),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==jt)&&(s&&this.protectLocalComposition(e,s),ka(this.contentDOM,this.children,e),wn&&yd(this.dom))}localCompositionInfo(e,t){let{from:r,to:i}=e.state.selection;if(!(e.state.selection instanceof P)||rt+this.node.content.size)return null;let o=e.input.compositionNode;if(!o||!this.dom.contains(o.parentNode))return null;if(this.node.inlineContent){let s=o.nodeValue,l=bd(this.node.content,s,r-t,i-t);return l<0?null:{node:o,pos:l,text:s}}else return{node:o,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:r,text:i}){if(this.getDesc(t))return;let o=t;for(;o.parentNode!=this.contentDOM;o=o.parentNode){for(;o.previousSibling;)o.parentNode.removeChild(o.previousSibling);for(;o.nextSibling;)o.parentNode.removeChild(o.nextSibling);o.pmViewDesc&&(o.pmViewDesc=void 0)}let s=new uo(this,o,t,i);e.input.compositionNodes.push(s),this.children=go(this.children,r,r+i.length,e,s)}update(e,t,r,i){return this.dirty==Ze||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,r,i),!0)}updateInner(e,t,r,i){this.updateOuterDeco(t),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(i,this.posAtStart),this.dirty=ze}updateOuterDeco(e){if(Yr(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=Sa(this.dom,this.nodeDOM,ho(this.outerDeco,this.node,t),ho(e,this.node,t)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.dom.draggable=!0)}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.dom.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}};function Wl(n,e,t,r,i){wa(r,e,n);let o=new Ot(void 0,n,e,t,r,r,r,i,0);return o.contentDOM&&o.updateChildren(i,0),o}var Ur=class n extends Ot{constructor(e,t,r,i,o,s,l){super(e,t,r,i,o,null,s,l,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,r,i){return this.dirty==Ze||this.dirty!=ze&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=ze||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,i.trackWrites==this.nodeDOM&&(i.trackWrites=null)),this.node=e,this.dirty=ze,!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,r){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,t,r){let i=this.node.cut(e,t),o=document.createTextNode(i.text);return new n(this.parent,i,this.outerDeco,this.innerDeco,o,o,r)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=Ze)}get domAtom(){return!1}isText(e){return this.node.text==e}},Gr=class extends Gt{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==ze&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}},po=class extends Ot{constructor(e,t,r,i,o,s,l,a,c,f){super(e,t,r,i,o,s,l,c,f),this.spec=a}update(e,t,r,i){if(this.dirty==Ze)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let o=this.spec.update(e,t,r);return o&&this.updateInner(e,t,r,i),o}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,r,i)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,r,i){this.spec.setSelection?this.spec.setSelection(e,t,r.root):super.setSelection(e,t,r,i)}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 ka(n,e,t){let r=n.firstChild,i=!1;for(let o=0;o>1,s=Math.min(o,e.length);for(;i-1)l>this.index&&(this.changed=!0,this.destroyBetween(this.index,l)),this.top=this.top.children[this.index];else{let a=Mn.create(this.top,e[o],t,r);this.top.children.splice(this.index,0,a),this.top=a,this.changed=!0}this.index=0,o++}}findNodeMatch(e,t,r,i){let o=-1,s;if(i>=this.preMatch.index&&(s=this.preMatch.matches[i-this.preMatch.index]).parent==this.top&&s.matchesNode(e,t,r))o=this.top.children.indexOf(s,this.index);else for(let l=this.index,a=Math.min(this.top.children.length,l+5);l0;){let l;for(;;)if(r){let c=t.children[r-1];if(c instanceof Mn)t=c,r=c.children.length;else{l=c,r--;break}}else{if(t==e)break e;r=t.parent.children.indexOf(t),t=t.parent}let a=l.node;if(a){if(a!=n.child(i-1))break;--i,o.set(l,i),s.push(l)}}return{index:i,matched:o,matches:s.reverse()}}function md(n,e){return n.type.side-e.type.side}function gd(n,e,t,r){let i=e.locals(n),o=0;if(i.length==0){for(let c=0;co;)l.push(i[s++]);let h=o+d.nodeSize;if(d.isText){let g=h;s!g.inline):l.slice();r(d,m,e.forChild(o,d),p),o=h}}function yd(n){if(n.nodeName=="UL"||n.nodeName=="OL"){let e=n.style.cssText;n.style.cssText=e+"; list-style: square !important",window.getComputedStyle(n).listStyle,n.style.cssText=e}}function bd(n,e,t,r){for(let i=0,o=0;i=t){if(o>=r&&a.slice(r-e.length-l,r-l)==e)return r-e.length;let c=l=0&&c+e.length+l>=t)return l+c;if(t==r&&a.length>=r+e.length-l&&a.slice(r-l,r-l+e.length)==e)return r}}return-1}function go(n,e,t,r,i){let o=[];for(let s=0,l=0;s=t||f<=e?o.push(a):(ct&&o.push(a.slice(t-c,a.size,r)))}return o}function To(n,e=null){let t=n.domSelectionRange(),r=n.state.doc;if(!t.focusNode)return null;let i=n.docView.nearestDesc(t.focusNode),o=i&&i.size==0,s=n.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(s<0)return null;let l=r.resolve(s),a,c;if(ii(t)){for(a=s;i&&!i.node;)i=i.parent;let u=i.node;if(i&&u.isAtom&&A.isSelectable(u)&&i.parent&&!(u.isInline&&Ku(t.focusNode,t.focusOffset,i.dom))){let d=i.posBefore;c=new A(s==d?l:r.resolve(d))}}else{if(t instanceof n.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let u=s,d=s;for(let p=0;p{(t.anchorNode!=r||t.anchorOffset!=i)&&(e.removeEventListener("selectionchange",n.input.hideSelectionGuard),setTimeout(()=>{(!Ma(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function xd(n){let e=n.domSelection(),t=document.createRange();if(!e)return;let r=n.cursorWrapper.dom,i=r.nodeName=="IMG";i?t.setStart(r.parentNode,pe(r)+1):t.setStart(r,0),t.collapse(!0),e.removeAllRanges(),e.addRange(t),!i&&!n.state.selection.visible&&Ee&&Ct<=11&&(r.disabled=!0,r.disabled=!1)}function Ca(n,e){if(e instanceof A){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(Kl(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else Kl(n)}function Kl(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function Eo(n,e,t,r){return n.someProp("createSelectionBetween",i=>i(n,e,t))||P.between(e,t,r)}function Ul(n){return n.editable&&!n.hasFocus()?!1:Oa(n)}function Oa(n){let e=n.domSelectionRange();if(!e.anchorNode)return!1;try{return n.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(n.editable||n.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function kd(n){let e=n.docView.domFromPos(n.state.selection.anchor,0),t=n.domSelectionRange();return Ut(e.node,e.offset,t.anchorNode,t.anchorOffset)}function yo(n,e){let{$anchor:t,$head:r}=n.selection,i=e>0?t.max(r):t.min(r),o=i.parent.inlineContent?i.depth?n.doc.resolve(e>0?i.after():i.before()):null:i;return o&&D.findFrom(o,e)}function wt(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function Gl(n,e,t){let r=n.state.selection;if(r instanceof P)if(t.indexOf("s")>-1){let{$head:i}=r,o=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter;if(!o||o.isText||!o.isLeaf)return!1;let s=n.state.doc.resolve(i.pos+o.nodeSize*(e<0?-1:1));return wt(n,new P(r.$anchor,s))}else if(r.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let i=yo(n.state,e);return i&&i instanceof A?wt(n,i):!1}else if(!(Le&&t.indexOf("m")>-1)){let i=r.$head,o=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter,s;if(!o||o.isText)return!1;let l=e<0?i.pos-o.nodeSize:i.pos;return o.isAtom||(s=n.docView.descAt(l))&&!s.contentDOM?A.isSelectable(o)?wt(n,new A(e<0?n.state.doc.resolve(i.pos-o.nodeSize):i)):ar?wt(n,new P(n.state.doc.resolve(e<0?l:l+o.nodeSize))):!1:!1}}else return!1;else{if(r instanceof A&&r.node.isInline)return wt(n,new P(e>0?r.$to:r.$from));{let i=yo(n.state,e);return i?wt(n,i):!1}}}function Xr(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function nr(n,e){let t=n.pmViewDesc;return t&&t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR")}function xn(n,e){return e<0?Sd(n):wd(n)}function Sd(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let i,o,s=!1;for(Je&&t.nodeType==1&&r0){if(t.nodeType!=1)break;{let l=t.childNodes[r-1];if(nr(l,-1))i=t,o=--r;else if(l.nodeType==3)t=l,r=t.nodeValue.length;else break}}else{if(Ta(t))break;{let l=t.previousSibling;for(;l&&nr(l,-1);)i=t.parentNode,o=pe(l),l=l.previousSibling;if(l)t=l,r=Xr(t);else{if(t=t.parentNode,t==n.dom)break;r=0}}}s?bo(n,t,r):i&&bo(n,i,o)}function wd(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let i=Xr(t),o,s;for(;;)if(r{n.state==i&&mt(n)},50)}function Yl(n,e){let t=n.state.doc.resolve(e);if(!(xe||Yu)&&t.parent.inlineContent){let i=n.coordsAtPos(e);if(e>t.start()){let o=n.coordsAtPos(e-1),s=(o.top+o.bottom)/2;if(s>i.top&&s1)return o.lefti.top&&s1)return o.left>i.left?"ltr":"rtl"}}return getComputedStyle(n.dom).direction=="rtl"?"rtl":"ltr"}function Xl(n,e,t){let r=n.state.selection;if(r instanceof P&&!r.empty||t.indexOf("s")>-1||Le&&t.indexOf("m")>-1)return!1;let{$from:i,$to:o}=r;if(!i.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let s=yo(n.state,e);if(s&&s instanceof A)return wt(n,s)}if(!i.parent.inlineContent){let s=e<0?i:o,l=r instanceof we?D.near(s,e):D.findFrom(s,e);return l?wt(n,l):!1}return!1}function Zl(n,e){if(!(n.state.selection instanceof P))return!0;let{$head:t,$anchor:r,empty:i}=n.state.selection;if(!t.sameParent(r))return!0;if(!i)return!1;if(n.endOfTextblock(e>0?"forward":"backward"))return!0;let o=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(o&&!o.isText){let s=n.state.tr;return e<0?s.delete(t.pos-o.nodeSize,t.pos):s.delete(t.pos,t.pos+o.nodeSize),n.dispatch(s),!0}return!1}function Ql(n,e,t){n.domObserver.stop(),e.contentEditable=t,n.domObserver.start()}function Od(n){if(!Me||n.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(e&&e.nodeType==1&&t==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;Ql(n,r,"true"),setTimeout(()=>Ql(n,r,"false"),20)}return!1}function Td(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function Ed(n,e){let t=e.keyCode,r=Td(e);if(t==8||Le&&t==72&&r=="c")return Zl(n,-1)||xn(n,-1);if(t==46&&!e.shiftKey||Le&&t==68&&r=="c")return Zl(n,1)||xn(n,1);if(t==13||t==27)return!0;if(t==37||Le&&t==66&&r=="c"){let i=t==37?Yl(n,n.state.selection.from)=="ltr"?-1:1:-1;return Gl(n,i,r)||xn(n,i)}else if(t==39||Le&&t==70&&r=="c"){let i=t==39?Yl(n,n.state.selection.from)=="ltr"?1:-1:1;return Gl(n,i,r)||xn(n,i)}else{if(t==38||Le&&t==80&&r=="c")return Xl(n,-1,r)||xn(n,-1);if(t==40||Le&&t==78&&r=="c")return Od(n)||Xl(n,1,r)||xn(n,1);if(r==(Le?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function Ea(n,e){n.someProp("transformCopied",p=>{e=p(e,n)});let t=[],{content:r,openStart:i,openEnd:o}=e;for(;i>1&&o>1&&r.childCount==1&&r.firstChild.childCount==1;){i--,o--;let p=r.firstChild;t.push(p.type.name,p.attrs!=p.type.defaultAttrs?p.attrs:null),r=p.content}let s=n.someProp("clipboardSerializer")||ct.fromSchema(n.state.schema),l=Ra(),a=l.createElement("div");a.appendChild(s.serializeFragment(r,{document:l}));let c=a.firstChild,f,u=0;for(;c&&c.nodeType==1&&(f=Ia[c.nodeName.toLowerCase()]);){for(let p=f.length-1;p>=0;p--){let h=l.createElement(f[p]);for(;a.firstChild;)h.appendChild(a.firstChild);a.appendChild(h),u++}c=a.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${i} ${o}${u?` -${u}`:""} ${JSON.stringify(t)}`);let d=n.someProp("clipboardTextSerializer",p=>p(e,n))||e.content.textBetween(0,e.content.size,` - -`);return{dom:a,text:d,slice:e}}function Aa(n,e,t,r,i){let o=i.parent.type.spec.code,s,l;if(!t&&!e)return null;let a=e&&(r||o||!t);if(a){if(n.someProp("transformPastedText",d=>{e=d(e,o||r,n)}),o)return e?new M(S.from(n.state.schema.text(e.replace(/\r\n?/g,` -`))),0,0):M.empty;let u=n.someProp("clipboardTextParser",d=>d(e,i,r,n));if(u)l=u;else{let d=i.marks(),{schema:p}=n.state,h=ct.fromSchema(p);s=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(m=>{let g=s.appendChild(document.createElement("p"));m&&g.appendChild(h.serializeNode(p.text(m,d)))})}}else n.someProp("transformPastedHTML",u=>{t=u(t,n)}),s=Pd(t),ar&&Id(s);let c=s&&s.querySelector("[data-pm-slice]"),f=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(f&&f[3])for(let u=+f[3];u>0;u--){let d=s.firstChild;for(;d&&d.nodeType!=1;)d=d.nextSibling;if(!d)break;s=d}if(l||(l=(n.someProp("clipboardParser")||n.someProp("domParser")||at.fromSchema(n.state.schema)).parseSlice(s,{preserveWhitespace:!!(a||f),context:i,ruleFromNode(d){return d.nodeName=="BR"&&!d.nextSibling&&d.parentNode&&!Ad.test(d.parentNode.nodeName)?{ignore:!0}:null}})),f)l=Rd(ea(l,+f[1],+f[2]),f[4]);else if(l=M.maxOpen(Nd(l.content,i),!0),l.openStart||l.openEnd){let u=0,d=0;for(let p=l.content.firstChild;u{l=u(l,n)}),l}var Ad=/^(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 Nd(n,e){if(n.childCount<2)return n;for(let t=e.depth;t>=0;t--){let i=e.node(t).contentMatchAt(e.index(t)),o,s=[];if(n.forEach(l=>{if(!s)return;let a=i.findWrapping(l.type),c;if(!a)return s=null;if(c=s.length&&o.length&&Da(a,o,l,s[s.length-1],0))s[s.length-1]=c;else{s.length&&(s[s.length-1]=Pa(s[s.length-1],o.length));let f=Na(l,a);s.push(f),i=i.matchType(f.type),o=a}}),s)return S.from(s)}return n}function Na(n,e,t=0){for(let r=e.length-1;r>=t;r--)n=e[r].create(null,S.from(n));return n}function Da(n,e,t,r,i){if(i1&&(o=0),i=t&&(l=e<0?s.contentMatchAt(0).fillBefore(l,o<=i).append(l):l.append(s.contentMatchAt(s.childCount).fillBefore(S.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,s.copy(l))}function ea(n,e,t){return et})),io.createHTML(n)):n}function Pd(n){let e=/^(\s*]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=Ra().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(n),i;if((i=r&&Ia[r[1].toLowerCase()])&&(n=i.map(o=>"<"+o+">").join("")+n+i.map(o=>"").reverse().join("")),t.innerHTML=Dd(n),i)for(let o=0;o=0;l-=2){let a=t.nodes[r[l]];if(!a||a.hasRequiredAttrs())break;i=S.from(a.create(r[l+1],i)),o++,s++}return new M(i,o,s)}var Ce={},Oe={},Bd={touchstart:!0,touchmove:!0},xo=class{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:""},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.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}};function Ld(n){for(let e in Ce){let t=Ce[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=r=>{zd(n,r)&&!Ao(n,r)&&(n.editable||!(r.type in Oe))&&t(n,r)},Bd[e]?{passive:!0}:void 0)}Me&&n.dom.addEventListener("input",()=>null),ko(n)}function Mt(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function Fd(n){n.domObserver.stop();for(let e in n.input.eventHandlers)n.dom.removeEventListener(e,n.input.eventHandlers[e]);clearTimeout(n.input.composingTimeout),clearTimeout(n.input.lastIOSEnterFallbackTimeout)}function ko(n){n.someProp("handleDOMEvents",e=>{for(let t in e)n.input.eventHandlers[t]||n.dom.addEventListener(t,n.input.eventHandlers[t]=r=>Ao(n,r))})}function Ao(n,e){return n.someProp("handleDOMEvents",t=>{let r=t[e.type];return r?r(n,e)||e.defaultPrevented:!1})}function zd(n,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target;t!=n.dom;t=t.parentNode)if(!t||t.nodeType==11||t.pmViewDesc&&t.pmViewDesc.stopEvent(e))return!1;return!0}function Vd(n,e){!Ao(n,e)&&Ce[e.type]&&(n.editable||!(e.type in Oe))&&Ce[e.type](n,e)}Oe.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,!La(n,t)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(ht&&xe&&t.keyCode==13)))if(t.keyCode!=229&&n.domObserver.forceFlush(),wn&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let r=Date.now();n.input.lastIOSEnter=r,n.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{n.input.lastIOSEnter==r&&(n.someProp("handleKeyDown",i=>i(n,Wt(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",r=>r(n,t))||Ed(n,t)?t.preventDefault():Mt(n,"key")};Oe.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)};Oe.keypress=(n,e)=>{let t=e;if(La(n,t)||!t.charCode||t.ctrlKey&&!t.altKey||Le&&t.metaKey)return;if(n.someProp("handleKeyPress",i=>i(n,t))){t.preventDefault();return}let r=n.state.selection;if(!(r instanceof P)||!r.$from.sameParent(r.$to)){let i=String.fromCharCode(t.charCode);!/[\r\n]/.test(i)&&!n.someProp("handleTextInput",o=>o(n,r.$from.pos,r.$to.pos,i))&&n.dispatch(n.state.tr.insertText(i).scrollIntoView()),t.preventDefault()}};function oi(n){return{left:n.clientX,top:n.clientY}}function $d(n,e){let t=e.x-n.clientX,r=e.y-n.clientY;return t*t+r*r<100}function No(n,e,t,r,i){if(r==-1)return!1;let o=n.state.doc.resolve(r);for(let s=o.depth+1;s>0;s--)if(n.someProp(e,l=>s>o.depth?l(n,t,o.nodeAfter,o.before(s),i,!0):l(n,t,o.node(s),o.before(s),i,!1)))return!0;return!1}function Sn(n,e,t){if(n.focused||n.focus(),n.state.selection.eq(e))return;let r=n.state.tr.setSelection(e);t=="pointer"&&r.setMeta("pointer",!0),n.dispatch(r)}function Hd(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),r=t.nodeAfter;return r&&r.isAtom&&A.isSelectable(r)?(Sn(n,new A(t),"pointer"),!0):!1}function Wd(n,e){if(e==-1)return!1;let t=n.state.selection,r,i;t instanceof A&&(r=t.node);let o=n.state.doc.resolve(e);for(let s=o.depth+1;s>0;s--){let l=s>o.depth?o.nodeAfter:o.node(s);if(A.isSelectable(l)){r&&t.$from.depth>0&&s>=t.$from.depth&&o.before(t.$from.depth+1)==t.$from.pos?i=o.before(t.$from.depth):i=o.before(s);break}}return i!=null?(Sn(n,A.create(n.state.doc,i),"pointer"),!0):!1}function jd(n,e,t,r,i){return No(n,"handleClickOn",e,t,r)||n.someProp("handleClick",o=>o(n,e,r))||(i?Wd(n,t):Hd(n,t))}function qd(n,e,t,r){return No(n,"handleDoubleClickOn",e,t,r)||n.someProp("handleDoubleClick",i=>i(n,e,r))}function Jd(n,e,t,r){return No(n,"handleTripleClickOn",e,t,r)||n.someProp("handleTripleClick",i=>i(n,e,r))||_d(n,t,r)}function _d(n,e,t){if(t.button!=0)return!1;let r=n.state.doc;if(e==-1)return r.inlineContent?(Sn(n,P.create(r,0,r.content.size),"pointer"),!0):!1;let i=r.resolve(e);for(let o=i.depth+1;o>0;o--){let s=o>i.depth?i.nodeAfter:i.node(o),l=i.before(o);if(s.inlineContent)Sn(n,P.create(r,l+1,l+1+s.content.size),"pointer");else if(A.isSelectable(s))Sn(n,A.create(r,l),"pointer");else continue;return!0}}function Do(n){return Zr(n)}var Ba=Le?"metaKey":"ctrlKey";Ce.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let r=Do(n),i=Date.now(),o="singleClick";i-n.input.lastClick.time<500&&$d(t,n.input.lastClick)&&!t[Ba]&&(n.input.lastClick.type=="singleClick"?o="doubleClick":n.input.lastClick.type=="doubleClick"&&(o="tripleClick")),n.input.lastClick={time:i,x:t.clientX,y:t.clientY,type:o};let s=n.posAtCoords(oi(t));s&&(o=="singleClick"?(n.input.mouseDown&&n.input.mouseDown.done(),n.input.mouseDown=new So(n,s,t,!!r)):(o=="doubleClick"?qd:Jd)(n,s.pos,s.inside,t)?t.preventDefault():Mt(n,"pointer"))};var So=class{constructor(e,t,r,i){this.view=e,this.pos=t,this.event=r,this.flushed=i,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[Ba],this.allowDefault=r.shiftKey;let o,s;if(t.inside>-1)o=e.state.doc.nodeAt(t.inside),s=t.inside;else{let f=e.state.doc.resolve(t.pos);o=f.parent,s=f.depth?f.before():0}let l=i?null:r.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a&&a.dom.nodeType==1?a.dom:null;let{selection:c}=e.state;(r.button==0&&o.type.spec.draggable&&o.type.spec.selectable!==!1||c instanceof A&&c.from<=s&&c.to>s)&&(this.mightDrag={node:o,pos:s,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Je&&!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()),e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),Mt(e,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),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(()=>mt(this.view)),this.view.input.mouseDown=null}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(oi(e))),this.updateAllowDefault(e),this.allowDefault||!t?Mt(this.view,"pointer"):jd(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||Me&&this.mightDrag&&!this.mightDrag.node.isAtom||xe&&!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)?(Sn(this.view,D.near(this.view.state.doc.resolve(t.pos)),"pointer"),e.preventDefault()):Mt(this.view,"pointer")}move(e){this.updateAllowDefault(e),Mt(this.view,"pointer"),e.buttons==0&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}};Ce.touchstart=n=>{n.input.lastTouch=Date.now(),Do(n),Mt(n,"pointer")};Ce.touchmove=n=>{n.input.lastTouch=Date.now(),Mt(n,"pointer")};Ce.contextmenu=n=>Do(n);function La(n,e){return n.composing?!0:Me&&Math.abs(e.timeStamp-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}var Kd=ht?5e3:-1;Oe.compositionstart=Oe.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:e}=n,t=e.selection.$to;if(e.selection instanceof P&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)))n.markCursor=n.state.storedMarks||t.marks(),Zr(n,!0),n.markCursor=null;else if(Zr(n,!e.selection.empty),Je&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let r=n.domSelectionRange();for(let i=r.focusNode,o=r.focusOffset;i&&i.nodeType==1&&o!=0;){let s=o<0?i.lastChild:i.childNodes[o-1];if(!s)break;if(s.nodeType==3){let l=n.domSelection();l&&l.collapse(s,s.nodeValue.length);break}else i=s,o=-1}}n.input.composing=!0}Fa(n,Kd)};Oe.compositionend=(n,e)=>{n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=e.timeStamp,n.input.compositionPendingChanges=n.domObserver.pendingRecords().length?n.input.compositionID:0,n.input.compositionNode=null,n.input.compositionPendingChanges&&Promise.resolve().then(()=>n.domObserver.flush()),n.input.compositionID++,Fa(n,20))};function Fa(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>Zr(n),e))}function za(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=Gd());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function Ud(n){let e=n.domSelectionRange();if(!e.focusNode)return null;let t=Ju(e.focusNode,e.focusOffset),r=_u(e.focusNode,e.focusOffset);if(t&&r&&t!=r){let i=r.pmViewDesc,o=n.domObserver.lastChangedTextNode;if(t==o||r==o)return o;if(!i||!i.isText(r.nodeValue))return r;if(n.input.compositionNode==r){let s=t.pmViewDesc;if(!(!s||!s.isText(t.nodeValue)))return r}}return t||r}function Gd(){let n=document.createEvent("Event");return n.initEvent("event",!0,!0),n.timeStamp}function Zr(n,e=!1){if(!(ht&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),za(n),e||n.docView&&n.docView.dirty){let t=To(n);return t&&!t.eq(n.state.selection)?n.dispatch(n.state.tr.setSelection(t)):(n.markCursor||e)&&!n.state.selection.empty?n.dispatch(n.state.tr.deleteSelection()):n.updateState(n.state),!0}return!1}}function Yd(n,e){if(!n.dom.parentNode)return;let t=n.dom.parentNode.appendChild(document.createElement("div"));t.appendChild(e),t.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),i=document.createRange();i.selectNodeContents(e),n.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),n.focus()},50)}var ir=Ee&&Ct<15||wn&&Xu<604;Ce.copy=Oe.cut=(n,e)=>{let t=e,r=n.state.selection,i=t.type=="cut";if(r.empty)return;let o=ir?null:t.clipboardData,s=r.content(),{dom:l,text:a}=Ea(n,s);o?(t.preventDefault(),o.clearData(),o.setData("text/html",l.innerHTML),o.setData("text/plain",a)):Yd(n,l),i&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function Xd(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function Zd(n,e){if(!n.dom.parentNode)return;let t=n.input.shiftKey||n.state.selection.$from.parent.type.spec.code,r=n.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let i=n.input.shiftKey&&n.input.lastKeyCode!=45;setTimeout(()=>{n.focus(),r.parentNode&&r.parentNode.removeChild(r),t?or(n,r.value,null,i,e):or(n,r.textContent,r.innerHTML,i,e)},50)}function or(n,e,t,r,i){let o=Aa(n,e,t,r,n.state.selection.$from);if(n.someProp("handlePaste",a=>a(n,i,o||M.empty)))return!0;if(!o)return!1;let s=Xd(o),l=s?n.state.tr.replaceSelectionWith(s,r):n.state.tr.replaceSelection(o);return n.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Va(n){let e=n.getData("text/plain")||n.getData("Text");if(e)return e;let t=n.getData("text/uri-list");return t?t.replace(/\r?\n/g," "):""}Oe.paste=(n,e)=>{let t=e;if(n.composing&&!ht)return;let r=ir?null:t.clipboardData,i=n.input.shiftKey&&n.input.lastKeyCode!=45;r&&or(n,Va(r),r.getData("text/html"),i,t)?t.preventDefault():Zd(n,t)};var Qr=class{constructor(e,t,r){this.slice=e,this.move=t,this.node=r}},$a=Le?"altKey":"ctrlKey";Ce.dragstart=(n,e)=>{let t=e,r=n.input.mouseDown;if(r&&r.done(),!t.dataTransfer)return;let i=n.state.selection,o=i.empty?null:n.posAtCoords(oi(t)),s;if(!(o&&o.pos>=i.from&&o.pos<=(i instanceof A?i.to-1:i.to))){if(r&&r.mightDrag)s=A.create(n.state.doc,r.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let u=n.docView.nearestDesc(t.target,!0);u&&u.node.type.spec.draggable&&u!=n.docView&&(s=A.create(n.state.doc,u.posBefore))}}let l=(s||n.state.selection).content(),{dom:a,text:c,slice:f}=Ea(n,l);(!t.dataTransfer.files.length||!xe||ha>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(ir?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",ir||t.dataTransfer.setData("text/plain",c),n.dragging=new Qr(f,!t[$a],s)};Ce.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)};Oe.dragover=Oe.dragenter=(n,e)=>e.preventDefault();Oe.drop=(n,e)=>{let t=e,r=n.dragging;if(n.dragging=null,!t.dataTransfer)return;let i=n.posAtCoords(oi(t));if(!i)return;let o=n.state.doc.resolve(i.pos),s=r&&r.slice;s?n.someProp("transformPasted",h=>{s=h(s,n)}):s=Aa(n,Va(t.dataTransfer),ir?null:t.dataTransfer.getData("text/html"),!1,o);let l=!!(r&&!t[$a]);if(n.someProp("handleDrop",h=>h(n,t,s||M.empty,l))){t.preventDefault();return}if(!s)return;t.preventDefault();let a=s?Wr(n.state.doc,o.pos,s):o.pos;a==null&&(a=o.pos);let c=n.state.tr;if(l){let{node:h}=r;h?h.replace(c):c.deleteSelection()}let f=c.mapping.map(a),u=s.openStart==0&&s.openEnd==0&&s.content.childCount==1,d=c.doc;if(u?c.replaceRangeWith(f,f,s.content.firstChild):c.replaceRange(f,f,s),c.doc.eq(d))return;let p=c.doc.resolve(f);if(u&&A.isSelectable(s.content.firstChild)&&p.nodeAfter&&p.nodeAfter.sameMarkup(s.content.firstChild))c.setSelection(new A(p));else{let h=c.mapping.map(a);c.mapping.maps[c.mapping.maps.length-1].forEach((m,g,b,x)=>h=x),c.setSelection(Eo(n,p,c.doc.resolve(h)))}n.focus(),n.dispatch(c.setMeta("uiEvent","drop"))};Ce.focus=n=>{n.input.lastFocus=Date.now(),n.focused||(n.domObserver.stop(),n.dom.classList.add("ProseMirror-focused"),n.domObserver.start(),n.focused=!0,setTimeout(()=>{n.docView&&n.hasFocus()&&!n.domObserver.currentSelection.eq(n.domSelectionRange())&&mt(n)},20))};Ce.blur=(n,e)=>{let t=e;n.focused&&(n.domObserver.stop(),n.dom.classList.remove("ProseMirror-focused"),n.domObserver.start(),t.relatedTarget&&n.dom.contains(t.relatedTarget)&&n.domObserver.currentSelection.clear(),n.focused=!1)};Ce.beforeinput=(n,e)=>{if(xe&&ht&&e.inputType=="deleteContentBackward"){n.domObserver.flushSoon();let{domChangeCount:r}=n.input;setTimeout(()=>{if(n.input.domChangeCount!=r||(n.dom.blur(),n.focus(),n.someProp("handleKeyDown",o=>o(n,Wt(8,"Backspace")))))return;let{$cursor:i}=n.state.selection;i&&i.pos>0&&n.dispatch(n.state.tr.delete(i.pos-1,i.pos).scrollIntoView())},50)}};for(let n in Oe)Ce[n]=Oe[n];function sr(n,e){if(n==e)return!0;for(let t in n)if(n[t]!==e[t])return!1;for(let t in e)if(!(t in n))return!1;return!0}var ei=class n{constructor(e,t){this.toDOM=e,this.spec=t||_t,this.side=this.spec.side||0}map(e,t,r,i){let{pos:o,deleted:s}=e.mapResult(t.from+i,this.side<0?-1:1);return s?null:new Ae(o-r,o-r,this)}valid(){return!0}eq(e){return this==e||e instanceof n&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&sr(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}},Jt=class n{constructor(e,t){this.attrs=e,this.spec=t||_t}map(e,t,r,i){let o=e.map(t.from+i,this.spec.inclusiveStart?-1:1)-r,s=e.map(t.to+i,this.spec.inclusiveEnd?1:-1)-r;return o>=s?null:new Ae(o,s,this)}valid(e,t){return t.from=e&&(!o||o(l.spec))&&r.push(l.copy(l.from+i,l.to+i))}for(let s=0;se){let l=this.children[s]+1;this.children[s+2].findInner(e-l,t-l,r,i+l,o)}}map(e,t,r){return this==ve||e.maps.length==0?this:this.mapInner(e,t,0,0,r||_t)}mapInner(e,t,r,i,o){let s;for(let l=0;l{let c=a+r,f;if(f=Wa(t,l,c)){for(i||(i=this.children.slice());ol&&u.to=e){this.children[l]==e&&(r=this.children[l+2]);break}let o=e+1,s=o+t.content.size;for(let l=0;lo&&a.type instanceof Jt){let c=Math.max(o,a.from)-o,f=Math.min(s,a.to)-o;ci.map(e,t,_t));return n.from(r)}forChild(e,t){if(t.isLeaf)return se.empty;let r=[];for(let i=0;it instanceof se)?e:e.reduce((t,r)=>t.concat(r instanceof se?r:r.members),[]))}}forEachSet(e){for(let t=0;t{let g=m-h-(p-d);for(let b=0;bx+f-u)continue;let w=l[b]+f-u;p>=w?l[b+1]=d<=w?-2:-1:d>=f&&g&&(l[b]+=g,l[b+1]+=g)}u+=g}),f=t.maps[c].map(f,-1)}let a=!1;for(let c=0;c=r.content.size){a=!0;continue}let d=t.map(n[c+1]+o,-1),p=d-i,{index:h,offset:m}=r.content.findIndex(u),g=r.maybeChild(h);if(g&&m==u&&m+g.nodeSize==p){let b=l[c+2].mapInner(t,g,f+1,n[c]+o+1,s);b!=ve?(l[c]=u,l[c+1]=p,l[c+2]=b):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=ep(l,n,e,t,i,o,s),f=ni(c,r,0,s);e=f.local;for(let u=0;ut&&s.to{let c=Wa(n,l,a+t);if(c){o=!0;let f=ni(c,l,t+a+1,r);f!=ve&&i.push(a,a+l.nodeSize,f)}});let s=Ha(o?ja(n):n,-t).sort(Kt);for(let l=0;l0;)e++;n.splice(e,0,t)}function oo(n){let e=[];return n.someProp("decorations",t=>{let r=t(n.state);r&&r!=ve&&e.push(r)}),n.cursorWrapper&&e.push(se.create(n.state.doc,[n.cursorWrapper.deco])),ti.from(e)}var tp={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},np=Ee&&Ct<=11,Mo=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}},Co=class{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new Mo,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let i=0;ii.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),np&&(this.onCharData=r=>{this.queue.push({target:r.target,type:"characterData",oldValue:r.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,tp)),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(Ul(this.view)){if(this.suppressingSelectionUpdates)return mt(this.view);if(Ee&&Ct<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Ut(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,r;for(let o=e.focusNode;o;o=rr(o))t.add(o);for(let o=e.anchorNode;o;o=rr(o))if(t.has(o)){r=o;break}let i=r&&this.view.docView.nearestDesc(r);if(i&&i.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r}))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 r=e.domSelectionRange(),i=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&Ul(e)&&!this.ignoreSelectionChange(r),o=-1,s=-1,l=!1,a=[];if(e.editable)for(let f=0;fu.nodeName=="BR");if(f.length==2){let[u,d]=f;u.parentNode&&u.parentNode.parentNode==d.parentNode?d.remove():u.remove()}else{let{focusNode:u}=this.currentSelection;for(let d of f){let p=d.parentNode;p&&p.nodeName=="LI"&&(!u||op(e,u)!=p)&&d.remove()}}}let c=null;o<0&&i&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)-1||i)&&(o>-1&&(e.docView.markDirty(o,s),rp(e)),this.handleDOMChange(o,s,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||mt(e),this.currentSelection.set(r))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let r=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(r==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!r||r.ignoreMutation(e))return null;if(e.type=="childList"){for(let f=0;fi;g--){let b=r.childNodes[g-1],x=b.pmViewDesc;if(b.nodeName=="BR"&&!x){o=g;break}if(!x||x.size)break}let u=n.state.doc,d=n.someProp("domParser")||at.fromSchema(n.state.schema),p=u.resolve(s),h=null,m=d.parse(r,{topNode:p.parent,topMatch:p.parent.contentMatchAt(p.index()),topOpen:!0,from:i,to:o,preserveWhitespace:p.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:lp,context:p});if(c&&c[0].pos!=null){let g=c[0].pos,b=c[1]&&c[1].pos;b==null&&(b=g),h={anchor:g+s,head:b+s}}return{doc:m,sel:h,from:s,to:l}}function lp(n){let e=n.pmViewDesc;if(e)return e.parseRule();if(n.nodeName=="BR"&&n.parentNode){if(Me&&/^(ul|ol)$/i.test(n.parentNode.nodeName)){let t=document.createElement("div");return t.appendChild(document.createElement("li")),{skip:t}}else if(n.parentNode.lastChild==n||Me&&/^(tr|table)$/i.test(n.parentNode.nodeName))return{ignore:!0}}else if(n.nodeName=="IMG"&&n.getAttribute("mark-placeholder"))return{ignore:!0};return null}var ap=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function cp(n,e,t,r,i){let o=n.input.compositionPendingChanges||(n.composing?n.input.compositionID:0);if(n.input.compositionPendingChanges=0,e<0){let T=n.input.lastSelectionTime>Date.now()-50?n.input.lastSelectionOrigin:null,N=To(n,T);if(N&&!n.state.selection.eq(N)){if(xe&&ht&&n.input.lastKeyCode===13&&Date.now()-100H(n,Wt(13,"Enter"))))return;let F=n.state.tr.setSelection(N);T=="pointer"?F.setMeta("pointer",!0):T=="key"&&F.scrollIntoView(),o&&F.setMeta("composition",o),n.dispatch(F)}return}let s=n.state.doc.resolve(e),l=s.sharedDepth(t);e=s.before(l+1),t=n.state.doc.resolve(t).after(l+1);let a=n.state.selection,c=sp(n,e,t),f=n.state.doc,u=f.slice(c.from,c.to),d,p;n.input.lastKeyCode===8&&Date.now()-100Date.now()-225||ht)&&i.some(T=>T.nodeType==1&&!ap.test(T.nodeName))&&(!h||h.endA>=h.endB)&&n.someProp("handleKeyDown",T=>T(n,Wt(13,"Enter")))){n.input.lastIOSEnter=0;return}if(!h)if(r&&a instanceof P&&!a.empty&&a.$head.sameParent(a.$anchor)&&!n.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))h={start:a.from,endA:a.to,endB:a.to};else{if(c.sel){let T=sa(n,n.state.doc,c.sel);if(T&&!T.eq(n.state.selection)){let N=n.state.tr.setSelection(T);o&&N.setMeta("composition",o),n.dispatch(N)}}return}n.state.selection.fromn.state.selection.from&&h.start<=n.state.selection.from+2&&n.state.selection.from>=c.from?h.start=n.state.selection.from:h.endA=n.state.selection.to-2&&n.state.selection.to<=c.to&&(h.endB+=n.state.selection.to-h.endA,h.endA=n.state.selection.to)),Ee&&Ct<=11&&h.endB==h.start+1&&h.endA==h.start&&h.start>c.from&&c.doc.textBetween(h.start-c.from-1,h.start-c.from+1)==" \xA0"&&(h.start--,h.endA--,h.endB--);let m=c.doc.resolveNoCache(h.start-c.from),g=c.doc.resolveNoCache(h.endB-c.from),b=f.resolve(h.start),x=m.sameParent(g)&&m.parent.inlineContent&&b.end()>=h.endA,w;if((wn&&n.input.lastIOSEnter>Date.now()-225&&(!x||i.some(T=>T.nodeName=="DIV"||T.nodeName=="P"))||!x&&m.posT(n,Wt(13,"Enter")))){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>h.start&&up(f,h.start,h.endA,m,g)&&n.someProp("handleKeyDown",T=>T(n,Wt(8,"Backspace")))){ht&&xe&&n.domObserver.suppressSelectionUpdates();return}xe&&h.endB==h.start&&(n.input.lastChromeDelete=Date.now()),ht&&!x&&m.start()!=g.start()&&g.parentOffset==0&&m.depth==g.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==h.endA&&(h.endB-=2,g=c.doc.resolveNoCache(h.endB-c.from),setTimeout(()=>{n.someProp("handleKeyDown",function(T){return T(n,Wt(13,"Enter"))})},20));let y=h.start,C=h.endA,k,I,B;if(x){if(m.pos==g.pos)Ee&&Ct<=11&&m.parentOffset==0&&(n.domObserver.suppressSelectionUpdates(),setTimeout(()=>mt(n),20)),k=n.state.tr.delete(y,C),I=f.resolve(h.start).marksAcross(f.resolve(h.endA));else if(h.endA==h.endB&&(B=fp(m.parent.content.cut(m.parentOffset,g.parentOffset),b.parent.content.cut(b.parentOffset,h.endA-b.start()))))k=n.state.tr,B.type=="add"?k.addMark(y,C,B.mark):k.removeMark(y,C,B.mark);else if(m.parent.child(m.index()).isText&&m.index()==g.index()-(g.textOffset?0:1)){let T=m.parent.textBetween(m.parentOffset,g.parentOffset);if(n.someProp("handleTextInput",N=>N(n,y,C,T)))return;k=n.state.tr.insertText(T,y,C)}}if(k||(k=n.state.tr.replace(y,C,c.doc.slice(h.start-c.from,h.endB-c.from))),c.sel){let T=sa(n,k.doc,c.sel);T&&!(xe&&n.composing&&T.empty&&(h.start!=h.endB||n.input.lastChromeDeletee.content.size?null:Eo(n,e.resolve(t.anchor),e.resolve(t.head))}function fp(n,e){let t=n.firstChild.marks,r=e.firstChild.marks,i=t,o=r,s,l,a;for(let f=0;ff.mark(l.addToSet(f.marks));else if(i.length==0&&o.length==1)l=o[0],s="remove",a=f=>f.mark(l.removeFromSet(f.marks));else return null;let c=[];for(let f=0;ft||so(s,!0,!1)0&&(e||n.indexAfter(r)==n.node(r).childCount);)r--,i++,e=!1;if(t){let o=n.node(r).maybeChild(n.indexAfter(r));for(;o&&!o.isLeaf;)o=o.firstChild,i++}return i}function dp(n,e,t,r,i){let o=n.findDiffStart(e,t);if(o==null)return null;let{a:s,b:l}=n.findDiffEnd(e,t+n.size,t+e.size);if(i=="end"){let a=Math.max(0,o-Math.min(s,l));r-=s+a-o}if(s=s?o-r:0;o-=a,o&&o=l?o-r:0;o-=a,o&&o=56320&&e<=57343&&t>=55296&&t<=56319}var ri=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 xo,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(da),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=fa(this),ca(this),this.nodeViews=ua(this),this.docView=Wl(this.state.doc,aa(this),oo(this),this.dom,this),this.domObserver=new Co(this,(r,i,o,s)=>cp(this,r,i,o,s)),this.domObserver.start(),Ld(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&&ko(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(da),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let r in this._props)t[r]=this._props[r];t.state=this.state;for(let r in e)t[r]=e[r];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var r;let i=this.state,o=!1,s=!1;e.storedMarks&&this.composing&&(za(this),s=!0),this.state=e;let l=i.plugins!=e.plugins||this._props.plugins!=t.plugins;if(l||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let p=ua(this);hp(p,this.nodeViews)&&(this.nodeViews=p,o=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&ko(this),this.editable=fa(this),ca(this);let a=oo(this),c=aa(this),f=i.plugins!=e.plugins&&!i.doc.eq(e.doc)?"reset":e.scrollToSelection>i.scrollToSelection?"to selection":"preserve",u=o||!this.docView.matchesNode(e.doc,c,a);(u||!e.selection.eq(i.selection))&&(s=!0);let d=f=="preserve"&&s&&this.dom.style.overflowAnchor==null&&ed(this);if(s){this.domObserver.stop();let p=u&&(Ee||xe)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&pp(i.selection,e.selection);if(u){let h=xe?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=Ud(this)),(o||!this.docView.update(e.doc,c,a,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=Wl(e.doc,c,a,this.dom,this)),h&&!this.trackWrites&&(p=!0)}p||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&kd(this))?mt(this,p):(Ca(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(i),!((r=this.dragging)===null||r===void 0)&&r.node&&!i.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,i),f=="reset"?this.dom.scrollTop=0:f=="to selection"?this.scrollToSelection():d&&td(d)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof A){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&Ll(this,t.getBoundingClientRect(),e)}else Ll(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 t=0;t0&&this.state.doc.nodeAt(o))==r.node&&(i=o)}this.dragging=new Qr(e.slice,e.move,i<0?void 0:A.create(this.state.doc,i))}someProp(e,t){let r=this._props&&this._props[e],i;if(r!=null&&(i=t?t(r):r))return i;for(let s=0;st.ownerDocument.getSelection()),this._root=t}return e||document}updateRoot(){this._root=null}posAtCoords(e){return ld(this,e)}coordsAtPos(e,t=1){return va(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,r=-1){let i=this.docView.posFromDOM(e,t,r);if(i==null)throw new RangeError("DOM position not inside the editor");return i}endOfTextblock(e,t){return dd(this,t||this.state,e)}pasteHTML(e,t){return or(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return or(this,e,null,!0,t||new ClipboardEvent("paste"))}destroy(){this.docView&&(Fd(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],oo(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,ju())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return Vd(this,e)}dispatch(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))}domSelectionRange(){let e=this.domSelection();return e?Me&&this.root.nodeType===11&&Uu(this.dom.ownerDocument)==this.dom&&ip(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}};function aa(n){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(n.editable),n.someProp("attributes",t=>{if(typeof t=="function"&&(t=t(n.state)),t)for(let r in t)r=="class"?e.class+=" "+t[r]:r=="style"?e.style=(e.style?e.style+";":"")+t[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(t[r]))}),e.translate||(e.translate="no"),[Ae.node(0,n.state.doc.content.size,e)]}function ca(n){if(n.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),n.cursorWrapper={dom:e,deco:Ae.widget(n.state.selection.from,e,{raw:!0,marks:n.markCursor})}}else n.cursorWrapper=null}function fa(n){return!n.someProp("editable",e=>e(n.state)===!1)}function pp(n,e){let t=Math.min(n.$anchor.sharedDepth(n.head),e.$anchor.sharedDepth(e.head));return n.$anchor.start(t)!=e.$anchor.start(t)}function ua(n){let e=Object.create(null);function t(r){for(let i in r)Object.prototype.hasOwnProperty.call(e,i)||(e[i]=r[i])}return n.someProp("nodeViews",t),n.someProp("markViews",t),e}function hp(n,e){let t=0,r=0;for(let i in n){if(n[i]!=e[i])return!0;t++}for(let i in e)r++;return t!=r}function da(n){if(n.spec.state||n.spec.filterTransaction||n.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var gt={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:"'"},li={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},mp=typeof navigator<"u"&&/Mac/.test(navigator.platform),gp=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(ee=0;ee<10;ee++)gt[48+ee]=gt[96+ee]=String(ee);var ee;for(ee=1;ee<=24;ee++)gt[ee+111]="F"+ee;var ee;for(ee=65;ee<=90;ee++)gt[ee]=String.fromCharCode(ee+32),li[ee]=String.fromCharCode(ee);var ee;for(si in gt)li.hasOwnProperty(si)||(li[si]=gt[si]);var si;function qa(n){var e=mp&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||gp&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?li:gt)[n.keyCode]||n.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 yp=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!1;function bp(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let r,i,o,s;for(let l=0;l127)&&(o=gt[r.keyCode])&&o!=i){let l=e[Io(o,r)];if(l&&l(t.state,t.dispatch,t))return!0}}return!1}}var ai=(n,e)=>n.selection.empty?!1:(e&&e(n.tr.deleteSelection().scrollIntoView()),!0);function Ka(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("backward",n):t.parentOffset>0)?null:t}var Lo=(n,e,t)=>{let r=Ka(n,t);if(!r)return!1;let i=zo(r);if(!i){let s=r.blockRange(),l=s&&ut(s);return l==null?!1:(e&&e(n.tr.lift(s,l).scrollIntoView()),!0)}let o=i.nodeBefore;if(nc(n,i,e,-1))return!0;if(r.parent.content.size==0&&(Cn(o,"end")||A.isSelectable(o)))for(let s=r.depth;;s--){let l=Zn(n.doc,r.before(s),r.after(s),M.empty);if(l&&l.slice.size1)break}return o.isAtom&&i.depth==r.depth-1?(e&&e(n.tr.delete(i.pos-o.nodeSize,i.pos).scrollIntoView()),!0):!1},Ua=(n,e,t)=>{let r=Ka(n,t);if(!r)return!1;let i=zo(r);return i?Ya(n,i,e):!1},Ga=(n,e,t)=>{let r=Xa(n,t);if(!r)return!1;let i=Ho(r);return i?Ya(n,i,e):!1};function Ya(n,e,t){let r=e.nodeBefore,i=r,o=e.pos-1;for(;!i.isTextblock;o--){if(i.type.spec.isolating)return!1;let f=i.lastChild;if(!f)return!1;i=f}let s=e.nodeAfter,l=s,a=e.pos+1;for(;!l.isTextblock;a++){if(l.type.spec.isolating)return!1;let f=l.firstChild;if(!f)return!1;l=f}let c=Zn(n.doc,o,a,M.empty);if(!c||c.from!=o||c instanceof be&&c.slice.size>=a-o)return!1;if(t){let f=n.tr.step(c);f.setSelection(P.create(f.doc,o)),t(f.scrollIntoView())}return!0}function Cn(n,e,t=!1){for(let r=n;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(t&&r.childCount!=1)return!1}return!1}var Fo=(n,e,t)=>{let{$head:r,empty:i}=n.selection,o=r;if(!i)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("backward",n):r.parentOffset>0)return!1;o=zo(r)}let s=o&&o.nodeBefore;return!s||!A.isSelectable(s)?!1:(e&&e(n.tr.setSelection(A.create(n.doc,o.pos-s.nodeSize)).scrollIntoView()),!0)};function zo(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){if(n.index(e)>0)return n.doc.resolve(n.before(e+1));if(n.node(e).type.spec.isolating)break}return null}function Xa(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("forward",n):t.parentOffset{let r=Xa(n,t);if(!r)return!1;let i=Ho(r);if(!i)return!1;let o=i.nodeAfter;if(nc(n,i,e,1))return!0;if(r.parent.content.size==0&&(Cn(o,"start")||A.isSelectable(o))){let s=Zn(n.doc,r.before(),r.after(),M.empty);if(s&&s.slice.size{let{$head:r,empty:i}=n.selection,o=r;if(!i)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("forward",n):r.parentOffset=0;e--){let t=n.node(e);if(n.index(e)+1{let t=n.selection,r=t instanceof A,i;if(r){if(t.node.isTextblock||!qe(n.doc,t.from))return!1;i=t.from}else if(i=yn(n.doc,t.from,-1),i==null)return!1;if(e){let o=n.tr.join(i);r&&o.setSelection(A.create(o.doc,i-n.doc.resolve(i).nodeBefore.nodeSize)),e(o.scrollIntoView())}return!0},Qa=(n,e)=>{let t=n.selection,r;if(t instanceof A){if(t.node.isTextblock||!qe(n.doc,t.to))return!1;r=t.to}else if(r=yn(n.doc,t.to,1),r==null)return!1;return e&&e(n.tr.join(r).scrollIntoView()),!0},ec=(n,e)=>{let{$from:t,$to:r}=n.selection,i=t.blockRange(r),o=i&&ut(i);return o==null?!1:(e&&e(n.tr.lift(i,o).scrollIntoView()),!0)},Wo=(n,e)=>{let{$head:t,$anchor:r}=n.selection;return!t.parent.type.spec.code||!t.sameParent(r)?!1:(e&&e(n.tr.insertText(` -`).scrollIntoView()),!0)};function jo(n){for(let e=0;e{let{$head:t,$anchor:r}=n.selection;if(!t.parent.type.spec.code||!t.sameParent(r))return!1;let i=t.node(-1),o=t.indexAfter(-1),s=jo(i.contentMatchAt(o));if(!s||!i.canReplaceWith(o,o,s))return!1;if(e){let l=t.after(),a=n.tr.replaceWith(l,l,s.createAndFill());a.setSelection(D.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},Jo=(n,e)=>{let t=n.selection,{$from:r,$to:i}=t;if(t instanceof we||r.parent.inlineContent||i.parent.inlineContent)return!1;let o=jo(i.parent.contentMatchAt(i.indexAfter()));if(!o||!o.isTextblock)return!1;if(e){let s=(!r.parentOffset&&i.index(){let{$cursor:t}=n.selection;if(!t||t.parent.content.size)return!1;if(t.depth>1&&t.after()!=t.end(-1)){let o=t.before();if(Be(n.doc,o))return e&&e(n.tr.split(o).scrollIntoView()),!0}let r=t.blockRange(),i=r&&ut(r);return i==null?!1:(e&&e(n.tr.lift(r,i).scrollIntoView()),!0)};function xp(n){return(e,t)=>{let{$from:r,$to:i}=e.selection;if(e.selection instanceof A&&e.selection.node.isBlock)return!r.parentOffset||!Be(e.doc,r.pos)?!1:(t&&t(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let o=[],s,l,a=!1,c=!1;for(let p=r.depth;;p--)if(r.node(p).isBlock){a=r.end(p)==r.pos+(r.depth-p),c=r.start(p)==r.pos-(r.depth-p),l=jo(r.node(p-1).contentMatchAt(r.indexAfter(p-1)));let m=n&&n(i.parent,a,r);o.unshift(m||(a&&l?{type:l}:null)),s=p;break}else{if(p==1)return!1;o.unshift(null)}let f=e.tr;(e.selection instanceof P||e.selection instanceof we)&&f.deleteSelection();let u=f.mapping.map(r.pos),d=Be(f.doc,u,o.length,o);if(d||(o[0]=l?{type:l}:null,d=Be(f.doc,u,o.length,o)),f.split(u,o.length,o),!a&&c&&r.node(s).type!=l){let p=f.mapping.map(r.before(s)),h=f.doc.resolve(p);l&&r.node(s-1).canReplaceWith(h.index(),h.index()+1,l)&&f.setNodeMarkup(f.mapping.map(r.before(s)),l)}return t&&t(f.scrollIntoView()),!0}}var kp=xp();var tc=(n,e)=>{let{$from:t,to:r}=n.selection,i,o=t.sharedDepth(r);return o==0?!1:(i=t.before(o),e&&e(n.tr.setSelection(A.create(n.doc,i))),!0)},Sp=(n,e)=>(e&&e(n.tr.setSelection(new we(n.doc))),!0);function wp(n,e,t){let r=e.nodeBefore,i=e.nodeAfter,o=e.index();return!r||!i||!r.type.compatibleContent(i.type)?!1:!r.content.size&&e.parent.canReplace(o-1,o)?(t&&t(n.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(o,o+1)||!(i.isTextblock||qe(n.doc,e.pos))?!1:(t&&t(n.tr.join(e.pos).scrollIntoView()),!0)}function nc(n,e,t,r){let i=e.nodeBefore,o=e.nodeAfter,s,l,a=i.type.spec.isolating||o.type.spec.isolating;if(!a&&wp(n,e,t))return!0;let c=!a&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(s=(l=i.contentMatchAt(i.childCount)).findWrapping(o.type))&&l.matchType(s[0]||o.type).validEnd){if(t){let p=e.pos+o.nodeSize,h=S.empty;for(let b=s.length-1;b>=0;b--)h=S.from(s[b].create(null,h));h=S.from(i.copy(h));let m=n.tr.step(new Q(e.pos-1,p,e.pos,p,new M(h,1,0),s.length,!0)),g=m.doc.resolve(p+2*s.length);g.nodeAfter&&g.nodeAfter.type==i.type&&qe(m.doc,g.pos)&&m.join(g.pos),t(m.scrollIntoView())}return!0}let f=o.type.spec.isolating||r>0&&a?null:D.findFrom(e,1),u=f&&f.$from.blockRange(f.$to),d=u&&ut(u);if(d!=null&&d>=e.depth)return t&&t(n.tr.lift(u,d).scrollIntoView()),!0;if(c&&Cn(o,"start",!0)&&Cn(i,"end")){let p=i,h=[];for(;h.push(p),!p.isTextblock;)p=p.lastChild;let m=o,g=1;for(;!m.isTextblock;m=m.firstChild)g++;if(p.canReplace(p.childCount,p.childCount,m.content)){if(t){let b=S.empty;for(let w=h.length-1;w>=0;w--)b=S.from(h[w].copy(b));let x=n.tr.step(new Q(e.pos-h.length,e.pos+o.nodeSize,e.pos+g,e.pos+o.nodeSize-g,new M(b,h.length,0),0,!0));t(x.scrollIntoView())}return!0}}return!1}function rc(n){return function(e,t){let r=e.selection,i=n<0?r.$from:r.$to,o=i.depth;for(;i.node(o).isInline;){if(!o)return!1;o--}return i.node(o).isTextblock?(t&&t(e.tr.setSelection(P.create(e.doc,n<0?i.start(o):i.end(o)))),!0):!1}}var Ko=rc(-1),Uo=rc(1);function ic(n,e=null){return function(t,r){let{$from:i,$to:o}=t.selection,s=i.blockRange(o),l=s&&gn(s,n,e);return l?(r&&r(t.tr.wrap(s,l).scrollIntoView()),!0):!1}}function Go(n,e=null){return function(t,r){let i=!1;for(let o=0;o{if(i)return!1;if(!(!a.isTextblock||a.hasMarkup(n,e)))if(a.type==n)i=!0;else{let f=t.doc.resolve(c),u=f.index();i=f.parent.canReplaceWith(u,u+1,n)}})}if(!i)return!1;if(r){let o=t.tr;for(let s=0;s=2&&e.$from.node(e.depth-1).type.compatibleContent(t)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let a=s.resolve(e.start-2);o=new zt(a,a,e.depth),e.endIndex=0;f--)o=S.from(t[f].type.create(t[f].attrs,o));n.step(new Q(e.start-(r?2:0),e.end,e.start,e.end,new M(o,0,0),t.length,!0));let s=0;for(let f=0;fs.childCount>0&&s.firstChild.type==n);return o?t?r.node(o.depth-1).type==n?Tp(e,t,n,o):Ep(e,t,o):!0:!1}}function Tp(n,e,t,r){let i=n.tr,o=r.end,s=r.$to.end(r.depth);om;h--)p-=i.child(h).nodeSize,r.delete(p-1,p+1);let o=r.doc.resolve(t.start),s=o.nodeAfter;if(r.mapping.map(t.end)!=t.start+o.nodeAfter.nodeSize)return!1;let l=t.startIndex==0,a=t.endIndex==i.childCount,c=o.node(-1),f=o.index(-1);if(!c.canReplace(f+(l?0:1),f+1,s.content.append(a?S.empty:S.from(i))))return!1;let u=o.pos,d=u+s.nodeSize;return r.step(new Q(u-(l?1:0),d+(a?1:0),u+1,d-1,new M((l?S.empty:S.from(i.copy(S.empty))).append(a?S.empty:S.from(i.copy(S.empty))),l?0:1,a?0:1),l?0:1)),e(r.scrollIntoView()),!0}function lc(n){return function(e,t){let{$from:r,$to:i}=e.selection,o=r.blockRange(i,c=>c.childCount>0&&c.firstChild.type==n);if(!o)return!1;let s=o.startIndex;if(s==0)return!1;let l=o.parent,a=l.child(s-1);if(a.type!=n)return!1;if(t){let c=a.lastChild&&a.lastChild.type==l.type,f=S.from(c?n.create():null),u=new M(S.from(n.create(null,S.from(l.type.create(null,f)))),c?3:1,0),d=o.start,p=o.end;t(e.tr.step(new Q(d-(c?3:1),p,d,p,u,1,!0)).scrollIntoView())}return!0}}function yi(n){let{state:e,transaction:t}=n,{selection:r}=t,{doc:i}=t,{storedMarks:o}=t;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return o},get selection(){return r},get doc(){return i},get tr(){return r=t.selection,i=t.doc,o=t.storedMarks,t}}}var On=class{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:r}=this,{view:i}=t,{tr:o}=r,s=this.buildProps(o);return Object.fromEntries(Object.entries(e).map(([l,a])=>[l,(...f)=>{let u=a(...f)(s);return!o.getMeta("preventDispatch")&&!this.hasCustomState&&i.dispatch(o),u}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(e,t=!0){let{rawCommands:r,editor:i,state:o}=this,{view:s}=i,l=[],a=!!e,c=e||o.tr,f=()=>(!a&&t&&!c.getMeta("preventDispatch")&&!this.hasCustomState&&s.dispatch(c),l.every(d=>d===!0)),u={...Object.fromEntries(Object.entries(r).map(([d,p])=>[d,(...m)=>{let g=this.buildProps(c,t),b=p(...m)(g);return l.push(b),u}])),run:f};return u}createCan(e){let{rawCommands:t,state:r}=this,i=!1,o=e||r.tr,s=this.buildProps(o,i);return{...Object.fromEntries(Object.entries(t).map(([a,c])=>[a,(...f)=>c(...f)({...s,dispatch:void 0})])),chain:()=>this.createChain(o,i)}}buildProps(e,t=!0){let{rawCommands:r,editor:i,state:o}=this,{view:s}=i,l={tr:e,editor:i,view:s,state:yi({state:o,transaction:e}),dispatch:t?()=>{}:void 0,chain:()=>this.createChain(e,t),can:()=>this.createCan(e),get commands(){return Object.fromEntries(Object.entries(r).map(([a,c])=>[a,(...f)=>c(...f)(l)]))}};return l}},es=class{constructor(){this.callbacks={}}on(e,t){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(t),this}emit(e,...t){let r=this.callbacks[e];return r&&r.forEach(i=>i.apply(this,t)),this}off(e,t){let r=this.callbacks[e];return r&&(t?this.callbacks[e]=r.filter(i=>i!==t):delete this.callbacks[e]),this}once(e,t){let r=(...i)=>{this.off(e,r),t.apply(this,i)};return this.on(e,r)}removeAllListeners(){this.callbacks={}}};function O(n,e,t){return n.config[e]===void 0&&n.parent?O(n.parent,e,t):typeof n.config[e]=="function"?n.config[e].bind({...t,parent:n.parent?O(n.parent,e,t):null}):n.config[e]}function bi(n){let e=n.filter(i=>i.type==="extension"),t=n.filter(i=>i.type==="node"),r=n.filter(i=>i.type==="mark");return{baseExtensions:e,nodeExtensions:t,markExtensions:r}}function mc(n){let e=[],{nodeExtensions:t,markExtensions:r}=bi(n),i=[...t,...r],o={default:null,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return n.forEach(s=>{let l={name:s.name,options:s.options,storage:s.storage,extensions:i},a=O(s,"addGlobalAttributes",l);if(!a)return;a().forEach(f=>{f.types.forEach(u=>{Object.entries(f.attributes).forEach(([d,p])=>{e.push({type:u,name:d,attribute:{...o,...p}})})})})}),i.forEach(s=>{let l={name:s.name,options:s.options,storage:s.storage},a=O(s,"addAttributes",l);if(!a)return;let c=a();Object.entries(c).forEach(([f,u])=>{let d={...o,...u};typeof d?.default=="function"&&(d.default=d.default()),d?.isRequired&&d?.default===void 0&&delete d.default,e.push({type:s.name,name:f,attribute:d})})}),e}function le(n,e){if(typeof n=="string"){if(!e.nodes[n])throw Error(`There is no node type named '${n}'. Maybe you forgot to add the extension?`);return e.nodes[n]}return n}function V(...n){return n.filter(e=>!!e).reduce((e,t)=>{let r={...e};return Object.entries(t).forEach(([i,o])=>{if(!r[i]){r[i]=o;return}if(i==="class"){let l=o?String(o).split(" "):[],a=r[i]?r[i].split(" "):[],c=l.filter(f=>!a.includes(f));r[i]=[...a,...c].join(" ")}else if(i==="style"){let l=o?o.split(";").map(f=>f.trim()).filter(Boolean):[],a=r[i]?r[i].split(";").map(f=>f.trim()).filter(Boolean):[],c=new Map;a.forEach(f=>{let[u,d]=f.split(":").map(p=>p.trim());c.set(u,d)}),l.forEach(f=>{let[u,d]=f.split(":").map(p=>p.trim());c.set(u,d)}),r[i]=Array.from(c.entries()).map(([f,u])=>`${f}: ${u}`).join("; ")}else r[i]=o}),r},{})}function ts(n,e){return e.filter(t=>t.type===n.type.name).filter(t=>t.attribute.rendered).map(t=>t.attribute.renderHTML?t.attribute.renderHTML(n.attrs)||{}:{[t.name]:n.attrs[t.name]}).reduce((t,r)=>V(t,r),{})}function gc(n){return typeof n=="function"}function L(n,e=void 0,...t){return gc(n)?e?n.bind(e)(...t):n(...t):n}function Ap(n={}){return Object.keys(n).length===0&&n.constructor===Object}function Np(n){return typeof n!="string"?n:n.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(n):n==="true"?!0:n==="false"?!1:n}function ac(n,e){return"style"in n?n:{...n,getAttrs:t=>{let r=n.getAttrs?n.getAttrs(t):n.attrs;if(r===!1)return!1;let i=e.reduce((o,s)=>{let l=s.attribute.parseHTML?s.attribute.parseHTML(t):Np(t.getAttribute(s.name));return l==null?o:{...o,[s.name]:l}},{});return{...r,...i}}}}function cc(n){return Object.fromEntries(Object.entries(n).filter(([e,t])=>e==="attrs"&&Ap(t)?!1:t!=null))}function Dp(n,e){var t;let r=mc(n),{nodeExtensions:i,markExtensions:o}=bi(n),s=(t=i.find(c=>O(c,"topNode")))===null||t===void 0?void 0:t.name,l=Object.fromEntries(i.map(c=>{let f=r.filter(b=>b.type===c.name),u={name:c.name,options:c.options,storage:c.storage,editor:e},d=n.reduce((b,x)=>{let w=O(x,"extendNodeSchema",u);return{...b,...w?w(c):{}}},{}),p=cc({...d,content:L(O(c,"content",u)),marks:L(O(c,"marks",u)),group:L(O(c,"group",u)),inline:L(O(c,"inline",u)),atom:L(O(c,"atom",u)),selectable:L(O(c,"selectable",u)),draggable:L(O(c,"draggable",u)),code:L(O(c,"code",u)),whitespace:L(O(c,"whitespace",u)),linebreakReplacement:L(O(c,"linebreakReplacement",u)),defining:L(O(c,"defining",u)),isolating:L(O(c,"isolating",u)),attrs:Object.fromEntries(f.map(b=>{var x;return[b.name,{default:(x=b?.attribute)===null||x===void 0?void 0:x.default}]}))}),h=L(O(c,"parseHTML",u));h&&(p.parseDOM=h.map(b=>ac(b,f)));let m=O(c,"renderHTML",u);m&&(p.toDOM=b=>m({node:b,HTMLAttributes:ts(b,f)}));let g=O(c,"renderText",u);return g&&(p.toText=g),[c.name,p]})),a=Object.fromEntries(o.map(c=>{let f=r.filter(g=>g.type===c.name),u={name:c.name,options:c.options,storage:c.storage,editor:e},d=n.reduce((g,b)=>{let x=O(b,"extendMarkSchema",u);return{...g,...x?x(c):{}}},{}),p=cc({...d,inclusive:L(O(c,"inclusive",u)),excludes:L(O(c,"excludes",u)),group:L(O(c,"group",u)),spanning:L(O(c,"spanning",u)),code:L(O(c,"code",u)),attrs:Object.fromEntries(f.map(g=>{var b;return[g.name,{default:(b=g?.attribute)===null||b===void 0?void 0:b.default}]}))}),h=L(O(c,"parseHTML",u));h&&(p.parseDOM=h.map(g=>ac(g,f)));let m=O(c,"renderHTML",u);return m&&(p.toDOM=g=>m({mark:g,HTMLAttributes:ts(g,f)})),[c.name,p]}));return new Wn({topNode:s,nodes:l,marks:a})}function Xo(n,e){return e.nodes[n]||e.marks[n]||null}function fc(n,e){return Array.isArray(e)?e.some(t=>(typeof t=="string"?t:t.name)===n.name):e}function as(n,e){let t=ct.fromSchema(e).serializeFragment(n),i=document.implementation.createHTMLDocument().createElement("div");return i.appendChild(t),i.innerHTML}var Pp=(n,e=500)=>{let t="",r=n.parentOffset;return n.parent.nodesBetween(Math.max(0,r-e),r,(i,o,s,l)=>{var a,c;let f=((c=(a=i.type.spec).toText)===null||c===void 0?void 0:c.call(a,{node:i,pos:o,parent:s,index:l}))||i.textContent||"%leaf%";t+=i.isAtom&&!i.isText?f:f.slice(0,Math.max(0,r-o))}),t};function cs(n){return Object.prototype.toString.call(n)==="[object RegExp]"}var Tn=class{constructor(e){this.find=e.find,this.handler=e.handler}},Ip=(n,e)=>{if(cs(e))return e.exec(n);let t=e(n);if(!t)return null;let r=[t.text];return r.index=t.index,r.input=n,r.data=t.data,t.replaceWith&&(t.text.includes(t.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),r.push(t.replaceWith)),r};function ci(n){var e;let{editor:t,from:r,to:i,text:o,rules:s,plugin:l}=n,{view:a}=t;if(a.composing)return!1;let c=a.state.doc.resolve(r);if(c.parent.type.spec.code||!((e=c.nodeBefore||c.nodeAfter)===null||e===void 0)&&e.marks.find(d=>d.type.spec.code))return!1;let f=!1,u=Pp(c)+o;return s.forEach(d=>{if(f)return;let p=Ip(u,d.find);if(!p)return;let h=a.state.tr,m=yi({state:a.state,transaction:h}),g={from:r-(p[0].length-o.length),to:i},{commands:b,chain:x,can:w}=new On({editor:t,state:m});d.handler({state:m,range:g,match:p,commands:b,chain:x,can:w})===null||!h.steps.length||(h.setMeta(l,{transform:h,from:r,to:i,text:o}),a.dispatch(h),f=!0)}),f}function Rp(n){let{editor:e,rules:t}=n,r=new q({state:{init(){return null},apply(i,o,s){let l=i.getMeta(r);if(l)return l;let a=i.getMeta("applyInputRules");return!!a&&setTimeout(()=>{let{text:f}=a;typeof f=="string"?f=f:f=as(S.from(f),s.schema);let{from:u}=a,d=u+f.length;ci({editor:e,from:u,to:d,text:f,rules:t,plugin:r})}),i.selectionSet||i.docChanged?null:o}},props:{handleTextInput(i,o,s,l){return ci({editor:e,from:o,to:s,text:l,rules:t,plugin:r})},handleDOMEvents:{compositionend:i=>(setTimeout(()=>{let{$cursor:o}=i.state.selection;o&&ci({editor:e,from:o.pos,to:o.pos,text:"",rules:t,plugin:r})}),!1)},handleKeyDown(i,o){if(o.key!=="Enter")return!1;let{$cursor:s}=i.state.selection;return s?ci({editor:e,from:s.pos,to:s.pos,text:` -`,rules:t,plugin:r}):!1}},isInputRules:!0});return r}function Bp(n){return Object.prototype.toString.call(n).slice(8,-1)}function fi(n){return Bp(n)!=="Object"?!1:n.constructor===Object&&Object.getPrototypeOf(n)===Object.prototype}function vi(n,e){let t={...n};return fi(n)&&fi(e)&&Object.keys(e).forEach(r=>{fi(e[r])&&fi(n[r])?t[r]=vi(n[r],e[r]):t[r]=e[r]}),t}var _e=class n{constructor(e={}){this.type="mark",this.name="mark",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=L(O(this,"addOptions",{name:this.name}))),this.storage=L(O(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new n(e)}configure(e={}){let t=this.extend({...this.config,addOptions:()=>vi(this.options,e)});return t.name=this.name,t.parent=this.parent,t}extend(e={}){let t=new n(e);return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=L(O(t,"addOptions",{name:t.name})),t.storage=L(O(t,"addStorage",{name:t.name,options:t.options})),t}static handleExit({editor:e,mark:t}){let{tr:r}=e.state,i=e.state.selection.$from;if(i.pos===i.end()){let s=i.marks();if(!!!s.find(c=>c?.type.name===t.name))return!1;let a=s.find(c=>c?.type.name===t.name);return a&&r.removeStoredMark(a),r.insertText(" ",i.pos),e.view.dispatch(r),!0}return!1}};function Lp(n){return typeof n=="number"}var ns=class{constructor(e){this.find=e.find,this.handler=e.handler}},Fp=(n,e,t)=>{if(cs(e))return[...n.matchAll(e)];let r=e(n,t);return r?r.map(i=>{let o=[i.text];return o.index=i.index,o.input=n,o.data=i.data,i.replaceWith&&(i.text.includes(i.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),o.push(i.replaceWith)),o}):[]};function zp(n){let{editor:e,state:t,from:r,to:i,rule:o,pasteEvent:s,dropEvent:l}=n,{commands:a,chain:c,can:f}=new On({editor:e,state:t}),u=[];return t.doc.nodesBetween(r,i,(p,h)=>{if(!p.isTextblock||p.type.spec.code)return;let m=Math.max(r,h),g=Math.min(i,h+p.content.size),b=p.textBetween(m-h,g-h,void 0,"\uFFFC");Fp(b,o.find,s).forEach(w=>{if(w.index===void 0)return;let y=m+w.index+1,C=y+w[0].length,k={from:t.tr.mapping.map(y),to:t.tr.mapping.map(C)},I=o.handler({state:t,range:k,match:w,commands:a,chain:c,can:f,pasteEvent:s,dropEvent:l});u.push(I)})}),u.every(p=>p!==null)}var ui=null,Vp=n=>{var e;let t=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=t.clipboardData)===null||e===void 0||e.setData("text/html",n),t};function $p(n){let{editor:e,rules:t}=n,r=null,i=!1,o=!1,s=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,l;try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}let a=({state:f,from:u,to:d,rule:p,pasteEvt:h})=>{let m=f.tr,g=yi({state:f,transaction:m});if(!(!zp({editor:e,state:g,from:Math.max(u-1,0),to:d.b-1,rule:p,pasteEvent:h,dropEvent:l})||!m.steps.length)){try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}return s=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,m}};return t.map(f=>new q({view(u){let d=h=>{var m;r=!((m=u.dom.parentElement)===null||m===void 0)&&m.contains(h.target)?u.dom.parentElement:null,r&&(ui=e)},p=()=>{ui&&(ui=null)};return window.addEventListener("dragstart",d),window.addEventListener("dragend",p),{destroy(){window.removeEventListener("dragstart",d),window.removeEventListener("dragend",p)}}},props:{handleDOMEvents:{drop:(u,d)=>{if(o=r===u.dom.parentElement,l=d,!o){let p=ui;p&&setTimeout(()=>{let h=p.state.selection;h&&p.commands.deleteRange({from:h.from,to:h.to})},10)}return!1},paste:(u,d)=>{var p;let h=(p=d.clipboardData)===null||p===void 0?void 0:p.getData("text/html");return s=d,i=!!h?.includes("data-pm-slice"),!1}}},appendTransaction:(u,d,p)=>{let h=u[0],m=h.getMeta("uiEvent")==="paste"&&!i,g=h.getMeta("uiEvent")==="drop"&&!o,b=h.getMeta("applyPasteRules"),x=!!b;if(!m&&!g&&!x)return;if(x){let{text:C}=b;typeof C=="string"?C=C:C=as(S.from(C),p.schema);let{from:k}=b,I=k+C.length,B=Vp(C);return a({rule:f,state:p,from:k,to:{b:I},pasteEvt:B})}let w=d.doc.content.findDiffStart(p.doc.content),y=d.doc.content.findDiffEnd(p.doc.content);if(!(!Lp(w)||!y||w===y.b))return a({rule:f,state:p,from:w,to:y,pasteEvt:s})}}))}function Hp(n){let e=n.filter((t,r)=>n.indexOf(t)!==r);return Array.from(new Set(e))}var rs=class n{constructor(e,t){this.splittableMarks=[],this.editor=t,this.extensions=n.resolve(e),this.schema=Dp(this.extensions,t),this.setupExtensions()}static resolve(e){let t=n.sort(n.flatten(e)),r=Hp(t.map(i=>i.name));return r.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${r.map(i=>`'${i}'`).join(", ")}]. This can lead to issues.`),t}static flatten(e){return e.map(t=>{let r={name:t.name,options:t.options,storage:t.storage},i=O(t,"addExtensions",r);return i?[t,...this.flatten(i())]:t}).flat(10)}static sort(e){return e.sort((r,i)=>{let o=O(r,"priority")||100,s=O(i,"priority")||100;return o>s?-1:o{let r={name:t.name,options:t.options,storage:t.storage,editor:this.editor,type:Xo(t.name,this.schema)},i=O(t,"addCommands",r);return i?{...e,...i()}:e},{})}get plugins(){let{editor:e}=this,t=n.sort([...this.extensions].reverse()),r=[],i=[],o=t.map(s=>{let l={name:s.name,options:s.options,storage:s.storage,editor:e,type:Xo(s.name,this.schema)},a=[],c=O(s,"addKeyboardShortcuts",l),f={};if(s.type==="mark"&&O(s,"exitable",l)&&(f.ArrowRight=()=>_e.handleExit({editor:e,mark:s})),c){let m=Object.fromEntries(Object.entries(c()).map(([g,b])=>[g,()=>b({editor:e})]));f={...f,...m}}let u=Ja(f);a.push(u);let d=O(s,"addInputRules",l);fc(s,e.options.enableInputRules)&&d&&r.push(...d());let p=O(s,"addPasteRules",l);fc(s,e.options.enablePasteRules)&&p&&i.push(...p());let h=O(s,"addProseMirrorPlugins",l);if(h){let m=h();a.push(...m)}return a}).flat();return[Rp({editor:e,rules:r}),...$p({editor:e,rules:i}),...o]}get attributes(){return mc(this.extensions)}get nodeViews(){let{editor:e}=this,{nodeExtensions:t}=bi(this.extensions);return Object.fromEntries(t.filter(r=>!!O(r,"addNodeView")).map(r=>{let i=this.attributes.filter(a=>a.type===r.name),o={name:r.name,options:r.options,storage:r.storage,editor:e,type:le(r.name,this.schema)},s=O(r,"addNodeView",o);if(!s)return[];let l=(a,c,f,u,d)=>{let p=ts(a,i);return s()({node:a,view:c,getPos:f,decorations:u,innerDecorations:d,editor:e,extension:r,HTMLAttributes:p})};return[r.name,l]}))}setupExtensions(){this.extensions.forEach(e=>{var t;this.editor.extensionStorage[e.name]=e.storage;let r={name:e.name,options:e.options,storage:e.storage,editor:this.editor,type:Xo(e.name,this.schema)};e.type==="mark"&&(!((t=L(O(e,"keepOnSplit",r)))!==null&&t!==void 0)||t)&&this.splittableMarks.push(e.name);let i=O(e,"onBeforeCreate",r),o=O(e,"onCreate",r),s=O(e,"onUpdate",r),l=O(e,"onSelectionUpdate",r),a=O(e,"onTransaction",r),c=O(e,"onFocus",r),f=O(e,"onBlur",r),u=O(e,"onDestroy",r);i&&this.editor.on("beforeCreate",i),o&&this.editor.on("create",o),s&&this.editor.on("update",s),l&&this.editor.on("selectionUpdate",l),a&&this.editor.on("transaction",a),c&&this.editor.on("focus",c),f&&this.editor.on("blur",f),u&&this.editor.on("destroy",u)})}},te=class n{constructor(e={}){this.type="extension",this.name="extension",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=L(O(this,"addOptions",{name:this.name}))),this.storage=L(O(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new n(e)}configure(e={}){let t=this.extend({...this.config,addOptions:()=>vi(this.options,e)});return t.name=this.name,t.parent=this.parent,t}extend(e={}){let t=new n({...this.config,...e});return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=L(O(t,"addOptions",{name:t.name})),t.storage=L(O(t,"addStorage",{name:t.name,options:t.options})),t}};function yc(n,e,t){let{from:r,to:i}=e,{blockSeparator:o=` - -`,textSerializers:s={}}=t||{},l="";return n.nodesBetween(r,i,(a,c,f,u)=>{var d;a.isBlock&&c>r&&(l+=o);let p=s?.[a.type.name];if(p)return f&&(l+=p({node:a,pos:c,parent:f,index:u,range:e})),!1;a.isText&&(l+=(d=a?.text)===null||d===void 0?void 0:d.slice(Math.max(r,c)-c,i-c))}),l}function bc(n){return Object.fromEntries(Object.entries(n.nodes).filter(([,e])=>e.spec.toText).map(([e,t])=>[e,t.spec.toText]))}var Wp=te.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new q({key:new X("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{let{editor:n}=this,{state:e,schema:t}=n,{doc:r,selection:i}=e,{ranges:o}=i,s=Math.min(...o.map(f=>f.$from.pos)),l=Math.max(...o.map(f=>f.$to.pos)),a=bc(t);return yc(r,{from:s,to:l},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:a})}}})]}}),jp=()=>({editor:n,view:e})=>(requestAnimationFrame(()=>{var t;n.isDestroyed||(e.dom.blur(),(t=window?.getSelection())===null||t===void 0||t.removeAllRanges())}),!0),qp=(n=!1)=>({commands:e})=>e.setContent("",n),Jp=()=>({state:n,tr:e,dispatch:t})=>{let{selection:r}=e,{ranges:i}=r;return t&&i.forEach(({$from:o,$to:s})=>{n.doc.nodesBetween(o.pos,s.pos,(l,a)=>{if(l.type.isText)return;let{doc:c,mapping:f}=e,u=c.resolve(f.map(a)),d=c.resolve(f.map(a+l.nodeSize)),p=u.blockRange(d);if(!p)return;let h=ut(p);if(l.type.isTextblock){let{defaultType:m}=u.parent.contentMatchAt(u.index());e.setNodeMarkup(p.start,m)}(h||h===0)&&e.lift(p,h)})}),!0},_p=n=>e=>n(e),Kp=()=>({state:n,dispatch:e})=>Jo(n,e),Up=(n,e)=>({editor:t,tr:r})=>{let{state:i}=t,o=i.doc.slice(n.from,n.to);r.deleteRange(n.from,n.to);let s=r.mapping.map(e);return r.insert(s,o.content),r.setSelection(new P(r.doc.resolve(s-1))),!0},Gp=()=>({tr:n,dispatch:e})=>{let{selection:t}=n,r=t.$anchor.node();if(r.content.size>0)return!1;let i=n.selection.$anchor;for(let o=i.depth;o>0;o-=1)if(i.node(o).type===r.type){if(e){let l=i.before(o),a=i.after(o);n.delete(l,a).scrollIntoView()}return!0}return!1},Yp=n=>({tr:e,state:t,dispatch:r})=>{let i=le(n,t.schema),o=e.selection.$anchor;for(let s=o.depth;s>0;s-=1)if(o.node(s).type===i){if(r){let a=o.before(s),c=o.after(s);e.delete(a,c).scrollIntoView()}return!0}return!1},Xp=n=>({tr:e,dispatch:t})=>{let{from:r,to:i}=n;return t&&e.delete(r,i),!0},Zp=()=>({state:n,dispatch:e})=>ai(n,e),Qp=()=>({commands:n})=>n.keyboardShortcut("Enter"),eh=()=>({state:n,dispatch:e})=>qo(n,e);function hi(n,e,t={strict:!0}){let r=Object.keys(e);return r.length?r.every(i=>t.strict?e[i]===n[i]:cs(e[i])?e[i].test(n[i]):e[i]===n[i]):!0}function vc(n,e,t={}){return n.find(r=>r.type===e&&hi(Object.fromEntries(Object.keys(t).map(i=>[i,r.attrs[i]])),t))}function uc(n,e,t={}){return!!vc(n,e,t)}function fs(n,e,t){var r;if(!n||!e)return;let i=n.parent.childAfter(n.parentOffset);if((!i.node||!i.node.marks.some(f=>f.type===e))&&(i=n.parent.childBefore(n.parentOffset)),!i.node||!i.node.marks.some(f=>f.type===e)||(t=t||((r=i.node.marks[0])===null||r===void 0?void 0:r.attrs),!vc([...i.node.marks],e,t)))return;let s=i.index,l=n.start()+i.offset,a=s+1,c=l+i.node.nodeSize;for(;s>0&&uc([...n.parent.child(s-1).marks],e,t);)s-=1,l-=n.parent.child(s).nodeSize;for(;a({tr:t,state:r,dispatch:i})=>{let o=At(n,r.schema),{doc:s,selection:l}=t,{$from:a,from:c,to:f}=l;if(i){let u=fs(a,o,e);if(u&&u.from<=c&&u.to>=f){let d=P.create(s,u.from,u.to);t.setSelection(d)}}return!0},nh=n=>e=>{let t=typeof n=="function"?n(e):n;for(let r=0;r({editor:t,view:r,tr:i,dispatch:o})=>{e={scrollIntoView:!0,...e};let s=()=>{r.dom.focus(),requestAnimationFrame(()=>{t.isDestroyed||(r.focus(),e?.scrollIntoView&&t.commands.scrollIntoView())})};if(r.hasFocus()&&n===null||n===!1)return!0;if(o&&n===null&&!xc(t.state.selection))return s(),!0;let l=kc(i.doc,n)||t.state.selection,a=t.state.selection.eq(l);return o&&(a||i.setSelection(l),a&&i.storedMarks&&i.setStoredMarks(i.storedMarks),s()),!0},ih=(n,e)=>t=>n.every((r,i)=>e(r,{...t,index:i})),oh=(n,e)=>({tr:t,commands:r})=>r.insertContentAt({from:t.selection.from,to:t.selection.to},n,e),Sc=n=>{let e=n.childNodes;for(let t=e.length-1;t>=0;t-=1){let r=e[t];r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?n.removeChild(r):r.nodeType===1&&Sc(r)}return n};function di(n){let e=`${n}`,t=new window.DOMParser().parseFromString(e,"text/html").body;return Sc(t)}function mi(n,e,t){if(n instanceof Re||n instanceof S)return n;t={slice:!0,parseOptions:{},...t};let r=typeof n=="object"&&n!==null,i=typeof n=="string";if(r)try{if(Array.isArray(n)&&n.length>0)return S.fromArray(n.map(l=>e.nodeFromJSON(l)));let s=e.nodeFromJSON(n);return t.errorOnInvalidContent&&s.check(),s}catch(o){if(t.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:o});return console.warn("[tiptap warn]: Invalid content.","Passed value:",n,"Error:",o),mi("",e,t)}if(i){if(t.errorOnInvalidContent){let s=!1,l="",a=new Wn({topNode:e.spec.topNode,marks:e.spec.marks,nodes:e.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:c=>(s=!0,l=typeof c=="string"?c:c.outerHTML,null)}]}})});if(t.slice?at.fromSchema(a).parseSlice(di(n),t.parseOptions):at.fromSchema(a).parse(di(n),t.parseOptions),t.errorOnInvalidContent&&s)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${l}`)})}let o=at.fromSchema(e);return t.slice?o.parseSlice(di(n),t.parseOptions).content:o.parse(di(n),t.parseOptions)}return mi("",e,t)}function sh(n,e,t){let r=n.steps.length-1;if(r{s===0&&(s=f)}),n.setSelection(D.near(n.doc.resolve(s),t))}var lh=n=>!("type"in n),ah=(n,e,t)=>({tr:r,dispatch:i,editor:o})=>{var s;if(i){t={parseOptions:o.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...t};let l;try{l=mi(e,o.schema,{parseOptions:{preserveWhitespace:"full",...t.parseOptions},errorOnInvalidContent:(s=t.errorOnInvalidContent)!==null&&s!==void 0?s:o.options.enableContentCheck})}catch(h){return o.emit("contentError",{editor:o,error:h,disableCollaboration:()=>{o.storage.collaboration&&(o.storage.collaboration.isDisabled=!0)}}),!1}let{from:a,to:c}=typeof n=="number"?{from:n,to:n}:{from:n.from,to:n.to},f=!0,u=!0;if((lh(l)?l:[l]).forEach(h=>{h.check(),f=f?h.isText&&h.marks.length===0:!1,u=u?h.isBlock:!1}),a===c&&u){let{parent:h}=r.doc.resolve(a);h.isTextblock&&!h.type.spec.code&&!h.childCount&&(a-=1,c+=1)}let p;if(f){if(Array.isArray(e))p=e.map(h=>h.text||"").join("");else if(e instanceof S){let h="";e.forEach(m=>{m.text&&(h+=m.text)}),p=h}else typeof e=="object"&&e&&e.text?p=e.text:p=e;r.insertText(p,a,c)}else p=l,r.replaceWith(a,c,p);t.updateSelection&&sh(r,r.steps.length-1,-1),t.applyInputRules&&r.setMeta("applyInputRules",{from:a,text:p}),t.applyPasteRules&&r.setMeta("applyPasteRules",{from:a,text:p})}return!0},ch=()=>({state:n,dispatch:e})=>Za(n,e),fh=()=>({state:n,dispatch:e})=>Qa(n,e),uh=()=>({state:n,dispatch:e})=>Lo(n,e),dh=()=>({state:n,dispatch:e})=>Vo(n,e),ph=()=>({state:n,dispatch:e,tr:t})=>{try{let r=yn(n.doc,n.selection.$from.pos,-1);return r==null?!1:(t.join(r,2),e&&e(t),!0)}catch{return!1}},hh=()=>({state:n,dispatch:e,tr:t})=>{try{let r=yn(n.doc,n.selection.$from.pos,1);return r==null?!1:(t.join(r,2),e&&e(t),!0)}catch{return!1}},mh=()=>({state:n,dispatch:e})=>Ua(n,e),gh=()=>({state:n,dispatch:e})=>Ga(n,e);function wc(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}function Mc(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function yh(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t==="Space"&&(t=" ");let r,i,o,s;for(let l=0;l({editor:e,view:t,tr:r,dispatch:i})=>{let o=yh(n).split(/-(?!$)/),s=o.find(c=>!["Alt","Ctrl","Meta","Shift"].includes(c)),l=new KeyboardEvent("keydown",{key:s==="Space"?" ":s,altKey:o.includes("Alt"),ctrlKey:o.includes("Ctrl"),metaKey:o.includes("Meta"),shiftKey:o.includes("Shift"),bubbles:!0,cancelable:!0}),a=e.captureTransaction(()=>{t.someProp("handleKeyDown",c=>c(t,l))});return a?.steps.forEach(c=>{let f=c.map(r.mapping);f&&i&&r.maybeStep(f)}),!0};function cr(n,e,t={}){let{from:r,to:i,empty:o}=n.selection,s=e?le(e,n.schema):null,l=[];n.doc.nodesBetween(r,i,(u,d)=>{if(u.isText)return;let p=Math.max(r,d),h=Math.min(i,d+u.nodeSize);l.push({node:u,from:p,to:h})});let a=i-r,c=l.filter(u=>s?s.name===u.node.type.name:!0).filter(u=>hi(u.node.attrs,t,{strict:!1}));return o?!!c.length:c.reduce((u,d)=>u+d.to-d.from,0)>=a}var vh=(n,e={})=>({state:t,dispatch:r})=>{let i=le(n,t.schema);return cr(t,i,e)?ec(t,r):!1},xh=()=>({state:n,dispatch:e})=>_o(n,e),kh=n=>({state:e,dispatch:t})=>{let r=le(n,e.schema);return sc(r)(e,t)},Sh=()=>({state:n,dispatch:e})=>Wo(n,e);function xi(n,e){return e.nodes[n]?"node":e.marks[n]?"mark":null}function dc(n,e){let t=typeof e=="string"?[e]:e;return Object.keys(n).reduce((r,i)=>(t.includes(i)||(r[i]=n[i]),r),{})}var wh=(n,e)=>({tr:t,state:r,dispatch:i})=>{let o=null,s=null,l=xi(typeof n=="string"?n:n.name,r.schema);return l?(l==="node"&&(o=le(n,r.schema)),l==="mark"&&(s=At(n,r.schema)),i&&t.selection.ranges.forEach(a=>{r.doc.nodesBetween(a.$from.pos,a.$to.pos,(c,f)=>{o&&o===c.type&&t.setNodeMarkup(f,void 0,dc(c.attrs,e)),s&&c.marks.length&&c.marks.forEach(u=>{s===u.type&&t.addMark(f,f+c.nodeSize,s.create(dc(u.attrs,e)))})})}),!0):!1},Mh=()=>({tr:n,dispatch:e})=>(e&&n.scrollIntoView(),!0),Ch=()=>({tr:n,dispatch:e})=>{if(e){let t=new we(n.doc);n.setSelection(t)}return!0},Oh=()=>({state:n,dispatch:e})=>Fo(n,e),Th=()=>({state:n,dispatch:e})=>$o(n,e),Eh=()=>({state:n,dispatch:e})=>tc(n,e),Ah=()=>({state:n,dispatch:e})=>Uo(n,e),Nh=()=>({state:n,dispatch:e})=>Ko(n,e);function is(n,e,t={},r={}){return mi(n,e,{slice:!1,parseOptions:t,errorOnInvalidContent:r.errorOnInvalidContent})}var Dh=(n,e=!1,t={},r={})=>({editor:i,tr:o,dispatch:s,commands:l})=>{var a,c;let{doc:f}=o;if(t.preserveWhitespace!=="full"){let u=is(n,i.schema,t,{errorOnInvalidContent:(a=r.errorOnInvalidContent)!==null&&a!==void 0?a:i.options.enableContentCheck});return s&&o.replaceWith(0,f.content.size,u).setMeta("preventUpdate",!e),!0}return s&&o.setMeta("preventUpdate",!e),l.insertContentAt({from:0,to:f.content.size},n,{parseOptions:t,errorOnInvalidContent:(c=r.errorOnInvalidContent)!==null&&c!==void 0?c:i.options.enableContentCheck})};function Cc(n,e){let t=At(e,n.schema),{from:r,to:i,empty:o}=n.selection,s=[];o?(n.storedMarks&&s.push(...n.storedMarks),s.push(...n.selection.$head.marks())):n.doc.nodesBetween(r,i,a=>{s.push(...a.marks)});let l=s.find(a=>a.type.name===t.name);return l?{...l.attrs}:{}}function Ph(n){for(let e=0;e0;t-=1){let r=n.node(t);if(e(r))return{pos:t>0?n.before(t):0,start:n.start(t),depth:t,node:r}}}function us(n){return e=>Ih(e.$from,n)}function Rh(n,e){let t={from:0,to:n.content.size};return yc(n,t,e)}function Bh(n,e){let t=le(e,n.schema),{from:r,to:i}=n.selection,o=[];n.doc.nodesBetween(r,i,l=>{o.push(l)});let s=o.reverse().find(l=>l.type.name===t.name);return s?{...s.attrs}:{}}function Lh(n,e){let t=xi(typeof e=="string"?e:e.name,n.schema);return t==="node"?Bh(n,e):t==="mark"?Cc(n,e):{}}function Oc(n,e,t){let r=[];return n===e?t.resolve(n).marks().forEach(i=>{let o=t.resolve(n),s=fs(o,i.type);s&&r.push({mark:i,...s})}):t.nodesBetween(n,e,(i,o)=>{!i||i?.nodeSize===void 0||r.push(...i.marks.map(s=>({from:o,to:o+i.nodeSize,mark:s})))}),r}function pi(n,e,t){return Object.fromEntries(Object.entries(t).filter(([r])=>{let i=n.find(o=>o.type===e&&o.name===r);return i?i.attribute.keepOnSplit:!1}))}function ss(n,e,t={}){let{empty:r,ranges:i}=n.selection,o=e?At(e,n.schema):null;if(r)return!!(n.storedMarks||n.selection.$from.marks()).filter(u=>o?o.name===u.type.name:!0).find(u=>hi(u.attrs,t,{strict:!1}));let s=0,l=[];if(i.forEach(({$from:u,$to:d})=>{let p=u.pos,h=d.pos;n.doc.nodesBetween(p,h,(m,g)=>{if(!m.isText&&!m.marks.length)return;let b=Math.max(p,g),x=Math.min(h,g+m.nodeSize),w=x-b;s+=w,l.push(...m.marks.map(y=>({mark:y,from:b,to:x})))})}),s===0)return!1;let a=l.filter(u=>o?o.name===u.mark.type.name:!0).filter(u=>hi(u.mark.attrs,t,{strict:!1})).reduce((u,d)=>u+d.to-d.from,0),c=l.filter(u=>o?u.mark.type!==o&&u.mark.type.excludes(o):!0).reduce((u,d)=>u+d.to-d.from,0);return(a>0?a+c:a)>=s}function Fh(n,e,t={}){if(!e)return cr(n,null,t)||ss(n,null,t);let r=xi(e,n.schema);return r==="node"?cr(n,e,t):r==="mark"?ss(n,e,t):!1}function pc(n,e){let{nodeExtensions:t}=bi(e),r=t.find(s=>s.name===n);if(!r)return!1;let i={name:r.name,options:r.options,storage:r.storage},o=L(O(r,"group",i));return typeof o!="string"?!1:o.split(" ").includes("list")}function fr(n,{checkChildren:e=!0,ignoreWhitespace:t=!1}={}){var r;if(t){if(n.type.name==="hardBreak")return!0;if(n.isText)return/^\s*$/m.test((r=n.text)!==null&&r!==void 0?r:"")}if(n.isText)return!n.text;if(n.isAtom||n.isLeaf)return!1;if(n.content.childCount===0)return!0;if(e){let i=!0;return n.content.forEach(o=>{i!==!1&&(fr(o,{ignoreWhitespace:t,checkChildren:e})||(i=!1))}),i}return!1}function Tc(n){return n instanceof A}function zh(n,e,t){var r;let{selection:i}=e,o=null;if(xc(i)&&(o=i.$cursor),o){let l=(r=n.storedMarks)!==null&&r!==void 0?r:o.marks();return!!t.isInSet(l)||!l.some(a=>a.type.excludes(t))}let{ranges:s}=i;return s.some(({$from:l,$to:a})=>{let c=l.depth===0?n.doc.inlineContent&&n.doc.type.allowsMarkType(t):!1;return n.doc.nodesBetween(l.pos,a.pos,(f,u,d)=>{if(c)return!1;if(f.isInline){let p=!d||d.type.allowsMarkType(t),h=!!t.isInSet(f.marks)||!f.marks.some(m=>m.type.excludes(t));c=p&&h}return!c}),c})}var Vh=(n,e={})=>({tr:t,state:r,dispatch:i})=>{let{selection:o}=t,{empty:s,ranges:l}=o,a=At(n,r.schema);if(i)if(s){let c=Cc(r,a);t.addStoredMark(a.create({...c,...e}))}else l.forEach(c=>{let f=c.$from.pos,u=c.$to.pos;r.doc.nodesBetween(f,u,(d,p)=>{let h=Math.max(p,f),m=Math.min(p+d.nodeSize,u);d.marks.find(b=>b.type===a)?d.marks.forEach(b=>{a===b.type&&t.addMark(h,m,a.create({...b.attrs,...e}))}):t.addMark(h,m,a.create(e))})});return zh(r,t,a)},$h=(n,e)=>({tr:t})=>(t.setMeta(n,e),!0),Hh=(n,e={})=>({state:t,dispatch:r,chain:i})=>{let o=le(n,t.schema),s;return t.selection.$anchor.sameParent(t.selection.$head)&&(s=t.selection.$anchor.parent.attrs),o.isTextblock?i().command(({commands:l})=>Go(o,{...s,...e})(t)?!0:l.clearNodes()).command(({state:l})=>Go(o,{...s,...e})(l,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},Wh=n=>({tr:e,dispatch:t})=>{if(t){let{doc:r}=e,i=Yt(n,0,r.content.size),o=A.create(r,i);e.setSelection(o)}return!0},jh=n=>({tr:e,dispatch:t})=>{if(t){let{doc:r}=e,{from:i,to:o}=typeof n=="number"?{from:n,to:n}:n,s=P.atStart(r).from,l=P.atEnd(r).to,a=Yt(i,s,l),c=Yt(o,s,l),f=P.create(r,a,c);e.setSelection(f)}return!0},qh=n=>({state:e,dispatch:t})=>{let r=le(n,e.schema);return lc(r)(e,t)};function hc(n,e){let t=n.storedMarks||n.selection.$to.parentOffset&&n.selection.$from.marks();if(t){let r=t.filter(i=>e?.includes(i.type.name));n.tr.ensureMarks(r)}}var Jh=({keepMarks:n=!0}={})=>({tr:e,state:t,dispatch:r,editor:i})=>{let{selection:o,doc:s}=e,{$from:l,$to:a}=o,c=i.extensionManager.attributes,f=pi(c,l.node().type.name,l.node().attrs);if(o instanceof A&&o.node.isBlock)return!l.parentOffset||!Be(s,l.pos)?!1:(r&&(n&&hc(t,i.extensionManager.splittableMarks),e.split(l.pos).scrollIntoView()),!0);if(!l.parent.isBlock)return!1;let u=a.parentOffset===a.parent.content.size,d=l.depth===0?void 0:Ph(l.node(-1).contentMatchAt(l.indexAfter(-1))),p=u&&d?[{type:d,attrs:f}]:void 0,h=Be(e.doc,e.mapping.map(l.pos),1,p);if(!p&&!h&&Be(e.doc,e.mapping.map(l.pos),1,d?[{type:d}]:void 0)&&(h=!0,p=d?[{type:d,attrs:f}]:void 0),r){if(h&&(o instanceof P&&e.deleteSelection(),e.split(e.mapping.map(l.pos),1,p),d&&!u&&!l.parentOffset&&l.parent.type!==d)){let m=e.mapping.map(l.before()),g=e.doc.resolve(m);l.node(-1).canReplaceWith(g.index(),g.index()+1,d)&&e.setNodeMarkup(e.mapping.map(l.before()),d)}n&&hc(t,i.extensionManager.splittableMarks),e.scrollIntoView()}return h},_h=(n,e={})=>({tr:t,state:r,dispatch:i,editor:o})=>{var s;let l=le(n,r.schema),{$from:a,$to:c}=r.selection,f=r.selection.node;if(f&&f.isBlock||a.depth<2||!a.sameParent(c))return!1;let u=a.node(-1);if(u.type!==l)return!1;let d=o.extensionManager.attributes;if(a.parent.content.size===0&&a.node(-1).childCount===a.indexAfter(-1)){if(a.depth===2||a.node(-3).type!==l||a.index(-2)!==a.node(-2).childCount-1)return!1;if(i){let b=S.empty,x=a.index(-1)?1:a.index(-2)?2:3;for(let B=a.depth-x;B>=a.depth-3;B-=1)b=S.from(a.node(B).copy(b));let w=a.indexAfter(-1){if(I>-1)return!1;B.isTextblock&&B.content.size===0&&(I=T+1)}),I>-1&&t.setSelection(P.near(t.doc.resolve(I))),t.scrollIntoView()}return!0}let p=c.pos===a.end()?u.contentMatchAt(0).defaultType:null,h={...pi(d,u.type.name,u.attrs),...e},m={...pi(d,a.node().type.name,a.node().attrs),...e};t.delete(a.pos,c.pos);let g=p?[{type:l,attrs:h},{type:p,attrs:m}]:[{type:l,attrs:h}];if(!Be(t.doc,a.pos,2))return!1;if(i){let{selection:b,storedMarks:x}=r,{splittableMarks:w}=o.extensionManager,y=x||b.$to.parentOffset&&b.$from.marks();if(t.split(a.pos,2,g).scrollIntoView(),!y||!i)return!0;let C=y.filter(k=>w.includes(k.type.name));t.ensureMarks(C)}return!0},Zo=(n,e)=>{let t=us(s=>s.type===e)(n.selection);if(!t)return!0;let r=n.doc.resolve(Math.max(0,t.pos-1)).before(t.depth);if(r===void 0)return!0;let i=n.doc.nodeAt(r);return t.node.type===i?.type&&qe(n.doc,t.pos)&&n.join(t.pos),!0},Qo=(n,e)=>{let t=us(s=>s.type===e)(n.selection);if(!t)return!0;let r=n.doc.resolve(t.start).after(t.depth);if(r===void 0)return!0;let i=n.doc.nodeAt(r);return t.node.type===i?.type&&qe(n.doc,r)&&n.join(r),!0},Kh=(n,e,t,r={})=>({editor:i,tr:o,state:s,dispatch:l,chain:a,commands:c,can:f})=>{let{extensions:u,splittableMarks:d}=i.extensionManager,p=le(n,s.schema),h=le(e,s.schema),{selection:m,storedMarks:g}=s,{$from:b,$to:x}=m,w=b.blockRange(x),y=g||m.$to.parentOffset&&m.$from.marks();if(!w)return!1;let C=us(k=>pc(k.type.name,u))(m);if(w.depth>=1&&C&&w.depth-C.depth<=1){if(C.node.type===p)return c.liftListItem(h);if(pc(C.node.type.name,u)&&p.validContent(C.node.content)&&l)return a().command(()=>(o.setNodeMarkup(C.pos,p),!0)).command(()=>Zo(o,p)).command(()=>Qo(o,p)).run()}return!t||!y||!l?a().command(()=>f().wrapInList(p,r)?!0:c.clearNodes()).wrapInList(p,r).command(()=>Zo(o,p)).command(()=>Qo(o,p)).run():a().command(()=>{let k=f().wrapInList(p,r),I=y.filter(B=>d.includes(B.type.name));return o.ensureMarks(I),k?!0:c.clearNodes()}).wrapInList(p,r).command(()=>Zo(o,p)).command(()=>Qo(o,p)).run()},Uh=(n,e={},t={})=>({state:r,commands:i})=>{let{extendEmptyMarkRange:o=!1}=t,s=At(n,r.schema);return ss(r,s,e)?i.unsetMark(s,{extendEmptyMarkRange:o}):i.setMark(s,e)},Gh=(n,e,t={})=>({state:r,commands:i})=>{let o=le(n,r.schema),s=le(e,r.schema),l=cr(r,o,t),a;return r.selection.$anchor.sameParent(r.selection.$head)&&(a=r.selection.$anchor.parent.attrs),l?i.setNode(s,a):i.setNode(o,{...a,...t})},Yh=(n,e={})=>({state:t,commands:r})=>{let i=le(n,t.schema);return cr(t,i,e)?r.lift(i):r.wrapIn(i,e)},Xh=()=>({state:n,dispatch:e})=>{let t=n.plugins;for(let r=0;r=0;a-=1)s.step(l.steps[a].invert(l.docs[a]));if(o.text){let a=s.doc.resolve(o.from).marks();s.replaceWith(o.from,o.to,n.schema.text(o.text,a))}else s.delete(o.from,o.to)}return!0}}return!1},Zh=()=>({tr:n,dispatch:e})=>{let{selection:t}=n,{empty:r,ranges:i}=t;return r||e&&i.forEach(o=>{n.removeMark(o.$from.pos,o.$to.pos)}),!0},Qh=(n,e={})=>({tr:t,state:r,dispatch:i})=>{var o;let{extendEmptyMarkRange:s=!1}=e,{selection:l}=t,a=At(n,r.schema),{$from:c,empty:f,ranges:u}=l;if(!i)return!0;if(f&&s){let{from:d,to:p}=l,h=(o=c.marks().find(g=>g.type===a))===null||o===void 0?void 0:o.attrs,m=fs(c,a,h);m&&(d=m.from,p=m.to),t.removeMark(d,p,a)}else u.forEach(d=>{t.removeMark(d.$from.pos,d.$to.pos,a)});return t.removeStoredMark(a),!0},em=(n,e={})=>({tr:t,state:r,dispatch:i})=>{let o=null,s=null,l=xi(typeof n=="string"?n:n.name,r.schema);return l?(l==="node"&&(o=le(n,r.schema)),l==="mark"&&(s=At(n,r.schema)),i&&t.selection.ranges.forEach(a=>{let c=a.$from.pos,f=a.$to.pos,u,d,p,h;t.selection.empty?r.doc.nodesBetween(c,f,(m,g)=>{o&&o===m.type&&(p=Math.max(g,c),h=Math.min(g+m.nodeSize,f),u=g,d=m)}):r.doc.nodesBetween(c,f,(m,g)=>{g=c&&g<=f&&(o&&o===m.type&&t.setNodeMarkup(g,void 0,{...m.attrs,...e}),s&&m.marks.length&&m.marks.forEach(b=>{if(s===b.type){let x=Math.max(g,c),w=Math.min(g+m.nodeSize,f);t.addMark(x,w,s.create({...b.attrs,...e}))}}))}),d&&(u!==void 0&&t.setNodeMarkup(u,void 0,{...d.attrs,...e}),s&&d.marks.length&&d.marks.forEach(m=>{s===m.type&&t.addMark(p,h,s.create({...m.attrs,...e}))}))}),!0):!1},tm=(n,e={})=>({state:t,dispatch:r})=>{let i=le(n,t.schema);return ic(i,e)(t,r)},nm=(n,e={})=>({state:t,dispatch:r})=>{let i=le(n,t.schema);return oc(i,e)(t,r)},rm=Object.freeze({__proto__:null,blur:jp,clearContent:qp,clearNodes:Jp,command:_p,createParagraphNear:Kp,cut:Up,deleteCurrentNode:Gp,deleteNode:Yp,deleteRange:Xp,deleteSelection:Zp,enter:Qp,exitCode:eh,extendMarkRange:th,first:nh,focus:rh,forEach:ih,insertContent:oh,insertContentAt:ah,joinBackward:uh,joinDown:fh,joinForward:dh,joinItemBackward:ph,joinItemForward:hh,joinTextblockBackward:mh,joinTextblockForward:gh,joinUp:ch,keyboardShortcut:bh,lift:vh,liftEmptyBlock:xh,liftListItem:kh,newlineInCode:Sh,resetAttributes:wh,scrollIntoView:Mh,selectAll:Ch,selectNodeBackward:Oh,selectNodeForward:Th,selectParentNode:Eh,selectTextblockEnd:Ah,selectTextblockStart:Nh,setContent:Dh,setMark:Vh,setMeta:$h,setNode:Hh,setNodeSelection:Wh,setTextSelection:jh,sinkListItem:qh,splitBlock:Jh,splitListItem:_h,toggleList:Kh,toggleMark:Uh,toggleNode:Gh,toggleWrap:Yh,undoInputRule:Xh,unsetAllMarks:Zh,unsetMark:Qh,updateAttributes:em,wrapIn:tm,wrapInList:nm}),im=te.create({name:"commands",addCommands(){return{...rm}}}),om=te.create({name:"drop",addProseMirrorPlugins(){return[new q({key:new X("tiptapDrop"),props:{handleDrop:(n,e,t,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:t,moved:r})}}})]}}),sm=te.create({name:"editable",addProseMirrorPlugins(){return[new q({key:new X("editable"),props:{editable:()=>this.editor.options.editable}})]}}),lm=te.create({name:"focusEvents",addProseMirrorPlugins(){let{editor:n}=this;return[new q({key:new X("focusEvents"),props:{handleDOMEvents:{focus:(e,t)=>{n.isFocused=!0;let r=n.state.tr.setMeta("focus",{event:t}).setMeta("addToHistory",!1);return e.dispatch(r),!1},blur:(e,t)=>{n.isFocused=!1;let r=n.state.tr.setMeta("blur",{event:t}).setMeta("addToHistory",!1);return e.dispatch(r),!1}}}})]}}),am=te.create({name:"keymap",addKeyboardShortcuts(){let n=()=>this.editor.commands.first(({commands:s})=>[()=>s.undoInputRule(),()=>s.command(({tr:l})=>{let{selection:a,doc:c}=l,{empty:f,$anchor:u}=a,{pos:d,parent:p}=u,h=u.parent.isTextblock&&d>0?l.doc.resolve(d-1):u,m=h.parent.type.spec.isolating,g=u.pos-u.parentOffset,b=m&&h.parent.childCount===1?g===u.pos:D.atStart(c).from===d;return!f||!p.type.isTextblock||p.textContent.length||!b||b&&u.parent.type.name==="paragraph"?!1:s.clearNodes()}),()=>s.deleteSelection(),()=>s.joinBackward(),()=>s.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:s})=>[()=>s.deleteSelection(),()=>s.deleteCurrentNode(),()=>s.joinForward(),()=>s.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:s})=>[()=>s.newlineInCode(),()=>s.createParagraphNear(),()=>s.liftEmptyBlock(),()=>s.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:n,"Mod-Backspace":n,"Shift-Backspace":n,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},i={...r},o={...r,"Ctrl-h":n,"Alt-Backspace":n,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return wc()||Mc()?o:i},addProseMirrorPlugins(){return[new q({key:new X("clearDocument"),appendTransaction:(n,e,t)=>{let r=n.some(m=>m.docChanged)&&!e.doc.eq(t.doc),i=n.some(m=>m.getMeta("preventClearDocument"));if(!r||i)return;let{empty:o,from:s,to:l}=e.selection,a=D.atStart(e.doc).from,c=D.atEnd(e.doc).to;if(o||!(s===a&&l===c)||!fr(t.doc))return;let d=t.tr,p=yi({state:t,transaction:d}),{commands:h}=new On({editor:this.editor,state:p});if(h.clearNodes(),!!d.steps.length)return d}})]}}),cm=te.create({name:"paste",addProseMirrorPlugins(){return[new q({key:new X("tiptapPaste"),props:{handlePaste:(n,e,t)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:t})}}})]}}),fm=te.create({name:"tabindex",addProseMirrorPlugins(){return[new q({key:new X("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}});var ls=class n{get name(){return this.node.type.name}constructor(e,t,r=!1,i=null){this.currentNode=null,this.actualDepth=null,this.isBlock=r,this.resolvedPos=e,this.editor=t,this.currentNode=i}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var e;return(e=this.actualDepth)!==null&&e!==void 0?e:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let t=this.from,r=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can\u2019t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}t=this.from+1,r=this.to-1}this.editor.commands.insertContentAt({from:t,to:r},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?0:1)}get parent(){if(this.depth===0)return null;let e=this.resolvedPos.start(this.resolvedPos.depth-1),t=this.resolvedPos.doc.resolve(e);return new n(t,this.editor)}get before(){let e=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.from-3)),new n(e,this.editor)}get after(){let e=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.to+3)),new n(e,this.editor)}get children(){let e=[];return this.node.content.forEach((t,r)=>{let i=t.isBlock&&!t.isTextblock,o=t.isAtom&&!t.isText,s=this.pos+r+(o?0:1),l=this.resolvedPos.doc.resolve(s);if(!i&&l.depth<=this.depth)return;let a=new n(l,this.editor,i,i?t:null);i&&(a.actualDepth=this.depth+1),e.push(new n(l,this.editor,i,i?t:null))}),e}get firstChild(){return this.children[0]||null}get lastChild(){let e=this.children;return e[e.length-1]||null}closest(e,t={}){let r=null,i=this.parent;for(;i&&!r;){if(i.node.type.name===e)if(Object.keys(t).length>0){let o=i.node.attrs,s=Object.keys(t);for(let l=0;l{r&&i.length>0||(s.node.type.name===e&&o.every(a=>t[a]===s.node.attrs[a])&&i.push(s),!(r&&i.length>0)&&(i=i.concat(s.querySelectorAll(e,t,r))))}),i}setAttribute(e){let{tr:t}=this.editor.state;t.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(t)}},um=`.ProseMirror { +function ke(n){this.content=n}ke.prototype={constructor:ke,find:function(n){for(var e=0;e>1}};ke.from=function(n){if(n instanceof ke)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new ke(e)};var _o=ke;function Aa(n,e,t){for(let r=0;;r++){if(r==n.childCount||r==e.childCount)return n.childCount==e.childCount?null:t;let i=n.child(r),o=e.child(r);if(i==o){t+=i.nodeSize;continue}if(!i.sameMarkup(o))return t;if(i.isText&&i.text!=o.text){for(let s=0;i.text[s]==o.text[s];s++)t++;return t}if(i.content.size||o.content.size){let s=Aa(i.content,o.content,t+1);if(s!=null)return s}t+=i.nodeSize}}function Na(n,e,t,r){for(let i=n.childCount,o=e.childCount;;){if(i==0||o==0)return i==o?null:{a:t,b:r};let s=n.child(--i),l=e.child(--o),a=s.nodeSize;if(s==l){t-=a,r-=a;continue}if(!s.sameMarkup(l))return{a:t,b:r};if(s.isText&&s.text!=l.text){let c=0,u=Math.min(s.text.length,l.text.length);for(;ce&&r(a,i+l,o||null,s)!==!1&&a.content.size){let u=l+1;a.nodesBetween(Math.max(0,e-u),Math.min(a.content.size,t-u),r,i+u)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,r,i){let o="",s=!0;return this.nodesBetween(e,t,(l,a)=>{let c=l.isText?l.text.slice(Math.max(e,a)-a,t-a):l.isLeaf?i?typeof i=="function"?i(l):i:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&r&&(s?s=!1:o+=r),o+=c},0),o}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,r=e.firstChild,i=this.content.slice(),o=0;for(t.isText&&t.sameMarkup(r)&&(i[i.length-1]=t.withText(t.text+r.text),o=1);oe)for(let o=0,s=0;se&&((st)&&(l.isText?l=l.cut(Math.max(0,e-s),Math.min(l.text.length,t-s)):l=l.cut(Math.max(0,e-s-1),Math.min(l.content.size,t-s-1))),r.push(l),i+=l.nodeSize),s=a}return new n(r,i)}cutByIndex(e,t){return e==t?n.empty:e==0&&t==this.content.length?this:new n(this.content.slice(e,t))}replaceChild(e,t){let r=this.content[e];if(r==t)return this;let i=this.content.slice(),o=this.size+t.nodeSize-r.nodeSize;return i[e]=t,new n(i,o)}addToStart(e){return new n([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new n(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;tthis.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let r=0,i=0;;r++){let o=this.child(r),s=i+o.nodeSize;if(s>=e)return s==e||t>0?si(r+1,s):si(r,i);i=s}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return n.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new n(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return n.empty;let t,r=0;for(let i=0;ithis.type.rank&&(t||(t=e.slice(0,i)),t.push(this),r=!0),t&&t.push(o)}}return t||(t=e.slice()),r||t.push(this),t}removeFromSet(e){for(let t=0;tr.type.rank-i.type.rank),t}};W.none=[];var Xt=class extends Error{},E=class n{constructor(e,t,r){this.content=e,this.openStart=t,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let r=Ra(this.content,e+this.openStart,t);return r&&new n(r,this.openStart,this.openEnd)}removeBetween(e,t){return new n(Da(this.content,e+this.openStart,t+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(e,t){if(!t)return n.empty;let r=t.openStart||0,i=t.openEnd||0;if(typeof r!="number"||typeof i!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new n(S.fromJSON(e,t.content),r,i)}static maxOpen(e,t=!0){let r=0,i=0;for(let o=e.firstChild;o&&!o.isLeaf&&(t||!o.type.spec.isolating);o=o.firstChild)r++;for(let o=e.lastChild;o&&!o.isLeaf&&(t||!o.type.spec.isolating);o=o.lastChild)i++;return new n(e,r,i)}};E.empty=new E(S.empty,0,0);function Da(n,e,t){let{index:r,offset:i}=n.findIndex(e),o=n.maybeChild(r),{index:s,offset:l}=n.findIndex(t);if(i==e||o.isText){if(l!=t&&!n.child(s).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(r!=s)throw new RangeError("Removing non-flat range");return n.replaceChild(r,o.copy(Da(o.content,e-i-1,t-i-1)))}function Ra(n,e,t,r){let{index:i,offset:o}=n.findIndex(e),s=n.maybeChild(i);if(o==e||s.isText)return r&&!r.canReplace(i,i,t)?null:n.cut(0,e).append(t).append(n.cut(e));let l=Ra(s.content,e-o-1,t);return l&&n.replaceChild(i,s.copy(l))}function Zd(n,e,t){if(t.openStart>n.depth)throw new Xt("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new Xt("Inconsistent open depths");return Ia(n,e,t,0)}function Ia(n,e,t,r){let i=n.index(r),o=n.node(r);if(i==e.index(r)&&r=0&&n.isText&&n.sameMarkup(e[t])?e[t]=n.withText(e[t].text+n.text):e.push(n)}function ir(n,e,t,r){let i=(e||n).node(t),o=0,s=e?e.index(t):i.childCount;n&&(o=n.index(t),n.depth>t?o++:n.textOffset&&(Gt(n.nodeAfter,r),o++));for(let l=o;li&&Jo(n,e,i+1),s=r.depth>i&&Jo(t,r,i+1),l=[];return ir(null,n,i,l),o&&s&&e.index(i)==t.index(i)?(Pa(o,s),Gt(Yt(o,La(n,e,t,r,i+1)),l)):(o&&Gt(Yt(o,ci(n,e,i+1)),l),ir(e,t,i,l),s&&Gt(Yt(s,ci(t,r,i+1)),l)),ir(r,null,i,l),new S(l)}function ci(n,e,t){let r=[];if(ir(null,n,t,r),n.depth>t){let i=Jo(n,e,t+1);Gt(Yt(i,ci(n,e,t+1)),r)}return ir(e,null,t,r),new S(r)}function ep(n,e){let t=e.depth-n.openStart,i=e.node(t).copy(n.content);for(let o=t-1;o>=0;o--)i=e.node(o).copy(S.from(i));return{start:i.resolveNoCache(n.openStart+t),end:i.resolveNoCache(i.content.size-n.openEnd-t)}}var ui=class n{constructor(e,t,r){this.pos=e,this.path=t,this.parentOffset=r,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 new 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 new 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 r=this.pos-this.path[this.path.length-1],i=e.child(t);return r?e.child(t).cut(r):i}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 r=this.path[t*3],i=t==0?0:this.path[t*3-1]+1;for(let o=0;o0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos=0;r--)if(e.pos<=this.end(r)&&(!t||t(this.node(r))))return new Qt(this,e,r);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&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let r=[],i=0,o=t;for(let s=e;;){let{index:l,offset:a}=s.content.findIndex(o),c=o-a;if(r.push(s,l,i+a),!c||(s=s.child(l),s.isText))break;o=c-1,i+=a+1}return new n(t,r,o)}static resolveCached(e,t){let r=xa.get(e);if(r)for(let o=0;oe&&this.nodesBetween(e,t,o=>(r.isInSet(o.marks)&&(i=!0),!i)),i}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()+")"),Ba(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,r=S.empty,i=0,o=r.childCount){let s=this.contentMatchAt(e).matchFragment(r,i,o),l=s&&s.matchFragment(this.content,t);if(!l||!l.validEnd)return!1;for(let a=i;at.type.name)}`);this.content.forEach(t=>t.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(t=>t.toJSON())),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let r;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=t.marks.map(e.markFromJSON)}if(t.type=="text"){if(typeof t.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(t.text,r)}let i=S.fromJSON(e,t.content),o=e.nodeType(t.type).create(t.attrs,i,r);return o.type.checkAttrs(o.attrs),o}};$e.prototype.text=void 0;var Yo=class n extends $e{constructor(e,t,r,i){if(super(e,t,null,i),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Ba(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new n(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new n(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(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 Ba(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}var Zt=class n{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let r=new Xo(e,t);if(r.next==null)return n.empty;let i=za(r);r.next&&r.err("Unexpected trailing text");let o=cp(ap(i));return up(o,r),o}matchType(e){for(let t=0;tc.createAndFill()));for(let c=0;c=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(r){e.push(r);for(let i=0;i{let o=i+(r.validEnd?"*":" ")+" ";for(let s=0;s"+e.indexOf(r.next[s].next);return o}).join(` +`)}};Zt.empty=new Zt(!0);var Xo=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 new SyntaxError(e+" (in content expression '"+this.string+"')")}};function za(n){let e=[];do e.push(rp(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function rp(n){let e=[];do e.push(ip(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function ip(n){let e=lp(n);for(;;)if(n.eat("+"))e={type:"plus",expr:e};else if(n.eat("*"))e={type:"star",expr:e};else if(n.eat("?"))e={type:"opt",expr:e};else if(n.eat("{"))e=op(n,e);else break;return e}function ka(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function op(n,e){let t=ka(n),r=t;return n.eat(",")&&(n.next!="}"?r=ka(n):r=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:r,expr:e}}function sp(n,e){let t=n.nodeTypes,r=t[e];if(r)return[r];let i=[];for(let o in t){let s=t[o];s.isInGroup(e)&&i.push(s)}return i.length==0&&n.err("No node type or group '"+e+"' found"),i}function lp(n){if(n.eat("(")){let e=za(n);return n.eat(")")||n.err("Missing closing paren"),e}else if(/\W/.test(n.next))n.err("Unexpected token '"+n.next+"'");else{let e=sp(n,n.next).map(t=>(n.inline==null?n.inline=t.isInline:n.inline!=t.isInline&&n.err("Mixing inline and block content"),{type:"name",value:t}));return n.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function ap(n){let e=[[]];return i(o(n,0),t()),e;function t(){return e.push([])-1}function r(s,l,a){let c={term:a,to:l};return e[s].push(c),c}function i(s,l){s.forEach(a=>a.to=l)}function o(s,l){if(s.type=="choice")return s.exprs.reduce((a,c)=>a.concat(o(c,l)),[]);if(s.type=="seq")for(let a=0;;a++){let c=o(s.exprs[a],l);if(a==s.exprs.length-1)return c;i(c,l=t())}else if(s.type=="star"){let a=t();return r(l,a),i(o(s.expr,a),a),[r(a)]}else if(s.type=="plus"){let a=t();return i(o(s.expr,l),a),i(o(s.expr,a),a),[r(a)]}else{if(s.type=="opt")return[r(l)].concat(o(s.expr,l));if(s.type=="range"){let a=l;for(let c=0;c{n[s].forEach(({term:l,to:a})=>{if(!l)return;let c;for(let u=0;u{c||i.push([l,c=[]]),c.indexOf(u)==-1&&c.push(u)})})});let o=e[r.join(",")]=new Zt(r.indexOf(n.length-1)>-1);for(let s=0;s-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:$a(this.attrs,e)}create(e=null,t,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new $e(this,this.computeAttrs(e),S.from(t),W.setFrom(r))}createChecked(e=null,t,r){return t=S.from(t),this.checkContent(t),new $e(this,this.computeAttrs(e),t,W.setFrom(r))}createAndFill(e=null,t,r){if(e=this.computeAttrs(e),t=S.from(t),t.size){let s=this.contentMatch.fillBefore(t);if(!s)return null;t=s.append(t)}let i=this.contentMatch.matchFragment(t),o=i&&i.fillBefore(S.empty,!0);return o?new $e(this,e,t.append(o),W.setFrom(r)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let r=0;r-1}allowsMarks(e){if(this.markSet==null)return!0;for(let t=0;tr[o]=new n(o,t,s));let i=t.spec.topNode||"doc";if(!r[i])throw new RangeError("Schema is missing its top node type ('"+i+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let o in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function fp(n,e,t){let r=t.split("|");return i=>{let o=i===null?"null":typeof i;if(r.indexOf(o)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${n}, got ${o}`)}}var Qo=class{constructor(e,t,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?fp(e,t,r.validate):r.validate}get isRequired(){return!this.hasDefault}},sr=class n{constructor(e,t,r,i){this.name=e,this.rank=t,this.schema=r,this.spec=i,this.attrs=ja(e,i.attrs),this.excluded=null;let o=Ha(this.attrs);this.instance=o?new W(this,o):null}create(e=null){return!e&&this.instance?this.instance:new W(this,$a(this.attrs,e))}static compile(e,t){let r=Object.create(null),i=0;return e.forEach((o,s)=>r[o]=new n(o,i++,t,s)),r}removeFromSet(e){for(var t=0;t-1}},lr=class{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let i in e)t[i]=e[i];t.nodes=_o.from(e.nodes),t.marks=_o.from(e.marks||{}),this.nodes=fi.compile(this.spec.nodes,this),this.marks=sr.compile(this.spec.marks,this);let r=Object.create(null);for(let i in this.nodes){if(i in this.marks)throw new RangeError(i+" can not be both a node and a mark");let o=this.nodes[i],s=o.spec.content||"",l=o.spec.marks;if(o.contentMatch=r[s]||(r[s]=Zt.parse(s,this.nodes)),o.inlineContent=o.contentMatch.inlineContent,o.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!o.isInline||!o.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=o}o.markSet=l=="_"?null:l?wa(this,l.split(" ")):l==""||!o.inlineContent?[]:null}for(let i in this.marks){let o=this.marks[i],s=o.spec.excludes;o.excluded=s==null?[o]:s==""?[]:wa(this,s.split(" "))}this.nodeFromJSON=this.nodeFromJSON.bind(this),this.markFromJSON=this.markFromJSON.bind(this),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,r,i){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof fi){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(t,r,i)}text(e,t){let r=this.nodes.text;return new Yo(r,r.defaultAttrs,e,W.setFrom(t))}mark(e,t){return typeof e=="string"&&(e=this.marks[e]),e.create(t)}nodeFromJSON(e){return $e.fromJSON(this,e)}markFromJSON(e){return W.fromJSON(this,e)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}};function wa(n,e){let t=[];for(let r=0;r-1)&&t.push(s=a)}if(!s)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return t}function dp(n){return n.tag!=null}function pp(n){return n.style!=null}var yt=class n{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let r=this.matchedStyles=[];t.forEach(i=>{if(dp(i))this.tags.push(i);else if(pp(i)){let o=/[^=]*/.exec(i.style)[0];r.indexOf(o)<0&&r.push(o),this.styles.push(i)}}),this.normalizeLists=!this.tags.some(i=>{if(!/^(ul|ol)\b/.test(i.tag)||!i.node)return!1;let o=e.nodes[i.node];return o.contentMatch.matchType(o)})}parse(e,t={}){let r=new di(this,t,!1);return r.addAll(e,W.none,t.from,t.to),r.finish()}parseSlice(e,t={}){let r=new di(this,t,!0);return r.addAll(e,W.none,t.from,t.to),E.maxOpen(r.finish())}matchTag(e,t,r){for(let i=r?this.tags.indexOf(r)+1:0;ie.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=t))){if(s.getAttrs){let a=s.getAttrs(t);if(a===!1)continue;s.attrs=a||void 0}return s}}}static schemaRules(e){let t=[];function r(i){let o=i.priority==null?50:i.priority,s=0;for(;s{r(s=Ma(s)),s.mark||s.ignore||s.clearMark||(s.mark=i)})}for(let i in e.nodes){let o=e.nodes[i].spec.parseDOM;o&&o.forEach(s=>{r(s=Ma(s)),s.node||s.ignore||s.mark||(s.node=i)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new n(e,n.schemaRules(e)))}},Wa={address:!0,article:!0,aside:!0,blockquote:!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},hp={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Ua={ol:!0,ul:!0},ar=1,Zo=2,or=4;function Ca(n,e,t){return e!=null?(e?ar:0)|(e==="full"?Zo:0):n&&n.whitespace=="pre"?ar|Zo:t&~or}var Dn=class{constructor(e,t,r,i,o,s){this.type=e,this.attrs=t,this.marks=r,this.solid=i,this.options=s,this.content=[],this.activeMarks=W.none,this.match=o||(s&or?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(S.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let r=this.type.contentMatch,i;return(i=r.findWrapping(e.type))?(this.match=r,i):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&ar)){let r=this.content[this.content.length-1],i;if(r&&r.isText&&(i=/[ \t\r\n\u000c]+$/.exec(r.text))){let o=r;r.text.length==i[0].length?this.content.pop():this.content[this.content.length-1]=o.withText(o.text.slice(0,o.text.length-i[0].length))}}let t=S.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(S.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&&!Wa.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}},di=class{constructor(e,t,r){this.parser=e,this.options=t,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let i=t.topNode,o,s=Ca(null,t.preserveWhitespace,0)|(r?or:0);i?o=new Dn(i.type,i.attrs,W.none,!0,t.topMatch||i.type.contentMatch,s):r?o=new Dn(null,null,W.none,!0,null,s):o=new Dn(e.schema.topNodeType,null,W.none,!0,null,s),this.nodes=[o],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 r=e.nodeValue,i=this.top,o=i.options&Zo?"full":this.localPreserveWS||(i.options&ar)>0;if(o==="full"||i.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(o)o!=="full"?r=r.replace(/\r?\n|\r/g," "):r=r.replace(/\r\n?/g,` +`);else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let s=i.content[i.content.length-1],l=e.previousSibling;(!s||l&&l.nodeName=="BR"||s.isText&&/[ \t\r\n\u000c]$/.test(s.text))&&(r=r.slice(1))}r&&this.insertNode(this.parser.schema.text(r),t),this.findInText(e)}else this.findInside(e)}addElement(e,t,r){let i=this.localPreserveWS,o=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let s=e.nodeName.toLowerCase(),l;Ua.hasOwnProperty(s)&&this.parser.normalizeLists&&mp(e);let a=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,r));e:if(a?a.ignore:hp.hasOwnProperty(s))this.findInside(e),this.ignoreFallback(e,t);else if(!a||a.skip||a.closeParent){a&&a.closeParent?this.open=Math.max(0,this.open-1):a&&a.skip.nodeType&&(e=a.skip);let c,u=this.needsBlock;if(Wa.hasOwnProperty(s))o.content.length&&o.content[0].isInline&&this.open&&(this.open--,o=this.top),c=!0,o.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break e}let f=a&&a.skip?t:this.readStyles(e,t);f&&this.addAll(e,f),c&&this.sync(o),this.needsBlock=u}else{let c=this.readStyles(e,t);c&&this.addElementByRule(e,a,c,a.consuming===!1?l:void 0)}this.localPreserveWS=i}leafFallback(e,t){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(` +`),t)}ignoreFallback(e,t){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),t)}readStyles(e,t){let r=e.style;if(r&&r.length)for(let i=0;i!a.clearMark(c)):t=t.concat(this.parser.schema.marks[a.mark].create(a.attrs)),a.consuming===!1)l=a;else break}}return t}addElementByRule(e,t,r,i){let o,s;if(t.node)if(s=this.parser.schema.nodes[t.node],s.isLeaf)this.insertNode(s.create(t.attrs),r)||this.leafFallback(e,r);else{let a=this.enter(s,t.attrs||null,r,t.preserveWhitespace);a&&(o=!0,r=a)}else{let a=this.parser.schema.marks[t.mark];r=r.concat(a.create(t.attrs))}let l=this.top;if(s&&s.isLeaf)this.findInside(e);else if(i)this.addElement(e,r,i);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a,r));else{let a=e;typeof t.contentElement=="string"?a=e.querySelector(t.contentElement):typeof t.contentElement=="function"?a=t.contentElement(e):t.contentElement&&(a=t.contentElement),this.findAround(e,a,!0),this.addAll(a,r),this.findAround(e,a,!1)}o&&this.sync(l)&&this.open--}addAll(e,t,r,i){let o=r||0;for(let s=r?e.childNodes[r]:e.firstChild,l=i==null?null:e.childNodes[i];s!=l;s=s.nextSibling,++o)this.findAtPoint(e,o),this.addDOM(s,t);this.findAtPoint(e,o)}findPlace(e,t){let r,i;for(let o=this.open;o>=0;o--){let s=this.nodes[o],l=s.findWrapping(e);if(l&&(!r||r.length>l.length)&&(r=l,i=s,!l.length)||s.solid)break}if(!r)return null;this.sync(i);for(let o=0;o(s.type?s.type.allowsMarkType(c.type):Ea(c.type,e))?(a=c.addToSet(a),!1):!0),this.nodes.push(new Dn(e,t,a,i,null,l)),this.open++,r}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;this.localPreserveWS&&(this.nodes[t].options|=ar)}return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let r=this.nodes[t].content;for(let i=r.length-1;i>=0;i--)e+=r[i].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let r=0;r-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),r=this.options.context,i=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),o=-(r?r.depth+1:0)+(i?0:1),s=(l,a)=>{for(;l>=0;l--){let c=t[l];if(c==""){if(l==t.length-1||l==0)continue;for(;a>=o;a--)if(s(l-1,a))return!0;return!1}else{let u=a>0||a==0&&i?this.nodes[a].type:r&&a>=o?r.node(a-o).type:null;if(!u||u.name!=c&&!u.isInGroup(c))return!1;a--}}return!0};return s(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let r=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let t in this.parser.schema.nodes){let r=this.parser.schema.nodes[t];if(r.isTextblock&&r.defaultAttrs)return r}}};function mp(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&Ua.hasOwnProperty(r)&&t?(t.appendChild(e),e=t):r=="li"?t=e:r&&(t=null)}}function gp(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function Ma(n){let e={};for(let t in n)e[t]=n[t];return e}function Ea(n,e){let t=e.schema.nodes;for(let r in t){let i=t[r];if(!i.allowsMarkType(n))continue;let o=[],s=l=>{o.push(l);for(let a=0;a{if(o.length||s.marks.length){let l=0,a=0;for(;l=0;i--){let o=this.serializeMark(e.marks[i],e.isInline,t);o&&((o.contentDOM||o.dom).appendChild(r),r=o.dom)}return r}serializeMark(e,t,r={}){let i=this.marks[e.type.name];return i&&li(qo(r),i(e,t),null,e.attrs)}static renderSpec(e,t,r=null,i){return li(e,t,r,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new n(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=Oa(e.nodes);return t.text||(t.text=r=>r.text),t}static marksFromSchema(e){return Oa(e.marks)}};function Oa(n){let e={};for(let t in n){let r=n[t].spec.toDOM;r&&(e[t]=r)}return e}function qo(n){return n.document||window.document}var Ta=new WeakMap;function yp(n){let e=Ta.get(n);return e===void 0&&Ta.set(n,e=bp(n)),e}function bp(n){let e=null;function t(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let i=0;i-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let s=i.indexOf(" ");s>0&&(t=i.slice(0,s),i=i.slice(s+1));let l,a=t?n.createElementNS(t,i):n.createElement(i),c=e[1],u=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){u=2;for(let f in c)if(c[f]!=null){let d=f.indexOf(" ");d>0?a.setAttributeNS(f.slice(0,d),f.slice(d+1),c[f]):a.setAttribute(f,c[f])}}for(let f=u;fu)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else{let{dom:p,contentDOM:h}=li(n,d,t,r);if(a.appendChild(p),h){if(l)throw new RangeError("Multiple content holes");l=h}}}return{dom:a,contentDOM:l}}var qa=65535,Ja=Math.pow(2,16);function vp(n,e){return n+e*Ja}function _a(n){return n&qa}function xp(n){return(n-(n&qa))/Ja}var Ga=1,Ya=2,pi=4,Xa=8,fr=class{constructor(e,t,r){this.pos=e,this.delInfo=t,this.recover=r}get deleted(){return(this.delInfo&Xa)>0}get deletedBefore(){return(this.delInfo&(Ga|pi))>0}get deletedAfter(){return(this.delInfo&(Ya|pi))>0}get deletedAcross(){return(this.delInfo&pi)>0}},vt=class n{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&n.empty)return n.empty}recover(e){let t=0,r=_a(e);if(!this.inverted)for(let i=0;ie)break;let c=this.ranges[l+o],u=this.ranges[l+s],f=a+c;if(e<=f){let d=c?e==a?-1:e==f?1:t:t,p=a+i+(d<0?0:u);if(r)return p;let h=e==(t<0?a:f)?null:vp(l/3,e-a),m=e==a?Ya:e==f?Ga:pi;return(t<0?e!=a:e!=f)&&(m|=Xa),new fr(p,m,h)}i+=u-c}return r?e+i:new fr(e+i,0,null)}touches(e,t){let r=0,i=_a(t),o=this.inverted?2:1,s=this.inverted?1:2;for(let l=0;le)break;let c=this.ranges[l+o],u=a+c;if(e<=u&&l==i*3)return!0;r+=this.ranges[l+s]-c}return!1}forEach(e){let t=this.inverted?2:1,r=this.inverted?1:2;for(let i=0,o=0;i=0;t--){let i=e.getMirror(t);this.appendMap(e.maps[t].invert(),i!=null&&i>t?r-i-1:void 0)}}invert(){let e=new n;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let r=this.from;ro&&a!s.isAtom||!l.type.allowsMarkType(this.mark.type)?s:s.mark(this.mark.addToSet(s.marks)),i),t.openStart,t.openEnd);return ye.fromReplace(e,this.from,this.to,o)}invert(){return new en(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new n(t.pos,r.pos,this.mark)}merge(e){return e instanceof n&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new n(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new n(t.from,t.to,e.markFromJSON(t.mark))}};fe.jsonID("addMark",pr);var en=class n extends fe{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=new E(ss(t.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),t.openStart,t.openEnd);return ye.fromReplace(e,this.from,this.to,r)}invert(){return new pr(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new n(t.pos,r.pos,this.mark)}merge(e){return e instanceof n&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new n(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new n(t.from,t.to,e.markFromJSON(t.mark))}};fe.jsonID("removeMark",en);var hr=class n extends fe{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return ye.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return ye.fromReplace(e,this.pos,this.pos+1,new E(S.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let r=this.mark.addToSet(t.marks);if(r.length==t.marks.length){for(let i=0;ir.pos?null:new n(t.pos,r.pos,i,o,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(e,t){if(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new n(t.from,t.to,t.gapFrom,t.gapTo,E.fromJSON(e,t.slice),t.insert,!!t.structure)}};fe.jsonID("replaceAround",oe);function rs(n,e,t){let r=n.resolve(e),i=t-e,o=r.depth;for(;i>0&&o>0&&r.indexAfter(o)==r.node(o).childCount;)o--,i--;if(i>0){let s=r.node(o).maybeChild(r.indexAfter(o));for(;i>0;){if(!s||s.isLeaf)return!0;s=s.firstChild,i--}}return!1}function kp(n,e,t,r){let i=[],o=[],s,l;n.doc.nodesBetween(e,t,(a,c,u)=>{if(!a.isInline)return;let f=a.marks;if(!r.isInSet(f)&&u.type.allowsMarkType(r.type)){let d=Math.max(c,e),p=Math.min(c+a.nodeSize,t),h=r.addToSet(f);for(let m=0;mn.step(a)),o.forEach(a=>n.step(a))}function Sp(n,e,t,r){let i=[],o=0;n.doc.nodesBetween(e,t,(s,l)=>{if(!s.isInline)return;o++;let a=null;if(r instanceof sr){let c=s.marks,u;for(;u=r.isInSet(c);)(a||(a=[])).push(u),c=u.removeFromSet(c)}else r?r.isInSet(s.marks)&&(a=[r]):a=s.marks;if(a&&a.length){let c=Math.min(l+s.nodeSize,t);for(let u=0;un.step(new en(s.from,s.to,s.style)))}function ls(n,e,t,r=t.contentMatch,i=!0){let o=n.doc.nodeAt(e),s=[],l=e+1;for(let a=0;a=0;a--)n.step(s[a])}function wp(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function xt(n){let t=n.parent.content.cutByIndex(n.startIndex,n.endIndex);for(let r=n.depth;;--r){let i=n.$from.node(r),o=n.$from.index(r),s=n.$to.indexAfter(r);if(rt;h--)m||r.index(h)>0?(m=!0,u=S.from(r.node(h).copy(u)),f++):a--;let d=S.empty,p=0;for(let h=o,m=!1;h>t;h--)m||i.after(h+1)=0;s--){if(r.size){let l=t[s].type.contentMatch.matchFragment(r);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=S.from(t[s].type.create(t[s].attrs,r))}let i=e.start,o=e.end;n.step(new oe(i,o,i,o,new E(r,0,0),t.length,!0))}function Tp(n,e,t,r,i){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let o=n.steps.length;n.doc.nodesBetween(e,t,(s,l)=>{let a=typeof i=="function"?i(s):i;if(s.isTextblock&&!s.hasMarkup(r,a)&&Ap(n.doc,n.mapping.slice(o).map(l),r)){let c=null;if(r.schema.linebreakReplacement){let p=r.whitespace=="pre",h=!!r.contentMatch.matchType(r.schema.linebreakReplacement);p&&!h?c=!1:!p&&h&&(c=!0)}c===!1&&Za(n,s,l,o),ls(n,n.mapping.slice(o).map(l,1),r,void 0,c===null);let u=n.mapping.slice(o),f=u.map(l,1),d=u.map(l+s.nodeSize,1);return n.step(new oe(f,d,f+1,d-1,new E(S.from(r.create(a,null,s.marks)),0,0),1,!0)),c===!0&&Qa(n,s,l,o),!1}})}function Qa(n,e,t,r){e.forEach((i,o)=>{if(i.isText){let s,l=/\r?\n|\r/g;for(;s=l.exec(i.text);){let a=n.mapping.slice(r).map(t+1+o+s.index);n.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function Za(n,e,t,r){e.forEach((i,o)=>{if(i.type==i.type.schema.linebreakReplacement){let s=n.mapping.slice(r).map(t+1+o);n.replaceWith(s,s+1,e.type.schema.text(` +`))}})}function Ap(n,e,t){let r=n.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,t)}function Np(n,e,t,r,i){let o=n.doc.nodeAt(e);if(!o)throw new RangeError("No node at given position");t||(t=o.type);let s=t.create(r,null,i||o.marks);if(o.isLeaf)return n.replaceWith(e,e+o.nodeSize,s);if(!t.validContent(o.content))throw new RangeError("Invalid content for node type "+t.name);n.step(new oe(e,e+o.nodeSize,e+1,e+o.nodeSize-1,new E(S.from(s),0,0),1,!0))}function Ve(n,e,t=1,r){let i=n.resolve(e),o=i.depth-t,s=r&&r[r.length-1]||i.parent;if(o<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!s.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let c=i.depth-1,u=t-2;c>o;c--,u--){let f=i.node(c),d=i.index(c);if(f.type.spec.isolating)return!1;let p=f.content.cutByIndex(d,f.childCount),h=r&&r[u+1];h&&(p=p.replaceChild(0,h.type.create(h.attrs)));let m=r&&r[u]||f;if(!f.canReplace(d+1,f.childCount)||!m.type.validContent(p))return!1}let l=i.indexAfter(o),a=r&&r[0];return i.node(o).canReplaceWith(l,l,a?a.type:i.node(o+1).type)}function Dp(n,e,t=1,r){let i=n.doc.resolve(e),o=S.empty,s=S.empty;for(let l=i.depth,a=i.depth-t,c=t-1;l>a;l--,c--){o=S.from(i.node(l).copy(o));let u=r&&r[c];s=S.from(u?u.type.create(u.attrs,s):i.node(l).copy(s))}n.step(new Se(e,e,new E(o.append(s),t,t),!0))}function Ze(n,e){let t=n.resolve(e),r=t.index();return ec(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(r,r+1)}function Rp(n,e){e.content.size||n.type.compatibleContent(e.type);let t=n.contentMatchAt(n.childCount),{linebreakReplacement:r}=n.type.schema;for(let i=0;i0?(o=r.node(i+1),l++,s=r.node(i).maybeChild(l)):(o=r.node(i).maybeChild(l-1),s=r.node(i+1)),o&&!o.isTextblock&&ec(o,s)&&r.node(i).canReplace(l,l+1))return e;if(i==0)break;e=t<0?r.before(i):r.after(i)}}function Ip(n,e,t){let r=null,{linebreakReplacement:i}=n.doc.type.schema,o=n.doc.resolve(e-t),s=o.node().type;if(i&&s.inlineContent){let u=s.whitespace=="pre",f=!!s.contentMatch.matchType(i);u&&!f?r=!1:!u&&f&&(r=!0)}let l=n.steps.length;if(r===!1){let u=n.doc.resolve(e+t);Za(n,u.node(),u.before(),l)}s.inlineContent&&ls(n,e+t-1,s,o.node().contentMatchAt(o.index()),r==null);let a=n.mapping.slice(l),c=a.map(e-t);if(n.step(new Se(c,a.map(e+t,-1),E.empty,!0)),r===!0){let u=n.doc.resolve(c);Qa(n,u.node(),u.before(),n.steps.length)}return n}function Pp(n,e,t){let r=n.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),t))return e;if(r.parentOffset==0)for(let i=r.depth-1;i>=0;i--){let o=r.index(i);if(r.node(i).canReplaceWith(o,o,t))return r.before(i+1);if(o>0)return null}if(r.parentOffset==r.parent.content.size)for(let i=r.depth-1;i>=0;i--){let o=r.indexAfter(i);if(r.node(i).canReplaceWith(o,o,t))return r.after(i+1);if(o=0;s--){let l=s==r.depth?0:r.pos<=(r.start(s+1)+r.end(s+1))/2?-1:1,a=r.index(s)+(l>0?1:0),c=r.node(s),u=!1;if(o==1)u=c.canReplace(a,a,i);else{let f=c.contentMatchAt(a).findWrapping(i.firstChild.type);u=f&&c.canReplaceWith(a,a,f[0])}if(u)return l==0?r.pos:l<0?r.before(s+1):r.after(s+1)}return null}function gr(n,e,t=e,r=E.empty){if(e==t&&!r.size)return null;let i=n.resolve(e),o=n.resolve(t);return tc(i,o,r)?new Se(e,t,r):new is(i,o,r).fit()}function tc(n,e,t){return!t.openStart&&!t.openEnd&&n.start()==e.start()&&n.parent.canReplace(n.index(),e.index(),t.content)}var is=class{constructor(e,t,r){this.$from=e,this.$to=t,this.unplaced=r,this.frontier=[],this.placed=S.empty;for(let i=0;i<=e.depth;i++){let o=e.node(i);this.frontier.push({type:o.type,match:o.contentMatchAt(e.indexAfter(i))})}for(let i=e.depth;i>0;i--)this.placed=S.from(e.node(i).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let c=this.findFittable();c?this.placeNodes(c):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,r=this.$from,i=this.close(e<0?this.$to:r.doc.resolve(e));if(!i)return null;let o=this.placed,s=r.depth,l=i.depth;for(;s&&l&&o.childCount==1;)o=o.firstChild.content,s--,l--;let a=new E(o,s,l);return e>-1?new oe(r.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||r.pos!=this.$to.pos?new Se(r.pos,i.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,r=0,i=this.unplaced.openEnd;r1&&(i=0),o.type.spec.isolating&&i<=r){e=r;break}t=o.content}for(let t=1;t<=2;t++)for(let r=t==1?e:this.unplaced.openStart;r>=0;r--){let i,o=null;r?(o=ts(this.unplaced.content,r-1).firstChild,i=o.content):i=this.unplaced.content;let s=i.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:c}=this.frontier[l],u,f=null;if(t==1&&(s?c.matchType(s.type)||(f=c.fillBefore(S.from(s),!1)):o&&a.compatibleContent(o.type)))return{sliceDepth:r,frontierDepth:l,parent:o,inject:f};if(t==2&&s&&(u=c.findWrapping(s.type)))return{sliceDepth:r,frontierDepth:l,parent:o,wrap:u};if(o&&c.matchType(o.type))break}}}openMore(){let{content:e,openStart:t,openEnd:r}=this.unplaced,i=ts(e,t);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new E(e,t+1,Math.max(r,i.size+t>=e.size-r?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:r}=this.unplaced,i=ts(e,t);if(i.childCount<=1&&t>0){let o=e.size-t<=t+i.size;this.unplaced=new E(cr(e,t-1,1),t-1,o?t-1:r)}else this.unplaced=new E(cr(e,t,1),t,r)}placeNodes({sliceDepth:e,frontierDepth:t,parent:r,inject:i,wrap:o}){for(;this.depth>t;)this.closeFrontierNode();if(o)for(let m=0;m1||a==0||m.content.size)&&(f=g,u.push(nc(m.mark(d.allowedMarks(m.marks)),c==1?a:0,c==l.childCount?p:-1)))}let h=c==l.childCount;h||(p=-1),this.placed=ur(this.placed,t,S.from(u)),this.frontier[t].match=f,h&&p<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let m=0,g=l;m1&&i==this.$to.end(--r);)++i;return i}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:r,type:i}=this.frontier[t],o=t=0;l--){let{match:a,type:c}=this.frontier[l],u=ns(e,l,c,a,!0);if(!u||u.childCount)continue e}return{depth:t,fit:s,move:o?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=ur(this.placed,t.depth,t.fit)),e=t.move;for(let r=t.depth+1;r<=e.depth;r++){let i=e.node(r),o=i.type.contentMatch.fillBefore(i.content,!0,e.index(r));this.openFrontierNode(i.type,i.attrs,o)}return e}openFrontierNode(e,t=null,r){let i=this.frontier[this.depth];i.match=i.match.matchType(e),this.placed=ur(this.placed,this.depth,S.from(e.create(t,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(S.empty,!0);t.childCount&&(this.placed=ur(this.placed,this.frontier.length,t))}};function cr(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(cr(n.firstChild.content,e-1,t)))}function ur(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy(ur(n.lastChild.content,e-1,t)))}function ts(n,e){for(let t=0;t1&&(r=r.replaceChild(0,nc(r.firstChild,e-1,r.childCount==1?t-1:0))),e>0&&(r=n.type.contentMatch.fillBefore(r).append(r),t<=0&&(r=r.append(n.type.contentMatch.matchFragment(r).fillBefore(S.empty,!0)))),n.copy(r)}function ns(n,e,t,r,i){let o=n.node(e),s=i?n.indexAfter(e):n.index(e);if(s==o.childCount&&!t.compatibleContent(o.type))return null;let l=r.fillBefore(o.content,!0,s);return l&&!Lp(t,o.content,s)?l:null}function Lp(n,e,t){for(let r=t;r0;d--,p--){let h=i.node(d).type.spec;if(h.defining||h.definingAsContext||h.isolating)break;s.indexOf(d)>-1?l=d:i.before(d)==p&&s.splice(1,0,-d)}let a=s.indexOf(l),c=[],u=r.openStart;for(let d=r.content,p=0;;p++){let h=d.firstChild;if(c.push(h),p==r.openStart)break;d=h.content}for(let d=u-1;d>=0;d--){let p=c[d],h=Bp(p.type);if(h&&!p.sameMarkup(i.node(Math.abs(l)-1)))u=d;else if(h||!p.type.isTextblock)break}for(let d=r.openStart;d>=0;d--){let p=(d+u+1)%(r.openStart+1),h=c[p];if(h)for(let m=0;m=0&&(n.replace(e,t,r),!(n.steps.length>f));d--){let p=s[d];p<0||(e=i.before(p),t=o.after(p))}}function rc(n,e,t,r,i){if(er){let o=i.contentMatchAt(0),s=o.fillBefore(n).append(n);n=s.append(o.matchFragment(s).fillBefore(S.empty,!0))}return n}function Fp(n,e,t,r){if(!r.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let i=Pp(n.doc,e,r.type);i!=null&&(e=t=i)}n.replaceRange(e,t,new E(S.from(r),0,0))}function Hp(n,e,t){let r=n.doc.resolve(e),i=n.doc.resolve(t),o=ic(r,i);for(let s=0;s0&&(a||r.node(l-1).canReplace(r.index(l-1),i.indexAfter(l-1))))return n.delete(r.before(l),i.after(l))}for(let s=1;s<=r.depth&&s<=i.depth;s++)if(e-r.start(s)==r.depth-s&&t>r.end(s)&&i.end(s)-t!=i.depth-s&&r.start(s-1)==i.start(s-1)&&r.node(s-1).canReplace(r.index(s-1),i.index(s-1)))return n.delete(r.before(s),t);n.delete(e,t)}function ic(n,e){let t=[],r=Math.min(n.depth,e.depth);for(let i=r;i>=0;i--){let o=n.start(i);if(oe.pos+(e.depth-i)||n.node(i).type.spec.isolating||e.node(i).type.spec.isolating)break;(o==e.start(i)||i==n.depth&&i==e.depth&&n.parent.inlineContent&&e.parent.inlineContent&&i&&e.start(i-1)==o-1)&&t.push(i)}return t}var hi=class n extends fe{constructor(e,t,r){super(),this.pos=e,this.attr=t,this.value=r}apply(e){let t=e.nodeAt(this.pos);if(!t)return ye.fail("No node at attribute step's position");let r=Object.create(null);for(let o in t.attrs)r[o]=t.attrs[o];r[this.attr]=this.value;let i=t.type.create(r,null,t.marks);return ye.fromReplace(e,this.pos,this.pos+1,new E(S.from(i),0,t.isLeaf?0:1))}getMap(){return vt.empty}invert(e){return new n(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new n(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.pos!="number"||typeof t.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new n(t.pos,t.attr,t.value)}};fe.jsonID("attr",hi);var mi=class n extends fe{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let i in e.attrs)t[i]=e.attrs[i];t[this.attr]=this.value;let r=e.type.create(t,e.content,e.marks);return ye.ok(r)}getMap(){return vt.empty}invert(e){return new n(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new n(t.attr,t.value)}};fe.jsonID("docAttr",mi);var Rn=class extends Error{};Rn=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t};Rn.prototype=Object.create(Error.prototype);Rn.prototype.constructor=Rn;Rn.prototype.name="TransformError";var In=class{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new dr}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new Rn(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}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,r=E.empty){let i=gr(this.doc,e,t,r);return i&&this.step(i),this}replaceWith(e,t,r){return this.replace(e,t,new E(S.from(r),0,0))}delete(e,t){return this.replace(e,t,E.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,r){return zp(this,e,t,r),this}replaceRangeWith(e,t,r){return Fp(this,e,t,r),this}deleteRange(e,t){return Hp(this,e,t),this}lift(e,t){return Cp(this,e,t),this}join(e,t=1){return Ip(this,e,t),this}wrap(e,t){return Op(this,e,t),this}setBlockType(e,t=e,r,i=null){return Tp(this,e,t,r,i),this}setNodeMarkup(e,t,r=null,i){return Np(this,e,t,r,i),this}setNodeAttribute(e,t,r){return this.step(new hi(e,t,r)),this}setDocAttribute(e,t){return this.step(new mi(e,t)),this}addNodeMark(e,t){return this.step(new hr(e,t)),this}removeNodeMark(e,t){if(!(t instanceof W)){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(t=t.isInSet(r.marks),!t)return this}return this.step(new mr(e,t)),this}split(e,t=1,r){return Dp(this,e,t,r),this}addMark(e,t,r){return kp(this,e,t,r),this}removeMark(e,t,r){return Sp(this,e,t,r),this}clearIncompatible(e,t,r){return ls(this,e,t,r),this}};var as=Object.create(null),I=class{constructor(e,t,r){this.$anchor=e,this.$head=t,this.ranges=r||[new bi(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;o--){let s=t<0?Bn(e.node(0),e.node(o),e.before(o+1),e.index(o),t,r):Bn(e.node(0),e.node(o),e.after(o+1),e.index(o)+1,t,r);if(s)return s}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new Oe(e.node(0))}static atStart(e){return Bn(e,e,0,0,1)||new Oe(e)}static atEnd(e){return Bn(e,e,e.content.size,e.childCount,-1)||new Oe(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=as[t.type];if(!r)throw new RangeError(`No selection type ${t.type} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in as)throw new RangeError("Duplicate use of selection JSON ID "+e);return as[e]=t,t.prototype.jsonID=e,t}getBookmark(){return P.between(this.$anchor,this.$head).getBookmark()}};I.prototype.visible=!0;var bi=class{constructor(e,t){this.$from=e,this.$to=t}},oc=!1;function sc(n){!oc&&!n.parent.inlineContent&&(oc=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}var P=class n extends I{constructor(e,t=e){sc(e),sc(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let r=e.resolve(t.map(this.head));if(!r.parent.inlineContent)return I.near(r);let i=e.resolve(t.map(this.anchor));return new n(i.parent.inlineContent?i:r,r)}replace(e,t=E.empty){if(super.replace(e,t),t==E.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof n&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new vi(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if(typeof t.anchor!="number"||typeof t.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new n(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){let i=e.resolve(t);return new this(i,r==t?i:e.resolve(r))}static between(e,t,r){let i=e.pos-t.pos;if((!r||i)&&(r=i>=0?1:-1),!t.parent.inlineContent){let o=I.findFrom(t,r,!0)||I.findFrom(t,-r,!0);if(o)t=o.$head;else return I.near(t,r)}return e.parent.inlineContent||(i==0?e=t:(e=(I.findFrom(e,-r,!0)||I.findFrom(e,r,!0)).$anchor,e.pos0?0:1);i>0?s=0;s+=i){let l=e.child(s);if(l.isAtom){if(!o&&D.isSelectable(l))return D.create(n,t-(i<0?l.nodeSize:0))}else{let a=Bn(n,l,t+i,i<0?l.childCount:0,i,o);if(a)return a}t+=l.nodeSize*i}return null}function lc(n,e,t){let r=n.steps.length-1;if(r{s==null&&(s=u)}),n.setSelection(I.near(n.doc.resolve(s),t))}var ac=1,yi=2,cc=4,fs=class extends In{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|=yi,this}ensureMarks(e){return W.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&yi)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&~yi,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let r=this.selection;return t&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||W.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,r){let i=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(i.text(e),!0):this.deleteSelection();{if(r==null&&(r=t),r=r??t,!e)return this.deleteRange(t,r);let o=this.storedMarks;if(!o){let s=this.doc.resolve(t);o=r==t?s.marks():s.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(t,r,i.text(e,o)),this.selection.empty||this.setSelection(I.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|=cc,this}get scrolledIntoView(){return(this.updated&cc)>0}};function uc(n,e){return!e||!n?n:n.bind(e)}var tn=class{constructor(e,t,r){this.name=e,this.init=uc(t.init,r),this.apply=uc(t.apply,r)}},Vp=[new tn("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new tn("selection",{init(n,e){return n.selection||I.atStart(e.doc)},apply(n){return n.selection}}),new tn("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,r){return r.selection.$cursor?n.storedMarks:null}}),new tn("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}})],yr=class{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=Vp.slice(),t&&t.forEach(r=>{if(this.pluginsByKey[r.key])throw new RangeError("Adding different instances of a keyed plugin ("+r.key+")");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new tn(r.key,r.spec.state,r))})}},xi=class n{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 r=0;rr.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let i=e[r],o=i.spec.state;o&&o.toJSON&&(t[r]=o.toJSON.call(i,this[i.key]))}return t}static fromJSON(e,t,r){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let i=new yr(e.schema,e.plugins),o=new n(i);return i.fields.forEach(s=>{if(s.name=="doc")o.doc=$e.fromJSON(e.schema,t.doc);else if(s.name=="selection")o.selection=I.fromJSON(o.doc,t.selection);else if(s.name=="storedMarks")t.storedMarks&&(o.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let l in r){let a=r[l],c=a.spec.state;if(a.key==s.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(t,l)){o[s.name]=c.fromJSON.call(a,e,t[l],o);return}}o[s.name]=s.init(e,o)}}),o}};function fc(n,e,t){for(let r in n){let i=n[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=fc(i,e,{})),t[r]=i}return t}var _=class{constructor(e){this.spec=e,this.props={},e.props&&fc(e.props,this,this.props),this.key=e.key?e.key.key:dc("plugin")}getState(e){return e[this.key]}},cs=Object.create(null);function dc(n){return n in cs?n+"$"+ ++cs[n]:(cs[n]=0,n+"$")}var G=class{constructor(e="key"){this.key=dc(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}};var be=function(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e},kr=function(n){let e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e},ys=null,St=function(n,e,t){let r=ys||(ys=document.createRange());return r.setEnd(n,t??n.nodeValue.length),r.setStart(n,e||0),r},jp=function(){ys=null},cn=function(n,e,t,r){return t&&(pc(n,e,t,r,-1)||pc(n,e,t,r,1))},Wp=/^(img|br|input|textarea|hr)$/i;function pc(n,e,t,r,i){for(;;){if(n==t&&e==r)return!0;if(e==(i<0?0:We(n))){let o=n.parentNode;if(!o||o.nodeType!=1||Mr(n)||Wp.test(n.nodeName)||n.contentEditable=="false")return!1;e=be(n)+(i<0?0:1),n=o}else if(n.nodeType==1){if(n=n.childNodes[e+(i<0?-1:0)],n.contentEditable=="false")return!1;e=i<0?We(n):0}else return!1}}function We(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Up(n,e){for(;;){if(n.nodeType==3&&e)return n;if(n.nodeType==1&&e>0){if(n.contentEditable=="false")return null;n=n.childNodes[e-1],e=We(n)}else if(n.parentNode&&!Mr(n))e=be(n),n=n.parentNode;else return null}}function _p(n,e){for(;;){if(n.nodeType==3&&e2),je=Vn||(ot?/Mac/.test(ot.platform):!1),Gp=ot?/Win/.test(ot.platform):!1,wt=/Android \d/.test(Ht),Er=!!hc&&"webkitFontSmoothing"in hc.documentElement.style,Yp=Er?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Xp(n){let e=n.defaultView&&n.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:n.documentElement.clientWidth,top:0,bottom:n.documentElement.clientHeight}}function kt(n,e){return typeof n=="number"?n:n[e]}function Qp(n){let e=n.getBoundingClientRect(),t=e.width/n.offsetWidth||1,r=e.height/n.offsetHeight||1;return{left:e.left,right:e.left+n.clientWidth*t,top:e.top,bottom:e.top+n.clientHeight*r}}function mc(n,e,t){let r=n.someProp("scrollThreshold")||0,i=n.someProp("scrollMargin")||5,o=n.dom.ownerDocument;for(let s=t||n.dom;s;s=kr(s)){if(s.nodeType!=1)continue;let l=s,a=l==o.body,c=a?Xp(o):Qp(l),u=0,f=0;if(e.topc.bottom-kt(r,"bottom")&&(f=e.bottom-e.top>c.bottom-c.top?e.top+kt(i,"top")-c.top:e.bottom-c.bottom+kt(i,"bottom")),e.leftc.right-kt(r,"right")&&(u=e.right-c.right+kt(i,"right")),u||f)if(a)o.defaultView.scrollBy(u,f);else{let d=l.scrollLeft,p=l.scrollTop;f&&(l.scrollTop+=f),u&&(l.scrollLeft+=u);let h=l.scrollLeft-d,m=l.scrollTop-p;e={left:e.left-h,top:e.top-m,right:e.right-h,bottom:e.bottom-m}}if(a||/^(fixed|sticky)$/.test(getComputedStyle(s).position))break}}function Zp(n){let e=n.dom.getBoundingClientRect(),t=Math.max(0,e.top),r,i;for(let o=(e.left+e.right)/2,s=t+1;s=t-20){r=l,i=a.top;break}}return{refDOM:r,refTop:i,stack:Jc(n.dom)}}function Jc(n){let e=[],t=n.ownerDocument;for(let r=n;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),n!=t);r=kr(r));return e}function eh({refDOM:n,refTop:e,stack:t}){let r=n?n.getBoundingClientRect().top:0;Gc(t,r==0?0:r-e)}function Gc(n,e){for(let t=0;t=l){s=Math.max(h.bottom,s),l=Math.min(h.top,l);let m=h.left>e.left?h.left-e.left:h.right=(h.left+h.right)/2?1:0));continue}}else h.top>e.top&&!a&&h.left<=e.left&&h.right>=e.left&&(a=u,c={left:Math.max(h.left,Math.min(h.right,e.left)),top:h.top});!t&&(e.left>=h.right&&e.top>=h.top||e.left>=h.left&&e.top>=h.bottom)&&(o=f+1)}}return!t&&a&&(t=a,i=c,r=0),t&&t.nodeType==3?nh(t,i):!t||r&&t.nodeType==1?{node:n,offset:o}:Yc(t,i)}function nh(n,e){let t=n.nodeValue.length,r=document.createRange();for(let i=0;i=(o.left+o.right)/2?1:0)}}return{node:n,offset:0}}function Ls(n,e){return n.left>=e.left-1&&n.left<=e.right+1&&n.top>=e.top-1&&n.top<=e.bottom+1}function rh(n,e){let t=n.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left(s.left+s.right)/2?1:-1}return n.docView.posFromDOM(r,i,o)}function oh(n,e,t,r){let i=-1;for(let o=e,s=!1;o!=n.dom;){let l=n.docView.nearestDesc(o,!0),a;if(!l)return null;if(l.dom.nodeType==1&&(l.node.isBlock&&l.parent||!l.contentDOM)&&((a=l.dom.getBoundingClientRect()).width||a.height)&&(l.node.isBlock&&l.parent&&(!s&&a.left>r.left||a.top>r.top?i=l.posBefore:(!s&&a.right-1?i:n.docView.posFromDOM(e,t,-1)}function Xc(n,e,t){let r=n.childNodes.length;if(r&&t.tope.top&&i++}let c;Er&&i&&r.nodeType==1&&(c=r.childNodes[i-1]).nodeType==1&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&i--,r==n.dom&&i==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?l=n.state.doc.content.size:(i==0||r.nodeType!=1||r.childNodes[i-1].nodeName!="BR")&&(l=oh(n,r,i,e))}l==null&&(l=ih(n,s,e));let a=n.docView.nearestDesc(s,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function gc(n){return n.top=0&&i==r.nodeValue.length?(a--,u=1):t<0?a--:c++,br(Pt(St(r,a,c),u),u<0)}if(!n.state.doc.resolve(e-(o||0)).parent.inlineContent){if(o==null&&i&&(t<0||i==We(r))){let a=r.childNodes[i-1];if(a.nodeType==1)return ds(a.getBoundingClientRect(),!1)}if(o==null&&i=0)}if(o==null&&i&&(t<0||i==We(r))){let a=r.childNodes[i-1],c=a.nodeType==3?St(a,We(a)-(s?0:1)):a.nodeType==1&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(c)return br(Pt(c,1),!1)}if(o==null&&i=0)}function br(n,e){if(n.width==0)return n;let t=e?n.left:n.right;return{top:n.top,bottom:n.bottom,left:t,right:t}}function ds(n,e){if(n.height==0)return n;let t=e?n.top:n.bottom;return{top:t,bottom:t,left:n.left,right:n.right}}function Zc(n,e,t){let r=n.state,i=n.root.activeElement;r!=e&&n.updateState(e),i!=n.dom&&n.focus();try{return t()}finally{r!=e&&n.updateState(r),i!=n.dom&&i&&i.focus()}}function ah(n,e,t){let r=e.selection,i=t=="up"?r.$from:r.$to;return Zc(n,e,()=>{let{node:o}=n.docView.domFromPos(i.pos,t=="up"?-1:1);for(;;){let l=n.docView.nearestDesc(o,!0);if(!l)break;if(l.node.isBlock){o=l.contentDOM||l.dom;break}o=l.dom.parentNode}let s=Qc(n,i.pos,1);for(let l=o.firstChild;l;l=l.nextSibling){let a;if(l.nodeType==1)a=l.getClientRects();else if(l.nodeType==3)a=St(l,0,l.nodeValue.length).getClientRects();else continue;for(let c=0;cu.top+1&&(t=="up"?s.top-u.top>(u.bottom-s.top)*2:u.bottom-s.bottom>(s.bottom-u.top)*2))return!1}}return!0})}var ch=/[\u0590-\u08ac]/;function uh(n,e,t){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,o=!i,s=i==r.parent.content.size,l=n.domSelection();return l?!ch.test(r.parent.textContent)||!l.modify?t=="left"||t=="backward"?o:s:Zc(n,e,()=>{let{focusNode:a,focusOffset:c,anchorNode:u,anchorOffset:f}=n.domSelectionRange(),d=l.caretBidiLevel;l.modify("move",t,"character");let p=r.depth?n.docView.domAfterPos(r.before()):n.dom,{focusNode:h,focusOffset:m}=n.domSelectionRange(),g=h&&!p.contains(h.nodeType==1?h:h.parentNode)||a==h&&c==m;try{l.collapse(u,f),a&&(a!=u||c!=f)&&l.extend&&l.extend(a,c)}catch{}return d!=null&&(l.caretBidiLevel=d),g}):r.pos==r.start()||r.pos==r.end()}var yc=null,bc=null,vc=!1;function fh(n,e,t){return yc==e&&bc==t?vc:(yc=e,bc=t,vc=t=="up"||t=="down"?ah(n,e,t):uh(n,e,t))}var Ue=0,xc=1,rn=2,st=3,un=class{constructor(e,t,r,i){this.parent=e,this.children=t,this.dom=r,this.contentDOM=i,this.dirty=Ue,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,r){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;tbe(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))i=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(t==0)for(let o=e;;o=o.parentNode){if(o==this.dom){i=!1;break}if(o.previousSibling)break}if(i==null&&t==e.childNodes.length)for(let o=e;;o=o.parentNode){if(o==this.dom){i=!0;break}if(o.nextSibling)break}}return i??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let r=!0,i=e;i;i=i.parentNode){let o=this.getDesc(i),s;if(o&&(!t||o.node))if(r&&(s=o.nodeDOM)&&!(s.nodeType==1?s.contains(e.nodeType==1?e:e.parentNode):s==e))r=!1;else return o}}getDesc(e){let t=e.pmViewDesc;for(let r=t;r;r=r.parent)if(r==this)return t}posFromDOM(e,t,r){for(let i=e;i;i=i.parentNode){let o=this.getDesc(i);if(o)return o.localPosFromDOM(e,t,r)}return-1}descAt(e){for(let t=0,r=0;te||s instanceof wi){i=e-o;break}o=l}if(i)return this.children[r].domFromPos(i-this.children[r].border,t);for(let o;r&&!(o=this.children[r-1]).size&&o instanceof ki&&o.side>=0;r--);if(t<=0){let o,s=!0;for(;o=r?this.children[r-1]:null,!(!o||o.dom.parentNode==this.contentDOM);r--,s=!1);return o&&t&&s&&!o.border&&!o.domAtom?o.domFromPos(o.size,t):{node:this.contentDOM,offset:o?be(o.dom)+1:0}}else{let o,s=!0;for(;o=r=u&&t<=c-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,t,u);e=s;for(let f=l;f>0;f--){let d=this.children[f-1];if(d.size&&d.dom.parentNode==this.contentDOM&&!d.emptyChildAt(1)){i=be(d.dom)+1;break}e-=d.size}i==-1&&(i=0)}if(i>-1&&(c>t||l==this.children.length-1)){t=c;for(let u=l+1;uh&&st){let h=l;l=a,a=h}let p=document.createRange();p.setEnd(a.node,a.offset),p.setStart(l.node,l.offset),c.removeAllRanges(),c.addRange(p)}}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 r=0,i=0;i=r:er){let l=r+o.border,a=s-o.border;if(e>=l&&t<=a){this.dirty=e==r||t==s?rn:xc,e==l&&t==a&&(o.contentLost||o.dom.parentNode!=this.contentDOM)?o.dirty=st:o.markDirty(e-l,t-l);return}else o.dirty=o.dom==o.contentDOM&&o.dom.parentNode==this.contentDOM&&!o.children.length?rn:st}r=s}this.dirty=rn}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let r=e==1?rn:xc;t.dirty{if(!o)return i;if(o.parent)return o.parent.posBeforeChild(o)})),!t.type.spec.raw){if(s.nodeType!=1){let l=document.createElement("span");l.appendChild(s),s=l}s.contentEditable="false",s.classList.add("ProseMirror-widget")}super(e,[],s,null),this.widget=t,this.widget=t,o=this}matchesWidget(e){return this.dirty==Ue&&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 side(){return this.widget.type.side}},ks=class extends un{constructor(e,t,r,i){super(e,[],t,null),this.textDOM=r,this.text=i}get size(){return this.text.length}localPosFromDOM(e,t){return e!=this.textDOM?this.posAtStart+(t?this.size:0):this.posAtStart+t}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}},jn=class n extends un{constructor(e,t,r,i,o){super(e,[],r,i),this.mark=t,this.spec=o}static create(e,t,r,i){let o=i.nodeViews[t.type.name],s=o&&o(t,i,r);return(!s||!s.dom)&&(s=bt.renderSpec(document,t.type.spec.toDOM(t,r),null,t.attrs)),new n(e,t,s.dom,s.contentDOM||s.dom,s)}parseRule(){return this.dirty&st||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=st&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=Ue){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty0&&(o=Ms(o,0,e,r));for(let l=0;l{if(!a)return s;if(a.parent)return a.parent.posBeforeChild(a)},r,i),u=c&&c.dom,f=c&&c.contentDOM;if(t.isText){if(!u)u=document.createTextNode(t.text);else if(u.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else u||({dom:u,contentDOM:f}=bt.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs));!f&&!t.isText&&u.nodeName!="BR"&&(u.hasAttribute("contenteditable")||(u.contentEditable="false"),t.type.spec.draggable&&(u.draggable=!0));let d=u;return u=nu(u,r,t),c?a=new Ss(e,t,r,i,u,f||null,d,c,o,s+1):t.isText?new Si(e,t,r,i,u,d,o):new n(e,t,r,i,u,f||null,d,o,s+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let t=this.children.length-1;t>=0;t--){let r=this.children[t];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>S.empty)}return e}matchesNode(e,t,r){return this.dirty==Ue&&e.eq(this.node)&&Ci(t,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let r=this.node.inlineContent,i=t,o=e.composing?this.localCompositionInfo(e,t):null,s=o&&o.pos>-1?o:null,l=o&&o.pos<0,a=new Cs(this,s&&s.node,e);mh(this.node,this.innerDeco,(c,u,f)=>{c.spec.marks?a.syncToMarks(c.spec.marks,r,e):c.type.side>=0&&!f&&a.syncToMarks(u==this.node.childCount?W.none:this.node.child(u).marks,r,e),a.placeWidget(c,e,i)},(c,u,f,d)=>{a.syncToMarks(c.marks,r,e);let p;a.findNodeMatch(c,u,f,d)||l&&e.state.selection.from>i&&e.state.selection.to-1&&a.updateNodeAt(c,u,f,p,e)||a.updateNextNode(c,u,f,e,d,i)||a.addNode(c,u,f,e,i),i+=c.nodeSize}),a.syncToMarks([],r,e),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==rn)&&(s&&this.protectLocalComposition(e,s),eu(this.contentDOM,this.children,e),Vn&&gh(this.dom))}localCompositionInfo(e,t){let{from:r,to:i}=e.state.selection;if(!(e.state.selection instanceof P)||rt+this.node.content.size)return null;let o=e.input.compositionNode;if(!o||!this.dom.contains(o.parentNode))return null;if(this.node.inlineContent){let s=o.nodeValue,l=yh(this.node.content,s,r-t,i-t);return l<0?null:{node:o,pos:l,text:s}}else return{node:o,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:r,text:i}){if(this.getDesc(t))return;let o=t;for(;o.parentNode!=this.contentDOM;o=o.parentNode){for(;o.previousSibling;)o.parentNode.removeChild(o.previousSibling);for(;o.nextSibling;)o.parentNode.removeChild(o.nextSibling);o.pmViewDesc&&(o.pmViewDesc=void 0)}let s=new ks(this,o,t,i);e.input.compositionNodes.push(s),this.children=Ms(this.children,r,r+i.length,e,s)}update(e,t,r,i){return this.dirty==st||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,r,i),!0)}updateInner(e,t,r,i){this.updateOuterDeco(t),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(i,this.posAtStart),this.dirty=Ue}updateOuterDeco(e){if(Ci(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=tu(this.dom,this.nodeDOM,ws(this.outerDeco,this.node,t),ws(e,this.node,t)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.dom.draggable=!0)}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.dom.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}};function kc(n,e,t,r,i){nu(r,e,n);let o=new Ft(void 0,n,e,t,r,r,r,i,0);return o.contentDOM&&o.updateChildren(i,0),o}var Si=class n extends Ft{constructor(e,t,r,i,o,s,l){super(e,t,r,i,o,null,s,l,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,r,i){return this.dirty==st||this.dirty!=Ue&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=Ue||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,i.trackWrites==this.nodeDOM&&(i.trackWrites=null)),this.node=e,this.dirty=Ue,!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,r){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,t,r){let i=this.node.cut(e,t),o=document.createTextNode(i.text);return new n(this.parent,i,this.outerDeco,this.innerDeco,o,o,r)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=st)}get domAtom(){return!1}isText(e){return this.node.text==e}},wi=class extends un{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Ue&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}},Ss=class extends Ft{constructor(e,t,r,i,o,s,l,a,c,u){super(e,t,r,i,o,s,l,c,u),this.spec=a}update(e,t,r,i){if(this.dirty==st)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let o=this.spec.update(e,t,r);return o&&this.updateInner(e,t,r,i),o}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,r,i)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,r,i){this.spec.setSelection?this.spec.setSelection(e,t,r.root):super.setSelection(e,t,r,i)}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 eu(n,e,t){let r=n.firstChild,i=!1;for(let o=0;o>1,s=Math.min(o,e.length);for(;i-1)l>this.index&&(this.changed=!0,this.destroyBetween(this.index,l)),this.top=this.top.children[this.index];else{let a=jn.create(this.top,e[o],t,r);this.top.children.splice(this.index,0,a),this.top=a,this.changed=!0}this.index=0,o++}}findNodeMatch(e,t,r,i){let o=-1,s;if(i>=this.preMatch.index&&(s=this.preMatch.matches[i-this.preMatch.index]).parent==this.top&&s.matchesNode(e,t,r))o=this.top.children.indexOf(s,this.index);else for(let l=this.index,a=Math.min(this.top.children.length,l+5);l0;){let l;for(;;)if(r){let c=t.children[r-1];if(c instanceof jn)t=c,r=c.children.length;else{l=c,r--;break}}else{if(t==e)break e;r=t.parent.children.indexOf(t),t=t.parent}let a=l.node;if(a){if(a!=n.child(i-1))break;--i,o.set(l,i),s.push(l)}}return{index:i,matched:o,matches:s.reverse()}}function hh(n,e){return n.type.side-e.type.side}function mh(n,e,t,r){let i=e.locals(n),o=0;if(i.length==0){for(let c=0;co;)l.push(i[s++]);let h=o+d.nodeSize;if(d.isText){let g=h;s!g.inline):l.slice();r(d,m,e.forChild(o,d),p),o=h}}function gh(n){if(n.nodeName=="UL"||n.nodeName=="OL"){let e=n.style.cssText;n.style.cssText=e+"; list-style: square !important",window.getComputedStyle(n).listStyle,n.style.cssText=e}}function yh(n,e,t,r){for(let i=0,o=0;i=t){if(o>=r&&a.slice(r-e.length-l,r-l)==e)return r-e.length;let c=l=0&&c+e.length+l>=t)return l+c;if(t==r&&a.length>=r+e.length-l&&a.slice(r-l,r-l+e.length)==e)return r}}return-1}function Ms(n,e,t,r,i){let o=[];for(let s=0,l=0;s=t||u<=e?o.push(a):(ct&&o.push(a.slice(t-c,a.size,r)))}return o}function Bs(n,e=null){let t=n.domSelectionRange(),r=n.state.doc;if(!t.focusNode)return null;let i=n.docView.nearestDesc(t.focusNode),o=i&&i.size==0,s=n.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(s<0)return null;let l=r.resolve(s),a,c;if(Ri(t)){for(a=s;i&&!i.node;)i=i.parent;let f=i.node;if(i&&f.isAtom&&D.isSelectable(f)&&i.parent&&!(f.isInline&&Kp(t.focusNode,t.focusOffset,i.dom))){let d=i.posBefore;c=new D(s==d?l:r.resolve(d))}}else{if(t instanceof n.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let f=s,d=s;for(let p=0;p{(t.anchorNode!=r||t.anchorOffset!=i)&&(e.removeEventListener("selectionchange",n.input.hideSelectionGuard),setTimeout(()=>{(!ru(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function vh(n){let e=n.domSelection(),t=document.createRange();if(!e)return;let r=n.cursorWrapper.dom,i=r.nodeName=="IMG";i?t.setStart(r.parentNode,be(r)+1):t.setStart(r,0),t.collapse(!0),e.removeAllRanges(),e.addRange(t),!i&&!n.state.selection.visible&&Ie&&zt<=11&&(r.disabled=!0,r.disabled=!1)}function iu(n,e){if(e instanceof D){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(Ec(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else Ec(n)}function Ec(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function zs(n,e,t,r){return n.someProp("createSelectionBetween",i=>i(n,e,t))||P.between(e,t,r)}function Oc(n){return n.editable&&!n.hasFocus()?!1:ou(n)}function ou(n){let e=n.domSelectionRange();if(!e.anchorNode)return!1;try{return n.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(n.editable||n.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function xh(n){let e=n.docView.domFromPos(n.state.selection.anchor,0),t=n.domSelectionRange();return cn(e.node,e.offset,t.anchorNode,t.anchorOffset)}function Es(n,e){let{$anchor:t,$head:r}=n.selection,i=e>0?t.max(r):t.min(r),o=i.parent.inlineContent?i.depth?n.doc.resolve(e>0?i.after():i.before()):null:i;return o&&I.findFrom(o,e)}function Lt(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function Tc(n,e,t){let r=n.state.selection;if(r instanceof P)if(t.indexOf("s")>-1){let{$head:i}=r,o=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter;if(!o||o.isText||!o.isLeaf)return!1;let s=n.state.doc.resolve(i.pos+o.nodeSize*(e<0?-1:1));return Lt(n,new P(r.$anchor,s))}else if(r.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let i=Es(n.state,e);return i&&i instanceof D?Lt(n,i):!1}else if(!(je&&t.indexOf("m")>-1)){let i=r.$head,o=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter,s;if(!o||o.isText)return!1;let l=e<0?i.pos-o.nodeSize:i.pos;return o.isAtom||(s=n.docView.descAt(l))&&!s.contentDOM?D.isSelectable(o)?Lt(n,new D(e<0?n.state.doc.resolve(i.pos-o.nodeSize):i)):Er?Lt(n,new P(n.state.doc.resolve(e<0?l:l+o.nodeSize))):!1:!1}}else return!1;else{if(r instanceof D&&r.node.isInline)return Lt(n,new P(e>0?r.$to:r.$from));{let i=Es(n.state,e);return i?Lt(n,i):!1}}}function Mi(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function xr(n,e){let t=n.pmViewDesc;return t&&t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR")}function Fn(n,e){return e<0?kh(n):Sh(n)}function kh(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let i,o,s=!1;for(et&&t.nodeType==1&&r0){if(t.nodeType!=1)break;{let l=t.childNodes[r-1];if(xr(l,-1))i=t,o=--r;else if(l.nodeType==3)t=l,r=t.nodeValue.length;else break}}else{if(su(t))break;{let l=t.previousSibling;for(;l&&xr(l,-1);)i=t.parentNode,o=be(l),l=l.previousSibling;if(l)t=l,r=Mi(t);else{if(t=t.parentNode,t==n.dom)break;r=0}}}s?Os(n,t,r):i&&Os(n,i,o)}function Sh(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let i=Mi(t),o,s;for(;;)if(r{n.state==i&&Ct(n)},50)}function Ac(n,e){let t=n.state.doc.resolve(e);if(!(Ce||Gp)&&t.parent.inlineContent){let i=n.coordsAtPos(e);if(e>t.start()){let o=n.coordsAtPos(e-1),s=(o.top+o.bottom)/2;if(s>i.top&&s1)return o.lefti.top&&s1)return o.left>i.left?"ltr":"rtl"}}return getComputedStyle(n.dom).direction=="rtl"?"rtl":"ltr"}function Nc(n,e,t){let r=n.state.selection;if(r instanceof P&&!r.empty||t.indexOf("s")>-1||je&&t.indexOf("m")>-1)return!1;let{$from:i,$to:o}=r;if(!i.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let s=Es(n.state,e);if(s&&s instanceof D)return Lt(n,s)}if(!i.parent.inlineContent){let s=e<0?i:o,l=r instanceof Oe?I.near(s,e):I.findFrom(s,e);return l?Lt(n,l):!1}return!1}function Dc(n,e){if(!(n.state.selection instanceof P))return!0;let{$head:t,$anchor:r,empty:i}=n.state.selection;if(!t.sameParent(r))return!0;if(!i)return!1;if(n.endOfTextblock(e>0?"forward":"backward"))return!0;let o=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(o&&!o.isText){let s=n.state.tr;return e<0?s.delete(t.pos-o.nodeSize,t.pos):s.delete(t.pos,t.pos+o.nodeSize),n.dispatch(s),!0}return!1}function Rc(n,e,t){n.domObserver.stop(),e.contentEditable=t,n.domObserver.start()}function Mh(n){if(!Te||n.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(e&&e.nodeType==1&&t==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;Rc(n,r,"true"),setTimeout(()=>Rc(n,r,"false"),20)}return!1}function Eh(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function Oh(n,e){let t=e.keyCode,r=Eh(e);if(t==8||je&&t==72&&r=="c")return Dc(n,-1)||Fn(n,-1);if(t==46&&!e.shiftKey||je&&t==68&&r=="c")return Dc(n,1)||Fn(n,1);if(t==13||t==27)return!0;if(t==37||je&&t==66&&r=="c"){let i=t==37?Ac(n,n.state.selection.from)=="ltr"?-1:1:-1;return Tc(n,i,r)||Fn(n,i)}else if(t==39||je&&t==70&&r=="c"){let i=t==39?Ac(n,n.state.selection.from)=="ltr"?1:-1:1;return Tc(n,i,r)||Fn(n,i)}else{if(t==38||je&&t==80&&r=="c")return Nc(n,-1,r)||Fn(n,-1);if(t==40||je&&t==78&&r=="c")return Mh(n)||Nc(n,1,r)||Fn(n,1);if(r==(je?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function lu(n,e){n.someProp("transformCopied",p=>{e=p(e,n)});let t=[],{content:r,openStart:i,openEnd:o}=e;for(;i>1&&o>1&&r.childCount==1&&r.firstChild.childCount==1;){i--,o--;let p=r.firstChild;t.push(p.type.name,p.attrs!=p.type.defaultAttrs?p.attrs:null),r=p.content}let s=n.someProp("clipboardSerializer")||bt.fromSchema(n.state.schema),l=pu(),a=l.createElement("div");a.appendChild(s.serializeFragment(r,{document:l}));let c=a.firstChild,u,f=0;for(;c&&c.nodeType==1&&(u=du[c.nodeName.toLowerCase()]);){for(let p=u.length-1;p>=0;p--){let h=l.createElement(u[p]);for(;a.firstChild;)h.appendChild(a.firstChild);a.appendChild(h),f++}c=a.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${i} ${o}${f?` -${f}`:""} ${JSON.stringify(t)}`);let d=n.someProp("clipboardTextSerializer",p=>p(e,n))||e.content.textBetween(0,e.content.size,` + +`);return{dom:a,text:d,slice:e}}function au(n,e,t,r,i){let o=i.parent.type.spec.code,s,l;if(!t&&!e)return null;let a=e&&(r||o||!t);if(a){if(n.someProp("transformPastedText",d=>{e=d(e,o||r,n)}),o)return e?new E(S.from(n.state.schema.text(e.replace(/\r\n?/g,` +`))),0,0):E.empty;let f=n.someProp("clipboardTextParser",d=>d(e,i,r,n));if(f)l=f;else{let d=i.marks(),{schema:p}=n.state,h=bt.fromSchema(p);s=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(m=>{let g=s.appendChild(document.createElement("p"));m&&g.appendChild(h.serializeNode(p.text(m,d)))})}}else n.someProp("transformPastedHTML",f=>{t=f(t,n)}),s=Dh(t),Er&&Rh(s);let c=s&&s.querySelector("[data-pm-slice]"),u=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(u&&u[3])for(let f=+u[3];f>0;f--){let d=s.firstChild;for(;d&&d.nodeType!=1;)d=d.nextSibling;if(!d)break;s=d}if(l||(l=(n.someProp("clipboardParser")||n.someProp("domParser")||yt.fromSchema(n.state.schema)).parseSlice(s,{preserveWhitespace:!!(a||u),context:i,ruleFromNode(d){return d.nodeName=="BR"&&!d.nextSibling&&d.parentNode&&!Th.test(d.parentNode.nodeName)?{ignore:!0}:null}})),u)l=Ih(Ic(l,+u[1],+u[2]),u[4]);else if(l=E.maxOpen(Ah(l.content,i),!0),l.openStart||l.openEnd){let f=0,d=0;for(let p=l.content.firstChild;f{l=f(l,n)}),l}var Th=/^(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 Ah(n,e){if(n.childCount<2)return n;for(let t=e.depth;t>=0;t--){let i=e.node(t).contentMatchAt(e.index(t)),o,s=[];if(n.forEach(l=>{if(!s)return;let a=i.findWrapping(l.type),c;if(!a)return s=null;if(c=s.length&&o.length&&uu(a,o,l,s[s.length-1],0))s[s.length-1]=c;else{s.length&&(s[s.length-1]=fu(s[s.length-1],o.length));let u=cu(l,a);s.push(u),i=i.matchType(u.type),o=a}}),s)return S.from(s)}return n}function cu(n,e,t=0){for(let r=e.length-1;r>=t;r--)n=e[r].create(null,S.from(n));return n}function uu(n,e,t,r,i){if(i1&&(o=0),i=t&&(l=e<0?s.contentMatchAt(0).fillBefore(l,o<=i).append(l):l.append(s.contentMatchAt(s.childCount).fillBefore(S.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,s.copy(l))}function Ic(n,e,t){return et})),hs.createHTML(n)):n}function Dh(n){let e=/^(\s*]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=pu().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(n),i;if((i=r&&du[r[1].toLowerCase()])&&(n=i.map(o=>"<"+o+">").join("")+n+i.map(o=>"").reverse().join("")),t.innerHTML=Nh(n),i)for(let o=0;o=0;l-=2){let a=t.nodes[r[l]];if(!a||a.hasRequiredAttrs())break;i=S.from(a.create(r[l+1],i)),o++,s++}return new E(i,o,s)}var Ae={},Ne={},Ph={touchstart:!0,touchmove:!0},As=class{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:""},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.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}};function Lh(n){for(let e in Ae){let t=Ae[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=r=>{zh(n,r)&&!Fs(n,r)&&(n.editable||!(r.type in Ne))&&t(n,r)},Ph[e]?{passive:!0}:void 0)}Te&&n.dom.addEventListener("input",()=>null),Ns(n)}function Bt(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function Bh(n){n.domObserver.stop();for(let e in n.input.eventHandlers)n.dom.removeEventListener(e,n.input.eventHandlers[e]);clearTimeout(n.input.composingTimeout),clearTimeout(n.input.lastIOSEnterFallbackTimeout)}function Ns(n){n.someProp("handleDOMEvents",e=>{for(let t in e)n.input.eventHandlers[t]||n.dom.addEventListener(t,n.input.eventHandlers[t]=r=>Fs(n,r))})}function Fs(n,e){return n.someProp("handleDOMEvents",t=>{let r=t[e.type];return r?r(n,e)||e.defaultPrevented:!1})}function zh(n,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target;t!=n.dom;t=t.parentNode)if(!t||t.nodeType==11||t.pmViewDesc&&t.pmViewDesc.stopEvent(e))return!1;return!0}function Fh(n,e){!Fs(n,e)&&Ae[e.type]&&(n.editable||!(e.type in Ne))&&Ae[e.type](n,e)}Ne.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,!mu(n,t)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(wt&&Ce&&t.keyCode==13)))if(t.keyCode!=229&&n.domObserver.forceFlush(),Vn&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let r=Date.now();n.input.lastIOSEnter=r,n.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{n.input.lastIOSEnter==r&&(n.someProp("handleKeyDown",i=>i(n,nn(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",r=>r(n,t))||Oh(n,t)?t.preventDefault():Bt(n,"key")};Ne.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)};Ne.keypress=(n,e)=>{let t=e;if(mu(n,t)||!t.charCode||t.ctrlKey&&!t.altKey||je&&t.metaKey)return;if(n.someProp("handleKeyPress",i=>i(n,t))){t.preventDefault();return}let r=n.state.selection;if(!(r instanceof P)||!r.$from.sameParent(r.$to)){let i=String.fromCharCode(t.charCode);!/[\r\n]/.test(i)&&!n.someProp("handleTextInput",o=>o(n,r.$from.pos,r.$to.pos,i))&&n.dispatch(n.state.tr.insertText(i).scrollIntoView()),t.preventDefault()}};function Ii(n){return{left:n.clientX,top:n.clientY}}function Hh(n,e){let t=e.x-n.clientX,r=e.y-n.clientY;return t*t+r*r<100}function Hs(n,e,t,r,i){if(r==-1)return!1;let o=n.state.doc.resolve(r);for(let s=o.depth+1;s>0;s--)if(n.someProp(e,l=>s>o.depth?l(n,t,o.nodeAfter,o.before(s),i,!0):l(n,t,o.node(s),o.before(s),i,!1)))return!0;return!1}function $n(n,e,t){if(n.focused||n.focus(),n.state.selection.eq(e))return;let r=n.state.tr.setSelection(e);t=="pointer"&&r.setMeta("pointer",!0),n.dispatch(r)}function $h(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),r=t.nodeAfter;return r&&r.isAtom&&D.isSelectable(r)?($n(n,new D(t),"pointer"),!0):!1}function Vh(n,e){if(e==-1)return!1;let t=n.state.selection,r,i;t instanceof D&&(r=t.node);let o=n.state.doc.resolve(e);for(let s=o.depth+1;s>0;s--){let l=s>o.depth?o.nodeAfter:o.node(s);if(D.isSelectable(l)){r&&t.$from.depth>0&&s>=t.$from.depth&&o.before(t.$from.depth+1)==t.$from.pos?i=o.before(t.$from.depth):i=o.before(s);break}}return i!=null?($n(n,D.create(n.state.doc,i),"pointer"),!0):!1}function jh(n,e,t,r,i){return Hs(n,"handleClickOn",e,t,r)||n.someProp("handleClick",o=>o(n,e,r))||(i?Vh(n,t):$h(n,t))}function Wh(n,e,t,r){return Hs(n,"handleDoubleClickOn",e,t,r)||n.someProp("handleDoubleClick",i=>i(n,e,r))}function Uh(n,e,t,r){return Hs(n,"handleTripleClickOn",e,t,r)||n.someProp("handleTripleClick",i=>i(n,e,r))||_h(n,t,r)}function _h(n,e,t){if(t.button!=0)return!1;let r=n.state.doc;if(e==-1)return r.inlineContent?($n(n,P.create(r,0,r.content.size),"pointer"),!0):!1;let i=r.resolve(e);for(let o=i.depth+1;o>0;o--){let s=o>i.depth?i.nodeAfter:i.node(o),l=i.before(o);if(s.inlineContent)$n(n,P.create(r,l+1,l+1+s.content.size),"pointer");else if(D.isSelectable(s))$n(n,D.create(r,l),"pointer");else continue;return!0}}function $s(n){return Ei(n)}var hu=je?"metaKey":"ctrlKey";Ae.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let r=$s(n),i=Date.now(),o="singleClick";i-n.input.lastClick.time<500&&Hh(t,n.input.lastClick)&&!t[hu]&&(n.input.lastClick.type=="singleClick"?o="doubleClick":n.input.lastClick.type=="doubleClick"&&(o="tripleClick")),n.input.lastClick={time:i,x:t.clientX,y:t.clientY,type:o};let s=n.posAtCoords(Ii(t));s&&(o=="singleClick"?(n.input.mouseDown&&n.input.mouseDown.done(),n.input.mouseDown=new Ds(n,s,t,!!r)):(o=="doubleClick"?Wh:Uh)(n,s.pos,s.inside,t)?t.preventDefault():Bt(n,"pointer"))};var Ds=class{constructor(e,t,r,i){this.view=e,this.pos=t,this.event=r,this.flushed=i,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[hu],this.allowDefault=r.shiftKey;let o,s;if(t.inside>-1)o=e.state.doc.nodeAt(t.inside),s=t.inside;else{let u=e.state.doc.resolve(t.pos);o=u.parent,s=u.depth?u.before():0}let l=i?null:r.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a&&a.dom.nodeType==1?a.dom:null;let{selection:c}=e.state;(r.button==0&&o.type.spec.draggable&&o.type.spec.selectable!==!1||c instanceof D&&c.from<=s&&c.to>s)&&(this.mightDrag={node:o,pos:s,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&et&&!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()),e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),Bt(e,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),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(()=>Ct(this.view)),this.view.input.mouseDown=null}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(Ii(e))),this.updateAllowDefault(e),this.allowDefault||!t?Bt(this.view,"pointer"):jh(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||Te&&this.mightDrag&&!this.mightDrag.node.isAtom||Ce&&!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)?($n(this.view,I.near(this.view.state.doc.resolve(t.pos)),"pointer"),e.preventDefault()):Bt(this.view,"pointer")}move(e){this.updateAllowDefault(e),Bt(this.view,"pointer"),e.buttons==0&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}};Ae.touchstart=n=>{n.input.lastTouch=Date.now(),$s(n),Bt(n,"pointer")};Ae.touchmove=n=>{n.input.lastTouch=Date.now(),Bt(n,"pointer")};Ae.contextmenu=n=>$s(n);function mu(n,e){return n.composing?!0:Te&&Math.abs(e.timeStamp-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}var Kh=wt?5e3:-1;Ne.compositionstart=Ne.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:e}=n,t=e.selection.$to;if(e.selection instanceof P&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)))n.markCursor=n.state.storedMarks||t.marks(),Ei(n,!0),n.markCursor=null;else if(Ei(n,!e.selection.empty),et&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let r=n.domSelectionRange();for(let i=r.focusNode,o=r.focusOffset;i&&i.nodeType==1&&o!=0;){let s=o<0?i.lastChild:i.childNodes[o-1];if(!s)break;if(s.nodeType==3){let l=n.domSelection();l&&l.collapse(s,s.nodeValue.length);break}else i=s,o=-1}}n.input.composing=!0}gu(n,Kh)};Ne.compositionend=(n,e)=>{n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=e.timeStamp,n.input.compositionPendingChanges=n.domObserver.pendingRecords().length?n.input.compositionID:0,n.input.compositionNode=null,n.input.compositionPendingChanges&&Promise.resolve().then(()=>n.domObserver.flush()),n.input.compositionID++,gu(n,20))};function gu(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>Ei(n),e))}function yu(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=Jh());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function qh(n){let e=n.domSelectionRange();if(!e.focusNode)return null;let t=Up(e.focusNode,e.focusOffset),r=_p(e.focusNode,e.focusOffset);if(t&&r&&t!=r){let i=r.pmViewDesc,o=n.domObserver.lastChangedTextNode;if(t==o||r==o)return o;if(!i||!i.isText(r.nodeValue))return r;if(n.input.compositionNode==r){let s=t.pmViewDesc;if(!(!s||!s.isText(t.nodeValue)))return r}}return t||r}function Jh(){let n=document.createEvent("Event");return n.initEvent("event",!0,!0),n.timeStamp}function Ei(n,e=!1){if(!(wt&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),yu(n),e||n.docView&&n.docView.dirty){let t=Bs(n);return t&&!t.eq(n.state.selection)?n.dispatch(n.state.tr.setSelection(t)):(n.markCursor||e)&&!n.state.selection.empty?n.dispatch(n.state.tr.deleteSelection()):n.updateState(n.state),!0}return!1}}function Gh(n,e){if(!n.dom.parentNode)return;let t=n.dom.parentNode.appendChild(document.createElement("div"));t.appendChild(e),t.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),i=document.createRange();i.selectNodeContents(e),n.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),n.focus()},50)}var Sr=Ie&&zt<15||Vn&&Yp<604;Ae.copy=Ne.cut=(n,e)=>{let t=e,r=n.state.selection,i=t.type=="cut";if(r.empty)return;let o=Sr?null:t.clipboardData,s=r.content(),{dom:l,text:a}=lu(n,s);o?(t.preventDefault(),o.clearData(),o.setData("text/html",l.innerHTML),o.setData("text/plain",a)):Gh(n,l),i&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function Yh(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function Xh(n,e){if(!n.dom.parentNode)return;let t=n.input.shiftKey||n.state.selection.$from.parent.type.spec.code,r=n.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let i=n.input.shiftKey&&n.input.lastKeyCode!=45;setTimeout(()=>{n.focus(),r.parentNode&&r.parentNode.removeChild(r),t?wr(n,r.value,null,i,e):wr(n,r.textContent,r.innerHTML,i,e)},50)}function wr(n,e,t,r,i){let o=au(n,e,t,r,n.state.selection.$from);if(n.someProp("handlePaste",a=>a(n,i,o||E.empty)))return!0;if(!o)return!1;let s=Yh(o),l=s?n.state.tr.replaceSelectionWith(s,r):n.state.tr.replaceSelection(o);return n.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function bu(n){let e=n.getData("text/plain")||n.getData("Text");if(e)return e;let t=n.getData("text/uri-list");return t?t.replace(/\r?\n/g," "):""}Ne.paste=(n,e)=>{let t=e;if(n.composing&&!wt)return;let r=Sr?null:t.clipboardData,i=n.input.shiftKey&&n.input.lastKeyCode!=45;r&&wr(n,bu(r),r.getData("text/html"),i,t)?t.preventDefault():Xh(n,t)};var Oi=class{constructor(e,t,r){this.slice=e,this.move=t,this.node=r}},vu=je?"altKey":"ctrlKey";Ae.dragstart=(n,e)=>{let t=e,r=n.input.mouseDown;if(r&&r.done(),!t.dataTransfer)return;let i=n.state.selection,o=i.empty?null:n.posAtCoords(Ii(t)),s;if(!(o&&o.pos>=i.from&&o.pos<=(i instanceof D?i.to-1:i.to))){if(r&&r.mightDrag)s=D.create(n.state.doc,r.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let f=n.docView.nearestDesc(t.target,!0);f&&f.node.type.spec.draggable&&f!=n.docView&&(s=D.create(n.state.doc,f.posBefore))}}let l=(s||n.state.selection).content(),{dom:a,text:c,slice:u}=lu(n,l);(!t.dataTransfer.files.length||!Ce||qc>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(Sr?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",Sr||t.dataTransfer.setData("text/plain",c),n.dragging=new Oi(u,!t[vu],s)};Ae.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)};Ne.dragover=Ne.dragenter=(n,e)=>e.preventDefault();Ne.drop=(n,e)=>{let t=e,r=n.dragging;if(n.dragging=null,!t.dataTransfer)return;let i=n.posAtCoords(Ii(t));if(!i)return;let o=n.state.doc.resolve(i.pos),s=r&&r.slice;s?n.someProp("transformPasted",h=>{s=h(s,n)}):s=au(n,bu(t.dataTransfer),Sr?null:t.dataTransfer.getData("text/html"),!1,o);let l=!!(r&&!t[vu]);if(n.someProp("handleDrop",h=>h(n,t,s||E.empty,l))){t.preventDefault();return}if(!s)return;t.preventDefault();let a=s?gi(n.state.doc,o.pos,s):o.pos;a==null&&(a=o.pos);let c=n.state.tr;if(l){let{node:h}=r;h?h.replace(c):c.deleteSelection()}let u=c.mapping.map(a),f=s.openStart==0&&s.openEnd==0&&s.content.childCount==1,d=c.doc;if(f?c.replaceRangeWith(u,u,s.content.firstChild):c.replaceRange(u,u,s),c.doc.eq(d))return;let p=c.doc.resolve(u);if(f&&D.isSelectable(s.content.firstChild)&&p.nodeAfter&&p.nodeAfter.sameMarkup(s.content.firstChild))c.setSelection(new D(p));else{let h=c.mapping.map(a);c.mapping.maps[c.mapping.maps.length-1].forEach((m,g,b,x)=>h=x),c.setSelection(zs(n,p,c.doc.resolve(h)))}n.focus(),n.dispatch(c.setMeta("uiEvent","drop"))};Ae.focus=n=>{n.input.lastFocus=Date.now(),n.focused||(n.domObserver.stop(),n.dom.classList.add("ProseMirror-focused"),n.domObserver.start(),n.focused=!0,setTimeout(()=>{n.docView&&n.hasFocus()&&!n.domObserver.currentSelection.eq(n.domSelectionRange())&&Ct(n)},20))};Ae.blur=(n,e)=>{let t=e;n.focused&&(n.domObserver.stop(),n.dom.classList.remove("ProseMirror-focused"),n.domObserver.start(),t.relatedTarget&&n.dom.contains(t.relatedTarget)&&n.domObserver.currentSelection.clear(),n.focused=!1)};Ae.beforeinput=(n,e)=>{if(Ce&&wt&&e.inputType=="deleteContentBackward"){n.domObserver.flushSoon();let{domChangeCount:r}=n.input;setTimeout(()=>{if(n.input.domChangeCount!=r||(n.dom.blur(),n.focus(),n.someProp("handleKeyDown",o=>o(n,nn(8,"Backspace")))))return;let{$cursor:i}=n.state.selection;i&&i.pos>0&&n.dispatch(n.state.tr.delete(i.pos-1,i.pos).scrollIntoView())},50)}};for(let n in Ne)Ae[n]=Ne[n];function Cr(n,e){if(n==e)return!0;for(let t in n)if(n[t]!==e[t])return!1;for(let t in e)if(!(t in n))return!1;return!0}var Ti=class n{constructor(e,t){this.toDOM=e,this.spec=t||ln,this.side=this.spec.side||0}map(e,t,r,i){let{pos:o,deleted:s}=e.mapResult(t.from+i,this.side<0?-1:1);return s?null:new Pe(o-r,o-r,this)}valid(){return!0}eq(e){return this==e||e instanceof n&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Cr(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}},sn=class n{constructor(e,t){this.attrs=e,this.spec=t||ln}map(e,t,r,i){let o=e.map(t.from+i,this.spec.inclusiveStart?-1:1)-r,s=e.map(t.to+i,this.spec.inclusiveEnd?1:-1)-r;return o>=s?null:new Pe(o,s,this)}valid(e,t){return t.from=e&&(!o||o(l.spec))&&r.push(l.copy(l.from+i,l.to+i))}for(let s=0;se){let l=this.children[s]+1;this.children[s+2].findInner(e-l,t-l,r,i+l,o)}}map(e,t,r){return this==we||e.maps.length==0?this:this.mapInner(e,t,0,0,r||ln)}mapInner(e,t,r,i,o){let s;for(let l=0;l{let c=a+r,u;if(u=ku(t,l,c)){for(i||(i=this.children.slice());ol&&f.to=e){this.children[l]==e&&(r=this.children[l+2]);break}let o=e+1,s=o+t.content.size;for(let l=0;lo&&a.type instanceof sn){let c=Math.max(o,a.from)-o,u=Math.min(s,a.to)-o;ci.map(e,t,ln));return n.from(r)}forChild(e,t){if(t.isLeaf)return de.empty;let r=[];for(let i=0;it instanceof de)?e:e.reduce((t,r)=>t.concat(r instanceof de?r:r.members),[]))}}forEachSet(e){for(let t=0;t{let g=m-h-(p-d);for(let b=0;bx+u-f)continue;let C=l[b]+u-f;p>=C?l[b+1]=d<=C?-2:-1:d>=u&&g&&(l[b]+=g,l[b+1]+=g)}f+=g}),u=t.maps[c].map(u,-1)}let a=!1;for(let c=0;c=r.content.size){a=!0;continue}let d=t.map(n[c+1]+o,-1),p=d-i,{index:h,offset:m}=r.content.findIndex(f),g=r.maybeChild(h);if(g&&m==f&&m+g.nodeSize==p){let b=l[c+2].mapInner(t,g,u+1,n[c]+o+1,s);b!=we?(l[c]=f,l[c+1]=p,l[c+2]=b):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=Zh(l,n,e,t,i,o,s),u=Ni(c,r,0,s);e=u.local;for(let f=0;ft&&s.to{let c=ku(n,l,a+t);if(c){o=!0;let u=Ni(c,l,t+a+1,r);u!=we&&i.push(a,a+l.nodeSize,u)}});let s=xu(o?Su(n):n,-t).sort(an);for(let l=0;l0;)e++;n.splice(e,0,t)}function ms(n){let e=[];return n.someProp("decorations",t=>{let r=t(n.state);r&&r!=we&&e.push(r)}),n.cursorWrapper&&e.push(de.create(n.state.doc,[n.cursorWrapper.deco])),Ai.from(e)}var em={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},tm=Ie&&zt<=11,Is=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}},Ps=class{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new Is,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let i=0;ii.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),tm&&(this.onCharData=r=>{this.queue.push({target:r.target,type:"characterData",oldValue:r.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,em)),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(Oc(this.view)){if(this.suppressingSelectionUpdates)return Ct(this.view);if(Ie&&zt<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&cn(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,r;for(let o=e.focusNode;o;o=kr(o))t.add(o);for(let o=e.anchorNode;o;o=kr(o))if(t.has(o)){r=o;break}let i=r&&this.view.docView.nearestDesc(r);if(i&&i.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r}))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 r=e.domSelectionRange(),i=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&Oc(e)&&!this.ignoreSelectionChange(r),o=-1,s=-1,l=!1,a=[];if(e.editable)for(let u=0;uf.nodeName=="BR");if(u.length==2){let[f,d]=u;f.parentNode&&f.parentNode.parentNode==d.parentNode?d.remove():f.remove()}else{let{focusNode:f}=this.currentSelection;for(let d of u){let p=d.parentNode;p&&p.nodeName=="LI"&&(!f||im(e,f)!=p)&&d.remove()}}}let c=null;o<0&&i&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)-1||i)&&(o>-1&&(e.docView.markDirty(o,s),nm(e)),this.handleDOMChange(o,s,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||Ct(e),this.currentSelection.set(r))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let r=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(r==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!r||r.ignoreMutation(e))return null;if(e.type=="childList"){for(let u=0;ui;g--){let b=r.childNodes[g-1],x=b.pmViewDesc;if(b.nodeName=="BR"&&!x){o=g;break}if(!x||x.size)break}let f=n.state.doc,d=n.someProp("domParser")||yt.fromSchema(n.state.schema),p=f.resolve(s),h=null,m=d.parse(r,{topNode:p.parent,topMatch:p.parent.contentMatchAt(p.index()),topOpen:!0,from:i,to:o,preserveWhitespace:p.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:sm,context:p});if(c&&c[0].pos!=null){let g=c[0].pos,b=c[1]&&c[1].pos;b==null&&(b=g),h={anchor:g+s,head:b+s}}return{doc:m,sel:h,from:s,to:l}}function sm(n){let e=n.pmViewDesc;if(e)return e.parseRule();if(n.nodeName=="BR"&&n.parentNode){if(Te&&/^(ul|ol)$/i.test(n.parentNode.nodeName)){let t=document.createElement("div");return t.appendChild(document.createElement("li")),{skip:t}}else if(n.parentNode.lastChild==n||Te&&/^(tr|table)$/i.test(n.parentNode.nodeName))return{ignore:!0}}else if(n.nodeName=="IMG"&&n.getAttribute("mark-placeholder"))return{ignore:!0};return null}var lm=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function am(n,e,t,r,i){let o=n.input.compositionPendingChanges||(n.composing?n.input.compositionID:0);if(n.input.compositionPendingChanges=0,e<0){let O=n.input.lastSelectionTime>Date.now()-50?n.input.lastSelectionOrigin:null,N=Bs(n,O);if(N&&!n.state.selection.eq(N)){if(Ce&&wt&&n.input.lastKeyCode===13&&Date.now()-100V(n,nn(13,"Enter"))))return;let z=n.state.tr.setSelection(N);O=="pointer"?z.setMeta("pointer",!0):O=="key"&&z.scrollIntoView(),o&&z.setMeta("composition",o),n.dispatch(z)}return}let s=n.state.doc.resolve(e),l=s.sharedDepth(t);e=s.before(l+1),t=n.state.doc.resolve(t).after(l+1);let a=n.state.selection,c=om(n,e,t),u=n.state.doc,f=u.slice(c.from,c.to),d,p;n.input.lastKeyCode===8&&Date.now()-100Date.now()-225||wt)&&i.some(O=>O.nodeType==1&&!lm.test(O.nodeName))&&(!h||h.endA>=h.endB)&&n.someProp("handleKeyDown",O=>O(n,nn(13,"Enter")))){n.input.lastIOSEnter=0;return}if(!h)if(r&&a instanceof P&&!a.empty&&a.$head.sameParent(a.$anchor)&&!n.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))h={start:a.from,endA:a.to,endB:a.to};else{if(c.sel){let O=Hc(n,n.state.doc,c.sel);if(O&&!O.eq(n.state.selection)){let N=n.state.tr.setSelection(O);o&&N.setMeta("composition",o),n.dispatch(N)}}return}n.state.selection.fromn.state.selection.from&&h.start<=n.state.selection.from+2&&n.state.selection.from>=c.from?h.start=n.state.selection.from:h.endA=n.state.selection.to-2&&n.state.selection.to<=c.to&&(h.endB+=n.state.selection.to-h.endA,h.endA=n.state.selection.to)),Ie&&zt<=11&&h.endB==h.start+1&&h.endA==h.start&&h.start>c.from&&c.doc.textBetween(h.start-c.from-1,h.start-c.from+1)==" \xA0"&&(h.start--,h.endA--,h.endB--);let m=c.doc.resolveNoCache(h.start-c.from),g=c.doc.resolveNoCache(h.endB-c.from),b=u.resolve(h.start),x=m.sameParent(g)&&m.parent.inlineContent&&b.end()>=h.endA,C;if((Vn&&n.input.lastIOSEnter>Date.now()-225&&(!x||i.some(O=>O.nodeName=="DIV"||O.nodeName=="P"))||!x&&m.posO(n,nn(13,"Enter")))){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>h.start&&um(u,h.start,h.endA,m,g)&&n.someProp("handleKeyDown",O=>O(n,nn(8,"Backspace")))){wt&&Ce&&n.domObserver.suppressSelectionUpdates();return}Ce&&h.endB==h.start&&(n.input.lastChromeDelete=Date.now()),wt&&!x&&m.start()!=g.start()&&g.parentOffset==0&&m.depth==g.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==h.endA&&(h.endB-=2,g=c.doc.resolveNoCache(h.endB-c.from),setTimeout(()=>{n.someProp("handleKeyDown",function(O){return O(n,nn(13,"Enter"))})},20));let y=h.start,M=h.endA,k,R,B;if(x){if(m.pos==g.pos)Ie&&zt<=11&&m.parentOffset==0&&(n.domObserver.suppressSelectionUpdates(),setTimeout(()=>Ct(n),20)),k=n.state.tr.delete(y,M),R=u.resolve(h.start).marksAcross(u.resolve(h.endA));else if(h.endA==h.endB&&(B=cm(m.parent.content.cut(m.parentOffset,g.parentOffset),b.parent.content.cut(b.parentOffset,h.endA-b.start()))))k=n.state.tr,B.type=="add"?k.addMark(y,M,B.mark):k.removeMark(y,M,B.mark);else if(m.parent.child(m.index()).isText&&m.index()==g.index()-(g.textOffset?0:1)){let O=m.parent.textBetween(m.parentOffset,g.parentOffset);if(n.someProp("handleTextInput",N=>N(n,y,M,O)))return;k=n.state.tr.insertText(O,y,M)}}if(k||(k=n.state.tr.replace(y,M,c.doc.slice(h.start-c.from,h.endB-c.from))),c.sel){let O=Hc(n,k.doc,c.sel);O&&!(Ce&&n.composing&&O.empty&&(h.start!=h.endB||n.input.lastChromeDeletee.content.size?null:zs(n,e.resolve(t.anchor),e.resolve(t.head))}function cm(n,e){let t=n.firstChild.marks,r=e.firstChild.marks,i=t,o=r,s,l,a;for(let u=0;uu.mark(l.addToSet(u.marks));else if(i.length==0&&o.length==1)l=o[0],s="remove",a=u=>u.mark(l.removeFromSet(u.marks));else return null;let c=[];for(let u=0;ut||gs(s,!0,!1)0&&(e||n.indexAfter(r)==n.node(r).childCount);)r--,i++,e=!1;if(t){let o=n.node(r).maybeChild(n.indexAfter(r));for(;o&&!o.isLeaf;)o=o.firstChild,i++}return i}function fm(n,e,t,r,i){let o=n.findDiffStart(e,t);if(o==null)return null;let{a:s,b:l}=n.findDiffEnd(e,t+n.size,t+e.size);if(i=="end"){let a=Math.max(0,o-Math.min(s,l));r-=s+a-o}if(s=s?o-r:0;o-=a,o&&o=l?o-r:0;o-=a,o&&o=56320&&e<=57343&&t>=55296&&t<=56319}var Di=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 As,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(_c),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=Wc(this),jc(this),this.nodeViews=Uc(this),this.docView=kc(this.state.doc,Vc(this),ms(this),this.dom,this),this.domObserver=new Ps(this,(r,i,o,s)=>am(this,r,i,o,s)),this.domObserver.start(),Lh(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&&Ns(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(_c),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let r in this._props)t[r]=this._props[r];t.state=this.state;for(let r in e)t[r]=e[r];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var r;let i=this.state,o=!1,s=!1;e.storedMarks&&this.composing&&(yu(this),s=!0),this.state=e;let l=i.plugins!=e.plugins||this._props.plugins!=t.plugins;if(l||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let p=Uc(this);pm(p,this.nodeViews)&&(this.nodeViews=p,o=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&Ns(this),this.editable=Wc(this),jc(this);let a=ms(this),c=Vc(this),u=i.plugins!=e.plugins&&!i.doc.eq(e.doc)?"reset":e.scrollToSelection>i.scrollToSelection?"to selection":"preserve",f=o||!this.docView.matchesNode(e.doc,c,a);(f||!e.selection.eq(i.selection))&&(s=!0);let d=u=="preserve"&&s&&this.dom.style.overflowAnchor==null&&Zp(this);if(s){this.domObserver.stop();let p=f&&(Ie||Ce)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&dm(i.selection,e.selection);if(f){let h=Ce?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=qh(this)),(o||!this.docView.update(e.doc,c,a,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=kc(e.doc,c,a,this.dom,this)),h&&!this.trackWrites&&(p=!0)}p||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&xh(this))?Ct(this,p):(iu(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(i),!((r=this.dragging)===null||r===void 0)&&r.node&&!i.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,i),u=="reset"?this.dom.scrollTop=0:u=="to selection"?this.scrollToSelection():d&&eh(d)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof D){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&mc(this,t.getBoundingClientRect(),e)}else mc(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 t=0;t0&&this.state.doc.nodeAt(o))==r.node&&(i=o)}this.dragging=new Oi(e.slice,e.move,i<0?void 0:D.create(this.state.doc,i))}someProp(e,t){let r=this._props&&this._props[e],i;if(r!=null&&(i=t?t(r):r))return i;for(let s=0;st.ownerDocument.getSelection()),this._root=t}return e||document}updateRoot(){this._root=null}posAtCoords(e){return sh(this,e)}coordsAtPos(e,t=1){return Qc(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,r=-1){let i=this.docView.posFromDOM(e,t,r);if(i==null)throw new RangeError("DOM position not inside the editor");return i}endOfTextblock(e,t){return fh(this,t||this.state,e)}pasteHTML(e,t){return wr(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return wr(this,e,null,!0,t||new ClipboardEvent("paste"))}destroy(){this.docView&&(Bh(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],ms(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,jp())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return Fh(this,e)}dispatch(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))}domSelectionRange(){let e=this.domSelection();return e?Te&&this.root.nodeType===11&&qp(this.dom.ownerDocument)==this.dom&&rm(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}};function Vc(n){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(n.editable),n.someProp("attributes",t=>{if(typeof t=="function"&&(t=t(n.state)),t)for(let r in t)r=="class"?e.class+=" "+t[r]:r=="style"?e.style=(e.style?e.style+";":"")+t[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(t[r]))}),e.translate||(e.translate="no"),[Pe.node(0,n.state.doc.content.size,e)]}function jc(n){if(n.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),n.cursorWrapper={dom:e,deco:Pe.widget(n.state.selection.from,e,{raw:!0,marks:n.markCursor})}}else n.cursorWrapper=null}function Wc(n){return!n.someProp("editable",e=>e(n.state)===!1)}function dm(n,e){let t=Math.min(n.$anchor.sharedDepth(n.head),e.$anchor.sharedDepth(e.head));return n.$anchor.start(t)!=e.$anchor.start(t)}function Uc(n){let e=Object.create(null);function t(r){for(let i in r)Object.prototype.hasOwnProperty.call(e,i)||(e[i]=r[i])}return n.someProp("nodeViews",t),n.someProp("markViews",t),e}function pm(n,e){let t=0,r=0;for(let i in n){if(n[i]!=e[i])return!0;t++}for(let i in e)r++;return t!=r}function _c(n){if(n.spec.state||n.spec.filterTransaction||n.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var Mt={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:"'"},Li={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},hm=typeof navigator<"u"&&/Mac/.test(navigator.platform),mm=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(se=0;se<10;se++)Mt[48+se]=Mt[96+se]=String(se);var se;for(se=1;se<=24;se++)Mt[se+111]="F"+se;var se;for(se=65;se<=90;se++)Mt[se]=String.fromCharCode(se+32),Li[se]=String.fromCharCode(se);var se;for(Pi in Mt)Li.hasOwnProperty(Pi)||(Li[Pi]=Mt[Pi]);var Pi;function wu(n){var e=hm&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||mm&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?Li:Mt)[n.keyCode]||n.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 gm=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!1;function ym(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let r,i,o,s;for(let l=0;l127)&&(o=Mt[r.keyCode])&&o!=i){let l=e[js(o,r)];if(l&&l(t.state,t.dispatch,t))return!0}}return!1}}var Bi=(n,e)=>n.selection.empty?!1:(e&&e(n.tr.deleteSelection().scrollIntoView()),!0);function Eu(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("backward",n):t.parentOffset>0)?null:t}var _s=(n,e,t)=>{let r=Eu(n,t);if(!r)return!1;let i=qs(r);if(!i){let s=r.blockRange(),l=s&&xt(s);return l==null?!1:(e&&e(n.tr.lift(s,l).scrollIntoView()),!0)}let o=i.nodeBefore;if(Lu(n,i,e,-1))return!0;if(r.parent.content.size==0&&(Wn(o,"end")||D.isSelectable(o)))for(let s=r.depth;;s--){let l=gr(n.doc,r.before(s),r.after(s),E.empty);if(l&&l.slice.size1)break}return o.isAtom&&i.depth==r.depth-1?(e&&e(n.tr.delete(i.pos-o.nodeSize,i.pos).scrollIntoView()),!0):!1},Ou=(n,e,t)=>{let r=Eu(n,t);if(!r)return!1;let i=qs(r);return i?Au(n,i,e):!1},Tu=(n,e,t)=>{let r=Nu(n,t);if(!r)return!1;let i=Ys(r);return i?Au(n,i,e):!1};function Au(n,e,t){let r=e.nodeBefore,i=r,o=e.pos-1;for(;!i.isTextblock;o--){if(i.type.spec.isolating)return!1;let u=i.lastChild;if(!u)return!1;i=u}let s=e.nodeAfter,l=s,a=e.pos+1;for(;!l.isTextblock;a++){if(l.type.spec.isolating)return!1;let u=l.firstChild;if(!u)return!1;l=u}let c=gr(n.doc,o,a,E.empty);if(!c||c.from!=o||c instanceof Se&&c.slice.size>=a-o)return!1;if(t){let u=n.tr.step(c);u.setSelection(P.create(u.doc,o)),t(u.scrollIntoView())}return!0}function Wn(n,e,t=!1){for(let r=n;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(t&&r.childCount!=1)return!1}return!1}var Ks=(n,e,t)=>{let{$head:r,empty:i}=n.selection,o=r;if(!i)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("backward",n):r.parentOffset>0)return!1;o=qs(r)}let s=o&&o.nodeBefore;return!s||!D.isSelectable(s)?!1:(e&&e(n.tr.setSelection(D.create(n.doc,o.pos-s.nodeSize)).scrollIntoView()),!0)};function qs(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){if(n.index(e)>0)return n.doc.resolve(n.before(e+1));if(n.node(e).type.spec.isolating)break}return null}function Nu(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("forward",n):t.parentOffset{let r=Nu(n,t);if(!r)return!1;let i=Ys(r);if(!i)return!1;let o=i.nodeAfter;if(Lu(n,i,e,1))return!0;if(r.parent.content.size==0&&(Wn(o,"start")||D.isSelectable(o))){let s=gr(n.doc,r.before(),r.after(),E.empty);if(s&&s.slice.size{let{$head:r,empty:i}=n.selection,o=r;if(!i)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("forward",n):r.parentOffset=0;e--){let t=n.node(e);if(n.index(e)+1{let t=n.selection,r=t instanceof D,i;if(r){if(t.node.isTextblock||!Ze(n.doc,t.from))return!1;i=t.from}else if(i=Ln(n.doc,t.from,-1),i==null)return!1;if(e){let o=n.tr.join(i);r&&o.setSelection(D.create(o.doc,i-n.doc.resolve(i).nodeBefore.nodeSize)),e(o.scrollIntoView())}return!0},Ru=(n,e)=>{let t=n.selection,r;if(t instanceof D){if(t.node.isTextblock||!Ze(n.doc,t.to))return!1;r=t.to}else if(r=Ln(n.doc,t.to,1),r==null)return!1;return e&&e(n.tr.join(r).scrollIntoView()),!0},Iu=(n,e)=>{let{$from:t,$to:r}=n.selection,i=t.blockRange(r),o=i&&xt(i);return o==null?!1:(e&&e(n.tr.lift(i,o).scrollIntoView()),!0)},Xs=(n,e)=>{let{$head:t,$anchor:r}=n.selection;return!t.parent.type.spec.code||!t.sameParent(r)?!1:(e&&e(n.tr.insertText(` +`).scrollIntoView()),!0)};function Qs(n){for(let e=0;e{let{$head:t,$anchor:r}=n.selection;if(!t.parent.type.spec.code||!t.sameParent(r))return!1;let i=t.node(-1),o=t.indexAfter(-1),s=Qs(i.contentMatchAt(o));if(!s||!i.canReplaceWith(o,o,s))return!1;if(e){let l=t.after(),a=n.tr.replaceWith(l,l,s.createAndFill());a.setSelection(I.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},el=(n,e)=>{let t=n.selection,{$from:r,$to:i}=t;if(t instanceof Oe||r.parent.inlineContent||i.parent.inlineContent)return!1;let o=Qs(i.parent.contentMatchAt(i.indexAfter()));if(!o||!o.isTextblock)return!1;if(e){let s=(!r.parentOffset&&i.index(){let{$cursor:t}=n.selection;if(!t||t.parent.content.size)return!1;if(t.depth>1&&t.after()!=t.end(-1)){let o=t.before();if(Ve(n.doc,o))return e&&e(n.tr.split(o).scrollIntoView()),!0}let r=t.blockRange(),i=r&&xt(r);return i==null?!1:(e&&e(n.tr.lift(r,i).scrollIntoView()),!0)};function vm(n){return(e,t)=>{let{$from:r,$to:i}=e.selection;if(e.selection instanceof D&&e.selection.node.isBlock)return!r.parentOffset||!Ve(e.doc,r.pos)?!1:(t&&t(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let o=[],s,l,a=!1,c=!1;for(let p=r.depth;;p--)if(r.node(p).isBlock){a=r.end(p)==r.pos+(r.depth-p),c=r.start(p)==r.pos-(r.depth-p),l=Qs(r.node(p-1).contentMatchAt(r.indexAfter(p-1)));let m=n&&n(i.parent,a,r);o.unshift(m||(a&&l?{type:l}:null)),s=p;break}else{if(p==1)return!1;o.unshift(null)}let u=e.tr;(e.selection instanceof P||e.selection instanceof Oe)&&u.deleteSelection();let f=u.mapping.map(r.pos),d=Ve(u.doc,f,o.length,o);if(d||(o[0]=l?{type:l}:null,d=Ve(u.doc,f,o.length,o)),u.split(f,o.length,o),!a&&c&&r.node(s).type!=l){let p=u.mapping.map(r.before(s)),h=u.doc.resolve(p);l&&r.node(s-1).canReplaceWith(h.index(),h.index()+1,l)&&u.setNodeMarkup(u.mapping.map(r.before(s)),l)}return t&&t(u.scrollIntoView()),!0}}var xm=vm();var Pu=(n,e)=>{let{$from:t,to:r}=n.selection,i,o=t.sharedDepth(r);return o==0?!1:(i=t.before(o),e&&e(n.tr.setSelection(D.create(n.doc,i))),!0)},km=(n,e)=>(e&&e(n.tr.setSelection(new Oe(n.doc))),!0);function Sm(n,e,t){let r=e.nodeBefore,i=e.nodeAfter,o=e.index();return!r||!i||!r.type.compatibleContent(i.type)?!1:!r.content.size&&e.parent.canReplace(o-1,o)?(t&&t(n.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(o,o+1)||!(i.isTextblock||Ze(n.doc,e.pos))?!1:(t&&t(n.tr.join(e.pos).scrollIntoView()),!0)}function Lu(n,e,t,r){let i=e.nodeBefore,o=e.nodeAfter,s,l,a=i.type.spec.isolating||o.type.spec.isolating;if(!a&&Sm(n,e,t))return!0;let c=!a&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(s=(l=i.contentMatchAt(i.childCount)).findWrapping(o.type))&&l.matchType(s[0]||o.type).validEnd){if(t){let p=e.pos+o.nodeSize,h=S.empty;for(let b=s.length-1;b>=0;b--)h=S.from(s[b].create(null,h));h=S.from(i.copy(h));let m=n.tr.step(new oe(e.pos-1,p,e.pos,p,new E(h,1,0),s.length,!0)),g=m.doc.resolve(p+2*s.length);g.nodeAfter&&g.nodeAfter.type==i.type&&Ze(m.doc,g.pos)&&m.join(g.pos),t(m.scrollIntoView())}return!0}let u=o.type.spec.isolating||r>0&&a?null:I.findFrom(e,1),f=u&&u.$from.blockRange(u.$to),d=f&&xt(f);if(d!=null&&d>=e.depth)return t&&t(n.tr.lift(f,d).scrollIntoView()),!0;if(c&&Wn(o,"start",!0)&&Wn(i,"end")){let p=i,h=[];for(;h.push(p),!p.isTextblock;)p=p.lastChild;let m=o,g=1;for(;!m.isTextblock;m=m.firstChild)g++;if(p.canReplace(p.childCount,p.childCount,m.content)){if(t){let b=S.empty;for(let C=h.length-1;C>=0;C--)b=S.from(h[C].copy(b));let x=n.tr.step(new oe(e.pos-h.length,e.pos+o.nodeSize,e.pos+g,e.pos+o.nodeSize-g,new E(b,h.length,0),0,!0));t(x.scrollIntoView())}return!0}}return!1}function Bu(n){return function(e,t){let r=e.selection,i=n<0?r.$from:r.$to,o=i.depth;for(;i.node(o).isInline;){if(!o)return!1;o--}return i.node(o).isTextblock?(t&&t(e.tr.setSelection(P.create(e.doc,n<0?i.start(o):i.end(o)))),!0):!1}}var nl=Bu(-1),rl=Bu(1);function zu(n,e=null){return function(t,r){let{$from:i,$to:o}=t.selection,s=i.blockRange(o),l=s&&Pn(s,n,e);return l?(r&&r(t.tr.wrap(s,l).scrollIntoView()),!0):!1}}function il(n,e=null){return function(t,r){let i=!1;for(let o=0;o{if(i)return!1;if(!(!a.isTextblock||a.hasMarkup(n,e)))if(a.type==n)i=!0;else{let u=t.doc.resolve(c),f=u.index();i=u.parent.canReplaceWith(f,f+1,n)}})}if(!i)return!1;if(r){let o=t.tr;for(let s=0;s=2&&e.$from.node(e.depth-1).type.compatibleContent(t)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let a=s.resolve(e.start-2);o=new Qt(a,a,e.depth),e.endIndex=0;u--)o=S.from(t[u].type.create(t[u].attrs,o));n.step(new oe(e.start-(r?2:0),e.end,e.start,e.end,new E(o,0,0),t.length,!0));let s=0;for(let u=0;us.childCount>0&&s.firstChild.type==n);return o?t?r.node(o.depth-1).type==n?Em(e,t,n,o):Om(e,t,o):!0:!1}}function Em(n,e,t,r){let i=n.tr,o=r.end,s=r.$to.end(r.depth);om;h--)p-=i.child(h).nodeSize,r.delete(p-1,p+1);let o=r.doc.resolve(t.start),s=o.nodeAfter;if(r.mapping.map(t.end)!=t.start+o.nodeAfter.nodeSize)return!1;let l=t.startIndex==0,a=t.endIndex==i.childCount,c=o.node(-1),u=o.index(-1);if(!c.canReplace(u+(l?0:1),u+1,s.content.append(a?S.empty:S.from(i))))return!1;let f=o.pos,d=f+s.nodeSize;return r.step(new oe(f-(l?1:0),d+(a?1:0),f+1,d-1,new E((l?S.empty:S.from(i.copy(S.empty))).append(a?S.empty:S.from(i.copy(S.empty))),l?0:1,a?0:1),l?0:1)),e(r.scrollIntoView()),!0}function $u(n){return function(e,t){let{$from:r,$to:i}=e.selection,o=r.blockRange(i,c=>c.childCount>0&&c.firstChild.type==n);if(!o)return!1;let s=o.startIndex;if(s==0)return!1;let l=o.parent,a=l.child(s-1);if(a.type!=n)return!1;if(t){let c=a.lastChild&&a.lastChild.type==l.type,u=S.from(c?n.create():null),f=new E(S.from(n.create(null,S.from(l.type.create(null,u)))),c?3:1,0),d=o.start,p=o.end;t(e.tr.step(new oe(d-(c?3:1),p,d,p,f,1,!0)).scrollIntoView())}return!0}}function _i(n){let{state:e,transaction:t}=n,{selection:r}=t,{doc:i}=t,{storedMarks:o}=t;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return o},get selection(){return r},get doc(){return i},get tr(){return r=t.selection,i=t.doc,o=t.storedMarks,t}}}var Un=class{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:r}=this,{view:i}=t,{tr:o}=r,s=this.buildProps(o);return Object.fromEntries(Object.entries(e).map(([l,a])=>[l,(...u)=>{let f=a(...u)(s);return!o.getMeta("preventDispatch")&&!this.hasCustomState&&i.dispatch(o),f}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(e,t=!0){let{rawCommands:r,editor:i,state:o}=this,{view:s}=i,l=[],a=!!e,c=e||o.tr,u=()=>(!a&&t&&!c.getMeta("preventDispatch")&&!this.hasCustomState&&s.dispatch(c),l.every(d=>d===!0)),f={...Object.fromEntries(Object.entries(r).map(([d,p])=>[d,(...m)=>{let g=this.buildProps(c,t),b=p(...m)(g);return l.push(b),f}])),run:u};return f}createCan(e){let{rawCommands:t,state:r}=this,i=!1,o=e||r.tr,s=this.buildProps(o,i);return{...Object.fromEntries(Object.entries(t).map(([a,c])=>[a,(...u)=>c(...u)({...s,dispatch:void 0})])),chain:()=>this.createChain(o,i)}}buildProps(e,t=!0){let{rawCommands:r,editor:i,state:o}=this,{view:s}=i,l={tr:e,editor:i,view:s,state:_i({state:o,transaction:e}),dispatch:t?()=>{}:void 0,chain:()=>this.createChain(e,t),can:()=>this.createCan(e),get commands(){return Object.fromEntries(Object.entries(r).map(([a,c])=>[a,(...u)=>c(...u)(l)]))}};return l}},cl=class{constructor(){this.callbacks={}}on(e,t){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(t),this}emit(e,...t){let r=this.callbacks[e];return r&&r.forEach(i=>i.apply(this,t)),this}off(e,t){let r=this.callbacks[e];return r&&(t?this.callbacks[e]=r.filter(i=>i!==t):delete this.callbacks[e]),this}once(e,t){let r=(...i)=>{this.off(e,r),t.apply(this,i)};return this.on(e,r)}removeAllListeners(){this.callbacks={}}};function T(n,e,t){return n.config[e]===void 0&&n.parent?T(n.parent,e,t):typeof n.config[e]=="function"?n.config[e].bind({...t,parent:n.parent?T(n.parent,e,t):null}):n.config[e]}function Ki(n){let e=n.filter(i=>i.type==="extension"),t=n.filter(i=>i.type==="node"),r=n.filter(i=>i.type==="mark");return{baseExtensions:e,nodeExtensions:t,markExtensions:r}}function Ju(n){let e=[],{nodeExtensions:t,markExtensions:r}=Ki(n),i=[...t,...r],o={default:null,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return n.forEach(s=>{let l={name:s.name,options:s.options,storage:s.storage,extensions:i},a=T(s,"addGlobalAttributes",l);if(!a)return;a().forEach(u=>{u.types.forEach(f=>{Object.entries(u.attributes).forEach(([d,p])=>{e.push({type:f,name:d,attribute:{...o,...p}})})})})}),i.forEach(s=>{let l={name:s.name,options:s.options,storage:s.storage},a=T(s,"addAttributes",l);if(!a)return;let c=a();Object.entries(c).forEach(([u,f])=>{let d={...o,...f};typeof d?.default=="function"&&(d.default=d.default()),d?.isRequired&&d?.default===void 0&&delete d.default,e.push({type:s.name,name:u,attribute:d})})}),e}function pe(n,e){if(typeof n=="string"){if(!e.nodes[n])throw Error(`There is no node type named '${n}'. Maybe you forgot to add the extension?`);return e.nodes[n]}return n}function $(...n){return n.filter(e=>!!e).reduce((e,t)=>{let r={...e};return Object.entries(t).forEach(([i,o])=>{if(!r[i]){r[i]=o;return}if(i==="class"){let l=o?String(o).split(" "):[],a=r[i]?r[i].split(" "):[],c=l.filter(u=>!a.includes(u));r[i]=[...a,...c].join(" ")}else if(i==="style"){let l=o?o.split(";").map(u=>u.trim()).filter(Boolean):[],a=r[i]?r[i].split(";").map(u=>u.trim()).filter(Boolean):[],c=new Map;a.forEach(u=>{let[f,d]=u.split(":").map(p=>p.trim());c.set(f,d)}),l.forEach(u=>{let[f,d]=u.split(":").map(p=>p.trim());c.set(f,d)}),r[i]=Array.from(c.entries()).map(([u,f])=>`${u}: ${f}`).join("; ")}else r[i]=o}),r},{})}function ul(n,e){return e.filter(t=>t.type===n.type.name).filter(t=>t.attribute.rendered).map(t=>t.attribute.renderHTML?t.attribute.renderHTML(n.attrs)||{}:{[t.name]:n.attrs[t.name]}).reduce((t,r)=>$(t,r),{})}function Gu(n){return typeof n=="function"}function F(n,e=void 0,...t){return Gu(n)?e?n.bind(e)(...t):n(...t):n}function Tm(n={}){return Object.keys(n).length===0&&n.constructor===Object}function Am(n){return typeof n!="string"?n:n.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(n):n==="true"?!0:n==="false"?!1:n}function Vu(n,e){return"style"in n?n:{...n,getAttrs:t=>{let r=n.getAttrs?n.getAttrs(t):n.attrs;if(r===!1)return!1;let i=e.reduce((o,s)=>{let l=s.attribute.parseHTML?s.attribute.parseHTML(t):Am(t.getAttribute(s.name));return l==null?o:{...o,[s.name]:l}},{});return{...r,...i}}}}function ju(n){return Object.fromEntries(Object.entries(n).filter(([e,t])=>e==="attrs"&&Tm(t)?!1:t!=null))}function Nm(n,e){var t;let r=Ju(n),{nodeExtensions:i,markExtensions:o}=Ki(n),s=(t=i.find(c=>T(c,"topNode")))===null||t===void 0?void 0:t.name,l=Object.fromEntries(i.map(c=>{let u=r.filter(b=>b.type===c.name),f={name:c.name,options:c.options,storage:c.storage,editor:e},d=n.reduce((b,x)=>{let C=T(x,"extendNodeSchema",f);return{...b,...C?C(c):{}}},{}),p=ju({...d,content:F(T(c,"content",f)),marks:F(T(c,"marks",f)),group:F(T(c,"group",f)),inline:F(T(c,"inline",f)),atom:F(T(c,"atom",f)),selectable:F(T(c,"selectable",f)),draggable:F(T(c,"draggable",f)),code:F(T(c,"code",f)),whitespace:F(T(c,"whitespace",f)),linebreakReplacement:F(T(c,"linebreakReplacement",f)),defining:F(T(c,"defining",f)),isolating:F(T(c,"isolating",f)),attrs:Object.fromEntries(u.map(b=>{var x;return[b.name,{default:(x=b?.attribute)===null||x===void 0?void 0:x.default}]}))}),h=F(T(c,"parseHTML",f));h&&(p.parseDOM=h.map(b=>Vu(b,u)));let m=T(c,"renderHTML",f);m&&(p.toDOM=b=>m({node:b,HTMLAttributes:ul(b,u)}));let g=T(c,"renderText",f);return g&&(p.toText=g),[c.name,p]})),a=Object.fromEntries(o.map(c=>{let u=r.filter(g=>g.type===c.name),f={name:c.name,options:c.options,storage:c.storage,editor:e},d=n.reduce((g,b)=>{let x=T(b,"extendMarkSchema",f);return{...g,...x?x(c):{}}},{}),p=ju({...d,inclusive:F(T(c,"inclusive",f)),excludes:F(T(c,"excludes",f)),group:F(T(c,"group",f)),spanning:F(T(c,"spanning",f)),code:F(T(c,"code",f)),attrs:Object.fromEntries(u.map(g=>{var b;return[g.name,{default:(b=g?.attribute)===null||b===void 0?void 0:b.default}]}))}),h=F(T(c,"parseHTML",f));h&&(p.parseDOM=h.map(g=>Vu(g,u)));let m=T(c,"renderHTML",f);return m&&(p.toDOM=g=>m({mark:g,HTMLAttributes:ul(g,u)})),[c.name,p]}));return new lr({topNode:s,nodes:l,marks:a})}function sl(n,e){return e.nodes[n]||e.marks[n]||null}function Wu(n,e){return Array.isArray(e)?e.some(t=>(typeof t=="string"?t:t.name)===n.name):e}function gl(n,e){let t=bt.fromSchema(e).serializeFragment(n),i=document.implementation.createHTMLDocument().createElement("div");return i.appendChild(t),i.innerHTML}var Dm=(n,e=500)=>{let t="",r=n.parentOffset;return n.parent.nodesBetween(Math.max(0,r-e),r,(i,o,s,l)=>{var a,c;let u=((c=(a=i.type.spec).toText)===null||c===void 0?void 0:c.call(a,{node:i,pos:o,parent:s,index:l}))||i.textContent||"%leaf%";t+=i.isAtom&&!i.isText?u:u.slice(0,Math.max(0,r-o))}),t};function yl(n){return Object.prototype.toString.call(n)==="[object RegExp]"}var _n=class{constructor(e){this.find=e.find,this.handler=e.handler}},Rm=(n,e)=>{if(yl(e))return e.exec(n);let t=e(n);if(!t)return null;let r=[t.text];return r.index=t.index,r.input=n,r.data=t.data,t.replaceWith&&(t.text.includes(t.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),r.push(t.replaceWith)),r};function zi(n){var e;let{editor:t,from:r,to:i,text:o,rules:s,plugin:l}=n,{view:a}=t;if(a.composing)return!1;let c=a.state.doc.resolve(r);if(c.parent.type.spec.code||!((e=c.nodeBefore||c.nodeAfter)===null||e===void 0)&&e.marks.find(d=>d.type.spec.code))return!1;let u=!1,f=Dm(c)+o;return s.forEach(d=>{if(u)return;let p=Rm(f,d.find);if(!p)return;let h=a.state.tr,m=_i({state:a.state,transaction:h}),g={from:r-(p[0].length-o.length),to:i},{commands:b,chain:x,can:C}=new Un({editor:t,state:m});d.handler({state:m,range:g,match:p,commands:b,chain:x,can:C})===null||!h.steps.length||(h.setMeta(l,{transform:h,from:r,to:i,text:o}),a.dispatch(h),u=!0)}),u}function Im(n){let{editor:e,rules:t}=n,r=new _({state:{init(){return null},apply(i,o,s){let l=i.getMeta(r);if(l)return l;let a=i.getMeta("applyInputRules");return!!a&&setTimeout(()=>{let{text:u}=a;typeof u=="string"?u=u:u=gl(S.from(u),s.schema);let{from:f}=a,d=f+u.length;zi({editor:e,from:f,to:d,text:u,rules:t,plugin:r})}),i.selectionSet||i.docChanged?null:o}},props:{handleTextInput(i,o,s,l){return zi({editor:e,from:o,to:s,text:l,rules:t,plugin:r})},handleDOMEvents:{compositionend:i=>(setTimeout(()=>{let{$cursor:o}=i.state.selection;o&&zi({editor:e,from:o.pos,to:o.pos,text:"",rules:t,plugin:r})}),!1)},handleKeyDown(i,o){if(o.key!=="Enter")return!1;let{$cursor:s}=i.state.selection;return s?zi({editor:e,from:s.pos,to:s.pos,text:` +`,rules:t,plugin:r}):!1}},isInputRules:!0});return r}function Pm(n){return Object.prototype.toString.call(n).slice(8,-1)}function Fi(n){return Pm(n)!=="Object"?!1:n.constructor===Object&&Object.getPrototypeOf(n)===Object.prototype}function qi(n,e){let t={...n};return Fi(n)&&Fi(e)&&Object.keys(e).forEach(r=>{Fi(e[r])&&Fi(n[r])?t[r]=qi(n[r],e[r]):t[r]=e[r]}),t}var De=class n{constructor(e={}){this.type="mark",this.name="mark",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=F(T(this,"addOptions",{name:this.name}))),this.storage=F(T(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new n(e)}configure(e={}){let t=this.extend({...this.config,addOptions:()=>qi(this.options,e)});return t.name=this.name,t.parent=this.parent,t}extend(e={}){let t=new n(e);return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=F(T(t,"addOptions",{name:t.name})),t.storage=F(T(t,"addStorage",{name:t.name,options:t.options})),t}static handleExit({editor:e,mark:t}){let{tr:r}=e.state,i=e.state.selection.$from;if(i.pos===i.end()){let s=i.marks();if(!!!s.find(c=>c?.type.name===t.name))return!1;let a=s.find(c=>c?.type.name===t.name);return a&&r.removeStoredMark(a),r.insertText(" ",i.pos),e.view.dispatch(r),!0}return!1}};function Lm(n){return typeof n=="number"}var fl=class{constructor(e){this.find=e.find,this.handler=e.handler}},Bm=(n,e,t)=>{if(yl(e))return[...n.matchAll(e)];let r=e(n,t);return r?r.map(i=>{let o=[i.text];return o.index=i.index,o.input=n,o.data=i.data,i.replaceWith&&(i.text.includes(i.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),o.push(i.replaceWith)),o}):[]};function zm(n){let{editor:e,state:t,from:r,to:i,rule:o,pasteEvent:s,dropEvent:l}=n,{commands:a,chain:c,can:u}=new Un({editor:e,state:t}),f=[];return t.doc.nodesBetween(r,i,(p,h)=>{if(!p.isTextblock||p.type.spec.code)return;let m=Math.max(r,h),g=Math.min(i,h+p.content.size),b=p.textBetween(m-h,g-h,void 0,"\uFFFC");Bm(b,o.find,s).forEach(C=>{if(C.index===void 0)return;let y=m+C.index+1,M=y+C[0].length,k={from:t.tr.mapping.map(y),to:t.tr.mapping.map(M)},R=o.handler({state:t,range:k,match:C,commands:a,chain:c,can:u,pasteEvent:s,dropEvent:l});f.push(R)})}),f.every(p=>p!==null)}var Hi=null,Fm=n=>{var e;let t=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=t.clipboardData)===null||e===void 0||e.setData("text/html",n),t};function Hm(n){let{editor:e,rules:t}=n,r=null,i=!1,o=!1,s=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,l;try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}let a=({state:u,from:f,to:d,rule:p,pasteEvt:h})=>{let m=u.tr,g=_i({state:u,transaction:m});if(!(!zm({editor:e,state:g,from:Math.max(f-1,0),to:d.b-1,rule:p,pasteEvent:h,dropEvent:l})||!m.steps.length)){try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}return s=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,m}};return t.map(u=>new _({view(f){let d=h=>{var m;r=!((m=f.dom.parentElement)===null||m===void 0)&&m.contains(h.target)?f.dom.parentElement:null,r&&(Hi=e)},p=()=>{Hi&&(Hi=null)};return window.addEventListener("dragstart",d),window.addEventListener("dragend",p),{destroy(){window.removeEventListener("dragstart",d),window.removeEventListener("dragend",p)}}},props:{handleDOMEvents:{drop:(f,d)=>{if(o=r===f.dom.parentElement,l=d,!o){let p=Hi;p&&setTimeout(()=>{let h=p.state.selection;h&&p.commands.deleteRange({from:h.from,to:h.to})},10)}return!1},paste:(f,d)=>{var p;let h=(p=d.clipboardData)===null||p===void 0?void 0:p.getData("text/html");return s=d,i=!!h?.includes("data-pm-slice"),!1}}},appendTransaction:(f,d,p)=>{let h=f[0],m=h.getMeta("uiEvent")==="paste"&&!i,g=h.getMeta("uiEvent")==="drop"&&!o,b=h.getMeta("applyPasteRules"),x=!!b;if(!m&&!g&&!x)return;if(x){let{text:M}=b;typeof M=="string"?M=M:M=gl(S.from(M),p.schema);let{from:k}=b,R=k+M.length,B=Fm(M);return a({rule:u,state:p,from:k,to:{b:R},pasteEvt:B})}let C=d.doc.content.findDiffStart(p.doc.content),y=d.doc.content.findDiffEnd(p.doc.content);if(!(!Lm(C)||!y||C===y.b))return a({rule:u,state:p,from:C,to:y,pasteEvt:s})}}))}function $m(n){let e=n.filter((t,r)=>n.indexOf(t)!==r);return Array.from(new Set(e))}var dl=class n{constructor(e,t){this.splittableMarks=[],this.editor=t,this.extensions=n.resolve(e),this.schema=Nm(this.extensions,t),this.setupExtensions()}static resolve(e){let t=n.sort(n.flatten(e)),r=$m(t.map(i=>i.name));return r.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${r.map(i=>`'${i}'`).join(", ")}]. This can lead to issues.`),t}static flatten(e){return e.map(t=>{let r={name:t.name,options:t.options,storage:t.storage},i=T(t,"addExtensions",r);return i?[t,...this.flatten(i())]:t}).flat(10)}static sort(e){return e.sort((r,i)=>{let o=T(r,"priority")||100,s=T(i,"priority")||100;return o>s?-1:o{let r={name:t.name,options:t.options,storage:t.storage,editor:this.editor,type:sl(t.name,this.schema)},i=T(t,"addCommands",r);return i?{...e,...i()}:e},{})}get plugins(){let{editor:e}=this,t=n.sort([...this.extensions].reverse()),r=[],i=[],o=t.map(s=>{let l={name:s.name,options:s.options,storage:s.storage,editor:e,type:sl(s.name,this.schema)},a=[],c=T(s,"addKeyboardShortcuts",l),u={};if(s.type==="mark"&&T(s,"exitable",l)&&(u.ArrowRight=()=>De.handleExit({editor:e,mark:s})),c){let m=Object.fromEntries(Object.entries(c()).map(([g,b])=>[g,()=>b({editor:e})]));u={...u,...m}}let f=Cu(u);a.push(f);let d=T(s,"addInputRules",l);Wu(s,e.options.enableInputRules)&&d&&r.push(...d());let p=T(s,"addPasteRules",l);Wu(s,e.options.enablePasteRules)&&p&&i.push(...p());let h=T(s,"addProseMirrorPlugins",l);if(h){let m=h();a.push(...m)}return a}).flat();return[Im({editor:e,rules:r}),...Hm({editor:e,rules:i}),...o]}get attributes(){return Ju(this.extensions)}get nodeViews(){let{editor:e}=this,{nodeExtensions:t}=Ki(this.extensions);return Object.fromEntries(t.filter(r=>!!T(r,"addNodeView")).map(r=>{let i=this.attributes.filter(a=>a.type===r.name),o={name:r.name,options:r.options,storage:r.storage,editor:e,type:pe(r.name,this.schema)},s=T(r,"addNodeView",o);if(!s)return[];let l=(a,c,u,f,d)=>{let p=ul(a,i);return s()({node:a,view:c,getPos:u,decorations:f,innerDecorations:d,editor:e,extension:r,HTMLAttributes:p})};return[r.name,l]}))}setupExtensions(){this.extensions.forEach(e=>{var t;this.editor.extensionStorage[e.name]=e.storage;let r={name:e.name,options:e.options,storage:e.storage,editor:this.editor,type:sl(e.name,this.schema)};e.type==="mark"&&(!((t=F(T(e,"keepOnSplit",r)))!==null&&t!==void 0)||t)&&this.splittableMarks.push(e.name);let i=T(e,"onBeforeCreate",r),o=T(e,"onCreate",r),s=T(e,"onUpdate",r),l=T(e,"onSelectionUpdate",r),a=T(e,"onTransaction",r),c=T(e,"onFocus",r),u=T(e,"onBlur",r),f=T(e,"onDestroy",r);i&&this.editor.on("beforeCreate",i),o&&this.editor.on("create",o),s&&this.editor.on("update",s),l&&this.editor.on("selectionUpdate",l),a&&this.editor.on("transaction",a),c&&this.editor.on("focus",c),u&&this.editor.on("blur",u),f&&this.editor.on("destroy",f)})}},le=class n{constructor(e={}){this.type="extension",this.name="extension",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=F(T(this,"addOptions",{name:this.name}))),this.storage=F(T(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new n(e)}configure(e={}){let t=this.extend({...this.config,addOptions:()=>qi(this.options,e)});return t.name=this.name,t.parent=this.parent,t}extend(e={}){let t=new n({...this.config,...e});return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=F(T(t,"addOptions",{name:t.name})),t.storage=F(T(t,"addStorage",{name:t.name,options:t.options})),t}};function Yu(n,e,t){let{from:r,to:i}=e,{blockSeparator:o=` + +`,textSerializers:s={}}=t||{},l="";return n.nodesBetween(r,i,(a,c,u,f)=>{var d;a.isBlock&&c>r&&(l+=o);let p=s?.[a.type.name];if(p)return u&&(l+=p({node:a,pos:c,parent:u,index:f,range:e})),!1;a.isText&&(l+=(d=a?.text)===null||d===void 0?void 0:d.slice(Math.max(r,c)-c,i-c))}),l}function Xu(n){return Object.fromEntries(Object.entries(n.nodes).filter(([,e])=>e.spec.toText).map(([e,t])=>[e,t.spec.toText]))}var Vm=le.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new _({key:new G("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{let{editor:n}=this,{state:e,schema:t}=n,{doc:r,selection:i}=e,{ranges:o}=i,s=Math.min(...o.map(u=>u.$from.pos)),l=Math.max(...o.map(u=>u.$to.pos)),a=Xu(t);return Yu(r,{from:s,to:l},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:a})}}})]}}),jm=()=>({editor:n,view:e})=>(requestAnimationFrame(()=>{var t;n.isDestroyed||(e.dom.blur(),(t=window?.getSelection())===null||t===void 0||t.removeAllRanges())}),!0),Wm=(n=!1)=>({commands:e})=>e.setContent("",n),Um=()=>({state:n,tr:e,dispatch:t})=>{let{selection:r}=e,{ranges:i}=r;return t&&i.forEach(({$from:o,$to:s})=>{n.doc.nodesBetween(o.pos,s.pos,(l,a)=>{if(l.type.isText)return;let{doc:c,mapping:u}=e,f=c.resolve(u.map(a)),d=c.resolve(u.map(a+l.nodeSize)),p=f.blockRange(d);if(!p)return;let h=xt(p);if(l.type.isTextblock){let{defaultType:m}=f.parent.contentMatchAt(f.index());e.setNodeMarkup(p.start,m)}(h||h===0)&&e.lift(p,h)})}),!0},_m=n=>e=>n(e),Km=()=>({state:n,dispatch:e})=>el(n,e),qm=(n,e)=>({editor:t,tr:r})=>{let{state:i}=t,o=i.doc.slice(n.from,n.to);r.deleteRange(n.from,n.to);let s=r.mapping.map(e);return r.insert(s,o.content),r.setSelection(new P(r.doc.resolve(s-1))),!0},Jm=()=>({tr:n,dispatch:e})=>{let{selection:t}=n,r=t.$anchor.node();if(r.content.size>0)return!1;let i=n.selection.$anchor;for(let o=i.depth;o>0;o-=1)if(i.node(o).type===r.type){if(e){let l=i.before(o),a=i.after(o);n.delete(l,a).scrollIntoView()}return!0}return!1},Gm=n=>({tr:e,state:t,dispatch:r})=>{let i=pe(n,t.schema),o=e.selection.$anchor;for(let s=o.depth;s>0;s-=1)if(o.node(s).type===i){if(r){let a=o.before(s),c=o.after(s);e.delete(a,c).scrollIntoView()}return!0}return!1},Ym=n=>({tr:e,dispatch:t})=>{let{from:r,to:i}=n;return t&&e.delete(r,i),!0},Xm=()=>({state:n,dispatch:e})=>Bi(n,e),Qm=()=>({commands:n})=>n.keyboardShortcut("Enter"),Zm=()=>({state:n,dispatch:e})=>Zs(n,e);function ji(n,e,t={strict:!0}){let r=Object.keys(e);return r.length?r.every(i=>t.strict?e[i]===n[i]:yl(e[i])?e[i].test(n[i]):e[i]===n[i]):!0}function Qu(n,e,t={}){return n.find(r=>r.type===e&&ji(Object.fromEntries(Object.keys(t).map(i=>[i,r.attrs[i]])),t))}function Uu(n,e,t={}){return!!Qu(n,e,t)}function bl(n,e,t){var r;if(!n||!e)return;let i=n.parent.childAfter(n.parentOffset);if((!i.node||!i.node.marks.some(u=>u.type===e))&&(i=n.parent.childBefore(n.parentOffset)),!i.node||!i.node.marks.some(u=>u.type===e)||(t=t||((r=i.node.marks[0])===null||r===void 0?void 0:r.attrs),!Qu([...i.node.marks],e,t)))return;let s=i.index,l=n.start()+i.offset,a=s+1,c=l+i.node.nodeSize;for(;s>0&&Uu([...n.parent.child(s-1).marks],e,t);)s-=1,l-=n.parent.child(s).nodeSize;for(;a({tr:t,state:r,dispatch:i})=>{let o=Vt(n,r.schema),{doc:s,selection:l}=t,{$from:a,from:c,to:u}=l;if(i){let f=bl(a,o,e);if(f&&f.from<=c&&f.to>=u){let d=P.create(s,f.from,f.to);t.setSelection(d)}}return!0},tg=n=>e=>{let t=typeof n=="function"?n(e):n;for(let r=0;r({editor:t,view:r,tr:i,dispatch:o})=>{e={scrollIntoView:!0,...e};let s=()=>{r.dom.focus(),requestAnimationFrame(()=>{t.isDestroyed||(r.focus(),e?.scrollIntoView&&t.commands.scrollIntoView())})};if(r.hasFocus()&&n===null||n===!1)return!0;if(o&&n===null&&!Zu(t.state.selection))return s(),!0;let l=ef(i.doc,n)||t.state.selection,a=t.state.selection.eq(l);return o&&(a||i.setSelection(l),a&&i.storedMarks&&i.setStoredMarks(i.storedMarks),s()),!0},rg=(n,e)=>t=>n.every((r,i)=>e(r,{...t,index:i})),ig=(n,e)=>({tr:t,commands:r})=>r.insertContentAt({from:t.selection.from,to:t.selection.to},n,e),tf=n=>{let e=n.childNodes;for(let t=e.length-1;t>=0;t-=1){let r=e[t];r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?n.removeChild(r):r.nodeType===1&&tf(r)}return n};function $i(n){let e=`${n}`,t=new window.DOMParser().parseFromString(e,"text/html").body;return tf(t)}function Wi(n,e,t){if(n instanceof $e||n instanceof S)return n;t={slice:!0,parseOptions:{},...t};let r=typeof n=="object"&&n!==null,i=typeof n=="string";if(r)try{if(Array.isArray(n)&&n.length>0)return S.fromArray(n.map(l=>e.nodeFromJSON(l)));let s=e.nodeFromJSON(n);return t.errorOnInvalidContent&&s.check(),s}catch(o){if(t.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:o});return console.warn("[tiptap warn]: Invalid content.","Passed value:",n,"Error:",o),Wi("",e,t)}if(i){if(t.errorOnInvalidContent){let s=!1,l="",a=new lr({topNode:e.spec.topNode,marks:e.spec.marks,nodes:e.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:c=>(s=!0,l=typeof c=="string"?c:c.outerHTML,null)}]}})});if(t.slice?yt.fromSchema(a).parseSlice($i(n),t.parseOptions):yt.fromSchema(a).parse($i(n),t.parseOptions),t.errorOnInvalidContent&&s)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${l}`)})}let o=yt.fromSchema(e);return t.slice?o.parseSlice($i(n),t.parseOptions).content:o.parse($i(n),t.parseOptions)}return Wi("",e,t)}function og(n,e,t){let r=n.steps.length-1;if(r{s===0&&(s=u)}),n.setSelection(I.near(n.doc.resolve(s),t))}var sg=n=>!("type"in n),lg=(n,e,t)=>({tr:r,dispatch:i,editor:o})=>{var s;if(i){t={parseOptions:o.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...t};let l;try{l=Wi(e,o.schema,{parseOptions:{preserveWhitespace:"full",...t.parseOptions},errorOnInvalidContent:(s=t.errorOnInvalidContent)!==null&&s!==void 0?s:o.options.enableContentCheck})}catch(h){return o.emit("contentError",{editor:o,error:h,disableCollaboration:()=>{o.storage.collaboration&&(o.storage.collaboration.isDisabled=!0)}}),!1}let{from:a,to:c}=typeof n=="number"?{from:n,to:n}:{from:n.from,to:n.to},u=!0,f=!0;if((sg(l)?l:[l]).forEach(h=>{h.check(),u=u?h.isText&&h.marks.length===0:!1,f=f?h.isBlock:!1}),a===c&&f){let{parent:h}=r.doc.resolve(a);h.isTextblock&&!h.type.spec.code&&!h.childCount&&(a-=1,c+=1)}let p;if(u){if(Array.isArray(e))p=e.map(h=>h.text||"").join("");else if(e instanceof S){let h="";e.forEach(m=>{m.text&&(h+=m.text)}),p=h}else typeof e=="object"&&e&&e.text?p=e.text:p=e;r.insertText(p,a,c)}else p=l,r.replaceWith(a,c,p);t.updateSelection&&og(r,r.steps.length-1,-1),t.applyInputRules&&r.setMeta("applyInputRules",{from:a,text:p}),t.applyPasteRules&&r.setMeta("applyPasteRules",{from:a,text:p})}return!0},ag=()=>({state:n,dispatch:e})=>Du(n,e),cg=()=>({state:n,dispatch:e})=>Ru(n,e),ug=()=>({state:n,dispatch:e})=>_s(n,e),fg=()=>({state:n,dispatch:e})=>Js(n,e),dg=()=>({state:n,dispatch:e,tr:t})=>{try{let r=Ln(n.doc,n.selection.$from.pos,-1);return r==null?!1:(t.join(r,2),e&&e(t),!0)}catch{return!1}},pg=()=>({state:n,dispatch:e,tr:t})=>{try{let r=Ln(n.doc,n.selection.$from.pos,1);return r==null?!1:(t.join(r,2),e&&e(t),!0)}catch{return!1}},hg=()=>({state:n,dispatch:e})=>Ou(n,e),mg=()=>({state:n,dispatch:e})=>Tu(n,e);function nf(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}function rf(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function gg(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t==="Space"&&(t=" ");let r,i,o,s;for(let l=0;l({editor:e,view:t,tr:r,dispatch:i})=>{let o=gg(n).split(/-(?!$)/),s=o.find(c=>!["Alt","Ctrl","Meta","Shift"].includes(c)),l=new KeyboardEvent("keydown",{key:s==="Space"?" ":s,altKey:o.includes("Alt"),ctrlKey:o.includes("Ctrl"),metaKey:o.includes("Meta"),shiftKey:o.includes("Shift"),bubbles:!0,cancelable:!0}),a=e.captureTransaction(()=>{t.someProp("handleKeyDown",c=>c(t,l))});return a?.steps.forEach(c=>{let u=c.map(r.mapping);u&&i&&r.maybeStep(u)}),!0};function Or(n,e,t={}){let{from:r,to:i,empty:o}=n.selection,s=e?pe(e,n.schema):null,l=[];n.doc.nodesBetween(r,i,(f,d)=>{if(f.isText)return;let p=Math.max(r,d),h=Math.min(i,d+f.nodeSize);l.push({node:f,from:p,to:h})});let a=i-r,c=l.filter(f=>s?s.name===f.node.type.name:!0).filter(f=>ji(f.node.attrs,t,{strict:!1}));return o?!!c.length:c.reduce((f,d)=>f+d.to-d.from,0)>=a}var bg=(n,e={})=>({state:t,dispatch:r})=>{let i=pe(n,t.schema);return Or(t,i,e)?Iu(t,r):!1},vg=()=>({state:n,dispatch:e})=>tl(n,e),xg=n=>({state:e,dispatch:t})=>{let r=pe(n,e.schema);return Hu(r)(e,t)},kg=()=>({state:n,dispatch:e})=>Xs(n,e);function Ji(n,e){return e.nodes[n]?"node":e.marks[n]?"mark":null}function _u(n,e){let t=typeof e=="string"?[e]:e;return Object.keys(n).reduce((r,i)=>(t.includes(i)||(r[i]=n[i]),r),{})}var Sg=(n,e)=>({tr:t,state:r,dispatch:i})=>{let o=null,s=null,l=Ji(typeof n=="string"?n:n.name,r.schema);return l?(l==="node"&&(o=pe(n,r.schema)),l==="mark"&&(s=Vt(n,r.schema)),i&&t.selection.ranges.forEach(a=>{r.doc.nodesBetween(a.$from.pos,a.$to.pos,(c,u)=>{o&&o===c.type&&t.setNodeMarkup(u,void 0,_u(c.attrs,e)),s&&c.marks.length&&c.marks.forEach(f=>{s===f.type&&t.addMark(u,u+c.nodeSize,s.create(_u(f.attrs,e)))})})}),!0):!1},wg=()=>({tr:n,dispatch:e})=>(e&&n.scrollIntoView(),!0),Cg=()=>({tr:n,dispatch:e})=>{if(e){let t=new Oe(n.doc);n.setSelection(t)}return!0},Mg=()=>({state:n,dispatch:e})=>Ks(n,e),Eg=()=>({state:n,dispatch:e})=>Gs(n,e),Og=()=>({state:n,dispatch:e})=>Pu(n,e),Tg=()=>({state:n,dispatch:e})=>rl(n,e),Ag=()=>({state:n,dispatch:e})=>nl(n,e);function pl(n,e,t={},r={}){return Wi(n,e,{slice:!1,parseOptions:t,errorOnInvalidContent:r.errorOnInvalidContent})}var Ng=(n,e=!1,t={},r={})=>({editor:i,tr:o,dispatch:s,commands:l})=>{var a,c;let{doc:u}=o;if(t.preserveWhitespace!=="full"){let f=pl(n,i.schema,t,{errorOnInvalidContent:(a=r.errorOnInvalidContent)!==null&&a!==void 0?a:i.options.enableContentCheck});return s&&o.replaceWith(0,u.content.size,f).setMeta("preventUpdate",!e),!0}return s&&o.setMeta("preventUpdate",!e),l.insertContentAt({from:0,to:u.content.size},n,{parseOptions:t,errorOnInvalidContent:(c=r.errorOnInvalidContent)!==null&&c!==void 0?c:i.options.enableContentCheck})};function of(n,e){let t=Vt(e,n.schema),{from:r,to:i,empty:o}=n.selection,s=[];o?(n.storedMarks&&s.push(...n.storedMarks),s.push(...n.selection.$head.marks())):n.doc.nodesBetween(r,i,a=>{s.push(...a.marks)});let l=s.find(a=>a.type.name===t.name);return l?{...l.attrs}:{}}function sf(n,e){let t=new In(n);return e.forEach(r=>{r.steps.forEach(i=>{t.step(i)})}),t}function Dg(n){for(let e=0;e{t(i)&&r.push({node:i,pos:o})}),r}function Rg(n,e){for(let t=n.depth;t>0;t-=1){let r=n.node(t);if(e(r))return{pos:t>0?n.before(t):0,start:n.start(t),depth:t,node:r}}}function vl(n){return e=>Rg(e.$from,n)}function Ig(n,e){let t={from:0,to:n.content.size};return Yu(n,t,e)}function Pg(n,e){let t=pe(e,n.schema),{from:r,to:i}=n.selection,o=[];n.doc.nodesBetween(r,i,l=>{o.push(l)});let s=o.reverse().find(l=>l.type.name===t.name);return s?{...s.attrs}:{}}function xl(n,e){let t=Ji(typeof e=="string"?e:e.name,n.schema);return t==="node"?Pg(n,e):t==="mark"?of(n,e):{}}function Lg(n,e=JSON.stringify){let t={};return n.filter(r=>{let i=e(r);return Object.prototype.hasOwnProperty.call(t,i)?!1:t[i]=!0})}function Bg(n){let e=Lg(n);return e.length===1?e:e.filter((t,r)=>!e.filter((o,s)=>s!==r).some(o=>t.oldRange.from>=o.oldRange.from&&t.oldRange.to<=o.oldRange.to&&t.newRange.from>=o.newRange.from&&t.newRange.to<=o.newRange.to))}function af(n){let{mapping:e,steps:t}=n,r=[];return e.maps.forEach((i,o)=>{let s=[];if(i.ranges.length)i.forEach((l,a)=>{s.push({from:l,to:a})});else{let{from:l,to:a}=t[o];if(l===void 0||a===void 0)return;s.push({from:l,to:a})}s.forEach(({from:l,to:a})=>{let c=e.slice(o).map(l,-1),u=e.slice(o).map(a),f=e.invert().map(c,-1),d=e.invert().map(u);r.push({oldRange:{from:f,to:d},newRange:{from:c,to:u}})})}),Bg(r)}function Gi(n,e,t){let r=[];return n===e?t.resolve(n).marks().forEach(i=>{let o=t.resolve(n),s=bl(o,i.type);s&&r.push({mark:i,...s})}):t.nodesBetween(n,e,(i,o)=>{!i||i?.nodeSize===void 0||r.push(...i.marks.map(s=>({from:o,to:o+i.nodeSize,mark:s})))}),r}function Vi(n,e,t){return Object.fromEntries(Object.entries(t).filter(([r])=>{let i=n.find(o=>o.type===e&&o.name===r);return i?i.attribute.keepOnSplit:!1}))}function hl(n,e,t={}){let{empty:r,ranges:i}=n.selection,o=e?Vt(e,n.schema):null;if(r)return!!(n.storedMarks||n.selection.$from.marks()).filter(f=>o?o.name===f.type.name:!0).find(f=>ji(f.attrs,t,{strict:!1}));let s=0,l=[];if(i.forEach(({$from:f,$to:d})=>{let p=f.pos,h=d.pos;n.doc.nodesBetween(p,h,(m,g)=>{if(!m.isText&&!m.marks.length)return;let b=Math.max(p,g),x=Math.min(h,g+m.nodeSize),C=x-b;s+=C,l.push(...m.marks.map(y=>({mark:y,from:b,to:x})))})}),s===0)return!1;let a=l.filter(f=>o?o.name===f.mark.type.name:!0).filter(f=>ji(f.mark.attrs,t,{strict:!1})).reduce((f,d)=>f+d.to-d.from,0),c=l.filter(f=>o?f.mark.type!==o&&f.mark.type.excludes(o):!0).reduce((f,d)=>f+d.to-d.from,0);return(a>0?a+c:a)>=s}function zg(n,e,t={}){if(!e)return Or(n,null,t)||hl(n,null,t);let r=Ji(e,n.schema);return r==="node"?Or(n,e,t):r==="mark"?hl(n,e,t):!1}function Ku(n,e){let{nodeExtensions:t}=Ki(e),r=t.find(s=>s.name===n);if(!r)return!1;let i={name:r.name,options:r.options,storage:r.storage},o=F(T(r,"group",i));return typeof o!="string"?!1:o.split(" ").includes("list")}function Tr(n,{checkChildren:e=!0,ignoreWhitespace:t=!1}={}){var r;if(t){if(n.type.name==="hardBreak")return!0;if(n.isText)return/^\s*$/m.test((r=n.text)!==null&&r!==void 0?r:"")}if(n.isText)return!n.text;if(n.isAtom||n.isLeaf)return!1;if(n.content.childCount===0)return!0;if(e){let i=!0;return n.content.forEach(o=>{i!==!1&&(Tr(o,{ignoreWhitespace:t,checkChildren:e})||(i=!1))}),i}return!1}function cf(n){return n instanceof D}function Fg(n,e,t){var r;let{selection:i}=e,o=null;if(Zu(i)&&(o=i.$cursor),o){let l=(r=n.storedMarks)!==null&&r!==void 0?r:o.marks();return!!t.isInSet(l)||!l.some(a=>a.type.excludes(t))}let{ranges:s}=i;return s.some(({$from:l,$to:a})=>{let c=l.depth===0?n.doc.inlineContent&&n.doc.type.allowsMarkType(t):!1;return n.doc.nodesBetween(l.pos,a.pos,(u,f,d)=>{if(c)return!1;if(u.isInline){let p=!d||d.type.allowsMarkType(t),h=!!t.isInSet(u.marks)||!u.marks.some(m=>m.type.excludes(t));c=p&&h}return!c}),c})}var Hg=(n,e={})=>({tr:t,state:r,dispatch:i})=>{let{selection:o}=t,{empty:s,ranges:l}=o,a=Vt(n,r.schema);if(i)if(s){let c=of(r,a);t.addStoredMark(a.create({...c,...e}))}else l.forEach(c=>{let u=c.$from.pos,f=c.$to.pos;r.doc.nodesBetween(u,f,(d,p)=>{let h=Math.max(p,u),m=Math.min(p+d.nodeSize,f);d.marks.find(b=>b.type===a)?d.marks.forEach(b=>{a===b.type&&t.addMark(h,m,a.create({...b.attrs,...e}))}):t.addMark(h,m,a.create(e))})});return Fg(r,t,a)},$g=(n,e)=>({tr:t})=>(t.setMeta(n,e),!0),Vg=(n,e={})=>({state:t,dispatch:r,chain:i})=>{let o=pe(n,t.schema),s;return t.selection.$anchor.sameParent(t.selection.$head)&&(s=t.selection.$anchor.parent.attrs),o.isTextblock?i().command(({commands:l})=>il(o,{...s,...e})(t)?!0:l.clearNodes()).command(({state:l})=>il(o,{...s,...e})(l,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},jg=n=>({tr:e,dispatch:t})=>{if(t){let{doc:r}=e,i=fn(n,0,r.content.size),o=D.create(r,i);e.setSelection(o)}return!0},Wg=n=>({tr:e,dispatch:t})=>{if(t){let{doc:r}=e,{from:i,to:o}=typeof n=="number"?{from:n,to:n}:n,s=P.atStart(r).from,l=P.atEnd(r).to,a=fn(i,s,l),c=fn(o,s,l),u=P.create(r,a,c);e.setSelection(u)}return!0},Ug=n=>({state:e,dispatch:t})=>{let r=pe(n,e.schema);return $u(r)(e,t)};function qu(n,e){let t=n.storedMarks||n.selection.$to.parentOffset&&n.selection.$from.marks();if(t){let r=t.filter(i=>e?.includes(i.type.name));n.tr.ensureMarks(r)}}var _g=({keepMarks:n=!0}={})=>({tr:e,state:t,dispatch:r,editor:i})=>{let{selection:o,doc:s}=e,{$from:l,$to:a}=o,c=i.extensionManager.attributes,u=Vi(c,l.node().type.name,l.node().attrs);if(o instanceof D&&o.node.isBlock)return!l.parentOffset||!Ve(s,l.pos)?!1:(r&&(n&&qu(t,i.extensionManager.splittableMarks),e.split(l.pos).scrollIntoView()),!0);if(!l.parent.isBlock)return!1;let f=a.parentOffset===a.parent.content.size,d=l.depth===0?void 0:Dg(l.node(-1).contentMatchAt(l.indexAfter(-1))),p=f&&d?[{type:d,attrs:u}]:void 0,h=Ve(e.doc,e.mapping.map(l.pos),1,p);if(!p&&!h&&Ve(e.doc,e.mapping.map(l.pos),1,d?[{type:d}]:void 0)&&(h=!0,p=d?[{type:d,attrs:u}]:void 0),r){if(h&&(o instanceof P&&e.deleteSelection(),e.split(e.mapping.map(l.pos),1,p),d&&!f&&!l.parentOffset&&l.parent.type!==d)){let m=e.mapping.map(l.before()),g=e.doc.resolve(m);l.node(-1).canReplaceWith(g.index(),g.index()+1,d)&&e.setNodeMarkup(e.mapping.map(l.before()),d)}n&&qu(t,i.extensionManager.splittableMarks),e.scrollIntoView()}return h},Kg=(n,e={})=>({tr:t,state:r,dispatch:i,editor:o})=>{var s;let l=pe(n,r.schema),{$from:a,$to:c}=r.selection,u=r.selection.node;if(u&&u.isBlock||a.depth<2||!a.sameParent(c))return!1;let f=a.node(-1);if(f.type!==l)return!1;let d=o.extensionManager.attributes;if(a.parent.content.size===0&&a.node(-1).childCount===a.indexAfter(-1)){if(a.depth===2||a.node(-3).type!==l||a.index(-2)!==a.node(-2).childCount-1)return!1;if(i){let b=S.empty,x=a.index(-1)?1:a.index(-2)?2:3;for(let B=a.depth-x;B>=a.depth-3;B-=1)b=S.from(a.node(B).copy(b));let C=a.indexAfter(-1){if(R>-1)return!1;B.isTextblock&&B.content.size===0&&(R=O+1)}),R>-1&&t.setSelection(P.near(t.doc.resolve(R))),t.scrollIntoView()}return!0}let p=c.pos===a.end()?f.contentMatchAt(0).defaultType:null,h={...Vi(d,f.type.name,f.attrs),...e},m={...Vi(d,a.node().type.name,a.node().attrs),...e};t.delete(a.pos,c.pos);let g=p?[{type:l,attrs:h},{type:p,attrs:m}]:[{type:l,attrs:h}];if(!Ve(t.doc,a.pos,2))return!1;if(i){let{selection:b,storedMarks:x}=r,{splittableMarks:C}=o.extensionManager,y=x||b.$to.parentOffset&&b.$from.marks();if(t.split(a.pos,2,g).scrollIntoView(),!y||!i)return!0;let M=y.filter(k=>C.includes(k.type.name));t.ensureMarks(M)}return!0},ll=(n,e)=>{let t=vl(s=>s.type===e)(n.selection);if(!t)return!0;let r=n.doc.resolve(Math.max(0,t.pos-1)).before(t.depth);if(r===void 0)return!0;let i=n.doc.nodeAt(r);return t.node.type===i?.type&&Ze(n.doc,t.pos)&&n.join(t.pos),!0},al=(n,e)=>{let t=vl(s=>s.type===e)(n.selection);if(!t)return!0;let r=n.doc.resolve(t.start).after(t.depth);if(r===void 0)return!0;let i=n.doc.nodeAt(r);return t.node.type===i?.type&&Ze(n.doc,r)&&n.join(r),!0},qg=(n,e,t,r={})=>({editor:i,tr:o,state:s,dispatch:l,chain:a,commands:c,can:u})=>{let{extensions:f,splittableMarks:d}=i.extensionManager,p=pe(n,s.schema),h=pe(e,s.schema),{selection:m,storedMarks:g}=s,{$from:b,$to:x}=m,C=b.blockRange(x),y=g||m.$to.parentOffset&&m.$from.marks();if(!C)return!1;let M=vl(k=>Ku(k.type.name,f))(m);if(C.depth>=1&&M&&C.depth-M.depth<=1){if(M.node.type===p)return c.liftListItem(h);if(Ku(M.node.type.name,f)&&p.validContent(M.node.content)&&l)return a().command(()=>(o.setNodeMarkup(M.pos,p),!0)).command(()=>ll(o,p)).command(()=>al(o,p)).run()}return!t||!y||!l?a().command(()=>u().wrapInList(p,r)?!0:c.clearNodes()).wrapInList(p,r).command(()=>ll(o,p)).command(()=>al(o,p)).run():a().command(()=>{let k=u().wrapInList(p,r),R=y.filter(B=>d.includes(B.type.name));return o.ensureMarks(R),k?!0:c.clearNodes()}).wrapInList(p,r).command(()=>ll(o,p)).command(()=>al(o,p)).run()},Jg=(n,e={},t={})=>({state:r,commands:i})=>{let{extendEmptyMarkRange:o=!1}=t,s=Vt(n,r.schema);return hl(r,s,e)?i.unsetMark(s,{extendEmptyMarkRange:o}):i.setMark(s,e)},Gg=(n,e,t={})=>({state:r,commands:i})=>{let o=pe(n,r.schema),s=pe(e,r.schema),l=Or(r,o,t),a;return r.selection.$anchor.sameParent(r.selection.$head)&&(a=r.selection.$anchor.parent.attrs),l?i.setNode(s,a):i.setNode(o,{...a,...t})},Yg=(n,e={})=>({state:t,commands:r})=>{let i=pe(n,t.schema);return Or(t,i,e)?r.lift(i):r.wrapIn(i,e)},Xg=()=>({state:n,dispatch:e})=>{let t=n.plugins;for(let r=0;r=0;a-=1)s.step(l.steps[a].invert(l.docs[a]));if(o.text){let a=s.doc.resolve(o.from).marks();s.replaceWith(o.from,o.to,n.schema.text(o.text,a))}else s.delete(o.from,o.to)}return!0}}return!1},Qg=()=>({tr:n,dispatch:e})=>{let{selection:t}=n,{empty:r,ranges:i}=t;return r||e&&i.forEach(o=>{n.removeMark(o.$from.pos,o.$to.pos)}),!0},Zg=(n,e={})=>({tr:t,state:r,dispatch:i})=>{var o;let{extendEmptyMarkRange:s=!1}=e,{selection:l}=t,a=Vt(n,r.schema),{$from:c,empty:u,ranges:f}=l;if(!i)return!0;if(u&&s){let{from:d,to:p}=l,h=(o=c.marks().find(g=>g.type===a))===null||o===void 0?void 0:o.attrs,m=bl(c,a,h);m&&(d=m.from,p=m.to),t.removeMark(d,p,a)}else f.forEach(d=>{t.removeMark(d.$from.pos,d.$to.pos,a)});return t.removeStoredMark(a),!0},ey=(n,e={})=>({tr:t,state:r,dispatch:i})=>{let o=null,s=null,l=Ji(typeof n=="string"?n:n.name,r.schema);return l?(l==="node"&&(o=pe(n,r.schema)),l==="mark"&&(s=Vt(n,r.schema)),i&&t.selection.ranges.forEach(a=>{let c=a.$from.pos,u=a.$to.pos,f,d,p,h;t.selection.empty?r.doc.nodesBetween(c,u,(m,g)=>{o&&o===m.type&&(p=Math.max(g,c),h=Math.min(g+m.nodeSize,u),f=g,d=m)}):r.doc.nodesBetween(c,u,(m,g)=>{g=c&&g<=u&&(o&&o===m.type&&t.setNodeMarkup(g,void 0,{...m.attrs,...e}),s&&m.marks.length&&m.marks.forEach(b=>{if(s===b.type){let x=Math.max(g,c),C=Math.min(g+m.nodeSize,u);t.addMark(x,C,s.create({...b.attrs,...e}))}}))}),d&&(f!==void 0&&t.setNodeMarkup(f,void 0,{...d.attrs,...e}),s&&d.marks.length&&d.marks.forEach(m=>{s===m.type&&t.addMark(p,h,s.create({...m.attrs,...e}))}))}),!0):!1},ty=(n,e={})=>({state:t,dispatch:r})=>{let i=pe(n,t.schema);return zu(i,e)(t,r)},ny=(n,e={})=>({state:t,dispatch:r})=>{let i=pe(n,t.schema);return Fu(i,e)(t,r)},ry=Object.freeze({__proto__:null,blur:jm,clearContent:Wm,clearNodes:Um,command:_m,createParagraphNear:Km,cut:qm,deleteCurrentNode:Jm,deleteNode:Gm,deleteRange:Ym,deleteSelection:Xm,enter:Qm,exitCode:Zm,extendMarkRange:eg,first:tg,focus:ng,forEach:rg,insertContent:ig,insertContentAt:lg,joinBackward:ug,joinDown:cg,joinForward:fg,joinItemBackward:dg,joinItemForward:pg,joinTextblockBackward:hg,joinTextblockForward:mg,joinUp:ag,keyboardShortcut:yg,lift:bg,liftEmptyBlock:vg,liftListItem:xg,newlineInCode:kg,resetAttributes:Sg,scrollIntoView:wg,selectAll:Cg,selectNodeBackward:Mg,selectNodeForward:Eg,selectParentNode:Og,selectTextblockEnd:Tg,selectTextblockStart:Ag,setContent:Ng,setMark:Hg,setMeta:$g,setNode:Vg,setNodeSelection:jg,setTextSelection:Wg,sinkListItem:Ug,splitBlock:_g,splitListItem:Kg,toggleList:qg,toggleMark:Jg,toggleNode:Gg,toggleWrap:Yg,undoInputRule:Xg,unsetAllMarks:Qg,unsetMark:Zg,updateAttributes:ey,wrapIn:ty,wrapInList:ny}),iy=le.create({name:"commands",addCommands(){return{...ry}}}),oy=le.create({name:"drop",addProseMirrorPlugins(){return[new _({key:new G("tiptapDrop"),props:{handleDrop:(n,e,t,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:t,moved:r})}}})]}}),sy=le.create({name:"editable",addProseMirrorPlugins(){return[new _({key:new G("editable"),props:{editable:()=>this.editor.options.editable}})]}}),ly=le.create({name:"focusEvents",addProseMirrorPlugins(){let{editor:n}=this;return[new _({key:new G("focusEvents"),props:{handleDOMEvents:{focus:(e,t)=>{n.isFocused=!0;let r=n.state.tr.setMeta("focus",{event:t}).setMeta("addToHistory",!1);return e.dispatch(r),!1},blur:(e,t)=>{n.isFocused=!1;let r=n.state.tr.setMeta("blur",{event:t}).setMeta("addToHistory",!1);return e.dispatch(r),!1}}}})]}}),ay=le.create({name:"keymap",addKeyboardShortcuts(){let n=()=>this.editor.commands.first(({commands:s})=>[()=>s.undoInputRule(),()=>s.command(({tr:l})=>{let{selection:a,doc:c}=l,{empty:u,$anchor:f}=a,{pos:d,parent:p}=f,h=f.parent.isTextblock&&d>0?l.doc.resolve(d-1):f,m=h.parent.type.spec.isolating,g=f.pos-f.parentOffset,b=m&&h.parent.childCount===1?g===f.pos:I.atStart(c).from===d;return!u||!p.type.isTextblock||p.textContent.length||!b||b&&f.parent.type.name==="paragraph"?!1:s.clearNodes()}),()=>s.deleteSelection(),()=>s.joinBackward(),()=>s.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:s})=>[()=>s.deleteSelection(),()=>s.deleteCurrentNode(),()=>s.joinForward(),()=>s.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:s})=>[()=>s.newlineInCode(),()=>s.createParagraphNear(),()=>s.liftEmptyBlock(),()=>s.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:n,"Mod-Backspace":n,"Shift-Backspace":n,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},i={...r},o={...r,"Ctrl-h":n,"Alt-Backspace":n,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return nf()||rf()?o:i},addProseMirrorPlugins(){return[new _({key:new G("clearDocument"),appendTransaction:(n,e,t)=>{let r=n.some(m=>m.docChanged)&&!e.doc.eq(t.doc),i=n.some(m=>m.getMeta("preventClearDocument"));if(!r||i)return;let{empty:o,from:s,to:l}=e.selection,a=I.atStart(e.doc).from,c=I.atEnd(e.doc).to;if(o||!(s===a&&l===c)||!Tr(t.doc))return;let d=t.tr,p=_i({state:t,transaction:d}),{commands:h}=new Un({editor:this.editor,state:p});if(h.clearNodes(),!!d.steps.length)return d}})]}}),cy=le.create({name:"paste",addProseMirrorPlugins(){return[new _({key:new G("tiptapPaste"),props:{handlePaste:(n,e,t)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:t})}}})]}}),uy=le.create({name:"tabindex",addProseMirrorPlugins(){return[new _({key:new G("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}});var ml=class n{get name(){return this.node.type.name}constructor(e,t,r=!1,i=null){this.currentNode=null,this.actualDepth=null,this.isBlock=r,this.resolvedPos=e,this.editor=t,this.currentNode=i}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var e;return(e=this.actualDepth)!==null&&e!==void 0?e:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let t=this.from,r=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can\u2019t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}t=this.from+1,r=this.to-1}this.editor.commands.insertContentAt({from:t,to:r},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?0:1)}get parent(){if(this.depth===0)return null;let e=this.resolvedPos.start(this.resolvedPos.depth-1),t=this.resolvedPos.doc.resolve(e);return new n(t,this.editor)}get before(){let e=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.from-3)),new n(e,this.editor)}get after(){let e=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.to+3)),new n(e,this.editor)}get children(){let e=[];return this.node.content.forEach((t,r)=>{let i=t.isBlock&&!t.isTextblock,o=t.isAtom&&!t.isText,s=this.pos+r+(o?0:1),l=this.resolvedPos.doc.resolve(s);if(!i&&l.depth<=this.depth)return;let a=new n(l,this.editor,i,i?t:null);i&&(a.actualDepth=this.depth+1),e.push(new n(l,this.editor,i,i?t:null))}),e}get firstChild(){return this.children[0]||null}get lastChild(){let e=this.children;return e[e.length-1]||null}closest(e,t={}){let r=null,i=this.parent;for(;i&&!r;){if(i.node.type.name===e)if(Object.keys(t).length>0){let o=i.node.attrs,s=Object.keys(t);for(let l=0;l{r&&i.length>0||(s.node.type.name===e&&o.every(a=>t[a]===s.node.attrs[a])&&i.push(s),!(r&&i.length>0)&&(i=i.concat(s.querySelectorAll(e,t,r))))}),i}setAttribute(e){let{tr:t}=this.editor.state;t.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(t)}},fy=`.ProseMirror { position: relative; } @@ -84,13 +84,17 @@ img.ProseMirror-separator { .tippy-box[data-animation=fade][data-state=hidden] { opacity: 0 -}`;function dm(n,e,t){let r=document.querySelector(`style[data-tiptap-style${t?`-${t}`:""}]`);if(r!==null)return r;let i=document.createElement("style");return e&&i.setAttribute("nonce",e),i.setAttribute(`data-tiptap-style${t?`-${t}`:""}`,""),i.innerHTML=n,document.getElementsByTagName("head")[0].appendChild(i),i}var gi=class extends es{constructor(e={}){super(),this.isFocused=!1,this.isInitialized=!1,this.extensionStorage={},this.options={element:document.createElement("div"),content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,onBeforeCreate:()=>null,onCreate:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:t})=>{throw t},onPaste:()=>null,onDrop:()=>null},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.setOptions(e),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("contentError",this.options.onContentError),this.createView(),this.injectCSS(),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:t,slice:r,moved:i})=>this.options.onDrop(t,r,i)),this.on("paste",({event:t,slice:r})=>this.options.onPaste(t,r)),window.setTimeout(()=>{this.isDestroyed||(this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}),this.isInitialized=!0)},0)}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager.chain()}can(){return this.commandManager.can()}injectCSS(){this.options.injectCSS&&document&&(this.css=dm(um,this.options.injectNonce))}setOptions(e={}){this.options={...this.options,...e},!(!this.view||!this.state||this.isDestroyed)&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(e,t=!0){this.setOptions({editable:e}),t&&this.emit("update",{editor:this,transaction:this.state.tr})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get state(){return this.view.state}registerPlugin(e,t){let r=gc(t)?t(e,[...this.state.plugins]):[...this.state.plugins,e],i=this.state.reconfigure({plugins:r});return this.view.updateState(i),i}unregisterPlugin(e){if(this.isDestroyed)return;let t=this.state.plugins,r=t;if([].concat(e).forEach(o=>{let s=typeof o=="string"?`${o}$`:o.key;r=t.filter(l=>!l.key.startsWith(s))}),t.length===r.length)return;let i=this.state.reconfigure({plugins:r});return this.view.updateState(i),i}createExtensionManager(){var e,t;let i=[...this.options.enableCoreExtensions?[sm,Wp.configure({blockSeparator:(t=(e=this.options.coreExtensionOptions)===null||e===void 0?void 0:e.clipboardTextSerializer)===null||t===void 0?void 0:t.blockSeparator}),im,lm,am,fm,om,cm].filter(o=>typeof this.options.enableCoreExtensions=="object"?this.options.enableCoreExtensions[o.name]!==!1:!0):[],...this.options.extensions].filter(o=>["extension","node","mark"].includes(o?.type));this.extensionManager=new rs(i,this)}createCommandManager(){this.commandManager=new On({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createView(){var e;let t;try{t=is(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(s){if(!(s instanceof Error)||!["[tiptap error]: Invalid JSON content","[tiptap error]: Invalid HTML content"].includes(s.message))throw s;this.emit("contentError",{editor:this,error:s,disableCollaboration:()=>{this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter(l=>l.name!=="collaboration"),this.createExtensionManager()}}),t=is(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}let r=kc(t,this.options.autofocus);this.view=new ri(this.options.element,{...this.options.editorProps,attributes:{role:"textbox",...(e=this.options.editorProps)===null||e===void 0?void 0:e.attributes},dispatchTransaction:this.dispatchTransaction.bind(this),state:_r.create({doc:t,selection:r||void 0})});let i=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(i),this.createNodeViews(),this.prependClass();let o=this.view.dom;o.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`tiptap ${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(s=>{var l;return(l=this.capturedTransaction)===null||l===void 0?void 0:l.step(s)});return}let t=this.state.apply(e),r=!this.state.selection.eq(t.selection);this.emit("beforeTransaction",{editor:this,transaction:e,nextState:t}),this.view.updateState(t),this.emit("transaction",{editor:this,transaction:e}),r&&this.emit("selectionUpdate",{editor:this,transaction:e});let i=e.getMeta("focus"),o=e.getMeta("blur");i&&this.emit("focus",{editor:this,event:i.event,transaction:e}),o&&this.emit("blur",{editor:this,event:o.event,transaction:e}),!(!e.docChanged||e.getMeta("preventUpdate"))&&this.emit("update",{editor:this,transaction:e})}getAttributes(e){return Lh(this.state,e)}isActive(e,t){let r=typeof e=="string"?e:null,i=typeof e=="string"?t:e;return Fh(this.state,r,i)}getJSON(){return this.state.doc.toJSON()}getHTML(){return as(this.state.doc.content,this.schema)}getText(e){let{blockSeparator:t=` +}`;function dy(n,e,t){let r=document.querySelector(`style[data-tiptap-style${t?`-${t}`:""}]`);if(r!==null)return r;let i=document.createElement("style");return e&&i.setAttribute("nonce",e),i.setAttribute(`data-tiptap-style${t?`-${t}`:""}`,""),i.innerHTML=n,document.getElementsByTagName("head")[0].appendChild(i),i}var Ui=class extends cl{constructor(e={}){super(),this.isFocused=!1,this.isInitialized=!1,this.extensionStorage={},this.options={element:document.createElement("div"),content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,onBeforeCreate:()=>null,onCreate:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:t})=>{throw t},onPaste:()=>null,onDrop:()=>null},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.setOptions(e),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("contentError",this.options.onContentError),this.createView(),this.injectCSS(),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:t,slice:r,moved:i})=>this.options.onDrop(t,r,i)),this.on("paste",({event:t,slice:r})=>this.options.onPaste(t,r)),window.setTimeout(()=>{this.isDestroyed||(this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}),this.isInitialized=!0)},0)}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager.chain()}can(){return this.commandManager.can()}injectCSS(){this.options.injectCSS&&document&&(this.css=dy(fy,this.options.injectNonce))}setOptions(e={}){this.options={...this.options,...e},!(!this.view||!this.state||this.isDestroyed)&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(e,t=!0){this.setOptions({editable:e}),t&&this.emit("update",{editor:this,transaction:this.state.tr})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get state(){return this.view.state}registerPlugin(e,t){let r=Gu(t)?t(e,[...this.state.plugins]):[...this.state.plugins,e],i=this.state.reconfigure({plugins:r});return this.view.updateState(i),i}unregisterPlugin(e){if(this.isDestroyed)return;let t=this.state.plugins,r=t;if([].concat(e).forEach(o=>{let s=typeof o=="string"?`${o}$`:o.key;r=t.filter(l=>!l.key.startsWith(s))}),t.length===r.length)return;let i=this.state.reconfigure({plugins:r});return this.view.updateState(i),i}createExtensionManager(){var e,t;let i=[...this.options.enableCoreExtensions?[sy,Vm.configure({blockSeparator:(t=(e=this.options.coreExtensionOptions)===null||e===void 0?void 0:e.clipboardTextSerializer)===null||t===void 0?void 0:t.blockSeparator}),iy,ly,ay,uy,oy,cy].filter(o=>typeof this.options.enableCoreExtensions=="object"?this.options.enableCoreExtensions[o.name]!==!1:!0):[],...this.options.extensions].filter(o=>["extension","node","mark"].includes(o?.type));this.extensionManager=new dl(i,this)}createCommandManager(){this.commandManager=new Un({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createView(){var e;let t;try{t=pl(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(s){if(!(s instanceof Error)||!["[tiptap error]: Invalid JSON content","[tiptap error]: Invalid HTML content"].includes(s.message))throw s;this.emit("contentError",{editor:this,error:s,disableCollaboration:()=>{this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter(l=>l.name!=="collaboration"),this.createExtensionManager()}}),t=pl(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}let r=ef(t,this.options.autofocus);this.view=new Di(this.options.element,{...this.options.editorProps,attributes:{role:"textbox",...(e=this.options.editorProps)===null||e===void 0?void 0:e.attributes},dispatchTransaction:this.dispatchTransaction.bind(this),state:xi.create({doc:t,selection:r||void 0})});let i=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(i),this.createNodeViews(),this.prependClass();let o=this.view.dom;o.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`tiptap ${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(s=>{var l;return(l=this.capturedTransaction)===null||l===void 0?void 0:l.step(s)});return}let t=this.state.apply(e),r=!this.state.selection.eq(t.selection);this.emit("beforeTransaction",{editor:this,transaction:e,nextState:t}),this.view.updateState(t),this.emit("transaction",{editor:this,transaction:e}),r&&this.emit("selectionUpdate",{editor:this,transaction:e});let i=e.getMeta("focus"),o=e.getMeta("blur");i&&this.emit("focus",{editor:this,event:i.event,transaction:e}),o&&this.emit("blur",{editor:this,event:o.event,transaction:e}),!(!e.docChanged||e.getMeta("preventUpdate"))&&this.emit("update",{editor:this,transaction:e})}getAttributes(e){return xl(this.state,e)}isActive(e,t){let r=typeof e=="string"?e:null,i=typeof e=="string"?t:e;return zg(this.state,r,i)}getJSON(){return this.state.doc.toJSON()}getHTML(){return gl(this.state.doc.content,this.schema)}getText(e){let{blockSeparator:t=` -`,textSerializers:r={}}=e||{};return Rh(this.state.doc,{blockSeparator:t,textSerializers:{...bc(this.schema),...r}})}get isEmpty(){return fr(this.state.doc)}getCharacterCount(){return console.warn('[tiptap warn]: "editor.getCharacterCount()" is deprecated. Please use "editor.storage.characterCount.characters()" instead.'),this.state.doc.content.size-2}destroy(){if(this.emit("destroy"),this.view){let e=this.view.dom;e&&e.editor&&delete e.editor,this.view.destroy()}this.removeAllListeners()}get isDestroyed(){var e;return!(!((e=this.view)===null||e===void 0)&&e.docView)}$node(e,t){var r;return((r=this.$doc)===null||r===void 0?void 0:r.querySelector(e,t))||null}$nodes(e,t){var r;return((r=this.$doc)===null||r===void 0?void 0:r.querySelectorAll(e,t))||null}$pos(e){let t=this.state.doc.resolve(e);return new ls(t,this)}get $doc(){return this.$pos(0)}};function Qe(n){return new Tn({find:n.find,handler:({state:e,range:t,match:r})=>{let i=L(n.getAttributes,void 0,r);if(i===!1||i===null)return null;let{tr:o}=e,s=r[r.length-1],l=r[0];if(s){let a=l.search(/\S/),c=t.from+l.indexOf(s),f=c+s.length;if(Oc(t.from,t.to,e.doc).filter(p=>p.mark.type.excluded.find(m=>m===n.type&&m!==p.mark.type)).filter(p=>p.to>c).length)return null;ft.from&&o.delete(t.from+a,c);let d=t.from+a+s.length;o.addMark(t.from+a,d,n.type.create(i||{})),o.removeStoredMark(n.type)}}})}function Ec(n){return new Tn({find:n.find,handler:({state:e,range:t,match:r})=>{let i=L(n.getAttributes,void 0,r)||{},{tr:o}=e,s=t.from,l=t.to,a=n.type.create(i);if(r[1]){let c=r[0].lastIndexOf(r[1]),f=s+c;f>l?f=l:l=f+r[1].length;let u=r[0][r[0].length-1];o.insertText(u,s+r[0].length-1),o.replaceWith(f,l,a)}else if(r[0]){let c=n.type.isInline?s:s-1;o.insert(c,n.type.create(i)).delete(o.mapping.map(s),o.mapping.map(l))}o.scrollIntoView()}})}function ur(n){return new Tn({find:n.find,handler:({state:e,range:t,match:r})=>{let i=e.doc.resolve(t.from),o=L(n.getAttributes,void 0,r)||{};if(!i.node(-1).canReplaceWith(i.index(-1),i.indexAfter(-1),n.type))return null;e.tr.delete(t.from,t.to).setBlockType(t.from,t.from,n.type,o)}})}function Nt(n){return new Tn({find:n.find,handler:({state:e,range:t,match:r,chain:i})=>{let o=L(n.getAttributes,void 0,r)||{},s=e.tr.delete(t.from,t.to),a=s.doc.resolve(t.from).blockRange(),c=a&&gn(a,n.type,o);if(!c)return null;if(s.wrap(a,c),n.keepMarks&&n.editor){let{selection:u,storedMarks:d}=e,{splittableMarks:p}=n.editor.extensionManager,h=d||u.$to.parentOffset&&u.$from.marks();if(h){let m=h.filter(g=>p.includes(g.type.name));s.ensureMarks(m)}}if(n.keepAttributes){let u=n.type.name==="bulletList"||n.type.name==="orderedList"?"listItem":"taskList";i().updateAttributes(u,o).run()}let f=s.doc.resolve(t.from-1).nodeBefore;f&&f.type===n.type&&qe(s.doc,t.from-1)&&(!n.joinPredicate||n.joinPredicate(r,f))&&s.join(t.from-1)}})}var J=class n{constructor(e={}){this.type="node",this.name="node",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=L(O(this,"addOptions",{name:this.name}))),this.storage=L(O(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new n(e)}configure(e={}){let t=this.extend({...this.config,addOptions:()=>vi(this.options,e)});return t.name=this.name,t.parent=this.parent,t}extend(e={}){let t=new n(e);return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=L(O(t,"addOptions",{name:t.name})),t.storage=L(O(t,"addStorage",{name:t.name,options:t.options})),t}};function et(n){return new ns({find:n.find,handler:({state:e,range:t,match:r,pasteEvent:i})=>{let o=L(n.getAttributes,void 0,r,i);if(o===!1||o===null)return null;let{tr:s}=e,l=r[r.length-1],a=r[0],c=t.to;if(l){let f=a.search(/\S/),u=t.from+a.indexOf(l),d=u+l.length;if(Oc(t.from,t.to,e.doc).filter(h=>h.mark.type.excluded.find(g=>g===n.type&&g!==h.mark.type)).filter(h=>h.to>u).length)return null;dt.from&&s.delete(t.from+f,u),c=t.from+f+l.length,s.addMark(t.from+f,c,n.type.create(o||{})),s.removeStoredMark(n.type)}}})}function Ac(n){return n.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}var pm=/^\s*>\s$/,Nc=J.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:n}){return["blockquote",V(this.options.HTMLAttributes,n),0]},addCommands(){return{setBlockquote:()=>({commands:n})=>n.wrapIn(this.name),toggleBlockquote:()=>({commands:n})=>n.toggleWrap(this.name),unsetBlockquote:()=>({commands:n})=>n.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[Nt({find:pm,type:this.type})]}});var hm=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,mm=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,gm=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,ym=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,Dc=_e.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:n=>n.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:n=>n.type.name===this.name},{style:"font-weight",getAttrs:n=>/^(bold(er)?|[5-9]\d{2,})$/.test(n)&&null}]},renderHTML({HTMLAttributes:n}){return["strong",V(this.options.HTMLAttributes,n),0]},addCommands(){return{setBold:()=>({commands:n})=>n.setMark(this.name),toggleBold:()=>({commands:n})=>n.toggleMark(this.name),unsetBold:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[Qe({find:hm,type:this.type}),Qe({find:gm,type:this.type})]},addPasteRules(){return[et({find:mm,type:this.type}),et({find:ym,type:this.type})]}});var bm="listItem",Pc="textStyle",Ic=/^\s*([-+*])\s$/,Rc=J.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:n}){return["ul",V(this.options.HTMLAttributes,n),0]},addCommands(){return{toggleBulletList:()=>({commands:n,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(bm,this.editor.getAttributes(Pc)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let n=Nt({find:Ic,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(n=Nt({find:Ic,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(Pc),editor:this.editor})),[n]}});var vm=/(^|[^`])`([^`]+)`(?!`)/,xm=/(^|[^`])`([^`]+)`(?!`)/g,Bc=_e.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:n}){return["code",V(this.options.HTMLAttributes,n),0]},addCommands(){return{setCode:()=>({commands:n})=>n.setMark(this.name),toggleCode:()=>({commands:n})=>n.toggleMark(this.name),unsetCode:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[Qe({find:vm,type:this.type})]},addPasteRules(){return[et({find:xm,type:this.type})]}});var km=/^```([a-z]+)?[\s\n]$/,Sm=/^~~~([a-z]+)?[\s\n]$/,Lc=J.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:n=>{var e;let{languageClassPrefix:t}=this.options,o=[...((e=n.firstElementChild)===null||e===void 0?void 0:e.classList)||[]].filter(s=>s.startsWith(t)).map(s=>s.replace(t,""))[0];return o||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:n,HTMLAttributes:e}){return["pre",V(this.options.HTMLAttributes,e),["code",{class:n.attrs.language?this.options.languageClassPrefix+n.attrs.language:null},0]]},addCommands(){return{setCodeBlock:n=>({commands:e})=>e.setNode(this.name,n),toggleCodeBlock:n=>({commands:e})=>e.toggleNode(this.name,"paragraph",n)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{let{empty:n,$anchor:e}=this.editor.state.selection,t=e.pos===1;return!n||e.parent.type.name!==this.name?!1:t||!e.parent.textContent.length?this.editor.commands.clearNodes():!1},Enter:({editor:n})=>{if(!this.options.exitOnTripleEnter)return!1;let{state:e}=n,{selection:t}=e,{$from:r,empty:i}=t;if(!i||r.parent.type!==this.type)return!1;let o=r.parentOffset===r.parent.nodeSize-2,s=r.parent.textContent.endsWith(` +`,textSerializers:r={}}=e||{};return Ig(this.state.doc,{blockSeparator:t,textSerializers:{...Xu(this.schema),...r}})}get isEmpty(){return Tr(this.state.doc)}getCharacterCount(){return console.warn('[tiptap warn]: "editor.getCharacterCount()" is deprecated. Please use "editor.storage.characterCount.characters()" instead.'),this.state.doc.content.size-2}destroy(){if(this.emit("destroy"),this.view){let e=this.view.dom;e&&e.editor&&delete e.editor,this.view.destroy()}this.removeAllListeners()}get isDestroyed(){var e;return!(!((e=this.view)===null||e===void 0)&&e.docView)}$node(e,t){var r;return((r=this.$doc)===null||r===void 0?void 0:r.querySelector(e,t))||null}$nodes(e,t){var r;return((r=this.$doc)===null||r===void 0?void 0:r.querySelectorAll(e,t))||null}$pos(e){let t=this.state.doc.resolve(e);return new ml(t,this)}get $doc(){return this.$pos(0)}};function lt(n){return new _n({find:n.find,handler:({state:e,range:t,match:r})=>{let i=F(n.getAttributes,void 0,r);if(i===!1||i===null)return null;let{tr:o}=e,s=r[r.length-1],l=r[0];if(s){let a=l.search(/\S/),c=t.from+l.indexOf(s),u=c+s.length;if(Gi(t.from,t.to,e.doc).filter(p=>p.mark.type.excluded.find(m=>m===n.type&&m!==p.mark.type)).filter(p=>p.to>c).length)return null;ut.from&&o.delete(t.from+a,c);let d=t.from+a+s.length;o.addMark(t.from+a,d,n.type.create(i||{})),o.removeStoredMark(n.type)}}})}function uf(n){return new _n({find:n.find,handler:({state:e,range:t,match:r})=>{let i=F(n.getAttributes,void 0,r)||{},{tr:o}=e,s=t.from,l=t.to,a=n.type.create(i);if(r[1]){let c=r[0].lastIndexOf(r[1]),u=s+c;u>l?u=l:l=u+r[1].length;let f=r[0][r[0].length-1];o.insertText(f,s+r[0].length-1),o.replaceWith(u,l,a)}else if(r[0]){let c=n.type.isInline?s:s-1;o.insert(c,n.type.create(i)).delete(o.mapping.map(s),o.mapping.map(l))}o.scrollIntoView()}})}function Ar(n){return new _n({find:n.find,handler:({state:e,range:t,match:r})=>{let i=e.doc.resolve(t.from),o=F(n.getAttributes,void 0,r)||{};if(!i.node(-1).canReplaceWith(i.index(-1),i.indexAfter(-1),n.type))return null;e.tr.delete(t.from,t.to).setBlockType(t.from,t.from,n.type,o)}})}function jt(n){return new _n({find:n.find,handler:({state:e,range:t,match:r,chain:i})=>{let o=F(n.getAttributes,void 0,r)||{},s=e.tr.delete(t.from,t.to),a=s.doc.resolve(t.from).blockRange(),c=a&&Pn(a,n.type,o);if(!c)return null;if(s.wrap(a,c),n.keepMarks&&n.editor){let{selection:f,storedMarks:d}=e,{splittableMarks:p}=n.editor.extensionManager,h=d||f.$to.parentOffset&&f.$from.marks();if(h){let m=h.filter(g=>p.includes(g.type.name));s.ensureMarks(m)}}if(n.keepAttributes){let f=n.type.name==="bulletList"||n.type.name==="orderedList"?"listItem":"taskList";i().updateAttributes(f,o).run()}let u=s.doc.resolve(t.from-1).nodeBefore;u&&u.type===n.type&&Ze(s.doc,t.from-1)&&(!n.joinPredicate||n.joinPredicate(r,u))&&s.join(t.from-1)}})}var J=class n{constructor(e={}){this.type="node",this.name="node",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=F(T(this,"addOptions",{name:this.name}))),this.storage=F(T(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new n(e)}configure(e={}){let t=this.extend({...this.config,addOptions:()=>qi(this.options,e)});return t.name=this.name,t.parent=this.parent,t}extend(e={}){let t=new n(e);return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=F(T(t,"addOptions",{name:t.name})),t.storage=F(T(t,"addStorage",{name:t.name,options:t.options})),t}};function _e(n){return new fl({find:n.find,handler:({state:e,range:t,match:r,pasteEvent:i})=>{let o=F(n.getAttributes,void 0,r,i);if(o===!1||o===null)return null;let{tr:s}=e,l=r[r.length-1],a=r[0],c=t.to;if(l){let u=a.search(/\S/),f=t.from+a.indexOf(l),d=f+l.length;if(Gi(t.from,t.to,e.doc).filter(h=>h.mark.type.excluded.find(g=>g===n.type&&g!==h.mark.type)).filter(h=>h.to>f).length)return null;dt.from&&s.delete(t.from+u,f),c=t.from+u+l.length,s.addMark(t.from+u,c,n.type.create(o||{})),s.removeStoredMark(n.type)}}})}function ff(n){return n.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}var py=/^\s*>\s$/,df=J.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:n}){return["blockquote",$(this.options.HTMLAttributes,n),0]},addCommands(){return{setBlockquote:()=>({commands:n})=>n.wrapIn(this.name),toggleBlockquote:()=>({commands:n})=>n.toggleWrap(this.name),unsetBlockquote:()=>({commands:n})=>n.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[jt({find:py,type:this.type})]}});var hy=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,my=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,gy=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,yy=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,pf=De.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:n=>n.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:n=>n.type.name===this.name},{style:"font-weight",getAttrs:n=>/^(bold(er)?|[5-9]\d{2,})$/.test(n)&&null}]},renderHTML({HTMLAttributes:n}){return["strong",$(this.options.HTMLAttributes,n),0]},addCommands(){return{setBold:()=>({commands:n})=>n.setMark(this.name),toggleBold:()=>({commands:n})=>n.toggleMark(this.name),unsetBold:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[lt({find:hy,type:this.type}),lt({find:gy,type:this.type})]},addPasteRules(){return[_e({find:my,type:this.type}),_e({find:yy,type:this.type})]}});var by="listItem",hf="textStyle",mf=/^\s*([-+*])\s$/,gf=J.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:n}){return["ul",$(this.options.HTMLAttributes,n),0]},addCommands(){return{toggleBulletList:()=>({commands:n,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(by,this.editor.getAttributes(hf)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let n=jt({find:mf,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(n=jt({find:mf,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(hf),editor:this.editor})),[n]}});var vy=/(^|[^`])`([^`]+)`(?!`)/,xy=/(^|[^`])`([^`]+)`(?!`)/g,yf=De.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:n}){return["code",$(this.options.HTMLAttributes,n),0]},addCommands(){return{setCode:()=>({commands:n})=>n.setMark(this.name),toggleCode:()=>({commands:n})=>n.toggleMark(this.name),unsetCode:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[lt({find:vy,type:this.type})]},addPasteRules(){return[_e({find:xy,type:this.type})]}});var ky=/^```([a-z]+)?[\s\n]$/,Sy=/^~~~([a-z]+)?[\s\n]$/,bf=J.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:n=>{var e;let{languageClassPrefix:t}=this.options,o=[...((e=n.firstElementChild)===null||e===void 0?void 0:e.classList)||[]].filter(s=>s.startsWith(t)).map(s=>s.replace(t,""))[0];return o||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:n,HTMLAttributes:e}){return["pre",$(this.options.HTMLAttributes,e),["code",{class:n.attrs.language?this.options.languageClassPrefix+n.attrs.language:null},0]]},addCommands(){return{setCodeBlock:n=>({commands:e})=>e.setNode(this.name,n),toggleCodeBlock:n=>({commands:e})=>e.toggleNode(this.name,"paragraph",n)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{let{empty:n,$anchor:e}=this.editor.state.selection,t=e.pos===1;return!n||e.parent.type.name!==this.name?!1:t||!e.parent.textContent.length?this.editor.commands.clearNodes():!1},Enter:({editor:n})=>{if(!this.options.exitOnTripleEnter)return!1;let{state:e}=n,{selection:t}=e,{$from:r,empty:i}=t;if(!i||r.parent.type!==this.type)return!1;let o=r.parentOffset===r.parent.nodeSize-2,s=r.parent.textContent.endsWith(` -`);return!o||!s?!1:n.chain().command(({tr:l})=>(l.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowDown:({editor:n})=>{if(!this.options.exitOnArrowDown)return!1;let{state:e}=n,{selection:t,doc:r}=e,{$from:i,empty:o}=t;if(!o||i.parent.type!==this.type||!(i.parentOffset===i.parent.nodeSize-2))return!1;let l=i.after();return l===void 0?!1:r.nodeAt(l)?n.commands.command(({tr:c})=>(c.setSelection(D.near(r.resolve(l))),!0)):n.commands.exitCode()}}},addInputRules(){return[ur({find:km,type:this.type,getAttributes:n=>({language:n[1]})}),ur({find:Sm,type:this.type,getAttributes:n=>({language:n[1]})})]},addProseMirrorPlugins(){return[new q({key:new X("codeBlockVSCodeHandler"),props:{handlePaste:(n,e)=>{if(!e.clipboardData||this.editor.isActive(this.type.name))return!1;let t=e.clipboardData.getData("text/plain"),r=e.clipboardData.getData("vscode-editor-data"),i=r?JSON.parse(r):void 0,o=i?.mode;if(!t||!o)return!1;let{tr:s,schema:l}=n.state,a=l.text(t.replace(/\r\n?/g,` -`));return s.replaceSelectionWith(this.type.create({language:o},a)),s.selection.$from.parent.type!==this.type&&s.setSelection(P.near(s.doc.resolve(Math.max(0,s.selection.from-2)))),s.setMeta("paste",!0),n.dispatch(s),!0}}})]}});var Fc=J.create({name:"doc",topNode:!0,content:"block+"});function zc(n={}){return new q({view(e){return new ds(e,n)}})}var ds=class{constructor(e,t){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=t.width)!==null&&r!==void 0?r:1,this.color=t.color===!1?void 0:t.color||"black",this.class=t.class,this.handlers=["dragover","dragend","drop","dragleave"].map(i=>{let o=s=>{this[i](s)};return e.dom.addEventListener(i,o),{name:i,handler:o}})}destroy(){this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){this.cursorPos!=null&&t.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):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,r;if(t){let l=e.nodeBefore,a=e.nodeAfter;if(l||a){let c=this.editorView.nodeDOM(this.cursorPos-(l?l.nodeSize:0));if(c){let f=c.getBoundingClientRect(),u=l?f.bottom:f.top;l&&a&&(u=(u+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2),r={left:f.left,right:f.right,top:u-this.width/2,bottom:u+this.width/2}}}}if(!r){let l=this.editorView.coordsAtPos(this.cursorPos);r={left:l.left-this.width/2,right:l.left+this.width/2,top:l.top,bottom:l.bottom}}let i=this.editorView.dom.offsetParent;this.element||(this.element=i.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 o,s;if(!i||i==document.body&&getComputedStyle(i).position=="static")o=-pageXOffset,s=-pageYOffset;else{let l=i.getBoundingClientRect();o=l.left-i.scrollLeft,s=l.top-i.scrollTop}this.element.style.left=r.left-o+"px",this.element.style.top=r.top-s+"px",this.element.style.width=r.right-r.left+"px",this.element.style.height=r.bottom-r.top+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),i=r&&r.type.spec.disableDropCursor,o=typeof i=="function"?i(this.editorView,t,e):i;if(t&&!o){let s=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=Wr(this.editorView.state.doc,s,this.editorView.dragging.slice);l!=null&&(s=l)}this.setCursor(s),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){(e.target==this.editorView.dom||!this.editorView.dom.contains(e.relatedTarget))&&this.setCursor(null)}};var Vc=te.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[zc(this.options)]}});var ke=class n extends D{constructor(e){super(e,e)}map(e,t){let r=e.resolve(t.map(this.head));return n.valid(r)?new n(r):D.near(r)}content(){return M.empty}eq(e){return e instanceof n&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new n(e.resolve(t.pos))}getBookmark(){return new ps(this.anchor)}static valid(e){let t=e.parent;if(t.isTextblock||!wm(e)||!Mm(e))return!1;let r=t.type.spec.allowGapCursor;if(r!=null)return r;let i=t.contentMatchAt(e.index()).defaultType;return i&&i.isTextblock}static findGapCursorFrom(e,t,r=!1){e:for(;;){if(!r&&n.valid(e))return e;let i=e.pos,o=null;for(let s=e.depth;;s--){let l=e.node(s);if(t>0?e.indexAfter(s)0){o=l.child(t>0?e.indexAfter(s):e.index(s)-1);break}else if(s==0)return null;i+=t;let a=e.doc.resolve(i);if(n.valid(a))return a}for(;;){let s=t>0?o.firstChild:o.lastChild;if(!s){if(o.isAtom&&!o.isText&&!A.isSelectable(o)){e=e.doc.resolve(i+o.nodeSize*t),r=!1;continue e}break}o=s,i+=t;let l=e.doc.resolve(i);if(n.valid(l))return l}return null}}};ke.prototype.visible=!1;ke.findFrom=ke.findGapCursorFrom;D.jsonID("gapcursor",ke);var ps=class n{constructor(e){this.pos=e}map(e){return new n(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return ke.valid(t)?new ke(t):D.near(t)}};function wm(n){for(let e=n.depth;e>=0;e--){let t=n.index(e),r=n.node(e);if(t==0){if(r.type.spec.isolating)return!0;continue}for(let i=r.child(t-1);;i=i.lastChild){if(i.childCount==0&&!i.inlineContent||i.isAtom||i.type.spec.isolating)return!0;if(i.inlineContent)return!1}}return!0}function Mm(n){for(let e=n.depth;e>=0;e--){let t=n.indexAfter(e),r=n.node(e);if(t==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let i=r.child(t);;i=i.firstChild){if(i.childCount==0&&!i.inlineContent||i.isAtom||i.type.spec.isolating)return!0;if(i.inlineContent)return!1}}return!0}function $c(){return new q({props:{decorations:Em,createSelectionBetween(n,e,t){return e.pos==t.pos&&ke.valid(t)?new ke(t):null},handleClick:Om,handleKeyDown:Cm,handleDOMEvents:{beforeinput:Tm}}})}var Cm=Ro({ArrowLeft:ki("horiz",-1),ArrowRight:ki("horiz",1),ArrowUp:ki("vert",-1),ArrowDown:ki("vert",1)});function ki(n,e){let t=n=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,i,o){let s=r.selection,l=e>0?s.$to:s.$from,a=s.empty;if(s instanceof P){if(!o.endOfTextblock(t)||l.depth==0)return!1;a=!1,l=r.doc.resolve(e>0?l.after():l.before())}let c=ke.findGapCursorFrom(l,e,a);return c?(i&&i(r.tr.setSelection(new ke(c))),!0):!1}}function Om(n,e,t){if(!n||!n.editable)return!1;let r=n.state.doc.resolve(e);if(!ke.valid(r))return!1;let i=n.posAtCoords({left:t.clientX,top:t.clientY});return i&&i.inside>-1&&A.isSelectable(n.state.doc.nodeAt(i.inside))?!1:(n.dispatch(n.state.tr.setSelection(new ke(r))),!0)}function Tm(n,e){if(e.inputType!="insertCompositionText"||!(n.state.selection instanceof ke))return!1;let{$from:t}=n.state.selection,r=t.parent.contentMatchAt(t.index()).findWrapping(n.state.schema.nodes.text);if(!r)return!1;let i=S.empty;for(let s=r.length-1;s>=0;s--)i=S.from(r[s].createAndFill(null,i));let o=n.state.tr.replace(t.pos,t.pos,new M(i,0,0));return o.setSelection(P.near(o.doc.resolve(t.pos+1))),n.dispatch(o),!1}function Em(n){if(!(n.selection instanceof ke))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",se.create(n.doc,[Ae.widget(n.selection.head,e,{key:"gapcursor"})])}var Hc=te.create({name:"gapCursor",addProseMirrorPlugins(){return[$c()]},extendNodeSchema(n){var e;let t={name:n.name,options:n.options,storage:n.storage};return{allowGapCursor:(e=L(O(n,"allowGapCursor",t)))!==null&&e!==void 0?e:null}}});var Wc=J.create({name:"hardBreak",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:n}){return["br",V(this.options.HTMLAttributes,n)]},renderText(){return` -`},addCommands(){return{setHardBreak:()=>({commands:n,chain:e,state:t,editor:r})=>n.first([()=>n.exitCode(),()=>n.command(()=>{let{selection:i,storedMarks:o}=t;if(i.$from.parent.type.spec.isolating)return!1;let{keepMarks:s}=this.options,{splittableMarks:l}=r.extensionManager,a=o||i.$to.parentOffset&&i.$from.marks();return e().insertContent({type:this.name}).command(({tr:c,dispatch:f})=>{if(f&&a&&s){let u=a.filter(d=>l.includes(d.type.name));c.ensureMarks(u)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}});var jc=J.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(n=>({tag:`h${n}`,attrs:{level:n}}))},renderHTML({node:n,HTMLAttributes:e}){return[`h${this.options.levels.includes(n.attrs.level)?n.attrs.level:this.options.levels[0]}`,V(this.options.HTMLAttributes,e),0]},addCommands(){return{setHeading:n=>({commands:e})=>this.options.levels.includes(n.level)?e.setNode(this.name,n):!1,toggleHeading:n=>({commands:e})=>this.options.levels.includes(n.level)?e.toggleNode(this.name,"paragraph",n):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((n,e)=>({...n,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(n=>ur({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${n}})\\s$`),type:this.type,getAttributes:{level:n}}))}});var Si=200,he=function(){};he.prototype.append=function(e){return e.length?(e=he.from(e),!this.length&&e||e.length=t?he.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))};he.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};he.prototype.forEach=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length),t<=r?this.forEachInner(e,t,r,0):this.forEachInvertedInner(e,t,r,0)};he.prototype.map=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length);var i=[];return this.forEach(function(o,s){return i.push(e(o,s))},t,r),i};he.from=function(e){return e instanceof he?e:e&&e.length?new qc(e):he.empty};var qc=function(n){function e(r){n.call(this),this.values=r}n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e;var t={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(i,o){return i==0&&o==this.length?this:new e(this.values.slice(i,o))},e.prototype.getInner=function(i){return this.values[i]},e.prototype.forEachInner=function(i,o,s,l){for(var a=o;a=s;a--)if(i(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(i){if(this.length+i.length<=Si)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=Si)return new e(i.flatten().concat(this.values))},t.length.get=function(){return this.values.length},t.depth.get=function(){return 0},Object.defineProperties(e.prototype,t),e}(he);he.empty=new qc([]);var Am=function(n){function e(t,r){n.call(this),this.left=t,this.right=r,this.length=t.length+r.length,this.depth=Math.max(t.depth,r.depth)+1}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return rl&&this.right.forEachInner(r,Math.max(i-l,0),Math.min(this.length,o)-l,s+l)===!1)return!1},e.prototype.forEachInvertedInner=function(r,i,o,s){var l=this.left.length;if(i>l&&this.right.forEachInvertedInner(r,i-l,Math.max(o,l)-l,s+l)===!1||o=o?this.right.slice(r-o,i-o):this.left.slice(r,o).append(this.right.slice(0,i-o))},e.prototype.leafAppend=function(r){var i=this.right.leafAppend(r);if(i)return new e(this.left,i)},e.prototype.leafPrepend=function(r){var i=this.left.leafPrepend(r);if(i)return new e(i,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e}(he),hs=he;var Nm=500,Zt=class n{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let i,o;t&&(i=this.remapping(r,this.items.length),o=i.maps.length);let s=e.tr,l,a,c=[],f=[];return this.items.forEach((u,d)=>{if(!u.step){i||(i=this.remapping(r,d+1),o=i.maps.length),o--,f.push(u);return}if(i){f.push(new tt(u.map));let p=u.step.map(i.slice(o)),h;p&&s.maybeStep(p).doc&&(h=s.mapping.maps[s.mapping.maps.length-1],c.push(new tt(h,void 0,void 0,c.length+f.length))),o--,h&&i.appendMap(h,o)}else s.maybeStep(u.step);if(u.selection)return l=i?u.selection.map(i.slice(o)):u.selection,a=new n(this.items.slice(0,r).append(f.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:s,selection:l}}addTransform(e,t,r,i){let o=[],s=this.eventCount,l=this.items,a=!i&&l.length?l.get(l.length-1):null;for(let f=0;fPm&&(l=Dm(l,c),s-=c),new n(l.append(o),s)}remapping(e,t){let r=new Kn;return this.items.forEach((i,o)=>{let s=i.mirrorOffset!=null&&o-i.mirrorOffset>=e?r.maps.length-i.mirrorOffset:void 0;r.appendMap(i.map,s)},e,t),r}addMaps(e){return this.eventCount==0?this:new n(this.items.append(e.map(t=>new tt(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-t),o=e.mapping,s=e.steps.length,l=this.eventCount;this.items.forEach(d=>{d.selection&&l--},i);let a=t;this.items.forEach(d=>{let p=o.getMirror(--a);if(p==null)return;s=Math.min(s,p);let h=o.maps[p];if(d.step){let m=e.steps[p].invert(e.docs[p]),g=d.selection&&d.selection.map(o.slice(a+1,p));g&&l++,r.push(new tt(h,m,g))}else r.push(new tt(h))},i);let c=[];for(let d=t;dNm&&(u=u.compress(this.items.length-r.length)),u}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),r=t.maps.length,i=[],o=0;return this.items.forEach((s,l)=>{if(l>=e)i.push(s),s.selection&&o++;else if(s.step){let a=s.step.map(t.slice(r)),c=a&&a.getMap();if(r--,c&&t.appendMap(c,r),a){let f=s.selection&&s.selection.map(t.slice(r));f&&o++;let u=new tt(c.invert(),a,f),d,p=i.length-1;(d=i.length&&i[p].merge(u))?i[p]=d:i.push(u)}}else s.map&&r--},this.items.length,0),new n(hs.from(i.reverse()),o)}};Zt.empty=new Zt(hs.empty,0);function Dm(n,e){let t;return n.forEach((r,i)=>{if(r.selection&&e--==0)return t=i,!1}),n.slice(t)}var tt=class n{constructor(e,t,r,i){this.map=e,this.step=t,this.selection=r,this.mirrorOffset=i}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new n(t.getMap().invert(),t,this.selection)}}},nt=class{constructor(e,t,r,i,o){this.done=e,this.undone=t,this.prevRanges=r,this.prevTime=i,this.prevComposition=o}},Pm=20;function Im(n,e,t,r){let i=t.getMeta(Xt),o;if(i)return i.historyState;t.getMeta(Lm)&&(n=new nt(n.done,n.undone,null,0,-1));let s=t.getMeta("appendedTransaction");if(t.steps.length==0)return n;if(s&&s.getMeta(Xt))return s.getMeta(Xt).redo?new nt(n.done.addTransform(t,void 0,r,wi(e)),n.undone,Jc(t.mapping.maps),n.prevTime,n.prevComposition):new nt(n.done,n.undone.addTransform(t,void 0,r,wi(e)),null,n.prevTime,n.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(s&&s.getMeta("addToHistory")===!1)){let l=t.getMeta("composition"),a=n.prevTime==0||!s&&n.prevComposition!=l&&(n.prevTime<(t.time||0)-r.newGroupDelay||!Rm(t,n.prevRanges)),c=s?ms(n.prevRanges,t.mapping):Jc(t.mapping.maps);return new nt(n.done.addTransform(t,a?e.selection.getBookmark():void 0,r,wi(e)),Zt.empty,c,t.time,l??n.prevComposition)}else return(o=t.getMeta("rebased"))?new nt(n.done.rebased(t,o),n.undone.rebased(t,o),ms(n.prevRanges,t.mapping),n.prevTime,n.prevComposition):new nt(n.done.addMaps(t.mapping.maps),n.undone.addMaps(t.mapping.maps),ms(n.prevRanges,t.mapping),n.prevTime,n.prevComposition)}function Rm(n,e){if(!e)return!1;if(!n.docChanged)return!0;let t=!1;return n.mapping.maps[0].forEach((r,i)=>{for(let o=0;o=e[o]&&(t=!0)}),t}function Jc(n){let e=[];for(let t=n.length-1;t>=0&&e.length==0;t--)n[t].forEach((r,i,o,s)=>e.push(o,s));return e}function ms(n,e){if(!n)return null;let t=[];for(let r=0;r{let i=Xt.getState(t);if(!i||(n?i.undone:i.done).eventCount==0)return!1;if(r){let o=Bm(i,t,n);o&&r(e?o.scrollIntoView():o)}return!0}}var ys=Mi(!1,!0),bs=Mi(!0,!0),Db=Mi(!1,!1),Pb=Mi(!0,!1);var Uc=te.create({name:"history",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:n,dispatch:e})=>ys(n,e),redo:()=>({state:n,dispatch:e})=>bs(n,e)}},addProseMirrorPlugins(){return[Kc(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-\u044F":()=>this.editor.commands.undo(),"Shift-Mod-\u044F":()=>this.editor.commands.redo()}}});var Gc=J.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{}}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:n}){return["hr",V(this.options.HTMLAttributes,n)]},addCommands(){return{setHorizontalRule:()=>({chain:n,state:e})=>{let{selection:t}=e,{$from:r,$to:i}=t,o=n();return r.parentOffset===0?o.insertContentAt({from:Math.max(r.pos-1,0),to:i.pos},{type:this.name}):Tc(t)?o.insertContentAt(i.pos,{type:this.name}):o.insertContent({type:this.name}),o.command(({tr:s,dispatch:l})=>{var a;if(l){let{$to:c}=s.selection,f=c.end();if(c.nodeAfter)c.nodeAfter.isTextblock?s.setSelection(P.create(s.doc,c.pos+1)):c.nodeAfter.isBlock?s.setSelection(A.create(s.doc,c.pos)):s.setSelection(P.create(s.doc,c.pos));else{let u=(a=c.parent.type.contentMatch.defaultType)===null||a===void 0?void 0:a.create();u&&(s.insert(f,u),s.setSelection(P.create(s.doc,f+1)))}s.scrollIntoView()}return!0}).run()}}},addInputRules(){return[Ec({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}});var Fm=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,zm=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,Vm=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,$m=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,Yc=_e.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:n=>n.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:n=>n.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:n}){return["em",V(this.options.HTMLAttributes,n),0]},addCommands(){return{setItalic:()=>({commands:n})=>n.setMark(this.name),toggleItalic:()=>({commands:n})=>n.toggleMark(this.name),unsetItalic:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[Qe({find:Fm,type:this.type}),Qe({find:Vm,type:this.type})]},addPasteRules(){return[et({find:zm,type:this.type}),et({find:$m,type:this.type})]}});var Xc=J.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:n}){return["li",V(this.options.HTMLAttributes,n),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}});var Hm="listItem",Zc="textStyle",Qc=/^(\d+)\.\s$/,ef=J.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:n=>n.hasAttribute("start")?parseInt(n.getAttribute("start")||"",10):1},type:{default:void 0,parseHTML:n=>n.getAttribute("type")}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:n}){let{start:e,...t}=n;return e===1?["ol",V(this.options.HTMLAttributes,t),0]:["ol",V(this.options.HTMLAttributes,n),0]},addCommands(){return{toggleOrderedList:()=>({commands:n,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(Hm,this.editor.getAttributes(Zc)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let n=Nt({find:Qc,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(n=Nt({find:Qc,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(Zc)}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1],editor:this.editor})),[n]}});var tf=J.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:n}){return["p",V(this.options.HTMLAttributes,n),0]},addCommands(){return{setParagraph:()=>({commands:n})=>n.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}});var Wm=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,jm=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,nf=_e.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:n=>n.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["s",V(this.options.HTMLAttributes,n),0]},addCommands(){return{setStrike:()=>({commands:n})=>n.setMark(this.name),toggleStrike:()=>({commands:n})=>n.toggleMark(this.name),unsetStrike:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[Qe({find:Wm,type:this.type})]},addPasteRules(){return[et({find:jm,type:this.type})]}});var rf=J.create({name:"text",group:"inline"});var of=te.create({name:"starterKit",addExtensions(){var n,e,t,r,i,o,s,l,a,c,f,u,d,p,h,m,g,b;let x=[];return this.options.bold!==!1&&x.push(Dc.configure((n=this.options)===null||n===void 0?void 0:n.bold)),this.options.blockquote!==!1&&x.push(Nc.configure((e=this.options)===null||e===void 0?void 0:e.blockquote)),this.options.bulletList!==!1&&x.push(Rc.configure((t=this.options)===null||t===void 0?void 0:t.bulletList)),this.options.code!==!1&&x.push(Bc.configure((r=this.options)===null||r===void 0?void 0:r.code)),this.options.codeBlock!==!1&&x.push(Lc.configure((i=this.options)===null||i===void 0?void 0:i.codeBlock)),this.options.document!==!1&&x.push(Fc.configure((o=this.options)===null||o===void 0?void 0:o.document)),this.options.dropcursor!==!1&&x.push(Vc.configure((s=this.options)===null||s===void 0?void 0:s.dropcursor)),this.options.gapcursor!==!1&&x.push(Hc.configure((l=this.options)===null||l===void 0?void 0:l.gapcursor)),this.options.hardBreak!==!1&&x.push(Wc.configure((a=this.options)===null||a===void 0?void 0:a.hardBreak)),this.options.heading!==!1&&x.push(jc.configure((c=this.options)===null||c===void 0?void 0:c.heading)),this.options.history!==!1&&x.push(Uc.configure((f=this.options)===null||f===void 0?void 0:f.history)),this.options.horizontalRule!==!1&&x.push(Gc.configure((u=this.options)===null||u===void 0?void 0:u.horizontalRule)),this.options.italic!==!1&&x.push(Yc.configure((d=this.options)===null||d===void 0?void 0:d.italic)),this.options.listItem!==!1&&x.push(Xc.configure((p=this.options)===null||p===void 0?void 0:p.listItem)),this.options.orderedList!==!1&&x.push(ef.configure((h=this.options)===null||h===void 0?void 0:h.orderedList)),this.options.paragraph!==!1&&x.push(tf.configure((m=this.options)===null||m===void 0?void 0:m.paragraph)),this.options.strike!==!1&&x.push(nf.configure((g=this.options)===null||g===void 0?void 0:g.strike)),this.options.text!==!1&&x.push(rf.configure((b=this.options)===null||b===void 0?void 0:b.text)),x}});function qm(n){var e;let{char:t,allowSpaces:r,allowToIncludeChar:i,allowedPrefixes:o,startOfLine:s,$position:l}=n,a=r&&!i,c=Ac(t),f=new RegExp(`\\s${c}$`),u=s?"^":"",d=i?"":c,p=a?new RegExp(`${u}${c}.*?(?=\\s${d}|$)`,"gm"):new RegExp(`${u}(?:^)?${c}[^\\s${d}]*`,"gm"),h=((e=l.nodeBefore)===null||e===void 0?void 0:e.isText)&&l.nodeBefore.text;if(!h)return null;let m=l.pos-h.length,g=Array.from(h.matchAll(p)).pop();if(!g||g.input===void 0||g.index===void 0)return null;let b=g.input.slice(Math.max(0,g.index-1),g.index),x=new RegExp(`^[${o?.join("")}\0]?$`).test(b);if(o!==null&&!x)return null;let w=m+g.index,y=w+g[0].length;return a&&f.test(h.slice(y-1,y+1))&&(g[0]+=" ",y+=1),w=l.pos?{range:{from:w,to:y},query:g[0].slice(t.length),text:g[0]}:null}var Jm=new X("suggestion");function sf({pluginKey:n=Jm,editor:e,char:t="@",allowSpaces:r=!1,allowToIncludeChar:i=!1,allowedPrefixes:o=[" "],startOfLine:s=!1,decorationTag:l="span",decorationClass:a="suggestion",command:c=()=>null,items:f=()=>[],render:u=()=>({}),allow:d=()=>!0,findSuggestionMatch:p=qm}){let h,m=u?.(),g=new q({key:n,view(){return{update:async(b,x)=>{var w,y,C,k,I,B,T;let N=(w=this.key)===null||w===void 0?void 0:w.getState(x),F=(y=this.key)===null||y===void 0?void 0:y.getState(b.state),H=N.active&&F.active&&N.range.from!==F.range.from,j=!N.active&&F.active,ge=N.active&&!F.active,fe=!j&&!ge&&N.query!==F.query,K=j||H&&fe,G=fe||H,Y=ge||H&&fe;if(!K&&!G&&!Y)return;let ue=Y&&!K?N:F,Ne=b.dom.querySelector(`[data-decoration-id="${ue.decorationId}"]`);h={editor:e,range:ue.range,query:ue.query,text:ue.text,items:[],command:De=>c({editor:e,range:ue.range,props:De}),decorationNode:Ne,clientRect:Ne?()=>{var De;let{decorationId:Pe}=(De=this.key)===null||De===void 0?void 0:De.getState(e.state),We=b.dom.querySelector(`[data-decoration-id="${Pe}"]`);return We?.getBoundingClientRect()||null}:null},K&&((C=m?.onBeforeStart)===null||C===void 0||C.call(m,h)),G&&((k=m?.onBeforeUpdate)===null||k===void 0||k.call(m,h)),(G||K)&&(h.items=await f({editor:e,query:ue.query})),Y&&((I=m?.onExit)===null||I===void 0||I.call(m,h)),G&&((B=m?.onUpdate)===null||B===void 0||B.call(m,h)),K&&((T=m?.onStart)===null||T===void 0||T.call(m,h))},destroy:()=>{var b;h&&((b=m?.onExit)===null||b===void 0||b.call(m,h))}}},state:{init(){return{active:!1,range:{from:0,to:0},query:null,text:null,composing:!1}},apply(b,x,w,y){let{isEditable:C}=e,{composing:k}=e.view,{selection:I}=b,{empty:B,from:T}=I,N={...x};if(N.composing=k,C&&(B||e.view.composing)){(Tx.range.to)&&!k&&!x.composing&&(N.active=!1);let F=p({char:t,allowSpaces:r,allowToIncludeChar:i,allowedPrefixes:o,startOfLine:s,$position:I.$from}),H=`id_${Math.floor(Math.random()*4294967295)}`;F&&d({editor:e,state:y,range:F.range,isActive:x.active})?(N.active=!0,N.decorationId=x.decorationId?x.decorationId:H,N.range=F.range,N.query=F.query,N.text=F.text):N.active=!1}else N.active=!1;return N.active||(N.decorationId=null,N.range={from:0,to:0},N.query=null,N.text=null),N}},props:{handleKeyDown(b,x){var w;let{active:y,range:C}=g.getState(b.state);return y&&((w=m?.onKeyDown)===null||w===void 0?void 0:w.call(m,{view:b,event:x,range:C}))||!1},decorations(b){let{active:x,range:w,decorationId:y}=g.getState(b);return x?se.create(b.doc,[Ae.inline(w.from,w.to,{nodeName:l,class:a,"data-decoration-id":y})]):null}}});return g}var _m=new X("mention"),lf=J.create({name:"mention",priority:101,addOptions(){return{HTMLAttributes:{},renderText({options:n,node:e}){var t;return`${n.suggestion.char}${(t=e.attrs.label)!==null&&t!==void 0?t:e.attrs.id}`},deleteTriggerWithBackspace:!1,renderHTML({options:n,node:e}){var t;return["span",V(this.HTMLAttributes,n.HTMLAttributes),`${n.suggestion.char}${(t=e.attrs.label)!==null&&t!==void 0?t:e.attrs.id}`]},suggestion:{char:"@",pluginKey:_m,command:({editor:n,range:e,props:t})=>{var r,i,o;let s=n.view.state.selection.$to.nodeAfter;((r=s?.text)===null||r===void 0?void 0:r.startsWith(" "))&&(e.to+=1),n.chain().focus().insertContentAt(e,[{type:this.name,attrs:t},{type:"text",text:" "}]).run(),(o=(i=n.view.dom.ownerDocument.defaultView)===null||i===void 0?void 0:i.getSelection())===null||o===void 0||o.collapseToEnd()},allow:({state:n,range:e})=>{let t=n.doc.resolve(e.from),r=n.schema.nodes[this.name];return!!t.parent.type.contentMatch.matchType(r)}}}},group:"inline",inline:!0,selectable:!1,atom:!0,addAttributes(){return{id:{default:null,parseHTML:n=>n.getAttribute("data-id"),renderHTML:n=>n.id?{"data-id":n.id}:{}},label:{default:null,parseHTML:n=>n.getAttribute("data-label"),renderHTML:n=>n.label?{"data-label":n.label}:{}}}},parseHTML(){return[{tag:`span[data-type="${this.name}"]`}]},renderHTML({node:n,HTMLAttributes:e}){if(this.options.renderLabel!==void 0)return console.warn("renderLabel is deprecated use renderText and renderHTML instead"),["span",V({"data-type":this.name},this.options.HTMLAttributes,e),this.options.renderLabel({options:this.options,node:n})];let t={...this.options};t.HTMLAttributes=V({"data-type":this.name},this.options.HTMLAttributes,e);let r=this.options.renderHTML({options:t,node:n});return typeof r=="string"?["span",V({"data-type":this.name},this.options.HTMLAttributes,e),r]:r},renderText({node:n}){return this.options.renderLabel!==void 0?(console.warn("renderLabel is deprecated use renderText and renderHTML instead"),this.options.renderLabel({options:this.options,node:n})):this.options.renderText({options:this.options,node:n})},addKeyboardShortcuts(){return{Backspace:()=>this.editor.commands.command(({tr:n,state:e})=>{let t=!1,{selection:r}=e,{empty:i,anchor:o}=r;return i?(e.doc.nodesBetween(o-1,o,(s,l)=>{if(s.type.name===this.name)return t=!0,n.insertText(this.options.deleteTriggerWithBackspace?"":this.options.suggestion.char||"",l,l+s.nodeSize),!1}),t):!1})}},addProseMirrorPlugins(){return[sf({editor:this.editor,...this.options.suggestion})]}});var af=te.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something \u2026",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[new q({key:new X("placeholder"),props:{decorations:({doc:n,selection:e})=>{let t=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:r}=e,i=[];if(!t)return null;let o=this.editor.isEmpty;return n.descendants((s,l)=>{let a=r>=l&&r<=l+s.nodeSize,c=!s.isLeaf&&fr(s);if((a||!this.options.showOnlyCurrent)&&c){let f=[this.options.emptyNodeClass];o&&f.push(this.options.emptyEditorClass);let u=Ae.node(l,l+s.nodeSize,{class:f.join(" "),"data-placeholder":typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:s,pos:l,hasAnchor:a}):this.options.placeholder});i.push(u)}return this.options.includeChildren}),se.create(n,i)}}})]}});var U="top",re="bottom",ne="right",Z="left",Ci="auto",Dt=[U,re,ne,Z],yt="start",Qt="end",cf="clippingParents",Oi="viewport",En="popper",ff="reference",vs=Dt.reduce(function(n,e){return n.concat([e+"-"+yt,e+"-"+Qt])},[]),Ti=[].concat(Dt,[Ci]).reduce(function(n,e){return n.concat([e,e+"-"+yt,e+"-"+Qt])},[]),Km="beforeRead",Um="read",Gm="afterRead",Ym="beforeMain",Xm="main",Zm="afterMain",Qm="beforeWrite",eg="write",tg="afterWrite",uf=[Km,Um,Gm,Ym,Xm,Zm,Qm,eg,tg];function ae(n){return n?(n.nodeName||"").toLowerCase():null}function _(n){if(n==null)return window;if(n.toString()!=="[object Window]"){var e=n.ownerDocument;return e&&e.defaultView||window}return n}function Ve(n){var e=_(n).Element;return n instanceof e||n instanceof Element}function ie(n){var e=_(n).HTMLElement;return n instanceof e||n instanceof HTMLElement}function An(n){if(typeof ShadowRoot>"u")return!1;var e=_(n).ShadowRoot;return n instanceof e||n instanceof ShadowRoot}function ng(n){var e=n.state;Object.keys(e.elements).forEach(function(t){var r=e.styles[t]||{},i=e.attributes[t]||{},o=e.elements[t];!ie(o)||!ae(o)||(Object.assign(o.style,r),Object.keys(i).forEach(function(s){var l=i[s];l===!1?o.removeAttribute(s):o.setAttribute(s,l===!0?"":l)}))})}function rg(n){var e=n.state,t={popper:{position:e.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};return Object.assign(e.elements.popper.style,t.popper),e.styles=t,e.elements.arrow&&Object.assign(e.elements.arrow.style,t.arrow),function(){Object.keys(e.elements).forEach(function(r){var i=e.elements[r],o=e.attributes[r]||{},s=Object.keys(e.styles.hasOwnProperty(r)?e.styles[r]:t[r]),l=s.reduce(function(a,c){return a[c]="",a},{});!ie(i)||!ae(i)||(Object.assign(i.style,l),Object.keys(o).forEach(function(a){i.removeAttribute(a)}))})}}var dr={name:"applyStyles",enabled:!0,phase:"write",fn:ng,effect:rg,requires:["computeStyles"]};function ce(n){return n.split("-")[0]}var Ke=Math.max,en=Math.min,bt=Math.round;function Nn(){var n=navigator.userAgentData;return n!=null&&n.brands&&Array.isArray(n.brands)?n.brands.map(function(e){return e.brand+"/"+e.version}).join(" "):navigator.userAgent}function pr(){return!/^((?!chrome|android).)*safari/i.test(Nn())}function $e(n,e,t){e===void 0&&(e=!1),t===void 0&&(t=!1);var r=n.getBoundingClientRect(),i=1,o=1;e&&ie(n)&&(i=n.offsetWidth>0&&bt(r.width)/n.offsetWidth||1,o=n.offsetHeight>0&&bt(r.height)/n.offsetHeight||1);var s=Ve(n)?_(n):window,l=s.visualViewport,a=!pr()&&t,c=(r.left+(a&&l?l.offsetLeft:0))/i,f=(r.top+(a&&l?l.offsetTop:0))/o,u=r.width/i,d=r.height/o;return{width:u,height:d,top:f,right:c+u,bottom:f+d,left:c,x:c,y:f}}function tn(n){var e=$e(n),t=n.offsetWidth,r=n.offsetHeight;return Math.abs(e.width-t)<=1&&(t=e.width),Math.abs(e.height-r)<=1&&(r=e.height),{x:n.offsetLeft,y:n.offsetTop,width:t,height:r}}function hr(n,e){var t=e.getRootNode&&e.getRootNode();if(n.contains(e))return!0;if(t&&An(t)){var r=e;do{if(r&&n.isSameNode(r))return!0;r=r.parentNode||r.host}while(r)}return!1}function Te(n){return _(n).getComputedStyle(n)}function xs(n){return["table","td","th"].indexOf(ae(n))>=0}function me(n){return((Ve(n)?n.ownerDocument:n.document)||window.document).documentElement}function vt(n){return ae(n)==="html"?n:n.assignedSlot||n.parentNode||(An(n)?n.host:null)||me(n)}function df(n){return!ie(n)||Te(n).position==="fixed"?null:n.offsetParent}function ig(n){var e=/firefox/i.test(Nn()),t=/Trident/i.test(Nn());if(t&&ie(n)){var r=Te(n);if(r.position==="fixed")return null}var i=vt(n);for(An(i)&&(i=i.host);ie(i)&&["html","body"].indexOf(ae(i))<0;){var o=Te(i);if(o.transform!=="none"||o.perspective!=="none"||o.contain==="paint"||["transform","perspective"].indexOf(o.willChange)!==-1||e&&o.willChange==="filter"||e&&o.filter&&o.filter!=="none")return i;i=i.parentNode}return null}function Ue(n){for(var e=_(n),t=df(n);t&&xs(t)&&Te(t).position==="static";)t=df(t);return t&&(ae(t)==="html"||ae(t)==="body"&&Te(t).position==="static")?e:t||ig(n)||e}function nn(n){return["top","bottom"].indexOf(n)>=0?"x":"y"}function rn(n,e,t){return Ke(n,en(e,t))}function pf(n,e,t){var r=rn(n,e,t);return r>t?t:r}function mr(){return{top:0,right:0,bottom:0,left:0}}function gr(n){return Object.assign({},mr(),n)}function yr(n,e){return e.reduce(function(t,r){return t[r]=n,t},{})}var og=function(e,t){return e=typeof e=="function"?e(Object.assign({},t.rects,{placement:t.placement})):e,gr(typeof e!="number"?e:yr(e,Dt))};function sg(n){var e,t=n.state,r=n.name,i=n.options,o=t.elements.arrow,s=t.modifiersData.popperOffsets,l=ce(t.placement),a=nn(l),c=[Z,ne].indexOf(l)>=0,f=c?"height":"width";if(!(!o||!s)){var u=og(i.padding,t),d=tn(o),p=a==="y"?U:Z,h=a==="y"?re:ne,m=t.rects.reference[f]+t.rects.reference[a]-s[a]-t.rects.popper[f],g=s[a]-t.rects.reference[a],b=Ue(o),x=b?a==="y"?b.clientHeight||0:b.clientWidth||0:0,w=m/2-g/2,y=u[p],C=x-d[f]-u[h],k=x/2-d[f]/2+w,I=rn(y,k,C),B=a;t.modifiersData[r]=(e={},e[B]=I,e.centerOffset=I-k,e)}}function lg(n){var e=n.state,t=n.options,r=t.element,i=r===void 0?"[data-popper-arrow]":r;i!=null&&(typeof i=="string"&&(i=e.elements.popper.querySelector(i),!i)||hr(e.elements.popper,i)&&(e.elements.arrow=i))}var hf={name:"arrow",enabled:!0,phase:"main",fn:sg,effect:lg,requires:["popperOffsets"],requiresIfExists:["preventOverflow"]};function He(n){return n.split("-")[1]}var ag={top:"auto",right:"auto",bottom:"auto",left:"auto"};function cg(n,e){var t=n.x,r=n.y,i=e.devicePixelRatio||1;return{x:bt(t*i)/i||0,y:bt(r*i)/i||0}}function mf(n){var e,t=n.popper,r=n.popperRect,i=n.placement,o=n.variation,s=n.offsets,l=n.position,a=n.gpuAcceleration,c=n.adaptive,f=n.roundOffsets,u=n.isFixed,d=s.x,p=d===void 0?0:d,h=s.y,m=h===void 0?0:h,g=typeof f=="function"?f({x:p,y:m}):{x:p,y:m};p=g.x,m=g.y;var b=s.hasOwnProperty("x"),x=s.hasOwnProperty("y"),w=Z,y=U,C=window;if(c){var k=Ue(t),I="clientHeight",B="clientWidth";if(k===_(t)&&(k=me(t),Te(k).position!=="static"&&l==="absolute"&&(I="scrollHeight",B="scrollWidth")),k=k,i===U||(i===Z||i===ne)&&o===Qt){y=re;var T=u&&k===C&&C.visualViewport?C.visualViewport.height:k[I];m-=T-r.height,m*=a?1:-1}if(i===Z||(i===U||i===re)&&o===Qt){w=ne;var N=u&&k===C&&C.visualViewport?C.visualViewport.width:k[B];p-=N-r.width,p*=a?1:-1}}var F=Object.assign({position:l},c&&ag),H=f===!0?cg({x:p,y:m},_(t)):{x:p,y:m};if(p=H.x,m=H.y,a){var j;return Object.assign({},F,(j={},j[y]=x?"0":"",j[w]=b?"0":"",j.transform=(C.devicePixelRatio||1)<=1?"translate("+p+"px, "+m+"px)":"translate3d("+p+"px, "+m+"px, 0)",j))}return Object.assign({},F,(e={},e[y]=x?m+"px":"",e[w]=b?p+"px":"",e.transform="",e))}function fg(n){var e=n.state,t=n.options,r=t.gpuAcceleration,i=r===void 0?!0:r,o=t.adaptive,s=o===void 0?!0:o,l=t.roundOffsets,a=l===void 0?!0:l,c={placement:ce(e.placement),variation:He(e.placement),popper:e.elements.popper,popperRect:e.rects.popper,gpuAcceleration:i,isFixed:e.options.strategy==="fixed"};e.modifiersData.popperOffsets!=null&&(e.styles.popper=Object.assign({},e.styles.popper,mf(Object.assign({},c,{offsets:e.modifiersData.popperOffsets,position:e.options.strategy,adaptive:s,roundOffsets:a})))),e.modifiersData.arrow!=null&&(e.styles.arrow=Object.assign({},e.styles.arrow,mf(Object.assign({},c,{offsets:e.modifiersData.arrow,position:"absolute",adaptive:!1,roundOffsets:a})))),e.attributes.popper=Object.assign({},e.attributes.popper,{"data-popper-placement":e.placement})}var gf={name:"computeStyles",enabled:!0,phase:"beforeWrite",fn:fg,data:{}};var Ei={passive:!0};function ug(n){var e=n.state,t=n.instance,r=n.options,i=r.scroll,o=i===void 0?!0:i,s=r.resize,l=s===void 0?!0:s,a=_(e.elements.popper),c=[].concat(e.scrollParents.reference,e.scrollParents.popper);return o&&c.forEach(function(f){f.addEventListener("scroll",t.update,Ei)}),l&&a.addEventListener("resize",t.update,Ei),function(){o&&c.forEach(function(f){f.removeEventListener("scroll",t.update,Ei)}),l&&a.removeEventListener("resize",t.update,Ei)}}var yf={name:"eventListeners",enabled:!0,phase:"write",fn:function(){},effect:ug,data:{}};var dg={left:"right",right:"left",bottom:"top",top:"bottom"};function Dn(n){return n.replace(/left|right|bottom|top/g,function(e){return dg[e]})}var pg={start:"end",end:"start"};function Ai(n){return n.replace(/start|end/g,function(e){return pg[e]})}function on(n){var e=_(n),t=e.pageXOffset,r=e.pageYOffset;return{scrollLeft:t,scrollTop:r}}function sn(n){return $e(me(n)).left+on(n).scrollLeft}function ks(n,e){var t=_(n),r=me(n),i=t.visualViewport,o=r.clientWidth,s=r.clientHeight,l=0,a=0;if(i){o=i.width,s=i.height;var c=pr();(c||!c&&e==="fixed")&&(l=i.offsetLeft,a=i.offsetTop)}return{width:o,height:s,x:l+sn(n),y:a}}function Ss(n){var e,t=me(n),r=on(n),i=(e=n.ownerDocument)==null?void 0:e.body,o=Ke(t.scrollWidth,t.clientWidth,i?i.scrollWidth:0,i?i.clientWidth:0),s=Ke(t.scrollHeight,t.clientHeight,i?i.scrollHeight:0,i?i.clientHeight:0),l=-r.scrollLeft+sn(n),a=-r.scrollTop;return Te(i||t).direction==="rtl"&&(l+=Ke(t.clientWidth,i?i.clientWidth:0)-o),{width:o,height:s,x:l,y:a}}function ln(n){var e=Te(n),t=e.overflow,r=e.overflowX,i=e.overflowY;return/auto|scroll|overlay|hidden/.test(t+i+r)}function Ni(n){return["html","body","#document"].indexOf(ae(n))>=0?n.ownerDocument.body:ie(n)&&ln(n)?n:Ni(vt(n))}function Pt(n,e){var t;e===void 0&&(e=[]);var r=Ni(n),i=r===((t=n.ownerDocument)==null?void 0:t.body),o=_(r),s=i?[o].concat(o.visualViewport||[],ln(r)?r:[]):r,l=e.concat(s);return i?l:l.concat(Pt(vt(s)))}function Pn(n){return Object.assign({},n,{left:n.x,top:n.y,right:n.x+n.width,bottom:n.y+n.height})}function hg(n,e){var t=$e(n,!1,e==="fixed");return t.top=t.top+n.clientTop,t.left=t.left+n.clientLeft,t.bottom=t.top+n.clientHeight,t.right=t.left+n.clientWidth,t.width=n.clientWidth,t.height=n.clientHeight,t.x=t.left,t.y=t.top,t}function bf(n,e,t){return e===Oi?Pn(ks(n,t)):Ve(e)?hg(e,t):Pn(Ss(me(n)))}function mg(n){var e=Pt(vt(n)),t=["absolute","fixed"].indexOf(Te(n).position)>=0,r=t&&ie(n)?Ue(n):n;return Ve(r)?e.filter(function(i){return Ve(i)&&hr(i,r)&&ae(i)!=="body"}):[]}function ws(n,e,t,r){var i=e==="clippingParents"?mg(n):[].concat(e),o=[].concat(i,[t]),s=o[0],l=o.reduce(function(a,c){var f=bf(n,c,r);return a.top=Ke(f.top,a.top),a.right=en(f.right,a.right),a.bottom=en(f.bottom,a.bottom),a.left=Ke(f.left,a.left),a},bf(n,s,r));return l.width=l.right-l.left,l.height=l.bottom-l.top,l.x=l.left,l.y=l.top,l}function br(n){var e=n.reference,t=n.element,r=n.placement,i=r?ce(r):null,o=r?He(r):null,s=e.x+e.width/2-t.width/2,l=e.y+e.height/2-t.height/2,a;switch(i){case U:a={x:s,y:e.y-t.height};break;case re:a={x:s,y:e.y+e.height};break;case ne:a={x:e.x+e.width,y:l};break;case Z:a={x:e.x-t.width,y:l};break;default:a={x:e.x,y:e.y}}var c=i?nn(i):null;if(c!=null){var f=c==="y"?"height":"width";switch(o){case yt:a[c]=a[c]-(e[f]/2-t[f]/2);break;case Qt:a[c]=a[c]+(e[f]/2-t[f]/2);break;default:}}return a}function Ge(n,e){e===void 0&&(e={});var t=e,r=t.placement,i=r===void 0?n.placement:r,o=t.strategy,s=o===void 0?n.strategy:o,l=t.boundary,a=l===void 0?cf:l,c=t.rootBoundary,f=c===void 0?Oi:c,u=t.elementContext,d=u===void 0?En:u,p=t.altBoundary,h=p===void 0?!1:p,m=t.padding,g=m===void 0?0:m,b=gr(typeof g!="number"?g:yr(g,Dt)),x=d===En?ff:En,w=n.rects.popper,y=n.elements[h?x:d],C=ws(Ve(y)?y:y.contextElement||me(n.elements.popper),a,f,s),k=$e(n.elements.reference),I=br({reference:k,element:w,strategy:"absolute",placement:i}),B=Pn(Object.assign({},w,I)),T=d===En?B:k,N={top:C.top-T.top+b.top,bottom:T.bottom-C.bottom+b.bottom,left:C.left-T.left+b.left,right:T.right-C.right+b.right},F=n.modifiersData.offset;if(d===En&&F){var H=F[i];Object.keys(N).forEach(function(j){var ge=[ne,re].indexOf(j)>=0?1:-1,fe=[U,re].indexOf(j)>=0?"y":"x";N[j]+=H[fe]*ge})}return N}function Ms(n,e){e===void 0&&(e={});var t=e,r=t.placement,i=t.boundary,o=t.rootBoundary,s=t.padding,l=t.flipVariations,a=t.allowedAutoPlacements,c=a===void 0?Ti:a,f=He(r),u=f?l?vs:vs.filter(function(h){return He(h)===f}):Dt,d=u.filter(function(h){return c.indexOf(h)>=0});d.length===0&&(d=u);var p=d.reduce(function(h,m){return h[m]=Ge(n,{placement:m,boundary:i,rootBoundary:o,padding:s})[ce(m)],h},{});return Object.keys(p).sort(function(h,m){return p[h]-p[m]})}function gg(n){if(ce(n)===Ci)return[];var e=Dn(n);return[Ai(n),e,Ai(e)]}function yg(n){var e=n.state,t=n.options,r=n.name;if(!e.modifiersData[r]._skip){for(var i=t.mainAxis,o=i===void 0?!0:i,s=t.altAxis,l=s===void 0?!0:s,a=t.fallbackPlacements,c=t.padding,f=t.boundary,u=t.rootBoundary,d=t.altBoundary,p=t.flipVariations,h=p===void 0?!0:p,m=t.allowedAutoPlacements,g=e.options.placement,b=ce(g),x=b===g,w=a||(x||!h?[Dn(g)]:gg(g)),y=[g].concat(w).reduce(function(it,je){return it.concat(ce(je)===Ci?Ms(e,{placement:je,boundary:f,rootBoundary:u,padding:c,flipVariations:h,allowedAutoPlacements:m}):je)},[]),C=e.rects.reference,k=e.rects.popper,I=new Map,B=!0,T=y[0],N=0;N=0,fe=ge?"width":"height",K=Ge(e,{placement:F,boundary:f,rootBoundary:u,altBoundary:d,padding:c}),G=ge?j?ne:Z:j?re:U;C[fe]>k[fe]&&(G=Dn(G));var Y=Dn(G),ue=[];if(o&&ue.push(K[H]<=0),l&&ue.push(K[G]<=0,K[Y]<=0),ue.every(function(it){return it})){T=F,B=!1;break}I.set(F,ue)}if(B)for(var Ne=h?3:1,De=function(je){var ot=y.find(function(cn){var st=I.get(cn);if(st)return st.slice(0,je).every(function(fn){return fn})});if(ot)return T=ot,"break"},Pe=Ne;Pe>0;Pe--){var We=De(Pe);if(We==="break")break}e.placement!==T&&(e.modifiersData[r]._skip=!0,e.placement=T,e.reset=!0)}}var vf={name:"flip",enabled:!0,phase:"main",fn:yg,requiresIfExists:["offset"],data:{_skip:!1}};function xf(n,e,t){return t===void 0&&(t={x:0,y:0}),{top:n.top-e.height-t.y,right:n.right-e.width+t.x,bottom:n.bottom-e.height+t.y,left:n.left-e.width-t.x}}function kf(n){return[U,ne,re,Z].some(function(e){return n[e]>=0})}function bg(n){var e=n.state,t=n.name,r=e.rects.reference,i=e.rects.popper,o=e.modifiersData.preventOverflow,s=Ge(e,{elementContext:"reference"}),l=Ge(e,{altBoundary:!0}),a=xf(s,r),c=xf(l,i,o),f=kf(a),u=kf(c);e.modifiersData[t]={referenceClippingOffsets:a,popperEscapeOffsets:c,isReferenceHidden:f,hasPopperEscaped:u},e.attributes.popper=Object.assign({},e.attributes.popper,{"data-popper-reference-hidden":f,"data-popper-escaped":u})}var Sf={name:"hide",enabled:!0,phase:"main",requiresIfExists:["preventOverflow"],fn:bg};function vg(n,e,t){var r=ce(n),i=[Z,U].indexOf(r)>=0?-1:1,o=typeof t=="function"?t(Object.assign({},e,{placement:n})):t,s=o[0],l=o[1];return s=s||0,l=(l||0)*i,[Z,ne].indexOf(r)>=0?{x:l,y:s}:{x:s,y:l}}function xg(n){var e=n.state,t=n.options,r=n.name,i=t.offset,o=i===void 0?[0,0]:i,s=Ti.reduce(function(f,u){return f[u]=vg(u,e.rects,o),f},{}),l=s[e.placement],a=l.x,c=l.y;e.modifiersData.popperOffsets!=null&&(e.modifiersData.popperOffsets.x+=a,e.modifiersData.popperOffsets.y+=c),e.modifiersData[r]=s}var wf={name:"offset",enabled:!0,phase:"main",requires:["popperOffsets"],fn:xg};function kg(n){var e=n.state,t=n.name;e.modifiersData[t]=br({reference:e.rects.reference,element:e.rects.popper,strategy:"absolute",placement:e.placement})}var Mf={name:"popperOffsets",enabled:!0,phase:"read",fn:kg,data:{}};function Cs(n){return n==="x"?"y":"x"}function Sg(n){var e=n.state,t=n.options,r=n.name,i=t.mainAxis,o=i===void 0?!0:i,s=t.altAxis,l=s===void 0?!1:s,a=t.boundary,c=t.rootBoundary,f=t.altBoundary,u=t.padding,d=t.tether,p=d===void 0?!0:d,h=t.tetherOffset,m=h===void 0?0:h,g=Ge(e,{boundary:a,rootBoundary:c,padding:u,altBoundary:f}),b=ce(e.placement),x=He(e.placement),w=!x,y=nn(b),C=Cs(y),k=e.modifiersData.popperOffsets,I=e.rects.reference,B=e.rects.popper,T=typeof m=="function"?m(Object.assign({},e.rects,{placement:e.placement})):m,N=typeof T=="number"?{mainAxis:T,altAxis:T}:Object.assign({mainAxis:0,altAxis:0},T),F=e.modifiersData.offset?e.modifiersData.offset[e.placement]:null,H={x:0,y:0};if(k){if(o){var j,ge=y==="y"?U:Z,fe=y==="y"?re:ne,K=y==="y"?"height":"width",G=k[y],Y=G+g[ge],ue=G-g[fe],Ne=p?-B[K]/2:0,De=x===yt?I[K]:B[K],Pe=x===yt?-B[K]:-I[K],We=e.elements.arrow,it=p&&We?tn(We):{width:0,height:0},je=e.modifiersData["arrow#persistent"]?e.modifiersData["arrow#persistent"].padding:mr(),ot=je[ge],cn=je[fe],st=rn(0,I[K],it[K]),fn=w?I[K]/2-Ne-st-ot-N.mainAxis:De-st-ot-N.mainAxis,xt=w?-I[K]/2+Ne+st+cn+N.mainAxis:Pe+st+cn+N.mainAxis,un=e.elements.arrow&&Ue(e.elements.arrow),kr=un?y==="y"?un.clientTop||0:un.clientLeft||0:0,Rn=(j=F?.[y])!=null?j:0,Sr=G+fn-Rn-kr,wr=G+xt-Rn,Bn=rn(p?en(Y,Sr):Y,G,p?Ke(ue,wr):ue);k[y]=Bn,H[y]=Bn-G}if(l){var Ln,Mr=y==="x"?U:Z,Cr=y==="x"?re:ne,lt=k[C],kt=C==="y"?"height":"width",Fn=lt+g[Mr],It=lt-g[Cr],zn=[U,Z].indexOf(b)!==-1,Or=(Ln=F?.[C])!=null?Ln:0,Tr=zn?Fn:lt-I[kt]-B[kt]-Or+N.altAxis,Er=zn?lt+I[kt]+B[kt]-Or-N.altAxis:It,Ar=p&&zn?pf(Tr,lt,Er):rn(p?Tr:Fn,lt,p?Er:It);k[C]=Ar,H[C]=Ar-lt}e.modifiersData[r]=H}}var Cf={name:"preventOverflow",enabled:!0,phase:"main",fn:Sg,requiresIfExists:["offset"]};function Os(n){return{scrollLeft:n.scrollLeft,scrollTop:n.scrollTop}}function Ts(n){return n===_(n)||!ie(n)?on(n):Os(n)}function wg(n){var e=n.getBoundingClientRect(),t=bt(e.width)/n.offsetWidth||1,r=bt(e.height)/n.offsetHeight||1;return t!==1||r!==1}function Es(n,e,t){t===void 0&&(t=!1);var r=ie(e),i=ie(e)&&wg(e),o=me(e),s=$e(n,i,t),l={scrollLeft:0,scrollTop:0},a={x:0,y:0};return(r||!r&&!t)&&((ae(e)!=="body"||ln(o))&&(l=Ts(e)),ie(e)?(a=$e(e,!0),a.x+=e.clientLeft,a.y+=e.clientTop):o&&(a.x=sn(o))),{x:s.left+l.scrollLeft-a.x,y:s.top+l.scrollTop-a.y,width:s.width,height:s.height}}function Mg(n){var e=new Map,t=new Set,r=[];n.forEach(function(o){e.set(o.name,o)});function i(o){t.add(o.name);var s=[].concat(o.requires||[],o.requiresIfExists||[]);s.forEach(function(l){if(!t.has(l)){var a=e.get(l);a&&i(a)}}),r.push(o)}return n.forEach(function(o){t.has(o.name)||i(o)}),r}function As(n){var e=Mg(n);return uf.reduce(function(t,r){return t.concat(e.filter(function(i){return i.phase===r}))},[])}function Ns(n){var e;return function(){return e||(e=new Promise(function(t){Promise.resolve().then(function(){e=void 0,t(n())})})),e}}function Ds(n){var e=n.reduce(function(t,r){var i=t[r.name];return t[r.name]=i?Object.assign({},i,r,{options:Object.assign({},i.options,r.options),data:Object.assign({},i.data,r.data)}):r,t},{});return Object.keys(e).map(function(t){return e[t]})}var Of={placement:"bottom",modifiers:[],strategy:"absolute"};function Tf(){for(var n=arguments.length,e=new Array(n),t=0;t-1}function Wf(n,e){return typeof n=="function"?n.apply(void 0,e):n}function Af(n,e){if(e===0)return n;var t;return function(r){clearTimeout(t),t=setTimeout(function(){n(r)},e)}}function Eg(n){return n.split(/\s+/).filter(Boolean)}function In(n){return[].concat(n)}function Nf(n,e){n.indexOf(e)===-1&&n.push(e)}function Ag(n){return n.filter(function(e,t){return n.indexOf(e)===t})}function Ng(n){return n.split("-")[0]}function Pi(n){return[].slice.call(n)}function Df(n){return Object.keys(n).reduce(function(e,t){return n[t]!==void 0&&(e[t]=n[t]),e},{})}function vr(){return document.createElement("div")}function Ii(n){return["Element","Fragment"].some(function(e){return Vs(n,e)})}function Dg(n){return Vs(n,"NodeList")}function Pg(n){return Vs(n,"MouseEvent")}function Ig(n){return!!(n&&n._tippy&&n._tippy.reference===n)}function Rg(n){return Ii(n)?[n]:Dg(n)?Pi(n):Array.isArray(n)?n:Pi(document.querySelectorAll(n))}function Rs(n,e){n.forEach(function(t){t&&(t.style.transitionDuration=e+"ms")})}function Pf(n,e){n.forEach(function(t){t&&t.setAttribute("data-state",e)})}function Bg(n){var e,t=In(n),r=t[0];return r!=null&&(e=r.ownerDocument)!=null&&e.body?r.ownerDocument:document}function Lg(n,e){var t=e.clientX,r=e.clientY;return n.every(function(i){var o=i.popperRect,s=i.popperState,l=i.props,a=l.interactiveBorder,c=Ng(s.placement),f=s.modifiersData.offset;if(!f)return!0;var u=c==="bottom"?f.top.y:0,d=c==="top"?f.bottom.y:0,p=c==="right"?f.left.x:0,h=c==="left"?f.right.x:0,m=o.top-r+u>a,g=r-o.bottom-d>a,b=o.left-t+p>a,x=t-o.right-h>a;return m||g||b||x})}function Bs(n,e,t){var r=e+"EventListener";["transitionend","webkitTransitionEnd"].forEach(function(i){n[r](i,t)})}function If(n,e){for(var t=e;t;){var r;if(n.contains(t))return!0;t=t.getRootNode==null||(r=t.getRootNode())==null?void 0:r.host}return!1}var rt={isTouch:!1},Rf=0;function Fg(){rt.isTouch||(rt.isTouch=!0,window.performance&&document.addEventListener("mousemove",jf))}function jf(){var n=performance.now();n-Rf<20&&(rt.isTouch=!1,document.removeEventListener("mousemove",jf)),Rf=n}function zg(){var n=document.activeElement;if(Ig(n)){var e=n._tippy;n.blur&&!e.state.isVisible&&n.blur()}}function Vg(){document.addEventListener("touchstart",Fg,an),window.addEventListener("blur",zg)}var $g=typeof window<"u"&&typeof document<"u",Hg=$g?!!window.msCrypto:!1;var Wg={animateFill:!1,followCursor:!1,inlinePositioning:!1,sticky:!1},jg={allowHTML:!1,animation:"fade",arrow:!0,content:"",inertia:!1,maxWidth:350,role:"tooltip",theme:"",zIndex:9999},Ye=Object.assign({appendTo:Hf,aria:{content:"auto",expanded:"auto"},delay:0,duration:[300,250],getReferenceClientRect:null,hideOnClick:!0,ignoreAttributes:!1,interactive:!1,interactiveBorder:2,interactiveDebounce:0,moveTransition:"",offset:[0,10],onAfterUpdate:function(){},onBeforeUpdate:function(){},onCreate:function(){},onDestroy:function(){},onHidden:function(){},onHide:function(){},onMount:function(){},onShow:function(){},onShown:function(){},onTrigger:function(){},onUntrigger:function(){},onClickOutside:function(){},placement:"top",plugins:[],popperOptions:{},render:null,showOnCreate:!1,touch:!0,trigger:"mouseenter focus",triggerTarget:null},Wg,jg),qg=Object.keys(Ye),Jg=function(e){var t=Object.keys(e);t.forEach(function(r){Ye[r]=e[r]})};function qf(n){var e=n.plugins||[],t=e.reduce(function(r,i){var o=i.name,s=i.defaultValue;if(o){var l;r[o]=n[o]!==void 0?n[o]:(l=Ye[o])!=null?l:s}return r},{});return Object.assign({},n,t)}function _g(n,e){var t=e?Object.keys(qf(Object.assign({},Ye,{plugins:e}))):qg,r=t.reduce(function(i,o){var s=(n.getAttribute("data-tippy-"+o)||"").trim();if(!s)return i;if(o==="content")i[o]=s;else try{i[o]=JSON.parse(s)}catch{i[o]=s}return i},{});return r}function Bf(n,e){var t=Object.assign({},e,{content:Wf(e.content,[n])},e.ignoreAttributes?{}:_g(n,e.plugins));return t.aria=Object.assign({},Ye.aria,t.aria),t.aria={expanded:t.aria.expanded==="auto"?e.interactive:t.aria.expanded,content:t.aria.content==="auto"?e.interactive?null:"describedby":t.aria.content},t}var Kg=function(){return"innerHTML"};function Fs(n,e){n[Kg()]=e}function Lf(n){var e=vr();return n===!0?e.className=Vf:(e.className=$f,Ii(n)?e.appendChild(n):Fs(e,n)),e}function Ff(n,e){Ii(e.content)?(Fs(n,""),n.appendChild(e.content)):typeof e.content!="function"&&(e.allowHTML?Fs(n,e.content):n.textContent=e.content)}function zs(n){var e=n.firstElementChild,t=Pi(e.children);return{box:e,content:t.find(function(r){return r.classList.contains(zf)}),arrow:t.find(function(r){return r.classList.contains(Vf)||r.classList.contains($f)}),backdrop:t.find(function(r){return r.classList.contains(Tg)})}}function Jf(n){var e=vr(),t=vr();t.className=Og,t.setAttribute("data-state","hidden"),t.setAttribute("tabindex","-1");var r=vr();r.className=zf,r.setAttribute("data-state","hidden"),Ff(r,n.props),e.appendChild(t),t.appendChild(r),i(n.props,n.props);function i(o,s){var l=zs(e),a=l.box,c=l.content,f=l.arrow;s.theme?a.setAttribute("data-theme",s.theme):a.removeAttribute("data-theme"),typeof s.animation=="string"?a.setAttribute("data-animation",s.animation):a.removeAttribute("data-animation"),s.inertia?a.setAttribute("data-inertia",""):a.removeAttribute("data-inertia"),a.style.maxWidth=typeof s.maxWidth=="number"?s.maxWidth+"px":s.maxWidth,s.role?a.setAttribute("role",s.role):a.removeAttribute("role"),(o.content!==s.content||o.allowHTML!==s.allowHTML)&&Ff(c,n.props),s.arrow?f?o.arrow!==s.arrow&&(a.removeChild(f),a.appendChild(Lf(s.arrow))):a.appendChild(Lf(s.arrow)):f&&a.removeChild(f)}return{popper:e,onUpdate:i}}Jf.$$tippy=!0;var Ug=1,Di=[],Ls=[];function Gg(n,e){var t=Bf(n,Object.assign({},Ye,qf(Df(e)))),r,i,o,s=!1,l=!1,a=!1,c=!1,f,u,d,p=[],h=Af(Sr,t.interactiveDebounce),m,g=Ug++,b=null,x=Ag(t.plugins),w={isEnabled:!0,isVisible:!1,isDestroyed:!1,isMounted:!1,isShown:!1},y={id:g,reference:n,popper:vr(),popperInstance:b,props:t,state:w,plugins:x,clearDelayTimeouts:Tr,setProps:Er,setContent:Ar,show:Uf,hide:Gf,hideWithInteractivity:Yf,enable:zn,disable:Or,unmount:Xf,destroy:Zf};if(!t.render)return y;var C=t.render(y),k=C.popper,I=C.onUpdate;k.setAttribute("data-tippy-root",""),k.id="tippy-"+y.id,y.popper=k,n._tippy=y,k._tippy=y;var B=x.map(function(v){return v.fn(y)}),T=n.hasAttribute("aria-expanded");return un(),Ne(),G(),Y("onCreate",[y]),t.showOnCreate&&Fn(),k.addEventListener("mouseenter",function(){y.props.interactive&&y.state.isVisible&&y.clearDelayTimeouts()}),k.addEventListener("mouseleave",function(){y.props.interactive&&y.props.trigger.indexOf("mouseenter")>=0&&ge().addEventListener("mousemove",h)}),y;function N(){var v=y.props.touch;return Array.isArray(v)?v:[v,0]}function F(){return N()[0]==="hold"}function H(){var v;return!!((v=y.props.render)!=null&&v.$$tippy)}function j(){return m||n}function ge(){var v=j().parentNode;return v?Bg(v):document}function fe(){return zs(k)}function K(v){return y.state.isMounted&&!y.state.isVisible||rt.isTouch||f&&f.type==="focus"?0:Is(y.props.delay,v?0:1,Ye.delay)}function G(v){v===void 0&&(v=!1),k.style.pointerEvents=y.props.interactive&&!v?"":"none",k.style.zIndex=""+y.props.zIndex}function Y(v,E,R){if(R===void 0&&(R=!0),B.forEach(function(z){z[v]&&z[v].apply(z,E)}),R){var W;(W=y.props)[v].apply(W,E)}}function ue(){var v=y.props.aria;if(v.content){var E="aria-"+v.content,R=k.id,W=In(y.props.triggerTarget||n);W.forEach(function(z){var Se=z.getAttribute(E);if(y.state.isVisible)z.setAttribute(E,Se?Se+" "+R:R);else{var Ie=Se&&Se.replace(R,"").trim();Ie?z.setAttribute(E,Ie):z.removeAttribute(E)}})}}function Ne(){if(!(T||!y.props.aria.expanded)){var v=In(y.props.triggerTarget||n);v.forEach(function(E){y.props.interactive?E.setAttribute("aria-expanded",y.state.isVisible&&E===j()?"true":"false"):E.removeAttribute("aria-expanded")})}}function De(){ge().removeEventListener("mousemove",h),Di=Di.filter(function(v){return v!==h})}function Pe(v){if(!(rt.isTouch&&(a||v.type==="mousedown"))){var E=v.composedPath&&v.composedPath()[0]||v.target;if(!(y.props.interactive&&If(k,E))){if(In(y.props.triggerTarget||n).some(function(R){return If(R,E)})){if(rt.isTouch||y.state.isVisible&&y.props.trigger.indexOf("click")>=0)return}else Y("onClickOutside",[y,v]);y.props.hideOnClick===!0&&(y.clearDelayTimeouts(),y.hide(),l=!0,setTimeout(function(){l=!1}),y.state.isMounted||ot())}}}function We(){a=!0}function it(){a=!1}function je(){var v=ge();v.addEventListener("mousedown",Pe,!0),v.addEventListener("touchend",Pe,an),v.addEventListener("touchstart",it,an),v.addEventListener("touchmove",We,an)}function ot(){var v=ge();v.removeEventListener("mousedown",Pe,!0),v.removeEventListener("touchend",Pe,an),v.removeEventListener("touchstart",it,an),v.removeEventListener("touchmove",We,an)}function cn(v,E){fn(v,function(){!y.state.isVisible&&k.parentNode&&k.parentNode.contains(k)&&E()})}function st(v,E){fn(v,E)}function fn(v,E){var R=fe().box;function W(z){z.target===R&&(Bs(R,"remove",W),E())}if(v===0)return E();Bs(R,"remove",u),Bs(R,"add",W),u=W}function xt(v,E,R){R===void 0&&(R=!1);var W=In(y.props.triggerTarget||n);W.forEach(function(z){z.addEventListener(v,E,R),p.push({node:z,eventType:v,handler:E,options:R})})}function un(){F()&&(xt("touchstart",Rn,{passive:!0}),xt("touchend",wr,{passive:!0})),Eg(y.props.trigger).forEach(function(v){if(v!=="manual")switch(xt(v,Rn),v){case"mouseenter":xt("mouseleave",wr);break;case"focus":xt(Hg?"focusout":"blur",Bn);break;case"focusin":xt("focusout",Bn);break}})}function kr(){p.forEach(function(v){var E=v.node,R=v.eventType,W=v.handler,z=v.options;E.removeEventListener(R,W,z)}),p=[]}function Rn(v){var E,R=!1;if(!(!y.state.isEnabled||Ln(v)||l)){var W=((E=f)==null?void 0:E.type)==="focus";f=v,m=v.currentTarget,Ne(),!y.state.isVisible&&Pg(v)&&Di.forEach(function(z){return z(v)}),v.type==="click"&&(y.props.trigger.indexOf("mouseenter")<0||s)&&y.props.hideOnClick!==!1&&y.state.isVisible?R=!0:Fn(v),v.type==="click"&&(s=!R),R&&!W&&It(v)}}function Sr(v){var E=v.target,R=j().contains(E)||k.contains(E);if(!(v.type==="mousemove"&&R)){var W=kt().concat(k).map(function(z){var Se,Ie=z._tippy,dn=(Se=Ie.popperInstance)==null?void 0:Se.state;return dn?{popperRect:z.getBoundingClientRect(),popperState:dn,props:t}:null}).filter(Boolean);Lg(W,v)&&(De(),It(v))}}function wr(v){var E=Ln(v)||y.props.trigger.indexOf("click")>=0&&s;if(!E){if(y.props.interactive){y.hideWithInteractivity(v);return}It(v)}}function Bn(v){y.props.trigger.indexOf("focusin")<0&&v.target!==j()||y.props.interactive&&v.relatedTarget&&k.contains(v.relatedTarget)||It(v)}function Ln(v){return rt.isTouch?F()!==v.type.indexOf("touch")>=0:!1}function Mr(){Cr();var v=y.props,E=v.popperOptions,R=v.placement,W=v.offset,z=v.getReferenceClientRect,Se=v.moveTransition,Ie=H()?zs(k).arrow:null,dn=z?{getBoundingClientRect:z,contextElement:z.contextElement||j()}:n,$s={name:"$$tippy",enabled:!0,phase:"beforeWrite",requires:["computeStyles"],fn:function(Nr){var pn=Nr.state;if(H()){var Qf=fe(),Bi=Qf.box;["placement","reference-hidden","escaped"].forEach(function(Dr){Dr==="placement"?Bi.setAttribute("data-placement",pn.placement):pn.attributes.popper["data-popper-"+Dr]?Bi.setAttribute("data-"+Dr,""):Bi.removeAttribute("data-"+Dr)}),pn.attributes.popper={}}}},Rt=[{name:"offset",options:{offset:W}},{name:"preventOverflow",options:{padding:{top:2,bottom:2,left:5,right:5}}},{name:"flip",options:{padding:5}},{name:"computeStyles",options:{adaptive:!Se}},$s];H()&&Ie&&Rt.push({name:"arrow",options:{element:Ie,padding:3}}),Rt.push.apply(Rt,E?.modifiers||[]),y.popperInstance=Ps(dn,k,Object.assign({},E,{placement:R,onFirstUpdate:d,modifiers:Rt}))}function Cr(){y.popperInstance&&(y.popperInstance.destroy(),y.popperInstance=null)}function lt(){var v=y.props.appendTo,E,R=j();y.props.interactive&&v===Hf||v==="parent"?E=R.parentNode:E=Wf(v,[R]),E.contains(k)||E.appendChild(k),y.state.isMounted=!0,Mr()}function kt(){return Pi(k.querySelectorAll("[data-tippy-root]"))}function Fn(v){y.clearDelayTimeouts(),v&&Y("onTrigger",[y,v]),je();var E=K(!0),R=N(),W=R[0],z=R[1];rt.isTouch&&W==="hold"&&z&&(E=z),E?r=setTimeout(function(){y.show()},E):y.show()}function It(v){if(y.clearDelayTimeouts(),Y("onUntrigger",[y,v]),!y.state.isVisible){ot();return}if(!(y.props.trigger.indexOf("mouseenter")>=0&&y.props.trigger.indexOf("click")>=0&&["mouseleave","mousemove"].indexOf(v.type)>=0&&s)){var E=K(!1);E?i=setTimeout(function(){y.state.isVisible&&y.hide()},E):o=requestAnimationFrame(function(){y.hide()})}}function zn(){y.state.isEnabled=!0}function Or(){y.hide(),y.state.isEnabled=!1}function Tr(){clearTimeout(r),clearTimeout(i),cancelAnimationFrame(o)}function Er(v){if(!y.state.isDestroyed){Y("onBeforeUpdate",[y,v]),kr();var E=y.props,R=Bf(n,Object.assign({},E,Df(v),{ignoreAttributes:!0}));y.props=R,un(),E.interactiveDebounce!==R.interactiveDebounce&&(De(),h=Af(Sr,R.interactiveDebounce)),E.triggerTarget&&!R.triggerTarget?In(E.triggerTarget).forEach(function(W){W.removeAttribute("aria-expanded")}):R.triggerTarget&&n.removeAttribute("aria-expanded"),Ne(),G(),I&&I(E,R),y.popperInstance&&(Mr(),kt().forEach(function(W){requestAnimationFrame(W._tippy.popperInstance.forceUpdate)})),Y("onAfterUpdate",[y,v])}}function Ar(v){y.setProps({content:v})}function Uf(){var v=y.state.isVisible,E=y.state.isDestroyed,R=!y.state.isEnabled,W=rt.isTouch&&!y.props.touch,z=Is(y.props.duration,0,Ye.duration);if(!(v||E||R||W)&&!j().hasAttribute("disabled")&&(Y("onShow",[y],!1),y.props.onShow(y)!==!1)){if(y.state.isVisible=!0,H()&&(k.style.visibility="visible"),G(),je(),y.state.isMounted||(k.style.transition="none"),H()){var Se=fe(),Ie=Se.box,dn=Se.content;Rs([Ie,dn],0)}d=function(){var Rt;if(!(!y.state.isVisible||c)){if(c=!0,k.offsetHeight,k.style.transition=y.props.moveTransition,H()&&y.props.animation){var Ri=fe(),Nr=Ri.box,pn=Ri.content;Rs([Nr,pn],z),Pf([Nr,pn],"visible")}ue(),Ne(),Nf(Ls,y),(Rt=y.popperInstance)==null||Rt.forceUpdate(),Y("onMount",[y]),y.props.animation&&H()&&st(z,function(){y.state.isShown=!0,Y("onShown",[y])})}},lt()}}function Gf(){var v=!y.state.isVisible,E=y.state.isDestroyed,R=!y.state.isEnabled,W=Is(y.props.duration,1,Ye.duration);if(!(v||E||R)&&(Y("onHide",[y],!1),y.props.onHide(y)!==!1)){if(y.state.isVisible=!1,y.state.isShown=!1,c=!1,s=!1,H()&&(k.style.visibility="hidden"),De(),ot(),G(!0),H()){var z=fe(),Se=z.box,Ie=z.content;y.props.animation&&(Rs([Se,Ie],W),Pf([Se,Ie],"hidden"))}ue(),Ne(),y.props.animation?H()&&cn(W,y.unmount):y.unmount()}}function Yf(v){ge().addEventListener("mousemove",h),Nf(Di,h),h(v)}function Xf(){y.state.isVisible&&y.hide(),y.state.isMounted&&(Cr(),kt().forEach(function(v){v._tippy.unmount()}),k.parentNode&&k.parentNode.removeChild(k),Ls=Ls.filter(function(v){return v!==y}),y.state.isMounted=!1,Y("onHidden",[y]))}function Zf(){y.state.isDestroyed||(y.clearDelayTimeouts(),y.unmount(),kr(),delete n._tippy,y.state.isDestroyed=!0,Y("onDestroy",[y]))}}function xr(n,e){e===void 0&&(e={});var t=Ye.plugins.concat(e.plugins||[]);Vg();var r=Object.assign({},e,{plugins:t}),i=Rg(n);if(0)var o,s;var l=i.reduce(function(a,c){var f=c&&Gg(c,r);return f&&a.push(f),a},[]);return Ii(n)?l[0]:l}xr.defaultProps=Ye;xr.setDefaultProps=Jg;xr.currentInput=rt;var ES=Object.assign({},dr,{effect:function(e){var t=e.state,r={popper:{position:t.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};Object.assign(t.elements.popper.style,r.popper),t.styles=r,t.elements.arrow&&Object.assign(t.elements.arrow.style,r.arrow)}});xr.setDefaultProps({render:Jf});var _f=xr;var Yg=(n,e,t)=>{n.chain().focus().deleteRange(e).insertContentAt(e,[{type:"mention",attrs:t},{type:"text",text:" "}]).run(),n.view.dom.ownerDocument.defaultView?.getSelection()?.collapseToEnd()},Xg=n=>{let e=[];return Alpine.store("filamentCommentsMentionsFiltered",{items:[],selectedIndex:0}),{items:({query:t})=>(e=n.filter(r=>r.name.toLowerCase().replace(/\s/g,"").includes(t.toLowerCase())).slice(0,5),console.log("filteredItems",n,e,t),Alpine.store("filamentCommentsMentionsFiltered").items=e,Alpine.store("filamentCommentsMentionsFiltered").selectedIndex=0,e),command:({editor:t,range:r,props:i})=>{let s=t.view.state.selection.$to.nodeAfter?.text?.startsWith(" ");t.view.state.mention$.text.length>1&&(r.to=r.from+(t.view.state.mention$.text.length-1)),s&&(r.to+=1);let l=3,a=!1;for(;l>0&&!a;)try{Yg(t,r,i),a=!0}catch{l--,r.to-=1}},render:()=>{let t,r,i;return{onStart:o=>{i=o.command,t=_f("body",{getReferenceClientRect:o.clientRect,content:(()=>{r=Alpine.data("filamentCommentsMentions",()=>({add(l){o.command({id:l.id,label:l.name})}}));let s=document.createElement("div");return s.setAttribute("x-data","filamentCommentsMentions"),s.innerHTML=` +`);return!o||!s?!1:n.chain().command(({tr:l})=>(l.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowDown:({editor:n})=>{if(!this.options.exitOnArrowDown)return!1;let{state:e}=n,{selection:t,doc:r}=e,{$from:i,empty:o}=t;if(!o||i.parent.type!==this.type||!(i.parentOffset===i.parent.nodeSize-2))return!1;let l=i.after();return l===void 0?!1:r.nodeAt(l)?n.commands.command(({tr:c})=>(c.setSelection(I.near(r.resolve(l))),!0)):n.commands.exitCode()}}},addInputRules(){return[Ar({find:ky,type:this.type,getAttributes:n=>({language:n[1]})}),Ar({find:Sy,type:this.type,getAttributes:n=>({language:n[1]})})]},addProseMirrorPlugins(){return[new _({key:new G("codeBlockVSCodeHandler"),props:{handlePaste:(n,e)=>{if(!e.clipboardData||this.editor.isActive(this.type.name))return!1;let t=e.clipboardData.getData("text/plain"),r=e.clipboardData.getData("vscode-editor-data"),i=r?JSON.parse(r):void 0,o=i?.mode;if(!t||!o)return!1;let{tr:s,schema:l}=n.state,a=l.text(t.replace(/\r\n?/g,` +`));return s.replaceSelectionWith(this.type.create({language:o},a)),s.selection.$from.parent.type!==this.type&&s.setSelection(P.near(s.doc.resolve(Math.max(0,s.selection.from-2)))),s.setMeta("paste",!0),n.dispatch(s),!0}}})]}});var vf=J.create({name:"doc",topNode:!0,content:"block+"});function xf(n={}){return new _({view(e){return new kl(e,n)}})}var kl=class{constructor(e,t){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=t.width)!==null&&r!==void 0?r:1,this.color=t.color===!1?void 0:t.color||"black",this.class=t.class,this.handlers=["dragover","dragend","drop","dragleave"].map(i=>{let o=s=>{this[i](s)};return e.dom.addEventListener(i,o),{name:i,handler:o}})}destroy(){this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){this.cursorPos!=null&&t.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):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,r;if(t){let l=e.nodeBefore,a=e.nodeAfter;if(l||a){let c=this.editorView.nodeDOM(this.cursorPos-(l?l.nodeSize:0));if(c){let u=c.getBoundingClientRect(),f=l?u.bottom:u.top;l&&a&&(f=(f+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2),r={left:u.left,right:u.right,top:f-this.width/2,bottom:f+this.width/2}}}}if(!r){let l=this.editorView.coordsAtPos(this.cursorPos);r={left:l.left-this.width/2,right:l.left+this.width/2,top:l.top,bottom:l.bottom}}let i=this.editorView.dom.offsetParent;this.element||(this.element=i.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 o,s;if(!i||i==document.body&&getComputedStyle(i).position=="static")o=-pageXOffset,s=-pageYOffset;else{let l=i.getBoundingClientRect();o=l.left-i.scrollLeft,s=l.top-i.scrollTop}this.element.style.left=r.left-o+"px",this.element.style.top=r.top-s+"px",this.element.style.width=r.right-r.left+"px",this.element.style.height=r.bottom-r.top+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),i=r&&r.type.spec.disableDropCursor,o=typeof i=="function"?i(this.editorView,t,e):i;if(t&&!o){let s=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=gi(this.editorView.state.doc,s,this.editorView.dragging.slice);l!=null&&(s=l)}this.setCursor(s),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){(e.target==this.editorView.dom||!this.editorView.dom.contains(e.relatedTarget))&&this.setCursor(null)}};var kf=le.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[xf(this.options)]}});var Me=class n extends I{constructor(e){super(e,e)}map(e,t){let r=e.resolve(t.map(this.head));return n.valid(r)?new n(r):I.near(r)}content(){return E.empty}eq(e){return e instanceof n&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new n(e.resolve(t.pos))}getBookmark(){return new Sl(this.anchor)}static valid(e){let t=e.parent;if(t.isTextblock||!wy(e)||!Cy(e))return!1;let r=t.type.spec.allowGapCursor;if(r!=null)return r;let i=t.contentMatchAt(e.index()).defaultType;return i&&i.isTextblock}static findGapCursorFrom(e,t,r=!1){e:for(;;){if(!r&&n.valid(e))return e;let i=e.pos,o=null;for(let s=e.depth;;s--){let l=e.node(s);if(t>0?e.indexAfter(s)0){o=l.child(t>0?e.indexAfter(s):e.index(s)-1);break}else if(s==0)return null;i+=t;let a=e.doc.resolve(i);if(n.valid(a))return a}for(;;){let s=t>0?o.firstChild:o.lastChild;if(!s){if(o.isAtom&&!o.isText&&!D.isSelectable(o)){e=e.doc.resolve(i+o.nodeSize*t),r=!1;continue e}break}o=s,i+=t;let l=e.doc.resolve(i);if(n.valid(l))return l}return null}}};Me.prototype.visible=!1;Me.findFrom=Me.findGapCursorFrom;I.jsonID("gapcursor",Me);var Sl=class n{constructor(e){this.pos=e}map(e){return new n(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return Me.valid(t)?new Me(t):I.near(t)}};function wy(n){for(let e=n.depth;e>=0;e--){let t=n.index(e),r=n.node(e);if(t==0){if(r.type.spec.isolating)return!0;continue}for(let i=r.child(t-1);;i=i.lastChild){if(i.childCount==0&&!i.inlineContent||i.isAtom||i.type.spec.isolating)return!0;if(i.inlineContent)return!1}}return!0}function Cy(n){for(let e=n.depth;e>=0;e--){let t=n.indexAfter(e),r=n.node(e);if(t==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let i=r.child(t);;i=i.firstChild){if(i.childCount==0&&!i.inlineContent||i.isAtom||i.type.spec.isolating)return!0;if(i.inlineContent)return!1}}return!0}function Sf(){return new _({props:{decorations:Ty,createSelectionBetween(n,e,t){return e.pos==t.pos&&Me.valid(t)?new Me(t):null},handleClick:Ey,handleKeyDown:My,handleDOMEvents:{beforeinput:Oy}}})}var My=Ws({ArrowLeft:Yi("horiz",-1),ArrowRight:Yi("horiz",1),ArrowUp:Yi("vert",-1),ArrowDown:Yi("vert",1)});function Yi(n,e){let t=n=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,i,o){let s=r.selection,l=e>0?s.$to:s.$from,a=s.empty;if(s instanceof P){if(!o.endOfTextblock(t)||l.depth==0)return!1;a=!1,l=r.doc.resolve(e>0?l.after():l.before())}let c=Me.findGapCursorFrom(l,e,a);return c?(i&&i(r.tr.setSelection(new Me(c))),!0):!1}}function Ey(n,e,t){if(!n||!n.editable)return!1;let r=n.state.doc.resolve(e);if(!Me.valid(r))return!1;let i=n.posAtCoords({left:t.clientX,top:t.clientY});return i&&i.inside>-1&&D.isSelectable(n.state.doc.nodeAt(i.inside))?!1:(n.dispatch(n.state.tr.setSelection(new Me(r))),!0)}function Oy(n,e){if(e.inputType!="insertCompositionText"||!(n.state.selection instanceof Me))return!1;let{$from:t}=n.state.selection,r=t.parent.contentMatchAt(t.index()).findWrapping(n.state.schema.nodes.text);if(!r)return!1;let i=S.empty;for(let s=r.length-1;s>=0;s--)i=S.from(r[s].createAndFill(null,i));let o=n.state.tr.replace(t.pos,t.pos,new E(i,0,0));return o.setSelection(P.near(o.doc.resolve(t.pos+1))),n.dispatch(o),!1}function Ty(n){if(!(n.selection instanceof Me))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",de.create(n.doc,[Pe.widget(n.selection.head,e,{key:"gapcursor"})])}var wf=le.create({name:"gapCursor",addProseMirrorPlugins(){return[Sf()]},extendNodeSchema(n){var e;let t={name:n.name,options:n.options,storage:n.storage};return{allowGapCursor:(e=F(T(n,"allowGapCursor",t)))!==null&&e!==void 0?e:null}}});var Cf=J.create({name:"hardBreak",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:n}){return["br",$(this.options.HTMLAttributes,n)]},renderText(){return` +`},addCommands(){return{setHardBreak:()=>({commands:n,chain:e,state:t,editor:r})=>n.first([()=>n.exitCode(),()=>n.command(()=>{let{selection:i,storedMarks:o}=t;if(i.$from.parent.type.spec.isolating)return!1;let{keepMarks:s}=this.options,{splittableMarks:l}=r.extensionManager,a=o||i.$to.parentOffset&&i.$from.marks();return e().insertContent({type:this.name}).command(({tr:c,dispatch:u})=>{if(u&&a&&s){let f=a.filter(d=>l.includes(d.type.name));c.ensureMarks(f)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}});var Mf=J.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(n=>({tag:`h${n}`,attrs:{level:n}}))},renderHTML({node:n,HTMLAttributes:e}){return[`h${this.options.levels.includes(n.attrs.level)?n.attrs.level:this.options.levels[0]}`,$(this.options.HTMLAttributes,e),0]},addCommands(){return{setHeading:n=>({commands:e})=>this.options.levels.includes(n.level)?e.setNode(this.name,n):!1,toggleHeading:n=>({commands:e})=>this.options.levels.includes(n.level)?e.toggleNode(this.name,"paragraph",n):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((n,e)=>({...n,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(n=>Ar({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${n}})\\s$`),type:this.type,getAttributes:{level:n}}))}});var Xi=200,ve=function(){};ve.prototype.append=function(e){return e.length?(e=ve.from(e),!this.length&&e||e.length=t?ve.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))};ve.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};ve.prototype.forEach=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length),t<=r?this.forEachInner(e,t,r,0):this.forEachInvertedInner(e,t,r,0)};ve.prototype.map=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length);var i=[];return this.forEach(function(o,s){return i.push(e(o,s))},t,r),i};ve.from=function(e){return e instanceof ve?e:e&&e.length?new Ef(e):ve.empty};var Ef=function(n){function e(r){n.call(this),this.values=r}n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e;var t={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(i,o){return i==0&&o==this.length?this:new e(this.values.slice(i,o))},e.prototype.getInner=function(i){return this.values[i]},e.prototype.forEachInner=function(i,o,s,l){for(var a=o;a=s;a--)if(i(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(i){if(this.length+i.length<=Xi)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=Xi)return new e(i.flatten().concat(this.values))},t.length.get=function(){return this.values.length},t.depth.get=function(){return 0},Object.defineProperties(e.prototype,t),e}(ve);ve.empty=new Ef([]);var Ay=function(n){function e(t,r){n.call(this),this.left=t,this.right=r,this.length=t.length+r.length,this.depth=Math.max(t.depth,r.depth)+1}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return rl&&this.right.forEachInner(r,Math.max(i-l,0),Math.min(this.length,o)-l,s+l)===!1)return!1},e.prototype.forEachInvertedInner=function(r,i,o,s){var l=this.left.length;if(i>l&&this.right.forEachInvertedInner(r,i-l,Math.max(o,l)-l,s+l)===!1||o=o?this.right.slice(r-o,i-o):this.left.slice(r,o).append(this.right.slice(0,i-o))},e.prototype.leafAppend=function(r){var i=this.right.leafAppend(r);if(i)return new e(this.left,i)},e.prototype.leafPrepend=function(r){var i=this.left.leafPrepend(r);if(i)return new e(i,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e}(ve),wl=ve;var Ny=500,pn=class n{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let i,o;t&&(i=this.remapping(r,this.items.length),o=i.maps.length);let s=e.tr,l,a,c=[],u=[];return this.items.forEach((f,d)=>{if(!f.step){i||(i=this.remapping(r,d+1),o=i.maps.length),o--,u.push(f);return}if(i){u.push(new at(f.map));let p=f.step.map(i.slice(o)),h;p&&s.maybeStep(p).doc&&(h=s.mapping.maps[s.mapping.maps.length-1],c.push(new at(h,void 0,void 0,c.length+u.length))),o--,h&&i.appendMap(h,o)}else s.maybeStep(f.step);if(f.selection)return l=i?f.selection.map(i.slice(o)):f.selection,a=new n(this.items.slice(0,r).append(u.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:s,selection:l}}addTransform(e,t,r,i){let o=[],s=this.eventCount,l=this.items,a=!i&&l.length?l.get(l.length-1):null;for(let u=0;uRy&&(l=Dy(l,c),s-=c),new n(l.append(o),s)}remapping(e,t){let r=new dr;return this.items.forEach((i,o)=>{let s=i.mirrorOffset!=null&&o-i.mirrorOffset>=e?r.maps.length-i.mirrorOffset:void 0;r.appendMap(i.map,s)},e,t),r}addMaps(e){return this.eventCount==0?this:new n(this.items.append(e.map(t=>new at(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-t),o=e.mapping,s=e.steps.length,l=this.eventCount;this.items.forEach(d=>{d.selection&&l--},i);let a=t;this.items.forEach(d=>{let p=o.getMirror(--a);if(p==null)return;s=Math.min(s,p);let h=o.maps[p];if(d.step){let m=e.steps[p].invert(e.docs[p]),g=d.selection&&d.selection.map(o.slice(a+1,p));g&&l++,r.push(new at(h,m,g))}else r.push(new at(h))},i);let c=[];for(let d=t;dNy&&(f=f.compress(this.items.length-r.length)),f}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),r=t.maps.length,i=[],o=0;return this.items.forEach((s,l)=>{if(l>=e)i.push(s),s.selection&&o++;else if(s.step){let a=s.step.map(t.slice(r)),c=a&&a.getMap();if(r--,c&&t.appendMap(c,r),a){let u=s.selection&&s.selection.map(t.slice(r));u&&o++;let f=new at(c.invert(),a,u),d,p=i.length-1;(d=i.length&&i[p].merge(f))?i[p]=d:i.push(f)}}else s.map&&r--},this.items.length,0),new n(wl.from(i.reverse()),o)}};pn.empty=new pn(wl.empty,0);function Dy(n,e){let t;return n.forEach((r,i)=>{if(r.selection&&e--==0)return t=i,!1}),n.slice(t)}var at=class n{constructor(e,t,r,i){this.map=e,this.step=t,this.selection=r,this.mirrorOffset=i}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new n(t.getMap().invert(),t,this.selection)}}},ct=class{constructor(e,t,r,i,o){this.done=e,this.undone=t,this.prevRanges=r,this.prevTime=i,this.prevComposition=o}},Ry=20;function Iy(n,e,t,r){let i=t.getMeta(dn),o;if(i)return i.historyState;t.getMeta(By)&&(n=new ct(n.done,n.undone,null,0,-1));let s=t.getMeta("appendedTransaction");if(t.steps.length==0)return n;if(s&&s.getMeta(dn))return s.getMeta(dn).redo?new ct(n.done.addTransform(t,void 0,r,Qi(e)),n.undone,Of(t.mapping.maps),n.prevTime,n.prevComposition):new ct(n.done,n.undone.addTransform(t,void 0,r,Qi(e)),null,n.prevTime,n.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(s&&s.getMeta("addToHistory")===!1)){let l=t.getMeta("composition"),a=n.prevTime==0||!s&&n.prevComposition!=l&&(n.prevTime<(t.time||0)-r.newGroupDelay||!Py(t,n.prevRanges)),c=s?Cl(n.prevRanges,t.mapping):Of(t.mapping.maps);return new ct(n.done.addTransform(t,a?e.selection.getBookmark():void 0,r,Qi(e)),pn.empty,c,t.time,l??n.prevComposition)}else return(o=t.getMeta("rebased"))?new ct(n.done.rebased(t,o),n.undone.rebased(t,o),Cl(n.prevRanges,t.mapping),n.prevTime,n.prevComposition):new ct(n.done.addMaps(t.mapping.maps),n.undone.addMaps(t.mapping.maps),Cl(n.prevRanges,t.mapping),n.prevTime,n.prevComposition)}function Py(n,e){if(!e)return!1;if(!n.docChanged)return!0;let t=!1;return n.mapping.maps[0].forEach((r,i)=>{for(let o=0;o=e[o]&&(t=!0)}),t}function Of(n){let e=[];for(let t=n.length-1;t>=0&&e.length==0;t--)n[t].forEach((r,i,o,s)=>e.push(o,s));return e}function Cl(n,e){if(!n)return null;let t=[];for(let r=0;r{let i=dn.getState(t);if(!i||(n?i.undone:i.done).eventCount==0)return!1;if(r){let o=Ly(i,t,n);o&&r(e?o.scrollIntoView():o)}return!0}}var El=Zi(!1,!0),Ol=Zi(!0,!0),rx=Zi(!1,!1),ix=Zi(!0,!1);var Nf=le.create({name:"history",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:n,dispatch:e})=>El(n,e),redo:()=>({state:n,dispatch:e})=>Ol(n,e)}},addProseMirrorPlugins(){return[Af(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-\u044F":()=>this.editor.commands.undo(),"Shift-Mod-\u044F":()=>this.editor.commands.redo()}}});var Df=J.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{}}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:n}){return["hr",$(this.options.HTMLAttributes,n)]},addCommands(){return{setHorizontalRule:()=>({chain:n,state:e})=>{let{selection:t}=e,{$from:r,$to:i}=t,o=n();return r.parentOffset===0?o.insertContentAt({from:Math.max(r.pos-1,0),to:i.pos},{type:this.name}):cf(t)?o.insertContentAt(i.pos,{type:this.name}):o.insertContent({type:this.name}),o.command(({tr:s,dispatch:l})=>{var a;if(l){let{$to:c}=s.selection,u=c.end();if(c.nodeAfter)c.nodeAfter.isTextblock?s.setSelection(P.create(s.doc,c.pos+1)):c.nodeAfter.isBlock?s.setSelection(D.create(s.doc,c.pos)):s.setSelection(P.create(s.doc,c.pos));else{let f=(a=c.parent.type.contentMatch.defaultType)===null||a===void 0?void 0:a.create();f&&(s.insert(u,f),s.setSelection(P.create(s.doc,u+1)))}s.scrollIntoView()}return!0}).run()}}},addInputRules(){return[uf({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}});var zy=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,Fy=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,Hy=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,$y=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,Rf=De.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:n=>n.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:n=>n.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:n}){return["em",$(this.options.HTMLAttributes,n),0]},addCommands(){return{setItalic:()=>({commands:n})=>n.setMark(this.name),toggleItalic:()=>({commands:n})=>n.toggleMark(this.name),unsetItalic:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[lt({find:zy,type:this.type}),lt({find:Hy,type:this.type})]},addPasteRules(){return[_e({find:Fy,type:this.type}),_e({find:$y,type:this.type})]}});var If=J.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:n}){return["li",$(this.options.HTMLAttributes,n),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}});var Vy="listItem",Pf="textStyle",Lf=/^(\d+)\.\s$/,Bf=J.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:n=>n.hasAttribute("start")?parseInt(n.getAttribute("start")||"",10):1},type:{default:void 0,parseHTML:n=>n.getAttribute("type")}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:n}){let{start:e,...t}=n;return e===1?["ol",$(this.options.HTMLAttributes,t),0]:["ol",$(this.options.HTMLAttributes,n),0]},addCommands(){return{toggleOrderedList:()=>({commands:n,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(Vy,this.editor.getAttributes(Pf)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let n=jt({find:Lf,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(n=jt({find:Lf,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(Pf)}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1],editor:this.editor})),[n]}});var zf=J.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:n}){return["p",$(this.options.HTMLAttributes,n),0]},addCommands(){return{setParagraph:()=>({commands:n})=>n.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}});var jy=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,Wy=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,Ff=De.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:n=>n.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["s",$(this.options.HTMLAttributes,n),0]},addCommands(){return{setStrike:()=>({commands:n})=>n.setMark(this.name),toggleStrike:()=>({commands:n})=>n.toggleMark(this.name),unsetStrike:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[lt({find:jy,type:this.type})]},addPasteRules(){return[_e({find:Wy,type:this.type})]}});var Hf=J.create({name:"text",group:"inline"});var $f=le.create({name:"starterKit",addExtensions(){var n,e,t,r,i,o,s,l,a,c,u,f,d,p,h,m,g,b;let x=[];return this.options.bold!==!1&&x.push(pf.configure((n=this.options)===null||n===void 0?void 0:n.bold)),this.options.blockquote!==!1&&x.push(df.configure((e=this.options)===null||e===void 0?void 0:e.blockquote)),this.options.bulletList!==!1&&x.push(gf.configure((t=this.options)===null||t===void 0?void 0:t.bulletList)),this.options.code!==!1&&x.push(yf.configure((r=this.options)===null||r===void 0?void 0:r.code)),this.options.codeBlock!==!1&&x.push(bf.configure((i=this.options)===null||i===void 0?void 0:i.codeBlock)),this.options.document!==!1&&x.push(vf.configure((o=this.options)===null||o===void 0?void 0:o.document)),this.options.dropcursor!==!1&&x.push(kf.configure((s=this.options)===null||s===void 0?void 0:s.dropcursor)),this.options.gapcursor!==!1&&x.push(wf.configure((l=this.options)===null||l===void 0?void 0:l.gapcursor)),this.options.hardBreak!==!1&&x.push(Cf.configure((a=this.options)===null||a===void 0?void 0:a.hardBreak)),this.options.heading!==!1&&x.push(Mf.configure((c=this.options)===null||c===void 0?void 0:c.heading)),this.options.history!==!1&&x.push(Nf.configure((u=this.options)===null||u===void 0?void 0:u.history)),this.options.horizontalRule!==!1&&x.push(Df.configure((f=this.options)===null||f===void 0?void 0:f.horizontalRule)),this.options.italic!==!1&&x.push(Rf.configure((d=this.options)===null||d===void 0?void 0:d.italic)),this.options.listItem!==!1&&x.push(If.configure((p=this.options)===null||p===void 0?void 0:p.listItem)),this.options.orderedList!==!1&&x.push(Bf.configure((h=this.options)===null||h===void 0?void 0:h.orderedList)),this.options.paragraph!==!1&&x.push(zf.configure((m=this.options)===null||m===void 0?void 0:m.paragraph)),this.options.strike!==!1&&x.push(Ff.configure((g=this.options)===null||g===void 0?void 0:g.strike)),this.options.text!==!1&&x.push(Hf.configure((b=this.options)===null||b===void 0?void 0:b.text)),x}});function Uy(n){var e;let{char:t,allowSpaces:r,allowToIncludeChar:i,allowedPrefixes:o,startOfLine:s,$position:l}=n,a=r&&!i,c=ff(t),u=new RegExp(`\\s${c}$`),f=s?"^":"",d=i?"":c,p=a?new RegExp(`${f}${c}.*?(?=\\s${d}|$)`,"gm"):new RegExp(`${f}(?:^)?${c}[^\\s${d}]*`,"gm"),h=((e=l.nodeBefore)===null||e===void 0?void 0:e.isText)&&l.nodeBefore.text;if(!h)return null;let m=l.pos-h.length,g=Array.from(h.matchAll(p)).pop();if(!g||g.input===void 0||g.index===void 0)return null;let b=g.input.slice(Math.max(0,g.index-1),g.index),x=new RegExp(`^[${o?.join("")}\0]?$`).test(b);if(o!==null&&!x)return null;let C=m+g.index,y=C+g[0].length;return a&&u.test(h.slice(y-1,y+1))&&(g[0]+=" ",y+=1),C=l.pos?{range:{from:C,to:y},query:g[0].slice(t.length),text:g[0]}:null}var _y=new G("suggestion");function Vf({pluginKey:n=_y,editor:e,char:t="@",allowSpaces:r=!1,allowToIncludeChar:i=!1,allowedPrefixes:o=[" "],startOfLine:s=!1,decorationTag:l="span",decorationClass:a="suggestion",command:c=()=>null,items:u=()=>[],render:f=()=>({}),allow:d=()=>!0,findSuggestionMatch:p=Uy}){let h,m=f?.(),g=new _({key:n,view(){return{update:async(b,x)=>{var C,y,M,k,R,B,O;let N=(C=this.key)===null||C===void 0?void 0:C.getState(x),z=(y=this.key)===null||y===void 0?void 0:y.getState(b.state),V=N.active&&z.active&&N.range.from!==z.range.from,U=!N.active&&z.active,te=N.active&&!z.active,X=!U&&!te&&N.query!==z.query,K=U||V&&X,ne=X||V,re=te||V&&X;if(!K&&!ne&&!re)return;let ge=re&&!K?N:z,Be=b.dom.querySelector(`[data-decoration-id="${ge.decorationId}"]`);h={editor:e,range:ge.range,query:ge.query,text:ge.text,items:[],command:ze=>c({editor:e,range:ge.range,props:ze}),decorationNode:Be,clientRect:Be?()=>{var ze;let{decorationId:Fe}=(ze=this.key)===null||ze===void 0?void 0:ze.getState(e.state),Xe=b.dom.querySelector(`[data-decoration-id="${Fe}"]`);return Xe?.getBoundingClientRect()||null}:null},K&&((M=m?.onBeforeStart)===null||M===void 0||M.call(m,h)),ne&&((k=m?.onBeforeUpdate)===null||k===void 0||k.call(m,h)),(ne||K)&&(h.items=await u({editor:e,query:ge.query})),re&&((R=m?.onExit)===null||R===void 0||R.call(m,h)),ne&&((B=m?.onUpdate)===null||B===void 0||B.call(m,h)),K&&((O=m?.onStart)===null||O===void 0||O.call(m,h))},destroy:()=>{var b;h&&((b=m?.onExit)===null||b===void 0||b.call(m,h))}}},state:{init(){return{active:!1,range:{from:0,to:0},query:null,text:null,composing:!1}},apply(b,x,C,y){let{isEditable:M}=e,{composing:k}=e.view,{selection:R}=b,{empty:B,from:O}=R,N={...x};if(N.composing=k,M&&(B||e.view.composing)){(Ox.range.to)&&!k&&!x.composing&&(N.active=!1);let z=p({char:t,allowSpaces:r,allowToIncludeChar:i,allowedPrefixes:o,startOfLine:s,$position:R.$from}),V=`id_${Math.floor(Math.random()*4294967295)}`;z&&d({editor:e,state:y,range:z.range,isActive:x.active})?(N.active=!0,N.decorationId=x.decorationId?x.decorationId:V,N.range=z.range,N.query=z.query,N.text=z.text):N.active=!1}else N.active=!1;return N.active||(N.decorationId=null,N.range={from:0,to:0},N.query=null,N.text=null),N}},props:{handleKeyDown(b,x){var C;let{active:y,range:M}=g.getState(b.state);return y&&((C=m?.onKeyDown)===null||C===void 0?void 0:C.call(m,{view:b,event:x,range:M}))||!1},decorations(b){let{active:x,range:C,decorationId:y}=g.getState(b);return x?de.create(b.doc,[Pe.inline(C.from,C.to,{nodeName:l,class:a,"data-decoration-id":y})]):null}}});return g}var Ky=new G("mention"),jf=J.create({name:"mention",priority:101,addOptions(){return{HTMLAttributes:{},renderText({options:n,node:e}){var t;return`${n.suggestion.char}${(t=e.attrs.label)!==null&&t!==void 0?t:e.attrs.id}`},deleteTriggerWithBackspace:!1,renderHTML({options:n,node:e}){var t;return["span",$(this.HTMLAttributes,n.HTMLAttributes),`${n.suggestion.char}${(t=e.attrs.label)!==null&&t!==void 0?t:e.attrs.id}`]},suggestion:{char:"@",pluginKey:Ky,command:({editor:n,range:e,props:t})=>{var r,i,o;let s=n.view.state.selection.$to.nodeAfter;((r=s?.text)===null||r===void 0?void 0:r.startsWith(" "))&&(e.to+=1),n.chain().focus().insertContentAt(e,[{type:this.name,attrs:t},{type:"text",text:" "}]).run(),(o=(i=n.view.dom.ownerDocument.defaultView)===null||i===void 0?void 0:i.getSelection())===null||o===void 0||o.collapseToEnd()},allow:({state:n,range:e})=>{let t=n.doc.resolve(e.from),r=n.schema.nodes[this.name];return!!t.parent.type.contentMatch.matchType(r)}}}},group:"inline",inline:!0,selectable:!1,atom:!0,addAttributes(){return{id:{default:null,parseHTML:n=>n.getAttribute("data-id"),renderHTML:n=>n.id?{"data-id":n.id}:{}},label:{default:null,parseHTML:n=>n.getAttribute("data-label"),renderHTML:n=>n.label?{"data-label":n.label}:{}}}},parseHTML(){return[{tag:`span[data-type="${this.name}"]`}]},renderHTML({node:n,HTMLAttributes:e}){if(this.options.renderLabel!==void 0)return console.warn("renderLabel is deprecated use renderText and renderHTML instead"),["span",$({"data-type":this.name},this.options.HTMLAttributes,e),this.options.renderLabel({options:this.options,node:n})];let t={...this.options};t.HTMLAttributes=$({"data-type":this.name},this.options.HTMLAttributes,e);let r=this.options.renderHTML({options:t,node:n});return typeof r=="string"?["span",$({"data-type":this.name},this.options.HTMLAttributes,e),r]:r},renderText({node:n}){return this.options.renderLabel!==void 0?(console.warn("renderLabel is deprecated use renderText and renderHTML instead"),this.options.renderLabel({options:this.options,node:n})):this.options.renderText({options:this.options,node:n})},addKeyboardShortcuts(){return{Backspace:()=>this.editor.commands.command(({tr:n,state:e})=>{let t=!1,{selection:r}=e,{empty:i,anchor:o}=r;return i?(e.doc.nodesBetween(o-1,o,(s,l)=>{if(s.type.name===this.name)return t=!0,n.insertText(this.options.deleteTriggerWithBackspace?"":this.options.suggestion.char||"",l,l+s.nodeSize),!1}),t):!1})}},addProseMirrorPlugins(){return[Vf({editor:this.editor,...this.options.suggestion})]}});var Wf=le.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something \u2026",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[new _({key:new G("placeholder"),props:{decorations:({doc:n,selection:e})=>{let t=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:r}=e,i=[];if(!t)return null;let o=this.editor.isEmpty;return n.descendants((s,l)=>{let a=r>=l&&r<=l+s.nodeSize,c=!s.isLeaf&&Tr(s);if((a||!this.options.showOnlyCurrent)&&c){let u=[this.options.emptyNodeClass];o&&u.push(this.options.emptyEditorClass);let f=Pe.node(l,l+s.nodeSize,{class:u.join(" "),"data-placeholder":typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:s,pos:l,hasAnchor:a}):this.options.placeholder});i.push(f)}return this.options.includeChildren}),de.create(n,i)}}})]}});var Uf=De.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:n=>n.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["u",$(this.options.HTMLAttributes,n),0]},addCommands(){return{setUnderline:()=>({commands:n})=>n.setMark(this.name),toggleUnderline:()=>({commands:n})=>n.toggleMark(this.name),unsetUnderline:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}});var qy="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2odyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rck0msd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5m\xF6gensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2oodside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",Jy="\u03B5\u03BB1\u03C52\u0431\u04331\u0435\u043B3\u0434\u0435\u0442\u04384\u0435\u044E2\u043A\u0430\u0442\u043E\u043B\u0438\u043A6\u043E\u043C3\u043C\u043A\u04342\u043E\u043D1\u0441\u043A\u0432\u04306\u043E\u043D\u043B\u0430\u0439\u043D5\u0440\u04333\u0440\u0443\u04412\u04442\u0441\u0430\u0439\u04423\u0440\u04313\u0443\u043A\u04403\u049B\u0430\u04373\u0570\u0561\u05753\u05D9\u05E9\u05E8\u05D0\u05DC5\u05E7\u05D5\u05DD3\u0627\u0628\u0648\u0638\u0628\u064A5\u0631\u0627\u0645\u0643\u06485\u0644\u0627\u0631\u062F\u06464\u0628\u062D\u0631\u064A\u06465\u062C\u0632\u0627\u0626\u06315\u0633\u0639\u0648\u062F\u064A\u06296\u0639\u0644\u064A\u0627\u06465\u0645\u063A\u0631\u06285\u0645\u0627\u0631\u0627\u062A5\u06CC\u0631\u0627\u06465\u0628\u0627\u0631\u062A2\u0632\u0627\u06314\u064A\u062A\u06433\u06BE\u0627\u0631\u062A5\u062A\u0648\u0646\u06334\u0633\u0648\u062F\u0627\u06463\u0631\u064A\u06295\u0634\u0628\u0643\u06294\u0639\u0631\u0627\u06422\u06282\u0645\u0627\u06464\u0641\u0644\u0633\u0637\u064A\u06466\u0642\u0637\u06313\u0643\u0627\u062B\u0648\u0644\u064A\u06436\u0648\u06453\u0645\u0635\u06312\u0644\u064A\u0633\u064A\u06275\u0648\u0631\u064A\u062A\u0627\u0646\u064A\u06277\u0642\u06394\u0647\u0645\u0631\u0627\u06475\u067E\u0627\u06A9\u0633\u062A\u0627\u06467\u0680\u0627\u0631\u062A4\u0915\u0949\u092E3\u0928\u0947\u091F3\u092D\u093E\u0930\u09240\u092E\u094D3\u094B\u09245\u0938\u0902\u0917\u0920\u09285\u09AC\u09BE\u0982\u09B2\u09BE5\u09AD\u09BE\u09B0\u09A42\u09F0\u09A44\u0A2D\u0A3E\u0A30\u0A244\u0AAD\u0ABE\u0AB0\u0AA44\u0B2D\u0B3E\u0B30\u0B244\u0B87\u0BA8\u0BCD\u0BA4\u0BBF\u0BAF\u0BBE6\u0BB2\u0B99\u0BCD\u0B95\u0BC86\u0B9A\u0BBF\u0B99\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0BC2\u0BB0\u0BCD11\u0C2D\u0C3E\u0C30\u0C24\u0C4D5\u0CAD\u0CBE\u0CB0\u0CA44\u0D2D\u0D3E\u0D30\u0D24\u0D025\u0DBD\u0D82\u0D9A\u0DCF4\u0E04\u0E2D\u0E213\u0E44\u0E17\u0E223\u0EA5\u0EB2\u0EA73\u10D2\u10D42\u307F\u3093\u306A3\u30A2\u30DE\u30BE\u30F34\u30AF\u30E9\u30A6\u30C94\u30B0\u30FC\u30B0\u30EB4\u30B3\u30E02\u30B9\u30C8\u30A23\u30BB\u30FC\u30EB3\u30D5\u30A1\u30C3\u30B7\u30E7\u30F36\u30DD\u30A4\u30F3\u30C84\u4E16\u754C2\u4E2D\u4FE11\u56FD1\u570B1\u6587\u7F513\u4E9A\u9A6C\u900A3\u4F01\u4E1A2\u4F5B\u5C712\u4FE1\u606F2\u5065\u5EB72\u516B\u53662\u516C\u53F81\u76CA2\u53F0\u6E7E1\u70632\u5546\u57CE1\u5E971\u68072\u5609\u91CC0\u5927\u9152\u5E975\u5728\u7EBF2\u5927\u62FF2\u5929\u4E3B\u65593\u5A31\u4E502\u5BB6\u96FB2\u5E7F\u4E1C2\u5FAE\u535A2\u6148\u55842\u6211\u7231\u4F603\u624B\u673A2\u62DB\u80582\u653F\u52A11\u5E9C2\u65B0\u52A0\u57612\u95FB2\u65F6\u5C1A2\u66F8\u7C4D2\u673A\u67842\u6DE1\u9A6C\u95213\u6E38\u620F2\u6FB3\u95802\u70B9\u770B2\u79FB\u52A82\u7EC4\u7EC7\u673A\u67844\u7F51\u57401\u5E971\u7AD91\u7EDC2\u8054\u901A2\u8C37\u6B4C2\u8D2D\u72692\u901A\u8CA92\u96C6\u56E22\u96FB\u8A0A\u76C8\u79D14\u98DE\u5229\u6D663\u98DF\u54C12\u9910\u53852\u9999\u683C\u91CC\u62C93\u6E2F2\uB2F7\uB1371\uCEF42\uC0BC\uC1312\uD55C\uAD6D2",Pl="numeric",Ll="ascii",Bl="alpha",Rr="asciinumeric",Dr="alphanumeric",zl="domain",Yf="emoji",Gy="scheme",Yy="slashscheme",Tl="whitespace";function Xy(n,e){return n in e||(e[n]=[]),e[n]}function hn(n,e,t){e[Pl]&&(e[Rr]=!0,e[Dr]=!0),e[Ll]&&(e[Rr]=!0,e[Bl]=!0),e[Rr]&&(e[Dr]=!0),e[Bl]&&(e[Dr]=!0),e[Dr]&&(e[zl]=!0),e[Yf]&&(e[zl]=!0);for(let r in e){let i=Xy(r,t);i.indexOf(n)<0&&i.push(n)}}function Qy(n,e){let t={};for(let r in e)e[r].indexOf(n)>=0&&(t[r]=!0);return t}function Le(n=null){this.j={},this.jr=[],this.jd=null,this.t=n}Le.groups={};Le.prototype={accepts(){return!!this.t},go(n){let e=this,t=e.j[n];if(t)return t;for(let r=0;rn.ta(e,t,r,i),Z=(n,e,t,r,i)=>n.tr(e,t,r,i),_f=(n,e,t,r,i)=>n.ts(e,t,r,i),w=(n,e,t,r,i)=>n.tt(e,t,r,i),Tt="WORD",Fl="UWORD",Xf="ASCIINUMERICAL",Qf="ALPHANUMERICAL",Fr="LOCALHOST",Hl="TLD",$l="UTLD",ro="SCHEME",Kn="SLASH_SCHEME",jl="NUM",Vl="WS",Wl="NL",Ir="OPENBRACE",Pr="CLOSEBRACE",io="OPENBRACKET",oo="CLOSEBRACKET",so="OPENPAREN",lo="CLOSEPAREN",ao="OPENANGLEBRACKET",co="CLOSEANGLEBRACKET",uo="FULLWIDTHLEFTPAREN",fo="FULLWIDTHRIGHTPAREN",po="LEFTCORNERBRACKET",ho="RIGHTCORNERBRACKET",mo="LEFTWHITECORNERBRACKET",go="RIGHTWHITECORNERBRACKET",yo="FULLWIDTHLESSTHAN",bo="FULLWIDTHGREATERTHAN",vo="AMPERSAND",xo="APOSTROPHE",ko="ASTERISK",Ut="AT",So="BACKSLASH",wo="BACKTICK",Co="CARET",mn="COLON",Ul="COMMA",Mo="DOLLAR",ut="DOT",Eo="EQUALS",_l="EXCLAMATION",qe="HYPHEN",Lr="PERCENT",Oo="PIPE",To="PLUS",Ao="POUND",Br="QUERY",Kl="QUOTE",Zf="FULLWIDTHMIDDLEDOT",ql="SEMI",ft="SLASH",zr="TILDE",No="UNDERSCORE",ed="EMOJI",Do="SYM",td=Object.freeze({__proto__:null,ALPHANUMERICAL:Qf,AMPERSAND:vo,APOSTROPHE:xo,ASCIINUMERICAL:Xf,ASTERISK:ko,AT:Ut,BACKSLASH:So,BACKTICK:wo,CARET:Co,CLOSEANGLEBRACKET:co,CLOSEBRACE:Pr,CLOSEBRACKET:oo,CLOSEPAREN:lo,COLON:mn,COMMA:Ul,DOLLAR:Mo,DOT:ut,EMOJI:ed,EQUALS:Eo,EXCLAMATION:_l,FULLWIDTHGREATERTHAN:bo,FULLWIDTHLEFTPAREN:uo,FULLWIDTHLESSTHAN:yo,FULLWIDTHMIDDLEDOT:Zf,FULLWIDTHRIGHTPAREN:fo,HYPHEN:qe,LEFTCORNERBRACKET:po,LEFTWHITECORNERBRACKET:mo,LOCALHOST:Fr,NL:Wl,NUM:jl,OPENANGLEBRACKET:ao,OPENBRACE:Ir,OPENBRACKET:io,OPENPAREN:so,PERCENT:Lr,PIPE:Oo,PLUS:To,POUND:Ao,QUERY:Br,QUOTE:Kl,RIGHTCORNERBRACKET:ho,RIGHTWHITECORNERBRACKET:go,SCHEME:ro,SEMI:ql,SLASH:ft,SLASH_SCHEME:Kn,SYM:Do,TILDE:zr,TLD:Hl,UNDERSCORE:No,UTLD:$l,UWORD:Fl,WORD:Tt,WS:Vl}),Et=/[a-z]/,Nr=/\p{L}/u,Al=/\p{Emoji}/u;var Ot=/\d/,Nl=/\s/;var Kf="\r",Dl=` +`,Zy="\uFE0F",e0="\u200D",Rl="\uFFFC",eo=null,to=null;function t0(n=[]){let e={};Le.groups=e;let t=new Le;eo==null&&(eo=qf(qy)),to==null&&(to=qf(Jy)),w(t,"'",xo),w(t,"{",Ir),w(t,"}",Pr),w(t,"[",io),w(t,"]",oo),w(t,"(",so),w(t,")",lo),w(t,"<",ao),w(t,">",co),w(t,"\uFF08",uo),w(t,"\uFF09",fo),w(t,"\u300C",po),w(t,"\u300D",ho),w(t,"\u300E",mo),w(t,"\u300F",go),w(t,"\uFF1C",yo),w(t,"\uFF1E",bo),w(t,"&",vo),w(t,"*",ko),w(t,"@",Ut),w(t,"`",wo),w(t,"^",Co),w(t,":",mn),w(t,",",Ul),w(t,"$",Mo),w(t,".",ut),w(t,"=",Eo),w(t,"!",_l),w(t,"-",qe),w(t,"%",Lr),w(t,"|",Oo),w(t,"+",To),w(t,"#",Ao),w(t,"?",Br),w(t,'"',Kl),w(t,"/",ft),w(t,";",ql),w(t,"~",zr),w(t,"_",No),w(t,"\\",So),w(t,"\u30FB",Zf);let r=Z(t,Ot,jl,{[Pl]:!0});Z(r,Ot,r);let i=Z(r,Et,Xf,{[Rr]:!0}),o=Z(r,Nr,Qf,{[Dr]:!0}),s=Z(t,Et,Tt,{[Ll]:!0});Z(s,Ot,i),Z(s,Et,s),Z(i,Ot,i),Z(i,Et,i);let l=Z(t,Nr,Fl,{[Bl]:!0});Z(l,Et),Z(l,Ot,o),Z(l,Nr,l),Z(o,Ot,o),Z(o,Et),Z(o,Nr,o);let a=w(t,Dl,Wl,{[Tl]:!0}),c=w(t,Kf,Vl,{[Tl]:!0}),u=Z(t,Nl,Vl,{[Tl]:!0});w(t,Rl,u),w(c,Dl,a),w(c,Rl,u),Z(c,Nl,u),w(u,Kf),w(u,Dl),Z(u,Nl,u),w(u,Rl,u);let f=Z(t,Al,ed,{[Yf]:!0});w(f,"#"),Z(f,Al,f),w(f,Zy,f);let d=w(f,e0);w(d,"#"),Z(d,Al,f);let p=[[Et,s],[Ot,i]],h=[[Et,null],[Nr,l],[Ot,o]];for(let m=0;mm[0]>g[0]?1:-1);for(let m=0;m=0?x[zl]=!0:Et.test(g)?Ot.test(g)?x[Rr]=!0:x[Ll]=!0:x[Pl]=!0,_f(t,g,g,x)}return _f(t,"localhost",Fr,{ascii:!0}),t.jd=new Le(Do),{start:t,tokens:Object.assign({groups:e},td)}}function nd(n,e){let t=n0(e.replace(/[A-Z]/g,l=>l.toLowerCase())),r=t.length,i=[],o=0,s=0;for(;s=0&&(f+=t[s].length,d++),c+=t[s].length,o+=t[s].length,s++;o-=f,s-=d,c-=f,i.push({t:u.t,v:e.slice(o-c,o),s:o-c,e:o})}return i}function n0(n){let e=[],t=n.length,r=0;for(;r56319||r+1===t||(o=n.charCodeAt(r+1))<56320||o>57343?n[r]:n.slice(r,r+2);e.push(s),r+=s.length}return e}function Wt(n,e,t,r,i){let o,s=e.length;for(let l=0;l=0;)o++;if(o>0){e.push(t.join(""));for(let s=parseInt(n.substring(r,r+o),10);s>0;s--)t.pop();r+=o}else t.push(n[r]),r++}return e}var Hr={defaultProtocol:"http",events:null,format:Jf,formatHref:Jf,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function Jl(n,e=null){let t=Object.assign({},Hr);n&&(t=Object.assign(t,n instanceof Jl?n.o:n));let r=t.ignoreTags,i=[];for(let o=0;ot?r.substring(0,t)+"\u2026":r},toFormattedHref(n){return n.get("formatHref",this.toHref(n.get("defaultProtocol")),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(n=Hr.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(n),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(n){return{type:this.t,value:this.toFormattedString(n),isLink:this.isLink,href:this.toFormattedHref(n),start:this.startIndex(),end:this.endIndex()}},validate(n){return n.get("validate",this.toString(),this)},render(n){let e=this,t=this.toHref(n.get("defaultProtocol")),r=n.get("formatHref",t,this),i=n.get("tagName",t,e),o=this.toFormattedString(n),s={},l=n.get("className",t,e),a=n.get("target",t,e),c=n.get("rel",t,e),u=n.getObj("attributes",t,e),f=n.getObj("events",t,e);return s.href=r,l&&(s.class=l),a&&(s.target=a),c&&(s.rel=c),u&&Object.assign(s,u),{tagName:i,attributes:s,content:o,eventListeners:f}}};function Ro(n,e){class t extends rd{constructor(i,o){super(i,o),this.t=n}}for(let r in e)t.prototype[r]=e[r];return t.t=n,t}var r0=Ro("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),Gf=Ro("text"),i0=Ro("nl"),no=Ro("url",{isLink:!0,toHref(n=Hr.defaultProtocol){return this.hasProtocol()?this.v:`${n}://${this.v}`},hasProtocol(){let n=this.tk;return n.length>=2&&n[0].t!==Fr&&n[1].t===mn}});var Ke=n=>new Le(n);function o0({groups:n}){let e=n.domain.concat([vo,ko,Ut,So,wo,Co,Mo,Eo,qe,jl,Lr,Oo,To,Ao,ft,Do,zr,No]),t=[xo,mn,Ul,ut,_l,Lr,Br,Kl,ql,ao,co,Ir,Pr,oo,io,so,lo,uo,fo,po,ho,mo,go,yo,bo],r=[vo,xo,ko,So,wo,Co,Mo,Eo,qe,Ir,Pr,Lr,Oo,To,Ao,Br,ft,Do,zr,No],i=Ke(),o=w(i,zr);H(o,r,o),H(o,n.domain,o);let s=Ke(),l=Ke(),a=Ke();H(i,n.domain,s),H(i,n.scheme,l),H(i,n.slashscheme,a),H(s,r,o),H(s,n.domain,s);let c=w(s,Ut);w(o,Ut,c),w(l,Ut,c),w(a,Ut,c);let u=w(o,ut);H(u,r,o),H(u,n.domain,o);let f=Ke();H(c,n.domain,f),H(f,n.domain,f);let d=w(f,ut);H(d,n.domain,f);let p=Ke(r0);H(d,n.tld,p),H(d,n.utld,p),w(c,Fr,p);let h=w(f,qe);w(h,qe,h),H(h,n.domain,f),H(p,n.domain,f),w(p,ut,d),w(p,qe,h);let m=w(s,qe),g=w(s,ut);w(m,qe,m),H(m,n.domain,s),H(g,r,o),H(g,n.domain,s);let b=Ke(no);H(g,n.tld,b),H(g,n.utld,b),H(b,n.domain,s),H(b,r,o),w(b,ut,g),w(b,qe,m),w(b,Ut,c);let x=w(b,mn),C=Ke(no);H(x,n.numeric,C);let y=Ke(no),M=Ke();H(y,e,y),H(y,t,M),H(M,e,y),H(M,t,M),w(b,ft,y),w(C,ft,y);let k=w(l,mn),R=w(a,mn),B=w(R,ft),O=w(B,ft);H(l,n.domain,s),w(l,ut,g),w(l,qe,m),H(a,n.domain,s),w(a,ut,g),w(a,qe,m),H(k,n.domain,y),w(k,ft,y),w(k,Br,y),H(O,n.domain,y),H(O,e,y),w(O,ft,y);let N=[[Ir,Pr],[io,oo],[so,lo],[ao,co],[uo,fo],[po,ho],[mo,go],[yo,bo]];for(let z=0;z=0&&d++,i++,u++;if(d<0)i-=u,i0&&(o.push(Il(Gf,e,s)),s=[]),i-=d,u-=d;let p=f.t,h=t.slice(i-u,i);o.push(Il(p,e,h))}}return s.length>0&&o.push(Il(Gf,e,s)),o}function Il(n,e,t){let r=t[0].s,i=t[t.length-1].e,o=e.slice(r,i);return new n(o,t)}var l0=typeof console<"u"&&console&&console.warn||(()=>{}),a0="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",Y={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function id(){return Le.groups={},Y.scanner=null,Y.parser=null,Y.tokenQueue=[],Y.pluginQueue=[],Y.customSchemes=[],Y.initialized=!1,Y}function Gl(n,e=!1){if(Y.initialized&&l0(`linkifyjs: already initialized - will not register custom scheme "${n}" ${a0}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(n))throw new Error(`linkifyjs: incorrect scheme format. +1. Must only contain digits, lowercase ASCII letters or "-" +2. Cannot start or end with "-" +3. "-" cannot repeat`);Y.customSchemes.push([n,e])}function c0(){Y.scanner=t0(Y.customSchemes);for(let n=0;n{let i=e.some(c=>c.docChanged)&&!t.doc.eq(r.doc),o=e.some(c=>c.getMeta("preventAutolink"));if(!i||o)return;let{tr:s}=r,l=sf(t.doc,[...e]);if(af(l).forEach(({newRange:c})=>{let u=lf(r.doc,c,p=>p.isTextblock),f,d;if(u.length>1)f=u[0],d=r.doc.textBetween(f.pos,f.pos+f.node.nodeSize,void 0," ");else if(u.length){let p=r.doc.textBetween(c.from,c.to," "," ");if(!f0.test(p))return;f=u[0],d=r.doc.textBetween(f.pos,c.to,void 0," ")}if(f&&d){let p=d.split(u0).filter(Boolean);if(p.length<=0)return!1;let h=p[p.length-1],m=f.pos+d.lastIndexOf(h);if(!h)return!1;let g=Io(h).map(b=>b.toObject(n.defaultProtocol));if(!p0(g))return!1;g.filter(b=>b.isLink).map(b=>({...b,from:m+b.start+1,to:m+b.end+1})).filter(b=>r.schema.marks.code?!r.doc.rangeHasMark(b.from,b.to,r.schema.marks.code):!0).filter(b=>n.validate(b.value)).filter(b=>n.shouldAutoLink(b.value)).forEach(b=>{Gi(b.from,b.to,r.doc).some(x=>x.mark.type===n.type)||s.addMark(b.from,b.to,n.type.create({href:b.href}))})}}),!!s.steps.length)return s}})}function m0(n){return new _({key:new G("handleClickLink"),props:{handleClick:(e,t,r)=>{var i,o;if(r.button!==0||!e.editable)return!1;let s=r.target,l=[];for(;s.nodeName!=="DIV";)l.push(s),s=s.parentNode;if(!l.find(d=>d.nodeName==="A"))return!1;let a=xl(e.state,n.type.name),c=r.target,u=(i=c?.href)!==null&&i!==void 0?i:a.href,f=(o=c?.target)!==null&&o!==void 0?o:a.target;return c&&u?(window.open(u,f),!0):!1}}})}function g0(n){return new _({key:new G("handlePasteLink"),props:{handlePaste:(e,t,r)=>{let{state:i}=e,{selection:o}=i,{empty:s}=o;if(s)return!1;let l="";r.content.forEach(c=>{l+=c.textContent});let a=Yl(l,{defaultProtocol:n.defaultProtocol}).find(c=>c.isLink&&c.value===l);return!l||!a?!1:n.editor.commands.setMark(n.type,{href:a.href})}}})}function gn(n,e){let t=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return e&&e.forEach(r=>{let i=typeof r=="string"?r:r.scheme;i&&t.push(i)}),!n||n.replace(d0,"").match(new RegExp(`^(?:(?:${t.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var od=De.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(n=>{if(typeof n=="string"){Gl(n);return}Gl(n.scheme,n.optionalSlashes)})},onDestroy(){id()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,linkOnPaste:!0,autolink:!0,protocols:[],defaultProtocol:"http",HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},isAllowedUri:(n,e)=>!!gn(n,e.protocols),validate:n=>!!n,shouldAutoLink:n=>!!n}},addAttributes(){return{href:{default:null,parseHTML(n){return n.getAttribute("href")}},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class}}},parseHTML(){return[{tag:"a[href]",getAttrs:n=>{let e=n.getAttribute("href");return!e||!this.options.isAllowedUri(e,{defaultValidate:t=>!!gn(t,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:n}){return this.options.isAllowedUri(n.href,{defaultValidate:e=>!!gn(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",$(this.options.HTMLAttributes,n),0]:["a",$(this.options.HTMLAttributes,{...n,href:""}),0]},addCommands(){return{setLink:n=>({chain:e})=>{let{href:t}=n;return this.options.isAllowedUri(t,{defaultValidate:r=>!!gn(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().setMark(this.name,n).setMeta("preventAutolink",!0).run():!1},toggleLink:n=>({chain:e})=>{let{href:t}=n;return this.options.isAllowedUri(t,{defaultValidate:r=>!!gn(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().toggleMark(this.name,n,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run():!1},unsetLink:()=>({chain:n})=>n().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[_e({find:n=>{let e=[];if(n){let{protocols:t,defaultProtocol:r}=this.options,i=Yl(n).filter(o=>o.isLink&&this.options.isAllowedUri(o.value,{defaultValidate:s=>!!gn(s,t),protocols:t,defaultProtocol:r}));i.length&&i.forEach(o=>e.push({text:o.value,data:{href:o.href},index:o.start}))}return e},type:this.type,getAttributes:n=>{var e;return{href:(e=n.data)===null||e===void 0?void 0:e.href}}})]},addProseMirrorPlugins(){let n=[],{protocols:e,defaultProtocol:t}=this.options;return this.options.autolink&&n.push(h0({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:i=>!!gn(i,e),protocols:e,defaultProtocol:t}),shouldAutoLink:this.options.shouldAutoLink})),this.options.openOnClick===!0&&n.push(m0({type:this.type})),this.options.linkOnPaste&&n.push(g0({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type})),n}});var ee="top",ce="bottom",ae="right",ie="left",Po="auto",_t=[ee,ce,ae,ie],At="start",yn="end",sd="clippingParents",Lo="viewport",qn="popper",ld="reference",Ql=_t.reduce(function(n,e){return n.concat([e+"-"+At,e+"-"+yn])},[]),Bo=[].concat(_t,[Po]).reduce(function(n,e){return n.concat([e,e+"-"+At,e+"-"+yn])},[]),y0="beforeRead",b0="read",v0="afterRead",x0="beforeMain",k0="main",S0="afterMain",w0="beforeWrite",C0="write",M0="afterWrite",ad=[y0,b0,v0,x0,k0,S0,w0,C0,M0];function he(n){return n?(n.nodeName||"").toLowerCase():null}function Q(n){if(n==null)return window;if(n.toString()!=="[object Window]"){var e=n.ownerDocument;return e&&e.defaultView||window}return n}function Je(n){var e=Q(n).Element;return n instanceof e||n instanceof Element}function ue(n){var e=Q(n).HTMLElement;return n instanceof e||n instanceof HTMLElement}function Jn(n){if(typeof ShadowRoot>"u")return!1;var e=Q(n).ShadowRoot;return n instanceof e||n instanceof ShadowRoot}function E0(n){var e=n.state;Object.keys(e.elements).forEach(function(t){var r=e.styles[t]||{},i=e.attributes[t]||{},o=e.elements[t];!ue(o)||!he(o)||(Object.assign(o.style,r),Object.keys(i).forEach(function(s){var l=i[s];l===!1?o.removeAttribute(s):o.setAttribute(s,l===!0?"":l)}))})}function O0(n){var e=n.state,t={popper:{position:e.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};return Object.assign(e.elements.popper.style,t.popper),e.styles=t,e.elements.arrow&&Object.assign(e.elements.arrow.style,t.arrow),function(){Object.keys(e.elements).forEach(function(r){var i=e.elements[r],o=e.attributes[r]||{},s=Object.keys(e.styles.hasOwnProperty(r)?e.styles[r]:t[r]),l=s.reduce(function(a,c){return a[c]="",a},{});!ue(i)||!he(i)||(Object.assign(i.style,l),Object.keys(o).forEach(function(a){i.removeAttribute(a)}))})}}var $r={name:"applyStyles",enabled:!0,phase:"write",fn:E0,effect:O0,requires:["computeStyles"]};function me(n){return n.split("-")[0]}var tt=Math.max,bn=Math.min,Nt=Math.round;function Gn(){var n=navigator.userAgentData;return n!=null&&n.brands&&Array.isArray(n.brands)?n.brands.map(function(e){return e.brand+"/"+e.version}).join(" "):navigator.userAgent}function Vr(){return!/^((?!chrome|android).)*safari/i.test(Gn())}function Ge(n,e,t){e===void 0&&(e=!1),t===void 0&&(t=!1);var r=n.getBoundingClientRect(),i=1,o=1;e&&ue(n)&&(i=n.offsetWidth>0&&Nt(r.width)/n.offsetWidth||1,o=n.offsetHeight>0&&Nt(r.height)/n.offsetHeight||1);var s=Je(n)?Q(n):window,l=s.visualViewport,a=!Vr()&&t,c=(r.left+(a&&l?l.offsetLeft:0))/i,u=(r.top+(a&&l?l.offsetTop:0))/o,f=r.width/i,d=r.height/o;return{width:f,height:d,top:u,right:c+f,bottom:u+d,left:c,x:c,y:u}}function vn(n){var e=Ge(n),t=n.offsetWidth,r=n.offsetHeight;return Math.abs(e.width-t)<=1&&(t=e.width),Math.abs(e.height-r)<=1&&(r=e.height),{x:n.offsetLeft,y:n.offsetTop,width:t,height:r}}function jr(n,e){var t=e.getRootNode&&e.getRootNode();if(n.contains(e))return!0;if(t&&Jn(t)){var r=e;do{if(r&&n.isSameNode(r))return!0;r=r.parentNode||r.host}while(r)}return!1}function Re(n){return Q(n).getComputedStyle(n)}function Zl(n){return["table","td","th"].indexOf(he(n))>=0}function xe(n){return((Je(n)?n.ownerDocument:n.document)||window.document).documentElement}function Dt(n){return he(n)==="html"?n:n.assignedSlot||n.parentNode||(Jn(n)?n.host:null)||xe(n)}function cd(n){return!ue(n)||Re(n).position==="fixed"?null:n.offsetParent}function T0(n){var e=/firefox/i.test(Gn()),t=/Trident/i.test(Gn());if(t&&ue(n)){var r=Re(n);if(r.position==="fixed")return null}var i=Dt(n);for(Jn(i)&&(i=i.host);ue(i)&&["html","body"].indexOf(he(i))<0;){var o=Re(i);if(o.transform!=="none"||o.perspective!=="none"||o.contain==="paint"||["transform","perspective"].indexOf(o.willChange)!==-1||e&&o.willChange==="filter"||e&&o.filter&&o.filter!=="none")return i;i=i.parentNode}return null}function nt(n){for(var e=Q(n),t=cd(n);t&&Zl(t)&&Re(t).position==="static";)t=cd(t);return t&&(he(t)==="html"||he(t)==="body"&&Re(t).position==="static")?e:t||T0(n)||e}function xn(n){return["top","bottom"].indexOf(n)>=0?"x":"y"}function kn(n,e,t){return tt(n,bn(e,t))}function ud(n,e,t){var r=kn(n,e,t);return r>t?t:r}function Wr(){return{top:0,right:0,bottom:0,left:0}}function Ur(n){return Object.assign({},Wr(),n)}function _r(n,e){return e.reduce(function(t,r){return t[r]=n,t},{})}var A0=function(e,t){return e=typeof e=="function"?e(Object.assign({},t.rects,{placement:t.placement})):e,Ur(typeof e!="number"?e:_r(e,_t))};function N0(n){var e,t=n.state,r=n.name,i=n.options,o=t.elements.arrow,s=t.modifiersData.popperOffsets,l=me(t.placement),a=xn(l),c=[ie,ae].indexOf(l)>=0,u=c?"height":"width";if(!(!o||!s)){var f=A0(i.padding,t),d=vn(o),p=a==="y"?ee:ie,h=a==="y"?ce:ae,m=t.rects.reference[u]+t.rects.reference[a]-s[a]-t.rects.popper[u],g=s[a]-t.rects.reference[a],b=nt(o),x=b?a==="y"?b.clientHeight||0:b.clientWidth||0:0,C=m/2-g/2,y=f[p],M=x-d[u]-f[h],k=x/2-d[u]/2+C,R=kn(y,k,M),B=a;t.modifiersData[r]=(e={},e[B]=R,e.centerOffset=R-k,e)}}function D0(n){var e=n.state,t=n.options,r=t.element,i=r===void 0?"[data-popper-arrow]":r;i!=null&&(typeof i=="string"&&(i=e.elements.popper.querySelector(i),!i)||jr(e.elements.popper,i)&&(e.elements.arrow=i))}var fd={name:"arrow",enabled:!0,phase:"main",fn:N0,effect:D0,requires:["popperOffsets"],requiresIfExists:["preventOverflow"]};function Ye(n){return n.split("-")[1]}var R0={top:"auto",right:"auto",bottom:"auto",left:"auto"};function I0(n,e){var t=n.x,r=n.y,i=e.devicePixelRatio||1;return{x:Nt(t*i)/i||0,y:Nt(r*i)/i||0}}function dd(n){var e,t=n.popper,r=n.popperRect,i=n.placement,o=n.variation,s=n.offsets,l=n.position,a=n.gpuAcceleration,c=n.adaptive,u=n.roundOffsets,f=n.isFixed,d=s.x,p=d===void 0?0:d,h=s.y,m=h===void 0?0:h,g=typeof u=="function"?u({x:p,y:m}):{x:p,y:m};p=g.x,m=g.y;var b=s.hasOwnProperty("x"),x=s.hasOwnProperty("y"),C=ie,y=ee,M=window;if(c){var k=nt(t),R="clientHeight",B="clientWidth";if(k===Q(t)&&(k=xe(t),Re(k).position!=="static"&&l==="absolute"&&(R="scrollHeight",B="scrollWidth")),k=k,i===ee||(i===ie||i===ae)&&o===yn){y=ce;var O=f&&k===M&&M.visualViewport?M.visualViewport.height:k[R];m-=O-r.height,m*=a?1:-1}if(i===ie||(i===ee||i===ce)&&o===yn){C=ae;var N=f&&k===M&&M.visualViewport?M.visualViewport.width:k[B];p-=N-r.width,p*=a?1:-1}}var z=Object.assign({position:l},c&&R0),V=u===!0?I0({x:p,y:m},Q(t)):{x:p,y:m};if(p=V.x,m=V.y,a){var U;return Object.assign({},z,(U={},U[y]=x?"0":"",U[C]=b?"0":"",U.transform=(M.devicePixelRatio||1)<=1?"translate("+p+"px, "+m+"px)":"translate3d("+p+"px, "+m+"px, 0)",U))}return Object.assign({},z,(e={},e[y]=x?m+"px":"",e[C]=b?p+"px":"",e.transform="",e))}function P0(n){var e=n.state,t=n.options,r=t.gpuAcceleration,i=r===void 0?!0:r,o=t.adaptive,s=o===void 0?!0:o,l=t.roundOffsets,a=l===void 0?!0:l,c={placement:me(e.placement),variation:Ye(e.placement),popper:e.elements.popper,popperRect:e.rects.popper,gpuAcceleration:i,isFixed:e.options.strategy==="fixed"};e.modifiersData.popperOffsets!=null&&(e.styles.popper=Object.assign({},e.styles.popper,dd(Object.assign({},c,{offsets:e.modifiersData.popperOffsets,position:e.options.strategy,adaptive:s,roundOffsets:a})))),e.modifiersData.arrow!=null&&(e.styles.arrow=Object.assign({},e.styles.arrow,dd(Object.assign({},c,{offsets:e.modifiersData.arrow,position:"absolute",adaptive:!1,roundOffsets:a})))),e.attributes.popper=Object.assign({},e.attributes.popper,{"data-popper-placement":e.placement})}var pd={name:"computeStyles",enabled:!0,phase:"beforeWrite",fn:P0,data:{}};var zo={passive:!0};function L0(n){var e=n.state,t=n.instance,r=n.options,i=r.scroll,o=i===void 0?!0:i,s=r.resize,l=s===void 0?!0:s,a=Q(e.elements.popper),c=[].concat(e.scrollParents.reference,e.scrollParents.popper);return o&&c.forEach(function(u){u.addEventListener("scroll",t.update,zo)}),l&&a.addEventListener("resize",t.update,zo),function(){o&&c.forEach(function(u){u.removeEventListener("scroll",t.update,zo)}),l&&a.removeEventListener("resize",t.update,zo)}}var hd={name:"eventListeners",enabled:!0,phase:"write",fn:function(){},effect:L0,data:{}};var B0={left:"right",right:"left",bottom:"top",top:"bottom"};function Yn(n){return n.replace(/left|right|bottom|top/g,function(e){return B0[e]})}var z0={start:"end",end:"start"};function Fo(n){return n.replace(/start|end/g,function(e){return z0[e]})}function Sn(n){var e=Q(n),t=e.pageXOffset,r=e.pageYOffset;return{scrollLeft:t,scrollTop:r}}function wn(n){return Ge(xe(n)).left+Sn(n).scrollLeft}function ea(n,e){var t=Q(n),r=xe(n),i=t.visualViewport,o=r.clientWidth,s=r.clientHeight,l=0,a=0;if(i){o=i.width,s=i.height;var c=Vr();(c||!c&&e==="fixed")&&(l=i.offsetLeft,a=i.offsetTop)}return{width:o,height:s,x:l+wn(n),y:a}}function ta(n){var e,t=xe(n),r=Sn(n),i=(e=n.ownerDocument)==null?void 0:e.body,o=tt(t.scrollWidth,t.clientWidth,i?i.scrollWidth:0,i?i.clientWidth:0),s=tt(t.scrollHeight,t.clientHeight,i?i.scrollHeight:0,i?i.clientHeight:0),l=-r.scrollLeft+wn(n),a=-r.scrollTop;return Re(i||t).direction==="rtl"&&(l+=tt(t.clientWidth,i?i.clientWidth:0)-o),{width:o,height:s,x:l,y:a}}function Cn(n){var e=Re(n),t=e.overflow,r=e.overflowX,i=e.overflowY;return/auto|scroll|overlay|hidden/.test(t+i+r)}function Ho(n){return["html","body","#document"].indexOf(he(n))>=0?n.ownerDocument.body:ue(n)&&Cn(n)?n:Ho(Dt(n))}function Kt(n,e){var t;e===void 0&&(e=[]);var r=Ho(n),i=r===((t=n.ownerDocument)==null?void 0:t.body),o=Q(r),s=i?[o].concat(o.visualViewport||[],Cn(r)?r:[]):r,l=e.concat(s);return i?l:l.concat(Kt(Dt(s)))}function Xn(n){return Object.assign({},n,{left:n.x,top:n.y,right:n.x+n.width,bottom:n.y+n.height})}function F0(n,e){var t=Ge(n,!1,e==="fixed");return t.top=t.top+n.clientTop,t.left=t.left+n.clientLeft,t.bottom=t.top+n.clientHeight,t.right=t.left+n.clientWidth,t.width=n.clientWidth,t.height=n.clientHeight,t.x=t.left,t.y=t.top,t}function md(n,e,t){return e===Lo?Xn(ea(n,t)):Je(e)?F0(e,t):Xn(ta(xe(n)))}function H0(n){var e=Kt(Dt(n)),t=["absolute","fixed"].indexOf(Re(n).position)>=0,r=t&&ue(n)?nt(n):n;return Je(r)?e.filter(function(i){return Je(i)&&jr(i,r)&&he(i)!=="body"}):[]}function na(n,e,t,r){var i=e==="clippingParents"?H0(n):[].concat(e),o=[].concat(i,[t]),s=o[0],l=o.reduce(function(a,c){var u=md(n,c,r);return a.top=tt(u.top,a.top),a.right=bn(u.right,a.right),a.bottom=bn(u.bottom,a.bottom),a.left=tt(u.left,a.left),a},md(n,s,r));return l.width=l.right-l.left,l.height=l.bottom-l.top,l.x=l.left,l.y=l.top,l}function Kr(n){var e=n.reference,t=n.element,r=n.placement,i=r?me(r):null,o=r?Ye(r):null,s=e.x+e.width/2-t.width/2,l=e.y+e.height/2-t.height/2,a;switch(i){case ee:a={x:s,y:e.y-t.height};break;case ce:a={x:s,y:e.y+e.height};break;case ae:a={x:e.x+e.width,y:l};break;case ie:a={x:e.x-t.width,y:l};break;default:a={x:e.x,y:e.y}}var c=i?xn(i):null;if(c!=null){var u=c==="y"?"height":"width";switch(o){case At:a[c]=a[c]-(e[u]/2-t[u]/2);break;case yn:a[c]=a[c]+(e[u]/2-t[u]/2);break;default:}}return a}function rt(n,e){e===void 0&&(e={});var t=e,r=t.placement,i=r===void 0?n.placement:r,o=t.strategy,s=o===void 0?n.strategy:o,l=t.boundary,a=l===void 0?sd:l,c=t.rootBoundary,u=c===void 0?Lo:c,f=t.elementContext,d=f===void 0?qn:f,p=t.altBoundary,h=p===void 0?!1:p,m=t.padding,g=m===void 0?0:m,b=Ur(typeof g!="number"?g:_r(g,_t)),x=d===qn?ld:qn,C=n.rects.popper,y=n.elements[h?x:d],M=na(Je(y)?y:y.contextElement||xe(n.elements.popper),a,u,s),k=Ge(n.elements.reference),R=Kr({reference:k,element:C,strategy:"absolute",placement:i}),B=Xn(Object.assign({},C,R)),O=d===qn?B:k,N={top:M.top-O.top+b.top,bottom:O.bottom-M.bottom+b.bottom,left:M.left-O.left+b.left,right:O.right-M.right+b.right},z=n.modifiersData.offset;if(d===qn&&z){var V=z[i];Object.keys(N).forEach(function(U){var te=[ae,ce].indexOf(U)>=0?1:-1,X=[ee,ce].indexOf(U)>=0?"y":"x";N[U]+=V[X]*te})}return N}function ra(n,e){e===void 0&&(e={});var t=e,r=t.placement,i=t.boundary,o=t.rootBoundary,s=t.padding,l=t.flipVariations,a=t.allowedAutoPlacements,c=a===void 0?Bo:a,u=Ye(r),f=u?l?Ql:Ql.filter(function(h){return Ye(h)===u}):_t,d=f.filter(function(h){return c.indexOf(h)>=0});d.length===0&&(d=f);var p=d.reduce(function(h,m){return h[m]=rt(n,{placement:m,boundary:i,rootBoundary:o,padding:s})[me(m)],h},{});return Object.keys(p).sort(function(h,m){return p[h]-p[m]})}function $0(n){if(me(n)===Po)return[];var e=Yn(n);return[Fo(n),e,Fo(e)]}function V0(n){var e=n.state,t=n.options,r=n.name;if(!e.modifiersData[r]._skip){for(var i=t.mainAxis,o=i===void 0?!0:i,s=t.altAxis,l=s===void 0?!0:s,a=t.fallbackPlacements,c=t.padding,u=t.boundary,f=t.rootBoundary,d=t.altBoundary,p=t.flipVariations,h=p===void 0?!0:p,m=t.allowedAutoPlacements,g=e.options.placement,b=me(g),x=b===g,C=a||(x||!h?[Yn(g)]:$0(g)),y=[g].concat(C).reduce(function(pt,Qe){return pt.concat(me(Qe)===Po?ra(e,{placement:Qe,boundary:u,rootBoundary:f,padding:c,flipVariations:h,allowedAutoPlacements:m}):Qe)},[]),M=e.rects.reference,k=e.rects.popper,R=new Map,B=!0,O=y[0],N=0;N=0,X=te?"width":"height",K=rt(e,{placement:z,boundary:u,rootBoundary:f,altBoundary:d,padding:c}),ne=te?U?ae:ie:U?ce:ee;M[X]>k[X]&&(ne=Yn(ne));var re=Yn(ne),ge=[];if(o&&ge.push(K[V]<=0),l&&ge.push(K[ne]<=0,K[re]<=0),ge.every(function(pt){return pt})){O=z,B=!1;break}R.set(z,ge)}if(B)for(var Be=h?3:1,ze=function(Qe){var ht=y.find(function(En){var mt=R.get(En);if(mt)return mt.slice(0,Qe).every(function(On){return On})});if(ht)return O=ht,"break"},Fe=Be;Fe>0;Fe--){var Xe=ze(Fe);if(Xe==="break")break}e.placement!==O&&(e.modifiersData[r]._skip=!0,e.placement=O,e.reset=!0)}}var gd={name:"flip",enabled:!0,phase:"main",fn:V0,requiresIfExists:["offset"],data:{_skip:!1}};function yd(n,e,t){return t===void 0&&(t={x:0,y:0}),{top:n.top-e.height-t.y,right:n.right-e.width+t.x,bottom:n.bottom-e.height+t.y,left:n.left-e.width-t.x}}function bd(n){return[ee,ae,ce,ie].some(function(e){return n[e]>=0})}function j0(n){var e=n.state,t=n.name,r=e.rects.reference,i=e.rects.popper,o=e.modifiersData.preventOverflow,s=rt(e,{elementContext:"reference"}),l=rt(e,{altBoundary:!0}),a=yd(s,r),c=yd(l,i,o),u=bd(a),f=bd(c);e.modifiersData[t]={referenceClippingOffsets:a,popperEscapeOffsets:c,isReferenceHidden:u,hasPopperEscaped:f},e.attributes.popper=Object.assign({},e.attributes.popper,{"data-popper-reference-hidden":u,"data-popper-escaped":f})}var vd={name:"hide",enabled:!0,phase:"main",requiresIfExists:["preventOverflow"],fn:j0};function W0(n,e,t){var r=me(n),i=[ie,ee].indexOf(r)>=0?-1:1,o=typeof t=="function"?t(Object.assign({},e,{placement:n})):t,s=o[0],l=o[1];return s=s||0,l=(l||0)*i,[ie,ae].indexOf(r)>=0?{x:l,y:s}:{x:s,y:l}}function U0(n){var e=n.state,t=n.options,r=n.name,i=t.offset,o=i===void 0?[0,0]:i,s=Bo.reduce(function(u,f){return u[f]=W0(f,e.rects,o),u},{}),l=s[e.placement],a=l.x,c=l.y;e.modifiersData.popperOffsets!=null&&(e.modifiersData.popperOffsets.x+=a,e.modifiersData.popperOffsets.y+=c),e.modifiersData[r]=s}var xd={name:"offset",enabled:!0,phase:"main",requires:["popperOffsets"],fn:U0};function _0(n){var e=n.state,t=n.name;e.modifiersData[t]=Kr({reference:e.rects.reference,element:e.rects.popper,strategy:"absolute",placement:e.placement})}var kd={name:"popperOffsets",enabled:!0,phase:"read",fn:_0,data:{}};function ia(n){return n==="x"?"y":"x"}function K0(n){var e=n.state,t=n.options,r=n.name,i=t.mainAxis,o=i===void 0?!0:i,s=t.altAxis,l=s===void 0?!1:s,a=t.boundary,c=t.rootBoundary,u=t.altBoundary,f=t.padding,d=t.tether,p=d===void 0?!0:d,h=t.tetherOffset,m=h===void 0?0:h,g=rt(e,{boundary:a,rootBoundary:c,padding:f,altBoundary:u}),b=me(e.placement),x=Ye(e.placement),C=!x,y=xn(b),M=ia(y),k=e.modifiersData.popperOffsets,R=e.rects.reference,B=e.rects.popper,O=typeof m=="function"?m(Object.assign({},e.rects,{placement:e.placement})):m,N=typeof O=="number"?{mainAxis:O,altAxis:O}:Object.assign({mainAxis:0,altAxis:0},O),z=e.modifiersData.offset?e.modifiersData.offset[e.placement]:null,V={x:0,y:0};if(k){if(o){var U,te=y==="y"?ee:ie,X=y==="y"?ce:ae,K=y==="y"?"height":"width",ne=k[y],re=ne+g[te],ge=ne-g[X],Be=p?-B[K]/2:0,ze=x===At?R[K]:B[K],Fe=x===At?-B[K]:-R[K],Xe=e.elements.arrow,pt=p&&Xe?vn(Xe):{width:0,height:0},Qe=e.modifiersData["arrow#persistent"]?e.modifiersData["arrow#persistent"].padding:Wr(),ht=Qe[te],En=Qe[X],mt=kn(0,R[K],pt[K]),On=C?R[K]/2-Be-mt-ht-N.mainAxis:ze-mt-ht-N.mainAxis,Rt=C?-R[K]/2+Be+mt+En+N.mainAxis:Fe+mt+En+N.mainAxis,Tn=e.elements.arrow&&nt(e.elements.arrow),Gr=Tn?y==="y"?Tn.clientTop||0:Tn.clientLeft||0:0,Zn=(U=z?.[y])!=null?U:0,Yr=ne+On-Zn-Gr,Xr=ne+Rt-Zn,er=kn(p?bn(re,Yr):re,ne,p?tt(ge,Xr):ge);k[y]=er,V[y]=er-ne}if(l){var tr,Qr=y==="x"?ee:ie,Zr=y==="x"?ce:ae,gt=k[M],It=M==="y"?"height":"width",nr=gt+g[Qr],qt=gt-g[Zr],rr=[ee,ie].indexOf(b)!==-1,ei=(tr=z?.[M])!=null?tr:0,ti=rr?nr:gt-R[It]-B[It]-ei+N.altAxis,ni=rr?gt+R[It]+B[It]-ei-N.altAxis:qt,ri=p&&rr?ud(ti,gt,ni):kn(p?ti:nr,gt,p?ni:qt);k[M]=ri,V[M]=ri-gt}e.modifiersData[r]=V}}var Sd={name:"preventOverflow",enabled:!0,phase:"main",fn:K0,requiresIfExists:["offset"]};function oa(n){return{scrollLeft:n.scrollLeft,scrollTop:n.scrollTop}}function sa(n){return n===Q(n)||!ue(n)?Sn(n):oa(n)}function q0(n){var e=n.getBoundingClientRect(),t=Nt(e.width)/n.offsetWidth||1,r=Nt(e.height)/n.offsetHeight||1;return t!==1||r!==1}function la(n,e,t){t===void 0&&(t=!1);var r=ue(e),i=ue(e)&&q0(e),o=xe(e),s=Ge(n,i,t),l={scrollLeft:0,scrollTop:0},a={x:0,y:0};return(r||!r&&!t)&&((he(e)!=="body"||Cn(o))&&(l=sa(e)),ue(e)?(a=Ge(e,!0),a.x+=e.clientLeft,a.y+=e.clientTop):o&&(a.x=wn(o))),{x:s.left+l.scrollLeft-a.x,y:s.top+l.scrollTop-a.y,width:s.width,height:s.height}}function J0(n){var e=new Map,t=new Set,r=[];n.forEach(function(o){e.set(o.name,o)});function i(o){t.add(o.name);var s=[].concat(o.requires||[],o.requiresIfExists||[]);s.forEach(function(l){if(!t.has(l)){var a=e.get(l);a&&i(a)}}),r.push(o)}return n.forEach(function(o){t.has(o.name)||i(o)}),r}function aa(n){var e=J0(n);return ad.reduce(function(t,r){return t.concat(e.filter(function(i){return i.phase===r}))},[])}function ca(n){var e;return function(){return e||(e=new Promise(function(t){Promise.resolve().then(function(){e=void 0,t(n())})})),e}}function ua(n){var e=n.reduce(function(t,r){var i=t[r.name];return t[r.name]=i?Object.assign({},i,r,{options:Object.assign({},i.options,r.options),data:Object.assign({},i.data,r.data)}):r,t},{});return Object.keys(e).map(function(t){return e[t]})}var wd={placement:"bottom",modifiers:[],strategy:"absolute"};function Cd(){for(var n=arguments.length,e=new Array(n),t=0;t-1}function Hd(n,e){return typeof n=="function"?n.apply(void 0,e):n}function Ed(n,e){if(e===0)return n;var t;return function(r){clearTimeout(t),t=setTimeout(function(){n(r)},e)}}function Q0(n){return n.split(/\s+/).filter(Boolean)}function Qn(n){return[].concat(n)}function Od(n,e){n.indexOf(e)===-1&&n.push(e)}function Z0(n){return n.filter(function(e,t){return n.indexOf(e)===t})}function eb(n){return n.split("-")[0]}function Vo(n){return[].slice.call(n)}function Td(n){return Object.keys(n).reduce(function(e,t){return n[t]!==void 0&&(e[t]=n[t]),e},{})}function qr(){return document.createElement("div")}function jo(n){return["Element","Fragment"].some(function(e){return ba(n,e)})}function tb(n){return ba(n,"NodeList")}function nb(n){return ba(n,"MouseEvent")}function rb(n){return!!(n&&n._tippy&&n._tippy.reference===n)}function ib(n){return jo(n)?[n]:tb(n)?Vo(n):Array.isArray(n)?n:Vo(document.querySelectorAll(n))}function pa(n,e){n.forEach(function(t){t&&(t.style.transitionDuration=e+"ms")})}function Ad(n,e){n.forEach(function(t){t&&t.setAttribute("data-state",e)})}function ob(n){var e,t=Qn(n),r=t[0];return r!=null&&(e=r.ownerDocument)!=null&&e.body?r.ownerDocument:document}function sb(n,e){var t=e.clientX,r=e.clientY;return n.every(function(i){var o=i.popperRect,s=i.popperState,l=i.props,a=l.interactiveBorder,c=eb(s.placement),u=s.modifiersData.offset;if(!u)return!0;var f=c==="bottom"?u.top.y:0,d=c==="top"?u.bottom.y:0,p=c==="right"?u.left.x:0,h=c==="left"?u.right.x:0,m=o.top-r+f>a,g=r-o.bottom-d>a,b=o.left-t+p>a,x=t-o.right-h>a;return m||g||b||x})}function ha(n,e,t){var r=e+"EventListener";["transitionend","webkitTransitionEnd"].forEach(function(i){n[r](i,t)})}function Nd(n,e){for(var t=e;t;){var r;if(n.contains(t))return!0;t=t.getRootNode==null||(r=t.getRootNode())==null?void 0:r.host}return!1}var dt={isTouch:!1},Dd=0;function lb(){dt.isTouch||(dt.isTouch=!0,window.performance&&document.addEventListener("mousemove",$d))}function $d(){var n=performance.now();n-Dd<20&&(dt.isTouch=!1,document.removeEventListener("mousemove",$d)),Dd=n}function ab(){var n=document.activeElement;if(rb(n)){var e=n._tippy;n.blur&&!e.state.isVisible&&n.blur()}}function cb(){document.addEventListener("touchstart",lb,Mn),window.addEventListener("blur",ab)}var ub=typeof window<"u"&&typeof document<"u",fb=ub?!!window.msCrypto:!1;var db={animateFill:!1,followCursor:!1,inlinePositioning:!1,sticky:!1},pb={allowHTML:!1,animation:"fade",arrow:!0,content:"",inertia:!1,maxWidth:350,role:"tooltip",theme:"",zIndex:9999},it=Object.assign({appendTo:Fd,aria:{content:"auto",expanded:"auto"},delay:0,duration:[300,250],getReferenceClientRect:null,hideOnClick:!0,ignoreAttributes:!1,interactive:!1,interactiveBorder:2,interactiveDebounce:0,moveTransition:"",offset:[0,10],onAfterUpdate:function(){},onBeforeUpdate:function(){},onCreate:function(){},onDestroy:function(){},onHidden:function(){},onHide:function(){},onMount:function(){},onShow:function(){},onShown:function(){},onTrigger:function(){},onUntrigger:function(){},onClickOutside:function(){},placement:"top",plugins:[],popperOptions:{},render:null,showOnCreate:!1,touch:!0,trigger:"mouseenter focus",triggerTarget:null},db,pb),hb=Object.keys(it),mb=function(e){var t=Object.keys(e);t.forEach(function(r){it[r]=e[r]})};function Vd(n){var e=n.plugins||[],t=e.reduce(function(r,i){var o=i.name,s=i.defaultValue;if(o){var l;r[o]=n[o]!==void 0?n[o]:(l=it[o])!=null?l:s}return r},{});return Object.assign({},n,t)}function gb(n,e){var t=e?Object.keys(Vd(Object.assign({},it,{plugins:e}))):hb,r=t.reduce(function(i,o){var s=(n.getAttribute("data-tippy-"+o)||"").trim();if(!s)return i;if(o==="content")i[o]=s;else try{i[o]=JSON.parse(s)}catch{i[o]=s}return i},{});return r}function Rd(n,e){var t=Object.assign({},e,{content:Hd(e.content,[n])},e.ignoreAttributes?{}:gb(n,e.plugins));return t.aria=Object.assign({},it.aria,t.aria),t.aria={expanded:t.aria.expanded==="auto"?e.interactive:t.aria.expanded,content:t.aria.content==="auto"?e.interactive?null:"describedby":t.aria.content},t}var yb=function(){return"innerHTML"};function ga(n,e){n[yb()]=e}function Id(n){var e=qr();return n===!0?e.className=Bd:(e.className=zd,jo(n)?e.appendChild(n):ga(e,n)),e}function Pd(n,e){jo(e.content)?(ga(n,""),n.appendChild(e.content)):typeof e.content!="function"&&(e.allowHTML?ga(n,e.content):n.textContent=e.content)}function ya(n){var e=n.firstElementChild,t=Vo(e.children);return{box:e,content:t.find(function(r){return r.classList.contains(Ld)}),arrow:t.find(function(r){return r.classList.contains(Bd)||r.classList.contains(zd)}),backdrop:t.find(function(r){return r.classList.contains(X0)})}}function jd(n){var e=qr(),t=qr();t.className=Y0,t.setAttribute("data-state","hidden"),t.setAttribute("tabindex","-1");var r=qr();r.className=Ld,r.setAttribute("data-state","hidden"),Pd(r,n.props),e.appendChild(t),t.appendChild(r),i(n.props,n.props);function i(o,s){var l=ya(e),a=l.box,c=l.content,u=l.arrow;s.theme?a.setAttribute("data-theme",s.theme):a.removeAttribute("data-theme"),typeof s.animation=="string"?a.setAttribute("data-animation",s.animation):a.removeAttribute("data-animation"),s.inertia?a.setAttribute("data-inertia",""):a.removeAttribute("data-inertia"),a.style.maxWidth=typeof s.maxWidth=="number"?s.maxWidth+"px":s.maxWidth,s.role?a.setAttribute("role",s.role):a.removeAttribute("role"),(o.content!==s.content||o.allowHTML!==s.allowHTML)&&Pd(c,n.props),s.arrow?u?o.arrow!==s.arrow&&(a.removeChild(u),a.appendChild(Id(s.arrow))):a.appendChild(Id(s.arrow)):u&&a.removeChild(u)}return{popper:e,onUpdate:i}}jd.$$tippy=!0;var bb=1,$o=[],ma=[];function vb(n,e){var t=Rd(n,Object.assign({},it,Vd(Td(e)))),r,i,o,s=!1,l=!1,a=!1,c=!1,u,f,d,p=[],h=Ed(Yr,t.interactiveDebounce),m,g=bb++,b=null,x=Z0(t.plugins),C={isEnabled:!0,isVisible:!1,isDestroyed:!1,isMounted:!1,isShown:!1},y={id:g,reference:n,popper:qr(),popperInstance:b,props:t,state:C,plugins:x,clearDelayTimeouts:ti,setProps:ni,setContent:ri,show:qd,hide:Jd,hideWithInteractivity:Gd,enable:rr,disable:ei,unmount:Yd,destroy:Xd};if(!t.render)return y;var M=t.render(y),k=M.popper,R=M.onUpdate;k.setAttribute("data-tippy-root",""),k.id="tippy-"+y.id,y.popper=k,n._tippy=y,k._tippy=y;var B=x.map(function(v){return v.fn(y)}),O=n.hasAttribute("aria-expanded");return Tn(),Be(),ne(),re("onCreate",[y]),t.showOnCreate&&nr(),k.addEventListener("mouseenter",function(){y.props.interactive&&y.state.isVisible&&y.clearDelayTimeouts()}),k.addEventListener("mouseleave",function(){y.props.interactive&&y.props.trigger.indexOf("mouseenter")>=0&&te().addEventListener("mousemove",h)}),y;function N(){var v=y.props.touch;return Array.isArray(v)?v:[v,0]}function z(){return N()[0]==="hold"}function V(){var v;return!!((v=y.props.render)!=null&&v.$$tippy)}function U(){return m||n}function te(){var v=U().parentNode;return v?ob(v):document}function X(){return ya(k)}function K(v){return y.state.isMounted&&!y.state.isVisible||dt.isTouch||u&&u.type==="focus"?0:da(y.props.delay,v?0:1,it.delay)}function ne(v){v===void 0&&(v=!1),k.style.pointerEvents=y.props.interactive&&!v?"":"none",k.style.zIndex=""+y.props.zIndex}function re(v,A,L){if(L===void 0&&(L=!0),B.forEach(function(j){j[v]&&j[v].apply(j,A)}),L){var q;(q=y.props)[v].apply(q,A)}}function ge(){var v=y.props.aria;if(v.content){var A="aria-"+v.content,L=k.id,q=Qn(y.props.triggerTarget||n);q.forEach(function(j){var Ee=j.getAttribute(A);if(y.state.isVisible)j.setAttribute(A,Ee?Ee+" "+L:L);else{var He=Ee&&Ee.replace(L,"").trim();He?j.setAttribute(A,He):j.removeAttribute(A)}})}}function Be(){if(!(O||!y.props.aria.expanded)){var v=Qn(y.props.triggerTarget||n);v.forEach(function(A){y.props.interactive?A.setAttribute("aria-expanded",y.state.isVisible&&A===U()?"true":"false"):A.removeAttribute("aria-expanded")})}}function ze(){te().removeEventListener("mousemove",h),$o=$o.filter(function(v){return v!==h})}function Fe(v){if(!(dt.isTouch&&(a||v.type==="mousedown"))){var A=v.composedPath&&v.composedPath()[0]||v.target;if(!(y.props.interactive&&Nd(k,A))){if(Qn(y.props.triggerTarget||n).some(function(L){return Nd(L,A)})){if(dt.isTouch||y.state.isVisible&&y.props.trigger.indexOf("click")>=0)return}else re("onClickOutside",[y,v]);y.props.hideOnClick===!0&&(y.clearDelayTimeouts(),y.hide(),l=!0,setTimeout(function(){l=!1}),y.state.isMounted||ht())}}}function Xe(){a=!0}function pt(){a=!1}function Qe(){var v=te();v.addEventListener("mousedown",Fe,!0),v.addEventListener("touchend",Fe,Mn),v.addEventListener("touchstart",pt,Mn),v.addEventListener("touchmove",Xe,Mn)}function ht(){var v=te();v.removeEventListener("mousedown",Fe,!0),v.removeEventListener("touchend",Fe,Mn),v.removeEventListener("touchstart",pt,Mn),v.removeEventListener("touchmove",Xe,Mn)}function En(v,A){On(v,function(){!y.state.isVisible&&k.parentNode&&k.parentNode.contains(k)&&A()})}function mt(v,A){On(v,A)}function On(v,A){var L=X().box;function q(j){j.target===L&&(ha(L,"remove",q),A())}if(v===0)return A();ha(L,"remove",f),ha(L,"add",q),f=q}function Rt(v,A,L){L===void 0&&(L=!1);var q=Qn(y.props.triggerTarget||n);q.forEach(function(j){j.addEventListener(v,A,L),p.push({node:j,eventType:v,handler:A,options:L})})}function Tn(){z()&&(Rt("touchstart",Zn,{passive:!0}),Rt("touchend",Xr,{passive:!0})),Q0(y.props.trigger).forEach(function(v){if(v!=="manual")switch(Rt(v,Zn),v){case"mouseenter":Rt("mouseleave",Xr);break;case"focus":Rt(fb?"focusout":"blur",er);break;case"focusin":Rt("focusout",er);break}})}function Gr(){p.forEach(function(v){var A=v.node,L=v.eventType,q=v.handler,j=v.options;A.removeEventListener(L,q,j)}),p=[]}function Zn(v){var A,L=!1;if(!(!y.state.isEnabled||tr(v)||l)){var q=((A=u)==null?void 0:A.type)==="focus";u=v,m=v.currentTarget,Be(),!y.state.isVisible&&nb(v)&&$o.forEach(function(j){return j(v)}),v.type==="click"&&(y.props.trigger.indexOf("mouseenter")<0||s)&&y.props.hideOnClick!==!1&&y.state.isVisible?L=!0:nr(v),v.type==="click"&&(s=!L),L&&!q&&qt(v)}}function Yr(v){var A=v.target,L=U().contains(A)||k.contains(A);if(!(v.type==="mousemove"&&L)){var q=It().concat(k).map(function(j){var Ee,He=j._tippy,An=(Ee=He.popperInstance)==null?void 0:Ee.state;return An?{popperRect:j.getBoundingClientRect(),popperState:An,props:t}:null}).filter(Boolean);sb(q,v)&&(ze(),qt(v))}}function Xr(v){var A=tr(v)||y.props.trigger.indexOf("click")>=0&&s;if(!A){if(y.props.interactive){y.hideWithInteractivity(v);return}qt(v)}}function er(v){y.props.trigger.indexOf("focusin")<0&&v.target!==U()||y.props.interactive&&v.relatedTarget&&k.contains(v.relatedTarget)||qt(v)}function tr(v){return dt.isTouch?z()!==v.type.indexOf("touch")>=0:!1}function Qr(){Zr();var v=y.props,A=v.popperOptions,L=v.placement,q=v.offset,j=v.getReferenceClientRect,Ee=v.moveTransition,He=V()?ya(k).arrow:null,An=j?{getBoundingClientRect:j,contextElement:j.contextElement||U()}:n,va={name:"$$tippy",enabled:!0,phase:"beforeWrite",requires:["computeStyles"],fn:function(ii){var Nn=ii.state;if(V()){var Qd=X(),Uo=Qd.box;["placement","reference-hidden","escaped"].forEach(function(oi){oi==="placement"?Uo.setAttribute("data-placement",Nn.placement):Nn.attributes.popper["data-popper-"+oi]?Uo.setAttribute("data-"+oi,""):Uo.removeAttribute("data-"+oi)}),Nn.attributes.popper={}}}},Jt=[{name:"offset",options:{offset:q}},{name:"preventOverflow",options:{padding:{top:2,bottom:2,left:5,right:5}}},{name:"flip",options:{padding:5}},{name:"computeStyles",options:{adaptive:!Ee}},va];V()&&He&&Jt.push({name:"arrow",options:{element:He,padding:3}}),Jt.push.apply(Jt,A?.modifiers||[]),y.popperInstance=fa(An,k,Object.assign({},A,{placement:L,onFirstUpdate:d,modifiers:Jt}))}function Zr(){y.popperInstance&&(y.popperInstance.destroy(),y.popperInstance=null)}function gt(){var v=y.props.appendTo,A,L=U();y.props.interactive&&v===Fd||v==="parent"?A=L.parentNode:A=Hd(v,[L]),A.contains(k)||A.appendChild(k),y.state.isMounted=!0,Qr()}function It(){return Vo(k.querySelectorAll("[data-tippy-root]"))}function nr(v){y.clearDelayTimeouts(),v&&re("onTrigger",[y,v]),Qe();var A=K(!0),L=N(),q=L[0],j=L[1];dt.isTouch&&q==="hold"&&j&&(A=j),A?r=setTimeout(function(){y.show()},A):y.show()}function qt(v){if(y.clearDelayTimeouts(),re("onUntrigger",[y,v]),!y.state.isVisible){ht();return}if(!(y.props.trigger.indexOf("mouseenter")>=0&&y.props.trigger.indexOf("click")>=0&&["mouseleave","mousemove"].indexOf(v.type)>=0&&s)){var A=K(!1);A?i=setTimeout(function(){y.state.isVisible&&y.hide()},A):o=requestAnimationFrame(function(){y.hide()})}}function rr(){y.state.isEnabled=!0}function ei(){y.hide(),y.state.isEnabled=!1}function ti(){clearTimeout(r),clearTimeout(i),cancelAnimationFrame(o)}function ni(v){if(!y.state.isDestroyed){re("onBeforeUpdate",[y,v]),Gr();var A=y.props,L=Rd(n,Object.assign({},A,Td(v),{ignoreAttributes:!0}));y.props=L,Tn(),A.interactiveDebounce!==L.interactiveDebounce&&(ze(),h=Ed(Yr,L.interactiveDebounce)),A.triggerTarget&&!L.triggerTarget?Qn(A.triggerTarget).forEach(function(q){q.removeAttribute("aria-expanded")}):L.triggerTarget&&n.removeAttribute("aria-expanded"),Be(),ne(),R&&R(A,L),y.popperInstance&&(Qr(),It().forEach(function(q){requestAnimationFrame(q._tippy.popperInstance.forceUpdate)})),re("onAfterUpdate",[y,v])}}function ri(v){y.setProps({content:v})}function qd(){var v=y.state.isVisible,A=y.state.isDestroyed,L=!y.state.isEnabled,q=dt.isTouch&&!y.props.touch,j=da(y.props.duration,0,it.duration);if(!(v||A||L||q)&&!U().hasAttribute("disabled")&&(re("onShow",[y],!1),y.props.onShow(y)!==!1)){if(y.state.isVisible=!0,V()&&(k.style.visibility="visible"),ne(),Qe(),y.state.isMounted||(k.style.transition="none"),V()){var Ee=X(),He=Ee.box,An=Ee.content;pa([He,An],0)}d=function(){var Jt;if(!(!y.state.isVisible||c)){if(c=!0,k.offsetHeight,k.style.transition=y.props.moveTransition,V()&&y.props.animation){var Wo=X(),ii=Wo.box,Nn=Wo.content;pa([ii,Nn],j),Ad([ii,Nn],"visible")}ge(),Be(),Od(ma,y),(Jt=y.popperInstance)==null||Jt.forceUpdate(),re("onMount",[y]),y.props.animation&&V()&&mt(j,function(){y.state.isShown=!0,re("onShown",[y])})}},gt()}}function Jd(){var v=!y.state.isVisible,A=y.state.isDestroyed,L=!y.state.isEnabled,q=da(y.props.duration,1,it.duration);if(!(v||A||L)&&(re("onHide",[y],!1),y.props.onHide(y)!==!1)){if(y.state.isVisible=!1,y.state.isShown=!1,c=!1,s=!1,V()&&(k.style.visibility="hidden"),ze(),ht(),ne(!0),V()){var j=X(),Ee=j.box,He=j.content;y.props.animation&&(pa([Ee,He],q),Ad([Ee,He],"hidden"))}ge(),Be(),y.props.animation?V()&&En(q,y.unmount):y.unmount()}}function Gd(v){te().addEventListener("mousemove",h),Od($o,h),h(v)}function Yd(){y.state.isVisible&&y.hide(),y.state.isMounted&&(Zr(),It().forEach(function(v){v._tippy.unmount()}),k.parentNode&&k.parentNode.removeChild(k),ma=ma.filter(function(v){return v!==y}),y.state.isMounted=!1,re("onHidden",[y]))}function Xd(){y.state.isDestroyed||(y.clearDelayTimeouts(),y.unmount(),Gr(),delete n._tippy,y.state.isDestroyed=!0,re("onDestroy",[y]))}}function Jr(n,e){e===void 0&&(e={});var t=it.plugins.concat(e.plugins||[]);cb();var r=Object.assign({},e,{plugins:t}),i=ib(n);if(0)var o,s;var l=i.reduce(function(a,c){var u=c&&vb(c,r);return u&&a.push(u),a},[]);return jo(n)?l[0]:l}Jr.defaultProps=it;Jr.setDefaultProps=mb;Jr.currentInput=dt;var lC=Object.assign({},$r,{effect:function(e){var t=e.state,r={popper:{position:t.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};Object.assign(t.elements.popper.style,r.popper),t.styles=r,t.elements.arrow&&Object.assign(t.elements.arrow.style,r.arrow)}});Jr.setDefaultProps({render:jd});var Wd=Jr;var xb=(n,e,t)=>{n.chain().focus().deleteRange(e).insertContentAt(e,[{type:"mention",attrs:t},{type:"text",text:" "}]).run(),n.view.dom.ownerDocument.defaultView?.getSelection()?.collapseToEnd()},kb=n=>{let e=[];return Alpine.store("filamentCommentsMentionsFiltered",{items:[],selectedIndex:0}),{items:({query:t})=>(e=n.filter(r=>r.name.toLowerCase().replace(/\s/g,"").includes(t.toLowerCase())).slice(0,5),console.log("filteredItems",n,e,t),Alpine.store("filamentCommentsMentionsFiltered").items=e,Alpine.store("filamentCommentsMentionsFiltered").selectedIndex=0,e),command:({editor:t,range:r,props:i})=>{let s=t.view.state.selection.$to.nodeAfter?.text?.startsWith(" ");t.view.state.mention$.text.length>1&&(r.to=r.from+(t.view.state.mention$.text.length-1)),s&&(r.to+=1);let l=3,a=!1;for(;l>0&&!a;)try{xb(t,r,i),a=!0}catch{l--,r.to-=1}},render:()=>{let t,r,i;return{onStart:o=>{i=o.command,t=Wd("body",{getReferenceClientRect:o.clientRect,content:(()=>{r=Alpine.data("filamentCommentsMentions",()=>({add(l){o.command({id:l.id,label:l.name})}}));let s=document.createElement("div");return s.setAttribute("x-data","filamentCommentsMentions"),s.innerHTML=` - `,s})(),showOnCreate:!0,interactive:!0,trigger:"manual",placement:document.dir==="rtl"?"bottom-end":"bottom-start",theme:"light",arrow:!0})},onUpdate:o=>{o.clientRect&&t[0].setProps({getReferenceClientRect:o.clientRect})},onKeyDown:o=>{let s=Alpine.store("filamentCommentsMentionsFiltered").items,l=Alpine.store("filamentCommentsMentionsFiltered").selectedIndex;if(o.event.key==="ArrowDown")return Alpine.store("filamentCommentsMentionsFiltered").selectedIndex=(l+1)%s.length,!0;if(o.event.key==="ArrowUp")return Alpine.store("filamentCommentsMentionsFiltered").selectedIndex=(l-1+s.length)%s.length,!0;if(o.event.key==="Enter"){let a=s[l];return a&&i({id:a.id,label:a.name}),!0}return o.event.key==="Escape"?(t[0].hide(),!0):!1},onExit:()=>{t[0].hide()}}}}},Kf=Xg;var Zg=(n,e)=>{let t;return function(...i){let o=()=>{clearTimeout(t),n(...i)};clearTimeout(t),t=setTimeout(o,e)}};document.addEventListener("alpine:init",()=>{Alpine.data("editor",(n,e,t,r,i,o=null)=>{let s,l="comm:prose comm:dark:prose-invert comm:prose-sm comm:sm:prose-base comm:lg:prose-lg comm:xl:prose-2xl comm:focus:outline-none comm:p-4 comm:min-w-full comm:w-full comm:rounded-lg comm:border comm:border-gray-300 comm:dark:border-gray-700";return{updatedAt:Date.now(),init(){let a=this,c=o??`commentions::${t}`,f=Zg(u=>{Livewire.dispatchTo(c,"body:updated",u.getHTML())},300);s=new gi({element:this.$refs.element,extensions:[of,lf.configure({HTMLAttributes:{class:"mention"},suggestion:Kf(e)}),af.configure({placeholder:r})],editorProps:{attributes:{class:i||l}},placeholder:"Type something...",content:n,onCreate({editor:u}){a.updatedAt=Date.now()},onUpdate({editor:u}){f(u),a.updatedAt=Date.now()},onSelectionUpdate({editor:u}){a.updatedAt=Date.now()}}),Livewire.on(`${t}:content:cleared`,()=>{s.commands.setContent("")})},isLoaded(){return s},isActive(a,c={}){return s.isActive(a,c)}}})}); + `,s})(),showOnCreate:!0,interactive:!0,trigger:"manual",placement:document.dir==="rtl"?"bottom-end":"bottom-start",theme:"light",arrow:!0})},onUpdate:o=>{o.clientRect&&t[0].setProps({getReferenceClientRect:o.clientRect})},onKeyDown:o=>{let s=Alpine.store("filamentCommentsMentionsFiltered").items,l=Alpine.store("filamentCommentsMentionsFiltered").selectedIndex;if(o.event.key==="ArrowDown")return Alpine.store("filamentCommentsMentionsFiltered").selectedIndex=(l+1)%s.length,!0;if(o.event.key==="ArrowUp")return Alpine.store("filamentCommentsMentionsFiltered").selectedIndex=(l-1+s.length)%s.length,!0;if(o.event.key==="Enter"){let a=s[l];return a&&i({id:a.id,label:a.name}),!0}return o.event.key==="Escape"?(t[0].hide(),!0):!1},onExit:()=>{t[0].hide()}}}}},Ud=kb;var Sb=(n,e)=>{let t;return function(...i){let o=()=>{clearTimeout(t),n(...i)};clearTimeout(t),t=setTimeout(o,e)}},wb=["http:","https:","mailto:"],Kd=n=>{try{return wb.includes(new URL(n,window.location.origin).protocol)}catch{return!1}},Cb=(n,e={})=>{if(n.isActive("link")){n.chain().focus().extendMarkRange("link").unsetLink().run();return}let t=n.getAttributes("link").href,r=window.prompt(e.prompt??"Enter the URL",t||"https://");if(r!==null){if(r===""){n.chain().focus().extendMarkRange("link").unsetLink().run();return}if(!Kd(r)){window.alert(e.invalid??"That link uses an unsupported or unsafe URL.");return}n.chain().focus().extendMarkRange("link").setLink({href:r}).run()}},_d={bold:{run:n=>n.chain().focus().toggleBold().run(),active:n=>n.isActive("bold")},italic:{run:n=>n.chain().focus().toggleItalic().run(),active:n=>n.isActive("italic")},underline:{run:n=>n.chain().focus().toggleUnderline().run(),active:n=>n.isActive("underline")},strike:{run:n=>n.chain().focus().toggleStrike().run(),active:n=>n.isActive("strike")},h1:{run:n=>n.chain().focus().toggleHeading({level:1}).run(),active:n=>n.isActive("heading",{level:1})},h2:{run:n=>n.chain().focus().toggleHeading({level:2}).run(),active:n=>n.isActive("heading",{level:2})},h3:{run:n=>n.chain().focus().toggleHeading({level:3}).run(),active:n=>n.isActive("heading",{level:3})},blockquote:{run:n=>n.chain().focus().toggleBlockquote().run(),active:n=>n.isActive("blockquote")},bulletList:{run:n=>n.chain().focus().toggleBulletList().run(),active:n=>n.isActive("bulletList")},orderedList:{run:n=>n.chain().focus().toggleOrderedList().run(),active:n=>n.isActive("orderedList")},code:{run:n=>n.chain().focus().toggleCode().run(),active:n=>n.isActive("code")},link:{run:(n,e)=>Cb(n,e),active:n=>n.isActive("link")}};document.addEventListener("alpine:init",()=>{Alpine.data("editor",(n,e,t,r,i,o=null,s={})=>{let l,a="comm:prose comm:dark:prose-invert comm:prose-sm comm:sm:prose-base comm:lg:prose-lg comm:xl:prose-2xl comm:focus:outline-none comm:p-4 comm:min-w-full comm:w-full";return{updatedAt:Date.now(),init(){let c=this,u=o??`commentions::${t}`,f=Sb(d=>{Livewire.dispatchTo(u,"body:updated",d.getHTML())},300);l=new Ui({element:this.$refs.element,extensions:[$f.configure({heading:{levels:[1,2,3]}}),Uf,od.configure({openOnClick:!1,validate:d=>Kd(d),HTMLAttributes:{class:"comm-link"}}),jf.configure({HTMLAttributes:{class:"mention"},suggestion:Ud(e)}),Wf.configure({placeholder:r})],editorProps:{attributes:{class:i||a}},placeholder:"Type something...",content:n,onCreate({editor:d}){c.updatedAt=Date.now()},onUpdate({editor:d}){f(d),c.updatedAt=Date.now()},onSelectionUpdate({editor:d}){c.updatedAt=Date.now()}}),Livewire.on(`${t}:content:cleared`,()=>{l.commands.setContent("")})},isLoaded(){return l},isActive(c,u={}){return l.isActive(c,u)},runToolbarCommand(c){let u=_d[c];u&&l&&u.run(l,s)},isToolbarButtonActive(c){this.updatedAt;let u=_d[c];return!!(u&&l&&u.active(l))}}})}); diff --git a/resources/js/commentions.js b/resources/js/commentions.js index c93af2e..229311d 100644 --- a/resources/js/commentions.js +++ b/resources/js/commentions.js @@ -2,6 +2,8 @@ import { Editor } from '@tiptap/core' import StarterKit from '@tiptap/starter-kit' import Mention from '@tiptap/extension-mention' import Placeholder from '@tiptap/extension-placeholder' +import Underline from '@tiptap/extension-underline' +import Link from '@tiptap/extension-link' import suggestion from './suggestion' const debounce = (func, wait) => { @@ -16,11 +18,64 @@ const debounce = (func, wait) => { }; }; +const SAFE_LINK_PROTOCOLS = ['http:', 'https:', 'mailto:']; + +const isSafeUrl = (url) => { + try { + return SAFE_LINK_PROTOCOLS.includes(new URL(url, window.location.origin).protocol); + } catch { + return false; + } +}; + +const promptForLink = (editor, labels = {}) => { + if (editor.isActive('link')) { + editor.chain().focus().extendMarkRange('link').unsetLink().run(); + return; + } + + const previousUrl = editor.getAttributes('link').href; + const url = window.prompt(labels.prompt ?? 'Enter the URL', previousUrl || 'https://'); + + if (url === null) { + return; + } + + if (url === '') { + editor.chain().focus().extendMarkRange('link').unsetLink().run(); + return; + } + + if (! isSafeUrl(url)) { + window.alert(labels.invalid ?? 'That link uses an unsupported or unsafe URL.'); + return; + } + + editor.chain().focus().extendMarkRange('link').setLink({ href: url }).run(); +}; + +// Maps a toolbar button name to the TipTap command it runs and the predicate +// used to highlight it when the active selection already has that formatting. +const toolbarCommands = { + bold: { run: (e) => e.chain().focus().toggleBold().run(), active: (e) => e.isActive('bold') }, + italic: { run: (e) => e.chain().focus().toggleItalic().run(), active: (e) => e.isActive('italic') }, + underline: { run: (e) => e.chain().focus().toggleUnderline().run(), active: (e) => e.isActive('underline') }, + strike: { run: (e) => e.chain().focus().toggleStrike().run(), active: (e) => e.isActive('strike') }, + h1: { run: (e) => e.chain().focus().toggleHeading({ level: 1 }).run(), active: (e) => e.isActive('heading', { level: 1 }) }, + h2: { run: (e) => e.chain().focus().toggleHeading({ level: 2 }).run(), active: (e) => e.isActive('heading', { level: 2 }) }, + h3: { run: (e) => e.chain().focus().toggleHeading({ level: 3 }).run(), active: (e) => e.isActive('heading', { level: 3 }) }, + blockquote: { run: (e) => e.chain().focus().toggleBlockquote().run(), active: (e) => e.isActive('blockquote') }, + bulletList: { run: (e) => e.chain().focus().toggleBulletList().run(), active: (e) => e.isActive('bulletList') }, + orderedList: { run: (e) => e.chain().focus().toggleOrderedList().run(), active: (e) => e.isActive('orderedList') }, + code: { run: (e) => e.chain().focus().toggleCode().run(), active: (e) => e.isActive('code') }, + link: { run: (e, labels) => promptForLink(e, labels), active: (e) => e.isActive('link') }, +}; + document.addEventListener('alpine:init', () => { - Alpine.data('editor', (content, mentions, component, placeholder, editorCssClasses, componentAlias = null) => { + Alpine.data('editor', (content, mentions, component, placeholder, editorCssClasses, componentAlias = null, toolbarLabels = {}) => { let editor - const defaultEditorCssClasses = `comm:prose comm:dark:prose-invert comm:prose-sm comm:sm:prose-base comm:lg:prose-lg comm:xl:prose-2xl comm:focus:outline-none comm:p-4 comm:min-w-full comm:w-full comm:rounded-lg comm:border comm:border-gray-300 comm:dark:border-gray-700`; + const defaultEditorCssClasses = `comm:prose comm:dark:prose-invert comm:prose-sm comm:sm:prose-base comm:lg:prose-lg comm:xl:prose-2xl comm:focus:outline-none comm:p-4 comm:min-w-full comm:w-full`; return { updatedAt: Date.now(), @@ -36,7 +91,17 @@ document.addEventListener('alpine:init', () => { editor = new Editor({ element: this.$refs.element, extensions: [ - StarterKit, + StarterKit.configure({ + heading: { levels: [1, 2, 3] }, + }), + Underline, + Link.configure({ + openOnClick: false, + validate: (url) => isSafeUrl(url), + HTMLAttributes: { + class: 'comm-link', + }, + }), Mention.configure({ HTMLAttributes: { class: 'mention', @@ -82,6 +147,24 @@ document.addEventListener('alpine:init', () => { isActive(type, opts = {}) { return editor.isActive(type, opts) }, + + runToolbarCommand(name) { + const command = toolbarCommands[name] + + if (command && editor) { + command.run(editor, toolbarLabels) + } + }, + + isToolbarButtonActive(name) { + // Touch `updatedAt` so Alpine re-evaluates this on every + // selection/content change, keeping button highlights in sync. + void this.updatedAt + + const command = toolbarCommands[name] + + return !! (command && editor && command.active(editor)) + }, } }) }) diff --git a/resources/lang/en/comments.php b/resources/lang/en/comments.php index 77dc525..eec55ab 100644 --- a/resources/lang/en/comments.php +++ b/resources/lang/en/comments.php @@ -30,4 +30,22 @@ 'notification_subscribed' => 'Subscribed to notifications', 'notification_unsubscribed' => 'Unsubscribed from notifications', 'notification_comment_deleted' => 'Comment deleted', + + 'toolbar' => [ + 'aria_label' => 'Text formatting', + 'bold' => 'Bold', + 'italic' => 'Italic', + 'underline' => 'Underline', + 'strike' => 'Strikethrough', + 'h1' => 'Heading 1', + 'h2' => 'Heading 2', + 'h3' => 'Heading 3', + 'blockquote' => 'Quote', + 'bullet_list' => 'Bullet list', + 'ordered_list' => 'Numbered list', + 'code' => 'Code', + 'link' => 'Link', + 'link_prompt' => 'Enter the URL', + 'link_invalid' => 'That link uses an unsupported or unsafe URL.', + ], ]; diff --git a/resources/views/comment-list.blade.php b/resources/views/comment-list.blade.php index 6ecbf31..8ed1053 100644 --- a/resources/views/comment-list.blade.php +++ b/resources/views/comment-list.blade.php @@ -21,6 +21,7 @@ class="comm:w-8 comm:h-8 comm:text-gray-400 comm:dark:text-gray-500" :comment="$comment" :mentionables="$mentionables" :tip-tap-css-classes="$tipTapCssClasses" + :toolbar-buttons="$toolbarButtons" /> @endforeach diff --git a/resources/views/comment.blade.php b/resources/views/comment.blade.php index 8c880f3..55f4b64 100644 --- a/resources/views/comment.blade.php +++ b/resources/views/comment.blade.php @@ -92,7 +92,8 @@ class="comm:text-xs comm:text-gray-300 comm:ml-1" @if ($editing)
-
+
+ @include('commentions::partials.toolbar', ['toolbarButtons' => $this->getToolbarButtons()])
diff --git a/resources/views/comments-modal.blade.php b/resources/views/comments-modal.blade.php index 30560b9..3cb9809 100644 --- a/resources/views/comments-modal.blade.php +++ b/resources/views/comments-modal.blade.php @@ -12,5 +12,6 @@ :sidebar-enabled="$sidebarEnabled ?? true" :show-subscribers="$showSubscribers ?? true" :tip-tap-css-classes="$tipTapCssClasses ?? null" + :toolbar-buttons="$toolbarButtons ?? null" />
diff --git a/resources/views/comments.blade.php b/resources/views/comments.blade.php index d151a6f..cf35402 100644 --- a/resources/views/comments.blade.php +++ b/resources/views/comments.blade.php @@ -8,8 +8,9 @@ {{-- tiptap editor --}}
+ @include('commentions::partials.toolbar', ['toolbarButtons' => $this->getToolbarButtons()])
@@ -42,6 +43,7 @@ :load-more-label="$loadMoreLabel ?? __('commentions::comments.show_more')" :per-page-increment="$perPageIncrement ?? null" :tip-tap-css-classes="$tipTapCssClasses" + :toolbar-buttons="$this->getToolbarButtons()" />
diff --git a/resources/views/filament/infolists/components/comments-entry.blade.php b/resources/views/filament/infolists/components/comments-entry.blade.php index 9af985c..3fdb845 100644 --- a/resources/views/filament/infolists/components/comments-entry.blade.php +++ b/resources/views/filament/infolists/components/comments-entry.blade.php @@ -10,5 +10,6 @@ :per-page-increment="$getPerPageIncrement()" :sidebar-enabled="$isSidebarEnabled()" :tip-tap-css-classes="$getTipTapCssClasses()" + :toolbar-buttons="$getToolbarButtons()" /> diff --git a/resources/views/partials/toolbar.blade.php b/resources/views/partials/toolbar.blade.php new file mode 100644 index 0000000..534cb9d --- /dev/null +++ b/resources/views/partials/toolbar.blade.php @@ -0,0 +1,64 @@ +@php + $toolbarButtonIcons = [ + 'bold' => 'heroicon-s-bold', + 'italic' => 'heroicon-s-italic', + 'underline' => 'heroicon-s-underline', + 'strike' => 'heroicon-s-strikethrough', + 'h1' => 'heroicon-s-h1', + 'h2' => 'heroicon-s-h2', + 'h3' => 'heroicon-s-h3', + 'blockquote' => 'heroicon-s-chat-bubble-left-ellipsis', + 'bulletList' => 'heroicon-s-list-bullet', + 'orderedList' => 'heroicon-s-numbered-list', + 'code' => 'heroicon-s-code-bracket', + 'link' => 'heroicon-s-link', + ]; + + $toolbarButtonLabels = [ + 'bold' => __('commentions::comments.toolbar.bold'), + 'italic' => __('commentions::comments.toolbar.italic'), + 'underline' => __('commentions::comments.toolbar.underline'), + 'strike' => __('commentions::comments.toolbar.strike'), + 'h1' => __('commentions::comments.toolbar.h1'), + 'h2' => __('commentions::comments.toolbar.h2'), + 'h3' => __('commentions::comments.toolbar.h3'), + 'blockquote' => __('commentions::comments.toolbar.blockquote'), + 'bulletList' => __('commentions::comments.toolbar.bullet_list'), + 'orderedList' => __('commentions::comments.toolbar.ordered_list'), + 'code' => __('commentions::comments.toolbar.code'), + 'link' => __('commentions::comments.toolbar.link'), + ]; +@endphp + +@if (! empty($toolbarButtons)) + +@endif diff --git a/src/Actions/SanitizeCommentHtml.php b/src/Actions/SanitizeCommentHtml.php new file mode 100644 index 0000000..0db2e8e --- /dev/null +++ b/src/Actions/SanitizeCommentHtml.php @@ -0,0 +1,57 @@ +sanitizer()->sanitize($body); + } + + protected function sanitizer(): HtmlSanitizer + { + $config = (new HtmlSanitizerConfig()) + ->allowElement('strong') + ->allowElement('em') + ->allowElement('s') + ->allowElement('u') + ->allowElement('code') + ->allowElement('p') + ->allowElement('br') + ->allowElement('hr') + ->allowElement('pre') + ->allowElement('blockquote') + ->allowElement('h1') + ->allowElement('h2') + ->allowElement('h3') + ->allowElement('ul') + ->allowElement('ol') + ->allowElement('li') + ->allowElement('a', ['href', 'target', 'rel', 'class']) + ->allowElement('span', ['class', 'data-type', 'data-id', 'data-label']) + ->allowLinkSchemes(['http', 'https', 'mailto']) + ->allowRelativeLinks() + ->forceAttribute('a', 'rel', 'noopener noreferrer') + ->withMaxInputLength(500_000); + + return new HtmlSanitizer($config); + } + + public static function run(...$args) + { + return (new self())(...$args); + } +} diff --git a/src/Comment.php b/src/Comment.php index 91eca58..78d9026 100644 --- a/src/Comment.php +++ b/src/Comment.php @@ -15,6 +15,7 @@ use Illuminate\Support\Collection; use Kirschbaum\Commentions\Actions\HtmlToMarkdown; use Kirschbaum\Commentions\Actions\ParseComment; +use Kirschbaum\Commentions\Actions\SanitizeCommentHtml; use Kirschbaum\Commentions\Actions\ToggleCommentReaction; use Kirschbaum\Commentions\Contracts\Commentable; use Kirschbaum\Commentions\Contracts\Commenter; @@ -57,6 +58,13 @@ public function commentable(): MorphTo return $this->morphTo(); } + public function body(): Attribute + { + return Attribute::make( + set: fn (string $value): string => SanitizeCommentHtml::run($value), + ); + } + public function bodyParsed(): Attribute { return Attribute::make( diff --git a/src/Config.php b/src/Config.php index 052a2e2..6615ae4 100644 --- a/src/Config.php +++ b/src/Config.php @@ -93,7 +93,57 @@ public static function getTipTapCssClasses(): ?string return call_user_func(static::$resolveTipTapCssClasses); } - return 'comm:prose comm:dark:prose-invert comm:prose-sm comm:sm:prose-base comm:lg:prose-lg comm:xl:prose-2xl comm:focus:outline-none comm:p-4 comm:min-w-full comm:w-full comm:rounded-lg comm:border comm:border-gray-300 comm:dark:border-gray-700'; + return 'comm:prose comm:dark:prose-invert comm:prose-sm comm:sm:prose-base comm:lg:prose-lg comm:xl:prose-2xl comm:focus:outline-none comm:p-4 comm:min-w-full comm:w-full'; + } + + /** + * Resolve the configured editor toolbar buttons, normalized into groups. + * + * @return array> + */ + public static function getToolbarButtons(): array + { + if (! config('commentions.toolbar.enabled', true)) { + return []; + } + + return static::normalizeToolbarButtons(config('commentions.toolbar.buttons', [])); + } + + /** + * Normalize a flat or grouped list of toolbar buttons into groups, so the + * editor can always render groups separated by visual dividers. Non-string + * buttons and empty groups are dropped, so malformed configuration can + * never reach the editor view. + * + * @param array $buttons + * @return array> + */ + public static function normalizeToolbarButtons(array $buttons): array + { + if ($buttons === []) { + return []; + } + + $isGrouped = array_is_list($buttons) + && count(array_filter($buttons, 'is_array')) === count($buttons); + + $groups = $isGrouped ? $buttons : [$buttons]; + + $normalized = []; + + foreach ($groups as $group) { + $group = array_values(array_filter( + is_array($group) ? $group : [$group], + 'is_string', + )); + + if ($group !== []) { + $normalized[] = $group; + } + } + + return $normalized; } public static function getComponentPrefix(): string diff --git a/src/Filament/Actions/CommentsAction.php b/src/Filament/Actions/CommentsAction.php index 0252ff8..0c3ac19 100644 --- a/src/Filament/Actions/CommentsAction.php +++ b/src/Filament/Actions/CommentsAction.php @@ -9,6 +9,7 @@ use Kirschbaum\Commentions\Filament\Concerns\HasPolling; use Kirschbaum\Commentions\Filament\Concerns\HasSidebar; use Kirschbaum\Commentions\Filament\Concerns\HasTipTapCssClasses; +use Kirschbaum\Commentions\Filament\Concerns\HasToolbar; class CommentsAction extends Action { @@ -17,6 +18,7 @@ class CommentsAction extends Action use HasPolling; use HasSidebar; use HasTipTapCssClasses; + use HasToolbar; protected function setUp(): void { @@ -35,6 +37,7 @@ protected function setUp(): void 'sidebarEnabled' => $this->isSidebarEnabled(), 'showSubscribers' => $this->showSubscribers(), 'tipTapCssClasses' => $this->getTipTapCssClasses(), + 'toolbarButtons' => $this->getToolbarButtons(), ])) ->modalWidth($this->isSidebarEnabled() ? '4xl' : 'xl') ->label(__('commentions::comments.label')) diff --git a/src/Filament/Actions/CommentsTableAction.php b/src/Filament/Actions/CommentsTableAction.php index d09630b..ac0f352 100644 --- a/src/Filament/Actions/CommentsTableAction.php +++ b/src/Filament/Actions/CommentsTableAction.php @@ -8,6 +8,7 @@ use Kirschbaum\Commentions\Filament\Concerns\HasPolling; use Kirschbaum\Commentions\Filament\Concerns\HasSidebar; use Kirschbaum\Commentions\Filament\Concerns\HasTipTapCssClasses; +use Kirschbaum\Commentions\Filament\Concerns\HasToolbar; class CommentsTableAction extends Action { @@ -15,6 +16,7 @@ class CommentsTableAction extends Action use HasPolling; use HasSidebar; use HasTipTapCssClasses; + use HasToolbar; protected function setUp(): void { @@ -29,6 +31,7 @@ protected function setUp(): void 'sidebarEnabled' => $this->isSidebarEnabled(), 'showSubscribers' => $this->showSubscribers(), 'tipTapCssClasses' => $this->getTipTapCssClasses(), + 'toolbarButtons' => $this->getToolbarButtons(), ])) ->modalWidth($this->isSidebarEnabled() ? '4xl' : 'xl') ->label(__('commentions::comments.label')) diff --git a/src/Filament/Concerns/HasToolbar.php b/src/Filament/Concerns/HasToolbar.php new file mode 100644 index 0000000..00b0fbd --- /dev/null +++ b/src/Filament/Concerns/HasToolbar.php @@ -0,0 +1,38 @@ +|Closure|null */ + protected array|Closure|null $toolbarButtons = null; + + /** + * Configure the editor formatting toolbar. Accepts a flat list of button + * names, or groups of names for visual separators, e.g. + * ->toolbarButtons([['bold', 'italic'], ['link']]). + * + * @param array|Closure|null $buttons + */ + public function toolbarButtons(array|Closure|null $buttons): static + { + $this->toolbarButtons = $buttons; + + return $this; + } + + /** + * @return array>|null + */ + public function getToolbarButtons(): ?array + { + $buttons = $this->evaluate($this->toolbarButtons); + + return $buttons === null + ? null + : Config::normalizeToolbarButtons($buttons); + } +} diff --git a/src/Filament/Infolists/Components/CommentsEntry.php b/src/Filament/Infolists/Components/CommentsEntry.php index 1d6031f..0f5947c 100644 --- a/src/Filament/Infolists/Components/CommentsEntry.php +++ b/src/Filament/Infolists/Components/CommentsEntry.php @@ -8,6 +8,7 @@ use Kirschbaum\Commentions\Filament\Concerns\HasPolling; use Kirschbaum\Commentions\Filament\Concerns\HasSidebar; use Kirschbaum\Commentions\Filament\Concerns\HasTipTapCssClasses; +use Kirschbaum\Commentions\Filament\Concerns\HasToolbar; class CommentsEntry extends Entry { @@ -16,6 +17,7 @@ class CommentsEntry extends Entry use HasPolling; use HasSidebar; use HasTipTapCssClasses; + use HasToolbar; protected string $view = 'commentions::filament.infolists.components.comments-entry'; } diff --git a/src/Livewire/Comment.php b/src/Livewire/Comment.php index 82eb5e9..09baa34 100644 --- a/src/Livewire/Comment.php +++ b/src/Livewire/Comment.php @@ -8,6 +8,7 @@ use Kirschbaum\Commentions\Config; use Kirschbaum\Commentions\Contracts\RenderableComment; use Kirschbaum\Commentions\Livewire\Concerns\HasMentions; +use Kirschbaum\Commentions\Livewire\Concerns\HasToolbarButtons; use Livewire\Attributes\On; use Livewire\Attributes\Renderless; use Livewire\Component; @@ -15,6 +16,7 @@ class Comment extends Component { use HasMentions; + use HasToolbarButtons; public CommentModel|RenderableComment $comment; diff --git a/src/Livewire/CommentList.php b/src/Livewire/CommentList.php index 4f687d7..001f0cc 100644 --- a/src/Livewire/CommentList.php +++ b/src/Livewire/CommentList.php @@ -7,6 +7,7 @@ use Kirschbaum\Commentions\Livewire\Concerns\HasMentions; use Kirschbaum\Commentions\Livewire\Concerns\HasPagination; use Kirschbaum\Commentions\Livewire\Concerns\HasPolling; +use Kirschbaum\Commentions\Livewire\Concerns\HasToolbarButtons; use Livewire\Attributes\Computed; use Livewire\Attributes\On; use Livewire\Component; @@ -16,6 +17,7 @@ class CommentList extends Component use HasMentions; use HasPagination; use HasPolling; + use HasToolbarButtons; public Model $record; diff --git a/src/Livewire/Comments.php b/src/Livewire/Comments.php index fda9a36..c7247d3 100644 --- a/src/Livewire/Comments.php +++ b/src/Livewire/Comments.php @@ -9,6 +9,7 @@ use Kirschbaum\Commentions\Livewire\Concerns\HasPagination; use Kirschbaum\Commentions\Livewire\Concerns\HasPolling; use Kirschbaum\Commentions\Livewire\Concerns\HasSidebar; +use Kirschbaum\Commentions\Livewire\Concerns\HasToolbarButtons; use Livewire\Attributes\On; use Livewire\Attributes\Renderless; use Livewire\Component; @@ -19,6 +20,7 @@ class Comments extends Component use HasPagination; use HasPolling; use HasSidebar; + use HasToolbarButtons; public Model $record; diff --git a/src/Livewire/Concerns/HasToolbarButtons.php b/src/Livewire/Concerns/HasToolbarButtons.php new file mode 100644 index 0000000..bfd82be --- /dev/null +++ b/src/Livewire/Concerns/HasToolbarButtons.php @@ -0,0 +1,28 @@ +>|null */ + public ?array $toolbarButtons = null; + + /** + * The editor toolbar buttons, normalized into groups, and falling back to + * the package configuration when not explicitly provided by the host + * component. Normalizing here means a flat list passed straight to the + * component renders the same as a grouped one. + * + * @return array> + */ + public function getToolbarButtons(): array + { + if ($this->toolbarButtons === null) { + return Config::getToolbarButtons(); + } + + return Config::normalizeToolbarButtons($this->toolbarButtons); + } +} diff --git a/tests/Livewire/CommentToolbarTest.php b/tests/Livewire/CommentToolbarTest.php new file mode 100644 index 0000000..2c9bd58 --- /dev/null +++ b/tests/Livewire/CommentToolbarTest.php @@ -0,0 +1,107 @@ + Auth::user()); +}); + +test('normalizeToolbarButtons wraps a flat list into a single group', function () { + expect(Config::normalizeToolbarButtons(['bold', 'italic'])) + ->toBe([['bold', 'italic']]); +}); + +test('normalizeToolbarButtons keeps grouped buttons as-is', function () { + expect(Config::normalizeToolbarButtons([['bold'], ['link']])) + ->toBe([['bold'], ['link']]); +}); + +test('normalizeToolbarButtons returns empty for no buttons', function () { + expect(Config::normalizeToolbarButtons([]))->toBe([]); +}); + +test('normalizeToolbarButtons handles mixed array and string input without error', function () { + expect(Config::normalizeToolbarButtons([['bold'], 'italic'])) + ->toBe([['italic']]); +}); + +test('normalizeToolbarButtons drops empty groups', function () { + expect(Config::normalizeToolbarButtons([['bold'], []])) + ->toBe([['bold']]); +}); + +test('getToolbarButtons returns empty when the toolbar is disabled', function () { + config(['commentions.toolbar.enabled' => false]); + + expect(Config::getToolbarButtons())->toBe([]); +}); + +test('CommentsEntry toolbarButtons normalizes a flat list into a group', function () { + $entry = CommentsEntry::make('comments')->toolbarButtons(['bold', 'link']); + + expect($entry->getToolbarButtons())->toBe([['bold', 'link']]); +}); + +test('CommentsEntry returns null toolbar buttons when not configured', function () { + expect(CommentsEntry::make('comments')->getToolbarButtons())->toBeNull(); +}); + +test('the comment editor renders the configured toolbar buttons', function () { + $user = User::factory()->create(); + actingAs($user); + + $post = Post::factory()->create(); + + livewire(Comments::class, [ + 'record' => $post, + 'toolbarButtons' => [['bold', 'italic']], + ]) + ->assertSeeHtml('data-toolbar-button="bold"') + ->assertSeeHtml('data-toolbar-button="italic"') + ->assertDontSeeHtml('data-toolbar-button="link"'); +}); + +test('the comment editor renders no toolbar when buttons are empty', function () { + $user = User::factory()->create(); + actingAs($user); + + $post = Post::factory()->create(); + + livewire(Comments::class, [ + 'record' => $post, + 'toolbarButtons' => [], + ])->assertDontSeeHtml('commentions-toolbar'); +}); + +test('the comment editor falls back to the configured default toolbar', function () { + $user = User::factory()->create(); + actingAs($user); + + $post = Post::factory()->create(); + + livewire(Comments::class, ['record' => $post]) + ->assertSeeHtml('data-toolbar-button="bold"') + ->assertSeeHtml('data-toolbar-button="link"'); +}); + +test('the comment editor normalizes a flat toolbar buttons list', function () { + $user = User::factory()->create(); + actingAs($user); + + $post = Post::factory()->create(); + + livewire(Comments::class, [ + 'record' => $post, + 'toolbarButtons' => ['bold', 'italic'], + ]) + ->assertSeeHtml('data-toolbar-button="bold"') + ->assertSeeHtml('data-toolbar-button="italic"'); +}); diff --git a/tests/SanitizeCommentHtmlTest.php b/tests/SanitizeCommentHtmlTest.php new file mode 100644 index 0000000..6df866c --- /dev/null +++ b/tests/SanitizeCommentHtmlTest.php @@ -0,0 +1,101 @@ +hello

')) + ->toBe('

hello

'); +}); + +test('it strips event handler attributes', function () { + expect(SanitizeCommentHtml::run('

hello

')) + ->toBe('

hello

'); +}); + +test('it strips img and iframe elements', function () { + expect(SanitizeCommentHtml::run(''))->toBe(''); + expect(SanitizeCommentHtml::run(''))->toBe(''); +}); + +test('it removes javascript link schemes but keeps the link text', function () { + $clean = SanitizeCommentHtml::run('click'); + + expect($clean) + ->toContain('click') + ->not->toContain('javascript:'); +}); + +test('it keeps safe http links', function () { + expect(SanitizeCommentHtml::run('link')) + ->toContain('href="https://example.test"'); +}); + +test('it forces rel="noopener noreferrer" on links to prevent reverse tabnabbing', function () { + expect(SanitizeCommentHtml::run('link')) + ->toContain('rel="noopener noreferrer"'); +}); + +test('it keeps the formatting marks the editor can produce', function () { + $html = '

b i u s c

' + . '
  • one
quote

heading

'; + + expect(SanitizeCommentHtml::run($html))->toBe($html); +}); + +test('it allows headings only up to h3, matching the editor', function () { + $clean = SanitizeCommentHtml::run('

kept

dropped

'); + + expect($clean) + ->toContain('

kept

') + ->not->toContain('h4'); +}); + +test('it preserves mention spans and their data attributes', function () { + $mention = '@Jane'; + + $clean = SanitizeCommentHtml::run($mention); + + expect($clean) + ->toContain('data-type="mention"') + ->toContain('data-id="42"') + ->toContain('data-label="Jane"') + ->toContain('class="mention"'); +}); + +test('saving a comment sanitizes a malicious body', function () { + $user = User::factory()->create(); + $post = Post::factory()->create(); + + $comment = $post->comment('

hi

', $user); + + expect($comment->body) + ->toBe('

hi

') + ->not->toContain('onerror') + ->not->toContain('create(); + $mentioned = User::factory()->create(); + $post = Post::factory()->create(); + + $comment = $post->comment( + sprintf( + 'Hey @%s', + $mentioned->id, + $mentioned->name, + $mentioned->name, + ), + $user, + ); + + expect($comment->body) + ->toContain('data-type="mention"') + ->toContain(sprintf('data-id="%s"', $mentioned->id)); + + expect($comment->getMentioned()) + ->toHaveCount(1) + ->toContain($mentioned); +});