From c99d658a9d55c27f777969a956cf79b2c14ba173 Mon Sep 17 00:00:00 2001 From: Stevring Date: Tue, 13 Oct 2026 17:19:05 +0800 Subject: [PATCH 01/12] fix(ui-conversation): avoid automatic composer focus on mobile --- THIRD_PARTY_NOTICES.md | 1 + .../client/ui-conversation/README.i18n.yaml | 4 +-- packages/client/ui-conversation/README.md | 2 ++ packages/client/ui-conversation/README.zh.md | 2 ++ packages/client/ui-conversation/package.json | 3 +- .../src/client/skeleton/InputBar.tsx | 13 ++++--- .../tests/input-bar.client.spec.tsx | 36 +++++++++++++++++++ pnpm-lock.yaml | 3 ++ 8 files changed, 56 insertions(+), 8 deletions(-) diff --git a/THIRD_PARTY_NOTICES.md b/THIRD_PARTY_NOTICES.md index 43b8d64815..9b6d6b5ff0 100644 --- a/THIRD_PARTY_NOTICES.md +++ b/THIRD_PARTY_NOTICES.md @@ -78,6 +78,7 @@ External packages installed for runtime use or embedded in distributed Host or b | [`ajv`](https://github.com/ajv-validator/ajv) | MIT | | [`anser`](https://github.com/IonicaBizau/anser) | MIT | | [`big.js`](https://github.com/MikeMcl/big.js) | MIT | +| [`bowser`](https://github.com/bowser-js/bowser) | MIT | | [`buffer`](https://github.com/feross/buffer) | MIT | | [`chokidar`](https://github.com/paulmillr/chokidar) | MIT | | [`chrome-devtools-frontend`](https://github.com/ChromeDevTools/devtools-frontend) | BSD-3-Clause | diff --git a/packages/client/ui-conversation/README.i18n.yaml b/packages/client/ui-conversation/README.i18n.yaml index 3b74b55d70..a0de810175 100644 --- a/packages/client/ui-conversation/README.i18n.yaml +++ b/packages/client/ui-conversation/README.i18n.yaml @@ -21,8 +21,8 @@ en: 9912b286384c41d7 zh: 3e994887c1948677 /deepseek-ai-dsh-client-ui-conversation/shell-and-standard-props: - en: c4d4aaef46daab72 - zh: 0dac50689d806ecf + en: 763b9cb25557eb00 + zh: bbadb8442cc259d8 /deepseek-ai-dsh-client-ui-conversation/temporary-composer-entries: en: bb1244310f5c0382 zh: 824b84077432b559 diff --git a/packages/client/ui-conversation/README.md b/packages/client/ui-conversation/README.md index 1a0cb88bc9..550dbcf281 100644 --- a/packages/client/ui-conversation/README.md +++ b/packages/client/ui-conversation/README.md @@ -68,6 +68,8 @@ The composer measures its expanded control groups after size, content, visibilit The context meter follows the [statistics-control radius](../../../docs/ui-radius.md#radius-scale). +The composer skips automatic focus on mount, Session switching, and unlock for Bowser's UA classifications `mobile` and `tablet`, and for iPads reporting `MacIntel` with more than one touch point. Tapping the input still focuses it. Desktop devices, including Windows touchscreen computers, retain automatic focus regardless of window width. Browser modes or custom UA strings that conceal the mobile platform can prevent identification; a desktop UA alone cannot distinguish Android tablets from Linux computers. + The context-occupancy button shows a ring and percentage below the input card, after the Session statistics. Clicking it opens the token breakdown in a panel kept inside the viewport, including when no statistics are shown; the button stays hidden until context usage and capacity are available. With Coding Tools off, the shell hides only Trajectory; other plugin-contributed Views remain available. The View tab bar is hidden when fewer than two Views are available. Turning Coding Tools off while Trajectory is active returns to Chat; stored View preferences and recorded Session data remain intact. Turning it on makes Trajectory available again. View owners receive the available roster so their navigation actions can follow the same visibility. diff --git a/packages/client/ui-conversation/README.zh.md b/packages/client/ui-conversation/README.zh.md index ccef596924..38b8765f9b 100644 --- a/packages/client/ui-conversation/README.zh.md +++ b/packages/client/ui-conversation/README.zh.md @@ -68,6 +68,8 @@ Queue 预览启用空白折叠和文档边缘 trim,保留 emoji,并使用 CS 上下文占用率入口遵循[统计控件圆角规则](../../../docs/ui-radius.zh.md#radius-scale)。 +对于 Bowser 从 UA 识别为 `mobile` 或 `tablet` 的设备,以及报告 `MacIntel` 且触摸点数大于一的 iPad,composer 会跳过挂载、切换 Session 和解除锁定时的自动聚焦。点击输入框仍会聚焦。桌面设备(包括 Windows 触屏电脑)保留自动聚焦,不受窗口宽度影响。隐藏移动平台信息的浏览器模式或自定义 UA 可能导致识别失败;仅凭桌面 UA 无法区分 Android 平板与 Linux 电脑。 + 上下文占用按钮在输入卡片下方、会话统计右侧显示圆环和百分比。点击按钮可在视口内的面板查看 token 构成,没有统计项时面板也不会越界;上下文用量和容量尚不可用时,按钮保持隐藏。 关闭代码工作工具时,外壳仅隐藏 Trajectory;其他插件贡献的 View 仍然可用。可用 View 少于两个时隐藏 View 标签栏。在 Trajectory 激活时关闭代码工作工具会返回 Chat;已保存的 View 偏好和 Session 记录保持不变。开启后,Trajectory 恢复可用。View 所有者接收可用列表,使导航操作跟随相同的可见性。 diff --git a/packages/client/ui-conversation/package.json b/packages/client/ui-conversation/package.json index 11a24a79f7..f28213a34b 100644 --- a/packages/client/ui-conversation/package.json +++ b/packages/client/ui-conversation/package.json @@ -96,7 +96,8 @@ "@deepseek-ai/dsh-agent": "workspace:*", "@deepseek-ai/dsh-settings": "workspace:*", "@deepseek-ai/dsh-client-shortcuts": "workspace:*", - "@deepseek-ai/dsh-client-product-analytics": "workspace:*" + "@deepseek-ai/dsh-client-product-analytics": "workspace:*", + "bowser": "^2.14.1" }, "files": [ "locale/*.json", diff --git a/packages/client/ui-conversation/src/client/skeleton/InputBar.tsx b/packages/client/ui-conversation/src/client/skeleton/InputBar.tsx index ef95796577..e479d1364e 100644 --- a/packages/client/ui-conversation/src/client/skeleton/InputBar.tsx +++ b/packages/client/ui-conversation/src/client/skeleton/InputBar.tsx @@ -16,6 +16,7 @@ import { memo, useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react' import type { ChangeEvent, KeyboardEvent, MouseEvent } from 'react' import clsx from 'clsx' +import bowser from 'bowser' import { IconPlusOutlineMedium, IconWarningOutlineRegular, Toast, Tooltip, } from '@deepseek-ai/dsh-client-ui-primitives' @@ -172,13 +173,15 @@ export const InputBar = memo(function InputBar({ revealDraftSelection(scrollRef) } - // Unlock (mount / session switch) returns focus to the box, and owns the - // reveal that comes with it. Lexical's focus() suppresses the browser's - // scroll walk (preventScroll inside), so the reveal in our own scrollport - // is ours to perform — switching to a longer draft otherwise leaves the - // caret (restored at the draft's end) off screen. + // Phones and tablets require explicit composer focus. Desktop-mode iPads + // share the Mac platform identifier, so touch support also identifies them. + // Automatic desktop focus restores and reveals the draft selection without + // scrolling the conversation. useEffect(() => { if (locked || editor === null) return + const platformType = bowser.parse(navigator.userAgent).platform.type + const desktopIPad = navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1 + if (platformType === 'mobile' || platformType === 'tablet' || desktopIPad) return focusDraftEditor(editor, revealSelection) }, [locked, sessionId, editor]) diff --git a/packages/client/ui-conversation/tests/input-bar.client.spec.tsx b/packages/client/ui-conversation/tests/input-bar.client.spec.tsx index 4ee04fe8a7..557c1086dd 100644 --- a/packages/client/ui-conversation/tests/input-bar.client.spec.tsx +++ b/packages/client/ui-conversation/tests/input-bar.client.spec.tsx @@ -1415,6 +1415,42 @@ describe('running and lock semantics', () => { expect(focused).toEqual([true]) }) + it.each([ + { name: 'iPhone', userAgent: 'Mozilla/5.0 (iPhone; CPU iPhone OS 18_6 like Mac OS X) AppleWebKit/605.1.15 Version/18.6 Mobile/15E148 Safari/604.1', platform: 'iPhone', maxTouchPoints: 5, automatic: false }, + { name: 'Android phone', userAgent: 'Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 Chrome/119.0.0.0 Mobile Safari/537.36', platform: 'Linux armv8l', maxTouchPoints: 0, automatic: false }, + { name: 'Android tablet', userAgent: 'Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 Chrome/119.0.0.0 Safari/537.36', platform: 'Linux armv8l', maxTouchPoints: 5, automatic: false }, + { name: 'desktop-mode iPad', userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 Version/18.6 Safari/605.1.15', platform: 'MacIntel', maxTouchPoints: 5, automatic: false }, + { name: 'Mac', userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 Version/18.6 Safari/605.1.15', platform: 'MacIntel', maxTouchPoints: 0, automatic: true }, + { name: 'Windows touchscreen', userAgent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 Chrome/119.0.0.0 Safari/537.36', platform: 'Win32', maxTouchPoints: 5, automatic: true }, + ])('automatic composer focus respects device classification: $name', ({ userAgent, platform, maxTouchPoints, automatic }) => { + for (const [name, value] of Object.entries({ userAgent, platform, maxTouchPoints })) { + const descriptor = Object.getOwnPropertyDescriptor(navigator, name) + Object.defineProperty(navigator, name, { configurable: true, value }) + onTestFinished(() => { + if (descriptor === undefined) Reflect.deleteProperty(navigator, name) + else Object.defineProperty(navigator, name, descriptor) + }) + } + const outside = document.createElement('input') + document.body.append(outside) + onTestFinished(() => { outside.remove() }) + outside.focus() + + const { view, textarea, props } = bench({ draft: 'draft' }) + expect(document.activeElement).toBe(automatic ? textarea : outside) + act(() => { outside.focus() }) + act(() => { view.rerender() }) + expect(document.activeElement).toBe(automatic ? textarea : outside) + act(() => { outside.focus() }) + act(() => { view.rerender() }) + act(() => { view.rerender() }) + expect(document.activeElement).toBe(automatic ? textarea : outside) + + act(() => { outside.focus() }) + fireEvent.mouseDown(view.container.querySelector('[data-composer-card]')!, { button: 0 }) + expect(document.activeElement).toBe(textarea) + }) + it('a persisted draft adopted after mount does not steal focus from another control', () => { const { shell } = bench() const other = document.createElement('input') diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 2edabccb3f..bb22920df5 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -3988,6 +3988,9 @@ importers: '@lexical/utils': specifier: ^0.49.0 version: 0.49.0(typescript@6.0.3) + bowser: + specifier: ^2.14.1 + version: 2.14.1 clsx: specifier: ^2.0.0 version: 2.1.1 From c29a31337982cbeafcae45a779e61a1a64e27257 Mon Sep 17 00:00:00 2001 From: Stevring Date: Wed, 14 Oct 2026 15:39:36 +0800 Subject: [PATCH 02/12] fix(client): avoid automatic picker focus on mobile Use the shared device focus policy for command popups, schedule forms, and the composer model picker while retaining user-requested focus. --- apps/web/tests/default-model.e2e.ts | 33 +++++++++++++++ packages/client/ui-commands/README.i18n.yaml | 4 +- packages/client/ui-commands/README.md | 2 +- packages/client/ui-commands/README.zh.md | 2 +- .../src/client/PopupSelectView.tsx | 16 ++++---- .../tests/popup-view.client.spec.tsx | 35 +++++++++++++++- .../client/ui-conversation/README.i18n.yaml | 4 +- packages/client/ui-conversation/README.md | 2 +- packages/client/ui-conversation/README.zh.md | 2 +- packages/client/ui-conversation/package.json | 3 +- .../src/client/skeleton/InputBar.tsx | 9 +---- .../ui-model-selection/README.i18n.yaml | 8 ++-- packages/client/ui-model-selection/README.md | 6 +-- .../client/ui-model-selection/README.zh.md | 6 +-- .../src/client/ModelSelect.tsx | 10 +++-- .../client/ui-primitives/README.i18n.yaml | 4 +- packages/client/ui-primitives/README.md | 2 + packages/client/ui-primitives/README.zh.md | 2 + packages/client/ui-primitives/package.json | 3 +- packages/client/ui-primitives/src/focus.ts | 15 ++++++- packages/client/ui-primitives/src/index.ts | 2 +- packages/client/ui-schedule/README.i18n.yaml | 4 +- packages/client/ui-schedule/README.md | 2 +- packages/client/ui-schedule/README.zh.md | 2 +- .../ui-schedule/src/client/TaskMenu.tsx | 9 +++-- .../tests/task-menu.client.spec.tsx | 40 ++++++++++++++++++- pnpm-lock.yaml | 6 +-- 27 files changed, 176 insertions(+), 57 deletions(-) diff --git a/apps/web/tests/default-model.e2e.ts b/apps/web/tests/default-model.e2e.ts index e8d1867f69..c1fee1e87a 100644 --- a/apps/web/tests/default-model.e2e.ts +++ b/apps/web/tests/default-model.e2e.ts @@ -199,6 +199,39 @@ describe('web e2e: the composer model switch is the default for later sessions', } }) + it.each([ + { device: 'iPhone', userAgent: 'Mozilla/5.0 (iPhone; CPU iPhone OS 18_6 like Mac OS X) AppleWebKit/605.1.15 Version/18.6 Mobile/15E148 Safari/604.1', automatic: false }, + { device: 'narrow desktop', userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 Version/18.6 Safari/605.1.15', automatic: true }, + ])('respects $device search focus when opening /model', async ({ userAgent, automatic }) => { + const context = await browser.newContext({ + userAgent, viewport: { width: 390, height: 844 }, locale: ZH_BROWSER_LOCALE, + }) + try { + const devicePage = await context.newPage() + const consoleWatch = watchConsole(devicePage) + await devicePage.goto(scaffold.authenticatedUrl, { waitUntil: 'load' }) + await devicePage.getByRole('textbox', { name: '选择工作区' }).click() + const composer = devicePage.locator('[data-composer-input][contenteditable="true"]').first() + await composer.waitFor() + await composer.fill('/model') + await devicePage.getByRole('option', { name: /^模型/ }).click() + const search = devicePage.getByRole('textbox', { name: '筛选选项', exact: true }) + await search.waitFor() + await devicePage.getByRole('option', { name: /Origin Large/ }).waitFor() + expect(await search.evaluate(input => document.activeElement === input)).toBe(automatic) + await search.click() + expect(await search.evaluate(input => document.activeElement === input)).toBe(true) + await search.fill('Origin') + await devicePage.getByRole('option', { name: /Origin Large/ }).waitFor() + expect(await devicePage.getByRole('option', { name: /Acme/ }).count()).toBe(0) + await search.press('Escape') + await composer.fill('') + expect(consoleWatch.pageErrors).toEqual([]) + } finally { + await context.close() + } + }) + it('shares provider order, fuzzy result order and sticky header material between both model pickers', async () => { const readGroups = (surface: Locator, role: 'option' | 'menuitemradio') => surface.locator('[data-menu-group]') .evaluateAll((groups, rowRole) => groups.map(group => ({ diff --git a/packages/client/ui-commands/README.i18n.yaml b/packages/client/ui-commands/README.i18n.yaml index 2521e4cb81..eed1e982c7 100644 --- a/packages/client/ui-commands/README.i18n.yaml +++ b/packages/client/ui-commands/README.i18n.yaml @@ -15,8 +15,8 @@ en: d152484eb41ac6b4 zh: 09388d293f9be9cb /deepseek-ai-dsh-client-ui-commands/use-this-package: - en: 01adce72791579fa - zh: 70eb55a1529038e7 + en: c325c9eaca4efe47 + zh: dbbc29cc9cec54bc /deepseek-ai-dsh-client-ui-commands/use-this-package/kinds-and-decorations: en: 57679a20574d8b3f zh: 98d5e5a7781e6de1 diff --git a/packages/client/ui-commands/README.md b/packages/client/ui-commands/README.md index fc5e7efe21..ef8781649e 100644 --- a/packages/client/ui-commands/README.md +++ b/packages/client/ui-commands/README.md @@ -25,7 +25,7 @@ Typing a `/` command opens a registered popup, a client action, a host command's ## Use this package -Mount this plugin alongside `ui-input-trigger` and `ui-conversation`; the `/` source then appears in the trigger menu, and business packages register their command surfaces through `ctx.commandUi`. Typing `/model` opens the registered popup; a host command with an argument claim opens its input or executes directly. The popup holds composer focus: typing filters the loaded rows locally, `↑`/`↓` walk them, Enter and `Tab` accept the highlighted row, and Escape and `Shift+Tab` return to the composer. The highlight opens on the row the options mark as the session's current value, so accepting on a freshly opened panel confirms it. The composer's `+` button and a typed `/` open the same menu: an Add section (File, Goal, Plan, Feedback) and a Commands section (Compact, Permission, Model, Export) in usage order, each row with a glyph, a localized title and description, and the command name as an alias where the localized title differs from it. +Mount this plugin alongside `ui-input-trigger` and `ui-conversation`; the `/` source then appears in the trigger menu, and business packages register their command surfaces through `ctx.commandUi`. Typing `/model` opens the registered popup; a host command with an argument claim opens its input or executes directly. The popup automatically focuses its search input on desktop. Phones and tablets require tapping the search input, following the shared [text-input focus policy](../ui-primitives/README.md#use-this-package). With search focused, typing filters the loaded rows locally, `↑`/`↓` walk them, Enter and `Tab` accept the highlighted row, and Escape and `Shift+Tab` return to the composer. The highlight opens on the row the options mark as the session's current value, so accepting on a freshly opened panel confirms it. The composer's `+` button and a typed `/` open the same menu: an Add section (File, Goal, Plan, Feedback) and a Commands section (Compact, Permission, Model, Export) in usage order, each row with a glyph, a localized title and description, and the command name as an alias where the localized title differs from it. ### Kinds and decorations diff --git a/packages/client/ui-commands/README.zh.md b/packages/client/ui-commands/README.zh.md index 7393d20329..7ad5b4f9a1 100644 --- a/packages/client/ui-commands/README.zh.md +++ b/packages/client/ui-commands/README.zh.md @@ -25,7 +25,7 @@ kind: "package-reference" ## 使用本包 -与 `ui-input-trigger` 及 `ui-conversation` 一起挂载本插件;`/` source 随即出现在触发菜单中,业务包经 `ctx.commandUi` 注册自己的命令表面。键入 `/model` 打开已注册的弹窗;带参数声明的宿主命令打开其输入或直接执行。弹窗持有 composer 焦点:键入即在已加载的行上本地筛选,`↑`/`↓` 在行间移动,回车与 `Tab` 接受高亮行,Escape 与 `Shift+Tab` 把焦点还给 composer。高亮落在选项标记为会话当前值的行上,因此在刚打开的弹窗上接受即确认当前值。composer 的 `+` 按钮与键入的 `/` 打开同一个菜单:「添加」小节(文件、目标、计划、反馈)与「指令」小节(压缩、权限、模型、下载日志)按使用频次排列,每行带图标、本地化的标题与说明,本地化标题与命令名不同时还显示命令名作为别名。 +与 `ui-input-trigger` 及 `ui-conversation` 一起挂载本插件;`/` source 随即出现在触发菜单中,业务包经 `ctx.commandUi` 注册自己的命令表面。键入 `/model` 打开已注册的弹窗;带参数声明的宿主命令打开其输入或直接执行。桌面端的弹窗自动聚焦搜索框。手机和平板需要点击搜索框,遵循共享的[文字输入框聚焦策略](../ui-primitives/README.zh.md#use-this-package)。搜索框聚焦后,键入即在已加载的行上本地筛选,`↑`/`↓` 在行间移动,回车与 `Tab` 接受高亮行,Escape 与 `Shift+Tab` 把焦点还给 composer。高亮落在选项标记为会话当前值的行上,因此在刚打开的弹窗上接受即确认当前值。composer 的 `+` 按钮与键入的 `/` 打开同一个菜单:「添加」小节(文件、目标、计划、反馈)与「指令」小节(压缩、权限、模型、下载日志)按使用频次排列,每行带图标、本地化的标题与说明,本地化标题与命令名不同时还显示命令名作为别名。 ### 种类与装饰 diff --git a/packages/client/ui-commands/src/client/PopupSelectView.tsx b/packages/client/ui-commands/src/client/PopupSelectView.tsx index 4b0b4bf418..f0338c6c68 100644 --- a/packages/client/ui-commands/src/client/PopupSelectView.tsx +++ b/packages/client/ui-commands/src/client/PopupSelectView.tsx @@ -1,9 +1,10 @@ /** * Official popupSelect shell: renders one session's PopupSelectController * store into the conversation.input.overlay anchor. Unlike the slash menu - * (combobox — textarea keeps focus), this shell HOLDS focus while open: the - * inner search input takes focus, plain typing filters the loaded options - * locally, Enter and Tab accept the filtered highlight, ↑↓ walk it (wrapping, + * (combobox — textarea keeps focus), this shell focuses its search input on + * desktop; phones and tablets require explicit search focus. Typing filters + * the loaded options locally, Enter and Tab accept the filtered highlight, + * ↑↓ walk it (wrapping, * scrolled into view), and Escape and Shift+Tab dismiss back to the composer. * ←→ keep the search input's native caret. Any pointer interaction outside the * box dismisses (the click's own target takes focus). Closed state renders @@ -14,7 +15,7 @@ import { MenuGroup, MenuSurface, observeStickyMenuGroups } from '@deepseek-ai/ds import { Fragment, useEffect, useMemo, useRef } from 'react' import { useSyncExternalStore } from 'react' import clsx from 'clsx' -import { IconCheckOutlineRegular, RiskConfirmation, useAnchoredMaxHeight } from '@deepseek-ai/dsh-client-ui-primitives' +import { IconCheckOutlineRegular, RiskConfirmation, shouldAutoFocusTextInput, useAnchoredMaxHeight } from '@deepseek-ai/dsh-client-ui-primitives' import type { PropsLocale } from '@deepseek-ai/dsh-client-ui-slots' import { filterOptions } from './popup.ts' import type { SelectOption } from './contract.ts' @@ -67,8 +68,7 @@ export function PopupSelectView({ popup, t }: PopupSelectViewProps) { cardRef.current?.querySelector('[aria-selected="true"]')?.scrollIntoView({ block: 'nearest' }) }, [active, rows, state.confirming]) - // Focus ownership: the search input grabs on open, and ANY outside - // pointer interaction dismisses — + // Any outside pointer interaction dismisses — // capture phase so a click landing anywhere else (textarea included) // closes the shell before its own handlers run; that click's target then // takes focus naturally, so no focusComposer here. @@ -84,7 +84,9 @@ export function PopupSelectView({ popup, t }: PopupSelectViewProps) { // Focus the search input after it mounts (separate effect so the ref is populated). useEffect(() => { - if (state.open && state.confirming === null) searchRef.current?.focus() + if (!state.open || state.confirming !== null) return + if (!shouldAutoFocusTextInput()) return + searchRef.current?.focus() }, [state.open, state.confirming]) if (!state.open) return null diff --git a/packages/client/ui-commands/tests/popup-view.client.spec.tsx b/packages/client/ui-commands/tests/popup-view.client.spec.tsx index 3003a868d9..387108f2ed 100644 --- a/packages/client/ui-commands/tests/popup-view.client.spec.tsx +++ b/packages/client/ui-commands/tests/popup-view.client.spec.tsx @@ -1,7 +1,8 @@ // @vitest-environment jsdom /** * PopupSelectView interaction spec: the search input takes - * focus on open and plain typing filters locally, ↑↓ move the filtered + * focus on desktop open; mobile search requires explicit focus. Typing filters + * locally, ↑↓ move the filtered * highlight while ←→ stay native to the input, Enter and Tab select * single-flight, Escape and Shift+Tab dismiss back through focusComposer, * outside pointerdown dismisses @@ -9,7 +10,7 @@ * retry button, the highlighted row scrolls into view, and the card height * clamps to the space above the composer. */ -import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' +import { afterEach, beforeEach, describe, expect, it, onTestFinished, vi } from 'vitest' import { act, cleanup, fireEvent, render, screen } from '@testing-library/react' import type { SelectOption } from '../src/client/contract.ts' import type { PopupSpec, TokenSegment } from '../src/client/popup.ts' @@ -140,6 +141,36 @@ describe('PopupSelectView', () => { expect(rowLabels()).toEqual(['Dark', 'Light', 'Sepia']) }) + it.each([ + { name: 'iPhone', userAgent: 'Mozilla/5.0 (iPhone; CPU iPhone OS 18_6 like Mac OS X) AppleWebKit/605.1.15 Version/18.6 Mobile/15E148 Safari/604.1', platform: 'iPhone', maxTouchPoints: 5, automatic: false }, + { name: 'Android phone', userAgent: 'Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 Chrome/119.0.0.0 Mobile Safari/537.36', platform: 'Linux armv8l', maxTouchPoints: 0, automatic: false }, + { name: 'Android tablet', userAgent: 'Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 Chrome/119.0.0.0 Safari/537.36', platform: 'Linux armv8l', maxTouchPoints: 5, automatic: false }, + { name: 'desktop-mode iPad', userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 Version/18.6 Safari/605.1.15', platform: 'MacIntel', maxTouchPoints: 5, automatic: false }, + { name: 'Mac', userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 Version/18.6 Safari/605.1.15', platform: 'MacIntel', maxTouchPoints: 0, automatic: true }, + { name: 'Windows touchscreen', userAgent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 Chrome/119.0.0.0 Safari/537.36', platform: 'Win32', maxTouchPoints: 5, automatic: true }, + ])('automatic search focus respects device classification: $name', async ({ userAgent, platform, maxTouchPoints, automatic }) => { + for (const [name, value] of Object.entries({ userAgent, platform, maxTouchPoints })) { + const descriptor = Object.getOwnPropertyDescriptor(navigator, name) + Object.defineProperty(navigator, name, { configurable: true, value }) + onTestFinished(() => { + if (descriptor === undefined) Reflect.deleteProperty(navigator, name) + else Object.defineProperty(navigator, name, descriptor) + }) + } + const { popup, search } = await mountOpen() + expect(document.activeElement === search).toBe(automatic) + act(() => { search.focus() }) + fireEvent.change(search, { target: { value: 'dark' } }) + expect(document.activeElement).toBe(search) + expect(rowLabels()).toEqual(['Dark']) + act(() => { popup.dismiss() }) + await act(async () => { + popup.open('theme', spec(), 'ctx-A', SEGMENT) + await Promise.resolve() + }) + expect(document.activeElement === screen.getByRole('textbox', { name: '筛选选项' })).toBe(automatic) + }) + it('renders an optional option badge as a superscript marker', async () => { await mountOpen({ options: () => Promise.resolve([{ id: 'auto', label: 'Auto review', badge: 'EXP' }]), diff --git a/packages/client/ui-conversation/README.i18n.yaml b/packages/client/ui-conversation/README.i18n.yaml index a0de810175..4c0b48fe55 100644 --- a/packages/client/ui-conversation/README.i18n.yaml +++ b/packages/client/ui-conversation/README.i18n.yaml @@ -21,8 +21,8 @@ en: 9912b286384c41d7 zh: 3e994887c1948677 /deepseek-ai-dsh-client-ui-conversation/shell-and-standard-props: - en: 763b9cb25557eb00 - zh: bbadb8442cc259d8 + en: fce20a7d042b1d29 + zh: 0f8e4faff447df6f /deepseek-ai-dsh-client-ui-conversation/temporary-composer-entries: en: bb1244310f5c0382 zh: 824b84077432b559 diff --git a/packages/client/ui-conversation/README.md b/packages/client/ui-conversation/README.md index 550dbcf281..6d0b228e8d 100644 --- a/packages/client/ui-conversation/README.md +++ b/packages/client/ui-conversation/README.md @@ -68,7 +68,7 @@ The composer measures its expanded control groups after size, content, visibilit The context meter follows the [statistics-control radius](../../../docs/ui-radius.md#radius-scale). -The composer skips automatic focus on mount, Session switching, and unlock for Bowser's UA classifications `mobile` and `tablet`, and for iPads reporting `MacIntel` with more than one touch point. Tapping the input still focuses it. Desktop devices, including Windows touchscreen computers, retain automatic focus regardless of window width. Browser modes or custom UA strings that conceal the mobile platform can prevent identification; a desktop UA alone cannot distinguish Android tablets from Linux computers. +The composer uses the shared [text-input focus policy](../ui-primitives/README.md#use-this-package) on mount, Session switching, and unlock. Identified phones and tablets require tapping the input; desktop devices retain automatic focus. The context-occupancy button shows a ring and percentage below the input card, after the Session statistics. Clicking it opens the token breakdown in a panel kept inside the viewport, including when no statistics are shown; the button stays hidden until context usage and capacity are available. diff --git a/packages/client/ui-conversation/README.zh.md b/packages/client/ui-conversation/README.zh.md index 38b8765f9b..4e417affd9 100644 --- a/packages/client/ui-conversation/README.zh.md +++ b/packages/client/ui-conversation/README.zh.md @@ -68,7 +68,7 @@ Queue 预览启用空白折叠和文档边缘 trim,保留 emoji,并使用 CS 上下文占用率入口遵循[统计控件圆角规则](../../../docs/ui-radius.zh.md#radius-scale)。 -对于 Bowser 从 UA 识别为 `mobile` 或 `tablet` 的设备,以及报告 `MacIntel` 且触摸点数大于一的 iPad,composer 会跳过挂载、切换 Session 和解除锁定时的自动聚焦。点击输入框仍会聚焦。桌面设备(包括 Windows 触屏电脑)保留自动聚焦,不受窗口宽度影响。隐藏移动平台信息的浏览器模式或自定义 UA 可能导致识别失败;仅凭桌面 UA 无法区分 Android 平板与 Linux 电脑。 +composer 在挂载、切换 Session 和解除锁定时使用共享的[文字输入框聚焦策略](../ui-primitives/README.zh.md#use-this-package)。识别出的手机和平板需要点击输入框;桌面设备保留自动聚焦。 上下文占用按钮在输入卡片下方、会话统计右侧显示圆环和百分比。点击按钮可在视口内的面板查看 token 构成,没有统计项时面板也不会越界;上下文用量和容量尚不可用时,按钮保持隐藏。 diff --git a/packages/client/ui-conversation/package.json b/packages/client/ui-conversation/package.json index f28213a34b..11a24a79f7 100644 --- a/packages/client/ui-conversation/package.json +++ b/packages/client/ui-conversation/package.json @@ -96,8 +96,7 @@ "@deepseek-ai/dsh-agent": "workspace:*", "@deepseek-ai/dsh-settings": "workspace:*", "@deepseek-ai/dsh-client-shortcuts": "workspace:*", - "@deepseek-ai/dsh-client-product-analytics": "workspace:*", - "bowser": "^2.14.1" + "@deepseek-ai/dsh-client-product-analytics": "workspace:*" }, "files": [ "locale/*.json", diff --git a/packages/client/ui-conversation/src/client/skeleton/InputBar.tsx b/packages/client/ui-conversation/src/client/skeleton/InputBar.tsx index e479d1364e..8faa94c784 100644 --- a/packages/client/ui-conversation/src/client/skeleton/InputBar.tsx +++ b/packages/client/ui-conversation/src/client/skeleton/InputBar.tsx @@ -16,9 +16,8 @@ import { memo, useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react' import type { ChangeEvent, KeyboardEvent, MouseEvent } from 'react' import clsx from 'clsx' -import bowser from 'bowser' import { - IconPlusOutlineMedium, IconWarningOutlineRegular, Toast, Tooltip, + IconPlusOutlineMedium, IconWarningOutlineRegular, shouldAutoFocusTextInput, Toast, Tooltip, } from '@deepseek-ai/dsh-client-ui-primitives' // Type-only: the `plan` projection key merge (the TodoDock posture — the // composer reads a host-computed value; the domain owns the key). @@ -173,15 +172,11 @@ export const InputBar = memo(function InputBar({ revealDraftSelection(scrollRef) } - // Phones and tablets require explicit composer focus. Desktop-mode iPads - // share the Mac platform identifier, so touch support also identifies them. // Automatic desktop focus restores and reveals the draft selection without // scrolling the conversation. useEffect(() => { if (locked || editor === null) return - const platformType = bowser.parse(navigator.userAgent).platform.type - const desktopIPad = navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1 - if (platformType === 'mobile' || platformType === 'tablet' || desktopIPad) return + if (!shouldAutoFocusTextInput()) return focusDraftEditor(editor, revealSelection) }, [locked, sessionId, editor]) diff --git a/packages/client/ui-model-selection/README.i18n.yaml b/packages/client/ui-model-selection/README.i18n.yaml index fc05dbc20d..342d716d15 100644 --- a/packages/client/ui-model-selection/README.i18n.yaml +++ b/packages/client/ui-model-selection/README.i18n.yaml @@ -15,11 +15,11 @@ en: d152484eb41ac6b4 zh: 09388d293f9be9cb /deepseek-ai-dsh-client-ui-model-selection/use-this-package: - en: ef50e68e7493d0a9 - zh: 3b1faea17b606173 + en: 7abb4deba3173c9c + zh: b76beffb3d9363db /deepseek-ai-dsh-client-ui-model-selection/use-this-package/model-and-effort: - en: 48f8157ffdfe6e69 - zh: 64ec9a533e2aa8f4 + en: 317641f416ba20c2 + zh: 4fe5bd48d24363e3 /deepseek-ai-dsh-client-ui-model-selection/use-this-package/model-label-extensions: en: bc47871cf8b61451 zh: 17d21da46604f071 diff --git a/packages/client/ui-model-selection/README.md b/packages/client/ui-model-selection/README.md index 5c181ca2ac..79fb8a2d5e 100644 --- a/packages/client/ui-model-selection/README.md +++ b/packages/client/ui-model-selection/README.md @@ -31,13 +31,13 @@ DeepSeek account and API-key routes appear as separate provider groups, each exp When no model is selected or the saved selection is absent from the catalog, the composer shows “Select model” in regular weight and hides the reasoning effort caption. Clicking it opens the model list directly; Escape and Shift+Tab close it. An empty catalog displays “No models available.” -Mount this plugin alongside `ui-conversation` and the commands package; the composer then shows the model seat next to the pending indicator, and `/model` opens the same directory as a popup. While the seat's menu is open, `↑`/`↓` move focus through root and effort rows, or move the model-list highlight without leaving search. Enter and Tab settle the highlighted model or focused row; Escape and `Shift+Tab` leave a drilled pane first and otherwise close back to the trigger. Drilling focuses model search when shown, otherwise the current model or effort row, and going back lands on the cell that opened the pane left. The composer shows the catalog name while the selected model is available. Removing a model or provider, including account sign-out, preserves the stored provider, model, and reasoning effort without displaying their IDs. Restoring the catalog entry restores its name and effort caption. +Mount this plugin alongside `ui-conversation` and the commands package; the composer then shows the model seat next to the pending indicator, and `/model` opens the same directory as a popup. While the seat's menu is open, `↑`/`↓` move focus through root and effort rows, or move the model-list highlight without leaving search. Enter and Tab settle the highlighted model or focused row; Escape and `Shift+Tab` leave a drilled pane first and otherwise close back to the trigger. On desktop devices, drilling focuses model search when shown, otherwise the current model or effort row, and going back focuses the cell that opened the pane. Mobile devices do not automatically focus the trigger or pane when opening or navigating the menu; tapping search or using keyboard navigation can focus search explicitly. The composer shows the catalog name while the selected model is available. Removing a model or provider, including account sign-out, preserves the stored provider, model, and reasoning effort without displaying their IDs. Restoring the catalog entry restores its name and effort caption. -Mouse selection uses native browser clicks, including their cancellation behavior; a press alone never selects. Opening the root menu focuses its trigger, and clicking the trigger again closes the menu and returns focus there. Root rows and the search-clear button show the same fill for keyboard focus and hover, without a native outline. Selecting a model or effort returns focus to the trigger without a focus ring; leaving the trigger or reopening the menu restores its normal focus indication. While a selection from either entry is pending, focus stays on the trigger, the trigger shows a spinner in place of its chevron, and each row whose value the selection carries shows one in place of its check; a rejected selection leaves the menu open. Tab returns to model search with the current model highlighted when search is shown, otherwise to the current row. +Mouse selection uses native browser clicks, including their cancellation behavior; a press alone never selects. On desktop devices, opening the root menu focuses its trigger, and clicking the trigger again closes the menu and returns focus there. Root rows and the search-clear button show the same fill for keyboard focus and hover, without a native outline. Selecting a model or effort returns focus to the trigger without a focus ring; leaving the trigger or reopening the menu restores its normal focus indication. While a selection from either entry is pending, focus stays on the trigger, the trigger shows a spinner in place of its chevron, and each row whose value the selection carries shows one in place of its check; a rejected selection leaves the menu open. Tab returns to model search with the current model highlighted when search is shown, otherwise to the current row. ### Model and effort -The button's model menu shows search only when its full catalog contains more than four models; smaller catalogs focus the current model or first row and support keyboard navigation directly. The `/model` command always keeps its search field. Both search fields match model names case-insensitively, including nonconsecutive characters in order; leading and trailing spaces are ignored. Within each provider, prefix matches come first, followed by alignment score and then catalog order. Empty groups are hidden. Empty catalogs and queries without matches are announced through a status region. Search keeps focus while arrow keys cycle the highlighted result across provider groups; Enter or Tab selects it. Left and right arrows keep their native caret behavior. Opening highlights the current model or the first available row, and editing the query resets the highlight to the first result. Reopening the model pane clears the query. +The button's model menu shows search only when its full catalog contains more than four models; smaller catalogs support keyboard navigation directly and automatically focus the current model or first row only on desktop devices. The `/model` command always keeps its search field. Both search fields match model names case-insensitively, including nonconsecutive characters in order; leading and trailing spaces are ignored. Within each provider, prefix matches come first, followed by alignment score and then catalog order. Empty groups are hidden. Empty catalogs and queries without matches are announced through a status region. Search keeps focus while arrow keys cycle the highlighted result across provider groups; Enter or Tab selects it. Left and right arrows keep their native caret behavior. Opening highlights the current model or the first available row, and editing the query resets the highlight to the first result. Reopening the model pane clears the query. Model and reasoning-effort names use weight 400 (regular) in the composer menu, including the selected item. The search field follows the command popup's compact treatment with transparent background and border in both palettes, with no leading icon and a caption-tone placeholder. The clear button appears for a nonempty query and restores the full list with focus in the search field. diff --git a/packages/client/ui-model-selection/README.zh.md b/packages/client/ui-model-selection/README.zh.md index 9755602564..e327d2e02a 100644 --- a/packages/client/ui-model-selection/README.zh.md +++ b/packages/client/ui-model-selection/README.zh.md @@ -31,13 +31,13 @@ DeepSeek 账号和 API Key 路由显示为独立提供方分组,各自展示 未选择模型或已保存的选择不在目录中时,composer 以常规字重显示“请选择模型”,并隐藏推理强度文案。点击后直接打开模型列表,Escape 和 Shift+Tab 关闭列表。目录为空时显示“暂无可用模型” -与 `ui-conversation` 及命令包一起挂载本插件;composer 随即在待处理指示器旁显示模型位,`/model` 则以弹窗打开同一份目录。模型位菜单打开期间,`↑`/`↓` 在根菜单和推理等级行间移动焦点,或在模型列表中移动高亮并让焦点保留在搜索框。Enter 和 Tab 选定高亮模型或聚焦行;Escape 与 `Shift+Tab` 先退出已下钻的面板,否则关闭并回到触发器。下钻时若显示模型搜索框则聚焦搜索框,否则聚焦当前模型或推理强度行,返回则落在打开该面板的格子上。所选模型可用时,composer 显示目录中的模型名称。模型或提供方被删除时(包括账号退登),保留已保存的提供方、模型和推理强度,但不展示其 ID。目录条目恢复后重新显示名称和推理强度。 +与 `ui-conversation` 及命令包一起挂载本插件;composer 随即在待处理指示器旁显示模型位,`/model` 则以弹窗打开同一份目录。模型位菜单打开期间,`↑`/`↓` 在根菜单和推理等级行间移动焦点,或在模型列表中移动高亮并让焦点保留在搜索框。Enter 和 Tab 选定高亮模型或聚焦行;Escape 与 `Shift+Tab` 先退出已下钻的面板,否则关闭并回到触发器。在桌面设备上,下钻时若显示模型搜索框则聚焦搜索框,否则聚焦当前模型或推理强度行,返回则聚焦打开该面板的格子。移动设备在打开菜单或切换面板时不会自动聚焦触发按钮或面板;主动点按搜索框或使用键盘导航可以聚焦搜索框。所选模型可用时,composer 显示目录中的模型名称。模型或提供方被删除时(包括账号退登),保留已保存的提供方、模型和推理强度,但不展示其 ID。目录条目恢复后重新显示名称和推理强度。 -鼠标选择沿用浏览器原生点击及其取消行为;仅按下按钮不会选定。打开根菜单时聚焦触发按钮,再次点击触发按钮会关闭菜单并把焦点还给它。根菜单行和搜索清除按钮的键盘焦点与悬停使用相同底色,不显示原生焦点轮廓。选定模型或推理等级后,焦点返回触发按钮但不显示焦点环;焦点离开按钮或重新打开菜单后恢复正常焦点提示。等待任一入口发起的选择结果时,焦点停在触发按钮,触发按钮以加载图标代替下拉箭头,该选择包含的值所在行以加载图标代替勾选标记;选择被拒绝后菜单保持打开。显示模型搜索框时,Tab 返回搜索框并高亮当前模型,否则返回当前选中行。 +鼠标选择沿用浏览器原生点击及其取消行为;仅按下按钮不会选定。在桌面设备上,打开根菜单时聚焦触发按钮,再次点击触发按钮会关闭菜单并把焦点还给它。根菜单行和搜索清除按钮的键盘焦点与悬停使用相同底色,不显示原生焦点轮廓。选定模型或推理等级后,焦点返回触发按钮但不显示焦点环;焦点离开按钮或重新打开菜单后恢复正常焦点提示。等待任一入口发起的选择结果时,焦点停在触发按钮,触发按钮以加载图标代替下拉箭头,该选择包含的值所在行以加载图标代替勾选标记;选择被拒绝后菜单保持打开。显示模型搜索框时,Tab 返回搜索框并高亮当前模型,否则返回当前选中行。 ### 模型与推理强度 -按钮模型菜单仅在完整目录超过四个模型时显示搜索框;较小目录聚焦当前模型或首行,直接支持键盘导航。`/model` 命令始终保留搜索框。两个搜索框均按模型名称进行不区分大小写的匹配,支持按顺序输入不连续字符,并忽略首尾空格。每个提供方内的结果优先按前缀匹配、其次按匹配得分、最后按目录顺序排列。没有匹配项的分组会隐藏。空目录和无匹配结果均通过状态区域通知屏幕阅读器。方向键在各提供方分组的结果间循环移动高亮,焦点保留在搜索框;Enter 或 Tab 选定高亮项。左右方向键仍用于移动输入光标。打开时高亮当前模型或首个可用选项,修改搜索内容后高亮首个结果。重新打开模型面板会清空搜索内容。 +按钮模型菜单仅在完整目录超过四个模型时显示搜索框;较小目录直接支持键盘导航,仅在桌面设备上自动聚焦当前模型或首行。`/model` 命令始终保留搜索框。两个搜索框均按模型名称进行不区分大小写的匹配,支持按顺序输入不连续字符,并忽略首尾空格。每个提供方内的结果优先按前缀匹配、其次按匹配得分、最后按目录顺序排列。没有匹配项的分组会隐藏。空目录和无匹配结果均通过状态区域通知屏幕阅读器。方向键在各提供方分组的结果间循环移动高亮,焦点保留在搜索框;Enter 或 Tab 选定高亮项。左右方向键仍用于移动输入光标。打开时高亮当前模型或首个可用选项,修改搜索内容后高亮首个结果。重新打开模型面板会清空搜索内容。 composer 菜单中的模型名称和推理等级均使用 400(regular)字重,包括选中项。搜索框沿用 command 弹窗的紧凑样式,在浅/深色主题下均保持背景和边框透明,不显示前置图标,占位文字使用 caption 色。搜索内容非空时显示清除按钮;点击后恢复完整列表,并将焦点留在搜索框。 diff --git a/packages/client/ui-model-selection/src/client/ModelSelect.tsx b/packages/client/ui-model-selection/src/client/ModelSelect.tsx index c497bcbe77..9469c72085 100644 --- a/packages/client/ui-model-selection/src/client/ModelSelect.tsx +++ b/packages/client/ui-model-selection/src/client/ModelSelect.tsx @@ -12,7 +12,9 @@ * search field. Provider headings paint their background only while pinned * by scrolling. Clearing a query restores the full list and search focus. * Selecting restores trigger focus without a ring until the trigger loses focus - * or the menu reopens. Model names match a case-insensitive ordered subsequence + * or the menu reopens. Mobile devices do not automatically focus the + * trigger or a pane when opening or drilling, so search does not raise the keyboard. + * Model names match a case-insensitive ordered subsequence * within each provider group, ranked by * prefix, alignment score, then catalog order. Returning to the root pane * hands focus back to the cell that opened it. Data and submission ride the @@ -35,7 +37,7 @@ import clsx from 'clsx' import type { ModelReasoningEffort, ModelSelection } from '@deepseek-ai/dsh-api-remotes/client' import { IconCheckOutlineRegular, IconChevronDownOutlineRegular, IconChevronRightOutlineRegular, IconCloseFillRegular, - IconDataOutlineRegular, IconWarningOutlineRegular, Input, rankByName, StateDot, Toast, + IconDataOutlineRegular, IconWarningOutlineRegular, Input, rankByName, shouldAutoFocusTextInput, StateDot, Toast, } from '@deepseek-ai/dsh-client-ui-primitives' import type { PropsLocale, PropsRenderSlots, PropsRuntime } from '@deepseek-ai/dsh-client-ui-slots' import type { ModelLabelOwner, ModelSelectInjected } from './slots.ts' @@ -182,7 +184,7 @@ export function ModelSelect( previousShowSearch.current = showSearch const intent = paneFocus.current ?? (changedSearchMode && pane === 'model' ? 'drill' : null) paneFocus.current = null - if (!open || intent === null) return + if (!open || intent === null || !shouldAutoFocusTextInput()) return if (intent === 'drill') { if (pane === 'model' && showSearch) { searchRef.current?.focus() @@ -249,7 +251,7 @@ export function ModelSelect( const show = (): void => { setSelectionFocus(false) - triggerRef.current?.focus() + if (shouldAutoFocusTextInput()) triggerRef.current?.focus() setQuery('') setHighlightedIndex(null) if (currentChoice === undefined) paneFocus.current = 'drill' diff --git a/packages/client/ui-primitives/README.i18n.yaml b/packages/client/ui-primitives/README.i18n.yaml index 92dcd1dcd0..c522c7d9a3 100644 --- a/packages/client/ui-primitives/README.i18n.yaml +++ b/packages/client/ui-primitives/README.i18n.yaml @@ -15,8 +15,8 @@ en: d152484eb41ac6b4 zh: 09388d293f9be9cb /deepseek-ai-dsh-client-ui-primitives/use-this-package: - en: 7bae72c97d0449f5 - zh: 4589ecc2b216edc5 + en: ca1f7a50db82a513 + zh: 6dbd3cbb1c2ac46d /deepseek-ai-dsh-client-ui-primitives/use-this-package/component-catalog: en: 03388f40dc593990 zh: 5f1541a6e20c8cfe diff --git a/packages/client/ui-primitives/README.md b/packages/client/ui-primitives/README.md index 803cce60c0..a7c2920885 100644 --- a/packages/client/ui-primitives/README.md +++ b/packages/client/ui-primitives/README.md @@ -27,6 +27,8 @@ Use `dsh-client-ui-primitives` to build web-client controls and render agent out `Toast` uses the theme’s toast background and label colors in both light and dark modes. `Menu` data rows and `MenuItemButton` component rows accept owner-provided effective shortcuts and align their keys at the trailing edge as muted text without a background, including submenus. `ShortcutKeys` defaults to unboxed keys for menu and inline hints. Its `tooltip` variant uses lighter keycaps over the dark bubble and groups plus-separated combinations into one filled block. `Tooltip.shortcutKeys` vertically centers keycaps beside optional localized action text, or shows only keys when the label is empty. The optional `className` supplies owner interaction styles. `Modal` uses the frame’s shared overlay inset, with a minimum 24px viewport margin. Its mask leaves the Windows caption unpainted while the full-viewport layer blocks background clicks. `Modal` and the settings shell share top-layer Escape and Tab handling through `useModalLayer`, restoring the previous focus on close. `closeTopModal(document)` requests the foreground modal’s current close action; newer menus or unregistered dialogs block dismissal of the modal behind them. Components use `isBehindModal` to avoid moving focus behind a nested dialog. Menus consume their local Escape before modal dismissal. `observeComposition` supplies the same composition-end and legacy IME guard to local modal and recording handlers; callers dispose its document listeners with their interaction lifetime. +`shouldAutoFocusTextInput()` controls automatic text-input focus for the composer and command popups. It returns false for Bowser's UA classifications `mobile` and `tablet`, and for iPads reporting `MacIntel` with more than one touch point. Other devices, including Windows touchscreen computers, retain automatic focus regardless of window width. User-requested focus remains available. Browser modes or custom UA strings that conceal the mobile platform can prevent identification; unrecognized UAs permit automatic focus. A desktop UA alone cannot distinguish Android tablets from Linux computers. + Automatic modal entry and modal/menu return focus, including after Escape and application close shortcuts, use `focusWithoutRing(element, options?)` to suppress the outline until Tab or directional navigation resumes normal focus styling. Dialog containers keep their outline-free styling. Existing borders, shadows, and error states remain intact. Mark a dialog's initial control with `data-modal-autofocus` so the modal captures its invoking control before moving focus. Controls mounted with the dialog must not use React `autoFocus`, which runs before that capture. Tab and Shift+Tab from the dialog container enter its first and last focusable controls. This package is a Web-shell build input. Its static ESM retains third-party imports and styles for Vite; independent consumers supply its development dependencies ([dependency rules](../AGENTS.md#dependency-declaration)). diff --git a/packages/client/ui-primitives/README.zh.md b/packages/client/ui-primitives/README.zh.md index a87598a306..f6adf22e6f 100644 --- a/packages/client/ui-primitives/README.zh.md +++ b/packages/client/ui-primitives/README.zh.md @@ -27,6 +27,8 @@ kind: "package-library" `Toast` 在浅色和深色模式下均使用主题的系统提示背景与文字颜色。`Menu` 数据条目与 `MenuItemButton` 组件条目接收功能 owner 提供的有效快捷键,并在末端以无背景的浅灰色文字对齐显示,子菜单也采用同一呈现。`ShortcutKeys` 默认以无方块的按键文字显示菜单和行内提示。`tooltip` 变体在深色气泡上使用稍浅的键帽,以加号连接的组合则共用一个填充色块。`Tooltip.shortcutKeys` 将键帽与可选的本地化操作文本垂直居中排列,标签为空时只显示按键。可选的 `className` 供调用方设置交互状态样式。`Modal` 使用框架共享的浮层起点,视口边距至少为 24px。其遮罩不绘制 Windows 顶栏区域,覆盖整个视口的模态层仍阻挡背景点击。`Modal` 与设置外壳通过 `useModalLayer` 共用顶层 Esc 和 Tab 处理,关闭时恢复先前焦点。`closeTopModal(document)` 请求前台弹窗当前的关闭操作;上层菜单或未注册的对话框会阻止关闭其后方弹窗。组件通过 `isBehindModal` 避免将焦点移到嵌套弹窗后方。菜单先消费自己的 Esc,再由模态层处理关闭。 `observeComposition` 为局部弹层和录键处理提供相同的 composition-end 与旧版 IME 保护;调用方随交互生命周期释放其 document 监听。 +`shouldAutoFocusTextInput()` 控制 composer 和命令弹窗中文字输入框的自动聚焦。对于 Bowser 从 UA 识别为 `mobile` 或 `tablet` 的设备,以及报告 `MacIntel` 且触摸点数大于一的 iPad,该函数返回 false。其他设备(包括 Windows 触屏电脑)保留自动聚焦,不受窗口宽度影响。用户主动请求的聚焦仍然可用。隐藏移动平台信息的浏览器模式或自定义 UA 可能导致识别失败;未识别的 UA 允许自动聚焦。仅凭桌面 UA 无法区分 Android 平板与 Linux 电脑。 + 弹窗自动进入及弹窗、菜单回焦,包括通过 Esc 和应用关闭快捷键触发的回焦,均使用 `focusWithoutRing(element, options?)`,在 Tab 或方向键导航恢复正常焦点样式前抑制外轮廓线。弹窗容器仍不绘制焦点外框。原有边框、阴影和错误状态保持不变。用 `data-modal-autofocus` 标记弹窗的初始控件,让模态层先保存触发控件,再移动焦点。随弹窗挂载的控件不得使用 React `autoFocus`,因为它会在保存触发控件前执行。弹窗容器获得焦点时,Tab 和 Shift+Tab 分别进入第一个和最后一个可聚焦控件。 本包是 Web 壳的构建输入。静态 ESM 为 Vite 保留第三方导入和样式;独立消费方自行提供开发依赖([依赖规则](../AGENTS.md#dependency-declaration))。 diff --git a/packages/client/ui-primitives/package.json b/packages/client/ui-primitives/package.json index 09dd9df339..19be8cd0be 100644 --- a/packages/client/ui-primitives/package.json +++ b/packages/client/ui-primitives/package.json @@ -48,7 +48,8 @@ "mdast-util-math": "^3.0.0", "micromark-extension-gfm": "^3.0.0", "micromark-util-sanitize-uri": "^2.0.1", - "simple-icons": "16.31.0" + "simple-icons": "16.31.0", + "bowser": "^2.14.1" }, "files": [ "lib/index.js", diff --git a/packages/client/ui-primitives/src/focus.ts b/packages/client/ui-primitives/src/focus.ts index bc7e5a372a..b013665ff8 100644 --- a/packages/client/ui-primitives/src/focus.ts +++ b/packages/client/ui-primitives/src/focus.ts @@ -1,7 +1,20 @@ -/** Focus presentation for automatic entry and restoration. */ +/** Focus policy and presentation for automatic entry and restoration. */ +import bowser from 'bowser' const releases = new WeakMap void>() const navigationKeys = new Set(['Tab', 'ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight', 'Home', 'End']) +/** + * Decide whether the current browser device permits automatic text-input focus. + * Bowser identifies phones and tablets from the UA; MacIntel with multiple touch points identifies desktop-mode iPads. + * This policy does not restrict focus requested by a user gesture or keyboard navigation. + * @returns false for identified phones and tablets; true for other devices, including unrecognized UAs. + */ +export function shouldAutoFocusTextInput(): boolean { + const platformType = bowser.parse(navigator.userAgent).platform.type + const desktopIPad = navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1 + return platformType !== 'mobile' && platformType !== 'tablet' && !desktopIPad +} + /** * Focus an automatic destination without a focus outline until keyboard navigation or blur. * The theme suppresses outlines while data-dsh-automatic-focus is present; borders and shadows remain intact. diff --git a/packages/client/ui-primitives/src/index.ts b/packages/client/ui-primitives/src/index.ts index 1083cf6827..d2abf8e22f 100644 --- a/packages/client/ui-primitives/src/index.ts +++ b/packages/client/ui-primitives/src/index.ts @@ -36,7 +36,7 @@ export { HoverCard } from './HoverCard.tsx' export { HoverCardGroup } from './HoverCardGroup.tsx' export { ShortcutKeys } from './ShortcutKeys.tsx' export { observeComposition } from './keyboard-composition.ts' -export { focusWithoutRing } from './focus.ts' +export { focusWithoutRing, shouldAutoFocusTextInput } from './focus.ts' export { closeTopModal, isBehindModal, modalSelector, useModalLayer } from './useModalLayer.ts' export { Modal } from './Modal.tsx' export { RiskConfirmation } from './RiskConfirmation.tsx' diff --git a/packages/client/ui-schedule/README.i18n.yaml b/packages/client/ui-schedule/README.i18n.yaml index 8a2a17dc02..2c8ab8c27a 100644 --- a/packages/client/ui-schedule/README.i18n.yaml +++ b/packages/client/ui-schedule/README.i18n.yaml @@ -15,8 +15,8 @@ en: d152484eb41ac6b4 zh: 405b30feaf48c087 /deepseek-ai-dsh-client-ui-schedule/use-this-package: - en: 7d44cd1640bebfad - zh: 1d6b6c28a3c27115 + en: 39d20eefa79b882b + zh: 336c03080e222a86 /deepseek-ai-dsh-client-ui-schedule/use-this-package/time-zone-data-source: en: 6bd6882dbbbefcb0 zh: 03aa15f1a65d13dc diff --git a/packages/client/ui-schedule/README.md b/packages/client/ui-schedule/README.md index 6f02ed050a..f9240f65ec 100644 --- a/packages/client/ui-schedule/README.md +++ b/packages/client/ui-schedule/README.md @@ -31,7 +31,7 @@ The page header keeps the title at its natural width and moves New to another li Selecting a task from the list opens Rules; refreshing that task preserves the selected tab. Rules edits an active task's name, instruction, and run time; the edits stay in a local draft until saved, and inactive tasks remain read-only. Unmodified Left/Right arrows cycle the tabs, Home/End select the first/last tab, and keyboard focus follows the selection. The tabs do not consume these keys with Alt, Ctrl, Meta, or Shift. The linked-Session control in the detail tab strip stays available on the Rules tab, and confirmed deletion is available from either view. -Rules shows the rule in a Run time card whose rows edit a local draft: Repeat is a menu of Weekly, Monday to Friday, Every day, Every N hours, Every N minutes, Every N seconds, Once, and Custom (cron), a weekly rule adds a Weekday row, a fixed-rate choice edits only the interval quantity in the unit it names, a one-shot rule edits separate Date and Time rows, and Custom (cron) edits one Cron expression row holding a five-field expression, interpreted in the selected time zone. The card parses that expression in the browser and, under the row, shows a localized sentence describing it; an expression the Host would reject shows the localized validation message in place of that sentence and blocks Save. A stored weekly rule whose weekday set is exactly Monday through Friday selects the Monday to Friday choice. The Date row is a read-only trigger showing the staged date as `YYYY/MM/DD` and opening a month calendar with localized weekday headings, month navigation, and a marked today; the draft and the submitted text keep the ISO form; the Time row is a read-only trigger showing one 24-hour clock and opening three scrolling columns of hours, minutes, and seconds with the staged value marked and scrolled into view. A calendar or clock pick stages the draft under the same staged save as every other row, arrow keys walk the open column or grid, Enter stages the marked value, Escape closes the panel and returns focus to its row, and a disabled row cannot open one. Clock rows show whole seconds, an untouched row keeps a stored millisecond value for its submit, and editing a time submits whole-second precision. Time zone is a searchable, height-bounded menu. An unlabeled top block keeps the five most recently selected exact zones in browser-local storage; first use seeds the actual system zone and UTC rather than inferring a location from UI language. The system zone is marked, and the remaining inventory is ordered by current UTC offset and canonical IANA id. Each visible label puts `UTC±HH:MM` before the localized zone name; canonical ids stay internal but remain searchable. Zones that ICU renders with the same offset and localized name share one visible row; every grouped id remains searchable, and an already stored id remains selected instead of being rewritten. The inventory comes from `Intl.supportedValuesOf('timeZone')`, and names come from `Intl.DateTimeFormat(..., { timeZoneName: 'longGeneric' })`: both are browser ICU/CLDR data, not a scraped or product-maintained translation table. There is therefore no crawler or generated zone-name resource to refresh. A third-party locale supplies its ordinary `time.locale` value and automatically receives the corresponding ICU names; only the selector's surrounding UI copy needs translation. When the runtime cannot enumerate zones, a short identifier fallback is offered, and a stored zone outside the offered set is kept. Daily, Weekly, and Cron keep their stored rule and IANA zone, and each frequency line names the zone only when it differs from the host's system zone. A one-shot After/At seeds the date and time from the record's stored zone, or this device's zone when the record stores none, so the seeded clock names the stored instant; changing that zone keeps the entered clock values and changes the instant. A kind the card seeds on selection uses the committed occurrence's clock and the choice's zone, which is the record's stored zone or this device's zone, a seeded weekly rule starts from that occurrence's weekday in that zone, and a seeded cron rule states that occurrence's clock as a daily expression. Every accepts at least 60 whole seconds, independent of time zones. One Save submits the complete expected record with the staged change and preserves the id, original Session, latest receipt, and saved history; [Schedule](../../schedule/schedule/README.md#use-this-package) defines future-target selection, reanchoring, and unchanged-rule no-ops. +Rules shows the rule in a Run time card whose rows edit a local draft: Repeat is a menu of Weekly, Monday to Friday, Every day, Every N hours, Every N minutes, Every N seconds, Once, and Custom (cron), a weekly rule adds a Weekday row, a fixed-rate choice edits only the interval quantity in the unit it names, a one-shot rule edits separate Date and Time rows, and Custom (cron) edits one Cron expression row holding a five-field expression, interpreted in the selected time zone. The card parses that expression in the browser and, under the row, shows a localized sentence describing it; an expression the Host would reject shows the localized validation message in place of that sentence and blocks Save. A stored weekly rule whose weekday set is exactly Monday through Friday selects the Monday to Friday choice. The Date row is a read-only trigger showing the staged date as `YYYY/MM/DD` and opening a month calendar with localized weekday headings, month navigation, and a marked today; the draft and the submitted text keep the ISO form; the Time row is a read-only trigger showing one 24-hour clock and opening three scrolling columns of hours, minutes, and seconds with the staged value marked and scrolled into view. A calendar or clock pick stages the draft under the same staged save as every other row, arrow keys walk the open column or grid, Enter stages the marked value, Escape closes the panel and returns focus to its row, and a disabled row cannot open one. Clock rows show whole seconds, an untouched row keeps a stored millisecond value for its submit, and editing a time submits whole-second precision. Time zone is a searchable, height-bounded menu. Its search field takes focus automatically on desktop; phones and tablets require explicit focus. An unlabeled top block keeps the five most recently selected exact zones in browser-local storage; first use seeds the actual system zone and UTC rather than inferring a location from UI language. The system zone is marked, and the remaining inventory is ordered by current UTC offset and canonical IANA id. Each visible label puts `UTC±HH:MM` before the localized zone name; canonical ids stay internal but remain searchable. Zones that ICU renders with the same offset and localized name share one visible row; every grouped id remains searchable, and an already stored id remains selected instead of being rewritten. The inventory comes from `Intl.supportedValuesOf('timeZone')`, and names come from `Intl.DateTimeFormat(..., { timeZoneName: 'longGeneric' })`: both are browser ICU/CLDR data, not a scraped or product-maintained translation table. There is therefore no crawler or generated zone-name resource to refresh. A third-party locale supplies its ordinary `time.locale` value and automatically receives the corresponding ICU names; only the selector's surrounding UI copy needs translation. When the runtime cannot enumerate zones, a short identifier fallback is offered, and a stored zone outside the offered set is kept. Daily, Weekly, and Cron keep their stored rule and IANA zone, and each frequency line names the zone only when it differs from the host's system zone. A one-shot After/At seeds the date and time from the record's stored zone, or this device's zone when the record stores none, so the seeded clock names the stored instant; changing that zone keeps the entered clock values and changes the instant. A kind the card seeds on selection uses the committed occurrence's clock and the choice's zone, which is the record's stored zone or this device's zone, a seeded weekly rule starts from that occurrence's weekday in that zone, and a seeded cron rule states that occurrence's clock as a daily expression. Every accepts at least 60 whole seconds, independent of time zones. One Save submits the complete expected record with the staged change and preserves the id, original Session, latest receipt, and saved history; [Schedule](../../schedule/schedule/README.md#use-this-package) defines future-target selection, reanchoring, and unchanged-rule no-ops. The rows are disabled while a save is in flight, while the catalog is loading, during a deletion, and for an inactive task. A save bar appears only while the local draft differs from the stored task: it shows Unsaved changes with Cancel and Save changes, and Save changes becomes Saving… while the save is in flight. Cancel restores the stored values. A catalog refresh becomes the shown values only while the draft has no unsaved edit, so an unsaved draft survives an authoritative refresh. A failed save keeps the draft and shows a localized message; after a conflict, retry against the refreshed record. If the task disappears from the catalog, Delete is disabled until the task returns. A successful update refreshes the authoritative catalog. A rejected or unconfirmed update is distinct from a catalog-read failure: Retry reloads the catalog without presenting the update as failed. If the update itself cannot be confirmed, check the task before retrying. Late responses after switching tasks or closing details do not replace the current view, and no failure rolls back a Host write already begun. diff --git a/packages/client/ui-schedule/README.zh.md b/packages/client/ui-schedule/README.zh.md index b7de6727ed..2035639ceb 100644 --- a/packages/client/ui-schedule/README.zh.md +++ b/packages/client/ui-schedule/README.zh.md @@ -31,7 +31,7 @@ kind: "package-reference" 从列表选择任务时默认打开“规则”;刷新同一任务会保留当前页签。活动任务的“规则”修改名称、指令和运行时间;这些修改保留在本地草稿中直到保存,未运行任务保持只读。不带修饰键的左右方向键循环切换页签,Home/End 选择第一个/最后一个页签,键盘焦点随选择移动。页签不会拦截这些键与 Alt、Ctrl、Meta 或 Shift 的组合。共用的会话入口位于详情页签条内,在“规则”页签可见;确认删除操作在两种页签下都可用。 -“规则”在“运行时间”卡片中以行编辑本地草稿:“重复”是含每周、周一至周五、每天、每 N 小时、每 N 分钟、每 N 秒、仅一次和自定义(cron)的菜单,每周规则增加“星期”行,固定速率选项只修改它所属单位的间隔数量,一次性规则用独立的“日期”和“时间”两行编辑目标,自定义(cron)用一行“Cron 表达式”编辑按所选时区解释的 5 字段表达式。卡片在浏览器中解析该表达式,并在该行下方显示描述它的本地化语句;Host 会拒绝的表达式改为显示本地化校验信息,并在解析通过前阻止保存。已存储的每周规则若星期集合恰好为周一至周五,则选中“周一至周五”选项。“日期”行是只读触发器,以 `YYYY/MM/DD` 显示暂存的日期并展开带本地化星期表头、月份切换和今天标记的月历;草稿与提交文本保持 ISO 形态;“时间”行是只读触发器,显示统一的 24 小时时钟,并展开时、分、秒三列可滚动列表,当前值高亮并在打开时滚动到可见。在月历或时钟上点选即按与其他行相同的分阶段保存写入草稿;方向键在打开的列或网格内移动,Enter 选定当前值,Escape 关闭面板并把焦点还给所在行,被禁用的行无法打开面板。时钟行显示到秒,未改动的行在提交时保留已存储的毫秒值,编辑时间时按整秒精度提交。“时区”使用高度受限的可搜索菜单。顶部无标题区域保留浏览器本地最近选过的 5 个准确时区;首次使用按真实系统时区和 UTC 初始化,而不根据界面语言猜测所在地。系统时区带有标记,其余清单按当前 UTC 偏移、再按规范 IANA 标识排序。可见文案把 `UTC±HH:MM` 放在本地化时区名称之前;IANA 标识仅在内部使用,但可用于搜索。ICU 显示成相同偏移和本地化名称的多个时区只占一行;所有被合并的标识仍可用于搜索,任务已保存的标识也会继续作为选中值,不会被改写。时区清单来自 `Intl.supportedValuesOf('timeZone')`,名称来自 `Intl.DateTimeFormat(..., { timeZoneName: 'longGeneric' })`:两者都是浏览器内置的 ICU/CLDR 数据,不是抓取或产品自维护的翻译表。因此没有需要刷新的爬虫或生成时区资源;第三方语言包只需提供常规的 `time.locale` 值,即可自动获得对应的 ICU 名称,仅需翻译选择器周边的 UI 文案。运行时无法枚举时改用简短的标识候选列表,已存储但不在其中的时区会保留。每天、每周和 cron 保留各自已存储的规则与时区,其频率行仅在时区与宿主系统时区不同时标出时区。一次性 After/At 以记录已存储的时区初始化日期和时间;记录未保存时区时取本设备时区,初始钟表值在该时区下仍表示同一瞬时;更改时区会保留输入的钟表值并改变时点。因选择种类而重新初始化的种类使用已提交发生时点的钟表值和该选项的时区,该时区取记录已存储的时区或本设备时区:每周的星期取自该发生时点在该时区下的星期,cron 则把该发生时点的钟表值写成每天执行的表达式。固定间隔至少为 60 整秒,不受时区影响。一次保存以分阶段的变更提交完整预期记录,并保留 id、原会话、最近一次回执及已保存历史;未来目标选择、重新确定起算时间和未变更规则的无写入语义见 [Schedule](../../schedule/schedule/README.zh.md#use-this-package)。 +“规则”在“运行时间”卡片中以行编辑本地草稿:“重复”是含每周、周一至周五、每天、每 N 小时、每 N 分钟、每 N 秒、仅一次和自定义(cron)的菜单,每周规则增加“星期”行,固定速率选项只修改它所属单位的间隔数量,一次性规则用独立的“日期”和“时间”两行编辑目标,自定义(cron)用一行“Cron 表达式”编辑按所选时区解释的 5 字段表达式。卡片在浏览器中解析该表达式,并在该行下方显示描述它的本地化语句;Host 会拒绝的表达式改为显示本地化校验信息,并在解析通过前阻止保存。已存储的每周规则若星期集合恰好为周一至周五,则选中“周一至周五”选项。“日期”行是只读触发器,以 `YYYY/MM/DD` 显示暂存的日期并展开带本地化星期表头、月份切换和今天标记的月历;草稿与提交文本保持 ISO 形态;“时间”行是只读触发器,显示统一的 24 小时时钟,并展开时、分、秒三列可滚动列表,当前值高亮并在打开时滚动到可见。在月历或时钟上点选即按与其他行相同的分阶段保存写入草稿;方向键在打开的列或网格内移动,Enter 选定当前值,Escape 关闭面板并把焦点还给所在行,被禁用的行无法打开面板。时钟行显示到秒,未改动的行在提交时保留已存储的毫秒值,编辑时间时按整秒精度提交。“时区”使用高度受限的可搜索菜单。桌面端打开时自动聚焦搜索框;手机和平板需要手动聚焦。顶部无标题区域保留浏览器本地最近选过的 5 个准确时区;首次使用按真实系统时区和 UTC 初始化,而不根据界面语言猜测所在地。系统时区带有标记,其余清单按当前 UTC 偏移、再按规范 IANA 标识排序。可见文案把 `UTC±HH:MM` 放在本地化时区名称之前;IANA 标识仅在内部使用,但可用于搜索。ICU 显示成相同偏移和本地化名称的多个时区只占一行;所有被合并的标识仍可用于搜索,任务已保存的标识也会继续作为选中值,不会被改写。时区清单来自 `Intl.supportedValuesOf('timeZone')`,名称来自 `Intl.DateTimeFormat(..., { timeZoneName: 'longGeneric' })`:两者都是浏览器内置的 ICU/CLDR 数据,不是抓取或产品自维护的翻译表。因此没有需要刷新的爬虫或生成时区资源;第三方语言包只需提供常规的 `time.locale` 值,即可自动获得对应的 ICU 名称,仅需翻译选择器周边的 UI 文案。运行时无法枚举时改用简短的标识候选列表,已存储但不在其中的时区会保留。每天、每周和 cron 保留各自已存储的规则与时区,其频率行仅在时区与宿主系统时区不同时标出时区。一次性 After/At 以记录已存储的时区初始化日期和时间;记录未保存时区时取本设备时区,初始钟表值在该时区下仍表示同一瞬时;更改时区会保留输入的钟表值并改变时点。因选择种类而重新初始化的种类使用已提交发生时点的钟表值和该选项的时区,该时区取记录已存储的时区或本设备时区:每周的星期取自该发生时点在该时区下的星期,cron 则把该发生时点的钟表值写成每天执行的表达式。固定间隔至少为 60 整秒,不受时区影响。一次保存以分阶段的变更提交完整预期记录,并保留 id、原会话、最近一次回执及已保存历史;未来目标选择、重新确定起算时间和未变更规则的无写入语义见 [Schedule](../../schedule/schedule/README.zh.md#use-this-package)。 行在保存进行中、目录加载中、删除期间以及任务未运行时禁用。仅当本地草稿与已存储任务不同时才出现保存栏:显示“有未保存的修改”及“取消”和“保存修改”,保存期间“保存修改”变为“保存中…”。“取消”恢复已存储的值。仅当草稿没有未保存修改时,目录刷新才会成为显示值,因此未保存的草稿会保留到权威刷新之后。保存失败保留草稿并显示本地化提示;冲突后针对刷新后的记录重试。任务从目录消失时,“删除”会禁用,直到任务重新出现。更新成功后刷新权威目录。更新被拒绝或无法确认与目录读取失败相互区分:“重试”重新加载目录,不将该更新显示为失败。若更新本身无法确认,应在重试前检查任务。切换任务或关闭详情后才到达的响应不会替换当前视图,任何失败都不会回滚宿主已开始的写入。 diff --git a/packages/client/ui-schedule/src/client/TaskMenu.tsx b/packages/client/ui-schedule/src/client/TaskMenu.tsx index 458712d6b3..d0c39d0942 100644 --- a/packages/client/ui-schedule/src/client/TaskMenu.tsx +++ b/packages/client/ui-schedule/src/client/TaskMenu.tsx @@ -11,7 +11,7 @@ import type { CSSProperties, ReactNode } from 'react' import { createPortal } from 'react-dom' import clsx from 'clsx' import { - IconCheckOutlineRegular, useAnchoredPosition, useDismissOnOutsidePointer, + IconCheckOutlineRegular, shouldAutoFocusTextInput, useAnchoredPosition, useDismissOnOutsidePointer, } from '@deepseek-ai/dsh-client-ui-primitives' import css from './TaskMenu.module.css' @@ -114,8 +114,9 @@ function isLabel(entry: TaskMenuEntry): entry is TaskMenuLabel { * @param props.portal - render the list into document.body, fixed-positioned * from the anchor rect (follows scroll and resize while open). * @param props.header - owner content pinned above the scrolling rows; a control - * it marks `data-menu-field` takes the keyboard once the list is placed, which - * is the frame a portaled list becomes focusable in. + * it marks `data-menu-field` takes the keyboard on desktop once the list is placed, + * which is the frame a portaled list becomes focusable in. Phones and tablets + * require explicit field focus. * @param props.className - extra class on the anchor wrapper span. * @param props.listClassName - extra class on the dropdown card itself. * @returns the anchor wrapper with the conditional list. @@ -175,7 +176,7 @@ export function TaskMenu({ open, anchor, items = [], selectedId, onSelect, onClo handedOver.current = false return } - if (handedOver.current) return + if (handedOver.current || !shouldAutoFocusTextInput()) return const list = listRef.current /* v8 ignore next -- the list is rendered in the same commit that sets `open`, before this effect runs. */ if (list === null) return diff --git a/packages/client/ui-schedule/tests/task-menu.client.spec.tsx b/packages/client/ui-schedule/tests/task-menu.client.spec.tsx index f93c36c838..f503d6a04e 100644 --- a/packages/client/ui-schedule/tests/task-menu.client.spec.tsx +++ b/packages/client/ui-schedule/tests/task-menu.client.spec.tsx @@ -6,7 +6,7 @@ */ import { useState } from 'react' import { act, cleanup, fireEvent, render, screen, within } from '@testing-library/react' -import { afterEach, describe, expect, it, vi } from 'vitest' +import { afterEach, describe, expect, it, onTestFinished, vi } from 'vitest' import { TaskMenu } from '../src/client/TaskMenu.tsx' import type { TaskMenuEntry } from '../src/client/TaskMenu.tsx' import taskMenuCss from '../src/client/TaskMenu.module.css' @@ -142,6 +142,44 @@ describe('TaskMenu', () => { expect(document.activeElement).toBe(screen.getByRole('textbox', { name: 'Filter' })) }) + it.each([ + { name: 'iPhone', userAgent: 'Mozilla/5.0 (iPhone; CPU iPhone OS 18_6 like Mac OS X) AppleWebKit/605.1.15 Version/18.6 Mobile/15E148 Safari/604.1', platform: 'iPhone', maxTouchPoints: 5 }, + { name: 'Android tablet', userAgent: 'Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 Chrome/119.0.0.0 Safari/537.36', platform: 'Linux armv8l', maxTouchPoints: 5 }, + { name: 'desktop-mode iPad', userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 Version/18.6 Safari/605.1.15', platform: 'MacIntel', maxTouchPoints: 5 }, + ])('leaves header search focus to the user on $name', ({ userAgent, platform, maxTouchPoints }) => { + for (const [name, value] of Object.entries({ userAgent, platform, maxTouchPoints })) { + const descriptor = Object.getOwnPropertyDescriptor(navigator, name) + Object.defineProperty(navigator, name, { configurable: true, value }) + onTestFinished(() => { + if (descriptor === undefined) Reflect.deleteProperty(navigator, name) + else Object.defineProperty(navigator, name, descriptor) + }) + } + const menu = (open: boolean) => trigger} + header={} + items={ITEMS} + onSelect={() => {}} + onClose={() => {}} + /> + const { rerender } = render(menu(false)) + const trigger = screen.getByRole('button', { name: 'trigger' }) + trigger.focus() + rerender(menu(true)) + const field = screen.getByRole('textbox', { name: 'Filter' }) + expect(document.activeElement).toBe(trigger) + field.focus() + expect(document.activeElement).toBe(field) + fireEvent.keyDown(field, { key: 'ArrowDown' }) + expect(document.activeElement).toBe(screen.getByRole('menuitem', { name: 'Alpha' })) + rerender(menu(false)) + trigger.focus() + rerender(menu(true)) + expect(document.activeElement).toBe(trigger) + }) + it('keeps the keyboard on the row when a placed portal list repositions', () => { render( Date: Thu, 15 Oct 2026 17:31:49 +0800 Subject: [PATCH 03/12] fix(client): preserve composer position above mobile keyboards Patch Lexical viewport coordinates and cover keyboard panning in editor and browser regressions. Update the patch disclosure. --- THIRD_PARTY_NOTICES.md | 2 + apps/web/tests/composer-focus.e2e.ts | 54 ++++++++++++++ .../expected/composer-focus/focus.expected.md | 4 ++ .../client/ui-conversation/README.i18n.yaml | 4 +- packages/client/ui-conversation/README.md | 2 +- packages/client/ui-conversation/README.zh.md | 2 +- .../tests/editor-viewport.client.spec.ts | 72 +++++++++++++++++++ patches/lexical@0.49.0.patch | 58 +++++++++++++++ pnpm-lock.yaml | 27 +++---- pnpm-workspace.yaml | 1 + 10 files changed, 209 insertions(+), 17 deletions(-) create mode 100644 packages/client/ui-conversation/tests/editor-viewport.client.spec.ts create mode 100644 patches/lexical@0.49.0.patch diff --git a/THIRD_PARTY_NOTICES.md b/THIRD_PARTY_NOTICES.md index 9b6d6b5ff0..b4da211246 100644 --- a/THIRD_PARTY_NOTICES.md +++ b/THIRD_PARTY_NOTICES.md @@ -41,6 +41,7 @@ External packages installed for runtime use or embedded in distributed Host or b | [`@earendil-works/pi-ai`](https://github.com/earendil-works/pi) | MIT | | [`@earendil-works/pi-coding-agent`](https://github.com/earendil-works/pi) | MIT | | [`@eslint-community/regexpp`](https://github.com/eslint-community/regexpp) | MIT | +| [`@floating-ui/dom`](https://github.com/floating-ui/floating-ui) | MIT | | [`@fortune-sheet/core`](https://github.com/ruilisi/fortune-sheet) | MIT | | [`@fortune-sheet/react`](https://github.com/ruilisi/fortune-sheet) | MIT | | [`@joplin/turndown-plugin-gfm`](https://github.com/laurent22/joplin-turndown-plugin-gfm) | MIT | @@ -159,6 +160,7 @@ pnpm applies local patches to the following packages at install time, so shipped - `@yao-pkg/pkg@6.21.0` — [`patches/@yao-pkg__pkg@6.21.0.patch`](patches/@yao-pkg__pkg@6.21.0.patch) - `app-builder-lib@26.17.0` — [`patches/app-builder-lib@26.17.0.patch`](patches/app-builder-lib@26.17.0.patch) - `exceljs@4.4.0` — [`patches/exceljs@4.4.0.patch`](patches/exceljs@4.4.0.patch) +- `lexical@0.49.0` — [`patches/lexical@0.49.0.patch`](patches/lexical@0.49.0.patch) - `node-pty@1.2.0-beta.15` — [`patches/node-pty@1.2.0-beta.15.patch`](patches/node-pty@1.2.0-beta.15.patch) ## Chrome DevTools frontend diff --git a/apps/web/tests/composer-focus.e2e.ts b/apps/web/tests/composer-focus.e2e.ts index 39c73a4937..3c0e14db25 100644 --- a/apps/web/tests/composer-focus.e2e.ts +++ b/apps/web/tests/composer-focus.e2e.ts @@ -39,6 +39,51 @@ function describeSelection(state: Awaited>): s return `${state.focused ? 'focused' : 'unfocused'}; selection ${JSON.stringify(state.text)} (${state.anchor} → ${state.focus})` } +/** + * Keep the visible composer still when keyboard panning changes viewport coordinates. + * @param page - Page with the focused composer. + * @returns The observed page and composer scroll behavior. + */ +async function exerciseKeyboardViewport(page: Page): Promise { + const input = page.locator('[data-composer-input][contenteditable="true"]') + const restore = await page.evaluateHandle(() => { + const viewport = window.visualViewport + if (viewport === null) throw new Error('Expected a visual viewport') + const style = document.documentElement.style + const height = style.getPropertyValue('height') + const priority = style.getPropertyPriority('height') + const scroll = window.scrollY + const offset = Object.getOwnPropertyDescriptor(viewport, 'offsetTop') + style.setProperty('height', `${window.innerHeight * 2}px`) + window.scrollTo(0, window.innerHeight) + // Safari can report the keyboard's page displacement as offsetTop even + // though DOM rectangles already account for that page scroll. + Object.defineProperty(viewport, 'offsetTop', { configurable: true, get: () => window.scrollY }) + return () => { + if (offset === undefined) Reflect.deleteProperty(viewport, 'offsetTop') + else Object.defineProperty(viewport, 'offsetTop', offset) + if (height === '') style.removeProperty('height') + else style.setProperty('height', height, priority) + window.scrollTo(0, scroll) + } + }) + try { + const before = await input.evaluate(el => ({ top: el.getBoundingClientRect().top, scroll: window.scrollY })) + expect(before.scroll).toBeGreaterThan(0) + await page.keyboard.insertText('z') + const after = await input.evaluate(el => new Promise<{ top: number; scroll: number }>((resolve) => { + requestAnimationFrame(() => requestAnimationFrame(() => { + resolve({ top: el.getBoundingClientRect().top, scroll: window.scrollY }) + })) + })) + expect(after).toEqual(before) + return '- typing with a keyboard-panned viewport preserves page scroll and composer position' + } finally { + await restore.evaluate((dispose) => { dispose() }) + await restore.dispose() + } +} + /** * Exercise the card's top, inter-row gap, toolbar gap and bottom padding. * @param page - Page containing an editable composer. @@ -113,6 +158,15 @@ async function exerciseComposer(page: Page): Promise { await page.keyboard.insertText('!') await expect.poll(() => input.textContent()).toBe('alpha BET!A gamma') observations.push(`- typing replaces the restored selection and resumes at the restored caret: ${await input.textContent()}`) + const retained = await input.elementHandle() + const beforeResize = await selectionState(page) + for (const width of [390, 768, 1680]) { + await page.setViewportSize({ width, height: 1000 }) + expect(await retained!.evaluate(element => element.isConnected)).toBe(true) + expect(await selectionState(page)).toEqual(beforeResize) + } + observations.push('- resizing through 390px, 768px and 1680px preserves the editor, focus, draft and caret') + observations.push(await exerciseKeyboardViewport(page)) return observations } diff --git a/apps/web/tests/expected/composer-focus/focus.expected.md b/apps/web/tests/expected/composer-focus/focus.expected.md index 03e7a8dbec..4791c8948a 100644 --- a/apps/web/tests/expected/composer-focus/focus.expected.md +++ b/apps/web/tests/expected/composer-focus/focus.expected.md @@ -8,6 +8,8 @@ - bottom padding: focused; selection "beta" (10 → 6) - return from outside: focused; selection "beta" (10 → 6) - typing replaces the restored selection and resumes at the restored caret: alpha BET!A gamma +- resizing through 390px, 768px and 1680px preserves the editor, focus, draft and caret +- typing with a keyboard-panned viewport preserves page scroll and composer position ## Existing session @@ -17,3 +19,5 @@ - bottom padding: focused; selection "beta" (10 → 6) - return from outside: focused; selection "beta" (10 → 6) - typing replaces the restored selection and resumes at the restored caret: alpha BET!A gamma +- resizing through 390px, 768px and 1680px preserves the editor, focus, draft and caret +- typing with a keyboard-panned viewport preserves page scroll and composer position diff --git a/packages/client/ui-conversation/README.i18n.yaml b/packages/client/ui-conversation/README.i18n.yaml index 4c0b48fe55..18351953a5 100644 --- a/packages/client/ui-conversation/README.i18n.yaml +++ b/packages/client/ui-conversation/README.i18n.yaml @@ -21,8 +21,8 @@ en: 9912b286384c41d7 zh: 3e994887c1948677 /deepseek-ai-dsh-client-ui-conversation/shell-and-standard-props: - en: fce20a7d042b1d29 - zh: 0f8e4faff447df6f + en: 74566fff43564bfe + zh: 4944512f461a08b0 /deepseek-ai-dsh-client-ui-conversation/temporary-composer-entries: en: bb1244310f5c0382 zh: 824b84077432b559 diff --git a/packages/client/ui-conversation/README.md b/packages/client/ui-conversation/README.md index 6d0b228e8d..2c9c270a55 100644 --- a/packages/client/ui-conversation/README.md +++ b/packages/client/ui-conversation/README.md @@ -68,7 +68,7 @@ The composer measures its expanded control groups after size, content, visibilit The context meter follows the [statistics-control radius](../../../docs/ui-radius.md#radius-scale). -The composer uses the shared [text-input focus policy](../ui-primitives/README.md#use-this-package) on mount, Session switching, and unlock. Identified phones and tablets require tapping the input; desktop devices retain automatic focus. +The composer uses the shared [text-input focus policy](../ui-primitives/README.md#use-this-package) on mount, Session switching, and unlock. Identified phones and tablets require tapping the input; desktop devices retain automatic focus. The [Lexical patch](../../../patches/lexical@0.49.0.patch) keeps caret scrolling in the same coordinate system as DOM geometry when a mobile keyboard pans the page. The context-occupancy button shows a ring and percentage below the input card, after the Session statistics. Clicking it opens the token breakdown in a panel kept inside the viewport, including when no statistics are shown; the button stays hidden until context usage and capacity are available. diff --git a/packages/client/ui-conversation/README.zh.md b/packages/client/ui-conversation/README.zh.md index 4e417affd9..efa98b4c1c 100644 --- a/packages/client/ui-conversation/README.zh.md +++ b/packages/client/ui-conversation/README.zh.md @@ -68,7 +68,7 @@ Queue 预览启用空白折叠和文档边缘 trim,保留 emoji,并使用 CS 上下文占用率入口遵循[统计控件圆角规则](../../../docs/ui-radius.zh.md#radius-scale)。 -composer 在挂载、切换 Session 和解除锁定时使用共享的[文字输入框聚焦策略](../ui-primitives/README.zh.md#use-this-package)。识别出的手机和平板需要点击输入框;桌面设备保留自动聚焦。 +composer 在挂载、切换 Session 和解除锁定时使用共享的[文字输入框聚焦策略](../ui-primitives/README.zh.md#use-this-package)。识别出的手机和平板需要点击输入框;桌面设备保留自动聚焦。移动端键盘平移页面时,[Lexical 补丁](../../../patches/lexical@0.49.0.patch)让光标滚动计算与 DOM 几何使用同一坐标系。 上下文占用按钮在输入卡片下方、会话统计右侧显示圆环和百分比。点击按钮可在视口内的面板查看 token 构成,没有统计项时面板也不会越界;上下文用量和容量尚不可用时,按钮保持隐藏。 diff --git a/packages/client/ui-conversation/tests/editor-viewport.client.spec.ts b/packages/client/ui-conversation/tests/editor-viewport.client.spec.ts new file mode 100644 index 0000000000..3a430024d6 --- /dev/null +++ b/packages/client/ui-conversation/tests/editor-viewport.client.spec.ts @@ -0,0 +1,72 @@ +// @vitest-environment jsdom +/** Composer caret visibility across page scrolling and virtual-keyboard viewport changes. */ +import { expect, it, onTestFinished, vi } from 'vitest' +import { DraftEditorRuntime } from '../src/client/input/editor/runtime.ts' + +function fixture(viewport: { height: number; offsetTop: number; pageTop: number } | undefined, pageScroll: number) { + // jsdom has no visual viewport or Range geometry; use the browser measurements + // while leaving Lexical's DOM selection and scrolling decisions intact. + vi.stubGlobal('visualViewport', viewport) + vi.stubGlobal('scrollY', pageScroll) + vi.stubGlobal('innerHeight', 600) + const scrollBy = vi.spyOn(window, 'scrollBy').mockImplementation(() => {}) + const geometry = Object.getOwnPropertyDescriptor(Range.prototype, 'getBoundingClientRect') + let caret = new DOMRect(20, 169, 0, 26) + Object.defineProperty(Range.prototype, 'getBoundingClientRect', { + configurable: true, + value: () => caret, + }) + const root = document.createElement('div') + root.setAttribute('contenteditable', 'true') + root.tabIndex = 0 + root.getBoundingClientRect = () => new DOMRect(0, 0, 400, 1000) + document.body.append(root) + const runtime: DraftEditorRuntime = new DraftEditorRuntime({ + onUpdate: () => { runtime.refreshProjection() }, + openReference: () => false, activeClaimToken: () => null, + lexicon: () => new Map(), resolveLexicon: () => undefined, + }) + const dispose = runtime.register() + onTestFinished(() => { + dispose() + root.remove() + scrollBy.mockRestore() + if (geometry === undefined) Reflect.deleteProperty(Range.prototype, 'getBoundingClientRect') + else Object.defineProperty(Range.prototype, 'getBoundingClientRect', geometry) + vi.unstubAllGlobals() + }) + runtime.editor.setRootElement(root) + root.focus({ preventScroll: true }) + scrollBy.mockClear() + return { + scrollBy, + typeAt(top: number): void { + caret = new DOMRect(20, top, 0, 26) + runtime.setDraft('a') + }, + } +} + +it('keeps a visible caret still after Safari pans the page above the keyboard', () => { + const f = fixture({ height: 376, offsetTop: 196, pageTop: 196 }, 196) + f.typeAt(169) + expect(f.scrollBy).not.toHaveBeenCalled() +}) + +it('reveals a caret below the keyboard after the page has scrolled', () => { + const f = fixture({ height: 376, offsetTop: 196, pageTop: 196 }, 196) + f.typeAt(410) + expect(f.scrollBy).toHaveBeenCalledExactlyOnceWith(0, 60) +}) + +it('retains visual viewport panning relative to an already scrolled page', () => { + const f = fixture({ height: 376, offsetTop: 150, pageTop: 350 }, 200) + f.typeAt(100) + expect(f.scrollBy).toHaveBeenCalledExactlyOnceWith(0, -50) +}) + +it('uses the window height when the browser has no visual viewport', () => { + const f = fixture(undefined, 200) + f.typeAt(630) + expect(f.scrollBy).toHaveBeenCalledExactlyOnceWith(0, 56) +}) diff --git a/patches/lexical@0.49.0.patch b/patches/lexical@0.49.0.patch new file mode 100644 index 0000000000..9581885353 --- /dev/null +++ b/patches/lexical@0.49.0.patch @@ -0,0 +1,58 @@ +diff --git a/dist/Lexical.dev.js b/dist/Lexical.dev.js +index 7c6fbcfbbfdda3f79d3b41bec1640e60e1df479c..5423063a9ce8e4a8f9da6fc25ee9d59c4997a7ac 100644 +--- a/dist/Lexical.dev.js ++++ b/dist/Lexical.dev.js +@@ -16346,7 +16346,8 @@ function scrollIntoViewIfNeeded(editor, selectionRect, rootElement) { + // or the caret stays behind the keyboard. + const visualViewport = defaultView.visualViewport; + if (visualViewport) { +- const offsetTop = visualViewport.offsetTop; ++ // Match getBoundingClientRect coordinates when a keyboard pans the page. ++ const offsetTop = visualViewport.pageTop - defaultView.scrollY; + targetTop = offsetTop; + targetBottom = offsetTop + visualViewport.height; + } else { +diff --git a/dist/Lexical.dev.mjs b/dist/Lexical.dev.mjs +index 32aeb4eb929ac82d05988992e97ab3204bf698b4..6390ccb612b7363c8fa959c3b880bd8785f210a0 100644 +--- a/dist/Lexical.dev.mjs ++++ b/dist/Lexical.dev.mjs +@@ -16344,7 +16344,8 @@ function scrollIntoViewIfNeeded(editor, selectionRect, rootElement) { + // or the caret stays behind the keyboard. + const visualViewport = defaultView.visualViewport; + if (visualViewport) { +- const offsetTop = visualViewport.offsetTop; ++ // Match getBoundingClientRect coordinates when a keyboard pans the page. ++ const offsetTop = visualViewport.pageTop - defaultView.scrollY; + targetTop = offsetTop; + targetBottom = offsetTop + visualViewport.height; + } else { +diff --git a/dist/Lexical.prod.js b/dist/Lexical.prod.js +index ab333382f19e0e5dd6a8b0529f565f1731f275a0..e1e5b60124ed3daace2310c75f2720ec67d6c1d9 100644 +--- a/dist/Lexical.prod.js ++++ b/dist/Lexical.prod.js +@@ -9,2 +9,2 @@ + "use strict";function t(t,...e){const n=new URL("https://lexical.dev/docs/error"),o=new URLSearchParams;o.append("code",t);for(const t of e)o.append("v",t);throw n.search=o.toString(),Error(`Minified Lexical error #${t}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function e(t,...e){const n=new URL("https://lexical.dev/docs/error"),o=new URLSearchParams;o.append("code",t);for(const t of e)o.append("v",t);n.search=o.toString(),console.warn(`Minified Lexical warning #${t}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}const n="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,o=n&&"documentMode"in document?document.documentMode:null,r=n&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),s=n&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),i=!(!n||!("InputEvent"in window)||o)&&"getTargetRanges"in new window.InputEvent("input"),l=n&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,c=n&&/Android/.test(navigator.userAgent),a=n&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent)&&!c,u=n&&/^(?=.*Chrome).*/i.test(navigator.userAgent),f=n&&c&&u,d=n&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&r&&!u,h=0,g=1,_=2,p=128,m=1,y=2,x=3,C=4,S=5,T=6,N=a||l||d?"\xa0":"\u200b",v="\n\n",E=s?"\xa0":N,k="\u0591-\u07ff\ufb1d-\ufdfd\ufe70-\ufefc",O="A-Za-z\xc0-\xd6\xd8-\xf6\xf8-\u02b8\u0300-\u0590\u0800-\u1fff\u200e\u2c00-\ufb1c\ufe00-\ufe6f\ufefd-\uffff",b=new RegExp("^[^"+O+"]*["+k+"]"),M=new RegExp("^[^"+k+"]*["+O+"]"),A={bold:1,capitalize:1024,code:16,highlight:p,italic:2,lowercase:256,strikethrough:4,subscript:32,superscript:64,underline:8,uppercase:512},D={directionless:1,unmergeable:2},w={center:2,end:6,justify:4,left:1,right:3,start:5},I={[y]:"center",[T]:"end",[C]:"justify",[m]:"left",[x]:"right",[S]:"start"},P={normal:0,segmented:2,token:1},F={[h]:"normal",[_]:"segmented",[g]:"token"},R="$config";function L(){return Ml()._blockCursorElement}function K(t){return null!==t&&1===t.nodeType&&t.hasAttribute("data-lexical-slot")}class B{element;before;after;constructor(t,e,n){this.element=t,this.before=e||null,this.after=n||null}withBefore(t){return new B(this.element,t,this.after)}withAfter(t){return new B(this.element,this.before,t)}withElement(t){return this.element===t?this:new B(t,this.before,this.after)}insertChild(e){const n=this.getInsertionAnchor();return null!==n&&n.parentElement!==this.element&&t(357),this.element.insertBefore(e,n),this}removeChild(e){return e.parentElement!==this.element&&t(358),this.element.removeChild(e),this}replaceChild(e,n){return n.parentElement!==this.element&&t(359),this.element.replaceChild(e,n),this}getFirstChild(){const t=this.getFirstChildAnchor(),e=t?t.nextSibling:this.element.firstChild;return e===this.getInsertionAnchor()?null:e}getFirstChildAnchor(){return this.after}resolveLeafPosition(t,e,n){if(this.element===t)return e===t&&0===n?"before":"after";const o=$(t,this.element);if(null===o)return"after";const r=Array.prototype.indexOf.call(t.childNodes,o);if(r<0)return"after";if(e===t)return n<=r?"before":"after";const s=$(t,e);if(null===s)return"after";const i=Array.prototype.indexOf.call(t.childNodes,s);return i>=0&&i<=r?"before":"after"}getInsertionAnchor(){return this.before}}function $(t,e){let n=e;for(;null!==n&&n.parentNode!==t;)n=n.parentNode;return n}class z extends B{withBefore(t){return new z(this.element,t,this.after)}withAfter(t){return new z(this.element,this.before,t)}withElement(t){return this.element===t?this:new z(t,this.before,this.after)}getInsertionAnchor(){return super.getInsertionAnchor()||this.getManagedLineBreak()}getFirstChildAnchor(){let t=super.getFirstChildAnchor(),e=t?t.nextSibling:this.element.firstChild;for(;K(e);)t=e,e=e.nextSibling;const n=t?t.nextSibling:this.element.firstChild;return null!==n&&n===L()?n:t}getManagedLineBreak(){return this.element.__lexicalLineBreak||null}setManagedLineBreak(t){if(this.element.__lexicalLastChildKind=t,null===t)this.removeManagedLineBreak();else{const e="decorator"===t&&(d||l||a);this.insertManagedLineBreak(e)}}removeManagedLineBreak(){const t=this.getManagedLineBreak();if(t){const e=this.element,n="IMG"===t.nodeName?t.nextSibling:null;n&&e.removeChild(n),e.removeChild(t),e.__lexicalLineBreak=void 0}}insertManagedLineBreak(t){const e=this.getManagedLineBreak();if(e){if(t===("IMG"===e.nodeName))return;this.removeManagedLineBreak()}const n=this.element,o=this.before,r=fl().createElement("br");if(r.setAttribute("data-lexical-managed-linebreak","true"),n.insertBefore(r,o),t){const t=fl().createElement("img");t.setAttribute("data-lexical-managed-linebreak","true"),t.style.setProperty("display","inline","important"),t.style.setProperty("border","0px","important"),t.style.setProperty("margin","0px","important"),t.alt="",n.insertBefore(t,r),n.__lexicalLineBreak=t}else n.__lexicalLineBreak=r}getFirstChildOffset(){const t=this.getFirstChild(),e=this.getInsertionAnchor();let n=0;for(let o=this.element.firstChild;null!==o&&o!==t&&o!==e;o=o.nextSibling)n++;return n}resolveChildIndex(t,e,n,o){if(n===this.element){const e=this.getFirstChildOffset(),n=L(),r=this.element.childNodes,s=Math.min(o,r.length);let i=0;for(let t=e;tn){i+=1;break}}return[t.getParentOrThrow(),i]}}function W(e,n){const o=[];let r=n;for(;r!==e&&null!==r;r=r.parentNode){let t=0;for(let e=r.previousSibling;null!==e;e=e.previousSibling)t++;o.push(t)}return r!==e&&t(225),o.reverse()}let U;try{U="0.49.0+prod.cjs"}catch(t){}const H=U??'"+source"';class j{_front=new Set;_back=new Set;_cache;get size(){return this._front.size+this._back.size}addBack(t){return delete this._cache,this._front.has(t)||this._back.add(t),this}addFront(t){return delete this._cache,this._back.has(t)||this._front.add(t),this}delete(t){return delete this._cache,this._front.delete(t)||this._back.delete(t)}toArray(){const t=Array.from(this._front).reverse();for(const e of this._back)t.push(e);return t}toReadonlyArray(){return this._cache=this._cache||this.toArray(),this._cache}[Symbol.iterator](){return this.toReadonlyArray()[Symbol.iterator]()}}const Y=null;function G(t,e=1e3){return t instanceof J?t.clone():t.sizethis._size}getNursery(){return this._mutable&&this._nursery||(this.compact(),this._nursery=new Map(this._nursery),this._mutable=!0),this._nursery}compact(t=!1){if(this._nursery&&this._nursery.size>0&&(t||this.shouldCompact())){const t=new Map(this._old);for(const[e,n]of this._nursery)n!==Y?t.set(e,n):t.delete(e);this._old=t,this._nursery=void 0}return this._mutable=!1,this}set(t,e){const n=this.getWithTombstone(t);if(n===e)return this;const o=this.getNursery();return n!==Y&&void 0!==n||(this._size++,n===Y&&o.delete(t)),o.set(t,e),this}delete(t){const e=this.has(t);return e&&(this.getNursery().set(t,Y),this._size--),e}getOrInsert(t,e){const n=this.get(t);return void 0!==n?n:(this.set(t,e),e)}getOrInsertComputed(t,e){const n=this.get(t);if(void 0!==n)return n;const o=e(t);return this.set(t,o),o}clear(){this._mutable=!1,this._old=void 0,this._nursery=void 0,this._size=0}*keys(){for(const t of this.entries())yield t[0]}*values(){for(const t of this.entries())yield t[1]}*entries(){const t=this._nursery,e=this._old;if(e)for(const n of e){const e=n[0],o=t?t.get(e):void 0;o!==Y&&(void 0!==o&&(n[1]=o),yield n)}if(t)for(const n of t)n[1]===Y||e&&e.has(n[0])||(yield n)}forEach(t,e){void 0!==e&&(t=t.bind(e));for(const[e,n]of this.entries())t(n,e,this)}get[Symbol.toStringTag](){return"GenMap"}[Symbol.iterator](){return this.entries()}}function V(t,e,n,o,r,s){if(as(t)){let i=t.getFirstChild();for(;null!==i;){const t=i.__key;i.__parent===e&&((as(i)||tc(i)&&null!==i.__slots)&&V(i,t,n,o,r,s),n.has(t)||s.delete(t),r.push(t)),i=i.getNextSibling()}}for(const i of tc(t)&&null!==t.__slots?t.__slots.values():[]){const t=o.get(i);void 0!==t&&ec(t)&&t.__slotHost===e&&((as(t)||tc(t)&&null!==t.__slots)&&V(t,i,n,o,r,s),n.has(i)||s.delete(i),r.push(i))}}let q=!1,X=0;function Q(t){X=t.timeStamp}function Z(t,e,n){const o="BR"===t.nodeName,r=e.__lexicalLineBreak;return r&&(t===r||o&&t.previousSibling===r)||o&&void 0!==hi(t,n)}function tt(t,e,n){const o=rl(Gi(n)),r=o&&gl(o,n._rootElement);let s=null,i=null;null!==r&&r.anchorNode===t&&(s=r.anchorOffset,i=r.focusOffset);const l=t.nodeValue;null!==l&&ki(e,l,s,i,!1)}function et(t,e,n){if(jo(t)){const e=t.anchor.getNode();if(e.is(n)&&t.format!==e.getFormat())return!1}return ti(e)&&n.isAttached()}function nt(t,e,n){for(let o=t;o&&!Wl(o);o=zi(o)){const t=hi(o,e);if(void 0!==t){const e=ui(t,n);if(e)return ds(e)||!Sl(o)?void 0:[o,e]}}}function ot(t,e,n){q=!0;const o=performance.now()-X>100;try{is(t,()=>{const r=pr()||function(t){return t.read("latest",()=>{const t=pr();return null!==t?t.clone():null})}(t),i=new Map,l=t._editorState,c=t._blockCursorElement;let a=!1,u="";for(let n=0;n0){let e=0;for(let r=0;r0)for(const[e,n]of i)n.reconcileObservedMutation(e,t);const f=n.takeRecords();if(f.length>0){for(let e=0;e{ot(t,e,n)})}const it="direct",lt="latest";class ct{key;parse;unparse;isEqual;defaultValue;resetOnCopyNode;constructor(t,e){this.key=t,this.parse=e.parse.bind(e),this.unparse=(e.unparse||pt).bind(e),this.isEqual=(e.isEqual||Object.is).bind(e),this.defaultValue=this.parse(void 0),this.resetOnCopyNode=e.resetOnCopyNode||!1}}function at(t,e,n=lt){const o=(n===lt?t.getLatest():t).__state;return o?o.getValue(e):e.defaultValue}function ut(t){const e=new Map,n=new Set;for(const{ownNodeConfig:o}of Vl("function"==typeof t?t:t.replace))if(o&&o.stateConfigs)for(const t of o.stateConfigs){let o;"stateConfig"in t?(o=t.stateConfig,t.flat&&n.add(o.key)):o=t,e.set(o.key,o)}return{flatKeys:n,sharedConfigMap:e}}const ft=new Set(["__proto__","constructor","prototype"]);class dt{node;knownState;unknownState;sharedNodeState;size;constructor(t,e,n=void 0,o=new Map,r=void 0){this.node=t,this.sharedNodeState=e,this.unknownState=n,this.knownState=o;const{sharedConfigMap:s}=this.sharedNodeState,i=void 0!==r?r:function(t,e,n){let o=n.size;if(e)for(const r in e){const e=t.get(r);e&&n.has(e)||o++}return o}(s,n,o);this.size=i}getValue(t){const e=this.knownState.get(t);if(void 0!==e)return e;this.sharedNodeState.sharedConfigMap.set(t.key,t);let n=t.defaultValue;if(this.unknownState&&t.key in this.unknownState){const e=this.unknownState[t.key];void 0!==e&&(n=t.parse(e)),this.updateFromKnown(t,n)}return n}getInternalState(){return[this.unknownState,this.knownState]}toJSON(){const t={...this.unknownState},e={};for(const[e,n]of this.knownState)e.isEqual(n,e.defaultValue)?delete t[e.key]:t[e.key]=e.unparse(n);for(const n of this.sharedNodeState.flatKeys)n in t&&(e[n]=t[n],delete t[n]);return _t(t)&&(e.$=t),e}getWritable(t){if(this.node===t)return this;const{sharedNodeState:e,unknownState:n}=this,o=new Map(this.knownState);return new dt(t,e,function(t,e,n){let o;if(n)for(const[r,s]of Object.entries(n)){if(ft.has(r))continue;const n=t.get(r);n?e.has(n)||e.set(n,n.parse(s)):(o=o||{},o[r]=s)}return o}(e.sharedConfigMap,o,n),o,this.size)}resetOnCopyNode(){for(const t of this.knownState.keys())t.resetOnCopyNode&&this.knownState.set(t,t.defaultValue);return this}updateFromKnown(t,e){const n=t.key;this.sharedNodeState.sharedConfigMap.set(n,t);const{knownState:o,unknownState:r}=this;o.has(t)||r&&n in r||(r&&(delete r[n],this.unknownState=_t(r)),this.size++),o.set(t,e)}updateFromUnknown(t,e){if(ft.has(t))return;const n=this.sharedNodeState.sharedConfigMap.get(t);n?this.updateFromKnown(n,n.parse(e)):(this.unknownState=this.unknownState||{},t in this.unknownState||this.size++,this.unknownState[t]=e)}updateFromJSON(t){const{knownState:e}=this;for(const t of e.keys())e.set(t,t.defaultValue);if(this.size=e.size,this.unknownState=void 0,t)for(const[e,n]of Object.entries(t))this.updateFromUnknown(e,n)}}function ht(t){const e=t.getWritable(),n=e.__state?e.__state.getWritable(e):new dt(e,gt(e));return e.__state=n,n}function gt(t){return t.__state?t.__state.sharedNodeState:Us(Ml(),t.getType()).sharedNodeState}function _t(t){if(t)for(const e in t)return t}function pt(t){return t}function mt(t,e,n){for(const[o,r]of e.knownState){if(t.has(o.key))continue;t.add(o.key);const e=n?n.getValue(o):o.defaultValue;if(e!==r&&!o.isEqual(e,r))return!0}return!1}function yt(t,e,n){const{unknownState:o}=e,r=n?n.unknownState:void 0;if(o)for(const[e,n]of Object.entries(o)){if(t.has(e))continue;t.add(e);if(n!==(r?r[e]:void 0))return!0}return!1}function xt(t,e){const n=t.__state;return n&&n.node===t?n.getWritable(e):n}function Ct(t,e){const n=t.__mode,o=t.__format,r=t.__style,s=e.__mode,i=e.__format,l=e.__style,c=t.__state,a=e.__state;return(null===n||n===s)&&(null===o||o===i)&&(null===r||r===l)&&(null===t.__state||c===a||function(t,e){if(t===e)return!0;const n=new Set;return!(t&&mt(n,t,e)||e&&mt(n,e,t)||t&&yt(n,t,e)||e&&yt(n,e,t))}(c,a))}function St(t,e){const n=t.mergeWithSibling(e),o=jr()._normalizedNodes;return o.add(t.__key),o.add(e.__key),n}function Tt(t){let e,n,o=t;if(""!==o.__text||!o.isSimpleText()||o.isUnmergeable()){for(;null!==(e=o.getPreviousSibling())&&wo(e)&&e.isSimpleText()&&!e.isUnmergeable();){if(""!==e.__text){if(Ct(e,o)){o=St(e,o);break}break}e.remove()}for(;null!==(n=o.getNextSibling())&&wo(n)&&n.isSimpleText()&&!n.isUnmergeable();){if(""!==n.__text){if(Ct(o,n)){o=St(o,n);break}break}n.remove()}}else o.remove()}function Nt(t){return vt(t.anchor),vt(t.focus),t}function vt(t){for(;"element"===t.type;){const e=t.getNode(),n=t.offset;let o,r;if(n===e.getChildrenSize()?(o=e.getChildAtIndex(n-1),r=!0):(o=e.getChildAtIndex(n),r=!1),wo(o)){t.set(o.__key,r?o.getTextContentSize():0,"text",!0);break}if(!as(o))break;t.set(o.__key,r?o.getChildrenSize():0,"element",!0)}}const Et=Symbol.for("@lexical/CachedTextSize");function kt(e,n){return Ut.read(()=>{let o=0,r=e;for(let e=0;e0&&!o?t.classList.add(n):e<1&&o&&t.classList.remove(n)}t.style.setProperty("padding-inline-start",0===e?"":`calc(${e} * var(--lexical-indent-base-value, ${te}))`)}function ne(t,e){const n=t.style;0===e?Zt(n,""):1===e?Zt(n,"left"):2===e?Zt(n,"center"):3===e?Zt(n,"right"):4===e?Zt(n,"justify"):5===e?Zt(n,"start"):6===e&&Zt(n,"end")}function oe(t,e){const n=function(t){const e=t.__dir;if(null!==e)return e;if(gs(t))return null;const n=t.getParent();return null===n||Xi(n)&&null===n.__dir?"auto":null}(e);null!==n?t.dir=n:t.removeAttribute("dir")}function re(t){const e=fl().createElement("div");return e.setAttribute("data-lexical-slot",t),e.style.display="none",e}function se(t,e,n){e||"false"===t.contentEditable?Ul(n,At):n.removeAttribute("contenteditable")}function ie(t,e,n){const o=wt,r=Rt();wt="";let s="";const i=ds(t);for(const[o,r]of n){const n=re(o);se(e,i,n),e.appendChild(n),wt="";const l=Rt();fe(r,Dl(t,n,At)),Lt(l),ce(t,o,e,n),s+=wt}return Lt(r),wt=o,s}function le(t){return tc(t)&&null!==t.__slots?t.__slots:Zl}function ce(t,e,n,o){const r=Jt.$getSlotTargetElement(t,e,n,At);null!==r&&(o.parentElement!==r&&r.appendChild(o),o.style.display="")}function ae(t){const e=jt.get(t);return void 0!==e?e.parentElement:null}function ue(t,e,n){const o=le(t),r=le(e);for(const[t,e]of o)if(!r.has(t)){const t=ae(e);Xt(e,null),null!==t&&t.remove()}const s=wt,i=Rt();let l="",c=null;const a=ds(e);for(const[t,s]of r){const r=o.get(t);let i=void 0!==r?ae(r):null;wt="";const u=Rt();if(null===i){i=re(t);let o=null;for(const t of n.children)if(!t.hasAttribute("data-lexical-slot")){o=t;break}n.insertBefore(i,o),fe(s,Dl(e,i,At))}else r===s?pe(s,i):(void 0!==r&&Xt(r,i),fe(s,Dl(e,i,At)));if(Lt(u),se(n,a,i),ce(e,t,n,i),l+=wt,i.parentElement===n){const t=null===c?n.firstChild:c.nextSibling;t!==i&&n.insertBefore(i,t),c=i}}return Lt(i),wt=s,l}function fe(e,n){const o=Ht.get(e);if(void 0===o&&t(60),null!==n){const t=Wt.get(e);if(void 0!==t){const r=jt.get(e);if(void 0!==r){const s=ec(t)?t.__slotHost:null,i=ec(o)?o.__slotHost:null,l=t.__parent!==o.__parent||s!==i,c=null!==i&&r.parentElement!==n.element;if(l||c)return n.insertChild(r),pe(e,n.element)}}}const r=Jt.$createDOM(o,At);if(function(t,e,n){const o=n._keyToDOMMap;di(e,n,t),o.set(t,e)}(e,r,At),wo(o)?r.setAttribute("data-lexical-text","true"):ds(o)&&(r.setAttribute("data-lexical-decorator","true"),zl(r,{captureSelection:!0})),as(o)){const t=o.__indent,e=o.__size;oe(r,o),0!==t&&ee(r,t);const n=le(o),s=n.size>0?ie(o,r,n):"";if(0===e)r.__lexicalTextContent=s,r.__lexicalFirstTextKey=null,wt+=s,n.size>0&&(r.__lexicalSlotTextLength=s.length);else{const t=wt,i=e-1;if(de(Xl(o,Ht),o,0,i,Dl(o,r,At)),""!==s){const e=r.__lexicalTextContent||"";r.__lexicalTextContent=s+e,wt=t+s+e}n.size>0&&(r.__lexicalSlotTextLength=s.length)}const i=o.__format;0!==i&&ne(r,i),o.isInline()||he(null,o,r)}else{const t=o.getTextContent();if(ds(o)){const t=o.decorate(At,Mt);null!==t&&me(e,t),r.contentEditable="false";const n=le(o);n.size>0&&ie(o,r,n)}wt+=t}return null!==n&&n.insertChild(r),Jt.$decorateDOM(o,null,r,At),Ot(o),Fi(Gt,Dt,Bt,o,"created"),r}function de(e,n,o,r,s){const i=wt,l=Rt();wt="",It=null,Pt=null,Ft=null;let c=o;for(;c<=r;++c){const t=Rt();fe(e[c],s);const n=Ht.get(e[c]);null!==n&&wo(n)?null===It&&(It=n.getFormat(),Pt=n.getStyle(),Ft=n.__key):as(n)&&c0?null:"empty"}return null}(e,Ht);r!==s&&o.setManagedLineBreak(s)}function ge(e,n,o){var r;It=null,Pt=null,Ft=null,function(e,n,o){const r=wt,s=e.__size,i=n.__size;wt="";const l=o.element,c=At._keyToDOMMap.get(n.__key);void 0===c&&t(351,n.__key);const a=i-s;if(!Vt&&Math.abs(a)<=1&&s>=bt&&e.__first===n.__first&&(0!==a||!At._cloneNotNeeded.has(e.__key))){const s=c.__lexicalTextContent,u=Yt.get(e.__key);if(!Vt&&"string"==typeof s&&void 0!==u){const i=function(t,e){const n=e.size;if(0===n||n>=t.__size)return null;let o=t.__last,r=null,s=0;for(;null!==o&&s0?s.slice(h):s,_=g.slice(0,g.length-e)+d;return c.__lexicalTextContent=_,wt=r+_,void _e(n,c,u)}if(function(e,n,o,r,s,i,l,c){if(1!==c&&-1!==c)return!1;const a=1===c?2:1;if(l!==a)return!1;const u=l-c;let f=e.__last;for(let t=0;t0?s.slice(E):s;return r.__lexicalTextContent=k.slice(0,k.length-T)+N,!0}(e,0,o,c,s,i,f,a)){const e=c.__lexicalTextContent;return"string"!=typeof e&&t(353),wt=r+e,void _e(n,c,u)}}}if(0===a){let n=e.__first,o=0;for(;null!==n;){const e=Ht.get(n);if(void 0===e)break;const r=Vt||zt.has(n)||$t.has(n),s=Rt();if(r)pe(n,l);else{let o,r;if(as(e)){r=jt.get(n);const s=r&&r.__lexicalTextContent;"string"!=typeof s&&t(354,e.getType()),o=s}else o=e.getTextContent();wt+=o,void 0!==r&&Kt(r)}wo(e)?null===It&&(It=e.getFormat(),Pt=e.getStyle(),Ft=e.__key):as(e)&&oi,g=d>l;if(h&&!g){const e=n[l+1],o=void 0===e?null:At.getElementByKey(e);de(n,t,d,l,s.withBefore(o??s.before))}else g&&!h&&Qt(e,f,i,s.element)}(n,r,c,s,i,o)}c.__lexicalTextContent=wt,c.__lexicalFirstTextKey=Ft,wt=r+wt}(e,n,Dl(n,o,At)),Xi(n)||(r=n,null==It||It===r.__textFormat||qt||r.setTextFormat(It),function(t){null==Pt||Pt===t.__textStyle||qt||t.setTextStyle(Pt)}(n))}function _e(t,e,n){const o=e.__lexicalFirstTextKey;if(null!=o){const e=t.__key;let r=o;for(;null!==r;){const t=Ht.get(r);if(void 0===t){r=null;break}if(t.__parent===e)break;r=t.__parent}if(null!==r&&!n.has(r)){const t=Ht.get(o);if(wo(t))return It=t.getFormat(),void(Pt=t.getStyle())}}e.__lexicalFirstTextKey=Ft}function pe(e,n){const o=Wt.get(e);let r=Ht.get(e);void 0!==o&&void 0!==r||t(61);const s=Vt||zt.has(e)||$t.has(e),i=$i(At,e);if(o===r&&!s){let e;if(as(o)){const n=i.__lexicalTextContent;"string"!=typeof n&&t(355,o.getType()),e=n,Kt(i)}else e=o.getTextContent();return wt+=e,i}if(o!==r&&s&&Fi(Gt,Dt,Bt,r,"updated"),Jt.$updateDOM(r,o,i,At)){const o=fe(e,null);return null===n&&t(62),n.replaceChild(o,i),Xt(e,null),o}if(as(o)){as(r)||t(334,e);const n=r.__indent;(Vt||n!==o.__indent)&&ee(i,n);const l=r.__format;(Vt||l!==o.__format)&&ne(i,l);const c=s&&(le(r).size>0||le(o).size>0)?ue(o,r,i):"";if(s){const t=wt;if(ge(o,r,i),gs(r)||r.isInline()||he(0,r,i),""!==c){const e=i.__lexicalTextContent||"";i.__lexicalTextContent=c+e,wt=t+c+e,i.__lexicalSlotTextLength=c.length}else(le(r).size>0||le(o).size>0)&&(i.__lexicalSlotTextLength=0)}else{const e=i.__lexicalTextContent;"string"!=typeof e&&t(356,o.getType()),wt+=e,Kt(i)}if((Vt||r.__dir!==o.__dir||r.__parent!==o.__parent)&&(oe(i,r),gs(r)&&!Vt))for(const t of r.getChildren())if(as(t)){oe($i(At,t.getKey()),t)}}else{const t=r.getTextContent();if(ds(r)){const t=r.decorate(At,Mt);null!==t&&me(e,t),s&&(le(r).size>0||le(o).size>0)&&ue(o,r,i)}wt+=t}if(!qt&&gs(r)){const t=r.getLatest();if(t.__cachedText!==wt){const e=t.getWritable();e.__cachedText=wt,r=e}}return Jt.$decorateDOM(r,o,i,At),Ot(r),i}function me(t,e){let n=At._pendingDecorators;const o=At._decorators;if(null===n){if(o[t]===e)return;n=_i(At)}n[t]=e}function ye(t){let e=t.nextSibling;return null!==e&&e===At._blockCursorElement&&(e=e.nextSibling),e}function xe(t,e){const n=new Set;for(let o=e;o{for(const n of e){const e=Ht.get(n);if(void 0===e)continue;const o=e.__parent;if(null===o)continue;let r=t.get(o);void 0===r&&(r=new Set,t.set(o,r)),r.add(n)}};return e($t.keys()),e(zt),t}();const i=new Map;return Gt=i,pe("root",null),At=void 0,Dt=void 0,$t=void 0,zt=void 0,Wt=void 0,Ut=void 0,Ht=void 0,Mt=void 0,jt=void 0,Yt=void 0,Gt=void 0,Jt=Fs,i}function Se(e){const n=jt.get(e);return void 0===n&&t(75,e),n} +-/*@__INLINE__*/function Te(t){return{type:t}}const Ne=/* @__PURE__ */Te("SELECTION_CHANGE_COMMAND"),ve=/* @__PURE__ */Te("SELECTION_INSERT_CLIPBOARD_NODES_COMMAND"),Ee=/* @__PURE__ */Te("CLICK_COMMAND"),ke=/* @__PURE__ */Te("BEFORE_INPUT_COMMAND"),Oe=/* @__PURE__ */Te("INPUT_COMMAND"),be=/* @__PURE__ */Te("COMPOSITION_START_COMMAND"),Me=/* @__PURE__ */Te("COMPOSITION_END_COMMAND"),Ae=/* @__PURE__ */Te("DELETE_CHARACTER_COMMAND"),De=/* @__PURE__ */Te("INSERT_LINE_BREAK_COMMAND"),we=/* @__PURE__ */Te("INSERT_PARAGRAPH_COMMAND"),Ie=/* @__PURE__ */Te("CONTROLLED_TEXT_INSERTION_COMMAND"),Pe=/* @__PURE__ */Te("PASTE_COMMAND"),Fe=/* @__PURE__ */Te("REMOVE_TEXT_COMMAND"),Re=/* @__PURE__ */Te("DELETE_WORD_COMMAND"),Le=/* @__PURE__ */Te("DELETE_LINE_COMMAND"),Ke=/* @__PURE__ */Te("FORMAT_TEXT_COMMAND"),Be=/* @__PURE__ */Te("SET_TEXT_FORMAT_COMMAND"),$e=/* @__PURE__ */Te("UNDO_COMMAND"),ze=/* @__PURE__ */Te("REDO_COMMAND"),We=/* @__PURE__ */Te("KEYDOWN_COMMAND"),Ue=/* @__PURE__ */Te("KEY_ARROW_RIGHT_COMMAND"),He=/* @__PURE__ */Te("MOVE_TO_END"),je=/* @__PURE__ */Te("KEY_ARROW_LEFT_COMMAND"),Ye=/* @__PURE__ */Te("MOVE_TO_START"),Ge=/* @__PURE__ */Te("KEY_ARROW_UP_COMMAND"),Je=/* @__PURE__ */Te("KEY_ARROW_DOWN_COMMAND"),Ve=/* @__PURE__ */Te("KEY_ENTER_COMMAND"),qe=/* @__PURE__ */Te("KEY_SPACE_COMMAND"),Xe=/* @__PURE__ */Te("KEY_BACKSPACE_COMMAND"),Qe=/* @__PURE__ */Te("KEY_ESCAPE_COMMAND"),Ze=/* @__PURE__ */Te("KEY_DELETE_COMMAND"),tn=/* @__PURE__ */Te("KEY_TAB_COMMAND"),en=/* @__PURE__ */Te("INSERT_TAB_COMMAND"),nn=/* @__PURE__ */Te("INDENT_CONTENT_COMMAND"),on=/* @__PURE__ */Te("OUTDENT_CONTENT_COMMAND"),rn=/* @__PURE__ */Te("DROP_COMMAND"),sn=/* @__PURE__ */Te("FORMAT_ELEMENT_COMMAND"),ln=/* @__PURE__ */Te("DRAGSTART_COMMAND"),cn=/* @__PURE__ */Te("DRAGOVER_COMMAND"),an=/* @__PURE__ */Te("DRAGEND_COMMAND"),un=/* @__PURE__ */Te("COPY_COMMAND"),fn=/* @__PURE__ */Te("CUT_COMMAND"),dn=/* @__PURE__ */Te("SELECT_ALL_COMMAND"),hn=/* @__PURE__ */Te("CLEAR_EDITOR_COMMAND"),gn=/* @__PURE__ */Te("CLEAR_HISTORY_COMMAND"),_n=/* @__PURE__ */Te("CAN_REDO_COMMAND"),pn=/* @__PURE__ */Te("CAN_UNDO_COMMAND"),mn=/* @__PURE__ */Te("FOCUS_COMMAND"),yn=/* @__PURE__ */Te("BLUR_COMMAND"),xn=/* @__PURE__ */Te("KEY_MODIFIER_COMMAND");function Cn(t){const e=new Map;return{dispose(){for(const t of e.values())t.dispose();e.clear()},register(n,o){let r=e.get(n);void 0===r&&(r={dispose:t(n,o),holders:new Set},e.set(n,r));const s=()=>{const t=e.get(n);t&&t.holders.delete(s)&&0===t.holders.size&&(e.delete(n),t.dispose())};return r.holders.add(s),s}}}function Sn(t,e,n,o){return t.addEventListener(e,n,o),t.removeEventListener.bind(t,e,n,o)}const Tn=Object.freeze({}),Nn=[["keydown",function(t,e){const n=e._inputState;n.lastKeyDownTimeStamp=t.timeStamp,n.lastKeyCode=t.key,"Backspace"!==t.key&&Pn(n);if(e.isComposing())return;Bi(e,We,t)}],["pointerdown",function(t,e){const n=Cl(t),o=t.pointerType;Tl(n)&&"touch"!==o&&"pen"!==o&&0===t.button&&is(e,()=>{Hl(n,e)||(e._inputState.isSelectionChangeFromMouseDown=!0)})}],["compositionstart",function(t,e){Bi(e,be,t)}],["compositionend",function(t,e){const n=e._inputState;s?n.compositionPhase="ending-firefox":l||!a&&!d?Bi(e,Me,t):(n.compositionPhase="ending-safari",n.compositionEndData=t.data)}],["input",function(t,e){t.stopPropagation();const n=e._inputState;Pn(n),is(e,()=>{Rn(t,e)||e.dispatchCommand(Oe,t)},{event:t}),n.unprocessedBeforeInputData=null}],["click",function(t,e){is(e,()=>{const n=pr(),o=rl(Gi(e)),r=mr();if(o)if(jo(n)){const t=n.anchor,e=t.getNode();"element"===t.type&&0===t.offset&&n.isCollapsed()&&!gs(e)&&1===mi().getChildrenSize()&&e.getTopLevelElementOrThrow().isEmpty()&&null!==r&&n.is(r)&&(o.removeAllRanges(),n.dirty=!0)}else if("touch"===t.pointerType||"pen"===t.pointerType){const n=gl(o,e._rootElement).anchorNode;if(Sl(n)||ti(n)){yi(_r(r,o,e,t))}}if(s&&null!==o&&0===o.rangeCount){const n=e._rootElement;if(null!==n&&t.target===n){const s=t.clientY;let i=n.childNodes.length;for(let t=0;tfunction(t,e){const n=t.inputType;if("deleteCompositionText"===n||s&&Ki(e))return;if("insertCompositionText"===n)return;is(e,()=>{Rn(t,e)||Bi(e,ke,t)},{event:t})}(t,e)]);const vn=new WeakMap,En=new WeakMap,kn=Cn(t=>(t.addEventListener("selectionchange",Yn),()=>t.removeEventListener("selectionchange",Yn)));function On(t,e,n,o,r,s){const l=t.anchor,c=t.focus,a=l.getNode(),u=jr();let f;if(void 0!==s)f=s;else{const t=rl(Gi(u));f=null!==t?gl(t,u._rootElement):null}const d=null!==f?f.anchorNode:null,h=l.key,g=u.getElementByKey(h),_=n.length;return h!==c.key||!wo(a)||(!r&&(!i||u._inputState.lastBeforeInputInsertTextTimeStamp1||(r||!i)&&null!==g&&!a.isComposing()&&d!==Il(a,g,u)||null!==f&&null!==e&&(!e.collapsed||e.startContainer!==f.anchorNode||e.startOffset!==f.anchorOffset)||!a.isComposing()&&(a.getFormat()!==t.format||a.getStyle()!==t.style)||function(t,e){if(e.isSegmented())return!0;if(!t.isCollapsed())return!1;const n=t.anchor.offset,o=e.getParentOrThrow(),r=Qs(e);return 0===n?!e.canInsertTextBefore()||!o.canInsertTextBefore()&&!e.isComposing()||r||function(t){const e=t.getPreviousSibling();return(wo(e)||as(e)&&e.isInline())&&!e.canInsertTextAfter()}(e):n===e.getTextContentSize()&&(!e.canInsertTextAfter()||!o.canInsertTextAfter()&&!e.isComposing()||r)}(t,a)}function bn(t,e){return ti(t)&&null!==t.nodeValue&&0!==e&&e!==t.nodeValue.length}function Mn(e,n,o){const{anchorNode:r,anchorOffset:s,focusNode:i,focusOffset:l}=gl(e,n._rootElement),c=n._inputState;c.isSelectionChangeFromDOMUpdate&&(c.isSelectionChangeFromDOMUpdate=!1,bn(r,s)&&bn(i,l)&&!c.postDeleteSelectionToRestore)||is(n,()=>{if(!o)return void yi(null);if(!Js(n,r,i))return;let a=pr();if(c.postDeleteSelectionToRestore&&jo(a)&&a.isCollapsed()){const t=a.anchor,e=c.postDeleteSelectionToRestore.anchor;(t.key===e.key&&t.offset===e.offset+1||1===t.offset&&e.getNode().is(t.getNode().getPreviousSibling()))&&(a=c.postDeleteSelectionToRestore.clone(),yi(a))}if(c.postDeleteSelectionToRestore=null,jo(a)){const o=a.anchor,u=o.getNode();if(a.isCollapsed()){"Range"===e.type&&r===i&&(a.dirty=!0);const s=Gi(n).event,l=s?s.timeStamp:performance.now(),{format:f,style:d,offset:h,key:g,timeStamp:_}=c.collapsedSelectionFormat,p=mi(),m=!1===n.isComposing()&&""===p.getTextContent();if(l<_+200&&o.offset===h&&o.key===g)An(a,f,d);else if("text"===o.type)wo(u)||t(141),Dn(a,u);else if("element"===o.type&&!m){as(u)||t(259);const e=o.getNode();e.isEmpty()?function(t,e){const n=e.getTextFormat(),o=e.getTextStyle();An(t,n,o)}(a,e):An(a,a.format,"")}}else{const t=o.key,e=a.focus.key,n=a.getNodes(),r=n.length,i=a.isBackward(),c=i?l:s,u=i?s:l,f=i?e:t,d=i?t:e;let h=2047,g=!1;for(let t=0;tPn(t),0)}function Rn(t,e){const n=Cl(t);if(Sl(n)&&Hl(n,e))return!0;const o=e.getRootElement();if(null===o)return!1;const r=xl(o.ownerDocument);return null!==r&&o.contains(r)&&Hl(r,e)}function Ln(e){const n=e.inputType,o=wn(e),r=jr(),s=r._inputState,i=pr();if("insertText"===n&&e.data&&s.isInsertTextAfterHandledSelectionCommand){if(Pn(s),e.preventDefault(),jo(i)&&!i.isCollapsed()){const t=i.isBackward()?i.anchor:i.focus;i.anchor.set(t.key,t.offset,t.type),i.focus.set(t.key,t.offset,t.type)}return!0}if("deleteContentBackward"===n){if(null===i){const t=mr();if(!jo(t))return!0;yi(t.clone())}if(jo(i)){const n=i.anchor.key===i.focus.key;if(function(t,e){return"MediaLast"===t.lastKeyCode&&e{is(r,()=>{ci(null)})},30),jo(i)){const e=i.anchor.getNode();e.markDirty(),wo(e)||t(142),Dn(i,e)}}else{if(ci(null),l&&null!==o&&!o.collapsed&&(i.applyDOMRange(o),!i.isCollapsed()))return e.preventDefault(),i.removeText(),!0;e.preventDefault();const t=i.anchor.getNode(),c=t.getTextContent(),a=t.canInsertTextAfter(),u=0===i.anchor.offset&&i.focus.offset===c.length;let d=f&&n&&!u&&a;if(d&&i.isCollapsed()&&(d=!ds(Li(i.anchor,!0))),!d){Bi(r,Ae,!0);const t=pr();f&&jo(t)&&t.isCollapsed()&&(s.postDeleteSelectionToRestore=t,setTimeout(()=>s.postDeleteSelectionToRestore=null))}}return!0}}if(!jo(i))return!0;const c=e.data;null!==s.unprocessedBeforeInputData&&Ei(!1,r,s.unprocessedBeforeInputData),i.dirty&&null===s.unprocessedBeforeInputData||!i.isCollapsed()||gs(i.anchor.getNode())||null===o||i.applyDOMRange(o),s.unprocessedBeforeInputData=null;const a=i.anchor,u=i.focus,d=a.getNode(),h=u.getNode();if("insertText"===n||"insertTranspose"===n){if("\n"===c)e.preventDefault(),Bi(r,De,!1);else if(c===v)e.preventDefault(),Bi(r,we);else if(null==c&&e.dataTransfer){const t=e.dataTransfer.getData("text/plain");e.preventDefault(),i.insertRawText(t)}else null!=c&&On(i,o,c,e.timeStamp,!0)?(e.preventDefault(),Bi(r,Ie,c),In(c)):s.unprocessedBeforeInputData=c;return s.lastBeforeInputInsertTextTimeStamp=e.timeStamp,!0}switch(e.preventDefault(),n){case"insertFromYank":case"insertFromDrop":case"insertReplacementText":Bi(r,Ie,e);In((e.dataTransfer?e.dataTransfer.getData("text/plain"):null)??e.data);break;case"insertFromComposition":{const t=s.hadOrphanedCompositionEvents;s.hadOrphanedCompositionEvents=!1;const n=r._compositionKey;ci(null),t||Bi(r,Ie,e),zn(n);break}case"insertLineBreak":ci(null),Bi(r,De,!1);break;case"insertParagraph":ci(null),s.isInsertLineBreak&&!l?(s.isInsertLineBreak=!1,Bi(r,De,!1)):Bi(r,we);break;case"insertFromPaste":case"insertFromPasteAsQuotation":Bi(r,Pe,e);break;case"deleteByComposition":(function(t,e){return t!==e||as(t)||as(e)||!Qs(t)||!Qs(e)})(d,h)&&Bi(r,Fe,e);break;case"deleteByDrag":Ui(lo),Bi(r,Fe,e);break;case"deleteByCut":Bi(r,Fe,e);break;case"deleteContent":Bi(r,Ae,!1);break;case"deleteWordBackward":Bi(r,Re,!0);break;case"deleteWordForward":Bi(r,Re,!1);break;case"deleteHardLineBackward":case"deleteSoftLineBackward":Bi(r,Le,!0);break;case"deleteContentForward":case"deleteHardLineForward":case"deleteSoftLineForward":Bi(r,Le,!1);break;case"formatStrikeThrough":Bi(r,Ke,"strikethrough");break;case"formatBold":Bi(r,Ke,"bold");break;case"formatItalic":Bi(r,Ke,"italic");break;case"formatUnderline":Bi(r,Ke,"underline");break;case"historyUndo":Bi(r,$e);break;case"historyRedo":Bi(r,ze)}return!0}function Kn(t){const e=jr(),n=e._inputState,o=pr(),r=t.data,l=wn(t);let c=!1;if(null!=r&&jo(o)){const a=rl(Gi(e)),u=null!==a?gl(a,e._rootElement):null,d="insertCompositionText"===t.inputType&&"ending-firefox"!==n.compositionPhase&&!e.isComposing();d&&(n.hadOrphanedCompositionEvents=!0);const h=o.anchor.getNode(),g="insertCompositionText"===t.inputType&&"ending-firefox"!==n.compositionPhase&&e.isComposing()&&wo(h)&&Zs(h);if(!d&&!g&&On(o,l,r,t.timeStamp,!1,u)){if(c=!0,"ending-firefox"===n.compositionPhase){const t=Wn(e,r);if(n.compositionPhase="idle",t)return Ui(ao),xi(),!0}const l=o.anchor.getNode();if(null===a||null===u)return!0;const d=o.isBackward(),h=d?o.anchor.offset:o.focus.offset,g=d?o.focus.offset:o.anchor.offset;i&&!o.isCollapsed()&&wo(l)&&null!==u.anchorNode&&l.getTextContent().slice(0,h)+r+l.getTextContent().slice(h+g)===vi(u.anchorNode)||Bi(e,Ie,r);const _=r.length;s&&_>1&&"insertCompositionText"===t.inputType&&!e.isComposing()&&(o.anchor.offset-=_,o._cachedNodes=null,o._cachedIsBackward=null),f&&e.isComposing()&&(n.lastKeyDownTimeStamp=0,ci(null))}}if(!c){Ei(!1,e,null!==r?r:void 0),"ending-firefox"===n.compositionPhase&&(Wn(e,r||void 0),Ui(ao),n.compositionPhase="idle")}return xi(),!0}function Bn(t){const e=jr(),n=e._inputState,o=pr();if(jo(o)&&!e.isComposing()){n.compositionPhase="composing",n.hadOrphanedCompositionEvents=!1;const r=o.anchor,s=o.anchor.getNode();if(ci(r.key),Ui(co),t.timeStamp{Wn(e,n.compositionEndData)}),n.compositionPhase="idle",n.compositionEndData="",o)return!0}if(function(t){return Ai(t,"ArrowRight",{shiftKey:"any"})}(t))Bi(e,Ue,t);else if(function(t){return Ai(t,"ArrowRight",{...Di,shiftKey:"any"})}(t))Bi(e,He,t);else if(function(t){return Ai(t,"ArrowLeft",{shiftKey:"any"})}(t))Bi(e,je,t);else if(function(t){return Ai(t,"ArrowLeft",{...Di,shiftKey:"any"})}(t))Bi(e,Ye,t);else if(function(t){return Ai(t,"ArrowUp",{altKey:"any",shiftKey:"any"})}(t))Bi(e,Ge,t);else if(function(t){return Ai(t,"ArrowDown",{altKey:"any",shiftKey:"any"})}(t))Bi(e,Je,t);else if(function(t){return Ai(t,"Enter",{altKey:"any",ctrlKey:"any",metaKey:"any",shiftKey:!0})}(t))n.isInsertLineBreak=!0,Bi(e,Ve,t);else if(function(t){return" "===t.key}(t))Bi(e,qe,t);else if(function(t){return r&&Ai(t,"o",{ctrlKey:!0})}(t))t.preventDefault(),n.isInsertLineBreak=!0,Bi(e,De,!0);else if(function(t){return Ai(t,"Enter",{altKey:"any",ctrlKey:"any",metaKey:"any"})}(t))n.isInsertLineBreak=!1,Bi(e,Ve,t);else if(function(t){return Ai(t,"Backspace",{shiftKey:"any"})||r&&Ai(t,"h",{ctrlKey:!0})}(t))Ii(t)?Bi(e,Xe,t)&&Fn(n):(t.preventDefault(),Bi(e,Ae,!0));else if(function(t){return"Escape"===t.key}(t))Bi(e,Qe,t);else if(function(t){return Ai(t,"Delete",{})||r&&Ai(t,"d",{ctrlKey:!0})}(t))!function(t){return"Delete"===t.key}(t)?(t.preventDefault(),Bi(e,Ae,!1)):Bi(e,Ze,t);else if(function(t){return Ai(t,"Backspace",wi)}(t))t.preventDefault(),Bi(e,Re,!0);else if(function(t){return Ai(t,"Delete",wi)}(t))t.preventDefault(),Bi(e,Re,!1);else if(function(t){return r&&Ai(t,"Backspace",{metaKey:!0})}(t))t.preventDefault(),Bi(e,Le,!0);else if(function(t){return r&&(Ai(t,"Delete",{metaKey:!0})||Ai(t,"k",{ctrlKey:!0}))}(t))t.preventDefault(),Bi(e,Le,!1);else if(function(t){return Ai(t,"b",Di)}(t))t.preventDefault(),Bi(e,Ke,"bold");else if(function(t){return Ai(t,"u",Di)}(t))t.preventDefault(),Bi(e,Ke,"underline");else if(function(t){return Ai(t,"i",Di)}(t))t.preventDefault(),Bi(e,Ke,"italic");else if(function(t){return Ai(t,"Tab",{shiftKey:"any"})}(t))Bi(e,tn,t);else if(function(t){return Ai(t,"z",Di)}(t))t.preventDefault(),Bi(e,$e);else if(function(t){if(r)return Ai(t,"z",{metaKey:!0,shiftKey:!0});return Ai(t,"y",{ctrlKey:!0})||Ai(t,"z",{ctrlKey:!0,shiftKey:!0})}(t))t.preventDefault(),Bi(e,ze);else{const o=e._editorState._selection;!function(t){return Ai(t,"a",Di)}(t)?null===o||jo(o)||(!function(t){return Ai(t,"c",Di)}(t)?function(t){return Ai(t,"x",Di)}(t)&&(t.preventDefault(),Bi(e,fn,t)):(t.preventDefault(),Bi(e,un,t))):(t.preventDefault(),Bi(e,dn,t)&&Fn(n))}return function(t){return t.ctrlKey||t.shiftKey||t.altKey||t.metaKey}(t)&&e.dispatchCommand(xn,t),!0}function Hn(t){let e=t.__lexicalEventHandles;return void 0===e&&(e=[],t.__lexicalEventHandles=e),e}const jn=new Map;function Yn(t){const e=sl(t.target);if(null===e)return;const n=Wi(t.target);let o=null,r=null;const s=null!==n?En.get(n):void 0;if(null!==n){if(void 0!==s){const t=s.editors;let n=s.hasShadowEditor;if(void 0===n){n=!1;for(const e of t)if(null!==e._rootElement&&il(e._rootElement.getRootNode())){n=!0;break}s.hasShadowEditor=n}if(n){let n=null,s=null;for(const i of t){const t=i._rootElement;if(null===t)continue;const l=gl(e,t).anchorNode;if(null!==l&&qs(l)===i){if(il(t.getRootNode())){o=i,r=l;break}null===n&&(n=i,s=l)}}null===o&&null!==n&&(o=n,r=s)}else{const t=e.anchorNode;null===t||Sl(t)&&null!==t.shadowRoot||(o=qs(t),null!==o&&(r=t))}}if(null===o){const t=xl(n);o=null!==t?qs(t):null}}if(null===o)return;if(o._inputState.isSelectionChangeFromMouseDown){if(void 0!==s)for(const t of s.editors)t._inputState.isSelectionChangeFromMouseDown=!1;is(o,()=>{const n=mr(),s=r??gl(e,o._rootElement).anchorNode;if(Sl(s)||ti(s)){yi(_r(n,e,o,t))}})}const i=Ti(o),l=i[i.length-1],c=l._key,a=jn.get(c),u=a||l;u!==o&&Mn(e,u,!1),Mn(e,o,!0),o!==l?jn.set(c,o):a&&jn.delete(c)}function Gn(t){t._lexicalHandled=!0}function Jn(t){return!0===t._lexicalHandled}const Vn=()=>{};function qn(e){const n=vn.get(e);if(void 0===n)return void Vn();const o=En.get(n);if(void 0===o)return void Vn();vn.delete(e);const r=Xs(e);Vs(r)?(!function(t){if(null!==t._parentEditor){const e=Ti(t),n=e[e.length-1]._key;jn.get(n)===t&&jn.delete(n)}else jn.delete(t._key)}(r),o.editors.delete(r),o.hasShadowEditor=void 0,e.__lexicalEditor=null):r&&t(198);const s=Hn(e);for(let t=0;tt.__key===this.__key);if(wo(this))return n;if(jo(e)&&"element"===e.anchor.type&&"element"===e.focus.type){if(e.isCollapsed())return!1;const t=this.getParent();if(ds(this)&&this.isInline()&&t){const n=e.isBackward()?e.focus:e.anchor;if(t.is(n.getNode())&&n.offset===t.getChildrenSize()&&this.is(t.getLastChild()))return!1}}return n}getKey(){return this.__key}getIndexWithinParent(){const t=this.getParent();if(null===t)return-1;let e=t.getFirstChild(),n=0;for(;null!==e;){if(this.is(e))return n;n++,e=e.getNextSibling()}return-1}getParent(){const t=this.getLatest().__parent;return null===t?null:ui(t)}getParentOrThrow(){const e=this.getParent();return null===e&&t(66,this.__key),e}getTopLevelElement(){let e=this;for(;null!==e;){const n=e.getParent();if(Xi(n)||null!==nc(e))return as(e)||e===this&&ds(e)||t(194),e;e=n}return null}getTopLevelElementOrThrow(){const e=this.getTopLevelElement();return null===e&&t(67,this.__key),e}getParents(){const t=[];let e=this.getParent();for(;null!==e;)t.push(e),e=e.getParent();return t}getParentKeys(){const t=[];let e=this.getParent();for(;null!==e;)t.push(e.__key),e=e.getParent();return t}getPreviousSibling(){const t=this.getLatest().__prev;return null===t?null:ui(t)}getPreviousSiblings(){const t=[],e=this.getParent();if(null===e)return t;let n=e.getFirstChild();for(;null!==n&&!n.is(this);)t.push(n),n=n.getNextSibling();return t}getNextSibling(){const t=this.getLatest().__next;return null===t?null:ui(t)}getNextSiblings(){const t=[];let e=this.getNextSibling();for(;null!==e;)t.push(e),e=e.getNextSibling();return t}getCommonAncestor(t){const e=as(this)?this:this.getParent(),n=as(t)?t:t.getParent(),o=e&&n?Zc(e,n):null;return o?o.commonAncestor:null}is(t){return null!=t&&this.__key===t.__key}isBefore(e){const n=Zc(this,e);return null!==n&&("descendant"===n.type||("branch"===n.type?-1===qc(n):("same"!==n.type&&"ancestor"!==n.type&&t(279),!1)))}isParentOf(t){return ji(t,this)}getNodesBetween(e){const n=this.isBefore(e),o=[],r=new Set;let s=this;for(;null!==s;){const i=s.__key;if(r.has(i)||(r.add(i),o.push(s)),s===e)break;const l=as(s)?n?s.getFirstChild():s.getLastChild():null;if(null!==l){s=l;continue}const c=n?s.getNextSibling():s.getPreviousSibling();if(null!==c){s=c;continue}const a=s.getParentOrThrow();if(r.has(a.__key)||o.push(a),a===e)break;let u=null,f=a;do{if(null===f&&t(68),u=n?f.getNextSibling():f.getPreviousSibling(),f=f.getParent(),null===f)break;null!==u||r.has(f.__key)||o.push(f)}while(null===u);s=u}return n||o.reverse(),o}isDirty(){const t=jr()._dirtyLeaves;return null!==t&&t.has(this.__key)}getLatest(){if(Zn(this))return this;const e=ui(this.__key);return null===e&&t(113),e}getWritable(){if(Zn(this))return this;Wr();const t=Hr(),e=jr(),n=t._nodeMap,o=this.__key,r=this.getLatest(),s=e._cloneNotNeeded,i=pr();if(null!==i&&i.setCachedNodes(null),s.has(o))return li(r),r;const l=Ll(r);return s.add(o),li(l),n.set(o,l),l}getTextContent(){return _c(this)}getTextContentSize(){return this.getTextContent().length}createDOM(e,n){t(70)}updateDOM(e,n,o){t(71)}getDOMSlot(t){return new B(t)}exportDOM(t){return{element:this.createDOM(t._config,t)}}exportJSON(){const t=this.__state?this.__state.toJSON():void 0;return{type:this.__type,version:1,...t}}static importJSON(e){t(18,this.name)}updateFromJSON(t){return function(t,e){const n=t.getWritable(),o=e.$;let r=o;for(const t of gt(n).flatKeys)t in e&&(void 0!==r&&r!==o||(r={...o}),r[t]=e[t]);return(n.__state||r)&&ht(t).updateFromJSON(r),n}(this,t)}static transform(){return null}remove(t){Xn(this,!0,t)}replace(e,n){Wr();let o=pr();null!==o&&(o=o.clone()),tl(this,e);const r=this.getLatest(),s=this.__key,i=e.__key,l=e.getWritable(),c=this.getParentOrThrow().getWritable(),a=c.__size,u=l.getParent(),f=null!==u?l.getIndexWithinParent():-1;si(l),null!==u&&jo(o)&&yr(o,u,f,-1);const d=r.getPreviousSibling(),h=r.getNextSibling(),g=r.__prev,_=r.__next,p=r.__parent;if(Xn(r,!1,!0),null===d)c.__first=i;else{d.getWritable().__next=i}if(l.__prev=g,null===h)c.__last=i;else{h.getWritable().__prev=i}l.__next=_,l.__parent=p,c.__size=a;let m=0;n&&(as(this)&&as(l)||t(139),m=l.getChildrenSize(),l.splice(m,0,this.getChildren()));const y=lc(this);if(y.length>0){tc(this)&&tc(l)||t(368,this.__key,l.__key);for(const t of y){const e=cc(this,t);null!==e&&(xc(this,t),yc(l,t,e))}}if(jo(o)){yi(o);const t=o.anchor,e=o.focus;t.key===s&&(n&&"element"===t.type?t.set(l.__key,m+t.offset,"element"):$o(t,l)),e.key===s&&(n&&"element"===e.type?e.set(l.__key,m+e.offset,"element"):$o(e,l))}return ai()===s&&ci(i),l}insertAfter(t,e=!0){Wr(),tl(this,t);const n=this.getWritable(),o=t.getWritable();Cc(this.getParentOrThrow());const r=o.getParent(),s=pr();let i=!1,l=!1;if(null!==r){const n=t.getIndexWithinParent();if(jo(s)){const t=r.__key,e=s.anchor,o=s.focus;i="element"===e.type&&e.key===t&&e.offset===n+1,l="element"===o.type&&o.key===t&&o.offset===n+1}si(o),e&&jo(s)&&yr(s,r,n,-1)}else si(o);const c=this.getNextSibling(),a=this.getParentOrThrow().getWritable(),u=o.__key,f=n.__next;if(null===c)a.__last=u;else{c.getWritable().__prev=u}if(a.__size++,n.__next=u,o.__next=f,o.__prev=n.__key,o.__parent=n.__parent,e&&jo(s)){const t=this.getIndexWithinParent();yr(s,a,t+1);const e=a.__key;i&&s.anchor.set(e,t+2,"element"),l&&s.focus.set(e,t+2,"element")}return t}insertBefore(t,e=!0){Wr(),tl(this,t);const n=this.getWritable(),o=t.getWritable();Cc(this.getParentOrThrow());const r=o.__key,s=pr(),i=o.getParent(),l=null!==i?o.getIndexWithinParent():-1;si(o),null!==i&&e&&jo(s)&&yr(s,i,l,-1);const c=this.getPreviousSibling(),a=this.getParentOrThrow().getWritable(),u=n.__prev,f=this.getIndexWithinParent();if(null===c)a.__first=r;else{c.getWritable().__next=r}if(a.__size++,n.__prev=r,o.__prev=u,o.__next=n.__key,o.__parent=n.__parent,e&&jo(s)){yr(s,this.getParentOrThrow(),f)}return t}isParentRequired(){return!1}createParentElementNode(){return Ms()}selectStart(){return this.selectPrevious()}selectEnd(){return this.selectNext(0,0)}selectPrevious(t,e){Wr();const n=oc(this);if(null!==n)return n.selectPrevious(t,e);const o=this.getPreviousSibling(),r=this.getParentOrThrow();if(null===o)return r.select(0,0);if(as(o))return o.select();if(!wo(o)){const t=o.getIndexWithinParent()+1;return r.select(t,t)}return o.select(t,e)}selectNext(t,e){Wr();const n=oc(this);if(null!==n)return n.selectNext(t,e);const o=this.getNextSibling(),r=this.getParentOrThrow();if(null===o)return r.select();if(as(o))return o.select(0,0);if(!wo(o)){const t=o.getIndexWithinParent();return r.select(t,t)}return o.select(t,e)}markDirty(){this.getWritable()}reconcileObservedMutation(t,e){this.markDirty()}}function no(t){return t instanceof eo}const oo="history-merge",ro="collaboration",so="skip-scroll-into-view",io="skip-dom-selection",lo="skip-selection-focus",co="composition-start",ao="composition-end",uo="!important";function fo(t){const e={};if(!t)return e;let n="",o="",r=null,s=!1,i=!1,l=!1,c=0;const a=t.length;let u=-1;for(let f=0;f=0&&o.slice(r).toLowerCase()===uo?t.setProperty(e,o.slice(0,r).trim(),"important"):t.setProperty(e,n,"")}function go(t,e,n=""){if(e===n)return;const o=fo(n),r=fo(e);for(const e in r)delete o[e],ho(t,e,r[e]);for(const e in o)t.removeProperty(e)}function _o(t,e){return 16&e?"code":e&p?"mark":32&e?"sub":64&e?"sup":null}function po(t,e){return 1&e?"strong":2&e?"em":"span"}function mo(t,e,n,o,r){const s=o.classList;let i=Pi(r,"base");void 0!==i&&s.add(...i),i=Pi(r,"underlineStrikethrough");let l=!1;const c=8&e&&4&e;void 0!==i&&(8&n&&4&n?(l=!0,c||s.add(...i)):c&&s.remove(...i));for(const t in A){const o=A[t];if(i=Pi(r,t),void 0!==i)if(n&o){if(l&&("underline"===t||"strikethrough"===t)){e&o&&s.remove(...i);continue}(0===(e&o)||c&&"underline"===t||"strikethrough"===t)&&s.add(...i)}else e&o&&s.remove(...i)}}function yo(t,e,n){const o=n.isComposing(),r=t+(o?N:""),i=Ml(),l=Al(i).$getDOMSlot(n,e,i),c=l.getFirstChild();if(null===c||c.nodeType!==Node.TEXT_NODE)return void l.insertChild(fl().createTextNode(r));const a=c,u=a.nodeValue;if(u!==r)if(o||s){const[t,e,n]=function(t,e){const n=t.length,o=e.length;let r=0,s=0;for(;r({conversion:Oo,priority:0}),b:()=>({conversion:vo,priority:0}),code:()=>({conversion:Ao,priority:0}),em:()=>({conversion:Ao,priority:0}),i:()=>({conversion:Ao,priority:0}),mark:()=>({conversion:Ao,priority:0}),s:()=>({conversion:Ao,priority:0}),span:()=>({conversion:No,priority:0}),strong:()=>({conversion:Ao,priority:0}),sub:()=>({conversion:Ao,priority:0}),sup:()=>({conversion:Ao,priority:0}),u:()=>({conversion:Ao,priority:0})}})}afterCloneFrom(t){super.afterCloneFrom(t),this.__text=t.__text,this.__format=t.__format,this.__style=t.__style,this.__mode=t.__mode,this.__detail=t.__detail}constructor(t="",e){super(e),this.__text=t,this.__format=0,this.__style="",this.__mode=0,this.__detail=0}getFormat(){return this.getLatest().__format}getDetail(){return this.getLatest().__detail}getMode(){const t=this.getLatest();return F[t.__mode]}getStyle(){return this.getLatest().__style}isToken(){return 1===this.getLatest().__mode}isComposing(){return this.__key===ai()}isSegmented(){return 2===this.getLatest().__mode}isDirectionless(){return!!(1&this.getLatest().__detail)}isUnmergeable(){return!!(2&this.getLatest().__detail)}hasFormat(t){const e=A[t];return 0!==(this.getFormat()&e)}isSimpleText(){return"text"===this.__type&&0===this.__mode}getTextContent(){return this.getLatest().__text}getFormatFlags(t,e){return oi(this.getLatest().__format,t,e)}canHaveFormat(){return!0}isInline(){return!0}createDOM(t,e){const n=this.__format,o=_o(0,n),r=po(0,n),s=null===o?r:o,i=fl().createElement(s);let l=i;this.hasFormat("code")&&i.setAttribute("spellcheck","false"),null!==o&&(l=fl().createElement(r),i.appendChild(l));xo(l,this,0,n,this.__text,t);const c=this.__style;return""!==c&&go(i.style,c),i}updateDOM(e,n,o){const r=this.__text,s=e.__format,i=this.__format,l=_o(0,s),c=_o(0,i),a=po(0,s),u=po(0,i);if((null===l?a:l)!==(null===c?u:c))return!0;if(l===c&&a!==u){const e=n.firstChild;null==e&&t(48);const s=fl().createElement(u);return xo(s,this,0,i,r,o),n.replaceChild(s,e),!1}let f=n;null!==c&&null!==l&&(f=n.firstChild,null==f&&t(49)),yo(r,f,this);const d=o.theme.text;void 0!==d&&s!==i&&mo(0,s,i,f,d);const h=e.__style,g=this.__style;return h!==g&&go(n.style,g,h),!1}updateFromJSON(t){return super.updateFromJSON(t).setTextContent(t.text).setFormat(t.format).setDetail(t.detail).setMode(t.mode).setStyle(t.style)}exportDOM(e){let{element:n}=super.exportDOM(e);return Sl(n)||t(132),n.style.whiteSpace="pre-wrap",this.hasFormat("lowercase")?n.style.textTransform="lowercase":this.hasFormat("uppercase")?n.style.textTransform="uppercase":this.hasFormat("capitalize")&&(n.style.textTransform="capitalize"),this.hasFormat("bold")&&(n=Co(n,"b")),this.hasFormat("italic")&&(n=Co(n,"i")),this.hasFormat("strikethrough")&&(n=Co(n,"s")),this.hasFormat("underline")&&(n=Co(n,"u")),{element:n}}exportJSON(){return{detail:this.getDetail(),format:this.getFormat(),mode:this.getMode(),style:this.getStyle(),text:this.getTextContent(),...super.exportJSON()}}selectionTransform(t,e){}setFormat(t){const e=this.getWritable();return e.__format="string"==typeof t?A[t]:t,e}setDetail(t){const e=this.getWritable();return e.__detail="string"==typeof t?D[t]:t,e}setStyle(t){const e=this.getWritable();return e.__style=t,e}toggleFormat(t){const e=oi(this.getFormat(),t,null);return this.setFormat(e)}toggleDirectionless(){const t=this.getWritable();return t.__detail^=1,t}toggleUnmergeable(){const t=this.getWritable();return t.__detail^=2,t}setMode(t){const e=P[t];if(this.__mode===e)return this;const n=this.getWritable();return n.__mode=e,n}setTextContent(t){if(this.__text===t)return this;const e=this.getWritable();return e.__text=t,e}select(t,e){Wr();let n=t,o=e;const r=pr(),s=this.getTextContent(),i=this.__key;if("string"==typeof s){const t=s.length;void 0===n&&(n=t),void 0===o&&(o=t)}else n=0,o=0;if(!jo(r))return dr(i,n,i,o,"text","text");{const t=ai();t!==r.anchor.key&&t!==r.focus.key||ci(i),r.setTextNodeRange(this,n,this,o)}return r}selectStart(){return this.select(0,0)}selectEnd(){const t=this.getTextContentSize();return this.select(t,t)}spliceText(t,e,n,o){const r=this.getWritable(),s=r.__text,i=n.length;let l=t;l<0&&(l=i+l,l<0&&(l=0));const c=pr();if(o&&jo(c)){const e=t+i;c.setTextNodeRange(r,e,r,e)}const a=s.slice(0,l)+n+s.slice(l+e);return r.__text=a,r}canInsertTextBefore(){return!0}canInsertTextAfter(){return!0}splitText(...t){Wr();const e=this.getLatest(),n=e.getTextContent();if(""===n)return[];const o=e.__key,r=ai(),s=n.length;t.sort((t,e)=>t-e),t.push(s);const i=[],l=t.length;for(let e=0,o=0;ee&&(i.push(n.slice(e,r)),e=r)}const c=i.length;if(1===c)return[e];const a=i[0],u=e.getParent();let f;const d=e.getFormat(),h=e.getStyle(),g=e.__detail;let _=!1,p=null,m=null;const y=pr();if(jo(y)){const[t,e]=y.isBackward()?[y.focus,y.anchor]:[y.anchor,y.focus];"text"===t.type&&t.key===o&&(p=t),"text"===e.type&&e.key===o&&(m=e)}e.isSegmented()?(f=Do(a),f.__format=d,f.__style=h,f.__detail=g,f.__state=xt(e,f),_=!0):f=e.setTextContent(a);const x=[f];for(let t=1;t=T&&(p.set(t.getKey(),C-T,"text"),C=T){m.set(t.getKey(),S-T,"text");break}T=e}if(null!==u){!function(t){const e=t.getPreviousSibling(),n=t.getNextSibling();null!==e&&li(e);null!==n&&li(n)}(this);const t=u.getWritable(),e=this.getIndexWithinParent();_?(t.splice(e,0,x),this.remove()):t.splice(e,1,x),jo(y)&&yr(y,u,e,c-1)}return x}mergeWithSibling(e){const n=e===this.getPreviousSibling();n||e===this.getNextSibling()||t(50);const o=this.__key,r=e.__key,s=this.__text,i=s.length;ai()===r&&ci(o);const l=pr();if(jo(l)){const t=l.anchor,s=l.focus;null!==t&&t.key===r&&Sr(t,n,o,e,i),null!==s&&s.key===r&&Sr(s,n,o,e,i)}const c=e.__text,a=n?c+s:s+c;this.setTextContent(a);const u=this.getWritable();return e.remove(),u}isTextEntity(){return!1}}function No(t){return{forChild:Io(t.style),node:null}}function vo(t){const e=t,n="normal"===e.style.fontWeight;return{forChild:Io(e.style,n?void 0:"bold"),node:null}}const Eo=new WeakMap;function ko(t){if(!Sl(t))return!1;if("PRE"===t.nodeName)return!0;const e=t.style.whiteSpace;return"string"==typeof e&&e.startsWith("pre")}function Oo(e){const n=e;null===e.parentElement&&t(129);let o=n.textContent||"";if(null!==function(t){let e,n=t.parentNode;const o=[t];for(;null!==n&&void 0===(e=Eo.get(n))&&!ko(n);)o.push(n),n=n.parentNode;const r=void 0===e?n:e;for(let t=0;t0){/[ \t\n]$/.test(n)&&(o=o.slice(1)),e=!1;break}}e&&(o=o.slice(1))}if(" "===o[o.length-1]){let t=n,e=!0;for(;null!==t&&null!==(t=bo(t,!0));){if((t.textContent||"").replace(/^( |\t|\r?\n)+/,"").length>0){e=!1;break}}e&&(o=o.slice(0,o.length-1))}return""===o?{node:null}:{node:Do(o)}}function bo(t,e){let n=t;for(;;){let t;for(;null===(t=e?n.nextSibling:n.previousSibling);){const t=n.parentElement;if(null===t)return null;n=t}if(n=t,Sl(n)){const t=n.style.display;if(""===t&&!El(n)||""!==t&&!t.startsWith("inline"))return null}let o=n;for(;null!==(o=e?n.firstChild:n.lastChild);)n=o;if(ti(n))return n;if("BR"===n.nodeName)return null}}const Mo={code:"code",em:"italic",i:"italic",mark:"highlight",s:"strikethrough",strong:"bold",sub:"subscript",sup:"superscript",u:"underline"};function Ao(t){const e=Mo[t.nodeName.toLowerCase()];return void 0===e?{node:null}:{forChild:Io(t.style,e),node:null}}function Do(t=""){return Zi(new To(t))}function wo(t){return t instanceof To}function Io(t,e){const n=t.fontWeight,o=t.textDecoration.split(" "),r="700"===n||"bold"===n,s=o.includes("line-through"),i="italic"===t.fontStyle,l=o.includes("underline"),c=t.verticalAlign;return t=>wo(t)||So(t)?(r&&!t.hasFormat("bold")&&t.toggleFormat("bold"),s&&!t.hasFormat("strikethrough")&&t.toggleFormat("strikethrough"),i&&!t.hasFormat("italic")&&t.toggleFormat("italic"),l&&!t.hasFormat("underline")&&t.toggleFormat("underline"),"sub"!==c||t.hasFormat("subscript")||t.toggleFormat("subscript"),"super"!==c||t.hasFormat("superscript")||t.toggleFormat("superscript"),e&&!t.hasFormat(e)&&t.toggleFormat(e),t):t}class Po extends To{$config(){return this.config("tab",{extends:To})}constructor(t=void 0){super("\t",t),this.__detail=2}createDOM(t){const e=super.createDOM(t),n=Pi(t.theme,"tab");if(void 0!==n){e.classList.add(...n)}return e}setTextContent(t){return super.setTextContent("\t")}spliceText(e,n,o,r){return""===o&&0===n||"\t"===o&&1===n||t(286),this}setDetail(e){return 2!==e&&t(127),this}setMode(e){return"normal"!==e&&t(128),this}canInsertTextBefore(){return!1}canInsertTextAfter(){return!1}}function Fo(){return Zi(new Po)}function Ro(t){return t instanceof Po}class Lo{key;offset;type;_selection;constructor(t,e,n){this._selection=null,this.key=t,this.offset=e,this.type=n}is(t){return this.key===t.key&&this.offset===t.offset&&this.type===t.type}isBefore(t){if(this.key===t.key)return this.offsett&&(o=t)}else if(!as(e)){const t=e.getNextSibling();if(wo(t))n=t.__key,o=0,r="text";else{const t=e.getParent();t&&(n=t.__key,o=e.getIndexWithinParent()+1)}}t.set(n,o,r)}function $o(t,e){if(as(e)){const n=e.getLastDescendant();as(n)||wo(n)?Bo(t,n):Bo(t,e)}else Bo(t,e)}function zo(t,e,n,o){const r=t.getNode(),s=r.getChildAtIndex(t.offset),i=Do();if(i.setFormat(n),i.setStyle(o),As(s))s.splice(0,0,[i]);else if(null!==s){const t=Xi(r)?Ms().append(i):i;s.insertBefore(t)}else if(Xi(r)){const t=r.getLastChild();as(t)&&!t.isInline()&&t.isEmpty()?t.append(i):r.append(Ms().append(i))}else r.append(i);t.is(e)&&e.set(i.__key,0,"text"),t.set(i.__key,0,"text")}function Wo(e,n,o,r){const s=e.anchor.getNode();wo(s)||t(398);const i=e.anchor.offset,l=Do(n);l.setFormat(o),l.setStyle(r);const c=s.getParentOrThrow();if(0===i)c.isInline()&&!s.__prev?c.insertBefore(l):s.insertBefore(l,!1);else if(i===s.getTextContentSize())c.isInline()&&!s.__next?c.insertAfter(l):s.insertAfter(l,!1);else{const[t]=s.splitText(i);t.insertAfter(l,!1)}""===s.getTextContent()&&s.isAttached()&&s.remove(),l.selectEnd(),l.isComposing()&&"text"===e.anchor.type&&e.anchor.set(e.anchor.key,e.anchor.offset-n.length,e.anchor.type)}class Uo{_nodes;_cachedNodes;dirty;constructor(t){this._cachedNodes=null,this._nodes=t,this.dirty=!1}getCachedNodes(){return this._cachedNodes}setCachedNodes(t){this._cachedNodes=t}is(t){if(!Go(t))return!1;const e=this._nodes,n=t._nodes;return e.size===n.size&&Array.from(e).every(t=>n.has(t))}isCollapsed(){return!1}isBackward(){return!1}getStartEndPoints(){return null}add(t){this.dirty=!0,this._nodes.add(t),this._cachedNodes=null}delete(t){this.dirty=!0,this._nodes.delete(t),this._cachedNodes=null}clear(){this.dirty=!0,this._nodes.clear(),this._cachedNodes=null}has(t){return this._nodes.has(t)}clone(){return new Uo(new Set(this._nodes))}extract(){return this.getNodes()}insertRawText(t){}insertText(){}insertNodes(t){const e=this.getNodes().filter(t=>null===nc(t)),n=e.length;if(0===n)return;const o=e[n-1];let r;if(wo(o))r=o.select();else{const t=o.getIndexWithinParent()+1;r=o.getParentOrThrow().select(t,t)}r.insertNodes(t);for(let t=0;tnull===nc(t));if((pr()||mr())===this&&t[0]){const e=Rc(t[0],"next");na(Gc(e,e))}for(const e of t)e.remove();Ho()}}function Ho(){const t=mi();if(t.isEmpty()){const e=Ms();t.append(e),e.select()}}function jo(t){return t instanceof Yo}class Yo{format;style;anchor;focus;_cachedNodes;_cachedIsBackward;dirty;constructor(t,e,n,o){this.anchor=t,this.focus=e,t._selection=this,e._selection=this,this._cachedNodes=null,this._cachedIsBackward=null,this.format=n,this.style=o,this.dirty=!1}getCachedNodes(){return this._cachedNodes}setCachedNodes(t){this._cachedNodes=t}is(t){return!!jo(t)&&(this.anchor.is(t.anchor)&&this.focus.is(t.focus)&&this.format===t.format&&this.style===t.style)}isCollapsed(){return this.anchor.is(this.focus)}getNodes(){const t=this._cachedNodes;if(null!==t)return t;const e=function(t){const e=[],[n,o]=t.getTextSlices();n&&e.push(n.caret.origin);const r=new Set,s=new Set;for(const n of t)if(wc(n)){const{origin:t}=n;0===e.length?r.add(t):(s.add(t),e.push(t))}else{const{origin:t}=n;as(t)&&s.has(t)||e.push(t)}o&&e.push(o.caret.origin);if(Dc(t.focus)&&as(t.focus.origin)&&null===t.focus.getNodeAtCaret())for(let n=$c(t.focus.origin,"previous");wc(n)&&r.has(n.origin)&&!n.origin.isEmpty()&&n.origin.is(e[e.length-1]);n=Wc(n))r.delete(n.origin),e.pop();for(;e.length>1;){const t=e[e.length-1];if(!as(t)||s.has(t)||t.isEmpty()||r.has(t))break;e.pop()}if(0===e.length&&t.isCollapsed()){const n=aa(t.anchor),o=aa(t.anchor.getFlipped()),r=t=>Ac(t)?t.origin:t.getNodeAtCaret(),s=r(n)||r(o)||(t.anchor.getNodeAtCaret()?n.origin:o.origin);e.push(s)}return e}(da(ra(this),"next"));return zr()||(this._cachedNodes=e),e}setTextNodeRange(t,e,n,o){return this.anchor.set(t.__key,e,"text"),this.focus.set(n.__key,o,"text"),this}getTextContent(){const t=this.getNodes();if(0===t.length)return"";const e=t[0],n=t[t.length-1],o=this.anchor,r=this.focus,s=o.isBefore(r),[i,l]=Xo(this);let c="",a=!0;for(let u=0;u(as(t)||ds(t))&&!t.isInline())){as(r)||t(211,o.constructor.name,o.getType());const n=br(this);return r.splice(n,0,e),void s.selectEnd()}if(as(r)&&null!==nc(r)){const t=br(this),n=Or(e);r.splice(t,0,n);const o=n[n.length-1];return void(void 0!==o?o.selectEnd():r.select(t,t))}if(null===r){const t=Dr(e),n=t.getLastDescendant();let o=ta(this.anchor,"next");for(const e of t.getChildren())o=ma(e,o);return void(null!==n&&n.selectEnd())}if(as(r)&&!r.isParentRequired()&&!Xi(r.getParentOrThrow())){const t=br(this),n=Or(e);r.splice(t,0,n);const o=n[n.length-1];return void(void 0!==o?o.selectEnd():r.select(t,t))}const i=Dr(e),l=i.getLastDescendant(),c=i.getChildren(),a=!as(r)||!r.isEmpty()?this.insertParagraph():null;a&&!r.isAttached()&&(o=this.anchor.getNode(),r=ql(o,bl));const u=c[c.length-1];let f=c[0];var d;as(d=f)&&bl(d)&&!d.isEmpty()&&as(r)&&(!r.isEmpty()||r.canMergeWhenEmpty())&&(as(r)||t(211,o.constructor.name,o.getType()),r.append(...f.getChildren()),f=c[1]),f&&(null===r&&t(212,o.constructor.name,o.getType()),function(e,n){const o=n.getParentOrThrow().getLastChild();let r=n;const s=[n];for(;r!==o;)r.getNextSibling()||t(140),r=r.getNextSibling(),s.push(r);let i=e;for(const t of s)i=i.insertAfter(t)}(r,f));const h=ql(l,bl);a&&as(h)&&(a.canMergeWhenEmpty()||bl(u))&&(h.append(...a.getChildren()),a.remove()),as(r)&&r.isEmpty()&&r.remove(),l.selectEnd();const g=as(r)?r.getLastChild():null;Ns(g)&&h!==r&&g.remove()}insertParagraph(){const e=this.anchor.getNode();if("element"===this.anchor.type&&Xi(e)){const t=Ms();return e.splice(this.anchor.offset,0,[t]),t.select(),t}const n=br(this),o=ql(this.anchor.getNode(),bl);if(null!==o&&null!==nc(o))return null;as(o)||t(213);const r=o.getChildAtIndex(n),s=r?[r,...r.getNextSiblings()]:[],i=o.insertNewAfter(this,!1);return i?(i.append(...s),i.selectStart(),i):null}insertLineBreak(t){const e=Ts();if(this.insertNodes([e]),t){const t=e.getParentOrThrow(),n=e.getIndexWithinParent();t.select(n,n)}}extract(){const t=[...this.getNodes()],e=t.length;let n=t[0],o=t[e-1];const[r,s]=Xo(this),i=this.isBackward(),[l,c]=i?[this.focus,this.anchor]:[this.anchor,this.focus],[a,u]=i?[s,r]:[r,s];if(0===e)return[];if(1===e){if(wo(n)&&!this.isCollapsed()){const t=n.splitText(a,u),e=0===a?t[0]:t[1];return e?(l.set(e.getKey(),0,"text"),c.set(e.getKey(),e.getTextContentSize(),"text"),[e]):[]}return[n]}if(wo(n)&&(a===n.getTextContentSize()?t.shift():0!==a&&([,n]=n.splitText(a),t[0]=n,l.set(n.getKey(),0,"text"))),wo(o)){const e=o.getTextContent().length;0===u?t.pop():u!==e&&([o]=o.splitText(u),t[t.length-1]=o,c.set(o.getKey(),o.getTextContentSize(),"text"))}return t}modify(t,e,n){if(wr(this,t,e,n))return;const o="move"===t,r=jr(),s=rl(Gi(r));if(!s)return;const i=r._blockCursorElement,l=r._rootElement,c=this.focus.getNode();null===l||null===i||!as(c)||c.isInline()||c.canBeEmpty()||ol(i,r,l);const a=$i(r,this.focus.key);let u=a;if("text"===this.focus.type&&(u=wo(c)?Il(c,a,r):null),this.dirty){const t=$i(r,this.anchor.key);let e=t;if("text"===this.anchor.type){const n=this.anchor.getNode();e=wo(n)?Il(n,t,r):null}e&&u&&Tr(s,e,this.anchor.offset,u,this.focus.offset)}if("character"===n&&wo(c)&&c.isUnmergeable()){if(e?0===this.focus.offset:this.focus.offset===c.getTextContentSize()){const t=Rc(c,e?"previous":"next").getNodeAtCaret();if(wo(t)){if(!o){const n=t.getTextContentSize();return e?this.focus.set(t.__key,n-1,"text"):this.focus.set(t.__key,1,"text"),void(this.dirty=!0)}{const n=r.getElementByKey(t.getKey()),o=n?Il(t,n,r):null;if(o){const t=e?o.length:0;Tr(s,o,t,o,t)}}}}}if(tr(s,t,e?"backward":"forward",n),s.rangeCount>0){const t=dl(s,r._rootElement),n=t||s.getRangeAt(0),i=this.anchor.getNode(),l=gs(i)?i:Vi(i);if(this.applyDOMRange(n),this.dirty=!0,!o){er(this,e,l);(t?"backward"!==s.direction:s.anchorNode===n.startContainer&&s.anchorOffset===n.startOffset)||Zo(this)}}"lineboundary"===n&&wr(this,t,e,n,"decorators")}forwardDeletion(t,e,n){if(!n&&("element"===t.type&&as(e)&&t.offset===e.getChildrenSize()||"text"===t.type&&t.offset===e.getTextContentSize())){const t=e.getParent(),n=e.getNextSibling()||(null===t?null:t.getNextSibling());if(as(n)&&n.isShadowRoot())return!0}return!1}deleteCharacter(t){const e=this.isCollapsed();if(this.isCollapsed()){const e=this.anchor;let n=e.getNode();if(this.forwardDeletion(e,n,t))return;const o=jc(ta(e,t?"previous":"next"));if(o.getTextSlices().every(t=>null===t||0===t.distance)){let t={type:"initial"};for(const e of o.iterNodeCarets("shadowRoot"))if(wc(e))if(e.origin.isInline());else{if(e.origin.isShadowRoot()){if("merge-block"===t.type)break;if(as(o.anchor.origin)&&o.anchor.origin.isEmpty()){const t=aa(e);oa(this,Gc(t,t)),o.anchor.origin.remove()}return}"merge-next-block"!==t.type&&"merge-block"!==t.type||(t={block:t.block,caret:e,type:"merge-block"})}else{if("merge-block"===t.type)break;if(Dc(e)){if(as(e.origin)){if(e.origin.isInline()){if(!e.origin.isParentOf(o.anchor.origin))break}else t={block:e.origin,type:"merge-next-block"};continue}if(ds(e.origin)){if(e.origin.isIsolated());else if(lc(e.origin).length>0){if(as(o.anchor.origin)&&o.anchor.origin.isEmpty()){o.anchor.origin.remove();const t=gr();t.add(e.origin.getKey()),yi(t)}}else if("merge-next-block"===t.type&&(e.origin.isKeyboardSelectable()||!e.origin.isInline())&&as(o.anchor.origin)&&o.anchor.origin.isEmpty()){o.anchor.origin.remove();const t=gr();t.add(e.origin.getKey()),yi(t)}else e.origin.remove();return}break}}if("merge-block"===t.type){const{caret:e,block:n}=t;if(lc(n).length>0)return;return e.origin.isEmpty()&&!n.isEmpty()&&e.origin.getParent()===n.getParent()?void e.origin.remove(!0):(oa(this,Gc(!e.origin.isEmpty()&&n.isEmpty()?sa(Rc(n,e.direction)):o.anchor,e)),this.removeText())}for(let t=e.getNode();null!==t;){if(null!==nc(t))return;if(as(t)&&t.isShadowRoot())break;t=t.getParent()}}const r=this.focus;if(nr(this,t,"character"),this.isCollapsed()){if(t&&0===e.offset&&Qo(this,e.getNode()))return}else{const o="text"===r.type?r.getNode():null;if(n="text"===e.type?e.getNode():null,null!==o&&o.isSegmented()){const e=r.offset,s=o.getTextContentSize();if(o.is(n)||t&&e!==s||!t&&0!==e)return void rr(o,t,e)}else if(null!==n&&n.isSegmented()){const r=e.offset,s=n.getTextContentSize();if(n.is(o)||t&&0!==r||!t&&r!==s)return void rr(n,t,r)}!function(t,e){const n=t.anchor,o=t.focus,r=n.getNode(),s=o.getNode();if(r===s&&"text"===n.type&&"text"===o.type){const t=n.offset,s=o.offset,i=t0&&(g===h.getTextContentSize()||Zs(h)||([h]=h.splitText(g)),h.setFormat(p));for(let t=a+1;toi(t,e,o))}function qo(t){const e=t.offset;if("text"===t.type)return e;const n=t.getNode();return e===n.getChildrenSize()?n.getTextContent().length:0}function Xo(t){const e=t.getStartEndPoints();if(null===e)return[0,0];const[n,o]=e;return"element"===n.type&&"element"===o.type&&n.key===o.key&&n.offset===o.offset?[0,0]:[qo(n),qo(o)]}function Qo(t,e){for(let n=e;n;n=n.getParent()){if(as(n)){if(n.collapseAtStart(t))return!0;if(Xi(n))break}if(n.getPreviousSibling())break}return!1}function Zo(t){const e=t.focus,n=t.anchor,o=n.key,r=n.offset,s=n.type;n.set(e.key,e.offset,e.type,!0),e.set(o,r,s,!0)}function tr(t,e,n,o){t.modify(e,n,o)}function er(t,e,n){const o=t.getNodes(),r=o.filter(t=>ji(t,n));if(0===r.length||r.length===o.length)return!1;const s=e?r[0]:r[r.length-1],i=as(s)?s:s.getParentOrThrow();return e?i.selectStart():i.selectEnd(),!0}function nr(t,e,n){if(wr(t,"extend",e,n))return;const o=jr(),r=rl(Gi(o));if(!r||"function"!=typeof r.modify)return;const s=o._blockCursorElement,i=o._rootElement,l=t.anchor,c=t.focus.getNode();null===i||null===s||!as(c)||c.isInline()||c.canBeEmpty()||ol(s,o,i);const a=t=>{const e=t.getNode(),n=o.getElementByKey(t.key);return null!==n&&"text"===t.type&&wo(e)?Il(e,n,o):n},u=l.getNode(),f=a(l);if(null===f)return;const d=l.offset,h=t.isCollapsed(),g=t.focus,_=h?f:a(g);if(null===_)return;const p=g.offset;if(Tr(r,_,p,_,p),tr(r,"move",e?"backward":"forward",n),0===r.rangeCount)return;const m=dl(r,i)||r.getRangeAt(0),y=m.startContainer,x=m.startOffset;if(h&&"character"===n&&"text"===l.type&&wo(u)&&u.isUnmergeable()){if(d===(e?0:u.getTextContentSize())){const n=Rc(u,e?"previous":"next").getNodeAtCaret();if(wo(n)){const o=e?n.getTextContentSize()-1:1;return t.focus.set(n.__key,o,"text"),void(t.dirty=!0)}}}if(h&&"character"===n&&"text"===l.type){const n=e?0:u.getTextContentSize(),o=y===f?x:d!==n?n:-1;if(o>=0)return void(o!==d&&(t.focus.set(l.key,o,"text"),t.dirty=!0))}const[C,S,T,N]=e?[y,x,f,d]:[f,d,y,x],v=gs(u)?u:Vi(u);t.applyDOMRange({collapsed:!1,endContainer:T,endOffset:N,startContainer:C,startOffset:S}),t.dirty=!0,!er(t,e,v)&&e&&Zo(t),"lineboundary"===n&&wr(t,"extend",e,n,"decorators")}const or=(()=>{try{const t=new RegExp("\\p{Emoji}","u"),e=t.test.bind(t);if(e("\u2764\ufe0f")&&e("#\ufe0f\u20e3")&&e("\u{1f44d}"))return e}catch(t){}return()=>!1})();function rr(t,e,n){const o=t,r=o.getTextContent().split(/(?=\s)/g),s=r.length;let i=0,l=0;for(let t=0;tn||o){r.splice(t,1),o&&(l=void 0);break}}const c=r.join("").trim();""===c?o.remove():(o.setTextContent(c),o.select(l,l))}function sr(e,n,o,r){let s,i=n,l=!1;if(Sl(e)){let c=!1;const a=e.childNodes,u=a.length,f=r._blockCursorElement;i===u&&u>0&&(c=!0,i=u-1),void 0!==hi(e,r)||Hl(e,r)||(l=!0);let d=a[i],h=!1;if(d===f)d=a[i+1],h=!0;else if(null!==f){const t=f.parentNode;if(e===t){n>Array.prototype.indexOf.call(t.children,f)&&i--}}if(s=Ci(d),wo(s))i=Kc(s,c?"next":"previous");else{let a=Ci(e);if(null===a)return null;if(as(a)){const l=r.getElementByKey(a.getKey());null===l&&t(214);const u=Dl(a,l,r);[a,i]=u.resolveChildIndex(a,l,e,n),as(a)||t(215),c&&i>=a.getChildrenSize()&&(i=Math.max(0,a.getChildrenSize()-1));let f=a.getChildAtIndex(i);if(as(f)&&function(t,e,n){const o=t.getParent();return null===n||null===o||!o.canBeEmpty()||o!==n.getNode()}(f,0,o)){const t=c?f.getLastDescendant():f.getFirstDescendant();null===t?a=f:(f=t,a=as(f)?f:f.getParentOrThrow()),i=0}wo(f)?(s=f,a=null,i=Kc(f,c?"next":"previous")):f!==a&&c&&!h&&(as(a)||t(216),i=Math.min(a.getChildrenSize(),i+1))}else{const t=oc(a),o=null!==t?t:a,s=o.getIndexWithinParent(),l=r.getElementByKey(a.getKey());let c="after";if(null!==l&&Ci(e)===a){const t=Dl(a,l,r);t.element!==l?c=t.resolveLeafPosition(l,e,n):0===n&&ds(a)&&(c="before")}i="before"===c?s:s+1,a=o.getParentOrThrow()}if(as(a))return[Ko(a.__key,i,"element"),l]}}else s=Ci(e);return wo(s)?[Ko(s.__key,Kc(s,i,"clamp"),"text"),l]:null}function ir(t,e,n){const o=t.offset,r=t.getNode();if(0===o){const o=r.getPreviousSibling(),s=r.getParent();if(e){if((n||!e)&&null===o&&as(s)&&s.isInline()){const e=s.getPreviousSibling();wo(e)&&t.set(e.__key,e.getTextContent().length,"text")}}else as(o)&&!n&&o.isInline()?t.set(o.__key,o.getChildrenSize(),"element"):wo(o)&&!r.isUnmergeable()&&t.set(o.__key,o.getTextContent().length,"text")}else if(o===r.getTextContent().length){const o=r.getNextSibling(),s=r.getParent();if(e&&as(o)&&o.isInline())t.set(o.__key,0,"element");else if((n||e)&&null===o&&as(s)&&s.isInline()&&!s.canInsertTextAfter()&&s.getTextContentSize()>1){const e=s.getNextSibling();wo(e)&&t.set(e.__key,0,"text")}}}function lr(t){const e=ui(t.key);return null===e?null:sc(e)}function cr(t,e,n){const o=lr(t),r=lr(e);if(o===r||null!==o&&null!==r&&o.is(r))return!1;const s=n(o,r);if(null!==o)return as(o)?e.set(o.getKey(),s?o.getChildrenSize():0,"element"):e.set(o.getKey(),s?o.getTextContentSize():0,"text"),!0;const i=oc(r);if(null===i)return!1;const l=i.getParent();if(null===l)return!1;const c=i.getIndexWithinParent();return e.set(l.getKey(),s?c+1:c,"element"),!0}function ar(t){const e=cr(t.anchor,t.focus,(e,n)=>function(t,e,n,o){if(null!==n&&null!==o){const t=oc(n),e=oc(o);if(null!==t&&t.is(e)){for(const e of ic(t).values()){if(e===n.getKey())return!0;if(e===o.getKey())return!1}return!0}return null===t||null===e||t.isBefore(e)}if(null!==n){const t=oc(n),o=ui(e.key);return null===t||null===o||!(!t.is(o)&&!t.isParentOf(o))||t.isBefore(o)}const r=oc(o),s=ui(t.key);return null!==r&&null!==s&&!r.is(s)&&!r.isParentOf(s)&&s.isBefore(r)}(t.anchor,t.focus,e,n));return e&&(t.dirty=!0),e}function ur(t,e,n,o,r,s){if(null===t||null===n||!Js(r,t,n))return null;const i=sr(t,e,jo(s)?s.anchor:null,r);if(null===i)return null;const l=sr(n,o,jo(s)?s.focus:null,r);if(null===l)return null;const[c,a]=i,[u,f]=l;if("element"===c.type&&"element"===u.type){const e=Ci(t),o=Ci(n);if(ds(e)&&ds(o))return null}const d=r._slotsUsed&&cr(c,u,()=>0!==(t.compareDocumentPosition(n)&Node.DOCUMENT_POSITION_FOLLOWING));return function(t,e){if("text"===t.type&&"text"===e.type){const n=t.isBefore(e),o=t.is(e);ir(t,n,o),ir(e,!n,o),o&&e.set(t.key,t.offset,t.type)}}(c,u),[c,u,a||f||d]}function fr(t){return as(t)&&!t.isInline()}function dr(t,e,n,o,r,s){const i=Hr(),l=new Yo(Ko(t,e,r),Ko(n,o,s),0,"");return l.dirty=!0,i._selection=l,l}function hr(){const t=Ko("root",0,"element"),e=Ko("root",0,"element");return new Yo(t,e,0,"")}function gr(){return new Uo(new Set)}function _r(t,e,n,o){const r=n._window;if(null===r)return null;const s=o||r.event,i=s?s.type:void 0,l="selectionchange"===i,c=!q&&(l||"beforeinput"===i||"compositionstart"===i||"compositionend"===i||"click"===i&&s&&3===s.detail||"drop"===i||void 0===i);let a,u,f,d;if(jo(t)&&!c)return t.clone();{if(null===e)return null;const o=gl(e,n._rootElement);if(a=o.anchorNode,u=o.focusNode,f=o.anchorOffset,d=o.focusOffset,(l||void 0===i)&&jo(t)&&!Js(n,a,u))return t.clone()}const h=ur(a,f,u,d,n,t);if(null===h)return null;const[g,_,p]=h;let m=0,y="";if(jo(t)){const e=t.anchor;if(g.key===e.key)m=t.format,y=t.style;else{const t=g.getNode();wo(t)?(m=t.getFormat(),y=t.getStyle()):as(t)&&(m=t.getTextFormat(),y=t.getTextStyle())}}const x=new Yo(g,_,m,y);return p&&(x.dirty=!0),x}function pr(){return Hr()._selection}function mr(){return jr()._editorState._selection}function yr(t,e,n,o=1){const r=t.anchor,s=t.focus,i=r.getNode(),l=s.getNode();if(!e.is(i)&&!e.is(l))return;const c=e.__key;if(t.isCollapsed()){const e=r.offset;if(n<=e&&o>0||n0||n0||n=t,i=r?s.getChildAtIndex(t-1):s.getChildAtIndex(n);if(wo(i)){let t=0;r&&(t=i.getTextContentSize()),e.set(i.__key,t,"text"),o.set(i.__key,t,"text")}return}if(as(s)){const t=s.getChildrenSize(),o=n>=t,r=o?s.getChildAtIndex(t-1):s.getChildAtIndex(n);if(wo(r)){let t=0;o&&(t=r.getTextContentSize()),e.set(r.__key,t,"text")}}if(as(i)){const t=i.getChildrenSize(),e=r>=t,n=e?i.getChildAtIndex(t-1):i.getChildAtIndex(r);if(wo(n)){let t=0;e&&(t=n.getTextContentSize()),o.set(n.__key,t,"text")}}}function Cr(t,e,n,o,r){let s=null,i=0,l=null;null!==o?(s=o.__key,wo(o)?(i=o.getTextContentSize(),l="text"):as(o)&&(i=o.getChildrenSize(),l="element")):null!==r&&(s=r.__key,wo(r)?l="text":as(r)&&(l="element")),null!==s&&null!==l?t.set(s,i,l):(i=e.getIndexWithinParent(),-1===i&&(i=n.getChildrenSize()),t.set(n.__key,i,"element"))}function Sr(t,e,n,o,r){"text"===t.type?t.set(n,t.offset+(e?0:r),"text"):t.offset>o.getIndexWithinParent()&&t.set(t.key,t.offset-1,"element")}function Tr(t,e,n,o,r){try{t.setBaseAndExtent(e,n,o,r)}catch(t){}}function Nr(t,e,n){const o=$i(t,e.getKey());if(as(e)){const r=Dl(e,o,t);return[r.element,n+r.getFirstChildOffset()]}return[o,n]}function vr(t,e,n,o,r,i){const l=i.getRootNode(),c=ei(l)||il(l)?xl(l):null;if(r.has(ro)&&c!==i||null!==c&&Ys(c,c))return;const a=gl(o,i);let u;if(!jo(e))return void(null!==t&&Js(n,a.anchorNode,a.focusNode)&&o.removeAllRanges());const f=e.anchor,d=e.focus,h=f.getNode(),g=d.getNode(),[_,p]=Nr(n,h,f.offset),[m,y]=Nr(n,g,d.offset),x=e.format,C=e.style,S=e.isCollapsed();let T=_,N=m,v=!1;if("text"===f.type?(T=wo(h)?Il(h,_,n):null,v=h.getFormat()!==x||h.getStyle()!==C):jo(t)&&"text"===t.anchor.type&&(v=!0),"text"===d.type&&(N=wo(g)?Il(g,m,n):null),null!==T&&null!==N){if(S&&(null===t||v||jo(t)&&(t.format!==x||t.style!==C))&&function(t,e,n,o,r,s){t._inputState.collapsedSelectionFormat={format:e,key:r,offset:o,style:n,timeStamp:s}}(n,x,C,p,f.key,performance.now()),("Range"!==o.type||!S)&&a.anchorOffset===p&&a.focusOffset===y&&a.anchorNode===T&&a.focusNode===N){if(null===c||!i.contains(c)){const t=null!==c?qs(c):null;null!==t&&t!==n||r.has(lo)||i.focus({preventScroll:!0})}if("element"!==f.type)return}if(Tr(o,T,p,N,y),s&&e.isCollapsed()&&null!==i&&!r.has(lo)){const t=yl(i);if(null===t||!i.contains(t)){const t=xl(i.ownerDocument),e=null!==t?qs(t):null;null!==e&&e!==n||i.focus({preventScroll:!0})}}if(!r.has(so)&&e.isCollapsed()&&null!==i&&i===yl(i)){const t=jo(e)&&"element"===e.anchor.type?T.childNodes[p]||null:(void 0===u&&(u=hl(o,i)),u);if(null!==t){let e;if(ti(t)){const n=t.ownerDocument.createRange();n.selectNode(t),e=n.getBoundingClientRect()}else e=t.getBoundingClientRect();!function(t,e,n){const o=Wi(n),r=Yi(o);if(null===o||null===r)return;const s=n.getBoundingClientRect();if(e.bottoma&&(f=l-a),0!==f)if(e)r.scrollBy(0,f);else{const t=u.scrollTop;u.scrollTop+=f;const e=u.scrollTop-t;i-=e,l-=e}if(e)break;u=zi(u)}}(n,e,i)}}!function(t){t._inputState.isSelectionChangeFromDOMUpdate=!0}(n)}}function Er(t,e){for(const n of t.split(/(\r?\n|\t)/))"\n"===n||"\r\n"===n?e.linebreak():"\t"===n?e.tab():""!==n&&e.text(n)}function kr(t){const e=[];return Er(t,{linebreak:()=>e.push(Ts()),tab:()=>e.push(Fo()),text:t=>e.push(Do(t))}),e}function Or(t){const e=[];for(const n of t)Ns(n)||(!as(n)&&!ds(n)||n.isInline()?e.push(n):as(n)&&e.push(...Or(n.getChildren())));return e}function br(e){let n=e;e.isCollapsed()||n.removeText();const o=pr();jo(o)&&(n=o),jo(n)||t(161);const r=n.anchor;let s=r.getNode(),i=r.offset;for(;!bl(s)&&null===nc(s);){const t=s;if([s,i]=Mr(s,i),t.is(s))break}return i}function Mr(t,e){const n=t.getParent();if(!n){const t=Ms();return mi().append(t),t.select(),[mi(),0]}if(wo(t)){const o=t.splitText(e);if(0===o.length)return[n,t.getIndexWithinParent()];const r=0===e?0:1;return[n,o[0].getIndexWithinParent()+r]}if(!as(t)||0===e)return[n,t.getIndexWithinParent()];const o=t.getChildAtIndex(e);if(o){const n=new Yo(Ko(t.__key,e,"element"),Ko(t.__key,e,"element"),0,""),r=t.insertNewAfter(n);r&&r.append(o,...o.getNextSiblings())}return[n,t.getIndexWithinParent()+1]}function Ar(t){return Ns(t)||Ji(t)||wo(t)||t.isParentRequired()}function Dr(t){const e=Ms();let n=null;for(let o=0;o99&&t(14)}function Hr(){return null===Ir&&t(195,Gr()),Ir}function jr(){return null===Pr&&t(337,Gr()),Pr}function Yr(){jr()._dirtyType=2}function Gr(){let t=0;const e=new Set,n=Ks.version;if("undefined"!=typeof window)for(const o of al(document)){const r=Xs(o);if(Vs(r))t++;else if(r){let t=String(r.constructor.version||"<0.17.1");t===n&&(t+=" (separately built, likely a bundler configuration issue)"),e.add(t)}}let o=` Detected on the page: ${t} compatible editor(s) with version ${n}`;return e.size&&(o+=` and incompatible editors with versions ${Array.from(e).join(", ")}`),o}function Jr(){return Pr}function Vr(t,e,n){const o=e.__type,r=Us(t,o);let s=n.get(o);void 0===s&&(s=Array.from(r.transforms),n.set(o,s));const i=s.length;for(let t=0;t0&&os(t,t._deferred));const s=t._editorState,i=s._selection,l=n._selection,c=0!==t._dirtyType,a=Ir,u=Fr,f=Pr,d=t._updating,h=t._observer;let g=null;if(t._pendingEditorState=null,t._editorState=n,!r&&c&&null!==h){Pr=t,Ir=n,Fr=!1,t._updating=!0;try{const e=t._dirtyType,o=t._dirtyElements,r=t._dirtyLeaves;h.disconnect(),g=Ce(s,n,t,e,o,r)}catch(e){if(e instanceof Error&&t._onError(e),Rr)throw e;return Is(t,null,o,n),st(t),t._dirtyType=2,Rr=!0,ts(t,s),void(Rr=!1)}finally{h.observe(o,$r),t._updating=d,Ir=a,Fr=u,Pr=f}}n._readOnly||(n._readOnly=!0);const _=t._dirtyLeaves,p=t._dirtyElements,m=t._normalizedNodes,y=t._updateTags;c&&(t._dirtyType=0,t._cloneNotNeeded.clear(),t._dirtyLeaves=new Set,t._dirtyElements=new Map,t._normalizedNodes=new Set);t._updateTags=new Set,function(t,e){const n=t._decorators;let o=t._pendingDecorators||n;const r=e._nodeMap;let s;for(s in o)r.has(s)||(o===n&&(o=_i(t)),delete o[s])}(t,n);const x=r?null:rl(Gi(t));if(t._editable&&null!==x&&(c||null===l||l.dirty||!l.is(i))&&null!==o&&!y.has(io)){Pr=t,Ir=n;try{if(null!==h&&h.disconnect(),c||null===l||l.dirty){const e=t._blockCursorElement;null!==e&&ol(e,t,o),vr(i,l,t,x,y,o)}!function(t,e,n){let o=t._blockCursorElement;if(jo(n)&&n.isCollapsed()&&"element"===n.anchor.type&&e.contains(yl(e))){const r=n.anchor,s=r.getNode(),i=r.offset;let l=!1,c=null;if(i===s.getChildrenSize()){nl(s.getChildAtIndex(i-1))&&(l=!0)}else{const e=s.getChildAtIndex(i);if(null!==e&&nl(e)){const n=e.getPreviousSibling();(null===n||nl(n))&&(l=!0,c=t.getElementByKey(e.__key))}}if(l){const n=Dl(s,t.getElementByKey(s.__key),t).element;return null===o&&(t._blockCursorElement=o=function(t){const e=t.theme,n=fl().createElement("div");n.contentEditable="false",n.setAttribute("data-lexical-cursor","true");let o=e.blockCursor;if(void 0!==o){if("string"==typeof o){const t=ya(o);o=e.blockCursor=t}void 0!==o&&n.classList.add(...o)}return n}(t._config)),e.style.caretColor="transparent",void(null===c?n.appendChild(o):n.insertBefore(o,c))}}null!==o&&ol(o,t,e)}(t,o,l)}finally{null!==h&&h.observe(o,$r),Pr=f,Ir=a}}null!==g&&function(t,e,n,o,r){const s=Array.from(t._listeners.mutation),i=s.length;for(let t=0;t{Kr.delete(t),t._cascadeCount=0},0)}(t),t._cascadeCount++>99)return t._updates=[],t._cascadeCount=0,void t._onWarn(new Error(`One or more update listeners are endlessly enqueueing more updates. May have encountered infinite recursion caused by update listeners that trigger additional updates without a stop condition. Editor namespace: ${t._config.namespace}`));const n=e.shift();if(n){const[e,o]=n;ss(t,e,o)}}(t)}(t,e)}finally{Lr=n}}function es(t,e,n,...o){const r=e._updating;e._updating=n;try{const n=e._listeners[t],r=Array.from(n);for(const[t,e]of r){e&&e();const r=t(...o);n.has(t)?n.set(t,r):r&&r()}}finally{e._updating=r}}function ns(t,e,n,o){const r=Ti(t);let s;if(!Lr)for(let t=0;t=0;t--)for(let i=0;i0&&l._updating){s=l;break}const c=l._commands.get(e);if(void 0!==c){const e=c[t];if(e.size>0){let t=!1;if(is(l,()=>{for(const r of e)if(r(n,o))return void(t=!0)}),t)return t}}}return s&&s.update(()=>{ns(s,e,n,o)}),!1}function os(t,e){if(t._deferred=[],0!==e.length){const n=t._updating;t._updating=!0;try{for(let t=0;t0||u>0;){if(c>0){e._dirtyLeaves=new Set;for(const t of l){const o=r.get(t);wo(o)&&o.isAttached()&&o.isSimpleText()&&!o.isUnmergeable()&&Tt(o),void 0!==o&&qr(o,s)&&Vr(e,o,i),n.add(t)}if(l=e._dirtyLeaves,c=l.size,c>0){Br++;continue}}e._dirtyLeaves=new Set,e._dirtyElements=new Map,a.delete("root")&&a.set("root",!0);for(const t of a){const n=t[0],l=t[1];if(o.set(n,l),!l)continue;const c=r.get(n);void 0!==c&&qr(c,s)&&Vr(e,c,i)}l=e._dirtyLeaves,c=l.size,a=e._dirtyElements,u=a.size,Br++}e._dirtyLeaves=n,e._dirtyElements=o}(a,e),rs(e),function(t,e,n,o){const r=t._nodeMap,s=e._nodeMap,i=[];for(const[t]of o){const e=s.get(t);void 0!==e&&(e.isAttached()||(as(e)&&V(e,t,r,s,i,o),r.has(t)||o.delete(t),i.push(t)))}for(const t of n){const e=s.get(t);void 0===e||e.isAttached()||(tc(e)&&null!==e.__slots&&V(e,t,r,s,i,n),r.has(t)||n.delete(t),i.push(t))}for(const t of i)s.delete(t);const l=jr(),c=l._compositionKey;null===c||s.has(c)||(l._compositionKey=null)}(c,a,e._dirtyLeaves,e._dirtyElements));r!==e._compositionKey&&(a._flushSync=!0);const s=a._selection;if(jo(s)){e._slotsUsed&&ar(s);const n=a._nodeMap,o=s.anchor.key,r=s.focus.key;void 0!==n.get(o)&&void 0!==n.get(r)||t(19)}else Go(s)&&0===s._nodes.size&&(a._selection=null)}catch(t){return t instanceof Error&&e._onError(t),e._pendingEditorState=c,e._dirtyType=2,e._cloneNotNeeded.clear(),e._dirtyLeaves=new Set,e._dirtyElements.clear(),void ts(e)}finally{Ir=f,Fr=d,Pr=h,e._updating=g,Br=0}const p=0!==e._dirtyType||e._deferred.length>0||function(t,e){const n=e.getEditorState()._selection,o=t._selection;if(null!==o){if(o.dirty||!o.is(n))return!0}else if(null!==n)return!0;return!1}(a,e);p?a._flushSync?(a._flushSync=!1,ts(e)):u&&js(()=>{ts(e)}):(a._flushSync=!1,u&&(r.clear(),e._deferred=[],e._pendingEditorState=null))}function is(t,e,n){Pr===t&&void 0===n?zr()?ss(t,e,n):e():ss(t,e,n)}function ls(t){if(Xi(t)){let e=null;for(const n of t.getChildren())e=n.isInline()?(e||n.replace(n.createParentElementNode())).append(n):null}}class cs extends eo{__first;__last;__size;__format;__style;__indent;__dir;__textFormat;__textStyle;__slotHost;__slots;$config(){return this.config(Symbol.for("ElementNode"),{$transform:ls,extends:eo})}constructor(t){super(t),this.__first=null,this.__last=null,this.__size=0,this.__format=0,this.__style="",this.__indent=0,this.__dir=null,this.__textFormat=0,this.__textStyle="",this.__slotHost=null,this.__slots=null}afterCloneFrom(e){super.afterCloneFrom(e),this.__key===e.__key&&(this.__first=e.__first,this.__last=e.__last,this.__size=e.__size,this.__slotHost=e.__slotHost,null!==this.__slotHost&&null!==this.__parent&&t(384,this.__key,String(this.__slotHost),String(this.__parent)),this.__slots=e.__slots),this.__indent=e.__indent,this.__format=e.__format,this.__style=e.__style,this.__dir=e.__dir,this.__textFormat=e.__textFormat,this.__textStyle=e.__textStyle}getFormat(){return this.getLatest().__format}getFormatType(){const t=this.getFormat();return I[t]||""}getStyle(){return this.getLatest().__style}getIndent(){return this.getLatest().__indent}getChildren(){const t=[];let e=this.getFirstChild();for(;null!==e;)t.push(e),e=e.getNextSibling();return t}getChildrenKeys(){const t=[];let e=this.getFirstChild();for(;null!==e;)t.push(e.__key),e=e.getNextSibling();return t}getChildrenSize(){return this.getLatest().__size}isEmpty(){return 0===this.getChildrenSize()&&0===lc(this).length}isDirty(){const t=jr()._dirtyElements;return null!==t&&t.has(this.__key)}isLastChild(){const t=this.getLatest(),e=this.getParentOrThrow().getLastChild();return null!==e&&e.is(t)}getAllTextNodes(){const t=[];for(const e of lc(this)){const n=cc(this,e);as(n)&&t.push(...n.getAllTextNodes())}let e=this.getFirstChild();for(;null!==e;){if(wo(e)&&t.push(e),as(e)){const n=e.getAllTextNodes();t.push(...n)}e=e.getNextSibling()}return t}getFirstDescendant(){let t=this.getFirstChild();for(;as(t);){const e=t.getFirstChild();if(null===e)break;t=e}return t}getLastDescendant(){let t=this.getLastChild();for(;as(t);){const e=t.getLastChild();if(null===e)break;t=e}return t}getDescendantByIndex(t){const e=this.getChildren(),n=e.length;if(t>=n){const t=e[n-1];return as(t)&&t.getLastDescendant()||t||null}const o=e[t];return as(o)&&o.getFirstDescendant()||o||null}getFirstChild(){const t=this.getLatest().__first;return null===t?null:ui(t)}getFirstChildOrThrow(){const e=this.getFirstChild();return null===e&&t(45,this.__key),e}getLastChild(){const t=this.getLatest().__last;return null===t?null:ui(t)}getLastChildOrThrow(){const e=this.getLastChild();return null===e&&t(96,this.__key),e}getChildAtIndex(t){const e=this.getChildrenSize();let n,o;if(t=t;){if(o===t)return n;n=n.getPreviousSibling(),o--}return null}getTextContent(){let t=_c(this);const e=this.getChildren(),n=e.length;for(let o=0;ot.remove()),t}append(...t){return this.splice(this.getChildrenSize(),0,t)}setDirection(t){const e=this.getWritable();return e.__dir=t,e}setFormat(t){return this.getWritable().__format=""!==t&&w[t]||0,this}setStyle(t){return this.getWritable().__style=t||"",this}setTextFormat(t){const e=this.getWritable();return e.__textFormat=t,e}setTextStyle(t){const e=this.getWritable();return e.__textStyle=t,e}setIndent(t){return this.getWritable().__indent=t,this}splice(e,n,o){Zn(this)&&t(324,this.__key,this.__type);const r=this.getChildrenSize(),s=this.getWritable();e+n<=r||t(226,String(e),String(n),String(r));for(const t of o);const i=s.__key,l=[],c=[],a=this.getChildAtIndex(e+n);let u=null,f=r-n+o.length;if(0!==e)if(e===r)u=this.getLastChild();else{const t=this.getChildAtIndex(e);null!==t&&(u=t.getPreviousSibling())}if(n>0){let e=null===u?this.getFirstChild():u.getNextSibling();for(let o=0;o0&&(e.style.paddingInlineStart=40*t+"px",e.setAttribute("data-lexical-indent",String(t)));const n=this.getDirection();n&&(e.dir=n)}return{element:e}}exportJSON(){const t={children:[],direction:this.getDirection(),format:this.getFormatType(),indent:this.getIndent(),...super.exportJSON()},e=this.getTextFormat(),n=this.getTextStyle();return 0===e&&""===n||Xi(this)||this.getChildren().some(wo)||(0!==e&&(t.textFormat=e),""!==n&&(t.textStyle=n)),t}updateFromJSON(t){return super.updateFromJSON(t).setFormat(t.format).setIndent(t.indent).setDirection(t.direction).setTextFormat(t.textFormat||0).setTextStyle(t.textStyle||"")}insertNewAfter(t,e){return null}canIndent(){return!0}collapseAtStart(t){return!1}excludeFromCopy(t){return!1}canReplaceWith(t){return!0}canInsertAfter(t){return!0}canBeEmpty(){return!0}canInsertTextBefore(){return!0}canInsertTextAfter(){return!0}isInline(){return!1}isShadowRoot(){return!1}canMergeWith(t){return!1}extractWithChild(t,e,n){return!1}canMergeWhenEmpty(){return!1}reconcileObservedMutation(t,e){const n=Dl(this,t,e);let o=n.getFirstChild();for(let t=this.getFirstChild();t;t=t.getNextSibling()){const r=e.getElementByKey(t.getKey());null!==r&&(null==o?(n.insertChild(r),o=r):o!==r&&n.replaceChild(r,o),o=o.nextSibling)}}}function as(t){return t instanceof cs}function us(t,e,n){let o=t.getNode();for(;o;){const t=o.__key;if(e.has(t)&&!n.has(t))return!0;o=o.getParent()}return!1}class fs extends eo{__slotHost;__slots;constructor(t){super(t),this.__slotHost=null,this.__slots=null}afterCloneFrom(e){super.afterCloneFrom(e),this.__key===e.__key&&(this.__slotHost=e.__slotHost,null!==this.__slotHost&&null!==this.__parent&&t(383,this.__key,String(this.__slotHost),String(this.__parent)),this.__slots=e.__slots)}decorate(t,e){return null}isIsolated(){return!1}isInline(){return!0}isKeyboardSelectable(){return!0}}function ds(t){return t instanceof fs}class hs extends cs{__cachedText;$config(){return this.config("root",{extends:cs})}constructor(){super("root"),this.__cachedText=null}getTopLevelElementOrThrow(){t(51)}getTextContent(){const t=this.__cachedText;return null===t||!zr()&&0!==jr()._dirtyType?super.getTextContent():t}remove(){t(52)}replace(e){t(53)}insertBefore(e){t(54)}insertAfter(e){t(55)}updateDOM(t,e){return!1}splice(e,n,o){for(const e of o)as(e)||ds(e)||t(282);return super.splice(e,n,o)}static importJSON(t){return mi().updateFromJSON(t)}collapseAtStart(){return!0}}function gs(t){return t instanceof hs}function _s(t){return new ys(G(t._nodeMap),null,t._slotsUsed)}function ps(){return new ys(new Map([["root",new hs]]),null,!1)}function ms(e){const n=e.exportJSON(),o=e.constructor;if(n.type!==o.getType()&&t(130,o.name),as(e)){const r=n.children;Array.isArray(r)||t(59,o.name);const s=e.getChildren();for(let t=0;t0){const s={};for(const n of r){const r=cc(e,n);null===r&&t(366,o.name,n),s[n]=ms(r)}n.$slots=s}return n}class ys{_nodeMap;_selection;_flushSync;_readOnly;_parsed;_slotsUsed;constructor(t,e=null,n=!1){this._nodeMap=t,this._selection=e||null,this._flushSync=!1,this._readOnly=!1,this._parsed=!1,this._slotsUsed=n}isEmpty(){return 1===this._nodeMap.size&&null===this._selection}read(t,e){return Zr(e&&e.editor||null,this,t)}clone(t){const e=new ys(this._nodeMap,void 0===t?this._selection:t,this._slotsUsed);return e._readOnly=!0,e}toJSON(){return Zr(null,this,()=>({root:ms(mi())}))}}class xs extends cs{$config(){return this.config("artificial",{extends:cs})}createDOM(t){return fl().createElement("div")}}class Cs extends eo{$config(){return this.config("linebreak",{importDOM:{br:t=>vs(t)||Es(t)?null:{conversion:Ss,priority:0}}})}getTextContent(){return"\n"}createDOM(){return fl().createElement("br")}updateDOM(){return!1}isInline(){return!0}}function Ss(t){return{node:Ts()}}function Ts(){return Zi(new Cs)}function Ns(t){return t instanceof Cs}function vs(t){const e=t.parentElement;if(null!==e&&Ol(e)){const n=e.firstChild;if(n===t||n.nextSibling===t&&ks(n)){const n=e.lastChild;if(n===t||n.previousSibling===t&&ks(n))return!0}}return!1}function Es(t){const e=t.parentElement;if(null!==e&&Ol(e)){const n=e.firstChild;if(n===t||n.nextSibling===t&&ks(n))return!1;const o=e.lastChild;if(o===t||o.previousSibling===t&&ks(o))return!0}return!1}function ks(t){return ti(t)&&/^( |\t|\r?\n)+$/.test(t.textContent||"")}class Os extends cs{$config(){return this.config("paragraph",{extends:cs,importDOM:{p:()=>({conversion:bs,priority:0})}})}createDOM(t){const e=fl().createElement("p"),n=Pi(t.theme,"paragraph");if(void 0!==n){e.classList.add(...n)}return e}updateDOM(t,e,n){return!1}exportDOM(t){const{element:e}=super.exportDOM(t);if(Sl(e)){this.isEmpty()&&e.append(fl().createElement("br"));const t=this.getFormatType();t&&(e.style.textAlign=t)}return{element:e}}exportJSON(){const t=super.exportJSON();if(void 0===t.textFormat||void 0===t.textStyle){const e=this.getChildren().find(wo);e?(t.textFormat=e.getFormat(),t.textStyle=e.getStyle()):(t.textFormat=this.getTextFormat(),t.textStyle=this.getTextStyle())}return t}insertNewAfter(t,e){const n=Ms();n.setTextFormat(t.format),n.setTextStyle(t.style);const o=this.getDirection();return n.setDirection(o),n.setFormat(this.getFormatType()),n.setStyle(this.getStyle()),this.insertAfter(n,e),n}collapseAtStart(){const t=this.getChildren();if(0===t.length||wo(t[0])&&""===t[0].getTextContent().trim()){if(null!==this.getNextSibling())return this.selectNext(),this.remove(),!0;if(null!==this.getPreviousSibling())return this.selectPrevious(),this.remove(),!0}return!1}}function bs(t){const e=Ms();if($l(e,t),Kl(t,e),""===e.getFormatType()){const n=t.getAttribute("align");n&&n&&n in w&&e.setFormat(n)}return Bl(e,t),{node:e}}function Ms(){return Zi(new Os)}function As(t){return t instanceof Os}function Ds(t){console.warn(t)}const ws=0;function Is(t,e,n,o,r){const s=t._keyToDOMMap;s.clear(),t._editorState=ps(),t._pendingEditorState=o,t._compositionKey=null,t._dirtyType=0,t._cloneNotNeeded.clear(),t._dirtyLeaves=new Set,t._dirtyElements.clear(),t._normalizedNodes=new Set,r&&r.preserveUpdateQueue||(t._updateTags=new Set,t._updates=[],t._cascadeCount=0),t._blockCursorElement=null,null!==t._inputState.handledSelectionCommandTimeoutId&&clearTimeout(t._inputState.handledSelectionCommandTimeoutId),t._inputState={collapsedSelectionFormat:{format:0,key:"root",offset:0,style:"",timeStamp:0},compositionEndData:"",compositionPhase:"idle",hadOrphanedCompositionEvents:!1,handledSelectionCommandTimeoutId:null,isInsertLineBreak:!1,isInsertTextAfterHandledSelectionCommand:!1,isSelectionChangeFromDOMUpdate:!1,isSelectionChangeFromMouseDown:!1,lastBeforeInputInsertTextTimeStamp:0,lastKeyCode:null,lastKeyDownTimeStamp:0,postDeleteSelectionToRestore:null,unprocessedBeforeInputData:null};const i=t._observer;null!==i&&(i.disconnect(),t._observer=null),null!==e&&(e.textContent="",function(t,e){const n=`__lexicalKey_${e._key}`;delete t[n]}(e,t)),null!==n&&(n.textContent="",s.set("root",n),di(n,t,"root"))}function Ps(t){const e=new Set,n=new Set;for(const{klass:o,ownNodeConfig:r}of Vl(t)){const t=o.transform;if(!n.has(t)){n.add(t);const r=o.transform();r&&e.add(r)}if(r){const t=r.$transform;t&&e.add(t)}}return e}const Fs={$createDOM:(t,e)=>t.createDOM(e._config,e),$decorateDOM:(t,e,n,o)=>{},$exportDOM:(t,e)=>{const n=Hs(e,t.getType());return n&&void 0!==n.exportDOM?n.exportDOM(e,t):t.exportDOM(e)},$extractWithChild:(t,e,n,o,r)=>as(t)&&t.extractWithChild(e,n,o),$getDOMSlot:(t,e,n)=>t.getDOMSlot(e),$getSlotTargetElement:(t,e,n,o)=>null,$shouldExclude:(t,e,n)=>as(t)&&t.excludeFromCopy("html"),$shouldInclude:(t,e,n)=>!e||t.isSelected(e),$updateDOM:(t,e,n,o)=>t.updateDOM(e,n,o._config)};function Rs(t,e){const n=t.get(e);t.delete(e),n&&n()}function Ls(t,e,n){return t.set(e,n),Rs.bind(null,t,e)}class Ks{static version;_headless;_parentEditor;_rootElement;_editorState;_pendingEditorState;_compositionKey;_deferred;_keyToDOMMap;_updates;_updating;_cascadeCount;_listeners;_commands;_nodes;_decorators;_pendingDecorators;_config;_dirtyType;_cloneNotNeeded;_dirtyLeaves;_dirtyElements;_normalizedNodes;_updateTags;_observer;_key;_onError;_onWarn;_htmlConversions;_window;_editable;_blockCursorElement;_slotsUsed;_inputState;_createEditorArgs;constructor(t,e,n,o,r,s,i,l,c){this._createEditorArgs=c,this._parentEditor=e,this._rootElement=null,this._editorState=t,this._pendingEditorState=null,this._compositionKey=null,this._deferred=[],this._keyToDOMMap=new J,this._updates=[],this._updating=!1,this._cascadeCount=0,this._listeners={decorator:new Map,editable:new Map,mutation:new Map,root:new Map,textcontent:new Map,update:new Map},this._commands=new Map,this._config=o,this._nodes=n,this._decorators={},this._pendingDecorators=null,this._dirtyType=0,this._cloneNotNeeded=new Set,this._dirtyLeaves=new Set,this._dirtyElements=new Map,this._normalizedNodes=new Set,this._updateTags=new Set,this._observer=null,this._key=Ni(),this._onError=r,this._onWarn=s,this._htmlConversions=i,this._editable=l,this._headless=null!==e&&e._headless,this._window=null,this._blockCursorElement=null,this._slotsUsed=!1,this._inputState={collapsedSelectionFormat:{format:0,key:"root",offset:0,style:"",timeStamp:0},compositionEndData:"",compositionPhase:"idle",hadOrphanedCompositionEvents:!1,handledSelectionCommandTimeoutId:null,isInsertLineBreak:!1,isInsertTextAfterHandledSelectionCommand:!1,isSelectionChangeFromDOMUpdate:!1,isSelectionChangeFromMouseDown:!1,lastBeforeInputInsertTextTimeStamp:0,lastKeyCode:null,lastKeyDownTimeStamp:0,postDeleteSelectionToRestore:null,unprocessedBeforeInputData:null}}isComposing(){return null!=this._compositionKey}registerUpdateListener(t){return Ls(this._listeners.update,t)}registerEditableListener(t){return Ls(this._listeners.editable,t)}registerDecoratorListener(t){return Ls(this._listeners.decorator,t)}registerTextContentListener(t){return Ls(this._listeners.textcontent,t)}registerRootListener(t){const e=this._listeners.root;return xa(Ls(e,t,t(this._rootElement,null)||void 0),()=>function(t,e,n){const o=t.get(e);o&&o(),t.set(e,e(...n)||void 0)}(e,t,[null,this._rootElement]))}registerCommand(e,n,o){void 0===o&&t(35);const r=this._commands;r.has(e)||r.set(e,[new j,new j,new j,new j,new j]);const s=r.get(e);void 0===s&&t(36,String(e));const i=function(t){return 7&t}(o),l=s[i];return i!==o?l.addFront(n):l.addBack(n),()=>{l.delete(n),s.every(t=>0===t.size)&&r.delete(e)}}registerMutationListener(t,e,n){const o=this.resolveRegisteredNodeAfterReplacements(this.getRegisteredNode(t)).klass,r=this._listeners.mutation;let s=r.get(e);void 0===s&&(s=new Set,r.set(e,s)),s.add(o);const i=n&&n.skipInitialization;return void 0!==i&&i||this.initializeMutationListener(e,o),()=>{s.delete(o),0===s.size&&r.delete(e)}}getRegisteredNode(e){const n=this._nodes.get(e.getType());return void 0===n&&t(37,e.name),n}resolveRegisteredNodeAfterReplacements(t){for(;t.replaceWithKlass;)t=this.getRegisteredNode(t.replaceWithKlass);return t}initializeMutationListener(t,e){const n=this._editorState,o=Rl(n).get(e.getType());if(!o)return;const r=new Map;for(const t of o.keys())r.set(t,"created");r.size>0&&t(r,{dirtyLeaves:new Set,prevEditorState:n,updateTags:new Set(["registerMutationListener"])})}registerNodeTransformToKlass(t,e){const n=this.getRegisteredNode(t);return n.transforms.add(e),n}registerNodeTransform(t,e){const n=this.registerNodeTransformToKlass(t,e),o=[n],r=n.replaceWithKlass;if(null!=r){const t=this.registerNodeTransformToKlass(r,e);o.push(t)}return function(t,e){const n=Rl(t.getEditorState()),o=[];for(const t of e){const e=n.get(t);e&&o.push(e)}if(0===o.length)return;t.update(()=>{for(const t of o)for(const e of t.keys()){const t=ui(e);t&&t.markDirty()}},null===t._pendingEditorState?{tag:oo}:void 0)}(this,o.map(t=>t.klass.getType())),()=>{o.forEach(t=>t.transforms.delete(e))}}hasNode(t){return this._nodes.has(t.getType())}hasNodes(t){return t.every(this.hasNode.bind(this))}dispatchCommand(t,...e){return Bi(this,t,...e)}getDecorators(){return this._decorators}getRootElement(){return this._rootElement}getKey(){return this._key}setRootElement(t){const e=this._rootElement;if(t!==e){const n=Pi(this._config.theme,"root"),o=this._pendingEditorState||this._editorState;if(this._rootElement=t,Is(this,e,t,o,{preserveUpdateQueue:!0}),null!==e&&(this._config.disableEvents||qn(e),null!=n&&e.classList.remove(...n)),null!==t){const e=Yi(t),o=t.style;o.userSelect="text",o.whiteSpace="pre-wrap",o.wordBreak="break-word",t.setAttribute("data-lexical-editor","true"),this._window=e,this._dirtyType=2,st(this),this._updateTags.add(oo),ts(this),this._config.disableEvents||function(t,e){const n=t.ownerDocument;vn.set(t,n);let o=En.get(n);void 0===o&&(o={editors:new Set,hasShadowEditor:void 0},En.set(n,o)),o.editors.add(e),o.hasShadowEditor=void 0,t.__lexicalEditor=e;const r=Hn(t);r.push(kn.register(n));for(let n=0;n{Jn(t)||(Gn(t),(e.isEditable()||"click"===o)&&s(t,e))}:t=>{if(Jn(t))return;Gn(t);const n=e.isEditable();switch(o){case"cut":return n&&Bi(e,fn,t);case"copy":return Bi(e,un,t);case"paste":return n&&Bi(e,Pe,t);case"dragstart":return n&&Bi(e,ln,t);case"dragover":return n&&Bi(e,cn,t);case"dragend":return n&&Bi(e,an,t);case"focus":return n&&Bi(e,mn,t);case"blur":return n&&Bi(e,yn,t);case"drop":return n&&Bi(e,rn,t)}};r.push(Sn(t,o,i))}}(t,this),null!=n&&t.classList.add(...n)}else this._window=null,this._updateTags.add(oo),ts(this);es("root",this,!1,t,e)}}getElementByKey(t){return this._keyToDOMMap.get(t)||null}getEditorState(){return this._editorState}setEditorState(e,n){e.isEmpty()&&t(38);let o=e;o._readOnly&&(o=_s(e),o._selection=e._selection?e._selection.clone():null),rt(this);const r=this._pendingEditorState,s=void 0!==n?n.tag:null;null===r||r.isEmpty()||(null!=s&&this._updateTags.add(s),ts(this)),this._pendingEditorState=o,this._dirtyType=2,this._dirtyElements.set("root",!1),this._compositionKey=null,this._slotsUsed=this._slotsUsed||e._slotsUsed,is(this,()=>{if(s&&this._updateTags.add(s),e._parsed)for(const[t,e]of o._nodeMap.entries())as(e)?this._dirtyElements.set(t,!0):this._dirtyLeaves.add(t)},{discrete:!this._updating||void 0})}parseEditorState(t,e){return function(t,e,n){const o=ps(),r=Ir,s=Fr,i=Pr,l=e._dirtyElements,c=e._dirtyLeaves,a=e._cloneNotNeeded,u=e._dirtyType;e._dirtyElements=new Map,e._dirtyLeaves=new Set,e._cloneNotNeeded=new Set,e._dirtyType=0,Ir=o,Fr=!1,Pr=e,$s(null);try{const r=e._nodes;Qr(t.root,r),n&&n(),o._readOnly=!0,o._parsed=!0}catch(t){t instanceof Error&&e._onError(t)}finally{e._dirtyElements=l,e._dirtyLeaves=c,e._cloneNotNeeded=a,e._dirtyType=u,Ir=r,Fr=s,Pr=i}return o}("string"==typeof t?JSON.parse(t):t,this,e)}read(...t){const[e,n]=1===t.length?["force-commit",t[0]]:t;"force-commit"===e&&ts(this);return("pending"===e?this._pendingEditorState||this._editorState:this.getEditorState()).read(n,{editor:this})}update(t,e){!function(t,e,n){t._updating?t._updates.push([e,n]):ss(t,e,n)}(this,t,e)}focus(t,e={}){const n=this._rootElement;null!==n&&(n.setAttribute("autocapitalize","off"),is(this,()=>{const o=pr(),r=mi();null!==o?o.dirty||yi(o.clone()):0!==r.getChildrenSize()&&("rootStart"===e.defaultSelection?r.selectStart():r.selectEnd()),Ui("focus"),Hi(()=>{n.removeAttribute("autocapitalize"),t&&t()})}),null===this._pendingEditorState&&n.removeAttribute("autocapitalize"))}blur(){const t=this._rootElement;null!==t&&t.blur();const e=rl(this._window);null!==e&&e.removeAllRanges()}isEditable(){return this._editable}setEditable(t){this._editable!==t&&(this._editable=t,es("editable",this,!0,t),this._slotsUsed&&this.update(()=>Yr()))}toJSON(){return{editorState:this._editorState.toJSON()}}}Ks.version=H;let Bs=null;function $s(t){Bs=t}const zs=Symbol("INTERNAL_SKIP_AFTER_CLONE_FROM");let Ws=1;function Us(e,n){const o=Hs(e,n);return void 0===o&&t(30,n),o}function Hs(t,e){return t._nodes.get(e)}const js="function"==typeof queueMicrotask?queueMicrotask:t=>{Promise.resolve().then(t)};function Ys(t,e){const n=void 0!==e?e:(()=>{const e=t.getRootNode();return ei(e)||il(e)?xl(e):null})();if(!Sl(n))return!1;if(n.hasAttribute("data-lexical-slot"))return!1;const o=gi(n),r=n.nodeName;return no(o)&&("INPUT"===r||"TEXTAREA"===r||"true"===n.contentEditable&&null==Xs(n))}const Gs=Ys;function Js(t,e,n){const o=t.getRootElement();if(!o)return!1;try{if(!e||!o.contains(e)||!o.contains(n))return!1}catch(t){return!1}return qs(e)===t&&t.read("latest",()=>!Ys(e))}function Vs(t){return t instanceof Ks}function qs(t){let e=t;for(;null!=e;){const t=Xs(e);if(Vs(t))return t;e=zi(e)}return null}function Xs(t){return t?t.__lexicalEditor:null}function Qs(t){return Ro(t)||t.isToken()}function Zs(t){return Qs(t)||t.isSegmented()}function ti(t){return Tl(t)&&3===t.nodeType}function ei(t){return Tl(t)&&9===t.nodeType}function ni(t){let e=t;for(;null!=e;){if(ti(e))return e;e=e.firstChild}return null}function oi(t,e,n){const o=A[e];if(null!==n&&(t&o)===(n&o))return t;let r=t^o;return"subscript"===e?r&=~A.superscript:"superscript"===e?r&=~A.subscript:"lowercase"===e?(r&=~A.uppercase,r&=~A.capitalize):"uppercase"===e?(r&=~A.lowercase,r&=~A.capitalize):"capitalize"===e&&(r&=~A.lowercase,r&=~A.uppercase),r}function ri(t,e){const n=function(){const t=Bs;return Bs=null,t}();if(null!=(e=e||n&&n.__key))return void(t.__key=e);Wr(),Ur();const o=jr(),r=Hr(),s=""+Ws++;r._nodeMap.set(s,t),as(t)?o._dirtyElements.set(s,!0):o._dirtyLeaves.add(s),o._cloneNotNeeded.add(s),0===o._dirtyType&&(o._dirtyType=1),t.__key=s}function si(e){null!==nc(e)&&t(380,e.__key,String(nc(e)));const n=e.getParent();if(null!==n){const t=e.getWritable(),o=n.getWritable(),r=e.getPreviousSibling(),s=e.getNextSibling(),i=null!==s?s.__key:null,l=null!==r?r.__key:null,c=null!==r?r.getWritable():null,a=null!==s?s.getWritable():null;null===r&&(o.__first=i),null===s&&(o.__last=l),null!==c&&(c.__next=i),null!==a&&(a.__prev=l),t.__prev=null,t.__next=null,t.__parent=null,o.__size--}}const ii=si;function li(e){Ur(),Zn(e)&&t(323,e.__key,e.__type);const n=e.getLatest(),o=null!==n.__parent?n.__parent:ec(n)?n.__slotHost:null,r=Hr(),s=jr(),i=r._nodeMap,l=s._dirtyElements;null!==o&&function(t,e,n){let o=t;for(;null!==o;){if(n.has(o))return;const t=e.get(o);if(void 0===t)break;n.set(o,!1),o=null!==t.__parent?t.__parent:ec(t)?t.__slotHost:null}}(o,i,l);const c=n.__key;0===s._dirtyType&&(s._dirtyType=1),as(e)?l.set(c,!0):s._dirtyLeaves.add(c)}function ci(t){Wr();const e=jr(),n=e._compositionKey;if(t!==n){if(e._compositionKey=t,null!==n){const t=ui(n);null!==t&&t.getWritable()}if(null!==t){const e=ui(t);null!==e&&e.getWritable()}}}function ai(){if(zr())return null;return jr()._compositionKey}function ui(t,e){const n=(e||Hr())._nodeMap.get(t);return void 0===n?null:n}function fi(t,e){const n=hi(t,jr());return void 0!==n?ui(n,e):null}function di(t,e,n){t[`__lexicalKey_${e._key}`]=n}function hi(t,e){return t[`__lexicalKey_${e._key}`]}function gi(t,e){let n=t;for(;null!=n;){const t=fi(n,e);if(null!==t)return t;n=zi(n)}return null}function _i(t){const e=t._decorators,n=Object.assign({},e);return t._pendingDecorators=n,n}function pi(t){return t.read(()=>mi().getTextContent())}function mi(){return Hr()._nodeMap.get("root")}function yi(t){Wr();const e=Hr();null!==t&&(t.dirty=!0,t.setCachedNodes(null),jo(t)&&jr()._slotsUsed&&ar(t)),e._selection=t}function xi(){Wr();rt(jr())}function Ci(t){const e=function(t,e){let n=t;for(;null!=n;){const t=hi(n,e);if(void 0!==t)return t;n=zi(n)}return null}(t,jr());return null===e?null:ui(e)}function Si(t){return/[\uD800-\uDBFF][\uDC00-\uDFFF]/g.test(t)}function Ti(t){const e=[];for(let n=t;null!==n;n=n._parentEditor)e.push(n);return e}function Ni(){return Math.random().toString(36).replace(/[^a-z]+/g,"").substring(0,5)}function vi(t){return ti(t)?t.nodeValue:null}function Ei(t,e,n){const o=rl(Gi(e));if(null===o)return;const r=gl(o,e._rootElement),s=r.anchorNode;let{anchorOffset:i,focusOffset:l}=r;if(null!==s){let e=vi(s);const o=gi(s);if(null!==e&&wo(o)){if((e===N||e===E)&&n){const t=n.length;e=n,i=t,l=t}null!==e&&ki(o,e,i,l,t)}}}function ki(t,e,n,o,r){let s=t;if(s.isAttached()&&(r||!s.isDirty())){const i=s.isComposing();if(s.isToken()&&i)return;let c=e;if((i||r)&&(e.endsWith(N)&&(c=e.slice(0,-N.length)),r)){const t=E;let e;for(;-1!==(e=c.indexOf(t));)c=c.slice(0,e)+c.slice(e+t.length),null!==n&&n>e&&(n=Math.max(e,n-t.length)),null!==o&&o>e&&(o=Math.max(e,o-t.length))}const u=s.getTextContent();if(r||c!==u){const e=pr();if(""===c){if(ci(null),a||l||d)s.remove();else{const t=jr();Oi(s,"",e),setTimeout(()=>{t.update(()=>{s.isAttached()&&""===s.getTextContent()&&s.remove()})},20)}return}const r=s.getParent(),u=mr(),f=s.getTextContentSize(),h=ai(),g=s.getKey();if(s.isToken()&&!i||null!==h&&g===h&&!i||jo(u)&&(null!==r&&!r.canInsertTextBefore()&&0===u.anchor.offset||u.anchor.key===t.__key&&0===u.anchor.offset&&!s.canInsertTextBefore()&&!i||u.focus.key===t.__key&&u.focus.offset===f&&!s.canInsertTextAfter()&&!i))return void s.markDirty();if(!jo(e)||null===n||null===o)return void Oi(s,c,e);if(e.setTextNodeRange(s,n,s,o),s.isSegmented()){const t=Do(s.getTextContent());s.replace(t),s=t}Oi(s,c,e)}}}function Oi(t,e,n){if(t.setTextContent(e),jo(n)){const e=t.getKey();let o=!1;for(const r of["anchor","focus"]){const s=n[r];"text"===s.type&&s.key===e&&(s.offset=Kc(t,s.offset,"clamp"),o=!0)}o&&(n._cachedNodes=null,n._cachedIsBackward=null)}}function bi(t,e,n){const o=e[n]||!1;return"any"===o||o===t[n]}function Mi(t,e){return bi(t,e,"altKey")&&bi(t,e,"ctrlKey")&&bi(t,e,"shiftKey")&&bi(t,e,"metaKey")}function Ai(t,e,n){if(!Mi(t,n))return!1;if(t.key.toLowerCase()===e.toLowerCase())return!0;if(e.length>1)return!1;if(1===t.key.length&&t.key.charCodeAt(0)<=127)return!1;if(t.code.startsWith("Digit")&&/^\d$/.test(e))return t.code===`Digit${e}`;const o="Key"+e.toUpperCase();return t.code===o}const Di={ctrlKey:!r,metaKey:r},wi={altKey:r,ctrlKey:!r};function Ii(t){return"Backspace"===t.key}function Pi(t,e){void 0===t.__lexicalClassNameCache&&(t.__lexicalClassNameCache={});const n=t.__lexicalClassNameCache,o=n[e];if(void 0!==o)return o;const r=t[e];if("string"==typeof r){const t=ya(r);return n[e]=t,t}return r}function Fi(e,n,o,r,s){if(0===o.size)return;const i=r.__type,l=r.__key,c=n.get(i);void 0===c&&t(33,i);const a=c.klass;let u=e.get(a);void 0===u&&(u=new Map,e.set(a,u));const f=u.get(l),d="destroyed"===f&&"created"===s;(void 0===f||d)&&u.set(l,d?"updated":s)}function Ri(t,e,n){const o=t.getParent();let r=n,s=t;return null!==o&&(e&&0===n?(r=s.getIndexWithinParent(),s=o):e||n!==s.getChildrenSize()||(r=s.getIndexWithinParent()+1,s=o)),s.getChildAtIndex(e?r-1:r)}function Li(t,e){const n=t.offset;if("element"===t.type){return Ri(t.getNode(),e,n)}{const o=t.getNode();if(e&&0===n||!e&&n===o.getTextContentSize()){const t=e?o.getPreviousSibling():o.getNextSibling();return null===t?Ri(o.getParentOrThrow(),e,o.getIndexWithinParent()+(e?0:1)):t}}return null}function Ki(t){const e=Gi(t).event,n=e&&e.inputType;return"insertFromPaste"===n||"insertFromPasteAsQuotation"===n}function Bi(t,e,...n){return ns(t,e,n[0],t)}function $i(e,n){const o=e._keyToDOMMap.get(n);return void 0===o&&t(75,n),o}function zi(t){const e=t.assignedSlot||t.parentElement;if(null!==e)return e;const n=t.parentNode;return il(n)?n.host:null}function Wi(t){return ei(t)?t:Sl(t)?t.ownerDocument:null}function Ui(t){Wr();jr()._updateTags.add(t)}function Hi(t){Wr();jr()._deferred.push(t)}function ji(t,e){let n=t.getParent();for(;null!==n;){if(n.is(e))return!0;n=n.getParent()}return!1}function Yi(t){const e=Wi(t);return e?e.defaultView:null}function Gi(e){const n=e._window;return null===n&&t(78),n}function Ji(t){return as(t)&&t.isInline()||ds(t)&&t.isInline()}function Vi(t){let e=t.getLatest();for(;null!==e;){if(null!==nc(e)&&as(e))return e;const t=e.getParentOrThrow();if(Xi(t))return t;e=t}return e}function qi(t){return as(t)&&t.isShadowRoot()}function Xi(t){return gs(t)||qi(t)}function Qi(t,e=!1){const n=t.constructor.clone(t,zs);return ri(n,null),n.afterCloneFrom(t),e||n.resetOnCopyNodeFrom(t),n}function Zi(e){const n=jr(),o=e.getType(),r=Hs(n,o);void 0===r&&t(200,e.constructor.name,o);const{replace:s,replaceWithKlass:i}=r;if(null!==s){const n=s(e),r=n.constructor;return null!==i?n instanceof i||t(201,i.name,i.getType(),r.name,r.getType(),e.constructor.name,o):n instanceof e.constructor&&r!==e.constructor||t(202,r.name,r.getType(),e.constructor.name,o),n.__key===e.__key&&t(203,e.constructor.name,o,r.name,r.getType()),n}return e}function tl(e,n){!gs(e.getParent())||as(n)||ds(n)||t(99)}function el(e){const n=ui(e);return null===n&&t(63,e),n}function nl(t){if(!t||t.isInline())return!1;if(ds(t))return!0;if(as(t)){if(t.isShadowRoot()){const e=t.getParent();return!(as(e)&&e.isShadowRoot())}return!t.canBeEmpty()}return!1}function ol(t,e,n){n.style.removeProperty("caret-color"),e._blockCursorElement=null;const o=t.parentElement;null!==o&&o.removeChild(t)}function rl(t){return n?(t||window).getSelection():null}function sl(t){const e=Yi(t);return e?e.getSelection():null}function il(t){return Nl(t)&&"host"in t}const ll=[];function cl(t){const e=t.getRootNode();if(e===t||!il(e))return ll;const n=[e];let o=e.host;for(;;){const t=o.getRootNode();if(t===o||!il(t))break;n.push(t),o=t.host}return n}function*al(t){const e=[t];let n;for(;n=e.pop();){yield*n.querySelectorAll('[data-lexical-editor="true"]');const t=(ei(n)?n:n.ownerDocument).createTreeWalker(n,NodeFilter.SHOW_ELEMENT);let o;for(;o=t.nextNode();)o.shadowRoot&&e.push(o.shadowRoot)}}function ul(t){return null!==t?t.ownerDocument:document}function fl(){const t=Jr();return ul(null!==t?t._rootElement:null)}function dl(t,e){if(null===e||"function"!=typeof t.getComposedRanges)return null;const n=cl(e);if(0===n.length)return null;const o=t.getComposedRanges;try{const e=o.call(t,{shadowRoots:n})[0];if(void 0!==e)return e}catch(t){}try{const e=o.apply(t,n)[0];if(void 0!==e)return e}catch(t){}return null}function hl(t,e){const n=dl(t,e);if(null!==n){const t=_l(n);if(null!==t)return t}return t.rangeCount>0?t.getRangeAt(0):null}function gl(t,e){const n=dl(t,e);return null===n?t:pl(n,ml(t))}function _l(t){const e=t.startContainer.ownerDocument;if(null===e)return null;const n=e.createRange();try{return n.setStart(t.startContainer,t.startOffset),n.setEnd(t.endContainer,t.endOffset),n}catch(t){return null}}function pl(t,e){const{startContainer:n,startOffset:o,endContainer:r,endOffset:s}=t;return"backward"===e?{anchorNode:r,anchorOffset:s,direction:e,focusNode:n,focusOffset:o}:{anchorNode:n,anchorOffset:o,direction:e,focusNode:r,focusOffset:s}}function ml(t){return t.direction}function yl(t){const e=t.getRootNode();return ei(e)||il(e)?e.activeElement:null}function xl(t){let e=t.activeElement;for(;null!==e&&null!==e.shadowRoot;){const t=e.shadowRoot.activeElement;if(null===t)break;e=t}return e}function Cl(t){const e=t.target;if(null!==e&&Sl(e)&&null!==e.shadowRoot&&"function"==typeof t.composedPath){const e=t.composedPath();if(e.length>0)return e[0]}return e}function Sl(t){return Tl(t)&&1===t.nodeType}function Tl(t){return"object"==typeof t&&null!==t&&"nodeType"in t&&"number"==typeof t.nodeType}function Nl(t){return Tl(t)&&11===t.nodeType}const vl=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|mark|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var|#text)$/i;function El(t){return!(!Sl(t)||!t.style.display.startsWith("inline"))||vl.test(t.nodeName)}const kl=/^(address|article|aside|blockquote|canvas|dd|div|dl|dt|fieldset|figcaption|figure|footer|form|h1|h2|h3|h4|h5|h6|header|hr|li|main|nav|noscript|ol|p|pre|section|table|td|tfoot|ul|video)$/i;function Ol(t){return(!Sl(t)||!t.style.display.startsWith("inline"))&&kl.test(t.nodeName)}function bl(t){if(ds(t)&&!t.isInline())return!0;if(!as(t)||Xi(t))return!1;const e=t.getFirstChild(),n=null===e||Ns(e)||wo(e)||e.isInline();return!t.isInline()&&!1!==t.canBeEmpty()&&n}function Ml(){return jr()}function Al(t=Ml()){return t._config.dom||Fs}function Dl(e,n,o=Ml()){const r=Al(o).$getDOMSlot(e,n,o);return as(e)&&(wl(r)||t(344,e.getKey(),e.getType())),r}function wl(t){return t instanceof z}function Il(t,e,n=Ml()){return ni(Dl(t,e,n).element)}const Pl=new WeakMap,Fl=new Map;function Rl(e){if(!e._readOnly&&e.isEmpty())return Fl;e._readOnly||t(192);let n=Pl.get(e);return n||(n=function(t){const e=new Map;for(const[n,o]of t._nodeMap){const t=o.__type;let r=e.get(t);r||(r=new Map,e.set(t,r)),r.set(n,o)}return e}(e),Pl.set(e,n)),n}function Ll(t){const e=t.constructor.clone(t,zs);return e.afterCloneFrom(t),e}function Kl(t,e){const n=t.getAttribute("data-lexical-indent");if(null!==n){const t=parseInt(n,10);if(Number.isFinite(t)&&t>=0)return void e.setIndent(t)}const o=parseInt(t.style.paddingInlineStart,10)||0,r=Math.round(o/40);e.setIndent(r)}function Bl(t,e){const n=e.getAttribute("dir");return"ltr"===n||"rtl"===n?t.setDirection(n):t}function $l(t,e){const n=e.style.textAlign;return n&&n in w?t.setFormat(n):t}function zl(t,e){t.__lexicalUnmanaged=!0,e&&void 0!==e.captureSelection&&(t.__lexicalCapturedSelection=e.captureSelection)}function Wl(t){return!0===t.__lexicalUnmanaged}function Ul(t,e=Ml()){const n=e.isEditable();t.contentEditable=n?"true":"false",n?t.__lexicalEditor=e:delete t.__lexicalEditor}function Hl(t,e){let n=t;for(;null!=n;){if(!0===n.__lexicalCapturedSelection)return!0;if(Sl(n)&&n.hasAttribute("data-lexical-slot"))return!1;if(void 0!==hi(n,e))return!1;n=zi(n)}return!1}function jl(t,e){return function(t,e){return Object.prototype.hasOwnProperty.call(t,e)}(t,e)&&t[e]!==eo[e]}const Yl=new WeakMap,Gl=Symbol("lexical.synthesizedGetType");function Jl(e){const n=Yl.get(e);if(n)return n;const o=null!=e.prototype&&R in e.prototype?e.prototype[R]():void 0,r=function(e){if(!(e===eo||e.prototype instanceof eo)){let n="",o="";try{n=e.getType()}catch(t){}try{Ks.version&&(o=JSON.parse(Ks.version))}catch(t){}t(290,e.name,n,o)}return e===fs||e===cs||e===eo}(e),s=!r&&jl(e,"getType")?e.getType:void 0,i=s&&!(Gl in s)?s.call(e):void 0;let l,c=i;if(o)if(i)l=o[i];else{for(const[t,e]of Object.entries(o))c=t,l=e;if(!l)for(const t of Object.getOwnPropertySymbols(o)){const e=o[t];if(e){l=e;break}}}if(!r&&c){if(!jl(e,"getType")){const t=e,n=function(){return this!==t?eo.getType.call(this):c};n[Gl]=!0,e.getType=n}if(jl(e,"clone")||(e.clone=(t,n)=>{$s(t);const o=new e;return n!==zs&&o.afterCloneFrom(t),o}),jl(e,"importJSON")||(e.importJSON=l&&l.$importJSON||(t=>(new e).updateFromJSON(t))),!jl(e,"importDOM")&&l){const{importDOM:t}=l;t&&(e.importDOM=()=>t)}}const a={klass:e,ownNodeConfig:l,ownNodeType:c};return Yl.set(e,a),a}function*Vl(t){for(let e=t;e&&(e===eo||no(e.prototype));){const t=Jl(e);yield t,e=t.ownNodeConfig&&t.ownNodeConfig.extends||Ql(e)}}const ql=(t,e)=>{let n=t;for(;null!=n&&!gs(n);){if(e(n))return n;n=n.getParent()}return null};function Xl(e,n){const o=[];let r=e.__first;for(;null!==r;){const e=null===n?ui(r):n.get(r);null==e&&t(174),o.push(r),r=e.__next}return o}function Ql(t){const e=Object.getPrototypeOf(t);if("function"==typeof e&&e!==Function.prototype)return e;const n=t.prototype&&Object.getPrototypeOf(t.prototype);return n?n.constructor:null}const Zl=new Map;function tc(t){return as(t)||ds(t)}function ec(t){return as(t)||ds(t)}function nc(t){const e=t.getLatest();return ec(e)?e.__slotHost:null}function oc(e){const n=nc(e);if(null===n)return null;const o=ui(n);return as(o)||ds(o)||t(370),o}function rc(t){const e=oc(t);if(null===e)return null;const n=t.getLatest().__key;for(const[t,o]of ic(e))if(o===n)return t;return null}function sc(t){let e=t.getLatest();for(;null!==e;){if(null!==nc(e))return e;e=e.getParent()}return null}function ic(t){const e=t.getLatest();return tc(e)&&null!==e.__slots?e.__slots:Zl}function lc(t){return Array.from(ic(t).keys())}function cc(t,e){const n=ic(t).get(e);return void 0===n?null:ui(n)}const ac=["__proto__","constructor","prototype"],uc=Symbol("slotMapOwner");function fc(t){let e=t.__slots;return null!==e&&e[uc]===t||(e=new Map(e),e[uc]=t,t.__slots=e),e}const dc=new WeakMap,hc=[];function gc(t){for(const{ownNodeConfig:e}of Vl(t)){const t=e&&e.slots;if(t)return t}return hc}function _c(t){let e="";for(const n of lc(t)){const o=cc(t,n);null!==o&&(e+=o.getTextContent())}return e}function pc(t,e,n){const o=n.get(t),r=n.get(e);return void 0!==o?void 0!==r?o-r:-1:void 0!==r?1:te?1:0}function mc(e){const n=e.__slots;if(null===n||n.size<2)return;const o=function(e){let n=dc.get(e);if(void 0===n){const o=gc(e),r=new Map;for(const n of o)ac.includes(n)&&t(371,e.name,n),r.has(n)&&t(372,e.name,n),r.set(n,r.size);n=r,dc.set(e,n)}return n}(e.constructor);let r=null,s=!0;for(const t of n.keys()){if(null!==r&&pc(r,t,o)>0){s=!1;break}r=t}if(s)return;const i=Array.from(n).sort(([t],[e])=>pc(t,e,o));n.clear();for(const[t,e]of i)n.set(t,e)}function yc(e,n,o){"__proto__"!==n&&"constructor"!==n&&"prototype"!==n||t(373,n);const r=e.getLatest();if(null!==r.__slots&&r.__slots.get(n)===o.getLatest().__key)return r;(!as(o)&&!ds(o)||o.isInline())&&t(374,o.__key);const s=e.getWritable(),i=fc(s),l=i.get(n);void 0!==l&&Sc(l);const c=o.getWritable(),a=oc(c);if(null!==a){const t=rc(c);null!==t&&fc(a.getWritable()).delete(t),c.__slotHost=null}return si(c),c.__slotHost=s.__key,i.set(n,c.__key),mc(s),function(){const t=Ml();t._slotsUsed=!0,t._pendingEditorState&&(t._pendingEditorState._slotsUsed=!0)}(),s}function xc(t,e){const n=t.getWritable();if(null===n.__slots)return n;const o=n.__slots.get(e);return void 0!==o&&(Sc(o),fc(n).delete(e)),n}function Cc(t,e){}function Sc(e){const n=ui(e);if(null===n)return;const o=n.getWritable();ec(o)||t(377,e),o.__slotHost=null,o.remove()}const Tc={next:"previous",previous:"next"};class Nc{origin;constructor(t){this.origin=t}[Symbol.iterator](){return Jc({hasNext:Dc,initial:this.getAdjacentCaret(),map:t=>t,step:t=>t.getAdjacentCaret()})}getAdjacentCaret(){return Rc(this.getNodeAtCaret(),this.direction)}getSiblingCaret(){return Rc(this.origin,this.direction)}remove(){const t=this.getNodeAtCaret();return t&&t.remove(),this}replaceOrInsert(t,e){const n=this.getNodeAtCaret();return t.is(this.origin)||t.is(n)||(null===n?this.insert(t):n.replace(t,e)),this}splice(e,n,o="next"){const r=o===this.direction?n:Array.from(n).reverse();let s=this;const i=this.getParentAtCaret(),l=new Map;for(let t=s.getAdjacentCaret();null!==t&&l.size0){const n=s.getNodeAtCaret();if(n)if(l.delete(n.getKey()),l.delete(e.getKey()),n.is(e)||s.origin.is(e));else{const t=e.getParent();t&&t.is(i)&&e.remove(),n.replace(e)}else null===n&&t(263,Array.from(l).join(" "))}else s.insert(e);s=Rc(e,this.direction)}for(const t of l.values())t.remove();return this}}class vc extends Nc{type="child";getLatest(){const t=this.origin.getLatest();return t===this.origin?this:$c(t,this.direction)}getParentCaret(t="root"){return Rc(Oc(this.getParentAtCaret(),t),this.direction)}getFlipped(){const t=kc(this.direction);return Rc(this.getNodeAtCaret(),t)||$c(this.origin,t)}getParentAtCaret(){return this.origin}getChildCaret(){return this}isSameNodeCaret(t){return t instanceof vc&&this.direction===t.direction&&this.origin.is(t.origin)}isSamePointCaret(t){return this.isSameNodeCaret(t)}}const Ec={root:gs,shadowRoot:Xi};function kc(t){return Tc[t]}function Oc(t,e="root"){return null===t||Ec[e](t)?null:null===nc(t)?t:null}class bc extends Nc{type="sibling";getLatest(){const t=this.origin.getLatest();return t===this.origin?this:Rc(t,this.direction)}getSiblingCaret(){return this}getParentAtCaret(){return this.origin.getParent()}getChildCaret(){return as(this.origin)?$c(this.origin,this.direction):null}getParentCaret(t="root"){return Rc(Oc(this.getParentAtCaret(),t),this.direction)}getFlipped(){const t=kc(this.direction);return Rc(this.getNodeAtCaret(),t)||$c(this.origin.getParentOrThrow(),t)}isSamePointCaret(t){return t instanceof bc&&this.direction===t.direction&&this.origin.is(t.origin)}isSameNodeCaret(t){return(t instanceof bc||t instanceof Mc)&&this.direction===t.direction&&this.origin.is(t.origin)}}class Mc extends Nc{type="text";offset;constructor(t,e){super(t),this.offset=e}getLatest(){const t=this.origin.getLatest();return t===this.origin?this:Lc(t,this.direction,this.offset)}getParentAtCaret(){return this.origin.getParent()}getChildCaret(){return null}getParentCaret(t="root"){return Rc(Oc(this.getParentAtCaret(),t),this.direction)}getFlipped(){return Lc(this.origin,kc(this.direction),this.offset)}isSamePointCaret(t){return t instanceof Mc&&this.direction===t.direction&&this.origin.is(t.origin)&&this.offset===t.offset}isSameNodeCaret(t){return(t instanceof bc||t instanceof Mc)&&this.direction===t.direction&&this.origin.is(t.origin)}getSiblingCaret(){return Rc(this.origin,this.direction)}}function Ac(t){return t instanceof Mc}function Dc(t){return t instanceof bc}function wc(t){return t instanceof vc}const Ic={next:class extends Mc{direction="next";getNodeAtCaret(){return this.origin.getNextSibling()}insert(t){return this.origin.insertAfter(t),this}},previous:class extends Mc{direction="previous";getNodeAtCaret(){return this.origin.getPreviousSibling()}insert(t){return this.origin.insertBefore(t),this}}},Pc={next:class extends bc{direction="next";getNodeAtCaret(){return this.origin.getNextSibling()}insert(t){return this.origin.insertAfter(t),this}},previous:class extends bc{direction="previous";getNodeAtCaret(){return this.origin.getPreviousSibling()}insert(t){return this.origin.insertBefore(t),this}}},Fc={next:class extends vc{direction="next";getNodeAtCaret(){return this.origin.getFirstChild()}insert(t){return this.origin.splice(0,0,[t]),this}},previous:class extends vc{direction="previous";getNodeAtCaret(){return this.origin.getLastChild()}insert(t){return this.origin.splice(this.origin.getChildrenSize(),0,[t]),this}}};function Rc(t,e){return t?new Pc[e](t):null}function Lc(t,e,n){return t?new Ic[e](t,Kc(t,n)):null}function Kc(t,n,o="error"){const r=t.getTextContentSize();let s="next"===n?r:"previous"===n?0:n;return(s<0||s>r)&&("clamp"!==o&&e(284,String(n),String(r),t.getKey()),s=s<0?0:r),s}function Bc(t,e){return new Hc(t,e)}function $c(t,e){return as(t)?new Fc[e](t):null}function zc(t){return t&&t.getChildCaret()||t}function Wc(t){return t&&zc(t.getAdjacentCaret())}class Uc{type="node-caret-range";direction;anchor;focus;constructor(t,e,n){this.anchor=t,this.focus=e,this.direction=n}getLatest(){const t=this.anchor.getLatest(),e=this.focus.getLatest();return t===this.anchor&&e===this.focus?this:new Uc(t,e,this.direction)}isCollapsed(){return this.anchor.isSamePointCaret(this.focus)}getTextSlices(){const t=t=>{const e=this[t].getLatest();return Ac(e)?function(t,e){const{direction:n,origin:o}=t,r=Kc(o,"focus"===e?kc(n):n);return Bc(t,r-t.offset)}(e,t):null},e=t("anchor"),n=t("focus");if(e&&n){const{caret:t}=e,{caret:o}=n;if(t.isSameNodeCaret(o))return[Bc(t,o.offset-t.offset),null]}return[e,n]}iterNodeCarets(t="root"){const e=Ac(this.anchor)?this.anchor.getSiblingCaret():this.anchor.getLatest(),n=this.focus.getLatest(),o=Ac(n),r=e=>e.isSameNodeCaret(n)?null:Wc(e)||e.getParentCaret(t);return Jc({hasNext:t=>null!==t&&!(o&&n.isSameNodeCaret(t)),initial:e.isSameNodeCaret(n)?null:r(e),map:t=>t,step:r})}[Symbol.iterator](){return this.iterNodeCarets("root")}}class Hc{type="slice";caret;distance;constructor(t,e){this.caret=t,this.distance=e}getSliceIndices(){const{distance:t,caret:{offset:e}}=this,n=e+t;return n{let n;for(let o=c;on.has(t.getKey())&&bl(t));if(f&&lc(f).length>0)return null;return u&&f?[u,f]:null}(d,h,a);if(g){const[t,e]=g;$c(t,"previous").splice(0,e.getChildren());let n=e.getParent();for(e.remove(!0);n&&n.isEmpty();){const t=n;n=n.getParent(),t.remove(!0)}}else if(h){const t=function(t){if(wc(t)){const e=t.origin;if(bl(e))return e}else{const e=t.getParentAtCaret();if(e&&bl(e))return e}return null}(h),e=t&&t.getParent(),n=t&&t.getParents().findLast(qi);if(t&&e&&!gs(e)&&t.isEmpty()&&a.has(t.getKey())&&0===lc(t).length&&(!n||a.has(n.getKey()))){t.remove(!0);let n=e;for(;n&&!gs(n)&&n.isEmpty();){const t=n.getParent();if(t&&gs(t)&&t.getChildrenSize()<=1)break;const e=n;n=t,e.remove(!0)}}}const _=[d,h,...l,...c].find(la);if(_){return Yc(fa(aa(_),e.direction))}t(269,JSON.stringify(l.map(t=>t.origin.__key)))}function aa(t){const e=function(t){let e=t;for(;wc(e);){const t=Wc(e);if(!wc(t))break;e=t}return e}(t.getLatest()),{direction:n}=e;if(wo(e.origin))return Ac(e)?e:Lc(e.origin,n,n);const o=e.getAdjacentCaret();return Dc(o)&&wo(o.origin)?Lc(o.origin,n,kc(n)):e}function ua(t){return Ac(t)&&t.offset!==Kc(t.origin,t.direction)}function fa(t,e){return t.direction===e?t:t.getFlipped()}function da(t,e){return t.direction===e?t:Gc(fa(t.focus,e),fa(t.anchor,e))}function ha(t,e,n){let o=$c(t,"next");for(let t=0;t0||!s&&n.canBeEmpty()&&r(n,"last"))&&i.insert(e(n).splice(0,0,o))}return i}function ma(e,n,o){let r=fa(n,"next");Ac(r)&&(0===r.offset?r=Rc(r.origin,"previous").getFlipped():r.offset===r.origin.getTextContentSize()&&(r=Rc(r.origin,"next"))),r.origin.is(e)&&(Dc(r)||t(342,e.getKey(),e.getType()),r=sa(r)),(e.is(r.getNodeAtCaret())||e.is(r.getFlipped().getNodeAtCaret()))&&e.remove(!0);for(let t=r;t;t=pa(t,o))r=t;return Ac(r)&&t(283),r.insert(e.isInline()?Ms().append(e):e),fa(Rc(e.getLatest(),"next"),n.direction)}function ya(...t){const e=[];for(const n of t)if(n&&"string"==typeof n)for(const[t]of n.matchAll(/\S+/g))e.push(t);return e}function xa(...t){return()=>{for(let e=t.length-1;e>=0;e--)t[e]();t.length=0}}exports.$addUpdateTag=Ui,exports.$applyNodeReplacement=Zi,exports.$assumeActiveEditor=function(t){null!==Hr()&&null===Pr&&(Pr=t),Pr!==t&&e(378)},exports.$caretFromPoint=ta,exports.$caretRangeFromSelection=ra,exports.$cloneWithProperties=Ll,exports.$cloneWithPropertiesEphemeral=function(t){return(e=Ll(t))[Qn]=!0,e;var e},exports.$comparePointCaretNext=Vc,exports.$copyNode=Qi,exports.$create=function(t){const e=Ml();return Wr(),new(e.resolveRegisteredNodeAfterReplacements(e.getRegisteredNode(t)).klass)},exports.$createChildrenArray=Xl,exports.$createLineBreakNode=Ts,exports.$createNodeSelection=gr,exports.$createParagraphNode=Ms,exports.$createPoint=Ko,exports.$createRangeSelection=hr,exports.$createRangeSelectionFromDom=function(t,e){return _r(null,t,e,null)},exports.$createTabNode=Fo,exports.$createTextNode=Do,exports.$extendCaretToRange=jc,exports.$findMatchingParent=ql,exports.$formatText=Vo,exports.$fullReconcile=Yr,exports.$generateNodesFromRawText=kr,exports.$getAdjacentChildCaret=Wc,exports.$getAdjacentNode=Li,exports.$getAdjacentSiblingOrParentSiblingCaret=function(t,e="root"){let n=0,o=t,r=Wc(o);for(;null===r;){if(n--,r=o.getParentCaret(e),!r)return null;o=r,r=Wc(o)}return r&&[r,n]},exports.$getCaretInDirection=fa,exports.$getCaretRange=Gc,exports.$getCaretRangeInDirection=da,exports.$getCharacterOffsets=Xo,exports.$getChildCaret=$c,exports.$getChildCaretAtIndex=ha,exports.$getChildCaretOrSelf=zc,exports.$getCollapsedCaretRange=Yc,exports.$getCommonAncestor=Zc,exports.$getCommonAncestorResultBranchOrder=qc,exports.$getDOMSlot=Dl,exports.$getDOMTextNode=Il,exports.$getDocument=fl,exports.$getEditor=Ml,exports.$getEditorDOMRenderConfig=Al,exports.$getNearestNodeFromDOMNode=gi,exports.$getNearestRootOrShadowRoot=Vi,exports.$getNodeByKey=ui,exports.$getNodeByKeyOrThrow=el,exports.$getNodeFromDOMNode=fi,exports.$getPreviousSelection=mr,exports.$getRoot=mi,exports.$getSelection=pr,exports.$getSiblingCaret=Rc,exports.$getSlot=cc,exports.$getSlotFrame=sc,exports.$getSlotHost=oc,exports.$getSlotNameWithinHost=rc,exports.$getSlotNames=lc,exports.$getState=at,exports.$getStateChange=function(t,e,n){const o=at(t,n,it),r=at(e,n,it);return n.isEqual(o,r)?null:[o,r]},exports.$getTextContent=function(){const t=pr();return null===t?"":t.getTextContent()},exports.$getTextNodeOffset=Kc,exports.$getTextPointCaret=Lc,exports.$getTextPointCaretSlice=Bc,exports.$getWritableNodeState=ht,exports.$hasAncestor=ji,exports.$hasUpdateTag=function(t){return jr()._updateTags.has(t)},exports.$insertNodeToNearestRootAtCaret=ma,exports.$insertNodes=function(t){let e=pr()||mr();null===e&&(e=mi().selectEnd()),e.insertNodes(t)},exports.$isBlockElementNode=fr,exports.$isChildCaret=wc,exports.$isDecoratorNode=ds,exports.$isEditorState=function(t){return t instanceof ys},exports.$isElementDOMSlot=wl,exports.$isElementNode=as,exports.$isExtendableTextPointCaret=ua,exports.$isInlineElementOrDecoratorNode=Ji,exports.$isInlineFormattable=So,exports.$isLeafNode=function(t){return wo(t)||Ns(t)||ds(t)},exports.$isLexicalNode=no,exports.$isLineBreakNode=Ns,exports.$isNodeCaret=function(t){return t instanceof Nc},exports.$isNodeSelection=Go,exports.$isParagraphNode=As,exports.$isRangeSelection=jo,exports.$isRootNode=gs,exports.$isRootOrShadowRoot=Xi,exports.$isSelectionCapturedInDecoratorInput=Ys,exports.$isShadowRootNode=qi,exports.$isSiblingCaret=Dc,exports.$isSlotChild=ec,exports.$isSlotHost=tc,exports.$isTabNode=Ro,exports.$isTextNode=wo,exports.$isTextPointCaret=Ac,exports.$isTextPointCaretSlice=function(t){return t instanceof Hc},exports.$isTokenOrSegmented=Zs,exports.$isTokenOrTab=Qs,exports.$markSlotEditable=Ul,exports.$needsBlockCursorBeside=nl,exports.$nodesOfType=function(t){const e=t.getType(),n=Hr();if(n._readOnly){const t=Rl(n).get(e);return t?Array.from(t.values()):[]}const o=n._nodeMap,r=[];for(const[,n]of o)n instanceof t&&n.__type===e&&n.isAttached()&&r.push(n);return r},exports.$normalizeCaret=aa,exports.$normalizeSelection__EXPERIMENTAL=Nt,exports.$onUpdate=Hi,exports.$parseSerializedNode=function(t){return Qr(t,jr()._nodes)},exports.$removeFromParent=si,exports.$removeSlot=xc,exports.$removeTextFromCaretRange=ca,exports.$rewindSiblingCaret=sa,exports.$selectAll=function(t){const e=mi();if(jo(t)){const e=t.anchor,n=t.focus,o=e.getNode();if(gs(o))return e.set(o.getKey(),0,"element"),n.set(o.getKey(),o.getChildrenSize(),"element"),Nt(t),t;const r=o.getTopLevelElementOrThrow(),s=r.getParent();if(null===s)return as(r)&&(e.set(r.getKey(),0,"element"),n.set(r.getKey(),r.getChildrenSize(),"element"),Nt(t)),t;const i=s;return e.set(i.getKey(),0,"element"),n.set(i.getKey(),i.getChildrenSize(),"element"),Nt(t),t}{const t=e.select(0,e.getChildrenSize());return yi(Nt(t)),t}},exports.$setCompositionKey=ci,exports.$setDirectionFromDOM=Bl,exports.$setFormatFromDOM=$l,exports.$setPointFromCaret=ea,exports.$setSelection=yi,exports.$setSelectionFromCaretRange=na,exports.$setSlot=yc,exports.$setState=function(t,e,n){let o;if(Wr(),"function"==typeof n){const r=t.getLatest(),s=at(r,e);if(o=n(s),e.isEqual(s,o))return r}else o=n;const r=t.getWritable();return ht(r).updateFromKnown(e,o),r},exports.$setTextFormat=function(t,e){const n=[];for(const[t,o]of Object.entries(e))"boolean"==typeof o&&n.push([t,o]);0!==n.length&&Jo(t,t=>{for(const[e,o]of n)t=oi(t,e,o?A[e]:0);return t})},exports.$splitAtPointCaretNext=pa,exports.$splitNode=function(e,n){let o=e.getChildAtIndex(n);null==o&&(o=e),Xi(e)&&t(102);const r=e=>{const n=e.getParentOrThrow(),s=Xi(n),i=e!==o||s?Qi(e):e;if(s)return as(e)&&as(i)||t(133),e.insertAfter(i),[e,i,i];{const[t,o,s]=r(n),l=e.getNextSiblings();return s.append(i,...l),[t,o,i]}},[s,i]=r(o);return[s,i]},exports.$updateDOMSelection=vr,exports.$updateRangeSelectionFromCaretRange=oa,exports.ArtificialNode__DO_NOT_USE=xs,exports.BEFORE_INPUT_COMMAND=ke,exports.BLUR_COMMAND=yn,exports.CAN_REDO_COMMAND=_n,exports.CAN_UNDO_COMMAND=pn,exports.CAN_USE_BEFORE_INPUT=i,exports.CAN_USE_DOM=n,exports.CLEAR_EDITOR_COMMAND=hn,exports.CLEAR_HISTORY_COMMAND=gn,exports.CLICK_COMMAND=Ee,exports.COLLABORATION_TAG=ro,exports.COMMAND_PRIORITY_BEFORE_CRITICAL=-4,exports.COMMAND_PRIORITY_BEFORE_EDITOR=-8,exports.COMMAND_PRIORITY_BEFORE_HIGH=-5,exports.COMMAND_PRIORITY_BEFORE_LOW=-7,exports.COMMAND_PRIORITY_BEFORE_NORMAL=-6,exports.COMMAND_PRIORITY_CRITICAL=4,exports.COMMAND_PRIORITY_EDITOR=ws,exports.COMMAND_PRIORITY_HIGH=3,exports.COMMAND_PRIORITY_LOW=1,exports.COMMAND_PRIORITY_NORMAL=2,exports.COMPOSITION_END_COMMAND=Me,exports.COMPOSITION_END_TAG=ao,exports.COMPOSITION_START_COMMAND=be,exports.COMPOSITION_START_TAG=co,exports.CONTROLLED_TEXT_INSERTION_COMMAND=Ie,exports.COPY_COMMAND=un,exports.CUT_COMMAND=fn,exports.CUT_TAG="cut",exports.DEFAULT_EDITOR_DOM_CONFIG=Fs,exports.DELETE_CHARACTER_COMMAND=Ae,exports.DELETE_LINE_COMMAND=Le,exports.DELETE_WORD_COMMAND=Re,exports.DRAGEND_COMMAND=an,exports.DRAGOVER_COMMAND=cn,exports.DRAGSTART_COMMAND=ln,exports.DROP_COMMAND=rn,exports.DecoratorNode=fs,exports.ElementNode=cs,exports.FOCUS_COMMAND=mn,exports.FORMAT_ELEMENT_COMMAND=sn,exports.FORMAT_TEXT_COMMAND=Ke,exports.HISTORIC_TAG="historic",exports.HISTORY_MERGE_TAG=oo,exports.HISTORY_PUSH_TAG="history-push",exports.INDENT_CONTENT_COMMAND=nn,exports.INPUT_COMMAND=Oe,exports.INSERT_LINE_BREAK_COMMAND=De,exports.INSERT_PARAGRAPH_COMMAND=we,exports.INSERT_TAB_COMMAND=en,exports.INTERNAL_$isBlock=bl,exports.IS_ALL_FORMATTING=2047,exports.IS_ANDROID=c,exports.IS_ANDROID_CHROME=f,exports.IS_APPLE=r,exports.IS_APPLE_WEBKIT=d,exports.IS_BOLD=1,exports.IS_CHROME=u,exports.IS_CODE=16,exports.IS_FIREFOX=s,exports.IS_HIGHLIGHT=p,exports.IS_IOS=l,exports.IS_ITALIC=2,exports.IS_SAFARI=a,exports.IS_STRIKETHROUGH=4,exports.IS_SUBSCRIPT=32,exports.IS_SUPERSCRIPT=64,exports.IS_UNDERLINE=8,exports.KEY_ARROW_DOWN_COMMAND=Je,exports.KEY_ARROW_LEFT_COMMAND=je,exports.KEY_ARROW_RIGHT_COMMAND=Ue,exports.KEY_ARROW_UP_COMMAND=Ge,exports.KEY_BACKSPACE_COMMAND=Xe,exports.KEY_DELETE_COMMAND=Ze,exports.KEY_DOWN_COMMAND=We,exports.KEY_ENTER_COMMAND=Ve,exports.KEY_ESCAPE_COMMAND=Qe,exports.KEY_MODIFIER_COMMAND=xn,exports.KEY_SPACE_COMMAND=qe,exports.KEY_TAB_COMMAND=tn,exports.LineBreakNode=Cs,exports.MOVE_TO_END=He,exports.MOVE_TO_START=Ye,exports.NODE_STATE_DIRECT=it,exports.NODE_STATE_KEY="$",exports.NODE_STATE_LATEST=lt,exports.OUTDENT_CONTENT_COMMAND=on,exports.PASTE_COMMAND=Pe,exports.PASTE_TAG="paste",exports.ParagraphNode=Os,exports.REDO_COMMAND=ze,exports.REMOVE_TEXT_COMMAND=Fe,exports.RootNode=hs,exports.SELECTION_CHANGE_COMMAND=Ne,exports.SELECTION_INSERT_CLIPBOARD_NODES_COMMAND=ve,exports.SELECT_ALL_COMMAND=dn,exports.SET_TEXT_FORMAT_COMMAND=Be,exports.SKIP_COLLAB_TAG="skip-collab",exports.SKIP_DOM_SELECTION_TAG=io,exports.SKIP_SCROLL_INTO_VIEW_TAG=so,exports.SKIP_SELECTION_FOCUS_TAG=lo,exports.TEXT_TYPE_TO_FORMAT=A,exports.TabNode=Po,exports.TextNode=To,exports.UNDO_COMMAND=$e,exports.addClassNamesToElement=function(t,...e){const n=ya(...e);n.length>0&&t.classList.add(...n)},exports.buildImportMap=function(t){return t},exports.configExtension=function(...t){return t},exports.createCommand=Te,exports.createEditor=function(e){const n=e||{},o=Jr(),r=n.theme||{},s=void 0===e?o:n.parentEditor||null,i=n.disableEvents||!1,l=ps(),c=n.namespace||(null!==s?s._config.namespace:Ni()),a=n.editorState,u=[hs,To,Cs,Po,Os,xs,...n.nodes||[]],{onError:f,onWarn:d,html:h}=n,g=void 0===n.editable||n.editable;let _;if(void 0===e&&null!==o)_=o._nodes;else{_=new Map;for(let e=0;e{Object.keys(t).forEach(e=>{let o=n.get(e);void 0===o&&(o=[],n.set(e,o)),o.push(t[e])})};return t.forEach(t=>{const e=t.klass.importDOM;if(null==e||o.has(e))return;o.add(e);const n=e.call(t.klass);null!==n&&r(n)}),e&&r(e),n}(_,h?h.import:void 0),g,e);return void 0!==a&&(p._pendingEditorState=a,p._dirtyType=2),function(t){t.registerCommand(ke,Ln,ws),t.registerCommand(Oe,Kn,ws),t.registerCommand(be,Bn,ws),t.registerCommand(Me,$n,ws),t.registerCommand(We,Un,ws)}(p),p},exports.createRefCountedRegistry=Cn,exports.createSharedNodeState=ut,exports.createState=function(t,e){return new ct(t,e)},exports.declarePeerDependency=function(t,e){return[t,e]},exports.defineExtension=function(t){return t},exports.findAllLexicalElementsDeep=al,exports.flipDirection=kc,exports.getActiveElement=yl,exports.getActiveElementDeep=xl,exports.getComposedEventTarget=Cl,exports.getComposedStaticRange=dl,exports.getDOMOwnerDocument=Wi,exports.getDOMSelection=rl,exports.getDOMSelectionFromTarget=sl,exports.getDOMSelectionPoints=gl,exports.getDOMSelectionRange=hl,exports.getDOMSelectionRangeAndPoints=function(t,e){const n=dl(t,e);if(null===n)return{points:t,range:t.rangeCount>0?t.getRangeAt(0):null};const o=_l(n)??(t.rangeCount>0?t.getRangeAt(0):null);return{points:pl(n,ml(t)),range:o}},exports.getDOMShadowRoots=cl,exports.getDOMTextNode=ni,exports.getDeclaredSlots=gc,exports.getEditorPropertyFromDOMNode=Xs,exports.getNearestEditorFromDOMNode=qs,exports.getParentElement=zi,exports.getRegisteredNode=Hs,exports.getRegisteredNodeOrThrow=Us,exports.getRegisteredSubtypeMap=function(t){const e=new Map,n=new Map;for(const o of t){const{ownNodeType:t}=Jl(o);t&&(n.set(t,o),e.set(t,new Set))}for(const[t,o]of n)for(const{ownNodeType:n}of Vl(o)){const o=n&&e.get(n);o&&o.add(t)}return e},exports.getRootOwnerDocument=ul,exports.getStaticNodeConfig=Jl,exports.getStyleObjectFromCSS=fo,exports.getTextDirection=function(t){return b.test(t)?"rtl":M.test(t)?"ltr":null},exports.getTransformSetFromKlass=Ps,exports.isBlockDomNode=Ol,exports.isCurrentlyReadOnlyMode=zr,exports.isDOMCapturingSelection=Hl,exports.isDOMDocumentNode=ei,exports.isDOMNode=Tl,exports.isDOMShadowRoot=il,exports.isDOMTextNode=ti,exports.isDOMUnmanaged=Wl,exports.isDocumentFragment=Nl,exports.isExactShortcutMatch=Ai,exports.isHTMLAnchorElement=function(t){return Sl(t)&&"A"===t.tagName},exports.isHTMLElement=Sl,exports.isHTMLTableCellElement=function(t){return Sl(t)&&("TD"===t.tagName||"TH"===t.tagName)},exports.isHTMLTableRowElement=function(t){return Sl(t)&&"TR"===t.tagName},exports.isInlineDomNode=El,exports.isLastChildInBlockNode=Es,exports.isLexicalEditor=Vs,exports.isModifierMatch=Mi,exports.isOnlyChildInBlockNode=vs,exports.isSelectionCapturedInDecoratorInput=Gs,exports.isSelectionWithinEditor=Js,exports.iterStaticNodeConfigChain=Vl,exports.makeStepwiseIterator=Jc,exports.mergeRegister=xa,exports.mountSlotContainer=function(t,e,n,o){const r=t.read("latest",()=>{const o=ui(e);return null!==o?function(t,e,n=Ml()){const o=cc(t,e);if(null===o)return null;const r=n.getElementByKey(o.getKey());return null!==r?r.parentElement:null}(o,n,t):null});return null!==r&&(r.parentElement!==o&&o.appendChild(r),r.style.display=""),r},exports.normalizeClassNames=ya,exports.registerEventListener=Sn,exports.registerEventListeners=function(t,e,n){return xa(...Object.entries(e).map(([e,o])=>Sn(t,e,o,n)))},exports.removeClassNamesFromElement=function(t,...e){const n=ya(...e);n.length>0&&t.classList.remove(...n)},exports.removeFromParent=ii,exports.resetRandomKey=function(){Ws=1},exports.safeCast=function(t){return t},exports.setDOMStyleFromCSS=go,exports.setDOMStyleObject=function(t,e){for(const n in e){const o=e[n];null==o?t.removeProperty(n):ho(t,n,o)}},exports.setDOMUnmanaged=zl,exports.setNodeIndentFromDOM=Kl,exports.shallowMergeConfig=function(t,e){if(!e||t===e)return t;for(const n in e)if(t[n]!==e[n])return{...t,...e};return t},exports.stopLexicalPropagation=Gn,exports.toggleTextFormatType=oi,exports.tokenizeRawText=Er,exports.unmountSlotContainer=function(t,e,n){n.style.display="none";const o=t.getElementByKey(e);null!==o&&n.parentElement!==o&&o.insertBefore(n,o.firstChild)}; ++/*@__INLINE__*/function Te(t){return{type:t}}const Ne=/* @__PURE__ */Te("SELECTION_CHANGE_COMMAND"),ve=/* @__PURE__ */Te("SELECTION_INSERT_CLIPBOARD_NODES_COMMAND"),Ee=/* @__PURE__ */Te("CLICK_COMMAND"),ke=/* @__PURE__ */Te("BEFORE_INPUT_COMMAND"),Oe=/* @__PURE__ */Te("INPUT_COMMAND"),be=/* @__PURE__ */Te("COMPOSITION_START_COMMAND"),Me=/* @__PURE__ */Te("COMPOSITION_END_COMMAND"),Ae=/* @__PURE__ */Te("DELETE_CHARACTER_COMMAND"),De=/* @__PURE__ */Te("INSERT_LINE_BREAK_COMMAND"),we=/* @__PURE__ */Te("INSERT_PARAGRAPH_COMMAND"),Ie=/* @__PURE__ */Te("CONTROLLED_TEXT_INSERTION_COMMAND"),Pe=/* @__PURE__ */Te("PASTE_COMMAND"),Fe=/* @__PURE__ */Te("REMOVE_TEXT_COMMAND"),Re=/* @__PURE__ */Te("DELETE_WORD_COMMAND"),Le=/* @__PURE__ */Te("DELETE_LINE_COMMAND"),Ke=/* @__PURE__ */Te("FORMAT_TEXT_COMMAND"),Be=/* @__PURE__ */Te("SET_TEXT_FORMAT_COMMAND"),$e=/* @__PURE__ */Te("UNDO_COMMAND"),ze=/* @__PURE__ */Te("REDO_COMMAND"),We=/* @__PURE__ */Te("KEYDOWN_COMMAND"),Ue=/* @__PURE__ */Te("KEY_ARROW_RIGHT_COMMAND"),He=/* @__PURE__ */Te("MOVE_TO_END"),je=/* @__PURE__ */Te("KEY_ARROW_LEFT_COMMAND"),Ye=/* @__PURE__ */Te("MOVE_TO_START"),Ge=/* @__PURE__ */Te("KEY_ARROW_UP_COMMAND"),Je=/* @__PURE__ */Te("KEY_ARROW_DOWN_COMMAND"),Ve=/* @__PURE__ */Te("KEY_ENTER_COMMAND"),qe=/* @__PURE__ */Te("KEY_SPACE_COMMAND"),Xe=/* @__PURE__ */Te("KEY_BACKSPACE_COMMAND"),Qe=/* @__PURE__ */Te("KEY_ESCAPE_COMMAND"),Ze=/* @__PURE__ */Te("KEY_DELETE_COMMAND"),tn=/* @__PURE__ */Te("KEY_TAB_COMMAND"),en=/* @__PURE__ */Te("INSERT_TAB_COMMAND"),nn=/* @__PURE__ */Te("INDENT_CONTENT_COMMAND"),on=/* @__PURE__ */Te("OUTDENT_CONTENT_COMMAND"),rn=/* @__PURE__ */Te("DROP_COMMAND"),sn=/* @__PURE__ */Te("FORMAT_ELEMENT_COMMAND"),ln=/* @__PURE__ */Te("DRAGSTART_COMMAND"),cn=/* @__PURE__ */Te("DRAGOVER_COMMAND"),an=/* @__PURE__ */Te("DRAGEND_COMMAND"),un=/* @__PURE__ */Te("COPY_COMMAND"),fn=/* @__PURE__ */Te("CUT_COMMAND"),dn=/* @__PURE__ */Te("SELECT_ALL_COMMAND"),hn=/* @__PURE__ */Te("CLEAR_EDITOR_COMMAND"),gn=/* @__PURE__ */Te("CLEAR_HISTORY_COMMAND"),_n=/* @__PURE__ */Te("CAN_REDO_COMMAND"),pn=/* @__PURE__ */Te("CAN_UNDO_COMMAND"),mn=/* @__PURE__ */Te("FOCUS_COMMAND"),yn=/* @__PURE__ */Te("BLUR_COMMAND"),xn=/* @__PURE__ */Te("KEY_MODIFIER_COMMAND");function Cn(t){const e=new Map;return{dispose(){for(const t of e.values())t.dispose();e.clear()},register(n,o){let r=e.get(n);void 0===r&&(r={dispose:t(n,o),holders:new Set},e.set(n,r));const s=()=>{const t=e.get(n);t&&t.holders.delete(s)&&0===t.holders.size&&(e.delete(n),t.dispose())};return r.holders.add(s),s}}}function Sn(t,e,n,o){return t.addEventListener(e,n,o),t.removeEventListener.bind(t,e,n,o)}const Tn=Object.freeze({}),Nn=[["keydown",function(t,e){const n=e._inputState;n.lastKeyDownTimeStamp=t.timeStamp,n.lastKeyCode=t.key,"Backspace"!==t.key&&Pn(n);if(e.isComposing())return;Bi(e,We,t)}],["pointerdown",function(t,e){const n=Cl(t),o=t.pointerType;Tl(n)&&"touch"!==o&&"pen"!==o&&0===t.button&&is(e,()=>{Hl(n,e)||(e._inputState.isSelectionChangeFromMouseDown=!0)})}],["compositionstart",function(t,e){Bi(e,be,t)}],["compositionend",function(t,e){const n=e._inputState;s?n.compositionPhase="ending-firefox":l||!a&&!d?Bi(e,Me,t):(n.compositionPhase="ending-safari",n.compositionEndData=t.data)}],["input",function(t,e){t.stopPropagation();const n=e._inputState;Pn(n),is(e,()=>{Rn(t,e)||e.dispatchCommand(Oe,t)},{event:t}),n.unprocessedBeforeInputData=null}],["click",function(t,e){is(e,()=>{const n=pr(),o=rl(Gi(e)),r=mr();if(o)if(jo(n)){const t=n.anchor,e=t.getNode();"element"===t.type&&0===t.offset&&n.isCollapsed()&&!gs(e)&&1===mi().getChildrenSize()&&e.getTopLevelElementOrThrow().isEmpty()&&null!==r&&n.is(r)&&(o.removeAllRanges(),n.dirty=!0)}else if("touch"===t.pointerType||"pen"===t.pointerType){const n=gl(o,e._rootElement).anchorNode;if(Sl(n)||ti(n)){yi(_r(r,o,e,t))}}if(s&&null!==o&&0===o.rangeCount){const n=e._rootElement;if(null!==n&&t.target===n){const s=t.clientY;let i=n.childNodes.length;for(let t=0;tfunction(t,e){const n=t.inputType;if("deleteCompositionText"===n||s&&Ki(e))return;if("insertCompositionText"===n)return;is(e,()=>{Rn(t,e)||Bi(e,ke,t)},{event:t})}(t,e)]);const vn=new WeakMap,En=new WeakMap,kn=Cn(t=>(t.addEventListener("selectionchange",Yn),()=>t.removeEventListener("selectionchange",Yn)));function On(t,e,n,o,r,s){const l=t.anchor,c=t.focus,a=l.getNode(),u=jr();let f;if(void 0!==s)f=s;else{const t=rl(Gi(u));f=null!==t?gl(t,u._rootElement):null}const d=null!==f?f.anchorNode:null,h=l.key,g=u.getElementByKey(h),_=n.length;return h!==c.key||!wo(a)||(!r&&(!i||u._inputState.lastBeforeInputInsertTextTimeStamp1||(r||!i)&&null!==g&&!a.isComposing()&&d!==Il(a,g,u)||null!==f&&null!==e&&(!e.collapsed||e.startContainer!==f.anchorNode||e.startOffset!==f.anchorOffset)||!a.isComposing()&&(a.getFormat()!==t.format||a.getStyle()!==t.style)||function(t,e){if(e.isSegmented())return!0;if(!t.isCollapsed())return!1;const n=t.anchor.offset,o=e.getParentOrThrow(),r=Qs(e);return 0===n?!e.canInsertTextBefore()||!o.canInsertTextBefore()&&!e.isComposing()||r||function(t){const e=t.getPreviousSibling();return(wo(e)||as(e)&&e.isInline())&&!e.canInsertTextAfter()}(e):n===e.getTextContentSize()&&(!e.canInsertTextAfter()||!o.canInsertTextAfter()&&!e.isComposing()||r)}(t,a)}function bn(t,e){return ti(t)&&null!==t.nodeValue&&0!==e&&e!==t.nodeValue.length}function Mn(e,n,o){const{anchorNode:r,anchorOffset:s,focusNode:i,focusOffset:l}=gl(e,n._rootElement),c=n._inputState;c.isSelectionChangeFromDOMUpdate&&(c.isSelectionChangeFromDOMUpdate=!1,bn(r,s)&&bn(i,l)&&!c.postDeleteSelectionToRestore)||is(n,()=>{if(!o)return void yi(null);if(!Js(n,r,i))return;let a=pr();if(c.postDeleteSelectionToRestore&&jo(a)&&a.isCollapsed()){const t=a.anchor,e=c.postDeleteSelectionToRestore.anchor;(t.key===e.key&&t.offset===e.offset+1||1===t.offset&&e.getNode().is(t.getNode().getPreviousSibling()))&&(a=c.postDeleteSelectionToRestore.clone(),yi(a))}if(c.postDeleteSelectionToRestore=null,jo(a)){const o=a.anchor,u=o.getNode();if(a.isCollapsed()){"Range"===e.type&&r===i&&(a.dirty=!0);const s=Gi(n).event,l=s?s.timeStamp:performance.now(),{format:f,style:d,offset:h,key:g,timeStamp:_}=c.collapsedSelectionFormat,p=mi(),m=!1===n.isComposing()&&""===p.getTextContent();if(l<_+200&&o.offset===h&&o.key===g)An(a,f,d);else if("text"===o.type)wo(u)||t(141),Dn(a,u);else if("element"===o.type&&!m){as(u)||t(259);const e=o.getNode();e.isEmpty()?function(t,e){const n=e.getTextFormat(),o=e.getTextStyle();An(t,n,o)}(a,e):An(a,a.format,"")}}else{const t=o.key,e=a.focus.key,n=a.getNodes(),r=n.length,i=a.isBackward(),c=i?l:s,u=i?s:l,f=i?e:t,d=i?t:e;let h=2047,g=!1;for(let t=0;tPn(t),0)}function Rn(t,e){const n=Cl(t);if(Sl(n)&&Hl(n,e))return!0;const o=e.getRootElement();if(null===o)return!1;const r=xl(o.ownerDocument);return null!==r&&o.contains(r)&&Hl(r,e)}function Ln(e){const n=e.inputType,o=wn(e),r=jr(),s=r._inputState,i=pr();if("insertText"===n&&e.data&&s.isInsertTextAfterHandledSelectionCommand){if(Pn(s),e.preventDefault(),jo(i)&&!i.isCollapsed()){const t=i.isBackward()?i.anchor:i.focus;i.anchor.set(t.key,t.offset,t.type),i.focus.set(t.key,t.offset,t.type)}return!0}if("deleteContentBackward"===n){if(null===i){const t=mr();if(!jo(t))return!0;yi(t.clone())}if(jo(i)){const n=i.anchor.key===i.focus.key;if(function(t,e){return"MediaLast"===t.lastKeyCode&&e{is(r,()=>{ci(null)})},30),jo(i)){const e=i.anchor.getNode();e.markDirty(),wo(e)||t(142),Dn(i,e)}}else{if(ci(null),l&&null!==o&&!o.collapsed&&(i.applyDOMRange(o),!i.isCollapsed()))return e.preventDefault(),i.removeText(),!0;e.preventDefault();const t=i.anchor.getNode(),c=t.getTextContent(),a=t.canInsertTextAfter(),u=0===i.anchor.offset&&i.focus.offset===c.length;let d=f&&n&&!u&&a;if(d&&i.isCollapsed()&&(d=!ds(Li(i.anchor,!0))),!d){Bi(r,Ae,!0);const t=pr();f&&jo(t)&&t.isCollapsed()&&(s.postDeleteSelectionToRestore=t,setTimeout(()=>s.postDeleteSelectionToRestore=null))}}return!0}}if(!jo(i))return!0;const c=e.data;null!==s.unprocessedBeforeInputData&&Ei(!1,r,s.unprocessedBeforeInputData),i.dirty&&null===s.unprocessedBeforeInputData||!i.isCollapsed()||gs(i.anchor.getNode())||null===o||i.applyDOMRange(o),s.unprocessedBeforeInputData=null;const a=i.anchor,u=i.focus,d=a.getNode(),h=u.getNode();if("insertText"===n||"insertTranspose"===n){if("\n"===c)e.preventDefault(),Bi(r,De,!1);else if(c===v)e.preventDefault(),Bi(r,we);else if(null==c&&e.dataTransfer){const t=e.dataTransfer.getData("text/plain");e.preventDefault(),i.insertRawText(t)}else null!=c&&On(i,o,c,e.timeStamp,!0)?(e.preventDefault(),Bi(r,Ie,c),In(c)):s.unprocessedBeforeInputData=c;return s.lastBeforeInputInsertTextTimeStamp=e.timeStamp,!0}switch(e.preventDefault(),n){case"insertFromYank":case"insertFromDrop":case"insertReplacementText":Bi(r,Ie,e);In((e.dataTransfer?e.dataTransfer.getData("text/plain"):null)??e.data);break;case"insertFromComposition":{const t=s.hadOrphanedCompositionEvents;s.hadOrphanedCompositionEvents=!1;const n=r._compositionKey;ci(null),t||Bi(r,Ie,e),zn(n);break}case"insertLineBreak":ci(null),Bi(r,De,!1);break;case"insertParagraph":ci(null),s.isInsertLineBreak&&!l?(s.isInsertLineBreak=!1,Bi(r,De,!1)):Bi(r,we);break;case"insertFromPaste":case"insertFromPasteAsQuotation":Bi(r,Pe,e);break;case"deleteByComposition":(function(t,e){return t!==e||as(t)||as(e)||!Qs(t)||!Qs(e)})(d,h)&&Bi(r,Fe,e);break;case"deleteByDrag":Ui(lo),Bi(r,Fe,e);break;case"deleteByCut":Bi(r,Fe,e);break;case"deleteContent":Bi(r,Ae,!1);break;case"deleteWordBackward":Bi(r,Re,!0);break;case"deleteWordForward":Bi(r,Re,!1);break;case"deleteHardLineBackward":case"deleteSoftLineBackward":Bi(r,Le,!0);break;case"deleteContentForward":case"deleteHardLineForward":case"deleteSoftLineForward":Bi(r,Le,!1);break;case"formatStrikeThrough":Bi(r,Ke,"strikethrough");break;case"formatBold":Bi(r,Ke,"bold");break;case"formatItalic":Bi(r,Ke,"italic");break;case"formatUnderline":Bi(r,Ke,"underline");break;case"historyUndo":Bi(r,$e);break;case"historyRedo":Bi(r,ze)}return!0}function Kn(t){const e=jr(),n=e._inputState,o=pr(),r=t.data,l=wn(t);let c=!1;if(null!=r&&jo(o)){const a=rl(Gi(e)),u=null!==a?gl(a,e._rootElement):null,d="insertCompositionText"===t.inputType&&"ending-firefox"!==n.compositionPhase&&!e.isComposing();d&&(n.hadOrphanedCompositionEvents=!0);const h=o.anchor.getNode(),g="insertCompositionText"===t.inputType&&"ending-firefox"!==n.compositionPhase&&e.isComposing()&&wo(h)&&Zs(h);if(!d&&!g&&On(o,l,r,t.timeStamp,!1,u)){if(c=!0,"ending-firefox"===n.compositionPhase){const t=Wn(e,r);if(n.compositionPhase="idle",t)return Ui(ao),xi(),!0}const l=o.anchor.getNode();if(null===a||null===u)return!0;const d=o.isBackward(),h=d?o.anchor.offset:o.focus.offset,g=d?o.focus.offset:o.anchor.offset;i&&!o.isCollapsed()&&wo(l)&&null!==u.anchorNode&&l.getTextContent().slice(0,h)+r+l.getTextContent().slice(h+g)===vi(u.anchorNode)||Bi(e,Ie,r);const _=r.length;s&&_>1&&"insertCompositionText"===t.inputType&&!e.isComposing()&&(o.anchor.offset-=_,o._cachedNodes=null,o._cachedIsBackward=null),f&&e.isComposing()&&(n.lastKeyDownTimeStamp=0,ci(null))}}if(!c){Ei(!1,e,null!==r?r:void 0),"ending-firefox"===n.compositionPhase&&(Wn(e,r||void 0),Ui(ao),n.compositionPhase="idle")}return xi(),!0}function Bn(t){const e=jr(),n=e._inputState,o=pr();if(jo(o)&&!e.isComposing()){n.compositionPhase="composing",n.hadOrphanedCompositionEvents=!1;const r=o.anchor,s=o.anchor.getNode();if(ci(r.key),Ui(co),t.timeStamp{Wn(e,n.compositionEndData)}),n.compositionPhase="idle",n.compositionEndData="",o)return!0}if(function(t){return Ai(t,"ArrowRight",{shiftKey:"any"})}(t))Bi(e,Ue,t);else if(function(t){return Ai(t,"ArrowRight",{...Di,shiftKey:"any"})}(t))Bi(e,He,t);else if(function(t){return Ai(t,"ArrowLeft",{shiftKey:"any"})}(t))Bi(e,je,t);else if(function(t){return Ai(t,"ArrowLeft",{...Di,shiftKey:"any"})}(t))Bi(e,Ye,t);else if(function(t){return Ai(t,"ArrowUp",{altKey:"any",shiftKey:"any"})}(t))Bi(e,Ge,t);else if(function(t){return Ai(t,"ArrowDown",{altKey:"any",shiftKey:"any"})}(t))Bi(e,Je,t);else if(function(t){return Ai(t,"Enter",{altKey:"any",ctrlKey:"any",metaKey:"any",shiftKey:!0})}(t))n.isInsertLineBreak=!0,Bi(e,Ve,t);else if(function(t){return" "===t.key}(t))Bi(e,qe,t);else if(function(t){return r&&Ai(t,"o",{ctrlKey:!0})}(t))t.preventDefault(),n.isInsertLineBreak=!0,Bi(e,De,!0);else if(function(t){return Ai(t,"Enter",{altKey:"any",ctrlKey:"any",metaKey:"any"})}(t))n.isInsertLineBreak=!1,Bi(e,Ve,t);else if(function(t){return Ai(t,"Backspace",{shiftKey:"any"})||r&&Ai(t,"h",{ctrlKey:!0})}(t))Ii(t)?Bi(e,Xe,t)&&Fn(n):(t.preventDefault(),Bi(e,Ae,!0));else if(function(t){return"Escape"===t.key}(t))Bi(e,Qe,t);else if(function(t){return Ai(t,"Delete",{})||r&&Ai(t,"d",{ctrlKey:!0})}(t))!function(t){return"Delete"===t.key}(t)?(t.preventDefault(),Bi(e,Ae,!1)):Bi(e,Ze,t);else if(function(t){return Ai(t,"Backspace",wi)}(t))t.preventDefault(),Bi(e,Re,!0);else if(function(t){return Ai(t,"Delete",wi)}(t))t.preventDefault(),Bi(e,Re,!1);else if(function(t){return r&&Ai(t,"Backspace",{metaKey:!0})}(t))t.preventDefault(),Bi(e,Le,!0);else if(function(t){return r&&(Ai(t,"Delete",{metaKey:!0})||Ai(t,"k",{ctrlKey:!0}))}(t))t.preventDefault(),Bi(e,Le,!1);else if(function(t){return Ai(t,"b",Di)}(t))t.preventDefault(),Bi(e,Ke,"bold");else if(function(t){return Ai(t,"u",Di)}(t))t.preventDefault(),Bi(e,Ke,"underline");else if(function(t){return Ai(t,"i",Di)}(t))t.preventDefault(),Bi(e,Ke,"italic");else if(function(t){return Ai(t,"Tab",{shiftKey:"any"})}(t))Bi(e,tn,t);else if(function(t){return Ai(t,"z",Di)}(t))t.preventDefault(),Bi(e,$e);else if(function(t){if(r)return Ai(t,"z",{metaKey:!0,shiftKey:!0});return Ai(t,"y",{ctrlKey:!0})||Ai(t,"z",{ctrlKey:!0,shiftKey:!0})}(t))t.preventDefault(),Bi(e,ze);else{const o=e._editorState._selection;!function(t){return Ai(t,"a",Di)}(t)?null===o||jo(o)||(!function(t){return Ai(t,"c",Di)}(t)?function(t){return Ai(t,"x",Di)}(t)&&(t.preventDefault(),Bi(e,fn,t)):(t.preventDefault(),Bi(e,un,t))):(t.preventDefault(),Bi(e,dn,t)&&Fn(n))}return function(t){return t.ctrlKey||t.shiftKey||t.altKey||t.metaKey}(t)&&e.dispatchCommand(xn,t),!0}function Hn(t){let e=t.__lexicalEventHandles;return void 0===e&&(e=[],t.__lexicalEventHandles=e),e}const jn=new Map;function Yn(t){const e=sl(t.target);if(null===e)return;const n=Wi(t.target);let o=null,r=null;const s=null!==n?En.get(n):void 0;if(null!==n){if(void 0!==s){const t=s.editors;let n=s.hasShadowEditor;if(void 0===n){n=!1;for(const e of t)if(null!==e._rootElement&&il(e._rootElement.getRootNode())){n=!0;break}s.hasShadowEditor=n}if(n){let n=null,s=null;for(const i of t){const t=i._rootElement;if(null===t)continue;const l=gl(e,t).anchorNode;if(null!==l&&qs(l)===i){if(il(t.getRootNode())){o=i,r=l;break}null===n&&(n=i,s=l)}}null===o&&null!==n&&(o=n,r=s)}else{const t=e.anchorNode;null===t||Sl(t)&&null!==t.shadowRoot||(o=qs(t),null!==o&&(r=t))}}if(null===o){const t=xl(n);o=null!==t?qs(t):null}}if(null===o)return;if(o._inputState.isSelectionChangeFromMouseDown){if(void 0!==s)for(const t of s.editors)t._inputState.isSelectionChangeFromMouseDown=!1;is(o,()=>{const n=mr(),s=r??gl(e,o._rootElement).anchorNode;if(Sl(s)||ti(s)){yi(_r(n,e,o,t))}})}const i=Ti(o),l=i[i.length-1],c=l._key,a=jn.get(c),u=a||l;u!==o&&Mn(e,u,!1),Mn(e,o,!0),o!==l?jn.set(c,o):a&&jn.delete(c)}function Gn(t){t._lexicalHandled=!0}function Jn(t){return!0===t._lexicalHandled}const Vn=()=>{};function qn(e){const n=vn.get(e);if(void 0===n)return void Vn();const o=En.get(n);if(void 0===o)return void Vn();vn.delete(e);const r=Xs(e);Vs(r)?(!function(t){if(null!==t._parentEditor){const e=Ti(t),n=e[e.length-1]._key;jn.get(n)===t&&jn.delete(n)}else jn.delete(t._key)}(r),o.editors.delete(r),o.hasShadowEditor=void 0,e.__lexicalEditor=null):r&&t(198);const s=Hn(e);for(let t=0;tt.__key===this.__key);if(wo(this))return n;if(jo(e)&&"element"===e.anchor.type&&"element"===e.focus.type){if(e.isCollapsed())return!1;const t=this.getParent();if(ds(this)&&this.isInline()&&t){const n=e.isBackward()?e.focus:e.anchor;if(t.is(n.getNode())&&n.offset===t.getChildrenSize()&&this.is(t.getLastChild()))return!1}}return n}getKey(){return this.__key}getIndexWithinParent(){const t=this.getParent();if(null===t)return-1;let e=t.getFirstChild(),n=0;for(;null!==e;){if(this.is(e))return n;n++,e=e.getNextSibling()}return-1}getParent(){const t=this.getLatest().__parent;return null===t?null:ui(t)}getParentOrThrow(){const e=this.getParent();return null===e&&t(66,this.__key),e}getTopLevelElement(){let e=this;for(;null!==e;){const n=e.getParent();if(Xi(n)||null!==nc(e))return as(e)||e===this&&ds(e)||t(194),e;e=n}return null}getTopLevelElementOrThrow(){const e=this.getTopLevelElement();return null===e&&t(67,this.__key),e}getParents(){const t=[];let e=this.getParent();for(;null!==e;)t.push(e),e=e.getParent();return t}getParentKeys(){const t=[];let e=this.getParent();for(;null!==e;)t.push(e.__key),e=e.getParent();return t}getPreviousSibling(){const t=this.getLatest().__prev;return null===t?null:ui(t)}getPreviousSiblings(){const t=[],e=this.getParent();if(null===e)return t;let n=e.getFirstChild();for(;null!==n&&!n.is(this);)t.push(n),n=n.getNextSibling();return t}getNextSibling(){const t=this.getLatest().__next;return null===t?null:ui(t)}getNextSiblings(){const t=[];let e=this.getNextSibling();for(;null!==e;)t.push(e),e=e.getNextSibling();return t}getCommonAncestor(t){const e=as(this)?this:this.getParent(),n=as(t)?t:t.getParent(),o=e&&n?Zc(e,n):null;return o?o.commonAncestor:null}is(t){return null!=t&&this.__key===t.__key}isBefore(e){const n=Zc(this,e);return null!==n&&("descendant"===n.type||("branch"===n.type?-1===qc(n):("same"!==n.type&&"ancestor"!==n.type&&t(279),!1)))}isParentOf(t){return ji(t,this)}getNodesBetween(e){const n=this.isBefore(e),o=[],r=new Set;let s=this;for(;null!==s;){const i=s.__key;if(r.has(i)||(r.add(i),o.push(s)),s===e)break;const l=as(s)?n?s.getFirstChild():s.getLastChild():null;if(null!==l){s=l;continue}const c=n?s.getNextSibling():s.getPreviousSibling();if(null!==c){s=c;continue}const a=s.getParentOrThrow();if(r.has(a.__key)||o.push(a),a===e)break;let u=null,f=a;do{if(null===f&&t(68),u=n?f.getNextSibling():f.getPreviousSibling(),f=f.getParent(),null===f)break;null!==u||r.has(f.__key)||o.push(f)}while(null===u);s=u}return n||o.reverse(),o}isDirty(){const t=jr()._dirtyLeaves;return null!==t&&t.has(this.__key)}getLatest(){if(Zn(this))return this;const e=ui(this.__key);return null===e&&t(113),e}getWritable(){if(Zn(this))return this;Wr();const t=Hr(),e=jr(),n=t._nodeMap,o=this.__key,r=this.getLatest(),s=e._cloneNotNeeded,i=pr();if(null!==i&&i.setCachedNodes(null),s.has(o))return li(r),r;const l=Ll(r);return s.add(o),li(l),n.set(o,l),l}getTextContent(){return _c(this)}getTextContentSize(){return this.getTextContent().length}createDOM(e,n){t(70)}updateDOM(e,n,o){t(71)}getDOMSlot(t){return new B(t)}exportDOM(t){return{element:this.createDOM(t._config,t)}}exportJSON(){const t=this.__state?this.__state.toJSON():void 0;return{type:this.__type,version:1,...t}}static importJSON(e){t(18,this.name)}updateFromJSON(t){return function(t,e){const n=t.getWritable(),o=e.$;let r=o;for(const t of gt(n).flatKeys)t in e&&(void 0!==r&&r!==o||(r={...o}),r[t]=e[t]);return(n.__state||r)&&ht(t).updateFromJSON(r),n}(this,t)}static transform(){return null}remove(t){Xn(this,!0,t)}replace(e,n){Wr();let o=pr();null!==o&&(o=o.clone()),tl(this,e);const r=this.getLatest(),s=this.__key,i=e.__key,l=e.getWritable(),c=this.getParentOrThrow().getWritable(),a=c.__size,u=l.getParent(),f=null!==u?l.getIndexWithinParent():-1;si(l),null!==u&&jo(o)&&yr(o,u,f,-1);const d=r.getPreviousSibling(),h=r.getNextSibling(),g=r.__prev,_=r.__next,p=r.__parent;if(Xn(r,!1,!0),null===d)c.__first=i;else{d.getWritable().__next=i}if(l.__prev=g,null===h)c.__last=i;else{h.getWritable().__prev=i}l.__next=_,l.__parent=p,c.__size=a;let m=0;n&&(as(this)&&as(l)||t(139),m=l.getChildrenSize(),l.splice(m,0,this.getChildren()));const y=lc(this);if(y.length>0){tc(this)&&tc(l)||t(368,this.__key,l.__key);for(const t of y){const e=cc(this,t);null!==e&&(xc(this,t),yc(l,t,e))}}if(jo(o)){yi(o);const t=o.anchor,e=o.focus;t.key===s&&(n&&"element"===t.type?t.set(l.__key,m+t.offset,"element"):$o(t,l)),e.key===s&&(n&&"element"===e.type?e.set(l.__key,m+e.offset,"element"):$o(e,l))}return ai()===s&&ci(i),l}insertAfter(t,e=!0){Wr(),tl(this,t);const n=this.getWritable(),o=t.getWritable();Cc(this.getParentOrThrow());const r=o.getParent(),s=pr();let i=!1,l=!1;if(null!==r){const n=t.getIndexWithinParent();if(jo(s)){const t=r.__key,e=s.anchor,o=s.focus;i="element"===e.type&&e.key===t&&e.offset===n+1,l="element"===o.type&&o.key===t&&o.offset===n+1}si(o),e&&jo(s)&&yr(s,r,n,-1)}else si(o);const c=this.getNextSibling(),a=this.getParentOrThrow().getWritable(),u=o.__key,f=n.__next;if(null===c)a.__last=u;else{c.getWritable().__prev=u}if(a.__size++,n.__next=u,o.__next=f,o.__prev=n.__key,o.__parent=n.__parent,e&&jo(s)){const t=this.getIndexWithinParent();yr(s,a,t+1);const e=a.__key;i&&s.anchor.set(e,t+2,"element"),l&&s.focus.set(e,t+2,"element")}return t}insertBefore(t,e=!0){Wr(),tl(this,t);const n=this.getWritable(),o=t.getWritable();Cc(this.getParentOrThrow());const r=o.__key,s=pr(),i=o.getParent(),l=null!==i?o.getIndexWithinParent():-1;si(o),null!==i&&e&&jo(s)&&yr(s,i,l,-1);const c=this.getPreviousSibling(),a=this.getParentOrThrow().getWritable(),u=n.__prev,f=this.getIndexWithinParent();if(null===c)a.__first=r;else{c.getWritable().__next=r}if(a.__size++,n.__prev=r,o.__prev=u,o.__next=n.__key,o.__parent=n.__parent,e&&jo(s)){yr(s,this.getParentOrThrow(),f)}return t}isParentRequired(){return!1}createParentElementNode(){return Ms()}selectStart(){return this.selectPrevious()}selectEnd(){return this.selectNext(0,0)}selectPrevious(t,e){Wr();const n=oc(this);if(null!==n)return n.selectPrevious(t,e);const o=this.getPreviousSibling(),r=this.getParentOrThrow();if(null===o)return r.select(0,0);if(as(o))return o.select();if(!wo(o)){const t=o.getIndexWithinParent()+1;return r.select(t,t)}return o.select(t,e)}selectNext(t,e){Wr();const n=oc(this);if(null!==n)return n.selectNext(t,e);const o=this.getNextSibling(),r=this.getParentOrThrow();if(null===o)return r.select();if(as(o))return o.select(0,0);if(!wo(o)){const t=o.getIndexWithinParent();return r.select(t,t)}return o.select(t,e)}markDirty(){this.getWritable()}reconcileObservedMutation(t,e){this.markDirty()}}function no(t){return t instanceof eo}const oo="history-merge",ro="collaboration",so="skip-scroll-into-view",io="skip-dom-selection",lo="skip-selection-focus",co="composition-start",ao="composition-end",uo="!important";function fo(t){const e={};if(!t)return e;let n="",o="",r=null,s=!1,i=!1,l=!1,c=0;const a=t.length;let u=-1;for(let f=0;f=0&&o.slice(r).toLowerCase()===uo?t.setProperty(e,o.slice(0,r).trim(),"important"):t.setProperty(e,n,"")}function go(t,e,n=""){if(e===n)return;const o=fo(n),r=fo(e);for(const e in r)delete o[e],ho(t,e,r[e]);for(const e in o)t.removeProperty(e)}function _o(t,e){return 16&e?"code":e&p?"mark":32&e?"sub":64&e?"sup":null}function po(t,e){return 1&e?"strong":2&e?"em":"span"}function mo(t,e,n,o,r){const s=o.classList;let i=Pi(r,"base");void 0!==i&&s.add(...i),i=Pi(r,"underlineStrikethrough");let l=!1;const c=8&e&&4&e;void 0!==i&&(8&n&&4&n?(l=!0,c||s.add(...i)):c&&s.remove(...i));for(const t in A){const o=A[t];if(i=Pi(r,t),void 0!==i)if(n&o){if(l&&("underline"===t||"strikethrough"===t)){e&o&&s.remove(...i);continue}(0===(e&o)||c&&"underline"===t||"strikethrough"===t)&&s.add(...i)}else e&o&&s.remove(...i)}}function yo(t,e,n){const o=n.isComposing(),r=t+(o?N:""),i=Ml(),l=Al(i).$getDOMSlot(n,e,i),c=l.getFirstChild();if(null===c||c.nodeType!==Node.TEXT_NODE)return void l.insertChild(fl().createTextNode(r));const a=c,u=a.nodeValue;if(u!==r)if(o||s){const[t,e,n]=function(t,e){const n=t.length,o=e.length;let r=0,s=0;for(;r({conversion:Oo,priority:0}),b:()=>({conversion:vo,priority:0}),code:()=>({conversion:Ao,priority:0}),em:()=>({conversion:Ao,priority:0}),i:()=>({conversion:Ao,priority:0}),mark:()=>({conversion:Ao,priority:0}),s:()=>({conversion:Ao,priority:0}),span:()=>({conversion:No,priority:0}),strong:()=>({conversion:Ao,priority:0}),sub:()=>({conversion:Ao,priority:0}),sup:()=>({conversion:Ao,priority:0}),u:()=>({conversion:Ao,priority:0})}})}afterCloneFrom(t){super.afterCloneFrom(t),this.__text=t.__text,this.__format=t.__format,this.__style=t.__style,this.__mode=t.__mode,this.__detail=t.__detail}constructor(t="",e){super(e),this.__text=t,this.__format=0,this.__style="",this.__mode=0,this.__detail=0}getFormat(){return this.getLatest().__format}getDetail(){return this.getLatest().__detail}getMode(){const t=this.getLatest();return F[t.__mode]}getStyle(){return this.getLatest().__style}isToken(){return 1===this.getLatest().__mode}isComposing(){return this.__key===ai()}isSegmented(){return 2===this.getLatest().__mode}isDirectionless(){return!!(1&this.getLatest().__detail)}isUnmergeable(){return!!(2&this.getLatest().__detail)}hasFormat(t){const e=A[t];return 0!==(this.getFormat()&e)}isSimpleText(){return"text"===this.__type&&0===this.__mode}getTextContent(){return this.getLatest().__text}getFormatFlags(t,e){return oi(this.getLatest().__format,t,e)}canHaveFormat(){return!0}isInline(){return!0}createDOM(t,e){const n=this.__format,o=_o(0,n),r=po(0,n),s=null===o?r:o,i=fl().createElement(s);let l=i;this.hasFormat("code")&&i.setAttribute("spellcheck","false"),null!==o&&(l=fl().createElement(r),i.appendChild(l));xo(l,this,0,n,this.__text,t);const c=this.__style;return""!==c&&go(i.style,c),i}updateDOM(e,n,o){const r=this.__text,s=e.__format,i=this.__format,l=_o(0,s),c=_o(0,i),a=po(0,s),u=po(0,i);if((null===l?a:l)!==(null===c?u:c))return!0;if(l===c&&a!==u){const e=n.firstChild;null==e&&t(48);const s=fl().createElement(u);return xo(s,this,0,i,r,o),n.replaceChild(s,e),!1}let f=n;null!==c&&null!==l&&(f=n.firstChild,null==f&&t(49)),yo(r,f,this);const d=o.theme.text;void 0!==d&&s!==i&&mo(0,s,i,f,d);const h=e.__style,g=this.__style;return h!==g&&go(n.style,g,h),!1}updateFromJSON(t){return super.updateFromJSON(t).setTextContent(t.text).setFormat(t.format).setDetail(t.detail).setMode(t.mode).setStyle(t.style)}exportDOM(e){let{element:n}=super.exportDOM(e);return Sl(n)||t(132),n.style.whiteSpace="pre-wrap",this.hasFormat("lowercase")?n.style.textTransform="lowercase":this.hasFormat("uppercase")?n.style.textTransform="uppercase":this.hasFormat("capitalize")&&(n.style.textTransform="capitalize"),this.hasFormat("bold")&&(n=Co(n,"b")),this.hasFormat("italic")&&(n=Co(n,"i")),this.hasFormat("strikethrough")&&(n=Co(n,"s")),this.hasFormat("underline")&&(n=Co(n,"u")),{element:n}}exportJSON(){return{detail:this.getDetail(),format:this.getFormat(),mode:this.getMode(),style:this.getStyle(),text:this.getTextContent(),...super.exportJSON()}}selectionTransform(t,e){}setFormat(t){const e=this.getWritable();return e.__format="string"==typeof t?A[t]:t,e}setDetail(t){const e=this.getWritable();return e.__detail="string"==typeof t?D[t]:t,e}setStyle(t){const e=this.getWritable();return e.__style=t,e}toggleFormat(t){const e=oi(this.getFormat(),t,null);return this.setFormat(e)}toggleDirectionless(){const t=this.getWritable();return t.__detail^=1,t}toggleUnmergeable(){const t=this.getWritable();return t.__detail^=2,t}setMode(t){const e=P[t];if(this.__mode===e)return this;const n=this.getWritable();return n.__mode=e,n}setTextContent(t){if(this.__text===t)return this;const e=this.getWritable();return e.__text=t,e}select(t,e){Wr();let n=t,o=e;const r=pr(),s=this.getTextContent(),i=this.__key;if("string"==typeof s){const t=s.length;void 0===n&&(n=t),void 0===o&&(o=t)}else n=0,o=0;if(!jo(r))return dr(i,n,i,o,"text","text");{const t=ai();t!==r.anchor.key&&t!==r.focus.key||ci(i),r.setTextNodeRange(this,n,this,o)}return r}selectStart(){return this.select(0,0)}selectEnd(){const t=this.getTextContentSize();return this.select(t,t)}spliceText(t,e,n,o){const r=this.getWritable(),s=r.__text,i=n.length;let l=t;l<0&&(l=i+l,l<0&&(l=0));const c=pr();if(o&&jo(c)){const e=t+i;c.setTextNodeRange(r,e,r,e)}const a=s.slice(0,l)+n+s.slice(l+e);return r.__text=a,r}canInsertTextBefore(){return!0}canInsertTextAfter(){return!0}splitText(...t){Wr();const e=this.getLatest(),n=e.getTextContent();if(""===n)return[];const o=e.__key,r=ai(),s=n.length;t.sort((t,e)=>t-e),t.push(s);const i=[],l=t.length;for(let e=0,o=0;ee&&(i.push(n.slice(e,r)),e=r)}const c=i.length;if(1===c)return[e];const a=i[0],u=e.getParent();let f;const d=e.getFormat(),h=e.getStyle(),g=e.__detail;let _=!1,p=null,m=null;const y=pr();if(jo(y)){const[t,e]=y.isBackward()?[y.focus,y.anchor]:[y.anchor,y.focus];"text"===t.type&&t.key===o&&(p=t),"text"===e.type&&e.key===o&&(m=e)}e.isSegmented()?(f=Do(a),f.__format=d,f.__style=h,f.__detail=g,f.__state=xt(e,f),_=!0):f=e.setTextContent(a);const x=[f];for(let t=1;t=T&&(p.set(t.getKey(),C-T,"text"),C=T){m.set(t.getKey(),S-T,"text");break}T=e}if(null!==u){!function(t){const e=t.getPreviousSibling(),n=t.getNextSibling();null!==e&&li(e);null!==n&&li(n)}(this);const t=u.getWritable(),e=this.getIndexWithinParent();_?(t.splice(e,0,x),this.remove()):t.splice(e,1,x),jo(y)&&yr(y,u,e,c-1)}return x}mergeWithSibling(e){const n=e===this.getPreviousSibling();n||e===this.getNextSibling()||t(50);const o=this.__key,r=e.__key,s=this.__text,i=s.length;ai()===r&&ci(o);const l=pr();if(jo(l)){const t=l.anchor,s=l.focus;null!==t&&t.key===r&&Sr(t,n,o,e,i),null!==s&&s.key===r&&Sr(s,n,o,e,i)}const c=e.__text,a=n?c+s:s+c;this.setTextContent(a);const u=this.getWritable();return e.remove(),u}isTextEntity(){return!1}}function No(t){return{forChild:Io(t.style),node:null}}function vo(t){const e=t,n="normal"===e.style.fontWeight;return{forChild:Io(e.style,n?void 0:"bold"),node:null}}const Eo=new WeakMap;function ko(t){if(!Sl(t))return!1;if("PRE"===t.nodeName)return!0;const e=t.style.whiteSpace;return"string"==typeof e&&e.startsWith("pre")}function Oo(e){const n=e;null===e.parentElement&&t(129);let o=n.textContent||"";if(null!==function(t){let e,n=t.parentNode;const o=[t];for(;null!==n&&void 0===(e=Eo.get(n))&&!ko(n);)o.push(n),n=n.parentNode;const r=void 0===e?n:e;for(let t=0;t0){/[ \t\n]$/.test(n)&&(o=o.slice(1)),e=!1;break}}e&&(o=o.slice(1))}if(" "===o[o.length-1]){let t=n,e=!0;for(;null!==t&&null!==(t=bo(t,!0));){if((t.textContent||"").replace(/^( |\t|\r?\n)+/,"").length>0){e=!1;break}}e&&(o=o.slice(0,o.length-1))}return""===o?{node:null}:{node:Do(o)}}function bo(t,e){let n=t;for(;;){let t;for(;null===(t=e?n.nextSibling:n.previousSibling);){const t=n.parentElement;if(null===t)return null;n=t}if(n=t,Sl(n)){const t=n.style.display;if(""===t&&!El(n)||""!==t&&!t.startsWith("inline"))return null}let o=n;for(;null!==(o=e?n.firstChild:n.lastChild);)n=o;if(ti(n))return n;if("BR"===n.nodeName)return null}}const Mo={code:"code",em:"italic",i:"italic",mark:"highlight",s:"strikethrough",strong:"bold",sub:"subscript",sup:"superscript",u:"underline"};function Ao(t){const e=Mo[t.nodeName.toLowerCase()];return void 0===e?{node:null}:{forChild:Io(t.style,e),node:null}}function Do(t=""){return Zi(new To(t))}function wo(t){return t instanceof To}function Io(t,e){const n=t.fontWeight,o=t.textDecoration.split(" "),r="700"===n||"bold"===n,s=o.includes("line-through"),i="italic"===t.fontStyle,l=o.includes("underline"),c=t.verticalAlign;return t=>wo(t)||So(t)?(r&&!t.hasFormat("bold")&&t.toggleFormat("bold"),s&&!t.hasFormat("strikethrough")&&t.toggleFormat("strikethrough"),i&&!t.hasFormat("italic")&&t.toggleFormat("italic"),l&&!t.hasFormat("underline")&&t.toggleFormat("underline"),"sub"!==c||t.hasFormat("subscript")||t.toggleFormat("subscript"),"super"!==c||t.hasFormat("superscript")||t.toggleFormat("superscript"),e&&!t.hasFormat(e)&&t.toggleFormat(e),t):t}class Po extends To{$config(){return this.config("tab",{extends:To})}constructor(t=void 0){super("\t",t),this.__detail=2}createDOM(t){const e=super.createDOM(t),n=Pi(t.theme,"tab");if(void 0!==n){e.classList.add(...n)}return e}setTextContent(t){return super.setTextContent("\t")}spliceText(e,n,o,r){return""===o&&0===n||"\t"===o&&1===n||t(286),this}setDetail(e){return 2!==e&&t(127),this}setMode(e){return"normal"!==e&&t(128),this}canInsertTextBefore(){return!1}canInsertTextAfter(){return!1}}function Fo(){return Zi(new Po)}function Ro(t){return t instanceof Po}class Lo{key;offset;type;_selection;constructor(t,e,n){this._selection=null,this.key=t,this.offset=e,this.type=n}is(t){return this.key===t.key&&this.offset===t.offset&&this.type===t.type}isBefore(t){if(this.key===t.key)return this.offsett&&(o=t)}else if(!as(e)){const t=e.getNextSibling();if(wo(t))n=t.__key,o=0,r="text";else{const t=e.getParent();t&&(n=t.__key,o=e.getIndexWithinParent()+1)}}t.set(n,o,r)}function $o(t,e){if(as(e)){const n=e.getLastDescendant();as(n)||wo(n)?Bo(t,n):Bo(t,e)}else Bo(t,e)}function zo(t,e,n,o){const r=t.getNode(),s=r.getChildAtIndex(t.offset),i=Do();if(i.setFormat(n),i.setStyle(o),As(s))s.splice(0,0,[i]);else if(null!==s){const t=Xi(r)?Ms().append(i):i;s.insertBefore(t)}else if(Xi(r)){const t=r.getLastChild();as(t)&&!t.isInline()&&t.isEmpty()?t.append(i):r.append(Ms().append(i))}else r.append(i);t.is(e)&&e.set(i.__key,0,"text"),t.set(i.__key,0,"text")}function Wo(e,n,o,r){const s=e.anchor.getNode();wo(s)||t(398);const i=e.anchor.offset,l=Do(n);l.setFormat(o),l.setStyle(r);const c=s.getParentOrThrow();if(0===i)c.isInline()&&!s.__prev?c.insertBefore(l):s.insertBefore(l,!1);else if(i===s.getTextContentSize())c.isInline()&&!s.__next?c.insertAfter(l):s.insertAfter(l,!1);else{const[t]=s.splitText(i);t.insertAfter(l,!1)}""===s.getTextContent()&&s.isAttached()&&s.remove(),l.selectEnd(),l.isComposing()&&"text"===e.anchor.type&&e.anchor.set(e.anchor.key,e.anchor.offset-n.length,e.anchor.type)}class Uo{_nodes;_cachedNodes;dirty;constructor(t){this._cachedNodes=null,this._nodes=t,this.dirty=!1}getCachedNodes(){return this._cachedNodes}setCachedNodes(t){this._cachedNodes=t}is(t){if(!Go(t))return!1;const e=this._nodes,n=t._nodes;return e.size===n.size&&Array.from(e).every(t=>n.has(t))}isCollapsed(){return!1}isBackward(){return!1}getStartEndPoints(){return null}add(t){this.dirty=!0,this._nodes.add(t),this._cachedNodes=null}delete(t){this.dirty=!0,this._nodes.delete(t),this._cachedNodes=null}clear(){this.dirty=!0,this._nodes.clear(),this._cachedNodes=null}has(t){return this._nodes.has(t)}clone(){return new Uo(new Set(this._nodes))}extract(){return this.getNodes()}insertRawText(t){}insertText(){}insertNodes(t){const e=this.getNodes().filter(t=>null===nc(t)),n=e.length;if(0===n)return;const o=e[n-1];let r;if(wo(o))r=o.select();else{const t=o.getIndexWithinParent()+1;r=o.getParentOrThrow().select(t,t)}r.insertNodes(t);for(let t=0;tnull===nc(t));if((pr()||mr())===this&&t[0]){const e=Rc(t[0],"next");na(Gc(e,e))}for(const e of t)e.remove();Ho()}}function Ho(){const t=mi();if(t.isEmpty()){const e=Ms();t.append(e),e.select()}}function jo(t){return t instanceof Yo}class Yo{format;style;anchor;focus;_cachedNodes;_cachedIsBackward;dirty;constructor(t,e,n,o){this.anchor=t,this.focus=e,t._selection=this,e._selection=this,this._cachedNodes=null,this._cachedIsBackward=null,this.format=n,this.style=o,this.dirty=!1}getCachedNodes(){return this._cachedNodes}setCachedNodes(t){this._cachedNodes=t}is(t){return!!jo(t)&&(this.anchor.is(t.anchor)&&this.focus.is(t.focus)&&this.format===t.format&&this.style===t.style)}isCollapsed(){return this.anchor.is(this.focus)}getNodes(){const t=this._cachedNodes;if(null!==t)return t;const e=function(t){const e=[],[n,o]=t.getTextSlices();n&&e.push(n.caret.origin);const r=new Set,s=new Set;for(const n of t)if(wc(n)){const{origin:t}=n;0===e.length?r.add(t):(s.add(t),e.push(t))}else{const{origin:t}=n;as(t)&&s.has(t)||e.push(t)}o&&e.push(o.caret.origin);if(Dc(t.focus)&&as(t.focus.origin)&&null===t.focus.getNodeAtCaret())for(let n=$c(t.focus.origin,"previous");wc(n)&&r.has(n.origin)&&!n.origin.isEmpty()&&n.origin.is(e[e.length-1]);n=Wc(n))r.delete(n.origin),e.pop();for(;e.length>1;){const t=e[e.length-1];if(!as(t)||s.has(t)||t.isEmpty()||r.has(t))break;e.pop()}if(0===e.length&&t.isCollapsed()){const n=aa(t.anchor),o=aa(t.anchor.getFlipped()),r=t=>Ac(t)?t.origin:t.getNodeAtCaret(),s=r(n)||r(o)||(t.anchor.getNodeAtCaret()?n.origin:o.origin);e.push(s)}return e}(da(ra(this),"next"));return zr()||(this._cachedNodes=e),e}setTextNodeRange(t,e,n,o){return this.anchor.set(t.__key,e,"text"),this.focus.set(n.__key,o,"text"),this}getTextContent(){const t=this.getNodes();if(0===t.length)return"";const e=t[0],n=t[t.length-1],o=this.anchor,r=this.focus,s=o.isBefore(r),[i,l]=Xo(this);let c="",a=!0;for(let u=0;u(as(t)||ds(t))&&!t.isInline())){as(r)||t(211,o.constructor.name,o.getType());const n=br(this);return r.splice(n,0,e),void s.selectEnd()}if(as(r)&&null!==nc(r)){const t=br(this),n=Or(e);r.splice(t,0,n);const o=n[n.length-1];return void(void 0!==o?o.selectEnd():r.select(t,t))}if(null===r){const t=Dr(e),n=t.getLastDescendant();let o=ta(this.anchor,"next");for(const e of t.getChildren())o=ma(e,o);return void(null!==n&&n.selectEnd())}if(as(r)&&!r.isParentRequired()&&!Xi(r.getParentOrThrow())){const t=br(this),n=Or(e);r.splice(t,0,n);const o=n[n.length-1];return void(void 0!==o?o.selectEnd():r.select(t,t))}const i=Dr(e),l=i.getLastDescendant(),c=i.getChildren(),a=!as(r)||!r.isEmpty()?this.insertParagraph():null;a&&!r.isAttached()&&(o=this.anchor.getNode(),r=ql(o,bl));const u=c[c.length-1];let f=c[0];var d;as(d=f)&&bl(d)&&!d.isEmpty()&&as(r)&&(!r.isEmpty()||r.canMergeWhenEmpty())&&(as(r)||t(211,o.constructor.name,o.getType()),r.append(...f.getChildren()),f=c[1]),f&&(null===r&&t(212,o.constructor.name,o.getType()),function(e,n){const o=n.getParentOrThrow().getLastChild();let r=n;const s=[n];for(;r!==o;)r.getNextSibling()||t(140),r=r.getNextSibling(),s.push(r);let i=e;for(const t of s)i=i.insertAfter(t)}(r,f));const h=ql(l,bl);a&&as(h)&&(a.canMergeWhenEmpty()||bl(u))&&(h.append(...a.getChildren()),a.remove()),as(r)&&r.isEmpty()&&r.remove(),l.selectEnd();const g=as(r)?r.getLastChild():null;Ns(g)&&h!==r&&g.remove()}insertParagraph(){const e=this.anchor.getNode();if("element"===this.anchor.type&&Xi(e)){const t=Ms();return e.splice(this.anchor.offset,0,[t]),t.select(),t}const n=br(this),o=ql(this.anchor.getNode(),bl);if(null!==o&&null!==nc(o))return null;as(o)||t(213);const r=o.getChildAtIndex(n),s=r?[r,...r.getNextSiblings()]:[],i=o.insertNewAfter(this,!1);return i?(i.append(...s),i.selectStart(),i):null}insertLineBreak(t){const e=Ts();if(this.insertNodes([e]),t){const t=e.getParentOrThrow(),n=e.getIndexWithinParent();t.select(n,n)}}extract(){const t=[...this.getNodes()],e=t.length;let n=t[0],o=t[e-1];const[r,s]=Xo(this),i=this.isBackward(),[l,c]=i?[this.focus,this.anchor]:[this.anchor,this.focus],[a,u]=i?[s,r]:[r,s];if(0===e)return[];if(1===e){if(wo(n)&&!this.isCollapsed()){const t=n.splitText(a,u),e=0===a?t[0]:t[1];return e?(l.set(e.getKey(),0,"text"),c.set(e.getKey(),e.getTextContentSize(),"text"),[e]):[]}return[n]}if(wo(n)&&(a===n.getTextContentSize()?t.shift():0!==a&&([,n]=n.splitText(a),t[0]=n,l.set(n.getKey(),0,"text"))),wo(o)){const e=o.getTextContent().length;0===u?t.pop():u!==e&&([o]=o.splitText(u),t[t.length-1]=o,c.set(o.getKey(),o.getTextContentSize(),"text"))}return t}modify(t,e,n){if(wr(this,t,e,n))return;const o="move"===t,r=jr(),s=rl(Gi(r));if(!s)return;const i=r._blockCursorElement,l=r._rootElement,c=this.focus.getNode();null===l||null===i||!as(c)||c.isInline()||c.canBeEmpty()||ol(i,r,l);const a=$i(r,this.focus.key);let u=a;if("text"===this.focus.type&&(u=wo(c)?Il(c,a,r):null),this.dirty){const t=$i(r,this.anchor.key);let e=t;if("text"===this.anchor.type){const n=this.anchor.getNode();e=wo(n)?Il(n,t,r):null}e&&u&&Tr(s,e,this.anchor.offset,u,this.focus.offset)}if("character"===n&&wo(c)&&c.isUnmergeable()){if(e?0===this.focus.offset:this.focus.offset===c.getTextContentSize()){const t=Rc(c,e?"previous":"next").getNodeAtCaret();if(wo(t)){if(!o){const n=t.getTextContentSize();return e?this.focus.set(t.__key,n-1,"text"):this.focus.set(t.__key,1,"text"),void(this.dirty=!0)}{const n=r.getElementByKey(t.getKey()),o=n?Il(t,n,r):null;if(o){const t=e?o.length:0;Tr(s,o,t,o,t)}}}}}if(tr(s,t,e?"backward":"forward",n),s.rangeCount>0){const t=dl(s,r._rootElement),n=t||s.getRangeAt(0),i=this.anchor.getNode(),l=gs(i)?i:Vi(i);if(this.applyDOMRange(n),this.dirty=!0,!o){er(this,e,l);(t?"backward"!==s.direction:s.anchorNode===n.startContainer&&s.anchorOffset===n.startOffset)||Zo(this)}}"lineboundary"===n&&wr(this,t,e,n,"decorators")}forwardDeletion(t,e,n){if(!n&&("element"===t.type&&as(e)&&t.offset===e.getChildrenSize()||"text"===t.type&&t.offset===e.getTextContentSize())){const t=e.getParent(),n=e.getNextSibling()||(null===t?null:t.getNextSibling());if(as(n)&&n.isShadowRoot())return!0}return!1}deleteCharacter(t){const e=this.isCollapsed();if(this.isCollapsed()){const e=this.anchor;let n=e.getNode();if(this.forwardDeletion(e,n,t))return;const o=jc(ta(e,t?"previous":"next"));if(o.getTextSlices().every(t=>null===t||0===t.distance)){let t={type:"initial"};for(const e of o.iterNodeCarets("shadowRoot"))if(wc(e))if(e.origin.isInline());else{if(e.origin.isShadowRoot()){if("merge-block"===t.type)break;if(as(o.anchor.origin)&&o.anchor.origin.isEmpty()){const t=aa(e);oa(this,Gc(t,t)),o.anchor.origin.remove()}return}"merge-next-block"!==t.type&&"merge-block"!==t.type||(t={block:t.block,caret:e,type:"merge-block"})}else{if("merge-block"===t.type)break;if(Dc(e)){if(as(e.origin)){if(e.origin.isInline()){if(!e.origin.isParentOf(o.anchor.origin))break}else t={block:e.origin,type:"merge-next-block"};continue}if(ds(e.origin)){if(e.origin.isIsolated());else if(lc(e.origin).length>0){if(as(o.anchor.origin)&&o.anchor.origin.isEmpty()){o.anchor.origin.remove();const t=gr();t.add(e.origin.getKey()),yi(t)}}else if("merge-next-block"===t.type&&(e.origin.isKeyboardSelectable()||!e.origin.isInline())&&as(o.anchor.origin)&&o.anchor.origin.isEmpty()){o.anchor.origin.remove();const t=gr();t.add(e.origin.getKey()),yi(t)}else e.origin.remove();return}break}}if("merge-block"===t.type){const{caret:e,block:n}=t;if(lc(n).length>0)return;return e.origin.isEmpty()&&!n.isEmpty()&&e.origin.getParent()===n.getParent()?void e.origin.remove(!0):(oa(this,Gc(!e.origin.isEmpty()&&n.isEmpty()?sa(Rc(n,e.direction)):o.anchor,e)),this.removeText())}for(let t=e.getNode();null!==t;){if(null!==nc(t))return;if(as(t)&&t.isShadowRoot())break;t=t.getParent()}}const r=this.focus;if(nr(this,t,"character"),this.isCollapsed()){if(t&&0===e.offset&&Qo(this,e.getNode()))return}else{const o="text"===r.type?r.getNode():null;if(n="text"===e.type?e.getNode():null,null!==o&&o.isSegmented()){const e=r.offset,s=o.getTextContentSize();if(o.is(n)||t&&e!==s||!t&&0!==e)return void rr(o,t,e)}else if(null!==n&&n.isSegmented()){const r=e.offset,s=n.getTextContentSize();if(n.is(o)||t&&0!==r||!t&&r!==s)return void rr(n,t,r)}!function(t,e){const n=t.anchor,o=t.focus,r=n.getNode(),s=o.getNode();if(r===s&&"text"===n.type&&"text"===o.type){const t=n.offset,s=o.offset,i=t0&&(g===h.getTextContentSize()||Zs(h)||([h]=h.splitText(g)),h.setFormat(p));for(let t=a+1;toi(t,e,o))}function qo(t){const e=t.offset;if("text"===t.type)return e;const n=t.getNode();return e===n.getChildrenSize()?n.getTextContent().length:0}function Xo(t){const e=t.getStartEndPoints();if(null===e)return[0,0];const[n,o]=e;return"element"===n.type&&"element"===o.type&&n.key===o.key&&n.offset===o.offset?[0,0]:[qo(n),qo(o)]}function Qo(t,e){for(let n=e;n;n=n.getParent()){if(as(n)){if(n.collapseAtStart(t))return!0;if(Xi(n))break}if(n.getPreviousSibling())break}return!1}function Zo(t){const e=t.focus,n=t.anchor,o=n.key,r=n.offset,s=n.type;n.set(e.key,e.offset,e.type,!0),e.set(o,r,s,!0)}function tr(t,e,n,o){t.modify(e,n,o)}function er(t,e,n){const o=t.getNodes(),r=o.filter(t=>ji(t,n));if(0===r.length||r.length===o.length)return!1;const s=e?r[0]:r[r.length-1],i=as(s)?s:s.getParentOrThrow();return e?i.selectStart():i.selectEnd(),!0}function nr(t,e,n){if(wr(t,"extend",e,n))return;const o=jr(),r=rl(Gi(o));if(!r||"function"!=typeof r.modify)return;const s=o._blockCursorElement,i=o._rootElement,l=t.anchor,c=t.focus.getNode();null===i||null===s||!as(c)||c.isInline()||c.canBeEmpty()||ol(s,o,i);const a=t=>{const e=t.getNode(),n=o.getElementByKey(t.key);return null!==n&&"text"===t.type&&wo(e)?Il(e,n,o):n},u=l.getNode(),f=a(l);if(null===f)return;const d=l.offset,h=t.isCollapsed(),g=t.focus,_=h?f:a(g);if(null===_)return;const p=g.offset;if(Tr(r,_,p,_,p),tr(r,"move",e?"backward":"forward",n),0===r.rangeCount)return;const m=dl(r,i)||r.getRangeAt(0),y=m.startContainer,x=m.startOffset;if(h&&"character"===n&&"text"===l.type&&wo(u)&&u.isUnmergeable()){if(d===(e?0:u.getTextContentSize())){const n=Rc(u,e?"previous":"next").getNodeAtCaret();if(wo(n)){const o=e?n.getTextContentSize()-1:1;return t.focus.set(n.__key,o,"text"),void(t.dirty=!0)}}}if(h&&"character"===n&&"text"===l.type){const n=e?0:u.getTextContentSize(),o=y===f?x:d!==n?n:-1;if(o>=0)return void(o!==d&&(t.focus.set(l.key,o,"text"),t.dirty=!0))}const[C,S,T,N]=e?[y,x,f,d]:[f,d,y,x],v=gs(u)?u:Vi(u);t.applyDOMRange({collapsed:!1,endContainer:T,endOffset:N,startContainer:C,startOffset:S}),t.dirty=!0,!er(t,e,v)&&e&&Zo(t),"lineboundary"===n&&wr(t,"extend",e,n,"decorators")}const or=(()=>{try{const t=new RegExp("\\p{Emoji}","u"),e=t.test.bind(t);if(e("\u2764\ufe0f")&&e("#\ufe0f\u20e3")&&e("\u{1f44d}"))return e}catch(t){}return()=>!1})();function rr(t,e,n){const o=t,r=o.getTextContent().split(/(?=\s)/g),s=r.length;let i=0,l=0;for(let t=0;tn||o){r.splice(t,1),o&&(l=void 0);break}}const c=r.join("").trim();""===c?o.remove():(o.setTextContent(c),o.select(l,l))}function sr(e,n,o,r){let s,i=n,l=!1;if(Sl(e)){let c=!1;const a=e.childNodes,u=a.length,f=r._blockCursorElement;i===u&&u>0&&(c=!0,i=u-1),void 0!==hi(e,r)||Hl(e,r)||(l=!0);let d=a[i],h=!1;if(d===f)d=a[i+1],h=!0;else if(null!==f){const t=f.parentNode;if(e===t){n>Array.prototype.indexOf.call(t.children,f)&&i--}}if(s=Ci(d),wo(s))i=Kc(s,c?"next":"previous");else{let a=Ci(e);if(null===a)return null;if(as(a)){const l=r.getElementByKey(a.getKey());null===l&&t(214);const u=Dl(a,l,r);[a,i]=u.resolveChildIndex(a,l,e,n),as(a)||t(215),c&&i>=a.getChildrenSize()&&(i=Math.max(0,a.getChildrenSize()-1));let f=a.getChildAtIndex(i);if(as(f)&&function(t,e,n){const o=t.getParent();return null===n||null===o||!o.canBeEmpty()||o!==n.getNode()}(f,0,o)){const t=c?f.getLastDescendant():f.getFirstDescendant();null===t?a=f:(f=t,a=as(f)?f:f.getParentOrThrow()),i=0}wo(f)?(s=f,a=null,i=Kc(f,c?"next":"previous")):f!==a&&c&&!h&&(as(a)||t(216),i=Math.min(a.getChildrenSize(),i+1))}else{const t=oc(a),o=null!==t?t:a,s=o.getIndexWithinParent(),l=r.getElementByKey(a.getKey());let c="after";if(null!==l&&Ci(e)===a){const t=Dl(a,l,r);t.element!==l?c=t.resolveLeafPosition(l,e,n):0===n&&ds(a)&&(c="before")}i="before"===c?s:s+1,a=o.getParentOrThrow()}if(as(a))return[Ko(a.__key,i,"element"),l]}}else s=Ci(e);return wo(s)?[Ko(s.__key,Kc(s,i,"clamp"),"text"),l]:null}function ir(t,e,n){const o=t.offset,r=t.getNode();if(0===o){const o=r.getPreviousSibling(),s=r.getParent();if(e){if((n||!e)&&null===o&&as(s)&&s.isInline()){const e=s.getPreviousSibling();wo(e)&&t.set(e.__key,e.getTextContent().length,"text")}}else as(o)&&!n&&o.isInline()?t.set(o.__key,o.getChildrenSize(),"element"):wo(o)&&!r.isUnmergeable()&&t.set(o.__key,o.getTextContent().length,"text")}else if(o===r.getTextContent().length){const o=r.getNextSibling(),s=r.getParent();if(e&&as(o)&&o.isInline())t.set(o.__key,0,"element");else if((n||e)&&null===o&&as(s)&&s.isInline()&&!s.canInsertTextAfter()&&s.getTextContentSize()>1){const e=s.getNextSibling();wo(e)&&t.set(e.__key,0,"text")}}}function lr(t){const e=ui(t.key);return null===e?null:sc(e)}function cr(t,e,n){const o=lr(t),r=lr(e);if(o===r||null!==o&&null!==r&&o.is(r))return!1;const s=n(o,r);if(null!==o)return as(o)?e.set(o.getKey(),s?o.getChildrenSize():0,"element"):e.set(o.getKey(),s?o.getTextContentSize():0,"text"),!0;const i=oc(r);if(null===i)return!1;const l=i.getParent();if(null===l)return!1;const c=i.getIndexWithinParent();return e.set(l.getKey(),s?c+1:c,"element"),!0}function ar(t){const e=cr(t.anchor,t.focus,(e,n)=>function(t,e,n,o){if(null!==n&&null!==o){const t=oc(n),e=oc(o);if(null!==t&&t.is(e)){for(const e of ic(t).values()){if(e===n.getKey())return!0;if(e===o.getKey())return!1}return!0}return null===t||null===e||t.isBefore(e)}if(null!==n){const t=oc(n),o=ui(e.key);return null===t||null===o||!(!t.is(o)&&!t.isParentOf(o))||t.isBefore(o)}const r=oc(o),s=ui(t.key);return null!==r&&null!==s&&!r.is(s)&&!r.isParentOf(s)&&s.isBefore(r)}(t.anchor,t.focus,e,n));return e&&(t.dirty=!0),e}function ur(t,e,n,o,r,s){if(null===t||null===n||!Js(r,t,n))return null;const i=sr(t,e,jo(s)?s.anchor:null,r);if(null===i)return null;const l=sr(n,o,jo(s)?s.focus:null,r);if(null===l)return null;const[c,a]=i,[u,f]=l;if("element"===c.type&&"element"===u.type){const e=Ci(t),o=Ci(n);if(ds(e)&&ds(o))return null}const d=r._slotsUsed&&cr(c,u,()=>0!==(t.compareDocumentPosition(n)&Node.DOCUMENT_POSITION_FOLLOWING));return function(t,e){if("text"===t.type&&"text"===e.type){const n=t.isBefore(e),o=t.is(e);ir(t,n,o),ir(e,!n,o),o&&e.set(t.key,t.offset,t.type)}}(c,u),[c,u,a||f||d]}function fr(t){return as(t)&&!t.isInline()}function dr(t,e,n,o,r,s){const i=Hr(),l=new Yo(Ko(t,e,r),Ko(n,o,s),0,"");return l.dirty=!0,i._selection=l,l}function hr(){const t=Ko("root",0,"element"),e=Ko("root",0,"element");return new Yo(t,e,0,"")}function gr(){return new Uo(new Set)}function _r(t,e,n,o){const r=n._window;if(null===r)return null;const s=o||r.event,i=s?s.type:void 0,l="selectionchange"===i,c=!q&&(l||"beforeinput"===i||"compositionstart"===i||"compositionend"===i||"click"===i&&s&&3===s.detail||"drop"===i||void 0===i);let a,u,f,d;if(jo(t)&&!c)return t.clone();{if(null===e)return null;const o=gl(e,n._rootElement);if(a=o.anchorNode,u=o.focusNode,f=o.anchorOffset,d=o.focusOffset,(l||void 0===i)&&jo(t)&&!Js(n,a,u))return t.clone()}const h=ur(a,f,u,d,n,t);if(null===h)return null;const[g,_,p]=h;let m=0,y="";if(jo(t)){const e=t.anchor;if(g.key===e.key)m=t.format,y=t.style;else{const t=g.getNode();wo(t)?(m=t.getFormat(),y=t.getStyle()):as(t)&&(m=t.getTextFormat(),y=t.getTextStyle())}}const x=new Yo(g,_,m,y);return p&&(x.dirty=!0),x}function pr(){return Hr()._selection}function mr(){return jr()._editorState._selection}function yr(t,e,n,o=1){const r=t.anchor,s=t.focus,i=r.getNode(),l=s.getNode();if(!e.is(i)&&!e.is(l))return;const c=e.__key;if(t.isCollapsed()){const e=r.offset;if(n<=e&&o>0||n0||n0||n=t,i=r?s.getChildAtIndex(t-1):s.getChildAtIndex(n);if(wo(i)){let t=0;r&&(t=i.getTextContentSize()),e.set(i.__key,t,"text"),o.set(i.__key,t,"text")}return}if(as(s)){const t=s.getChildrenSize(),o=n>=t,r=o?s.getChildAtIndex(t-1):s.getChildAtIndex(n);if(wo(r)){let t=0;o&&(t=r.getTextContentSize()),e.set(r.__key,t,"text")}}if(as(i)){const t=i.getChildrenSize(),e=r>=t,n=e?i.getChildAtIndex(t-1):i.getChildAtIndex(r);if(wo(n)){let t=0;e&&(t=n.getTextContentSize()),o.set(n.__key,t,"text")}}}function Cr(t,e,n,o,r){let s=null,i=0,l=null;null!==o?(s=o.__key,wo(o)?(i=o.getTextContentSize(),l="text"):as(o)&&(i=o.getChildrenSize(),l="element")):null!==r&&(s=r.__key,wo(r)?l="text":as(r)&&(l="element")),null!==s&&null!==l?t.set(s,i,l):(i=e.getIndexWithinParent(),-1===i&&(i=n.getChildrenSize()),t.set(n.__key,i,"element"))}function Sr(t,e,n,o,r){"text"===t.type?t.set(n,t.offset+(e?0:r),"text"):t.offset>o.getIndexWithinParent()&&t.set(t.key,t.offset-1,"element")}function Tr(t,e,n,o,r){try{t.setBaseAndExtent(e,n,o,r)}catch(t){}}function Nr(t,e,n){const o=$i(t,e.getKey());if(as(e)){const r=Dl(e,o,t);return[r.element,n+r.getFirstChildOffset()]}return[o,n]}function vr(t,e,n,o,r,i){const l=i.getRootNode(),c=ei(l)||il(l)?xl(l):null;if(r.has(ro)&&c!==i||null!==c&&Ys(c,c))return;const a=gl(o,i);let u;if(!jo(e))return void(null!==t&&Js(n,a.anchorNode,a.focusNode)&&o.removeAllRanges());const f=e.anchor,d=e.focus,h=f.getNode(),g=d.getNode(),[_,p]=Nr(n,h,f.offset),[m,y]=Nr(n,g,d.offset),x=e.format,C=e.style,S=e.isCollapsed();let T=_,N=m,v=!1;if("text"===f.type?(T=wo(h)?Il(h,_,n):null,v=h.getFormat()!==x||h.getStyle()!==C):jo(t)&&"text"===t.anchor.type&&(v=!0),"text"===d.type&&(N=wo(g)?Il(g,m,n):null),null!==T&&null!==N){if(S&&(null===t||v||jo(t)&&(t.format!==x||t.style!==C))&&function(t,e,n,o,r,s){t._inputState.collapsedSelectionFormat={format:e,key:r,offset:o,style:n,timeStamp:s}}(n,x,C,p,f.key,performance.now()),("Range"!==o.type||!S)&&a.anchorOffset===p&&a.focusOffset===y&&a.anchorNode===T&&a.focusNode===N){if(null===c||!i.contains(c)){const t=null!==c?qs(c):null;null!==t&&t!==n||r.has(lo)||i.focus({preventScroll:!0})}if("element"!==f.type)return}if(Tr(o,T,p,N,y),s&&e.isCollapsed()&&null!==i&&!r.has(lo)){const t=yl(i);if(null===t||!i.contains(t)){const t=xl(i.ownerDocument),e=null!==t?qs(t):null;null!==e&&e!==n||i.focus({preventScroll:!0})}}if(!r.has(so)&&e.isCollapsed()&&null!==i&&i===yl(i)){const t=jo(e)&&"element"===e.anchor.type?T.childNodes[p]||null:(void 0===u&&(u=hl(o,i)),u);if(null!==t){let e;if(ti(t)){const n=t.ownerDocument.createRange();n.selectNode(t),e=n.getBoundingClientRect()}else e=t.getBoundingClientRect();!function(t,e,n){const o=Wi(n),r=Yi(o);if(null===o||null===r)return;const s=n.getBoundingClientRect();if(e.bottoma&&(f=l-a),0!==f)if(e)r.scrollBy(0,f);else{const t=u.scrollTop;u.scrollTop+=f;const e=u.scrollTop-t;i-=e,l-=e}if(e)break;u=zi(u)}}(n,e,i)}}!function(t){t._inputState.isSelectionChangeFromDOMUpdate=!0}(n)}}function Er(t,e){for(const n of t.split(/(\r?\n|\t)/))"\n"===n||"\r\n"===n?e.linebreak():"\t"===n?e.tab():""!==n&&e.text(n)}function kr(t){const e=[];return Er(t,{linebreak:()=>e.push(Ts()),tab:()=>e.push(Fo()),text:t=>e.push(Do(t))}),e}function Or(t){const e=[];for(const n of t)Ns(n)||(!as(n)&&!ds(n)||n.isInline()?e.push(n):as(n)&&e.push(...Or(n.getChildren())));return e}function br(e){let n=e;e.isCollapsed()||n.removeText();const o=pr();jo(o)&&(n=o),jo(n)||t(161);const r=n.anchor;let s=r.getNode(),i=r.offset;for(;!bl(s)&&null===nc(s);){const t=s;if([s,i]=Mr(s,i),t.is(s))break}return i}function Mr(t,e){const n=t.getParent();if(!n){const t=Ms();return mi().append(t),t.select(),[mi(),0]}if(wo(t)){const o=t.splitText(e);if(0===o.length)return[n,t.getIndexWithinParent()];const r=0===e?0:1;return[n,o[0].getIndexWithinParent()+r]}if(!as(t)||0===e)return[n,t.getIndexWithinParent()];const o=t.getChildAtIndex(e);if(o){const n=new Yo(Ko(t.__key,e,"element"),Ko(t.__key,e,"element"),0,""),r=t.insertNewAfter(n);r&&r.append(o,...o.getNextSiblings())}return[n,t.getIndexWithinParent()+1]}function Ar(t){return Ns(t)||Ji(t)||wo(t)||t.isParentRequired()}function Dr(t){const e=Ms();let n=null;for(let o=0;o99&&t(14)}function Hr(){return null===Ir&&t(195,Gr()),Ir}function jr(){return null===Pr&&t(337,Gr()),Pr}function Yr(){jr()._dirtyType=2}function Gr(){let t=0;const e=new Set,n=Ks.version;if("undefined"!=typeof window)for(const o of al(document)){const r=Xs(o);if(Vs(r))t++;else if(r){let t=String(r.constructor.version||"<0.17.1");t===n&&(t+=" (separately built, likely a bundler configuration issue)"),e.add(t)}}let o=` Detected on the page: ${t} compatible editor(s) with version ${n}`;return e.size&&(o+=` and incompatible editors with versions ${Array.from(e).join(", ")}`),o}function Jr(){return Pr}function Vr(t,e,n){const o=e.__type,r=Us(t,o);let s=n.get(o);void 0===s&&(s=Array.from(r.transforms),n.set(o,s));const i=s.length;for(let t=0;t0&&os(t,t._deferred));const s=t._editorState,i=s._selection,l=n._selection,c=0!==t._dirtyType,a=Ir,u=Fr,f=Pr,d=t._updating,h=t._observer;let g=null;if(t._pendingEditorState=null,t._editorState=n,!r&&c&&null!==h){Pr=t,Ir=n,Fr=!1,t._updating=!0;try{const e=t._dirtyType,o=t._dirtyElements,r=t._dirtyLeaves;h.disconnect(),g=Ce(s,n,t,e,o,r)}catch(e){if(e instanceof Error&&t._onError(e),Rr)throw e;return Is(t,null,o,n),st(t),t._dirtyType=2,Rr=!0,ts(t,s),void(Rr=!1)}finally{h.observe(o,$r),t._updating=d,Ir=a,Fr=u,Pr=f}}n._readOnly||(n._readOnly=!0);const _=t._dirtyLeaves,p=t._dirtyElements,m=t._normalizedNodes,y=t._updateTags;c&&(t._dirtyType=0,t._cloneNotNeeded.clear(),t._dirtyLeaves=new Set,t._dirtyElements=new Map,t._normalizedNodes=new Set);t._updateTags=new Set,function(t,e){const n=t._decorators;let o=t._pendingDecorators||n;const r=e._nodeMap;let s;for(s in o)r.has(s)||(o===n&&(o=_i(t)),delete o[s])}(t,n);const x=r?null:rl(Gi(t));if(t._editable&&null!==x&&(c||null===l||l.dirty||!l.is(i))&&null!==o&&!y.has(io)){Pr=t,Ir=n;try{if(null!==h&&h.disconnect(),c||null===l||l.dirty){const e=t._blockCursorElement;null!==e&&ol(e,t,o),vr(i,l,t,x,y,o)}!function(t,e,n){let o=t._blockCursorElement;if(jo(n)&&n.isCollapsed()&&"element"===n.anchor.type&&e.contains(yl(e))){const r=n.anchor,s=r.getNode(),i=r.offset;let l=!1,c=null;if(i===s.getChildrenSize()){nl(s.getChildAtIndex(i-1))&&(l=!0)}else{const e=s.getChildAtIndex(i);if(null!==e&&nl(e)){const n=e.getPreviousSibling();(null===n||nl(n))&&(l=!0,c=t.getElementByKey(e.__key))}}if(l){const n=Dl(s,t.getElementByKey(s.__key),t).element;return null===o&&(t._blockCursorElement=o=function(t){const e=t.theme,n=fl().createElement("div");n.contentEditable="false",n.setAttribute("data-lexical-cursor","true");let o=e.blockCursor;if(void 0!==o){if("string"==typeof o){const t=ya(o);o=e.blockCursor=t}void 0!==o&&n.classList.add(...o)}return n}(t._config)),e.style.caretColor="transparent",void(null===c?n.appendChild(o):n.insertBefore(o,c))}}null!==o&&ol(o,t,e)}(t,o,l)}finally{null!==h&&h.observe(o,$r),Pr=f,Ir=a}}null!==g&&function(t,e,n,o,r){const s=Array.from(t._listeners.mutation),i=s.length;for(let t=0;t{Kr.delete(t),t._cascadeCount=0},0)}(t),t._cascadeCount++>99)return t._updates=[],t._cascadeCount=0,void t._onWarn(new Error(`One or more update listeners are endlessly enqueueing more updates. May have encountered infinite recursion caused by update listeners that trigger additional updates without a stop condition. Editor namespace: ${t._config.namespace}`));const n=e.shift();if(n){const[e,o]=n;ss(t,e,o)}}(t)}(t,e)}finally{Lr=n}}function es(t,e,n,...o){const r=e._updating;e._updating=n;try{const n=e._listeners[t],r=Array.from(n);for(const[t,e]of r){e&&e();const r=t(...o);n.has(t)?n.set(t,r):r&&r()}}finally{e._updating=r}}function ns(t,e,n,o){const r=Ti(t);let s;if(!Lr)for(let t=0;t=0;t--)for(let i=0;i0&&l._updating){s=l;break}const c=l._commands.get(e);if(void 0!==c){const e=c[t];if(e.size>0){let t=!1;if(is(l,()=>{for(const r of e)if(r(n,o))return void(t=!0)}),t)return t}}}return s&&s.update(()=>{ns(s,e,n,o)}),!1}function os(t,e){if(t._deferred=[],0!==e.length){const n=t._updating;t._updating=!0;try{for(let t=0;t0||u>0;){if(c>0){e._dirtyLeaves=new Set;for(const t of l){const o=r.get(t);wo(o)&&o.isAttached()&&o.isSimpleText()&&!o.isUnmergeable()&&Tt(o),void 0!==o&&qr(o,s)&&Vr(e,o,i),n.add(t)}if(l=e._dirtyLeaves,c=l.size,c>0){Br++;continue}}e._dirtyLeaves=new Set,e._dirtyElements=new Map,a.delete("root")&&a.set("root",!0);for(const t of a){const n=t[0],l=t[1];if(o.set(n,l),!l)continue;const c=r.get(n);void 0!==c&&qr(c,s)&&Vr(e,c,i)}l=e._dirtyLeaves,c=l.size,a=e._dirtyElements,u=a.size,Br++}e._dirtyLeaves=n,e._dirtyElements=o}(a,e),rs(e),function(t,e,n,o){const r=t._nodeMap,s=e._nodeMap,i=[];for(const[t]of o){const e=s.get(t);void 0!==e&&(e.isAttached()||(as(e)&&V(e,t,r,s,i,o),r.has(t)||o.delete(t),i.push(t)))}for(const t of n){const e=s.get(t);void 0===e||e.isAttached()||(tc(e)&&null!==e.__slots&&V(e,t,r,s,i,n),r.has(t)||n.delete(t),i.push(t))}for(const t of i)s.delete(t);const l=jr(),c=l._compositionKey;null===c||s.has(c)||(l._compositionKey=null)}(c,a,e._dirtyLeaves,e._dirtyElements));r!==e._compositionKey&&(a._flushSync=!0);const s=a._selection;if(jo(s)){e._slotsUsed&&ar(s);const n=a._nodeMap,o=s.anchor.key,r=s.focus.key;void 0!==n.get(o)&&void 0!==n.get(r)||t(19)}else Go(s)&&0===s._nodes.size&&(a._selection=null)}catch(t){return t instanceof Error&&e._onError(t),e._pendingEditorState=c,e._dirtyType=2,e._cloneNotNeeded.clear(),e._dirtyLeaves=new Set,e._dirtyElements.clear(),void ts(e)}finally{Ir=f,Fr=d,Pr=h,e._updating=g,Br=0}const p=0!==e._dirtyType||e._deferred.length>0||function(t,e){const n=e.getEditorState()._selection,o=t._selection;if(null!==o){if(o.dirty||!o.is(n))return!0}else if(null!==n)return!0;return!1}(a,e);p?a._flushSync?(a._flushSync=!1,ts(e)):u&&js(()=>{ts(e)}):(a._flushSync=!1,u&&(r.clear(),e._deferred=[],e._pendingEditorState=null))}function is(t,e,n){Pr===t&&void 0===n?zr()?ss(t,e,n):e():ss(t,e,n)}function ls(t){if(Xi(t)){let e=null;for(const n of t.getChildren())e=n.isInline()?(e||n.replace(n.createParentElementNode())).append(n):null}}class cs extends eo{__first;__last;__size;__format;__style;__indent;__dir;__textFormat;__textStyle;__slotHost;__slots;$config(){return this.config(Symbol.for("ElementNode"),{$transform:ls,extends:eo})}constructor(t){super(t),this.__first=null,this.__last=null,this.__size=0,this.__format=0,this.__style="",this.__indent=0,this.__dir=null,this.__textFormat=0,this.__textStyle="",this.__slotHost=null,this.__slots=null}afterCloneFrom(e){super.afterCloneFrom(e),this.__key===e.__key&&(this.__first=e.__first,this.__last=e.__last,this.__size=e.__size,this.__slotHost=e.__slotHost,null!==this.__slotHost&&null!==this.__parent&&t(384,this.__key,String(this.__slotHost),String(this.__parent)),this.__slots=e.__slots),this.__indent=e.__indent,this.__format=e.__format,this.__style=e.__style,this.__dir=e.__dir,this.__textFormat=e.__textFormat,this.__textStyle=e.__textStyle}getFormat(){return this.getLatest().__format}getFormatType(){const t=this.getFormat();return I[t]||""}getStyle(){return this.getLatest().__style}getIndent(){return this.getLatest().__indent}getChildren(){const t=[];let e=this.getFirstChild();for(;null!==e;)t.push(e),e=e.getNextSibling();return t}getChildrenKeys(){const t=[];let e=this.getFirstChild();for(;null!==e;)t.push(e.__key),e=e.getNextSibling();return t}getChildrenSize(){return this.getLatest().__size}isEmpty(){return 0===this.getChildrenSize()&&0===lc(this).length}isDirty(){const t=jr()._dirtyElements;return null!==t&&t.has(this.__key)}isLastChild(){const t=this.getLatest(),e=this.getParentOrThrow().getLastChild();return null!==e&&e.is(t)}getAllTextNodes(){const t=[];for(const e of lc(this)){const n=cc(this,e);as(n)&&t.push(...n.getAllTextNodes())}let e=this.getFirstChild();for(;null!==e;){if(wo(e)&&t.push(e),as(e)){const n=e.getAllTextNodes();t.push(...n)}e=e.getNextSibling()}return t}getFirstDescendant(){let t=this.getFirstChild();for(;as(t);){const e=t.getFirstChild();if(null===e)break;t=e}return t}getLastDescendant(){let t=this.getLastChild();for(;as(t);){const e=t.getLastChild();if(null===e)break;t=e}return t}getDescendantByIndex(t){const e=this.getChildren(),n=e.length;if(t>=n){const t=e[n-1];return as(t)&&t.getLastDescendant()||t||null}const o=e[t];return as(o)&&o.getFirstDescendant()||o||null}getFirstChild(){const t=this.getLatest().__first;return null===t?null:ui(t)}getFirstChildOrThrow(){const e=this.getFirstChild();return null===e&&t(45,this.__key),e}getLastChild(){const t=this.getLatest().__last;return null===t?null:ui(t)}getLastChildOrThrow(){const e=this.getLastChild();return null===e&&t(96,this.__key),e}getChildAtIndex(t){const e=this.getChildrenSize();let n,o;if(t=t;){if(o===t)return n;n=n.getPreviousSibling(),o--}return null}getTextContent(){let t=_c(this);const e=this.getChildren(),n=e.length;for(let o=0;ot.remove()),t}append(...t){return this.splice(this.getChildrenSize(),0,t)}setDirection(t){const e=this.getWritable();return e.__dir=t,e}setFormat(t){return this.getWritable().__format=""!==t&&w[t]||0,this}setStyle(t){return this.getWritable().__style=t||"",this}setTextFormat(t){const e=this.getWritable();return e.__textFormat=t,e}setTextStyle(t){const e=this.getWritable();return e.__textStyle=t,e}setIndent(t){return this.getWritable().__indent=t,this}splice(e,n,o){Zn(this)&&t(324,this.__key,this.__type);const r=this.getChildrenSize(),s=this.getWritable();e+n<=r||t(226,String(e),String(n),String(r));for(const t of o);const i=s.__key,l=[],c=[],a=this.getChildAtIndex(e+n);let u=null,f=r-n+o.length;if(0!==e)if(e===r)u=this.getLastChild();else{const t=this.getChildAtIndex(e);null!==t&&(u=t.getPreviousSibling())}if(n>0){let e=null===u?this.getFirstChild():u.getNextSibling();for(let o=0;o0&&(e.style.paddingInlineStart=40*t+"px",e.setAttribute("data-lexical-indent",String(t)));const n=this.getDirection();n&&(e.dir=n)}return{element:e}}exportJSON(){const t={children:[],direction:this.getDirection(),format:this.getFormatType(),indent:this.getIndent(),...super.exportJSON()},e=this.getTextFormat(),n=this.getTextStyle();return 0===e&&""===n||Xi(this)||this.getChildren().some(wo)||(0!==e&&(t.textFormat=e),""!==n&&(t.textStyle=n)),t}updateFromJSON(t){return super.updateFromJSON(t).setFormat(t.format).setIndent(t.indent).setDirection(t.direction).setTextFormat(t.textFormat||0).setTextStyle(t.textStyle||"")}insertNewAfter(t,e){return null}canIndent(){return!0}collapseAtStart(t){return!1}excludeFromCopy(t){return!1}canReplaceWith(t){return!0}canInsertAfter(t){return!0}canBeEmpty(){return!0}canInsertTextBefore(){return!0}canInsertTextAfter(){return!0}isInline(){return!1}isShadowRoot(){return!1}canMergeWith(t){return!1}extractWithChild(t,e,n){return!1}canMergeWhenEmpty(){return!1}reconcileObservedMutation(t,e){const n=Dl(this,t,e);let o=n.getFirstChild();for(let t=this.getFirstChild();t;t=t.getNextSibling()){const r=e.getElementByKey(t.getKey());null!==r&&(null==o?(n.insertChild(r),o=r):o!==r&&n.replaceChild(r,o),o=o.nextSibling)}}}function as(t){return t instanceof cs}function us(t,e,n){let o=t.getNode();for(;o;){const t=o.__key;if(e.has(t)&&!n.has(t))return!0;o=o.getParent()}return!1}class fs extends eo{__slotHost;__slots;constructor(t){super(t),this.__slotHost=null,this.__slots=null}afterCloneFrom(e){super.afterCloneFrom(e),this.__key===e.__key&&(this.__slotHost=e.__slotHost,null!==this.__slotHost&&null!==this.__parent&&t(383,this.__key,String(this.__slotHost),String(this.__parent)),this.__slots=e.__slots)}decorate(t,e){return null}isIsolated(){return!1}isInline(){return!0}isKeyboardSelectable(){return!0}}function ds(t){return t instanceof fs}class hs extends cs{__cachedText;$config(){return this.config("root",{extends:cs})}constructor(){super("root"),this.__cachedText=null}getTopLevelElementOrThrow(){t(51)}getTextContent(){const t=this.__cachedText;return null===t||!zr()&&0!==jr()._dirtyType?super.getTextContent():t}remove(){t(52)}replace(e){t(53)}insertBefore(e){t(54)}insertAfter(e){t(55)}updateDOM(t,e){return!1}splice(e,n,o){for(const e of o)as(e)||ds(e)||t(282);return super.splice(e,n,o)}static importJSON(t){return mi().updateFromJSON(t)}collapseAtStart(){return!0}}function gs(t){return t instanceof hs}function _s(t){return new ys(G(t._nodeMap),null,t._slotsUsed)}function ps(){return new ys(new Map([["root",new hs]]),null,!1)}function ms(e){const n=e.exportJSON(),o=e.constructor;if(n.type!==o.getType()&&t(130,o.name),as(e)){const r=n.children;Array.isArray(r)||t(59,o.name);const s=e.getChildren();for(let t=0;t0){const s={};for(const n of r){const r=cc(e,n);null===r&&t(366,o.name,n),s[n]=ms(r)}n.$slots=s}return n}class ys{_nodeMap;_selection;_flushSync;_readOnly;_parsed;_slotsUsed;constructor(t,e=null,n=!1){this._nodeMap=t,this._selection=e||null,this._flushSync=!1,this._readOnly=!1,this._parsed=!1,this._slotsUsed=n}isEmpty(){return 1===this._nodeMap.size&&null===this._selection}read(t,e){return Zr(e&&e.editor||null,this,t)}clone(t){const e=new ys(this._nodeMap,void 0===t?this._selection:t,this._slotsUsed);return e._readOnly=!0,e}toJSON(){return Zr(null,this,()=>({root:ms(mi())}))}}class xs extends cs{$config(){return this.config("artificial",{extends:cs})}createDOM(t){return fl().createElement("div")}}class Cs extends eo{$config(){return this.config("linebreak",{importDOM:{br:t=>vs(t)||Es(t)?null:{conversion:Ss,priority:0}}})}getTextContent(){return"\n"}createDOM(){return fl().createElement("br")}updateDOM(){return!1}isInline(){return!0}}function Ss(t){return{node:Ts()}}function Ts(){return Zi(new Cs)}function Ns(t){return t instanceof Cs}function vs(t){const e=t.parentElement;if(null!==e&&Ol(e)){const n=e.firstChild;if(n===t||n.nextSibling===t&&ks(n)){const n=e.lastChild;if(n===t||n.previousSibling===t&&ks(n))return!0}}return!1}function Es(t){const e=t.parentElement;if(null!==e&&Ol(e)){const n=e.firstChild;if(n===t||n.nextSibling===t&&ks(n))return!1;const o=e.lastChild;if(o===t||o.previousSibling===t&&ks(o))return!0}return!1}function ks(t){return ti(t)&&/^( |\t|\r?\n)+$/.test(t.textContent||"")}class Os extends cs{$config(){return this.config("paragraph",{extends:cs,importDOM:{p:()=>({conversion:bs,priority:0})}})}createDOM(t){const e=fl().createElement("p"),n=Pi(t.theme,"paragraph");if(void 0!==n){e.classList.add(...n)}return e}updateDOM(t,e,n){return!1}exportDOM(t){const{element:e}=super.exportDOM(t);if(Sl(e)){this.isEmpty()&&e.append(fl().createElement("br"));const t=this.getFormatType();t&&(e.style.textAlign=t)}return{element:e}}exportJSON(){const t=super.exportJSON();if(void 0===t.textFormat||void 0===t.textStyle){const e=this.getChildren().find(wo);e?(t.textFormat=e.getFormat(),t.textStyle=e.getStyle()):(t.textFormat=this.getTextFormat(),t.textStyle=this.getTextStyle())}return t}insertNewAfter(t,e){const n=Ms();n.setTextFormat(t.format),n.setTextStyle(t.style);const o=this.getDirection();return n.setDirection(o),n.setFormat(this.getFormatType()),n.setStyle(this.getStyle()),this.insertAfter(n,e),n}collapseAtStart(){const t=this.getChildren();if(0===t.length||wo(t[0])&&""===t[0].getTextContent().trim()){if(null!==this.getNextSibling())return this.selectNext(),this.remove(),!0;if(null!==this.getPreviousSibling())return this.selectPrevious(),this.remove(),!0}return!1}}function bs(t){const e=Ms();if($l(e,t),Kl(t,e),""===e.getFormatType()){const n=t.getAttribute("align");n&&n&&n in w&&e.setFormat(n)}return Bl(e,t),{node:e}}function Ms(){return Zi(new Os)}function As(t){return t instanceof Os}function Ds(t){console.warn(t)}const ws=0;function Is(t,e,n,o,r){const s=t._keyToDOMMap;s.clear(),t._editorState=ps(),t._pendingEditorState=o,t._compositionKey=null,t._dirtyType=0,t._cloneNotNeeded.clear(),t._dirtyLeaves=new Set,t._dirtyElements.clear(),t._normalizedNodes=new Set,r&&r.preserveUpdateQueue||(t._updateTags=new Set,t._updates=[],t._cascadeCount=0),t._blockCursorElement=null,null!==t._inputState.handledSelectionCommandTimeoutId&&clearTimeout(t._inputState.handledSelectionCommandTimeoutId),t._inputState={collapsedSelectionFormat:{format:0,key:"root",offset:0,style:"",timeStamp:0},compositionEndData:"",compositionPhase:"idle",hadOrphanedCompositionEvents:!1,handledSelectionCommandTimeoutId:null,isInsertLineBreak:!1,isInsertTextAfterHandledSelectionCommand:!1,isSelectionChangeFromDOMUpdate:!1,isSelectionChangeFromMouseDown:!1,lastBeforeInputInsertTextTimeStamp:0,lastKeyCode:null,lastKeyDownTimeStamp:0,postDeleteSelectionToRestore:null,unprocessedBeforeInputData:null};const i=t._observer;null!==i&&(i.disconnect(),t._observer=null),null!==e&&(e.textContent="",function(t,e){const n=`__lexicalKey_${e._key}`;delete t[n]}(e,t)),null!==n&&(n.textContent="",s.set("root",n),di(n,t,"root"))}function Ps(t){const e=new Set,n=new Set;for(const{klass:o,ownNodeConfig:r}of Vl(t)){const t=o.transform;if(!n.has(t)){n.add(t);const r=o.transform();r&&e.add(r)}if(r){const t=r.$transform;t&&e.add(t)}}return e}const Fs={$createDOM:(t,e)=>t.createDOM(e._config,e),$decorateDOM:(t,e,n,o)=>{},$exportDOM:(t,e)=>{const n=Hs(e,t.getType());return n&&void 0!==n.exportDOM?n.exportDOM(e,t):t.exportDOM(e)},$extractWithChild:(t,e,n,o,r)=>as(t)&&t.extractWithChild(e,n,o),$getDOMSlot:(t,e,n)=>t.getDOMSlot(e),$getSlotTargetElement:(t,e,n,o)=>null,$shouldExclude:(t,e,n)=>as(t)&&t.excludeFromCopy("html"),$shouldInclude:(t,e,n)=>!e||t.isSelected(e),$updateDOM:(t,e,n,o)=>t.updateDOM(e,n,o._config)};function Rs(t,e){const n=t.get(e);t.delete(e),n&&n()}function Ls(t,e,n){return t.set(e,n),Rs.bind(null,t,e)}class Ks{static version;_headless;_parentEditor;_rootElement;_editorState;_pendingEditorState;_compositionKey;_deferred;_keyToDOMMap;_updates;_updating;_cascadeCount;_listeners;_commands;_nodes;_decorators;_pendingDecorators;_config;_dirtyType;_cloneNotNeeded;_dirtyLeaves;_dirtyElements;_normalizedNodes;_updateTags;_observer;_key;_onError;_onWarn;_htmlConversions;_window;_editable;_blockCursorElement;_slotsUsed;_inputState;_createEditorArgs;constructor(t,e,n,o,r,s,i,l,c){this._createEditorArgs=c,this._parentEditor=e,this._rootElement=null,this._editorState=t,this._pendingEditorState=null,this._compositionKey=null,this._deferred=[],this._keyToDOMMap=new J,this._updates=[],this._updating=!1,this._cascadeCount=0,this._listeners={decorator:new Map,editable:new Map,mutation:new Map,root:new Map,textcontent:new Map,update:new Map},this._commands=new Map,this._config=o,this._nodes=n,this._decorators={},this._pendingDecorators=null,this._dirtyType=0,this._cloneNotNeeded=new Set,this._dirtyLeaves=new Set,this._dirtyElements=new Map,this._normalizedNodes=new Set,this._updateTags=new Set,this._observer=null,this._key=Ni(),this._onError=r,this._onWarn=s,this._htmlConversions=i,this._editable=l,this._headless=null!==e&&e._headless,this._window=null,this._blockCursorElement=null,this._slotsUsed=!1,this._inputState={collapsedSelectionFormat:{format:0,key:"root",offset:0,style:"",timeStamp:0},compositionEndData:"",compositionPhase:"idle",hadOrphanedCompositionEvents:!1,handledSelectionCommandTimeoutId:null,isInsertLineBreak:!1,isInsertTextAfterHandledSelectionCommand:!1,isSelectionChangeFromDOMUpdate:!1,isSelectionChangeFromMouseDown:!1,lastBeforeInputInsertTextTimeStamp:0,lastKeyCode:null,lastKeyDownTimeStamp:0,postDeleteSelectionToRestore:null,unprocessedBeforeInputData:null}}isComposing(){return null!=this._compositionKey}registerUpdateListener(t){return Ls(this._listeners.update,t)}registerEditableListener(t){return Ls(this._listeners.editable,t)}registerDecoratorListener(t){return Ls(this._listeners.decorator,t)}registerTextContentListener(t){return Ls(this._listeners.textcontent,t)}registerRootListener(t){const e=this._listeners.root;return xa(Ls(e,t,t(this._rootElement,null)||void 0),()=>function(t,e,n){const o=t.get(e);o&&o(),t.set(e,e(...n)||void 0)}(e,t,[null,this._rootElement]))}registerCommand(e,n,o){void 0===o&&t(35);const r=this._commands;r.has(e)||r.set(e,[new j,new j,new j,new j,new j]);const s=r.get(e);void 0===s&&t(36,String(e));const i=function(t){return 7&t}(o),l=s[i];return i!==o?l.addFront(n):l.addBack(n),()=>{l.delete(n),s.every(t=>0===t.size)&&r.delete(e)}}registerMutationListener(t,e,n){const o=this.resolveRegisteredNodeAfterReplacements(this.getRegisteredNode(t)).klass,r=this._listeners.mutation;let s=r.get(e);void 0===s&&(s=new Set,r.set(e,s)),s.add(o);const i=n&&n.skipInitialization;return void 0!==i&&i||this.initializeMutationListener(e,o),()=>{s.delete(o),0===s.size&&r.delete(e)}}getRegisteredNode(e){const n=this._nodes.get(e.getType());return void 0===n&&t(37,e.name),n}resolveRegisteredNodeAfterReplacements(t){for(;t.replaceWithKlass;)t=this.getRegisteredNode(t.replaceWithKlass);return t}initializeMutationListener(t,e){const n=this._editorState,o=Rl(n).get(e.getType());if(!o)return;const r=new Map;for(const t of o.keys())r.set(t,"created");r.size>0&&t(r,{dirtyLeaves:new Set,prevEditorState:n,updateTags:new Set(["registerMutationListener"])})}registerNodeTransformToKlass(t,e){const n=this.getRegisteredNode(t);return n.transforms.add(e),n}registerNodeTransform(t,e){const n=this.registerNodeTransformToKlass(t,e),o=[n],r=n.replaceWithKlass;if(null!=r){const t=this.registerNodeTransformToKlass(r,e);o.push(t)}return function(t,e){const n=Rl(t.getEditorState()),o=[];for(const t of e){const e=n.get(t);e&&o.push(e)}if(0===o.length)return;t.update(()=>{for(const t of o)for(const e of t.keys()){const t=ui(e);t&&t.markDirty()}},null===t._pendingEditorState?{tag:oo}:void 0)}(this,o.map(t=>t.klass.getType())),()=>{o.forEach(t=>t.transforms.delete(e))}}hasNode(t){return this._nodes.has(t.getType())}hasNodes(t){return t.every(this.hasNode.bind(this))}dispatchCommand(t,...e){return Bi(this,t,...e)}getDecorators(){return this._decorators}getRootElement(){return this._rootElement}getKey(){return this._key}setRootElement(t){const e=this._rootElement;if(t!==e){const n=Pi(this._config.theme,"root"),o=this._pendingEditorState||this._editorState;if(this._rootElement=t,Is(this,e,t,o,{preserveUpdateQueue:!0}),null!==e&&(this._config.disableEvents||qn(e),null!=n&&e.classList.remove(...n)),null!==t){const e=Yi(t),o=t.style;o.userSelect="text",o.whiteSpace="pre-wrap",o.wordBreak="break-word",t.setAttribute("data-lexical-editor","true"),this._window=e,this._dirtyType=2,st(this),this._updateTags.add(oo),ts(this),this._config.disableEvents||function(t,e){const n=t.ownerDocument;vn.set(t,n);let o=En.get(n);void 0===o&&(o={editors:new Set,hasShadowEditor:void 0},En.set(n,o)),o.editors.add(e),o.hasShadowEditor=void 0,t.__lexicalEditor=e;const r=Hn(t);r.push(kn.register(n));for(let n=0;n{Jn(t)||(Gn(t),(e.isEditable()||"click"===o)&&s(t,e))}:t=>{if(Jn(t))return;Gn(t);const n=e.isEditable();switch(o){case"cut":return n&&Bi(e,fn,t);case"copy":return Bi(e,un,t);case"paste":return n&&Bi(e,Pe,t);case"dragstart":return n&&Bi(e,ln,t);case"dragover":return n&&Bi(e,cn,t);case"dragend":return n&&Bi(e,an,t);case"focus":return n&&Bi(e,mn,t);case"blur":return n&&Bi(e,yn,t);case"drop":return n&&Bi(e,rn,t)}};r.push(Sn(t,o,i))}}(t,this),null!=n&&t.classList.add(...n)}else this._window=null,this._updateTags.add(oo),ts(this);es("root",this,!1,t,e)}}getElementByKey(t){return this._keyToDOMMap.get(t)||null}getEditorState(){return this._editorState}setEditorState(e,n){e.isEmpty()&&t(38);let o=e;o._readOnly&&(o=_s(e),o._selection=e._selection?e._selection.clone():null),rt(this);const r=this._pendingEditorState,s=void 0!==n?n.tag:null;null===r||r.isEmpty()||(null!=s&&this._updateTags.add(s),ts(this)),this._pendingEditorState=o,this._dirtyType=2,this._dirtyElements.set("root",!1),this._compositionKey=null,this._slotsUsed=this._slotsUsed||e._slotsUsed,is(this,()=>{if(s&&this._updateTags.add(s),e._parsed)for(const[t,e]of o._nodeMap.entries())as(e)?this._dirtyElements.set(t,!0):this._dirtyLeaves.add(t)},{discrete:!this._updating||void 0})}parseEditorState(t,e){return function(t,e,n){const o=ps(),r=Ir,s=Fr,i=Pr,l=e._dirtyElements,c=e._dirtyLeaves,a=e._cloneNotNeeded,u=e._dirtyType;e._dirtyElements=new Map,e._dirtyLeaves=new Set,e._cloneNotNeeded=new Set,e._dirtyType=0,Ir=o,Fr=!1,Pr=e,$s(null);try{const r=e._nodes;Qr(t.root,r),n&&n(),o._readOnly=!0,o._parsed=!0}catch(t){t instanceof Error&&e._onError(t)}finally{e._dirtyElements=l,e._dirtyLeaves=c,e._cloneNotNeeded=a,e._dirtyType=u,Ir=r,Fr=s,Pr=i}return o}("string"==typeof t?JSON.parse(t):t,this,e)}read(...t){const[e,n]=1===t.length?["force-commit",t[0]]:t;"force-commit"===e&&ts(this);return("pending"===e?this._pendingEditorState||this._editorState:this.getEditorState()).read(n,{editor:this})}update(t,e){!function(t,e,n){t._updating?t._updates.push([e,n]):ss(t,e,n)}(this,t,e)}focus(t,e={}){const n=this._rootElement;null!==n&&(n.setAttribute("autocapitalize","off"),is(this,()=>{const o=pr(),r=mi();null!==o?o.dirty||yi(o.clone()):0!==r.getChildrenSize()&&("rootStart"===e.defaultSelection?r.selectStart():r.selectEnd()),Ui("focus"),Hi(()=>{n.removeAttribute("autocapitalize"),t&&t()})}),null===this._pendingEditorState&&n.removeAttribute("autocapitalize"))}blur(){const t=this._rootElement;null!==t&&t.blur();const e=rl(this._window);null!==e&&e.removeAllRanges()}isEditable(){return this._editable}setEditable(t){this._editable!==t&&(this._editable=t,es("editable",this,!0,t),this._slotsUsed&&this.update(()=>Yr()))}toJSON(){return{editorState:this._editorState.toJSON()}}}Ks.version=H;let Bs=null;function $s(t){Bs=t}const zs=Symbol("INTERNAL_SKIP_AFTER_CLONE_FROM");let Ws=1;function Us(e,n){const o=Hs(e,n);return void 0===o&&t(30,n),o}function Hs(t,e){return t._nodes.get(e)}const js="function"==typeof queueMicrotask?queueMicrotask:t=>{Promise.resolve().then(t)};function Ys(t,e){const n=void 0!==e?e:(()=>{const e=t.getRootNode();return ei(e)||il(e)?xl(e):null})();if(!Sl(n))return!1;if(n.hasAttribute("data-lexical-slot"))return!1;const o=gi(n),r=n.nodeName;return no(o)&&("INPUT"===r||"TEXTAREA"===r||"true"===n.contentEditable&&null==Xs(n))}const Gs=Ys;function Js(t,e,n){const o=t.getRootElement();if(!o)return!1;try{if(!e||!o.contains(e)||!o.contains(n))return!1}catch(t){return!1}return qs(e)===t&&t.read("latest",()=>!Ys(e))}function Vs(t){return t instanceof Ks}function qs(t){let e=t;for(;null!=e;){const t=Xs(e);if(Vs(t))return t;e=zi(e)}return null}function Xs(t){return t?t.__lexicalEditor:null}function Qs(t){return Ro(t)||t.isToken()}function Zs(t){return Qs(t)||t.isSegmented()}function ti(t){return Tl(t)&&3===t.nodeType}function ei(t){return Tl(t)&&9===t.nodeType}function ni(t){let e=t;for(;null!=e;){if(ti(e))return e;e=e.firstChild}return null}function oi(t,e,n){const o=A[e];if(null!==n&&(t&o)===(n&o))return t;let r=t^o;return"subscript"===e?r&=~A.superscript:"superscript"===e?r&=~A.subscript:"lowercase"===e?(r&=~A.uppercase,r&=~A.capitalize):"uppercase"===e?(r&=~A.lowercase,r&=~A.capitalize):"capitalize"===e&&(r&=~A.lowercase,r&=~A.uppercase),r}function ri(t,e){const n=function(){const t=Bs;return Bs=null,t}();if(null!=(e=e||n&&n.__key))return void(t.__key=e);Wr(),Ur();const o=jr(),r=Hr(),s=""+Ws++;r._nodeMap.set(s,t),as(t)?o._dirtyElements.set(s,!0):o._dirtyLeaves.add(s),o._cloneNotNeeded.add(s),0===o._dirtyType&&(o._dirtyType=1),t.__key=s}function si(e){null!==nc(e)&&t(380,e.__key,String(nc(e)));const n=e.getParent();if(null!==n){const t=e.getWritable(),o=n.getWritable(),r=e.getPreviousSibling(),s=e.getNextSibling(),i=null!==s?s.__key:null,l=null!==r?r.__key:null,c=null!==r?r.getWritable():null,a=null!==s?s.getWritable():null;null===r&&(o.__first=i),null===s&&(o.__last=l),null!==c&&(c.__next=i),null!==a&&(a.__prev=l),t.__prev=null,t.__next=null,t.__parent=null,o.__size--}}const ii=si;function li(e){Ur(),Zn(e)&&t(323,e.__key,e.__type);const n=e.getLatest(),o=null!==n.__parent?n.__parent:ec(n)?n.__slotHost:null,r=Hr(),s=jr(),i=r._nodeMap,l=s._dirtyElements;null!==o&&function(t,e,n){let o=t;for(;null!==o;){if(n.has(o))return;const t=e.get(o);if(void 0===t)break;n.set(o,!1),o=null!==t.__parent?t.__parent:ec(t)?t.__slotHost:null}}(o,i,l);const c=n.__key;0===s._dirtyType&&(s._dirtyType=1),as(e)?l.set(c,!0):s._dirtyLeaves.add(c)}function ci(t){Wr();const e=jr(),n=e._compositionKey;if(t!==n){if(e._compositionKey=t,null!==n){const t=ui(n);null!==t&&t.getWritable()}if(null!==t){const e=ui(t);null!==e&&e.getWritable()}}}function ai(){if(zr())return null;return jr()._compositionKey}function ui(t,e){const n=(e||Hr())._nodeMap.get(t);return void 0===n?null:n}function fi(t,e){const n=hi(t,jr());return void 0!==n?ui(n,e):null}function di(t,e,n){t[`__lexicalKey_${e._key}`]=n}function hi(t,e){return t[`__lexicalKey_${e._key}`]}function gi(t,e){let n=t;for(;null!=n;){const t=fi(n,e);if(null!==t)return t;n=zi(n)}return null}function _i(t){const e=t._decorators,n=Object.assign({},e);return t._pendingDecorators=n,n}function pi(t){return t.read(()=>mi().getTextContent())}function mi(){return Hr()._nodeMap.get("root")}function yi(t){Wr();const e=Hr();null!==t&&(t.dirty=!0,t.setCachedNodes(null),jo(t)&&jr()._slotsUsed&&ar(t)),e._selection=t}function xi(){Wr();rt(jr())}function Ci(t){const e=function(t,e){let n=t;for(;null!=n;){const t=hi(n,e);if(void 0!==t)return t;n=zi(n)}return null}(t,jr());return null===e?null:ui(e)}function Si(t){return/[\uD800-\uDBFF][\uDC00-\uDFFF]/g.test(t)}function Ti(t){const e=[];for(let n=t;null!==n;n=n._parentEditor)e.push(n);return e}function Ni(){return Math.random().toString(36).replace(/[^a-z]+/g,"").substring(0,5)}function vi(t){return ti(t)?t.nodeValue:null}function Ei(t,e,n){const o=rl(Gi(e));if(null===o)return;const r=gl(o,e._rootElement),s=r.anchorNode;let{anchorOffset:i,focusOffset:l}=r;if(null!==s){let e=vi(s);const o=gi(s);if(null!==e&&wo(o)){if((e===N||e===E)&&n){const t=n.length;e=n,i=t,l=t}null!==e&&ki(o,e,i,l,t)}}}function ki(t,e,n,o,r){let s=t;if(s.isAttached()&&(r||!s.isDirty())){const i=s.isComposing();if(s.isToken()&&i)return;let c=e;if((i||r)&&(e.endsWith(N)&&(c=e.slice(0,-N.length)),r)){const t=E;let e;for(;-1!==(e=c.indexOf(t));)c=c.slice(0,e)+c.slice(e+t.length),null!==n&&n>e&&(n=Math.max(e,n-t.length)),null!==o&&o>e&&(o=Math.max(e,o-t.length))}const u=s.getTextContent();if(r||c!==u){const e=pr();if(""===c){if(ci(null),a||l||d)s.remove();else{const t=jr();Oi(s,"",e),setTimeout(()=>{t.update(()=>{s.isAttached()&&""===s.getTextContent()&&s.remove()})},20)}return}const r=s.getParent(),u=mr(),f=s.getTextContentSize(),h=ai(),g=s.getKey();if(s.isToken()&&!i||null!==h&&g===h&&!i||jo(u)&&(null!==r&&!r.canInsertTextBefore()&&0===u.anchor.offset||u.anchor.key===t.__key&&0===u.anchor.offset&&!s.canInsertTextBefore()&&!i||u.focus.key===t.__key&&u.focus.offset===f&&!s.canInsertTextAfter()&&!i))return void s.markDirty();if(!jo(e)||null===n||null===o)return void Oi(s,c,e);if(e.setTextNodeRange(s,n,s,o),s.isSegmented()){const t=Do(s.getTextContent());s.replace(t),s=t}Oi(s,c,e)}}}function Oi(t,e,n){if(t.setTextContent(e),jo(n)){const e=t.getKey();let o=!1;for(const r of["anchor","focus"]){const s=n[r];"text"===s.type&&s.key===e&&(s.offset=Kc(t,s.offset,"clamp"),o=!0)}o&&(n._cachedNodes=null,n._cachedIsBackward=null)}}function bi(t,e,n){const o=e[n]||!1;return"any"===o||o===t[n]}function Mi(t,e){return bi(t,e,"altKey")&&bi(t,e,"ctrlKey")&&bi(t,e,"shiftKey")&&bi(t,e,"metaKey")}function Ai(t,e,n){if(!Mi(t,n))return!1;if(t.key.toLowerCase()===e.toLowerCase())return!0;if(e.length>1)return!1;if(1===t.key.length&&t.key.charCodeAt(0)<=127)return!1;if(t.code.startsWith("Digit")&&/^\d$/.test(e))return t.code===`Digit${e}`;const o="Key"+e.toUpperCase();return t.code===o}const Di={ctrlKey:!r,metaKey:r},wi={altKey:r,ctrlKey:!r};function Ii(t){return"Backspace"===t.key}function Pi(t,e){void 0===t.__lexicalClassNameCache&&(t.__lexicalClassNameCache={});const n=t.__lexicalClassNameCache,o=n[e];if(void 0!==o)return o;const r=t[e];if("string"==typeof r){const t=ya(r);return n[e]=t,t}return r}function Fi(e,n,o,r,s){if(0===o.size)return;const i=r.__type,l=r.__key,c=n.get(i);void 0===c&&t(33,i);const a=c.klass;let u=e.get(a);void 0===u&&(u=new Map,e.set(a,u));const f=u.get(l),d="destroyed"===f&&"created"===s;(void 0===f||d)&&u.set(l,d?"updated":s)}function Ri(t,e,n){const o=t.getParent();let r=n,s=t;return null!==o&&(e&&0===n?(r=s.getIndexWithinParent(),s=o):e||n!==s.getChildrenSize()||(r=s.getIndexWithinParent()+1,s=o)),s.getChildAtIndex(e?r-1:r)}function Li(t,e){const n=t.offset;if("element"===t.type){return Ri(t.getNode(),e,n)}{const o=t.getNode();if(e&&0===n||!e&&n===o.getTextContentSize()){const t=e?o.getPreviousSibling():o.getNextSibling();return null===t?Ri(o.getParentOrThrow(),e,o.getIndexWithinParent()+(e?0:1)):t}}return null}function Ki(t){const e=Gi(t).event,n=e&&e.inputType;return"insertFromPaste"===n||"insertFromPasteAsQuotation"===n}function Bi(t,e,...n){return ns(t,e,n[0],t)}function $i(e,n){const o=e._keyToDOMMap.get(n);return void 0===o&&t(75,n),o}function zi(t){const e=t.assignedSlot||t.parentElement;if(null!==e)return e;const n=t.parentNode;return il(n)?n.host:null}function Wi(t){return ei(t)?t:Sl(t)?t.ownerDocument:null}function Ui(t){Wr();jr()._updateTags.add(t)}function Hi(t){Wr();jr()._deferred.push(t)}function ji(t,e){let n=t.getParent();for(;null!==n;){if(n.is(e))return!0;n=n.getParent()}return!1}function Yi(t){const e=Wi(t);return e?e.defaultView:null}function Gi(e){const n=e._window;return null===n&&t(78),n}function Ji(t){return as(t)&&t.isInline()||ds(t)&&t.isInline()}function Vi(t){let e=t.getLatest();for(;null!==e;){if(null!==nc(e)&&as(e))return e;const t=e.getParentOrThrow();if(Xi(t))return t;e=t}return e}function qi(t){return as(t)&&t.isShadowRoot()}function Xi(t){return gs(t)||qi(t)}function Qi(t,e=!1){const n=t.constructor.clone(t,zs);return ri(n,null),n.afterCloneFrom(t),e||n.resetOnCopyNodeFrom(t),n}function Zi(e){const n=jr(),o=e.getType(),r=Hs(n,o);void 0===r&&t(200,e.constructor.name,o);const{replace:s,replaceWithKlass:i}=r;if(null!==s){const n=s(e),r=n.constructor;return null!==i?n instanceof i||t(201,i.name,i.getType(),r.name,r.getType(),e.constructor.name,o):n instanceof e.constructor&&r!==e.constructor||t(202,r.name,r.getType(),e.constructor.name,o),n.__key===e.__key&&t(203,e.constructor.name,o,r.name,r.getType()),n}return e}function tl(e,n){!gs(e.getParent())||as(n)||ds(n)||t(99)}function el(e){const n=ui(e);return null===n&&t(63,e),n}function nl(t){if(!t||t.isInline())return!1;if(ds(t))return!0;if(as(t)){if(t.isShadowRoot()){const e=t.getParent();return!(as(e)&&e.isShadowRoot())}return!t.canBeEmpty()}return!1}function ol(t,e,n){n.style.removeProperty("caret-color"),e._blockCursorElement=null;const o=t.parentElement;null!==o&&o.removeChild(t)}function rl(t){return n?(t||window).getSelection():null}function sl(t){const e=Yi(t);return e?e.getSelection():null}function il(t){return Nl(t)&&"host"in t}const ll=[];function cl(t){const e=t.getRootNode();if(e===t||!il(e))return ll;const n=[e];let o=e.host;for(;;){const t=o.getRootNode();if(t===o||!il(t))break;n.push(t),o=t.host}return n}function*al(t){const e=[t];let n;for(;n=e.pop();){yield*n.querySelectorAll('[data-lexical-editor="true"]');const t=(ei(n)?n:n.ownerDocument).createTreeWalker(n,NodeFilter.SHOW_ELEMENT);let o;for(;o=t.nextNode();)o.shadowRoot&&e.push(o.shadowRoot)}}function ul(t){return null!==t?t.ownerDocument:document}function fl(){const t=Jr();return ul(null!==t?t._rootElement:null)}function dl(t,e){if(null===e||"function"!=typeof t.getComposedRanges)return null;const n=cl(e);if(0===n.length)return null;const o=t.getComposedRanges;try{const e=o.call(t,{shadowRoots:n})[0];if(void 0!==e)return e}catch(t){}try{const e=o.apply(t,n)[0];if(void 0!==e)return e}catch(t){}return null}function hl(t,e){const n=dl(t,e);if(null!==n){const t=_l(n);if(null!==t)return t}return t.rangeCount>0?t.getRangeAt(0):null}function gl(t,e){const n=dl(t,e);return null===n?t:pl(n,ml(t))}function _l(t){const e=t.startContainer.ownerDocument;if(null===e)return null;const n=e.createRange();try{return n.setStart(t.startContainer,t.startOffset),n.setEnd(t.endContainer,t.endOffset),n}catch(t){return null}}function pl(t,e){const{startContainer:n,startOffset:o,endContainer:r,endOffset:s}=t;return"backward"===e?{anchorNode:r,anchorOffset:s,direction:e,focusNode:n,focusOffset:o}:{anchorNode:n,anchorOffset:o,direction:e,focusNode:r,focusOffset:s}}function ml(t){return t.direction}function yl(t){const e=t.getRootNode();return ei(e)||il(e)?e.activeElement:null}function xl(t){let e=t.activeElement;for(;null!==e&&null!==e.shadowRoot;){const t=e.shadowRoot.activeElement;if(null===t)break;e=t}return e}function Cl(t){const e=t.target;if(null!==e&&Sl(e)&&null!==e.shadowRoot&&"function"==typeof t.composedPath){const e=t.composedPath();if(e.length>0)return e[0]}return e}function Sl(t){return Tl(t)&&1===t.nodeType}function Tl(t){return"object"==typeof t&&null!==t&&"nodeType"in t&&"number"==typeof t.nodeType}function Nl(t){return Tl(t)&&11===t.nodeType}const vl=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|mark|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var|#text)$/i;function El(t){return!(!Sl(t)||!t.style.display.startsWith("inline"))||vl.test(t.nodeName)}const kl=/^(address|article|aside|blockquote|canvas|dd|div|dl|dt|fieldset|figcaption|figure|footer|form|h1|h2|h3|h4|h5|h6|header|hr|li|main|nav|noscript|ol|p|pre|section|table|td|tfoot|ul|video)$/i;function Ol(t){return(!Sl(t)||!t.style.display.startsWith("inline"))&&kl.test(t.nodeName)}function bl(t){if(ds(t)&&!t.isInline())return!0;if(!as(t)||Xi(t))return!1;const e=t.getFirstChild(),n=null===e||Ns(e)||wo(e)||e.isInline();return!t.isInline()&&!1!==t.canBeEmpty()&&n}function Ml(){return jr()}function Al(t=Ml()){return t._config.dom||Fs}function Dl(e,n,o=Ml()){const r=Al(o).$getDOMSlot(e,n,o);return as(e)&&(wl(r)||t(344,e.getKey(),e.getType())),r}function wl(t){return t instanceof z}function Il(t,e,n=Ml()){return ni(Dl(t,e,n).element)}const Pl=new WeakMap,Fl=new Map;function Rl(e){if(!e._readOnly&&e.isEmpty())return Fl;e._readOnly||t(192);let n=Pl.get(e);return n||(n=function(t){const e=new Map;for(const[n,o]of t._nodeMap){const t=o.__type;let r=e.get(t);r||(r=new Map,e.set(t,r)),r.set(n,o)}return e}(e),Pl.set(e,n)),n}function Ll(t){const e=t.constructor.clone(t,zs);return e.afterCloneFrom(t),e}function Kl(t,e){const n=t.getAttribute("data-lexical-indent");if(null!==n){const t=parseInt(n,10);if(Number.isFinite(t)&&t>=0)return void e.setIndent(t)}const o=parseInt(t.style.paddingInlineStart,10)||0,r=Math.round(o/40);e.setIndent(r)}function Bl(t,e){const n=e.getAttribute("dir");return"ltr"===n||"rtl"===n?t.setDirection(n):t}function $l(t,e){const n=e.style.textAlign;return n&&n in w?t.setFormat(n):t}function zl(t,e){t.__lexicalUnmanaged=!0,e&&void 0!==e.captureSelection&&(t.__lexicalCapturedSelection=e.captureSelection)}function Wl(t){return!0===t.__lexicalUnmanaged}function Ul(t,e=Ml()){const n=e.isEditable();t.contentEditable=n?"true":"false",n?t.__lexicalEditor=e:delete t.__lexicalEditor}function Hl(t,e){let n=t;for(;null!=n;){if(!0===n.__lexicalCapturedSelection)return!0;if(Sl(n)&&n.hasAttribute("data-lexical-slot"))return!1;if(void 0!==hi(n,e))return!1;n=zi(n)}return!1}function jl(t,e){return function(t,e){return Object.prototype.hasOwnProperty.call(t,e)}(t,e)&&t[e]!==eo[e]}const Yl=new WeakMap,Gl=Symbol("lexical.synthesizedGetType");function Jl(e){const n=Yl.get(e);if(n)return n;const o=null!=e.prototype&&R in e.prototype?e.prototype[R]():void 0,r=function(e){if(!(e===eo||e.prototype instanceof eo)){let n="",o="";try{n=e.getType()}catch(t){}try{Ks.version&&(o=JSON.parse(Ks.version))}catch(t){}t(290,e.name,n,o)}return e===fs||e===cs||e===eo}(e),s=!r&&jl(e,"getType")?e.getType:void 0,i=s&&!(Gl in s)?s.call(e):void 0;let l,c=i;if(o)if(i)l=o[i];else{for(const[t,e]of Object.entries(o))c=t,l=e;if(!l)for(const t of Object.getOwnPropertySymbols(o)){const e=o[t];if(e){l=e;break}}}if(!r&&c){if(!jl(e,"getType")){const t=e,n=function(){return this!==t?eo.getType.call(this):c};n[Gl]=!0,e.getType=n}if(jl(e,"clone")||(e.clone=(t,n)=>{$s(t);const o=new e;return n!==zs&&o.afterCloneFrom(t),o}),jl(e,"importJSON")||(e.importJSON=l&&l.$importJSON||(t=>(new e).updateFromJSON(t))),!jl(e,"importDOM")&&l){const{importDOM:t}=l;t&&(e.importDOM=()=>t)}}const a={klass:e,ownNodeConfig:l,ownNodeType:c};return Yl.set(e,a),a}function*Vl(t){for(let e=t;e&&(e===eo||no(e.prototype));){const t=Jl(e);yield t,e=t.ownNodeConfig&&t.ownNodeConfig.extends||Ql(e)}}const ql=(t,e)=>{let n=t;for(;null!=n&&!gs(n);){if(e(n))return n;n=n.getParent()}return null};function Xl(e,n){const o=[];let r=e.__first;for(;null!==r;){const e=null===n?ui(r):n.get(r);null==e&&t(174),o.push(r),r=e.__next}return o}function Ql(t){const e=Object.getPrototypeOf(t);if("function"==typeof e&&e!==Function.prototype)return e;const n=t.prototype&&Object.getPrototypeOf(t.prototype);return n?n.constructor:null}const Zl=new Map;function tc(t){return as(t)||ds(t)}function ec(t){return as(t)||ds(t)}function nc(t){const e=t.getLatest();return ec(e)?e.__slotHost:null}function oc(e){const n=nc(e);if(null===n)return null;const o=ui(n);return as(o)||ds(o)||t(370),o}function rc(t){const e=oc(t);if(null===e)return null;const n=t.getLatest().__key;for(const[t,o]of ic(e))if(o===n)return t;return null}function sc(t){let e=t.getLatest();for(;null!==e;){if(null!==nc(e))return e;e=e.getParent()}return null}function ic(t){const e=t.getLatest();return tc(e)&&null!==e.__slots?e.__slots:Zl}function lc(t){return Array.from(ic(t).keys())}function cc(t,e){const n=ic(t).get(e);return void 0===n?null:ui(n)}const ac=["__proto__","constructor","prototype"],uc=Symbol("slotMapOwner");function fc(t){let e=t.__slots;return null!==e&&e[uc]===t||(e=new Map(e),e[uc]=t,t.__slots=e),e}const dc=new WeakMap,hc=[];function gc(t){for(const{ownNodeConfig:e}of Vl(t)){const t=e&&e.slots;if(t)return t}return hc}function _c(t){let e="";for(const n of lc(t)){const o=cc(t,n);null!==o&&(e+=o.getTextContent())}return e}function pc(t,e,n){const o=n.get(t),r=n.get(e);return void 0!==o?void 0!==r?o-r:-1:void 0!==r?1:te?1:0}function mc(e){const n=e.__slots;if(null===n||n.size<2)return;const o=function(e){let n=dc.get(e);if(void 0===n){const o=gc(e),r=new Map;for(const n of o)ac.includes(n)&&t(371,e.name,n),r.has(n)&&t(372,e.name,n),r.set(n,r.size);n=r,dc.set(e,n)}return n}(e.constructor);let r=null,s=!0;for(const t of n.keys()){if(null!==r&&pc(r,t,o)>0){s=!1;break}r=t}if(s)return;const i=Array.from(n).sort(([t],[e])=>pc(t,e,o));n.clear();for(const[t,e]of i)n.set(t,e)}function yc(e,n,o){"__proto__"!==n&&"constructor"!==n&&"prototype"!==n||t(373,n);const r=e.getLatest();if(null!==r.__slots&&r.__slots.get(n)===o.getLatest().__key)return r;(!as(o)&&!ds(o)||o.isInline())&&t(374,o.__key);const s=e.getWritable(),i=fc(s),l=i.get(n);void 0!==l&&Sc(l);const c=o.getWritable(),a=oc(c);if(null!==a){const t=rc(c);null!==t&&fc(a.getWritable()).delete(t),c.__slotHost=null}return si(c),c.__slotHost=s.__key,i.set(n,c.__key),mc(s),function(){const t=Ml();t._slotsUsed=!0,t._pendingEditorState&&(t._pendingEditorState._slotsUsed=!0)}(),s}function xc(t,e){const n=t.getWritable();if(null===n.__slots)return n;const o=n.__slots.get(e);return void 0!==o&&(Sc(o),fc(n).delete(e)),n}function Cc(t,e){}function Sc(e){const n=ui(e);if(null===n)return;const o=n.getWritable();ec(o)||t(377,e),o.__slotHost=null,o.remove()}const Tc={next:"previous",previous:"next"};class Nc{origin;constructor(t){this.origin=t}[Symbol.iterator](){return Jc({hasNext:Dc,initial:this.getAdjacentCaret(),map:t=>t,step:t=>t.getAdjacentCaret()})}getAdjacentCaret(){return Rc(this.getNodeAtCaret(),this.direction)}getSiblingCaret(){return Rc(this.origin,this.direction)}remove(){const t=this.getNodeAtCaret();return t&&t.remove(),this}replaceOrInsert(t,e){const n=this.getNodeAtCaret();return t.is(this.origin)||t.is(n)||(null===n?this.insert(t):n.replace(t,e)),this}splice(e,n,o="next"){const r=o===this.direction?n:Array.from(n).reverse();let s=this;const i=this.getParentAtCaret(),l=new Map;for(let t=s.getAdjacentCaret();null!==t&&l.size0){const n=s.getNodeAtCaret();if(n)if(l.delete(n.getKey()),l.delete(e.getKey()),n.is(e)||s.origin.is(e));else{const t=e.getParent();t&&t.is(i)&&e.remove(),n.replace(e)}else null===n&&t(263,Array.from(l).join(" "))}else s.insert(e);s=Rc(e,this.direction)}for(const t of l.values())t.remove();return this}}class vc extends Nc{type="child";getLatest(){const t=this.origin.getLatest();return t===this.origin?this:$c(t,this.direction)}getParentCaret(t="root"){return Rc(Oc(this.getParentAtCaret(),t),this.direction)}getFlipped(){const t=kc(this.direction);return Rc(this.getNodeAtCaret(),t)||$c(this.origin,t)}getParentAtCaret(){return this.origin}getChildCaret(){return this}isSameNodeCaret(t){return t instanceof vc&&this.direction===t.direction&&this.origin.is(t.origin)}isSamePointCaret(t){return this.isSameNodeCaret(t)}}const Ec={root:gs,shadowRoot:Xi};function kc(t){return Tc[t]}function Oc(t,e="root"){return null===t||Ec[e](t)?null:null===nc(t)?t:null}class bc extends Nc{type="sibling";getLatest(){const t=this.origin.getLatest();return t===this.origin?this:Rc(t,this.direction)}getSiblingCaret(){return this}getParentAtCaret(){return this.origin.getParent()}getChildCaret(){return as(this.origin)?$c(this.origin,this.direction):null}getParentCaret(t="root"){return Rc(Oc(this.getParentAtCaret(),t),this.direction)}getFlipped(){const t=kc(this.direction);return Rc(this.getNodeAtCaret(),t)||$c(this.origin.getParentOrThrow(),t)}isSamePointCaret(t){return t instanceof bc&&this.direction===t.direction&&this.origin.is(t.origin)}isSameNodeCaret(t){return(t instanceof bc||t instanceof Mc)&&this.direction===t.direction&&this.origin.is(t.origin)}}class Mc extends Nc{type="text";offset;constructor(t,e){super(t),this.offset=e}getLatest(){const t=this.origin.getLatest();return t===this.origin?this:Lc(t,this.direction,this.offset)}getParentAtCaret(){return this.origin.getParent()}getChildCaret(){return null}getParentCaret(t="root"){return Rc(Oc(this.getParentAtCaret(),t),this.direction)}getFlipped(){return Lc(this.origin,kc(this.direction),this.offset)}isSamePointCaret(t){return t instanceof Mc&&this.direction===t.direction&&this.origin.is(t.origin)&&this.offset===t.offset}isSameNodeCaret(t){return(t instanceof bc||t instanceof Mc)&&this.direction===t.direction&&this.origin.is(t.origin)}getSiblingCaret(){return Rc(this.origin,this.direction)}}function Ac(t){return t instanceof Mc}function Dc(t){return t instanceof bc}function wc(t){return t instanceof vc}const Ic={next:class extends Mc{direction="next";getNodeAtCaret(){return this.origin.getNextSibling()}insert(t){return this.origin.insertAfter(t),this}},previous:class extends Mc{direction="previous";getNodeAtCaret(){return this.origin.getPreviousSibling()}insert(t){return this.origin.insertBefore(t),this}}},Pc={next:class extends bc{direction="next";getNodeAtCaret(){return this.origin.getNextSibling()}insert(t){return this.origin.insertAfter(t),this}},previous:class extends bc{direction="previous";getNodeAtCaret(){return this.origin.getPreviousSibling()}insert(t){return this.origin.insertBefore(t),this}}},Fc={next:class extends vc{direction="next";getNodeAtCaret(){return this.origin.getFirstChild()}insert(t){return this.origin.splice(0,0,[t]),this}},previous:class extends vc{direction="previous";getNodeAtCaret(){return this.origin.getLastChild()}insert(t){return this.origin.splice(this.origin.getChildrenSize(),0,[t]),this}}};function Rc(t,e){return t?new Pc[e](t):null}function Lc(t,e,n){return t?new Ic[e](t,Kc(t,n)):null}function Kc(t,n,o="error"){const r=t.getTextContentSize();let s="next"===n?r:"previous"===n?0:n;return(s<0||s>r)&&("clamp"!==o&&e(284,String(n),String(r),t.getKey()),s=s<0?0:r),s}function Bc(t,e){return new Hc(t,e)}function $c(t,e){return as(t)?new Fc[e](t):null}function zc(t){return t&&t.getChildCaret()||t}function Wc(t){return t&&zc(t.getAdjacentCaret())}class Uc{type="node-caret-range";direction;anchor;focus;constructor(t,e,n){this.anchor=t,this.focus=e,this.direction=n}getLatest(){const t=this.anchor.getLatest(),e=this.focus.getLatest();return t===this.anchor&&e===this.focus?this:new Uc(t,e,this.direction)}isCollapsed(){return this.anchor.isSamePointCaret(this.focus)}getTextSlices(){const t=t=>{const e=this[t].getLatest();return Ac(e)?function(t,e){const{direction:n,origin:o}=t,r=Kc(o,"focus"===e?kc(n):n);return Bc(t,r-t.offset)}(e,t):null},e=t("anchor"),n=t("focus");if(e&&n){const{caret:t}=e,{caret:o}=n;if(t.isSameNodeCaret(o))return[Bc(t,o.offset-t.offset),null]}return[e,n]}iterNodeCarets(t="root"){const e=Ac(this.anchor)?this.anchor.getSiblingCaret():this.anchor.getLatest(),n=this.focus.getLatest(),o=Ac(n),r=e=>e.isSameNodeCaret(n)?null:Wc(e)||e.getParentCaret(t);return Jc({hasNext:t=>null!==t&&!(o&&n.isSameNodeCaret(t)),initial:e.isSameNodeCaret(n)?null:r(e),map:t=>t,step:r})}[Symbol.iterator](){return this.iterNodeCarets("root")}}class Hc{type="slice";caret;distance;constructor(t,e){this.caret=t,this.distance=e}getSliceIndices(){const{distance:t,caret:{offset:e}}=this,n=e+t;return n{let n;for(let o=c;on.has(t.getKey())&&bl(t));if(f&&lc(f).length>0)return null;return u&&f?[u,f]:null}(d,h,a);if(g){const[t,e]=g;$c(t,"previous").splice(0,e.getChildren());let n=e.getParent();for(e.remove(!0);n&&n.isEmpty();){const t=n;n=n.getParent(),t.remove(!0)}}else if(h){const t=function(t){if(wc(t)){const e=t.origin;if(bl(e))return e}else{const e=t.getParentAtCaret();if(e&&bl(e))return e}return null}(h),e=t&&t.getParent(),n=t&&t.getParents().findLast(qi);if(t&&e&&!gs(e)&&t.isEmpty()&&a.has(t.getKey())&&0===lc(t).length&&(!n||a.has(n.getKey()))){t.remove(!0);let n=e;for(;n&&!gs(n)&&n.isEmpty();){const t=n.getParent();if(t&&gs(t)&&t.getChildrenSize()<=1)break;const e=n;n=t,e.remove(!0)}}}const _=[d,h,...l,...c].find(la);if(_){return Yc(fa(aa(_),e.direction))}t(269,JSON.stringify(l.map(t=>t.origin.__key)))}function aa(t){const e=function(t){let e=t;for(;wc(e);){const t=Wc(e);if(!wc(t))break;e=t}return e}(t.getLatest()),{direction:n}=e;if(wo(e.origin))return Ac(e)?e:Lc(e.origin,n,n);const o=e.getAdjacentCaret();return Dc(o)&&wo(o.origin)?Lc(o.origin,n,kc(n)):e}function ua(t){return Ac(t)&&t.offset!==Kc(t.origin,t.direction)}function fa(t,e){return t.direction===e?t:t.getFlipped()}function da(t,e){return t.direction===e?t:Gc(fa(t.focus,e),fa(t.anchor,e))}function ha(t,e,n){let o=$c(t,"next");for(let t=0;t0||!s&&n.canBeEmpty()&&r(n,"last"))&&i.insert(e(n).splice(0,0,o))}return i}function ma(e,n,o){let r=fa(n,"next");Ac(r)&&(0===r.offset?r=Rc(r.origin,"previous").getFlipped():r.offset===r.origin.getTextContentSize()&&(r=Rc(r.origin,"next"))),r.origin.is(e)&&(Dc(r)||t(342,e.getKey(),e.getType()),r=sa(r)),(e.is(r.getNodeAtCaret())||e.is(r.getFlipped().getNodeAtCaret()))&&e.remove(!0);for(let t=r;t;t=pa(t,o))r=t;return Ac(r)&&t(283),r.insert(e.isInline()?Ms().append(e):e),fa(Rc(e.getLatest(),"next"),n.direction)}function ya(...t){const e=[];for(const n of t)if(n&&"string"==typeof n)for(const[t]of n.matchAll(/\S+/g))e.push(t);return e}function xa(...t){return()=>{for(let e=t.length-1;e>=0;e--)t[e]();t.length=0}}exports.$addUpdateTag=Ui,exports.$applyNodeReplacement=Zi,exports.$assumeActiveEditor=function(t){null!==Hr()&&null===Pr&&(Pr=t),Pr!==t&&e(378)},exports.$caretFromPoint=ta,exports.$caretRangeFromSelection=ra,exports.$cloneWithProperties=Ll,exports.$cloneWithPropertiesEphemeral=function(t){return(e=Ll(t))[Qn]=!0,e;var e},exports.$comparePointCaretNext=Vc,exports.$copyNode=Qi,exports.$create=function(t){const e=Ml();return Wr(),new(e.resolveRegisteredNodeAfterReplacements(e.getRegisteredNode(t)).klass)},exports.$createChildrenArray=Xl,exports.$createLineBreakNode=Ts,exports.$createNodeSelection=gr,exports.$createParagraphNode=Ms,exports.$createPoint=Ko,exports.$createRangeSelection=hr,exports.$createRangeSelectionFromDom=function(t,e){return _r(null,t,e,null)},exports.$createTabNode=Fo,exports.$createTextNode=Do,exports.$extendCaretToRange=jc,exports.$findMatchingParent=ql,exports.$formatText=Vo,exports.$fullReconcile=Yr,exports.$generateNodesFromRawText=kr,exports.$getAdjacentChildCaret=Wc,exports.$getAdjacentNode=Li,exports.$getAdjacentSiblingOrParentSiblingCaret=function(t,e="root"){let n=0,o=t,r=Wc(o);for(;null===r;){if(n--,r=o.getParentCaret(e),!r)return null;o=r,r=Wc(o)}return r&&[r,n]},exports.$getCaretInDirection=fa,exports.$getCaretRange=Gc,exports.$getCaretRangeInDirection=da,exports.$getCharacterOffsets=Xo,exports.$getChildCaret=$c,exports.$getChildCaretAtIndex=ha,exports.$getChildCaretOrSelf=zc,exports.$getCollapsedCaretRange=Yc,exports.$getCommonAncestor=Zc,exports.$getCommonAncestorResultBranchOrder=qc,exports.$getDOMSlot=Dl,exports.$getDOMTextNode=Il,exports.$getDocument=fl,exports.$getEditor=Ml,exports.$getEditorDOMRenderConfig=Al,exports.$getNearestNodeFromDOMNode=gi,exports.$getNearestRootOrShadowRoot=Vi,exports.$getNodeByKey=ui,exports.$getNodeByKeyOrThrow=el,exports.$getNodeFromDOMNode=fi,exports.$getPreviousSelection=mr,exports.$getRoot=mi,exports.$getSelection=pr,exports.$getSiblingCaret=Rc,exports.$getSlot=cc,exports.$getSlotFrame=sc,exports.$getSlotHost=oc,exports.$getSlotNameWithinHost=rc,exports.$getSlotNames=lc,exports.$getState=at,exports.$getStateChange=function(t,e,n){const o=at(t,n,it),r=at(e,n,it);return n.isEqual(o,r)?null:[o,r]},exports.$getTextContent=function(){const t=pr();return null===t?"":t.getTextContent()},exports.$getTextNodeOffset=Kc,exports.$getTextPointCaret=Lc,exports.$getTextPointCaretSlice=Bc,exports.$getWritableNodeState=ht,exports.$hasAncestor=ji,exports.$hasUpdateTag=function(t){return jr()._updateTags.has(t)},exports.$insertNodeToNearestRootAtCaret=ma,exports.$insertNodes=function(t){let e=pr()||mr();null===e&&(e=mi().selectEnd()),e.insertNodes(t)},exports.$isBlockElementNode=fr,exports.$isChildCaret=wc,exports.$isDecoratorNode=ds,exports.$isEditorState=function(t){return t instanceof ys},exports.$isElementDOMSlot=wl,exports.$isElementNode=as,exports.$isExtendableTextPointCaret=ua,exports.$isInlineElementOrDecoratorNode=Ji,exports.$isInlineFormattable=So,exports.$isLeafNode=function(t){return wo(t)||Ns(t)||ds(t)},exports.$isLexicalNode=no,exports.$isLineBreakNode=Ns,exports.$isNodeCaret=function(t){return t instanceof Nc},exports.$isNodeSelection=Go,exports.$isParagraphNode=As,exports.$isRangeSelection=jo,exports.$isRootNode=gs,exports.$isRootOrShadowRoot=Xi,exports.$isSelectionCapturedInDecoratorInput=Ys,exports.$isShadowRootNode=qi,exports.$isSiblingCaret=Dc,exports.$isSlotChild=ec,exports.$isSlotHost=tc,exports.$isTabNode=Ro,exports.$isTextNode=wo,exports.$isTextPointCaret=Ac,exports.$isTextPointCaretSlice=function(t){return t instanceof Hc},exports.$isTokenOrSegmented=Zs,exports.$isTokenOrTab=Qs,exports.$markSlotEditable=Ul,exports.$needsBlockCursorBeside=nl,exports.$nodesOfType=function(t){const e=t.getType(),n=Hr();if(n._readOnly){const t=Rl(n).get(e);return t?Array.from(t.values()):[]}const o=n._nodeMap,r=[];for(const[,n]of o)n instanceof t&&n.__type===e&&n.isAttached()&&r.push(n);return r},exports.$normalizeCaret=aa,exports.$normalizeSelection__EXPERIMENTAL=Nt,exports.$onUpdate=Hi,exports.$parseSerializedNode=function(t){return Qr(t,jr()._nodes)},exports.$removeFromParent=si,exports.$removeSlot=xc,exports.$removeTextFromCaretRange=ca,exports.$rewindSiblingCaret=sa,exports.$selectAll=function(t){const e=mi();if(jo(t)){const e=t.anchor,n=t.focus,o=e.getNode();if(gs(o))return e.set(o.getKey(),0,"element"),n.set(o.getKey(),o.getChildrenSize(),"element"),Nt(t),t;const r=o.getTopLevelElementOrThrow(),s=r.getParent();if(null===s)return as(r)&&(e.set(r.getKey(),0,"element"),n.set(r.getKey(),r.getChildrenSize(),"element"),Nt(t)),t;const i=s;return e.set(i.getKey(),0,"element"),n.set(i.getKey(),i.getChildrenSize(),"element"),Nt(t),t}{const t=e.select(0,e.getChildrenSize());return yi(Nt(t)),t}},exports.$setCompositionKey=ci,exports.$setDirectionFromDOM=Bl,exports.$setFormatFromDOM=$l,exports.$setPointFromCaret=ea,exports.$setSelection=yi,exports.$setSelectionFromCaretRange=na,exports.$setSlot=yc,exports.$setState=function(t,e,n){let o;if(Wr(),"function"==typeof n){const r=t.getLatest(),s=at(r,e);if(o=n(s),e.isEqual(s,o))return r}else o=n;const r=t.getWritable();return ht(r).updateFromKnown(e,o),r},exports.$setTextFormat=function(t,e){const n=[];for(const[t,o]of Object.entries(e))"boolean"==typeof o&&n.push([t,o]);0!==n.length&&Jo(t,t=>{for(const[e,o]of n)t=oi(t,e,o?A[e]:0);return t})},exports.$splitAtPointCaretNext=pa,exports.$splitNode=function(e,n){let o=e.getChildAtIndex(n);null==o&&(o=e),Xi(e)&&t(102);const r=e=>{const n=e.getParentOrThrow(),s=Xi(n),i=e!==o||s?Qi(e):e;if(s)return as(e)&&as(i)||t(133),e.insertAfter(i),[e,i,i];{const[t,o,s]=r(n),l=e.getNextSiblings();return s.append(i,...l),[t,o,i]}},[s,i]=r(o);return[s,i]},exports.$updateDOMSelection=vr,exports.$updateRangeSelectionFromCaretRange=oa,exports.ArtificialNode__DO_NOT_USE=xs,exports.BEFORE_INPUT_COMMAND=ke,exports.BLUR_COMMAND=yn,exports.CAN_REDO_COMMAND=_n,exports.CAN_UNDO_COMMAND=pn,exports.CAN_USE_BEFORE_INPUT=i,exports.CAN_USE_DOM=n,exports.CLEAR_EDITOR_COMMAND=hn,exports.CLEAR_HISTORY_COMMAND=gn,exports.CLICK_COMMAND=Ee,exports.COLLABORATION_TAG=ro,exports.COMMAND_PRIORITY_BEFORE_CRITICAL=-4,exports.COMMAND_PRIORITY_BEFORE_EDITOR=-8,exports.COMMAND_PRIORITY_BEFORE_HIGH=-5,exports.COMMAND_PRIORITY_BEFORE_LOW=-7,exports.COMMAND_PRIORITY_BEFORE_NORMAL=-6,exports.COMMAND_PRIORITY_CRITICAL=4,exports.COMMAND_PRIORITY_EDITOR=ws,exports.COMMAND_PRIORITY_HIGH=3,exports.COMMAND_PRIORITY_LOW=1,exports.COMMAND_PRIORITY_NORMAL=2,exports.COMPOSITION_END_COMMAND=Me,exports.COMPOSITION_END_TAG=ao,exports.COMPOSITION_START_COMMAND=be,exports.COMPOSITION_START_TAG=co,exports.CONTROLLED_TEXT_INSERTION_COMMAND=Ie,exports.COPY_COMMAND=un,exports.CUT_COMMAND=fn,exports.CUT_TAG="cut",exports.DEFAULT_EDITOR_DOM_CONFIG=Fs,exports.DELETE_CHARACTER_COMMAND=Ae,exports.DELETE_LINE_COMMAND=Le,exports.DELETE_WORD_COMMAND=Re,exports.DRAGEND_COMMAND=an,exports.DRAGOVER_COMMAND=cn,exports.DRAGSTART_COMMAND=ln,exports.DROP_COMMAND=rn,exports.DecoratorNode=fs,exports.ElementNode=cs,exports.FOCUS_COMMAND=mn,exports.FORMAT_ELEMENT_COMMAND=sn,exports.FORMAT_TEXT_COMMAND=Ke,exports.HISTORIC_TAG="historic",exports.HISTORY_MERGE_TAG=oo,exports.HISTORY_PUSH_TAG="history-push",exports.INDENT_CONTENT_COMMAND=nn,exports.INPUT_COMMAND=Oe,exports.INSERT_LINE_BREAK_COMMAND=De,exports.INSERT_PARAGRAPH_COMMAND=we,exports.INSERT_TAB_COMMAND=en,exports.INTERNAL_$isBlock=bl,exports.IS_ALL_FORMATTING=2047,exports.IS_ANDROID=c,exports.IS_ANDROID_CHROME=f,exports.IS_APPLE=r,exports.IS_APPLE_WEBKIT=d,exports.IS_BOLD=1,exports.IS_CHROME=u,exports.IS_CODE=16,exports.IS_FIREFOX=s,exports.IS_HIGHLIGHT=p,exports.IS_IOS=l,exports.IS_ITALIC=2,exports.IS_SAFARI=a,exports.IS_STRIKETHROUGH=4,exports.IS_SUBSCRIPT=32,exports.IS_SUPERSCRIPT=64,exports.IS_UNDERLINE=8,exports.KEY_ARROW_DOWN_COMMAND=Je,exports.KEY_ARROW_LEFT_COMMAND=je,exports.KEY_ARROW_RIGHT_COMMAND=Ue,exports.KEY_ARROW_UP_COMMAND=Ge,exports.KEY_BACKSPACE_COMMAND=Xe,exports.KEY_DELETE_COMMAND=Ze,exports.KEY_DOWN_COMMAND=We,exports.KEY_ENTER_COMMAND=Ve,exports.KEY_ESCAPE_COMMAND=Qe,exports.KEY_MODIFIER_COMMAND=xn,exports.KEY_SPACE_COMMAND=qe,exports.KEY_TAB_COMMAND=tn,exports.LineBreakNode=Cs,exports.MOVE_TO_END=He,exports.MOVE_TO_START=Ye,exports.NODE_STATE_DIRECT=it,exports.NODE_STATE_KEY="$",exports.NODE_STATE_LATEST=lt,exports.OUTDENT_CONTENT_COMMAND=on,exports.PASTE_COMMAND=Pe,exports.PASTE_TAG="paste",exports.ParagraphNode=Os,exports.REDO_COMMAND=ze,exports.REMOVE_TEXT_COMMAND=Fe,exports.RootNode=hs,exports.SELECTION_CHANGE_COMMAND=Ne,exports.SELECTION_INSERT_CLIPBOARD_NODES_COMMAND=ve,exports.SELECT_ALL_COMMAND=dn,exports.SET_TEXT_FORMAT_COMMAND=Be,exports.SKIP_COLLAB_TAG="skip-collab",exports.SKIP_DOM_SELECTION_TAG=io,exports.SKIP_SCROLL_INTO_VIEW_TAG=so,exports.SKIP_SELECTION_FOCUS_TAG=lo,exports.TEXT_TYPE_TO_FORMAT=A,exports.TabNode=Po,exports.TextNode=To,exports.UNDO_COMMAND=$e,exports.addClassNamesToElement=function(t,...e){const n=ya(...e);n.length>0&&t.classList.add(...n)},exports.buildImportMap=function(t){return t},exports.configExtension=function(...t){return t},exports.createCommand=Te,exports.createEditor=function(e){const n=e||{},o=Jr(),r=n.theme||{},s=void 0===e?o:n.parentEditor||null,i=n.disableEvents||!1,l=ps(),c=n.namespace||(null!==s?s._config.namespace:Ni()),a=n.editorState,u=[hs,To,Cs,Po,Os,xs,...n.nodes||[]],{onError:f,onWarn:d,html:h}=n,g=void 0===n.editable||n.editable;let _;if(void 0===e&&null!==o)_=o._nodes;else{_=new Map;for(let e=0;e{Object.keys(t).forEach(e=>{let o=n.get(e);void 0===o&&(o=[],n.set(e,o)),o.push(t[e])})};return t.forEach(t=>{const e=t.klass.importDOM;if(null==e||o.has(e))return;o.add(e);const n=e.call(t.klass);null!==n&&r(n)}),e&&r(e),n}(_,h?h.import:void 0),g,e);return void 0!==a&&(p._pendingEditorState=a,p._dirtyType=2),function(t){t.registerCommand(ke,Ln,ws),t.registerCommand(Oe,Kn,ws),t.registerCommand(be,Bn,ws),t.registerCommand(Me,$n,ws),t.registerCommand(We,Un,ws)}(p),p},exports.createRefCountedRegistry=Cn,exports.createSharedNodeState=ut,exports.createState=function(t,e){return new ct(t,e)},exports.declarePeerDependency=function(t,e){return[t,e]},exports.defineExtension=function(t){return t},exports.findAllLexicalElementsDeep=al,exports.flipDirection=kc,exports.getActiveElement=yl,exports.getActiveElementDeep=xl,exports.getComposedEventTarget=Cl,exports.getComposedStaticRange=dl,exports.getDOMOwnerDocument=Wi,exports.getDOMSelection=rl,exports.getDOMSelectionFromTarget=sl,exports.getDOMSelectionPoints=gl,exports.getDOMSelectionRange=hl,exports.getDOMSelectionRangeAndPoints=function(t,e){const n=dl(t,e);if(null===n)return{points:t,range:t.rangeCount>0?t.getRangeAt(0):null};const o=_l(n)??(t.rangeCount>0?t.getRangeAt(0):null);return{points:pl(n,ml(t)),range:o}},exports.getDOMShadowRoots=cl,exports.getDOMTextNode=ni,exports.getDeclaredSlots=gc,exports.getEditorPropertyFromDOMNode=Xs,exports.getNearestEditorFromDOMNode=qs,exports.getParentElement=zi,exports.getRegisteredNode=Hs,exports.getRegisteredNodeOrThrow=Us,exports.getRegisteredSubtypeMap=function(t){const e=new Map,n=new Map;for(const o of t){const{ownNodeType:t}=Jl(o);t&&(n.set(t,o),e.set(t,new Set))}for(const[t,o]of n)for(const{ownNodeType:n}of Vl(o)){const o=n&&e.get(n);o&&o.add(t)}return e},exports.getRootOwnerDocument=ul,exports.getStaticNodeConfig=Jl,exports.getStyleObjectFromCSS=fo,exports.getTextDirection=function(t){return b.test(t)?"rtl":M.test(t)?"ltr":null},exports.getTransformSetFromKlass=Ps,exports.isBlockDomNode=Ol,exports.isCurrentlyReadOnlyMode=zr,exports.isDOMCapturingSelection=Hl,exports.isDOMDocumentNode=ei,exports.isDOMNode=Tl,exports.isDOMShadowRoot=il,exports.isDOMTextNode=ti,exports.isDOMUnmanaged=Wl,exports.isDocumentFragment=Nl,exports.isExactShortcutMatch=Ai,exports.isHTMLAnchorElement=function(t){return Sl(t)&&"A"===t.tagName},exports.isHTMLElement=Sl,exports.isHTMLTableCellElement=function(t){return Sl(t)&&("TD"===t.tagName||"TH"===t.tagName)},exports.isHTMLTableRowElement=function(t){return Sl(t)&&"TR"===t.tagName},exports.isInlineDomNode=El,exports.isLastChildInBlockNode=Es,exports.isLexicalEditor=Vs,exports.isModifierMatch=Mi,exports.isOnlyChildInBlockNode=vs,exports.isSelectionCapturedInDecoratorInput=Gs,exports.isSelectionWithinEditor=Js,exports.iterStaticNodeConfigChain=Vl,exports.makeStepwiseIterator=Jc,exports.mergeRegister=xa,exports.mountSlotContainer=function(t,e,n,o){const r=t.read("latest",()=>{const o=ui(e);return null!==o?function(t,e,n=Ml()){const o=cc(t,e);if(null===o)return null;const r=n.getElementByKey(o.getKey());return null!==r?r.parentElement:null}(o,n,t):null});return null!==r&&(r.parentElement!==o&&o.appendChild(r),r.style.display=""),r},exports.normalizeClassNames=ya,exports.registerEventListener=Sn,exports.registerEventListeners=function(t,e,n){return xa(...Object.entries(e).map(([e,o])=>Sn(t,e,o,n)))},exports.removeClassNamesFromElement=function(t,...e){const n=ya(...e);n.length>0&&t.classList.remove(...n)},exports.removeFromParent=ii,exports.resetRandomKey=function(){Ws=1},exports.safeCast=function(t){return t},exports.setDOMStyleFromCSS=go,exports.setDOMStyleObject=function(t,e){for(const n in e){const o=e[n];null==o?t.removeProperty(n):ho(t,n,o)}},exports.setDOMUnmanaged=zl,exports.setNodeIndentFromDOM=Kl,exports.shallowMergeConfig=function(t,e){if(!e||t===e)return t;for(const n in e)if(t[n]!==e[n])return{...t,...e};return t},exports.stopLexicalPropagation=Gn,exports.toggleTextFormatType=oi,exports.tokenizeRawText=Er,exports.unmountSlotContainer=function(t,e,n){n.style.display="none";const o=t.getElementByKey(e);null!==o&&n.parentElement!==o&&o.insertBefore(n,o.firstChild)}; +diff --git a/dist/Lexical.prod.mjs b/dist/Lexical.prod.mjs +index e2ef2d833f8403e4288764ee109759431c236481..38adb8318370c61ea67a32275227a863b6f68052 100644 +--- a/dist/Lexical.prod.mjs ++++ b/dist/Lexical.prod.mjs +@@ -9,2 +9,2 @@ + function t(t,...e){const n=new URL("https://lexical.dev/docs/error"),o=new URLSearchParams;o.append("code",t);for(const t of e)o.append("v",t);throw n.search=o.toString(),Error(`Minified Lexical error #${t}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function e(t,...e){const n=new URL("https://lexical.dev/docs/error"),o=new URLSearchParams;o.append("code",t);for(const t of e)o.append("v",t);n.search=o.toString(),console.warn(`Minified Lexical warning #${t}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}const n="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,o=n&&"documentMode"in document?document.documentMode:null,r=n&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),i=n&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),s=!(!n||!("InputEvent"in window)||o)&&"getTargetRanges"in new window.InputEvent("input"),l=n&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,c=n&&/Android/.test(navigator.userAgent),a=n&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent)&&!c,u=n&&/^(?=.*Chrome).*/i.test(navigator.userAgent),f=n&&c&&u,d=n&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&r&&!u,h=0,g=1,_=2,p=1,y=2,m=4,x=8,C=16,S=32,v=64,T=128,k=2047,b=1,N=2,E=3,w=4,O=5,M=6,A=a||l||d?"\xa0":"\u200b",D="\n\n",F=i?"\xa0":A,P="\u0591-\u07ff\ufb1d-\ufdfd\ufe70-\ufefc",I="A-Za-z\xc0-\xd6\xd8-\xf6\xf8-\u02b8\u0300-\u0590\u0800-\u1fff\u200e\u2c00-\ufb1c\ufe00-\ufe6f\ufefd-\uffff",L=new RegExp("^[^"+I+"]*["+P+"]"),K=new RegExp("^[^"+P+"]*["+I+"]"),z={bold:1,capitalize:1024,code:16,highlight:T,italic:2,lowercase:256,strikethrough:4,subscript:32,superscript:64,underline:8,uppercase:512},B={directionless:1,unmergeable:2},R={center:2,end:6,justify:4,left:1,right:3,start:5},W={[N]:"center",[M]:"end",[w]:"justify",[b]:"left",[E]:"right",[O]:"start"},$={normal:0,segmented:2,token:1},U={[h]:"normal",[_]:"segmented",[g]:"token"},H="$",j="$config";function J(){return vc()._blockCursorElement}function V(t){return null!==t&&1===t.nodeType&&t.hasAttribute("data-lexical-slot")}class q{element;before;after;constructor(t,e,n){this.element=t,this.before=e||null,this.after=n||null}withBefore(t){return new q(this.element,t,this.after)}withAfter(t){return new q(this.element,this.before,t)}withElement(t){return this.element===t?this:new q(t,this.before,this.after)}insertChild(e){const n=this.getInsertionAnchor();return null!==n&&n.parentElement!==this.element&&t(357),this.element.insertBefore(e,n),this}removeChild(e){return e.parentElement!==this.element&&t(358),this.element.removeChild(e),this}replaceChild(e,n){return n.parentElement!==this.element&&t(359),this.element.replaceChild(e,n),this}getFirstChild(){const t=this.getFirstChildAnchor(),e=t?t.nextSibling:this.element.firstChild;return e===this.getInsertionAnchor()?null:e}getFirstChildAnchor(){return this.after}resolveLeafPosition(t,e,n){if(this.element===t)return e===t&&0===n?"before":"after";const o=Y(t,this.element);if(null===o)return"after";const r=Array.prototype.indexOf.call(t.childNodes,o);if(r<0)return"after";if(e===t)return n<=r?"before":"after";const i=Y(t,e);if(null===i)return"after";const s=Array.prototype.indexOf.call(t.childNodes,i);return s>=0&&s<=r?"before":"after"}getInsertionAnchor(){return this.before}}function Y(t,e){let n=e;for(;null!==n&&n.parentNode!==t;)n=n.parentNode;return n}class G extends q{withBefore(t){return new G(this.element,t,this.after)}withAfter(t){return new G(this.element,this.before,t)}withElement(t){return this.element===t?this:new G(t,this.before,this.after)}getInsertionAnchor(){return super.getInsertionAnchor()||this.getManagedLineBreak()}getFirstChildAnchor(){let t=super.getFirstChildAnchor(),e=t?t.nextSibling:this.element.firstChild;for(;V(e);)t=e,e=e.nextSibling;const n=t?t.nextSibling:this.element.firstChild;return null!==n&&n===J()?n:t}getManagedLineBreak(){return this.element.__lexicalLineBreak||null}setManagedLineBreak(t){if(this.element.__lexicalLastChildKind=t,null===t)this.removeManagedLineBreak();else{const e="decorator"===t&&(d||l||a);this.insertManagedLineBreak(e)}}removeManagedLineBreak(){const t=this.getManagedLineBreak();if(t){const e=this.element,n="IMG"===t.nodeName?t.nextSibling:null;n&&e.removeChild(n),e.removeChild(t),e.__lexicalLineBreak=void 0}}insertManagedLineBreak(t){const e=this.getManagedLineBreak();if(e){if(t===("IMG"===e.nodeName))return;this.removeManagedLineBreak()}const n=this.element,o=this.before,r=Zl().createElement("br");if(r.setAttribute("data-lexical-managed-linebreak","true"),n.insertBefore(r,o),t){const t=Zl().createElement("img");t.setAttribute("data-lexical-managed-linebreak","true"),t.style.setProperty("display","inline","important"),t.style.setProperty("border","0px","important"),t.style.setProperty("margin","0px","important"),t.alt="",n.insertBefore(t,r),n.__lexicalLineBreak=t}else n.__lexicalLineBreak=r}getFirstChildOffset(){const t=this.getFirstChild(),e=this.getInsertionAnchor();let n=0;for(let o=this.element.firstChild;null!==o&&o!==t&&o!==e;o=o.nextSibling)n++;return n}resolveChildIndex(t,e,n,o){if(n===this.element){const e=this.getFirstChildOffset(),n=J(),r=this.element.childNodes,i=Math.min(o,r.length);let s=0;for(let t=e;tn){s+=1;break}}return[t.getParentOrThrow(),s]}}function X(e,n){const o=[];let r=n;for(;r!==e&&null!==r;r=r.parentNode){let t=0;for(let e=r.previousSibling;null!==e;e=e.previousSibling)t++;o.push(t)}return r!==e&&t(225),o.reverse()}let Q;try{Q="0.49.0+prod.esm"}catch(t){}const Z=Q??'"+source"';class tt{_front=new Set;_back=new Set;_cache;get size(){return this._front.size+this._back.size}addBack(t){return delete this._cache,this._front.has(t)||this._back.add(t),this}addFront(t){return delete this._cache,this._back.has(t)||this._front.add(t),this}delete(t){return delete this._cache,this._front.delete(t)||this._back.delete(t)}toArray(){const t=Array.from(this._front).reverse();for(const e of this._back)t.push(e);return t}toReadonlyArray(){return this._cache=this._cache||this.toArray(),this._cache}[Symbol.iterator](){return this.toReadonlyArray()[Symbol.iterator]()}}const et=null;function nt(t,e=1e3){return t instanceof ot?t.clone():t.sizethis._size}getNursery(){return this._mutable&&this._nursery||(this.compact(),this._nursery=new Map(this._nursery),this._mutable=!0),this._nursery}compact(t=!1){if(this._nursery&&this._nursery.size>0&&(t||this.shouldCompact())){const t=new Map(this._old);for(const[e,n]of this._nursery)n!==et?t.set(e,n):t.delete(e);this._old=t,this._nursery=void 0}return this._mutable=!1,this}set(t,e){const n=this.getWithTombstone(t);if(n===e)return this;const o=this.getNursery();return n!==et&&void 0!==n||(this._size++,n===et&&o.delete(t)),o.set(t,e),this}delete(t){const e=this.has(t);return e&&(this.getNursery().set(t,et),this._size--),e}getOrInsert(t,e){const n=this.get(t);return void 0!==n?n:(this.set(t,e),e)}getOrInsertComputed(t,e){const n=this.get(t);if(void 0!==n)return n;const o=e(t);return this.set(t,o),o}clear(){this._mutable=!1,this._old=void 0,this._nursery=void 0,this._size=0}*keys(){for(const t of this.entries())yield t[0]}*values(){for(const t of this.entries())yield t[1]}*entries(){const t=this._nursery,e=this._old;if(e)for(const n of e){const e=n[0],o=t?t.get(e):void 0;o!==et&&(void 0!==o&&(n[1]=o),yield n)}if(t)for(const n of t)n[1]===et||e&&e.has(n[0])||(yield n)}forEach(t,e){void 0!==e&&(t=t.bind(e));for(const[e,n]of this.entries())t(n,e,this)}get[Symbol.toStringTag](){return"GenMap"}[Symbol.iterator](){return this.entries()}}function rt(t,e,n,o,r,i){if(Pi(t)){let s=t.getFirstChild();for(;null!==s;){const t=s.__key;s.__parent===e&&((Pi(s)||Qc(s)&&null!==s.__slots)&&rt(s,t,n,o,r,i),n.has(t)||i.delete(t),r.push(t)),s=s.getNextSibling()}}for(const s of Qc(t)&&null!==t.__slots?t.__slots.values():[]){const t=o.get(s);void 0!==t&&Zc(t)&&t.__slotHost===e&&((Pi(t)||Qc(t)&&null!==t.__slots)&&rt(t,s,n,o,r,i),n.has(s)||i.delete(s),r.push(s))}}let it=!1,st=0;function lt(t){st=t.timeStamp}function ct(t,e,n){const o="BR"===t.nodeName,r=e.__lexicalLineBreak;return r&&(t===r||o&&t.previousSibling===r)||o&&void 0!==Qs(t,n)}function at(t,e,n){const o=Jl(Il(n)),r=o&&nc(o,n._rootElement);let i=null,s=null;null!==r&&r.anchorNode===t&&(i=r.anchorOffset,s=r.focusOffset);const l=t.nodeValue;null!==l&&fl(e,l,i,s,!1)}function ut(t,e,n){if(ur(t)){const e=t.anchor.getNode();if(e.is(n)&&t.format!==e.getFormat())return!1}return zs(e)&&n.isAttached()}function ft(t,e,n){for(let o=t;o&&!zc(o);o=wl(o)){const t=Qs(o,e);if(void 0!==t){const e=Ys(t,n);if(e)return Ki(e)||!gc(o)?void 0:[o,e]}}}function dt(t,e,n){it=!0;const o=performance.now()-st>100;try{Ai(t,()=>{const r=Kr()||function(t){return t.read("latest",()=>{const t=Kr();return null!==t?t.clone():null})}(t),s=new Map,l=t._editorState,c=t._blockCursorElement;let a=!1,u="";for(let n=0;n0){let e=0;for(let r=0;r0)for(const[e,n]of s)n.reconcileObservedMutation(e,t);const f=n.takeRecords();if(f.length>0){for(let e=0;e{dt(t,e,n)})}const _t="direct",pt="latest";class yt{key;parse;unparse;isEqual;defaultValue;resetOnCopyNode;constructor(t,e){this.key=t,this.parse=e.parse.bind(e),this.unparse=(e.unparse||wt).bind(e),this.isEqual=(e.isEqual||Object.is).bind(e),this.defaultValue=this.parse(void 0),this.resetOnCopyNode=e.resetOnCopyNode||!1}}function mt(t,e){return new yt(t,e)}function xt(t,e,n=pt){const o=(n===pt?t.getLatest():t).__state;return o?o.getValue(e):e.defaultValue}function Ct(t,e,n){const o=xt(t,n,_t),r=xt(e,n,_t);return n.isEqual(o,r)?null:[o,r]}function St(t,e,n){let o;if(fi(),"function"==typeof n){const r=t.getLatest(),i=xt(r,e);if(o=n(i),e.isEqual(i,o))return r}else o=n;const r=t.getWritable();return bt(r).updateFromKnown(e,o),r}function vt(t){const e=new Map,n=new Set;for(const{ownNodeConfig:o}of jc("function"==typeof t?t:t.replace))if(o&&o.stateConfigs)for(const t of o.stateConfigs){let o;"stateConfig"in t?(o=t.stateConfig,t.flat&&n.add(o.key)):o=t,e.set(o.key,o)}return{flatKeys:n,sharedConfigMap:e}}const Tt=new Set(["__proto__","constructor","prototype"]);class kt{node;knownState;unknownState;sharedNodeState;size;constructor(t,e,n=void 0,o=new Map,r=void 0){this.node=t,this.sharedNodeState=e,this.unknownState=n,this.knownState=o;const{sharedConfigMap:i}=this.sharedNodeState,s=void 0!==r?r:function(t,e,n){let o=n.size;if(e)for(const r in e){const e=t.get(r);e&&n.has(e)||o++}return o}(i,n,o);this.size=s}getValue(t){const e=this.knownState.get(t);if(void 0!==e)return e;this.sharedNodeState.sharedConfigMap.set(t.key,t);let n=t.defaultValue;if(this.unknownState&&t.key in this.unknownState){const e=this.unknownState[t.key];void 0!==e&&(n=t.parse(e)),this.updateFromKnown(t,n)}return n}getInternalState(){return[this.unknownState,this.knownState]}toJSON(){const t={...this.unknownState},e={};for(const[e,n]of this.knownState)e.isEqual(n,e.defaultValue)?delete t[e.key]:t[e.key]=e.unparse(n);for(const n of this.sharedNodeState.flatKeys)n in t&&(e[n]=t[n],delete t[n]);return Et(t)&&(e.$=t),e}getWritable(t){if(this.node===t)return this;const{sharedNodeState:e,unknownState:n}=this,o=new Map(this.knownState);return new kt(t,e,function(t,e,n){let o;if(n)for(const[r,i]of Object.entries(n)){if(Tt.has(r))continue;const n=t.get(r);n?e.has(n)||e.set(n,n.parse(i)):(o=o||{},o[r]=i)}return o}(e.sharedConfigMap,o,n),o,this.size)}resetOnCopyNode(){for(const t of this.knownState.keys())t.resetOnCopyNode&&this.knownState.set(t,t.defaultValue);return this}updateFromKnown(t,e){const n=t.key;this.sharedNodeState.sharedConfigMap.set(n,t);const{knownState:o,unknownState:r}=this;o.has(t)||r&&n in r||(r&&(delete r[n],this.unknownState=Et(r)),this.size++),o.set(t,e)}updateFromUnknown(t,e){if(Tt.has(t))return;const n=this.sharedNodeState.sharedConfigMap.get(t);n?this.updateFromKnown(n,n.parse(e)):(this.unknownState=this.unknownState||{},t in this.unknownState||this.size++,this.unknownState[t]=e)}updateFromJSON(t){const{knownState:e}=this;for(const t of e.keys())e.set(t,t.defaultValue);if(this.size=e.size,this.unknownState=void 0,t)for(const[e,n]of Object.entries(t))this.updateFromUnknown(e,n)}}function bt(t){const e=t.getWritable(),n=e.__state?e.__state.getWritable(e):new kt(e,Nt(e));return e.__state=n,n}function Nt(t){return t.__state?t.__state.sharedNodeState:Ns(vc(),t.getType()).sharedNodeState}function Et(t){if(t)for(const e in t)return t}function wt(t){return t}function Ot(t,e,n){for(const[o,r]of e.knownState){if(t.has(o.key))continue;t.add(o.key);const e=n?n.getValue(o):o.defaultValue;if(e!==r&&!o.isEqual(e,r))return!0}return!1}function Mt(t,e,n){const{unknownState:o}=e,r=n?n.unknownState:void 0;if(o)for(const[e,n]of Object.entries(o)){if(t.has(e))continue;t.add(e);if(n!==(r?r[e]:void 0))return!0}return!1}function At(t,e){const n=t.__state;return n&&n.node===t?n.getWritable(e):n}function Dt(t,e){const n=t.__mode,o=t.__format,r=t.__style,i=e.__mode,s=e.__format,l=e.__style,c=t.__state,a=e.__state;return(null===n||n===i)&&(null===o||o===s)&&(null===r||r===l)&&(null===t.__state||c===a||function(t,e){if(t===e)return!0;const n=new Set;return!(t&&Ot(n,t,e)||e&&Ot(n,e,t)||t&&Mt(n,t,e)||e&&Mt(n,e,t))}(c,a))}function Ft(t,e){const n=t.mergeWithSibling(e),o=_i()._normalizedNodes;return o.add(t.__key),o.add(e.__key),n}function Pt(t){let e,n,o=t;if(""!==o.__text||!o.isSimpleText()||o.isUnmergeable()){for(;null!==(e=o.getPreviousSibling())&&Xo(e)&&e.isSimpleText()&&!e.isUnmergeable();){if(""!==e.__text){if(Dt(e,o)){o=Ft(e,o);break}break}e.remove()}for(;null!==(n=o.getNextSibling())&&Xo(n)&&n.isSimpleText()&&!n.isUnmergeable();){if(""!==n.__text){if(Dt(o,n)){o=Ft(o,n);break}break}n.remove()}}else o.remove()}function It(t){return Lt(t.anchor),Lt(t.focus),t}function Lt(t){for(;"element"===t.type;){const e=t.getNode(),n=t.offset;let o,r;if(n===e.getChildrenSize()?(o=e.getChildAtIndex(n-1),r=!0):(o=e.getChildAtIndex(n),r=!1),Xo(o)){t.set(o.__key,r?o.getTextContentSize():0,"text",!0);break}if(!Pi(o))break;t.set(o.__key,r?o.getChildrenSize():0,"element",!0)}}const Kt=Symbol.for("@lexical/CachedTextSize");function zt(e,n){return ee.read(()=>{let o=0,r=e;for(let e=0;e0&&!o?t.classList.add(n):e<1&&o&&t.classList.remove(n)}t.style.setProperty("padding-inline-start",0===e?"":`calc(${e} * var(--lexical-indent-base-value, ${de}))`)}function ge(t,e){const n=t.style;0===e?fe(n,""):1===e?fe(n,"left"):2===e?fe(n,"center"):3===e?fe(n,"right"):4===e?fe(n,"justify"):5===e?fe(n,"start"):6===e&&fe(n,"end")}function _e(t,e){const n=function(t){const e=t.__dir;if(null!==e)return e;if(Bi(t))return null;const n=t.getParent();return null===n||Bl(n)&&null===n.__dir?"auto":null}(e);null!==n?t.dir=n:t.removeAttribute("dir")}function pe(t){const e=Zl().createElement("div");return e.setAttribute("data-lexical-slot",t),e.style.display="none",e}function ye(t,e,n){e||"false"===t.contentEditable?Bc(n,$t):n.removeAttribute("contenteditable")}function me(t,e,n){const o=Ht,r=qt();Ht="";let i="";const s=Ki(t);for(const[o,r]of n){const n=pe(o);ye(e,s,n),e.appendChild(n),Ht="";const l=qt();Te(r,kc(t,n,$t)),Yt(l),Ce(t,o,e,n),i+=Ht}return Yt(r),Ht=o,i}function xe(t){return Qc(t)&&null!==t.__slots?t.__slots:Xc}function Ce(t,e,n,o){const r=se.$getSlotTargetElement(t,e,n,$t);null!==r&&(o.parentElement!==r&&r.appendChild(o),o.style.display="")}function Se(t){const e=oe.get(t);return void 0!==e?e.parentElement:null}function ve(t,e,n){const o=xe(t),r=xe(e);for(const[t,e]of o)if(!r.has(t)){const t=Se(e);ae(e,null),null!==t&&t.remove()}const i=Ht,s=qt();let l="",c=null;const a=Ki(e);for(const[t,i]of r){const r=o.get(t);let s=void 0!==r?Se(r):null;Ht="";const u=qt();if(null===s){s=pe(t);let o=null;for(const t of n.children)if(!t.hasAttribute("data-lexical-slot")){o=t;break}n.insertBefore(s,o),Te(i,kc(e,s,$t))}else r===i?we(i,s):(void 0!==r&&ae(r,s),Te(i,kc(e,s,$t)));if(Yt(u),ye(n,a,s),Ce(e,t,n,s),l+=Ht,s.parentElement===n){const t=null===c?n.firstChild:c.nextSibling;t!==s&&n.insertBefore(s,t),c=s}}return Yt(s),Ht=i,l}function Te(e,n){const o=ne.get(e);if(void 0===o&&t(60),null!==n){const t=te.get(e);if(void 0!==t){const r=oe.get(e);if(void 0!==r){const i=Zc(t)?t.__slotHost:null,s=Zc(o)?o.__slotHost:null,l=t.__parent!==o.__parent||i!==s,c=null!==s&&r.parentElement!==n.element;if(l||c)return n.insertChild(r),we(e,n.element)}}}const r=se.$createDOM(o,$t);if(function(t,e,n){const o=n._keyToDOMMap;Xs(e,n,t),o.set(t,e)}(e,r,$t),Xo(o)?r.setAttribute("data-lexical-text","true"):Ki(o)&&(r.setAttribute("data-lexical-decorator","true"),Kc(r,{captureSelection:!0})),Pi(o)){const t=o.__indent,e=o.__size;_e(r,o),0!==t&&he(r,t);const n=xe(o),i=n.size>0?me(o,r,n):"";if(0===e)r.__lexicalTextContent=i,r.__lexicalFirstTextKey=null,Ht+=i,n.size>0&&(r.__lexicalSlotTextLength=i.length);else{const t=Ht,s=e-1;if(ke(Yc(o,ne),o,0,s,kc(o,r,$t)),""!==i){const e=r.__lexicalTextContent||"";r.__lexicalTextContent=i+e,Ht=t+i+e}n.size>0&&(r.__lexicalSlotTextLength=i.length)}const s=o.__format;0!==s&&ge(r,s),o.isInline()||be(null,o,r)}else{const t=o.getTextContent();if(Ki(o)){const t=o.decorate($t,Wt);null!==t&&Oe(e,t),r.contentEditable="false";const n=xe(o);n.size>0&&me(o,r,n)}Ht+=t}return null!==n&&n.insertChild(r),se.$decorateDOM(o,null,r,$t),Bt(o),Sl(ie,Ut,Xt,o,"created"),r}function ke(e,n,o,r,i){const s=Ht,l=qt();Ht="",jt=null,Jt=null,Vt=null;let c=o;for(;c<=r;++c){const t=qt();Te(e[c],i);const n=ne.get(e[c]);null!==n&&Xo(n)?null===jt&&(jt=n.getFormat(),Jt=n.getStyle(),Vt=n.__key):Pi(n)&&c0?null:"empty"}return null}(e,ne);r!==i&&o.setManagedLineBreak(i)}function Ne(e,n,o){var r;jt=null,Jt=null,Vt=null,function(e,n,o){const r=Ht,i=e.__size,s=n.__size;Ht="";const l=o.element,c=$t._keyToDOMMap.get(n.__key);void 0===c&&t(351,n.__key);const a=s-i;if(!le&&Math.abs(a)<=1&&i>=Rt&&e.__first===n.__first&&(0!==a||!$t._cloneNotNeeded.has(e.__key))){const i=c.__lexicalTextContent,u=re.get(e.__key);if(!le&&"string"==typeof i&&void 0!==u){const s=function(t,e){const n=e.size;if(0===n||n>=t.__size)return null;let o=t.__last,r=null,i=0;for(;null!==o&&i0?i.slice(h):i,_=g.slice(0,g.length-e)+d;return c.__lexicalTextContent=_,Ht=r+_,void Ee(n,c,u)}if(function(e,n,o,r,i,s,l,c){if(1!==c&&-1!==c)return!1;const a=1===c?2:1;if(l!==a)return!1;const u=l-c;let f=e.__last;for(let t=0;t0?i.slice(k):i;return r.__lexicalTextContent=b.slice(0,b.length-v)+T,!0}(e,0,o,c,i,s,f,a)){const e=c.__lexicalTextContent;return"string"!=typeof e&&t(353),Ht=r+e,void Ee(n,c,u)}}}if(0===a){let n=e.__first,o=0;for(;null!==n;){const e=ne.get(n);if(void 0===e)break;const r=le||Zt.has(n)||Qt.has(n),i=qt();if(r)we(n,l);else{let o,r;if(Pi(e)){r=oe.get(n);const i=r&&r.__lexicalTextContent;"string"!=typeof i&&t(354,e.getType()),o=i}else o=e.getTextContent();Ht+=o,void 0!==r&&Gt(r)}Xo(e)?null===jt&&(jt=e.getFormat(),Jt=e.getStyle(),Vt=e.__key):Pi(e)&&os,g=d>l;if(h&&!g){const e=n[l+1],o=void 0===e?null:$t.getElementByKey(e);ke(n,t,d,l,i.withBefore(o??i.before))}else g&&!h&&ue(e,f,s,i.element)}(n,r,c,i,s,o)}c.__lexicalTextContent=Ht,c.__lexicalFirstTextKey=Vt,Ht=r+Ht}(e,n,kc(n,o,$t)),Bl(n)||(r=n,null==jt||jt===r.__textFormat||ce||r.setTextFormat(jt),function(t){null==Jt||Jt===t.__textStyle||ce||t.setTextStyle(Jt)}(n))}function Ee(t,e,n){const o=e.__lexicalFirstTextKey;if(null!=o){const e=t.__key;let r=o;for(;null!==r;){const t=ne.get(r);if(void 0===t){r=null;break}if(t.__parent===e)break;r=t.__parent}if(null!==r&&!n.has(r)){const t=ne.get(o);if(Xo(t))return jt=t.getFormat(),void(Jt=t.getStyle())}}e.__lexicalFirstTextKey=Vt}function we(e,n){const o=te.get(e);let r=ne.get(e);void 0!==o&&void 0!==r||t(61);const i=le||Zt.has(e)||Qt.has(e),s=El($t,e);if(o===r&&!i){let e;if(Pi(o)){const n=s.__lexicalTextContent;"string"!=typeof n&&t(355,o.getType()),e=n,Gt(s)}else e=o.getTextContent();return Ht+=e,s}if(o!==r&&i&&Sl(ie,Ut,Xt,r,"updated"),se.$updateDOM(r,o,s,$t)){const o=Te(e,null);return null===n&&t(62),n.replaceChild(o,s),ae(e,null),o}if(Pi(o)){Pi(r)||t(334,e);const n=r.__indent;(le||n!==o.__indent)&&he(s,n);const l=r.__format;(le||l!==o.__format)&&ge(s,l);const c=i&&(xe(r).size>0||xe(o).size>0)?ve(o,r,s):"";if(i){const t=Ht;if(Ne(o,r,s),Bi(r)||r.isInline()||be(0,r,s),""!==c){const e=s.__lexicalTextContent||"";s.__lexicalTextContent=c+e,Ht=t+c+e,s.__lexicalSlotTextLength=c.length}else(xe(r).size>0||xe(o).size>0)&&(s.__lexicalSlotTextLength=0)}else{const e=s.__lexicalTextContent;"string"!=typeof e&&t(356,o.getType()),Ht+=e,Gt(s)}if((le||r.__dir!==o.__dir||r.__parent!==o.__parent)&&(_e(s,r),Bi(r)&&!le))for(const t of r.getChildren())if(Pi(t)){_e(El($t,t.getKey()),t)}}else{const t=r.getTextContent();if(Ki(r)){const t=r.decorate($t,Wt);null!==t&&Oe(e,t),i&&(xe(r).size>0||xe(o).size>0)&&ve(o,r,s)}Ht+=t}if(!ce&&Bi(r)){const t=r.getLatest();if(t.__cachedText!==Ht){const e=t.getWritable();e.__cachedText=Ht,r=e}}return se.$decorateDOM(r,o,s,$t),Bt(r),s}function Oe(t,e){let n=$t._pendingDecorators;const o=$t._decorators;if(null===n){if(o[t]===e)return;n=tl($t)}n[t]=e}function Me(t){let e=t.nextSibling;return null!==e&&e===$t._blockCursorElement&&(e=e.nextSibling),e}function Ae(t,e){const n=new Set;for(let o=e;o{for(const n of e){const e=ne.get(n);if(void 0===e)continue;const o=e.__parent;if(null===o)continue;let r=t.get(o);void 0===r&&(r=new Set,t.set(o,r)),r.add(n)}};return e(Qt.keys()),e(Zt),t}();const s=new Map;return ie=s,we("root",null),$t=void 0,Ut=void 0,Qt=void 0,Zt=void 0,te=void 0,ee=void 0,ne=void 0,Wt=void 0,oe=void 0,re=void 0,ie=void 0,se=ps,s}function Fe(e){const n=oe.get(e);return void 0===n&&t(75,e),n} +-/*@__INLINE__*/function Pe(t){return{type:t}}const Ie=/* @__PURE__ */Pe("SELECTION_CHANGE_COMMAND"),Le=/* @__PURE__ */Pe("SELECTION_INSERT_CLIPBOARD_NODES_COMMAND"),Ke=/* @__PURE__ */Pe("CLICK_COMMAND"),ze=/* @__PURE__ */Pe("BEFORE_INPUT_COMMAND"),Be=/* @__PURE__ */Pe("INPUT_COMMAND"),Re=/* @__PURE__ */Pe("COMPOSITION_START_COMMAND"),We=/* @__PURE__ */Pe("COMPOSITION_END_COMMAND"),$e=/* @__PURE__ */Pe("DELETE_CHARACTER_COMMAND"),Ue=/* @__PURE__ */Pe("INSERT_LINE_BREAK_COMMAND"),He=/* @__PURE__ */Pe("INSERT_PARAGRAPH_COMMAND"),je=/* @__PURE__ */Pe("CONTROLLED_TEXT_INSERTION_COMMAND"),Je=/* @__PURE__ */Pe("PASTE_COMMAND"),Ve=/* @__PURE__ */Pe("REMOVE_TEXT_COMMAND"),qe=/* @__PURE__ */Pe("DELETE_WORD_COMMAND"),Ye=/* @__PURE__ */Pe("DELETE_LINE_COMMAND"),Ge=/* @__PURE__ */Pe("FORMAT_TEXT_COMMAND"),Xe=/* @__PURE__ */Pe("SET_TEXT_FORMAT_COMMAND"),Qe=/* @__PURE__ */Pe("UNDO_COMMAND"),Ze=/* @__PURE__ */Pe("REDO_COMMAND"),tn=/* @__PURE__ */Pe("KEYDOWN_COMMAND"),en=/* @__PURE__ */Pe("KEY_ARROW_RIGHT_COMMAND"),nn=/* @__PURE__ */Pe("MOVE_TO_END"),on=/* @__PURE__ */Pe("KEY_ARROW_LEFT_COMMAND"),rn=/* @__PURE__ */Pe("MOVE_TO_START"),sn=/* @__PURE__ */Pe("KEY_ARROW_UP_COMMAND"),ln=/* @__PURE__ */Pe("KEY_ARROW_DOWN_COMMAND"),cn=/* @__PURE__ */Pe("KEY_ENTER_COMMAND"),an=/* @__PURE__ */Pe("KEY_SPACE_COMMAND"),un=/* @__PURE__ */Pe("KEY_BACKSPACE_COMMAND"),fn=/* @__PURE__ */Pe("KEY_ESCAPE_COMMAND"),dn=/* @__PURE__ */Pe("KEY_DELETE_COMMAND"),hn=/* @__PURE__ */Pe("KEY_TAB_COMMAND"),gn=/* @__PURE__ */Pe("INSERT_TAB_COMMAND"),_n=/* @__PURE__ */Pe("INDENT_CONTENT_COMMAND"),pn=/* @__PURE__ */Pe("OUTDENT_CONTENT_COMMAND"),yn=/* @__PURE__ */Pe("DROP_COMMAND"),mn=/* @__PURE__ */Pe("FORMAT_ELEMENT_COMMAND"),xn=/* @__PURE__ */Pe("DRAGSTART_COMMAND"),Cn=/* @__PURE__ */Pe("DRAGOVER_COMMAND"),Sn=/* @__PURE__ */Pe("DRAGEND_COMMAND"),vn=/* @__PURE__ */Pe("COPY_COMMAND"),Tn=/* @__PURE__ */Pe("CUT_COMMAND"),kn=/* @__PURE__ */Pe("SELECT_ALL_COMMAND"),bn=/* @__PURE__ */Pe("CLEAR_EDITOR_COMMAND"),Nn=/* @__PURE__ */Pe("CLEAR_HISTORY_COMMAND"),En=/* @__PURE__ */Pe("CAN_REDO_COMMAND"),wn=/* @__PURE__ */Pe("CAN_UNDO_COMMAND"),On=/* @__PURE__ */Pe("FOCUS_COMMAND"),Mn=/* @__PURE__ */Pe("BLUR_COMMAND"),An=/* @__PURE__ */Pe("KEY_MODIFIER_COMMAND");function Dn(t){const e=new Map;return{dispose(){for(const t of e.values())t.dispose();e.clear()},register(n,o){let r=e.get(n);void 0===r&&(r={dispose:t(n,o),holders:new Set},e.set(n,r));const i=()=>{const t=e.get(n);t&&t.holders.delete(i)&&0===t.holders.size&&(e.delete(n),t.dispose())};return r.holders.add(i),i}}}function Fn(t,e,n,o){return t.addEventListener(e,n,o),t.removeEventListener.bind(t,e,n,o)}const Pn=Object.freeze({}),In=[["keydown",function(t,e){const n=e._inputState;n.lastKeyDownTimeStamp=t.timeStamp,n.lastKeyCode=t.key,"Backspace"!==t.key&&Jn(n);if(e.isComposing())return;Nl(e,tn,t)}],["pointerdown",function(t,e){const n=ac(t),o=t.pointerType;_c(n)&&"touch"!==o&&"pen"!==o&&0===t.button&&Ai(e,()=>{Rc(n,e)||(e._inputState.isSelectionChangeFromMouseDown=!0)})}],["compositionstart",function(t,e){Nl(e,Re,t)}],["compositionend",function(t,e){const n=e._inputState;i?n.compositionPhase="ending-firefox":l||!a&&!d?Nl(e,We,t):(n.compositionPhase="ending-safari",n.compositionEndData=t.data)}],["input",function(t,e){t.stopPropagation();const n=e._inputState;Jn(n),Ai(e,()=>{qn(t,e)||e.dispatchCommand(Be,t)},{event:t}),n.unprocessedBeforeInputData=null}],["click",function(t,e){Ai(e,()=>{const n=Kr(),o=Jl(Il(e)),r=zr();if(o)if(ur(n)){const t=n.anchor,e=t.getNode();"element"===t.type&&0===t.offset&&n.isCollapsed()&&!Bi(e)&&1===nl().getChildrenSize()&&e.getTopLevelElementOrThrow().isEmpty()&&null!==r&&n.is(r)&&(o.removeAllRanges(),n.dirty=!0)}else if("touch"===t.pointerType||"pen"===t.pointerType){const n=nc(o,e._rootElement).anchorNode;if(gc(n)||zs(n)){ol(Lr(r,o,e,t))}}if(i&&null!==o&&0===o.rangeCount){const n=e._rootElement;if(null!==n&&t.target===n){const i=t.clientY;let s=n.childNodes.length;for(let t=0;tfunction(t,e){const n=t.inputType;if("deleteCompositionText"===n||i&&bl(e))return;if("insertCompositionText"===n)return;Ai(e,()=>{qn(t,e)||Nl(e,ze,t)},{event:t})}(t,e)]);const Ln=new WeakMap,Kn=new WeakMap,zn=Dn(t=>(t.addEventListener("selectionchange",ro),()=>t.removeEventListener("selectionchange",ro)));function Bn(t,e,n,o,r,i){const l=t.anchor,c=t.focus,a=l.getNode(),u=_i();let f;if(void 0!==i)f=i;else{const t=Jl(Il(u));f=null!==t?nc(t,u._rootElement):null}const d=null!==f?f.anchorNode:null,h=l.key,g=u.getElementByKey(h),_=n.length;return h!==c.key||!Xo(a)||(!r&&(!s||u._inputState.lastBeforeInputInsertTextTimeStamp1||(r||!s)&&null!==g&&!a.isComposing()&&d!==wc(a,g,u)||null!==f&&null!==e&&(!e.collapsed||e.startContainer!==f.anchorNode||e.startOffset!==f.anchorOffset)||!a.isComposing()&&(a.getFormat()!==t.format||a.getStyle()!==t.style)||function(t,e){if(e.isSegmented())return!0;if(!t.isCollapsed())return!1;const n=t.anchor.offset,o=e.getParentOrThrow(),r=Ls(e);return 0===n?!e.canInsertTextBefore()||!o.canInsertTextBefore()&&!e.isComposing()||r||function(t){const e=t.getPreviousSibling();return(Xo(e)||Pi(e)&&e.isInline())&&!e.canInsertTextAfter()}(e):n===e.getTextContentSize()&&(!e.canInsertTextAfter()||!o.canInsertTextAfter()&&!e.isComposing()||r)}(t,a)}function Rn(t,e){return zs(t)&&null!==t.nodeValue&&0!==e&&e!==t.nodeValue.length}function Wn(e,n,o){const{anchorNode:r,anchorOffset:i,focusNode:s,focusOffset:l}=nc(e,n._rootElement),c=n._inputState;c.isSelectionChangeFromDOMUpdate&&(c.isSelectionChangeFromDOMUpdate=!1,Rn(r,i)&&Rn(s,l)&&!c.postDeleteSelectionToRestore)||Ai(n,()=>{if(!o)return void ol(null);if(!As(n,r,s))return;let a=Kr();if(c.postDeleteSelectionToRestore&&ur(a)&&a.isCollapsed()){const t=a.anchor,e=c.postDeleteSelectionToRestore.anchor;(t.key===e.key&&t.offset===e.offset+1||1===t.offset&&e.getNode().is(t.getNode().getPreviousSibling()))&&(a=c.postDeleteSelectionToRestore.clone(),ol(a))}if(c.postDeleteSelectionToRestore=null,ur(a)){const o=a.anchor,u=o.getNode();if(a.isCollapsed()){"Range"===e.type&&r===s&&(a.dirty=!0);const i=Il(n).event,l=i?i.timeStamp:performance.now(),{format:f,style:d,offset:h,key:g,timeStamp:_}=c.collapsedSelectionFormat,p=nl(),y=!1===n.isComposing()&&""===p.getTextContent();if(l<_+200&&o.offset===h&&o.key===g)$n(a,f,d);else if("text"===o.type)Xo(u)||t(141),Un(a,u);else if("element"===o.type&&!y){Pi(u)||t(259);const e=o.getNode();e.isEmpty()?function(t,e){const n=e.getTextFormat(),o=e.getTextStyle();$n(t,n,o)}(a,e):$n(a,a.format,"")}}else{const t=o.key,e=a.focus.key,n=a.getNodes(),r=n.length,s=a.isBackward(),c=s?l:i,u=s?i:l,f=s?e:t,d=s?t:e;let h=2047,g=!1;for(let t=0;tJn(t),0)}function qn(t,e){const n=ac(t);if(gc(n)&&Rc(n,e))return!0;const o=e.getRootElement();if(null===o)return!1;const r=cc(o.ownerDocument);return null!==r&&o.contains(r)&&Rc(r,e)}function Yn(e){const n=e.inputType,o=Hn(e),r=_i(),i=r._inputState,s=Kr();if("insertText"===n&&e.data&&i.isInsertTextAfterHandledSelectionCommand){if(Jn(i),e.preventDefault(),ur(s)&&!s.isCollapsed()){const t=s.isBackward()?s.anchor:s.focus;s.anchor.set(t.key,t.offset,t.type),s.focus.set(t.key,t.offset,t.type)}return!0}if("deleteContentBackward"===n){if(null===s){const t=zr();if(!ur(t))return!0;ol(t.clone())}if(ur(s)){const n=s.anchor.key===s.focus.key;if(function(t,e){return"MediaLast"===t.lastKeyCode&&e{Ai(r,()=>{Vs(null)})},30),ur(s)){const e=s.anchor.getNode();e.markDirty(),Xo(e)||t(142),Un(s,e)}}else{if(Vs(null),l&&null!==o&&!o.collapsed&&(s.applyDOMRange(o),!s.isCollapsed()))return e.preventDefault(),s.removeText(),!0;e.preventDefault();const t=s.anchor.getNode(),c=t.getTextContent(),a=t.canInsertTextAfter(),u=0===s.anchor.offset&&s.focus.offset===c.length;let d=f&&n&&!u&&a;if(d&&s.isCollapsed()&&(d=!Ki(kl(s.anchor,!0))),!d){Nl(r,$e,!0);const t=Kr();f&&ur(t)&&t.isCollapsed()&&(i.postDeleteSelectionToRestore=t,setTimeout(()=>i.postDeleteSelectionToRestore=null))}}return!0}}if(!ur(s))return!0;const c=e.data;null!==i.unprocessedBeforeInputData&&ul(!1,r,i.unprocessedBeforeInputData),s.dirty&&null===i.unprocessedBeforeInputData||!s.isCollapsed()||Bi(s.anchor.getNode())||null===o||s.applyDOMRange(o),i.unprocessedBeforeInputData=null;const a=s.anchor,u=s.focus,d=a.getNode(),h=u.getNode();if("insertText"===n||"insertTranspose"===n){if("\n"===c)e.preventDefault(),Nl(r,Ue,!1);else if(c===D)e.preventDefault(),Nl(r,He);else if(null==c&&e.dataTransfer){const t=e.dataTransfer.getData("text/plain");e.preventDefault(),s.insertRawText(t)}else null!=c&&Bn(s,o,c,e.timeStamp,!0)?(e.preventDefault(),Nl(r,je,c),jn(c)):i.unprocessedBeforeInputData=c;return i.lastBeforeInputInsertTextTimeStamp=e.timeStamp,!0}switch(e.preventDefault(),n){case"insertFromYank":case"insertFromDrop":case"insertReplacementText":Nl(r,je,e);jn((e.dataTransfer?e.dataTransfer.getData("text/plain"):null)??e.data);break;case"insertFromComposition":{const t=i.hadOrphanedCompositionEvents;i.hadOrphanedCompositionEvents=!1;const n=r._compositionKey;Vs(null),t||Nl(r,je,e),Zn(n);break}case"insertLineBreak":Vs(null),Nl(r,Ue,!1);break;case"insertParagraph":Vs(null),i.isInsertLineBreak&&!l?(i.isInsertLineBreak=!1,Nl(r,Ue,!1)):Nl(r,He);break;case"insertFromPaste":case"insertFromPasteAsQuotation":Nl(r,Je,e);break;case"deleteByComposition":(function(t,e){return t!==e||Pi(t)||Pi(e)||!Ls(t)||!Ls(e)})(d,h)&&Nl(r,Ve,e);break;case"deleteByDrag":Al(No),Nl(r,Ve,e);break;case"deleteByCut":Nl(r,Ve,e);break;case"deleteContent":Nl(r,$e,!1);break;case"deleteWordBackward":Nl(r,qe,!0);break;case"deleteWordForward":Nl(r,qe,!1);break;case"deleteHardLineBackward":case"deleteSoftLineBackward":Nl(r,Ye,!0);break;case"deleteContentForward":case"deleteHardLineForward":case"deleteSoftLineForward":Nl(r,Ye,!1);break;case"formatStrikeThrough":Nl(r,Ge,"strikethrough");break;case"formatBold":Nl(r,Ge,"bold");break;case"formatItalic":Nl(r,Ge,"italic");break;case"formatUnderline":Nl(r,Ge,"underline");break;case"historyUndo":Nl(r,Qe);break;case"historyRedo":Nl(r,Ze)}return!0}function Gn(t){const e=_i(),n=e._inputState,o=Kr(),r=t.data,l=Hn(t);let c=!1;if(null!=r&&ur(o)){const a=Jl(Il(e)),u=null!==a?nc(a,e._rootElement):null,d="insertCompositionText"===t.inputType&&"ending-firefox"!==n.compositionPhase&&!e.isComposing();d&&(n.hadOrphanedCompositionEvents=!0);const h=o.anchor.getNode(),g="insertCompositionText"===t.inputType&&"ending-firefox"!==n.compositionPhase&&e.isComposing()&&Xo(h)&&Ks(h);if(!d&&!g&&Bn(o,l,r,t.timeStamp,!1,u)){if(c=!0,"ending-firefox"===n.compositionPhase){const t=to(e,r);if(n.compositionPhase="idle",t)return Al(wo),rl(),!0}const l=o.anchor.getNode();if(null===a||null===u)return!0;const d=o.isBackward(),h=d?o.anchor.offset:o.focus.offset,g=d?o.focus.offset:o.anchor.offset;s&&!o.isCollapsed()&&Xo(l)&&null!==u.anchorNode&&l.getTextContent().slice(0,h)+r+l.getTextContent().slice(h+g)===al(u.anchorNode)||Nl(e,je,r);const _=r.length;i&&_>1&&"insertCompositionText"===t.inputType&&!e.isComposing()&&(o.anchor.offset-=_,o._cachedNodes=null,o._cachedIsBackward=null),f&&e.isComposing()&&(n.lastKeyDownTimeStamp=0,Vs(null))}}if(!c){ul(!1,e,null!==r?r:void 0),"ending-firefox"===n.compositionPhase&&(to(e,r||void 0),Al(wo),n.compositionPhase="idle")}return rl(),!0}function Xn(t){const e=_i(),n=e._inputState,o=Kr();if(ur(o)&&!e.isComposing()){n.compositionPhase="composing",n.hadOrphanedCompositionEvents=!1;const r=o.anchor,i=o.anchor.getNode();if(Vs(r.key),Al(Eo),t.timeStamp{to(e,n.compositionEndData)}),n.compositionPhase="idle",n.compositionEndData="",o)return!0}if(function(t){return _l(t,"ArrowRight",{shiftKey:"any"})}(t))Nl(e,en,t);else if(function(t){return _l(t,"ArrowRight",{...pl,shiftKey:"any"})}(t))Nl(e,nn,t);else if(function(t){return _l(t,"ArrowLeft",{shiftKey:"any"})}(t))Nl(e,on,t);else if(function(t){return _l(t,"ArrowLeft",{...pl,shiftKey:"any"})}(t))Nl(e,rn,t);else if(function(t){return _l(t,"ArrowUp",{altKey:"any",shiftKey:"any"})}(t))Nl(e,sn,t);else if(function(t){return _l(t,"ArrowDown",{altKey:"any",shiftKey:"any"})}(t))Nl(e,ln,t);else if(function(t){return _l(t,"Enter",{altKey:"any",ctrlKey:"any",metaKey:"any",shiftKey:!0})}(t))n.isInsertLineBreak=!0,Nl(e,cn,t);else if(function(t){return" "===t.key}(t))Nl(e,an,t);else if(function(t){return r&&_l(t,"o",{ctrlKey:!0})}(t))t.preventDefault(),n.isInsertLineBreak=!0,Nl(e,Ue,!0);else if(function(t){return _l(t,"Enter",{altKey:"any",ctrlKey:"any",metaKey:"any"})}(t))n.isInsertLineBreak=!1,Nl(e,cn,t);else if(function(t){return _l(t,"Backspace",{shiftKey:"any"})||r&&_l(t,"h",{ctrlKey:!0})}(t))ml(t)?Nl(e,un,t)&&Vn(n):(t.preventDefault(),Nl(e,$e,!0));else if(function(t){return"Escape"===t.key}(t))Nl(e,fn,t);else if(function(t){return _l(t,"Delete",{})||r&&_l(t,"d",{ctrlKey:!0})}(t))!function(t){return"Delete"===t.key}(t)?(t.preventDefault(),Nl(e,$e,!1)):Nl(e,dn,t);else if(function(t){return _l(t,"Backspace",yl)}(t))t.preventDefault(),Nl(e,qe,!0);else if(function(t){return _l(t,"Delete",yl)}(t))t.preventDefault(),Nl(e,qe,!1);else if(function(t){return r&&_l(t,"Backspace",{metaKey:!0})}(t))t.preventDefault(),Nl(e,Ye,!0);else if(function(t){return r&&(_l(t,"Delete",{metaKey:!0})||_l(t,"k",{ctrlKey:!0}))}(t))t.preventDefault(),Nl(e,Ye,!1);else if(function(t){return _l(t,"b",pl)}(t))t.preventDefault(),Nl(e,Ge,"bold");else if(function(t){return _l(t,"u",pl)}(t))t.preventDefault(),Nl(e,Ge,"underline");else if(function(t){return _l(t,"i",pl)}(t))t.preventDefault(),Nl(e,Ge,"italic");else if(function(t){return _l(t,"Tab",{shiftKey:"any"})}(t))Nl(e,hn,t);else if(function(t){return _l(t,"z",pl)}(t))t.preventDefault(),Nl(e,Qe);else if(function(t){if(r)return _l(t,"z",{metaKey:!0,shiftKey:!0});return _l(t,"y",{ctrlKey:!0})||_l(t,"z",{ctrlKey:!0,shiftKey:!0})}(t))t.preventDefault(),Nl(e,Ze);else{const o=e._editorState._selection;!function(t){return _l(t,"a",pl)}(t)?null===o||ur(o)||(!function(t){return _l(t,"c",pl)}(t)?function(t){return _l(t,"x",pl)}(t)&&(t.preventDefault(),Nl(e,Tn,t)):(t.preventDefault(),Nl(e,vn,t))):(t.preventDefault(),Nl(e,kn,t)&&Vn(n))}return function(t){return t.ctrlKey||t.shiftKey||t.altKey||t.metaKey}(t)&&e.dispatchCommand(An,t),!0}function no(t){let e=t.__lexicalEventHandles;return void 0===e&&(e=[],t.__lexicalEventHandles=e),e}const oo=new Map;function ro(t){const e=Vl(t.target);if(null===e)return;const n=Ol(t.target);let o=null,r=null;const i=null!==n?Kn.get(n):void 0;if(null!==n){if(void 0!==i){const t=i.editors;let n=i.hasShadowEditor;if(void 0===n){n=!1;for(const e of t)if(null!==e._rootElement&&ql(e._rootElement.getRootNode())){n=!0;break}i.hasShadowEditor=n}if(n){let n=null,i=null;for(const s of t){const t=s._rootElement;if(null===t)continue;const l=nc(e,t).anchorNode;if(null!==l&&Fs(l)===s){if(ql(t.getRootNode())){o=s,r=l;break}null===n&&(n=s,i=l)}}null===o&&null!==n&&(o=n,r=i)}else{const t=e.anchorNode;null===t||gc(t)&&null!==t.shadowRoot||(o=Fs(t),null!==o&&(r=t))}}if(null===o){const t=cc(n);o=null!==t?Fs(t):null}}if(null===o)return;if(o._inputState.isSelectionChangeFromMouseDown){if(void 0!==i)for(const t of i.editors)t._inputState.isSelectionChangeFromMouseDown=!1;Ai(o,()=>{const n=zr(),i=r??nc(e,o._rootElement).anchorNode;if(gc(i)||zs(i)){ol(Lr(n,e,o,t))}})}const s=ll(o),l=s[s.length-1],c=l._key,a=oo.get(c),u=a||l;u!==o&&Wn(e,u,!1),Wn(e,o,!0),o!==l?oo.set(c,o):a&&oo.delete(c)}function io(t){t._lexicalHandled=!0}function so(t){return!0===t._lexicalHandled}const lo=()=>{};function co(e){const n=Ln.get(e);if(void 0===n)return void lo();const o=Kn.get(n);if(void 0===o)return void lo();Ln.delete(e);const r=Ps(e);Ds(r)?(!function(t){if(null!==t._parentEditor){const e=ll(t),n=e[e.length-1]._key;oo.get(n)===t&&oo.delete(n)}else oo.delete(t._key)}(r),o.editors.delete(r),o.hasShadowEditor=void 0,e.__lexicalEditor=null):r&&t(198);const i=no(e);for(let t=0;tt.__key===this.__key);if(Xo(this))return n;if(ur(e)&&"element"===e.anchor.type&&"element"===e.focus.type){if(e.isCollapsed())return!1;const t=this.getParent();if(Ki(this)&&this.isInline()&&t){const n=e.isBackward()?e.focus:e.anchor;if(t.is(n.getNode())&&n.offset===t.getChildrenSize()&&this.is(t.getLastChild()))return!1}}return n}getKey(){return this.__key}getIndexWithinParent(){const t=this.getParent();if(null===t)return-1;let e=t.getFirstChild(),n=0;for(;null!==e;){if(this.is(e))return n;n++,e=e.getNextSibling()}return-1}getParent(){const t=this.getLatest().__parent;return null===t?null:Ys(t)}getParentOrThrow(){const e=this.getParent();return null===e&&t(66,this.__key),e}getTopLevelElement(){let e=this;for(;null!==e;){const n=e.getParent();if(Bl(n)||null!==ta(e))return Pi(e)||e===this&&Ki(e)||t(194),e;e=n}return null}getTopLevelElementOrThrow(){const e=this.getTopLevelElement();return null===e&&t(67,this.__key),e}getParents(){const t=[];let e=this.getParent();for(;null!==e;)t.push(e),e=e.getParent();return t}getParentKeys(){const t=[];let e=this.getParent();for(;null!==e;)t.push(e.__key),e=e.getParent();return t}getPreviousSibling(){const t=this.getLatest().__prev;return null===t?null:Ys(t)}getPreviousSiblings(){const t=[],e=this.getParent();if(null===e)return t;let n=e.getFirstChild();for(;null!==n&&!n.is(this);)t.push(n),n=n.getNextSibling();return t}getNextSibling(){const t=this.getLatest().__next;return null===t?null:Ys(t)}getNextSiblings(){const t=[];let e=this.getNextSibling();for(;null!==e;)t.push(e),e=e.getNextSibling();return t}getCommonAncestor(t){const e=Pi(this)?this:this.getParent(),n=Pi(t)?t:t.getParent(),o=e&&n?Za(e,n):null;return o?o.commonAncestor:null}is(t){return null!=t&&this.__key===t.__key}isBefore(e){const n=Za(this,e);return null!==n&&("descendant"===n.type||("branch"===n.type?-1===Ga(n):("same"!==n.type&&"ancestor"!==n.type&&t(279),!1)))}isParentOf(t){return Fl(t,this)}getNodesBetween(e){const n=this.isBefore(e),o=[],r=new Set;let i=this;for(;null!==i;){const s=i.__key;if(r.has(s)||(r.add(s),o.push(i)),i===e)break;const l=Pi(i)?n?i.getFirstChild():i.getLastChild():null;if(null!==l){i=l;continue}const c=n?i.getNextSibling():i.getPreviousSibling();if(null!==c){i=c;continue}const a=i.getParentOrThrow();if(r.has(a.__key)||o.push(a),a===e)break;let u=null,f=a;do{if(null===f&&t(68),u=n?f.getNextSibling():f.getPreviousSibling(),f=f.getParent(),null===f)break;null!==u||r.has(f.__key)||o.push(f)}while(null===u);i=u}return n||o.reverse(),o}isDirty(){const t=_i()._dirtyLeaves;return null!==t&&t.has(this.__key)}getLatest(){if(ho(this))return this;const e=Ys(this.__key);return null===e&&t(113),e}getWritable(){if(ho(this))return this;fi();const t=hi(),e=_i(),n=t._nodeMap,o=this.__key,r=this.getLatest(),i=e._cloneNotNeeded,s=Kr();if(null!==s&&s.setCachedNodes(null),i.has(o))return Js(r),r;const l=Dc(r);return i.add(o),Js(l),n.set(o,l),l}getTextContent(){return ha(this)}getTextContentSize(){return this.getTextContent().length}createDOM(e,n){t(70)}updateDOM(e,n,o){t(71)}getDOMSlot(t){return new q(t)}exportDOM(t){return{element:this.createDOM(t._config,t)}}exportJSON(){const t=this.__state?this.__state.toJSON():void 0;return{type:this.__type,version:1,...t}}static importJSON(e){t(18,this.name)}updateFromJSON(t){return function(t,e){const n=t.getWritable(),o=e.$;let r=o;for(const t of Nt(n).flatKeys)t in e&&(void 0!==r&&r!==o||(r={...o}),r[t]=e[t]);return(n.__state||r)&&bt(t).updateFromJSON(r),n}(this,t)}static transform(){return null}remove(t){ao(this,!0,t)}replace(e,n){fi();let o=Kr();null!==o&&(o=o.clone()),$l(this,e);const r=this.getLatest(),i=this.__key,s=e.__key,l=e.getWritable(),c=this.getParentOrThrow().getWritable(),a=c.__size,u=l.getParent(),f=null!==u?l.getIndexWithinParent():-1;Hs(l),null!==u&&ur(o)&&Br(o,u,f,-1);const d=r.getPreviousSibling(),h=r.getNextSibling(),g=r.__prev,_=r.__next,p=r.__parent;if(ao(r,!1,!0),null===d)c.__first=s;else{d.getWritable().__next=s}if(l.__prev=g,null===h)c.__last=s;else{h.getWritable().__prev=s}l.__next=_,l.__parent=p,c.__size=a;let y=0;n&&(Pi(this)&&Pi(l)||t(139),y=l.getChildrenSize(),l.splice(y,0,this.getChildren()));const m=ia(this);if(m.length>0){Qc(this)&&Qc(l)||t(368,this.__key,l.__key);for(const t of m){const e=sa(this,t);null!==e&&(ya(this,t),pa(l,t,e))}}if(ur(o)){ol(o);const t=o.anchor,e=o.focus;t.key===i&&(n&&"element"===t.type?t.set(l.__key,y+t.offset,"element"):ir(t,l)),e.key===i&&(n&&"element"===e.type?e.set(l.__key,y+e.offset,"element"):ir(e,l))}return qs()===i&&Vs(s),l}insertAfter(t,e=!0){fi(),$l(this,t);const n=this.getWritable(),o=t.getWritable();ma(this.getParentOrThrow());const r=o.getParent(),i=Kr();let s=!1,l=!1;if(null!==r){const n=t.getIndexWithinParent();if(ur(i)){const t=r.__key,e=i.anchor,o=i.focus;s="element"===e.type&&e.key===t&&e.offset===n+1,l="element"===o.type&&o.key===t&&o.offset===n+1}Hs(o),e&&ur(i)&&Br(i,r,n,-1)}else Hs(o);const c=this.getNextSibling(),a=this.getParentOrThrow().getWritable(),u=o.__key,f=n.__next;if(null===c)a.__last=u;else{c.getWritable().__prev=u}if(a.__size++,n.__next=u,o.__next=f,o.__prev=n.__key,o.__parent=n.__parent,e&&ur(i)){const t=this.getIndexWithinParent();Br(i,a,t+1);const e=a.__key;s&&i.anchor.set(e,t+2,"element"),l&&i.focus.set(e,t+2,"element")}return t}insertBefore(t,e=!0){fi(),$l(this,t);const n=this.getWritable(),o=t.getWritable();ma(this.getParentOrThrow());const r=o.__key,i=Kr(),s=o.getParent(),l=null!==s?o.getIndexWithinParent():-1;Hs(o),null!==s&&e&&ur(i)&&Br(i,s,l,-1);const c=this.getPreviousSibling(),a=this.getParentOrThrow().getWritable(),u=n.__prev,f=this.getIndexWithinParent();if(null===c)a.__first=r;else{c.getWritable().__next=r}if(a.__size++,n.__prev=r,o.__prev=u,o.__next=n.__key,o.__parent=n.__parent,e&&ur(i)){Br(i,this.getParentOrThrow(),f)}return t}isParentRequired(){return!1}createParentElementNode(){return es()}selectStart(){return this.selectPrevious()}selectEnd(){return this.selectNext(0,0)}selectPrevious(t,e){fi();const n=ea(this);if(null!==n)return n.selectPrevious(t,e);const o=this.getPreviousSibling(),r=this.getParentOrThrow();if(null===o)return r.select(0,0);if(Pi(o))return o.select();if(!Xo(o)){const t=o.getIndexWithinParent()+1;return r.select(t,t)}return o.select(t,e)}selectNext(t,e){fi();const n=ea(this);if(null!==n)return n.selectNext(t,e);const o=this.getNextSibling(),r=this.getParentOrThrow();if(null===o)return r.select();if(Pi(o))return o.select(0,0);if(!Xo(o)){const t=o.getIndexWithinParent();return r.select(t,t)}return o.select(t,e)}markDirty(){this.getWritable()}reconcileObservedMutation(t,e){this.markDirty()}}function po(t){return t instanceof _o}const yo="historic",mo="history-push",xo="history-merge",Co="paste",So="cut",vo="collaboration",To="skip-collab",ko="skip-scroll-into-view",bo="skip-dom-selection",No="skip-selection-focus",Eo="composition-start",wo="composition-end",Oo="!important";function Mo(t){const e={};if(!t)return e;let n="",o="",r=null,i=!1,s=!1,l=!1,c=0;const a=t.length;let u=-1;for(let f=0;f=0&&o.slice(r).toLowerCase()===Oo?t.setProperty(e,o.slice(0,r).trim(),"important"):t.setProperty(e,n,"")}function Do(t,e){for(const n in e){const o=e[n];null==o?t.removeProperty(n):Ao(t,n,o)}}function Fo(t,e,n=""){if(e===n)return;const o=Mo(n),r=Mo(e);for(const e in r)delete o[e],Ao(t,e,r[e]);for(const e in o)t.removeProperty(e)}function Po(t,e){return 16&e?"code":e&T?"mark":32&e?"sub":64&e?"sup":null}function Io(t,e){return 1&e?"strong":2&e?"em":"span"}function Lo(t,e,n,o,r){const i=o.classList;let s=Cl(r,"base");void 0!==s&&i.add(...s),s=Cl(r,"underlineStrikethrough");let l=!1;const c=8&e&&4&e;void 0!==s&&(8&n&&4&n?(l=!0,c||i.add(...s)):c&&i.remove(...s));for(const t in z){const o=z[t];if(s=Cl(r,t),void 0!==s)if(n&o){if(l&&("underline"===t||"strikethrough"===t)){e&o&&i.remove(...s);continue}(0===(e&o)||c&&"underline"===t||"strikethrough"===t)&&i.add(...s)}else e&o&&i.remove(...s)}}function Ko(t,e,n){const o=n.isComposing(),r=t+(o?A:""),s=vc(),l=Tc(s).$getDOMSlot(n,e,s),c=l.getFirstChild();if(null===c||c.nodeType!==Node.TEXT_NODE)return void l.insertChild(Zl().createTextNode(r));const a=c,u=a.nodeValue;if(u!==r)if(o||i){const[t,e,n]=function(t,e){const n=t.length,o=e.length;let r=0,i=0;for(;r({conversion:Jo,priority:0}),b:()=>({conversion:Uo,priority:0}),code:()=>({conversion:Yo,priority:0}),em:()=>({conversion:Yo,priority:0}),i:()=>({conversion:Yo,priority:0}),mark:()=>({conversion:Yo,priority:0}),s:()=>({conversion:Yo,priority:0}),span:()=>({conversion:$o,priority:0}),strong:()=>({conversion:Yo,priority:0}),sub:()=>({conversion:Yo,priority:0}),sup:()=>({conversion:Yo,priority:0}),u:()=>({conversion:Yo,priority:0})}})}afterCloneFrom(t){super.afterCloneFrom(t),this.__text=t.__text,this.__format=t.__format,this.__style=t.__style,this.__mode=t.__mode,this.__detail=t.__detail}constructor(t="",e){super(e),this.__text=t,this.__format=0,this.__style="",this.__mode=0,this.__detail=0}getFormat(){return this.getLatest().__format}getDetail(){return this.getLatest().__detail}getMode(){const t=this.getLatest();return U[t.__mode]}getStyle(){return this.getLatest().__style}isToken(){return 1===this.getLatest().__mode}isComposing(){return this.__key===qs()}isSegmented(){return 2===this.getLatest().__mode}isDirectionless(){return!!(1&this.getLatest().__detail)}isUnmergeable(){return!!(2&this.getLatest().__detail)}hasFormat(t){const e=z[t];return 0!==(this.getFormat()&e)}isSimpleText(){return"text"===this.__type&&0===this.__mode}getTextContent(){return this.getLatest().__text}getFormatFlags(t,e){return Ws(this.getLatest().__format,t,e)}canHaveFormat(){return!0}isInline(){return!0}createDOM(t,e){const n=this.__format,o=Po(0,n),r=Io(0,n),i=null===o?r:o,s=Zl().createElement(i);let l=s;this.hasFormat("code")&&s.setAttribute("spellcheck","false"),null!==o&&(l=Zl().createElement(r),s.appendChild(l));zo(l,this,0,n,this.__text,t);const c=this.__style;return""!==c&&Fo(s.style,c),s}updateDOM(e,n,o){const r=this.__text,i=e.__format,s=this.__format,l=Po(0,i),c=Po(0,s),a=Io(0,i),u=Io(0,s);if((null===l?a:l)!==(null===c?u:c))return!0;if(l===c&&a!==u){const e=n.firstChild;null==e&&t(48);const i=Zl().createElement(u);return zo(i,this,0,s,r,o),n.replaceChild(i,e),!1}let f=n;null!==c&&null!==l&&(f=n.firstChild,null==f&&t(49)),Ko(r,f,this);const d=o.theme.text;void 0!==d&&i!==s&&Lo(0,i,s,f,d);const h=e.__style,g=this.__style;return h!==g&&Fo(n.style,g,h),!1}updateFromJSON(t){return super.updateFromJSON(t).setTextContent(t.text).setFormat(t.format).setDetail(t.detail).setMode(t.mode).setStyle(t.style)}exportDOM(e){let{element:n}=super.exportDOM(e);return gc(n)||t(132),n.style.whiteSpace="pre-wrap",this.hasFormat("lowercase")?n.style.textTransform="lowercase":this.hasFormat("uppercase")?n.style.textTransform="uppercase":this.hasFormat("capitalize")&&(n.style.textTransform="capitalize"),this.hasFormat("bold")&&(n=Bo(n,"b")),this.hasFormat("italic")&&(n=Bo(n,"i")),this.hasFormat("strikethrough")&&(n=Bo(n,"s")),this.hasFormat("underline")&&(n=Bo(n,"u")),{element:n}}exportJSON(){return{detail:this.getDetail(),format:this.getFormat(),mode:this.getMode(),style:this.getStyle(),text:this.getTextContent(),...super.exportJSON()}}selectionTransform(t,e){}setFormat(t){const e=this.getWritable();return e.__format="string"==typeof t?z[t]:t,e}setDetail(t){const e=this.getWritable();return e.__detail="string"==typeof t?B[t]:t,e}setStyle(t){const e=this.getWritable();return e.__style=t,e}toggleFormat(t){const e=Ws(this.getFormat(),t,null);return this.setFormat(e)}toggleDirectionless(){const t=this.getWritable();return t.__detail^=1,t}toggleUnmergeable(){const t=this.getWritable();return t.__detail^=2,t}setMode(t){const e=$[t];if(this.__mode===e)return this;const n=this.getWritable();return n.__mode=e,n}setTextContent(t){if(this.__text===t)return this;const e=this.getWritable();return e.__text=t,e}select(t,e){fi();let n=t,o=e;const r=Kr(),i=this.getTextContent(),s=this.__key;if("string"==typeof i){const t=i.length;void 0===n&&(n=t),void 0===o&&(o=t)}else n=0,o=0;if(!ur(r))return Dr(s,n,s,o,"text","text");{const t=qs();t!==r.anchor.key&&t!==r.focus.key||Vs(s),r.setTextNodeRange(this,n,this,o)}return r}selectStart(){return this.select(0,0)}selectEnd(){const t=this.getTextContentSize();return this.select(t,t)}spliceText(t,e,n,o){const r=this.getWritable(),i=r.__text,s=n.length;let l=t;l<0&&(l=s+l,l<0&&(l=0));const c=Kr();if(o&&ur(c)){const e=t+s;c.setTextNodeRange(r,e,r,e)}const a=i.slice(0,l)+n+i.slice(l+e);return r.__text=a,r}canInsertTextBefore(){return!0}canInsertTextAfter(){return!0}splitText(...t){fi();const e=this.getLatest(),n=e.getTextContent();if(""===n)return[];const o=e.__key,r=qs(),i=n.length;t.sort((t,e)=>t-e),t.push(i);const s=[],l=t.length;for(let e=0,o=0;ee&&(s.push(n.slice(e,r)),e=r)}const c=s.length;if(1===c)return[e];const a=s[0],u=e.getParent();let f;const d=e.getFormat(),h=e.getStyle(),g=e.__detail;let _=!1,p=null,y=null;const m=Kr();if(ur(m)){const[t,e]=m.isBackward()?[m.focus,m.anchor]:[m.anchor,m.focus];"text"===t.type&&t.key===o&&(p=t),"text"===e.type&&e.key===o&&(y=e)}e.isSegmented()?(f=Go(a),f.__format=d,f.__style=h,f.__detail=g,f.__state=At(e,f),_=!0):f=e.setTextContent(a);const x=[f];for(let t=1;t=v&&(p.set(t.getKey(),C-v,"text"),C=v){y.set(t.getKey(),S-v,"text");break}v=e}if(null!==u){!function(t){const e=t.getPreviousSibling(),n=t.getNextSibling();null!==e&&Js(e);null!==n&&Js(n)}(this);const t=u.getWritable(),e=this.getIndexWithinParent();_?(t.splice(e,0,x),this.remove()):t.splice(e,1,x),ur(m)&&Br(m,u,e,c-1)}return x}mergeWithSibling(e){const n=e===this.getPreviousSibling();n||e===this.getNextSibling()||t(50);const o=this.__key,r=e.__key,i=this.__text,s=i.length;qs()===r&&Vs(o);const l=Kr();if(ur(l)){const t=l.anchor,i=l.focus;null!==t&&t.key===r&&$r(t,n,o,e,s),null!==i&&i.key===r&&$r(i,n,o,e,s)}const c=e.__text,a=n?c+i:i+c;this.setTextContent(a);const u=this.getWritable();return e.remove(),u}isTextEntity(){return!1}}function $o(t){return{forChild:Qo(t.style),node:null}}function Uo(t){const e=t,n="normal"===e.style.fontWeight;return{forChild:Qo(e.style,n?void 0:"bold"),node:null}}const Ho=new WeakMap;function jo(t){if(!gc(t))return!1;if("PRE"===t.nodeName)return!0;const e=t.style.whiteSpace;return"string"==typeof e&&e.startsWith("pre")}function Jo(e){const n=e;null===e.parentElement&&t(129);let o=n.textContent||"";if(null!==function(t){let e,n=t.parentNode;const o=[t];for(;null!==n&&void 0===(e=Ho.get(n))&&!jo(n);)o.push(n),n=n.parentNode;const r=void 0===e?n:e;for(let t=0;t0){/[ \t\n]$/.test(n)&&(o=o.slice(1)),e=!1;break}}e&&(o=o.slice(1))}if(" "===o[o.length-1]){let t=n,e=!0;for(;null!==t&&null!==(t=Vo(t,!0));){if((t.textContent||"").replace(/^( |\t|\r?\n)+/,"").length>0){e=!1;break}}e&&(o=o.slice(0,o.length-1))}return""===o?{node:null}:{node:Go(o)}}function Vo(t,e){let n=t;for(;;){let t;for(;null===(t=e?n.nextSibling:n.previousSibling);){const t=n.parentElement;if(null===t)return null;n=t}if(n=t,gc(n)){const t=n.style.display;if(""===t&&!mc(n)||""!==t&&!t.startsWith("inline"))return null}let o=n;for(;null!==(o=e?n.firstChild:n.lastChild);)n=o;if(zs(n))return n;if("BR"===n.nodeName)return null}}const qo={code:"code",em:"italic",i:"italic",mark:"highlight",s:"strikethrough",strong:"bold",sub:"subscript",sup:"superscript",u:"underline"};function Yo(t){const e=qo[t.nodeName.toLowerCase()];return void 0===e?{node:null}:{forChild:Qo(t.style,e),node:null}}function Go(t=""){return Wl(new Wo(t))}function Xo(t){return t instanceof Wo}function Qo(t,e){const n=t.fontWeight,o=t.textDecoration.split(" "),r="700"===n||"bold"===n,i=o.includes("line-through"),s="italic"===t.fontStyle,l=o.includes("underline"),c=t.verticalAlign;return t=>Xo(t)||Ro(t)?(r&&!t.hasFormat("bold")&&t.toggleFormat("bold"),i&&!t.hasFormat("strikethrough")&&t.toggleFormat("strikethrough"),s&&!t.hasFormat("italic")&&t.toggleFormat("italic"),l&&!t.hasFormat("underline")&&t.toggleFormat("underline"),"sub"!==c||t.hasFormat("subscript")||t.toggleFormat("subscript"),"super"!==c||t.hasFormat("superscript")||t.toggleFormat("superscript"),e&&!t.hasFormat(e)&&t.toggleFormat(e),t):t}class Zo extends Wo{$config(){return this.config("tab",{extends:Wo})}constructor(t=void 0){super("\t",t),this.__detail=2}createDOM(t){const e=super.createDOM(t),n=Cl(t.theme,"tab");if(void 0!==n){e.classList.add(...n)}return e}setTextContent(t){return super.setTextContent("\t")}spliceText(e,n,o,r){return""===o&&0===n||"\t"===o&&1===n||t(286),this}setDetail(e){return 2!==e&&t(127),this}setMode(e){return"normal"!==e&&t(128),this}canInsertTextBefore(){return!1}canInsertTextAfter(){return!1}}function tr(){return Wl(new Zo)}function er(t){return t instanceof Zo}class nr{key;offset;type;_selection;constructor(t,e,n){this._selection=null,this.key=t,this.offset=e,this.type=n}is(t){return this.key===t.key&&this.offset===t.offset&&this.type===t.type}isBefore(t){if(this.key===t.key)return this.offsett&&(o=t)}else if(!Pi(e)){const t=e.getNextSibling();if(Xo(t))n=t.__key,o=0,r="text";else{const t=e.getParent();t&&(n=t.__key,o=e.getIndexWithinParent()+1)}}t.set(n,o,r)}function ir(t,e){if(Pi(e)){const n=e.getLastDescendant();Pi(n)||Xo(n)?rr(t,n):rr(t,e)}else rr(t,e)}function sr(t,e,n,o){const r=t.getNode(),i=r.getChildAtIndex(t.offset),s=Go();if(s.setFormat(n),s.setStyle(o),ns(i))i.splice(0,0,[s]);else if(null!==i){const t=Bl(r)?es().append(s):s;i.insertBefore(t)}else if(Bl(r)){const t=r.getLastChild();Pi(t)&&!t.isInline()&&t.isEmpty()?t.append(s):r.append(es().append(s))}else r.append(s);t.is(e)&&e.set(s.__key,0,"text"),t.set(s.__key,0,"text")}function lr(e,n,o,r){const i=e.anchor.getNode();Xo(i)||t(398);const s=e.anchor.offset,l=Go(n);l.setFormat(o),l.setStyle(r);const c=i.getParentOrThrow();if(0===s)c.isInline()&&!i.__prev?c.insertBefore(l):i.insertBefore(l,!1);else if(s===i.getTextContentSize())c.isInline()&&!i.__next?c.insertAfter(l):i.insertAfter(l,!1);else{const[t]=i.splitText(s);t.insertAfter(l,!1)}""===i.getTextContent()&&i.isAttached()&&i.remove(),l.selectEnd(),l.isComposing()&&"text"===e.anchor.type&&e.anchor.set(e.anchor.key,e.anchor.offset-n.length,e.anchor.type)}class cr{_nodes;_cachedNodes;dirty;constructor(t){this._cachedNodes=null,this._nodes=t,this.dirty=!1}getCachedNodes(){return this._cachedNodes}setCachedNodes(t){this._cachedNodes=t}is(t){if(!dr(t))return!1;const e=this._nodes,n=t._nodes;return e.size===n.size&&Array.from(e).every(t=>n.has(t))}isCollapsed(){return!1}isBackward(){return!1}getStartEndPoints(){return null}add(t){this.dirty=!0,this._nodes.add(t),this._cachedNodes=null}delete(t){this.dirty=!0,this._nodes.delete(t),this._cachedNodes=null}clear(){this.dirty=!0,this._nodes.clear(),this._cachedNodes=null}has(t){return this._nodes.has(t)}clone(){return new cr(new Set(this._nodes))}extract(){return this.getNodes()}insertRawText(t){}insertText(){}insertNodes(t){const e=this.getNodes().filter(t=>null===ta(t)),n=e.length;if(0===n)return;const o=e[n-1];let r;if(Xo(o))r=o.select();else{const t=o.getIndexWithinParent()+1;r=o.getParentOrThrow().select(t,t)}r.insertNodes(t);for(let t=0;tnull===ta(t));if((Kr()||zr())===this&&t[0]){const e=Ia(t[0],"next");nu(Va(e,e))}for(const e of t)e.remove();ar()}}function ar(){const t=nl();if(t.isEmpty()){const e=es();t.append(e),e.select()}}function ur(t){return t instanceof fr}class fr{format;style;anchor;focus;_cachedNodes;_cachedIsBackward;dirty;constructor(t,e,n,o){this.anchor=t,this.focus=e,t._selection=this,e._selection=this,this._cachedNodes=null,this._cachedIsBackward=null,this.format=n,this.style=o,this.dirty=!1}getCachedNodes(){return this._cachedNodes}setCachedNodes(t){this._cachedNodes=t}is(t){return!!ur(t)&&(this.anchor.is(t.anchor)&&this.focus.is(t.focus)&&this.format===t.format&&this.style===t.style)}isCollapsed(){return this.anchor.is(this.focus)}getNodes(){const t=this._cachedNodes;if(null!==t)return t;const e=function(t){const e=[],[n,o]=t.getTextSlices();n&&e.push(n.caret.origin);const r=new Set,i=new Set;for(const n of t)if(Aa(n)){const{origin:t}=n;0===e.length?r.add(t):(i.add(t),e.push(t))}else{const{origin:t}=n;Pi(t)&&i.has(t)||e.push(t)}o&&e.push(o.caret.origin);if(Ma(t.focus)&&Pi(t.focus.origin)&&null===t.focus.getNodeAtCaret())for(let n=Ba(t.focus.origin,"previous");Aa(n)&&r.has(n.origin)&&!n.origin.isEmpty()&&n.origin.is(e[e.length-1]);n=Wa(n))r.delete(n.origin),e.pop();for(;e.length>1;){const t=e[e.length-1];if(!Pi(t)||i.has(t)||t.isEmpty()||r.has(t))break;e.pop()}if(0===e.length&&t.isCollapsed()){const n=au(t.anchor),o=au(t.anchor.getFlipped()),r=t=>wa(t)?t.origin:t.getNodeAtCaret(),i=r(n)||r(o)||(t.anchor.getNodeAtCaret()?n.origin:o.origin);e.push(i)}return e}(du(ru(this),"next"));return ui()||(this._cachedNodes=e),e}setTextNodeRange(t,e,n,o){return this.anchor.set(t.__key,e,"text"),this.focus.set(n.__key,o,"text"),this}getTextContent(){const t=this.getNodes();if(0===t.length)return"";const e=t[0],n=t[t.length-1],o=this.anchor,r=this.focus,i=o.isBefore(r),[s,l]=yr(this);let c="",a=!0;for(let u=0;u(Pi(t)||Ki(t))&&!t.isInline())){Pi(r)||t(211,o.constructor.name,o.getType());const n=Xr(this);return r.splice(n,0,e),void i.selectEnd()}if(Pi(r)&&null!==ta(r)){const t=Xr(this),n=Gr(e);r.splice(t,0,n);const o=n[n.length-1];return void(void 0!==o?o.selectEnd():r.select(t,t))}if(null===r){const t=ti(e),n=t.getLastDescendant();let o=tu(this.anchor,"next");for(const e of t.getChildren())o=mu(e,o);return void(null!==n&&n.selectEnd())}if(Pi(r)&&!r.isParentRequired()&&!Bl(r.getParentOrThrow())){const t=Xr(this),n=Gr(e);r.splice(t,0,n);const o=n[n.length-1];return void(void 0!==o?o.selectEnd():r.select(t,t))}const s=ti(e),l=s.getLastDescendant(),c=s.getChildren(),a=!Pi(r)||!r.isEmpty()?this.insertParagraph():null;a&&!r.isAttached()&&(o=this.anchor.getNode(),r=qc(o,Sc));const u=c[c.length-1];let f=c[0];var d;Pi(d=f)&&Sc(d)&&!d.isEmpty()&&Pi(r)&&(!r.isEmpty()||r.canMergeWhenEmpty())&&(Pi(r)||t(211,o.constructor.name,o.getType()),r.append(...f.getChildren()),f=c[1]),f&&(null===r&&t(212,o.constructor.name,o.getType()),function(e,n){const o=n.getParentOrThrow().getLastChild();let r=n;const i=[n];for(;r!==o;)r.getNextSibling()||t(140),r=r.getNextSibling(),i.push(r);let s=e;for(const t of i)s=s.insertAfter(t)}(r,f));const h=qc(l,Sc);a&&Pi(h)&&(a.canMergeWhenEmpty()||Sc(u))&&(h.append(...a.getChildren()),a.remove()),Pi(r)&&r.isEmpty()&&r.remove(),l.selectEnd();const g=Pi(r)?r.getLastChild():null;Yi(g)&&h!==r&&g.remove()}insertParagraph(){const e=this.anchor.getNode();if("element"===this.anchor.type&&Bl(e)){const t=es();return e.splice(this.anchor.offset,0,[t]),t.select(),t}const n=Xr(this),o=qc(this.anchor.getNode(),Sc);if(null!==o&&null!==ta(o))return null;Pi(o)||t(213);const r=o.getChildAtIndex(n),i=r?[r,...r.getNextSiblings()]:[],s=o.insertNewAfter(this,!1);return s?(s.append(...i),s.selectStart(),s):null}insertLineBreak(t){const e=qi();if(this.insertNodes([e]),t){const t=e.getParentOrThrow(),n=e.getIndexWithinParent();t.select(n,n)}}extract(){const t=[...this.getNodes()],e=t.length;let n=t[0],o=t[e-1];const[r,i]=yr(this),s=this.isBackward(),[l,c]=s?[this.focus,this.anchor]:[this.anchor,this.focus],[a,u]=s?[i,r]:[r,i];if(0===e)return[];if(1===e){if(Xo(n)&&!this.isCollapsed()){const t=n.splitText(a,u),e=0===a?t[0]:t[1];return e?(l.set(e.getKey(),0,"text"),c.set(e.getKey(),e.getTextContentSize(),"text"),[e]):[]}return[n]}if(Xo(n)&&(a===n.getTextContentSize()?t.shift():0!==a&&([,n]=n.splitText(a),t[0]=n,l.set(n.getKey(),0,"text"))),Xo(o)){const e=o.getTextContent().length;0===u?t.pop():u!==e&&([o]=o.splitText(u),t[t.length-1]=o,c.set(o.getKey(),o.getTextContentSize(),"text"))}return t}modify(t,e,n){if(ei(this,t,e,n))return;const o="move"===t,r=_i(),i=Jl(Il(r));if(!i)return;const s=r._blockCursorElement,l=r._rootElement,c=this.focus.getNode();null===l||null===s||!Pi(c)||c.isInline()||c.canBeEmpty()||jl(s,r,l);const a=El(r,this.focus.key);let u=a;if("text"===this.focus.type&&(u=Xo(c)?wc(c,a,r):null),this.dirty){const t=El(r,this.anchor.key);let e=t;if("text"===this.anchor.type){const n=this.anchor.getNode();e=Xo(n)?wc(n,t,r):null}e&&u&&Ur(i,e,this.anchor.offset,u,this.focus.offset)}if("character"===n&&Xo(c)&&c.isUnmergeable()){if(e?0===this.focus.offset:this.focus.offset===c.getTextContentSize()){const t=Ia(c,e?"previous":"next").getNodeAtCaret();if(Xo(t)){if(!o){const n=t.getTextContentSize();return e?this.focus.set(t.__key,n-1,"text"):this.focus.set(t.__key,1,"text"),void(this.dirty=!0)}{const n=r.getElementByKey(t.getKey()),o=n?wc(t,n,r):null;if(o){const t=e?o.length:0;Ur(i,o,t,o,t)}}}}}if(Cr(i,t,e?"backward":"forward",n),i.rangeCount>0){const t=tc(i,r._rootElement),n=t||i.getRangeAt(0),s=this.anchor.getNode(),l=Bi(s)?s:Kl(s);if(this.applyDOMRange(n),this.dirty=!0,!o){Sr(this,e,l);(t?"backward"!==i.direction:i.anchorNode===n.startContainer&&i.anchorOffset===n.startOffset)||xr(this)}}"lineboundary"===n&&ei(this,t,e,n,"decorators")}forwardDeletion(t,e,n){if(!n&&("element"===t.type&&Pi(e)&&t.offset===e.getChildrenSize()||"text"===t.type&&t.offset===e.getTextContentSize())){const t=e.getParent(),n=e.getNextSibling()||(null===t?null:t.getNextSibling());if(Pi(n)&&n.isShadowRoot())return!0}return!1}deleteCharacter(t){const e=this.isCollapsed();if(this.isCollapsed()){const e=this.anchor;let n=e.getNode();if(this.forwardDeletion(e,n,t))return;const o=ja(tu(e,t?"previous":"next"));if(o.getTextSlices().every(t=>null===t||0===t.distance)){let t={type:"initial"};for(const e of o.iterNodeCarets("shadowRoot"))if(Aa(e))if(e.origin.isInline());else{if(e.origin.isShadowRoot()){if("merge-block"===t.type)break;if(Pi(o.anchor.origin)&&o.anchor.origin.isEmpty()){const t=au(e);ou(this,Va(t,t)),o.anchor.origin.remove()}return}"merge-next-block"!==t.type&&"merge-block"!==t.type||(t={block:t.block,caret:e,type:"merge-block"})}else{if("merge-block"===t.type)break;if(Ma(e)){if(Pi(e.origin)){if(e.origin.isInline()){if(!e.origin.isParentOf(o.anchor.origin))break}else t={block:e.origin,type:"merge-next-block"};continue}if(Ki(e.origin)){if(e.origin.isIsolated());else if(ia(e.origin).length>0){if(Pi(o.anchor.origin)&&o.anchor.origin.isEmpty()){o.anchor.origin.remove();const t=Pr();t.add(e.origin.getKey()),ol(t)}}else if("merge-next-block"===t.type&&(e.origin.isKeyboardSelectable()||!e.origin.isInline())&&Pi(o.anchor.origin)&&o.anchor.origin.isEmpty()){o.anchor.origin.remove();const t=Pr();t.add(e.origin.getKey()),ol(t)}else e.origin.remove();return}break}}if("merge-block"===t.type){const{caret:e,block:n}=t;if(ia(n).length>0)return;return e.origin.isEmpty()&&!n.isEmpty()&&e.origin.getParent()===n.getParent()?void e.origin.remove(!0):(ou(this,Va(!e.origin.isEmpty()&&n.isEmpty()?iu(Ia(n,e.direction)):o.anchor,e)),this.removeText())}for(let t=e.getNode();null!==t;){if(null!==ta(t))return;if(Pi(t)&&t.isShadowRoot())break;t=t.getParent()}}const r=this.focus;if(vr(this,t,"character"),this.isCollapsed()){if(t&&0===e.offset&&mr(this,e.getNode()))return}else{const o="text"===r.type?r.getNode():null;if(n="text"===e.type?e.getNode():null,null!==o&&o.isSegmented()){const e=r.offset,i=o.getTextContentSize();if(o.is(n)||t&&e!==i||!t&&0!==e)return void kr(o,t,e)}else if(null!==n&&n.isSegmented()){const r=e.offset,i=n.getTextContentSize();if(n.is(o)||t&&0!==r||!t&&r!==i)return void kr(n,t,r)}!function(t,e){const n=t.anchor,o=t.focus,r=n.getNode(),i=o.getNode();if(r===i&&"text"===n.type&&"text"===o.type){const t=n.offset,i=o.offset,s=t0&&(g===h.getTextContentSize()||Ks(h)||([h]=h.splitText(g)),h.setFormat(p));for(let t=a+1;t{for(const[e,o]of n)t=Ws(t,e,o?z[e]:0);return t})}function _r(t,e,n=null){const o=null===n&&ur(t)?Ws(t.format,e,null):n;hr(t,t=>Ws(t,e,o))}function pr(t){const e=t.offset;if("text"===t.type)return e;const n=t.getNode();return e===n.getChildrenSize()?n.getTextContent().length:0}function yr(t){const e=t.getStartEndPoints();if(null===e)return[0,0];const[n,o]=e;return"element"===n.type&&"element"===o.type&&n.key===o.key&&n.offset===o.offset?[0,0]:[pr(n),pr(o)]}function mr(t,e){for(let n=e;n;n=n.getParent()){if(Pi(n)){if(n.collapseAtStart(t))return!0;if(Bl(n))break}if(n.getPreviousSibling())break}return!1}function xr(t){const e=t.focus,n=t.anchor,o=n.key,r=n.offset,i=n.type;n.set(e.key,e.offset,e.type,!0),e.set(o,r,i,!0)}function Cr(t,e,n,o){t.modify(e,n,o)}function Sr(t,e,n){const o=t.getNodes(),r=o.filter(t=>Fl(t,n));if(0===r.length||r.length===o.length)return!1;const i=e?r[0]:r[r.length-1],s=Pi(i)?i:i.getParentOrThrow();return e?s.selectStart():s.selectEnd(),!0}function vr(t,e,n){if(ei(t,"extend",e,n))return;const o=_i(),r=Jl(Il(o));if(!r||"function"!=typeof r.modify)return;const i=o._blockCursorElement,s=o._rootElement,l=t.anchor,c=t.focus.getNode();null===s||null===i||!Pi(c)||c.isInline()||c.canBeEmpty()||jl(i,o,s);const a=t=>{const e=t.getNode(),n=o.getElementByKey(t.key);return null!==n&&"text"===t.type&&Xo(e)?wc(e,n,o):n},u=l.getNode(),f=a(l);if(null===f)return;const d=l.offset,h=t.isCollapsed(),g=t.focus,_=h?f:a(g);if(null===_)return;const p=g.offset;if(Ur(r,_,p,_,p),Cr(r,"move",e?"backward":"forward",n),0===r.rangeCount)return;const y=tc(r,s)||r.getRangeAt(0),m=y.startContainer,x=y.startOffset;if(h&&"character"===n&&"text"===l.type&&Xo(u)&&u.isUnmergeable()){if(d===(e?0:u.getTextContentSize())){const n=Ia(u,e?"previous":"next").getNodeAtCaret();if(Xo(n)){const o=e?n.getTextContentSize()-1:1;return t.focus.set(n.__key,o,"text"),void(t.dirty=!0)}}}if(h&&"character"===n&&"text"===l.type){const n=e?0:u.getTextContentSize(),o=m===f?x:d!==n?n:-1;if(o>=0)return void(o!==d&&(t.focus.set(l.key,o,"text"),t.dirty=!0))}const[C,S,v,T]=e?[m,x,f,d]:[f,d,m,x],k=Bi(u)?u:Kl(u);t.applyDOMRange({collapsed:!1,endContainer:v,endOffset:T,startContainer:C,startOffset:S}),t.dirty=!0,!Sr(t,e,k)&&e&&xr(t),"lineboundary"===n&&ei(t,"extend",e,n,"decorators")}const Tr=(()=>{try{const t=new RegExp("\\p{Emoji}","u"),e=t.test.bind(t);if(e("\u2764\ufe0f")&&e("#\ufe0f\u20e3")&&e("\u{1f44d}"))return e}catch(t){}return()=>!1})();function kr(t,e,n){const o=t,r=o.getTextContent().split(/(?=\s)/g),i=r.length;let s=0,l=0;for(let t=0;tn||o){r.splice(t,1),o&&(l=void 0);break}}const c=r.join("").trim();""===c?o.remove():(o.setTextContent(c),o.select(l,l))}function br(e,n,o,r){let i,s=n,l=!1;if(gc(e)){let c=!1;const a=e.childNodes,u=a.length,f=r._blockCursorElement;s===u&&u>0&&(c=!0,s=u-1),void 0!==Qs(e,r)||Rc(e,r)||(l=!0);let d=a[s],h=!1;if(d===f)d=a[s+1],h=!0;else if(null!==f){const t=f.parentNode;if(e===t){n>Array.prototype.indexOf.call(t.children,f)&&s--}}if(i=il(d),Xo(i))s=Ka(i,c?"next":"previous");else{let a=il(e);if(null===a)return null;if(Pi(a)){const l=r.getElementByKey(a.getKey());null===l&&t(214);const u=kc(a,l,r);[a,s]=u.resolveChildIndex(a,l,e,n),Pi(a)||t(215),c&&s>=a.getChildrenSize()&&(s=Math.max(0,a.getChildrenSize()-1));let f=a.getChildAtIndex(s);if(Pi(f)&&function(t,e,n){const o=t.getParent();return null===n||null===o||!o.canBeEmpty()||o!==n.getNode()}(f,0,o)){const t=c?f.getLastDescendant():f.getFirstDescendant();null===t?a=f:(f=t,a=Pi(f)?f:f.getParentOrThrow()),s=0}Xo(f)?(i=f,a=null,s=Ka(f,c?"next":"previous")):f!==a&&c&&!h&&(Pi(a)||t(216),s=Math.min(a.getChildrenSize(),s+1))}else{const t=ea(a),o=null!==t?t:a,i=o.getIndexWithinParent(),l=r.getElementByKey(a.getKey());let c="after";if(null!==l&&il(e)===a){const t=kc(a,l,r);t.element!==l?c=t.resolveLeafPosition(l,e,n):0===n&&Ki(a)&&(c="before")}s="before"===c?i:i+1,a=o.getParentOrThrow()}if(Pi(a))return[or(a.__key,s,"element"),l]}}else i=il(e);return Xo(i)?[or(i.__key,Ka(i,s,"clamp"),"text"),l]:null}function Nr(t,e,n){const o=t.offset,r=t.getNode();if(0===o){const o=r.getPreviousSibling(),i=r.getParent();if(e){if((n||!e)&&null===o&&Pi(i)&&i.isInline()){const e=i.getPreviousSibling();Xo(e)&&t.set(e.__key,e.getTextContent().length,"text")}}else Pi(o)&&!n&&o.isInline()?t.set(o.__key,o.getChildrenSize(),"element"):Xo(o)&&!r.isUnmergeable()&&t.set(o.__key,o.getTextContent().length,"text")}else if(o===r.getTextContent().length){const o=r.getNextSibling(),i=r.getParent();if(e&&Pi(o)&&o.isInline())t.set(o.__key,0,"element");else if((n||e)&&null===o&&Pi(i)&&i.isInline()&&!i.canInsertTextAfter()&&i.getTextContentSize()>1){const e=i.getNextSibling();Xo(e)&&t.set(e.__key,0,"text")}}}function Er(t){const e=Ys(t.key);return null===e?null:oa(e)}function wr(t,e,n){const o=Er(t),r=Er(e);if(o===r||null!==o&&null!==r&&o.is(r))return!1;const i=n(o,r);if(null!==o)return Pi(o)?e.set(o.getKey(),i?o.getChildrenSize():0,"element"):e.set(o.getKey(),i?o.getTextContentSize():0,"text"),!0;const s=ea(r);if(null===s)return!1;const l=s.getParent();if(null===l)return!1;const c=s.getIndexWithinParent();return e.set(l.getKey(),i?c+1:c,"element"),!0}function Or(t){const e=wr(t.anchor,t.focus,(e,n)=>function(t,e,n,o){if(null!==n&&null!==o){const t=ea(n),e=ea(o);if(null!==t&&t.is(e)){for(const e of ra(t).values()){if(e===n.getKey())return!0;if(e===o.getKey())return!1}return!0}return null===t||null===e||t.isBefore(e)}if(null!==n){const t=ea(n),o=Ys(e.key);return null===t||null===o||!(!t.is(o)&&!t.isParentOf(o))||t.isBefore(o)}const r=ea(o),i=Ys(t.key);return null!==r&&null!==i&&!r.is(i)&&!r.isParentOf(i)&&i.isBefore(r)}(t.anchor,t.focus,e,n));return e&&(t.dirty=!0),e}function Mr(t,e,n,o,r,i){if(null===t||null===n||!As(r,t,n))return null;const s=br(t,e,ur(i)?i.anchor:null,r);if(null===s)return null;const l=br(n,o,ur(i)?i.focus:null,r);if(null===l)return null;const[c,a]=s,[u,f]=l;if("element"===c.type&&"element"===u.type){const e=il(t),o=il(n);if(Ki(e)&&Ki(o))return null}const d=r._slotsUsed&&wr(c,u,()=>0!==(t.compareDocumentPosition(n)&Node.DOCUMENT_POSITION_FOLLOWING));return function(t,e){if("text"===t.type&&"text"===e.type){const n=t.isBefore(e),o=t.is(e);Nr(t,n,o),Nr(e,!n,o),o&&e.set(t.key,t.offset,t.type)}}(c,u),[c,u,a||f||d]}function Ar(t){return Pi(t)&&!t.isInline()}function Dr(t,e,n,o,r,i){const s=hi(),l=new fr(or(t,e,r),or(n,o,i),0,"");return l.dirty=!0,s._selection=l,l}function Fr(){const t=or("root",0,"element"),e=or("root",0,"element");return new fr(t,e,0,"")}function Pr(){return new cr(new Set)}function Ir(t,e){return Lr(null,t,e,null)}function Lr(t,e,n,o){const r=n._window;if(null===r)return null;const i=o||r.event,s=i?i.type:void 0,l="selectionchange"===s,c=!it&&(l||"beforeinput"===s||"compositionstart"===s||"compositionend"===s||"click"===s&&i&&3===i.detail||"drop"===s||void 0===s);let a,u,f,d;if(ur(t)&&!c)return t.clone();{if(null===e)return null;const o=nc(e,n._rootElement);if(a=o.anchorNode,u=o.focusNode,f=o.anchorOffset,d=o.focusOffset,(l||void 0===s)&&ur(t)&&!As(n,a,u))return t.clone()}const h=Mr(a,f,u,d,n,t);if(null===h)return null;const[g,_,p]=h;let y=0,m="";if(ur(t)){const e=t.anchor;if(g.key===e.key)y=t.format,m=t.style;else{const t=g.getNode();Xo(t)?(y=t.getFormat(),m=t.getStyle()):Pi(t)&&(y=t.getTextFormat(),m=t.getTextStyle())}}const x=new fr(g,_,y,m);return p&&(x.dirty=!0),x}function Kr(){return hi()._selection}function zr(){return _i()._editorState._selection}function Br(t,e,n,o=1){const r=t.anchor,i=t.focus,s=r.getNode(),l=i.getNode();if(!e.is(s)&&!e.is(l))return;const c=e.__key;if(t.isCollapsed()){const e=r.offset;if(n<=e&&o>0||n0||n0||n=t,s=r?i.getChildAtIndex(t-1):i.getChildAtIndex(n);if(Xo(s)){let t=0;r&&(t=s.getTextContentSize()),e.set(s.__key,t,"text"),o.set(s.__key,t,"text")}return}if(Pi(i)){const t=i.getChildrenSize(),o=n>=t,r=o?i.getChildAtIndex(t-1):i.getChildAtIndex(n);if(Xo(r)){let t=0;o&&(t=r.getTextContentSize()),e.set(r.__key,t,"text")}}if(Pi(s)){const t=s.getChildrenSize(),e=r>=t,n=e?s.getChildAtIndex(t-1):s.getChildAtIndex(r);if(Xo(n)){let t=0;e&&(t=n.getTextContentSize()),o.set(n.__key,t,"text")}}}function Wr(t,e,n,o,r){let i=null,s=0,l=null;null!==o?(i=o.__key,Xo(o)?(s=o.getTextContentSize(),l="text"):Pi(o)&&(s=o.getChildrenSize(),l="element")):null!==r&&(i=r.__key,Xo(r)?l="text":Pi(r)&&(l="element")),null!==i&&null!==l?t.set(i,s,l):(s=e.getIndexWithinParent(),-1===s&&(s=n.getChildrenSize()),t.set(n.__key,s,"element"))}function $r(t,e,n,o,r){"text"===t.type?t.set(n,t.offset+(e?0:r),"text"):t.offset>o.getIndexWithinParent()&&t.set(t.key,t.offset-1,"element")}function Ur(t,e,n,o,r){try{t.setBaseAndExtent(e,n,o,r)}catch(t){}}function Hr(t,e,n){const o=El(t,e.getKey());if(Pi(e)){const r=kc(e,o,t);return[r.element,n+r.getFirstChildOffset()]}return[o,n]}function jr(t,e,n,o,r,s){const l=s.getRootNode(),c=Bs(l)||ql(l)?cc(l):null;if(r.has(vo)&&c!==s||null!==c&&Os(c,c))return;const a=nc(o,s);let u;if(!ur(e))return void(null!==t&&As(n,a.anchorNode,a.focusNode)&&o.removeAllRanges());const f=e.anchor,d=e.focus,h=f.getNode(),g=d.getNode(),[_,p]=Hr(n,h,f.offset),[y,m]=Hr(n,g,d.offset),x=e.format,C=e.style,S=e.isCollapsed();let v=_,T=y,k=!1;if("text"===f.type?(v=Xo(h)?wc(h,_,n):null,k=h.getFormat()!==x||h.getStyle()!==C):ur(t)&&"text"===t.anchor.type&&(k=!0),"text"===d.type&&(T=Xo(g)?wc(g,y,n):null),null!==v&&null!==T){if(S&&(null===t||k||ur(t)&&(t.format!==x||t.style!==C))&&function(t,e,n,o,r,i){t._inputState.collapsedSelectionFormat={format:e,key:r,offset:o,style:n,timeStamp:i}}(n,x,C,p,f.key,performance.now()),("Range"!==o.type||!S)&&a.anchorOffset===p&&a.focusOffset===m&&a.anchorNode===v&&a.focusNode===T){if(null===c||!s.contains(c)){const t=null!==c?Fs(c):null;null!==t&&t!==n||r.has(No)||s.focus({preventScroll:!0})}if("element"!==f.type)return}if(Ur(o,v,p,T,m),i&&e.isCollapsed()&&null!==s&&!r.has(No)){const t=lc(s);if(null===t||!s.contains(t)){const t=cc(s.ownerDocument),e=null!==t?Fs(t):null;null!==e&&e!==n||s.focus({preventScroll:!0})}}if(!r.has(ko)&&e.isCollapsed()&&null!==s&&s===lc(s)){const t=ur(e)&&"element"===e.anchor.type?v.childNodes[p]||null:(void 0===u&&(u=ec(o,s)),u);if(null!==t){let e;if(zs(t)){const n=t.ownerDocument.createRange();n.selectNode(t),e=n.getBoundingClientRect()}else e=t.getBoundingClientRect();!function(t,e,n){const o=Ol(n),r=Pl(o);if(null===o||null===r)return;const i=n.getBoundingClientRect();if(e.bottoma&&(f=l-a),0!==f)if(e)r.scrollBy(0,f);else{const t=u.scrollTop;u.scrollTop+=f;const e=u.scrollTop-t;s-=e,l-=e}if(e)break;u=wl(u)}}(n,e,s)}}!function(t){t._inputState.isSelectionChangeFromDOMUpdate=!0}(n)}}function Jr(t){let e=Kr()||zr();null===e&&(e=nl().selectEnd()),e.insertNodes(t)}function Vr(t,e){for(const n of t.split(/(\r?\n|\t)/))"\n"===n||"\r\n"===n?e.linebreak():"\t"===n?e.tab():""!==n&&e.text(n)}function qr(t){const e=[];return Vr(t,{linebreak:()=>e.push(qi()),tab:()=>e.push(tr()),text:t=>e.push(Go(t))}),e}function Yr(){const t=Kr();return null===t?"":t.getTextContent()}function Gr(t){const e=[];for(const n of t)Yi(n)||(!Pi(n)&&!Ki(n)||n.isInline()?e.push(n):Pi(n)&&e.push(...Gr(n.getChildren())));return e}function Xr(e){let n=e;e.isCollapsed()||n.removeText();const o=Kr();ur(o)&&(n=o),ur(n)||t(161);const r=n.anchor;let i=r.getNode(),s=r.offset;for(;!Sc(i)&&null===ta(i);){const t=i;if([i,s]=Qr(i,s),t.is(i))break}return s}function Qr(t,e){const n=t.getParent();if(!n){const t=es();return nl().append(t),t.select(),[nl(),0]}if(Xo(t)){const o=t.splitText(e);if(0===o.length)return[n,t.getIndexWithinParent()];const r=0===e?0:1;return[n,o[0].getIndexWithinParent()+r]}if(!Pi(t)||0===e)return[n,t.getIndexWithinParent()];const o=t.getChildAtIndex(e);if(o){const n=new fr(or(t.__key,e,"element"),or(t.__key,e,"element"),0,""),r=t.insertNewAfter(n);r&&r.append(o,...o.getNextSiblings())}return[n,t.getIndexWithinParent()+1]}function Zr(t){return Yi(t)||Ll(t)||Xo(t)||t.isParentRequired()}function ti(t){const e=es();let n=null;for(let o=0;o99&&t(14)}function hi(){return null===ni&&t(195,yi()),ni}function gi(t){null!==hi()&&null===oi&&(oi=t),oi!==t&&e(378)}function _i(){return null===oi&&t(337,yi()),oi}function pi(){_i()._dirtyType=2}function yi(){let t=0;const e=new Set,n=Cs.version;if("undefined"!=typeof window)for(const o of Xl(document)){const r=Ps(o);if(Ds(r))t++;else if(r){let t=String(r.constructor.version||"<0.17.1");t===n&&(t+=" (separately built, likely a bundler configuration issue)"),e.add(t)}}let o=` Detected on the page: ${t} compatible editor(s) with version ${n}`;return e.size&&(o+=` and incompatible editors with versions ${Array.from(e).join(", ")}`),o}function mi(){return oi}function xi(t,e,n){const o=e.__type,r=Ns(t,o);let i=n.get(o);void 0===i&&(i=Array.from(r.transforms),n.set(o,i));const s=i.length;for(let t=0;t0&&wi(t,t._deferred));const i=t._editorState,s=i._selection,l=n._selection,c=0!==t._dirtyType,a=ni,u=ri,f=oi,d=t._updating,h=t._observer;let g=null;if(t._pendingEditorState=null,t._editorState=n,!r&&c&&null!==h){oi=t,ni=n,ri=!1,t._updating=!0;try{const e=t._dirtyType,o=t._dirtyElements,r=t._dirtyLeaves;h.disconnect(),g=De(i,n,t,e,o,r)}catch(e){if(e instanceof Error&&t._onError(e),ii)throw e;return gs(t,null,o,n),gt(t),t._dirtyType=2,ii=!0,bi(t,i),void(ii=!1)}finally{h.observe(o,ai),t._updating=d,ni=a,ri=u,oi=f}}n._readOnly||(n._readOnly=!0);const _=t._dirtyLeaves,p=t._dirtyElements,y=t._normalizedNodes,m=t._updateTags;c&&(t._dirtyType=0,t._cloneNotNeeded.clear(),t._dirtyLeaves=new Set,t._dirtyElements=new Map,t._normalizedNodes=new Set);t._updateTags=new Set,function(t,e){const n=t._decorators;let o=t._pendingDecorators||n;const r=e._nodeMap;let i;for(i in o)r.has(i)||(o===n&&(o=tl(t)),delete o[i])}(t,n);const x=r?null:Jl(Il(t));if(t._editable&&null!==x&&(c||null===l||l.dirty||!l.is(s))&&null!==o&&!m.has(bo)){oi=t,ni=n;try{if(null!==h&&h.disconnect(),c||null===l||l.dirty){const e=t._blockCursorElement;null!==e&&jl(e,t,o),jr(s,l,t,x,m,o)}!function(t,e,n){let o=t._blockCursorElement;if(ur(n)&&n.isCollapsed()&&"element"===n.anchor.type&&e.contains(lc(e))){const r=n.anchor,i=r.getNode(),s=r.offset;let l=!1,c=null;if(s===i.getChildrenSize()){Hl(i.getChildAtIndex(s-1))&&(l=!0)}else{const e=i.getChildAtIndex(s);if(null!==e&&Hl(e)){const n=e.getPreviousSibling();(null===n||Hl(n))&&(l=!0,c=t.getElementByKey(e.__key))}}if(l){const n=kc(i,t.getElementByKey(i.__key),t).element;return null===o&&(t._blockCursorElement=o=function(t){const e=t.theme,n=Zl().createElement("div");n.contentEditable="false",n.setAttribute("data-lexical-cursor","true");let o=e.blockCursor;if(void 0!==o){if("string"==typeof o){const t=ku(o);o=e.blockCursor=t}void 0!==o&&n.classList.add(...o)}return n}(t._config)),e.style.caretColor="transparent",void(null===c?n.appendChild(o):n.insertBefore(o,c))}}null!==o&&jl(o,t,e)}(t,o,l)}finally{null!==h&&h.observe(o,ai),oi=f,ni=a}}null!==g&&function(t,e,n,o,r){const i=Array.from(t._listeners.mutation),s=i.length;for(let t=0;t{li.delete(t),t._cascadeCount=0},0)}(t),t._cascadeCount++>99)return t._updates=[],t._cascadeCount=0,void t._onWarn(new Error(`One or more update listeners are endlessly enqueueing more updates. May have encountered infinite recursion caused by update listeners that trigger additional updates without a stop condition. Editor namespace: ${t._config.namespace}`));const n=e.shift();if(n){const[e,o]=n;Mi(t,e,o)}}(t)}(t,e)}finally{si=n}}function Ni(t,e,n,...o){const r=e._updating;e._updating=n;try{const n=e._listeners[t],r=Array.from(n);for(const[t,e]of r){e&&e();const r=t(...o);n.has(t)?n.set(t,r):r&&r()}}finally{e._updating=r}}function Ei(t,e,n,o){const r=ll(t);let i;if(!si)for(let t=0;t=0;t--)for(let s=0;s0&&l._updating){i=l;break}const c=l._commands.get(e);if(void 0!==c){const e=c[t];if(e.size>0){let t=!1;if(Ai(l,()=>{for(const r of e)if(r(n,o))return void(t=!0)}),t)return t}}}return i&&i.update(()=>{Ei(i,e,n,o)}),!1}function wi(t,e){if(t._deferred=[],0!==e.length){const n=t._updating;t._updating=!0;try{for(let t=0;t0||u>0;){if(c>0){e._dirtyLeaves=new Set;for(const t of l){const o=r.get(t);Xo(o)&&o.isAttached()&&o.isSimpleText()&&!o.isUnmergeable()&&Pt(o),void 0!==o&&Ci(o,i)&&xi(e,o,s),n.add(t)}if(l=e._dirtyLeaves,c=l.size,c>0){ci++;continue}}e._dirtyLeaves=new Set,e._dirtyElements=new Map,a.delete("root")&&a.set("root",!0);for(const t of a){const n=t[0],l=t[1];if(o.set(n,l),!l)continue;const c=r.get(n);void 0!==c&&Ci(c,i)&&xi(e,c,s)}l=e._dirtyLeaves,c=l.size,a=e._dirtyElements,u=a.size,ci++}e._dirtyLeaves=n,e._dirtyElements=o}(a,e),Oi(e),function(t,e,n,o){const r=t._nodeMap,i=e._nodeMap,s=[];for(const[t]of o){const e=i.get(t);void 0!==e&&(e.isAttached()||(Pi(e)&&rt(e,t,r,i,s,o),r.has(t)||o.delete(t),s.push(t)))}for(const t of n){const e=i.get(t);void 0===e||e.isAttached()||(Qc(e)&&null!==e.__slots&&rt(e,t,r,i,s,n),r.has(t)||n.delete(t),s.push(t))}for(const t of s)i.delete(t);const l=_i(),c=l._compositionKey;null===c||i.has(c)||(l._compositionKey=null)}(c,a,e._dirtyLeaves,e._dirtyElements));r!==e._compositionKey&&(a._flushSync=!0);const i=a._selection;if(ur(i)){e._slotsUsed&&Or(i);const n=a._nodeMap,o=i.anchor.key,r=i.focus.key;void 0!==n.get(o)&&void 0!==n.get(r)||t(19)}else dr(i)&&0===i._nodes.size&&(a._selection=null)}catch(t){return t instanceof Error&&e._onError(t),e._pendingEditorState=c,e._dirtyType=2,e._cloneNotNeeded.clear(),e._dirtyLeaves=new Set,e._dirtyElements.clear(),void bi(e)}finally{ni=f,ri=d,oi=h,e._updating=g,ci=0}const p=0!==e._dirtyType||e._deferred.length>0||function(t,e){const n=e.getEditorState()._selection,o=t._selection;if(null!==o){if(o.dirty||!o.is(n))return!0}else if(null!==n)return!0;return!1}(a,e);p?a._flushSync?(a._flushSync=!1,bi(e)):u&&ws(()=>{bi(e)}):(a._flushSync=!1,u&&(r.clear(),e._deferred=[],e._pendingEditorState=null))}function Ai(t,e,n){oi===t&&void 0===n?ui()?Mi(t,e,n):e():Mi(t,e,n)}function Di(t){if(Bl(t)){let e=null;for(const n of t.getChildren())e=n.isInline()?(e||n.replace(n.createParentElementNode())).append(n):null}}class Fi extends _o{__first;__last;__size;__format;__style;__indent;__dir;__textFormat;__textStyle;__slotHost;__slots;$config(){return this.config(Symbol.for("ElementNode"),{$transform:Di,extends:_o})}constructor(t){super(t),this.__first=null,this.__last=null,this.__size=0,this.__format=0,this.__style="",this.__indent=0,this.__dir=null,this.__textFormat=0,this.__textStyle="",this.__slotHost=null,this.__slots=null}afterCloneFrom(e){super.afterCloneFrom(e),this.__key===e.__key&&(this.__first=e.__first,this.__last=e.__last,this.__size=e.__size,this.__slotHost=e.__slotHost,null!==this.__slotHost&&null!==this.__parent&&t(384,this.__key,String(this.__slotHost),String(this.__parent)),this.__slots=e.__slots),this.__indent=e.__indent,this.__format=e.__format,this.__style=e.__style,this.__dir=e.__dir,this.__textFormat=e.__textFormat,this.__textStyle=e.__textStyle}getFormat(){return this.getLatest().__format}getFormatType(){const t=this.getFormat();return W[t]||""}getStyle(){return this.getLatest().__style}getIndent(){return this.getLatest().__indent}getChildren(){const t=[];let e=this.getFirstChild();for(;null!==e;)t.push(e),e=e.getNextSibling();return t}getChildrenKeys(){const t=[];let e=this.getFirstChild();for(;null!==e;)t.push(e.__key),e=e.getNextSibling();return t}getChildrenSize(){return this.getLatest().__size}isEmpty(){return 0===this.getChildrenSize()&&0===ia(this).length}isDirty(){const t=_i()._dirtyElements;return null!==t&&t.has(this.__key)}isLastChild(){const t=this.getLatest(),e=this.getParentOrThrow().getLastChild();return null!==e&&e.is(t)}getAllTextNodes(){const t=[];for(const e of ia(this)){const n=sa(this,e);Pi(n)&&t.push(...n.getAllTextNodes())}let e=this.getFirstChild();for(;null!==e;){if(Xo(e)&&t.push(e),Pi(e)){const n=e.getAllTextNodes();t.push(...n)}e=e.getNextSibling()}return t}getFirstDescendant(){let t=this.getFirstChild();for(;Pi(t);){const e=t.getFirstChild();if(null===e)break;t=e}return t}getLastDescendant(){let t=this.getLastChild();for(;Pi(t);){const e=t.getLastChild();if(null===e)break;t=e}return t}getDescendantByIndex(t){const e=this.getChildren(),n=e.length;if(t>=n){const t=e[n-1];return Pi(t)&&t.getLastDescendant()||t||null}const o=e[t];return Pi(o)&&o.getFirstDescendant()||o||null}getFirstChild(){const t=this.getLatest().__first;return null===t?null:Ys(t)}getFirstChildOrThrow(){const e=this.getFirstChild();return null===e&&t(45,this.__key),e}getLastChild(){const t=this.getLatest().__last;return null===t?null:Ys(t)}getLastChildOrThrow(){const e=this.getLastChild();return null===e&&t(96,this.__key),e}getChildAtIndex(t){const e=this.getChildrenSize();let n,o;if(t=t;){if(o===t)return n;n=n.getPreviousSibling(),o--}return null}getTextContent(){let t=ha(this);const e=this.getChildren(),n=e.length;for(let o=0;ot.remove()),t}append(...t){return this.splice(this.getChildrenSize(),0,t)}setDirection(t){const e=this.getWritable();return e.__dir=t,e}setFormat(t){return this.getWritable().__format=""!==t&&R[t]||0,this}setStyle(t){return this.getWritable().__style=t||"",this}setTextFormat(t){const e=this.getWritable();return e.__textFormat=t,e}setTextStyle(t){const e=this.getWritable();return e.__textStyle=t,e}setIndent(t){return this.getWritable().__indent=t,this}splice(e,n,o){ho(this)&&t(324,this.__key,this.__type);const r=this.getChildrenSize(),i=this.getWritable();e+n<=r||t(226,String(e),String(n),String(r));for(const t of o);const s=i.__key,l=[],c=[],a=this.getChildAtIndex(e+n);let u=null,f=r-n+o.length;if(0!==e)if(e===r)u=this.getLastChild();else{const t=this.getChildAtIndex(e);null!==t&&(u=t.getPreviousSibling())}if(n>0){let e=null===u?this.getFirstChild():u.getNextSibling();for(let o=0;o0&&(e.style.paddingInlineStart=40*t+"px",e.setAttribute("data-lexical-indent",String(t)));const n=this.getDirection();n&&(e.dir=n)}return{element:e}}exportJSON(){const t={children:[],direction:this.getDirection(),format:this.getFormatType(),indent:this.getIndent(),...super.exportJSON()},e=this.getTextFormat(),n=this.getTextStyle();return 0===e&&""===n||Bl(this)||this.getChildren().some(Xo)||(0!==e&&(t.textFormat=e),""!==n&&(t.textStyle=n)),t}updateFromJSON(t){return super.updateFromJSON(t).setFormat(t.format).setIndent(t.indent).setDirection(t.direction).setTextFormat(t.textFormat||0).setTextStyle(t.textStyle||"")}insertNewAfter(t,e){return null}canIndent(){return!0}collapseAtStart(t){return!1}excludeFromCopy(t){return!1}canReplaceWith(t){return!0}canInsertAfter(t){return!0}canBeEmpty(){return!0}canInsertTextBefore(){return!0}canInsertTextAfter(){return!0}isInline(){return!1}isShadowRoot(){return!1}canMergeWith(t){return!1}extractWithChild(t,e,n){return!1}canMergeWhenEmpty(){return!1}reconcileObservedMutation(t,e){const n=kc(this,t,e);let o=n.getFirstChild();for(let t=this.getFirstChild();t;t=t.getNextSibling()){const r=e.getElementByKey(t.getKey());null!==r&&(null==o?(n.insertChild(r),o=r):o!==r&&n.replaceChild(r,o),o=o.nextSibling)}}}function Pi(t){return t instanceof Fi}function Ii(t,e,n){let o=t.getNode();for(;o;){const t=o.__key;if(e.has(t)&&!n.has(t))return!0;o=o.getParent()}return!1}class Li extends _o{__slotHost;__slots;constructor(t){super(t),this.__slotHost=null,this.__slots=null}afterCloneFrom(e){super.afterCloneFrom(e),this.__key===e.__key&&(this.__slotHost=e.__slotHost,null!==this.__slotHost&&null!==this.__parent&&t(383,this.__key,String(this.__slotHost),String(this.__parent)),this.__slots=e.__slots)}decorate(t,e){return null}isIsolated(){return!1}isInline(){return!0}isKeyboardSelectable(){return!0}}function Ki(t){return t instanceof Li}class zi extends Fi{__cachedText;$config(){return this.config("root",{extends:Fi})}constructor(){super("root"),this.__cachedText=null}getTopLevelElementOrThrow(){t(51)}getTextContent(){const t=this.__cachedText;return null===t||!ui()&&0!==_i()._dirtyType?super.getTextContent():t}remove(){t(52)}replace(e){t(53)}insertBefore(e){t(54)}insertAfter(e){t(55)}updateDOM(t,e){return!1}splice(e,n,o){for(const e of o)Pi(e)||Ki(e)||t(282);return super.splice(e,n,o)}static importJSON(t){return nl().updateFromJSON(t)}collapseAtStart(){return!0}}function Bi(t){return t instanceof zi}function Ri(t){return new Hi(nt(t._nodeMap),null,t._slotsUsed)}function Wi(){return new Hi(new Map([["root",new zi]]),null,!1)}function $i(e){const n=e.exportJSON(),o=e.constructor;if(n.type!==o.getType()&&t(130,o.name),Pi(e)){const r=n.children;Array.isArray(r)||t(59,o.name);const i=e.getChildren();for(let t=0;t0){const i={};for(const n of r){const r=sa(e,n);null===r&&t(366,o.name,n),i[n]=$i(r)}n.$slots=i}return n}function Ui(t){return t instanceof Hi}class Hi{_nodeMap;_selection;_flushSync;_readOnly;_parsed;_slotsUsed;constructor(t,e=null,n=!1){this._nodeMap=t,this._selection=e||null,this._flushSync=!1,this._readOnly=!1,this._parsed=!1,this._slotsUsed=n}isEmpty(){return 1===this._nodeMap.size&&null===this._selection}read(t,e){return ki(e&&e.editor||null,this,t)}clone(t){const e=new Hi(this._nodeMap,void 0===t?this._selection:t,this._slotsUsed);return e._readOnly=!0,e}toJSON(){return ki(null,this,()=>({root:$i(nl())}))}}class ji extends Fi{$config(){return this.config("artificial",{extends:Fi})}createDOM(t){return Zl().createElement("div")}}class Ji extends _o{$config(){return this.config("linebreak",{importDOM:{br:t=>Gi(t)||Xi(t)?null:{conversion:Vi,priority:0}}})}getTextContent(){return"\n"}createDOM(){return Zl().createElement("br")}updateDOM(){return!1}isInline(){return!0}}function Vi(t){return{node:qi()}}function qi(){return Wl(new Ji)}function Yi(t){return t instanceof Ji}function Gi(t){const e=t.parentElement;if(null!==e&&Cc(e)){const n=e.firstChild;if(n===t||n.nextSibling===t&&Qi(n)){const n=e.lastChild;if(n===t||n.previousSibling===t&&Qi(n))return!0}}return!1}function Xi(t){const e=t.parentElement;if(null!==e&&Cc(e)){const n=e.firstChild;if(n===t||n.nextSibling===t&&Qi(n))return!1;const o=e.lastChild;if(o===t||o.previousSibling===t&&Qi(o))return!0}return!1}function Qi(t){return zs(t)&&/^( |\t|\r?\n)+$/.test(t.textContent||"")}class Zi extends Fi{$config(){return this.config("paragraph",{extends:Fi,importDOM:{p:()=>({conversion:ts,priority:0})}})}createDOM(t){const e=Zl().createElement("p"),n=Cl(t.theme,"paragraph");if(void 0!==n){e.classList.add(...n)}return e}updateDOM(t,e,n){return!1}exportDOM(t){const{element:e}=super.exportDOM(t);if(gc(e)){this.isEmpty()&&e.append(Zl().createElement("br"));const t=this.getFormatType();t&&(e.style.textAlign=t)}return{element:e}}exportJSON(){const t=super.exportJSON();if(void 0===t.textFormat||void 0===t.textStyle){const e=this.getChildren().find(Xo);e?(t.textFormat=e.getFormat(),t.textStyle=e.getStyle()):(t.textFormat=this.getTextFormat(),t.textStyle=this.getTextStyle())}return t}insertNewAfter(t,e){const n=es();n.setTextFormat(t.format),n.setTextStyle(t.style);const o=this.getDirection();return n.setDirection(o),n.setFormat(this.getFormatType()),n.setStyle(this.getStyle()),this.insertAfter(n,e),n}collapseAtStart(){const t=this.getChildren();if(0===t.length||Xo(t[0])&&""===t[0].getTextContent().trim()){if(null!==this.getNextSibling())return this.selectNext(),this.remove(),!0;if(null!==this.getPreviousSibling())return this.selectPrevious(),this.remove(),!0}return!1}}function ts(t){const e=es();if(Lc(e,t),Pc(t,e),""===e.getFormatType()){const n=t.getAttribute("align");n&&n&&n in R&&e.setFormat(n)}return Ic(e,t),{node:e}}function es(){return Wl(new Zi)}function ns(t){return t instanceof Zi}function os(t){console.warn(t)}const rs=0,is=1,ss=2,ls=3,cs=4,as=-8,us=-7,fs=-6,ds=-5,hs=-4;function gs(t,e,n,o,r){const i=t._keyToDOMMap;i.clear(),t._editorState=Wi(),t._pendingEditorState=o,t._compositionKey=null,t._dirtyType=0,t._cloneNotNeeded.clear(),t._dirtyLeaves=new Set,t._dirtyElements.clear(),t._normalizedNodes=new Set,r&&r.preserveUpdateQueue||(t._updateTags=new Set,t._updates=[],t._cascadeCount=0),t._blockCursorElement=null,null!==t._inputState.handledSelectionCommandTimeoutId&&clearTimeout(t._inputState.handledSelectionCommandTimeoutId),t._inputState={collapsedSelectionFormat:{format:0,key:"root",offset:0,style:"",timeStamp:0},compositionEndData:"",compositionPhase:"idle",hadOrphanedCompositionEvents:!1,handledSelectionCommandTimeoutId:null,isInsertLineBreak:!1,isInsertTextAfterHandledSelectionCommand:!1,isSelectionChangeFromDOMUpdate:!1,isSelectionChangeFromMouseDown:!1,lastBeforeInputInsertTextTimeStamp:0,lastKeyCode:null,lastKeyDownTimeStamp:0,postDeleteSelectionToRestore:null,unprocessedBeforeInputData:null};const s=t._observer;null!==s&&(s.disconnect(),t._observer=null),null!==e&&(e.textContent="",function(t,e){const n=`__lexicalKey_${e._key}`;delete t[n]}(e,t)),null!==n&&(n.textContent="",i.set("root",n),Xs(n,t,"root"))}function _s(t){const e=new Set,n=new Set;for(const{klass:o,ownNodeConfig:r}of jc(t)){const t=o.transform;if(!n.has(t)){n.add(t);const r=o.transform();r&&e.add(r)}if(r){const t=r.$transform;t&&e.add(t)}}return e}const ps={$createDOM:(t,e)=>t.createDOM(e._config,e),$decorateDOM:(t,e,n,o)=>{},$exportDOM:(t,e)=>{const n=Es(e,t.getType());return n&&void 0!==n.exportDOM?n.exportDOM(e,t):t.exportDOM(e)},$extractWithChild:(t,e,n,o,r)=>Pi(t)&&t.extractWithChild(e,n,o),$getDOMSlot:(t,e,n)=>t.getDOMSlot(e),$getSlotTargetElement:(t,e,n,o)=>null,$shouldExclude:(t,e,n)=>Pi(t)&&t.excludeFromCopy("html"),$shouldInclude:(t,e,n)=>!e||t.isSelected(e),$updateDOM:(t,e,n,o)=>t.updateDOM(e,n,o._config)};function ys(e){const n=e||{},o=mi(),r=n.theme||{},i=void 0===e?o:n.parentEditor||null,s=n.disableEvents||!1,l=Wi(),c=n.namespace||(null!==i?i._config.namespace:cl()),a=n.editorState,u=[zi,Wo,Ji,Zo,Zi,ji,...n.nodes||[]],{onError:f,onWarn:d,html:h}=n,g=void 0===n.editable||n.editable;let _;if(void 0===e&&null!==o)_=o._nodes;else{_=new Map;for(let e=0;e{Object.keys(t).forEach(e=>{let o=n.get(e);void 0===o&&(o=[],n.set(e,o)),o.push(t[e])})};return t.forEach(t=>{const e=t.klass.importDOM;if(null==e||o.has(e))return;o.add(e);const n=e.call(t.klass);null!==n&&r(n)}),e&&r(e),n}(_,h?h.import:void 0),g,e);return void 0!==a&&(p._pendingEditorState=a,p._dirtyType=2),function(t){t.registerCommand(ze,Yn,rs),t.registerCommand(Be,Gn,rs),t.registerCommand(Re,Xn,rs),t.registerCommand(We,Qn,rs),t.registerCommand(tn,eo,rs)}(p),p}function ms(t,e){const n=t.get(e);t.delete(e),n&&n()}function xs(t,e,n){return t.set(e,n),ms.bind(null,t,e)}class Cs{static version;_headless;_parentEditor;_rootElement;_editorState;_pendingEditorState;_compositionKey;_deferred;_keyToDOMMap;_updates;_updating;_cascadeCount;_listeners;_commands;_nodes;_decorators;_pendingDecorators;_config;_dirtyType;_cloneNotNeeded;_dirtyLeaves;_dirtyElements;_normalizedNodes;_updateTags;_observer;_key;_onError;_onWarn;_htmlConversions;_window;_editable;_blockCursorElement;_slotsUsed;_inputState;_createEditorArgs;constructor(t,e,n,o,r,i,s,l,c){this._createEditorArgs=c,this._parentEditor=e,this._rootElement=null,this._editorState=t,this._pendingEditorState=null,this._compositionKey=null,this._deferred=[],this._keyToDOMMap=new ot,this._updates=[],this._updating=!1,this._cascadeCount=0,this._listeners={decorator:new Map,editable:new Map,mutation:new Map,root:new Map,textcontent:new Map,update:new Map},this._commands=new Map,this._config=o,this._nodes=n,this._decorators={},this._pendingDecorators=null,this._dirtyType=0,this._cloneNotNeeded=new Set,this._dirtyLeaves=new Set,this._dirtyElements=new Map,this._normalizedNodes=new Set,this._updateTags=new Set,this._observer=null,this._key=cl(),this._onError=r,this._onWarn=i,this._htmlConversions=s,this._editable=l,this._headless=null!==e&&e._headless,this._window=null,this._blockCursorElement=null,this._slotsUsed=!1,this._inputState={collapsedSelectionFormat:{format:0,key:"root",offset:0,style:"",timeStamp:0},compositionEndData:"",compositionPhase:"idle",hadOrphanedCompositionEvents:!1,handledSelectionCommandTimeoutId:null,isInsertLineBreak:!1,isInsertTextAfterHandledSelectionCommand:!1,isSelectionChangeFromDOMUpdate:!1,isSelectionChangeFromMouseDown:!1,lastBeforeInputInsertTextTimeStamp:0,lastKeyCode:null,lastKeyDownTimeStamp:0,postDeleteSelectionToRestore:null,unprocessedBeforeInputData:null}}isComposing(){return null!=this._compositionKey}registerUpdateListener(t){return xs(this._listeners.update,t)}registerEditableListener(t){return xs(this._listeners.editable,t)}registerDecoratorListener(t){return xs(this._listeners.decorator,t)}registerTextContentListener(t){return xs(this._listeners.textcontent,t)}registerRootListener(t){const e=this._listeners.root;return Eu(xs(e,t,t(this._rootElement,null)||void 0),()=>function(t,e,n){const o=t.get(e);o&&o(),t.set(e,e(...n)||void 0)}(e,t,[null,this._rootElement]))}registerCommand(e,n,o){void 0===o&&t(35);const r=this._commands;r.has(e)||r.set(e,[new tt,new tt,new tt,new tt,new tt]);const i=r.get(e);void 0===i&&t(36,String(e));const s=function(t){return 7&t}(o),l=i[s];return s!==o?l.addFront(n):l.addBack(n),()=>{l.delete(n),i.every(t=>0===t.size)&&r.delete(e)}}registerMutationListener(t,e,n){const o=this.resolveRegisteredNodeAfterReplacements(this.getRegisteredNode(t)).klass,r=this._listeners.mutation;let i=r.get(e);void 0===i&&(i=new Set,r.set(e,i)),i.add(o);const s=n&&n.skipInitialization;return void 0!==s&&s||this.initializeMutationListener(e,o),()=>{i.delete(o),0===i.size&&r.delete(e)}}getRegisteredNode(e){const n=this._nodes.get(e.getType());return void 0===n&&t(37,e.name),n}resolveRegisteredNodeAfterReplacements(t){for(;t.replaceWithKlass;)t=this.getRegisteredNode(t.replaceWithKlass);return t}initializeMutationListener(t,e){const n=this._editorState,o=Ac(n).get(e.getType());if(!o)return;const r=new Map;for(const t of o.keys())r.set(t,"created");r.size>0&&t(r,{dirtyLeaves:new Set,prevEditorState:n,updateTags:new Set(["registerMutationListener"])})}registerNodeTransformToKlass(t,e){const n=this.getRegisteredNode(t);return n.transforms.add(e),n}registerNodeTransform(t,e){const n=this.registerNodeTransformToKlass(t,e),o=[n],r=n.replaceWithKlass;if(null!=r){const t=this.registerNodeTransformToKlass(r,e);o.push(t)}return function(t,e){const n=Ac(t.getEditorState()),o=[];for(const t of e){const e=n.get(t);e&&o.push(e)}if(0===o.length)return;t.update(()=>{for(const t of o)for(const e of t.keys()){const t=Ys(e);t&&t.markDirty()}},null===t._pendingEditorState?{tag:xo}:void 0)}(this,o.map(t=>t.klass.getType())),()=>{o.forEach(t=>t.transforms.delete(e))}}hasNode(t){return this._nodes.has(t.getType())}hasNodes(t){return t.every(this.hasNode.bind(this))}dispatchCommand(t,...e){return Nl(this,t,...e)}getDecorators(){return this._decorators}getRootElement(){return this._rootElement}getKey(){return this._key}setRootElement(t){const e=this._rootElement;if(t!==e){const n=Cl(this._config.theme,"root"),o=this._pendingEditorState||this._editorState;if(this._rootElement=t,gs(this,e,t,o,{preserveUpdateQueue:!0}),null!==e&&(this._config.disableEvents||co(e),null!=n&&e.classList.remove(...n)),null!==t){const e=Pl(t),o=t.style;o.userSelect="text",o.whiteSpace="pre-wrap",o.wordBreak="break-word",t.setAttribute("data-lexical-editor","true"),this._window=e,this._dirtyType=2,gt(this),this._updateTags.add(xo),bi(this),this._config.disableEvents||function(t,e){const n=t.ownerDocument;Ln.set(t,n);let o=Kn.get(n);void 0===o&&(o={editors:new Set,hasShadowEditor:void 0},Kn.set(n,o)),o.editors.add(e),o.hasShadowEditor=void 0,t.__lexicalEditor=e;const r=no(t);r.push(zn.register(n));for(let n=0;n{so(t)||(io(t),(e.isEditable()||"click"===o)&&i(t,e))}:t=>{if(so(t))return;io(t);const n=e.isEditable();switch(o){case"cut":return n&&Nl(e,Tn,t);case"copy":return Nl(e,vn,t);case"paste":return n&&Nl(e,Je,t);case"dragstart":return n&&Nl(e,xn,t);case"dragover":return n&&Nl(e,Cn,t);case"dragend":return n&&Nl(e,Sn,t);case"focus":return n&&Nl(e,On,t);case"blur":return n&&Nl(e,Mn,t);case"drop":return n&&Nl(e,yn,t)}};r.push(Fn(t,o,s))}}(t,this),null!=n&&t.classList.add(...n)}else this._window=null,this._updateTags.add(xo),bi(this);Ni("root",this,!1,t,e)}}getElementByKey(t){return this._keyToDOMMap.get(t)||null}getEditorState(){return this._editorState}setEditorState(e,n){e.isEmpty()&&t(38);let o=e;o._readOnly&&(o=Ri(e),o._selection=e._selection?e._selection.clone():null),ht(this);const r=this._pendingEditorState,i=void 0!==n?n.tag:null;null===r||r.isEmpty()||(null!=i&&this._updateTags.add(i),bi(this)),this._pendingEditorState=o,this._dirtyType=2,this._dirtyElements.set("root",!1),this._compositionKey=null,this._slotsUsed=this._slotsUsed||e._slotsUsed,Ai(this,()=>{if(i&&this._updateTags.add(i),e._parsed)for(const[t,e]of o._nodeMap.entries())Pi(e)?this._dirtyElements.set(t,!0):this._dirtyLeaves.add(t)},{discrete:!this._updating||void 0})}parseEditorState(t,e){return function(t,e,n){const o=Wi(),r=ni,i=ri,s=oi,l=e._dirtyElements,c=e._dirtyLeaves,a=e._cloneNotNeeded,u=e._dirtyType;e._dirtyElements=new Map,e._dirtyLeaves=new Set,e._cloneNotNeeded=new Set,e._dirtyType=0,ni=o,ri=!1,oi=e,vs(null);try{const r=e._nodes;Ti(t.root,r),n&&n(),o._readOnly=!0,o._parsed=!0}catch(t){t instanceof Error&&e._onError(t)}finally{e._dirtyElements=l,e._dirtyLeaves=c,e._cloneNotNeeded=a,e._dirtyType=u,ni=r,ri=i,oi=s}return o}("string"==typeof t?JSON.parse(t):t,this,e)}read(...t){const[e,n]=1===t.length?["force-commit",t[0]]:t;"force-commit"===e&&bi(this);return("pending"===e?this._pendingEditorState||this._editorState:this.getEditorState()).read(n,{editor:this})}update(t,e){!function(t,e,n){t._updating?t._updates.push([e,n]):Mi(t,e,n)}(this,t,e)}focus(t,e={}){const n=this._rootElement;null!==n&&(n.setAttribute("autocapitalize","off"),Ai(this,()=>{const o=Kr(),r=nl();null!==o?o.dirty||ol(o.clone()):0!==r.getChildrenSize()&&("rootStart"===e.defaultSelection?r.selectStart():r.selectEnd()),Al("focus"),Dl(()=>{n.removeAttribute("autocapitalize"),t&&t()})}),null===this._pendingEditorState&&n.removeAttribute("autocapitalize"))}blur(){const t=this._rootElement;null!==t&&t.blur();const e=Jl(this._window);null!==e&&e.removeAllRanges()}isEditable(){return this._editable}setEditable(t){this._editable!==t&&(this._editable=t,Ni("editable",this,!0,t),this._slotsUsed&&this.update(()=>pi()))}toJSON(){return{editorState:this._editorState.toJSON()}}}Cs.version=Z;let Ss=null;function vs(t){Ss=t}const Ts=Symbol("INTERNAL_SKIP_AFTER_CLONE_FROM");let ks=1;function bs(){ks=1}function Ns(e,n){const o=Es(e,n);return void 0===o&&t(30,n),o}function Es(t,e){return t._nodes.get(e)}const ws="function"==typeof queueMicrotask?queueMicrotask:t=>{Promise.resolve().then(t)};function Os(t,e){const n=void 0!==e?e:(()=>{const e=t.getRootNode();return Bs(e)||ql(e)?cc(e):null})();if(!gc(n))return!1;if(n.hasAttribute("data-lexical-slot"))return!1;const o=Zs(n),r=n.nodeName;return po(o)&&("INPUT"===r||"TEXTAREA"===r||"true"===n.contentEditable&&null==Ps(n))}const Ms=Os;function As(t,e,n){const o=t.getRootElement();if(!o)return!1;try{if(!e||!o.contains(e)||!o.contains(n))return!1}catch(t){return!1}return Fs(e)===t&&t.read("latest",()=>!Os(e))}function Ds(t){return t instanceof Cs}function Fs(t){let e=t;for(;null!=e;){const t=Ps(e);if(Ds(t))return t;e=wl(e)}return null}function Ps(t){return t?t.__lexicalEditor:null}function Is(t){return L.test(t)?"rtl":K.test(t)?"ltr":null}function Ls(t){return er(t)||t.isToken()}function Ks(t){return Ls(t)||t.isSegmented()}function zs(t){return _c(t)&&3===t.nodeType}function Bs(t){return _c(t)&&9===t.nodeType}function Rs(t){let e=t;for(;null!=e;){if(zs(e))return e;e=e.firstChild}return null}function Ws(t,e,n){const o=z[e];if(null!==n&&(t&o)===(n&o))return t;let r=t^o;return"subscript"===e?r&=~z.superscript:"superscript"===e?r&=~z.subscript:"lowercase"===e?(r&=~z.uppercase,r&=~z.capitalize):"uppercase"===e?(r&=~z.lowercase,r&=~z.capitalize):"capitalize"===e&&(r&=~z.lowercase,r&=~z.uppercase),r}function $s(t){return Xo(t)||Yi(t)||Ki(t)}function Us(t,e){const n=function(){const t=Ss;return Ss=null,t}();if(null!=(e=e||n&&n.__key))return void(t.__key=e);fi(),di();const o=_i(),r=hi(),i=""+ks++;r._nodeMap.set(i,t),Pi(t)?o._dirtyElements.set(i,!0):o._dirtyLeaves.add(i),o._cloneNotNeeded.add(i),0===o._dirtyType&&(o._dirtyType=1),t.__key=i}function Hs(e){null!==ta(e)&&t(380,e.__key,String(ta(e)));const n=e.getParent();if(null!==n){const t=e.getWritable(),o=n.getWritable(),r=e.getPreviousSibling(),i=e.getNextSibling(),s=null!==i?i.__key:null,l=null!==r?r.__key:null,c=null!==r?r.getWritable():null,a=null!==i?i.getWritable():null;null===r&&(o.__first=s),null===i&&(o.__last=l),null!==c&&(c.__next=s),null!==a&&(a.__prev=l),t.__prev=null,t.__next=null,t.__parent=null,o.__size--}}const js=Hs;function Js(e){di(),ho(e)&&t(323,e.__key,e.__type);const n=e.getLatest(),o=null!==n.__parent?n.__parent:Zc(n)?n.__slotHost:null,r=hi(),i=_i(),s=r._nodeMap,l=i._dirtyElements;null!==o&&function(t,e,n){let o=t;for(;null!==o;){if(n.has(o))return;const t=e.get(o);if(void 0===t)break;n.set(o,!1),o=null!==t.__parent?t.__parent:Zc(t)?t.__slotHost:null}}(o,s,l);const c=n.__key;0===i._dirtyType&&(i._dirtyType=1),Pi(e)?l.set(c,!0):i._dirtyLeaves.add(c)}function Vs(t){fi();const e=_i(),n=e._compositionKey;if(t!==n){if(e._compositionKey=t,null!==n){const t=Ys(n);null!==t&&t.getWritable()}if(null!==t){const e=Ys(t);null!==e&&e.getWritable()}}}function qs(){if(ui())return null;return _i()._compositionKey}function Ys(t,e){const n=(e||hi())._nodeMap.get(t);return void 0===n?null:n}function Gs(t,e){const n=Qs(t,_i());return void 0!==n?Ys(n,e):null}function Xs(t,e,n){t[`__lexicalKey_${e._key}`]=n}function Qs(t,e){return t[`__lexicalKey_${e._key}`]}function Zs(t,e){let n=t;for(;null!=n;){const t=Gs(n,e);if(null!==t)return t;n=wl(n)}return null}function tl(t){const e=t._decorators,n=Object.assign({},e);return t._pendingDecorators=n,n}function el(t){return t.read(()=>nl().getTextContent())}function nl(){return hi()._nodeMap.get("root")}function ol(t){fi();const e=hi();null!==t&&(t.dirty=!0,t.setCachedNodes(null),ur(t)&&_i()._slotsUsed&&Or(t)),e._selection=t}function rl(){fi();ht(_i())}function il(t){const e=function(t,e){let n=t;for(;null!=n;){const t=Qs(n,e);if(void 0!==t)return t;n=wl(n)}return null}(t,_i());return null===e?null:Ys(e)}function sl(t){return/[\uD800-\uDBFF][\uDC00-\uDFFF]/g.test(t)}function ll(t){const e=[];for(let n=t;null!==n;n=n._parentEditor)e.push(n);return e}function cl(){return Math.random().toString(36).replace(/[^a-z]+/g,"").substring(0,5)}function al(t){return zs(t)?t.nodeValue:null}function ul(t,e,n){const o=Jl(Il(e));if(null===o)return;const r=nc(o,e._rootElement),i=r.anchorNode;let{anchorOffset:s,focusOffset:l}=r;if(null!==i){let e=al(i);const o=Zs(i);if(null!==e&&Xo(o)){if((e===A||e===F)&&n){const t=n.length;e=n,s=t,l=t}null!==e&&fl(o,e,s,l,t)}}}function fl(t,e,n,o,r){let i=t;if(i.isAttached()&&(r||!i.isDirty())){const s=i.isComposing();if(i.isToken()&&s)return;let c=e;if((s||r)&&(e.endsWith(A)&&(c=e.slice(0,-A.length)),r)){const t=F;let e;for(;-1!==(e=c.indexOf(t));)c=c.slice(0,e)+c.slice(e+t.length),null!==n&&n>e&&(n=Math.max(e,n-t.length)),null!==o&&o>e&&(o=Math.max(e,o-t.length))}const u=i.getTextContent();if(r||c!==u){const e=Kr();if(""===c){if(Vs(null),a||l||d)i.remove();else{const t=_i();dl(i,"",e),setTimeout(()=>{t.update(()=>{i.isAttached()&&""===i.getTextContent()&&i.remove()})},20)}return}const r=i.getParent(),u=zr(),f=i.getTextContentSize(),h=qs(),g=i.getKey();if(i.isToken()&&!s||null!==h&&g===h&&!s||ur(u)&&(null!==r&&!r.canInsertTextBefore()&&0===u.anchor.offset||u.anchor.key===t.__key&&0===u.anchor.offset&&!i.canInsertTextBefore()&&!s||u.focus.key===t.__key&&u.focus.offset===f&&!i.canInsertTextAfter()&&!s))return void i.markDirty();if(!ur(e)||null===n||null===o)return void dl(i,c,e);if(e.setTextNodeRange(i,n,i,o),i.isSegmented()){const t=Go(i.getTextContent());i.replace(t),i=t}dl(i,c,e)}}}function dl(t,e,n){if(t.setTextContent(e),ur(n)){const e=t.getKey();let o=!1;for(const r of["anchor","focus"]){const i=n[r];"text"===i.type&&i.key===e&&(i.offset=Ka(t,i.offset,"clamp"),o=!0)}o&&(n._cachedNodes=null,n._cachedIsBackward=null)}}function hl(t,e,n){const o=e[n]||!1;return"any"===o||o===t[n]}function gl(t,e){return hl(t,e,"altKey")&&hl(t,e,"ctrlKey")&&hl(t,e,"shiftKey")&&hl(t,e,"metaKey")}function _l(t,e,n){if(!gl(t,n))return!1;if(t.key.toLowerCase()===e.toLowerCase())return!0;if(e.length>1)return!1;if(1===t.key.length&&t.key.charCodeAt(0)<=127)return!1;if(t.code.startsWith("Digit")&&/^\d$/.test(e))return t.code===`Digit${e}`;const o="Key"+e.toUpperCase();return t.code===o}const pl={ctrlKey:!r,metaKey:r},yl={altKey:r,ctrlKey:!r};function ml(t){return"Backspace"===t.key}function xl(t){const e=nl();if(ur(t)){const e=t.anchor,n=t.focus,o=e.getNode();if(Bi(o))return e.set(o.getKey(),0,"element"),n.set(o.getKey(),o.getChildrenSize(),"element"),It(t),t;const r=o.getTopLevelElementOrThrow(),i=r.getParent();if(null===i)return Pi(r)&&(e.set(r.getKey(),0,"element"),n.set(r.getKey(),r.getChildrenSize(),"element"),It(t)),t;const s=i;return e.set(s.getKey(),0,"element"),n.set(s.getKey(),s.getChildrenSize(),"element"),It(t),t}{const t=e.select(0,e.getChildrenSize());return ol(It(t)),t}}function Cl(t,e){void 0===t.__lexicalClassNameCache&&(t.__lexicalClassNameCache={});const n=t.__lexicalClassNameCache,o=n[e];if(void 0!==o)return o;const r=t[e];if("string"==typeof r){const t=ku(r);return n[e]=t,t}return r}function Sl(e,n,o,r,i){if(0===o.size)return;const s=r.__type,l=r.__key,c=n.get(s);void 0===c&&t(33,s);const a=c.klass;let u=e.get(a);void 0===u&&(u=new Map,e.set(a,u));const f=u.get(l),d="destroyed"===f&&"created"===i;(void 0===f||d)&&u.set(l,d?"updated":i)}function vl(t){const e=t.getType(),n=hi();if(n._readOnly){const t=Ac(n).get(e);return t?Array.from(t.values()):[]}const o=n._nodeMap,r=[];for(const[,n]of o)n instanceof t&&n.__type===e&&n.isAttached()&&r.push(n);return r}function Tl(t,e,n){const o=t.getParent();let r=n,i=t;return null!==o&&(e&&0===n?(r=i.getIndexWithinParent(),i=o):e||n!==i.getChildrenSize()||(r=i.getIndexWithinParent()+1,i=o)),i.getChildAtIndex(e?r-1:r)}function kl(t,e){const n=t.offset;if("element"===t.type){return Tl(t.getNode(),e,n)}{const o=t.getNode();if(e&&0===n||!e&&n===o.getTextContentSize()){const t=e?o.getPreviousSibling():o.getNextSibling();return null===t?Tl(o.getParentOrThrow(),e,o.getIndexWithinParent()+(e?0:1)):t}}return null}function bl(t){const e=Il(t).event,n=e&&e.inputType;return"insertFromPaste"===n||"insertFromPasteAsQuotation"===n}function Nl(t,e,...n){return Ei(t,e,n[0],t)}function El(e,n){const o=e._keyToDOMMap.get(n);return void 0===o&&t(75,n),o}function wl(t){const e=t.assignedSlot||t.parentElement;if(null!==e)return e;const n=t.parentNode;return ql(n)?n.host:null}function Ol(t){return Bs(t)?t:gc(t)?t.ownerDocument:null}function Ml(t){return _i()._updateTags.has(t)}function Al(t){fi();_i()._updateTags.add(t)}function Dl(t){fi();_i()._deferred.push(t)}function Fl(t,e){let n=t.getParent();for(;null!==n;){if(n.is(e))return!0;n=n.getParent()}return!1}function Pl(t){const e=Ol(t);return e?e.defaultView:null}function Il(e){const n=e._window;return null===n&&t(78),n}function Ll(t){return Pi(t)&&t.isInline()||Ki(t)&&t.isInline()}function Kl(t){let e=t.getLatest();for(;null!==e;){if(null!==ta(e)&&Pi(e))return e;const t=e.getParentOrThrow();if(Bl(t))return t;e=t}return e}function zl(t){return Pi(t)&&t.isShadowRoot()}function Bl(t){return Bi(t)||zl(t)}function Rl(t,e=!1){const n=t.constructor.clone(t,Ts);return Us(n,null),n.afterCloneFrom(t),e||n.resetOnCopyNodeFrom(t),n}function Wl(e){const n=_i(),o=e.getType(),r=Es(n,o);void 0===r&&t(200,e.constructor.name,o);const{replace:i,replaceWithKlass:s}=r;if(null!==i){const n=i(e),r=n.constructor;return null!==s?n instanceof s||t(201,s.name,s.getType(),r.name,r.getType(),e.constructor.name,o):n instanceof e.constructor&&r!==e.constructor||t(202,r.name,r.getType(),e.constructor.name,o),n.__key===e.__key&&t(203,e.constructor.name,o,r.name,r.getType()),n}return e}function $l(e,n){!Bi(e.getParent())||Pi(n)||Ki(n)||t(99)}function Ul(e){const n=Ys(e);return null===n&&t(63,e),n}function Hl(t){if(!t||t.isInline())return!1;if(Ki(t))return!0;if(Pi(t)){if(t.isShadowRoot()){const e=t.getParent();return!(Pi(e)&&e.isShadowRoot())}return!t.canBeEmpty()}return!1}function jl(t,e,n){n.style.removeProperty("caret-color"),e._blockCursorElement=null;const o=t.parentElement;null!==o&&o.removeChild(t)}function Jl(t){return n?(t||window).getSelection():null}function Vl(t){const e=Pl(t);return e?e.getSelection():null}function ql(t){return pc(t)&&"host"in t}const Yl=[];function Gl(t){const e=t.getRootNode();if(e===t||!ql(e))return Yl;const n=[e];let o=e.host;for(;;){const t=o.getRootNode();if(t===o||!ql(t))break;n.push(t),o=t.host}return n}function*Xl(t){const e=[t];let n;for(;n=e.pop();){yield*n.querySelectorAll('[data-lexical-editor="true"]');const t=(Bs(n)?n:n.ownerDocument).createTreeWalker(n,NodeFilter.SHOW_ELEMENT);let o;for(;o=t.nextNode();)o.shadowRoot&&e.push(o.shadowRoot)}}function Ql(t){return null!==t?t.ownerDocument:document}function Zl(){const t=mi();return Ql(null!==t?t._rootElement:null)}function tc(t,e){if(null===e||"function"!=typeof t.getComposedRanges)return null;const n=Gl(e);if(0===n.length)return null;const o=t.getComposedRanges;try{const e=o.call(t,{shadowRoots:n})[0];if(void 0!==e)return e}catch(t){}try{const e=o.apply(t,n)[0];if(void 0!==e)return e}catch(t){}return null}function ec(t,e){const n=tc(t,e);if(null!==n){const t=rc(n);if(null!==t)return t}return t.rangeCount>0?t.getRangeAt(0):null}function nc(t,e){const n=tc(t,e);return null===n?t:ic(n,sc(t))}function oc(t,e){const n=tc(t,e);if(null===n)return{points:t,range:t.rangeCount>0?t.getRangeAt(0):null};const o=rc(n)??(t.rangeCount>0?t.getRangeAt(0):null);return{points:ic(n,sc(t)),range:o}}function rc(t){const e=t.startContainer.ownerDocument;if(null===e)return null;const n=e.createRange();try{return n.setStart(t.startContainer,t.startOffset),n.setEnd(t.endContainer,t.endOffset),n}catch(t){return null}}function ic(t,e){const{startContainer:n,startOffset:o,endContainer:r,endOffset:i}=t;return"backward"===e?{anchorNode:r,anchorOffset:i,direction:e,focusNode:n,focusOffset:o}:{anchorNode:n,anchorOffset:o,direction:e,focusNode:r,focusOffset:i}}function sc(t){return t.direction}function lc(t){const e=t.getRootNode();return Bs(e)||ql(e)?e.activeElement:null}function cc(t){let e=t.activeElement;for(;null!==e&&null!==e.shadowRoot;){const t=e.shadowRoot.activeElement;if(null===t)break;e=t}return e}function ac(t){const e=t.target;if(null!==e&&gc(e)&&null!==e.shadowRoot&&"function"==typeof t.composedPath){const e=t.composedPath();if(e.length>0)return e[0]}return e}function uc(e,n){let o=e.getChildAtIndex(n);null==o&&(o=e),Bl(e)&&t(102);const r=e=>{const n=e.getParentOrThrow(),i=Bl(n),s=e!==o||i?Rl(e):e;if(i)return Pi(e)&&Pi(s)||t(133),e.insertAfter(s),[e,s,s];{const[t,o,i]=r(n),l=e.getNextSiblings();return i.append(s,...l),[t,o,s]}},[i,s]=r(o);return[i,s]}function fc(t){return gc(t)&&"A"===t.tagName}function dc(t){return gc(t)&&"TR"===t.tagName}function hc(t){return gc(t)&&("TD"===t.tagName||"TH"===t.tagName)}function gc(t){return _c(t)&&1===t.nodeType}function _c(t){return"object"==typeof t&&null!==t&&"nodeType"in t&&"number"==typeof t.nodeType}function pc(t){return _c(t)&&11===t.nodeType}const yc=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|mark|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var|#text)$/i;function mc(t){return!(!gc(t)||!t.style.display.startsWith("inline"))||yc.test(t.nodeName)}const xc=/^(address|article|aside|blockquote|canvas|dd|div|dl|dt|fieldset|figcaption|figure|footer|form|h1|h2|h3|h4|h5|h6|header|hr|li|main|nav|noscript|ol|p|pre|section|table|td|tfoot|ul|video)$/i;function Cc(t){return(!gc(t)||!t.style.display.startsWith("inline"))&&xc.test(t.nodeName)}function Sc(t){if(Ki(t)&&!t.isInline())return!0;if(!Pi(t)||Bl(t))return!1;const e=t.getFirstChild(),n=null===e||Yi(e)||Xo(e)||e.isInline();return!t.isInline()&&!1!==t.canBeEmpty()&&n}function vc(){return _i()}function Tc(t=vc()){return t._config.dom||ps}function kc(e,n,o=vc()){const r=Tc(o).$getDOMSlot(e,n,o);return Pi(e)&&(Ec(r)||t(344,e.getKey(),e.getType())),r}function bc(t,e,n,o){const r=t.read("latest",()=>{const o=Ys(e);return null!==o?function(t,e,n=vc()){const o=sa(t,e);if(null===o)return null;const r=n.getElementByKey(o.getKey());return null!==r?r.parentElement:null}(o,n,t):null});return null!==r&&(r.parentElement!==o&&o.appendChild(r),r.style.display=""),r}function Nc(t,e,n){n.style.display="none";const o=t.getElementByKey(e);null!==o&&n.parentElement!==o&&o.insertBefore(n,o.firstChild)}function Ec(t){return t instanceof G}function wc(t,e,n=vc()){return Rs(kc(t,e,n).element)}const Oc=new WeakMap,Mc=new Map;function Ac(e){if(!e._readOnly&&e.isEmpty())return Mc;e._readOnly||t(192);let n=Oc.get(e);return n||(n=function(t){const e=new Map;for(const[n,o]of t._nodeMap){const t=o.__type;let r=e.get(t);r||(r=new Map,e.set(t,r)),r.set(n,o)}return e}(e),Oc.set(e,n)),n}function Dc(t){const e=t.constructor.clone(t,Ts);return e.afterCloneFrom(t),e}function Fc(t){return(e=Dc(t))[fo]=!0,e;var e}function Pc(t,e){const n=t.getAttribute("data-lexical-indent");if(null!==n){const t=parseInt(n,10);if(Number.isFinite(t)&&t>=0)return void e.setIndent(t)}const o=parseInt(t.style.paddingInlineStart,10)||0,r=Math.round(o/40);e.setIndent(r)}function Ic(t,e){const n=e.getAttribute("dir");return"ltr"===n||"rtl"===n?t.setDirection(n):t}function Lc(t,e){const n=e.style.textAlign;return n&&n in R?t.setFormat(n):t}function Kc(t,e){t.__lexicalUnmanaged=!0,e&&void 0!==e.captureSelection&&(t.__lexicalCapturedSelection=e.captureSelection)}function zc(t){return!0===t.__lexicalUnmanaged}function Bc(t,e=vc()){const n=e.isEditable();t.contentEditable=n?"true":"false",n?t.__lexicalEditor=e:delete t.__lexicalEditor}function Rc(t,e){let n=t;for(;null!=n;){if(!0===n.__lexicalCapturedSelection)return!0;if(gc(n)&&n.hasAttribute("data-lexical-slot"))return!1;if(void 0!==Qs(n,e))return!1;n=wl(n)}return!1}function Wc(t,e){return function(t,e){return Object.prototype.hasOwnProperty.call(t,e)}(t,e)&&t[e]!==_o[e]}const $c=new WeakMap,Uc=Symbol("lexical.synthesizedGetType");function Hc(e){const n=$c.get(e);if(n)return n;const o=null!=e.prototype&&j in e.prototype?e.prototype[j]():void 0,r=function(e){if(!(e===_o||e.prototype instanceof _o)){let n="",o="";try{n=e.getType()}catch(t){}try{Cs.version&&(o=JSON.parse(Cs.version))}catch(t){}t(290,e.name,n,o)}return e===Li||e===Fi||e===_o}(e),i=!r&&Wc(e,"getType")?e.getType:void 0,s=i&&!(Uc in i)?i.call(e):void 0;let l,c=s;if(o)if(s)l=o[s];else{for(const[t,e]of Object.entries(o))c=t,l=e;if(!l)for(const t of Object.getOwnPropertySymbols(o)){const e=o[t];if(e){l=e;break}}}if(!r&&c){if(!Wc(e,"getType")){const t=e,n=function(){return this!==t?_o.getType.call(this):c};n[Uc]=!0,e.getType=n}if(Wc(e,"clone")||(e.clone=(t,n)=>{vs(t);const o=new e;return n!==Ts&&o.afterCloneFrom(t),o}),Wc(e,"importJSON")||(e.importJSON=l&&l.$importJSON||(t=>(new e).updateFromJSON(t))),!Wc(e,"importDOM")&&l){const{importDOM:t}=l;t&&(e.importDOM=()=>t)}}const a={klass:e,ownNodeConfig:l,ownNodeType:c};return $c.set(e,a),a}function*jc(t){for(let e=t;e&&(e===_o||po(e.prototype));){const t=Hc(e);yield t,e=t.ownNodeConfig&&t.ownNodeConfig.extends||Gc(e)}}function Jc(t){const e=new Map,n=new Map;for(const o of t){const{ownNodeType:t}=Hc(o);t&&(n.set(t,o),e.set(t,new Set))}for(const[t,o]of n)for(const{ownNodeType:n}of jc(o)){const o=n&&e.get(n);o&&o.add(t)}return e}function Vc(t){const e=vc();fi();return new(e.resolveRegisteredNodeAfterReplacements(e.getRegisteredNode(t)).klass)}const qc=(t,e)=>{let n=t;for(;null!=n&&!Bi(n);){if(e(n))return n;n=n.getParent()}return null};function Yc(e,n){const o=[];let r=e.__first;for(;null!==r;){const e=null===n?Ys(r):n.get(r);null==e&&t(174),o.push(r),r=e.__next}return o}function Gc(t){const e=Object.getPrototypeOf(t);if("function"==typeof e&&e!==Function.prototype)return e;const n=t.prototype&&Object.getPrototypeOf(t.prototype);return n?n.constructor:null}const Xc=new Map;function Qc(t){return Pi(t)||Ki(t)}function Zc(t){return Pi(t)||Ki(t)}function ta(t){const e=t.getLatest();return Zc(e)?e.__slotHost:null}function ea(e){const n=ta(e);if(null===n)return null;const o=Ys(n);return Pi(o)||Ki(o)||t(370),o}function na(t){const e=ea(t);if(null===e)return null;const n=t.getLatest().__key;for(const[t,o]of ra(e))if(o===n)return t;return null}function oa(t){let e=t.getLatest();for(;null!==e;){if(null!==ta(e))return e;e=e.getParent()}return null}function ra(t){const e=t.getLatest();return Qc(e)&&null!==e.__slots?e.__slots:Xc}function ia(t){return Array.from(ra(t).keys())}function sa(t,e){const n=ra(t).get(e);return void 0===n?null:Ys(n)}const la=["__proto__","constructor","prototype"],ca=Symbol("slotMapOwner");function aa(t){let e=t.__slots;return null!==e&&e[ca]===t||(e=new Map(e),e[ca]=t,t.__slots=e),e}const ua=new WeakMap,fa=[];function da(t){for(const{ownNodeConfig:e}of jc(t)){const t=e&&e.slots;if(t)return t}return fa}function ha(t){let e="";for(const n of ia(t)){const o=sa(t,n);null!==o&&(e+=o.getTextContent())}return e}function ga(t,e,n){const o=n.get(t),r=n.get(e);return void 0!==o?void 0!==r?o-r:-1:void 0!==r?1:te?1:0}function _a(e){const n=e.__slots;if(null===n||n.size<2)return;const o=function(e){let n=ua.get(e);if(void 0===n){const o=da(e),r=new Map;for(const n of o)la.includes(n)&&t(371,e.name,n),r.has(n)&&t(372,e.name,n),r.set(n,r.size);n=r,ua.set(e,n)}return n}(e.constructor);let r=null,i=!0;for(const t of n.keys()){if(null!==r&&ga(r,t,o)>0){i=!1;break}r=t}if(i)return;const s=Array.from(n).sort(([t],[e])=>ga(t,e,o));n.clear();for(const[t,e]of s)n.set(t,e)}function pa(e,n,o){"__proto__"!==n&&"constructor"!==n&&"prototype"!==n||t(373,n);const r=e.getLatest();if(null!==r.__slots&&r.__slots.get(n)===o.getLatest().__key)return r;(!Pi(o)&&!Ki(o)||o.isInline())&&t(374,o.__key);const i=e.getWritable(),s=aa(i),l=s.get(n);void 0!==l&&xa(l);const c=o.getWritable(),a=ea(c);if(null!==a){const t=na(c);null!==t&&aa(a.getWritable()).delete(t),c.__slotHost=null}return Hs(c),c.__slotHost=i.__key,s.set(n,c.__key),_a(i),function(){const t=vc();t._slotsUsed=!0,t._pendingEditorState&&(t._pendingEditorState._slotsUsed=!0)}(),i}function ya(t,e){const n=t.getWritable();if(null===n.__slots)return n;const o=n.__slots.get(e);return void 0!==o&&(xa(o),aa(n).delete(e)),n}function ma(t,e){}function xa(e){const n=Ys(e);if(null===n)return;const o=n.getWritable();Zc(o)||t(377,e),o.__slotHost=null,o.remove()}const Ca={next:"previous",previous:"next"};class Sa{origin;constructor(t){this.origin=t}[Symbol.iterator](){return qa({hasNext:Ma,initial:this.getAdjacentCaret(),map:t=>t,step:t=>t.getAdjacentCaret()})}getAdjacentCaret(){return Ia(this.getNodeAtCaret(),this.direction)}getSiblingCaret(){return Ia(this.origin,this.direction)}remove(){const t=this.getNodeAtCaret();return t&&t.remove(),this}replaceOrInsert(t,e){const n=this.getNodeAtCaret();return t.is(this.origin)||t.is(n)||(null===n?this.insert(t):n.replace(t,e)),this}splice(e,n,o="next"){const r=o===this.direction?n:Array.from(n).reverse();let i=this;const s=this.getParentAtCaret(),l=new Map;for(let t=i.getAdjacentCaret();null!==t&&l.size0){const n=i.getNodeAtCaret();if(n)if(l.delete(n.getKey()),l.delete(e.getKey()),n.is(e)||i.origin.is(e));else{const t=e.getParent();t&&t.is(s)&&e.remove(),n.replace(e)}else null===n&&t(263,Array.from(l).join(" "))}else i.insert(e);i=Ia(e,this.direction)}for(const t of l.values())t.remove();return this}}class va extends Sa{type="child";getLatest(){const t=this.origin.getLatest();return t===this.origin?this:Ba(t,this.direction)}getParentCaret(t="root"){return Ia(ba(this.getParentAtCaret(),t),this.direction)}getFlipped(){const t=ka(this.direction);return Ia(this.getNodeAtCaret(),t)||Ba(this.origin,t)}getParentAtCaret(){return this.origin}getChildCaret(){return this}isSameNodeCaret(t){return t instanceof va&&this.direction===t.direction&&this.origin.is(t.origin)}isSamePointCaret(t){return this.isSameNodeCaret(t)}}const Ta={root:Bi,shadowRoot:Bl};function ka(t){return Ca[t]}function ba(t,e="root"){return null===t||Ta[e](t)?null:null===ta(t)?t:null}class Na extends Sa{type="sibling";getLatest(){const t=this.origin.getLatest();return t===this.origin?this:Ia(t,this.direction)}getSiblingCaret(){return this}getParentAtCaret(){return this.origin.getParent()}getChildCaret(){return Pi(this.origin)?Ba(this.origin,this.direction):null}getParentCaret(t="root"){return Ia(ba(this.getParentAtCaret(),t),this.direction)}getFlipped(){const t=ka(this.direction);return Ia(this.getNodeAtCaret(),t)||Ba(this.origin.getParentOrThrow(),t)}isSamePointCaret(t){return t instanceof Na&&this.direction===t.direction&&this.origin.is(t.origin)}isSameNodeCaret(t){return(t instanceof Na||t instanceof Ea)&&this.direction===t.direction&&this.origin.is(t.origin)}}class Ea extends Sa{type="text";offset;constructor(t,e){super(t),this.offset=e}getLatest(){const t=this.origin.getLatest();return t===this.origin?this:La(t,this.direction,this.offset)}getParentAtCaret(){return this.origin.getParent()}getChildCaret(){return null}getParentCaret(t="root"){return Ia(ba(this.getParentAtCaret(),t),this.direction)}getFlipped(){return La(this.origin,ka(this.direction),this.offset)}isSamePointCaret(t){return t instanceof Ea&&this.direction===t.direction&&this.origin.is(t.origin)&&this.offset===t.offset}isSameNodeCaret(t){return(t instanceof Na||t instanceof Ea)&&this.direction===t.direction&&this.origin.is(t.origin)}getSiblingCaret(){return Ia(this.origin,this.direction)}}function wa(t){return t instanceof Ea}function Oa(t){return t instanceof Sa}function Ma(t){return t instanceof Na}function Aa(t){return t instanceof va}const Da={next:class extends Ea{direction="next";getNodeAtCaret(){return this.origin.getNextSibling()}insert(t){return this.origin.insertAfter(t),this}},previous:class extends Ea{direction="previous";getNodeAtCaret(){return this.origin.getPreviousSibling()}insert(t){return this.origin.insertBefore(t),this}}},Fa={next:class extends Na{direction="next";getNodeAtCaret(){return this.origin.getNextSibling()}insert(t){return this.origin.insertAfter(t),this}},previous:class extends Na{direction="previous";getNodeAtCaret(){return this.origin.getPreviousSibling()}insert(t){return this.origin.insertBefore(t),this}}},Pa={next:class extends va{direction="next";getNodeAtCaret(){return this.origin.getFirstChild()}insert(t){return this.origin.splice(0,0,[t]),this}},previous:class extends va{direction="previous";getNodeAtCaret(){return this.origin.getLastChild()}insert(t){return this.origin.splice(this.origin.getChildrenSize(),0,[t]),this}}};function Ia(t,e){return t?new Fa[e](t):null}function La(t,e,n){return t?new Da[e](t,Ka(t,n)):null}function Ka(t,n,o="error"){const r=t.getTextContentSize();let i="next"===n?r:"previous"===n?0:n;return(i<0||i>r)&&("clamp"!==o&&e(284,String(n),String(r),t.getKey()),i=i<0?0:r),i}function za(t,e){return new Ua(t,e)}function Ba(t,e){return Pi(t)?new Pa[e](t):null}function Ra(t){return t&&t.getChildCaret()||t}function Wa(t){return t&&Ra(t.getAdjacentCaret())}class $a{type="node-caret-range";direction;anchor;focus;constructor(t,e,n){this.anchor=t,this.focus=e,this.direction=n}getLatest(){const t=this.anchor.getLatest(),e=this.focus.getLatest();return t===this.anchor&&e===this.focus?this:new $a(t,e,this.direction)}isCollapsed(){return this.anchor.isSamePointCaret(this.focus)}getTextSlices(){const t=t=>{const e=this[t].getLatest();return wa(e)?function(t,e){const{direction:n,origin:o}=t,r=Ka(o,"focus"===e?ka(n):n);return za(t,r-t.offset)}(e,t):null},e=t("anchor"),n=t("focus");if(e&&n){const{caret:t}=e,{caret:o}=n;if(t.isSameNodeCaret(o))return[za(t,o.offset-t.offset),null]}return[e,n]}iterNodeCarets(t="root"){const e=wa(this.anchor)?this.anchor.getSiblingCaret():this.anchor.getLatest(),n=this.focus.getLatest(),o=wa(n),r=e=>e.isSameNodeCaret(n)?null:Wa(e)||e.getParentCaret(t);return qa({hasNext:t=>null!==t&&!(o&&n.isSameNodeCaret(t)),initial:e.isSameNodeCaret(n)?null:r(e),map:t=>t,step:r})}[Symbol.iterator](){return this.iterNodeCarets("root")}}class Ua{type="slice";caret;distance;constructor(t,e){this.caret=t,this.distance=e}getSliceIndices(){const{distance:t,caret:{offset:e}}=this,n=e+t;return n{let n;for(let o=c;on.has(t.getKey())&&Sc(t));if(f&&ia(f).length>0)return null;return u&&f?[u,f]:null}(d,h,a);if(g){const[t,e]=g;Ba(t,"previous").splice(0,e.getChildren());let n=e.getParent();for(e.remove(!0);n&&n.isEmpty();){const t=n;n=n.getParent(),t.remove(!0)}}else if(h){const t=function(t){if(Aa(t)){const e=t.origin;if(Sc(e))return e}else{const e=t.getParentAtCaret();if(e&&Sc(e))return e}return null}(h),e=t&&t.getParent(),n=t&&t.getParents().findLast(zl);if(t&&e&&!Bi(e)&&t.isEmpty()&&a.has(t.getKey())&&0===ia(t).length&&(!n||a.has(n.getKey()))){t.remove(!0);let n=e;for(;n&&!Bi(n)&&n.isEmpty();){const t=n.getParent();if(t&&Bi(t)&&t.getChildrenSize()<=1)break;const e=n;n=t,e.remove(!0)}}}const _=[d,h,...l,...c].find(lu);if(_){return Ja(fu(au(_),e.direction))}t(269,JSON.stringify(l.map(t=>t.origin.__key)))}function au(t){const e=function(t){let e=t;for(;Aa(e);){const t=Wa(e);if(!Aa(t))break;e=t}return e}(t.getLatest()),{direction:n}=e;if(Xo(e.origin))return wa(e)?e:La(e.origin,n,n);const o=e.getAdjacentCaret();return Ma(o)&&Xo(o.origin)?La(o.origin,n,ka(n)):e}function uu(t){return wa(t)&&t.offset!==Ka(t.origin,t.direction)}function fu(t,e){return t.direction===e?t:t.getFlipped()}function du(t,e){return t.direction===e?t:Va(fu(t.focus,e),fu(t.anchor,e))}function hu(t,e,n){let o=Ba(t,"next");for(let t=0;t0||!i&&n.canBeEmpty()&&r(n,"last"))&&s.insert(e(n).splice(0,0,o))}return s}function mu(e,n,o){let r=fu(n,"next");wa(r)&&(0===r.offset?r=Ia(r.origin,"previous").getFlipped():r.offset===r.origin.getTextContentSize()&&(r=Ia(r.origin,"next"))),r.origin.is(e)&&(Ma(r)||t(342,e.getKey(),e.getType()),r=iu(r)),(e.is(r.getNodeAtCaret())||e.is(r.getFlipped().getNodeAtCaret()))&&e.remove(!0);for(let t=r;t;t=yu(t,o))r=t;return wa(r)&&t(283),r.insert(e.isInline()?es().append(e):e),fu(Ia(e.getLatest(),"next"),n.direction)}function xu(t){return t}function Cu(...t){return t}function Su(t,e){return[t,e]}function vu(t){return t}function Tu(t,e){if(!e||t===e)return t;for(const n in e)if(t[n]!==e[n])return{...t,...e};return t}function ku(...t){const e=[];for(const n of t)if(n&&"string"==typeof n)for(const[t]of n.matchAll(/\S+/g))e.push(t);return e}function bu(t,...e){const n=ku(...e);n.length>0&&t.classList.add(...n)}function Nu(t,...e){const n=ku(...e);n.length>0&&t.classList.remove(...n)}function Eu(...t){return()=>{for(let e=t.length-1;e>=0;e--)t[e]();t.length=0}}function wu(t,e,n){return Eu(...Object.entries(e).map(([e,o])=>Fn(t,e,o,n)))}export{Al as $addUpdateTag,Wl as $applyNodeReplacement,gi as $assumeActiveEditor,tu as $caretFromPoint,ru as $caretRangeFromSelection,Dc as $cloneWithProperties,Fc as $cloneWithPropertiesEphemeral,Ya as $comparePointCaretNext,Rl as $copyNode,Vc as $create,Yc as $createChildrenArray,qi as $createLineBreakNode,Pr as $createNodeSelection,es as $createParagraphNode,or as $createPoint,Fr as $createRangeSelection,Ir as $createRangeSelectionFromDom,tr as $createTabNode,Go as $createTextNode,ja as $extendCaretToRange,qc as $findMatchingParent,_r as $formatText,pi as $fullReconcile,qr as $generateNodesFromRawText,Wa as $getAdjacentChildCaret,kl as $getAdjacentNode,gu as $getAdjacentSiblingOrParentSiblingCaret,fu as $getCaretInDirection,Va as $getCaretRange,du as $getCaretRangeInDirection,yr as $getCharacterOffsets,Ba as $getChildCaret,hu as $getChildCaretAtIndex,Ra as $getChildCaretOrSelf,Ja as $getCollapsedCaretRange,Za as $getCommonAncestor,Ga as $getCommonAncestorResultBranchOrder,kc as $getDOMSlot,wc as $getDOMTextNode,Zl as $getDocument,vc as $getEditor,Tc as $getEditorDOMRenderConfig,Zs as $getNearestNodeFromDOMNode,Kl as $getNearestRootOrShadowRoot,Ys as $getNodeByKey,Ul as $getNodeByKeyOrThrow,Gs as $getNodeFromDOMNode,zr as $getPreviousSelection,nl as $getRoot,Kr as $getSelection,Ia as $getSiblingCaret,sa as $getSlot,oa as $getSlotFrame,ea as $getSlotHost,na as $getSlotNameWithinHost,ia as $getSlotNames,xt as $getState,Ct as $getStateChange,Yr as $getTextContent,Ka as $getTextNodeOffset,La as $getTextPointCaret,za as $getTextPointCaretSlice,bt as $getWritableNodeState,Fl as $hasAncestor,Ml as $hasUpdateTag,mu as $insertNodeToNearestRootAtCaret,Jr as $insertNodes,Ar as $isBlockElementNode,Aa as $isChildCaret,Ki as $isDecoratorNode,Ui as $isEditorState,Ec as $isElementDOMSlot,Pi as $isElementNode,uu as $isExtendableTextPointCaret,Ll as $isInlineElementOrDecoratorNode,Ro as $isInlineFormattable,$s as $isLeafNode,po as $isLexicalNode,Yi as $isLineBreakNode,Oa as $isNodeCaret,dr as $isNodeSelection,ns as $isParagraphNode,ur as $isRangeSelection,Bi as $isRootNode,Bl as $isRootOrShadowRoot,Os as $isSelectionCapturedInDecoratorInput,zl as $isShadowRootNode,Ma as $isSiblingCaret,Zc as $isSlotChild,Qc as $isSlotHost,er as $isTabNode,Xo as $isTextNode,wa as $isTextPointCaret,Ha as $isTextPointCaretSlice,Ks as $isTokenOrSegmented,Ls as $isTokenOrTab,Bc as $markSlotEditable,Hl as $needsBlockCursorBeside,vl as $nodesOfType,au as $normalizeCaret,It as $normalizeSelection__EXPERIMENTAL,Dl as $onUpdate,vi as $parseSerializedNode,Hs as $removeFromParent,ya as $removeSlot,cu as $removeTextFromCaretRange,iu as $rewindSiblingCaret,xl as $selectAll,Vs as $setCompositionKey,Ic as $setDirectionFromDOM,Lc as $setFormatFromDOM,eu as $setPointFromCaret,ol as $setSelection,nu as $setSelectionFromCaretRange,pa as $setSlot,St as $setState,gr as $setTextFormat,yu as $splitAtPointCaretNext,uc as $splitNode,jr as $updateDOMSelection,ou as $updateRangeSelectionFromCaretRange,ji as ArtificialNode__DO_NOT_USE,ze as BEFORE_INPUT_COMMAND,Mn as BLUR_COMMAND,En as CAN_REDO_COMMAND,wn as CAN_UNDO_COMMAND,s as CAN_USE_BEFORE_INPUT,n as CAN_USE_DOM,bn as CLEAR_EDITOR_COMMAND,Nn as CLEAR_HISTORY_COMMAND,Ke as CLICK_COMMAND,vo as COLLABORATION_TAG,hs as COMMAND_PRIORITY_BEFORE_CRITICAL,as as COMMAND_PRIORITY_BEFORE_EDITOR,ds as COMMAND_PRIORITY_BEFORE_HIGH,us as COMMAND_PRIORITY_BEFORE_LOW,fs as COMMAND_PRIORITY_BEFORE_NORMAL,cs as COMMAND_PRIORITY_CRITICAL,rs as COMMAND_PRIORITY_EDITOR,ls as COMMAND_PRIORITY_HIGH,is as COMMAND_PRIORITY_LOW,ss as COMMAND_PRIORITY_NORMAL,We as COMPOSITION_END_COMMAND,wo as COMPOSITION_END_TAG,Re as COMPOSITION_START_COMMAND,Eo as COMPOSITION_START_TAG,je as CONTROLLED_TEXT_INSERTION_COMMAND,vn as COPY_COMMAND,Tn as CUT_COMMAND,So as CUT_TAG,ps as DEFAULT_EDITOR_DOM_CONFIG,$e as DELETE_CHARACTER_COMMAND,Ye as DELETE_LINE_COMMAND,qe as DELETE_WORD_COMMAND,Sn as DRAGEND_COMMAND,Cn as DRAGOVER_COMMAND,xn as DRAGSTART_COMMAND,yn as DROP_COMMAND,Li as DecoratorNode,Fi as ElementNode,On as FOCUS_COMMAND,mn as FORMAT_ELEMENT_COMMAND,Ge as FORMAT_TEXT_COMMAND,yo as HISTORIC_TAG,xo as HISTORY_MERGE_TAG,mo as HISTORY_PUSH_TAG,_n as INDENT_CONTENT_COMMAND,Be as INPUT_COMMAND,Ue as INSERT_LINE_BREAK_COMMAND,He as INSERT_PARAGRAPH_COMMAND,gn as INSERT_TAB_COMMAND,Sc as INTERNAL_$isBlock,k as IS_ALL_FORMATTING,c as IS_ANDROID,f as IS_ANDROID_CHROME,r as IS_APPLE,d as IS_APPLE_WEBKIT,p as IS_BOLD,u as IS_CHROME,C as IS_CODE,i as IS_FIREFOX,T as IS_HIGHLIGHT,l as IS_IOS,y as IS_ITALIC,a as IS_SAFARI,m as IS_STRIKETHROUGH,S as IS_SUBSCRIPT,v as IS_SUPERSCRIPT,x as IS_UNDERLINE,ln as KEY_ARROW_DOWN_COMMAND,on as KEY_ARROW_LEFT_COMMAND,en as KEY_ARROW_RIGHT_COMMAND,sn as KEY_ARROW_UP_COMMAND,un as KEY_BACKSPACE_COMMAND,dn as KEY_DELETE_COMMAND,tn as KEY_DOWN_COMMAND,cn as KEY_ENTER_COMMAND,fn as KEY_ESCAPE_COMMAND,An as KEY_MODIFIER_COMMAND,an as KEY_SPACE_COMMAND,hn as KEY_TAB_COMMAND,Ji as LineBreakNode,nn as MOVE_TO_END,rn as MOVE_TO_START,_t as NODE_STATE_DIRECT,H as NODE_STATE_KEY,pt as NODE_STATE_LATEST,pn as OUTDENT_CONTENT_COMMAND,Je as PASTE_COMMAND,Co as PASTE_TAG,Zi as ParagraphNode,Ze as REDO_COMMAND,Ve as REMOVE_TEXT_COMMAND,zi as RootNode,Ie as SELECTION_CHANGE_COMMAND,Le as SELECTION_INSERT_CLIPBOARD_NODES_COMMAND,kn as SELECT_ALL_COMMAND,Xe as SET_TEXT_FORMAT_COMMAND,To as SKIP_COLLAB_TAG,bo as SKIP_DOM_SELECTION_TAG,ko as SKIP_SCROLL_INTO_VIEW_TAG,No as SKIP_SELECTION_FOCUS_TAG,z as TEXT_TYPE_TO_FORMAT,Zo as TabNode,Wo as TextNode,Qe as UNDO_COMMAND,bu as addClassNamesToElement,uo as buildImportMap,Cu as configExtension,Pe as createCommand,ys as createEditor,Dn as createRefCountedRegistry,vt as createSharedNodeState,mt as createState,Su as declarePeerDependency,xu as defineExtension,Xl as findAllLexicalElementsDeep,ka as flipDirection,lc as getActiveElement,cc as getActiveElementDeep,ac as getComposedEventTarget,tc as getComposedStaticRange,Ol as getDOMOwnerDocument,Jl as getDOMSelection,Vl as getDOMSelectionFromTarget,nc as getDOMSelectionPoints,ec as getDOMSelectionRange,oc as getDOMSelectionRangeAndPoints,Gl as getDOMShadowRoots,Rs as getDOMTextNode,da as getDeclaredSlots,Ps as getEditorPropertyFromDOMNode,Fs as getNearestEditorFromDOMNode,wl as getParentElement,Es as getRegisteredNode,Ns as getRegisteredNodeOrThrow,Jc as getRegisteredSubtypeMap,Ql as getRootOwnerDocument,Hc as getStaticNodeConfig,Mo as getStyleObjectFromCSS,Is as getTextDirection,_s as getTransformSetFromKlass,Cc as isBlockDomNode,ui as isCurrentlyReadOnlyMode,Rc as isDOMCapturingSelection,Bs as isDOMDocumentNode,_c as isDOMNode,ql as isDOMShadowRoot,zs as isDOMTextNode,zc as isDOMUnmanaged,pc as isDocumentFragment,_l as isExactShortcutMatch,fc as isHTMLAnchorElement,gc as isHTMLElement,hc as isHTMLTableCellElement,dc as isHTMLTableRowElement,mc as isInlineDomNode,Xi as isLastChildInBlockNode,Ds as isLexicalEditor,gl as isModifierMatch,Gi as isOnlyChildInBlockNode,Ms as isSelectionCapturedInDecoratorInput,As as isSelectionWithinEditor,jc as iterStaticNodeConfigChain,qa as makeStepwiseIterator,Eu as mergeRegister,bc as mountSlotContainer,ku as normalizeClassNames,Fn as registerEventListener,wu as registerEventListeners,Nu as removeClassNamesFromElement,js as removeFromParent,bs as resetRandomKey,vu as safeCast,Fo as setDOMStyleFromCSS,Do as setDOMStyleObject,Kc as setDOMUnmanaged,Pc as setNodeIndentFromDOM,Tu as shallowMergeConfig,io as stopLexicalPropagation,Ws as toggleTextFormatType,Vr as tokenizeRawText,Nc as unmountSlotContainer}; ++/*@__INLINE__*/function Pe(t){return{type:t}}const Ie=/* @__PURE__ */Pe("SELECTION_CHANGE_COMMAND"),Le=/* @__PURE__ */Pe("SELECTION_INSERT_CLIPBOARD_NODES_COMMAND"),Ke=/* @__PURE__ */Pe("CLICK_COMMAND"),ze=/* @__PURE__ */Pe("BEFORE_INPUT_COMMAND"),Be=/* @__PURE__ */Pe("INPUT_COMMAND"),Re=/* @__PURE__ */Pe("COMPOSITION_START_COMMAND"),We=/* @__PURE__ */Pe("COMPOSITION_END_COMMAND"),$e=/* @__PURE__ */Pe("DELETE_CHARACTER_COMMAND"),Ue=/* @__PURE__ */Pe("INSERT_LINE_BREAK_COMMAND"),He=/* @__PURE__ */Pe("INSERT_PARAGRAPH_COMMAND"),je=/* @__PURE__ */Pe("CONTROLLED_TEXT_INSERTION_COMMAND"),Je=/* @__PURE__ */Pe("PASTE_COMMAND"),Ve=/* @__PURE__ */Pe("REMOVE_TEXT_COMMAND"),qe=/* @__PURE__ */Pe("DELETE_WORD_COMMAND"),Ye=/* @__PURE__ */Pe("DELETE_LINE_COMMAND"),Ge=/* @__PURE__ */Pe("FORMAT_TEXT_COMMAND"),Xe=/* @__PURE__ */Pe("SET_TEXT_FORMAT_COMMAND"),Qe=/* @__PURE__ */Pe("UNDO_COMMAND"),Ze=/* @__PURE__ */Pe("REDO_COMMAND"),tn=/* @__PURE__ */Pe("KEYDOWN_COMMAND"),en=/* @__PURE__ */Pe("KEY_ARROW_RIGHT_COMMAND"),nn=/* @__PURE__ */Pe("MOVE_TO_END"),on=/* @__PURE__ */Pe("KEY_ARROW_LEFT_COMMAND"),rn=/* @__PURE__ */Pe("MOVE_TO_START"),sn=/* @__PURE__ */Pe("KEY_ARROW_UP_COMMAND"),ln=/* @__PURE__ */Pe("KEY_ARROW_DOWN_COMMAND"),cn=/* @__PURE__ */Pe("KEY_ENTER_COMMAND"),an=/* @__PURE__ */Pe("KEY_SPACE_COMMAND"),un=/* @__PURE__ */Pe("KEY_BACKSPACE_COMMAND"),fn=/* @__PURE__ */Pe("KEY_ESCAPE_COMMAND"),dn=/* @__PURE__ */Pe("KEY_DELETE_COMMAND"),hn=/* @__PURE__ */Pe("KEY_TAB_COMMAND"),gn=/* @__PURE__ */Pe("INSERT_TAB_COMMAND"),_n=/* @__PURE__ */Pe("INDENT_CONTENT_COMMAND"),pn=/* @__PURE__ */Pe("OUTDENT_CONTENT_COMMAND"),yn=/* @__PURE__ */Pe("DROP_COMMAND"),mn=/* @__PURE__ */Pe("FORMAT_ELEMENT_COMMAND"),xn=/* @__PURE__ */Pe("DRAGSTART_COMMAND"),Cn=/* @__PURE__ */Pe("DRAGOVER_COMMAND"),Sn=/* @__PURE__ */Pe("DRAGEND_COMMAND"),vn=/* @__PURE__ */Pe("COPY_COMMAND"),Tn=/* @__PURE__ */Pe("CUT_COMMAND"),kn=/* @__PURE__ */Pe("SELECT_ALL_COMMAND"),bn=/* @__PURE__ */Pe("CLEAR_EDITOR_COMMAND"),Nn=/* @__PURE__ */Pe("CLEAR_HISTORY_COMMAND"),En=/* @__PURE__ */Pe("CAN_REDO_COMMAND"),wn=/* @__PURE__ */Pe("CAN_UNDO_COMMAND"),On=/* @__PURE__ */Pe("FOCUS_COMMAND"),Mn=/* @__PURE__ */Pe("BLUR_COMMAND"),An=/* @__PURE__ */Pe("KEY_MODIFIER_COMMAND");function Dn(t){const e=new Map;return{dispose(){for(const t of e.values())t.dispose();e.clear()},register(n,o){let r=e.get(n);void 0===r&&(r={dispose:t(n,o),holders:new Set},e.set(n,r));const i=()=>{const t=e.get(n);t&&t.holders.delete(i)&&0===t.holders.size&&(e.delete(n),t.dispose())};return r.holders.add(i),i}}}function Fn(t,e,n,o){return t.addEventListener(e,n,o),t.removeEventListener.bind(t,e,n,o)}const Pn=Object.freeze({}),In=[["keydown",function(t,e){const n=e._inputState;n.lastKeyDownTimeStamp=t.timeStamp,n.lastKeyCode=t.key,"Backspace"!==t.key&&Jn(n);if(e.isComposing())return;Nl(e,tn,t)}],["pointerdown",function(t,e){const n=ac(t),o=t.pointerType;_c(n)&&"touch"!==o&&"pen"!==o&&0===t.button&&Ai(e,()=>{Rc(n,e)||(e._inputState.isSelectionChangeFromMouseDown=!0)})}],["compositionstart",function(t,e){Nl(e,Re,t)}],["compositionend",function(t,e){const n=e._inputState;i?n.compositionPhase="ending-firefox":l||!a&&!d?Nl(e,We,t):(n.compositionPhase="ending-safari",n.compositionEndData=t.data)}],["input",function(t,e){t.stopPropagation();const n=e._inputState;Jn(n),Ai(e,()=>{qn(t,e)||e.dispatchCommand(Be,t)},{event:t}),n.unprocessedBeforeInputData=null}],["click",function(t,e){Ai(e,()=>{const n=Kr(),o=Jl(Il(e)),r=zr();if(o)if(ur(n)){const t=n.anchor,e=t.getNode();"element"===t.type&&0===t.offset&&n.isCollapsed()&&!Bi(e)&&1===nl().getChildrenSize()&&e.getTopLevelElementOrThrow().isEmpty()&&null!==r&&n.is(r)&&(o.removeAllRanges(),n.dirty=!0)}else if("touch"===t.pointerType||"pen"===t.pointerType){const n=nc(o,e._rootElement).anchorNode;if(gc(n)||zs(n)){ol(Lr(r,o,e,t))}}if(i&&null!==o&&0===o.rangeCount){const n=e._rootElement;if(null!==n&&t.target===n){const i=t.clientY;let s=n.childNodes.length;for(let t=0;tfunction(t,e){const n=t.inputType;if("deleteCompositionText"===n||i&&bl(e))return;if("insertCompositionText"===n)return;Ai(e,()=>{qn(t,e)||Nl(e,ze,t)},{event:t})}(t,e)]);const Ln=new WeakMap,Kn=new WeakMap,zn=Dn(t=>(t.addEventListener("selectionchange",ro),()=>t.removeEventListener("selectionchange",ro)));function Bn(t,e,n,o,r,i){const l=t.anchor,c=t.focus,a=l.getNode(),u=_i();let f;if(void 0!==i)f=i;else{const t=Jl(Il(u));f=null!==t?nc(t,u._rootElement):null}const d=null!==f?f.anchorNode:null,h=l.key,g=u.getElementByKey(h),_=n.length;return h!==c.key||!Xo(a)||(!r&&(!s||u._inputState.lastBeforeInputInsertTextTimeStamp1||(r||!s)&&null!==g&&!a.isComposing()&&d!==wc(a,g,u)||null!==f&&null!==e&&(!e.collapsed||e.startContainer!==f.anchorNode||e.startOffset!==f.anchorOffset)||!a.isComposing()&&(a.getFormat()!==t.format||a.getStyle()!==t.style)||function(t,e){if(e.isSegmented())return!0;if(!t.isCollapsed())return!1;const n=t.anchor.offset,o=e.getParentOrThrow(),r=Ls(e);return 0===n?!e.canInsertTextBefore()||!o.canInsertTextBefore()&&!e.isComposing()||r||function(t){const e=t.getPreviousSibling();return(Xo(e)||Pi(e)&&e.isInline())&&!e.canInsertTextAfter()}(e):n===e.getTextContentSize()&&(!e.canInsertTextAfter()||!o.canInsertTextAfter()&&!e.isComposing()||r)}(t,a)}function Rn(t,e){return zs(t)&&null!==t.nodeValue&&0!==e&&e!==t.nodeValue.length}function Wn(e,n,o){const{anchorNode:r,anchorOffset:i,focusNode:s,focusOffset:l}=nc(e,n._rootElement),c=n._inputState;c.isSelectionChangeFromDOMUpdate&&(c.isSelectionChangeFromDOMUpdate=!1,Rn(r,i)&&Rn(s,l)&&!c.postDeleteSelectionToRestore)||Ai(n,()=>{if(!o)return void ol(null);if(!As(n,r,s))return;let a=Kr();if(c.postDeleteSelectionToRestore&&ur(a)&&a.isCollapsed()){const t=a.anchor,e=c.postDeleteSelectionToRestore.anchor;(t.key===e.key&&t.offset===e.offset+1||1===t.offset&&e.getNode().is(t.getNode().getPreviousSibling()))&&(a=c.postDeleteSelectionToRestore.clone(),ol(a))}if(c.postDeleteSelectionToRestore=null,ur(a)){const o=a.anchor,u=o.getNode();if(a.isCollapsed()){"Range"===e.type&&r===s&&(a.dirty=!0);const i=Il(n).event,l=i?i.timeStamp:performance.now(),{format:f,style:d,offset:h,key:g,timeStamp:_}=c.collapsedSelectionFormat,p=nl(),y=!1===n.isComposing()&&""===p.getTextContent();if(l<_+200&&o.offset===h&&o.key===g)$n(a,f,d);else if("text"===o.type)Xo(u)||t(141),Un(a,u);else if("element"===o.type&&!y){Pi(u)||t(259);const e=o.getNode();e.isEmpty()?function(t,e){const n=e.getTextFormat(),o=e.getTextStyle();$n(t,n,o)}(a,e):$n(a,a.format,"")}}else{const t=o.key,e=a.focus.key,n=a.getNodes(),r=n.length,s=a.isBackward(),c=s?l:i,u=s?i:l,f=s?e:t,d=s?t:e;let h=2047,g=!1;for(let t=0;tJn(t),0)}function qn(t,e){const n=ac(t);if(gc(n)&&Rc(n,e))return!0;const o=e.getRootElement();if(null===o)return!1;const r=cc(o.ownerDocument);return null!==r&&o.contains(r)&&Rc(r,e)}function Yn(e){const n=e.inputType,o=Hn(e),r=_i(),i=r._inputState,s=Kr();if("insertText"===n&&e.data&&i.isInsertTextAfterHandledSelectionCommand){if(Jn(i),e.preventDefault(),ur(s)&&!s.isCollapsed()){const t=s.isBackward()?s.anchor:s.focus;s.anchor.set(t.key,t.offset,t.type),s.focus.set(t.key,t.offset,t.type)}return!0}if("deleteContentBackward"===n){if(null===s){const t=zr();if(!ur(t))return!0;ol(t.clone())}if(ur(s)){const n=s.anchor.key===s.focus.key;if(function(t,e){return"MediaLast"===t.lastKeyCode&&e{Ai(r,()=>{Vs(null)})},30),ur(s)){const e=s.anchor.getNode();e.markDirty(),Xo(e)||t(142),Un(s,e)}}else{if(Vs(null),l&&null!==o&&!o.collapsed&&(s.applyDOMRange(o),!s.isCollapsed()))return e.preventDefault(),s.removeText(),!0;e.preventDefault();const t=s.anchor.getNode(),c=t.getTextContent(),a=t.canInsertTextAfter(),u=0===s.anchor.offset&&s.focus.offset===c.length;let d=f&&n&&!u&&a;if(d&&s.isCollapsed()&&(d=!Ki(kl(s.anchor,!0))),!d){Nl(r,$e,!0);const t=Kr();f&&ur(t)&&t.isCollapsed()&&(i.postDeleteSelectionToRestore=t,setTimeout(()=>i.postDeleteSelectionToRestore=null))}}return!0}}if(!ur(s))return!0;const c=e.data;null!==i.unprocessedBeforeInputData&&ul(!1,r,i.unprocessedBeforeInputData),s.dirty&&null===i.unprocessedBeforeInputData||!s.isCollapsed()||Bi(s.anchor.getNode())||null===o||s.applyDOMRange(o),i.unprocessedBeforeInputData=null;const a=s.anchor,u=s.focus,d=a.getNode(),h=u.getNode();if("insertText"===n||"insertTranspose"===n){if("\n"===c)e.preventDefault(),Nl(r,Ue,!1);else if(c===D)e.preventDefault(),Nl(r,He);else if(null==c&&e.dataTransfer){const t=e.dataTransfer.getData("text/plain");e.preventDefault(),s.insertRawText(t)}else null!=c&&Bn(s,o,c,e.timeStamp,!0)?(e.preventDefault(),Nl(r,je,c),jn(c)):i.unprocessedBeforeInputData=c;return i.lastBeforeInputInsertTextTimeStamp=e.timeStamp,!0}switch(e.preventDefault(),n){case"insertFromYank":case"insertFromDrop":case"insertReplacementText":Nl(r,je,e);jn((e.dataTransfer?e.dataTransfer.getData("text/plain"):null)??e.data);break;case"insertFromComposition":{const t=i.hadOrphanedCompositionEvents;i.hadOrphanedCompositionEvents=!1;const n=r._compositionKey;Vs(null),t||Nl(r,je,e),Zn(n);break}case"insertLineBreak":Vs(null),Nl(r,Ue,!1);break;case"insertParagraph":Vs(null),i.isInsertLineBreak&&!l?(i.isInsertLineBreak=!1,Nl(r,Ue,!1)):Nl(r,He);break;case"insertFromPaste":case"insertFromPasteAsQuotation":Nl(r,Je,e);break;case"deleteByComposition":(function(t,e){return t!==e||Pi(t)||Pi(e)||!Ls(t)||!Ls(e)})(d,h)&&Nl(r,Ve,e);break;case"deleteByDrag":Al(No),Nl(r,Ve,e);break;case"deleteByCut":Nl(r,Ve,e);break;case"deleteContent":Nl(r,$e,!1);break;case"deleteWordBackward":Nl(r,qe,!0);break;case"deleteWordForward":Nl(r,qe,!1);break;case"deleteHardLineBackward":case"deleteSoftLineBackward":Nl(r,Ye,!0);break;case"deleteContentForward":case"deleteHardLineForward":case"deleteSoftLineForward":Nl(r,Ye,!1);break;case"formatStrikeThrough":Nl(r,Ge,"strikethrough");break;case"formatBold":Nl(r,Ge,"bold");break;case"formatItalic":Nl(r,Ge,"italic");break;case"formatUnderline":Nl(r,Ge,"underline");break;case"historyUndo":Nl(r,Qe);break;case"historyRedo":Nl(r,Ze)}return!0}function Gn(t){const e=_i(),n=e._inputState,o=Kr(),r=t.data,l=Hn(t);let c=!1;if(null!=r&&ur(o)){const a=Jl(Il(e)),u=null!==a?nc(a,e._rootElement):null,d="insertCompositionText"===t.inputType&&"ending-firefox"!==n.compositionPhase&&!e.isComposing();d&&(n.hadOrphanedCompositionEvents=!0);const h=o.anchor.getNode(),g="insertCompositionText"===t.inputType&&"ending-firefox"!==n.compositionPhase&&e.isComposing()&&Xo(h)&&Ks(h);if(!d&&!g&&Bn(o,l,r,t.timeStamp,!1,u)){if(c=!0,"ending-firefox"===n.compositionPhase){const t=to(e,r);if(n.compositionPhase="idle",t)return Al(wo),rl(),!0}const l=o.anchor.getNode();if(null===a||null===u)return!0;const d=o.isBackward(),h=d?o.anchor.offset:o.focus.offset,g=d?o.focus.offset:o.anchor.offset;s&&!o.isCollapsed()&&Xo(l)&&null!==u.anchorNode&&l.getTextContent().slice(0,h)+r+l.getTextContent().slice(h+g)===al(u.anchorNode)||Nl(e,je,r);const _=r.length;i&&_>1&&"insertCompositionText"===t.inputType&&!e.isComposing()&&(o.anchor.offset-=_,o._cachedNodes=null,o._cachedIsBackward=null),f&&e.isComposing()&&(n.lastKeyDownTimeStamp=0,Vs(null))}}if(!c){ul(!1,e,null!==r?r:void 0),"ending-firefox"===n.compositionPhase&&(to(e,r||void 0),Al(wo),n.compositionPhase="idle")}return rl(),!0}function Xn(t){const e=_i(),n=e._inputState,o=Kr();if(ur(o)&&!e.isComposing()){n.compositionPhase="composing",n.hadOrphanedCompositionEvents=!1;const r=o.anchor,i=o.anchor.getNode();if(Vs(r.key),Al(Eo),t.timeStamp{to(e,n.compositionEndData)}),n.compositionPhase="idle",n.compositionEndData="",o)return!0}if(function(t){return _l(t,"ArrowRight",{shiftKey:"any"})}(t))Nl(e,en,t);else if(function(t){return _l(t,"ArrowRight",{...pl,shiftKey:"any"})}(t))Nl(e,nn,t);else if(function(t){return _l(t,"ArrowLeft",{shiftKey:"any"})}(t))Nl(e,on,t);else if(function(t){return _l(t,"ArrowLeft",{...pl,shiftKey:"any"})}(t))Nl(e,rn,t);else if(function(t){return _l(t,"ArrowUp",{altKey:"any",shiftKey:"any"})}(t))Nl(e,sn,t);else if(function(t){return _l(t,"ArrowDown",{altKey:"any",shiftKey:"any"})}(t))Nl(e,ln,t);else if(function(t){return _l(t,"Enter",{altKey:"any",ctrlKey:"any",metaKey:"any",shiftKey:!0})}(t))n.isInsertLineBreak=!0,Nl(e,cn,t);else if(function(t){return" "===t.key}(t))Nl(e,an,t);else if(function(t){return r&&_l(t,"o",{ctrlKey:!0})}(t))t.preventDefault(),n.isInsertLineBreak=!0,Nl(e,Ue,!0);else if(function(t){return _l(t,"Enter",{altKey:"any",ctrlKey:"any",metaKey:"any"})}(t))n.isInsertLineBreak=!1,Nl(e,cn,t);else if(function(t){return _l(t,"Backspace",{shiftKey:"any"})||r&&_l(t,"h",{ctrlKey:!0})}(t))ml(t)?Nl(e,un,t)&&Vn(n):(t.preventDefault(),Nl(e,$e,!0));else if(function(t){return"Escape"===t.key}(t))Nl(e,fn,t);else if(function(t){return _l(t,"Delete",{})||r&&_l(t,"d",{ctrlKey:!0})}(t))!function(t){return"Delete"===t.key}(t)?(t.preventDefault(),Nl(e,$e,!1)):Nl(e,dn,t);else if(function(t){return _l(t,"Backspace",yl)}(t))t.preventDefault(),Nl(e,qe,!0);else if(function(t){return _l(t,"Delete",yl)}(t))t.preventDefault(),Nl(e,qe,!1);else if(function(t){return r&&_l(t,"Backspace",{metaKey:!0})}(t))t.preventDefault(),Nl(e,Ye,!0);else if(function(t){return r&&(_l(t,"Delete",{metaKey:!0})||_l(t,"k",{ctrlKey:!0}))}(t))t.preventDefault(),Nl(e,Ye,!1);else if(function(t){return _l(t,"b",pl)}(t))t.preventDefault(),Nl(e,Ge,"bold");else if(function(t){return _l(t,"u",pl)}(t))t.preventDefault(),Nl(e,Ge,"underline");else if(function(t){return _l(t,"i",pl)}(t))t.preventDefault(),Nl(e,Ge,"italic");else if(function(t){return _l(t,"Tab",{shiftKey:"any"})}(t))Nl(e,hn,t);else if(function(t){return _l(t,"z",pl)}(t))t.preventDefault(),Nl(e,Qe);else if(function(t){if(r)return _l(t,"z",{metaKey:!0,shiftKey:!0});return _l(t,"y",{ctrlKey:!0})||_l(t,"z",{ctrlKey:!0,shiftKey:!0})}(t))t.preventDefault(),Nl(e,Ze);else{const o=e._editorState._selection;!function(t){return _l(t,"a",pl)}(t)?null===o||ur(o)||(!function(t){return _l(t,"c",pl)}(t)?function(t){return _l(t,"x",pl)}(t)&&(t.preventDefault(),Nl(e,Tn,t)):(t.preventDefault(),Nl(e,vn,t))):(t.preventDefault(),Nl(e,kn,t)&&Vn(n))}return function(t){return t.ctrlKey||t.shiftKey||t.altKey||t.metaKey}(t)&&e.dispatchCommand(An,t),!0}function no(t){let e=t.__lexicalEventHandles;return void 0===e&&(e=[],t.__lexicalEventHandles=e),e}const oo=new Map;function ro(t){const e=Vl(t.target);if(null===e)return;const n=Ol(t.target);let o=null,r=null;const i=null!==n?Kn.get(n):void 0;if(null!==n){if(void 0!==i){const t=i.editors;let n=i.hasShadowEditor;if(void 0===n){n=!1;for(const e of t)if(null!==e._rootElement&&ql(e._rootElement.getRootNode())){n=!0;break}i.hasShadowEditor=n}if(n){let n=null,i=null;for(const s of t){const t=s._rootElement;if(null===t)continue;const l=nc(e,t).anchorNode;if(null!==l&&Fs(l)===s){if(ql(t.getRootNode())){o=s,r=l;break}null===n&&(n=s,i=l)}}null===o&&null!==n&&(o=n,r=i)}else{const t=e.anchorNode;null===t||gc(t)&&null!==t.shadowRoot||(o=Fs(t),null!==o&&(r=t))}}if(null===o){const t=cc(n);o=null!==t?Fs(t):null}}if(null===o)return;if(o._inputState.isSelectionChangeFromMouseDown){if(void 0!==i)for(const t of i.editors)t._inputState.isSelectionChangeFromMouseDown=!1;Ai(o,()=>{const n=zr(),i=r??nc(e,o._rootElement).anchorNode;if(gc(i)||zs(i)){ol(Lr(n,e,o,t))}})}const s=ll(o),l=s[s.length-1],c=l._key,a=oo.get(c),u=a||l;u!==o&&Wn(e,u,!1),Wn(e,o,!0),o!==l?oo.set(c,o):a&&oo.delete(c)}function io(t){t._lexicalHandled=!0}function so(t){return!0===t._lexicalHandled}const lo=()=>{};function co(e){const n=Ln.get(e);if(void 0===n)return void lo();const o=Kn.get(n);if(void 0===o)return void lo();Ln.delete(e);const r=Ps(e);Ds(r)?(!function(t){if(null!==t._parentEditor){const e=ll(t),n=e[e.length-1]._key;oo.get(n)===t&&oo.delete(n)}else oo.delete(t._key)}(r),o.editors.delete(r),o.hasShadowEditor=void 0,e.__lexicalEditor=null):r&&t(198);const i=no(e);for(let t=0;tt.__key===this.__key);if(Xo(this))return n;if(ur(e)&&"element"===e.anchor.type&&"element"===e.focus.type){if(e.isCollapsed())return!1;const t=this.getParent();if(Ki(this)&&this.isInline()&&t){const n=e.isBackward()?e.focus:e.anchor;if(t.is(n.getNode())&&n.offset===t.getChildrenSize()&&this.is(t.getLastChild()))return!1}}return n}getKey(){return this.__key}getIndexWithinParent(){const t=this.getParent();if(null===t)return-1;let e=t.getFirstChild(),n=0;for(;null!==e;){if(this.is(e))return n;n++,e=e.getNextSibling()}return-1}getParent(){const t=this.getLatest().__parent;return null===t?null:Ys(t)}getParentOrThrow(){const e=this.getParent();return null===e&&t(66,this.__key),e}getTopLevelElement(){let e=this;for(;null!==e;){const n=e.getParent();if(Bl(n)||null!==ta(e))return Pi(e)||e===this&&Ki(e)||t(194),e;e=n}return null}getTopLevelElementOrThrow(){const e=this.getTopLevelElement();return null===e&&t(67,this.__key),e}getParents(){const t=[];let e=this.getParent();for(;null!==e;)t.push(e),e=e.getParent();return t}getParentKeys(){const t=[];let e=this.getParent();for(;null!==e;)t.push(e.__key),e=e.getParent();return t}getPreviousSibling(){const t=this.getLatest().__prev;return null===t?null:Ys(t)}getPreviousSiblings(){const t=[],e=this.getParent();if(null===e)return t;let n=e.getFirstChild();for(;null!==n&&!n.is(this);)t.push(n),n=n.getNextSibling();return t}getNextSibling(){const t=this.getLatest().__next;return null===t?null:Ys(t)}getNextSiblings(){const t=[];let e=this.getNextSibling();for(;null!==e;)t.push(e),e=e.getNextSibling();return t}getCommonAncestor(t){const e=Pi(this)?this:this.getParent(),n=Pi(t)?t:t.getParent(),o=e&&n?Za(e,n):null;return o?o.commonAncestor:null}is(t){return null!=t&&this.__key===t.__key}isBefore(e){const n=Za(this,e);return null!==n&&("descendant"===n.type||("branch"===n.type?-1===Ga(n):("same"!==n.type&&"ancestor"!==n.type&&t(279),!1)))}isParentOf(t){return Fl(t,this)}getNodesBetween(e){const n=this.isBefore(e),o=[],r=new Set;let i=this;for(;null!==i;){const s=i.__key;if(r.has(s)||(r.add(s),o.push(i)),i===e)break;const l=Pi(i)?n?i.getFirstChild():i.getLastChild():null;if(null!==l){i=l;continue}const c=n?i.getNextSibling():i.getPreviousSibling();if(null!==c){i=c;continue}const a=i.getParentOrThrow();if(r.has(a.__key)||o.push(a),a===e)break;let u=null,f=a;do{if(null===f&&t(68),u=n?f.getNextSibling():f.getPreviousSibling(),f=f.getParent(),null===f)break;null!==u||r.has(f.__key)||o.push(f)}while(null===u);i=u}return n||o.reverse(),o}isDirty(){const t=_i()._dirtyLeaves;return null!==t&&t.has(this.__key)}getLatest(){if(ho(this))return this;const e=Ys(this.__key);return null===e&&t(113),e}getWritable(){if(ho(this))return this;fi();const t=hi(),e=_i(),n=t._nodeMap,o=this.__key,r=this.getLatest(),i=e._cloneNotNeeded,s=Kr();if(null!==s&&s.setCachedNodes(null),i.has(o))return Js(r),r;const l=Dc(r);return i.add(o),Js(l),n.set(o,l),l}getTextContent(){return ha(this)}getTextContentSize(){return this.getTextContent().length}createDOM(e,n){t(70)}updateDOM(e,n,o){t(71)}getDOMSlot(t){return new q(t)}exportDOM(t){return{element:this.createDOM(t._config,t)}}exportJSON(){const t=this.__state?this.__state.toJSON():void 0;return{type:this.__type,version:1,...t}}static importJSON(e){t(18,this.name)}updateFromJSON(t){return function(t,e){const n=t.getWritable(),o=e.$;let r=o;for(const t of Nt(n).flatKeys)t in e&&(void 0!==r&&r!==o||(r={...o}),r[t]=e[t]);return(n.__state||r)&&bt(t).updateFromJSON(r),n}(this,t)}static transform(){return null}remove(t){ao(this,!0,t)}replace(e,n){fi();let o=Kr();null!==o&&(o=o.clone()),$l(this,e);const r=this.getLatest(),i=this.__key,s=e.__key,l=e.getWritable(),c=this.getParentOrThrow().getWritable(),a=c.__size,u=l.getParent(),f=null!==u?l.getIndexWithinParent():-1;Hs(l),null!==u&&ur(o)&&Br(o,u,f,-1);const d=r.getPreviousSibling(),h=r.getNextSibling(),g=r.__prev,_=r.__next,p=r.__parent;if(ao(r,!1,!0),null===d)c.__first=s;else{d.getWritable().__next=s}if(l.__prev=g,null===h)c.__last=s;else{h.getWritable().__prev=s}l.__next=_,l.__parent=p,c.__size=a;let y=0;n&&(Pi(this)&&Pi(l)||t(139),y=l.getChildrenSize(),l.splice(y,0,this.getChildren()));const m=ia(this);if(m.length>0){Qc(this)&&Qc(l)||t(368,this.__key,l.__key);for(const t of m){const e=sa(this,t);null!==e&&(ya(this,t),pa(l,t,e))}}if(ur(o)){ol(o);const t=o.anchor,e=o.focus;t.key===i&&(n&&"element"===t.type?t.set(l.__key,y+t.offset,"element"):ir(t,l)),e.key===i&&(n&&"element"===e.type?e.set(l.__key,y+e.offset,"element"):ir(e,l))}return qs()===i&&Vs(s),l}insertAfter(t,e=!0){fi(),$l(this,t);const n=this.getWritable(),o=t.getWritable();ma(this.getParentOrThrow());const r=o.getParent(),i=Kr();let s=!1,l=!1;if(null!==r){const n=t.getIndexWithinParent();if(ur(i)){const t=r.__key,e=i.anchor,o=i.focus;s="element"===e.type&&e.key===t&&e.offset===n+1,l="element"===o.type&&o.key===t&&o.offset===n+1}Hs(o),e&&ur(i)&&Br(i,r,n,-1)}else Hs(o);const c=this.getNextSibling(),a=this.getParentOrThrow().getWritable(),u=o.__key,f=n.__next;if(null===c)a.__last=u;else{c.getWritable().__prev=u}if(a.__size++,n.__next=u,o.__next=f,o.__prev=n.__key,o.__parent=n.__parent,e&&ur(i)){const t=this.getIndexWithinParent();Br(i,a,t+1);const e=a.__key;s&&i.anchor.set(e,t+2,"element"),l&&i.focus.set(e,t+2,"element")}return t}insertBefore(t,e=!0){fi(),$l(this,t);const n=this.getWritable(),o=t.getWritable();ma(this.getParentOrThrow());const r=o.__key,i=Kr(),s=o.getParent(),l=null!==s?o.getIndexWithinParent():-1;Hs(o),null!==s&&e&&ur(i)&&Br(i,s,l,-1);const c=this.getPreviousSibling(),a=this.getParentOrThrow().getWritable(),u=n.__prev,f=this.getIndexWithinParent();if(null===c)a.__first=r;else{c.getWritable().__next=r}if(a.__size++,n.__prev=r,o.__prev=u,o.__next=n.__key,o.__parent=n.__parent,e&&ur(i)){Br(i,this.getParentOrThrow(),f)}return t}isParentRequired(){return!1}createParentElementNode(){return es()}selectStart(){return this.selectPrevious()}selectEnd(){return this.selectNext(0,0)}selectPrevious(t,e){fi();const n=ea(this);if(null!==n)return n.selectPrevious(t,e);const o=this.getPreviousSibling(),r=this.getParentOrThrow();if(null===o)return r.select(0,0);if(Pi(o))return o.select();if(!Xo(o)){const t=o.getIndexWithinParent()+1;return r.select(t,t)}return o.select(t,e)}selectNext(t,e){fi();const n=ea(this);if(null!==n)return n.selectNext(t,e);const o=this.getNextSibling(),r=this.getParentOrThrow();if(null===o)return r.select();if(Pi(o))return o.select(0,0);if(!Xo(o)){const t=o.getIndexWithinParent();return r.select(t,t)}return o.select(t,e)}markDirty(){this.getWritable()}reconcileObservedMutation(t,e){this.markDirty()}}function po(t){return t instanceof _o}const yo="historic",mo="history-push",xo="history-merge",Co="paste",So="cut",vo="collaboration",To="skip-collab",ko="skip-scroll-into-view",bo="skip-dom-selection",No="skip-selection-focus",Eo="composition-start",wo="composition-end",Oo="!important";function Mo(t){const e={};if(!t)return e;let n="",o="",r=null,i=!1,s=!1,l=!1,c=0;const a=t.length;let u=-1;for(let f=0;f=0&&o.slice(r).toLowerCase()===Oo?t.setProperty(e,o.slice(0,r).trim(),"important"):t.setProperty(e,n,"")}function Do(t,e){for(const n in e){const o=e[n];null==o?t.removeProperty(n):Ao(t,n,o)}}function Fo(t,e,n=""){if(e===n)return;const o=Mo(n),r=Mo(e);for(const e in r)delete o[e],Ao(t,e,r[e]);for(const e in o)t.removeProperty(e)}function Po(t,e){return 16&e?"code":e&T?"mark":32&e?"sub":64&e?"sup":null}function Io(t,e){return 1&e?"strong":2&e?"em":"span"}function Lo(t,e,n,o,r){const i=o.classList;let s=Cl(r,"base");void 0!==s&&i.add(...s),s=Cl(r,"underlineStrikethrough");let l=!1;const c=8&e&&4&e;void 0!==s&&(8&n&&4&n?(l=!0,c||i.add(...s)):c&&i.remove(...s));for(const t in z){const o=z[t];if(s=Cl(r,t),void 0!==s)if(n&o){if(l&&("underline"===t||"strikethrough"===t)){e&o&&i.remove(...s);continue}(0===(e&o)||c&&"underline"===t||"strikethrough"===t)&&i.add(...s)}else e&o&&i.remove(...s)}}function Ko(t,e,n){const o=n.isComposing(),r=t+(o?A:""),s=vc(),l=Tc(s).$getDOMSlot(n,e,s),c=l.getFirstChild();if(null===c||c.nodeType!==Node.TEXT_NODE)return void l.insertChild(Zl().createTextNode(r));const a=c,u=a.nodeValue;if(u!==r)if(o||i){const[t,e,n]=function(t,e){const n=t.length,o=e.length;let r=0,i=0;for(;r({conversion:Jo,priority:0}),b:()=>({conversion:Uo,priority:0}),code:()=>({conversion:Yo,priority:0}),em:()=>({conversion:Yo,priority:0}),i:()=>({conversion:Yo,priority:0}),mark:()=>({conversion:Yo,priority:0}),s:()=>({conversion:Yo,priority:0}),span:()=>({conversion:$o,priority:0}),strong:()=>({conversion:Yo,priority:0}),sub:()=>({conversion:Yo,priority:0}),sup:()=>({conversion:Yo,priority:0}),u:()=>({conversion:Yo,priority:0})}})}afterCloneFrom(t){super.afterCloneFrom(t),this.__text=t.__text,this.__format=t.__format,this.__style=t.__style,this.__mode=t.__mode,this.__detail=t.__detail}constructor(t="",e){super(e),this.__text=t,this.__format=0,this.__style="",this.__mode=0,this.__detail=0}getFormat(){return this.getLatest().__format}getDetail(){return this.getLatest().__detail}getMode(){const t=this.getLatest();return U[t.__mode]}getStyle(){return this.getLatest().__style}isToken(){return 1===this.getLatest().__mode}isComposing(){return this.__key===qs()}isSegmented(){return 2===this.getLatest().__mode}isDirectionless(){return!!(1&this.getLatest().__detail)}isUnmergeable(){return!!(2&this.getLatest().__detail)}hasFormat(t){const e=z[t];return 0!==(this.getFormat()&e)}isSimpleText(){return"text"===this.__type&&0===this.__mode}getTextContent(){return this.getLatest().__text}getFormatFlags(t,e){return Ws(this.getLatest().__format,t,e)}canHaveFormat(){return!0}isInline(){return!0}createDOM(t,e){const n=this.__format,o=Po(0,n),r=Io(0,n),i=null===o?r:o,s=Zl().createElement(i);let l=s;this.hasFormat("code")&&s.setAttribute("spellcheck","false"),null!==o&&(l=Zl().createElement(r),s.appendChild(l));zo(l,this,0,n,this.__text,t);const c=this.__style;return""!==c&&Fo(s.style,c),s}updateDOM(e,n,o){const r=this.__text,i=e.__format,s=this.__format,l=Po(0,i),c=Po(0,s),a=Io(0,i),u=Io(0,s);if((null===l?a:l)!==(null===c?u:c))return!0;if(l===c&&a!==u){const e=n.firstChild;null==e&&t(48);const i=Zl().createElement(u);return zo(i,this,0,s,r,o),n.replaceChild(i,e),!1}let f=n;null!==c&&null!==l&&(f=n.firstChild,null==f&&t(49)),Ko(r,f,this);const d=o.theme.text;void 0!==d&&i!==s&&Lo(0,i,s,f,d);const h=e.__style,g=this.__style;return h!==g&&Fo(n.style,g,h),!1}updateFromJSON(t){return super.updateFromJSON(t).setTextContent(t.text).setFormat(t.format).setDetail(t.detail).setMode(t.mode).setStyle(t.style)}exportDOM(e){let{element:n}=super.exportDOM(e);return gc(n)||t(132),n.style.whiteSpace="pre-wrap",this.hasFormat("lowercase")?n.style.textTransform="lowercase":this.hasFormat("uppercase")?n.style.textTransform="uppercase":this.hasFormat("capitalize")&&(n.style.textTransform="capitalize"),this.hasFormat("bold")&&(n=Bo(n,"b")),this.hasFormat("italic")&&(n=Bo(n,"i")),this.hasFormat("strikethrough")&&(n=Bo(n,"s")),this.hasFormat("underline")&&(n=Bo(n,"u")),{element:n}}exportJSON(){return{detail:this.getDetail(),format:this.getFormat(),mode:this.getMode(),style:this.getStyle(),text:this.getTextContent(),...super.exportJSON()}}selectionTransform(t,e){}setFormat(t){const e=this.getWritable();return e.__format="string"==typeof t?z[t]:t,e}setDetail(t){const e=this.getWritable();return e.__detail="string"==typeof t?B[t]:t,e}setStyle(t){const e=this.getWritable();return e.__style=t,e}toggleFormat(t){const e=Ws(this.getFormat(),t,null);return this.setFormat(e)}toggleDirectionless(){const t=this.getWritable();return t.__detail^=1,t}toggleUnmergeable(){const t=this.getWritable();return t.__detail^=2,t}setMode(t){const e=$[t];if(this.__mode===e)return this;const n=this.getWritable();return n.__mode=e,n}setTextContent(t){if(this.__text===t)return this;const e=this.getWritable();return e.__text=t,e}select(t,e){fi();let n=t,o=e;const r=Kr(),i=this.getTextContent(),s=this.__key;if("string"==typeof i){const t=i.length;void 0===n&&(n=t),void 0===o&&(o=t)}else n=0,o=0;if(!ur(r))return Dr(s,n,s,o,"text","text");{const t=qs();t!==r.anchor.key&&t!==r.focus.key||Vs(s),r.setTextNodeRange(this,n,this,o)}return r}selectStart(){return this.select(0,0)}selectEnd(){const t=this.getTextContentSize();return this.select(t,t)}spliceText(t,e,n,o){const r=this.getWritable(),i=r.__text,s=n.length;let l=t;l<0&&(l=s+l,l<0&&(l=0));const c=Kr();if(o&&ur(c)){const e=t+s;c.setTextNodeRange(r,e,r,e)}const a=i.slice(0,l)+n+i.slice(l+e);return r.__text=a,r}canInsertTextBefore(){return!0}canInsertTextAfter(){return!0}splitText(...t){fi();const e=this.getLatest(),n=e.getTextContent();if(""===n)return[];const o=e.__key,r=qs(),i=n.length;t.sort((t,e)=>t-e),t.push(i);const s=[],l=t.length;for(let e=0,o=0;ee&&(s.push(n.slice(e,r)),e=r)}const c=s.length;if(1===c)return[e];const a=s[0],u=e.getParent();let f;const d=e.getFormat(),h=e.getStyle(),g=e.__detail;let _=!1,p=null,y=null;const m=Kr();if(ur(m)){const[t,e]=m.isBackward()?[m.focus,m.anchor]:[m.anchor,m.focus];"text"===t.type&&t.key===o&&(p=t),"text"===e.type&&e.key===o&&(y=e)}e.isSegmented()?(f=Go(a),f.__format=d,f.__style=h,f.__detail=g,f.__state=At(e,f),_=!0):f=e.setTextContent(a);const x=[f];for(let t=1;t=v&&(p.set(t.getKey(),C-v,"text"),C=v){y.set(t.getKey(),S-v,"text");break}v=e}if(null!==u){!function(t){const e=t.getPreviousSibling(),n=t.getNextSibling();null!==e&&Js(e);null!==n&&Js(n)}(this);const t=u.getWritable(),e=this.getIndexWithinParent();_?(t.splice(e,0,x),this.remove()):t.splice(e,1,x),ur(m)&&Br(m,u,e,c-1)}return x}mergeWithSibling(e){const n=e===this.getPreviousSibling();n||e===this.getNextSibling()||t(50);const o=this.__key,r=e.__key,i=this.__text,s=i.length;qs()===r&&Vs(o);const l=Kr();if(ur(l)){const t=l.anchor,i=l.focus;null!==t&&t.key===r&&$r(t,n,o,e,s),null!==i&&i.key===r&&$r(i,n,o,e,s)}const c=e.__text,a=n?c+i:i+c;this.setTextContent(a);const u=this.getWritable();return e.remove(),u}isTextEntity(){return!1}}function $o(t){return{forChild:Qo(t.style),node:null}}function Uo(t){const e=t,n="normal"===e.style.fontWeight;return{forChild:Qo(e.style,n?void 0:"bold"),node:null}}const Ho=new WeakMap;function jo(t){if(!gc(t))return!1;if("PRE"===t.nodeName)return!0;const e=t.style.whiteSpace;return"string"==typeof e&&e.startsWith("pre")}function Jo(e){const n=e;null===e.parentElement&&t(129);let o=n.textContent||"";if(null!==function(t){let e,n=t.parentNode;const o=[t];for(;null!==n&&void 0===(e=Ho.get(n))&&!jo(n);)o.push(n),n=n.parentNode;const r=void 0===e?n:e;for(let t=0;t0){/[ \t\n]$/.test(n)&&(o=o.slice(1)),e=!1;break}}e&&(o=o.slice(1))}if(" "===o[o.length-1]){let t=n,e=!0;for(;null!==t&&null!==(t=Vo(t,!0));){if((t.textContent||"").replace(/^( |\t|\r?\n)+/,"").length>0){e=!1;break}}e&&(o=o.slice(0,o.length-1))}return""===o?{node:null}:{node:Go(o)}}function Vo(t,e){let n=t;for(;;){let t;for(;null===(t=e?n.nextSibling:n.previousSibling);){const t=n.parentElement;if(null===t)return null;n=t}if(n=t,gc(n)){const t=n.style.display;if(""===t&&!mc(n)||""!==t&&!t.startsWith("inline"))return null}let o=n;for(;null!==(o=e?n.firstChild:n.lastChild);)n=o;if(zs(n))return n;if("BR"===n.nodeName)return null}}const qo={code:"code",em:"italic",i:"italic",mark:"highlight",s:"strikethrough",strong:"bold",sub:"subscript",sup:"superscript",u:"underline"};function Yo(t){const e=qo[t.nodeName.toLowerCase()];return void 0===e?{node:null}:{forChild:Qo(t.style,e),node:null}}function Go(t=""){return Wl(new Wo(t))}function Xo(t){return t instanceof Wo}function Qo(t,e){const n=t.fontWeight,o=t.textDecoration.split(" "),r="700"===n||"bold"===n,i=o.includes("line-through"),s="italic"===t.fontStyle,l=o.includes("underline"),c=t.verticalAlign;return t=>Xo(t)||Ro(t)?(r&&!t.hasFormat("bold")&&t.toggleFormat("bold"),i&&!t.hasFormat("strikethrough")&&t.toggleFormat("strikethrough"),s&&!t.hasFormat("italic")&&t.toggleFormat("italic"),l&&!t.hasFormat("underline")&&t.toggleFormat("underline"),"sub"!==c||t.hasFormat("subscript")||t.toggleFormat("subscript"),"super"!==c||t.hasFormat("superscript")||t.toggleFormat("superscript"),e&&!t.hasFormat(e)&&t.toggleFormat(e),t):t}class Zo extends Wo{$config(){return this.config("tab",{extends:Wo})}constructor(t=void 0){super("\t",t),this.__detail=2}createDOM(t){const e=super.createDOM(t),n=Cl(t.theme,"tab");if(void 0!==n){e.classList.add(...n)}return e}setTextContent(t){return super.setTextContent("\t")}spliceText(e,n,o,r){return""===o&&0===n||"\t"===o&&1===n||t(286),this}setDetail(e){return 2!==e&&t(127),this}setMode(e){return"normal"!==e&&t(128),this}canInsertTextBefore(){return!1}canInsertTextAfter(){return!1}}function tr(){return Wl(new Zo)}function er(t){return t instanceof Zo}class nr{key;offset;type;_selection;constructor(t,e,n){this._selection=null,this.key=t,this.offset=e,this.type=n}is(t){return this.key===t.key&&this.offset===t.offset&&this.type===t.type}isBefore(t){if(this.key===t.key)return this.offsett&&(o=t)}else if(!Pi(e)){const t=e.getNextSibling();if(Xo(t))n=t.__key,o=0,r="text";else{const t=e.getParent();t&&(n=t.__key,o=e.getIndexWithinParent()+1)}}t.set(n,o,r)}function ir(t,e){if(Pi(e)){const n=e.getLastDescendant();Pi(n)||Xo(n)?rr(t,n):rr(t,e)}else rr(t,e)}function sr(t,e,n,o){const r=t.getNode(),i=r.getChildAtIndex(t.offset),s=Go();if(s.setFormat(n),s.setStyle(o),ns(i))i.splice(0,0,[s]);else if(null!==i){const t=Bl(r)?es().append(s):s;i.insertBefore(t)}else if(Bl(r)){const t=r.getLastChild();Pi(t)&&!t.isInline()&&t.isEmpty()?t.append(s):r.append(es().append(s))}else r.append(s);t.is(e)&&e.set(s.__key,0,"text"),t.set(s.__key,0,"text")}function lr(e,n,o,r){const i=e.anchor.getNode();Xo(i)||t(398);const s=e.anchor.offset,l=Go(n);l.setFormat(o),l.setStyle(r);const c=i.getParentOrThrow();if(0===s)c.isInline()&&!i.__prev?c.insertBefore(l):i.insertBefore(l,!1);else if(s===i.getTextContentSize())c.isInline()&&!i.__next?c.insertAfter(l):i.insertAfter(l,!1);else{const[t]=i.splitText(s);t.insertAfter(l,!1)}""===i.getTextContent()&&i.isAttached()&&i.remove(),l.selectEnd(),l.isComposing()&&"text"===e.anchor.type&&e.anchor.set(e.anchor.key,e.anchor.offset-n.length,e.anchor.type)}class cr{_nodes;_cachedNodes;dirty;constructor(t){this._cachedNodes=null,this._nodes=t,this.dirty=!1}getCachedNodes(){return this._cachedNodes}setCachedNodes(t){this._cachedNodes=t}is(t){if(!dr(t))return!1;const e=this._nodes,n=t._nodes;return e.size===n.size&&Array.from(e).every(t=>n.has(t))}isCollapsed(){return!1}isBackward(){return!1}getStartEndPoints(){return null}add(t){this.dirty=!0,this._nodes.add(t),this._cachedNodes=null}delete(t){this.dirty=!0,this._nodes.delete(t),this._cachedNodes=null}clear(){this.dirty=!0,this._nodes.clear(),this._cachedNodes=null}has(t){return this._nodes.has(t)}clone(){return new cr(new Set(this._nodes))}extract(){return this.getNodes()}insertRawText(t){}insertText(){}insertNodes(t){const e=this.getNodes().filter(t=>null===ta(t)),n=e.length;if(0===n)return;const o=e[n-1];let r;if(Xo(o))r=o.select();else{const t=o.getIndexWithinParent()+1;r=o.getParentOrThrow().select(t,t)}r.insertNodes(t);for(let t=0;tnull===ta(t));if((Kr()||zr())===this&&t[0]){const e=Ia(t[0],"next");nu(Va(e,e))}for(const e of t)e.remove();ar()}}function ar(){const t=nl();if(t.isEmpty()){const e=es();t.append(e),e.select()}}function ur(t){return t instanceof fr}class fr{format;style;anchor;focus;_cachedNodes;_cachedIsBackward;dirty;constructor(t,e,n,o){this.anchor=t,this.focus=e,t._selection=this,e._selection=this,this._cachedNodes=null,this._cachedIsBackward=null,this.format=n,this.style=o,this.dirty=!1}getCachedNodes(){return this._cachedNodes}setCachedNodes(t){this._cachedNodes=t}is(t){return!!ur(t)&&(this.anchor.is(t.anchor)&&this.focus.is(t.focus)&&this.format===t.format&&this.style===t.style)}isCollapsed(){return this.anchor.is(this.focus)}getNodes(){const t=this._cachedNodes;if(null!==t)return t;const e=function(t){const e=[],[n,o]=t.getTextSlices();n&&e.push(n.caret.origin);const r=new Set,i=new Set;for(const n of t)if(Aa(n)){const{origin:t}=n;0===e.length?r.add(t):(i.add(t),e.push(t))}else{const{origin:t}=n;Pi(t)&&i.has(t)||e.push(t)}o&&e.push(o.caret.origin);if(Ma(t.focus)&&Pi(t.focus.origin)&&null===t.focus.getNodeAtCaret())for(let n=Ba(t.focus.origin,"previous");Aa(n)&&r.has(n.origin)&&!n.origin.isEmpty()&&n.origin.is(e[e.length-1]);n=Wa(n))r.delete(n.origin),e.pop();for(;e.length>1;){const t=e[e.length-1];if(!Pi(t)||i.has(t)||t.isEmpty()||r.has(t))break;e.pop()}if(0===e.length&&t.isCollapsed()){const n=au(t.anchor),o=au(t.anchor.getFlipped()),r=t=>wa(t)?t.origin:t.getNodeAtCaret(),i=r(n)||r(o)||(t.anchor.getNodeAtCaret()?n.origin:o.origin);e.push(i)}return e}(du(ru(this),"next"));return ui()||(this._cachedNodes=e),e}setTextNodeRange(t,e,n,o){return this.anchor.set(t.__key,e,"text"),this.focus.set(n.__key,o,"text"),this}getTextContent(){const t=this.getNodes();if(0===t.length)return"";const e=t[0],n=t[t.length-1],o=this.anchor,r=this.focus,i=o.isBefore(r),[s,l]=yr(this);let c="",a=!0;for(let u=0;u(Pi(t)||Ki(t))&&!t.isInline())){Pi(r)||t(211,o.constructor.name,o.getType());const n=Xr(this);return r.splice(n,0,e),void i.selectEnd()}if(Pi(r)&&null!==ta(r)){const t=Xr(this),n=Gr(e);r.splice(t,0,n);const o=n[n.length-1];return void(void 0!==o?o.selectEnd():r.select(t,t))}if(null===r){const t=ti(e),n=t.getLastDescendant();let o=tu(this.anchor,"next");for(const e of t.getChildren())o=mu(e,o);return void(null!==n&&n.selectEnd())}if(Pi(r)&&!r.isParentRequired()&&!Bl(r.getParentOrThrow())){const t=Xr(this),n=Gr(e);r.splice(t,0,n);const o=n[n.length-1];return void(void 0!==o?o.selectEnd():r.select(t,t))}const s=ti(e),l=s.getLastDescendant(),c=s.getChildren(),a=!Pi(r)||!r.isEmpty()?this.insertParagraph():null;a&&!r.isAttached()&&(o=this.anchor.getNode(),r=qc(o,Sc));const u=c[c.length-1];let f=c[0];var d;Pi(d=f)&&Sc(d)&&!d.isEmpty()&&Pi(r)&&(!r.isEmpty()||r.canMergeWhenEmpty())&&(Pi(r)||t(211,o.constructor.name,o.getType()),r.append(...f.getChildren()),f=c[1]),f&&(null===r&&t(212,o.constructor.name,o.getType()),function(e,n){const o=n.getParentOrThrow().getLastChild();let r=n;const i=[n];for(;r!==o;)r.getNextSibling()||t(140),r=r.getNextSibling(),i.push(r);let s=e;for(const t of i)s=s.insertAfter(t)}(r,f));const h=qc(l,Sc);a&&Pi(h)&&(a.canMergeWhenEmpty()||Sc(u))&&(h.append(...a.getChildren()),a.remove()),Pi(r)&&r.isEmpty()&&r.remove(),l.selectEnd();const g=Pi(r)?r.getLastChild():null;Yi(g)&&h!==r&&g.remove()}insertParagraph(){const e=this.anchor.getNode();if("element"===this.anchor.type&&Bl(e)){const t=es();return e.splice(this.anchor.offset,0,[t]),t.select(),t}const n=Xr(this),o=qc(this.anchor.getNode(),Sc);if(null!==o&&null!==ta(o))return null;Pi(o)||t(213);const r=o.getChildAtIndex(n),i=r?[r,...r.getNextSiblings()]:[],s=o.insertNewAfter(this,!1);return s?(s.append(...i),s.selectStart(),s):null}insertLineBreak(t){const e=qi();if(this.insertNodes([e]),t){const t=e.getParentOrThrow(),n=e.getIndexWithinParent();t.select(n,n)}}extract(){const t=[...this.getNodes()],e=t.length;let n=t[0],o=t[e-1];const[r,i]=yr(this),s=this.isBackward(),[l,c]=s?[this.focus,this.anchor]:[this.anchor,this.focus],[a,u]=s?[i,r]:[r,i];if(0===e)return[];if(1===e){if(Xo(n)&&!this.isCollapsed()){const t=n.splitText(a,u),e=0===a?t[0]:t[1];return e?(l.set(e.getKey(),0,"text"),c.set(e.getKey(),e.getTextContentSize(),"text"),[e]):[]}return[n]}if(Xo(n)&&(a===n.getTextContentSize()?t.shift():0!==a&&([,n]=n.splitText(a),t[0]=n,l.set(n.getKey(),0,"text"))),Xo(o)){const e=o.getTextContent().length;0===u?t.pop():u!==e&&([o]=o.splitText(u),t[t.length-1]=o,c.set(o.getKey(),o.getTextContentSize(),"text"))}return t}modify(t,e,n){if(ei(this,t,e,n))return;const o="move"===t,r=_i(),i=Jl(Il(r));if(!i)return;const s=r._blockCursorElement,l=r._rootElement,c=this.focus.getNode();null===l||null===s||!Pi(c)||c.isInline()||c.canBeEmpty()||jl(s,r,l);const a=El(r,this.focus.key);let u=a;if("text"===this.focus.type&&(u=Xo(c)?wc(c,a,r):null),this.dirty){const t=El(r,this.anchor.key);let e=t;if("text"===this.anchor.type){const n=this.anchor.getNode();e=Xo(n)?wc(n,t,r):null}e&&u&&Ur(i,e,this.anchor.offset,u,this.focus.offset)}if("character"===n&&Xo(c)&&c.isUnmergeable()){if(e?0===this.focus.offset:this.focus.offset===c.getTextContentSize()){const t=Ia(c,e?"previous":"next").getNodeAtCaret();if(Xo(t)){if(!o){const n=t.getTextContentSize();return e?this.focus.set(t.__key,n-1,"text"):this.focus.set(t.__key,1,"text"),void(this.dirty=!0)}{const n=r.getElementByKey(t.getKey()),o=n?wc(t,n,r):null;if(o){const t=e?o.length:0;Ur(i,o,t,o,t)}}}}}if(Cr(i,t,e?"backward":"forward",n),i.rangeCount>0){const t=tc(i,r._rootElement),n=t||i.getRangeAt(0),s=this.anchor.getNode(),l=Bi(s)?s:Kl(s);if(this.applyDOMRange(n),this.dirty=!0,!o){Sr(this,e,l);(t?"backward"!==i.direction:i.anchorNode===n.startContainer&&i.anchorOffset===n.startOffset)||xr(this)}}"lineboundary"===n&&ei(this,t,e,n,"decorators")}forwardDeletion(t,e,n){if(!n&&("element"===t.type&&Pi(e)&&t.offset===e.getChildrenSize()||"text"===t.type&&t.offset===e.getTextContentSize())){const t=e.getParent(),n=e.getNextSibling()||(null===t?null:t.getNextSibling());if(Pi(n)&&n.isShadowRoot())return!0}return!1}deleteCharacter(t){const e=this.isCollapsed();if(this.isCollapsed()){const e=this.anchor;let n=e.getNode();if(this.forwardDeletion(e,n,t))return;const o=ja(tu(e,t?"previous":"next"));if(o.getTextSlices().every(t=>null===t||0===t.distance)){let t={type:"initial"};for(const e of o.iterNodeCarets("shadowRoot"))if(Aa(e))if(e.origin.isInline());else{if(e.origin.isShadowRoot()){if("merge-block"===t.type)break;if(Pi(o.anchor.origin)&&o.anchor.origin.isEmpty()){const t=au(e);ou(this,Va(t,t)),o.anchor.origin.remove()}return}"merge-next-block"!==t.type&&"merge-block"!==t.type||(t={block:t.block,caret:e,type:"merge-block"})}else{if("merge-block"===t.type)break;if(Ma(e)){if(Pi(e.origin)){if(e.origin.isInline()){if(!e.origin.isParentOf(o.anchor.origin))break}else t={block:e.origin,type:"merge-next-block"};continue}if(Ki(e.origin)){if(e.origin.isIsolated());else if(ia(e.origin).length>0){if(Pi(o.anchor.origin)&&o.anchor.origin.isEmpty()){o.anchor.origin.remove();const t=Pr();t.add(e.origin.getKey()),ol(t)}}else if("merge-next-block"===t.type&&(e.origin.isKeyboardSelectable()||!e.origin.isInline())&&Pi(o.anchor.origin)&&o.anchor.origin.isEmpty()){o.anchor.origin.remove();const t=Pr();t.add(e.origin.getKey()),ol(t)}else e.origin.remove();return}break}}if("merge-block"===t.type){const{caret:e,block:n}=t;if(ia(n).length>0)return;return e.origin.isEmpty()&&!n.isEmpty()&&e.origin.getParent()===n.getParent()?void e.origin.remove(!0):(ou(this,Va(!e.origin.isEmpty()&&n.isEmpty()?iu(Ia(n,e.direction)):o.anchor,e)),this.removeText())}for(let t=e.getNode();null!==t;){if(null!==ta(t))return;if(Pi(t)&&t.isShadowRoot())break;t=t.getParent()}}const r=this.focus;if(vr(this,t,"character"),this.isCollapsed()){if(t&&0===e.offset&&mr(this,e.getNode()))return}else{const o="text"===r.type?r.getNode():null;if(n="text"===e.type?e.getNode():null,null!==o&&o.isSegmented()){const e=r.offset,i=o.getTextContentSize();if(o.is(n)||t&&e!==i||!t&&0!==e)return void kr(o,t,e)}else if(null!==n&&n.isSegmented()){const r=e.offset,i=n.getTextContentSize();if(n.is(o)||t&&0!==r||!t&&r!==i)return void kr(n,t,r)}!function(t,e){const n=t.anchor,o=t.focus,r=n.getNode(),i=o.getNode();if(r===i&&"text"===n.type&&"text"===o.type){const t=n.offset,i=o.offset,s=t0&&(g===h.getTextContentSize()||Ks(h)||([h]=h.splitText(g)),h.setFormat(p));for(let t=a+1;t{for(const[e,o]of n)t=Ws(t,e,o?z[e]:0);return t})}function _r(t,e,n=null){const o=null===n&&ur(t)?Ws(t.format,e,null):n;hr(t,t=>Ws(t,e,o))}function pr(t){const e=t.offset;if("text"===t.type)return e;const n=t.getNode();return e===n.getChildrenSize()?n.getTextContent().length:0}function yr(t){const e=t.getStartEndPoints();if(null===e)return[0,0];const[n,o]=e;return"element"===n.type&&"element"===o.type&&n.key===o.key&&n.offset===o.offset?[0,0]:[pr(n),pr(o)]}function mr(t,e){for(let n=e;n;n=n.getParent()){if(Pi(n)){if(n.collapseAtStart(t))return!0;if(Bl(n))break}if(n.getPreviousSibling())break}return!1}function xr(t){const e=t.focus,n=t.anchor,o=n.key,r=n.offset,i=n.type;n.set(e.key,e.offset,e.type,!0),e.set(o,r,i,!0)}function Cr(t,e,n,o){t.modify(e,n,o)}function Sr(t,e,n){const o=t.getNodes(),r=o.filter(t=>Fl(t,n));if(0===r.length||r.length===o.length)return!1;const i=e?r[0]:r[r.length-1],s=Pi(i)?i:i.getParentOrThrow();return e?s.selectStart():s.selectEnd(),!0}function vr(t,e,n){if(ei(t,"extend",e,n))return;const o=_i(),r=Jl(Il(o));if(!r||"function"!=typeof r.modify)return;const i=o._blockCursorElement,s=o._rootElement,l=t.anchor,c=t.focus.getNode();null===s||null===i||!Pi(c)||c.isInline()||c.canBeEmpty()||jl(i,o,s);const a=t=>{const e=t.getNode(),n=o.getElementByKey(t.key);return null!==n&&"text"===t.type&&Xo(e)?wc(e,n,o):n},u=l.getNode(),f=a(l);if(null===f)return;const d=l.offset,h=t.isCollapsed(),g=t.focus,_=h?f:a(g);if(null===_)return;const p=g.offset;if(Ur(r,_,p,_,p),Cr(r,"move",e?"backward":"forward",n),0===r.rangeCount)return;const y=tc(r,s)||r.getRangeAt(0),m=y.startContainer,x=y.startOffset;if(h&&"character"===n&&"text"===l.type&&Xo(u)&&u.isUnmergeable()){if(d===(e?0:u.getTextContentSize())){const n=Ia(u,e?"previous":"next").getNodeAtCaret();if(Xo(n)){const o=e?n.getTextContentSize()-1:1;return t.focus.set(n.__key,o,"text"),void(t.dirty=!0)}}}if(h&&"character"===n&&"text"===l.type){const n=e?0:u.getTextContentSize(),o=m===f?x:d!==n?n:-1;if(o>=0)return void(o!==d&&(t.focus.set(l.key,o,"text"),t.dirty=!0))}const[C,S,v,T]=e?[m,x,f,d]:[f,d,m,x],k=Bi(u)?u:Kl(u);t.applyDOMRange({collapsed:!1,endContainer:v,endOffset:T,startContainer:C,startOffset:S}),t.dirty=!0,!Sr(t,e,k)&&e&&xr(t),"lineboundary"===n&&ei(t,"extend",e,n,"decorators")}const Tr=(()=>{try{const t=new RegExp("\\p{Emoji}","u"),e=t.test.bind(t);if(e("\u2764\ufe0f")&&e("#\ufe0f\u20e3")&&e("\u{1f44d}"))return e}catch(t){}return()=>!1})();function kr(t,e,n){const o=t,r=o.getTextContent().split(/(?=\s)/g),i=r.length;let s=0,l=0;for(let t=0;tn||o){r.splice(t,1),o&&(l=void 0);break}}const c=r.join("").trim();""===c?o.remove():(o.setTextContent(c),o.select(l,l))}function br(e,n,o,r){let i,s=n,l=!1;if(gc(e)){let c=!1;const a=e.childNodes,u=a.length,f=r._blockCursorElement;s===u&&u>0&&(c=!0,s=u-1),void 0!==Qs(e,r)||Rc(e,r)||(l=!0);let d=a[s],h=!1;if(d===f)d=a[s+1],h=!0;else if(null!==f){const t=f.parentNode;if(e===t){n>Array.prototype.indexOf.call(t.children,f)&&s--}}if(i=il(d),Xo(i))s=Ka(i,c?"next":"previous");else{let a=il(e);if(null===a)return null;if(Pi(a)){const l=r.getElementByKey(a.getKey());null===l&&t(214);const u=kc(a,l,r);[a,s]=u.resolveChildIndex(a,l,e,n),Pi(a)||t(215),c&&s>=a.getChildrenSize()&&(s=Math.max(0,a.getChildrenSize()-1));let f=a.getChildAtIndex(s);if(Pi(f)&&function(t,e,n){const o=t.getParent();return null===n||null===o||!o.canBeEmpty()||o!==n.getNode()}(f,0,o)){const t=c?f.getLastDescendant():f.getFirstDescendant();null===t?a=f:(f=t,a=Pi(f)?f:f.getParentOrThrow()),s=0}Xo(f)?(i=f,a=null,s=Ka(f,c?"next":"previous")):f!==a&&c&&!h&&(Pi(a)||t(216),s=Math.min(a.getChildrenSize(),s+1))}else{const t=ea(a),o=null!==t?t:a,i=o.getIndexWithinParent(),l=r.getElementByKey(a.getKey());let c="after";if(null!==l&&il(e)===a){const t=kc(a,l,r);t.element!==l?c=t.resolveLeafPosition(l,e,n):0===n&&Ki(a)&&(c="before")}s="before"===c?i:i+1,a=o.getParentOrThrow()}if(Pi(a))return[or(a.__key,s,"element"),l]}}else i=il(e);return Xo(i)?[or(i.__key,Ka(i,s,"clamp"),"text"),l]:null}function Nr(t,e,n){const o=t.offset,r=t.getNode();if(0===o){const o=r.getPreviousSibling(),i=r.getParent();if(e){if((n||!e)&&null===o&&Pi(i)&&i.isInline()){const e=i.getPreviousSibling();Xo(e)&&t.set(e.__key,e.getTextContent().length,"text")}}else Pi(o)&&!n&&o.isInline()?t.set(o.__key,o.getChildrenSize(),"element"):Xo(o)&&!r.isUnmergeable()&&t.set(o.__key,o.getTextContent().length,"text")}else if(o===r.getTextContent().length){const o=r.getNextSibling(),i=r.getParent();if(e&&Pi(o)&&o.isInline())t.set(o.__key,0,"element");else if((n||e)&&null===o&&Pi(i)&&i.isInline()&&!i.canInsertTextAfter()&&i.getTextContentSize()>1){const e=i.getNextSibling();Xo(e)&&t.set(e.__key,0,"text")}}}function Er(t){const e=Ys(t.key);return null===e?null:oa(e)}function wr(t,e,n){const o=Er(t),r=Er(e);if(o===r||null!==o&&null!==r&&o.is(r))return!1;const i=n(o,r);if(null!==o)return Pi(o)?e.set(o.getKey(),i?o.getChildrenSize():0,"element"):e.set(o.getKey(),i?o.getTextContentSize():0,"text"),!0;const s=ea(r);if(null===s)return!1;const l=s.getParent();if(null===l)return!1;const c=s.getIndexWithinParent();return e.set(l.getKey(),i?c+1:c,"element"),!0}function Or(t){const e=wr(t.anchor,t.focus,(e,n)=>function(t,e,n,o){if(null!==n&&null!==o){const t=ea(n),e=ea(o);if(null!==t&&t.is(e)){for(const e of ra(t).values()){if(e===n.getKey())return!0;if(e===o.getKey())return!1}return!0}return null===t||null===e||t.isBefore(e)}if(null!==n){const t=ea(n),o=Ys(e.key);return null===t||null===o||!(!t.is(o)&&!t.isParentOf(o))||t.isBefore(o)}const r=ea(o),i=Ys(t.key);return null!==r&&null!==i&&!r.is(i)&&!r.isParentOf(i)&&i.isBefore(r)}(t.anchor,t.focus,e,n));return e&&(t.dirty=!0),e}function Mr(t,e,n,o,r,i){if(null===t||null===n||!As(r,t,n))return null;const s=br(t,e,ur(i)?i.anchor:null,r);if(null===s)return null;const l=br(n,o,ur(i)?i.focus:null,r);if(null===l)return null;const[c,a]=s,[u,f]=l;if("element"===c.type&&"element"===u.type){const e=il(t),o=il(n);if(Ki(e)&&Ki(o))return null}const d=r._slotsUsed&&wr(c,u,()=>0!==(t.compareDocumentPosition(n)&Node.DOCUMENT_POSITION_FOLLOWING));return function(t,e){if("text"===t.type&&"text"===e.type){const n=t.isBefore(e),o=t.is(e);Nr(t,n,o),Nr(e,!n,o),o&&e.set(t.key,t.offset,t.type)}}(c,u),[c,u,a||f||d]}function Ar(t){return Pi(t)&&!t.isInline()}function Dr(t,e,n,o,r,i){const s=hi(),l=new fr(or(t,e,r),or(n,o,i),0,"");return l.dirty=!0,s._selection=l,l}function Fr(){const t=or("root",0,"element"),e=or("root",0,"element");return new fr(t,e,0,"")}function Pr(){return new cr(new Set)}function Ir(t,e){return Lr(null,t,e,null)}function Lr(t,e,n,o){const r=n._window;if(null===r)return null;const i=o||r.event,s=i?i.type:void 0,l="selectionchange"===s,c=!it&&(l||"beforeinput"===s||"compositionstart"===s||"compositionend"===s||"click"===s&&i&&3===i.detail||"drop"===s||void 0===s);let a,u,f,d;if(ur(t)&&!c)return t.clone();{if(null===e)return null;const o=nc(e,n._rootElement);if(a=o.anchorNode,u=o.focusNode,f=o.anchorOffset,d=o.focusOffset,(l||void 0===s)&&ur(t)&&!As(n,a,u))return t.clone()}const h=Mr(a,f,u,d,n,t);if(null===h)return null;const[g,_,p]=h;let y=0,m="";if(ur(t)){const e=t.anchor;if(g.key===e.key)y=t.format,m=t.style;else{const t=g.getNode();Xo(t)?(y=t.getFormat(),m=t.getStyle()):Pi(t)&&(y=t.getTextFormat(),m=t.getTextStyle())}}const x=new fr(g,_,y,m);return p&&(x.dirty=!0),x}function Kr(){return hi()._selection}function zr(){return _i()._editorState._selection}function Br(t,e,n,o=1){const r=t.anchor,i=t.focus,s=r.getNode(),l=i.getNode();if(!e.is(s)&&!e.is(l))return;const c=e.__key;if(t.isCollapsed()){const e=r.offset;if(n<=e&&o>0||n0||n0||n=t,s=r?i.getChildAtIndex(t-1):i.getChildAtIndex(n);if(Xo(s)){let t=0;r&&(t=s.getTextContentSize()),e.set(s.__key,t,"text"),o.set(s.__key,t,"text")}return}if(Pi(i)){const t=i.getChildrenSize(),o=n>=t,r=o?i.getChildAtIndex(t-1):i.getChildAtIndex(n);if(Xo(r)){let t=0;o&&(t=r.getTextContentSize()),e.set(r.__key,t,"text")}}if(Pi(s)){const t=s.getChildrenSize(),e=r>=t,n=e?s.getChildAtIndex(t-1):s.getChildAtIndex(r);if(Xo(n)){let t=0;e&&(t=n.getTextContentSize()),o.set(n.__key,t,"text")}}}function Wr(t,e,n,o,r){let i=null,s=0,l=null;null!==o?(i=o.__key,Xo(o)?(s=o.getTextContentSize(),l="text"):Pi(o)&&(s=o.getChildrenSize(),l="element")):null!==r&&(i=r.__key,Xo(r)?l="text":Pi(r)&&(l="element")),null!==i&&null!==l?t.set(i,s,l):(s=e.getIndexWithinParent(),-1===s&&(s=n.getChildrenSize()),t.set(n.__key,s,"element"))}function $r(t,e,n,o,r){"text"===t.type?t.set(n,t.offset+(e?0:r),"text"):t.offset>o.getIndexWithinParent()&&t.set(t.key,t.offset-1,"element")}function Ur(t,e,n,o,r){try{t.setBaseAndExtent(e,n,o,r)}catch(t){}}function Hr(t,e,n){const o=El(t,e.getKey());if(Pi(e)){const r=kc(e,o,t);return[r.element,n+r.getFirstChildOffset()]}return[o,n]}function jr(t,e,n,o,r,s){const l=s.getRootNode(),c=Bs(l)||ql(l)?cc(l):null;if(r.has(vo)&&c!==s||null!==c&&Os(c,c))return;const a=nc(o,s);let u;if(!ur(e))return void(null!==t&&As(n,a.anchorNode,a.focusNode)&&o.removeAllRanges());const f=e.anchor,d=e.focus,h=f.getNode(),g=d.getNode(),[_,p]=Hr(n,h,f.offset),[y,m]=Hr(n,g,d.offset),x=e.format,C=e.style,S=e.isCollapsed();let v=_,T=y,k=!1;if("text"===f.type?(v=Xo(h)?wc(h,_,n):null,k=h.getFormat()!==x||h.getStyle()!==C):ur(t)&&"text"===t.anchor.type&&(k=!0),"text"===d.type&&(T=Xo(g)?wc(g,y,n):null),null!==v&&null!==T){if(S&&(null===t||k||ur(t)&&(t.format!==x||t.style!==C))&&function(t,e,n,o,r,i){t._inputState.collapsedSelectionFormat={format:e,key:r,offset:o,style:n,timeStamp:i}}(n,x,C,p,f.key,performance.now()),("Range"!==o.type||!S)&&a.anchorOffset===p&&a.focusOffset===m&&a.anchorNode===v&&a.focusNode===T){if(null===c||!s.contains(c)){const t=null!==c?Fs(c):null;null!==t&&t!==n||r.has(No)||s.focus({preventScroll:!0})}if("element"!==f.type)return}if(Ur(o,v,p,T,m),i&&e.isCollapsed()&&null!==s&&!r.has(No)){const t=lc(s);if(null===t||!s.contains(t)){const t=cc(s.ownerDocument),e=null!==t?Fs(t):null;null!==e&&e!==n||s.focus({preventScroll:!0})}}if(!r.has(ko)&&e.isCollapsed()&&null!==s&&s===lc(s)){const t=ur(e)&&"element"===e.anchor.type?v.childNodes[p]||null:(void 0===u&&(u=ec(o,s)),u);if(null!==t){let e;if(zs(t)){const n=t.ownerDocument.createRange();n.selectNode(t),e=n.getBoundingClientRect()}else e=t.getBoundingClientRect();!function(t,e,n){const o=Ol(n),r=Pl(o);if(null===o||null===r)return;const i=n.getBoundingClientRect();if(e.bottoma&&(f=l-a),0!==f)if(e)r.scrollBy(0,f);else{const t=u.scrollTop;u.scrollTop+=f;const e=u.scrollTop-t;s-=e,l-=e}if(e)break;u=wl(u)}}(n,e,s)}}!function(t){t._inputState.isSelectionChangeFromDOMUpdate=!0}(n)}}function Jr(t){let e=Kr()||zr();null===e&&(e=nl().selectEnd()),e.insertNodes(t)}function Vr(t,e){for(const n of t.split(/(\r?\n|\t)/))"\n"===n||"\r\n"===n?e.linebreak():"\t"===n?e.tab():""!==n&&e.text(n)}function qr(t){const e=[];return Vr(t,{linebreak:()=>e.push(qi()),tab:()=>e.push(tr()),text:t=>e.push(Go(t))}),e}function Yr(){const t=Kr();return null===t?"":t.getTextContent()}function Gr(t){const e=[];for(const n of t)Yi(n)||(!Pi(n)&&!Ki(n)||n.isInline()?e.push(n):Pi(n)&&e.push(...Gr(n.getChildren())));return e}function Xr(e){let n=e;e.isCollapsed()||n.removeText();const o=Kr();ur(o)&&(n=o),ur(n)||t(161);const r=n.anchor;let i=r.getNode(),s=r.offset;for(;!Sc(i)&&null===ta(i);){const t=i;if([i,s]=Qr(i,s),t.is(i))break}return s}function Qr(t,e){const n=t.getParent();if(!n){const t=es();return nl().append(t),t.select(),[nl(),0]}if(Xo(t)){const o=t.splitText(e);if(0===o.length)return[n,t.getIndexWithinParent()];const r=0===e?0:1;return[n,o[0].getIndexWithinParent()+r]}if(!Pi(t)||0===e)return[n,t.getIndexWithinParent()];const o=t.getChildAtIndex(e);if(o){const n=new fr(or(t.__key,e,"element"),or(t.__key,e,"element"),0,""),r=t.insertNewAfter(n);r&&r.append(o,...o.getNextSiblings())}return[n,t.getIndexWithinParent()+1]}function Zr(t){return Yi(t)||Ll(t)||Xo(t)||t.isParentRequired()}function ti(t){const e=es();let n=null;for(let o=0;o99&&t(14)}function hi(){return null===ni&&t(195,yi()),ni}function gi(t){null!==hi()&&null===oi&&(oi=t),oi!==t&&e(378)}function _i(){return null===oi&&t(337,yi()),oi}function pi(){_i()._dirtyType=2}function yi(){let t=0;const e=new Set,n=Cs.version;if("undefined"!=typeof window)for(const o of Xl(document)){const r=Ps(o);if(Ds(r))t++;else if(r){let t=String(r.constructor.version||"<0.17.1");t===n&&(t+=" (separately built, likely a bundler configuration issue)"),e.add(t)}}let o=` Detected on the page: ${t} compatible editor(s) with version ${n}`;return e.size&&(o+=` and incompatible editors with versions ${Array.from(e).join(", ")}`),o}function mi(){return oi}function xi(t,e,n){const o=e.__type,r=Ns(t,o);let i=n.get(o);void 0===i&&(i=Array.from(r.transforms),n.set(o,i));const s=i.length;for(let t=0;t0&&wi(t,t._deferred));const i=t._editorState,s=i._selection,l=n._selection,c=0!==t._dirtyType,a=ni,u=ri,f=oi,d=t._updating,h=t._observer;let g=null;if(t._pendingEditorState=null,t._editorState=n,!r&&c&&null!==h){oi=t,ni=n,ri=!1,t._updating=!0;try{const e=t._dirtyType,o=t._dirtyElements,r=t._dirtyLeaves;h.disconnect(),g=De(i,n,t,e,o,r)}catch(e){if(e instanceof Error&&t._onError(e),ii)throw e;return gs(t,null,o,n),gt(t),t._dirtyType=2,ii=!0,bi(t,i),void(ii=!1)}finally{h.observe(o,ai),t._updating=d,ni=a,ri=u,oi=f}}n._readOnly||(n._readOnly=!0);const _=t._dirtyLeaves,p=t._dirtyElements,y=t._normalizedNodes,m=t._updateTags;c&&(t._dirtyType=0,t._cloneNotNeeded.clear(),t._dirtyLeaves=new Set,t._dirtyElements=new Map,t._normalizedNodes=new Set);t._updateTags=new Set,function(t,e){const n=t._decorators;let o=t._pendingDecorators||n;const r=e._nodeMap;let i;for(i in o)r.has(i)||(o===n&&(o=tl(t)),delete o[i])}(t,n);const x=r?null:Jl(Il(t));if(t._editable&&null!==x&&(c||null===l||l.dirty||!l.is(s))&&null!==o&&!m.has(bo)){oi=t,ni=n;try{if(null!==h&&h.disconnect(),c||null===l||l.dirty){const e=t._blockCursorElement;null!==e&&jl(e,t,o),jr(s,l,t,x,m,o)}!function(t,e,n){let o=t._blockCursorElement;if(ur(n)&&n.isCollapsed()&&"element"===n.anchor.type&&e.contains(lc(e))){const r=n.anchor,i=r.getNode(),s=r.offset;let l=!1,c=null;if(s===i.getChildrenSize()){Hl(i.getChildAtIndex(s-1))&&(l=!0)}else{const e=i.getChildAtIndex(s);if(null!==e&&Hl(e)){const n=e.getPreviousSibling();(null===n||Hl(n))&&(l=!0,c=t.getElementByKey(e.__key))}}if(l){const n=kc(i,t.getElementByKey(i.__key),t).element;return null===o&&(t._blockCursorElement=o=function(t){const e=t.theme,n=Zl().createElement("div");n.contentEditable="false",n.setAttribute("data-lexical-cursor","true");let o=e.blockCursor;if(void 0!==o){if("string"==typeof o){const t=ku(o);o=e.blockCursor=t}void 0!==o&&n.classList.add(...o)}return n}(t._config)),e.style.caretColor="transparent",void(null===c?n.appendChild(o):n.insertBefore(o,c))}}null!==o&&jl(o,t,e)}(t,o,l)}finally{null!==h&&h.observe(o,ai),oi=f,ni=a}}null!==g&&function(t,e,n,o,r){const i=Array.from(t._listeners.mutation),s=i.length;for(let t=0;t{li.delete(t),t._cascadeCount=0},0)}(t),t._cascadeCount++>99)return t._updates=[],t._cascadeCount=0,void t._onWarn(new Error(`One or more update listeners are endlessly enqueueing more updates. May have encountered infinite recursion caused by update listeners that trigger additional updates without a stop condition. Editor namespace: ${t._config.namespace}`));const n=e.shift();if(n){const[e,o]=n;Mi(t,e,o)}}(t)}(t,e)}finally{si=n}}function Ni(t,e,n,...o){const r=e._updating;e._updating=n;try{const n=e._listeners[t],r=Array.from(n);for(const[t,e]of r){e&&e();const r=t(...o);n.has(t)?n.set(t,r):r&&r()}}finally{e._updating=r}}function Ei(t,e,n,o){const r=ll(t);let i;if(!si)for(let t=0;t=0;t--)for(let s=0;s0&&l._updating){i=l;break}const c=l._commands.get(e);if(void 0!==c){const e=c[t];if(e.size>0){let t=!1;if(Ai(l,()=>{for(const r of e)if(r(n,o))return void(t=!0)}),t)return t}}}return i&&i.update(()=>{Ei(i,e,n,o)}),!1}function wi(t,e){if(t._deferred=[],0!==e.length){const n=t._updating;t._updating=!0;try{for(let t=0;t0||u>0;){if(c>0){e._dirtyLeaves=new Set;for(const t of l){const o=r.get(t);Xo(o)&&o.isAttached()&&o.isSimpleText()&&!o.isUnmergeable()&&Pt(o),void 0!==o&&Ci(o,i)&&xi(e,o,s),n.add(t)}if(l=e._dirtyLeaves,c=l.size,c>0){ci++;continue}}e._dirtyLeaves=new Set,e._dirtyElements=new Map,a.delete("root")&&a.set("root",!0);for(const t of a){const n=t[0],l=t[1];if(o.set(n,l),!l)continue;const c=r.get(n);void 0!==c&&Ci(c,i)&&xi(e,c,s)}l=e._dirtyLeaves,c=l.size,a=e._dirtyElements,u=a.size,ci++}e._dirtyLeaves=n,e._dirtyElements=o}(a,e),Oi(e),function(t,e,n,o){const r=t._nodeMap,i=e._nodeMap,s=[];for(const[t]of o){const e=i.get(t);void 0!==e&&(e.isAttached()||(Pi(e)&&rt(e,t,r,i,s,o),r.has(t)||o.delete(t),s.push(t)))}for(const t of n){const e=i.get(t);void 0===e||e.isAttached()||(Qc(e)&&null!==e.__slots&&rt(e,t,r,i,s,n),r.has(t)||n.delete(t),s.push(t))}for(const t of s)i.delete(t);const l=_i(),c=l._compositionKey;null===c||i.has(c)||(l._compositionKey=null)}(c,a,e._dirtyLeaves,e._dirtyElements));r!==e._compositionKey&&(a._flushSync=!0);const i=a._selection;if(ur(i)){e._slotsUsed&&Or(i);const n=a._nodeMap,o=i.anchor.key,r=i.focus.key;void 0!==n.get(o)&&void 0!==n.get(r)||t(19)}else dr(i)&&0===i._nodes.size&&(a._selection=null)}catch(t){return t instanceof Error&&e._onError(t),e._pendingEditorState=c,e._dirtyType=2,e._cloneNotNeeded.clear(),e._dirtyLeaves=new Set,e._dirtyElements.clear(),void bi(e)}finally{ni=f,ri=d,oi=h,e._updating=g,ci=0}const p=0!==e._dirtyType||e._deferred.length>0||function(t,e){const n=e.getEditorState()._selection,o=t._selection;if(null!==o){if(o.dirty||!o.is(n))return!0}else if(null!==n)return!0;return!1}(a,e);p?a._flushSync?(a._flushSync=!1,bi(e)):u&&ws(()=>{bi(e)}):(a._flushSync=!1,u&&(r.clear(),e._deferred=[],e._pendingEditorState=null))}function Ai(t,e,n){oi===t&&void 0===n?ui()?Mi(t,e,n):e():Mi(t,e,n)}function Di(t){if(Bl(t)){let e=null;for(const n of t.getChildren())e=n.isInline()?(e||n.replace(n.createParentElementNode())).append(n):null}}class Fi extends _o{__first;__last;__size;__format;__style;__indent;__dir;__textFormat;__textStyle;__slotHost;__slots;$config(){return this.config(Symbol.for("ElementNode"),{$transform:Di,extends:_o})}constructor(t){super(t),this.__first=null,this.__last=null,this.__size=0,this.__format=0,this.__style="",this.__indent=0,this.__dir=null,this.__textFormat=0,this.__textStyle="",this.__slotHost=null,this.__slots=null}afterCloneFrom(e){super.afterCloneFrom(e),this.__key===e.__key&&(this.__first=e.__first,this.__last=e.__last,this.__size=e.__size,this.__slotHost=e.__slotHost,null!==this.__slotHost&&null!==this.__parent&&t(384,this.__key,String(this.__slotHost),String(this.__parent)),this.__slots=e.__slots),this.__indent=e.__indent,this.__format=e.__format,this.__style=e.__style,this.__dir=e.__dir,this.__textFormat=e.__textFormat,this.__textStyle=e.__textStyle}getFormat(){return this.getLatest().__format}getFormatType(){const t=this.getFormat();return W[t]||""}getStyle(){return this.getLatest().__style}getIndent(){return this.getLatest().__indent}getChildren(){const t=[];let e=this.getFirstChild();for(;null!==e;)t.push(e),e=e.getNextSibling();return t}getChildrenKeys(){const t=[];let e=this.getFirstChild();for(;null!==e;)t.push(e.__key),e=e.getNextSibling();return t}getChildrenSize(){return this.getLatest().__size}isEmpty(){return 0===this.getChildrenSize()&&0===ia(this).length}isDirty(){const t=_i()._dirtyElements;return null!==t&&t.has(this.__key)}isLastChild(){const t=this.getLatest(),e=this.getParentOrThrow().getLastChild();return null!==e&&e.is(t)}getAllTextNodes(){const t=[];for(const e of ia(this)){const n=sa(this,e);Pi(n)&&t.push(...n.getAllTextNodes())}let e=this.getFirstChild();for(;null!==e;){if(Xo(e)&&t.push(e),Pi(e)){const n=e.getAllTextNodes();t.push(...n)}e=e.getNextSibling()}return t}getFirstDescendant(){let t=this.getFirstChild();for(;Pi(t);){const e=t.getFirstChild();if(null===e)break;t=e}return t}getLastDescendant(){let t=this.getLastChild();for(;Pi(t);){const e=t.getLastChild();if(null===e)break;t=e}return t}getDescendantByIndex(t){const e=this.getChildren(),n=e.length;if(t>=n){const t=e[n-1];return Pi(t)&&t.getLastDescendant()||t||null}const o=e[t];return Pi(o)&&o.getFirstDescendant()||o||null}getFirstChild(){const t=this.getLatest().__first;return null===t?null:Ys(t)}getFirstChildOrThrow(){const e=this.getFirstChild();return null===e&&t(45,this.__key),e}getLastChild(){const t=this.getLatest().__last;return null===t?null:Ys(t)}getLastChildOrThrow(){const e=this.getLastChild();return null===e&&t(96,this.__key),e}getChildAtIndex(t){const e=this.getChildrenSize();let n,o;if(t=t;){if(o===t)return n;n=n.getPreviousSibling(),o--}return null}getTextContent(){let t=ha(this);const e=this.getChildren(),n=e.length;for(let o=0;ot.remove()),t}append(...t){return this.splice(this.getChildrenSize(),0,t)}setDirection(t){const e=this.getWritable();return e.__dir=t,e}setFormat(t){return this.getWritable().__format=""!==t&&R[t]||0,this}setStyle(t){return this.getWritable().__style=t||"",this}setTextFormat(t){const e=this.getWritable();return e.__textFormat=t,e}setTextStyle(t){const e=this.getWritable();return e.__textStyle=t,e}setIndent(t){return this.getWritable().__indent=t,this}splice(e,n,o){ho(this)&&t(324,this.__key,this.__type);const r=this.getChildrenSize(),i=this.getWritable();e+n<=r||t(226,String(e),String(n),String(r));for(const t of o);const s=i.__key,l=[],c=[],a=this.getChildAtIndex(e+n);let u=null,f=r-n+o.length;if(0!==e)if(e===r)u=this.getLastChild();else{const t=this.getChildAtIndex(e);null!==t&&(u=t.getPreviousSibling())}if(n>0){let e=null===u?this.getFirstChild():u.getNextSibling();for(let o=0;o0&&(e.style.paddingInlineStart=40*t+"px",e.setAttribute("data-lexical-indent",String(t)));const n=this.getDirection();n&&(e.dir=n)}return{element:e}}exportJSON(){const t={children:[],direction:this.getDirection(),format:this.getFormatType(),indent:this.getIndent(),...super.exportJSON()},e=this.getTextFormat(),n=this.getTextStyle();return 0===e&&""===n||Bl(this)||this.getChildren().some(Xo)||(0!==e&&(t.textFormat=e),""!==n&&(t.textStyle=n)),t}updateFromJSON(t){return super.updateFromJSON(t).setFormat(t.format).setIndent(t.indent).setDirection(t.direction).setTextFormat(t.textFormat||0).setTextStyle(t.textStyle||"")}insertNewAfter(t,e){return null}canIndent(){return!0}collapseAtStart(t){return!1}excludeFromCopy(t){return!1}canReplaceWith(t){return!0}canInsertAfter(t){return!0}canBeEmpty(){return!0}canInsertTextBefore(){return!0}canInsertTextAfter(){return!0}isInline(){return!1}isShadowRoot(){return!1}canMergeWith(t){return!1}extractWithChild(t,e,n){return!1}canMergeWhenEmpty(){return!1}reconcileObservedMutation(t,e){const n=kc(this,t,e);let o=n.getFirstChild();for(let t=this.getFirstChild();t;t=t.getNextSibling()){const r=e.getElementByKey(t.getKey());null!==r&&(null==o?(n.insertChild(r),o=r):o!==r&&n.replaceChild(r,o),o=o.nextSibling)}}}function Pi(t){return t instanceof Fi}function Ii(t,e,n){let o=t.getNode();for(;o;){const t=o.__key;if(e.has(t)&&!n.has(t))return!0;o=o.getParent()}return!1}class Li extends _o{__slotHost;__slots;constructor(t){super(t),this.__slotHost=null,this.__slots=null}afterCloneFrom(e){super.afterCloneFrom(e),this.__key===e.__key&&(this.__slotHost=e.__slotHost,null!==this.__slotHost&&null!==this.__parent&&t(383,this.__key,String(this.__slotHost),String(this.__parent)),this.__slots=e.__slots)}decorate(t,e){return null}isIsolated(){return!1}isInline(){return!0}isKeyboardSelectable(){return!0}}function Ki(t){return t instanceof Li}class zi extends Fi{__cachedText;$config(){return this.config("root",{extends:Fi})}constructor(){super("root"),this.__cachedText=null}getTopLevelElementOrThrow(){t(51)}getTextContent(){const t=this.__cachedText;return null===t||!ui()&&0!==_i()._dirtyType?super.getTextContent():t}remove(){t(52)}replace(e){t(53)}insertBefore(e){t(54)}insertAfter(e){t(55)}updateDOM(t,e){return!1}splice(e,n,o){for(const e of o)Pi(e)||Ki(e)||t(282);return super.splice(e,n,o)}static importJSON(t){return nl().updateFromJSON(t)}collapseAtStart(){return!0}}function Bi(t){return t instanceof zi}function Ri(t){return new Hi(nt(t._nodeMap),null,t._slotsUsed)}function Wi(){return new Hi(new Map([["root",new zi]]),null,!1)}function $i(e){const n=e.exportJSON(),o=e.constructor;if(n.type!==o.getType()&&t(130,o.name),Pi(e)){const r=n.children;Array.isArray(r)||t(59,o.name);const i=e.getChildren();for(let t=0;t0){const i={};for(const n of r){const r=sa(e,n);null===r&&t(366,o.name,n),i[n]=$i(r)}n.$slots=i}return n}function Ui(t){return t instanceof Hi}class Hi{_nodeMap;_selection;_flushSync;_readOnly;_parsed;_slotsUsed;constructor(t,e=null,n=!1){this._nodeMap=t,this._selection=e||null,this._flushSync=!1,this._readOnly=!1,this._parsed=!1,this._slotsUsed=n}isEmpty(){return 1===this._nodeMap.size&&null===this._selection}read(t,e){return ki(e&&e.editor||null,this,t)}clone(t){const e=new Hi(this._nodeMap,void 0===t?this._selection:t,this._slotsUsed);return e._readOnly=!0,e}toJSON(){return ki(null,this,()=>({root:$i(nl())}))}}class ji extends Fi{$config(){return this.config("artificial",{extends:Fi})}createDOM(t){return Zl().createElement("div")}}class Ji extends _o{$config(){return this.config("linebreak",{importDOM:{br:t=>Gi(t)||Xi(t)?null:{conversion:Vi,priority:0}}})}getTextContent(){return"\n"}createDOM(){return Zl().createElement("br")}updateDOM(){return!1}isInline(){return!0}}function Vi(t){return{node:qi()}}function qi(){return Wl(new Ji)}function Yi(t){return t instanceof Ji}function Gi(t){const e=t.parentElement;if(null!==e&&Cc(e)){const n=e.firstChild;if(n===t||n.nextSibling===t&&Qi(n)){const n=e.lastChild;if(n===t||n.previousSibling===t&&Qi(n))return!0}}return!1}function Xi(t){const e=t.parentElement;if(null!==e&&Cc(e)){const n=e.firstChild;if(n===t||n.nextSibling===t&&Qi(n))return!1;const o=e.lastChild;if(o===t||o.previousSibling===t&&Qi(o))return!0}return!1}function Qi(t){return zs(t)&&/^( |\t|\r?\n)+$/.test(t.textContent||"")}class Zi extends Fi{$config(){return this.config("paragraph",{extends:Fi,importDOM:{p:()=>({conversion:ts,priority:0})}})}createDOM(t){const e=Zl().createElement("p"),n=Cl(t.theme,"paragraph");if(void 0!==n){e.classList.add(...n)}return e}updateDOM(t,e,n){return!1}exportDOM(t){const{element:e}=super.exportDOM(t);if(gc(e)){this.isEmpty()&&e.append(Zl().createElement("br"));const t=this.getFormatType();t&&(e.style.textAlign=t)}return{element:e}}exportJSON(){const t=super.exportJSON();if(void 0===t.textFormat||void 0===t.textStyle){const e=this.getChildren().find(Xo);e?(t.textFormat=e.getFormat(),t.textStyle=e.getStyle()):(t.textFormat=this.getTextFormat(),t.textStyle=this.getTextStyle())}return t}insertNewAfter(t,e){const n=es();n.setTextFormat(t.format),n.setTextStyle(t.style);const o=this.getDirection();return n.setDirection(o),n.setFormat(this.getFormatType()),n.setStyle(this.getStyle()),this.insertAfter(n,e),n}collapseAtStart(){const t=this.getChildren();if(0===t.length||Xo(t[0])&&""===t[0].getTextContent().trim()){if(null!==this.getNextSibling())return this.selectNext(),this.remove(),!0;if(null!==this.getPreviousSibling())return this.selectPrevious(),this.remove(),!0}return!1}}function ts(t){const e=es();if(Lc(e,t),Pc(t,e),""===e.getFormatType()){const n=t.getAttribute("align");n&&n&&n in R&&e.setFormat(n)}return Ic(e,t),{node:e}}function es(){return Wl(new Zi)}function ns(t){return t instanceof Zi}function os(t){console.warn(t)}const rs=0,is=1,ss=2,ls=3,cs=4,as=-8,us=-7,fs=-6,ds=-5,hs=-4;function gs(t,e,n,o,r){const i=t._keyToDOMMap;i.clear(),t._editorState=Wi(),t._pendingEditorState=o,t._compositionKey=null,t._dirtyType=0,t._cloneNotNeeded.clear(),t._dirtyLeaves=new Set,t._dirtyElements.clear(),t._normalizedNodes=new Set,r&&r.preserveUpdateQueue||(t._updateTags=new Set,t._updates=[],t._cascadeCount=0),t._blockCursorElement=null,null!==t._inputState.handledSelectionCommandTimeoutId&&clearTimeout(t._inputState.handledSelectionCommandTimeoutId),t._inputState={collapsedSelectionFormat:{format:0,key:"root",offset:0,style:"",timeStamp:0},compositionEndData:"",compositionPhase:"idle",hadOrphanedCompositionEvents:!1,handledSelectionCommandTimeoutId:null,isInsertLineBreak:!1,isInsertTextAfterHandledSelectionCommand:!1,isSelectionChangeFromDOMUpdate:!1,isSelectionChangeFromMouseDown:!1,lastBeforeInputInsertTextTimeStamp:0,lastKeyCode:null,lastKeyDownTimeStamp:0,postDeleteSelectionToRestore:null,unprocessedBeforeInputData:null};const s=t._observer;null!==s&&(s.disconnect(),t._observer=null),null!==e&&(e.textContent="",function(t,e){const n=`__lexicalKey_${e._key}`;delete t[n]}(e,t)),null!==n&&(n.textContent="",i.set("root",n),Xs(n,t,"root"))}function _s(t){const e=new Set,n=new Set;for(const{klass:o,ownNodeConfig:r}of jc(t)){const t=o.transform;if(!n.has(t)){n.add(t);const r=o.transform();r&&e.add(r)}if(r){const t=r.$transform;t&&e.add(t)}}return e}const ps={$createDOM:(t,e)=>t.createDOM(e._config,e),$decorateDOM:(t,e,n,o)=>{},$exportDOM:(t,e)=>{const n=Es(e,t.getType());return n&&void 0!==n.exportDOM?n.exportDOM(e,t):t.exportDOM(e)},$extractWithChild:(t,e,n,o,r)=>Pi(t)&&t.extractWithChild(e,n,o),$getDOMSlot:(t,e,n)=>t.getDOMSlot(e),$getSlotTargetElement:(t,e,n,o)=>null,$shouldExclude:(t,e,n)=>Pi(t)&&t.excludeFromCopy("html"),$shouldInclude:(t,e,n)=>!e||t.isSelected(e),$updateDOM:(t,e,n,o)=>t.updateDOM(e,n,o._config)};function ys(e){const n=e||{},o=mi(),r=n.theme||{},i=void 0===e?o:n.parentEditor||null,s=n.disableEvents||!1,l=Wi(),c=n.namespace||(null!==i?i._config.namespace:cl()),a=n.editorState,u=[zi,Wo,Ji,Zo,Zi,ji,...n.nodes||[]],{onError:f,onWarn:d,html:h}=n,g=void 0===n.editable||n.editable;let _;if(void 0===e&&null!==o)_=o._nodes;else{_=new Map;for(let e=0;e{Object.keys(t).forEach(e=>{let o=n.get(e);void 0===o&&(o=[],n.set(e,o)),o.push(t[e])})};return t.forEach(t=>{const e=t.klass.importDOM;if(null==e||o.has(e))return;o.add(e);const n=e.call(t.klass);null!==n&&r(n)}),e&&r(e),n}(_,h?h.import:void 0),g,e);return void 0!==a&&(p._pendingEditorState=a,p._dirtyType=2),function(t){t.registerCommand(ze,Yn,rs),t.registerCommand(Be,Gn,rs),t.registerCommand(Re,Xn,rs),t.registerCommand(We,Qn,rs),t.registerCommand(tn,eo,rs)}(p),p}function ms(t,e){const n=t.get(e);t.delete(e),n&&n()}function xs(t,e,n){return t.set(e,n),ms.bind(null,t,e)}class Cs{static version;_headless;_parentEditor;_rootElement;_editorState;_pendingEditorState;_compositionKey;_deferred;_keyToDOMMap;_updates;_updating;_cascadeCount;_listeners;_commands;_nodes;_decorators;_pendingDecorators;_config;_dirtyType;_cloneNotNeeded;_dirtyLeaves;_dirtyElements;_normalizedNodes;_updateTags;_observer;_key;_onError;_onWarn;_htmlConversions;_window;_editable;_blockCursorElement;_slotsUsed;_inputState;_createEditorArgs;constructor(t,e,n,o,r,i,s,l,c){this._createEditorArgs=c,this._parentEditor=e,this._rootElement=null,this._editorState=t,this._pendingEditorState=null,this._compositionKey=null,this._deferred=[],this._keyToDOMMap=new ot,this._updates=[],this._updating=!1,this._cascadeCount=0,this._listeners={decorator:new Map,editable:new Map,mutation:new Map,root:new Map,textcontent:new Map,update:new Map},this._commands=new Map,this._config=o,this._nodes=n,this._decorators={},this._pendingDecorators=null,this._dirtyType=0,this._cloneNotNeeded=new Set,this._dirtyLeaves=new Set,this._dirtyElements=new Map,this._normalizedNodes=new Set,this._updateTags=new Set,this._observer=null,this._key=cl(),this._onError=r,this._onWarn=i,this._htmlConversions=s,this._editable=l,this._headless=null!==e&&e._headless,this._window=null,this._blockCursorElement=null,this._slotsUsed=!1,this._inputState={collapsedSelectionFormat:{format:0,key:"root",offset:0,style:"",timeStamp:0},compositionEndData:"",compositionPhase:"idle",hadOrphanedCompositionEvents:!1,handledSelectionCommandTimeoutId:null,isInsertLineBreak:!1,isInsertTextAfterHandledSelectionCommand:!1,isSelectionChangeFromDOMUpdate:!1,isSelectionChangeFromMouseDown:!1,lastBeforeInputInsertTextTimeStamp:0,lastKeyCode:null,lastKeyDownTimeStamp:0,postDeleteSelectionToRestore:null,unprocessedBeforeInputData:null}}isComposing(){return null!=this._compositionKey}registerUpdateListener(t){return xs(this._listeners.update,t)}registerEditableListener(t){return xs(this._listeners.editable,t)}registerDecoratorListener(t){return xs(this._listeners.decorator,t)}registerTextContentListener(t){return xs(this._listeners.textcontent,t)}registerRootListener(t){const e=this._listeners.root;return Eu(xs(e,t,t(this._rootElement,null)||void 0),()=>function(t,e,n){const o=t.get(e);o&&o(),t.set(e,e(...n)||void 0)}(e,t,[null,this._rootElement]))}registerCommand(e,n,o){void 0===o&&t(35);const r=this._commands;r.has(e)||r.set(e,[new tt,new tt,new tt,new tt,new tt]);const i=r.get(e);void 0===i&&t(36,String(e));const s=function(t){return 7&t}(o),l=i[s];return s!==o?l.addFront(n):l.addBack(n),()=>{l.delete(n),i.every(t=>0===t.size)&&r.delete(e)}}registerMutationListener(t,e,n){const o=this.resolveRegisteredNodeAfterReplacements(this.getRegisteredNode(t)).klass,r=this._listeners.mutation;let i=r.get(e);void 0===i&&(i=new Set,r.set(e,i)),i.add(o);const s=n&&n.skipInitialization;return void 0!==s&&s||this.initializeMutationListener(e,o),()=>{i.delete(o),0===i.size&&r.delete(e)}}getRegisteredNode(e){const n=this._nodes.get(e.getType());return void 0===n&&t(37,e.name),n}resolveRegisteredNodeAfterReplacements(t){for(;t.replaceWithKlass;)t=this.getRegisteredNode(t.replaceWithKlass);return t}initializeMutationListener(t,e){const n=this._editorState,o=Ac(n).get(e.getType());if(!o)return;const r=new Map;for(const t of o.keys())r.set(t,"created");r.size>0&&t(r,{dirtyLeaves:new Set,prevEditorState:n,updateTags:new Set(["registerMutationListener"])})}registerNodeTransformToKlass(t,e){const n=this.getRegisteredNode(t);return n.transforms.add(e),n}registerNodeTransform(t,e){const n=this.registerNodeTransformToKlass(t,e),o=[n],r=n.replaceWithKlass;if(null!=r){const t=this.registerNodeTransformToKlass(r,e);o.push(t)}return function(t,e){const n=Ac(t.getEditorState()),o=[];for(const t of e){const e=n.get(t);e&&o.push(e)}if(0===o.length)return;t.update(()=>{for(const t of o)for(const e of t.keys()){const t=Ys(e);t&&t.markDirty()}},null===t._pendingEditorState?{tag:xo}:void 0)}(this,o.map(t=>t.klass.getType())),()=>{o.forEach(t=>t.transforms.delete(e))}}hasNode(t){return this._nodes.has(t.getType())}hasNodes(t){return t.every(this.hasNode.bind(this))}dispatchCommand(t,...e){return Nl(this,t,...e)}getDecorators(){return this._decorators}getRootElement(){return this._rootElement}getKey(){return this._key}setRootElement(t){const e=this._rootElement;if(t!==e){const n=Cl(this._config.theme,"root"),o=this._pendingEditorState||this._editorState;if(this._rootElement=t,gs(this,e,t,o,{preserveUpdateQueue:!0}),null!==e&&(this._config.disableEvents||co(e),null!=n&&e.classList.remove(...n)),null!==t){const e=Pl(t),o=t.style;o.userSelect="text",o.whiteSpace="pre-wrap",o.wordBreak="break-word",t.setAttribute("data-lexical-editor","true"),this._window=e,this._dirtyType=2,gt(this),this._updateTags.add(xo),bi(this),this._config.disableEvents||function(t,e){const n=t.ownerDocument;Ln.set(t,n);let o=Kn.get(n);void 0===o&&(o={editors:new Set,hasShadowEditor:void 0},Kn.set(n,o)),o.editors.add(e),o.hasShadowEditor=void 0,t.__lexicalEditor=e;const r=no(t);r.push(zn.register(n));for(let n=0;n{so(t)||(io(t),(e.isEditable()||"click"===o)&&i(t,e))}:t=>{if(so(t))return;io(t);const n=e.isEditable();switch(o){case"cut":return n&&Nl(e,Tn,t);case"copy":return Nl(e,vn,t);case"paste":return n&&Nl(e,Je,t);case"dragstart":return n&&Nl(e,xn,t);case"dragover":return n&&Nl(e,Cn,t);case"dragend":return n&&Nl(e,Sn,t);case"focus":return n&&Nl(e,On,t);case"blur":return n&&Nl(e,Mn,t);case"drop":return n&&Nl(e,yn,t)}};r.push(Fn(t,o,s))}}(t,this),null!=n&&t.classList.add(...n)}else this._window=null,this._updateTags.add(xo),bi(this);Ni("root",this,!1,t,e)}}getElementByKey(t){return this._keyToDOMMap.get(t)||null}getEditorState(){return this._editorState}setEditorState(e,n){e.isEmpty()&&t(38);let o=e;o._readOnly&&(o=Ri(e),o._selection=e._selection?e._selection.clone():null),ht(this);const r=this._pendingEditorState,i=void 0!==n?n.tag:null;null===r||r.isEmpty()||(null!=i&&this._updateTags.add(i),bi(this)),this._pendingEditorState=o,this._dirtyType=2,this._dirtyElements.set("root",!1),this._compositionKey=null,this._slotsUsed=this._slotsUsed||e._slotsUsed,Ai(this,()=>{if(i&&this._updateTags.add(i),e._parsed)for(const[t,e]of o._nodeMap.entries())Pi(e)?this._dirtyElements.set(t,!0):this._dirtyLeaves.add(t)},{discrete:!this._updating||void 0})}parseEditorState(t,e){return function(t,e,n){const o=Wi(),r=ni,i=ri,s=oi,l=e._dirtyElements,c=e._dirtyLeaves,a=e._cloneNotNeeded,u=e._dirtyType;e._dirtyElements=new Map,e._dirtyLeaves=new Set,e._cloneNotNeeded=new Set,e._dirtyType=0,ni=o,ri=!1,oi=e,vs(null);try{const r=e._nodes;Ti(t.root,r),n&&n(),o._readOnly=!0,o._parsed=!0}catch(t){t instanceof Error&&e._onError(t)}finally{e._dirtyElements=l,e._dirtyLeaves=c,e._cloneNotNeeded=a,e._dirtyType=u,ni=r,ri=i,oi=s}return o}("string"==typeof t?JSON.parse(t):t,this,e)}read(...t){const[e,n]=1===t.length?["force-commit",t[0]]:t;"force-commit"===e&&bi(this);return("pending"===e?this._pendingEditorState||this._editorState:this.getEditorState()).read(n,{editor:this})}update(t,e){!function(t,e,n){t._updating?t._updates.push([e,n]):Mi(t,e,n)}(this,t,e)}focus(t,e={}){const n=this._rootElement;null!==n&&(n.setAttribute("autocapitalize","off"),Ai(this,()=>{const o=Kr(),r=nl();null!==o?o.dirty||ol(o.clone()):0!==r.getChildrenSize()&&("rootStart"===e.defaultSelection?r.selectStart():r.selectEnd()),Al("focus"),Dl(()=>{n.removeAttribute("autocapitalize"),t&&t()})}),null===this._pendingEditorState&&n.removeAttribute("autocapitalize"))}blur(){const t=this._rootElement;null!==t&&t.blur();const e=Jl(this._window);null!==e&&e.removeAllRanges()}isEditable(){return this._editable}setEditable(t){this._editable!==t&&(this._editable=t,Ni("editable",this,!0,t),this._slotsUsed&&this.update(()=>pi()))}toJSON(){return{editorState:this._editorState.toJSON()}}}Cs.version=Z;let Ss=null;function vs(t){Ss=t}const Ts=Symbol("INTERNAL_SKIP_AFTER_CLONE_FROM");let ks=1;function bs(){ks=1}function Ns(e,n){const o=Es(e,n);return void 0===o&&t(30,n),o}function Es(t,e){return t._nodes.get(e)}const ws="function"==typeof queueMicrotask?queueMicrotask:t=>{Promise.resolve().then(t)};function Os(t,e){const n=void 0!==e?e:(()=>{const e=t.getRootNode();return Bs(e)||ql(e)?cc(e):null})();if(!gc(n))return!1;if(n.hasAttribute("data-lexical-slot"))return!1;const o=Zs(n),r=n.nodeName;return po(o)&&("INPUT"===r||"TEXTAREA"===r||"true"===n.contentEditable&&null==Ps(n))}const Ms=Os;function As(t,e,n){const o=t.getRootElement();if(!o)return!1;try{if(!e||!o.contains(e)||!o.contains(n))return!1}catch(t){return!1}return Fs(e)===t&&t.read("latest",()=>!Os(e))}function Ds(t){return t instanceof Cs}function Fs(t){let e=t;for(;null!=e;){const t=Ps(e);if(Ds(t))return t;e=wl(e)}return null}function Ps(t){return t?t.__lexicalEditor:null}function Is(t){return L.test(t)?"rtl":K.test(t)?"ltr":null}function Ls(t){return er(t)||t.isToken()}function Ks(t){return Ls(t)||t.isSegmented()}function zs(t){return _c(t)&&3===t.nodeType}function Bs(t){return _c(t)&&9===t.nodeType}function Rs(t){let e=t;for(;null!=e;){if(zs(e))return e;e=e.firstChild}return null}function Ws(t,e,n){const o=z[e];if(null!==n&&(t&o)===(n&o))return t;let r=t^o;return"subscript"===e?r&=~z.superscript:"superscript"===e?r&=~z.subscript:"lowercase"===e?(r&=~z.uppercase,r&=~z.capitalize):"uppercase"===e?(r&=~z.lowercase,r&=~z.capitalize):"capitalize"===e&&(r&=~z.lowercase,r&=~z.uppercase),r}function $s(t){return Xo(t)||Yi(t)||Ki(t)}function Us(t,e){const n=function(){const t=Ss;return Ss=null,t}();if(null!=(e=e||n&&n.__key))return void(t.__key=e);fi(),di();const o=_i(),r=hi(),i=""+ks++;r._nodeMap.set(i,t),Pi(t)?o._dirtyElements.set(i,!0):o._dirtyLeaves.add(i),o._cloneNotNeeded.add(i),0===o._dirtyType&&(o._dirtyType=1),t.__key=i}function Hs(e){null!==ta(e)&&t(380,e.__key,String(ta(e)));const n=e.getParent();if(null!==n){const t=e.getWritable(),o=n.getWritable(),r=e.getPreviousSibling(),i=e.getNextSibling(),s=null!==i?i.__key:null,l=null!==r?r.__key:null,c=null!==r?r.getWritable():null,a=null!==i?i.getWritable():null;null===r&&(o.__first=s),null===i&&(o.__last=l),null!==c&&(c.__next=s),null!==a&&(a.__prev=l),t.__prev=null,t.__next=null,t.__parent=null,o.__size--}}const js=Hs;function Js(e){di(),ho(e)&&t(323,e.__key,e.__type);const n=e.getLatest(),o=null!==n.__parent?n.__parent:Zc(n)?n.__slotHost:null,r=hi(),i=_i(),s=r._nodeMap,l=i._dirtyElements;null!==o&&function(t,e,n){let o=t;for(;null!==o;){if(n.has(o))return;const t=e.get(o);if(void 0===t)break;n.set(o,!1),o=null!==t.__parent?t.__parent:Zc(t)?t.__slotHost:null}}(o,s,l);const c=n.__key;0===i._dirtyType&&(i._dirtyType=1),Pi(e)?l.set(c,!0):i._dirtyLeaves.add(c)}function Vs(t){fi();const e=_i(),n=e._compositionKey;if(t!==n){if(e._compositionKey=t,null!==n){const t=Ys(n);null!==t&&t.getWritable()}if(null!==t){const e=Ys(t);null!==e&&e.getWritable()}}}function qs(){if(ui())return null;return _i()._compositionKey}function Ys(t,e){const n=(e||hi())._nodeMap.get(t);return void 0===n?null:n}function Gs(t,e){const n=Qs(t,_i());return void 0!==n?Ys(n,e):null}function Xs(t,e,n){t[`__lexicalKey_${e._key}`]=n}function Qs(t,e){return t[`__lexicalKey_${e._key}`]}function Zs(t,e){let n=t;for(;null!=n;){const t=Gs(n,e);if(null!==t)return t;n=wl(n)}return null}function tl(t){const e=t._decorators,n=Object.assign({},e);return t._pendingDecorators=n,n}function el(t){return t.read(()=>nl().getTextContent())}function nl(){return hi()._nodeMap.get("root")}function ol(t){fi();const e=hi();null!==t&&(t.dirty=!0,t.setCachedNodes(null),ur(t)&&_i()._slotsUsed&&Or(t)),e._selection=t}function rl(){fi();ht(_i())}function il(t){const e=function(t,e){let n=t;for(;null!=n;){const t=Qs(n,e);if(void 0!==t)return t;n=wl(n)}return null}(t,_i());return null===e?null:Ys(e)}function sl(t){return/[\uD800-\uDBFF][\uDC00-\uDFFF]/g.test(t)}function ll(t){const e=[];for(let n=t;null!==n;n=n._parentEditor)e.push(n);return e}function cl(){return Math.random().toString(36).replace(/[^a-z]+/g,"").substring(0,5)}function al(t){return zs(t)?t.nodeValue:null}function ul(t,e,n){const o=Jl(Il(e));if(null===o)return;const r=nc(o,e._rootElement),i=r.anchorNode;let{anchorOffset:s,focusOffset:l}=r;if(null!==i){let e=al(i);const o=Zs(i);if(null!==e&&Xo(o)){if((e===A||e===F)&&n){const t=n.length;e=n,s=t,l=t}null!==e&&fl(o,e,s,l,t)}}}function fl(t,e,n,o,r){let i=t;if(i.isAttached()&&(r||!i.isDirty())){const s=i.isComposing();if(i.isToken()&&s)return;let c=e;if((s||r)&&(e.endsWith(A)&&(c=e.slice(0,-A.length)),r)){const t=F;let e;for(;-1!==(e=c.indexOf(t));)c=c.slice(0,e)+c.slice(e+t.length),null!==n&&n>e&&(n=Math.max(e,n-t.length)),null!==o&&o>e&&(o=Math.max(e,o-t.length))}const u=i.getTextContent();if(r||c!==u){const e=Kr();if(""===c){if(Vs(null),a||l||d)i.remove();else{const t=_i();dl(i,"",e),setTimeout(()=>{t.update(()=>{i.isAttached()&&""===i.getTextContent()&&i.remove()})},20)}return}const r=i.getParent(),u=zr(),f=i.getTextContentSize(),h=qs(),g=i.getKey();if(i.isToken()&&!s||null!==h&&g===h&&!s||ur(u)&&(null!==r&&!r.canInsertTextBefore()&&0===u.anchor.offset||u.anchor.key===t.__key&&0===u.anchor.offset&&!i.canInsertTextBefore()&&!s||u.focus.key===t.__key&&u.focus.offset===f&&!i.canInsertTextAfter()&&!s))return void i.markDirty();if(!ur(e)||null===n||null===o)return void dl(i,c,e);if(e.setTextNodeRange(i,n,i,o),i.isSegmented()){const t=Go(i.getTextContent());i.replace(t),i=t}dl(i,c,e)}}}function dl(t,e,n){if(t.setTextContent(e),ur(n)){const e=t.getKey();let o=!1;for(const r of["anchor","focus"]){const i=n[r];"text"===i.type&&i.key===e&&(i.offset=Ka(t,i.offset,"clamp"),o=!0)}o&&(n._cachedNodes=null,n._cachedIsBackward=null)}}function hl(t,e,n){const o=e[n]||!1;return"any"===o||o===t[n]}function gl(t,e){return hl(t,e,"altKey")&&hl(t,e,"ctrlKey")&&hl(t,e,"shiftKey")&&hl(t,e,"metaKey")}function _l(t,e,n){if(!gl(t,n))return!1;if(t.key.toLowerCase()===e.toLowerCase())return!0;if(e.length>1)return!1;if(1===t.key.length&&t.key.charCodeAt(0)<=127)return!1;if(t.code.startsWith("Digit")&&/^\d$/.test(e))return t.code===`Digit${e}`;const o="Key"+e.toUpperCase();return t.code===o}const pl={ctrlKey:!r,metaKey:r},yl={altKey:r,ctrlKey:!r};function ml(t){return"Backspace"===t.key}function xl(t){const e=nl();if(ur(t)){const e=t.anchor,n=t.focus,o=e.getNode();if(Bi(o))return e.set(o.getKey(),0,"element"),n.set(o.getKey(),o.getChildrenSize(),"element"),It(t),t;const r=o.getTopLevelElementOrThrow(),i=r.getParent();if(null===i)return Pi(r)&&(e.set(r.getKey(),0,"element"),n.set(r.getKey(),r.getChildrenSize(),"element"),It(t)),t;const s=i;return e.set(s.getKey(),0,"element"),n.set(s.getKey(),s.getChildrenSize(),"element"),It(t),t}{const t=e.select(0,e.getChildrenSize());return ol(It(t)),t}}function Cl(t,e){void 0===t.__lexicalClassNameCache&&(t.__lexicalClassNameCache={});const n=t.__lexicalClassNameCache,o=n[e];if(void 0!==o)return o;const r=t[e];if("string"==typeof r){const t=ku(r);return n[e]=t,t}return r}function Sl(e,n,o,r,i){if(0===o.size)return;const s=r.__type,l=r.__key,c=n.get(s);void 0===c&&t(33,s);const a=c.klass;let u=e.get(a);void 0===u&&(u=new Map,e.set(a,u));const f=u.get(l),d="destroyed"===f&&"created"===i;(void 0===f||d)&&u.set(l,d?"updated":i)}function vl(t){const e=t.getType(),n=hi();if(n._readOnly){const t=Ac(n).get(e);return t?Array.from(t.values()):[]}const o=n._nodeMap,r=[];for(const[,n]of o)n instanceof t&&n.__type===e&&n.isAttached()&&r.push(n);return r}function Tl(t,e,n){const o=t.getParent();let r=n,i=t;return null!==o&&(e&&0===n?(r=i.getIndexWithinParent(),i=o):e||n!==i.getChildrenSize()||(r=i.getIndexWithinParent()+1,i=o)),i.getChildAtIndex(e?r-1:r)}function kl(t,e){const n=t.offset;if("element"===t.type){return Tl(t.getNode(),e,n)}{const o=t.getNode();if(e&&0===n||!e&&n===o.getTextContentSize()){const t=e?o.getPreviousSibling():o.getNextSibling();return null===t?Tl(o.getParentOrThrow(),e,o.getIndexWithinParent()+(e?0:1)):t}}return null}function bl(t){const e=Il(t).event,n=e&&e.inputType;return"insertFromPaste"===n||"insertFromPasteAsQuotation"===n}function Nl(t,e,...n){return Ei(t,e,n[0],t)}function El(e,n){const o=e._keyToDOMMap.get(n);return void 0===o&&t(75,n),o}function wl(t){const e=t.assignedSlot||t.parentElement;if(null!==e)return e;const n=t.parentNode;return ql(n)?n.host:null}function Ol(t){return Bs(t)?t:gc(t)?t.ownerDocument:null}function Ml(t){return _i()._updateTags.has(t)}function Al(t){fi();_i()._updateTags.add(t)}function Dl(t){fi();_i()._deferred.push(t)}function Fl(t,e){let n=t.getParent();for(;null!==n;){if(n.is(e))return!0;n=n.getParent()}return!1}function Pl(t){const e=Ol(t);return e?e.defaultView:null}function Il(e){const n=e._window;return null===n&&t(78),n}function Ll(t){return Pi(t)&&t.isInline()||Ki(t)&&t.isInline()}function Kl(t){let e=t.getLatest();for(;null!==e;){if(null!==ta(e)&&Pi(e))return e;const t=e.getParentOrThrow();if(Bl(t))return t;e=t}return e}function zl(t){return Pi(t)&&t.isShadowRoot()}function Bl(t){return Bi(t)||zl(t)}function Rl(t,e=!1){const n=t.constructor.clone(t,Ts);return Us(n,null),n.afterCloneFrom(t),e||n.resetOnCopyNodeFrom(t),n}function Wl(e){const n=_i(),o=e.getType(),r=Es(n,o);void 0===r&&t(200,e.constructor.name,o);const{replace:i,replaceWithKlass:s}=r;if(null!==i){const n=i(e),r=n.constructor;return null!==s?n instanceof s||t(201,s.name,s.getType(),r.name,r.getType(),e.constructor.name,o):n instanceof e.constructor&&r!==e.constructor||t(202,r.name,r.getType(),e.constructor.name,o),n.__key===e.__key&&t(203,e.constructor.name,o,r.name,r.getType()),n}return e}function $l(e,n){!Bi(e.getParent())||Pi(n)||Ki(n)||t(99)}function Ul(e){const n=Ys(e);return null===n&&t(63,e),n}function Hl(t){if(!t||t.isInline())return!1;if(Ki(t))return!0;if(Pi(t)){if(t.isShadowRoot()){const e=t.getParent();return!(Pi(e)&&e.isShadowRoot())}return!t.canBeEmpty()}return!1}function jl(t,e,n){n.style.removeProperty("caret-color"),e._blockCursorElement=null;const o=t.parentElement;null!==o&&o.removeChild(t)}function Jl(t){return n?(t||window).getSelection():null}function Vl(t){const e=Pl(t);return e?e.getSelection():null}function ql(t){return pc(t)&&"host"in t}const Yl=[];function Gl(t){const e=t.getRootNode();if(e===t||!ql(e))return Yl;const n=[e];let o=e.host;for(;;){const t=o.getRootNode();if(t===o||!ql(t))break;n.push(t),o=t.host}return n}function*Xl(t){const e=[t];let n;for(;n=e.pop();){yield*n.querySelectorAll('[data-lexical-editor="true"]');const t=(Bs(n)?n:n.ownerDocument).createTreeWalker(n,NodeFilter.SHOW_ELEMENT);let o;for(;o=t.nextNode();)o.shadowRoot&&e.push(o.shadowRoot)}}function Ql(t){return null!==t?t.ownerDocument:document}function Zl(){const t=mi();return Ql(null!==t?t._rootElement:null)}function tc(t,e){if(null===e||"function"!=typeof t.getComposedRanges)return null;const n=Gl(e);if(0===n.length)return null;const o=t.getComposedRanges;try{const e=o.call(t,{shadowRoots:n})[0];if(void 0!==e)return e}catch(t){}try{const e=o.apply(t,n)[0];if(void 0!==e)return e}catch(t){}return null}function ec(t,e){const n=tc(t,e);if(null!==n){const t=rc(n);if(null!==t)return t}return t.rangeCount>0?t.getRangeAt(0):null}function nc(t,e){const n=tc(t,e);return null===n?t:ic(n,sc(t))}function oc(t,e){const n=tc(t,e);if(null===n)return{points:t,range:t.rangeCount>0?t.getRangeAt(0):null};const o=rc(n)??(t.rangeCount>0?t.getRangeAt(0):null);return{points:ic(n,sc(t)),range:o}}function rc(t){const e=t.startContainer.ownerDocument;if(null===e)return null;const n=e.createRange();try{return n.setStart(t.startContainer,t.startOffset),n.setEnd(t.endContainer,t.endOffset),n}catch(t){return null}}function ic(t,e){const{startContainer:n,startOffset:o,endContainer:r,endOffset:i}=t;return"backward"===e?{anchorNode:r,anchorOffset:i,direction:e,focusNode:n,focusOffset:o}:{anchorNode:n,anchorOffset:o,direction:e,focusNode:r,focusOffset:i}}function sc(t){return t.direction}function lc(t){const e=t.getRootNode();return Bs(e)||ql(e)?e.activeElement:null}function cc(t){let e=t.activeElement;for(;null!==e&&null!==e.shadowRoot;){const t=e.shadowRoot.activeElement;if(null===t)break;e=t}return e}function ac(t){const e=t.target;if(null!==e&&gc(e)&&null!==e.shadowRoot&&"function"==typeof t.composedPath){const e=t.composedPath();if(e.length>0)return e[0]}return e}function uc(e,n){let o=e.getChildAtIndex(n);null==o&&(o=e),Bl(e)&&t(102);const r=e=>{const n=e.getParentOrThrow(),i=Bl(n),s=e!==o||i?Rl(e):e;if(i)return Pi(e)&&Pi(s)||t(133),e.insertAfter(s),[e,s,s];{const[t,o,i]=r(n),l=e.getNextSiblings();return i.append(s,...l),[t,o,s]}},[i,s]=r(o);return[i,s]}function fc(t){return gc(t)&&"A"===t.tagName}function dc(t){return gc(t)&&"TR"===t.tagName}function hc(t){return gc(t)&&("TD"===t.tagName||"TH"===t.tagName)}function gc(t){return _c(t)&&1===t.nodeType}function _c(t){return"object"==typeof t&&null!==t&&"nodeType"in t&&"number"==typeof t.nodeType}function pc(t){return _c(t)&&11===t.nodeType}const yc=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|mark|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var|#text)$/i;function mc(t){return!(!gc(t)||!t.style.display.startsWith("inline"))||yc.test(t.nodeName)}const xc=/^(address|article|aside|blockquote|canvas|dd|div|dl|dt|fieldset|figcaption|figure|footer|form|h1|h2|h3|h4|h5|h6|header|hr|li|main|nav|noscript|ol|p|pre|section|table|td|tfoot|ul|video)$/i;function Cc(t){return(!gc(t)||!t.style.display.startsWith("inline"))&&xc.test(t.nodeName)}function Sc(t){if(Ki(t)&&!t.isInline())return!0;if(!Pi(t)||Bl(t))return!1;const e=t.getFirstChild(),n=null===e||Yi(e)||Xo(e)||e.isInline();return!t.isInline()&&!1!==t.canBeEmpty()&&n}function vc(){return _i()}function Tc(t=vc()){return t._config.dom||ps}function kc(e,n,o=vc()){const r=Tc(o).$getDOMSlot(e,n,o);return Pi(e)&&(Ec(r)||t(344,e.getKey(),e.getType())),r}function bc(t,e,n,o){const r=t.read("latest",()=>{const o=Ys(e);return null!==o?function(t,e,n=vc()){const o=sa(t,e);if(null===o)return null;const r=n.getElementByKey(o.getKey());return null!==r?r.parentElement:null}(o,n,t):null});return null!==r&&(r.parentElement!==o&&o.appendChild(r),r.style.display=""),r}function Nc(t,e,n){n.style.display="none";const o=t.getElementByKey(e);null!==o&&n.parentElement!==o&&o.insertBefore(n,o.firstChild)}function Ec(t){return t instanceof G}function wc(t,e,n=vc()){return Rs(kc(t,e,n).element)}const Oc=new WeakMap,Mc=new Map;function Ac(e){if(!e._readOnly&&e.isEmpty())return Mc;e._readOnly||t(192);let n=Oc.get(e);return n||(n=function(t){const e=new Map;for(const[n,o]of t._nodeMap){const t=o.__type;let r=e.get(t);r||(r=new Map,e.set(t,r)),r.set(n,o)}return e}(e),Oc.set(e,n)),n}function Dc(t){const e=t.constructor.clone(t,Ts);return e.afterCloneFrom(t),e}function Fc(t){return(e=Dc(t))[fo]=!0,e;var e}function Pc(t,e){const n=t.getAttribute("data-lexical-indent");if(null!==n){const t=parseInt(n,10);if(Number.isFinite(t)&&t>=0)return void e.setIndent(t)}const o=parseInt(t.style.paddingInlineStart,10)||0,r=Math.round(o/40);e.setIndent(r)}function Ic(t,e){const n=e.getAttribute("dir");return"ltr"===n||"rtl"===n?t.setDirection(n):t}function Lc(t,e){const n=e.style.textAlign;return n&&n in R?t.setFormat(n):t}function Kc(t,e){t.__lexicalUnmanaged=!0,e&&void 0!==e.captureSelection&&(t.__lexicalCapturedSelection=e.captureSelection)}function zc(t){return!0===t.__lexicalUnmanaged}function Bc(t,e=vc()){const n=e.isEditable();t.contentEditable=n?"true":"false",n?t.__lexicalEditor=e:delete t.__lexicalEditor}function Rc(t,e){let n=t;for(;null!=n;){if(!0===n.__lexicalCapturedSelection)return!0;if(gc(n)&&n.hasAttribute("data-lexical-slot"))return!1;if(void 0!==Qs(n,e))return!1;n=wl(n)}return!1}function Wc(t,e){return function(t,e){return Object.prototype.hasOwnProperty.call(t,e)}(t,e)&&t[e]!==_o[e]}const $c=new WeakMap,Uc=Symbol("lexical.synthesizedGetType");function Hc(e){const n=$c.get(e);if(n)return n;const o=null!=e.prototype&&j in e.prototype?e.prototype[j]():void 0,r=function(e){if(!(e===_o||e.prototype instanceof _o)){let n="",o="";try{n=e.getType()}catch(t){}try{Cs.version&&(o=JSON.parse(Cs.version))}catch(t){}t(290,e.name,n,o)}return e===Li||e===Fi||e===_o}(e),i=!r&&Wc(e,"getType")?e.getType:void 0,s=i&&!(Uc in i)?i.call(e):void 0;let l,c=s;if(o)if(s)l=o[s];else{for(const[t,e]of Object.entries(o))c=t,l=e;if(!l)for(const t of Object.getOwnPropertySymbols(o)){const e=o[t];if(e){l=e;break}}}if(!r&&c){if(!Wc(e,"getType")){const t=e,n=function(){return this!==t?_o.getType.call(this):c};n[Uc]=!0,e.getType=n}if(Wc(e,"clone")||(e.clone=(t,n)=>{vs(t);const o=new e;return n!==Ts&&o.afterCloneFrom(t),o}),Wc(e,"importJSON")||(e.importJSON=l&&l.$importJSON||(t=>(new e).updateFromJSON(t))),!Wc(e,"importDOM")&&l){const{importDOM:t}=l;t&&(e.importDOM=()=>t)}}const a={klass:e,ownNodeConfig:l,ownNodeType:c};return $c.set(e,a),a}function*jc(t){for(let e=t;e&&(e===_o||po(e.prototype));){const t=Hc(e);yield t,e=t.ownNodeConfig&&t.ownNodeConfig.extends||Gc(e)}}function Jc(t){const e=new Map,n=new Map;for(const o of t){const{ownNodeType:t}=Hc(o);t&&(n.set(t,o),e.set(t,new Set))}for(const[t,o]of n)for(const{ownNodeType:n}of jc(o)){const o=n&&e.get(n);o&&o.add(t)}return e}function Vc(t){const e=vc();fi();return new(e.resolveRegisteredNodeAfterReplacements(e.getRegisteredNode(t)).klass)}const qc=(t,e)=>{let n=t;for(;null!=n&&!Bi(n);){if(e(n))return n;n=n.getParent()}return null};function Yc(e,n){const o=[];let r=e.__first;for(;null!==r;){const e=null===n?Ys(r):n.get(r);null==e&&t(174),o.push(r),r=e.__next}return o}function Gc(t){const e=Object.getPrototypeOf(t);if("function"==typeof e&&e!==Function.prototype)return e;const n=t.prototype&&Object.getPrototypeOf(t.prototype);return n?n.constructor:null}const Xc=new Map;function Qc(t){return Pi(t)||Ki(t)}function Zc(t){return Pi(t)||Ki(t)}function ta(t){const e=t.getLatest();return Zc(e)?e.__slotHost:null}function ea(e){const n=ta(e);if(null===n)return null;const o=Ys(n);return Pi(o)||Ki(o)||t(370),o}function na(t){const e=ea(t);if(null===e)return null;const n=t.getLatest().__key;for(const[t,o]of ra(e))if(o===n)return t;return null}function oa(t){let e=t.getLatest();for(;null!==e;){if(null!==ta(e))return e;e=e.getParent()}return null}function ra(t){const e=t.getLatest();return Qc(e)&&null!==e.__slots?e.__slots:Xc}function ia(t){return Array.from(ra(t).keys())}function sa(t,e){const n=ra(t).get(e);return void 0===n?null:Ys(n)}const la=["__proto__","constructor","prototype"],ca=Symbol("slotMapOwner");function aa(t){let e=t.__slots;return null!==e&&e[ca]===t||(e=new Map(e),e[ca]=t,t.__slots=e),e}const ua=new WeakMap,fa=[];function da(t){for(const{ownNodeConfig:e}of jc(t)){const t=e&&e.slots;if(t)return t}return fa}function ha(t){let e="";for(const n of ia(t)){const o=sa(t,n);null!==o&&(e+=o.getTextContent())}return e}function ga(t,e,n){const o=n.get(t),r=n.get(e);return void 0!==o?void 0!==r?o-r:-1:void 0!==r?1:te?1:0}function _a(e){const n=e.__slots;if(null===n||n.size<2)return;const o=function(e){let n=ua.get(e);if(void 0===n){const o=da(e),r=new Map;for(const n of o)la.includes(n)&&t(371,e.name,n),r.has(n)&&t(372,e.name,n),r.set(n,r.size);n=r,ua.set(e,n)}return n}(e.constructor);let r=null,i=!0;for(const t of n.keys()){if(null!==r&&ga(r,t,o)>0){i=!1;break}r=t}if(i)return;const s=Array.from(n).sort(([t],[e])=>ga(t,e,o));n.clear();for(const[t,e]of s)n.set(t,e)}function pa(e,n,o){"__proto__"!==n&&"constructor"!==n&&"prototype"!==n||t(373,n);const r=e.getLatest();if(null!==r.__slots&&r.__slots.get(n)===o.getLatest().__key)return r;(!Pi(o)&&!Ki(o)||o.isInline())&&t(374,o.__key);const i=e.getWritable(),s=aa(i),l=s.get(n);void 0!==l&&xa(l);const c=o.getWritable(),a=ea(c);if(null!==a){const t=na(c);null!==t&&aa(a.getWritable()).delete(t),c.__slotHost=null}return Hs(c),c.__slotHost=i.__key,s.set(n,c.__key),_a(i),function(){const t=vc();t._slotsUsed=!0,t._pendingEditorState&&(t._pendingEditorState._slotsUsed=!0)}(),i}function ya(t,e){const n=t.getWritable();if(null===n.__slots)return n;const o=n.__slots.get(e);return void 0!==o&&(xa(o),aa(n).delete(e)),n}function ma(t,e){}function xa(e){const n=Ys(e);if(null===n)return;const o=n.getWritable();Zc(o)||t(377,e),o.__slotHost=null,o.remove()}const Ca={next:"previous",previous:"next"};class Sa{origin;constructor(t){this.origin=t}[Symbol.iterator](){return qa({hasNext:Ma,initial:this.getAdjacentCaret(),map:t=>t,step:t=>t.getAdjacentCaret()})}getAdjacentCaret(){return Ia(this.getNodeAtCaret(),this.direction)}getSiblingCaret(){return Ia(this.origin,this.direction)}remove(){const t=this.getNodeAtCaret();return t&&t.remove(),this}replaceOrInsert(t,e){const n=this.getNodeAtCaret();return t.is(this.origin)||t.is(n)||(null===n?this.insert(t):n.replace(t,e)),this}splice(e,n,o="next"){const r=o===this.direction?n:Array.from(n).reverse();let i=this;const s=this.getParentAtCaret(),l=new Map;for(let t=i.getAdjacentCaret();null!==t&&l.size0){const n=i.getNodeAtCaret();if(n)if(l.delete(n.getKey()),l.delete(e.getKey()),n.is(e)||i.origin.is(e));else{const t=e.getParent();t&&t.is(s)&&e.remove(),n.replace(e)}else null===n&&t(263,Array.from(l).join(" "))}else i.insert(e);i=Ia(e,this.direction)}for(const t of l.values())t.remove();return this}}class va extends Sa{type="child";getLatest(){const t=this.origin.getLatest();return t===this.origin?this:Ba(t,this.direction)}getParentCaret(t="root"){return Ia(ba(this.getParentAtCaret(),t),this.direction)}getFlipped(){const t=ka(this.direction);return Ia(this.getNodeAtCaret(),t)||Ba(this.origin,t)}getParentAtCaret(){return this.origin}getChildCaret(){return this}isSameNodeCaret(t){return t instanceof va&&this.direction===t.direction&&this.origin.is(t.origin)}isSamePointCaret(t){return this.isSameNodeCaret(t)}}const Ta={root:Bi,shadowRoot:Bl};function ka(t){return Ca[t]}function ba(t,e="root"){return null===t||Ta[e](t)?null:null===ta(t)?t:null}class Na extends Sa{type="sibling";getLatest(){const t=this.origin.getLatest();return t===this.origin?this:Ia(t,this.direction)}getSiblingCaret(){return this}getParentAtCaret(){return this.origin.getParent()}getChildCaret(){return Pi(this.origin)?Ba(this.origin,this.direction):null}getParentCaret(t="root"){return Ia(ba(this.getParentAtCaret(),t),this.direction)}getFlipped(){const t=ka(this.direction);return Ia(this.getNodeAtCaret(),t)||Ba(this.origin.getParentOrThrow(),t)}isSamePointCaret(t){return t instanceof Na&&this.direction===t.direction&&this.origin.is(t.origin)}isSameNodeCaret(t){return(t instanceof Na||t instanceof Ea)&&this.direction===t.direction&&this.origin.is(t.origin)}}class Ea extends Sa{type="text";offset;constructor(t,e){super(t),this.offset=e}getLatest(){const t=this.origin.getLatest();return t===this.origin?this:La(t,this.direction,this.offset)}getParentAtCaret(){return this.origin.getParent()}getChildCaret(){return null}getParentCaret(t="root"){return Ia(ba(this.getParentAtCaret(),t),this.direction)}getFlipped(){return La(this.origin,ka(this.direction),this.offset)}isSamePointCaret(t){return t instanceof Ea&&this.direction===t.direction&&this.origin.is(t.origin)&&this.offset===t.offset}isSameNodeCaret(t){return(t instanceof Na||t instanceof Ea)&&this.direction===t.direction&&this.origin.is(t.origin)}getSiblingCaret(){return Ia(this.origin,this.direction)}}function wa(t){return t instanceof Ea}function Oa(t){return t instanceof Sa}function Ma(t){return t instanceof Na}function Aa(t){return t instanceof va}const Da={next:class extends Ea{direction="next";getNodeAtCaret(){return this.origin.getNextSibling()}insert(t){return this.origin.insertAfter(t),this}},previous:class extends Ea{direction="previous";getNodeAtCaret(){return this.origin.getPreviousSibling()}insert(t){return this.origin.insertBefore(t),this}}},Fa={next:class extends Na{direction="next";getNodeAtCaret(){return this.origin.getNextSibling()}insert(t){return this.origin.insertAfter(t),this}},previous:class extends Na{direction="previous";getNodeAtCaret(){return this.origin.getPreviousSibling()}insert(t){return this.origin.insertBefore(t),this}}},Pa={next:class extends va{direction="next";getNodeAtCaret(){return this.origin.getFirstChild()}insert(t){return this.origin.splice(0,0,[t]),this}},previous:class extends va{direction="previous";getNodeAtCaret(){return this.origin.getLastChild()}insert(t){return this.origin.splice(this.origin.getChildrenSize(),0,[t]),this}}};function Ia(t,e){return t?new Fa[e](t):null}function La(t,e,n){return t?new Da[e](t,Ka(t,n)):null}function Ka(t,n,o="error"){const r=t.getTextContentSize();let i="next"===n?r:"previous"===n?0:n;return(i<0||i>r)&&("clamp"!==o&&e(284,String(n),String(r),t.getKey()),i=i<0?0:r),i}function za(t,e){return new Ua(t,e)}function Ba(t,e){return Pi(t)?new Pa[e](t):null}function Ra(t){return t&&t.getChildCaret()||t}function Wa(t){return t&&Ra(t.getAdjacentCaret())}class $a{type="node-caret-range";direction;anchor;focus;constructor(t,e,n){this.anchor=t,this.focus=e,this.direction=n}getLatest(){const t=this.anchor.getLatest(),e=this.focus.getLatest();return t===this.anchor&&e===this.focus?this:new $a(t,e,this.direction)}isCollapsed(){return this.anchor.isSamePointCaret(this.focus)}getTextSlices(){const t=t=>{const e=this[t].getLatest();return wa(e)?function(t,e){const{direction:n,origin:o}=t,r=Ka(o,"focus"===e?ka(n):n);return za(t,r-t.offset)}(e,t):null},e=t("anchor"),n=t("focus");if(e&&n){const{caret:t}=e,{caret:o}=n;if(t.isSameNodeCaret(o))return[za(t,o.offset-t.offset),null]}return[e,n]}iterNodeCarets(t="root"){const e=wa(this.anchor)?this.anchor.getSiblingCaret():this.anchor.getLatest(),n=this.focus.getLatest(),o=wa(n),r=e=>e.isSameNodeCaret(n)?null:Wa(e)||e.getParentCaret(t);return qa({hasNext:t=>null!==t&&!(o&&n.isSameNodeCaret(t)),initial:e.isSameNodeCaret(n)?null:r(e),map:t=>t,step:r})}[Symbol.iterator](){return this.iterNodeCarets("root")}}class Ua{type="slice";caret;distance;constructor(t,e){this.caret=t,this.distance=e}getSliceIndices(){const{distance:t,caret:{offset:e}}=this,n=e+t;return n{let n;for(let o=c;on.has(t.getKey())&&Sc(t));if(f&&ia(f).length>0)return null;return u&&f?[u,f]:null}(d,h,a);if(g){const[t,e]=g;Ba(t,"previous").splice(0,e.getChildren());let n=e.getParent();for(e.remove(!0);n&&n.isEmpty();){const t=n;n=n.getParent(),t.remove(!0)}}else if(h){const t=function(t){if(Aa(t)){const e=t.origin;if(Sc(e))return e}else{const e=t.getParentAtCaret();if(e&&Sc(e))return e}return null}(h),e=t&&t.getParent(),n=t&&t.getParents().findLast(zl);if(t&&e&&!Bi(e)&&t.isEmpty()&&a.has(t.getKey())&&0===ia(t).length&&(!n||a.has(n.getKey()))){t.remove(!0);let n=e;for(;n&&!Bi(n)&&n.isEmpty();){const t=n.getParent();if(t&&Bi(t)&&t.getChildrenSize()<=1)break;const e=n;n=t,e.remove(!0)}}}const _=[d,h,...l,...c].find(lu);if(_){return Ja(fu(au(_),e.direction))}t(269,JSON.stringify(l.map(t=>t.origin.__key)))}function au(t){const e=function(t){let e=t;for(;Aa(e);){const t=Wa(e);if(!Aa(t))break;e=t}return e}(t.getLatest()),{direction:n}=e;if(Xo(e.origin))return wa(e)?e:La(e.origin,n,n);const o=e.getAdjacentCaret();return Ma(o)&&Xo(o.origin)?La(o.origin,n,ka(n)):e}function uu(t){return wa(t)&&t.offset!==Ka(t.origin,t.direction)}function fu(t,e){return t.direction===e?t:t.getFlipped()}function du(t,e){return t.direction===e?t:Va(fu(t.focus,e),fu(t.anchor,e))}function hu(t,e,n){let o=Ba(t,"next");for(let t=0;t0||!i&&n.canBeEmpty()&&r(n,"last"))&&s.insert(e(n).splice(0,0,o))}return s}function mu(e,n,o){let r=fu(n,"next");wa(r)&&(0===r.offset?r=Ia(r.origin,"previous").getFlipped():r.offset===r.origin.getTextContentSize()&&(r=Ia(r.origin,"next"))),r.origin.is(e)&&(Ma(r)||t(342,e.getKey(),e.getType()),r=iu(r)),(e.is(r.getNodeAtCaret())||e.is(r.getFlipped().getNodeAtCaret()))&&e.remove(!0);for(let t=r;t;t=yu(t,o))r=t;return wa(r)&&t(283),r.insert(e.isInline()?es().append(e):e),fu(Ia(e.getLatest(),"next"),n.direction)}function xu(t){return t}function Cu(...t){return t}function Su(t,e){return[t,e]}function vu(t){return t}function Tu(t,e){if(!e||t===e)return t;for(const n in e)if(t[n]!==e[n])return{...t,...e};return t}function ku(...t){const e=[];for(const n of t)if(n&&"string"==typeof n)for(const[t]of n.matchAll(/\S+/g))e.push(t);return e}function bu(t,...e){const n=ku(...e);n.length>0&&t.classList.add(...n)}function Nu(t,...e){const n=ku(...e);n.length>0&&t.classList.remove(...n)}function Eu(...t){return()=>{for(let e=t.length-1;e>=0;e--)t[e]();t.length=0}}function wu(t,e,n){return Eu(...Object.entries(e).map(([e,o])=>Fn(t,e,o,n)))}export{Al as $addUpdateTag,Wl as $applyNodeReplacement,gi as $assumeActiveEditor,tu as $caretFromPoint,ru as $caretRangeFromSelection,Dc as $cloneWithProperties,Fc as $cloneWithPropertiesEphemeral,Ya as $comparePointCaretNext,Rl as $copyNode,Vc as $create,Yc as $createChildrenArray,qi as $createLineBreakNode,Pr as $createNodeSelection,es as $createParagraphNode,or as $createPoint,Fr as $createRangeSelection,Ir as $createRangeSelectionFromDom,tr as $createTabNode,Go as $createTextNode,ja as $extendCaretToRange,qc as $findMatchingParent,_r as $formatText,pi as $fullReconcile,qr as $generateNodesFromRawText,Wa as $getAdjacentChildCaret,kl as $getAdjacentNode,gu as $getAdjacentSiblingOrParentSiblingCaret,fu as $getCaretInDirection,Va as $getCaretRange,du as $getCaretRangeInDirection,yr as $getCharacterOffsets,Ba as $getChildCaret,hu as $getChildCaretAtIndex,Ra as $getChildCaretOrSelf,Ja as $getCollapsedCaretRange,Za as $getCommonAncestor,Ga as $getCommonAncestorResultBranchOrder,kc as $getDOMSlot,wc as $getDOMTextNode,Zl as $getDocument,vc as $getEditor,Tc as $getEditorDOMRenderConfig,Zs as $getNearestNodeFromDOMNode,Kl as $getNearestRootOrShadowRoot,Ys as $getNodeByKey,Ul as $getNodeByKeyOrThrow,Gs as $getNodeFromDOMNode,zr as $getPreviousSelection,nl as $getRoot,Kr as $getSelection,Ia as $getSiblingCaret,sa as $getSlot,oa as $getSlotFrame,ea as $getSlotHost,na as $getSlotNameWithinHost,ia as $getSlotNames,xt as $getState,Ct as $getStateChange,Yr as $getTextContent,Ka as $getTextNodeOffset,La as $getTextPointCaret,za as $getTextPointCaretSlice,bt as $getWritableNodeState,Fl as $hasAncestor,Ml as $hasUpdateTag,mu as $insertNodeToNearestRootAtCaret,Jr as $insertNodes,Ar as $isBlockElementNode,Aa as $isChildCaret,Ki as $isDecoratorNode,Ui as $isEditorState,Ec as $isElementDOMSlot,Pi as $isElementNode,uu as $isExtendableTextPointCaret,Ll as $isInlineElementOrDecoratorNode,Ro as $isInlineFormattable,$s as $isLeafNode,po as $isLexicalNode,Yi as $isLineBreakNode,Oa as $isNodeCaret,dr as $isNodeSelection,ns as $isParagraphNode,ur as $isRangeSelection,Bi as $isRootNode,Bl as $isRootOrShadowRoot,Os as $isSelectionCapturedInDecoratorInput,zl as $isShadowRootNode,Ma as $isSiblingCaret,Zc as $isSlotChild,Qc as $isSlotHost,er as $isTabNode,Xo as $isTextNode,wa as $isTextPointCaret,Ha as $isTextPointCaretSlice,Ks as $isTokenOrSegmented,Ls as $isTokenOrTab,Bc as $markSlotEditable,Hl as $needsBlockCursorBeside,vl as $nodesOfType,au as $normalizeCaret,It as $normalizeSelection__EXPERIMENTAL,Dl as $onUpdate,vi as $parseSerializedNode,Hs as $removeFromParent,ya as $removeSlot,cu as $removeTextFromCaretRange,iu as $rewindSiblingCaret,xl as $selectAll,Vs as $setCompositionKey,Ic as $setDirectionFromDOM,Lc as $setFormatFromDOM,eu as $setPointFromCaret,ol as $setSelection,nu as $setSelectionFromCaretRange,pa as $setSlot,St as $setState,gr as $setTextFormat,yu as $splitAtPointCaretNext,uc as $splitNode,jr as $updateDOMSelection,ou as $updateRangeSelectionFromCaretRange,ji as ArtificialNode__DO_NOT_USE,ze as BEFORE_INPUT_COMMAND,Mn as BLUR_COMMAND,En as CAN_REDO_COMMAND,wn as CAN_UNDO_COMMAND,s as CAN_USE_BEFORE_INPUT,n as CAN_USE_DOM,bn as CLEAR_EDITOR_COMMAND,Nn as CLEAR_HISTORY_COMMAND,Ke as CLICK_COMMAND,vo as COLLABORATION_TAG,hs as COMMAND_PRIORITY_BEFORE_CRITICAL,as as COMMAND_PRIORITY_BEFORE_EDITOR,ds as COMMAND_PRIORITY_BEFORE_HIGH,us as COMMAND_PRIORITY_BEFORE_LOW,fs as COMMAND_PRIORITY_BEFORE_NORMAL,cs as COMMAND_PRIORITY_CRITICAL,rs as COMMAND_PRIORITY_EDITOR,ls as COMMAND_PRIORITY_HIGH,is as COMMAND_PRIORITY_LOW,ss as COMMAND_PRIORITY_NORMAL,We as COMPOSITION_END_COMMAND,wo as COMPOSITION_END_TAG,Re as COMPOSITION_START_COMMAND,Eo as COMPOSITION_START_TAG,je as CONTROLLED_TEXT_INSERTION_COMMAND,vn as COPY_COMMAND,Tn as CUT_COMMAND,So as CUT_TAG,ps as DEFAULT_EDITOR_DOM_CONFIG,$e as DELETE_CHARACTER_COMMAND,Ye as DELETE_LINE_COMMAND,qe as DELETE_WORD_COMMAND,Sn as DRAGEND_COMMAND,Cn as DRAGOVER_COMMAND,xn as DRAGSTART_COMMAND,yn as DROP_COMMAND,Li as DecoratorNode,Fi as ElementNode,On as FOCUS_COMMAND,mn as FORMAT_ELEMENT_COMMAND,Ge as FORMAT_TEXT_COMMAND,yo as HISTORIC_TAG,xo as HISTORY_MERGE_TAG,mo as HISTORY_PUSH_TAG,_n as INDENT_CONTENT_COMMAND,Be as INPUT_COMMAND,Ue as INSERT_LINE_BREAK_COMMAND,He as INSERT_PARAGRAPH_COMMAND,gn as INSERT_TAB_COMMAND,Sc as INTERNAL_$isBlock,k as IS_ALL_FORMATTING,c as IS_ANDROID,f as IS_ANDROID_CHROME,r as IS_APPLE,d as IS_APPLE_WEBKIT,p as IS_BOLD,u as IS_CHROME,C as IS_CODE,i as IS_FIREFOX,T as IS_HIGHLIGHT,l as IS_IOS,y as IS_ITALIC,a as IS_SAFARI,m as IS_STRIKETHROUGH,S as IS_SUBSCRIPT,v as IS_SUPERSCRIPT,x as IS_UNDERLINE,ln as KEY_ARROW_DOWN_COMMAND,on as KEY_ARROW_LEFT_COMMAND,en as KEY_ARROW_RIGHT_COMMAND,sn as KEY_ARROW_UP_COMMAND,un as KEY_BACKSPACE_COMMAND,dn as KEY_DELETE_COMMAND,tn as KEY_DOWN_COMMAND,cn as KEY_ENTER_COMMAND,fn as KEY_ESCAPE_COMMAND,An as KEY_MODIFIER_COMMAND,an as KEY_SPACE_COMMAND,hn as KEY_TAB_COMMAND,Ji as LineBreakNode,nn as MOVE_TO_END,rn as MOVE_TO_START,_t as NODE_STATE_DIRECT,H as NODE_STATE_KEY,pt as NODE_STATE_LATEST,pn as OUTDENT_CONTENT_COMMAND,Je as PASTE_COMMAND,Co as PASTE_TAG,Zi as ParagraphNode,Ze as REDO_COMMAND,Ve as REMOVE_TEXT_COMMAND,zi as RootNode,Ie as SELECTION_CHANGE_COMMAND,Le as SELECTION_INSERT_CLIPBOARD_NODES_COMMAND,kn as SELECT_ALL_COMMAND,Xe as SET_TEXT_FORMAT_COMMAND,To as SKIP_COLLAB_TAG,bo as SKIP_DOM_SELECTION_TAG,ko as SKIP_SCROLL_INTO_VIEW_TAG,No as SKIP_SELECTION_FOCUS_TAG,z as TEXT_TYPE_TO_FORMAT,Zo as TabNode,Wo as TextNode,Qe as UNDO_COMMAND,bu as addClassNamesToElement,uo as buildImportMap,Cu as configExtension,Pe as createCommand,ys as createEditor,Dn as createRefCountedRegistry,vt as createSharedNodeState,mt as createState,Su as declarePeerDependency,xu as defineExtension,Xl as findAllLexicalElementsDeep,ka as flipDirection,lc as getActiveElement,cc as getActiveElementDeep,ac as getComposedEventTarget,tc as getComposedStaticRange,Ol as getDOMOwnerDocument,Jl as getDOMSelection,Vl as getDOMSelectionFromTarget,nc as getDOMSelectionPoints,ec as getDOMSelectionRange,oc as getDOMSelectionRangeAndPoints,Gl as getDOMShadowRoots,Rs as getDOMTextNode,da as getDeclaredSlots,Ps as getEditorPropertyFromDOMNode,Fs as getNearestEditorFromDOMNode,wl as getParentElement,Es as getRegisteredNode,Ns as getRegisteredNodeOrThrow,Jc as getRegisteredSubtypeMap,Ql as getRootOwnerDocument,Hc as getStaticNodeConfig,Mo as getStyleObjectFromCSS,Is as getTextDirection,_s as getTransformSetFromKlass,Cc as isBlockDomNode,ui as isCurrentlyReadOnlyMode,Rc as isDOMCapturingSelection,Bs as isDOMDocumentNode,_c as isDOMNode,ql as isDOMShadowRoot,zs as isDOMTextNode,zc as isDOMUnmanaged,pc as isDocumentFragment,_l as isExactShortcutMatch,fc as isHTMLAnchorElement,gc as isHTMLElement,hc as isHTMLTableCellElement,dc as isHTMLTableRowElement,mc as isInlineDomNode,Xi as isLastChildInBlockNode,Ds as isLexicalEditor,gl as isModifierMatch,Gi as isOnlyChildInBlockNode,Ms as isSelectionCapturedInDecoratorInput,As as isSelectionWithinEditor,jc as iterStaticNodeConfigChain,qa as makeStepwiseIterator,Eu as mergeRegister,bc as mountSlotContainer,ku as normalizeClassNames,Fn as registerEventListener,wu as registerEventListeners,Nu as removeClassNamesFromElement,js as removeFromParent,bs as resetRandomKey,vu as safeCast,Fo as setDOMStyleFromCSS,Do as setDOMStyleObject,Kc as setDOMUnmanaged,Pc as setNodeIndentFromDOM,Tu as shallowMergeConfig,io as stopLexicalPropagation,Ws as toggleTextFormatType,Vr as tokenizeRawText,Nc as unmountSlotContainer}; +diff --git a/src/LexicalUtils.ts b/src/LexicalUtils.ts +index 68509f1a85808d87999aa52183157258e39f97a1..661334b9d5ae3f67d25cef64527939db2e16e706 100644 +--- a/src/LexicalUtils.ts ++++ b/src/LexicalUtils.ts +@@ -1638,7 +1638,8 @@ export function scrollIntoViewIfNeeded( + // or the caret stays behind the keyboard. + const visualViewport = defaultView.visualViewport; + if (visualViewport) { +- const offsetTop = visualViewport.offsetTop; ++ // Match getBoundingClientRect coordinates when a keyboard pans the page. ++ const offsetTop = visualViewport.pageTop - defaultView.scrollY; + targetTop = offsetTop; + targetBottom = offsetTop + visualViewport.height; + } else { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 69b1d06faf..7aaf2de909 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -18,6 +18,7 @@ patchedDependencies: '@yao-pkg/pkg@6.21.0': 4d4861969595629311f7d90a0b34b15481c96d5682d828a151a104c69d4616d3 app-builder-lib@26.17.0: b70dc2a2a78ffabb80a4f14fafc7c103237f2b0a207e1f296fa1c1387ea29348 exceljs@4.4.0: c1bf8ac8f319dab382f08e3a669b715e691d46c703ac5a4163eb383fbedd1d48 + lexical@0.49.0: 54c4413db208cf234cb68c6a837f2523d3b319aa17911f1da385af08362e1356 node-pty@1.2.0-beta.15: 9d30053266d0f39d3debe894c675867f6782da6bcadbc94a693b3cfb9eff8ed0 importers: @@ -3993,7 +3994,7 @@ importers: version: 2.1.1 lexical: specifier: ^0.49.0 - version: 0.49.0(typescript@6.0.3) + version: 0.49.0(patch_hash=54c4413db208cf234cb68c6a837f2523d3b319aa17911f1da385af08362e1356)(typescript@6.0.3) react: specifier: ^18.2.0 version: 18.3.1 @@ -25690,14 +25691,14 @@ snapshots: '@lexical/selection': 0.49.0(typescript@6.0.3) '@lexical/utils': 0.49.0(typescript@6.0.3) '@types/trusted-types': 2.0.7 - lexical: 0.49.0(typescript@6.0.3) + lexical: 0.49.0(patch_hash=54c4413db208cf234cb68c6a837f2523d3b319aa17911f1da385af08362e1356)(typescript@6.0.3) optionalDependencies: typescript: 6.0.3 '@lexical/dragon@0.49.0(typescript@6.0.3)': dependencies: '@lexical/extension': 0.49.0(typescript@6.0.3) - lexical: 0.49.0(typescript@6.0.3) + lexical: 0.49.0(patch_hash=54c4413db208cf234cb68c6a837f2523d3b319aa17911f1da385af08362e1356)(typescript@6.0.3) optionalDependencies: typescript: 6.0.3 @@ -25706,7 +25707,7 @@ snapshots: '@lexical/internal': 0.49.0(typescript@6.0.3) '@lexical/utils': 0.49.0(typescript@6.0.3) '@preact/signals-core': 1.14.4 - lexical: 0.49.0(typescript@6.0.3) + lexical: 0.49.0(patch_hash=54c4413db208cf234cb68c6a837f2523d3b319aa17911f1da385af08362e1356)(typescript@6.0.3) optionalDependencies: typescript: 6.0.3 @@ -25714,7 +25715,7 @@ snapshots: dependencies: '@lexical/internal': 0.49.0(typescript@6.0.3) happy-dom: 20.11.6 - lexical: 0.49.0(typescript@6.0.3) + lexical: 0.49.0(patch_hash=54c4413db208cf234cb68c6a837f2523d3b319aa17911f1da385af08362e1356)(typescript@6.0.3) optionalDependencies: typescript: 6.0.3 transitivePeerDependencies: @@ -25725,7 +25726,7 @@ snapshots: dependencies: '@lexical/extension': 0.49.0(typescript@6.0.3) '@lexical/utils': 0.49.0(typescript@6.0.3) - lexical: 0.49.0(typescript@6.0.3) + lexical: 0.49.0(patch_hash=54c4413db208cf234cb68c6a837f2523d3b319aa17911f1da385af08362e1356)(typescript@6.0.3) optionalDependencies: typescript: 6.0.3 @@ -25735,7 +25736,7 @@ snapshots: '@lexical/internal': 0.49.0(typescript@6.0.3) '@lexical/selection': 0.49.0(typescript@6.0.3) '@lexical/utils': 0.49.0(typescript@6.0.3) - lexical: 0.49.0(typescript@6.0.3) + lexical: 0.49.0(patch_hash=54c4413db208cf234cb68c6a837f2523d3b319aa17911f1da385af08362e1356)(typescript@6.0.3) optionalDependencies: typescript: 6.0.3 @@ -25749,7 +25750,7 @@ snapshots: '@lexical/html': 0.49.0(typescript@6.0.3) '@lexical/internal': 0.49.0(typescript@6.0.3) '@lexical/utils': 0.49.0(typescript@6.0.3) - lexical: 0.49.0(typescript@6.0.3) + lexical: 0.49.0(patch_hash=54c4413db208cf234cb68c6a837f2523d3b319aa17911f1da385af08362e1356)(typescript@6.0.3) optionalDependencies: typescript: 6.0.3 @@ -25760,21 +25761,21 @@ snapshots: '@lexical/extension': 0.49.0(typescript@6.0.3) '@lexical/selection': 0.49.0(typescript@6.0.3) '@lexical/utils': 0.49.0(typescript@6.0.3) - lexical: 0.49.0(typescript@6.0.3) + lexical: 0.49.0(patch_hash=54c4413db208cf234cb68c6a837f2523d3b319aa17911f1da385af08362e1356)(typescript@6.0.3) optionalDependencies: typescript: 6.0.3 '@lexical/selection@0.49.0(typescript@6.0.3)': dependencies: '@lexical/internal': 0.49.0(typescript@6.0.3) - lexical: 0.49.0(typescript@6.0.3) + lexical: 0.49.0(patch_hash=54c4413db208cf234cb68c6a837f2523d3b319aa17911f1da385af08362e1356)(typescript@6.0.3) optionalDependencies: typescript: 6.0.3 '@lexical/text@0.49.0(typescript@6.0.3)': dependencies: '@lexical/internal': 0.49.0(typescript@6.0.3) - lexical: 0.49.0(typescript@6.0.3) + lexical: 0.49.0(patch_hash=54c4413db208cf234cb68c6a837f2523d3b319aa17911f1da385af08362e1356)(typescript@6.0.3) optionalDependencies: typescript: 6.0.3 @@ -25782,7 +25783,7 @@ snapshots: dependencies: '@lexical/internal': 0.49.0(typescript@6.0.3) '@lexical/selection': 0.49.0(typescript@6.0.3) - lexical: 0.49.0(typescript@6.0.3) + lexical: 0.49.0(patch_hash=54c4413db208cf234cb68c6a837f2523d3b319aa17911f1da385af08362e1356)(typescript@6.0.3) optionalDependencies: typescript: 6.0.3 @@ -29646,7 +29647,7 @@ snapshots: prelude-ls: 1.2.1 type-check: 0.4.0 - lexical@0.49.0(typescript@6.0.3): + lexical@0.49.0(patch_hash=54c4413db208cf234cb68c6a837f2523d3b319aa17911f1da385af08362e1356)(typescript@6.0.3): dependencies: '@lexical/internal': 0.49.0(typescript@6.0.3) optionalDependencies: diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index 2b60265604..e9f3c19f44 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -116,4 +116,5 @@ patchedDependencies: '@yao-pkg/pkg@6.21.0': patches/@yao-pkg__pkg@6.21.0.patch app-builder-lib@26.17.0: patches/app-builder-lib@26.17.0.patch exceljs@4.4.0: patches/exceljs@4.4.0.patch + lexical@0.49.0: patches/lexical@0.49.0.patch node-pty@1.2.0-beta.15: patches/node-pty@1.2.0-beta.15.patch From f23d7801bdd537bbe04226a3101e76920026c418 Mon Sep 17 00:00:00 2001 From: Stevring Date: Thu, 15 Oct 2026 17:41:49 +0800 Subject: [PATCH 04/12] fix(client): dismiss mobile keyboard after submitting prompts Dismiss focus when an accepted submission empties the mobile composer, preserving desktop focus and retained drafts. Rename the shared device predicate to isMobileDevice and update its consumers, documentation, and focus regressions. --- apps/web/tests/composer-focus.e2e.ts | 57 ++++++++++++++++++- .../composer-focus/submission.expected.md | 2 + .../src/client/PopupSelectView.tsx | 4 +- .../client/ui-conversation/README.i18n.yaml | 4 +- packages/client/ui-conversation/README.md | 2 +- packages/client/ui-conversation/README.zh.md | 2 +- .../src/client/input/editor/runtime.ts | 5 +- .../src/client/input/editor/view-binding.ts | 15 +++++ .../src/client/skeleton/InputBar.tsx | 11 +++- .../tests/editor-focus.client.spec.ts | 19 ++++++- .../tests/input-bar.client.spec.tsx | 39 ++++++++++++- .../src/client/ModelSelect.tsx | 6 +- .../client/ui-primitives/README.i18n.yaml | 4 +- packages/client/ui-primitives/README.md | 2 +- packages/client/ui-primitives/README.zh.md | 2 +- packages/client/ui-primitives/src/focus.ts | 11 ++-- packages/client/ui-primitives/src/index.ts | 2 +- .../ui-schedule/src/client/TaskMenu.tsx | 4 +- 18 files changed, 161 insertions(+), 30 deletions(-) create mode 100644 apps/web/tests/expected/composer-focus/submission.expected.md diff --git a/apps/web/tests/composer-focus.e2e.ts b/apps/web/tests/composer-focus.e2e.ts index 3c0e14db25..f3a15020c9 100644 --- a/apps/web/tests/composer-focus.e2e.ts +++ b/apps/web/tests/composer-focus.e2e.ts @@ -199,7 +199,62 @@ it('restores the previous caret or selection in fresh and existing sessions', as '# Composer whitespace focus', '', '## Fresh session', '', ...hero, '', '## Existing session', '', ...docked, ].join('\n'), webSnapshotMode()) - await assertFixtureInventory(SNAPSHOT_DIR, ['focus.expected.md']) + await assertFixtureInventory(SNAPSHOT_DIR, ['focus.expected.md', 'submission.expected.md']) if (webSnapshotMode() !== 'record') expect(tripwire.warnings).toEqual([]) expect(tripwire.pageErrors).toEqual([]) }, 180_000) + +it('dismisses the mobile keyboard after Send while retaining desktop focus', async () => { + const browser = await chromium.launch() + onTestFinished(() => browser.close()) + const observations: string[] = [] + for (const mobile of [false, true]) { + const scaffold = await launchWebScaffold({ + replayFixture: fileURLToPath(new URL('../../../snapshots/web/live-interactions/session.v3.jsonl', import.meta.url)), + compareReplaySession: false, + }) + try { + const page = await browser.newPage({ + viewport: { width: mobile ? 390 : 1280, height: 844 }, + locale: 'en-US', timezoneId: 'Asia/Shanghai', + ...mobile ? { + userAgent: 'Mozilla/5.0 (iPhone; CPU iPhone OS 18_6 like Mac OS X) AppleWebKit/605.1.15 Version/18.6 Mobile/15E148 Safari/604.1', + isMobile: true, hasTouch: true, + } : {}, + }) + const tripwire = watchConsole(page) + const platform = mobile ? 'Mobile' : 'Desktop' + let finished = false + const off = scaffold.ctx.on('session/event', (_session, event) => { + if (event.type === 'turn/end') finished = true + }) + try { + await page.goto(scaffold.authenticatedUrl) + await connectFreshWorkspace(page, scaffold.workspaceCwd, `submission-${platform}`) + const input = page.locator('[data-composer-input][contenteditable="true"]') + await input.fill('Reply with a one-sentence description of event sourcing, then stop.') + expect(await input.evaluate(element => document.activeElement === element)).toBe(true) + const send = page.getByRole('button', { name: 'Send message', exact: true }) + if (mobile) await send.tap() + else await send.click() + await expect.poll(() => input.textContent()).toBe('') + await expect.poll(() => input.evaluate(element => document.activeElement === element)).toBe(!mobile) + await expect.poll(() => finished, { timeout: 60_000 }).toBe(true) + expect(await input.evaluate(element => document.activeElement === element)).toBe(!mobile) + observations.push(`- ${platform}: Send clears the draft; editor ${mobile ? 'unfocused' : 'focused'} through response completion`) + expect(tripwire.pageErrors).toEqual([]) + if (webSnapshotMode() !== 'record') expect(tripwire.warnings).toEqual([]) + } catch (error) { + await saveFailureShot(page, `web-e2e-composer-submission-${platform}`) + throw error + } finally { + off() + await page.close() + } + } finally { + await scaffold.close() + } + } + await compareOrRefreshGolden(join(SNAPSHOT_DIR, 'submission.expected.md'), observations.join('\n'), webSnapshotMode()) + await assertFixtureInventory(SNAPSHOT_DIR, ['focus.expected.md', 'submission.expected.md']) +}, 180_000) diff --git a/apps/web/tests/expected/composer-focus/submission.expected.md b/apps/web/tests/expected/composer-focus/submission.expected.md new file mode 100644 index 0000000000..4f711bfed1 --- /dev/null +++ b/apps/web/tests/expected/composer-focus/submission.expected.md @@ -0,0 +1,2 @@ +- Desktop: Send clears the draft; editor focused through response completion +- Mobile: Send clears the draft; editor unfocused through response completion diff --git a/packages/client/ui-commands/src/client/PopupSelectView.tsx b/packages/client/ui-commands/src/client/PopupSelectView.tsx index f0338c6c68..911a8f5d21 100644 --- a/packages/client/ui-commands/src/client/PopupSelectView.tsx +++ b/packages/client/ui-commands/src/client/PopupSelectView.tsx @@ -15,7 +15,7 @@ import { MenuGroup, MenuSurface, observeStickyMenuGroups } from '@deepseek-ai/ds import { Fragment, useEffect, useMemo, useRef } from 'react' import { useSyncExternalStore } from 'react' import clsx from 'clsx' -import { IconCheckOutlineRegular, RiskConfirmation, shouldAutoFocusTextInput, useAnchoredMaxHeight } from '@deepseek-ai/dsh-client-ui-primitives' +import { IconCheckOutlineRegular, isMobileDevice, RiskConfirmation, useAnchoredMaxHeight } from '@deepseek-ai/dsh-client-ui-primitives' import type { PropsLocale } from '@deepseek-ai/dsh-client-ui-slots' import { filterOptions } from './popup.ts' import type { SelectOption } from './contract.ts' @@ -85,7 +85,7 @@ export function PopupSelectView({ popup, t }: PopupSelectViewProps) { // Focus the search input after it mounts (separate effect so the ref is populated). useEffect(() => { if (!state.open || state.confirming !== null) return - if (!shouldAutoFocusTextInput()) return + if (isMobileDevice()) return searchRef.current?.focus() }, [state.open, state.confirming]) diff --git a/packages/client/ui-conversation/README.i18n.yaml b/packages/client/ui-conversation/README.i18n.yaml index 18351953a5..681f796105 100644 --- a/packages/client/ui-conversation/README.i18n.yaml +++ b/packages/client/ui-conversation/README.i18n.yaml @@ -21,8 +21,8 @@ en: 9912b286384c41d7 zh: 3e994887c1948677 /deepseek-ai-dsh-client-ui-conversation/shell-and-standard-props: - en: 74566fff43564bfe - zh: 4944512f461a08b0 + en: 6cbb0800f2db9220 + zh: 405701def5431492 /deepseek-ai-dsh-client-ui-conversation/temporary-composer-entries: en: bb1244310f5c0382 zh: 824b84077432b559 diff --git a/packages/client/ui-conversation/README.md b/packages/client/ui-conversation/README.md index 2c9c270a55..f15bb0e7a3 100644 --- a/packages/client/ui-conversation/README.md +++ b/packages/client/ui-conversation/README.md @@ -68,7 +68,7 @@ The composer measures its expanded control groups after size, content, visibilit The context meter follows the [statistics-control radius](../../../docs/ui-radius.md#radius-scale). -The composer uses the shared [text-input focus policy](../ui-primitives/README.md#use-this-package) on mount, Session switching, and unlock. Identified phones and tablets require tapping the input; desktop devices retain automatic focus. The [Lexical patch](../../../patches/lexical@0.49.0.patch) keeps caret scrolling in the same coordinate system as DOM geometry when a mobile keyboard pans the page. +The composer uses the shared [text-input focus policy](../ui-primitives/README.md#use-this-package) on mount, Session switching, and unlock. Identified phones and tablets require tapping the input; desktop devices retain automatic focus. On these mobile devices, a submission that empties the draft dismisses the keyboard; rejected submissions and retained newer draft text preserve focus. The [Lexical patch](../../../patches/lexical@0.49.0.patch) keeps caret scrolling in the same coordinate system as DOM geometry when a mobile keyboard pans the page. The context-occupancy button shows a ring and percentage below the input card, after the Session statistics. Clicking it opens the token breakdown in a panel kept inside the viewport, including when no statistics are shown; the button stays hidden until context usage and capacity are available. diff --git a/packages/client/ui-conversation/README.zh.md b/packages/client/ui-conversation/README.zh.md index efa98b4c1c..76a0b25ca4 100644 --- a/packages/client/ui-conversation/README.zh.md +++ b/packages/client/ui-conversation/README.zh.md @@ -68,7 +68,7 @@ Queue 预览启用空白折叠和文档边缘 trim,保留 emoji,并使用 CS 上下文占用率入口遵循[统计控件圆角规则](../../../docs/ui-radius.zh.md#radius-scale)。 -composer 在挂载、切换 Session 和解除锁定时使用共享的[文字输入框聚焦策略](../ui-primitives/README.zh.md#use-this-package)。识别出的手机和平板需要点击输入框;桌面设备保留自动聚焦。移动端键盘平移页面时,[Lexical 补丁](../../../patches/lexical@0.49.0.patch)让光标滚动计算与 DOM 几何使用同一坐标系。 +composer 在挂载、切换 Session 和解除锁定时使用共享的[文字输入框聚焦策略](../ui-primitives/README.zh.md#use-this-package)。识别出的手机和平板需要点击输入框;桌面设备保留自动聚焦。在这些移动设备上,提交后清空草稿会收起键盘;被拒绝的提交和保留的新草稿文字不会改变焦点。移动端键盘平移页面时,[Lexical 补丁](../../../patches/lexical@0.49.0.patch)让光标滚动计算与 DOM 几何使用同一坐标系。 上下文占用按钮在输入卡片下方、会话统计右侧显示圆环和百分比。点击按钮可在视口内的面板查看 token 构成,没有统计项时面板也不会越界;上下文用量和容量尚不可用时,按钮保持隐藏。 diff --git a/packages/client/ui-conversation/src/client/input/editor/runtime.ts b/packages/client/ui-conversation/src/client/input/editor/runtime.ts index 7cd85c0506..8cf4123cb8 100644 --- a/packages/client/ui-conversation/src/client/input/editor/runtime.ts +++ b/packages/client/ui-conversation/src/client/input/editor/runtime.ts @@ -42,6 +42,9 @@ const REFERENCE_PLACEHOLDER_RE = /[\uE100-\uE11D\uFFFC]/gu /** Undo merge window for contiguous typing, in ms (the old machine's mergeWindowMs). */ const HISTORY_MERGE_DELAY_MS = 1000 +/** Editor update that removes submitted content while retaining any newer draft suffix. */ +export const DRAFT_SUBMITTED_TAG = 'dsh-draft-submitted' + /** One model-owned editor; registration and disposal remain with its model. */ export class DraftEditorRuntime { /** The editor bound by the Composer's contenteditable host. */ @@ -323,7 +326,7 @@ export class DraftEditorRuntime { const root = $getRoot() root.clear() root.selectEnd() - }, { discrete: true, tag: HISTORY_MERGE_TAG }) + }, { discrete: true, tag: [HISTORY_MERGE_TAG, DRAFT_SUBMITTED_TAG] }) } /** diff --git a/packages/client/ui-conversation/src/client/input/editor/view-binding.ts b/packages/client/ui-conversation/src/client/input/editor/view-binding.ts index dacb1796b8..725d610d04 100644 --- a/packages/client/ui-conversation/src/client/input/editor/view-binding.ts +++ b/packages/client/ui-conversation/src/client/input/editor/view-binding.ts @@ -1,11 +1,26 @@ /** DOM and keymap bindings installed by the InputBar's existing effects. */ import type { MouseEvent, MutableRefObject, RefObject } from 'react' import type { LexicalEditor } from 'lexical' +import { $getRoot } from 'lexical' +import { isMobileDevice } from '@deepseek-ai/dsh-client-ui-primitives' import type { ComposerKeyboard } from '../../contract/draft-editor.ts' import type { ComposerBarProps } from '../../contract/slots.ts' import type { BusyEnterBehavior } from '../../contract/composer-submission.ts' import { resolveSubmitMode } from '../submission-policy.ts' import { registerComposerKeymap } from './keymap.ts' +import { DRAFT_SUBMITTED_TAG } from './runtime.ts' + +/** + * Dismiss the mobile keyboard after a submission empties the draft. + * @param editor - the Session-owned editor. + * @returns the update-listener cleanup. + */ +export function installDraftKeyboardDismissal(editor: LexicalEditor): () => void { + return editor.registerUpdateListener(({ editorState, tags }) => { + if (!tags.has(DRAFT_SUBMITTED_TAG) || !isMobileDevice()) return + if (editorState.read(() => $getRoot().getTextContentSize() === 0)) editor.getRootElement()?.blur() + }) +} interface DraftViewGate { locked: boolean diff --git a/packages/client/ui-conversation/src/client/skeleton/InputBar.tsx b/packages/client/ui-conversation/src/client/skeleton/InputBar.tsx index 8faa94c784..e3a43f138f 100644 --- a/packages/client/ui-conversation/src/client/skeleton/InputBar.tsx +++ b/packages/client/ui-conversation/src/client/skeleton/InputBar.tsx @@ -17,7 +17,7 @@ import { memo, useCallback, useEffect, useLayoutEffect, useMemo, useRef, useStat import type { ChangeEvent, KeyboardEvent, MouseEvent } from 'react' import clsx from 'clsx' import { - IconPlusOutlineMedium, IconWarningOutlineRegular, shouldAutoFocusTextInput, Toast, Tooltip, + IconPlusOutlineMedium, IconWarningOutlineRegular, isMobileDevice, Toast, Tooltip, } from '@deepseek-ai/dsh-client-ui-primitives' // Type-only: the `plan` projection key merge (the TodoDock posture — the // composer reads a host-computed value; the domain owns the key). @@ -31,7 +31,7 @@ import type { Translate } from '@deepseek-ai/dsh-client-ui-slots' import type { ComposerBarProps } from '../contract/slots.ts' import { DraftEditor } from '../input/editor/DraftEditor.tsx' import { - focusDraftEditor, installDraftFilePicker, installDraftKeymap, installDraftWheel, + focusDraftEditor, installDraftFilePicker, installDraftKeyboardDismissal, installDraftKeymap, installDraftWheel, keepDraftFocus, revealDraftSelection, } from '../input/editor/view-binding.ts' import { resolveSubmitMode } from '../input/submission-policy.ts' @@ -176,7 +176,7 @@ export const InputBar = memo(function InputBar({ // scrolling the conversation. useEffect(() => { if (locked || editor === null) return - if (!shouldAutoFocusTextInput()) return + if (isMobileDevice()) return focusDraftEditor(editor, revealSelection) }, [locked, sessionId, editor]) @@ -267,6 +267,11 @@ export const InputBar = memo(function InputBar({ return installDraftKeymap(editor, keyboard, gate) }, [editor, keyboard]) + useEffect(() => { + if (editor === null) return + return installDraftKeyboardDismissal(editor) + }, [editor]) + // Button presses steal focus from the editor; suppress at mousedown so // typing continues seamlessly. Lexical's focus() carries preventScroll and // restores the previous selection, so no reveal is needed: the caret has diff --git a/packages/client/ui-conversation/tests/editor-focus.client.spec.ts b/packages/client/ui-conversation/tests/editor-focus.client.spec.ts index 7f115ff744..fe9ebf277f 100644 --- a/packages/client/ui-conversation/tests/editor-focus.client.spec.ts +++ b/packages/client/ui-conversation/tests/editor-focus.client.spec.ts @@ -3,7 +3,7 @@ import { expect, it, onTestFinished, vi } from 'vitest' import { $getRoot, $getSelection, $isRangeSelection, SELECTION_CHANGE_COMMAND, UNDO_COMMAND } from 'lexical' import { DraftEditorRuntime } from '../src/client/input/editor/runtime.ts' -import { focusDraftEditor } from '../src/client/input/editor/view-binding.ts' +import { focusDraftEditor, installDraftKeyboardDismissal } from '../src/client/input/editor/view-binding.ts' function fixture(start = 1, end = 4) { // jsdom has no Range geometry; these cases observe selection and focus, not scrolling. @@ -137,6 +137,23 @@ it('restores a pending selection when blur and explicit focus share one update b expect(reveal).toHaveBeenCalledOnce() }) +it('retains mobile focus for a newer draft suffix and removes dismissal with the view', () => { + const userAgent = vi.spyOn(navigator, 'userAgent', 'get').mockReturnValue('Mozilla/5.0 (iPhone; CPU iPhone OS 18_6 like Mac OS X) AppleWebKit/605.1.15 Version/18.6 Mobile/15E148 Safari/604.1') + onTestFinished(() => { userAgent.mockRestore() }) + const f = fixture() + const dispose = installDraftKeyboardDismissal(f.editor) + onTestFinished(dispose) + + f.runtime.clearCommittedDraft(() => 6) + expect(f.root.textContent).toBe('beta') + expect(document.activeElement).toBe(f.root) + + dispose() + f.runtime.clearCommittedDraft(() => null) + expect(f.root.textContent).toBe('') + expect(document.activeElement).toBe(f.root) +}) + it('removes focus preservation and update subscriptions when registration is disposed', () => { const f = fixture() f.dispose() diff --git a/packages/client/ui-conversation/tests/input-bar.client.spec.tsx b/packages/client/ui-conversation/tests/input-bar.client.spec.tsx index 557c1086dd..7cd23b3d4e 100644 --- a/packages/client/ui-conversation/tests/input-bar.client.spec.tsx +++ b/packages/client/ui-conversation/tests/input-bar.client.spec.tsx @@ -1422,7 +1422,7 @@ describe('running and lock semantics', () => { { name: 'desktop-mode iPad', userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 Version/18.6 Safari/605.1.15', platform: 'MacIntel', maxTouchPoints: 5, automatic: false }, { name: 'Mac', userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 Version/18.6 Safari/605.1.15', platform: 'MacIntel', maxTouchPoints: 0, automatic: true }, { name: 'Windows touchscreen', userAgent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 Chrome/119.0.0.0 Safari/537.36', platform: 'Win32', maxTouchPoints: 5, automatic: true }, - ])('automatic composer focus respects device classification: $name', ({ userAgent, platform, maxTouchPoints, automatic }) => { + ])('composer focus and submission respect device classification: $name', async ({ userAgent, platform, maxTouchPoints, automatic }) => { for (const [name, value] of Object.entries({ userAgent, platform, maxTouchPoints })) { const descriptor = Object.getOwnPropertyDescriptor(navigator, name) Object.defineProperty(navigator, name, { configurable: true, value }) @@ -1436,7 +1436,7 @@ describe('running and lock semantics', () => { onTestFinished(() => { outside.remove() }) outside.focus() - const { view, textarea, props } = bench({ draft: 'draft' }) + const { view, textarea, props, shell, button, sink } = bench({ draft: 'draft' }) expect(document.activeElement).toBe(automatic ? textarea : outside) act(() => { outside.focus() }) act(() => { view.rerender() }) @@ -1449,6 +1449,41 @@ describe('running and lock semantics', () => { act(() => { outside.focus() }) fireEvent.mouseDown(view.container.querySelector('[data-composer-card]')!, { button: 0 }) expect(document.activeElement).toBe(textarea) + + writeDraft(shell, '') + expect(document.activeElement).toBe(textarea) + fireEvent.keyDown(textarea, { key: 'Enter' }) + expect(sink).not.toHaveBeenCalled() + expect(document.activeElement).toBe(textarea) + + for (const gesture of ['click', 'enter'] as const) { + writeDraft(shell, `send by ${gesture}`) + act(() => { textarea.focus() }) + if (gesture === 'click') { + fireEvent.mouseDown(button, { button: 0 }) + fireEvent.click(button) + } else { + fireEvent.keyDown(textarea, { key: 'Enter' }) + } + await act(async () => {}) + expect(sink).toHaveBeenLastCalledWith(`send by ${gesture}`, [], 'queue', expect.any(AbortSignal)) + expect(shell.snapshot.draft).toBe('') + expect(document.activeElement === textarea).toBe(automatic) + } + + writeDraft(shell, '/goal ') + act(() => { + shell.beginCommand( + { name: 'goal', token: '/goal ', submit: () => Promise.resolve({ kind: 'error', text: 'Missing goal' }) }, + { start: 0, end: 6, draftRev: shell.snapshot.draftRev }, + ) + textarea.focus() + }) + fireEvent.keyDown(textarea, { key: 'Enter' }) + await act(async () => {}) + expect(shell.snapshot.phase).toBe('claimed') + expect(shell.snapshot.draft).toBe('/goal ') + expect(document.activeElement).toBe(textarea) }) it('a persisted draft adopted after mount does not steal focus from another control', () => { diff --git a/packages/client/ui-model-selection/src/client/ModelSelect.tsx b/packages/client/ui-model-selection/src/client/ModelSelect.tsx index 9469c72085..cbdbe9dd48 100644 --- a/packages/client/ui-model-selection/src/client/ModelSelect.tsx +++ b/packages/client/ui-model-selection/src/client/ModelSelect.tsx @@ -37,7 +37,7 @@ import clsx from 'clsx' import type { ModelReasoningEffort, ModelSelection } from '@deepseek-ai/dsh-api-remotes/client' import { IconCheckOutlineRegular, IconChevronDownOutlineRegular, IconChevronRightOutlineRegular, IconCloseFillRegular, - IconDataOutlineRegular, IconWarningOutlineRegular, Input, rankByName, shouldAutoFocusTextInput, StateDot, Toast, + IconDataOutlineRegular, IconWarningOutlineRegular, Input, isMobileDevice, rankByName, StateDot, Toast, } from '@deepseek-ai/dsh-client-ui-primitives' import type { PropsLocale, PropsRenderSlots, PropsRuntime } from '@deepseek-ai/dsh-client-ui-slots' import type { ModelLabelOwner, ModelSelectInjected } from './slots.ts' @@ -184,7 +184,7 @@ export function ModelSelect( previousShowSearch.current = showSearch const intent = paneFocus.current ?? (changedSearchMode && pane === 'model' ? 'drill' : null) paneFocus.current = null - if (!open || intent === null || !shouldAutoFocusTextInput()) return + if (!open || intent === null || isMobileDevice()) return if (intent === 'drill') { if (pane === 'model' && showSearch) { searchRef.current?.focus() @@ -251,7 +251,7 @@ export function ModelSelect( const show = (): void => { setSelectionFocus(false) - if (shouldAutoFocusTextInput()) triggerRef.current?.focus() + if (!isMobileDevice()) triggerRef.current?.focus() setQuery('') setHighlightedIndex(null) if (currentChoice === undefined) paneFocus.current = 'drill' diff --git a/packages/client/ui-primitives/README.i18n.yaml b/packages/client/ui-primitives/README.i18n.yaml index c522c7d9a3..07d93dc975 100644 --- a/packages/client/ui-primitives/README.i18n.yaml +++ b/packages/client/ui-primitives/README.i18n.yaml @@ -15,8 +15,8 @@ en: d152484eb41ac6b4 zh: 09388d293f9be9cb /deepseek-ai-dsh-client-ui-primitives/use-this-package: - en: ca1f7a50db82a513 - zh: 6dbd3cbb1c2ac46d + en: 5875d977b12a64f4 + zh: a89693f28c608558 /deepseek-ai-dsh-client-ui-primitives/use-this-package/component-catalog: en: 03388f40dc593990 zh: 5f1541a6e20c8cfe diff --git a/packages/client/ui-primitives/README.md b/packages/client/ui-primitives/README.md index a7c2920885..f2d850af90 100644 --- a/packages/client/ui-primitives/README.md +++ b/packages/client/ui-primitives/README.md @@ -27,7 +27,7 @@ Use `dsh-client-ui-primitives` to build web-client controls and render agent out `Toast` uses the theme’s toast background and label colors in both light and dark modes. `Menu` data rows and `MenuItemButton` component rows accept owner-provided effective shortcuts and align their keys at the trailing edge as muted text without a background, including submenus. `ShortcutKeys` defaults to unboxed keys for menu and inline hints. Its `tooltip` variant uses lighter keycaps over the dark bubble and groups plus-separated combinations into one filled block. `Tooltip.shortcutKeys` vertically centers keycaps beside optional localized action text, or shows only keys when the label is empty. The optional `className` supplies owner interaction styles. `Modal` uses the frame’s shared overlay inset, with a minimum 24px viewport margin. Its mask leaves the Windows caption unpainted while the full-viewport layer blocks background clicks. `Modal` and the settings shell share top-layer Escape and Tab handling through `useModalLayer`, restoring the previous focus on close. `closeTopModal(document)` requests the foreground modal’s current close action; newer menus or unregistered dialogs block dismissal of the modal behind them. Components use `isBehindModal` to avoid moving focus behind a nested dialog. Menus consume their local Escape before modal dismissal. `observeComposition` supplies the same composition-end and legacy IME guard to local modal and recording handlers; callers dispose its document listeners with their interaction lifetime. -`shouldAutoFocusTextInput()` controls automatic text-input focus for the composer and command popups. It returns false for Bowser's UA classifications `mobile` and `tablet`, and for iPads reporting `MacIntel` with more than one touch point. Other devices, including Windows touchscreen computers, retain automatic focus regardless of window width. User-requested focus remains available. Browser modes or custom UA strings that conceal the mobile platform can prevent identification; unrecognized UAs permit automatic focus. A desktop UA alone cannot distinguish Android tablets from Linux computers. +`isMobileDevice()` identifies phones and tablets for behavior such as automatic text-input focus and keyboard dismissal. It returns true for Bowser's UA classifications `mobile` and `tablet`, and for iPads reporting `MacIntel` with more than one touch point. It returns false for other devices, including Windows touchscreen computers, regardless of window width. The composer and command popups suppress automatic text-input focus on identified mobile devices; user-requested focus remains available. Browser modes or custom UA strings that conceal the mobile platform can prevent identification; unrecognized UAs return false. A desktop UA alone cannot distinguish Android tablets from Linux computers. Automatic modal entry and modal/menu return focus, including after Escape and application close shortcuts, use `focusWithoutRing(element, options?)` to suppress the outline until Tab or directional navigation resumes normal focus styling. Dialog containers keep their outline-free styling. Existing borders, shadows, and error states remain intact. Mark a dialog's initial control with `data-modal-autofocus` so the modal captures its invoking control before moving focus. Controls mounted with the dialog must not use React `autoFocus`, which runs before that capture. Tab and Shift+Tab from the dialog container enter its first and last focusable controls. diff --git a/packages/client/ui-primitives/README.zh.md b/packages/client/ui-primitives/README.zh.md index f6adf22e6f..ee779ff616 100644 --- a/packages/client/ui-primitives/README.zh.md +++ b/packages/client/ui-primitives/README.zh.md @@ -27,7 +27,7 @@ kind: "package-library" `Toast` 在浅色和深色模式下均使用主题的系统提示背景与文字颜色。`Menu` 数据条目与 `MenuItemButton` 组件条目接收功能 owner 提供的有效快捷键,并在末端以无背景的浅灰色文字对齐显示,子菜单也采用同一呈现。`ShortcutKeys` 默认以无方块的按键文字显示菜单和行内提示。`tooltip` 变体在深色气泡上使用稍浅的键帽,以加号连接的组合则共用一个填充色块。`Tooltip.shortcutKeys` 将键帽与可选的本地化操作文本垂直居中排列,标签为空时只显示按键。可选的 `className` 供调用方设置交互状态样式。`Modal` 使用框架共享的浮层起点,视口边距至少为 24px。其遮罩不绘制 Windows 顶栏区域,覆盖整个视口的模态层仍阻挡背景点击。`Modal` 与设置外壳通过 `useModalLayer` 共用顶层 Esc 和 Tab 处理,关闭时恢复先前焦点。`closeTopModal(document)` 请求前台弹窗当前的关闭操作;上层菜单或未注册的对话框会阻止关闭其后方弹窗。组件通过 `isBehindModal` 避免将焦点移到嵌套弹窗后方。菜单先消费自己的 Esc,再由模态层处理关闭。 `observeComposition` 为局部弹层和录键处理提供相同的 composition-end 与旧版 IME 保护;调用方随交互生命周期释放其 document 监听。 -`shouldAutoFocusTextInput()` 控制 composer 和命令弹窗中文字输入框的自动聚焦。对于 Bowser 从 UA 识别为 `mobile` 或 `tablet` 的设备,以及报告 `MacIntel` 且触摸点数大于一的 iPad,该函数返回 false。其他设备(包括 Windows 触屏电脑)保留自动聚焦,不受窗口宽度影响。用户主动请求的聚焦仍然可用。隐藏移动平台信息的浏览器模式或自定义 UA 可能导致识别失败;未识别的 UA 允许自动聚焦。仅凭桌面 UA 无法区分 Android 平板与 Linux 电脑。 +`isMobileDevice()` 识别手机和平板,供自动聚焦和收起键盘等行为使用。对于 Bowser 从 UA 识别为 `mobile` 或 `tablet` 的设备,以及报告 `MacIntel` 且触摸点数大于一的 iPad,该函数返回 true。对于其他设备(包括 Windows 触屏电脑),该函数返回 false,不受窗口宽度影响。composer 和命令弹窗在识别出的移动设备上禁止自动聚焦;用户主动请求的聚焦仍然可用。隐藏移动平台信息的浏览器模式或自定义 UA 可能导致识别失败;未识别的 UA 返回 false。仅凭桌面 UA 无法区分 Android 平板与 Linux 电脑。 弹窗自动进入及弹窗、菜单回焦,包括通过 Esc 和应用关闭快捷键触发的回焦,均使用 `focusWithoutRing(element, options?)`,在 Tab 或方向键导航恢复正常焦点样式前抑制外轮廓线。弹窗容器仍不绘制焦点外框。原有边框、阴影和错误状态保持不变。用 `data-modal-autofocus` 标记弹窗的初始控件,让模态层先保存触发控件,再移动焦点。随弹窗挂载的控件不得使用 React `autoFocus`,因为它会在保存触发控件前执行。弹窗容器获得焦点时,Tab 和 Shift+Tab 分别进入第一个和最后一个可聚焦控件。 diff --git a/packages/client/ui-primitives/src/focus.ts b/packages/client/ui-primitives/src/focus.ts index b013665ff8..87f47c25e1 100644 --- a/packages/client/ui-primitives/src/focus.ts +++ b/packages/client/ui-primitives/src/focus.ts @@ -1,18 +1,17 @@ -/** Focus policy and presentation for automatic entry and restoration. */ +/** Mobile-device detection and automatic focus presentation. */ import bowser from 'bowser' const releases = new WeakMap void>() const navigationKeys = new Set(['Tab', 'ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight', 'Home', 'End']) /** - * Decide whether the current browser device permits automatic text-input focus. + * Identify phones and tablets from the current browser's device information. * Bowser identifies phones and tablets from the UA; MacIntel with multiple touch points identifies desktop-mode iPads. - * This policy does not restrict focus requested by a user gesture or keyboard navigation. - * @returns false for identified phones and tablets; true for other devices, including unrecognized UAs. + * @returns true for identified phones and tablets; false for other devices, including unrecognized UAs. */ -export function shouldAutoFocusTextInput(): boolean { +export function isMobileDevice(): boolean { const platformType = bowser.parse(navigator.userAgent).platform.type const desktopIPad = navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1 - return platformType !== 'mobile' && platformType !== 'tablet' && !desktopIPad + return platformType === 'mobile' || platformType === 'tablet' || desktopIPad } /** diff --git a/packages/client/ui-primitives/src/index.ts b/packages/client/ui-primitives/src/index.ts index d2abf8e22f..49c574c699 100644 --- a/packages/client/ui-primitives/src/index.ts +++ b/packages/client/ui-primitives/src/index.ts @@ -36,7 +36,7 @@ export { HoverCard } from './HoverCard.tsx' export { HoverCardGroup } from './HoverCardGroup.tsx' export { ShortcutKeys } from './ShortcutKeys.tsx' export { observeComposition } from './keyboard-composition.ts' -export { focusWithoutRing, shouldAutoFocusTextInput } from './focus.ts' +export { focusWithoutRing, isMobileDevice } from './focus.ts' export { closeTopModal, isBehindModal, modalSelector, useModalLayer } from './useModalLayer.ts' export { Modal } from './Modal.tsx' export { RiskConfirmation } from './RiskConfirmation.tsx' diff --git a/packages/client/ui-schedule/src/client/TaskMenu.tsx b/packages/client/ui-schedule/src/client/TaskMenu.tsx index d0c39d0942..90683b9904 100644 --- a/packages/client/ui-schedule/src/client/TaskMenu.tsx +++ b/packages/client/ui-schedule/src/client/TaskMenu.tsx @@ -11,7 +11,7 @@ import type { CSSProperties, ReactNode } from 'react' import { createPortal } from 'react-dom' import clsx from 'clsx' import { - IconCheckOutlineRegular, shouldAutoFocusTextInput, useAnchoredPosition, useDismissOnOutsidePointer, + IconCheckOutlineRegular, isMobileDevice, useAnchoredPosition, useDismissOnOutsidePointer, } from '@deepseek-ai/dsh-client-ui-primitives' import css from './TaskMenu.module.css' @@ -176,7 +176,7 @@ export function TaskMenu({ open, anchor, items = [], selectedId, onSelect, onClo handedOver.current = false return } - if (handedOver.current || !shouldAutoFocusTextInput()) return + if (handedOver.current || isMobileDevice()) return const list = listRef.current /* v8 ignore next -- the list is rendered in the same commit that sets `open`, before this effect runs. */ if (list === null) return From feaed5016bf53b7e4d92953c0f018a525d9c0caa Mon Sep 17 00:00:00 2001 From: Stevring Date: Tue, 20 Oct 2026 12:16:57 +0800 Subject: [PATCH 05/12] fix(client): retain mobile viewport and input behavior on the split base --- apps/desktop/scripts/runtime-patch-policy.ts | 1 + .../tests/prepare-runtime-patches.spec.ts | 3 +- apps/web/index.html | 2 +- apps/web/tests/composer-focus.e2e.ts | 6 +++- apps/web/tests/default-model.e2e.ts | 11 +++++-- .../client/ui-conversation/README.i18n.yaml | 4 +-- packages/client/ui-conversation/README.md | 2 ++ packages/client/ui-conversation/README.zh.md | 2 ++ .../input/editor/composer-editor.module.css | 6 ++-- .../src/client/skeleton/EmptyHero.tsx | 7 +++-- .../src/client/skeleton/InputBar.module.css | 30 ++++++++++++++----- .../tests/editor-viewport.client.spec.ts | 2 +- .../ui-primitives/tests/atoms.client.spec.tsx | 11 +++++++ packages/client/web/README.i18n.yaml | 7 +++-- packages/client/web/README.md | 11 +++++++ packages/client/web/README.zh.md | 11 +++++++ packages/client/web/src/base.css | 24 +++++++++++++++ 17 files changed, 117 insertions(+), 23 deletions(-) diff --git a/apps/desktop/scripts/runtime-patch-policy.ts b/apps/desktop/scripts/runtime-patch-policy.ts index 1bca41b947..d285f9bab8 100644 --- a/apps/desktop/scripts/runtime-patch-policy.ts +++ b/apps/desktop/scripts/runtime-patch-policy.ts @@ -16,6 +16,7 @@ export const DESKTOP_RUNTIME_PATCHES: Readonly const before = readFileSync(join(repository, 'pnpm-lock.yaml')) const plan = prepareRuntimePatches(project, repository) expect(plan.patches.map(entry => entry.spec)).toEqual(['@earendil-works/pi-ai@1.3.0', 'node-pty@1.2.0-beta.15']) - expect(plan.workspaceOnly).toHaveLength(7) + expect(plan.workspaceOnly).toHaveLength(8) expect(plan.workspaceOnly).toContain('@botiverse/oar') + expect(plan.workspaceOnly).toContain('lexical') const settings = yaml.load(readFileSync(join(project, 'pnpm-workspace.yaml'), 'utf8')) as { overrides: Record } expect(settings.overrides['@earendil-works/pi-ai']).toBeUndefined() expect(settings.overrides['@earendil-works/pi-ai@^1.3.0']).toBe('1.3.0') diff --git a/apps/web/index.html b/apps/web/index.html index f5c2ffac06..598c7a62f2 100644 --- a/apps/web/index.html +++ b/apps/web/index.html @@ -2,7 +2,7 @@ - + diff --git a/apps/web/tests/composer-focus.e2e.ts b/apps/web/tests/composer-focus.e2e.ts index f3a15020c9..fb110595c4 100644 --- a/apps/web/tests/composer-focus.e2e.ts +++ b/apps/web/tests/composer-focus.e2e.ts @@ -55,21 +55,25 @@ async function exerciseKeyboardViewport(page: Page): Promise { const scroll = window.scrollY const offset = Object.getOwnPropertyDescriptor(viewport, 'offsetTop') style.setProperty('height', `${window.innerHeight * 2}px`) - window.scrollTo(0, window.innerHeight) + const input = document.querySelector('[data-composer-input]')! + window.scrollTo(0, input.getBoundingClientRect().top + scroll - window.innerHeight / 4) // Safari can report the keyboard's page displacement as offsetTop even // though DOM rectangles already account for that page scroll. Object.defineProperty(viewport, 'offsetTop', { configurable: true, get: () => window.scrollY }) + window.dispatchEvent(new Event('scroll')) return () => { if (offset === undefined) Reflect.deleteProperty(viewport, 'offsetTop') else Object.defineProperty(viewport, 'offsetTop', offset) if (height === '') style.removeProperty('height') else style.setProperty('height', height, priority) window.scrollTo(0, scroll) + window.dispatchEvent(new Event('scroll')) } }) try { const before = await input.evaluate(el => ({ top: el.getBoundingClientRect().top, scroll: window.scrollY })) expect(before.scroll).toBeGreaterThan(0) + expect(before.top).toBeGreaterThanOrEqual(0) await page.keyboard.insertText('z') const after = await input.evaluate(el => new Promise<{ top: number; scroll: number }>((resolve) => { requestAnimationFrame(() => requestAnimationFrame(() => { diff --git a/apps/web/tests/default-model.e2e.ts b/apps/web/tests/default-model.e2e.ts index c1fee1e87a..5fd4cab81f 100644 --- a/apps/web/tests/default-model.e2e.ts +++ b/apps/web/tests/default-model.e2e.ts @@ -201,10 +201,12 @@ describe('web e2e: the composer model switch is the default for later sessions', it.each([ { device: 'iPhone', userAgent: 'Mozilla/5.0 (iPhone; CPU iPhone OS 18_6 like Mac OS X) AppleWebKit/605.1.15 Version/18.6 Mobile/15E148 Safari/604.1', automatic: false }, + { device: 'Android Chrome', userAgent: 'Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 Chrome/119.0.0.0 Mobile Safari/537.36', automatic: false }, + { device: 'iPhone Chrome', userAgent: 'Mozilla/5.0 (iPhone; CPU iPhone OS 18_6 like Mac OS X) AppleWebKit/605.1.15 CriOS/139.0.0.0 Mobile/15E148 Safari/604.1', automatic: false }, { device: 'narrow desktop', userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 Version/18.6 Safari/605.1.15', automatic: true }, - ])('respects $device search focus when opening /model', async ({ userAgent, automatic }) => { + ])('respects $device viewport and search focus when opening /model', async ({ userAgent, automatic }) => { const context = await browser.newContext({ - userAgent, viewport: { width: 390, height: 844 }, locale: ZH_BROWSER_LOCALE, + userAgent, viewport: { width: 390, height: 844 }, locale: ZH_BROWSER_LOCALE, hasTouch: !automatic, }) try { const devicePage = await context.newPage() @@ -213,14 +215,19 @@ describe('web e2e: the composer model switch is the default for later sessions', await devicePage.getByRole('textbox', { name: '选择工作区' }).click() const composer = devicePage.locator('[data-composer-input][contenteditable="true"]').first() await composer.waitFor() + expect(await composer.evaluate(element => getComputedStyle(element).fontSize)).toBe(automatic ? '14px' : '16px') await composer.fill('/model') await devicePage.getByRole('option', { name: /^模型/ }).click() const search = devicePage.getByRole('textbox', { name: '筛选选项', exact: true }) await search.waitFor() await devicePage.getByRole('option', { name: /Origin Large/ }).waitFor() + expect(await devicePage.locator('meta[name="viewport"]').getAttribute('content')).toBe( + 'width=device-width, initial-scale=1, viewport-fit=cover', + ) expect(await search.evaluate(input => document.activeElement === input)).toBe(automatic) await search.click() expect(await search.evaluate(input => document.activeElement === input)).toBe(true) + expect(await devicePage.evaluate(() => window.visualViewport?.scale)).toBe(1) await search.fill('Origin') await devicePage.getByRole('option', { name: /Origin Large/ }).waitFor() expect(await devicePage.getByRole('option', { name: /Acme/ }).count()).toBe(0) diff --git a/packages/client/ui-conversation/README.i18n.yaml b/packages/client/ui-conversation/README.i18n.yaml index 681f796105..aedfa270e2 100644 --- a/packages/client/ui-conversation/README.i18n.yaml +++ b/packages/client/ui-conversation/README.i18n.yaml @@ -21,8 +21,8 @@ en: 9912b286384c41d7 zh: 3e994887c1948677 /deepseek-ai-dsh-client-ui-conversation/shell-and-standard-props: - en: 6cbb0800f2db9220 - zh: 405701def5431492 + en: 9379a248ebd47974 + zh: 584bc4eaa7fa73fd /deepseek-ai-dsh-client-ui-conversation/temporary-composer-entries: en: bb1244310f5c0382 zh: 824b84077432b559 diff --git a/packages/client/ui-conversation/README.md b/packages/client/ui-conversation/README.md index f15bb0e7a3..5bad942451 100644 --- a/packages/client/ui-conversation/README.md +++ b/packages/client/ui-conversation/README.md @@ -64,6 +64,8 @@ Queue previews enable whitespace collapsing and document-edge trimming, retain e The shared image slot props keep display choices separate from durable references: `thumbnail` requests a contained attachment-list thumbnail, while `compact` requests a cropped gallery tile. An optional per-image `label` supplies the accessible display name; loading and cache identity still use the original attachment reference. `MessageImagesContentInput` adds optional complete `MessageImageLabels` for the root-scoped `conversation.images.content` Factory. Message, tool, and Factory inputs carry the view's authorized `loadImage` callback explicitly; loading and URL caching remain with the resource owner. [ui-attachment](../ui-attachment/README.md) provides this Factory and owns rendering and the lightbox. +The composer uses a minimum 16px draft font on coarse-pointer devices to avoid focus-triggered browser zoom; larger font preferences still apply. + The composer measures its expanded control groups after size, content, visibility, or font-loading changes. If they cannot share a line, the row sets `--dsh-composer-model-text-display: none` and `--dsh-composer-model-icon-display: block` for the model seat; their defaults are `block` and `none`. Wrapping remains available if even the icon cannot fit. The context meter follows the [statistics-control radius](../../../docs/ui-radius.md#radius-scale). diff --git a/packages/client/ui-conversation/README.zh.md b/packages/client/ui-conversation/README.zh.md index 76a0b25ca4..d756b06020 100644 --- a/packages/client/ui-conversation/README.zh.md +++ b/packages/client/ui-conversation/README.zh.md @@ -64,6 +64,8 @@ Queue 预览启用空白折叠和文档边缘 trim,保留 emoji,并使用 CS 共享图片插槽属性将展示选择与持久化引用分开:`thumbnail` 请求完整缩放的附件列表缩略图,`compact` 请求裁剪的图片方块。每张图片可通过可选的 `label` 提供无障碍展示名称;加载和缓存标识仍使用原始附件引用。`MessageImagesContentInput` 为 root 作用域的 `conversation.images.content` Factory 增加可选的完整 `MessageImageLabels`。消息、工具及 Factory 输入显式携带视图提供的授权 `loadImage` 回调;读取和 URL 缓存仍由资源所有者负责。[ui-attachment](../ui-attachment/README.zh.md) 提供该 Factory,负责渲染与灯箱。 +在粗指针设备上,composer 的草稿字号至少为 16px,以避免获得焦点时浏览器自动放大;更大的字号偏好仍然生效。 + 控件组的尺寸、内容、可见性或字体加载状态变化后,composer 测量展开状态下的控件组。若无法排在同一行,控制栏为模型位设置 `--dsh-composer-model-text-display: none` 和 `--dsh-composer-model-icon-display: block`;两者默认值分别为 `block` 和 `none`。若连图标也放不下,仍允许换行。 上下文占用率入口遵循[统计控件圆角规则](../../../docs/ui-radius.zh.md#radius-scale)。 diff --git a/packages/client/ui-conversation/src/client/input/editor/composer-editor.module.css b/packages/client/ui-conversation/src/client/input/editor/composer-editor.module.css index 3d153065b4..c1b1cae009 100644 --- a/packages/client/ui-conversation/src/client/input/editor/composer-editor.module.css +++ b/packages/client/ui-conversation/src/client/input/editor/composer-editor.module.css @@ -10,8 +10,10 @@ -webkit-box-decoration-break: clone; } -.reference:hover { - background: var(--dsw-alias-state-business-tertiary); +@media (hover: hover) { + .reference:hover { + background: var(--dsw-alias-state-business-tertiary); + } } .openable { diff --git a/packages/client/ui-conversation/src/client/skeleton/EmptyHero.tsx b/packages/client/ui-conversation/src/client/skeleton/EmptyHero.tsx index 40df87269b..b46db926da 100644 --- a/packages/client/ui-conversation/src/client/skeleton/EmptyHero.tsx +++ b/packages/client/ui-conversation/src/client/skeleton/EmptyHero.tsx @@ -138,12 +138,13 @@ export function HeroShell({ t, renderSlot, children }: HeroShellProps) { {/* figma 34:10412: fish 34×25 leading the headline, gap 10. */} { - if (window.matchMedia('(hover: hover) and (prefers-reduced-motion: no-preference)').matches) { + onPointerEnter={(event) => { + if (event.pointerType !== 'touch' + && window.matchMedia('(hover: hover) and (prefers-reduced-motion: no-preference)').matches) { setHovering(true) } }} - onMouseLeave={() => { setHovering(false) }} + onPointerLeave={() => { setHovering(false) }} > {renderSlot('conversation.hero.brand.mark', { size: 34, className: css.fish }, { fallback: , diff --git a/packages/client/ui-conversation/src/client/skeleton/InputBar.module.css b/packages/client/ui-conversation/src/client/skeleton/InputBar.module.css index 123a0fcbea..67ad49f958 100644 --- a/packages/client/ui-conversation/src/client/skeleton/InputBar.module.css +++ b/packages/client/ui-conversation/src/client/skeleton/InputBar.module.css @@ -76,6 +76,12 @@ --dsh-scrollbar-thumb-hover: var(--dsw-alias-scrollbar-hover-l2); } +@media (pointer: coarse) { + .card { + font-size: max(16px, var(--dsh-content-font-size, 14px)); + } +} + /* No-workspace trigger state: an inset 1px dashed outline marks the card as a workspace picker rather than a live composer. Keeping the complete stroke inside the rounded box prevents clipped corner pixels from reading heavier. */ @@ -103,8 +109,10 @@ pointer-events: none; } -.cardWorkspaceTrigger:hover::after { - color: var(--dsw-alias-state-business-primary); +@media (hover: hover) { + .cardWorkspaceTrigger:hover::after { + color: var(--dsw-alias-state-business-primary); + } } .accessory { @@ -330,8 +338,10 @@ cursor: pointer; } -.add:hover:not(:disabled) { - background: var(--dsw-alias-interactive-bg-hover-solid); +@media (hover: hover) { + .add:hover:not(:disabled) { + background: var(--dsw-alias-interactive-bg-hover-solid); + } } .add:disabled { @@ -362,8 +372,10 @@ appearance: none; } -.select:hover:not(:disabled) { - background-color: var(--dsw-alias-interactive-bg-hover); +@media (hover: hover) { + .select:hover:not(:disabled) { + background-color: var(--dsw-alias-interactive-bg-hover); + } } .select:disabled { @@ -395,8 +407,10 @@ transform: translateY(-2px); } -.primary:hover:not(:disabled) { - background: var(--dsw-alias-button-info-hover); +@media (hover: hover) { + .primary:hover:not(:disabled) { + background: var(--dsw-alias-button-info-hover); + } } .primary:disabled { diff --git a/packages/client/ui-conversation/tests/editor-viewport.client.spec.ts b/packages/client/ui-conversation/tests/editor-viewport.client.spec.ts index 3a430024d6..42f9a51e85 100644 --- a/packages/client/ui-conversation/tests/editor-viewport.client.spec.ts +++ b/packages/client/ui-conversation/tests/editor-viewport.client.spec.ts @@ -23,7 +23,7 @@ function fixture(viewport: { height: number; offsetTop: number; pageTop: number document.body.append(root) const runtime: DraftEditorRuntime = new DraftEditorRuntime({ onUpdate: () => { runtime.refreshProjection() }, - openReference: () => false, activeClaimToken: () => null, + openReference: () => false, lexicon: () => new Map(), resolveLexicon: () => undefined, }) const dispose = runtime.register() diff --git a/packages/client/ui-primitives/tests/atoms.client.spec.tsx b/packages/client/ui-primitives/tests/atoms.client.spec.tsx index bc48ea0d38..44f56b97ca 100644 --- a/packages/client/ui-primitives/tests/atoms.client.spec.tsx +++ b/packages/client/ui-primitives/tests/atoms.client.spec.tsx @@ -4,9 +4,20 @@ import { act, cleanup, fireEvent, render, screen } from '@testing-library/react' import { afterEach, describe, expect, it, vi } from 'vitest' import { Button, ConnectionIndicator, Input, Menu, MenuItemButton, Modal, Pill } from '@deepseek-ai/dsh-client-ui-primitives' import { POINTER_GRACE_MS } from '../src/pointer-grace.ts' +import { focusWithoutRing } from '../src/focus.ts' afterEach(cleanup) +it('retains automatic focus styling while typing and restores it for keyboard navigation', () => { + render() + const button = screen.getByRole('button') + focusWithoutRing(button) + fireEvent.keyDown(button, { key: 'a' }) + expect(button.hasAttribute('data-dsh-automatic-focus')).toBe(true) + fireEvent.keyDown(button, { key: 'ArrowDown' }) + expect(button.hasAttribute('data-dsh-automatic-focus')).toBe(false) +}) + describe('Button', () => { it('exposes its native button for focus and releases the ref on unmount', () => { const ref = createRef() diff --git a/packages/client/web/README.i18n.yaml b/packages/client/web/README.i18n.yaml index bd0e87b2db..2fa9af0ee2 100644 --- a/packages/client/web/README.i18n.yaml +++ b/packages/client/web/README.i18n.yaml @@ -15,8 +15,11 @@ en: d152484eb41ac6b4 zh: 09388d293f9be9cb /deepseek-ai-dsh-client-web/use-this-package: - en: 3105391bad2e9f06 - zh: fe0c5af5db6c241c + en: 5dba7f9e0c6a94c8 + zh: f160f806c487337b +/deepseek-ai-dsh-client-web/use-this-package/viewport-sizing: + en: 8c0b533d25f077ce + zh: 0cf0b6ae1b23f344 /deepseek-ai-dsh-client-web/use-this-package/what-boot-looks-like: en: f3b01aa878764e5c zh: f02eab65d441bfe0 diff --git a/packages/client/web/README.md b/packages/client/web/README.md index 93f6bb9529..36cf3a9556 100644 --- a/packages/client/web/README.md +++ b/packages/client/web/README.md @@ -31,8 +31,19 @@ Static application pages install `__DSH_BOOT_READY__` before the entry runs. The The shell base styles apply automatic CJK/Latin spacing to ordinary content in supporting browsers. Semantic code and terminal, diff, read, and search output containers retain literal source spacing and column alignment; browsers without `text-autospace` support ignore both declarations. +The shell sets text-size adjustment to 100%, so mobile browsers render configured font sizes without automatically enlarging text after viewport changes. Application font-size preferences still apply. + Web and Desktop mathematical rendering requires WOFF2 support. The [Web build](../../../apps/web/katex-fonts.ts) retains every KaTeX font face in WOFF2 and omits WOFF/TTF fallbacks; a face without WOFF2 rejects the build. Font glyphs, weights, styles, and layout rules are preserved. + +### Viewport sizing + +The root fills the CSS layout viewport with absolute positioning. Opening the keyboard retains the application's layout height, so the homepage and navigation drawer do not resize with the keyboard. The browser pans the page to reveal focused inputs; inner panes own content scrolling. + +The root applies horizontal safe-area padding and publishes `--dsh-safe-area-top` and `--dsh-safe-area-bottom` for frame content padding. + +The [Web application entry](../../../apps/web/index.html) declares `width=device-width, initial-scale=1, viewport-fit=cover` without limiting user zoom. Touch inputs use a minimum font size of 16px to avoid focus-triggered page enlargement. + ### What boot looks like Boot runs in two stages: the module stage adopts the parser-loaded bootstrap batch, builds the module system from the Host-provided boot graph, and prefetches the `immediately` tier through the shared application-batch URL, which executes once. The plugin stage then activates every graph entry and waits for all of them before handing the marked boot DOM to the UI renderer, which hydrates it and switches to the complete UI. diff --git a/packages/client/web/README.zh.md b/packages/client/web/README.zh.md index c913362067..ffb8756129 100644 --- a/packages/client/web/README.zh.md +++ b/packages/client/web/README.zh.md @@ -31,8 +31,19 @@ kind: "package-library" 外壳基础样式会在支持的浏览器中为普通内容自动添加中西文间距。语义化代码以及终端、diff、读取和搜索输出容器会保留源码中的原始间距和列对齐;不支持 `text-autospace` 的浏览器会忽略这两项声明。 +外壳将文字尺寸调整比例设为 100%,让移动浏览器按配置的字号渲染文字,避免视口变化后自动放大。应用内的字号偏好仍然生效。 + Web 和 Desktop 的数学公式渲染要求支持 WOFF2。[Web 构建](../../../apps/web/katex-fonts.ts)以 WOFF2 保留全部 KaTeX 字体样式,并排除 WOFF/TTF 后备格式;任一字体样式缺少 WOFF2 都会使构建失败。字体的字形、字重、样式和布局规则保持不变。 + +### 视口尺寸 + +根容器通过绝对定位铺满 CSS 布局视口。键盘抬起时,应用保留原有布局高度,首页和导航抽屉不会随键盘缩放。浏览器平移页面以露出获得焦点的输入框,内容滚动由内部面板负责。 + +根容器应用左右安全区边距,并发布 `--dsh-safe-area-top` 和 `--dsh-safe-area-bottom`,供框架为内容保留上下边距。 + +[Web 应用入口](../../../apps/web/index.html)声明 `width=device-width, initial-scale=1, viewport-fit=cover`,不限制用户缩放。触摸输入框使用至少 16px 的字号,避免获得焦点时自动放大页面。 + ### 启动过程是怎样的 启动分两个阶段:模块阶段接纳 parser 已加载的 bootstrap 批次,从 Host 提供的启动图构建模块系统,并通过只执行一次的共享 application 批次 URL 预取 `immediately` 层级。插件阶段随后激活每个图 entry 并等待全部就绪,之后才把带标记的启动 DOM 交给 UI 渲染器,由它 hydrate 并切换到完整 UI。 diff --git a/packages/client/web/src/base.css b/packages/client/web/src/base.css index af74988cf1..3cb02ff38c 100644 --- a/packages/client/web/src/base.css +++ b/packages/client/web/src/base.css @@ -8,6 +8,30 @@ body, margin: 0; } +html, +body { + overflow: hidden; +} + +html { + -webkit-text-size-adjust: 100%; + text-size-adjust: 100%; +} + +/* Inner panes own scrolling. The browser pans focused inputs without resizing + the application or recentering its content when the keyboard opens. */ +#root { + --dsh-safe-area-top: env(safe-area-inset-top, 0px); + --dsh-safe-area-bottom: env(safe-area-inset-bottom, 0px); + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + box-sizing: border-box; + padding-inline: env(safe-area-inset-left, 0px) env(safe-area-inset-right, 0px); +} + body { font-family: var( --dsw-font-family, From 4995b2a11d1742386da59f5147deac154d9b9750 Mon Sep 17 00:00:00 2001 From: Stevring Date: Tue, 20 Oct 2026 12:56:25 +0800 Subject: [PATCH 06/12] test(web): align mobile dependency notices and font regression --- THIRD_PARTY_NOTICES.md | 1 - apps/web/tests/markdown-cjk-strong.e2e.ts | 30 +++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/THIRD_PARTY_NOTICES.md b/THIRD_PARTY_NOTICES.md index b4da211246..8a1395a20b 100644 --- a/THIRD_PARTY_NOTICES.md +++ b/THIRD_PARTY_NOTICES.md @@ -41,7 +41,6 @@ External packages installed for runtime use or embedded in distributed Host or b | [`@earendil-works/pi-ai`](https://github.com/earendil-works/pi) | MIT | | [`@earendil-works/pi-coding-agent`](https://github.com/earendil-works/pi) | MIT | | [`@eslint-community/regexpp`](https://github.com/eslint-community/regexpp) | MIT | -| [`@floating-ui/dom`](https://github.com/floating-ui/floating-ui) | MIT | | [`@fortune-sheet/core`](https://github.com/ruilisi/fortune-sheet) | MIT | | [`@fortune-sheet/react`](https://github.com/ruilisi/fortune-sheet) | MIT | | [`@joplin/turndown-plugin-gfm`](https://github.com/laurent22/joplin-turndown-plugin-gfm) | MIT | diff --git a/apps/web/tests/markdown-cjk-strong.e2e.ts b/apps/web/tests/markdown-cjk-strong.e2e.ts index 4d9594d771..411d3ea2c5 100644 --- a/apps/web/tests/markdown-cjk-strong.e2e.ts +++ b/apps/web/tests/markdown-cjk-strong.e2e.ts @@ -125,6 +125,36 @@ describe('web e2e: CJK-adjacent Markdown strong emphasis', () => { expect(await page.getByText(paragraph, { exact: true }).count()).toBe(1) } + const viewport = page.viewportSize()! + try { + for (const size of [{ width: 390, height: 844 }, { width: 951, height: 589 }, { width: 669, height: 951 }]) { + await page.setViewportSize(size) + expect(await page.evaluate(() => getComputedStyle(document.documentElement).getPropertyValue('-webkit-text-size-adjust'))) + .toBe('100%') + expect(await strong.evaluateAll(elements => elements.map(el => getComputedStyle(el).fontSize))) + .toEqual(CASES.map(() => '14px')) + } + const restoreFont = await page.evaluateHandle(() => { + const style = document.body.style + const before = style.getPropertyValue('--dsh-content-font-size') + const priority = style.getPropertyPriority('--dsh-content-font-size') + style.setProperty('--dsh-content-font-size', '18px') + return () => { + if (before) style.setProperty('--dsh-content-font-size', before, priority) + else style.removeProperty('--dsh-content-font-size') + } + }) + try { + expect(await strong.evaluateAll(elements => elements.map(el => getComputedStyle(el).fontSize))) + .toEqual(CASES.map(() => '18px')) + } finally { + await restoreFont.evaluate((restore) => { restore() }) + await restoreFont.dispose() + } + } finally { + await page.setViewportSize(viewport) + } + const snapshot = (await captureStableAria(page, '[class*="centerCol"]', scaffold.workspaceCwd)) .split(SEED_ID).join('{{seededId}}') await compareOrRefreshGolden(UI_EXPECTED, snapshot, MODE) From 6fbd06d845a8987c080daa321313477d9e0f35e9 Mon Sep 17 00:00:00 2001 From: Stevring Date: Tue, 20 Oct 2026 14:48:20 +0800 Subject: [PATCH 07/12] fix(client): preserve mobile model menu keyboard focus --- apps/web/tests/default-model.e2e.ts | 57 +++++++++++++++++ .../default-model/mobile-keyboard.expected.md | 5 ++ .../ui-model-selection/README.i18n.yaml | 8 +-- packages/client/ui-model-selection/README.md | 6 +- .../client/ui-model-selection/README.zh.md | 6 +- .../src/client/ModelSelect.tsx | 10 +-- .../tests/model-select.client.spec.tsx | 61 +++++++++++++++++++ 7 files changed, 138 insertions(+), 15 deletions(-) create mode 100644 apps/web/tests/expected/default-model/mobile-keyboard.expected.md diff --git a/apps/web/tests/default-model.e2e.ts b/apps/web/tests/default-model.e2e.ts index 5fd4cab81f..6fe67adfcd 100644 --- a/apps/web/tests/default-model.e2e.ts +++ b/apps/web/tests/default-model.e2e.ts @@ -239,6 +239,63 @@ describe('web e2e: the composer model switch is the default for later sessions', } }) + it.each([ + { device: 'iPhone', userAgent: 'Mozilla/5.0 (iPhone; CPU iPhone OS 18_6 like Mac OS X) AppleWebKit/605.1.15 Version/18.6 Mobile/15E148 Safari/604.1', platform: 'iPhone' }, + { device: 'desktop-mode iPad', userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 Version/18.6 Safari/605.1.15', platform: 'MacIntel' }, + ])('retains model menu keyboard focus on $device', async ({ userAgent, platform }) => { + const context = await browser.newContext({ + userAgent, viewport: { width: 390, height: 844 }, locale: ZH_BROWSER_LOCALE, hasTouch: true, + }) + try { + await context.addInitScript(({ platform }) => { + Object.defineProperty(navigator, 'platform', { configurable: true, value: platform }) + Object.defineProperty(navigator, 'maxTouchPoints', { configurable: true, value: 5 }) + }, { platform }) + const devicePage = await context.newPage() + const consoleWatch = watchConsole(devicePage) + await devicePage.goto(scaffold.authenticatedUrl, { waitUntil: 'load' }) + await devicePage.getByRole('textbox', { name: '选择工作区' }).click() + const trigger = devicePage.getByRole('button', { name: /^选择模型/ }) + const observations: string[] = [] + const observeFocus = async (action: string): Promise => { + const focused = await devicePage.evaluate(() => { + const element = document.activeElement! + const role = element.getAttribute('role') ?? element.tagName.toLowerCase() + const label = element.getAttribute('aria-label') ?? element.textContent?.replace(/\s+/g, ' ').trim() + return `${role}: ${label}` + }) + observations.push(`${action}: ${focused}`) + } + await trigger.click() + await expect.poll(() => trigger.evaluate(element => document.activeElement === element)).toBe(true) + await observeFocus('Open') + await devicePage.keyboard.press('ArrowDown') + await devicePage.keyboard.press('Enter') + const model = devicePage.getByRole('menuitemradio', { name: 'Origin Large', exact: true }) + await expect.poll(() => model.evaluate(element => document.activeElement === element)).toBe(true) + await observeFocus('Enter model pane') + await devicePage.keyboard.press('ArrowDown') + const search = devicePage.getByRole('searchbox', { name: '搜索模型…' }) + await expect.poll(() => search.evaluate(element => document.activeElement === element)).toBe(true) + await observeFocus('Navigate models') + await devicePage.keyboard.press('Escape') + const modelCell = devicePage.getByRole('menuitem', { name: /^模型/ }) + await expect.poll(() => modelCell.evaluate(element => document.activeElement === element)).toBe(true) + await observeFocus('Return to root') + await devicePage.keyboard.press('Escape') + await expect.poll(() => trigger.evaluate(element => document.activeElement === element)).toBe(true) + await observeFocus('Close') + expect(await trigger.getAttribute('aria-expanded')).toBe('false') + expect(consoleWatch.pageErrors).toEqual([]) + await compareOrRefreshGolden( + fileURLToPath(new URL('./expected/default-model/mobile-keyboard.expected.md', import.meta.url)), + observations.join('\n'), webSnapshotMode(), + ) + } finally { + await context.close() + } + }) + it('shares provider order, fuzzy result order and sticky header material between both model pickers', async () => { const readGroups = (surface: Locator, role: 'option' | 'menuitemradio') => surface.locator('[data-menu-group]') .evaluateAll((groups, rowRole) => groups.map(group => ({ diff --git a/apps/web/tests/expected/default-model/mobile-keyboard.expected.md b/apps/web/tests/expected/default-model/mobile-keyboard.expected.md new file mode 100644 index 0000000000..74b05a3ce9 --- /dev/null +++ b/apps/web/tests/expected/default-model/mobile-keyboard.expected.md @@ -0,0 +1,5 @@ +Open: button: 选择模型,当前 Origin Large +Enter model pane: menuitemradio: Origin Large +Navigate models: searchbox: 搜索模型… +Return to root: menuitem: 模型Origin Large +Close: button: 选择模型,当前 Origin Large diff --git a/packages/client/ui-model-selection/README.i18n.yaml b/packages/client/ui-model-selection/README.i18n.yaml index 342d716d15..177bc09fb2 100644 --- a/packages/client/ui-model-selection/README.i18n.yaml +++ b/packages/client/ui-model-selection/README.i18n.yaml @@ -15,11 +15,11 @@ en: d152484eb41ac6b4 zh: 09388d293f9be9cb /deepseek-ai-dsh-client-ui-model-selection/use-this-package: - en: 7abb4deba3173c9c - zh: b76beffb3d9363db + en: 9b1eca0aec81ac29 + zh: 9a1599c3abf76513 /deepseek-ai-dsh-client-ui-model-selection/use-this-package/model-and-effort: - en: 317641f416ba20c2 - zh: 4fe5bd48d24363e3 + en: 2e6d9965e01dc0ce + zh: 332cc82233eb02f3 /deepseek-ai-dsh-client-ui-model-selection/use-this-package/model-label-extensions: en: bc47871cf8b61451 zh: 17d21da46604f071 diff --git a/packages/client/ui-model-selection/README.md b/packages/client/ui-model-selection/README.md index 79fb8a2d5e..b2c809123f 100644 --- a/packages/client/ui-model-selection/README.md +++ b/packages/client/ui-model-selection/README.md @@ -31,13 +31,13 @@ DeepSeek account and API-key routes appear as separate provider groups, each exp When no model is selected or the saved selection is absent from the catalog, the composer shows “Select model” in regular weight and hides the reasoning effort caption. Clicking it opens the model list directly; Escape and Shift+Tab close it. An empty catalog displays “No models available.” -Mount this plugin alongside `ui-conversation` and the commands package; the composer then shows the model seat next to the pending indicator, and `/model` opens the same directory as a popup. While the seat's menu is open, `↑`/`↓` move focus through root and effort rows, or move the model-list highlight without leaving search. Enter and Tab settle the highlighted model or focused row; Escape and `Shift+Tab` leave a drilled pane first and otherwise close back to the trigger. On desktop devices, drilling focuses model search when shown, otherwise the current model or effort row, and going back focuses the cell that opened the pane. Mobile devices do not automatically focus the trigger or pane when opening or navigating the menu; tapping search or using keyboard navigation can focus search explicitly. The composer shows the catalog name while the selected model is available. Removing a model or provider, including account sign-out, preserves the stored provider, model, and reasoning effort without displaying their IDs. Restoring the catalog entry restores its name and effort caption. +Mount this plugin alongside `ui-conversation` and the commands package; the composer then shows the model seat next to the pending indicator, and `/model` opens the same directory as a popup. While the seat's menu is open, `↑`/`↓` move focus through root and effort rows, or move the model-list highlight without leaving search. Enter and Tab settle the highlighted model or focused row; Escape and `Shift+Tab` leave a drilled pane first and otherwise close back to the trigger. Drilling focuses model search when shown on desktop devices; otherwise it focuses the current model or effort row, or the first enabled row when none is selected. Going back focuses the cell that opened the pane. Phones and tablets leave search unfocused until the user taps it or uses keyboard navigation. The composer shows the catalog name while the selected model is available. Removing a model or provider, including account sign-out, preserves the stored provider, model, and reasoning effort without displaying their IDs. Restoring the catalog entry restores its name and effort caption. -Mouse selection uses native browser clicks, including their cancellation behavior; a press alone never selects. On desktop devices, opening the root menu focuses its trigger, and clicking the trigger again closes the menu and returns focus there. Root rows and the search-clear button show the same fill for keyboard focus and hover, without a native outline. Selecting a model or effort returns focus to the trigger without a focus ring; leaving the trigger or reopening the menu restores its normal focus indication. While a selection from either entry is pending, focus stays on the trigger, the trigger shows a spinner in place of its chevron, and each row whose value the selection carries shows one in place of its check; a rejected selection leaves the menu open. Tab returns to model search with the current model highlighted when search is shown, otherwise to the current row. +Mouse selection uses native browser clicks, including their cancellation behavior; a press alone never selects. Opening the root menu focuses its trigger, and clicking the trigger again closes the menu and returns focus there. Root rows and the search-clear button show the same fill for keyboard focus and hover, without a native outline. Selecting a model or effort returns focus to the trigger without a focus ring; leaving the trigger or reopening the menu restores its normal focus indication. While a selection from either entry is pending, focus stays on the trigger, the trigger shows a spinner in place of its chevron, and each row whose value the selection carries shows one in place of its check; a rejected selection leaves the menu open. Tab returns to model search with the current model highlighted when search is shown, otherwise to the current row. ### Model and effort -The button's model menu shows search only when its full catalog contains more than four models; smaller catalogs support keyboard navigation directly and automatically focus the current model or first row only on desktop devices. The `/model` command always keeps its search field. Both search fields match model names case-insensitively, including nonconsecutive characters in order; leading and trailing spaces are ignored. Within each provider, prefix matches come first, followed by alignment score and then catalog order. Empty groups are hidden. Empty catalogs and queries without matches are announced through a status region. Search keeps focus while arrow keys cycle the highlighted result across provider groups; Enter or Tab selects it. Left and right arrows keep their native caret behavior. Opening highlights the current model or the first available row, and editing the query resets the highlight to the first result. Reopening the model pane clears the query. +The button's model menu shows search only when its full catalog contains more than four models; smaller catalogs support keyboard navigation directly and focus the current model or first enabled row on all devices. The `/model` command always keeps its search field. Both search fields match model names case-insensitively, including nonconsecutive characters in order; leading and trailing spaces are ignored. Within each provider, prefix matches come first, followed by alignment score and then catalog order. Empty groups are hidden. Empty catalogs and queries without matches are announced through a status region. Search keeps focus while arrow keys cycle the highlighted result across provider groups; Enter or Tab selects it. Left and right arrows keep their native caret behavior. Opening highlights the current model or the first available row, and editing the query resets the highlight to the first result. Reopening the model pane clears the query. Model and reasoning-effort names use weight 400 (regular) in the composer menu, including the selected item. The search field follows the command popup's compact treatment with transparent background and border in both palettes, with no leading icon and a caption-tone placeholder. The clear button appears for a nonempty query and restores the full list with focus in the search field. diff --git a/packages/client/ui-model-selection/README.zh.md b/packages/client/ui-model-selection/README.zh.md index e327d2e02a..e99a1e05ce 100644 --- a/packages/client/ui-model-selection/README.zh.md +++ b/packages/client/ui-model-selection/README.zh.md @@ -31,13 +31,13 @@ DeepSeek 账号和 API Key 路由显示为独立提供方分组,各自展示 未选择模型或已保存的选择不在目录中时,composer 以常规字重显示“请选择模型”,并隐藏推理强度文案。点击后直接打开模型列表,Escape 和 Shift+Tab 关闭列表。目录为空时显示“暂无可用模型” -与 `ui-conversation` 及命令包一起挂载本插件;composer 随即在待处理指示器旁显示模型位,`/model` 则以弹窗打开同一份目录。模型位菜单打开期间,`↑`/`↓` 在根菜单和推理等级行间移动焦点,或在模型列表中移动高亮并让焦点保留在搜索框。Enter 和 Tab 选定高亮模型或聚焦行;Escape 与 `Shift+Tab` 先退出已下钻的面板,否则关闭并回到触发器。在桌面设备上,下钻时若显示模型搜索框则聚焦搜索框,否则聚焦当前模型或推理强度行,返回则聚焦打开该面板的格子。移动设备在打开菜单或切换面板时不会自动聚焦触发按钮或面板;主动点按搜索框或使用键盘导航可以聚焦搜索框。所选模型可用时,composer 显示目录中的模型名称。模型或提供方被删除时(包括账号退登),保留已保存的提供方、模型和推理强度,但不展示其 ID。目录条目恢复后重新显示名称和推理强度。 +与 `ui-conversation` 及命令包一起挂载本插件;composer 随即在待处理指示器旁显示模型位,`/model` 则以弹窗打开同一份目录。模型位菜单打开期间,`↑`/`↓` 在根菜单和推理等级行间移动焦点,或在模型列表中移动高亮并让焦点保留在搜索框。Enter 和 Tab 选定高亮模型或聚焦行;Escape 与 `Shift+Tab` 先退出已下钻的面板,否则关闭并回到触发器。下钻时,桌面设备在显示模型搜索框时聚焦搜索框;其他情况聚焦当前模型或推理强度行,没有选中项时聚焦首个可用行。返回时聚焦打开该面板的格子。手机和平板在用户主动点按搜索框或使用键盘导航前,不会聚焦搜索框。所选模型可用时,composer 显示目录中的模型名称。模型或提供方被删除时(包括账号退登),保留已保存的提供方、模型和推理强度,但不展示其 ID。目录条目恢复后重新显示名称和推理强度。 -鼠标选择沿用浏览器原生点击及其取消行为;仅按下按钮不会选定。在桌面设备上,打开根菜单时聚焦触发按钮,再次点击触发按钮会关闭菜单并把焦点还给它。根菜单行和搜索清除按钮的键盘焦点与悬停使用相同底色,不显示原生焦点轮廓。选定模型或推理等级后,焦点返回触发按钮但不显示焦点环;焦点离开按钮或重新打开菜单后恢复正常焦点提示。等待任一入口发起的选择结果时,焦点停在触发按钮,触发按钮以加载图标代替下拉箭头,该选择包含的值所在行以加载图标代替勾选标记;选择被拒绝后菜单保持打开。显示模型搜索框时,Tab 返回搜索框并高亮当前模型,否则返回当前选中行。 +鼠标选择沿用浏览器原生点击及其取消行为;仅按下按钮不会选定。打开根菜单时聚焦触发按钮,再次点击触发按钮会关闭菜单并把焦点还给它。根菜单行和搜索清除按钮的键盘焦点与悬停使用相同底色,不显示原生焦点轮廓。选定模型或推理等级后,焦点返回触发按钮但不显示焦点环;焦点离开按钮或重新打开菜单后恢复正常焦点提示。等待任一入口发起的选择结果时,焦点停在触发按钮,触发按钮以加载图标代替下拉箭头,该选择包含的值所在行以加载图标代替勾选标记;选择被拒绝后菜单保持打开。显示模型搜索框时,Tab 返回搜索框并高亮当前模型,否则返回当前选中行。 ### 模型与推理强度 -按钮模型菜单仅在完整目录超过四个模型时显示搜索框;较小目录直接支持键盘导航,仅在桌面设备上自动聚焦当前模型或首行。`/model` 命令始终保留搜索框。两个搜索框均按模型名称进行不区分大小写的匹配,支持按顺序输入不连续字符,并忽略首尾空格。每个提供方内的结果优先按前缀匹配、其次按匹配得分、最后按目录顺序排列。没有匹配项的分组会隐藏。空目录和无匹配结果均通过状态区域通知屏幕阅读器。方向键在各提供方分组的结果间循环移动高亮,焦点保留在搜索框;Enter 或 Tab 选定高亮项。左右方向键仍用于移动输入光标。打开时高亮当前模型或首个可用选项,修改搜索内容后高亮首个结果。重新打开模型面板会清空搜索内容。 +按钮模型菜单仅在完整目录超过四个模型时显示搜索框;较小目录直接支持键盘导航,并在所有设备上聚焦当前模型或首个可用行。`/model` 命令始终保留搜索框。两个搜索框均按模型名称进行不区分大小写的匹配,支持按顺序输入不连续字符,并忽略首尾空格。每个提供方内的结果优先按前缀匹配、其次按匹配得分、最后按目录顺序排列。没有匹配项的分组会隐藏。空目录和无匹配结果均通过状态区域通知屏幕阅读器。方向键在各提供方分组的结果间循环移动高亮,焦点保留在搜索框;Enter 或 Tab 选定高亮项。左右方向键仍用于移动输入光标。打开时高亮当前模型或首个可用选项,修改搜索内容后高亮首个结果。重新打开模型面板会清空搜索内容。 composer 菜单中的模型名称和推理等级均使用 400(regular)字重,包括选中项。搜索框沿用 command 弹窗的紧凑样式,在浅/深色主题下均保持背景和边框透明,不显示前置图标,占位文字使用 caption 色。搜索内容非空时显示清除按钮;点击后恢复完整列表,并将焦点留在搜索框。 diff --git a/packages/client/ui-model-selection/src/client/ModelSelect.tsx b/packages/client/ui-model-selection/src/client/ModelSelect.tsx index cbdbe9dd48..59dbf85427 100644 --- a/packages/client/ui-model-selection/src/client/ModelSelect.tsx +++ b/packages/client/ui-model-selection/src/client/ModelSelect.tsx @@ -12,8 +12,8 @@ * search field. Provider headings paint their background only while pinned * by scrolling. Clearing a query restores the full list and search focus. * Selecting restores trigger focus without a ring until the trigger loses focus - * or the menu reopens. Mobile devices do not automatically focus the - * trigger or a pane when opening or drilling, so search does not raise the keyboard. + * or the menu reopens. Mobile devices restore button focus when opening or + * drilling; model search takes focus only after explicit user input. * Model names match a case-insensitive ordered subsequence * within each provider group, ranked by * prefix, alignment score, then catalog order. Returning to the root pane @@ -184,9 +184,9 @@ export function ModelSelect( previousShowSearch.current = showSearch const intent = paneFocus.current ?? (changedSearchMode && pane === 'model' ? 'drill' : null) paneFocus.current = null - if (!open || intent === null || isMobileDevice()) return + if (!open || intent === null) return if (intent === 'drill') { - if (pane === 'model' && showSearch) { + if (pane === 'model' && showSearch && !isMobileDevice()) { searchRef.current?.focus() return } @@ -251,7 +251,7 @@ export function ModelSelect( const show = (): void => { setSelectionFocus(false) - if (!isMobileDevice()) triggerRef.current?.focus() + triggerRef.current?.focus() setQuery('') setHighlightedIndex(null) if (currentChoice === undefined) paneFocus.current = 'drill' diff --git a/packages/client/ui-model-selection/tests/model-select.client.spec.tsx b/packages/client/ui-model-selection/tests/model-select.client.spec.tsx index 54c606f636..336c12c97d 100644 --- a/packages/client/ui-model-selection/tests/model-select.client.spec.tsx +++ b/packages/client/ui-model-selection/tests/model-select.client.spec.tsx @@ -457,6 +457,67 @@ describe('ModelSelect keyboard walk', () => { return select } + it.each([ + { device: 'iPhone', userAgent: 'Mozilla/5.0 (iPhone; CPU iPhone OS 18_6 like Mac OS X) AppleWebKit/605.1.15 Version/18.6 Mobile/15E148 Safari/604.1', platform: 'iPhone', maxTouchPoints: 5 }, + { device: 'desktop-mode iPad', userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 Version/18.6 Safari/605.1.15', platform: 'MacIntel', maxTouchPoints: 5 }, + ].flatMap(device => [1, 5].map(modelCount => ({ ...device, modelCount }))))( + 'retains menu keyboard focus on $device with $modelCount models without automatically focusing search', + async ({ userAgent, platform, maxTouchPoints, modelCount }) => { + for (const [name, value] of Object.entries({ userAgent, platform, maxTouchPoints })) { + const descriptor = Object.getOwnPropertyDescriptor(navigator, name) + Object.defineProperty(navigator, name, { configurable: true, value }) + onTestFinished(() => { + if (descriptor === undefined) Reflect.deleteProperty(navigator, name) + else Object.defineProperty(navigator, name, descriptor) + }) + } + const select = vi.fn() + render() + const trigger = screen.getByRole('button', { name: /选择模型/ }) + fireEvent.click(trigger) + expect(document.activeElement).toBe(trigger) + + const modelCell = screen.getByRole('menuitem', { name: /^模型/ }) + const effortCell = screen.getByRole('menuitem', { name: /推理等级/ }) + fireEvent.keyDown(trigger, { key: 'ArrowDown' }) + fireEvent.keyDown(modelCell, { key: 'ArrowDown' }) + expect(document.activeElement).toBe(effortCell) + fireEvent.keyDown(effortCell, { key: 'Tab' }) + const high = screen.getByRole('menuitemradio', { name: 'High' }) + const max = screen.getByRole('menuitemradio', { name: /Max/ }) + expect(document.activeElement).toBe(high) + fireEvent.keyDown(high, { key: 'ArrowDown' }) + expect(document.activeElement).toBe(max) + fireEvent.keyDown(max, { key: 'Escape' }) + + const restoredEffortCell = screen.getByRole('menuitem', { name: /推理等级/ }) + expect(document.activeElement).toBe(restoredEffortCell) + fireEvent.keyDown(restoredEffortCell, { key: 'ArrowUp' }) + const restoredModelCell = screen.getByRole('menuitem', { name: /^模型/ }) + expect(document.activeElement).toBe(restoredModelCell) + fireEvent.keyDown(restoredModelCell, { key: 'Tab' }) + const model = screen.getByRole('menuitemradio', { name: 'DeepSeek-V4-Flash' }) + expect(document.activeElement).toBe(model) + if (modelCount > 4) { + const search = screen.getByRole('searchbox') + expect(document.activeElement).not.toBe(search) + fireEvent.keyDown(model, { key: 'ArrowDown' }) + expect(document.activeElement).toBe(search) + } else { + expect(screen.queryByRole('searchbox')).toBeNull() + } + fireEvent.keyDown(document.activeElement!, { key: 'Escape' }) + expect(document.activeElement).toBe(screen.getByRole('menuitem', { name: /^模型/ })) + fireEvent.keyDown(document.activeElement!, { key: 'Escape' }) + expect(screen.queryByRole('menu')).toBeNull() + await waitFor(() => { expect(document.activeElement).toBe(trigger) }) + expect(select).not.toHaveBeenCalled() + }, + ) + it.each(['model', 'effort'])('prevents button mousedown defaults in the %s pane without selecting it', (pane) => { const select = mountOpen() const cell = screen.getByRole('menuitem', { name: pane === 'model' ? /^模型/ : /推理等级/ }) From d83d0a73309a4d4adc8053c10ff1242703fdaec7 Mon Sep 17 00:00:00 2001 From: Stevring Date: Tue, 20 Oct 2026 15:00:44 +0800 Subject: [PATCH 08/12] docs(web): remove unavailable navigation drawer claim --- packages/client/web/README.i18n.yaml | 4 ++-- packages/client/web/README.md | 2 +- packages/client/web/README.zh.md | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/client/web/README.i18n.yaml b/packages/client/web/README.i18n.yaml index 2fa9af0ee2..f33c8ad009 100644 --- a/packages/client/web/README.i18n.yaml +++ b/packages/client/web/README.i18n.yaml @@ -18,8 +18,8 @@ en: 5dba7f9e0c6a94c8 zh: f160f806c487337b /deepseek-ai-dsh-client-web/use-this-package/viewport-sizing: - en: 8c0b533d25f077ce - zh: 0cf0b6ae1b23f344 + en: c29bc7d1604312ce + zh: 833c2a24d9a445e7 /deepseek-ai-dsh-client-web/use-this-package/what-boot-looks-like: en: f3b01aa878764e5c zh: f02eab65d441bfe0 diff --git a/packages/client/web/README.md b/packages/client/web/README.md index 36cf3a9556..32ef1dd308 100644 --- a/packages/client/web/README.md +++ b/packages/client/web/README.md @@ -38,7 +38,7 @@ Web and Desktop mathematical rendering requires WOFF2 support. The [Web build](. ### Viewport sizing -The root fills the CSS layout viewport with absolute positioning. Opening the keyboard retains the application's layout height, so the homepage and navigation drawer do not resize with the keyboard. The browser pans the page to reveal focused inputs; inner panes own content scrolling. +The root fills the CSS layout viewport with absolute positioning. The browser pans the page to reveal focused inputs; inner panes own content scrolling. The root applies horizontal safe-area padding and publishes `--dsh-safe-area-top` and `--dsh-safe-area-bottom` for frame content padding. diff --git a/packages/client/web/README.zh.md b/packages/client/web/README.zh.md index ffb8756129..6eb646d441 100644 --- a/packages/client/web/README.zh.md +++ b/packages/client/web/README.zh.md @@ -38,7 +38,7 @@ Web 和 Desktop 的数学公式渲染要求支持 WOFF2。[Web 构建](../../../ ### 视口尺寸 -根容器通过绝对定位铺满 CSS 布局视口。键盘抬起时,应用保留原有布局高度,首页和导航抽屉不会随键盘缩放。浏览器平移页面以露出获得焦点的输入框,内容滚动由内部面板负责。 +根容器通过绝对定位铺满 CSS 布局视口。浏览器平移页面以露出获得焦点的输入框,内容滚动由内部面板负责。 根容器应用左右安全区边距,并发布 `--dsh-safe-area-top` 和 `--dsh-safe-area-bottom`,供框架为内容保留上下边距。 From 788c22d007f270a5e7d2dadefae56af2b353c383 Mon Sep 17 00:00:00 2001 From: Stevring Date: Tue, 20 Oct 2026 15:05:48 +0800 Subject: [PATCH 09/12] fix(client): retain composer position after mobile submission --- apps/web/tests/composer-focus.e2e.ts | 103 +++++++++++------- .../composer-focus/submission.expected.md | 7 +- .../client/ui-conversation/README.i18n.yaml | 4 +- packages/client/ui-conversation/README.md | 2 +- packages/client/ui-conversation/README.zh.md | 2 +- .../src/client/input/editor/view-binding.ts | 14 ++- .../src/client/skeleton/InputBar.tsx | 5 +- .../tests/editor-focus.client.spec.ts | 28 ++++- 8 files changed, 110 insertions(+), 55 deletions(-) diff --git a/apps/web/tests/composer-focus.e2e.ts b/apps/web/tests/composer-focus.e2e.ts index fb110595c4..111f219472 100644 --- a/apps/web/tests/composer-focus.e2e.ts +++ b/apps/web/tests/composer-focus.e2e.ts @@ -1,7 +1,7 @@ /** Browser selection and focus after presses in the composer's unused space. */ import { fileURLToPath } from 'node:url' import { join } from 'node:path' -import { chromium, type Page } from 'playwright' +import { chromium, webkit, type Page } from 'playwright' import { expect, it, onTestFailed, onTestFinished } from 'vitest' import { assertFixtureInventory, compareOrRefreshGolden, launchWebScaffold, seedSession, watchConsole, webSnapshotMode, @@ -208,52 +208,77 @@ it('restores the previous caret or selection in fresh and existing sessions', as expect(tripwire.pageErrors).toEqual([]) }, 180_000) -it('dismisses the mobile keyboard after Send while retaining desktop focus', async () => { - const browser = await chromium.launch() - onTestFinished(() => browser.close()) +it('keeps mobile submission keyboard navigation in the composer while retaining desktop focus', async () => { const observations: string[] = [] - for (const mobile of [false, true]) { + for (const { engine, mobile, submission } of [ + { engine: chromium, mobile: false, submission: 'Send' }, + { engine: chromium, mobile: true, submission: 'Send' }, + { engine: chromium, mobile: true, submission: 'Enter' }, + { engine: webkit, mobile: true, submission: 'Send' }, + { engine: webkit, mobile: true, submission: 'Enter' }, + ]) { const scaffold = await launchWebScaffold({ replayFixture: fileURLToPath(new URL('../../../snapshots/web/live-interactions/session.v3.jsonl', import.meta.url)), compareReplaySession: false, }) try { - const page = await browser.newPage({ - viewport: { width: mobile ? 390 : 1280, height: 844 }, - locale: 'en-US', timezoneId: 'Asia/Shanghai', - ...mobile ? { - userAgent: 'Mozilla/5.0 (iPhone; CPU iPhone OS 18_6 like Mac OS X) AppleWebKit/605.1.15 Version/18.6 Mobile/15E148 Safari/604.1', - isMobile: true, hasTouch: true, - } : {}, - }) - const tripwire = watchConsole(page) - const platform = mobile ? 'Mobile' : 'Desktop' - let finished = false - const off = scaffold.ctx.on('session/event', (_session, event) => { - if (event.type === 'turn/end') finished = true - }) + const browser = await engine.launch() try { - await page.goto(scaffold.authenticatedUrl) - await connectFreshWorkspace(page, scaffold.workspaceCwd, `submission-${platform}`) - const input = page.locator('[data-composer-input][contenteditable="true"]') - await input.fill('Reply with a one-sentence description of event sourcing, then stop.') - expect(await input.evaluate(element => document.activeElement === element)).toBe(true) - const send = page.getByRole('button', { name: 'Send message', exact: true }) - if (mobile) await send.tap() - else await send.click() - await expect.poll(() => input.textContent()).toBe('') - await expect.poll(() => input.evaluate(element => document.activeElement === element)).toBe(!mobile) - await expect.poll(() => finished, { timeout: 60_000 }).toBe(true) - expect(await input.evaluate(element => document.activeElement === element)).toBe(!mobile) - observations.push(`- ${platform}: Send clears the draft; editor ${mobile ? 'unfocused' : 'focused'} through response completion`) - expect(tripwire.pageErrors).toEqual([]) - if (webSnapshotMode() !== 'record') expect(tripwire.warnings).toEqual([]) - } catch (error) { - await saveFailureShot(page, `web-e2e-composer-submission-${platform}`) - throw error + const page = await browser.newPage({ + viewport: { width: mobile ? 390 : 1280, height: 844 }, + locale: 'en-US', timezoneId: 'Asia/Shanghai', + ...mobile ? { + userAgent: 'Mozilla/5.0 (iPhone; CPU iPhone OS 18_6 like Mac OS X) AppleWebKit/605.1.15 Version/18.6 Mobile/15E148 Safari/604.1', + isMobile: true, hasTouch: true, + } : {}, + }) + const tripwire = watchConsole(page) + const platform = `${engine.name()} ${mobile ? 'mobile' : 'desktop'} ${submission}` + let finished = false + const off = scaffold.ctx.on('session/event', (_session, event) => { + if (event.type === 'turn/end') finished = true + }) + try { + await page.goto(scaffold.authenticatedUrl) + await connectFreshWorkspace(page, scaffold.workspaceCwd, `submission-${platform}`) + const input = page.locator('[data-composer-input][contenteditable="true"]') + await input.fill('Reply with a one-sentence description of event sourcing, then stop.') + expect(await input.evaluate(element => document.activeElement === element)).toBe(true) + if (submission === 'Enter') await page.keyboard.press('Enter') + else { + const send = page.getByRole('button', { name: 'Send message', exact: true }) + if (mobile) await send.tap() + else await send.click() + } + await expect.poll(() => input.textContent()).toBe('') + await expect.poll(() => input.evaluate(element => document.activeElement === element)).toBe(!mobile) + await expect.poll(() => finished, { timeout: 60_000 }).toBe(true) + expect(await input.evaluate(element => document.activeElement === element)).toBe(!mobile) + if (mobile) { + const card = page.locator('[data-composer-card]') + expect(await card.evaluate(element => document.activeElement === element)).toBe(true) + // Option+Tab includes buttons in WebKit's keyboard navigation mode. + const next = engine === webkit ? 'Alt+Tab' : 'Tab' + await page.keyboard.press(next) + expect(await input.evaluate(element => document.activeElement === element)).toBe(true) + await page.keyboard.press(next) + const attachment = page.getByRole('button', { name: 'Add files or run commands', exact: true }) + expect(await attachment.evaluate(element => document.activeElement === element)).toBe(true) + observations.push(`- ${platform}: clears the draft; focus remains on the composer card through response completion, then advances to the editor and attachment button`) + } else { + observations.push(`- ${platform}: clears the draft; editor stays focused through response completion`) + } + expect(tripwire.pageErrors).toEqual([]) + if (webSnapshotMode() !== 'record') expect(tripwire.warnings).toEqual([]) + } catch (error) { + await saveFailureShot(page, `web-e2e-composer-submission-${platform}`) + throw error + } finally { + off() + await page.close() + } } finally { - off() - await page.close() + await browser.close() } } finally { await scaffold.close() diff --git a/apps/web/tests/expected/composer-focus/submission.expected.md b/apps/web/tests/expected/composer-focus/submission.expected.md index 4f711bfed1..dc724c194e 100644 --- a/apps/web/tests/expected/composer-focus/submission.expected.md +++ b/apps/web/tests/expected/composer-focus/submission.expected.md @@ -1,2 +1,5 @@ -- Desktop: Send clears the draft; editor focused through response completion -- Mobile: Send clears the draft; editor unfocused through response completion +- chromium desktop Send: clears the draft; editor stays focused through response completion +- chromium mobile Send: clears the draft; focus remains on the composer card through response completion, then advances to the editor and attachment button +- chromium mobile Enter: clears the draft; focus remains on the composer card through response completion, then advances to the editor and attachment button +- webkit mobile Send: clears the draft; focus remains on the composer card through response completion, then advances to the editor and attachment button +- webkit mobile Enter: clears the draft; focus remains on the composer card through response completion, then advances to the editor and attachment button diff --git a/packages/client/ui-conversation/README.i18n.yaml b/packages/client/ui-conversation/README.i18n.yaml index aedfa270e2..5c207603ba 100644 --- a/packages/client/ui-conversation/README.i18n.yaml +++ b/packages/client/ui-conversation/README.i18n.yaml @@ -21,8 +21,8 @@ en: 9912b286384c41d7 zh: 3e994887c1948677 /deepseek-ai-dsh-client-ui-conversation/shell-and-standard-props: - en: 9379a248ebd47974 - zh: 584bc4eaa7fa73fd + en: 6b5fc8c06d8f448c + zh: 975ef7abc829b54b /deepseek-ai-dsh-client-ui-conversation/temporary-composer-entries: en: bb1244310f5c0382 zh: 824b84077432b559 diff --git a/packages/client/ui-conversation/README.md b/packages/client/ui-conversation/README.md index 5bad942451..962f56b832 100644 --- a/packages/client/ui-conversation/README.md +++ b/packages/client/ui-conversation/README.md @@ -70,7 +70,7 @@ The composer measures its expanded control groups after size, content, visibilit The context meter follows the [statistics-control radius](../../../docs/ui-radius.md#radius-scale). -The composer uses the shared [text-input focus policy](../ui-primitives/README.md#use-this-package) on mount, Session switching, and unlock. Identified phones and tablets require tapping the input; desktop devices retain automatic focus. On these mobile devices, a submission that empties the draft dismisses the keyboard; rejected submissions and retained newer draft text preserve focus. The [Lexical patch](../../../patches/lexical@0.49.0.patch) keeps caret scrolling in the same coordinate system as DOM geometry when a mobile keyboard pans the page. +The composer uses the shared [text-input focus policy](../ui-primitives/README.md#use-this-package) on mount, Session switching, and unlock. Identified phones and tablets require tapping the input; desktop devices retain automatic focus. On these mobile devices, a submission that empties the focused draft moves focus to the non-text composer card, dismissing the keyboard while retaining its navigation position. Rejected submissions, retained newer draft text, and another control already holding focus preserve focus. The [Lexical patch](../../../patches/lexical@0.49.0.patch) keeps caret scrolling in the same coordinate system as DOM geometry when a mobile keyboard pans the page. The context-occupancy button shows a ring and percentage below the input card, after the Session statistics. Clicking it opens the token breakdown in a panel kept inside the viewport, including when no statistics are shown; the button stays hidden until context usage and capacity are available. diff --git a/packages/client/ui-conversation/README.zh.md b/packages/client/ui-conversation/README.zh.md index d756b06020..9ad49bdc77 100644 --- a/packages/client/ui-conversation/README.zh.md +++ b/packages/client/ui-conversation/README.zh.md @@ -70,7 +70,7 @@ Queue 预览启用空白折叠和文档边缘 trim,保留 emoji,并使用 CS 上下文占用率入口遵循[统计控件圆角规则](../../../docs/ui-radius.zh.md#radius-scale)。 -composer 在挂载、切换 Session 和解除锁定时使用共享的[文字输入框聚焦策略](../ui-primitives/README.zh.md#use-this-package)。识别出的手机和平板需要点击输入框;桌面设备保留自动聚焦。在这些移动设备上,提交后清空草稿会收起键盘;被拒绝的提交和保留的新草稿文字不会改变焦点。移动端键盘平移页面时,[Lexical 补丁](../../../patches/lexical@0.49.0.patch)让光标滚动计算与 DOM 几何使用同一坐标系。 +composer 在挂载、切换 Session 和解除锁定时使用共享的[文字输入框聚焦策略](../ui-primitives/README.zh.md#use-this-package)。识别出的手机和平板需要点击输入框;桌面设备保留自动聚焦。在这些移动设备上,提交清空正在聚焦的草稿后,焦点移到不接受文字输入的 composer 卡片,收起键盘并保留键盘导航位置。被拒绝的提交、保留的新草稿文字,以及已经聚焦的其他控件均保留原有焦点。移动端键盘平移页面时,[Lexical 补丁](../../../patches/lexical@0.49.0.patch)让光标滚动计算与 DOM 几何使用同一坐标系。 上下文占用按钮在输入卡片下方、会话统计右侧显示圆环和百分比。点击按钮可在视口内的面板查看 token 构成,没有统计项时面板也不会越界;上下文用量和容量尚不可用时,按钮保持隐藏。 diff --git a/packages/client/ui-conversation/src/client/input/editor/view-binding.ts b/packages/client/ui-conversation/src/client/input/editor/view-binding.ts index 725d610d04..c6f88c28e3 100644 --- a/packages/client/ui-conversation/src/client/input/editor/view-binding.ts +++ b/packages/client/ui-conversation/src/client/input/editor/view-binding.ts @@ -2,7 +2,7 @@ import type { MouseEvent, MutableRefObject, RefObject } from 'react' import type { LexicalEditor } from 'lexical' import { $getRoot } from 'lexical' -import { isMobileDevice } from '@deepseek-ai/dsh-client-ui-primitives' +import { focusWithoutRing, isMobileDevice } from '@deepseek-ai/dsh-client-ui-primitives' import type { ComposerKeyboard } from '../../contract/draft-editor.ts' import type { ComposerBarProps } from '../../contract/slots.ts' import type { BusyEnterBehavior } from '../../contract/composer-submission.ts' @@ -11,14 +11,20 @@ import { registerComposerKeymap } from './keymap.ts' import { DRAFT_SUBMITTED_TAG } from './runtime.ts' /** - * Dismiss the mobile keyboard after a submission empties the draft. + * Transfer mobile editor focus after a submission empties the draft. + * A control the user already focused retains focus. * @param editor - the Session-owned editor. + * @param destination - stable, focusable non-text element that retains the composer's keyboard position. * @returns the update-listener cleanup. */ -export function installDraftKeyboardDismissal(editor: LexicalEditor): () => void { +export function installDraftKeyboardDismissal(editor: LexicalEditor, destination: RefObject): () => void { return editor.registerUpdateListener(({ editorState, tags }) => { if (!tags.has(DRAFT_SUBMITTED_TAG) || !isMobileDevice()) return - if (editorState.read(() => $getRoot().getTextContentSize() === 0)) editor.getRootElement()?.blur() + const input = editor.getRootElement() + if (input === null || input.ownerDocument.activeElement !== input) return + if (editorState.read(() => $getRoot().getTextContentSize() === 0) && destination.current !== null) { + focusWithoutRing(destination.current, { preventScroll: true }) + } }) } diff --git a/packages/client/ui-conversation/src/client/skeleton/InputBar.tsx b/packages/client/ui-conversation/src/client/skeleton/InputBar.tsx index e3a43f138f..e713fb758c 100644 --- a/packages/client/ui-conversation/src/client/skeleton/InputBar.tsx +++ b/packages/client/ui-conversation/src/client/skeleton/InputBar.tsx @@ -269,7 +269,7 @@ export const InputBar = memo(function InputBar({ useEffect(() => { if (editor === null) return - return installDraftKeyboardDismissal(editor) + return installDraftKeyboardDismissal(editor, cardRef) }, [editor]) // Button presses steal focus from the editor; suppress at mousedown so @@ -287,7 +287,7 @@ export const InputBar = memo(function InputBar({ if (target.closest('[data-composer-overlay]') !== null) return if (scrollRef.current?.contains(target)) return const control = target.closest('button, a, input, select, textarea, [role="button"], [contenteditable], [tabindex]') - if (control !== null && e.currentTarget.contains(control)) return + if (control !== null && control !== e.currentTarget && e.currentTarget.contains(control)) return e.preventDefault() // Lexical's stored selection can lag behind native caret moves, so calling // editor.focus() on a focused editor can restore an older caret. @@ -397,6 +397,7 @@ export const InputBar = memo(function InputBar({ click's reopen (close-then-open flickers the chip's open echo). */}
{ root.remove(); outside.remove() }) + document.body.append(card, outside) + onTestFinished(() => { card.remove(); outside.remove() }) // jsdom collapses document Selection on every focus(); Chromium retains the // editor range here. Keep native focus events and activeElement changes. for (const element of [root, outside]) { @@ -65,7 +68,7 @@ function fixture(start = 1, end = 4) { editor.read(() => {}) return reveal } - return { runtime, editor, root, outside, onUpdate, dispose, selection, domSelection, focusComposer } + return { runtime, editor, root, card, outside, onUpdate, dispose, selection, domSelection, focusComposer } } it.each([ @@ -137,11 +140,28 @@ it('restores a pending selection when blur and explicit focus share one update b expect(reveal).toHaveBeenCalledOnce() }) +it('hands mobile submission focus to the composer without stealing focus from another control', () => { + const userAgent = vi.spyOn(navigator, 'userAgent', 'get').mockReturnValue('Mozilla/5.0 (iPhone; CPU iPhone OS 18_6 like Mac OS X) AppleWebKit/605.1.15 Version/18.6 Mobile/15E148 Safari/604.1') + onTestFinished(() => { userAgent.mockRestore() }) + const f = fixture() + const dispose = installDraftKeyboardDismissal(f.editor, { current: f.card }) + onTestFinished(dispose) + + f.runtime.clearCommittedDraft(() => null) + expect(f.root.textContent).toBe('') + expect(document.activeElement).toBe(f.card) + + f.runtime.setDraft('next draft') + f.outside.focus() + f.runtime.clearCommittedDraft(() => null) + expect(document.activeElement).toBe(f.outside) +}) + it('retains mobile focus for a newer draft suffix and removes dismissal with the view', () => { const userAgent = vi.spyOn(navigator, 'userAgent', 'get').mockReturnValue('Mozilla/5.0 (iPhone; CPU iPhone OS 18_6 like Mac OS X) AppleWebKit/605.1.15 Version/18.6 Mobile/15E148 Safari/604.1') onTestFinished(() => { userAgent.mockRestore() }) const f = fixture() - const dispose = installDraftKeyboardDismissal(f.editor) + const dispose = installDraftKeyboardDismissal(f.editor, { current: f.card }) onTestFinished(dispose) f.runtime.clearCommittedDraft(() => 6) From 9b029cdb38b235e3490ad06c1ff4da1e2a6e9fdd Mon Sep 17 00:00:00 2001 From: Saafo <46736350+Saafo@users.noreply.github.com> Date: Tue, 20 Oct 2026 15:06:50 +0800 Subject: [PATCH 10/12] =?UTF-8?q?=F0=9F=90=9B=20fix(client):=20keep=20fram?= =?UTF-8?q?e=20content=20inside=20vertical=20safe=20areas?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/web/tests/safe-area.e2e.ts | 39 +++++++++++++++++++ apps/web/tsconfig.json | 1 + packages/client/ui-layout/README.i18n.yaml | 4 +- packages/client/ui-layout/README.md | 2 + packages/client/ui-layout/README.zh.md | 2 + .../ui-layout/src/client/AppFrame.module.css | 2 + packages/client/web/README.i18n.yaml | 4 +- packages/client/web/README.md | 2 +- packages/client/web/README.zh.md | 2 +- tsconfig.host.json | 1 + 10 files changed, 53 insertions(+), 6 deletions(-) create mode 100644 apps/web/tests/safe-area.e2e.ts diff --git a/apps/web/tests/safe-area.e2e.ts b/apps/web/tests/safe-area.e2e.ts new file mode 100644 index 0000000000..6943de0d4c --- /dev/null +++ b/apps/web/tests/safe-area.e2e.ts @@ -0,0 +1,39 @@ +/** Layout consumes the Web shell's vertical safe insets without resizing the viewport. */ +import { fileURLToPath } from 'node:url' +import { chromium } from 'playwright' +import { expect, it } from 'vitest' +import { launchWebScaffold } from './scaffold.ts' + +it('keeps sidebar and conversation content inside top and bottom safe areas', async () => { + const scaffold = await launchWebScaffold({ + profile: { packages: [] }, + extraOverlayPath: fileURLToPath(new URL('./pin-browse-picker.overlay.yml', import.meta.url)), + }) + try { + const browser = await chromium.launch() + try { + const page = await browser.newPage({ viewport: { width: 390, height: 844 } }) + await page.goto(scaffold.authenticatedUrl) + const center = page.locator('[class*="centerCol"]') + await center.waitFor() + // Desktop Chromium has no hardware cutout; supply the shell variables at their real owner. + await page.locator('#root').evaluate((root) => { + root.style.setProperty('--dsh-safe-area-top', '47px') + root.style.setProperty('--dsh-safe-area-bottom', '34px') + }) + await expect.poll(async () => (await center.boundingBox())?.y).toBe(47) + expect((await center.boundingBox())?.height).toBe(763) + expect((await page.locator('[class*="sidebarCol"]').boundingBox())?.y).toBe(47) + const input = page.getByRole('textbox').first() + await input.focus() + const box = await input.boundingBox() + expect(box!.y + box!.height).toBeLessThanOrEqual(810) + await page.locator('#root').evaluate((root) => { + root.style.removeProperty('--dsh-safe-area-top') + root.style.removeProperty('--dsh-safe-area-bottom') + }) + await expect.poll(async () => (await center.boundingBox())?.y).toBe(0) + expect((await center.boundingBox())?.height).toBe(844) + } finally { await browser.close() } + } finally { await scaffold.close() } +}) diff --git a/apps/web/tsconfig.json b/apps/web/tsconfig.json index db02a233ec..5c0c0df26b 100644 --- a/apps/web/tsconfig.json +++ b/apps/web/tsconfig.json @@ -103,6 +103,7 @@ "tests/settings-chrome.e2e.ts", "tests/session-log-upload.e2e.ts", "tests/caption-overlays.e2e.ts", + "tests/safe-area.e2e.ts", "tests/settings-appearance.e2e.ts", "tests/menu-material.e2e.ts", "tests/desktop-locale.e2e.ts", diff --git a/packages/client/ui-layout/README.i18n.yaml b/packages/client/ui-layout/README.i18n.yaml index 4ad7481ef7..98d21448b5 100644 --- a/packages/client/ui-layout/README.i18n.yaml +++ b/packages/client/ui-layout/README.i18n.yaml @@ -15,8 +15,8 @@ en: d152484eb41ac6b4 zh: 09388d293f9be9cb /deepseek-ai-dsh-client-ui-layout/use-this-package: - en: cc6e9021ba3001bc - zh: 97444857762b4e8e + en: 6e10526aaa310120 + zh: 8cd703f499c63dce /deepseek-ai-dsh-client-ui-layout/use-this-package/window-chrome-seat: en: 7eac53b38d0777fe zh: 7f9422dff671ba50 diff --git a/packages/client/ui-layout/README.md b/packages/client/ui-layout/README.md index 43c61b89d1..c315ccb731 100644 --- a/packages/client/ui-layout/README.md +++ b/packages/client/ui-layout/README.md @@ -29,6 +29,8 @@ Desktop Mod+B toggles the left sidebar through the same layout action used by it The root slot composes the sidebar, main content, and right column. The sidebar spans 264–420px, defaults to 280px, and retains a 56px rail when collapsed; below 1024px it collapses automatically, and opening the right panel collapses a manually expanded sidebar. The right panel first opens at 45% of the viewport, then retains the user's pixel preference, capped at 70%. To protect 400px for the center, the frame first reduces the right panel to 300px, then reports insufficient room so its occupant closes it, and only then compresses the center further. Dragging has no transition delay; the right handle is absent while closed or fullscreen. +The frame applies the Web shell’s top and bottom safe-area variables as vertical padding, defaulting to zero when absent. Its outer height stays equal to the layout viewport. + Global panels occupy the root-scoped `main` keyed slot; `conversation` is the reserved key for the Conversation. `ctx.layout.selectPanel(id)` selects a registered panel, and `null` selects the Conversation without changing the current Session. The Plugins page contributes one of the shipped global panels. The single root-scoped `shell.bottom` slot spans the full width below the three columns. Its occupant controls its own height and visibility; the columns shrink by that height, and empty content reserves no space. Main-panel navigation preserves the bottom component. Column resize handles stop above it, while `shell.overlay` covers the whole frame. The default composition leaves this slot empty. diff --git a/packages/client/ui-layout/README.zh.md b/packages/client/ui-layout/README.zh.md index 9b426dcdef..6f81f62ed8 100644 --- a/packages/client/ui-layout/README.zh.md +++ b/packages/client/ui-layout/README.zh.md @@ -29,6 +29,8 @@ kind: "package-reference" 本插件在 root slot 中组合侧边栏、主内容和右栏。侧边栏宽度为 264~420px,默认为 280px,收起后保留 56px 控制栏;窗口宽度低于 1024px 时自动收起,打开右侧面板也会收起手动展开的侧边栏。右侧面板首次打开时使用视口宽度的 45%,之后保留用户的像素宽度偏好,上限为 70%。为给中栏保留 400px,框架先将右侧面板缩减至 300px,再报告空间不足,使占用方将其关闭,最后才进一步压缩中栏。拖动没有过渡延迟;右侧手柄在关闭或全屏时不显示。 +框架将 Web 壳提供的上下安全区变量用于垂直内边距,变量缺省时按零处理。框架外部高度始终等于布局视口。 + 全局面板占据 root 作用域的 `main` keyed slot;`conversation` 是为会话界面保留的 key。`ctx.layout.selectPanel(id)` 选中已注册面板,`null` 则选中会话界面,但不改变当前会话。Plugins 页面是默认组合中的一个全局面板。 root 作用域的单一 `shell.bottom` slot 横跨三列下方的整行。占用方控制自身高度与显隐;三列按该高度缩短,空内容不预留空间。切换主面板时保留底部组件。列宽拖拽手柄止于底部内容上方,`shell.overlay` 仍覆盖整个框架。默认组合不占用此 slot。 diff --git a/packages/client/ui-layout/src/client/AppFrame.module.css b/packages/client/ui-layout/src/client/AppFrame.module.css index 5b71ebecfd..b3c18fc02c 100644 --- a/packages/client/ui-layout/src/client/AppFrame.module.css +++ b/packages/client/ui-layout/src/client/AppFrame.module.css @@ -3,6 +3,8 @@ display: grid; grid-template-rows: minmax(0, 1fr) auto; height: 100%; + box-sizing: border-box; + padding-block: var(--dsh-safe-area-top, 0px) var(--dsh-safe-area-bottom, 0px); overflow: hidden; background: var(--dsw-alias-bg-base); } diff --git a/packages/client/web/README.i18n.yaml b/packages/client/web/README.i18n.yaml index f33c8ad009..83cb657219 100644 --- a/packages/client/web/README.i18n.yaml +++ b/packages/client/web/README.i18n.yaml @@ -18,8 +18,8 @@ en: 5dba7f9e0c6a94c8 zh: f160f806c487337b /deepseek-ai-dsh-client-web/use-this-package/viewport-sizing: - en: c29bc7d1604312ce - zh: 833c2a24d9a445e7 + en: e7b19d8f2c771b70 + zh: fe517c603cb5a162 /deepseek-ai-dsh-client-web/use-this-package/what-boot-looks-like: en: f3b01aa878764e5c zh: f02eab65d441bfe0 diff --git a/packages/client/web/README.md b/packages/client/web/README.md index 32ef1dd308..9d88f398fc 100644 --- a/packages/client/web/README.md +++ b/packages/client/web/README.md @@ -40,7 +40,7 @@ Web and Desktop mathematical rendering requires WOFF2 support. The [Web build](. The root fills the CSS layout viewport with absolute positioning. The browser pans the page to reveal focused inputs; inner panes own content scrolling. -The root applies horizontal safe-area padding and publishes `--dsh-safe-area-top` and `--dsh-safe-area-bottom` for frame content padding. +The root applies horizontal safe-area padding and publishes `--dsh-safe-area-top` and `--dsh-safe-area-bottom`. The layout frame consumes these as vertical padding, keeping its sidebar and conversation, including the composer, inside the safe area. The [Web application entry](../../../apps/web/index.html) declares `width=device-width, initial-scale=1, viewport-fit=cover` without limiting user zoom. Touch inputs use a minimum font size of 16px to avoid focus-triggered page enlargement. diff --git a/packages/client/web/README.zh.md b/packages/client/web/README.zh.md index 6eb646d441..3c181edf65 100644 --- a/packages/client/web/README.zh.md +++ b/packages/client/web/README.zh.md @@ -40,7 +40,7 @@ Web 和 Desktop 的数学公式渲染要求支持 WOFF2。[Web 构建](../../../ 根容器通过绝对定位铺满 CSS 布局视口。浏览器平移页面以露出获得焦点的输入框,内容滚动由内部面板负责。 -根容器应用左右安全区边距,并发布 `--dsh-safe-area-top` 和 `--dsh-safe-area-bottom`,供框架为内容保留上下边距。 +根容器应用左右安全区边距,并发布 `--dsh-safe-area-top` 和 `--dsh-safe-area-bottom`。布局框架将这两个值用于上下内边距,使侧栏和包含输入框的会话区域位于安全区内。 [Web 应用入口](../../../apps/web/index.html)声明 `width=device-width, initial-scale=1, viewport-fit=cover`,不限制用户缩放。触摸输入框使用至少 16px 的字号,避免获得焦点时自动放大页面。 diff --git a/tsconfig.host.json b/tsconfig.host.json index 226923ef76..a97b27b103 100644 --- a/tsconfig.host.json +++ b/tsconfig.host.json @@ -96,6 +96,7 @@ "apps/web/tests/settings-chrome.e2e.ts", "apps/web/tests/session-log-upload.e2e.ts", "apps/web/tests/caption-overlays.e2e.ts", + "apps/web/tests/safe-area.e2e.ts", "apps/web/tests/settings-appearance.e2e.ts", "apps/web/tests/menu-material.e2e.ts", "apps/web/tests/desktop-locale.e2e.ts", From dc83ed11bc09d8833710aafcc73ca6a68af1d663 Mon Sep 17 00:00:00 2001 From: Stevring Date: Thu, 22 Oct 2026 10:18:39 +0800 Subject: [PATCH 11/12] refactor(client): simplify and cache mobile device detection --- .../tests/popup-view.client.spec.tsx | 5 ++ .../tests/editor-focus.client.spec.ts | 13 ++++- .../tests/input-bar.client.spec.tsx | 5 ++ .../tests/model-select.client.spec.tsx | 5 ++ .../client/ui-primitives/README.i18n.yaml | 4 +- packages/client/ui-primitives/README.md | 2 +- packages/client/ui-primitives/README.zh.md | 2 +- packages/client/ui-primitives/package.json | 3 +- packages/client/ui-primitives/src/focus.ts | 17 ++++--- .../ui-primitives/tests/atoms.client.spec.tsx | 49 ++++++++++++++++++- .../tests/task-menu.client.spec.tsx | 7 ++- pnpm-lock.yaml | 3 -- 12 files changed, 95 insertions(+), 20 deletions(-) diff --git a/packages/client/ui-commands/tests/popup-view.client.spec.tsx b/packages/client/ui-commands/tests/popup-view.client.spec.tsx index 387108f2ed..9b1d246927 100644 --- a/packages/client/ui-commands/tests/popup-view.client.spec.tsx +++ b/packages/client/ui-commands/tests/popup-view.client.spec.tsx @@ -10,6 +10,7 @@ * retry button, the highlighted row scrolls into view, and the card height * clamps to the space above the composer. */ +import * as uiPrimitives from '@deepseek-ai/dsh-client-ui-primitives' import { afterEach, beforeEach, describe, expect, it, onTestFinished, vi } from 'vitest' import { act, cleanup, fireEvent, render, screen } from '@testing-library/react' import type { SelectOption } from '../src/client/contract.ts' @@ -157,6 +158,10 @@ describe('PopupSelectView', () => { else Object.defineProperty(navigator, name, descriptor) }) } + vi.resetModules() + const detection = await import('@deepseek-ai/dsh-client-ui-primitives/src/focus.ts') + const device = vi.spyOn(uiPrimitives, 'isMobileDevice').mockImplementation(detection.isMobileDevice) + onTestFinished(() => { device.mockRestore() }) const { popup, search } = await mountOpen() expect(document.activeElement === search).toBe(automatic) act(() => { search.focus() }) diff --git a/packages/client/ui-conversation/tests/editor-focus.client.spec.ts b/packages/client/ui-conversation/tests/editor-focus.client.spec.ts index 1dc79ec895..0dd714c9a1 100644 --- a/packages/client/ui-conversation/tests/editor-focus.client.spec.ts +++ b/packages/client/ui-conversation/tests/editor-focus.client.spec.ts @@ -1,5 +1,6 @@ // @vitest-environment jsdom /** Composer selection survives focus transfers and background editor reconciliation. */ +import * as uiPrimitives from '@deepseek-ai/dsh-client-ui-primitives' import { expect, it, onTestFinished, vi } from 'vitest' import { $getRoot, $getSelection, $isRangeSelection, SELECTION_CHANGE_COMMAND, UNDO_COMMAND } from 'lexical' import { DraftEditorRuntime } from '../src/client/input/editor/runtime.ts' @@ -140,9 +141,13 @@ it('restores a pending selection when blur and explicit focus share one update b expect(reveal).toHaveBeenCalledOnce() }) -it('hands mobile submission focus to the composer without stealing focus from another control', () => { +it('hands mobile submission focus to the composer without stealing focus from another control', async () => { const userAgent = vi.spyOn(navigator, 'userAgent', 'get').mockReturnValue('Mozilla/5.0 (iPhone; CPU iPhone OS 18_6 like Mac OS X) AppleWebKit/605.1.15 Version/18.6 Mobile/15E148 Safari/604.1') onTestFinished(() => { userAgent.mockRestore() }) + vi.resetModules() + const detection = await import('@deepseek-ai/dsh-client-ui-primitives/src/focus.ts') + const device = vi.spyOn(uiPrimitives, 'isMobileDevice').mockImplementation(detection.isMobileDevice) + onTestFinished(() => { device.mockRestore() }) const f = fixture() const dispose = installDraftKeyboardDismissal(f.editor, { current: f.card }) onTestFinished(dispose) @@ -157,9 +162,13 @@ it('hands mobile submission focus to the composer without stealing focus from an expect(document.activeElement).toBe(f.outside) }) -it('retains mobile focus for a newer draft suffix and removes dismissal with the view', () => { +it('retains mobile focus for a newer draft suffix and removes dismissal with the view', async () => { const userAgent = vi.spyOn(navigator, 'userAgent', 'get').mockReturnValue('Mozilla/5.0 (iPhone; CPU iPhone OS 18_6 like Mac OS X) AppleWebKit/605.1.15 Version/18.6 Mobile/15E148 Safari/604.1') onTestFinished(() => { userAgent.mockRestore() }) + vi.resetModules() + const detection = await import('@deepseek-ai/dsh-client-ui-primitives/src/focus.ts') + const device = vi.spyOn(uiPrimitives, 'isMobileDevice').mockImplementation(detection.isMobileDevice) + onTestFinished(() => { device.mockRestore() }) const f = fixture() const dispose = installDraftKeyboardDismissal(f.editor, { current: f.card }) onTestFinished(dispose) diff --git a/packages/client/ui-conversation/tests/input-bar.client.spec.tsx b/packages/client/ui-conversation/tests/input-bar.client.spec.tsx index 7cd23b3d4e..e3c0e1b11e 100644 --- a/packages/client/ui-conversation/tests/input-bar.client.spec.tsx +++ b/packages/client/ui-conversation/tests/input-bar.client.spec.tsx @@ -8,6 +8,7 @@ // root listener routes them through the keymap commands); draft writes drive // the shell (jsdom's beforeinput lacks the ranges Lexical needs). +import * as uiPrimitives from '@deepseek-ai/dsh-client-ui-primitives' import './control-row-dom.ts' import type { InboxState } from '@deepseek-ai/dsh-agent/types' import type { GlobalStandardProps } from '@deepseek-ai/dsh-client-ui-slots' @@ -1431,6 +1432,10 @@ describe('running and lock semantics', () => { else Object.defineProperty(navigator, name, descriptor) }) } + vi.resetModules() + const detection = await import('@deepseek-ai/dsh-client-ui-primitives/src/focus.ts') + const device = vi.spyOn(uiPrimitives, 'isMobileDevice').mockImplementation(detection.isMobileDevice) + onTestFinished(() => { device.mockRestore() }) const outside = document.createElement('input') document.body.append(outside) onTestFinished(() => { outside.remove() }) diff --git a/packages/client/ui-model-selection/tests/model-select.client.spec.tsx b/packages/client/ui-model-selection/tests/model-select.client.spec.tsx index 336c12c97d..bb4832a0ce 100644 --- a/packages/client/ui-model-selection/tests/model-select.client.spec.tsx +++ b/packages/client/ui-model-selection/tests/model-select.client.spec.tsx @@ -1,4 +1,5 @@ // @vitest-environment jsdom +import * as uiPrimitives from '@deepseek-ai/dsh-client-ui-primitives' import { act, cleanup, fireEvent, render, screen, waitFor } from '@testing-library/react' import { afterEach, beforeEach, describe, expect, it, onTestFinished, vi } from 'vitest' import { RemoteError, SlotTestRuntime } from '@deepseek-ai/dsh-client-test-runtime' @@ -471,6 +472,10 @@ describe('ModelSelect keyboard walk', () => { else Object.defineProperty(navigator, name, descriptor) }) } + vi.resetModules() + const detection = await import('@deepseek-ai/dsh-client-ui-primitives/src/focus.ts') + const device = vi.spyOn(uiPrimitives, 'isMobileDevice').mockImplementation(detection.isMobileDevice) + onTestFinished(() => { device.mockRestore() }) const select = vi.fn() render( void>() const navigationKeys = new Set(['Tab', 'ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight', 'Home', 'End']) +let mobileDevice: boolean | undefined /** - * Identify phones and tablets from the current browser's device information. - * Bowser identifies phones and tablets from the UA; MacIntel with multiple touch points identifies desktop-mode iPads. - * @returns true for identified phones and tablets; false for other devices, including unrecognized UAs. + * Identify iOS and Android phones and tablets from the current browser's device information. + * MacIntel with multiple touch points identifies desktop-mode iPads. + * The first result is shared by all callers until the page reloads. + * @returns true for recognized mobile devices; false for other devices, including unrecognized UAs. */ export function isMobileDevice(): boolean { - const platformType = bowser.parse(navigator.userAgent).platform.type - const desktopIPad = navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1 - return platformType === 'mobile' || platformType === 'tablet' || desktopIPad + if (mobileDevice !== undefined) return mobileDevice + const { userAgent, platform, maxTouchPoints } = navigator + mobileDevice = /Android|iPhone|iPad|iPod/i.test(userAgent) + || (platform === 'MacIntel' && maxTouchPoints > 1) + return mobileDevice } /** diff --git a/packages/client/ui-primitives/tests/atoms.client.spec.tsx b/packages/client/ui-primitives/tests/atoms.client.spec.tsx index d03035ee29..3f56fda81c 100644 --- a/packages/client/ui-primitives/tests/atoms.client.spec.tsx +++ b/packages/client/ui-primitives/tests/atoms.client.spec.tsx @@ -1,7 +1,7 @@ // @vitest-environment jsdom import { createRef, useState } from 'react' import { act, cleanup, fireEvent, render, screen } from '@testing-library/react' -import { afterEach, describe, expect, it, vi } from 'vitest' +import { afterEach, beforeEach, describe, expect, it, onTestFinished, vi } from 'vitest' import { Button, ConnectionIndicator, Input, Menu, MenuItemButton, Modal, Pill } from '@deepseek-ai/dsh-client-ui-primitives' import { POINTER_GRACE_MS } from '../src/pointer-grace.ts' import { focusWithoutRing } from '../src/focus.ts' @@ -9,6 +9,53 @@ import buttonCss from '../src/Button.module.css' afterEach(cleanup) +describe('isMobileDevice', () => { + beforeEach(() => { vi.resetModules() }) + + it.each([ + { name: 'iPhone', userAgent: 'Mozilla/5.0 (iPhone; CPU iPhone OS 18_6 like Mac OS X)', platform: 'iPhone', maxTouchPoints: 5, mobile: true }, + { name: 'iPad', userAgent: 'Mozilla/5.0 (iPad; CPU OS 18_6 like Mac OS X)', platform: 'iPad', maxTouchPoints: 5, mobile: true }, + { name: 'iPod', userAgent: 'Mozilla/5.0 (iPod; U; CPU like Mac OS X; en)', platform: 'iPod', maxTouchPoints: 5, mobile: true }, + { name: 'Android phone', userAgent: 'Mozilla/5.0 (Linux; Android 10; K) Mobile', platform: 'Linux armv8l', maxTouchPoints: 0, mobile: true }, + { name: 'Android tablet', userAgent: 'Mozilla/5.0 (Linux; Android 10; K)', platform: 'Linux armv8l', maxTouchPoints: 5, mobile: true }, + { name: 'desktop-mode iPad', userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7)', platform: 'MacIntel', maxTouchPoints: 5, mobile: true }, + { name: 'Mac', userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7)', platform: 'MacIntel', maxTouchPoints: 0, mobile: false }, + { name: 'Windows touchscreen', userAgent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64)', platform: 'Win32', maxTouchPoints: 5, mobile: false }, + { name: 'native networking UA', userAgent: 'DeepSeek%20Chat/0 CFNetwork/3860.400.51 Darwin/25.3.0', platform: '', maxTouchPoints: 0, mobile: false }, + { name: 'unknown UA', userAgent: 'Unrecognized/1.0', platform: '', maxTouchPoints: 0, mobile: false }, + ])('classifies $name', async ({ userAgent, platform, maxTouchPoints, mobile }) => { + for (const [name, value] of Object.entries({ userAgent, platform, maxTouchPoints })) { + const descriptor = Object.getOwnPropertyDescriptor(navigator, name) + Object.defineProperty(navigator, name, { configurable: true, value }) + onTestFinished(() => { + if (descriptor === undefined) Reflect.deleteProperty(navigator, name) + else Object.defineProperty(navigator, name, descriptor) + }) + } + const { isMobileDevice } = await import('../src/focus.ts') + expect(isMobileDevice()).toBe(mobile) + }) + + it.each([true, false])('shares a cached %s result between callers until the module reloads', async (mobile) => { + const mobileUA = 'Mozilla/5.0 (iPhone)' + const desktopUA = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7)' + const ua = vi.spyOn(navigator, 'userAgent', 'get').mockReturnValue(mobile ? mobileUA : desktopUA) + onTestFinished(() => { ua.mockRestore() }) + const first = await import('../src/focus.ts') + expect(first.isMobileDevice()).toBe(mobile) + + ua.mockReturnValue(mobile ? desktopUA : mobileUA) + const other = await import('@deepseek-ai/dsh-client-ui-primitives/src/focus.ts') + expect(other.isMobileDevice()).toBe(mobile) + expect(ua).toHaveBeenCalledTimes(1) + + vi.resetModules() + const reloaded = await import('../src/focus.ts') + expect(reloaded.isMobileDevice()).toBe(!mobile) + expect(ua).toHaveBeenCalledTimes(2) + }) +}) + it('retains automatic focus styling while typing and restores it for keyboard navigation', () => { render() const button = screen.getByRole('button') diff --git a/packages/client/ui-schedule/tests/task-menu.client.spec.tsx b/packages/client/ui-schedule/tests/task-menu.client.spec.tsx index f503d6a04e..9097bcec30 100644 --- a/packages/client/ui-schedule/tests/task-menu.client.spec.tsx +++ b/packages/client/ui-schedule/tests/task-menu.client.spec.tsx @@ -4,6 +4,7 @@ * handover a portaled list performs once it is placed, the row walk, and the * dismissal and focus-return paths the task manager's four menus rely on. */ +import * as uiPrimitives from '@deepseek-ai/dsh-client-ui-primitives' import { useState } from 'react' import { act, cleanup, fireEvent, render, screen, within } from '@testing-library/react' import { afterEach, describe, expect, it, onTestFinished, vi } from 'vitest' @@ -146,7 +147,7 @@ describe('TaskMenu', () => { { name: 'iPhone', userAgent: 'Mozilla/5.0 (iPhone; CPU iPhone OS 18_6 like Mac OS X) AppleWebKit/605.1.15 Version/18.6 Mobile/15E148 Safari/604.1', platform: 'iPhone', maxTouchPoints: 5 }, { name: 'Android tablet', userAgent: 'Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 Chrome/119.0.0.0 Safari/537.36', platform: 'Linux armv8l', maxTouchPoints: 5 }, { name: 'desktop-mode iPad', userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 Version/18.6 Safari/605.1.15', platform: 'MacIntel', maxTouchPoints: 5 }, - ])('leaves header search focus to the user on $name', ({ userAgent, platform, maxTouchPoints }) => { + ])('leaves header search focus to the user on $name', async ({ userAgent, platform, maxTouchPoints }) => { for (const [name, value] of Object.entries({ userAgent, platform, maxTouchPoints })) { const descriptor = Object.getOwnPropertyDescriptor(navigator, name) Object.defineProperty(navigator, name, { configurable: true, value }) @@ -155,6 +156,10 @@ describe('TaskMenu', () => { else Object.defineProperty(navigator, name, descriptor) }) } + vi.resetModules() + const detection = await import('@deepseek-ai/dsh-client-ui-primitives/src/focus.ts') + const device = vi.spyOn(uiPrimitives, 'isMobileDevice').mockImplementation(detection.isMobileDevice) + onTestFinished(() => { device.mockRestore() }) const menu = (open: boolean) => Date: Thu, 22 Oct 2026 12:04:03 +0800 Subject: [PATCH 12/12] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Defer=20global=20vie?= =?UTF-8?q?wport=20styles=20from=20mobile=20input=20fixes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/web/index.html | 2 +- apps/web/tests/default-model.e2e.ts | 6 +-- apps/web/tests/markdown-cjk-strong.e2e.ts | 30 -------------- apps/web/tests/safe-area.e2e.ts | 39 ------------------- apps/web/tsconfig.json | 1 - .../tests/editor-viewport.client.spec.ts | 1 + packages/client/ui-layout/README.i18n.yaml | 4 +- packages/client/ui-layout/README.md | 2 - packages/client/ui-layout/README.zh.md | 2 - .../ui-layout/src/client/AppFrame.module.css | 2 - packages/client/web/README.i18n.yaml | 7 +--- packages/client/web/README.md | 11 ------ packages/client/web/README.zh.md | 11 ------ packages/client/web/src/base.css | 24 ------------ tsconfig.host.json | 1 - 15 files changed, 7 insertions(+), 136 deletions(-) delete mode 100644 apps/web/tests/safe-area.e2e.ts diff --git a/apps/web/index.html b/apps/web/index.html index c85734e653..ff3ca620b7 100644 --- a/apps/web/index.html +++ b/apps/web/index.html @@ -2,7 +2,7 @@ - + diff --git a/apps/web/tests/default-model.e2e.ts b/apps/web/tests/default-model.e2e.ts index 6fe67adfcd..9625333287 100644 --- a/apps/web/tests/default-model.e2e.ts +++ b/apps/web/tests/default-model.e2e.ts @@ -204,7 +204,7 @@ describe('web e2e: the composer model switch is the default for later sessions', { device: 'Android Chrome', userAgent: 'Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 Chrome/119.0.0.0 Mobile Safari/537.36', automatic: false }, { device: 'iPhone Chrome', userAgent: 'Mozilla/5.0 (iPhone; CPU iPhone OS 18_6 like Mac OS X) AppleWebKit/605.1.15 CriOS/139.0.0.0 Mobile/15E148 Safari/604.1', automatic: false }, { device: 'narrow desktop', userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 Version/18.6 Safari/605.1.15', automatic: true }, - ])('respects $device viewport and search focus when opening /model', async ({ userAgent, automatic }) => { + ])('respects $device composer sizing and search focus when opening /model', async ({ userAgent, automatic }) => { const context = await browser.newContext({ userAgent, viewport: { width: 390, height: 844 }, locale: ZH_BROWSER_LOCALE, hasTouch: !automatic, }) @@ -221,13 +221,9 @@ describe('web e2e: the composer model switch is the default for later sessions', const search = devicePage.getByRole('textbox', { name: '筛选选项', exact: true }) await search.waitFor() await devicePage.getByRole('option', { name: /Origin Large/ }).waitFor() - expect(await devicePage.locator('meta[name="viewport"]').getAttribute('content')).toBe( - 'width=device-width, initial-scale=1, viewport-fit=cover', - ) expect(await search.evaluate(input => document.activeElement === input)).toBe(automatic) await search.click() expect(await search.evaluate(input => document.activeElement === input)).toBe(true) - expect(await devicePage.evaluate(() => window.visualViewport?.scale)).toBe(1) await search.fill('Origin') await devicePage.getByRole('option', { name: /Origin Large/ }).waitFor() expect(await devicePage.getByRole('option', { name: /Acme/ }).count()).toBe(0) diff --git a/apps/web/tests/markdown-cjk-strong.e2e.ts b/apps/web/tests/markdown-cjk-strong.e2e.ts index 411d3ea2c5..4d9594d771 100644 --- a/apps/web/tests/markdown-cjk-strong.e2e.ts +++ b/apps/web/tests/markdown-cjk-strong.e2e.ts @@ -125,36 +125,6 @@ describe('web e2e: CJK-adjacent Markdown strong emphasis', () => { expect(await page.getByText(paragraph, { exact: true }).count()).toBe(1) } - const viewport = page.viewportSize()! - try { - for (const size of [{ width: 390, height: 844 }, { width: 951, height: 589 }, { width: 669, height: 951 }]) { - await page.setViewportSize(size) - expect(await page.evaluate(() => getComputedStyle(document.documentElement).getPropertyValue('-webkit-text-size-adjust'))) - .toBe('100%') - expect(await strong.evaluateAll(elements => elements.map(el => getComputedStyle(el).fontSize))) - .toEqual(CASES.map(() => '14px')) - } - const restoreFont = await page.evaluateHandle(() => { - const style = document.body.style - const before = style.getPropertyValue('--dsh-content-font-size') - const priority = style.getPropertyPriority('--dsh-content-font-size') - style.setProperty('--dsh-content-font-size', '18px') - return () => { - if (before) style.setProperty('--dsh-content-font-size', before, priority) - else style.removeProperty('--dsh-content-font-size') - } - }) - try { - expect(await strong.evaluateAll(elements => elements.map(el => getComputedStyle(el).fontSize))) - .toEqual(CASES.map(() => '18px')) - } finally { - await restoreFont.evaluate((restore) => { restore() }) - await restoreFont.dispose() - } - } finally { - await page.setViewportSize(viewport) - } - const snapshot = (await captureStableAria(page, '[class*="centerCol"]', scaffold.workspaceCwd)) .split(SEED_ID).join('{{seededId}}') await compareOrRefreshGolden(UI_EXPECTED, snapshot, MODE) diff --git a/apps/web/tests/safe-area.e2e.ts b/apps/web/tests/safe-area.e2e.ts deleted file mode 100644 index 6943de0d4c..0000000000 --- a/apps/web/tests/safe-area.e2e.ts +++ /dev/null @@ -1,39 +0,0 @@ -/** Layout consumes the Web shell's vertical safe insets without resizing the viewport. */ -import { fileURLToPath } from 'node:url' -import { chromium } from 'playwright' -import { expect, it } from 'vitest' -import { launchWebScaffold } from './scaffold.ts' - -it('keeps sidebar and conversation content inside top and bottom safe areas', async () => { - const scaffold = await launchWebScaffold({ - profile: { packages: [] }, - extraOverlayPath: fileURLToPath(new URL('./pin-browse-picker.overlay.yml', import.meta.url)), - }) - try { - const browser = await chromium.launch() - try { - const page = await browser.newPage({ viewport: { width: 390, height: 844 } }) - await page.goto(scaffold.authenticatedUrl) - const center = page.locator('[class*="centerCol"]') - await center.waitFor() - // Desktop Chromium has no hardware cutout; supply the shell variables at their real owner. - await page.locator('#root').evaluate((root) => { - root.style.setProperty('--dsh-safe-area-top', '47px') - root.style.setProperty('--dsh-safe-area-bottom', '34px') - }) - await expect.poll(async () => (await center.boundingBox())?.y).toBe(47) - expect((await center.boundingBox())?.height).toBe(763) - expect((await page.locator('[class*="sidebarCol"]').boundingBox())?.y).toBe(47) - const input = page.getByRole('textbox').first() - await input.focus() - const box = await input.boundingBox() - expect(box!.y + box!.height).toBeLessThanOrEqual(810) - await page.locator('#root').evaluate((root) => { - root.style.removeProperty('--dsh-safe-area-top') - root.style.removeProperty('--dsh-safe-area-bottom') - }) - await expect.poll(async () => (await center.boundingBox())?.y).toBe(0) - expect((await center.boundingBox())?.height).toBe(844) - } finally { await browser.close() } - } finally { await scaffold.close() } -}) diff --git a/apps/web/tsconfig.json b/apps/web/tsconfig.json index c757b043bc..0776425343 100644 --- a/apps/web/tsconfig.json +++ b/apps/web/tsconfig.json @@ -110,7 +110,6 @@ "tests/settings-chrome.e2e.ts", "tests/session-log-upload.e2e.ts", "tests/caption-overlays.e2e.ts", - "tests/safe-area.e2e.ts", "tests/settings-appearance.e2e.ts", "tests/menu-material.e2e.ts", "tests/desktop-locale.e2e.ts", diff --git a/packages/client/ui-conversation/tests/editor-viewport.client.spec.ts b/packages/client/ui-conversation/tests/editor-viewport.client.spec.ts index 42f9a51e85..b000350885 100644 --- a/packages/client/ui-conversation/tests/editor-viewport.client.spec.ts +++ b/packages/client/ui-conversation/tests/editor-viewport.client.spec.ts @@ -23,6 +23,7 @@ function fixture(viewport: { height: number; offsetTop: number; pageTop: number document.body.append(root) const runtime: DraftEditorRuntime = new DraftEditorRuntime({ onUpdate: () => { runtime.refreshProjection() }, + quoteLabels: () => ({ remove: 'Remove quote' }), openReference: () => false, lexicon: () => new Map(), resolveLexicon: () => undefined, }) diff --git a/packages/client/ui-layout/README.i18n.yaml b/packages/client/ui-layout/README.i18n.yaml index 98d21448b5..4ad7481ef7 100644 --- a/packages/client/ui-layout/README.i18n.yaml +++ b/packages/client/ui-layout/README.i18n.yaml @@ -15,8 +15,8 @@ en: d152484eb41ac6b4 zh: 09388d293f9be9cb /deepseek-ai-dsh-client-ui-layout/use-this-package: - en: 6e10526aaa310120 - zh: 8cd703f499c63dce + en: cc6e9021ba3001bc + zh: 97444857762b4e8e /deepseek-ai-dsh-client-ui-layout/use-this-package/window-chrome-seat: en: 7eac53b38d0777fe zh: 7f9422dff671ba50 diff --git a/packages/client/ui-layout/README.md b/packages/client/ui-layout/README.md index c315ccb731..43c61b89d1 100644 --- a/packages/client/ui-layout/README.md +++ b/packages/client/ui-layout/README.md @@ -29,8 +29,6 @@ Desktop Mod+B toggles the left sidebar through the same layout action used by it The root slot composes the sidebar, main content, and right column. The sidebar spans 264–420px, defaults to 280px, and retains a 56px rail when collapsed; below 1024px it collapses automatically, and opening the right panel collapses a manually expanded sidebar. The right panel first opens at 45% of the viewport, then retains the user's pixel preference, capped at 70%. To protect 400px for the center, the frame first reduces the right panel to 300px, then reports insufficient room so its occupant closes it, and only then compresses the center further. Dragging has no transition delay; the right handle is absent while closed or fullscreen. -The frame applies the Web shell’s top and bottom safe-area variables as vertical padding, defaulting to zero when absent. Its outer height stays equal to the layout viewport. - Global panels occupy the root-scoped `main` keyed slot; `conversation` is the reserved key for the Conversation. `ctx.layout.selectPanel(id)` selects a registered panel, and `null` selects the Conversation without changing the current Session. The Plugins page contributes one of the shipped global panels. The single root-scoped `shell.bottom` slot spans the full width below the three columns. Its occupant controls its own height and visibility; the columns shrink by that height, and empty content reserves no space. Main-panel navigation preserves the bottom component. Column resize handles stop above it, while `shell.overlay` covers the whole frame. The default composition leaves this slot empty. diff --git a/packages/client/ui-layout/README.zh.md b/packages/client/ui-layout/README.zh.md index 6f81f62ed8..9b426dcdef 100644 --- a/packages/client/ui-layout/README.zh.md +++ b/packages/client/ui-layout/README.zh.md @@ -29,8 +29,6 @@ kind: "package-reference" 本插件在 root slot 中组合侧边栏、主内容和右栏。侧边栏宽度为 264~420px,默认为 280px,收起后保留 56px 控制栏;窗口宽度低于 1024px 时自动收起,打开右侧面板也会收起手动展开的侧边栏。右侧面板首次打开时使用视口宽度的 45%,之后保留用户的像素宽度偏好,上限为 70%。为给中栏保留 400px,框架先将右侧面板缩减至 300px,再报告空间不足,使占用方将其关闭,最后才进一步压缩中栏。拖动没有过渡延迟;右侧手柄在关闭或全屏时不显示。 -框架将 Web 壳提供的上下安全区变量用于垂直内边距,变量缺省时按零处理。框架外部高度始终等于布局视口。 - 全局面板占据 root 作用域的 `main` keyed slot;`conversation` 是为会话界面保留的 key。`ctx.layout.selectPanel(id)` 选中已注册面板,`null` 则选中会话界面,但不改变当前会话。Plugins 页面是默认组合中的一个全局面板。 root 作用域的单一 `shell.bottom` slot 横跨三列下方的整行。占用方控制自身高度与显隐;三列按该高度缩短,空内容不预留空间。切换主面板时保留底部组件。列宽拖拽手柄止于底部内容上方,`shell.overlay` 仍覆盖整个框架。默认组合不占用此 slot。 diff --git a/packages/client/ui-layout/src/client/AppFrame.module.css b/packages/client/ui-layout/src/client/AppFrame.module.css index b3c18fc02c..5b71ebecfd 100644 --- a/packages/client/ui-layout/src/client/AppFrame.module.css +++ b/packages/client/ui-layout/src/client/AppFrame.module.css @@ -3,8 +3,6 @@ display: grid; grid-template-rows: minmax(0, 1fr) auto; height: 100%; - box-sizing: border-box; - padding-block: var(--dsh-safe-area-top, 0px) var(--dsh-safe-area-bottom, 0px); overflow: hidden; background: var(--dsw-alias-bg-base); } diff --git a/packages/client/web/README.i18n.yaml b/packages/client/web/README.i18n.yaml index 83cb657219..bd0e87b2db 100644 --- a/packages/client/web/README.i18n.yaml +++ b/packages/client/web/README.i18n.yaml @@ -15,11 +15,8 @@ en: d152484eb41ac6b4 zh: 09388d293f9be9cb /deepseek-ai-dsh-client-web/use-this-package: - en: 5dba7f9e0c6a94c8 - zh: f160f806c487337b -/deepseek-ai-dsh-client-web/use-this-package/viewport-sizing: - en: e7b19d8f2c771b70 - zh: fe517c603cb5a162 + en: 3105391bad2e9f06 + zh: fe0c5af5db6c241c /deepseek-ai-dsh-client-web/use-this-package/what-boot-looks-like: en: f3b01aa878764e5c zh: f02eab65d441bfe0 diff --git a/packages/client/web/README.md b/packages/client/web/README.md index 9d88f398fc..93f6bb9529 100644 --- a/packages/client/web/README.md +++ b/packages/client/web/README.md @@ -31,19 +31,8 @@ Static application pages install `__DSH_BOOT_READY__` before the entry runs. The The shell base styles apply automatic CJK/Latin spacing to ordinary content in supporting browsers. Semantic code and terminal, diff, read, and search output containers retain literal source spacing and column alignment; browsers without `text-autospace` support ignore both declarations. -The shell sets text-size adjustment to 100%, so mobile browsers render configured font sizes without automatically enlarging text after viewport changes. Application font-size preferences still apply. - Web and Desktop mathematical rendering requires WOFF2 support. The [Web build](../../../apps/web/katex-fonts.ts) retains every KaTeX font face in WOFF2 and omits WOFF/TTF fallbacks; a face without WOFF2 rejects the build. Font glyphs, weights, styles, and layout rules are preserved. - -### Viewport sizing - -The root fills the CSS layout viewport with absolute positioning. The browser pans the page to reveal focused inputs; inner panes own content scrolling. - -The root applies horizontal safe-area padding and publishes `--dsh-safe-area-top` and `--dsh-safe-area-bottom`. The layout frame consumes these as vertical padding, keeping its sidebar and conversation, including the composer, inside the safe area. - -The [Web application entry](../../../apps/web/index.html) declares `width=device-width, initial-scale=1, viewport-fit=cover` without limiting user zoom. Touch inputs use a minimum font size of 16px to avoid focus-triggered page enlargement. - ### What boot looks like Boot runs in two stages: the module stage adopts the parser-loaded bootstrap batch, builds the module system from the Host-provided boot graph, and prefetches the `immediately` tier through the shared application-batch URL, which executes once. The plugin stage then activates every graph entry and waits for all of them before handing the marked boot DOM to the UI renderer, which hydrates it and switches to the complete UI. diff --git a/packages/client/web/README.zh.md b/packages/client/web/README.zh.md index 3c181edf65..c913362067 100644 --- a/packages/client/web/README.zh.md +++ b/packages/client/web/README.zh.md @@ -31,19 +31,8 @@ kind: "package-library" 外壳基础样式会在支持的浏览器中为普通内容自动添加中西文间距。语义化代码以及终端、diff、读取和搜索输出容器会保留源码中的原始间距和列对齐;不支持 `text-autospace` 的浏览器会忽略这两项声明。 -外壳将文字尺寸调整比例设为 100%,让移动浏览器按配置的字号渲染文字,避免视口变化后自动放大。应用内的字号偏好仍然生效。 - Web 和 Desktop 的数学公式渲染要求支持 WOFF2。[Web 构建](../../../apps/web/katex-fonts.ts)以 WOFF2 保留全部 KaTeX 字体样式,并排除 WOFF/TTF 后备格式;任一字体样式缺少 WOFF2 都会使构建失败。字体的字形、字重、样式和布局规则保持不变。 - -### 视口尺寸 - -根容器通过绝对定位铺满 CSS 布局视口。浏览器平移页面以露出获得焦点的输入框,内容滚动由内部面板负责。 - -根容器应用左右安全区边距,并发布 `--dsh-safe-area-top` 和 `--dsh-safe-area-bottom`。布局框架将这两个值用于上下内边距,使侧栏和包含输入框的会话区域位于安全区内。 - -[Web 应用入口](../../../apps/web/index.html)声明 `width=device-width, initial-scale=1, viewport-fit=cover`,不限制用户缩放。触摸输入框使用至少 16px 的字号,避免获得焦点时自动放大页面。 - ### 启动过程是怎样的 启动分两个阶段:模块阶段接纳 parser 已加载的 bootstrap 批次,从 Host 提供的启动图构建模块系统,并通过只执行一次的共享 application 批次 URL 预取 `immediately` 层级。插件阶段随后激活每个图 entry 并等待全部就绪,之后才把带标记的启动 DOM 交给 UI 渲染器,由它 hydrate 并切换到完整 UI。 diff --git a/packages/client/web/src/base.css b/packages/client/web/src/base.css index 3cb02ff38c..af74988cf1 100644 --- a/packages/client/web/src/base.css +++ b/packages/client/web/src/base.css @@ -8,30 +8,6 @@ body, margin: 0; } -html, -body { - overflow: hidden; -} - -html { - -webkit-text-size-adjust: 100%; - text-size-adjust: 100%; -} - -/* Inner panes own scrolling. The browser pans focused inputs without resizing - the application or recentering its content when the keyboard opens. */ -#root { - --dsh-safe-area-top: env(safe-area-inset-top, 0px); - --dsh-safe-area-bottom: env(safe-area-inset-bottom, 0px); - position: absolute; - top: 0; - left: 0; - width: 100%; - height: 100%; - box-sizing: border-box; - padding-inline: env(safe-area-inset-left, 0px) env(safe-area-inset-right, 0px); -} - body { font-family: var( --dsw-font-family, diff --git a/tsconfig.host.json b/tsconfig.host.json index b66c2e0986..4ac3d43a4d 100644 --- a/tsconfig.host.json +++ b/tsconfig.host.json @@ -102,7 +102,6 @@ "apps/web/tests/settings-chrome.e2e.ts", "apps/web/tests/session-log-upload.e2e.ts", "apps/web/tests/caption-overlays.e2e.ts", - "apps/web/tests/safe-area.e2e.ts", "apps/web/tests/settings-appearance.e2e.ts", "apps/web/tests/menu-material.e2e.ts", "apps/web/tests/desktop-locale.e2e.ts",