diff --git a/.env.example b/.env.example index 1047cd32..403fa52a 100644 --- a/.env.example +++ b/.env.example @@ -23,6 +23,13 @@ AUTH_MODE=direct-discord # FABRICA_INSTANCE_ID= # FABRICA_INSTANCE_CREDENTIAL= +# Eigener LiveKit-Server fuers Bildschirmteilen im Vortrag, alle drei oder +# keiner. Gesetzt gilt er vor der Konsole. URL mit wss://, Secret mit +# mindestens 32 Zeichen (openssl rand -base64 48). +# LIVEKIT_URL= +# LIVEKIT_API_KEY= +# LIVEKIT_API_SECRET= + # Schluessel fuer Geheimnisse in der Datenbank (etwa das Token des Discord-Bots). # Leer lassen: ignis legt beim ersten Bedarf storage/private/secret.key an, die # Datei gehoert dann ins Backup. Selbst setzen mit: openssl rand -base64 32 diff --git a/.github/webpackages-ref b/.github/webpackages-ref index 84ecd3f6..f7a2516e 100644 --- a/.github/webpackages-ref +++ b/.github/webpackages-ref @@ -13,4 +13,4 @@ # 3. Im selben Commit composer.lock (composer update 'emergencyforge/*') # und das Dist (npm run build) aus genau diesem Stand erneuern, sonst # schlägt der Dist-Vergleich in php.yml fehl. -mail/v0.2.1 +editor/v0.13.0 diff --git a/composer.json b/composer.json index a8426aa9..18733fb2 100644 --- a/composer.json +++ b/composer.json @@ -31,7 +31,7 @@ "illuminate/queue": "^11.0", "symfony/console": "^7.0", "dragonmantank/cron-expression": "^3.6", - "emergencyforge/editor-php": "^0.10", + "emergencyforge/editor-php": "^0.13", "emergencyforge/http-kernel": "^0.1.3", "emergencyforge/plugin-system": "^0.1", "emergencyforge/health-check": "^0.1", @@ -40,7 +40,7 @@ "emergencyforge/mail": "^0.2", "emergencyforge/list-query": "^0.1", "emergencyforge/ui-php": "^1.9", - "emergencyforge/training": "^0.6", + "emergencyforge/training": "^0.7", "chillerlan/php-qrcode": "^6.0" }, "autoload": { diff --git a/composer.lock b/composer.lock index 63671abe..7d3551bc 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "a8e6b53ab1ee16510f49edb8de94247f", + "content-hash": "20ad4f9115b92ab181175cf2ff36a1c4", "packages": [ { "name": "brick/math", @@ -976,11 +976,11 @@ }, { "name": "emergencyforge/editor-php", - "version": "0.10.0", + "version": "0.13.0", "dist": { "type": "path", "url": "../WebPackages/packages/editor/php", - "reference": "5aff751bff7184962078cd188e38327d21c6aedd" + "reference": "8f2e934b4e1f03c4f84a0c813b8d03335208dfd4" }, "require": { "php": ">=8.3", @@ -1224,11 +1224,11 @@ }, { "name": "emergencyforge/training", - "version": "0.6.0", + "version": "0.7.0", "dist": { "type": "path", "url": "../WebPackages/packages/training", - "reference": "7d91abe2814bffc439d4c739763e353bf951faa9" + "reference": "be7fe7331367acb3c4c3067802504758b70cb759" }, "require": { "emergencyforge/fuzzy-search": "^0.1", @@ -1264,11 +1264,11 @@ }, { "name": "emergencyforge/ui-php", - "version": "1.12.2", + "version": "1.14.0", "dist": { "type": "path", "url": "../WebPackages/packages/ui/php", - "reference": "293546337517ab826e4a3eee801b8aca1a04bf1b" + "reference": "5c0368a48eb5802dd448503fbe5da2b2b34b4a08" }, "require": { "php": ">=8.3" diff --git a/plugins/training/assets/js/presentation.js b/plugins/training/assets/js/presentation.js index 06d999f6..30a47f8a 100644 --- a/plugins/training/assets/js/presentation.js +++ b/plugins/training/assets/js/presentation.js @@ -1403,7 +1403,7 @@ let reason = ''; if (!canShare) reason = 'Bildschirm teilen geht nur im Browser'; else if (!share && via === 'direct' && audience > SCREEN_LIMIT) reason = 'Bildschirm teilen geht ohne EF Sync bis 15 Zuschauer'; - const tip = reason || ((share ? share.via : via) === 'livekit' ? 'Über den Medienserver von EmergencyForge' : 'Direkt an jeden Zuschauer, bis 15'); + const tip = reason || ((share ? share.via : via) === 'livekit' ? $('.ignis-segmented [data-live-mode="screen"]').dataset.livekitTip : 'Direkt an jeden Zuschauer, bis 15'); // Der Knopf im Wartebild sagt dasselbe wie der im Kopf, sonst täte er stumm nichts. [$('.ignis-segmented [data-live-mode="screen"]'), $('[data-live-wait-share]')].forEach((button) => { button.setAttribute('aria-disabled', reason ? 'true' : 'false'); diff --git a/plugins/training/src/Controllers/PresentationController.php b/plugins/training/src/Controllers/PresentationController.php index e0bda3ac..e1842056 100644 --- a/plugins/training/src/Controllers/PresentationController.php +++ b/plugins/training/src/Controllers/PresentationController.php @@ -12,7 +12,6 @@ use EmergencyForge\Http\Response; use Illuminate\Support\Carbon; use InvalidArgumentException; -use Plugin\Training\AiDrafts; use Plugin\Training\Converter; use Plugin\Training\Models\Course; use Plugin\Training\Models\Participation; @@ -75,7 +74,7 @@ public function start(Request $request, string $course, string $session): Respon if ($slides !== null && !$slides->viewsAsPdf()) { return self::back('training/manage/' . $courseModel->id . '#termine', $slides->convert_status === Converter::FAILED ? 'Die Folien ließen sich nicht umwandeln.' : 'Die Folien werden noch umgewandelt.'); } - $live = Presentations::start($sessionModel, self::userId(), AiDrafts::client()); + $live = Presentations::start($sessionModel, self::userId(), Presentations::roomTokens()); if ($live->wasRecentlyCreated) { (new AuditLogger())->log(self::userId(), 'Vortrag gestartet', $sessionModel->title, 'Ausbildung', 0, ['change_type' => 'training_presentation_started']); } @@ -227,7 +226,7 @@ public function screen(Request $request, string $course, string $session): Respo } try { // `direct`: der Host bekam einen LiveKit-Schlüssel, kam aber nicht in den Raum. - $result = Presentations::startScreen($live, self::userId(), AiDrafts::client(), $via === 'direct'); + $result = Presentations::startScreen($live, self::userId(), Presentations::roomTokens(), $via === 'direct'); } catch (DomainException $e) { return self::json(['error' => $e->getMessage()], 409); } @@ -256,7 +255,7 @@ public function roomToken(Request $request, string $course, string $session): Re session_write_close(); } try { - $token = Presentations::roomToken($live, $userId, AiDrafts::client()); + $token = Presentations::roomToken($live, $userId, Presentations::roomTokens()); } catch (DomainException $e) { // `unavailable`: ein Zuschauer bekam keinen Schlüssel, der Raum bleibt und er darf es wieder versuchen. return match ($e->getMessage()) { diff --git a/plugins/training/src/Presentations.php b/plugins/training/src/Presentations.php index 3b673380..7158a713 100644 --- a/plugins/training/src/Presentations.php +++ b/plugins/training/src/Presentations.php @@ -4,7 +4,7 @@ namespace Plugin\Training; -use App\Auth\FabricaClient; +use App\Logging\Logger; use App\Models\User; use App\Support\AccountIdentity; use DateTimeImmutable; @@ -12,8 +12,10 @@ use DomainException; use EmergencyForge\Training\Presentation\Attendance as AttendanceRule; use EmergencyForge\Training\Presentation\DrawEvent; +use EmergencyForge\Training\Presentation\LiveKitServer; use EmergencyForge\Training\Presentation\Liveness; use EmergencyForge\Training\Presentation\Question; +use EmergencyForge\Training\Presentation\RoomTokens; use EmergencyForge\Training\Presentation\Signal; use EmergencyForge\Training\Presentation\Visit; use EmergencyForge\Training\Presentation\WatchTime; @@ -64,10 +66,27 @@ final class Presentations private const SIGNAL_WINDOW = 60; /** - * Mit EF Sync (`$client`) bekommt der Vortrag einen Raum; der Name kommt vom Server und + * Woher die LiveKit-Schlüssel kommen: der eigene Server aus der `.env`, + * sonst die Konsole. Eine halb ausgefüllte `.env` legt den Vortrag nicht + * lahm, es gilt dann die Konsole und das Log sagt, was fehlt. + */ + public static function roomTokens(): ?RoomTokens + { + try { + $own = LiveKitServer::fromEnv($_ENV); + } catch (InvalidArgumentException $e) { + Logger::error('Eigener LiveKit-Server nicht nutzbar, es gilt die Konsole: ' . $e->getMessage()); + $own = null; + } + + return $own ?? AiDrafts::client(); + } + + /** + * Mit Schlüsselquelle (`$client`) bekommt der Vortrag einen Raum; der Name kommt vom Server und * nie vom Browser. Den Schlüssel dafür holt erst roomToken(). */ - public static function start(Session $session, int $userId, ?FabricaClient $client = null): Presentation + public static function start(Session $session, int $userId, ?RoomTokens $client = null): Presentation { // Sperre auf dem Termin, damit zwei gleichzeitige Starts nur einen Vortrag anlegen. $talk = Capsule::connection()->transaction(static function () use ($session, $userId, $client): Presentation { @@ -306,20 +325,20 @@ private static function stopScreen(Presentation $row): void } /** - * Teilen beginnen. Mit Raum über LiveKit. Scheitert die Konsole, entfällt der Raum und + * Teilen beginnen. Mit Raum über LiveKit. Scheitert die Schlüsselquelle, entfällt der Raum und * es geht direkt weiter, solange der Host die Zuschauer allein versorgen kann. Mit - * `$direct` (der Host kam nicht in den Raum) fragt niemand die Konsole und der Raum bleibt. + * `$direct` (der Host kam nicht in den Raum) fragt niemand die Schlüsselquelle und der Raum bleibt. * * @return array{via:'livekit'|'direct', url?:string, token?:string} * @throws DomainException `too_many` ohne LiveKit bei mehr als SCREEN_LIMIT Zuschauern, `ended`, `not_host` */ - public static function startScreen(Presentation $p, int $userId, ?FabricaClient $client, bool $direct = false): array + public static function startScreen(Presentation $p, int $userId, ?RoomTokens $client, bool $direct = false): array { $room = $p->room; $token = null; $failed = false; if (!$direct && $client !== null && $room !== null) { - // Vor der Sperre, damit eine langsame Konsole die Zeile nicht festhält. + // Vor der Sperre, damit eine langsame Schlüsselquelle die Zeile nicht festhält. try { $token = self::key($room, $userId, true, $client); } catch (\RuntimeException) { @@ -344,7 +363,7 @@ public static function startScreen(Presentation $p, int $userId, ?FabricaClient $row->mode = 'screen'; $row->screen_via = $live ? 'livekit' : 'direct'; if ($failed && $row->room === $room) { - // Die Konsole lieferte dem Host nichts; ohne seinen Schlüssel taugt der Raum nicht. + // Die Schlüsselquelle lieferte dem Host nichts; ohne seinen Schlüssel taugt der Raum nicht. $row->room = null; } $row->version++; @@ -357,16 +376,16 @@ public static function startScreen(Presentation $p, int $userId, ?FabricaClient } /** - * Raum-Schlüssel für einen Zuschauer oder den Host. Scheitert die Konsole beim Host, + * Raum-Schlüssel für einen Zuschauer oder den Host. Scheitert die Schlüsselquelle beim Host, * fällt der Raum des Vortrags weg (ein laufendes LiveKit-Teilen endet mit ihm) und alles * läuft über die Abfrage weiter; die Version steigt, damit alle Fenster es merken. Bei einem * Zuschauer ändert sich nichts am Vortrag, denn viele fragen gleichzeitig und ein * kurzer Fehler soll niemandem den Raum nehmen. * * @return array{url:string, token:string} - * @throws DomainException `ended`, `no_room` ohne Raum, ohne Konsole oder wenn der Host keinen Schlüssel bekam, `unavailable` wenn ein Zuschauer keinen bekam + * @throws DomainException `ended`, `no_room` ohne Raum, ohne Schlüsselquelle oder wenn der Host keinen Schlüssel bekam, `unavailable` wenn ein Zuschauer keinen bekam */ - public static function roomToken(Presentation $p, int $userId, ?FabricaClient $client): array + public static function roomToken(Presentation $p, int $userId, ?RoomTokens $client): array { if ($p->ended_at !== null) { throw new DomainException('ended'); @@ -409,7 +428,7 @@ public static function roomToken(Presentation $p, int $userId, ?FabricaClient $c * @return array{url:string, token:string} * @throws \RuntimeException */ - private static function key(string $room, int $userId, bool $host, FabricaClient $client): array + private static function key(string $room, int $userId, bool $host, RoomTokens $client): array { $identity = 'u' . $userId . ($host ? '' : '-' . bin2hex(random_bytes(4))); try { diff --git a/plugins/training/templates/presentation/_bar.php b/plugins/training/templates/presentation/_bar.php index b35d1208..155ca79e 100644 --- a/plugins/training/templates/presentation/_bar.php +++ b/plugins/training/templates/presentation/_bar.php @@ -14,14 +14,16 @@ * @var list $targets nur present */ -use Plugin\Training\AiDrafts; +use EmergencyForge\Training\Presentation\LiveKitServer; use Plugin\Training\Presentations; $liveHost = Presentations::identity($presentation->presenter()->with('mitarbeiter')->first()); $livePresent = $liveRole === 'present'; $liveElapsed = max(0, time() - $presentation->started_at->getTimestamp()); -// Mit EF Sync geht das Teilen über LiveKit; fällt die Konsole aus, zeigt sich das erst beim Start. -$liveKit = AiDrafts::client() !== null; +// Mit eigenem Server oder EF Sync geht das Teilen über LiveKit; fällt er aus, zeigt sich das erst beim Start. +$liveTokens = Presentations::roomTokens(); +$liveKit = $liveTokens !== null; +$liveKitTip = $liveTokens instanceof LiveKitServer ? 'Über den eigenen Medienserver' : 'Über den Medienserver von EmergencyForge'; $e = static fn (string $value): string => htmlspecialchars($value, ENT_QUOTES); ob_start(); ?> @@ -51,7 +53,7 @@
- +
diff --git a/public/assets/dist/editor.css b/public/assets/dist/editor.css index a99f67b9..aa9ecd6c 100644 --- a/public/assets/dist/editor.css +++ b/public/assets/dist/editor.css @@ -1,2 +1,2 @@ -:where(:root){--efe-accent:#2563eb;--efe-surface:#fff;--efe-surface-raised:#f6f7f9;--efe-text:#1f2328;--efe-text-muted:#5f6672;--efe-border:#c9ced6;--efe-bubble-bg:#fff;--efe-shadow:0 10px 28px #14141e29, 0 2px 6px #14141e14;--efe-surround-bg:#e7e9ee;--efe-radius:6px;--efe-sticky-top:0px;--efe-page-bg:#fff;--efe-page-text:#1f2430;--efe-page-accent:#2563eb}.efe-frame,.efe-toolbar,.efe-bubble,.efe-balloon,.efe-suggest{--_accent-soft:var(--efe-accent-soft,color-mix(in srgb, var(--efe-accent) 14%, transparent));--_focus:var(--efe-focus-ring,var(--efe-accent));--_fill-1:color-mix(in srgb, var(--efe-text) 4%, var(--efe-surface));--_fill-2:color-mix(in srgb, var(--efe-text) 7%, transparent);--_hover:color-mix(in srgb, var(--efe-text) 9%, transparent);--_ease:var(--efe-ease,cubic-bezier(.16, 1, .3, 1));--_spring:var(--efe-spring,cubic-bezier(.34, 1.56, .64, 1))}.efe-frame{border:1px solid var(--efe-border);border-radius:calc(var(--efe-radius) * 2);background:var(--_fill-1);color:var(--efe-text);transition:background-color .25s var(--_ease), border-color .25s var(--_ease), box-shadow .25s var(--_ease);position:relative}.efe-frame:focus-within{border-color:color-mix(in srgb, var(--_focus) 55%, transparent);background:var(--efe-surface);box-shadow:0 0 0 4px var(--_accent-soft)}.efe-frame>.efe-toolbar{top:var(--efe-sticky-top);z-index:5;background:inherit;border-radius:calc(var(--efe-radius) * 2 - 1px) calc(var(--efe-radius) * 2 - 1px) 0 0;border:0;padding:8px;position:sticky}.efe-frame>:last-child{border-bottom-left-radius:calc(var(--efe-radius) * 2 - 1px);border-bottom-right-radius:calc(var(--efe-radius) * 2 - 1px)}.efe-surround{background:var(--efe-surround-bg);contain:inline-size;padding:2rem 1rem;overflow-x:auto}.efe-surround>.efe-page{margin-inline:auto}.efe-page{box-sizing:border-box;width:var(--efe-page-width);background:var(--efe-page-bg);min-height:297mm;color:var(--efe-page-text);--efe-page-width:210mm;padding:20mm;box-shadow:0 1px 4px #0000002e}.efe-page:focus,.efe-page .ProseMirror{outline:none}.efe-page .ProseMirror{min-height:100%}.efe-page p{margin:0 0 .75em}.efe-page p:last-child{margin-bottom:0}.efe-page .is-editor-empty:first-child:before,.efe-page .ProseMirror p.is-empty:before{content:attr(data-placeholder);float:left;height:0;color:var(--efe-placeholder,#8a8a8a);pointer-events:none}.efe-page table{border-collapse:collapse;table-layout:fixed;width:100%;margin:0 0 .75em}.efe-page th,.efe-page td{border:1px solid var(--efe-table-border,color-mix(in srgb, currentColor 25%, transparent));vertical-align:top;padding:.35em .5em}.efe-page th{background:var(--efe-table-header-bg,color-mix(in srgb, currentColor 6%, transparent));text-align:left;font-weight:600}.efe-page .ProseMirror :is(h1,h2,h3,h4,h5,h6,p,li,td,th,blockquote){color:var(--efe-page-text)}.efe-page :is(h1,h2,h3){margin:1em 0 .5em;font-weight:700;line-height:1.25}.efe-page :is(h1,h2,h3):first-child{margin-top:0}.efe-page h1{font-size:1.75rem}.efe-page h2{font-size:1.4rem}.efe-page h3{font-size:1.15rem}.efe-page :is(ul,ol){margin:0 0 .75em;padding-left:1.6em}.efe-page ul{list-style:outside}.efe-page ol{list-style:decimal}.efe-page li>p{margin:0}.efe-page blockquote{border-left:3px solid color-mix(in srgb, currentColor 25%, transparent);margin:0 0 .75em;padding:.1em 0 .1em 1em;font-style:italic}.efe-page hr{border:0;border-top:1px solid color-mix(in srgb, currentColor 25%, transparent);margin:1em 0}.efe-page hr.ProseMirror-selectednode{border-top-color:var(--efe-page-accent)}.efe-page a{color:var(--efe-page-accent);text-decoration:underline}.efe-toolbar{background:var(--efe-surface-raised);border:1px solid var(--efe-border);border-radius:calc(var(--efe-radius) * 2);color:var(--efe-text);flex-wrap:wrap;align-items:center;gap:6px;padding:6px;font-size:.875rem;line-height:1.2;display:flex}.efe-icon{fill:none;stroke:currentColor;stroke-width:1.6px;stroke-linecap:round;stroke-linejoin:round;flex:none;width:18px;height:18px}.efe-icon--fa{text-align:center;height:auto;font-size:15px;line-height:1}.efe-toolbar__divider{display:none}.efe-toolbar__group{background:var(--_fill-2);border-radius:calc(var(--efe-radius) + 2px);align-items:center;gap:2px;padding:2px;display:inline-flex}.efe-btn{min-width:30px;height:30px;color:var(--efe-text-muted);border-radius:var(--efe-radius);font:inherit;cursor:pointer;transition:background-color .16s var(--_ease), color .16s var(--_ease), transform .12s var(--_ease);background:0 0;border:0;justify-content:center;align-items:center;gap:4px;margin:0;padding:0 6px;line-height:1;display:inline-flex;position:relative}.efe-btn:hover:not(:disabled){background:var(--_hover);color:var(--efe-text)}.efe-btn:active:not(:disabled){transform:scale(.92)}.efe-btn:after{content:"";background:var(--efe-accent);width:14px;height:2px;transition:transform .22s var(--_spring);pointer-events:none;border-radius:1px;margin-left:-7px;position:absolute;bottom:2px;left:50%;transform:scaleX(0)}.efe-btn.is-active{color:var(--efe-text)}.efe-btn.is-active:after{transform:scaleX(1)}.efe-btn:disabled{opacity:.35;cursor:default}.efe-btn:focus-visible,.efe-dropdown__item:focus-visible{outline:2px solid var(--_focus);outline-offset:-2px}.efe-btn--labelled{white-space:nowrap;padding:0 8px;font-size:.8125rem}.efe-btn--dropdown{padding:0 4px 0 6px}.efe-btn--dropdown>.efe-icon:last-child{stroke-width:2px;opacity:.7;width:12px;height:12px;transition:transform .22s var(--_ease)}.efe-btn--dropdown[aria-expanded=true]>.efe-icon:last-child{transform:rotate(180deg)}.efe-btn--heading{width:8.5rem;color:var(--efe-text);justify-content:space-between;padding-left:8px;font-weight:500}.efe-btn__text{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.efe-dropdown{display:inline-flex;position:relative}.efe-dropdown__menu{z-index:20;background:var(--efe-bubble-bg);min-width:12rem;color:var(--efe-text);border:1px solid var(--efe-border);border-radius:calc(var(--efe-radius) + 4px);box-shadow:var(--efe-shadow);transform-origin:0 0;flex-direction:column;gap:1px;padding:5px;display:flex;position:absolute;top:calc(100% + 6px);left:0}.efe-dropdown__menu[hidden]{display:none}.efe-dropdown__menu[data-state=open]{animation:efe-fade-in .16s var(--_ease) both, efe-drop-in .22s var(--_spring) both}.efe-dropdown__menu[data-state=closed]{pointer-events:none;animation:.12s ease-in both efe-drop-out}.efe-dropdown__item{min-height:30px;color:inherit;border-radius:var(--efe-radius);font:inherit;text-align:left;white-space:nowrap;cursor:pointer;transition:background-color .12s var(--_ease), color .12s var(--_ease);background:0 0;border:0;align-items:center;gap:8px;padding:6px 10px;display:flex}.efe-dropdown__item:hover:not(:disabled){background:var(--_hover)}.efe-dropdown__item[aria-checked=true]{background:var(--_accent-soft);color:var(--efe-accent)}.efe-dropdown__item:disabled{opacity:.4;cursor:default}.efe-dropdown__menu--heading{min-width:13rem}.efe-dropdown__item--h1{font-size:1.5em;font-weight:700}.efe-dropdown__item--h2{font-size:1.3em;font-weight:700}.efe-dropdown__item--h3{font-size:1.12em;font-weight:700}.efe-bubble,.efe-balloon{z-index:30;background:var(--efe-bubble-bg);color:var(--efe-text);border:1px solid var(--efe-border);border-radius:calc(var(--efe-radius) + 5px);box-shadow:var(--efe-shadow);text-align:left;font-family:inherit;font-size:.875rem;font-style:normal;font-weight:400;line-height:1.2;position:absolute}.efe-bubble{transform-origin:bottom;gap:2px;padding:4px;display:flex}.efe-bubble[data-state=open]{animation:efe-fade-in .16s var(--_ease) both, efe-rise-in .26s var(--_spring) both}.efe-bubble[data-state=closed]{pointer-events:none;animation:.12s ease-in both efe-rise-out}.efe-bubble:focus{outline:none}.efe-balloon{transform-origin:top;gap:6px;width:max-content;max-width:calc(100vw - 16px);padding:8px;display:grid}.efe-balloon[data-state=open]{animation:efe-fade-in .16s var(--_ease) both, efe-drop-in .26s var(--_spring) both}.efe-balloon[data-state=closed]{pointer-events:none;animation:.12s ease-in both efe-drop-out}.efe-balloon__label{color:var(--efe-text-muted);font-size:.75rem}.efe-balloon__row{align-items:center;gap:4px;display:flex}.efe-balloon__input{box-sizing:border-box;background:var(--efe-surface);width:16rem;min-width:0;height:30px;color:var(--efe-text);border:1px solid var(--efe-border);border-radius:var(--efe-radius);font:inherit;transition:border-color .16s var(--_ease), box-shadow .16s var(--_ease);flex:auto;margin:0;padding:0 9px}.efe-balloon__input:focus{border-color:var(--_focus);box-shadow:0 0 0 3px var(--_accent-soft);outline:none}.efe-balloon__input[aria-invalid=true]{border-color:var(--efe-danger,#c0392b);box-shadow:0 0 0 3px color-mix(in srgb, var(--efe-danger,#c0392b) 18%, transparent)}.efe-btn--primary,.efe-btn--primary:hover:not(:disabled){color:var(--efe-accent)}.efe-balloon__error{color:var(--efe-danger,#c0392b);font-size:.75rem}.efe-balloon__error[hidden],.efe-btn[hidden]{display:none}@keyframes efe-fade-in{0%{opacity:0}}@keyframes efe-drop-in{0%{transform:translateY(-5px)scale(.97)}}@keyframes efe-rise-in{0%{transform:translateY(5px)scale(.97)}}@keyframes efe-drop-out{to{opacity:0;transform:translateY(-4px)scale(.97)}}@keyframes efe-rise-out{to{opacity:0;transform:translateY(4px)scale(.97)}}@media (width<=480px){.efe-balloon__input{width:auto}}@media (prefers-reduced-motion:reduce){.efe-frame,.efe-btn,.efe-btn:after,.efe-btn--dropdown>.efe-icon:last-child,.efe-dropdown__item,.efe-dropdown__menu,.efe-bubble,.efe-balloon,.efe-balloon__input,.efe-dropdown__menu[data-state],.efe-bubble[data-state],.efe-balloon[data-state]{transition:none;animation:none}.efe-btn:active:not(:disabled){transform:none}}.efe-variable{cursor:default;-webkit-box-decoration-break:clone;box-decoration-break:clone;border-radius:.3em}.efe-variable--filled{-webkit-text-decoration:underline dotted color-mix(in srgb, var(--efe-page-accent,#2563eb) 55%, transparent);text-decoration:underline dotted color-mix(in srgb, var(--efe-page-accent,#2563eb) 55%, transparent);text-underline-offset:.2em;text-decoration-thickness:1px}.efe-variable--filled:hover{background:color-mix(in srgb, var(--efe-page-accent,#2563eb) 8%, transparent)}.efe-variable--placeholder,.efe-variable--missing,.efe-variable--unknown{white-space:nowrap;vertical-align:baseline;margin:0 .05em;padding:0 .45em;font-size:.88em;line-height:1.5;display:inline-block}.efe-variable--placeholder{background:color-mix(in srgb, var(--efe-page-accent,#2563eb) 10%, transparent);border:1px solid color-mix(in srgb, var(--efe-page-accent,#2563eb) 35%, transparent);color:var(--efe-page-accent,#2563eb)}.efe-variable--missing{background:var(--efe-missing-bg,#fff4e0);border:1px dashed var(--efe-missing-border,#d9822b);color:var(--efe-missing-text,#8a4b08)}.efe-variable--missing:before{content:"fehlt: ";font-weight:600}.efe-variable--unknown{background:var(--efe-unknown-bg,#fdecec);border:1px dashed var(--efe-unknown-border,#c0392b);color:var(--efe-unknown-text,#9b2c22);font-family:ui-monospace,monospace}.efe-variable.is-selected{outline:2px solid var(--efe-page-accent,#2563eb);outline-offset:1px}.efe-variable.is-flagged,.efe-field.is-flagged .efe-field__input{animation:1.6s ease-out efe-flag}@keyframes efe-flag{0%,40%{box-shadow:0 0 0 3px color-mix(in srgb, var(--efe-page-accent,#2563eb) 45%, transparent)}to{box-shadow:0 0 0 3px #0000}}.efe-image{vertical-align:middle;max-width:100%}.efe-figure{margin:0 0 .75em}.efe-figure img{max-width:100%;height:auto;display:block}.efe-image.ProseMirror-selectednode,.efe-figure.ProseMirror-selectednode img{outline:2px solid var(--efe-page-accent,#2563eb);outline-offset:1px}.efe-callout{--_tone:var(--efe-callout-note,#2563eb);border-left:3px solid var(--_tone);border-radius:var(--efe-radius);background:color-mix(in srgb, var(--_tone) 10%, transparent);margin:.75em 0;padding:.6em .9em}.efe-callout--important{--_tone:var(--efe-callout-important,#d97706)}.efe-callout--tip{--_tone:var(--efe-callout-tip,#16a34a)}.efe-callout:before{content:attr(aria-label);color:var(--_tone);font-size:.875em;font-weight:600;display:block}.efe-callout>:first-child{margin-top:.2em}.efe-callout>:last-child{margin-bottom:0}.efe-video{aspect-ratio:16/9;border-radius:var(--efe-radius);color:#e5e7eb;background:#0b0b0d;place-items:center;max-width:100%;margin:.75em 0;display:grid;position:relative;overflow:hidden}.efe-video__play{cursor:pointer;background:var(--efe-page-accent,#2563eb);border:0;border-radius:50%;width:56px;height:56px;padding:0;position:relative}.efe-video__play:after{content:"";border:10px solid #0000;border-left:17px solid #fff;border-right-width:0;width:0;height:0;margin:auto;position:absolute;inset:0;transform:translate(2px)}.efe-video__note{color:#d1d5db;background:linear-gradient(#0000,#0009);padding:.5em .9em;font-size:.8125rem;position:absolute;bottom:0;left:0;right:0}.efe-video.ProseMirror-selectednode{outline:2px solid var(--efe-page-accent,#2563eb);outline-offset:1px}.efe-suggest{background:var(--efe-bubble-bg);min-width:16rem;max-height:16rem;color:var(--efe-text);border:1px solid var(--efe-border);border-radius:calc(var(--efe-radius) + 4px);box-shadow:var(--efe-shadow);z-index:30;flex-direction:column;padding:5px;font-size:.875rem;display:flex;overflow-y:auto}.efe-suggest__item{color:inherit;border-radius:var(--efe-radius);font:inherit;text-align:left;cursor:pointer;background:0 0;border:none;padding:6px 10px}.efe-suggest__item:hover{background:var(--_hover)}.efe-suggest__item.is-active{background:var(--_accent-soft);color:var(--efe-accent)}.efe-suggest__empty{color:var(--efe-text-muted);padding:6px 10px}.efe-page .efe-field{display:inline}.efe-page .efe-field__input{border-bottom:1px solid var(--efe-field-border,#9aa3b2);cursor:text;background:0 0;border-radius:.2em .2em 0 0;outline:none;min-width:6ch;padding:0 .2em;display:inline-block}.efe-page .efe-field--empty .efe-field__input,.efe-page .efe-field__input:hover{background:var(--efe-field-bg,color-mix(in srgb, var(--efe-page-accent) 7%, transparent))}.efe-page .efe-field__input:focus{border-bottom-color:var(--efe-page-accent);background:var(--efe-field-bg-focus,color-mix(in srgb, var(--efe-page-accent) 14%, transparent))}.efe-page .efe-field--empty .efe-field__input:before{content:attr(data-efe-placeholder);color:var(--efe-placeholder,#8a8a8a)}.efe-page .efe-field--required.efe-field--empty .efe-field__input{border-bottom-color:var(--efe-field-required,#d9822b);background:var(--efe-missing-bg,#fff4e0)}.efe-page .efe-field--required.efe-field--empty .efe-field__input:after{content:" *";color:var(--efe-field-required,#d9822b);font-weight:600}.efe-page select.efe-field__input{appearance:none;color:inherit;font:inherit;cursor:pointer;border-top:0;border-left:0;border-right:0;margin:0;padding-right:1.1em}.efe-page .efe-field--empty select.efe-field__input{color:var(--efe-placeholder,#8a8a8a)}.efe-page select.efe-field__input option{color:canvastext}.efe-page select.efe-field__input:disabled{opacity:1;cursor:default}.efe-page .efe-field--select{position:relative}.efe-page .efe-field--select:after{content:"▾";color:var(--efe-placeholder,#8a8a8a);pointer-events:none;position:absolute;right:.25em}.efe-section{border-radius:.25em;margin:0 0 1em;padding:0;transition:background-color .15s;position:relative}.efe-section:before{content:"";background:0 0;border-radius:1px;width:2px;transition:background-color .15s;position:absolute;top:.1em;bottom:.1em;left:-.9rem}.efe-section--locked:before{background:var(--efe-section-locked-rule,#c2c8d2)}.efe-section--locked:hover{background:var(--efe-section-locked-hover,#64748b0f)}.efe-section--free:focus-within:before{background:var(--efe-page-accent,#2563eb)}.efe-section.is-nudged{background:var(--efe-section-nudge,#d9822b1f)}.efe-section.is-nudged:before{background:var(--efe-field-required,#d9822b)}.efe-section__head{letter-spacing:.04em;text-transform:uppercase;color:var(--efe-placeholder,#8a8a8a);-webkit-user-select:none;user-select:none;align-items:center;gap:.4em;margin:0 0 .3em;font-size:.72rem;line-height:1.2;display:flex}.efe-section__head[hidden],.efe-section__repeat[hidden]{display:none}.efe-section__lock{color:var(--efe-section-locked-icon,#8a93a3);display:inline-flex}.efe-section__lock .efe-icon{width:.95rem;height:.95rem}.efe-section__title{font-weight:600}.efe-section__badge{letter-spacing:.03em;background:color-mix(in srgb, var(--efe-page-accent) 12%, transparent);color:var(--efe-page-accent);border-radius:.6em;padding:.05em .5em;font-size:.95em;font-weight:600;display:inline-block}.efe-section--free .efe-section__badge:first-child,.efe-section__badge--repeat{color:#4b5563;background:#6b728024}.efe-section__content>:last-child{margin-bottom:0}.efe-page .efe-section--free .efe-section__content>p:only-child:has(>br.ProseMirror-trailingBreak:only-child):before{content:var(--efe-hint,"");float:left;height:0;color:var(--efe-placeholder,#8a8a8a);pointer-events:none}.efe-section__repeat{-webkit-user-select:none;user-select:none;gap:.5em;margin-top:.4em;font-size:.8rem;display:flex}.efe-section__repeat-btn{border:1px dashed color-mix(in srgb, var(--efe-page-text,#1f2430) 30%, transparent);color:color-mix(in srgb, var(--efe-page-text,#1f2430) 70%, transparent);font:inherit;cursor:pointer;background:0 0;border-radius:.4em;align-items:center;gap:.35em;padding:.2em .6em;display:inline-flex}.efe-section__repeat-btn:hover,.efe-section__repeat-btn:focus-visible{border-color:var(--efe-page-accent,#2563eb);color:var(--efe-page-accent,#2563eb)}.efe-section__repeat-btn .efe-icon{width:.9rem;height:.9rem}.efe-page--preview .efe-section__head,.efe-page--preview .efe-section__repeat{display:none}.efe-page--preview .efe-section:before{content:none}.efe-page--preview .efe-section,.efe-page--preview .efe-section:hover{background:0 0}.efe-page--preview .efe-variable--filled,.efe-page--preview .efe-variable--filled:hover{background:0 0;text-decoration:none}.efe-page--preview .efe-field__input,.efe-page--preview .efe-field__input:hover{cursor:default;background:0 0;border:0;min-width:0;padding:0}.efe-page--preview .efe-field--empty .efe-field__input:before,.efe-page--preview .efe-field--select:after{content:none}.efe-page--preview select.efe-field__input{pointer-events:none;padding-right:0}.efe-page--preview .efe-field--required.efe-field--empty .efe-field__input{border-bottom:1px dashed var(--efe-field-required,#d9822b);background:0 0;min-width:6ch;display:inline-block}.efe-page--preview .efe-field--required.efe-field--empty .efe-field__input:after,.efe-page--preview .efe-section--free .efe-section__content>p:only-child:before{content:none}.efe-page-break{cursor:default;-webkit-user-select:none;user-select:none;justify-content:center;align-items:center;height:1.4em;margin:1em 0;display:flex;position:relative}.efe-page-break:before{content:"";z-index:0;border-top:1px dashed color-mix(in srgb, currentColor 30%, transparent);position:absolute;top:50%;left:0;right:0}.efe-page-break:after{content:"Seitenumbruch";z-index:1;background:var(--efe-page-bg,#fff);color:color-mix(in srgb, currentColor 55%, transparent);letter-spacing:.02em;white-space:nowrap;flex-shrink:0;padding:0 .75em;font-size:.75em;position:relative}.efe-page-break.ProseMirror-selectednode:before{border-top-color:var(--efe-page-accent)}.efe-page-gap{box-sizing:border-box;width:var(--efe-page-width);border-top:1px solid var(--efe-page-gap-border,color-mix(in srgb, var(--efe-surround-bg) 85%, #000));border-bottom:1px solid var(--efe-page-gap-border,color-mix(in srgb, var(--efe-surround-bg) 85%, #000));background:var(--efe-page-gap-bg,var(--efe-surround-bg));pointer-events:none;-webkit-user-select:none;user-select:none;margin-left:50%;position:relative;transform:translate(-50%)}.efe-page-gap__nummer{background:var(--efe-page-bg,#fff);color:color-mix(in srgb, currentColor 55%, transparent);letter-spacing:.02em;opacity:.6;padding:0 .3em;font-size:.7em;position:absolute;top:0;right:20mm;transform:translateY(-100%)}@media print{.efe-page-break{page-break-after:always;break-after:page;border:none;height:0;margin:0}.efe-page-break:before,.efe-page-break:after{content:none}.efe-toolbar,.efe-bubble,.efe-balloon,.efe-page-gap,.efe-section__head,.efe-section__repeat,.efe-section__badge,.efe-section__lock,.efe-section__title,.efe-suggest{display:none!important}.efe-section,.efe-section:hover{background:0 0!important}.efe-section:before{content:none!important}.efe-variable--filled{background:0 0!important;text-decoration:none!important}.efe-variable--missing,.efe-variable--unknown,.efe-variable--placeholder{display:none!important}.efe-field,.efe-field__input{background:0 0!important;border:0!important;min-width:0!important;padding:0!important;display:inline!important}.efe-field--empty .efe-field__input:before,.efe-field--empty .efe-field__input:after,.efe-field--select:after,.efe-section__content>p:only-child:before{content:none!important}}.efe-page{--_input-tint:var(--efe-input-tint,color-mix(in srgb, var(--efe-page-accent,#2563eb) 7%, transparent));--_input-line:var(--efe-input-line,color-mix(in srgb, var(--efe-page-accent,#2563eb) 50%, transparent));--_input-text:var(--efe-input-text,var(--efe-page-accent,#2563eb));--_fixed-tint:var(--efe-fixed-tint,color-mix(in srgb, currentColor 6%, transparent));--_fixed-line:var(--efe-fixed-line,color-mix(in srgb, currentColor 40%, transparent))}.efe-input,.efe-repeat,.efe-optional{margin:0 0 .75em;position:relative}.efe-input{background:var(--_input-tint);box-shadow:inset 0 0 0 1px var(--_input-line);border-radius:.3em;padding:.5em .65em;display:flow-root}.efe-input:focus-within{box-shadow:inset 0 0 0 1.5px var(--_input-text), 0 0 0 3px color-mix(in srgb, var(--_input-text) 18%, transparent)}.efe-block__head{-webkit-user-select:none;user-select:none;align-items:center;gap:.4em;margin:0 0 .25em;font-size:.72rem;line-height:1.2;display:flex}.efe-block__head[hidden]{display:none}.efe-block__label{color:var(--_input-text);font-weight:600}.efe-block__badge{letter-spacing:.03em;color:var(--efe-text-muted,#5f6672);background:color-mix(in srgb, currentColor 8%, transparent);border-radius:.25em;padding:.05em .4em;font-size:.68rem}.efe-input__body>p:only-child:empty:before,.efe-input.is-empty .efe-input__body>p:first-child:before{content:var(--efe-placeholder,"");color:var(--efe-text-muted,#5f6672);pointer-events:none;font-style:italic}.efe-input.is-locked{background:var(--_fixed-tint);box-shadow:inset 0 0 0 1px var(--_fixed-line)}.efe-input__choice{font:inherit;margin:0 0 .35em}.efe-input__snippet-text{white-space:pre-line;margin:0}.efe-input__snippet-more{color:var(--_input-text);margin-top:.3em;font-size:.75rem}.efe-fixed{background:repeating-linear-gradient(135deg, var(--_fixed-tint) 0 4px, transparent 4px 8px);box-shadow:inset 0 0 0 1px var(--_fixed-line);border-radius:.25em;margin:.25em 0 .6em;padding:.35em .6em;position:relative}.efe-fixed__head{background:var(--efe-page-bg,#fff);margin:0;padding:0 .3em;position:absolute;top:-.7em;right:.6em}.efe-aside{margin:0 0 .75em 1.25em;padding:.6em;position:relative}.efe-aside--left{margin:0 1.25em .75em 0}.efe-aside--framed{border:1px solid}.efe-repeat,.efe-optional{border-left:2px solid var(--_input-line);padding-left:.6em}.efe-block__btn{border:1px solid var(--efe-border,#c9ced6);background:var(--efe-surface,#fff);color:var(--efe-text,inherit);font:inherit;cursor:pointer;border-radius:.3em;align-items:center;gap:.25em;padding:.1em .45em;display:inline-flex}.efe-optional.is-off>.efe-optional__body{display:none}.efe-optional.is-off{opacity:.7}.efe-prompt{color:var(--efe-text-muted,#5f6672);font-style:italic}.efe-is-fixed.is-nudged,.efe-input.is-nudged{animation:.45s efe-nudge}.efe-field--locked{opacity:.65}@keyframes efe-nudge{0%,to{transform:none}20%{transform:translate(-3px)}45%{transform:translate(3px)}70%{transform:translate(-1.5px)}}@media (prefers-reduced-motion:reduce){.efe-is-fixed.is-nudged,.efe-input.is-nudged{animation:none}}.efe-page--preview .efe-input,.efe-page--preview .efe-fixed,.efe-page--preview .efe-repeat,.efe-page--preview .efe-optional{box-shadow:none;background:0 0;border:0;padding:0}.efe-page--preview .efe-block__head,.efe-page--preview .efe-prompt,.efe-page--preview .efe-optional.is-off{display:none}.efe-page--layout{position:relative}.efe-band-replica{height:var(--efe-band-height);opacity:.72;pointer-events:none;-webkit-user-select:none;user-select:none;font-size:.85em;position:absolute;overflow:hidden}.efe-page>.efe-band-replica--head{top:var(--efe-band-distance)}.efe-page>.efe-band-replica--foot{bottom:var(--efe-band-distance);flex-direction:column;justify-content:flex-end;display:flex}.efe-band-replica p{margin:0}.efe-band-replica table{border-collapse:collapse;width:100%}.efe-page-gap--bands{background:0 0;border:0;flex-direction:column;display:flex}.efe-page-gap__margin{background:var(--efe-page-bg);position:relative}.efe-page-gap__margin .efe-band-replica--head{top:var(--efe-band-distance)}.efe-page-gap__margin .efe-band-replica--foot{bottom:var(--efe-band-distance);flex-direction:column;justify-content:flex-end;display:flex}.efe-page-gap__space{background:var(--efe-page-gap-bg,var(--efe-surround-bg));border-top:1px solid var(--efe-page-gap-border,color-mix(in srgb, var(--efe-surround-bg) 85%, #000));border-bottom:1px solid var(--efe-page-gap-border,color-mix(in srgb, var(--efe-surround-bg) 85%, #000))}.efe-page-gap--bands .efe-page-gap__nummer{top:auto;bottom:2mm;transform:none}.efe-docedit{flex-direction:column;gap:0;min-width:0;display:flex}.efe-docedit__toolbar{flex-wrap:wrap;align-items:center;gap:6px;display:flex}.efe-docedit__tools[hidden],.efe-docedit__bar[hidden]{display:none}.efe-docedit__tools,.efe-docedit__format,.efe-docedit__bar{flex-wrap:wrap;align-items:center;gap:6px;display:flex}.efe-btn--text{white-space:nowrap;width:auto;padding:0 10px}.efe-docedit__menu .efe-dropdown__menu{min-width:240px}.efe-docedit__menu .efe-dropdown__item{text-align:left;gap:1px;display:grid}.efe-docedit__menu .efe-dropdown__item small{color:var(--efe-text-muted);font-size:.75rem}.efe-docedit__layout{grid-template-columns:minmax(0,1fr) 320px;align-items:start;display:grid}.efe-docedit__sheet{flex-direction:column;align-items:center;min-width:0;display:flex;overflow-x:auto}.efe-docedit__page{position:relative}.efe-docedit__sheet>*{zoom:var(--efe-sheet-zoom,1)}@media (width<=960px){.efe-docedit__layout{grid-template-columns:minmax(0,1fr)}}.efe-ruler{background:var(--efe-surface-raised,#fff);height:22px;box-shadow:0 0 0 1px var(--efe-border);-webkit-user-select:none;user-select:none;touch-action:none;border-radius:4px 4px 0 0;flex:none;margin:0 auto;position:relative}.efe-ruler[hidden]{display:none}.efe-ruler__ticks{background:repeating-linear-gradient(to right, color-mix(in srgb, var(--efe-text) 55%, transparent) 0 1px, transparent 1px 10mm) 0 100% / 100% 9px no-repeat, repeating-linear-gradient(to right, color-mix(in srgb, var(--efe-text) 35%, transparent) 0 1px, transparent 1px 5mm) 0 100% / 100% 6px no-repeat, repeating-linear-gradient(to right, color-mix(in srgb, var(--efe-text) 18%, transparent) 0 1px, transparent 1px 1mm) 0 100% / 100% 3px no-repeat;position:absolute;inset:0}.efe-ruler__off{background:repeating-linear-gradient(135deg, color-mix(in srgb, var(--efe-text) 8%, transparent) 0 3px, transparent 3px 6px);position:absolute;top:0;bottom:0}.efe-ruler__num{color:var(--efe-text-muted);font-size:9px;line-height:10px;position:absolute;top:1px;transform:translate(-50%)}.efe-ruler__handle{cursor:ew-resize;place-items:end center;width:14px;height:22px;margin-left:-7px;display:grid;position:absolute;top:0}.efe-ruler__handle:after{content:"";border-left:6px solid #0000;border-right:6px solid #0000;border-top:9px solid var(--efe-accent)}.efe-ruler__handle:focus-visible{outline:2px solid var(--_focus);outline-offset:1px}.efe-ruler__tip{z-index:5;background:var(--efe-text);color:var(--efe-surface,#fff);white-space:nowrap;pointer-events:none;border-radius:4px;padding:2px 6px;font-size:11px;position:absolute;top:26px;transform:translate(-50%)}.efe-band-slot{z-index:2;position:absolute}.efe-docedit[data-mode=template] .efe-band-slot{outline:1px dashed color-mix(in srgb, var(--efe-page-text) 25%, transparent);outline-offset:2mm}.efe-band-slot.is-overflow{outline:1.5px dashed #d97706}.efe-band-slot__editor .ProseMirror{min-height:1.2em}.efe-band-slot__editor .ProseMirror p{margin:0}.efe-docedit[data-mode=template] .efe-band-slot__editor{max-height:none}.efe-docedit:not([data-mode=template]) .efe-band-slot__editor{max-height:var(--efe-band-limit);overflow:hidden}.efe-band-slot__editor[hidden]{display:none}.efe-band-slot__tabs{white-space:nowrap;gap:4px;font-size:11px;display:flex;position:absolute;bottom:calc(100% + 2mm);left:0}.efe-band-slot--foot .efe-band-slot__tabs{top:calc(100% + 2mm);bottom:auto}.efe-band-slot__tab,.efe-band-slot__add{border:1px solid var(--efe-border);background:var(--efe-surface,#fff);color:var(--efe-text);font:inherit;cursor:pointer;border-radius:999px;padding:1px 8px;font-size:11px}.efe-band-slot__tab[aria-pressed=true]{border-color:var(--efe-accent);color:var(--efe-accent)}.efe-band-slot__label,.efe-band-slot__note{color:var(--efe-text-muted)}.efe-docedit__panel{border-left:1px solid var(--efe-border);background:var(--efe-surface,#fff);color:var(--efe-text);align-content:start;gap:14px;min-width:0;padding:16px;font-size:13px;line-height:1.45;display:grid}.efe-prop__kicker{letter-spacing:.06em;text-transform:uppercase;color:var(--efe-text-muted);margin:0;font-size:11px}.efe-prop__title{margin:2px 0 0;font-size:15px;font-weight:600}.efe-prop{gap:5px;display:grid}.efe-prop__label{color:var(--efe-text-muted);font-size:12px;font-weight:500}.efe-prop__input{box-sizing:border-box;border:1px solid var(--efe-border);background:var(--efe-surface-raised,#fff);width:100%;color:var(--efe-text);font:inherit;border-radius:6px;padding:6px 8px}.efe-prop__input:focus-visible,.efe-prop__btn:focus-visible,.efe-prop__seg button:focus-visible{outline:2px solid var(--_focus);outline-offset:1px}.efe-prop__area{resize:vertical;min-height:72px}.efe-prop__grid{grid-template-columns:repeat(4,minmax(0,1fr));gap:8px;display:grid}.efe-prop__grid--2{grid-template-columns:repeat(2,minmax(0,1fr))}.efe-prop__hint,.efe-prop__note{color:var(--efe-text-muted);margin:0;font-size:12.5px}.efe-prop__note{background:color-mix(in srgb, var(--efe-text) 5%, transparent);border-radius:8px;padding:8px 10px}.efe-prop__note--warn{color:var(--efe-text);background:#f59e0b29;gap:8px;display:grid}.efe-prop__note--warn p{margin:0}.efe-prop__note--ok{color:var(--efe-text);background:#16a34a1f}.efe-prop__check{cursor:pointer;align-items:flex-start;gap:8px;display:flex}.efe-prop__check input{accent-color:var(--efe-accent);margin-top:3px}.efe-prop__seg{border:1px solid var(--efe-border);border-radius:999px;gap:2px;width:fit-content;padding:2px;display:inline-flex}.efe-prop__seg button{color:var(--efe-text-muted);font:inherit;cursor:pointer;background:0 0;border:0;border-radius:999px;padding:3px 12px}.efe-prop__seg button[aria-pressed=true]{background:var(--_accent-soft,color-mix(in srgb, var(--efe-accent) 14%, transparent));color:var(--efe-text)}.efe-prop__btn{border:1px solid var(--efe-border);background:var(--efe-surface-raised,#fff);color:var(--efe-text);font:inherit;cursor:pointer;border-radius:6px;justify-self:start;padding:6px 12px}.efe-prop__btn--primary{background:var(--efe-accent);color:#fff;border-color:#0000}.efe-prop__btn--danger{color:#dc2626}.efe-prop__row{align-items:center;gap:8px;display:flex}.efe-prop__range{accent-color:var(--efe-accent);flex:1}.efe-prop__code{margin:0;font-family:ui-monospace,monospace;font-size:12px}.efe-prop__open{gap:4px;display:grid}.efe-prop__open-item{text-align:left;border:1px solid var(--efe-border);background:var(--efe-surface-raised,#fff);color:var(--efe-text);font:inherit;cursor:pointer;border-radius:6px;gap:1px;padding:7px 10px;display:grid}.efe-prop__open-item small{color:#b45309}.efe-prop__summary p{margin:0}.efe-docedit__bubble{z-index:40;background:var(--efe-bubble-bg,var(--efe-surface-raised,#fff));box-shadow:0 0 0 1px var(--efe-border), 0 8px 24px -6px #00000040;border-radius:10px;gap:4px;padding:4px;display:flex;position:fixed}.efe-docedit__bubble[hidden]{display:none} +:where(:root){--efe-accent:#2563eb;--efe-surface:#fff;--efe-surface-raised:#f6f7f9;--efe-text:#1f2328;--efe-text-muted:#5f6672;--efe-border:#c9ced6;--efe-bubble-bg:#fff;--efe-shadow:0 10px 28px #14141e29, 0 2px 6px #14141e14;--efe-surround-bg:#e7e9ee;--efe-radius:6px;--efe-sticky-top:0px;--efe-page-bg:#fff;--efe-page-text:#1f2430;--efe-page-accent:#2563eb}.efe-frame,.efe-toolbar,.efe-bubble,.efe-balloon,.efe-suggest{--_accent-soft:var(--efe-accent-soft,color-mix(in srgb, var(--efe-accent) 14%, transparent));--_focus:var(--efe-focus-ring,var(--efe-accent));--_fill-1:color-mix(in srgb, var(--efe-text) 4%, var(--efe-surface));--_fill-2:color-mix(in srgb, var(--efe-text) 7%, transparent);--_hover:color-mix(in srgb, var(--efe-text) 9%, transparent);--_ease:var(--efe-ease,cubic-bezier(.16, 1, .3, 1));--_spring:var(--efe-spring,cubic-bezier(.34, 1.56, .64, 1))}.efe-frame{border:1px solid var(--efe-border);border-radius:calc(var(--efe-radius) * 2);background:var(--_fill-1);color:var(--efe-text);transition:background-color .25s var(--_ease), border-color .25s var(--_ease), box-shadow .25s var(--_ease);position:relative}.efe-frame:focus-within{border-color:color-mix(in srgb, var(--_focus) 55%, transparent);background:var(--efe-surface);box-shadow:0 0 0 4px var(--_accent-soft)}.efe-frame>.efe-toolbar{top:var(--efe-sticky-top);z-index:5;background:inherit;border-radius:calc(var(--efe-radius) * 2 - 1px) calc(var(--efe-radius) * 2 - 1px) 0 0;border:0;padding:8px;position:sticky}.efe-frame>:last-child{border-bottom-left-radius:calc(var(--efe-radius) * 2 - 1px);border-bottom-right-radius:calc(var(--efe-radius) * 2 - 1px)}.efe-surround{background:var(--efe-surround-bg);contain:inline-size;padding:2rem 1rem;overflow-x:auto}.efe-surround>.efe-page{margin-inline:auto}.efe-page{box-sizing:border-box;width:var(--efe-page-width);background:var(--efe-page-bg);min-height:297mm;color:var(--efe-page-text);--efe-page-width:210mm;padding:20mm;box-shadow:0 1px 4px #0000002e}.efe-page:focus,.efe-page .ProseMirror{outline:none}.efe-page .ProseMirror{min-height:100%}.efe-page p{margin:0 0 .75em}.efe-page p:last-child{margin-bottom:0}.efe-page .is-editor-empty:first-child:before,.efe-page .ProseMirror p.is-empty:before{content:attr(data-placeholder);float:left;height:0;color:var(--efe-placeholder,#8a8a8a);pointer-events:none}.efe-page table{border-collapse:collapse;table-layout:fixed;width:100%;margin:0 0 .75em}.efe-page th,.efe-page td{border:1px solid var(--efe-table-border,color-mix(in srgb, currentColor 25%, transparent));vertical-align:top;padding:.35em .5em}.efe-page th{background:var(--efe-table-header-bg,color-mix(in srgb, currentColor 6%, transparent));text-align:left;font-weight:600}.efe-page .ProseMirror :is(h1,h2,h3,h4,h5,h6,p,li,td,th,blockquote){color:var(--efe-page-text)}.efe-page :is(h1,h2,h3){margin:1em 0 .5em;font-weight:700;line-height:1.25}.efe-page :is(h1,h2,h3):first-child{margin-top:0}.efe-page h1{font-size:1.75rem}.efe-page h2{font-size:1.4rem}.efe-page h3{font-size:1.15rem}.efe-page :is(ul,ol){margin:0 0 .75em;padding-left:1.6em}.efe-page ul{list-style:outside}.efe-page ol{list-style:decimal}.efe-page li>p{margin:0}.efe-page blockquote{border-left:3px solid color-mix(in srgb, currentColor 25%, transparent);margin:0 0 .75em;padding:.1em 0 .1em 1em;font-style:italic}.efe-page hr{border:0;border-top:1px solid color-mix(in srgb, currentColor 25%, transparent);margin:1em 0}.efe-page hr.ProseMirror-selectednode{border-top-color:var(--efe-page-accent)}.efe-page a{color:var(--efe-page-accent);text-decoration:underline}.efe-toolbar{background:var(--efe-surface-raised);border:1px solid var(--efe-border);border-radius:calc(var(--efe-radius) * 2);color:var(--efe-text);flex-wrap:wrap;align-items:center;gap:6px;padding:6px;font-size:.875rem;line-height:1.2;display:flex}.efe-icon{fill:none;stroke:currentColor;stroke-width:1.6px;stroke-linecap:round;stroke-linejoin:round;flex:none;width:18px;height:18px}.efe-icon--fa{text-align:center;height:auto;font-size:15px;line-height:1}.efe-toolbar__divider{display:none}.efe-toolbar__group{background:var(--_fill-2);border-radius:calc(var(--efe-radius) + 2px);align-items:center;gap:2px;padding:2px;display:inline-flex}.efe-btn{min-width:30px;height:30px;color:var(--efe-text-muted);border-radius:var(--efe-radius);font:inherit;cursor:pointer;transition:background-color .16s var(--_ease), color .16s var(--_ease), transform .12s var(--_ease);background:0 0;border:0;justify-content:center;align-items:center;gap:4px;margin:0;padding:0 6px;line-height:1;display:inline-flex;position:relative}.efe-btn:hover:not(:disabled){background:var(--_hover);color:var(--efe-text)}.efe-btn:active:not(:disabled){transform:scale(.92)}.efe-btn:after{content:"";background:var(--efe-accent);width:14px;height:2px;transition:transform .22s var(--_spring);pointer-events:none;border-radius:1px;margin-left:-7px;position:absolute;bottom:2px;left:50%;transform:scaleX(0)}.efe-btn.is-active{color:var(--efe-text)}.efe-btn.is-active:after{transform:scaleX(1)}.efe-btn:disabled{opacity:.35;cursor:default}.efe-btn:focus-visible,.efe-dropdown__item:focus-visible{outline:2px solid var(--_focus);outline-offset:-2px}.efe-btn--labelled{white-space:nowrap;padding:0 8px;font-size:.8125rem}.efe-btn--dropdown{padding:0 4px 0 6px}.efe-btn--dropdown>.efe-icon:last-child{stroke-width:2px;opacity:.7;width:12px;height:12px;transition:transform .22s var(--_ease)}.efe-btn--dropdown[aria-expanded=true]>.efe-icon:last-child{transform:rotate(180deg)}.efe-btn--heading{width:8.5rem;color:var(--efe-text);justify-content:space-between;padding-left:8px;font-weight:500}.efe-btn__text{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.efe-dropdown{display:inline-flex;position:relative}.efe-dropdown__menu{z-index:20;background:var(--efe-bubble-bg);min-width:12rem;color:var(--efe-text);border:1px solid var(--efe-border);border-radius:calc(var(--efe-radius) + 4px);box-shadow:var(--efe-shadow);transform-origin:0 0;flex-direction:column;gap:1px;padding:5px;display:flex;position:absolute;top:calc(100% + 6px);left:0}.efe-dropdown__menu[hidden]{display:none}.efe-dropdown__menu[data-state=open]{animation:efe-fade-in .16s var(--_ease) both, efe-drop-in .22s var(--_spring) both}.efe-dropdown__menu[data-state=closed]{pointer-events:none;animation:.12s ease-in both efe-drop-out}.efe-dropdown__item{min-height:30px;color:inherit;border-radius:var(--efe-radius);font:inherit;text-align:left;white-space:nowrap;cursor:pointer;transition:background-color .12s var(--_ease), color .12s var(--_ease);background:0 0;border:0;align-items:center;gap:8px;padding:6px 10px;display:flex}.efe-dropdown__item:hover:not(:disabled){background:var(--_hover)}.efe-dropdown__item[aria-checked=true]{background:var(--_accent-soft);color:var(--efe-accent)}.efe-dropdown__item:disabled{opacity:.4;cursor:default}.efe-dropdown__menu--heading,.efe-dropdown__menu--styles{min-width:13rem}.efe-dropdown__label{opacity:.6;padding:8px 10px 2px;font-size:11px;font-weight:600}.efe-dropdown__item--h1{font-size:1.5em;font-weight:700}.efe-dropdown__item--h2{font-size:1.3em;font-weight:700}.efe-dropdown__item--h3{font-size:1.12em;font-weight:700}.efe-bubble,.efe-balloon{z-index:30;background:var(--efe-bubble-bg);color:var(--efe-text);border:1px solid var(--efe-border);border-radius:calc(var(--efe-radius) + 5px);box-shadow:var(--efe-shadow);text-align:left;font-family:inherit;font-size:.875rem;font-style:normal;font-weight:400;line-height:1.2;position:absolute}.efe-bubble{transform-origin:bottom;gap:2px;padding:4px;display:flex}.efe-bubble[data-state=open]{animation:efe-fade-in .16s var(--_ease) both, efe-rise-in .26s var(--_spring) both}.efe-bubble[data-state=closed]{pointer-events:none;animation:.12s ease-in both efe-rise-out}.efe-bubble:focus{outline:none}.efe-balloon{transform-origin:top;gap:6px;width:max-content;max-width:calc(100vw - 16px);padding:8px;display:grid}.efe-balloon[data-state=open]{animation:efe-fade-in .16s var(--_ease) both, efe-drop-in .26s var(--_spring) both}.efe-balloon[data-state=closed]{pointer-events:none;animation:.12s ease-in both efe-drop-out}.efe-balloon__label{color:var(--efe-text-muted);font-size:.75rem}.efe-balloon__row{align-items:center;gap:4px;display:flex}.efe-balloon__input{box-sizing:border-box;background:var(--efe-surface);width:16rem;min-width:0;height:30px;color:var(--efe-text);border:1px solid var(--efe-border);border-radius:var(--efe-radius);font:inherit;transition:border-color .16s var(--_ease), box-shadow .16s var(--_ease);flex:auto;margin:0;padding:0 9px}.efe-balloon__input:focus{border-color:var(--_focus);box-shadow:0 0 0 3px var(--_accent-soft);outline:none}.efe-balloon__input[aria-invalid=true]{border-color:var(--efe-danger,#c0392b);box-shadow:0 0 0 3px color-mix(in srgb, var(--efe-danger,#c0392b) 18%, transparent)}.efe-btn--primary,.efe-btn--primary:hover:not(:disabled){color:var(--efe-accent)}.efe-balloon__error{color:var(--efe-danger,#c0392b);font-size:.75rem}.efe-balloon__error[hidden],.efe-btn[hidden]{display:none}@keyframes efe-fade-in{0%{opacity:0}}@keyframes efe-drop-in{0%{transform:translateY(-5px)scale(.97)}}@keyframes efe-rise-in{0%{transform:translateY(5px)scale(.97)}}@keyframes efe-drop-out{to{opacity:0;transform:translateY(-4px)scale(.97)}}@keyframes efe-rise-out{to{opacity:0;transform:translateY(4px)scale(.97)}}@media (width<=480px){.efe-balloon__input{width:auto}}@media (prefers-reduced-motion:reduce){.efe-frame,.efe-btn,.efe-btn:after,.efe-btn--dropdown>.efe-icon:last-child,.efe-dropdown__item,.efe-dropdown__menu,.efe-bubble,.efe-balloon,.efe-balloon__input,.efe-dropdown__menu[data-state],.efe-bubble[data-state],.efe-balloon[data-state]{transition:none;animation:none}.efe-btn:active:not(:disabled){transform:none}}.efe-variable{cursor:default;-webkit-box-decoration-break:clone;box-decoration-break:clone;border-radius:.3em}.efe-variable--filled{-webkit-text-decoration:underline dotted color-mix(in srgb, var(--efe-page-accent,#2563eb) 55%, transparent);text-decoration:underline dotted color-mix(in srgb, var(--efe-page-accent,#2563eb) 55%, transparent);text-underline-offset:.2em;text-decoration-thickness:1px}.efe-variable--filled:hover{background:color-mix(in srgb, var(--efe-page-accent,#2563eb) 8%, transparent)}.efe-variable--placeholder,.efe-variable--missing,.efe-variable--unknown{white-space:nowrap;vertical-align:baseline;margin:0 .05em;padding:0 .45em;font-size:.88em;line-height:1.5;display:inline-block}.efe-variable--placeholder{background:color-mix(in srgb, var(--efe-page-accent,#2563eb) 10%, transparent);border:1px solid color-mix(in srgb, var(--efe-page-accent,#2563eb) 35%, transparent);color:var(--efe-page-accent,#2563eb)}.efe-variable--missing{background:var(--efe-missing-bg,#fff4e0);border:1px dashed var(--efe-missing-border,#d9822b);color:var(--efe-missing-text,#8a4b08)}.efe-variable--missing:before{content:attr(data-efe-missing);font-weight:600}.efe-variable--unknown{background:var(--efe-unknown-bg,#fdecec);border:1px dashed var(--efe-unknown-border,#c0392b);color:var(--efe-unknown-text,#9b2c22);font-family:ui-monospace,monospace}.efe-variable.is-selected{outline:2px solid var(--efe-page-accent,#2563eb);outline-offset:1px}.efe-variable.is-flagged,.efe-field.is-flagged .efe-field__input{animation:1.6s ease-out efe-flag}@keyframes efe-flag{0%,40%{box-shadow:0 0 0 3px color-mix(in srgb, var(--efe-page-accent,#2563eb) 45%, transparent)}to{box-shadow:0 0 0 3px #0000}}.efe-image{vertical-align:middle;max-width:100%}.efe-figure{margin:0 0 .75em}.efe-figure img{max-width:100%;height:auto;display:block}.efe-image.ProseMirror-selectednode,.efe-figure.ProseMirror-selectednode img{outline:2px solid var(--efe-page-accent,#2563eb);outline-offset:1px}.efe-callout{--_tone:var(--efe-callout-note,#2563eb);border-left:3px solid var(--_tone);border-radius:var(--efe-radius);background:color-mix(in srgb, var(--_tone) 10%, transparent);margin:.75em 0;padding:.6em .9em}.efe-callout--important{--_tone:var(--efe-callout-important,#d97706)}.efe-callout--tip{--_tone:var(--efe-callout-tip,#16a34a)}.efe-callout:before{content:attr(aria-label);color:var(--_tone);font-size:.875em;font-weight:600;display:block}.efe-callout>:first-child{margin-top:.2em}.efe-callout>:last-child{margin-bottom:0}.efe-video{aspect-ratio:16/9;border-radius:var(--efe-radius);color:#e5e7eb;background:#0b0b0d;place-items:center;max-width:100%;margin:.75em 0;display:grid;position:relative;overflow:hidden}.efe-video__play{cursor:pointer;background:var(--efe-page-accent,#2563eb);border:0;border-radius:50%;width:56px;height:56px;padding:0;position:relative}.efe-video__play:after{content:"";border:10px solid #0000;border-left:17px solid #fff;border-right-width:0;width:0;height:0;margin:auto;position:absolute;inset:0;transform:translate(2px)}.efe-video__note{color:#d1d5db;background:linear-gradient(#0000,#0009);padding:.5em .9em;font-size:.8125rem;position:absolute;bottom:0;left:0;right:0}.efe-video.ProseMirror-selectednode{outline:2px solid var(--efe-page-accent,#2563eb);outline-offset:1px}.efe-suggest{background:var(--efe-bubble-bg);min-width:16rem;max-height:16rem;color:var(--efe-text);border:1px solid var(--efe-border);border-radius:calc(var(--efe-radius) + 4px);box-shadow:var(--efe-shadow);z-index:30;flex-direction:column;padding:5px;font-size:.875rem;display:flex;overflow-y:auto}.efe-suggest__item{color:inherit;border-radius:var(--efe-radius);font:inherit;text-align:left;cursor:pointer;background:0 0;border:none;padding:6px 10px}.efe-suggest__item:hover{background:var(--_hover)}.efe-suggest__item.is-active{background:var(--_accent-soft);color:var(--efe-accent)}.efe-suggest__empty{color:var(--efe-text-muted);padding:6px 10px}.efe-page .efe-field{display:inline}.efe-page .efe-field__input{border-bottom:1px solid var(--efe-field-border,#9aa3b2);cursor:text;background:0 0;border-radius:.2em .2em 0 0;outline:none;min-width:6ch;padding:0 .2em;display:inline-block}.efe-page .efe-field--empty .efe-field__input,.efe-page .efe-field__input:hover{background:var(--efe-field-bg,color-mix(in srgb, var(--efe-page-accent) 7%, transparent))}.efe-page .efe-field__input:focus{border-bottom-color:var(--efe-page-accent);background:var(--efe-field-bg-focus,color-mix(in srgb, var(--efe-page-accent) 14%, transparent))}.efe-page .efe-field--empty .efe-field__input:before{content:attr(data-efe-placeholder);color:var(--efe-placeholder,#8a8a8a)}.efe-page .efe-field--required.efe-field--empty .efe-field__input{border-bottom-color:var(--efe-field-required,#d9822b);background:var(--efe-missing-bg,#fff4e0)}.efe-page .efe-field--required.efe-field--empty .efe-field__input:after{content:" *";color:var(--efe-field-required,#d9822b);font-weight:600}.efe-page select.efe-field__input{appearance:none;color:inherit;font:inherit;cursor:pointer;border-top:0;border-left:0;border-right:0;margin:0;padding-right:1.1em}.efe-page .efe-field--empty select.efe-field__input{color:var(--efe-placeholder,#8a8a8a)}.efe-page select.efe-field__input option{color:canvastext}.efe-page select.efe-field__input:disabled{opacity:1;cursor:default}.efe-page .efe-field--select{position:relative}.efe-page .efe-field--select:after{content:"▾";color:var(--efe-placeholder,#8a8a8a);pointer-events:none;position:absolute;right:.25em}.efe-section{border-radius:.25em;margin:0 0 1em;padding:0;transition:background-color .15s;position:relative}.efe-section:before{content:"";background:0 0;border-radius:1px;width:2px;transition:background-color .15s;position:absolute;top:.1em;bottom:.1em;left:-.9rem}.efe-section--locked:before{background:var(--efe-section-locked-rule,#c2c8d2)}.efe-section--locked:hover{background:var(--efe-section-locked-hover,#64748b0f)}.efe-section--free:focus-within:before{background:var(--efe-page-accent,#2563eb)}.efe-section.is-nudged{background:var(--efe-section-nudge,#d9822b1f)}.efe-section.is-nudged:before{background:var(--efe-field-required,#d9822b)}.efe-section__head{letter-spacing:.04em;text-transform:uppercase;color:var(--efe-placeholder,#8a8a8a);-webkit-user-select:none;user-select:none;align-items:center;gap:.4em;margin:0 0 .3em;font-size:.72rem;line-height:1.2;display:flex}.efe-section__head[hidden],.efe-section__repeat[hidden]{display:none}.efe-section__lock{color:var(--efe-section-locked-icon,#8a93a3);display:inline-flex}.efe-section__lock .efe-icon{width:.95rem;height:.95rem}.efe-section__title{font-weight:600}.efe-section__badge{letter-spacing:.03em;background:color-mix(in srgb, var(--efe-page-accent) 12%, transparent);color:var(--efe-page-accent);border-radius:.6em;padding:.05em .5em;font-size:.95em;font-weight:600;display:inline-block}.efe-section--free .efe-section__badge:first-child,.efe-section__badge--repeat{color:#4b5563;background:#6b728024}.efe-section__content>:last-child{margin-bottom:0}.efe-page .efe-section--free .efe-section__content>p:only-child:has(>br.ProseMirror-trailingBreak:only-child):before{content:var(--efe-hint,"");float:left;height:0;color:var(--efe-placeholder,#8a8a8a);pointer-events:none}.efe-section__repeat{-webkit-user-select:none;user-select:none;gap:.5em;margin-top:.4em;font-size:.8rem;display:flex}.efe-section__repeat-btn{border:1px dashed color-mix(in srgb, var(--efe-page-text,#1f2430) 30%, transparent);color:color-mix(in srgb, var(--efe-page-text,#1f2430) 70%, transparent);font:inherit;cursor:pointer;background:0 0;border-radius:.4em;align-items:center;gap:.35em;padding:.2em .6em;display:inline-flex}.efe-section__repeat-btn:hover,.efe-section__repeat-btn:focus-visible{border-color:var(--efe-page-accent,#2563eb);color:var(--efe-page-accent,#2563eb)}.efe-section__repeat-btn .efe-icon{width:.9rem;height:.9rem}.efe-page--preview .efe-section__head,.efe-page--preview .efe-section__repeat{display:none}.efe-page--preview .efe-section:before{content:none}.efe-page--preview .efe-section,.efe-page--preview .efe-section:hover{background:0 0}.efe-page--preview .efe-variable--filled,.efe-page--preview .efe-variable--filled:hover{background:0 0;text-decoration:none}.efe-page--preview .efe-field__input,.efe-page--preview .efe-field__input:hover{cursor:default;background:0 0;border:0;min-width:0;padding:0}.efe-page--preview .efe-field--empty .efe-field__input:before,.efe-page--preview .efe-field--select:after{content:none}.efe-page--preview select.efe-field__input{pointer-events:none;padding-right:0}.efe-page--preview .efe-field--required.efe-field--empty .efe-field__input{border-bottom:1px dashed var(--efe-field-required,#d9822b);background:0 0;min-width:6ch;display:inline-block}.efe-page--preview .efe-field--required.efe-field--empty .efe-field__input:after,.efe-page--preview .efe-section--free .efe-section__content>p:only-child:before{content:none}.efe-page-break{cursor:default;-webkit-user-select:none;user-select:none;justify-content:center;align-items:center;height:1.4em;margin:1em 0;display:flex;position:relative}.efe-page-break:before{content:"";z-index:0;border-top:1px dashed color-mix(in srgb, currentColor 30%, transparent);position:absolute;top:50%;left:0;right:0}.efe-page-break:after{content:"Seitenumbruch";z-index:1;background:var(--efe-page-bg,#fff);color:color-mix(in srgb, currentColor 55%, transparent);letter-spacing:.02em;white-space:nowrap;flex-shrink:0;padding:0 .75em;font-size:.75em;position:relative}.efe-page-break.ProseMirror-selectednode:before{border-top-color:var(--efe-page-accent)}.efe-page-gap{box-sizing:border-box;width:var(--efe-page-width);border-top:1px solid var(--efe-page-gap-border,color-mix(in srgb, var(--efe-surround-bg) 85%, #000));border-bottom:1px solid var(--efe-page-gap-border,color-mix(in srgb, var(--efe-surround-bg) 85%, #000));background:var(--efe-page-gap-bg,var(--efe-surround-bg));pointer-events:none;-webkit-user-select:none;user-select:none;margin-left:50%;position:relative;transform:translate(-50%)}.efe-page-gap__nummer{background:var(--efe-page-bg,#fff);color:color-mix(in srgb, currentColor 55%, transparent);letter-spacing:.02em;opacity:.6;padding:0 .3em;font-size:.7em;position:absolute;top:0;right:20mm;transform:translateY(-100%)}@media print{.efe-page-break{page-break-after:always;break-after:page;border:none;height:0;margin:0}.efe-page-break:before,.efe-page-break:after{content:none}.efe-toolbar,.efe-bubble,.efe-balloon,.efe-page-gap,.efe-section__head,.efe-section__repeat,.efe-section__badge,.efe-section__lock,.efe-section__title,.efe-suggest{display:none!important}.efe-section,.efe-section:hover{background:0 0!important}.efe-section:before{content:none!important}.efe-variable--filled{background:0 0!important;text-decoration:none!important}.efe-variable--missing,.efe-variable--unknown,.efe-variable--placeholder{display:none!important}.efe-field,.efe-field__input{background:0 0!important;border:0!important;min-width:0!important;padding:0!important;display:inline!important}.efe-field--empty .efe-field__input:before,.efe-field--empty .efe-field__input:after,.efe-field--select:after,.efe-section__content>p:only-child:before{content:none!important}}.efe-page{--_input-tint:var(--efe-input-tint,color-mix(in srgb, var(--efe-page-accent,#2563eb) 7%, transparent));--_input-line:var(--efe-input-line,color-mix(in srgb, var(--efe-page-accent,#2563eb) 50%, transparent));--_input-text:var(--efe-input-text,var(--efe-page-accent,#2563eb));--_fixed-tint:var(--efe-fixed-tint,color-mix(in srgb, currentColor 6%, transparent));--_fixed-line:var(--efe-fixed-line,color-mix(in srgb, currentColor 40%, transparent))}.efe-input,.efe-repeat,.efe-optional{margin:0 0 .75em;position:relative}.efe-input{background:var(--_input-tint);box-shadow:inset 0 0 0 1px var(--_input-line);border-radius:.3em;padding:.5em .65em;display:flow-root}.efe-input:focus-within{box-shadow:inset 0 0 0 1.5px var(--_input-text), 0 0 0 3px color-mix(in srgb, var(--_input-text) 18%, transparent)}.efe-block__head{-webkit-user-select:none;user-select:none;align-items:center;gap:.4em;margin:0 0 .25em;font-size:.72rem;line-height:1.2;display:flex}.efe-block__head[hidden]{display:none}.efe-block__label{color:var(--_input-text);font-weight:600}.efe-block__badge{letter-spacing:.03em;color:var(--efe-text-muted,#5f6672);background:color-mix(in srgb, currentColor 8%, transparent);border-radius:.25em;padding:.05em .4em;font-size:.68rem}.efe-input__body>p:only-child:empty:before,.efe-input.is-empty .efe-input__body>p:first-child:before{content:var(--efe-placeholder,"");color:var(--efe-text-muted,#5f6672);pointer-events:none;font-style:italic}.efe-input.is-locked{background:var(--_fixed-tint);box-shadow:inset 0 0 0 1px var(--_fixed-line)}.efe-input__choice{font:inherit;margin:0 0 .35em}.efe-input__snippet-text{white-space:pre-line;margin:0}.efe-input__snippet-more{color:var(--_input-text);margin-top:.3em;font-size:.75rem}.efe-fixed{background:repeating-linear-gradient(135deg, var(--_fixed-tint) 0 4px, transparent 4px 8px);box-shadow:inset 0 0 0 1px var(--_fixed-line);border-radius:.25em;margin:.25em 0 .6em;padding:.35em .6em;position:relative}.efe-fixed__head{background:var(--efe-page-bg,#fff);margin:0;padding:0 .3em;position:absolute;top:-.7em;right:.6em}.efe-aside{margin:0 0 .75em 1.25em;padding:.6em;position:relative}.efe-aside--left{margin:0 1.25em .75em 0}.efe-aside--framed{border:1px solid}.efe-repeat,.efe-optional{border-left:2px solid var(--_input-line);padding-left:.6em}.efe-block__btn{border:1px solid var(--efe-border,#c9ced6);background:var(--efe-surface,#fff);color:var(--efe-text,inherit);font:inherit;cursor:pointer;border-radius:.3em;align-items:center;gap:.25em;padding:.1em .45em;display:inline-flex}.efe-optional.is-off>.efe-optional__body{display:none}.efe-optional.is-off{opacity:.7}.efe-prompt{color:var(--efe-text-muted,#5f6672);font-style:italic}.efe-is-fixed.is-nudged,.efe-input.is-nudged{animation:.45s efe-nudge}.efe-field--locked{opacity:.65}@keyframes efe-nudge{0%,to{transform:none}20%{transform:translate(-3px)}45%{transform:translate(3px)}70%{transform:translate(-1.5px)}}@media (prefers-reduced-motion:reduce){.efe-is-fixed.is-nudged,.efe-input.is-nudged{animation:none}}.efe-page--preview .efe-input,.efe-page--preview .efe-fixed,.efe-page--preview .efe-repeat,.efe-page--preview .efe-optional{box-shadow:none;background:0 0;border:0;padding:0}.efe-page--preview .efe-block__head,.efe-page--preview .efe-prompt,.efe-page--preview .efe-optional.is-off{display:none}.efe-page--layout{position:relative}.efe-band-replica{height:var(--efe-band-height);opacity:.72;pointer-events:none;-webkit-user-select:none;user-select:none;font-size:.85em;position:absolute;overflow:hidden}.efe-page>.efe-band-replica--head{top:var(--efe-band-distance)}.efe-page>.efe-band-replica--foot{bottom:var(--efe-band-distance);flex-direction:column;justify-content:flex-end;display:flex}.efe-band-replica p{margin:0}.efe-band-replica table{border-collapse:collapse;width:100%}.efe-page-gap--bands{background:0 0;border:0;flex-direction:column;display:flex}.efe-page-gap__margin{background:var(--efe-page-bg);position:relative}.efe-page-gap__margin .efe-band-replica--head{top:var(--efe-band-distance)}.efe-page-gap__margin .efe-band-replica--foot{bottom:var(--efe-band-distance);flex-direction:column;justify-content:flex-end;display:flex}.efe-page-gap__space{background:var(--efe-page-gap-bg,var(--efe-surround-bg));border-top:1px solid var(--efe-page-gap-border,color-mix(in srgb, var(--efe-surround-bg) 85%, #000));border-bottom:1px solid var(--efe-page-gap-border,color-mix(in srgb, var(--efe-surround-bg) 85%, #000))}.efe-page-gap--bands .efe-page-gap__nummer{top:auto;bottom:2mm;transform:none}.efe-docedit{flex-direction:column;gap:0;min-width:0;display:flex}.efe-docedit__toolbar{flex-wrap:wrap;align-items:center;gap:6px;display:flex}.efe-docedit__tools[hidden],.efe-docedit__bar[hidden]{display:none}.efe-docedit__tools,.efe-docedit__format,.efe-docedit__bar{flex-wrap:wrap;align-items:center;gap:6px;display:flex}.efe-btn--text{white-space:nowrap;width:auto;padding:0 10px}.efe-docedit__menu .efe-dropdown__menu{min-width:240px}.efe-docedit__menu .efe-dropdown__item{text-align:left;gap:1px;display:grid}.efe-docedit__menu .efe-dropdown__item small{color:var(--efe-text-muted);font-size:.75rem}.efe-docedit__layout{grid-template-columns:minmax(0,1fr) 320px;align-items:start;display:grid}.efe-docedit__sheet{flex-direction:column;align-items:center;min-width:0;display:flex;overflow-x:auto}.efe-docedit__page{position:relative}.efe-docedit__sheet>*{zoom:var(--efe-sheet-zoom,1)}@media (width<=960px){.efe-docedit__layout{grid-template-columns:minmax(0,1fr)}}.efe-ruler{background:var(--efe-surface-raised,#fff);height:22px;box-shadow:0 0 0 1px var(--efe-border);-webkit-user-select:none;user-select:none;touch-action:none;border-radius:4px 4px 0 0;flex:none;margin:0 auto;position:relative}.efe-ruler[hidden]{display:none}.efe-ruler__ticks{background:repeating-linear-gradient(to right, color-mix(in srgb, var(--efe-text) 55%, transparent) 0 1px, transparent 1px 10mm) 0 100% / 100% 9px no-repeat, repeating-linear-gradient(to right, color-mix(in srgb, var(--efe-text) 35%, transparent) 0 1px, transparent 1px 5mm) 0 100% / 100% 6px no-repeat, repeating-linear-gradient(to right, color-mix(in srgb, var(--efe-text) 18%, transparent) 0 1px, transparent 1px 1mm) 0 100% / 100% 3px no-repeat;position:absolute;inset:0}.efe-ruler__off{background:repeating-linear-gradient(135deg, color-mix(in srgb, var(--efe-text) 8%, transparent) 0 3px, transparent 3px 6px);position:absolute;top:0;bottom:0}.efe-ruler__num{color:var(--efe-text-muted);font-size:9px;line-height:10px;position:absolute;top:1px;transform:translate(-50%)}.efe-ruler__handle{cursor:ew-resize;place-items:end center;width:14px;height:22px;margin-left:-7px;display:grid;position:absolute;top:0}.efe-ruler__handle:after{content:"";border-left:6px solid #0000;border-right:6px solid #0000;border-top:9px solid var(--efe-accent)}.efe-ruler__handle:focus-visible{outline:2px solid var(--_focus);outline-offset:1px}.efe-ruler__tip{z-index:5;background:var(--efe-text);color:var(--efe-surface,#fff);white-space:nowrap;pointer-events:none;border-radius:4px;padding:2px 6px;font-size:11px;position:absolute;top:26px;transform:translate(-50%)}.efe-band-slot{z-index:2;position:absolute}.efe-docedit[data-mode=template] .efe-band-slot{outline:1px dashed color-mix(in srgb, var(--efe-page-text) 25%, transparent);outline-offset:2mm}.efe-band-slot.is-overflow{outline:1.5px dashed #d97706}.efe-band-slot__editor .ProseMirror{min-height:1.2em}.efe-band-slot__editor .ProseMirror p{margin:0}.efe-docedit[data-mode=template] .efe-band-slot__editor{max-height:none}.efe-docedit:not([data-mode=template]) .efe-band-slot__editor{max-height:var(--efe-band-limit);overflow:hidden}.efe-band-slot__editor[hidden]{display:none}.efe-band-slot__tabs{white-space:nowrap;gap:4px;font-size:11px;display:flex;position:absolute;bottom:calc(100% + 2mm);left:0}.efe-band-slot--foot .efe-band-slot__tabs{top:calc(100% + 2mm);bottom:auto}.efe-band-slot__tab,.efe-band-slot__add{border:1px solid var(--efe-border);background:var(--efe-surface,#fff);color:var(--efe-text);font:inherit;cursor:pointer;border-radius:999px;padding:1px 8px;font-size:11px}.efe-band-slot__tab[aria-pressed=true]{border-color:var(--efe-accent);color:var(--efe-accent)}.efe-band-slot__label,.efe-band-slot__note{color:var(--efe-text-muted)}.efe-docedit__panel{border-left:1px solid var(--efe-border);background:var(--efe-surface,#fff);color:var(--efe-text);align-content:start;gap:14px;min-width:0;padding:16px;font-size:13px;line-height:1.45;display:grid}.efe-prop__kicker{letter-spacing:.06em;text-transform:uppercase;color:var(--efe-text-muted);margin:0;font-size:11px}.efe-prop__title{margin:2px 0 0;font-size:15px;font-weight:600}.efe-prop{gap:5px;display:grid}.efe-prop__label{color:var(--efe-text-muted);font-size:12px;font-weight:500}.efe-prop__input{box-sizing:border-box;border:1px solid var(--efe-border);background:var(--efe-surface-raised,#fff);width:100%;color:var(--efe-text);font:inherit;border-radius:6px;padding:6px 8px}.efe-prop__input:focus-visible,.efe-prop__btn:focus-visible,.efe-prop__seg button:focus-visible{outline:2px solid var(--_focus);outline-offset:1px}.efe-prop__area{resize:vertical;min-height:72px}.efe-prop__grid{grid-template-columns:repeat(4,minmax(0,1fr));gap:8px;display:grid}.efe-prop__grid--2{grid-template-columns:repeat(2,minmax(0,1fr))}.efe-prop__hint,.efe-prop__note{color:var(--efe-text-muted);margin:0;font-size:12.5px}.efe-prop__note{background:color-mix(in srgb, var(--efe-text) 5%, transparent);border-radius:8px;padding:8px 10px}.efe-prop__note--warn{color:var(--efe-text);background:#f59e0b29;gap:8px;display:grid}.efe-prop__note--warn p{margin:0}.efe-prop__note--ok{color:var(--efe-text);background:#16a34a1f}.efe-prop__check{cursor:pointer;align-items:flex-start;gap:8px;display:flex}.efe-prop__check input{accent-color:var(--efe-accent);margin-top:3px}.efe-prop__seg{border:1px solid var(--efe-border);border-radius:999px;gap:2px;width:fit-content;padding:2px;display:inline-flex}.efe-prop__seg button{color:var(--efe-text-muted);font:inherit;cursor:pointer;background:0 0;border:0;border-radius:999px;padding:3px 12px}.efe-prop__seg button[aria-pressed=true]{background:var(--_accent-soft,color-mix(in srgb, var(--efe-accent) 14%, transparent));color:var(--efe-text)}.efe-prop__btn{border:1px solid var(--efe-border);background:var(--efe-surface-raised,#fff);color:var(--efe-text);font:inherit;cursor:pointer;border-radius:6px;justify-self:start;padding:6px 12px}.efe-prop__btn--primary{background:var(--efe-accent);color:#fff;border-color:#0000}.efe-prop__btn--danger{color:#dc2626}.efe-prop__row{align-items:center;gap:8px;display:flex}.efe-prop__range{accent-color:var(--efe-accent);flex:1}.efe-prop__code{margin:0;font-family:ui-monospace,monospace;font-size:12px}.efe-prop__open{gap:4px;display:grid}.efe-prop__open-item{text-align:left;border:1px solid var(--efe-border);background:var(--efe-surface-raised,#fff);color:var(--efe-text);font:inherit;cursor:pointer;border-radius:6px;gap:1px;padding:7px 10px;display:grid}.efe-prop__open-item small{color:#b45309}.efe-prop__summary p{margin:0}.efe-docedit__bubble{z-index:40;background:var(--efe-bubble-bg,var(--efe-surface-raised,#fff));box-shadow:0 0 0 1px var(--efe-border), 0 8px 24px -6px #00000040;border-radius:10px;gap:4px;padding:4px;display:flex;position:fixed}.efe-docedit__bubble[hidden]{display:none}.efe-emoji{--_emoji-font:var(--efe-emoji-font,"Noto Color Emoji", "Apple Color Emoji", "Segoe UI Emoji", sans-serif);gap:8px;width:21.5rem;padding:10px}.efe-emoji .efe-balloon__input{width:auto}.efe-emoji__tone,.efe-emoji__cell,.efe-emoji__tab,.efe-emoji__preview,.efe-suggest__glyph{font-family:var(--_emoji-font,var(--efe-emoji-font,"Noto Color Emoji", "Apple Color Emoji", "Segoe UI Emoji", sans-serif));font-style:normal;font-weight:400}.efe-emoji__tone{font-size:1.05rem}.efe-emoji__tones{background:var(--_fill-1);border-radius:var(--efe-radius);gap:2px;padding:4px;display:flex}.efe-emoji__tones[hidden]{display:none}.efe-emoji__tones .efe-emoji__cell[aria-checked=true]{background:var(--_accent-soft);box-shadow:inset 0 0 0 1px var(--efe-accent)}.efe-emoji__tabs{border-bottom:1px solid var(--efe-border);gap:2px;padding-bottom:6px;display:flex}.efe-emoji__tab{height:30px;color:var(--efe-text-muted);border-radius:var(--efe-radius);cursor:pointer;filter:grayscale();opacity:.7;transition:background-color .12s var(--_ease), opacity .12s var(--_ease), filter .12s var(--_ease);background:0 0;border:none;flex:1 1 0;place-items:center;padding:0;font-size:1.05rem;line-height:1;display:grid;position:relative}.efe-emoji__tab[hidden]{display:none}.efe-emoji__tab:hover,.efe-emoji__tab[aria-selected=true]{filter:none;opacity:1}.efe-emoji__tab:hover{background:var(--_hover)}.efe-emoji__tab[aria-selected=true]:after{content:"";background:var(--efe-accent);border-radius:2px;height:2px;position:absolute;bottom:-7px;left:25%;right:25%}.efe-emoji__tab .efe-icon{width:16px;height:16px}.efe-emoji__body{overscroll-behavior:contain;scrollbar-width:thin;height:15.5rem;margin:0 -4px;padding:0 4px;overflow-y:auto}.efe-emoji__section+.efe-emoji__section{margin-top:6px}.efe-emoji__title{z-index:1;background:var(--efe-bubble-bg);color:var(--efe-text-muted);letter-spacing:.02em;margin:0;padding:6px 2px 4px;font-size:.7rem;font-weight:600;position:sticky;top:0}.efe-emoji__grid{grid-template-columns:repeat(9,1fr);display:grid}.efe-emoji__cell{aspect-ratio:1;border-radius:var(--efe-radius);cursor:pointer;min-width:0;transition:background-color .1s var(--_ease);background:0 0;border:none;place-items:center;padding:0;font-size:1.35rem;line-height:1;display:grid}.efe-emoji__cell:hover,.efe-emoji__cell:focus-visible{background:var(--_hover);outline:none}.efe-emoji__cell:focus-visible{box-shadow:inset 0 0 0 2px var(--_focus)}.efe-emoji__empty{color:var(--efe-text-muted);text-align:center;margin:0;padding:2.5rem 0}.efe-emoji__footer{border-top:1px solid var(--efe-border);min-height:28px;color:var(--efe-text-muted);align-items:center;gap:8px;padding-top:6px;font-size:.75rem;display:flex}.efe-emoji__preview{font-size:1.4rem;line-height:1}.efe-emoji__footer .efe-emoji__preview+span{color:var(--efe-text);font-size:.8125rem}.efe-suggest__item--emoji{align-items:center;gap:8px;display:flex}.efe-suggest__glyph{font-size:1.15rem;line-height:1}@media (prefers-reduced-motion:reduce){.efe-emoji__tab,.efe-emoji__cell{transition:none}}@media (width<=480px){.efe-emoji{width:calc(100vw - 16px)}} /*$vite$:1*/ \ No newline at end of file diff --git a/public/assets/dist/editor.iife.js b/public/assets/dist/editor.iife.js index d4f6b04e..494ba595 100644 --- a/public/assets/dist/editor.iife.js +++ b/public/assets/dist/editor.iife.js @@ -3,25 +3,25 @@ var EmergencyForgeEditor=(function(e){Object.defineProperty(e,Symbol.toStringTag `);else if(a.linebreakReplacement&&/[\r\n]/.test(n)&&this.top.findWrapping(a.linebreakReplacement.create())){let e=n.split(/\r?\n|\r/);for(let n=0;n!n.clearMark(e)):t.concat(this.parser.schema.marks[n.mark].create(n.attrs)),n.consuming===!1)e=n;else break}}return t}addElementByRule(e,t,n,r){let i,a;if(t.node){if(a=this.parser.schema.nodes[t.node],a.isLeaf)this.insertNode(a.create(t.attrs),n,e.nodeName==`BR`)||this.leafFallback(e,n);else{let e=this.enter(a,t.attrs||null,n,t.preserveWhitespace);e&&(i=!0,n=e)}}else{let e=this.parser.schema.marks[t.mark];n=n.concat(e.create(t.attrs))}let o=this.top;if(a&&a.isLeaf)this.findInside(e);else if(r)this.addElement(e,n,r);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(e=>this.insertNode(e,n,!1));else{let r=e;typeof t.contentElement==`string`?r=e.querySelector(t.contentElement):typeof t.contentElement==`function`?r=t.contentElement(e):t.contentElement&&(r=t.contentElement),this.findAround(e,r,!0),this.addAll(r,n),this.findAround(e,r,!1)}i&&this.sync(o)&&this.open--}addAll(e,t,n,r){let i=n||0;for(let a=n?e.childNodes[n]:e.firstChild,o=r==null?null:e.childNodes[r];a!=o;a=a.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(a,t);this.findAtPoint(e,i)}findPlace(e,t,n){let r,i;for(let t=this.open,a=0;t>=0;t--){let o=this.nodes[t],s=o.findWrapping(e);if(s&&(!r||r.length>s.length+a)&&(r=s,i=o,!s.length))break;if(o.solid){if(n)break;a+=2}}if(!r)return null;this.sync(i);for(let e=0;e!(a.type?a.type.allowsMarkType(t.type):qe(t.type,e))||(s=t.addToSet(s),!1)),this.nodes.push(new He(e,t,s,r,null,o)),this.open++,n}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--)if(this.nodes[t]==e)return this.open=t,!0;else this.localPreserveWS&&(this.nodes[t].options|=Re);return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let n=this.nodes[t].content;for(let t=n.length-1;t>=0;t--)e+=n[t].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let n=0;n-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split(`/`),n=this.options.context,r=!this.isOpen&&(!n||n.parent.type==this.nodes[0].type),i=-(n?n.depth+1:0)+ +!r,a=(e,o)=>{for(;e>=0;e--){let s=t[e];if(s==``){if(e==t.length-1||e==0)continue;for(;o>=i;o--)if(a(e-1,o))return!0;return!1}{let e=o>0||o==0&&r?this.nodes[o].type:n&&o>=i?n.node(o-i).type:null;if(!e||e.name!=s&&!e.isInGroup(s))return!1;o--}}return!0};return a(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let n=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(let e in this.parser.schema.nodes){let t=this.parser.schema.nodes[e];if(t.isTextblock&&t.defaultAttrs)return t}}};function We(e){for(let t=e.firstChild,n=null;t;t=t.nextSibling){let e=t.nodeType==1?t.nodeName.toLowerCase():null;e&&Le.hasOwnProperty(e)&&n?(n.appendChild(t),t=n):e==`li`?n=t:e&&(n=null)}}function Ge(e,t){return(e.matches||e.msMatchesSelector||e.webkitMatchesSelector||e.mozMatchesSelector).call(e,t)}function Ke(e){let t={};for(let n in e)t[n]=e[n];return t}function qe(e,t){let n=t.schema.nodes;for(let r in n){let i=n[r];if(!i.allowsMarkType(e))continue;let a=[],o=e=>{a.push(e);for(let n=0;n{if(i.length||e.marks.length){let n=0,a=0;for(;n=0;r--){let i=this.serializeMark(e.marks[r],e.isInline,t);i&&((i.contentDOM||i.dom).appendChild(n),n=i.dom)}return n}serializeMark(e,t,n={}){let r=this.marks[e.type.name];return r&&et(Xe(n),r(e,t),null,e.attrs)}static renderSpec(e,t,n=null,r){return typeof t==`string`?{dom:e.createTextNode(t)}:et(e,t,n,r)}static fromSchema(t){return t.cached.domSerializer||(t.cached.domSerializer=new e(this.nodesFromSchema(t),this.marksFromSchema(t)))}static nodesFromSchema(e){let t=Ye(e.nodes);return t.text||=e=>e.text,t}static marksFromSchema(e){return Ye(e.marks)}};function Ye(e){let t={};for(let n in e){let r=e[n].spec.toDOM;r&&(t[n]=r)}return t}function Xe(e){return e.document||window.document}var Ze=new WeakMap;function Qe(e){let t=Ze.get(e);return t===void 0&&Ze.set(e,t=$e(e)),t}function $e(e){let t=null;function n(e){if(e&&typeof e==`object`){if(Array.isArray(e)){if(typeof e[0]==`string`)t||=[],t.push(e);else for(let t=0;t-1)throw RangeError(`Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.`);let o=i.indexOf(` `);o>0&&(n=i.slice(0,o),i=i.slice(o+1));let s,c=n?e.createElementNS(n,i):e.createElement(i),l=t[1],u=1;if(l&&typeof l==`object`&&l.nodeType==null&&!Array.isArray(l)){u=2;for(let e in l)if(l[e]!=null){let t=e.indexOf(` `);t>0?c.setAttributeNS(e.slice(0,t),e.slice(t+1),l[e]):e==`style`&&c.style?c.style.cssText=l[e]:c.setAttribute(e,l[e])}}for(let i=u;iu)throw RangeError(`Content hole must be the only child of its parent node`);return{dom:c,contentDOM:c}}if(typeof a==`string`)c.appendChild(e.createTextNode(a));else{let{dom:t,contentDOM:i}=et(e,a,n,r);if(c.appendChild(t),i){if(s)throw RangeError(`Multiple content holes`);s=i}}}return{dom:c,contentDOM:s}}var tt=65535,nt=2**16;function rt(e,t){return e+t*nt}function it(e){return e&tt}function at(e){return(e-(e&tt))/nt}var ot=1,st=2,ct=4,lt=8,ut=class{constructor(e,t,n){this.pos=e,this.delInfo=t,this.recover=n}get deleted(){return(this.delInfo<)>0}get deletedBefore(){return(this.delInfo&5)>0}get deletedAfter(){return(this.delInfo&6)>0}get deletedAcross(){return(this.delInfo&ct)>0}},dt=class e{constructor(t,n=!1){if(this.ranges=t,this.inverted=n,!t.length&&e.empty)return e.empty}recover(e){let t=0,n=it(e);if(!this.inverted)for(let e=0;ee)break;let c=this.ranges[o+i],l=this.ranges[o+a],u=s+c;if(e<=u){let i=c?e==s?-1:e==u?1:t:t,a=s+r+(i<0?0:l);if(n)return a;let d=e==(t<0?s:u)?null:rt(o/3,e-s),f=0;return c&&(f|=e==s?st:e==u?ot:ct,(t<0?e!=s:e!=u)&&(f|=lt)),new ut(a,f,d)}r+=l-c}return n?e+r:new ut(e+r,0,null)}touches(e,t){let n=0,r=it(t),i=this.inverted?2:1,a=this.inverted?1:2;for(let t=0;te)break;let s=this.ranges[t+i];if(e<=o+s&&t==r*3)return!0;n+=this.ranges[t+a]-s}return!1}forEach(e){let t=this.inverted?2:1,n=this.inverted?1:2;for(let r=0,i=0;r=0;t--){let r=e.getMirror(t);this.appendMap(e._maps[t].invert(),r!=null&&r>t?n-r-1:void 0)}}invert(){let t=new e;return t.appendMappingInverted(this),t}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let n=this.from;nn&&t!e.isAtom||!t.type.allowsMarkType(this.mark.type)?e:e.mark(this.mark.addToSet(e.marks)),r),t.openStart,t.openEnd);return mt.fromReplace(e,this.from,this.to,i)}invert(t){let n=[];return t.nodesBetween(this.from,this.to,(t,r)=>{if(t.isInline&&t.isAtom){let i=this.mark.addToSet(t.marks);if(!f.sameSet(i,t.marks)){let a=Math.max(this.from,r),o=Math.min(this.to,r+t.nodeSize);vt(_t,a,o,this.mark,n);for(let r of t.marks)r.isInSet(i)||vt(e,a,o,r,n)}}}),n.length==1?n[0]:new yt(n)}map(t){let n=t.map(this.from,1),r=t.map(this.to,-1);return n>=r?null:new e(n,r,this.mark)}merge(t){return t instanceof e&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new e(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:`addMark`,mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for AddMarkStep.fromJSON`);return new e(n.from,n.to,t.markFromJSON(n.mark))}};O.jsonID(`addMark`,gt);var _t=class e extends O{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=new m(ht(t.content,e=>e.mark(this.mark.removeFromSet(e.marks)),e),t.openStart,t.openEnd);return mt.fromReplace(e,this.from,this.to,n)}invert(e){let t=[];return e.nodesBetween(this.from,this.to,(e,n)=>{e.isInline&&e.isAtom&&this.mark.isInSet(e.marks)&&vt(gt,Math.max(this.from,n),Math.min(this.to,n+e.nodeSize),this.mark,t)}),t.length==1?t[0]:new yt(t)}map(t){let n=t.map(this.from,1),r=t.map(this.to,-1);return n>=r?null:new e(n,r,this.mark)}merge(t){return t instanceof e&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new e(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:`removeMark`,mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for RemoveMarkStep.fromJSON`);return new e(n.from,n.to,t.markFromJSON(n.mark))}};O.jsonID(`removeMark`,_t);function vt(e,t,n,r,i){let a=i.length?i[i.length-1]:null;a&&a instanceof e&&a.to==t&&a.mark.eq(r)?i[i.length-1]=new e(a.from,n,r):i.push(new e(t,n,r))}var yt=class e extends O{constructor(e){super(),this.steps=e}apply(e){for(let t of this.steps){let n=t.apply(e);if(!n.doc)return n;e=n.doc}return new mt(e,null)}invert(t){return new e(this.steps.map(e=>e.invert(t)))}map(t){let n=[];for(let e of this.steps){let r=e.map(t);r&&n.push(r)}return n.length?new e(n):null}toJSON(){return{stepType:`markSet`,steps:this.steps.map(e=>e.toJSON())}}static fromJSON(t,n){if(!Array.isArray(n.steps)||!n.steps.every(e=>e.stepType==`addMark`||e.stepType==`removeMark`))throw RangeError(`Invalid JSON for MarkSetStep`);return new e(n.steps.map(e=>O.fromJSON(t,e)))}};O.jsonID(`markSet`,yt);var bt=class e extends O{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return mt.fail(`No node at mark step's position`);let n=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return mt.fromReplace(e,this.pos,this.pos+1,new m(c.from(n),0,+!t.isLeaf))}invert(t){let n=t.nodeAt(this.pos);if(n){let t=this.mark.addToSet(n.marks);if(t.length==n.marks.length){for(let r=0;rr.pos||i>a?null:new e(n.pos,r.pos,i,a,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:`replaceAround`,from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`||typeof n.gapFrom!=`number`||typeof n.gapTo!=`number`||typeof n.insert!=`number`)throw RangeError(`Invalid input for ReplaceAroundStep.fromJSON`);return new e(n.from,n.to,n.gapFrom,n.gapTo,m.fromJSON(t,n.slice),n.insert,!!n.structure)}};O.jsonID(`replaceAround`,Ct);function wt(e,t,n){let r=e.resolve(t),i=n-t,a=r.depth;for(;i>0&&a>0&&r.indexAfter(a)==r.node(a).childCount;)a--,i--;if(i>0){let e=r.node(a).maybeChild(r.indexAfter(a));for(;i>0;){if(!e||e.isLeaf)return!0;e=e.firstChild,i--}}return!1}function Tt(e,t,n,r){let i=[];e.doc.nodesBetween(t,n,(e,a,o)=>{if(!e.isInline)return;let s=e.marks;!r.isInSet(s)&&o.type.allowsMarkType(r.type)&&vt(gt,Math.max(a,t),Math.min(a+e.nodeSize,n),r,i)}),i.forEach(t=>e.step(t))}function Et(e,t,n,r){let i=[],a=0;e.doc.nodesBetween(t,n,(e,o)=>{if(!e.isInline||!e.isAtom)return;a++;let s=null;if(r instanceof ke){let t=e.marks,n;for(;n=r.isInSet(t);)(s||=[]).push(n),t=n.removeFromSet(t)}else r?r.isInSet(e.marks)&&(s=[r]):s=e.marks;if(s&&s.length){let r=Math.min(o+e.nodeSize,n);for(let e=0;ee.step(new _t(t.from,t.to,t.style)))}function Dt(e,t,n,r=n.contentMatch,i=!0){let a=e.doc.nodeAt(t),o=[],s=t+1;for(let t=0;t=0;t--)e.step(o[t])}function Ot(e,t,n){return(t==0||e.canReplace(t,e.childCount))&&(n==e.childCount||e.canReplace(0,n))}function kt(e){let t=e.parent.content.cutByIndex(e.startIndex,e.endIndex);for(let n=e.depth,r=0,i=0;;--n){let a=e.$from.node(n),o=e.$from.index(n)+r,s=e.$to.indexAfter(n)-i;if(nn;e--)t||r.index(e)>0?(t=!0,d=c.from(r.node(e).copy(d)),f++):l--;let p=c.empty,h=0;for(let e=a,t=!1;e>n;e--)t||i.after(e+1)=0;e--){if(r.size){let t=n[e].type.contentMatch.matchFragment(r);if(!t||!t.validEnd)throw RangeError(`Wrapper type given to Transform.wrap does not form valid content of its parent wrapper`)}r=c.from(n[e].type.create(n[e].attrs,r))}let i=t.start,a=t.end;e.step(new Ct(i,a,i,a,new m(r,0,0),n.length,!0))}function It(e,t,n,r,i){if(!r.isTextblock)throw RangeError(`Type given to setBlockType should be a textblock`);let a=e.steps.length;e.doc.nodesBetween(t,n,(t,n)=>{let o=typeof i==`function`?i(t):i;if(t.isTextblock&&!t.hasMarkup(r,o)&&zt(e.doc,e.mapping.slice(a).map(n),r)){let i=null;if(r.schema.linebreakReplacement){let e=r.whitespace==`pre`,t=!!r.contentMatch.matchType(r.schema.linebreakReplacement);e&&!t?i=!1:!e&&t&&(i=!0)}i===!1&&Rt(e,t,n,a),Dt(e,e.mapping.slice(a).map(n,1),r,void 0,i===null);let s=e.mapping.slice(a),l=s.map(n,1),u=s.map(n+t.nodeSize,1);return e.step(new Ct(l,u,l+1,u-1,new m(c.from(r.create(o,null,t.marks)),0,0),1,!0)),i===!0&&Lt(e,t,n,a),!1}})}function Lt(e,t,n,r){t.forEach((i,a)=>{if(i.isText){let o,s=/\r?\n|\r/g;for(;o=s.exec(i.text);){let i=e.mapping.slice(r).map(n+1+a+o.index);e.replaceWith(i,i+1,t.type.schema.linebreakReplacement.create())}}})}function Rt(e,t,n,r){t.forEach((i,a)=>{if(i.type==i.type.schema.linebreakReplacement){let i=e.mapping.slice(r).map(n+1+a);e.replaceWith(i,i+1,t.type.schema.text(` `))}})}function zt(e,t,n){let r=e.resolve(t),i=r.index();return r.parent.canReplaceWith(i,i+1,n)}function Bt(e,t,n,r,i){let a=e.doc.nodeAt(t);if(!a)throw RangeError(`No node at given position`);n||=a.type;let o=n.create(r,null,i||a.marks);if(a.isLeaf)return e.replaceWith(t,t+a.nodeSize,o);if(!n.validContent(a.content))throw RangeError(`Invalid content for node type `+n.name);e.step(new Ct(t,t+a.nodeSize,t+1,t+a.nodeSize-1,new m(c.from(o),0,0),1,!0))}function Vt(e,t,n=1,r){let i=e.resolve(t),a=i.depth-n,o=r&&r[r.length-1]||i.parent;if(a<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!o.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let e=i.depth-1,t=n-2;e>a;e--,t--){let n=i.node(e),a=i.index(e);if(n.type.spec.isolating)return!1;let o=n.content.cutByIndex(a,n.childCount),s=r&&r[t+1];s&&(o=o.replaceChild(0,s.type.create(s.attrs)));let c=r&&r[t]||n;if(!n.canReplace(a+1,n.childCount)||!c.type.validContent(o))return!1}let s=i.indexAfter(a),c=r&&r[0];return i.node(a).canReplaceWith(s,s,c?c.type:i.node(a+1).type)}function Ht(e,t,n=1,r){let i=e.doc.resolve(t),a=c.empty,o=c.empty;for(let e=i.depth,t=i.depth-n,s=n-1;e>t;e--,s--){a=c.from(i.node(e).copy(a));let t=r&&r[s];o=c.from(t?t.type.create(t.attrs,o):i.node(e).copy(o))}e.step(new St(t,t,new m(a.append(o),n,n),!0))}function Ut(e,t){let n=e.resolve(t),r=n.index();return Gt(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function Wt(e,t){t.content.size||e.type.compatibleContent(t.type);let n=e.contentMatchAt(e.childCount),{linebreakReplacement:r}=e.type.schema;for(let i=0;i0?(i=r.node(e+1),o++,a=r.node(e).maybeChild(o)):(i=r.node(e).maybeChild(o-1),a=r.node(e+1)),i&&!i.isTextblock&&Gt(i,a)&&r.node(e).canReplace(o,o+1))return t;if(e==0)break;t=n<0?r.before(e):r.after(e)}}function qt(e,t,n){let r=null,{linebreakReplacement:i}=e.doc.type.schema,a=e.doc.resolve(t-n),o=a.node().type;if(i&&o.inlineContent){let e=o.whitespace==`pre`,t=!!o.contentMatch.matchType(i);e&&!t?r=!1:!e&&t&&(r=!0)}let s=e.steps.length;if(r===!1){let r=e.doc.resolve(t+n);Rt(e,r.node(),r.before(),s)}o.inlineContent&&Dt(e,t+n-1,o,a.node().contentMatchAt(a.index()),r==null);let c=e.mapping.slice(s),l=c.map(t-n);if(e.step(new St(l,c.map(t+n,-1),m.empty,!0)),r===!0){let t=e.doc.resolve(l);Lt(e,t.node(),t.before(),e.steps.length)}return e}function Jt(e,t,n){let r=e.resolve(t);if(r.parent.canReplaceWith(r.index(),r.index(),n))return t;if(r.parentOffset==0)for(let e=r.depth-1;e>=0;e--){let t=r.index(e);if(r.node(e).canReplaceWith(t,t,n))return r.before(e+1);if(t>0)return null}if(r.parentOffset==r.parent.content.size)for(let e=r.depth-1;e>=0;e--){let t=r.indexAfter(e);if(r.node(e).canReplaceWith(t,t,n))return r.after(e+1);if(t=0;t--){let n=t==r.depth?0:r.pos<=(r.start(t+1)+r.end(t+1))/2?-1:1,a=r.index(t)+ +(n>0),o=r.node(t),s=!1;if(e==1)s=o.canReplace(a,a,i);else{let e=o.contentMatchAt(a).findWrapping(i.firstChild.type);s=e&&o.canReplaceWith(a,a,e[0])}if(s)return n==0?r.pos:n<0?r.before(t+1):r.after(t+1)}return null}function Xt(e,t,n=t,r=m.empty){if(t==n&&!r.size)return null;let i=e.resolve(t),a=e.resolve(n);return Zt(i,a,r)?new St(t,n,r):new Qt(i,a,r).fit()}function Zt(e,t,n){return!n.openStart&&!n.openEnd&&e.start()==t.start()&&e.parent.canReplace(e.index(),t.index(),n.content)}var Qt=class{constructor(e,t,n){this.$from=e,this.$to=t,this.unplaced=n,this.frontier=[],this.placed=c.empty;for(let t=0;t<=e.depth;t++){let n=e.node(t);this.frontier.push({type:n.type,match:n.contentMatchAt(e.indexAfter(t))})}for(let t=e.depth;t>0;t--)this.placed=c.from(e.node(t).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let e=this.findFittable();e?this.placeNodes(e):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,n=this.$from,r=this.close(e<0?this.$to:n.doc.resolve(e));if(!r)return null;let i=this.placed,a=n.depth,o=r.depth;for(;a&&o&&i.childCount==1;)i=i.firstChild.content,a--,o--;let s=new m(i,a,o);return e>-1?new Ct(n.pos,e,this.$to.pos,this.$to.end(),s,t):s.size||n.pos!=this.$to.pos?new St(n.pos,r.pos,s):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,n=0,r=this.unplaced.openEnd;n1&&(r=0),i.type.spec.isolating&&r<=n){e=n;break}t=i.content}for(let t=1;t<=2;t++)for(let n=t==1?e:this.unplaced.openStart;n>=0;n--){let e,r=null;n?(r=tn(this.unplaced.content,n-1).firstChild,e=r.content):e=this.unplaced.content;let i=e.firstChild;for(let e=this.depth;e>=0;e--){let{type:a,match:o}=this.frontier[e],s,l=null;if(t==1&&(i?o.matchType(i.type)||(l=o.fillBefore(c.from(i),!1)):r&&a.compatibleContent(r.type)))return{sliceDepth:n,frontierDepth:e,parent:r,inject:l};if(t==2&&i&&(s=o.findWrapping(i.type)))return{sliceDepth:n,frontierDepth:e,parent:r,wrap:s};if(r&&o.matchType(r.type))break}}}openMore(){let{content:e,openStart:t,openEnd:n}=this.unplaced;return sn(e,-1)<=t?!1:(this.unplaced.size>1&&sn(e,1)>n&&n++,this.unplaced=new m(e,t+1,n),!0)}dropNode(){let{content:e,openStart:t,openEnd:n}=this.unplaced,r=tn(e,t);if(r.childCount<=1&&t>0){let i=e.size-t<=t+r.size;this.unplaced=new m($t(e,t-1,1),t-1,i?t-1:n)}else this.unplaced=new m($t(e,t,1),t,n)}placeNodes({sliceDepth:e,frontierDepth:t,parent:n,inject:r,wrap:i}){for(;this.depth>t;)this.closeFrontierNode();if(i)for(let e=0;e1||s==0||e.content.size)&&(d=t,u.push(nn(e.mark(f.allowedMarks(e.marks)),l==1?s:0,l==o.childCount?p:-1)))}let h=l==o.childCount;h||(p=-1),this.placed=en(this.placed,t,c.from(u)),this.frontier[t].match=d,h&&p<0&&n&&n.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let e=0,t=u[u.length-1];t&&e1&&r==this.$to.end(--n);)++r;return r}findCloseLevel(e){scan:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:n,type:r}=this.frontier[t],i=t=0;n--){let{match:t,type:r}=this.frontier[n],i=rn(e,n,r,t,!0);if(!i||i.childCount)continue scan}return{depth:t,fit:a,move:i?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=en(this.placed,t.depth,t.fit)),e=t.move;for(let n=t.depth+1;n<=e.depth;n++){let t=e.node(n),r=t.type.contentMatch.fillBefore(t.content,!0,e.index(n));this.openFrontierNode(t.type,t.attrs,r)}return e}openFrontierNode(e,t=null,n){let r=this.frontier[this.depth];r.match=r.match.matchType(e),this.placed=en(this.placed,this.depth,c.from(e.create(t,n))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let e=this.frontier.pop().match.fillBefore(c.empty,!0);e.childCount&&(this.placed=en(this.placed,this.frontier.length,e))}};function $t(e,t,n){return t==0?e.cutByIndex(n,e.childCount):e.replaceChild(0,e.firstChild.copy($t(e.firstChild.content,t-1,n)))}function en(e,t,n){return t==0?e.append(n):e.replaceChild(e.childCount-1,e.lastChild.copy(en(e.lastChild.content,t-1,n)))}function tn(e,t){for(let n=0;n1&&(r=r.replaceChild(0,nn(r.firstChild,t-1,r.childCount==1?n-1:0))),t>0&&(r=e.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(e.type.contentMatch.matchFragment(r).fillBefore(c.empty,!0)))),e.copy(r)}function rn(e,t,n,r,i){let a=e.node(t),o=i?e.indexAfter(t):e.index(t);if(o==a.childCount&&!n.compatibleContent(a.type))return null;let s=r.fillBefore(a.content,!0,o);return s&&!an(n,a.content,o)?s:null}function an(e,t,n){for(let r=n;r0;e--,t--){let n=i.node(e).type.spec;if(n.defining||n.definingAsContext||n.isolating)break;o.indexOf(e)>-1?s=e:i.before(e)==t&&o.splice(1,0,-e)}let c=o.indexOf(s),l=[],u=r.openStart;for(let e=r.content,t=0;;t++){let n=e.firstChild;if(l.push(n),t==r.openStart)break;e=n.content}for(let e=u-1;e>=0;e--){let t=l[e],n=on(t.type);if(n&&!t.sameMarkup(i.node(Math.abs(s)-1)))u=e;else if(n||!t.type.isTextblock)break}for(let t=r.openStart;t>=0;t--){let s=(t+u+1)%(r.openStart+1),d=l[s];if(d)for(let t=0;t=0&&(e.replace(t,n,r),!(e.steps.length>d));s--){let e=o[s];e<0||(t=i.before(e),n=a.after(e))}}function ln(e,t,n,r,i){if(tr){let t=i.contentMatchAt(0),n=t.fillBefore(e).append(e);e=n.append(t.matchFragment(n).fillBefore(c.empty,!0))}return e}function un(e,t,n,r){if(!r.isInline&&t==n&&e.doc.resolve(t).parent.content.size){let i=Jt(e.doc,t,r.type);i!=null&&(t=n=i)}e.replaceRange(t,n,new m(c.from(r),0,0))}function dn(e,t,n){let r=e.doc.resolve(t),i=e.doc.resolve(n);if(r.parent.isTextblock&&i.parent.isTextblock&&r.start()!=i.start()&&r.parentOffset==0&&i.parentOffset==0){let a=r.sharedDepth(n),o=!1;for(let e=r.depth;e>a;e--)r.node(e).type.spec.isolating&&(o=!0);for(let e=i.depth;e>a;e--)i.node(e).type.spec.isolating&&(o=!0);if(!o){for(let e=r.depth;e>0&&t==r.start(e);e--)t=r.before(e);for(let e=i.depth;e>0&&n==i.start(e);e--)n=i.before(e);r=e.doc.resolve(t),i=e.doc.resolve(n)}}let a=fn(r,i);for(let t=0;t0&&(o||r.node(n-1).canReplace(r.index(n-1),i.indexAfter(n-1))))return e.delete(r.before(n),i.after(n))}for(let a=1;a<=r.depth&&a<=i.depth;a++)if(t-r.start(a)==r.depth-a&&n>r.end(a)&&i.end(a)-n!=i.depth-a&&r.start(a-1)==i.start(a-1)&&r.node(a-1).canReplace(r.index(a-1),i.index(a-1)))return e.delete(r.before(a),n);e.delete(t,n)}function fn(e,t){let n=[],r=Math.min(e.depth,t.depth);for(let i=r;i>=0;i--){let r=e.start(i);if(rt.pos+(t.depth-i)||e.node(i).type.spec.isolating||t.node(i).type.spec.isolating)break;(r==t.start(i)||i==e.depth&&i==t.depth&&e.parent.inlineContent&&t.parent.inlineContent&&i&&t.start(i-1)==r-1)&&n.push(i)}return n}var pn=class e extends O{constructor(e,t,n){super(),this.pos=e,this.attr=t,this.value=n}apply(e){let t=e.nodeAt(this.pos);if(!t)return mt.fail(`No node at attribute step's position`);let n=Object.create(null);for(let e in t.attrs)n[e]=t.attrs[e];n[this.attr]=this.value;let r=t.type.create(n,null,t.marks);return mt.fromReplace(e,this.pos,this.pos+1,new m(c.from(r),0,+!t.isLeaf))}getMap(){return dt.empty}invert(t){return new e(this.pos,this.attr,t.nodeAt(this.pos).attrs[this.attr])}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new e(n.pos,this.attr,this.value)}toJSON(){return{stepType:`attr`,pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(t,n){if(typeof n.pos!=`number`||typeof n.attr!=`string`)throw RangeError(`Invalid input for AttrStep.fromJSON`);return new e(n.pos,n.attr,n.value)}};O.jsonID(`attr`,pn);var mn=class e extends O{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let n in e.attrs)t[n]=e.attrs[n];t[this.attr]=this.value;let n=e.type.create(t,e.content,e.marks);return mt.ok(n)}getMap(){return dt.empty}invert(t){return new e(this.attr,t.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:`docAttr`,attr:this.attr,value:this.value}}static fromJSON(t,n){if(typeof n.attr!=`string`)throw RangeError(`Invalid input for DocAttrStep.fromJSON`);return new e(n.attr,n.value)}};O.jsonID(`docAttr`,mn);var hn=class extends Error{};hn=function e(t){let n=Error.call(this,t);return n.__proto__=e.prototype,n},hn.prototype=Object.create(Error.prototype),hn.prototype.constructor=hn,hn.prototype.name=`TransformError`;var gn=class{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new ft}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new hn(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}changedRange(){let e=1e9,t=-1e9;for(let n=0;n{e=Math.min(e,i),t=Math.max(t,a)})}return e==1e9?null:{from:e,to:t}}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,n=m.empty){let r=Xt(this.doc,e,t,n);return r&&this.step(r),this}replaceWith(e,t,n){return this.replace(e,t,new m(c.from(n),0,0))}delete(e,t){return this.replace(e,t,m.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,n){return cn(this,e,t,n),this}replaceRangeWith(e,t,n){return un(this,e,t,n),this}deleteRange(e,t){return dn(this,e,t),this}lift(e,t){return At(this,e,t),this}join(e,t=1){return qt(this,e,t),this}wrap(e,t){return Ft(this,e,t),this}setBlockType(e,t=e,n,r=null){return It(this,e,t,n,r),this}setNodeMarkup(e,t,n=null,r){return Bt(this,e,t,n,r),this}setNodeAttribute(e,t,n){return this.step(new pn(e,t,n)),this}setDocAttribute(e,t){return this.step(new mn(e,t)),this}addNodeMark(e,t){return this.step(new bt(e,t)),this}removeNodeMark(e,t){let n=this.doc.nodeAt(e);if(!n)throw RangeError(`No node at position `+e);if(t instanceof f)t.isInSet(n.marks)&&this.step(new xt(e,t));else{let r=n.marks,i,a=[];for(;i=t.isInSet(r);)a.push(new xt(e,i)),r=i.removeFromSet(r);for(let e=a.length-1;e>=0;e--)this.step(a[e])}return this}split(e,t=1,n){return Ht(this,e,t,n),this}addMark(e,t,n){return Tt(this,e,t,n),this}removeMark(e,t,n){return Et(this,e,t,n),this}clearIncompatible(e,t,n){return Dt(this,e,t,n),this}},_n=Object.create(null),k=class{constructor(e,t,n){this.$anchor=e,this.$head=t,this.ranges=n||[new vn(e.min(t),e.max(t))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let t=0;t=0;r--){let i=t<0?Tn(e.node(0),e.node(r),e.before(r+1),e.index(r),t,n):Tn(e.node(0),e.node(r),e.after(r+1),e.index(r)+1,t,n);if(i)return i}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new Cn(e.node(0))}static atStart(e){return Tn(e,e,0,0,1)||new Cn(e)}static atEnd(e){return Tn(e,e,e.content.size,e.childCount,-1)||new Cn(e)}static fromJSON(e,t){if(!t||!t.type)throw RangeError(`Invalid input for Selection.fromJSON`);let n=_n[t.type];if(!n)throw RangeError(`No selection type ${t.type} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in _n)throw RangeError(`Duplicate use of selection JSON ID `+e);return _n[e]=t,t.prototype.jsonID=e,t}getBookmark(){return A.between(this.$anchor,this.$head).getBookmark()}};k.prototype.visible=!0;var vn=class{constructor(e,t){this.$from=e,this.$to=t}},yn=!1;function bn(e){!yn&&!e.parent.inlineContent&&(yn=!0,console.warn(`TextSelection endpoint not pointing into a node with inline content (`+e.parent.type.name+`)`))}var A=class e extends k{constructor(e,t=e){bn(e),bn(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(t,n){let r=t.resolve(n.map(this.head));if(!r.parent.inlineContent)return k.near(r);let i=t.resolve(n.map(this.anchor));return new e(i.parent.inlineContent?i:r,r)}replace(e,t=m.empty){if(super.replace(e,t),t==m.empty){let t=this.$from.marksAcross(this.$to);t&&e.ensureMarks(t)}}eq(t){return t instanceof e&&t.anchor==this.anchor&&t.head==this.head}getBookmark(){return new xn(this.anchor,this.head)}toJSON(){return{type:`text`,anchor:this.anchor,head:this.head}}static fromJSON(t,n){if(typeof n.anchor!=`number`||typeof n.head!=`number`)throw RangeError(`Invalid input for TextSelection.fromJSON`);return new e(t.resolve(n.anchor),t.resolve(n.head))}static create(e,t,n=t){let r=e.resolve(t);return new this(r,n==t?r:e.resolve(n))}static between(t,n,r){let i=t.pos-n.pos;if((!r||i)&&(r=i>=0?1:-1),!n.parent.inlineContent){let e=k.findFrom(n,r,!0)||k.findFrom(n,-r,!0);if(e)n=e.$head;else return k.near(n,r)}return t.parent.inlineContent||(i==0?t=n:(t=(k.findFrom(t,-r,!0)||k.findFrom(t,r,!0)).$anchor,t.pos0?0:1);i>0?o=0;o+=i){let r=t.child(o);if(!r.isAtom){let t=Tn(e,r,n+i,i<0?r.childCount:0,i,a);if(t)return t}else if(!a&&j.isSelectable(r))return j.create(e,n-(i<0?r.nodeSize:0));n+=r.nodeSize*i}return null}function En(e,t,n){let r=e.steps.length-1;if(r{o??=r}),e.setSelection(k.near(e.doc.resolve(o),n))}var Dn=1,On=2,kn=4,An=class extends gn{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|=On,this}ensureMarks(e){return f.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&On)>0}addStep(e,t){super.addStep(e,t),this.updated&=-3,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let n=this.selection;return t&&(e=e.mark(this.storedMarks||(n.empty?n.$from.marks():n.$from.marksAcross(n.$to)||f.none))),n.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,n){let r=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(r.text(e),!0):this.deleteSelection();{if(n??=t,!e)return this.deleteRange(t,n);let i=this.storedMarks;if(!i){let e=this.doc.resolve(t);i=n==t?e.marks():e.marksAcross(this.doc.resolve(n))}return this.replaceRangeWith(t,n,r.text(e,i)),!this.selection.empty&&this.selection.to==t+e.length&&this.setSelection(k.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|=kn,this}get scrolledIntoView(){return(this.updated&kn)>0}};function jn(e,t){return!t||!e?e:e.bind(t)}var Mn=class{constructor(e,t,n){this.name=e,this.init=jn(t.init,n),this.apply=jn(t.apply,n)}},Nn=[new Mn(`doc`,{init(e){return e.doc||e.schema.topNodeType.createAndFill()},apply(e){return e.doc}}),new Mn(`selection`,{init(e,t){return e.selection||k.atStart(t.doc)},apply(e){return e.selection}}),new Mn(`storedMarks`,{init(e){return e.storedMarks||null},apply(e,t,n,r){return r.selection.$cursor?e.storedMarks:null}}),new Mn(`scrollToSelection`,{init(){return 0},apply(e,t){return e.scrolledIntoView?t+1:t}})],Pn=class{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=Nn.slice(),t&&t.forEach(e=>{if(this.pluginsByKey[e.key])throw RangeError(`Adding different instances of a keyed plugin (`+e.key+`)`);this.plugins.push(e),this.pluginsByKey[e.key]=e,e.spec.state&&this.fields.push(new Mn(e.key,e.spec.state,e))})}},Fn=class e{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,t=-1){for(let n=0;ne.toJSON())),e&&typeof e==`object`)for(let n in e){if(n==`doc`||n==`selection`)throw RangeError("The JSON fields `doc` and `selection` are reserved");let r=e[n],i=r.spec.state;i&&i.toJSON&&(t[n]=i.toJSON.call(r,this[r.key]))}return t}static fromJSON(t,n,r){if(!n)throw RangeError(`Invalid input for EditorState.fromJSON`);if(!t.schema)throw RangeError(`Required config field 'schema' missing`);let i=new Pn(t.schema,t.plugins),a=new e(i);return i.fields.forEach(e=>{if(e.name==`doc`)a.doc=ae.fromJSON(t.schema,n.doc);else if(e.name==`selection`)a.selection=k.fromJSON(a.doc,n.selection);else if(e.name==`storedMarks`)n.storedMarks&&(a.storedMarks=n.storedMarks.map(t.schema.markFromJSON));else{if(r)for(let i in r){let o=r[i],s=o.spec.state;if(o.key==e.name&&s&&s.fromJSON&&Object.prototype.hasOwnProperty.call(n,i)){a[e.name]=s.fromJSON.call(o,t,n[i],a);return}}a[e.name]=e.init(t,a)}}),a}};function In(e,t,n){for(let r in e){let i=e[r];i instanceof Function?i=i.bind(t):r==`handleDOMEvents`&&(i=In(i,t,{})),n[r]=i}return n}var M=class{constructor(e){this.spec=e,this.props={},e.props&&In(e.props,this,this.props),this.key=e.key?e.key.key:Rn(`plugin`)}getState(e){return e[this.key]}},Ln=Object.create(null);function Rn(e){return e in Ln?e+`$`+ ++Ln[e]:(Ln[e]=0,e+`$`)}var N=class{constructor(e=`key`){this.key=Rn(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}},zn=(e,t)=>!e.selection.empty&&(t&&t(e.tr.deleteSelection().scrollIntoView()),!0);function Bn(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock(`backward`,e):n.parentOffset>0)?null:n}var Vn=(e,t,n)=>{let r=Bn(e,n);if(!r)return!1;let i=qn(r);if(!i){let n=r.blockRange(),i=n&&kt(n);return i!=null&&(t&&t(e.tr.lift(n,i).scrollIntoView()),!0)}let a=i.nodeBefore;if(dr(e,i,t,-1))return!0;if(r.parent.content.size==0&&(Gn(a,`end`)||j.isSelectable(a)))for(let n=r.depth;;n--){let o=Xt(e.doc,r.before(n),r.after(n),m.empty);if(o&&o.slice.size1)break}return a.isAtom&&i.depth==r.depth-1?(t&&t(e.tr.delete(i.pos-a.nodeSize,i.pos).scrollIntoView()),!0):!1},Hn=(e,t,n)=>{let r=Bn(e,n);if(!r)return!1;let i=qn(r);return i?Wn(e,i,t):!1},Un=(e,t,n)=>{let r=Jn(e,n);if(!r)return!1;let i=Zn(r);return i?Wn(e,i,t):!1};function Wn(e,t,n){let r=t.nodeBefore,i=t.pos-1;for(;!r.isTextblock;i--){if(r.type.spec.isolating)return!1;let e=r.lastChild;if(!e)return!1;r=e}let a=t.nodeAfter,o=t.pos+1;for(;!a.isTextblock;o++){if(a.type.spec.isolating)return!1;let e=a.firstChild;if(!e)return!1;a=e}let s=Xt(e.doc,i,o,m.empty);if(!s||s.from!=i||s instanceof St&&s.slice.size>=o-i)return!1;if(n){let t=e.tr.step(s);t.setSelection(A.create(t.doc,i)),n(t.scrollIntoView())}return!0}function Gn(e,t,n=!1){for(let r=e;r;r=t==`start`?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&r.childCount!=1)return!1}return!1}var Kn=(e,t,n)=>{let{$head:r,empty:i}=e.selection,a=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock(`backward`,e):r.parentOffset>0)return!1;a=qn(r)}let o=a&&a.nodeBefore;return!o||!j.isSelectable(o)?!1:(t&&t(e.tr.setSelection(j.create(e.doc,a.pos-o.nodeSize)).scrollIntoView()),!0)};function qn(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){if(e.index(t)>0)return e.doc.resolve(e.before(t+1));if(e.node(t).type.spec.isolating)break}return null}function Jn(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock(`forward`,e):n.parentOffset{let r=Jn(e,n);if(!r)return!1;let i=Zn(r);if(!i)return!1;let a=i.nodeAfter;if(dr(e,i,t,1))return!0;if(r.parent.content.size==0&&(Gn(a,`start`)||j.isSelectable(a))){let n=Xt(e.doc,r.before(),r.after(),m.empty);if(n&&n.slice.size{let{$head:r,empty:i}=e.selection,a=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock(`forward`,e):r.parentOffset=0;t--){let n=e.node(t);if(e.index(t)+1{let n=e.selection,r=n instanceof j,i;if(r){if(n.node.isTextblock||!Ut(e.doc,n.from))return!1;i=n.from}else if(i=Kt(e.doc,n.from,-1),i==null)return!1;if(t){let n=e.tr.join(i);r&&n.setSelection(j.create(n.doc,i-e.doc.resolve(i).nodeBefore.nodeSize)),t(n.scrollIntoView())}return!0},$n=(e,t)=>{let n=e.selection,r;if(n instanceof j){if(n.node.isTextblock||!Ut(e.doc,n.to))return!1;r=n.to}else if(r=Kt(e.doc,n.to,1),r==null)return!1;return t&&t(e.tr.join(r).scrollIntoView()),!0},er=(e,t)=>{let{$from:n,$to:r}=e.selection,i=n.blockRange(r),a=i&&kt(i);return a!=null&&(t&&t(e.tr.lift(i,a).scrollIntoView()),!0)},tr=(e,t)=>{let{$head:n,$anchor:r}=e.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(t&&t(e.tr.insertText(` -`).scrollIntoView()),!0)};function nr(e){for(let t=0;t{let{$head:n,$anchor:r}=e.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let i=n.node(-1),a=n.indexAfter(-1),o=nr(i.contentMatchAt(a));if(!o||!i.canReplaceWith(a,a,o))return!1;if(t){let r=n.after(),i=e.tr.replaceWith(r,r,o.createAndFill());i.setSelection(k.near(i.doc.resolve(r),1)),t(i.scrollIntoView())}return!0},ir=(e,t)=>{let n=e.selection,{$from:r,$to:i}=n;if(n instanceof Cn||r.parent.inlineContent||i.parent.inlineContent)return!1;let a=nr(i.parent.contentMatchAt(i.indexAfter()));if(!a||!a.isTextblock)return!1;if(t){let n=(!r.parentOffset&&i.index(){let{$cursor:n}=e.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let r=n.before();if(Vt(e.doc,r))return t&&t(e.tr.split(r).scrollIntoView()),!0}let r=n.blockRange(),i=r&&kt(r);return i!=null&&(t&&t(e.tr.lift(r,i).scrollIntoView()),!0)};function or(e){return(t,n)=>{if(t.selection instanceof j&&t.selection.node.isBlock){let{$from:e}=t.selection;return!e.parentOffset||!Vt(t.doc,e.pos)?!1:(n&&n(t.tr.split(e.pos).scrollIntoView()),!0)}if(!t.selection.$from.depth)return!1;let r=t.tr;!t.selection.empty&&(t.selection instanceof A||t.selection instanceof Cn)&&r.deleteSelection();let{$from:i}=r.selection,a=r.steps.length,o=[],s,c,l=!1,u=!1;for(let t=i.depth;;t--)if(i.node(t).isBlock){l=i.end(t)==i.pos+(i.depth-t),u=i.start(t)==i.pos-(i.depth-t),c=nr(i.node(t-1).contentMatchAt(i.indexAfter(t-1)));let n=e&&e(i.parent,l,i);o.unshift(n||(l&&c?{type:c}:null)),s=t;break}else{if(t==1)return!1;o.unshift(null)}let d=i.pos,f=Vt(r.doc,d,o.length,o);if(f||=(o[0]=c?{type:c}:null,Vt(r.doc,d,o.length,o)),!f)return!1;if(r.split(d,o.length,o),!l&&u&&i.node(s).type!=c){let e=r.mapping.slice(a),t=e.map(i.before(s)),n=r.doc.resolve(t);c&&i.node(s-1).canReplaceWith(n.index(),n.index()+1,c)&&r.setNodeMarkup(e.map(i.before(s)),c)}return n&&n(r.scrollIntoView()),!0}}var sr=or(),cr=(e,t)=>{let{$from:n,to:r}=e.selection,i,a=n.sharedDepth(r);return a!=0&&(i=n.before(a),t&&t(e.tr.setSelection(j.create(e.doc,i))),!0)},lr=(e,t)=>(t&&t(e.tr.setSelection(new Cn(e.doc))),!0);function ur(e,t,n){let r=t.nodeBefore,i=t.nodeAfter,a=t.index();return!r||!i||!r.type.compatibleContent(i.type)?!1:!r.content.size&&t.parent.canReplace(a-1,a)?(n&&n(e.tr.delete(t.pos-r.nodeSize,t.pos).scrollIntoView()),!0):!t.parent.canReplace(a,a+1)||!(i.isTextblock||Ut(e.doc,t.pos))?!1:(n&&n(e.tr.join(t.pos).scrollIntoView()),!0)}function dr(e,t,n,r){let i=t.nodeBefore,a=t.nodeAfter,o,s,l=i.type.spec.isolating||a.type.spec.isolating;if(!l&&ur(e,t,n))return!0;let u=!l&&t.parent.canReplace(t.index(),t.index()+1);if(u&&(o=(s=i.contentMatchAt(i.childCount)).findWrapping(a.type))&&s.matchType(o[0]||a.type).validEnd){if(n){let r=t.pos+a.nodeSize,s=c.empty;for(let e=o.length-1;e>=0;e--)s=c.from(o[e].create(null,s));s=c.from(i.copy(s));let l=e.tr.step(new Ct(t.pos-1,r,t.pos,r,new m(s,1,0),o.length,!0)),u=l.doc.resolve(r+2*o.length);u.nodeAfter&&u.nodeAfter.type==i.type&&Ut(l.doc,u.pos)&&l.join(u.pos),n(l.scrollIntoView())}return!0}let d=a.type.spec.isolating||r>0&&l?null:k.findFrom(t,1),f=d&&d.$from.blockRange(d.$to),p=f&&kt(f);if(p!=null&&p>=t.depth)return n&&n(e.tr.lift(f,p).scrollIntoView()),!0;if(u&&Gn(a,`start`,!0)&&Gn(i,`end`)){let r=i,o=[];for(;o.push(r),!r.isTextblock;)r=r.lastChild;let s=a,l=1;for(;!s.isTextblock;s=s.firstChild)l++;if(r.canReplace(r.childCount,r.childCount,s.content)){if(n){let r=c.empty;for(let e=o.length-1;e>=0;e--)r=c.from(o[e].copy(r));n(e.tr.step(new Ct(t.pos-o.length,t.pos+a.nodeSize,t.pos+l,t.pos+a.nodeSize-l,new m(r,o.length,0),0,!0)).scrollIntoView())}return!0}}return!1}function fr(e){return function(t,n){let r=t.selection,i=e<0?r.$from:r.$to,a=i.depth;for(;i.node(a).isInline;){if(!a)return!1;a--}return i.node(a).isTextblock?(n&&n(t.tr.setSelection(A.create(t.doc,e<0?i.start(a):i.end(a)))),!0):!1}}var pr=fr(-1),mr=fr(1);function hr(e,t=null){return function(n,r){let{$from:i,$to:a}=n.selection,o=i.blockRange(a),s=o&&jt(o,e,t);return s?(r&&r(n.tr.wrap(o,s).scrollIntoView()),!0):!1}}function gr(e,t=null){return function(n,r){let i=!1;for(let r=0;r{if(i)return!1;if(r.isTextblock&&!r.hasMarkup(e,t)){if(r.type==e)i=!0;else{let t=n.doc.resolve(a),r=t.index();i=t.parent.canReplaceWith(r,r+1,e)}}})}if(!i)return!1;if(r){let i=n.tr;for(let r=0;r=2&&t.$from.node(t.depth-1).type.compatibleContent(n)&&t.startIndex==0){if(t.$from.index(t.depth-1)==0)return!1;let e=o.resolve(t.start-2);a=new re(e,e,t.depth),t.endIndex=0;e--)a=c.from(n[e].type.create(n[e].attrs,a));e.step(new Ct(t.start-(r?2:0),t.end,t.start,t.end,new m(a,0,0),n.length,!0));let o=0;for(let e=0;et.childCount>0&&t.firstChild.type==e);return a?n?r.node(a.depth-1).type==e?Er(t,n,e,a):Dr(t,n,a):!0:!1}}function Er(e,t,n,r){let i=e.tr,a=r.end,o=r.$to.end(r.depth);aa;t--)e-=i.child(t).nodeSize,r.delete(e-1,e+1);let a=r.doc.resolve(n.start),o=a.nodeAfter;if(r.mapping.map(n.end)!=n.start+a.nodeAfter.nodeSize)return!1;let s=n.startIndex==0,l=n.endIndex==i.childCount,u=a.node(-1),d=a.index(-1);if(!u.canReplace(d+ +!s,d+1,o.content.append(l?c.empty:c.from(i))))return!1;let f=a.pos,p=f+o.nodeSize;return r.step(new Ct(f-+!!s,p+ +!!l,f+1,p-1,new m((s?c.empty:c.from(i.copy(c.empty))).append(l?c.empty:c.from(i.copy(c.empty))),+!s,+!l),+!s)),t(r.scrollIntoView()),!0}function Or(e){return function(t,n){let{$from:r,$to:i}=t.selection,a=r.blockRange(i,t=>t.childCount>0&&t.firstChild.type==e);if(!a)return!1;let o=a.startIndex;if(o==0)return!1;let s=a.parent,l=s.child(o-1);if(l.type!=e)return!1;if(n){let r=l.lastChild&&l.lastChild.type==s.type,i=c.from(r?e.create():null),o=new m(c.from(e.create(null,c.from(s.type.create(null,i)))),r?3:1,0),u=a.start,d=a.end;n(t.tr.step(new Ct(u-(r?3:1),d,u,d,o,1,!0)).scrollIntoView())}return!0}}var kr=function(e){for(var t=0;;t++)if(e=e.previousSibling,!e)return t},Ar=function(e){let t=e.assignedSlot||e.parentNode;return t&&t.nodeType==11?t.host:t},jr=null,Mr=function(e,t,n){let r=jr||=document.createRange();return r.setEnd(e,n??e.nodeValue.length),r.setStart(e,t||0),r},Nr=function(){jr=null},Pr=function(e,t,n,r){return n&&(Ir(e,t,n,r,-1)||Ir(e,t,n,r,1))},Fr=/^(img|br|input|textarea|hr)$/i;function Ir(e,t,n,r,i){for(;;){if(e==n&&t==r)return!0;if(t==(i<0?0:Lr(e))){let n=e.parentNode;if(!n||!P(n)||Hr(e)||Fr.test(e.nodeName)||e.contentEditable==`false`)return!1;t=kr(e)+(i<0?0:1),e=n}else if(P(e)){let n=e.childNodes[t+(i<0?-1:0)];if(P(n)&&n.contentEditable==`false`){if(n.pmViewDesc?.ignoreForSelection)t+=i;else return!1}else e=n,t=i<0?Lr(e):0}else return!1}}function Lr(e){return e.nodeType==3?e.nodeValue.length:e.childNodes.length}function P(e){return e.nodeType==1}function F(e){return e.nodeType==3}function Rr(e,t){return t?e.contains(P(t)?t:t.parentNode):!1}function zr(e,t){for(;;){if(F(e)&&t)return e;if(P(e)&&t>0){if(e.contentEditable==`false`)return null;e=e.childNodes[t-1],t=Lr(e)}else if(e.parentNode&&!Hr(e))t=kr(e),e=e.parentNode;else return null}}function Br(e,t){for(;;){if(F(e)&&t2),oi=ai||(qr?/Mac/.test(qr.platform):!1),si=qr?/Win/.test(qr.platform):!1,ci=/Android \d/.test(Yr),li=!!Jr&&`webkitFontSmoothing`in Jr.documentElement.style,ui=li?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function di(e){let t=e.defaultView&&e.defaultView.visualViewport;return t?{left:0,right:t.width,top:0,bottom:t.height}:{left:0,right:e.documentElement.clientWidth,top:0,bottom:e.documentElement.clientHeight}}function fi(e,t){return typeof e==`number`?e:e[t]}function pi(e){let t=e.getBoundingClientRect(),n=t.width/e.offsetWidth||1,r=t.height/e.offsetHeight||1;return{left:t.left,right:t.left+e.clientWidth*n,top:t.top,bottom:t.top+e.clientHeight*r}}function mi(e,t,n){if(!ki(t)&&t.left==0)return;let r=e.someProp(`scrollThreshold`)||0,i=e.someProp(`scrollMargin`)||5,a=e.dom.ownerDocument;for(let o=n||e.dom;o;){if(!P(o)){o=Ar(o);continue}let e=o==a.body,n=e?di(a):pi(o),s=0,c=0;if(t.topn.bottom-fi(r,`bottom`)&&(c=t.bottom-t.top>n.bottom-n.top?t.top+fi(i,`top`)-n.top:t.bottom-n.bottom+fi(i,`bottom`)),t.leftn.right-fi(r,`right`)&&(s=t.right-n.right+fi(i,`right`)),s||c){if(e)a.defaultView.scrollBy(s,c);else{let e=o.scrollLeft,n=o.scrollTop;c&&(o.scrollTop+=c),s&&(o.scrollLeft+=s);let r=o.scrollLeft-e,i=o.scrollTop-n;t={left:t.left-r,top:t.top-i,right:t.right-r,bottom:t.bottom-i}}}let l=e?`fixed`:getComputedStyle(o).position;if(/^(fixed|sticky)$/.test(l))break;o=l==`absolute`?o.offsetParent:Ar(o)}}function hi(e){let t=e.dom.getBoundingClientRect(),n=Math.max(0,t.top),r,i;for(let a=(t.left+t.right)/2,o=n+1;o=n-20){r=t,i=s.top;break}}return{refDOM:r,refTop:i,stack:gi(e.dom)}}function gi(e){let t=[],n=e.ownerDocument;for(let r=e;r&&(t.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),e!=n);r=Ar(r));return t}function _i({refDOM:e,refTop:t,stack:n}){let r=e?e.getBoundingClientRect().top:0;vi(n,r==0?0:r-t)}function vi(e,t){for(let n=0;n=s){o=Math.max(p.bottom,o),s=Math.min(p.top,s);let e=p.left>t.left?p.left-t.left:p.right=(p.left+p.right)/2));continue}}else p.top>t.top&&!c&&p.left<=t.left&&p.right>=t.left&&(c=u,l={left:Math.max(p.left,Math.min(p.right,t.left)),top:p.top});!n&&(t.left>=p.right&&t.top>=p.top||t.left>=p.left&&t.top>=p.bottom)&&(a=d+1)}}return!n&&c&&(n=c,i=l,r=0),n&&F(n)?Si(n,i):!n||r?{node:e,offset:a}:xi(n,i)}function Si(e,t){let n=e.nodeValue.length,r=document.createRange(),i;for(let a=0;a=(n.left+n.right)/2)};break}}return r.detach(),i||{node:e,offset:0}}function Ci(e,t){return e.left>=t.left-1&&e.left<=t.right+1&&e.top>=t.top-1&&e.top<=t.bottom+1}function wi(e,t){let n=e.parentNode;return n&&/^li$/i.test(n.nodeName)&&t.left(e.left+e.right)/2?1:-1}return e.docView.posFromDOM(r,i,a)}function Ei(e,t,n,r){let i=-1;for(let n=t,a=!1;n!=e.dom;){let t=e.docView.nearestDesc(n,!0),o;if(!t)return null;if(P(t.dom)&&(t.node.isBlock&&t.parent||!t.contentDOM)&&((o=t.dom.getBoundingClientRect()).width||o.height)&&(t.node.isBlock&&t.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(t.dom.nodeName)&&(!a&&o.left>r.left||o.top>r.top?i=t.posBefore:(!a&&o.right-1?i:e.docView.posFromDOM(t,n,-1)}function Di(e,t,n){let r=e.childNodes.length;if(r&&n.topt.top&&i++}let n;li&&i&&P(r)&&P(n=r.childNodes[i-1])&&n.contentEditable==`false`&&n.getBoundingClientRect().top>=t.top&&i--,r==e.dom&&i==r.childNodes.length-1&&P(r.lastChild)&&t.top>r.lastChild.getBoundingClientRect().bottom?s=e.state.doc.content.size:i!=0&&P(r)&&r.childNodes[i-1].nodeName==`BR`||(s=Ei(e,r,i,t))}s??=Ti(e,o,t);let c=e.docView.nearestDesc(o,!0);return{pos:s,inside:c?c.posAtStart-c.border:-1}}function ki(e){return e.top=0&&i==r.nodeValue.length?(e--,a=1):n<0?e--:t++,Ni(Ai(Mr(r,e,t),a),a<0)}}if(!e.state.doc.resolve(t-(a||0)).parent.inlineContent){if(a==null&&i&&(n<0||i==Lr(r))){let e=r.childNodes[i-1];if(P(e))return Pi(e.getBoundingClientRect(),!1)}if(a==null&&i=0)}if(a==null&&i&&(n<0||i==Lr(r))){let e=r.childNodes[i-1],t=F(e)?Mr(e,Lr(e)-+!o):P(e)&&(e.nodeName!=`BR`||!e.nextSibling)?e:null;if(t)return Ni(Ai(t,1),!1)}if(a==null&&i=0)}function Ni(e,t){if(e.width==0)return e;let n=t?e.left:e.right;return{top:e.top,bottom:e.bottom,left:n,right:n}}function Pi(e,t){if(e.height==0)return e;let n=t?e.top:e.bottom;return{top:n,bottom:n,left:e.left,right:e.right}}function Fi(e,t,n){let r=e.state,i=e.root.activeElement;r!=t&&e.updateState(t),i!=e.dom&&e.focus();try{return n()}finally{r!=t&&e.updateState(r),i!=e.dom&&i&&i.focus()}}function Ii(e,t,n){let r=t.selection,i=n==`up`?r.$from:r.$to;return Fi(e,t,()=>{let{node:t}=e.docView.domFromPos(i.pos,n==`up`?-1:1);for(;;){let n=e.docView.nearestDesc(t,!0);if(!n)break;if(n.node.isBlock){t=n.contentDOM||n.dom;break}t=n.dom.parentNode}let r=Mi(e,i.pos,1);for(let e=t.firstChild;e;e=e.nextSibling){let t;if(P(e))t=e.getClientRects();else if(F(e))t=Mr(e,0,e.nodeValue.length).getClientRects();else continue;for(let e=0;ei.top+1&&(n==`up`?r.top-i.top>(i.bottom-r.top)*2:i.bottom-r.bottom>(r.bottom-i.top)*2))return!1}}return!0})}var Li=/[\u0590-\u08ac]/;function Ri(e,t,n){let{$head:r}=t.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,a=!i,o=i==r.parent.content.size,s=e.domSelection();return s?!Li.test(r.parent.textContent)||!s.modify?n==`left`||n==`backward`?a:o:Fi(e,t,()=>{let{focusNode:t,focusOffset:i,anchorNode:a,anchorOffset:o}=e.domSelectionRange(),c=s.caretBidiLevel;s.modify(`move`,n,`character`);let l=r.depth?e.docView.domAfterPos(r.before()):e.dom,{focusNode:u,focusOffset:d}=e.domSelectionRange(),f=u&&!Rr(l,u)||t==u&&i==d;try{s.collapse(a,o),t&&(t!=a||i!=o)&&s.extend&&s.extend(t,i)}catch{}return c!=null&&(s.caretBidiLevel=c),f}):r.pos==r.start()||r.pos==r.end()}var zi=null,Bi=null,Vi=!1;function Hi(e,t,n){return zi==t&&Bi==n?Vi:(zi=t,Bi=n,Vi=n==`up`||n==`down`?Ii(e,t,n):Ri(e,t,n))}var Ui=0,Wi=1,Gi=2,Ki=3,qi=class{constructor(e,t,n,r){this.parent=e,this.children=t,this.dom=n,this.contentDOM=r,this.dirty=Ui,n.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,n){return!1}matchesHack(e){return!1}parseRule(e){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;tkr(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM)){let n=e.compareDocumentPosition(this.contentDOM);r=n&16?t>Array.from(e.childNodes).findIndex(e=>e.contains(this.contentDOM)):!(n&4)}else if(this.dom.firstChild){if(t==0)for(let t=e;;t=t.parentNode){if(t==this.dom){r=!1;break}if(t.previousSibling)break}if(r==null&&t==e.childNodes.length)for(let t=e;;t=t.parentNode){if(t==this.dom){r=!0;break}if(t.nextSibling)break}}return r??n>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let n=!0,r=e;r;r=r.parentNode){let i=this.getDesc(r),a;if(i&&(!t||i.node)){if(n&&(a=i.nodeDOM)&&!(P(a)?Rr(a,e):a==e))n=!1;else return i}}}getDesc(e){let t=e.pmViewDesc;for(let e=t;e;e=e.parent)if(e==this)return t}posFromDOM(e,t,n){for(let r=e;r;r=r.parentNode){let i=this.getDesc(r);if(i)return i.localPosFromDOM(e,t,n)}return-1}descAt(e){for(let t=0,n=0;te){r=e-t;break}t=a}if(r)return this.children[n].domFromPos(r-this.children[n].border,t);for(;n>0;n--){let e=this.children[n-1];if(e.size||!(e instanceof ea||e instanceof Ji&&e.side>=0))break}if(t<=0){let e,r=!0;for(;e=n?this.children[n-1]:null,e&&e.dom.parentNode!=this.contentDOM;n--,r=!1);return e&&t&&r&&!e.border&&!e.domAtom?e.domFromPos(e.size,t):{node:this.contentDOM,offset:e?kr(e.dom)+1:0}}{let e,r=!0;for(;e=n=i&&t<=s-n.border&&n.node&&n.contentDOM&&this.contentDOM.contains(n.contentDOM))return n.parseRange(e,t,i);e=a;for(let t=o;t>0;t--){let n=this.children[t-1];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(1)){r=kr(n.dom)+1;break}e-=n.size}r==-1&&(r=0)}if(r>-1&&(s>t||o==this.children.length-1)){t=s;for(let e=o+1;es&&at){let e=o;o=s,s=e}let n=document.createRange();n.setEnd(s.node,s.offset),n.setStart(o.node,o.offset),c.removeAllRanges(),c.addRange(n)}}ignoreMutation(e){return!this.contentDOM&&e.type!=`selection`}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let n=0,r=0;r=n:en){let r=n+i.border,o=a-i.border;if(e>=r&&t<=o){this.dirty=e==n||t==a?Gi:Wi,e==r&&t==o&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=Ki:i.markDirty(e-r,t-r);return}i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?Gi:Ki}n=a}this.dirty=Gi}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let n=e==1?Gi:Wi;t.dirty{if(!i)return r;if(i.parent)return i.parent.posBeforeChild(i)})),!t.type.spec.raw){let e=P(a)?a:document.createElement(`span`);e!=a&&(e.appendChild(a),a=e),e.hasAttribute(`contenteditable`)||(e.contentEditable=`false`),e.classList.add(`ProseMirror-widget`)}super(e,[],a,null),this.widget=t,this.widget=t,i=this}matchesWidget(e){return this.dirty==Ui&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return t?t(e):!1}ignoreMutation(e){return e.type!=`selection`||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}},Yi=class extends qi{constructor(e,t,n,r){super(e,[],t,null),this.textDOM=n,this.text=r}get size(){return this.text.length}localPosFromDOM(e,t){return e==this.textDOM?this.posAtStart+t:this.posAtStart+(t?this.size:0)}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type===`characterData`&&e.target.nodeValue==e.oldValue}},Xi=class e extends qi{constructor(e,t,n,r,i){super(e,[],n,r),this.mark=t,this.spec=i}static create(t,n,r,i){let a=i.nodeViews[n.type.name],o=a&&a(n,i,r);return o&&o.dom||(o=Je.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new e(t,n,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty&Ki||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=Ki&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=Ui){let e=this.parent;for(;!e.node;)e=e.parent;e.dirty0&&(a=_a(a,0,t,r));for(let e=0;e{if(!c)return o;if(c.parent)return c.parent.posBeforeChild(c)},r,i),u=l&&l.dom,d=l&&l.contentDOM;if(n.isText){if(!u)u=document.createTextNode(n.text);else if(!F(u))throw RangeError(`Text must be rendered as a DOM text node`)}else if(!u){let e=Je.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs);({dom:u,contentDOM:d}=e)}!d&&!n.isText&&u.nodeName!=`BR`&&(u.hasAttribute(`contenteditable`)||(u.contentEditable=`false`),n.type.spec.draggable&&(u.draggable=!0));let f=u;return u=ca(u,r,n),l?c=new ta(t,n,r,i,u,d||null,f,l):n.isText?new $i(t,n,r,i,u,f):new e(t,n,r,i,u,d||null,f)}parseRule(e){if(this.node.type.spec.reparseInView)return null;let t={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace==`pre`&&(t.preserveWhitespace=`full`),!this.contentDOM)t.getContent=()=>this.node.content;else if(!this.contentLost)t.contentElement=this.contentDOM;else{for(let e=this.children.length-1;e>=0;e--){let n=this.children[e];if(this.dom.contains(n.dom.parentNode)){t.contentElement=n.dom.parentNode;break}}if(!t.contentElement){let n=e&&e.find(t=>P(t)&&e.indexOf(t.parentNode)<0&&this.dom.contains(t));n?t.contentElement=n:t.getContent=()=>c.empty}}return t}matchesNode(e,t,n){return this.dirty==Ui&&e.eq(this.node)&&la(t,this.outerDeco)&&n.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return+!this.node.isLeaf}updateChildren(e,t){let n=this.node.inlineContent,r=t,i=e.composing?this.localCompositionInfo(e,t):null,a=i&&i.pos>-1?i:null,o=i&&i.pos<0,s=new da(this,a&&a.node,e),c=this.node.inlineContent,l=c&&this.node.isBlock;ma(this.node,this.innerDeco,(t,i,a)=>{t.spec.marks?s.syncToMarks(t.spec.marks,n,e,i):t.type.side>=0&&!a&&s.syncToMarks(i==this.node.childCount?f.none:this.node.child(i).marks,n,e,i),s.placeWidget(t,e,r)},(t,a,u,d)=>{s.syncToMarks(t.marks,n,e,d),l&&t.isAtom&&!t.isText&&s.addHackNode(`IMG`,s.top);let f;s.findNodeMatch(t,a,u,d)||o&&e.state.selection.from>r&&e.state.selection.to-1&&s.updateNodeAt(t,a,u,f,e)||s.updateNextNode(t,a,u,e,d,r)||s.addNode(t,a,u,e,r),r+=t.nodeSize,c&&(l=t.isAtom&&!t.isText)}),s.syncToMarks([],n,e,0),this.node.isTextblock&&s.addTextblockHacks(),s.destroyRest(),(s.changed||this.dirty==Gi)&&(a&&this.protectLocalComposition(e,a),na(this.contentDOM,this.children,e),ai&&ha(this.dom))}localCompositionInfo(e,t){let{from:n,to:r}=e.state.selection;if(!(e.state.selection instanceof A)||nt+this.node.content.size)return null;let i=e.input.compositionNode;if(!i||!this.dom.contains(i.parentNode))return null;if(this.node.inlineContent){let e=i.nodeValue,a=ga(this.node.content,e,n-t,r-t);return a<0?null:{node:i,pos:a,text:e}}return{node:i,pos:-1,text:``}}protectLocalComposition(e,{node:t,pos:n,text:r}){if(this.getDesc(t))return;let i=t;for(;i.parentNode!=this.contentDOM;i=i.parentNode){for(;i.previousSibling;)i.parentNode.removeChild(i.previousSibling);for(;i.nextSibling;)i.parentNode.removeChild(i.nextSibling);i.pmViewDesc&&(i.pmViewDesc=void 0)}let a=new Yi(this,i,t,r);e.input.compositionNodes.push(a),this.children=_a(this.children,n,n+r.length,e,a)}update(e,t,n,r){return this.dirty==Ki||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,n,r),!0)}updateInner(e,t,n,r){this.updateOuterDeco(t),this.node=e,this.innerDeco=n,this.contentDOM&&this.updateChildren(r,this.posAtStart),this.dirty=Ui}updateOuterDeco(e){if(la(e,this.outerDeco))return;let t=!P(this.nodeDOM),n=this.dom;this.dom=oa(this.dom,this.nodeDOM,aa(this.outerDeco,this.node,t),aa(e,this.node,t)),this.dom!=n&&(n.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){P(this.nodeDOM)&&(this.nodeDOM.classList.add(`ProseMirror-selectednode`),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){P(this.nodeDOM)&&(this.nodeDOM.classList.remove(`ProseMirror-selectednode`),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute(`draggable`))}get domAtom(){return this.node.isAtom}};function Qi(e,t,n,r,i){ca(r,t,e);let a=new Zi(void 0,e,t,n,r,r,r);return a.contentDOM&&a.updateChildren(i,0),a}var $i=class e extends Zi{constructor(e,t,n,r,i,a){super(e,t,n,r,i,null,a)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,n,r){return this.dirty==Ki||this.dirty!=Ui&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=Ui||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,r.trackWrites==this.nodeDOM&&(r.trackWrites=null)),this.node=e,this.dirty=Ui,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,n){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,n)}ignoreMutation(e){return e.type!=`characterData`&&e.type!=`selection`}slice(t,n,r){let i=this.node.cut(t,n),a=document.createTextNode(i.text);return new e(this.parent,i,this.outerDeco,this.innerDeco,a,a)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=Ki)}get domAtom(){return!1}isText(e){return this.node.text==e}},ea=class extends qi{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Ui&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName==`IMG`}},ta=class extends Zi{constructor(e,t,n,r,i,a,o,s){super(e,t,n,r,i,a,o),this.spec=s}update(e,t,n,r){if(this.dirty==Ki)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let i=this.spec.update(e,t,n);return i&&this.updateInner(e,t,n,r),i}return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,n,r)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,n,r){this.spec.setSelection?this.spec.setSelection(e,t,n.root):super.setSelection(e,t,n,r)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}};function na(e,t,n){let r=e.firstChild,i=!1;for(let a=0;a>1,o=Math.min(a,e.length);for(;i-1)i>this.index&&(this.changed=!0,this.destroyBetween(this.index,i)),this.top=this.top.children[this.index];else{let r=Xi.create(this.top,e[a],t,n);this.top.children.splice(this.index,0,r),this.top=r,this.changed=!0}this.index=0,a++}}findNodeMatch(e,t,n,r){let i=-1,a;if(r>=this.preMatch.index&&(a=this.preMatch.matches[r-this.preMatch.index]).parent==this.top&&a.matchesNode(e,t,n))i=this.top.children.indexOf(a,this.index);else for(let r=this.index,a=Math.min(this.top.children.length,r+5);r0;){let s;for(;;)if(r){let e=n.children[r-1];if(e instanceof Xi)n=e,r=e.children.length;else{s=e,r--;break}}else if(n==t)break outer;else r=n.parent.children.indexOf(n),n=n.parent;let c=s.node;if(c){if(c!=e.child(i-1))break;--i,a.set(s,i),o.push(s)}}return{index:i,matched:a,matches:o.reverse()}}function pa(e,t){return e.type.side-t.type.side}function ma(e,t,n,r){let i=t.locals(e),a=0;if(i.length==0){for(let n=0;na;)s.push(i[o++]);let m=a+f.nodeSize;if(f.isText){let e=m;o!e.inline):s.slice();r(f,h,t.forChild(a,f),p),a=m}}function ha(e){if(e.nodeName==`UL`||e.nodeName==`OL`){let t=e.style.cssText;e.style.cssText=t+`; list-style: square !important`,window.getComputedStyle(e).listStyle,e.style.cssText=t}}function ga(e,t,n,r){for(let i=0,a=0;i=n){if(a>=r&&c.slice(r-t.length-s,r-s)==t)return r-t.length;let e=s=0&&e+t.length+s>=n)return s+e;if(n==r&&c.length>=r+t.length-s&&c.slice(r-s,r-s+t.length)==t)return r}}return-1}function _a(e,t,n,r,i){let a=[];for(let o=0,s=0;o=n||u<=t?a.push(c):(ln&&a.push(c.slice(n-l,c.size,r)))}return a}function va(e,t=null){let n=e.domSelectionRange(),r=e.state.doc;if(!n.focusNode)return null;let i=e.docView.nearestDesc(n.focusNode),a=i&&i.size==0,o=e.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(o<0)return null;let s=r.resolve(o),c,l;if(Ur(n)){for(c=o;i&&!i.node;)i=i.parent;if(i&&i.node.isAtom&&j.isSelectable(i.node)&&i.parent&&!(i.node.isInline&&Vr(n.focusNode,n.focusOffset,i.dom))){let e=i.posBefore;l=new j(o==e?s:r.resolve(e))}else if(ti&&t==`key`&&o>e.state.selection.to&&P(n.focusNode)&&n.focusOffset==n.focusNode.childNodes.length&&i&&i.posAtStart>e.state.selection.to)for(let e=n.focusNode;;e=e.parentNode){if(getComputedStyle(e).overflow!=`visible`){l=k.findFrom(r.resolve(i.posAtStart),1);break}if(e==i.dom||e.nextSibling||!e.parentNode||!P(e.parentNode))break}}else{if(n instanceof e.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let t=o,i=o;for(let r=0;r{(n.anchorNode!=r||n.anchorOffset!=i)&&(t.removeEventListener(`selectionchange`,e.input.hideSelectionGuard),setTimeout(()=>{(!ya(e)||e.state.selection.visible)&&e.dom.classList.remove(`ProseMirror-hideselection`)},20))})}function Ea(e){let t=e.domSelection();if(!t)return;let n=e.cursorWrapper.dom,r=n.nodeName==`IMG`;r?t.collapse(n.parentNode,kr(n)+1):t.collapse(n,0),!r&&!e.state.selection.visible&&$r&&ei<=11&&(n.disabled=!0,n.disabled=!1)}function Da(e,t){if(t instanceof j){let n=e.docView.descAt(t.from);n!=e.lastSelectedViewDesc&&(Oa(e),n&&n.selectNode(),e.lastSelectedViewDesc=n)}else Oa(e)}function Oa(e){e.lastSelectedViewDesc&&=(e.lastSelectedViewDesc.parent&&e.lastSelectedViewDesc.deselectNode(),void 0)}function ka(e,t,n,r){return e.someProp(`createSelectionBetween`,r=>r(e,t,n))||A.between(t,n,r)}function Aa(e){return e.editable&&!e.hasFocus()?!1:ja(e)}function ja(e){let t=e.domSelectionRange();if(!t.anchorNode)return!1;try{return Rr(e.dom,t.anchorNode)&&(e.editable||Rr(e.dom,t.focusNode))}catch{return!1}}function Ma(e){let t=e.docView.domFromPos(e.state.selection.anchor,0),n=e.domSelectionRange();return Pr(t.node,t.offset,n.anchorNode,n.anchorOffset)}function Na(e,t){let{$anchor:n,$head:r}=e.selection,i=t>0?n.max(r):n.min(r),a=i.parent.inlineContent?i.depth?e.doc.resolve(t>0?i.after():i.before()):null:i;return a&&k.findFrom(a,t)}function Pa(e,t){return e.dispatch(e.state.tr.setSelection(t).scrollIntoView()),!0}function Fa(e,t,n){let r=e.state.selection;if(r instanceof A){if(n.indexOf(`s`)>-1){let{$head:n}=r,i=n.textOffset?null:t<0?n.nodeBefore:n.nodeAfter;if(!i||i.isText||!i.isLeaf)return!1;let a=e.state.doc.resolve(n.pos+i.nodeSize*(t<0?-1:1));return Pa(e,new A(r.$anchor,a))}if(!r.empty)return!1;if(e.endOfTextblock(t>0?`forward`:`backward`)){let n=Na(e.state,t);return n&&n instanceof j?Pa(e,n):!1}if(!oi||n.indexOf(`m`)<0){let n=r.$head,i=n.textOffset?null:t<0?n.nodeBefore:n.nodeAfter,a;if(!i||i.isText)return!1;let o=t<0?n.pos-i.nodeSize:n.pos;return i.isAtom||(a=e.docView.descAt(o))&&!a.contentDOM?j.isSelectable(i)?Pa(e,new j(t<0?e.state.doc.resolve(n.pos-i.nodeSize):n)):Pa(e,new A(e.state.doc.resolve(t<0?o:o+i.nodeSize))):!1}}else if(r instanceof j&&r.node.isInline)return Pa(e,new A(t>0?r.$to:r.$from));else{let n=Na(e.state,t);return n?Pa(e,n):!1}}function Ia(e,t){let n=e.pmViewDesc;return n?n.size==0&&(t<0||e.nextSibling||e.nodeName!=`BR`):P(e)&&e.contentEditable==`false`}function La(e,t){return t<0?Ra(e):za(e)}function Ra(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let i,a,o=!1;for(ti&&P(n)&&r0){if(!P(n))break;let e=n.childNodes[r-1];if(Ia(e,-1))i=n,a=--r;else if(F(e))n=e,r=n.nodeValue.length;else break}else if(Ba(n))break;else{let t=n.previousSibling;for(;t&&Ia(t,-1);)i=n.parentNode,a=kr(t),t=t.previousSibling;if(t)n=t,r=Lr(n);else{if(n=n.parentNode,n==e.dom)break;r=0}}o?Ua(e,n,r):i&&Ua(e,i,a)}function za(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let i=Lr(n),a,o;for(;;)if(r{e.state==a&&ba(e)},50)}function Wa(e,t){let n=e.state.doc.resolve(t);if(!(I||si)&&n.parent.inlineContent){let r=e.coordsAtPos(t);if(t>n.start()){let n=e.coordsAtPos(t-1),i=(n.top+n.bottom)/2;if(i>r.top&&i1)return n.leftr.top&&i1)return n.left>r.left?`ltr`:`rtl`}}let r=e.dom;for(let t=n.depth;t>0;t--)if(n.node(t).isBlock){r=e.nodeDOM(n.before(t))||r;break}return getComputedStyle(r).direction==`rtl`?`rtl`:`ltr`}function Ga(e,t,n){let r=e.state.selection;if(r instanceof A&&!r.empty||n.indexOf(`s`)>-1||oi&&n.indexOf(`m`)>-1)return!1;let{$from:i,$to:a}=r;if(!i.parent.inlineContent||e.endOfTextblock(t<0?`up`:`down`)){let n=Na(e.state,t);if(n&&n instanceof j)return Pa(e,n)}if(!i.parent.inlineContent){let n=t<0?i:a,o=r instanceof Cn?k.near(n,t):k.findFrom(n,t);return o?Pa(e,o):!1}return!1}function Ka(e,t){if(!(e.state.selection instanceof A))return!0;let{$head:n,$anchor:r,empty:i}=e.state.selection;if(!n.sameParent(r))return!0;if(!i)return!1;if(e.endOfTextblock(t>0?`forward`:`backward`))return!0;let a=!n.textOffset&&(t<0?n.nodeBefore:n.nodeAfter);if(a&&!a.isText){let r=e.state.tr;return t<0?r.delete(n.pos-a.nodeSize,n.pos):r.delete(n.pos,n.pos+a.nodeSize),e.dispatch(r),!0}return!1}function qa(e,t,n){e.domObserver.stop(),t.contentEditable=n,e.domObserver.start()}function Ja(e){if(!ii||e.state.selection.$head.parentOffset>0)return!1;let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(t&&P(t)&&n==0&&t.firstChild&&P(t.firstChild)&&t.firstChild.contentEditable==`false`){let n=t.firstChild;qa(e,n,`true`),setTimeout(()=>qa(e,n,`false`),20)}return!1}function Ya(e){let t=``;return e.ctrlKey&&(t+=`c`),e.metaKey&&(t+=`m`),e.altKey&&(t+=`a`),e.shiftKey&&(t+=`s`),t}function Xa(e,t){let n=t.keyCode,r=Ya(t);if(n==8||oi&&n==72&&r==`c`)return Ka(e,-1)||La(e,-1);if(n==46&&!t.shiftKey||oi&&n==68&&r==`c`)return Ka(e,1)||La(e,1);if(n==13||n==27)return!0;if(n==37||oi&&n==66&&r==`c`){let t=n==37?Wa(e,e.state.selection.from)==`ltr`?-1:1:-1;return Fa(e,t,r)||La(e,t)}if(n==39||oi&&n==70&&r==`c`){let t=n==39?Wa(e,e.state.selection.from)==`ltr`?1:-1:1;return Fa(e,t,r)||La(e,t)}return n==38||oi&&n==80&&r==`c`?Ga(e,-1,r)||La(e,-1):n==40||oi&&n==78&&r==`c`?Ja(e)||Ga(e,1,r)||La(e,1):!(r!=(oi?`m`:`c`)||n!=66&&n!=73&&n!=89&&n!=90)}function Za(e,t){e.someProp(`transformCopied`,n=>{t=n(t,e)});let n=[],{content:r,openStart:i,openEnd:a}=t;for(;i>1&&a>1&&r.childCount==1&&r.firstChild.childCount==1;){i--,a--;let e=r.firstChild;n.push(e.type.name,e.attrs==e.type.defaultAttrs?null:e.attrs),r=e.content}let o=e.someProp(`clipboardSerializer`)||Je.fromSchema(e.state.schema),s=so(),c=s.createElement(`div`);c.appendChild(o.serializeFragment(r,{document:s}));let l=c.firstChild,u,d=0;for(;l&&P(l)&&(u=oo[l.nodeName.toLowerCase()]);){for(let e=u.length-1;e>=0;e--){let t=s.createElement(u[e]);for(;c.firstChild;)t.appendChild(c.firstChild);c.appendChild(t),d++}l=c.firstChild}return l&&P(l)&&l.setAttribute(`data-pm-slice`,`${i} ${a}${d?` -${d}`:``} ${JSON.stringify(n)}`),{dom:c,text:e.someProp(`clipboardTextSerializer`,n=>n(t,e))||t.content.textBetween(0,t.content.size,` +`).scrollIntoView()),!0)};function nr(e){for(let t=0;t{let{$head:n,$anchor:r}=e.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let i=n.node(-1),a=n.indexAfter(-1),o=nr(i.contentMatchAt(a));if(!o||!i.canReplaceWith(a,a,o))return!1;if(t){let r=n.after(),i=e.tr.replaceWith(r,r,o.createAndFill());i.setSelection(k.near(i.doc.resolve(r),1)),t(i.scrollIntoView())}return!0},ir=(e,t)=>{let n=e.selection,{$from:r,$to:i}=n;if(n instanceof Cn||r.parent.inlineContent||i.parent.inlineContent)return!1;let a=nr(i.parent.contentMatchAt(i.indexAfter()));if(!a||!a.isTextblock)return!1;if(t){let n=(!r.parentOffset&&i.index(){let{$cursor:n}=e.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let r=n.before();if(Vt(e.doc,r))return t&&t(e.tr.split(r).scrollIntoView()),!0}let r=n.blockRange(),i=r&&kt(r);return i!=null&&(t&&t(e.tr.lift(r,i).scrollIntoView()),!0)};function or(e){return(t,n)=>{if(t.selection instanceof j&&t.selection.node.isBlock){let{$from:e}=t.selection;return!e.parentOffset||!Vt(t.doc,e.pos)?!1:(n&&n(t.tr.split(e.pos).scrollIntoView()),!0)}if(!t.selection.$from.depth)return!1;let r=t.tr;!t.selection.empty&&(t.selection instanceof A||t.selection instanceof Cn)&&r.deleteSelection();let{$from:i}=r.selection,a=r.steps.length,o=[],s,c,l=!1,u=!1;for(let t=i.depth;;t--)if(i.node(t).isBlock){l=i.end(t)==i.pos+(i.depth-t),u=i.start(t)==i.pos-(i.depth-t),c=nr(i.node(t-1).contentMatchAt(i.indexAfter(t-1)));let n=e&&e(i.parent,l,i);o.unshift(n||(l&&c?{type:c}:null)),s=t;break}else{if(t==1)return!1;o.unshift(null)}let d=i.pos,f=Vt(r.doc,d,o.length,o);if(f||=(o[0]=c?{type:c}:null,Vt(r.doc,d,o.length,o)),!f)return!1;if(r.split(d,o.length,o),!l&&u&&i.node(s).type!=c){let e=r.mapping.slice(a),t=e.map(i.before(s)),n=r.doc.resolve(t);c&&i.node(s-1).canReplaceWith(n.index(),n.index()+1,c)&&r.setNodeMarkup(e.map(i.before(s)),c)}return n&&n(r.scrollIntoView()),!0}}var sr=or(),cr=(e,t)=>{let{$from:n,to:r}=e.selection,i,a=n.sharedDepth(r);return a!=0&&(i=n.before(a),t&&t(e.tr.setSelection(j.create(e.doc,i))),!0)},lr=(e,t)=>(t&&t(e.tr.setSelection(new Cn(e.doc))),!0);function ur(e,t,n){let r=t.nodeBefore,i=t.nodeAfter,a=t.index();return!r||!i||!r.type.compatibleContent(i.type)?!1:!r.content.size&&t.parent.canReplace(a-1,a)?(n&&n(e.tr.delete(t.pos-r.nodeSize,t.pos).scrollIntoView()),!0):!t.parent.canReplace(a,a+1)||!(i.isTextblock||Ut(e.doc,t.pos))?!1:(n&&n(e.tr.join(t.pos).scrollIntoView()),!0)}function dr(e,t,n,r){let i=t.nodeBefore,a=t.nodeAfter,o,s,l=i.type.spec.isolating||a.type.spec.isolating;if(!l&&ur(e,t,n))return!0;let u=!l&&t.parent.canReplace(t.index(),t.index()+1);if(u&&(o=(s=i.contentMatchAt(i.childCount)).findWrapping(a.type))&&s.matchType(o[0]||a.type).validEnd){if(n){let r=t.pos+a.nodeSize,s=c.empty;for(let e=o.length-1;e>=0;e--)s=c.from(o[e].create(null,s));s=c.from(i.copy(s));let l=e.tr.step(new Ct(t.pos-1,r,t.pos,r,new m(s,1,0),o.length,!0)),u=l.doc.resolve(r+2*o.length);u.nodeAfter&&u.nodeAfter.type==i.type&&Ut(l.doc,u.pos)&&l.join(u.pos),n(l.scrollIntoView())}return!0}let d=a.type.spec.isolating||r>0&&l?null:k.findFrom(t,1),f=d&&d.$from.blockRange(d.$to),p=f&&kt(f);if(p!=null&&p>=t.depth)return n&&n(e.tr.lift(f,p).scrollIntoView()),!0;if(u&&Gn(a,`start`,!0)&&Gn(i,`end`)){let r=i,o=[];for(;o.push(r),!r.isTextblock;)r=r.lastChild;let s=a,l=1;for(;!s.isTextblock;s=s.firstChild)l++;if(r.canReplace(r.childCount,r.childCount,s.content)){if(n){let r=c.empty;for(let e=o.length-1;e>=0;e--)r=c.from(o[e].copy(r));n(e.tr.step(new Ct(t.pos-o.length,t.pos+a.nodeSize,t.pos+l,t.pos+a.nodeSize-l,new m(r,o.length,0),0,!0)).scrollIntoView())}return!0}}return!1}function fr(e){return function(t,n){let r=t.selection,i=e<0?r.$from:r.$to,a=i.depth;for(;i.node(a).isInline;){if(!a)return!1;a--}return i.node(a).isTextblock?(n&&n(t.tr.setSelection(A.create(t.doc,e<0?i.start(a):i.end(a)))),!0):!1}}var pr=fr(-1),mr=fr(1);function hr(e,t=null){return function(n,r){let{$from:i,$to:a}=n.selection,o=i.blockRange(a),s=o&&jt(o,e,t);return s?(r&&r(n.tr.wrap(o,s).scrollIntoView()),!0):!1}}function gr(e,t=null){return function(n,r){let i=!1;for(let r=0;r{if(i)return!1;if(r.isTextblock&&!r.hasMarkup(e,t)){if(r.type==e)i=!0;else{let t=n.doc.resolve(a),r=t.index();i=t.parent.canReplaceWith(r,r+1,e)}}})}if(!i)return!1;if(r){let i=n.tr;for(let r=0;r=2&&t.$from.node(t.depth-1).type.compatibleContent(n)&&t.startIndex==0){if(t.$from.index(t.depth-1)==0)return!1;let e=o.resolve(t.start-2);a=new re(e,e,t.depth),t.endIndex=0;e--)a=c.from(n[e].type.create(n[e].attrs,a));e.step(new Ct(t.start-(r?2:0),t.end,t.start,t.end,new m(a,0,0),n.length,!0));let o=0;for(let e=0;et.childCount>0&&t.firstChild.type==e);return a?n?r.node(a.depth-1).type==e?Er(t,n,e,a):Dr(t,n,a):!0:!1}}function Er(e,t,n,r){let i=e.tr,a=r.end,o=r.$to.end(r.depth);aa;t--)e-=i.child(t).nodeSize,r.delete(e-1,e+1);let a=r.doc.resolve(n.start),o=a.nodeAfter;if(r.mapping.map(n.end)!=n.start+a.nodeAfter.nodeSize)return!1;let s=n.startIndex==0,l=n.endIndex==i.childCount,u=a.node(-1),d=a.index(-1);if(!u.canReplace(d+ +!s,d+1,o.content.append(l?c.empty:c.from(i))))return!1;let f=a.pos,p=f+o.nodeSize;return r.step(new Ct(f-+!!s,p+ +!!l,f+1,p-1,new m((s?c.empty:c.from(i.copy(c.empty))).append(l?c.empty:c.from(i.copy(c.empty))),+!s,+!l),+!s)),t(r.scrollIntoView()),!0}function Or(e){return function(t,n){let{$from:r,$to:i}=t.selection,a=r.blockRange(i,t=>t.childCount>0&&t.firstChild.type==e);if(!a)return!1;let o=a.startIndex;if(o==0)return!1;let s=a.parent,l=s.child(o-1);if(l.type!=e)return!1;if(n){let r=l.lastChild&&l.lastChild.type==s.type,i=c.from(r?e.create():null),o=new m(c.from(e.create(null,c.from(s.type.create(null,i)))),r?3:1,0),u=a.start,d=a.end;n(t.tr.step(new Ct(u-(r?3:1),d,u,d,o,1,!0)).scrollIntoView())}return!0}}var kr=function(e){for(var t=0;;t++)if(e=e.previousSibling,!e)return t},Ar=function(e){let t=e.assignedSlot||e.parentNode;return t&&t.nodeType==11?t.host:t},jr=null,Mr=function(e,t,n){let r=jr||=document.createRange();return r.setEnd(e,n??e.nodeValue.length),r.setStart(e,t||0),r},Nr=function(){jr=null},Pr=function(e,t,n,r){return n&&(Ir(e,t,n,r,-1)||Ir(e,t,n,r,1))},Fr=/^(img|br|input|textarea|hr)$/i;function Ir(e,t,n,r,i){for(;;){if(e==n&&t==r)return!0;if(t==(i<0?0:Lr(e))){let n=e.parentNode;if(!n||!P(n)||Hr(e)||Fr.test(e.nodeName)||e.contentEditable==`false`)return!1;t=kr(e)+(i<0?0:1),e=n}else if(P(e)){let n=e.childNodes[t+(i<0?-1:0)];if(P(n)&&n.contentEditable==`false`){if(n.pmViewDesc?.ignoreForSelection)t+=i;else return!1}else e=n,t=i<0?Lr(e):0}else return!1}}function Lr(e){return e.nodeType==3?e.nodeValue.length:e.childNodes.length}function P(e){return e.nodeType==1}function F(e){return e.nodeType==3}function Rr(e,t){return t?e.contains(P(t)?t:t.parentNode):!1}function zr(e,t){for(;;){if(F(e)&&t)return e;if(P(e)&&t>0){if(e.contentEditable==`false`)return null;e=e.childNodes[t-1],t=Lr(e)}else if(e.parentNode&&!Hr(e))t=kr(e),e=e.parentNode;else return null}}function Br(e,t){for(;;){if(F(e)&&t2),si=oi||(qr?/Mac/.test(qr.platform):!1),ci=qr?/Win/.test(qr.platform):!1,li=/Android \d/.test(Yr),ui=!!Jr&&`webkitFontSmoothing`in Jr.documentElement.style,di=ui?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function fi(e){let t=e.defaultView&&e.defaultView.visualViewport;return t?{left:0,right:t.width,top:0,bottom:t.height}:{left:0,right:e.documentElement.clientWidth,top:0,bottom:e.documentElement.clientHeight}}function pi(e,t){return typeof e==`number`?e:e[t]}function mi(e){let t=e.getBoundingClientRect(),n=t.width/e.offsetWidth||1,r=t.height/e.offsetHeight||1;return{left:t.left,right:t.left+e.clientWidth*n,top:t.top,bottom:t.top+e.clientHeight*r}}function hi(e,t,n){if(!Ai(t)&&t.left==0)return;let r=e.someProp(`scrollThreshold`)||0,i=e.someProp(`scrollMargin`)||5,a=e.dom.ownerDocument;for(let o=n||e.dom;o;){if(!P(o)){o=Ar(o);continue}let e=o==a.body,n=e?fi(a):mi(o),s=0,c=0;if(t.topn.bottom-pi(r,`bottom`)&&(c=t.bottom-t.top>n.bottom-n.top?t.top+pi(i,`top`)-n.top:t.bottom-n.bottom+pi(i,`bottom`)),t.leftn.right-pi(r,`right`)&&(s=t.right-n.right+pi(i,`right`)),s||c){if(e)a.defaultView.scrollBy(s,c);else{let e=o.scrollLeft,n=o.scrollTop;c&&(o.scrollTop+=c),s&&(o.scrollLeft+=s);let r=o.scrollLeft-e,i=o.scrollTop-n;t={left:t.left-r,top:t.top-i,right:t.right-r,bottom:t.bottom-i}}}let l=e?`fixed`:getComputedStyle(o).position;if(/^(fixed|sticky)$/.test(l))break;o=l==`absolute`?o.offsetParent:Ar(o)}}function gi(e){let t=e.dom.getBoundingClientRect(),n=Math.max(0,t.top),r,i;for(let a=(t.left+t.right)/2,o=n+1;o=n-20){r=t,i=s.top;break}}return{refDOM:r,refTop:i,stack:_i(e.dom)}}function _i(e){let t=[],n=e.ownerDocument;for(let r=e;r&&(t.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),e!=n);r=Ar(r));return t}function vi({refDOM:e,refTop:t,stack:n}){let r=e?e.getBoundingClientRect().top:0;yi(n,r==0?0:r-t)}function yi(e,t){for(let n=0;n=s){o=Math.max(p.bottom,o),s=Math.min(p.top,s);let e=p.left>t.left?p.left-t.left:p.right=(p.left+p.right)/2));continue}}else p.top>t.top&&!c&&p.left<=t.left&&p.right>=t.left&&(c=u,l={left:Math.max(p.left,Math.min(p.right,t.left)),top:p.top});!n&&(t.left>=p.right&&t.top>=p.top||t.left>=p.left&&t.top>=p.bottom)&&(a=d+1)}}return!n&&c&&(n=c,i=l,r=0),n&&F(n)?Ci(n,i):!n||r?{node:e,offset:a}:Si(n,i)}function Ci(e,t){let n=e.nodeValue.length,r=document.createRange(),i;for(let a=0;a=(n.left+n.right)/2)};break}}return r.detach(),i||{node:e,offset:0}}function wi(e,t){return e.left>=t.left-1&&e.left<=t.right+1&&e.top>=t.top-1&&e.top<=t.bottom+1}function Ti(e,t){let n=e.parentNode;return n&&/^li$/i.test(n.nodeName)&&t.left(e.left+e.right)/2?1:-1}return e.docView.posFromDOM(r,i,a)}function Di(e,t,n,r){let i=-1;for(let n=t,a=!1;n!=e.dom;){let t=e.docView.nearestDesc(n,!0),o;if(!t)return null;if(P(t.dom)&&(t.node.isBlock&&t.parent||!t.contentDOM)&&((o=t.dom.getBoundingClientRect()).width||o.height)&&(t.node.isBlock&&t.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(t.dom.nodeName)&&(!a&&o.left>r.left||o.top>r.top?i=t.posBefore:(!a&&o.right-1?i:e.docView.posFromDOM(t,n,-1)}function Oi(e,t,n){let r=e.childNodes.length;if(r&&n.topt.top&&i++}let n;ui&&i&&P(r)&&P(n=r.childNodes[i-1])&&n.contentEditable==`false`&&n.getBoundingClientRect().top>=t.top&&i--,r==e.dom&&i==r.childNodes.length-1&&P(r.lastChild)&&t.top>r.lastChild.getBoundingClientRect().bottom?s=e.state.doc.content.size:i!=0&&P(r)&&r.childNodes[i-1].nodeName==`BR`||(s=Di(e,r,i,t))}s??=Ei(e,o,t);let c=e.docView.nearestDesc(o,!0);return{pos:s,inside:c?c.posAtStart-c.border:-1}}function Ai(e){return e.top=0&&i==r.nodeValue.length?(e--,a=1):n<0?e--:t++,Pi(ji(Mr(r,e,t),a),a<0)}}if(!e.state.doc.resolve(t-(a||0)).parent.inlineContent){if(a==null&&i&&(n<0||i==Lr(r))){let e=r.childNodes[i-1];if(P(e))return Fi(e.getBoundingClientRect(),!1)}if(a==null&&i=0)}if(a==null&&i&&(n<0||i==Lr(r))){let e=r.childNodes[i-1],t=F(e)?Mr(e,Lr(e)-+!o):P(e)&&(e.nodeName!=`BR`||!e.nextSibling)?e:null;if(t)return Pi(ji(t,1),!1)}if(a==null&&i=0)}function Pi(e,t){if(e.width==0)return e;let n=t?e.left:e.right;return{top:e.top,bottom:e.bottom,left:n,right:n}}function Fi(e,t){if(e.height==0)return e;let n=t?e.top:e.bottom;return{top:n,bottom:n,left:e.left,right:e.right}}function Ii(e,t,n){let r=e.state,i=e.root.activeElement;r!=t&&e.updateState(t),i!=e.dom&&e.focus();try{return n()}finally{r!=t&&e.updateState(r),i!=e.dom&&i&&i.focus()}}function Li(e,t,n){let r=t.selection,i=n==`up`?r.$from:r.$to;return Ii(e,t,()=>{let{node:t}=e.docView.domFromPos(i.pos,n==`up`?-1:1);for(;;){let n=e.docView.nearestDesc(t,!0);if(!n)break;if(n.node.isBlock){t=n.contentDOM||n.dom;break}t=n.dom.parentNode}let r=Ni(e,i.pos,1);for(let e=t.firstChild;e;e=e.nextSibling){let t;if(P(e))t=e.getClientRects();else if(F(e))t=Mr(e,0,e.nodeValue.length).getClientRects();else continue;for(let e=0;ei.top+1&&(n==`up`?r.top-i.top>(i.bottom-r.top)*2:i.bottom-r.bottom>(r.bottom-i.top)*2))return!1}}return!0})}var Ri=/[\u0590-\u08ac]/;function zi(e,t,n){let{$head:r}=t.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,a=!i,o=i==r.parent.content.size,s=e.domSelection();return s?!Ri.test(r.parent.textContent)||!s.modify?n==`left`||n==`backward`?a:o:Ii(e,t,()=>{let{focusNode:t,focusOffset:i,anchorNode:a,anchorOffset:o}=e.domSelectionRange(),c=s.caretBidiLevel;s.modify(`move`,n,`character`);let l=r.depth?e.docView.domAfterPos(r.before()):e.dom,{focusNode:u,focusOffset:d}=e.domSelectionRange(),f=u&&!Rr(l,u)||t==u&&i==d;try{s.collapse(a,o),t&&(t!=a||i!=o)&&s.extend&&s.extend(t,i)}catch{}return c!=null&&(s.caretBidiLevel=c),f}):r.pos==r.start()||r.pos==r.end()}var Bi=null,Vi=null,Hi=!1;function Ui(e,t,n){return Bi==t&&Vi==n?Hi:(Bi=t,Vi=n,Hi=n==`up`||n==`down`?Li(e,t,n):zi(e,t,n))}var Wi=0,Gi=1,Ki=2,qi=3,Ji=class{constructor(e,t,n,r){this.parent=e,this.children=t,this.dom=n,this.contentDOM=r,this.dirty=Wi,n.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,n){return!1}matchesHack(e){return!1}parseRule(e){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;tkr(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM)){let n=e.compareDocumentPosition(this.contentDOM);r=n&16?t>Array.from(e.childNodes).findIndex(e=>e.contains(this.contentDOM)):!(n&4)}else if(this.dom.firstChild){if(t==0)for(let t=e;;t=t.parentNode){if(t==this.dom){r=!1;break}if(t.previousSibling)break}if(r==null&&t==e.childNodes.length)for(let t=e;;t=t.parentNode){if(t==this.dom){r=!0;break}if(t.nextSibling)break}}return r??n>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let n=!0,r=e;r;r=r.parentNode){let i=this.getDesc(r),a;if(i&&(!t||i.node)){if(n&&(a=i.nodeDOM)&&!(P(a)?Rr(a,e):a==e))n=!1;else return i}}}getDesc(e){let t=e.pmViewDesc;for(let e=t;e;e=e.parent)if(e==this)return t}posFromDOM(e,t,n){for(let r=e;r;r=r.parentNode){let i=this.getDesc(r);if(i)return i.localPosFromDOM(e,t,n)}return-1}descAt(e){for(let t=0,n=0;te){r=e-t;break}t=a}if(r)return this.children[n].domFromPos(r-this.children[n].border,t);for(;n>0;n--){let e=this.children[n-1];if(e.size||!(e instanceof ta||e instanceof Yi&&e.side>=0))break}if(t<=0){let e,r=!0;for(;e=n?this.children[n-1]:null,e&&e.dom.parentNode!=this.contentDOM;n--,r=!1);return e&&t&&r&&!e.border&&!e.domAtom?e.domFromPos(e.size,t):{node:this.contentDOM,offset:e?kr(e.dom)+1:0}}{let e,r=!0;for(;e=n=i&&t<=s-n.border&&n.node&&n.contentDOM&&this.contentDOM.contains(n.contentDOM))return n.parseRange(e,t,i);e=a;for(let t=o;t>0;t--){let n=this.children[t-1];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(1)){r=kr(n.dom)+1;break}e-=n.size}r==-1&&(r=0)}if(r>-1&&(s>t||o==this.children.length-1)){t=s;for(let e=o+1;es&&at){let e=o;o=s,s=e}let n=document.createRange();n.setEnd(s.node,s.offset),n.setStart(o.node,o.offset),c.removeAllRanges(),c.addRange(n)}}ignoreMutation(e){return!this.contentDOM&&e.type!=`selection`}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let n=0,r=0;r=n:en){let r=n+i.border,o=a-i.border;if(e>=r&&t<=o){this.dirty=e==n||t==a?Ki:Gi,e==r&&t==o&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=qi:i.markDirty(e-r,t-r);return}i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?Ki:qi}n=a}this.dirty=Ki}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let n=e==1?Ki:Gi;t.dirty{if(!i)return r;if(i.parent)return i.parent.posBeforeChild(i)})),!t.type.spec.raw){let e=P(a)?a:document.createElement(`span`);e!=a&&(e.appendChild(a),a=e),e.hasAttribute(`contenteditable`)||(e.contentEditable=`false`),e.classList.add(`ProseMirror-widget`)}super(e,[],a,null),this.widget=t,this.widget=t,i=this}matchesWidget(e){return this.dirty==Wi&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return t?t(e):!1}ignoreMutation(e){return e.type!=`selection`||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}},Xi=class extends Ji{constructor(e,t,n,r){super(e,[],t,null),this.textDOM=n,this.text=r}get size(){return this.text.length}localPosFromDOM(e,t){return e==this.textDOM?this.posAtStart+t:this.posAtStart+(t?this.size:0)}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type===`characterData`&&e.target.nodeValue==e.oldValue}},Zi=class e extends Ji{constructor(e,t,n,r,i){super(e,[],n,r),this.mark=t,this.spec=i}static create(t,n,r,i){let a=i.nodeViews[n.type.name],o=a&&a(n,i,r);return o&&o.dom||(o=Je.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new e(t,n,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty&qi||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=qi&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=Wi){let e=this.parent;for(;!e.node;)e=e.parent;e.dirty0&&(a=va(a,0,t,r));for(let e=0;e{if(!c)return o;if(c.parent)return c.parent.posBeforeChild(c)},r,i),u=l&&l.dom,d=l&&l.contentDOM;if(n.isText){if(!u)u=document.createTextNode(n.text);else if(!F(u))throw RangeError(`Text must be rendered as a DOM text node`)}else if(!u){let e=Je.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs);({dom:u,contentDOM:d}=e)}!d&&!n.isText&&u.nodeName!=`BR`&&(u.hasAttribute(`contenteditable`)||(u.contentEditable=`false`),n.type.spec.draggable&&(u.draggable=!0));let f=u;return u=la(u,r,n),l?c=new na(t,n,r,i,u,d||null,f,l):n.isText?new ea(t,n,r,i,u,f):new e(t,n,r,i,u,d||null,f)}parseRule(e){if(this.node.type.spec.reparseInView)return null;let t={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace==`pre`&&(t.preserveWhitespace=`full`),!this.contentDOM)t.getContent=()=>this.node.content;else if(!this.contentLost)t.contentElement=this.contentDOM;else{for(let e=this.children.length-1;e>=0;e--){let n=this.children[e];if(this.dom.contains(n.dom.parentNode)){t.contentElement=n.dom.parentNode;break}}if(!t.contentElement){let n=e&&e.find(t=>P(t)&&e.indexOf(t.parentNode)<0&&this.dom.contains(t));n?t.contentElement=n:t.getContent=()=>c.empty}}return t}matchesNode(e,t,n){return this.dirty==Wi&&e.eq(this.node)&&ua(t,this.outerDeco)&&n.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return+!this.node.isLeaf}updateChildren(e,t){let n=this.node.inlineContent,r=t,i=e.composing?this.localCompositionInfo(e,t):null,a=i&&i.pos>-1?i:null,o=i&&i.pos<0,s=new fa(this,a&&a.node,e),c=this.node.inlineContent,l=c&&this.node.isBlock;ha(this.node,this.innerDeco,(t,i,a)=>{t.spec.marks?s.syncToMarks(t.spec.marks,n,e,i):t.type.side>=0&&!a&&s.syncToMarks(i==this.node.childCount?f.none:this.node.child(i).marks,n,e,i),s.placeWidget(t,e,r)},(t,a,u,d)=>{s.syncToMarks(t.marks,n,e,d),l&&t.isAtom&&!t.isText&&s.addHackNode(`IMG`,s.top);let f;s.findNodeMatch(t,a,u,d)||o&&e.state.selection.from>r&&e.state.selection.to-1&&s.updateNodeAt(t,a,u,f,e)||s.updateNextNode(t,a,u,e,d,r)||s.addNode(t,a,u,e,r),r+=t.nodeSize,c&&(l=t.isAtom&&!t.isText)}),s.syncToMarks([],n,e,0),this.node.isTextblock&&s.addTextblockHacks(),s.destroyRest(),(s.changed||this.dirty==Ki)&&(a&&this.protectLocalComposition(e,a),ra(this.contentDOM,this.children,e),oi&&ga(this.dom))}localCompositionInfo(e,t){let{from:n,to:r}=e.state.selection;if(!(e.state.selection instanceof A)||nt+this.node.content.size)return null;let i=e.input.compositionNode;if(!i||!this.dom.contains(i.parentNode))return null;if(this.node.inlineContent){let e=i.nodeValue,a=_a(this.node.content,e,n-t,r-t);return a<0?null:{node:i,pos:a,text:e}}return{node:i,pos:-1,text:``}}protectLocalComposition(e,{node:t,pos:n,text:r}){if(this.getDesc(t))return;let i=t;for(;i.parentNode!=this.contentDOM;i=i.parentNode){for(;i.previousSibling;)i.parentNode.removeChild(i.previousSibling);for(;i.nextSibling;)i.parentNode.removeChild(i.nextSibling);i.pmViewDesc&&(i.pmViewDesc=void 0)}let a=new Xi(this,i,t,r);e.input.compositionNodes.push(a),this.children=va(this.children,n,n+r.length,e,a)}update(e,t,n,r){return this.dirty==qi||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,n,r),!0)}updateInner(e,t,n,r){this.updateOuterDeco(t),this.node=e,this.innerDeco=n,this.contentDOM&&this.updateChildren(r,this.posAtStart),this.dirty=Wi}updateOuterDeco(e){if(ua(e,this.outerDeco))return;let t=!P(this.nodeDOM),n=this.dom;this.dom=sa(this.dom,this.nodeDOM,oa(this.outerDeco,this.node,t),oa(e,this.node,t)),this.dom!=n&&(n.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){P(this.nodeDOM)&&(this.nodeDOM.classList.add(`ProseMirror-selectednode`),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){P(this.nodeDOM)&&(this.nodeDOM.classList.remove(`ProseMirror-selectednode`),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute(`draggable`))}get domAtom(){return this.node.isAtom}};function $i(e,t,n,r,i){la(r,t,e);let a=new Qi(void 0,e,t,n,r,r,r);return a.contentDOM&&a.updateChildren(i,0),a}var ea=class e extends Qi{constructor(e,t,n,r,i,a){super(e,t,n,r,i,null,a)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,n,r){return this.dirty==qi||this.dirty!=Wi&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=Wi||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,r.trackWrites==this.nodeDOM&&(r.trackWrites=null)),this.node=e,this.dirty=Wi,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,n){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,n)}ignoreMutation(e){return e.type!=`characterData`&&e.type!=`selection`}slice(t,n,r){let i=this.node.cut(t,n),a=document.createTextNode(i.text);return new e(this.parent,i,this.outerDeco,this.innerDeco,a,a)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=qi)}get domAtom(){return!1}isText(e){return this.node.text==e}},ta=class extends Ji{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Wi&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName==`IMG`}},na=class extends Qi{constructor(e,t,n,r,i,a,o,s){super(e,t,n,r,i,a,o),this.spec=s}update(e,t,n,r){if(this.dirty==qi)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let i=this.spec.update(e,t,n);return i&&this.updateInner(e,t,n,r),i}return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,n,r)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,n,r){this.spec.setSelection?this.spec.setSelection(e,t,n.root):super.setSelection(e,t,n,r)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}};function ra(e,t,n){let r=e.firstChild,i=!1;for(let a=0;a>1,o=Math.min(a,e.length);for(;i-1)i>this.index&&(this.changed=!0,this.destroyBetween(this.index,i)),this.top=this.top.children[this.index];else{let r=Zi.create(this.top,e[a],t,n);this.top.children.splice(this.index,0,r),this.top=r,this.changed=!0}this.index=0,a++}}findNodeMatch(e,t,n,r){let i=-1,a;if(r>=this.preMatch.index&&(a=this.preMatch.matches[r-this.preMatch.index]).parent==this.top&&a.matchesNode(e,t,n))i=this.top.children.indexOf(a,this.index);else for(let r=this.index,a=Math.min(this.top.children.length,r+5);r0;){let s;for(;;)if(r){let e=n.children[r-1];if(e instanceof Zi)n=e,r=e.children.length;else{s=e,r--;break}}else if(n==t)break outer;else r=n.parent.children.indexOf(n),n=n.parent;let c=s.node;if(c){if(c!=e.child(i-1))break;--i,a.set(s,i),o.push(s)}}return{index:i,matched:a,matches:o.reverse()}}function ma(e,t){return e.type.side-t.type.side}function ha(e,t,n,r){let i=t.locals(e),a=0;if(i.length==0){for(let n=0;na;)s.push(i[o++]);let m=a+f.nodeSize;if(f.isText){let e=m;o!e.inline):s.slice();r(f,h,t.forChild(a,f),p),a=m}}function ga(e){if(e.nodeName==`UL`||e.nodeName==`OL`){let t=e.style.cssText;e.style.cssText=t+`; list-style: square !important`,window.getComputedStyle(e).listStyle,e.style.cssText=t}}function _a(e,t,n,r){for(let i=0,a=0;i=n){if(a>=r&&c.slice(r-t.length-s,r-s)==t)return r-t.length;let e=s=0&&e+t.length+s>=n)return s+e;if(n==r&&c.length>=r+t.length-s&&c.slice(r-s,r-s+t.length)==t)return r}}return-1}function va(e,t,n,r,i){let a=[];for(let o=0,s=0;o=n||u<=t?a.push(c):(ln&&a.push(c.slice(n-l,c.size,r)))}return a}function ya(e,t=null){let n=e.domSelectionRange(),r=e.state.doc;if(!n.focusNode)return null;let i=e.docView.nearestDesc(n.focusNode),a=i&&i.size==0,o=e.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(o<0)return null;let s=r.resolve(o),c,l;if(Ur(n)){for(c=o;i&&!i.node;)i=i.parent;if(i&&i.node.isAtom&&j.isSelectable(i.node)&&i.parent&&!(i.node.isInline&&Vr(n.focusNode,n.focusOffset,i.dom))){let e=i.posBefore;l=new j(o==e?s:r.resolve(e))}else if(ti&&t==`key`&&o>e.state.selection.to&&P(n.focusNode)&&n.focusOffset==n.focusNode.childNodes.length&&i&&i.posAtStart>e.state.selection.to)for(let e=n.focusNode;;e=e.parentNode){if(getComputedStyle(e).overflow!=`visible`){l=k.findFrom(r.resolve(i.posAtStart),1);break}if(e==i.dom||e.nextSibling||!e.parentNode||!P(e.parentNode))break}}else{if(n instanceof e.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let t=o,i=o;for(let r=0;r{(n.anchorNode!=r||n.anchorOffset!=i)&&(t.removeEventListener(`selectionchange`,e.input.hideSelectionGuard),setTimeout(()=>{(!ba(e)||e.state.selection.visible)&&e.dom.classList.remove(`ProseMirror-hideselection`)},20))})}function Da(e){let t=e.domSelection();if(!t)return;let n=e.cursorWrapper.dom,r=n.nodeName==`IMG`;r?t.collapse(n.parentNode,kr(n)+1):t.collapse(n,0),!r&&!e.state.selection.visible&&$r&&ei<=11&&(n.disabled=!0,n.disabled=!1)}function Oa(e,t){if(t instanceof j){let n=e.docView.descAt(t.from);n!=e.lastSelectedViewDesc&&(ka(e),n&&n.selectNode(),e.lastSelectedViewDesc=n)}else ka(e)}function ka(e){e.lastSelectedViewDesc&&=(e.lastSelectedViewDesc.parent&&e.lastSelectedViewDesc.deselectNode(),void 0)}function Aa(e,t,n,r){return e.someProp(`createSelectionBetween`,r=>r(e,t,n))||A.between(t,n,r)}function ja(e){return e.editable&&!e.hasFocus()?!1:Ma(e)}function Ma(e){let t=e.domSelectionRange();if(!t.anchorNode)return!1;try{return Rr(e.dom,t.anchorNode)&&(e.editable||Rr(e.dom,t.focusNode))}catch{return!1}}function Na(e){let t=e.docView.domFromPos(e.state.selection.anchor,0),n=e.domSelectionRange();return Pr(t.node,t.offset,n.anchorNode,n.anchorOffset)}function Pa(e,t){let{$anchor:n,$head:r}=e.selection,i=t>0?n.max(r):n.min(r),a=i.parent.inlineContent?i.depth?e.doc.resolve(t>0?i.after():i.before()):null:i;return a&&k.findFrom(a,t)}function Fa(e,t){return e.dispatch(e.state.tr.setSelection(t).scrollIntoView()),!0}function Ia(e,t,n){let r=e.state.selection;if(r instanceof A){if(n.indexOf(`s`)>-1){let{$head:n}=r,i=n.textOffset?null:t<0?n.nodeBefore:n.nodeAfter;if(!i||i.isText||!i.isLeaf)return!1;let a=e.state.doc.resolve(n.pos+i.nodeSize*(t<0?-1:1));return Fa(e,new A(r.$anchor,a))}if(!r.empty)return!1;if(e.endOfTextblock(t>0?`forward`:`backward`)){let n=Pa(e.state,t);return n&&n instanceof j?Fa(e,n):!1}if(!si||n.indexOf(`m`)<0){let n=r.$head,i=n.textOffset?null:t<0?n.nodeBefore:n.nodeAfter,a;if(!i||i.isText)return!1;let o=t<0?n.pos-i.nodeSize:n.pos;return i.isAtom||(a=e.docView.descAt(o))&&!a.contentDOM?j.isSelectable(i)?Fa(e,new j(t<0?e.state.doc.resolve(n.pos-i.nodeSize):n)):Fa(e,new A(e.state.doc.resolve(t<0?o:o+i.nodeSize))):!1}}else if(r instanceof j&&r.node.isInline)return Fa(e,new A(t>0?r.$to:r.$from));else{let n=Pa(e.state,t);return n?Fa(e,n):!1}}function La(e,t){let n=e.pmViewDesc;return n?n.size==0&&(t<0||e.nextSibling||e.nodeName!=`BR`):P(e)&&e.contentEditable==`false`}function Ra(e,t){return t<0?za(e):Ba(e)}function za(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let i,a,o=!1;for(ti&&P(n)&&r0){if(!P(n))break;let e=n.childNodes[r-1];if(La(e,-1))i=n,a=--r;else if(F(e))n=e,r=n.nodeValue.length;else break}else if(Va(n))break;else{let t=n.previousSibling;for(;t&&La(t,-1);)i=n.parentNode,a=kr(t),t=t.previousSibling;if(t)n=t,r=Lr(n);else{if(n=n.parentNode,n==e.dom)break;r=0}}o?Wa(e,n,r):i&&Wa(e,i,a)}function Ba(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let i=Lr(n),a,o;for(;;)if(r{e.state==a&&xa(e)},50)}function Ga(e,t){let n=e.state.doc.resolve(t);if(!(ri||ci)&&n.parent.inlineContent){let r=e.coordsAtPos(t);if(t>n.start()){let n=e.coordsAtPos(t-1),i=(n.top+n.bottom)/2;if(i>r.top&&i1)return n.leftr.top&&i1)return n.left>r.left?`ltr`:`rtl`}}let r=e.dom;for(let t=n.depth;t>0;t--)if(n.node(t).isBlock){r=e.nodeDOM(n.before(t))||r;break}return getComputedStyle(r).direction==`rtl`?`rtl`:`ltr`}function Ka(e,t,n){let r=e.state.selection;if(r instanceof A&&!r.empty||n.indexOf(`s`)>-1||si&&n.indexOf(`m`)>-1)return!1;let{$from:i,$to:a}=r;if(!i.parent.inlineContent||e.endOfTextblock(t<0?`up`:`down`)){let n=Pa(e.state,t);if(n&&n instanceof j)return Fa(e,n)}if(!i.parent.inlineContent){let n=t<0?i:a,o=r instanceof Cn?k.near(n,t):k.findFrom(n,t);return o?Fa(e,o):!1}return!1}function qa(e,t){if(!(e.state.selection instanceof A))return!0;let{$head:n,$anchor:r,empty:i}=e.state.selection;if(!n.sameParent(r))return!0;if(!i)return!1;if(e.endOfTextblock(t>0?`forward`:`backward`))return!0;let a=!n.textOffset&&(t<0?n.nodeBefore:n.nodeAfter);if(a&&!a.isText){let r=e.state.tr;return t<0?r.delete(n.pos-a.nodeSize,n.pos):r.delete(n.pos,n.pos+a.nodeSize),e.dispatch(r),!0}return!1}function Ja(e,t,n){e.domObserver.stop(),t.contentEditable=n,e.domObserver.start()}function Ya(e){if(!ai||e.state.selection.$head.parentOffset>0)return!1;let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(t&&P(t)&&n==0&&t.firstChild&&P(t.firstChild)&&t.firstChild.contentEditable==`false`){let n=t.firstChild;Ja(e,n,`true`),setTimeout(()=>Ja(e,n,`false`),20)}return!1}function Xa(e){let t=``;return e.ctrlKey&&(t+=`c`),e.metaKey&&(t+=`m`),e.altKey&&(t+=`a`),e.shiftKey&&(t+=`s`),t}function Za(e,t){let n=t.keyCode,r=Xa(t);if(n==8||si&&n==72&&r==`c`)return qa(e,-1)||Ra(e,-1);if(n==46&&!t.shiftKey||si&&n==68&&r==`c`)return qa(e,1)||Ra(e,1);if(n==13||n==27)return!0;if(n==37||si&&n==66&&r==`c`){let t=n==37?Ga(e,e.state.selection.from)==`ltr`?-1:1:-1;return Ia(e,t,r)||Ra(e,t)}if(n==39||si&&n==70&&r==`c`){let t=n==39?Ga(e,e.state.selection.from)==`ltr`?1:-1:1;return Ia(e,t,r)||Ra(e,t)}return n==38||si&&n==80&&r==`c`?Ka(e,-1,r)||Ra(e,-1):n==40||si&&n==78&&r==`c`?Ya(e)||Ka(e,1,r)||Ra(e,1):!(r!=(si?`m`:`c`)||n!=66&&n!=73&&n!=89&&n!=90)}function Qa(e,t){e.someProp(`transformCopied`,n=>{t=n(t,e)});let n=[],{content:r,openStart:i,openEnd:a}=t;for(;i>1&&a>1&&r.childCount==1&&r.firstChild.childCount==1;){i--,a--;let e=r.firstChild;n.push(e.type.name,e.attrs==e.type.defaultAttrs?null:e.attrs),r=e.content}let o=e.someProp(`clipboardSerializer`)||Je.fromSchema(e.state.schema),s=co(),c=s.createElement(`div`);c.appendChild(o.serializeFragment(r,{document:s}));let l=c.firstChild,u,d=0;for(;l&&P(l)&&(u=so[l.nodeName.toLowerCase()]);){for(let e=u.length-1;e>=0;e--){let t=s.createElement(u[e]);for(;c.firstChild;)t.appendChild(c.firstChild);c.appendChild(t),d++}l=c.firstChild}return l&&P(l)&&l.setAttribute(`data-pm-slice`,`${i} ${a}${d?` -${d}`:``} ${JSON.stringify(n)}`),{dom:c,text:e.someProp(`clipboardTextSerializer`,n=>n(t,e))||t.content.textBetween(0,t.content.size,` -`),slice:t}}function Qa(e,t,n,r,i){let a=i.parent.type.spec.code,o,s;if(!n&&!t)return null;let l=!!t&&(r||a||!n);if(l){if(e.someProp(`transformPastedText`,n=>{t=n(t,a||r,e)}),a)return s=new m(c.from(e.state.schema.text(t.replace(/\r\n?/g,` -`))),0,0),e.someProp(`transformPasted`,t=>{s=t(s,e,!0)}),s;let n=e.someProp(`clipboardTextParser`,n=>n(t,i,r,e));if(n)s=n;else{let n=i.marks(),{schema:r}=e.state,a=Je.fromSchema(r);o=document.createElement(`div`),t.split(/(?:\r\n?|\n)+/).forEach(e=>{let t=o.appendChild(document.createElement(`p`));e&&t.appendChild(a.serializeNode(r.text(e,n)))})}}else e.someProp(`transformPastedHTML`,t=>{n=t(n,e)}),o=uo(n),li&&fo(o);let u=o&&o.querySelector(`[data-pm-slice]`),d=u&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(u.getAttribute(`data-pm-slice`)||``);if(d&&d[3])for(let e=+d[3];e>0;e--){let e=o.firstChild;for(;e&&!P(e);)e=e.nextSibling;if(!e)break;o=e}if(s||=(e.someProp(`clipboardParser`)||e.someProp(`domParser`)||Pe.fromSchema(e.state.schema)).parseSlice(o,{preserveWhitespace:!!(l||d),context:i,ruleFromNode(e){return e.nodeName==`BR`&&!e.nextSibling&&e.parentNode&&!$a.test(e.parentNode.nodeName)?{ignore:!0}:null}}),d)s=po(ao(s,+d[1],+d[2]),d[4]);else if(s=m.maxOpen(eo(s.content,i),!0),s.openStart||s.openEnd){let e=0,t=0;for(let t=s.content.firstChild;e{s=t(s,e,l)}),s}var $a=/^(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 eo(e,t){if(e.childCount<2)return e;for(let n=t.depth;n>=0;n--){let r=t.node(n).contentMatchAt(t.index(n)),i,a=[];if(e.forEach(e=>{if(!a)return;let t=r.findWrapping(e.type),n;if(!t)return a=null;if(n=a.length&&i.length&&no(t,i,e,a[a.length-1],0))a[a.length-1]=n;else{a.length&&(a[a.length-1]=ro(a[a.length-1],i.length));let n=to(e,t);a.push(n),r=r.matchType(n.type),i=t}}),a)return c.from(a)}return e}function to(e,t,n=0){for(let r=t.length-1;r>=n;r--)e=t[r].create(null,c.from(e));return e}function no(e,t,n,r,i){if(i1&&(a=0),i=n&&(s=t<0?o.contentMatchAt(0).fillBefore(s,a<=i).append(s):s.append(o.contentMatchAt(o.childCount).fillBefore(c.empty,!0))),e.replaceChild(t<0?0:e.childCount-1,o.copy(s))}function ao(e,t,n){return te})}return co.createHTML(e)}function uo(e){let t=/^(\s*]*>)*/.exec(e);t&&(e=e.slice(t[0].length));let n=so(),r=n.body,i=/<([a-z][^>\s]+)/i.exec(e),a;if((a=i&&oo[i[1].toLowerCase()])&&(e=a.map(e=>`<`+e+`>`).join(``)+e+a.map(e=>``).reverse().join(``)),r.innerHTML=lo(e),a)for(let e=0;e=0;e-=2){let t=n.nodes[r[e]];if(!t||t.hasRequiredAttrs())break;try{i=c.from(t.create(r[e+1],i))}catch{break}a++,o++}return new m(i,a,o)}var mo={},ho={},go={touchstart:!0,touchmove:!0},_o=class{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastKeyDispatched=!1,this.lastClick={time:0,x:0,y:0,type:``,button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}};function vo(e){for(let t in mo){let n=mo[t];e.dom.addEventListener(t,e.input.eventHandlers[t]=t=>{Co(e,t)&&!So(e,t)&&(e.editable||!(t.type in ho))&&n(e,t)},go[t]?{passive:!0}:void 0)}ii&&e.dom.addEventListener(`input`,()=>null),xo(e)}function yo(e,t){e.input.lastSelectionOrigin=t,e.input.lastSelectionTime=Date.now()}function bo(e){e.input.mouseDown&&e.input.mouseDown.done(),e.domObserver.stop();for(let t in e.input.eventHandlers)e.dom.removeEventListener(t,e.input.eventHandlers[t]);clearTimeout(e.input.composingTimeout),clearTimeout(e.input.lastIOSEnterFallbackTimeout)}function xo(e){e.someProp(`handleDOMEvents`,t=>{for(let n in t)e.input.eventHandlers[n]||e.dom.addEventListener(n,e.input.eventHandlers[n]=t=>So(e,t))})}function So(e,t){return e.someProp(`handleDOMEvents`,n=>{let r=n[t.type];return r?r(e,t)||t.defaultPrevented:!1})}function Co(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let n=t.target;n!=e.dom;n=n.parentNode)if(!n||n.nodeType==11||n.pmViewDesc&&n.pmViewDesc.stopEvent(t))return!1;return!0}function wo(e,t){!So(e,t)&&mo[t.type]&&(e.editable||!(t.type in ho))&&mo[t.type](e,t)}function To(e,t){let{input:n}=e;return n.lastKeyDispatched||e.composing?!1:(n.lastKeyDispatched=!0,typeof t==`string`&&(t=Wr(t==`Backspace`?8:13,t)),e.someProp(`handleKeyDown`,n=>n(e,t)))}ho.keydown=(e,t)=>{let n=t;if(e.input.shiftKey=n.keyCode==16||n.shiftKey,!Ho(e)&&(e.input.lastKeyCode=n.keyCode,e.input.lastKeyCodeTime=Date.now(),e.input.lastKeyDispatched=!1,!(ci&&I&&n.keyCode==13))){if(n.keyCode!=229&&e.domObserver.forceFlush(),ai&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let t=Date.now();e.input.lastIOSEnter=t,e.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{e.input.lastIOSEnter==t&&(To(e,`Enter`),e.input.lastIOSEnter=0)},200)}else To(e,n)||Xa(e,n)?n.preventDefault():yo(e,`key`)}},ho.keyup=(e,t)=>{t.keyCode==16&&(e.input.shiftKey=!1)},ho.keypress=(e,t)=>{let n=t;if(Ho(e)||!n.charCode||n.ctrlKey&&!n.altKey||oi&&n.metaKey)return;if(e.someProp(`handleKeyPress`,t=>t(e,n))){n.preventDefault();return}let r=e.state.selection;if(!(r instanceof A)||!r.$from.sameParent(r.$to)){let t=String.fromCharCode(n.charCode),i=()=>e.state.tr.insertText(t).scrollIntoView();!/[\r\n]/.test(t)&&!e.someProp(`handleTextInput`,n=>n(e,r.$from.pos,r.$to.pos,t,i))&&e.dispatch(i()),n.preventDefault()}};function Eo(e){return{left:e.clientX,top:e.clientY}}function Do(e,t){let n=t.x-e.clientX,r=t.y-e.clientY;return n*n+r*r<100}function Oo(e,t,n,r,i){if(r==-1)return!1;let a=e.state.doc.resolve(r);for(let r=a.depth+1;r>0;r--)if(e.someProp(t,t=>r>a.depth?t(e,n,a.nodeAfter,a.before(r),i,!0):t(e,n,a.node(r),a.before(r),i,!1)))return!0;return!1}function ko(e,t,n){if(e.focused||e.focus(),e.state.selection.eq(t))return;let r=e.state.tr.setSelection(t);r.setMeta(`pointer`,!0),e.dispatch(r)}function Ao(e,t){if(t==-1)return!1;let n=e.state.doc.resolve(t),r=n.nodeAfter;return r&&r.isAtom&&j.isSelectable(r)?(ko(e,new j(n)),!0):!1}function jo(e,t){if(t==-1)return!1;let n=e.state.selection,r,i;n instanceof j&&(r=n.node);let a=e.state.doc.resolve(t);for(let e=a.depth+1;e>0;e--){let t=e>a.depth?a.nodeAfter:a.node(e);if(j.isSelectable(t)){i=r&&n.$from.depth>0&&e>=n.$from.depth&&a.before(n.$from.depth+1)==n.$from.pos?a.before(n.$from.depth):a.before(e);break}}return i!=null&&(ko(e,j.create(e.state.doc,i)),!0)}function Mo(e,t,n,r,i){return Oo(e,`handleClickOn`,t,n,r)||e.someProp(`handleClick`,n=>n(e,t,r))||(i?jo(e,n):Ao(e,n))}function No(e,t,n,r){return Oo(e,`handleDoubleClickOn`,t,n,r)||e.someProp(`handleDoubleClick`,n=>n(e,t,r))}function Po(e,t,n,r){return Oo(e,`handleTripleClickOn`,t,n,r)||e.someProp(`handleTripleClick`,n=>n(e,t,r))||Fo(e,n,r)}function Fo(e,t,n){if(n.button!=0)return!1;let r=Io(e,t,!0),i=e.state.doc;return r?(ko(e,r),r instanceof A&&i.eq(e.state.doc)&&(e.input.mouseDown=new Vo(e,r)),!0):!1}function Io(e,t,n){let r=e.state.doc;if(t==-1)return r.inlineContent?A.create(r,0,r.content.size):null;let i=r.resolve(t);for(let e=i.depth+1;e>0;e--){let t=e>i.depth?i.nodeAfter:i.node(e),a=i.before(e);if(t.inlineContent)return A.create(r,a+1,a+1+t.content.size);if(n&&j.isSelectable(t))return j.create(r,a)}return null}function Lo(e){return Jo(e)}var Ro=oi?`metaKey`:`ctrlKey`;mo.mousedown=(e,t)=>{let n=t;e.input.shiftKey=n.shiftKey;let r=Lo(e),i=Date.now(),a=`singleClick`;i-e.input.lastClick.time<500&&Do(n,e.input.lastClick)&&!n[Ro]&&e.input.lastClick.button==n.button&&(e.input.lastClick.type==`singleClick`?a=`doubleClick`:e.input.lastClick.type==`doubleClick`&&(a=`tripleClick`)),e.input.lastClick={time:i,x:n.clientX,y:n.clientY,type:a,button:n.button},e.input.mouseDown&&e.input.mouseDown.done();let o=e.posAtCoords(Eo(n));o&&(a==`singleClick`?e.input.mouseDown=new Bo(e,o,n,!!r):(a==`doubleClick`?No:Po)(e,o.pos,o.inside,n)?n.preventDefault():yo(e,`pointer`))};var zo=class{constructor(e){this.view=e,this.mightDrag=null,e.root.addEventListener(`mouseup`,this.up=this.up.bind(this)),e.root.addEventListener(`mousemove`,this.move=this.move.bind(this))}up(e){this.done()}move(e){e.buttons==0&&this.done()}done(){this.view.root.removeEventListener(`mouseup`,this.up),this.view.root.removeEventListener(`mousemove`,this.move),this.view.input.mouseDown==this&&(this.view.input.mouseDown=null)}delaySelUpdate(){return!1}},Bo=class extends zo{constructor(e,t,n,r){super(e),this.pos=t,this.event=n,this.flushed=r,this.delayedSelectionSync=!1,this.startDoc=e.state.doc,this.selectNode=!!n[Ro],this.allowDefault=n.shiftKey;let i,a;if(t.inside>-1)i=e.state.doc.nodeAt(t.inside),a=t.inside;else{let n=e.state.doc.resolve(t.pos);i=n.parent,a=n.depth?n.before():0}let o=r?null:n.target,s=o?e.docView.nearestDesc(o,!0):null;this.target=s&&P(s.nodeDOM)?s.nodeDOM:null;let{selection:c}=e.state;n.button==0&&(i.type.spec.draggable&&i.type.spec.selectable!==!1||c instanceof j&&c.from<=a&&c.to>a)&&(this.mightDrag={node:i,pos:a,addAttr:!(!this.target||this.target.draggable),setUneditable:!!(this.target&&ti&&!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()),yo(e,`pointer`)}done(){super.done(),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute(`draggable`),this.mightDrag.setUneditable&&this.target.removeAttribute(`contentEditable`),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>{this.view.isDestroyed||ba(this.view)})}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(Eo(e))),this.updateAllowDefault(e),this.allowDefault||!t?yo(this.view,`pointer`):Mo(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||ii&&this.mightDrag&&!this.mightDrag.node.isAtom||I&&!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)?(ko(this.view,k.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):yo(this.view,`pointer`)}move(e){this.updateAllowDefault(e),yo(this.view,`pointer`),super.move(e)}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}delaySelUpdate(){return this.allowDefault?(this.delayedSelectionSync=!0,!0):!1}},Vo=class extends zo{constructor(e,t){super(e),this.startSelection=t,this.startDoc=e.state.doc}move(e){if(e.buttons==0||this.view.isDestroyed||!this.view.state.doc.eq(this.startDoc)){this.done();return}e.preventDefault(),yo(this.view,`pointer`);let t=this.view.posAtCoords(Eo(e)),n=t&&Io(this.view,t.inside,!1);if(!n)return;let{doc:r}=this.view.state,i=this.startSelection,[a,o]=n.from{e.input.lastTouch=Date.now(),Lo(e),yo(e,`pointer`)},mo.touchmove=e=>{e.input.lastTouch=Date.now(),yo(e,`pointer`)},mo.contextmenu=e=>Lo(e);function Ho(e,t){return e.composing?!0:ii&&Math.abs(Date.now()-e.input.compositionEndedAt)<500?(e.input.compositionEndedAt=-2e8,!0):!1}var Uo=ci?5e3:-1;ho.compositionstart=ho.compositionupdate=e=>{if(!e.composing){e.domObserver.flush();let{state:t}=e,n=t.selection.$to;if(t.selection instanceof A&&t.selection.empty&&(t.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(e=>e.type.spec.inclusive===!1)||I&&si&&Wo(e)))e.markCursor=e.state.storedMarks||n.marks(),Jo(e,!0),e.markCursor=null;else if(Jo(e,!t.selection.empty),ti&&t.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let t=e.domSelectionRange();for(let n=t.focusNode,r=t.focusOffset;n&&P(n)&&r!=0;){let t=r<0?n.lastChild:n.childNodes[r-1];if(!t)break;if(F(t)){let n=e.domSelection();n&&n.collapse(t,t.nodeValue.length);break}n=t,r=-1}}e.input.composing=!0}Go(e,Uo)};function Wo(e){let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(!t||!P(t)||n>=t.childNodes.length)return!1;let r=t.childNodes[n];return P(r)&&r.contentEditable==`false`}ho.compositionend=(e,t)=>{e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=Date.now(),e.input.compositionPendingChanges=e.domObserver.pendingRecords().length?e.input.compositionID:0,e.input.compositionNode=null,e.input.badSafariComposition?e.domObserver.forceFlush():e.input.compositionPendingChanges&&Promise.resolve().then(()=>e.domObserver.flush()),e.input.compositionID++,Go(e,20))};function Go(e,t){clearTimeout(e.input.composingTimeout),t>-1&&(e.input.composingTimeout=setTimeout(()=>Jo(e),t))}function Ko(e){for(e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=Date.now());e.input.compositionNodes.length>0;)e.input.compositionNodes.pop().markParentsDirty()}function qo(e){let t=e.domSelectionRange();if(!t.focusNode)return null;let n=zr(t.focusNode,t.focusOffset),r=Br(t.focusNode,t.focusOffset);if(n&&r&&n!=r){let t=r.pmViewDesc,i=e.domObserver.lastChangedTextNode;if(n==i||r==i)return i;if(!t||!t.isText(r.nodeValue))return r;if(e.input.compositionNode==r){let e=n.pmViewDesc;if(e&&e.isText(n.nodeValue))return r}}return n||r}function Jo(e,t=!1){if(!(ci&&e.domObserver.flushingSoon>=0)){if(e.domObserver.forceFlush(),Ko(e),t||e.docView&&e.docView.dirty){let n=va(e),r=e.state.selection;return n&&!n.eq(r)?e.dispatch(e.state.tr.setSelection(n)):(e.markCursor||t)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?e.dispatch(e.state.tr.deleteSelection()):e.updateState(e.state),!0}return!1}}function Yo(e,t){if(!e.dom.parentNode)return;let n=e.dom.parentNode.appendChild(document.createElement(`div`));n.appendChild(t),n.style.cssText=`position: fixed; left: -10000px; top: 10px`;let r=getSelection(),i=document.createRange();i.selectNodeContents(t),e.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),e.focus()},50)}var Xo=$r&&ei<15||ai&&ui<604;mo.copy=ho.cut=(e,t)=>{let n=t,r=e.state.selection,i=n.type==`cut`;if(r.empty)return;let a=Xo?null:n.clipboardData,{dom:o,text:s}=Za(e,r.content());a?(n.preventDefault(),a.clearData(),a.setData(`text/html`,o.innerHTML),a.setData(`text/plain`,s)):Yo(e,o),i&&e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta(`uiEvent`,`cut`))};function Zo(e){return e.openStart==0&&e.openEnd==0&&e.content.childCount==1?e.content.firstChild:null}function Qo(e,t){if(!e.dom.parentNode)return;let n=e.input.shiftKey||e.state.selection.$from.parent.type.spec.code,r=e.dom.parentNode.appendChild(document.createElement(n?`textarea`:`div`));n||(r.contentEditable=`true`),r.style.cssText=`position: fixed; left: -10000px; top: 10px`,r.focus();let i=e.input.shiftKey&&e.input.lastKeyCode!=45;setTimeout(()=>{e.focus(),r.parentNode&&r.parentNode.removeChild(r),n?$o(e,r.value,null,i,t):$o(e,r.textContent,r.innerHTML,i,t)},50)}function $o(e,t,n,r,i){let a=Qa(e,t,n,r,e.state.selection.$from);if(e.someProp(`handlePaste`,t=>t(e,i,a||m.empty)))return!0;if(!a)return!1;let o=Zo(a),s=o?e.state.tr.replaceSelectionWith(o,r):e.state.tr.replaceSelection(a);return e.dispatch(s.scrollIntoView().setMeta(`paste`,!0).setMeta(`uiEvent`,`paste`)),!0}function es(e){let t=e.getData(`text/plain`)||e.getData(`Text`);if(t)return t;let n=e.getData(`text/uri-list`);return n?n.replace(/\r?\n/g,` `):``}ho.paste=(e,t)=>{let n=t;if(e.composing&&!ci)return;let r=Xo?null:n.clipboardData,i=e.input.shiftKey&&e.input.lastKeyCode!=45;r&&$o(e,es(r),r.getData(`text/html`),i,n)?n.preventDefault():Qo(e,n)};var ts=class{constructor(e,t,n){this.slice=e,this.move=t,this.node=n}},ns=oi?`altKey`:`ctrlKey`;function rs(e,t){let n;return e.someProp(`dragCopies`,e=>{n||=e(t)}),n==null?!t[ns]:!n}mo.dragstart=(e,t)=>{let n=t,r=e.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let i=e.state.selection,a=i.empty?null:e.posAtCoords(Eo(n)),o;if(!(a&&a.pos>=i.from&&a.pos<=(i instanceof j?i.to-1:i.to))){if(r&&r.mightDrag)o=j.create(e.state.doc,r.mightDrag.pos);else if(n.target&&P(n.target)){let t=e.docView.nearestDesc(n.target,!0);t&&t.node.type.spec.draggable&&t!=e.docView&&(o=j.create(e.state.doc,t.posBefore))}}let{dom:s,text:c,slice:l}=Za(e,(o||e.state.selection).content());(!n.dataTransfer.files.length||!I||ri>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(Xo?`Text`:`text/html`,s.innerHTML),n.dataTransfer.effectAllowed=`copyMove`,Xo||n.dataTransfer.setData(`text/plain`,c),e.dragging=new ts(l,rs(e,n),o)},mo.dragend=e=>{let t=e.dragging;window.setTimeout(()=>{e.dragging==t&&(e.dragging=null)},50)},ho.dragover=ho.dragenter=(e,t)=>t.preventDefault(),ho.drop=(e,t)=>{try{is(e,t,e.dragging)}finally{e.dragging=null}};function is(e,t,n){if(!t.dataTransfer)return;let r=e.posAtCoords(Eo(t));if(!r)return;let i=e.state.doc.resolve(r.pos),a=n&&n.slice;a?e.someProp(`transformPasted`,t=>{a=t(a,e,!1)}):a=Qa(e,es(t.dataTransfer),Xo?null:t.dataTransfer.getData(`text/html`),!1,i);let o=!!(n&&rs(e,t));if(e.someProp(`handleDrop`,n=>n(e,t,a||m.empty,o))){t.preventDefault();return}if(!a)return;t.preventDefault();let s=a?Yt(e.state.doc,i.pos,a):i.pos;s??=i.pos;let c=e.state.tr;if(o){let{node:e}=n;e?e.replace(c):c.deleteSelection()}let l=c.mapping.map(s),u=a.openStart==0&&a.openEnd==0&&a.content.childCount==1,d=c.doc;if(u?c.replaceRangeWith(l,l,a.content.firstChild):c.replaceRange(l,l,a),c.doc.eq(d))return;let f=c.doc.resolve(l);if(u&&j.isSelectable(a.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(a.content.firstChild))c.setSelection(new j(f));else{let t=c.mapping.map(s);c.mapping.maps[c.mapping.maps.length-1].forEach((e,n,r,i)=>t=i),c.setSelection(ka(e,f,c.doc.resolve(t)))}e.focus(),e.dispatch(c.setMeta(`uiEvent`,`drop`))}mo.focus=e=>{if(e.input.lastFocus=Date.now(),!e.focused){e.domObserver.stop(),e.dom.classList.add(`ProseMirror-focused`),e.domObserver.start(),e.focused=!0;let t=e.domSelectionRange();if(!e.domObserver.currentSelection.eq(t)){let{focusNode:n,focusOffset:r}=t;setTimeout(()=>{let t=e.domSelectionRange();t.focusNode==n&&t.focusOffset==r&&e.docView&&e.hasFocus()&&ba(e)},20)}}},mo.blur=(e,t)=>{let n=t;e.focused&&=(e.domObserver.stop(),e.dom.classList.remove(`ProseMirror-focused`),e.domObserver.start(),n.relatedTarget&&e.dom.contains(n.relatedTarget)&&e.domObserver.currentSelection.clear(),!1)},mo.beforeinput=(e,t)=>{if(ci&&t.inputType==`deleteContentBackward`){e.domObserver.flushSoon();let{domChangeCount:t}=e.input;setTimeout(()=>{if(e.input.domChangeCount!=t||e.domObserver.pendingRecords().length||(e.dom.blur(),e.focus(),To(e,`Backspace`)))return;let{$cursor:n}=e.state.selection;n&&n.pos>0&&e.dispatch(e.state.tr.delete(n.pos-1,n.pos).scrollIntoView())},50)}};for(let e in ho)mo[e]=ho[e];function as(e,t){if(e==t)return!0;for(let n in e)if(e[n]!==t[n])return!1;for(let n in t)if(!(n in e))return!1;return!0}var ss=class{constructor(e){this.frag=e,this.index=0,this.off=0}nodeAt(e){for(;this.off<=e&&this.index=a?null:new ds(i,a,this)}valid(e,t){return t.from=e&&(!i||i(o.spec))&&n.push(o.copy(o.from+r,o.to+r))}for(let a=0;ae){let o=this.children[a]+1;this.children[a+2].findInner(e-o,t-o,n,r+o,i)}}map(e,t,n){return this==ms||e.maps.length==0?this:this.mapInner(e,t,0,0,n||ps)}mapInner(t,n,r,i,a){let o;if(this.local.length){let e=new ss(n.content);for(let s=0;s{let o=t+r,s;if(s=ys(n,e,o)){for(i||=this.children.slice();aa&&n.to=t){this.children[e]==t&&(r=this.children[e+2]);break}let a=t+1,o=a+n.content.size;for(let e=0;ea&&t.type instanceof ls){let e=Math.max(a,t.from)-a,n=Math.min(o,t.to)-a;ee.map(t,n,ps));return e.from(r)}forChild(t,n){if(n.isLeaf)return L.empty;let r=[];for(let i=0;ie instanceof L)?t:t.reduce((e,t)=>e.concat(t instanceof L?t:t.members),[]))}}forEachSet(e){for(let t=0;t{let o=a-i-(n-e);for(let i=0;ia+t-r)continue;let c=s[i]+t-r;n>=c?s[i+1]=e<=c?-2:-1:e>=t&&o&&(s[i]+=o,s[i+1]+=o)}r+=o}),t=n.maps[e].map(t,-1)}let c=!1;for(let t=0;t=r.content.size){c=!0;continue}let d=n.map(e[t+1]+a,-1)-i,{index:f,offset:p}=r.content.findIndex(u),m=r.maybeChild(f);if(m&&p==u&&p+m.nodeSize==d){let r=s[t+2].mapInner(n,m,l+1,e[t]+a+1,o);r==ms?(s[t+1]=-2,c=!0):(s[t]=u,s[t+1]=d,s[t+2]=r)}else c=!0}if(c){let c=xs(vs(s,e,t,n,i,a,o),r,0,o);t=c.local;for(let e=0;en&&a.to{let s=ys(e,t,o+n);if(s){a=!0;let e=xs(s,t,n+o+1,r);e!=ms&&i.push(o,o+t.nodeSize,e)}});let o=_s(a?bs(e):e,-n).sort(Ss);if(o.length){let e=new ss(t.content);for(let n=0;n0;)t++;e.splice(t,0,n)}function Ts(e){let t=[];return e.someProp(`decorations`,n=>{let r=n(e.state);r&&r!=ms&&t.push(r)}),e.cursorWrapper&&t.push(L.create(e.state.doc,[e.cursorWrapper.deco])),hs.from(t)}var Es={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},Ds=$r&&ei<=11,Os=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}},ks=class{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new Os,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(t=>{for(let e=0;ee.type==`childList`&&e.removedNodes.length||e.type==`characterData`&&e.oldValue.length>e.target.nodeValue.length)?this.flushSoon():ii&&e.composing&&t.some(e=>e.type==`childList`&&e.target.nodeName==`TR`)?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),Ds&&(this.onCharData=e=>{this.queue.push({target:e.target,type:`characterData`,oldValue:e.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,Es)),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(Aa(this.view)){if(this.suppressingSelectionUpdates)return ba(this.view);if($r&&ei<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Pr(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t=new Set,n;for(let n=e.focusNode;n;n=Ar(n))t.add(n);for(let r=e.anchorNode;r;r=Ar(r))if(t.has(r)){n=r;break}let r=n&&this.view.docView.nearestDesc(n);if(r&&r.ignoreMutation({type:`selection`,target:F(n)?n.parentNode:n}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let n,r=!1;!this.suppressingSelectionUpdates&&Aa(e)&&(n=e.domSelectionRange(),r=!this.currentSelection.eq(n)&&!this.ignoreSelectionChange(n));let i=-1,a=-1,o=!1,s=[];if(e.editable)for(let e=0;ee.nodeName==`BR`)&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46||I&&(e.composing||e.input.compositionEndedAt>Date.now()-50)&&t.some(e=>e.type==`childList`&&e.removedNodes.length))){for(let e of s)if(e.nodeName==`BR`&&e.parentNode){let t=e.nextSibling;for(;t&&P(t);){if(t.contentEditable==`false`){e.parentNode.removeChild(e);break}t=t.firstChild}}}else if(ti&&s.length){let t=s.filter(e=>e.nodeName==`BR`);if(t.length==2){let[e,n]=t;e.parentNode&&e.parentNode.parentNode==n.parentNode?n.remove():e.remove()}else{let{focusNode:n}=this.currentSelection;for(let r of t){let t=r.parentNode;t&&t.nodeName==`LI`&&(!n||Fs(e,n)!=t)&&r.remove()}}}let c=null;i<0&&r&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)-1||r)&&(i>-1&&(e.docView.markDirty(i,a),Ms(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,Is(e,s)),this.handleDOMChange(i,a,o,s),e.docView&&e.docView.dirty?e.updateState(e.state):n&&!this.currentSelection.eq(n)&&ba(e),n&&this.currentSelection.set(n))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let n=this.view.docView.nearestDesc(e.target);if(e.type==`attributes`&&(n==this.view.docView||e.attributeName==`contenteditable`||e.attributeName==`style`&&!e.oldValue&&!e.target.getAttribute(`style`))||!n||n.ignoreMutation(e))return null;if(e.type==`childList`){for(let n=0;na;e--){let t=i.childNodes[e-1],n=t.pmViewDesc;if(t.nodeName==`BR`&&!n){o=e;break}if(!n||n.size)break}let f=e.state.doc,p=e.someProp(`domParser`)||Pe.fromSchema(e.state.schema),m=f.resolve(s),h=null,g=p.parse(i,{topNode:m.parent,topMatch:m.parent.contentMatchAt(m.index()),topOpen:!0,from:a,to:o,preserveWhitespace:m.parent.type.whitespace!=`pre`||`full`,findPositions:u,ruleFromNode:Rs(r),context:m});if(u&&u[0].pos!=null){let e=u[0].pos,t=u[1]&&u[1].pos;t??=e,h={anchor:e+s,head:t+s}}return{doc:g,sel:h,from:s,to:c}}var Rs=e=>t=>{let n=t.pmViewDesc;if(n)return n.parseRule(e);if(t.nodeName==`BR`&&t.parentNode){if(ii&&/^(ul|ol)$/i.test(t.parentNode.nodeName)){let e=document.createElement(`div`);return e.appendChild(document.createElement(`li`)),{skip:e}}if(t.parentNode.lastChild==t||ii&&/^(tr|table)$/i.test(t.parentNode.nodeName))return{ignore:!0}}else if(t.nodeName==`IMG`&&t.getAttribute(`mark-placeholder`))return{ignore:!0};return null},zs=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function Bs(e,t,n,r,i){let a=e.input.compositionPendingChanges||(e.composing?e.input.compositionID:0);if(e.input.compositionPendingChanges=0,t<0){let t=e.input.lastSelectionTime>Date.now()-50?e.input.lastSelectionOrigin:null,n=va(e,t);if(n&&!e.state.selection.eq(n)){if(I&&ci&&e.input.lastKeyCode===13&&Date.now()-100Date.now()-225||ci)&&i.some(e=>P(e)&&!zs.test(e.nodeName))&&(!m||m.endA>=m.endB)&&To(e,`Enter`)){e.input.lastIOSEnter=0;return}if(!m){if(r&&c instanceof A&&!c.empty&&c.$head.sameParent(c.$anchor)&&!e.composing&&!(l.sel&&l.sel.anchor!=l.sel.head))m={start:c.from,endA:c.to,endB:c.to};else{if(l.sel){let t=Vs(e,e.state.doc,l.sel);if(t&&!t.eq(e.state.selection)){let n=e.state.tr.setSelection(t);a&&n.setMeta(`composition`,a),e.dispatch(n)}}return}}e.state.selection.frome.state.selection.from&&m.start<=e.state.selection.from+2&&e.state.selection.from>=l.from?m.start=e.state.selection.from:m.endA=e.state.selection.to-2&&e.state.selection.to<=l.to&&(m.endB+=e.state.selection.to-m.endA,m.endA=e.state.selection.to)),$r&&ei<=11&&m.endB==m.start+1&&m.endA==m.start&&m.start>l.from&&l.doc.textBetween(m.start-l.from-1,m.start-l.from+1)==` \xA0`&&(m.start--,m.endA--,m.endB--);let h=l.doc.resolveNoCache(m.start-l.from),g=l.doc.resolveNoCache(m.endB-l.from),_=u.resolve(m.start),v=h.sameParent(g)&&h.parent.inlineContent&&_.end()>=m.endA;if((ai&&e.input.lastIOSEnter>Date.now()-225&&(!v||i.some(e=>e.nodeName==`DIV`||e.nodeName==`P`))||!v&&Ws(l.doc,h.pos,g.pos))&&To(e,`Enter`)){e.input.lastIOSEnter=0;return}if(e.state.selection.anchor>m.start&&(v?m.endA>m.start&&m.endB==m.start:Us(u,m.start,m.endA,h,g))&&To(e,`Backspace`)){ci&&I&&e.domObserver.suppressSelectionUpdates();return}I&&m.endB==m.start&&(e.input.lastChromeDelete=Date.now()),ci&&!v&&h.start()!=g.start()&&g.parentOffset==0&&h.depth==g.depth&&l.sel&&l.sel.anchor==l.sel.head&&l.sel.head==m.endA&&(m.endB-=2,g=l.doc.resolveNoCache(m.endB-l.from),setTimeout(()=>To(e,`Enter`),20));let y=m.start,b=m.endA,x=t=>{let n=t||e.state.tr.replace(y,b,l.doc.slice(m.start-l.from,m.endB-l.from));if(l.sel){let t=Vs(e,n.doc,l.sel);t&&!(I&&e.composing&&t.empty&&(m.start!=m.endB||e.input.lastChromeDeleteba(e),20));let t=x(e.state.tr.delete(y,b)),n=u.resolve(m.start).marksAcross(u.resolve(m.endA));n&&t.ensureMarks(n),e.dispatch(t)}else if(m.endA==m.endB&&(S=Hs(h.parent.content.cut(h.parentOffset,g.parentOffset),_.parent.content.cut(_.parentOffset,m.endA-_.start())))){let t=x(e.state.tr);S.type==`add`?t.addMark(y,b,S.mark):t.removeMark(y,b,S.mark),e.dispatch(t)}else if(h.parent.child(h.index()).isText&&h.index()==g.index()-+!g.textOffset){let t=h.parent.textBetween(h.parentOffset,g.parentOffset),n=()=>x(e.state.tr.insertText(t,y,b));e.someProp(`handleTextInput`,r=>r(e,y,b,t,n))||e.dispatch(n())}else e.dispatch(x())}else e.dispatch(x())}function Vs(e,t,n){return Math.max(n.anchor,n.head)>t.content.size?null:ka(e,t.resolve(n.anchor),t.resolve(n.head))}function Hs(e,t){let n=e.firstChild.marks,r=t.firstChild.marks,i=n,a=r,o,s,l;for(let e=0;ee.mark(s.addToSet(e.marks));else if(i.length==0&&a.length==1)s=a[0],o=`remove`,l=e=>e.mark(s.removeFromSet(e.marks));else return null;let u=[];for(let e=0;en||Gs(o,!0,!1){e.isTextblock&&a>=t&&a0&&(t||e.indexAfter(r)==e.node(r).childCount);)r--,i++,t=!1;if(n){let t=e.node(r).maybeChild(e.indexAfter(r));for(;t&&!t.isLeaf;)t=t.firstChild,i++}return i}function Ks(e,t,n,r,i){let a=e.findDiffStart(t,n),o=n+e.size,s=n+t.size;if(a==null)return null;let{a:c,b:l}=e.findDiffEnd(t,o,s);if(i==`end`){let e=Math.max(0,a-Math.min(c,l));r-=c+e-a}if(c=c?a-r:0;a-=e,l=a+(l-c),c=a}else if(l=l?a-r:0;a-=e,c=a+(c-l),l=a}return{start:a,endA:c,endB:l}}var qs=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 _o,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(ec),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=Xs(this),Ys(this),this.nodeViews=Qs(this),this.docView=Qi(this.state.doc,Js(this),Ts(this),this.dom,this),this.domObserver=new ks(this,(e,t,n,r)=>Bs(this,e,t,n,r)),this.domObserver.start(),vo(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&&xo(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(ec),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let e in this._props)t[e]=this._props[e];t.state=this.state;for(let n in e)t[n]=e[n];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){let n=this.state,r=!1,i=!1;e.storedMarks&&this.composing&&(Ko(this),i=!0),this.state=e;let a=n.plugins!=e.plugins||this._props.plugins!=t.plugins;if(a||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let e=Qs(this);$s(e,this.nodeViews)&&(this.nodeViews=e,r=!0)}(a||t.handleDOMEvents!=this._props.handleDOMEvents)&&xo(this),this.editable=Xs(this),Ys(this);let o=Ts(this),s=Js(this),c=n.plugins!=e.plugins&&!n.doc.eq(e.doc)?`reset`:e.scrollToSelection>n.scrollToSelection?`to selection`:`preserve`,l=r||!this.docView.matchesNode(e.doc,s,o);(l||!e.selection.eq(n.selection))&&(i=!0);let u=c==`preserve`&&i&&this.dom.style.overflowAnchor==null&&hi(this);if(i){this.domObserver.stop();let t=l&&($r||I)&&!this.composing&&!n.selection.empty&&!e.selection.empty&&Zs(n.selection,e.selection);if(l){let n=I?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=qo(this)),(r||!this.docView.update(e.doc,s,o,this))&&(this.docView.updateOuterDeco(s),this.docView.destroy(),this.docView=Qi(e.doc,s,o,this.dom,this)),!n||this.trackWrites&&this.dom.contains(this.trackWrites)||(t=!0)}let i=this.input.mouseDown;t||!(i&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&Ma(this)&&i.delaySelUpdate())?ba(this,t):(Da(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(n),this.dragging?.node&&!n.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,n),c==`reset`?this.dom.scrollTop=0:c==`to selection`?this.scrollToSelection():u&&_i(u)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(e&&Rr(this.dom,e)&&!this.someProp(`handleScrollToSelection`,e=>e(this))){if(this.state.selection instanceof j){let t=this.docView.domAfterPos(this.state.selection.from);P(t)&&mi(this,t.getBoundingClientRect(),e)}else mi(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let e=0;e0&&ee.ownerDocument.getSelection()),this._root=e}return e||document}updateRoot(){this._root=null}posAtCoords(e){return Oi(this,e)}coordsAtPos(e,t=1){return Mi(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,n=-1){let r=this.docView.posFromDOM(e,t,n);if(r==null)throw RangeError(`DOM position not inside the editor`);return r}endOfTextblock(e,t){return Hi(this,t||this.state,e)}pasteHTML(e,t){return $o(this,``,e,!1,t||new ClipboardEvent(`paste`))}pasteText(e,t){return $o(this,e,null,!0,t||new ClipboardEvent(`paste`))}serializeForClipboard(e){return Za(this,e)}destroy(){this.docView&&(bo(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Ts(this),this),this.dom.textContent=``):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Nr())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return wo(this,e)}domSelectionRange(){let e=this.dom.isConnected!==!1&&this.domSelection();return e?ii&&this.root.nodeType===11&&Gr(this.dom.ownerDocument)==this.dom&&Ps(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}};qs.prototype.dispatch=function(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))};function Js(e){let t=Object.create(null);return t.class=`ProseMirror`,t.contenteditable=String(e.editable),e.someProp(`attributes`,n=>{if(typeof n==`function`&&(n=n(e.state)),n)for(let e in n)e==`class`?t.class+=` `+n[e]:e==`style`?t.style=(t.style?t.style+`;`:``)+n[e]:!t[e]&&e!=`contenteditable`&&e!=`nodeName`&&(t[e]=String(n[e]))}),t.translate||=`no`,[ds.node(0,e.state.doc.content.size,t)]}function Ys(e){if(e.markCursor){let t=document.createElement(`img`);t.className=`ProseMirror-separator`,t.setAttribute(`mark-placeholder`,`true`),t.setAttribute(`alt`,``),e.cursorWrapper={dom:t,deco:ds.widget(e.state.selection.from,t,{raw:!0,marks:e.markCursor})}}else e.cursorWrapper=null}function Xs(e){return!e.someProp(`editable`,t=>t(e.state)===!1)}function Zs(e,t){let n=Math.min(e.$anchor.sharedDepth(e.head),t.$anchor.sharedDepth(t.head));return e.$anchor.start(n)!=t.$anchor.start(n)}function Qs(e){let t=Object.create(null);function n(e){for(let n in e)Object.prototype.hasOwnProperty.call(t,n)||(t[n]=e[n])}return e.someProp(`nodeViews`,n),e.someProp(`markViews`,n),t}function $s(e,t){let n=0,r=0;for(let r in e){if(e[r]!=t[r])return!0;n++}for(let e in t)r++;return n!=r}function ec(e){if(e.spec.state||e.spec.filterTransaction||e.spec.appendTransaction)throw RangeError(`Plugins passed directly to the view must not have a state component`)}for(var tc={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:`'`},nc={48:`)`,49:`!`,50:`@`,51:`#`,52:`$`,53:`%`,54:`^`,55:`&`,56:`*`,57:`(`,59:`:`,61:`+`,173:`_`,186:`:`,187:`+`,188:`<`,189:`_`,190:`>`,191:`?`,192:`~`,219:`{`,220:`|`,221:`}`,222:`"`},rc=typeof navigator<`u`&&/Mac/.test(navigator.platform),ic=typeof navigator<`u`&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),ac=0;ac<10;ac++)tc[48+ac]=tc[96+ac]=String(ac);for(var ac=1;ac<=24;ac++)tc[ac+111]=`F`+ac;for(var ac=65;ac<=90;ac++)tc[ac]=String.fromCharCode(ac+32),nc[ac]=String.fromCharCode(ac);for(var oc in tc)nc.hasOwnProperty(oc)||(nc[oc]=tc[oc]);function sc(e){var t=!(rc&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||ic&&e.shiftKey&&e.key&&e.key.length==1||e.key==`Unidentified`)&&e.key||(e.shiftKey?nc:tc)[e.keyCode]||e.key||`Unidentified`;return t==`Esc`&&(t=`Escape`),t==`Del`&&(t=`Delete`),t==`Left`&&(t=`ArrowLeft`),t==`Up`&&(t=`ArrowUp`),t==`Right`&&(t=`ArrowRight`),t==`Down`&&(t=`ArrowDown`),t}var cc=typeof navigator<`u`&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),lc=typeof navigator<`u`&&/Win/.test(navigator.platform);function uc(e){let t=e.split(/-(?!$)/),n=t[t.length-1];n==`Space`&&(n=` `);let r,i,a,o;for(let e=0;e=t?R.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},R.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},R.prototype.forEach=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length),t<=n?this.forEachInner(e,t,n,0):this.forEachInvertedInner(e,t,n,0)},R.prototype.map=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length);var r=[];return this.forEach(function(t,n){return r.push(e(t,n))},t,n),r},R.from=function(e){return e instanceof R?e:e&&e.length?new gc(e):R.empty};var gc=function(e){function t(t){e.call(this),this.values=t}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var n={length:{configurable:!0},depth:{configurable:!0}};return t.prototype.flatten=function(){return this.values},t.prototype.sliceInner=function(e,n){return e==0&&n==this.length?this:new t(this.values.slice(e,n))},t.prototype.getInner=function(e){return this.values[e]},t.prototype.forEachInner=function(e,t,n,r){for(var i=t;i=n;i--)if(e(this.values[i],r+i)===!1)return!1},t.prototype.leafAppend=function(e){if(this.length+e.length<=hc)return new t(this.values.concat(e.flatten()))},t.prototype.leafPrepend=function(e){if(this.length+e.length<=hc)return new t(e.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(t.prototype,n),t}(R);R.empty=new gc([]);var _c=function(e){function t(t,n){e.call(this),this.left=t,this.right=n,this.length=t.length+n.length,this.depth=Math.max(t.depth,n.depth)+1}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},t.prototype.getInner=function(e){return ei&&this.right.forEachInner(e,Math.max(t-i,0),Math.min(this.length,n)-i,r+i)===!1)return!1},t.prototype.forEachInvertedInner=function(e,t,n,r){var i=this.left.length;if(t>i&&this.right.forEachInvertedInner(e,t-i,Math.max(n,i)-i,r+i)===!1||n=n?this.right.slice(e-n,t-n):this.left.slice(e,n).append(this.right.slice(0,t-n))},t.prototype.leafAppend=function(e){var n=this.right.leafAppend(e);if(n)return new t(this.left,n)},t.prototype.leafPrepend=function(e){var n=this.left.leafPrepend(e);if(n)return new t(n,this.right)},t.prototype.appendInner=function(e){return this.left.depth>=Math.max(this.right.depth,e.depth)+1?new t(this.left,new t(this.right,e)):new t(this,e)},t}(R),vc=500,yc=class e{constructor(e,t){this.items=e,this.eventCount=t}popEvent(t,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let i,a;n&&(i=this.remapping(r,this.items.length),a=i.maps.length);let o=t.tr,s,c,l=[],u=[];return this.items.forEach((t,n)=>{if(!t.step)i||(i=this.remapping(r,n+1),a=i.maps.length),a--,u.push(t);else{if(i){u.push(new xc(t.map));let e=t.step.map(i.slice(a)),n;e&&o.maybeStep(e).doc&&(n=o.mapping.maps[o.mapping.maps.length-1],l.push(new xc(n,void 0,void 0,l.length+u.length))),a--,n&&i.appendMap(n,a)}else o.maybeStep(t.step);if(t.selection)return s=i?t.selection.map(i.slice(a)):t.selection,c=new e(this.items.slice(0,r).append(u.reverse().concat(l)),this.eventCount-1),!1}},this.items.length,0),{remaining:c,transform:o,selection:s}}addTransform(t,n,r,i){let a=[],o=this.eventCount,s=this.items,c=!i&&s.length?s.get(s.length-1):null;for(let e=0;eCc&&(s=bc(s,l),o-=l),new e(s.append(a),o)}remapping(e,t){let n=new ft;return this.items.forEach((t,r)=>{let i=t.mirrorOffset!=null&&r-t.mirrorOffset>=e?n.maps.length-t.mirrorOffset:void 0;n.appendMap(t.map,i)},e,t),n}addMaps(t){return this.eventCount==0?this:new e(this.items.append(t.map(e=>new xc(e))),this.eventCount)}rebased(t,n){if(!this.eventCount)return this;n=Math.min(this.items.length,n);let r=[],i=this.items.length-n,a=t.mapping,o=t.steps.length,s=this.eventCount;this.items.forEach(e=>{e.selection&&s--},i);let c=n;this.items.forEach(e=>{let n=a.getMirror(--c);if(n==null)return;o=Math.min(o,n);let i=a.maps[n];if(e.step){let o=t.steps[n].invert(t.docs[n]),l=e.selection&&e.selection.map(a.slice(c+1,n));l&&s++,r.push(new xc(i,o,l))}else r.push(new xc(i))},i);let l=[];for(let e=n;evc&&(d=d.compress(this.items.length-r.length)),d}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(t=this.items.length){let n=this.remapping(0,t),r=n.maps.length,i=[],a=0;return this.items.forEach((e,o)=>{if(o>=t)i.push(e),e.selection&&a++;else if(e.step){let t=e.step.map(n.slice(r)),o=t&&t.getMap();if(r--,o&&n.appendMap(o,r),t){let s=e.selection&&e.selection.map(n.slice(r));s&&a++;let c=new xc(o.invert(),t,s),l,u=i.length-1;(l=i.length&&i[u].merge(c))?i[u]=l:i.push(c)}}else e.map&&r--},this.items.length,0),new e(R.from(i.reverse()),a)}};yc.empty=new yc(R.empty,0);function bc(e,t){let n;return e.forEach((e,r)=>{if(e.selection&&t--==0)return n=r,!1}),e.slice(n)}var xc=class e{constructor(e,t,n,r){this.map=e,this.step=t,this.selection=n,this.mirrorOffset=r}merge(t){if(this.step&&t.step&&!t.selection){let n=t.step.merge(this.step);if(n)return new e(n.getMap().invert(),n,this.selection)}}},Sc=class{constructor(e,t,n,r,i){this.done=e,this.undone=t,this.prevRanges=n,this.prevTime=r,this.prevComposition=i}},Cc=20;function wc(e,t,n,r){let i=n.getMeta(Nc),a;if(i)return i.historyState;n.getMeta(Pc)&&(e=new Sc(e.done,e.undone,null,0,-1));let o=n.getMeta(`appendedTransaction`);if(n.steps.length==0)return e;if(o&&o.getMeta(Nc))return o.getMeta(Nc).redo?new Sc(e.done.addTransform(n,void 0,r,jc(t)),e.undone,Ec(n.mapping.maps),e.prevTime,e.prevComposition):new Sc(e.done,e.undone.addTransform(n,void 0,r,jc(t)),null,e.prevTime,e.prevComposition);if(n.getMeta(`addToHistory`)!==!1&&!(o&&o.getMeta(`addToHistory`)===!1)){let i=n.getMeta(`composition`),a=e.prevTime==0||!o&&e.prevComposition!=i&&(e.prevTime<(n.time||0)-r.newGroupDelay||!Tc(n,e.prevRanges)),s=o?Dc(e.prevRanges,n.mapping):Ec(n.mapping.maps);return new Sc(e.done.addTransform(n,a?t.selection.getBookmark():void 0,r,jc(t)),yc.empty,s,n.time,i??e.prevComposition)}return(a=n.getMeta(`rebased`))?new Sc(e.done.rebased(n,a),e.undone.rebased(n,a),Dc(e.prevRanges,n.mapping),e.prevTime,e.prevComposition):new Sc(e.done.addMaps(n.mapping.maps),e.undone.addMaps(n.mapping.maps),Dc(e.prevRanges,n.mapping),e.prevTime,e.prevComposition)}function Tc(e,t){if(!t)return!1;if(!e.docChanged)return!0;let n=!1;return e.mapping.maps[0].forEach((e,r)=>{for(let i=0;i=t[i]&&(n=!0)}),n}function Ec(e){let t=[];for(let n=e.length-1;n>=0&&t.length==0;n--)e[n].forEach((e,n,r,i)=>t.push(r,i));return t}function Dc(e,t){if(!e)return null;let n=[];for(let r=0;r{let i=Nc.getState(n);if(!i||(e?i.undone:i.done).eventCount==0)return!1;if(r){let a=Oc(i,n,e);a&&r(t?a.scrollIntoView():a)}return!0}}var Lc=Ic(!1,!0),Rc=Ic(!0,!0);function zc(e){return e.getMeta(Nc)!=null}function Bc(e){let{state:t,transaction:n}=e,{selection:r}=n,{doc:i}=n,{storedMarks:a}=n;return{...t,apply:t.apply.bind(t),applyTransaction:t.applyTransaction.bind(t),plugins:t.plugins,schema:t.schema,reconfigure:t.reconfigure.bind(t),toJSON:t.toJSON.bind(t),get storedMarks(){return a},get selection(){return r},get doc(){return i},get tr(){return r=n.selection,i=n.doc,a=n.storedMarks,n}}}var Vc=class e{constructor(e){this.editor=e.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=e.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){let{rawCommands:e,editor:t,state:n}=this,{view:r}=t,{tr:i}=n,a=this.buildProps(i);return Object.fromEntries(Object.entries(e).map(([e,t])=>[e,(...e)=>{let n=t(...e)(a);return!i.getMeta(`preventDispatch`)&&!this.hasCustomState&&r.dispatch(i),n}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(e,t=!0){let{rawCommands:n,editor:r,state:i}=this,{view:a}=r,o=[],s=!!e,c=e||i.tr,l=()=>(!s&&t&&!c.getMeta(`preventDispatch`)&&!this.hasCustomState&&a.dispatch(c),o.every(e=>e===!0)),u={...Object.fromEntries(Object.entries(n).map(([e,n])=>[e,(...e)=>{let r=this.buildProps(c,t),i=n(...e)(r);return o.push(i),u}])),run:l};return u}static createFakeChain(){let e=new Proxy({},{get:(t,n)=>{if(n!==`then`)return n===`run`?()=>!1:()=>e}});return e}createCan(e){let{rawCommands:t,state:n}=this,r=e||n.tr,i=this.buildProps(r,!1);return{...Object.fromEntries(Object.entries(t).map(([e,t])=>[e,(...e)=>t(...e)({...i,dispatch:void 0})])),chain:()=>this.createChain(r,!1)}}static createFallbackCan(){let t=e.createFakeChain();return new Proxy({chain:()=>t},{get:(e,t)=>{if(t!==`then`)return t===`chain`?e.chain:()=>!1}})}buildProps(e,t=!0){let{rawCommands:n,editor:r,state:i}=this,{view:a}=r,o={tr:e,editor:r,view:a,state:Bc({state:i,transaction:e}),dispatch:t?()=>void 0:void 0,chain:()=>this.createChain(e,t),can:()=>this.createCan(e),get commands(){return Object.fromEntries(Object.entries(n).map(([e,t])=>[e,(...e)=>t(...e)(o)]))}};return o}},Hc=()=>({editor:e,view:t})=>(requestAnimationFrame(()=>{if(!e.isDestroyed){var n;t.dom.blur(),(n=window)==null||(n=n.getSelection())==null||n.removeAllRanges()}}),!0),Uc=(e=!0)=>({commands:t})=>t.setContent(``,{emitUpdate:e}),Wc=()=>({tr:e,dispatch:t})=>{let{selection:n}=e,{ranges:r}=n;if(!t)return!0;let i=e.mapping.maps.length;return r.forEach(({$from:t,$to:n})=>{let r=t.pos,a=n.pos,o=e.mapping.slice(i),s=1;e.doc.nodesBetween(o.map(r),o.map(a),(t,n)=>{s=Math.max(s,e.doc.resolve(n).depth+1)});for(let t=0;t{if(t.type.isText)return;e.mapping.maps.length!==s&&(s=e.mapping.maps.length,c=e.mapping.slice(n));let i=e.doc.resolve(c.map(r)),a=e.doc.resolve(c.map(r+t.nodeSize)),o=i.blockRange(a);if(!o)return;let l=kt(o);if(t.type.isTextblock){let{defaultType:t}=i.parent.contentMatchAt(i.index()),n=e.doc.nodeAt(o.start);t&&n&&!n.hasMarkup(t)&&t.validContent(n.content)&&e.setNodeMarkup(o.start,t)}(l||l===0)&&e.lift(o,l)}),e.doc.eq(t))break}}),!0},Gc=e=>t=>e(t),Kc=()=>({state:e,dispatch:t})=>ir(e,t),qc=(e,t)=>({editor:n,tr:r})=>{let{state:i}=n,a=i.doc.slice(e.from,e.to);r.deleteRange(e.from,e.to);let o=r.mapping.map(t);return r.insert(o,a.content),r.setSelection(new A(r.doc.resolve(Math.max(o-1,0)))),!0},Jc=()=>({tr:e,dispatch:t})=>{let{selection:n}=e,r=n.$anchor.node();if(r.content.size>0)return!1;let i=e.selection.$anchor;for(let n=i.depth;n>0;--n)if(i.node(n).type===r.type){if(t){let t=i.before(n),r=i.after(n);e.delete(t,r).scrollIntoView()}return!0}return!1};function z(e,t){if(typeof e==`string`){if(!t.nodes[e])throw Error(`There is no node type named '${e}'. Maybe you forgot to add the extension?`);return t.nodes[e]}return e}var Yc=e=>({tr:t,state:n,dispatch:r})=>{let i=z(e,n.schema),a=t.selection.$anchor;for(let e=a.depth;e>0;--e)if(a.node(e).type===i){if(r){let n=a.before(e),r=a.after(e);t.delete(n,r).scrollIntoView()}return!0}return!1},Xc=e=>({tr:t,dispatch:n})=>{let{from:r,to:i}=e;return n&&t.delete(r,i),!0},Zc=e=>e.content?/^text(\*|\+)/.test(e.content):!1,Qc=(e,t,n)=>{if(!e.parent.isInline||n===`left`&&e.pos>e.start()||n===`right`&&e.pos({from:Qc(e,n,`left`),to:Qc(t,n,`right`)}),el=()=>({state:e,dispatch:t})=>{if(e.selection.empty)return!1;if(t){let n=e.tr,{ranges:r}=e.selection,i=e.selection instanceof A?e.selection.$from.marksAcross(e.selection.$to):null,a=n.steps.length;r.forEach(t=>{let r=n.mapping.slice(a),{from:i,to:o}=$c(n.doc.resolve(r.map(t.$from.pos)),n.doc.resolve(r.map(t.$to.pos)),e.schema);n.deleteRange(i,o)}),n.selection.empty||n.setSelection(A.near(n.doc.resolve(n.selection.from))),i&&n.ensureMarks(i),n.scrollIntoView(),t(n)}return!0},tl=()=>({commands:e})=>e.keyboardShortcut(`Enter`),nl=()=>({state:e,dispatch:t})=>rr(e,t);function rl(e){return Object.prototype.toString.call(e)===`[object RegExp]`}function il(e,t,n={strict:!0}){let r=Object.keys(t);return!r.length||r.every(r=>n.strict?t[r]===e[r]:rl(t[r])?t[r].test(e[r]):t[r]===e[r])}function al(e,t,n={}){return e.find(e=>e.type===t&&il(Object.fromEntries(Object.keys(n).map(t=>[t,e.attrs[t]])),n))}function ol(e,t,n={}){return!!al(e,t,n)}function sl(e,t,n){if(!e||!t)return;let r=e.parent.childAfter(e.parentOffset);if(r.node&&r.node.marks.some(e=>e.type===t)||(r=e.parent.childBefore(e.parentOffset)),!r.node||!r.node.marks.some(e=>e.type===t))return;if(!n){let e=r.node.marks.find(e=>e.type===t);e&&(n=e.attrs)}if(!al([...r.node.marks],t,n))return;let i=r.index,a=e.start()+r.offset,o=i+1,s=a+r.node.nodeSize;for(;i>0&&ol([...e.parent.child(i-1).marks],t,n);)--i,a-=e.parent.child(i).nodeSize;for(;o({tr:n,state:r,dispatch:i})=>{let a=cl(e,r.schema),{doc:o,selection:s}=n,{$from:c,from:l,to:u}=s;if(i){let e=sl(c,a,t);if(e&&e.from<=l&&e.to>=u){let t=A.create(o,e.from,e.to);n.setSelection(t)}}return!0},ul=e=>t=>{let n=typeof e==`function`?e(t):e;for(let e=0;e({editor:n,view:r,tr:i,dispatch:a})=>{t={scrollIntoView:!0,...t};let o=()=>{(hl()||ml())&&r.dom.focus(),gl()&&!hl()&&!ml()&&r.dom.focus({preventScroll:!0}),requestAnimationFrame(()=>{n.isDestroyed||(r.focus(),t?.scrollIntoView&&n.commands.scrollIntoView())})};try{if(r.hasFocus()&&e===null||e===!1)return!0}catch{return!1}if(a&&e===null&&!dl(n.state.selection))return o(),!0;let s=pl(i.doc,e)||n.state.selection,c=n.state.selection.eq(s);return a&&(c||i.setSelection(s),c&&i.storedMarks&&i.setStoredMarks(i.storedMarks),o()),!0},vl=(e,t)=>n=>e.every((e,r)=>t(e,{...n,index:r})),yl=(e,t)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},e,t),bl=e=>{let t=e.childNodes;for(let n=t.length-1;n>=0;--n){let r=t[n];r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?e.removeChild(r):r.nodeType===1&&bl(r)}return e};function xl(e){if(typeof window>`u`)throw Error(`[tiptap error]: there is no window object available, so this function cannot be used`);let t=`${e}`,n=new window.DOMParser().parseFromString(t,`text/html`).body;return bl(n)}function Sl(e){return typeof e?.nodesBetween==`function`}function Cl(e,t,n){if(Sl(e))return e;let r=typeof e==`object`&&!!e;n={slice:!0,parseOptions:{},...n};let i=typeof e==`string`;if(r)try{if(Array.isArray(e)&&e.length>0)return c.fromArray(e.map(e=>t.nodeFromJSON(e)));let r=t.nodeFromJSON(e);return n.errorOnInvalidContent&&r.check(),r}catch(r){if(n.errorOnInvalidContent)throw Error(`[tiptap error]: Invalid JSON content`,{cause:r});return console.warn(`[tiptap warn]: Invalid content.`,`Passed value:`,e,`Error:`,r),Cl(``,t,n)}if(i){if(n.errorOnInvalidContent){let r=!1,i=``,a=new Ae({topNode:t.spec.topNode,marks:t.spec.marks,nodes:t.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:`inline*`,group:`block`,parseDOM:[{tag:`*`,getAttrs:e=>(r=!0,i=typeof e==`string`?e:e.outerHTML,null)}]}})});if(n.slice?Pe.fromSchema(a).parseSlice(xl(e),n.parseOptions):Pe.fromSchema(a).parse(xl(e),n.parseOptions),n.errorOnInvalidContent&&r)throw Error(`[tiptap error]: Invalid HTML content`,{cause:Error(`Invalid element found: ${i}`)})}let r=Pe.fromSchema(t);return n.slice?r.parseSlice(xl(e),n.parseOptions).content:r.parse(xl(e),n.parseOptions)}return Cl(``,t,n)}function wl(e){return!(`type`in e)}function Tl(e,t,n){let r=e.steps.length-1;if(r{o===0&&(o=r)}),e.setSelection(k.near(e.doc.resolve(o),n))}var El=(e,t,n)=>({tr:r,dispatch:i,editor:a})=>{if(i){n={parseOptions:a.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};let i,o=e=>{a.emit(`contentError`,{editor:a,error:e,disableCollaboration:()=>{`collaboration`in a.storage&&typeof a.storage.collaboration==`object`&&a.storage.collaboration&&(a.storage.collaboration.isDisabled=!0)}})},s={preserveWhitespace:`full`,...n.parseOptions};if(!n.errorOnInvalidContent&&!a.options.enableContentCheck&&a.options.emitContentError)try{Cl(t,a.schema,{parseOptions:s,errorOnInvalidContent:!0})}catch(e){o(e)}try{i=Cl(t,a.schema,{parseOptions:s,errorOnInvalidContent:n.errorOnInvalidContent??a.options.enableContentCheck})}catch(e){return o(e),!1}let{from:l,to:u}=typeof e==`number`?{from:e,to:e}:{from:e.from,to:e.to},d=!0,f=!0,p=wl(i)?i.content:[i];if(p.forEach(e=>{e.check(),d=d?e.isText&&e.marks.length===0:!1,f=f?e.isBlock:!1}),l===u&&f){let{parent:e}=r.doc.resolve(l);e.isTextblock&&!e.type.spec.code&&!e.childCount&&(--l,u+=1)}let m;if(d)m=Array.isArray(t)?t.map(e=>e.text||``).join(``):Sl(t)?p.map(e=>e.text??``).join(``):typeof t==`object`&&t&&t.text?t.text:t,r.insertText(m,l,u);else{m=c.from(p);let e=r.doc.resolve(l),t=e.node(),n=e.parentOffset===0,i=t.isText||t.isTextblock,a=t.content.size>0;n&&i&&a&&f&&(l=Math.max(0,l-1)),r.replaceWith(l,u,p)}n.updateSelection&&Tl(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta(`applyInputRules`,{from:l,text:m}),n.applyPasteRules&&r.setMeta(`applyPasteRules`,{from:l,text:m})}return!0};function Dl(e){for(let t=0;t({tr:t,dispatch:n,editor:r})=>{let{pos:i,attrs:a,content:o,updateSelection:s=!0}=e,c;c=typeof i==`number`?t.doc.resolve(i):i||t.selection.$from;let l=Dl(c.parent.contentMatchAt(c.index()));if(!l)return!1;let u=Object.keys(l.spec.attrs||{}),d=a?Object.fromEntries(Object.entries(a).filter(([e])=>u.includes(e))):{},f;if(o){let e=Cl(o,r.schema);f=l.createAndFill(d,e)}else f=l.createAndFill(d);return f?(n&&(t.insert(c.pos,f),s&&Tl(t,t.steps.length-1,-1)),!0):!1},kl=()=>({state:e,dispatch:t})=>Qn(e,t),Al=()=>({state:e,dispatch:t})=>$n(e,t),jl=()=>({state:e,dispatch:t})=>Vn(e,t),Ml=()=>({state:e,dispatch:t})=>Yn(e,t),Nl=(e,t)=>{let n=e.resolve(t),r=n.nodeBefore,i=n.nodeAfter;return!r||!i?!1:!r.type.spec.isolating&&!i.type.spec.isolating},Pl=()=>({state:e,dispatch:t,tr:n})=>{try{let r=Kt(e.doc,e.selection.$from.pos,-1);return r==null||!Nl(e.doc,r)?!1:(n.join(r,2),t&&t(n),!0)}catch{return!1}},Fl=()=>({state:e,dispatch:t,tr:n})=>{try{let r=Kt(e.doc,e.selection.$from.pos,1);return r==null||!Nl(e.doc,r)?!1:(n.join(r,2),t&&t(n),!0)}catch{return!1}},Il=()=>({state:e,dispatch:t})=>Hn(e,t),Ll=()=>({state:e,dispatch:t})=>Un(e,t);function Rl(){return typeof navigator<`u`&&/Mac/.test(navigator.platform)}function zl(e){let t=e.split(/-(?!$)/),n=t[t.length-1];n===`Space`&&(n=` `);let r,i,a,o;for(let e=0;e({editor:t,view:n,tr:r,dispatch:i})=>{let a=zl(e).split(/-(?!$)/),o=a.find(e=>![`Alt`,`Ctrl`,`Meta`,`Shift`].includes(e)),s=new KeyboardEvent(`keydown`,{key:o===`Space`?` `:o,altKey:a.includes(`Alt`),ctrlKey:a.includes(`Ctrl`),metaKey:a.includes(`Meta`),shiftKey:a.includes(`Shift`),bubbles:!0,cancelable:!0});return t.captureTransaction(()=>{n.someProp(`handleKeyDown`,e=>e(n,s))})?.steps.forEach(e=>{let t=e.map(r.mapping);t&&i&&r.maybeStep(t)}),!0};function Vl(e,t,n={}){let{from:r,to:i,empty:a}=e.selection,o=t?z(t,e.schema):null,s=[];e.doc.nodesBetween(r,i,(e,t)=>{if(e.isText)return;let n=Math.max(r,t),a=Math.min(i,t+e.nodeSize);s.push({node:e,from:n,to:a})});let c=i-r,l=s.filter(e=>!o||o.name===e.node.type.name).filter(e=>il(e.node.attrs,n,{strict:!1}));return a?!!l.length:l.reduce((e,t)=>e+t.to-t.from,0)>=c}var Hl=(e,t={})=>({state:n,dispatch:r})=>Vl(n,z(e,n.schema),t)?er(n,r):!1,Ul=()=>({state:e,dispatch:t})=>ar(e,t),Wl=e=>({state:t,dispatch:n})=>Tr(z(e,t.schema))(t,n),Gl=()=>({state:e,dispatch:t})=>tr(e,t);function Kl(e,t){return t.nodes[e]?`node`:t.marks[e]?`mark`:null}function ql(e,t){let n=typeof t==`string`?[t]:t;return Object.keys(e).reduce((t,r)=>(n.includes(r)||(t[r]=e[r]),t),{})}var Jl=(e,t)=>({tr:n,state:r,dispatch:i})=>{let a=null,o=null,s=Kl(typeof e==`string`?e:e.name,r.schema);if(!s)return!1;s===`node`&&(a=z(e,r.schema)),s===`mark`&&(o=cl(e,r.schema));let c=!1;return n.selection.ranges.forEach(e=>{r.doc.nodesBetween(e.$from.pos,e.$to.pos,(e,r)=>{a&&a===e.type&&(c=!0,i&&n.setNodeMarkup(r,void 0,ql(e.attrs,t))),o&&e.marks.length&&e.marks.forEach(a=>{o===a.type&&(c=!0,i&&n.addMark(r,r+e.nodeSize,o.create(ql(a.attrs,t))))})})}),c},Yl=()=>({tr:e,dispatch:t})=>(t&&e.scrollIntoView(),!0),Xl=()=>({tr:e,dispatch:t})=>{if(t){let t=new Cn(e.doc);e.setSelection(t)}return!0},Zl=()=>({state:e,dispatch:t})=>Kn(e,t),Ql=()=>({state:e,dispatch:t})=>Xn(e,t),$l=()=>({state:e,dispatch:t})=>cr(e,t),eu=()=>({state:e,dispatch:t})=>mr(e,t),tu=()=>({state:e,dispatch:t})=>pr(e,t);function nu(e,t,n={},r={}){return Cl(e,t,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var ru=(e,{errorOnInvalidContent:t,emitUpdate:n=!0,parseOptions:r={}}={})=>({editor:i,tr:a,dispatch:o,commands:s})=>{let{doc:c}=a;if(r.preserveWhitespace!==`full`){let s=nu(e,i.schema,r,{errorOnInvalidContent:t??i.options.enableContentCheck});if(o){let e=wl(s)?s.content:[s];a.replaceWith(0,c.content.size,e).setMeta(`preventUpdate`,!n)}return!0}return o&&a.setMeta(`preventUpdate`,!n),s.insertContentAt({from:0,to:c.content.size},e,{parseOptions:r,errorOnInvalidContent:t??i.options.enableContentCheck})};function iu(e,t){let n=cl(t,e.schema),{from:r,to:i,empty:a}=e.selection,o=[];a?(e.storedMarks&&o.push(...e.storedMarks),o.push(...e.selection.$head.marks())):e.doc.nodesBetween(r,i,e=>{o.push(...e.marks)});let s=o.find(e=>e.type.name===n.name);return s?{...s.attrs}:{}}function au(e,t){let n=new gn(e);return t.forEach(e=>{e.steps.forEach(e=>{n.step(e)})}),n}function ou(e,t,n){let r=[];return e.nodesBetween(t.from,t.to,(e,t)=>{n(e)&&r.push({node:e,pos:t})}),r}function su(e,t){for(let n=e.depth;n>0;--n){let r=e.node(n);if(t(r))return{pos:n>0?e.before(n):0,start:e.start(n),depth:n,node:r}}}function cu(e){return t=>su(t.$from,e)}function B(e,t,n){return e.config[t]===void 0&&e.parent?B(e.parent,t,n):typeof e.config[t]==`function`?e.config[t].bind({...n,parent:e.parent?B(e.parent,t,n):null}):e.config[t]}function lu(e){return e.map(e=>{let t=B(e,`addExtensions`,{name:e.name,options:e.options,storage:e.storage});return t?[e,...lu(t())]:e}).flat(10)}function uu(e,t){let n=Je.fromSchema(t).serializeFragment(e),r=document.implementation.createHTMLDocument().createElement(`div`);return r.appendChild(n),r.innerHTML}function du(e,t){let n=new Map;for(let t of e){let e=n.get(t.type)??new Map;e.set(t.name,t),n.set(t.type,e)}return[...Object.values(t.nodes),...Object.values(t.marks)].flatMap(e=>Object.entries(e.spec.attrs??{}).map(([t,r])=>{let i=n.get(e.name)?.get(t),a=Object.hasOwn(r,`default`);return{type:e.name,name:t,attribute:{rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,...i?.attribute,default:r.default,isRequired:!a,validate:r.validate}}}))}var fu={content:`string`,marks:`string`,group:`string`,inline:`boolean`,atom:`boolean`,selectable:`boolean`,draggable:`boolean`,code:`boolean`,whitespace:[`pre`,`normal`],definingAsContext:`boolean`,definingForContent:`boolean`,defining:`boolean`,isolating:`boolean`,linebreakReplacement:`boolean`},pu={inclusive:`boolean`,excludes:`string`,group:`string`,spanning:`boolean`,code:`boolean`};function mu(e,t,n){return Object.fromEntries(Object.entries(t).flatMap(([t,r])=>{let i=e[t];if(i===void 0)return[];if(!(typeof r==`string`?typeof i===r:typeof i==`string`&&r.includes(i)))throw RangeError(`Invalid schemaSpec field '${n}.${t}'`);return[[t,i]]}))}function hu(e,t,n,r){return{...Object.fromEntries(Object.entries(t).filter(([e])=>e!==`attrs`&&!Object.hasOwn(r,e))),...mu(n,r,e),attrs:n.attrs}}function gu(e,t,n){for(let r of Object.keys(t))if(!Object.hasOwn(e,r))throw RangeError(`schemaSpec requires a local ${n} extension named '${r}'`);for(let r of Object.keys(e))if(!Object.hasOwn(t,r))throw RangeError(`Local ${n} extension '${r}' is not in schemaSpec`)}function _u(e,t){gu(e.nodes,t.nodes,`node`),gu(e.marks,t.marks,`mark`);let n=t.spec.nodes,r=t.spec.marks;return t.spec.nodes.forEach((t,r)=>{n=n.update(t,hu(t,e.nodes[t],r,fu))}),t.spec.marks.forEach((t,n)=>{r=r.update(t,hu(t,e.marks[t],n,pu))}),{topNode:t.topNodeType.name,nodes:n,marks:r}}function vu(e){let t=e.filter((t,n)=>e.indexOf(t)!==n);return Array.from(new Set(t))}function yu(e){return{baseExtensions:e.filter(e=>e.type===`extension`),nodeExtensions:e.filter(e=>e.type===`node`),markExtensions:e.filter(e=>e.type===`mark`)}}function bu(e){let t=[],{nodeExtensions:n,markExtensions:r}=yu(e),i=[...n,...r],a={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1},o=n.filter(e=>e.name!==`text`).map(e=>e.name),s=r.map(e=>e.name),c=[...o,...s];return e.forEach(e=>{let n=B(e,`addGlobalAttributes`,{name:e.name,options:e.options,storage:e.storage,extensions:i});n&&n().forEach(e=>{let n;n=Array.isArray(e.types)?e.types:e.types===`*`?c:e.types===`nodes`?o:e.types===`marks`?s:[],n.forEach(n=>{Object.entries(e.attributes).forEach(([e,r])=>{t.push({type:n,name:e,attribute:{...a,...r}})})})})}),i.forEach(e=>{let n=B(e,`addAttributes`,{name:e.name,options:e.options,storage:e.storage});if(!n)return;let r=n();Object.entries(r).forEach(([n,r])=>{let i={...a,...r};typeof i?.default==`function`&&(i.default=i.default()),i?.isRequired&&i?.default===void 0&&delete i.default,t.push({type:e.name,name:n,attribute:i})})}),t}function xu(e){return typeof e==`function`}function V(e,t=void 0,...n){return xu(e)?t?e.bind(t)(...n):e(...n):e}function Su(e={}){return Object.keys(e).length===0&&e.constructor===Object}function Cu(e){let t=[],n=``,r=!1,i=!1,a=0,o=e.length;for(let s=0;s0){--a,n+=o;continue}if(o===`;`&&a===0){t.push(n),n=``;continue}}n+=o}}return n&&t.push(n),t}function wu(e){let t=[],n=Cu(e||``),r=n.length;for(let e=0;e!!e).reduce((e,t)=>{let n={...e};return Object.entries(t).forEach(([e,t])=>{if(e===`__proto__`)Object.defineProperty(n,e,{configurable:!0,enumerable:!0,value:t,writable:!0});else if(!n[e])n[e]=t;else if(e===`class`){let r=t?String(t).split(` `):[],i=n[e]?n[e].split(` `):[],a=r.filter(e=>!i.includes(e));n[e]=[...i,...a].join(` `)}else if(e===`style`){let r=new Map([...wu(n[e]),...wu(t)]);n[e]=Array.from(r.entries()).map(([e,t])=>`${e}: ${t}`).join(`; `)}else n[e]=t}),n},{})}function Tu(e,t){return t.filter(t=>t.type===e.type.name).filter(e=>e.attribute.rendered).map(t=>t.attribute.renderHTML?t.attribute.renderHTML(e.attrs)||{}:{[t.name]:e.attrs[t.name]}).reduce((e,t)=>H(e,t),{})}function Eu(e){return typeof e==`string`?e.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(e):e===`true`||e!==`false`&&e:e}function Du(e,t){return`style`in e?e:{...e,getAttrs:n=>{let r=e.getAttrs?e.getAttrs(n):e.attrs;if(r===!1)return!1;let i=t.reduce((e,t)=>{let r=t.attribute.parseHTML?t.attribute.parseHTML(n):Eu(n.getAttribute(t.name));return r==null?e:{...e,[t.name]:r}},{});return{...r,...i}}}}function Ou(e){return Object.fromEntries(Object.entries(e).filter(([e,t])=>e===`attrs`&&Su(t)?!1:t!=null))}function ku(e){var t,n;let r={};return!(e!=null&&(t=e.attribute)!=null&&t.isRequired)&&`default`in(e?.attribute||{})&&(r.default=e.attribute.default),(e==null||(n=e.attribute)==null?void 0:n.validate)!==void 0&&(r.validate=e.attribute.validate),[e.name,r]}function Au(e,t,n=bu(e)){let{nodeExtensions:r,markExtensions:i}=yu(e);return{topNode:r.find(e=>B(e,`topNode`))?.name,nodes:Object.fromEntries(r.map(r=>{let i=n.filter(e=>e.type===r.name),a={name:r.name,options:r.options,storage:r.storage,editor:t},o=Ou({...e.reduce((e,t)=>{let n=B(t,`extendNodeSchema`,a);return{...e,...n?n(r):{}}},{}),content:V(B(r,`content`,a)),marks:V(B(r,`marks`,a)),group:V(B(r,`group`,a)),inline:V(B(r,`inline`,a)),atom:V(B(r,`atom`,a)),selectable:V(B(r,`selectable`,a)),draggable:V(B(r,`draggable`,a)),code:V(B(r,`code`,a)),whitespace:V(B(r,`whitespace`,a)),linebreakReplacement:V(B(r,`linebreakReplacement`,a)),defining:V(B(r,`defining`,a)),isolating:V(B(r,`isolating`,a)),attrs:Object.fromEntries(i.map(ku))}),s=V(B(r,`parseHTML`,a));s&&(o.parseDOM=s.map(e=>Du(e,i)));let c=B(r,`renderHTML`,a);c&&(o.toDOM=e=>c({node:e,HTMLAttributes:Tu(e,i)}));let l=B(r,`renderText`,a);return l&&(o.toText=l),[r.name,o]})),marks:Object.fromEntries(i.map(r=>{let i=n.filter(e=>e.type===r.name),a={name:r.name,options:r.options,storage:r.storage,editor:t},o=Ou({...e.reduce((e,t)=>{let n=B(t,`extendMarkSchema`,a);return{...e,...n?n(r):{}}},{}),inclusive:V(B(r,`inclusive`,a)),excludes:V(B(r,`excludes`,a)),group:V(B(r,`group`,a)),spanning:V(B(r,`spanning`,a)),code:V(B(r,`code`,a)),attrs:Object.fromEntries(i.map(ku))}),s=V(B(r,`parseHTML`,a));s&&(o.parseDOM=s.map(e=>Du(e,i)));let c=B(r,`renderHTML`,a);return c&&(o.toDOM=e=>c({mark:e,HTMLAttributes:Tu(e,i)})),[r.name,o]}))}}function ju(e,t,n){if(n===void 0)return new Ae(Au(e,t));let r=vu(e.filter(e=>e.type!==`extension`).map(e=>e.name));if(r.length)throw RangeError(`Duplicate local schema types: ${r.join(`, `)}`);let i=new Ae(n);return new Ae(_u(Au(e,t,du(bu(e),i)),i))}function Mu(e){return e.sort((e,t)=>{let n=B(e,`priority`)||100,r=B(t,`priority`)||100;return n>r?-1:+(ne.name));return n.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${n.map(e=>`'${e}'`).join(`, `)}]. This can lead to issues.`),t}function Pu(e,t){return ju(Nu(e),t)}function Fu(e,t,n){let{from:r,to:i}=t,{blockSeparator:a=` +`),slice:t}}function $a(e,t,n,r,i){let a=i.parent.type.spec.code,o,s;if(!n&&!t)return null;let l=!!t&&(r||a||!n);if(l){if(e.someProp(`transformPastedText`,n=>{t=n(t,a||r,e)}),a)return s=new m(c.from(e.state.schema.text(t.replace(/\r\n?/g,` +`))),0,0),e.someProp(`transformPasted`,t=>{s=t(s,e,!0)}),s;let n=e.someProp(`clipboardTextParser`,n=>n(t,i,r,e));if(n)s=n;else{let n=i.marks(),{schema:r}=e.state,a=Je.fromSchema(r);o=document.createElement(`div`),t.split(/(?:\r\n?|\n)+/).forEach(e=>{let t=o.appendChild(document.createElement(`p`));e&&t.appendChild(a.serializeNode(r.text(e,n)))})}}else e.someProp(`transformPastedHTML`,t=>{n=t(n,e)}),o=fo(n),ui&&po(o);let u=o&&o.querySelector(`[data-pm-slice]`),d=u&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(u.getAttribute(`data-pm-slice`)||``);if(d&&d[3])for(let e=+d[3];e>0;e--){let e=o.firstChild;for(;e&&!P(e);)e=e.nextSibling;if(!e)break;o=e}if(s||=(e.someProp(`clipboardParser`)||e.someProp(`domParser`)||Pe.fromSchema(e.state.schema)).parseSlice(o,{preserveWhitespace:!!(l||d),context:i,ruleFromNode(e){return e.nodeName==`BR`&&!e.nextSibling&&e.parentNode&&!eo.test(e.parentNode.nodeName)?{ignore:!0}:null}}),d)s=mo(oo(s,+d[1],+d[2]),d[4]);else if(s=m.maxOpen(to(s.content,i),!0),s.openStart||s.openEnd){let e=0,t=0;for(let t=s.content.firstChild;e{s=t(s,e,l)}),s}var eo=/^(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 to(e,t){if(e.childCount<2)return e;for(let n=t.depth;n>=0;n--){let r=t.node(n).contentMatchAt(t.index(n)),i,a=[];if(e.forEach(e=>{if(!a)return;let t=r.findWrapping(e.type),n;if(!t)return a=null;if(n=a.length&&i.length&&ro(t,i,e,a[a.length-1],0))a[a.length-1]=n;else{a.length&&(a[a.length-1]=io(a[a.length-1],i.length));let n=no(e,t);a.push(n),r=r.matchType(n.type),i=t}}),a)return c.from(a)}return e}function no(e,t,n=0){for(let r=t.length-1;r>=n;r--)e=t[r].create(null,c.from(e));return e}function ro(e,t,n,r,i){if(i1&&(a=0),i=n&&(s=t<0?o.contentMatchAt(0).fillBefore(s,a<=i).append(s):s.append(o.contentMatchAt(o.childCount).fillBefore(c.empty,!0))),e.replaceChild(t<0?0:e.childCount-1,o.copy(s))}function oo(e,t,n){return te})}return lo.createHTML(e)}function fo(e){let t=/^(\s*]*>)*/.exec(e);t&&(e=e.slice(t[0].length));let n=co(),r=n.body,i=/<([a-z][^>\s]+)/i.exec(e),a;if((a=i&&so[i[1].toLowerCase()])&&(e=a.map(e=>`<`+e+`>`).join(``)+e+a.map(e=>``).reverse().join(``)),r.innerHTML=uo(e),a)for(let e=0;e=0;e-=2){let t=n.nodes[r[e]];if(!t||t.hasRequiredAttrs())break;try{i=c.from(t.create(r[e+1],i))}catch{break}a++,o++}return new m(i,a,o)}var ho={},go={},_o={touchstart:!0,touchmove:!0},vo=class{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastKeyDispatched=!1,this.lastClick={time:0,x:0,y:0,type:``,button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}};function yo(e){for(let t in ho){let n=ho[t];e.dom.addEventListener(t,e.input.eventHandlers[t]=t=>{wo(e,t)&&!Co(e,t)&&(e.editable||!(t.type in go))&&n(e,t)},_o[t]?{passive:!0}:void 0)}ai&&e.dom.addEventListener(`input`,()=>null),So(e)}function bo(e,t){e.input.lastSelectionOrigin=t,e.input.lastSelectionTime=Date.now()}function xo(e){e.input.mouseDown&&e.input.mouseDown.done(),e.domObserver.stop();for(let t in e.input.eventHandlers)e.dom.removeEventListener(t,e.input.eventHandlers[t]);clearTimeout(e.input.composingTimeout),clearTimeout(e.input.lastIOSEnterFallbackTimeout)}function So(e){e.someProp(`handleDOMEvents`,t=>{for(let n in t)e.input.eventHandlers[n]||e.dom.addEventListener(n,e.input.eventHandlers[n]=t=>Co(e,t))})}function Co(e,t){return e.someProp(`handleDOMEvents`,n=>{let r=n[t.type];return r?r(e,t)||t.defaultPrevented:!1})}function wo(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let n=t.target;n!=e.dom;n=n.parentNode)if(!n||n.nodeType==11||n.pmViewDesc&&n.pmViewDesc.stopEvent(t))return!1;return!0}function To(e,t){!Co(e,t)&&ho[t.type]&&(e.editable||!(t.type in go))&&ho[t.type](e,t)}function Eo(e,t){let{input:n}=e;return n.lastKeyDispatched||e.composing?!1:(n.lastKeyDispatched=!0,typeof t==`string`&&(t=Wr(t==`Backspace`?8:13,t)),e.someProp(`handleKeyDown`,n=>n(e,t)))}go.keydown=(e,t)=>{let n=t;if(e.input.shiftKey=n.keyCode==16||n.shiftKey,!Uo(e)&&(e.input.lastKeyCode=n.keyCode,e.input.lastKeyCodeTime=Date.now(),e.input.lastKeyDispatched=!1,!(li&&ri&&n.keyCode==13))){if(n.keyCode!=229&&e.domObserver.forceFlush(),oi&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let t=Date.now();e.input.lastIOSEnter=t,e.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{e.input.lastIOSEnter==t&&(Eo(e,`Enter`),e.input.lastIOSEnter=0)},200)}else Eo(e,n)||Za(e,n)?n.preventDefault():bo(e,`key`)}},go.keyup=(e,t)=>{t.keyCode==16&&(e.input.shiftKey=!1)},go.keypress=(e,t)=>{let n=t;if(Uo(e)||!n.charCode||n.ctrlKey&&!n.altKey||si&&n.metaKey)return;if(e.someProp(`handleKeyPress`,t=>t(e,n))){n.preventDefault();return}let r=e.state.selection;if(!(r instanceof A)||!r.$from.sameParent(r.$to)){let t=String.fromCharCode(n.charCode),i=()=>e.state.tr.insertText(t).scrollIntoView();!/[\r\n]/.test(t)&&!e.someProp(`handleTextInput`,n=>n(e,r.$from.pos,r.$to.pos,t,i))&&e.dispatch(i()),n.preventDefault()}};function Do(e){return{left:e.clientX,top:e.clientY}}function Oo(e,t){let n=t.x-e.clientX,r=t.y-e.clientY;return n*n+r*r<100}function ko(e,t,n,r,i){if(r==-1)return!1;let a=e.state.doc.resolve(r);for(let r=a.depth+1;r>0;r--)if(e.someProp(t,t=>r>a.depth?t(e,n,a.nodeAfter,a.before(r),i,!0):t(e,n,a.node(r),a.before(r),i,!1)))return!0;return!1}function Ao(e,t,n){if(e.focused||e.focus(),e.state.selection.eq(t))return;let r=e.state.tr.setSelection(t);r.setMeta(`pointer`,!0),e.dispatch(r)}function jo(e,t){if(t==-1)return!1;let n=e.state.doc.resolve(t),r=n.nodeAfter;return r&&r.isAtom&&j.isSelectable(r)?(Ao(e,new j(n)),!0):!1}function Mo(e,t){if(t==-1)return!1;let n=e.state.selection,r,i;n instanceof j&&(r=n.node);let a=e.state.doc.resolve(t);for(let e=a.depth+1;e>0;e--){let t=e>a.depth?a.nodeAfter:a.node(e);if(j.isSelectable(t)){i=r&&n.$from.depth>0&&e>=n.$from.depth&&a.before(n.$from.depth+1)==n.$from.pos?a.before(n.$from.depth):a.before(e);break}}return i!=null&&(Ao(e,j.create(e.state.doc,i)),!0)}function No(e,t,n,r,i){return ko(e,`handleClickOn`,t,n,r)||e.someProp(`handleClick`,n=>n(e,t,r))||(i?Mo(e,n):jo(e,n))}function Po(e,t,n,r){return ko(e,`handleDoubleClickOn`,t,n,r)||e.someProp(`handleDoubleClick`,n=>n(e,t,r))}function Fo(e,t,n,r){return ko(e,`handleTripleClickOn`,t,n,r)||e.someProp(`handleTripleClick`,n=>n(e,t,r))||Io(e,n,r)}function Io(e,t,n){if(n.button!=0)return!1;let r=Lo(e,t,!0),i=e.state.doc;return r?(Ao(e,r),r instanceof A&&i.eq(e.state.doc)&&(e.input.mouseDown=new Ho(e,r)),!0):!1}function Lo(e,t,n){let r=e.state.doc;if(t==-1)return r.inlineContent?A.create(r,0,r.content.size):null;let i=r.resolve(t);for(let e=i.depth+1;e>0;e--){let t=e>i.depth?i.nodeAfter:i.node(e),a=i.before(e);if(t.inlineContent)return A.create(r,a+1,a+1+t.content.size);if(n&&j.isSelectable(t))return j.create(r,a)}return null}function Ro(e){return Yo(e)}var zo=si?`metaKey`:`ctrlKey`;ho.mousedown=(e,t)=>{let n=t;e.input.shiftKey=n.shiftKey;let r=Ro(e),i=Date.now(),a=`singleClick`;i-e.input.lastClick.time<500&&Oo(n,e.input.lastClick)&&!n[zo]&&e.input.lastClick.button==n.button&&(e.input.lastClick.type==`singleClick`?a=`doubleClick`:e.input.lastClick.type==`doubleClick`&&(a=`tripleClick`)),e.input.lastClick={time:i,x:n.clientX,y:n.clientY,type:a,button:n.button},e.input.mouseDown&&e.input.mouseDown.done();let o=e.posAtCoords(Do(n));o&&(a==`singleClick`?e.input.mouseDown=new Vo(e,o,n,!!r):(a==`doubleClick`?Po:Fo)(e,o.pos,o.inside,n)?n.preventDefault():bo(e,`pointer`))};var Bo=class{constructor(e){this.view=e,this.mightDrag=null,e.root.addEventListener(`mouseup`,this.up=this.up.bind(this)),e.root.addEventListener(`mousemove`,this.move=this.move.bind(this))}up(e){this.done()}move(e){e.buttons==0&&this.done()}done(){this.view.root.removeEventListener(`mouseup`,this.up),this.view.root.removeEventListener(`mousemove`,this.move),this.view.input.mouseDown==this&&(this.view.input.mouseDown=null)}delaySelUpdate(){return!1}},Vo=class extends Bo{constructor(e,t,n,r){super(e),this.pos=t,this.event=n,this.flushed=r,this.delayedSelectionSync=!1,this.startDoc=e.state.doc,this.selectNode=!!n[zo],this.allowDefault=n.shiftKey;let i,a;if(t.inside>-1)i=e.state.doc.nodeAt(t.inside),a=t.inside;else{let n=e.state.doc.resolve(t.pos);i=n.parent,a=n.depth?n.before():0}let o=r?null:n.target,s=o?e.docView.nearestDesc(o,!0):null;this.target=s&&P(s.nodeDOM)?s.nodeDOM:null;let{selection:c}=e.state;n.button==0&&(i.type.spec.draggable&&i.type.spec.selectable!==!1||c instanceof j&&c.from<=a&&c.to>a)&&(this.mightDrag={node:i,pos:a,addAttr:!(!this.target||this.target.draggable),setUneditable:!!(this.target&&ti&&!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()),bo(e,`pointer`)}done(){super.done(),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute(`draggable`),this.mightDrag.setUneditable&&this.target.removeAttribute(`contentEditable`),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>{this.view.isDestroyed||xa(this.view)})}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(Do(e))),this.updateAllowDefault(e),this.allowDefault||!t?bo(this.view,`pointer`):No(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||ai&&this.mightDrag&&!this.mightDrag.node.isAtom||ri&&!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)?(Ao(this.view,k.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):bo(this.view,`pointer`)}move(e){this.updateAllowDefault(e),bo(this.view,`pointer`),super.move(e)}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}delaySelUpdate(){return this.allowDefault?(this.delayedSelectionSync=!0,!0):!1}},Ho=class extends Bo{constructor(e,t){super(e),this.startSelection=t,this.startDoc=e.state.doc}move(e){if(e.buttons==0||this.view.isDestroyed||!this.view.state.doc.eq(this.startDoc)){this.done();return}e.preventDefault(),bo(this.view,`pointer`);let t=this.view.posAtCoords(Do(e)),n=t&&Lo(this.view,t.inside,!1);if(!n)return;let{doc:r}=this.view.state,i=this.startSelection,[a,o]=n.from{e.input.lastTouch=Date.now(),Ro(e),bo(e,`pointer`)},ho.touchmove=e=>{e.input.lastTouch=Date.now(),bo(e,`pointer`)},ho.contextmenu=e=>Ro(e);function Uo(e,t){return e.composing?!0:ai&&Math.abs(Date.now()-e.input.compositionEndedAt)<500?(e.input.compositionEndedAt=-2e8,!0):!1}var Wo=li?5e3:-1;go.compositionstart=go.compositionupdate=e=>{if(!e.composing){e.domObserver.flush();let{state:t}=e,n=t.selection.$to;if(t.selection instanceof A&&t.selection.empty&&(t.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(e=>e.type.spec.inclusive===!1)||ri&&ci&&Go(e)))e.markCursor=e.state.storedMarks||n.marks(),Yo(e,!0),e.markCursor=null;else if(Yo(e,!t.selection.empty),ti&&t.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let t=e.domSelectionRange();for(let n=t.focusNode,r=t.focusOffset;n&&P(n)&&r!=0;){let t=r<0?n.lastChild:n.childNodes[r-1];if(!t)break;if(F(t)){let n=e.domSelection();n&&n.collapse(t,t.nodeValue.length);break}n=t,r=-1}}e.input.composing=!0}Ko(e,Wo)};function Go(e){let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(!t||!P(t)||n>=t.childNodes.length)return!1;let r=t.childNodes[n];return P(r)&&r.contentEditable==`false`}go.compositionend=(e,t)=>{e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=Date.now(),e.input.compositionPendingChanges=e.domObserver.pendingRecords().length?e.input.compositionID:0,e.input.compositionNode=null,e.input.badSafariComposition?e.domObserver.forceFlush():e.input.compositionPendingChanges&&Promise.resolve().then(()=>e.domObserver.flush()),e.input.compositionID++,Ko(e,20))};function Ko(e,t){clearTimeout(e.input.composingTimeout),t>-1&&(e.input.composingTimeout=setTimeout(()=>Yo(e),t))}function qo(e){for(e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=Date.now());e.input.compositionNodes.length>0;)e.input.compositionNodes.pop().markParentsDirty()}function Jo(e){let t=e.domSelectionRange();if(!t.focusNode)return null;let n=zr(t.focusNode,t.focusOffset),r=Br(t.focusNode,t.focusOffset);if(n&&r&&n!=r){let t=r.pmViewDesc,i=e.domObserver.lastChangedTextNode;if(n==i||r==i)return i;if(!t||!t.isText(r.nodeValue))return r;if(e.input.compositionNode==r){let e=n.pmViewDesc;if(e&&e.isText(n.nodeValue))return r}}return n||r}function Yo(e,t=!1){if(!(li&&e.domObserver.flushingSoon>=0)){if(e.domObserver.forceFlush(),qo(e),t||e.docView&&e.docView.dirty){let n=ya(e),r=e.state.selection;return n&&!n.eq(r)?e.dispatch(e.state.tr.setSelection(n)):(e.markCursor||t)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?e.dispatch(e.state.tr.deleteSelection()):e.updateState(e.state),!0}return!1}}function Xo(e,t){if(!e.dom.parentNode)return;let n=e.dom.parentNode.appendChild(document.createElement(`div`));n.appendChild(t),n.style.cssText=`position: fixed; left: -10000px; top: 10px`;let r=getSelection(),i=document.createRange();i.selectNodeContents(t),e.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),e.focus()},50)}var Zo=$r&&ei<15||oi&&di<604;ho.copy=go.cut=(e,t)=>{let n=t,r=e.state.selection,i=n.type==`cut`;if(r.empty)return;let a=Zo?null:n.clipboardData,{dom:o,text:s}=Qa(e,r.content());a?(n.preventDefault(),a.clearData(),a.setData(`text/html`,o.innerHTML),a.setData(`text/plain`,s)):Xo(e,o),i&&e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta(`uiEvent`,`cut`))};function Qo(e){return e.openStart==0&&e.openEnd==0&&e.content.childCount==1?e.content.firstChild:null}function $o(e,t){if(!e.dom.parentNode)return;let n=e.input.shiftKey||e.state.selection.$from.parent.type.spec.code,r=e.dom.parentNode.appendChild(document.createElement(n?`textarea`:`div`));n||(r.contentEditable=`true`),r.style.cssText=`position: fixed; left: -10000px; top: 10px`,r.focus();let i=e.input.shiftKey&&e.input.lastKeyCode!=45;setTimeout(()=>{e.focus(),r.parentNode&&r.parentNode.removeChild(r),n?es(e,r.value,null,i,t):es(e,r.textContent,r.innerHTML,i,t)},50)}function es(e,t,n,r,i){let a=$a(e,t,n,r,e.state.selection.$from);if(e.someProp(`handlePaste`,t=>t(e,i,a||m.empty)))return!0;if(!a)return!1;let o=Qo(a),s=o?e.state.tr.replaceSelectionWith(o,r):e.state.tr.replaceSelection(a);return e.dispatch(s.scrollIntoView().setMeta(`paste`,!0).setMeta(`uiEvent`,`paste`)),!0}function ts(e){let t=e.getData(`text/plain`)||e.getData(`Text`);if(t)return t;let n=e.getData(`text/uri-list`);return n?n.replace(/\r?\n/g,` `):``}go.paste=(e,t)=>{let n=t;if(e.composing&&!li)return;let r=Zo?null:n.clipboardData,i=e.input.shiftKey&&e.input.lastKeyCode!=45;r&&es(e,ts(r),r.getData(`text/html`),i,n)?n.preventDefault():$o(e,n)};var ns=class{constructor(e,t,n){this.slice=e,this.move=t,this.node=n}},rs=si?`altKey`:`ctrlKey`;function is(e,t){let n;return e.someProp(`dragCopies`,e=>{n||=e(t)}),n==null?!t[rs]:!n}ho.dragstart=(e,t)=>{let n=t,r=e.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let i=e.state.selection,a=i.empty?null:e.posAtCoords(Do(n)),o;if(!(a&&a.pos>=i.from&&a.pos<=(i instanceof j?i.to-1:i.to))){if(r&&r.mightDrag)o=j.create(e.state.doc,r.mightDrag.pos);else if(n.target&&P(n.target)){let t=e.docView.nearestDesc(n.target,!0);t&&t.node.type.spec.draggable&&t!=e.docView&&(o=j.create(e.state.doc,t.posBefore))}}let{dom:s,text:c,slice:l}=Qa(e,(o||e.state.selection).content());(!n.dataTransfer.files.length||!ri||ii>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(Zo?`Text`:`text/html`,s.innerHTML),n.dataTransfer.effectAllowed=`copyMove`,Zo||n.dataTransfer.setData(`text/plain`,c),e.dragging=new ns(l,is(e,n),o)},ho.dragend=e=>{let t=e.dragging;window.setTimeout(()=>{e.dragging==t&&(e.dragging=null)},50)},go.dragover=go.dragenter=(e,t)=>t.preventDefault(),go.drop=(e,t)=>{try{as(e,t,e.dragging)}finally{e.dragging=null}};function as(e,t,n){if(!t.dataTransfer)return;let r=e.posAtCoords(Do(t));if(!r)return;let i=e.state.doc.resolve(r.pos),a=n&&n.slice;a?e.someProp(`transformPasted`,t=>{a=t(a,e,!1)}):a=$a(e,ts(t.dataTransfer),Zo?null:t.dataTransfer.getData(`text/html`),!1,i);let o=!!(n&&is(e,t));if(e.someProp(`handleDrop`,n=>n(e,t,a||m.empty,o))){t.preventDefault();return}if(!a)return;t.preventDefault();let s=a?Yt(e.state.doc,i.pos,a):i.pos;s??=i.pos;let c=e.state.tr;if(o){let{node:e}=n;e?e.replace(c):c.deleteSelection()}let l=c.mapping.map(s),u=a.openStart==0&&a.openEnd==0&&a.content.childCount==1,d=c.doc;if(u?c.replaceRangeWith(l,l,a.content.firstChild):c.replaceRange(l,l,a),c.doc.eq(d))return;let f=c.doc.resolve(l);if(u&&j.isSelectable(a.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(a.content.firstChild))c.setSelection(new j(f));else{let t=c.mapping.map(s);c.mapping.maps[c.mapping.maps.length-1].forEach((e,n,r,i)=>t=i),c.setSelection(Aa(e,f,c.doc.resolve(t)))}e.focus(),e.dispatch(c.setMeta(`uiEvent`,`drop`))}ho.focus=e=>{if(e.input.lastFocus=Date.now(),!e.focused){e.domObserver.stop(),e.dom.classList.add(`ProseMirror-focused`),e.domObserver.start(),e.focused=!0;let t=e.domSelectionRange();if(!e.domObserver.currentSelection.eq(t)){let{focusNode:n,focusOffset:r}=t;setTimeout(()=>{let t=e.domSelectionRange();t.focusNode==n&&t.focusOffset==r&&e.docView&&e.hasFocus()&&xa(e)},20)}}},ho.blur=(e,t)=>{let n=t;e.focused&&=(e.domObserver.stop(),e.dom.classList.remove(`ProseMirror-focused`),e.domObserver.start(),n.relatedTarget&&e.dom.contains(n.relatedTarget)&&e.domObserver.currentSelection.clear(),!1)},ho.beforeinput=(e,t)=>{if(li&&t.inputType==`deleteContentBackward`){e.domObserver.flushSoon();let{domChangeCount:t}=e.input;setTimeout(()=>{if(e.input.domChangeCount!=t||e.domObserver.pendingRecords().length||(e.dom.blur(),e.focus(),Eo(e,`Backspace`)))return;let{$cursor:n}=e.state.selection;n&&n.pos>0&&e.dispatch(e.state.tr.delete(n.pos-1,n.pos).scrollIntoView())},50)}};for(let e in go)ho[e]=go[e];function ss(e,t){if(e==t)return!0;for(let n in e)if(e[n]!==t[n])return!1;for(let n in t)if(!(n in e))return!1;return!0}var cs=class{constructor(e){this.frag=e,this.index=0,this.off=0}nodeAt(e){for(;this.off<=e&&this.index=a?null:new fs(i,a,this)}valid(e,t){return t.from=e&&(!i||i(o.spec))&&n.push(o.copy(o.from+r,o.to+r))}for(let a=0;ae){let o=this.children[a]+1;this.children[a+2].findInner(e-o,t-o,n,r+o,i)}}map(e,t,n){return this==hs||e.maps.length==0?this:this.mapInner(e,t,0,0,n||ms)}mapInner(t,n,r,i,a){let o;if(this.local.length){let e=new cs(n.content);for(let s=0;s{let o=t+r,s;if(s=bs(n,e,o)){for(i||=this.children.slice();aa&&n.to=t){this.children[e]==t&&(r=this.children[e+2]);break}let a=t+1,o=a+n.content.size;for(let e=0;ea&&t.type instanceof us){let e=Math.max(a,t.from)-a,n=Math.min(o,t.to)-a;ee.map(t,n,ms));return e.from(r)}forChild(t,n){if(n.isLeaf)return I.empty;let r=[];for(let i=0;ie instanceof I)?t:t.reduce((e,t)=>e.concat(t instanceof I?t:t.members),[]))}}forEachSet(e){for(let t=0;t{let o=a-i-(n-e);for(let i=0;ia+t-r)continue;let c=s[i]+t-r;n>=c?s[i+1]=e<=c?-2:-1:e>=t&&o&&(s[i]+=o,s[i+1]+=o)}r+=o}),t=n.maps[e].map(t,-1)}let c=!1;for(let t=0;t=r.content.size){c=!0;continue}let d=n.map(e[t+1]+a,-1)-i,{index:f,offset:p}=r.content.findIndex(u),m=r.maybeChild(f);if(m&&p==u&&p+m.nodeSize==d){let r=s[t+2].mapInner(n,m,l+1,e[t]+a+1,o);r==hs?(s[t+1]=-2,c=!0):(s[t]=u,s[t+1]=d,s[t+2]=r)}else c=!0}if(c){let c=Ss(ys(s,e,t,n,i,a,o),r,0,o);t=c.local;for(let e=0;en&&a.to{let s=bs(e,t,o+n);if(s){a=!0;let e=Ss(s,t,n+o+1,r);e!=hs&&i.push(o,o+t.nodeSize,e)}});let o=vs(a?xs(e):e,-n).sort(Cs);if(o.length){let e=new cs(t.content);for(let n=0;n0;)t++;e.splice(t,0,n)}function Es(e){let t=[];return e.someProp(`decorations`,n=>{let r=n(e.state);r&&r!=hs&&t.push(r)}),e.cursorWrapper&&t.push(I.create(e.state.doc,[e.cursorWrapper.deco])),gs.from(t)}var Ds={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},Os=$r&&ei<=11,ks=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}},As=class{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new ks,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(t=>{for(let e=0;ee.type==`childList`&&e.removedNodes.length||e.type==`characterData`&&e.oldValue.length>e.target.nodeValue.length)?this.flushSoon():ai&&e.composing&&t.some(e=>e.type==`childList`&&e.target.nodeName==`TR`)?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),Os&&(this.onCharData=e=>{this.queue.push({target:e.target,type:`characterData`,oldValue:e.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,Ds)),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(ja(this.view)){if(this.suppressingSelectionUpdates)return xa(this.view);if($r&&ei<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Pr(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t=new Set,n;for(let n=e.focusNode;n;n=Ar(n))t.add(n);for(let r=e.anchorNode;r;r=Ar(r))if(t.has(r)){n=r;break}let r=n&&this.view.docView.nearestDesc(n);if(r&&r.ignoreMutation({type:`selection`,target:F(n)?n.parentNode:n}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let n,r=!1;!this.suppressingSelectionUpdates&&ja(e)&&(n=e.domSelectionRange(),r=!this.currentSelection.eq(n)&&!this.ignoreSelectionChange(n));let i=-1,a=-1,o=!1,s=[];if(e.editable)for(let e=0;ee.nodeName==`BR`)&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46||ri&&(e.composing||e.input.compositionEndedAt>Date.now()-50)&&t.some(e=>e.type==`childList`&&e.removedNodes.length))){for(let e of s)if(e.nodeName==`BR`&&e.parentNode){let t=e.nextSibling;for(;t&&P(t);){if(t.contentEditable==`false`){e.parentNode.removeChild(e);break}t=t.firstChild}}}else if(ti&&s.length){let t=s.filter(e=>e.nodeName==`BR`);if(t.length==2){let[e,n]=t;e.parentNode&&e.parentNode.parentNode==n.parentNode?n.remove():e.remove()}else{let{focusNode:n}=this.currentSelection;for(let r of t){let t=r.parentNode;t&&t.nodeName==`LI`&&(!n||Is(e,n)!=t)&&r.remove()}}}let c=null;i<0&&r&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)-1||r)&&(i>-1&&(e.docView.markDirty(i,a),Ns(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,Ls(e,s)),this.handleDOMChange(i,a,o,s),e.docView&&e.docView.dirty?e.updateState(e.state):n&&!this.currentSelection.eq(n)&&xa(e),n&&this.currentSelection.set(n))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let n=this.view.docView.nearestDesc(e.target);if(e.type==`attributes`&&(n==this.view.docView||e.attributeName==`contenteditable`||e.attributeName==`style`&&!e.oldValue&&!e.target.getAttribute(`style`))||!n||n.ignoreMutation(e))return null;if(e.type==`childList`){for(let n=0;na;e--){let t=i.childNodes[e-1],n=t.pmViewDesc;if(t.nodeName==`BR`&&!n){o=e;break}if(!n||n.size)break}let f=e.state.doc,p=e.someProp(`domParser`)||Pe.fromSchema(e.state.schema),m=f.resolve(s),h=null,g=p.parse(i,{topNode:m.parent,topMatch:m.parent.contentMatchAt(m.index()),topOpen:!0,from:a,to:o,preserveWhitespace:m.parent.type.whitespace!=`pre`||`full`,findPositions:u,ruleFromNode:zs(r),context:m});if(u&&u[0].pos!=null){let e=u[0].pos,t=u[1]&&u[1].pos;t??=e,h={anchor:e+s,head:t+s}}return{doc:g,sel:h,from:s,to:c}}var zs=e=>t=>{let n=t.pmViewDesc;if(n)return n.parseRule(e);if(t.nodeName==`BR`&&t.parentNode){if(ai&&/^(ul|ol)$/i.test(t.parentNode.nodeName)){let e=document.createElement(`div`);return e.appendChild(document.createElement(`li`)),{skip:e}}if(t.parentNode.lastChild==t||ai&&/^(tr|table)$/i.test(t.parentNode.nodeName))return{ignore:!0}}else if(t.nodeName==`IMG`&&t.getAttribute(`mark-placeholder`))return{ignore:!0};return null},Bs=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function Vs(e,t,n,r,i){let a=e.input.compositionPendingChanges||(e.composing?e.input.compositionID:0);if(e.input.compositionPendingChanges=0,t<0){let t=e.input.lastSelectionTime>Date.now()-50?e.input.lastSelectionOrigin:null,n=ya(e,t);if(n&&!e.state.selection.eq(n)){if(ri&&li&&e.input.lastKeyCode===13&&Date.now()-100Date.now()-225||li)&&i.some(e=>P(e)&&!Bs.test(e.nodeName))&&(!m||m.endA>=m.endB)&&Eo(e,`Enter`)){e.input.lastIOSEnter=0;return}if(!m){if(r&&c instanceof A&&!c.empty&&c.$head.sameParent(c.$anchor)&&!e.composing&&!(l.sel&&l.sel.anchor!=l.sel.head))m={start:c.from,endA:c.to,endB:c.to};else{if(l.sel){let t=Hs(e,e.state.doc,l.sel);if(t&&!t.eq(e.state.selection)){let n=e.state.tr.setSelection(t);a&&n.setMeta(`composition`,a),e.dispatch(n)}}return}}e.state.selection.frome.state.selection.from&&m.start<=e.state.selection.from+2&&e.state.selection.from>=l.from?m.start=e.state.selection.from:m.endA=e.state.selection.to-2&&e.state.selection.to<=l.to&&(m.endB+=e.state.selection.to-m.endA,m.endA=e.state.selection.to)),$r&&ei<=11&&m.endB==m.start+1&&m.endA==m.start&&m.start>l.from&&l.doc.textBetween(m.start-l.from-1,m.start-l.from+1)==` \xA0`&&(m.start--,m.endA--,m.endB--);let h=l.doc.resolveNoCache(m.start-l.from),g=l.doc.resolveNoCache(m.endB-l.from),_=u.resolve(m.start),v=h.sameParent(g)&&h.parent.inlineContent&&_.end()>=m.endA;if((oi&&e.input.lastIOSEnter>Date.now()-225&&(!v||i.some(e=>e.nodeName==`DIV`||e.nodeName==`P`))||!v&&Gs(l.doc,h.pos,g.pos))&&Eo(e,`Enter`)){e.input.lastIOSEnter=0;return}if(e.state.selection.anchor>m.start&&(v?m.endA>m.start&&m.endB==m.start:Ws(u,m.start,m.endA,h,g))&&Eo(e,`Backspace`)){li&&ri&&e.domObserver.suppressSelectionUpdates();return}ri&&m.endB==m.start&&(e.input.lastChromeDelete=Date.now()),li&&!v&&h.start()!=g.start()&&g.parentOffset==0&&h.depth==g.depth&&l.sel&&l.sel.anchor==l.sel.head&&l.sel.head==m.endA&&(m.endB-=2,g=l.doc.resolveNoCache(m.endB-l.from),setTimeout(()=>Eo(e,`Enter`),20));let y=m.start,b=m.endA,x=t=>{let n=t||e.state.tr.replace(y,b,l.doc.slice(m.start-l.from,m.endB-l.from));if(l.sel){let t=Hs(e,n.doc,l.sel);t&&!(ri&&e.composing&&t.empty&&(m.start!=m.endB||e.input.lastChromeDeletexa(e),20));let t=x(e.state.tr.delete(y,b)),n=u.resolve(m.start).marksAcross(u.resolve(m.endA));n&&t.ensureMarks(n),e.dispatch(t)}else if(m.endA==m.endB&&(S=Us(h.parent.content.cut(h.parentOffset,g.parentOffset),_.parent.content.cut(_.parentOffset,m.endA-_.start())))){let t=x(e.state.tr);S.type==`add`?t.addMark(y,b,S.mark):t.removeMark(y,b,S.mark),e.dispatch(t)}else if(h.parent.child(h.index()).isText&&h.index()==g.index()-+!g.textOffset){let t=h.parent.textBetween(h.parentOffset,g.parentOffset),n=()=>x(e.state.tr.insertText(t,y,b));e.someProp(`handleTextInput`,r=>r(e,y,b,t,n))||e.dispatch(n())}else e.dispatch(x())}else e.dispatch(x())}function Hs(e,t,n){return Math.max(n.anchor,n.head)>t.content.size?null:Aa(e,t.resolve(n.anchor),t.resolve(n.head))}function Us(e,t){let n=e.firstChild.marks,r=t.firstChild.marks,i=n,a=r,o,s,l;for(let e=0;ee.mark(s.addToSet(e.marks));else if(i.length==0&&a.length==1)s=a[0],o=`remove`,l=e=>e.mark(s.removeFromSet(e.marks));else return null;let u=[];for(let e=0;en||Ks(o,!0,!1){e.isTextblock&&a>=t&&a0&&(t||e.indexAfter(r)==e.node(r).childCount);)r--,i++,t=!1;if(n){let t=e.node(r).maybeChild(e.indexAfter(r));for(;t&&!t.isLeaf;)t=t.firstChild,i++}return i}function qs(e,t,n,r,i){let a=e.findDiffStart(t,n),o=n+e.size,s=n+t.size;if(a==null)return null;let{a:c,b:l}=e.findDiffEnd(t,o,s);if(i==`end`){let e=Math.max(0,a-Math.min(c,l));r-=c+e-a}if(c=c?a-r:0;a-=e,l=a+(l-c),c=a}else if(l=l?a-r:0;a-=e,c=a+(c-l),l=a}return{start:a,endA:c,endB:l}}var Js=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 vo,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(tc),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=Zs(this),Xs(this),this.nodeViews=$s(this),this.docView=$i(this.state.doc,Ys(this),Es(this),this.dom,this),this.domObserver=new As(this,(e,t,n,r)=>Vs(this,e,t,n,r)),this.domObserver.start(),yo(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&&So(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(tc),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let e in this._props)t[e]=this._props[e];t.state=this.state;for(let n in e)t[n]=e[n];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){let n=this.state,r=!1,i=!1;e.storedMarks&&this.composing&&(qo(this),i=!0),this.state=e;let a=n.plugins!=e.plugins||this._props.plugins!=t.plugins;if(a||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let e=$s(this);ec(e,this.nodeViews)&&(this.nodeViews=e,r=!0)}(a||t.handleDOMEvents!=this._props.handleDOMEvents)&&So(this),this.editable=Zs(this),Xs(this);let o=Es(this),s=Ys(this),c=n.plugins!=e.plugins&&!n.doc.eq(e.doc)?`reset`:e.scrollToSelection>n.scrollToSelection?`to selection`:`preserve`,l=r||!this.docView.matchesNode(e.doc,s,o);(l||!e.selection.eq(n.selection))&&(i=!0);let u=c==`preserve`&&i&&this.dom.style.overflowAnchor==null&&gi(this);if(i){this.domObserver.stop();let t=l&&($r||ri)&&!this.composing&&!n.selection.empty&&!e.selection.empty&&Qs(n.selection,e.selection);if(l){let n=ri?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=Jo(this)),(r||!this.docView.update(e.doc,s,o,this))&&(this.docView.updateOuterDeco(s),this.docView.destroy(),this.docView=$i(e.doc,s,o,this.dom,this)),!n||this.trackWrites&&this.dom.contains(this.trackWrites)||(t=!0)}let i=this.input.mouseDown;t||!(i&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&Na(this)&&i.delaySelUpdate())?xa(this,t):(Oa(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(n),this.dragging?.node&&!n.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,n),c==`reset`?this.dom.scrollTop=0:c==`to selection`?this.scrollToSelection():u&&vi(u)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(e&&Rr(this.dom,e)&&!this.someProp(`handleScrollToSelection`,e=>e(this))){if(this.state.selection instanceof j){let t=this.docView.domAfterPos(this.state.selection.from);P(t)&&hi(this,t.getBoundingClientRect(),e)}else hi(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let e=0;e0&&ee.ownerDocument.getSelection()),this._root=e}return e||document}updateRoot(){this._root=null}posAtCoords(e){return ki(this,e)}coordsAtPos(e,t=1){return Ni(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,n=-1){let r=this.docView.posFromDOM(e,t,n);if(r==null)throw RangeError(`DOM position not inside the editor`);return r}endOfTextblock(e,t){return Ui(this,t||this.state,e)}pasteHTML(e,t){return es(this,``,e,!1,t||new ClipboardEvent(`paste`))}pasteText(e,t){return es(this,e,null,!0,t||new ClipboardEvent(`paste`))}serializeForClipboard(e){return Qa(this,e)}destroy(){this.docView&&(xo(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Es(this),this),this.dom.textContent=``):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Nr())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return To(this,e)}domSelectionRange(){let e=this.dom.isConnected!==!1&&this.domSelection();return e?ai&&this.root.nodeType===11&&Gr(this.dom.ownerDocument)==this.dom&&Fs(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}};Js.prototype.dispatch=function(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))};function Ys(e){let t=Object.create(null);return t.class=`ProseMirror`,t.contenteditable=String(e.editable),e.someProp(`attributes`,n=>{if(typeof n==`function`&&(n=n(e.state)),n)for(let e in n)e==`class`?t.class+=` `+n[e]:e==`style`?t.style=(t.style?t.style+`;`:``)+n[e]:!t[e]&&e!=`contenteditable`&&e!=`nodeName`&&(t[e]=String(n[e]))}),t.translate||=`no`,[fs.node(0,e.state.doc.content.size,t)]}function Xs(e){if(e.markCursor){let t=document.createElement(`img`);t.className=`ProseMirror-separator`,t.setAttribute(`mark-placeholder`,`true`),t.setAttribute(`alt`,``),e.cursorWrapper={dom:t,deco:fs.widget(e.state.selection.from,t,{raw:!0,marks:e.markCursor})}}else e.cursorWrapper=null}function Zs(e){return!e.someProp(`editable`,t=>t(e.state)===!1)}function Qs(e,t){let n=Math.min(e.$anchor.sharedDepth(e.head),t.$anchor.sharedDepth(t.head));return e.$anchor.start(n)!=t.$anchor.start(n)}function $s(e){let t=Object.create(null);function n(e){for(let n in e)Object.prototype.hasOwnProperty.call(t,n)||(t[n]=e[n])}return e.someProp(`nodeViews`,n),e.someProp(`markViews`,n),t}function ec(e,t){let n=0,r=0;for(let r in e){if(e[r]!=t[r])return!0;n++}for(let e in t)r++;return n!=r}function tc(e){if(e.spec.state||e.spec.filterTransaction||e.spec.appendTransaction)throw RangeError(`Plugins passed directly to the view must not have a state component`)}for(var nc={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:`'`},rc={48:`)`,49:`!`,50:`@`,51:`#`,52:`$`,53:`%`,54:`^`,55:`&`,56:`*`,57:`(`,59:`:`,61:`+`,173:`_`,186:`:`,187:`+`,188:`<`,189:`_`,190:`>`,191:`?`,192:`~`,219:`{`,220:`|`,221:`}`,222:`"`},ic=typeof navigator<`u`&&/Mac/.test(navigator.platform),ac=typeof navigator<`u`&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),oc=0;oc<10;oc++)nc[48+oc]=nc[96+oc]=String(oc);for(var oc=1;oc<=24;oc++)nc[oc+111]=`F`+oc;for(var oc=65;oc<=90;oc++)nc[oc]=String.fromCharCode(oc+32),rc[oc]=String.fromCharCode(oc);for(var sc in nc)rc.hasOwnProperty(sc)||(rc[sc]=nc[sc]);function cc(e){var t=!(ic&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||ac&&e.shiftKey&&e.key&&e.key.length==1||e.key==`Unidentified`)&&e.key||(e.shiftKey?rc:nc)[e.keyCode]||e.key||`Unidentified`;return t==`Esc`&&(t=`Escape`),t==`Del`&&(t=`Delete`),t==`Left`&&(t=`ArrowLeft`),t==`Up`&&(t=`ArrowUp`),t==`Right`&&(t=`ArrowRight`),t==`Down`&&(t=`ArrowDown`),t}var lc=typeof navigator<`u`&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),uc=typeof navigator<`u`&&/Win/.test(navigator.platform);function dc(e){let t=e.split(/-(?!$)/),n=t[t.length-1];n==`Space`&&(n=` `);let r,i,a,o;for(let e=0;e=t?_c.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},_c.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},_c.prototype.forEach=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length),t<=n?this.forEachInner(e,t,n,0):this.forEachInvertedInner(e,t,n,0)},_c.prototype.map=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length);var r=[];return this.forEach(function(t,n){return r.push(e(t,n))},t,n),r},_c.from=function(e){return e instanceof _c?e:e&&e.length?new vc(e):_c.empty};var vc=function(e){function t(t){e.call(this),this.values=t}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var n={length:{configurable:!0},depth:{configurable:!0}};return t.prototype.flatten=function(){return this.values},t.prototype.sliceInner=function(e,n){return e==0&&n==this.length?this:new t(this.values.slice(e,n))},t.prototype.getInner=function(e){return this.values[e]},t.prototype.forEachInner=function(e,t,n,r){for(var i=t;i=n;i--)if(e(this.values[i],r+i)===!1)return!1},t.prototype.leafAppend=function(e){if(this.length+e.length<=gc)return new t(this.values.concat(e.flatten()))},t.prototype.leafPrepend=function(e){if(this.length+e.length<=gc)return new t(e.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(t.prototype,n),t}(_c);_c.empty=new vc([]);var yc=function(e){function t(t,n){e.call(this),this.left=t,this.right=n,this.length=t.length+n.length,this.depth=Math.max(t.depth,n.depth)+1}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},t.prototype.getInner=function(e){return ei&&this.right.forEachInner(e,Math.max(t-i,0),Math.min(this.length,n)-i,r+i)===!1)return!1},t.prototype.forEachInvertedInner=function(e,t,n,r){var i=this.left.length;if(t>i&&this.right.forEachInvertedInner(e,t-i,Math.max(n,i)-i,r+i)===!1||n=n?this.right.slice(e-n,t-n):this.left.slice(e,n).append(this.right.slice(0,t-n))},t.prototype.leafAppend=function(e){var n=this.right.leafAppend(e);if(n)return new t(this.left,n)},t.prototype.leafPrepend=function(e){var n=this.left.leafPrepend(e);if(n)return new t(n,this.right)},t.prototype.appendInner=function(e){return this.left.depth>=Math.max(this.right.depth,e.depth)+1?new t(this.left,new t(this.right,e)):new t(this,e)},t}(_c),bc=500,xc=class e{constructor(e,t){this.items=e,this.eventCount=t}popEvent(t,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let i,a;n&&(i=this.remapping(r,this.items.length),a=i.maps.length);let o=t.tr,s,c,l=[],u=[];return this.items.forEach((t,n)=>{if(!t.step)i||(i=this.remapping(r,n+1),a=i.maps.length),a--,u.push(t);else{if(i){u.push(new Cc(t.map));let e=t.step.map(i.slice(a)),n;e&&o.maybeStep(e).doc&&(n=o.mapping.maps[o.mapping.maps.length-1],l.push(new Cc(n,void 0,void 0,l.length+u.length))),a--,n&&i.appendMap(n,a)}else o.maybeStep(t.step);if(t.selection)return s=i?t.selection.map(i.slice(a)):t.selection,c=new e(this.items.slice(0,r).append(u.reverse().concat(l)),this.eventCount-1),!1}},this.items.length,0),{remaining:c,transform:o,selection:s}}addTransform(t,n,r,i){let a=[],o=this.eventCount,s=this.items,c=!i&&s.length?s.get(s.length-1):null;for(let e=0;eTc&&(s=Sc(s,l),o-=l),new e(s.append(a),o)}remapping(e,t){let n=new ft;return this.items.forEach((t,r)=>{let i=t.mirrorOffset!=null&&r-t.mirrorOffset>=e?n.maps.length-t.mirrorOffset:void 0;n.appendMap(t.map,i)},e,t),n}addMaps(t){return this.eventCount==0?this:new e(this.items.append(t.map(e=>new Cc(e))),this.eventCount)}rebased(t,n){if(!this.eventCount)return this;n=Math.min(this.items.length,n);let r=[],i=this.items.length-n,a=t.mapping,o=t.steps.length,s=this.eventCount;this.items.forEach(e=>{e.selection&&s--},i);let c=n;this.items.forEach(e=>{let n=a.getMirror(--c);if(n==null)return;o=Math.min(o,n);let i=a.maps[n];if(e.step){let o=t.steps[n].invert(t.docs[n]),l=e.selection&&e.selection.map(a.slice(c+1,n));l&&s++,r.push(new Cc(i,o,l))}else r.push(new Cc(i))},i);let l=[];for(let e=n;ebc&&(d=d.compress(this.items.length-r.length)),d}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(t=this.items.length){let n=this.remapping(0,t),r=n.maps.length,i=[],a=0;return this.items.forEach((e,o)=>{if(o>=t)i.push(e),e.selection&&a++;else if(e.step){let t=e.step.map(n.slice(r)),o=t&&t.getMap();if(r--,o&&n.appendMap(o,r),t){let s=e.selection&&e.selection.map(n.slice(r));s&&a++;let c=new Cc(o.invert(),t,s),l,u=i.length-1;(l=i.length&&i[u].merge(c))?i[u]=l:i.push(c)}}else e.map&&r--},this.items.length,0),new e(_c.from(i.reverse()),a)}};xc.empty=new xc(_c.empty,0);function Sc(e,t){let n;return e.forEach((e,r)=>{if(e.selection&&t--==0)return n=r,!1}),e.slice(n)}var Cc=class e{constructor(e,t,n,r){this.map=e,this.step=t,this.selection=n,this.mirrorOffset=r}merge(t){if(this.step&&t.step&&!t.selection){let n=t.step.merge(this.step);if(n)return new e(n.getMap().invert(),n,this.selection)}}},wc=class{constructor(e,t,n,r,i){this.done=e,this.undone=t,this.prevRanges=n,this.prevTime=r,this.prevComposition=i}},Tc=20;function Ec(e,t,n,r){let i=n.getMeta(Fc),a;if(i)return i.historyState;n.getMeta(Ic)&&(e=new wc(e.done,e.undone,null,0,-1));let o=n.getMeta(`appendedTransaction`);if(n.steps.length==0)return e;if(o&&o.getMeta(Fc))return o.getMeta(Fc).redo?new wc(e.done.addTransform(n,void 0,r,Nc(t)),e.undone,Oc(n.mapping.maps),e.prevTime,e.prevComposition):new wc(e.done,e.undone.addTransform(n,void 0,r,Nc(t)),null,e.prevTime,e.prevComposition);if(n.getMeta(`addToHistory`)!==!1&&!(o&&o.getMeta(`addToHistory`)===!1)){let i=n.getMeta(`composition`),a=e.prevTime==0||!o&&e.prevComposition!=i&&(e.prevTime<(n.time||0)-r.newGroupDelay||!Dc(n,e.prevRanges)),s=o?kc(e.prevRanges,n.mapping):Oc(n.mapping.maps);return new wc(e.done.addTransform(n,a?t.selection.getBookmark():void 0,r,Nc(t)),xc.empty,s,n.time,i??e.prevComposition)}return(a=n.getMeta(`rebased`))?new wc(e.done.rebased(n,a),e.undone.rebased(n,a),kc(e.prevRanges,n.mapping),e.prevTime,e.prevComposition):new wc(e.done.addMaps(n.mapping.maps),e.undone.addMaps(n.mapping.maps),kc(e.prevRanges,n.mapping),e.prevTime,e.prevComposition)}function Dc(e,t){if(!t)return!1;if(!e.docChanged)return!0;let n=!1;return e.mapping.maps[0].forEach((e,r)=>{for(let i=0;i=t[i]&&(n=!0)}),n}function Oc(e){let t=[];for(let n=e.length-1;n>=0&&t.length==0;n--)e[n].forEach((e,n,r,i)=>t.push(r,i));return t}function kc(e,t){if(!e)return null;let n=[];for(let r=0;r{let i=Fc.getState(n);if(!i||(e?i.undone:i.done).eventCount==0)return!1;if(r){let a=Ac(i,n,e);a&&r(t?a.scrollIntoView():a)}return!0}}var zc=Rc(!1,!0),Bc=Rc(!0,!0);function Vc(e){return e.getMeta(Fc)!=null}function Hc(e){let{state:t,transaction:n}=e,{selection:r}=n,{doc:i}=n,{storedMarks:a}=n;return{...t,apply:t.apply.bind(t),applyTransaction:t.applyTransaction.bind(t),plugins:t.plugins,schema:t.schema,reconfigure:t.reconfigure.bind(t),toJSON:t.toJSON.bind(t),get storedMarks(){return a},get selection(){return r},get doc(){return i},get tr(){return r=n.selection,i=n.doc,a=n.storedMarks,n}}}var Uc=class e{constructor(e){this.editor=e.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=e.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){let{rawCommands:e,editor:t,state:n}=this,{view:r}=t,{tr:i}=n,a=this.buildProps(i);return Object.fromEntries(Object.entries(e).map(([e,t])=>[e,(...e)=>{let n=t(...e)(a);return!i.getMeta(`preventDispatch`)&&!this.hasCustomState&&r.dispatch(i),n}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(e,t=!0){let{rawCommands:n,editor:r,state:i}=this,{view:a}=r,o=[],s=!!e,c=e||i.tr,l=()=>(!s&&t&&!c.getMeta(`preventDispatch`)&&!this.hasCustomState&&a.dispatch(c),o.every(e=>e===!0)),u={...Object.fromEntries(Object.entries(n).map(([e,n])=>[e,(...e)=>{let r=this.buildProps(c,t),i=n(...e)(r);return o.push(i),u}])),run:l};return u}static createFakeChain(){let e=new Proxy({},{get:(t,n)=>{if(n!==`then`)return n===`run`?()=>!1:()=>e}});return e}createCan(e){let{rawCommands:t,state:n}=this,r=e||n.tr,i=this.buildProps(r,!1);return{...Object.fromEntries(Object.entries(t).map(([e,t])=>[e,(...e)=>t(...e)({...i,dispatch:void 0})])),chain:()=>this.createChain(r,!1)}}static createFallbackCan(){let t=e.createFakeChain();return new Proxy({chain:()=>t},{get:(e,t)=>{if(t!==`then`)return t===`chain`?e.chain:()=>!1}})}buildProps(e,t=!0){let{rawCommands:n,editor:r,state:i}=this,{view:a}=r,o={tr:e,editor:r,view:a,state:Hc({state:i,transaction:e}),dispatch:t?()=>void 0:void 0,chain:()=>this.createChain(e,t),can:()=>this.createCan(e),get commands(){return Object.fromEntries(Object.entries(n).map(([e,t])=>[e,(...e)=>t(...e)(o)]))}};return o}},Wc=()=>({editor:e,view:t})=>(requestAnimationFrame(()=>{if(!e.isDestroyed){var n;t.dom.blur(),(n=window)==null||(n=n.getSelection())==null||n.removeAllRanges()}}),!0),Gc=(e=!0)=>({commands:t})=>t.setContent(``,{emitUpdate:e}),Kc=()=>({tr:e,dispatch:t})=>{let{selection:n}=e,{ranges:r}=n;if(!t)return!0;let i=e.mapping.maps.length;return r.forEach(({$from:t,$to:n})=>{let r=t.pos,a=n.pos,o=e.mapping.slice(i),s=1;e.doc.nodesBetween(o.map(r),o.map(a),(t,n)=>{s=Math.max(s,e.doc.resolve(n).depth+1)});for(let t=0;t{if(t.type.isText)return;e.mapping.maps.length!==s&&(s=e.mapping.maps.length,c=e.mapping.slice(n));let i=e.doc.resolve(c.map(r)),a=e.doc.resolve(c.map(r+t.nodeSize)),o=i.blockRange(a);if(!o)return;let l=kt(o);if(t.type.isTextblock){let{defaultType:t}=i.parent.contentMatchAt(i.index()),n=e.doc.nodeAt(o.start);t&&n&&!n.hasMarkup(t)&&t.validContent(n.content)&&e.setNodeMarkup(o.start,t)}(l||l===0)&&e.lift(o,l)}),e.doc.eq(t))break}}),!0},qc=e=>t=>e(t),Jc=()=>({state:e,dispatch:t})=>ir(e,t),Yc=(e,t)=>({editor:n,tr:r})=>{let{state:i}=n,a=i.doc.slice(e.from,e.to);r.deleteRange(e.from,e.to);let o=r.mapping.map(t);return r.insert(o,a.content),r.setSelection(new A(r.doc.resolve(Math.max(o-1,0)))),!0},Xc=()=>({tr:e,dispatch:t})=>{let{selection:n}=e,r=n.$anchor.node();if(r.content.size>0)return!1;let i=e.selection.$anchor;for(let n=i.depth;n>0;--n)if(i.node(n).type===r.type){if(t){let t=i.before(n),r=i.after(n);e.delete(t,r).scrollIntoView()}return!0}return!1};function L(e,t){if(typeof e==`string`){if(!t.nodes[e])throw Error(`There is no node type named '${e}'. Maybe you forgot to add the extension?`);return t.nodes[e]}return e}var Zc=e=>({tr:t,state:n,dispatch:r})=>{let i=L(e,n.schema),a=t.selection.$anchor;for(let e=a.depth;e>0;--e)if(a.node(e).type===i){if(r){let n=a.before(e),r=a.after(e);t.delete(n,r).scrollIntoView()}return!0}return!1},Qc=e=>({tr:t,dispatch:n})=>{let{from:r,to:i}=e;return n&&t.delete(r,i),!0},$c=e=>e.content?/^text(\*|\+)/.test(e.content):!1,el=(e,t,n)=>{if(!e.parent.isInline||n===`left`&&e.pos>e.start()||n===`right`&&e.pos({from:el(e,n,`left`),to:el(t,n,`right`)}),nl=()=>({state:e,dispatch:t})=>{if(e.selection.empty)return!1;if(t){let n=e.tr,{ranges:r}=e.selection,i=e.selection instanceof A?e.selection.$from.marksAcross(e.selection.$to):null,a=n.steps.length;r.forEach(t=>{let r=n.mapping.slice(a),{from:i,to:o}=tl(n.doc.resolve(r.map(t.$from.pos)),n.doc.resolve(r.map(t.$to.pos)),e.schema);n.deleteRange(i,o)}),n.selection.empty||n.setSelection(A.near(n.doc.resolve(n.selection.from))),i&&n.ensureMarks(i),n.scrollIntoView(),t(n)}return!0},rl=()=>({commands:e})=>e.keyboardShortcut(`Enter`),il=()=>({state:e,dispatch:t})=>rr(e,t);function al(e){return Object.prototype.toString.call(e)===`[object RegExp]`}function ol(e,t,n={strict:!0}){let r=Object.keys(t);return!r.length||r.every(r=>n.strict?t[r]===e[r]:al(t[r])?t[r].test(e[r]):t[r]===e[r])}function sl(e,t,n={}){return e.find(e=>e.type===t&&ol(Object.fromEntries(Object.keys(n).map(t=>[t,e.attrs[t]])),n))}function cl(e,t,n={}){return!!sl(e,t,n)}function ll(e,t,n){if(!e||!t)return;let r=e.parent.childAfter(e.parentOffset);if(r.node&&r.node.marks.some(e=>e.type===t)||(r=e.parent.childBefore(e.parentOffset)),!r.node||!r.node.marks.some(e=>e.type===t))return;if(!n){let e=r.node.marks.find(e=>e.type===t);e&&(n=e.attrs)}if(!sl([...r.node.marks],t,n))return;let i=r.index,a=e.start()+r.offset,o=i+1,s=a+r.node.nodeSize;for(;i>0&&cl([...e.parent.child(i-1).marks],t,n);)--i,a-=e.parent.child(i).nodeSize;for(;o({tr:n,state:r,dispatch:i})=>{let a=ul(e,r.schema),{doc:o,selection:s}=n,{$from:c,from:l,to:u}=s;if(i){let e=ll(c,a,t);if(e&&e.from<=l&&e.to>=u){let t=A.create(o,e.from,e.to);n.setSelection(t)}}return!0},fl=e=>t=>{let n=typeof e==`function`?e(t):e;for(let e=0;e({editor:n,view:r,tr:i,dispatch:a})=>{t={scrollIntoView:!0,...t};let o=()=>{(_l()||gl())&&r.dom.focus(),vl()&&!_l()&&!gl()&&r.dom.focus({preventScroll:!0}),requestAnimationFrame(()=>{n.isDestroyed||(r.focus(),t?.scrollIntoView&&n.commands.scrollIntoView())})};try{if(r.hasFocus()&&e===null||e===!1)return!0}catch{return!1}if(a&&e===null&&!pl(n.state.selection))return o(),!0;let s=hl(i.doc,e)||n.state.selection,c=n.state.selection.eq(s);return a&&(c||i.setSelection(s),c&&i.storedMarks&&i.setStoredMarks(i.storedMarks),o()),!0},bl=(e,t)=>n=>e.every((e,r)=>t(e,{...n,index:r})),xl=(e,t)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},e,t),Sl=e=>{let t=e.childNodes;for(let n=t.length-1;n>=0;--n){let r=t[n];r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?e.removeChild(r):r.nodeType===1&&Sl(r)}return e};function Cl(e){if(typeof window>`u`)throw Error(`[tiptap error]: there is no window object available, so this function cannot be used`);let t=`${e}`,n=new window.DOMParser().parseFromString(t,`text/html`).body;return Sl(n)}function wl(e){return typeof e?.nodesBetween==`function`}function Tl(e,t,n){if(wl(e))return e;let r=typeof e==`object`&&!!e;n={slice:!0,parseOptions:{},...n};let i=typeof e==`string`;if(r)try{if(Array.isArray(e)&&e.length>0)return c.fromArray(e.map(e=>t.nodeFromJSON(e)));let r=t.nodeFromJSON(e);return n.errorOnInvalidContent&&r.check(),r}catch(r){if(n.errorOnInvalidContent)throw Error(`[tiptap error]: Invalid JSON content`,{cause:r});return console.warn(`[tiptap warn]: Invalid content.`,`Passed value:`,e,`Error:`,r),Tl(``,t,n)}if(i){if(n.errorOnInvalidContent){let r=!1,i=``,a=new Ae({topNode:t.spec.topNode,marks:t.spec.marks,nodes:t.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:`inline*`,group:`block`,parseDOM:[{tag:`*`,getAttrs:e=>(r=!0,i=typeof e==`string`?e:e.outerHTML,null)}]}})});if(n.slice?Pe.fromSchema(a).parseSlice(Cl(e),n.parseOptions):Pe.fromSchema(a).parse(Cl(e),n.parseOptions),n.errorOnInvalidContent&&r)throw Error(`[tiptap error]: Invalid HTML content`,{cause:Error(`Invalid element found: ${i}`)})}let r=Pe.fromSchema(t);return n.slice?r.parseSlice(Cl(e),n.parseOptions).content:r.parse(Cl(e),n.parseOptions)}return Tl(``,t,n)}function El(e){return!(`type`in e)}function Dl(e,t,n){let r=e.steps.length-1;if(r{o===0&&(o=r)}),e.setSelection(k.near(e.doc.resolve(o),n))}var Ol=(e,t,n)=>({tr:r,dispatch:i,editor:a})=>{if(i){n={parseOptions:a.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};let i,o=e=>{a.emit(`contentError`,{editor:a,error:e,disableCollaboration:()=>{`collaboration`in a.storage&&typeof a.storage.collaboration==`object`&&a.storage.collaboration&&(a.storage.collaboration.isDisabled=!0)}})},s={preserveWhitespace:`full`,...n.parseOptions};if(!n.errorOnInvalidContent&&!a.options.enableContentCheck&&a.options.emitContentError)try{Tl(t,a.schema,{parseOptions:s,errorOnInvalidContent:!0})}catch(e){o(e)}try{i=Tl(t,a.schema,{parseOptions:s,errorOnInvalidContent:n.errorOnInvalidContent??a.options.enableContentCheck})}catch(e){return o(e),!1}let{from:l,to:u}=typeof e==`number`?{from:e,to:e}:{from:e.from,to:e.to},d=!0,f=!0,p=El(i)?i.content:[i];if(p.forEach(e=>{e.check(),d=d?e.isText&&e.marks.length===0:!1,f=f?e.isBlock:!1}),l===u&&f){let{parent:e}=r.doc.resolve(l);e.isTextblock&&!e.type.spec.code&&!e.childCount&&(--l,u+=1)}let m;if(d)m=Array.isArray(t)?t.map(e=>e.text||``).join(``):wl(t)?p.map(e=>e.text??``).join(``):typeof t==`object`&&t&&t.text?t.text:t,r.insertText(m,l,u);else{m=c.from(p);let e=r.doc.resolve(l),t=e.node(),n=e.parentOffset===0,i=t.isText||t.isTextblock,a=t.content.size>0;n&&i&&a&&f&&(l=Math.max(0,l-1)),r.replaceWith(l,u,p)}n.updateSelection&&Dl(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta(`applyInputRules`,{from:l,text:m}),n.applyPasteRules&&r.setMeta(`applyPasteRules`,{from:l,text:m})}return!0};function kl(e){for(let t=0;t({tr:t,dispatch:n,editor:r})=>{let{pos:i,attrs:a,content:o,updateSelection:s=!0}=e,c;c=typeof i==`number`?t.doc.resolve(i):i||t.selection.$from;let l=kl(c.parent.contentMatchAt(c.index()));if(!l)return!1;let u=Object.keys(l.spec.attrs||{}),d=a?Object.fromEntries(Object.entries(a).filter(([e])=>u.includes(e))):{},f;if(o){let e=Tl(o,r.schema);f=l.createAndFill(d,e)}else f=l.createAndFill(d);return f?(n&&(t.insert(c.pos,f),s&&Dl(t,t.steps.length-1,-1)),!0):!1},jl=()=>({state:e,dispatch:t})=>Qn(e,t),Ml=()=>({state:e,dispatch:t})=>$n(e,t),Nl=()=>({state:e,dispatch:t})=>Vn(e,t),Pl=()=>({state:e,dispatch:t})=>Yn(e,t),Fl=(e,t)=>{let n=e.resolve(t),r=n.nodeBefore,i=n.nodeAfter;return!r||!i?!1:!r.type.spec.isolating&&!i.type.spec.isolating},Il=()=>({state:e,dispatch:t,tr:n})=>{try{let r=Kt(e.doc,e.selection.$from.pos,-1);return r==null||!Fl(e.doc,r)?!1:(n.join(r,2),t&&t(n),!0)}catch{return!1}},Ll=()=>({state:e,dispatch:t,tr:n})=>{try{let r=Kt(e.doc,e.selection.$from.pos,1);return r==null||!Fl(e.doc,r)?!1:(n.join(r,2),t&&t(n),!0)}catch{return!1}},Rl=()=>({state:e,dispatch:t})=>Hn(e,t),zl=()=>({state:e,dispatch:t})=>Un(e,t);function Bl(){return typeof navigator<`u`&&/Mac/.test(navigator.platform)}function Vl(e){let t=e.split(/-(?!$)/),n=t[t.length-1];n===`Space`&&(n=` `);let r,i,a,o;for(let e=0;e({editor:t,view:n,tr:r,dispatch:i})=>{let a=Vl(e).split(/-(?!$)/),o=a.find(e=>![`Alt`,`Ctrl`,`Meta`,`Shift`].includes(e)),s=new KeyboardEvent(`keydown`,{key:o===`Space`?` `:o,altKey:a.includes(`Alt`),ctrlKey:a.includes(`Ctrl`),metaKey:a.includes(`Meta`),shiftKey:a.includes(`Shift`),bubbles:!0,cancelable:!0});return t.captureTransaction(()=>{n.someProp(`handleKeyDown`,e=>e(n,s))})?.steps.forEach(e=>{let t=e.map(r.mapping);t&&i&&r.maybeStep(t)}),!0};function Ul(e,t,n={}){let{from:r,to:i,empty:a}=e.selection,o=t?L(t,e.schema):null,s=[];e.doc.nodesBetween(r,i,(e,t)=>{if(e.isText)return;let n=Math.max(r,t),a=Math.min(i,t+e.nodeSize);s.push({node:e,from:n,to:a})});let c=i-r,l=s.filter(e=>!o||o.name===e.node.type.name).filter(e=>ol(e.node.attrs,n,{strict:!1}));return a?!!l.length:l.reduce((e,t)=>e+t.to-t.from,0)>=c}var Wl=(e,t={})=>({state:n,dispatch:r})=>Ul(n,L(e,n.schema),t)?er(n,r):!1,Gl=()=>({state:e,dispatch:t})=>ar(e,t),Kl=e=>({state:t,dispatch:n})=>Tr(L(e,t.schema))(t,n),ql=()=>({state:e,dispatch:t})=>tr(e,t);function Jl(e,t){return t.nodes[e]?`node`:t.marks[e]?`mark`:null}function Yl(e,t){let n=typeof t==`string`?[t]:t;return Object.keys(e).reduce((t,r)=>(n.includes(r)||(t[r]=e[r]),t),{})}var Xl=(e,t)=>({tr:n,state:r,dispatch:i})=>{let a=null,o=null,s=Jl(typeof e==`string`?e:e.name,r.schema);if(!s)return!1;s===`node`&&(a=L(e,r.schema)),s===`mark`&&(o=ul(e,r.schema));let c=!1;return n.selection.ranges.forEach(e=>{r.doc.nodesBetween(e.$from.pos,e.$to.pos,(e,r)=>{a&&a===e.type&&(c=!0,i&&n.setNodeMarkup(r,void 0,Yl(e.attrs,t))),o&&e.marks.length&&e.marks.forEach(a=>{o===a.type&&(c=!0,i&&n.addMark(r,r+e.nodeSize,o.create(Yl(a.attrs,t))))})})}),c},Zl=()=>({tr:e,dispatch:t})=>(t&&e.scrollIntoView(),!0),Ql=()=>({tr:e,dispatch:t})=>{if(t){let t=new Cn(e.doc);e.setSelection(t)}return!0},$l=()=>({state:e,dispatch:t})=>Kn(e,t),eu=()=>({state:e,dispatch:t})=>Xn(e,t),tu=()=>({state:e,dispatch:t})=>cr(e,t),nu=()=>({state:e,dispatch:t})=>mr(e,t),ru=()=>({state:e,dispatch:t})=>pr(e,t);function iu(e,t,n={},r={}){return Tl(e,t,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var au=(e,{errorOnInvalidContent:t,emitUpdate:n=!0,parseOptions:r={}}={})=>({editor:i,tr:a,dispatch:o,commands:s})=>{let{doc:c}=a;if(r.preserveWhitespace!==`full`){let s=iu(e,i.schema,r,{errorOnInvalidContent:t??i.options.enableContentCheck});if(o){let e=El(s)?s.content:[s];a.replaceWith(0,c.content.size,e).setMeta(`preventUpdate`,!n)}return!0}return o&&a.setMeta(`preventUpdate`,!n),s.insertContentAt({from:0,to:c.content.size},e,{parseOptions:r,errorOnInvalidContent:t??i.options.enableContentCheck})};function ou(e,t){let n=ul(t,e.schema),{from:r,to:i,empty:a}=e.selection,o=[];a?(e.storedMarks&&o.push(...e.storedMarks),o.push(...e.selection.$head.marks())):e.doc.nodesBetween(r,i,e=>{o.push(...e.marks)});let s=o.find(e=>e.type.name===n.name);return s?{...s.attrs}:{}}function su(e,t){let n=new gn(e);return t.forEach(e=>{e.steps.forEach(e=>{n.step(e)})}),n}function cu(e,t,n){let r=[];return e.nodesBetween(t.from,t.to,(e,t)=>{n(e)&&r.push({node:e,pos:t})}),r}function lu(e,t){for(let n=e.depth;n>0;--n){let r=e.node(n);if(t(r))return{pos:n>0?e.before(n):0,start:e.start(n),depth:n,node:r}}}function uu(e){return t=>lu(t.$from,e)}function R(e,t,n){return e.config[t]===void 0&&e.parent?R(e.parent,t,n):typeof e.config[t]==`function`?e.config[t].bind({...n,parent:e.parent?R(e.parent,t,n):null}):e.config[t]}function du(e){return e.map(e=>{let t=R(e,`addExtensions`,{name:e.name,options:e.options,storage:e.storage});return t?[e,...du(t())]:e}).flat(10)}function fu(e,t){let n=Je.fromSchema(t).serializeFragment(e),r=document.implementation.createHTMLDocument().createElement(`div`);return r.appendChild(n),r.innerHTML}function pu(e,t){let n=new Map;for(let t of e){let e=n.get(t.type)??new Map;e.set(t.name,t),n.set(t.type,e)}return[...Object.values(t.nodes),...Object.values(t.marks)].flatMap(e=>Object.entries(e.spec.attrs??{}).map(([t,r])=>{let i=n.get(e.name)?.get(t),a=Object.hasOwn(r,`default`);return{type:e.name,name:t,attribute:{rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,...i?.attribute,default:r.default,isRequired:!a,validate:r.validate}}}))}var mu={content:`string`,marks:`string`,group:`string`,inline:`boolean`,atom:`boolean`,selectable:`boolean`,draggable:`boolean`,code:`boolean`,whitespace:[`pre`,`normal`],definingAsContext:`boolean`,definingForContent:`boolean`,defining:`boolean`,isolating:`boolean`,linebreakReplacement:`boolean`},hu={inclusive:`boolean`,excludes:`string`,group:`string`,spanning:`boolean`,code:`boolean`};function gu(e,t,n){return Object.fromEntries(Object.entries(t).flatMap(([t,r])=>{let i=e[t];if(i===void 0)return[];if(!(typeof r==`string`?typeof i===r:typeof i==`string`&&r.includes(i)))throw RangeError(`Invalid schemaSpec field '${n}.${t}'`);return[[t,i]]}))}function _u(e,t,n,r){return{...Object.fromEntries(Object.entries(t).filter(([e])=>e!==`attrs`&&!Object.hasOwn(r,e))),...gu(n,r,e),attrs:n.attrs}}function vu(e,t,n){for(let r of Object.keys(t))if(!Object.hasOwn(e,r))throw RangeError(`schemaSpec requires a local ${n} extension named '${r}'`);for(let r of Object.keys(e))if(!Object.hasOwn(t,r))throw RangeError(`Local ${n} extension '${r}' is not in schemaSpec`)}function yu(e,t){vu(e.nodes,t.nodes,`node`),vu(e.marks,t.marks,`mark`);let n=t.spec.nodes,r=t.spec.marks;return t.spec.nodes.forEach((t,r)=>{n=n.update(t,_u(t,e.nodes[t],r,mu))}),t.spec.marks.forEach((t,n)=>{r=r.update(t,_u(t,e.marks[t],n,hu))}),{topNode:t.topNodeType.name,nodes:n,marks:r}}function bu(e){let t=e.filter((t,n)=>e.indexOf(t)!==n);return Array.from(new Set(t))}function xu(e){return{baseExtensions:e.filter(e=>e.type===`extension`),nodeExtensions:e.filter(e=>e.type===`node`),markExtensions:e.filter(e=>e.type===`mark`)}}function Su(e){let t=[],{nodeExtensions:n,markExtensions:r}=xu(e),i=[...n,...r],a={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1},o=n.filter(e=>e.name!==`text`).map(e=>e.name),s=r.map(e=>e.name),c=[...o,...s];return e.forEach(e=>{let n=R(e,`addGlobalAttributes`,{name:e.name,options:e.options,storage:e.storage,extensions:i});n&&n().forEach(e=>{let n;n=Array.isArray(e.types)?e.types:e.types===`*`?c:e.types===`nodes`?o:e.types===`marks`?s:[],n.forEach(n=>{Object.entries(e.attributes).forEach(([e,r])=>{t.push({type:n,name:e,attribute:{...a,...r}})})})})}),i.forEach(e=>{let n=R(e,`addAttributes`,{name:e.name,options:e.options,storage:e.storage});if(!n)return;let r=n();Object.entries(r).forEach(([n,r])=>{let i={...a,...r};typeof i?.default==`function`&&(i.default=i.default()),i?.isRequired&&i?.default===void 0&&delete i.default,t.push({type:e.name,name:n,attribute:i})})}),t}function Cu(e){return typeof e==`function`}function z(e,t=void 0,...n){return Cu(e)?t?e.bind(t)(...n):e(...n):e}function wu(e={}){return Object.keys(e).length===0&&e.constructor===Object}function Tu(e){let t=[],n=``,r=!1,i=!1,a=0,o=e.length;for(let s=0;s0){--a,n+=o;continue}if(o===`;`&&a===0){t.push(n),n=``;continue}}n+=o}}return n&&t.push(n),t}function Eu(e){let t=[],n=Tu(e||``),r=n.length;for(let e=0;e!!e).reduce((e,t)=>{let n={...e};return Object.entries(t).forEach(([e,t])=>{if(e===`__proto__`)Object.defineProperty(n,e,{configurable:!0,enumerable:!0,value:t,writable:!0});else if(!n[e])n[e]=t;else if(e===`class`){let r=t?String(t).split(` `):[],i=n[e]?n[e].split(` `):[],a=r.filter(e=>!i.includes(e));n[e]=[...i,...a].join(` `)}else if(e===`style`){let r=new Map([...Eu(n[e]),...Eu(t)]);n[e]=Array.from(r.entries()).map(([e,t])=>`${e}: ${t}`).join(`; `)}else n[e]=t}),n},{})}function Du(e,t){return t.filter(t=>t.type===e.type.name).filter(e=>e.attribute.rendered).map(t=>t.attribute.renderHTML?t.attribute.renderHTML(e.attrs)||{}:{[t.name]:e.attrs[t.name]}).reduce((e,t)=>B(e,t),{})}function Ou(e){return typeof e==`string`?e.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(e):e===`true`||e!==`false`&&e:e}function ku(e,t){return`style`in e?e:{...e,getAttrs:n=>{let r=e.getAttrs?e.getAttrs(n):e.attrs;if(r===!1)return!1;let i=t.reduce((e,t)=>{let r=t.attribute.parseHTML?t.attribute.parseHTML(n):Ou(n.getAttribute(t.name));return r==null?e:{...e,[t.name]:r}},{});return{...r,...i}}}}function Au(e){return Object.fromEntries(Object.entries(e).filter(([e,t])=>e===`attrs`&&wu(t)?!1:t!=null))}function ju(e){var t,n;let r={};return!(e!=null&&(t=e.attribute)!=null&&t.isRequired)&&`default`in(e?.attribute||{})&&(r.default=e.attribute.default),(e==null||(n=e.attribute)==null?void 0:n.validate)!==void 0&&(r.validate=e.attribute.validate),[e.name,r]}function Mu(e,t,n=Su(e)){let{nodeExtensions:r,markExtensions:i}=xu(e);return{topNode:r.find(e=>R(e,`topNode`))?.name,nodes:Object.fromEntries(r.map(r=>{let i=n.filter(e=>e.type===r.name),a={name:r.name,options:r.options,storage:r.storage,editor:t},o=Au({...e.reduce((e,t)=>{let n=R(t,`extendNodeSchema`,a);return{...e,...n?n(r):{}}},{}),content:z(R(r,`content`,a)),marks:z(R(r,`marks`,a)),group:z(R(r,`group`,a)),inline:z(R(r,`inline`,a)),atom:z(R(r,`atom`,a)),selectable:z(R(r,`selectable`,a)),draggable:z(R(r,`draggable`,a)),code:z(R(r,`code`,a)),whitespace:z(R(r,`whitespace`,a)),linebreakReplacement:z(R(r,`linebreakReplacement`,a)),defining:z(R(r,`defining`,a)),isolating:z(R(r,`isolating`,a)),attrs:Object.fromEntries(i.map(ju))}),s=z(R(r,`parseHTML`,a));s&&(o.parseDOM=s.map(e=>ku(e,i)));let c=R(r,`renderHTML`,a);c&&(o.toDOM=e=>c({node:e,HTMLAttributes:Du(e,i)}));let l=R(r,`renderText`,a);return l&&(o.toText=l),[r.name,o]})),marks:Object.fromEntries(i.map(r=>{let i=n.filter(e=>e.type===r.name),a={name:r.name,options:r.options,storage:r.storage,editor:t},o=Au({...e.reduce((e,t)=>{let n=R(t,`extendMarkSchema`,a);return{...e,...n?n(r):{}}},{}),inclusive:z(R(r,`inclusive`,a)),excludes:z(R(r,`excludes`,a)),group:z(R(r,`group`,a)),spanning:z(R(r,`spanning`,a)),code:z(R(r,`code`,a)),attrs:Object.fromEntries(i.map(ju))}),s=z(R(r,`parseHTML`,a));s&&(o.parseDOM=s.map(e=>ku(e,i)));let c=R(r,`renderHTML`,a);return c&&(o.toDOM=e=>c({mark:e,HTMLAttributes:Du(e,i)})),[r.name,o]}))}}function Nu(e,t,n){if(n===void 0)return new Ae(Mu(e,t));let r=bu(e.filter(e=>e.type!==`extension`).map(e=>e.name));if(r.length)throw RangeError(`Duplicate local schema types: ${r.join(`, `)}`);let i=new Ae(n);return new Ae(yu(Mu(e,t,pu(Su(e),i)),i))}function Pu(e){return e.sort((e,t)=>{let n=R(e,`priority`)||100,r=R(t,`priority`)||100;return n>r?-1:+(ne.name));return n.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${n.map(e=>`'${e}'`).join(`, `)}]. This can lead to issues.`),t}function Iu(e,t){return Nu(Fu(e),t)}function Lu(e,t,n){let{from:r,to:i}=t,{blockSeparator:a=` -`,textSerializers:o={}}=n||{},s=``;return e.nodesBetween(r,i,(e,n,c,l)=>{e.isBlock&&n>r&&(s+=a);let u=o?.[e.type.name];if(u)return c&&(s+=u({node:e,pos:n,parent:c,index:l,range:t})),!1;if(e.isText){var d;s+=e==null||(d=e.text)==null?void 0:d.slice(Math.max(r,n)-n,i-n)}}),s}function Iu(e,t){return Fu(e,{from:0,to:e.content.size},t)}function Lu(e){return Object.fromEntries(Object.entries(e.nodes).filter(([,e])=>e.spec.toText).map(([e,t])=>[e,t.spec.toText]))}function Ru(e,t){let n=z(t,e.schema),{from:r,to:i}=e.selection,a=[];e.doc.nodesBetween(r,i,e=>{a.push(e)});let o=a.reverse().find(e=>e.type.name===n.name);return o?{...o.attrs}:{}}function zu(e,t){let n=Kl(typeof t==`string`?t:t.name,e.schema);return n===`node`?Ru(e,t):n===`mark`?iu(e,t):{}}function Bu(e,t=JSON.stringify){let n={};return e.filter(e=>{let r=t(e);return Object.prototype.hasOwnProperty.call(n,r)?!1:n[r]=!0})}function Vu(e){let t=Bu(e);return t.length===1?t:t.filter((e,n)=>!t.filter((e,t)=>t!==n).some(t=>e.oldRange.from>=t.oldRange.from&&e.oldRange.to<=t.oldRange.to&&e.newRange.from>=t.newRange.from&&e.newRange.to<=t.newRange.to))}function Hu(e){let{mapping:t,steps:n}=e,r=[],i=t.invert();return t.maps.forEach((e,a)=>{let o=[];if(e.ranges.length)e.forEach((e,t)=>{o.push({from:e,to:t})});else{let{from:e,to:t}=n[a];if(e===void 0||t===void 0)return;o.push({from:e,to:t})}let s=t.slice(a);o.forEach(({from:e,to:t})=>{let n=s.map(e,-1),a=s.map(t),o=i.map(n,-1),c=i.map(a);r.push({oldRange:{from:o,to:c},newRange:{from:n,to:a}})})}),Vu(r)}function Uu(e,t,n){let r=[];return e===t?n.resolve(e).marks().forEach(t=>{let i=sl(n.resolve(e),t.type);i&&r.push({mark:t,...i})}):n.nodesBetween(e,t,(e,t)=>{e&&e?.nodeSize!==void 0&&r.push(...e.marks.map(n=>({from:t,to:t+e.nodeSize,mark:n})))}),r}var Wu=(e,t,n,r=20)=>{let i=e.doc.resolve(n),a=r,o=null;for(;a>0&&o===null;){let e=i.node(a);e?.type.name===t?o=e:--a}return[o,a]},Gu=e=>{let t=e.depth-1;if(t<0)return null;let n=e.index(t);return n===0?null:e.node(t).child(n-1)};function Ku(e,t){return t.nodes[e]||t.marks[e]||null}function qu(e,t,n){return Object.fromEntries(Object.entries(n).filter(([n])=>{let r=e.find(e=>e.type===t&&e.name===n);return r?r.attribute.keepOnSplit:!1}))}var Ju=(e,t=500)=>{let n=``,r=e.parentOffset;return e.parent.nodesBetween(Math.max(0,r-t),r,(e,t,i,a)=>{var o;let s=(o=e.type.spec).toText?.call(o,{node:e,pos:t,parent:i,index:a})||e.textContent||`%leaf%`;n+=e.isAtom&&!e.isText?s:s.slice(0,Math.max(0,r-t))}),n};function Yu(e,t,n={}){let{empty:r,ranges:i}=e.selection,a=t?cl(t,e.schema):null;if(r)return!!(e.storedMarks||e.selection.$from.marks()).filter(e=>!a||a.name===e.type.name).find(e=>il(e.attrs,n,{strict:!1}));let o=0,s=[];if(i.forEach(({$from:t,$to:n})=>{let r=t.pos,i=n.pos;e.doc.nodesBetween(r,i,(e,t)=>{if(a&&e.inlineContent&&!e.type.allowsMarkType(a))return!1;if(!e.isText&&!e.marks.length)return;let n=Math.max(r,t),c=Math.min(i,t+e.nodeSize),l=c-n;o+=l,s.push(...e.marks.map(e=>({mark:e,from:n,to:c})))})}),o===0)return!1;let c=s.filter(e=>!a||a.name===e.mark.type.name).filter(e=>il(e.mark.attrs,n,{strict:!1})).reduce((e,t)=>e+t.to-t.from,0),l=s.filter(e=>!a||e.mark.type!==a&&e.mark.type.excludes(a)).reduce((e,t)=>e+t.to-t.from,0);return(c>0?c+l:c)>=o}function Xu(e,t,n={}){if(!t)return Vl(e,null,n)||Yu(e,null,n);let r=Kl(t,e.schema);return r===`node`?Vl(e,t,n):r===`mark`&&Yu(e,t,n)}var Zu=(e,t)=>{let{$from:n,$to:r,$anchor:i}=e.selection;if(t){let n=cu(e=>e.type.name===t)(e.selection);if(!n)return!1;let r=e.doc.resolve(n.pos+1);return i.pos+1===r.end()}return!(r.parentOffset{let{$from:t,$to:n}=e.selection;return!(t.parentOffset>0||t.pos!==n.pos)};function $u(e,t){return Array.isArray(t)?t.some(t=>(typeof t==`string`?t:t.name)===e.name):t}function ed(e,t){let{nodeExtensions:n}=yu(t),r=n.find(t=>t.name===e);if(!r)return!1;let i=V(B(r,`group`,{name:r.name,options:r.options,storage:r.storage}));return typeof i==`string`&&i.split(` `).includes(`list`)}function td(e,{checkChildren:t=!0,ignoreWhitespace:n=!1}={}){if(n){if(e.type.name===`hardBreak`)return!0;if(e.isText)return!/\S/.test(e.text??``)}if(e.isText)return!e.text;if(e.isAtom||e.isLeaf)return!1;if(e.content.childCount===0)return!0;if(t){let r=!0;return e.content.forEach(e=>{r!==!1&&(td(e,{ignoreWhitespace:n,checkChildren:t})||(r=!1))}),r}return!1}function nd(e){return e instanceof j}function rd(e){if(typeof e!=`object`||!e)return!1;let t=e;return typeof t.apply==`function`&&typeof t.getMap==`function`&&typeof t.invert==`function`&&typeof t.map==`function`&&typeof t.merge==`function`&&typeof t.toJSON==`function`}function id(e){if(typeof e!=`object`||!e)return!1;let t=e;if(!rd(t))return!1;let n=t.toJSON();return!(typeof n!=`object`||!n||n.stepType!==`replace`)}var ad=class e{constructor(e){this.position=e}static fromJSON(t){return new e(t.position)}toJSON(){return{position:this.position}}};function od(e,t){let n=t.mapping.mapResult(e.position);return{position:new ad(n.pos),mapResult:n}}function sd(e){return new ad(e)}function cd(e,t,n){let r=e.state.doc.content.size,i=fl(t,0,r),a=fl(n,0,r),o=e.coordsAtPos(i),s=e.coordsAtPos(a,-1),c=Math.min(o.top,s.top),l=Math.max(o.bottom,s.bottom),u=Math.min(o.left,s.left),d=Math.max(o.right,s.right),f={top:c,bottom:l,left:u,right:d,width:d-u,height:l-c,x:u,y:c};return{...f,toJSON:()=>f}}function ld(e,t,n){let{selection:r}=t,i=null;if(dl(r)&&(i=r.$cursor),i){let t=e.storedMarks??i.marks();return i.parent.type.allowsMarkType(n)&&(!!n.isInSet(t)||!t.some(e=>e.type.excludes(n)))}let{ranges:a}=r;return a.some(({$from:t,$to:r})=>{let i=t.depth===0&&e.doc.inlineContent&&e.doc.type.allowsMarkType(n);return e.doc.nodesBetween(t.pos,r.pos,(e,t,r)=>{if(i)return!1;if(e.isInline){let t=!r||r.type.allowsMarkType(n),a=!!n.isInSet(e.marks)||!e.marks.some(e=>e.type.excludes(n));i=t&&a}return!i}),i})}var ud=(e,t={})=>({tr:n,state:r,dispatch:i})=>{let{selection:a}=n,{empty:o,ranges:s}=a,c=cl(e,r.schema);if(i){if(o){let e=iu(r,c);n.addStoredMark(c.create({...e,...t}))}else s.forEach(e=>{let i=e.$from.pos,a=e.$to.pos;r.doc.nodesBetween(i,a,(e,r)=>{let o=Math.max(r,i),s=Math.min(r+e.nodeSize,a);e.marks.find(e=>e.type===c)?e.marks.forEach(e=>{c===e.type&&n.addMark(o,s,c.create({...e.attrs,...t}))}):n.addMark(o,s,c.create(t))})})}return ld(r,n,c)},dd=(e,t)=>({tr:n})=>(n.setMeta(e,t),!0),fd=(e,t={})=>({state:n,dispatch:r,chain:i})=>{let a=z(e,n.schema),o;return n.selection.$anchor.sameParent(n.selection.$head)&&(o=n.selection.$anchor.parent.attrs),a.isTextblock?i().command(({commands:e})=>gr(a,{...o,...t})(n)?!0:e.clearNodes()).command(({state:e})=>gr(a,{...o,...t})(e,r)).run():(console.warn(`[tiptap warn]: Currently "setNode()" only supports text block nodes.`),!1)},pd=e=>({tr:t,dispatch:n})=>{if(n){let{doc:n}=t,r=fl(e,0,n.content.size),i=j.create(n,r);t.setSelection(i)}return!0},md=(e,t)=>({tr:n,state:r,dispatch:i})=>{let{selection:a}=r,o,s;return typeof t==`number`?(o=t,s=t):t&&`from`in t&&`to`in t?(o=t.from,s=t.to):(o=a.from,s=a.to),i&&n.doc.nodesBetween(o,s,(t,r)=>{t.isText||n.setNodeMarkup(r,void 0,{...t.attrs,dir:e})}),!0},hd=e=>({tr:t,dispatch:n})=>{if(n){let{doc:n}=t,{from:r,to:i}=typeof e==`number`?{from:e,to:e}:e,a=A.atStart(n).from,o=A.atEnd(n).to,s=fl(r,a,o),c=fl(i,a,o),l=A.create(n,s,c);t.setSelection(l)}return!0},gd=e=>({state:t,dispatch:n})=>Or(z(e,t.schema))(t,n);function _d(e,t){let n=e.storedMarks||e.selection.$to.parentOffset&&e.selection.$from.marks();if(n){let r=n.filter(e=>t?.includes(e.type.name));e.tr.ensureMarks(r)}}var vd=({keepMarks:e=!0}={})=>({tr:t,state:n,dispatch:r,editor:i})=>{let{selection:a,doc:o}=t,{$from:s,$to:c}=a,l=i.extensionManager.attributes,u=qu(l,s.node().type.name,s.node().attrs);if(a instanceof j&&a.node.isBlock)return!s.parentOffset||!Vt(o,s.pos)?!1:(r&&(e&&_d(n,i.extensionManager.splittableMarks),t.split(s.pos).scrollIntoView()),!0);if(!s.parent.isBlock)return!1;let d=c.parentOffset===c.parent.content.size,f=s.depth===0?void 0:Dl(s.node(-1).contentMatchAt(s.indexAfter(-1))),p=d&&f?[{type:f,attrs:u}]:void 0,m=a instanceof A&&!a.empty?Fn.create({doc:t.doc,selection:a}).tr.deleteSelection():null,h=m?m.doc:t.doc,g=m?m.mapping.map(s.pos):s.pos,_=Vt(h,g,1,p);if(!p&&!_&&Vt(h,g,1,f?[{type:f}]:void 0)&&(_=!0,p=f?[{type:f,attrs:u}]:void 0),r){if(_){let e=t.steps.length;if(a instanceof A&&t.deleteSelection(),t.split(t.mapping.slice(e).map(s.pos),1,p),f&&!d&&!s.parentOffset&&s.parent.type!==f){let n=t.mapping.slice(e).map(s.before()),r=t.doc.resolve(n);s.node(-1).canReplaceWith(r.index(),r.index()+1,f)&&t.setNodeMarkup(t.mapping.slice(e).map(s.before()),f)}}e&&_d(n,i.extensionManager.splittableMarks),t.scrollIntoView()}return _},yd=(e,t={})=>({tr:n,state:r,dispatch:i,editor:a})=>{let o=z(e,r.schema),{$from:s,$to:l}=r.selection,u=r.selection.node;if(u&&u.isBlock||s.depth<2||!s.sameParent(l))return!1;let d=s.node(-1);if(d.type!==o)return!1;let f=a.extensionManager.attributes;if(s.parent.content.size===0&&s.node(-1).childCount===s.indexAfter(-1)){if(s.depth===2||s.node(-3).type!==o||s.index(-2)!==s.node(-2).childCount-1)return!1;if(i){let e=c.empty,r=s.index(-1)?1:s.index(-2)?2:3;for(let t=s.depth-r;t>=s.depth-3;--t)e=c.from(s.node(t).copy(e));let i=s.indexAfter(-1){if(d>-1)return!1;e.isTextblock&&e.content.size===0&&(d=t+1)}),d>-1&&n.setSelection(A.near(n.doc.resolve(d))),n.scrollIntoView()}return!0}let p=l.pos===s.end()?d.contentMatchAt(0).defaultType:null,h={...qu(f,d.type.name,d.attrs),...t},g={...qu(f,s.node().type.name,s.node().attrs),...t},_=s.parentOffset===0&&s.index(-1)===0,v=s.before(-1);n.delete(s.pos,l.pos);let y=_?d.attrs:h,b=p?[{type:o,attrs:y},{type:p,attrs:g}]:[{type:o,attrs:y}];if(!Vt(n.doc,s.pos,2))return!1;if(i){let{selection:e,storedMarks:t}=r,{splittableMarks:o}=a.extensionManager,c=t||e.$to.parentOffset&&e.$from.marks();if(n.split(s.pos,2,b).scrollIntoView(),_&&n.setNodeMarkup(v,void 0,h),!c||!i)return!0;let l=c.filter(e=>o.includes(e.type.name));n.ensureMarks(l)}return!0};function bd(e,t,n){if(!e.validContent(t))return null;try{return e.create(n,t)}catch{return null}}function xd(e,t){if(e.pendingContent.length===0)return!0;let n=bd(t,c.from(e.pendingContent));return n?(e.items.push(n),e.pendingContent=[],!0):!1}function Sd(e,t,n){return n.validContent(c.from([...t.pendingContent,e]))?(t.pendingContent.push(e),!0):!xd(t,n)||!n.validContent(c.from(e))?!1:(t.pendingContent.push(e),!0)}function Cd(e,t,n,r){let i=r(e,n);if(!i)return!1;let a=bd(n.listType,c.from(i),e.attrs);return a?n.itemType.validContent(c.from([...t.pendingContent,a]))?(t.pendingContent.push(a),!0):xd(t,n.itemType)?(t.items.push(...i),!0):!1:!1}function wd(e,t,n){let r={items:[],pendingContent:[]};for(let i=0;ie!==t||(n=r,!1)),n}function Dd(e){return!e||e===`1`?null:e}function Od(e,t){return Dd(e)===Dd(t)}var kd=(e,t)=>{let n=cu(e=>e.type===t)(e.selection);if(!n)return!0;let r=e.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(r===void 0)return!0;let i=e.doc.nodeAt(r);return!(n.node.type===i?.type&&Ut(e.doc,n.pos))||!Od(n.node.attrs.type,i?.attrs.type)||e.join(n.pos),!0},Ad=(e,t)=>{let n=cu(e=>e.type===t)(e.selection);if(!n)return!0;let r=e.doc.resolve(n.start).after(n.depth);if(r===void 0)return!0;let i=e.doc.nodeAt(r);return!(n.node.type===i?.type&&Ut(e.doc,r))||!Od(n.node.attrs.type,i?.attrs.type)||e.join(r),!0};function jd(e){let t=e.doc,n=t.firstChild;if(!n)return null;let r=t.resolve(1),i=t.resolve(n.nodeSize-1);return A.between(r,i)}var Md=(e,t,n,r={})=>({editor:i,tr:a,state:o,dispatch:s,chain:l,commands:u,can:d})=>{let{extensions:f,splittableMarks:p}=i.extensionManager,m=z(e,o.schema),h=z(t,o.schema),{selection:g,storedMarks:_}=o,{$from:v,$to:y}=g,b=v.blockRange(y),x=_||g.$to.parentOffset&&g.$from.marks();if(!b)return!1;let S=cu(e=>ed(e.type.name,f))(g),C=g.from===0&&g.to===o.doc.content.size,w=o.doc.content.content,T=w.length===1?w[0]:null,ee=C&&T&&ed(T.type.name,f)?{node:T,pos:0,depth:0}:null,E=S??ee,D=!!S&&b.depth>=1&&b.depth-S.depth<=1,te=!!ee;if((D||te)&&E){if(E.node.type===m)return C&&te?l().command(({tr:e,dispatch:t})=>{let n=jd(e);return n?(e.setSelection(n),t&&t(e),!0):!1}).liftListItem(h).run():u.liftListItem(h);if(ed(E.node.type.name,f)&&m.validContent(E.node.content))return l().command(()=>(a.setNodeMarkup(E.pos,m),!0)).command(()=>kd(a,m)).command(()=>Ad(a,m)).run();if(ed(E.node.type.name,f)){let e=E.node.firstChild?.type;if(e&&e!==h){let e=Td(E.node,{listType:m,itemType:h,isListNode:e=>ed(e.type.name,f)}),t=e?c.from(e):null;return!t||!m.validContent(t)?!1:l().command(()=>{let{$anchor:e,$head:n}=a.selection,i=e.parent,o=n.parent,s=e.parentOffset,c=n.parentOffset,l;try{l=m.create(r,t)}catch{return!1}if(a.replaceWith(E.pos,E.pos+E.node.nodeSize,l),i.inlineContent&&o.inlineContent){let e=Ed(l,i),t=Ed(l,o);if(e!==null&&t!==null){let n=E.pos+e+2+s,r=E.pos+t+2+c;a.setSelection(A.create(a.doc,n,r))}}return!0}).command(()=>kd(a,m)).command(()=>Ad(a,m)).run()}}}return!n||!x||!s?l().command(()=>d().wrapInList(m,r)?!0:u.clearNodes()).wrapInList(m,r).command(()=>kd(a,m)).command(()=>Ad(a,m)).run():l().command(()=>{let e=d().wrapInList(m,r),t=x.filter(e=>p.includes(e.type.name));return a.ensureMarks(t),e?!0:u.clearNodes()}).wrapInList(m,r).command(()=>kd(a,m)).command(()=>Ad(a,m)).run()},Nd=(e,t={},n={})=>({state:r,commands:i})=>{let{extendEmptyMarkRange:a=!1}=n,o=cl(e,r.schema);return Yu(r,o,t)?i.unsetMark(o,{extendEmptyMarkRange:a}):i.setMark(o,t)},Pd=(e,t,n={})=>({state:r,commands:i})=>{let a=z(e,r.schema),o=z(t,r.schema),s=Vl(r,a,n),c;return r.selection.$anchor.sameParent(r.selection.$head)&&(c=r.selection.$anchor.parent.attrs),s?i.setNode(o,c):i.setNode(a,{...c,...n})},Fd=(e,t={})=>({state:n,commands:r})=>{let i=z(e,n.schema);return Vl(n,i,t)?r.lift(i):r.wrapIn(i,t)},Id=()=>({state:e,dispatch:t})=>{let n=e.plugins;for(let r=0;r=0;--e)t.step(n.steps[e].invert(n.docs[e]));if(a.text){let n=t.doc.resolve(a.from).marks();t.replaceWith(a.from,a.to,e.schema.text(a.text,n))}else t.delete(a.from,a.to)}return!0}}return!1},Ld=(e={})=>({tr:t,dispatch:n,editor:r})=>{let{ignoreClearable:i=!1}=e,{selection:a}=t,{empty:o,ranges:s}=a;if(o)return!0;let{nonClearableMarks:c}=r.extensionManager;if(n){let e=Object.values(r.schema.marks).filter(e=>i||!c.includes(e.name));s.forEach(n=>{for(let r of e)t.removeMark(n.$from.pos,n.$to.pos,r)})}return!0},Rd=(e,t={})=>({tr:n,state:r,dispatch:i})=>{let{extendEmptyMarkRange:a=!1}=t,{selection:o}=n,s=cl(e,r.schema),{$from:c,empty:l,ranges:u}=o;if(!i)return!0;if(l&&a){let{from:e,to:t}=o,r=sl(c,s,c.marks().find(e=>e.type===s)?.attrs);r&&(e=r.from,t=r.to),n.removeMark(e,t,s)}else u.forEach(e=>{n.removeMark(e.$from.pos,e.$to.pos,s)});return n.removeStoredMark(s),!0},zd=e=>({tr:t,state:n,dispatch:r})=>{let{selection:i}=n,a,o;return typeof e==`number`?(a=e,o=e):e&&`from`in e&&`to`in e?(a=e.from,o=e.to):(a=i.from,o=i.to),r&&t.doc.nodesBetween(a,o,(e,n)=>{if(e.isText)return;let r={...e.attrs};delete r.dir,t.setNodeMarkup(n,void 0,r)}),!0},Bd=(e,t={})=>({tr:n,state:r,dispatch:i})=>{let a=null,o=null,s=Kl(typeof e==`string`?e:e.name,r.schema);if(!s)return!1;s===`node`&&(a=z(e,r.schema)),s===`mark`&&(o=cl(e,r.schema));let c=!1;return n.selection.ranges.forEach(e=>{let s=e.$from.pos,l=e.$to.pos,u,d,f,p;n.selection.empty?r.doc.nodesBetween(s,l,(e,t)=>{a&&a===e.type&&(c=!0,f=Math.max(t,s),p=Math.min(t+e.nodeSize,l),u=t,d=e)}):r.doc.nodesBetween(s,l,(e,r)=>{r=s&&r<=l&&(a&&a===e.type&&(c=!0,i&&n.setNodeMarkup(r,void 0,{...e.attrs,...t})),o&&e.marks.length&&e.marks.forEach(a=>{if(o===a.type&&(c=!0,i)){let i=Math.max(r,s),c=Math.min(r+e.nodeSize,l);n.addMark(i,c,o.create({...a.attrs,...t}))}}))}),d&&(u!==void 0&&i&&n.setNodeMarkup(u,void 0,{...d.attrs,...t}),o&&d.marks.length&&d.marks.forEach(e=>{o===e.type&&i&&n.addMark(f,p,o.create({...e.attrs,...t}))}))}),c},Vd=new N(`__tiptap_decorations__`),Hd=e=>({tr:t,dispatch:n})=>(n&&t.setMeta(Vd,{type:`force`,name:e}),!0),Ud=(e,t={})=>({state:n,dispatch:r})=>hr(z(e,n.schema),t)(n,r),Wd=(e,t={})=>({state:n,dispatch:r})=>Sr(z(e,n.schema),t)(n,r),Gd=n({blur:()=>Hc,clearContent:()=>Uc,clearNodes:()=>Wc,command:()=>Gc,createParagraphNear:()=>Kc,cut:()=>qc,deleteCurrentNode:()=>Jc,deleteNode:()=>Yc,deleteRange:()=>Xc,deleteSelection:()=>el,enter:()=>tl,exitCode:()=>nl,extendMarkRange:()=>ll,first:()=>ul,focus:()=>_l,forEach:()=>vl,insertContent:()=>yl,insertContentAt:()=>El,insertDefaultBlock:()=>Ol,joinBackward:()=>jl,joinDown:()=>Al,joinForward:()=>Ml,joinItemBackward:()=>Pl,joinItemForward:()=>Fl,joinTextblockBackward:()=>Il,joinTextblockForward:()=>Ll,joinUp:()=>kl,keyboardShortcut:()=>Bl,lift:()=>Hl,liftEmptyBlock:()=>Ul,liftListItem:()=>Wl,newlineInCode:()=>Gl,resetAttributes:()=>Jl,scrollIntoView:()=>Yl,selectAll:()=>Xl,selectNodeBackward:()=>Zl,selectNodeForward:()=>Ql,selectParentNode:()=>$l,selectTextblockEnd:()=>eu,selectTextblockStart:()=>tu,setContent:()=>ru,setMark:()=>ud,setMeta:()=>dd,setNode:()=>fd,setNodeSelection:()=>pd,setTextDirection:()=>md,setTextSelection:()=>hd,sinkListItem:()=>gd,splitBlock:()=>vd,splitListItem:()=>yd,toggleList:()=>Md,toggleMark:()=>Nd,toggleNode:()=>Pd,toggleWrap:()=>Fd,undoInputRule:()=>Id,unsetAllMarks:()=>Ld,unsetMark:()=>Rd,unsetTextDirection:()=>zd,updateAttributes:()=>Bd,updateDecorations:()=>Hd,wrapIn:()=>Ud,wrapInList:()=>Wd}),Kd=new WeakMap;function qd(e,t){Kd.set(e,(Kd.get(e)??0)+1);try{return t()}finally{let t=(Kd.get(e)??1)-1;t>0?Kd.set(e,t):Kd.delete(e)}}function Jd(e){return Kd.has(e)}var Yd=class{constructor(){this.callbacks={}}on(e,t){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(t),this}emit(e,...t){let n=this.callbacks[e];return n&&n.forEach(e=>e.apply(this,t)),this}off(e,t){let n=this.callbacks[e];return n&&(t?this.callbacks[e]=n.filter(e=>e!==t):delete this.callbacks[e]),this}once(e,t){let n=(...r)=>{this.off(e,n),t.apply(this,r)};return this.on(e,n)}removeAllListeners(){this.callbacks={}}},Xd=typeof process<`u`&&process.env.NODE_ENV!==`production`;function Zd(e){return e.kind===`widget`}function Qd(e,t){let n=[],r=new Set;for(let i of e)i.kind===`widget`&&Zd(i)&&r.add(i.key),n.push(i.toPMDecoration(t));return{decorations:n,widgetKeys:r}}function $d(e,t,n){let{decorations:r,widgetKeys:i}=Qd(t,n);return{set:L.create(e,r),widgetKeys:i}}function ef({position:e,from:t,to:n,docSize:r}){return eef({position:e.anchor,from:t,to:n,docSize:r})?!0:(e.anchor===n||a.has(i)||(a.add(i),console.warn(`[tiptap warn]: Extension "${i}" returned a decoration outside the requested range [${t}, ${n}). It was ignored.`)),!1))}function nf(e){let t=e.spec?.key;return typeof t==`string`?t:void 0}function rf(e){let t=new Map,n=new Map;for(let r of e.find()){let e=nf(r);if(!e)continue;let i=r.spec.extensionName??`unknown`,a=t.get(e)??new Set;a.add(i),t.set(e,a),n.set(e,(n.get(e)??0)+1)}return Array.from(t,([e,t])=>({key:e,extensions:t})).filter(({key:e})=>(n.get(e)??0)>1)}function af(e){return e.jsonID===`attr`}function of(e){let t=!1;if(e.getMap().forEach(()=>{t=!0}),t||af(e))return!0;let n=e;return typeof n.from==`number`&&typeof n.to==`number`}function sf(e,t){let n=null,r=0,i=0;for(let a=0;at.to);a+=1){let o=i+e.child(a).nodeSize;o>=t.from&&(n===null&&(n=i),r=o),i=o}return n===null?null:{from:n,to:r}}function cf(e,t){if(e.steps.some(e=>!of(e)))return{type:`full`};let n=Hu(e).map(({newRange:e})=>e);e.steps.forEach((t,r)=>{if(!af(t))return;let i=e.mapping.slice(r);n.push({from:i.map(t.pos,-1),to:i.map(t.pos+1)})});let r=[];for(let e of n){let n=sf(t,e);n&&r.push(n)}r.sort((e,t)=>e.from-t.from);let i=[];for(let e of r){let t=i[i.length-1];t&&e.from<=t.to?t.to=Math.max(t.to,e.to):i.push({...e})}return{type:`ranges`,ranges:i}}function lf(e,t,n,r){return e.map(t,n,{onRemove:e=>{let t=e?.key;typeof t==`string`&&r.delete(t)}})}function uf(e,t,n){let r=t.decorationSetsByExtension[e]??L.empty,i=new Set(t.widgetKeysByExtension[e]??[]);return{set:lf(r,n.mapping,n.doc,i),widgetKeys:i}}function df(e,t){let n=Object.values(t).flatMap(e=>e.find());return L.create(e,n)}function ff(e){let t=new Set;for(let n of Object.values(e))for(let e of n)t.add(e);return t}function pf(e,t){switch(t.update??`document`){case`document`:if(t.createInRange)throw Error(`[tiptap error]: Extension "${e}" provides createInRange() but does not use the "changedRanges" decoration update strategy.`);return;case`changedRanges`:if(!t.createInRange)throw Error(`[tiptap error]: Extension "${e}" uses the "changedRanges" decoration update strategy but does not provide createInRange().`);return;case`manual`:if(t.createInRange)throw Error(`[tiptap error]: Extension "${e}" uses the "manual" decoration update strategy, which is not compatible with createInRange(). createInRange() requires the "changedRanges" strategy.`);if(t.shouldUpdate)throw Error(`[tiptap error]: Extension "${e}" cannot combine the "manual" decoration update strategy with shouldUpdate().`);return;default:throw Error(`[tiptap error]: Extension "${e}" uses an unknown decoration update strategy. Expected "document", "changedRanges", or "manual".`)}}function mf(e,t,n){return n?!0:e.update===`manual`?!1:e.shouldUpdate?e.shouldUpdate(t):t.tr.docChanged}var hf=new Set,gf=class{constructor(e){this.warnedWidgetKeys=new Set,this.warnedOutOfRangeExtensions=new Set,this.handleBeforeTransaction=({nextState:e})=>{let t=Vd.getState(e);t&&this.warnDuplicateWidgetKeys(t)},this.editor=e.editor,this.entries=this.resolveEntries(e.entries),this.entries.forEach(({name:e,spec:t})=>pf(e,t)),this.plugin=this.entries.length>0?this.createPlugin():null,this.editor.on(`beforeTransaction`,this.handleBeforeTransaction)}destroy(){this.editor.off(`beforeTransaction`,this.handleBeforeTransaction)}liveWidgetKeys(){return Vd.getState(this.editor.state)?.widgetKeys??hf}get mountedView(){return this.editor.isDestroyed?null:this.editor.view}resolveEntries(e){let t=[];for(let{name:n,addDecorations:r}of e){let e=r();e&&t.push({name:n,spec:e})}return t}createPlugin(){let{editor:e,entries:t}=this;return new M({key:Vd,state:{init:(e,n)=>{let r={},i={};for(let{name:e,spec:a}of t){let{set:t,widgetKeys:o}=this.buildFullSet(e,a,n);r[e]=t,i[e]=o}let a={decorationSetsByExtension:r,widgetKeysByExtension:i,mergedDecorationSet:this.buildMergedSet(n.doc,r),widgetKeys:ff(i)};return this.warnDuplicateWidgetKeys(a),a},apply:(n,r,i,a)=>{let o=n.getMeta(Vd),s=o?.type===`force`&&!o.name,c=o?.type===`force`?o.name:void 0,l={},u={},d=new Set;return qd(e,()=>{for(let{name:o,spec:f}of t){let t=s||c===o;if(!mf(f,{editor:e,tr:n,oldState:i,newState:a},t)){let e=uf(o,r,n);l[o]=e.set,u[o]=e.widgetKeys}else if(f.update===`changedRanges`&&n.docChanged&&!t){let e=this.applyChangedRangesRecompute(o,f,r,n,a);l[o]=e.set,u[o]=e.widgetKeys,d.add(o)}else{let{set:e,widgetKeys:t}=this.buildFullSet(o,f,a);l[o]=e,u[o]=t,d.add(o)}}}),d.size===0&&!n.docChanged?r:{decorationSetsByExtension:l,widgetKeysByExtension:u,mergedDecorationSet:this.mergeAfterApply({entries:t,previous:r,tr:n,decorationSetsByExtension:l,recomputedNames:d}),widgetKeys:ff(u)}}},props:{decorations(e){return Vd.getState(e)?.mergedDecorationSet??L.empty}}})}applyChangedRangesRecompute(e,t,n,r,i){let a=cf(r,i.doc);return a.type===`full`?this.buildFullSet(e,t,i):this.rebuildRanges(e,t,n,r,i,a.ranges)}rebuildRanges(e,t,n,r,i,a){let o=n.decorationSetsByExtension[e]??L.empty,s=new Set(n.widgetKeysByExtension[e]??[]),c=lf(o,r.mapping,r.doc,s),l=i.doc.content.size;for(let{from:n,to:r}of a){let a=c.find(n,r).filter(e=>ef({position:e.from,from:n,to:r,docSize:l}));for(let e of a){let t=nf(e);t&&s.delete(t)}c=c.remove(a);let{decorations:o,widgetKeys:u}=Qd(tf({decorations:this.runCreate(e,`createInRange`,()=>t.createInRange({editor:this.editor,state:i,view:this.mountedView,from:n,to:r})),from:n,to:r,docSize:l,extensionName:e,warnedExtensions:this.warnedOutOfRangeExtensions}),e);c=c.add(i.doc,o);for(let e of u)s.add(e)}return{set:c,widgetKeys:s}}buildFullSet(e,t,n){let r=this.runCreate(e,`create`,()=>t.create({editor:this.editor,state:n,view:this.mountedView}));return $d(n.doc,r,e)}runCreate(e,t,n){try{return n()}catch(n){return console.error(`[tiptap error]: Extension "${e}" threw in \`addDecorations().${t}()\`. Its decorations were dropped for this update.`,n),[]}}warnDuplicateWidgetKeys(e){if(!Xd)return;if(e.widgetKeys.size===0){this.warnedWidgetKeys.clear();return}let t=rf(e.mergedDecorationSet),n=new Set(t.map(({key:e})=>e));for(let{key:e,extensions:n}of t){if(this.warnedWidgetKeys.has(e))continue;let t=Array.from(n).map(e=>`"${e}"`).join(`, `);console.warn(`[tiptap warn]: Duplicate widget decoration key "${e}" in extension${n.size===1?``:`s`} ${t}. Widget decoration keys must be globally unique, otherwise ProseMirror misplaces the widget DOM. Use a stable, unique key (e.g. \`comment-\${id}\`).`)}this.warnedWidgetKeys=n}buildMergedSet(e,t){let n=Object.keys(t);return n.length===1?t[n[0]]:df(e,t)}mergeAfterApply({entries:e,previous:t,tr:n,decorationSetsByExtension:r,recomputedNames:i}){return e.length===1?r[e[0].name]:i.size===0?t.mergedDecorationSet.map(n.mapping,n.doc):df(n.doc,r)}};function _f(e,t){let{selection:n}=e,{$from:r}=n;if(n instanceof j){let e=r.index();return r.parent.canReplaceWith(e,e+1,t)}let i=r.depth;for(;i>=0;){let e=r.index(i);if(r.node(i).contentMatchAt(e).matchType(t))return!0;--i}return!1}function vf(e,t,n){let r=document.querySelector(`style[data-tiptap-style${n?`-${n}`:``}]`);if(r!==null)return r;let i=document.createElement(`style`);return t&&i.setAttribute(`nonce`,t),i.setAttribute(`data-tiptap-style${n?`-${n}`:``}`,``),i.innerHTML=e,document.getElementsByTagName(`head`)[0].appendChild(i),i}function yf(e){return e.replace(/[-/\\^$*+?.()|[\]{}]/g,`\\$&`)}function bf(e,t){let n=e.getAttribute(`style`);if(!n)return null;let r=n.split(`;`).map(e=>e.trim()).filter(Boolean),i=t.toLowerCase();for(let e=r.length-1;e>=0;--e){let t=r[e],n=t.indexOf(`:`);if(n!==-1&&t.slice(0,n).trim().toLowerCase()===i)return t.slice(n+1).trim()}return null}function xf(e){return typeof e==`number`}function Sf(e){return Object.prototype.toString.call(e).slice(8,-1)}function Cf(e){return Sf(e)===`Object`&&e.constructor===Object&&Object.getPrototypeOf(e)===Object.prototype}function wf(e){return typeof e==`string`&&e.trim().length>0&&!/[;{}]/.test(e)}function Tf(e,t){return e.replace(/^[ \t]*/,e=>{let n=0;for(let t of e)n+=t===` `?4-n%4:1;return` `.repeat(Math.max(0,n-t))})}function Ef(e,t){let n=`text\n${e}\n`,r=t(n)[0];return(r?.type===`paragraph`||r?.type===`text`)&&r.raw===n}function Df(e,t,n){let r=t.split(` -`),i=n.isParagraphContinuation??(e=>Ef(e,n.blockTokens)),a=0;for(let e of r){if(!e.trim()||!i(e))break;a+=1}return{mainContent:[e,...r.slice(0,a).map(e=>e.trimStart())].join(` +`,textSerializers:o={}}=n||{},s=``;return e.nodesBetween(r,i,(e,n,c,l)=>{e.isBlock&&n>r&&(s+=a);let u=o?.[e.type.name];if(u)return c&&(s+=u({node:e,pos:n,parent:c,index:l,range:t})),!1;if(e.isText){var d;s+=e==null||(d=e.text)==null?void 0:d.slice(Math.max(r,n)-n,i-n)}}),s}function Ru(e,t){return Lu(e,{from:0,to:e.content.size},t)}function zu(e){return Object.fromEntries(Object.entries(e.nodes).filter(([,e])=>e.spec.toText).map(([e,t])=>[e,t.spec.toText]))}function Bu(e,t){let n=L(t,e.schema),{from:r,to:i}=e.selection,a=[];e.doc.nodesBetween(r,i,e=>{a.push(e)});let o=a.reverse().find(e=>e.type.name===n.name);return o?{...o.attrs}:{}}function Vu(e,t){let n=Jl(typeof t==`string`?t:t.name,e.schema);return n===`node`?Bu(e,t):n===`mark`?ou(e,t):{}}function Hu(e,t=JSON.stringify){let n={};return e.filter(e=>{let r=t(e);return Object.prototype.hasOwnProperty.call(n,r)?!1:n[r]=!0})}function Uu(e){let t=Hu(e);return t.length===1?t:t.filter((e,n)=>!t.filter((e,t)=>t!==n).some(t=>e.oldRange.from>=t.oldRange.from&&e.oldRange.to<=t.oldRange.to&&e.newRange.from>=t.newRange.from&&e.newRange.to<=t.newRange.to))}function Wu(e){let{mapping:t,steps:n}=e,r=[],i=t.invert();return t.maps.forEach((e,a)=>{let o=[];if(e.ranges.length)e.forEach((e,t)=>{o.push({from:e,to:t})});else{let{from:e,to:t}=n[a];if(e===void 0||t===void 0)return;o.push({from:e,to:t})}let s=t.slice(a);o.forEach(({from:e,to:t})=>{let n=s.map(e,-1),a=s.map(t),o=i.map(n,-1),c=i.map(a);r.push({oldRange:{from:o,to:c},newRange:{from:n,to:a}})})}),Uu(r)}function Gu(e,t,n){let r=[];return e===t?n.resolve(e).marks().forEach(t=>{let i=ll(n.resolve(e),t.type);i&&r.push({mark:t,...i})}):n.nodesBetween(e,t,(e,t)=>{e&&e?.nodeSize!==void 0&&r.push(...e.marks.map(n=>({from:t,to:t+e.nodeSize,mark:n})))}),r}var Ku=(e,t,n,r=20)=>{let i=e.doc.resolve(n),a=r,o=null;for(;a>0&&o===null;){let e=i.node(a);e?.type.name===t?o=e:--a}return[o,a]},qu=e=>{let t=e.depth-1;if(t<0)return null;let n=e.index(t);return n===0?null:e.node(t).child(n-1)};function Ju(e,t){return t.nodes[e]||t.marks[e]||null}function Yu(e,t,n){return Object.fromEntries(Object.entries(n).filter(([n])=>{let r=e.find(e=>e.type===t&&e.name===n);return r?r.attribute.keepOnSplit:!1}))}var Xu=(e,t=500)=>{let n=``,r=e.parentOffset;return e.parent.nodesBetween(Math.max(0,r-t),r,(e,t,i,a)=>{var o;let s=(o=e.type.spec).toText?.call(o,{node:e,pos:t,parent:i,index:a})||e.textContent||`%leaf%`;n+=e.isAtom&&!e.isText?s:s.slice(0,Math.max(0,r-t))}),n};function Zu(e,t,n={}){let{empty:r,ranges:i}=e.selection,a=t?ul(t,e.schema):null;if(r)return!!(e.storedMarks||e.selection.$from.marks()).filter(e=>!a||a.name===e.type.name).find(e=>ol(e.attrs,n,{strict:!1}));let o=0,s=[];if(i.forEach(({$from:t,$to:n})=>{let r=t.pos,i=n.pos;e.doc.nodesBetween(r,i,(e,t)=>{if(a&&e.inlineContent&&!e.type.allowsMarkType(a))return!1;if(!e.isText&&!e.marks.length)return;let n=Math.max(r,t),c=Math.min(i,t+e.nodeSize),l=c-n;o+=l,s.push(...e.marks.map(e=>({mark:e,from:n,to:c})))})}),o===0)return!1;let c=s.filter(e=>!a||a.name===e.mark.type.name).filter(e=>ol(e.mark.attrs,n,{strict:!1})).reduce((e,t)=>e+t.to-t.from,0),l=s.filter(e=>!a||e.mark.type!==a&&e.mark.type.excludes(a)).reduce((e,t)=>e+t.to-t.from,0);return(c>0?c+l:c)>=o}function Qu(e,t,n={}){if(!t)return Ul(e,null,n)||Zu(e,null,n);let r=Jl(t,e.schema);return r===`node`?Ul(e,t,n):r===`mark`&&Zu(e,t,n)}var $u=(e,t)=>{let{$from:n,$to:r,$anchor:i}=e.selection;if(t){let n=uu(e=>e.type.name===t)(e.selection);if(!n)return!1;let r=e.doc.resolve(n.pos+1);return i.pos+1===r.end()}return!(r.parentOffset{let{$from:t,$to:n}=e.selection;return!(t.parentOffset>0||t.pos!==n.pos)};function td(e,t){return Array.isArray(t)?t.some(t=>(typeof t==`string`?t:t.name)===e.name):t}function nd(e,t){let{nodeExtensions:n}=xu(t),r=n.find(t=>t.name===e);if(!r)return!1;let i=z(R(r,`group`,{name:r.name,options:r.options,storage:r.storage}));return typeof i==`string`&&i.split(` `).includes(`list`)}function rd(e,{checkChildren:t=!0,ignoreWhitespace:n=!1}={}){if(n){if(e.type.name===`hardBreak`)return!0;if(e.isText)return!/\S/.test(e.text??``)}if(e.isText)return!e.text;if(e.isAtom||e.isLeaf)return!1;if(e.content.childCount===0)return!0;if(t){let r=!0;return e.content.forEach(e=>{r!==!1&&(rd(e,{ignoreWhitespace:n,checkChildren:t})||(r=!1))}),r}return!1}function id(e){return e instanceof j}function ad(e){if(typeof e!=`object`||!e)return!1;let t=e;return typeof t.apply==`function`&&typeof t.getMap==`function`&&typeof t.invert==`function`&&typeof t.map==`function`&&typeof t.merge==`function`&&typeof t.toJSON==`function`}function od(e){if(typeof e!=`object`||!e)return!1;let t=e;if(!ad(t))return!1;let n=t.toJSON();return!(typeof n!=`object`||!n||n.stepType!==`replace`)}var sd=class e{constructor(e){this.position=e}static fromJSON(t){return new e(t.position)}toJSON(){return{position:this.position}}};function cd(e,t){let n=t.mapping.mapResult(e.position);return{position:new sd(n.pos),mapResult:n}}function ld(e){return new sd(e)}function ud(e,t,n){let r=e.state.doc.content.size,i=ml(t,0,r),a=ml(n,0,r),o=e.coordsAtPos(i),s=e.coordsAtPos(a,-1),c=Math.min(o.top,s.top),l=Math.max(o.bottom,s.bottom),u=Math.min(o.left,s.left),d=Math.max(o.right,s.right),f={top:c,bottom:l,left:u,right:d,width:d-u,height:l-c,x:u,y:c};return{...f,toJSON:()=>f}}function dd(e,t,n){let{selection:r}=t,i=null;if(pl(r)&&(i=r.$cursor),i){let t=e.storedMarks??i.marks();return i.parent.type.allowsMarkType(n)&&(!!n.isInSet(t)||!t.some(e=>e.type.excludes(n)))}let{ranges:a}=r;return a.some(({$from:t,$to:r})=>{let i=t.depth===0&&e.doc.inlineContent&&e.doc.type.allowsMarkType(n);return e.doc.nodesBetween(t.pos,r.pos,(e,t,r)=>{if(i)return!1;if(e.isInline){let t=!r||r.type.allowsMarkType(n),a=!!n.isInSet(e.marks)||!e.marks.some(e=>e.type.excludes(n));i=t&&a}return!i}),i})}var fd=(e,t={})=>({tr:n,state:r,dispatch:i})=>{let{selection:a}=n,{empty:o,ranges:s}=a,c=ul(e,r.schema);if(i){if(o){let e=ou(r,c);n.addStoredMark(c.create({...e,...t}))}else s.forEach(e=>{let i=e.$from.pos,a=e.$to.pos;r.doc.nodesBetween(i,a,(e,r)=>{let o=Math.max(r,i),s=Math.min(r+e.nodeSize,a);e.marks.find(e=>e.type===c)?e.marks.forEach(e=>{c===e.type&&n.addMark(o,s,c.create({...e.attrs,...t}))}):n.addMark(o,s,c.create(t))})})}return dd(r,n,c)},pd=(e,t)=>({tr:n})=>(n.setMeta(e,t),!0),md=(e,t={})=>({state:n,dispatch:r,chain:i})=>{let a=L(e,n.schema),o;return n.selection.$anchor.sameParent(n.selection.$head)&&(o=n.selection.$anchor.parent.attrs),a.isTextblock?i().command(({commands:e})=>gr(a,{...o,...t})(n)?!0:e.clearNodes()).command(({state:e})=>gr(a,{...o,...t})(e,r)).run():(console.warn(`[tiptap warn]: Currently "setNode()" only supports text block nodes.`),!1)},hd=e=>({tr:t,dispatch:n})=>{if(n){let{doc:n}=t,r=ml(e,0,n.content.size),i=j.create(n,r);t.setSelection(i)}return!0},gd=(e,t)=>({tr:n,state:r,dispatch:i})=>{let{selection:a}=r,o,s;return typeof t==`number`?(o=t,s=t):t&&`from`in t&&`to`in t?(o=t.from,s=t.to):(o=a.from,s=a.to),i&&n.doc.nodesBetween(o,s,(t,r)=>{t.isText||n.setNodeMarkup(r,void 0,{...t.attrs,dir:e})}),!0},_d=e=>({tr:t,dispatch:n})=>{if(n){let{doc:n}=t,{from:r,to:i}=typeof e==`number`?{from:e,to:e}:e,a=A.atStart(n).from,o=A.atEnd(n).to,s=ml(r,a,o),c=ml(i,a,o),l=A.create(n,s,c);t.setSelection(l)}return!0},vd=e=>({state:t,dispatch:n})=>Or(L(e,t.schema))(t,n);function yd(e,t){let n=e.storedMarks||e.selection.$to.parentOffset&&e.selection.$from.marks();if(n){let r=n.filter(e=>t?.includes(e.type.name));e.tr.ensureMarks(r)}}var bd=({keepMarks:e=!0}={})=>({tr:t,state:n,dispatch:r,editor:i})=>{let{selection:a,doc:o}=t,{$from:s,$to:c}=a,l=i.extensionManager.attributes,u=Yu(l,s.node().type.name,s.node().attrs);if(a instanceof j&&a.node.isBlock)return!s.parentOffset||!Vt(o,s.pos)?!1:(r&&(e&&yd(n,i.extensionManager.splittableMarks),t.split(s.pos).scrollIntoView()),!0);if(!s.parent.isBlock)return!1;let d=c.parentOffset===c.parent.content.size,f=s.depth===0?void 0:kl(s.node(-1).contentMatchAt(s.indexAfter(-1))),p=d&&f?[{type:f,attrs:u}]:void 0,m=a instanceof A&&!a.empty?Fn.create({doc:t.doc,selection:a}).tr.deleteSelection():null,h=m?m.doc:t.doc,g=m?m.mapping.map(s.pos):s.pos,_=Vt(h,g,1,p);if(!p&&!_&&Vt(h,g,1,f?[{type:f}]:void 0)&&(_=!0,p=f?[{type:f,attrs:u}]:void 0),r){if(_){let e=t.steps.length;if(a instanceof A&&t.deleteSelection(),t.split(t.mapping.slice(e).map(s.pos),1,p),f&&!d&&!s.parentOffset&&s.parent.type!==f){let n=t.mapping.slice(e).map(s.before()),r=t.doc.resolve(n);s.node(-1).canReplaceWith(r.index(),r.index()+1,f)&&t.setNodeMarkup(t.mapping.slice(e).map(s.before()),f)}}e&&yd(n,i.extensionManager.splittableMarks),t.scrollIntoView()}return _},xd=(e,t={})=>({tr:n,state:r,dispatch:i,editor:a})=>{let o=L(e,r.schema),{$from:s,$to:l}=r.selection,u=r.selection.node;if(u&&u.isBlock||s.depth<2||!s.sameParent(l))return!1;let d=s.node(-1);if(d.type!==o)return!1;let f=a.extensionManager.attributes;if(s.parent.content.size===0&&s.node(-1).childCount===s.indexAfter(-1)){if(s.depth===2||s.node(-3).type!==o||s.index(-2)!==s.node(-2).childCount-1)return!1;if(i){let e=c.empty,r=s.index(-1)?1:s.index(-2)?2:3;for(let t=s.depth-r;t>=s.depth-3;--t)e=c.from(s.node(t).copy(e));let i=s.indexAfter(-1){if(d>-1)return!1;e.isTextblock&&e.content.size===0&&(d=t+1)}),d>-1&&n.setSelection(A.near(n.doc.resolve(d))),n.scrollIntoView()}return!0}let p=l.pos===s.end()?d.contentMatchAt(0).defaultType:null,h={...Yu(f,d.type.name,d.attrs),...t},g={...Yu(f,s.node().type.name,s.node().attrs),...t},_=s.parentOffset===0&&s.index(-1)===0,v=s.before(-1);n.delete(s.pos,l.pos);let y=_?d.attrs:h,b=p?[{type:o,attrs:y},{type:p,attrs:g}]:[{type:o,attrs:y}];if(!Vt(n.doc,s.pos,2))return!1;if(i){let{selection:e,storedMarks:t}=r,{splittableMarks:o}=a.extensionManager,c=t||e.$to.parentOffset&&e.$from.marks();if(n.split(s.pos,2,b).scrollIntoView(),_&&n.setNodeMarkup(v,void 0,h),!c||!i)return!0;let l=c.filter(e=>o.includes(e.type.name));n.ensureMarks(l)}return!0};function Sd(e,t,n){if(!e.validContent(t))return null;try{return e.create(n,t)}catch{return null}}function Cd(e,t){if(e.pendingContent.length===0)return!0;let n=Sd(t,c.from(e.pendingContent));return n?(e.items.push(n),e.pendingContent=[],!0):!1}function wd(e,t,n){return n.validContent(c.from([...t.pendingContent,e]))?(t.pendingContent.push(e),!0):!Cd(t,n)||!n.validContent(c.from(e))?!1:(t.pendingContent.push(e),!0)}function Td(e,t,n,r){let i=r(e,n);if(!i)return!1;let a=Sd(n.listType,c.from(i),e.attrs);return a?n.itemType.validContent(c.from([...t.pendingContent,a]))?(t.pendingContent.push(a),!0):Cd(t,n.itemType)?(t.items.push(...i),!0):!1:!1}function Ed(e,t,n){let r={items:[],pendingContent:[]};for(let i=0;ie!==t||(n=r,!1)),n}function kd(e){return!e||e===`1`?null:e}function Ad(e,t){return kd(e)===kd(t)}var jd=(e,t)=>{let n=uu(e=>e.type===t)(e.selection);if(!n)return!0;let r=e.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(r===void 0)return!0;let i=e.doc.nodeAt(r);return!(n.node.type===i?.type&&Ut(e.doc,n.pos))||!Ad(n.node.attrs.type,i?.attrs.type)||e.join(n.pos),!0},Md=(e,t)=>{let n=uu(e=>e.type===t)(e.selection);if(!n)return!0;let r=e.doc.resolve(n.start).after(n.depth);if(r===void 0)return!0;let i=e.doc.nodeAt(r);return!(n.node.type===i?.type&&Ut(e.doc,r))||!Ad(n.node.attrs.type,i?.attrs.type)||e.join(r),!0};function Nd(e){let t=e.doc,n=t.firstChild;if(!n)return null;let r=t.resolve(1),i=t.resolve(n.nodeSize-1);return A.between(r,i)}var Pd=(e,t,n,r={})=>({editor:i,tr:a,state:o,dispatch:s,chain:l,commands:u,can:d})=>{let{extensions:f,splittableMarks:p}=i.extensionManager,m=L(e,o.schema),h=L(t,o.schema),{selection:g,storedMarks:_}=o,{$from:v,$to:y}=g,b=v.blockRange(y),x=_||g.$to.parentOffset&&g.$from.marks();if(!b)return!1;let S=uu(e=>nd(e.type.name,f))(g),C=g.from===0&&g.to===o.doc.content.size,w=o.doc.content.content,T=w.length===1?w[0]:null,ee=C&&T&&nd(T.type.name,f)?{node:T,pos:0,depth:0}:null,E=S??ee,D=!!S&&b.depth>=1&&b.depth-S.depth<=1,te=!!ee;if((D||te)&&E){if(E.node.type===m)return C&&te?l().command(({tr:e,dispatch:t})=>{let n=Nd(e);return n?(e.setSelection(n),t&&t(e),!0):!1}).liftListItem(h).run():u.liftListItem(h);if(nd(E.node.type.name,f)&&m.validContent(E.node.content))return l().command(()=>(a.setNodeMarkup(E.pos,m),!0)).command(()=>jd(a,m)).command(()=>Md(a,m)).run();if(nd(E.node.type.name,f)){let e=E.node.firstChild?.type;if(e&&e!==h){let e=Dd(E.node,{listType:m,itemType:h,isListNode:e=>nd(e.type.name,f)}),t=e?c.from(e):null;return!t||!m.validContent(t)?!1:l().command(()=>{let{$anchor:e,$head:n}=a.selection,i=e.parent,o=n.parent,s=e.parentOffset,c=n.parentOffset,l;try{l=m.create(r,t)}catch{return!1}if(a.replaceWith(E.pos,E.pos+E.node.nodeSize,l),i.inlineContent&&o.inlineContent){let e=Od(l,i),t=Od(l,o);if(e!==null&&t!==null){let n=E.pos+e+2+s,r=E.pos+t+2+c;a.setSelection(A.create(a.doc,n,r))}}return!0}).command(()=>jd(a,m)).command(()=>Md(a,m)).run()}}}return!n||!x||!s?l().command(()=>d().wrapInList(m,r)?!0:u.clearNodes()).wrapInList(m,r).command(()=>jd(a,m)).command(()=>Md(a,m)).run():l().command(()=>{let e=d().wrapInList(m,r),t=x.filter(e=>p.includes(e.type.name));return a.ensureMarks(t),e?!0:u.clearNodes()}).wrapInList(m,r).command(()=>jd(a,m)).command(()=>Md(a,m)).run()},Fd=(e,t={},n={})=>({state:r,commands:i})=>{let{extendEmptyMarkRange:a=!1}=n,o=ul(e,r.schema);return Zu(r,o,t)?i.unsetMark(o,{extendEmptyMarkRange:a}):i.setMark(o,t)},Id=(e,t,n={})=>({state:r,commands:i})=>{let a=L(e,r.schema),o=L(t,r.schema),s=Ul(r,a,n),c;return r.selection.$anchor.sameParent(r.selection.$head)&&(c=r.selection.$anchor.parent.attrs),s?i.setNode(o,c):i.setNode(a,{...c,...n})},Ld=(e,t={})=>({state:n,commands:r})=>{let i=L(e,n.schema);return Ul(n,i,t)?r.lift(i):r.wrapIn(i,t)},Rd=()=>({state:e,dispatch:t})=>{let n=e.plugins;for(let r=0;r=0;--e)t.step(n.steps[e].invert(n.docs[e]));if(a.text){let n=t.doc.resolve(a.from).marks();t.replaceWith(a.from,a.to,e.schema.text(a.text,n))}else t.delete(a.from,a.to)}return!0}}return!1},zd=(e={})=>({tr:t,dispatch:n,editor:r})=>{let{ignoreClearable:i=!1}=e,{selection:a}=t,{empty:o,ranges:s}=a;if(o)return!0;let{nonClearableMarks:c}=r.extensionManager;if(n){let e=Object.values(r.schema.marks).filter(e=>i||!c.includes(e.name));s.forEach(n=>{for(let r of e)t.removeMark(n.$from.pos,n.$to.pos,r)})}return!0},Bd=(e,t={})=>({tr:n,state:r,dispatch:i})=>{let{extendEmptyMarkRange:a=!1}=t,{selection:o}=n,s=ul(e,r.schema),{$from:c,empty:l,ranges:u}=o;if(!i)return!0;if(l&&a){let{from:e,to:t}=o,r=ll(c,s,c.marks().find(e=>e.type===s)?.attrs);r&&(e=r.from,t=r.to),n.removeMark(e,t,s)}else u.forEach(e=>{n.removeMark(e.$from.pos,e.$to.pos,s)});return n.removeStoredMark(s),!0},Vd=e=>({tr:t,state:n,dispatch:r})=>{let{selection:i}=n,a,o;return typeof e==`number`?(a=e,o=e):e&&`from`in e&&`to`in e?(a=e.from,o=e.to):(a=i.from,o=i.to),r&&t.doc.nodesBetween(a,o,(e,n)=>{if(e.isText)return;let r={...e.attrs};delete r.dir,t.setNodeMarkup(n,void 0,r)}),!0},Hd=(e,t={})=>({tr:n,state:r,dispatch:i})=>{let a=null,o=null,s=Jl(typeof e==`string`?e:e.name,r.schema);if(!s)return!1;s===`node`&&(a=L(e,r.schema)),s===`mark`&&(o=ul(e,r.schema));let c=!1;return n.selection.ranges.forEach(e=>{let s=e.$from.pos,l=e.$to.pos,u,d,f,p;n.selection.empty?r.doc.nodesBetween(s,l,(e,t)=>{a&&a===e.type&&(c=!0,f=Math.max(t,s),p=Math.min(t+e.nodeSize,l),u=t,d=e)}):r.doc.nodesBetween(s,l,(e,r)=>{r=s&&r<=l&&(a&&a===e.type&&(c=!0,i&&n.setNodeMarkup(r,void 0,{...e.attrs,...t})),o&&e.marks.length&&e.marks.forEach(a=>{if(o===a.type&&(c=!0,i)){let i=Math.max(r,s),c=Math.min(r+e.nodeSize,l);n.addMark(i,c,o.create({...a.attrs,...t}))}}))}),d&&(u!==void 0&&i&&n.setNodeMarkup(u,void 0,{...d.attrs,...t}),o&&d.marks.length&&d.marks.forEach(e=>{o===e.type&&i&&n.addMark(f,p,o.create({...e.attrs,...t}))}))}),c},Ud=new N(`__tiptap_decorations__`),Wd=e=>({tr:t,dispatch:n})=>(n&&t.setMeta(Ud,{type:`force`,name:e}),!0),Gd=(e,t={})=>({state:n,dispatch:r})=>hr(L(e,n.schema),t)(n,r),Kd=(e,t={})=>({state:n,dispatch:r})=>Sr(L(e,n.schema),t)(n,r),qd=n({blur:()=>Wc,clearContent:()=>Gc,clearNodes:()=>Kc,command:()=>qc,createParagraphNear:()=>Jc,cut:()=>Yc,deleteCurrentNode:()=>Xc,deleteNode:()=>Zc,deleteRange:()=>Qc,deleteSelection:()=>nl,enter:()=>rl,exitCode:()=>il,extendMarkRange:()=>dl,first:()=>fl,focus:()=>yl,forEach:()=>bl,insertContent:()=>xl,insertContentAt:()=>Ol,insertDefaultBlock:()=>Al,joinBackward:()=>Nl,joinDown:()=>Ml,joinForward:()=>Pl,joinItemBackward:()=>Il,joinItemForward:()=>Ll,joinTextblockBackward:()=>Rl,joinTextblockForward:()=>zl,joinUp:()=>jl,keyboardShortcut:()=>Hl,lift:()=>Wl,liftEmptyBlock:()=>Gl,liftListItem:()=>Kl,newlineInCode:()=>ql,resetAttributes:()=>Xl,scrollIntoView:()=>Zl,selectAll:()=>Ql,selectNodeBackward:()=>$l,selectNodeForward:()=>eu,selectParentNode:()=>tu,selectTextblockEnd:()=>nu,selectTextblockStart:()=>ru,setContent:()=>au,setMark:()=>fd,setMeta:()=>pd,setNode:()=>md,setNodeSelection:()=>hd,setTextDirection:()=>gd,setTextSelection:()=>_d,sinkListItem:()=>vd,splitBlock:()=>bd,splitListItem:()=>xd,toggleList:()=>Pd,toggleMark:()=>Fd,toggleNode:()=>Id,toggleWrap:()=>Ld,undoInputRule:()=>Rd,unsetAllMarks:()=>zd,unsetMark:()=>Bd,unsetTextDirection:()=>Vd,updateAttributes:()=>Hd,updateDecorations:()=>Wd,wrapIn:()=>Gd,wrapInList:()=>Kd}),Jd=new WeakMap;function Yd(e,t){Jd.set(e,(Jd.get(e)??0)+1);try{return t()}finally{let t=(Jd.get(e)??1)-1;t>0?Jd.set(e,t):Jd.delete(e)}}function Xd(e){return Jd.has(e)}var Zd=class{constructor(){this.callbacks={}}on(e,t){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(t),this}emit(e,...t){let n=this.callbacks[e];return n&&n.forEach(e=>e.apply(this,t)),this}off(e,t){let n=this.callbacks[e];return n&&(t?this.callbacks[e]=n.filter(e=>e!==t):delete this.callbacks[e]),this}once(e,t){let n=(...r)=>{this.off(e,n),t.apply(this,r)};return this.on(e,n)}removeAllListeners(){this.callbacks={}}},Qd=typeof process<`u`&&process.env.NODE_ENV!==`production`;function $d(e){return e.kind===`widget`}function ef(e,t){let n=[],r=new Set;for(let i of e)i.kind===`widget`&&$d(i)&&r.add(i.key),n.push(i.toPMDecoration(t));return{decorations:n,widgetKeys:r}}function tf(e,t,n){let{decorations:r,widgetKeys:i}=ef(t,n);return{set:I.create(e,r),widgetKeys:i}}function nf({position:e,from:t,to:n,docSize:r}){return enf({position:e.anchor,from:t,to:n,docSize:r})?!0:(e.anchor===n||a.has(i)||(a.add(i),console.warn(`[tiptap warn]: Extension "${i}" returned a decoration outside the requested range [${t}, ${n}). It was ignored.`)),!1))}function af(e){let t=e.spec?.key;return typeof t==`string`?t:void 0}function of(e){let t=new Map,n=new Map;for(let r of e.find()){let e=af(r);if(!e)continue;let i=r.spec.extensionName??`unknown`,a=t.get(e)??new Set;a.add(i),t.set(e,a),n.set(e,(n.get(e)??0)+1)}return Array.from(t,([e,t])=>({key:e,extensions:t})).filter(({key:e})=>(n.get(e)??0)>1)}function sf(e){return e.jsonID===`attr`}function cf(e){let t=!1;if(e.getMap().forEach(()=>{t=!0}),t||sf(e))return!0;let n=e;return typeof n.from==`number`&&typeof n.to==`number`}function lf(e,t){let n=null,r=0,i=0;for(let a=0;at.to);a+=1){let o=i+e.child(a).nodeSize;o>=t.from&&(n===null&&(n=i),r=o),i=o}return n===null?null:{from:n,to:r}}function uf(e,t){if(e.steps.some(e=>!cf(e)))return{type:`full`};let n=Wu(e).map(({newRange:e})=>e);e.steps.forEach((t,r)=>{if(!sf(t))return;let i=e.mapping.slice(r);n.push({from:i.map(t.pos,-1),to:i.map(t.pos+1)})});let r=[];for(let e of n){let n=lf(t,e);n&&r.push(n)}r.sort((e,t)=>e.from-t.from);let i=[];for(let e of r){let t=i[i.length-1];t&&e.from<=t.to?t.to=Math.max(t.to,e.to):i.push({...e})}return{type:`ranges`,ranges:i}}function df(e,t,n,r){return e.map(t,n,{onRemove:e=>{let t=e?.key;typeof t==`string`&&r.delete(t)}})}function ff(e,t,n){let r=t.decorationSetsByExtension[e]??I.empty,i=new Set(t.widgetKeysByExtension[e]??[]);return{set:df(r,n.mapping,n.doc,i),widgetKeys:i}}function pf(e,t){let n=Object.values(t).flatMap(e=>e.find());return I.create(e,n)}function mf(e){let t=new Set;for(let n of Object.values(e))for(let e of n)t.add(e);return t}function hf(e,t){switch(t.update??`document`){case`document`:if(t.createInRange)throw Error(`[tiptap error]: Extension "${e}" provides createInRange() but does not use the "changedRanges" decoration update strategy.`);return;case`changedRanges`:if(!t.createInRange)throw Error(`[tiptap error]: Extension "${e}" uses the "changedRanges" decoration update strategy but does not provide createInRange().`);return;case`manual`:if(t.createInRange)throw Error(`[tiptap error]: Extension "${e}" uses the "manual" decoration update strategy, which is not compatible with createInRange(). createInRange() requires the "changedRanges" strategy.`);if(t.shouldUpdate)throw Error(`[tiptap error]: Extension "${e}" cannot combine the "manual" decoration update strategy with shouldUpdate().`);return;default:throw Error(`[tiptap error]: Extension "${e}" uses an unknown decoration update strategy. Expected "document", "changedRanges", or "manual".`)}}function gf(e,t,n){return n?!0:e.update===`manual`?!1:e.shouldUpdate?e.shouldUpdate(t):t.tr.docChanged}var _f=new Set,vf=class{constructor(e){this.warnedWidgetKeys=new Set,this.warnedOutOfRangeExtensions=new Set,this.handleBeforeTransaction=({nextState:e})=>{let t=Ud.getState(e);t&&this.warnDuplicateWidgetKeys(t)},this.editor=e.editor,this.entries=this.resolveEntries(e.entries),this.entries.forEach(({name:e,spec:t})=>hf(e,t)),this.plugin=this.entries.length>0?this.createPlugin():null,this.editor.on(`beforeTransaction`,this.handleBeforeTransaction)}destroy(){this.editor.off(`beforeTransaction`,this.handleBeforeTransaction)}liveWidgetKeys(){return Ud.getState(this.editor.state)?.widgetKeys??_f}get mountedView(){return this.editor.isDestroyed?null:this.editor.view}resolveEntries(e){let t=[];for(let{name:n,addDecorations:r}of e){let e=r();e&&t.push({name:n,spec:e})}return t}createPlugin(){let{editor:e,entries:t}=this;return new M({key:Ud,state:{init:(e,n)=>{let r={},i={};for(let{name:e,spec:a}of t){let{set:t,widgetKeys:o}=this.buildFullSet(e,a,n);r[e]=t,i[e]=o}let a={decorationSetsByExtension:r,widgetKeysByExtension:i,mergedDecorationSet:this.buildMergedSet(n.doc,r),widgetKeys:mf(i)};return this.warnDuplicateWidgetKeys(a),a},apply:(n,r,i,a)=>{let o=n.getMeta(Ud),s=o?.type===`force`&&!o.name,c=o?.type===`force`?o.name:void 0,l={},u={},d=new Set;return Yd(e,()=>{for(let{name:o,spec:f}of t){let t=s||c===o;if(!gf(f,{editor:e,tr:n,oldState:i,newState:a},t)){let e=ff(o,r,n);l[o]=e.set,u[o]=e.widgetKeys}else if(f.update===`changedRanges`&&n.docChanged&&!t){let e=this.applyChangedRangesRecompute(o,f,r,n,a);l[o]=e.set,u[o]=e.widgetKeys,d.add(o)}else{let{set:e,widgetKeys:t}=this.buildFullSet(o,f,a);l[o]=e,u[o]=t,d.add(o)}}}),d.size===0&&!n.docChanged?r:{decorationSetsByExtension:l,widgetKeysByExtension:u,mergedDecorationSet:this.mergeAfterApply({entries:t,previous:r,tr:n,decorationSetsByExtension:l,recomputedNames:d}),widgetKeys:mf(u)}}},props:{decorations(e){return Ud.getState(e)?.mergedDecorationSet??I.empty}}})}applyChangedRangesRecompute(e,t,n,r,i){let a=uf(r,i.doc);return a.type===`full`?this.buildFullSet(e,t,i):this.rebuildRanges(e,t,n,r,i,a.ranges)}rebuildRanges(e,t,n,r,i,a){let o=n.decorationSetsByExtension[e]??I.empty,s=new Set(n.widgetKeysByExtension[e]??[]),c=df(o,r.mapping,r.doc,s),l=i.doc.content.size;for(let{from:n,to:r}of a){let a=c.find(n,r).filter(e=>nf({position:e.from,from:n,to:r,docSize:l}));for(let e of a){let t=af(e);t&&s.delete(t)}c=c.remove(a);let{decorations:o,widgetKeys:u}=ef(rf({decorations:this.runCreate(e,`createInRange`,()=>t.createInRange({editor:this.editor,state:i,view:this.mountedView,from:n,to:r})),from:n,to:r,docSize:l,extensionName:e,warnedExtensions:this.warnedOutOfRangeExtensions}),e);c=c.add(i.doc,o);for(let e of u)s.add(e)}return{set:c,widgetKeys:s}}buildFullSet(e,t,n){let r=this.runCreate(e,`create`,()=>t.create({editor:this.editor,state:n,view:this.mountedView}));return tf(n.doc,r,e)}runCreate(e,t,n){try{return n()}catch(n){return console.error(`[tiptap error]: Extension "${e}" threw in \`addDecorations().${t}()\`. Its decorations were dropped for this update.`,n),[]}}warnDuplicateWidgetKeys(e){if(!Qd)return;if(e.widgetKeys.size===0){this.warnedWidgetKeys.clear();return}let t=of(e.mergedDecorationSet),n=new Set(t.map(({key:e})=>e));for(let{key:e,extensions:n}of t){if(this.warnedWidgetKeys.has(e))continue;let t=Array.from(n).map(e=>`"${e}"`).join(`, `);console.warn(`[tiptap warn]: Duplicate widget decoration key "${e}" in extension${n.size===1?``:`s`} ${t}. Widget decoration keys must be globally unique, otherwise ProseMirror misplaces the widget DOM. Use a stable, unique key (e.g. \`comment-\${id}\`).`)}this.warnedWidgetKeys=n}buildMergedSet(e,t){let n=Object.keys(t);return n.length===1?t[n[0]]:pf(e,t)}mergeAfterApply({entries:e,previous:t,tr:n,decorationSetsByExtension:r,recomputedNames:i}){return e.length===1?r[e[0].name]:i.size===0?t.mergedDecorationSet.map(n.mapping,n.doc):pf(n.doc,r)}};function yf(e,t){let{selection:n}=e,{$from:r}=n;if(n instanceof j){let e=r.index();return r.parent.canReplaceWith(e,e+1,t)}let i=r.depth;for(;i>=0;){let e=r.index(i);if(r.node(i).contentMatchAt(e).matchType(t))return!0;--i}return!1}function bf(e,t,n){let r=document.querySelector(`style[data-tiptap-style${n?`-${n}`:``}]`);if(r!==null)return r;let i=document.createElement(`style`);return t&&i.setAttribute(`nonce`,t),i.setAttribute(`data-tiptap-style${n?`-${n}`:``}`,``),i.innerHTML=e,document.getElementsByTagName(`head`)[0].appendChild(i),i}function xf(e){return e.replace(/[-/\\^$*+?.()|[\]{}]/g,`\\$&`)}function Sf(e,t){let n=e.getAttribute(`style`);if(!n)return null;let r=n.split(`;`).map(e=>e.trim()).filter(Boolean),i=t.toLowerCase();for(let e=r.length-1;e>=0;--e){let t=r[e],n=t.indexOf(`:`);if(n!==-1&&t.slice(0,n).trim().toLowerCase()===i)return t.slice(n+1).trim()}return null}function Cf(e){return typeof e==`number`}function wf(e){return Object.prototype.toString.call(e).slice(8,-1)}function Tf(e){return wf(e)===`Object`&&e.constructor===Object&&Object.getPrototypeOf(e)===Object.prototype}function Ef(e){return typeof e==`string`&&e.trim().length>0&&!/[;{}]/.test(e)}function Df(e,t){return e.replace(/^[ \t]*/,e=>{let n=0;for(let t of e)n+=t===` `?4-n%4:1;return` `.repeat(Math.max(0,n-t))})}function Of(e,t){let n=`text\n${e}\n`,r=t(n)[0];return(r?.type===`paragraph`||r?.type===`text`)&&r.raw===n}function kf(e,t,n){let r=t.split(` +`),i=n.isParagraphContinuation??(e=>Of(e,n.blockTokens)),a=0;for(let e of r){if(!e.trim()||!i(e))break;a+=1}return{mainContent:[e,...r.slice(0,a).map(e=>e.trimStart())].join(` `),nestedContent:r.slice(a).join(` -`)}}function Of(e,t,n){let r=e.split(` -`),i=[],a=``,o=0,s=t.baseIndentSize||2;for(;o0)break;if(e.trim()===``){o+=1,a=`${a}${e}\n`;continue}return}let d=t.extractItemData(u),{indentLevel:f,mainContent:p}=d;a=`${a}${e}\n`;let m=[p];for(o+=1;oe.trim()!==``);if(t===-1)break;if((((l=r[o+1+t].match(/^(\s*)/))==null||(l=l[1])==null?void 0:l.length)||0)>f){m.push(e),a=`${a}${e}\n`,o+=1;continue}break}if((((c=e.match(/^(\s*)/))==null||(c=c[1])==null?void 0:c.length)||0)>f)m.push(e),a=`${a}${e}\n`,o+=1;else break}let h,g=m.slice(1);if(g.length>0){let e=Df(p,g.map(e=>Tf(e,f+s)).join(` -`),n);d.mainContent=e.mainContent;let r=e.nestedContent;r.trim()&&(h=t.customNestedParser?t.customNestedParser(r):n.blockTokens(r))}let _=t.createToken(d,h);i.push(_)}if(i.length!==0)return{items:i,raw:a.slice(0,e.length)}}var kf=4;function Af(e){let t=0;for(let n of e)t=n===` `?t+kf-t%kf:t+1;return t}function jf(e,t,n,r,i){if(!e||!Array.isArray(e.content))return``;let a=typeof n==`function`?n(r):n,[o,...s]=e.content,c=t.renderChildren([o]),l=`${a}${i?.indentMainContent?c.split(` +`)}}function Af(e,t,n){let r=e.split(` +`),i=[],a=``,o=0,s=t.baseIndentSize||2;for(;o0)break;if(e.trim()===``){o+=1,a=`${a}${e}\n`;continue}return}let d=t.extractItemData(u),{indentLevel:f,mainContent:p}=d;a=`${a}${e}\n`;let m=[p];for(o+=1;oe.trim()!==``);if(t===-1)break;if((((l=r[o+1+t].match(/^(\s*)/))==null||(l=l[1])==null?void 0:l.length)||0)>f){m.push(e),a=`${a}${e}\n`,o+=1;continue}break}if((((c=e.match(/^(\s*)/))==null||(c=c[1])==null?void 0:c.length)||0)>f)m.push(e),a=`${a}${e}\n`,o+=1;else break}let h,g=m.slice(1);if(g.length>0){let e=kf(p,g.map(e=>Df(e,f+s)).join(` +`),n);d.mainContent=e.mainContent;let r=e.nestedContent;r.trim()&&(h=t.customNestedParser?t.customNestedParser(r):n.blockTokens(r))}let _=t.createToken(d,h);i.push(_)}if(i.length!==0)return{items:i,raw:a.slice(0,e.length)}}var jf=4;function Mf(e){let t=0;for(let n of e)t=n===` `?t+jf-t%jf:t+1;return t}function Nf(e,t,n,r,i){if(!e||!Array.isArray(e.content))return``;let a=typeof n==`function`?n(r):n,[o,...s]=e.content,c=t.renderChildren([o]),l=`${a}${i?.indentMainContent?c.split(` `).map((e,n)=>n===0?e:t.indent(e)).join(` -`):c}`;return s&&s.length>0&&s.forEach((e,n)=>{let r=t.renderChild?.call(t,e,n+1)??t.renderChildren([e]);if(r!=null){let n=e=>{if(!i?.alignNestedToPrefix)return t.indent(e);let n=t.indent(``),r=Af(a);return(Af(n)>=r?n:` `.repeat(r))+e},o=r.split(` +`):c}`;return s&&s.length>0&&s.forEach((e,n)=>{let r=t.renderChild?.call(t,e,n+1)??t.renderChildren([e]);if(r!=null){let n=e=>{if(!i?.alignNestedToPrefix)return t.indent(e);let n=t.indent(``),r=Mf(a);return(Mf(n)>=r?n:` `.repeat(r))+e},o=r.split(` `).map(e=>n(e||``)).join(` -`);l+=e.type===`paragraph`?`\n\n${o}`:`\n${o}`}}),l}function Mf(e,t){let n={...e};return Cf(e)&&Cf(t)&&Object.keys(t).forEach(r=>{Cf(t[r])&&Cf(e[r])?n[r]=Mf(e[r],t[r]):n[r]=t[r]}),n}function Nf(e,t,n={}){let{state:r}=t,{doc:i,tr:a}=r,o=e;i.descendants((t,r)=>{let i=a.mapping.map(r),s=a.mapping.map(r)+t.nodeSize,c=null;if(t.marks.forEach(e=>{if(e!==o)return!1;c=e}),!c)return;let l=!1;if(Object.keys(n).forEach(e=>{n[e]!==c.attrs[e]&&(l=!0)}),l){let t=e.type.create({...e.attrs,...n});a.removeMark(i,s,e.type),a.addMark(i,s,t)}}),a.docChanged&&t.view.dispatch(a)}var Pf=class{constructor(e){this.find=e.find,this.handler=e.handler,this.undoable=e.undoable??!0}},Ff=(e,t)=>{if(rl(t))return t.exec(e);let n=t(e);if(!n)return null;let r=[n.text];return r.index=n.index,r.input=e,r.data=n.data,n.replaceWith&&(n.text.includes(n.replaceWith)||console.warn(`[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".`),r.push(n.replaceWith)),r};function If(e){let{editor:t,from:n,to:r,text:i,insertText:a}=e;if(!a)return{inputTransaction:null,tr:t.view.state.tr};let o=t.view.state.tr.insertText(i,n,r);return{inputTransaction:o,tr:Fn.create({doc:o.doc,selection:o.selection,storedMarks:o.storedMarks}).tr}}function Lf(e){let{editor:t,from:n,to:r,text:i,rule:a,match:o,plugin:s,insertText:c}=e,{view:l}=t,{inputTransaction:u,tr:d}=If({editor:t,from:n,to:r,text:i,insertText:c}),f=u?n+i.length:r,p=Bc({state:l.state,transaction:d}),m={from:n-(o[0].length-i.length),to:f},{commands:h,chain:g,can:_}=new Vc({editor:t,state:p});return a.handler({state:p,range:m,match:o,commands:h,chain:g,can:_})===null||!d.steps.length?!1:(u&&(l.dispatch(u),!l.state.doc.eq(u.doc))||(Mc(d),d.setMeta(`inputRule`,!0),a.undoable&&d.setMeta(s,{transform:d,from:n,to:f,text:i}),l.dispatch(d)),!0)}function Rf(e,t,n){let r=t[0].length-n.length;if(r<=0)return!0;let i=e.parentOffset-r;return i>=0&&e.parent.textBetween(i,e.parentOffset)===t[0].slice(0,r)}function zf(e){let{editor:t,from:n,to:r,text:i,rules:a,plugin:o,insertText:s}=e,{view:c}=t;if(c.composing)return!1;let l=c.state.doc.resolve(n);if(l.parent.type.spec.code||(l.nodeBefore||l.nodeAfter)?.marks.find(e=>e.type.spec.code))return!1;let u=Ju(l)+i;for(let e of a){let a=Ff(u,e.find);if(a&&Rf(l,a,i)&&Lf({editor:t,from:n,to:r,text:i,rule:e,match:a,plugin:o,insertText:s}))return!0}return!1}function Bf(e){let{editor:t,rules:n}=e,r=new M({state:{init(){return null},apply(e,i,a){let o=e.getMeta(r);if(o)return o;let s=e.getMeta(`applyInputRules`);return s&&setTimeout(()=>{let{text:e}=s;e=typeof e==`string`?e:uu(c.from(e),a.schema);let{from:i}=s,o=i+e.length;zf({editor:t,from:i,to:o,text:e,rules:n,plugin:r})}),e.selectionSet||e.docChanged?null:i}},props:{handleTextInput(e,i,a,o){return zf({editor:t,from:i,to:a,text:o,rules:n,plugin:r,insertText:!0})},handleDOMEvents:{compositionend:e=>(setTimeout(()=>{let{$cursor:i}=e.state.selection;i&&zf({editor:t,from:i.pos,to:i.pos,text:``,rules:n,plugin:r})}),!1)},handleKeyDown(e,i){if(i.key!==`Enter`)return!1;let{$cursor:a}=e.state.selection;return a?zf({editor:t,from:a.pos,to:a.pos,text:` -`,rules:n,plugin:r}):!1}},isInputRules:!0});return r}var Vf=class{constructor(e={}){this.type=`extendable`,this.parent=null,this.child=null,this.name=``,this.config={name:this.name},this.config={...this.config,...e},this.name=this.config.name}get options(){return{...V(B(this,`addOptions`,{name:this.name}))}}get storage(){return{...V(B(this,`addStorage`,{name:this.name,options:this.options}))}}configure(e={}){let t=this.extend({...this.config,addOptions:()=>Mf(this.options,e)});return t.name=this.name,t.parent=this.parent,this.child=null,t}extend(e={}){let t=new this.constructor({...this.config,...e});return t.parent=this,this.child=t,t.name=`name`in e?e.name:t.parent.name,t}},Hf=class e extends Vf{constructor(...e){super(...e),this.type=`mark`}static create(t={}){let n=typeof t==`function`?t():t;return new e(n)}static handleExit({editor:e,mark:t}){let{tr:n}=e.state,r=e.state.selection.$from;if(r.pos===r.end()){let i=r.marks();if(!i.find(e=>e?.type.name===t.name))return!1;let a=i.find(e=>e?.type.name===t.name);return a&&n.removeStoredMark(a),n.insertText(` `,r.pos),e.view.dispatch(n),!0}return!1}configure(e){return super.configure(e)}extend(e){let t=typeof e==`function`?e():e;return super.extend(t)}},Uf=class{constructor(e){this.find=e.find,this.handler=e.handler}},Wf=(e,t,n)=>{if(rl(t))return[...e.matchAll(t)];let r=t(e,n);return r?r.map(t=>{let n=[t.text];return n.index=t.index,n.input=e,n.data=t.data,t.replaceWith&&(t.text.includes(t.replaceWith)||console.warn(`[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".`),n.push(t.replaceWith)),n}):[]};function Gf(e){let{editor:t,state:n,from:r,to:i,rule:a,pasteEvent:o,dropEvent:s}=e,{commands:c,chain:l,can:u}=new Vc({editor:t,state:n}),d=[];return n.doc.nodesBetween(r,i,(e,t)=>{var f;if((f=e.type)!=null&&(f=f.spec)!=null&&f.code||!(e.isText||e.isTextblock||e.isInline))return;let p=e.content?.size??e.nodeSize??0,m=Math.max(r,t),h=Math.min(i,t+p);m>=h||Wf(e.isText?e.text||``:e.textBetween(m-t,h-t,void 0,``),a.find,o).forEach(e=>{if(e.index===void 0)return;let t=m+e.index+1,r=t+e[0].length,i={from:n.tr.mapping.map(t),to:n.tr.mapping.map(r)},f=a.handler({state:n,range:i,match:e,commands:c,chain:l,can:u,pasteEvent:o,dropEvent:s});d.push(f)})}),d.every(e=>e!==null)}var Kf=null,qf=e=>{var t;let n=new ClipboardEvent(`paste`,{clipboardData:new DataTransfer});return(t=n.clipboardData)==null||t.setData(`text/html`,e),n};function Jf(e){let{editor:t,rules:n}=e,r=null,i=!1,a=!1,o=typeof ClipboardEvent<`u`?new ClipboardEvent(`paste`):null,s;try{s=typeof DragEvent<`u`?new DragEvent(`drop`):null}catch{s=null}let l=({state:e,from:n,to:r,rule:i,pasteEvt:a})=>{let c=e.tr,l=Bc({state:e,transaction:c});if(Gf({editor:t,state:l,from:Math.max(n-1,0),to:r.b-1,rule:i,pasteEvent:a,dropEvent:s})&&c.steps.length){try{s=typeof DragEvent<`u`?new DragEvent(`drop`):null}catch{s=null}return o=typeof ClipboardEvent<`u`?new ClipboardEvent(`paste`):null,c}};return t.on(`destroy`,()=>{Kf===t&&(Kf=null)}),n.map(e=>new M({view(e){let n=n=>{r=e.dom.parentElement?.contains(n.target)?e.dom.parentElement:null,r&&(Kf=t)},i=()=>{Kf&&=null};return window.addEventListener(`dragstart`,n),window.addEventListener(`dragend`,i),{destroy(){window.removeEventListener(`dragstart`,n),window.removeEventListener(`dragend`,i)}}},props:{handleDOMEvents:{drop:(e,t)=>{if(a=r===e.dom.parentElement,s=t,!a){let e=Kf;e?.isEditable&&setTimeout(()=>{if(e.isDestroyed)return;let t=e.state.selection;t&&e.commands.deleteRange({from:t.from,to:t.to})},10)}return!1},paste:(e,t)=>{let n=t.clipboardData?.getData(`text/html`);return o=t,i=!!n?.includes(`data-pm-slice`),!1}}},appendTransaction:(t,n,r)=>{let s=t[0],u=s.getMeta(`uiEvent`)===`paste`&&!i,d=s.getMeta(`uiEvent`)===`drop`&&!a,f=s.getMeta(`applyPasteRules`),p=!!f;if(!u&&!d&&!p)return;if(p){let{text:t}=f;t=typeof t==`string`?t:uu(c.from(t),r.schema);let{from:n}=f,i=n+t.length,a=qf(t);return l({rule:e,state:r,from:n,to:{b:i},pasteEvt:a})}let m=n.doc.content.findDiffStart(r.doc.content),h=n.doc.content.findDiffEnd(r.doc.content);if(xf(m)&&h&&m!==h.b)return l({rule:e,state:r,from:m,to:h,pasteEvt:o})}}))}var Yf=class{constructor(e,t){this.splittableMarks=[],this.nonClearableMarks=[],this.decorationManager=null,this.editor=t,this.baseExtensions=e,this.extensions=Nu(e),this.hasSchemaSpec=t.options.schemaSpec!==void 0,this.schema=ju(this.extensions,t,t.options.schemaSpec),this.setupExtensions()}get commands(){return this.extensions.reduce((e,t)=>{let n=B(t,`addCommands`,{name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:this.editor,type:Ku(t.name,this.schema)});return n?{...e,...n()}:e},{})}get plugins(){let{editor:e}=this,t=Mu([...this.extensions].reverse()).flatMap(t=>{let n={name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:e,type:Ku(t.name,this.schema)},r=[],i=B(t,`addKeyboardShortcuts`,n),a={};if(t.type===`mark`&&B(t,`exitable`,n)&&(a.ArrowRight=()=>Hf.handleExit({editor:e,mark:t})),i){let t=Object.fromEntries(Object.entries(i()).map(([t,n])=>[t,()=>n({editor:e})]));a={...a,...t}}let o=pc(a);r.push(o);let s=B(t,`addInputRules`,n);if($u(t,e.options.enableInputRules)&&s){let t=s();if(t&&t.length){let n=Bf({editor:e,rules:t}),i=Array.isArray(n)?n:[n];r.push(...i)}}let c=B(t,`addPasteRules`,n);if($u(t,e.options.enablePasteRules)&&c){let t=c();if(t&&t.length){let n=Jf({editor:e,rules:t});r.push(...n)}}let l=B(t,`addProseMirrorPlugins`,n);if(l){let e=l();r.push(...e)}return r}),n=this.createDecorationPlugin();return n&&t.push(n),t}createDecorationPlugin(){var e;let{editor:t}=this;(e=this.decorationManager)==null||e.destroy();let n=[];return this.extensions.forEach(e=>{let r=B(e,`addDecorations`,{name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:t,type:Ku(e.name,this.schema)});r&&n.push({name:e.name,addDecorations:r})}),this.decorationManager=new gf({editor:t,entries:n}),this.decorationManager.plugin}get attributes(){let e=bu(this.extensions);return this.hasSchemaSpec?du(e,this.schema):e}get nodeViews(){let{editor:e}=this,{nodeExtensions:t}=yu(this.extensions);return Object.fromEntries(t.filter(e=>!!B(e,`addNodeView`)).map(t=>{let n=this.attributes.filter(e=>e.type===t.name),r=B(t,`addNodeView`,{name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:e,type:z(t.name,this.schema)});if(!r)return[];let i=r();return i?[t.name,(r,a,o,s,c)=>{let l=Tu(r,n);return i({node:r,view:a,getPos:o,decorations:s,innerDecorations:c,editor:e,extension:t,HTMLAttributes:l})}]:[]}))}dispatchTransaction(e){let{editor:t}=this;return Mu([...this.extensions].reverse()).reduceRight((e,n)=>{let r={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:Ku(n.name,this.schema)},i=B(n,`dispatchTransaction`,r);return i?t=>{i.call(r,{transaction:t,next:e})}:e},e)}transformPastedHTML(e){let{editor:t}=this;return Mu([...this.extensions]).reduce((e,n)=>{let r={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:Ku(n.name,this.schema)},i=B(n,`transformPastedHTML`,r);return i?(t,n)=>{let a=e(t,n);return i.call(r,a)}:e},e||(e=>e))}get markViews(){let{editor:e}=this,{markExtensions:t}=yu(this.extensions);return Object.fromEntries(t.filter(e=>!!B(e,`addMarkView`)).map(t=>{let n=this.attributes.filter(e=>e.type===t.name),r=B(t,`addMarkView`,{name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:e,type:cl(t.name,this.schema)});return r?[t.name,(i,a,o)=>{let s=Tu(i,n);return r()({mark:i,view:a,inline:o,editor:e,extension:t,HTMLAttributes:s,updateAttributes:t=>{Nf(i,e,t)}})}]:[]}))}destroy(){var e;(e=this.decorationManager)==null||e.destroy(),this.extensions.forEach(e=>{let t=e;for(;t.parent;){let e=t.parent;e.child===t&&(e.child=null),t=e}}),this.extensions=[],this.baseExtensions=[],this.decorationManager=null,this.schema=null,this.editor=null}setupExtensions(){let e=this.extensions;this.editor.extensionStorage=Object.fromEntries(e.map(e=>[e.name,e.storage])),e.forEach(e=>{let t={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:Ku(e.name,this.schema)};e.type===`mark`&&((V(B(e,`keepOnSplit`,t))??!0)&&this.splittableMarks.push(e.name),(V(B(e,`clearable`,t))??!0)||this.nonClearableMarks.push(e.name));let n=B(e,`onBeforeCreate`,t),r=B(e,`onCreate`,t),i=B(e,`onUpdate`,t),a=B(e,`onSelectionUpdate`,t),o=B(e,`onTransaction`,t),s=B(e,`onFocus`,t),c=B(e,`onBlur`,t),l=B(e,`onDestroy`,t);n&&this.editor.on(`beforeCreate`,n),r&&this.editor.on(`create`,r),i&&this.editor.on(`update`,i),a&&this.editor.on(`selectionUpdate`,a),o&&this.editor.on(`transaction`,o),s&&this.editor.on(`focus`,s),c&&this.editor.on(`blur`,c),l&&this.editor.on(`destroy`,l)})}};Yf.resolve=Nu,Yf.sort=Mu,Yf.flatten=lu;var U=class e extends Vf{constructor(...e){super(...e),this.type=`extension`}static create(t={}){let n=typeof t==`function`?t():t;return new e(n)}configure(e){return super.configure(e)}extend(e){let t=typeof e==`function`?e():e;return super.extend(t)}},Xf=U.create({name:`clipboardTextSerializer`,addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new M({key:new N(`clipboardTextSerializer`),props:{clipboardTextSerializer:()=>{let{editor:e}=this,{state:t,schema:n}=e,{doc:r,selection:i}=t,a=Lu(n),{blockSeparator:o}=this.options,s={...o===void 0?{}:{blockSeparator:o},textSerializers:a};return[...i.ranges].sort((e,t)=>e.$from.pos-t.$from.pos).map(({$from:e,$to:t})=>Fu(r,{from:e.pos,to:t.pos},s)).join(o??` +`);l+=e.type===`paragraph`?`\n\n${o}`:`\n${o}`}}),l}function Pf(e,t){let n={...e};return Tf(e)&&Tf(t)&&Object.keys(t).forEach(r=>{Tf(t[r])&&Tf(e[r])?n[r]=Pf(e[r],t[r]):n[r]=t[r]}),n}function Ff(e,t,n={}){let{state:r}=t,{doc:i,tr:a}=r,o=e;i.descendants((t,r)=>{let i=a.mapping.map(r),s=a.mapping.map(r)+t.nodeSize,c=null;if(t.marks.forEach(e=>{if(e!==o)return!1;c=e}),!c)return;let l=!1;if(Object.keys(n).forEach(e=>{n[e]!==c.attrs[e]&&(l=!0)}),l){let t=e.type.create({...e.attrs,...n});a.removeMark(i,s,e.type),a.addMark(i,s,t)}}),a.docChanged&&t.view.dispatch(a)}var If=class{constructor(e){this.find=e.find,this.handler=e.handler,this.undoable=e.undoable??!0}},Lf=(e,t)=>{if(al(t))return t.exec(e);let n=t(e);if(!n)return null;let r=[n.text];return r.index=n.index,r.input=e,r.data=n.data,n.replaceWith&&(n.text.includes(n.replaceWith)||console.warn(`[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".`),r.push(n.replaceWith)),r};function Rf(e){let{editor:t,from:n,to:r,text:i,insertText:a}=e;if(!a)return{inputTransaction:null,tr:t.view.state.tr};let o=t.view.state.tr.insertText(i,n,r);return{inputTransaction:o,tr:Fn.create({doc:o.doc,selection:o.selection,storedMarks:o.storedMarks}).tr}}function zf(e){let{editor:t,from:n,to:r,text:i,rule:a,match:o,plugin:s,insertText:c}=e,{view:l}=t,{inputTransaction:u,tr:d}=Rf({editor:t,from:n,to:r,text:i,insertText:c}),f=u?n+i.length:r,p=Hc({state:l.state,transaction:d}),m={from:n-(o[0].length-i.length),to:f},{commands:h,chain:g,can:_}=new Uc({editor:t,state:p});return a.handler({state:p,range:m,match:o,commands:h,chain:g,can:_})===null||!d.steps.length?!1:(u&&(l.dispatch(u),!l.state.doc.eq(u.doc))||(Pc(d),d.setMeta(`inputRule`,!0),a.undoable&&d.setMeta(s,{transform:d,from:n,to:f,text:i}),l.dispatch(d)),!0)}function Bf(e,t,n){let r=t[0].length-n.length;if(r<=0)return!0;let i=e.parentOffset-r;return i>=0&&e.parent.textBetween(i,e.parentOffset)===t[0].slice(0,r)}function Vf(e){let{editor:t,from:n,to:r,text:i,rules:a,plugin:o,insertText:s}=e,{view:c}=t;if(c.composing)return!1;let l=c.state.doc.resolve(n);if(l.parent.type.spec.code||(l.nodeBefore||l.nodeAfter)?.marks.find(e=>e.type.spec.code))return!1;let u=Xu(l)+i;for(let e of a){let a=Lf(u,e.find);if(a&&Bf(l,a,i)&&zf({editor:t,from:n,to:r,text:i,rule:e,match:a,plugin:o,insertText:s}))return!0}return!1}function Hf(e){let{editor:t,rules:n}=e,r=new M({state:{init(){return null},apply(e,i,a){let o=e.getMeta(r);if(o)return o;let s=e.getMeta(`applyInputRules`);return s&&setTimeout(()=>{let{text:e}=s;e=typeof e==`string`?e:fu(c.from(e),a.schema);let{from:i}=s,o=i+e.length;Vf({editor:t,from:i,to:o,text:e,rules:n,plugin:r})}),e.selectionSet||e.docChanged?null:i}},props:{handleTextInput(e,i,a,o){return Vf({editor:t,from:i,to:a,text:o,rules:n,plugin:r,insertText:!0})},handleDOMEvents:{compositionend:e=>(setTimeout(()=>{let{$cursor:i}=e.state.selection;i&&Vf({editor:t,from:i.pos,to:i.pos,text:``,rules:n,plugin:r})}),!1)},handleKeyDown(e,i){if(i.key!==`Enter`)return!1;let{$cursor:a}=e.state.selection;return a?Vf({editor:t,from:a.pos,to:a.pos,text:` +`,rules:n,plugin:r}):!1}},isInputRules:!0});return r}var Uf=class{constructor(e={}){this.type=`extendable`,this.parent=null,this.child=null,this.name=``,this.config={name:this.name},this.config={...this.config,...e},this.name=this.config.name}get options(){return{...z(R(this,`addOptions`,{name:this.name}))}}get storage(){return{...z(R(this,`addStorage`,{name:this.name,options:this.options}))}}configure(e={}){let t=this.extend({...this.config,addOptions:()=>Pf(this.options,e)});return t.name=this.name,t.parent=this.parent,this.child=null,t}extend(e={}){let t=new this.constructor({...this.config,...e});return t.parent=this,this.child=t,t.name=`name`in e?e.name:t.parent.name,t}},Wf=class e extends Uf{constructor(...e){super(...e),this.type=`mark`}static create(t={}){let n=typeof t==`function`?t():t;return new e(n)}static handleExit({editor:e,mark:t}){let{tr:n}=e.state,r=e.state.selection.$from;if(r.pos===r.end()){let i=r.marks();if(!i.find(e=>e?.type.name===t.name))return!1;let a=i.find(e=>e?.type.name===t.name);return a&&n.removeStoredMark(a),n.insertText(` `,r.pos),e.view.dispatch(n),!0}return!1}configure(e){return super.configure(e)}extend(e){let t=typeof e==`function`?e():e;return super.extend(t)}},Gf=class{constructor(e){this.find=e.find,this.handler=e.handler}},Kf=(e,t,n)=>{if(al(t))return[...e.matchAll(t)];let r=t(e,n);return r?r.map(t=>{let n=[t.text];return n.index=t.index,n.input=e,n.data=t.data,t.replaceWith&&(t.text.includes(t.replaceWith)||console.warn(`[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".`),n.push(t.replaceWith)),n}):[]};function qf(e){let{editor:t,state:n,from:r,to:i,rule:a,pasteEvent:o,dropEvent:s}=e,{commands:c,chain:l,can:u}=new Uc({editor:t,state:n}),d=[];return n.doc.nodesBetween(r,i,(e,t)=>{var f;if((f=e.type)!=null&&(f=f.spec)!=null&&f.code||!(e.isText||e.isTextblock||e.isInline))return;let p=e.content?.size??e.nodeSize??0,m=Math.max(r,t),h=Math.min(i,t+p);m>=h||Kf(e.isText?e.text||``:e.textBetween(m-t,h-t,void 0,``),a.find,o).forEach(e=>{if(e.index===void 0)return;let t=m+e.index+1,r=t+e[0].length,i={from:n.tr.mapping.map(t),to:n.tr.mapping.map(r)},f=a.handler({state:n,range:i,match:e,commands:c,chain:l,can:u,pasteEvent:o,dropEvent:s});d.push(f)})}),d.every(e=>e!==null)}var Jf=null,Yf=e=>{var t;let n=new ClipboardEvent(`paste`,{clipboardData:new DataTransfer});return(t=n.clipboardData)==null||t.setData(`text/html`,e),n};function Xf(e){let{editor:t,rules:n}=e,r=null,i=!1,a=!1,o=typeof ClipboardEvent<`u`?new ClipboardEvent(`paste`):null,s;try{s=typeof DragEvent<`u`?new DragEvent(`drop`):null}catch{s=null}let l=({state:e,from:n,to:r,rule:i,pasteEvt:a})=>{let c=e.tr,l=Hc({state:e,transaction:c});if(qf({editor:t,state:l,from:Math.max(n-1,0),to:r.b-1,rule:i,pasteEvent:a,dropEvent:s})&&c.steps.length){try{s=typeof DragEvent<`u`?new DragEvent(`drop`):null}catch{s=null}return o=typeof ClipboardEvent<`u`?new ClipboardEvent(`paste`):null,c}};return t.on(`destroy`,()=>{Jf===t&&(Jf=null)}),n.map(e=>new M({view(e){let n=n=>{r=e.dom.parentElement?.contains(n.target)?e.dom.parentElement:null,r&&(Jf=t)},i=()=>{Jf&&=null};return window.addEventListener(`dragstart`,n),window.addEventListener(`dragend`,i),{destroy(){window.removeEventListener(`dragstart`,n),window.removeEventListener(`dragend`,i)}}},props:{handleDOMEvents:{drop:(e,t)=>{if(a=r===e.dom.parentElement,s=t,!a){let e=Jf;e?.isEditable&&setTimeout(()=>{if(e.isDestroyed)return;let t=e.state.selection;t&&e.commands.deleteRange({from:t.from,to:t.to})},10)}return!1},paste:(e,t)=>{let n=t.clipboardData?.getData(`text/html`);return o=t,i=!!n?.includes(`data-pm-slice`),!1}}},appendTransaction:(t,n,r)=>{let s=t[0],u=s.getMeta(`uiEvent`)===`paste`&&!i,d=s.getMeta(`uiEvent`)===`drop`&&!a,f=s.getMeta(`applyPasteRules`),p=!!f;if(!u&&!d&&!p)return;if(p){let{text:t}=f;t=typeof t==`string`?t:fu(c.from(t),r.schema);let{from:n}=f,i=n+t.length,a=Yf(t);return l({rule:e,state:r,from:n,to:{b:i},pasteEvt:a})}let m=n.doc.content.findDiffStart(r.doc.content),h=n.doc.content.findDiffEnd(r.doc.content);if(Cf(m)&&h&&m!==h.b)return l({rule:e,state:r,from:m,to:h,pasteEvt:o})}}))}var Zf=class{constructor(e,t){this.splittableMarks=[],this.nonClearableMarks=[],this.decorationManager=null,this.editor=t,this.baseExtensions=e,this.extensions=Fu(e),this.hasSchemaSpec=t.options.schemaSpec!==void 0,this.schema=Nu(this.extensions,t,t.options.schemaSpec),this.setupExtensions()}get commands(){return this.extensions.reduce((e,t)=>{let n=R(t,`addCommands`,{name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:this.editor,type:Ju(t.name,this.schema)});return n?{...e,...n()}:e},{})}get plugins(){let{editor:e}=this,t=Pu([...this.extensions].reverse()).flatMap(t=>{let n={name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:e,type:Ju(t.name,this.schema)},r=[],i=R(t,`addKeyboardShortcuts`,n),a={};if(t.type===`mark`&&R(t,`exitable`,n)&&(a.ArrowRight=()=>Wf.handleExit({editor:e,mark:t})),i){let t=Object.fromEntries(Object.entries(i()).map(([t,n])=>[t,()=>n({editor:e})]));a={...a,...t}}let o=mc(a);r.push(o);let s=R(t,`addInputRules`,n);if(td(t,e.options.enableInputRules)&&s){let t=s();if(t&&t.length){let n=Hf({editor:e,rules:t}),i=Array.isArray(n)?n:[n];r.push(...i)}}let c=R(t,`addPasteRules`,n);if(td(t,e.options.enablePasteRules)&&c){let t=c();if(t&&t.length){let n=Xf({editor:e,rules:t});r.push(...n)}}let l=R(t,`addProseMirrorPlugins`,n);if(l){let e=l();r.push(...e)}return r}),n=this.createDecorationPlugin();return n&&t.push(n),t}createDecorationPlugin(){var e;let{editor:t}=this;(e=this.decorationManager)==null||e.destroy();let n=[];return this.extensions.forEach(e=>{let r=R(e,`addDecorations`,{name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:t,type:Ju(e.name,this.schema)});r&&n.push({name:e.name,addDecorations:r})}),this.decorationManager=new vf({editor:t,entries:n}),this.decorationManager.plugin}get attributes(){let e=Su(this.extensions);return this.hasSchemaSpec?pu(e,this.schema):e}get nodeViews(){let{editor:e}=this,{nodeExtensions:t}=xu(this.extensions);return Object.fromEntries(t.filter(e=>!!R(e,`addNodeView`)).map(t=>{let n=this.attributes.filter(e=>e.type===t.name),r=R(t,`addNodeView`,{name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:e,type:L(t.name,this.schema)});if(!r)return[];let i=r();return i?[t.name,(r,a,o,s,c)=>{let l=Du(r,n);return i({node:r,view:a,getPos:o,decorations:s,innerDecorations:c,editor:e,extension:t,HTMLAttributes:l})}]:[]}))}dispatchTransaction(e){let{editor:t}=this;return Pu([...this.extensions].reverse()).reduceRight((e,n)=>{let r={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:Ju(n.name,this.schema)},i=R(n,`dispatchTransaction`,r);return i?t=>{i.call(r,{transaction:t,next:e})}:e},e)}transformPastedHTML(e){let{editor:t}=this;return Pu([...this.extensions]).reduce((e,n)=>{let r={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:Ju(n.name,this.schema)},i=R(n,`transformPastedHTML`,r);return i?(t,n)=>{let a=e(t,n);return i.call(r,a)}:e},e||(e=>e))}get markViews(){let{editor:e}=this,{markExtensions:t}=xu(this.extensions);return Object.fromEntries(t.filter(e=>!!R(e,`addMarkView`)).map(t=>{let n=this.attributes.filter(e=>e.type===t.name),r=R(t,`addMarkView`,{name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:e,type:ul(t.name,this.schema)});return r?[t.name,(i,a,o)=>{let s=Du(i,n);return r()({mark:i,view:a,inline:o,editor:e,extension:t,HTMLAttributes:s,updateAttributes:t=>{Ff(i,e,t)}})}]:[]}))}destroy(){var e;(e=this.decorationManager)==null||e.destroy(),this.extensions.forEach(e=>{let t=e;for(;t.parent;){let e=t.parent;e.child===t&&(e.child=null),t=e}}),this.extensions=[],this.baseExtensions=[],this.decorationManager=null,this.schema=null,this.editor=null}setupExtensions(){let e=this.extensions;this.editor.extensionStorage=Object.fromEntries(e.map(e=>[e.name,e.storage])),e.forEach(e=>{let t={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:Ju(e.name,this.schema)};e.type===`mark`&&((z(R(e,`keepOnSplit`,t))??!0)&&this.splittableMarks.push(e.name),(z(R(e,`clearable`,t))??!0)||this.nonClearableMarks.push(e.name));let n=R(e,`onBeforeCreate`,t),r=R(e,`onCreate`,t),i=R(e,`onUpdate`,t),a=R(e,`onSelectionUpdate`,t),o=R(e,`onTransaction`,t),s=R(e,`onFocus`,t),c=R(e,`onBlur`,t),l=R(e,`onDestroy`,t);n&&this.editor.on(`beforeCreate`,n),r&&this.editor.on(`create`,r),i&&this.editor.on(`update`,i),a&&this.editor.on(`selectionUpdate`,a),o&&this.editor.on(`transaction`,o),s&&this.editor.on(`focus`,s),c&&this.editor.on(`blur`,c),l&&this.editor.on(`destroy`,l)})}};Zf.resolve=Fu,Zf.sort=Pu,Zf.flatten=du;var V=class e extends Uf{constructor(...e){super(...e),this.type=`extension`}static create(t={}){let n=typeof t==`function`?t():t;return new e(n)}configure(e){return super.configure(e)}extend(e){let t=typeof e==`function`?e():e;return super.extend(t)}},Qf=V.create({name:`clipboardTextSerializer`,addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new M({key:new N(`clipboardTextSerializer`),props:{clipboardTextSerializer:()=>{let{editor:e}=this,{state:t,schema:n}=e,{doc:r,selection:i}=t,a=zu(n),{blockSeparator:o}=this.options,s={...o===void 0?{}:{blockSeparator:o},textSerializers:a};return[...i.ranges].sort((e,t)=>e.$from.pos-t.$from.pos).map(({$from:e,$to:t})=>Lu(r,{from:e.pos,to:t.pos},s)).join(o??` -`)}}})]}}),Zf=U.create({name:`commands`,addCommands(){return{...Gd}}}),Qf=U.create({name:`delete`,onUpdate({transaction:e,appendedTransactions:t}){var n;let r=()=>{var n,r;if(((n=this.editor.options.coreExtensionOptions)==null||(n=n.delete)==null||(r=n.filterTransaction)==null?void 0:r.call(n,e))??e.getMeta(`y-sync$`))return;let i=au(e.before,[e,...t]);Hu(i).forEach(t=>{i.mapping.mapResult(t.oldRange.from).deletedAfter&&i.mapping.mapResult(t.oldRange.to).deletedBefore&&i.before.nodesBetween(t.oldRange.from,t.oldRange.to,(n,r)=>{let a=r+n.nodeSize-2,o=t.oldRange.from<=r&&a<=t.oldRange.to;this.editor.emit(`delete`,{type:`node`,node:n,from:r,to:a,newFrom:i.mapping.map(r),newTo:i.mapping.map(a),deletedRange:t.oldRange,newRange:t.newRange,partial:!o,editor:this.editor,transaction:e,combinedTransform:i})})});let a=i.mapping;i.steps.forEach((t,n)=>{if(t instanceof _t){let r=a.slice(n).map(t.from,-1),o=a.slice(n).map(t.to),s=a.invert().map(r,-1),c=a.invert().map(o),l=r>0&&i.doc.nodeAt(r-1)?.marks.some(e=>e.eq(t.mark)),u=i.doc.nodeAt(o)?.marks.some(e=>e.eq(t.mark));this.editor.emit(`delete`,{type:`mark`,mark:t.mark,from:t.from,to:t.to,deletedRange:{from:s,to:c},newRange:{from:r,to:o},partial:!!(u||l),editor:this.editor,transaction:e,combinedTransform:i})}})};((n=this.editor.options.coreExtensionOptions)==null||(n=n.delete)==null?void 0:n.async)??!0?setTimeout(r,0):r()}}),$f=U.create({name:`drop`,addProseMirrorPlugins(){return[new M({key:new N(`tiptapDrop`),props:{handleDrop:(e,t,n,r)=>{this.editor.emit(`drop`,{editor:this.editor,event:t,slice:n,moved:r})}}})]}}),ep=U.create({name:`editable`,addProseMirrorPlugins(){return[new M({key:new N(`editable`),props:{editable:()=>this.editor.options.editable}})]}}),tp=new N(`focusEvents`),np=U.create({name:`focusEvents`,addProseMirrorPlugins(){let{editor:e}=this;return[new M({key:tp,props:{handleDOMEvents:{focus:(t,n)=>{e.isFocused=!0;let r=e.state.tr.setMeta(`focus`,{event:n}).setMeta(`addToHistory`,!1);return t.dispatch(r),!1},blur:(t,n)=>{e.isFocused=!1;let r=e.state.tr.setMeta(`blur`,{event:n}).setMeta(`addToHistory`,!1);return t.dispatch(r),!1}}}})]}}),rp=U.create({name:`keymap`,addKeyboardShortcuts(){let e=()=>this.editor.commands.first(({commands:e})=>[()=>e.undoInputRule(),()=>e.command(({tr:t})=>{let{selection:n,doc:r}=t,{empty:i,$anchor:a}=n,{pos:o,parent:s}=a,c=a.parent.isTextblock&&o>0?t.doc.resolve(o-1):a,l=c.parent.type.spec.isolating,u=a.pos-a.parentOffset,d=l&&c.parent.childCount===1?u===a.pos:k.atStart(r).from===o;return!i||!s.type.isTextblock||s.textContent.length||!d||d&&a.parent.type.name===`paragraph`?!1:e.clearNodes()}),()=>e.deleteSelection(),()=>e.joinBackward(),()=>e.selectNodeBackward()]),t=()=>this.editor.commands.first(({commands:e})=>[()=>e.deleteSelection(),()=>e.deleteCurrentNode(),()=>e.joinForward(),()=>e.selectNodeForward()]),n={Enter:()=>this.editor.commands.first(({commands:e})=>[()=>e.newlineInCode(),()=>e.createParagraphNear(),()=>e.liftEmptyBlock(),()=>e.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:e,"Mod-Backspace":e,"Shift-Backspace":e,Delete:t,"Mod-Delete":t,"Mod-a":()=>this.editor.commands.selectAll()},r={...n},i={...n,"Ctrl-h":e,"Alt-Backspace":e,"Ctrl-d":t,"Ctrl-Alt-Backspace":t,"Alt-Delete":t,"Alt-d":t,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return hl()||Rl()?i:r},addProseMirrorPlugins(){return[new M({key:new N(`clearDocument`),appendTransaction:(e,t,n)=>{if(e.some(e=>e.getMeta(`composition`)))return;let r=e.some(e=>e.docChanged)&&!t.doc.eq(n.doc),i=e.some(e=>e.getMeta(`preventClearDocument`));if(!r||i)return;let{empty:a,from:o,to:s}=t.selection,c=k.atStart(t.doc).from,l=k.atEnd(t.doc).to;if(a||o!==c||s!==l||!td(n.doc))return;let u=n.tr,d=Bc({state:n,transaction:u}),{commands:f}=new Vc({editor:this.editor,state:d});if(f.clearNodes(),u.steps.length)return u}})]}}),ip=U.create({name:`paste`,addProseMirrorPlugins(){return[new M({key:new N(`tiptapPaste`),props:{handlePaste:(e,t,n)=>{this.editor.emit(`paste`,{editor:this.editor,event:t,slice:n})}}})]}}),ap=U.create({name:`tabindex`,addOptions(){return{value:void 0}},addProseMirrorPlugins(){return[new M({key:new N(`tabindex`),props:{attributes:()=>!this.editor.isEditable&&this.options.value===void 0?{}:{tabindex:this.options.value??`0`}}})]}}),op=U.create({name:`textDirection`,addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];let{nodeExtensions:e}=yu(this.extensions);return[{types:e.filter(e=>e.name!==`text`).map(e=>e.name),attributes:{dir:{default:this.options.direction,parseHTML:e=>{let t=e.getAttribute(`dir`);return t&&(t===`ltr`||t===`rtl`||t===`auto`)?t:this.options.direction},renderHTML:e=>e.dir?{dir:e.dir}:{}}}}]},addProseMirrorPlugins(){return[new M({key:new N(`textDirection`),props:{attributes:()=>{let e=this.options.direction;return e?{dir:e}:{}}}})]}}),sp=!1;function cp(e){if(sp)return;sp=!0;let t;try{let n=St.fromJSON(e,{from:0,to:0});if(!id(n))return;t=n.slice.content}catch{return}t instanceof c||console.warn(`[tiptap warn]: prosemirror-model is loaded more than once. Wrapping and splitting nodes will fail. Deduplicate it in your lock file, or alias it to a single copy in your bundler.`)}var lp=class e{get name(){return this.node.type.name}constructor(e,t,n=!1,r=null){this.currentNode=null,this.actualDepth=null,this.isBlock=n,this.resolvedPos=e,this.editor=t,this.currentNode=r}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){return this.actualDepth??this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let t=this.from,n=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can’t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}t=this.from+1,n=this.to-1}this.editor.commands.insertContentAt({from:t,to:n},e)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+ +!this.node.isText}get parent(){if(this.depth===0)return null;let t=this.resolvedPos.start(this.resolvedPos.depth-1),n=this.resolvedPos.doc.resolve(t);return new e(n,this.editor)}get before(){let t=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return t.depth!==this.depth&&(t=this.resolvedPos.doc.resolve(this.from-3)),new e(t,this.editor)}get after(){let t=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return t.depth!==this.depth&&(t=this.resolvedPos.doc.resolve(this.to+3)),new e(t,this.editor)}get children(){let t=[];return this.node.content.forEach((n,r)=>{let i=n.isBlock&&!n.isTextblock,a=n.isAtom&&!n.isText,o=n.isInline,s=this.pos+r+ +!a;if(s<0||s>this.resolvedPos.doc.nodeSize-2)return;let c=this.resolvedPos.doc.resolve(s);if(!i&&!o&&c.depth<=this.depth)return;let l=new e(c,this.editor,i,i||o?n:null);i&&(l.actualDepth=this.depth+1),t.push(l)}),t}get firstChild(){return this.children[0]||null}get lastChild(){let e=this.children;return e[e.length-1]||null}closest(e,t={}){let n=null,r=this.parent;for(;r&&!n;){if(r.node.type.name===e){if(Object.keys(t).length>0){let e=r.node.attrs,n=Object.keys(t);for(let r=0;r{n&&r.length>0||(a.node.type.name===e&&i.every(e=>t[e]===a.node.attrs[e])&&r.push(a),n&&r.length>0||(r=r.concat(a.querySelectorAll(e,t,n))))}),r}setAttribute(e){let{tr:t}=this.editor.state;t.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(t)}},up=`.ProseMirror { +`)}}})]}}),$f=V.create({name:`commands`,addCommands(){return{...qd}}}),ep=V.create({name:`delete`,onUpdate({transaction:e,appendedTransactions:t}){var n;let r=()=>{var n,r;if(((n=this.editor.options.coreExtensionOptions)==null||(n=n.delete)==null||(r=n.filterTransaction)==null?void 0:r.call(n,e))??e.getMeta(`y-sync$`))return;let i=su(e.before,[e,...t]);Wu(i).forEach(t=>{i.mapping.mapResult(t.oldRange.from).deletedAfter&&i.mapping.mapResult(t.oldRange.to).deletedBefore&&i.before.nodesBetween(t.oldRange.from,t.oldRange.to,(n,r)=>{let a=r+n.nodeSize-2,o=t.oldRange.from<=r&&a<=t.oldRange.to;this.editor.emit(`delete`,{type:`node`,node:n,from:r,to:a,newFrom:i.mapping.map(r),newTo:i.mapping.map(a),deletedRange:t.oldRange,newRange:t.newRange,partial:!o,editor:this.editor,transaction:e,combinedTransform:i})})});let a=i.mapping;i.steps.forEach((t,n)=>{if(t instanceof _t){let r=a.slice(n).map(t.from,-1),o=a.slice(n).map(t.to),s=a.invert().map(r,-1),c=a.invert().map(o),l=r>0&&i.doc.nodeAt(r-1)?.marks.some(e=>e.eq(t.mark)),u=i.doc.nodeAt(o)?.marks.some(e=>e.eq(t.mark));this.editor.emit(`delete`,{type:`mark`,mark:t.mark,from:t.from,to:t.to,deletedRange:{from:s,to:c},newRange:{from:r,to:o},partial:!!(u||l),editor:this.editor,transaction:e,combinedTransform:i})}})};((n=this.editor.options.coreExtensionOptions)==null||(n=n.delete)==null?void 0:n.async)??!0?setTimeout(r,0):r()}}),tp=V.create({name:`drop`,addProseMirrorPlugins(){return[new M({key:new N(`tiptapDrop`),props:{handleDrop:(e,t,n,r)=>{this.editor.emit(`drop`,{editor:this.editor,event:t,slice:n,moved:r})}}})]}}),np=V.create({name:`editable`,addProseMirrorPlugins(){return[new M({key:new N(`editable`),props:{editable:()=>this.editor.options.editable}})]}}),rp=new N(`focusEvents`),ip=V.create({name:`focusEvents`,addProseMirrorPlugins(){let{editor:e}=this;return[new M({key:rp,props:{handleDOMEvents:{focus:(t,n)=>{e.isFocused=!0;let r=e.state.tr.setMeta(`focus`,{event:n}).setMeta(`addToHistory`,!1);return t.dispatch(r),!1},blur:(t,n)=>{e.isFocused=!1;let r=e.state.tr.setMeta(`blur`,{event:n}).setMeta(`addToHistory`,!1);return t.dispatch(r),!1}}}})]}}),ap=V.create({name:`keymap`,addKeyboardShortcuts(){let e=()=>this.editor.commands.first(({commands:e})=>[()=>e.undoInputRule(),()=>e.command(({tr:t})=>{let{selection:n,doc:r}=t,{empty:i,$anchor:a}=n,{pos:o,parent:s}=a,c=a.parent.isTextblock&&o>0?t.doc.resolve(o-1):a,l=c.parent.type.spec.isolating,u=a.pos-a.parentOffset,d=l&&c.parent.childCount===1?u===a.pos:k.atStart(r).from===o;return!i||!s.type.isTextblock||s.textContent.length||!d||d&&a.parent.type.name===`paragraph`?!1:e.clearNodes()}),()=>e.deleteSelection(),()=>e.joinBackward(),()=>e.selectNodeBackward()]),t=()=>this.editor.commands.first(({commands:e})=>[()=>e.deleteSelection(),()=>e.deleteCurrentNode(),()=>e.joinForward(),()=>e.selectNodeForward()]),n={Enter:()=>this.editor.commands.first(({commands:e})=>[()=>e.newlineInCode(),()=>e.createParagraphNear(),()=>e.liftEmptyBlock(),()=>e.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:e,"Mod-Backspace":e,"Shift-Backspace":e,Delete:t,"Mod-Delete":t,"Mod-a":()=>this.editor.commands.selectAll()},r={...n},i={...n,"Ctrl-h":e,"Alt-Backspace":e,"Ctrl-d":t,"Ctrl-Alt-Backspace":t,"Alt-Delete":t,"Alt-d":t,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return _l()||Bl()?i:r},addProseMirrorPlugins(){return[new M({key:new N(`clearDocument`),appendTransaction:(e,t,n)=>{if(e.some(e=>e.getMeta(`composition`)))return;let r=e.some(e=>e.docChanged)&&!t.doc.eq(n.doc),i=e.some(e=>e.getMeta(`preventClearDocument`));if(!r||i)return;let{empty:a,from:o,to:s}=t.selection,c=k.atStart(t.doc).from,l=k.atEnd(t.doc).to;if(a||o!==c||s!==l||!rd(n.doc))return;let u=n.tr,d=Hc({state:n,transaction:u}),{commands:f}=new Uc({editor:this.editor,state:d});if(f.clearNodes(),u.steps.length)return u}})]}}),op=V.create({name:`paste`,addProseMirrorPlugins(){return[new M({key:new N(`tiptapPaste`),props:{handlePaste:(e,t,n)=>{this.editor.emit(`paste`,{editor:this.editor,event:t,slice:n})}}})]}}),sp=V.create({name:`tabindex`,addOptions(){return{value:void 0}},addProseMirrorPlugins(){return[new M({key:new N(`tabindex`),props:{attributes:()=>!this.editor.isEditable&&this.options.value===void 0?{}:{tabindex:this.options.value??`0`}}})]}}),cp=V.create({name:`textDirection`,addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];let{nodeExtensions:e}=xu(this.extensions);return[{types:e.filter(e=>e.name!==`text`).map(e=>e.name),attributes:{dir:{default:this.options.direction,parseHTML:e=>{let t=e.getAttribute(`dir`);return t&&(t===`ltr`||t===`rtl`||t===`auto`)?t:this.options.direction},renderHTML:e=>e.dir?{dir:e.dir}:{}}}}]},addProseMirrorPlugins(){return[new M({key:new N(`textDirection`),props:{attributes:()=>{let e=this.options.direction;return e?{dir:e}:{}}}})]}}),lp=!1;function up(e){if(lp)return;lp=!0;let t;try{let n=St.fromJSON(e,{from:0,to:0});if(!od(n))return;t=n.slice.content}catch{return}t instanceof c||console.warn(`[tiptap warn]: prosemirror-model is loaded more than once. Wrapping and splitting nodes will fail. Deduplicate it in your lock file, or alias it to a single copy in your bundler.`)}var dp=class e{get name(){return this.node.type.name}constructor(e,t,n=!1,r=null){this.currentNode=null,this.actualDepth=null,this.isBlock=n,this.resolvedPos=e,this.editor=t,this.currentNode=r}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){return this.actualDepth??this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let t=this.from,n=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can’t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}t=this.from+1,n=this.to-1}this.editor.commands.insertContentAt({from:t,to:n},e)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+ +!this.node.isText}get parent(){if(this.depth===0)return null;let t=this.resolvedPos.start(this.resolvedPos.depth-1),n=this.resolvedPos.doc.resolve(t);return new e(n,this.editor)}get before(){let t=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return t.depth!==this.depth&&(t=this.resolvedPos.doc.resolve(this.from-3)),new e(t,this.editor)}get after(){let t=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return t.depth!==this.depth&&(t=this.resolvedPos.doc.resolve(this.to+3)),new e(t,this.editor)}get children(){let t=[];return this.node.content.forEach((n,r)=>{let i=n.isBlock&&!n.isTextblock,a=n.isAtom&&!n.isText,o=n.isInline,s=this.pos+r+ +!a;if(s<0||s>this.resolvedPos.doc.nodeSize-2)return;let c=this.resolvedPos.doc.resolve(s);if(!i&&!o&&c.depth<=this.depth)return;let l=new e(c,this.editor,i,i||o?n:null);i&&(l.actualDepth=this.depth+1),t.push(l)}),t}get firstChild(){return this.children[0]||null}get lastChild(){let e=this.children;return e[e.length-1]||null}closest(e,t={}){let n=null,r=this.parent;for(;r&&!n;){if(r.node.type.name===e){if(Object.keys(t).length>0){let e=r.node.attrs,n=Object.keys(t);for(let r=0;r{n&&r.length>0||(a.node.type.name===e&&i.every(e=>t[e]===a.node.attrs[e])&&r.push(a),n&&r.length>0||(r=r.concat(a.querySelectorAll(e,t,n))))}),r}setAttribute(e){let{tr:t}=this.editor.state;t.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(t)}},fp=`.ProseMirror { position: relative; } @@ -91,18 +91,18 @@ img.ProseMirror-separator { .ProseMirror-focused .ProseMirror-gapcursor { display: block; -}`,dp=class extends Yd{constructor(e={}){super(),this.css=null,this.className=`tiptap`,this.editorView=null,this.isFocused=!1,this.destroyed=!1,this.isInitialized=!1,this.extensionStorage={},this.instanceId=Math.random().toString(36).slice(2,9),this.hasWarnedStaleDecorationRead=!1,this.options={element:typeof document<`u`?document.createElement(`div`):null,content:``,injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,textDirection:void 0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,emitContentError:!1,onBeforeCreate:()=>null,onCreate:()=>null,onMount:()=>null,onUnmount:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:e})=>{throw e},onPaste:()=>null,onDrop:()=>null,onDelete:()=>null,enableExtensionDispatchTransaction:!0},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.utils={getUpdatedPosition:od,createMappablePosition:sd},this.setOptions(e),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on(`beforeCreate`,this.options.onBeforeCreate),this.emit(`beforeCreate`,{editor:this}),this.on(`mount`,this.options.onMount),this.on(`unmount`,this.options.onUnmount),this.on(`contentError`,this.options.onContentError),this.on(`create`,this.options.onCreate),this.on(`update`,this.options.onUpdate),this.on(`selectionUpdate`,this.options.onSelectionUpdate),this.on(`transaction`,this.options.onTransaction),this.on(`focus`,this.options.onFocus),this.on(`blur`,this.options.onBlur),this.on(`destroy`,this.options.onDestroy),this.on(`drop`,({event:e,slice:t,moved:n})=>this.options.onDrop(e,t,n)),this.on(`paste`,({event:e,slice:t})=>this.options.onPaste(e,t)),this.on(`delete`,this.options.onDelete);let t=this.createDoc();if(!this.editorState){let e=pl(t,this.options.autofocus);this.editorState=Fn.create({doc:t,schema:this.schema,selection:e||void 0})}cp(this.schema),this.options.element&&this.mount(this.options.element)}mount(e){if(typeof document>`u`)throw Error(`[tiptap error]: The editor cannot be mounted because there is no 'document' defined in this environment.`);this.createView(e),this.emit(`mount`,{editor:this}),this.css&&!document.head.contains(this.css)&&document.head.appendChild(this.css),window.setTimeout(()=>{this.isDestroyed||(this.options.autofocus!==!1&&this.options.autofocus!==null&&this.commands.focus(this.options.autofocus),this.emit(`create`,{editor:this}),this.isInitialized=!0)},0)}unmount(){if(this.editorView){this.editorState=this.editorView.state;let e=this.editorView.dom;e?.editor&&delete e.editor,this.editorView.destroy()}if(this.editorView=null,this.isInitialized=!1,this.css&&!document.querySelectorAll(`.${this.className}`).length)try{typeof this.css.remove==`function`?this.css.remove():this.css.parentNode&&this.css.parentNode.removeChild(this.css)}catch(e){console.warn(`Failed to remove CSS element:`,e)}this.css=null,this.emit(`unmount`,{editor:this})}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager?this.commandManager.chain():Vc.createFakeChain()}can(){return this.commandManager?this.commandManager.can():Vc.createFallbackCan()}injectCSS(){this.options.injectCSS&&typeof document<`u`&&(this.css=vf(up,this.options.injectNonce))}setOptions(e={}){this.options={...this.options,...e},this.editorView&&this.state&&!this.isDestroyed&&(this.options.editorProps&&this.view.setProps({...this.options.editorProps,attributes:this.getEditorViewAttributes()}),this.view.updateState(this.state))}setEditable(e,t=!0){this.setOptions({editable:e}),t&&this.emit(`update`,{editor:this,transaction:this.state.tr,appendedTransactions:[]})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get view(){return this.editorView?this.editorView:new Proxy({state:this.editorState,updateState:e=>{this.editorState=e},dispatch:e=>{this.dispatchTransaction(e)},composing:!1,dragging:null,editable:!0,isDestroyed:!1},{get:(e,t)=>{if(this.editorView)return this.editorView[t];if(t===`state`)return this.editorState;if(t in e)return Reflect.get(e,t);throw Error(`[tiptap error]: The editor view is not available. Cannot access view['${t}']. The editor may not be mounted yet.`)}})}get state(){return Xd&&!this.hasWarnedStaleDecorationRead&&Jd(this)&&(this.hasWarnedStaleDecorationRead=!0,console.warn("[tiptap warn]: `editor.state` was read while decoration `create()` was running. It returns the pre-transaction document. Use the `state` argument passed to `create()` instead. Helpers like `editor.isActive()` read `editor.state` too, so pass `state` to their standalone versions instead of calling them on the editor.")),this.editorView&&(this.editorState=this.view.state),this.editorState}registerPlugin(e,t){let n=xu(t)?t(e,[...this.state.plugins]):[...this.state.plugins,e],r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}unregisterPlugin(e){if(this.isDestroyed)return;let t=this.state.plugins,n=t;if([].concat(e).forEach(e=>{let t=typeof e==`string`?`${e}$`:e.key;n=n.filter(e=>!e.key.startsWith(t))}),t.length===n.length)return;let r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}createExtensionManager(){var e,t;let n=[...this.options.enableCoreExtensions?[ep,Xf.configure({blockSeparator:(e=this.options.coreExtensionOptions)==null||(e=e.clipboardTextSerializer)==null?void 0:e.blockSeparator}),Zf,np,rp,ap.configure({value:(t=this.options.coreExtensionOptions)==null||(t=t.tabindex)==null?void 0:t.value}),$f,ip,Qf,op.configure({direction:this.options.textDirection})].filter(e=>typeof this.options.enableCoreExtensions!=`object`||this.options.enableCoreExtensions[e.name]!==!1):[],...this.options.extensions].filter(e=>[`extension`,`node`,`mark`].includes(e?.type));this.extensionManager=new Yf(n,this)}createCommandManager(){this.commandManager=new Vc({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let e;try{e=nu(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(e){if(!(e instanceof Error)||![`[tiptap error]: Invalid JSON content`,`[tiptap error]: Invalid HTML content`].includes(e.message))throw e;let t=nu(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1});return this.editorState=Fn.create({doc:t,schema:this.schema,selection:pl(t,this.options.autofocus)||void 0}),this.emit(`contentError`,{editor:this,error:e,disableCollaboration:()=>{`collaboration`in this.storage&&typeof this.storage.collaboration==`object`&&this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter(e=>e.name!==`collaboration`),this.createExtensionManager()}}),this.editorState.doc}return e}getEditorViewAttributes(){let e=this.options.editorProps?.attributes;return xu(e)?t=>({role:`textbox`,...e(t)}):{role:`textbox`,...e}}createView(e){let{editorProps:t,enableExtensionDispatchTransaction:n}=this.options,r=t.dispatchTransaction||this.dispatchTransaction.bind(this),i=n?this.extensionManager.dispatchTransaction(r):r,a=t.transformPastedHTML,o=this.extensionManager.transformPastedHTML(a);this.editorView=new qs(e,{...t,attributes:this.getEditorViewAttributes(),dispatchTransaction:i,transformPastedHTML:o,state:this.editorState,markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews});let s=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(s),this.prependClass(),this.injectCSS();let c=this.view.dom;c.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`${this.className} ${this.view.dom.className}`}captureTransaction(e){this.isCapturingTransaction=!0,e(),this.isCapturingTransaction=!1;let t=this.capturedTransaction;return this.capturedTransaction=null,t}dispatchTransaction(e){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=e;return}e.steps.forEach(e=>this.capturedTransaction?.step(e));return}let{state:t,transactions:n}=this.state.applyTransaction(e),r=!this.state.selection.eq(t.selection),i=n.includes(e),a=this.state;if(this.emit(`beforeTransaction`,{editor:this,transaction:e,nextState:t}),!i)return;this.view.updateState(t),this.emit(`transaction`,{editor:this,transaction:e,appendedTransactions:n.slice(1)}),r&&this.emit(`selectionUpdate`,{editor:this,transaction:e});let o=n.findLast(e=>e.getMeta(`focus`)||e.getMeta(`blur`)),s=o?.getMeta(`focus`),c=o?.getMeta(`blur`);s&&this.emit(`focus`,{editor:this,event:s.event,transaction:o}),c&&this.emit(`blur`,{editor:this,event:c.event,transaction:o}),e.getMeta(`preventUpdate`)||!n.some(e=>e.docChanged)||a.doc.eq(t.doc)||this.emit(`update`,{editor:this,transaction:e,appendedTransactions:n.slice(1)})}getAttributes(e){return zu(this.state,e)}isActive(e,t){let n=typeof e==`string`?e:null,r=typeof e==`string`?t:e;return Xu(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return uu(this.state.doc.content,this.schema)}getText(e){let{blockSeparator:t=` +}`,pp=class extends Zd{constructor(e={}){super(),this.css=null,this.className=`tiptap`,this.editorView=null,this.isFocused=!1,this.destroyed=!1,this.isInitialized=!1,this.extensionStorage={},this.instanceId=Math.random().toString(36).slice(2,9),this.hasWarnedStaleDecorationRead=!1,this.options={element:typeof document<`u`?document.createElement(`div`):null,content:``,injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,textDirection:void 0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,emitContentError:!1,onBeforeCreate:()=>null,onCreate:()=>null,onMount:()=>null,onUnmount:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:e})=>{throw e},onPaste:()=>null,onDrop:()=>null,onDelete:()=>null,enableExtensionDispatchTransaction:!0},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.utils={getUpdatedPosition:cd,createMappablePosition:ld},this.setOptions(e),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on(`beforeCreate`,this.options.onBeforeCreate),this.emit(`beforeCreate`,{editor:this}),this.on(`mount`,this.options.onMount),this.on(`unmount`,this.options.onUnmount),this.on(`contentError`,this.options.onContentError),this.on(`create`,this.options.onCreate),this.on(`update`,this.options.onUpdate),this.on(`selectionUpdate`,this.options.onSelectionUpdate),this.on(`transaction`,this.options.onTransaction),this.on(`focus`,this.options.onFocus),this.on(`blur`,this.options.onBlur),this.on(`destroy`,this.options.onDestroy),this.on(`drop`,({event:e,slice:t,moved:n})=>this.options.onDrop(e,t,n)),this.on(`paste`,({event:e,slice:t})=>this.options.onPaste(e,t)),this.on(`delete`,this.options.onDelete);let t=this.createDoc();if(!this.editorState){let e=hl(t,this.options.autofocus);this.editorState=Fn.create({doc:t,schema:this.schema,selection:e||void 0})}up(this.schema),this.options.element&&this.mount(this.options.element)}mount(e){if(typeof document>`u`)throw Error(`[tiptap error]: The editor cannot be mounted because there is no 'document' defined in this environment.`);this.createView(e),this.emit(`mount`,{editor:this}),this.css&&!document.head.contains(this.css)&&document.head.appendChild(this.css),window.setTimeout(()=>{this.isDestroyed||(this.options.autofocus!==!1&&this.options.autofocus!==null&&this.commands.focus(this.options.autofocus),this.emit(`create`,{editor:this}),this.isInitialized=!0)},0)}unmount(){if(this.editorView){this.editorState=this.editorView.state;let e=this.editorView.dom;e?.editor&&delete e.editor,this.editorView.destroy()}if(this.editorView=null,this.isInitialized=!1,this.css&&!document.querySelectorAll(`.${this.className}`).length)try{typeof this.css.remove==`function`?this.css.remove():this.css.parentNode&&this.css.parentNode.removeChild(this.css)}catch(e){console.warn(`Failed to remove CSS element:`,e)}this.css=null,this.emit(`unmount`,{editor:this})}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager?this.commandManager.chain():Uc.createFakeChain()}can(){return this.commandManager?this.commandManager.can():Uc.createFallbackCan()}injectCSS(){this.options.injectCSS&&typeof document<`u`&&(this.css=bf(fp,this.options.injectNonce))}setOptions(e={}){this.options={...this.options,...e},this.editorView&&this.state&&!this.isDestroyed&&(this.options.editorProps&&this.view.setProps({...this.options.editorProps,attributes:this.getEditorViewAttributes()}),this.view.updateState(this.state))}setEditable(e,t=!0){this.setOptions({editable:e}),t&&this.emit(`update`,{editor:this,transaction:this.state.tr,appendedTransactions:[]})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get view(){return this.editorView?this.editorView:new Proxy({state:this.editorState,updateState:e=>{this.editorState=e},dispatch:e=>{this.dispatchTransaction(e)},composing:!1,dragging:null,editable:!0,isDestroyed:!1},{get:(e,t)=>{if(this.editorView)return this.editorView[t];if(t===`state`)return this.editorState;if(t in e)return Reflect.get(e,t);throw Error(`[tiptap error]: The editor view is not available. Cannot access view['${t}']. The editor may not be mounted yet.`)}})}get state(){return Qd&&!this.hasWarnedStaleDecorationRead&&Xd(this)&&(this.hasWarnedStaleDecorationRead=!0,console.warn("[tiptap warn]: `editor.state` was read while decoration `create()` was running. It returns the pre-transaction document. Use the `state` argument passed to `create()` instead. Helpers like `editor.isActive()` read `editor.state` too, so pass `state` to their standalone versions instead of calling them on the editor.")),this.editorView&&(this.editorState=this.view.state),this.editorState}registerPlugin(e,t){let n=Cu(t)?t(e,[...this.state.plugins]):[...this.state.plugins,e],r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}unregisterPlugin(e){if(this.isDestroyed)return;let t=this.state.plugins,n=t;if([].concat(e).forEach(e=>{let t=typeof e==`string`?`${e}$`:e.key;n=n.filter(e=>!e.key.startsWith(t))}),t.length===n.length)return;let r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}createExtensionManager(){var e,t;let n=[...this.options.enableCoreExtensions?[np,Qf.configure({blockSeparator:(e=this.options.coreExtensionOptions)==null||(e=e.clipboardTextSerializer)==null?void 0:e.blockSeparator}),$f,ip,ap,sp.configure({value:(t=this.options.coreExtensionOptions)==null||(t=t.tabindex)==null?void 0:t.value}),tp,op,ep,cp.configure({direction:this.options.textDirection})].filter(e=>typeof this.options.enableCoreExtensions!=`object`||this.options.enableCoreExtensions[e.name]!==!1):[],...this.options.extensions].filter(e=>[`extension`,`node`,`mark`].includes(e?.type));this.extensionManager=new Zf(n,this)}createCommandManager(){this.commandManager=new Uc({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let e;try{e=iu(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(e){if(!(e instanceof Error)||![`[tiptap error]: Invalid JSON content`,`[tiptap error]: Invalid HTML content`].includes(e.message))throw e;let t=iu(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1});return this.editorState=Fn.create({doc:t,schema:this.schema,selection:hl(t,this.options.autofocus)||void 0}),this.emit(`contentError`,{editor:this,error:e,disableCollaboration:()=>{`collaboration`in this.storage&&typeof this.storage.collaboration==`object`&&this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter(e=>e.name!==`collaboration`),this.createExtensionManager()}}),this.editorState.doc}return e}getEditorViewAttributes(){let e=this.options.editorProps?.attributes;return Cu(e)?t=>({role:`textbox`,...e(t)}):{role:`textbox`,...e}}createView(e){let{editorProps:t,enableExtensionDispatchTransaction:n}=this.options,r=t.dispatchTransaction||this.dispatchTransaction.bind(this),i=n?this.extensionManager.dispatchTransaction(r):r,a=t.transformPastedHTML,o=this.extensionManager.transformPastedHTML(a);this.editorView=new Js(e,{...t,attributes:this.getEditorViewAttributes(),dispatchTransaction:i,transformPastedHTML:o,state:this.editorState,markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews});let s=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(s),this.prependClass(),this.injectCSS();let c=this.view.dom;c.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`${this.className} ${this.view.dom.className}`}captureTransaction(e){this.isCapturingTransaction=!0,e(),this.isCapturingTransaction=!1;let t=this.capturedTransaction;return this.capturedTransaction=null,t}dispatchTransaction(e){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=e;return}e.steps.forEach(e=>this.capturedTransaction?.step(e));return}let{state:t,transactions:n}=this.state.applyTransaction(e),r=!this.state.selection.eq(t.selection),i=n.includes(e),a=this.state;if(this.emit(`beforeTransaction`,{editor:this,transaction:e,nextState:t}),!i)return;this.view.updateState(t),this.emit(`transaction`,{editor:this,transaction:e,appendedTransactions:n.slice(1)}),r&&this.emit(`selectionUpdate`,{editor:this,transaction:e});let o=n.findLast(e=>e.getMeta(`focus`)||e.getMeta(`blur`)),s=o?.getMeta(`focus`),c=o?.getMeta(`blur`);s&&this.emit(`focus`,{editor:this,event:s.event,transaction:o}),c&&this.emit(`blur`,{editor:this,event:c.event,transaction:o}),e.getMeta(`preventUpdate`)||!n.some(e=>e.docChanged)||a.doc.eq(t.doc)||this.emit(`update`,{editor:this,transaction:e,appendedTransactions:n.slice(1)})}getAttributes(e){return Vu(this.state,e)}isActive(e,t){let n=typeof e==`string`?e:null,r=typeof e==`string`?t:e;return Qu(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return fu(this.state.doc.content,this.schema)}getText(e){let{blockSeparator:t=` -`,textSerializers:n={}}=e||{};return Iu(this.state.doc,{blockSeparator:t,textSerializers:{...Lu(this.schema),...n}})}get isEmpty(){return td(this.state.doc)}destroy(){this.destroyed||(this.destroyed=!0,this.emit(`destroy`),this.unmount(),this.removeAllListeners(),this.extensionManager.destroy(),this.extensionManager=null,this.schema=null,this.commandManager=null,this.extensionStorage={})}get isDestroyed(){return this.editorView?.isDestroyed??!0}$node(e,t){return this.$doc?.querySelector(e,t)||null}$nodes(e,t){return this.$doc?.querySelectorAll(e,t)||null}$pos(e){let t=this.state.doc.resolve(e),n=e>0&&t.nodeAfter&&!t.nodeAfter.isText&&t.nodeAfter.isAtom?t.nodeAfter:null;return new lp(t,this,!1,n)}get $doc(){return this.$pos(0)}};function fp(e){return new Pf({find:e.find,handler:({state:t,range:n,match:r})=>{let i=V(e.getAttributes,void 0,r);if(i===!1||i===null)return null;let{tr:a}=t,o=r[r.length-1],s=r[0];if(o){let r=s.search(/\S/),c=n.from+s.indexOf(o),l=c+o.length;if(Uu(n.from,n.to,t.doc).filter(t=>t.mark.type.excluded.find(n=>n===e.type&&n!==t.mark.type)).filter(e=>e.to>c).length)return null;ln.from&&a.delete(n.from+r,c);let u=n.from+r+o.length;a.addMark(n.from+r,u,e.type.create(i||{})),a.removeStoredMark(e.type)}},undoable:e.undoable})}function pp(e){return new Pf({find:e.find,handler:({state:t,range:n,match:r})=>{let i=V(e.getAttributes,void 0,r)||{},{tr:a}=t,o=n.from,s=n.to,c=e.type.create(i);if(r[1]){let e=o+r[0].lastIndexOf(r[1]);e>s?e=s:s=e+r[1].length;let t=r[0][r[0].length-1];a.insertText(t,o+r[0].length-1),a.replaceWith(e,s,c)}else if(r[0]){let t=e.type.isInline?o:o-1;a.insert(t,e.type.create(i)).delete(a.mapping.map(o),a.mapping.map(s))}a.scrollIntoView()},undoable:e.undoable})}function mp(e){return new Pf({find:e.find,handler:({state:t,range:n,match:r})=>{let i=t.doc.resolve(n.from),a=V(e.getAttributes,void 0,r)||{};if(!i.node(-1).canReplaceWith(i.index(-1),i.indexAfter(-1),e.type))return null;t.tr.delete(n.from,n.to).setBlockType(n.from,n.from,e.type,a)},undoable:e.undoable})}function hp(e){return new Pf({find:e.find,handler:({state:t,range:n,match:r,chain:i})=>{let a=V(e.getAttributes,void 0,r)||{},o=t.tr.delete(n.from,n.to),s=o.doc.resolve(n.from).blockRange(),c=s&&jt(s,e.type,a);if(!c)return null;if(o.wrap(s,c),e.keepMarks&&e.editor){let{selection:n,storedMarks:r}=t,{splittableMarks:i}=e.editor.extensionManager,a=r||n.$to.parentOffset&&n.$from.marks();if(a){let e=a.filter(e=>i.includes(e.type.name));o.ensureMarks(e)}}if(e.keepAttributes){let t=e.type.name===`bulletList`||e.type.name===`orderedList`?`listItem`:`taskList`;i().updateAttributes(t,a).run()}let l=o.doc.resolve(n.from-1).nodeBefore;l&&l.type===e.type&&Ut(o.doc,n.from-1)&&(!e.joinPredicate||e.joinPredicate(r,l))&&o.join(n.from-1)},undoable:e.undoable})}var W=class e extends Vf{constructor(...e){super(...e),this.type=`node`}static create(t={}){let n=typeof t==`function`?t():t;return new e(n)}configure(e){return super.configure(e)}extend(e){let t=typeof e==`function`?e():e;return super.extend(t)}};function gp(e){return new Uf({find:e.find,handler:({state:t,range:n,match:r,pasteEvent:i})=>{let a=V(e.getAttributes,void 0,r,i);if(a===!1||a===null)return null;let{tr:o}=t,s=r[r.length-1],c=r[0],l=n.to;if(s){let i=c.search(/\S/),u=n.from+c.indexOf(s),d=u+s.length;if(Uu(n.from,n.to,t.doc).filter(t=>t.mark.type.excluded.find(n=>n===e.type&&n!==t.mark.type)).filter(e=>e.to>u).length)return null;dn.from&&o.delete(n.from+i,u),l=n.from+i+s.length,o.addMark(n.from+i,l,e.type.create(a||{})),r.index!==void 0&&r.input!==void 0&&r.index+r[0].length>=r.input.length||o.removeStoredMark(e.type)}}})}var _p=new WeakSet,vp=new WeakSet;function yp(e){let t=e;return _p.add(t),t}function bp(e){return Array.isArray(e)&&_p.has(e)}function xp(e){return e.flatMap(e=>e==null?[]:Array.isArray(e)&&vp.has(e)&&!bp(e)?xp(e):[e])}function Sp(e,t){if(e===`slot`)return 0;if(e instanceof Function){let n=e(t);return Array.isArray(n)&&!bp(n)&&!vp.has(n)?yp(n):n}let{children:n,...r}=t??{};if(e===`svg`)throw Error(`SVG elements are not supported in the JSX syntax, use the array syntax instead`);if(Array.isArray(n)){if(bp(n))return yp([e,r,n]);if(n.length===0)return yp([e,r]);let t=xp(n);return t.length===0?yp([e,r]):yp([e,r,...t])}return yp(n==null?[e,r]:[e,r,n])}var Cp=(e,t)=>Sp(e,t),wp=(e,t)=>{let{state:n}=e,{selection:r}=n;if(!r.empty)return!1;let{$from:i}=r;if(i.parentOffset!==0)return!1;let a=i.depth-1;if(a<0)return!1;let o=i.node(a),s=i.index(a);if(s===0)return!1;if(o.type===t)return e.commands.lift(t.name);let c=o.child(s-1);if(c.type!==t||!c.lastChild?.isTextblock)return!1;let l=i.before()-1-1;return e.commands.command(({tr:e,dispatch:t})=>{if(!t)return!0;let n=i.parent.content,r=new m(n,0,0);return e.replace(l,i.after(),r),e.setSelection(A.create(e.doc,l+n.size)),e.scrollIntoView(),t(e),!0})},Tp=/^\s*>\s$/,Ep=W.create({name:`blockquote`,addOptions(){return{HTMLAttributes:{}}},content:`block+`,group:`block`,defining:!0,parseHTML(){return[{tag:`blockquote`}]},renderHTML({HTMLAttributes:e}){return Cp(`blockquote`,{...H(this.options.HTMLAttributes,e),children:Cp(`slot`,{})})},parseMarkdown:(e,t)=>{let n=t.parseBlockChildren??t.parseChildren;return t.createNode(`blockquote`,void 0,n(e.tokens||[]))},renderMarkdown:(e,t)=>{if(!e.content)return``;let n=[];return e.content.forEach((e,r)=>{let i=(t.renderChild?.call(t,e,r)??t.renderChildren([e])).split(` +`,textSerializers:n={}}=e||{};return Ru(this.state.doc,{blockSeparator:t,textSerializers:{...zu(this.schema),...n}})}get isEmpty(){return rd(this.state.doc)}destroy(){this.destroyed||(this.destroyed=!0,this.emit(`destroy`),this.unmount(),this.removeAllListeners(),this.extensionManager.destroy(),this.extensionManager=null,this.schema=null,this.commandManager=null,this.extensionStorage={})}get isDestroyed(){return this.editorView?.isDestroyed??!0}$node(e,t){return this.$doc?.querySelector(e,t)||null}$nodes(e,t){return this.$doc?.querySelectorAll(e,t)||null}$pos(e){let t=this.state.doc.resolve(e),n=e>0&&t.nodeAfter&&!t.nodeAfter.isText&&t.nodeAfter.isAtom?t.nodeAfter:null;return new dp(t,this,!1,n)}get $doc(){return this.$pos(0)}};function mp(e){return new If({find:e.find,handler:({state:t,range:n,match:r})=>{let i=z(e.getAttributes,void 0,r);if(i===!1||i===null)return null;let{tr:a}=t,o=r[r.length-1],s=r[0];if(o){let r=s.search(/\S/),c=n.from+s.indexOf(o),l=c+o.length;if(Gu(n.from,n.to,t.doc).filter(t=>t.mark.type.excluded.find(n=>n===e.type&&n!==t.mark.type)).filter(e=>e.to>c).length)return null;ln.from&&a.delete(n.from+r,c);let u=n.from+r+o.length;a.addMark(n.from+r,u,e.type.create(i||{})),a.removeStoredMark(e.type)}},undoable:e.undoable})}function hp(e){return new If({find:e.find,handler:({state:t,range:n,match:r})=>{let i=z(e.getAttributes,void 0,r)||{},{tr:a}=t,o=n.from,s=n.to,c=e.type.create(i);if(r[1]){let e=o+r[0].lastIndexOf(r[1]);e>s?e=s:s=e+r[1].length;let t=r[0][r[0].length-1];a.insertText(t,o+r[0].length-1),a.replaceWith(e,s,c)}else if(r[0]){let t=e.type.isInline?o:o-1;a.insert(t,e.type.create(i)).delete(a.mapping.map(o),a.mapping.map(s))}a.scrollIntoView()},undoable:e.undoable})}function gp(e){return new If({find:e.find,handler:({state:t,range:n,match:r})=>{let i=t.doc.resolve(n.from),a=z(e.getAttributes,void 0,r)||{};if(!i.node(-1).canReplaceWith(i.index(-1),i.indexAfter(-1),e.type))return null;t.tr.delete(n.from,n.to).setBlockType(n.from,n.from,e.type,a)},undoable:e.undoable})}function _p(e){return new If({find:e.find,handler:({state:t,range:n,match:r,chain:i})=>{let a=z(e.getAttributes,void 0,r)||{},o=t.tr.delete(n.from,n.to),s=o.doc.resolve(n.from).blockRange(),c=s&&jt(s,e.type,a);if(!c)return null;if(o.wrap(s,c),e.keepMarks&&e.editor){let{selection:n,storedMarks:r}=t,{splittableMarks:i}=e.editor.extensionManager,a=r||n.$to.parentOffset&&n.$from.marks();if(a){let e=a.filter(e=>i.includes(e.type.name));o.ensureMarks(e)}}if(e.keepAttributes){let t=e.type.name===`bulletList`||e.type.name===`orderedList`?`listItem`:`taskList`;i().updateAttributes(t,a).run()}let l=o.doc.resolve(n.from-1).nodeBefore;l&&l.type===e.type&&Ut(o.doc,n.from-1)&&(!e.joinPredicate||e.joinPredicate(r,l))&&o.join(n.from-1)},undoable:e.undoable})}var H=class e extends Uf{constructor(...e){super(...e),this.type=`node`}static create(t={}){let n=typeof t==`function`?t():t;return new e(n)}configure(e){return super.configure(e)}extend(e){let t=typeof e==`function`?e():e;return super.extend(t)}};function vp(e){return new Gf({find:e.find,handler:({state:t,range:n,match:r,pasteEvent:i})=>{let a=z(e.getAttributes,void 0,r,i);if(a===!1||a===null)return null;let{tr:o}=t,s=r[r.length-1],c=r[0],l=n.to;if(s){let i=c.search(/\S/),u=n.from+c.indexOf(s),d=u+s.length;if(Gu(n.from,n.to,t.doc).filter(t=>t.mark.type.excluded.find(n=>n===e.type&&n!==t.mark.type)).filter(e=>e.to>u).length)return null;dn.from&&o.delete(n.from+i,u),l=n.from+i+s.length,o.addMark(n.from+i,l,e.type.create(a||{})),r.index!==void 0&&r.input!==void 0&&r.index+r[0].length>=r.input.length||o.removeStoredMark(e.type)}}})}var yp=new WeakSet,bp=new WeakSet;function xp(e){let t=e;return yp.add(t),t}function Sp(e){return Array.isArray(e)&&yp.has(e)}function Cp(e){return e.flatMap(e=>e==null?[]:Array.isArray(e)&&bp.has(e)&&!Sp(e)?Cp(e):[e])}function wp(e,t){if(e===`slot`)return 0;if(e instanceof Function){let n=e(t);return Array.isArray(n)&&!Sp(n)&&!bp.has(n)?xp(n):n}let{children:n,...r}=t??{};if(e===`svg`)throw Error(`SVG elements are not supported in the JSX syntax, use the array syntax instead`);if(Array.isArray(n)){if(Sp(n))return xp([e,r,n]);if(n.length===0)return xp([e,r]);let t=Cp(n);return t.length===0?xp([e,r]):xp([e,r,...t])}return xp(n==null?[e,r]:[e,r,n])}var Tp=(e,t)=>wp(e,t),Ep=(e,t)=>{let{state:n}=e,{selection:r}=n;if(!r.empty)return!1;let{$from:i}=r;if(i.parentOffset!==0)return!1;let a=i.depth-1;if(a<0)return!1;let o=i.node(a),s=i.index(a);if(s===0)return!1;if(o.type===t)return e.commands.lift(t.name);let c=o.child(s-1);if(c.type!==t||!c.lastChild?.isTextblock)return!1;let l=i.before()-1-1;return e.commands.command(({tr:e,dispatch:t})=>{if(!t)return!0;let n=i.parent.content,r=new m(n,0,0);return e.replace(l,i.after(),r),e.setSelection(A.create(e.doc,l+n.size)),e.scrollIntoView(),t(e),!0})},Dp=/^\s*>\s$/,Op=H.create({name:`blockquote`,addOptions(){return{HTMLAttributes:{}}},content:`block+`,group:`block`,defining:!0,parseHTML(){return[{tag:`blockquote`}]},renderHTML({HTMLAttributes:e}){return Tp(`blockquote`,{...B(this.options.HTMLAttributes,e),children:Tp(`slot`,{})})},parseMarkdown:(e,t)=>{let n=t.parseBlockChildren??t.parseChildren;return t.createNode(`blockquote`,void 0,n(e.tokens||[]))},renderMarkdown:(e,t)=>{if(!e.content)return``;let n=[];return e.content.forEach((e,r)=>{let i=(t.renderChild?.call(t,e,r)??t.renderChildren([e])).split(` `).map(e=>e.trim()===``?`>`:`> ${e}`);n.push(i.join(` `))}),n.join(` > -`)},addCommands(){return{setBlockquote:()=>({commands:e})=>e.wrapIn(this.name),toggleBlockquote:()=>({commands:e})=>e.toggleWrap(this.name),unsetBlockquote:()=>({commands:e})=>e.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote(),Backspace:()=>wp(this.editor,this.type)}},addInputRules(){return[hp({find:Tp,type:this.type})]}}),Dp=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,Op=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,kp=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,Ap=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,jp=Hf.create({name:`bold`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`strong`},{tag:`b`,getAttrs:e=>e.style.fontWeight!==`normal`&&null},{style:`font-weight=400`,clearMark:e=>e.type.name===this.name},{style:`font-weight`,getAttrs:e=>/^(bold(er)?|[5-9]\d{2,})$/.test(e)&&null}]},renderHTML({HTMLAttributes:e}){return Cp(`strong`,{...H(this.options.HTMLAttributes,e),children:Cp(`slot`,{})})},markdownTokenName:`strong`,parseMarkdown:(e,t)=>t.applyMark(`bold`,t.parseInline(e.tokens||[])),markdownOptions:{htmlReopen:{open:``,close:``}},renderMarkdown:(e,t)=>`**${t.renderChildren(e)}**`,addCommands(){return{setBold:()=>({commands:e})=>e.setMark(this.name),toggleBold:()=>({commands:e})=>e.toggleMark(this.name),unsetBold:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[fp({find:Dp,type:this.type}),fp({find:kp,type:this.type})]},addPasteRules(){return[gp({find:Op,type:this.type}),gp({find:Ap,type:this.type})]}}),Mp=e=>{let t=/`([^`]+)`(?!`)$/.exec(e);return!t||t.index>0&&e[t.index-1]==="`"?null:{index:t.index,text:t[0],replaceWith:t[1]}},Np=e=>{let t=/`([^`]+)`(?!`)/g,n=[],r;for(;(r=t.exec(e))!==null;)r.index>0&&e[r.index-1]==="`"||n.push({index:r.index,text:r[0],replaceWith:r[1]});return n};function Pp(e){let t=new Set((e.match(/`+/g)||[]).map(e=>e.length)),n=1;for(;t.has(n);)n+=1;return n}var Fp=Hf.create({name:`code`,addOptions(){return{HTMLAttributes:{}}},excludes:`_`,code:!0,exitable:!0,parseHTML(){return[{tag:`code`}]},renderHTML({HTMLAttributes:e}){return[`code`,H(this.options.HTMLAttributes,e),0]},markdownTokenName:`codespan`,parseMarkdown:(e,t)=>t.applyMark(`code`,[{type:`text`,text:e.text||``}]),renderMarkdown:(e,t,n)=>{var r;if(!e.content)return``;let i=typeof(n==null||(r=n.meta)==null?void 0:r.markText)==`string`?n.meta.markText:``,a="`".repeat(Pp(i)),o=i.startsWith("`")||i.endsWith("`")?` `:``;return`${a}${o}${t.renderChildren(e.content)}${o}${a}`},addCommands(){return{setCode:()=>({commands:e})=>e.setMark(this.name),toggleCode:()=>({commands:e})=>e.toggleMark(this.name),unsetCode:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[fp({find:Mp,type:this.type})]},addPasteRules(){return[gp({find:Np,type:this.type})]}}),Ip=4,Lp=/^```([a-z]+)?[\s\n]$/,Rp=/^~~~([a-z]+)?[\s\n]$/,zp=W.create({name:`codeBlock`,addOptions(){return{languageClassPrefix:`language-`,exitOnTripleEnter:!0,exitOnArrowDown:!0,exitOnArrowUp:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:Ip,HTMLAttributes:{}}},content:`text*`,marks:``,group:`block`,code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:e=>{let{languageClassPrefix:t}=this.options;return t&&[...e.firstElementChild?.classList||[]].filter(e=>e.startsWith(t)).map(e=>e.replace(t,``))[0]||null},rendered:!1}}},parseHTML(){return[{tag:`pre`,preserveWhitespace:`full`}]},renderHTML({node:e,HTMLAttributes:t}){return[`pre`,H(this.options.HTMLAttributes,t),[`code`,{class:e.attrs.language?this.options.languageClassPrefix+e.attrs.language:null},0]]},markdownTokenName:`code`,parseMarkdown:(e,t)=>e.raw?.startsWith("```")===!1&&e.raw?.startsWith(`~~~`)===!1&&e.codeBlockStyle!==`indented`?[]:t.createNode(`codeBlock`,{language:e.lang||null},e.text?[t.createTextNode(e.text)]:[]),renderMarkdown:(e,t)=>{let n=``,r=e.attrs?.language||``;return n=e.content?[`\`\`\`${r}`,t.renderChildren(e.content),"```"].join(` -`):`\`\`\`${r}\n\n\`\`\``,n},addCommands(){return{setCodeBlock:e=>({commands:t})=>t.setNode(this.name,e),toggleCodeBlock:e=>({commands:t})=>t.toggleNode(this.name,`paragraph`,e)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{let{empty:e,$anchor:t}=this.editor.state.selection,n=t.pos===1;return!e||t.parent.type.name!==this.name?!1:n||!t.parent.textContent.length?this.editor.commands.clearNodes():!1},Tab:({editor:e})=>{if(!this.options.enableTabIndentation)return!1;let t=this.options.tabSize??Ip,{state:n}=e,{selection:r}=n,{$from:i,empty:a}=r;if(i.parent.type!==this.type)return!1;let o=` `.repeat(t);return a?e.commands.insertContent(o):e.commands.command(({tr:e})=>{let{from:t,to:i}=r,a=n.doc.textBetween(t,i,` +`)},addCommands(){return{setBlockquote:()=>({commands:e})=>e.wrapIn(this.name),toggleBlockquote:()=>({commands:e})=>e.toggleWrap(this.name),unsetBlockquote:()=>({commands:e})=>e.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote(),Backspace:()=>Ep(this.editor,this.type)}},addInputRules(){return[_p({find:Dp,type:this.type})]}}),kp=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,Ap=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,jp=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,Mp=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,Np=Wf.create({name:`bold`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`strong`},{tag:`b`,getAttrs:e=>e.style.fontWeight!==`normal`&&null},{style:`font-weight=400`,clearMark:e=>e.type.name===this.name},{style:`font-weight`,getAttrs:e=>/^(bold(er)?|[5-9]\d{2,})$/.test(e)&&null}]},renderHTML({HTMLAttributes:e}){return Tp(`strong`,{...B(this.options.HTMLAttributes,e),children:Tp(`slot`,{})})},markdownTokenName:`strong`,parseMarkdown:(e,t)=>t.applyMark(`bold`,t.parseInline(e.tokens||[])),markdownOptions:{htmlReopen:{open:``,close:``}},renderMarkdown:(e,t)=>`**${t.renderChildren(e)}**`,addCommands(){return{setBold:()=>({commands:e})=>e.setMark(this.name),toggleBold:()=>({commands:e})=>e.toggleMark(this.name),unsetBold:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[mp({find:kp,type:this.type}),mp({find:jp,type:this.type})]},addPasteRules(){return[vp({find:Ap,type:this.type}),vp({find:Mp,type:this.type})]}}),Pp=e=>{let t=/`([^`]+)`(?!`)$/.exec(e);return!t||t.index>0&&e[t.index-1]==="`"?null:{index:t.index,text:t[0],replaceWith:t[1]}},Fp=e=>{let t=/`([^`]+)`(?!`)/g,n=[],r;for(;(r=t.exec(e))!==null;)r.index>0&&e[r.index-1]==="`"||n.push({index:r.index,text:r[0],replaceWith:r[1]});return n};function Ip(e){let t=new Set((e.match(/`+/g)||[]).map(e=>e.length)),n=1;for(;t.has(n);)n+=1;return n}var Lp=Wf.create({name:`code`,addOptions(){return{HTMLAttributes:{}}},excludes:`_`,code:!0,exitable:!0,parseHTML(){return[{tag:`code`}]},renderHTML({HTMLAttributes:e}){return[`code`,B(this.options.HTMLAttributes,e),0]},markdownTokenName:`codespan`,parseMarkdown:(e,t)=>t.applyMark(`code`,[{type:`text`,text:e.text||``}]),renderMarkdown:(e,t,n)=>{var r;if(!e.content)return``;let i=typeof(n==null||(r=n.meta)==null?void 0:r.markText)==`string`?n.meta.markText:``,a="`".repeat(Ip(i)),o=i.startsWith("`")||i.endsWith("`")?` `:``;return`${a}${o}${t.renderChildren(e.content)}${o}${a}`},addCommands(){return{setCode:()=>({commands:e})=>e.setMark(this.name),toggleCode:()=>({commands:e})=>e.toggleMark(this.name),unsetCode:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[mp({find:Pp,type:this.type})]},addPasteRules(){return[vp({find:Fp,type:this.type})]}}),Rp=4,zp=/^```([a-z]+)?[\s\n]$/,Bp=/^~~~([a-z]+)?[\s\n]$/,Vp=H.create({name:`codeBlock`,addOptions(){return{languageClassPrefix:`language-`,exitOnTripleEnter:!0,exitOnArrowDown:!0,exitOnArrowUp:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:Rp,HTMLAttributes:{}}},content:`text*`,marks:``,group:`block`,code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:e=>{let{languageClassPrefix:t}=this.options;return t&&[...e.firstElementChild?.classList||[]].filter(e=>e.startsWith(t)).map(e=>e.replace(t,``))[0]||null},rendered:!1}}},parseHTML(){return[{tag:`pre`,preserveWhitespace:`full`}]},renderHTML({node:e,HTMLAttributes:t}){return[`pre`,B(this.options.HTMLAttributes,t),[`code`,{class:e.attrs.language?this.options.languageClassPrefix+e.attrs.language:null},0]]},markdownTokenName:`code`,parseMarkdown:(e,t)=>e.raw?.startsWith("```")===!1&&e.raw?.startsWith(`~~~`)===!1&&e.codeBlockStyle!==`indented`?[]:t.createNode(`codeBlock`,{language:e.lang||null},e.text?[t.createTextNode(e.text)]:[]),renderMarkdown:(e,t)=>{let n=``,r=e.attrs?.language||``;return n=e.content?[`\`\`\`${r}`,t.renderChildren(e.content),"```"].join(` +`):`\`\`\`${r}\n\n\`\`\``,n},addCommands(){return{setCodeBlock:e=>({commands:t})=>t.setNode(this.name,e),toggleCodeBlock:e=>({commands:t})=>t.toggleNode(this.name,`paragraph`,e)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{let{empty:e,$anchor:t}=this.editor.state.selection,n=t.pos===1;return!e||t.parent.type.name!==this.name?!1:n||!t.parent.textContent.length?this.editor.commands.clearNodes():!1},Tab:({editor:e})=>{if(!this.options.enableTabIndentation)return!1;let t=this.options.tabSize??Rp,{state:n}=e,{selection:r}=n,{$from:i,empty:a}=r;if(i.parent.type!==this.type)return!1;let o=` `.repeat(t);return a?e.commands.insertContent(o):e.commands.command(({tr:e})=>{let{from:t,to:i}=r,a=n.doc.textBetween(t,i,` `,` `).split(` `).map(e=>o+e).join(` -`);return e.replaceWith(t,i,n.schema.text(a)),!0})},"Shift-Tab":({editor:e})=>{if(!this.options.enableTabIndentation)return!1;let t=this.options.tabSize??Ip,{state:n}=e,{selection:r}=n,{$from:i,empty:a}=r;return i.parent.type===this.type?a?e.commands.command(({tr:e})=>{let{pos:r}=i,a=i.start(),o=i.end(),s=n.doc.textBetween(a,o,` +`);return e.replaceWith(t,i,n.schema.text(a)),!0})},"Shift-Tab":({editor:e})=>{if(!this.options.enableTabIndentation)return!1;let t=this.options.tabSize??Rp,{state:n}=e,{selection:r}=n,{$from:i,empty:a}=r;return i.parent.type===this.type?a?e.commands.command(({tr:e})=>{let{pos:r}=i,a=i.start(),o=i.end(),s=n.doc.textBetween(a,o,` `,` `).split(` `),c=0,l=0,u=r-a;for(let e=0;e=u){c=e;break}l+=s[e].length+1}let d=s[c].match(/^ */)?.[0]||``,f=Math.min(d.length,t);if(f===0)return!0;let p=a;for(let e=0;e{let{from:i,to:a}=r,o=n.doc.textBetween(i,a,` @@ -111,43 +111,43 @@ img.ProseMirror-separator { `).map(e=>{let n=e.match(/^ */)?.[0]||``,r=Math.min(n.length,t);return e.slice(r)}).join(` `);return e.replaceWith(i,a,n.schema.text(o)),!0}):!1},Enter:({editor:e})=>{if(!this.options.exitOnTripleEnter)return!1;let{state:t}=e,{selection:n}=t,{$from:r,empty:i}=n;if(!i||r.parent.type!==this.type)return!1;let a=r.parentOffset===r.parent.nodeSize-2,o=r.parent.textContent.endsWith(` -`);return!a||!o?!1:e.chain().command(({tr:e})=>(e.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowUp:({editor:e})=>{if(!this.options.exitOnArrowUp)return!1;let{state:t}=e,{selection:n}=t,{$from:r,empty:i}=n;if(!i||r.parent.type!==this.type||r.parentOffset!==0)return!1;let a=r.before();return a>0?!1:e.commands.insertDefaultBlock({pos:a})},ArrowDown:({editor:e})=>{if(!this.options.exitOnArrowDown)return!1;let{state:t}=e,{selection:n,doc:r}=t,{$from:i,empty:a}=n;if(!a||i.parent.type!==this.type||i.parentOffset!==i.parent.nodeSize-2)return!1;let o=i.after();return o===void 0?!1:r.nodeAt(o)?e.commands.command(({tr:e})=>(e.setSelection(k.near(r.resolve(o))),!0)):e.commands.exitCode()}}},addInputRules(){return[mp({find:Lp,type:this.type,getAttributes:e=>({language:e[1]})}),mp({find:Rp,type:this.type,getAttributes:e=>({language:e[1]})})]},addProseMirrorPlugins(){return[new M({key:new N(`codeBlockVSCodeHandler`),props:{handlePaste:(e,t)=>{if(!t.clipboardData||this.editor.isActive(this.type.name))return!1;let n=t.clipboardData.getData(`text/plain`),r=t.clipboardData.getData(`vscode-editor-data`),i=(r?JSON.parse(r):void 0)?.mode;if(!n||!i)return!1;let{tr:a,schema:o}=e.state,s=o.text(n.replace(/\r\n?/g,` -`));return a.replaceSelectionWith(this.type.create({language:i},s)),a.selection.$from.parent.type!==this.type&&a.setSelection(A.near(a.doc.resolve(Math.max(0,a.selection.from-2)))),a.setMeta(`paste`,!0),e.dispatch(a),!0}}})]}}),Bp=W.create({name:`doc`,topNode:!0,content:`block+`,renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,` +`);return!a||!o?!1:e.chain().command(({tr:e})=>(e.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowUp:({editor:e})=>{if(!this.options.exitOnArrowUp)return!1;let{state:t}=e,{selection:n}=t,{$from:r,empty:i}=n;if(!i||r.parent.type!==this.type||r.parentOffset!==0)return!1;let a=r.before();return a>0?!1:e.commands.insertDefaultBlock({pos:a})},ArrowDown:({editor:e})=>{if(!this.options.exitOnArrowDown)return!1;let{state:t}=e,{selection:n,doc:r}=t,{$from:i,empty:a}=n;if(!a||i.parent.type!==this.type||i.parentOffset!==i.parent.nodeSize-2)return!1;let o=i.after();return o===void 0?!1:r.nodeAt(o)?e.commands.command(({tr:e})=>(e.setSelection(k.near(r.resolve(o))),!0)):e.commands.exitCode()}}},addInputRules(){return[gp({find:zp,type:this.type,getAttributes:e=>({language:e[1]})}),gp({find:Bp,type:this.type,getAttributes:e=>({language:e[1]})})]},addProseMirrorPlugins(){return[new M({key:new N(`codeBlockVSCodeHandler`),props:{handlePaste:(e,t)=>{if(!t.clipboardData||this.editor.isActive(this.type.name))return!1;let n=t.clipboardData.getData(`text/plain`),r=t.clipboardData.getData(`vscode-editor-data`),i=(r?JSON.parse(r):void 0)?.mode;if(!n||!i)return!1;let{tr:a,schema:o}=e.state,s=o.text(n.replace(/\r\n?/g,` +`));return a.replaceSelectionWith(this.type.create({language:i},s)),a.selection.$from.parent.type!==this.type&&a.setSelection(A.near(a.doc.resolve(Math.max(0,a.selection.from-2)))),a.setMeta(`paste`,!0),e.dispatch(a),!0}}})]}}),Hp=H.create({name:`doc`,topNode:!0,content:`block+`,renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,` -`):``}),Vp=W.create({name:`hardBreak`,markdownTokenName:`br`,addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:`inline`,selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:`br`}]},renderHTML({HTMLAttributes:e}){return[`br`,H(this.options.HTMLAttributes,e)]},renderText(){return` +`):``}),Up=H.create({name:`hardBreak`,markdownTokenName:`br`,addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:`inline`,selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:`br`}]},renderHTML({HTMLAttributes:e}){return[`br`,B(this.options.HTMLAttributes,e)]},renderText(){return` `},renderMarkdown:()=>` -`,parseMarkdown:()=>({type:`hardBreak`}),addCommands(){return{setHardBreak:()=>({commands:e,chain:t,state:n,editor:r})=>e.first([()=>e.exitCode(),()=>e.command(()=>{let{selection:e,storedMarks:i}=n;if(e.$from.parent.type.spec.isolating)return!1;let{keepMarks:a}=this.options,{splittableMarks:o}=r.extensionManager,s=i||e.$to.parentOffset&&e.$from.marks();return t().insertContent({type:this.name}).command(({tr:e,dispatch:t})=>{if(t&&s&&a){let t=s.filter(e=>o.includes(e.type.name));e.ensureMarks(t)}return!0}).scrollIntoView().run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),Hp=W.create({name:`heading`,addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:`inline*`,group:`block`,defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(e=>({tag:`h${e}`,attrs:{level:e}}))},renderHTML({node:e,HTMLAttributes:t}){return[`h${this.options.levels.includes(e.attrs.level)?e.attrs.level:this.options.levels[0]}`,H(this.options.HTMLAttributes,t),0]},parseMarkdown(e,t){let n=e.depth||1;return this.options.levels.includes(n)?t.createNode(`heading`,{level:n},t.parseInline(e.tokens||[])):t.createNode(`paragraph`,void 0,t.parseInline(e.tokens||[]))},renderMarkdown:(e,t)=>{let n=e.attrs?.level?parseInt(e.attrs.level,10):1,r=`#`.repeat(n);return e.content?`${r} ${t.renderChildren(e.content)}`:``},addCommands(){return{setHeading:e=>({commands:t})=>this.options.levels.includes(e.level)?t.setNode(this.name,e):!1,toggleHeading:e=>({commands:t})=>this.options.levels.includes(e.level)?t.toggleNode(this.name,`paragraph`,e):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((e,t)=>({...e,[`Mod-Alt-${t}`]:()=>this.editor.commands.toggleHeading({level:t})}),{})},addInputRules(){return this.options.levels.map(e=>mp({find:RegExp(`^(#{${Math.min(...this.options.levels)},${e}})\\s$`),type:this.type,getAttributes:{level:e}}))}}),Up=W.create({name:`horizontalRule`,addOptions(){return{HTMLAttributes:{},nextNodeType:`paragraph`}},group:`block`,parseHTML(){return[{tag:`hr`}]},renderHTML({HTMLAttributes:e}){return[`hr`,H(this.options.HTMLAttributes,e)]},markdownTokenName:`hr`,parseMarkdown:(e,t)=>t.createNode(`horizontalRule`),renderMarkdown:()=>`---`,addCommands(){return{setHorizontalRule:()=>({chain:e,state:t})=>{if(!_f(t,t.schema.nodes[this.name]))return!1;let{selection:n}=t,{$to:r}=n,i=e();return nd(n)?i.insertContentAt(r.pos,{type:this.name}):i.insertContent({type:this.name}),i.command(({state:e,tr:t,dispatch:n})=>{if(n){let{$to:n}=t.selection,r=n.end();if(n.nodeAfter)n.nodeAfter.isTextblock?t.setSelection(A.create(t.doc,n.pos+1)):n.nodeAfter.isBlock?t.setSelection(j.create(t.doc,n.pos)):t.setSelection(A.create(t.doc,n.pos));else{let i=(e.schema.nodes[this.options.nextNodeType]||n.parent.type.contentMatch.defaultType)?.create();i&&(t.insert(r,i),t.setSelection(A.create(t.doc,r+1)))}t.scrollIntoView()}return!0}).run()}}},addInputRules(){return[pp({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),Wp=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,Gp=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,Kp=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,qp=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,Jp=Hf.create({name:`italic`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`em`},{tag:`i`,getAttrs:e=>e.style.fontStyle!==`normal`&&null},{style:`font-style=normal`,clearMark:e=>e.type.name===this.name},{style:`font-style=italic`}]},renderHTML({HTMLAttributes:e}){return[`em`,H(this.options.HTMLAttributes,e),0]},addCommands(){return{setItalic:()=>({commands:e})=>e.setMark(this.name),toggleItalic:()=>({commands:e})=>e.toggleMark(this.name),unsetItalic:()=>({commands:e})=>e.unsetMark(this.name)}},markdownTokenName:`em`,parseMarkdown:(e,t)=>t.applyMark(`italic`,t.parseInline(e.tokens||[])),markdownOptions:{htmlReopen:{open:``,close:``}},renderMarkdown:(e,t)=>`*${t.renderChildren(e)}*`,addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[fp({find:Wp,type:this.type}),fp({find:Kp,type:this.type})]},addPasteRules(){return[gp({find:Gp,type:this.type}),gp({find:qp,type:this.type})]}}),Yp=`aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2odyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos6kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rck0msd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12b0cam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2oodside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2`,Xp=`ελ1υ2бг1ел3дети4ею2католик6ом3мкд2он1сква6онлайн5рг3рус2ф2сайт3рб3укр3қаз3հայ3ישראל5קום3ابوظبي5رامكو5لاردن4بحرين5جزائر5سعودية6عليان5مغرب5مارات5یران5بارت2زار4يتك3ھارت5تونس4سودان3رية5شبكة4عراق2ب2مان4فلسطين6قطر3كاثوليك6وم3مصر2ليسيا5وريتانيا7قع4همراه5پاکستان7ڀارت4कॉम3नेट3भारत0म्3ोत5संगठन5বাংলা5ভারত2ৰত4ਭਾਰਤ4ભારત4ଭାରତ4இந்தியா6லங்கை6சிங்கப்பூர்11భారత్5ಭಾರತ4ഭാരതം5ලංකා4คอม3ไทย3ລາວ3გე2みんな3アマゾン4クラウド4グーグル4コム2ストア3セール3ファッション6ポイント4世界2中信1国1國1文网3亚马逊3企业2佛山2信息2健康2八卦2公司1益2台湾1灣2商城1店1标2嘉里0大酒店5在线2大拿2天主教3娱乐2家電2广东2微博2慈善2我爱你3手机2招聘2政务1府2新加坡2闻2时尚2書籍2机构2淡马锡3游戏2澳門2点看2移动2组织机构4网址1店1站1络2联通2谷歌2购物2通販2集团2電訊盈科4飞利浦3食品2餐厅2香格里拉3港2닷넷1컴2삼성2한국2`,Zp=`numeric`,Qp=`ascii`,$p=`alpha`,em=`asciinumeric`,tm=`alphanumeric`,nm=`domain`,rm=`emoji`,im=`scheme`,am=`slashscheme`,om=`whitespace`;function sm(e,t){return e in t||(t[e]=[]),t[e]}function cm(e,t,n){t[Zp]&&(t[em]=!0,t[tm]=!0),t[Qp]&&(t[em]=!0,t[$p]=!0),t[em]&&(t[tm]=!0),t[$p]&&(t[tm]=!0),t[tm]&&(t[nm]=!0),t[rm]&&(t[nm]=!0);for(let r in t){let t=sm(r,n);t.indexOf(e)<0&&t.push(e)}}function lm(e,t){let n={};for(let r in t)t[r].indexOf(e)>=0&&(n[r]=!0);return n}function um(e=null){this.j={},this.jr=[],this.jd=null,this.t=e}um.groups={},um.prototype={accepts(){return!!this.t},go(e){let t=this,n=t.j[e];if(n)return n;for(let n=0;ne.ta(t,n,r,i),K=(e,t,n,r,i)=>e.tr(t,n,r,i),dm=(e,t,n,r,i)=>e.ts(t,n,r,i),q=(e,t,n,r,i)=>e.tt(t,n,r,i),fm=`WORD`,pm=`UWORD`,mm=`ASCIINUMERICAL`,hm=`ALPHANUMERICAL`,gm=`LOCALHOST`,_m=`TLD`,vm=`UTLD`,ym=`SCHEME`,bm=`SLASH_SCHEME`,xm=`NUM`,Sm=`WS`,Cm=`NL`,wm=`OPENBRACE`,Tm=`CLOSEBRACE`,Em=`OPENBRACKET`,Dm=`CLOSEBRACKET`,Om=`OPENPAREN`,km=`CLOSEPAREN`,Am=`OPENANGLEBRACKET`,jm=`CLOSEANGLEBRACKET`,Mm=`FULLWIDTHLEFTPAREN`,Nm=`FULLWIDTHRIGHTPAREN`,Pm=`LEFTCORNERBRACKET`,Fm=`RIGHTCORNERBRACKET`,Im=`LEFTWHITECORNERBRACKET`,Lm=`RIGHTWHITECORNERBRACKET`,Rm=`FULLWIDTHLESSTHAN`,zm=`FULLWIDTHGREATERTHAN`,Bm=`AMPERSAND`,Vm=`APOSTROPHE`,Hm=`ASTERISK`,Um=`AT`,Wm=`BACKSLASH`,Gm=`BACKTICK`,Km=`CARET`,qm=`COLON`,Jm=`COMMA`,Ym=`DOLLAR`,Xm=`DOT`,Zm=`EQUALS`,Qm=`EXCLAMATION`,$m=`HYPHEN`,eh=`PERCENT`,th=`PIPE`,nh=`PLUS`,rh=`POUND`,ih=`QUERY`,ah=`QUOTE`,oh=`FULLWIDTHMIDDLEDOT`,sh=`SEMI`,ch=`SLASH`,lh=`TILDE`,uh=`UNDERSCORE`,dh=`EMOJI`,fh=`SYM`,ph=Object.freeze({__proto__:null,ALPHANUMERICAL:hm,AMPERSAND:Bm,APOSTROPHE:Vm,ASCIINUMERICAL:mm,ASTERISK:Hm,AT:Um,BACKSLASH:Wm,BACKTICK:Gm,CARET:Km,CLOSEANGLEBRACKET:jm,CLOSEBRACE:Tm,CLOSEBRACKET:Dm,CLOSEPAREN:km,COLON:qm,COMMA:Jm,DOLLAR:Ym,DOT:Xm,EMOJI:dh,EQUALS:Zm,EXCLAMATION:Qm,FULLWIDTHGREATERTHAN:zm,FULLWIDTHLEFTPAREN:Mm,FULLWIDTHLESSTHAN:Rm,FULLWIDTHMIDDLEDOT:oh,FULLWIDTHRIGHTPAREN:Nm,HYPHEN:$m,LEFTCORNERBRACKET:Pm,LEFTWHITECORNERBRACKET:Im,LOCALHOST:gm,NL:Cm,NUM:xm,OPENANGLEBRACKET:Am,OPENBRACE:wm,OPENBRACKET:Em,OPENPAREN:Om,PERCENT:eh,PIPE:th,PLUS:nh,POUND:rh,QUERY:ih,QUOTE:ah,RIGHTCORNERBRACKET:Fm,RIGHTWHITECORNERBRACKET:Lm,SCHEME:ym,SEMI:sh,SLASH:ch,SLASH_SCHEME:bm,SYM:fh,TILDE:lh,TLD:_m,UNDERSCORE:uh,UTLD:vm,UWORD:pm,WORD:fm,WS:Sm}),mh=/[a-z]/,hh=/[a-z]/i,gh=/[\u{1F000}-\u{1FAFF}\u{2600}-\u{27BF}]|\u{FE0F}/u;try{hh=RegExp(`\\p{L}`,`u`),gh=RegExp(`\\p{Emoji}`,`u`)}catch{}var _h=/\d/,vh=/\s/,yh=`\r`,bh=` -`,xh=`️`,Sh=`‍`,Ch=``,wh=null,Th=null;function Eh(e=[]){let t={};um.groups=t;let n=new um;wh??=Ah(Yp),Th??=Ah(Xp),q(n,`'`,Vm),q(n,`{`,wm),q(n,`}`,Tm),q(n,`[`,Em),q(n,`]`,Dm),q(n,`(`,Om),q(n,`)`,km),q(n,`<`,Am),q(n,`>`,jm),q(n,`(`,Mm),q(n,`)`,Nm),q(n,`「`,Pm),q(n,`」`,Fm),q(n,`『`,Im),q(n,`』`,Lm),q(n,`<`,Rm),q(n,`>`,zm),q(n,`&`,Bm),q(n,`*`,Hm),q(n,`@`,Um),q(n,"`",Gm),q(n,`^`,Km),q(n,`:`,qm),q(n,`,`,Jm),q(n,`$`,Ym),q(n,`.`,Xm),q(n,`=`,Zm),q(n,`!`,Qm),q(n,`-`,$m),q(n,`%`,eh),q(n,`|`,th),q(n,`+`,nh),q(n,`#`,rh),q(n,`?`,ih),q(n,`"`,ah),q(n,`/`,ch),q(n,`;`,sh),q(n,`~`,lh),q(n,`_`,uh),q(n,`\\`,Wm),q(n,`・`,oh);let r=K(n,_h,xm,{[Zp]:!0});K(r,_h,r);let i=K(r,mh,mm,{[em]:!0}),a=K(r,hh,hm,{[tm]:!0}),o=K(n,mh,fm,{[Qp]:!0});K(o,_h,i),K(o,mh,o),K(i,_h,i),K(i,mh,i);let s=K(n,hh,pm,{[$p]:!0});K(s,mh),K(s,_h,a),K(s,hh,s),K(a,_h,a),K(a,mh),K(a,hh,a);let c=q(n,bh,Cm,{[om]:!0}),l=q(n,yh,Sm,{[om]:!0}),u=K(n,vh,Sm,{[om]:!0});q(n,Ch,u),q(l,bh,c),q(l,Ch,u),K(l,vh,u),q(u,yh),q(u,bh),K(u,vh,u),q(u,Ch,u);let d=K(n,gh,dh,{[rm]:!0});q(d,`#`),K(d,gh,d),q(d,xh,d);let f=q(d,Sh);q(f,`#`),K(f,gh,d);let p=[[mh,o],[_h,i]],m=[[mh,null],[hh,s],[_h,a]];for(let e=0;ee[0]>t[0]?1:-1);for(let t=0;t=0?i[nm]=!0:mh.test(r)?_h.test(r)?i[em]=!0:i[Qp]=!0:i[Zp]=!0,dm(n,r,r,i)}return dm(n,`localhost`,gm,{ascii:!0}),n.jd=new um(fh),{start:n,tokens:Object.assign({groups:t},ph)}}function Dh(e,t){let n=Oh(t.replace(/[A-Z]/g,e=>e.toLowerCase())),r=n.length,i=[],a=0,o=0;for(;o=0&&(d+=n[o].length,f++),l+=n[o].length,a+=n[o].length,o++;a-=d,o-=f,l-=d,i.push({t:u.t,v:t.slice(a-l,a),s:a-l,e:a})}return i}function Oh(e){let t=[],n=e.length,r=0;for(;r56319||r+1===n||(a=e.charCodeAt(r+1))<56320||a>57343?e[r]:e.slice(r,r+2);t.push(o),r+=o.length}return t}function kh(e,t,n,r,i){let a,o=t.length;for(let n=0;n=0;)i++;if(i>0){t.push(n.join(``));for(let t=parseInt(e.substring(r,r+i),10);t>0;t--)n.pop();r+=i}else n.push(e[r]),r++}return t}var jh={defaultProtocol:`http`,events:null,format:Nh,formatHref:Nh,nl2br:!1,tagName:`a`,target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],ignoreClasses:[],render:null};function Mh(e,t=null){let n=Object.assign({},jh);e&&(n=Object.assign(n,e instanceof Mh?e.o:e));let r=n.ignoreTags,i=[];for(let e=0;e=0)return!0;return!1},defaultRender(e){return e},check(e){return this.get(`validate`,e.toString(),e)},get(e,t,n){let r=t!=null,i=this.o[e];return i&&(typeof i==`object`?(i=n.t in i?i[n.t]:jh[e],typeof i==`function`&&r&&(i=i(t,n))):typeof i==`function`&&r&&(i=i(t,n.t,n)),i)},getObj(e,t,n){let r=this.o[e];return typeof r==`function`&&t!=null&&(r=r(t,n.t,n)),r},render(e){let t=e.render(this);return(this.get(`render`,null,e)||this.defaultRender)(t,e.t,e)}};function Nh(e){return e}function Ph(e,t){this.t=`token`,this.v=e,this.tk=t}Ph.prototype={isLink:!1,toString(){return this.v},toHref(e){return this.toString()},toFormattedString(e){let t=this.toString(),n=e.get(`truncate`,t,this),r=e.get(`format`,t,this);return n&&r.length>n?r.substring(0,n)+`…`:r},toFormattedHref(e){return e.get(`formatHref`,this.toHref(e.get(`defaultProtocol`)),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(e=jh.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(e),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(e){return{type:this.t,value:this.toFormattedString(e),isLink:this.isLink,href:this.toFormattedHref(e),start:this.startIndex(),end:this.endIndex()}},validate(e){return e.get(`validate`,this.toString(),this)},render(e){let t=this,n=this.toHref(e.get(`defaultProtocol`)),r=e.get(`formatHref`,n,this),i=e.get(`tagName`,n,t),a=this.toFormattedString(e),o={},s=e.get(`className`,n,t),c=e.get(`target`,n,t),l=e.get(`rel`,n,t),u=e.getObj(`attributes`,n,t),d=e.getObj(`events`,n,t);return o.href=r,s&&(o.class=s),c&&(o.target=c),l&&(o.rel=l),u&&Object.assign(o,u),{tagName:i,attributes:o,content:a,eventListeners:d}}};function Fh(e,t){class n extends Ph{constructor(t,n){super(t,n),this.t=e}}for(let e in t)n.prototype[e]=t[e];return n.t=e,n}var Ih=Fh(`email`,{isLink:!0,toHref(){return`mailto:`+this.toString()}}),Lh=Fh(`text`),Rh=Fh(`nl`),zh=Fh(`url`,{isLink:!0,toHref(e=jh.defaultProtocol){return this.hasProtocol()?this.v:`${e}://${this.v}`},hasProtocol(){let e=this.tk;return e.length>=2&&e[0].t!==gm&&e[1].t===qm}}),Bh=e=>new um(e);function Vh({groups:e}){let t=e.domain.concat([Bm,Hm,Um,Wm,Gm,Km,Ym,Zm,$m,xm,eh,th,nh,rh,ch,fh,lh,uh]),n=[Vm,qm,Jm,Xm,Qm,eh,ih,ah,sh,Am,jm,wm,Tm,Dm,Em,Om,km,Mm,Nm,Pm,Fm,Im,Lm,Rm,zm],r=[Bm,Vm,Hm,Wm,Gm,Km,Ym,Zm,$m,wm,Tm,eh,th,nh,rh,ih,ch,fh,lh,uh],i=Bh(),a=q(i,lh);G(a,r,a),G(a,e.domain,a);let o=Bh(),s=Bh(),c=Bh();G(i,e.domain,o),G(i,e.scheme,s),G(i,e.slashscheme,c),G(o,r,a),G(o,e.domain,o);let l=q(o,Um);q(a,Um,l),q(s,Um,l),q(c,Um,l);let u=q(a,Xm);G(u,r,a),G(u,e.domain,a);let d=Bh();G(l,e.domain,d),G(d,e.domain,d);let f=q(d,Xm);G(f,e.domain,d);let p=Bh(Ih);G(f,e.tld,p),G(f,e.utld,p),q(l,gm,p);let m=q(d,$m);q(m,$m,m),G(m,e.domain,d),G(p,e.domain,d),q(p,Xm,f),q(p,$m,m);let h=q(o,$m),g=q(o,Xm);q(h,$m,h),G(h,e.domain,o),G(g,r,a),G(g,e.domain,o);let _=Bh(zh);G(g,e.tld,_),G(g,e.utld,_),G(_,e.domain,o),G(_,r,a),q(_,Xm,g),q(_,$m,h),q(_,Um,l);let v=q(_,qm),y=Bh(zh);G(v,e.numeric,y);let b=Bh(zh),x=Bh();G(b,t,b),G(b,n,x),G(x,t,b),G(x,n,x),q(_,ch,b),q(y,ch,b),q(_,ih,x),q(_,rh,b),q(y,ih,x),q(y,rh,b);let S=q(s,qm),C=q(q(q(c,qm),ch),ch);G(s,e.domain,o),q(s,Xm,g),q(s,$m,h),G(c,e.domain,o),q(c,Xm,g),q(c,$m,h),G(S,e.domain,b),q(S,ch,b),q(S,ih,b),G(C,e.domain,b),G(C,t,b),q(C,ch,b);let w=[[wm,Tm],[Em,Dm],[Om,km],[Am,jm],[Mm,Nm],[Pm,Fm],[Im,Lm],[Rm,zm]];for(let e=0;e=0&&p++,m.push(c),s[i]&&s[i].has(c))break;for(let e=0,t=i-m.length+1;e0&&(a.push(Uh(Lh,t,o)),o=[]),i-=p,d-=p;let e=f.t,r=n.slice(i-d,i);a.push(Uh(e,t,r))}}return o.length>0&&a.push(Uh(Lh,t,o)),a}function Uh(e,t,n){let r=n[0].s,i=n[n.length-1].e;return new e(t.slice(r,i),n)}var Wh=typeof console<`u`&&console&&console.warn||(()=>{}),Gh=`until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.`,J={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function Kh(){return um.groups={},J.scanner=null,J.parser=null,J.tokenQueue=[],J.pluginQueue=[],J.customSchemes=[],J.initialized=!1,J}function qh(e,t=!1){if(J.initialized&&Wh(`linkifyjs: already initialized - will not register custom scheme "${e}" ${Gh}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(e))throw Error(`linkifyjs: incorrect scheme format. +`,parseMarkdown:()=>({type:`hardBreak`}),addCommands(){return{setHardBreak:()=>({commands:e,chain:t,state:n,editor:r})=>e.first([()=>e.exitCode(),()=>e.command(()=>{let{selection:e,storedMarks:i}=n;if(e.$from.parent.type.spec.isolating)return!1;let{keepMarks:a}=this.options,{splittableMarks:o}=r.extensionManager,s=i||e.$to.parentOffset&&e.$from.marks();return t().insertContent({type:this.name}).command(({tr:e,dispatch:t})=>{if(t&&s&&a){let t=s.filter(e=>o.includes(e.type.name));e.ensureMarks(t)}return!0}).scrollIntoView().run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),Wp=H.create({name:`heading`,addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:`inline*`,group:`block`,defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(e=>({tag:`h${e}`,attrs:{level:e}}))},renderHTML({node:e,HTMLAttributes:t}){return[`h${this.options.levels.includes(e.attrs.level)?e.attrs.level:this.options.levels[0]}`,B(this.options.HTMLAttributes,t),0]},parseMarkdown(e,t){let n=e.depth||1;return this.options.levels.includes(n)?t.createNode(`heading`,{level:n},t.parseInline(e.tokens||[])):t.createNode(`paragraph`,void 0,t.parseInline(e.tokens||[]))},renderMarkdown:(e,t)=>{let n=e.attrs?.level?parseInt(e.attrs.level,10):1,r=`#`.repeat(n);return e.content?`${r} ${t.renderChildren(e.content)}`:``},addCommands(){return{setHeading:e=>({commands:t})=>this.options.levels.includes(e.level)?t.setNode(this.name,e):!1,toggleHeading:e=>({commands:t})=>this.options.levels.includes(e.level)?t.toggleNode(this.name,`paragraph`,e):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((e,t)=>({...e,[`Mod-Alt-${t}`]:()=>this.editor.commands.toggleHeading({level:t})}),{})},addInputRules(){return this.options.levels.map(e=>gp({find:RegExp(`^(#{${Math.min(...this.options.levels)},${e}})\\s$`),type:this.type,getAttributes:{level:e}}))}}),Gp=H.create({name:`horizontalRule`,addOptions(){return{HTMLAttributes:{},nextNodeType:`paragraph`}},group:`block`,parseHTML(){return[{tag:`hr`}]},renderHTML({HTMLAttributes:e}){return[`hr`,B(this.options.HTMLAttributes,e)]},markdownTokenName:`hr`,parseMarkdown:(e,t)=>t.createNode(`horizontalRule`),renderMarkdown:()=>`---`,addCommands(){return{setHorizontalRule:()=>({chain:e,state:t})=>{if(!yf(t,t.schema.nodes[this.name]))return!1;let{selection:n}=t,{$to:r}=n,i=e();return id(n)?i.insertContentAt(r.pos,{type:this.name}):i.insertContent({type:this.name}),i.command(({state:e,tr:t,dispatch:n})=>{if(n){let{$to:n}=t.selection,r=n.end();if(n.nodeAfter)n.nodeAfter.isTextblock?t.setSelection(A.create(t.doc,n.pos+1)):n.nodeAfter.isBlock?t.setSelection(j.create(t.doc,n.pos)):t.setSelection(A.create(t.doc,n.pos));else{let i=(e.schema.nodes[this.options.nextNodeType]||n.parent.type.contentMatch.defaultType)?.create();i&&(t.insert(r,i),t.setSelection(A.create(t.doc,r+1)))}t.scrollIntoView()}return!0}).run()}}},addInputRules(){return[hp({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),Kp=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,qp=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,Jp=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,Yp=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,Xp=Wf.create({name:`italic`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`em`},{tag:`i`,getAttrs:e=>e.style.fontStyle!==`normal`&&null},{style:`font-style=normal`,clearMark:e=>e.type.name===this.name},{style:`font-style=italic`}]},renderHTML({HTMLAttributes:e}){return[`em`,B(this.options.HTMLAttributes,e),0]},addCommands(){return{setItalic:()=>({commands:e})=>e.setMark(this.name),toggleItalic:()=>({commands:e})=>e.toggleMark(this.name),unsetItalic:()=>({commands:e})=>e.unsetMark(this.name)}},markdownTokenName:`em`,parseMarkdown:(e,t)=>t.applyMark(`italic`,t.parseInline(e.tokens||[])),markdownOptions:{htmlReopen:{open:``,close:``}},renderMarkdown:(e,t)=>`*${t.renderChildren(e)}*`,addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[mp({find:Kp,type:this.type}),mp({find:Jp,type:this.type})]},addPasteRules(){return[vp({find:qp,type:this.type}),vp({find:Yp,type:this.type})]}}),Zp=`aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2odyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos6kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rck0msd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12b0cam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2oodside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2`,Qp=`ελ1υ2бг1ел3дети4ею2католик6ом3мкд2он1сква6онлайн5рг3рус2ф2сайт3рб3укр3қаз3հայ3ישראל5קום3ابوظبي5رامكو5لاردن4بحرين5جزائر5سعودية6عليان5مغرب5مارات5یران5بارت2زار4يتك3ھارت5تونس4سودان3رية5شبكة4عراق2ب2مان4فلسطين6قطر3كاثوليك6وم3مصر2ليسيا5وريتانيا7قع4همراه5پاکستان7ڀارت4कॉम3नेट3भारत0म्3ोत5संगठन5বাংলা5ভারত2ৰত4ਭਾਰਤ4ભારત4ଭାରତ4இந்தியா6லங்கை6சிங்கப்பூர்11భారత్5ಭಾರತ4ഭാരതം5ලංකා4คอม3ไทย3ລາວ3გე2みんな3アマゾン4クラウド4グーグル4コム2ストア3セール3ファッション6ポイント4世界2中信1国1國1文网3亚马逊3企业2佛山2信息2健康2八卦2公司1益2台湾1灣2商城1店1标2嘉里0大酒店5在线2大拿2天主教3娱乐2家電2广东2微博2慈善2我爱你3手机2招聘2政务1府2新加坡2闻2时尚2書籍2机构2淡马锡3游戏2澳門2点看2移动2组织机构4网址1店1站1络2联通2谷歌2购物2通販2集团2電訊盈科4飞利浦3食品2餐厅2香格里拉3港2닷넷1컴2삼성2한국2`,$p=`numeric`,em=`ascii`,tm=`alpha`,nm=`asciinumeric`,rm=`alphanumeric`,im=`domain`,am=`emoji`,om=`scheme`,sm=`slashscheme`,cm=`whitespace`;function lm(e,t){return e in t||(t[e]=[]),t[e]}function um(e,t,n){t[$p]&&(t[nm]=!0,t[rm]=!0),t[em]&&(t[nm]=!0,t[tm]=!0),t[nm]&&(t[rm]=!0),t[tm]&&(t[rm]=!0),t[rm]&&(t[im]=!0),t[am]&&(t[im]=!0);for(let r in t){let t=lm(r,n);t.indexOf(e)<0&&t.push(e)}}function dm(e,t){let n={};for(let r in t)t[r].indexOf(e)>=0&&(n[r]=!0);return n}function fm(e=null){this.j={},this.jr=[],this.jd=null,this.t=e}fm.groups={},fm.prototype={accepts(){return!!this.t},go(e){let t=this,n=t.j[e];if(n)return n;for(let n=0;ne.ta(t,n,r,i),W=(e,t,n,r,i)=>e.tr(t,n,r,i),pm=(e,t,n,r,i)=>e.ts(t,n,r,i),G=(e,t,n,r,i)=>e.tt(t,n,r,i),mm=`WORD`,hm=`UWORD`,gm=`ASCIINUMERICAL`,_m=`ALPHANUMERICAL`,vm=`LOCALHOST`,ym=`TLD`,bm=`UTLD`,xm=`SCHEME`,Sm=`SLASH_SCHEME`,Cm=`NUM`,wm=`WS`,Tm=`NL`,Em=`OPENBRACE`,Dm=`CLOSEBRACE`,Om=`OPENBRACKET`,km=`CLOSEBRACKET`,Am=`OPENPAREN`,jm=`CLOSEPAREN`,Mm=`OPENANGLEBRACKET`,Nm=`CLOSEANGLEBRACKET`,Pm=`FULLWIDTHLEFTPAREN`,Fm=`FULLWIDTHRIGHTPAREN`,Im=`LEFTCORNERBRACKET`,Lm=`RIGHTCORNERBRACKET`,Rm=`LEFTWHITECORNERBRACKET`,zm=`RIGHTWHITECORNERBRACKET`,Bm=`FULLWIDTHLESSTHAN`,Vm=`FULLWIDTHGREATERTHAN`,Hm=`AMPERSAND`,Um=`APOSTROPHE`,Wm=`ASTERISK`,Gm=`AT`,Km=`BACKSLASH`,qm=`BACKTICK`,Jm=`CARET`,Ym=`COLON`,Xm=`COMMA`,Zm=`DOLLAR`,Qm=`DOT`,$m=`EQUALS`,eh=`EXCLAMATION`,th=`HYPHEN`,nh=`PERCENT`,rh=`PIPE`,ih=`PLUS`,ah=`POUND`,oh=`QUERY`,sh=`QUOTE`,ch=`FULLWIDTHMIDDLEDOT`,lh=`SEMI`,uh=`SLASH`,dh=`TILDE`,fh=`UNDERSCORE`,ph=`EMOJI`,mh=`SYM`,hh=Object.freeze({__proto__:null,ALPHANUMERICAL:_m,AMPERSAND:Hm,APOSTROPHE:Um,ASCIINUMERICAL:gm,ASTERISK:Wm,AT:Gm,BACKSLASH:Km,BACKTICK:qm,CARET:Jm,CLOSEANGLEBRACKET:Nm,CLOSEBRACE:Dm,CLOSEBRACKET:km,CLOSEPAREN:jm,COLON:Ym,COMMA:Xm,DOLLAR:Zm,DOT:Qm,EMOJI:ph,EQUALS:$m,EXCLAMATION:eh,FULLWIDTHGREATERTHAN:Vm,FULLWIDTHLEFTPAREN:Pm,FULLWIDTHLESSTHAN:Bm,FULLWIDTHMIDDLEDOT:ch,FULLWIDTHRIGHTPAREN:Fm,HYPHEN:th,LEFTCORNERBRACKET:Im,LEFTWHITECORNERBRACKET:Rm,LOCALHOST:vm,NL:Tm,NUM:Cm,OPENANGLEBRACKET:Mm,OPENBRACE:Em,OPENBRACKET:Om,OPENPAREN:Am,PERCENT:nh,PIPE:rh,PLUS:ih,POUND:ah,QUERY:oh,QUOTE:sh,RIGHTCORNERBRACKET:Lm,RIGHTWHITECORNERBRACKET:zm,SCHEME:xm,SEMI:lh,SLASH:uh,SLASH_SCHEME:Sm,SYM:mh,TILDE:dh,TLD:ym,UNDERSCORE:fh,UTLD:bm,UWORD:hm,WORD:mm,WS:wm}),gh=/[a-z]/,_h=/[a-z]/i,vh=/[\u{1F000}-\u{1FAFF}\u{2600}-\u{27BF}]|\u{FE0F}/u;try{_h=RegExp(`\\p{L}`,`u`),vh=RegExp(`\\p{Emoji}`,`u`)}catch{}var yh=/\d/,bh=/\s/,xh=`\r`,Sh=` +`,Ch=`️`,wh=`‍`,Th=``,Eh=null,Dh=null;function Oh(e=[]){let t={};fm.groups=t;let n=new fm;Eh??=Mh(Zp),Dh??=Mh(Qp),G(n,`'`,Um),G(n,`{`,Em),G(n,`}`,Dm),G(n,`[`,Om),G(n,`]`,km),G(n,`(`,Am),G(n,`)`,jm),G(n,`<`,Mm),G(n,`>`,Nm),G(n,`(`,Pm),G(n,`)`,Fm),G(n,`「`,Im),G(n,`」`,Lm),G(n,`『`,Rm),G(n,`』`,zm),G(n,`<`,Bm),G(n,`>`,Vm),G(n,`&`,Hm),G(n,`*`,Wm),G(n,`@`,Gm),G(n,"`",qm),G(n,`^`,Jm),G(n,`:`,Ym),G(n,`,`,Xm),G(n,`$`,Zm),G(n,`.`,Qm),G(n,`=`,$m),G(n,`!`,eh),G(n,`-`,th),G(n,`%`,nh),G(n,`|`,rh),G(n,`+`,ih),G(n,`#`,ah),G(n,`?`,oh),G(n,`"`,sh),G(n,`/`,uh),G(n,`;`,lh),G(n,`~`,dh),G(n,`_`,fh),G(n,`\\`,Km),G(n,`・`,ch);let r=W(n,yh,Cm,{[$p]:!0});W(r,yh,r);let i=W(r,gh,gm,{[nm]:!0}),a=W(r,_h,_m,{[rm]:!0}),o=W(n,gh,mm,{[em]:!0});W(o,yh,i),W(o,gh,o),W(i,yh,i),W(i,gh,i);let s=W(n,_h,hm,{[tm]:!0});W(s,gh),W(s,yh,a),W(s,_h,s),W(a,yh,a),W(a,gh),W(a,_h,a);let c=G(n,Sh,Tm,{[cm]:!0}),l=G(n,xh,wm,{[cm]:!0}),u=W(n,bh,wm,{[cm]:!0});G(n,Th,u),G(l,Sh,c),G(l,Th,u),W(l,bh,u),G(u,xh),G(u,Sh),W(u,bh,u),G(u,Th,u);let d=W(n,vh,ph,{[am]:!0});G(d,`#`),W(d,vh,d),G(d,Ch,d);let f=G(d,wh);G(f,`#`),W(f,vh,d);let p=[[gh,o],[yh,i]],m=[[gh,null],[_h,s],[yh,a]];for(let e=0;ee[0]>t[0]?1:-1);for(let t=0;t=0?i[im]=!0:gh.test(r)?yh.test(r)?i[nm]=!0:i[em]=!0:i[$p]=!0,pm(n,r,r,i)}return pm(n,`localhost`,vm,{ascii:!0}),n.jd=new fm(mh),{start:n,tokens:Object.assign({groups:t},hh)}}function kh(e,t){let n=Ah(t.replace(/[A-Z]/g,e=>e.toLowerCase())),r=n.length,i=[],a=0,o=0;for(;o=0&&(d+=n[o].length,f++),l+=n[o].length,a+=n[o].length,o++;a-=d,o-=f,l-=d,i.push({t:u.t,v:t.slice(a-l,a),s:a-l,e:a})}return i}function Ah(e){let t=[],n=e.length,r=0;for(;r56319||r+1===n||(a=e.charCodeAt(r+1))<56320||a>57343?e[r]:e.slice(r,r+2);t.push(o),r+=o.length}return t}function jh(e,t,n,r,i){let a,o=t.length;for(let n=0;n=0;)i++;if(i>0){t.push(n.join(``));for(let t=parseInt(e.substring(r,r+i),10);t>0;t--)n.pop();r+=i}else n.push(e[r]),r++}return t}var Nh={defaultProtocol:`http`,events:null,format:Fh,formatHref:Fh,nl2br:!1,tagName:`a`,target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],ignoreClasses:[],render:null};function Ph(e,t=null){let n=Object.assign({},Nh);e&&(n=Object.assign(n,e instanceof Ph?e.o:e));let r=n.ignoreTags,i=[];for(let e=0;e=0)return!0;return!1},defaultRender(e){return e},check(e){return this.get(`validate`,e.toString(),e)},get(e,t,n){let r=t!=null,i=this.o[e];return i&&(typeof i==`object`?(i=n.t in i?i[n.t]:Nh[e],typeof i==`function`&&r&&(i=i(t,n))):typeof i==`function`&&r&&(i=i(t,n.t,n)),i)},getObj(e,t,n){let r=this.o[e];return typeof r==`function`&&t!=null&&(r=r(t,n.t,n)),r},render(e){let t=e.render(this);return(this.get(`render`,null,e)||this.defaultRender)(t,e.t,e)}};function Fh(e){return e}function Ih(e,t){this.t=`token`,this.v=e,this.tk=t}Ih.prototype={isLink:!1,toString(){return this.v},toHref(e){return this.toString()},toFormattedString(e){let t=this.toString(),n=e.get(`truncate`,t,this),r=e.get(`format`,t,this);return n&&r.length>n?r.substring(0,n)+`…`:r},toFormattedHref(e){return e.get(`formatHref`,this.toHref(e.get(`defaultProtocol`)),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(e=Nh.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(e),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(e){return{type:this.t,value:this.toFormattedString(e),isLink:this.isLink,href:this.toFormattedHref(e),start:this.startIndex(),end:this.endIndex()}},validate(e){return e.get(`validate`,this.toString(),this)},render(e){let t=this,n=this.toHref(e.get(`defaultProtocol`)),r=e.get(`formatHref`,n,this),i=e.get(`tagName`,n,t),a=this.toFormattedString(e),o={},s=e.get(`className`,n,t),c=e.get(`target`,n,t),l=e.get(`rel`,n,t),u=e.getObj(`attributes`,n,t),d=e.getObj(`events`,n,t);return o.href=r,s&&(o.class=s),c&&(o.target=c),l&&(o.rel=l),u&&Object.assign(o,u),{tagName:i,attributes:o,content:a,eventListeners:d}}};function Lh(e,t){class n extends Ih{constructor(t,n){super(t,n),this.t=e}}for(let e in t)n.prototype[e]=t[e];return n.t=e,n}var Rh=Lh(`email`,{isLink:!0,toHref(){return`mailto:`+this.toString()}}),zh=Lh(`text`),Bh=Lh(`nl`),Vh=Lh(`url`,{isLink:!0,toHref(e=Nh.defaultProtocol){return this.hasProtocol()?this.v:`${e}://${this.v}`},hasProtocol(){let e=this.tk;return e.length>=2&&e[0].t!==vm&&e[1].t===Ym}}),Hh=e=>new fm(e);function Uh({groups:e}){let t=e.domain.concat([Hm,Wm,Gm,Km,qm,Jm,Zm,$m,th,Cm,nh,rh,ih,ah,uh,mh,dh,fh]),n=[Um,Ym,Xm,Qm,eh,nh,oh,sh,lh,Mm,Nm,Em,Dm,km,Om,Am,jm,Pm,Fm,Im,Lm,Rm,zm,Bm,Vm],r=[Hm,Um,Wm,Km,qm,Jm,Zm,$m,th,Em,Dm,nh,rh,ih,ah,oh,uh,mh,dh,fh],i=Hh(),a=G(i,dh);U(a,r,a),U(a,e.domain,a);let o=Hh(),s=Hh(),c=Hh();U(i,e.domain,o),U(i,e.scheme,s),U(i,e.slashscheme,c),U(o,r,a),U(o,e.domain,o);let l=G(o,Gm);G(a,Gm,l),G(s,Gm,l),G(c,Gm,l);let u=G(a,Qm);U(u,r,a),U(u,e.domain,a);let d=Hh();U(l,e.domain,d),U(d,e.domain,d);let f=G(d,Qm);U(f,e.domain,d);let p=Hh(Rh);U(f,e.tld,p),U(f,e.utld,p),G(l,vm,p);let m=G(d,th);G(m,th,m),U(m,e.domain,d),U(p,e.domain,d),G(p,Qm,f),G(p,th,m);let h=G(o,th),g=G(o,Qm);G(h,th,h),U(h,e.domain,o),U(g,r,a),U(g,e.domain,o);let _=Hh(Vh);U(g,e.tld,_),U(g,e.utld,_),U(_,e.domain,o),U(_,r,a),G(_,Qm,g),G(_,th,h),G(_,Gm,l);let v=G(_,Ym),y=Hh(Vh);U(v,e.numeric,y);let b=Hh(Vh),x=Hh();U(b,t,b),U(b,n,x),U(x,t,b),U(x,n,x),G(_,uh,b),G(y,uh,b),G(_,oh,x),G(_,ah,b),G(y,oh,x),G(y,ah,b);let S=G(s,Ym),C=G(G(G(c,Ym),uh),uh);U(s,e.domain,o),G(s,Qm,g),G(s,th,h),U(c,e.domain,o),G(c,Qm,g),G(c,th,h),U(S,e.domain,b),G(S,uh,b),G(S,oh,b),U(C,e.domain,b),U(C,t,b),G(C,uh,b);let w=[[Em,Dm],[Om,km],[Am,jm],[Mm,Nm],[Pm,Fm],[Im,Lm],[Rm,zm],[Bm,Vm]];for(let e=0;e=0&&p++,m.push(c),s[i]&&s[i].has(c))break;for(let e=0,t=i-m.length+1;e0&&(a.push(Gh(zh,t,o)),o=[]),i-=p,d-=p;let e=f.t,r=n.slice(i-d,i);a.push(Gh(e,t,r))}}return o.length>0&&a.push(Gh(zh,t,o)),a}function Gh(e,t,n){let r=n[0].s,i=n[n.length-1].e;return new e(t.slice(r,i),n)}var Kh=typeof console<`u`&&console&&console.warn||(()=>{}),qh=`until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.`,K={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function Jh(){return fm.groups={},K.scanner=null,K.parser=null,K.tokenQueue=[],K.pluginQueue=[],K.customSchemes=[],K.initialized=!1,K}function Yh(e,t=!1){if(K.initialized&&Kh(`linkifyjs: already initialized - will not register custom scheme "${e}" ${qh}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(e))throw Error(`linkifyjs: incorrect scheme format. 1. Must only contain digits, lowercase ASCII letters or "-" 2. Cannot start or end with "-" -3. "-" cannot repeat`);J.customSchemes.push([e,t])}function Jh(){J.scanner=Eh(J.customSchemes);for(let e=0;ee.mark.type===n);if(!o.length)return;let{nodeAfter:s}=r;if(s&&o.some(e=>e.mark.isInSet(s.marks)))return;let c=e.storedMarks;e.removeMark(a,t.to,n),e.setStoredMarks(c),e.selection.empty&&e.selection.from===t.to&&e.removeStoredMark(n)}function rg(e){return e.length===1?e[0].isLink:e.length===3&&e[1].isLink?[`()`,`[]`].includes(e[0].value+e[2].value):!1}function ig(e){return new M({key:new N(`autolink`),appendTransaction:(t,n,r)=>{let i=t.some(e=>e.docChanged)&&!n.doc.eq(r.doc),a=t.some(e=>e.getMeta(`preventAutolink`));if(!i||a)return;let{tr:o}=r,s=au(n.doc,[...t]);if(!t.some(zc)){let t=[];s.steps.forEach((e,n)=>{if(!(e instanceof St)||!e.slice.size)return;let r=s.mapping.slice(n+1),i=r.map(e.from,1),a=r.map(e.from+e.slice.size,-1);it.to-e.to),t.forEach(t=>ng(o,t,e.type))}if(Hu(s).forEach(({newRange:t})=>{let n=ou(r.doc,t,e=>e.isTextblock),i,a;if(n.length>1)i=n[0],a=r.doc.textBetween(i.pos,i.pos+i.node.nodeSize,void 0,` `);else if(n.length){let e=r.doc.textBetween(t.from,t.to,` `,` `);if(!$h.test(e))return;i=n[0],a=r.doc.textBetween(i.pos,t.to,void 0,` `)}if(i&&a){let t=a.split(Qh).filter(Boolean);if(t.length<=0)return!1;let n=t[t.length-1],s=i.pos+a.lastIndexOf(n);if(!n)return!1;let c=Yh(n).map(t=>t.toObject(e.defaultProtocol));if(!rg(c))return!1;c.filter(e=>e.isLink).map(e=>({...e,from:s+e.start+1,to:s+e.end+1})).filter(e=>!r.schema.marks.code||!r.doc.rangeHasMark(e.from,e.to,r.schema.marks.code)).filter(t=>e.validate(t.value)).filter(t=>e.shouldAutoLink(t.value)).forEach(t=>{Uu(t.from,t.to,r.doc).some(t=>t.mark.type===e.type)||o.addMark(t.from,t.to,e.type.create({href:t.href}))})}}),o.steps.length)return o}})}function ag(e){return new M({key:new N(`handleClickLink`),props:{handleClick:(t,n,r)=>{if(r.button!==0||!t.editable)return!1;let i=null;if(r.target instanceof HTMLAnchorElement)i=r.target;else{let t=r.target;if(!t)return!1;let n=e.editor.view.dom;i=t.closest(`a`),i&&!n.contains(i)&&(i=null)}if(!i)return!1;let a=!1;if(e.enableClickSelection&&(a=e.editor.commands.extendMarkRange(e.type.name)),e.openOnClick){let n=zu(t.state,e.type.name),r=i.href??n.href,o=i.target??n.target;r&&(window.open(r,o),a=!0)}return a}}})}var og=/\[([^[\]]+)\]\(((?:[^\s()]|\([^\s()]*\))+)(?:\s+(?:(["'])(.*?)\3|“(.*?)”|‘(.*?)’))?\)$/,sg=/\[([^[\]]+)\]\(((?:[^\s()]|\([^\s()]*\))+)(?:\s+(?:(["'])(.*?)\3|“(.*?)”|‘(.*?)’))?\)/g;function cg(e,t){let n=0;for(let r=t-1;r>=0&&e[r]===`\\`;--r)n+=1;return n%2==1}function lg(e,t){let n=0,r=0;for(;r0}function ug(e,t,n){let[,r,i]=t;return(t.index?e[t.index-1]:void 0)===`!`||cg(e,t.index??0)||lg(e,t.index??0)?!1:!!r.trim()&&n(i)}function dg(e){let[t,n,r,,i,a,o]=e,s=i??a??o;return{index:e.index??0,text:t,replaceWith:n,data:{href:r,title:s||null,markdown:!0}}}function fg(e,t){return e.index{let n=og.exec(t);return!n||!ug(t,n,e.isAllowedHref)?null:dg(n)},type:e.type,getAttributes:pg});return new Pf({find:t.find,handler:e=>{let n=t.handler(e);return n!==null&&e.state.tr.steps.length&&e.state.tr.setMeta(`preventAutolink`,!0),n}})}function hg(e){let t=gp({find:t=>{let n=[];for(let r of t.matchAll(sg))ug(t,r,e.isAllowedHref)&&n.push(dg(r));let r=(e.findPlainUrls?.call(e,t)??[]).filter(e=>!n.some(t=>fg(t,e)));return[...n,...r]},type:e.type,getAttributes:pg});return new Uf({find:t.find,handler:e=>{let n=t.handler(e);return n!==null&&e.state.tr.steps.length&&e.match.data?.markdown&&e.state.tr.setMeta(`preventAutolink`,!0),n}})}function gg(e){return new M({key:new N(`handlePasteLink`),props:{handlePaste:(t,n,r)=>{let{shouldAutoLink:i}=e,{state:a}=t,{selection:o}=a,{empty:s}=o;if(s)return!1;let c=``;r.content.forEach(e=>{c+=e.textContent});let l=Xh(c,{defaultProtocol:e.defaultProtocol}).find(e=>e.isLink&&e.value===c);return!c||!l||i!==void 0&&!i(l.value)?!1:e.editor.commands.setMark(e.type,{href:l.href})}}})}function _g(e,t){let n=[`http`,`https`,`ftp`,`ftps`,`mailto`,`tel`,`callto`,`sms`,`cid`,`xmpp`];return t&&t.forEach(e=>{let t=typeof e==`string`?e:e.scheme;t&&n.push(t)}),!e||e.replace(tg,``).match(RegExp(`^(?:(?:${n.map(e=>e.replace(/[-/\\^$*+?.()|[\]{}]/g,`\\$&`)).join(`|`)}):|[^a-z]|[a-z0-9+.\\-]+(?:[^a-z+.\\-:]|$))`,`i`))}var vg=Hf.create({name:`link`,priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate,console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(e=>{typeof e==`string`?qh(e):qh(e.scheme,e.optionalSlashes)})},onDestroy(){Kh()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,enableClickSelection:!1,linkOnPaste:!0,markdownLinks:!1,autolink:!0,protocols:[],defaultProtocol:`http`,HTMLAttributes:{target:`_blank`,rel:`noopener noreferrer nofollow`,class:null},isAllowedUri:(e,t)=>!!_g(e,t.protocols),validate:e=>!!e,shouldAutoLink:e=>{let t=/^[a-z][a-z0-9+.-]*:\/\//i.test(e),n=/^[a-z][a-z0-9+.-]*:/i.test(e);if(t||n&&!e.includes(`@`))return!0;let r=(e.includes(`@`)?e.split(`@`).pop():e).split(/[/?#:]/)[0];return!(/^\d{1,3}(\.\d{1,3}){3}$/.test(r)||!/\./.test(r))}}},addAttributes(){return{href:{default:null,parseHTML(e){return e.getAttribute(`href`)}},target:{default:this.options.HTMLAttributes.target??null},rel:{default:this.options.HTMLAttributes.rel??null},class:{default:this.options.HTMLAttributes.class??null},title:{default:null}}},parseHTML(){return[{tag:`a[href]`,getAttrs:e=>{let t=e.getAttribute(`href`);return!t||!this.options.isAllowedUri(t,{defaultValidate:e=>!!_g(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:e}){return this.options.isAllowedUri(e.href,{defaultValidate:e=>!!_g(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?[`a`,H(this.options.HTMLAttributes,e),0]:[`a`,H(this.options.HTMLAttributes,{...e,href:``}),0]},markdownTokenName:`link`,parseMarkdown:(e,t)=>t.applyMark(`link`,t.parseInline(e.tokens||[]),{href:e.href,title:e.title||null}),renderMarkdown:(e,t)=>{let n=e.attrs?.href??``,r=e.attrs?.title??``,i=t.renderChildren(e);return r?`[${i}](${n} "${r}")`:`[${i}](${n})`},addCommands(){return{setLink:e=>({chain:t})=>{let{href:n}=e;return this.options.isAllowedUri(n,{defaultValidate:e=>!!_g(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?t().setMark(this.name,e).setMeta(`preventAutolink`,!0).run():!1},toggleLink:e=>({chain:t})=>{let{href:n}=e||{};return n&&!this.options.isAllowedUri(n,{defaultValidate:e=>!!_g(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:t().toggleMark(this.name,e,{extendEmptyMarkRange:!0}).setMeta(`preventAutolink`,!0).run()},unsetLink:()=>({chain:e})=>e().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta(`preventAutolink`,!0).run()}},addInputRules(){return this.options.markdownLinks?[mg({type:this.type,isAllowedHref:e=>this.options.isAllowedUri(e,{defaultValidate:e=>!!_g(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})})]:[]},addPasteRules(){let e=e=>{let t=[];if(e){let{protocols:n,defaultProtocol:r}=this.options;Xh(e,{defaultProtocol:r}).filter(e=>e.isLink&&this.options.isAllowedUri(e.value,{defaultValidate:e=>!!_g(e,n),protocols:n,defaultProtocol:r})).forEach(e=>{this.options.shouldAutoLink(e.value)&&t.push({text:e.value,data:{href:e.href},index:e.start})})}return t};return this.options.markdownLinks?[hg({type:this.type,isAllowedHref:e=>this.options.isAllowedUri(e,{defaultValidate:e=>!!_g(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol}),findPlainUrls:e})]:[gp({find:e,type:this.type,getAttributes:e=>({href:e.data?.href})})]},addProseMirrorPlugins(){let e=[],{protocols:t,defaultProtocol:n}=this.options;return this.options.autolink&&e.push(ig({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:e=>this.options.isAllowedUri(e,{defaultValidate:e=>!!_g(e,t),protocols:t,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),e.push(ag({type:this.type,editor:this.editor,openOnClick:this.options.openOnClick===`whenNotEditable`||this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&e.push(gg({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),e}}),yg=vg,bg=`listItem`,xg=`textStyle`,Sg=/^\s*([-+*])\s$/,Cg=W.create({name:`bulletList`,addOptions(){return{itemTypeName:`listItem`,HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:`block list`,content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul`}]},renderHTML({HTMLAttributes:e}){return[`ul`,H(this.options.HTMLAttributes,e),0]},markdownTokenName:`list`,parseMarkdown:(e,t)=>e.type!==`list`||e.ordered?[]:{type:`bulletList`,content:e.items?t.parseChildren(e.items):[]},renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,` -`):``,markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:e,chain:t})=>this.options.keepAttributes?t().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(bg,this.editor.getAttributes(xg)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let e=hp({find:Sg,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(e=hp({find:Sg,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(xg),editor:this.editor})),[e]}}),wg=(e,t,n)=>{let{selection:r}=e;if(!r.empty)return null;let{$from:i}=r;if(!i.parent.isTextblock||i.parentOffset!==i.parent.content.size)return null;let a=-1;for(let e=i.depth;e>0;--e)if(i.node(e).type.name===t){a=e;break}if(a<0)return null;let o=i.node(a),s=i.index(a);if(s+1>=o.childCount)return null;let c=o.child(s+1);if(!n.includes(c.type.name))return null;let l=e.schema.nodes[t],u=!1;if(c.forEach(e=>{e.type===l&&e.childCount>1&&(u=!0)}),!u)return null;let d=e.doc.resolve(i.after()).nodeAfter;if(!d||!n.includes(d.type.name))return null;let f=[];return d.forEach(e=>{f.push(e)}),f.length===0?null:{listItemDepth:a,nestedList:d,nestedListPos:i.after(),insertPos:i.after(a),items:f}},Tg=(e,t,n,r)=>{let i=wg(e,n,r);if(!i)return!1;let{selection:a}=e,{nestedList:o,nestedListPos:s,insertPos:l,items:u}=i,d=e.tr;d.delete(s,s+o.nodeSize);let f=d.mapping.map(l);return d.insert(f,c.from(u)),d.setSelection(a.map(d.doc,d.mapping)),t&&t(d),!0},Eg=(e,t,n)=>Tg(e.state,e.view.dispatch,t,n),Dg=(e,t)=>U.create({name:`${e}BranchingDeleteKeymap`,priority:101,addKeyboardShortcuts(){let n=()=>Eg(this.editor,e,t);return{Delete:n,"Mod-Delete":n}}}),Og=[[1e3,`m`],[900,`cm`],[500,`d`],[400,`cd`],[100,`c`],[90,`xc`],[50,`l`],[40,`xl`],[10,`x`],[9,`ix`],[5,`v`],[4,`iv`],[1,`i`]],kg=`abcdefghijklmnopqrstuvwxyz`,Ag=String.raw`\d+|[ivxlcdmIVXLCDM]+|${`[a-zA-Z]{1,2}`}`;function jg(e){let t=e,n=``;for(let[e,r]of Og)for(;t>=e;)n+=r,t-=e;return n}function Mg(e){return jg(e).toUpperCase()}function Ng(e){let t=e.toLowerCase(),n=0,r=0;for(;n0?t:1}let n=parseInt(e,10);return Number.isNaN(n)?1:n}function zg(e,t){if(e===`numeric`)return String(t);switch(e){case`a`:return Ig(t);case`A`:return Ig(t).toUpperCase();case`i`:return jg(t);case`I`:return Mg(t);default:return String(t)}}function Bg(e){if(e.length===0)return!1;let t=Lg(e[0])??`numeric`,n=Rg(e[0]);if(n<1)return!1;for(let r=0;r(e?.level??qg)>qg;function Yg(e){let t=e.tokens?.[0];return!!(e.text&&e.tokens?.length===1&&t?.type===`list`&&t.ordered&&t.raw===e.text)}function Xg(e,t){return t.tokenizeInline?t.parseInline(t.tokenizeInline(e)):t.parseInline([{type:`text`,raw:e,text:e}])}var Zg=W.create({name:`listItem`,addOptions(){return{HTMLAttributes:{},bulletListTypeName:`bulletList`,orderedListTypeName:`orderedList`}},content:`paragraph block*`,defining:!0,parseHTML(){return[{tag:`li`}]},renderHTML({HTMLAttributes:e}){return[`li`,H(this.options.HTMLAttributes,e),0]},markdownTokenName:`list_item`,parseMarkdown:(e,t)=>{if(e.type!==`list_item`)return[];let n=t.parseBlockChildren??t.parseChildren,r=[];if(e.tokens&&e.tokens.length>0){if(Yg(e))return{type:`listItem`,content:[{type:`paragraph`,content:Xg(e.text||``,t)}]};let[i,...a]=e.tokens;if(i.type===`heading`)return{type:`listItem`,content:[{type:`paragraph`,content:t.parseInline(i.tokens??[])},...a.length>0?n(a):[]]};if(e.tokens.some(e=>e.type===`paragraph`))r=n(e.tokens);else if(i.type===`text`&&i.tokens&&i.tokens.length>0){if(r=[{type:`paragraph`,content:t.parseInline(i.tokens)}],e.tokens.length>1){let t=n(e.tokens.slice(1));r.push(...t)}}else r=n(e.tokens)}return r.length===0&&(r=[{type:`paragraph`,content:[]}]),{type:`listItem`,content:Wg(r)}},renderMarkdown:(e,t,n)=>{let r=e=>{if(e.parentType===`bulletList`)return`- `;if(e.parentType===`orderedList`){var t,n;let r=((t=e.meta)==null||(t=t.parentAttrs)==null?void 0:t.start)||1;return Ug((n=e.meta)==null||(n=n.parentAttrs)==null?void 0:n.type,r-1+(e.index||0),`. `)}return`- `},i=jf(e,t,r,n,{alignNestedToPrefix:n?.parentType===`orderedList`});if(!Gg(e)||!Jg(n))return i;let a=r(n);return`${a}${Kg}${i.slice(a.length)}`},addExtensions(){return[Dg(this.name,[this.options.bulletListTypeName,this.options.orderedListTypeName])]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),Qg=(e,t)=>{let{$from:n}=t.selection,r=z(e,t.schema),i=null,a=n.depth,o=n.pos,s=null;for(;a>0&&s===null;)i=n.node(a),i.type===r?s=a:(--a,--o);return s===null?null:{$pos:t.doc.resolve(o),depth:s}},$g=(e,t)=>{let n=Qg(e,t);if(!n)return!1;let[,r]=Wu(t,e,n.$pos.pos+4);return r},e_=(e,t,n)=>{let{$anchor:r}=e.selection,i=Math.max(0,r.pos-2),a=e.doc.resolve(i).node();return!(!a||!n.includes(a.type.name))},t_=(e,t,n)=>{if(e.commands.undoInputRule())return!0;if(e.state.selection.from!==e.state.selection.to)return!1;if(!Vl(e.state,t)&&e_(e.state,t,n)){let{$anchor:n}=e.state.selection,r=e.state.doc.resolve(n.before()-1),i=[];r.node().descendants((e,n)=>{e.type.name===t&&i.push({node:e,pos:n})});let a=i.at(-1);if(!a)return!1;let o=e.state.doc.resolve(r.start()+a.pos+1);return e.chain().command(({tr:e})=>{let t=o.end();return e.delete(n.before(),n.after()).insert(t,n.parent),e.setSelection(A.create(e.doc,t+1)),!0}).command(({state:e,dispatch:t})=>(Hn(e,t),!0)).run()}if(!Vl(e.state,t)||!Qu(e.state))return!1;let{$from:r}=e.state.selection,i=r.depth-1;return r.node(i).type!==e.schema.nodes[t]||r.index(i)!==0?!1:e.chain().liftListItem(t).run()},n_=(e,t)=>{let n=$g(e,t),r=Qg(e,t);return!r||!n?!1:n>r.depth},r_=(e,t)=>{let n=$g(e,t),r=Qg(e,t);return!r||!n?!1:n!Vl(e.state,t)||!Zu(e.state,t)||!e.state.selection.empty?!1:n_(t,e.state)?e.chain().focus(e.state.selection.from+4).lift(t).joinBackward().run():r_(t,e.state)?e.commands.command(({state:e,dispatch:t})=>Un(e,t)):e.commands.joinItemForward(),a_=(e,t,n)=>{let{state:r}=e,{selection:i}=r;if(!i.empty)return!1;let{$from:a}=i;if(a.parentOffset!==0||!a.parent.isTextblock||Vl(r,t))return!1;let o=Gu(a);if(!o||!n.includes(o.type.name))return!1;let s=o.lastChild;if(!s||s.type.name!==t)return!1;let l=a.parent;if(!s.canReplace(s.childCount,s.childCount,c.from(l)))return!1;let u=a.before(),d=a.after(),f=u-2;return e.commands.command(({tr:e,dispatch:t})=>(t&&(e.delete(u,d).insert(f,c.from(l)),e.setSelection(A.create(e.doc,f+1)),e.scrollIntoView()),!0))},o_=U.create({name:`listKeymap`,addOptions(){return{listTypes:[{itemName:`listItem`,wrapperNames:[`bulletList`,`orderedList`]},{itemName:`taskItem`,wrapperNames:[`taskList`]}]}},addKeyboardShortcuts(){return{Delete:({editor:e})=>{let t=!1;return this.options.listTypes.forEach(({itemName:n})=>{e.state.schema.nodes[n]!==void 0&&i_(e,n)&&(t=!0)}),t},"Mod-Delete":({editor:e})=>{let t=!1;return this.options.listTypes.forEach(({itemName:n})=>{e.state.schema.nodes[n]!==void 0&&i_(e,n)&&(t=!0)}),t},Backspace:({editor:e})=>{let t=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{e.state.schema.nodes[n]!==void 0&&t_(e,n,r)&&(t=!0)}),t},"Mod-Backspace":({editor:e})=>{let t=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{e.state.schema.nodes[n]!==void 0&&t_(e,n,r)&&(t=!0)}),t},Tab:({editor:e})=>{for(let{itemName:t,wrapperNames:n}of this.options.listTypes)if(e.state.schema.nodes[t]!==void 0&&a_(e,t,n))return!0;return!1}}}}),s_=RegExp(`^(\\s*)(${Ag})([.)])\\s+(.*)$`),c_=/^\s/,l_={heading:/^#{1,6}(?:\s|$)/,bulletItem:/^[-+*]\s+/,codeFence:/^(?:```|~~~)/,blockMath:/^\$\$/,thematicBreak:/^(?:(?:-[ \t]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})$/};function u_(e){return s_.test(e.trimStart())}function d_(e){let t=e.trimStart();return l_.bulletItem.test(t)||u_(t)||l_.heading.test(t)||l_.thematicBreak.test(t)&&!t.startsWith(`-`)||/^>\s?/.test(t)||l_.codeFence.test(t)||l_.blockMath.test(t)}function f_(e){return Object.values(l_).some(t=>t.test(e))}function p_(e){let t=[],n=[],r=!1;return e.forEach(e=>{r?n.push(e):e.trim()===``||t.length>0&&d_(e)?(r=!0,n.push(e)):t.push(e)}),{paragraphLines:t,blockLines:n}}function m_(e){let t=[],n=0,r=0;for(;ne.mark.type===n);if(!o.length)return;let{nodeAfter:s}=r;if(s&&o.some(e=>e.mark.isInSet(s.marks)))return;let c=e.storedMarks;e.removeMark(a,t.to,n),e.setStoredMarks(c),e.selection.empty&&e.selection.from===t.to&&e.removeStoredMark(n)}function ag(e){return e.length===1?e[0].isLink:e.length===3&&e[1].isLink?[`()`,`[]`].includes(e[0].value+e[2].value):!1}function og(e){return new M({key:new N(`autolink`),appendTransaction:(t,n,r)=>{let i=t.some(e=>e.docChanged)&&!n.doc.eq(r.doc),a=t.some(e=>e.getMeta(`preventAutolink`));if(!i||a)return;let{tr:o}=r,s=su(n.doc,[...t]);if(!t.some(Vc)){let t=[];s.steps.forEach((e,n)=>{if(!(e instanceof St)||!e.slice.size)return;let r=s.mapping.slice(n+1),i=r.map(e.from,1),a=r.map(e.from+e.slice.size,-1);it.to-e.to),t.forEach(t=>ig(o,t,e.type))}if(Wu(s).forEach(({newRange:t})=>{let n=cu(r.doc,t,e=>e.isTextblock),i,a;if(n.length>1)i=n[0],a=r.doc.textBetween(i.pos,i.pos+i.node.nodeSize,void 0,` `);else if(n.length){let e=r.doc.textBetween(t.from,t.to,` `,` `);if(!tg.test(e))return;i=n[0],a=r.doc.textBetween(i.pos,t.to,void 0,` `)}if(i&&a){let t=a.split(eg).filter(Boolean);if(t.length<=0)return!1;let n=t[t.length-1],s=i.pos+a.lastIndexOf(n);if(!n)return!1;let c=Zh(n).map(t=>t.toObject(e.defaultProtocol));if(!ag(c))return!1;c.filter(e=>e.isLink).map(e=>({...e,from:s+e.start+1,to:s+e.end+1})).filter(e=>!r.schema.marks.code||!r.doc.rangeHasMark(e.from,e.to,r.schema.marks.code)).filter(t=>e.validate(t.value)).filter(t=>e.shouldAutoLink(t.value)).forEach(t=>{Gu(t.from,t.to,r.doc).some(t=>t.mark.type===e.type)||o.addMark(t.from,t.to,e.type.create({href:t.href}))})}}),o.steps.length)return o}})}function sg(e){return new M({key:new N(`handleClickLink`),props:{handleClick:(t,n,r)=>{if(r.button!==0||!t.editable)return!1;let i=null;if(r.target instanceof HTMLAnchorElement)i=r.target;else{let t=r.target;if(!t)return!1;let n=e.editor.view.dom;i=t.closest(`a`),i&&!n.contains(i)&&(i=null)}if(!i)return!1;let a=!1;if(e.enableClickSelection&&(a=e.editor.commands.extendMarkRange(e.type.name)),e.openOnClick){let n=Vu(t.state,e.type.name),r=i.href??n.href,o=i.target??n.target;r&&(window.open(r,o),a=!0)}return a}}})}var cg=/\[([^[\]]+)\]\(((?:[^\s()]|\([^\s()]*\))+)(?:\s+(?:(["'])(.*?)\3|“(.*?)”|‘(.*?)’))?\)$/,lg=/\[([^[\]]+)\]\(((?:[^\s()]|\([^\s()]*\))+)(?:\s+(?:(["'])(.*?)\3|“(.*?)”|‘(.*?)’))?\)/g;function ug(e,t){let n=0;for(let r=t-1;r>=0&&e[r]===`\\`;--r)n+=1;return n%2==1}function dg(e,t){let n=0,r=0;for(;r0}function fg(e,t,n){let[,r,i]=t;return(t.index?e[t.index-1]:void 0)===`!`||ug(e,t.index??0)||dg(e,t.index??0)?!1:!!r.trim()&&n(i)}function pg(e){let[t,n,r,,i,a,o]=e,s=i??a??o;return{index:e.index??0,text:t,replaceWith:n,data:{href:r,title:s||null,markdown:!0}}}function mg(e,t){return e.index{let n=cg.exec(t);return!n||!fg(t,n,e.isAllowedHref)?null:pg(n)},type:e.type,getAttributes:hg});return new If({find:t.find,handler:e=>{let n=t.handler(e);return n!==null&&e.state.tr.steps.length&&e.state.tr.setMeta(`preventAutolink`,!0),n}})}function _g(e){let t=vp({find:t=>{let n=[];for(let r of t.matchAll(lg))fg(t,r,e.isAllowedHref)&&n.push(pg(r));let r=(e.findPlainUrls?.call(e,t)??[]).filter(e=>!n.some(t=>mg(t,e)));return[...n,...r]},type:e.type,getAttributes:hg});return new Gf({find:t.find,handler:e=>{let n=t.handler(e);return n!==null&&e.state.tr.steps.length&&e.match.data?.markdown&&e.state.tr.setMeta(`preventAutolink`,!0),n}})}function vg(e){return new M({key:new N(`handlePasteLink`),props:{handlePaste:(t,n,r)=>{let{shouldAutoLink:i}=e,{state:a}=t,{selection:o}=a,{empty:s}=o;if(s)return!1;let c=``;r.content.forEach(e=>{c+=e.textContent});let l=Qh(c,{defaultProtocol:e.defaultProtocol}).find(e=>e.isLink&&e.value===c);return!c||!l||i!==void 0&&!i(l.value)?!1:e.editor.commands.setMark(e.type,{href:l.href})}}})}function yg(e,t){let n=[`http`,`https`,`ftp`,`ftps`,`mailto`,`tel`,`callto`,`sms`,`cid`,`xmpp`];return t&&t.forEach(e=>{let t=typeof e==`string`?e:e.scheme;t&&n.push(t)}),!e||e.replace(rg,``).match(RegExp(`^(?:(?:${n.map(e=>e.replace(/[-/\\^$*+?.()|[\]{}]/g,`\\$&`)).join(`|`)}):|[^a-z]|[a-z0-9+.\\-]+(?:[^a-z+.\\-:]|$))`,`i`))}var bg=Wf.create({name:`link`,priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate,console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(e=>{typeof e==`string`?Yh(e):Yh(e.scheme,e.optionalSlashes)})},onDestroy(){Jh()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,enableClickSelection:!1,linkOnPaste:!0,markdownLinks:!1,autolink:!0,protocols:[],defaultProtocol:`http`,HTMLAttributes:{target:`_blank`,rel:`noopener noreferrer nofollow`,class:null},isAllowedUri:(e,t)=>!!yg(e,t.protocols),validate:e=>!!e,shouldAutoLink:e=>{let t=/^[a-z][a-z0-9+.-]*:\/\//i.test(e),n=/^[a-z][a-z0-9+.-]*:/i.test(e);if(t||n&&!e.includes(`@`))return!0;let r=(e.includes(`@`)?e.split(`@`).pop():e).split(/[/?#:]/)[0];return!(/^\d{1,3}(\.\d{1,3}){3}$/.test(r)||!/\./.test(r))}}},addAttributes(){return{href:{default:null,parseHTML(e){return e.getAttribute(`href`)}},target:{default:this.options.HTMLAttributes.target??null},rel:{default:this.options.HTMLAttributes.rel??null},class:{default:this.options.HTMLAttributes.class??null},title:{default:null}}},parseHTML(){return[{tag:`a[href]`,getAttrs:e=>{let t=e.getAttribute(`href`);return!t||!this.options.isAllowedUri(t,{defaultValidate:e=>!!yg(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:e}){return this.options.isAllowedUri(e.href,{defaultValidate:e=>!!yg(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?[`a`,B(this.options.HTMLAttributes,e),0]:[`a`,B(this.options.HTMLAttributes,{...e,href:``}),0]},markdownTokenName:`link`,parseMarkdown:(e,t)=>t.applyMark(`link`,t.parseInline(e.tokens||[]),{href:e.href,title:e.title||null}),renderMarkdown:(e,t)=>{let n=e.attrs?.href??``,r=e.attrs?.title??``,i=t.renderChildren(e);return r?`[${i}](${n} "${r}")`:`[${i}](${n})`},addCommands(){return{setLink:e=>({chain:t})=>{let{href:n}=e;return this.options.isAllowedUri(n,{defaultValidate:e=>!!yg(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?t().setMark(this.name,e).setMeta(`preventAutolink`,!0).run():!1},toggleLink:e=>({chain:t})=>{let{href:n}=e||{};return n&&!this.options.isAllowedUri(n,{defaultValidate:e=>!!yg(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:t().toggleMark(this.name,e,{extendEmptyMarkRange:!0}).setMeta(`preventAutolink`,!0).run()},unsetLink:()=>({chain:e})=>e().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta(`preventAutolink`,!0).run()}},addInputRules(){return this.options.markdownLinks?[gg({type:this.type,isAllowedHref:e=>this.options.isAllowedUri(e,{defaultValidate:e=>!!yg(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})})]:[]},addPasteRules(){let e=e=>{let t=[];if(e){let{protocols:n,defaultProtocol:r}=this.options;Qh(e,{defaultProtocol:r}).filter(e=>e.isLink&&this.options.isAllowedUri(e.value,{defaultValidate:e=>!!yg(e,n),protocols:n,defaultProtocol:r})).forEach(e=>{this.options.shouldAutoLink(e.value)&&t.push({text:e.value,data:{href:e.href},index:e.start})})}return t};return this.options.markdownLinks?[_g({type:this.type,isAllowedHref:e=>this.options.isAllowedUri(e,{defaultValidate:e=>!!yg(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol}),findPlainUrls:e})]:[vp({find:e,type:this.type,getAttributes:e=>({href:e.data?.href})})]},addProseMirrorPlugins(){let e=[],{protocols:t,defaultProtocol:n}=this.options;return this.options.autolink&&e.push(og({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:e=>this.options.isAllowedUri(e,{defaultValidate:e=>!!yg(e,t),protocols:t,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),e.push(sg({type:this.type,editor:this.editor,openOnClick:this.options.openOnClick===`whenNotEditable`||this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&e.push(vg({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),e}}),xg=bg,Sg=`listItem`,Cg=`textStyle`,wg=/^\s*([-+*])\s$/,Tg=H.create({name:`bulletList`,addOptions(){return{itemTypeName:`listItem`,HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:`block list`,content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul`}]},renderHTML({HTMLAttributes:e}){return[`ul`,B(this.options.HTMLAttributes,e),0]},markdownTokenName:`list`,parseMarkdown:(e,t)=>e.type!==`list`||e.ordered?[]:{type:`bulletList`,content:e.items?t.parseChildren(e.items):[]},renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,` +`):``,markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:e,chain:t})=>this.options.keepAttributes?t().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(Sg,this.editor.getAttributes(Cg)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let e=_p({find:wg,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(e=_p({find:wg,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(Cg),editor:this.editor})),[e]}}),Eg=(e,t,n)=>{let{selection:r}=e;if(!r.empty)return null;let{$from:i}=r;if(!i.parent.isTextblock||i.parentOffset!==i.parent.content.size)return null;let a=-1;for(let e=i.depth;e>0;--e)if(i.node(e).type.name===t){a=e;break}if(a<0)return null;let o=i.node(a),s=i.index(a);if(s+1>=o.childCount)return null;let c=o.child(s+1);if(!n.includes(c.type.name))return null;let l=e.schema.nodes[t],u=!1;if(c.forEach(e=>{e.type===l&&e.childCount>1&&(u=!0)}),!u)return null;let d=e.doc.resolve(i.after()).nodeAfter;if(!d||!n.includes(d.type.name))return null;let f=[];return d.forEach(e=>{f.push(e)}),f.length===0?null:{listItemDepth:a,nestedList:d,nestedListPos:i.after(),insertPos:i.after(a),items:f}},Dg=(e,t,n,r)=>{let i=Eg(e,n,r);if(!i)return!1;let{selection:a}=e,{nestedList:o,nestedListPos:s,insertPos:l,items:u}=i,d=e.tr;d.delete(s,s+o.nodeSize);let f=d.mapping.map(l);return d.insert(f,c.from(u)),d.setSelection(a.map(d.doc,d.mapping)),t&&t(d),!0},Og=(e,t,n)=>Dg(e.state,e.view.dispatch,t,n),kg=(e,t)=>V.create({name:`${e}BranchingDeleteKeymap`,priority:101,addKeyboardShortcuts(){let n=()=>Og(this.editor,e,t);return{Delete:n,"Mod-Delete":n}}}),Ag=[[1e3,`m`],[900,`cm`],[500,`d`],[400,`cd`],[100,`c`],[90,`xc`],[50,`l`],[40,`xl`],[10,`x`],[9,`ix`],[5,`v`],[4,`iv`],[1,`i`]],jg=`abcdefghijklmnopqrstuvwxyz`,Mg=String.raw`\d+|[ivxlcdmIVXLCDM]+|${`[a-zA-Z]{1,2}`}`;function Ng(e){let t=e,n=``;for(let[e,r]of Ag)for(;t>=e;)n+=r,t-=e;return n}function Pg(e){return Ng(e).toUpperCase()}function Fg(e){let t=e.toLowerCase(),n=0,r=0;for(;n0?t:1}let n=parseInt(e,10);return Number.isNaN(n)?1:n}function Vg(e,t){if(e===`numeric`)return String(t);switch(e){case`a`:return Rg(t);case`A`:return Rg(t).toUpperCase();case`i`:return Ng(t);case`I`:return Pg(t);default:return String(t)}}function Hg(e){if(e.length===0)return!1;let t=zg(e[0])??`numeric`,n=Bg(e[0]);if(n<1)return!1;for(let r=0;r(e?.level??Yg)>Yg;function Zg(e){let t=e.tokens?.[0];return!!(e.text&&e.tokens?.length===1&&t?.type===`list`&&t.ordered&&t.raw===e.text)}function Qg(e,t){return t.tokenizeInline?t.parseInline(t.tokenizeInline(e)):t.parseInline([{type:`text`,raw:e,text:e}])}var $g=H.create({name:`listItem`,addOptions(){return{HTMLAttributes:{},bulletListTypeName:`bulletList`,orderedListTypeName:`orderedList`}},content:`paragraph block*`,defining:!0,parseHTML(){return[{tag:`li`}]},renderHTML({HTMLAttributes:e}){return[`li`,B(this.options.HTMLAttributes,e),0]},markdownTokenName:`list_item`,parseMarkdown:(e,t)=>{if(e.type!==`list_item`)return[];let n=t.parseBlockChildren??t.parseChildren,r=[];if(e.tokens&&e.tokens.length>0){if(Zg(e))return{type:`listItem`,content:[{type:`paragraph`,content:Qg(e.text||``,t)}]};let[i,...a]=e.tokens;if(i.type===`heading`)return{type:`listItem`,content:[{type:`paragraph`,content:t.parseInline(i.tokens??[])},...a.length>0?n(a):[]]};if(e.tokens.some(e=>e.type===`paragraph`))r=n(e.tokens);else if(i.type===`text`&&i.tokens&&i.tokens.length>0){if(r=[{type:`paragraph`,content:t.parseInline(i.tokens)}],e.tokens.length>1){let t=n(e.tokens.slice(1));r.push(...t)}}else r=n(e.tokens)}return r.length===0&&(r=[{type:`paragraph`,content:[]}]),{type:`listItem`,content:Kg(r)}},renderMarkdown:(e,t,n)=>{let r=e=>{if(e.parentType===`bulletList`)return`- `;if(e.parentType===`orderedList`){var t,n;let r=((t=e.meta)==null||(t=t.parentAttrs)==null?void 0:t.start)||1;return Gg((n=e.meta)==null||(n=n.parentAttrs)==null?void 0:n.type,r-1+(e.index||0),`. `)}return`- `},i=Nf(e,t,r,n,{alignNestedToPrefix:n?.parentType===`orderedList`});if(!qg(e)||!Xg(n))return i;let a=r(n);return`${a}${Jg}${i.slice(a.length)}`},addExtensions(){return[kg(this.name,[this.options.bulletListTypeName,this.options.orderedListTypeName])]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),e_=(e,t)=>{let{$from:n}=t.selection,r=L(e,t.schema),i=null,a=n.depth,o=n.pos,s=null;for(;a>0&&s===null;)i=n.node(a),i.type===r?s=a:(--a,--o);return s===null?null:{$pos:t.doc.resolve(o),depth:s}},t_=(e,t)=>{let n=e_(e,t);if(!n)return!1;let[,r]=Ku(t,e,n.$pos.pos+4);return r},n_=(e,t,n)=>{let{$anchor:r}=e.selection,i=Math.max(0,r.pos-2),a=e.doc.resolve(i).node();return!(!a||!n.includes(a.type.name))},r_=(e,t,n)=>{if(e.commands.undoInputRule())return!0;if(e.state.selection.from!==e.state.selection.to)return!1;if(!Ul(e.state,t)&&n_(e.state,t,n)){let{$anchor:n}=e.state.selection,r=e.state.doc.resolve(n.before()-1),i=[];r.node().descendants((e,n)=>{e.type.name===t&&i.push({node:e,pos:n})});let a=i.at(-1);if(!a)return!1;let o=e.state.doc.resolve(r.start()+a.pos+1);return e.chain().command(({tr:e})=>{let t=o.end();return e.delete(n.before(),n.after()).insert(t,n.parent),e.setSelection(A.create(e.doc,t+1)),!0}).command(({state:e,dispatch:t})=>(Hn(e,t),!0)).run()}if(!Ul(e.state,t)||!ed(e.state))return!1;let{$from:r}=e.state.selection,i=r.depth-1;return r.node(i).type!==e.schema.nodes[t]||r.index(i)!==0?!1:e.chain().liftListItem(t).run()},i_=(e,t)=>{let n=t_(e,t),r=e_(e,t);return!r||!n?!1:n>r.depth},a_=(e,t)=>{let n=t_(e,t),r=e_(e,t);return!r||!n?!1:n!Ul(e.state,t)||!$u(e.state,t)||!e.state.selection.empty?!1:i_(t,e.state)?e.chain().focus(e.state.selection.from+4).lift(t).joinBackward().run():a_(t,e.state)?e.commands.command(({state:e,dispatch:t})=>Un(e,t)):e.commands.joinItemForward(),s_=(e,t,n)=>{let{state:r}=e,{selection:i}=r;if(!i.empty)return!1;let{$from:a}=i;if(a.parentOffset!==0||!a.parent.isTextblock||Ul(r,t))return!1;let o=qu(a);if(!o||!n.includes(o.type.name))return!1;let s=o.lastChild;if(!s||s.type.name!==t)return!1;let l=a.parent;if(!s.canReplace(s.childCount,s.childCount,c.from(l)))return!1;let u=a.before(),d=a.after(),f=u-2;return e.commands.command(({tr:e,dispatch:t})=>(t&&(e.delete(u,d).insert(f,c.from(l)),e.setSelection(A.create(e.doc,f+1)),e.scrollIntoView()),!0))},c_=V.create({name:`listKeymap`,addOptions(){return{listTypes:[{itemName:`listItem`,wrapperNames:[`bulletList`,`orderedList`]},{itemName:`taskItem`,wrapperNames:[`taskList`]}]}},addKeyboardShortcuts(){return{Delete:({editor:e})=>{let t=!1;return this.options.listTypes.forEach(({itemName:n})=>{e.state.schema.nodes[n]!==void 0&&o_(e,n)&&(t=!0)}),t},"Mod-Delete":({editor:e})=>{let t=!1;return this.options.listTypes.forEach(({itemName:n})=>{e.state.schema.nodes[n]!==void 0&&o_(e,n)&&(t=!0)}),t},Backspace:({editor:e})=>{let t=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{e.state.schema.nodes[n]!==void 0&&r_(e,n,r)&&(t=!0)}),t},"Mod-Backspace":({editor:e})=>{let t=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{e.state.schema.nodes[n]!==void 0&&r_(e,n,r)&&(t=!0)}),t},Tab:({editor:e})=>{for(let{itemName:t,wrapperNames:n}of this.options.listTypes)if(e.state.schema.nodes[t]!==void 0&&s_(e,t,n))return!0;return!1}}}}),l_=RegExp(`^(\\s*)(${Mg})([.)])\\s+(.*)$`),u_=/^\s/,d_={heading:/^#{1,6}(?:\s|$)/,bulletItem:/^[-+*]\s+/,codeFence:/^(?:```|~~~)/,blockMath:/^\$\$/,thematicBreak:/^(?:(?:-[ \t]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})$/};function f_(e){return l_.test(e.trimStart())}function p_(e){let t=e.trimStart();return d_.bulletItem.test(t)||f_(t)||d_.heading.test(t)||d_.thematicBreak.test(t)&&!t.startsWith(`-`)||/^>\s?/.test(t)||d_.codeFence.test(t)||d_.blockMath.test(t)}function m_(e){return Object.values(d_).some(t=>t.test(e))}function h_(e){let t=[],n=[],r=!1;return e.forEach(e=>{r?n.push(e):e.trim()===``||t.length>0&&p_(e)?(r=!0,n.push(e)):t.push(e)}),{paragraphLines:t,blockLines:n}}function g_(e){let t=[],n=0,r=0;for(;ne.trim().length>0);if(t.length===0)return null;let n=[];for(let e of t){let t=e.trim().match(h_);if(!t)return null;n.push({marker:t[1],content:t[3]})}return Bg(n.map(e=>e.marker))?{type:`orderedList`,attrs:Hg(n[0].marker),content:n.map(e=>({type:`listItem`,content:[{type:`paragraph`,content:[{type:`text`,text:e.content}]}]}))}:null}function __(e,t,n){let r=[],i=0;for(;ie.trim().length>0);if(t.length===0)return null;let n=[];for(let e of t){let t=e.trim().match(__);if(!t)return null;n.push({marker:t[1],content:t[3]})}return Hg(n.map(e=>e.marker))?{type:`orderedList`,attrs:Wg(n[0].marker),content:n.map(e=>({type:`listItem`,content:[{type:`paragraph`,content:[{type:`text`,text:e.content}]}]}))}:null}function y_(e,t,n){let r=[],i=0;for(;it;)f.push(e[d]),d+=1;if(f.length>0){let e=__(f,Math.min(...f.map(e=>e.indent)),n);l.push({type:`list`,ordered:!0,start:f[0].number,typeMarker:f[0].type,items:e,raw:f.map(e=>e.raw).join(` -`)})}r.push({type:`list_item`,raw:a.raw,tokens:l}),i=d}else i+=1}return r}function v_(e,t){return e.map(e=>{if(e.type!==`list_item`)return t.parseChildren([e])[0];let n=[];return e.tokens&&e.tokens.length>0&&e.tokens.forEach(e=>{if(e.type===`paragraph`||e.type===`list`||e.type===`blockquote`||e.type===`code`)n.push(...t.parseChildren([e]));else if(e.type===`text`&&e.tokens){let r=t.parseChildren([e]);n.push({type:`paragraph`,content:r})}else{let r=t.parseChildren([e]);r.length>0&&n.push(...r)}}),{type:`listItem`,content:n}})}var y_=64;function b_(e,t){let n=[],r=0;for(;n.lengthe.hasAttribute(`start`)?parseInt(e.getAttribute(`start`)||``,10):1},type:{default:null,parseHTML:e=>{let t=e.getAttribute(`type`);if(t)return t;let n=e.getAttribute(`style`);if(n){let e=T_(n);if(e)return e}let r=e.querySelector(`li`);if(r){let e=r.getAttribute(`style`);if(e){let t=T_(e);if(t)return t}}return null}}}},parseHTML(){return[{tag:`ol`}]},renderHTML({HTMLAttributes:e}){let{start:t,type:n,...r}=e,i=H(this.options.HTMLAttributes,r);return t!==1&&(i.start=t),n&&n!==`1`&&(i.type=n),[`ol`,i,0]},markdownTokenName:`list`,parseMarkdown:(e,t)=>{if(e.type!==`list`||!e.ordered)return[];let n=e.start||1,r=e.typeMarker,i=e.items?v_(e.items,t):[],a={};return n!==1&&(a.start=n),r&&(a.type=r),Object.keys(a).length>0?{type:`orderedList`,attrs:a,content:i}:{type:`orderedList`,content:i}},renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,` -`):``,markdownTokenizer:{name:`orderedList`,level:`block`,start:()=>-1,tokenize:(e,t,n)=>{let[r,i,a]=x_(e);if(r.length===0)return;let o=__(r,r[0].indent,n);if(o.length!==0)return{type:`list`,ordered:!0,start:r[0]?.number||1,typeMarker:r[0]?.type,items:o,raw:a.slice(0,i).join(` -`)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:e,chain:t})=>this.options.keepAttributes?t().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(S_,this.editor.getAttributes(C_)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addProseMirrorPlugins(){return[new M({props:{handlePaste:(e,t)=>{if((t.clipboardData?.getData(`text/html`))?.trim())return!1;let n=t.clipboardData?.getData(`text/plain`);if(!n)return!1;let r=g_(n);if(!r)return!1;try{let t=e.state.schema.nodeFromJSON(r),n=e.state.tr.replaceSelectionWith(t);return e.dispatch(n),!0}catch{return!1}}}})]},addInputRules(){let e=(e,t)=>(!t.attrs.type||t.attrs.type===`1`)&&t.childCount+t.attrs.start===+e[1],t=hp({find:w_,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:e});return(this.options.keepMarks||this.options.keepAttributes)&&(t=hp({find:w_,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(C_)}),joinPredicate:e,editor:this.editor})),[t]}}),D_=/^\s*(\[([( |x])?\])\s$/,O_=`position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0`,k_=(e,t,n)=>{var r;return(n==null||(r=n.checkboxLabel)==null?void 0:r.call(n,e,t))||`Task item checkbox for ${e.textContent||`empty task item`}`},A_=W.create({name:`taskItem`,addOptions(){return{nested:!1,HTMLAttributes:{},taskListTypeName:`taskList`,a11y:void 0}},content(){return this.options.nested?`paragraph block*`:`paragraph+`},defining:!0,addAttributes(){return{checked:{default:!1,keepOnSplit:!1,parseHTML:e=>{let t=e.getAttribute(`data-checked`);return t===``||t===`true`},renderHTML:e=>({"data-checked":e.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51,contentElement:e=>e.querySelector(`div`)??e}]},renderHTML({node:e,HTMLAttributes:t}){return[`li`,H(this.options.HTMLAttributes,t,{"data-type":this.name}),[`label`,[`input`,{type:`checkbox`,checked:e.attrs.checked?`checked`:null}],[`span`]],[`div`,0]]},parseMarkdown:(e,t)=>{let n=[];if(e.tokens&&e.tokens.length>0?n.push(t.createNode(`paragraph`,{},t.parseInline(e.tokens))):e.text?n.push(t.createNode(`paragraph`,{},[t.createNode(`text`,{text:e.text})])):n.push(t.createNode(`paragraph`,{},[])),e.nestedTokens&&e.nestedTokens.length>0){let r=t.parseChildren(e.nestedTokens);n.push(...r)}return t.createNode(`taskItem`,{checked:e.checked||!1},n)},renderMarkdown:(e,t)=>jf(e,t,`- [${e.attrs?.checked?`x`:` `}] `,void 0,{indentMainContent:!0}),addExtensions(){return this.options.nested?[Dg(this.name,[this.options.taskListTypeName])]:[]},addKeyboardShortcuts(){let e={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...e,Tab:()=>this.editor.commands.sinkListItem(this.name)}:e},addNodeView(){return({node:e,HTMLAttributes:t,getPos:n,editor:r})=>{let i=document.createElement(`li`),a=document.createElement(`label`),o=document.createElement(`span`),s=document.createElement(`input`),c=document.createElement(`div`);o.style.cssText=O_;let l=e=>{let t=k_(e,e.attrs.checked,this.options.a11y);s.setAttribute(`aria-label`,t),o.textContent=t};l(e),a.contentEditable=`false`,s.type=`checkbox`,s.addEventListener(`mousedown`,e=>e.preventDefault()),s.addEventListener(`change`,t=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){s.checked=!s.checked;return}let{checked:i}=t.target;r.isEditable&&typeof n==`function`&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:e})=>{let t=n();if(typeof t!=`number`)return!1;let r=e.doc.nodeAt(t);return e.setNodeMarkup(t,void 0,{...r?.attrs,checked:i}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(e,i)||(s.checked=!s.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([e,t])=>{i.setAttribute(e,t)}),i.dataset.checked=e.attrs.checked,s.checked=e.attrs.checked,a.append(s,o),i.append(a,c),Object.entries(t).forEach(([e,t])=>{i.setAttribute(e,t)});let u=new Set(Object.keys(t));return{dom:i,contentDOM:c,update:e=>{if(e.type!==this.type)return!1;i.dataset.checked=e.attrs.checked,s.checked=e.attrs.checked,l(e);let t=r.extensionManager.attributes,n=Tu(e,t),a=new Set(Object.keys(n)),o=this.options.HTMLAttributes;return u.forEach(e=>{a.has(e)||(e in o?i.setAttribute(e,o[e]):i.removeAttribute(e))}),Object.entries(n).forEach(([e,t])=>{t==null?e in o?i.setAttribute(e,o[e]):i.removeAttribute(e):i.setAttribute(e,t)}),u=a,!0}}}},addInputRules(){return[hp({find:D_,type:this.type,getAttributes:e=>({checked:e[e.length-1]===`x`})})]}}),j_=W.create({name:`taskList`,addOptions(){return{itemTypeName:`taskItem`,HTMLAttributes:{}}},group:`block list`,content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:e}){return[`ul`,H(this.options.HTMLAttributes,e,{"data-type":this.name}),0]},parseMarkdown:(e,t)=>t.createNode(`taskList`,{},t.parseChildren(e.items||[])),renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,` -`):``,markdownTokenizer:{name:`taskList`,level:`block`,start(e){let t=e.match(/^\s*[-+*]\s+\[([ xX])\]\s+/)?.index;return t===void 0?-1:t},tokenize(e,t,n){let r=e=>{let t=Of(e,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:e=>({indentLevel:e[1].length,mainContent:e[4],checked:e[3].toLowerCase()===`x`}),createToken:(e,t)=>({type:`taskItem`,raw:``,mainContent:e.mainContent,indentLevel:e.indentLevel,checked:e.checked,text:e.mainContent,tokens:n.inlineTokens(e.mainContent),nestedTokens:t}),customNestedParser:r},n);if(t){let r={type:`taskList`,raw:t.raw,items:t.items},i=e.slice(t.raw.length);return i.trim()?[r,...n.blockTokens(i)]:[r]}return n.blockTokens(e)},i=Of(e,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:e=>({indentLevel:e[1].length,mainContent:e[4],checked:e[3].toLowerCase()===`x`}),createToken:(e,t)=>({type:`taskItem`,raw:``,mainContent:e.mainContent,indentLevel:e.indentLevel,checked:e.checked,text:e.mainContent,tokens:n.inlineTokens(e.mainContent),nestedTokens:t}),customNestedParser:r},n);if(i)return{type:`taskList`,raw:i.raw,items:i.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:e})=>e.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});U.create({name:`listKit`,addExtensions(){let e=[];return this.options.bulletList!==!1&&e.push(Cg.configure(this.options.bulletList)),this.options.listItem!==!1&&e.push(Zg.configure(this.options.listItem)),this.options.listKeymap!==!1&&e.push(o_.configure(this.options.listKeymap)),this.options.orderedList!==!1&&e.push(E_.configure(this.options.orderedList)),this.options.taskItem!==!1&&e.push(A_.configure(this.options.taskItem)),this.options.taskList!==!1&&e.push(j_.configure(this.options.taskList)),e}});var M_=` `,N_=`\xA0`,P_=W.create({name:`paragraph`,priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:`block`,content:`inline*`,parseHTML(){return[{tag:`p`}]},renderHTML({HTMLAttributes:e}){return[`p`,H(this.options.HTMLAttributes,e),0]},parseMarkdown:(e,t)=>{let n=e.tokens||[];if(n.length===1&&n[0].type===`image`)return t.parseChildren([n[0]]);let r=t.parseInline(n);return n.length===1&&n[0].type===`text`&&(n[0].raw===M_||n[0].text===M_||n[0].raw===N_||n[0].text===N_)&&r.length===1&&r[0].type===`text`&&(r[0].text===M_||r[0].text===N_)?t.createNode(`paragraph`,void 0,[]):t.createNode(`paragraph`,void 0,r)},renderMarkdown:(e,t,n)=>{if(!e)return``;let r=Array.isArray(e.content)?e.content:[];if(r.length===0){var i,a;let e=Array.isArray(n==null||(i=n.previousNode)==null?void 0:i.content)?n.previousNode.content:[];return(n==null||(a=n.previousNode)==null?void 0:a.type)===`paragraph`&&e.length===0?M_:``}return t.renderChildren(r)},addCommands(){return{setParagraph:()=>({commands:e})=>e.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),F_=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,I_=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,L_=Hf.create({name:`strike`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`s`},{tag:`del`},{tag:`strike`},{style:`text-decoration`,consuming:!1,getAttrs:e=>e.includes(`line-through`)?{}:!1}]},renderHTML({HTMLAttributes:e}){return[`s`,H(this.options.HTMLAttributes,e),0]},markdownTokenName:`del`,parseMarkdown:(e,t)=>t.applyMark(`strike`,t.parseInline(e.tokens||[])),renderMarkdown:(e,t)=>`~~${t.renderChildren(e)}~~`,addCommands(){return{setStrike:()=>({commands:e})=>e.setMark(this.name),toggleStrike:()=>({commands:e})=>e.toggleMark(this.name),unsetStrike:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[fp({find:F_,type:this.type})]},addPasteRules(){return[gp({find:I_,type:this.type})]}}),R_=W.create({name:`text`,group:`inline`,parseMarkdown:e=>({type:`text`,text:e.text||``}),renderMarkdown:e=>e.text||``}),z_=Hf.create({name:`underline`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`u`},{style:`text-decoration`,consuming:!1,getAttrs:e=>e.includes(`underline`)?{}:!1}]},renderHTML({HTMLAttributes:e}){return[`u`,H(this.options.HTMLAttributes,e),0]},parseMarkdown(e,t){return t.applyMark(this.name||`underline`,t.parseInline(e.tokens||[]))},renderMarkdown(e,t){return`${t.renderChildren(e)}`},markdownTokenizer:{name:`underline`,level:`inline`,start(e){return e.toLowerCase().indexOf(``)},tokenize(e,t,n){if(!/^/i.test(e))return;let r=/\\[\s\S]|`+|<\/u>/gi;r.lastIndex=3;let i=r.exec(e);for(;i;){if(i[0].startsWith("`")){let t=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/.exec(e.slice(i.index));t&&(r.lastIndex=i.index+t[0].length)}else if(!i[0].startsWith(`\\`)){let t=e.slice(3,i.index);return t?{type:`underline`,raw:e.slice(0,r.lastIndex),text:t,tokens:n.inlineTokens(t)}:void 0}i=r.exec(e)}}},addCommands(){return{setUnderline:()=>({commands:e})=>e.setMark(this.name),toggleUnderline:()=>({commands:e})=>e.toggleMark(this.name),unsetUnderline:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}});function B_(e={}){return new M({view(t){return new V_(t,e)}})}var V_=class{constructor(e,t){this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.lastDragEvent=null,this.width=t.width??1,this.color=t.color===!1?void 0:t.color||`black`,this.class=t.class,this.handlers=[`dragover`,`dragend`,`drop`,`dragleave`].map(t=>{let n=e=>{this[t](e)};return e.dom.addEventListener(t,n),{name:t,handler:n}})}destroy(){this.setCursor(null),this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){if(this.cursorPos!=null&&t.doc!=e.state.doc){if(this.lastDragEvent){let e=this.computeTarget(this.lastDragEvent);e==this.cursorPos?this.updateOverlay():this.setCursor(e)}else this.updateOverlay()}}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),t=!e.parent.inlineContent,n,r=this.editorView.dom,i=r.getBoundingClientRect(),a=i.width/r.offsetWidth,o=i.height/r.offsetHeight;if(t){let t=e.nodeBefore,r=e.nodeAfter;if(t||r){let e=this.editorView.nodeDOM(this.cursorPos-(t?t.nodeSize:0));if(e){let i=e.getBoundingClientRect(),a=t?i.bottom:i.top;t&&r&&(a=(a+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let s=this.width/2*o;n={left:i.left,right:i.right,top:a-s,bottom:a+s}}}}if(!n){let e=this.editorView.coordsAtPos(this.cursorPos),t=this.width/2*a;n={left:e.left-t,right:e.left+t,top:e.top,bottom:e.bottom}}let s=this.editorView.dom.offsetParent;this.element||(this.element=s.appendChild(document.createElement(`div`)),this.class&&(this.element.className=this.class),this.element.style.cssText=`position: absolute; z-index: 50; pointer-events: none;`,this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle(`prosemirror-dropcursor-block`,t),this.element.classList.toggle(`prosemirror-dropcursor-inline`,!t);let c,l;if(!s||s==document.body&&getComputedStyle(s).position==`static`)c=-pageXOffset,l=-pageYOffset;else{let e=s.getBoundingClientRect(),t=e.width/s.offsetWidth,n=e.height/s.offsetHeight;c=e.left-s.scrollLeft*t,l=e.top-s.scrollTop*n}this.element.style.left=(n.left-c)/a+`px`,this.element.style.top=(n.top-l)/o+`px`,this.element.style.width=(n.right-n.left)/a+`px`,this.element.style.height=(n.bottom-n.top)/o+`px`}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}computeTarget(e){let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),n=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),r=n&&n.type.spec.disableDropCursor,i=typeof r==`function`?r(this.editorView,t,e):r;if(!t||i)return null;let a=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let e=Yt(this.editorView.state.doc,a,this.editorView.dragging.slice);e!=null&&(a=e)}return a}dragover(e){if(!this.editorView.editable)return;this.lastDragEvent=e;let t=this.computeTarget(e);t!=null&&(this.setCursor(t),this.scheduleRemoval(5e3))}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}},H_=class e extends k{constructor(e){super(e,e)}map(t,n){let r=t.resolve(n.map(this.head));return e.valid(r)?new e(r):k.near(r)}content(){return m.empty}eq(t){return t instanceof e&&t.head==this.head}toJSON(){return{type:`gapcursor`,pos:this.head}}static fromJSON(t,n){if(typeof n.pos!=`number`)throw RangeError(`Invalid input for GapCursor.fromJSON`);return new e(t.resolve(n.pos))}getBookmark(){return new U_(this.anchor)}static valid(e){let t=e.parent;if(t.inlineContent||!G_(e)||!K_(e))return!1;let n=t.type.spec.allowGapCursor;if(n!=null)return n;let r=t.contentMatchAt(e.index()).defaultType;return r&&r.isTextblock}static findGapCursorFrom(t,n,r=!1){search:for(;;){if(!r&&e.valid(t))return t;let i=t.pos,a=null;for(let r=t.depth;;r--){let o=t.node(r);if(n>0?t.indexAfter(r)0){a=o.child(n>0?t.indexAfter(r):t.index(r)-1);break}if(r==0)return null;i+=n;let s=t.doc.resolve(i);if(e.valid(s))return s}for(;;){let o=n>0?a.firstChild:a.lastChild;if(!o){if(a.isAtom&&!a.isText&&!j.isSelectable(a)){t=t.doc.resolve(i+a.nodeSize*n),r=!1;continue search}break}a=o,i+=n;let s=t.doc.resolve(i);if(e.valid(s))return s}return null}}};H_.prototype.visible=!1,H_.findFrom=H_.findGapCursorFrom,k.jsonID(`gapcursor`,H_);var U_=class e{constructor(e){this.pos=e}map(t){return new e(t.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return H_.valid(t)?new H_(t):k.near(t)}};function W_(e){return e.isAtom||e.spec.isolating||e.spec.createGapCursor}function G_(e){for(let t=e.depth;t>=0;t--){let n=e.index(t),r=e.node(t);if(n==0){if(r.type.spec.isolating)return!0}else for(let e=r.child(n-1);;e=e.lastChild){if(e.childCount==0&&!e.inlineContent||W_(e.type))return!0;if(e.inlineContent)return!1}}return!0}function K_(e){for(let t=e.depth;t>=0;t--){let n=e.indexAfter(t),r=e.node(t);if(n==r.childCount){if(r.type.spec.isolating)return!0}else for(let e=r.child(n);;e=e.firstChild){if(e.childCount==0&&!e.inlineContent||W_(e.type))return!0;if(e.inlineContent)return!1}}return!0}function q_(){return new M({props:{decorations:Q_,createSelectionBetween(e,t,n){return t.pos==n.pos&&H_.valid(n)?new H_(n):null},handleClick:X_,handleKeyDown:J_,handleDOMEvents:{beforeinput:Z_}}})}var J_=mc({ArrowLeft:Y_(`horiz`,-1),ArrowRight:Y_(`horiz`,1),ArrowUp:Y_(`vert`,-1),ArrowDown:Y_(`vert`,1)});function Y_(e,t){let n=e==`vert`?t>0?`down`:`up`:t>0?`right`:`left`;return function(e,r,i){let a=e.selection,o=t>0?a.$to:a.$from,s=a.empty;if(a instanceof A){if(!i.endOfTextblock(n)||o.depth==0)return!1;s=!1,o=e.doc.resolve(t>0?o.after():o.before())}let c=H_.findGapCursorFrom(o,t,s);return c?(r&&r(e.tr.setSelection(new H_(c))),!0):!1}}function X_(e,t,n){if(!e||!e.editable)return!1;let r=e.state.doc.resolve(t);if(!H_.valid(r))return!1;let i=e.posAtCoords({left:n.clientX,top:n.clientY});return i&&i.inside>-1&&j.isSelectable(e.state.doc.nodeAt(i.inside))?!1:(e.dispatch(e.state.tr.setSelection(new H_(r))),!0)}function Z_(e,t){if(t.inputType!=`insertCompositionText`||!(e.state.selection instanceof H_))return!1;let{$from:n}=e.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(e.state.schema.nodes.text);if(!r)return!1;let i=c.empty;for(let e=r.length-1;e>=0;e--)i=c.from(r[e].createAndFill(null,i));let a=e.state.tr.replace(n.pos,n.pos,new m(i,0,0));return a.setSelection(A.near(a.doc.resolve(n.pos+1))),e.dispatch(a),!1}function Q_(e){if(!(e.selection instanceof H_))return null;let t=document.createElement(`div`);return t.className=`ProseMirror-gapcursor`,L.create(e.doc,[ds.widget(e.selection.head,t,{key:`gapcursor`})])}U.create({name:`characterCount`,addOptions(){return{limit:null,autoTrim:!0,mode:`textSize`,textCounter:e=>e.length,wordCounter:e=>e.split(` `).filter(e=>e!==``).length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=e=>{let t=e?.node||this.editor.state.doc;if((e?.mode||this.options.mode)===`textSize`){let e=t.textBetween(0,t.content.size,void 0,` `);return this.options.textCounter(e)}return t.nodeSize},this.storage.words=e=>{let t=e?.node||this.editor.state.doc,n=t.textBetween(0,t.content.size,` `,` `);return this.options.wordCounter(n)}},addProseMirrorPlugins(){let e=!1;return[new M({key:new N(`characterCount`),appendTransaction:(t,n,r)=>{if(e)return;let i=this.options.limit,a=this.options.autoTrim;if(i==null||i===0||a===!1){e=!0;return}let o=this.storage.characters({node:r.doc});if(o>i){let t=o-i;console.warn(`[CharacterCount] Initial content exceeded limit of ${i} characters. Content was automatically trimmed.`);let n=r.tr.deleteRange(0,t);return e=!0,n}e=!0},filterTransaction:(e,t)=>{let n=this.options.limit;if(!e.docChanged||n===0||n==null)return!0;let r=this.storage.characters({node:t.doc}),i=this.storage.characters({node:e.doc});if(i<=n||r>n&&i>n&&i<=r)return!0;if(r>n&&i>n&&i>r||!e.getMeta(`paste`))return!1;let a=e.selection.$head.pos,o=a-(i-n),s=a;return e.deleteRange(o,s),!(this.storage.characters({node:e.doc})>n)}})]}});var $_=U.create({name:`dropCursor`,addOptions(){return{color:`currentColor`,width:1,class:void 0}},addProseMirrorPlugins(){return[B_(this.options)]}});U.create({name:`focus`,addOptions(){return{className:`has-focus`,mode:`all`}},addProseMirrorPlugins(){return[new M({key:new N(`focus`),props:{decorations:({doc:e,selection:t})=>{let{isEditable:n,isFocused:r}=this.editor,{anchor:i}=t,a=[];if(!n||!r)return L.create(e,[]);let o=0;this.options.mode===`deepest`&&e.descendants((e,t)=>{if(!e.isText){if(!(i>=t&&i<=t+e.nodeSize-1))return!1;o+=1}});let s=0;return e.descendants((e,t)=>{if(e.isText||!(i>=t&&i<=t+e.nodeSize-1))return!1;if(s+=1,this.options.mode===`deepest`&&o-s>0||this.options.mode===`shallowest`&&s>1)return this.options.mode===`deepest`;a.push(ds.node(t,t+e.nodeSize,{class:this.options.className}))}),L.create(e,a)}}})]}});var ev=U.create({name:`gapCursor`,addProseMirrorPlugins(){return[q_()]},extendNodeSchema(e){return{allowGapCursor:V(B(e,`allowGapCursor`,{name:e.name,options:e.options,storage:e.storage}))??null}}}),tv=`placeholder`,nv=new N(`tiptap__placeholder`);function rv(e){let{editor:t,placeholder:n,dataAttribute:r,pos:i,node:a,isEmptyDoc:o,hasAnchor:s,classes:{emptyNode:c,emptyEditor:l}}=e,u=[c];return o&&u.push(l),ds.node(i,i+a.nodeSize,{class:u.join(` `),[r]:typeof n==`function`?n({editor:t,node:a,pos:i,hasAnchor:s}):n})}function iv(e,t){return typeof e==`function`?e(t):e}function av({editor:e,options:t,dataAttribute:n,doc:r,selection:i,from:a,to:o}){let{anchor:s}=i,c=[],l=e.isEmpty;return r.nodesBetween(a,o,(r,i)=>{let a=s>=i&&s<=i+r.nodeSize,o=!r.isLeaf&&td(r);return r.type.isTextblock&&(a||!t.showOnlyCurrent)&&o&&c.push(rv({editor:e,isEmptyDoc:l,dataAttribute:n,hasAnchor:a,placeholder:t.placeholder,classes:{emptyEditor:t.emptyEditorClass,emptyNode:iv(t.emptyNodeClass,{editor:e,node:r,pos:i,hasAnchor:a})},node:r,pos:i})),t.includeChildren}),c}function ov({editor:e,options:t,dataAttribute:n,doc:r,selection:i}){if(!e.isEditable&&t.showOnlyWhenEditable)return null;let{anchor:a}=i,o=[],s=e.isEmpty;if(t.showOnlyCurrent&&!t.includeChildren){let i=r.resolve(a),c=i.depth>0?i.node(1):i.nodeAfter,l=i.depth>0?i.before(1):a;if(c&&c.type.isTextblock&&td(c)){let r=a>=l&&a<=l+c.nodeSize;o.push(rv({editor:e,isEmptyDoc:s,dataAttribute:n,hasAnchor:r,placeholder:t.placeholder,classes:{emptyEditor:t.emptyEditorClass,emptyNode:iv(t.emptyNodeClass,{editor:e,node:c,pos:l,hasAnchor:r})},node:c,pos:l}))}}else o.push(...av({editor:e,options:t,dataAttribute:n,doc:r,selection:i,from:0,to:r.content.size}));return L.create(r,o)}function sv(e,t){let n=e.resolve(t);if(n.depth===0){let e=n.nodeAfter??n.nodeBefore;if(!e)return{from:t,to:t};let r=n.nodeAfter?t:t-e.nodeSize;return{from:r,to:r+e.nodeSize}}let r=n.before(1);return{from:r,to:r+n.node(1).nodeSize}}function cv(e,t){return{from:Math.max(0,t.from),to:Math.min(e.content.size,t.to)}}function lv(e,t,n){let r=[];return e.forEach((e,i)=>{let a=i,o=a+e.nodeSize,s=a+1,c=o+1;st&&r.push({from:a,to:o})}),r}function uv(e){if(e.length===0)return[];let t=[...e].sort((e,t)=>e.from-t.from),n=[{...t[0]}];for(let e=1;et.from?n.push(cv(e,sv(e,Math.min(t.to,e.content.size+1)-1))):t.frome.from>=t&&e.to<=c);l.length&&(s=s.remove(l));let u=av({editor:n,options:r,dataAttribute:i,doc:a,selection:o,from:t,to:c});u.length&&(s=s.add(a,u))}return s}function hv({editor:e,options:t,dataAttribute:n}){return{init(r,i){return ov({editor:e,options:t,dataAttribute:n,doc:i.doc,selection:i.selection})??L.empty},apply(r,i,a,o){return!r.docChanged&&!r.selectionSet?i:mv({decorations:i.map(r.mapping,r.doc),ranges:fv(r,a,o),editor:e,options:t,dataAttribute:n,doc:o.doc,selection:o.selection})}}}function gv(e){return e.replace(/\s+/g,`-`).replace(/[^a-zA-Z0-9-]/g,``).replace(/^[0-9-]+/,``).replace(/^-+/,``).toLowerCase()}function _v({editor:e,options:t}){let n=t.dataAttribute?`data-${gv(t.dataAttribute)}`:`data-${tv}`,r=t.showOnlyCurrent&&!t.includeChildren;return new M({key:nv,...r?{}:{state:hv({editor:e,options:t,dataAttribute:n})},props:{decorations:r?({doc:r,selection:i})=>ov({editor:e,options:t,dataAttribute:n,doc:r,selection:i}):n=>t.showOnlyWhenEditable&&!e.isEditable?L.empty:nv.getState(n)??L.empty}})}var vv=U.create({name:`placeholder`,addOptions(){return{emptyEditorClass:`is-editor-empty`,emptyNodeClass:`is-empty`,dataAttribute:tv,placeholder:`Write something …`,showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[_v({editor:this.editor,options:this.options})]}});function yv(e,t){return!e.selection.empty&&!nd(e.selection)&&t.isEditable}function bv(e,t){return yv(e,t)&&!t.isFocused&&!t.view.dragging}function xv(){var e;(e=window.getSelection())==null||e.removeAllRanges()}function Sv(e){e.focus()}U.create({name:`selection`,addOptions(){return{className:`selection`}},addProseMirrorPlugins(){let{editor:e,options:t}=this;return[new M({key:new N(`selection`),props:{decorations(n){return bv(n,e)?L.create(n.doc,[ds.inline(n.selection.from,n.selection.to,{class:t.className})]):null},handleDOMEvents:{blur(t){return yv(t.state,e)&&xv(),!1},focus(t){return yv(t.state,e)&&requestAnimationFrame(()=>{!e.isDestroyed&&t.hasFocus()&&Sv(t)}),!1}}}})]}});function Cv({types:e,node:t}){return t&&Array.isArray(e)&&e.includes(t.type)||t?.type===e}var wv=U.create({name:`trailingNode`,addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){let e=new N(this.name),t=this.options.node||this.editor.schema.topNodeType.contentMatch.defaultType?.name||`paragraph`,n=Object.entries(this.editor.schema.nodes).map(([,e])=>e).filter(e=>(this.options.notAfter||[]).concat(t).includes(e.name));return[new M({key:e,appendTransaction:(n,r,i)=>{let{doc:a,tr:o,schema:s}=i,c=e.getState(i),l=a.content.size,u=s.nodes[t];if(!n.some(e=>e.getMeta(`skipTrailingNode`))&&c)return o.insert(l,u.create())},state:{init:(e,t)=>{let r=t.tr.doc.lastChild;return!Cv({node:r,types:n})},apply:(e,t)=>{if(!e.docChanged||e.getMeta(`__uniqueIDTransaction`))return t;let r=e.doc.lastChild;return!Cv({node:r,types:n})}}})]}}),Tv=U.create({name:`undoRedo`,addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:e,dispatch:t})=>Lc(e,t),redo:()=>({state:e,dispatch:t})=>Rc(e,t)}},addProseMirrorPlugins(){return[Fc(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}),Ev=U.create({name:`starterKit`,addExtensions(){let e=[];return this.options.bold!==!1&&e.push(jp.configure(this.options.bold)),this.options.blockquote!==!1&&e.push(Ep.configure(this.options.blockquote)),this.options.bulletList!==!1&&e.push(Cg.configure(this.options.bulletList)),this.options.code!==!1&&e.push(Fp.configure(this.options.code)),this.options.codeBlock!==!1&&e.push(zp.configure(this.options.codeBlock)),this.options.document!==!1&&e.push(Bp.configure(this.options.document)),this.options.dropcursor!==!1&&e.push($_.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&e.push(ev.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&e.push(Vp.configure(this.options.hardBreak)),this.options.heading!==!1&&e.push(Hp.configure(this.options.heading)),this.options.undoRedo!==!1&&e.push(Tv.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&e.push(Up.configure(this.options.horizontalRule)),this.options.italic!==!1&&e.push(Jp.configure(this.options.italic)),this.options.listItem!==!1&&e.push(Zg.configure(this.options.listItem)),this.options.listKeymap!==!1&&e.push(o_.configure(this.options?.listKeymap)),this.options.link!==!1&&e.push(vg.configure(this.options?.link)),this.options.orderedList!==!1&&e.push(E_.configure(this.options.orderedList)),this.options.paragraph!==!1&&e.push(P_.configure(this.options.paragraph)),this.options.strike!==!1&&e.push(L_.configure(this.options.strike)),this.options.text!==!1&&e.push(R_.configure(this.options.text)),this.options.underline!==!1&&e.push(z_.configure(this.options?.underline)),this.options.trailingNode!==!1&&e.push(wv.configure(this.options?.trailingNode)),e}}),Dv,Ov;if(typeof WeakMap<`u`){let e=new WeakMap;Dv=t=>e.get(t),Ov=(t,n)=>(e.set(t,n),n)}else{let e=[],t=0;Dv=t=>{for(let n=0;n(t==10&&(t=0),e[t++]=n,e[t++]=r)}var Y=class{constructor(e,t,n,r){this.width=e,this.height=t,this.map=n,this.problems=r}findCell(e){for(let t=0;t=n){(a||=[]).push({type:`overlong_rowspan`,pos:c,n:f-e});break}let l=i+e*t;for(let e=0;er&&(a+=i.attrs.colspan)}}for(let e=0;e1&&(n=!0)}t==-1?t=a:t!=a&&(t=Math.max(t,a))}return t}function jv(e,t,n){e.problems||=[];let r={};for(let i=0;i0;t--)if(e.node(t).type.spec.tableRole==`row`)return e.node(0).resolve(e.before(t+1));return null}function Iv(e){for(let t=e.depth;t>0;t--){let n=e.node(t).type.spec.tableRole;if(n===`cell`||n===`header_cell`)return e.node(t)}return null}function Lv(e){let t=e.selection.$head;for(let e=t.depth;e>0;e--)if(t.node(e).type.spec.tableRole==`row`)return!0;return!1}function Rv(e){let t=e.selection;if(`$anchorCell`in t&&t.$anchorCell)return t.$anchorCell.pos>t.$headCell.pos?t.$anchorCell:t.$headCell;if(`node`in t&&t.node&&t.node.type.spec.tableRole==`cell`)return t.$anchor;let n=Fv(t.$head)||zv(t.$head);if(n)return n;throw RangeError(`No cell found around position ${t.head}`)}function zv(e){for(let t=e.nodeAfter,n=e.pos;t;t=t.firstChild,n++){let r=t.type.spec.tableRole;if(r==`cell`||r==`header_cell`)return e.doc.resolve(n)}for(let t=e.nodeBefore,n=e.pos;t;t=t.lastChild,n--){let r=t.type.spec.tableRole;if(r==`cell`||r==`header_cell`)return e.doc.resolve(n-t.nodeSize)}}function Bv(e){return e.parent.type.spec.tableRole==`row`&&!!e.nodeAfter}function Vv(e){return e.node(0).resolve(e.pos+e.nodeAfter.nodeSize)}function Hv(e,t){return e.depth==t.depth&&e.pos>=t.start(-1)&&e.pos<=t.end(-1)}function Uv(e,t,n){let r=e.node(-1),i=Y.get(r),a=e.start(-1),o=i.nextCell(e.pos-a,t,n);return o==null?null:e.node(0).resolve(a+o)}function Wv(e,t,n=1){let r={...e,colspan:e.colspan-n};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(t,n),r.colwidth.some(e=>e>0)||(r.colwidth=null)),r}function Gv(e,t,n=1){let r={...e,colspan:e.colspan+n};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let e=0;ee!=t.pos-i);s.unshift(t.pos-i);let c=s.map(e=>{let t=n.nodeAt(e);if(!t)throw RangeError(`No cell with offset ${e} found`);let r=i+e+1;return new vn(o.resolve(r),o.resolve(r+t.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=t}map(t,n){let r=t.resolve(n.map(this.$anchorCell.pos)),i=t.resolve(n.map(this.$headCell.pos));if(Bv(r)&&Bv(i)&&Hv(r,i)){let t=this.$anchorCell.node(-1)!=r.node(-1);return t&&this.isRowSelection()?e.rowSelection(r,i):t&&this.isColSelection()?e.colSelection(r,i):new e(r,i)}return A.between(r,i)}content(){let e=this.$anchorCell.node(-1),t=Y.get(e),n=this.$anchorCell.start(-1),r=t.rectBetween(this.$anchorCell.pos-n,this.$headCell.pos-n),i={},a=[];for(let n=r.top;n0||u>0){let e=c.attrs;if(l>0&&(e=Wv(e,0,l)),u>0&&(e=Wv(e,e.colspan-u,u)),s.leftr.bottom){let e={...c.attrs,rowspan:Math.min(s.bottom,r.bottom)-Math.max(s.top,r.top)};c=s.top0)return!1;let n=e+this.$anchorCell.nodeAfter.attrs.rowspan,r=t+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(n,r)==this.$headCell.node(-1).childCount}static colSelection(t,n=t){let r=t.node(-1),i=Y.get(r),a=t.start(-1),o=i.findCell(t.pos-a),s=i.findCell(n.pos-a),c=t.node(0);return o.top<=s.top?(o.top>0&&(t=c.resolve(a+i.map[o.left])),s.bottom0&&(n=c.resolve(a+i.map[s.left])),o.bottom0)return!1;let a=r+this.$anchorCell.nodeAfter.attrs.colspan,o=i+this.$headCell.nodeAfter.attrs.colspan;return Math.max(a,o)==t.width}eq(t){return t instanceof e&&t.$anchorCell.pos==this.$anchorCell.pos&&t.$headCell.pos==this.$headCell.pos}static rowSelection(t,n=t){let r=t.node(-1),i=Y.get(r),a=t.start(-1),o=i.findCell(t.pos-a),s=i.findCell(n.pos-a),c=t.node(0);return o.left<=s.left?(o.left>0&&(t=c.resolve(a+i.map[o.top*i.width])),s.right0&&(n=c.resolve(a+i.map[s.top*i.width])),o.right{t.push(ds.node(n,n+e.nodeSize,{class:`selectedCell`}))}),L.create(e.doc,t)}function Yv({$from:e,$to:t}){if(e.pos==t.pos||e.pos=0&&!(e.after(i+1)=0&&!(t.before(e+1)>t.start(e));e--,r--);return n==r&&/row|table/.test(e.node(i).type.spec.tableRole)}function Xv({$from:e,$to:t}){let n,r;for(let t=e.depth;t>0;t--){let r=e.node(t);if(r.type.spec.tableRole===`cell`||r.type.spec.tableRole===`header_cell`){n=r;break}}for(let e=t.depth;e>0;e--){let n=t.node(e);if(n.type.spec.tableRole===`cell`||n.type.spec.tableRole===`header_cell`){r=n;break}}return n!==r&&t.parentOffset===0}function Zv(e,t,n){let r=(t||e).selection,i=(t||e).doc,a,o;if(r instanceof j&&(o=r.node.type.spec.tableRole)){if(o==`cell`||o==`header_cell`)a=X.create(i,r.from);else if(o==`row`){let e=i.resolve(r.from+1);a=X.rowSelection(e,e)}else if(!n){let e=Y.get(r.node),t=r.from+1,n=t+e.map[e.width*e.height-1];a=X.create(i,t+1,n)}}else r instanceof A&&Yv(r)?a=A.create(i,r.from):r instanceof A&&Xv(r)&&(a=A.create(i,r.$from.start(),r.$from.end()));return a&&(t||=e.tr).setSelection(a),t}var Qv=new N(`fix-tables`);function $v(e,t,n,r){let i=e.childCount,a=t.childCount;outer:for(let o=0,s=0;o{t.type.spec.tableRole==`table`&&(n=ty(e,t,r,n))};return t?t.doc!=e.doc&&$v(t.doc,e.doc,0,r):e.doc.descendants(r),n}function ty(e,t,n,r){let i=Y.get(t);if(!i.problems)return r;r||=e.tr;let a=[];for(let e=0;e0){let t=`cell`;n.firstChild&&(t=n.firstChild.type.spec.tableRole);let a=[];for(let n=0;n0?-1:0;Kv(t,r,i+a)&&(a=i==0||i==t.width?null:0);for(let o=0;o0&&i0&&t.map[s-1]==c||i0?-1:0;cy(t,r,i+s)&&(s=i==0||i==t.height?null:0);for(let a=0,c=t.width*i;a0&&i0&&l==t.map[o-t.width]){let t=n.nodeAt(l).attrs;e.setNodeMarkup(e.mapping.slice(s).map(l+r),null,{...t,rowspan:t.rowspan-1}),a+=t.colspan-1}else if(i0&&n[a]==n[a-1]||r.right0&&n[i]==n[i-e]||r.bottom0){let e=s+1+l.content.size,t=my(l)?s+1:e;n.replaceWith(t+r.tableStart,e+r.tableStart,o)}n.setSelection(new X(n.doc.resolve(s+r.tableStart))),t(n)}return!0}function _y(e,t){let n=Nv(e.schema);return vy(({node:e})=>n[e.type.spec.tableRole])(e,t)}function vy(e){return(t,n)=>{let r=t.selection,i,a;if(r instanceof X){if(r.$anchorCell.pos!=r.$headCell.pos)return!1;i=r.$anchorCell.nodeAfter,a=r.$anchorCell.pos}else{if(i=Iv(r.$from),!i)return!1;a=Fv(r.$from)?.pos}if(i==null||a==null||i.attrs.colspan==1&&i.attrs.rowspan==1)return!1;if(n){let o=i.attrs,s=[],c=o.colwidth;o.rowspan>1&&(o={...o,rowspan:1}),o.colspan>1&&(o={...o,colspan:1});let l=ny(t),u=t.tr;for(let e=0;e{n.attrs[e]!==t&&a.setNodeMarkup(r,null,{...n.attrs,[e]:t})}):a.setNodeMarkup(i.pos,null,{...i.nodeAfter.attrs,[e]:t}),r(a)}return!0}}function by(e){return function(t,n){if(!Lv(t))return!1;if(n){let r=Nv(t.schema),i=ny(t),a=t.tr,o=i.map.cellsInRect(e==`column`?{left:i.left,top:0,right:i.right,bottom:i.map.height}:e==`row`?{left:0,top:i.top,right:i.map.width,bottom:i.bottom}:i),s=o.map(e=>i.table.nodeAt(e));for(let e=0;e{let t=e+i.tableStart,n=a.doc.nodeAt(t);n&&a.setNodeMarkup(t,u,n.attrs)}),n(a)}return!0}}Sy(`row`,{useDeprecatedLogic:!0}),Sy(`column`,{useDeprecatedLogic:!0});var Cy=Sy(`cell`,{useDeprecatedLogic:!0});function wy(e,t){if(t<0){let t=e.nodeBefore;if(t)return e.pos-t.nodeSize;for(let t=e.index(-1)-1,n=e.before();t>=0;t--){let r=e.node(-1).child(t),i=r.lastChild;if(i)return n-1-i.nodeSize;n-=r.nodeSize}}else{if(e.index()0;r--)if(n.node(r).type.spec.tableRole==`table`)return t&&t(e.tr.delete(n.before(r),n.after(r)).scrollIntoView()),!0;return!1}function Dy(e,t){let n=e.selection;if(!(n instanceof X))return!1;if(t){let r=e.tr,i=Nv(e.schema).cell.createAndFill().content;n.forEachCell((e,t)=>{e.content.eq(i)||r.replace(r.mapping.map(t+1),r.mapping.map(t+e.nodeSize-1),new m(i,0,0))}),r.docChanged&&t(r)}return!0}function Oy(e){if(e.size===0)return null;let{content:t,openStart:n,openEnd:r}=e;for(;t.childCount==1&&(n>0&&r>0||t.child(0).type.spec.tableRole==`table`);)n--,r--,t=t.child(0).content;let i=t.child(0),a=i.type.spec.tableRole,o=i.type.schema,s=[];if(a==`row`)for(let e=0;e=0;t--){let{rowspan:i,colspan:a}=r.child(t).attrs;for(let t=e;t=t.length&&t.push(c.empty),n[i]r&&(s=s.type.createChecked(Wv(s.attrs,s.attrs.colspan,n+s.attrs.colspan-r),s.content)),o.push(s),n+=s.attrs.colspan;for(let n=1;ni&&(t=t.type.create({...t.attrs,rowspan:Math.max(1,i-t.attrs.rowspan)},t.content)),o.push(t)}e.push(c.from(o))}n=e,t=i}return{width:e,height:t,rows:n}}function My(e,t,n,r,i,a,o){let s=e.doc.type.schema,l=Nv(s),u,d;if(i>t.width)for(let a=0,s=0;at.height){let s=[];for(let e=0,r=(t.height-1)*t.width;e=t.width?!1:n.nodeAt(t.map[r+e]).type==l.header_cell;s.push(i?d||=l.header_cell.createAndFill():u||=l.cell.createAndFill())}let f=l.row.create(null,c.from(s)),p=[];for(let e=t.height;e{if(!i)return!1;let a=n.selection;if(a instanceof X)return Ly(n,r,k.near(a.$headCell,t));if(e!=`horiz`&&!a.empty)return!1;let o=Uy(i,e,t);if(o==null)return!1;if(e==`horiz`)return Ly(n,r,k.near(n.doc.resolve(a.head+t),t));{let i=n.doc.resolve(o),a=Uv(i,e,t),s;return s=a?k.near(a,1):t<0?k.near(n.doc.resolve(i.before(-1)),-1):k.near(n.doc.resolve(i.after(-1)),1),Ly(n,r,s)}}}function zy(e,t){return(n,r,i)=>{if(!i)return!1;let a=n.selection,o;if(a instanceof X)o=a;else{let r=Uy(i,e,t);if(r==null)return!1;o=new X(n.doc.resolve(r))}let s=Uv(o.$headCell,e,t);return s?Ly(n,r,new X(o.$anchorCell,s)):!1}}function By(e,t){let n=e.state.doc,r=Fv(n.resolve(t));return r?(e.dispatch(e.state.tr.setSelection(new X(r))),!0):!1}function Vy(e,t,n){if(!Lv(e.state))return!1;let r=Oy(n),i=e.state.selection;if(i instanceof X){r||={width:1,height:1,rows:[c.from(Ay(Nv(e.state.schema).cell,n))]};let t=i.$anchorCell.node(-1),a=i.$anchorCell.start(-1),o=Y.get(t).rectBetween(i.$anchorCell.pos-a,i.$headCell.pos-a);return r=jy(r,o.right-o.left,o.bottom-o.top),Fy(e.state,e.dispatch,a,o,r),!0}if(r){let t=Rv(e.state),n=t.start(-1);return Fy(e.state,e.dispatch,n,Y.get(t.node(-1)).findCell(t.pos-n),r),!0}return!1}function Hy(e,t){if(t.button!=0||t.ctrlKey||t.metaKey)return;let n=Wy(e,t.target),r;if(t.shiftKey&&e.state.selection instanceof X)i(e.state.selection.$anchorCell,t),t.preventDefault();else if(t.shiftKey&&n&&(r=Fv(e.state.selection.$anchor))!=null&&Gy(e,t)?.pos!=r.pos)i(r,t),t.preventDefault();else if(!n)return;function i(t,n){let r=Gy(e,n),i=Pv.getState(e.state)==null;if(!r||!Hv(t,r)){if(i)r=t;else return}let a=new X(t,r);if(i||!e.state.selection.eq(a)){let n=e.state.tr.setSelection(a);i&&n.setMeta(Pv,t.pos),e.dispatch(n)}}function a(){e.root.removeEventListener(`mouseup`,a),e.root.removeEventListener(`dragstart`,a),e.root.removeEventListener(`mousemove`,o),Pv.getState(e.state)!=null&&e.dispatch(e.state.tr.setMeta(Pv,-1))}function o(r){let o=r,s=Pv.getState(e.state),c;if(s!=null)c=e.state.doc.resolve(s);else if(Wy(e,o.target)!=n&&(c=Gy(e,t),!c))return a();c&&i(c,o)}e.root.addEventListener(`mouseup`,a),e.root.addEventListener(`dragstart`,a),e.root.addEventListener(`mousemove`,o)}function Uy(e,t,n){if(!(e.state.selection instanceof A))return null;let{$head:r}=e.state.selection;for(let i=r.depth-1;i>=0;i--){let a=r.node(i);if((n<0?r.index(i):r.indexAfter(i))!=(n<0?0:a.childCount))return null;if(a.type.spec.tableRole==`cell`||a.type.spec.tableRole==`header_cell`){let a=r.before(i),o=t==`vert`?n>0?`down`:`up`:n>0?`right`:`left`;return e.endOfTextblock(o)?a:null}}return null}function Wy(e,t){for(;t&&t!=e.dom;t=t.parentNode)if(t.nodeName==`TD`||t.nodeName==`TH`)return t;return null}function Gy(e,t){let n=e.posAtCoords({left:t.clientX,top:t.clientY});if(!n)return null;let{inside:r,pos:i}=n;return r>=0&&Fv(e.state.doc.resolve(r))||Fv(e.state.doc.resolve(i))}var Ky=class{constructor(e,t){this.node=e,this.defaultCellMinWidth=t,this.dom=document.createElement(`div`),this.dom.className=`tableWrapper`,this.table=this.dom.appendChild(document.createElement(`table`)),this.table.style.setProperty(`--default-cell-min-width`,`${t}px`),this.colgroup=this.table.appendChild(document.createElement(`colgroup`)),qy(e,this.colgroup,this.table,t),this.contentDOM=this.table.appendChild(document.createElement(`tbody`))}update(e){return e.type==this.node.type&&(this.node=e,qy(e,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(e){return e.type==`attributes`&&(e.target==this.table||this.colgroup.contains(e.target))}};function qy(e,t,n,r,i,a){let o=0,s=!0,c=t.firstChild,l=e.firstChild;if(l){for(let e=0,n=0;enew r(e,n,t)),new Xy(-1,!1)},apply(e,t){return t.apply(e)}},props:{attributes:e=>{let t=Jy.getState(e);return t&&t.activeHandle>-1?{class:`resize-cursor`}:{}},handleDOMEvents:{mousemove:(t,n)=>{Zy(t,n,e,i)},mouseleave:e=>{Qy(e)},mousedown:(e,r)=>{$y(e,r,t,n)}},decorations:e=>{let t=Jy.getState(e);if(t&&t.activeHandle>-1)return cb(e,t.activeHandle)},nodeViews:{}}});return a}var Xy=class e{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(t){let n=this,r=t.getMeta(Jy);if(r&&r.setHandle!=null)return new e(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new e(n.activeHandle,r.setDragging);if(n.activeHandle>-1&&t.docChanged){let r=t.mapping.map(n.activeHandle,-1);return Bv(t.doc.resolve(r))||(r=-1),new e(r,n.dragging)}return n}};function Zy(e,t,n,r){if(!e.editable)return;let i=Jy.getState(e.state);if(i&&!i.dragging){let a=tb(t.target),o=-1;if(a){let{left:r,right:i}=a.getBoundingClientRect();t.clientX-r<=n?o=nb(e,t,`left`,n):i-t.clientX<=n&&(o=nb(e,t,`right`,n))}if(o!=i.activeHandle){if(!r&&o!==-1){let t=e.state.doc.resolve(o),n=t.node(-1),r=Y.get(n),i=t.start(-1);if(r.colCount(t.pos-i)+t.nodeAfter.attrs.colspan-1==r.width-1)return}ib(e,o)}}}function Qy(e){if(!e.editable)return;let t=Jy.getState(e.state);t&&t.activeHandle>-1&&!t.dragging&&ib(e,-1)}function $y(e,t,n,r){if(!e.editable)return!1;let i=e.dom.ownerDocument.defaultView??window,a=Jy.getState(e.state);if(!a||a.activeHandle==-1||a.dragging)return!1;let o=e.state.doc.nodeAt(a.activeHandle),s=eb(e,a.activeHandle,o.attrs);e.dispatch(e.state.tr.setMeta(Jy,{setDragging:{startX:t.clientX,startWidth:s}}));function c(t){i.removeEventListener(`mouseup`,c),i.removeEventListener(`mousemove`,l);let r=Jy.getState(e.state);r?.dragging&&(ab(e,r.activeHandle,rb(r.dragging,t,n)),e.dispatch(e.state.tr.setMeta(Jy,{setDragging:null})))}function l(t){if(!t.which)return c(t);let i=Jy.getState(e.state);if(i&&i.dragging){let a=rb(i.dragging,t,n);ob(e,i.activeHandle,a,r)}}return ob(e,a.activeHandle,s,r),i.addEventListener(`mouseup`,c),i.addEventListener(`mousemove`,l),t.preventDefault(),!0}function eb(e,t,{colspan:n,colwidth:r}){let i=r&&r[r.length-1];if(i)return i;let a=e.domAtPos(t),o=a.node.childNodes[a.offset].offsetWidth,s=n;if(r)for(let e=0;edb(e),renderHTML:e=>{let t=ub(e.align);return wf(t)?{style:`text-align: ${t}`}:{}}}}function mb(e){let t=e.parentElement,n=e.closest(`table`);if(!t||!n)return null;let r=Array.from(t.children).indexOf(e),i=n.querySelectorAll(`colgroup > col`)[r]?.getAttribute(`width`);return i?[parseInt(i,10)]:null}function hb(e){let t=e.getAttribute(`colwidth`);return t?t.split(`,`).map(e=>parseInt(e,10)):mb(e)}var gb=/[ \t\r\n\f]+/g;function _b(e){return e.children.length>0?!1:(e.textContent??``).replace(gb,``)===``}function vb(e){let t=e.createAndFill();if(!t)throw Error(`[tiptap error]: "${e.name}" has no default content to backfill.`);return t.content}function yb(e,t,n){if(!(n in t))return;let r=t[n];(r===1||r===`1`||r==null)&&delete e[n]}var bb=W.create({name:`tableCell`,addOptions(){return{HTMLAttributes:{}}},content:`block+`,addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:hb},align:pb()}},tableRole:`cell`,isolating:!0,parseHTML(){return[{tag:`td`,getAttrs:e=>_b(e)?{}:!1,getContent:(e,t)=>vb(t.nodes[this.name])},{tag:`td`}]},renderHTML({HTMLAttributes:e}){let t=H(this.options.HTMLAttributes,e);return yb(t,e,`colspan`),yb(t,e,`rowspan`),[`td`,t,0]}}),xb=W.create({name:`tableHeader`,addOptions(){return{HTMLAttributes:{}}},content:`block+`,addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:hb},align:pb()}},tableRole:`header_cell`,isolating:!0,parseHTML(){return[{tag:`th`,getAttrs:e=>_b(e)?{}:!1,getContent:(e,t)=>vb(t.nodes[this.name])},{tag:`th`}]},renderHTML({HTMLAttributes:e}){let t=H(this.options.HTMLAttributes,e);return yb(t,e,`colspan`),yb(t,e,`rowspan`),[`th`,t,0]}}),Sb=W.create({name:`tableRow`,addOptions(){return{HTMLAttributes:{}}},content:`(tableCell | tableHeader)*`,tableRole:`row`,parseHTML(){return[{tag:`tr`}]},renderHTML({HTMLAttributes:e}){return[`tr`,H(this.options.HTMLAttributes,e),0]}});function Cb(e,t){return t?[`width`,`${Math.max(t,e)}px`]:[`min-width`,`${e}px`]}function wb(e,t,n,r,i,a){let o=0,s=!0,c=t.firstChild,l=e.firstChild;if(l!==null)for(let e=0,n=0;e{let r=e.nodes[n];r.spec.tableRole&&(t[r.spec.tableRole]=r)}),e.cached.tableNodeTypes=t,t}function kb(e,t,n,r,i){let a=Ob(e),o=[],s=[];for(let e=0;e{let{selection:t}=e.state;if(!Ab(t))return!1;let n=0;return su(t.ranges[0].$from,e=>e.type.name===`table`)?.node.descendants(e=>{if(e.type.name===`table`)return!1;[`tableCell`,`tableHeader`].includes(e.type.name)&&(n+=1)}),n===t.ranges.length&&(e.commands.deleteTable(),!0)};function Mb(e,t){let n=e.mapping.map(t);if(su(e.selection.$from,e=>e.type.name===`table`)?.pos===n)return;let r=e.doc.nodeAt(n);if(!r)return;let i=n+r.nodeSize-1;e.setSelection(A.near(e.doc.resolve(i),-1))}function Nb(e){let t=``,n=0;for(;ne===`|`?`\\|`:e)+e.slice(i,i+r),n=i+r,a=!0;break}i+=o}a||(t+=e.slice(n,n+r),n+=r)}return t}function Pb(e){return e.split(` -`).map(e=>!e.includes(`|`)||!e.includes("`")?e:Nb(e)).join(` -`)}function Fb(e){return(e||``).replaceAll(``,` `).replace(/\s+/g,` `).trim()}function Ib(e,t){return t?e.split(t).join(` -`):e}function Lb(e){return e.replace(/\\.|\|/g,e=>e===`|`?`\\|`:e)}function Rb(e,t,n={}){if(!e||!e.content||e.content.length===0)return``;let r=[];e.content.forEach(e=>{let i=[];e.content&&e.content.forEach(e=>{let r=``;r=e.content&&Array.isArray(e.content)&&e.content.length>1?e.content.map(e=>Ib(t.renderChildren(e),n.cellLineSeparator)).join(` -`):Ib(e.content?t.renderChildren(e.content):``,n.cellLineSeparator);let a=Lb(Fb(r.replace(/[ \t]*\r?\n[ \t]*/g,`
`))),o=e.type===`tableHeader`,s=fb(e.attrs);i.push({text:a,isHeader:o,align:s})}),r.push(i)});let i=r.reduce((e,t)=>Math.max(e,t.length),0);if(i===0)return``;let a=Array.from({length:i}).fill(0);r.forEach(e=>{for(let t=0;ta[t]&&(a[t]=n),a[t]<3&&(a[t]=3)}});let o=(e,t)=>e+` `.repeat(Math.max(0,t-e.length)),s=r[0],c=s.some(e=>e.isHeader),l=Array.from({length:i}).fill(null);r.forEach(e=>{for(let t=0;tc&&s[t]&&s[t].text||``);return u+=`| ${d.map((e,t)=>o(e,a[t])).join(` | `)} |\n`,u+=`| ${a.map((e,t)=>{let n=Math.max(3,e),r=l[t];return r===`left`?`:${`-`.repeat(n)}`:r===`right`?`${`-`.repeat(n)}:`:r===`center`?`:${`-`.repeat(n)}:`:`-`.repeat(n)}).join(` | `)} |\n`,(c?r.slice(1):r).forEach(e=>{u+=`| ${Array.from({length:i}).fill(0).map((t,n)=>o(e[n]&&e[n].text||``,a[n])).join(` | `)} |\n`}),u}var zb=new N(`preserveCellSelectionOnContextMenu`);function Bb(e,t){let n=e.posAtCoords({left:t.clientX,top:t.clientY});if(n)return n.pos;if(!(t.target instanceof Node))return null;try{return e.posAtDOM(t.target,0)}catch{return null}}function Vb(e,t){let n=!1;return e.forEachCell((e,r)=>{t>=r&&t{let n=[],r=Array.isArray(e.align)?e.align:[];if(e.header){let i=[];e.header.forEach((e,n)=>{let a=ub(r[n]??e.align),o=a?{align:a}:{};i.push(t.createNode(`tableHeader`,o,[{type:`paragraph`,content:t.parseInline(e.tokens)}]))}),n.push(t.createNode(`tableRow`,{},i))}return e.rows&&e.rows.forEach(e=>{let i=[];e.forEach((e,n)=>{let a=ub(r[n]??e.align),o=a?{align:a}:{};i.push(t.createNode(`tableCell`,o,[{type:`paragraph`,content:t.parseInline(e.tokens)}]))}),n.push(t.createNode(`tableRow`,{},i))}),t.createNode(`table`,void 0,n)},renderMarkdown:(e,t)=>Rb(e,t),markdownTokenizer:{name:`table`,level:`block`,start:e=>{let t=e.split(` +`).trim();if(u){let e=n.blockTokens(u);l.push(...e)}let d=i+1,f=[];for(;dt;)f.push(e[d]),d+=1;if(f.length>0){let e=y_(f,Math.min(...f.map(e=>e.indent)),n);l.push({type:`list`,ordered:!0,start:f[0].number,typeMarker:f[0].type,items:e,raw:f.map(e=>e.raw).join(` +`)})}r.push({type:`list_item`,raw:a.raw,tokens:l}),i=d}else i+=1}return r}function b_(e,t){return e.map(e=>{if(e.type!==`list_item`)return t.parseChildren([e])[0];let n=[];return e.tokens&&e.tokens.length>0&&e.tokens.forEach(e=>{if(e.type===`paragraph`||e.type===`list`||e.type===`blockquote`||e.type===`code`)n.push(...t.parseChildren([e]));else if(e.type===`text`&&e.tokens){let r=t.parseChildren([e]);n.push({type:`paragraph`,content:r})}else{let r=t.parseChildren([e]);r.length>0&&n.push(...r)}}),{type:`listItem`,content:n}})}var x_=64;function S_(e,t){let n=[],r=0;for(;n.lengthe.hasAttribute(`start`)?parseInt(e.getAttribute(`start`)||``,10):1},type:{default:null,parseHTML:e=>{let t=e.getAttribute(`type`);if(t)return t;let n=e.getAttribute(`style`);if(n){let e=D_(n);if(e)return e}let r=e.querySelector(`li`);if(r){let e=r.getAttribute(`style`);if(e){let t=D_(e);if(t)return t}}return null}}}},parseHTML(){return[{tag:`ol`}]},renderHTML({HTMLAttributes:e}){let{start:t,type:n,...r}=e,i=B(this.options.HTMLAttributes,r);return t!==1&&(i.start=t),n&&n!==`1`&&(i.type=n),[`ol`,i,0]},markdownTokenName:`list`,parseMarkdown:(e,t)=>{if(e.type!==`list`||!e.ordered)return[];let n=e.start||1,r=e.typeMarker,i=e.items?b_(e.items,t):[],a={};return n!==1&&(a.start=n),r&&(a.type=r),Object.keys(a).length>0?{type:`orderedList`,attrs:a,content:i}:{type:`orderedList`,content:i}},renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,` +`):``,markdownTokenizer:{name:`orderedList`,level:`block`,start:()=>-1,tokenize:(e,t,n)=>{let[r,i,a]=C_(e);if(r.length===0)return;let o=y_(r,r[0].indent,n);if(o.length!==0)return{type:`list`,ordered:!0,start:r[0]?.number||1,typeMarker:r[0]?.type,items:o,raw:a.slice(0,i).join(` +`)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:e,chain:t})=>this.options.keepAttributes?t().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(w_,this.editor.getAttributes(T_)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addProseMirrorPlugins(){return[new M({props:{handlePaste:(e,t)=>{if((t.clipboardData?.getData(`text/html`))?.trim())return!1;let n=t.clipboardData?.getData(`text/plain`);if(!n)return!1;let r=v_(n);if(!r)return!1;try{let t=e.state.schema.nodeFromJSON(r),n=e.state.tr.replaceSelectionWith(t);return e.dispatch(n),!0}catch{return!1}}}})]},addInputRules(){let e=(e,t)=>(!t.attrs.type||t.attrs.type===`1`)&&t.childCount+t.attrs.start===+e[1],t=_p({find:E_,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:e});return(this.options.keepMarks||this.options.keepAttributes)&&(t=_p({find:E_,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(T_)}),joinPredicate:e,editor:this.editor})),[t]}}),k_=/^\s*(\[([( |x])?\])\s$/,A_=`position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0`,j_=(e,t,n)=>{var r;return(n==null||(r=n.checkboxLabel)==null?void 0:r.call(n,e,t))||`Task item checkbox for ${e.textContent||`empty task item`}`},M_=H.create({name:`taskItem`,addOptions(){return{nested:!1,HTMLAttributes:{},taskListTypeName:`taskList`,a11y:void 0}},content(){return this.options.nested?`paragraph block*`:`paragraph+`},defining:!0,addAttributes(){return{checked:{default:!1,keepOnSplit:!1,parseHTML:e=>{let t=e.getAttribute(`data-checked`);return t===``||t===`true`},renderHTML:e=>({"data-checked":e.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51,contentElement:e=>e.querySelector(`div`)??e}]},renderHTML({node:e,HTMLAttributes:t}){return[`li`,B(this.options.HTMLAttributes,t,{"data-type":this.name}),[`label`,[`input`,{type:`checkbox`,checked:e.attrs.checked?`checked`:null}],[`span`]],[`div`,0]]},parseMarkdown:(e,t)=>{let n=[];if(e.tokens&&e.tokens.length>0?n.push(t.createNode(`paragraph`,{},t.parseInline(e.tokens))):e.text?n.push(t.createNode(`paragraph`,{},[t.createNode(`text`,{text:e.text})])):n.push(t.createNode(`paragraph`,{},[])),e.nestedTokens&&e.nestedTokens.length>0){let r=t.parseChildren(e.nestedTokens);n.push(...r)}return t.createNode(`taskItem`,{checked:e.checked||!1},n)},renderMarkdown:(e,t)=>Nf(e,t,`- [${e.attrs?.checked?`x`:` `}] `,void 0,{indentMainContent:!0}),addExtensions(){return this.options.nested?[kg(this.name,[this.options.taskListTypeName])]:[]},addKeyboardShortcuts(){let e={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...e,Tab:()=>this.editor.commands.sinkListItem(this.name)}:e},addNodeView(){return({node:e,HTMLAttributes:t,getPos:n,editor:r})=>{let i=document.createElement(`li`),a=document.createElement(`label`),o=document.createElement(`span`),s=document.createElement(`input`),c=document.createElement(`div`);o.style.cssText=A_;let l=e=>{let t=j_(e,e.attrs.checked,this.options.a11y);s.setAttribute(`aria-label`,t),o.textContent=t};l(e),a.contentEditable=`false`,s.type=`checkbox`,s.addEventListener(`mousedown`,e=>e.preventDefault()),s.addEventListener(`change`,t=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){s.checked=!s.checked;return}let{checked:i}=t.target;r.isEditable&&typeof n==`function`&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:e})=>{let t=n();if(typeof t!=`number`)return!1;let r=e.doc.nodeAt(t);return e.setNodeMarkup(t,void 0,{...r?.attrs,checked:i}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(e,i)||(s.checked=!s.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([e,t])=>{i.setAttribute(e,t)}),i.dataset.checked=e.attrs.checked,s.checked=e.attrs.checked,a.append(s,o),i.append(a,c),Object.entries(t).forEach(([e,t])=>{i.setAttribute(e,t)});let u=new Set(Object.keys(t));return{dom:i,contentDOM:c,update:e=>{if(e.type!==this.type)return!1;i.dataset.checked=e.attrs.checked,s.checked=e.attrs.checked,l(e);let t=r.extensionManager.attributes,n=Du(e,t),a=new Set(Object.keys(n)),o=this.options.HTMLAttributes;return u.forEach(e=>{a.has(e)||(e in o?i.setAttribute(e,o[e]):i.removeAttribute(e))}),Object.entries(n).forEach(([e,t])=>{t==null?e in o?i.setAttribute(e,o[e]):i.removeAttribute(e):i.setAttribute(e,t)}),u=a,!0}}}},addInputRules(){return[_p({find:k_,type:this.type,getAttributes:e=>({checked:e[e.length-1]===`x`})})]}}),N_=H.create({name:`taskList`,addOptions(){return{itemTypeName:`taskItem`,HTMLAttributes:{}}},group:`block list`,content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:e}){return[`ul`,B(this.options.HTMLAttributes,e,{"data-type":this.name}),0]},parseMarkdown:(e,t)=>t.createNode(`taskList`,{},t.parseChildren(e.items||[])),renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,` +`):``,markdownTokenizer:{name:`taskList`,level:`block`,start(e){let t=e.match(/^\s*[-+*]\s+\[([ xX])\]\s+/)?.index;return t===void 0?-1:t},tokenize(e,t,n){let r=e=>{let t=Af(e,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:e=>({indentLevel:e[1].length,mainContent:e[4],checked:e[3].toLowerCase()===`x`}),createToken:(e,t)=>({type:`taskItem`,raw:``,mainContent:e.mainContent,indentLevel:e.indentLevel,checked:e.checked,text:e.mainContent,tokens:n.inlineTokens(e.mainContent),nestedTokens:t}),customNestedParser:r},n);if(t){let r={type:`taskList`,raw:t.raw,items:t.items},i=e.slice(t.raw.length);return i.trim()?[r,...n.blockTokens(i)]:[r]}return n.blockTokens(e)},i=Af(e,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:e=>({indentLevel:e[1].length,mainContent:e[4],checked:e[3].toLowerCase()===`x`}),createToken:(e,t)=>({type:`taskItem`,raw:``,mainContent:e.mainContent,indentLevel:e.indentLevel,checked:e.checked,text:e.mainContent,tokens:n.inlineTokens(e.mainContent),nestedTokens:t}),customNestedParser:r},n);if(i)return{type:`taskList`,raw:i.raw,items:i.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:e})=>e.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});V.create({name:`listKit`,addExtensions(){let e=[];return this.options.bulletList!==!1&&e.push(Tg.configure(this.options.bulletList)),this.options.listItem!==!1&&e.push($g.configure(this.options.listItem)),this.options.listKeymap!==!1&&e.push(c_.configure(this.options.listKeymap)),this.options.orderedList!==!1&&e.push(O_.configure(this.options.orderedList)),this.options.taskItem!==!1&&e.push(M_.configure(this.options.taskItem)),this.options.taskList!==!1&&e.push(N_.configure(this.options.taskList)),e}});var P_=` `,F_=`\xA0`,I_=H.create({name:`paragraph`,priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:`block`,content:`inline*`,parseHTML(){return[{tag:`p`}]},renderHTML({HTMLAttributes:e}){return[`p`,B(this.options.HTMLAttributes,e),0]},parseMarkdown:(e,t)=>{let n=e.tokens||[];if(n.length===1&&n[0].type===`image`)return t.parseChildren([n[0]]);let r=t.parseInline(n);return n.length===1&&n[0].type===`text`&&(n[0].raw===P_||n[0].text===P_||n[0].raw===F_||n[0].text===F_)&&r.length===1&&r[0].type===`text`&&(r[0].text===P_||r[0].text===F_)?t.createNode(`paragraph`,void 0,[]):t.createNode(`paragraph`,void 0,r)},renderMarkdown:(e,t,n)=>{if(!e)return``;let r=Array.isArray(e.content)?e.content:[];if(r.length===0){var i,a;let e=Array.isArray(n==null||(i=n.previousNode)==null?void 0:i.content)?n.previousNode.content:[];return(n==null||(a=n.previousNode)==null?void 0:a.type)===`paragraph`&&e.length===0?P_:``}return t.renderChildren(r)},addCommands(){return{setParagraph:()=>({commands:e})=>e.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),L_=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,R_=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,z_=Wf.create({name:`strike`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`s`},{tag:`del`},{tag:`strike`},{style:`text-decoration`,consuming:!1,getAttrs:e=>e.includes(`line-through`)?{}:!1}]},renderHTML({HTMLAttributes:e}){return[`s`,B(this.options.HTMLAttributes,e),0]},markdownTokenName:`del`,parseMarkdown:(e,t)=>t.applyMark(`strike`,t.parseInline(e.tokens||[])),renderMarkdown:(e,t)=>`~~${t.renderChildren(e)}~~`,addCommands(){return{setStrike:()=>({commands:e})=>e.setMark(this.name),toggleStrike:()=>({commands:e})=>e.toggleMark(this.name),unsetStrike:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[mp({find:L_,type:this.type})]},addPasteRules(){return[vp({find:R_,type:this.type})]}}),B_=H.create({name:`text`,group:`inline`,parseMarkdown:e=>({type:`text`,text:e.text||``}),renderMarkdown:e=>e.text||``}),V_=Wf.create({name:`underline`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`u`},{style:`text-decoration`,consuming:!1,getAttrs:e=>e.includes(`underline`)?{}:!1}]},renderHTML({HTMLAttributes:e}){return[`u`,B(this.options.HTMLAttributes,e),0]},parseMarkdown(e,t){return t.applyMark(this.name||`underline`,t.parseInline(e.tokens||[]))},renderMarkdown(e,t){return`${t.renderChildren(e)}`},markdownTokenizer:{name:`underline`,level:`inline`,start(e){return e.toLowerCase().indexOf(``)},tokenize(e,t,n){if(!/^/i.test(e))return;let r=/\\[\s\S]|`+|<\/u>/gi;r.lastIndex=3;let i=r.exec(e);for(;i;){if(i[0].startsWith("`")){let t=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/.exec(e.slice(i.index));t&&(r.lastIndex=i.index+t[0].length)}else if(!i[0].startsWith(`\\`)){let t=e.slice(3,i.index);return t?{type:`underline`,raw:e.slice(0,r.lastIndex),text:t,tokens:n.inlineTokens(t)}:void 0}i=r.exec(e)}}},addCommands(){return{setUnderline:()=>({commands:e})=>e.setMark(this.name),toggleUnderline:()=>({commands:e})=>e.toggleMark(this.name),unsetUnderline:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}});function H_(e={}){return new M({view(t){return new U_(t,e)}})}var U_=class{constructor(e,t){this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.lastDragEvent=null,this.width=t.width??1,this.color=t.color===!1?void 0:t.color||`black`,this.class=t.class,this.handlers=[`dragover`,`dragend`,`drop`,`dragleave`].map(t=>{let n=e=>{this[t](e)};return e.dom.addEventListener(t,n),{name:t,handler:n}})}destroy(){this.setCursor(null),this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){if(this.cursorPos!=null&&t.doc!=e.state.doc){if(this.lastDragEvent){let e=this.computeTarget(this.lastDragEvent);e==this.cursorPos?this.updateOverlay():this.setCursor(e)}else this.updateOverlay()}}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),t=!e.parent.inlineContent,n,r=this.editorView.dom,i=r.getBoundingClientRect(),a=i.width/r.offsetWidth,o=i.height/r.offsetHeight;if(t){let t=e.nodeBefore,r=e.nodeAfter;if(t||r){let e=this.editorView.nodeDOM(this.cursorPos-(t?t.nodeSize:0));if(e){let i=e.getBoundingClientRect(),a=t?i.bottom:i.top;t&&r&&(a=(a+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let s=this.width/2*o;n={left:i.left,right:i.right,top:a-s,bottom:a+s}}}}if(!n){let e=this.editorView.coordsAtPos(this.cursorPos),t=this.width/2*a;n={left:e.left-t,right:e.left+t,top:e.top,bottom:e.bottom}}let s=this.editorView.dom.offsetParent;this.element||(this.element=s.appendChild(document.createElement(`div`)),this.class&&(this.element.className=this.class),this.element.style.cssText=`position: absolute; z-index: 50; pointer-events: none;`,this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle(`prosemirror-dropcursor-block`,t),this.element.classList.toggle(`prosemirror-dropcursor-inline`,!t);let c,l;if(!s||s==document.body&&getComputedStyle(s).position==`static`)c=-pageXOffset,l=-pageYOffset;else{let e=s.getBoundingClientRect(),t=e.width/s.offsetWidth,n=e.height/s.offsetHeight;c=e.left-s.scrollLeft*t,l=e.top-s.scrollTop*n}this.element.style.left=(n.left-c)/a+`px`,this.element.style.top=(n.top-l)/o+`px`,this.element.style.width=(n.right-n.left)/a+`px`,this.element.style.height=(n.bottom-n.top)/o+`px`}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}computeTarget(e){let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),n=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),r=n&&n.type.spec.disableDropCursor,i=typeof r==`function`?r(this.editorView,t,e):r;if(!t||i)return null;let a=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let e=Yt(this.editorView.state.doc,a,this.editorView.dragging.slice);e!=null&&(a=e)}return a}dragover(e){if(!this.editorView.editable)return;this.lastDragEvent=e;let t=this.computeTarget(e);t!=null&&(this.setCursor(t),this.scheduleRemoval(5e3))}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}},W_=class e extends k{constructor(e){super(e,e)}map(t,n){let r=t.resolve(n.map(this.head));return e.valid(r)?new e(r):k.near(r)}content(){return m.empty}eq(t){return t instanceof e&&t.head==this.head}toJSON(){return{type:`gapcursor`,pos:this.head}}static fromJSON(t,n){if(typeof n.pos!=`number`)throw RangeError(`Invalid input for GapCursor.fromJSON`);return new e(t.resolve(n.pos))}getBookmark(){return new G_(this.anchor)}static valid(e){let t=e.parent;if(t.inlineContent||!q_(e)||!J_(e))return!1;let n=t.type.spec.allowGapCursor;if(n!=null)return n;let r=t.contentMatchAt(e.index()).defaultType;return r&&r.isTextblock}static findGapCursorFrom(t,n,r=!1){search:for(;;){if(!r&&e.valid(t))return t;let i=t.pos,a=null;for(let r=t.depth;;r--){let o=t.node(r);if(n>0?t.indexAfter(r)0){a=o.child(n>0?t.indexAfter(r):t.index(r)-1);break}if(r==0)return null;i+=n;let s=t.doc.resolve(i);if(e.valid(s))return s}for(;;){let o=n>0?a.firstChild:a.lastChild;if(!o){if(a.isAtom&&!a.isText&&!j.isSelectable(a)){t=t.doc.resolve(i+a.nodeSize*n),r=!1;continue search}break}a=o,i+=n;let s=t.doc.resolve(i);if(e.valid(s))return s}return null}}};W_.prototype.visible=!1,W_.findFrom=W_.findGapCursorFrom,k.jsonID(`gapcursor`,W_);var G_=class e{constructor(e){this.pos=e}map(t){return new e(t.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return W_.valid(t)?new W_(t):k.near(t)}};function K_(e){return e.isAtom||e.spec.isolating||e.spec.createGapCursor}function q_(e){for(let t=e.depth;t>=0;t--){let n=e.index(t),r=e.node(t);if(n==0){if(r.type.spec.isolating)return!0}else for(let e=r.child(n-1);;e=e.lastChild){if(e.childCount==0&&!e.inlineContent||K_(e.type))return!0;if(e.inlineContent)return!1}}return!0}function J_(e){for(let t=e.depth;t>=0;t--){let n=e.indexAfter(t),r=e.node(t);if(n==r.childCount){if(r.type.spec.isolating)return!0}else for(let e=r.child(n);;e=e.firstChild){if(e.childCount==0&&!e.inlineContent||K_(e.type))return!0;if(e.inlineContent)return!1}}return!0}function Y_(){return new M({props:{decorations:ev,createSelectionBetween(e,t,n){return t.pos==n.pos&&W_.valid(n)?new W_(n):null},handleClick:Q_,handleKeyDown:X_,handleDOMEvents:{beforeinput:$_}}})}var X_=hc({ArrowLeft:Z_(`horiz`,-1),ArrowRight:Z_(`horiz`,1),ArrowUp:Z_(`vert`,-1),ArrowDown:Z_(`vert`,1)});function Z_(e,t){let n=e==`vert`?t>0?`down`:`up`:t>0?`right`:`left`;return function(e,r,i){let a=e.selection,o=t>0?a.$to:a.$from,s=a.empty;if(a instanceof A){if(!i.endOfTextblock(n)||o.depth==0)return!1;s=!1,o=e.doc.resolve(t>0?o.after():o.before())}let c=W_.findGapCursorFrom(o,t,s);return c?(r&&r(e.tr.setSelection(new W_(c))),!0):!1}}function Q_(e,t,n){if(!e||!e.editable)return!1;let r=e.state.doc.resolve(t);if(!W_.valid(r))return!1;let i=e.posAtCoords({left:n.clientX,top:n.clientY});return i&&i.inside>-1&&j.isSelectable(e.state.doc.nodeAt(i.inside))?!1:(e.dispatch(e.state.tr.setSelection(new W_(r))),!0)}function $_(e,t){if(t.inputType!=`insertCompositionText`||!(e.state.selection instanceof W_))return!1;let{$from:n}=e.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(e.state.schema.nodes.text);if(!r)return!1;let i=c.empty;for(let e=r.length-1;e>=0;e--)i=c.from(r[e].createAndFill(null,i));let a=e.state.tr.replace(n.pos,n.pos,new m(i,0,0));return a.setSelection(A.near(a.doc.resolve(n.pos+1))),e.dispatch(a),!1}function ev(e){if(!(e.selection instanceof W_))return null;let t=document.createElement(`div`);return t.className=`ProseMirror-gapcursor`,I.create(e.doc,[fs.widget(e.selection.head,t,{key:`gapcursor`})])}V.create({name:`characterCount`,addOptions(){return{limit:null,autoTrim:!0,mode:`textSize`,textCounter:e=>e.length,wordCounter:e=>e.split(` `).filter(e=>e!==``).length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=e=>{let t=e?.node||this.editor.state.doc;if((e?.mode||this.options.mode)===`textSize`){let e=t.textBetween(0,t.content.size,void 0,` `);return this.options.textCounter(e)}return t.nodeSize},this.storage.words=e=>{let t=e?.node||this.editor.state.doc,n=t.textBetween(0,t.content.size,` `,` `);return this.options.wordCounter(n)}},addProseMirrorPlugins(){let e=!1;return[new M({key:new N(`characterCount`),appendTransaction:(t,n,r)=>{if(e)return;let i=this.options.limit,a=this.options.autoTrim;if(i==null||i===0||a===!1){e=!0;return}let o=this.storage.characters({node:r.doc});if(o>i){let t=o-i;console.warn(`[CharacterCount] Initial content exceeded limit of ${i} characters. Content was automatically trimmed.`);let n=r.tr.deleteRange(0,t);return e=!0,n}e=!0},filterTransaction:(e,t)=>{let n=this.options.limit;if(!e.docChanged||n===0||n==null)return!0;let r=this.storage.characters({node:t.doc}),i=this.storage.characters({node:e.doc});if(i<=n||r>n&&i>n&&i<=r)return!0;if(r>n&&i>n&&i>r||!e.getMeta(`paste`))return!1;let a=e.selection.$head.pos,o=a-(i-n),s=a;return e.deleteRange(o,s),!(this.storage.characters({node:e.doc})>n)}})]}});var tv=V.create({name:`dropCursor`,addOptions(){return{color:`currentColor`,width:1,class:void 0}},addProseMirrorPlugins(){return[H_(this.options)]}});V.create({name:`focus`,addOptions(){return{className:`has-focus`,mode:`all`}},addProseMirrorPlugins(){return[new M({key:new N(`focus`),props:{decorations:({doc:e,selection:t})=>{let{isEditable:n,isFocused:r}=this.editor,{anchor:i}=t,a=[];if(!n||!r)return I.create(e,[]);let o=0;this.options.mode===`deepest`&&e.descendants((e,t)=>{if(!e.isText){if(!(i>=t&&i<=t+e.nodeSize-1))return!1;o+=1}});let s=0;return e.descendants((e,t)=>{if(e.isText||!(i>=t&&i<=t+e.nodeSize-1))return!1;if(s+=1,this.options.mode===`deepest`&&o-s>0||this.options.mode===`shallowest`&&s>1)return this.options.mode===`deepest`;a.push(fs.node(t,t+e.nodeSize,{class:this.options.className}))}),I.create(e,a)}}})]}});var nv=V.create({name:`gapCursor`,addProseMirrorPlugins(){return[Y_()]},extendNodeSchema(e){return{allowGapCursor:z(R(e,`allowGapCursor`,{name:e.name,options:e.options,storage:e.storage}))??null}}}),rv=`placeholder`,iv=new N(`tiptap__placeholder`);function av(e){let{editor:t,placeholder:n,dataAttribute:r,pos:i,node:a,isEmptyDoc:o,hasAnchor:s,classes:{emptyNode:c,emptyEditor:l}}=e,u=[c];return o&&u.push(l),fs.node(i,i+a.nodeSize,{class:u.join(` `),[r]:typeof n==`function`?n({editor:t,node:a,pos:i,hasAnchor:s}):n})}function ov(e,t){return typeof e==`function`?e(t):e}function sv({editor:e,options:t,dataAttribute:n,doc:r,selection:i,from:a,to:o}){let{anchor:s}=i,c=[],l=e.isEmpty;return r.nodesBetween(a,o,(r,i)=>{let a=s>=i&&s<=i+r.nodeSize,o=!r.isLeaf&&rd(r);return r.type.isTextblock&&(a||!t.showOnlyCurrent)&&o&&c.push(av({editor:e,isEmptyDoc:l,dataAttribute:n,hasAnchor:a,placeholder:t.placeholder,classes:{emptyEditor:t.emptyEditorClass,emptyNode:ov(t.emptyNodeClass,{editor:e,node:r,pos:i,hasAnchor:a})},node:r,pos:i})),t.includeChildren}),c}function cv({editor:e,options:t,dataAttribute:n,doc:r,selection:i}){if(!e.isEditable&&t.showOnlyWhenEditable)return null;let{anchor:a}=i,o=[],s=e.isEmpty;if(t.showOnlyCurrent&&!t.includeChildren){let i=r.resolve(a),c=i.depth>0?i.node(1):i.nodeAfter,l=i.depth>0?i.before(1):a;if(c&&c.type.isTextblock&&rd(c)){let r=a>=l&&a<=l+c.nodeSize;o.push(av({editor:e,isEmptyDoc:s,dataAttribute:n,hasAnchor:r,placeholder:t.placeholder,classes:{emptyEditor:t.emptyEditorClass,emptyNode:ov(t.emptyNodeClass,{editor:e,node:c,pos:l,hasAnchor:r})},node:c,pos:l}))}}else o.push(...sv({editor:e,options:t,dataAttribute:n,doc:r,selection:i,from:0,to:r.content.size}));return I.create(r,o)}function lv(e,t){let n=e.resolve(t);if(n.depth===0){let e=n.nodeAfter??n.nodeBefore;if(!e)return{from:t,to:t};let r=n.nodeAfter?t:t-e.nodeSize;return{from:r,to:r+e.nodeSize}}let r=n.before(1);return{from:r,to:r+n.node(1).nodeSize}}function uv(e,t){return{from:Math.max(0,t.from),to:Math.min(e.content.size,t.to)}}function dv(e,t,n){let r=[];return e.forEach((e,i)=>{let a=i,o=a+e.nodeSize,s=a+1,c=o+1;st&&r.push({from:a,to:o})}),r}function fv(e){if(e.length===0)return[];let t=[...e].sort((e,t)=>e.from-t.from),n=[{...t[0]}];for(let e=1;et.from?n.push(uv(e,lv(e,Math.min(t.to,e.content.size+1)-1))):t.frome.from>=t&&e.to<=c);l.length&&(s=s.remove(l));let u=sv({editor:n,options:r,dataAttribute:i,doc:a,selection:o,from:t,to:c});u.length&&(s=s.add(a,u))}return s}function _v({editor:e,options:t,dataAttribute:n}){return{init(r,i){return cv({editor:e,options:t,dataAttribute:n,doc:i.doc,selection:i.selection})??I.empty},apply(r,i,a,o){return!r.docChanged&&!r.selectionSet?i:gv({decorations:i.map(r.mapping,r.doc),ranges:mv(r,a,o),editor:e,options:t,dataAttribute:n,doc:o.doc,selection:o.selection})}}}function vv(e){return e.replace(/\s+/g,`-`).replace(/[^a-zA-Z0-9-]/g,``).replace(/^[0-9-]+/,``).replace(/^-+/,``).toLowerCase()}function yv({editor:e,options:t}){let n=t.dataAttribute?`data-${vv(t.dataAttribute)}`:`data-${rv}`,r=t.showOnlyCurrent&&!t.includeChildren;return new M({key:iv,...r?{}:{state:_v({editor:e,options:t,dataAttribute:n})},props:{decorations:r?({doc:r,selection:i})=>cv({editor:e,options:t,dataAttribute:n,doc:r,selection:i}):n=>t.showOnlyWhenEditable&&!e.isEditable?I.empty:iv.getState(n)??I.empty}})}var bv=V.create({name:`placeholder`,addOptions(){return{emptyEditorClass:`is-editor-empty`,emptyNodeClass:`is-empty`,dataAttribute:rv,placeholder:`Write something …`,showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[yv({editor:this.editor,options:this.options})]}});function xv(e,t){return!e.selection.empty&&!id(e.selection)&&t.isEditable}function Sv(e,t){return xv(e,t)&&!t.isFocused&&!t.view.dragging}function Cv(){var e;(e=window.getSelection())==null||e.removeAllRanges()}function wv(e){e.focus()}V.create({name:`selection`,addOptions(){return{className:`selection`}},addProseMirrorPlugins(){let{editor:e,options:t}=this;return[new M({key:new N(`selection`),props:{decorations(n){return Sv(n,e)?I.create(n.doc,[fs.inline(n.selection.from,n.selection.to,{class:t.className})]):null},handleDOMEvents:{blur(t){return xv(t.state,e)&&Cv(),!1},focus(t){return xv(t.state,e)&&requestAnimationFrame(()=>{!e.isDestroyed&&t.hasFocus()&&wv(t)}),!1}}}})]}});function Tv({types:e,node:t}){return t&&Array.isArray(e)&&e.includes(t.type)||t?.type===e}var Ev=V.create({name:`trailingNode`,addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){let e=new N(this.name),t=this.options.node||this.editor.schema.topNodeType.contentMatch.defaultType?.name||`paragraph`,n=Object.entries(this.editor.schema.nodes).map(([,e])=>e).filter(e=>(this.options.notAfter||[]).concat(t).includes(e.name));return[new M({key:e,appendTransaction:(n,r,i)=>{let{doc:a,tr:o,schema:s}=i,c=e.getState(i),l=a.content.size,u=s.nodes[t];if(!n.some(e=>e.getMeta(`skipTrailingNode`))&&c)return o.insert(l,u.create())},state:{init:(e,t)=>{let r=t.tr.doc.lastChild;return!Tv({node:r,types:n})},apply:(e,t)=>{if(!e.docChanged||e.getMeta(`__uniqueIDTransaction`))return t;let r=e.doc.lastChild;return!Tv({node:r,types:n})}}})]}}),Dv=V.create({name:`undoRedo`,addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:e,dispatch:t})=>zc(e,t),redo:()=>({state:e,dispatch:t})=>Bc(e,t)}},addProseMirrorPlugins(){return[Lc(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}),Ov=V.create({name:`starterKit`,addExtensions(){let e=[];return this.options.bold!==!1&&e.push(Np.configure(this.options.bold)),this.options.blockquote!==!1&&e.push(Op.configure(this.options.blockquote)),this.options.bulletList!==!1&&e.push(Tg.configure(this.options.bulletList)),this.options.code!==!1&&e.push(Lp.configure(this.options.code)),this.options.codeBlock!==!1&&e.push(Vp.configure(this.options.codeBlock)),this.options.document!==!1&&e.push(Hp.configure(this.options.document)),this.options.dropcursor!==!1&&e.push(tv.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&e.push(nv.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&e.push(Up.configure(this.options.hardBreak)),this.options.heading!==!1&&e.push(Wp.configure(this.options.heading)),this.options.undoRedo!==!1&&e.push(Dv.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&e.push(Gp.configure(this.options.horizontalRule)),this.options.italic!==!1&&e.push(Xp.configure(this.options.italic)),this.options.listItem!==!1&&e.push($g.configure(this.options.listItem)),this.options.listKeymap!==!1&&e.push(c_.configure(this.options?.listKeymap)),this.options.link!==!1&&e.push(bg.configure(this.options?.link)),this.options.orderedList!==!1&&e.push(O_.configure(this.options.orderedList)),this.options.paragraph!==!1&&e.push(I_.configure(this.options.paragraph)),this.options.strike!==!1&&e.push(z_.configure(this.options.strike)),this.options.text!==!1&&e.push(B_.configure(this.options.text)),this.options.underline!==!1&&e.push(V_.configure(this.options?.underline)),this.options.trailingNode!==!1&&e.push(Ev.configure(this.options?.trailingNode)),e}}),kv,Av;if(typeof WeakMap<`u`){let e=new WeakMap;kv=t=>e.get(t),Av=(t,n)=>(e.set(t,n),n)}else{let e=[],t=0;kv=t=>{for(let n=0;n(t==10&&(t=0),e[t++]=n,e[t++]=r)}var q=class{constructor(e,t,n,r){this.width=e,this.height=t,this.map=n,this.problems=r}findCell(e){for(let t=0;t=n){(a||=[]).push({type:`overlong_rowspan`,pos:c,n:f-e});break}let l=i+e*t;for(let e=0;er&&(a+=i.attrs.colspan)}}for(let e=0;e1&&(n=!0)}t==-1?t=a:t!=a&&(t=Math.max(t,a))}return t}function Nv(e,t,n){e.problems||=[];let r={};for(let i=0;i0;t--)if(e.node(t).type.spec.tableRole==`row`)return e.node(0).resolve(e.before(t+1));return null}function Rv(e){for(let t=e.depth;t>0;t--){let n=e.node(t).type.spec.tableRole;if(n===`cell`||n===`header_cell`)return e.node(t)}return null}function zv(e){let t=e.selection.$head;for(let e=t.depth;e>0;e--)if(t.node(e).type.spec.tableRole==`row`)return!0;return!1}function Bv(e){let t=e.selection;if(`$anchorCell`in t&&t.$anchorCell)return t.$anchorCell.pos>t.$headCell.pos?t.$anchorCell:t.$headCell;if(`node`in t&&t.node&&t.node.type.spec.tableRole==`cell`)return t.$anchor;let n=Lv(t.$head)||Vv(t.$head);if(n)return n;throw RangeError(`No cell found around position ${t.head}`)}function Vv(e){for(let t=e.nodeAfter,n=e.pos;t;t=t.firstChild,n++){let r=t.type.spec.tableRole;if(r==`cell`||r==`header_cell`)return e.doc.resolve(n)}for(let t=e.nodeBefore,n=e.pos;t;t=t.lastChild,n--){let r=t.type.spec.tableRole;if(r==`cell`||r==`header_cell`)return e.doc.resolve(n-t.nodeSize)}}function Hv(e){return e.parent.type.spec.tableRole==`row`&&!!e.nodeAfter}function Uv(e){return e.node(0).resolve(e.pos+e.nodeAfter.nodeSize)}function Wv(e,t){return e.depth==t.depth&&e.pos>=t.start(-1)&&e.pos<=t.end(-1)}function Gv(e,t,n){let r=e.node(-1),i=q.get(r),a=e.start(-1),o=i.nextCell(e.pos-a,t,n);return o==null?null:e.node(0).resolve(a+o)}function Kv(e,t,n=1){let r={...e,colspan:e.colspan-n};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(t,n),r.colwidth.some(e=>e>0)||(r.colwidth=null)),r}function qv(e,t,n=1){let r={...e,colspan:e.colspan+n};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let e=0;ee!=t.pos-i);s.unshift(t.pos-i);let c=s.map(e=>{let t=n.nodeAt(e);if(!t)throw RangeError(`No cell with offset ${e} found`);let r=i+e+1;return new vn(o.resolve(r),o.resolve(r+t.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=t}map(t,n){let r=t.resolve(n.map(this.$anchorCell.pos)),i=t.resolve(n.map(this.$headCell.pos));if(Hv(r)&&Hv(i)&&Wv(r,i)){let t=this.$anchorCell.node(-1)!=r.node(-1);return t&&this.isRowSelection()?e.rowSelection(r,i):t&&this.isColSelection()?e.colSelection(r,i):new e(r,i)}return A.between(r,i)}content(){let e=this.$anchorCell.node(-1),t=q.get(e),n=this.$anchorCell.start(-1),r=t.rectBetween(this.$anchorCell.pos-n,this.$headCell.pos-n),i={},a=[];for(let n=r.top;n0||u>0){let e=c.attrs;if(l>0&&(e=Kv(e,0,l)),u>0&&(e=Kv(e,e.colspan-u,u)),s.leftr.bottom){let e={...c.attrs,rowspan:Math.min(s.bottom,r.bottom)-Math.max(s.top,r.top)};c=s.top0)return!1;let n=e+this.$anchorCell.nodeAfter.attrs.rowspan,r=t+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(n,r)==this.$headCell.node(-1).childCount}static colSelection(t,n=t){let r=t.node(-1),i=q.get(r),a=t.start(-1),o=i.findCell(t.pos-a),s=i.findCell(n.pos-a),c=t.node(0);return o.top<=s.top?(o.top>0&&(t=c.resolve(a+i.map[o.left])),s.bottom0&&(n=c.resolve(a+i.map[s.left])),o.bottom0)return!1;let a=r+this.$anchorCell.nodeAfter.attrs.colspan,o=i+this.$headCell.nodeAfter.attrs.colspan;return Math.max(a,o)==t.width}eq(t){return t instanceof e&&t.$anchorCell.pos==this.$anchorCell.pos&&t.$headCell.pos==this.$headCell.pos}static rowSelection(t,n=t){let r=t.node(-1),i=q.get(r),a=t.start(-1),o=i.findCell(t.pos-a),s=i.findCell(n.pos-a),c=t.node(0);return o.left<=s.left?(o.left>0&&(t=c.resolve(a+i.map[o.top*i.width])),s.right0&&(n=c.resolve(a+i.map[s.top*i.width])),o.right{t.push(fs.node(n,n+e.nodeSize,{class:`selectedCell`}))}),I.create(e.doc,t)}function Zv({$from:e,$to:t}){if(e.pos==t.pos||e.pos=0&&!(e.after(i+1)=0&&!(t.before(e+1)>t.start(e));e--,r--);return n==r&&/row|table/.test(e.node(i).type.spec.tableRole)}function Qv({$from:e,$to:t}){let n,r;for(let t=e.depth;t>0;t--){let r=e.node(t);if(r.type.spec.tableRole===`cell`||r.type.spec.tableRole===`header_cell`){n=r;break}}for(let e=t.depth;e>0;e--){let n=t.node(e);if(n.type.spec.tableRole===`cell`||n.type.spec.tableRole===`header_cell`){r=n;break}}return n!==r&&t.parentOffset===0}function $v(e,t,n){let r=(t||e).selection,i=(t||e).doc,a,o;if(r instanceof j&&(o=r.node.type.spec.tableRole)){if(o==`cell`||o==`header_cell`)a=J.create(i,r.from);else if(o==`row`){let e=i.resolve(r.from+1);a=J.rowSelection(e,e)}else if(!n){let e=q.get(r.node),t=r.from+1,n=t+e.map[e.width*e.height-1];a=J.create(i,t+1,n)}}else r instanceof A&&Zv(r)?a=A.create(i,r.from):r instanceof A&&Qv(r)&&(a=A.create(i,r.$from.start(),r.$from.end()));return a&&(t||=e.tr).setSelection(a),t}var ey=new N(`fix-tables`);function ty(e,t,n,r){let i=e.childCount,a=t.childCount;outer:for(let o=0,s=0;o{t.type.spec.tableRole==`table`&&(n=ry(e,t,r,n))};return t?t.doc!=e.doc&&ty(t.doc,e.doc,0,r):e.doc.descendants(r),n}function ry(e,t,n,r){let i=q.get(t);if(!i.problems)return r;r||=e.tr;let a=[];for(let e=0;e0){let t=`cell`;n.firstChild&&(t=n.firstChild.type.spec.tableRole);let a=[];for(let n=0;n0?-1:0;Jv(t,r,i+a)&&(a=i==0||i==t.width?null:0);for(let o=0;o0&&i0&&t.map[s-1]==c||i0?-1:0;uy(t,r,i+s)&&(s=i==0||i==t.height?null:0);for(let a=0,c=t.width*i;a0&&i0&&l==t.map[o-t.width]){let t=n.nodeAt(l).attrs;e.setNodeMarkup(e.mapping.slice(s).map(l+r),null,{...t,rowspan:t.rowspan-1}),a+=t.colspan-1}else if(i0&&n[a]==n[a-1]||r.right0&&n[i]==n[i-e]||r.bottom0){let e=s+1+l.content.size,t=gy(l)?s+1:e;n.replaceWith(t+r.tableStart,e+r.tableStart,o)}n.setSelection(new J(n.doc.resolve(s+r.tableStart))),t(n)}return!0}function yy(e,t){let n=Fv(e.schema);return by(({node:e})=>n[e.type.spec.tableRole])(e,t)}function by(e){return(t,n)=>{let r=t.selection,i,a;if(r instanceof J){if(r.$anchorCell.pos!=r.$headCell.pos)return!1;i=r.$anchorCell.nodeAfter,a=r.$anchorCell.pos}else{if(i=Rv(r.$from),!i)return!1;a=Lv(r.$from)?.pos}if(i==null||a==null||i.attrs.colspan==1&&i.attrs.rowspan==1)return!1;if(n){let o=i.attrs,s=[],c=o.colwidth;o.rowspan>1&&(o={...o,rowspan:1}),o.colspan>1&&(o={...o,colspan:1});let l=iy(t),u=t.tr;for(let e=0;e{n.attrs[e]!==t&&a.setNodeMarkup(r,null,{...n.attrs,[e]:t})}):a.setNodeMarkup(i.pos,null,{...i.nodeAfter.attrs,[e]:t}),r(a)}return!0}}function Sy(e){return function(t,n){if(!zv(t))return!1;if(n){let r=Fv(t.schema),i=iy(t),a=t.tr,o=i.map.cellsInRect(e==`column`?{left:i.left,top:0,right:i.right,bottom:i.map.height}:e==`row`?{left:0,top:i.top,right:i.map.width,bottom:i.bottom}:i),s=o.map(e=>i.table.nodeAt(e));for(let e=0;e{let t=e+i.tableStart,n=a.doc.nodeAt(t);n&&a.setNodeMarkup(t,u,n.attrs)}),n(a)}return!0}}wy(`row`,{useDeprecatedLogic:!0}),wy(`column`,{useDeprecatedLogic:!0});var Ty=wy(`cell`,{useDeprecatedLogic:!0});function Ey(e,t){if(t<0){let t=e.nodeBefore;if(t)return e.pos-t.nodeSize;for(let t=e.index(-1)-1,n=e.before();t>=0;t--){let r=e.node(-1).child(t),i=r.lastChild;if(i)return n-1-i.nodeSize;n-=r.nodeSize}}else{if(e.index()0;r--)if(n.node(r).type.spec.tableRole==`table`)return t&&t(e.tr.delete(n.before(r),n.after(r)).scrollIntoView()),!0;return!1}function ky(e,t){let n=e.selection;if(!(n instanceof J))return!1;if(t){let r=e.tr,i=Fv(e.schema).cell.createAndFill().content;n.forEachCell((e,t)=>{e.content.eq(i)||r.replace(r.mapping.map(t+1),r.mapping.map(t+e.nodeSize-1),new m(i,0,0))}),r.docChanged&&t(r)}return!0}function Ay(e){if(e.size===0)return null;let{content:t,openStart:n,openEnd:r}=e;for(;t.childCount==1&&(n>0&&r>0||t.child(0).type.spec.tableRole==`table`);)n--,r--,t=t.child(0).content;let i=t.child(0),a=i.type.spec.tableRole,o=i.type.schema,s=[];if(a==`row`)for(let e=0;e=0;t--){let{rowspan:i,colspan:a}=r.child(t).attrs;for(let t=e;t=t.length&&t.push(c.empty),n[i]r&&(s=s.type.createChecked(Kv(s.attrs,s.attrs.colspan,n+s.attrs.colspan-r),s.content)),o.push(s),n+=s.attrs.colspan;for(let n=1;ni&&(t=t.type.create({...t.attrs,rowspan:Math.max(1,i-t.attrs.rowspan)},t.content)),o.push(t)}e.push(c.from(o))}n=e,t=i}return{width:e,height:t,rows:n}}function Py(e,t,n,r,i,a,o){let s=e.doc.type.schema,l=Fv(s),u,d;if(i>t.width)for(let a=0,s=0;at.height){let s=[];for(let e=0,r=(t.height-1)*t.width;e=t.width?!1:n.nodeAt(t.map[r+e]).type==l.header_cell;s.push(i?d||=l.header_cell.createAndFill():u||=l.cell.createAndFill())}let f=l.row.create(null,c.from(s)),p=[];for(let e=t.height;e{if(!i)return!1;let a=n.selection;if(a instanceof J)return zy(n,r,k.near(a.$headCell,t));if(e!=`horiz`&&!a.empty)return!1;let o=Gy(i,e,t);if(o==null)return!1;if(e==`horiz`)return zy(n,r,k.near(n.doc.resolve(a.head+t),t));{let i=n.doc.resolve(o),a=Gv(i,e,t),s;return s=a?k.near(a,1):t<0?k.near(n.doc.resolve(i.before(-1)),-1):k.near(n.doc.resolve(i.after(-1)),1),zy(n,r,s)}}}function Vy(e,t){return(n,r,i)=>{if(!i)return!1;let a=n.selection,o;if(a instanceof J)o=a;else{let r=Gy(i,e,t);if(r==null)return!1;o=new J(n.doc.resolve(r))}let s=Gv(o.$headCell,e,t);return s?zy(n,r,new J(o.$anchorCell,s)):!1}}function Hy(e,t){let n=e.state.doc,r=Lv(n.resolve(t));return r?(e.dispatch(e.state.tr.setSelection(new J(r))),!0):!1}function Uy(e,t,n){if(!zv(e.state))return!1;let r=Ay(n),i=e.state.selection;if(i instanceof J){r||={width:1,height:1,rows:[c.from(My(Fv(e.state.schema).cell,n))]};let t=i.$anchorCell.node(-1),a=i.$anchorCell.start(-1),o=q.get(t).rectBetween(i.$anchorCell.pos-a,i.$headCell.pos-a);return r=Ny(r,o.right-o.left,o.bottom-o.top),Ly(e.state,e.dispatch,a,o,r),!0}if(r){let t=Bv(e.state),n=t.start(-1);return Ly(e.state,e.dispatch,n,q.get(t.node(-1)).findCell(t.pos-n),r),!0}return!1}function Wy(e,t){if(t.button!=0||t.ctrlKey||t.metaKey)return;let n=Ky(e,t.target),r;if(t.shiftKey&&e.state.selection instanceof J)i(e.state.selection.$anchorCell,t),t.preventDefault();else if(t.shiftKey&&n&&(r=Lv(e.state.selection.$anchor))!=null&&qy(e,t)?.pos!=r.pos)i(r,t),t.preventDefault();else if(!n)return;function i(t,n){let r=qy(e,n),i=Iv.getState(e.state)==null;if(!r||!Wv(t,r)){if(i)r=t;else return}let a=new J(t,r);if(i||!e.state.selection.eq(a)){let n=e.state.tr.setSelection(a);i&&n.setMeta(Iv,t.pos),e.dispatch(n)}}function a(){e.root.removeEventListener(`mouseup`,a),e.root.removeEventListener(`dragstart`,a),e.root.removeEventListener(`mousemove`,o),Iv.getState(e.state)!=null&&e.dispatch(e.state.tr.setMeta(Iv,-1))}function o(r){let o=r,s=Iv.getState(e.state),c;if(s!=null)c=e.state.doc.resolve(s);else if(Ky(e,o.target)!=n&&(c=qy(e,t),!c))return a();c&&i(c,o)}e.root.addEventListener(`mouseup`,a),e.root.addEventListener(`dragstart`,a),e.root.addEventListener(`mousemove`,o)}function Gy(e,t,n){if(!(e.state.selection instanceof A))return null;let{$head:r}=e.state.selection;for(let i=r.depth-1;i>=0;i--){let a=r.node(i);if((n<0?r.index(i):r.indexAfter(i))!=(n<0?0:a.childCount))return null;if(a.type.spec.tableRole==`cell`||a.type.spec.tableRole==`header_cell`){let a=r.before(i),o=t==`vert`?n>0?`down`:`up`:n>0?`right`:`left`;return e.endOfTextblock(o)?a:null}}return null}function Ky(e,t){for(;t&&t!=e.dom;t=t.parentNode)if(t.nodeName==`TD`||t.nodeName==`TH`)return t;return null}function qy(e,t){let n=e.posAtCoords({left:t.clientX,top:t.clientY});if(!n)return null;let{inside:r,pos:i}=n;return r>=0&&Lv(e.state.doc.resolve(r))||Lv(e.state.doc.resolve(i))}var Jy=class{constructor(e,t){this.node=e,this.defaultCellMinWidth=t,this.dom=document.createElement(`div`),this.dom.className=`tableWrapper`,this.table=this.dom.appendChild(document.createElement(`table`)),this.table.style.setProperty(`--default-cell-min-width`,`${t}px`),this.colgroup=this.table.appendChild(document.createElement(`colgroup`)),Yy(e,this.colgroup,this.table,t),this.contentDOM=this.table.appendChild(document.createElement(`tbody`))}update(e){return e.type==this.node.type&&(this.node=e,Yy(e,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(e){return e.type==`attributes`&&(e.target==this.table||this.colgroup.contains(e.target))}};function Yy(e,t,n,r,i,a){let o=0,s=!0,c=t.firstChild,l=e.firstChild;if(l){for(let e=0,n=0;enew r(e,n,t)),new Qy(-1,!1)},apply(e,t){return t.apply(e)}},props:{attributes:e=>{let t=Xy.getState(e);return t&&t.activeHandle>-1?{class:`resize-cursor`}:{}},handleDOMEvents:{mousemove:(t,n)=>{$y(t,n,e,i)},mouseleave:e=>{eb(e)},mousedown:(e,r)=>{tb(e,r,t,n)}},decorations:e=>{let t=Xy.getState(e);if(t&&t.activeHandle>-1)return ub(e,t.activeHandle)},nodeViews:{}}});return a}var Qy=class e{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(t){let n=this,r=t.getMeta(Xy);if(r&&r.setHandle!=null)return new e(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new e(n.activeHandle,r.setDragging);if(n.activeHandle>-1&&t.docChanged){let r=t.mapping.map(n.activeHandle,-1);return Hv(t.doc.resolve(r))||(r=-1),new e(r,n.dragging)}return n}};function $y(e,t,n,r){if(!e.editable)return;let i=Xy.getState(e.state);if(i&&!i.dragging){let a=rb(t.target),o=-1;if(a){let{left:r,right:i}=a.getBoundingClientRect();t.clientX-r<=n?o=ib(e,t,`left`,n):i-t.clientX<=n&&(o=ib(e,t,`right`,n))}if(o!=i.activeHandle){if(!r&&o!==-1){let t=e.state.doc.resolve(o),n=t.node(-1),r=q.get(n),i=t.start(-1);if(r.colCount(t.pos-i)+t.nodeAfter.attrs.colspan-1==r.width-1)return}ob(e,o)}}}function eb(e){if(!e.editable)return;let t=Xy.getState(e.state);t&&t.activeHandle>-1&&!t.dragging&&ob(e,-1)}function tb(e,t,n,r){if(!e.editable)return!1;let i=e.dom.ownerDocument.defaultView??window,a=Xy.getState(e.state);if(!a||a.activeHandle==-1||a.dragging)return!1;let o=e.state.doc.nodeAt(a.activeHandle),s=nb(e,a.activeHandle,o.attrs);e.dispatch(e.state.tr.setMeta(Xy,{setDragging:{startX:t.clientX,startWidth:s}}));function c(t){i.removeEventListener(`mouseup`,c),i.removeEventListener(`mousemove`,l);let r=Xy.getState(e.state);r?.dragging&&(sb(e,r.activeHandle,ab(r.dragging,t,n)),e.dispatch(e.state.tr.setMeta(Xy,{setDragging:null})))}function l(t){if(!t.which)return c(t);let i=Xy.getState(e.state);if(i&&i.dragging){let a=ab(i.dragging,t,n);cb(e,i.activeHandle,a,r)}}return cb(e,a.activeHandle,s,r),i.addEventListener(`mouseup`,c),i.addEventListener(`mousemove`,l),t.preventDefault(),!0}function nb(e,t,{colspan:n,colwidth:r}){let i=r&&r[r.length-1];if(i)return i;let a=e.domAtPos(t),o=a.node.childNodes[a.offset].offsetWidth,s=n;if(r)for(let e=0;epb(e),renderHTML:e=>{let t=fb(e.align);return Ef(t)?{style:`text-align: ${t}`}:{}}}}function gb(e){let t=e.parentElement,n=e.closest(`table`);if(!t||!n)return null;let r=Array.from(t.children).indexOf(e),i=n.querySelectorAll(`colgroup > col`)[r]?.getAttribute(`width`);return i?[parseInt(i,10)]:null}function _b(e){let t=e.getAttribute(`colwidth`);return t?t.split(`,`).map(e=>parseInt(e,10)):gb(e)}var vb=/[ \t\r\n\f]+/g;function yb(e){return e.children.length>0?!1:(e.textContent??``).replace(vb,``)===``}function bb(e){let t=e.createAndFill();if(!t)throw Error(`[tiptap error]: "${e.name}" has no default content to backfill.`);return t.content}function xb(e,t,n){if(!(n in t))return;let r=t[n];(r===1||r===`1`||r==null)&&delete e[n]}var Sb=H.create({name:`tableCell`,addOptions(){return{HTMLAttributes:{}}},content:`block+`,addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:_b},align:hb()}},tableRole:`cell`,isolating:!0,parseHTML(){return[{tag:`td`,getAttrs:e=>yb(e)?{}:!1,getContent:(e,t)=>bb(t.nodes[this.name])},{tag:`td`}]},renderHTML({HTMLAttributes:e}){let t=B(this.options.HTMLAttributes,e);return xb(t,e,`colspan`),xb(t,e,`rowspan`),[`td`,t,0]}}),Cb=H.create({name:`tableHeader`,addOptions(){return{HTMLAttributes:{}}},content:`block+`,addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:_b},align:hb()}},tableRole:`header_cell`,isolating:!0,parseHTML(){return[{tag:`th`,getAttrs:e=>yb(e)?{}:!1,getContent:(e,t)=>bb(t.nodes[this.name])},{tag:`th`}]},renderHTML({HTMLAttributes:e}){let t=B(this.options.HTMLAttributes,e);return xb(t,e,`colspan`),xb(t,e,`rowspan`),[`th`,t,0]}}),wb=H.create({name:`tableRow`,addOptions(){return{HTMLAttributes:{}}},content:`(tableCell | tableHeader)*`,tableRole:`row`,parseHTML(){return[{tag:`tr`}]},renderHTML({HTMLAttributes:e}){return[`tr`,B(this.options.HTMLAttributes,e),0]}});function Tb(e,t){return t?[`width`,`${Math.max(t,e)}px`]:[`min-width`,`${e}px`]}function Eb(e,t,n,r,i,a){let o=0,s=!0,c=t.firstChild,l=e.firstChild;if(l!==null)for(let e=0,n=0;e{let r=e.nodes[n];r.spec.tableRole&&(t[r.spec.tableRole]=r)}),e.cached.tableNodeTypes=t,t}function jb(e,t,n,r,i){let a=Ab(e),o=[],s=[];for(let e=0;e{let{selection:t}=e.state;if(!Mb(t))return!1;let n=0;return lu(t.ranges[0].$from,e=>e.type.name===`table`)?.node.descendants(e=>{if(e.type.name===`table`)return!1;[`tableCell`,`tableHeader`].includes(e.type.name)&&(n+=1)}),n===t.ranges.length&&(e.commands.deleteTable(),!0)};function Pb(e,t){let n=e.mapping.map(t);if(lu(e.selection.$from,e=>e.type.name===`table`)?.pos===n)return;let r=e.doc.nodeAt(n);if(!r)return;let i=n+r.nodeSize-1;e.setSelection(A.near(e.doc.resolve(i),-1))}function Fb(e){let t=``,n=0;for(;ne===`|`?`\\|`:e)+e.slice(i,i+r),n=i+r,a=!0;break}i+=o}a||(t+=e.slice(n,n+r),n+=r)}return t}function Ib(e){return e.split(` +`).map(e=>!e.includes(`|`)||!e.includes("`")?e:Fb(e)).join(` +`)}function Lb(e){return(e||``).replaceAll(``,` `).replace(/\s+/g,` `).trim()}function Rb(e,t){return t?e.split(t).join(` +`):e}function zb(e){return e.replace(/\\.|\|/g,e=>e===`|`?`\\|`:e)}function Bb(e,t,n={}){if(!e||!e.content||e.content.length===0)return``;let r=[];e.content.forEach(e=>{let i=[];e.content&&e.content.forEach(e=>{let r=``;r=e.content&&Array.isArray(e.content)&&e.content.length>1?e.content.map(e=>Rb(t.renderChildren(e),n.cellLineSeparator)).join(` +`):Rb(e.content?t.renderChildren(e.content):``,n.cellLineSeparator);let a=zb(Lb(r.replace(/[ \t]*\r?\n[ \t]*/g,`
`))),o=e.type===`tableHeader`,s=mb(e.attrs);i.push({text:a,isHeader:o,align:s})}),r.push(i)});let i=r.reduce((e,t)=>Math.max(e,t.length),0);if(i===0)return``;let a=Array.from({length:i}).fill(0);r.forEach(e=>{for(let t=0;ta[t]&&(a[t]=n),a[t]<3&&(a[t]=3)}});let o=(e,t)=>e+` `.repeat(Math.max(0,t-e.length)),s=r[0],c=s.some(e=>e.isHeader),l=Array.from({length:i}).fill(null);r.forEach(e=>{for(let t=0;tc&&s[t]&&s[t].text||``);return u+=`| ${d.map((e,t)=>o(e,a[t])).join(` | `)} |\n`,u+=`| ${a.map((e,t)=>{let n=Math.max(3,e),r=l[t];return r===`left`?`:${`-`.repeat(n)}`:r===`right`?`${`-`.repeat(n)}:`:r===`center`?`:${`-`.repeat(n)}:`:`-`.repeat(n)}).join(` | `)} |\n`,(c?r.slice(1):r).forEach(e=>{u+=`| ${Array.from({length:i}).fill(0).map((t,n)=>o(e[n]&&e[n].text||``,a[n])).join(` | `)} |\n`}),u}var Vb=new N(`preserveCellSelectionOnContextMenu`);function Hb(e,t){let n=e.posAtCoords({left:t.clientX,top:t.clientY});if(n)return n.pos;if(!(t.target instanceof Node))return null;try{return e.posAtDOM(t.target,0)}catch{return null}}function Ub(e,t){let n=!1;return e.forEachCell((e,r)=>{t>=r&&t{let n=[],r=Array.isArray(e.align)?e.align:[];if(e.header){let i=[];e.header.forEach((e,n)=>{let a=fb(r[n]??e.align),o=a?{align:a}:{};i.push(t.createNode(`tableHeader`,o,[{type:`paragraph`,content:t.parseInline(e.tokens)}]))}),n.push(t.createNode(`tableRow`,{},i))}return e.rows&&e.rows.forEach(e=>{let i=[];e.forEach((e,n)=>{let a=fb(r[n]??e.align),o=a?{align:a}:{};i.push(t.createNode(`tableCell`,o,[{type:`paragraph`,content:t.parseInline(e.tokens)}]))}),n.push(t.createNode(`tableRow`,{},i))}),t.createNode(`table`,void 0,n)},renderMarkdown:(e,t)=>Bb(e,t),markdownTokenizer:{name:`table`,level:`block`,start:e=>{let t=e.split(` `);if(t.length<2)return-1;let n=t[1];return!/^[ \t|:]*-[ \t|:-]*$/.test(n)||!n.includes(`|`)?-1:t[0].includes(`|`)?0:-1},tokenize(e,t,n){let r=e.indexOf(` `),i=r>=0?e.slice(0,r):e,a=i.split(` -`);if(a.length<2)return;let o=a[1];if(!/^[ \t|:]*-[ \t|:-]*$/.test(o)||!o.includes(`|`))return;let s=Pb(i);if(s===i)return;let c=n.blockTokens(s)[0];if(c?.type!==`table`||!c.raw)return;let l=c.raw.split(` +`);if(a.length<2)return;let o=a[1];if(!/^[ \t|:]*-[ \t|:-]*$/.test(o)||!o.includes(`|`))return;let s=Ib(i);if(s===i)return;let c=n.blockTokens(s)[0];if(c?.type!==`table`||!c.raw)return;let l=c.raw.split(` `).length,u=e.split(` `).slice(0,l).join(` -`);return{...c,raw:u}}},addCommands(){return{insertTable:({rows:e=3,cols:t=3,withHeaderRow:n=!0}={})=>({tr:r,dispatch:i,editor:a})=>{let o=kb(a.schema,e,t,n);if(i){let e=r.selection.from+1;r.replaceSelectionWith(o).scrollIntoView().setSelection(A.near(r.doc.resolve(e)))}return!0},addColumnBefore:()=>({state:e,dispatch:t})=>iy(e,t),addColumnAfter:()=>({state:e,dispatch:t})=>ay(e,t),deleteColumn:()=>({state:e,dispatch:t})=>{let n=su(e.selection.$from,e=>e.type.name===`table`);return sy(e,t&&(e=>{n&&Mb(e,n.pos),t(e)}))},addRowBefore:()=>({state:e,dispatch:t})=>uy(e,t),addRowAfter:()=>({state:e,dispatch:t})=>dy(e,t),deleteRow:()=>({state:e,dispatch:t})=>{let n=su(e.selection.$from,e=>e.type.name===`table`);return py(e,t&&(e=>{n&&Mb(e,n.pos),t(e)}))},deleteTable:()=>({state:e,dispatch:t})=>Ey(e,t),mergeCells:()=>({state:e,dispatch:t})=>gy(e,t),splitCell:()=>({state:e,dispatch:t})=>_y(e,t),toggleHeaderColumn:()=>({state:e,dispatch:t})=>Sy(`column`)(e,t),toggleHeaderRow:()=>({state:e,dispatch:t})=>Sy(`row`)(e,t),toggleHeaderCell:()=>({state:e,dispatch:t})=>Cy(e,t),mergeOrSplit:()=>({state:e,dispatch:t})=>gy(e,t)?!0:_y(e,t),setCellAttribute:(e,t)=>({state:n,dispatch:r})=>yy(e,t)(n,r),goToNextCell:()=>({state:e,dispatch:t})=>Ty(1)(e,t),goToPreviousCell:()=>({state:e,dispatch:t})=>Ty(-1)(e,t),fixTables:()=>({state:e,dispatch:t})=>(t&&ey(e),!0),setCellSelection:e=>({tr:t,dispatch:n})=>{if(n){let n=X.create(t.doc,e.anchorCell,e.headCell);t.setSelection(n)}return!0}}},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.goToNextCell()?!0:this.editor.can().addRowAfter()?this.editor.chain().addRowAfter().goToNextCell().run():!1,"Shift-Tab":()=>this.editor.commands.goToPreviousCell(),Backspace:jb,"Mod-Backspace":jb,Delete:jb,"Mod-Delete":jb}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[Yy({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:null,lastColumnResizable:this.options.lastColumnResizable})]:[],lb({allowTableNodeSelection:this.options.allowTableNodeSelection}),Hb()]},addNodeView(){let e=this.options.View;return e?({node:t,view:n,HTMLAttributes:r})=>{let i=H(this.options.HTMLAttributes,r);return new e(t,this.options.cellMinWidth,n,i)}:null},extendNodeSchema(e){return{tableRole:V(B(e,`tableRole`,{name:e.name,options:e.options,storage:e.storage}))}}});U.create({name:`tableKit`,addExtensions(){let e=[];return this.options.table!==!1&&e.push(Ub.configure(this.options.table)),this.options.tableCell!==!1&&e.push(bb.configure(this.options.tableCell)),this.options.tableHeader!==!1&&e.push(xb.configure(this.options.tableHeader)),this.options.tableRow!==!1&&e.push(Sb.configure(this.options.tableRow)),e}});var Wb=U.create({name:`textAlign`,addOptions(){return{types:[],alignments:[`left`,`center`,`right`,`justify`],defaultAlignment:null}},addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:e=>{let t=e.style.textAlign;return this.options.alignments.includes(t)?t:this.options.defaultAlignment},renderHTML:e=>!wf(e.textAlign)||!this.options.alignments.includes(e.textAlign)?{}:{style:`text-align: ${e.textAlign}`}}}}]},addCommands(){return{setTextAlign:e=>({commands:t})=>this.options.alignments.includes(e)?this.options.types.map(n=>t.updateAttributes(n,{textAlign:e})).some(e=>e):!1,unsetTextAlign:()=>({commands:e})=>this.options.types.map(t=>e.resetAttributes(t,`textAlign`)).some(e=>e),toggleTextAlign:e=>({editor:t,commands:n})=>this.options.alignments.includes(e)?t.isActive({textAlign:e})?n.unsetTextAlign():n.setTextAlign(e):!1}},addKeyboardShortcuts(){return{"Mod-Shift-l":()=>this.editor.commands.setTextAlign(`left`),"Mod-Shift-e":()=>this.editor.commands.setTextAlign(`center`),"Mod-Shift-r":()=>this.editor.commands.setTextAlign(`right`),"Mod-Shift-j":()=>this.editor.commands.setTextAlign(`justify`)}}}),Gb=vv,Kb=20,qb=(e,t=0)=>{let n=[];return!e.children.length||t>Kb||Array.from(e.children).forEach(e=>{e.tagName===`SPAN`?n.push(e):e.children.length&&n.push(...qb(e,t+1))}),n},Jb=e=>{if(!e.children.length)return;let t=qb(e);t&&t.forEach(e=>{var t;let n=e.getAttribute(`style`),r=(t=e.parentElement)==null||(t=t.closest(`span`))==null?void 0:t.getAttribute(`style`);e.setAttribute(`style`,`${r};${n}`)})},Yb=Hf.create({name:`textStyle`,priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!0}},parseHTML(){return[{tag:`span`,consuming:!1,getAttrs:e=>e.hasAttribute(`style`)?(this.options.mergeNestedSpanStyles&&Jb(e),{}):!1}]},renderHTML({HTMLAttributes:e}){return[`span`,H(this.options.HTMLAttributes,e),0]},addCommands(){return{toggleTextStyle:e=>({commands:t})=>t.toggleMark(this.name,e),removeEmptyTextStyle:()=>({tr:e})=>{let{selection:t}=e;return e.doc.nodesBetween(t.from,t.to,(t,n)=>{if(!t.isInline)return!0;t.marks.filter(e=>e.type===this.type).some(e=>Object.values(e.attrs).some(e=>!!e))||e.removeMark(n,n+t.nodeSize,this.type)}),!0}}}}),Xb=U.create({name:`backgroundColor`,addOptions(){return{types:[`textStyle`]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{backgroundColor:{default:null,parseHTML:e=>(bf(e,`background-color`)??e.style.backgroundColor)?.replace(/['"]+/g,``),renderHTML:e=>wf(e.backgroundColor)?{style:`background-color: ${e.backgroundColor}`}:{}}}}]},addCommands(){return{setBackgroundColor:e=>({chain:t})=>t().setMark(`textStyle`,{backgroundColor:e}).run(),unsetBackgroundColor:()=>({chain:e})=>e().setMark(`textStyle`,{backgroundColor:null}).removeEmptyTextStyle().run()}}}),Zb=U.create({name:`color`,addOptions(){return{types:[`textStyle`]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{color:{default:null,parseHTML:e=>(bf(e,`color`)??e.style.color)?.replace(/['"]+/g,``),renderHTML:e=>wf(e.color)?{style:`color: ${e.color}`}:{}}}}]},addCommands(){return{setColor:e=>({chain:t})=>t().setMark(`textStyle`,{color:e}).run(),unsetColor:()=>({chain:e})=>e().setMark(`textStyle`,{color:null}).removeEmptyTextStyle().run()}}}),Qb=U.create({name:`fontFamily`,addOptions(){return{types:[`textStyle`]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontFamily:{default:null,parseHTML:e=>bf(e,`font-family`)??e.style.fontFamily,renderHTML:e=>wf(e.fontFamily)?{style:`font-family: ${e.fontFamily}`}:{}}}}]},addCommands(){return{setFontFamily:e=>({chain:t})=>t().setMark(`textStyle`,{fontFamily:e}).run(),unsetFontFamily:()=>({chain:e})=>e().setMark(`textStyle`,{fontFamily:null}).removeEmptyTextStyle().run()}}}),$b=U.create({name:`fontSize`,addOptions(){return{types:[`textStyle`]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontSize:{default:null,parseHTML:e=>bf(e,`font-size`)??e.style.fontSize,renderHTML:e=>wf(e.fontSize)?{style:`font-size: ${e.fontSize}`}:{}}}}]},addCommands(){return{setFontSize:e=>({chain:t})=>t().setMark(`textStyle`,{fontSize:e}).run(),unsetFontSize:()=>({chain:e})=>e().setMark(`textStyle`,{fontSize:null}).removeEmptyTextStyle().run()}}}),ex=U.create({name:`lineHeight`,addOptions(){return{types:[`textStyle`]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{lineHeight:{default:null,parseHTML:e=>bf(e,`line-height`)??e.style.lineHeight,renderHTML:e=>wf(e.lineHeight)?{style:`line-height: ${e.lineHeight}`}:{}}}}]},addCommands(){return{setLineHeight:e=>({chain:t})=>t().setMark(`textStyle`,{lineHeight:e}).run(),unsetLineHeight:()=>({chain:e})=>e().setMark(`textStyle`,{lineHeight:null}).removeEmptyTextStyle().run()}}});U.create({name:`textStyleKit`,addExtensions(){let e=[];return this.options.backgroundColor!==!1&&e.push(Xb.configure(this.options.backgroundColor)),this.options.color!==!1&&e.push(Zb.configure(this.options.color)),this.options.fontFamily!==!1&&e.push(Qb.configure(this.options.fontFamily)),this.options.fontSize!==!1&&e.push($b.configure(this.options.fontSize)),this.options.lineHeight!==!1&&e.push(ex.configure(this.options.lineHeight)),this.options.textStyle!==!1&&e.push(Yb.configure(this.options.textStyle)),e}});var tx={undo:`M7.5 4.5 4 8l3.5 3.5M4 8h8a4 4 0 0 1 0 8H9`,redo:`M12.5 4.5 16 8l-3.5 3.5M16 8H8a4 4 0 0 0 0 8h3`,bold:`M6 4h4.5a3 3 0 0 1 0 6H6zM6 10h5.5a3 3 0 0 1 0 6H6z`,italic:`M9 4h6M5 16h6M12.5 4l-5 12`,underline:`M6 4v5a4 4 0 0 0 8 0V4M5 17h10`,strike:`M3.5 10h13M13.5 6.2C13 4.9 11.7 4 10 4 8 4 6.6 5.2 6.6 6.8c0 .9.4 1.7 1.2 2.2M7 13.6c.5 1.4 1.8 2.4 3.4 2.4 2 0 3.4-1.1 3.4-2.8 0-.5-.1-.9-.3-1.2`,link:`M8.6 11.4a3.2 3.2 0 0 0 4.6 0l2.3-2.3a3.2 3.2 0 0 0-4.6-4.6l-.9.9M11.4 8.6a3.2 3.2 0 0 0-4.6 0l-2.3 2.3a3.2 3.2 0 0 0 4.6 4.6l.9-.9`,unlink:`M10.6 5.4l.3-.3a3.2 3.2 0 0 1 4.6 4.6l-1.2 1.2M9.4 14.6l-.3.3a3.2 3.2 0 0 1-4.6-4.6l1.2-1.2M3.5 3.5l13 13`,bulletList:`M8 5h9M8 10h9M8 15h9M3.4 5a.6.6 0 1 0 1.2 0 .6.6 0 1 0-1.2 0M3.4 10a.6.6 0 1 0 1.2 0 .6.6 0 1 0-1.2 0M3.4 15a.6.6 0 1 0 1.2 0 .6.6 0 1 0-1.2 0`,orderedList:`M8.5 5h8.5M8.5 10h8.5M8.5 15h8.5M3.5 3.5h1v3.5M3.3 7h2.4M3.3 12.6c0-.6.5-1.1 1.1-1.1s1.1.5 1.1 1c0 .9-2.2 1.8-2.2 2.9h2.3`,blockquote:`M3.5 10.5c0-3 1.2-4.6 3.5-5.2M3.5 10.5h3.2v4H3.5zM10.5 10.5c0-3 1.2-4.6 3.5-5.2M10.5 10.5h3.2v4h-3.2z`,alignLeft:`M3 5h14M3 10h9M3 15h12`,alignCenter:`M3 5h14M5.5 10h9M4 15h12`,alignRight:`M3 5h14M8 10h9M5 15h12`,alignJustify:`M3 5h14M3 10h14M3 15h14`,table:`M4.5 4h11A1.5 1.5 0 0 1 17 5.5v9a1.5 1.5 0 0 1-1.5 1.5h-11A1.5 1.5 0 0 1 3 14.5v-9A1.5 1.5 0 0 1 4.5 4zM3 8.5h14M3 12.3h14M8 8.5V16M12.5 8.5V16`,image:`M4.5 4h11A1.5 1.5 0 0 1 17 5.5v9a1.5 1.5 0 0 1-1.5 1.5h-11A1.5 1.5 0 0 1 3 14.5v-9A1.5 1.5 0 0 1 4.5 4zM3.5 14l4-4 3 3 2-2 4 4M14 7.6a1.2 1.2 0 1 1-2.4 0 1.2 1.2 0 0 1 2.4 0z`,horizontalRule:`M2.5 10h15M5 5.5h10M5 14.5h10`,pageBreak:`M5 3v4h10V3M5 17v-4h10v4M2.5 10h2M6.5 10h2M11.5 10h2M15.5 10h2`,removeFormat:`M4.5 4.5h9M9 4.5 7 15.5M12.5 12.5l4 4M16.5 12.5l-4 4`,chevron:`M6 8l4 4 4-4`,check:`M4.5 10.5l3.5 3.5 7.5-8`,close:`M5.5 5.5l9 9M14.5 5.5l-9 9`,lock:`M6 9V6.5a4 4 0 0 1 8 0V9M5.5 9h9A1.5 1.5 0 0 1 16 10.5v5a1.5 1.5 0 0 1-1.5 1.5h-9A1.5 1.5 0 0 1 4 15.5v-5A1.5 1.5 0 0 1 5.5 9z`,plus:`M10 4.5v11M4.5 10h11`,trash:`M4.5 6h11M8 6V4.5h4V6M6 6l.7 9.6a1.5 1.5 0 0 0 1.5 1.4h3.6a1.5 1.5 0 0 0 1.5-1.4L14 6`,eye:`M2.5 10s2.8-5 7.5-5 7.5 5 7.5 5-2.8 5-7.5 5-7.5-5-7.5-5zM12.2 10a2.2 2.2 0 1 1-4.4 0 2.2 2.2 0 0 1 4.4 0z`,callout:`M10 3a7 7 0 1 1 0 14 7 7 0 0 1 0-14zM10 9v4.5M10 6.6v.2`,video:`M4.5 4.5h11A1.5 1.5 0 0 1 17 6v8a1.5 1.5 0 0 1-1.5 1.5h-11A1.5 1.5 0 0 1 3 14V6a1.5 1.5 0 0 1 1.5-1.5zM8.5 7.5v5l4-2.5z`},nx={undo:`rotate-left`,redo:`rotate-right`,bold:`bold`,italic:`italic`,underline:`underline`,strike:`strikethrough`,link:`link`,unlink:`link-slash`,bulletList:`list-ul`,orderedList:`list-ol`,blockquote:`quote-left`,alignLeft:`align-left`,alignCenter:`align-center`,alignRight:`align-right`,alignJustify:`align-justify`,table:`table`,image:`image`,horizontalRule:`minus`,pageBreak:`file-circle-plus`,removeFormat:`text-slash`,chevron:`chevron-down`,check:`check`,close:`xmark`,lock:`lock`,plus:`plus`,trash:`trash-can`,eye:`eye`,callout:`circle-info`,video:`circle-play`},rx=`http://www.w3.org/2000/svg`;function ix(e){return typeof document<`u`?document.documentElement.dataset[e]:void 0}function ax(e){if(ix(`efeIcons`)===`fontawesome`&&nx[e]){let t=document.createElement(`i`);return t.className=`efe-icon efe-icon--fa fa-solid fa-${nx[e]}`,t.setAttribute(`aria-hidden`,`true`),t}let t=document.createElementNS(rx,`svg`);t.setAttribute(`viewBox`,`0 0 20 20`),t.setAttribute(`class`,`efe-icon`),t.setAttribute(`aria-hidden`,`true`),t.setAttribute(`focusable`,`false`);let n=document.createElementNS(rx,`path`);return n.setAttribute(`d`,tx[e]),t.appendChild(n),t}function ox(e,t){let n=ix(`efeTooltip`);n&&/^data-[a-z-]+$/.test(n)?e.setAttribute(n,t):e.title=t}function sx({name:e,label:t,shortcut:n,className:r=`efe-btn`}){let i=document.createElement(`button`);return i.type=`button`,i.className=r,i.setAttribute(`aria-label`,t),ox(i,n?`${t} (${n})`:t),i.appendChild(ax(e)),i}var cx=[`top`,`right`,`bottom`,`left`],lx=[`start`,`end`],ux=cx.reduce((e,t)=>e.concat(t,t+`-`+lx[0],t+`-`+lx[1]),[]),dx=Math.min,fx=Math.max,px=Math.round,mx=Math.floor,hx=e=>({x:e,y:e}),gx={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function _x(e,t,n){return fx(e,dx(t,n))}function vx(e,t){return typeof e==`function`?e(t):e}function yx(e){return e.split(`-`)[0]}function bx(e){return e.split(`-`)[1]}function xx(e){return e===`x`?`y`:`x`}function Sx(e){return e===`y`?`height`:`width`}function Cx(e){let t=e[0];return t===`t`||t===`b`?`y`:`x`}function wx(e){return xx(Cx(e))}function Tx(e,t,n){n===void 0&&(n=!1);let r=bx(e),i=wx(e),a=Sx(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=Px(o)),[o,Px(o)]}function Ex(e){let t=Px(e);return[Dx(e),t,Dx(t)]}function Dx(e){return e.includes(`start`)?e.replace(`start`,`end`):e.replace(`end`,`start`)}var Ox=[`left`,`right`],kx=[`right`,`left`],Ax=[`top`,`bottom`],jx=[`bottom`,`top`];function Mx(e,t,n){switch(e){case`top`:case`bottom`:return n?t?kx:Ox:t?Ox:kx;case`left`:case`right`:return t?Ax:jx;default:return[]}}function Nx(e,t,n,r){let i=bx(e),a=Mx(yx(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(Dx)))),a}function Px(e){let t=yx(e);return gx[t]+e.slice(t.length)}function Fx(e){return{top:e.top??0,right:e.right??0,bottom:e.bottom??0,left:e.left??0}}function Ix(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:Fx(e)}function Lx(e){let{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function Rx(e,t,n){let{reference:r,floating:i}=e,a=Cx(t),o=wx(t),s=Sx(o),c=yx(t),l=a===`y`,u=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,f=r[s]/2-i[s]/2,p;switch(c){case`top`:p={x:u,y:r.y-i.height};break;case`bottom`:p={x:u,y:r.y+r.height};break;case`right`:p={x:r.x+r.width,y:d};break;case`left`:p={x:r.x-i.width,y:d};break;default:p={x:r.x,y:r.y}}let m=bx(t);return m&&(p[o]+=f*(m===`end`?1:-1)*(n&&l?-1:1)),p}async function zx(e,t){t===void 0&&(t={});let{x:n,y:r,platform:i,rects:a,elements:o,strategy:s}=e,{boundary:c=`clippingAncestors`,rootBoundary:l=`viewport`,elementContext:u=`floating`,altBoundary:d=!1,padding:f=0}=vx(t,e),p=Ix(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=Lx(await i.getClippingRect({element:await(i.isElement==null?void 0:i.isElement(m))??!0?m:m.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(o.floating)),boundary:c,rootBoundary:l,strategy:s})),g=u===`floating`?{x:n,y:r,width:a.floating.width,height:a.floating.height}:a.reference,_=await(i.getOffsetParent==null?void 0:i.getOffsetParent(o.floating)),v=await(i.isElement==null?void 0:i.isElement(_))&&await(i.getScale==null?void 0:i.getScale(_))||{x:1,y:1},y=Lx(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:g,offsetParent:_,strategy:s}):g);return{top:(h.top-y.top+p.top)/v.y,bottom:(y.bottom-h.bottom+p.bottom)/v.y,left:(h.left-y.left+p.left)/v.x,right:(y.right-h.right+p.right)/v.x}}var Bx=50,Vx=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:zx},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=Rx(l,r,c),f=r,p=0,m={};for(let n=0;n({name:`arrow`,options:e,async fn(t){let{x:n,y:r,placement:i,rects:a,platform:o,elements:s,middlewareData:c}=t,{element:l,padding:u=0}=vx(e,t)||{};if(l==null)return{};let d=Ix(u),f={x:n,y:r},p=wx(i),m=Sx(p),h=await o.getDimensions(l),g=p===`y`,_=g?`top`:`left`,v=g?`bottom`:`right`,y=g?`clientHeight`:`clientWidth`,b=a.reference[m]+a.reference[p]-f[p]-a.floating[m],x=f[p]-a.reference[p],S=await(o.getOffsetParent==null?void 0:o.getOffsetParent(l)),C=S?S[y]:0;C&&await(o.isElement==null?void 0:o.isElement(S))||(C=s.floating[y]||a.floating[m]);let w=b/2-x/2,T=C/2-h[m]/2-1,ee=dx(d[_],T),E=dx(d[v],T),D=C-h[m]-E,te=C/2-h[m]/2+w,ne=_x(ee,te,D),re=!c.arrow&&bx(i)!=null&&te!==ne&&a.reference[m]/2-(tebx(t)===e),...n.filter(t=>bx(t)!==e)]:n.filter(e=>yx(e)===e)).filter(n=>!e||bx(n)===e||(t?Dx(n)!==n:!1))}var Wx=function(e){return e===void 0&&(e={}),{name:`autoPlacement`,options:e,async fn(t){let{rects:n,middlewareData:r,placement:i,platform:a,elements:o}=t,{crossAxis:s=!1,alignment:c,allowedPlacements:l=ux,autoAlignment:u=!0,...d}=vx(e,t),f=c!==void 0||l===ux?Ux(c||null,u,l):l,p=r.autoPlacement?.index||0,m=f[p];if(m==null)return{};if(i!==m)return{reset:{placement:f[0]}};let h=await a.detectOverflow(t,d),g=Tx(m,n,await(a.isRTL==null?void 0:a.isRTL(o.floating))),_=[h[yx(m)],h[g[0]],h[g[1]]],v=[...r.autoPlacement?.overflows||[],{placement:m,overflows:_}],y=f[p+1];if(y)return{data:{index:p+1,overflows:v},reset:{placement:y}};let b=v.map(e=>{let t=bx(e.placement);return[e.placement,t&&s?e.overflows.slice(0,2).reduce((e,t)=>e+t,0):e.overflows[0],e.overflows]}).sort((e,t)=>e[1]-t[1]),x=b.filter(e=>e[2].slice(0,bx(e[0])?2:3).every(e=>e<=0))[0]?.[0]||b[0][0];return x===i?{}:{data:{index:p+1,overflows:v},reset:{placement:x}}}}},Gx=function(e){return e===void 0&&(e={}),{name:`flip`,options:e,async fn(t){var n;let{placement:r,middlewareData:i,rects:a,initialPlacement:o,platform:s,elements:c}=t,{mainAxis:l=!0,crossAxis:u=!0,fallbackPlacements:d,fallbackStrategy:f=`bestFit`,fallbackAxisSideDirection:p=`none`,flipAlignment:m=!0,...h}=vx(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=yx(r),_=Cx(o),v=yx(o)===o,y=await(s.isRTL==null?void 0:s.isRTL(c.floating)),b=d||(v||!m?[Px(o)]:Ex(o)),x=p!==`none`;!d&&x&&b.push(...Nx(o,m,p,y));let S=[o,...b],C=await s.detectOverflow(t,h),w=[],T=i.flip?.overflows||[];if(l&&w.push(C[g]),u){let e=Tx(r,a,y);w.push(C[e[0]],C[e[1]])}if(T=[...T,{placement:r,overflows:w}],!w.every(e=>e<=0)){let e=(i.flip?.index||0)+1,t=S[e];if(t&&(u!==`alignment`||_===Cx(t)||T.every(e=>Cx(e.placement)!==_||e.overflows[0]>0)))return{data:{index:e,overflows:T},reset:{placement:t}};let n=T.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0]?.placement;if(!n)switch(f){case`bestFit`:{let e=T.filter(e=>{if(x){let t=Cx(e.placement);return t===_||t===`y`}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0]?.[0];e&&(n=e);break}case`initialPlacement`:n=o}if(r!==n)return{reset:{placement:n}}}return{}}}};function Kx(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function qx(e){return cx.some(t=>e[t]>=0)}var Jx=function(e){return e===void 0&&(e={}),{name:`hide`,options:e,async fn(t){let{rects:n,platform:r}=t,{strategy:i=`referenceHidden`,...a}=vx(e,t);switch(i){case`referenceHidden`:{let e=Kx(await r.detectOverflow(t,{...a,elementContext:`reference`}),n.reference);return{data:{referenceHiddenOffsets:e,referenceHidden:qx(e)}}}case`escaped`:{let e=Kx(await r.detectOverflow(t,{...a,altBoundary:!0}),n.floating);return{data:{escapedOffsets:e,escaped:qx(e)}}}default:return{}}}}};function Yx(e){let t=dx(...e.map(e=>e.left)),n=dx(...e.map(e=>e.top)),r=fx(...e.map(e=>e.right)),i=fx(...e.map(e=>e.bottom));return{x:t,y:n,width:r-t,height:i-n}}function Xx(e){let t=e.slice().sort((e,t)=>e.y-t.y),n=[],r=null;for(let e=0;er.height/2?n.push([i]):n[n.length-1].push(i),r=i}return n.map(e=>Lx(Yx(e)))}var Zx=function(e){return e===void 0&&(e={}),{name:`inline`,options:e,async fn(t){let{placement:n,elements:r,rects:i,platform:a,strategy:o}=t,{padding:s=2,x:c,y:l}=vx(e,t),u=Array.from(await(a.getClientRects==null?void 0:a.getClientRects(r.reference))||[]);if(!u.length)return{};let d=Xx(u),f=Lx(Yx(u)),p=Ix(s);function m(){if(d.length===2&&(d[0].left>d[1].right||d[1].left>d[0].right)&&c!=null&&l!=null)return d.find(e=>c>e.left-p.left&&ce.top-p.top&&l=2){if(Cx(n)===`y`){let e=d[0],t=d[d.length-1],r=yx(n)===`top`,i=e.top,a=t.bottom,o=r?e.left:t.left;return Lx({x:o,y:i,width:(r?e.right:t.right)-o,height:a-i})}let e=yx(n)===`left`,t=fx(...d.map(e=>e.right)),r=dx(...d.map(e=>e.left)),i=d.filter(n=>e?n.left===r:n.right===t),a=i[0].top,o=i[i.length-1].bottom;return Lx({x:r,y:a,width:t-r,height:o-a})}return f}let h=await a.getElementRects({reference:{getBoundingClientRect:m},floating:r.floating,strategy:o});return i.reference.x!==h.reference.x||i.reference.y!==h.reference.y||i.reference.width!==h.reference.width||i.reference.height!==h.reference.height?{reset:{rects:h}}:{}}}},Qx=new Set([`left`,`top`]);async function $x(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=yx(n),s=bx(n),c=Cx(n)===`y`,l=Qx.has(o)?-1:1,u=a&&c?-1:1,d=vx(t,e),{mainAxis:f,crossAxis:p,alignmentAxis:m}=typeof d==`number`?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return s&&typeof m==`number`&&(p=s===`end`?m*-1:m),c?{x:p*u,y:f*l}:{x:f*l,y:p*u}}var eS=function(e){return e===void 0&&(e=0),{name:`offset`,options:e,async fn(t){var n;let{x:r,y:i,placement:a,middlewareData:o}=t,s=await $x(t,e);return a===o.offset?.placement&&(n=o.arrow)!=null&&n.alignmentOffset?{}:{x:r+s.x,y:i+s.y,data:{...s,placement:a}}}}},tS=function(e){return e===void 0&&(e={}),{name:`shift`,options:e,async fn(t){let{x:n,y:r,placement:i,platform:a}=t,{mainAxis:o=!0,crossAxis:s=!1,limiter:c={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...l}=vx(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=Cx(i),p=xx(f),m=u[p],h=u[f],g=(e,t)=>_x(t+d[e===`y`?`top`:`left`],t,t-d[e===`y`?`bottom`:`right`]);o&&(m=g(p,m)),s&&(h=g(f,h));let _=c.fn({...t,[p]:m,[f]:h});return{..._,data:{x:_.x-n,y:_.y-r,enabled:{[p]:o,[f]:s}}}}}},nS=function(e){return e===void 0&&(e={}),{name:`size`,options:e,async fn(t){let{placement:n,rects:r,platform:i,elements:a}=t,{apply:o=()=>{},...s}=vx(e,t),c=await i.detectOverflow(t,s),l=yx(n),u=bx(n),d=Cx(n)===`y`,{width:f,height:p}=r.floating,m,h;l===`top`||l===`bottom`?(m=l,h=u===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?`start`:`end`)?`left`:`right`):(h=l,m=u===`end`?`top`:`bottom`);let g=p-c.top-c.bottom,_=f-c.left-c.right,v=dx(p-c[m],g),y=dx(f-c[h],_),b=t.middlewareData.shift,x=!b,S=v,C=y;b!=null&&b.enabled.x&&(C=_),b!=null&&b.enabled.y&&(S=g),x&&!u&&(d?C=f-2*fx(c.left,c.right):S=p-2*fx(c.top,c.bottom)),await o({...t,availableWidth:C,availableHeight:S});let w=await i.getDimensions(a.floating);return f!==w.width||p!==w.height?{reset:{rects:!0}}:{}}}};function rS(){return typeof window<`u`}function iS(e){return sS(e)?(e.nodeName||``).toLowerCase():`#document`}function aS(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function oS(e){return((sS(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function sS(e){return rS()?e instanceof Node||e instanceof aS(e).Node:!1}function cS(e){return rS()?e instanceof Element||e instanceof aS(e).Element:!1}function lS(e){return rS()?e instanceof HTMLElement||e instanceof aS(e).HTMLElement:!1}function uS(e){return!rS()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof aS(e).ShadowRoot}function dS(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=SS(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!==`inline`&&i!==`contents`}function fS(e){return/^(table|td|th)$/.test(iS(e))}function pS(e){try{if(e.matches(`:popover-open`))return!0}catch{}try{return e.matches(`:modal`)}catch{return!1}}var mS=/transform|translate|scale|rotate|perspective|filter/,hS=/paint|layout|strict|content/,gS=e=>!!e&&e!==`none`,_S;function vS(e){let t=cS(e)?SS(e):e;return gS(t.transform)||gS(t.translate)||gS(t.scale)||gS(t.rotate)||gS(t.perspective)||!bS()&&(gS(t.backdropFilter)||gS(t.filter))||mS.test(t.willChange||``)||hS.test(t.contain||``)}function yS(e){let t=wS(e);for(;lS(t)&&!xS(t);){if(vS(t))return t;if(pS(t))return null;t=wS(t)}return null}function bS(){return _S??=typeof CSS<`u`&&CSS.supports&&CSS.supports(`-webkit-backdrop-filter`,`none`),_S}function xS(e){return/^(html|body|#document)$/.test(iS(e))}function SS(e){return aS(e).getComputedStyle(e)}function CS(e){return cS(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function wS(e){if(iS(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||uS(e)&&e.host||oS(e);return uS(t)?t.host:t}function TS(e){let t=wS(e);return xS(t)?(e.ownerDocument||e).body:lS(t)&&dS(t)?t:TS(t)}function ES(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=TS(e),i=r===e.ownerDocument?.body,a=aS(r);if(i){let e=DS(a);return t.concat(a,a.visualViewport||[],dS(r)?r:[],e&&n?ES(e):[])}return t.concat(r,ES(r,[],n))}function DS(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function OS(e){let t=SS(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=lS(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=px(n)!==a||px(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function kS(e){return cS(e)?e:e.contextElement}function AS(e){let t=kS(e);if(!lS(t))return hx(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=OS(t),o=(a?px(n.width):n.width)/r,s=(a?px(n.height):n.height)/i;return o&&Number.isFinite(o)||(o=1),s&&Number.isFinite(s)||(s=1),{x:o,y:s}}var jS=hx(0);function MS(e){let t=aS(e);return!bS()||!t.visualViewport?jS:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function NS(e,t,n){return t===void 0&&(t=!1),!!n&&t&&n===aS(e)}function PS(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=kS(e),o=hx(1);t&&(r?cS(r)&&(o=AS(r)):o=AS(e));let s=NS(a,n,r)?MS(a):hx(0),c=(i.left+s.x)/o.x,l=(i.top+s.y)/o.y,u=i.width/o.x,d=i.height/o.y;if(a&&r){let e=aS(a),t=cS(r)?aS(r):r,n=e,i=DS(n);for(;i&&t!==n;){let e=AS(i),t=i.getBoundingClientRect(),r=SS(i),a=t.left+(i.clientLeft+parseFloat(r.paddingLeft))*e.x,o=t.top+(i.clientTop+parseFloat(r.paddingTop))*e.y;c*=e.x,l*=e.y,u*=e.x,d*=e.y,c+=a,l+=o,n=aS(i),i=DS(n)}}return Lx({width:u,height:d,x:c,y:l})}function FS(e,t){let n=CS(e).scrollLeft;return t?t.left+n:PS(oS(e)).left+n}function IS(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-FS(e,n),y:n.top+t.scrollTop}}function LS(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=oS(r),s=t?pS(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=hx(1),u=hx(0),d=lS(r);if((d||!a)&&((iS(r)!==`body`||dS(o))&&(c=CS(r)),d)){let e=PS(r);l=AS(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?IS(o,c):hx(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+u.x+f.x,y:n.y*l.y-c.scrollTop*l.y+u.y+f.y}}function RS(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function zS(e){let t=CS(e),n=e.ownerDocument.body,r=fx(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),i=fx(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight),a=-t.scrollLeft+FS(e),o=-t.scrollTop;return SS(n).direction===`rtl`&&(a+=fx(e.clientWidth,n.clientWidth)-r),{width:r,height:i,x:a,y:o}}var BS=25;function VS(e,t,n){n===void 0&&(n=`viewport`);let r=n===`layoutViewport`,i=aS(e),a=oS(e),o=i.visualViewport,s=a.clientWidth,c=a.clientHeight,l=0,u=0;if(o){let e=!bS()||t===`fixed`;r?e||(l=-o.offsetLeft,u=-o.offsetTop):(s=o.width,c=o.height,e&&(l=o.offsetLeft,u=o.offsetTop))}if(FS(a)<=0){let e=a.ownerDocument,t=e.body,n=getComputedStyle(t),r=e.compatMode===`CSS1Compat`&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,i=Math.abs(a.clientWidth-t.clientWidth-r),o=getComputedStyle(a).scrollbarGutter===`stable both-edges`?i/2:i;o<=BS&&(s-=o)}return{width:s,height:c,x:l,y:u}}function HS(e,t){let n=PS(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=AS(e);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function US(e,t,n){let r;if(t===`viewport`||t===`layoutViewport`)r=VS(e,n,t);else if(t===`document`)r=zS(oS(e));else if(cS(t))r=HS(t,n);else{let n=MS(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return Lx(r)}function WS(e,t){let n=t.get(e);if(n)return n;let r=ES(e,[],!1).filter(e=>cS(e)&&iS(e)!==`body`),i=null,a=SS(e).position===`fixed`,o=a?wS(e):e;for(;cS(o)&&!xS(o);){let e=SS(o),t=vS(o),n=i?i.position:a?`fixed`:``;!t&&(n===`fixed`||n===`absolute`&&e.position===`static`)?r=r.filter(e=>e!==o):i=e,o=wS(o)}return t.set(e,r),r}function GS(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?pS(t)?[]:WS(t,this._c):[].concat(n),r],o=US(t,a[0],i),s=o.top,c=o.right,l=o.bottom,u=o.left;for(let e=1;e{s(!1,1e-7)},1e3)}y=!1}try{r=new IntersectionObserver(b,{...v,root:a.ownerDocument})}catch{r=new IntersectionObserver(b,v)}r.observe(e)}let c=aS(e),l=()=>s(n);return c.addEventListener(`resize`,l),s(!0),()=>{c.removeEventListener(`resize`,l),o()}}function nC(e,t,n,r){r===void 0&&(r={});let{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:o=typeof ResizeObserver==`function`,layoutShift:s=typeof IntersectionObserver==`function`,animationFrame:c=!1}=r,l=kS(e),u=i||a?[...l?ES(l):[],...t?ES(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n),a&&e.addEventListener(`resize`,n)});let d=l&&s?tC(l,n,a):null,f=-1,p=null;o&&(p=new ResizeObserver(e=>{let[r]=e;r&&r.target===l&&p&&t&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var e;(e=p)==null||e.observe(t)})),n()}),l&&!c&&p.observe(l),t&&p.observe(t));let m,h=c?PS(e):null;c&&g();function g(){let t=PS(e);h&&!eC(h,t)&&n(),h=t,m=requestAnimationFrame(g)}return n(),()=>{var e;u.forEach(e=>{i&&e.removeEventListener(`scroll`,n),a&&e.removeEventListener(`resize`,n)}),d?.(),(e=p)==null||e.disconnect(),p=null,c&&cancelAnimationFrame(m)}}var rC=eS,iC=Wx,aC=tS,oC=Gx,sC=nS,cC=Jx,lC=Hx,uC=Zx,dC=(e,t,n)=>{let r=new Map,i=n??{},a={...$S,...i.platform,_c:r};return Vx(e,t,{...i,platform:a})},fC=[`http:`,`https:`,`mailto:`];function pC(e){return e<=32||e===160||e===5760||e===6158||e>=8192&&e<=8233||e===8287||e===12288}function mC(e){let t=``;for(let n of e)pC(n.codePointAt(0))||(t+=n);return t}function hC(e){let t=e;for(let e=0;e<3;e+=1){let e=t.includes(`&`)?gC(t):t;if(e.includes(`%`))try{e=decodeURIComponent(e)}catch{}if(e===t)return e;t=e}return t}function gC(e){let t=document.createElement(`textarea`);return t.innerHTML=e,t.value}function _C(e){if(e==null||e===``)return!0;if(typeof e!=`string`||e.length>2048)return!1;let t=mC(hC(e));if(t.startsWith(`//`))return!1;let n=t.match(/^([a-zA-Z][a-zA-Z0-9+.-]*):/);return n?fC.includes(n[1].toLowerCase()+`:`):!1}function vC(){return yg.configure({openOnClick:!1,autolink:!0,protocols:[`http`,`https`,`mailto`],isAllowedUri:e=>_C(e),HTMLAttributes:{target:null,rel:null,class:null}})}function yC(e){let t=e.slice(0,e.indexOf(`:`)).toLowerCase();return t===`http`||t===`https`?{href:e,target:`_blank`,rel:`noopener noreferrer`}:{href:e}}var bC=new WeakMap;function xC(e,t){if(SC(e),e.dataset.state=`closed`,window.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches){t();return}let n=n=>{n&&n.target!==e||(SC(e),t())};e.addEventListener(`animationend`,n),bC.set(e,{finish:n,timer:setTimeout(n,200)})}function SC(e){let t=bC.get(e);t&&(clearTimeout(t.timer),e.removeEventListener(`animationend`,t.finish),bC.delete(e))}var CC=new WeakMap,wC=0;function TC(e){let t=CC.get(e);return t||(t=EC(e),CC.set(e,t)),t}function EC(e){let t=++wC,n=document.createElement(`div`);n.className=`efe-balloon`,n.setAttribute(`role`,`dialog`),n.setAttribute(`aria-label`,`Link bearbeiten`),n.dataset.state=`closed`;let r=document.createElement(`label`);r.className=`efe-balloon__label`,r.htmlFor=`efe-link-input-${t}`,r.textContent=`Linkadresse`;let i=document.createElement(`input`);i.type=`text`,i.id=`efe-link-input-${t}`,i.className=`efe-balloon__input`,i.placeholder=`https://`,i.autocomplete=`off`,i.spellcheck=!1,i.setAttribute(`inputmode`,`url`);let a=document.createElement(`span`);a.id=`efe-link-error-${t}`,a.className=`efe-balloon__error`,a.textContent=`Nur http, https oder mailto sind erlaubt.`,a.hidden=!0,i.setAttribute(`aria-describedby`,a.id);let o=DC(`check`,`Übernehmen`,`efe-btn efe-btn--primary`);o.dataset.efeCommand=`applyLink`;let s=DC(`unlink`,`Link entfernen`);s.dataset.efeCommand=`unsetLink`;let c=DC(`close`,`Abbrechen`),l=document.createElement(`div`);l.className=`efe-balloon__row`,l.append(i,o,s,c),n.append(r,l,a);let u=!1;function d(e){e?i.setAttribute(`aria-invalid`,`true`):i.removeAttribute(`aria-invalid`),a.hidden=!e}function f(){let{view:t,state:r}=e;dC({getBoundingClientRect:()=>cd(t,r.selection.from,r.selection.to),contextElement:t.dom},n,{placement:`bottom`,middleware:[rC(8),oC(),aC({padding:8})]}).then(({x:e,y:t})=>{n.style.left=`${e}px`,n.style.top=`${t}px`}).catch(()=>{})}function p(e){n.contains(e.target)||m(!1)}function m(t=!0){u&&(u=!1,xC(n,()=>n.remove()),document.removeEventListener(`mousedown`,p,!0),t&&!e.isDestroyed&&e.commands.focus())}function h(){e.isEditable&&e.schema.marks.link&&(i.value=e.getAttributes(`link`).href??``,s.hidden=!e.isActive(`link`),d(!1),u||(u=!0,SC(n),n.dataset.state=`open`,(e.view.dom.parentElement??document.body).appendChild(n),document.addEventListener(`mousedown`,p,!0)),f(),i.focus(),i.select())}function g(){let t=i.value.trim();t?_C(t)?(e.state.selection.empty&&!e.isActive(`link`)?e.chain().focus().insertContent({type:`text`,text:t,marks:[{type:`link`,attrs:yC(t)}]}).run():e.chain().focus().extendMarkRange(`link`).setLink(yC(t)).run(),m(!1)):d(!0):m()}return o.addEventListener(`click`,g),s.addEventListener(`click`,()=>{e.chain().focus().extendMarkRange(`link`).unsetLink().run(),m(!1)}),c.addEventListener(`click`,()=>m()),i.addEventListener(`input`,()=>d(!1)),n.addEventListener(`keydown`,e=>{e.key===`Enter`&&e.target===i?(e.preventDefault(),g()):e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),m())}),e.on(`destroy`,()=>m(!1)),{open:h,close:m,isOpen:()=>u,element:n}}function DC(e,t,n=`efe-btn`){let r=document.createElement(`button`);return r.type=`button`,r.className=n,r.setAttribute(`aria-label`,t),ox(r,t),r.appendChild(ax(e)),r}var OC=U.create({name:`efeLinkShortcut`,addKeyboardShortcuts(){return{"Mod-k":()=>(TC(this.editor).open(),!0)}}}),kC=/^\/(?!\/)[A-Za-z0-9\-._~/%]*\.(?:png|jpe?g|gif|webp|svg)(?:\?[A-Za-z0-9\-._~=&%]*)?$/i,AC=2048;function jC(e){return typeof e==`string`&&e.length<=AC&&kC.test(e)}var MC=W.create({name:`image`,group:`inline`,inline:!0,atom:!0,selectable:!0,draggable:!1,addAttributes(){return{src:{default:null,renderHTML:e=>jC(e.src)?{src:e.src}:{}},alt:{default:``,parseHTML:e=>e.getAttribute(`alt`)??``}}},parseHTML(){return[{tag:`img.efe-image`,getAttrs:e=>jC(e.getAttribute(`src`))?null:!1}]},renderHTML({HTMLAttributes:e}){return[`img`,H({class:`efe-image`},e)]},addKeyboardShortcuts(){return{Backspace:({editor:e})=>{let{selection:t}=e.state;if(!t.empty||t.$from.nodeBefore?.type.name!==this.name)return!1;let n=t.from-t.$from.nodeBefore.nodeSize;return e.commands.deleteRange({from:n,to:t.from})}}}}),NC=W.create({name:`imageBlock`,group:`block`,atom:!0,selectable:!0,draggable:!1,addOptions(){return{upload:null}},addAttributes(){return{src:{default:null},alt:{default:``}}},parseHTML(){return[{tag:`figure.efe-figure`,getAttrs:e=>{let t=e.querySelector(`img`),n=t?.getAttribute(`src`);return jC(n)?{src:n,alt:t.getAttribute(`alt`)??``}:!1}}]},renderHTML({node:e}){let t={alt:e.attrs.alt??``};return jC(e.attrs.src)&&(t.src=e.attrs.src),[`figure`,{class:`efe-figure`},[`img`,t]]},addCommands(){return{insertImageBlock:e=>({commands:t})=>jC(e?.src)&&t.insertContent({type:this.name,attrs:{src:e.src,alt:e.alt??``}})}}}),PC=Object.freeze([{value:`note`,label:`Hinweis`},{value:`important`,label:`Wichtig`},{value:`tip`,label:`Tipp`}]),FC=PC.map(e=>e.value);function IC(e){return PC.find(t=>t.value===e)?.label??PC[0].label}var LC=W.create({name:`callout`,group:`block`,defining:!0,addOptions(){return{blocks:[`paragraph`]}},content(){return`(${this.options.blocks.join(` | `)})+`},addAttributes(){return{variant:{default:`note`,parseHTML:e=>FC.includes(e.dataset.variant)?e.dataset.variant:`note`,renderHTML:e=>({"data-variant":FC.includes(e.variant)?e.variant:`note`})}}},parseHTML(){return[{tag:`aside.efe-callout`}]},renderHTML({node:e,HTMLAttributes:t}){let n=FC.includes(e.attrs.variant)?e.attrs.variant:`note`;return[`aside`,{...t,class:`efe-callout efe-callout--${n}`,role:`note`,"aria-label":IC(n)},0]},addCommands(){return{setCallout:e=>({commands:t,editor:n})=>FC.includes(e)?n.isActive(this.name)?t.updateAttributes(this.name,{variant:e}):t.wrapIn(this.name,{variant:e}):!1,unsetCallout:()=>({commands:e})=>e.lift(this.name)}}}),RC=/^[A-Za-z0-9_-]{11}$/,zC=/^\d{1,12}$/,BC=/^[a-f0-9]{6,20}$/,VC=/^[A-Za-z0-9]{1,16}$/,HC=Object.freeze({youtube:`YouTube`,vimeo:`Vimeo`,streamable:`Streamable`});function UC(e){if(!e||typeof e!=`object`)return!1;let{provider:t,id:n,hash:r=null}=e;return t===`youtube`?typeof n==`string`&&RC.test(n)&&r===null:t===`vimeo`?typeof n==`string`&&zC.test(n)&&(r===null||typeof r==`string`&&BC.test(r)):t===`streamable`&&typeof n==`string`&&VC.test(n)&&r===null}function WC(e){let t;try{t=new URL(String(e).trim())}catch{return null}if(t.protocol!==`https:`&&t.protocol!==`http:`)return null;let n=t.hostname.toLowerCase().replace(/^(www\.|m\.)/,``),r=t.pathname.split(`/`).filter(Boolean),i=null;if(n===`youtu.be`)i={provider:`youtube`,id:r[0],hash:null};else if(n===`youtube.com`||n===`youtube-nocookie.com`)i={provider:`youtube`,id:r[0]===`watch`||r.length===0?t.searchParams.get(`v`):[`embed`,`shorts`,`live`,`v`].includes(r[0])?r[1]:null,hash:null};else if(n===`vimeo.com`||n===`player.vimeo.com`){let e=r[0]===`video`?r.slice(1):r;i={provider:`vimeo`,id:e[0],hash:e[1]??t.searchParams.get(`h`)??null}}else n===`streamable.com`&&(i={provider:`streamable`,id:[`e`,`o`,`s`].includes(r[0])?r[1]:r.length===1?r[0]:null,hash:null});return i&&UC(i)?i:null}var GC=W.create({name:`video`,group:`block`,atom:!0,selectable:!0,draggable:!1,addAttributes(){return{provider:{default:null},id:{default:null},hash:{default:null}}},parseHTML(){return[{tag:`figure.efe-video`,getAttrs:e=>{let t={provider:e.dataset.provider,id:e.dataset.id,hash:e.dataset.hash??null};return UC(t)?t:!1}}]},renderHTML({node:e}){if(!UC(e.attrs))return[`figure`,{class:`efe-video efe-video--invalid`},[`figcaption`,{},`Video nicht verfügbar`]];let{provider:t,id:n,hash:r}=e.attrs;return[`figure`,{class:`efe-video`,"data-provider":t,"data-id":n,...r?{"data-hash":r}:{}},[`span`,{class:`efe-video__play`,"aria-hidden":`true`}],[`figcaption`,{class:`efe-video__note`},`${HC[t]}-Video`]]},addCommands(){return{insertVideo:e=>({commands:t})=>UC({hash:null,...e})&&t.insertContent({type:this.name,attrs:{hash:null,...e}})}}}),KC=new WeakMap,qC=0;function JC(e){let t=KC.get(e);return t||(t=YC(e),KC.set(e,t)),t}function YC(e){let t=++qC,n=document.createElement(`div`);n.className=`efe-balloon`,n.setAttribute(`role`,`dialog`),n.setAttribute(`aria-label`,`Video einbetten`),n.dataset.state=`closed`;let r=document.createElement(`label`);r.className=`efe-balloon__label`,r.htmlFor=`efe-video-input-${t}`,r.textContent=`YouTube-, Vimeo- oder Streamable-Adresse`;let i=document.createElement(`input`);i.type=`text`,i.id=`efe-video-input-${t}`,i.className=`efe-balloon__input`,i.placeholder=`https://www.youtube.com/watch?v=…`,i.autocomplete=`off`,i.spellcheck=!1,i.setAttribute(`inputmode`,`url`);let a=document.createElement(`span`);a.id=`efe-video-error-${t}`,a.className=`efe-balloon__error`,a.textContent=`Keine YouTube-, Vimeo- oder Streamable-Adresse erkannt.`,a.hidden=!0,i.setAttribute(`aria-describedby`,a.id);let o=XC(`check`,`Einfügen`,`efe-btn efe-btn--primary`);o.dataset.efeCommand=`applyVideo`;let s=XC(`close`,`Abbrechen`),c=document.createElement(`div`);c.className=`efe-balloon__row`,c.append(i,o,s),n.append(r,c,a);let l=!1;function u(e){i.toggleAttribute(`aria-invalid`,e),a.hidden=!e}function d(){let{view:t,state:r}=e;dC({getBoundingClientRect:()=>cd(t,r.selection.from,r.selection.to),contextElement:t.dom},n,{placement:`bottom`,middleware:[rC(8),oC(),aC({padding:8})]}).then(({x:e,y:t})=>{n.style.left=`${e}px`,n.style.top=`${t}px`}).catch(()=>{})}function f(e){n.contains(e.target)||p(!1)}function p(t=!0){l&&(l=!1,xC(n,()=>n.remove()),document.removeEventListener(`mousedown`,f,!0),t&&!e.isDestroyed&&e.commands.focus())}function m(){e.isEditable&&e.schema.nodes.video&&(i.value=``,u(!1),l||(l=!0,SC(n),n.dataset.state=`open`,(e.view.dom.parentElement??document.body).appendChild(n),document.addEventListener(`mousedown`,f,!0)),d(),i.focus())}function h(){let t=WC(i.value);t?(e.chain().focus().insertVideo(t).run(),p(!1)):u(!0)}return o.addEventListener(`click`,h),s.addEventListener(`click`,()=>p()),i.addEventListener(`input`,()=>u(!1)),n.addEventListener(`keydown`,e=>{e.key===`Enter`&&e.target===i?(e.preventDefault(),h()):e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),p())}),e.on(`destroy`,()=>p(!1)),{open:m,close:p,isOpen:()=>l,element:n}}function XC(e,t,n=`efe-btn`){let r=document.createElement(`button`);return r.type=`button`,r.className=n,r.setAttribute(`aria-label`,t),ox(r,t),r.appendChild(ax(e)),r}var ZC=new WeakMap;function QC(e){let t=e.view.dom;return t.closest(`.efe-page`)??t}function $C(e){return ZC.has(e)}function ew(e,t){let n=t===void 0?!$C(e):!!t;if(n===$C(e))return n;if(n)ZC.set(e,e.isEditable),e.setEditable(!1);else{let t=ZC.get(e);ZC.delete(e),e.setEditable(t!==!1)}return QC(e).classList.toggle(`efe-page--preview`,n),e.view.dom.classList.toggle(`efe-preview`,n),e.emit(`efe-preview`,{editor:e,preview:n}),e.view.dispatch(e.state.tr.setMeta(`efePreview`,n)),n}var tw=[{level:0,label:`Absatz`},{level:1,label:`Überschrift 1`},{level:2,label:`Überschrift 2`},{level:3,label:`Überschrift 3`}],nw=[{value:`left`,label:`Linksbündig`,icon:`alignLeft`},{value:`center`,label:`Zentriert`,icon:`alignCenter`},{value:`right`,label:`Rechtsbündig`,icon:`alignRight`},{value:`justify`,label:`Blocksatz`,icon:`alignJustify`}],rw=[`undo`,`redo`,`formatSelect`,`fontFamily`,`bold`,`italic`,`underline`,`strike`,`link`,`bulletList`,`orderedList`,`blockquote`,`align`,`table`,`image`,`callout`,`video`,`horizontalRule`,`pageBreak`,`sectionTools`,`preview`],iw=[`formatSelect`,`bold`,`italic`,`strike`,`bulletList`,`orderedList`,`table`,`align`,`pageBreak`,`link`,`sectionTools`,`preview`],aw={undo:`history`,redo:`history`,formatSelect:`format`,fontFamily:`format`,bold:`marks`,italic:`marks`,underline:`marks`,strike:`marks`,link:`link`,bulletList:`blocks`,orderedList:`blocks`,blockquote:`blocks`,align:`align`,table:`insert`,image:`insert`,callout:`insert`,video:`insert`,horizontalRule:`insert`,pageBreak:`insert`,sectionTools:`sections`,instanceTools:`instances`,preview:`view`},ow={undo:(e,t)=>fw(e,t,{command:`undo`,icon:`undo`,label:`Rückgängig`,shortcut:`Strg+Z`}),redo:(e,t)=>fw(e,t,{command:`redo`,icon:`redo`,label:`Wiederholen`,shortcut:`Strg+Y`}),formatSelect:(e,t)=>e.schema.nodes.heading?hw(e,t):null,fontFamily:(e,t,{fonts:n=[]})=>e.schema.marks.textStyle&&n.length>0?gw(e,t,n):null,bold:(e,t)=>lw(e,t,`bold`,`Fett`,`Strg+B`),italic:(e,t)=>lw(e,t,`italic`,`Kursiv`,`Strg+I`),underline:(e,t)=>lw(e,t,`underline`,`Unterstrichen`,`Strg+U`),strike:(e,t)=>lw(e,t,`strike`,`Durchgestrichen`,`Strg+Umschalt+S`),link:(e,t)=>e.schema.marks.link?yw(e,t):null,bulletList:(e,t)=>uw(e,t,`bulletList`,`toggleBulletList`,`Aufzählungsliste`),orderedList:(e,t)=>uw(e,t,`orderedList`,`toggleOrderedList`,`Nummerierte Liste`),blockquote:(e,t)=>uw(e,t,`blockquote`,`toggleBlockquote`,`Zitat`),align:(e,t)=>cw(e,`textAlign`)?_w(e,t):null,table:(e,t)=>e.schema.nodes.table?vw(e,t):null,image:(e,t)=>bw(e,t),callout:(e,t)=>e.schema.nodes.callout?xw(e,t):null,video:(e,t)=>e.schema.nodes.video?Sw(e,t):null,horizontalRule:(e,t)=>e.schema.nodes.horizontalRule?fw(e,t,{command:`setHorizontalRule`,icon:`horizontalRule`,label:`Trennlinie einfügen`}):null,pageBreak:(e,t)=>e.schema.nodes.pageBreak?fw(e,t,{command:`insertPageBreak`,icon:`pageBreak`,label:`Seitenumbruch einfügen`}):null,sectionTools:(e,t)=>Cw(e)?Tw(e,t):null,instanceTools:(e,t)=>ww(e)?Ew(e,t):null,preview:(e,t)=>e.schema.nodes.docSection||e.schema.nodes.docInput?Dw(e,t):null};function sw(e,t,n={}){let{items:r=rw}=n,i=Array.from(t.children);t.replaceChildren(),t.classList.add(`efe-toolbar`),t.setAttribute(`role`,`toolbar`),t.setAttribute(`aria-label`,`Textformatierung`);let a=[],o=null,s=null;for(let i of r){let r=ow[i],c=r?r(e,a,n):null;if(!c)continue;let l=aw[i];o!==l&&(o!==null&&t.appendChild(kw()),s=null),!Array.isArray(c)&&c.classList.contains(`efe-toolbar__group`)?t.appendChild(c):(s||(s=document.createElement(`div`),s.className=`efe-toolbar__group`,s.setAttribute(`role`,`group`),t.appendChild(s)),s.append(...Array.isArray(c)?c:[c])),o=l}i.length>0&&(o!==null&&t.appendChild(kw()),t.append(...i));let c=()=>{for(let e of a)e();if(!e.isEditable)for(let e of t.querySelectorAll(`button:not([data-efe-always-enabled])`))e.disabled=!0};return c(),e.on(`transaction`,c),e.on(`destroy`,()=>e.off(`transaction`,c)),{destroy(){e.off(`transaction`,c)}}}function cw(e,t){return e.extensionManager.extensions.some(e=>e.name===t)}function lw(e,t,n,r,i){return e.schema.marks[n]?dw(e,t,{command:`toggle${n.charAt(0).toUpperCase()}${n.slice(1)}`,name:n,icon:n,label:r,shortcut:i}):null}function uw(e,t,n,r,i){return e.schema.nodes[n]?dw(e,t,{command:r,name:n,icon:n,label:i}):null}function dw(e,t,{command:n,name:r,icon:i,label:a,shortcut:o}){let s=sx({name:i,label:a,shortcut:o});return s.dataset.efeCommand=n,s.setAttribute(`aria-pressed`,`false`),s.addEventListener(`click`,()=>{e.chain().focus()[n]().run()}),t.push(()=>{let t=e.isActive(r);s.setAttribute(`aria-pressed`,String(t)),s.classList.toggle(`is-active`,t),s.disabled=!e.can()[n]()}),s}function fw(e,t,{command:n,icon:r,label:i,shortcut:a}){let o=sx({name:r,label:i,shortcut:a});return o.dataset.efeCommand=n,o.addEventListener(`click`,()=>{e.chain().focus()[n]().run()}),t.push(()=>{o.disabled=!e.can()[n]()}),o}function pw(e,t,n,r=``){let i=document.createElement(`div`);i.className=`efe-dropdown`,t.setAttribute(`aria-haspopup`,`true`),t.setAttribute(`aria-expanded`,`false`);let a=document.createElement(`div`);a.className=`efe-dropdown__menu ${r}`.trim(),a.setAttribute(`role`,`menu`),a.hidden=!0,a.dataset.state=`closed`;for(let{element:e,action:t}of n)e.addEventListener(`click`,()=>{l(!1),t()}),a.appendChild(e);i.append(t,a);let o=()=>Array.from(a.querySelectorAll(`button:not(:disabled)`)),s=()=>a.dataset.state===`open`;function c(){SC(a),a.hidden=!1,a.dataset.state=`open`,t.setAttribute(`aria-expanded`,`true`),document.addEventListener(`click`,u,!0),document.addEventListener(`keydown`,d,!0)}function l(e){s()&&xC(a,()=>{a.hidden=!0}),t.setAttribute(`aria-expanded`,`false`),document.removeEventListener(`click`,u,!0),document.removeEventListener(`keydown`,d,!0),e&&t.focus()}function u(e){i.contains(e.target)||l(!1)}function d(e){if(e.key===`Escape`){e.preventDefault(),l(!0);return}if(e.key!==`ArrowDown`&&e.key!==`ArrowUp`)return;let t=o();if(t.length===0)return;e.preventDefault();let n=t.indexOf(document.activeElement),r=e.key===`ArrowDown`?1:-1;t[n===-1?0:(n+r+t.length)%t.length].focus()}return t.addEventListener(`click`,()=>{s()?l(!1):(c(),(a.querySelector(`[aria-checked="true"]:not(:disabled)`)??o()[0])?.focus())}),e.on(`destroy`,()=>l(!1)),i}function mw(e,t=`menuitem`){let n=document.createElement(`button`);return n.type=`button`,n.className=`efe-dropdown__item`,n.setAttribute(`role`,t),n.textContent=e,n}function hw(e,t){let n=document.createElement(`button`);n.type=`button`,n.className=`efe-btn efe-btn--dropdown efe-btn--heading`,n.dataset.efeCommand=`heading`,n.setAttribute(`aria-label`,`Absatzformat`),ox(n,`Absatzformat`);let r=document.createElement(`span`);r.className=`efe-btn__text`,n.append(r,ax(`chevron`));let i=tw.map(({level:t,label:n})=>{let r=mw(n,`menuitemradio`);return r.classList.add(`efe-dropdown__item--h${t}`),r.dataset.efeHeading=String(t),{element:r,action:()=>t===0?e.chain().focus().setParagraph().run():e.chain().focus().setHeading({level:t}).run(),level:t}});return t.push(()=>{let t=tw.find(({level:t})=>t>0&&e.isActive(`heading`,{level:t}))??tw[0];r.textContent=t.label;for(let n of i){let r=n.level===t.level;n.element.setAttribute(`aria-checked`,String(r)),n.element.disabled=!r&&(n.level===0?!e.can().setParagraph():!e.can().setHeading({level:n.level}))}n.disabled=i.every(e=>e.element.disabled)}),pw(e,n,i,`efe-dropdown__menu--heading`)}function gw(e,t,n){let r=document.createElement(`button`);r.type=`button`,r.className=`efe-btn efe-btn--dropdown efe-btn--heading`,r.dataset.efeCommand=`fontFamily`,r.setAttribute(`aria-label`,`Schrift`),ox(r,`Schrift`);let i=document.createElement(`span`);i.className=`efe-btn__text`,r.append(i,ax(`chevron`));let a=[{name:null,label:`Standard`},...n.map(({name:e,label:t})=>({name:e,label:t??e}))].map(({name:t,label:n})=>{let r=mw(n,`menuitemradio`);return r.dataset.efeFont=t??``,t&&(r.style.fontFamily=t),{element:r,action:()=>t?e.chain().focus().setFontFamily(t).run():e.chain().focus().unsetFontFamily().run(),name:t,label:n}});return t.push(()=>{let t=e.getAttributes(`textStyle`).fontFamily??null,n=a.find(e=>e.name===t)??a[0];i.textContent=n.label;for(let t of a)t.element.setAttribute(`aria-checked`,String(t===n)),t.element.disabled=t!==n&&!(t.name?e.can().setFontFamily(t.name):e.can().unsetFontFamily());r.disabled=a.every(e=>e.element.disabled)}),pw(e,r,a)}function _w(e,t){let n=document.createElement(`button`);n.type=`button`,n.className=`efe-btn efe-btn--dropdown`,n.dataset.efeCommand=`textAlign`,n.setAttribute(`aria-label`,`Ausrichtung`),ox(n,`Ausrichtung`);let r=ax(`alignLeft`);n.append(r,ax(`chevron`));let i=nw.map(({value:t,label:n,icon:r})=>{let i=mw(``,`menuitemradio`);return i.classList.add(`efe-dropdown__item--icon`),i.dataset.efeAlign=t,i.append(ax(r),document.createTextNode(n)),{element:i,value:t,iconName:r,action:()=>e.chain().focus().setTextAlign(t).run()}});return t.push(()=>{let t=i.find(t=>e.isActive({textAlign:t.value}))??i[0];for(let n of i)n.element.setAttribute(`aria-checked`,String(n===t)),n.element.disabled=!e.can().setTextAlign(n.value);let a=ax(t.iconName);r.replaceWith(a),r=a,n.disabled=i.every(e=>e.element.disabled)}),pw(e,n,i)}function vw(e,t){let n=document.createElement(`button`);n.type=`button`,n.className=`efe-btn efe-btn--dropdown`,n.dataset.efeCommand=`insertTable`,n.setAttribute(`aria-label`,`Tabelle`),ox(n,`Tabelle`),n.append(ax(`table`),ax(`chevron`));let r=()=>e.chain().focus(),i=[{label:`Tabelle einfügen (3×3)`,action:()=>r().insertTable({rows:3,cols:3,withHeaderRow:!0}).run(),can:()=>e.can().insertTable()},{label:`Zeile davor einfügen`,action:()=>r().addRowBefore().run(),can:()=>e.can().addRowBefore()},{label:`Zeile danach einfügen`,action:()=>r().addRowAfter().run(),can:()=>e.can().addRowAfter()},{label:`Spalte davor einfügen`,action:()=>r().addColumnBefore().run(),can:()=>e.can().addColumnBefore()},{label:`Spalte danach einfügen`,action:()=>r().addColumnAfter().run(),can:()=>e.can().addColumnAfter()},{label:`Zeile löschen`,action:()=>r().deleteRow().run(),can:()=>e.can().deleteRow()},{label:`Spalte löschen`,action:()=>r().deleteColumn().run(),can:()=>e.can().deleteColumn()},{label:`Tabelle löschen`,action:()=>r().deleteTable().run(),can:()=>e.can().deleteTable()}].map(e=>({...e,element:mw(e.label)}));return t.push(()=>{for(let e of i)e.element.disabled=!e.can();n.classList.toggle(`is-active`,e.isActive(`table`))}),pw(e,n,i)}function yw(e,t){let n=sx({name:`link`,label:`Link`,shortcut:`Strg+K`});return n.dataset.efeCommand=`toggleLink`,n.setAttribute(`aria-haspopup`,`dialog`),n.setAttribute(`aria-pressed`,`false`),n.addEventListener(`mousedown`,e=>e.preventDefault()),n.addEventListener(`click`,()=>{let t=TC(e);t.isOpen()?t.close():t.open()}),t.push(()=>{let t=e.isActive(`link`);n.setAttribute(`aria-pressed`,String(t)),n.classList.toggle(`is-active`,t)}),n}function bw(e,t){let n=e.extensionManager.extensions.find(e=>e.name===`imageBlock`)?.options.upload;if(typeof n!=`function`)return null;let r=sx({name:`image`,label:`Bild einfügen`});r.dataset.efeCommand=`insertImage`;let i=document.createElement(`input`);i.type=`file`,i.accept=`image/*`,i.hidden=!0,i.tabIndex=-1;let a=!1,o=t=>{a=t,r.toggleAttribute(`aria-busy`,t),r.disabled=t||!e.isEditable};return r.addEventListener(`click`,()=>i.click()),i.addEventListener(`change`,async()=>{let t=i.files?.[0];if(i.value=``,t){o(!0);try{let r=await n(t);r&&jC(r.src)?e.chain().focus().insertImageBlock({src:r.src,alt:r.alt??``}).run():console.error(`[editor] uploadImage lieferte keine erlaubte Bildquelle.`,r?.src)}catch(e){console.error(`[editor] Bild-Upload fehlgeschlagen.`,e)}finally{o(!1)}}}),t.push(()=>{r.disabled=a||!e.can().insertImageBlock({src:`/x.png`})}),[r,i]}function xw(e,t){let n=document.createElement(`button`);n.type=`button`,n.className=`efe-btn efe-btn--dropdown`,n.dataset.efeCommand=`setCallout`,n.setAttribute(`aria-label`,`Hinweisbox`),ox(n,`Hinweisbox`),n.append(ax(`callout`),ax(`chevron`));let r=PC.map(({value:t,label:n})=>{let r=mw(n,`menuitemradio`);return r.dataset.efeCallout=t,{element:r,value:t,action:()=>e.chain().focus().setCallout(t).run()}}),i={element:mw(`Hinweisbox entfernen`),value:null,action:()=>e.chain().focus().unsetCallout().run()};return i.element.dataset.efeCallout=`remove`,t.push(()=>{let t=e.isActive(`callout`);for(let n of r){let r=t&&e.isActive(`callout`,{variant:n.value});n.element.setAttribute(`aria-checked`,String(r)),n.element.disabled=!r&&!e.can().setCallout(n.value)}i.element.hidden=!t,n.classList.toggle(`is-active`,t),n.disabled=r.every(e=>e.element.disabled)}),pw(e,n,[...r,i])}function Sw(e,t){let n=sx({name:`video`,label:`Video einbetten`});return n.dataset.efeCommand=`insertVideo`,n.setAttribute(`aria-haspopup`,`dialog`),n.addEventListener(`mousedown`,e=>e.preventDefault()),n.addEventListener(`click`,()=>{let t=JC(e);t.isOpen()?t.close():t.open()}),t.push(()=>{n.disabled=!e.can().insertVideo({provider:`youtube`,id:`aaaaaaaaaaa`})}),n}function Cw(e){return!!e.extensionManager.extensions.find(e=>e.name===`sectionLockGuard`)?.options?.templateMode}function ww(e){return!!e.schema.nodes.docSection&&!Cw(e)}function Tw(e,t){let n=document.createElement(`div`);return n.className=`efe-toolbar__group`,n.setAttribute(`role`,`group`),n.setAttribute(`aria-label`,`Abschnitte`),n.append(Ow(e,t,{command:`insertSectionFree`,label:`Abschnitt einfügen (frei)`,text:`+ Frei`,action:()=>e.chain().focus().insertSection(`free`).run(),can:()=>e.can().insertSection(`free`)}),Ow(e,t,{command:`insertSectionLocked`,label:`Abschnitt einfügen (gesperrt)`,text:`+ Gesperrt`,action:()=>e.chain().focus().insertSection(`locked`).run(),can:()=>e.can().insertSection(`locked`)}),Ow(e,t,{command:`toggleSectionMode`,label:`Modus umschalten`,text:`Modus`,action:()=>e.chain().focus().toggleSectionMode().run(),can:()=>e.can().toggleSectionMode()})),n}function Ew(e,t){let n=document.createElement(`div`);return n.className=`efe-toolbar__group`,n.setAttribute(`role`,`group`),n.setAttribute(`aria-label`,`Wiederholbare Abschnitte`),n.append(Ow(e,t,{command:`addSectionInstance`,label:`Abschnitt wiederholen`,text:`+`,action:()=>e.chain().focus().addSectionInstance().run(),can:()=>e.can().addSectionInstance()}),Ow(e,t,{command:`removeSectionInstance`,label:`Abschnitt entfernen`,text:`−`,action:()=>e.chain().focus().removeSectionInstance().run(),can:()=>e.can().removeSectionInstance()})),n}function Dw(e,t){let n=sx({name:`eye`,label:`Vorschau: so sieht das Dokument gedruckt aus`});n.classList.add(`efe-btn--labelled`,`efe-btn--preview`),n.dataset.efeCommand=`preview`,n.dataset.efeAlwaysEnabled=`true`,n.setAttribute(`aria-pressed`,`false`),n.append(document.createTextNode(`Vorschau`));let r=()=>{let t=$C(e);n.setAttribute(`aria-pressed`,t?`true`:`false`),n.classList.toggle(`is-active`,t),n.disabled=!1};return n.addEventListener(`click`,()=>ew(e)),e.on(`efe-preview`,r),t.push(r),r(),n}function Ow(e,t,{command:n,label:r,text:i,action:a,can:o}){let s=document.createElement(`button`);return s.type=`button`,s.className=`efe-btn efe-btn--labelled`,s.dataset.efeCommand=n,s.setAttribute(`aria-label`,r),ox(s,r),s.textContent=i,s.addEventListener(`click`,a),t.push(()=>{s.disabled=!o()}),s}function kw(){let e=document.createElement(`span`);return e.className=`efe-toolbar__divider`,e.setAttribute(`role`,`separator`),e.setAttribute(`aria-orientation`,`vertical`),e}function Aw(e,t){let n=Math.min(e.top,t.top),r=Math.max(e.bottom,t.bottom),i=Math.min(e.left,t.left),a=Math.max(e.right,t.right)-i,o=r-n;return new DOMRect(i,n,a,o)}var jw=class{get middlewares(){let e=[];return this.floatingUIOptions.flip&&e.push(oC(typeof this.floatingUIOptions.flip==`boolean`?void 0:this.floatingUIOptions.flip)),this.floatingUIOptions.shift&&e.push(aC(typeof this.floatingUIOptions.shift==`boolean`?void 0:this.floatingUIOptions.shift)),this.floatingUIOptions.offset&&e.push(rC(typeof this.floatingUIOptions.offset==`boolean`?void 0:this.floatingUIOptions.offset)),this.floatingUIOptions.arrow&&e.push(lC(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&e.push(sC(typeof this.floatingUIOptions.size==`boolean`?void 0:this.floatingUIOptions.size)),this.floatingUIOptions.autoPlacement&&e.push(iC(typeof this.floatingUIOptions.autoPlacement==`boolean`?void 0:this.floatingUIOptions.autoPlacement)),this.floatingUIOptions.hide&&e.push(cC(typeof this.floatingUIOptions.hide==`boolean`?void 0:this.floatingUIOptions.hide)),this.floatingUIOptions.inline&&e.push(uC(typeof this.floatingUIOptions.inline==`boolean`?void 0:this.floatingUIOptions.inline)),e}get virtualElement(){var e;let{selection:t}=this.editor.state,n=this.getReferencedVirtualElement?.call(this);if(n)return n;if(!((e=this.view)!=null&&(e=e.dom)!=null&&e.parentNode))return;let r=cd(this.view,t.from,t.to),i={getBoundingClientRect:()=>r,getClientRects:()=>[r]};if(t instanceof j){let e=this.view.nodeDOM(t.from),n=e.dataset.nodeViewWrapper?e:e.querySelector(`[data-node-view-wrapper]`);n&&(e=n),e&&(i={getBoundingClientRect:()=>e.getBoundingClientRect(),getClientRects:()=>[e.getBoundingClientRect()]})}if(t instanceof X){let{$anchorCell:e,$headCell:n}=t,r=e?e.pos:n.pos,a=n?n.pos:e.pos,o=this.view.nodeDOM(r),s=this.view.nodeDOM(a);if(!o||!s)return;let c=o===s?o.getBoundingClientRect():Aw(o.getBoundingClientRect(),s.getBoundingClientRect());i={getBoundingClientRect:()=>c,getClientRects:()=>[c]}}return i}constructor({editor:e,element:t,view:n,pluginKey:r=`bubbleMenu`,updateDelay:i=250,resizeDelay:a=60,shouldShow:o,appendTo:s,getReferencedVirtualElement:c,options:l}){this.preventHide=!1,this.isVisible=!1,this.scrollTarget=window,this.floatingUIOptions={strategy:`absolute`,placement:`top`,offset:8,flip:{},shift:{},arrow:!1,size:!1,autoPlacement:!1,hide:!1,inline:!1,onShow:void 0,onHide:void 0,onUpdate:void 0,onDestroy:void 0},this.shouldShow=({view:e,state:t,from:n,to:r})=>{let{doc:i,selection:a}=t,{empty:o}=a,s=!i.textBetween(n,r).length&&dl(t.selection),c=this.element.contains(document.activeElement);return!(!(e.hasFocus()||c)||o||s||!this.editor.isEditable)},this.mousedownHandler=()=>{this.preventHide=!0},this.dragstartHandler=()=>{this.hide()},this.compositionEndHandler=()=>{clearTimeout(this.compositionEndTimer),this.compositionEndTimer=window.setTimeout(()=>{this.editor.isDestroyed||this.update(this.view)})},this.resizeHandler=()=>{this.resizeDebounceTimer&&clearTimeout(this.resizeDebounceTimer),this.resizeDebounceTimer=window.setTimeout(()=>{this.updatePosition()},this.resizeDelay)},this.focusHandler=()=>{setTimeout(()=>this.update(this.editor.view))},this.blurHandler=({event:e})=>{this.editor.isDestroyed?this.destroy():this.preventHide?this.preventHide=!1:e?.relatedTarget&&this.element.parentNode?.contains(e.relatedTarget)||e?.relatedTarget!==this.editor.view.dom&&this.hide()},this.handleDebouncedUpdate=(e,t)=>{let n=!t?.selection.eq(e.state.selection),r=!t?.doc.eq(e.state.doc);(n||r)&&(this.updateDebounceTimer&&clearTimeout(this.updateDebounceTimer),this.updateDebounceTimer=window.setTimeout(()=>{this.updateHandler(e,n,r,t)},this.updateDelay))},this.updateHandler=(e,t,n,r)=>{let{composing:i}=e;i||!t&&!n||(this.getShouldShow(r)?(this.show(),this.updatePosition()):this.hide())},this.transactionHandler=({transaction:e})=>{let t=e.getMeta(this.pluginKey);t===`updatePosition`?this.updatePosition():t&&typeof t==`object`&&t.type===`updateOptions`?this.updateOptions(t.options):t===`hide`?this.hide():t===`show`&&(this.updatePosition(),this.show())},this.editor=e,this.element=t,this.view=n,this.pluginKey=r,this.updateDelay=i,this.resizeDelay=a,this.appendTo=s,this.scrollTarget=l?.scrollTarget??window,this.getReferencedVirtualElement=c,this.floatingUIOptions={...this.floatingUIOptions,...l},this.element.tabIndex=0,o&&(this.shouldShow=o),this.element.addEventListener(`mousedown`,this.mousedownHandler,{capture:!0}),this.view.dom.addEventListener(`dragstart`,this.dragstartHandler),this.editor.on(`focus`,this.focusHandler),this.editor.on(`blur`,this.blurHandler),this.editor.on(`transaction`,this.transactionHandler),window.addEventListener(`resize`,this.resizeHandler),this.scrollTarget.addEventListener(`scroll`,this.resizeHandler),this.view.dom.addEventListener(`compositionend`,this.compositionEndHandler),this.update(n,n.state),this.getShouldShow()&&(this.show(),this.updatePosition())}updatePosition(){if(!this.isVisible)return;let e=this.virtualElement;e&&dC(e,this.element,{placement:this.floatingUIOptions.placement,strategy:this.floatingUIOptions.strategy,middleware:this.middlewares}).then(({x:e,y:t,strategy:n,middlewareData:r})=>{this.isVisible&&!this.editor.isDestroyed&&this.element.isConnected&&(r.hide?.referenceHidden||r.hide?.escaped?this.element.style.visibility=`hidden`:(this.element.style.visibility=`visible`,this.element.style.width=`max-content`,this.element.style.position=n,this.element.style.left=`${e}px`,this.element.style.top=`${t}px`,this.isVisible&&this.floatingUIOptions.onUpdate&&this.floatingUIOptions.onUpdate()))})}update(e,t){let{state:n}=e,r=n.selection.from!==n.selection.to;if(this.updateDelay>0&&r){this.handleDebouncedUpdate(e,t);return}let i=!t?.selection.eq(e.state.selection),a=!t?.doc.eq(e.state.doc);this.updateHandler(e,i,a,t)}getShouldShow(e){let{state:t}=this.view,{selection:n}=t,{ranges:r}=n,i=Math.min(...r.map(e=>e.$from.pos)),a=Math.max(...r.map(e=>e.$to.pos));return this.shouldShow?.call(this,{editor:this.editor,element:this.element,view:this.view,state:t,oldState:e,from:i,to:a})||!1}show(){var e;this.isVisible||=(this.element.style.visibility=`visible`,this.element.style.opacity=`1`,(e=(typeof this.appendTo==`function`?this.appendTo():this.appendTo)??this.view.dom.parentElement)==null||e.appendChild(this.element),this.floatingUIOptions.onShow&&this.floatingUIOptions.onShow(),!0)}hide(){this.isVisible&&=(this.element.style.visibility=`hidden`,this.element.style.opacity=`0`,this.element.remove(),this.floatingUIOptions.onHide&&this.floatingUIOptions.onHide(),!1)}updateOptions(e){if(e.updateDelay!==void 0&&(this.updateDelay=e.updateDelay),e.resizeDelay!==void 0&&(this.resizeDelay=e.resizeDelay),e.appendTo!==void 0&&(this.appendTo=e.appendTo),e.getReferencedVirtualElement!==void 0&&(this.getReferencedVirtualElement=e.getReferencedVirtualElement),e.shouldShow!==void 0&&e.shouldShow&&(this.shouldShow=e.shouldShow),e.options!==void 0){let t=e.options.scrollTarget??window;t!==this.scrollTarget&&(this.scrollTarget.removeEventListener(`scroll`,this.resizeHandler),this.scrollTarget=t,this.scrollTarget.addEventListener(`scroll`,this.resizeHandler)),this.floatingUIOptions={...this.floatingUIOptions,...e.options}}}destroy(){this.hide(),this.element.removeEventListener(`mousedown`,this.mousedownHandler,{capture:!0}),this.view.dom.removeEventListener(`dragstart`,this.dragstartHandler),window.removeEventListener(`resize`,this.resizeHandler),this.scrollTarget.removeEventListener(`scroll`,this.resizeHandler),this.editor.off(`focus`,this.focusHandler),this.editor.off(`blur`,this.blurHandler),this.editor.off(`transaction`,this.transactionHandler),this.view.dom.removeEventListener(`compositionend`,this.compositionEndHandler),clearTimeout(this.compositionEndTimer),clearTimeout(this.updateDebounceTimer),this.floatingUIOptions.onDestroy&&this.floatingUIOptions.onDestroy()}},Mw=e=>new M({key:typeof e.pluginKey==`string`?new N(e.pluginKey):e.pluginKey,view:t=>new jw({view:t,...e})}),Nw=U.create({name:`bubbleMenu`,addOptions(){return{element:null,pluginKey:`bubbleMenu`,updateDelay:void 0,appendTo:void 0,shouldShow:null}},addProseMirrorPlugins(){return this.options.element?[Mw({pluginKey:this.options.pluginKey,editor:this.editor,element:this.options.element,updateDelay:this.options.updateDelay,options:this.options.options,appendTo:this.options.appendTo,getReferencedVirtualElement:this.options.getReferencedVirtualElement,shouldShow:this.options.shouldShow})]:[]}}),Pw=`efeBubble`,Fw=[{mark:`bold`,icon:`bold`,label:`Fett`,shortcut:`Strg+B`},{mark:`italic`,icon:`italic`,label:`Kursiv`,shortcut:`Strg+I`},{mark:`underline`,icon:`underline`,label:`Unterstrichen`,shortcut:`Strg+U`},{mark:`strike`,icon:`strike`,label:`Durchgestrichen`,shortcut:`Strg+Umschalt+S`}];function Iw(){let e=document.createElement(`div`);e.className=`efe-bubble`,e.setAttribute(`role`,`toolbar`),e.setAttribute(`aria-label`,`Schnellleiste`),e.dataset.state=`closed`;let t=null,n=()=>e.dataset.state===`open`,r=null,i=e=>e.view.dispatch(e.state.tr.setMeta(Pw,`hide`)),a=Nw.configure({pluginKey:Pw,element:e,updateDelay:100,shouldShow:({editor:t,view:n,state:i,from:a,to:o})=>{let{selection:s}=i;return t.isDestroyed||!t.schema||!e.firstChild||!t.isEditable||!(s instanceof A)||s.empty||i.doc.textBetween(a,o).length===0||r&&r.eq(s)||t.schema.marks.link&&TC(t).isOpen()?!1:n.hasFocus()||e.contains(document.activeElement)},options:{placement:`top`,offset:8,flip:{padding:8},shift:{padding:8},onShow:()=>{SC(e),t=e.parentNode,e.dataset.state=`open`},onHide:()=>{e.style.visibility=`visible`,e.style.opacity=``,t?.appendChild(e),xC(e,()=>e.remove())}}}),o=U.create({name:`efeBubbleKeys`,addKeyboardShortcuts(){return{Escape:({editor:e})=>n()?(r=e.state.selection,i(e),!0):!1,"Alt-F10":()=>{let t=e.querySelector(`button:not(:disabled)`);return!n()||!t?!1:(t.focus(),!0)}}}});function s(t){let{marks:n}=t.schema,a=[],o=(t,n,r)=>{t.addEventListener(`mousedown`,e=>e.preventDefault()),t.addEventListener(`click`,n),e.appendChild(t),a.push(()=>{let e=r();t.classList.toggle(`is-active`,e),t.setAttribute(`aria-pressed`,String(e))})},s=Fw.filter(e=>n[e.mark]);for(let e of s){let n=sx({name:e.icon,label:e.label,shortcut:e.shortcut,className:`efe-btn`});n.dataset.efeCommand=`toggle${e.mark.charAt(0).toUpperCase()}${e.mark.slice(1)}`,o(n,()=>t.chain().focus().toggleMark(e.mark).run(),()=>t.isActive(e.mark))}if(n.link){let e=sx({name:`link`,label:`Link`,shortcut:`Strg+K`,className:`efe-btn`});e.dataset.efeCommand=`toggleLink`,o(e,()=>{i(t),TC(t).open()},()=>t.isActive(`link`))}if(s.length>0){let e=sx({name:`removeFormat`,label:`Formatierung entfernen`,className:`efe-btn`});e.dataset.efeCommand=`removeFormat`,o(e,()=>{let e=t.chain().focus();for(let t of s)e=e.unsetMark(t.mark);e.run()},()=>!1)}e.tabIndex=-1,e.addEventListener(`keydown`,n=>{let a=Array.from(e.querySelectorAll(`button`)),o=a.indexOf(document.activeElement);n.key===`ArrowRight`||n.key===`ArrowLeft`?(n.preventDefault(),a[(o+(n.key===`ArrowRight`?1:-1)+a.length)%a.length]?.focus()):n.key===`Escape`&&(n.preventDefault(),r=t.state.selection,t.commands.focus(),i(t))}),e.addEventListener(`focusout`,n=>{let r=n.relatedTarget;r&&(e.contains(r)||t.view.dom.contains(r))||i(t)});let c=()=>a.forEach(e=>e());t.on(`selectionUpdate`,()=>{r=null}),t.on(`transaction`,c),c()}return{element:e,extensions:[a,o],attach:s}}var Lw=[`headings`,`bold`,`italic`,`underline`,`strike`,`fontFamily`,`bulletList`,`orderedList`,`blockquote`,`link`,`table`,`textAlign`,`horizontalRule`,`image`,`callout`,`video`,`pageBreak`,`variables`,`fields`,`sections`,`inputs`],Rw=[`bold`,`italic`,`underline`,`strike`],zw=Object.freeze({mail:Object.freeze([...Rw,`bulletList`,`orderedList`,`blockquote`,`link`]),signature:Object.freeze([...Rw,`link`,`bulletList`,`orderedList`,`variables`]),document:Object.freeze([`headings`,...Rw,`fontFamily`,`bulletList`,`orderedList`,`blockquote`,`table`,`textAlign`,`horizontalRule`,`pageBreak`,`variables`,`fields`,`inputs`,`image`]),article:Object.freeze([`headings`,...Rw,`bulletList`,`orderedList`,`blockquote`,`link`,`table`,`horizontalRule`,`image`,`callout`,`video`])});function Bw(e){let{features:t,pages:n=!0,links:r=!1,sections:i=!1,variables:a}=e;if(t===void 0){let e=[`headings`,`bold`,`italic`,`strike`,`bulletList`,`orderedList`,`blockquote`,`horizontalRule`,`table`,`textAlign`,`variables`,`fields`];return n&&e.push(`pageBreak`),r&&e.push(`link`),i&&e.push(`sections`),new Set(e)}let o=typeof t==`string`?zw[t]:t;if(!Array.isArray(o))throw Error(`Unbekanntes Editor-Preset: ${String(t)}`);let s=new Set(o.filter(e=>Lw.includes(e)));return s.has(`inputs`)&&s.delete(`sections`),a||s.delete(`variables`),s}function Vw(e,t){return!e||typeof e!=`object`?e:Hw(e,t)[0]??{type:`doc`,content:[]}}function Hw(e,t){if(!e||typeof e!=`object`)return[];let n=Array.isArray(e.content)?e.content.flatMap(e=>Hw(e,t)):void 0;if(t.nodes[e.type]){let r={...e};return n&&(r.content=n),Array.isArray(e.marks)&&(r.marks=e.marks.filter(e=>t.marks[e?.type])),[r]}return!n||n.length===0?[]:n.every(e=>t.nodes[e.type]?.isInline)?[{type:`paragraph`,content:n}]:n}function Uw(e){return e instanceof Map?Array.from(e.entries()):Object.entries(e??{})}function Ww(e,t){if(e)return e instanceof Map?e.get(t):e[t]}function Gw(e,t){let n=Uw(e),r=(t??``).trim().toLowerCase();return n.filter(([e,t])=>{if(!r)return!0;let n=(t?.label??``).toLowerCase();return e.toLowerCase().includes(r)||n.includes(r)}).map(([e,t])=>({name:e,label:t?.label??e}))}function Kw(e,t,n){let r=Xw(e,t),i=r?.label?String(r.label):String(t??``),a=r?.value,o=a==null?``:String(a);return r===void 0?{state:`unknown`,label:i,value:null}:n===`labels`?{state:`placeholder`,label:i,value:null}:o.trim()===``?{state:`missing`,label:i,value:null}:{state:`filled`,label:i,value:o}}function qw(e){return e?(e instanceof Map?[...e.values()]:Object.values(e)).some(e=>e&&e.value!==void 0&&e.value!==null):!1}var Jw={filled:e=>`Automatisch ausgefüllt: ${e}`,missing:e=>`Für „${e}“ liegt kein Wert vor.`,placeholder:(e,t)=>`Platzhalter {{${t}}}: wird beim Ausfüllen durch ${e} ersetzt`,unknown:(e,t)=>`Unbekannter Platzhalter {{${t}}}`};function Yw(e){return({node:t,getPos:n,editor:r})=>{let i=document.createElement(`span`);i.setAttribute(`contenteditable`,`false`);let a=t=>{let n=t.attrs.name,{state:r,label:a,value:o}=Kw(e.variables,n,e.display??`values`);i.className=`efe-variable efe-variable--${r}`,i.dataset.efeVariable=n??``,i.dataset.efeVariableState=r,r===`filled`?i.textContent=o:r===`unknown`?i.textContent=`{{${n}}}`:i.textContent=a;let s=Jw[r](a,n);ox(i,s),i.setAttribute(`aria-label`,r===`filled`?`${o} (${s})`:s)};return a(t),i.addEventListener(`click`,()=>{if(!r.isEditable)return;let e=n();typeof e==`number`&&r.commands.setNodeSelection(e)}),{dom:i,update:e=>e.type===t.type&&(a(e),!0),selectNode:()=>{i.classList.add(`is-selected`)},deselectNode:()=>{i.classList.remove(`is-selected`)}}}}function Xw(e,t){return Ww(e,t)}var Zw=W.create({name:`docVariable`,group:`inline`,inline:!0,atom:!0,selectable:!0,addOptions(){return{variables:{},display:`values`}},addAttributes(){return{name:{default:null,parseHTML:e=>e.getAttribute(`data-efe-variable`),renderHTML:e=>({"data-efe-variable":e.name})}}},parseHTML(){return[{tag:`span[data-efe-variable]`}]},renderHTML({HTMLAttributes:e}){return[`span`,H({class:`efe-variable`},e)]},addCommands(){return{insertVariable:e=>({commands:t})=>t.insertContent({type:this.name,attrs:{name:e}})}},addNodeView(){return Yw(this.options)}}),Qw=e=>oT(e.attrs.options).length>0,$w=e=>e.attrs.kind===`date`;function eT(e,t,n){if(!e.isEditable)return!1;let r=n.attrs.who;return!r||typeof t.can!=`function`||!!t.can(r)}function tT({node:e,getPos:t,editor:n},r){let i=document.createElement(`span`);i.className=`efe-field efe-field--date`,i.setAttribute(`contenteditable`,`false`);let a=document.createElement(`input`);a.type=`date`,a.className=`efe-field__input`,i.appendChild(a);let o=e=>{let{fieldId:t,label:o,required:s,value:c,who:l}=e.attrs;i.dataset.efeField=t??``,i.classList.toggle(`efe-field--required`,!!s),i.classList.toggle(`efe-field--empty`,!c),i.classList.toggle(`efe-field--locked`,!!l&&!eT(n,r,e)),a.disabled=!eT(n,r,e),a.setAttribute(`aria-label`,o??``),a.setAttribute(`aria-required`,s?`true`:`false`),a.value!==(c??``)&&(a.value=c??``)};return a.addEventListener(`change`,()=>{let e=t(),i=typeof e==`number`?n.state.doc.nodeAt(e):null;!i||!eT(n,r,i)?a.value=i?.attrs.value??``:a.value!==(i.attrs.value??``)&&n.view.dispatch(n.state.tr.setNodeAttribute(e,`value`,a.value))}),a.addEventListener(`keydown`,e=>nT(e,n,a)),o(e),{dom:i,stopEvent:()=>!0,ignoreMutation:()=>!0,update:t=>t.type!==e.type||!$w(t)?!1:(o(t),!0)}}function nT(e,t,n){let r=e.key.toLowerCase();if((e.ctrlKey||e.metaKey)&&(r===`z`||r===`y`))return e.preventDefault(),r===`y`||e.shiftKey?t.commands.redo():t.commands.undo(),!0;if(e.key===`Tab`){e.preventDefault();let r=Array.from(t.view.dom.querySelectorAll(`.efe-field__input`)),i=r.indexOf(n);return i!==-1&&r[(i+(e.shiftKey?-1:1)+r.length)%r.length].focus(),!0}return!1}function rT({node:e,getPos:t,editor:n},r,i={}){let a=document.createElement(`span`);a.className=`efe-field efe-field--select`,a.setAttribute(`contenteditable`,`false`);let o=document.createElement(`select`);o.className=`efe-field__input`,a.appendChild(o);let s=null,c=e=>{let{fieldId:t,label:i,required:c,value:l,options:u}=e.attrs;a.dataset.efeField=t??``,a.classList.toggle(`efe-field--required`,!!c),a.classList.toggle(`efe-field--empty`,!l),o.disabled=!eT(n,u,e),a.classList.toggle(`efe-field--locked`,!!e.attrs.who&&o.disabled&&n.isEditable),o.setAttribute(`aria-label`,i??``),o.setAttribute(`aria-required`,c?`true`:`false`);let d=oT(u).map(e=>sT(e,r));l&&!d.includes(l)&&d.unshift(l);let f=(i??``)+(c?` *`:``),p=JSON.stringify([f,d]);p!==s&&(o.replaceChildren(new Option(f,``),...d.map(e=>new Option(e,e))),s=p),o.value=l??``};return o.addEventListener(`change`,()=>{let e=t(),r=typeof e==`number`?n.state.doc.nodeAt(e)?.attrs.value??``:null,a=typeof e==`number`?n.state.doc.nodeAt(e):null;!a||!eT(n,i,a)?o.value=r??``:r!==null&&o.value!==r&&n.view.dispatch(n.state.tr.setNodeAttribute(e,`value`,o.value))}),o.addEventListener(`keydown`,e=>nT(e,n,o)),c(e),{dom:a,stopEvent:()=>!0,ignoreMutation:()=>!0,update:t=>t.type!==e.type||!Qw(t)?!1:(c(t),!0)}}function iT(e){return({node:t,getPos:n,editor:r})=>{if($w(t))return tT({node:t,getPos:n,editor:r},e);if(Qw(t))return rT({node:t,getPos:n,editor:r},e.gender??null,e);let i=document.createElement(`span`);i.className=`efe-field`,i.setAttribute(`contenteditable`,`false`);let a=document.createElement(`span`);a.className=`efe-field__input`,a.setAttribute(`role`,`textbox`),i.appendChild(a);let o=!1,s=``,c=e=>{if(a.textContent=e,document.activeElement===a){let e=document.createRange();e.selectNodeContents(a),e.collapse(!1);let t=window.getSelection();t?.removeAllRanges(),t?.addRange(e)}},l=t=>{let{fieldId:n,label:o,required:l,value:u}=t.attrs;i.dataset.efeField=n??``,i.classList.toggle(`efe-field--required`,!!l),i.classList.toggle(`efe-field--empty`,!u);let d=eT(r,e,t);a.setAttribute(`contenteditable`,d?`true`:`false`),i.classList.toggle(`efe-field--locked`,!!t.attrs.who&&!d&&r.isEditable),a.dataset.efePlaceholder=o??``,a.setAttribute(`aria-label`,o??``),a.setAttribute(`aria-required`,l?`true`:`false`);let f=u??``;f!==s&&a.textContent!==f&&c(f),s=f},u=()=>{let i=n();if(typeof i!=`number`||!eT(r,e,r.state.doc.nodeAt(i)??t))return;let o=aT(r.state.doc.nodeAt(i)?.attrs??t.attrs),l=Array.from(a.textContent??``).slice(0,o).join(``);l!==a.textContent&&c(l),l!==r.state.doc.nodeAt(i)?.attrs.value&&(s=l,r.view.dispatch(r.state.tr.setNodeAttribute(i,`value`,l)))};return a.addEventListener(`compositionstart`,()=>{o=!0}),a.addEventListener(`compositionend`,()=>{o=!1,u()}),a.addEventListener(`input`,()=>{o||u()}),a.addEventListener(`keydown`,e=>{if(!nT(e,r,a)){if(e.key===`Enter`)e.preventDefault();else if(e.key===`a`&&(e.ctrlKey||e.metaKey)){e.preventDefault();let t=document.createRange();t.selectNodeContents(a);let n=window.getSelection();n?.removeAllRanges(),n?.addRange(t)}}}),a.addEventListener(`paste`,e=>{e.preventDefault();let t=e.clipboardData?.getData(`text/plain`)??``;document.execCommand(`insertText`,!1,t.replace(/\s+/g,` `))}),l(t),{dom:i,stopEvent:()=>!0,ignoreMutation:()=>!0,update:e=>e.type!==t.type||Qw(e)||$w(e)?!1:(l(e),!0)}}}function aT(e){let t=e?.maxLength;return typeof t==`number`&&t>0?t:500}function oT(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){let e=typeof n?.label==`string`?n.label.trim():``;if(!e)continue;let r={label:e};for(let e of[`male`,`female`]){let t=typeof n[e]==`string`?n[e].trim():``;t&&(r[e]=t)}t.push(r)}return t}function sT(e,t){return t&&e[t]||e.label}var cT=W.create({name:`docField`,group:`inline`,inline:!0,atom:!0,selectable:!0,addOptions(){return{gender:null,can:null}},addAttributes(){return{fieldId:{default:null,parseHTML:e=>e.getAttribute(`data-efe-field`),renderHTML:e=>({"data-efe-field":e.fieldId})},label:{default:``,parseHTML:e=>e.getAttribute(`data-efe-label`)??``,renderHTML:e=>({"data-efe-label":e.label})},required:{default:!1,parseHTML:e=>e.getAttribute(`data-efe-required`)===`true`,renderHTML:e=>({"data-efe-required":e.required?`true`:`false`})},maxLength:{default:null,parseHTML:e=>{let t=Number(e.getAttribute(`data-efe-maxlength`));return Number.isFinite(t)&&t>0?t:null},renderHTML:e=>e.maxLength?{"data-efe-maxlength":String(e.maxLength)}:{}},options:{default:null,parseHTML:e=>{try{let t=oT(JSON.parse(e.getAttribute(`data-efe-options`)??``));return t.length?t:null}catch{return null}},renderHTML:e=>e.options?.length?{"data-efe-options":JSON.stringify(e.options)}:{}},optionsSource:{default:null,parseHTML:e=>e.getAttribute(`data-efe-options-source`),renderHTML:e=>e.optionsSource?{"data-efe-options-source":e.optionsSource}:{}},kind:{default:null,rendered:!1},who:{default:null,rendered:!1},min:{default:null,rendered:!1},max:{default:null,rendered:!1},decimals:{default:null,rendered:!1},value:{default:``,parseHTML:e=>e.textContent??``,renderHTML:()=>({})}}},parseHTML(){return[{tag:`span[data-efe-field]`}]},renderHTML({node:e,HTMLAttributes:t}){return[`span`,H({class:`efe-field`},t),e.attrs.value??``]},addNodeView(){return iT(this.options)}});function lT(e){let t=[],n=null;return e.state.doc.descendants(e=>e.type.name===`docSection`?(n=e.attrs.sectionId??null,!0):(e.type.name===`docField`&&e.attrs.required&&!(e.attrs.value??``).trim()&&t.push({sectionId:n,fieldId:e.attrs.fieldId??null,label:e.attrs.label??``}),!0)),t}function uT(e){let{char:t,allowSpaces:n,allowToIncludeChar:r,allowedPrefixes:i,startOfLine:a,$position:o}=e,s=n&&!r,c=yf(t),l=RegExp(`\\s${c}$`),u=a?`^`:``,d=r?``:c,f=RegExp(s?`${u}${c}.*?(?=\\s${d}|$)`:`${u}(?:^)?${c}[^\\s${d}]*`,`gm`),p=o.nodeBefore?.isText&&o.nodeBefore.text;if(!p)return null;let m=o.pos-p.length,h=Array.from(p.matchAll(f)).pop();if(!h||h.input===void 0||h.index===void 0)return null;let g=h.input.slice(Math.max(0,h.index-1),h.index),_=RegExp(`^[${i?.map(yf).join(``)}\0]?$`).test(g);if(i!==null&&!_)return null;let v=m+h.index,y=v+h[0].length;return s&&l.test(p.slice(y-1,y+1))&&(h[0]+=` `,y+=1),v=o.pos?{range:{from:v,to:y},query:h[0].slice(t.length),text:h[0]}:null}function dT(e){return e.docChanged?e.steps.some(e=>{let t=e.slice;if(!t?.content)return!1;let n=t.content.textBetween(0,t.content.size,` -`);return/\s/.test(n)}):!1}function fT(e){return()=>{let t=e.state.selection.$anchor.pos,{top:n,right:r,bottom:i,left:a}=e.view.coordsAtPos(t);try{return new DOMRect(a,n,r-a,i-n)}catch{return null}}}function pT(e,t,n,r){return n?()=>{let n=r.getState(e.state)?.decorationId;return t.dom.querySelector(`[data-decoration-id="${n}"]`)?.getBoundingClientRect()||null}:fT(e)}function mT({match:e,dismissedRange:t,state:n,transaction:r,editor:i,shouldResetDismissed:a,effectiveAllowSpaces:o}){return a?.({editor:i,state:n,range:t,match:e,transaction:r,allowSpaces:o})?!1:o?e.range.from===t.from:e.range.from===t.from&&!dT(r)}function hT({view:e,pluginKeyRef:t}){let n=e.state.tr.setMeta(t,{exit:!0});e.dispatch(n)}function gT({pluginKey:e,decorationTag:t,decorationClass:n,decorationContent:r,decorationEmptyClass:i,renderer:a,dispatchExit:o}){return{handleKeyDown(t,n){var r;let i=e.getState(t.state);if(!i.active)return!1;if(n.key===`Escape`||n.key===`Esc`){var s;return a==null||(s=a.onKeyDown)==null||s.call(a,{view:t,event:n,range:i.range}),o(t),!0}return(a==null||(r=a.onKeyDown)==null?void 0:r.call(a,{view:t,event:n,range:i.range}))||!1},decorations(a){let{active:o,range:s,decorationId:c,query:l}=e.getState(a);if(!o)return null;let u=!l?.length,d=[n];return u&&d.push(i),L.create(a.doc,[ds.inline(s.from,s.to,{nodeName:t,class:d.join(` `),"data-decoration-id":c||void 0,"data-decoration-content":r})])}}}function _T({editor:e,char:t,effectiveAllowSpaces:n,allowToIncludeChar:r,allowedPrefixes:i,startOfLine:a,findSuggestionMatch:o,allow:s,shouldShow:c,shouldKeepDismissed:l,pluginKey:u}){return{init(){return{active:!1,range:{from:0,to:0},query:null,text:null,composing:!1,dismissedRange:null}},apply(d,f,p,m){let{isEditable:h}=e,{composing:g}=e.view,{selection:_}=d,{empty:v,from:y}=_,b={...f},x=d.getMeta(u);if(x&&x.exit)return b.active=!1,b.decorationId=null,b.range={from:0,to:0},b.query=null,b.text=null,b.dismissedRange=f.active?{...f.range}:f.dismissedRange,b;if(b.composing=g,d.docChanged&&b.dismissedRange!==null&&(b.dismissedRange={from:d.mapping.map(b.dismissedRange.from),to:d.mapping.map(b.dismissedRange.to)}),h&&(v||e.view.composing)){(yf.range.to)&&!g&&!f.composing&&(b.active=!1);let u=o({char:t,allowSpaces:n,allowToIncludeChar:r,allowedPrefixes:i,startOfLine:a,$position:_.$from}),p=`id_${Math.floor(Math.random()*4294967295)}`;u&&s({editor:e,state:m,range:u.range,isActive:f.active})&&(!c||c({editor:e,range:u.range,query:u.query,text:u.text,transaction:d}))?(b.dismissedRange!==null&&!l({match:u,dismissedRange:b.dismissedRange,state:m,transaction:d})&&(b.dismissedRange=null),b.dismissedRange===null?(b.active=!0,b.decorationId=f.decorationId||p,b.range=u.range,b.query=u.query,b.text=u.text):b.active=!1):(u||(b.dismissedRange=null),b.active=!1)}else b.active=!1;return b.active||(b.decorationId=null,b.range={from:0,to:0},b.query=null,b.text=null),b}}}function vT({editor:e,items:t}){let n=null,r=null,i=null,a=()=>{r!==null&&(clearTimeout(r),r=null),i?.(),i=null},o=e=>new Promise(t=>{i=t,r=setTimeout(()=>{r=null;let e=i;i=null,e?.()},e)}),s=()=>{n?.abort(),a(),n=null};return{abort:s,fetch:async(r,i)=>{s(),n=new AbortController;let a=n;if(i>0&&await o(i),n!==a||a.signal.aborted)return{status:`aborted`};try{let i=await t({editor:e,query:r,signal:a.signal});return n!==a||a.signal.aborted?{status:`aborted`}:{status:`resolved`,items:i}}catch{return n!==a||a.signal.aborted?{status:`aborted`}:{status:`error`}}}}}function yT({placement:e,offset:t,flip:n,floatingUi:r}){var i;let a=[rC({mainAxis:t.mainAxis??4,crossAxis:t.crossAxis??0})];return n&&a.push(oC()),r!=null&&(i=r.middleware)!=null&&i.length&&a.push(...r.middleware),{placement:e,strategy:r?.strategy??`absolute`,middleware:a}}function bT(e){if(e instanceof HTMLElement)return e;if(typeof e==`string`)try{let t=document.querySelector(e);if(t)return t}catch{return document.body}return document.body}function xT({getReferenceRect:e,contextElement:t,config:n,container:r,dismissOnOutsideClick:i,dismiss:a}){return(o,s={})=>{let c={getBoundingClientRect:()=>e()??new DOMRect,contextElement:t},l=!1,u=!o.isConnected;u&&bT(r).appendChild(o),s.onPosition||(o.style.visibility=`hidden`,o.style.width=`max-content`);let d=nC(c,o,()=>{dC(c,o,{placement:n.placement,strategy:n.strategy,middleware:n.middleware}).then(({x:e,y:t,placement:n,strategy:r})=>{s.onPosition?s.onPosition({x:e,y:t,placement:n,strategy:r}):(Object.assign(o.style,{position:r,left:`${e}px`,top:`${t}px`}),l||(l=!0,o.style.visibility=``))})},s.autoUpdate),f;return i&&(f=e=>{let n=e.target;!(n instanceof Node)||o.contains(n)||t.contains(n)||a()},document.addEventListener(`pointerdown`,f,!0)),()=>{d(),f&&document.removeEventListener(`pointerdown`,f,!0),u&&o.remove()}}}function ST({editor:e,pluginKey:t,items:n,renderer:r,minQueryLength:i,debounce:a,initialItems:o,placement:s,offset:c,container:l,flip:u,floatingUi:d,dismissOnOutsideClick:f,command:p,clientRectFor:m,dispatchExit:h}){let g,_=vT({editor:e,items:n}),v=yT({placement:s,offset:c,flip:u,floatingUi:d});function y(e,t){switch(e){case`started`:var n;r==null||(n=r.onStart)==null||n.call(r,t);break;case`updated`:var i;r==null||(i=r.onUpdate)==null||i.call(r,t);break;case`stopped`:var a;r==null||(a=r.onExit)==null||a.call(r,t)}}return{update:async(n,d)=>{let b=t.getState(d),x=t.getState(n.state);if(!b||!x)return;let S=null,C=b.query!==x.query,w=b.text!==x.text,T=b.range.from!==x.range.from||b.range.to!==x.range.to,ee=C||w||T;if(!b.active&&x.active)S=`started`;else if(b.active&&!x.active)S=`stopped`;else if(x.active&&ee)S=`updated`;else return;let E=S===`stopped`?b:x,D=n.dom.querySelector(`[data-decoration-id="${E.decorationId}"]`),te=m(n,D),ne=i===0||(E.query?E.query.length>=i:!1),re=(S===`started`||S===`updated`)&≠if(g={editor:e,range:E.range,query:E.query||``,text:E.text||``,items:o??[],command:t=>p({editor:e,range:E.range,props:t}),decorationNode:D,clientRect:te,loading:re,placement:s,offset:{mainAxis:c.mainAxis??4,crossAxis:c.crossAxis??0},container:l,flip:u,floatingUi:v,mount:xT({getReferenceRect:te,contextElement:n.dom,config:v,container:l,dismissOnOutsideClick:f,dismiss:()=>h(e.view)})},S===`started`){var ie;r==null||(ie=r.onBeforeStart)==null||ie.call(r,g)}if(S===`updated`){var ae;r==null||(ae=r.onBeforeUpdate)==null||ae.call(r,g)}if(S===`started`&&y(S,g),S===`started`||S===`updated`){if(!re)_.abort(),g={...g,items:o??[],loading:!1};else{g={...g,items:o??[],loading:!0},S=`updated`,y(S,g);let e=await _.fetch(E.query||``,a);if(e.status===`aborted`)return;if(!t.getState(n.state)?.active){_.abort();return}g=e.status===`resolved`?{...g,items:e.items,loading:!1}:{...g,loading:!1}}}S===`stopped`?(_.abort(),y(S,g),g=void 0):S===`updated`&&y(S,g)},destroy:()=>{var e;_.abort(),g&&(r==null||(e=r.onExit)==null||e.call(r,g))}}}var CT=new N(`suggestion`);function wT({pluginKey:e=CT,editor:t,char:n=`@`,allowSpaces:r=!1,allowToIncludeChar:i=!1,allowedPrefixes:a=[` `],startOfLine:o=!1,decorationTag:s=`span`,decorationClass:c=`suggestion`,decorationContent:l=``,decorationEmptyClass:u=`is-empty`,command:d=()=>null,items:f=()=>[],minQueryLength:p=0,debounce:m=0,initialItems:h,placement:g=`bottom-start`,offset:_={},container:v,flip:y=!0,floatingUi:b,dismissOnOutsideClick:x=!0,render:S=()=>({}),allow:C=()=>!0,findSuggestionMatch:w=uT,shouldShow:T,shouldResetDismissed:ee}){let E=S?.(),D=r&&!i,te=(n,r)=>pT(t,n,r,e);function ne(e){return mT({...e,editor:t,shouldResetDismissed:ee,effectiveAllowSpaces:D})}let re=t=>hT({view:t,pluginKeyRef:e});return new M({key:e,view:()=>ST({editor:t,pluginKey:e,items:f,renderer:E,minQueryLength:p,debounce:m,initialItems:h,placement:g,offset:_,container:v,flip:y,floatingUi:b,dismissOnOutsideClick:x,command:d,clientRectFor:te,dispatchExit:re}),state:_T({editor:t,char:n,effectiveAllowSpaces:D,allowToIncludeChar:i,allowedPrefixes:a,startOfLine:o,findSuggestionMatch:w,allow:C,shouldShow:T,shouldKeepDismissed:ne,pluginKey:e}),props:gT({pluginKey:e,decorationTag:s,decorationClass:c,decorationContent:l,decorationEmptyClass:u,renderer:E,dispatchExit:re})})}var TT=wT;function ET(){let e=null,t=null,n=[],r=0,i=null,a=()=>{if(e.innerHTML=``,n.length===0){let t=document.createElement(`div`);t.className=`efe-suggest__empty`,t.textContent=`Keine Treffer`,e.appendChild(t)}else n.forEach((t,n)=>{let a=document.createElement(`button`);a.type=`button`,a.className=`efe-suggest__item`,a.classList.toggle(`is-active`,n===r),a.textContent=t.label,a.dataset.efeVariableName=t.name,a.addEventListener(`mousedown`,e=>{e.preventDefault(),i?.(t)}),e.appendChild(a)})};return{onStart:o=>{e=document.createElement(`div`),e.className=`efe-suggest`,e.setAttribute(`role`,`listbox`),e.setAttribute(`aria-label`,`Variable auswählen`),n=o.items,r=0,i=o.command,a(),t=o.mount(e)},onUpdate:e=>{n=e.items,r=0,i=e.command,a()},onKeyDown:({event:e})=>n.length===0&&e.key!==`Escape`?!1:e.key===`ArrowDown`?(r=(r+1)%n.length,a(),!0):e.key===`ArrowUp`?(r=(r-1+n.length)%n.length,a(),!0):e.key===`Enter`?(i?.(n[r]),!0):e.key===`Escape`&&(t?.(),!0),onExit:()=>{t?.(),e=null}}}var DT=U.create({name:`variableSuggestion`,addOptions(){return{variables:{},char:`{{`}},addProseMirrorPlugins(){let e=this;return[TT({editor:this.editor,char:this.options.char,allowSpaces:!1,items:({query:t})=>Gw(e.options.variables,t),command:({editor:e,range:t,props:n})=>{e.chain().focus().insertContentAt(t,{type:`docVariable`,attrs:{name:n.name}}).run()},render:ET})]}});function OT(e){return({node:t,getPos:n,editor:r})=>{let i=!!e.templateMode,a=t,o=document.createElement(`section`);o.className=`efe-section`;let s=document.createElement(`div`);s.className=`efe-section__head`,s.setAttribute(`contenteditable`,`false`);let c=document.createElement(`div`);c.className=`efe-section__content`;let l=document.createElement(`div`);l.className=`efe-section__repeat`,l.setAttribute(`contenteditable`,`false`),o.append(s,c,l);let u=e=>e.attrs.title?String(e.attrs.title):``,d=e=>{s.replaceChildren();let{mode:t,repeatable:n}=e.attrs,r=u(e);if(i){let e=document.createElement(`span`);if(e.className=`efe-section__badge`,e.textContent=t===`locked`?`Gesperrt`:`Frei`,ox(e,t===`locked`?`Gesperrter Abschnitt: im Dokument nur die Felder ausfüllbar`:`Freier Abschnitt: im Dokument frei beschreibbar`),s.append(e),n){let e=document.createElement(`span`);e.className=`efe-section__badge efe-section__badge--repeat`,e.textContent=`Wiederholbar`,s.append(e)}}else if(t===`locked`){let e=document.createElement(`span`);e.className=`efe-section__lock`,e.append(ax(`lock`)),ox(e,`Aus der Vorlage, nicht änderbar`),s.append(e)}if(r){let e=document.createElement(`span`);e.className=`efe-section__title`,e.textContent=r,s.append(e)}s.hidden=s.childElementCount===0},f=()=>{let e=typeof n==`function`?n():void 0,t=a.attrs.templateSectionId;if(typeof e!=`number`||!t||a.attrs.repeatable!==!0)return null;let i=0,o=null;return r.state.doc.forEach((e,n)=>{e.type.name===`docSection`&&e.attrs.repeatable===!0&&e.attrs.templateSectionId===t&&(i+=1,o=n)}),{pos:e,count:i,isLast:o===e}},p=(e,t,n,r)=>{let i=document.createElement(`button`);return i.type=`button`,i.className=`efe-section__repeat-btn`,i.append(ax(e),document.createTextNode(t)),ox(i,n),i.addEventListener(`mousedown`,e=>e.preventDefault()),i.addEventListener(`click`,e=>{e.preventDefault(),r()}),i},m=()=>{l.replaceChildren();let e=!i&&r.isEditable?f():null;if(!e){l.hidden=!0;return}let t=u(a)||`Abschnitt`;e.count>1&&l.append(p(`trash`,`Entfernen`,`Diesen Eintrag „${t}“ entfernen`,()=>{let e=n();typeof e==`number`&&r.commands.removeSectionInstance(e)})),e.isLast&&l.append(p(`plus`,`${t}: weiteren hinzufügen`,`Einen weiteren Eintrag „${t}“ anlegen`,()=>{let e=n();typeof e==`number`&&r.commands.addSectionInstance(e)})),l.hidden=l.childElementCount===0},h=e=>{a=e;let{mode:t,sectionId:n,hint:r}=e.attrs;n?o.dataset.efeSection=n:delete o.dataset.efeSection,o.dataset.efeMode=t,o.classList.toggle(`efe-section--locked`,t===`locked`),o.classList.toggle(`efe-section--free`,t===`free`),o.classList.toggle(`efe-section--repeatable`,e.attrs.repeatable===!0),o.classList.toggle(`efe-section--titled`,!!e.attrs.title),r?(c.dataset.efeHint=r,c.style.setProperty(`--efe-hint`,JSON.stringify(String(r)))):(delete c.dataset.efeHint,c.style.removeProperty(`--efe-hint`)),d(e),m(),!i&&t===`locked`?(c.setAttribute(`contenteditable`,`false`),c.setAttribute(`aria-readonly`,`true`)):(c.removeAttribute(`contenteditable`),c.removeAttribute(`aria-readonly`))};h(t);let g=null,_=t=>{if(i||a.attrs.mode!==`locked`||!r.isEditable)return;let n=t.target instanceof Element?t.target:null;n&&c.contains(n)&&!n.closest(`.efe-field`)&&(o.classList.add(`is-nudged`),clearTimeout(g),g=setTimeout(()=>o.classList.remove(`is-nudged`),900),typeof e.onBlocked==`function`&&e.onBlocked(`locked-content`))};o.addEventListener(`mousedown`,_);let v=({transaction:e})=>{(e.docChanged||e.getMeta(`efePreview`)!==void 0)&&m()};return r.on(`transaction`,v),{dom:o,contentDOM:c,update:e=>e.type===t.type&&(h(e),!0),stopEvent:e=>{let t=e.target instanceof Node?e.target:null;return!!(t&&(s.contains(t)||l.contains(t)))},ignoreMutation:e=>e.type!==`selection`&&!c.contains(e.target),destroy:()=>{clearTimeout(g),o.removeEventListener(`mousedown`,_),r.off(`transaction`,v)}}}}function kT(){return typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():`section-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function AT(e){return e.attrs.templateSectionId||e.attrs.sectionId||null}function jT(e,t){return typeof t==`number`&&t>=0&&t=0;--t){let n=e.node(t);if(n.type.name===`docSection`)return{node:n,before:e.before(t),after:e.after(t)}}return null}function NT(e){let t=[];return e.forEach(e=>{e.type.name===`docSection`&&t.push(`${e.attrs.sectionId}:${AT(e)}:${e.attrs.mode}:${e.attrs.repeatable?`r`:`-`}`)}),t.join(`|`)}function PT(e){let t=[];return e.forEach(e=>{e.type.name===`docSection`&&t.push(e)}),t}function FT(e,t){let n=PT(e),r=PT(t),i=r.length-n.length;if(i!==1&&i!==-1)return!1;let a=i===1?r:n,o=i===1?n:r,s=o.length;for(let e=0;ee.attrs.templateSectionId===l&&e.attrs.repeatable===!0;for(let e=0;ee.attrs.sectionId));return!!c.attrs.sectionId&&!t.has(c.attrs.sectionId)}return o.some(u)}function IT(e){let t=new Set,n=!0;return e.forEach(e=>{if(e.type.name!==`docSection`)return;let r=e.attrs.sectionId;(!r||t.has(r))&&(n=!1),t.add(r)}),n}function LT(e){let t=[];return e.forEach((e,n)=>{e.type.name===`docSection`&&e.attrs.mode===`locked`&&t.push([n,n+e.nodeSize])}),t}function RT(e,t){let n=LT(t);if(n.length===0)return!1;let r=!1;return e.getMap().forEach((e,t)=>{for(let[i,a]of n)ei&&(r=!0)}),r}var zT=W.create({name:`docSection`,content:`block+`,defining:!0,isolating:!0,addOptions(){return{templateMode:!1,onBlocked:null}},addAttributes(){return{mode:{default:`free`,parseHTML:e=>e.getAttribute(`data-efe-mode`)??`free`,renderHTML:e=>({"data-efe-mode":e.mode})},sectionId:{default:null,parseHTML:e=>e.getAttribute(`data-efe-section`),renderHTML:e=>({"data-efe-section":e.sectionId})},templateSectionId:{default:null,parseHTML:e=>e.getAttribute(`data-efe-template-section`),renderHTML:e=>e.templateSectionId?{"data-efe-template-section":e.templateSectionId}:{}},repeatable:{default:!1,parseHTML:e=>e.getAttribute(`data-efe-repeatable`)===`true`,renderHTML:e=>e.repeatable?{"data-efe-repeatable":`true`}:{}},title:{default:``,parseHTML:()=>``,renderHTML:()=>({})},hint:{default:``,parseHTML:()=>``,renderHTML:()=>({})}}},parseHTML(){return[{tag:`section[data-efe-section][data-efe-mode]`}]},renderHTML({HTMLAttributes:e}){return[`section`,H({class:`efe-section`},e),0]},addCommands(){let e=this;return{insertSection:(t=`free`)=>({state:n,tr:r,dispatch:i})=>{if(!e.options.templateMode)return!1;let a=n.schema.nodes.docSection,o=n.schema.nodes.paragraph;if(!a)return!1;let s=kT(),c=a.create({mode:t,sectionId:s,templateSectionId:s},o?o.create():void 0),l=MT(n.selection.$from),u=l?l.after:n.doc.content.size;return i&&r.insert(u,c).scrollIntoView(),!0},toggleSectionMode:()=>({state:t,tr:n,dispatch:r})=>{if(!e.options.templateMode)return!1;let i=MT(t.selection.$from);if(!i)return!1;let a=i.node.attrs.mode===`locked`?`free`:`locked`;return r&&n.setNodeMarkup(i.before,void 0,{...i.node.attrs,mode:a}),!0},addSectionInstance:e=>({state:t,tr:n,dispatch:r})=>{let i=MT(jT(t,e));if(!i||!i.node.attrs.templateSectionId||i.node.attrs.repeatable!==!0)return!1;let a=i.node.type.create({...i.node.attrs,sectionId:kT()},VT(i.node).content,i.node.marks);return r&&n.insert(i.after,a).setMeta(`sectionInstance`,!0).scrollIntoView(),!0},removeSectionInstance:e=>({state:t,tr:n,dispatch:r})=>{let i=MT(jT(t,e));if(!i||!i.node.attrs.templateSectionId||i.node.attrs.repeatable!==!0)return!1;let a=i.node.attrs.templateSectionId,o=0;return t.doc.forEach(e=>{e.type.name===`docSection`&&e.attrs.repeatable===!0&&e.attrs.templateSectionId===a&&(o+=1)}),o<2?!1:(r&&n.delete(i.before,i.after).setMeta(`sectionInstance`,!0),!0)}}},addNodeView(){return OT(this.options)}}),BT=W.create({name:`doc`,topNode:!0,content:`docSection+`});function VT(e){if(e.type.name===`docField`)return e.type.create({...e.attrs,value:``},null,e.marks);if(e.childCount===0)return e;let t=[];return e.forEach(e=>{t.push(VT(e))}),e.copy(c.fromArray(t))}var HT=U.create({name:`sectionLockGuard`,addOptions(){return{templateMode:!1,onBlocked:null}},addProseMirrorPlugins(){let e=this;return[new M({key:new N(`sectionLockGuard`),filterTransaction(t,n){let r=t=>(typeof e.options.onBlocked==`function`&&e.options.onBlocked(t),!1);if(!t.docChanged||(e.options.templateMode&&t.setMeta(`templateMode`,!0),e.options.templateMode||t.getMeta(`templateMode`)===!0))return!0;if(!IT(n.doc))return console.warn(`[sectionLockGuard] Ungueltige sectionIds (leer oder doppelt) im Dokument. Transaktion im Schreibmodus vorsorglich verworfen.`),r(`invalid-section-ids`);if(t.getMeta(`sectionInstance`)===!0)return FT(n.doc,t.doc)?!0:r(`section-structure`);for(let e=0;e0?`choice`:`line`}function YT(e){return WT.includes(e?.format)?e.format:`plain`}function XT(e){return`${e}-${typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}`}function ZT(e,t){let n=KT[t],r=qT[t],i=[];for(let a of e??[])for(let e of $T(a,n,r,t===`full`))i.push(e);return i}function QT(e,t){let n=[];for(let r of e??[])if(r?.type===`text`&&typeof r.text==`string`&&r.text!==``){let e=(r.marks??[]).filter(e=>t.includes(e?.type)).map(e=>e.type===`textStyle`&&typeof e.attrs?.fontFamily==`string`?{type:`textStyle`,attrs:{fontFamily:e.attrs.fontFamily}}:{type:e.type});n.push(e.length?{type:`text`,text:r.text,marks:e}:{type:`text`,text:r.text})}else r?.type===`hardBreak`?n.push({type:`hardBreak`}):r?.type===`docVariable`&&r.attrs?.name&&n.push({type:`docVariable`,attrs:{name:r.attrs.name}});return n}function $T(e,t,n,r){let i=e?.type;if(!i)return[];if(i===`text`||i===`hardBreak`||i===`docVariable`){let t=QT([e],n);return t.length?[{type:`paragraph`,content:t}]:[]}let a=t.includes(i);if(i===`paragraph`||i===`heading`){let t=QT(e.content,n),o={type:a?i:`paragraph`},s={};return a&&i===`heading`&&(s.level=[1,2,3].includes(e.attrs?.level)?e.attrs.level:1),r&&[`left`,`center`,`right`,`justify`].includes(e.attrs?.textAlign)&&(s.textAlign=e.attrs.textAlign),Object.keys(s).length&&(o.attrs=s),t.length&&(o.content=t),[o]}if([`bulletList`,`orderedList`,`blockquote`,`listItem`,`table`,`tableRow`,`tableHeader`,`tableCell`].includes(i)){if(a&&[`bulletList`,`orderedList`,`table`,`tableRow`,`tableHeader`,`tableCell`,`listItem`,`blockquote`].includes(i)){let a=[`table`,`tableRow`].includes(i)||[`bulletList`,`orderedList`].includes(i)?(e.content??[]).map(e=>tE(e,t,n,r)).filter(Boolean):eE(e.content,t,n,r);if(!a.length)return[];let o={type:i,content:a};return e.attrs&&(i===`orderedList`||i===`tableCell`||i===`tableHeader`)&&(o.attrs=e.attrs),[o]}let o=[];for(let i of e.content??[])o.push(...$T(i,t,n,r));return o}return(i===`horizontalRule`||i===`pageBreak`)&&a?[{type:i}]:[]}function eE(e,t,n,r){let i=[];for(let a of e??[])i.push(...$T(a,t,n,r));return i.length?i:[{type:`paragraph`}]}function tE(e,t,n,r){let i=e?.type;if(i===`tableRow`){let a=(e.content??[]).map(e=>tE(e,t,n,r)).filter(Boolean);return a.length?{type:i,content:a}:null}if(i===`listItem`||i===`tableCell`||i===`tableHeader`){let a={type:i,content:eE(e.content,t,n,r)};return e.attrs&&i!==`listItem`&&(a.attrs=e.attrs),a}return null}var Z=e=>({default:e,rendered:!1,keepOnSplit:!1}),nE=()=>({templateMode:!1,can:null,onBlocked:null});function rE(e,t){return!t||typeof e.can!=`function`||!!e.can(t)}function iE(e){return!e||typeof e!=`object`?``:e.type===`text`?e.text??``:(e.content??[]).map(iE).join(e.type===`paragraph`?``:` `)}var aE=Hf.create({name:`efePrompt`,inclusive:!1,excludes:``,parseHTML(){return[{tag:`span.efe-prompt`}]},renderHTML({HTMLAttributes:e}){return[`span`,H({class:`efe-prompt`},e),0]}}),oE=W.create({name:`docInput`,group:`block`,content:`(docFixed | block)*`,defining:!0,isolating:!0,addOptions:nE,addAttributes(){return{inputId:Z(null),kind:Z(`text`),label:Z(``),format:Z(`plain`),start:Z(`empty`),placeholder:Z(``),required:Z(!1),minLength:Z(null),who:Z(null),snippets:Z(null),choice:Z(null)}},parseHTML(){return[{tag:`div[data-efe-input]`}]},renderHTML({node:e,HTMLAttributes:t}){return[`div`,H({class:`efe-input`,"data-efe-input":e.attrs.inputId??``},t),0]},addNodeView(){return pE(this.options)}}),sE=W.create({name:`docFixed`,content:`block+`,defining:!0,isolating:!0,addOptions:nE,addAttributes(){return{fixedId:Z(null)}},parseHTML(){return[{tag:`div[data-efe-fixed]`}]},renderHTML({node:e,HTMLAttributes:t}){return[`div`,H({class:`efe-fixed`,"data-efe-fixed":e.attrs.fixedId??``},t),0]},addNodeView(){return mE(this.options,`fixed`)}}),cE=W.create({name:`docAside`,group:`block`,content:`block+`,defining:!0,isolating:!0,addOptions:nE,addAttributes(){return{asideId:Z(null),side:Z(`right`),width:Z(60),frame:Z(!0)}},parseHTML(){return[{tag:`aside[data-efe-aside]`}]},renderHTML({node:e,HTMLAttributes:t}){let n=e.attrs.side===`left`?`left`:`right`;return[`aside`,H({class:`efe-aside efe-aside--${n}${e.attrs.frame===!1?``:` efe-aside--framed`}`,"data-efe-aside":e.attrs.asideId??``,style:`float: ${n}; width: ${Number(e.attrs.width)||60}mm`},t),0]},addNodeView(){return mE(this.options,`aside`)}}),lE=W.create({name:`docRepeat`,group:`block`,content:`block+`,defining:!0,isolating:!0,addOptions:nE,addAttributes(){return{repeatId:Z(null),instanceId:Z(null),label:Z(``)}},parseHTML(){return[{tag:`div[data-efe-repeat]`}]},renderHTML({node:e,HTMLAttributes:t}){return[`div`,H({class:`efe-repeat`,"data-efe-repeat":e.attrs.instanceId??``},t),0]},addNodeView(){return mE(this.options,`repeat`)}}),uE=W.create({name:`docOptional`,group:`block`,content:`block+`,defining:!0,isolating:!0,addOptions:nE,addAttributes(){return{optionalId:Z(null),label:Z(``),enabled:Z(!0)}},parseHTML(){return[{tag:`div[data-efe-optional]`}]},renderHTML({node:e,HTMLAttributes:t}){return[`div`,H({class:`efe-optional`,"data-efe-optional":e.attrs.optionalId??``},t),0]},addNodeView(){return mE(this.options,`optional`)}});function dE(e,t=`efe-block__badge`){let n=document.createElement(`span`);return n.className=t,n.textContent=e,n}function fE(e,t,n,r){let i=document.createElement(`button`);return i.type=`button`,i.className=`efe-block__btn`,i.append(ax(e),document.createTextNode(t)),ox(i,n),i.addEventListener(`mousedown`,e=>e.preventDefault()),i.addEventListener(`click`,e=>{e.preventDefault(),r()}),i}function pE(e){return({node:t,getPos:n,editor:r})=>{let i=!!e.templateMode,a=t,o=document.createElement(`div`);o.className=`efe-input`;let s=document.createElement(`div`);s.className=`efe-block__head efe-input__head`,s.setAttribute(`contenteditable`,`false`);let c=t.attrs.kind===`snippet`,l=c?null:document.createElement(`div`),u=c?document.createElement(`div`):null;l?(l.className=`efe-input__body`,o.append(s,l)):(u.className=`efe-input__snippet`,u.setAttribute(`contenteditable`,`false`),o.append(s,u));let d=t=>{let a=Array.isArray(t.attrs.snippets)?t.attrs.snippets:[];if(u.replaceChildren(),!i){let i=document.createElement(`select`);i.className=`efe-input__choice`,i.setAttribute(`aria-label`,t.attrs.label||`Textbaustein`),i.append(new Option(`${t.attrs.label||`Textbaustein`} wählen${t.attrs.required?` *`:``}`,``));for(let e of a)i.append(new Option(e.name??e.id,e.id));i.value=t.attrs.choice??``,i.disabled=!r.isEditable||!rE(e,t.attrs.who),i.addEventListener(`change`,()=>{let e=n();typeof e==`number`&&r.commands.chooseSnippet(e,i.value||null)}),u.append(i)}let o=i?a[0]:a.find(e=>e.id===t.attrs.choice);if(o){let e=document.createElement(`p`);e.className=`efe-input__snippet-text`,e.textContent=(Array.isArray(o.content)?o.content:o.content?.content??[]).map(iE).join(` -`),u.append(e)}if(i&&a.length){let e=document.createElement(`div`);e.className=`efe-input__snippet-more`,e.textContent=`${a.length} Varianten: ${a.map(e=>e.name??e.id).join(` · `)}`,u.append(e)}},f=t=>{a=t;let{label:n,required:u,format:f,who:p,placeholder:m,kind:h}=t.attrs,g=!i&&!rE(e,p);if(o.dataset.efeInput=t.attrs.inputId??``,o.dataset.efeKind=h??`text`,o.dataset.efeFormat=f??`plain`,o.classList.toggle(`is-required`,!!u),o.classList.toggle(`is-locked`,g),o.classList.toggle(`is-empty`,!c&&t.textContent.trim()===``),s.replaceChildren(dE(n||(c?`Textbaustein`:`Textbereich`),`efe-block__label`)),u&&s.append(dE(`Pflicht`)),p&&(i||g)){let e=dE(i?`nur: ${p}`:`gesperrt`,`efe-block__badge efe-block__badge--who`);ox(e,i?`Nur mit dem Recht „${p}“ auszufüllen`:`Füllt aus: ${p}`),s.append(e)}l?(m?l.style.setProperty(`--efe-placeholder`,JSON.stringify(String(m))):l.style.removeProperty(`--efe-placeholder`),i?l.removeAttribute(`contenteditable`):l.setAttribute(`contenteditable`,g||!r.isEditable?`false`:`true`)):d(t)};f(t);let p=({transaction:e})=>{e.getMeta(`efePreview`)!==void 0&&f(a)};return r.on(`transaction`,p),{dom:o,contentDOM:l,destroy:()=>r.off(`transaction`,p),update:e=>e.type!==t.type||e.attrs.kind===`snippet`!==c?!1:(f(e),!0),stopEvent:e=>{let t=e.target instanceof window.Node?e.target:null;return!!(t&&(s.contains(t)||u?.contains(t)))},ignoreMutation:e=>e.type===`selection`?!1:!l||e.type===`attributes`&&(e.target===l||e.target===o)||!l.contains(e.target),get node(){return a}}}}function mE(e,t){return({node:n,getPos:r,editor:i})=>{let a=!!e.templateMode,o=n,s=document.createElement(t===`aside`?`aside`:`div`);s.className=`efe-${t}`;let c=document.createElement(`div`);c.className=`efe-block__head efe-${t}__head`,c.setAttribute(`contenteditable`,`false`);let l=document.createElement(`div`);l.className=`efe-${t}__body`,s.append(c,l);let u=()=>{let e=0;return i.state.doc.forEach(t=>{t.type.name===`docRepeat`&&t.attrs.repeatId===o.attrs.repeatId&&(e+=1)}),e},d=()=>{let e=r();if(typeof e!=`number`)return!1;let t=i.state.doc.nodeAt(e+o.nodeSize);return!t||t.type.name!==`docRepeat`||t.attrs.repeatId!==o.attrs.repeatId},f=()=>{c.replaceChildren();let e=o.attrs.label?String(o.attrs.label):``;if(t===`fixed`)c.append(dE(`fest`)),ox(c,a?`Fester Teil: der Verfasser kann ihn weder ändern noch löschen`:`Aus der Vorlage, nicht änderbar`);else if(t===`aside`)a&&c.append(dE(`Randkasten · fest`));else if(t===`repeat`)c.append(dE(e||`Eintrag`,`efe-block__label`)),a?c.append(dE(`Wiederholbar`)):i.isEditable&&(u()>1&&c.append(fE(`trash`,`Entfernen`,`Diesen Eintrag „${e||`Eintrag`}“ entfernen`,()=>{let e=r();typeof e==`number`&&i.commands.removeRepeatInstance(e)})),d()&&c.append(fE(`plus`,`${e||`Eintrag`}: weiteren hinzufügen`,`Einen weiteren Eintrag „${e||`Eintrag`}“ anlegen`,()=>{let e=r();typeof e==`number`&&i.commands.addRepeatInstance(e)})));else if(t===`optional`){let t=document.createElement(`label`);t.className=`efe-optional__toggle`;let n=document.createElement(`input`);n.type=`checkbox`,n.checked=o.attrs.enabled!==!1,n.disabled=!i.isEditable,n.addEventListener(`change`,()=>{let e=r();typeof e==`number`&&i.commands.toggleOptional(e)}),t.append(n,document.createTextNode(` ${e||`Optionaler Block`}`)),c.append(t),a&&c.append(dE(`Optional`))}c.hidden=c.childElementCount===0},p=e=>{if(o=e,t===`aside`){let t=e.attrs.side===`left`?`left`:`right`;s.className=`efe-aside efe-aside--${t}${e.attrs.frame===!1?``:` efe-aside--framed`}`,s.style.float=t,s.style.width=`${Number(e.attrs.width)||60}mm`}t===`optional`&&s.classList.toggle(`is-off`,e.attrs.enabled===!1),f()};p(n);let m=({transaction:e})=>{t===`repeat`&&e.docChanged&&f()};return i.on(`transaction`,m),{dom:s,contentDOM:l,update:e=>e.type===n.type&&(p(e),!0),stopEvent:e=>{let t=e.target instanceof window.Node?e.target:null;return!!(t&&c.contains(t))},ignoreMutation:e=>e.type===`selection`?!1:e.type===`attributes`&&e.target===s||!l.contains(e.target),destroy:()=>{i.off(`transaction`,m)}}}}function hE(e){let t=e=>{if(!e||typeof e!=`object`)return e;if(e.type===`docField`)return{...e,attrs:{...e.attrs,value:``}};if(e.type===`docInput`){if(e.attrs?.kind===`snippet`)return{...e,attrs:{...e.attrs,choice:null}};let n=(e.content??[]).filter(e=>e.type===`docFixed`).map(t);return{...e,content:[{type:`paragraph`},...n]}}return e.content?{...e,content:e.content.map(t)}:e},n=t(e);return{...n,attrs:{...n.attrs,instanceId:XT(`i`)}}}function gE(e,t){for(let n=e.depth;n>=0;--n){let r=e.node(n);if(t.includes(r.type.name))return{node:r,depth:n,pos:n>0?e.before(n):0}}return null}function _E(e){let t=gE(e,[`docInput`,`docFixed`]);return!!(t&&t.node.type.name===`docInput`)}var vE=U.create({name:`inputCommands`,addOptions:nE,addCommands(){let e=this,t=()=>!!e.options.templateMode;return{insertInputField:(e=`line`,n={})=>({state:r,tr:i,dispatch:a})=>{if(!t())return!1;let{$from:o,$to:s,empty:c}=r.selection;if(!o.parent.isTextblock||o.parent!==s.parent||_E(o))return!1;let l=c?``:r.doc.textBetween(o.pos,s.pos,` `).trim(),u=r.schema.nodes.docField.create({fieldId:XT(`f`),kind:e,label:(n.label??Array.from(l).slice(0,60).join(``))||`Feld`,...e===`choice`?{options:[{label:`Option A`},{label:`Option B`}]}:{},...n});return a&&i.replaceSelectionWith(u,!1),!0},freeAsTextArea:(e={})=>({state:n,tr:r,dispatch:i})=>{if(!t())return!1;let{$from:a,$to:o,empty:s}=n.selection;if(gE(a,[`docInput`,`docAside`]))return!1;let c=n.schema.nodes.docInput,l={inputId:XT(`t`),kind:`text`,label:`Textbereich`,...e};if(s){let e=c.create({format:`basic`,start:`empty`,...l},n.schema.nodes.paragraph.create()),t=a.after(a.depth);return i&&r.insert(t,e),!0}let u=a.blockRange(o);return u?(i&&r.wrap(u,[{type:c,attrs:{format:`full`,start:`suggestion`,...l}}]),!0):!1},freeAsSnippet:(e={})=>({state:n,tr:r,dispatch:i})=>{if(!t())return!1;let{$from:a,$to:o}=n.selection;if(gE(a,[`docInput`,`docAside`]))return!1;let s=a.blockRange(o);if(!s)return!1;let c=[];for(let e=s.startIndex;e({state:e,tr:n,dispatch:r})=>{if(!t())return!1;let{$from:i,$to:a}=e.selection;if(!_E(i)||!_E(a))return!1;let o=i.blockRange(a,e=>e.type.name===`docInput`);return o?(r&&n.wrap(o,[{type:e.schema.nodes.docFixed,attrs:{fixedId:XT(`x`)}}]),!0):!1},releaseFixed:()=>({state:e,tr:n,dispatch:r})=>{if(!t())return!1;let i=gE(e.selection.$from,[`docFixed`]);return i?(r&&n.replaceWith(i.pos,i.pos+i.node.nodeSize,i.node.content),!0):!1},dissolveInput:()=>({state:e,tr:n,dispatch:r})=>{if(!t())return!1;let i=gE(e.selection.$from,[`docInput`]);if(!i)return!1;let a;if(i.node.attrs.kind===`snippet`){let t=(i.node.attrs.snippets??[])[0],n=Array.isArray(t?.content)?t.content:[{type:`paragraph`}];a=c.fromJSON(e.schema,n)}else{let t=[];i.node.forEach(e=>{e.type.name===`docFixed`?e.forEach(e=>t.push(e)):t.push(e)}),a=c.fromArray(t.length?t:[e.schema.nodes.paragraph.create()])}return r&&n.replaceWith(i.pos,i.pos+i.node.nodeSize,a),!0},insertAside:(e={})=>({state:n,tr:r,dispatch:i})=>{if(!t())return!1;let a=n.selection.$from,o=a.depth>0?a.before(1):0,s=n.schema.nodes.docAside.create({asideId:XT(`r`),side:`right`,width:60,frame:!0,...e},n.schema.nodes.paragraph.create(null,n.schema.text(`Randkasten`)));return i&&r.insert(o,s),!0},wrapInRepeat:(e={})=>({state:n,tr:r,dispatch:i})=>{if(!t())return!1;let{$from:a,$to:o}=n.selection,s=a.blockRange(o,e=>e.type.name===`doc`);return s?(i&&r.wrap(s,[{type:n.schema.nodes.docRepeat,attrs:{repeatId:XT(`w`),instanceId:XT(`i`),label:`Eintrag`,...e}}]),!0):!1},wrapInOptional:(e={})=>({state:n,tr:r,dispatch:i})=>{if(!t())return!1;let{$from:a,$to:o}=n.selection,s=a.blockRange(o,e=>e.type.name===`doc`);return s?(i&&r.wrap(s,[{type:n.schema.nodes.docOptional,attrs:{optionalId:XT(`o`),label:`Optional`,enabled:!0,...e}}]),!0):!1},chooseSnippet:(e,t)=>({state:n,tr:r,dispatch:i})=>{let a=n.doc.nodeAt(e);if(!a||a.type.name!==`docInput`||a.attrs.kind!==`snippet`)return!1;let o=(a.attrs.snippets??[]).some(e=>e.id===t);return t!==null&&!o?!1:(i&&r.setNodeAttribute(e,`choice`,t),!0)},toggleOptional:e=>({state:t,tr:n,dispatch:r})=>{let i=t.doc.nodeAt(e);return!i||i.type.name!==`docOptional`?!1:(r&&n.setNodeAttribute(e,`enabled`,i.attrs.enabled===!1),!0)},addRepeatInstance:e=>({state:t,tr:n,dispatch:r})=>{let i=t.doc.nodeAt(e);if(!i||i.type.name!==`docRepeat`)return!1;let a=t.schema.nodeFromJSON(hE(i.toJSON()));return r&&(n.insert(e+i.nodeSize,a),n.setMeta(`repeatInstance`,!0)),!0},removeRepeatInstance:e=>({state:t,tr:n,dispatch:r})=>{let i=t.doc.nodeAt(e);if(!i||i.type.name!==`docRepeat`)return!1;let a=0;return t.doc.forEach(e=>{e.type.name===`docRepeat`&&e.attrs.repeatId===i.attrs.repeatId&&(a+=1)}),a<2?!1:(r&&(n.delete(e,e+i.nodeSize),n.setMeta(`repeatInstance`,!0)),!0)}}}}),yE=new N(`inputGuard`);function bE(e,t){let n=[];return e.descendants((e,r)=>{if(e.type.name!==`docInput`)return!0;if(e.attrs.kind===`snippet`||!rE(t,e.attrs.who))return!1;let i=r+1;return e.forEach((e,t)=>{e.type.name===`docFixed`&&(n.push([i,r+1+t]),i=r+1+t+e.nodeSize)}),n.push([i,r+e.nodeSize-1]),!1}),n}function xE(e){let t=e=>!e||typeof e!=`object`?e:e.type===`docField`?{...e,attrs:{...e.attrs,value:``}}:e.type===`docInput`?e.attrs?.kind===`snippet`?{...e,attrs:{...e.attrs,choice:null}}:{...e,content:(e.content??[]).filter(e=>e.type===`docFixed`).map(t)}:e.type===`docOptional`?{...e,attrs:{...e.attrs,enabled:!0},content:(e.content??[]).map(t)}:e.content?{...e,content:e.content.map(t)}:e;return t(e)}var SE=(e,t)=>JSON.stringify(e)===JSON.stringify(t);function CE(e){let t=!0;return e.descendants(e=>{if(!t||e.type.name!==`docInput`)return t;if(e.attrs.kind===`snippet`)return!1;let n=YT(e.attrs),r=KT[n],i=qT[n],a=e=>!t||e.type.name===`docFixed`?!1:!r.includes(e.type.name)||e.marks.some(e=>!i.includes(e.type.name))||n!==`full`&&e.attrs?.textAlign?(t=!1,!1):!0;return e.forEach(e=>{a(e)&&e.descendants(a)}),!1}),t}function wE(e,t){let n=[],r=[];e.forEach(e=>n.push(e.toJSON())),t.forEach(e=>r.push(e.toJSON()));let i=r.length-n.length;if(i!==1&&i!==-1)return!1;let a=i===1?r:n,o=i===1?n:r,s=o.length;for(let e=0;ee?.type===`docRepeat`&&e.attrs?.repeatId===l);if(i===-1)return o.some(e=>e.type===`docRepeat`&&e.attrs?.repeatId===l);if(!u.length)return!1;let d=new Set(o.filter(e=>e.type===`docRepeat`).map(e=>e.attrs.instanceId));if(!c.attrs.instanceId||d.has(c.attrs.instanceId))return!1;let f=e=>xE({...e,attrs:{...e.attrs,instanceId:null}});return SE(f(c),f(u[0]))}function TE(e,t,n){let r=t.nodeAt(e.pos);if(!r)return!1;let i=r.type.name;return i===`docField`?e.attr===`value`&&rE(n,r.attrs.who):i===`docInput`?r.attrs.kind===`snippet`&&e.attr===`choice`&&rE(n,r.attrs.who):i===`docOptional`&&e.attr===`enabled`}function EE(e,t,n){return typeof e.attr==`string`&&typeof e.pos==`number`?TE(e,t,n):typeof e.from!=`number`||typeof e.to!=`number`?!1:bE(t,n).some(([t,n])=>e.from>=t&&e.to<=n)}function DE(e){let t=!1;return e.descendants(e=>t?!1:e.type.name!==`docInput`||(t=!0,!1)),t}function OE(e){let t=[],n=(e,n)=>t.push(ds.node(e,n,{contenteditable:`false`,class:`efe-is-fixed`})),r=(e,t)=>{e.type.name===`docInput`?e.forEach((e,r)=>{e.type.name===`docFixed`&&n(t+1+r,t+1+r+e.nodeSize)}):e.isText||(DE(e)?e.forEach((e,n)=>r(e,t+1+n)):n(t,t+e.nodeSize))};return e.forEach((e,t)=>r(e,t)),L.create(e,t)}function kE(e){for(let t=e.depth;t>0;--t){let n=e.node(t);if(n.type.name===`docFixed`)return null;if(n.type.name===`docInput`)return n}return null}var AE=U.create({name:`inputGuard`,addOptions(){return{templateMode:!1,can:null,onBlocked:null}},addProseMirrorPlugins(){let e=this,t=()=>!e.options.templateMode,n=t=>(typeof e.options.onBlocked==`function`&&e.options.onBlocked(t),!1);return[new M({key:yE,filterTransaction(r,i){if(!t()||!r.docChanged)return!0;if(r.getMeta(`repeatInstance`)===!0)return wE(i.doc,r.doc)||n(`structure`);for(let t=0;t{if(e.isTextblock){let n=!1;return e.descendants(e=>{a.isInSet(e.marks)&&(n=!0)}),n&&o.removeMark(t+1,t+e.nodeSize-1,a),!1}return!0});return o.docChanged?(o.setMeta(yE,!0),o.setMeta(`addToHistory`,!1),o):null},props:{decorations(e){return t()?OE(e.doc):null},transformPasted(e,r){if(!t())return e;let i=kE(r.state.selection.$from);if(!i)return n(`locked-content`),m.empty;let a=ZT(e.content.toJSON()??[],YT(i.attrs)),o=c.fromJSON(r.state.schema,a);return m.maxOpen(o)},handleClick(e,n){if(!t())return!1;let r=e.state.schema.marks[GT],i=e.state.doc.resolve(n);if(!r||!kE(i))return!1;let a=null,o=null;return i.parent.forEach((e,t)=>{let s=i.start()+t,c=s+e.nodeSize;e.isText&&r.isInSet(e.marks)&&n>=s&&n<=c&&(a=s,o=c)}),a!==null&&(e.dispatch(e.state.tr.setSelection(A.create(e.state.doc,a,o))),!0)},handleDOMEvents:{mousedown(e,r){if(!t()||!(r.target instanceof Element))return!1;let i=r.target.closest(`.efe-is-fixed, .efe-input.is-locked`);return!i||r.target.closest(`.efe-field, .efe-input__body[contenteditable="true"], button, select, input`)||(i.classList.add(`is-nudged`),setTimeout(()=>i.classList.remove(`is-nudged`),900),n(`locked-content`)),!1}}}})]}}),jE=W.create({name:`pageBreak`,group:`block`,atom:!0,selectable:!0,parseHTML(){return[{tag:`div[data-efe-page-break]`}]},renderHTML({HTMLAttributes:e}){return[`div`,H({class:`efe-page-break`,"data-efe-page-break":``},e)]},addCommands(){return{insertPageBreak:()=>({commands:e})=>e.insertContent({type:this.name})}}}),ME={A4:{width:210,height:297}},NE={top:20,right:20,bottom:20,left:20},PE=(e,t,n,r)=>Number.isFinite(e)?Math.max(t,Math.min(n,Math.round(e))):r;function FE(e){let t=e&&typeof e==`object`?e:{},n=t.orientation===`landscape`?`landscape`:`portrait`,r=ME.A4,i={};for(let e of[`top`,`right`,`bottom`,`left`])i[e]=PE(t.margins?.[e],10,80,NE[e]);let a=t.firstPageDifferent===!0,o=a&&t.firstPageMargins?{top:PE(t.firstPageMargins.top,10,80,i.top),bottom:PE(t.firstPageMargins.bottom,10,80,i.bottom)}:{top:i.top,bottom:i.bottom};return{width:n===`landscape`?r.height:r.width,height:n===`landscape`?r.width:r.height,margins:i,first:o,headerDistance:PE(t.headerDistance,4,30,8),footerDistance:PE(t.footerDistance,4,30,7),firstPageDifferent:a,orientation:n}}function IE(e,t){let n=t===1?e.first.top:e.margins.top,r=t===1?e.first.bottom:e.margins.bottom;return e.height-n-r}function LE(e,t,n,r){let i=e?.[t]??{};return n===1&&r&&i.first?i.first:i.rest??null}function RE(e,t){e.style.setProperty(`--efe-page-width`,`${t.width}mm`),e.style.setProperty(`--efe-page-height`,`${t.height}mm`),e.style.minHeight=`${t.height}mm`,e.style.paddingTop=`${t.first.top}mm`,e.style.paddingRight=`${t.margins.right}mm`,e.style.paddingBottom=`${t.margins.bottom}mm`,e.style.paddingLeft=`${t.margins.left}mm`,e.dataset.efeOrientation=t.orientation,e.classList.add(`efe-page--layout`)}function zE(e,t){if(e===`date`&&/^\d{4}-\d{2}-\d{2}$/.test(t)){let[e,n,r]=t.split(`-`);return`${r}.${n}.${e}`}return e===`number`&&/^-?\d+(\.\d+)?$/.test(t)?t.replace(`.`,`,`):t}function BE(e){let t={};return e.descendants(e=>e.type.name!==`docRepeat`&&(e.type.name===`docField`&&e.attrs.fieldId&&(t[e.attrs.fieldId]=zE(e.attrs.kind,e.attrs.value??``)),!0)),t}function VE(e,t,n){let r=document.createElement(`div`);r.className=`efe-band-replica__content`;let i;try{i=ae.fromJSON(e,t)}catch{return r}r.append(Je.fromSchema(e).serializeFragment(i.content));for(let e of r.querySelectorAll(`[data-efe-variable]`)){let t=e.getAttribute(`data-efe-variable`)??``,r;if(t===`seite`)r=String(n.page);else if(t===`seiten`)r=String(n.pages);else if(t.startsWith(`feld.`))r=n.fields?.[t.slice(5)]??``;else{let e=n.variables,i=e instanceof Map?e.get(t):e?.[t];r=i?.value||i?.label||t}e.textContent=r}for(let e of r.querySelectorAll(`.efe-field`))e.textContent||(e.textContent=e.getAttribute(`data-efe-label`)??``,e.classList.add(`efe-field--empty`));return r}function HE(e,t,{distance:n,margin:r,left:i,right:a}){let o=document.createElement(`div`);return o.className=`efe-band-replica efe-band-replica--${e}`,o.setAttribute(`contenteditable`,`false`),o.setAttribute(`aria-hidden`,`true`),o.style.setProperty(`--efe-band-distance`,`${n}mm`),o.style.setProperty(`--efe-band-height`,`${Math.max(1,r-n-2)}mm`),o.style.left=`${i}mm`,o.style.right=`${a}mm`,o.append(t),o}var UE=new N(`pageMarkers`);function WE({contentHeightPx:e,pxPerMm:t,breakOffsetsPx:n=[],gapPx:r=0,usableMm:i=257,gapPxForPage:a=null}){if(!(e>0)||!(t>0))return[];let o=e=>t*(typeof i==`function`?i(e):i),s=e=>typeof a==`function`?a(e):r;if(!(o(1)>0))return[];let c=[0,...[...new Set(n)].filter(t=>t>0&&te-t),e],l=[],u=1,d=0;for(let e=0;e0)?null:r.width/t}function qE(e,t){let n=[],r=e.dom.getBoundingClientRect(),i=Array.from(e.dom.querySelectorAll(`.efe-page-gap`)).map(e=>{let n=e.getBoundingClientRect();return{top:n.top,height:n.height||t}});return e.state.doc.descendants((t,a)=>{if(t.type.name!==`pageBreak`)return;let o=e.nodeDOM(a);if(o&&typeof o.getBoundingClientRect==`function`){let e=o.getBoundingClientRect(),t=i.filter(t=>t.tope+t.height,0);n.push(e.top-r.top-t)}}),n}function JE(e,t=null){let n=document.createElement(`div`);n.className=`efe-page-gap`,n.setAttribute(`contenteditable`,`false`),n.setAttribute(`data-efe-page`,String(e)),n.title=`Geschätzte Seitenaufteilung. Verbindlich ist die PDF-Vorschau.`;let r=document.createElement(`span`);if(r.className=`efe-page-gap__nummer`,r.textContent=`≈ ${e-1}`,!t)return n.style.height=`12mm`,n.appendChild(r),n;n.classList.add(`efe-page-gap--bands`),n.style.height=`${t.bottomMm+12+t.topMm}mm`;let i=document.createElement(`div`);i.className=`efe-page-gap__margin efe-page-gap__margin--foot`,i.style.height=`${t.bottomMm}mm`,t.footer&&i.append(t.footer),i.append(r);let a=document.createElement(`div`);a.className=`efe-page-gap__space`,a.style.height=`12mm`;let o=document.createElement(`div`);return o.className=`efe-page-gap__margin efe-page-gap__margin--head`,o.style.height=`${t.topMm}mm`,t.header&&o.append(t.header),n.append(i,a,o),n}function YE(e,t){let n=e.resolve(t),r=t;for(let e=n.depth;e>0;--e)n.node(e).type.name===`table`&&(r=n.before(e));return r}function XE(e){let t=0;for(let n=0;n>>0).toString(36)}function ZE(e,t,n,r,i,a){let o=LE(t.bands,r,i,n.firstPageDifferent);if(!o)return null;let s=VE(e.state.schema,o,{page:i,pages:a,variables:t.variables??{},fields:BE(e.state.doc)}),c=r===`header`,l=c?i===1?n.first.top:n.margins.top:i===1?n.first.bottom:n.margins.bottom;return HE(c?`head`:`foot`,s,{distance:c?n.headerDistance:n.footerDistance,margin:l,left:n.margins.left,right:n.margins.right})}var QE=new WeakMap;function $E(e,t={}){let n=t.layout?FE(t.layout):null,r=KE(e.dom,n?n.width:210);if(!r)return QE.set(e,1),L.empty;let i=e=>n?(e-1==1?n.first.bottom:n.margins.bottom)+12+n.margins.top:12,a=r*12,o=Array.from(e.dom.querySelectorAll(`.efe-page-gap`)).reduce((e,t)=>e+t.getBoundingClientRect().height,0),s=WE({contentHeightPx:e.dom.getBoundingClientRect().height-o,pxPerMm:r,breakOffsetsPx:qE(e,a),gapPx:a,...n?{usableMm:e=>IE(n,e),gapPxForPage:e=>r*i(e)}:{}}),c=s.length+1;if(QE.set(e,c),s.length===0)return L.empty;let l=e.dom.getBoundingClientRect(),u=[],d=n&&t.bands?XE(JSON.stringify([t.bands,BE(e.state.doc),c])):``;for(let{offsetPx:r,page:i}of s){let a=null;try{a=e.posAtCoords({left:l.left+l.width/2,top:l.top+r})}catch{a=null}if(!a)continue;let o;try{o=YE(e.state.doc,a.pos)}catch{continue}let s=n?()=>JE(i,{bottomMm:i-1==1?n.first.bottom:n.margins.bottom,topMm:n.margins.top,footer:ZE(e,t,n,`footer`,i-1,c),header:ZE(e,t,n,`header`,i,c)}):()=>JE(i);u.push(ds.widget(o,s,{key:`efe-page-gap-${i}${d?`-${d}`:``}`,side:0}))}return L.create(e.state.doc,u)}function eD(e){let t=typeof e.dom.closest==`function`?e.dom.closest(`.efe-page`):null;if(!t||typeof t.getBoundingClientRect!=`function`)return;let n=t.getBoundingClientRect(),r=n.width>0&&t.offsetWidth>0?n.width/t.offsetWidth:1;for(let t of e.dom.querySelectorAll(`.efe-page-gap`)){let e=Number(t.dataset.efeShift||0),i=(n.left-t.getBoundingClientRect().left)/r;if(Math.abs(i)>.5){let n=e+i;t.dataset.efeShift=String(n),t.style.translate=`${n}px 0`}}}function tD(e,t={}){let n=typeof e.dom.closest==`function`?e.dom.closest(`.efe-page`):null;if(!n||!t.layout)return;let r=FE(t.layout),i=QE.get(e)??1;if(n.querySelectorAll(`:scope > .efe-band-replica`).forEach(e=>e.remove()),t.replicas!==!1){let a=ZE(e,t,r,`header`,1,i),o=ZE(e,t,r,`footer`,i,i);a&&n.append(a),o&&n.append(o)}n.style.minHeight=`${i*r.height+(i-1)*12}mm`,n.dataset.efePages=String(i)}var nD=new WeakMap;function rD(e){let t=e?.view?nD.get(e.view):null;t&&t()}var iD=U.create({name:`pageMarkers`,addOptions(){return{layout:null,bands:null,variables:null,replicas:!0}},addProseMirrorPlugins(){let e=this.options;return[new M({key:UE,state:{init:()=>L.empty,apply(e,t){return e.getMeta(UE)||(e.docChanged?t.map(e.mapping,e.doc):t)}},props:{decorations(e){return UE.getState(e)??L.empty}},view(t){let n=null,r=null,i=()=>{if(n=null,t.isDestroyed)return;let r=$E(t,e);tD(t,e);let i=t.state.tr.setMeta(UE,r).setMeta(`addToHistory`,!1);t.dispatch(i),eD(t)},a=()=>{n!==null||t.isDestroyed||(n=typeof requestAnimationFrame==`function`?requestAnimationFrame(i):setTimeout(i,50))};return nD.set(t,a),typeof ResizeObserver<`u`?(r=new ResizeObserver(()=>a()),r.observe(t.dom)):typeof window<`u`&&typeof window.addEventListener==`function`&&window.addEventListener(`resize`,a),a(),{update(e,t){e.state.doc!==t.doc&&a()},destroy(){nD.delete(t),n!==null&&(typeof cancelAnimationFrame==`function`?cancelAnimationFrame(n):clearTimeout(n),n=null),r?r.disconnect():typeof window<`u`&&typeof window.removeEventListener==`function`&&window.removeEventListener(`resize`,a)}}}})]}}),aD=e=>e===`seite`||e===`seiten`||e.startsWith(`feld.`);function oD(e){let t=``,n=e=>e.type.name!==`docFixed`&&(e.isText&&!e.marks.some(e=>e.type.name===`efePrompt`)&&(t+=e.text),!0);return e.forEach(e=>{n(e)&&e.descendants(n),t+=` `}),t.replace(/\s+/g,` `).trim()}function sD(e){if(e.extensionManager.extensions.find(e=>e.name===`sectionLockGuard`||e.name===`inputGuard`)?.options?.templateMode)return[];let t=e.extensionManager.extensions.find(e=>e.name===`docVariable`),n=t?.options?.variables??{},r=t?.options?.display??`values`,i=[],a=new Set,o=``;return e.state.doc.descendants((e,t)=>{if(e.type.name===`docSection`)return o=e.attrs.title?String(e.attrs.title):``,!0;if(e.type.name===`docOptional`)return e.attrs.enabled!==!1;if(e.type.name===`docRepeat`)return o=e.attrs.label?String(e.attrs.label):``,!0;if(e.type.name===`docInput`){let n=e.attrs.label??``,r=e.attrs.inputId??null;if(e.attrs.kind===`snippet`)return e.attrs.required&&!e.attrs.choice&&i.push({kind:`snippet`,state:`empty`,label:n,section:o,pos:t,inputId:r}),!1;let a=oD(e),s=Number(e.attrs.minLength)||0;return e.attrs.required&&a===``?i.push({kind:`input`,state:`empty`,label:n,section:o,pos:t,inputId:r}):s>0&&a!==``&&a.lengthn.classList.remove(`is-flagged`),1600),t.kind===`field`){let e=n.querySelector(`.efe-field__input`);e instanceof HTMLElement&&e.focus({preventScroll:!0})}else e.isEditable&&e.commands.setNodeSelection(t.pos)}}var lD=10,uD=80;function dD(e,t){e.classList.add(`efe-ruler`);function n(){if(e.replaceChildren(),e.hidden=!t.visible(),e.hidden)return;let n=t.geometry();e.style.width=`${n.width}mm`;let r=document.createElement(`div`);r.className=`efe-ruler__off`,r.style.left=`0`,r.style.width=`${n.margins.left}mm`;let i=document.createElement(`div`);i.className=`efe-ruler__off`,i.style.right=`0`,i.style.width=`${n.margins.right}mm`;let a=document.createElement(`div`);a.className=`efe-ruler__ticks`,e.append(r,i,a);for(let t=10;t{let n=e.shiftKey?5:1,i=0;if(e.key===`ArrowRight`&&(i=n),e.key===`ArrowLeft`&&(i=-n),!i)return;e.preventDefault();let a=t.geometry().margins[r],o=fD(a+(r===`left`?i:-i));t.onMargin(r,o)}),i.addEventListener(`pointerdown`,n=>{n.preventDefault(),i.setPointerCapture?.(n.pointerId),i.classList.add(`is-dragging`);let a=document.createElement(`div`);a.className=`efe-ruler__tip`,e.append(a);let o=t.geometry().width,s=n=>{let i=e.getBoundingClientRect();if(!(i.width>0))return;let s=Math.round((n.clientX-i.left)/i.width*o);r===`right`&&(s=o-s),s=fD(s),a.textContent=`${r===`left`?`Links`:`Rechts`} ${s} mm`,a.style.left=r===`left`?`${s}mm`:`${o-s}mm`,t.onMargin(r,s)},c=()=>{i.removeEventListener(`pointermove`,s),i.classList.remove(`is-dragging`),a.remove()};i.addEventListener(`pointermove`,s),i.addEventListener(`pointerup`,c,{once:!0}),i.addEventListener(`pointercancel`,c,{once:!0})}),e.append(i)}}function r(){if(e.hidden||!e.childElementCount){n();return}let r=t.geometry();if(e.style.width!==`${r.width}mm`){n();return}let[i,a]=e.querySelectorAll(`.efe-ruler__off`);i.style.width=`${r.margins.left}mm`,a.style.width=`${r.margins.right}mm`;for(let t of[`left`,`right`]){let n=e.querySelector(`.efe-ruler__handle--${t}`);n.style.left=t===`left`?`${r.margins.left}mm`:`${r.width-r.margins.right}mm`,n.setAttribute(`aria-valuenow`,String(r.margins[t])),n.setAttribute(`aria-valuetext`,`${r.margins[t]} mm`)}}return{render:n,update:r,destroy(){e.replaceChildren()}}}function fD(e){return Math.max(lD,Math.min(uD,e))}var pD=[[`line`,`Zeile`],[`choice`,`Auswahl`],[`date`,`Datum`],[`number`,`Zahl`]],mD={plain:`Keine`,basic:`Einfach`,full:`Voll`},hD={plain:`Nur Text und Absätze.`,basic:`Fett, kursiv, unterstrichen und Listen.`,full:`Auch Überschriften, Tabellen, Ausrichtung.`};function Q(e,t={},...n){let r=document.createElement(e);for(let[e,n]of Object.entries(t))n!=null&&n!==!1&&(e===`class`?r.className=n:e===`text`?r.textContent=n:e.startsWith(`on`)?r.addEventListener(e.slice(2),n):e in r&&e!==`list`?r[e]=n:r.setAttribute(e,n===!0?``:n));return r.append(...n.flat().filter(e=>e!=null&&e!==!1)),r}var gD=0,_D=e=>`efe-prop-${e}-${++gD}`;function $(e,t,n){let r=t.id||_D(`x`);return t.id=r,Q(`div`,{class:`efe-prop`},Q(`label`,{class:`efe-prop__label`,for:r,text:e}),t,n?Q(`p`,{class:`efe-prop__hint`,text:n}):null)}function vD(e,t,n={}){return Q(`input`,{type:`text`,class:`efe-prop__input`,value:e??``,oninput:e=>t(e.target.value),...n})}function yD(e,t,n={}){return Q(`input`,{type:`number`,class:`efe-prop__input`,value:e??``,onchange:e=>{let n=e.target.value.trim();t(n===``?null:Number(n))},...n})}function bD(e,t,n){let r=Q(`select`,{class:`efe-prop__input`,onchange:e=>n(e.target.value)});for(let[n,i]of t)r.append(Q(`option`,{value:n,text:i,selected:n===e}));return r}function xD(e,t,n){let r=_D(`c`);return Q(`label`,{class:`efe-prop__check`,for:r},Q(`input`,{type:`checkbox`,id:r,checked:t,onchange:e=>n(e.target.checked)}),Q(`span`,{text:e}))}function SD(e,t,n){let r=Q(`div`,{class:`efe-prop__seg`,role:`group`});for(let[i,a]of t)r.append(Q(`button`,{type:`button`,text:a,"aria-pressed":String(i===e),onclick:()=>n(i)}));return r}function CD(e,t,n=``){return Q(`button`,{type:`button`,class:`efe-prop__btn ${n}`.trim(),text:e,onclick:t})}function wD(e,t){return Q(`div`,{class:`efe-prop__head`},Q(`p`,{class:`efe-prop__kicker`,text:e}),Q(`h2`,{class:`efe-prop__title`,text:t}))}function TD(e){let t=e.state.selection;if(t instanceof j)return{type:t.node.type.name,node:t.node,pos:t.from};let n=t.$from;for(let e=n.depth;e>0;--e){let t=n.node(e);if([`docFixed`,`docInput`,`docAside`,`docRepeat`,`docOptional`].includes(t.type.name))return{type:t.type.name,node:t,pos:n.before(e)}}return{type:`none`,node:null,pos:null}}function ED(e,t,n){let r=e.state.doc.nodeAt(t);r&&e.view.dispatch(e.state.tr.setNodeMarkup(t,void 0,{...r.attrs,...n}))}function DD(e,t,n){let r=e.state.doc.nodeAt(t);r&&e.view.dispatch(e.state.tr.replaceWith(t,t+r.nodeSize,n))}function OD(e,t,n){let{schema:r}=e.state;if(n.attrs.kind===`snippet`){let i=(n.attrs.snippets??[])[0],a=Array.isArray(i?.content)&&i.content.length?i.content:[{type:`paragraph`}];DD(e,t,c.fromJSON(r,a));return}let i=[];n.forEach(e=>{e.type.name===`docFixed`?e.forEach(e=>i.push(e)):i.push(e)}),DD(e,t,c.fromArray(i.length?i:[r.nodes.paragraph.create()]))}function kD(e){let t=e=>(e??[]).map(e=>(e.content??[]).map(e=>e.text??``).join(``)).join(` `);return(e??[]).map(e=>`${e.name}: ${t(Array.isArray(e.content)?e.content:e.content?.content)}`).join(` -`)}function AD(e,t){return e.split(` -`).map(e=>e.trim()).filter(Boolean).map((e,n)=>{let r=e.indexOf(`:`),i=r>0?e.slice(0,r).trim():`Variante ${n+1}`,a=r>0?e.slice(r+1).trim():e;return{id:t?.[n]?.id??`v-${Date.now().toString(36)}-${n}`,name:i,content:[a?{type:`paragraph`,content:[{type:`text`,text:a}]}:{type:`paragraph`}]}})}function jD(e,t){let n=null,r=(...t)=>e.append(...t.filter(e=>e!=null&&e!==!1)),i=()=>[[``,`Alle, die das Dokument schreiben`],...(t.options.who??[]).map(e=>[e.key,`Nur mit Recht „${e.label}“`])];function a(r=!1){let i=t.focusedEditor();if(!i)return;let a=t.mode()===`template`?TD(i):{type:t.mode(),pos:null},o=`${t.mode()}|${t.focused()}|${a.type}|${a.pos}`;if(r||o!==n||!e.contains(document.activeElement)){if(n=o,e.replaceChildren(),t.mode()===`write`)return x();if(t.mode()===`preview`)return S();switch(a.type){case`docField`:return f(i,a);case`docInput`:return a.node.attrs.kind===`snippet`?m(i,a):p(i,a);case`docFixed`:return h(i,a);case`docAside`:return g(i,a);case`docRepeat`:return _(i,a,`Wiederholblock`,`Der Verfasser kann weitere Einträge anlegen.`);case`docOptional`:return _(i,a,`Optionaler Block`,`Der Verfasser schaltet den Block ein oder aus.`);case`docVariable`:return v(a);case`image`:case`imageBlock`:return y();default:return t.focused()===`body`?s():d()}}}let o=()=>a(!0);function s(){let e=t.pkg(),n=e.layout,i=FE(n),a={...n.margins},s=a.left===25&&a.right===20?`din`:a.left===20&&a.right===20?`standard`:`eigen`,c=(e,n)=>$(n,yD(i.margins[e],n=>{n!==null&&t.setLayout({margins:{...t.pkg().layout.margins,[e]:n}})},{min:10,max:80}));if(r(wD(`Seite`,`Format und Ränder`),$(`Format`,SD(n.orientation??`portrait`,[[`portrait`,`A4 hoch`],[`landscape`,`A4 quer`]],e=>{t.setLayout({orientation:e}),o()})),$(`Vorgabe`,bD(s,[[`standard`,`Standard · 20 mm ringsum`],[`din`,`DIN 5008 · links 25, rechts 20 mm`],[`eigen`,`Eigene Ränder`]],e=>{e!==`eigen`&&(t.setLayout({margins:{...t.pkg().layout.margins,left:e===`din`?25:20,right:20}}),o())})),Q(`div`,{class:`efe-prop__grid`},c(`top`,`Oben`),c(`right`,`Rechts`),c(`bottom`,`Unten`),c(`left`,`Links`)),Q(`p`,{class:`efe-prop__hint`,text:`Werte in mm. Links und rechts auch am Lineal. Editor und PDF nutzen dieselben Werte.`}),xD(`Erste Seite anders (eigene Kopfzeile, eigene Ränder)`,n.firstPageDifferent===!0,e=>{let n=t.getPackage();n.layout.firstPageDifferent=e,e&&(n.layout.firstPageMargins=n.layout.firstPageMargins??{top:n.layout.margins.top,bottom:n.layout.margins.bottom},n.header.first=n.header.first??JSON.parse(JSON.stringify(n.header.rest??{type:`doc`,content:[{type:`paragraph`}]}))),t.rebuildWith(n),o()})),n.firstPageDifferent){let n=i.first;r(Q(`div`,{class:`efe-prop__grid efe-prop__grid--2`},$(`Seite 1 oben`,yD(n.top,e=>e!==null&&t.setLayout({firstPageMargins:{...n,top:e}}),{min:10,max:80})),$(`Seite 1 unten`,yD(n.bottom,e=>e!==null&&t.setLayout({firstPageMargins:{...n,bottom:e}}),{min:10,max:80}))),xD(`Eigene Fußzeile auf Seite 1`,!!e.footer.first,e=>{let n=t.getPackage();n.footer.first=e?JSON.parse(JSON.stringify(n.footer.rest??{type:`doc`,content:[{type:`paragraph`}]})):null,t.rebuildWith(n),o()}))}r(Q(`div`,{class:`efe-prop__grid efe-prop__grid--2`},$(`Kopfzeile ab Blattrand`,yD(i.headerDistance,e=>e!==null&&t.setLayout({headerDistance:e}),{min:4,max:30})),$(`Fußzeile ab Blattrand`,yD(i.footerDistance,e=>e!==null&&t.setLayout({footerDistance:e}),{min:4,max:30})))),l(),r(Q(`p`,{class:`efe-prop__note`,text:`Der Rand ist kein Schreibbereich. Text, Tabellen und Randkästen bleiben im Satzspiegel, in den Rand kommen nur Kopf- und Fußzeile.`}),u())}function l(){let e=t.options.letterheads??[];if(!e.length)return;let n=t.pkg().layout.letterheadId??``;r($(`Briefbogen`,bD(String(n),[[``,`Keiner, eigene Kopf- und Fußzeile`],...e.map(e=>[String(e.id),e.name])],n=>{let r=t.getPackage();if(!n){r.layout.letterheadId=null,t.rebuildWith(r),o();return}let i=e.find(e=>String(e.id)===n);i&&(r.layout={...r.layout,...i.layout??{},letterheadId:i.id},r.header={first:i.header?.first??null,rest:i.header?.rest??null},r.footer={first:i.footer?.first??null,rest:i.footer?.rest??null},t.rebuildWith(r),o())}),n?`Kopf- und Fußzeile kommen aus dem Briefbogen. Eine Änderung dort gilt für alle Vorlagen, die ihn nutzen.`:null))}function u(){let e=0,n=0,r=0,i=0;for(let a of Object.values(t.editors()))a?.state.doc.descendants(t=>(t.type.name===`docField`&&(e+=1,t.attrs.required&&(r+=1)),t.type.name===`docInput`&&(n+=1,t.attrs.required&&(r+=1)),t.type.name===`docFixed`&&(i+=1),!0));return Q(`div`,{class:`efe-prop__summary`},Q(`p`,{class:`efe-prop__kicker`,text:`In dieser Vorlage`}),Q(`p`,{text:`${e+n} Eingabebereiche, davon ${r} Pflicht · ${i} feste Teile im freien Text`}))}function d(){let e=t.focused(),[n,i]=e.split(`.`),a=t.overflow()[n],s=n===`header`;if(r(wD(s?`Kopfzeile`:`Fußzeile`,t.regionLabel(e)+(i===`rest`&&t.pkg().layout.firstPageDifferent?` der Folgeseiten`:``)),Q(`p`,{class:`efe-prop__hint`,text:`Liegt im ${s?`oberen`:`unteren`} Rand und steht auf ${i===`first`?`Seite 1`:t.pkg().layout.firstPageDifferent?`jeder Seite ab Seite 2`:`jeder Seite`}. Für den Verfasser fest, außer den Eingabebereichen darin.`}),Q(`p`,{class:`efe-prop__hint`,text:`Seitenzahlen über „Variable ▾“: Seite und Seitenzahl. Werte aus Feldern des Textkörpers über feld..`})),a){let e=s?`top`:`bottom`;r(Q(`div`,{class:`efe-prop__note efe-prop__note--warn`},Q(`p`,{text:`Die ${s?`Kopfzeile ist höher als der obere`:`Fußzeile ist höher als der untere`} Rand. Im PDF wird sie abgeschnitten.`}),CD(`${s?`Oberen`:`Unteren`} Rand auf ${a.neededMm} mm setzen`,()=>{let n=t.pkg().layout;if(a.slot===`first`){let r=FE(n).first;t.setLayout({firstPageMargins:{...r,[e]:Math.min(80,a.neededMm)}})}else t.setLayout({margins:{...n.margins,[e]:Math.min(80,a.neededMm)}});o()},`efe-prop__btn--primary`)))}t.pkg().layout.letterheadId?r(CD(`Vom Briefbogen lösen und selbst bearbeiten`,()=>{let e=t.getPackage();e.layout.letterheadId=null,t.rebuildWith(e),o()})):r(CD(`${t.regionLabel(e)} entfernen`,()=>{let e=t.getPackage();e[n][i]=null,t.rebuildWith(e),o()},`efe-prop__btn--danger`))}function f(e,n){let a=n.node.attrs,s=a.kind??(Array.isArray(a.options)&&a.options.length?`choice`:`line`),c=t=>ED(e,n.pos,t);if(r(wD(`Eingabebereich`,a.label||`Feld`),$(`Beschriftung`,vD(a.label,e=>c({label:e}))),$(`Art`,bD(s,pD,e=>{let t=e===`choice`&&!a.options?.length?{options:[{label:`Option A`},{label:`Option B`}]}:{};c({kind:e,value:``,...t}),o()}))),s===`line`&&r($(`Höchstlänge`,yD(a.maxLength,e=>c({maxLength:e&&e>0?e:null}),{min:1,max:500}),`Leer: 500 Zeichen`)),s===`choice`){let e=Object.keys(t.options.optionsSources??{});if(e.length&&r($(`Liste aus dem System`,bD(a.optionsSource??``,[[``,`Eigene Liste`],...e.map(e=>[e,t.options.optionsSourceLabels?.[e]??e])],e=>{c({optionsSource:e||null,...e?{options:t.options.optionsSources[e]}:{}}),o()}))),!a.optionsSource){let e=Q(`textarea`,{class:`efe-prop__input efe-prop__area`,rows:4,oninput:e=>c({options:e.target.value.split(` +`);return{...c,raw:u}}},addCommands(){return{insertTable:({rows:e=3,cols:t=3,withHeaderRow:n=!0}={})=>({tr:r,dispatch:i,editor:a})=>{let o=jb(a.schema,e,t,n);if(i){let e=r.selection.from+1;r.replaceSelectionWith(o).scrollIntoView().setSelection(A.near(r.doc.resolve(e)))}return!0},addColumnBefore:()=>({state:e,dispatch:t})=>oy(e,t),addColumnAfter:()=>({state:e,dispatch:t})=>sy(e,t),deleteColumn:()=>({state:e,dispatch:t})=>{let n=lu(e.selection.$from,e=>e.type.name===`table`);return ly(e,t&&(e=>{n&&Pb(e,n.pos),t(e)}))},addRowBefore:()=>({state:e,dispatch:t})=>fy(e,t),addRowAfter:()=>({state:e,dispatch:t})=>py(e,t),deleteRow:()=>({state:e,dispatch:t})=>{let n=lu(e.selection.$from,e=>e.type.name===`table`);return hy(e,t&&(e=>{n&&Pb(e,n.pos),t(e)}))},deleteTable:()=>({state:e,dispatch:t})=>Oy(e,t),mergeCells:()=>({state:e,dispatch:t})=>vy(e,t),splitCell:()=>({state:e,dispatch:t})=>yy(e,t),toggleHeaderColumn:()=>({state:e,dispatch:t})=>wy(`column`)(e,t),toggleHeaderRow:()=>({state:e,dispatch:t})=>wy(`row`)(e,t),toggleHeaderCell:()=>({state:e,dispatch:t})=>Ty(e,t),mergeOrSplit:()=>({state:e,dispatch:t})=>vy(e,t)?!0:yy(e,t),setCellAttribute:(e,t)=>({state:n,dispatch:r})=>xy(e,t)(n,r),goToNextCell:()=>({state:e,dispatch:t})=>Dy(1)(e,t),goToPreviousCell:()=>({state:e,dispatch:t})=>Dy(-1)(e,t),fixTables:()=>({state:e,dispatch:t})=>(t&&ny(e),!0),setCellSelection:e=>({tr:t,dispatch:n})=>{if(n){let n=J.create(t.doc,e.anchorCell,e.headCell);t.setSelection(n)}return!0}}},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.goToNextCell()?!0:this.editor.can().addRowAfter()?this.editor.chain().addRowAfter().goToNextCell().run():!1,"Shift-Tab":()=>this.editor.commands.goToPreviousCell(),Backspace:Nb,"Mod-Backspace":Nb,Delete:Nb,"Mod-Delete":Nb}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[Zy({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:null,lastColumnResizable:this.options.lastColumnResizable})]:[],db({allowTableNodeSelection:this.options.allowTableNodeSelection}),Wb()]},addNodeView(){let e=this.options.View;return e?({node:t,view:n,HTMLAttributes:r})=>{let i=B(this.options.HTMLAttributes,r);return new e(t,this.options.cellMinWidth,n,i)}:null},extendNodeSchema(e){return{tableRole:z(R(e,`tableRole`,{name:e.name,options:e.options,storage:e.storage}))}}});V.create({name:`tableKit`,addExtensions(){let e=[];return this.options.table!==!1&&e.push(Gb.configure(this.options.table)),this.options.tableCell!==!1&&e.push(Sb.configure(this.options.tableCell)),this.options.tableHeader!==!1&&e.push(Cb.configure(this.options.tableHeader)),this.options.tableRow!==!1&&e.push(wb.configure(this.options.tableRow)),e}});var Kb=V.create({name:`textAlign`,addOptions(){return{types:[],alignments:[`left`,`center`,`right`,`justify`],defaultAlignment:null}},addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:e=>{let t=e.style.textAlign;return this.options.alignments.includes(t)?t:this.options.defaultAlignment},renderHTML:e=>!Ef(e.textAlign)||!this.options.alignments.includes(e.textAlign)?{}:{style:`text-align: ${e.textAlign}`}}}}]},addCommands(){return{setTextAlign:e=>({commands:t})=>this.options.alignments.includes(e)?this.options.types.map(n=>t.updateAttributes(n,{textAlign:e})).some(e=>e):!1,unsetTextAlign:()=>({commands:e})=>this.options.types.map(t=>e.resetAttributes(t,`textAlign`)).some(e=>e),toggleTextAlign:e=>({editor:t,commands:n})=>this.options.alignments.includes(e)?t.isActive({textAlign:e})?n.unsetTextAlign():n.setTextAlign(e):!1}},addKeyboardShortcuts(){return{"Mod-Shift-l":()=>this.editor.commands.setTextAlign(`left`),"Mod-Shift-e":()=>this.editor.commands.setTextAlign(`center`),"Mod-Shift-r":()=>this.editor.commands.setTextAlign(`right`),"Mod-Shift-j":()=>this.editor.commands.setTextAlign(`justify`)}}}),qb=bv,Jb=20,Yb=(e,t=0)=>{let n=[];return!e.children.length||t>Jb||Array.from(e.children).forEach(e=>{e.tagName===`SPAN`?n.push(e):e.children.length&&n.push(...Yb(e,t+1))}),n},Xb=e=>{if(!e.children.length)return;let t=Yb(e);t&&t.forEach(e=>{var t;let n=e.getAttribute(`style`),r=(t=e.parentElement)==null||(t=t.closest(`span`))==null?void 0:t.getAttribute(`style`);e.setAttribute(`style`,`${r};${n}`)})},Zb=Wf.create({name:`textStyle`,priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!0}},parseHTML(){return[{tag:`span`,consuming:!1,getAttrs:e=>e.hasAttribute(`style`)?(this.options.mergeNestedSpanStyles&&Xb(e),{}):!1}]},renderHTML({HTMLAttributes:e}){return[`span`,B(this.options.HTMLAttributes,e),0]},addCommands(){return{toggleTextStyle:e=>({commands:t})=>t.toggleMark(this.name,e),removeEmptyTextStyle:()=>({tr:e})=>{let{selection:t}=e;return e.doc.nodesBetween(t.from,t.to,(t,n)=>{if(!t.isInline)return!0;t.marks.filter(e=>e.type===this.type).some(e=>Object.values(e.attrs).some(e=>!!e))||e.removeMark(n,n+t.nodeSize,this.type)}),!0}}}}),Qb=V.create({name:`backgroundColor`,addOptions(){return{types:[`textStyle`]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{backgroundColor:{default:null,parseHTML:e=>(Sf(e,`background-color`)??e.style.backgroundColor)?.replace(/['"]+/g,``),renderHTML:e=>Ef(e.backgroundColor)?{style:`background-color: ${e.backgroundColor}`}:{}}}}]},addCommands(){return{setBackgroundColor:e=>({chain:t})=>t().setMark(`textStyle`,{backgroundColor:e}).run(),unsetBackgroundColor:()=>({chain:e})=>e().setMark(`textStyle`,{backgroundColor:null}).removeEmptyTextStyle().run()}}}),$b=V.create({name:`color`,addOptions(){return{types:[`textStyle`]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{color:{default:null,parseHTML:e=>(Sf(e,`color`)??e.style.color)?.replace(/['"]+/g,``),renderHTML:e=>Ef(e.color)?{style:`color: ${e.color}`}:{}}}}]},addCommands(){return{setColor:e=>({chain:t})=>t().setMark(`textStyle`,{color:e}).run(),unsetColor:()=>({chain:e})=>e().setMark(`textStyle`,{color:null}).removeEmptyTextStyle().run()}}}),ex=V.create({name:`fontFamily`,addOptions(){return{types:[`textStyle`]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontFamily:{default:null,parseHTML:e=>Sf(e,`font-family`)??e.style.fontFamily,renderHTML:e=>Ef(e.fontFamily)?{style:`font-family: ${e.fontFamily}`}:{}}}}]},addCommands(){return{setFontFamily:e=>({chain:t})=>t().setMark(`textStyle`,{fontFamily:e}).run(),unsetFontFamily:()=>({chain:e})=>e().setMark(`textStyle`,{fontFamily:null}).removeEmptyTextStyle().run()}}}),tx=V.create({name:`fontSize`,addOptions(){return{types:[`textStyle`]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontSize:{default:null,parseHTML:e=>Sf(e,`font-size`)??e.style.fontSize,renderHTML:e=>Ef(e.fontSize)?{style:`font-size: ${e.fontSize}`}:{}}}}]},addCommands(){return{setFontSize:e=>({chain:t})=>t().setMark(`textStyle`,{fontSize:e}).run(),unsetFontSize:()=>({chain:e})=>e().setMark(`textStyle`,{fontSize:null}).removeEmptyTextStyle().run()}}}),nx=V.create({name:`lineHeight`,addOptions(){return{types:[`textStyle`]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{lineHeight:{default:null,parseHTML:e=>Sf(e,`line-height`)??e.style.lineHeight,renderHTML:e=>Ef(e.lineHeight)?{style:`line-height: ${e.lineHeight}`}:{}}}}]},addCommands(){return{setLineHeight:e=>({chain:t})=>t().setMark(`textStyle`,{lineHeight:e}).run(),unsetLineHeight:()=>({chain:e})=>e().setMark(`textStyle`,{lineHeight:null}).removeEmptyTextStyle().run()}}});V.create({name:`textStyleKit`,addExtensions(){let e=[];return this.options.backgroundColor!==!1&&e.push(Qb.configure(this.options.backgroundColor)),this.options.color!==!1&&e.push($b.configure(this.options.color)),this.options.fontFamily!==!1&&e.push(ex.configure(this.options.fontFamily)),this.options.fontSize!==!1&&e.push(tx.configure(this.options.fontSize)),this.options.lineHeight!==!1&&e.push(nx.configure(this.options.lineHeight)),this.options.textStyle!==!1&&e.push(Zb.configure(this.options.textStyle)),e}});var rx={undo:`M7.5 4.5 4 8l3.5 3.5M4 8h8a4 4 0 0 1 0 8H9`,redo:`M12.5 4.5 16 8l-3.5 3.5M16 8H8a4 4 0 0 0 0 8h3`,bold:`M6 4h4.5a3 3 0 0 1 0 6H6zM6 10h5.5a3 3 0 0 1 0 6H6z`,italic:`M9 4h6M5 16h6M12.5 4l-5 12`,underline:`M6 4v5a4 4 0 0 0 8 0V4M5 17h10`,strike:`M3.5 10h13M13.5 6.2C13 4.9 11.7 4 10 4 8 4 6.6 5.2 6.6 6.8c0 .9.4 1.7 1.2 2.2M7 13.6c.5 1.4 1.8 2.4 3.4 2.4 2 0 3.4-1.1 3.4-2.8 0-.5-.1-.9-.3-1.2`,link:`M8.6 11.4a3.2 3.2 0 0 0 4.6 0l2.3-2.3a3.2 3.2 0 0 0-4.6-4.6l-.9.9M11.4 8.6a3.2 3.2 0 0 0-4.6 0l-2.3 2.3a3.2 3.2 0 0 0 4.6 4.6l.9-.9`,unlink:`M10.6 5.4l.3-.3a3.2 3.2 0 0 1 4.6 4.6l-1.2 1.2M9.4 14.6l-.3.3a3.2 3.2 0 0 1-4.6-4.6l1.2-1.2M3.5 3.5l13 13`,bulletList:`M8 5h9M8 10h9M8 15h9M3.4 5a.6.6 0 1 0 1.2 0 .6.6 0 1 0-1.2 0M3.4 10a.6.6 0 1 0 1.2 0 .6.6 0 1 0-1.2 0M3.4 15a.6.6 0 1 0 1.2 0 .6.6 0 1 0-1.2 0`,orderedList:`M8.5 5h8.5M8.5 10h8.5M8.5 15h8.5M3.5 3.5h1v3.5M3.3 7h2.4M3.3 12.6c0-.6.5-1.1 1.1-1.1s1.1.5 1.1 1c0 .9-2.2 1.8-2.2 2.9h2.3`,blockquote:`M3.5 10.5c0-3 1.2-4.6 3.5-5.2M3.5 10.5h3.2v4H3.5zM10.5 10.5c0-3 1.2-4.6 3.5-5.2M10.5 10.5h3.2v4h-3.2z`,alignLeft:`M3 5h14M3 10h9M3 15h12`,alignCenter:`M3 5h14M5.5 10h9M4 15h12`,alignRight:`M3 5h14M8 10h9M5 15h12`,alignJustify:`M3 5h14M3 10h14M3 15h14`,table:`M4.5 4h11A1.5 1.5 0 0 1 17 5.5v9a1.5 1.5 0 0 1-1.5 1.5h-11A1.5 1.5 0 0 1 3 14.5v-9A1.5 1.5 0 0 1 4.5 4zM3 8.5h14M3 12.3h14M8 8.5V16M12.5 8.5V16`,image:`M4.5 4h11A1.5 1.5 0 0 1 17 5.5v9a1.5 1.5 0 0 1-1.5 1.5h-11A1.5 1.5 0 0 1 3 14.5v-9A1.5 1.5 0 0 1 4.5 4zM3.5 14l4-4 3 3 2-2 4 4M14 7.6a1.2 1.2 0 1 1-2.4 0 1.2 1.2 0 0 1 2.4 0z`,horizontalRule:`M2.5 10h15M5 5.5h10M5 14.5h10`,pageBreak:`M5 3v4h10V3M5 17v-4h10v4M2.5 10h2M6.5 10h2M11.5 10h2M15.5 10h2`,removeFormat:`M4.5 4.5h9M9 4.5 7 15.5M12.5 12.5l4 4M16.5 12.5l-4 4`,chevron:`M6 8l4 4 4-4`,check:`M4.5 10.5l3.5 3.5 7.5-8`,close:`M5.5 5.5l9 9M14.5 5.5l-9 9`,lock:`M6 9V6.5a4 4 0 0 1 8 0V9M5.5 9h9A1.5 1.5 0 0 1 16 10.5v5a1.5 1.5 0 0 1-1.5 1.5h-9A1.5 1.5 0 0 1 4 15.5v-5A1.5 1.5 0 0 1 5.5 9z`,plus:`M10 4.5v11M4.5 10h11`,trash:`M4.5 6h11M8 6V4.5h4V6M6 6l.7 9.6a1.5 1.5 0 0 0 1.5 1.4h3.6a1.5 1.5 0 0 0 1.5-1.4L14 6`,eye:`M2.5 10s2.8-5 7.5-5 7.5 5 7.5 5-2.8 5-7.5 5-7.5-5-7.5-5zM12.2 10a2.2 2.2 0 1 1-4.4 0 2.2 2.2 0 0 1 4.4 0z`,callout:`M10 3a7 7 0 1 1 0 14 7 7 0 0 1 0-14zM10 9v4.5M10 6.6v.2`,video:`M4.5 4.5h11A1.5 1.5 0 0 1 17 6v8a1.5 1.5 0 0 1-1.5 1.5h-11A1.5 1.5 0 0 1 3 14V6a1.5 1.5 0 0 1 1.5-1.5zM8.5 7.5v5l4-2.5z`,emoji:`M10 3a7 7 0 1 1 0 14 7 7 0 0 1 0-14zM7.2 11.8c.7.9 1.7 1.4 2.8 1.4s2.1-.5 2.8-1.4M7.5 8.2v.3M12.5 8.2v.3`,clock:`M10 3a7 7 0 1 1 0 14 7 7 0 0 1 0-14zM10 6.5V10l2.5 1.5`},ix={undo:`rotate-left`,redo:`rotate-right`,bold:`bold`,italic:`italic`,underline:`underline`,strike:`strikethrough`,link:`link`,unlink:`link-slash`,bulletList:`list-ul`,orderedList:`list-ol`,blockquote:`quote-left`,alignLeft:`align-left`,alignCenter:`align-center`,alignRight:`align-right`,alignJustify:`align-justify`,table:`table`,image:`image`,horizontalRule:`minus`,pageBreak:`file-circle-plus`,removeFormat:`text-slash`,chevron:`chevron-down`,check:`check`,close:`xmark`,lock:`lock`,plus:`plus`,trash:`trash-can`,eye:`eye`,callout:`circle-info`,video:`circle-play`,emoji:`face-smile`,clock:`clock-rotate-left`},ax=`http://www.w3.org/2000/svg`;function ox(e){return typeof document<`u`?document.documentElement.dataset[e]:void 0}function sx(e){if(ox(`efeIcons`)===`fontawesome`&&ix[e]){let t=document.createElement(`i`);return t.className=`efe-icon efe-icon--fa fa-solid fa-${ix[e]}`,t.setAttribute(`aria-hidden`,`true`),t}let t=document.createElementNS(ax,`svg`);t.setAttribute(`viewBox`,`0 0 20 20`),t.setAttribute(`class`,`efe-icon`),t.setAttribute(`aria-hidden`,`true`),t.setAttribute(`focusable`,`false`);let n=document.createElementNS(ax,`path`);return n.setAttribute(`d`,rx[e]),t.appendChild(n),t}function Y(e,t){let n=ox(`efeTooltip`);n&&/^data-[a-z-]+$/.test(n)?e.setAttribute(n,t):e.title=t}function cx({name:e,label:t,shortcut:n,className:r=`efe-btn`}){let i=document.createElement(`button`);return i.type=`button`,i.className=r,i.setAttribute(`aria-label`,t),Y(i,n?`${t} (${n})`:t),i.appendChild(sx(e)),i}var lx=[`top`,`right`,`bottom`,`left`],ux=[`start`,`end`],dx=lx.reduce((e,t)=>e.concat(t,t+`-`+ux[0],t+`-`+ux[1]),[]),fx=Math.min,px=Math.max,mx=Math.round,hx=Math.floor,gx=e=>({x:e,y:e}),_x={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function vx(e,t,n){return px(e,fx(t,n))}function yx(e,t){return typeof e==`function`?e(t):e}function bx(e){return e.split(`-`)[0]}function xx(e){return e.split(`-`)[1]}function Sx(e){return e===`x`?`y`:`x`}function Cx(e){return e===`y`?`height`:`width`}function wx(e){let t=e[0];return t===`t`||t===`b`?`y`:`x`}function Tx(e){return Sx(wx(e))}function Ex(e,t,n){n===void 0&&(n=!1);let r=xx(e),i=Tx(e),a=Cx(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=Fx(o)),[o,Fx(o)]}function Dx(e){let t=Fx(e);return[Ox(e),t,Ox(t)]}function Ox(e){return e.includes(`start`)?e.replace(`start`,`end`):e.replace(`end`,`start`)}var kx=[`left`,`right`],Ax=[`right`,`left`],jx=[`top`,`bottom`],Mx=[`bottom`,`top`];function Nx(e,t,n){switch(e){case`top`:case`bottom`:return n?t?Ax:kx:t?kx:Ax;case`left`:case`right`:return t?jx:Mx;default:return[]}}function Px(e,t,n,r){let i=xx(e),a=Nx(bx(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(Ox)))),a}function Fx(e){let t=bx(e);return _x[t]+e.slice(t.length)}function Ix(e){return{top:e.top??0,right:e.right??0,bottom:e.bottom??0,left:e.left??0}}function Lx(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:Ix(e)}function Rx(e){let{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function zx(e,t,n){let{reference:r,floating:i}=e,a=wx(t),o=Tx(t),s=Cx(o),c=bx(t),l=a===`y`,u=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,f=r[s]/2-i[s]/2,p;switch(c){case`top`:p={x:u,y:r.y-i.height};break;case`bottom`:p={x:u,y:r.y+r.height};break;case`right`:p={x:r.x+r.width,y:d};break;case`left`:p={x:r.x-i.width,y:d};break;default:p={x:r.x,y:r.y}}let m=xx(t);return m&&(p[o]+=f*(m===`end`?1:-1)*(n&&l?-1:1)),p}async function Bx(e,t){t===void 0&&(t={});let{x:n,y:r,platform:i,rects:a,elements:o,strategy:s}=e,{boundary:c=`clippingAncestors`,rootBoundary:l=`viewport`,elementContext:u=`floating`,altBoundary:d=!1,padding:f=0}=yx(t,e),p=Lx(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=Rx(await i.getClippingRect({element:await(i.isElement==null?void 0:i.isElement(m))??!0?m:m.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(o.floating)),boundary:c,rootBoundary:l,strategy:s})),g=u===`floating`?{x:n,y:r,width:a.floating.width,height:a.floating.height}:a.reference,_=await(i.getOffsetParent==null?void 0:i.getOffsetParent(o.floating)),v=await(i.isElement==null?void 0:i.isElement(_))&&await(i.getScale==null?void 0:i.getScale(_))||{x:1,y:1},y=Rx(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:g,offsetParent:_,strategy:s}):g);return{top:(h.top-y.top+p.top)/v.y,bottom:(y.bottom-h.bottom+p.bottom)/v.y,left:(h.left-y.left+p.left)/v.x,right:(y.right-h.right+p.right)/v.x}}var Vx=50,Hx=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:Bx},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=zx(l,r,c),f=r,p=0,m={};for(let n=0;n({name:`arrow`,options:e,async fn(t){let{x:n,y:r,placement:i,rects:a,platform:o,elements:s,middlewareData:c}=t,{element:l,padding:u=0}=yx(e,t)||{};if(l==null)return{};let d=Lx(u),f={x:n,y:r},p=Tx(i),m=Cx(p),h=await o.getDimensions(l),g=p===`y`,_=g?`top`:`left`,v=g?`bottom`:`right`,y=g?`clientHeight`:`clientWidth`,b=a.reference[m]+a.reference[p]-f[p]-a.floating[m],x=f[p]-a.reference[p],S=await(o.getOffsetParent==null?void 0:o.getOffsetParent(l)),C=S?S[y]:0;C&&await(o.isElement==null?void 0:o.isElement(S))||(C=s.floating[y]||a.floating[m]);let w=b/2-x/2,T=C/2-h[m]/2-1,ee=fx(d[_],T),E=fx(d[v],T),D=C-h[m]-E,te=C/2-h[m]/2+w,ne=vx(ee,te,D),re=!c.arrow&&xx(i)!=null&&te!==ne&&a.reference[m]/2-(texx(t)===e),...n.filter(t=>xx(t)!==e)]:n.filter(e=>bx(e)===e)).filter(n=>!e||xx(n)===e||(t?Ox(n)!==n:!1))}var Gx=function(e){return e===void 0&&(e={}),{name:`autoPlacement`,options:e,async fn(t){let{rects:n,middlewareData:r,placement:i,platform:a,elements:o}=t,{crossAxis:s=!1,alignment:c,allowedPlacements:l=dx,autoAlignment:u=!0,...d}=yx(e,t),f=c!==void 0||l===dx?Wx(c||null,u,l):l,p=r.autoPlacement?.index||0,m=f[p];if(m==null)return{};if(i!==m)return{reset:{placement:f[0]}};let h=await a.detectOverflow(t,d),g=Ex(m,n,await(a.isRTL==null?void 0:a.isRTL(o.floating))),_=[h[bx(m)],h[g[0]],h[g[1]]],v=[...r.autoPlacement?.overflows||[],{placement:m,overflows:_}],y=f[p+1];if(y)return{data:{index:p+1,overflows:v},reset:{placement:y}};let b=v.map(e=>{let t=xx(e.placement);return[e.placement,t&&s?e.overflows.slice(0,2).reduce((e,t)=>e+t,0):e.overflows[0],e.overflows]}).sort((e,t)=>e[1]-t[1]),x=b.filter(e=>e[2].slice(0,xx(e[0])?2:3).every(e=>e<=0))[0]?.[0]||b[0][0];return x===i?{}:{data:{index:p+1,overflows:v},reset:{placement:x}}}}},Kx=function(e){return e===void 0&&(e={}),{name:`flip`,options:e,async fn(t){var n;let{placement:r,middlewareData:i,rects:a,initialPlacement:o,platform:s,elements:c}=t,{mainAxis:l=!0,crossAxis:u=!0,fallbackPlacements:d,fallbackStrategy:f=`bestFit`,fallbackAxisSideDirection:p=`none`,flipAlignment:m=!0,...h}=yx(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=bx(r),_=wx(o),v=bx(o)===o,y=await(s.isRTL==null?void 0:s.isRTL(c.floating)),b=d||(v||!m?[Fx(o)]:Dx(o)),x=p!==`none`;!d&&x&&b.push(...Px(o,m,p,y));let S=[o,...b],C=await s.detectOverflow(t,h),w=[],T=i.flip?.overflows||[];if(l&&w.push(C[g]),u){let e=Ex(r,a,y);w.push(C[e[0]],C[e[1]])}if(T=[...T,{placement:r,overflows:w}],!w.every(e=>e<=0)){let e=(i.flip?.index||0)+1,t=S[e];if(t&&(u!==`alignment`||_===wx(t)||T.every(e=>wx(e.placement)!==_||e.overflows[0]>0)))return{data:{index:e,overflows:T},reset:{placement:t}};let n=T.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0]?.placement;if(!n)switch(f){case`bestFit`:{let e=T.filter(e=>{if(x){let t=wx(e.placement);return t===_||t===`y`}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0]?.[0];e&&(n=e);break}case`initialPlacement`:n=o}if(r!==n)return{reset:{placement:n}}}return{}}}};function qx(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Jx(e){return lx.some(t=>e[t]>=0)}var Yx=function(e){return e===void 0&&(e={}),{name:`hide`,options:e,async fn(t){let{rects:n,platform:r}=t,{strategy:i=`referenceHidden`,...a}=yx(e,t);switch(i){case`referenceHidden`:{let e=qx(await r.detectOverflow(t,{...a,elementContext:`reference`}),n.reference);return{data:{referenceHiddenOffsets:e,referenceHidden:Jx(e)}}}case`escaped`:{let e=qx(await r.detectOverflow(t,{...a,altBoundary:!0}),n.floating);return{data:{escapedOffsets:e,escaped:Jx(e)}}}default:return{}}}}};function Xx(e){let t=fx(...e.map(e=>e.left)),n=fx(...e.map(e=>e.top)),r=px(...e.map(e=>e.right)),i=px(...e.map(e=>e.bottom));return{x:t,y:n,width:r-t,height:i-n}}function Zx(e){let t=e.slice().sort((e,t)=>e.y-t.y),n=[],r=null;for(let e=0;er.height/2?n.push([i]):n[n.length-1].push(i),r=i}return n.map(e=>Rx(Xx(e)))}var Qx=function(e){return e===void 0&&(e={}),{name:`inline`,options:e,async fn(t){let{placement:n,elements:r,rects:i,platform:a,strategy:o}=t,{padding:s=2,x:c,y:l}=yx(e,t),u=Array.from(await(a.getClientRects==null?void 0:a.getClientRects(r.reference))||[]);if(!u.length)return{};let d=Zx(u),f=Rx(Xx(u)),p=Lx(s);function m(){if(d.length===2&&(d[0].left>d[1].right||d[1].left>d[0].right)&&c!=null&&l!=null)return d.find(e=>c>e.left-p.left&&ce.top-p.top&&l=2){if(wx(n)===`y`){let e=d[0],t=d[d.length-1],r=bx(n)===`top`,i=e.top,a=t.bottom,o=r?e.left:t.left;return Rx({x:o,y:i,width:(r?e.right:t.right)-o,height:a-i})}let e=bx(n)===`left`,t=px(...d.map(e=>e.right)),r=fx(...d.map(e=>e.left)),i=d.filter(n=>e?n.left===r:n.right===t),a=i[0].top,o=i[i.length-1].bottom;return Rx({x:r,y:a,width:t-r,height:o-a})}return f}let h=await a.getElementRects({reference:{getBoundingClientRect:m},floating:r.floating,strategy:o});return i.reference.x!==h.reference.x||i.reference.y!==h.reference.y||i.reference.width!==h.reference.width||i.reference.height!==h.reference.height?{reset:{rects:h}}:{}}}},$x=new Set([`left`,`top`]);async function eS(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=bx(n),s=xx(n),c=wx(n)===`y`,l=$x.has(o)?-1:1,u=a&&c?-1:1,d=yx(t,e),{mainAxis:f,crossAxis:p,alignmentAxis:m}=typeof d==`number`?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return s&&typeof m==`number`&&(p=s===`end`?m*-1:m),c?{x:p*u,y:f*l}:{x:f*l,y:p*u}}var tS=function(e){return e===void 0&&(e=0),{name:`offset`,options:e,async fn(t){var n;let{x:r,y:i,placement:a,middlewareData:o}=t,s=await eS(t,e);return a===o.offset?.placement&&(n=o.arrow)!=null&&n.alignmentOffset?{}:{x:r+s.x,y:i+s.y,data:{...s,placement:a}}}}},nS=function(e){return e===void 0&&(e={}),{name:`shift`,options:e,async fn(t){let{x:n,y:r,placement:i,platform:a}=t,{mainAxis:o=!0,crossAxis:s=!1,limiter:c={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...l}=yx(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=wx(i),p=Sx(f),m=u[p],h=u[f],g=(e,t)=>vx(t+d[e===`y`?`top`:`left`],t,t-d[e===`y`?`bottom`:`right`]);o&&(m=g(p,m)),s&&(h=g(f,h));let _=c.fn({...t,[p]:m,[f]:h});return{..._,data:{x:_.x-n,y:_.y-r,enabled:{[p]:o,[f]:s}}}}}},rS=function(e){return e===void 0&&(e={}),{name:`size`,options:e,async fn(t){let{placement:n,rects:r,platform:i,elements:a}=t,{apply:o=()=>{},...s}=yx(e,t),c=await i.detectOverflow(t,s),l=bx(n),u=xx(n),d=wx(n)===`y`,{width:f,height:p}=r.floating,m,h;l===`top`||l===`bottom`?(m=l,h=u===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?`start`:`end`)?`left`:`right`):(h=l,m=u===`end`?`top`:`bottom`);let g=p-c.top-c.bottom,_=f-c.left-c.right,v=fx(p-c[m],g),y=fx(f-c[h],_),b=t.middlewareData.shift,x=!b,S=v,C=y;b!=null&&b.enabled.x&&(C=_),b!=null&&b.enabled.y&&(S=g),x&&!u&&(d?C=f-2*px(c.left,c.right):S=p-2*px(c.top,c.bottom)),await o({...t,availableWidth:C,availableHeight:S});let w=await i.getDimensions(a.floating);return f!==w.width||p!==w.height?{reset:{rects:!0}}:{}}}};function iS(){return typeof window<`u`}function aS(e){return cS(e)?(e.nodeName||``).toLowerCase():`#document`}function oS(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function sS(e){return((cS(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function cS(e){return iS()?e instanceof Node||e instanceof oS(e).Node:!1}function lS(e){return iS()?e instanceof Element||e instanceof oS(e).Element:!1}function uS(e){return iS()?e instanceof HTMLElement||e instanceof oS(e).HTMLElement:!1}function dS(e){return!iS()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof oS(e).ShadowRoot}function fS(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=CS(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!==`inline`&&i!==`contents`}function pS(e){return/^(table|td|th)$/.test(aS(e))}function mS(e){try{if(e.matches(`:popover-open`))return!0}catch{}try{return e.matches(`:modal`)}catch{return!1}}var hS=/transform|translate|scale|rotate|perspective|filter/,gS=/paint|layout|strict|content/,_S=e=>!!e&&e!==`none`,vS;function yS(e){let t=lS(e)?CS(e):e;return _S(t.transform)||_S(t.translate)||_S(t.scale)||_S(t.rotate)||_S(t.perspective)||!xS()&&(_S(t.backdropFilter)||_S(t.filter))||hS.test(t.willChange||``)||gS.test(t.contain||``)}function bS(e){let t=TS(e);for(;uS(t)&&!SS(t);){if(yS(t))return t;if(mS(t))return null;t=TS(t)}return null}function xS(){return vS??=typeof CSS<`u`&&CSS.supports&&CSS.supports(`-webkit-backdrop-filter`,`none`),vS}function SS(e){return/^(html|body|#document)$/.test(aS(e))}function CS(e){return oS(e).getComputedStyle(e)}function wS(e){return lS(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function TS(e){if(aS(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||dS(e)&&e.host||sS(e);return dS(t)?t.host:t}function ES(e){let t=TS(e);return SS(t)?(e.ownerDocument||e).body:uS(t)&&fS(t)?t:ES(t)}function DS(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=ES(e),i=r===e.ownerDocument?.body,a=oS(r);if(i){let e=OS(a);return t.concat(a,a.visualViewport||[],fS(r)?r:[],e&&n?DS(e):[])}return t.concat(r,DS(r,[],n))}function OS(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function kS(e){let t=CS(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=uS(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=mx(n)!==a||mx(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function AS(e){return lS(e)?e:e.contextElement}function jS(e){let t=AS(e);if(!uS(t))return gx(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=kS(t),o=(a?mx(n.width):n.width)/r,s=(a?mx(n.height):n.height)/i;return o&&Number.isFinite(o)||(o=1),s&&Number.isFinite(s)||(s=1),{x:o,y:s}}var MS=gx(0);function NS(e){let t=oS(e);return!xS()||!t.visualViewport?MS:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function PS(e,t,n){return t===void 0&&(t=!1),!!n&&t&&n===oS(e)}function FS(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=AS(e),o=gx(1);t&&(r?lS(r)&&(o=jS(r)):o=jS(e));let s=PS(a,n,r)?NS(a):gx(0),c=(i.left+s.x)/o.x,l=(i.top+s.y)/o.y,u=i.width/o.x,d=i.height/o.y;if(a&&r){let e=oS(a),t=lS(r)?oS(r):r,n=e,i=OS(n);for(;i&&t!==n;){let e=jS(i),t=i.getBoundingClientRect(),r=CS(i),a=t.left+(i.clientLeft+parseFloat(r.paddingLeft))*e.x,o=t.top+(i.clientTop+parseFloat(r.paddingTop))*e.y;c*=e.x,l*=e.y,u*=e.x,d*=e.y,c+=a,l+=o,n=oS(i),i=OS(n)}}return Rx({width:u,height:d,x:c,y:l})}function IS(e,t){let n=wS(e).scrollLeft;return t?t.left+n:FS(sS(e)).left+n}function LS(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-IS(e,n),y:n.top+t.scrollTop}}function RS(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=sS(r),s=t?mS(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=gx(1),u=gx(0),d=uS(r);if((d||!a)&&((aS(r)!==`body`||fS(o))&&(c=wS(r)),d)){let e=FS(r);l=jS(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?LS(o,c):gx(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+u.x+f.x,y:n.y*l.y-c.scrollTop*l.y+u.y+f.y}}function zS(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function BS(e){let t=wS(e),n=e.ownerDocument.body,r=px(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),i=px(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight),a=-t.scrollLeft+IS(e),o=-t.scrollTop;return CS(n).direction===`rtl`&&(a+=px(e.clientWidth,n.clientWidth)-r),{width:r,height:i,x:a,y:o}}var VS=25;function HS(e,t,n){n===void 0&&(n=`viewport`);let r=n===`layoutViewport`,i=oS(e),a=sS(e),o=i.visualViewport,s=a.clientWidth,c=a.clientHeight,l=0,u=0;if(o){let e=!xS()||t===`fixed`;r?e||(l=-o.offsetLeft,u=-o.offsetTop):(s=o.width,c=o.height,e&&(l=o.offsetLeft,u=o.offsetTop))}if(IS(a)<=0){let e=a.ownerDocument,t=e.body,n=getComputedStyle(t),r=e.compatMode===`CSS1Compat`&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,i=Math.abs(a.clientWidth-t.clientWidth-r),o=getComputedStyle(a).scrollbarGutter===`stable both-edges`?i/2:i;o<=VS&&(s-=o)}return{width:s,height:c,x:l,y:u}}function US(e,t){let n=FS(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=jS(e);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function WS(e,t,n){let r;if(t===`viewport`||t===`layoutViewport`)r=HS(e,n,t);else if(t===`document`)r=BS(sS(e));else if(lS(t))r=US(t,n);else{let n=NS(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return Rx(r)}function GS(e,t){let n=t.get(e);if(n)return n;let r=DS(e,[],!1).filter(e=>lS(e)&&aS(e)!==`body`),i=null,a=CS(e).position===`fixed`,o=a?TS(e):e;for(;lS(o)&&!SS(o);){let e=CS(o),t=yS(o),n=i?i.position:a?`fixed`:``;!t&&(n===`fixed`||n===`absolute`&&e.position===`static`)?r=r.filter(e=>e!==o):i=e,o=TS(o)}return t.set(e,r),r}function KS(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?mS(t)?[]:GS(t,this._c):[].concat(n),r],o=WS(t,a[0],i),s=o.top,c=o.right,l=o.bottom,u=o.left;for(let e=1;e{s(!1,1e-7)},1e3)}y=!1}try{r=new IntersectionObserver(b,{...v,root:a.ownerDocument})}catch{r=new IntersectionObserver(b,v)}r.observe(e)}let c=oS(e),l=()=>s(n);return c.addEventListener(`resize`,l),s(!0),()=>{c.removeEventListener(`resize`,l),o()}}function rC(e,t,n,r){r===void 0&&(r={});let{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:o=typeof ResizeObserver==`function`,layoutShift:s=typeof IntersectionObserver==`function`,animationFrame:c=!1}=r,l=AS(e),u=i||a?[...l?DS(l):[],...t?DS(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n),a&&e.addEventListener(`resize`,n)});let d=l&&s?nC(l,n,a):null,f=-1,p=null;o&&(p=new ResizeObserver(e=>{let[r]=e;r&&r.target===l&&p&&t&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var e;(e=p)==null||e.observe(t)})),n()}),l&&!c&&p.observe(l),t&&p.observe(t));let m,h=c?FS(e):null;c&&g();function g(){let t=FS(e);h&&!tC(h,t)&&n(),h=t,m=requestAnimationFrame(g)}return n(),()=>{var e;u.forEach(e=>{i&&e.removeEventListener(`scroll`,n),a&&e.removeEventListener(`resize`,n)}),d?.(),(e=p)==null||e.disconnect(),p=null,c&&cancelAnimationFrame(m)}}var iC=tS,aC=Gx,oC=nS,sC=Kx,cC=rS,lC=Yx,uC=Ux,dC=Qx,fC=(e,t,n)=>{let r=new Map,i=n??{},a={...eC,...i.platform,_c:r};return Hx(e,t,{...i,platform:a})},pC=[`http:`,`https:`,`mailto:`];function mC(e){return e<=32||e===160||e===5760||e===6158||e>=8192&&e<=8233||e===8287||e===12288}function hC(e){let t=``;for(let n of e)mC(n.codePointAt(0))||(t+=n);return t}function gC(e){let t=e;for(let e=0;e<3;e+=1){let e=t.includes(`&`)?_C(t):t;if(e.includes(`%`))try{e=decodeURIComponent(e)}catch{}if(e===t)return e;t=e}return t}function _C(e){let t=document.createElement(`textarea`);return t.innerHTML=e,t.value}function vC(e){if(e==null||e===``)return!0;if(typeof e!=`string`||e.length>2048)return!1;let t=hC(gC(e));if(t.startsWith(`//`))return!1;let n=t.match(/^([a-zA-Z][a-zA-Z0-9+.-]*):/);return n?pC.includes(n[1].toLowerCase()+`:`):!1}function yC(){return xg.configure({openOnClick:!1,autolink:!0,protocols:[`http`,`https`,`mailto`],isAllowedUri:e=>vC(e),HTMLAttributes:{target:null,rel:null,class:null}})}function bC(e){let t=e.slice(0,e.indexOf(`:`)).toLowerCase();return t===`http`||t===`https`?{href:e,target:`_blank`,rel:`noopener noreferrer`}:{href:e}}var xC=new WeakMap;function SC(e,t){if(CC(e),e.dataset.state=`closed`,window.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches){t();return}let n=n=>{n&&n.target!==e||(CC(e),t())};e.addEventListener(`animationend`,n),xC.set(e,{finish:n,timer:setTimeout(n,200)})}function CC(e){let t=xC.get(e);t&&(clearTimeout(t.timer),e.removeEventListener(`animationend`,t.finish),xC.delete(e))}var wC={};function TC(e,t){wC[e]={...wC[e],...t}}function EC(){return typeof document<`u`&&document.documentElement.lang||`de`}function X(e,t={}){return DC(wC,EC(),e,t)}function DC(e,t,n,r={},i=`de`){let a=r.count;for(let o of new Set([t,t.split(`-`)[0],i])){let t=e[o]??{};if(typeof a==`number`){let e=t[`${n}_${new Intl.PluralRules(o).select(a)}`]??t[`${n}_other`];if(e!==void 0)return OC(e,r)}if(Object.hasOwn(t,n))return OC(t[n],r)}return n}function OC(e,t){return e.replace(/\{\{\s*(\w+)\s*\}\}/g,(e,n)=>Object.hasOwn(t,n)?String(t[n]):e)}TC(`de`,{"editor.bubble.bold":`Fett`,"editor.bubble.italic":`Kursiv`,"editor.bubble.link":`Link`,"editor.bubble.quick_bar":`Schnellleiste`,"editor.bubble.remove_format":`Formatierung entfernen`,"editor.bubble.shortcut_bold":`Strg+B`,"editor.bubble.shortcut_italic":`Strg+I`,"editor.bubble.shortcut_link":`Strg+K`,"editor.bubble.shortcut_strike":`Strg+Umschalt+S`,"editor.bubble.shortcut_underline":`Strg+U`,"editor.bubble.strike":`Durchgestrichen`,"editor.bubble.underline":`Unterstrichen`,"editor.callout.important":`Wichtig`,"editor.callout.note":`Hinweis`,"editor.callout.tip":`Tipp`,"editor.doc_properties.a4_landscape":`A4 quer`,"editor.doc_properties.a4_portrait":`A4 hoch`,"editor.doc_properties.all_filled":`Alles ausgefüllt. Das Dokument kann ausgestellt werden.`,"editor.doc_properties.all_required_filled":`Alle Pflichtangaben sind ausgefüllt.`,"editor.doc_properties.aside":`Randkasten`,"editor.doc_properties.aside_hint":`Steht im Satzspiegel, der Text läuft daneben weiter. Fest; Felder darin füllt der Verfasser aus.`,"editor.doc_properties.aside_title":`Fester Kasten mit Textumfluss`,"editor.doc_properties.band_every_page":`jeder Seite`,"editor.doc_properties.band_first_page":`Seite 1`,"editor.doc_properties.band_fixed":`Für den Verfasser fest, außer den Eingabebereichen darin.`,"editor.doc_properties.band_from_second_page":`jeder Seite ab Seite 2`,"editor.doc_properties.band_in_bottom":`Liegt im unteren Rand und steht auf {{pages}}.`,"editor.doc_properties.band_in_top":`Liegt im oberen Rand und steht auf {{pages}}.`,"editor.doc_properties.band_rest":`{{region}} der Folgeseiten`,"editor.doc_properties.band_variables":`Seitenzahlen über „Variable ▾“: Seite und Seitenzahl. Werte aus Feldern des Textkörpers über {{syntax}}.`,"editor.doc_properties.bottom":`Unten`,"editor.doc_properties.decimals":`Nachkommastellen`,"editor.doc_properties.detach_letterhead":`Vom Briefbogen lösen und selbst bearbeiten`,"editor.doc_properties.dissolve_block":`Block auflösen, der Inhalt bleibt`,"editor.doc_properties.dissolve_input":`Bereich auflösen, der Text wird fest`,"editor.doc_properties.dissolve_snippet":`Baustein auflösen, Variante 1 wird fester Text`,"editor.doc_properties.field":`Feld`,"editor.doc_properties.field_id":`Kennung`,"editor.doc_properties.field_required":`Pflicht, ohne Eintrag lässt sich das Dokument nicht ausstellen`,"editor.doc_properties.first_bottom":`Seite 1 unten`,"editor.doc_properties.first_footer":`Eigene Fußzeile auf Seite 1`,"editor.doc_properties.first_page_different":`Erste Seite anders (eigene Kopfzeile, eigene Ränder)`,"editor.doc_properties.first_top":`Seite 1 oben`,"editor.doc_properties.fix_bottom":`Unteren Rand auf {{mm}} mm setzen`,"editor.doc_properties.fix_hint":`Text im Bereich markieren und „Festsetzen“: diesen Teil kann der Verfasser nicht ändern oder löschen.`,"editor.doc_properties.fix_top":`Oberen Rand auf {{mm}} mm setzen`,"editor.doc_properties.fixed":`Fester Teil`,"editor.doc_properties.fixed_hint":`Der Verfasser schreibt davor und danach weiter. Ändern oder löschen kann er diesen Teil nicht; beim Speichern kommt er immer aus der Vorlage.`,"editor.doc_properties.fixed_title":`Im Textbereich festgesetzt`,"editor.doc_properties.footer":`Fußzeile`,"editor.doc_properties.footer_distance":`Fußzeile ab Blattrand`,"editor.doc_properties.format":`Format`,"editor.doc_properties.format_basic":`Einfach`,"editor.doc_properties.format_basic_hint":`Fett, kursiv, unterstrichen und Listen.`,"editor.doc_properties.format_full":`Voll`,"editor.doc_properties.format_full_hint":`Auch Überschriften, Tabellen, Ausrichtung.`,"editor.doc_properties.format_plain":`Keine`,"editor.doc_properties.format_plain_hint":`Nur Text und Absätze.`,"editor.doc_properties.formatting":`Formatierung`,"editor.doc_properties.frame":`Rahmen`,"editor.doc_properties.header":`Kopfzeile`,"editor.doc_properties.header_distance":`Kopfzeile ab Blattrand`,"editor.doc_properties.image":`Bild`,"editor.doc_properties.image_hint":`Fester Teil der Vorlage. Im PDF holt das Produkt die Datei aus seinem Speicher.`,"editor.doc_properties.image_title":`Logo oder Wappen`,"editor.doc_properties.input_area":`Eingabebereich`,"editor.doc_properties.kind":`Art`,"editor.doc_properties.kind_choice":`Auswahl`,"editor.doc_properties.kind_date":`Datum`,"editor.doc_properties.kind_line":`Zeile`,"editor.doc_properties.kind_number":`Zahl`,"editor.doc_properties.label":`Beschriftung`,"editor.doc_properties.left":`Links`,"editor.doc_properties.letterhead":`Briefbogen`,"editor.doc_properties.letterhead_hint":`Kopf- und Fußzeile kommen aus dem Briefbogen. Eine Änderung dort gilt für alle Vorlagen, die ihn nutzen.`,"editor.doc_properties.letterhead_none":`Keiner, eigene Kopf- und Fußzeile`,"editor.doc_properties.margin_note":`Der Rand ist kein Schreibbereich. Text, Tabellen und Randkästen bleiben im Satzspiegel, in den Rand kommen nur Kopf- und Fußzeile.`,"editor.doc_properties.margins_hint":`Werte in mm. Links und rechts auch am Lineal. Editor und PDF nutzen dieselben Werte.`,"editor.doc_properties.max":`Maximum`,"editor.doc_properties.max_length":`Höchstlänge`,"editor.doc_properties.max_length_hint":`Leer: 500 Zeichen`,"editor.doc_properties.min":`Minimum`,"editor.doc_properties.min_length":`Mindestlänge in Zeichen`,"editor.doc_properties.missing_count_one":`{{count}} Angabe fehlt noch.`,"editor.doc_properties.missing_count_other":`{{count}} Angaben fehlen noch.`,"editor.doc_properties.no_label":`Ohne Beschriftung`,"editor.doc_properties.open":`Noch offen`,"editor.doc_properties.open_count":`Noch offen ({{n}})`,"editor.doc_properties.option_a":`Option A`,"editor.doc_properties.option_b":`Option B`,"editor.doc_properties.optional":`Optionaler Block`,"editor.doc_properties.optional_enabled":`Zu Beginn eingeschaltet`,"editor.doc_properties.optional_hint":`Der Verfasser schaltet den Block ein oder aus.`,"editor.doc_properties.options_list":`Auswahl, eine pro Zeile`,"editor.doc_properties.options_own":`Eigene Liste`,"editor.doc_properties.options_source":`Liste aus dem System`,"editor.doc_properties.overflow_footer":`Die Fußzeile ist höher als der untere Rand. Im PDF wird sie abgeschnitten.`,"editor.doc_properties.overflow_header":`Die Kopfzeile ist höher als der obere Rand. Im PDF wird sie abgeschnitten.`,"editor.doc_properties.page":`Seite`,"editor.doc_properties.page_title":`Format und Ränder`,"editor.doc_properties.placeholder":`Platzhalter`,"editor.doc_properties.preset":`Vorgabe`,"editor.doc_properties.preset_custom":`Eigene Ränder`,"editor.doc_properties.preset_din":`DIN 5008 · links 25, rechts 20 mm`,"editor.doc_properties.preset_standard":`Standard · 20 mm ringsum`,"editor.doc_properties.print":`Druck`,"editor.doc_properties.print_hint":`Ohne Markierungen und Rahmen der Eingabebereiche. Verbindlich ist das PDF.`,"editor.doc_properties.print_title":`So kommt es aufs Papier`,"editor.doc_properties.reason_missing":`fehlt`,"editor.doc_properties.reason_required":`Pflicht`,"editor.doc_properties.reason_short":`zu kurz`,"editor.doc_properties.release":`Wieder freigeben`,"editor.doc_properties.remove_aside":`Randkasten entfernen`,"editor.doc_properties.remove_field":`Feld entfernen, die Beschriftung bleibt als Text`,"editor.doc_properties.remove_region":`{{region}} entfernen`,"editor.doc_properties.repeat":`Wiederholblock`,"editor.doc_properties.repeat_hint":`Der Verfasser kann weitere Einträge anlegen.`,"editor.doc_properties.required":`Pflicht`,"editor.doc_properties.right":`Rechts`,"editor.doc_properties.side":`Seite`,"editor.doc_properties.snippet":`Textbaustein`,"editor.doc_properties.snippet_required":`Pflicht, eine Variante muss gewählt sein`,"editor.doc_properties.snippet_variants":`Varianten, je Zeile „Name: Text“`,"editor.doc_properties.start":`Beim Anlegen`,"editor.doc_properties.start_empty":`Leer, mit Platzhalter`,"editor.doc_properties.start_suggestion":`Mit dem Text aus der Vorlage als Vorschlag`,"editor.doc_properties.summary":`In dieser Vorlage`,"editor.doc_properties.summary_fixed_one":`{{count}} fester Teil im freien Text`,"editor.doc_properties.summary_fixed_other":`{{count}} feste Teile im freien Text`,"editor.doc_properties.summary_inputs_one":`{{count}} Eingabebereich`,"editor.doc_properties.summary_inputs_other":`{{count}} Eingabebereiche`,"editor.doc_properties.summary_required_other":`davon {{count}} Pflicht`,"editor.doc_properties.text_area":`Textbereich`,"editor.doc_properties.top":`Oben`,"editor.doc_properties.var_example":`Zum Beispiel: {{value}}`,"editor.doc_properties.var_field":`Wert des Felds „{{field}}“`,"editor.doc_properties.var_page":`Seitenzahl, im PDF je Seite`,"editor.doc_properties.var_pages":`Gesamtzahl der Seiten`,"editor.doc_properties.var_system":`Füllt das System beim Ausstellen. Der Verfasser trägt hier nichts ein.`,"editor.doc_properties.variable":`Variable`,"editor.doc_properties.variant_n":`Variante {{n}}`,"editor.doc_properties.who_all":`Alle, die das Dokument schreiben`,"editor.doc_properties.who_chooses":`Wer wählt`,"editor.doc_properties.who_fills":`Wer füllt aus`,"editor.doc_properties.who_only":`Nur mit Recht „{{label}}“`,"editor.doc_properties.width":`Breite`,"editor.doc_properties.write":`Ausfüllen`,"editor.doc_properties.write_hint":`Schreiben geht nur in den farbigen Bereichen. Ein Klick auf festen Text zeigt kurz, dass er gesperrt ist.`,"editor.doc_properties.write_title":`Dokument ausfüllen`,"editor.doc_ruler.left_margin":`Linker Rand`,"editor.doc_ruler.right_margin":`Rechter Rand`,"editor.doc_ruler.tip_left":`Links {{mm}} mm`,"editor.doc_ruler.tip_right":`Rechts {{mm}} mm`,"editor.document_editor.add_footer":`Fußzeile hinzufügen`,"editor.document_editor.add_header":`Kopfzeile hinzufügen`,"editor.document_editor.aside":`Randkasten`,"editor.document_editor.fix":`Festsetzen`,"editor.document_editor.fix_tip":`Markierten Text im Textbereich festsetzen (Strg+Umschalt+F)`,"editor.document_editor.footer":`Fußzeile`,"editor.document_editor.footer_first":`Fußzeile Seite 1`,"editor.document_editor.footer_rest":`Fußzeile Folgeseiten`,"editor.document_editor.free_as_line":`Als Zeile freigeben`,"editor.document_editor.free_as_snippet":`Als Textbaustein`,"editor.document_editor.free_as_text_area":`Als Textbereich freigeben`,"editor.document_editor.from_letterhead":`Aus dem Briefbogen „{{name}}“`,"editor.document_editor.header":`Kopfzeile`,"editor.document_editor.header_first":`Kopfzeile Seite 1`,"editor.document_editor.header_rest":`Kopfzeile Folgeseiten`,"editor.document_editor.insert_input":`Eingabebereich einfügen`,"editor.document_editor.kind_choice":`Auswahl`,"editor.document_editor.kind_choice_hint":`Ein Wert aus einer festen Liste`,"editor.document_editor.kind_date":`Datum`,"editor.document_editor.kind_date_hint":`Datum mit Kalender`,"editor.document_editor.kind_line":`Zeile`,"editor.document_editor.kind_line_hint":`Eine Zeile Text, ohne Formatierung`,"editor.document_editor.kind_number":`Zahl`,"editor.document_editor.kind_number_hint":`Nur Ziffern`,"editor.document_editor.kind_snippet":`Textbaustein`,"editor.document_editor.kind_snippet_hint":`Einer von mehreren vorgegebenen Texten`,"editor.document_editor.kind_text":`Textbereich`,"editor.document_editor.kind_text_hint":`Mehrere Absätze, Formatierung einstellbar`,"editor.document_editor.optional":`Optionaler Block`,"editor.document_editor.repeat":`Wiederholblock`,"editor.document_editor.template":`Vorlage`,"editor.document_editor.text":`Text`,"editor.document_editor.var_page":`Seite`,"editor.document_editor.var_pages":`Seitenzahl`,"editor.document_editor.variable":`Variable`,"editor.emoji.categories":`Kategorien`,"editor.emoji.choose":`Emoji auswählen`,"editor.emoji.dialog":`Emoji einfügen`,"editor.emoji.failed":`Emojis konnten nicht geladen werden.`,"editor.emoji.hits_one":`{{count}} Treffer`,"editor.emoji.hits_other":`{{count}} Treffer`,"editor.emoji.loading":`Lade Emojis …`,"editor.emoji.none":`Kein Emoji gefunden`,"editor.emoji.recent":`Zuletzt benutzt`,"editor.emoji.search":`Emoji suchen`,"editor.emoji.tip":`Tipp: im Text mit Doppelpunkt suchen, etwa :daumen`,"editor.emoji.tone":`Hautfarbe`,"editor.emoji.tone_0":`Standard`,"editor.emoji.tone_1":`Hell`,"editor.emoji.tone_2":`Mittelhell`,"editor.emoji.tone_3":`Mittel`,"editor.emoji.tone_4":`Mitteldunkel`,"editor.emoji.tone_5":`Dunkel`,"editor.emoji.tone_current":`Hautfarbe: {{tone}}`,"editor.index.placeholder":`Hier schreiben …`,"editor.inputs.add_another":`{{label}}: weiteren hinzufügen`,"editor.inputs.add_another_tip":`Einen weiteren Eintrag „{{label}}“ anlegen`,"editor.inputs.aside":`Randkasten`,"editor.inputs.aside_fixed":`Randkasten · fest`,"editor.inputs.choose_snippet":`{{label}} wählen`,"editor.inputs.entry":`Eintrag`,"editor.inputs.field":`Feld`,"editor.inputs.filled_by":`Füllt aus: {{who}}`,"editor.inputs.fixed":`fest`,"editor.inputs.fixed_tip":`Fester Teil: der Verfasser kann ihn weder ändern noch löschen`,"editor.inputs.from_template":`Aus der Vorlage, nicht änderbar`,"editor.inputs.locked":`gesperrt`,"editor.inputs.only_who":`nur: {{who}}`,"editor.inputs.only_who_tip":`Nur mit dem Recht „{{who}}“ auszufüllen`,"editor.inputs.option_a":`Option A`,"editor.inputs.option_b":`Option B`,"editor.inputs.optional":`Optional`,"editor.inputs.optional_block":`Optionaler Block`,"editor.inputs.remove":`Entfernen`,"editor.inputs.remove_tip":`Diesen Eintrag „{{label}}“ entfernen`,"editor.inputs.repeatable":`Wiederholbar`,"editor.inputs.required":`Pflicht`,"editor.inputs.snippet":`Textbaustein`,"editor.inputs.text_area":`Textbereich`,"editor.inputs.variant_n":`Variante {{n}}`,"editor.inputs.variants_one":`{{count}} Variante: {{names}}`,"editor.inputs.variants_other":`{{count}} Varianten: {{names}}`,"editor.link_balloon.address":`Linkadresse`,"editor.link_balloon.apply":`Übernehmen`,"editor.link_balloon.cancel":`Abbrechen`,"editor.link_balloon.edit_link":`Link bearbeiten`,"editor.link_balloon.invalid":`Nur http, https oder mailto sind erlaubt.`,"editor.link_balloon.remove":`Link entfernen`,"editor.page_markers.estimate":`Geschätzte Seitenaufteilung. Verbindlich ist die PDF-Vorschau.`,"editor.section_view.add_another":`{{title}}: weiteren hinzufügen`,"editor.section_view.add_another_tip":`Einen weiteren Eintrag „{{title}}“ anlegen`,"editor.section_view.free":`Frei`,"editor.section_view.free_tip":`Freier Abschnitt: im Dokument frei beschreibbar`,"editor.section_view.from_template":`Aus der Vorlage, nicht änderbar`,"editor.section_view.locked":`Gesperrt`,"editor.section_view.locked_tip":`Gesperrter Abschnitt: im Dokument nur die Felder ausfüllbar`,"editor.section_view.remove":`Entfernen`,"editor.section_view.remove_tip":`Diesen Eintrag „{{title}}“ entfernen`,"editor.section_view.repeatable":`Wiederholbar`,"editor.section_view.section":`Abschnitt`,"editor.toolbar.align_center":`Zentriert`,"editor.toolbar.align_justify":`Blocksatz`,"editor.toolbar.align_left":`Linksbündig`,"editor.toolbar.align_right":`Rechtsbündig`,"editor.toolbar.alignment":`Ausrichtung`,"editor.toolbar.blockquote":`Zitat`,"editor.toolbar.bold":`Fett`,"editor.toolbar.bullet_list":`Aufzählungsliste`,"editor.toolbar.callout":`Hinweisbox`,"editor.toolbar.callout_remove":`Hinweisbox entfernen`,"editor.toolbar.emoji":`Emoji einfügen`,"editor.toolbar.font":`Schrift`,"editor.toolbar.font_default":`Standard`,"editor.toolbar.heading_1":`Überschrift 1`,"editor.toolbar.heading_2":`Überschrift 2`,"editor.toolbar.heading_3":`Überschrift 3`,"editor.toolbar.horizontal_rule":`Trennlinie einfügen`,"editor.toolbar.image":`Bild einfügen`,"editor.toolbar.instance_add":`Abschnitt wiederholen`,"editor.toolbar.instance_remove":`Abschnitt entfernen`,"editor.toolbar.instances":`Wiederholbare Abschnitte`,"editor.toolbar.italic":`Kursiv`,"editor.toolbar.link":`Link`,"editor.toolbar.ordered_list":`Nummerierte Liste`,"editor.toolbar.page_break":`Seitenumbruch einfügen`,"editor.toolbar.paragraph":`Absatz`,"editor.toolbar.paragraph_format":`Absatzformat`,"editor.toolbar.preview":`Vorschau`,"editor.toolbar.preview_tip":`Vorschau: so sieht das Dokument gedruckt aus`,"editor.toolbar.redo":`Wiederholen`,"editor.toolbar.section_free":`Abschnitt einfügen (frei)`,"editor.toolbar.section_free_text":`+ Frei`,"editor.toolbar.section_locked":`Abschnitt einfügen (gesperrt)`,"editor.toolbar.section_locked_text":`+ Gesperrt`,"editor.toolbar.section_mode":`Modus umschalten`,"editor.toolbar.section_mode_text":`Modus`,"editor.toolbar.sections":`Abschnitte`,"editor.toolbar.shortcut_bold":`Strg+B`,"editor.toolbar.shortcut_italic":`Strg+I`,"editor.toolbar.shortcut_link":`Strg+K`,"editor.toolbar.shortcut_redo":`Strg+Y`,"editor.toolbar.shortcut_strike":`Strg+Umschalt+S`,"editor.toolbar.shortcut_underline":`Strg+U`,"editor.toolbar.shortcut_undo":`Strg+Z`,"editor.toolbar.strike":`Durchgestrichen`,"editor.toolbar.style":`Stil`,"editor.toolbar.style_block":`Absatz`,"editor.toolbar.style_inline":`Textstelle`,"editor.toolbar.style_none":`Kein Stil`,"editor.toolbar.table":`Tabelle`,"editor.toolbar.table_column_after":`Spalte danach einfügen`,"editor.toolbar.table_column_before":`Spalte davor einfügen`,"editor.toolbar.table_column_delete":`Spalte löschen`,"editor.toolbar.table_delete":`Tabelle löschen`,"editor.toolbar.table_insert":`Tabelle einfügen (3×3)`,"editor.toolbar.table_row_after":`Zeile danach einfügen`,"editor.toolbar.table_row_before":`Zeile davor einfügen`,"editor.toolbar.table_row_delete":`Zeile löschen`,"editor.toolbar.text_formatting":`Textformatierung`,"editor.toolbar.underline":`Unterstrichen`,"editor.toolbar.undo":`Rückgängig`,"editor.toolbar.video":`Video einbetten`,"editor.variable_suggestion.choose":`Variable auswählen`,"editor.variable_suggestion.no_results":`Keine Treffer`,"editor.variable_view.filled":`Automatisch ausgefüllt: {{label}}`,"editor.variable_view.missing":`Für „{{label}}“ liegt kein Wert vor.`,"editor.variable_view.missing_prefix":`fehlt: `,"editor.variable_view.placeholder":`Platzhalter {{token}}: wird beim Ausfüllen durch {{label}} ersetzt`,"editor.variable_view.unknown":`Unbekannter Platzhalter {{token}}`,"editor.video.address":`YouTube-, Vimeo- oder Streamable-Adresse`,"editor.video.cancel":`Abbrechen`,"editor.video.embed":`Video einbetten`,"editor.video.insert":`Einfügen`,"editor.video.invalid":`Keine YouTube-, Vimeo- oder Streamable-Adresse erkannt.`,"editor.video.provider_video":`{{provider}}-Video`,"editor.video.unavailable":`Video nicht verfügbar`}),TC(`en`,{"editor.bubble.bold":`Bold`,"editor.bubble.italic":`Italic`,"editor.bubble.link":`Link`,"editor.bubble.quick_bar":`Quick toolbar`,"editor.bubble.remove_format":`Clear formatting`,"editor.bubble.shortcut_bold":`Ctrl+B`,"editor.bubble.shortcut_italic":`Ctrl+I`,"editor.bubble.shortcut_link":`Ctrl+K`,"editor.bubble.shortcut_strike":`Ctrl+Shift+S`,"editor.bubble.shortcut_underline":`Ctrl+U`,"editor.bubble.strike":`Strikethrough`,"editor.bubble.underline":`Underline`,"editor.callout.important":`Important`,"editor.callout.note":`Note`,"editor.callout.tip":`Tip`,"editor.doc_properties.a4_landscape":`A4 landscape`,"editor.doc_properties.a4_portrait":`A4 portrait`,"editor.doc_properties.all_filled":`Everything is filled in. The document can be issued.`,"editor.doc_properties.all_required_filled":`All required entries are filled in.`,"editor.doc_properties.aside":`Side box`,"editor.doc_properties.aside_hint":`Sits within the type area, the text flows beside it. Fixed; the writer fills in any fields inside it.`,"editor.doc_properties.aside_title":`Fixed box with text wrapping`,"editor.doc_properties.band_every_page":`every page`,"editor.doc_properties.band_first_page":`page 1`,"editor.doc_properties.band_fixed":`Fixed for the writer, except for the input areas in it.`,"editor.doc_properties.band_from_second_page":`every page from page 2`,"editor.doc_properties.band_in_bottom":`Sits in the bottom margin and appears on {{pages}}.`,"editor.doc_properties.band_in_top":`Sits in the top margin and appears on {{pages}}.`,"editor.doc_properties.band_rest":`{{region}} on following pages`,"editor.doc_properties.band_variables":`Page numbers via “Variable ▾”: Page and Page count. Values from body fields via {{syntax}}.`,"editor.doc_properties.bottom":`Bottom`,"editor.doc_properties.decimals":`Decimal places`,"editor.doc_properties.detach_letterhead":`Detach from letterhead and edit here`,"editor.doc_properties.dissolve_block":`Dissolve block, the content stays`,"editor.doc_properties.dissolve_input":`Dissolve area, the text becomes fixed`,"editor.doc_properties.dissolve_snippet":`Dissolve snippet, variant 1 becomes fixed text`,"editor.doc_properties.field":`Field`,"editor.doc_properties.field_id":`ID`,"editor.doc_properties.field_required":`Required, the document cannot be issued without an entry`,"editor.doc_properties.first_bottom":`Page 1 bottom`,"editor.doc_properties.first_footer":`Separate footer on page 1`,"editor.doc_properties.first_page_different":`Different first page (own header, own margins)`,"editor.doc_properties.first_top":`Page 1 top`,"editor.doc_properties.fix_bottom":`Set bottom margin to {{mm}} mm`,"editor.doc_properties.fix_hint":`Select text in the area and choose “Fix”: the writer cannot change or delete that part.`,"editor.doc_properties.fix_top":`Set top margin to {{mm}} mm`,"editor.doc_properties.fixed":`Fixed part`,"editor.doc_properties.fixed_hint":`The writer can keep writing before and after it but cannot change or delete this part; on saving it always comes from the template.`,"editor.doc_properties.fixed_title":`Fixed within the text area`,"editor.doc_properties.footer":`Footer`,"editor.doc_properties.footer_distance":`Footer from page edge`,"editor.doc_properties.format":`Format`,"editor.doc_properties.format_basic":`Basic`,"editor.doc_properties.format_basic_hint":`Bold, italic, underline and lists.`,"editor.doc_properties.format_full":`Full`,"editor.doc_properties.format_full_hint":`Also headings, tables and alignment.`,"editor.doc_properties.format_plain":`None`,"editor.doc_properties.format_plain_hint":`Text and paragraphs only.`,"editor.doc_properties.formatting":`Formatting`,"editor.doc_properties.frame":`Border`,"editor.doc_properties.header":`Header`,"editor.doc_properties.header_distance":`Header from page edge`,"editor.doc_properties.image":`Image`,"editor.doc_properties.image_hint":`Fixed part of the template. For the PDF, the product loads the file from its own storage.`,"editor.doc_properties.image_title":`Logo or crest`,"editor.doc_properties.input_area":`Input area`,"editor.doc_properties.kind":`Type`,"editor.doc_properties.kind_choice":`Choice`,"editor.doc_properties.kind_date":`Date`,"editor.doc_properties.kind_line":`Line`,"editor.doc_properties.kind_number":`Number`,"editor.doc_properties.label":`Label`,"editor.doc_properties.left":`Left`,"editor.doc_properties.letterhead":`Letterhead`,"editor.doc_properties.letterhead_hint":`Header and footer come from the letterhead. A change there applies to every template that uses it.`,"editor.doc_properties.letterhead_none":`None, own header and footer`,"editor.doc_properties.margin_note":`The margin is not a writing area. Text, tables and side boxes stay within the type area; only the header and footer go in the margin.`,"editor.doc_properties.margins_hint":`Values in mm. Left and right can also be set on the ruler. Editor and PDF use the same values.`,"editor.doc_properties.max":`Maximum`,"editor.doc_properties.max_length":`Maximum length`,"editor.doc_properties.max_length_hint":`Empty: 500 characters`,"editor.doc_properties.min":`Minimum`,"editor.doc_properties.min_length":`Minimum length in characters`,"editor.doc_properties.missing_count_one":`{{count}} entry is still missing.`,"editor.doc_properties.missing_count_other":`{{count}} entries are still missing.`,"editor.doc_properties.no_label":`No label`,"editor.doc_properties.open":`Still open`,"editor.doc_properties.open_count":`Still open ({{n}})`,"editor.doc_properties.option_a":`Option A`,"editor.doc_properties.option_b":`Option B`,"editor.doc_properties.optional":`Optional block`,"editor.doc_properties.optional_enabled":`On at the start`,"editor.doc_properties.optional_hint":`The writer turns the block on or off.`,"editor.doc_properties.options_list":`Choices, one per line`,"editor.doc_properties.options_own":`Custom list`,"editor.doc_properties.options_source":`List from the system`,"editor.doc_properties.overflow_footer":`The footer is taller than the bottom margin. It will be cut off in the PDF.`,"editor.doc_properties.overflow_header":`The header is taller than the top margin. It will be cut off in the PDF.`,"editor.doc_properties.page":`Page`,"editor.doc_properties.page_title":`Format and margins`,"editor.doc_properties.placeholder":`Placeholder`,"editor.doc_properties.preset":`Preset`,"editor.doc_properties.preset_custom":`Custom margins`,"editor.doc_properties.preset_din":`DIN 5008 · left 25, right 20 mm`,"editor.doc_properties.preset_standard":`Standard · 20 mm all round`,"editor.doc_properties.print":`Print`,"editor.doc_properties.print_hint":`Without the markers and borders of the input areas. The PDF is binding.`,"editor.doc_properties.print_title":`How it looks on paper`,"editor.doc_properties.reason_missing":`missing`,"editor.doc_properties.reason_required":`required`,"editor.doc_properties.reason_short":`too short`,"editor.doc_properties.release":`Release`,"editor.doc_properties.remove_aside":`Remove side box`,"editor.doc_properties.remove_field":`Remove field, the label stays as text`,"editor.doc_properties.remove_region":`Remove {{region}}`,"editor.doc_properties.repeat":`Repeating block`,"editor.doc_properties.repeat_hint":`The writer can add more entries.`,"editor.doc_properties.required":`Required`,"editor.doc_properties.right":`Right`,"editor.doc_properties.side":`Side`,"editor.doc_properties.snippet":`Text snippet`,"editor.doc_properties.snippet_required":`Required, a variant must be chosen`,"editor.doc_properties.snippet_variants":`Variants, one per line as “Name: Text”`,"editor.doc_properties.start":`When created`,"editor.doc_properties.start_empty":`Empty, with placeholder`,"editor.doc_properties.start_suggestion":`With the template text as a suggestion`,"editor.doc_properties.summary":`In this template`,"editor.doc_properties.summary_fixed_one":`{{count}} fixed part in free text`,"editor.doc_properties.summary_fixed_other":`{{count}} fixed parts in free text`,"editor.doc_properties.summary_inputs_one":`{{count}} input area`,"editor.doc_properties.summary_inputs_other":`{{count}} input areas`,"editor.doc_properties.summary_required_other":`{{count}} of them required`,"editor.doc_properties.text_area":`Text area`,"editor.doc_properties.top":`Top`,"editor.doc_properties.var_example":`For example: {{value}}`,"editor.doc_properties.var_field":`Value of the field “{{field}}”`,"editor.doc_properties.var_page":`Page number, per page in the PDF`,"editor.doc_properties.var_pages":`Total number of pages`,"editor.doc_properties.var_system":`Filled in by the system on issue. The writer enters nothing here.`,"editor.doc_properties.variable":`Variable`,"editor.doc_properties.variant_n":`Variant {{n}}`,"editor.doc_properties.who_all":`Everyone who writes the document`,"editor.doc_properties.who_chooses":`Who chooses`,"editor.doc_properties.who_fills":`Who fills it in`,"editor.doc_properties.who_only":`Only with the “{{label}}” permission`,"editor.doc_properties.width":`Width`,"editor.doc_properties.write":`Fill in`,"editor.doc_properties.write_hint":`You can only write in the coloured areas. Clicking fixed text briefly shows that it is locked.`,"editor.doc_properties.write_title":`Fill in the document`,"editor.doc_ruler.left_margin":`Left margin`,"editor.doc_ruler.right_margin":`Right margin`,"editor.doc_ruler.tip_left":`Left {{mm}} mm`,"editor.doc_ruler.tip_right":`Right {{mm}} mm`,"editor.document_editor.add_footer":`Add footer`,"editor.document_editor.add_header":`Add header`,"editor.document_editor.aside":`Side box`,"editor.document_editor.fix":`Fix`,"editor.document_editor.fix_tip":`Fix the selected text in the text area (Ctrl+Shift+F)`,"editor.document_editor.footer":`Footer`,"editor.document_editor.footer_first":`Footer page 1`,"editor.document_editor.footer_rest":`Footer following pages`,"editor.document_editor.free_as_line":`Make it a line field`,"editor.document_editor.free_as_snippet":`Make it a text snippet`,"editor.document_editor.free_as_text_area":`Make it a text area`,"editor.document_editor.from_letterhead":`From the letterhead “{{name}}”`,"editor.document_editor.header":`Header`,"editor.document_editor.header_first":`Header page 1`,"editor.document_editor.header_rest":`Header following pages`,"editor.document_editor.insert_input":`Insert input area`,"editor.document_editor.kind_choice":`Choice`,"editor.document_editor.kind_choice_hint":`One value from a fixed list`,"editor.document_editor.kind_date":`Date`,"editor.document_editor.kind_date_hint":`Date with calendar`,"editor.document_editor.kind_line":`Line`,"editor.document_editor.kind_line_hint":`One line of text, no formatting`,"editor.document_editor.kind_number":`Number`,"editor.document_editor.kind_number_hint":`Digits only`,"editor.document_editor.kind_snippet":`Text snippet`,"editor.document_editor.kind_snippet_hint":`One of several predefined texts`,"editor.document_editor.kind_text":`Text area`,"editor.document_editor.kind_text_hint":`Several paragraphs, adjustable formatting`,"editor.document_editor.optional":`Optional block`,"editor.document_editor.repeat":`Repeating block`,"editor.document_editor.template":`Template`,"editor.document_editor.text":`Text`,"editor.document_editor.var_page":`Page`,"editor.document_editor.var_pages":`Page count`,"editor.document_editor.variable":`Variable`,"editor.emoji.categories":`Categories`,"editor.emoji.choose":`Choose emoji`,"editor.emoji.dialog":`Insert emoji`,"editor.emoji.failed":`Emojis could not be loaded.`,"editor.emoji.hits_one":`{{count}} result`,"editor.emoji.hits_other":`{{count}} results`,"editor.emoji.loading":`Loading emojis …`,"editor.emoji.none":`No emoji found`,"editor.emoji.recent":`Recently used`,"editor.emoji.search":`Search emoji`,"editor.emoji.tip":`Tip: search in the text with a colon, like :thumbs`,"editor.emoji.tone":`Skin tone`,"editor.emoji.tone_0":`Default`,"editor.emoji.tone_1":`Light`,"editor.emoji.tone_2":`Medium-light`,"editor.emoji.tone_3":`Medium`,"editor.emoji.tone_4":`Medium-dark`,"editor.emoji.tone_5":`Dark`,"editor.emoji.tone_current":`Skin tone: {{tone}}`,"editor.index.placeholder":`Write here…`,"editor.inputs.add_another":`{{label}}: add another`,"editor.inputs.add_another_tip":`Add another “{{label}}” entry`,"editor.inputs.aside":`Side box`,"editor.inputs.aside_fixed":`Side box · fixed`,"editor.inputs.choose_snippet":`Choose {{label}}`,"editor.inputs.entry":`Entry`,"editor.inputs.field":`Field`,"editor.inputs.filled_by":`Filled in by: {{who}}`,"editor.inputs.fixed":`fixed`,"editor.inputs.fixed_tip":`Fixed part: the writer can neither change nor delete it`,"editor.inputs.from_template":`From the template, cannot be changed`,"editor.inputs.locked":`locked`,"editor.inputs.only_who":`only: {{who}}`,"editor.inputs.only_who_tip":`Can only be filled in with the “{{who}}” permission`,"editor.inputs.option_a":`Option A`,"editor.inputs.option_b":`Option B`,"editor.inputs.optional":`Optional`,"editor.inputs.optional_block":`Optional block`,"editor.inputs.remove":`Remove`,"editor.inputs.remove_tip":`Remove this entry “{{label}}”`,"editor.inputs.repeatable":`Repeatable`,"editor.inputs.required":`Required`,"editor.inputs.snippet":`Text snippet`,"editor.inputs.text_area":`Text area`,"editor.inputs.variant_n":`Variant {{n}}`,"editor.inputs.variants_one":`{{count}} variant: {{names}}`,"editor.inputs.variants_other":`{{count}} variants: {{names}}`,"editor.link_balloon.address":`Link address`,"editor.link_balloon.apply":`Apply`,"editor.link_balloon.cancel":`Cancel`,"editor.link_balloon.edit_link":`Edit link`,"editor.link_balloon.invalid":`Only http, https or mailto are allowed.`,"editor.link_balloon.remove":`Remove link`,"editor.page_markers.estimate":`Estimated page layout. The PDF preview is binding.`,"editor.section_view.add_another":`{{title}}: add another`,"editor.section_view.add_another_tip":`Add another “{{title}}” entry`,"editor.section_view.free":`Free`,"editor.section_view.free_tip":`Free section: can be written freely in the document`,"editor.section_view.from_template":`From the template, cannot be changed`,"editor.section_view.locked":`Locked`,"editor.section_view.locked_tip":`Locked section: only the fields can be filled in in the document`,"editor.section_view.remove":`Remove`,"editor.section_view.remove_tip":`Remove this entry “{{title}}”`,"editor.section_view.repeatable":`Repeatable`,"editor.section_view.section":`Section`,"editor.toolbar.align_center":`Centre`,"editor.toolbar.align_justify":`Justify`,"editor.toolbar.align_left":`Align left`,"editor.toolbar.align_right":`Align right`,"editor.toolbar.alignment":`Alignment`,"editor.toolbar.blockquote":`Quote`,"editor.toolbar.bold":`Bold`,"editor.toolbar.bullet_list":`Bulleted list`,"editor.toolbar.callout":`Callout`,"editor.toolbar.callout_remove":`Remove callout`,"editor.toolbar.emoji":`Insert emoji`,"editor.toolbar.font":`Font`,"editor.toolbar.font_default":`Default`,"editor.toolbar.heading_1":`Heading 1`,"editor.toolbar.heading_2":`Heading 2`,"editor.toolbar.heading_3":`Heading 3`,"editor.toolbar.horizontal_rule":`Insert horizontal line`,"editor.toolbar.image":`Insert image`,"editor.toolbar.instance_add":`Repeat section`,"editor.toolbar.instance_remove":`Remove section`,"editor.toolbar.instances":`Repeatable sections`,"editor.toolbar.italic":`Italic`,"editor.toolbar.link":`Link`,"editor.toolbar.ordered_list":`Numbered list`,"editor.toolbar.page_break":`Insert page break`,"editor.toolbar.paragraph":`Paragraph`,"editor.toolbar.paragraph_format":`Paragraph format`,"editor.toolbar.preview":`Preview`,"editor.toolbar.preview_tip":`Preview: how the document looks when printed`,"editor.toolbar.redo":`Redo`,"editor.toolbar.section_free":`Insert section (free)`,"editor.toolbar.section_free_text":`+ Free`,"editor.toolbar.section_locked":`Insert section (locked)`,"editor.toolbar.section_locked_text":`+ Locked`,"editor.toolbar.section_mode":`Switch mode`,"editor.toolbar.section_mode_text":`Mode`,"editor.toolbar.sections":`Sections`,"editor.toolbar.shortcut_bold":`Ctrl+B`,"editor.toolbar.shortcut_italic":`Ctrl+I`,"editor.toolbar.shortcut_link":`Ctrl+K`,"editor.toolbar.shortcut_redo":`Ctrl+Y`,"editor.toolbar.shortcut_strike":`Ctrl+Shift+S`,"editor.toolbar.shortcut_underline":`Ctrl+U`,"editor.toolbar.shortcut_undo":`Ctrl+Z`,"editor.toolbar.strike":`Strikethrough`,"editor.toolbar.style":`Style`,"editor.toolbar.style_block":`Paragraph`,"editor.toolbar.style_inline":`Selected text`,"editor.toolbar.style_none":`No style`,"editor.toolbar.table":`Table`,"editor.toolbar.table_column_after":`Insert column right`,"editor.toolbar.table_column_before":`Insert column left`,"editor.toolbar.table_column_delete":`Delete column`,"editor.toolbar.table_delete":`Delete table`,"editor.toolbar.table_insert":`Insert table (3×3)`,"editor.toolbar.table_row_after":`Insert row below`,"editor.toolbar.table_row_before":`Insert row above`,"editor.toolbar.table_row_delete":`Delete row`,"editor.toolbar.text_formatting":`Text formatting`,"editor.toolbar.underline":`Underline`,"editor.toolbar.undo":`Undo`,"editor.toolbar.video":`Embed video`,"editor.variable_suggestion.choose":`Choose a variable`,"editor.variable_suggestion.no_results":`No matches`,"editor.variable_view.filled":`Filled in automatically: {{label}}`,"editor.variable_view.missing":`There is no value for “{{label}}”.`,"editor.variable_view.missing_prefix":`missing: `,"editor.variable_view.placeholder":`Placeholder {{token}}: replaced by {{label}} when filled in`,"editor.variable_view.unknown":`Unknown placeholder {{token}}`,"editor.video.address":`YouTube, Vimeo or Streamable address`,"editor.video.cancel":`Cancel`,"editor.video.embed":`Embed video`,"editor.video.insert":`Insert`,"editor.video.invalid":`No YouTube, Vimeo or Streamable address recognised.`,"editor.video.provider_video":`{{provider}} video`,"editor.video.unavailable":`Video unavailable`});var kC=new WeakMap,AC=0;function jC(e){let t=kC.get(e);return t||(t=MC(e),kC.set(e,t)),t}function MC(e){let t=++AC,n=document.createElement(`div`);n.className=`efe-balloon`,n.setAttribute(`role`,`dialog`),n.setAttribute(`aria-label`,X(`editor.link_balloon.edit_link`)),n.dataset.state=`closed`;let r=document.createElement(`label`);r.className=`efe-balloon__label`,r.htmlFor=`efe-link-input-${t}`,r.textContent=X(`editor.link_balloon.address`);let i=document.createElement(`input`);i.type=`text`,i.id=`efe-link-input-${t}`,i.className=`efe-balloon__input`,i.placeholder=`https://`,i.autocomplete=`off`,i.spellcheck=!1,i.setAttribute(`inputmode`,`url`);let a=document.createElement(`span`);a.id=`efe-link-error-${t}`,a.className=`efe-balloon__error`,a.textContent=X(`editor.link_balloon.invalid`),a.hidden=!0,i.setAttribute(`aria-describedby`,a.id);let o=NC(`check`,X(`editor.link_balloon.apply`),`efe-btn efe-btn--primary`);o.dataset.efeCommand=`applyLink`;let s=NC(`unlink`,X(`editor.link_balloon.remove`));s.dataset.efeCommand=`unsetLink`;let c=NC(`close`,X(`editor.link_balloon.cancel`)),l=document.createElement(`div`);l.className=`efe-balloon__row`,l.append(i,o,s,c),n.append(r,l,a);let u=!1;function d(e){e?i.setAttribute(`aria-invalid`,`true`):i.removeAttribute(`aria-invalid`),a.hidden=!e}function f(){let{view:t,state:r}=e;fC({getBoundingClientRect:()=>ud(t,r.selection.from,r.selection.to),contextElement:t.dom},n,{placement:`bottom`,middleware:[iC(8),sC(),oC({padding:8})]}).then(({x:e,y:t})=>{n.style.left=`${e}px`,n.style.top=`${t}px`}).catch(()=>{})}function p(e){n.contains(e.target)||m(!1)}function m(t=!0){u&&(u=!1,SC(n,()=>n.remove()),document.removeEventListener(`mousedown`,p,!0),t&&!e.isDestroyed&&e.commands.focus())}function h(){e.isEditable&&e.schema.marks.link&&(i.value=e.getAttributes(`link`).href??``,s.hidden=!e.isActive(`link`),d(!1),u||(u=!0,CC(n),n.dataset.state=`open`,(e.view.dom.parentElement??document.body).appendChild(n),document.addEventListener(`mousedown`,p,!0)),f(),i.focus(),i.select())}function g(){let t=i.value.trim();t?vC(t)?(e.state.selection.empty&&!e.isActive(`link`)?e.chain().focus().insertContent({type:`text`,text:t,marks:[{type:`link`,attrs:bC(t)}]}).run():e.chain().focus().extendMarkRange(`link`).setLink(bC(t)).run(),m(!1)):d(!0):m()}return o.addEventListener(`click`,g),s.addEventListener(`click`,()=>{e.chain().focus().extendMarkRange(`link`).unsetLink().run(),m(!1)}),c.addEventListener(`click`,()=>m()),i.addEventListener(`input`,()=>d(!1)),n.addEventListener(`keydown`,e=>{e.key===`Enter`&&e.target===i?(e.preventDefault(),g()):e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),m())}),e.on(`destroy`,()=>m(!1)),{open:h,close:m,isOpen:()=>u,element:n}}function NC(e,t,n=`efe-btn`){let r=document.createElement(`button`);return r.type=`button`,r.className=n,r.setAttribute(`aria-label`,t),Y(r,t),r.appendChild(sx(e)),r}var PC=V.create({name:`efeLinkShortcut`,addKeyboardShortcuts(){return{"Mod-k":()=>(jC(this.editor).open(),!0)}}}),FC=/^\/(?!\/)[A-Za-z0-9\-._~/%]*\.(?:png|jpe?g|gif|webp|svg)(?:\?[A-Za-z0-9\-._~=&%]*)?$/i,IC=2048;function LC(e){return typeof e==`string`&&e.length<=IC&&FC.test(e)}var RC=H.create({name:`image`,group:`inline`,inline:!0,atom:!0,selectable:!0,draggable:!1,addAttributes(){return{src:{default:null,renderHTML:e=>LC(e.src)?{src:e.src}:{}},alt:{default:``,parseHTML:e=>e.getAttribute(`alt`)??``}}},parseHTML(){return[{tag:`img.efe-image`,getAttrs:e=>LC(e.getAttribute(`src`))?null:!1}]},renderHTML({HTMLAttributes:e}){return[`img`,B({class:`efe-image`},e)]},addKeyboardShortcuts(){return{Backspace:({editor:e})=>{let{selection:t}=e.state;if(!t.empty||t.$from.nodeBefore?.type.name!==this.name)return!1;let n=t.from-t.$from.nodeBefore.nodeSize;return e.commands.deleteRange({from:n,to:t.from})}}}}),zC=H.create({name:`imageBlock`,group:`block`,atom:!0,selectable:!0,draggable:!1,addOptions(){return{upload:null}},addAttributes(){return{src:{default:null},alt:{default:``}}},parseHTML(){return[{tag:`figure.efe-figure`,getAttrs:e=>{let t=e.querySelector(`img`),n=t?.getAttribute(`src`);return LC(n)?{src:n,alt:t.getAttribute(`alt`)??``}:!1}}]},renderHTML({node:e}){let t={alt:e.attrs.alt??``};return LC(e.attrs.src)&&(t.src=e.attrs.src),[`figure`,{class:`efe-figure`},[`img`,t]]},addCommands(){return{insertImageBlock:e=>({commands:t})=>LC(e?.src)&&t.insertContent({type:this.name,attrs:{src:e.src,alt:e.alt??``}})}}}),BC=Object.freeze([{value:`note`,get label(){return X(`editor.callout.note`)}},{value:`important`,get label(){return X(`editor.callout.important`)}},{value:`tip`,get label(){return X(`editor.callout.tip`)}}]),VC=BC.map(e=>e.value);function HC(e){return BC.find(t=>t.value===e)?.label??BC[0].label}var UC=H.create({name:`callout`,group:`block`,defining:!0,addOptions(){return{blocks:[`paragraph`]}},content(){return`(${this.options.blocks.join(` | `)})+`},addAttributes(){return{variant:{default:`note`,parseHTML:e=>VC.includes(e.dataset.variant)?e.dataset.variant:`note`,renderHTML:e=>({"data-variant":VC.includes(e.variant)?e.variant:`note`})}}},parseHTML(){return[{tag:`aside.efe-callout`}]},renderHTML({node:e,HTMLAttributes:t}){let n=VC.includes(e.attrs.variant)?e.attrs.variant:`note`;return[`aside`,{...t,class:`efe-callout efe-callout--${n}`,role:`note`,"aria-label":HC(n)},0]},addCommands(){return{setCallout:e=>({commands:t,editor:n})=>VC.includes(e)?n.isActive(this.name)?t.updateAttributes(this.name,{variant:e}):t.wrapIn(this.name,{variant:e}):!1,unsetCallout:()=>({commands:e})=>e.lift(this.name)}}}),WC=/^[A-Za-z0-9_-]{11}$/,GC=/^\d{1,12}$/,KC=/^[a-f0-9]{6,20}$/,qC=/^[A-Za-z0-9]{1,16}$/,JC=Object.freeze({youtube:`YouTube`,vimeo:`Vimeo`,streamable:`Streamable`});function YC(e){if(!e||typeof e!=`object`)return!1;let{provider:t,id:n,hash:r=null}=e;return t===`youtube`?typeof n==`string`&&WC.test(n)&&r===null:t===`vimeo`?typeof n==`string`&&GC.test(n)&&(r===null||typeof r==`string`&&KC.test(r)):t===`streamable`&&typeof n==`string`&&qC.test(n)&&r===null}function XC(e){let t;try{t=new URL(String(e).trim())}catch{return null}if(t.protocol!==`https:`&&t.protocol!==`http:`)return null;let n=t.hostname.toLowerCase().replace(/^(www\.|m\.)/,``),r=t.pathname.split(`/`).filter(Boolean),i=null;if(n===`youtu.be`)i={provider:`youtube`,id:r[0],hash:null};else if(n===`youtube.com`||n===`youtube-nocookie.com`)i={provider:`youtube`,id:r[0]===`watch`||r.length===0?t.searchParams.get(`v`):[`embed`,`shorts`,`live`,`v`].includes(r[0])?r[1]:null,hash:null};else if(n===`vimeo.com`||n===`player.vimeo.com`){let e=r[0]===`video`?r.slice(1):r;i={provider:`vimeo`,id:e[0],hash:e[1]??t.searchParams.get(`h`)??null}}else n===`streamable.com`&&(i={provider:`streamable`,id:[`e`,`o`,`s`].includes(r[0])?r[1]:r.length===1?r[0]:null,hash:null});return i&&YC(i)?i:null}var ZC=H.create({name:`video`,group:`block`,atom:!0,selectable:!0,draggable:!1,addAttributes(){return{provider:{default:null},id:{default:null},hash:{default:null}}},parseHTML(){return[{tag:`figure.efe-video`,getAttrs:e=>{let t={provider:e.dataset.provider,id:e.dataset.id,hash:e.dataset.hash??null};return YC(t)?t:!1}}]},renderHTML({node:e}){if(!YC(e.attrs))return[`figure`,{class:`efe-video efe-video--invalid`},[`figcaption`,{},X(`editor.video.unavailable`)]];let{provider:t,id:n,hash:r}=e.attrs;return[`figure`,{class:`efe-video`,"data-provider":t,"data-id":n,...r?{"data-hash":r}:{}},[`span`,{class:`efe-video__play`,"aria-hidden":`true`}],[`figcaption`,{class:`efe-video__note`},X(`editor.video.provider_video`,{provider:JC[t]})]]},addCommands(){return{insertVideo:e=>({commands:t})=>YC({hash:null,...e})&&t.insertContent({type:this.name,attrs:{hash:null,...e}})}}}),QC=new WeakMap,$C=0;function ew(e){let t=QC.get(e);return t||(t=tw(e),QC.set(e,t)),t}function tw(e){let t=++$C,n=document.createElement(`div`);n.className=`efe-balloon`,n.setAttribute(`role`,`dialog`),n.setAttribute(`aria-label`,X(`editor.video.embed`)),n.dataset.state=`closed`;let r=document.createElement(`label`);r.className=`efe-balloon__label`,r.htmlFor=`efe-video-input-${t}`,r.textContent=X(`editor.video.address`);let i=document.createElement(`input`);i.type=`text`,i.id=`efe-video-input-${t}`,i.className=`efe-balloon__input`,i.placeholder=`https://www.youtube.com/watch?v=…`,i.autocomplete=`off`,i.spellcheck=!1,i.setAttribute(`inputmode`,`url`);let a=document.createElement(`span`);a.id=`efe-video-error-${t}`,a.className=`efe-balloon__error`,a.textContent=X(`editor.video.invalid`),a.hidden=!0,i.setAttribute(`aria-describedby`,a.id);let o=nw(`check`,X(`editor.video.insert`),`efe-btn efe-btn--primary`);o.dataset.efeCommand=`applyVideo`;let s=nw(`close`,X(`editor.video.cancel`)),c=document.createElement(`div`);c.className=`efe-balloon__row`,c.append(i,o,s),n.append(r,c,a);let l=!1;function u(e){i.toggleAttribute(`aria-invalid`,e),a.hidden=!e}function d(){let{view:t,state:r}=e;fC({getBoundingClientRect:()=>ud(t,r.selection.from,r.selection.to),contextElement:t.dom},n,{placement:`bottom`,middleware:[iC(8),sC(),oC({padding:8})]}).then(({x:e,y:t})=>{n.style.left=`${e}px`,n.style.top=`${t}px`}).catch(()=>{})}function f(e){n.contains(e.target)||p(!1)}function p(t=!0){l&&(l=!1,SC(n,()=>n.remove()),document.removeEventListener(`mousedown`,f,!0),t&&!e.isDestroyed&&e.commands.focus())}function m(){e.isEditable&&e.schema.nodes.video&&(i.value=``,u(!1),l||(l=!0,CC(n),n.dataset.state=`open`,(e.view.dom.parentElement??document.body).appendChild(n),document.addEventListener(`mousedown`,f,!0)),d(),i.focus())}function h(){let t=XC(i.value);t?(e.chain().focus().insertVideo(t).run(),p(!1)):u(!0)}return o.addEventListener(`click`,h),s.addEventListener(`click`,()=>p()),i.addEventListener(`input`,()=>u(!1)),n.addEventListener(`keydown`,e=>{e.key===`Enter`&&e.target===i?(e.preventDefault(),h()):e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),p())}),e.on(`destroy`,()=>p(!1)),{open:m,close:p,isOpen:()=>l,element:n}}function nw(e,t,n=`efe-btn`){let r=document.createElement(`button`);return r.type=`button`,r.className=n,r.setAttribute(`aria-label`,t),Y(r,t),r.appendChild(sx(e)),r}function rw(e){return{groups:e.groups,emojis:e.emojis.map(([e,t,n,r,i])=>({unicode:e,label:t,group:r,skins:i,search:ow(`${t} ${n}`)}))}}var iw=new Map;function aw(e){if(!iw.has(e)){let t=fetch(e,{credentials:`same-origin`}).then(e=>{if(!e.ok)throw Error(`Emoji-Daten nicht geladen (${e.status})`);return e.json()}).then(rw);t.catch(()=>iw.delete(e)),iw.set(e,t)}return iw.get(e)}function ow(e){return e.toLowerCase().replaceAll(`ß`,`ss`).normalize(`NFD`).replace(/[̀-ͯ]/g,``)}function sw(e,t,n=1/0){let r=ow(t).trim().split(/\s+/).filter(Boolean);if(r.length===0)return[];let i=[];for(let t of e)r.every(e=>t.search.includes(e))&&i.push({emoji:t,rank:cw(t,r[0])});return i.sort((e,t)=>e.rank-t.rank).slice(0,n).map(e=>e.emoji)}function cw(e,t){let n=ow(e.label);return n.startsWith(t)?0:n.split(/[\s:,-]+/).some(e=>e.startsWith(t))?1:e.search.split(` `).some(e=>e.startsWith(t))?2:3}function lw(e,t){return t>0&&e.skins[t-1]||e.unicode}var uw=`efe-emoji-recent`,dw=`efe-emoji-tone`,fw=24;function pw(){try{let e=JSON.parse(localStorage.getItem(uw)??`[]`);return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}catch{return[]}}function mw(e){try{let t=[e,...pw().filter(t=>t!==e)].slice(0,fw);localStorage.setItem(uw,JSON.stringify(t))}catch{}}function hw(){try{let e=Number(localStorage.getItem(dw));return Number.isInteger(e)&&e>=0&&e<=5?e:0}catch{return 0}}function gw(e){try{localStorage.setItem(dw,String(e))}catch{}}var _w={0:`😀`,1:`👋`,3:`🐻`,4:`🍔`,5:`🚒`,6:`⚽`,7:`💡`,8:`🔣`,9:`🏁`},vw=[`✋`,`✋🏻`,`✋🏼`,`✋🏽`,`✋🏾`,`✋🏿`],yw=e=>[X(`editor.emoji.tone_0`),X(`editor.emoji.tone_1`),X(`editor.emoji.tone_2`),X(`editor.emoji.tone_3`),X(`editor.emoji.tone_4`),X(`editor.emoji.tone_5`)][e],bw=new WeakMap,xw=0;function Sw(e){let t=bw.get(e);return t||(t=Cw(e),bw.set(e,t)),t}function Cw(e){let t=++xw,n=()=>e.extensionManager.extensions.find(e=>e.name===`emoji`)?.options.data,r=document.createElement(`div`);r.className=`efe-balloon efe-emoji`,r.setAttribute(`role`,`dialog`),r.setAttribute(`aria-label`,X(`editor.emoji.dialog`)),r.dataset.state=`closed`;let i=document.createElement(`input`);i.type=`search`,i.className=`efe-balloon__input efe-emoji__search`,i.placeholder=X(`editor.emoji.search`),i.setAttribute(`aria-label`,X(`editor.emoji.search`)),i.autocomplete=`off`,i.spellcheck=!1;let a=document.createElement(`button`);a.type=`button`,a.className=`efe-btn efe-emoji__tone`,a.setAttribute(`aria-haspopup`,`true`),a.setAttribute(`aria-expanded`,`false`);let o=document.createElement(`div`);o.className=`efe-emoji__tones`,o.setAttribute(`role`,`radiogroup`),o.setAttribute(`aria-label`,X(`editor.emoji.tone`)),o.hidden=!0;let s=document.createElement(`div`);s.className=`efe-balloon__row`,s.append(i,a);let c=document.createElement(`div`);c.className=`efe-emoji__tabs`,c.setAttribute(`role`,`tablist`),c.setAttribute(`aria-label`,X(`editor.emoji.categories`));let l=document.createElement(`div`);l.className=`efe-emoji__body`,l.id=`efe-emoji-body-${t}`;let u=document.createElement(`div`);u.className=`efe-emoji__footer`,u.setAttribute(`aria-live`,`polite`),r.append(s,o,c,l,u);let d=!1,f=null,p=hw(),m=new Map;function h(e,t=lw(e,p)){let n=document.createElement(`button`);return n.type=`button`,n.className=`efe-emoji__cell`,n.textContent=t,n.dataset.efeEmoji=t,n.setAttribute(`aria-label`,e.label),n.tabIndex=-1,n}function g(e,t,n,r){let i=document.createElement(`section`);i.className=`efe-emoji__section`,n!==void 0&&(i.dataset.efeGroup=String(n));let a=document.createElement(`div`);a.className=`efe-emoji__title`,a.textContent=e;let o=document.createElement(`div`);return o.className=`efe-emoji__grid`,o.setAttribute(`role`,`group`),o.setAttribute(`aria-label`,e),t.forEach((e,t)=>o.appendChild(h(e,r?.[t]))),i.append(a,o),i}function _(){c.replaceChildren();let e=[{key:`recent`,label:X(`editor.emoji.recent`),glyph:null},...f.groups.map(e=>({key:String(e.id),label:e.label,glyph:_w[e.id]??`•`}))];for(let t of e){let e=document.createElement(`button`);e.type=`button`,e.className=`efe-emoji__tab`,e.setAttribute(`role`,`tab`),e.setAttribute(`aria-controls`,l.id),e.setAttribute(`aria-label`,t.label),e.dataset.efeTab=t.key,Y(e,t.label),t.glyph?e.textContent=t.glyph:e.appendChild(sx(`clock`)),e.addEventListener(`click`,()=>{i.value=``,y();let e=l.querySelector(`[data-efe-group="${t.key}"]`);e&&(l.scrollTop+=e.getBoundingClientRect().top-l.getBoundingClientRect().top),v()}),c.appendChild(e)}}function v(){let e=l.getBoundingClientRect().top+4,t=null;for(let n of l.querySelectorAll(`[data-efe-group]`))n.getBoundingClientRect().top<=e&&(t=n.dataset.efeGroup);t??=l.querySelector(`[data-efe-group]`)?.dataset.efeGroup;for(let e of c.children)e.setAttribute(`aria-selected`,String(e.dataset.efeTab===t&&i.value.trim()===``))}function y(){l.replaceChildren();let e=pw().map(e=>[e,m.get(e)]).filter(([,e])=>e);if(e.length>0){let t=g(X(`editor.emoji.recent`),e.map(([,e])=>e),void 0,e.map(([e])=>e));t.dataset.efeGroup=`recent`,l.appendChild(t)}for(let e of f.groups)l.appendChild(g(e.label,f.emojis.filter(t=>t.group===e.id),e.id));c.querySelector(`[data-efe-tab="recent"]`).hidden=e.length===0,l.scrollTop=0,x(null),v()}function b(e){let t=sw(f.emojis,e);if(l.replaceChildren(),t.length===0){let e=document.createElement(`p`);e.className=`efe-emoji__empty`,e.textContent=X(`editor.emoji.none`),l.appendChild(e)}else l.appendChild(g(X(`editor.emoji.hits`,{count:t.length}),t));l.scrollTop=0,x(t[0]??null),v()}function x(e,t){if(u.replaceChildren(),!e){u.textContent=X(`editor.emoji.tip`);return}let n=document.createElement(`span`);n.className=`efe-emoji__preview`,n.textContent=t??lw(e,p);let r=document.createElement(`span`);r.textContent=e.label,u.append(n,r)}function S(){a.textContent=vw[p];let e=X(`editor.emoji.tone_current`,{tone:yw(p)});a.setAttribute(`aria-label`,e),Y(a,e),o.replaceChildren(...vw.map((e,t)=>{let n=document.createElement(`button`);return n.type=`button`,n.className=`efe-emoji__cell`,n.setAttribute(`role`,`radio`),n.setAttribute(`aria-checked`,String(t===p)),n.setAttribute(`aria-label`,yw(t)),n.textContent=e,n.addEventListener(`click`,()=>{p=t,gw(p),C(!1),S(),w()}),n}))}function C(e){o.hidden=!e,a.setAttribute(`aria-expanded`,String(e)),e&&o.querySelector(`[aria-checked="true"]`)?.focus()}function w(){f&&(i.value.trim()?b(i.value):y())}function T(t){mw(t),e.view.focus(),e.chain().focus().insertContent(t).run(),D(!1)}function ee(){let{view:t,state:n}=e;fC({getBoundingClientRect:()=>ud(t,n.selection.from,n.selection.to),contextElement:t.dom},r,{placement:`bottom-start`,middleware:[iC(8),sC(),oC({padding:8})]}).then(({x:e,y:t})=>{r.style.left=`${e}px`,r.style.top=`${t}px`}).catch(()=>{})}function E(e){r.contains(e.target)||D(!1)}function D(t=!0){d&&(d=!1,C(!1),SC(r,()=>r.remove()),document.removeEventListener(`mousedown`,E,!0),t&&!e.isDestroyed&&e.commands.focus())}function te(){let t=n();e.isEditable&&t&&(i.value=``,d||(d=!0,CC(r),r.dataset.state=`open`,(e.view.dom.parentElement??document.body).appendChild(r),document.addEventListener(`mousedown`,E,!0)),S(),ee(),i.focus(),f?y():(l.replaceChildren(),u.textContent=X(`editor.emoji.loading`),aw(t).then(e=>{f=e,m=new Map;for(let e of f.emojis){m.set(e.unicode,e);for(let t of e.skins)m.set(t,e)}_(),d&&w()},()=>{u.textContent=X(`editor.emoji.failed`)})))}function ne(){return Array.from(l.querySelectorAll(`.efe-emoji__cell`))}function re(e,t){let n=ne();if(n.length===0)return;let r=n.indexOf(e);if(r===-1){n[0].focus();return}let a=Array.from(e.parentElement.children),o=a.indexOf(e),s=null;t===`ArrowRight`?s=n[r+1]:t===`ArrowLeft`?s=n[r-1]:t===`ArrowDown`?s=a[o+9]??n[r-o+a.length]??null:t===`ArrowUp`&&(s=o>=9?a[o-9]:n[r-o-1]??null),s?s.focus():t===`ArrowUp`&&i.focus()}i.addEventListener(`input`,w),i.addEventListener(`keydown`,e=>{if(e.key===`Enter`){e.preventDefault();let t=l.querySelector(`.efe-emoji__cell`);t&&T(t.dataset.efeEmoji)}else e.key===`ArrowDown`&&(e.preventDefault(),ne()[0]?.focus())}),l.addEventListener(`mousedown`,e=>{e.target.closest(`.efe-emoji__cell`)&&e.preventDefault()}),l.addEventListener(`click`,e=>{let t=e.target.closest(`.efe-emoji__cell`);t&&T(t.dataset.efeEmoji)});let ie=e=>{let t=e.target.closest?.(`.efe-emoji__cell`);t&&l.contains(t)&&x(m.get(t.dataset.efeEmoji),t.dataset.efeEmoji)};return l.addEventListener(`mouseover`,ie),l.addEventListener(`focusin`,ie),l.addEventListener(`scroll`,v,{passive:!0}),l.addEventListener(`keydown`,e=>{[`ArrowRight`,`ArrowLeft`,`ArrowDown`,`ArrowUp`].includes(e.key)&&(e.preventDefault(),re(document.activeElement,e.key))}),a.addEventListener(`click`,()=>C(o.hidden)),r.addEventListener(`keydown`,e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),o.hidden?D():(C(!1),a.focus()))}),e.on(`destroy`,()=>D(!1)),{open:te,close:D,isOpen:()=>d,element:r}}var ww=new WeakMap;function Tw(e){let t=e.view.dom;return t.closest(`.efe-page`)??t}function Ew(e){return ww.has(e)}function Dw(e,t){let n=t===void 0?!Ew(e):!!t;if(n===Ew(e))return n;if(n)ww.set(e,e.isEditable),e.setEditable(!1);else{let t=ww.get(e);ww.delete(e),e.setEditable(t!==!1)}return Tw(e).classList.toggle(`efe-page--preview`,n),e.view.dom.classList.toggle(`efe-preview`,n),e.emit(`efe-preview`,{editor:e,preview:n}),e.view.dispatch(e.state.tr.setMeta(`efePreview`,n)),n}var Ow=`efs-`,kw=[`paragraph`,`heading`];function Aw(e){return Array.isArray(e)?e.filter(e=>typeof e?.key==`string`&&/^[a-z][a-z0-9-]{0,31}$/.test(e.key)&&typeof e.label==`string`&&(e.kind===`block`||e.kind===`inline`)):[]}function jw(){let e=typeof document>`u`?null:document.querySelector(`meta[name="efe-styles"]`);if(!e)return[];try{return JSON.parse(e.getAttribute(`content`)??`[]`)}catch{return[]}}var Mw=Zb.extend({parseHTML(){return[...this.parent?.()??[],{tag:`span`,consuming:!1,getAttrs:e=>!e.hasAttribute(`style`)&&[...e.classList].some(e=>e.startsWith(`efs-`))?{}:!1}]}}),Nw=V.create({name:`editorStyles`,addGlobalAttributes(){return[{types:[...kw,`textStyle`],attributes:{styleClass:{default:null,parseHTML:e=>[...e.classList].find(e=>e.startsWith(`efs-`))?.slice(4)??null,renderHTML:e=>e.styleClass?{class:Ow+e.styleClass}:{}}}}]},addCommands(){return{setBlockStyle:e=>({chain:t})=>kw.reduce((t,n)=>t.updateAttributes(n,{styleClass:e}),t()).run(),setInlineStyle:e=>({chain:t})=>t().setMark(`textStyle`,{styleClass:e}).removeEmptyTextStyle().run(),unsetStyles:()=>({chain:e})=>kw.reduce((e,t)=>e.updateAttributes(t,{styleClass:null}),e()).setMark(`textStyle`,{styleClass:null}).removeEmptyTextStyle().run()}}});function Pw(e){return{block:kw.map(t=>e.getAttributes(t).styleClass).find(Boolean)??null,inline:e.getAttributes(`textStyle`).styleClass??null}}var Fw=()=>[{level:0,label:X(`editor.toolbar.paragraph`)},{level:1,label:X(`editor.toolbar.heading_1`)},{level:2,label:X(`editor.toolbar.heading_2`)},{level:3,label:X(`editor.toolbar.heading_3`)}],Iw=()=>[{value:`left`,label:X(`editor.toolbar.align_left`),icon:`alignLeft`},{value:`center`,label:X(`editor.toolbar.align_center`),icon:`alignCenter`},{value:`right`,label:X(`editor.toolbar.align_right`),icon:`alignRight`},{value:`justify`,label:X(`editor.toolbar.align_justify`),icon:`alignJustify`}],Lw=[`undo`,`redo`,`formatSelect`,`fontFamily`,`style`,`bold`,`italic`,`underline`,`strike`,`link`,`emoji`,`bulletList`,`orderedList`,`blockquote`,`align`,`table`,`image`,`callout`,`video`,`horizontalRule`,`pageBreak`,`sectionTools`,`preview`],Rw=[`formatSelect`,`bold`,`italic`,`strike`,`bulletList`,`orderedList`,`table`,`align`,`pageBreak`,`link`,`sectionTools`,`preview`],zw={undo:`history`,redo:`history`,formatSelect:`format`,fontFamily:`format`,style:`format`,bold:`marks`,italic:`marks`,underline:`marks`,strike:`marks`,link:`link`,emoji:`link`,bulletList:`blocks`,orderedList:`blocks`,blockquote:`blocks`,align:`align`,table:`insert`,image:`insert`,callout:`insert`,video:`insert`,horizontalRule:`insert`,pageBreak:`insert`,sectionTools:`sections`,instanceTools:`instances`,preview:`view`},Bw={undo:(e,t)=>Kw(e,t,{command:`undo`,icon:`undo`,label:X(`editor.toolbar.undo`),shortcut:X(`editor.toolbar.shortcut_undo`)}),redo:(e,t)=>Kw(e,t,{command:`redo`,icon:`redo`,label:X(`editor.toolbar.redo`),shortcut:X(`editor.toolbar.shortcut_redo`)}),formatSelect:(e,t)=>e.schema.nodes.heading?Yw(e,t):null,fontFamily:(e,t,{fonts:n=[]})=>e.schema.marks.textStyle&&n.length>0?Xw(e,t,n):null,style:(e,t,{styles:n=[]})=>Hw(e,`editorStyles`)&&n.length>0?Zw(e,t,n):null,bold:(e,t)=>Uw(e,t,`bold`,X(`editor.toolbar.bold`),X(`editor.toolbar.shortcut_bold`)),italic:(e,t)=>Uw(e,t,`italic`,X(`editor.toolbar.italic`),X(`editor.toolbar.shortcut_italic`)),underline:(e,t)=>Uw(e,t,`underline`,X(`editor.toolbar.underline`),X(`editor.toolbar.shortcut_underline`)),strike:(e,t)=>Uw(e,t,`strike`,X(`editor.toolbar.strike`),X(`editor.toolbar.shortcut_strike`)),link:(e,t)=>e.schema.marks.link?eT(e,t):null,bulletList:(e,t)=>Ww(e,t,`bulletList`,`toggleBulletList`,X(`editor.toolbar.bullet_list`)),orderedList:(e,t)=>Ww(e,t,`orderedList`,`toggleOrderedList`,X(`editor.toolbar.ordered_list`)),blockquote:(e,t)=>Ww(e,t,`blockquote`,`toggleBlockquote`,X(`editor.toolbar.blockquote`)),align:(e,t)=>Hw(e,`textAlign`)?Qw(e,t):null,table:(e,t)=>e.schema.nodes.table?$w(e,t):null,image:(e,t)=>tT(e,t),callout:(e,t)=>e.schema.nodes.callout?nT(e,t):null,video:(e,t)=>e.schema.nodes.video?rT(e,t):null,emoji:(e,t)=>Hw(e,`emoji`)?iT(e,t):null,horizontalRule:(e,t)=>e.schema.nodes.horizontalRule?Kw(e,t,{command:`setHorizontalRule`,icon:`horizontalRule`,label:X(`editor.toolbar.horizontal_rule`)}):null,pageBreak:(e,t)=>e.schema.nodes.pageBreak?Kw(e,t,{command:`insertPageBreak`,icon:`pageBreak`,label:X(`editor.toolbar.page_break`)}):null,sectionTools:(e,t)=>aT(e)?sT(e,t):null,instanceTools:(e,t)=>oT(e)?cT(e,t):null,preview:(e,t)=>e.schema.nodes.docSection||e.schema.nodes.docInput?lT(e,t):null};function Vw(e,t,n={}){let{items:r=Lw}=n,i=Array.from(t.children);t.replaceChildren(),t.classList.add(`efe-toolbar`),t.setAttribute(`role`,`toolbar`),t.setAttribute(`aria-label`,X(`editor.toolbar.text_formatting`));let a=[],o=null,s=null;for(let i of r){let r=Bw[i],c=r?r(e,a,n):null;if(!c)continue;let l=zw[i];o!==l&&(o!==null&&t.appendChild(dT()),s=null),!Array.isArray(c)&&c.classList.contains(`efe-toolbar__group`)?t.appendChild(c):(s||(s=document.createElement(`div`),s.className=`efe-toolbar__group`,s.setAttribute(`role`,`group`),t.appendChild(s)),s.append(...Array.isArray(c)?c:[c])),o=l}i.length>0&&(o!==null&&t.appendChild(dT()),t.append(...i));let c=()=>{for(let e of a)e();if(!e.isEditable)for(let e of t.querySelectorAll(`button:not([data-efe-always-enabled])`))e.disabled=!0};return c(),e.on(`transaction`,c),e.on(`destroy`,()=>e.off(`transaction`,c)),{destroy(){e.off(`transaction`,c)}}}function Hw(e,t){return e.extensionManager.extensions.some(e=>e.name===t)}function Uw(e,t,n,r,i){return e.schema.marks[n]?Gw(e,t,{command:`toggle${n.charAt(0).toUpperCase()}${n.slice(1)}`,name:n,icon:n,label:r,shortcut:i}):null}function Ww(e,t,n,r,i){return e.schema.nodes[n]?Gw(e,t,{command:r,name:n,icon:n,label:i}):null}function Gw(e,t,{command:n,name:r,icon:i,label:a,shortcut:o}){let s=cx({name:i,label:a,shortcut:o});return s.dataset.efeCommand=n,s.setAttribute(`aria-pressed`,`false`),s.addEventListener(`click`,()=>{e.chain().focus()[n]().run()}),t.push(()=>{let t=e.isActive(r);s.setAttribute(`aria-pressed`,String(t)),s.classList.toggle(`is-active`,t),s.disabled=!e.can()[n]()}),s}function Kw(e,t,{command:n,icon:r,label:i,shortcut:a}){let o=cx({name:r,label:i,shortcut:a});return o.dataset.efeCommand=n,o.addEventListener(`click`,()=>{e.chain().focus()[n]().run()}),t.push(()=>{o.disabled=!e.can()[n]()}),o}function qw(e,t,n,r=``){let i=document.createElement(`div`);i.className=`efe-dropdown`,t.setAttribute(`aria-haspopup`,`true`),t.setAttribute(`aria-expanded`,`false`);let a=document.createElement(`div`);a.className=`efe-dropdown__menu ${r}`.trim(),a.setAttribute(`role`,`menu`),a.hidden=!0,a.dataset.state=`closed`;for(let{element:e,action:t}of n)t&&e.addEventListener(`click`,()=>{l(!1),t()}),a.appendChild(e);i.append(t,a);let o=()=>Array.from(a.querySelectorAll(`button:not(:disabled)`)),s=()=>a.dataset.state===`open`;function c(){CC(a),a.hidden=!1,a.dataset.state=`open`,t.setAttribute(`aria-expanded`,`true`),document.addEventListener(`click`,u,!0),document.addEventListener(`keydown`,d,!0)}function l(e){s()&&SC(a,()=>{a.hidden=!0}),t.setAttribute(`aria-expanded`,`false`),document.removeEventListener(`click`,u,!0),document.removeEventListener(`keydown`,d,!0),e&&t.focus()}function u(e){i.contains(e.target)||l(!1)}function d(e){if(e.key===`Escape`){e.preventDefault(),l(!0);return}if(e.key!==`ArrowDown`&&e.key!==`ArrowUp`)return;let t=o();if(t.length===0)return;e.preventDefault();let n=t.indexOf(document.activeElement),r=e.key===`ArrowDown`?1:-1;t[n===-1?0:(n+r+t.length)%t.length].focus()}return t.addEventListener(`click`,()=>{s()?l(!1):(c(),(a.querySelector(`[aria-checked="true"]:not(:disabled)`)??o()[0])?.focus())}),e.on(`destroy`,()=>l(!1)),i}function Jw(e,t=`menuitem`){let n=document.createElement(`button`);return n.type=`button`,n.className=`efe-dropdown__item`,n.setAttribute(`role`,t),n.textContent=e,n}function Yw(e,t){let n=document.createElement(`button`);n.type=`button`,n.className=`efe-btn efe-btn--dropdown efe-btn--heading`,n.dataset.efeCommand=`heading`,n.setAttribute(`aria-label`,X(`editor.toolbar.paragraph_format`)),Y(n,X(`editor.toolbar.paragraph_format`));let r=document.createElement(`span`);r.className=`efe-btn__text`,n.append(r,sx(`chevron`));let i=Fw(),a=i.map(({level:t,label:n})=>{let r=Jw(n,`menuitemradio`);return r.classList.add(`efe-dropdown__item--h${t}`),r.dataset.efeHeading=String(t),{element:r,action:()=>t===0?e.chain().focus().setParagraph().run():e.chain().focus().setHeading({level:t}).run(),level:t}});return t.push(()=>{let t=i.find(({level:t})=>t>0&&e.isActive(`heading`,{level:t}))??i[0];r.textContent=t.label;for(let n of a){let r=n.level===t.level;n.element.setAttribute(`aria-checked`,String(r)),n.element.disabled=!r&&(n.level===0?!e.can().setParagraph():!e.can().setHeading({level:n.level}))}n.disabled=a.every(e=>e.element.disabled)}),qw(e,n,a,`efe-dropdown__menu--heading`)}function Xw(e,t,n){let r=document.createElement(`button`);r.type=`button`,r.className=`efe-btn efe-btn--dropdown efe-btn--heading`,r.dataset.efeCommand=`fontFamily`,r.setAttribute(`aria-label`,X(`editor.toolbar.font`)),Y(r,X(`editor.toolbar.font`));let i=document.createElement(`span`);i.className=`efe-btn__text`,r.append(i,sx(`chevron`));let a=[{name:null,label:X(`editor.toolbar.font_default`)},...n.map(({name:e,label:t})=>({name:e,label:t??e}))].map(({name:t,label:n})=>{let r=Jw(n,`menuitemradio`);return r.dataset.efeFont=t??``,t&&(r.style.fontFamily=t),{element:r,action:()=>t?e.chain().focus().setFontFamily(t).run():e.chain().focus().unsetFontFamily().run(),name:t,label:n}});return t.push(()=>{let t=e.getAttributes(`textStyle`).fontFamily??null,n=a.find(e=>e.name===t)??a[0];i.textContent=n.label;for(let t of a)t.element.setAttribute(`aria-checked`,String(t===n)),t.element.disabled=t!==n&&!(t.name?e.can().setFontFamily(t.name):e.can().unsetFontFamily());r.disabled=a.every(e=>e.element.disabled)}),qw(e,r,a)}function Zw(e,t,n){let r=document.createElement(`button`);r.type=`button`,r.className=`efe-btn efe-btn--dropdown efe-btn--heading`,r.dataset.efeCommand=`style`,r.setAttribute(`aria-label`,X(`editor.toolbar.style`)),Y(r,X(`editor.toolbar.style`));let i=document.createElement(`span`);i.className=`efe-btn__text`,r.append(i,sx(`chevron`));let a={element:Jw(X(`editor.toolbar.style_none`),`menuitemradio`),action:()=>e.chain().focus().unsetStyles().run(),key:null};a.element.dataset.efeStyle=``;let o=[{kind:`block`,title:X(`editor.toolbar.style_block`),command:`setBlockStyle`},{kind:`inline`,title:X(`editor.toolbar.style_inline`),command:`setInlineStyle`}],s=[a];for(let{kind:t,title:r,command:i}of o){let a=n.filter(e=>e.kind===t);if(a.length===0)continue;let o=document.createElement(`div`);o.className=`efe-dropdown__label`,o.setAttribute(`role`,`presentation`),o.textContent=r,s.push({element:o});for(let{key:n,label:r}of a){let a=Jw(``,`menuitemradio`);a.dataset.efeStyle=n;let o=document.createElement(`span`);o.className=Ow+n,o.textContent=r,a.append(o),s.push({element:a,action:()=>e.chain().focus()[i](n).run(),key:n,kind:t,label:r})}}return t.push(()=>{let{block:t,inline:n}=Pw(e),o=s.filter(e=>e.action),c=o.find(e=>e.kind===`inline`&&e.key===n)??o.find(e=>e.kind===`block`&&e.key===t)??null;i.textContent=c?.label??X(`editor.toolbar.style`);for(let e of o){let r=e===a?!t&&!n:e.key===(e.kind===`inline`?n:t);e.element.setAttribute(`aria-checked`,String(r))}r.disabled=!e.isEditable}),qw(e,r,s,`efe-dropdown__menu--styles`)}function Qw(e,t){let n=document.createElement(`button`);n.type=`button`,n.className=`efe-btn efe-btn--dropdown`,n.dataset.efeCommand=`textAlign`,n.setAttribute(`aria-label`,X(`editor.toolbar.alignment`)),Y(n,X(`editor.toolbar.alignment`));let r=sx(`alignLeft`);n.append(r,sx(`chevron`));let i=Iw().map(({value:t,label:n,icon:r})=>{let i=Jw(``,`menuitemradio`);return i.classList.add(`efe-dropdown__item--icon`),i.dataset.efeAlign=t,i.append(sx(r),document.createTextNode(n)),{element:i,value:t,iconName:r,action:()=>e.chain().focus().setTextAlign(t).run()}});return t.push(()=>{let t=i.find(t=>e.isActive({textAlign:t.value}))??i[0];for(let n of i)n.element.setAttribute(`aria-checked`,String(n===t)),n.element.disabled=!e.can().setTextAlign(n.value);let a=sx(t.iconName);r.replaceWith(a),r=a,n.disabled=i.every(e=>e.element.disabled)}),qw(e,n,i)}function $w(e,t){let n=document.createElement(`button`);n.type=`button`,n.className=`efe-btn efe-btn--dropdown`,n.dataset.efeCommand=`insertTable`,n.setAttribute(`aria-label`,X(`editor.toolbar.table`)),Y(n,X(`editor.toolbar.table`)),n.append(sx(`table`),sx(`chevron`));let r=()=>e.chain().focus(),i=[{label:X(`editor.toolbar.table_insert`),action:()=>r().insertTable({rows:3,cols:3,withHeaderRow:!0}).run(),can:()=>e.can().insertTable()},{label:X(`editor.toolbar.table_row_before`),action:()=>r().addRowBefore().run(),can:()=>e.can().addRowBefore()},{label:X(`editor.toolbar.table_row_after`),action:()=>r().addRowAfter().run(),can:()=>e.can().addRowAfter()},{label:X(`editor.toolbar.table_column_before`),action:()=>r().addColumnBefore().run(),can:()=>e.can().addColumnBefore()},{label:X(`editor.toolbar.table_column_after`),action:()=>r().addColumnAfter().run(),can:()=>e.can().addColumnAfter()},{label:X(`editor.toolbar.table_row_delete`),action:()=>r().deleteRow().run(),can:()=>e.can().deleteRow()},{label:X(`editor.toolbar.table_column_delete`),action:()=>r().deleteColumn().run(),can:()=>e.can().deleteColumn()},{label:X(`editor.toolbar.table_delete`),action:()=>r().deleteTable().run(),can:()=>e.can().deleteTable()}].map(e=>({...e,element:Jw(e.label)}));return t.push(()=>{for(let e of i)e.element.disabled=!e.can();n.classList.toggle(`is-active`,e.isActive(`table`))}),qw(e,n,i)}function eT(e,t){let n=cx({name:`link`,label:X(`editor.toolbar.link`),shortcut:X(`editor.toolbar.shortcut_link`)});return n.dataset.efeCommand=`toggleLink`,n.setAttribute(`aria-haspopup`,`dialog`),n.setAttribute(`aria-pressed`,`false`),n.addEventListener(`mousedown`,e=>e.preventDefault()),n.addEventListener(`click`,()=>{let t=jC(e);t.isOpen()?t.close():t.open()}),t.push(()=>{let t=e.isActive(`link`);n.setAttribute(`aria-pressed`,String(t)),n.classList.toggle(`is-active`,t)}),n}function tT(e,t){let n=e.extensionManager.extensions.find(e=>e.name===`imageBlock`)?.options.upload;if(typeof n!=`function`)return null;let r=cx({name:`image`,label:X(`editor.toolbar.image`)});r.dataset.efeCommand=`insertImage`;let i=document.createElement(`input`);i.type=`file`,i.accept=`image/*`,i.hidden=!0,i.tabIndex=-1;let a=!1,o=t=>{a=t,r.toggleAttribute(`aria-busy`,t),r.disabled=t||!e.isEditable};return r.addEventListener(`click`,()=>i.click()),i.addEventListener(`change`,async()=>{let t=i.files?.[0];if(i.value=``,t){o(!0);try{let r=await n(t);r&&LC(r.src)?e.chain().focus().insertImageBlock({src:r.src,alt:r.alt??``}).run():console.error(`[editor] uploadImage lieferte keine erlaubte Bildquelle.`,r?.src)}catch(e){console.error(`[editor] Bild-Upload fehlgeschlagen.`,e)}finally{o(!1)}}}),t.push(()=>{r.disabled=a||!e.can().insertImageBlock({src:`/x.png`})}),[r,i]}function nT(e,t){let n=document.createElement(`button`);n.type=`button`,n.className=`efe-btn efe-btn--dropdown`,n.dataset.efeCommand=`setCallout`,n.setAttribute(`aria-label`,X(`editor.toolbar.callout`)),Y(n,X(`editor.toolbar.callout`)),n.append(sx(`callout`),sx(`chevron`));let r=BC.map(({value:t,label:n})=>{let r=Jw(n,`menuitemradio`);return r.dataset.efeCallout=t,{element:r,value:t,action:()=>e.chain().focus().setCallout(t).run()}}),i={element:Jw(X(`editor.toolbar.callout_remove`)),value:null,action:()=>e.chain().focus().unsetCallout().run()};return i.element.dataset.efeCallout=`remove`,t.push(()=>{let t=e.isActive(`callout`);for(let n of r){let r=t&&e.isActive(`callout`,{variant:n.value});n.element.setAttribute(`aria-checked`,String(r)),n.element.disabled=!r&&!e.can().setCallout(n.value)}i.element.hidden=!t,n.classList.toggle(`is-active`,t),n.disabled=r.every(e=>e.element.disabled)}),qw(e,n,[...r,i])}function rT(e,t){let n=cx({name:`video`,label:X(`editor.toolbar.video`)});return n.dataset.efeCommand=`insertVideo`,n.setAttribute(`aria-haspopup`,`dialog`),n.addEventListener(`mousedown`,e=>e.preventDefault()),n.addEventListener(`click`,()=>{let t=ew(e);t.isOpen()?t.close():t.open()}),t.push(()=>{n.disabled=!e.can().insertVideo({provider:`youtube`,id:`aaaaaaaaaaa`})}),n}function iT(e,t){let n=cx({name:`emoji`,label:X(`editor.toolbar.emoji`)});return n.dataset.efeCommand=`insertEmoji`,n.setAttribute(`aria-haspopup`,`dialog`),n.addEventListener(`mousedown`,e=>e.preventDefault()),n.addEventListener(`click`,()=>{let t=Sw(e);t.isOpen()?t.close():t.open()}),t.push(()=>{n.disabled=!e.isEditable}),n}function aT(e){return!!e.extensionManager.extensions.find(e=>e.name===`sectionLockGuard`)?.options?.templateMode}function oT(e){return!!e.schema.nodes.docSection&&!aT(e)}function sT(e,t){let n=document.createElement(`div`);return n.className=`efe-toolbar__group`,n.setAttribute(`role`,`group`),n.setAttribute(`aria-label`,X(`editor.toolbar.sections`)),n.append(uT(e,t,{command:`insertSectionFree`,label:X(`editor.toolbar.section_free`),text:X(`editor.toolbar.section_free_text`),action:()=>e.chain().focus().insertSection(`free`).run(),can:()=>e.can().insertSection(`free`)}),uT(e,t,{command:`insertSectionLocked`,label:X(`editor.toolbar.section_locked`),text:X(`editor.toolbar.section_locked_text`),action:()=>e.chain().focus().insertSection(`locked`).run(),can:()=>e.can().insertSection(`locked`)}),uT(e,t,{command:`toggleSectionMode`,label:X(`editor.toolbar.section_mode`),text:X(`editor.toolbar.section_mode_text`),action:()=>e.chain().focus().toggleSectionMode().run(),can:()=>e.can().toggleSectionMode()})),n}function cT(e,t){let n=document.createElement(`div`);return n.className=`efe-toolbar__group`,n.setAttribute(`role`,`group`),n.setAttribute(`aria-label`,X(`editor.toolbar.instances`)),n.append(uT(e,t,{command:`addSectionInstance`,label:X(`editor.toolbar.instance_add`),text:`+`,action:()=>e.chain().focus().addSectionInstance().run(),can:()=>e.can().addSectionInstance()}),uT(e,t,{command:`removeSectionInstance`,label:X(`editor.toolbar.instance_remove`),text:`−`,action:()=>e.chain().focus().removeSectionInstance().run(),can:()=>e.can().removeSectionInstance()})),n}function lT(e,t){let n=cx({name:`eye`,label:X(`editor.toolbar.preview_tip`)});n.classList.add(`efe-btn--labelled`,`efe-btn--preview`),n.dataset.efeCommand=`preview`,n.dataset.efeAlwaysEnabled=`true`,n.setAttribute(`aria-pressed`,`false`),n.append(document.createTextNode(X(`editor.toolbar.preview`)));let r=()=>{let t=Ew(e);n.setAttribute(`aria-pressed`,t?`true`:`false`),n.classList.toggle(`is-active`,t),n.disabled=!1};return n.addEventListener(`click`,()=>Dw(e)),e.on(`efe-preview`,r),t.push(r),r(),n}function uT(e,t,{command:n,label:r,text:i,action:a,can:o}){let s=document.createElement(`button`);return s.type=`button`,s.className=`efe-btn efe-btn--labelled`,s.dataset.efeCommand=n,s.setAttribute(`aria-label`,r),Y(s,r),s.textContent=i,s.addEventListener(`click`,a),t.push(()=>{s.disabled=!o()}),s}function dT(){let e=document.createElement(`span`);return e.className=`efe-toolbar__divider`,e.setAttribute(`role`,`separator`),e.setAttribute(`aria-orientation`,`vertical`),e}function fT(e,t){let n=Math.min(e.top,t.top),r=Math.max(e.bottom,t.bottom),i=Math.min(e.left,t.left),a=Math.max(e.right,t.right)-i,o=r-n;return new DOMRect(i,n,a,o)}var pT=class{get middlewares(){let e=[];return this.floatingUIOptions.flip&&e.push(sC(typeof this.floatingUIOptions.flip==`boolean`?void 0:this.floatingUIOptions.flip)),this.floatingUIOptions.shift&&e.push(oC(typeof this.floatingUIOptions.shift==`boolean`?void 0:this.floatingUIOptions.shift)),this.floatingUIOptions.offset&&e.push(iC(typeof this.floatingUIOptions.offset==`boolean`?void 0:this.floatingUIOptions.offset)),this.floatingUIOptions.arrow&&e.push(uC(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&e.push(cC(typeof this.floatingUIOptions.size==`boolean`?void 0:this.floatingUIOptions.size)),this.floatingUIOptions.autoPlacement&&e.push(aC(typeof this.floatingUIOptions.autoPlacement==`boolean`?void 0:this.floatingUIOptions.autoPlacement)),this.floatingUIOptions.hide&&e.push(lC(typeof this.floatingUIOptions.hide==`boolean`?void 0:this.floatingUIOptions.hide)),this.floatingUIOptions.inline&&e.push(dC(typeof this.floatingUIOptions.inline==`boolean`?void 0:this.floatingUIOptions.inline)),e}get virtualElement(){var e;let{selection:t}=this.editor.state,n=this.getReferencedVirtualElement?.call(this);if(n)return n;if(!((e=this.view)!=null&&(e=e.dom)!=null&&e.parentNode))return;let r=ud(this.view,t.from,t.to),i={getBoundingClientRect:()=>r,getClientRects:()=>[r]};if(t instanceof j){let e=this.view.nodeDOM(t.from),n=e.dataset.nodeViewWrapper?e:e.querySelector(`[data-node-view-wrapper]`);n&&(e=n),e&&(i={getBoundingClientRect:()=>e.getBoundingClientRect(),getClientRects:()=>[e.getBoundingClientRect()]})}if(t instanceof J){let{$anchorCell:e,$headCell:n}=t,r=e?e.pos:n.pos,a=n?n.pos:e.pos,o=this.view.nodeDOM(r),s=this.view.nodeDOM(a);if(!o||!s)return;let c=o===s?o.getBoundingClientRect():fT(o.getBoundingClientRect(),s.getBoundingClientRect());i={getBoundingClientRect:()=>c,getClientRects:()=>[c]}}return i}constructor({editor:e,element:t,view:n,pluginKey:r=`bubbleMenu`,updateDelay:i=250,resizeDelay:a=60,shouldShow:o,appendTo:s,getReferencedVirtualElement:c,options:l}){this.preventHide=!1,this.isVisible=!1,this.scrollTarget=window,this.floatingUIOptions={strategy:`absolute`,placement:`top`,offset:8,flip:{},shift:{},arrow:!1,size:!1,autoPlacement:!1,hide:!1,inline:!1,onShow:void 0,onHide:void 0,onUpdate:void 0,onDestroy:void 0},this.shouldShow=({view:e,state:t,from:n,to:r})=>{let{doc:i,selection:a}=t,{empty:o}=a,s=!i.textBetween(n,r).length&&pl(t.selection),c=this.element.contains(document.activeElement);return!(!(e.hasFocus()||c)||o||s||!this.editor.isEditable)},this.mousedownHandler=()=>{this.preventHide=!0},this.dragstartHandler=()=>{this.hide()},this.compositionEndHandler=()=>{clearTimeout(this.compositionEndTimer),this.compositionEndTimer=window.setTimeout(()=>{this.editor.isDestroyed||this.update(this.view)})},this.resizeHandler=()=>{this.resizeDebounceTimer&&clearTimeout(this.resizeDebounceTimer),this.resizeDebounceTimer=window.setTimeout(()=>{this.updatePosition()},this.resizeDelay)},this.focusHandler=()=>{setTimeout(()=>this.update(this.editor.view))},this.blurHandler=({event:e})=>{this.editor.isDestroyed?this.destroy():this.preventHide?this.preventHide=!1:e?.relatedTarget&&this.element.parentNode?.contains(e.relatedTarget)||e?.relatedTarget!==this.editor.view.dom&&this.hide()},this.handleDebouncedUpdate=(e,t)=>{let n=!t?.selection.eq(e.state.selection),r=!t?.doc.eq(e.state.doc);(n||r)&&(this.updateDebounceTimer&&clearTimeout(this.updateDebounceTimer),this.updateDebounceTimer=window.setTimeout(()=>{this.updateHandler(e,n,r,t)},this.updateDelay))},this.updateHandler=(e,t,n,r)=>{let{composing:i}=e;i||!t&&!n||(this.getShouldShow(r)?(this.show(),this.updatePosition()):this.hide())},this.transactionHandler=({transaction:e})=>{let t=e.getMeta(this.pluginKey);t===`updatePosition`?this.updatePosition():t&&typeof t==`object`&&t.type===`updateOptions`?this.updateOptions(t.options):t===`hide`?this.hide():t===`show`&&(this.updatePosition(),this.show())},this.editor=e,this.element=t,this.view=n,this.pluginKey=r,this.updateDelay=i,this.resizeDelay=a,this.appendTo=s,this.scrollTarget=l?.scrollTarget??window,this.getReferencedVirtualElement=c,this.floatingUIOptions={...this.floatingUIOptions,...l},this.element.tabIndex=0,o&&(this.shouldShow=o),this.element.addEventListener(`mousedown`,this.mousedownHandler,{capture:!0}),this.view.dom.addEventListener(`dragstart`,this.dragstartHandler),this.editor.on(`focus`,this.focusHandler),this.editor.on(`blur`,this.blurHandler),this.editor.on(`transaction`,this.transactionHandler),window.addEventListener(`resize`,this.resizeHandler),this.scrollTarget.addEventListener(`scroll`,this.resizeHandler),this.view.dom.addEventListener(`compositionend`,this.compositionEndHandler),this.update(n,n.state),this.getShouldShow()&&(this.show(),this.updatePosition())}updatePosition(){if(!this.isVisible)return;let e=this.virtualElement;e&&fC(e,this.element,{placement:this.floatingUIOptions.placement,strategy:this.floatingUIOptions.strategy,middleware:this.middlewares}).then(({x:e,y:t,strategy:n,middlewareData:r})=>{this.isVisible&&!this.editor.isDestroyed&&this.element.isConnected&&(r.hide?.referenceHidden||r.hide?.escaped?this.element.style.visibility=`hidden`:(this.element.style.visibility=`visible`,this.element.style.width=`max-content`,this.element.style.position=n,this.element.style.left=`${e}px`,this.element.style.top=`${t}px`,this.isVisible&&this.floatingUIOptions.onUpdate&&this.floatingUIOptions.onUpdate()))})}update(e,t){let{state:n}=e,r=n.selection.from!==n.selection.to;if(this.updateDelay>0&&r){this.handleDebouncedUpdate(e,t);return}let i=!t?.selection.eq(e.state.selection),a=!t?.doc.eq(e.state.doc);this.updateHandler(e,i,a,t)}getShouldShow(e){let{state:t}=this.view,{selection:n}=t,{ranges:r}=n,i=Math.min(...r.map(e=>e.$from.pos)),a=Math.max(...r.map(e=>e.$to.pos));return this.shouldShow?.call(this,{editor:this.editor,element:this.element,view:this.view,state:t,oldState:e,from:i,to:a})||!1}show(){var e;this.isVisible||=(this.element.style.visibility=`visible`,this.element.style.opacity=`1`,(e=(typeof this.appendTo==`function`?this.appendTo():this.appendTo)??this.view.dom.parentElement)==null||e.appendChild(this.element),this.floatingUIOptions.onShow&&this.floatingUIOptions.onShow(),!0)}hide(){this.isVisible&&=(this.element.style.visibility=`hidden`,this.element.style.opacity=`0`,this.element.remove(),this.floatingUIOptions.onHide&&this.floatingUIOptions.onHide(),!1)}updateOptions(e){if(e.updateDelay!==void 0&&(this.updateDelay=e.updateDelay),e.resizeDelay!==void 0&&(this.resizeDelay=e.resizeDelay),e.appendTo!==void 0&&(this.appendTo=e.appendTo),e.getReferencedVirtualElement!==void 0&&(this.getReferencedVirtualElement=e.getReferencedVirtualElement),e.shouldShow!==void 0&&e.shouldShow&&(this.shouldShow=e.shouldShow),e.options!==void 0){let t=e.options.scrollTarget??window;t!==this.scrollTarget&&(this.scrollTarget.removeEventListener(`scroll`,this.resizeHandler),this.scrollTarget=t,this.scrollTarget.addEventListener(`scroll`,this.resizeHandler)),this.floatingUIOptions={...this.floatingUIOptions,...e.options}}}destroy(){this.hide(),this.element.removeEventListener(`mousedown`,this.mousedownHandler,{capture:!0}),this.view.dom.removeEventListener(`dragstart`,this.dragstartHandler),window.removeEventListener(`resize`,this.resizeHandler),this.scrollTarget.removeEventListener(`scroll`,this.resizeHandler),this.editor.off(`focus`,this.focusHandler),this.editor.off(`blur`,this.blurHandler),this.editor.off(`transaction`,this.transactionHandler),this.view.dom.removeEventListener(`compositionend`,this.compositionEndHandler),clearTimeout(this.compositionEndTimer),clearTimeout(this.updateDebounceTimer),this.floatingUIOptions.onDestroy&&this.floatingUIOptions.onDestroy()}},mT=e=>new M({key:typeof e.pluginKey==`string`?new N(e.pluginKey):e.pluginKey,view:t=>new pT({view:t,...e})}),hT=V.create({name:`bubbleMenu`,addOptions(){return{element:null,pluginKey:`bubbleMenu`,updateDelay:void 0,appendTo:void 0,shouldShow:null}},addProseMirrorPlugins(){return this.options.element?[mT({pluginKey:this.options.pluginKey,editor:this.editor,element:this.options.element,updateDelay:this.options.updateDelay,options:this.options.options,appendTo:this.options.appendTo,getReferencedVirtualElement:this.options.getReferencedVirtualElement,shouldShow:this.options.shouldShow})]:[]}}),gT=`efeBubble`,_T=()=>[{mark:`bold`,icon:`bold`,label:X(`editor.bubble.bold`),shortcut:X(`editor.bubble.shortcut_bold`)},{mark:`italic`,icon:`italic`,label:X(`editor.bubble.italic`),shortcut:X(`editor.bubble.shortcut_italic`)},{mark:`underline`,icon:`underline`,label:X(`editor.bubble.underline`),shortcut:X(`editor.bubble.shortcut_underline`)},{mark:`strike`,icon:`strike`,label:X(`editor.bubble.strike`),shortcut:X(`editor.bubble.shortcut_strike`)}];function vT(){let e=document.createElement(`div`);e.className=`efe-bubble`,e.setAttribute(`role`,`toolbar`),e.setAttribute(`aria-label`,X(`editor.bubble.quick_bar`)),e.dataset.state=`closed`;let t=null,n=()=>e.dataset.state===`open`,r=null,i=e=>e.view.dispatch(e.state.tr.setMeta(gT,`hide`)),a=hT.configure({pluginKey:gT,element:e,updateDelay:100,shouldShow:({editor:t,view:n,state:i,from:a,to:o})=>{let{selection:s}=i;return t.isDestroyed||!t.schema||!e.firstChild||!t.isEditable||!(s instanceof A)||s.empty||i.doc.textBetween(a,o).length===0||r&&r.eq(s)||t.schema.marks.link&&jC(t).isOpen()?!1:n.hasFocus()||e.contains(document.activeElement)},options:{placement:`top`,offset:8,flip:{padding:8},shift:{padding:8},onShow:()=>{CC(e),t=e.parentNode,e.dataset.state=`open`},onHide:()=>{e.style.visibility=`visible`,e.style.opacity=``,t?.appendChild(e),SC(e,()=>e.remove())}}}),o=V.create({name:`efeBubbleKeys`,addKeyboardShortcuts(){return{Escape:({editor:e})=>n()?(r=e.state.selection,i(e),!0):!1,"Alt-F10":()=>{let t=e.querySelector(`button:not(:disabled)`);return!n()||!t?!1:(t.focus(),!0)}}}});function s(t){let{marks:n}=t.schema,a=[],o=(t,n,r)=>{t.addEventListener(`mousedown`,e=>e.preventDefault()),t.addEventListener(`click`,n),e.appendChild(t),a.push(()=>{let e=r();t.classList.toggle(`is-active`,e),t.setAttribute(`aria-pressed`,String(e))})},s=_T().filter(e=>n[e.mark]);for(let e of s){let n=cx({name:e.icon,label:e.label,shortcut:e.shortcut,className:`efe-btn`});n.dataset.efeCommand=`toggle${e.mark.charAt(0).toUpperCase()}${e.mark.slice(1)}`,o(n,()=>t.chain().focus().toggleMark(e.mark).run(),()=>t.isActive(e.mark))}if(n.link){let e=cx({name:`link`,label:X(`editor.bubble.link`),shortcut:X(`editor.bubble.shortcut_link`),className:`efe-btn`});e.dataset.efeCommand=`toggleLink`,o(e,()=>{i(t),jC(t).open()},()=>t.isActive(`link`))}if(s.length>0){let e=cx({name:`removeFormat`,label:X(`editor.bubble.remove_format`),className:`efe-btn`});e.dataset.efeCommand=`removeFormat`,o(e,()=>{let e=t.chain().focus();for(let t of s)e=e.unsetMark(t.mark);e.run()},()=>!1)}e.tabIndex=-1,e.addEventListener(`keydown`,n=>{let a=Array.from(e.querySelectorAll(`button`)),o=a.indexOf(document.activeElement);n.key===`ArrowRight`||n.key===`ArrowLeft`?(n.preventDefault(),a[(o+(n.key===`ArrowRight`?1:-1)+a.length)%a.length]?.focus()):n.key===`Escape`&&(n.preventDefault(),r=t.state.selection,t.commands.focus(),i(t))}),e.addEventListener(`focusout`,n=>{let r=n.relatedTarget;r&&(e.contains(r)||t.view.dom.contains(r))||i(t)});let c=()=>a.forEach(e=>e());t.on(`selectionUpdate`,()=>{r=null}),t.on(`transaction`,c),c()}return{element:e,extensions:[a,o],attach:s}}var yT=[`headings`,`bold`,`italic`,`underline`,`strike`,`fontFamily`,`styles`,`bulletList`,`orderedList`,`blockquote`,`link`,`table`,`textAlign`,`horizontalRule`,`image`,`callout`,`video`,`emoji`,`pageBreak`,`variables`,`fields`,`sections`,`inputs`],bT=[`bold`,`italic`,`underline`,`strike`],xT=Object.freeze({mail:Object.freeze([...bT,`styles`,`bulletList`,`orderedList`,`blockquote`,`link`,`emoji`]),signature:Object.freeze([...bT,`link`,`bulletList`,`orderedList`,`variables`]),document:Object.freeze([`headings`,...bT,`fontFamily`,`styles`,`bulletList`,`orderedList`,`blockquote`,`table`,`textAlign`,`horizontalRule`,`pageBreak`,`variables`,`fields`,`inputs`,`image`]),article:Object.freeze([`headings`,...bT,`styles`,`bulletList`,`orderedList`,`blockquote`,`link`,`table`,`horizontalRule`,`image`,`callout`,`video`,`emoji`])});function ST(e){let{features:t,pages:n=!0,links:r=!1,sections:i=!1,variables:a,emojiData:o}=e;if(t===void 0){let e=[`headings`,`bold`,`italic`,`strike`,`bulletList`,`orderedList`,`blockquote`,`horizontalRule`,`table`,`textAlign`,`variables`,`fields`];return n&&e.push(`pageBreak`),r&&e.push(`link`),i&&e.push(`sections`),new Set(e)}let s=typeof t==`string`?xT[t]:t;if(!Array.isArray(s))throw Error(`Unbekanntes Editor-Preset: ${String(t)}`);let c=new Set(s.filter(e=>yT.includes(e)));return c.has(`inputs`)&&c.delete(`sections`),a||c.delete(`variables`),o||c.delete(`emoji`),c}function CT(e,t){return!e||typeof e!=`object`?e:wT(e,t)[0]??{type:`doc`,content:[]}}function wT(e,t){if(!e||typeof e!=`object`)return[];let n=Array.isArray(e.content)?e.content.flatMap(e=>wT(e,t)):void 0;if(t.nodes[e.type]){let r={...e};return n&&(r.content=n),Array.isArray(e.marks)&&(r.marks=e.marks.filter(e=>t.marks[e?.type])),[r]}return!n||n.length===0?[]:n.every(e=>t.nodes[e.type]?.isInline)?[{type:`paragraph`,content:n}]:n}function TT(e){return e instanceof Map?Array.from(e.entries()):Object.entries(e??{})}function ET(e,t){if(e)return e instanceof Map?e.get(t):e[t]}function DT(e,t){let n=TT(e),r=(t??``).trim().toLowerCase();return n.filter(([e,t])=>{if(!r)return!0;let n=(t?.label??``).toLowerCase();return e.toLowerCase().includes(r)||n.includes(r)}).map(([e,t])=>({name:e,label:t?.label??e}))}function OT(e,t,n){let r=MT(e,t),i=r?.label?String(r.label):String(t??``),a=r?.value,o=a==null?``:String(a);return r===void 0?{state:`unknown`,label:i,value:null}:n===`labels`?{state:`placeholder`,label:i,value:null}:o.trim()===``?{state:`missing`,label:i,value:null}:{state:`filled`,label:i,value:o}}function kT(e){return e?(e instanceof Map?[...e.values()]:Object.values(e)).some(e=>e&&e.value!==void 0&&e.value!==null):!1}var AT={filled:e=>X(`editor.variable_view.filled`,{label:e}),missing:e=>X(`editor.variable_view.missing`,{label:e}),placeholder:(e,t)=>X(`editor.variable_view.placeholder`,{label:e,token:`{{${t}}}`}),unknown:(e,t)=>X(`editor.variable_view.unknown`,{token:`{{${t}}}`})};function jT(e){return({node:t,getPos:n,editor:r})=>{let i=document.createElement(`span`);i.setAttribute(`contenteditable`,`false`);let a=t=>{let n=t.attrs.name,{state:r,label:a,value:o}=OT(e.variables,n,e.display??`values`);i.className=`efe-variable efe-variable--${r}`,i.dataset.efeVariable=n??``,i.dataset.efeVariableState=r,r===`missing`?i.dataset.efeMissing=X(`editor.variable_view.missing_prefix`):delete i.dataset.efeMissing,r===`filled`?i.textContent=o:r===`unknown`?i.textContent=`{{${n}}}`:i.textContent=a;let s=AT[r](a,n);Y(i,s),i.setAttribute(`aria-label`,r===`filled`?`${o} (${s})`:s)};return a(t),i.addEventListener(`click`,()=>{if(!r.isEditable)return;let e=n();typeof e==`number`&&r.commands.setNodeSelection(e)}),{dom:i,update:e=>e.type===t.type&&(a(e),!0),selectNode:()=>{i.classList.add(`is-selected`)},deselectNode:()=>{i.classList.remove(`is-selected`)}}}}function MT(e,t){return ET(e,t)}var NT=H.create({name:`docVariable`,group:`inline`,inline:!0,atom:!0,selectable:!0,addOptions(){return{variables:{},display:`values`}},addAttributes(){return{name:{default:null,parseHTML:e=>e.getAttribute(`data-efe-variable`),renderHTML:e=>({"data-efe-variable":e.name})}}},parseHTML(){return[{tag:`span[data-efe-variable]`}]},renderHTML({HTMLAttributes:e}){return[`span`,B({class:`efe-variable`},e)]},addCommands(){return{insertVariable:e=>({commands:t})=>t.insertContent({type:this.name,attrs:{name:e}})}},addNodeView(){return jT(this.options)}}),PT=e=>HT(e.attrs.options).length>0,FT=e=>e.attrs.kind===`date`;function IT(e,t,n){if(!e.isEditable)return!1;let r=n.attrs.who;return!r||typeof t.can!=`function`||!!t.can(r)}function LT({node:e,getPos:t,editor:n},r){let i=document.createElement(`span`);i.className=`efe-field efe-field--date`,i.setAttribute(`contenteditable`,`false`);let a=document.createElement(`input`);a.type=`date`,a.className=`efe-field__input`,i.appendChild(a);let o=e=>{let{fieldId:t,label:o,required:s,value:c,who:l}=e.attrs;i.dataset.efeField=t??``,i.classList.toggle(`efe-field--required`,!!s),i.classList.toggle(`efe-field--empty`,!c),i.classList.toggle(`efe-field--locked`,!!l&&!IT(n,r,e)),a.disabled=!IT(n,r,e),a.setAttribute(`aria-label`,o??``),a.setAttribute(`aria-required`,s?`true`:`false`),a.value!==(c??``)&&(a.value=c??``)};return a.addEventListener(`change`,()=>{let e=t(),i=typeof e==`number`?n.state.doc.nodeAt(e):null;!i||!IT(n,r,i)?a.value=i?.attrs.value??``:a.value!==(i.attrs.value??``)&&n.view.dispatch(n.state.tr.setNodeAttribute(e,`value`,a.value))}),a.addEventListener(`keydown`,e=>RT(e,n,a)),o(e),{dom:i,stopEvent:()=>!0,ignoreMutation:()=>!0,update:t=>t.type!==e.type||!FT(t)?!1:(o(t),!0)}}function RT(e,t,n){let r=e.key.toLowerCase();if((e.ctrlKey||e.metaKey)&&(r===`z`||r===`y`))return e.preventDefault(),r===`y`||e.shiftKey?t.commands.redo():t.commands.undo(),!0;if(e.key===`Tab`){e.preventDefault();let r=Array.from(t.view.dom.querySelectorAll(`.efe-field__input`)),i=r.indexOf(n);return i!==-1&&r[(i+(e.shiftKey?-1:1)+r.length)%r.length].focus(),!0}return!1}function zT({node:e,getPos:t,editor:n},r,i={}){let a=document.createElement(`span`);a.className=`efe-field efe-field--select`,a.setAttribute(`contenteditable`,`false`);let o=document.createElement(`select`);o.className=`efe-field__input`,a.appendChild(o);let s=null,c=e=>{let{fieldId:t,label:i,required:c,value:l,options:u}=e.attrs;a.dataset.efeField=t??``,a.classList.toggle(`efe-field--required`,!!c),a.classList.toggle(`efe-field--empty`,!l),o.disabled=!IT(n,u,e),a.classList.toggle(`efe-field--locked`,!!e.attrs.who&&o.disabled&&n.isEditable),o.setAttribute(`aria-label`,i??``),o.setAttribute(`aria-required`,c?`true`:`false`);let d=HT(u).map(e=>UT(e,r));l&&!d.includes(l)&&d.unshift(l);let f=(i??``)+(c?` *`:``),p=JSON.stringify([f,d]);p!==s&&(o.replaceChildren(new Option(f,``),...d.map(e=>new Option(e,e))),s=p),o.value=l??``};return o.addEventListener(`change`,()=>{let e=t(),r=typeof e==`number`?n.state.doc.nodeAt(e)?.attrs.value??``:null,a=typeof e==`number`?n.state.doc.nodeAt(e):null;!a||!IT(n,i,a)?o.value=r??``:r!==null&&o.value!==r&&n.view.dispatch(n.state.tr.setNodeAttribute(e,`value`,o.value))}),o.addEventListener(`keydown`,e=>RT(e,n,o)),c(e),{dom:a,stopEvent:()=>!0,ignoreMutation:()=>!0,update:t=>t.type!==e.type||!PT(t)?!1:(c(t),!0)}}function BT(e){return({node:t,getPos:n,editor:r})=>{if(FT(t))return LT({node:t,getPos:n,editor:r},e);if(PT(t))return zT({node:t,getPos:n,editor:r},e.gender??null,e);let i=document.createElement(`span`);i.className=`efe-field`,i.setAttribute(`contenteditable`,`false`);let a=document.createElement(`span`);a.className=`efe-field__input`,a.setAttribute(`role`,`textbox`),i.appendChild(a);let o=!1,s=``,c=e=>{if(a.textContent=e,document.activeElement===a){let e=document.createRange();e.selectNodeContents(a),e.collapse(!1);let t=window.getSelection();t?.removeAllRanges(),t?.addRange(e)}},l=t=>{let{fieldId:n,label:o,required:l,value:u}=t.attrs;i.dataset.efeField=n??``,i.classList.toggle(`efe-field--required`,!!l),i.classList.toggle(`efe-field--empty`,!u);let d=IT(r,e,t);a.setAttribute(`contenteditable`,d?`true`:`false`),i.classList.toggle(`efe-field--locked`,!!t.attrs.who&&!d&&r.isEditable),a.dataset.efePlaceholder=o??``,a.setAttribute(`aria-label`,o??``),a.setAttribute(`aria-required`,l?`true`:`false`);let f=u??``;f!==s&&a.textContent!==f&&c(f),s=f},u=()=>{let i=n();if(typeof i!=`number`||!IT(r,e,r.state.doc.nodeAt(i)??t))return;let o=VT(r.state.doc.nodeAt(i)?.attrs??t.attrs),l=Array.from(a.textContent??``).slice(0,o).join(``);l!==a.textContent&&c(l),l!==r.state.doc.nodeAt(i)?.attrs.value&&(s=l,r.view.dispatch(r.state.tr.setNodeAttribute(i,`value`,l)))};return a.addEventListener(`compositionstart`,()=>{o=!0}),a.addEventListener(`compositionend`,()=>{o=!1,u()}),a.addEventListener(`input`,()=>{o||u()}),a.addEventListener(`keydown`,e=>{if(!RT(e,r,a)){if(e.key===`Enter`)e.preventDefault();else if(e.key===`a`&&(e.ctrlKey||e.metaKey)){e.preventDefault();let t=document.createRange();t.selectNodeContents(a);let n=window.getSelection();n?.removeAllRanges(),n?.addRange(t)}}}),a.addEventListener(`paste`,e=>{e.preventDefault();let t=e.clipboardData?.getData(`text/plain`)??``;document.execCommand(`insertText`,!1,t.replace(/\s+/g,` `))}),l(t),{dom:i,stopEvent:()=>!0,ignoreMutation:()=>!0,update:e=>e.type!==t.type||PT(e)||FT(e)?!1:(l(e),!0)}}}function VT(e){let t=e?.maxLength;return typeof t==`number`&&t>0?t:500}function HT(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){let e=typeof n?.label==`string`?n.label.trim():``;if(!e)continue;let r={label:e};for(let e of[`male`,`female`]){let t=typeof n[e]==`string`?n[e].trim():``;t&&(r[e]=t)}t.push(r)}return t}function UT(e,t){return t&&e[t]||e.label}var WT=H.create({name:`docField`,group:`inline`,inline:!0,atom:!0,selectable:!0,addOptions(){return{gender:null,can:null}},addAttributes(){return{fieldId:{default:null,parseHTML:e=>e.getAttribute(`data-efe-field`),renderHTML:e=>({"data-efe-field":e.fieldId})},label:{default:``,parseHTML:e=>e.getAttribute(`data-efe-label`)??``,renderHTML:e=>({"data-efe-label":e.label})},required:{default:!1,parseHTML:e=>e.getAttribute(`data-efe-required`)===`true`,renderHTML:e=>({"data-efe-required":e.required?`true`:`false`})},maxLength:{default:null,parseHTML:e=>{let t=Number(e.getAttribute(`data-efe-maxlength`));return Number.isFinite(t)&&t>0?t:null},renderHTML:e=>e.maxLength?{"data-efe-maxlength":String(e.maxLength)}:{}},options:{default:null,parseHTML:e=>{try{let t=HT(JSON.parse(e.getAttribute(`data-efe-options`)??``));return t.length?t:null}catch{return null}},renderHTML:e=>e.options?.length?{"data-efe-options":JSON.stringify(e.options)}:{}},optionsSource:{default:null,parseHTML:e=>e.getAttribute(`data-efe-options-source`),renderHTML:e=>e.optionsSource?{"data-efe-options-source":e.optionsSource}:{}},kind:{default:null,rendered:!1},who:{default:null,rendered:!1},min:{default:null,rendered:!1},max:{default:null,rendered:!1},decimals:{default:null,rendered:!1},value:{default:``,parseHTML:e=>e.textContent??``,renderHTML:()=>({})}}},parseHTML(){return[{tag:`span[data-efe-field]`}]},renderHTML({node:e,HTMLAttributes:t}){return[`span`,B({class:`efe-field`},t),e.attrs.value??``]},addNodeView(){return BT(this.options)}});function GT(e){let t=[],n=null;return e.state.doc.descendants(e=>e.type.name===`docSection`?(n=e.attrs.sectionId??null,!0):(e.type.name===`docField`&&e.attrs.required&&!(e.attrs.value??``).trim()&&t.push({sectionId:n,fieldId:e.attrs.fieldId??null,label:e.attrs.label??``}),!0)),t}function KT(e){let{char:t,allowSpaces:n,allowToIncludeChar:r,allowedPrefixes:i,startOfLine:a,$position:o}=e,s=n&&!r,c=xf(t),l=RegExp(`\\s${c}$`),u=a?`^`:``,d=r?``:c,f=RegExp(s?`${u}${c}.*?(?=\\s${d}|$)`:`${u}(?:^)?${c}[^\\s${d}]*`,`gm`),p=o.nodeBefore?.isText&&o.nodeBefore.text;if(!p)return null;let m=o.pos-p.length,h=Array.from(p.matchAll(f)).pop();if(!h||h.input===void 0||h.index===void 0)return null;let g=h.input.slice(Math.max(0,h.index-1),h.index),_=RegExp(`^[${i?.map(xf).join(``)}\0]?$`).test(g);if(i!==null&&!_)return null;let v=m+h.index,y=v+h[0].length;return s&&l.test(p.slice(y-1,y+1))&&(h[0]+=` `,y+=1),v=o.pos?{range:{from:v,to:y},query:h[0].slice(t.length),text:h[0]}:null}function qT(e){return e.docChanged?e.steps.some(e=>{let t=e.slice;if(!t?.content)return!1;let n=t.content.textBetween(0,t.content.size,` +`);return/\s/.test(n)}):!1}function JT(e){return()=>{let t=e.state.selection.$anchor.pos,{top:n,right:r,bottom:i,left:a}=e.view.coordsAtPos(t);try{return new DOMRect(a,n,r-a,i-n)}catch{return null}}}function YT(e,t,n,r){return n?()=>{let n=r.getState(e.state)?.decorationId;return t.dom.querySelector(`[data-decoration-id="${n}"]`)?.getBoundingClientRect()||null}:JT(e)}function XT({match:e,dismissedRange:t,state:n,transaction:r,editor:i,shouldResetDismissed:a,effectiveAllowSpaces:o}){return a?.({editor:i,state:n,range:t,match:e,transaction:r,allowSpaces:o})?!1:o?e.range.from===t.from:e.range.from===t.from&&!qT(r)}function ZT({view:e,pluginKeyRef:t}){let n=e.state.tr.setMeta(t,{exit:!0});e.dispatch(n)}function QT({pluginKey:e,decorationTag:t,decorationClass:n,decorationContent:r,decorationEmptyClass:i,renderer:a,dispatchExit:o}){return{handleKeyDown(t,n){var r;let i=e.getState(t.state);if(!i.active)return!1;if(n.key===`Escape`||n.key===`Esc`){var s;return a==null||(s=a.onKeyDown)==null||s.call(a,{view:t,event:n,range:i.range}),o(t),!0}return(a==null||(r=a.onKeyDown)==null?void 0:r.call(a,{view:t,event:n,range:i.range}))||!1},decorations(a){let{active:o,range:s,decorationId:c,query:l}=e.getState(a);if(!o)return null;let u=!l?.length,d=[n];return u&&d.push(i),I.create(a.doc,[fs.inline(s.from,s.to,{nodeName:t,class:d.join(` `),"data-decoration-id":c||void 0,"data-decoration-content":r})])}}}function $T({editor:e,char:t,effectiveAllowSpaces:n,allowToIncludeChar:r,allowedPrefixes:i,startOfLine:a,findSuggestionMatch:o,allow:s,shouldShow:c,shouldKeepDismissed:l,pluginKey:u}){return{init(){return{active:!1,range:{from:0,to:0},query:null,text:null,composing:!1,dismissedRange:null}},apply(d,f,p,m){let{isEditable:h}=e,{composing:g}=e.view,{selection:_}=d,{empty:v,from:y}=_,b={...f},x=d.getMeta(u);if(x&&x.exit)return b.active=!1,b.decorationId=null,b.range={from:0,to:0},b.query=null,b.text=null,b.dismissedRange=f.active?{...f.range}:f.dismissedRange,b;if(b.composing=g,d.docChanged&&b.dismissedRange!==null&&(b.dismissedRange={from:d.mapping.map(b.dismissedRange.from),to:d.mapping.map(b.dismissedRange.to)}),h&&(v||e.view.composing)){(yf.range.to)&&!g&&!f.composing&&(b.active=!1);let u=o({char:t,allowSpaces:n,allowToIncludeChar:r,allowedPrefixes:i,startOfLine:a,$position:_.$from}),p=`id_${Math.floor(Math.random()*4294967295)}`;u&&s({editor:e,state:m,range:u.range,isActive:f.active})&&(!c||c({editor:e,range:u.range,query:u.query,text:u.text,transaction:d}))?(b.dismissedRange!==null&&!l({match:u,dismissedRange:b.dismissedRange,state:m,transaction:d})&&(b.dismissedRange=null),b.dismissedRange===null?(b.active=!0,b.decorationId=f.decorationId||p,b.range=u.range,b.query=u.query,b.text=u.text):b.active=!1):(u||(b.dismissedRange=null),b.active=!1)}else b.active=!1;return b.active||(b.decorationId=null,b.range={from:0,to:0},b.query=null,b.text=null),b}}}function eE({editor:e,items:t}){let n=null,r=null,i=null,a=()=>{r!==null&&(clearTimeout(r),r=null),i?.(),i=null},o=e=>new Promise(t=>{i=t,r=setTimeout(()=>{r=null;let e=i;i=null,e?.()},e)}),s=()=>{n?.abort(),a(),n=null};return{abort:s,fetch:async(r,i)=>{s(),n=new AbortController;let a=n;if(i>0&&await o(i),n!==a||a.signal.aborted)return{status:`aborted`};try{let i=await t({editor:e,query:r,signal:a.signal});return n!==a||a.signal.aborted?{status:`aborted`}:{status:`resolved`,items:i}}catch{return n!==a||a.signal.aborted?{status:`aborted`}:{status:`error`}}}}}function tE({placement:e,offset:t,flip:n,floatingUi:r}){var i;let a=[iC({mainAxis:t.mainAxis??4,crossAxis:t.crossAxis??0})];return n&&a.push(sC()),r!=null&&(i=r.middleware)!=null&&i.length&&a.push(...r.middleware),{placement:e,strategy:r?.strategy??`absolute`,middleware:a}}function nE(e){if(e instanceof HTMLElement)return e;if(typeof e==`string`)try{let t=document.querySelector(e);if(t)return t}catch{return document.body}return document.body}function rE({getReferenceRect:e,contextElement:t,config:n,container:r,dismissOnOutsideClick:i,dismiss:a}){return(o,s={})=>{let c={getBoundingClientRect:()=>e()??new DOMRect,contextElement:t},l=!1,u=!o.isConnected;u&&nE(r).appendChild(o),s.onPosition||(o.style.visibility=`hidden`,o.style.width=`max-content`);let d=rC(c,o,()=>{fC(c,o,{placement:n.placement,strategy:n.strategy,middleware:n.middleware}).then(({x:e,y:t,placement:n,strategy:r})=>{s.onPosition?s.onPosition({x:e,y:t,placement:n,strategy:r}):(Object.assign(o.style,{position:r,left:`${e}px`,top:`${t}px`}),l||(l=!0,o.style.visibility=``))})},s.autoUpdate),f;return i&&(f=e=>{let n=e.target;!(n instanceof Node)||o.contains(n)||t.contains(n)||a()},document.addEventListener(`pointerdown`,f,!0)),()=>{d(),f&&document.removeEventListener(`pointerdown`,f,!0),u&&o.remove()}}}function iE({editor:e,pluginKey:t,items:n,renderer:r,minQueryLength:i,debounce:a,initialItems:o,placement:s,offset:c,container:l,flip:u,floatingUi:d,dismissOnOutsideClick:f,command:p,clientRectFor:m,dispatchExit:h}){let g,_=eE({editor:e,items:n}),v=tE({placement:s,offset:c,flip:u,floatingUi:d});function y(e,t){switch(e){case`started`:var n;r==null||(n=r.onStart)==null||n.call(r,t);break;case`updated`:var i;r==null||(i=r.onUpdate)==null||i.call(r,t);break;case`stopped`:var a;r==null||(a=r.onExit)==null||a.call(r,t)}}return{update:async(n,d)=>{let b=t.getState(d),x=t.getState(n.state);if(!b||!x)return;let S=null,C=b.query!==x.query,w=b.text!==x.text,T=b.range.from!==x.range.from||b.range.to!==x.range.to,ee=C||w||T;if(!b.active&&x.active)S=`started`;else if(b.active&&!x.active)S=`stopped`;else if(x.active&&ee)S=`updated`;else return;let E=S===`stopped`?b:x,D=n.dom.querySelector(`[data-decoration-id="${E.decorationId}"]`),te=m(n,D),ne=i===0||(E.query?E.query.length>=i:!1),re=(S===`started`||S===`updated`)&≠if(g={editor:e,range:E.range,query:E.query||``,text:E.text||``,items:o??[],command:t=>p({editor:e,range:E.range,props:t}),decorationNode:D,clientRect:te,loading:re,placement:s,offset:{mainAxis:c.mainAxis??4,crossAxis:c.crossAxis??0},container:l,flip:u,floatingUi:v,mount:rE({getReferenceRect:te,contextElement:n.dom,config:v,container:l,dismissOnOutsideClick:f,dismiss:()=>h(e.view)})},S===`started`){var ie;r==null||(ie=r.onBeforeStart)==null||ie.call(r,g)}if(S===`updated`){var ae;r==null||(ae=r.onBeforeUpdate)==null||ae.call(r,g)}if(S===`started`&&y(S,g),S===`started`||S===`updated`){if(!re)_.abort(),g={...g,items:o??[],loading:!1};else{g={...g,items:o??[],loading:!0},S=`updated`,y(S,g);let e=await _.fetch(E.query||``,a);if(e.status===`aborted`)return;if(!t.getState(n.state)?.active){_.abort();return}g=e.status===`resolved`?{...g,items:e.items,loading:!1}:{...g,loading:!1}}}S===`stopped`?(_.abort(),y(S,g),g=void 0):S===`updated`&&y(S,g)},destroy:()=>{var e;_.abort(),g&&(r==null||(e=r.onExit)==null||e.call(r,g))}}}var aE=new N(`suggestion`);function oE({pluginKey:e=aE,editor:t,char:n=`@`,allowSpaces:r=!1,allowToIncludeChar:i=!1,allowedPrefixes:a=[` `],startOfLine:o=!1,decorationTag:s=`span`,decorationClass:c=`suggestion`,decorationContent:l=``,decorationEmptyClass:u=`is-empty`,command:d=()=>null,items:f=()=>[],minQueryLength:p=0,debounce:m=0,initialItems:h,placement:g=`bottom-start`,offset:_={},container:v,flip:y=!0,floatingUi:b,dismissOnOutsideClick:x=!0,render:S=()=>({}),allow:C=()=>!0,findSuggestionMatch:w=KT,shouldShow:T,shouldResetDismissed:ee}){let E=S?.(),D=r&&!i,te=(n,r)=>YT(t,n,r,e);function ne(e){return XT({...e,editor:t,shouldResetDismissed:ee,effectiveAllowSpaces:D})}let re=t=>ZT({view:t,pluginKeyRef:e});return new M({key:e,view:()=>iE({editor:t,pluginKey:e,items:f,renderer:E,minQueryLength:p,debounce:m,initialItems:h,placement:g,offset:_,container:v,flip:y,floatingUi:b,dismissOnOutsideClick:x,command:d,clientRectFor:te,dispatchExit:re}),state:$T({editor:t,char:n,effectiveAllowSpaces:D,allowToIncludeChar:i,allowedPrefixes:a,startOfLine:o,findSuggestionMatch:w,allow:C,shouldShow:T,shouldKeepDismissed:ne,pluginKey:e}),props:QT({pluginKey:e,decorationTag:s,decorationClass:c,decorationContent:l,decorationEmptyClass:u,renderer:E,dispatchExit:re})})}var sE=oE;function cE(){let e=null,t=null,n=[],r=0,i=null,a=()=>{if(e.innerHTML=``,n.length===0){let t=document.createElement(`div`);t.className=`efe-suggest__empty`,t.textContent=X(`editor.variable_suggestion.no_results`),e.appendChild(t)}else n.forEach((t,n)=>{let a=document.createElement(`button`);a.type=`button`,a.className=`efe-suggest__item`,a.classList.toggle(`is-active`,n===r),a.textContent=t.label,a.dataset.efeVariableName=t.name,a.addEventListener(`mousedown`,e=>{e.preventDefault(),i?.(t)}),e.appendChild(a)})};return{onStart:o=>{e=document.createElement(`div`),e.className=`efe-suggest`,e.setAttribute(`role`,`listbox`),e.setAttribute(`aria-label`,X(`editor.variable_suggestion.choose`)),n=o.items,r=0,i=o.command,a(),t=o.mount(e)},onUpdate:e=>{n=e.items,r=0,i=e.command,a()},onKeyDown:({event:e})=>n.length===0&&e.key!==`Escape`?!1:e.key===`ArrowDown`?(r=(r+1)%n.length,a(),!0):e.key===`ArrowUp`?(r=(r-1+n.length)%n.length,a(),!0):e.key===`Enter`?(i?.(n[r]),!0):e.key===`Escape`&&(t?.(),!0),onExit:()=>{t?.(),e=null}}}var lE=V.create({name:`variableSuggestion`,addOptions(){return{variables:{},char:`{{`}},addProseMirrorPlugins(){let e=this;return[sE({editor:this.editor,char:this.options.char,allowSpaces:!1,items:({query:t})=>DT(e.options.variables,t),command:({editor:e,range:t,props:n})=>{e.chain().focus().insertContentAt(t,{type:`docVariable`,attrs:{name:n.name}}).run()},render:cE})]}});function uE(e){return({node:t,getPos:n,editor:r})=>{let i=!!e.templateMode,a=t,o=document.createElement(`section`);o.className=`efe-section`;let s=document.createElement(`div`);s.className=`efe-section__head`,s.setAttribute(`contenteditable`,`false`);let c=document.createElement(`div`);c.className=`efe-section__content`;let l=document.createElement(`div`);l.className=`efe-section__repeat`,l.setAttribute(`contenteditable`,`false`),o.append(s,c,l);let u=e=>e.attrs.title?String(e.attrs.title):``,d=e=>{s.replaceChildren();let{mode:t,repeatable:n}=e.attrs,r=u(e);if(i){let e=document.createElement(`span`);if(e.className=`efe-section__badge`,e.textContent=X(t===`locked`?`editor.section_view.locked`:`editor.section_view.free`),Y(e,X(t===`locked`?`editor.section_view.locked_tip`:`editor.section_view.free_tip`)),s.append(e),n){let e=document.createElement(`span`);e.className=`efe-section__badge efe-section__badge--repeat`,e.textContent=X(`editor.section_view.repeatable`),s.append(e)}}else if(t===`locked`){let e=document.createElement(`span`);e.className=`efe-section__lock`,e.append(sx(`lock`)),Y(e,X(`editor.section_view.from_template`)),s.append(e)}if(r){let e=document.createElement(`span`);e.className=`efe-section__title`,e.textContent=r,s.append(e)}s.hidden=s.childElementCount===0},f=()=>{let e=typeof n==`function`?n():void 0,t=a.attrs.templateSectionId;if(typeof e!=`number`||!t||a.attrs.repeatable!==!0)return null;let i=0,o=null;return r.state.doc.forEach((e,n)=>{e.type.name===`docSection`&&e.attrs.repeatable===!0&&e.attrs.templateSectionId===t&&(i+=1,o=n)}),{pos:e,count:i,isLast:o===e}},p=(e,t,n,r)=>{let i=document.createElement(`button`);return i.type=`button`,i.className=`efe-section__repeat-btn`,i.append(sx(e),document.createTextNode(t)),Y(i,n),i.addEventListener(`mousedown`,e=>e.preventDefault()),i.addEventListener(`click`,e=>{e.preventDefault(),r()}),i},m=()=>{l.replaceChildren();let e=!i&&r.isEditable?f():null;if(!e){l.hidden=!0;return}let t=u(a)||X(`editor.section_view.section`);e.count>1&&l.append(p(`trash`,X(`editor.section_view.remove`),X(`editor.section_view.remove_tip`,{title:t}),()=>{let e=n();typeof e==`number`&&r.commands.removeSectionInstance(e)})),e.isLast&&l.append(p(`plus`,X(`editor.section_view.add_another`,{title:t}),X(`editor.section_view.add_another_tip`,{title:t}),()=>{let e=n();typeof e==`number`&&r.commands.addSectionInstance(e)})),l.hidden=l.childElementCount===0},h=e=>{a=e;let{mode:t,sectionId:n,hint:r}=e.attrs;n?o.dataset.efeSection=n:delete o.dataset.efeSection,o.dataset.efeMode=t,o.classList.toggle(`efe-section--locked`,t===`locked`),o.classList.toggle(`efe-section--free`,t===`free`),o.classList.toggle(`efe-section--repeatable`,e.attrs.repeatable===!0),o.classList.toggle(`efe-section--titled`,!!e.attrs.title),r?(c.dataset.efeHint=r,c.style.setProperty(`--efe-hint`,JSON.stringify(String(r)))):(delete c.dataset.efeHint,c.style.removeProperty(`--efe-hint`)),d(e),m(),!i&&t===`locked`?(c.setAttribute(`contenteditable`,`false`),c.setAttribute(`aria-readonly`,`true`)):(c.removeAttribute(`contenteditable`),c.removeAttribute(`aria-readonly`))};h(t);let g=null,_=t=>{if(i||a.attrs.mode!==`locked`||!r.isEditable)return;let n=t.target instanceof Element?t.target:null;n&&c.contains(n)&&!n.closest(`.efe-field`)&&(o.classList.add(`is-nudged`),clearTimeout(g),g=setTimeout(()=>o.classList.remove(`is-nudged`),900),typeof e.onBlocked==`function`&&e.onBlocked(`locked-content`))};o.addEventListener(`mousedown`,_);let v=({transaction:e})=>{(e.docChanged||e.getMeta(`efePreview`)!==void 0)&&m()};return r.on(`transaction`,v),{dom:o,contentDOM:c,update:e=>e.type===t.type&&(h(e),!0),stopEvent:e=>{let t=e.target instanceof Node?e.target:null;return!!(t&&(s.contains(t)||l.contains(t)))},ignoreMutation:e=>e.type!==`selection`&&!c.contains(e.target),destroy:()=>{clearTimeout(g),o.removeEventListener(`mousedown`,_),r.off(`transaction`,v)}}}}function dE(){return typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():`section-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function fE(e){return e.attrs.templateSectionId||e.attrs.sectionId||null}function pE(e,t){return typeof t==`number`&&t>=0&&t=0;--t){let n=e.node(t);if(n.type.name===`docSection`)return{node:n,before:e.before(t),after:e.after(t)}}return null}function hE(e){let t=[];return e.forEach(e=>{e.type.name===`docSection`&&t.push(`${e.attrs.sectionId}:${fE(e)}:${e.attrs.mode}:${e.attrs.repeatable?`r`:`-`}`)}),t.join(`|`)}function gE(e){let t=[];return e.forEach(e=>{e.type.name===`docSection`&&t.push(e)}),t}function _E(e,t){let n=gE(e),r=gE(t),i=r.length-n.length;if(i!==1&&i!==-1)return!1;let a=i===1?r:n,o=i===1?n:r,s=o.length;for(let e=0;ee.attrs.templateSectionId===l&&e.attrs.repeatable===!0;for(let e=0;ee.attrs.sectionId));return!!c.attrs.sectionId&&!t.has(c.attrs.sectionId)}return o.some(u)}function vE(e){let t=new Set,n=!0;return e.forEach(e=>{if(e.type.name!==`docSection`)return;let r=e.attrs.sectionId;(!r||t.has(r))&&(n=!1),t.add(r)}),n}function yE(e){let t=[];return e.forEach((e,n)=>{e.type.name===`docSection`&&e.attrs.mode===`locked`&&t.push([n,n+e.nodeSize])}),t}function bE(e,t){let n=yE(t);if(n.length===0)return!1;let r=!1;return e.getMap().forEach((e,t)=>{for(let[i,a]of n)ei&&(r=!0)}),r}var xE=H.create({name:`docSection`,content:`block+`,defining:!0,isolating:!0,addOptions(){return{templateMode:!1,onBlocked:null}},addAttributes(){return{mode:{default:`free`,parseHTML:e=>e.getAttribute(`data-efe-mode`)??`free`,renderHTML:e=>({"data-efe-mode":e.mode})},sectionId:{default:null,parseHTML:e=>e.getAttribute(`data-efe-section`),renderHTML:e=>({"data-efe-section":e.sectionId})},templateSectionId:{default:null,parseHTML:e=>e.getAttribute(`data-efe-template-section`),renderHTML:e=>e.templateSectionId?{"data-efe-template-section":e.templateSectionId}:{}},repeatable:{default:!1,parseHTML:e=>e.getAttribute(`data-efe-repeatable`)===`true`,renderHTML:e=>e.repeatable?{"data-efe-repeatable":`true`}:{}},title:{default:``,parseHTML:()=>``,renderHTML:()=>({})},hint:{default:``,parseHTML:()=>``,renderHTML:()=>({})}}},parseHTML(){return[{tag:`section[data-efe-section][data-efe-mode]`}]},renderHTML({HTMLAttributes:e}){return[`section`,B({class:`efe-section`},e),0]},addCommands(){let e=this;return{insertSection:(t=`free`)=>({state:n,tr:r,dispatch:i})=>{if(!e.options.templateMode)return!1;let a=n.schema.nodes.docSection,o=n.schema.nodes.paragraph;if(!a)return!1;let s=dE(),c=a.create({mode:t,sectionId:s,templateSectionId:s},o?o.create():void 0),l=mE(n.selection.$from),u=l?l.after:n.doc.content.size;return i&&r.insert(u,c).scrollIntoView(),!0},toggleSectionMode:()=>({state:t,tr:n,dispatch:r})=>{if(!e.options.templateMode)return!1;let i=mE(t.selection.$from);if(!i)return!1;let a=i.node.attrs.mode===`locked`?`free`:`locked`;return r&&n.setNodeMarkup(i.before,void 0,{...i.node.attrs,mode:a}),!0},addSectionInstance:e=>({state:t,tr:n,dispatch:r})=>{let i=mE(pE(t,e));if(!i||!i.node.attrs.templateSectionId||i.node.attrs.repeatable!==!0)return!1;let a=i.node.type.create({...i.node.attrs,sectionId:dE()},CE(i.node).content,i.node.marks);return r&&n.insert(i.after,a).setMeta(`sectionInstance`,!0).scrollIntoView(),!0},removeSectionInstance:e=>({state:t,tr:n,dispatch:r})=>{let i=mE(pE(t,e));if(!i||!i.node.attrs.templateSectionId||i.node.attrs.repeatable!==!0)return!1;let a=i.node.attrs.templateSectionId,o=0;return t.doc.forEach(e=>{e.type.name===`docSection`&&e.attrs.repeatable===!0&&e.attrs.templateSectionId===a&&(o+=1)}),o<2?!1:(r&&n.delete(i.before,i.after).setMeta(`sectionInstance`,!0),!0)}}},addNodeView(){return uE(this.options)}}),SE=H.create({name:`doc`,topNode:!0,content:`docSection+`});function CE(e){if(e.type.name===`docField`)return e.type.create({...e.attrs,value:``},null,e.marks);if(e.childCount===0)return e;let t=[];return e.forEach(e=>{t.push(CE(e))}),e.copy(c.fromArray(t))}var wE=V.create({name:`sectionLockGuard`,addOptions(){return{templateMode:!1,onBlocked:null}},addProseMirrorPlugins(){let e=this;return[new M({key:new N(`sectionLockGuard`),filterTransaction(t,n){let r=t=>(typeof e.options.onBlocked==`function`&&e.options.onBlocked(t),!1);if(!t.docChanged||(e.options.templateMode&&t.setMeta(`templateMode`,!0),e.options.templateMode||t.getMeta(`templateMode`)===!0))return!0;if(!vE(n.doc))return console.warn(`[sectionLockGuard] Ungueltige sectionIds (leer oder doppelt) im Dokument. Transaktion im Schreibmodus vorsorglich verworfen.`),r(`invalid-section-ids`);if(t.getMeta(`sectionInstance`)===!0)return _E(n.doc,t.doc)?!0:r(`section-structure`);for(let e=0;e0?`choice`:`line`}function jE(e){return EE.includes(e?.format)?e.format:`plain`}function ME(e){return`${e}-${typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}`}function NE(e,t){let n=OE[t],r=kE[t],i=[];for(let a of e??[])for(let e of IE(a,n,r,t===`full`))i.push(e);return i}function PE(e){let t=e?.attrs?.styleClass;return typeof t==`string`&&/^[a-z][a-z0-9-]{0,31}$/.test(t)?{styleClass:t}:{}}function FE(e,t){let n=[];for(let r of e??[])if(r?.type===`text`&&typeof r.text==`string`&&r.text!==``){let e=(r.marks??[]).filter(e=>t.includes(e?.type)).map(e=>{if(e.type!==`textStyle`)return{type:e.type};let t={...PE(e)};return typeof e.attrs?.fontFamily==`string`&&(t.fontFamily=e.attrs.fontFamily),Object.keys(t).length?{type:`textStyle`,attrs:t}:{type:`textStyle`}});n.push(e.length?{type:`text`,text:r.text,marks:e}:{type:`text`,text:r.text})}else r?.type===`hardBreak`?n.push({type:`hardBreak`}):r?.type===`docVariable`&&r.attrs?.name&&n.push({type:`docVariable`,attrs:{name:r.attrs.name}});return n}function IE(e,t,n,r){let i=e?.type;if(!i)return[];if(i===`text`||i===`hardBreak`||i===`docVariable`){let t=FE([e],n);return t.length?[{type:`paragraph`,content:t}]:[]}let a=t.includes(i);if(i===`paragraph`||i===`heading`){let t=FE(e.content,n),o={type:a?i:`paragraph`},s={};return a&&i===`heading`&&(s.level=[1,2,3].includes(e.attrs?.level)?e.attrs.level:1),r&&[`left`,`center`,`right`,`justify`].includes(e.attrs?.textAlign)&&(s.textAlign=e.attrs.textAlign),n.includes(`textStyle`)&&Object.assign(s,PE(e)),Object.keys(s).length&&(o.attrs=s),t.length&&(o.content=t),[o]}if([`bulletList`,`orderedList`,`blockquote`,`listItem`,`table`,`tableRow`,`tableHeader`,`tableCell`].includes(i)){if(a&&[`bulletList`,`orderedList`,`table`,`tableRow`,`tableHeader`,`tableCell`,`listItem`,`blockquote`].includes(i)){let a=[`table`,`tableRow`].includes(i)||[`bulletList`,`orderedList`].includes(i)?(e.content??[]).map(e=>RE(e,t,n,r)).filter(Boolean):LE(e.content,t,n,r);if(!a.length)return[];let o={type:i,content:a};return e.attrs&&(i===`orderedList`||i===`tableCell`||i===`tableHeader`)&&(o.attrs=e.attrs),[o]}let o=[];for(let i of e.content??[])o.push(...IE(i,t,n,r));return o}return(i===`horizontalRule`||i===`pageBreak`)&&a?[{type:i}]:[]}function LE(e,t,n,r){let i=[];for(let a of e??[])i.push(...IE(a,t,n,r));return i.length?i:[{type:`paragraph`}]}function RE(e,t,n,r){let i=e?.type;if(i===`tableRow`){let a=(e.content??[]).map(e=>RE(e,t,n,r)).filter(Boolean);return a.length?{type:i,content:a}:null}if(i===`listItem`||i===`tableCell`||i===`tableHeader`){let a={type:i,content:LE(e.content,t,n,r)};return e.attrs&&i!==`listItem`&&(a.attrs=e.attrs),a}return null}var Z=e=>({default:e,rendered:!1,keepOnSplit:!1}),zE=()=>({templateMode:!1,can:null,onBlocked:null});function BE(e,t){return!t||typeof e.can!=`function`||!!e.can(t)}function VE(e){return!e||typeof e!=`object`?``:e.type===`text`?e.text??``:(e.content??[]).map(VE).join(e.type===`paragraph`?``:` `)}var HE=Wf.create({name:`efePrompt`,inclusive:!1,excludes:``,parseHTML(){return[{tag:`span.efe-prompt`}]},renderHTML({HTMLAttributes:e}){return[`span`,B({class:`efe-prompt`},e),0]}}),UE=H.create({name:`docInput`,group:`block`,content:`(docFixed | block)*`,defining:!0,isolating:!0,addOptions:zE,addAttributes(){return{inputId:Z(null),kind:Z(`text`),label:Z(``),format:Z(`plain`),start:Z(`empty`),placeholder:Z(``),required:Z(!1),minLength:Z(null),who:Z(null),snippets:Z(null),choice:Z(null)}},parseHTML(){return[{tag:`div[data-efe-input]`}]},renderHTML({node:e,HTMLAttributes:t}){return[`div`,B({class:`efe-input`,"data-efe-input":e.attrs.inputId??``},t),0]},addNodeView(){return XE(this.options)}}),WE=H.create({name:`docFixed`,content:`block+`,defining:!0,isolating:!0,addOptions:zE,addAttributes(){return{fixedId:Z(null)}},parseHTML(){return[{tag:`div[data-efe-fixed]`}]},renderHTML({node:e,HTMLAttributes:t}){return[`div`,B({class:`efe-fixed`,"data-efe-fixed":e.attrs.fixedId??``},t),0]},addNodeView(){return ZE(this.options,`fixed`)}}),GE=H.create({name:`docAside`,group:`block`,content:`block+`,defining:!0,isolating:!0,addOptions:zE,addAttributes(){return{asideId:Z(null),side:Z(`right`),width:Z(60),frame:Z(!0)}},parseHTML(){return[{tag:`aside[data-efe-aside]`}]},renderHTML({node:e,HTMLAttributes:t}){let n=e.attrs.side===`left`?`left`:`right`;return[`aside`,B({class:`efe-aside efe-aside--${n}${e.attrs.frame===!1?``:` efe-aside--framed`}`,"data-efe-aside":e.attrs.asideId??``,style:`float: ${n}; width: ${Number(e.attrs.width)||60}mm`},t),0]},addNodeView(){return ZE(this.options,`aside`)}}),KE=H.create({name:`docRepeat`,group:`block`,content:`block+`,defining:!0,isolating:!0,addOptions:zE,addAttributes(){return{repeatId:Z(null),instanceId:Z(null),label:Z(``)}},parseHTML(){return[{tag:`div[data-efe-repeat]`}]},renderHTML({node:e,HTMLAttributes:t}){return[`div`,B({class:`efe-repeat`,"data-efe-repeat":e.attrs.instanceId??``},t),0]},addNodeView(){return ZE(this.options,`repeat`)}}),qE=H.create({name:`docOptional`,group:`block`,content:`block+`,defining:!0,isolating:!0,addOptions:zE,addAttributes(){return{optionalId:Z(null),label:Z(``),enabled:Z(!0)}},parseHTML(){return[{tag:`div[data-efe-optional]`}]},renderHTML({node:e,HTMLAttributes:t}){return[`div`,B({class:`efe-optional`,"data-efe-optional":e.attrs.optionalId??``},t),0]},addNodeView(){return ZE(this.options,`optional`)}});function JE(e,t=`efe-block__badge`){let n=document.createElement(`span`);return n.className=t,n.textContent=e,n}function YE(e,t,n,r){let i=document.createElement(`button`);return i.type=`button`,i.className=`efe-block__btn`,i.append(sx(e),document.createTextNode(t)),Y(i,n),i.addEventListener(`mousedown`,e=>e.preventDefault()),i.addEventListener(`click`,e=>{e.preventDefault(),r()}),i}function XE(e){return({node:t,getPos:n,editor:r})=>{let i=!!e.templateMode,a=t,o=document.createElement(`div`);o.className=`efe-input`;let s=document.createElement(`div`);s.className=`efe-block__head efe-input__head`,s.setAttribute(`contenteditable`,`false`);let c=t.attrs.kind===`snippet`,l=c?null:document.createElement(`div`),u=c?document.createElement(`div`):null;l?(l.className=`efe-input__body`,o.append(s,l)):(u.className=`efe-input__snippet`,u.setAttribute(`contenteditable`,`false`),o.append(s,u));let d=t=>{let a=Array.isArray(t.attrs.snippets)?t.attrs.snippets:[];if(u.replaceChildren(),!i){let i=document.createElement(`select`);i.className=`efe-input__choice`,i.setAttribute(`aria-label`,t.attrs.label||X(`editor.inputs.snippet`)),i.append(new Option(`${X(`editor.inputs.choose_snippet`,{label:t.attrs.label||X(`editor.inputs.snippet`)})}${t.attrs.required?` *`:``}`,``));for(let e of a)i.append(new Option(e.name??e.id,e.id));i.value=t.attrs.choice??``,i.disabled=!r.isEditable||!BE(e,t.attrs.who),i.addEventListener(`change`,()=>{let e=n();typeof e==`number`&&r.commands.chooseSnippet(e,i.value||null)}),u.append(i)}let o=i?a[0]:a.find(e=>e.id===t.attrs.choice);if(o){let e=document.createElement(`p`);e.className=`efe-input__snippet-text`,e.textContent=(Array.isArray(o.content)?o.content:o.content?.content??[]).map(VE).join(` +`),u.append(e)}if(i&&a.length){let e=document.createElement(`div`);e.className=`efe-input__snippet-more`,e.textContent=X(`editor.inputs.variants`,{count:a.length,names:a.map(e=>e.name??e.id).join(` · `)}),u.append(e)}},f=t=>{a=t;let{label:n,required:u,format:f,who:p,placeholder:m,kind:h}=t.attrs,g=!i&&!BE(e,p);if(o.dataset.efeInput=t.attrs.inputId??``,o.dataset.efeKind=h??`text`,o.dataset.efeFormat=f??`plain`,o.classList.toggle(`is-required`,!!u),o.classList.toggle(`is-locked`,g),o.classList.toggle(`is-empty`,!c&&t.textContent.trim()===``),s.replaceChildren(JE(n||X(c?`editor.inputs.snippet`:`editor.inputs.text_area`),`efe-block__label`)),u&&s.append(JE(X(`editor.inputs.required`))),p&&(i||g)){let e=JE(i?X(`editor.inputs.only_who`,{who:p}):X(`editor.inputs.locked`),`efe-block__badge efe-block__badge--who`);Y(e,X(i?`editor.inputs.only_who_tip`:`editor.inputs.filled_by`,{who:p})),s.append(e)}l?(m?l.style.setProperty(`--efe-placeholder`,JSON.stringify(String(m))):l.style.removeProperty(`--efe-placeholder`),i?l.removeAttribute(`contenteditable`):l.setAttribute(`contenteditable`,g||!r.isEditable?`false`:`true`)):d(t)};f(t);let p=({transaction:e})=>{e.getMeta(`efePreview`)!==void 0&&f(a)};return r.on(`transaction`,p),{dom:o,contentDOM:l,destroy:()=>r.off(`transaction`,p),update:e=>e.type!==t.type||e.attrs.kind===`snippet`!==c?!1:(f(e),!0),stopEvent:e=>{let t=e.target instanceof window.Node?e.target:null;return!!(t&&(s.contains(t)||u?.contains(t)))},ignoreMutation:e=>e.type===`selection`?!1:!l||e.type===`attributes`&&(e.target===l||e.target===o)||!l.contains(e.target),get node(){return a}}}}function ZE(e,t){return({node:n,getPos:r,editor:i})=>{let a=!!e.templateMode,o=n,s=document.createElement(t===`aside`?`aside`:`div`);s.className=`efe-${t}`;let c=document.createElement(`div`);c.className=`efe-block__head efe-${t}__head`,c.setAttribute(`contenteditable`,`false`);let l=document.createElement(`div`);l.className=`efe-${t}__body`,s.append(c,l);let u=()=>{let e=0;return i.state.doc.forEach(t=>{t.type.name===`docRepeat`&&t.attrs.repeatId===o.attrs.repeatId&&(e+=1)}),e},d=()=>{let e=r();if(typeof e!=`number`)return!1;let t=i.state.doc.nodeAt(e+o.nodeSize);return!t||t.type.name!==`docRepeat`||t.attrs.repeatId!==o.attrs.repeatId},f=()=>{c.replaceChildren();let e=o.attrs.label?String(o.attrs.label):``;if(t===`fixed`)c.append(JE(X(`editor.inputs.fixed`))),Y(c,X(a?`editor.inputs.fixed_tip`:`editor.inputs.from_template`));else if(t===`aside`)a&&c.append(JE(X(`editor.inputs.aside_fixed`)));else if(t===`repeat`)c.append(JE(e||X(`editor.inputs.entry`),`efe-block__label`)),a?c.append(JE(X(`editor.inputs.repeatable`))):i.isEditable&&(u()>1&&c.append(YE(`trash`,X(`editor.inputs.remove`),X(`editor.inputs.remove_tip`,{label:e||X(`editor.inputs.entry`)}),()=>{let e=r();typeof e==`number`&&i.commands.removeRepeatInstance(e)})),d()&&c.append(YE(`plus`,X(`editor.inputs.add_another`,{label:e||X(`editor.inputs.entry`)}),X(`editor.inputs.add_another_tip`,{label:e||X(`editor.inputs.entry`)}),()=>{let e=r();typeof e==`number`&&i.commands.addRepeatInstance(e)})));else if(t===`optional`){let t=document.createElement(`label`);t.className=`efe-optional__toggle`;let n=document.createElement(`input`);n.type=`checkbox`,n.checked=o.attrs.enabled!==!1,n.disabled=!i.isEditable,n.addEventListener(`change`,()=>{let e=r();typeof e==`number`&&i.commands.toggleOptional(e)}),t.append(n,document.createTextNode(` ${e||X(`editor.inputs.optional_block`)}`)),c.append(t),a&&c.append(JE(X(`editor.inputs.optional`)))}c.hidden=c.childElementCount===0},p=e=>{if(o=e,t===`aside`){let t=e.attrs.side===`left`?`left`:`right`;s.className=`efe-aside efe-aside--${t}${e.attrs.frame===!1?``:` efe-aside--framed`}`,s.style.float=t,s.style.width=`${Number(e.attrs.width)||60}mm`}t===`optional`&&s.classList.toggle(`is-off`,e.attrs.enabled===!1),f()};p(n);let m=({transaction:e})=>{t===`repeat`&&e.docChanged&&f()};return i.on(`transaction`,m),{dom:s,contentDOM:l,update:e=>e.type===n.type&&(p(e),!0),stopEvent:e=>{let t=e.target instanceof window.Node?e.target:null;return!!(t&&c.contains(t))},ignoreMutation:e=>e.type===`selection`?!1:e.type===`attributes`&&e.target===s||!l.contains(e.target),destroy:()=>{i.off(`transaction`,m)}}}}function QE(e){let t=e=>{if(!e||typeof e!=`object`)return e;if(e.type===`docField`)return{...e,attrs:{...e.attrs,value:``}};if(e.type===`docInput`){if(e.attrs?.kind===`snippet`)return{...e,attrs:{...e.attrs,choice:null}};let n=(e.content??[]).filter(e=>e.type===`docFixed`).map(t);return{...e,content:[{type:`paragraph`},...n]}}return e.content?{...e,content:e.content.map(t)}:e},n=t(e);return{...n,attrs:{...n.attrs,instanceId:ME(`i`)}}}function $E(e,t){for(let n=e.depth;n>=0;--n){let r=e.node(n);if(t.includes(r.type.name))return{node:r,depth:n,pos:n>0?e.before(n):0}}return null}function eD(e){let t=$E(e,[`docInput`,`docFixed`]);return!!(t&&t.node.type.name===`docInput`)}var tD=V.create({name:`inputCommands`,addOptions:zE,addCommands(){let e=this,t=()=>!!e.options.templateMode;return{insertInputField:(e=`line`,n={})=>({state:r,tr:i,dispatch:a})=>{if(!t())return!1;let{$from:o,$to:s,empty:c}=r.selection;if(!o.parent.isTextblock||o.parent!==s.parent||eD(o))return!1;let l=c?``:r.doc.textBetween(o.pos,s.pos,` `).trim(),u=r.schema.nodes.docField.create({fieldId:ME(`f`),kind:e,label:(n.label??Array.from(l).slice(0,60).join(``))||X(`editor.inputs.field`),...e===`choice`?{options:[{label:X(`editor.inputs.option_a`)},{label:X(`editor.inputs.option_b`)}]}:{},...n});return a&&i.replaceSelectionWith(u,!1),!0},freeAsTextArea:(e={})=>({state:n,tr:r,dispatch:i})=>{if(!t())return!1;let{$from:a,$to:o,empty:s}=n.selection;if($E(a,[`docInput`,`docAside`]))return!1;let c=n.schema.nodes.docInput,l={inputId:ME(`t`),kind:`text`,label:X(`editor.inputs.text_area`),...e};if(s){let e=c.create({format:`basic`,start:`empty`,...l},n.schema.nodes.paragraph.create()),t=a.after(a.depth);return i&&r.insert(t,e),!0}let u=a.blockRange(o);return u?(i&&r.wrap(u,[{type:c,attrs:{format:`full`,start:`suggestion`,...l}}]),!0):!1},freeAsSnippet:(e={})=>({state:n,tr:r,dispatch:i})=>{if(!t())return!1;let{$from:a,$to:o}=n.selection;if($E(a,[`docInput`,`docAside`]))return!1;let s=a.blockRange(o);if(!s)return!1;let c=[];for(let e=s.startIndex;e({state:e,tr:n,dispatch:r})=>{if(!t())return!1;let{$from:i,$to:a}=e.selection;if(!eD(i)||!eD(a))return!1;let o=i.blockRange(a,e=>e.type.name===`docInput`);return o?(r&&n.wrap(o,[{type:e.schema.nodes.docFixed,attrs:{fixedId:ME(`x`)}}]),!0):!1},releaseFixed:()=>({state:e,tr:n,dispatch:r})=>{if(!t())return!1;let i=$E(e.selection.$from,[`docFixed`]);return i?(r&&n.replaceWith(i.pos,i.pos+i.node.nodeSize,i.node.content),!0):!1},dissolveInput:()=>({state:e,tr:n,dispatch:r})=>{if(!t())return!1;let i=$E(e.selection.$from,[`docInput`]);if(!i)return!1;let a;if(i.node.attrs.kind===`snippet`){let t=(i.node.attrs.snippets??[])[0],n=Array.isArray(t?.content)?t.content:[{type:`paragraph`}];a=c.fromJSON(e.schema,n)}else{let t=[];i.node.forEach(e=>{e.type.name===`docFixed`?e.forEach(e=>t.push(e)):t.push(e)}),a=c.fromArray(t.length?t:[e.schema.nodes.paragraph.create()])}return r&&n.replaceWith(i.pos,i.pos+i.node.nodeSize,a),!0},insertAside:(e={})=>({state:n,tr:r,dispatch:i})=>{if(!t())return!1;let a=n.selection.$from,o=a.depth>0?a.before(1):0,s=n.schema.nodes.docAside.create({asideId:ME(`r`),side:`right`,width:60,frame:!0,...e},n.schema.nodes.paragraph.create(null,n.schema.text(X(`editor.inputs.aside`))));return i&&r.insert(o,s),!0},wrapInRepeat:(e={})=>({state:n,tr:r,dispatch:i})=>{if(!t())return!1;let{$from:a,$to:o}=n.selection,s=a.blockRange(o,e=>e.type.name===`doc`);return s?(i&&r.wrap(s,[{type:n.schema.nodes.docRepeat,attrs:{repeatId:ME(`w`),instanceId:ME(`i`),label:X(`editor.inputs.entry`),...e}}]),!0):!1},wrapInOptional:(e={})=>({state:n,tr:r,dispatch:i})=>{if(!t())return!1;let{$from:a,$to:o}=n.selection,s=a.blockRange(o,e=>e.type.name===`doc`);return s?(i&&r.wrap(s,[{type:n.schema.nodes.docOptional,attrs:{optionalId:ME(`o`),label:X(`editor.inputs.optional`),enabled:!0,...e}}]),!0):!1},chooseSnippet:(e,t)=>({state:n,tr:r,dispatch:i})=>{let a=n.doc.nodeAt(e);if(!a||a.type.name!==`docInput`||a.attrs.kind!==`snippet`)return!1;let o=(a.attrs.snippets??[]).some(e=>e.id===t);return t!==null&&!o?!1:(i&&r.setNodeAttribute(e,`choice`,t),!0)},toggleOptional:e=>({state:t,tr:n,dispatch:r})=>{let i=t.doc.nodeAt(e);return!i||i.type.name!==`docOptional`?!1:(r&&n.setNodeAttribute(e,`enabled`,i.attrs.enabled===!1),!0)},addRepeatInstance:e=>({state:t,tr:n,dispatch:r})=>{let i=t.doc.nodeAt(e);if(!i||i.type.name!==`docRepeat`)return!1;let a=t.schema.nodeFromJSON(QE(i.toJSON()));return r&&(n.insert(e+i.nodeSize,a),n.setMeta(`repeatInstance`,!0)),!0},removeRepeatInstance:e=>({state:t,tr:n,dispatch:r})=>{let i=t.doc.nodeAt(e);if(!i||i.type.name!==`docRepeat`)return!1;let a=0;return t.doc.forEach(e=>{e.type.name===`docRepeat`&&e.attrs.repeatId===i.attrs.repeatId&&(a+=1)}),a<2?!1:(r&&(n.delete(e,e+i.nodeSize),n.setMeta(`repeatInstance`,!0)),!0)}}}}),nD=new N(`inputGuard`);function rD(e,t){let n=[];return e.descendants((e,r)=>{if(e.type.name!==`docInput`)return!0;if(e.attrs.kind===`snippet`||!BE(t,e.attrs.who))return!1;let i=r+1;return e.forEach((e,t)=>{e.type.name===`docFixed`&&(n.push([i,r+1+t]),i=r+1+t+e.nodeSize)}),n.push([i,r+e.nodeSize-1]),!1}),n}function iD(e){let t=e=>!e||typeof e!=`object`?e:e.type===`docField`?{...e,attrs:{...e.attrs,value:``}}:e.type===`docInput`?e.attrs?.kind===`snippet`?{...e,attrs:{...e.attrs,choice:null}}:{...e,content:(e.content??[]).filter(e=>e.type===`docFixed`).map(t)}:e.type===`docOptional`?{...e,attrs:{...e.attrs,enabled:!0},content:(e.content??[]).map(t)}:e.content?{...e,content:e.content.map(t)}:e;return t(e)}var aD=(e,t)=>JSON.stringify(e)===JSON.stringify(t);function oD(e){let t=!0;return e.descendants(e=>{if(!t||e.type.name!==`docInput`)return t;if(e.attrs.kind===`snippet`)return!1;let n=jE(e.attrs),r=OE[n],i=kE[n],a=e=>!t||e.type.name===`docFixed`?!1:!r.includes(e.type.name)||e.marks.some(e=>!i.includes(e.type.name))||n!==`full`&&e.attrs?.textAlign?(t=!1,!1):!0;return e.forEach(e=>{a(e)&&e.descendants(a)}),!1}),t}function sD(e,t){let n=[],r=[];e.forEach(e=>n.push(e.toJSON())),t.forEach(e=>r.push(e.toJSON()));let i=r.length-n.length;if(i!==1&&i!==-1)return!1;let a=i===1?r:n,o=i===1?n:r,s=o.length;for(let e=0;ee?.type===`docRepeat`&&e.attrs?.repeatId===l);if(i===-1)return o.some(e=>e.type===`docRepeat`&&e.attrs?.repeatId===l);if(!u.length)return!1;let d=new Set(o.filter(e=>e.type===`docRepeat`).map(e=>e.attrs.instanceId));if(!c.attrs.instanceId||d.has(c.attrs.instanceId))return!1;let f=e=>iD({...e,attrs:{...e.attrs,instanceId:null}});return aD(f(c),f(u[0]))}function cD(e,t,n){let r=t.nodeAt(e.pos);if(!r)return!1;let i=r.type.name;return i===`docField`?e.attr===`value`&&BE(n,r.attrs.who):i===`docInput`?r.attrs.kind===`snippet`&&e.attr===`choice`&&BE(n,r.attrs.who):i===`docOptional`&&e.attr===`enabled`}function lD(e,t,n){return typeof e.attr==`string`&&typeof e.pos==`number`?cD(e,t,n):typeof e.from!=`number`||typeof e.to!=`number`?!1:rD(t,n).some(([t,n])=>e.from>=t&&e.to<=n)}function uD(e){let t=!1;return e.descendants(e=>t?!1:e.type.name!==`docInput`||(t=!0,!1)),t}function dD(e){let t=[],n=(e,n)=>t.push(fs.node(e,n,{contenteditable:`false`,class:`efe-is-fixed`})),r=(e,t)=>{e.type.name===`docInput`?e.forEach((e,r)=>{e.type.name===`docFixed`&&n(t+1+r,t+1+r+e.nodeSize)}):e.isText||(uD(e)?e.forEach((e,n)=>r(e,t+1+n)):n(t,t+e.nodeSize))};return e.forEach((e,t)=>r(e,t)),I.create(e,t)}function fD(e){for(let t=e.depth;t>0;--t){let n=e.node(t);if(n.type.name===`docFixed`)return null;if(n.type.name===`docInput`)return n}return null}var pD=V.create({name:`inputGuard`,addOptions(){return{templateMode:!1,can:null,onBlocked:null}},addProseMirrorPlugins(){let e=this,t=()=>!e.options.templateMode,n=t=>(typeof e.options.onBlocked==`function`&&e.options.onBlocked(t),!1);return[new M({key:nD,filterTransaction(r,i){if(!t()||!r.docChanged)return!0;if(r.getMeta(`repeatInstance`)===!0)return sD(i.doc,r.doc)||n(`structure`);for(let t=0;t{if(e.isTextblock){let n=!1;return e.descendants(e=>{a.isInSet(e.marks)&&(n=!0)}),n&&o.removeMark(t+1,t+e.nodeSize-1,a),!1}return!0});return o.docChanged?(o.setMeta(nD,!0),o.setMeta(`addToHistory`,!1),o):null},props:{decorations(e){return t()?dD(e.doc):null},transformPasted(e,r){if(!t())return e;let i=fD(r.state.selection.$from);if(!i)return n(`locked-content`),m.empty;let a=NE(e.content.toJSON()??[],jE(i.attrs)),o=c.fromJSON(r.state.schema,a);return m.maxOpen(o)},handleClick(e,n){if(!t())return!1;let r=e.state.schema.marks[DE],i=e.state.doc.resolve(n);if(!r||!fD(i))return!1;let a=null,o=null;return i.parent.forEach((e,t)=>{let s=i.start()+t,c=s+e.nodeSize;e.isText&&r.isInSet(e.marks)&&n>=s&&n<=c&&(a=s,o=c)}),a!==null&&(e.dispatch(e.state.tr.setSelection(A.create(e.state.doc,a,o))),!0)},handleDOMEvents:{mousedown(e,r){if(!t()||!(r.target instanceof Element))return!1;let i=r.target.closest(`.efe-is-fixed, .efe-input.is-locked`);return!i||r.target.closest(`.efe-field, .efe-input__body[contenteditable="true"], button, select, input`)||(i.classList.add(`is-nudged`),setTimeout(()=>i.classList.remove(`is-nudged`),900),n(`locked-content`)),!1}}}})]}}),mD=H.create({name:`pageBreak`,group:`block`,atom:!0,selectable:!0,parseHTML(){return[{tag:`div[data-efe-page-break]`}]},renderHTML({HTMLAttributes:e}){return[`div`,B({class:`efe-page-break`,"data-efe-page-break":``},e)]},addCommands(){return{insertPageBreak:()=>({commands:e})=>e.insertContent({type:this.name})}}}),hD={A4:{width:210,height:297}},gD={top:20,right:20,bottom:20,left:20},_D=(e,t,n,r)=>Number.isFinite(e)?Math.max(t,Math.min(n,Math.round(e))):r;function vD(e){let t=e&&typeof e==`object`?e:{},n=t.orientation===`landscape`?`landscape`:`portrait`,r=hD.A4,i={};for(let e of[`top`,`right`,`bottom`,`left`])i[e]=_D(t.margins?.[e],10,80,gD[e]);let a=t.firstPageDifferent===!0,o=a&&t.firstPageMargins?{top:_D(t.firstPageMargins.top,10,80,i.top),bottom:_D(t.firstPageMargins.bottom,10,80,i.bottom)}:{top:i.top,bottom:i.bottom};return{width:n===`landscape`?r.height:r.width,height:n===`landscape`?r.width:r.height,margins:i,first:o,headerDistance:_D(t.headerDistance,4,30,8),footerDistance:_D(t.footerDistance,4,30,7),firstPageDifferent:a,orientation:n}}function yD(e,t){let n=t===1?e.first.top:e.margins.top,r=t===1?e.first.bottom:e.margins.bottom;return e.height-n-r}function bD(e,t,n,r){let i=e?.[t]??{};return n===1&&r&&i.first?i.first:i.rest??null}function xD(e,t){e.style.setProperty(`--efe-page-width`,`${t.width}mm`),e.style.setProperty(`--efe-page-height`,`${t.height}mm`),e.style.minHeight=`${t.height}mm`,e.style.paddingTop=`${t.first.top}mm`,e.style.paddingRight=`${t.margins.right}mm`,e.style.paddingBottom=`${t.margins.bottom}mm`,e.style.paddingLeft=`${t.margins.left}mm`,e.dataset.efeOrientation=t.orientation,e.classList.add(`efe-page--layout`)}function SD(e,t){if(e===`date`&&/^\d{4}-\d{2}-\d{2}$/.test(t)){let[e,n,r]=t.split(`-`);return`${r}.${n}.${e}`}return e===`number`&&/^-?\d+(\.\d+)?$/.test(t)?t.replace(`.`,`,`):t}function CD(e){let t={};return e.descendants(e=>e.type.name!==`docRepeat`&&(e.type.name===`docField`&&e.attrs.fieldId&&(t[e.attrs.fieldId]=SD(e.attrs.kind,e.attrs.value??``)),!0)),t}function wD(e,t,n){let r=document.createElement(`div`);r.className=`efe-band-replica__content`;let i;try{i=ae.fromJSON(e,t)}catch{return r}r.append(Je.fromSchema(e).serializeFragment(i.content));for(let e of r.querySelectorAll(`[data-efe-variable]`)){let t=e.getAttribute(`data-efe-variable`)??``,r;if(t===`seite`)r=String(n.page);else if(t===`seiten`)r=String(n.pages);else if(t.startsWith(`feld.`))r=n.fields?.[t.slice(5)]??``;else{let e=n.variables,i=e instanceof Map?e.get(t):e?.[t];r=i?.value||i?.label||t}e.textContent=r}for(let e of r.querySelectorAll(`.efe-field`))e.textContent||(e.textContent=e.getAttribute(`data-efe-label`)??``,e.classList.add(`efe-field--empty`));return r}function TD(e,t,{distance:n,margin:r,left:i,right:a}){let o=document.createElement(`div`);return o.className=`efe-band-replica efe-band-replica--${e}`,o.setAttribute(`contenteditable`,`false`),o.setAttribute(`aria-hidden`,`true`),o.style.setProperty(`--efe-band-distance`,`${n}mm`),o.style.setProperty(`--efe-band-height`,`${Math.max(1,r-n-2)}mm`),o.style.left=`${i}mm`,o.style.right=`${a}mm`,o.append(t),o}var ED=new N(`pageMarkers`);function DD({contentHeightPx:e,pxPerMm:t,breakOffsetsPx:n=[],gapPx:r=0,usableMm:i=257,gapPxForPage:a=null}){if(!(e>0)||!(t>0))return[];let o=e=>t*(typeof i==`function`?i(e):i),s=e=>typeof a==`function`?a(e):r;if(!(o(1)>0))return[];let c=[0,...[...new Set(n)].filter(t=>t>0&&te-t),e],l=[],u=1,d=0;for(let e=0;e0)?null:r.width/t}function AD(e,t){let n=[],r=e.dom.getBoundingClientRect(),i=Array.from(e.dom.querySelectorAll(`.efe-page-gap`)).map(e=>{let n=e.getBoundingClientRect();return{top:n.top,height:n.height||t}});return e.state.doc.descendants((t,a)=>{if(t.type.name!==`pageBreak`)return;let o=e.nodeDOM(a);if(o&&typeof o.getBoundingClientRect==`function`){let e=o.getBoundingClientRect(),t=i.filter(t=>t.tope+t.height,0);n.push(e.top-r.top-t)}}),n}function jD(e,t=null){let n=document.createElement(`div`);n.className=`efe-page-gap`,n.setAttribute(`contenteditable`,`false`),n.setAttribute(`data-efe-page`,String(e)),n.title=X(`editor.page_markers.estimate`);let r=document.createElement(`span`);if(r.className=`efe-page-gap__nummer`,r.textContent=`≈ ${e-1}`,!t)return n.style.height=`12mm`,n.appendChild(r),n;n.classList.add(`efe-page-gap--bands`),n.style.height=`${t.bottomMm+12+t.topMm}mm`;let i=document.createElement(`div`);i.className=`efe-page-gap__margin efe-page-gap__margin--foot`,i.style.height=`${t.bottomMm}mm`,t.footer&&i.append(t.footer),i.append(r);let a=document.createElement(`div`);a.className=`efe-page-gap__space`,a.style.height=`12mm`;let o=document.createElement(`div`);return o.className=`efe-page-gap__margin efe-page-gap__margin--head`,o.style.height=`${t.topMm}mm`,t.header&&o.append(t.header),n.append(i,a,o),n}function MD(e,t){let n=e.resolve(t),r=t;for(let e=n.depth;e>0;--e)n.node(e).type.name===`table`&&(r=n.before(e));return r}function ND(e){let t=0;for(let n=0;n>>0).toString(36)}function PD(e,t,n,r,i,a){let o=bD(t.bands,r,i,n.firstPageDifferent);if(!o)return null;let s=wD(e.state.schema,o,{page:i,pages:a,variables:t.variables??{},fields:CD(e.state.doc)}),c=r===`header`,l=c?i===1?n.first.top:n.margins.top:i===1?n.first.bottom:n.margins.bottom;return TD(c?`head`:`foot`,s,{distance:c?n.headerDistance:n.footerDistance,margin:l,left:n.margins.left,right:n.margins.right})}var FD=new WeakMap;function ID(e,t={}){let n=t.layout?vD(t.layout):null,r=kD(e.dom,n?n.width:210);if(!r)return FD.set(e,1),I.empty;let i=e=>n?(e-1==1?n.first.bottom:n.margins.bottom)+12+n.margins.top:12,a=r*12,o=Array.from(e.dom.querySelectorAll(`.efe-page-gap`)).reduce((e,t)=>e+t.getBoundingClientRect().height,0),s=DD({contentHeightPx:e.dom.getBoundingClientRect().height-o,pxPerMm:r,breakOffsetsPx:AD(e,a),gapPx:a,...n?{usableMm:e=>yD(n,e),gapPxForPage:e=>r*i(e)}:{}}),c=s.length+1;if(FD.set(e,c),s.length===0)return I.empty;let l=e.dom.getBoundingClientRect(),u=[],d=n&&t.bands?ND(JSON.stringify([t.bands,CD(e.state.doc),c])):``;for(let{offsetPx:r,page:i}of s){let a=null;try{a=e.posAtCoords({left:l.left+l.width/2,top:l.top+r})}catch{a=null}if(!a)continue;let o;try{o=MD(e.state.doc,a.pos)}catch{continue}let s=n?()=>jD(i,{bottomMm:i-1==1?n.first.bottom:n.margins.bottom,topMm:n.margins.top,footer:PD(e,t,n,`footer`,i-1,c),header:PD(e,t,n,`header`,i,c)}):()=>jD(i);u.push(fs.widget(o,s,{key:`efe-page-gap-${i}${d?`-${d}`:``}`,side:0}))}return I.create(e.state.doc,u)}function LD(e){let t=typeof e.dom.closest==`function`?e.dom.closest(`.efe-page`):null;if(!t||typeof t.getBoundingClientRect!=`function`)return;let n=t.getBoundingClientRect(),r=n.width>0&&t.offsetWidth>0?n.width/t.offsetWidth:1;for(let t of e.dom.querySelectorAll(`.efe-page-gap`)){let e=Number(t.dataset.efeShift||0),i=(n.left-t.getBoundingClientRect().left)/r;if(Math.abs(i)>.5){let n=e+i;t.dataset.efeShift=String(n),t.style.translate=`${n}px 0`}}}function RD(e,t={}){let n=typeof e.dom.closest==`function`?e.dom.closest(`.efe-page`):null;if(!n||!t.layout)return;let r=vD(t.layout),i=FD.get(e)??1;if(n.querySelectorAll(`:scope > .efe-band-replica`).forEach(e=>e.remove()),t.replicas!==!1){let a=PD(e,t,r,`header`,1,i),o=PD(e,t,r,`footer`,i,i);a&&n.append(a),o&&n.append(o)}n.style.minHeight=`${i*r.height+(i-1)*12}mm`,n.dataset.efePages=String(i)}var zD=new WeakMap;function BD(e){let t=e?.view?zD.get(e.view):null;t&&t()}var VD=V.create({name:`pageMarkers`,addOptions(){return{layout:null,bands:null,variables:null,replicas:!0}},addProseMirrorPlugins(){let e=this.options;return[new M({key:ED,state:{init:()=>I.empty,apply(e,t){return e.getMeta(ED)||(e.docChanged?t.map(e.mapping,e.doc):t)}},props:{decorations(e){return ED.getState(e)??I.empty}},view(t){let n=null,r=null,i=()=>{if(n=null,t.isDestroyed)return;let r=ID(t,e);RD(t,e);let i=t.state.tr.setMeta(ED,r).setMeta(`addToHistory`,!1);t.dispatch(i),LD(t)},a=()=>{n!==null||t.isDestroyed||(n=typeof requestAnimationFrame==`function`?requestAnimationFrame(i):setTimeout(i,50))};return zD.set(t,a),typeof ResizeObserver<`u`?(r=new ResizeObserver(()=>a()),r.observe(t.dom)):typeof window<`u`&&typeof window.addEventListener==`function`&&window.addEventListener(`resize`,a),a(),{update(e,t){e.state.doc!==t.doc&&a()},destroy(){zD.delete(t),n!==null&&(typeof cancelAnimationFrame==`function`?cancelAnimationFrame(n):clearTimeout(n),n=null),r?r.disconnect():typeof window<`u`&&typeof window.removeEventListener==`function`&&window.removeEventListener(`resize`,a)}}}})]}}),HD=8,UD=V.create({name:`emoji`,addOptions(){return{data:null,char:`:`}},addProseMirrorPlugins(){let{data:e,char:t}=this.options;return e?[sE({editor:this.editor,pluginKey:new N(`emojiSuggestion`),char:t,allowSpaces:!1,items:async({query:t})=>{if(t.length<2)return[];let n=await aw(e).catch(()=>null);return n?sw(n.emojis,t,HD):[]},command:({editor:e,range:t,props:n})=>{let r=lw(n,hw());mw(r),e.chain().focus().insertContentAt(t,r).run()},render:WD})]:[]}});function WD(){let e=null,t=null,n=[],r=0,i=null,a=()=>{n.length===0?(t?.(),t=null):e.replaceChildren(...n.map((e,t)=>{let n=document.createElement(`button`);n.type=`button`,n.className=`efe-suggest__item efe-suggest__item--emoji`,n.classList.toggle(`is-active`,t===r),n.setAttribute(`role`,`option`),n.setAttribute(`aria-selected`,String(t===r));let a=document.createElement(`span`);return a.className=`efe-suggest__glyph`,a.textContent=lw(e,hw()),n.append(a,e.label),n.addEventListener(`mousedown`,t=>{t.preventDefault(),i?.(e)}),n}))},o=null,s=s=>{n=s.items,r=0,i=s.command,o=s.mount,n.length>0&&!t&&(t=o(e)),a()};return{onStart:t=>{e=document.createElement(`div`),e.className=`efe-suggest`,e.setAttribute(`role`,`listbox`),e.setAttribute(`aria-label`,X(`editor.emoji.choose`)),s(t)},onUpdate:s,onKeyDown:({event:e})=>n.length===0||!t?!1:e.key===`ArrowDown`||e.key===`ArrowUp`?(r=(r+(e.key===`ArrowDown`?1:-1)+n.length)%n.length,a(),!0):e.key===`Enter`||e.key===`Tab`?(i?.(n[r]),!0):e.key===`Escape`&&(t(),t=null,!0),onExit:()=>{t?.(),t=null,e=null}}}var GD=e=>e===`seite`||e===`seiten`||e.startsWith(`feld.`);function KD(e){let t=``,n=e=>e.type.name!==`docFixed`&&(e.isText&&!e.marks.some(e=>e.type.name===`efePrompt`)&&(t+=e.text),!0);return e.forEach(e=>{n(e)&&e.descendants(n),t+=` `}),t.replace(/\s+/g,` `).trim()}function qD(e){if(e.extensionManager.extensions.find(e=>e.name===`sectionLockGuard`||e.name===`inputGuard`)?.options?.templateMode)return[];let t=e.extensionManager.extensions.find(e=>e.name===`docVariable`),n=t?.options?.variables??{},r=t?.options?.display??`values`,i=[],a=new Set,o=``;return e.state.doc.descendants((e,t)=>{if(e.type.name===`docSection`)return o=e.attrs.title?String(e.attrs.title):``,!0;if(e.type.name===`docOptional`)return e.attrs.enabled!==!1;if(e.type.name===`docRepeat`)return o=e.attrs.label?String(e.attrs.label):``,!0;if(e.type.name===`docInput`){let n=e.attrs.label??``,r=e.attrs.inputId??null;if(e.attrs.kind===`snippet`)return e.attrs.required&&!e.attrs.choice&&i.push({kind:`snippet`,state:`empty`,label:n,section:o,pos:t,inputId:r}),!1;let a=KD(e),s=Number(e.attrs.minLength)||0;return e.attrs.required&&a===``?i.push({kind:`input`,state:`empty`,label:n,section:o,pos:t,inputId:r}):s>0&&a!==``&&a.lengthn.classList.remove(`is-flagged`),1600),t.kind===`field`){let e=n.querySelector(`.efe-field__input`);e instanceof HTMLElement&&e.focus({preventScroll:!0})}else e.isEditable&&e.commands.setNodeSelection(t.pos)}}var YD=10,XD=80;function ZD(e,t){e.classList.add(`efe-ruler`);function n(){if(e.replaceChildren(),e.hidden=!t.visible(),e.hidden)return;let n=t.geometry();e.style.width=`${n.width}mm`;let r=document.createElement(`div`);r.className=`efe-ruler__off`,r.style.left=`0`,r.style.width=`${n.margins.left}mm`;let i=document.createElement(`div`);i.className=`efe-ruler__off`,i.style.right=`0`,i.style.width=`${n.margins.right}mm`;let a=document.createElement(`div`);a.className=`efe-ruler__ticks`,e.append(r,i,a);for(let t=10;t{let n=e.shiftKey?5:1,i=0;if(e.key===`ArrowRight`&&(i=n),e.key===`ArrowLeft`&&(i=-n),!i)return;e.preventDefault();let a=t.geometry().margins[r],o=QD(a+(r===`left`?i:-i));t.onMargin(r,o)}),i.addEventListener(`pointerdown`,n=>{n.preventDefault(),i.setPointerCapture?.(n.pointerId),i.classList.add(`is-dragging`);let a=document.createElement(`div`);a.className=`efe-ruler__tip`,e.append(a);let o=t.geometry().width,s=n=>{let i=e.getBoundingClientRect();if(!(i.width>0))return;let s=Math.round((n.clientX-i.left)/i.width*o);r===`right`&&(s=o-s),s=QD(s),a.textContent=X(r===`left`?`editor.doc_ruler.tip_left`:`editor.doc_ruler.tip_right`,{mm:s}),a.style.left=r===`left`?`${s}mm`:`${o-s}mm`,t.onMargin(r,s)},c=()=>{i.removeEventListener(`pointermove`,s),i.classList.remove(`is-dragging`),a.remove()};i.addEventListener(`pointermove`,s),i.addEventListener(`pointerup`,c,{once:!0}),i.addEventListener(`pointercancel`,c,{once:!0})}),e.append(i)}}function r(){if(e.hidden||!e.childElementCount){n();return}let r=t.geometry();if(e.style.width!==`${r.width}mm`){n();return}let[i,a]=e.querySelectorAll(`.efe-ruler__off`);i.style.width=`${r.margins.left}mm`,a.style.width=`${r.margins.right}mm`;for(let t of[`left`,`right`]){let n=e.querySelector(`.efe-ruler__handle--${t}`);n.style.left=t===`left`?`${r.margins.left}mm`:`${r.width-r.margins.right}mm`,n.setAttribute(`aria-valuenow`,String(r.margins[t])),n.setAttribute(`aria-valuetext`,`${r.margins[t]} mm`)}}return{render:n,update:r,destroy(){e.replaceChildren()}}}function QD(e){return Math.max(YD,Math.min(XD,e))}var $D=()=>[[`line`,X(`editor.doc_properties.kind_line`)],[`choice`,X(`editor.doc_properties.kind_choice`)],[`date`,X(`editor.doc_properties.kind_date`)],[`number`,X(`editor.doc_properties.kind_number`)]],eO=()=>({plain:X(`editor.doc_properties.format_plain`),basic:X(`editor.doc_properties.format_basic`),full:X(`editor.doc_properties.format_full`)}),tO=()=>({plain:X(`editor.doc_properties.format_plain_hint`),basic:X(`editor.doc_properties.format_basic_hint`),full:X(`editor.doc_properties.format_full_hint`)});function Q(e,t={},...n){let r=document.createElement(e);for(let[e,n]of Object.entries(t))n!=null&&n!==!1&&(e===`class`?r.className=n:e===`text`?r.textContent=n:e.startsWith(`on`)?r.addEventListener(e.slice(2),n):e in r&&e!==`list`?r[e]=n:r.setAttribute(e,n===!0?``:n));return r.append(...n.flat().filter(e=>e!=null&&e!==!1)),r}var nO=0,rO=e=>`efe-prop-${e}-${++nO}`;function $(e,t,n){let r=t.id||rO(`x`);return t.id=r,Q(`div`,{class:`efe-prop`},Q(`label`,{class:`efe-prop__label`,for:r,text:e}),t,n?Q(`p`,{class:`efe-prop__hint`,text:n}):null)}function iO(e,t,n={}){return Q(`input`,{type:`text`,class:`efe-prop__input`,value:e??``,oninput:e=>t(e.target.value),...n})}function aO(e,t,n={}){return Q(`input`,{type:`number`,class:`efe-prop__input`,value:e??``,onchange:e=>{let n=e.target.value.trim();t(n===``?null:Number(n))},...n})}function oO(e,t,n){let r=Q(`select`,{class:`efe-prop__input`,onchange:e=>n(e.target.value)});for(let[n,i]of t)r.append(Q(`option`,{value:n,text:i,selected:n===e}));return r}function sO(e,t,n){let r=rO(`c`);return Q(`label`,{class:`efe-prop__check`,for:r},Q(`input`,{type:`checkbox`,id:r,checked:t,onchange:e=>n(e.target.checked)}),Q(`span`,{text:e}))}function cO(e,t,n){let r=Q(`div`,{class:`efe-prop__seg`,role:`group`});for(let[i,a]of t)r.append(Q(`button`,{type:`button`,text:a,"aria-pressed":String(i===e),onclick:()=>n(i)}));return r}function lO(e,t,n=``){return Q(`button`,{type:`button`,class:`efe-prop__btn ${n}`.trim(),text:e,onclick:t})}function uO(e,t){return Q(`div`,{class:`efe-prop__head`},Q(`p`,{class:`efe-prop__kicker`,text:e}),Q(`h2`,{class:`efe-prop__title`,text:t}))}function dO(e){let t=e.state.selection;if(t instanceof j)return{type:t.node.type.name,node:t.node,pos:t.from};let n=t.$from;for(let e=n.depth;e>0;--e){let t=n.node(e);if([`docFixed`,`docInput`,`docAside`,`docRepeat`,`docOptional`].includes(t.type.name))return{type:t.type.name,node:t,pos:n.before(e)}}return{type:`none`,node:null,pos:null}}function fO(e,t,n){let r=e.state.doc.nodeAt(t);r&&e.view.dispatch(e.state.tr.setNodeMarkup(t,void 0,{...r.attrs,...n}))}function pO(e,t,n){let r=e.state.doc.nodeAt(t);r&&e.view.dispatch(e.state.tr.replaceWith(t,t+r.nodeSize,n))}function mO(e,t,n){let{schema:r}=e.state;if(n.attrs.kind===`snippet`){let i=(n.attrs.snippets??[])[0],a=Array.isArray(i?.content)&&i.content.length?i.content:[{type:`paragraph`}];pO(e,t,c.fromJSON(r,a));return}let i=[];n.forEach(e=>{e.type.name===`docFixed`?e.forEach(e=>i.push(e)):i.push(e)}),pO(e,t,c.fromArray(i.length?i:[r.nodes.paragraph.create()]))}function hO(e){let t=e=>(e??[]).map(e=>(e.content??[]).map(e=>e.text??``).join(``)).join(` `);return(e??[]).map(e=>`${e.name}: ${t(Array.isArray(e.content)?e.content:e.content?.content)}`).join(` +`)}function gO(e,t){return e.split(` +`).map(e=>e.trim()).filter(Boolean).map((e,n)=>{let r=e.indexOf(`:`),i=r>0?e.slice(0,r).trim():X(`editor.doc_properties.variant_n`,{n:n+1}),a=r>0?e.slice(r+1).trim():e;return{id:t?.[n]?.id??`v-${Date.now().toString(36)}-${n}`,name:i,content:[a?{type:`paragraph`,content:[{type:`text`,text:a}]}:{type:`paragraph`}]}})}function _O(e,t){let n=null,r=(...t)=>e.append(...t.filter(e=>e!=null&&e!==!1)),i=()=>[[``,X(`editor.doc_properties.who_all`)],...(t.options.who??[]).map(e=>[e.key,X(`editor.doc_properties.who_only`,{label:e.label})])];function a(r=!1){let i=t.focusedEditor();if(!i)return;let a=t.mode()===`template`?dO(i):{type:t.mode(),pos:null},o=`${t.mode()}|${t.focused()}|${a.type}|${a.pos}`;if(r||o!==n||!e.contains(document.activeElement)){if(n=o,e.replaceChildren(),t.mode()===`write`)return x();if(t.mode()===`preview`)return S();switch(a.type){case`docField`:return f(i,a);case`docInput`:return a.node.attrs.kind===`snippet`?m(i,a):p(i,a);case`docFixed`:return h(i,a);case`docAside`:return g(i,a);case`docRepeat`:return _(i,a,X(`editor.doc_properties.repeat`),X(`editor.doc_properties.repeat_hint`));case`docOptional`:return _(i,a,X(`editor.doc_properties.optional`),X(`editor.doc_properties.optional_hint`));case`docVariable`:return v(a);case`image`:case`imageBlock`:return y();default:return t.focused()===`body`?s():d()}}}let o=()=>a(!0);function s(){let e=t.pkg(),n=e.layout,i=vD(n),a={...n.margins},s=a.left===25&&a.right===20?`din`:a.left===20&&a.right===20?`standard`:`eigen`,c=(e,n)=>$(n,aO(i.margins[e],n=>{n!==null&&t.setLayout({margins:{...t.pkg().layout.margins,[e]:n}})},{min:10,max:80}));if(r(uO(X(`editor.doc_properties.page`),X(`editor.doc_properties.page_title`)),$(X(`editor.doc_properties.format`),cO(n.orientation??`portrait`,[[`portrait`,X(`editor.doc_properties.a4_portrait`)],[`landscape`,X(`editor.doc_properties.a4_landscape`)]],e=>{t.setLayout({orientation:e}),o()})),$(X(`editor.doc_properties.preset`),oO(s,[[`standard`,X(`editor.doc_properties.preset_standard`)],[`din`,X(`editor.doc_properties.preset_din`)],[`eigen`,X(`editor.doc_properties.preset_custom`)]],e=>{e!==`eigen`&&(t.setLayout({margins:{...t.pkg().layout.margins,left:e===`din`?25:20,right:20}}),o())})),Q(`div`,{class:`efe-prop__grid`},c(`top`,X(`editor.doc_properties.top`)),c(`right`,X(`editor.doc_properties.right`)),c(`bottom`,X(`editor.doc_properties.bottom`)),c(`left`,X(`editor.doc_properties.left`))),Q(`p`,{class:`efe-prop__hint`,text:X(`editor.doc_properties.margins_hint`)}),sO(X(`editor.doc_properties.first_page_different`),n.firstPageDifferent===!0,e=>{let n=t.getPackage();n.layout.firstPageDifferent=e,e&&(n.layout.firstPageMargins=n.layout.firstPageMargins??{top:n.layout.margins.top,bottom:n.layout.margins.bottom},n.header.first=n.header.first??JSON.parse(JSON.stringify(n.header.rest??{type:`doc`,content:[{type:`paragraph`}]}))),t.rebuildWith(n),o()})),n.firstPageDifferent){let n=i.first;r(Q(`div`,{class:`efe-prop__grid efe-prop__grid--2`},$(X(`editor.doc_properties.first_top`),aO(n.top,e=>e!==null&&t.setLayout({firstPageMargins:{...n,top:e}}),{min:10,max:80})),$(X(`editor.doc_properties.first_bottom`),aO(n.bottom,e=>e!==null&&t.setLayout({firstPageMargins:{...n,bottom:e}}),{min:10,max:80}))),sO(X(`editor.doc_properties.first_footer`),!!e.footer.first,e=>{let n=t.getPackage();n.footer.first=e?JSON.parse(JSON.stringify(n.footer.rest??{type:`doc`,content:[{type:`paragraph`}]})):null,t.rebuildWith(n),o()}))}r(Q(`div`,{class:`efe-prop__grid efe-prop__grid--2`},$(X(`editor.doc_properties.header_distance`),aO(i.headerDistance,e=>e!==null&&t.setLayout({headerDistance:e}),{min:4,max:30})),$(X(`editor.doc_properties.footer_distance`),aO(i.footerDistance,e=>e!==null&&t.setLayout({footerDistance:e}),{min:4,max:30})))),l(),r(Q(`p`,{class:`efe-prop__note`,text:X(`editor.doc_properties.margin_note`)}),u())}function l(){let e=t.options.letterheads??[];if(!e.length)return;let n=t.pkg().layout.letterheadId??``;r($(X(`editor.doc_properties.letterhead`),oO(String(n),[[``,X(`editor.doc_properties.letterhead_none`)],...e.map(e=>[String(e.id),e.name])],n=>{let r=t.getPackage();if(!n){r.layout.letterheadId=null,t.rebuildWith(r),o();return}let i=e.find(e=>String(e.id)===n);i&&(r.layout={...r.layout,...i.layout??{},letterheadId:i.id},r.header={first:i.header?.first??null,rest:i.header?.rest??null},r.footer={first:i.footer?.first??null,rest:i.footer?.rest??null},t.rebuildWith(r),o())}),n?X(`editor.doc_properties.letterhead_hint`):null))}function u(){let e=0,n=0,r=0,i=0;for(let a of Object.values(t.editors()))a?.state.doc.descendants(t=>(t.type.name===`docField`&&(e+=1,t.attrs.required&&(r+=1)),t.type.name===`docInput`&&(n+=1,t.attrs.required&&(r+=1)),t.type.name===`docFixed`&&(i+=1),!0));return Q(`div`,{class:`efe-prop__summary`},Q(`p`,{class:`efe-prop__kicker`,text:X(`editor.doc_properties.summary`)}),Q(`p`,{text:`${X(`editor.doc_properties.summary_inputs`,{count:e+n})}, ${X(`editor.doc_properties.summary_required`,{count:r})} · ${X(`editor.doc_properties.summary_fixed`,{count:i})}`}))}function d(){let e=t.focused(),[n,i]=e.split(`.`),a=t.overflow()[n],s=n===`header`,c=t.pkg().layout.firstPageDifferent,l=X(i===`first`?`editor.doc_properties.band_first_page`:c?`editor.doc_properties.band_from_second_page`:`editor.doc_properties.band_every_page`),u=X(s?`editor.doc_properties.band_in_top`:`editor.doc_properties.band_in_bottom`,{pages:l});if(r(uO(X(s?`editor.doc_properties.header`:`editor.doc_properties.footer`),i===`rest`&&c?X(`editor.doc_properties.band_rest`,{region:t.regionLabel(e)}):t.regionLabel(e)),Q(`p`,{class:`efe-prop__hint`,text:`${u} ${X(`editor.doc_properties.band_fixed`)}`}),Q(`p`,{class:`efe-prop__hint`,text:X(`editor.doc_properties.band_variables`,{syntax:`feld.<${X(`editor.doc_properties.field_id`)}>`})})),a){let e=s?`top`:`bottom`;r(Q(`div`,{class:`efe-prop__note efe-prop__note--warn`},Q(`p`,{text:X(s?`editor.doc_properties.overflow_header`:`editor.doc_properties.overflow_footer`)}),lO(X(s?`editor.doc_properties.fix_top`:`editor.doc_properties.fix_bottom`,{mm:a.neededMm}),()=>{let n=t.pkg().layout;if(a.slot===`first`){let r=vD(n).first;t.setLayout({firstPageMargins:{...r,[e]:Math.min(80,a.neededMm)}})}else t.setLayout({margins:{...n.margins,[e]:Math.min(80,a.neededMm)}});o()},`efe-prop__btn--primary`)))}t.pkg().layout.letterheadId?r(lO(X(`editor.doc_properties.detach_letterhead`),()=>{let e=t.getPackage();e.layout.letterheadId=null,t.rebuildWith(e),o()})):r(lO(X(`editor.doc_properties.remove_region`,{region:t.regionLabel(e)}),()=>{let e=t.getPackage();e[n][i]=null,t.rebuildWith(e),o()},`efe-prop__btn--danger`))}function f(e,n){let a=n.node.attrs,s=a.kind??(Array.isArray(a.options)&&a.options.length?`choice`:`line`),c=t=>fO(e,n.pos,t);if(r(uO(X(`editor.doc_properties.input_area`),a.label||X(`editor.doc_properties.field`)),$(X(`editor.doc_properties.label`),iO(a.label,e=>c({label:e}))),$(X(`editor.doc_properties.kind`),oO(s,$D(),e=>{let t=e===`choice`&&!a.options?.length?{options:[{label:X(`editor.doc_properties.option_a`)},{label:X(`editor.doc_properties.option_b`)}]}:{};c({kind:e,value:``,...t}),o()}))),s===`line`&&r($(X(`editor.doc_properties.max_length`),aO(a.maxLength,e=>c({maxLength:e&&e>0?e:null}),{min:1,max:500}),X(`editor.doc_properties.max_length_hint`))),s===`choice`){let e=Object.keys(t.options.optionsSources??{});if(e.length&&r($(X(`editor.doc_properties.options_source`),oO(a.optionsSource??``,[[``,X(`editor.doc_properties.options_own`)],...e.map(e=>[e,t.options.optionsSourceLabels?.[e]??e])],e=>{c({optionsSource:e||null,...e?{options:t.options.optionsSources[e]}:{}}),o()}))),!a.optionsSource){let e=Q(`textarea`,{class:`efe-prop__input efe-prop__area`,rows:4,oninput:e=>c({options:e.target.value.split(` `).map(e=>e.trim()).filter(Boolean).map(e=>({label:e}))})});e.value=(a.options??[]).map(e=>e.label).join(` -`),r($(`Auswahl, eine pro Zeile`,e))}}s===`number`&&r(Q(`div`,{class:`efe-prop__grid`},$(`Minimum`,yD(a.min,e=>c({min:e}))),$(`Maximum`,yD(a.max,e=>c({max:e}))),$(`Nachkommastellen`,yD(a.decimals,e=>c({decimals:e}),{min:0,max:10})))),r(xD(`Pflicht, ohne Eintrag lässt sich das Dokument nicht ausstellen`,!!a.required,e=>c({required:e})),$(`Wer füllt aus`,bD(a.who??``,i(),e=>c({who:e||null}))),CD(`Feld entfernen, die Beschriftung bleibt als Text`,()=>{DD(e,n.pos,e.state.schema.text(a.label||` `)),o()},`efe-prop__btn--danger`))}function p(e,n){let a=n.node.attrs,s=t=>ED(e,n.pos,t),c=t.focused()===`body`?[`plain`,`basic`,`full`]:[`plain`,`basic`];r(wD(`Eingabebereich`,a.label||`Textbereich`),$(`Beschriftung`,vD(a.label,e=>s({label:e}))),$(`Formatierung`,SD(a.format??`plain`,c.map(e=>[e,mD[e]]),e=>{s({format:e}),o()}),hD[a.format??`plain`]),$(`Beim Anlegen`,bD(a.start??`empty`,[[`empty`,`Leer, mit Platzhalter`],[`suggestion`,`Mit dem Text aus der Vorlage als Vorschlag`]],e=>s({start:e}))),$(`Platzhalter`,vD(a.placeholder,e=>s({placeholder:e}))),xD(`Pflicht`,!!a.required,e=>s({required:e})),$(`Mindestlänge in Zeichen`,yD(a.minLength,e=>s({minLength:e&&e>0?e:null}),{min:0})),$(`Wer füllt aus`,bD(a.who??``,i(),e=>s({who:e||null}))),Q(`p`,{class:`efe-prop__hint`,text:`Text im Bereich markieren und „Festsetzen“: diesen Teil kann der Verfasser nicht ändern oder löschen.`}),CD(`Bereich auflösen, der Text wird fest`,()=>{OD(e,n.pos,n.node),o()},`efe-prop__btn--danger`))}function m(e,t){let n=t.node.attrs,a=n=>ED(e,t.pos,n),s=Q(`textarea`,{class:`efe-prop__input efe-prop__area`,rows:6,onchange:e=>a({snippets:AD(e.target.value,n.snippets)})});s.value=kD(n.snippets),r(wD(`Textbaustein`,n.label||`Textbaustein`),$(`Beschriftung`,vD(n.label,e=>a({label:e}))),$(`Varianten, je Zeile „Name: Text“`,s),xD(`Pflicht, eine Variante muss gewählt sein`,!!n.required,e=>a({required:e})),$(`Wer wählt`,bD(n.who??``,i(),e=>a({who:e||null}))),CD(`Baustein auflösen, Variante 1 wird fester Text`,()=>{OD(e,t.pos,t.node),o()},`efe-prop__btn--danger`))}function h(e,t){r(wD(`Fester Teil`,`Im Textbereich festgesetzt`),Q(`p`,{class:`efe-prop__hint`,text:`Der Verfasser schreibt davor und danach weiter. Ändern oder löschen kann er diesen Teil nicht; beim Speichern kommt er immer aus der Vorlage.`}),CD(`Wieder freigeben`,()=>{DD(e,t.pos,t.node.content),o()}))}function g(e,n){let i=n.node.attrs,a=t=>ED(e,n.pos,t),s=FE(t.pkg().layout),l=Math.max(30,s.width-s.margins.left-s.margins.right-40),u=Q(`input`,{type:`range`,min:30,max:l,value:Math.min(l,Number(i.width)||60),class:`efe-prop__range`}),d=Q(`span`,{text:`${u.value} mm`});u.addEventListener(`input`,()=>{d.textContent=`${u.value} mm`,a({width:Number(u.value)})}),r(wD(`Randkasten`,`Fester Kasten mit Textumfluss`),Q(`p`,{class:`efe-prop__hint`,text:`Steht im Satzspiegel, der Text läuft daneben weiter. Fest; Felder darin füllt der Verfasser aus.`}),$(`Seite`,SD(i.side===`left`?`left`:`right`,[[`left`,`Links`],[`right`,`Rechts`]],e=>{a({side:e}),o()})),$(`Breite`,Q(`div`,{class:`efe-prop__row`},u,d)),xD(`Rahmen`,i.frame!==!1,e=>a({frame:e})),CD(`Randkasten entfernen`,()=>{DD(e,n.pos,c.empty),o()},`efe-prop__btn--danger`))}function _(e,t,n,i){let a=t.node.attrs,s=n=>ED(e,t.pos,n);r(wD(n,a.label||n),Q(`p`,{class:`efe-prop__hint`,text:i}),$(`Beschriftung`,vD(a.label,e=>s({label:e}))),t.type===`docOptional`?xD(`Zu Beginn eingeschaltet`,a.enabled!==!1,e=>s({enabled:e})):null,CD(`Block auflösen, der Inhalt bleibt`,()=>{DD(e,t.pos,t.node.content),o()}))}function v(e){let n=e.node.attrs.name??``,i=(t.options.variables instanceof Map?Object.fromEntries(t.options.variables):t.options.variables??{})[n],a=n===`seite`?`Seitenzahl, im PDF je Seite`:n===`seiten`?`Gesamtzahl der Seiten`:n.startsWith(`feld.`)?`Wert des Felds „${n.slice(5)}“`:null;r(wD(`Variable`,i?.label??n),Q(`p`,{class:`efe-prop__hint`,text:a??`Füllt das System beim Ausstellen. Der Verfasser trägt hier nichts ein.`}),Q(`p`,{class:`efe-prop__code`,text:`{{${n}}}`}),i?.value?Q(`p`,{class:`efe-prop__hint`,text:`Zum Beispiel: ${i.value}`}):null)}function y(){r(wD(`Bild`,`Logo oder Wappen`),Q(`p`,{class:`efe-prop__hint`,text:`Fester Teil der Vorlage. Im PDF holt das Produkt die Datei aus seinem Speicher.`}))}function b(){let e=t.openItems(),n=Q(`div`,{class:`efe-prop__open`});if(!e.length)return n.append(Q(`p`,{class:`efe-prop__note efe-prop__note--ok`,text:`Alles ausgefüllt. Das Dokument kann ausgestellt werden.`})),{list:n,count:0};for(let r of e){let e=r.state===`short`?`zu kurz`:r.kind===`variable`?`fehlt`:`Pflicht`;n.append(Q(`button`,{type:`button`,class:`efe-prop__open-item`,onclick:()=>t.reveal(r)},Q(`span`,{text:r.label||r.name||`Ohne Beschriftung`}),Q(`small`,{text:`${t.regionLabel(r.region)} · ${e}`})))}return{list:n,count:e.length}}function x(){let{list:e,count:t}=b();r(wD(`Ausfüllen`,`Dokument ausfüllen`),Q(`p`,{class:`efe-prop__hint`,text:`Schreiben geht nur in den farbigen Bereichen. Ein Klick auf festen Text zeigt kurz, dass er gesperrt ist.`}),Q(`p`,{class:`efe-prop__kicker`,text:t?`Noch offen (${t})`:`Noch offen`}),e)}function S(){let{count:e}=b();r(wD(`Druck`,`So kommt es aufs Papier`),Q(`p`,{class:`efe-prop__hint`,text:`Ohne Markierungen und Rahmen der Eingabebereiche. Verbindlich ist das PDF.`}),Q(`p`,{class:`efe-prop__note${e?` efe-prop__note--warn`:` efe-prop__note--ok`}`,text:e?`${e} Angaben fehlen noch.`:`Alle Pflichtangaben sind ausgefüllt.`}))}return{render:a}}var MD=zw.document.filter(e=>e!==`pageBreak`),ND=[`header.first`,`header.rest`,`footer.first`,`footer.rest`];function PD(e=`fixed`,t={}){let n={type:`paragraph`},r=e===`free`?[{type:`docInput`,attrs:{inputId:XT(`t`),kind:`text`,label:`Text`,format:`full`,start:`suggestion`,placeholder:``,required:!1,minLength:null,who:null},content:[n]}]:[n];return{format:2,layout:{orientation:`portrait`,margins:{top:20,right:20,bottom:20,left:20},headerDistance:8,footerDistance:7,firstPageDifferent:!1,firstPageMargins:null,letterheadId:null,...t},body:{type:`doc`,content:r},header:{first:null,rest:null},footer:{first:null,rest:null}}}function FD(e){return e===void 0?void 0:JSON.parse(JSON.stringify(e))}function ID(e){let t=FD(e&&e.format===2?e:PD());t.layout={...PD().layout,...t.layout??{}},t.layout.margins={...PD().layout.margins,...t.layout.margins??{}},t.body=t.body?.type===`doc`?t.body:{type:`doc`,content:[{type:`paragraph`}]};for(let e of[`header`,`footer`])t[e]={first:t[e]?.first??null,rest:t[e]?.rest??null};return t}var LD=()=>({type:`doc`,content:[{type:`paragraph`}]});function RD(e){return{"header.first":`Kopfzeile Seite 1`,"header.rest":`Kopfzeile`,"footer.first":`Fußzeile Seite 1`,"footer.rest":`Fußzeile`,body:`Text`}[e]}function zD(e,t={}){let n=t.role===`document`?`document`:`template`,r=t.mode??(n===`document`?`write`:`template`);n===`document`&&r===`template`&&(r=`write`);let i=ID(t.package),a=null,o=!1,s=document.createElement(`div`);s.className=`efe-docedit`;let c=document.createElement(`div`);c.className=`efe-docedit__toolbar efe-frame`;let l=document.createElement(`div`);l.className=`efe-docedit__tools efe-toolbar`,l.setAttribute(`role`,`toolbar`),l.setAttribute(`aria-label`,`Vorlage`);let u=document.createElement(`div`);u.className=`efe-docedit__format`,c.append(l,u);let d=document.createElement(`div`);d.className=`efe-docedit__layout`;let f=document.createElement(`div`);f.className=`efe-surround efe-docedit__sheet`;let p=document.createElement(`div`);p.className=`efe-docedit__ruler`;let m=document.createElement(`div`);m.className=`efe-page efe-docedit__page`;let h={header:document.createElement(`div`),footer:document.createElement(`div`)};h.header.className=`efe-band-slot efe-band-slot--head`,h.footer.className=`efe-band-slot efe-band-slot--foot`;let g=document.createElement(`div`);g.className=`efe-docedit__body`,m.append(h.header,g,h.footer),f.append(p,m);let _=typeof Element<`u`&&`currentCSSZoom`in Element.prototype;function v(){let e=getComputedStyle(f),t=f.clientWidth-parseFloat(e.paddingLeft)-parseFloat(e.paddingRight),n=t>0&&m.offsetWidth>t?t/m.offsetWidth:1;f.style.setProperty(`--efe-sheet-zoom`,String(n))}let y=_&&typeof ResizeObserver==`function`?new ResizeObserver(v):null;y?.observe(f),y?.observe(m);let b=t.properties??document.createElement(`aside`);b.classList.add(`efe-docedit__panel`),d.append(f),t.properties||d.append(b);let x=document.createElement(`div`);x.className=`efe-docedit__bubble`,x.hidden=!0,s.append(c,d,x),e.append(s);let S={},C={header:{first:null,rest:null},footer:{first:null,rest:null}},w={header:`first`,footer:`first`},T=`body`,ee={},E=()=>FE(i.layout),D=()=>r===`template`,te=()=>D()&&!!i.layout.letterheadId,ne=()=>{typeof t.onChange==`function`&&t.onChange(ke.getPackage())};function re(){for(let e of Object.values(S))e?.destroy();S={},u.replaceChildren();for(let e of Object.values(h))e.replaceChildren();g.replaceChildren()}function ie(e,n,r){let a=D(),o=document.createElement(`div`);o.className=`efe-docedit__bar`,o.hidden=!0,ee[e]=o,u.append(o);let c=VD(n,{features:e===`body`?`document`:MD,content:r,templateMode:a,variables:ae,variableDisplay:a?`labels`:`values`,can:t.can??null,gender:t.gender??null,onBlocked:t.onBlocked??null,toolbar:o,fonts:t.fonts??[],bubble:!a,uploadImage:a?t.uploadImage:void 0,...e===`body`?{layout:i.layout,bands:C,bandReplicas:!1}:{},editable:!(e!==`body`&&te())});return c.on(`focus`,()=>{T=e,me(e),Oe()}),c.on(`selectionUpdate`,()=>{T===e&&(Oe(),Se())}),c.on(`update`,()=>{if(e!==`body`){let[t,n]=e.split(`.`);C[t][n]=c.getJSON(),rD(S.body),fe()}T===e&&Oe(),D()||oe(ke.getPackage()),ne()}),c.on(`blur`,()=>{setTimeout(()=>{s.contains(document.activeElement)||(x.hidden=!0)},0)}),c}let ae={};function oe(e){for(let e of Object.keys(ae))delete ae[e];let n=t.variables instanceof Map?Object.fromEntries(t.variables):t.variables??{};Object.assign(ae,n),ae.seite={label:`Seite`,value:`1`},ae.seiten={label:`Seitenzahl`,value:`1`};let r=e=>{e&&typeof e==`object`&&e.type!==`docRepeat`&&(e.type===`docField`&&e.attrs?.fieldId&&(ae[`feld.${e.attrs.fieldId}`]={label:e.attrs.label||e.attrs.fieldId,value:e.attrs.value||``}),(e.content??[]).forEach(r))};r(e.body);for(let t of[`header`,`footer`])r(e[t].first),r(e[t].rest)}function se(){re(),x.hidden=!0,s.dataset.mode=r,s.dataset.role=n,oe(i);for(let e of[`header`,`footer`])C[e].first=i.layout.firstPageDifferent?i[e].first:null,C[e].rest=i[e].rest,w[e]===`first`&&!C[e].first&&(w[e]=`rest`);RE(m,E()),S.body=ie(`body`,g,i.body);for(let e of[`header`,`footer`])ce(e);if(r===`preview`)for(let e of Object.values(S))e&&ew(e,!0);xe(),we.render(),me(`body`),Oe(),ue(),fe()}function ce(e){let n=h[e];n.replaceChildren();let r=D(),a=!!C[e].first,o=!!C[e].rest,s=document.createElement(`div`);s.className=`efe-band-slot__tabs`,s.setAttribute(`contenteditable`,`false`);let c=(t,n)=>{let r=document.createElement(`button`);return r.type=`button`,r.className=`efe-band-slot__tab`,r.textContent=n,r.setAttribute(`aria-pressed`,String(w[e]===t)),r.addEventListener(`mousedown`,e=>e.preventDefault()),r.addEventListener(`click`,()=>{w[e]=t,le(e);for(let e of s.querySelectorAll(`button`))e.setAttribute(`aria-pressed`,String(e===r));S[`${e}.${t}`]?.commands.focus()}),r},l=e===`header`?`Kopfzeile`:`Fußzeile`;if(a&&o)s.append(c(`first`,`${l} Seite 1`),c(`rest`,`${l} Folgeseiten`));else if(r&&(a||o)){let e=document.createElement(`span`);e.className=`efe-band-slot__label`,e.textContent=a?`${l} Seite 1`:l,s.append(e)}if(te()){let e=document.createElement(`span`);e.className=`efe-band-slot__note`,e.textContent=`Aus dem Briefbogen „${(t.letterheads??[]).find(e=>e.id===i.layout.letterheadId)?.name??i.layout.letterheadId}“`,s.append(e)}s.childElementCount&&(r||a&&o)&&n.append(s);for(let t of[`first`,`rest`]){let r=C[e][t];if(!r)continue;let i=document.createElement(`div`);i.className=`efe-band-slot__editor`,i.dataset.slot=t,n.append(i),S[`${e}.${t}`]=ie(`${e}.${t}`,i,r)}if(!o&&r&&!te()){let t=document.createElement(`button`);t.type=`button`,t.className=`efe-band-slot__add`,t.textContent=`${l} hinzufügen`,t.addEventListener(`click`,()=>{i=ke.getPackage(),i[e].rest=LD(),se(),S[`${e}.rest`]?.commands.focus()}),n.append(t)}le(e)}function le(e){for(let t of h[e].querySelectorAll(`.efe-band-slot__editor`))t.hidden=t.dataset.slot!==w[e];ue(),fe()}function ue(){let e=E(),t=h.header,n=h.footer;t.style.top=`${e.headerDistance}mm`,t.style.left=n.style.left=`${e.margins.left}mm`,t.style.right=n.style.right=`${e.margins.right}mm`,n.style.bottom=`${e.footerDistance}mm`;let r=w.header===`first`?e.first.top:e.margins.top,i=w.footer===`first`?e.first.bottom:e.margins.bottom;t.style.setProperty(`--efe-band-limit`,`${Math.max(1,r-e.headerDistance-2)}mm`),n.style.setProperty(`--efe-band-limit`,`${Math.max(1,i-e.footerDistance-2)}mm`)}let de={header:null,footer:null};function fe(){let e=E(),t=m.offsetWidth>0?m.offsetWidth/e.width:0;for(let n of[`header`,`footer`]){de[n]=null,h[n].classList.remove(`is-overflow`);let r=h[n].querySelector(`.efe-band-slot__editor[data-slot="${w[n]}"]`);if(!r||!t)continue;let i=n===`header`,a=i?w.header===`first`?e.first.top:e.margins.top:w.footer===`first`?e.first.bottom:e.margins.bottom,o=i?e.headerDistance:e.footerDistance,s=Math.ceil(r.scrollHeight/t)+o+2;s>a&&(de[n]={neededMm:s,slot:w[n]},h[n].classList.add(`is-overflow`))}}let pe=()=>S[T]??S.body;function me(e){for(let[t,n]of Object.entries(ee))n.hidden=t!==e}let he=[[`line`,`Zeile`,`Eine Zeile Text, ohne Formatierung`],[`choice`,`Auswahl`,`Ein Wert aus einer festen Liste`],[`date`,`Datum`,`Datum mit Kalender`],[`number`,`Zahl`,`Nur Ziffern`],[`text`,`Textbereich`,`Mehrere Absätze, Formatierung einstellbar`],[`snippet`,`Textbaustein`,`Einer von mehreren vorgegebenen Texten`]];function ge(e){let t=pe();return e===`text`?t.chain().focus().freeAsTextArea().run():e===`snippet`?t.chain().focus().freeAsSnippet().run():t.chain().focus().insertInputField(e).run()}function _e(e,t,n){let r=document.createElement(`button`);return r.type=`button`,r.className=`efe-btn efe-btn--text`,r.textContent=e,n&&(r.title=n),r.addEventListener(`mousedown`,e=>e.preventDefault()),r.addEventListener(`click`,t),r}function ve(e,t,n){let r=document.createElement(`div`);r.className=`efe-dropdown efe-docedit__menu`;let i=_e(`${e} ▾`,()=>{let e=a.hidden;ye(),a.hidden=!e,i.setAttribute(`aria-expanded`,String(e)),e&&a.querySelector(`button`)?.focus()});i.setAttribute(`aria-haspopup`,`true`),i.setAttribute(`aria-expanded`,`false`);let a=document.createElement(`div`);a.className=`efe-dropdown__menu`,a.setAttribute(`role`,`menu`),a.hidden=!0;for(let[e,r,i]of t){let t=document.createElement(`button`);t.type=`button`,t.className=`efe-dropdown__item`,t.setAttribute(`role`,`menuitem`),t.dataset.key=e;let o=document.createElement(`span`);if(o.textContent=r,t.append(o),i){let e=document.createElement(`small`);e.textContent=i,t.append(e)}t.addEventListener(`mousedown`,e=>e.preventDefault()),t.addEventListener(`click`,()=>{ye(),n(e)}),a.append(t)}return a.addEventListener(`keydown`,e=>{let t=[...a.querySelectorAll(`button`)],n=t.indexOf(document.activeElement);e.key===`ArrowDown`&&(e.preventDefault(),t[(n+1)%t.length].focus()),e.key===`ArrowUp`&&(e.preventDefault(),t[(n-1+t.length)%t.length].focus()),e.key===`Escape`&&(e.preventDefault(),ye(),pe().commands.focus())}),r.append(i,a),r.open=()=>i.click(),r}function ye(){for(let e of l.querySelectorAll(`.efe-dropdown__menu`))e.hidden=!0;for(let e of l.querySelectorAll(`[aria-haspopup]`))e.setAttribute(`aria-expanded`,`false`)}let be=null;function xe(){if(l.replaceChildren(),l.hidden=!D(),!D())return;let e=(...e)=>{let t=document.createElement(`div`);return t.className=`efe-toolbar__group`,t.append(...e),t};be=ve(`Eingabebereich einfügen`,he,e=>{ge(e),Oe()});let n=Object.entries(t.variables instanceof Map?Object.fromEntries(t.variables):t.variables??{}).map(([e,t])=>[e,t?.label??e,`{{${e}}}`]);n.push([`seite`,`Seite`,`{{seite}}`],[`seiten`,`Seitenzahl`,`{{seiten}}`]);let r=ve(`Variable`,n,e=>{pe().chain().focus().insertContent({type:`docVariable`,attrs:{name:e}}).run()});l.append(e(be,_e(`Festsetzen`,()=>pe().chain().focus().fixSelection().run(),`Markierten Text im Textbereich festsetzen (Strg+Umschalt+F)`)),e(_e(`Randkasten`,()=>S.body.chain().focus().insertAside().run()),_e(`Wiederholblock`,()=>S.body.chain().focus().wrapInRepeat().run()),_e(`Optionaler Block`,()=>S.body.chain().focus().wrapInOptional().run())),e(r))}function Se(){if(!D()){x.hidden=!0;return}let e=pe(),{state:t,view:n}=e,r=t.selection;if(!(r instanceof A)||r.empty||!t.doc.textBetween(r.from,r.to).trim()){x.hidden=!0;return}x.replaceChildren();let i=(e,t)=>x.append(_e(e,()=>{t(),x.hidden=!0,Oe()}));_E(r.$from)?i(`Festsetzen`,()=>e.chain().focus().fixSelection().run()):(r.$from.parent===r.$to.parent&&r.$from.parent.isTextblock&&i(`Als Zeile freigeben`,()=>e.chain().focus().insertInputField(`line`).run()),i(`Als Textbereich freigeben`,()=>e.chain().focus().freeAsTextArea().run()),T===`body`&&i(`Als Textbaustein`,()=>e.chain().focus().freeAsSnippet().run()));let a=null;try{a=n.coordsAtPos(r.to)}catch{a=null}x.hidden=!1,a&&(x.style.left=`${Math.max(8,a.left-20)}px`,x.style.top=`${a.bottom+8}px`)}s.addEventListener(`keydown`,e=>{if(!D()||!(e.ctrlKey||e.metaKey)||!e.shiftKey)return;let t=e.key.toLowerCase();t===`e`?(e.preventDefault(),be?.open()):t===`f`&&(e.preventDefault(),pe().chain().focus().fixSelection().run())}),s.addEventListener(`mousedown`,e=>{if(!D()||!(e.target instanceof Element))return;let t=e.target.closest(`.efe-field, .efe-input[data-efe-kind="snippet"]`);if(t)for(let[e,n]of Object.entries(S)){if(!n||!n.view.dom.contains(t))continue;let r;try{r=n.view.posAtDOM(t,0)}catch{return}let i=t.classList.contains(`efe-field`)?`docField`:`docInput`,a=[r,r-1].find(e=>e>=0&&n.state.doc.nodeAt(e)?.type.name===i);if(a===void 0)return;n.view.dispatch(n.state.tr.setSelection(j.create(n.state.doc,a))),T=e,me(e),Oe();return}}),document.addEventListener(`mousedown`,Ce);function Ce(e){l.contains(e.target)||ye()}let we=dD(p,{geometry:E,visible:()=>D(),onMargin:(e,t)=>Te({margins:{...i.layout.margins,[e]:t}})});function Te(e){Object.assign(i.layout,e),e.margins&&(i.layout.margins={...e.margins}),RE(m,E()),ue(),we.update(),rD(S.body),fe(),Oe(),ne()}function Ee(e){i=e,se(),ne()}let De=jD(b,{options:t,isTemplate:D,mode:()=>r,focused:()=>T,focusedEditor:pe,editors:()=>S,pkg:()=>i,overflow:()=>de,setLayout:Te,rebuildWith:Ee,getPackage:()=>ke.getPackage(),openItems:()=>ke.openItems(),reveal:e=>ke.revealOpenItem(e),regionLabel:RD});function Oe(){o||De.render()}let ke={root:s,get mode(){return r},get editors(){return{...S}},getPackage(){let e=FD(i);e.body=S.body?S.body.getJSON():e.body;for(let t of ND){let[n,r]=t.split(`.`);e[n][r]=S[t]?S[t].getJSON():e[n][r]}return e},setMode(e){if(![`template`,`write`,`preview`].includes(e)||e===r||n===`document`&&e===`template`)return r;let t=ke.getPackage();return n===`template`&&(r===`template`?a=t:e===`template`&&a&&(t=a,a=null)),i=ID(t),r=e,se(),r},openItems(){let e=i.layout.firstPageDifferent?[`header.first`,`body`,`footer.first`,`header.rest`,`footer.rest`]:[`header.rest`,`body`,`footer.rest`],t=[];for(let n of e){let e=S[n];if(e)for(let r of sD(e))t.push({...r,region:n})}return t},revealOpenItem(e){let t=S[e.region];if(t){if(e.region!==`body`){let[t,n]=e.region.split(`.`);w[t]=n,le(t)}cD(t,e)}},setLayout:Te,destroy(){o=!0,document.removeEventListener(`mousedown`,Ce),re(),we.destroy(),y?.disconnect(),s.remove()}};return se(),ke}var BD=`Hier schreiben …`;function VD(e,t={}){let{content:n,editable:r=!0,onUpdate:i,placeholder:a=BD,toolbar:o=null,bubble:s=!0,variables:c,templateMode:l=!1,onBlocked:u,toolbarItems:d,uploadImage:f,variableDisplay:p,gender:m=null,can:h=null,layout:g=null,bands:_=null,fonts:v=[]}=t,y=Bw(t),b=e=>y.has(e),x=e=>b(e)?{}:!1,S=b(`bulletList`)||b(`orderedList`),C=s?Iw():null,w=[Ev.configure({...b(`sections`)?{document:!1}:{},code:!1,codeBlock:!1,link:!1,bold:x(`bold`),italic:x(`italic`),underline:x(`underline`),strike:x(`strike`),heading:b(`headings`)?{levels:[1,2,3]}:!1,bulletList:x(`bulletList`),orderedList:x(`orderedList`),listItem:S?{}:!1,listKeymap:S?{}:!1,blockquote:x(`blockquote`),horizontalRule:x(`horizontalRule`),...b(`inputs`)&&!l?{trailingNode:!1}:{}}),...b(`table`)?[Ub.configure({resizable:!1}),Sb,xb,bb]:[],...b(`textAlign`)?[Wb.configure({types:[`heading`,`paragraph`]})]:[],...b(`fontFamily`)?[Yb,Qb]:[],Gb.configure({placeholder:a}),...b(`variables`)?[Zw.configure({variables:c??{},display:p??(l||!qw(c)?`labels`:`values`)})]:[],...b(`variables`)&&c?[DT.configure({variables:c})]:[],...b(`fields`)?[cT.configure({gender:m,can:h})]:[],MC,...b(`image`)?[NC.configure({upload:f??null})]:[],...b(`video`)?[GC]:[],...b(`callout`)?[LC.configure({blocks:HD(b)})]:[],...b(`sections`)?[BT,zT.configure({templateMode:l,onBlocked:u??null}),HT.configure({templateMode:l,onBlocked:u})]:[],...b(`inputs`)?[oE.configure({templateMode:l,can:h,onBlocked:u??null}),sE.configure({templateMode:l,can:h,onBlocked:u??null}),cE.configure({templateMode:l,can:h,onBlocked:u??null}),lE.configure({templateMode:l,can:h,onBlocked:u??null}),uE.configure({templateMode:l,can:h,onBlocked:u??null}),aE,vE.configure({templateMode:l}),AE.configure({templateMode:l,can:h,onBlocked:u??null})]:[],...b(`pageBreak`)?[jE,iD.configure({layout:g,bands:_,variables:c??null,replicas:t.bandReplicas!==!1})]:[],...b(`link`)?[vC(),OC]:[],...C?C.extensions:[]],T=new dp({element:e,extensions:w,content:n&&Vw(n,Pu(w)),editable:r,...i?{onUpdate:i}:{}});return C?.attach(T),g&&RE(e.closest?.(`.efe-page`)??e,FE(g)),o&&sw(T,o,{items:d??(t.features===void 0?iw:void 0),fonts:v}),T}function HD(e){let t=[`paragraph`];return e(`headings`)&&t.push(`heading`),e(`bulletList`)&&t.push(`bulletList`),e(`orderedList`)&&t.push(`orderedList`),e(`image`)&&t.push(`imageBlock`),t}var UD=VD;return e.CALLOUT_VARIANTS=PC,e.FORMAT_MARKS=qT,e.FORMAT_NODES=KT,e.bandFor=LE,e.blankInstance=hE,e.collectEmptyRequiredFields=lT,e.collectOpenItems=sD,e.createDocumentEditor=zD,e.createEditor=VD,e.createLexEditor=UD,e.degradeBlocks=ZT,e.features=Lw,e.fieldKind=JT,e.inputFormat=YT,e.isPreview=$C,e.isValidVideo=UC,e.newTemplatePackage=PD,e.pageGeometry=FE,e.parseVideoUrl=WC,e.presets=zw,e.revealOpenItem=cD,e.setPreview=ew,e.variableState=Kw,e})({}); \ No newline at end of file +`),r($(X(`editor.doc_properties.options_list`),e))}}s===`number`&&r(Q(`div`,{class:`efe-prop__grid`},$(X(`editor.doc_properties.min`),aO(a.min,e=>c({min:e}))),$(X(`editor.doc_properties.max`),aO(a.max,e=>c({max:e}))),$(X(`editor.doc_properties.decimals`),aO(a.decimals,e=>c({decimals:e}),{min:0,max:10})))),r(sO(X(`editor.doc_properties.field_required`),!!a.required,e=>c({required:e})),$(X(`editor.doc_properties.who_fills`),oO(a.who??``,i(),e=>c({who:e||null}))),lO(X(`editor.doc_properties.remove_field`),()=>{pO(e,n.pos,e.state.schema.text(a.label||` `)),o()},`efe-prop__btn--danger`))}function p(e,n){let a=n.node.attrs,s=t=>fO(e,n.pos,t),c=t.focused()===`body`?[`plain`,`basic`,`full`]:[`plain`,`basic`];r(uO(X(`editor.doc_properties.input_area`),a.label||X(`editor.doc_properties.text_area`)),$(X(`editor.doc_properties.label`),iO(a.label,e=>s({label:e}))),$(X(`editor.doc_properties.formatting`),cO(a.format??`plain`,c.map(e=>[e,eO()[e]]),e=>{s({format:e}),o()}),tO()[a.format??`plain`]),$(X(`editor.doc_properties.start`),oO(a.start??`empty`,[[`empty`,X(`editor.doc_properties.start_empty`)],[`suggestion`,X(`editor.doc_properties.start_suggestion`)]],e=>s({start:e}))),$(X(`editor.doc_properties.placeholder`),iO(a.placeholder,e=>s({placeholder:e}))),sO(X(`editor.doc_properties.required`),!!a.required,e=>s({required:e})),$(X(`editor.doc_properties.min_length`),aO(a.minLength,e=>s({minLength:e&&e>0?e:null}),{min:0})),$(X(`editor.doc_properties.who_fills`),oO(a.who??``,i(),e=>s({who:e||null}))),Q(`p`,{class:`efe-prop__hint`,text:X(`editor.doc_properties.fix_hint`)}),lO(X(`editor.doc_properties.dissolve_input`),()=>{mO(e,n.pos,n.node),o()},`efe-prop__btn--danger`))}function m(e,t){let n=t.node.attrs,a=n=>fO(e,t.pos,n),s=Q(`textarea`,{class:`efe-prop__input efe-prop__area`,rows:6,onchange:e=>a({snippets:gO(e.target.value,n.snippets)})});s.value=hO(n.snippets),r(uO(X(`editor.doc_properties.snippet`),n.label||X(`editor.doc_properties.snippet`)),$(X(`editor.doc_properties.label`),iO(n.label,e=>a({label:e}))),$(X(`editor.doc_properties.snippet_variants`),s),sO(X(`editor.doc_properties.snippet_required`),!!n.required,e=>a({required:e})),$(X(`editor.doc_properties.who_chooses`),oO(n.who??``,i(),e=>a({who:e||null}))),lO(X(`editor.doc_properties.dissolve_snippet`),()=>{mO(e,t.pos,t.node),o()},`efe-prop__btn--danger`))}function h(e,t){r(uO(X(`editor.doc_properties.fixed`),X(`editor.doc_properties.fixed_title`)),Q(`p`,{class:`efe-prop__hint`,text:X(`editor.doc_properties.fixed_hint`)}),lO(X(`editor.doc_properties.release`),()=>{pO(e,t.pos,t.node.content),o()}))}function g(e,n){let i=n.node.attrs,a=t=>fO(e,n.pos,t),s=vD(t.pkg().layout),l=Math.max(30,s.width-s.margins.left-s.margins.right-40),u=Q(`input`,{type:`range`,min:30,max:l,value:Math.min(l,Number(i.width)||60),class:`efe-prop__range`}),d=Q(`span`,{text:`${u.value} mm`});u.addEventListener(`input`,()=>{d.textContent=`${u.value} mm`,a({width:Number(u.value)})}),r(uO(X(`editor.doc_properties.aside`),X(`editor.doc_properties.aside_title`)),Q(`p`,{class:`efe-prop__hint`,text:X(`editor.doc_properties.aside_hint`)}),$(X(`editor.doc_properties.side`),cO(i.side===`left`?`left`:`right`,[[`left`,X(`editor.doc_properties.left`)],[`right`,X(`editor.doc_properties.right`)]],e=>{a({side:e}),o()})),$(X(`editor.doc_properties.width`),Q(`div`,{class:`efe-prop__row`},u,d)),sO(X(`editor.doc_properties.frame`),i.frame!==!1,e=>a({frame:e})),lO(X(`editor.doc_properties.remove_aside`),()=>{pO(e,n.pos,c.empty),o()},`efe-prop__btn--danger`))}function _(e,t,n,i){let a=t.node.attrs,s=n=>fO(e,t.pos,n);r(uO(n,a.label||n),Q(`p`,{class:`efe-prop__hint`,text:i}),$(X(`editor.doc_properties.label`),iO(a.label,e=>s({label:e}))),t.type===`docOptional`?sO(X(`editor.doc_properties.optional_enabled`),a.enabled!==!1,e=>s({enabled:e})):null,lO(X(`editor.doc_properties.dissolve_block`),()=>{pO(e,t.pos,t.node.content),o()}))}function v(e){let n=e.node.attrs.name??``,i=(t.options.variables instanceof Map?Object.fromEntries(t.options.variables):t.options.variables??{})[n],a=n===`seite`?X(`editor.doc_properties.var_page`):n===`seiten`?X(`editor.doc_properties.var_pages`):n.startsWith(`feld.`)?X(`editor.doc_properties.var_field`,{field:n.slice(5)}):null;r(uO(X(`editor.doc_properties.variable`),i?.label??n),Q(`p`,{class:`efe-prop__hint`,text:a??X(`editor.doc_properties.var_system`)}),Q(`p`,{class:`efe-prop__code`,text:`{{${n}}}`}),i?.value?Q(`p`,{class:`efe-prop__hint`,text:X(`editor.doc_properties.var_example`,{value:i.value})}):null)}function y(){r(uO(X(`editor.doc_properties.image`),X(`editor.doc_properties.image_title`)),Q(`p`,{class:`efe-prop__hint`,text:X(`editor.doc_properties.image_hint`)}))}function b(){let e=t.openItems(),n=Q(`div`,{class:`efe-prop__open`});if(!e.length)return n.append(Q(`p`,{class:`efe-prop__note efe-prop__note--ok`,text:X(`editor.doc_properties.all_filled`)})),{list:n,count:0};for(let r of e){let e=r.state===`short`?X(`editor.doc_properties.reason_short`):r.kind===`variable`?X(`editor.doc_properties.reason_missing`):X(`editor.doc_properties.reason_required`);n.append(Q(`button`,{type:`button`,class:`efe-prop__open-item`,onclick:()=>t.reveal(r)},Q(`span`,{text:r.label||r.name||X(`editor.doc_properties.no_label`)}),Q(`small`,{text:`${t.regionLabel(r.region)} · ${e}`})))}return{list:n,count:e.length}}function x(){let{list:e,count:t}=b();r(uO(X(`editor.doc_properties.write`),X(`editor.doc_properties.write_title`)),Q(`p`,{class:`efe-prop__hint`,text:X(`editor.doc_properties.write_hint`)}),Q(`p`,{class:`efe-prop__kicker`,text:t?X(`editor.doc_properties.open_count`,{n:t}):X(`editor.doc_properties.open`)}),e)}function S(){let{count:e}=b();r(uO(X(`editor.doc_properties.print`),X(`editor.doc_properties.print_title`)),Q(`p`,{class:`efe-prop__hint`,text:X(`editor.doc_properties.print_hint`)}),Q(`p`,{class:`efe-prop__note${e?` efe-prop__note--warn`:` efe-prop__note--ok`}`,text:e?X(`editor.doc_properties.missing_count`,{count:e}):X(`editor.doc_properties.all_required_filled`)}))}return{render:a}}var vO=xT.document.filter(e=>e!==`pageBreak`),yO=[`header.first`,`header.rest`,`footer.first`,`footer.rest`];function bO(e=`fixed`,t={}){let n={type:`paragraph`},r=e===`free`?[{type:`docInput`,attrs:{inputId:ME(`t`),kind:`text`,label:X(`editor.document_editor.text`),format:`full`,start:`suggestion`,placeholder:``,required:!1,minLength:null,who:null},content:[n]}]:[n];return{format:2,layout:{orientation:`portrait`,margins:{top:20,right:20,bottom:20,left:20},headerDistance:8,footerDistance:7,firstPageDifferent:!1,firstPageMargins:null,letterheadId:null,...t},body:{type:`doc`,content:r},header:{first:null,rest:null},footer:{first:null,rest:null}}}function xO(e){return e===void 0?void 0:JSON.parse(JSON.stringify(e))}function SO(e){let t=xO(e&&e.format===2?e:bO());t.layout={...bO().layout,...t.layout??{}},t.layout.margins={...bO().layout.margins,...t.layout.margins??{}},t.body=t.body?.type===`doc`?t.body:{type:`doc`,content:[{type:`paragraph`}]};for(let e of[`header`,`footer`])t[e]={first:t[e]?.first??null,rest:t[e]?.rest??null};return t}var CO=()=>({type:`doc`,content:[{type:`paragraph`}]});function wO(e){return{"header.first":X(`editor.document_editor.header_first`),"header.rest":X(`editor.document_editor.header`),"footer.first":X(`editor.document_editor.footer_first`),"footer.rest":X(`editor.document_editor.footer`),body:X(`editor.document_editor.text`)}[e]}function TO(e,t={}){let n=t.role===`document`?`document`:`template`,r=t.mode??(n===`document`?`write`:`template`);n===`document`&&r===`template`&&(r=`write`);let i=SO(t.package),a=null,o=!1,s=document.createElement(`div`);s.className=`efe-docedit`;let c=document.createElement(`div`);c.className=`efe-docedit__toolbar efe-frame`;let l=document.createElement(`div`);l.className=`efe-docedit__tools efe-toolbar`,l.setAttribute(`role`,`toolbar`),l.setAttribute(`aria-label`,X(`editor.document_editor.template`));let u=document.createElement(`div`);u.className=`efe-docedit__format`,c.append(l,u);let d=document.createElement(`div`);d.className=`efe-docedit__layout`;let f=document.createElement(`div`);f.className=`efe-surround efe-docedit__sheet`;let p=document.createElement(`div`);p.className=`efe-docedit__ruler`;let m=document.createElement(`div`);m.className=`efe-page efe-docedit__page`;let h={header:document.createElement(`div`),footer:document.createElement(`div`)};h.header.className=`efe-band-slot efe-band-slot--head`,h.footer.className=`efe-band-slot efe-band-slot--foot`;let g=document.createElement(`div`);g.className=`efe-docedit__body`,m.append(h.header,g,h.footer),f.append(p,m);let _=typeof Element<`u`&&`currentCSSZoom`in Element.prototype;function v(){let e=getComputedStyle(f),t=f.clientWidth-parseFloat(e.paddingLeft)-parseFloat(e.paddingRight),n=t>0&&m.offsetWidth>t?t/m.offsetWidth:1;f.style.setProperty(`--efe-sheet-zoom`,String(n))}let y=_&&typeof ResizeObserver==`function`?new ResizeObserver(v):null;y?.observe(f),y?.observe(m);let b=t.properties??document.createElement(`aside`);b.classList.add(`efe-docedit__panel`),d.append(f),t.properties||d.append(b);let x=document.createElement(`div`);x.className=`efe-docedit__bubble`,x.hidden=!0,s.append(c,d,x),e.append(s);let S={},C={header:{first:null,rest:null},footer:{first:null,rest:null}},w={header:`first`,footer:`first`},T=`body`,ee={},E=()=>vD(i.layout),D=()=>r===`template`,te=()=>D()&&!!i.layout.letterheadId,ne=()=>{typeof t.onChange==`function`&&t.onChange(ke.getPackage())};function re(){for(let e of Object.values(S))e?.destroy();S={},u.replaceChildren();for(let e of Object.values(h))e.replaceChildren();g.replaceChildren()}function ie(e,n,r){let a=D(),o=document.createElement(`div`);o.className=`efe-docedit__bar`,o.hidden=!0,ee[e]=o,u.append(o);let c=EO(n,{features:e===`body`?`document`:vO,content:r,templateMode:a,variables:ae,variableDisplay:a?`labels`:`values`,can:t.can??null,gender:t.gender??null,onBlocked:t.onBlocked??null,toolbar:o,fonts:t.fonts??[],...t.styles?{styles:t.styles}:{},bubble:!a,uploadImage:a?t.uploadImage:void 0,...e===`body`?{layout:i.layout,bands:C,bandReplicas:!1}:{},editable:!(e!==`body`&&te())});return c.on(`focus`,()=>{T=e,me(e),Oe()}),c.on(`selectionUpdate`,()=>{T===e&&(Oe(),Se())}),c.on(`update`,()=>{if(e!==`body`){let[t,n]=e.split(`.`);C[t][n]=c.getJSON(),BD(S.body),fe()}T===e&&Oe(),D()||oe(ke.getPackage()),ne()}),c.on(`blur`,()=>{setTimeout(()=>{s.contains(document.activeElement)||(x.hidden=!0)},0)}),c}let ae={};function oe(e){for(let e of Object.keys(ae))delete ae[e];let n=t.variables instanceof Map?Object.fromEntries(t.variables):t.variables??{};Object.assign(ae,n),ae.seite={label:X(`editor.document_editor.var_page`),value:`1`},ae.seiten={label:X(`editor.document_editor.var_pages`),value:`1`};let r=e=>{e&&typeof e==`object`&&e.type!==`docRepeat`&&(e.type===`docField`&&e.attrs?.fieldId&&(ae[`feld.${e.attrs.fieldId}`]={label:e.attrs.label||e.attrs.fieldId,value:e.attrs.value||``}),(e.content??[]).forEach(r))};r(e.body);for(let t of[`header`,`footer`])r(e[t].first),r(e[t].rest)}function se(){re(),x.hidden=!0,s.dataset.mode=r,s.dataset.role=n,oe(i);for(let e of[`header`,`footer`])C[e].first=i.layout.firstPageDifferent?i[e].first:null,C[e].rest=i[e].rest,w[e]===`first`&&!C[e].first&&(w[e]=`rest`);xD(m,E()),S.body=ie(`body`,g,i.body);for(let e of[`header`,`footer`])ce(e);if(r===`preview`)for(let e of Object.values(S))e&&Dw(e,!0);xe(),we.render(),me(`body`),Oe(),ue(),fe()}function ce(e){let n=h[e];n.replaceChildren();let r=D(),a=!!C[e].first,o=!!C[e].rest,s=document.createElement(`div`);s.className=`efe-band-slot__tabs`,s.setAttribute(`contenteditable`,`false`);let c=(t,n)=>{let r=document.createElement(`button`);return r.type=`button`,r.className=`efe-band-slot__tab`,r.textContent=n,r.setAttribute(`aria-pressed`,String(w[e]===t)),r.addEventListener(`mousedown`,e=>e.preventDefault()),r.addEventListener(`click`,()=>{w[e]=t,le(e);for(let e of s.querySelectorAll(`button`))e.setAttribute(`aria-pressed`,String(e===r));S[`${e}.${t}`]?.commands.focus()}),r},l=e===`header`,u=X(l?`editor.document_editor.header`:`editor.document_editor.footer`),d=X(l?`editor.document_editor.header_first`:`editor.document_editor.footer_first`);if(a&&o)s.append(c(`first`,d),c(`rest`,X(l?`editor.document_editor.header_rest`:`editor.document_editor.footer_rest`)));else if(r&&(a||o)){let e=document.createElement(`span`);e.className=`efe-band-slot__label`,e.textContent=a?d:u,s.append(e)}if(te()){let e=document.createElement(`span`);e.className=`efe-band-slot__note`,e.textContent=X(`editor.document_editor.from_letterhead`,{name:(t.letterheads??[]).find(e=>e.id===i.layout.letterheadId)?.name??i.layout.letterheadId}),s.append(e)}s.childElementCount&&(r||a&&o)&&n.append(s);for(let t of[`first`,`rest`]){let r=C[e][t];if(!r)continue;let i=document.createElement(`div`);i.className=`efe-band-slot__editor`,i.dataset.slot=t,n.append(i),S[`${e}.${t}`]=ie(`${e}.${t}`,i,r)}if(!o&&r&&!te()){let t=document.createElement(`button`);t.type=`button`,t.className=`efe-band-slot__add`,t.textContent=X(l?`editor.document_editor.add_header`:`editor.document_editor.add_footer`),t.addEventListener(`click`,()=>{i=ke.getPackage(),i[e].rest=CO(),se(),S[`${e}.rest`]?.commands.focus()}),n.append(t)}le(e)}function le(e){for(let t of h[e].querySelectorAll(`.efe-band-slot__editor`))t.hidden=t.dataset.slot!==w[e];ue(),fe()}function ue(){let e=E(),t=h.header,n=h.footer;t.style.top=`${e.headerDistance}mm`,t.style.left=n.style.left=`${e.margins.left}mm`,t.style.right=n.style.right=`${e.margins.right}mm`,n.style.bottom=`${e.footerDistance}mm`;let r=w.header===`first`?e.first.top:e.margins.top,i=w.footer===`first`?e.first.bottom:e.margins.bottom;t.style.setProperty(`--efe-band-limit`,`${Math.max(1,r-e.headerDistance-2)}mm`),n.style.setProperty(`--efe-band-limit`,`${Math.max(1,i-e.footerDistance-2)}mm`)}let de={header:null,footer:null};function fe(){let e=E(),t=m.offsetWidth>0?m.offsetWidth/e.width:0;for(let n of[`header`,`footer`]){de[n]=null,h[n].classList.remove(`is-overflow`);let r=h[n].querySelector(`.efe-band-slot__editor[data-slot="${w[n]}"]`);if(!r||!t)continue;let i=n===`header`,a=i?w.header===`first`?e.first.top:e.margins.top:w.footer===`first`?e.first.bottom:e.margins.bottom,o=i?e.headerDistance:e.footerDistance,s=Math.ceil(r.scrollHeight/t)+o+2;s>a&&(de[n]={neededMm:s,slot:w[n]},h[n].classList.add(`is-overflow`))}}let pe=()=>S[T]??S.body;function me(e){for(let[t,n]of Object.entries(ee))n.hidden=t!==e}let he=()=>[[`line`,X(`editor.document_editor.kind_line`),X(`editor.document_editor.kind_line_hint`)],[`choice`,X(`editor.document_editor.kind_choice`),X(`editor.document_editor.kind_choice_hint`)],[`date`,X(`editor.document_editor.kind_date`),X(`editor.document_editor.kind_date_hint`)],[`number`,X(`editor.document_editor.kind_number`),X(`editor.document_editor.kind_number_hint`)],[`text`,X(`editor.document_editor.kind_text`),X(`editor.document_editor.kind_text_hint`)],[`snippet`,X(`editor.document_editor.kind_snippet`),X(`editor.document_editor.kind_snippet_hint`)]];function ge(e){let t=pe();return e===`text`?t.chain().focus().freeAsTextArea().run():e===`snippet`?t.chain().focus().freeAsSnippet().run():t.chain().focus().insertInputField(e).run()}function _e(e,t,n){let r=document.createElement(`button`);return r.type=`button`,r.className=`efe-btn efe-btn--text`,r.textContent=e,n&&(r.title=n),r.addEventListener(`mousedown`,e=>e.preventDefault()),r.addEventListener(`click`,t),r}function ve(e,t,n){let r=document.createElement(`div`);r.className=`efe-dropdown efe-docedit__menu`;let i=_e(`${e} ▾`,()=>{let e=a.hidden;ye(),a.hidden=!e,i.setAttribute(`aria-expanded`,String(e)),e&&a.querySelector(`button`)?.focus()});i.setAttribute(`aria-haspopup`,`true`),i.setAttribute(`aria-expanded`,`false`);let a=document.createElement(`div`);a.className=`efe-dropdown__menu`,a.setAttribute(`role`,`menu`),a.hidden=!0;for(let[e,r,i]of t){let t=document.createElement(`button`);t.type=`button`,t.className=`efe-dropdown__item`,t.setAttribute(`role`,`menuitem`),t.dataset.key=e;let o=document.createElement(`span`);if(o.textContent=r,t.append(o),i){let e=document.createElement(`small`);e.textContent=i,t.append(e)}t.addEventListener(`mousedown`,e=>e.preventDefault()),t.addEventListener(`click`,()=>{ye(),n(e)}),a.append(t)}return a.addEventListener(`keydown`,e=>{let t=[...a.querySelectorAll(`button`)],n=t.indexOf(document.activeElement);e.key===`ArrowDown`&&(e.preventDefault(),t[(n+1)%t.length].focus()),e.key===`ArrowUp`&&(e.preventDefault(),t[(n-1+t.length)%t.length].focus()),e.key===`Escape`&&(e.preventDefault(),ye(),pe().commands.focus())}),r.append(i,a),r.open=()=>i.click(),r}function ye(){for(let e of l.querySelectorAll(`.efe-dropdown__menu`))e.hidden=!0;for(let e of l.querySelectorAll(`[aria-haspopup]`))e.setAttribute(`aria-expanded`,`false`)}let be=null;function xe(){if(l.replaceChildren(),l.hidden=!D(),!D())return;let e=(...e)=>{let t=document.createElement(`div`);return t.className=`efe-toolbar__group`,t.append(...e),t};be=ve(X(`editor.document_editor.insert_input`),he(),e=>{ge(e),Oe()});let n=Object.entries(t.variables instanceof Map?Object.fromEntries(t.variables):t.variables??{}).map(([e,t])=>[e,t?.label??e,`{{${e}}}`]);n.push([`seite`,X(`editor.document_editor.var_page`),`{{seite}}`],[`seiten`,X(`editor.document_editor.var_pages`),`{{seiten}}`]);let r=ve(X(`editor.document_editor.variable`),n,e=>{pe().chain().focus().insertContent({type:`docVariable`,attrs:{name:e}}).run()});l.append(e(be,_e(X(`editor.document_editor.fix`),()=>pe().chain().focus().fixSelection().run(),X(`editor.document_editor.fix_tip`))),e(_e(X(`editor.document_editor.aside`),()=>S.body.chain().focus().insertAside().run()),_e(X(`editor.document_editor.repeat`),()=>S.body.chain().focus().wrapInRepeat().run()),_e(X(`editor.document_editor.optional`),()=>S.body.chain().focus().wrapInOptional().run())),e(r))}function Se(){if(!D()){x.hidden=!0;return}let e=pe(),{state:t,view:n}=e,r=t.selection;if(!(r instanceof A)||r.empty||!t.doc.textBetween(r.from,r.to).trim()){x.hidden=!0;return}x.replaceChildren();let i=(e,t)=>x.append(_e(e,()=>{t(),x.hidden=!0,Oe()}));eD(r.$from)?i(X(`editor.document_editor.fix`),()=>e.chain().focus().fixSelection().run()):(r.$from.parent===r.$to.parent&&r.$from.parent.isTextblock&&i(X(`editor.document_editor.free_as_line`),()=>e.chain().focus().insertInputField(`line`).run()),i(X(`editor.document_editor.free_as_text_area`),()=>e.chain().focus().freeAsTextArea().run()),T===`body`&&i(X(`editor.document_editor.free_as_snippet`),()=>e.chain().focus().freeAsSnippet().run()));let a=null;try{a=n.coordsAtPos(r.to)}catch{a=null}x.hidden=!1,a&&(x.style.left=`${Math.max(8,a.left-20)}px`,x.style.top=`${a.bottom+8}px`)}s.addEventListener(`keydown`,e=>{if(!D()||!(e.ctrlKey||e.metaKey)||!e.shiftKey)return;let t=e.key.toLowerCase();t===`e`?(e.preventDefault(),be?.open()):t===`f`&&(e.preventDefault(),pe().chain().focus().fixSelection().run())}),s.addEventListener(`mousedown`,e=>{if(!D()||!(e.target instanceof Element))return;let t=e.target.closest(`.efe-field, .efe-input[data-efe-kind="snippet"]`);if(t)for(let[e,n]of Object.entries(S)){if(!n||!n.view.dom.contains(t))continue;let r;try{r=n.view.posAtDOM(t,0)}catch{return}let i=t.classList.contains(`efe-field`)?`docField`:`docInput`,a=[r,r-1].find(e=>e>=0&&n.state.doc.nodeAt(e)?.type.name===i);if(a===void 0)return;n.view.dispatch(n.state.tr.setSelection(j.create(n.state.doc,a))),T=e,me(e),Oe();return}}),document.addEventListener(`mousedown`,Ce);function Ce(e){l.contains(e.target)||ye()}let we=ZD(p,{geometry:E,visible:()=>D(),onMargin:(e,t)=>Te({margins:{...i.layout.margins,[e]:t}})});function Te(e){Object.assign(i.layout,e),e.margins&&(i.layout.margins={...e.margins}),xD(m,E()),ue(),we.update(),BD(S.body),fe(),Oe(),ne()}function Ee(e){i=e,se(),ne()}let De=_O(b,{options:t,isTemplate:D,mode:()=>r,focused:()=>T,focusedEditor:pe,editors:()=>S,pkg:()=>i,overflow:()=>de,setLayout:Te,rebuildWith:Ee,getPackage:()=>ke.getPackage(),openItems:()=>ke.openItems(),reveal:e=>ke.revealOpenItem(e),regionLabel:wO});function Oe(){o||De.render()}let ke={root:s,get mode(){return r},get editors(){return{...S}},getPackage(){let e=xO(i);e.body=S.body?S.body.getJSON():e.body;for(let t of yO){let[n,r]=t.split(`.`);e[n][r]=S[t]?S[t].getJSON():e[n][r]}return e},setMode(e){if(![`template`,`write`,`preview`].includes(e)||e===r||n===`document`&&e===`template`)return r;let t=ke.getPackage();return n===`template`&&(r===`template`?a=t:e===`template`&&a&&(t=a,a=null)),i=SO(t),r=e,se(),r},openItems(){let e=i.layout.firstPageDifferent?[`header.first`,`body`,`footer.first`,`header.rest`,`footer.rest`]:[`header.rest`,`body`,`footer.rest`],t=[];for(let n of e){let e=S[n];if(e)for(let r of qD(e))t.push({...r,region:n})}return t},revealOpenItem(e){let t=S[e.region];if(t){if(e.region!==`body`){let[t,n]=e.region.split(`.`);w[t]=n,le(t)}JD(t,e)}},setLayout:Te,destroy(){o=!0,document.removeEventListener(`mousedown`,Ce),re(),we.destroy(),y?.disconnect(),s.remove()}};return se(),ke}function EO(e,t={}){let{content:n,editable:r=!0,onUpdate:i,placeholder:a=X(`editor.index.placeholder`),toolbar:o=null,bubble:s=!0,variables:c,templateMode:l=!1,onBlocked:u,toolbarItems:d,uploadImage:f,variableDisplay:p,gender:m=null,can:h=null,layout:g=null,bands:_=null,fonts:v=[],styles:y=jw()}=t,b=ST(t),x=e=>b.has(e),S=e=>x(e)?{}:!1,C=x(`bulletList`)||x(`orderedList`),w=s?vT():null,T=[Ov.configure({...x(`sections`)?{document:!1}:{},code:!1,codeBlock:!1,link:!1,bold:S(`bold`),italic:S(`italic`),underline:S(`underline`),strike:S(`strike`),heading:x(`headings`)?{levels:[1,2,3]}:!1,bulletList:S(`bulletList`),orderedList:S(`orderedList`),listItem:C?{}:!1,listKeymap:C?{}:!1,blockquote:S(`blockquote`),horizontalRule:S(`horizontalRule`),...x(`inputs`)&&!l?{trailingNode:!1}:{}}),...x(`table`)?[Gb.configure({resizable:!1}),wb,Cb,Sb]:[],...x(`textAlign`)?[Kb.configure({types:[`heading`,`paragraph`]})]:[],...x(`styles`)?[Mw]:x(`fontFamily`)?[Zb]:[],...x(`fontFamily`)?[ex]:[],...x(`styles`)?[Nw]:[],qb.configure({placeholder:a}),...x(`variables`)?[NT.configure({variables:c??{},display:p??(l||!kT(c)?`labels`:`values`)})]:[],...x(`variables`)&&c?[lE.configure({variables:c})]:[],...x(`fields`)?[WT.configure({gender:m,can:h})]:[],RC,...x(`image`)?[zC.configure({upload:f??null})]:[],...x(`video`)?[ZC]:[],...x(`emoji`)?[UD.configure({data:t.emojiData})]:[],...x(`callout`)?[UC.configure({blocks:DO(x)})]:[],...x(`sections`)?[SE,xE.configure({templateMode:l,onBlocked:u??null}),wE.configure({templateMode:l,onBlocked:u})]:[],...x(`inputs`)?[UE.configure({templateMode:l,can:h,onBlocked:u??null}),WE.configure({templateMode:l,can:h,onBlocked:u??null}),GE.configure({templateMode:l,can:h,onBlocked:u??null}),KE.configure({templateMode:l,can:h,onBlocked:u??null}),qE.configure({templateMode:l,can:h,onBlocked:u??null}),HE,tD.configure({templateMode:l}),pD.configure({templateMode:l,can:h,onBlocked:u??null})]:[],...x(`pageBreak`)?[mD,VD.configure({layout:g,bands:_,variables:c??null,replicas:t.bandReplicas!==!1})]:[],...x(`link`)?[yC(),PC]:[],...w?w.extensions:[]],ee=new pp({element:e,extensions:T,content:n&&CT(n,Iu(T)),editable:r,...i?{onUpdate:i}:{}});return w?.attach(ee),g&&xD(e.closest?.(`.efe-page`)??e,vD(g)),o&&Vw(ee,o,{items:d??(t.features===void 0?Rw:void 0),fonts:v,styles:Aw(y)}),ee}function DO(e){let t=[`paragraph`];return e(`headings`)&&t.push(`heading`),e(`bulletList`)&&t.push(`bulletList`),e(`orderedList`)&&t.push(`orderedList`),e(`image`)&&t.push(`imageBlock`),t}var OO=EO;return e.CALLOUT_VARIANTS=BC,e.FORMAT_MARKS=kE,e.FORMAT_NODES=OE,e.bandFor=bD,e.blankInstance=QE,e.collectEmptyRequiredFields=GT,e.collectOpenItems=qD,e.createDocumentEditor=TO,e.createEditor=EO,e.createLexEditor=OO,e.degradeBlocks=NE,e.features=yT,e.fieldKind=AE,e.inputFormat=jE,e.isPreview=Ew,e.isValidVideo=YC,e.newTemplatePackage=bO,e.pageGeometry=vD,e.parseVideoUrl=XC,e.presets=xT,e.revealOpenItem=JD,e.setPreview=Dw,e.variableState=OT,e})({}); \ No newline at end of file diff --git a/public/assets/js/ui/_dialog.js b/public/assets/js/ui/_dialog.js index e43712c5..f4ae4dd6 100644 --- a/public/assets/js/ui/_dialog.js +++ b/public/assets/js/ui/_dialog.js @@ -1,16 +1,16 @@ -import{n as e}from"./_core.js";import{i as t,n,t as r}from"./_overlay.js";var i=[],a=()=>i.length>0,o=1,s=new WeakMap,c=`a[href]:not([tabindex="-1"]), button:not([disabled]):not([tabindex="-1"]), textarea:not([disabled]):not([tabindex="-1"]), input:not([disabled]):not([type="hidden"]):not([tabindex="-1"]), select:not([disabled]):not([tabindex="-1"]), [tabindex]:not([tabindex="-1"])`,l=class e{static hostFor=null;constructor(e={}){this.id=o++,this.options={title:``,body:``,actions:[],size:`md`,closeOnBackdrop:!0,closeOnEscape:!0,onOpen:null,onClose:null,ariaLabel:null,host:null,preserveBody:!1,...e},this.element=null,this.backdrop=null,this.previousFocus=null,this._resolve=null,this._result=null,this._bodyEl=null,this._bodyOrigin=null,this._boundKeyHandler=this._handleKey.bind(this)}open(){return this.element?Promise.resolve(this._result):(this.previousFocus=document.activeElement,this.host=this.options.host||(this.options.size===`sm`?e.hostFor?.(this.previousFocus):null)||null,this._render(),this.host&&(this.element.classList.add(`ignis-dialog--in-window`),this.backdrop.classList.add(`ignis-dialog-backdrop--in-window`),this.element.style.zIndex=``,this.backdrop.style.zIndex=``),(this.host||document.body).append(this.backdrop,this.element),i.push(this),this.host||r(this),this.element.offsetHeight,requestAnimationFrame(()=>{n(this.element,!0),n(this.backdrop,!0)}),document.addEventListener(`keydown`,this._boundKeyHandler,!0),this._focusFirst(),typeof this.options.onOpen==`function`&&this.options.onOpen(this),new Promise(e=>{this._resolve=e}))}close(e=null){if(!this.element)return;this._result=e,n(this.element,!1),n(this.backdrop,!1),document.removeEventListener(`keydown`,this._boundKeyHandler,!0);let r=this.element,a=this.backdrop,o=this.options.preserveBody&&this._bodyEl?this._bodyEl:null,s=this._bodyOrigin;setTimeout(()=>{o&&(s&&document.contains(s)?s.appendChild(o):(o.style.display=`none`,document.body.appendChild(o))),r.remove(),a.remove()},220),this.element=null,this.backdrop=null,i=i.filter(e=>e!==this),this.host||t(this),this.previousFocus&&document.contains(this.previousFocus)&&this.previousFocus.focus(),typeof this.options.onClose==`function`&&this.options.onClose(e),this._resolve&&=(this._resolve(e),null)}static confirm(t,n={}){return new e({size:`sm`,sheet:n.sheet===!0,title:n.title??`Bestätigen`,preset:`confirm`,icon:n.danger?`fa-trash-can`:`fa-circle-question`,initialFocus:`[data-dialog-action="0"]`,body:n.body??`${n.objectName?`

${u(n.objectName)}

`:``}

${u(t)}

`,ariaLabel:n.title??`Bestätigen`,actions:[{label:n.cancelText??`Abbrechen`,variant:`ghost`,close:!1,onClick:e=>e.close(!1)},{label:n.confirmText??`Bestätigen`,variant:n.danger?`danger`:`primary`,primary:!0,onClick:e=>e.close(!0)}]}).open().then(e=>e===!0)}static alert(t,n={}){let r=n.type??`info`,i={info:`fa-circle-info`,success:`fa-circle-check`,warning:`fa-triangle-exclamation`,error:`fa-circle-xmark`}[r]??`fa-circle-info`;return new e({size:`sm`,sheet:n.sheet===!0,title:n.title??{info:`Hinweis`,success:`Erfolg`,warning:`Achtung`,error:`Fehler`}[r],body:`
- -

${u(t)}

-
`,actions:[{label:n.okText??`OK`,variant:r===`error`?`danger`:`primary`,primary:!0,close:!0}]}).open().then(()=>void 0)}static prompt(t,n={}){let r=`ignis-dialog-prompt-${Math.random().toString(36).slice(2,8)}`,i=u(String(n.default??``)),a=u(String(n.placeholder??``));return new e({size:`sm`,sheet:n.sheet===!0,title:n.title??`Eingabe`,body:` - `,actions:[{label:n.cancelText??`Abbrechen`,variant:`ghost`,onClick:e=>e.close(null)},{label:n.confirmText??`OK`,variant:`primary`,primary:!0,onClick:e=>{let t=e.element.querySelector(`#${r}`);e.close(t?t.value:null)}}],onOpen:e=>{let t=e.element.querySelector(`#${r}`);t&&(t.focus(),t.select())}}).open()}static openElement(t,n={}){let r=typeof t==`string`?document.querySelector(t):t;if(!(r instanceof HTMLElement))return null;let i=s.get(r);if(i?.element)return i;let a=r.querySelector(`:scope > .modal-dialog > .modal-content`)||r.querySelector(`:scope > .modal-content`)||r,o=r.querySelector(`:scope > .modal-dialog`),c=n.size||`md`;o?.classList.contains(`modal-sm`)&&(c=`sm`),o?.classList.contains(`modal-lg`)&&(c=`lg`),o?.classList.contains(`modal-xl`)&&(c=`xl`);let l=new e({body:a,size:c,actions:[],preserveBody:!0,closeOnBackdrop:n.closeOnBackdrop??!r.hasAttribute(`data-dialog-static`),closeOnEscape:n.closeOnEscape??!r.hasAttribute(`data-dialog-static`),ariaLabel:n.ariaLabel||r.getAttribute(`aria-label`)||`Dialog`,onOpen:e=>{e.element.classList.add(`ignis-dialog--embedded`),r.dispatchEvent(new CustomEvent(`shown.ignis.dialog`,{bubbles:!0})),typeof n.onOpen==`function`&&n.onOpen(e)},onClose:e=>{r.dispatchEvent(new CustomEvent(`hidden.ignis.dialog`,{bubbles:!0,detail:{result:e}})),typeof n.onClose==`function`&&n.onClose(e)}});return s.set(r,l),l.open(),l}static closeElement(e,t=null){let n=typeof e==`string`?document.querySelector(e):e,r=n instanceof HTMLElement?s.get(n):null;r&&r.close(t)}static form(t={}){let n=typeof t.template==`string`?document.getElementById(t.template):t.template;if(!n||!(n instanceof HTMLTemplateElement))return console.error(`Dialog.form: template not found or not a